• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / wordpress-seo / e575b5b982fd62ca2f978f98ecd3a7c22fb3660d

09 Apr 2025 09:57AM UTC coverage: 54.555% (+0.1%) from 54.437%
e575b5b982fd62ca2f978f98ecd3a7c22fb3660d

Pull #22125

github

web-flow
Merge 09c442941 into 1f39fa1ec
Pull Request #22125: Add tracking of user progress in the Site Kit setup widget

7801 of 13850 branches covered (56.32%)

Branch coverage included in aggregate %.

146 of 161 new or added lines in 10 files covered. (90.68%)

9 existing lines in 2 files now uncovered.

29731 of 54946 relevant lines covered (54.11%)

43379.68 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/inc/options/class-wpseo-option-wpseo.php
1
<?php
2
/**
3
 * WPSEO plugin file.
4
 *
5
 * @package WPSEO\Internals\Options
6
 */
7

8
/**
9
 * Option: wpseo.
10
 */
11
class WPSEO_Option_Wpseo extends WPSEO_Option {
12

13
        /**
14
         * Option name.
15
         *
16
         * @var string
17
         */
18
        public $option_name = 'wpseo';
19

20
        /**
21
         * Array of defaults for the option.
22
         *
23
         * {@internal Shouldn't be requested directly, use $this->get_defaults();}}
24
         *
25
         * @var array
26
         */
27
        protected $defaults = [
28
                // Non-form fields, set via (ajax) function.
29
                'tracking'                                     => null,
30
                'toggled_tracking'                             => false,
31
                'license_server_version'                       => false,
32
                'ms_defaults_set'                              => false,
33
                'ignore_search_engines_discouraged_notice'     => false,
34
                'indexing_first_time'                          => true,
35
                'indexing_started'                             => null,
36
                'indexing_reason'                              => '',
37
                'indexables_indexing_completed'                => false,
38
                'index_now_key'                                => '',
39
                // Non-form field, should only be set via validation routine.
40
                'version'                                      => '', // Leave default as empty to ensure activation/upgrade works.
41
                'previous_version'                             => '',
42
                // Form fields.
43
                'disableadvanced_meta'                         => true,
44
                'enable_headless_rest_endpoints'               => true,
45
                'ryte_indexability'                            => false,
46
                'baiduverify'                                  => '', // Text field.
47
                'googleverify'                                 => '', // Text field.
48
                'msverify'                                     => '', // Text field.
49
                'yandexverify'                                 => '',
50
                'site_type'                                    => '', // List of options.
51
                'has_multiple_authors'                         => '',
52
                'environment_type'                             => '',
53
                'content_analysis_active'                      => true,
54
                'keyword_analysis_active'                      => true,
55
                'inclusive_language_analysis_active'           => false,
56
                'enable_admin_bar_menu'                        => true,
57
                'enable_cornerstone_content'                   => true,
58
                'enable_xml_sitemap'                           => true,
59
                'enable_text_link_counter'                     => true,
60
                'enable_index_now'                             => true,
61
                'enable_ai_generator'                          => true,
62
                'ai_enabled_pre_default'                       => false,
63
                'show_onboarding_notice'                       => false,
64
                'first_activated_on'                           => false,
65
                'myyoast-oauth'                                => [
66
                        'config'        => [
67
                                'clientId' => null,
68
                                'secret'   => null,
69
                        ],
70
                        'access_tokens' => [],
71
                ],
72
                'semrush_integration_active'                   => true,
73
                'semrush_tokens'                               => [],
74
                'semrush_country_code'                         => 'us',
75
                'permalink_structure'                          => '',
76
                'home_url'                                     => '',
77
                'dynamic_permalinks'                           => false,
78
                'category_base_url'                            => '',
79
                'tag_base_url'                                 => '',
80
                'custom_taxonomy_slugs'                        => [],
81
                'enable_enhanced_slack_sharing'                => true,
82
                'enable_metabox_insights'                      => true,
83
                'enable_link_suggestions'                      => true,
84
                'algolia_integration_active'                   => false,
85
                'import_cursors'                               => [],
86
                'workouts_data'                                => [ 'configuration' => [ 'finishedSteps' => [] ] ],
87
                'configuration_finished_steps'                 => [],
88
                'dismiss_configuration_workout_notice'         => false,
89
                'dismiss_premium_deactivated_notice'           => false,
90
                'importing_completed'                          => [],
91
                'wincher_integration_active'                   => true,
92
                'wincher_tokens'                               => [],
93
                'wincher_automatically_add_keyphrases'         => false,
94
                'wincher_website_id'                           => '',
95
                'first_time_install'                           => false,
96
                'should_redirect_after_install_free'           => false,
97
                'activation_redirect_timestamp_free'           => 0,
98
                'remove_feed_global'                           => false,
99
                'remove_feed_global_comments'                  => false,
100
                'remove_feed_post_comments'                    => false,
101
                'remove_feed_authors'                          => false,
102
                'remove_feed_categories'                       => false,
103
                'remove_feed_tags'                             => false,
104
                'remove_feed_custom_taxonomies'                => false,
105
                'remove_feed_post_types'                       => false,
106
                'remove_feed_search'                           => false,
107
                'remove_atom_rdf_feeds'                        => false,
108
                'remove_shortlinks'                            => false,
109
                'remove_rest_api_links'                        => false,
110
                'remove_rsd_wlw_links'                         => false,
111
                'remove_oembed_links'                          => false,
112
                'remove_generator'                             => false,
113
                'remove_emoji_scripts'                         => false,
114
                'remove_powered_by_header'                     => false,
115
                'remove_pingback_header'                       => false,
116
                'clean_campaign_tracking_urls'                 => false,
117
                'clean_permalinks'                             => false,
118
                'clean_permalinks_extra_variables'             => '',
119
                'search_cleanup'                               => false,
120
                'search_cleanup_emoji'                         => false,
121
                'search_cleanup_patterns'                      => false,
122
                'search_character_limit'                       => 50,
123
                'deny_search_crawling'                         => false,
124
                'deny_wp_json_crawling'                        => false,
125
                'deny_adsbot_crawling'                         => false,
126
                'deny_ccbot_crawling'                          => false,
127
                'deny_google_extended_crawling'                => false,
128
                'deny_gptbot_crawling'                         => false,
129
                'redirect_search_pretty_urls'                  => false,
130
                'least_readability_ignore_list'                => [],
131
                'least_seo_score_ignore_list'                  => [],
132
                'most_linked_ignore_list'                      => [],
133
                'least_linked_ignore_list'                     => [],
134
                'indexables_page_reading_list'                 => [ false, false, false, false, false ],
135
                'indexables_overview_state'                    => 'dashboard-not-visited',
136
                'last_known_public_post_types'                 => [],
137
                'last_known_public_taxonomies'                 => [],
138
                'last_known_no_unindexed'                      => [],
139
                'new_post_types'                               => [],
140
                'new_taxonomies'                               => [],
141
                'show_new_content_type_notification'           => false,
142
                'site_kit_configuration_permanently_dismissed' => false,
143
                'site_kit_connected'                           => false,
144
                'site_kit_usage_tracking'                      => [
145
                        'setup_widget_loaded'                => 'no',
146
                        'first_interaction_stage'            => '',
147
                        'last_interaction_stage'             => '',
148
                        'setup_widget_temporarily_dismissed' => 'no',
149
                        'setup_widget_permanently_dismissed' => 'no',
150
                ],
151
        ];
152

153
        /**
154
         * Sub-options which should not be overloaded with multi-site defaults.
155
         *
156
         * @var array
157
         */
158
        public $ms_exclude = [
159
                'ignore_search_engines_discouraged_notice',
160
                /* Privacy. */
161
                'baiduverify',
162
                'googleverify',
163
                'msverify',
164
                'yandexverify',
165
        ];
166

167
        /**
168
         * Possible values for the site_type option.
169
         *
170
         * @var array
171
         */
172
        protected $site_types = [
173
                '',
174
                'blog',
175
                'shop',
176
                'news',
177
                'smallBusiness',
178
                'corporateOther',
179
                'personalOther',
180
        ];
181

182
        /**
183
         * Possible environment types.
184
         *
185
         * @var array
186
         */
187
        protected $environment_types = [
188
                '',
189
                'local',
190
                'production',
191
                'staging',
192
                'development',
193
        ];
194

195
        /**
196
         * Possible has_multiple_authors options.
197
         *
198
         * @var array
199
         */
200
        protected $has_multiple_authors_options = [
201
                '',
202
                true,
203
                false,
204
        ];
205

206
        /**
207
         * Name for an option higher in the hierarchy to override setting access.
208
         *
209
         * @var string
210
         */
211
        protected $override_option_name = 'wpseo_ms';
212

213
        /**
214
         * Add the actions and filters for the option.
215
         *
216
         * @todo [JRF => testers] Check if the extra actions below would run into problems if an option
217
         *       is updated early on and if so, change the call to schedule these for a later action on add/update
218
         *       instead of running them straight away.
219
         */
220
        protected function __construct() {
×
221
                parent::__construct();
×
222

223
                /**
224
                 * Filter: 'wpseo_enable_tracking' - Enables the data tracking of Yoast SEO Premium.
225
                 *
226
                 * @param string|false $is_enabled The enabled state. Default is false.
227
                 */
228
                $this->defaults['tracking'] = apply_filters( 'wpseo_enable_tracking', false );
×
229

230
                /* Clear the cache on update/add. */
231
                add_action( 'add_option_' . $this->option_name, [ 'WPSEO_Utils', 'clear_cache' ] );
×
232
                add_action( 'update_option_' . $this->option_name, [ 'WPSEO_Utils', 'clear_cache' ] );
×
233

234
                add_filter( 'admin_title', [ 'Yoast_Input_Validation', 'add_yoast_admin_document_title_errors' ] );
×
235

236
                /**
237
                 * Filter the `wpseo` option defaults.
238
                 *
239
                 * @param array $defaults Array the defaults for the `wpseo` option attributes.
240
                 */
241
                $this->defaults = apply_filters( 'wpseo_option_wpseo_defaults', $this->defaults );
×
242
        }
243

244
        /**
245
         * Get the singleton instance of this class.
246
         *
247
         * @return object
248
         */
249
        public static function get_instance() {
×
250
                if ( ! ( self::$instance instanceof self ) ) {
×
251
                        self::$instance = new self();
×
252
                }
253

254
                return self::$instance;
×
255
        }
256

257
        /**
258
         * Add filters to make sure that the option is merged with its defaults before being returned.
259
         *
260
         * @return void
261
         */
262
        public function add_option_filters() {
×
263
                parent::add_option_filters();
×
264

265
                list( $hookname, $callback, $priority ) = $this->get_verify_features_option_filter_hook();
×
266

267
                if ( has_filter( $hookname, $callback ) === false ) {
×
268
                        add_filter( $hookname, $callback, $priority );
×
269
                }
270
        }
271

272
        /**
273
         * Remove the option filters.
274
         * Called from the clean_up methods to make sure we retrieve the original old option.
275
         *
276
         * @return void
277
         */
278
        public function remove_option_filters() {
×
279
                parent::remove_option_filters();
×
280

281
                list( $hookname, $callback, $priority ) = $this->get_verify_features_option_filter_hook();
×
282

283
                remove_filter( $hookname, $callback, $priority );
×
284
        }
285

286
        /**
287
         * Add filters to make sure that the option default is returned if the option is not set.
288
         *
289
         * @return void
290
         */
291
        public function add_default_filters() {
×
292
                parent::add_default_filters();
×
293

294
                list( $hookname, $callback, $priority ) = $this->get_verify_features_default_option_filter_hook();
×
295

296
                if ( has_filter( $hookname, $callback ) === false ) {
×
297
                        add_filter( $hookname, $callback, $priority );
×
298
                }
299
        }
300

301
        /**
302
         * Remove the default filters.
303
         * Called from the validate() method to prevent failure to add new options.
304
         *
305
         * @return void
306
         */
307
        public function remove_default_filters() {
×
308
                parent::remove_default_filters();
×
309

310
                list( $hookname, $callback, $priority ) = $this->get_verify_features_default_option_filter_hook();
×
311

312
                remove_filter( $hookname, $callback, $priority );
×
313
        }
314

315
        /**
316
         * Validate the option.
317
         *
318
         * @param array $dirty New value for the option.
319
         * @param array $clean Clean value for the option, normally the defaults.
320
         * @param array $old   Old value of the option.
321
         *
322
         * @return array Validated clean value for the option to be saved to the database.
323
         */
324
        protected function validate_option( $dirty, $clean, $old ) {
×
325

326
                foreach ( $clean as $key => $value ) {
×
327
                        switch ( $key ) {
328
                                case 'version':
×
329
                                        $clean[ $key ] = WPSEO_VERSION;
×
330
                                        break;
×
331
                                case 'previous_version':
×
332
                                case 'semrush_country_code':
×
333
                                case 'license_server_version':
×
334
                                case 'home_url':
×
335
                                case 'index_now_key':
×
336
                                case 'wincher_website_id':
×
337
                                case 'clean_permalinks_extra_variables':
×
338
                                case 'indexables_overview_state':
×
339
                                        if ( isset( $dirty[ $key ] ) ) {
×
340
                                                $clean[ $key ] = $dirty[ $key ];
×
341
                                        }
342
                                        break;
×
343
                                case 'indexing_reason':
×
344
                                        if ( isset( $dirty[ $key ] ) ) {
×
345
                                                $clean[ $key ] = sanitize_text_field( $dirty[ $key ] );
×
346
                                        }
347
                                        break;
×
348

349
                                /* Verification strings. */
350
                                case 'baiduverify':
×
351
                                case 'googleverify':
×
352
                                case 'msverify':
×
353
                                case 'yandexverify':
×
354
                                        $this->validate_verification_string( $key, $dirty, $old, $clean );
×
355
                                        break;
×
356

357
                                /*
358
                                 * Boolean dismiss warnings - not fields - may not be in form
359
                                 * (and don't need to be either as long as the default is false).
360
                                 */
361
                                case 'ignore_search_engines_discouraged_notice':
×
362
                                case 'ms_defaults_set':
×
363
                                        if ( isset( $dirty[ $key ] ) ) {
×
364
                                                $clean[ $key ] = WPSEO_Utils::validate_bool( $dirty[ $key ] );
×
365
                                        }
366
                                        elseif ( isset( $old[ $key ] ) ) {
×
367
                                                $clean[ $key ] = WPSEO_Utils::validate_bool( $old[ $key ] );
×
368
                                        }
369
                                        break;
×
370

371
                                case 'site_type':
×
372
                                        $clean[ $key ] = $old[ $key ];
×
373
                                        if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->site_types, true ) ) {
×
374
                                                $clean[ $key ] = $dirty[ $key ];
×
375
                                        }
376
                                        break;
×
377

378
                                case 'environment_type':
×
379
                                        $clean[ $key ] = $old[ $key ];
×
380
                                        if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->environment_types, true ) ) {
×
381
                                                $clean[ $key ] = $dirty[ $key ];
×
382
                                        }
383
                                        break;
×
384

385
                                case 'has_multiple_authors':
×
386
                                        $clean[ $key ] = $old[ $key ];
×
387
                                        if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->has_multiple_authors_options, true ) ) {
×
388
                                                $clean[ $key ] = $dirty[ $key ];
×
389
                                        }
390

391
                                        break;
×
392

393
                                case 'first_activated_on':
×
394
                                case 'indexing_started':
×
395
                                case 'activation_redirect_timestamp_free':
×
396
                                        $clean[ $key ] = false;
×
397
                                        if ( isset( $dirty[ $key ] ) ) {
×
398
                                                if ( $dirty[ $key ] === false || WPSEO_Utils::validate_int( $dirty[ $key ] ) ) {
×
399
                                                        $clean[ $key ] = $dirty[ $key ];
×
400
                                                }
401
                                        }
402
                                        break;
×
403

404
                                case 'tracking':
×
405
                                        $clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : null );
×
406
                                        break;
×
407

408
                                case 'myyoast_oauth':
×
409
                                case 'semrush_tokens':
×
410
                                case 'custom_taxonomy_slugs':
×
411
                                case 'wincher_tokens':
×
412
                                case 'workouts_data':
×
413
                                case 'configuration_finished_steps':
×
414
                                case 'least_readability_ignore_list':
×
415
                                case 'least_seo_score_ignore_list':
×
416
                                case 'most_linked_ignore_list':
×
417
                                case 'least_linked_ignore_list':
×
418
                                case 'indexables_page_reading_list':
×
419
                                case 'last_known_public_post_types':
×
420
                                case 'last_known_public_taxonomies':
×
421
                                case 'new_post_types':
×
422
                                case 'new_taxonomies':
×
NEW
423
                                case 'site_kit_usage_tracking':
×
UNCOV
424
                                        $clean[ $key ] = $old[ $key ];
×
425

426
                                        if ( isset( $dirty[ $key ] ) ) {
×
427
                                                $items = $dirty[ $key ];
×
428
                                                if ( ! is_array( $items ) ) {
×
429
                                                        $items = json_decode( $dirty[ $key ], true );
×
430
                                                }
431

432
                                                if ( is_array( $items ) ) {
×
433
                                                        $clean[ $key ] = $dirty[ $key ];
×
434
                                                }
435
                                        }
436

437
                                        break;
×
438

439
                                case 'permalink_structure':
×
440
                                case 'category_base_url':
×
441
                                case 'tag_base_url':
×
442
                                        if ( isset( $dirty[ $key ] ) ) {
×
443
                                                $clean[ $key ] = sanitize_option( $key, $dirty[ $key ] );
×
444
                                        }
445
                                        break;
×
446

447
                                case 'search_character_limit':
×
448
                                        if ( isset( $dirty[ $key ] ) ) {
×
449
                                                $clean[ $key ] = (int) $dirty[ $key ];
×
450
                                        }
451
                                        break;
×
452

453
                                case 'import_cursors':
×
454
                                case 'importing_completed':
×
455
                                        if ( isset( $dirty[ $key ] ) && is_array( $dirty[ $key ] ) ) {
×
456
                                                $clean[ $key ] = $dirty[ $key ];
×
457
                                        }
458
                                        break;
×
459

460
                                case 'last_known_no_unindexed':
×
461
                                        $clean[ $key ] = $old[ $key ];
×
462

463
                                        if ( isset( $dirty[ $key ] ) ) {
×
464
                                                $items = $dirty[ $key ];
×
465

466
                                                if ( is_array( $items ) ) {
×
467
                                                        foreach ( $items as $item_key => $item ) {
×
468
                                                                if ( ! is_string( $item_key ) || ! is_numeric( $item ) ) {
×
469
                                                                        unset( $items[ $item_key ] );
×
470
                                                                }
471
                                                        }
472
                                                        $clean[ $key ] = $items;
×
473
                                                }
474
                                        }
475

476
                                        break;
×
477

