#18879 closed defect (bug) (invalid)
Impossible to use wp_admin_bar_class filter
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | General | Version: | 3.2.1 |
| Severity: | normal | Keywords: | |
| Cc: | kpayne@… |
Description
wanting to extend WP_Admin_Bar class, cannot include the class-wp-admin-bar.php for a fatal (cannot redeclare class). because of require() instead of require_once() on _wp_admin_bar_init()
Attachments (1)
Change History (8)
comment:1
volcanicpixels — 20 months ago
- Keywords needs-patch added
- Keywords reporter-feedback added
There is no need to require class-wp-admin-bar.php a second time. If you're extending it, then it's already loaded by the time the 'wp_admin_bar_class' filter is fired.
Test code:
<?php
function check_wp_admin_bar_class( $class ) {
class My_Admin_Bar extends WP_Admin_Bar {
}
echo '<p> </p><p><pre>'; var_dump( class_exists( 'My_Admin_Bar' ) ); echo '</pre></p>';
return 'My_Admin_Bar';
}
add_action( 'wp_admin_bar_class', 'check_wp_admin_bar_class' );
- Resolution set to invalid
- Status changed from new to closed
kawauso's way works, sorry to bother.
Note: See
TracTickets for help on using
tickets.

Seems like a valid bug. I'll get a patch for it.