Making WordPress.org


Ignore:
Timestamp:
11/17/2014 11:23:36 PM (11 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.