Make WordPress Core


Ignore:
Timestamp:
07/24/2017 10:53:20 PM (7 years ago)
Author:
westonruter
Message:

Widgets: Rename Text widget's legacy mode to non-visual mode, restore boolean filter prop, and improve compatibility for widget_text filters applied in Custom HTML widget.

Merges [41132] onto 4.8 branch.
Amends [41050].
Props westonruter, obenland, timmydcrawford for testing.
See #35243, #40951, #40907.
Fixes #41394 for 4.8.1.

Location:
branches/4.8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.8

  • branches/4.8/src/wp-includes/default-widgets.php

    r41117 r41133  
    120120        $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
    121121
     122        // Prepare instance data that looks like a normal Text widget.
     123        $simulated_text_widget_instance = array_merge( $instance, array(
     124            'text' => isset( $instance['content'] ) ? $instance['content'] : '',
     125            'filter' => false, // Because wpautop is not applied.
     126            'visual' => false, // Because it wasn't created in TinyMCE.
     127        ) );
     128        unset( $simulated_text_widget_instance['content'] ); // Was moved to 'text' prop.
     129
    122130        /** This filter is documented in wp-includes/widgets/class-wp-widget-text.php */
    123         $content = apply_filters( 'widget_text', $instance['content'], $instance, $this );
     131        $content = apply_filters( 'widget_text', $instance['content'], $simulated_text_widget_instance, $this );
    124132
    125133        /**
Note: See TracChangeset for help on using the changeset viewer.