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