~canonical-sysadmins/wordpress/4.9.7

« back to all changes in this revision

Viewing changes to wp-includes/widgets/class-wp-widget-text.php

  • Committer: Barry Price
  • Date: 2017-09-20 02:34:45 UTC
  • mto: This revision was merged to the branch mainline in revision 32.
  • Revision ID: barry.price@canonical.com-20170920023445-2ylln1i0tkpo301s
new upstream release 4.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
115
115
                }
116
116
 
117
117
                $doc = new DOMDocument();
118
 
                $doc->loadHTML( sprintf(
119
 
                        '<html><head><meta charset="%s"></head><body>%s</body></html>',
 
118
                @$doc->loadHTML( sprintf(
 
119
                        '<!DOCTYPE html><html><head><meta charset="%s"></head><body>%s</body></html>',
120
120
                        esc_attr( get_bloginfo( 'charset' ) ),
121
121
                        $instance['text']
122
122
                ) );
335
335
         * @since 4.8.1 Restored original form to be displayed when in legacy mode.
336
336
         * @access public
337
337
         * @see WP_Widget_Visual_Text::render_control_template_scripts()
 
338
         * @see _WP_Editors::editor()
338
339
         *
339
340
         * @param array $instance Current settings.
340
341
         * @return void
349
350
                );
350
351
                ?>
351
352
                <?php if ( ! $this->is_legacy_instance( $instance ) ) : ?>
352
 
                        <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'] ); ?>">
353
 
                        <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'] ); ?>">
354
 
                        <input id="<?php echo $this->get_field_id( 'filter' ); ?>" name="<?php echo $this->get_field_name( 'filter' ); ?>" class="filter" type="hidden" value="on">
355
 
                        <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value="on">
 
353
                        <?php
 
354
 
 
355
                        if ( user_can_richedit() ) {
 
356
                                add_filter( 'the_editor_content', 'format_for_editor', 10, 2 );
 
357
                                $default_editor = 'tinymce';
 
358
                        } else {
 
359
                                $default_editor = 'html';
 
360
                        }
 
361
 
 
362
                        /** This filter is documented in wp-includes/class-wp-editor.php */
 
363
                        $text = apply_filters( 'the_editor_content', $instance['text'], $default_editor );
 
364
 
 
365
                        // Reset filter addition.
 
366
                        if ( user_can_richedit() ) {
 
367
                                remove_filter( 'the_editor_content', 'format_for_editor' );
 
368
                        }
 
369
 
 
370
                        // Prevent premature closing of textarea in case format_for_editor() didn't apply or the_editor_content filter did a wrong thing.
 
371
                        $escaped_text = preg_replace( '#</textarea#i', '&lt;/textarea', $text );
 
372
 
 
373
                        ?>
 
374
                        <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'] ); ?>">
 
375
                        <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>
 
376
                        <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">
 
377
                        <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">
356
378
                <?php else : ?>
357
379
                        <input id="<?php echo $this->get_field_id( 'visual' ); ?>" name="<?php echo $this->get_field_name( 'visual' ); ?>" class="visual" type="hidden" value="">
358
380
                        <p>