WPSEO_Option_MS::validate_option()
Validate the option.
Метод класса: WPSEO_Option_MS{}
Хуков нет.
Возвращает
Массив
. 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_MS::validate_option() WPSEO Option MS::validate option Yoast 22.4
protected function validate_option( $dirty, $clean, $old ) { foreach ( $clean as $key => $value ) { switch ( $key ) { case 'access': if ( isset( $dirty[ $key ] ) && in_array( $dirty[ $key ], self::$allowed_access_options, true ) ) { $clean[ $key ] = $dirty[ $key ]; } elseif ( function_exists( 'add_settings_error' ) ) { add_settings_error( $this->group_name, // Slug title of the setting. $key, // Suffix-ID for the error message box. /* translators: %1$s expands to the option name and %2$sexpands to Yoast SEO */ sprintf( __( '%1$s is not a valid choice for who should be allowed access to the %2$s settings. Value reset to the default.', 'wordpress-seo' ), esc_html( sanitize_text_field( $dirty[ $key ] ) ), 'Yoast SEO' ), // The error message. 'error' // Message type. ); } break; case 'defaultblog': if ( isset( $dirty[ $key ] ) && ( $dirty[ $key ] !== '' && $dirty[ $key ] !== '-' ) ) { $int = WPSEO_Utils::validate_int( $dirty[ $key ] ); if ( $int !== false && $int > 0 ) { // Check if a valid blog number has been received. $exists = get_blog_details( $int, false ); if ( $exists && $exists->deleted === '0' ) { $clean[ $key ] = $int; } elseif ( function_exists( 'add_settings_error' ) ) { add_settings_error( $this->group_name, // Slug title of the setting. $key, // Suffix-ID for the error message box. esc_html__( 'The default blog setting must be the numeric blog id of the blog you want to use as default.', 'wordpress-seo' ) . '<br>' . sprintf( /* translators: %s is the ID number of a blog. */ esc_html__( 'This must be an existing blog. Blog %s does not exist or has been marked as deleted.', 'wordpress-seo' ), '<strong>' . esc_html( sanitize_text_field( $dirty[ $key ] ) ) . '</strong>' ), // The error message. 'error' // Message type. ); } unset( $exists ); } elseif ( function_exists( 'add_settings_error' ) ) { add_settings_error( $this->group_name, // Slug title of the setting. $key, // Suffix-ID for the error message box. esc_html__( 'The default blog setting must be the numeric blog id of the blog you want to use as default.', 'wordpress-seo' ) . '<br>' . esc_html__( 'No numeric value was received.', 'wordpress-seo' ), // The error message. 'error' // Message type. ); } unset( $int ); } break; default: $clean[ $key ] = ( isset( $dirty[ $key ] ) ? WPSEO_Utils::validate_bool( $dirty[ $key ] ) : false ); break; } } return $clean; }