| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | * |
| 5 | 5 | * @package WPSEO\Admin |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | +use Yoast\WP\SEO\Helpers\Language_Helper; | |
| 8 | 9 | use Yoast\WP\SEO\Presenters\Admin\Alert_Presenter; |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * Class for managing feature toggles. |
| @@ -34,11 +35,9 @@ | ||
| 34 | 35 | * |
| 35 | 36 | * @return self Main instance. |
| 36 | 37 | */ |
| 37 | 38 | public static function instance() { |
| 38 | - if ( self::$instance === null ) { | |
| 39 | - self::$instance = new self(); | |
| 40 | - } | |
| 39 | + self::$instance ??= new self(); | |
| 41 | 40 | |
| 42 | 41 | return self::$instance; |
| 43 | 42 | } |
| 44 | 43 | |
| @@ -47,11 +46,9 @@ | ||
| 47 | 46 | * |
| 48 | 47 | * @return array List of sorted Yoast_Feature_Toggle instances. |
| 49 | 48 | */ |
| 50 | 49 | public function get_all() { |
| 51 | - if ( $this->toggles === null ) { | |
| 52 | - $this->toggles = $this->load_toggles(); | |
| 53 | - } | |
| 50 | + $this->toggles ??= $this->load_toggles(); | |
| 54 | 51 | |
| 55 | 52 | return $this->toggles; |
| 56 | 53 | } |
| 57 | 54 | |
| @@ -65,9 +62,9 @@ | ||
| 65 | 62 | protected function load_toggles() { |
| 66 | 63 | $xml_sitemap_extra = false; |
| 67 | 64 | if ( WPSEO_Options::get( 'enable_xml_sitemap' ) ) { |
| 68 | 65 | $xml_sitemap_extra = '<a href="' . esc_url( WPSEO_Sitemaps_Router::get_base_url( 'sitemap_index.xml' ) ) |
| 69 | - . '" target="_blank">' . esc_html__( 'See the XML sitemap.', 'wordpress-seo' ) . '</a>'; | |
| 66 | + . '" target="_blank">' . esc_html__( 'See the XML sitemap.', 'wordpress-seo' ) . '</a>'; | |
| 70 | 67 | } |
| 71 | 68 | |
| 72 | 69 | $feature_toggles = [ |
| 73 | 70 | (object) [ |
| @@ -86,8 +83,17 @@ | ||
| 86 | 83 | 'read_more_url' => 'https://yoa.st/2ao', |
| 87 | 84 | 'order' => 20, |
| 88 | 85 | ], |
| 89 | 86 | (object) [ |
| 87 | + 'name' => __( 'Inclusive language analysis', 'wordpress-seo' ), | |
| 88 | + 'supported_languages' => Language_Helper::$languages_with_inclusive_language_support, | |
| 89 | + 'setting' => 'inclusive_language_analysis_active', | |
| 90 | + 'label' => __( 'The inclusive language analysis offers suggestions to write more inclusive copy.', 'wordpress-seo' ), | |
| 91 | + 'read_more_label' => __( 'Discover why inclusive language is important for SEO.', 'wordpress-seo' ), | |
| 92 | + 'read_more_url' => 'https://yoa.st/inclusive-language-features-free', | |
| 93 | + 'order' => 25, | |
| 94 | + ], | |
| 95 | + (object) [ | |
| 90 | 96 | 'name' => __( 'Cornerstone content', 'wordpress-seo' ), |
| 91 | 97 | 'setting' => 'enable_cornerstone_content', |
| 92 | 98 | 'label' => __( 'The cornerstone content feature lets you to mark and filter cornerstone content on your website.', 'wordpress-seo' ), |
| 93 | 99 | 'read_more_label' => __( 'Find out how cornerstone content can help you improve your site structure.', 'wordpress-seo' ), |
| @@ -102,26 +108,26 @@ | ||
| 102 | 108 | 'read_more_url' => 'https://yoa.st/2aj', |
| 103 | 109 | 'order' => 40, |
| 104 | 110 | ], |
| 105 | 111 | (object) [ |
| 106 | - 'name' => __( 'Insights', 'wordpress-seo' ), | |
| 107 | - 'premium' => true, | |
| 108 | - 'setting' => 'enable_metabox_insights', | |
| 109 | - 'label' => __( 'Find relevant data about your content right in the Insights section in the Yoast SEO metabox. You’ll see what words you use most often and if they’re a match with your keywords! ', 'wordpress-seo' ), | |
| 110 | - 'read_more_label' => __( 'Find out how Insights can help you improve your content.', 'wordpress-seo' ), | |
| 111 | - 'read_more_url' => 'https://yoa.st/4ew', | |
| 112 | - 'premium_url' => 'https://yoa.st/2ai', | |
| 113 | - 'order' => 41, | |
| 112 | + 'name' => __( 'Insights', 'wordpress-seo' ), | |
| 113 | + 'setting' => 'enable_metabox_insights', | |
| 114 | + 'label' => __( 'Find relevant data about your content right in the Insights section in the Yoast SEO metabox. You’ll see what words you use most often and if they’re a match with your keywords! ', 'wordpress-seo' ), | |
| 115 | + 'read_more_label' => __( 'Find out how Insights can help you improve your content.', 'wordpress-seo' ), | |
| 116 | + 'read_more_url' => 'https://yoa.st/4ew', | |
| 117 | + 'premium_url' => 'https://yoa.st/2ai', | |
| 118 | + 'order' => 41, | |
| 114 | 119 | ], |
| 115 | 120 | (object) [ |
| 116 | - 'name' => __( 'Link suggestions', 'wordpress-seo' ), | |
| 117 | - 'premium' => true, | |
| 118 | - 'setting' => 'enable_link_suggestions', | |
| 119 | - 'label' => __( 'Get relevant internal linking suggestions — while you’re writing! The link suggestions metabox shows a list of posts on your blog with similar content that might be interesting to link to. ', 'wordpress-seo' ), | |
| 120 | - 'read_more_label' => __( 'Read more about how internal linking can improve your site structure.', 'wordpress-seo' ), | |
| 121 | - 'read_more_url' => 'https://yoa.st/4ev', | |
| 122 | - 'premium_url' => 'https://yoa.st/17g', | |
| 123 | - 'order' => 42, | |
| 121 | + 'name' => __( 'Link suggestions', 'wordpress-seo' ), | |
| 122 | + 'premium' => true, | |
| 123 | + 'setting' => 'enable_link_suggestions', | |
| 124 | + 'label' => __( 'Get relevant internal linking suggestions — while you’re writing! The link suggestions metabox shows a list of posts on your blog with similar content that might be interesting to link to. ', 'wordpress-seo' ), | |
| 125 | + 'read_more_label' => __( 'Read more about how internal linking can improve your site structure.', 'wordpress-seo' ), | |
| 126 | + 'read_more_url' => 'https://yoa.st/4ev', | |
| 127 | + 'premium_url' => 'https://yoa.st/17g', | |
| 128 | + 'premium_upsell_url' => 'https://yoa.st/get-link-suggestions', | |
| 129 | + 'order' => 42, | |
| 124 | 130 | ], |
| 125 | 131 | (object) [ |
| 126 | 132 | 'name' => __( 'XML sitemaps', 'wordpress-seo' ), |
| 127 | 133 | 'setting' => 'enable_xml_sitemap', |
| @@ -143,12 +149,12 @@ | ||
| 143 | 149 | (object) [ |
| 144 | 150 | 'name' => __( 'Security: no advanced or schema settings for authors', 'wordpress-seo' ), |
| 145 | 151 | 'setting' => 'disableadvanced_meta', |
| 146 | 152 | 'label' => sprintf( |
| 147 | - /* translators: 1: Yoast SEO, 2: translated version of "Off" */ | |
| 153 | + /* translators: 1: Yoast SEO, 2: translated version of "Off" */ | |
| 148 | 154 | __( 'The advanced section of the %1$s meta box allows a user to remove posts from the search results or change the canonical. The settings in the schema tab allows a user to change schema meta data for a post. These are things you might not want any author to do. That\'s why, by default, only editors and administrators can do this. Setting to "%2$s" allows all users to change these settings.', 'wordpress-seo' ), |
| 149 | 155 | 'Yoast SEO', |
| 150 | - __( 'Off', 'wordpress-seo' ) | |
| 156 | + __( 'Off', 'wordpress-seo' ), | |
| 151 | 157 | ), |
| 152 | 158 | 'order' => 90, |
| 153 | 159 | ], |
| 154 | 160 | (object) [ |
| @@ -157,9 +163,9 @@ | ||
| 157 | 163 | 'setting' => 'tracking', |
| 158 | 164 | 'read_more_label' => sprintf( |
| 159 | 165 | /* translators: 1: Yoast SEO */ |
| 160 | 166 | __( 'Allow us to track some data about your site to improve our plugin.', 'wordpress-seo' ), |
| 161 | - 'Yoast SEO' | |
| 167 | + 'Yoast SEO', | |
| 162 | 168 | ), |
| 163 | 169 | 'read_more_url' => 'https://yoa.st/usage-tracking-2', |
| 164 | 170 | 'order' => 95, |
| 165 | 171 | ], |
| @@ -166,11 +172,11 @@ | ||
| 166 | 172 | (object) [ |
| 167 | 173 | 'name' => __( 'REST API: Head endpoint', 'wordpress-seo' ), |
| 168 | 174 | 'setting' => 'enable_headless_rest_endpoints', |
| 169 | 175 | 'label' => sprintf( |
| 170 | - /* translators: 1: Yoast SEO */ | |
| 176 | + /* translators: 1: Yoast SEO */ | |
| 171 | 177 | __( 'This %1$s REST API endpoint gives you all the metadata you need for a specific URL. This will make it very easy for headless WordPress sites to use %1$s for all their SEO meta output.', 'wordpress-seo' ), |
| 172 | - 'Yoast SEO' | |
| 178 | + 'Yoast SEO', | |
| 173 | 179 | ), |
| 174 | 180 | 'order' => 100, |
| 175 | 181 | ], |
| 176 | 182 | (object) [ |
| @@ -180,8 +186,30 @@ | ||
| 180 | 186 | 'read_more_label' => __( 'Find out how a rich snippet can improve visibility and click-through-rate.', 'wordpress-seo' ), |
| 181 | 187 | 'read_more_url' => 'https://yoa.st/help-slack-share', |
| 182 | 188 | 'order' => 105, |
| 183 | 189 | ], |
| 190 | + (object) [ | |
| 191 | + 'name' => __( 'IndexNow', 'wordpress-seo' ), | |
| 192 | + 'premium' => true, | |
| 193 | + 'setting' => 'enable_index_now', | |
| 194 | + 'label' => __( 'Automatically ping search engines like Bing and Yandex whenever you publish, update or delete a post.', 'wordpress-seo' ), | |
| 195 | + 'read_more_label' => __( 'Find out how IndexNow can help your site.', 'wordpress-seo' ), | |
| 196 | + 'read_more_url' => 'https://yoa.st/index-now-read-more', | |
| 197 | + 'premium_url' => 'https://yoa.st/index-now-feature', | |
| 198 | + 'premium_upsell_url' => 'https://yoa.st/get-indexnow', | |
| 199 | + 'order' => 110, | |
| 200 | + ], | |
| 201 | + (object) [ | |
| 202 | + 'name' => __( 'AI title & description generator', 'wordpress-seo' ), | |
| 203 | + 'premium' => true, | |
| 204 | + 'setting' => 'enable_ai_generator', | |
| 205 | + 'label' => __( 'Use the power of Yoast AI to automatically generate compelling titles and descriptions for your posts and pages.', 'wordpress-seo' ), | |
| 206 | + 'read_more_label' => __( 'Learn more', 'wordpress-seo' ), | |
| 207 | + 'read_more_url' => 'https://yoa.st/ai-generator-read-more', | |
| 208 | + 'premium_url' => 'https://yoa.st/ai-generator-feature', | |
| 209 | + 'premium_upsell_url' => 'https://yoa.st/get-ai-generator', | |
| 210 | + 'order' => 115, | |
| 211 | + ], | |
| 184 | 212 | ]; |
| 185 | 213 | |
| 186 | 214 | /** |
| 187 | 215 | * Filter to add feature toggles from add-ons. |
| @@ -204,11 +232,11 @@ | ||
| 204 | 232 | */ |
| 205 | 233 | protected function sitemaps_toggle_after() { |
| 206 | 234 | $out = '<div id="yoast-seo-sitemaps-disabled-warning" style="display:none;">'; |
| 207 | 235 | $alert = new Alert_Presenter( |
| 208 | - /* translators: %1$s: expands to an opening anchor tag, %2$s: expands to a closing anchor tag */ | |
| 209 | - \sprintf( esc_html__( 'Disabling Yoast SEO\'s XML sitemaps will not disable WordPress\' core sitemaps. In some cases, this %1$s may result in SEO errors on your site%2$s. These may be reported in Google Search Console and other tools.', 'wordpress-seo' ), '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/44z' ) . '">', '</a>' ), | |
| 210 | - 'warning' | |
| 236 | + /* translators: %1$s: expands to an opening anchor tag, %2$s: expands to a closing anchor tag */ | |
| 237 | + sprintf( esc_html__( 'Disabling Yoast SEO\'s XML sitemaps will not disable WordPress\' core sitemaps. In some cases, this %1$s may result in SEO errors on your site%2$s. These may be reported in Google Search Console and other tools.', 'wordpress-seo' ), '<a target="_blank" href="' . WPSEO_Shortlinker::get( 'https://yoa.st/44z' ) . '">', '</a>' ), | |
| 238 | + 'warning', | |
| 211 | 239 | ); |
| 212 | 240 | $out .= $alert->present(); |
| 213 | 241 | $out .= '</div>'; |
| 214 | 242 | |
| @@ -219,8 +247,9 @@ | ||
| 219 | 247 | * Ensures that the passed value is a Yoast_Feature_Toggle. |
| 220 | 248 | * |
| 221 | 249 | * @param Yoast_Feature_Toggle|object|array $toggle_data Feature toggle instance, or raw object or array |
| 222 | 250 | * containing feature toggle data. |
| 251 | + * | |
| 223 | 252 | * @return Yoast_Feature_Toggle Feature toggle instance based on $toggle_data. |
| 224 | 253 | */ |
| 225 | 254 | protected function ensure_toggle( $toggle_data ) { |
| 226 | 255 | if ( $toggle_data instanceof Yoast_Feature_Toggle ) { |