Make WordPress Core

Ticket #32469: wp-view.patch

File wp-view.patch, 3.1 KB (added by jacobsantos, 10 years ago)

Add wp_view() function and wp-includes/views directory.

  • wp-includes/load.php

     
    826826
    827827        $wp_locale = new WP_Locale();
    828828}
     829
     830/**
     831 * Retrieve the contents of a file from the views directory in wp-includes.
     832 *
     833 * This will process the PHP file before returning the file contents. So any PHP
     834 * in the file will be executed.
     835 *
     836 * @internal This might include current or parent theme file for further
     837 * customization of the view. At the moment, it simply works with
     838 * wp-includes/views files.
     839 *
     840 * @since Unknown
     841 *
     842 * @param string $__name
     843 *   File name without '.php' at the end.
     844 *   Views may include a period when they are under additional directories.
     845 *   Files should use underscores (_) or dashes (-) and must not use periods.
     846 * @param array $__data
     847 *   This is the view variables. It will be extracted so the key names must be
     848 *   valid PHP varible names. Also, by default, no globals are available, so
     849 *   any variables must be passed in this array as well.
     850 */
     851function wp_view($__name, array $__data) {
     852        $__file = str_replace('.', '/', $__name)
     853        $__path = ABSPATH . WPINC . '/views/' . $__file . '.php';
     854
     855        if ( file_exists( $__path ) ) {
     856                implode($data);
     857                unset($__name, $__data, $__file, $__path);
     858                ob_start();
     859                include $path;
     860                $contents = ob_get_contents();
     861                ob_flush();
     862                return $contents;
     863        }
     864
     865        return false;
     866}
  • 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>