WPSEO_Option_Tracking_Only::validate_optionprotectedYoast 1.0

All concrete classes must contain a validate_option() method which validates all values within the option.

Метод класса: WPSEO_Option_Tracking_Only{}

Хуков нет.

Возвращает

Массив<Строку,. string> The clean option with the saved value.

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

// protected - в коде основоного (родительского) или дочернего класса
$result = $this->validate_option( $dirty, $clean, $old );
$dirty(обязательный)
.
$clean(обязательный)
.
$old(обязательный)
.

Код WPSEO_Option_Tracking_Only::validate_option() Yoast 27.8

protected function validate_option( $dirty, $clean, $old ) {

	foreach ( $clean as $key => $value ) {
		switch ( $key ) {
			case 'task_list_first_opened_on':
			case 'task_first_actioned_on':
			case 'frontend_inspector_first_actioned_on':
				// These should be set only once and never changed again (unless completely reset to default).

				if ( isset( $dirty[ $key ] ) && $old[ $key ] === $this->get_defaults()[ $key ] ) {
					// Allow setting it for the first time.
					$clean[ $key ] = sanitize_text_field( $dirty[ $key ] );
				}
				elseif ( isset( $dirty[ $key ] ) && $dirty[ $key ] === $this->get_defaults()[ $key ] ) {
					// Allow resetting to default.
					$clean[ $key ] = $dirty[ $key ];
				}
				else {
					// Otherwise keep old value.
					$clean[ $key ] = $old[ $key ];
				}

				break;
		}
	}

	return $clean;
}