Make WordPress Core

Ticket #32469: wp-editor-editor.patch

File wp-editor-editor.patch, 7.5 KB (added by jacobsantos, 10 years ago)

Changes WP_Editor::editor() method to use a view instead of displaying directly.

  • wp-includes/class-wp-editor.php

     
    184184                        $wrap_class .= ' has-dfw';
    185185                }
    186186
    187                 echo '<div id="wp-' . $editor_id . '-wrap" class="' . $wrap_class . '">';
    188 
    189                 if ( self::$editor_buttons_css ) {
    190                         wp_print_styles('editor-buttons');
    191                         self::$editor_buttons_css = false;
    192                 }
    193 
    194                 if ( !empty($set['editor_css']) )
    195                         echo $set['editor_css'] . "\n";
    196 
    197187                if ( !empty($buttons) || $set['media_buttons'] ) {
    198                         echo '<div id="wp-' . $editor_id . '-editor-tools" class="wp-editor-tools hide-if-no-js">';
    199 
    200188                        if ( $set['media_buttons'] ) {
    201189                                self::$has_medialib = true;
    202190
    203191                                if ( !function_exists('media_buttons') )
    204192                                        include(ABSPATH . 'wp-admin/includes/media.php');
    205 
    206                                 echo '<div id="wp-' . $editor_id . '-media-buttons" class="wp-media-buttons">';
    207 
    208                                 /**
    209                                  * Fires after the default media button(s) are displayed.
    210                                  *
    211                                  * @since 2.5.0
    212                                  *
    213                                  * @param string $editor_id Unique editor identifier, e.g. 'content'.
    214                                  */
    215                                 do_action( 'media_buttons', $editor_id );
    216                                 echo "</div>\n";
    217193                        }
    218 
    219                         echo '<div class="wp-editor-tabs">' . $buttons . "</div>\n";
    220                         echo "</div>\n";
    221194                }
    222195
    223196                /**
     
    227200                 *
    228201                 * @param string $output Editor's HTML markup.
    229202                 */
    230                 $the_editor = apply_filters( 'the_editor', '<div id="wp-' . $editor_id . '-editor-container" class="wp-editor-container">' .
    231                         '<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . $set['textarea_name'] . '" ' .
    232                         'id="' . $editor_id . '">%s</textarea></div>' );
     203                $the_editor = apply_filters(
     204                        'the_editor',
     205                        wp_view(
     206                                'wp-editor.editor-textarea',
     207                                compact( 'editor_id', 'editor_class', 'height', 'tabindex', 'autocomplete', 'set' )
     208                        )
     209                );
    233210
    234211                /**
    235212                 * Filter the default editor content.
     
    240217                 */
    241218                $content = apply_filters( 'the_editor_content', $content );
    242219
    243                 printf( $the_editor, $content );
    244                 echo "\n</div>\n\n";
     220                echo wp_view('wp-editor.editor', array_merge(
     221                        compact(
     222                                'editor_id',
     223                                'wrap_class',
     224                                'buttons',
     225                                'set'
     226                        ),
     227                        array(
     228                                'editor_buttons_css' => self::$editor_buttons_css,
     229                                'content' => sprintf( $the_editor, $content )
     230                        )
     231                ));
    245232
     233                if ( self::$editor_buttons_css ) {
     234                        self::$editor_buttons_css = false;
     235                }
     236
    246237                self::editor_settings($editor_id, $set);
    247238        }
    248239
  • wp-includes/views/wp-editor/editor-textarea.php

     
     1<div id="wp-<?php echo $editor_id; ?>-editor-container" class="wp-editor-container">
     2        <textarea<?php echo $editor_class . $height . $tabindex . $autocomplete; ?> cols="40"
     3                name="<?php echo $set['textarea_name']; ?>" id="<?php echo $editor_id; ?>">%s</textarea>
     4</div>
  • wp-includes/views/wp-editor/editor.php

     
     1<div id="wp-<?php echo $editor_id; ?>-wrap" class="<?php echo $wrap_class; ?>">
     2
     3<?php
     4if ( $editor_buttons_css ) {
     5        wp_print_styles('editor-buttons');
     6}
     7
     8if ( !empty($set['editor_css']) ) {
     9        echo $set['editor_css'] . "\n";
     10}
     11
     12if ( !empty($buttons) || $set['media_buttons'] ) {
     13?>
     14
     15        <div id="wp-<?php echo $editor_id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">';
     16<?php
     17        if ( $set['media_buttons'] ) {
     18?>
     19
     20                <div id="wp-<?php echo $editor_id; ?>-media-buttons" class="wp-media-buttons">';
     21<?php
     22                /**
     23                * Fires after the default media button(s) are displayed.
     24                *
     25                * @since 2.5.0
     26                *
     27                * @param string $editor_id Unique editor identifier, e.g. 'content'.
     28                */
     29                do_action( 'media_buttons', $editor_id );
     30?>
     31
     32                </div>
     33<?php
     34        }
     35?>
     36
     37                <div class="wp-editor-tabs"><?php echo $buttons; ?></div>
     38        </div>
     39<?php
     40}
     41?>
     42
     43<?php
     44        echo $content;
     45?>
     46
     47</div>
  • wp-includes/views/wp-editor/editor-textarea.php

     
     1<div id="wp-<?php echo $editor_id; ?>-editor-container" class="wp-editor-container">
     2        <textarea<?php echo $editor_class . $height . $tabindex . $autocomplete; ?> cols="40"
     3                name="<?php echo $set['textarea_name']; ?>" id="<?php echo $editor_id; ?>">%s</textarea>
     4</div>
  • wp-includes/views/wp-editor/editor.php

     
     1<div id="wp-<?php echo $editor_id; ?>-wrap" class="<?php echo $wrap_class; ?>">
     2
     3<?php
     4if ( $editor_buttons_css ) {
     5        wp_print_styles('editor-buttons');
     6}
     7
     8if ( !empty($set['editor_css']) ) {
     9        echo $set['editor_css'] . "\n";
     10}
     11
     12if ( !empty($buttons) || $set['media_buttons'] ) {
     13?>
     14
     15        <div id="wp-<?php echo $editor_id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">';
     16<?php
     17        if ( $set['media_buttons'] ) {
     18?>
     19
     20                <div id="wp-<?php echo $editor_id; ?>-media-buttons" class="wp-media-buttons">';
     21<?php
     22                /**
     23                * Fires after the default media button(s) are displayed.
     24                *
     25                * @since 2.5.0
     26                *
     27                * @param string $editor_id Unique editor identifier, e.g. 'content'.
     28                */
     29                do_action( 'media_buttons', $editor_id );
     30?>
     31
     32                </div>
     33<?php
     34        }
     35?>
     36
     37                <div class="wp-editor-tabs"><?php echo $buttons; ?></div>
     38        </div>
     39<?php
     40}
     41?>
     42
     43<?php
     44        echo $content;
     45?>
     46
     47</div>
  • wp-includes/views/wp-editor/editor-textarea.php

     
     1<div id="wp-<?php echo $editor_id; ?>-editor-container" class="wp-editor-container">
     2        <textarea<?php echo $editor_class . $height . $tabindex . $autocomplete; ?> cols="40"
     3                name="<?php echo $set['textarea_name']; ?>" id="<?php echo $editor_id; ?>">%s</textarea>
     4</div>
  • wp-includes/views/wp-editor/editor.php

     
     1<div id="wp-<?php echo $editor_id; ?>-wrap" class="<?php echo $wrap_class; ?>">
     2
     3<?php
     4if ( $editor_buttons_css ) {
     5        wp_print_styles('editor-buttons');
     6}
     7
     8if ( !empty($set['editor_css']) ) {
     9        echo $set['editor_css'] . "\n";
     10}
     11
     12if ( !empty($buttons) || $set['media_buttons'] ) {
     13?>
     14
     15        <div id="wp-<?php echo $editor_id; ?>-editor-tools" class="wp-editor-tools hide-if-no-js">';
     16<?php
     17        if ( $set['media_buttons'] ) {
     18?>
     19
     20                <div id="wp-<?php echo $editor_id; ?>-media-buttons" class="wp-media-buttons">';
     21<?php
     22                /**
     23                * Fires after the default media button(s) are displayed.
     24                *
     25                * @since 2.5.0
     26                *
     27                * @param string $editor_id Unique editor identifier, e.g. 'content'.
     28                */
     29                do_action( 'media_buttons', $editor_id );
     30?>
     31
     32                </div>
     33<?php
     34        }
     35?>
     36
     37                <div class="wp-editor-tabs"><?php echo $buttons; ?></div>
     38        </div>
     39<?php
     40}
     41?>
     42
     43<?php
     44        echo $content;
     45?>
     46
     47</div>