Changeset 40631
- Timestamp:
- 05/11/2017 06:54:24 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Gruntfile.js
r40527 r40631 457 457 ext: '.min.js', 458 458 src: [ 459 'wp-admin/js/* .js',459 'wp-admin/js/**/*.js', 460 460 'wp-includes/js/*.js', 461 461 'wp-includes/js/mediaelement/wp-mediaelement.js', -
trunk/src/wp-admin/css/customize-widgets.css
r40569 r40631 212 212 #customize-theme-controls .reordering .widget-reorder-nav { 213 213 display: block; 214 } 215 216 /* Text Widget */ 217 .wp-customizer div.mce-inline-toolbar-grp, 218 .wp-customizer div.mce-tooltip { 219 z-index: 500100 !important; 220 } 221 .wp-customizer .ui-autocomplete.wplink-autocomplete { 222 z-index: 500110; /* originally 100110, but z-index of .wp-full-overlay is 500000 */ 223 } 224 .wp-customizer #wp-link-backdrop { 225 z-index: 500100; /* originally 100100, but z-index of .wp-full-overlay is 500000 */ 226 } 227 .wp-customizer #wp-link-wrap { 228 z-index: 500105; /* originally 100105, but z-index of .wp-full-overlay is 500000 */ 214 229 } 215 230 -
trunk/src/wp-includes/default-filters.php
r40608 r40631 165 165 add_filter( 'wp_sprintf', 'wp_sprintf_l', 10, 2 ); 166 166 167 add_filter( 'widget_text', 'balanceTags' ); 167 add_filter( 'widget_text', 'balanceTags' ); 168 add_filter( 'widget_text_content', 'capital_P_dangit', 11 ); 169 add_filter( 'widget_text_content', 'wptexturize' ); 170 add_filter( 'widget_text_content', 'convert_smilies', 20 ); 171 add_filter( 'widget_text_content', 'wpautop' ); 168 172 169 173 add_filter( 'date_i18n', 'wp_maybe_decline_date' ); -
trunk/src/wp-includes/script-loader.php
r40607 r40631 603 603 604 604 $scripts->add( 'admin-widgets', "/wp-admin/js/widgets$suffix.js", array( 'jquery-ui-sortable', 'jquery-ui-draggable', 'jquery-ui-droppable' ), false, 1 ); 605 $scripts->add( 'text-widgets', "/wp-admin/js/widgets/text-widgets$suffix.js", array( 'jquery', 'backbone', 'editor', 'wp-util' ) ); 606 $scripts->add_inline_script( 'text-widgets', 'wp.textWidgets.init();', 'after' ); 605 607 606 608 $scripts->add( 'theme', "/wp-admin/js/theme$suffix.js", array( 'wp-backbone', 'wp-a11y' ), false, 1 ); -
trunk/src/wp-includes/widgets/class-wp-widget-text.php
r37489 r40631 29 29 'customize_selective_refresh' => true, 30 30 ); 31 $control_ops = array( 'width' => 400, 'height' => 350 ); 31 $control_ops = array( 32 'width' => 400, 33 'height' => 350, 34 ); 32 35 parent::__construct( 'text', __( 'Text' ), $widget_ops, $control_ops ); 36 } 37 38 /** 39 * Add hooks for enqueueing assets when registering all widget instances of this widget class. 40 * 41 * @since 4.8.0 42 * @access public 43 */ 44 public function _register() { 45 46 // Note that the widgets component in the customizer will also do the 'admin_print_scripts-widgets.php' action in WP_Customize_Widgets::print_scripts(). 47 add_action( 'admin_print_scripts-widgets.php', array( $this, 'enqueue_admin_scripts' ) ); 48 49 // Note that the widgets component in the customizer will also do the 'admin_footer-widgets.php' action in WP_Customize_Widgets::print_footer_scripts(). 50 add_action( 'admin_footer-widgets.php', array( $this, 'render_control_template_scripts' ) ); 51 52 parent::_register(); 33 53 } 34 54 … … 62 82 $text = apply_filters( 'widget_text', $widget_text, $instance, $this ); 63 83 84 if ( isset( $instance['filter'] ) ) { 85 if ( 'content' === $instance['filter'] ) { 86 87 /** 88 * Filters the content of the Text widget to apply changes expected from the visual (TinyMCE) editor. 89 * 90 * By default a subset of the_content filters are applied, including wpautop and wptexturize. 91 * 92 * @since 4.8.0 93 * 94 * @param string $widget_text The widget content. 95 * @param array $instance Array of settings for the current widget. 96 * @param WP_Widget_Text $this Current Text widget instance. 97 */ 98 $text = apply_filters( 'widget_text_content', $widget_text, $instance, $this ); 99 100 } elseif ( $instance['filter'] ) { 101 $text = wpautop( $text ); // Back-compat for instances prior to 4.8. 102 } 103 } 104 64 105 echo $args['before_widget']; 65 106 if ( ! empty( $title ) ) { 66 107 echo $args['before_title'] . $title . $args['after_title']; 67 } ?> 68 <div class="textwidget"><?php echo !empty( $instance['filter'] ) ? wpautop( $text ) : $text; ?></div> 108 } 109 110 ?> 111 <div class="textwidget"><?php echo $text; ?></div> 69 112 <?php 70 113 echo $args['after_widget']; … … 90 133 $instance['text'] = wp_kses_post( $new_instance['text'] ); 91 134 } 92 $instance['filter'] = ! empty( $new_instance['filter'] ); 135 136 /* 137 * Re-use legacy 'filter' (wpautop) property to now indicate content filters will always apply. 138 * Prior to 4.8, this is a boolean value used to indicate whether or not wpautop should be 139 * applied. By re-using this property, downgrading WordPress from 4.8 to 4.7 will ensure 140 * that the content for Text widgets created with TinyMCE will continue to get wpautop. 141 */ 142 $instance['filter'] = 'content'; 143 93 144 return $instance; 94 145 } 95 146 96 147 /** 148 * Loads the required scripts and styles for the widget control. 149 * 150 * @since 4.8.0 151 * @access public 152 */ 153 public function enqueue_admin_scripts() { 154 wp_enqueue_editor(); 155 wp_enqueue_script( 'text-widgets' ); 156 } 157 158 /** 97 159 * Outputs the Text widget settings form. 98 160 * 99 161 * @since 2.8.0 100 * @access public 162 * @since 4.8.0 Form only contains hidden inputs which are synced with JS template. 163 * @access public 164 * @see WP_Widget_Visual_Text::render_control_template_scripts() 101 165 * 102 166 * @param array $instance Current settings. 167 * @return void 103 168 */ 104 169 public function form( $instance ) { 105 $instance = wp_parse_args( (array) $instance, array( 'title' => '', 'text' => '' ) ); 106 $filter = isset( $instance['filter'] ) ? $instance['filter'] : 0; 107 $title = sanitize_text_field( $instance['title'] ); 170 $instance = wp_parse_args( 171 (array) $instance, 172 array( 173 'title' => '', 174 'text' => '', 175 ) 176 ); 108 177 ?> 109 <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> 110 <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($title); ?>" /></p> 111 112 <p><label for="<?php echo $this->get_field_id( 'text' ); ?>"><?php _e( 'Content:' ); ?></label> 113 <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> 114 115 <p><input id="<?php echo $this->get_field_id('filter'); ?>" name="<?php echo $this->get_field_name('filter'); ?>" type="checkbox"<?php checked( $filter ); ?> /> <label for="<?php echo $this->get_field_id('filter'); ?>"><?php _e('Automatically add paragraphs'); ?></label></p> 178 <input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" class="title" type="hidden" value="<?php echo esc_attr( $instance['title'] ); ?>"> 179 <input id="<?php echo $this->get_field_id( 'text' ); ?>" name="<?php echo $this->get_field_name( 'text' ); ?>" class="text" type="hidden" value="<?php echo esc_attr( $instance['text'] ); ?>"> 116 180 <?php 117 181 } 182 183 /** 184 * Render form template scripts. 185 * 186 * @since 4.8.0 187 * @access public 188 */ 189 public function render_control_template_scripts() { 190 ?> 191 <script type="text/html" id="tmpl-widget-text-control-fields"> 192 <# var elementIdPrefix = 'el' + String( Math.random() ).replace( /\D/g, '' ) + '_' #> 193 <p> 194 <label for="{{ elementIdPrefix }}title"><?php esc_html_e( 'Title:' ); ?></label> 195 <input id="{{ elementIdPrefix }}title" type="text" class="widefat title"> 196 </p> 197 <p> 198 <label for="{{ elementIdPrefix }}text" class="screen-reader-text"><?php esc_html_e( 'Content:' ); ?></label> 199 <textarea id="{{ elementIdPrefix }}text" class="widefat text" style="height: 200px" rows="16" cols="20"></textarea> 200 </p> 201 </script> 202 <?php 203 } 118 204 }
Note: See TracChangeset
for help on using the changeset viewer.