Making WordPress.org


Ignore:
Timestamp:
08/24/2016 08:22:35 PM (5 years ago)
Author:
coffee2code
Message:

developer.wordpress.org: Implement a tabbed interface for writing and previewing user contributed notes.

Also wraps form header in 'h3' tag so it appears in table of contents.

Props keesiemeijer.
See #1905.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content-preview.php

    r3790 r3852  
    3636    public static function scripts_and_styles() {
    3737        if ( is_singular() ) {
    38             wp_enqueue_script( 'wporg-developer-preview', get_template_directory_uri() . '/js/user-notes-preview.js', array( 'jquery', 'quicktags', 'wporg-developer-function-reference' ), '20160809', true );
     38            wp_enqueue_script( 'wporg-developer-tabs', get_template_directory_uri() . '/js/tabs.js', array( 'jquery' ), '20160809', true );
     39            wp_enqueue_script( 'wporg-developer-preview', get_template_directory_uri() . '/js/user-notes-preview.js', array( 'jquery', 'wporg-developer-function-reference', 'wporg-developer-tabs'  ), '20160809', true );
    3940            wp_localize_script( 'wporg-developer-preview', 'wporg_note_preview', array(
    40                 'ajaxurl' => admin_url( 'admin-ajax.php' ),
    41                 'nonce'   => wp_create_nonce( 'preview_nonce' ),
    42                 'preview' => __( 'preview note', 'wporg' ),
     41                'ajaxurl'       => admin_url( 'admin-ajax.php' ),
     42                'nonce'         => wp_create_nonce( 'preview_nonce' ),
     43                'preview'       => __( 'preview note', 'wporg' ),
     44                'preview_empty' => __( 'Nothing to preview', 'wporg' ),
     45                'is_admin'      => is_admin(),
    4346            ) );
    4447        }
     
    5558        }
    5659
    57         $comment = apply_filters('pre_comment_content', $_POST['preview_comment'] );
     60        $comment = apply_filters( 'pre_comment_content', $_POST['preview_comment'] );
    5861        $comment = wp_unslash( $comment );
    5962        $comment = apply_filters( 'get_comment_text', $comment );
    60         $comment = apply_filters( 'comment_text', $comment );       
     63        $comment = apply_filters( 'comment_text', $comment );
    6164
    6265        wp_send_json_success( array( 'comment' => $comment ) );
    6366    }
     67
     68    /**
     69     * Captures the comment-preview markup displayed (and populated) below the Add Note form.
     70     *
     71     * @access public
     72     * @static
     73     *
     74     * @return string Comment preview HTML markup.
     75     */
     76    public static function comment_preview() {
     77        if ( ! class_exists( 'DevHub_Note_Preview' ) ) {
     78            return '';
     79        }
     80
     81        ob_start();
     82?>
     83        <div id='comment-preview' class='tab-section comment byuser depth-1 comment-preview' aria-hidden="true">
     84            <article class='preview-body comment-body'>
     85                <div class='preview-content comment-content'></div>
     86            </article>
     87        </div>
     88        <?php
     89
     90        return ob_get_clean();
     91    }
    6492}
    6593
    66 
    6794DevHub_Note_Preview::init();
    68 
Note: See TracChangeset for help on using the changeset viewer.