Yoast_Form::media_input()publicYoast 2.0

Media input.

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

Хуков нет.

Возвращает

null. Ничего (null).

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

$Yoast_Form = new Yoast_Form();
$Yoast_Form->media_input( $variable, $label, $attr );
$variable(строка) (обязательный)
Option name.
$label(строка) (обязательный)
Label message.
$attr(массив)
Extra attributes to add to the media input and buttons.
По умолчанию: []

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

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

Код Yoast_Form::media_input() Yoast 22.4

public function media_input( $variable, $label, $attr = [] ) {
	$val      = $this->get_field_value( $variable, '' );
	$id_value = $this->get_field_value( $variable . '_id', '' );

	$var_esc = esc_attr( $variable );

	$defaults = [
		'disabled' => false,
	];
	$attr     = wp_parse_args( $attr, $defaults );

	$this->label(
		$label,
		[
			'for'   => 'wpseo_' . $variable,
			'class' => 'select',
		]
	);

	$id_field_id = 'wpseo_' . $var_esc . '_id';

	$disabled_attribute = $this->get_disabled_attribute( $variable, $attr );

	echo '<span>';
		echo '<input',
			' class="textinput"',
			' id="wpseo_', $var_esc, '"', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- output escaped before.
			' type="text" size="36"',
			' name="', esc_attr( $this->option_name ), '[', $var_esc, ']"', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- output escaped before.
			' value="', esc_attr( $val ), '"',
			' readonly="readonly"',
			' /> ';
		echo '<input',
			' id="wpseo_', $var_esc, '_button"', // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- output escaped before.
			' class="wpseo_image_upload_button button"',
			' type="button"',
			' value="', esc_attr__( 'Upload Image', 'wordpress-seo' ), '"',
			' data-target-id="', esc_attr( $id_field_id ), '"',
			// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: $disabled_attribute output is hardcoded.
			$disabled_attribute,
			' /> ';
		echo '<input',
			' class="wpseo_image_remove_button button"',
			' type="button"',
			' value="', esc_attr__( 'Clear Image', 'wordpress-seo' ), '"',
			// phpcs:ignore WordPress.Security.EscapeOutput -- Reason: $disabled_attribute output is hardcoded.
			$disabled_attribute,
			' />';
		echo '<input',
			' type="hidden"',
			' id="', esc_attr( $id_field_id ), '"',
			// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- output escaped before.
			' name="', esc_attr( $this->option_name ), '[', $var_esc, '_id]"',
			' value="', esc_attr( $id_value ), '"',
			' />';
	echo '</span>';
	echo '<br class="clear"/>';
}