WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

WPSEO_Option_Social::validate_option() protected Yoast 1.0

Validate the option.

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

Хуков нет.

Возвращает

Массив. 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_Social::validate_option() Yoast 17.3

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

	foreach ( $clean as $key => $value ) {
		switch ( $key ) {
			/* Text fields. */
			case 'og_frontpage_desc':
			case 'og_frontpage_title':
				if ( isset( $dirty[ $key ] ) && $dirty[ $key ] !== '' ) {
					$clean[ $key ] = WPSEO_Utils::sanitize_text_field( $dirty[ $key ] );
				}
				break;

			case 'og_default_image_id':
			case 'og_frontpage_image_id':
				if ( isset( $dirty[ $key ] ) ) {
					$clean[ $key ] = (int) $dirty[ $key ];

					if ( $dirty[ $key ] === '' ) {
						$clean[ $key ] = $dirty[ $key ];
					}
				}
				break;

			/* URL text fields - no ftp allowed. */
			case 'facebook_site':
			case 'instagram_url':
			case 'linkedin_url':
			case 'myspace_url':
			case 'pinterest_url':
			case 'og_default_image':
			case 'og_frontpage_image':
			case 'youtube_url':
			case 'wikipedia_url':
				$this->validate_url( $key, $dirty, $old, $clean );
				break;

			case 'pinterestverify':
				$this->validate_verification_string( $key, $dirty, $old, $clean );
				break;

			/* Twitter user name. */
			case 'twitter_site':
				if ( isset( $dirty[ $key ] ) && $dirty[ $key ] !== '' ) {
					$twitter_id = sanitize_text_field( ltrim( $dirty[ $key ], '@' ) );

					/*
					 * From the Twitter documentation about twitter screen names:
					 * Typically a maximum of 15 characters long, but some historical accounts
					 * may exist with longer names.
					 * A username can only contain alphanumeric characters (letters A-Z, numbers 0-9)
					 * with the exception of underscores.
					 *
					 * @link https://support.twitter.com/articles/101299-why-can-t-i-register-certain-usernames
					 */
					if ( preg_match( '`^[A-Za-z0-9_]{1,25}$`', $twitter_id ) ) {
						$clean[ $key ] = $twitter_id;
					}
					elseif ( preg_match( '`^http(?:s)?://(?:www\.)?twitter\.com/(?P<handle>[A-Za-z0-9_]{1,25})/?$`', $twitter_id, $matches ) ) {
						$clean[ $key ] = $matches['handle'];
					}
					else {
						if ( isset( $old[ $key ] ) && $old[ $key ] !== '' ) {
							$twitter_id = sanitize_text_field( ltrim( $old[ $key ], '@' ) );
							if ( preg_match( '`^[A-Za-z0-9_]{1,25}$`', $twitter_id ) ) {
								$clean[ $key ] = $twitter_id;
							}
						}
						if ( function_exists( 'add_settings_error' ) ) {
							add_settings_error(
								$this->group_name, // Slug title of the setting.
								$key, // Suffix-ID for the error message box.
								sprintf(
									/* translators: %s expands to a twitter user name. */
									__( '%s does not seem to be a valid Twitter Username. Please correct.', 'wordpress-seo' ),
									'<strong>' . esc_html( sanitize_text_field( $dirty[ $key ] ) ) . '</strong>'
								), // The error message.
								'error' // Message type.
							);
						}
					}
					unset( $twitter_id );

					Yoast_Input_Validation::add_dirty_value_to_settings_errors( $key, $dirty[ $key ] );
				}
				break;

			case 'twitter_card_type':
				if ( isset( $dirty[ $key ], self::$twitter_card_types[ $dirty[ $key ] ] ) && $dirty[ $key ] !== '' ) {
					$clean[ $key ] = $dirty[ $key ];
				}
				break;

			/* Boolean fields. */
			case 'opengraph':
			case 'twitter':
				$clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false );
				break;
		}
	}

	return $clean;
}