| @@ -1,26 +1,21 @@ | ||
| 1 | -<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName | |
| 2 | -/** | |
| 3 | - * Adds the PSH functionality to Jetpack. | |
| 4 | - * | |
| 5 | - * @package automattic/jetpack | |
| 6 | - */ | |
| 1 | +<?php | |
| 7 | 2 | |
| 8 | -// phpcs:disable Universal.Files.SeparateFunctionsFromOO.Mixed -- TODO: Move classes to appropriately-named class files. | |
| 9 | - | |
| 10 | 3 | use Automattic\Jetpack\Constants; |
| 11 | -use Automattic\Jetpack\Current_Plan as Jetpack_Plan; | |
| 4 | +use Automattic\Jetpack\Tracking; | |
| 12 | 5 | use Automattic\Jetpack\Redirect; |
| 13 | -use Automattic\Jetpack\Tracking; | |
| 14 | 6 | |
| 15 | -// Disable direct access and execution. | |
| 7 | +/** | |
| 8 | + * Disable direct access and execution. | |
| 9 | + */ | |
| 16 | 10 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | 11 | exit; |
| 18 | 12 | } |
| 19 | 13 | |
| 14 | + | |
| 20 | 15 | if ( |
| 21 | 16 | is_admin() && |
| 22 | - Jetpack::is_connection_ready() && | |
| 17 | + Jetpack::is_active() && | |
| 23 | 18 | /** This filter is documented in _inc/lib/admin-pages/class.jetpack-react-page.php */ |
| 24 | 19 | apply_filters( 'jetpack_show_promotions', true ) && |
| 25 | 20 | // Disable feature hints when plugins cannot be installed. |
| 26 | 21 | ! Constants::is_true( 'DISALLOW_FILE_MODS' ) && |
| @@ -39,20 +34,10 @@ | ||
| 39 | 34 | * @since 7.1.0 |
| 40 | 35 | */ |
| 41 | 36 | class Jetpack_Plugin_Search { |
| 42 | 37 | |
| 43 | - /** | |
| 44 | - * PSH slug name. | |
| 45 | - * | |
| 46 | - * @var string | |
| 47 | - */ | |
| 48 | - public static $slug = 'jetpack-plugin-search'; | |
| 38 | + static $slug = 'jetpack-plugin-search'; | |
| 49 | 39 | |
| 50 | - /** | |
| 51 | - * Singleton constructor. | |
| 52 | - * | |
| 53 | - * @return Jetpack_Plugin_Search | |
| 54 | - */ | |
| 55 | 40 | public static function init() { |
| 56 | 41 | static $instance = null; |
| 57 | 42 | |
| 58 | 43 | if ( ! $instance ) { |
| @@ -61,11 +46,8 @@ | ||
| 61 | 46 | |
| 62 | 47 | return $instance; |
| 63 | 48 | } |
| 64 | 49 | |
| 65 | - /** | |
| 66 | - * Jetpack_Plugin_Search constructor. | |
| 67 | - */ | |
| 68 | 50 | public function __construct() { |
| 69 | 51 | add_action( 'current_screen', array( $this, 'start' ) ); |
| 70 | 52 | } |
| 71 | 53 | |
| @@ -71,14 +53,14 @@ | ||
| 71 | 53 | |
| 72 | 54 | /** |
| 73 | 55 | * Add actions and filters only if this is the plugin installation screen and it's the first page. |
| 74 | 56 | * |
| 75 | - * @param object $screen WP SCreen object. | |
| 57 | + * @param object $screen | |
| 76 | 58 | * |
| 77 | 59 | * @since 7.1.0 |
| 78 | 60 | */ |
| 79 | 61 | public function start( $screen ) { |
| 80 | - if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 === intval( $_GET['paged'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 62 | + if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 == $_GET['paged'] ) ) { | |
| 81 | 63 | add_action( 'admin_enqueue_scripts', array( $this, 'load_plugins_search_script' ) ); |
| 82 | 64 | add_filter( 'plugins_api_result', array( $this, 'inject_jetpack_module_suggestion' ), 10, 3 ); |
| 83 | 65 | add_filter( 'self_admin_url', array( $this, 'plugin_details' ) ); |
| 84 | 66 | add_filter( 'plugin_install_action_links', array( $this, 'insert_module_related_links' ), 10, 2 ); |
| @@ -105,25 +87,21 @@ | ||
| 105 | 87 | * |
| 106 | 88 | * @since 7.1.0 |
| 107 | 89 | */ |
| 108 | 90 | public static function register_endpoints() { |
| 109 | - register_rest_route( | |
| 110 | - 'jetpack/v4', | |
| 111 | - '/hints', | |
| 112 | - array( | |
| 113 | - 'methods' => WP_REST_Server::EDITABLE, | |
| 114 | - 'callback' => __CLASS__ . '::dismiss', | |
| 115 | - 'permission_callback' => __CLASS__ . '::can_request', | |
| 116 | - 'args' => array( | |
| 117 | - 'hint' => array( | |
| 118 | - 'default' => '', | |
| 119 | - 'type' => 'string', | |
| 120 | - 'required' => true, | |
| 121 | - 'validate_callback' => __CLASS__ . '::is_hint_id', | |
| 122 | - ), | |
| 91 | + register_rest_route( 'jetpack/v4', '/hints', array( | |
| 92 | + 'methods' => WP_REST_Server::EDITABLE, | |
| 93 | + 'callback' => __CLASS__ . '::dismiss', | |
| 94 | + 'permission_callback' => __CLASS__ . '::can_request', | |
| 95 | + 'args' => array( | |
| 96 | + 'hint' => array( | |
| 97 | + 'default' => '', | |
| 98 | + 'type' => 'string', | |
| 99 | + 'required' => true, | |
| 100 | + 'validate_callback' => __CLASS__ . '::is_hint_id', | |
| 123 | 101 | ), |
| 124 | 102 | ) |
| 125 | - ); | |
| 103 | + ) ); | |
| 126 | 104 | } |
| 127 | 105 | |
| 128 | 106 | /** |
| 129 | 107 | * A WordPress REST API permission callback method that accepts a request object and |
| @@ -141,11 +119,11 @@ | ||
| 141 | 119 | * Validates that the ID of the hint to dismiss is a string. |
| 142 | 120 | * |
| 143 | 121 | * @since 7.1.0 |
| 144 | 122 | * |
| 145 | - * @param string|bool $value Value to check. | |
| 123 | + * @param string|bool $value Value to check. | |
| 146 | 124 | * @param WP_REST_Request $request The request sent to the WP REST API. |
| 147 | - * @param string $param Name of the parameter passed to endpoint holding $value. | |
| 125 | + * @param string $param Name of the parameter passed to endpoint holding $value. | |
| 148 | 126 | * |
| 149 | 127 | * @return bool|WP_Error |
| 150 | 128 | */ |
| 151 | 129 | public static function is_hint_id( $value, $request, $param ) { |
| @@ -150,9 +128,8 @@ | ||
| 150 | 128 | */ |
| 151 | 129 | public static function is_hint_id( $value, $request, $param ) { |
| 152 | 130 | return in_array( $value, Jetpack::get_available_modules(), true ) |
| 153 | 131 | ? true |
| 154 | - /* translators: %s is the name of a parameter passed to an endpoint. */ | |
| 155 | 132 | : new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) ); |
| 156 | 133 | } |
| 157 | 134 | |
| 158 | 135 | /** |
| @@ -212,9 +189,9 @@ | ||
| 212 | 189 | * |
| 213 | 190 | * @return bool True if $hint should be displayed. |
| 214 | 191 | */ |
| 215 | 192 | protected function should_display_hint( $hint ) { |
| 216 | - $dismissed_hints = static::get_dismissed_hints(); | |
| 193 | + $dismissed_hints = $this->get_dismissed_hints(); | |
| 217 | 194 | // If more than 2 hints have been dismissed, then show no more. |
| 218 | 195 | if ( 2 < count( $dismissed_hints ) ) { |
| 219 | 196 | return false; |
| 220 | 197 | } |
| @@ -226,11 +203,8 @@ | ||
| 226 | 203 | |
| 227 | 204 | return ! in_array( $hint, $dismissed_hints, true ); |
| 228 | 205 | } |
| 229 | 206 | |
| 230 | - /** | |
| 231 | - * Load the search scripts and CSS for PSH. | |
| 232 | - */ | |
| 233 | 207 | public function load_plugins_search_script() { |
| 234 | 208 | wp_enqueue_script( self::$slug, plugins_url( 'modules/plugin-search/plugin-search.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION, true ); |
| 235 | 209 | wp_localize_script( |
| 236 | 210 | self::$slug, |
| @@ -257,9 +231,9 @@ | ||
| 257 | 231 | 'hideText' => esc_html__( 'Hide this suggestion', 'jetpack' ), |
| 258 | 232 | ) |
| 259 | 233 | ); |
| 260 | 234 | |
| 261 | - wp_enqueue_style( self::$slug, plugins_url( 'modules/plugin-search/plugin-search.css', JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION ); | |
| 235 | + wp_enqueue_style( self::$slug, plugins_url( 'modules/plugin-search/plugin-search.css', JETPACK__PLUGIN_FILE ) ); | |
| 262 | 236 | } |
| 263 | 237 | |
| 264 | 238 | /** |
| 265 | 239 | * Get the plugin repo's data for Jetpack to populate the fields with. |
| @@ -269,23 +243,20 @@ | ||
| 269 | 243 | public static function get_jetpack_plugin_data() { |
| 270 | 244 | $data = get_transient( 'jetpack_plugin_data' ); |
| 271 | 245 | |
| 272 | 246 | if ( false === $data || is_wp_error( $data ) ) { |
| 273 | - include_once ABSPATH . 'wp-admin/includes/plugin-install.php'; | |
| 274 | - $data = plugins_api( | |
| 275 | - 'plugin_information', | |
| 276 | - array( | |
| 277 | - 'slug' => 'jetpack', | |
| 278 | - 'is_ssl' => is_ssl(), | |
| 279 | - 'fields' => array( | |
| 280 | - 'banners' => true, | |
| 281 | - 'reviews' => true, | |
| 282 | - 'active_installs' => true, | |
| 283 | - 'versions' => false, | |
| 284 | - 'sections' => false, | |
| 285 | - ), | |
| 286 | - ) | |
| 287 | - ); | |
| 247 | + include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' ); | |
| 248 | + $data = plugins_api( 'plugin_information', array( | |
| 249 | + 'slug' => 'jetpack', | |
| 250 | + 'is_ssl' => is_ssl(), | |
| 251 | + 'fields' => array( | |
| 252 | + 'banners' => true, | |
| 253 | + 'reviews' => true, | |
| 254 | + 'active_installs' => true, | |
| 255 | + 'versions' => false, | |
| 256 | + 'sections' => false, | |
| 257 | + ), | |
| 258 | + ) ); | |
| 288 | 259 | set_transient( 'jetpack_plugin_data', $data, DAY_IN_SECONDS ); |
| 289 | 260 | } |
| 290 | 261 | |
| 291 | 262 | return $data; |
| @@ -299,93 +270,60 @@ | ||
| 299 | 270 | * @return array List of features. |
| 300 | 271 | */ |
| 301 | 272 | public function get_extra_features() { |
| 302 | 273 | return array( |
| 303 | - 'akismet' => array( | |
| 304 | - 'name' => 'Akismet', | |
| 305 | - 'search_terms' => 'akismet, anti-spam, antispam, comments, spam, spam protection, form spam, captcha, no captcha, nocaptcha, recaptcha, phising, google', | |
| 306 | - 'short_description' => esc_html__( 'Keep your visitors and search engines happy by stopping comment and contact form spam with Akismet.', 'jetpack' ), | |
| 274 | + 'akismet' => array( | |
| 275 | + 'name' => 'Akismet', | |
| 276 | + 'search_terms' => 'akismet, anti-spam, antispam, comments, spam, spam protection, form spam, captcha, no captcha, nocaptcha, recaptcha, phising, google', | |
| 277 | + 'short_description' => esc_html__( 'Keep your visitors and search engines happy by stopping comment and contact form spam with Akismet.', 'jetpack' ), | |
| 307 | 278 | 'requires_connection' => true, |
| 308 | - 'module' => 'akismet', | |
| 309 | - 'sort' => '16', | |
| 310 | - 'learn_more_button' => Redirect::get_url( 'plugin-hint-upgrade-akismet' ), | |
| 311 | - 'configure_url' => admin_url( 'admin.php?page=akismet-key-config' ), | |
| 279 | + 'module' => 'akismet', | |
| 280 | + 'sort' => '16', | |
| 281 | + 'learn_more_button' => Redirect::get_url( 'plugin-hint-upgrade-akismet' ), | |
| 282 | + 'configure_url' => admin_url( 'admin.php?page=akismet-key-config' ), | |
| 312 | 283 | ), |
| 313 | - 'sharing-block' => array( | |
| 314 | - '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 | - 'short_description' => esc_html__( 'Add sharing buttons blocks anywhere on your website to help your visitors share your content.', 'jetpack' ), | |
| 317 | - 'requires_connection' => false, | |
| 318 | - 'module' => 'sharing-block', | |
| 319 | - 'sort' => '13', | |
| 320 | - 'learn_more_button' => Redirect::get_url( 'jetpack-support-sharing-block' ), | |
| 321 | - 'configure_url' => admin_url( 'site-editor.php?path=%2Fwp_template' ), | |
| 322 | - ), | |
| 323 | 284 | ); |
| 324 | 285 | } |
| 325 | 286 | |
| 326 | 287 | /** |
| 327 | 288 | * Intercept the plugins API response and add in an appropriate card for Jetpack |
| 328 | - * | |
| 329 | - * @param object $result Plugin search results. | |
| 330 | - * @param string $action unused. | |
| 331 | - * @param object $args Search args. | |
| 332 | 289 | */ |
| 333 | 290 | public function inject_jetpack_module_suggestion( $result, $action, $args ) { |
| 334 | - /* | |
| 335 | - * Bail if something else hooks into the Plugins' API response | |
| 336 | - * and does not return results. | |
| 337 | - */ | |
| 338 | - if ( empty( $result->plugins ) || is_wp_error( $result ) ) { | |
| 339 | - return $result; | |
| 340 | - } | |
| 341 | - | |
| 342 | - // Looks like a search query; it's matching time. | |
| 291 | + // Looks like a search query; it's matching time | |
| 343 | 292 | if ( ! empty( $args->search ) ) { |
| 344 | - $searchable_modules = array( | |
| 345 | - 'contact-form', | |
| 346 | - 'monitor', | |
| 347 | - 'photon', | |
| 348 | - 'photon-cdn', | |
| 349 | - 'protect', | |
| 350 | - 'publicize', | |
| 351 | - 'related-posts', | |
| 352 | - 'akismet', | |
| 353 | - 'vaultpress', | |
| 354 | - 'videopress', | |
| 355 | - 'search', | |
| 356 | - ); | |
| 357 | - | |
| 358 | - /* | |
| 359 | - * Let's handle the Sharing feature differently. | |
| 360 | - * If we're using a block-based theme, we should suggest the sharing block. | |
| 361 | - * If using a classic theme, we should suggest the old sharing module. | |
| 362 | - */ | |
| 363 | - if ( wp_is_block_theme() ) { | |
| 364 | - $searchable_modules[] = 'sharing-block'; | |
| 365 | - } else { | |
| 366 | - $searchable_modules[] = 'sharedaddy'; | |
| 367 | - } | |
| 368 | - | |
| 369 | 293 | require_once JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php'; |
| 370 | - $tracking = new Tracking(); | |
| 294 | + $tracking = new Tracking(); | |
| 371 | 295 | $jetpack_modules_list = array_intersect_key( |
| 372 | 296 | array_merge( $this->get_extra_features(), Jetpack_Admin::init()->get_modules() ), |
| 373 | - array_flip( $searchable_modules ) | |
| 297 | + array_flip( array( | |
| 298 | + 'contact-form', | |
| 299 | + 'lazy-images', | |
| 300 | + 'monitor', | |
| 301 | + 'photon', | |
| 302 | + 'photon-cdn', | |
| 303 | + 'protect', | |
| 304 | + 'publicize', | |
| 305 | + 'related-posts', | |
| 306 | + 'sharedaddy', | |
| 307 | + 'akismet', | |
| 308 | + 'vaultpress', | |
| 309 | + 'videopress', | |
| 310 | + 'search', | |
| 311 | + ) ) | |
| 374 | 312 | ); |
| 375 | 313 | uasort( $jetpack_modules_list, array( $this, 'by_sorting_option' ) ); |
| 376 | 314 | |
| 377 | - // Record event when user searches for a term over 3 chars (less than 3 is not very useful). | |
| 315 | + // Record event when user searches for a term over 3 chars (less than 3 is not very useful.) | |
| 378 | 316 | if ( strlen( $args->search ) >= 3 ) { |
| 379 | 317 | $tracking->record_user_event( 'wpa_plugin_search_term', array( 'search_term' => $args->search ) ); |
| 380 | 318 | } |
| 381 | 319 | |
| 382 | - // Lowercase, trim, remove punctuation/special chars, decode url, remove 'jetpack'. | |
| 320 | + // Lowercase, trim, remove punctuation/special chars, decode url, remove 'jetpack' | |
| 383 | 321 | $normalized_term = $this->sanitize_search_term( $args->search ); |
| 384 | 322 | |
| 385 | 323 | $matching_module = null; |
| 386 | 324 | |
| 387 | - // Try to match a passed search term with module's search terms. | |
| 325 | + // Try to match a passed search term with module's search terms | |
| 388 | 326 | foreach ( $jetpack_modules_list as $module_slug => $module_opts ) { |
| 389 | 327 | /* |
| 390 | 328 | * Does the site's current plan support the feature? |
| 391 | 329 | * We don't use Jetpack_Plan::supports() here because |
| @@ -404,25 +342,24 @@ | ||
| 404 | 342 | } |
| 405 | 343 | } |
| 406 | 344 | |
| 407 | 345 | if ( isset( $matching_module ) && $this->should_display_hint( $matching_module ) ) { |
| 408 | - // Record event when a matching feature is found. | |
| 346 | + // Record event when a matching feature is found | |
| 409 | 347 | $tracking->record_user_event( 'wpa_plugin_search_match_found', array( 'feature' => $matching_module ) ); |
| 410 | 348 | |
| 411 | - $inject = (array) self::get_jetpack_plugin_data(); | |
| 349 | + $inject = (array) self::get_jetpack_plugin_data(); | |
| 412 | 350 | $image_url = plugins_url( 'modules/plugin-search/psh', JETPACK__PLUGIN_FILE ); |
| 413 | 351 | $overrides = array( |
| 414 | - 'plugin-search' => true, // Helps to determine if that an injected card. | |
| 415 | - 'name' => sprintf( // Supplement name/description so that they clearly indicate this was added. | |
| 416 | - /* translators: Jetpack module name */ | |
| 352 | + 'plugin-search' => true, // Helps to determine if that an injected card. | |
| 353 | + 'name' => sprintf( // Supplement name/description so that they clearly indicate this was added. | |
| 417 | 354 | esc_html_x( 'Jetpack: %s', 'Jetpack: Module Name', 'jetpack' ), |
| 418 | 355 | $jetpack_modules_list[ $matching_module ]['name'] |
| 419 | 356 | ), |
| 420 | - 'short_description' => $jetpack_modules_list[ $matching_module ]['short_description'], | |
| 357 | + 'short_description' => $jetpack_modules_list[ $matching_module ]['short_description'], | |
| 421 | 358 | 'requires_connection' => (bool) $jetpack_modules_list[ $matching_module ]['requires_connection'], |
| 422 | - 'slug' => self::$slug, | |
| 423 | - 'version' => JETPACK__VERSION, | |
| 424 | - 'icons' => array( | |
| 359 | + 'slug' => self::$slug, | |
| 360 | + 'version' => JETPACK__VERSION, | |
| 361 | + 'icons' => array( | |
| 425 | 362 | '1x' => "$image_url-128.png", |
| 426 | 363 | '2x' => "$image_url-256.png", |
| 427 | 364 | 'svg' => "$image_url.svg", |
| 428 | 365 | ), |
| @@ -427,12 +364,12 @@ | ||
| 427 | 364 | 'svg' => "$image_url.svg", |
| 428 | 365 | ), |
| 429 | 366 | ); |
| 430 | 367 | |
| 431 | - // Splice in the base module data. | |
| 368 | + // Splice in the base module data | |
| 432 | 369 | $inject = array_merge( $inject, $jetpack_modules_list[ $matching_module ], $overrides ); |
| 433 | 370 | |
| 434 | - // Add it to the top of the list. | |
| 371 | + // Add it to the top of the list | |
| 435 | 372 | $result->plugins = array_filter( $result->plugins, array( $this, 'filter_cards' ) ); |
| 436 | 373 | array_unshift( $result->plugins, $inject ); |
| 437 | 374 | } |
| 438 | 375 | } |
| @@ -445,28 +382,14 @@ | ||
| 445 | 382 | * @since 7.1.0 |
| 446 | 383 | * @since 7.2.0 Only remove Jetpack. |
| 447 | 384 | * @since 7.4.0 Simplify for WordPress 5.1+. |
| 448 | 385 | * |
| 449 | - * @param array|object $plugin WordPress search result card. | |
| 386 | + * @param array|object $plugin | |
| 450 | 387 | * |
| 451 | 388 | * @return bool |
| 452 | 389 | */ |
| 453 | - public function filter_cards( $plugin ) { | |
| 454 | - /* | |
| 455 | - * $plugin is normally an array. | |
| 456 | - * However, since the response data can be filtered, | |
| 457 | - * we cannot fully trust its format. | |
| 458 | - * Let's handle both arrays and objects, and bail if it's neither. | |
| 459 | - */ | |
| 460 | - if ( is_array( $plugin ) && ! empty( $plugin['slug'] ) ) { | |
| 461 | - $slug = $plugin['slug']; | |
| 462 | - } elseif ( is_object( $plugin ) && ! empty( $plugin->slug ) ) { | |
| 463 | - $slug = $plugin->slug; | |
| 464 | - } else { | |
| 465 | - return false; | |
| 466 | - } | |
| 467 | - | |
| 468 | - return ! in_array( $slug, array( 'jetpack' ), true ); | |
| 390 | + function filter_cards( $plugin ) { | |
| 391 | + return ! in_array( $plugin['slug'], array( 'jetpack' ), true ); | |
| 469 | 392 | } |
| 470 | 393 | |
| 471 | 394 | /** |
| 472 | 395 | * Take a raw search query and return something a bit more standardized and |
| @@ -471,10 +394,10 @@ | ||
| 471 | 394 | /** |
| 472 | 395 | * Take a raw search query and return something a bit more standardized and |
| 473 | 396 | * easy to work with. |
| 474 | 397 | * |
| 475 | - * @param string $term The raw search term. | |
| 476 | - * @return string A simplified/sanitized version. | |
| 398 | + * @param String $term The raw search term | |
| 399 | + * @return String A simplified/sanitized version. | |
| 477 | 400 | */ |
| 478 | 401 | private function sanitize_search_term( $term ) { |
| 479 | 402 | $term = strtolower( urldecode( $term ) ); |
| 480 | 403 | |
| @@ -488,14 +411,11 @@ | ||
| 488 | 411 | } |
| 489 | 412 | |
| 490 | 413 | /** |
| 491 | 414 | * Callback function to sort the array of modules by the sort option. |
| 492 | - * | |
| 493 | - * @param array $m1 Array 1 to sort. | |
| 494 | - * @param array $m2 Array 2 to sort. | |
| 495 | 415 | */ |
| 496 | 416 | private function by_sorting_option( $m1, $m2 ) { |
| 497 | - return $m1['sort'] <=> $m2['sort']; | |
| 417 | + return $m1['sort'] - $m2['sort']; | |
| 498 | 418 | } |
| 499 | 419 | |
| 500 | 420 | /** |
| 501 | 421 | * Modify the URL to the feature settings, for example Publicize. |
| @@ -501,13 +421,14 @@ | ||
| 501 | 421 | * Modify the URL to the feature settings, for example Publicize. |
| 502 | 422 | * Sharing is included here because while we still have a page in WP Admin, |
| 503 | 423 | * we prefer to send users to Calypso. |
| 504 | 424 | * |
| 505 | - * @param string $feature Feature. | |
| 506 | - * @param string $configure_url URL to configure feature. | |
| 425 | + * @param string $feature | |
| 426 | + * @param string $configure_url | |
| 507 | 427 | * |
| 508 | 428 | * @return string |
| 509 | 429 | * @since 7.1.0 |
| 430 | + * | |
| 510 | 431 | */ |
| 511 | 432 | private function get_configure_url( $feature, $configure_url ) { |
| 512 | 433 | switch ( $feature ) { |
| 513 | 434 | case 'sharing': |
| @@ -538,11 +459,8 @@ | ||
| 538 | 459 | } |
| 539 | 460 | |
| 540 | 461 | /** |
| 541 | 462 | * Put some more appropriate links on our custom result cards. |
| 542 | - * | |
| 543 | - * @param array $links Related links. | |
| 544 | - * @param array $plugin Plugin result information. | |
| 545 | 463 | */ |
| 546 | 464 | public function insert_module_related_links( $links, $plugin ) { |
| 547 | 465 | if ( self::$slug !== $plugin['slug'] ) { |
| 548 | 466 | return $links; |
| @@ -552,20 +470,12 @@ | ||
| 552 | 470 | remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) ); |
| 553 | 471 | |
| 554 | 472 | $links = array(); |
| 555 | 473 | |
| 556 | - if ( 'sharing-block' === $plugin['module'] ) { | |
| 474 | + if ( 'akismet' === $plugin['module'] || 'vaultpress' === $plugin['module'] ) { | |
| 557 | 475 | $links['jp_get_started'] = '<a |
| 558 | 476 | id="plugin-select-settings" |
| 559 | 477 | class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button" |
| 560 | - href="' . esc_url( admin_url( 'site-editor.php?path=%2Fwp_template' ) ) . '" | |
| 561 | - data-module="' . esc_attr( $plugin['module'] ) . '" | |
| 562 | - data-track="get_started" | |
| 563 | - >' . esc_html__( 'Add block', 'jetpack' ) . '</a>'; | |
| 564 | - } elseif ( 'akismet' === $plugin['module'] || 'vaultpress' === $plugin['module'] ) { | |
| 565 | - $links['jp_get_started'] = '<a | |
| 566 | - id="plugin-select-settings" | |
| 567 | - class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button" | |
| 568 | 478 | href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '" |
| 569 | 479 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 570 | 480 | data-track="get_started" |
| 571 | 481 | >' . esc_html__( 'Get started', 'jetpack' ) . '</a>'; |
| @@ -596,9 +506,9 @@ | ||
| 596 | 506 | href="' . esc_url( $this->get_configure_url( $plugin['module'], $plugin['configure_url'] ) ) . '" |
| 597 | 507 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 598 | 508 | data-track="configure" |
| 599 | 509 | >' . esc_html__( 'Configure', 'jetpack' ) . '</a>'; |
| 600 | - // Module is active, doesn't have options to configure. | |
| 510 | + // Module is active, doesn't have options to configure | |
| 601 | 511 | } elseif ( Jetpack::is_module_active( $plugin['module'] ) ) { |
| 602 | 512 | $links['jp_get_started'] = '<a |
| 603 | 513 | id="plugin-select-settings" |
| 604 | 514 | class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button" |
| @@ -618,9 +528,9 @@ | ||
| 618 | 528 | data-track="learn_more" |
| 619 | 529 | >' . esc_html__( 'Learn more', 'jetpack' ) . '</a>'; |
| 620 | 530 | } |
| 621 | 531 | |
| 622 | - // Dismiss link. | |
| 532 | + // Dismiss link | |
| 623 | 533 | $links[] = '<a |
| 624 | 534 | class="jetpack-plugin-search__dismiss" |
| 625 | 535 | data-module="' . esc_attr( $plugin['module'] ) . '" |
| 626 | 536 | >' . esc_html__( 'Hide this suggestion', 'jetpack' ) . '</a>'; |
| @@ -626,8 +536,9 @@ | ||
| 626 | 536 | >' . esc_html__( 'Hide this suggestion', 'jetpack' ) . '</a>'; |
| 627 | 537 | |
| 628 | 538 | return $links; |
| 629 | 539 | } |
| 540 | + | |
| 630 | 541 | } |
| 631 | 542 | |
| 632 | 543 | /** |
| 633 | 544 | * Master control that checks if Plugin search hints is active. |