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

WP_Widget_Media_Image::get_instance_schema() public WP 4.8.0

Get schema for properties of a widget instance (item).

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

Хуков нет.

Возвращает

Массив. Schema for properties.

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

$WP_Widget_Media_Image = new WP_Widget_Media_Image();
$WP_Widget_Media_Image->get_instance_schema();

Заметки

  • Смотрите: WP_REST_Controller::get_item_schema()
  • Смотрите: WP_REST_Controller::get_additional_fields()

Список изменений

С версии 4.8.0 Введена.

Код WP_Widget_Media_Image::get_instance_schema() WP 5.5.1

wp-includes/widgets/class-wp-widget-media-image.php
<?php
public function get_instance_schema() {
	return array_merge(
		array(
			'size'              => array(
				'type'        => 'string',
				'enum'        => array_merge( get_intermediate_image_sizes(), array( 'full', 'custom' ) ),
				'default'     => 'medium',
				'description' => __( 'Size' ),
			),
			'width'             => array( // Via 'customWidth', only when size=custom; otherwise via 'width'.
				'type'        => 'integer',
				'minimum'     => 0,
				'default'     => 0,
				'description' => __( 'Width' ),
			),
			'height'            => array( // Via 'customHeight', only when size=custom; otherwise via 'height'.
				'type'        => 'integer',
				'minimum'     => 0,
				'default'     => 0,
				'description' => __( 'Height' ),
			),

			'caption'           => array(
				'type'                  => 'string',
				'default'               => '',
				'sanitize_callback'     => 'wp_kses_post',
				'description'           => __( 'Caption' ),
				'should_preview_update' => false,
			),
			'alt'               => array(
				'type'              => 'string',
				'default'           => '',
				'sanitize_callback' => 'sanitize_text_field',
				'description'       => __( 'Alternative Text' ),
			),
			'link_type'         => array(
				'type'                  => 'string',
				'enum'                  => array( 'none', 'file', 'post', 'custom' ),
				'default'               => 'custom',
				'media_prop'            => 'link',
				'description'           => __( 'Link To' ),
				'should_preview_update' => true,
			),
			'link_url'          => array(
				'type'                  => 'string',
				'default'               => '',
				'format'                => 'uri',
				'media_prop'            => 'linkUrl',
				'description'           => __( 'URL' ),
				'should_preview_update' => true,
			),
			'image_classes'     => array(
				'type'                  => 'string',
				'default'               => '',
				'sanitize_callback'     => array( $this, 'sanitize_token_list' ),
				'media_prop'            => 'extraClasses',
				'description'           => __( 'Image CSS Class' ),
				'should_preview_update' => false,
			),
			'link_classes'      => array(
				'type'                  => 'string',
				'default'               => '',
				'sanitize_callback'     => array( $this, 'sanitize_token_list' ),
				'media_prop'            => 'linkClassName',
				'should_preview_update' => false,
				'description'           => __( 'Link CSS Class' ),
			),
			'link_rel'          => array(
				'type'                  => 'string',
				'default'               => '',
				'sanitize_callback'     => array( $this, 'sanitize_token_list' ),
				'media_prop'            => 'linkRel',
				'description'           => __( 'Link Rel' ),
				'should_preview_update' => false,
			),
			'link_target_blank' => array(
				'type'                  => 'boolean',
				'default'               => false,
				'media_prop'            => 'linkTargetBlank',
				'description'           => __( 'Open link in a new tab' ),
				'should_preview_update' => false,
			),
			'image_title'       => array(
				'type'                  => 'string',
				'default'               => '',
				'sanitize_callback'     => 'sanitize_text_field',
				'media_prop'            => 'title',
				'description'           => __( 'Image Title Attribute' ),
				'should_preview_update' => false,
			),

			/*
			 * There are two additional properties exposed by the PostImage modal
			 * that don't seem to be relevant, as they may only be derived read-only
			 * values:
			 * - originalUrl
			 * - aspectRatio
			 * - height (redundant when size is not custom)
			 * - width (redundant when size is not custom)
			 */
		),
		parent::get_instance_schema()
	);
}