| @@ -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. |
| @@ -13,9 +15,9 @@ | ||
| 13 | 15 | use Automattic\Jetpack\Tracking; |
| 14 | 16 | |
| 15 | 17 | // Disable direct access and execution. |
| 16 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | - exit; | |
| 19 | + exit( 0 ); | |
| 18 | 20 | } |
| 19 | 21 | |
| 20 | 22 | if ( |
| 21 | 23 | is_admin() && |
| @@ -237,9 +239,8 @@ | ||
| 237 | 239 | 'jetpackPluginSearch', |
| 238 | 240 | array( |
| 239 | 241 | 'nonce' => wp_create_nonce( 'wp_rest' ), |
| 240 | 242 | 'base_rest_url' => rest_url( '/jetpack/v4' ), |
| 241 | - 'poweredBy' => esc_html__( 'by Jetpack (installed)', 'jetpack' ), | |
| 242 | 243 | 'manageSettings' => esc_html__( 'Configure', 'jetpack' ), |
| 243 | 244 | 'activateModule' => esc_html__( 'Activate Module', 'jetpack' ), |
| 244 | 245 | 'getStarted' => esc_html__( 'Get started', 'jetpack' ), |
| 245 | 246 | 'activated' => esc_html__( 'Activated', 'jetpack' ), |
| @@ -311,9 +312,9 @@ | ||
| 311 | 312 | 'configure_url' => admin_url( 'admin.php?page=akismet-key-config' ), |
| 312 | 313 | ), |
| 313 | 314 | 'sharing-block' => array( |
| 314 | 315 | 'name' => esc_html__( 'Sharing buttons block', 'jetpack' ), |
| 315 | - 'search_terms' => 'share, sharing, sharing block, sharing button, social buttons, buttons, share facebook, share twitter, social share, icons, email, facebook, twitter, x, linkedin, pinterest, pocket, social media', | |
| 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', | |
| 316 | 317 | 'short_description' => esc_html__( 'Add sharing buttons blocks anywhere on your website to help your visitors share your content.', 'jetpack' ), |
| 317 | 318 | 'requires_connection' => false, |
| 318 | 319 | 'module' => 'sharing-block', |
| 319 | 320 | 'sort' => '13', |
| @@ -365,8 +366,19 @@ | ||
| 365 | 366 | } else { |
| 366 | 367 | $searchable_modules[] = 'sharedaddy'; |
| 367 | 368 | } |
| 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 | + | |
| 369 | 381 | require_once JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php'; |
| 370 | 382 | $tracking = new Tracking(); |
| 371 | 383 | $jetpack_modules_list = array_intersect_key( |
| 372 | 384 | array_merge( $this->get_extra_features(), Jetpack_Admin::init()->get_modules() ), |
| @@ -417,8 +429,9 @@ | ||
| 417 | 429 | esc_html_x( 'Jetpack: %s', 'Jetpack: Module Name', 'jetpack' ), |
| 418 | 430 | $jetpack_modules_list[ $matching_module ]['name'] |
| 419 | 431 | ), |
| 420 | 432 | 'short_description' => $jetpack_modules_list[ $matching_module ]['short_description'], |
| 433 | + 'author' => esc_attr__( 'Jetpack (installed)', 'jetpack' ), | |
| 421 | 434 | 'requires_connection' => (bool) $jetpack_modules_list[ $matching_module ]['requires_connection'], |
| 422 | 435 | 'slug' => self::$slug, |
| 423 | 436 | 'version' => JETPACK__VERSION, |
| 424 | 437 | 'icons' => array( |
| @@ -514,14 +527,11 @@ | ||
| 514 | 527 | case 'publicize': |
| 515 | 528 | $configure_url = Redirect::get_url( 'calypso-marketing-connections' ); |
| 516 | 529 | break; |
| 517 | 530 | case 'seo-tools': |
| 518 | - $configure_url = Redirect::get_url( | |
| 519 | - 'calypso-marketing-traffic', | |
| 520 | - array( | |
| 521 | - 'anchor' => 'seo', | |
| 522 | - ) | |
| 523 | - ); | |
| 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' ); | |
| 524 | 534 | break; |
| 525 | 535 | case 'google-analytics': |
| 526 | 536 | $configure_url = Redirect::get_url( |
| 527 | 537 | 'calypso-marketing-traffic', |
| @@ -565,8 +575,9 @@ | ||
| 565 | 575 | $links['jp_get_started'] = '<a |
| 566 | 576 | id="plugin-select-settings" |
| 567 | 577 | class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button" |
| 568 | 578 | href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '" |
| 579 | + target="_blank" | |
| 569 | 580 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 570 | 581 | data-track="get_started" |
| 571 | 582 | >' . esc_html__( 'Get started', 'jetpack' ) . '</a>'; |
| 572 | 583 | // Jetpack installed, active, feature not enabled; prompt to enable. |
| @@ -597,13 +608,26 @@ | ||
| 597 | 608 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 598 | 609 | data-track="configure" |
| 599 | 610 | >' . esc_html__( 'Configure', 'jetpack' ) . '</a>'; |
| 600 | 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>'; | |
| 601 | 624 | } elseif ( Jetpack::is_module_active( $plugin['module'] ) ) { |
| 602 | 625 | $links['jp_get_started'] = '<a |
| 603 | 626 | id="plugin-select-settings" |
| 604 | 627 | class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button" |
| 605 | 628 | href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '" |
| 629 | + target="_blank" | |
| 606 | 630 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 607 | 631 | data-track="get_started" |
| 608 | 632 | >' . esc_html__( 'Get started', 'jetpack' ) . '</a>'; |
| 609 | 633 | } |