Yoast\WP\SEO\Abilities\Infrastructure
Site_Representation_Field_Validators::validate_logo
Validates that a logo is cleared or is an image in the media library.
Метод класса: Site_Representation_Field_Validators{}
Хуков нет.
Возвращает
string|null. A warning when the value cannot be saved, null otherwise.
Использование
$Site_Representation_Field_Validators = new Site_Representation_Field_Validators(); $Site_Representation_Field_Validators->validate_logo( $value, $field_name ): ?string;
- $value(int) (обязательный)
- The attachment ID of the logo to save.
- $field_name(строка) (обязательный)
- The option name of the logo ID.
Код Site_Representation_Field_Validators::validate_logo() Site Representation Field Validators::validate logo Yoast 28.8
public function validate_logo( int $value, string $field_name ): ?string {
if ( $value === 0 || $this->image_helper->is_valid_attachment( $value ) ) {
return null;
}
return \sprintf(
/* translators: %s expands to the name of a setting. */
\__( 'The %s setting was not changed, because it is not the ID of an image in the media library.', 'wordpress-seo' ),
$field_name,
);
}