1

There are so many resources on how to enable, disable, change and fix the admin bar, but per a question from a student, we just want to follow the path to how it's made.

What we know: 1. The trail starts with footer.php -> wp_footer(); 2. The trail ends with wp_includes/adminbar.php

What's the trail in the middle?

2

Here is the backtrace of the adminbar rendering in the home page of the backend for WordPress 4.9.2

array (
  'file' => 'wp-admin/index.php',
  'line' => 100,
  'function' => 'include',
)
array (
  'file' => 'wp-admin/admin-header.php',
  'line' => 219,
  'function' => 'do_action',
)
array (
  'file' => 'wp-includes/plugin.php',
  'line' => 457,
  'function' => 'do_action',
  'class' => 'WP_Hook',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-hook.php',
  'line' => 310,
  'function' => 'apply_filters',
  'class' => 'WP_Hook',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-hook.php',
  'line' => 286,
  'function' => 'wp_admin_bar_render',
)
array (
  'file' => 'wp-includes/admin-bar.php',
  'line' => 92,
  'function' => 'render',
  'class' => 'WP_Admin_Bar',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-admin-bar.php',
  'line' => 263,
  'function' => '_render',
  'class' => 'WP_Admin_Bar',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-admin-bar.php',
  'line' => 413,
)

and here the path on the home page

array (
  'file' => 'index.php',
  'line' => 17,
  'function' => 'require',
)
array (
  'file' => 'wp-blog-header.php',
  'line' => 19,
  'function' => 'require_once',
)
array (
  'file' => 'wp-includes/template-loader.php',
  'line' => 74,
  'function' => 'include',
)
array (
  'file' => 'wp-content/themes/storefront/page.php',
  'line' => 38,
  'function' => 'get_footer',
)
array (
  'file' => 'wp-includes/general-template.php',
  'line' => 76,
  'function' => 'locate_template',
)
array (
  'file' => 'wp-includes/template.php',
  'line' => 647,
  'function' => 'load_template',
)
array (
  'file' => 'wp-includes/template.php',
  'line' => 688,
  'function' => 'require_once',
)
array (
  'file' => 'wp-content/themes/storefront/footer.php',
  'line' => 36,
  'function' => 'wp_footer',
)
array (
  'file' => 'wp-includes/general-template.php',
  'line' => 2630,
  'function' => 'do_action',
)
array (
  'file' => 'wp-includes/plugin.php',
  'line' => 457,
  'function' => 'do_action',
  'class' => 'WP_Hook',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-hook.php',
  'line' => 310,
  'function' => 'apply_filters',
  'class' => 'WP_Hook',
  'type' => '->',
)
array (
  'file' => 'wp-includes/class-wp-hook.php',
  'line' => 286,
  'function' => 'wp_admin_bar_render',
)
6
  • How did you do that? And why doesn't the footer call show up? – Nora McDougall-Collins Feb 3 '18 at 0:07
  • 1
    @NoraMcDougall-Collins wp_footer is front end only, this was from the Backend. The relevant action here is in_admin_header which is the second item in the backtrace (wp-admin/admin-header.php:219). Can't speak for how mmm did it, but you yould hook into the admin_bar_init action and then use debug_backtrace to get the info. – janh Feb 3 '18 at 0:44
  • 1
    @janh it's totally that, I use php.net/debug_backtrace to find such paths. – mmm Feb 3 '18 at 10:28
  • If I understand your comments correctly, I believe that my original question was not specific enough. What I didn't realize is that the admin bar may be called through a different path from the backend (Dashboard) than it is when it shows on the front end (Viewer side) when the viewer is logged in. – Nora McDougall-Collins Feb 3 '18 at 16:30
  • oh yes, I forget the frontend. I have edited my question to add the trace on the home page. – mmm Feb 3 '18 at 22:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.