From 425ceaddae4a6b45a65cd7bef0c29ffb87d8d786 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Mon, 13 Jan 2025 10:56:50 -0500 Subject: [PATCH 1/4] [MOOSE-172]: use menu_order to reorder admin menu --- wp-content/plugins/core/src/Core.php | 1 + .../plugins/core/src/Menus/Menu_Order.php | 39 +++++++++++++++++++ .../core/src/Menus/Menu_Subscriber.php | 19 +++++++++ .../core/src/Post_Types/Training/Config.php | 7 ++-- 4 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 wp-content/plugins/core/src/Menus/Menu_Order.php create mode 100644 wp-content/plugins/core/src/Menus/Menu_Subscriber.php diff --git a/wp-content/plugins/core/src/Core.php b/wp-content/plugins/core/src/Core.php index 7f8acf70..384525bb 100644 --- a/wp-content/plugins/core/src/Core.php +++ b/wp-content/plugins/core/src/Core.php @@ -29,6 +29,7 @@ class Core { Integrations\Integrations_Subscriber::class, Object_Meta\Meta_Subscriber::class, Theme_Config\Theme_Config_Subscriber::class, + Menus\Menu_Subscriber::class, // Post Types Post_Types\Page\Page_Subscriber::class, diff --git a/wp-content/plugins/core/src/Menus/Menu_Order.php b/wp-content/plugins/core/src/Menus/Menu_Order.php new file mode 100644 index 00000000..db480906 --- /dev/null +++ b/wp-content/plugins/core/src/Menus/Menu_Order.php @@ -0,0 +1,39 @@ +site_has_custom_menu_order() ) { + return $menu_ord; + } + + return [ + 'index.php', + 'separator1', + 'edit.php?post_type=page', + // place CPTs here + 'edit.php', + 'upload.php', + 'gf_edit_forms', + 'separator2', + 'themes.php', + 'plugins.php', + 'users.php', + 'tools.php', + 'options-general.php', + 'edit.php?post_type=training', + 'separator-last', + 'edit.php?post_type=acf-field-group', + 'rank-math', + ]; + } + +} diff --git a/wp-content/plugins/core/src/Menus/Menu_Subscriber.php b/wp-content/plugins/core/src/Menus/Menu_Subscriber.php new file mode 100644 index 00000000..ae30097a --- /dev/null +++ b/wp-content/plugins/core/src/Menus/Menu_Subscriber.php @@ -0,0 +1,19 @@ +container->get( Menu_Order::class )->site_has_custom_menu_order(); + } ); + + add_filter( 'menu_order', function ( array $menu_ord ): array { + return $this->container->get( Menu_Order::class )->custom_menu_order( $menu_ord ); + } ); + } + +} diff --git a/wp-content/plugins/core/src/Post_Types/Training/Config.php b/wp-content/plugins/core/src/Post_Types/Training/Config.php index 5f94ac2b..2ffa8af8 100644 --- a/wp-content/plugins/core/src/Post_Types/Training/Config.php +++ b/wp-content/plugins/core/src/Post_Types/Training/Config.php @@ -29,9 +29,10 @@ public function get_args(): array { public function get_labels(): array { return [ - 'singular' => __( 'Training Doc', 'tribe' ), - 'plural' => __( 'Training Docs', 'tribe' ), - 'slug' => $this->post_type, + 'singular' => __( 'Training Doc', 'tribe' ), + 'plural' => __( 'Training Docs', 'tribe' ), + 'menu_name' => __( 'Training', 'tribe' ), + 'slug' => $this->post_type, ]; } From ae3be79cc5ca15b7c1ad4889d4878876d2662323 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Mon, 13 Jan 2025 16:23:59 -0500 Subject: [PATCH 2/4] [MOOSE-172]: order subscribers; remove const/conditional --- wp-content/plugins/core/src/Core.php | 4 ++-- .../Menus/{Menu_Order.php => Admin_Menu_Order.php} | 14 ++------------ .../plugins/core/src/Menus/Menu_Subscriber.php | 8 +++----- 3 files changed, 7 insertions(+), 19 deletions(-) rename wp-content/plugins/core/src/Menus/{Menu_Order.php => Admin_Menu_Order.php} (59%) diff --git a/wp-content/plugins/core/src/Core.php b/wp-content/plugins/core/src/Core.php index 384525bb..e13c99d3 100644 --- a/wp-content/plugins/core/src/Core.php +++ b/wp-content/plugins/core/src/Core.php @@ -23,13 +23,13 @@ class Core { * @var string[] Names of classes extending Abstract_Subscriber. */ private array $subscribers = [ - Settings\Settings_Subscriber::class, Assets\Assets_Subscriber::class, Blocks\Blocks_Subscriber::class, Integrations\Integrations_Subscriber::class, + Menus\Menu_Subscriber::class, Object_Meta\Meta_Subscriber::class, + Settings\Settings_Subscriber::class, Theme_Config\Theme_Config_Subscriber::class, - Menus\Menu_Subscriber::class, // Post Types Post_Types\Page\Page_Subscriber::class, diff --git a/wp-content/plugins/core/src/Menus/Menu_Order.php b/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php similarity index 59% rename from wp-content/plugins/core/src/Menus/Menu_Order.php rename to wp-content/plugins/core/src/Menus/Admin_Menu_Order.php index db480906..5972bfb0 100644 --- a/wp-content/plugins/core/src/Menus/Menu_Order.php +++ b/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php @@ -2,19 +2,9 @@ namespace Tribe\Plugin\Menus; -class Menu_Order { - - public const SITE_HAS_CUSTOM_MENU_ORDER = true; - - public function site_has_custom_menu_order(): bool { - return self::SITE_HAS_CUSTOM_MENU_ORDER; - } - - public function custom_menu_order( array $menu_ord ): array { - if ( ! $this->site_has_custom_menu_order() ) { - return $menu_ord; - } +class Admin_Menu_Order { + public function custom_menu_order(): array { return [ 'index.php', 'separator1', diff --git a/wp-content/plugins/core/src/Menus/Menu_Subscriber.php b/wp-content/plugins/core/src/Menus/Menu_Subscriber.php index ae30097a..999a1329 100644 --- a/wp-content/plugins/core/src/Menus/Menu_Subscriber.php +++ b/wp-content/plugins/core/src/Menus/Menu_Subscriber.php @@ -7,12 +7,10 @@ class Menu_Subscriber extends Abstract_Subscriber { public function register(): void { - add_filter( 'custom_menu_order', function (): bool { - return $this->container->get( Menu_Order::class )->site_has_custom_menu_order(); - } ); + add_filter( 'custom_menu_order', '__return_true' ); - add_filter( 'menu_order', function ( array $menu_ord ): array { - return $this->container->get( Menu_Order::class )->custom_menu_order( $menu_ord ); + add_filter( 'menu_order', function (): array { + return $this->container->get( Admin_Menu_Order::class )->custom_menu_order(); } ); } From aa24712d77f76ab5f9402ee05577a7fac1075399 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Wed, 15 Jan 2025 10:34:27 -0500 Subject: [PATCH 3/4] [MOOSE-172]: changelog; add yoast --- CHANGELOG.md | 2 ++ wp-content/plugins/core/src/Menus/Admin_Menu_Order.php | 1 + 2 files changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70315b35..c8d64fd5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,8 @@ item (Added, Changed, Depreciated, Removed, Fixed, Security). ## [2025.01] +- Added: `Admin_Menu_Order` class to handle reordering the WP Admin menu items that Moose loads with by default. + This also includes Yoast SEO & RankMath, just in case either are used by default. - Added: Node service to Lando so FE assets can be built automatically on start up. - Updated: project start up scripts to automatically generate the correct contents of the lcoal config files. - Updated: script to install WordPress so we can use a version constant and not install WP every time composer is diff --git a/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php b/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php index 5972bfb0..704dc2ed 100644 --- a/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php +++ b/wp-content/plugins/core/src/Menus/Admin_Menu_Order.php @@ -22,6 +22,7 @@ public function custom_menu_order(): array { 'edit.php?post_type=training', 'separator-last', 'edit.php?post_type=acf-field-group', + 'wpseo_dashboard', 'rank-math', ]; } From 021183e19a638771045267ee644161773f10ebf1 Mon Sep 17 00:00:00 2001 From: Geoff Dusome Date: Wed, 15 Jan 2025 10:35:37 -0500 Subject: [PATCH 4/4] [MOOSE-172]: changelog typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8d64fd5..1e6e85c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ item (Added, Changed, Depreciated, Removed, Fixed, Security). - Updated: project start up scripts to automatically generate the correct contents of the lcoal config files. - Updated: script to install WordPress so we can use a version constant and not install WP every time composer is installed or updated. -- Updated: ESLint config now supports browser environment variable such as `IntersectionObserver` +- Updated: ESLint config now supports browser environment variables such as `IntersectionObserver` - Added: ability for table blocks to utilize the `overflow-x` set on them by setting a `min-width` property for the `table` element within the table block. - Updated: Enabled background images on the Group block; We should try to use this instead of the Cover block where