PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.1
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.1
16.3-a.3 16.3-a.1 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 All 504 releases
← All changes | extensions/plugins/seo/seo.php +42 -2 13.3.316.3-a.1 View file →
@@ -6,21 +6,61 @@
6 6 */
7 7
8 8 namespace Automattic\Jetpack\Extensions\Seo;
9 9
10 +use Automattic\Jetpack\Modules;
11 +
12 +if ( ! defined( 'ABSPATH' ) ) {
13 + exit( 0 );
14 +}
15 +
10 16 add_action(
11 17 'jetpack_register_gutenberg_extensions',
12 18 function () {
19 + if ( is_seo_disabled() ) {
20 + return;
21 + }
22 +
13 23 \Jetpack_Gutenberg::set_availability_for_plan( 'advanced-seo' );
14 - \Jetpack_Gutenberg::set_extension_available( 'jetpack-seo' );
15 24 }
16 25 );
17 26
27 +/**
28 + * We only want to enable the SEO extension (and display SEO settings)
29 + * if the 'jetpack_disable_seo_tools' filter is not set to false.
30 + *
31 + * This is done on after_setup_theme to ensure that we have access to the hook
32 + * that is used by SEO plugins to disable the conflicting output of SEO Tools.
33 + */
34 +add_action(
35 + 'after_setup_theme',
36 + function () {
37 + if (
38 + ! is_seo_disabled()
39 + /** This filter is already documented in modules/seo-tools/class-jetpack-seo-utils.php */
40 + && ! apply_filters( 'jetpack_disable_seo_tools', false )
41 + ) {
42 + \Jetpack_Gutenberg::set_extension_available( 'jetpack-seo' );
43 + }
44 + }
45 +);
46 +
18 47 add_filter(
19 48 'jetpack_set_available_extensions',
20 49 function ( $extensions ) {
21 50 return array_merge(
22 - $extensions,
51 + (array) $extensions,
23 52 array( 'advanced-seo' )
24 53 );
25 54 }
26 55 );
56 +
57 +/**
58 + * SEO tools should be hidden from non-admins if the module is not active.
59 + *
60 + * @since 14.6
61 + *
62 + * @return bool
63 + */
64 +function is_seo_disabled(): bool {
65 + return ! ( new Modules() )->is_active( 'seo-tools' ) && ! current_user_can( 'jetpack_activate_modules' );
66 +}