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

WP_Widget_Text::form() WP 2.8.0

Outputs the Text widget settings form.

Это метод класса: WP_Widget_Text

Хуки из метода
Возвращает

null.

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

$WP_Widget_Text = new WP_Widget_Text();
$var = $WP_Widget_Text->form( $instance );
$instance(массив) (обязательный)
Current settings.

Заметки

  • Смотрите: WP_Widget_Text::render_control_template_scripts()
  • Смотрите: _WP_Editors::editor()

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

С версии 2.8.0 Введена.
С версии 4.8.0 Form only contains hidden inputs which are synced with JS template.
С версии 4.8.1 Restored original form to be displayed when in legacy mode.

Код WP Widget Text::form: wp-includes/widgets/class-wp-widget-text.php WP 5.2.3

<?php
public function form( $instance ) {
	$instance = wp_parse_args(
		(array) $instance,
		array(
			'title' => '',
			'text'  => '',
		)
	);
	?>
	<?php if ( ! $this->is_legacy_instance( $instance ) ) : ?>
		<?php

		if ( user_can_richedit() ) {
			add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
			$default_editor = 'tinymce';
		} else {
			$default_editor = 'html';
		}

		/** This filter is documented in wp-includes/class-wp-editor.php */
		$text = apply_filters( 'the_editor_content', $instance['text'], $default_editor );

		// Reset filter addition.
		if ( user_can_richedit() ) {
			remove_filter( 'the_editor_content', 'format_for_editor' );
		}

		// Prevent premature closing of textarea in case format_for_editor() didn't apply or the_editor_content filter did a wrong thing.
		$escaped_text = preg_replace( '#</textarea#i', '&lt;/textarea', $text );

		?>
		<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" class="title sync-input" type="hidden" value="<?php echo esc_attr( $instance['title'] ); ?>">
		<textarea id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="text sync-input" hidden><?php echo $escaped_text; ?></textarea>
		<input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" class="filter sync-input" type="hidden" value="on">
		<input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual sync-input" type="hidden" value="on">
	<?php else : ?>
		<input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value="">
		<p>
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:' ); ?></label>
			<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $instance['title'] ); ?>"/>
		</p>
		<div class="notice inline notice-info notice-alt">
			<?php if ( ! isset( $instance['visual'] ) ) : ?>
				<p><?php _e( 'This widget may contain code that may work better in the &#8220;Custom HTML&#8221; widget. How about trying that widget instead?' ); ?></p>
			<?php else : ?>
				<p><?php _e( 'This widget may have contained code that may work better in the &#8220;Custom HTML&#8221; widget. If you haven&#8217;t yet, how about trying that widget instead?' ); ?></p>
			<?php endif; ?>
		</div>
		<p>
			<label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label>
			<textarea class="widefat" rows="16" cols="20" id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>"><?php echo esc_textarea( $instance['text'] ); ?></textarea>
		</p>
		<p>
			<input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" type="checkbox"<?php checked( ! empty( $instance['filter'] ) ); ?> />&nbsp;<label for="<?php echo $this->get_field_id( 'filter' ); ?>"><?php _e( 'Automatically add paragraphs' ); ?></label>
		</p>
		<?php
	endif;
}