Why does adding a dashboard widget in includes/admin.php fail?

Question

Does includes/admin.php have special status I don’t understand?

This is my dash widget code:


add_action('wp_dashboard_setup', 'custom_dashboard_widgets');

function custom_dashboard_widgets() {
  global $wp_meta_boxes;
  error_log("I love testing!");
  wp_add_dashboard_widget('test_dash', 'Test Dash', 'test_dash');
}

function test_dash(){
  echo "Test";
}
?>

If I put that code in includes/dash.php it works perfectly. If I put it in includes/admin.php nothing happens. Both files are included in the plugin using the same method:

require_once('includes/admin.php');
require_once('includes/dash.php');

0
dtw 5 months 2022-07-22T05:46:33-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse