WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru Получай пассивный доход от сайта с помощью браузерных PUSH уведомлений
функция не описана

WPSEO_Option_Wpseo::validate_option() protected Yoast 1.0

Validate the option.

{} Это метод класса: WPSEO_Option_Wpseo{}

Хуков нет.

Возвращает

Массив. Validated clean value for the option to be saved to the database.

Использование

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_option( $dirty, $clean, $old );
$dirty(массив) (обязательный)
New value for the option.
$clean(массив) (обязательный)
Clean value for the option, normally the defaults.
$old(массив) (обязательный)
Old value of the option.

Код WPSEO_Option_Wpseo::validate_option() Yoast 16.2

<?php
protected function validate_option( $dirty, $clean, $old ) {

	foreach ( $clean as $key => $value ) {
		switch ( $key ) {
			case 'version':
				$clean[ $key ] = WPSEO_VERSION;
				break;
			case 'previous_version':
			case 'semrush_country_code':
			case 'license_server_version':
			case 'home_url':
			case 'zapier_api_key':
				if ( isset( $dirty[ $key ] ) ) {
					$clean[ $key ] = $dirty[ $key ];
				}
				break;
			case 'indexing_reason':
				if ( isset( $dirty[ $key ] ) ) {
					$clean[ $key ] = sanitize_text_field( $dirty[ $key ] );
				}
				break;

			/* Verification strings. */
			case 'baiduverify':
			case 'googleverify':
			case 'msverify':
			case 'yandexverify':
				$this->validate_verification_string( $key, $dirty, $old, $clean );
				break;

			/*
			 * Boolean dismiss warnings - not fields - may not be in form
			 * (and don't need to be either as long as the default is false).
			 */
			case 'ignore_search_engines_discouraged_notice':
			case 'ms_defaults_set':
				if ( isset( $dirty[ $key ] ) ) {
					$clean[ $key ] = WPSEO_Utils::validate_bool( $dirty[ $key ] );
				}
				elseif ( isset( $old[ $key ] ) ) {
					$clean[ $key ] = WPSEO_Utils::validate_bool( $old[ $key ] );
				}
				break;

			case 'site_type':
				$clean[ $key ] = $old[ $key ];
				if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->site_types, true ) ) {
					$clean[ $key ] = $dirty[ $key ];
				}
				break;

			case 'environment_type':
				$clean[ $key ] = $old[ $key ];
				if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->environment_types, true ) ) {
					$clean[ $key ] = $dirty[ $key ];
				}
				break;

			case 'has_multiple_authors':
				$clean[ $key ] = $old[ $key ];
				if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], $this->has_multiple_authors_options, true ) ) {
					$clean[ $key ] = $dirty[ $key ];
				}

				break;

			case 'first_activated_on':
			case 'indexing_started':
				$clean[ $key ] = false;
				if ( isset( $dirty[ $key ] ) ) {
					if ( $dirty[ $key ] === false || WPSEO_Utils::validate_int( $dirty[ $key ] ) ) {
						$clean[ $key ] = $dirty[ $key ];
					}
				}
				break;

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

			case 'myyoast_oauth':
			case 'semrush_tokens':
			case 'custom_taxonomy_slugs':
			case 'zapier_subscription':
				$clean[ $key ] = $old[ $key ];

				if ( isset( $dirty[ $key ] ) ) {
					$items = $dirty[ $key ];
					if ( ! is_array( $items ) ) {
						$items = json_decode( $dirty[ $key ], true );
					}

					if ( is_array( $items ) ) {
						$clean[ $key ] = $dirty[ $key ];
					}
				}

				break;

			case 'permalink_structure':
			case 'category_base_url':
			case 'tag_base_url':
				if ( isset( $dirty[ $key ] ) ) {
					$clean[ $key ] = sanitize_option( $key, $dirty[ $key ] );
				}
				break;

			/*
			 * Boolean (checkbox) fields.
			 */

			/*
			 * Covers:
			 *  'disableadvanced_meta'
			 *  'enable_headless_rest_endpoints'
			 *  'yoast_tracking'
			 *  'dynamic_permalinks'
			 *  'indexing_first_time'
			 *  and most of the feature variables.
			 */
			default:
				$clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false );
				break;
		}
	}

	return $clean;
}