Making WordPress.org

Changeset 988


Ignore:
Timestamp:
11/17/2014 11:23:36 PM (10 years ago)
Author:
coffee2code
Message:

Use wp_editor() instead of a textarea for user contributed notes comment form.

Includes php, js, inline code QuickTag buttons.

fixes #692.
props DrewAPicture.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer
Files:
3 edited

Legend:

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

    r868 r988  
    5959
    6060    <?php comment_form( array(
    61         'comment_field'       => '<p class="comment-form-comment"><label for="comment">' . _x( 'Add Note', 'noun', 'wporg' ) . '</label> <textarea id="comment" name="comment" cols="45" rows="8" aria-required="true"></textarea></p>',
     61        'comment_field'       => DevHub_User_Submitted_Content::wp_editor_comments(),
    6262        'comment_notes_after' => '<p>' .
    6363            __( 'Notes should supplement code reference entries, for example examples, tips, explanations, use-cases, and best practices.', 'wporg' ) .
     
    6565            __( 'Do not use this form for support requests, discussions, spam, bug reports, complaints, or self-promotion. Entries of this nature will be deleted.', 'wporg' ) .
    6666            '</p><p>' .
    67             sprintf( __( 'You can enter text and code. Code should be wrapped in the %s shortcode.', 'wporg' ), '[code][/code]' ) .
     67            __( 'You can enter text and code. Use the php, js, or inline code buttons to wrap code snippets.', 'wporg' ) .
    6868            '</p><p class="user-notes-are-gpl">' .
    6969            sprintf( __( '<strong>NOTE:</strong> All contributions are licensed under <a href="%s">GFDL</a> and are moderated before appearing on the site.', 'wporg' ), 'https://gnu.org/licenses/fdl.html' ) .
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/inc/user-content.php

    r868 r988  
    6767            wp_enqueue_style( 'syntaxhighlighter-theme-default' );
    6868
    69             wp_enqueue_script( 'wporg-developer-user-notes', get_template_directory_uri() . '/js/user-notes.js', array(), '20140912', true );
     69            wp_enqueue_script( 'wporg-developer-user-notes', get_template_directory_uri() . '/js/user-notes.js', array( 'quicktags' ), '20140912', true );
    7070            if ( get_option( 'thread_comments' ) ) {
    7171                wp_enqueue_script( 'comment-reply' );
     
    109109    }
    110110
     111    /**
     112     * Capture an {@see wp_editor()} instance as the 'User Contributed Notes' comment form.
     113     *
     114     * Uses output buffering to capture the editor instance for use with the {@see comments_form()}.
     115     *
     116     * @return string HTML output for the wp_editor-ized comment form.
     117     */
     118    public static function wp_editor_comments() {
     119        ob_start();
     120        echo '<p class="comment-form-comment"><label for="comment">' . _x( 'Add Note', 'noun', 'wporg' ) . '</label>';
     121        wp_editor( '', 'comment', array(
     122            'media_buttons' => false,
     123            'textarea_name' => 'comment',
     124            'textarea_rows' => 8,
     125            'quicktags'     => array(
     126                'buttons' => 'strong,em,ul,ol,li,wporg_php,js'
     127            ),
     128            'teeny'         => true,
     129            'tinymce'       => false,
     130        ) );
     131        echo '</p>';
     132        return ob_get_clean();
     133    }
     134
     135    public static function mce_buttons( $buttons ) {
     136        $buttons = array_merge( $buttons, array( 'wporg_php' ) );
     137        return $buttons;
     138    }
     139
     140    public static function mce_plugins( $plugins ) {
     141        $plugins['wporg_php'] = get_stylesheet_directory_uri() . '/js/user-notes.js';
     142        return $plugins;
     143    }
    111144} // DevHub_User_Submitted_Content
    112145
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-developer/js/user-notes.js

    r868 r988  
    2121        }
    2222    } );
     23
     24    // Add php and js buttons to QuickTags.
     25    QTags.addButton( 'php', 'php', '[php]', '[/php]' );
     26    QTags.addButton( 'js', 'js', '[js]', '[/js]' );
     27    QTags.addButton( 'inline-code', 'inline code', '<code>', '</code>' );
     28
    2329} )( jQuery );
Note: See TracChangeset for help on using the changeset viewer.