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