Completed
Push — add/constants ( 627491...bc42a9 )
by
unknown
203:10 queued 193:38
created

inject_jetpack_module_suggestion()   C

Complexity

Conditions 8
Paths 13

Size

Total Lines 91

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 8
nc 13
nop 3
dl 0
loc 91
rs 6.9519
c 0
b 0
f 0

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
/**
3
 * Adds the PSH functionality to Jetpack.
4
 *
5
 * @package automattic/jetpack
6
 */
7
8
use Automattic\Jetpack\Constants;
9
use Automattic\Jetpack\Redirect;
10
use Automattic\Jetpack\Tracking;
11
12
/**
13
 * Disable direct access and execution.
14
 */
15
if ( ! defined( 'ABSPATH' ) ) {
16
	exit;
17
}
18
19
if (
20
	is_admin() &&
21
	Jetpack::is_active() &&
22
	/** This filter is documented in _inc/lib/admin-pages/class.jetpack-react-page.php */
23
	apply_filters( 'jetpack_show_promotions', true ) &&
24
	// Disable feature hints when plugins cannot be installed.
25
	! Constants::is_true( 'DISALLOW_FILE_MODS' ) &&
26
	jetpack_is_psh_active()
27
) {
28
	Jetpack_Plugin_Search::init();
29
}
30
31
// Register endpoints when WP REST API is initialized.
32
add_action( 'rest_api_init', array( 'Jetpack_Plugin_Search', 'register_endpoints' ) );
33
34
/**
35
 * Class that includes cards in the plugin search results when users enter terms that match some Jetpack feature.
36
 * Card can be dismissed and includes a title, description, button to enable the feature and a link for more information.
37
 *
38
 * @since 7.1.0
39
 */
