wp/wp-includes/widgets/class-wp-widget-text.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 18 be944660c56a
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    59 
    59 
    60 		if ( $this->is_preview() ) {
    60 		if ( $this->is_preview() ) {
    61 			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
    61 			add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_preview_scripts' ) );
    62 		}
    62 		}
    63 
    63 
    64 		// Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts().
    64 		// Note that the widgets component in the customizer will also do
       
    65 		// the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts().
    65 		add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );
    66 		add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) );
    66 
    67 
    67 		// Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts().
    68 		// Note that the widgets component in the customizer will also do
       
    69 		// the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts().
    68 		add_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) );
    70 		add_action( 'admin_footer-widgets.php', array( 'WP_Widget_Text', 'render_control_template_scripts' ) );
    69 	}
    71 	}
    70 
    72 
    71 	/**
    73 	/**
    72 	 * Determines whether a given instance is legacy and should bypass using TinyMCE.
    74 	 * Determines whether a given instance is legacy and should bypass using TinyMCE.
   119 			// @codeCoverageIgnoreEnd
   121 			// @codeCoverageIgnoreEnd
   120 		}
   122 		}
   121 
   123 
   122 		$doc = new DOMDocument();
   124 		$doc = new DOMDocument();
   123 
   125 
   124 		// Suppress warnings generated by loadHTML
   126 		// Suppress warnings generated by loadHTML.
   125 		$errors = libxml_use_internal_errors( true );
   127 		$errors = libxml_use_internal_errors( true );
       
   128 		// phpcs:ignore WordPress.PHP.NoSilencedErrors.Discouraged
   126 		@$doc->loadHTML(
   129 		@$doc->loadHTML(
   127 			sprintf(
   130 			sprintf(
   128 				'<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
   131 				'<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
   129 				esc_attr( get_bloginfo( 'charset' ) ),
   132 				esc_attr( get_bloginfo( 'charset' ) ),
   130 				$instance['text']
   133 				$instance['text']
   210 	/**
   213 	/**
   211 	 * Outputs the content for the current Text widget instance.
   214 	 * Outputs the content for the current Text widget instance.
   212 	 *
   215 	 *
   213 	 * @since 2.8.0
   216 	 * @since 2.8.0
   214 	 *
   217 	 *
   215 	 * @global WP_Post $post
   218 	 * @global WP_Post $post Global post object.
   216 	 *
   219 	 *
   217 	 * @param array $args     Display arguments including 'before_title', 'after_title',
   220 	 * @param array $args     Display arguments including 'before_title', 'after_title',
   218 	 *                        'before_widget', and 'after_widget'.
   221 	 *                        'before_widget', and 'after_widget'.
   219 	 * @param array $instance Settings for the current Text widget instance.
   222 	 * @param array $instance Settings for the current Text widget instance.
   220 	 */
   223 	 */
   341 	 * Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
   344 	 * Inject max-width and remove height for videos too constrained to fit inside sidebars on frontend.
   342 	 *
   345 	 *
   343 	 * @since 4.9.0
   346 	 * @since 4.9.0
   344 	 *
   347 	 *
   345 	 * @see WP_Widget_Media_Video::inject_video_max_width_style()
   348 	 * @see WP_Widget_Media_Video::inject_video_max_width_style()
       
   349 	 *
   346 	 * @param array $matches Pattern matches from preg_replace_callback.
   350 	 * @param array $matches Pattern matches from preg_replace_callback.
   347 	 * @return string HTML Output.
   351 	 * @return string HTML Output.
   348 	 */
   352 	 */
   349 	public function inject_video_max_width_style( $matches ) {
   353 	public function inject_video_max_width_style( $matches ) {
   350 		$html = $matches[0];
   354 		$html = $matches[0];
   369 			$new_instance,
   373 			$new_instance,
   370 			array(
   374 			array(
   371 				'title'  => '',
   375 				'title'  => '',
   372 				'text'   => '',
   376 				'text'   => '',
   373 				'filter' => false, // For back-compat.
   377 				'filter' => false, // For back-compat.
   374 				'visual' => null, // Must be explicitly defined.
   378 				'visual' => null,  // Must be explicitly defined.
   375 			)
   379 			)
   376 		);
   380 		);
   377 
   381 
   378 		$instance = $old_instance;
   382 		$instance = $old_instance;
   379 
   383 
   414 	 * dynamically added via selective refresh, so it is important to unconditionally enqueue them.
   418 	 * dynamically added via selective refresh, so it is important to unconditionally enqueue them.
   415 	 *
   419 	 *
   416 	 * @since 4.9.3
   420 	 * @since 4.9.3
   417 	 */
   421 	 */
   418 	public function enqueue_preview_scripts() {
   422 	public function enqueue_preview_scripts() {
   419 		require_once dirname( dirname( __FILE__ ) ) . '/media.php';
   423 		require_once dirname( __DIR__ ) . '/media.php';
   420 
   424 
   421 		wp_playlist_scripts( 'audio' );
   425 		wp_playlist_scripts( 'audio' );
   422 		wp_playlist_scripts( 'video' );
   426 		wp_playlist_scripts( 'video' );
   423 	}
   427 	}
   424 
   428 
   438 	 * Outputs the Text widget settings form.
   442 	 * Outputs the Text widget settings form.
   439 	 *
   443 	 *
   440 	 * @since 2.8.0
   444 	 * @since 2.8.0
   441 	 * @since 4.8.0 Form only contains hidden inputs which are synced with JS template.
   445 	 * @since 4.8.0 Form only contains hidden inputs which are synced with JS template.
   442 	 * @since 4.8.1 Restored original form to be displayed when in legacy mode.
   446 	 * @since 4.8.1 Restored original form to be displayed when in legacy mode.
       
   447 	 *
   443 	 * @see WP_Widget_Text::render_control_template_scripts()
   448 	 * @see WP_Widget_Text::render_control_template_scripts()
   444 	 * @see _WP_Editors::editor()
   449 	 * @see _WP_Editors::editor()
   445 	 *
   450 	 *
   446 	 * @param array $instance Current settings.
   451 	 * @param array $instance Current settings.
   447 	 * @return void
       
   448 	 */
   452 	 */
   449 	public function form( $instance ) {
   453 	public function form( $instance ) {
   450 		$instance = wp_parse_args(
   454 		$instance = wp_parse_args(
   451 			(array) $instance,
   455 			(array) $instance,
   452 			array(
   456 			array(