- Timestamp:
- 11/30/2017 11:09:33 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/widgets/class-wp-widget-custom-html.php
r42185 r42343 32 32 */ 33 33 protected $default_instance = array( 34 'title' => '',34 'title' => '', 35 35 'content' => '', 36 36 ); … … 42 42 */ 43 43 public function __construct() { 44 $widget_ops = array(45 'classname' => 'widget_custom_html',46 'description' => __( 'Arbitrary HTML code.' ),44 $widget_ops = array( 45 'classname' => 'widget_custom_html', 46 'description' => __( 'Arbitrary HTML code.' ), 47 47 'customize_selective_refresh' => true, 48 48 ); 49 49 $control_ops = array( 50 'width' => 400,50 'width' => 400, 51 51 'height' => 350, 52 52 ); … … 131 131 132 132 // Prepare instance data that looks like a normal Text widget. 133 $simulated_text_widget_instance = array_merge( $instance, array( 134 'text' => isset( $instance['content'] ) ? $instance['content'] : '', 135 'filter' => false, // Because wpautop is not applied. 136 'visual' => false, // Because it wasn't created in TinyMCE. 137 ) ); 133 $simulated_text_widget_instance = array_merge( 134 $instance, array( 135 'text' => isset( $instance['content'] ) ? $instance['content'] : '', 136 'filter' => false, // Because wpautop is not applied. 137 'visual' => false, // Because it wasn't created in TinyMCE. 138 ) 139 ); 138 140 unset( $simulated_text_widget_instance['content'] ); // Was moved to 'text' prop. 139 141 … … 180 182 */ 181 183 public function update( $new_instance, $old_instance ) { 182 $instance = array_merge( $this->default_instance, $old_instance );184 $instance = array_merge( $this->default_instance, $old_instance ); 183 185 $instance['title'] = sanitize_text_field( $new_instance['title'] ); 184 186 if ( current_user_can( 'unfiltered_html' ) ) { … … 196 198 */ 197 199 public function enqueue_admin_scripts() { 198 $settings = wp_enqueue_code_editor( array( 199 'type' => 'text/html', 200 'codemirror' => array( 201 'indentUnit' => 2, 202 'tabSize' => 2, 203 ), 204 ) ); 200 $settings = wp_enqueue_code_editor( 201 array( 202 'type' => 'text/html', 203 'codemirror' => array( 204 'indentUnit' => 2, 205 'tabSize' => 2, 206 ), 207 ) 208 ); 205 209 206 210 wp_enqueue_script( 'custom-html-widgets' ); … … 217 221 'singular' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 1 ), 218 222 /* translators: %d: error count */ 219 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491.223 'plural' => _n( 'There is %d error which must be fixed before you can save.', 'There are %d errors which must be fixed before you can save.', 2 ), // @todo This is lacking, as some languages have a dedicated dual form. For proper handling of plurals in JS, see #20491. 220 224 ), 221 225 ); … … 263 267 <?php 264 268 $probably_unsafe_html = array( 'script', 'iframe', 'form', 'input', 'style' ); 265 $allowed_html = wp_kses_allowed_html( 'post' );266 $disallowed_html = array_diff( $probably_unsafe_html, array_keys( $allowed_html ) );269 $allowed_html = wp_kses_allowed_html( 'post' ); 270 $disallowed_html = array_diff( $probably_unsafe_html, array_keys( $allowed_html ) ); 267 271 ?> 268 272 <?php if ( ! empty( $disallowed_html ) ) : ?> … … 289 293 $screen = get_current_screen(); 290 294 291 $content = '<p>';295 $content = '<p>'; 292 296 $content .= __( 'Use the Custom HTML widget to add arbitrary HTML code to your widget areas.' ); 293 297 $content .= '</p>'; … … 300 304 esc_url( get_edit_profile_url() ), 301 305 'class="external-link" target="_blank"', 302 sprintf( '<span class="screen-reader-text"> %s</span>', 306 sprintf( 307 '<span class="screen-reader-text"> %s</span>', 303 308 /* translators: accessibility text */ 304 309 __( '(opens in a new window)' ) … … 315 320 } 316 321 317 $screen->add_help_tab( array( 318 'id' => 'custom_html_widget', 319 'title' => __( 'Custom HTML Widget' ), 320 'content' => $content, 321 ) ); 322 $screen->add_help_tab( 323 array( 324 'id' => 'custom_html_widget', 325 'title' => __( 'Custom HTML Widget' ), 326 'content' => $content, 327 ) 328 ); 322 329 } 323 330 }
Note: See TracChangeset
for help on using the changeset viewer.