PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-beta
Jetpack – WP Security, Backup, Speed, & Growth v16.3-beta
16.3-beta 16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 All 507 releases
← All changes | jetpack_vendor/automattic/jetpack-masterbar/src/admin-menu/class-admin-menu.php +18 -314 13.6.2 → 16.3-beta View file →
@@ -6,11 +6,8 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Masterbar;
9 9
10 -use Automattic\Jetpack\Assets\Logo;
11 -use Automattic\Jetpack\Redirect;
12 -
13 10 require_once __DIR__ . '/class-base-admin-menu.php';
14 11
15 12 /**
16 13 * Class Admin_Menu.
@@ -20,24 +17,11 @@
20 17 /**
21 18 * Create the desired menu output.
22 19 */
23 20 public function reregister_menu_items() {
24 - // Remove separators.
25 - remove_menu_page( 'separator1' );
26 - $this->add_stats_menu();
27 - $this->add_upgrades_menu();
28 - $this->add_posts_menu();
29 - $this->add_media_menu();
30 - $this->add_page_menu();
31 - $this->add_testimonials_menu();
32 - $this->add_portfolio_menu();
33 - $this->add_comments_menu();
34 21 $this->add_appearance_menu();
35 22 $this->add_plugins_menu();
36 23 $this->add_users_menu();
37 - $this->add_tools_menu();
38 - $this->add_options_menu();
39 - $this->add_jetpack_menu();
40 24
41 25 // Remove Links Manager menu since its usage is discouraged. https://github.com/Automattic/wp-calypso/issues/51188.
42 26 // @see https://core.trac.wordpress.org/ticket/21307#comment:73.
43 27 if ( $this->should_disable_links_manager() ) {
@@ -100,172 +84,8 @@
100 84 return true;
101 85 }
102 86
103 87 /**
104 - * Adds My Home menu.
105 - */
106 - public function add_my_home_menu() {
107 -
108 - if ( self::DEFAULT_VIEW !== $this->get_preferred_view( 'index.php' ) ) {
109 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
110 - add_menu_page( __( 'My Home', 'jetpack-masterbar' ), __( 'My Home', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/home/' . $this->domain, null, 'dashicons-admin-home', 1.5 );
111 - return;
112 - }
113 -
114 - $this->update_menu( 'index.php', 'https://wordpress.com/home/' . $this->domain, __( 'My Home', 'jetpack-masterbar' ), 'read', 'dashicons-admin-home' );
115 - }
116 -
117 - /**
118 - * Adds My Mailboxes menu.
119 - */
120 - public function add_my_mailboxes_menu() {
121 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
122 - add_menu_page( __( 'My Mailboxes', 'jetpack-masterbar' ), __( 'My Mailboxes', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/mailboxes/' . $this->domain, null, 'dashicons-email', 4.64424 );
123 - }
124 -
125 - /**
126 - * Adds Stats menu.
127 - */
128 - public function add_stats_menu() {
129 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
130 - add_menu_page( __( 'Stats', 'jetpack-masterbar' ), __( 'Stats', 'jetpack-masterbar' ), 'view_stats', 'https://wordpress.com/stats/day/' . $this->domain, null, 'dashicons-chart-bar', 3 );
131 - }
132 -
133 - /**
134 - * Adds Upgrades menu.
135 - *
136 - * @param string $plan The current WPCOM plan of the blog.
137 - */
138 - public function add_upgrades_menu( $plan = null ) {
139 - global $menu;
140 -
141 - $menu_exists = false;
142 - foreach ( $menu as $item ) {
143 - if ( 'paid-upgrades.php' === $item[2] ) {
144 - $menu_exists = true;
145 - break;
146 - }
147 - }
148 -
149 - if ( ! $menu_exists ) {
150 - if ( $plan ) {
151 - // Add display:none as a default for cases when CSS is not loaded.
152 - $site_upgrades = '%1$s<span class="inline-text" style="display:none">%2$s</span>';
153 - $site_upgrades = sprintf(
154 - $site_upgrades,
155 - __( 'Upgrades', 'jetpack-masterbar' ),
156 - // phpcs:ignore WordPress.WP.I18n.NonSingularStringLiteralText
157 - __( $plan, 'jetpack-masterbar' )
158 - );
159 - } else {
160 - $site_upgrades = __( 'Upgrades', 'jetpack-masterbar' );
161 - }
162 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
163 - add_menu_page( __( 'Upgrades', 'jetpack-masterbar' ), $site_upgrades, 'manage_options', 'paid-upgrades.php', null, 'dashicons-cart', 4 );
164 - }
165 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
166 - add_submenu_page( 'paid-upgrades.php', __( 'Plans', 'jetpack-masterbar' ), __( 'Plans', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/plans/' . $this->domain, null, 1 );
167 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
168 - add_submenu_page( 'paid-upgrades.php', __( 'Purchases', 'jetpack-masterbar' ), __( 'Purchases', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/purchases/subscriptions/' . $this->domain, null, 2 );
169 -
170 - if ( ! $menu_exists ) {
171 - // Remove the submenu auto-created by Core.
172 - $this->hide_submenu_page( 'paid-upgrades.php', 'paid-upgrades.php' );
173 - }
174 - }
175 -
176 - /**
177 - * Adds Posts menu.
178 - */
179 - public function add_posts_menu() {
180 - $submenus_to_update = array();
181 -
182 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'edit.php' ) ) {
183 - $submenus_to_update['edit.php'] = 'https://wordpress.com/posts/' . $this->domain;
184 - $submenus_to_update['post-new.php'] = 'https://wordpress.com/post/' . $this->domain;
185 - $this->update_submenus( 'edit.php', $submenus_to_update );
186 - }
187 -
188 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'edit-tags.php?taxonomy=category' ) ) {
189 - $this->update_submenus( 'edit.php', array( 'edit-tags.php?taxonomy=category' => 'https://wordpress.com/settings/taxonomies/category/' . $this->domain ) );
190 - }
191 -
192 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'edit-tags.php?taxonomy=post_tag' ) ) {
193 - $this->update_submenus( 'edit.php', array( 'edit-tags.php?taxonomy=post_tag' => 'https://wordpress.com/settings/taxonomies/post_tag/' . $this->domain ) );
194 - }
195 - }
196 -
197 - /**
198 - * Adds Media menu.
199 - */
200 - public function add_media_menu() {
201 - if ( self::CLASSIC_VIEW === $this->get_preferred_view( 'upload.php' ) ) {
202 - return;
203 - }
204 -
205 - $this->hide_submenu_page( 'upload.php', 'media-new.php' );
206 -
207 - $this->update_menu( 'upload.php', 'https://wordpress.com/media/' . $this->domain );
208 - }
209 -
210 - /**
211 - * Adds Page menu.
212 - */
213 - public function add_page_menu() {
214 - if ( self::CLASSIC_VIEW === $this->get_preferred_view( 'edit.php?post_type=page' ) ) {
215 - return;
216 - }
217 -
218 - $submenus_to_update = array(
219 - 'edit.php?post_type=page' => 'https://wordpress.com/pages/' . $this->domain,
220 - 'post-new.php?post_type=page' => 'https://wordpress.com/page/' . $this->domain,
221 - );
222 - $this->update_submenus( 'edit.php?post_type=page', $submenus_to_update );
223 - }
224 -
225 - /**
226 - * Adds Testimonials menu.
227 - */
228 - public function add_testimonials_menu() {
229 - $this->add_custom_post_type_menu( 'jetpack-testimonial' );
230 - }
231 -
232 - /**
233 - * Adds Portfolio menu.
234 - */
235 - public function add_portfolio_menu() {
236 - $this->add_custom_post_type_menu( 'jetpack-portfolio' );
237 - }
238 -
239 - /**
240 - * Adds a custom post type menu.
241 - *
242 - * @param string $post_type Custom post type.
243 - */
244 - public function add_custom_post_type_menu( $post_type ) {
245 - if ( self::CLASSIC_VIEW === $this->get_preferred_view( 'edit.php?post_type=' . $post_type ) ) {
246 - return;
247 - }
248 -
249 - $submenus_to_update = array(
250 - 'edit.php?post_type=' . $post_type => 'https://wordpress.com/types/' . $post_type . '/' . $this->domain,
251 - 'post-new.php?post_type=' . $post_type => 'https://wordpress.com/edit/' . $post_type . '/' . $this->domain,
252 - );
253 - $this->update_submenus( 'edit.php?post_type=' . $post_type, $submenus_to_update );
254 - }
255 -
256 - /**
257 - * Adds Comments menu.
258 - */
259 - public function add_comments_menu() {
260 - if ( self::CLASSIC_VIEW === $this->get_preferred_view( 'edit-comments.php' ) ) {
261 - return;
262 - }
263 -
264 - $this->update_menu( 'edit-comments.php', 'https://wordpress.com/comments/all/' . $this->domain );
265 - }
266 -
267 - /**
268 88 * Adds Appearance menu.
269 89 *
270 90 * @return string The Customizer URL.
271 91 */
@@ -333,152 +153,30 @@
333 153 }
334 154
335 155 $slug = current_user_can( 'list_users' ) ? 'users.php' : 'profile.php';
336 156 $this->update_submenus( $slug, $submenus_to_update );
337 - add_submenu_page( $slug, esc_attr__( 'Account Settings', 'jetpack-masterbar' ), __( 'Account Settings', 'jetpack-masterbar' ), 'read', 'https://wordpress.com/me/account' );
338 157 }
339 158
340 159 /**
341 - * Adds Tools menu.
342 - */
343 - public function add_tools_menu() {
344 - $submenus_to_update = array();
345 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'import.php' ) ) {
346 - $submenus_to_update['import.php'] = 'https://wordpress.com/import/' . $this->domain;
347 - }
348 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'export.php' ) ) {
349 - $submenus_to_update['export.php'] = 'https://wordpress.com/export/' . $this->domain;
350 - }
351 - $this->update_submenus( 'tools.php', $submenus_to_update );
352 -
353 - $this->hide_submenu_page( 'tools.php', 'tools.php' );
354 - $this->hide_submenu_page( 'tools.php', 'delete-blog' );
355 -
356 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
357 - add_submenu_page( 'tools.php', esc_attr__( 'Marketing', 'jetpack-masterbar' ), __( 'Marketing', 'jetpack-masterbar' ), 'publish_posts', 'https://wordpress.com/marketing/tools/' . $this->domain, null, 0 );
358 - if ( ! $this->use_wp_admin_interface() ) {
359 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
360 - add_submenu_page( 'tools.php', esc_attr__( 'Monetize', 'jetpack-masterbar' ), __( 'Monetize', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/earn/' . $this->domain, null, 1 );
361 - }
362 - }
363 -
364 - /**
365 - * Adds Settings menu.
366 - */
367 - public function add_options_menu() {
368 - $submenus_to_update = array();
369 -
370 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'options-general.php' ) ) {
371 - $this->hide_submenu_page( 'options-general.php', 'sharing' );
372 - }
373 -
374 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'options-general.php' ) ) {
375 - $submenus_to_update['options-general.php'] = 'https://wordpress.com/settings/general/' . $this->domain;
376 - }
377 -
378 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'options-writing.php' ) ) {
379 - $submenus_to_update['options-writing.php'] = 'https://wordpress.com/settings/writing/' . $this->domain;
380 - }
381 -
382 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'options-reading.php' )
383 - ) {
384 - $submenus_to_update['options-reading.php'] = 'https://wordpress.com/settings/reading/' . $this->domain;
385 - }
386 -
387 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'options-discussion.php' ) ) {
388 - $submenus_to_update['options-discussion.php'] = 'https://wordpress.com/settings/discussion/' . $this->domain;
389 - }
390 -
391 - $this->update_submenus( 'options-general.php', $submenus_to_update );
392 -
393 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
394 - add_submenu_page( 'options-general.php', esc_attr__( 'Newsletter', 'jetpack-masterbar' ), __( 'Newsletter', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/newsletter/' . $this->domain, null, 7 );
395 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
396 - add_submenu_page( 'options-general.php', esc_attr__( 'Podcasting', 'jetpack-masterbar' ), __( 'Podcasting', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/podcasting/' . $this->domain, null, 8 );
397 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
398 - add_submenu_page( 'options-general.php', esc_attr__( 'Performance', 'jetpack-masterbar' ), __( 'Performance', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/settings/performance/' . $this->domain, null, 9 );
399 - }
400 -
401 - /**
402 - * Create Jetpack menu.
160 + * Renders the upsell nudge directly in the admin menu.
403 161 *
404 - * @param int $position Menu position.
405 - * @param bool $separator Whether to add a separator before the menu.
162 + * This renders server-side via the `adminmenu` hook to avoid the layout
163 + * shift caused by the previous AJAX-based approach.
406 164 */
407 - public function create_jetpack_menu( $position = 50, $separator = true ) {
408 - if ( $separator ) {
409 - $this->add_admin_menu_separator( $position, 'manage_options' );
410 - ++$position;
165 + public function render_upsell_nudge() {
166 + // Skip if jetpack-mu-wpcom is already rendering the upsell banner.
167 + if ( has_action( 'adminmenu', 'wpcom_add_sidebar_notice_menu_page' ) ) {
168 + return;
411 169 }
412 170
413 - $icon = ( new Logo() )->get_base64_logo();
414 - $is_menu_updated = $this->update_menu( 'jetpack', null, null, null, $icon, $position );
415 - if ( ! $is_menu_updated ) {
416 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
417 - add_menu_page( esc_attr__( 'Jetpack', 'jetpack-masterbar' ), __( 'Jetpack', 'jetpack-masterbar' ), 'manage_options', 'jetpack', null, $icon, $position );
171 + /** This action is already documented in \Automattic\Jetpack\JITMS\JITM */
172 + if ( ! apply_filters( 'jetpack_just_in_time_msgs', true ) ) {
173 + return;
418 174 }
419 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
420 - add_submenu_page( 'jetpack', esc_attr__( 'Activity Log', 'jetpack-masterbar' ), __( 'Activity Log', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/activity-log/' . $this->domain, null, 2 );
421 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
422 - add_submenu_page( 'jetpack', esc_attr__( 'Backup', 'jetpack-masterbar' ), __( 'Backup', 'jetpack-masterbar' ), 'manage_options', 'https://wordpress.com/backup/' . $this->domain, null, 3 );
423 175
424 - if ( self::DEFAULT_VIEW === $this->get_preferred_view( 'jetpack' ) ) {
425 - $this->hide_submenu_page( 'jetpack', 'jetpack#/settings' );
426 - $this->hide_submenu_page( 'jetpack', 'stats' );
427 - $this->hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-backups' ) ) );
428 - $this->hide_submenu_page( 'jetpack', esc_url( Redirect::get_url( 'calypso-scanner' ) ) );
429 - }
430 -
431 - if ( ! $is_menu_updated ) {
432 - // Remove the submenu auto-created by Core just to be sure that there no issues on non-admin roles.
433 - remove_submenu_page( 'jetpack', 'jetpack' );
434 - }
435 - }
436 -
437 - /**
438 - * Adds Jetpack menu.
439 - */
440 - public function add_jetpack_menu() {
441 - $this->create_jetpack_menu();
442 - }
443 -
444 - /**
445 - * Add the calypso /woocommerce-installation/ menu item.
446 - *
447 - * @param array $current_plan The site's plan if they have one. This is passed from WPcom_Admin_Menu to prevent
448 - * redundant database queries.
449 - */
450 - public function add_woocommerce_installation_menu( $current_plan = null ) {
451 - /**
452 - * Whether to show the WordPress.com WooCommerce Installation menu.
453 - *
454 - * @use add_filter( 'jetpack_show_wpcom_woocommerce_installation_menu', '__return_true' );
455 - * @module masterbar
456 - * @since jetpack-10.3.0
457 - * @param bool $jetpack_show_wpcom_woocommerce_installation_menu Load the WordPress.com WooCommerce Installation menu item. Default to false.
458 - * @param array $current_plan Data about the current site's plan.
459 - */
460 - if ( apply_filters( 'jetpack_show_wpcom_woocommerce_installation_menu', false, $current_plan ) ) {
461 - $this->add_admin_menu_separator( 54, 'activate_plugins' );
462 -
463 - $icon_url = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxMDI0IDEwMjQiPjxwYXRoIGZpbGw9IiNhMmFhYjIiIGQ9Ik02MTIuMTkyIDQyNi4zMzZjMC02Ljg5Ni0zLjEzNi01MS42LTI4LTUxLjYtMzcuMzYgMC00Ni43MDQgNzIuMjU2LTQ2LjcwNCA4Mi42MjQgMCAzLjQwOCAzLjE1MiA1OC40OTYgMjguMDMyIDU4LjQ5NiAzNC4xOTItLjAzMiA0Ni42NzItNzIuMjg4IDQ2LjY3Mi04OS41MnptMjAyLjE5MiAwYzAtNi44OTYtMy4xNTItNTEuNi0yOC4wMzItNTEuNi0zNy4yOCAwLTQ2LjYwOCA3Mi4yNTYtNDYuNjA4IDgyLjYyNCAwIDMuNDA4IDMuMDcyIDU4LjQ5NiAyNy45NTIgNTguNDk2IDM0LjE5Mi0uMDMyIDQ2LjY4OC03Mi4yODggNDYuNjg4LTg5LjUyek0xNDEuMjk2Ljc2OGMtNjguMjI0IDAtMTIzLjUwNCA1NS40ODgtMTIzLjUwNCAxMjMuOTJ2NjUwLjcyYzAgNjguNDMyIDU1LjI5NiAxMjMuOTIgMTIzLjUwNCAxMjMuOTJoMzM5LjgwOGwxMjMuNTA0IDEyMy45MzZWODk5LjMyOGgyNzguMDQ4YzY4LjIyNCAwIDEyMy41Mi01NS40NzIgMTIzLjUyLTEyMy45MnYtNjUwLjcyYzAtNjguNDMyLTU1LjI5Ni0xMjMuOTItMTIzLjUyLTEyMy45MmgtNzQxLjM2em01MjYuODY0IDQyMi4xNmMwIDU1LjA4OC0zMS4wODggMTU0Ljg4LTEwMi42NCAxNTQuODgtNi4yMDggMC0xOC40OTYtMy42MTYtMjUuNDI0LTYuMDE2LTMyLjUxMi0xMS4xNjgtNTAuMTkyLTQ5LjY5Ni01Mi4zNTItNjYuMjU2IDAgMC0zLjA3Mi0xNy43OTItMy4wNzItNDAuNzUyIDAtMjIuOTkyIDMuMDcyLTQ1LjMyOCAzLjA3Mi00NS4zMjggMTUuNTUyLTc1LjcyOCA0My41NTItMTA2LjczNiA5Ni40NDgtMTA2LjczNiA1OS4wNzItLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4ek00ODYuNDk2IDMwMi40YzAgMy4zOTItNDMuNTUyIDE0MS4xNjgtNDMuNTUyIDIxMy40MjR2NzUuNzEyYy0yLjU5MiAxMi4wOC00LjE2IDI0LjE0NC0yMS44MjQgMjQuMTQ0LTQ2LjYwOCAwLTg4Ljg4LTE1MS40NzItOTIuMDE2LTE2MS44NC02LjIwOCA2Ljg5Ni02Mi4yNCAxNjEuODQtOTYuNDQ4IDE2MS44NC0yNC44NjQgMC00My41NTItMTEzLjY0OC00Ni42MDgtMTIzLjkzNkMxNzYuNzA0IDQzNi42NzIgMTYwIDMzNC4yMjQgMTYwIDMyNy4zMjhjMC0yMC42NzIgMS4xNTItMzguNzM2IDI2LjA0OC0zOC43MzYgNi4yMDggMCAyMS42IDYuMDY0IDIzLjcxMiAxNy4xNjggMTEuNjQ4IDYyLjAzMiAxNi42ODggMTIwLjUxMiAyOS4xNjggMTg1Ljk2OCAxLjg1NiAyLjkyOCAxLjUwNCA3LjAwOCA0LjU2IDEwLjQzMiAzLjE1Mi0xMC4yODggNjYuOTI4LTE2OC43ODQgOTQuOTYtMTY4Ljc4NCAyMi41NDQgMCAzMC40IDQ0LjU5MiAzMy41MzYgNjEuODI0IDYuMjA4IDIwLjY1NiAxMy4wODggNTUuMjE2IDIyLjQxNiA4Mi43NTIgMC0xMy43NzYgMTIuNDgtMjAzLjEyIDY1LjM5Mi0yMDMuMTIgMTguNTkyLjAzMiAyNi43MDQgNi45MjggMjYuNzA0IDI3LjU2OHpNODcwLjMyIDQyMi45MjhjMCA1NS4wODgtMzEuMDg4IDE1NC44OC0xMDIuNjQgMTU0Ljg4LTYuMTkyIDAtMTguNDQ4LTMuNjE2LTI1LjQyNC02LjAxNi0zMi40MzItMTEuMTY4LTUwLjE3Ni00OS42OTYtNTIuMjg4LTY2LjI1NiAwIDAtMy44ODgtMTcuOTItMy44ODgtNDAuODk2czMuODg4LTQ1LjE4NCAzLjg4OC00NS4xODRjMTUuNTUyLTc1LjcyOCA0My40ODgtMTA2LjczNiA5Ni4zODQtMTA2LjczNiA1OS4xMDQtLjAzMiA4My45NjggNTguNTI4IDgzLjk2OCAxMTAuMjA4eiIvPjwvc3ZnPg==';
464 - $menu_url = 'https://wordpress.com/woocommerce-installation/' . $this->domain;
465 -
466 - // Only show the menu if the user has the capability to activate_plugins.
467 - // @phan-suppress-next-line PhanTypeMismatchArgumentProbablyReal -- Core should ideally document null for no-callback arg. https://core.trac.wordpress.org/ticket/52539.
468 - add_menu_page( esc_attr__( 'WooCommerce', 'jetpack-masterbar' ), esc_attr__( 'WooCommerce', 'jetpack-masterbar' ), 'activate_plugins', $menu_url, null, $icon_url, 55 );
469 - }
470 - }
471 -
472 - /**
473 - * AJAX handler for retrieving the upsell nudge.
474 - */
475 - public function wp_ajax_upsell_nudge_jitm() {
476 - check_ajax_referer( 'upsell_nudge_jitm' );
477 -
478 176 $nudge = $this->get_upsell_nudge();
479 177 if ( ! $nudge ) {
480 - wp_die();
178 + return;
481 179 }
482 180
483 181 $link = $nudge['link'];
484 182 if ( str_starts_with( $link, '/' ) ) {
@@ -509,10 +207,16 @@
509 207 </div>
510 208 </div>
511 209 </a>
512 210 </li>
211 + <script>
212 + ( function ( el ) {
213 + if ( el && el.parentNode ) {
214 + el.parentNode.prepend( el );
215 + }
216 + } )( document.getElementById( 'toplevel_page_site-notices' ) );
217 + </script>
513 218 <?php
514 - wp_die();
515 219 }
516 220
517 221 /**
518 222 * Returns the first available upsell nudge.