File tree Expand file tree Collapse file tree 3 files changed +43
-2
lines changed
tests/phpunit/integration/Core/Admin Expand file tree Collapse file tree 3 files changed +43
-2
lines changed Original file line number Diff line number Diff line change @@ -129,8 +129,7 @@ public function add( Context $context ) {
129
129
function () use ( $ context ) {
130
130
$ this ->render ( $ context );
131
131
},
132
- $ context ->url ( 'dist/assets/images/logo-g_white_small.png ' ),
133
- 3
132
+ $ context ->url ( 'dist/assets/images/logo-g_white_small.png ' )
134
133
);
135
134
$ menu_slug = $ this ->slug ;
136
135
}
Original file line number Diff line number Diff line change @@ -127,6 +127,21 @@ function() {
127
127
add_action ( 'admin_notices ' , $ remove_notices_callback , -9999 );
128
128
add_action ( 'network_admin_notices ' , $ remove_notices_callback , -9999 );
129
129
add_action ( 'all_admin_notices ' , $ remove_notices_callback , -9999 );
130
+
131
+ add_filter ( 'custom_menu_order ' , '__return_true ' );
132
+ add_filter (
133
+ 'menu_order ' ,
134
+ function ( array $ menu_order ) {
135
+ $ new_order = array ();
136
+ foreach ( $ menu_order as $ index => $ item ) {
137
+ if ( 'index.php ' === $ item || 0 === strpos ( $ item , self ::PREFIX ) ) {
138
+ $ new_order [] = $ item ;
139
+ unset( $ menu_order [ $ index ] );
140
+ }
141
+ }
142
+ return array_values ( array_merge ( $ new_order , $ menu_order ) );
143
+ }
144
+ );
130
145
}
131
146
132
147
/**
Original file line number Diff line number Diff line change @@ -95,4 +95,31 @@ public function test_removal_of_admin_notices_outside_sitekit( $hookname ) {
95
95
do_action ( $ hookname );
96
96
$ this ->assertNotEmpty ( ob_get_clean () );
97
97
}
98
+
99
+ public function test_menu_order () {
100
+ $ menu_order = array (
101
+ 'index.php ' ,
102
+ 'third-party-plugin ' ,
103
+ 'edit.php ' ,
104
+ 'options-general.php ' ,
105
+ 'googlesitekit-dashboard ' ,
106
+ );
107
+
108
+ $ this ->screens ->register ();
109
+
110
+ // Imitate WordPress core running these filters.
111
+ if ( apply_filters ( 'custom_menu_order ' , false ) ) {
112
+ $ menu_order = apply_filters ( 'menu_order ' , $ menu_order );
113
+ }
114
+
115
+ $ expected_order = array (
116
+ 'index.php ' ,
117
+ 'googlesitekit-dashboard ' ,
118
+ 'third-party-plugin ' ,
119
+ 'edit.php ' ,
120
+ 'options-general.php ' ,
121
+ );
122
+
123
+ $ this ->assertEquals ( $ expected_order , $ menu_order );
124
+ }
98
125
}
You can’t perform that action at this time.
0 commit comments