diff --git a/src/wp-includes/class-wp-admin-bar.php b/src/wp-includes/class-wp-admin-bar.php index dc6ea0993c..43bdadccd6 100644 --- a/src/wp-includes/class-wp-admin-bar.php +++ b/src/wp-includes/class-wp-admin-bar.php @@ -19,21 +19,14 @@ class WP_Admin_Bar { public $user; /** - * @since 3.3.0 + * Deprecated menu property. * - * @param string $name - * @return string|array|void + * @since 3.1.0 + * @deprecated 3.3.0 Modify admin bar nodes with WP_Admin_Bar::get_node(), + * WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(). + * @var array */ - public function __get( $name ) { - switch ( $name ) { - case 'proto': - return is_ssl() ? 'https://' : 'http://'; - - case 'menu': - _deprecated_argument( 'WP_Admin_Bar', '3.3.0', 'Modify admin bar nodes with WP_Admin_Bar::get_node(), WP_Admin_Bar::add_node(), and WP_Admin_Bar::remove_node(), not the menu property.' ); - return array(); // Sorry, folks. - } - } + public $menu = array(); /** * Initializes the admin bar. diff --git a/tests/phpunit/tests/adminbar.php b/tests/phpunit/tests/adminbar.php index cec80d0cae..aa8043e7ec 100644 --- a/tests/phpunit/tests/adminbar.php +++ b/tests/phpunit/tests/adminbar.php @@ -754,4 +754,33 @@ class Tests_AdminBar extends WP_UnitTestCase { 'network-admin-o' => 'manage_network_options', ); } + + /** + * This test ensures that WP_Admin_Bar::$proto is not defined (including magic methods). + * + * @ticket 56876 + * @coversNothing + */ + public function test_proto_property_is_not_defined() { + $admin_bar = new WP_Admin_Bar(); + $this->assertFalse( property_exists( $admin_bar, 'proto' ), 'WP_Admin_Bar::$proto should not be defined.' ); + $this->assertFalse( isset( $admin_bar->proto ), 'WP_Admin_Bar::$proto should not be defined.' ); + } + + /** + * This test ensures that WP_Admin_Bar::$menu is declared as a "regular" class property. + * + * @ticket 56876 + * @coversNothing + */ + public function test_menu_property_is_defined() { + $admin_bar = new WP_Admin_Bar(); + $this->assertTrue( property_exists( $admin_bar, 'menu' ), 'WP_Admin_Bar::$proto property should be defined.' ); + + $menu_property = new ReflectionProperty( WP_Admin_Bar::class, 'menu' ); + $this->assertTrue( $menu_property->isPublic(), 'WP_Admin_Bar::$menu should be public.' ); + + $this->assertTrue( isset( $admin_bar->menu ), 'WP_Admin_Bar::$menu should be set.' ); + $this->assertSame( array(), $admin_bar->menu, 'WP_Admin_Bar::$menu should be equal to an empty array.' ); + } }