Opened 20 months ago

Closed 20 months ago

Last modified 20 months ago

#18879 closed defect (bug) (invalid)

Impossible to use wp_admin_bar_class filter

Reported by: geminorum 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)

18879.patch (531 bytes) - added by kurtpayne 20 months ago.

Download all attachments as: .zip

Change History (8)

  • Keywords needs-patch added

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

  • Keywords has-patch added; needs-patch removed
  • Cc kpayne@… 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>&nbsp;</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.

  • Milestone Awaiting Review deleted
  • Keywords has-patch reporter-feedback removed
Note: See TracTickets for help on using tickets.