Skip to:
Content

bbPress.org

Changeset 5399


Ignore:
Timestamp:
06/14/2014 10:14:34 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Normalize metabox UI across Forums, Topics, & Replies. Hat-tip netweb. Fixes #2463.

Location:
trunk/src/includes
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/includes/admin/admin.php

    r5325 r5399  
    568568                    // Topics admin
    569569                    if ( bbp_get_topic_post_type() === get_current_screen()->post_type ) {
    570                         wp_enqueue_script( 'bbp-admin-common-js', $this->js_url . 'topics' . $suffix . '.js', array( 'jquery' ), $version );
     570                        wp_enqueue_script( 'bbp-admin-topics-js', $this->js_url . 'topics' . $suffix . '.js', array( 'jquery' ), $version );
    571571
    572572                    // Replies admin
    573573                    } elseif ( bbp_get_reply_post_type() === get_current_screen()->post_type ) {
    574                         wp_enqueue_script( 'bbp-admin-common-js', $this->js_url . 'replies' . $suffix . '.js', array( 'jquery' ), $version );
     574                        wp_enqueue_script( 'bbp-admin-replies-js', $this->js_url . 'replies' . $suffix . '.js', array( 'jquery' ), $version );
    575575                    }
    576576
  • trunk/src/includes/admin/js/replies.js

    r5225 r5399  
    11jQuery( document ).ready(function() {
     2
     3    jQuery( '#misc-publishing-actions' ).find( '.misc-pub-section' ).first().remove();
     4    jQuery( '#save-action' ).remove();
    25
    36    var bbp_topic_id = jQuery( '#bbp_topic_id' );
  • trunk/src/includes/admin/metaboxes.php

    r5398 r5399  
    422422    ?>
    423423
     424    <hr />
     425
    424426    <p>
    425427        <strong class="label"><?php esc_html_e( 'Forum:', 'bbpress' ); ?></strong>
     
    471473    $reply_topic_id = bbp_get_reply_topic_id( $post_id );
    472474    $reply_forum_id = bbp_get_reply_forum_id( $post_id );
     475
     476
     477    /** Status ****************************************************************/
     478
     479    ?>
     480
     481    <p>
     482        <strong class="label"><?php esc_html_e( 'Status:', 'bbpress' ); ?></strong>
     483        <label class="screen-reader-text" for="post_status"><?php esc_html_e( 'Select what status to give the reply.', 'bbpress' ); ?></label>
     484        <?php bbp_form_reply_status_dropdown( array( 'select_id' => 'post_status', 'reply_id' => $post_id ) ); ?>
     485    </p>
     486
     487    <hr />
     488
     489    <?php
     490
     491    /** Forum *****************************************************************/
    473492
    474493    // Allow individual manipulation of reply forum
     
    497516        </p>
    498517
    499     <?php endif; ?>
     518    <?php endif;
     519
     520    /** Topic *****************************************************************/
     521
     522    ?>
    500523
    501524    <p>
     
    504527        <input name="parent_id" id="bbp_topic_id" type="text" value="<?php echo esc_attr( $reply_topic_id ); ?>" />
    505528    </p>
     529
     530    <?php
     531
     532    /** Reply To **************************************************************/
     533
     534    ?>
    506535
    507536    <p>
  • trunk/src/includes/replies/functions.php

    r5393 r5399  
    16651665}
    16661666
     1667/** Helpers *******************************************************************/
     1668
     1669/**
     1670 * Return an associative array of available reply statuses
     1671 *
     1672 * @since bbPress (r5399)
     1673 *
     1674 * @return array
     1675 */
     1676function bbp_get_reply_statuses() {
     1677    return apply_filters( 'bbp_get_reply_statuses', array(
     1678        bbp_get_public_status_id()  => _x( 'Publish', 'Publish the reply',     'bbpress' ),
     1679        bbp_get_spam_status_id()    => _x( 'Spam',    'Spam the reply',        'bbpress' ),
     1680        bbp_get_trash_status_id()   => _x( 'Trash',   'Trash the reply',       'bbpress' ),
     1681        bbp_get_pending_status_id() => _x( 'Pending', 'Mark reply as pending', 'bbpress' ),
     1682    ) );
     1683}
     1684
    16671685/** Reply Actions *************************************************************/
    16681686
  • trunk/src/includes/replies/template.php

    r5395 r5399  
    26232623        return apply_filters( 'bbp_get_form_reply_edit_reason', esc_attr( $reply_edit_reason ) );
    26242624    }
     2625
     2626/**
     2627 * Output value topic status dropdown
     2628 *
     2629 * @since bbPress (r5399)
     2630 *
     2631 * @param $args This function supports these arguments:
     2632 *  - select_id: Select id. Defaults to bbp_reply_status
     2633 *  - tab: Tabindex
     2634 *  - reply_id: Reply id
     2635 *  - selected: Override the selected option
     2636 */
     2637function bbp_form_reply_status_dropdown( $args = '' ) {
     2638    echo bbp_get_form_reply_status_dropdown( $args );
     2639}
     2640    /**
     2641     * Returns topic status downdown
     2642     *
     2643     * This dropdown is only intended to be seen by users with the 'moderate'
     2644     * capability. Because of this, no additional capablitiy checks are performed
     2645     * within this function to check available topic statuses.
     2646     *
     2647     * @since bbPress (r5399)
     2648     *
     2649     * @param $args This function supports these arguments:
     2650     *  - select_id: Select id. Defaults to bbp_reply_status
     2651     *  - tab: Tabindex
     2652     *  - topic_id: Reply id
     2653     *  - selected: Override the selected option
     2654     */
     2655    function bbp_get_form_reply_status_dropdown( $args = '' ) {
     2656
     2657        // Parse arguments against default values
     2658        $r = bbp_parse_args( $args, array(
     2659            'select_id' => 'bbp_reply_status',
     2660            'tab'       => bbp_get_tab_index(),
     2661            'reply_id'  => 0,
     2662            'selected'  => false
     2663        ), 'reply_status_dropdown' );
     2664
     2665        // No specific selected value passed
     2666        if ( empty( $r['selected'] ) ) {
     2667
     2668            // Post value is passed
     2669            if ( bbp_is_post_request() && isset( $_POST[ $r['select_id'] ] ) ) {
     2670                $r['selected'] = $_POST[ $r['select_id'] ];
     2671
     2672            // No Post value was passed
     2673            } else {
     2674
     2675                // Edit topic
     2676                if ( bbp_is_reply_edit() ) {
     2677                    $r['reply_id'] = bbp_get_reply_id( $r['reply_id'] );
     2678                    $r['selected'] = bbp_get_reply_status( $r['reply_id'] );
     2679
     2680                // New topic
     2681                } else {
     2682                    $r['selected'] = bbp_get_public_status_id();
     2683                }
     2684            }
     2685        }
     2686
     2687        // Used variables
     2688        $tab = ! empty( $r['tab'] ) ? ' tabindex="' . (int) $r['tab'] . '"' : '';
     2689
     2690        // Start an output buffer, we'll finish it after the select loop
     2691        ob_start(); ?>
     2692
     2693        <select name="<?php echo esc_attr( $r['select_id'] ) ?>" id="<?php echo esc_attr( $r['select_id'] ); ?>_select"<?php echo $tab; ?>>
     2694
     2695            <?php foreach ( bbp_get_reply_statuses( $r['topic_id'] ) as $key => $label ) : ?>
     2696
     2697                <option value="<?php echo esc_attr( $key ); ?>"<?php selected( $key, $r['selected'] ); ?>><?php echo esc_html( $label ); ?></option>
     2698
     2699            <?php endforeach; ?>
     2700
     2701        </select>
     2702
     2703        <?php
     2704
     2705        // Return the results
     2706        return apply_filters( 'bbp_get_form_reply_status_dropdown', ob_get_clean(), $r );
     2707    }
Note: See TracChangeset for help on using the changeset viewer.