WC_Settings_API::generate_color_html()publicWC 1.0.0

Generate Color Picker Input HTML.

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

Хуков нет.

Возвращает

Строку.

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

$WC_Settings_API = new WC_Settings_API();
$WC_Settings_API->generate_color_html( $key, $data );
$key(строка) (обязательный)
Field key.
$data(массив) (обязательный)
Field data.

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

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

Код WC_Settings_API::generate_color_html() WC 9.4.2

<?php
public function generate_color_html( $key, $data ) {
	$field_key = $this->get_field_key( $key );
	$defaults  = array(
		'title'             => '',
		'disabled'          => false,
		'class'             => '',
		'css'               => '',
		'placeholder'       => '',
		'desc_tip'          => false,
		'description'       => '',
		'custom_attributes' => array(),
	);

	$data = wp_parse_args( $data, $defaults );

	ob_start();
	?>
	<tr valign="top">
		<th scope="row" class="titledesc">
			<label for="<?php echo esc_attr( $field_key ); ?>"><?php echo wp_kses_post( $data['title'] ); ?> <?php echo $this->get_tooltip_html( $data ); // WPCS: XSS ok. ?></label>
		</th>
		<td class="forminp">
			<fieldset>
				<legend class="screen-reader-text"><span><?php echo wp_kses_post( $data['title'] ); ?></span></legend>
				<span class="colorpickpreview" style="background:<?php echo esc_attr( $this->get_option( $key ) ); ?>;">&nbsp;</span>
				<input class="colorpick <?php echo esc_attr( $data['class'] ); ?>" type="text" name="<?php echo esc_attr( $field_key ); ?>" id="<?php echo esc_attr( $field_key ); ?>" style="<?php echo esc_attr( $data['css'] ); ?>" value="<?php echo esc_attr( $this->get_option( $key ) ); ?>" placeholder="<?php echo esc_attr( $data['placeholder'] ); ?>" <?php disabled( $data['disabled'], true ); ?> <?php echo $this->get_custom_attribute_html( $data ); // WPCS: XSS ok. ?> />
				<div id="colorPickerDiv_<?php echo esc_attr( $field_key ); ?>" class="colorpickdiv" style="z-index: 100; background: #eee; border: 1px solid #ccc; position: absolute; display: none;"></div>
				<?php echo $this->get_description_html( $data ); // WPCS: XSS ok. ?>
			</fieldset>
		</td>
	</tr>
	<?php

	return ob_get_clean();
}