478
                                /*
479
                                 * Boolean (checkbox) fields.
480
                                 *
481
                                 * Covers:
482
                                 *  'disableadvanced_meta'
483
                                 *  'enable_headless_rest_endpoints'
484
                                 *  'yoast_tracking'
485
                                 *  'dynamic_permalinks'
486
                                 *  'indexing_first_time'
487
                                 *  'first_time_install'
488
                                 *  'remove_feed_global'
489
                                 *  'remove_feed_global_comments'
490
                                 *  'remove_feed_post_comments'
491
                                 *  'remove_feed_authors'
492
                                 *  'remove_feed_categories'
493
                                 *  'remove_feed_tags'
494
                                 *  'remove_feed_custom_taxonomies'
495
                                 *  'remove_feed_post_types'
496
                                 *  'remove_feed_search'
497
                                 *  'remove_atom_rdf_feeds'
498
                                 *  'remove_shortlinks'
499
                                 *  'remove_rest_api_links'
500
                                 *  'remove_rsd_wlw_links'
501
                                 *  'remove_oembed_links'
502
                                 *  'remove_generator'
503
                                 *  'remove_emoji_scripts'
504
                                 *  'remove_powered_by_header'
505
                                 *  'remove_pingback_header'
506
                                 *  'clean_campaign_tracking_urls'
507
                                 *  'clean_permalinks'
508
                                 *  'clean_permalinks_extra_variables'
509
                                 *  'search_cleanup'
510
                                 *  'search_cleanup_emoji'
511
                                 *  'search_cleanup_patterns'
512
                                 *  'deny_wp_json_crawling'
513
                                 *  'deny_adsbot_crawling'
514
                                 *  'deny_ccbot_crawling'
515
                                 *  'deny_google_extended_crawling'
516
                                 *  'deny_gptbot_crawling'
517
                                 *  'redirect_search_pretty_urls'
518
                                 *  'should_redirect_after_install_free'
519
                                 *  'show_new_content_type_notification'
520
                                 *  'site_kit_configuration_permanently_dismissed',
521
                                 * 'site_kit_connected',
522
                                 *  and most of the feature variables.
523
                                 */
524
                                default:
525
                                        $clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false );
×
526
                                        break;
×
527
                        }
528
                }
529

530
                return $clean;
×
531
        }
532

533
        /**
534
         * Verifies that the feature variables are turned off if the network is configured so.
535
         *
536
         * @param mixed $options Value of the option to be returned. Typically an array.
537
         *
538
         * @return mixed Filtered $options value.
539
         */