40
class Jetpack_Plugin_Search {
41
42
	/**
43
	 * PSH slug name.
44
	 *
45
	 * @var string
46
	 */
47
	public static $slug = 'jetpack-plugin-search';
48
49
	/**
50
	 * Singleton constructor.
51
	 *
52
	 * @return Jetpack_Plugin_Search
53
	 */
54
	public static function init() {
55
		static $instance = null;
56
57
		if ( ! $instance ) {
58
			$instance = new Jetpack_Plugin_Search();
59
		}
60
61
		return $instance;
62
	}
63
64
	/**
65
	 * Jetpack_Plugin_Search constructor.
66
	 */
67
	public function __construct() {
68
		add_action( 'current_screen', array( $this, 'start' ) );
69
	}
70
71
	/**
72
	 * Add actions and filters only if this is the plugin installation screen and it's the first page.
73
	 *
74
	 * @param object $screen WP SCreen object.
75
	 *
76
	 * @since 7.1.0
77
	 */
78
	public function start( $screen ) {
79
		if ( 'plugin-install' === $screen->base && ( ! isset( $_GET['paged'] ) || 1 === intval( $_GET['paged'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
80
			add_action( 'admin_enqueue_scripts', array( $this, 'load_plugins_search_script' ) );
81
			add_filter( 'plugins_api_result', array( $this, 'inject_jetpack_module_suggestion' ), 10, 3 );
82
			add_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
83
			add_filter( 'plugin_install_action_links', array( $this, 'insert_module_related_links' ), 10, 2 );
84
		}
85
	}
86
87
	/**
88
	 * Modify URL used to fetch to plugin information so it pulls Jetpack plugin page.
89
	 *
90
	 * @param string $url URL to load in dialog pulling the plugin page from wporg.
91
	 *
92
	 * @since 7.1.0
93
	 *
94
	 * @return string The URL with 'jetpack' instead of 'jetpack-plugin-search'.
95
	 */
96
	public function plugin_details( $url ) {
97
		return false !== stripos( $url, 'tab=plugin-information&amp;plugin=' . self::$slug )
98
			? 'plugin-install.php?tab=plugin-information&amp;plugin=jetpack&amp;TB_iframe=true&amp;width=600&amp;height=550'
99
			: $url;
100
	}
101
102
	/**
103
	 * Register REST API endpoints.
104
	 *
105
	 * @since 7.1.0
106
	 */
107
	public static function register_endpoints() {
108
		register_rest_route(
109
			'jetpack/v4',
110
			'/hints',
111
			array(
112
				'methods'             => WP_REST_Server::EDITABLE,
113
				'callback'            => __CLASS__ . '::dismiss',
114
				'permission_callback' => __CLASS__ . '::can_request',
115
				'args'                => array(
116
					'hint' => array(
117
						'default'           => '',
118
						'type'              => 'string',
119
						'required'          => true,
120
						'validate_callback' => __CLASS__ . '::is_hint_id',
121
					),
122
				),
123
			)
124
		);
125
	}
126
127
	/**
128
	 * A WordPress REST API permission callback method that accepts a request object and
129
	 * decides if the current user has enough privileges to act.
130
	 *
131
	 * @since 7.1.0
132
	 *
133
	 * @return bool does a current user have enough privileges.
134
	 */
135
	public static function can_request() {
136
		return current_user_can( 'jetpack_admin_page' );
137
	}
138
139
	/**
140
	 * Validates that the ID of the hint to dismiss is a string.
141
	 *
142
	 * @since 7.1.0
143
	 *
144
	 * @param string|bool     $value Value to check.
145
	 * @param WP_REST_Request $request The request sent to the WP REST API.
146
	 * @param string          $param Name of the parameter passed to endpoint holding $value.
147
	 *
148
	 * @return bool|WP_Error
149
	 */
150
	public static function is_hint_id( $value, $request, $param ) {
151
		return in_array( $value, Jetpack::get_available_modules(), true )
152
			? true
153
			/* translators: %s is the name of a parameter passed to an endpoint. */
154
			: new WP_Error( 'invalid_param', sprintf( esc_html__( '%s must be an alphanumeric string.', 'jetpack' ), $param ) );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'invalid_param'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
155
	}
156
157
	/**
158
	 * A WordPress REST API callback method that accepts a request object and decides what to do with it.
159
	 *
160
	 * @param WP_REST_Request $request {
161
	 *     Array of parameters received by request.
162
	 *
163
	 *     @type string $hint Slug of card to dismiss.
164
	 * }
165
	 *
166
	 * @since 7.1.0
167
	 *
168
	 * @return bool|array|WP_Error a resulting value or object, or an error.
169
	 */
170
	public static function dismiss( WP_REST_Request $request ) {
171
		return self::add_to_dismissed_hints( $request['hint'] )
172
			? rest_ensure_response( array( 'code' => 'success' ) )
173
			: new WP_Error( 'not_dismissed', esc_html__( 'The card could not be dismissed', 'jetpack' ), array( 'status' => 400 ) );
0 ignored issues
show
Unused Code introduced by
The call to WP_Error::__construct() has too many arguments starting with 'not_dismissed'.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
174
	}
175
176
	/**
177
	 * Returns a list of previously dismissed hints.
178
	 *
179
	 * @since 7.1.0
180
	 *
181
	 * @return array List of dismissed hints.
182
	 */
183
	protected static function get_dismissed_hints() {
184
		$dismissed_hints = Jetpack_Options::get_option( 'dismissed_hints' );
185
		return isset( $dismissed_hints ) && is_array( $dismissed_hints )
186
			? $dismissed_hints
187
			: array();
188
	}
189
190
	/**
191
	 * Save the hint in the list of dismissed hints.
192
	 *
193
	 * @since 7.1.0
194
	 *
195
	 * @param string $hint The hint id, which is a Jetpack module slug.
196
	 *
197
	 * @return bool Whether the card was added to the list and hence dismissed.
198
	 */
199
	protected static function add_to_dismissed_hints( $hint ) {
200
		return Jetpack_Options::update_option( 'dismissed_hints', array_merge( self::get_dismissed_hints(), array( $hint ) ) );
201
	}
202
203
	/**
204
	 * Checks that the module slug passed should be displayed.
205
	 *
206
	 * A feature hint will be displayed if it has not been dismissed before or if 2 or fewer other hints have been dismissed.
207
	 *
208
	 * @since 7.2.1
209
	 *
210
	 * @param string $hint The hint id, which is a Jetpack module slug.
211
	 *
212
	 * @return bool True if $hint should be displayed.
213
	 */
214
	protected function should_display_hint( $hint ) {
215
		$dismissed_hints = $this->get_dismissed_hints();
216
		// If more than 2 hints have been dismissed, then show no more.
217
		if ( 2 < count( $dismissed_hints ) ) {
218
			return false;
219
		}
220
221
		$plan = Jetpack_Plan::get();
222
		if ( isset( $plan['class'] ) && ( 'free' === $plan['class'] || 'personal' === $plan['class'] ) && 'vaultpress' === $hint ) {
223
			return false;
224
		}
225
226
		return ! in_array( $hint, $dismissed_hints, true );
227
	}
228
229
	/**
230
	 * Load the search scripts and CSS for PSH.
231
	 */
232
	public function load_plugins_search_script() {
233
		wp_enqueue_script( self::$slug, plugins_url( 'modules/plugin-search/plugin-search.js', JETPACK__PLUGIN_FILE ), array( 'jquery' ), JETPACK__VERSION, true );
234
		wp_localize_script(
235
			self::$slug,
236
			'jetpackPluginSearch',
237
			array(
238
				'nonce'          => wp_create_nonce( 'wp_rest' ),
239
				'base_rest_url'  => rest_url( '/jetpack/v4' ),
240
				'poweredBy'      => esc_html__( 'by Jetpack (installed)', 'jetpack' ),
241
				'manageSettings' => esc_html__( 'Configure', 'jetpack' ),
242
				'activateModule' => esc_html__( 'Activate Module', 'jetpack' ),
243
				'getStarted'     => esc_html__( 'Get started', 'jetpack' ),
244
				'activated'      => esc_html__( 'Activated', 'jetpack' ),
245
				'activating'     => esc_html__( 'Activating', 'jetpack' ),
246
				'logo'           => 'https://ps.w.org/jetpack/assets/icon.svg?rev=1791404',
247
				'legend'         => esc_html__(
248
					'This suggestion was made by Jetpack, the security and performance plugin already installed on your site.',
249
					'jetpack'
250
				),
251
				'supportText'    => esc_html__(
252
					'Learn more about these suggestions.',
253
					'jetpack'
254
				),
255
				'supportLink'    => Redirect::get_url( 'plugin-hint-learn-support' ),
256
				'hideText'       => esc_html__( 'Hide this suggestion', 'jetpack' ),
257
			)
258
		);
259
260
		wp_enqueue_style( self::$slug, plugins_url( 'modules/plugin-search/plugin-search.css', JETPACK__PLUGIN_FILE ), array(), JETPACK__VERSION );
261
	}
262
263
	/**
264
	 * Get the plugin repo's data for Jetpack to populate the fields with.
265
	 *
266
	 * @return array|mixed|object|WP_Error
267
	 */
268
	public static function get_jetpack_plugin_data() {
269
		$data = get_transient( 'jetpack_plugin_data' );
270
271
		if ( false === $data || is_wp_error( $data ) ) {
272
			include_once ABSPATH . 'wp-admin/includes/plugin-install.php';
273
			$data = plugins_api(
274
				'plugin_information',
275
				array(
276
					'slug'   => 'jetpack',
277
					'is_ssl' => is_ssl(),
278
					'fields' => array(
279
						'banners'         => true,
280
						'reviews'         => true,
281
						'active_installs' => true,
282
						'versions'        => false,
283
						'sections'        => false,
284
					),
285
				)
286
			);
287
			set_transient( 'jetpack_plugin_data', $data, DAY_IN_SECONDS );
288
		}
289
290
		return $data;
291
	}
292
293
	/**
294
	 * Create a list with additional features for those we don't have a module, like Akismet.
295
	 *
296
	 * @since 7.1.0
297
	 *
298
	 * @return array List of features.
299
	 */
300
	public function get_extra_features() {
301
		return array(
302
			'akismet' => array(
303
				'name'                => 'Akismet',
304
				'search_terms'        => 'akismet, anti-spam, antispam, comments, spam, spam protection, form spam, captcha, no captcha, nocaptcha, recaptcha, phising, google',
305
				'short_description'   => esc_html__( 'Keep your visitors and search engines happy by stopping comment and contact form spam with Akismet.', 'jetpack' ),
306
				'requires_connection' => true,
307
				'module'              => 'akismet',
308
				'sort'                => '16',
309
				'learn_more_button'   => Redirect::get_url( 'plugin-hint-upgrade-akismet' ),
310
				'configure_url'       => admin_url( 'admin.php?page=akismet-key-config' ),
311
			),
312
		);
313
	}
314
315
	/**
316
	 * Intercept the plugins API response and add in an appropriate card for Jetpack
317
	 *
318
	 * @param object $result Plugin search results.
319
	 * @param string $action unused.
320
	 * @param object $args Search args.
321
	 */
322
	public function inject_jetpack_module_suggestion( $result, $action, $args ) {
323
		// Looks like a search query; it's matching time.
324
		if ( ! empty( $args->search ) ) {
325
			require_once JETPACK__PLUGIN_DIR . 'class.jetpack-admin.php';
326
			$tracking             = new Tracking();
327
			$jetpack_modules_list = array_intersect_key(
328
				array_merge( $this->get_extra_features(), Jetpack_Admin::init()->get_modules() ),
329
				array_flip(
330
					array(
331
						'contact-form',
332
						'lazy-images',
333
						'monitor',
334
						'photon',
335
						'photon-cdn',
336
						'protect',
337
						'publicize',
338
						'related-posts',
339
						'sharedaddy',
340
						'akismet',
341
						'vaultpress',
342
						'videopress',
343
						'search',
344
					)
345
				)
346
			);
347
			uasort( $jetpack_modules_list, array( $this, 'by_sorting_option' ) );
348
349
			// Record event when user searches for a term over 3 chars (less than 3 is not very useful).
350
			if ( strlen( $args->search ) >= 3 ) {
351
				$tracking->record_user_event( 'wpa_plugin_search_term', array( 'search_term' => $args->search ) );
352
			}
353
354
			// Lowercase, trim, remove punctuation/special chars, decode url, remove 'jetpack'.
355
			$normalized_term = $this->sanitize_search_term( $args->search );
356
357
			$matching_module = null;
358
359
			// Try to match a passed search term with module's search terms.
360
			foreach ( $jetpack_modules_list as $module_slug => $module_opts ) {
361
				/*
362
				* Does the site's current plan support the feature?
363
				* We don't use Jetpack_Plan::supports() here because
364
				* that check always returns Akismet as supported,
365
				* since Akismet has a free version.
366
				*/
367
				$current_plan         = Jetpack_Plan::get();
368
				$is_supported_by_plan = in_array( $module_slug, $current_plan['supports'], true );
369
370
				if (
371
					false !== stripos( $module_opts['search_terms'] . ', ' . $module_opts['name'], $normalized_term )
372
					&& $is_supported_by_plan
373
				) {
374
					$matching_module = $module_slug;
375
					break;
376
				}
377
			}
378
379
			if ( isset( $matching_module ) && $this->should_display_hint( $matching_module ) ) {
380
				// Record event when a matching feature is found.
381
				$tracking->record_user_event( 'wpa_plugin_search_match_found', array( 'feature' => $matching_module ) );
382
383
				$inject    = (array) self::get_jetpack_plugin_data();
384
				$image_url = plugins_url( 'modules/plugin-search/psh', JETPACK__PLUGIN_FILE );
385
				$overrides = array(
386
					'plugin-search'       => true, // Helps to determine if that an injected card.
387
					'name'                => sprintf(       // Supplement name/description so that they clearly indicate this was added.
388
						/* translators: Jetpack module name */
389
						esc_html_x( 'Jetpack: %s', 'Jetpack: Module Name', 'jetpack' ),
390
						$jetpack_modules_list[ $matching_module ]['name']
391
					),
392
					'short_description'   => $jetpack_modules_list[ $matching_module ]['short_description'],
393
					'requires_connection' => (bool) $jetpack_modules_list[ $matching_module ]['requires_connection'],
394
					'slug'                => self::$slug,
395
					'version'             => JETPACK__VERSION,
396
					'icons'               => array(
397
						'1x'  => "$image_url-128.png",
398
						'2x'  => "$image_url-256.png",
399
						'svg' => "$image_url.svg",
400
					),
401
				);
402
403
				// Splice in the base module data.
404
				$inject = array_merge( $inject, $jetpack_modules_list[ $matching_module ], $overrides );
405
406
				// Add it to the top of the list.
407
				$result->plugins = array_filter( $result->plugins, array( $this, 'filter_cards' ) );
408
				array_unshift( $result->plugins, $inject );
409
			}
410
		}
411
		return $result;
412
	}
413
414
	/**
415
	 * Remove cards for Jetpack plugins since we don't want duplicates.
416
	 *
417
	 * @since 7.1.0
418
	 * @since 7.2.0 Only remove Jetpack.
419
	 * @since 7.4.0 Simplify for WordPress 5.1+.
420
	 *
421
	 * @param array|object $plugin WordPress search result card.
422
	 *
423
	 * @return bool
424
	 */
425
	public function filter_cards( $plugin ) {
426
		return ! in_array( $plugin['slug'], array( 'jetpack' ), true );
427
	}
428
429
	/**
430
	 * Take a raw search query and return something a bit more standardized and
431
	 * easy to work with.
432
	 *
433
	 * @param  string $term The raw search term.
434
	 * @return string A simplified/sanitized version.
435
	 */
436
	private function sanitize_search_term( $term ) {
437
		$term = strtolower( urldecode( $term ) );
438
439
		// remove non-alpha/space chars.
440
		$term = preg_replace( '/[^a-z ]/', '', $term );
441
442
		// remove strings that don't help matches.
443
		$term = trim( str_replace( array( 'jetpack', 'jp', 'free', 'wordpress' ), '', $term ) );
444
445
		return $term;
446
	}
447
448
	/**
449
	 * Callback function to sort the array of modules by the sort option.
450
	 *
451
	 * @param array $m1 Array 1 to sort.
452
	 * @param array $m2 Array 2 to sort.
453
	 */
454
	private function by_sorting_option( $m1, $m2 ) {
455
		return $m1['sort'] - $m2['sort'];
456
	}
457
458
	/**
459
	 * Modify the URL to the feature settings, for example Publicize.
460
	 * Sharing is included here because while we still have a page in WP Admin,
461
	 * we prefer to send users to Calypso.
462
	 *
463
	 * @param string $feature Feature.
464
	 * @param string $configure_url URL to configure feature.
465
	 *
466
	 * @return string
467
	 * @since 7.1.0
468
	 */
469
	private function get_configure_url( $feature, $configure_url ) {
470
		switch ( $feature ) {
471
			case 'sharing':
472
			case 'publicize':
473
				$configure_url = Redirect::get_url( 'calypso-marketing-connections' );
474
				break;
475
			case 'seo-tools':
476
				$configure_url = Redirect::get_url(
477
					'calypso-marketing-traffic',
478
					array(
479
						'anchor' => 'seo',
480
					)
481
				);
482
				break;
483
			case 'google-analytics':
484
				$configure_url = Redirect::get_url(
485
					'calypso-marketing-traffic',
486
					array(
487
						'anchor' => 'analytics',
488
					)
489
				);
490
				break;
491
			case 'wordads':
492
				$configure_url = Redirect::get_url( 'wpcom-ads-settings' );
493
				break;
494
		}
495
		return $configure_url;
496
	}
497
498
	/**
499
	 * Put some more appropriate links on our custom result cards.
500
	 *
501
	 * @param array $links Related links.
502
	 * @param array $plugin Plugin result information.
503
	 */
504
	public function insert_module_related_links( $links, $plugin ) {
505
		if ( self::$slug !== $plugin['slug'] ) {
506
			return $links;
507
		}
508
509
		// By the time this filter is applied, self_admin_url was already applied and we don't need it anymore.
510
		remove_filter( 'self_admin_url', array( $this, 'plugin_details' ) );
511
512
		$links = array();
513
514
		if ( 'akismet' === $plugin['module'] || 'vaultpress' === $plugin['module'] ) {
515
			$links['jp_get_started'] = '<a
516
				id="plugin-select-settings"
517
				class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
518
				href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '"
519
				data-module="' . esc_attr( $plugin['module'] ) . '"
520
				data-track="get_started"
521
				>' . esc_html__( 'Get started', 'jetpack' ) . '</a>';
522
			// Jetpack installed, active, feature not enabled; prompt to enable.
523
		} elseif (
524
			current_user_can( 'jetpack_activate_modules' ) &&
525
			! Jetpack::is_module_active( $plugin['module'] ) &&
526
			Jetpack_Plan::supports( $plugin['module'] )
527
		) {
528
			$links[] = '<button
529
					id="plugin-select-activate"
530
					class="jetpack-plugin-search__primary button"
531
					data-module="' . esc_attr( $plugin['module'] ) . '"
532
					data-configure-url="' . esc_url( $this->get_configure_url( $plugin['module'], $plugin['configure_url'] ) ) . '"
533
					> ' . esc_html__( 'Enable', 'jetpack' ) . '</button>';
534
535
			// Jetpack installed, active, feature enabled; link to settings.
536
		} elseif (
537
			! empty( $plugin['configure_url'] ) &&
538
			current_user_can( 'jetpack_configure_modules' ) &&
539
			Jetpack::is_module_active( $plugin['module'] ) &&
540
			/** This filter is documented in class.jetpack-admin.php */
541
			apply_filters( 'jetpack_module_configurable_' . $plugin['module'], false )
542
		) {
543
			$links[] = '<a
544
				id="plugin-select-settings"
545
				class="jetpack-plugin-search__primary button jetpack-plugin-search__configure"
546
				href="' . esc_url( $this->get_configure_url( $plugin['module'], $plugin['configure_url'] ) ) . '"
547
				data-module="' . esc_attr( $plugin['module'] ) . '"
548
				data-track="configure"
549
				>' . esc_html__( 'Configure', 'jetpack' ) . '</a>';
550
			// Module is active, doesn't have options to configure.
551
		} elseif ( Jetpack::is_module_active( $plugin['module'] ) ) {
552
			$links['jp_get_started'] = '<a
553
				id="plugin-select-settings"
554
				class="jetpack-plugin-search__primary jetpack-plugin-search__get-started button"
555
				href="' . esc_url( Redirect::get_url( 'plugin-hint-learn-' . $plugin['module'] ) ) . '"
556
				data-module="' . esc_attr( $plugin['module'] ) . '"
557
				data-track="get_started"
558
				>' . esc_html__( 'Get started', 'jetpack' ) . '</a>';
559
		}
560
561
		// Add link pointing to a relevant doc page in jetpack.com only if the Get started button isn't displayed.
562
		if ( ! empty( $plugin['learn_more_button'] ) && ! isset( $links['jp_get_started'] ) ) {
563
			$links[] = '<a
564
				class="jetpack-plugin-search__learn-more"
565
				href="' . esc_url( $plugin['learn_more_button'] ) . '"
566
				target="_blank"
567
				data-module="' . esc_attr( $plugin['module'] ) . '"
568
				data-track="learn_more"
569
				>' . esc_html__( 'Learn more', 'jetpack' ) . '</a>';
570
		}
571
572
		// Dismiss link.
573
		$links[] = '<a
574
			class="jetpack-plugin-search__dismiss"
575
			data-module="' . esc_attr( $plugin['module'] ) . '"
576
			>' . esc_html__( 'Hide this suggestion', 'jetpack' ) . '</a>';
577
578
		return $links;
579
	}
580
581
}
582
583
/**
584
 * Master control that checks if Plugin search hints is active.
585
 *
586
 * @since 7.1.1
587
 *
588
 * @return bool True if PSH is active.
589
 */
590
function jetpack_is_psh_active() {
591
	/**
592
	 * Disables the Plugin Search Hints feature found when searching the plugins page.
593
	 *
594
	 * @since 8.7.0
595
	 *
596
	 * @param bool Set false to disable the feature.
597
	 */
598
	return apply_filters( 'jetpack_psh_active', true );
599
}
600