PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.0
Jetpack – WP Security, Backup, Speed, & Growth v16.0
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 13.8.3 13.9.2 14.0.1 14.1.1 14.2.2 14.3.1 All 501 releases
← All changes | modules/plugin-search.php +80 -33 12.3.216.0 View file →
@@ -1,8 +1,10 @@
1 1 <?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2 2 /**
3 - * Adds the PSH functionality to Jetpack.
3 + * Plugin Search Hints, aka Feature Suggestions.
4 4 *
5 + * @since 7.1.0
6 + *
5 7 * @package automattic/jetpack
6 8 */
7 9
8 10 // phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files.
@@ -11,13 +13,11 @@
11 13 use Automattic\Jetpack\Current_Plan as Jetpack_Plan;
12 14 use Automattic\Jetpack\Redirect;
13 15 use Automattic\Jetpack\Tracking;
14 16
15 -/**
16 - * Disable direct access and execution.
17 - */
17 +// Disable direct access and execution.
18 18 if ( ! defined( 'ABSPATH' ) ) {
19 - exit;
19 + exit( 0 );
20 20 }
21 21
22 22 if (
23 23 is_admin() &&
@@ -239,9 +239,8 @@
239 239 'jetpackPluginSearch',
240 240 array(
241 241 'nonce' => wp_create_nonce( 'wp_rest' ),
242 242 'base_rest_url' => rest_url( '/jetpack/v4' ),
243 - 'poweredBy' => esc_html__( 'by Jetpack (installed)', 'jetpack' ),
244 243 'manageSettings' => esc_html__( 'Configure', 'jetpack' ),
245 244 'activateModule' => esc_html__( 'Activate Module', 'jetpack' ),
246 245 'getStarted' => esc_html__( 'Get started', 'jetpack' ),
247 246 'activated' => esc_html__( 'Activated', 'jetpack' ),
@@ -301,9 +300,9 @@
301 300 * @return array List of features.
302 301 */
303 302 public function get_extra_features() {
304 303 return array(
305 - 'akismet' => array(
304 + 'akismet' => array(
306 305 'name' => 'Akismet',
307 306 'search_terms' => 'akismet, anti-spam, antispam, comments, spam, spam protection, form spam, captcha, no captcha, nocaptcha, recaptcha, phising, google',
308 307 'short_description' => esc_html__( 'Keep your visitors and search engines happy by stopping comment and contact form spam with Akismet.', 'jetpack' ),
309 308 'requires_connection' => true,
@@ -311,8 +310,18 @@
311 310 'sort' => '16',
312 311 'learn_more_button' => Redirect::get_url( 'plugin-hint-upgrade-akismet' ),
313 312 'configure_url' => admin_url( 'admin.php?page=akismet-key-config' ),
314 313 ),
314 + 'sharing-block' => array(
315 + 'name' => esc_html__( 'Sharing buttons block', 'jetpack' ),
316 + 'search_terms' => 'share, sharing, sharing block, sharing button, social buttons, buttons, share facebook, share twitter, social share, icons, email, facebook, twitter, x, linkedin, pinterest, social media',
317 + 'short_description' => esc_html__( 'Add sharing buttons blocks anywhere on your website to help your visitors share your content.', 'jetpack' ),
318 + 'requires_connection' => false,
319 + 'module' => 'sharing-block',
320 + 'sort' => '13',
321 + 'learn_more_button' => Redirect::get_url( 'jetpack-support-sharing-block' ),
322 + 'configure_url' => admin_url( 'site-editor.php?path=%2Fwp_template' ),
323 + ),
315 324 );
316 325 }
317 326
318 327 /**
@@ -332,29 +341,48 @@
332 341 }
333 342
334 343 // Looks like a search query; it's matching time.
335 344 if ( ! empty( $args->search ) ) {
345 + $searchable_modules = array(
346 + 'contact-form',
347 + 'monitor',
348 + 'photon',
349 + 'photon-cdn',
350 + 'protect',
351 + 'publicize',
352 + 'related-posts',
353 + 'akismet',
354 + 'vaultpress',
355 + 'videopress',
356 + 'search',
357 + );
358 +
359 + /*
360 + * Let's handle the Sharing feature differently.
361 + * If we're using a block-based theme, we should suggest the sharing block.
362 + * If using a classic theme, we should suggest the old sharing module.
363 + */
364 + if ( wp_is_block_theme() ) {
365 + $searchable_modules[] = 'sharing-block';
366 + } else {
367 + $searchable_modules[] = 'sharedaddy';
368 + }
369 +
370 + /*
371 + * Only surface the SEO Tools hint once the new Jetpack SEO admin page is
372 + * available. The page is gated behind the `rsm_jetpack_seo` feature flag,
373 + * so without this gate the hint's CTAs would point to a page that isn't
374 + * registered yet.
375 + */
376 + if ( apply_filters( 'rsm_jetpack_seo', false ) ) {
377 + $searchable_modules[] = 'seo-tools';
378 + }
379 +
336 380 require_once JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php';
337 381 $tracking = new Tracking();
338 382 $jetpack_modules_list = array_intersect_key(
339 383 array_merge( $this->get_extra_features(), Jetpack_Admin::init()->get_modules() ),
340 - array_flip(
341 - array(
342 - 'contact-form',
343 - 'lazy-images',
344 - 'monitor',
345 - 'photon',
346 - 'photon-cdn',
347 - 'protect',
348 - 'publicize',
349 - 'related-posts',
350 - 'sharedaddy',
351 - 'akismet',
352 - 'vaultpress',
353 - 'videopress',
354 - 'search',
355 - )
356 - )
384 + array_flip( $searchable_modules )
357 385 );
358 386 uasort( $jetpack_modules_list, array( $this, 'by_sorting_option' ) );
359 387
360 388 // Record event when user searches for a term over 3 chars (less than 3 is not very useful).
@@ -400,8 +428,9 @@
400 428 esc_html_x( 'Jetpack: %s', 'Jetpack: Module Name', 'jetpack' ),
401 429 $jetpack_modules_list[ $matching_module ]['name']
402 430 ),
403 431 'short_description' => $jetpack_modules_list[ $matching_module ]['short_description'],
432 + 'author' => esc_attr__( 'Jetpack (installed)', 'jetpack' ),
404 433 'requires_connection' => (bool) $jetpack_modules_list[ $matching_module ]['requires_connection'],
405 434 'slug' => self::$slug,
406 435 'version' => JETPACK__VERSION,
407 436 'icons' => array(
@@ -476,9 +505,9 @@
476 505 * @param array $m1 Array 1 to sort.
477 506 * @param array $m2 Array 2 to sort.
478 507 */
479 508 private function by_sorting_option( $m1, $m2 ) {
480 - return $m1['sort'] - $m2['sort'];
509 + return $m1['sort'] <=> $m2['sort'];
481 510 }
482 511
483 512 /**
484 513 * Modify the URL to the feature settings, for example Publicize.
@@ -497,14 +526,11 @@
497 526 case 'publicize':
498 527 $configure_url = Redirect::get_url( 'calypso-marketing-connections' );
499 528 break;
500 529 case 'seo-tools':
501 - $configure_url = Redirect::get_url(
502 - 'calypso-marketing-traffic',
503 - array(
504 - 'anchor' => 'seo',
505 - )
506 - );
530 + // Jetpack SEO has its own wp-admin page (the new SEO home base);
531 + // send users there rather than the legacy Traffic page.
532 + $configure_url = admin_url( 'admin.php?page=jetpack-seo' );
507 533 break;
508 534 case 'google-analytics':
509 535 $configure_url = Redirect::get_url(
510 536 'calypso-marketing-traffic',
@@ -535,13 +561,22 @@
535 561 remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
536 562
537 563 $links = array();
538 564
539 - if ( 'akismet' === $plugin['module'] || 'vaultpress' === $plugin['module'] ) {
565 + if ( 'sharing-block' === $plugin['module'] ) {
540 566 $links['jp_get_started'] = '<a
541 567 id="plugin-select-settings"
542 568 class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
569 + href="' . esc_url( admin_url( 'site-editor.php?path=%2Fwp_template' ) ) . '"
570 + data-module="' . esc_attr( $plugin['module'] ) . '"
571 + data-track="get_started"
572 + >' . esc_html__( 'Add block', 'jetpack' ) . '</a>';
573 + } elseif ( 'akismet' === $plugin['module'] || 'vaultpress' === $plugin['module'] ) {
574 + $links['jp_get_started'] = '<a
575 + id="plugin-select-settings"
576 + class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
543 577 href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '"
578 + target="_blank"
544 579 data-module="' . esc_attr( $plugin['module'] ) . '"
545 580 data-track="get_started"
546 581 >' . esc_html__( 'Get started', 'jetpack' ) . '</a>';
547 582 // Jetpack installed, active, feature not enabled; prompt to enable.
@@ -572,13 +607,26 @@
572 607 data-module="' . esc_attr( $plugin['module'] ) . '"
573 608 data-track="configure"
574 609 >' . esc_html__( 'Configure', 'jetpack' ) . '</a>';
575 610 // Module is active, doesn't have options to configure.
611 + } elseif ( 'seo-tools' === $plugin['module'] && Jetpack::is_module_active( $plugin['module'] ) ) {
612 + // Jetpack SEO has its own wp-admin page; send users there (same tab)
613 + // rather than a jetpack.com doc redirect, which isn't registered for
614 + // this module. Reuse get_configure_url() so the destination stays in
615 + // one place.
616 + $links['jp_get_started'] = '<a
617 + id="plugin-select-settings"
618 + class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
619 + href="' . esc_url( $this->get_configure_url( $plugin['module'], $plugin['configure_url'] ) ) . '"
620 + data-module="' . esc_attr( $plugin['module'] ) . '"
621 + data-track="get_started"
622 + >' . esc_html__( 'Get started', 'jetpack' ) . '</a>';
576 623 } elseif ( Jetpack::is_module_active( $plugin['module'] ) ) {
577 624 $links['jp_get_started'] = '<a
578 625 id="plugin-select-settings"
579 626 class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
580 627 href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '"
628 + target="_blank"
581 629 data-module="' . esc_attr( $plugin['module'] ) . '"
582 630 data-track="get_started"
583 631 >' . esc_html__( 'Get started', 'jetpack' ) . '</a>';
584 632 }
@@ -601,9 +649,8 @@
601 649 >' . esc_html__( 'Hide this suggestion', 'jetpack' ) . '</a>';
602 650
603 651 return $links;
604 652 }
605 -
606 653 }
607 654
608 655 /**
609 656 * Master control that checks if Plugin search hints is active.