540
        public function verify_features_against_network( $options = [] ) {
×
541
                if ( ! is_array( $options ) || empty( $options ) ) {
×
542
                        return $options;
×
543
                }
544

545
                // For the feature variables, set their values to off in case they are disabled.
546
                $feature_vars = [
547
                        'disableadvanced_meta'               => false,
×
548
                        'ryte_indexability'                  => false,
549
                        'content_analysis_active'            => false,
550
                        'keyword_analysis_active'            => false,
551
                        'inclusive_language_analysis_active' => false,
552
                        'enable_admin_bar_menu'              => false,
553
                        'enable_cornerstone_content'         => false,
554
                        'enable_xml_sitemap'                 => false,
555
                        'enable_text_link_counter'           => false,
556
                        'enable_metabox_insights'            => false,
557
                        'enable_link_suggestions'            => false,
558
                        'enable_headless_rest_endpoints'     => false,
559
                        'tracking'                           => false,
560
                        'enable_enhanced_slack_sharing'      => false,
561
                        'semrush_integration_active'         => false,
562
                        'wincher_integration_active'         => false,
563
                        'remove_feed_global'                 => false,
564
                        'remove_feed_global_comments'        => false,
565
                        'remove_feed_post_comments'          => false,
566
                        'enable_index_now'                   => false,
567
                        'enable_ai_generator'                => false,
568
                        'remove_feed_authors'                => false,
569
                        'remove_feed_categories'             => false,
570
                        'remove_feed_tags'                   => false,
571
                        'remove_feed_custom_taxonomies'      => false,
572
                        'remove_feed_post_types'             => false,
573
                        'remove_feed_search'                 => false,
574
                        'remove_atom_rdf_feeds'              => false,
575
                        'remove_shortlinks'                  => false,
576
                        'remove_rest_api_links'              => false,
577
                        'remove_rsd_wlw_links'               => false,
578
                        'remove_oembed_links'                => false,
579
                        'remove_generator'                   => false,
580
                        'remove_emoji_scripts'               => false,
581
                        'remove_powered_by_header'           => false,
582
                        'remove_pingback_header'             => false,
583
                        'clean_campaign_tracking_urls'       => false,
584
                        'clean_permalinks'                   => false,
585
                        'search_cleanup'                     => false,
586
                        'search_cleanup_emoji'               => false,
587
                        'search_cleanup_patterns'            => false,
588
                        'redirect_search_pretty_urls'        => false,
589
                        'algolia_integration_active'         => false,
590
                ];
591

592
                // We can reuse this logic from the base class with the above defaults to parse with the correct feature values.
593
                $options = $this->prevent_disabled_options_update( $options, $feature_vars );
×
594

595
                return $options;
×
596
        }
597

598
        /**
599
         * Gets the filter hook name and callback for adjusting the retrieved option value
600
         * against the network-allowed features.
601
         *
602
         * @return array Array where the first item is the hook name, the second is the hook callback,
603
         *               and the third is the hook priority.
604
         */
605
        protected function get_verify_features_option_filter_hook() {
×
606
                return [
607
                        "option_{$this->option_name}",
×
608
                        [ $this, 'verify_features_against_network' ],
×
609
                        11,
×
610
                ];
611
        }
612

613
        /**
614
         * Gets the filter hook name and callback for adjusting the default option value against the network-allowed features.
615
         *
616
         * @return array Array where the first item is the hook name, the second is the hook callback,
617
         *               and the third is the hook priority.
618
         */
619
        protected function get_verify_features_default_option_filter_hook() {
×
620
                return [
621
                        "default_option_{$this->option_name}",
×
622
                        [ $this, 'verify_features_against_network' ],
×
623
                        11,
×
624
                ];
625
        }
626

627
        /**
628
         * Clean a given option value.
629
         *
630
         * @param array       $option_value          Old (not merged with defaults or filtered) option value to
631
         *                                           clean according to the rules for this option.
632
         * @param string|null $current_version       Optional. Version from which to upgrade, if not set,
633
         *                                           version specific upgrades will be disregarded.
634
         * @param array|null  $all_old_option_values Optional. Only used when importing old options to have
635
         *                                           access to the real old values, in contrast to the saved ones.
636
         *
637
         * @return array Cleaned option.
638
         */
639
        protected function clean_option( $option_value, $current_version = null, $all_old_option_values = null ) {
×
640
                // Deal with value change from text string to boolean.
641
                $value_change = [
642
                        'ignore_search_engines_discouraged_notice',
×
643
                ];
644

645
                $target_values = [
646
                        'ignore',
×
647
                        'done',
648
                ];
649

650
                foreach ( $value_change as $key ) {
×
651
                        if ( isset( $option_value[ $key ] )
×
652
                                && in_array( $option_value[ $key ], $target_values, true )
×
653
                        ) {
654
                                $option_value[ $key ] = true;
×
655
                        }
656
                }
657

658
                return $option_value;
×
659
        }
660
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc