Skip to:
Content

bbPress.org


Ignore:
Timestamp:
03/29/2018 06:03:12 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Admin: improve topic/reply row-action UX.

This change includes more improvements to how topics and replies are toggled from an admin area list-table:

  • Move "Empty Spam" buttons to their own actions div
  • Allow spam/trash/approve/unapprove from any other status, so topics/replies can be more freely moved around
  • Add public/non-public functions for replies to match topics

See #1799.

File:
1 edited

Legend:

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

    r6790 r6791  
    8080        add_filter( 'restrict_manage_posts', array( $this, 'filter_dropdown'  ) );
    8181        add_filter( 'bbp_request',           array( $this, 'filter_post_rows' ) );
     82
     83        // Empty spam
     84        add_filter( 'manage_posts_extra_tablenav', array( $this, 'filter_empty_spam' ) );
    8285
    8386        // Contextual Help
     
    471474                check_admin_referer( 'approve-reply_' . $reply_id );
    472475
    473                 $is_approve = bbp_is_reply_published( $reply_id );
     476                $is_approve = bbp_is_reply_public( $reply_id );
    474477                $message    = ( true === $is_approve )
    475478                    ? 'unpproved'
    476479                    : 'approved';
    477480                $success    = ( true === $is_approve )
    478                     ? bbp_approve_reply( $reply_id )
    479                     : bbp_unapprove_reply( $reply_id );
     481                    ? bbp_unapprove_reply( $reply_id )
     482                    : bbp_approve_reply( $reply_id );
    480483
    481484                break;
     
    801804        if ( current_user_can( 'moderate', $reply->ID ) ) {
    802805
    803             // Show the 'approve' link on pending posts only and 'unapprove' on published posts only
     806            // Show the 'approve' link on non-published posts only and 'unapprove' on published posts only
    804807            $approve_uri = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_approve' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'approve-reply_' . $reply->ID );
    805             if ( bbp_is_reply_published( $reply->ID ) ) {
     808            if ( bbp_is_reply_public( $reply->ID ) ) {
    806809                $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>';
    807             } elseif ( ! bbp_is_reply_private( $reply->ID ) ) {
     810            } else {
    808811                $actions['approved']   = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply',   'bbpress' ) . '">' . _x( 'Approve',   'Approve reply',   'bbpress' ) . '</a>';
    809812            }
    810813
    811814            // Show the 'spam' link on published and pending replies and 'not spam' on spammed replies
    812             if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id() ), true ) ) {
     815            if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id(), bbp_get_spam_status_id() ), true ) ) {
    813816                $spam_uri  = wp_nonce_url( add_query_arg( array( 'reply_id' => $reply->ID, 'action' => 'bbp_toggle_reply_spam' ), remove_query_arg( array( 'bbp_reply_toggle_notice', 'reply_id', 'failed', 'super' ) ) ), 'spam-reply_'  . $reply->ID );
    814                 if ( bbp_is_reply_spam( $reply->ID ) ) {
     817                if ( ! bbp_is_reply_spam( $reply->ID ) ) {
     818                    $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this reply as spam',    'bbpress' ) . '">' . esc_html__( 'Spam',     'bbpress' ) . '</a>';
     819                } else {
    815820                    $actions['unspam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark the reply as not spam', 'bbpress' ) . '">' . esc_html__( 'Not Spam', 'bbpress' ) . '</a>';
    816                 } else {
    817                     $actions['spam'] = '<a href="' . esc_url( $spam_uri ) . '" title="' . esc_attr__( 'Mark this reply as spam',    'bbpress' ) . '">' . esc_html__( 'Spam',     'bbpress' ) . '</a>';
    818821                }
    819822            }
     
    833836            if ( ( bbp_get_trash_status_id() === $reply->post_status ) || empty( $trash_days ) ) {
    834837                $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently', 'bbpress' ) . "' href='" . esc_url( get_delete_post_link( $reply->ID, '', true ) ) . "'>" . esc_html__( 'Delete Permanently', 'bbpress' ) . "</a>";
    835             } elseif ( bbp_get_spam_status_id() === $reply->post_status ) {
    836                 unset( $actions['trash'] );
    837838            }
    838839        }
     
    880881    public function filter_dropdown() {
    881882
    882         // Add "Empty Spam" button for moderators
    883         if ( ! empty( $_GET['post_status'] ) && ( bbp_get_spam_status_id() === $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
     883        // Get which forum is selected
     884        $selected = ! empty( $_GET['bbp_forum_id'] )
     885            ? (int) $_GET['bbp_forum_id']
     886            : 0;
     887
     888        // Show the forums dropdown
     889        bbp_dropdown( array(
     890            'selected'  => $selected,
     891            'show_none' => esc_html__( 'In all forums', 'bbpress' )
     892        ) );
     893    }
     894
     895    /**
     896     * Add "Empty Spam" button for moderators
     897     *
     898     * @since 2.6.0 bbPress (r6791)
     899     */
     900    public function filter_empty_spam() {
     901
     902        // Bail if not viewing spam
     903        if ( empty( $_GET['post_status'] ) || ( bbp_get_spam_status_id() !== $_GET['post_status'] ) && current_user_can( 'moderate' ) ) {
     904            return;
     905        }
     906
     907        ?>
     908
     909        <div class="alignleft actions"><?php
     910
     911            // Output the nonce & button
    884912            wp_nonce_field( 'bulk-destroy', '_destroy_nonce' );
    885913            submit_button(
     
    889917                false
    890918            );
    891         }
    892 
    893         // Get which forum is selected
    894         $selected = ! empty( $_GET['bbp_forum_id'] )
    895             ? (int) $_GET['bbp_forum_id']
    896             : 0;
    897 
    898         // Show the forums dropdown
    899         bbp_dropdown( array(
    900             'selected'  => $selected,
    901             'show_none' => esc_html__( 'In all forums', 'bbpress' )
    902         ) );
     919
     920        ?></div><?php
    903921    }
    904922
Note: See TracChangeset for help on using the changeset viewer.