Skip to:
Content

bbPress.org

Ticket #2645: 2645.diff

File 2645.diff, 42.0 KB (added by netweb, 11 years ago)
  • src/includes/admin/replies.php

     
    155155                        'content'       =>
    156156                                '<p>' . __( 'Hovering over a row in the replies list will display action links that allow you to manage your reply. You can perform the following actions:', 'bbpress' ) . '</p>' .
    157157                                '<ul>' .
    158                                         '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.',                                                                                 'bbpress' ) . '</li>' .
    159                                         //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.',                                                                  'bbpress' ) . '</li>' .
    160                                         '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.',                                                                                       'bbpress' ) . '</li>' .
    161                                         '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.',                                                                                   'bbpress' ) . '</li>' .
    162                                         '<li>' . __( '<strong>Preview</strong> will show you what your draft reply will look like if you publish it. View will take you to your live site to view the reply. Which link is available depends on your reply&#8217;s status.', 'bbpress' ) . '</li>' .
     158                                        '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that reply. You can also reach that screen by clicking on the reply title.',                  'bbpress' ) . '</li>' .
     159                                        //'<li>' . __( '<strong>Quick Edit</strong> provides inline access to the metadata of your reply, allowing you to update reply details without leaving this screen.', 'bbpress' ) . '</li>' .
     160                                        '<li>' . __( '<strong>Trash</strong> removes your reply from this list and places it in the trash, from which you can permanently delete it.',                        'bbpress' ) . '</li>' .
     161                                        '<li>' . __( '<strong>Spam</strong> removes your reply from this list and places it in the spam queue, from which you can permanently delete it.',                    'bbpress' ) . '</li>' .
     162                                        '<li>' . __( '<strong>View</strong> will take you to your live site to view the reply.',                                                                              'bbpress' ) . '</li>' .
     163                                        '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.',                                                                              'bbpress' ) . '</li>' .
    163164                                '</ul>'
    164165                ) );
    165166
     
    417418                                background-color: #faeaea;
    418419                        }
    419420
     421                        .status-pending {
     422                                background-color: #fef7f1;
     423                        }
     424
    420425                /*]]>*/
    421426                </style>
    422427
     
    449454                if ( $this->bail() ) return;
    450455
    451456                // Only proceed if GET is a reply toggle action
    452                 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam' ) ) && !empty( $_GET['reply_id'] ) ) {
     457                if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_reply_spam', 'bbp_toggle_reply_approve' ) ) && !empty( $_GET['reply_id'] ) ) {
    453458                        $action    = $_GET['action'];            // What action is taking place?
    454459                        $reply_id  = (int) $_GET['reply_id'];    // What's the reply id?
    455460                        $success   = false;                      // Flag
    456461                        $post_data = array( 'ID' => $reply_id ); // Prelim array
     462                        $reply     = bbp_get_reply( $reply_id );
    457463
    458464                        // Get reply and die if empty
    459                         $reply = bbp_get_reply( $reply_id );
    460                         if ( empty( $reply ) ) // Which reply?
     465                        if ( empty( $reply ) ) {
    461466                                wp_die( __( 'The reply was not found!', 'bbpress' ) );
     467                        }
    462468
    463                         if ( !current_user_can( 'moderate', $reply->ID ) ) // What is the user doing here?
     469                        // What is the user doing here?
     470                        if ( ! current_user_can( 'moderate', $reply->ID ) ) {
    464471                                wp_die( __( 'You do not have the permission to do that!', 'bbpress' ) );
     472                        }
    465473
    466474                        switch ( $action ) {
     475                                case 'bbp_toggle_reply_approve' :
     476                                        check_admin_referer( 'approve-reply_' . $reply_id );
     477
     478                                        $is_approve = bbp_is_reply_pending( $reply_id );
     479                                        $message    = $is_approve ? 'approved' : 'unapproved';
     480                                        $success    = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id );
     481
     482                                        break;
     483
    467484                                case 'bbp_toggle_reply_spam' :
    468485                                        check_admin_referer( 'spam-reply_' . $reply_id );
    469486
     
    474491                                        break;
    475492                        }
    476493
    477                         $success = wp_update_post( $post_data );
    478494                        $message = array( 'bbp_reply_toggle_notice' => $message, 'reply_id' => $reply->ID );
    479495
    480496                        if ( false === $success || is_wp_error( $success ) )
     
    511527                if ( $this->bail() ) return;
    512528
    513529                // Only proceed if GET is a reply toggle action
    514                 if ( bbp_is_get_request() && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed' ) ) && !empty( $_GET['reply_id'] ) ) {
     530                if ( bbp_is_get_request() && !empty( $_GET['bbp_reply_toggle_notice'] ) && in_array( $_GET['bbp_reply_toggle_notice'], array( 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && !empty( $_GET['reply_id'] ) ) {
    515531                        $notice     = $_GET['bbp_reply_toggle_notice'];         // Which notice?
    516532                        $reply_id   = (int) $_GET['reply_id'];                  // What's the reply id?
    517533                        $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure?
    518534
    519535                        // Empty? No reply?
    520                         if ( empty( $notice ) || empty( $reply_id ) )
     536                        if ( empty( $notice ) || empty( $reply_id ) ) {
    521537                                return;
     538                        }
    522539
    523540                        // Get reply and bail if empty
    524541                        $reply = bbp_get_reply( $reply_id );
    525                         if ( empty( $reply ) )
     542                        if ( empty( $reply ) ) {
    526543                                return;
     544                        }
    527545
    528546                        $reply_title = bbp_get_reply_title( $reply->ID );
    529547
    530548                        switch ( $notice ) {
    531549                                case 'spammed' :
    532                                         $message = $is_failure === true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.', 'bbpress' ), $reply_title );
     550                                        $message = $is_failure === true ? sprintf( __( 'There was a problem marking the reply "%1$s" as spam.',   'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully marked as spam.',  'bbpress' ), $reply_title );
    533551                                        break;
    534552
    535553                                case 'unspammed' :
    536554                                        $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the reply "%1$s" as spam.', 'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unmarked as spam.', 'bbpress' ), $reply_title );
    537555                                        break;
     556
     557                                case 'approved'   :
     558                                        $message = $is_failure === true ? sprintf( __( 'There was a problem approving the reply "%1$s".',         'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully approved.',         'bbpress' ), $reply_title );
     559                                        break;
     560
     561                                case 'unapproved' :
     562                                        $message = $is_failure === true ? sprintf( __( 'There was a problem unapproving the reply "%1$s".',       'bbpress' ), $reply_title ) : sprintf( __( 'Reply "%1$s" successfully unapproved.',       'bbpress' ), $reply_title );
     563                                        break;
    538564                        }
    539565
    540566                        // Do additional reply toggle notice filters (admin side)
     
    718744         */
    719745        public function row_actions( $actions, $reply ) {
    720746
    721                 if ( $this->bail() ) return $actions;
     747                if ( $this->bail() ) return $actions; {
     748                        unset( $actions['inline hide-if-no-js'] );
     749                }
    722750
    723                 unset( $actions['inline hide-if-no-js'] );
    724 
    725751                // Reply view links to topic
    726752                $actions['view'] = '<a href="' . esc_url( bbp_get_reply_url( $reply->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_reply_title( $reply->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
    727753
     
    729755                if ( ( bbp_get_trash_status_id() === $reply->post_status ) && !current_user_can( 'view_trash' ) )
    730756                        unset( $actions['view'] );
    731757
     758                        // Pending
     759                        // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
     760                        $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 );
     761                        if ( bbp_is_reply_published( $reply->ID ) ) {
     762                                $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this reply', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove reply', 'bbpress' ) . '</a>';
     763                        } elseif ( ! bbp_is_reply_private( $reply->ID ) ) {
     764                                $actions['approved']   = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this reply',   'bbpress' ) . '">' . _x( 'Approve',   'Approve reply',   'bbpress' ) . '</a>';
     765                        }
     766
    732767                // Only show the actions if the user is capable of viewing them
    733768                if ( current_user_can( 'moderate', $reply->ID ) ) {
    734769                        if ( in_array( $reply->post_status, array( bbp_get_public_status_id(), bbp_get_spam_status_id() ) ) ) {
  • src/includes/admin/topics.php

     
    154154                        'content'       =>
    155155                                '<p>' . __( 'Hovering over a row in the topics list will display action links that allow you to manage your topic. You can perform the following actions:', 'bbpress' ) . '</p>' .
    156156                                '<ul>' .
    157                                         '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                                                                                 'bbpress' ) . '</li>' .
    158                                         '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                                                                       'bbpress' ) . '</li>' .
    159                                         '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.',                                                                                   'bbpress' ) . '</li>' .
    160                                         '<li>' . __( '<strong>Preview</strong> will show you what your draft topic will look like if you publish it. View will take you to your live site to view the topic. Which link is available depends on your topic&#8217;s status.', 'bbpress' ) . '</li>' .
    161                                         '<li>' . __( '<strong>Close</strong> will mark the selected topic as &#8217;closed&#8217; and disable the option to post new replies to the topic.',                                                                                 'bbpress' ) . '</li>' .
    162                                         '<li>' . __( '<strong>Stick</strong> will keep the selected topic &#8217;pinned&#8217; to the top the parent forum topic list.',                                                                                                     'bbpress' ) . '</li>' .
    163                                         '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic &#8217;pinned&#8217; to the top of ALL forums and be visable in any forums topics list.',                                                      'bbpress' ) . '</li>' .
     157                                        '<li>' . __( '<strong>Edit</strong> takes you to the editing screen for that topic. You can also reach that screen by clicking on the topic title.',                            'bbpress' ) . '</li>' .
     158                                        '<li>' . __( '<strong>Trash</strong> removes your topic from this list and places it in the trash, from which you can permanently delete it.',                                  'bbpress' ) . '</li>' .
     159                                        '<li>' . __( '<strong>Spam</strong> removes your topic from this list and places it in the spam queue, from which you can permanently delete it.',                              'bbpress' ) . '</li>' .
     160                                        '<li>' . __( '<strong>View</strong> will take you to your live site to view the topic.',                                                                                        'bbpress' ) . '</li>' .
     161                                        '<li>' . __( '<strong>Approve</strong> will change the status from pending to publish.',                                                                                        'bbpress' ) . '</li>' .
     162                                        '<li>' . __( '<strong>Close</strong> will mark the selected topic as &#8217;closed&#8217; and disable the option to post new replies to the topic.',                            'bbpress' ) . '</li>' .
     163                                        '<li>' . __( '<strong>Stick</strong> will keep the selected topic &#8217;pinned&#8217; to the top the parent forum topic list.',                                                'bbpress' ) . '</li>' .
     164                                        '<li>' . __( '<strong>Stick <em>(to front)</em></strong> will keep the selected topic &#8217;pinned&#8217; to the top of ALL forums and be visable in any forums topics list.', 'bbpress' ) . '</li>' .
    164165                                '</ul>'
    165166                ) );
    166167
     
    433434                                background-color: #faeaea;
    434435                        }
    435436
     437                        .status-pending {
     438                                background-color: #fef7f1;
     439                        }
     440
    436441                /*]]>*/
    437442                </style>
    438443
     
    473478                if ( $this->bail() ) return;
    474479
    475480                // Only proceed if GET is a topic toggle action
    476                 if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam' ) ) && !empty( $_GET['topic_id'] ) ) {
     481                if ( bbp_is_get_request() && !empty( $_GET['action'] ) && in_array( $_GET['action'], array( 'bbp_toggle_topic_close', 'bbp_toggle_topic_stick', 'bbp_toggle_topic_spam', 'bbp_toggle_topic_approve' ) ) && !empty( $_GET['topic_id'] ) ) {
    477482                        $action    = $_GET['action'];            // What action is taking place?
    478483                        $topic_id  = (int) $_GET['topic_id'];    // What's the topic id?
    479484                        $success   = false;                      // Flag
     
    481486                        $topic     = bbp_get_topic( $topic_id );
    482487
    483488                        // Bail if topic is missing
    484                         if ( empty( $topic ) )
     489                        if ( empty( $topic ) ) {
    485490                                wp_die( __( 'The topic was not found!', 'bbpress' ) );
     491                        }
    486492
    487                         if ( !current_user_can( 'moderate', $topic->ID ) ) // What is the user doing here?
     493                        // What is the user doing here?
     494                        if ( ! current_user_can( 'moderate', $topic->ID ) ) {
    488495                                wp_die( __( 'You do not have the permission to do that!', 'bbpress' ) );
     496                        }
    489497
    490498                        switch ( $action ) {
     499                                case 'bbp_toggle_topic_approve'  :
     500                                        check_admin_referer( 'approve-topic_' . $topic_id );
     501
     502                                        $is_approve = bbp_is_topic_pending( $topic_id );
     503                                        $message    = true === $is_approve ? 'approved' : 'unapproved';
     504                                        $success    = true === $is_approve ? bbp_approve_topic( $topic_id ) : bbp_unapprove_topic( $topic_id );
     505
     506                                        break;
     507
    491508                                case 'bbp_toggle_topic_close' :
    492509                                        check_admin_referer( 'close-topic_' . $topic_id );
    493510
     
    554571                if ( $this->bail() ) return;
    555572
    556573                // Only proceed if GET is a topic toggle action
    557                 if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed' ) ) && !empty( $_GET['topic_id'] ) ) {
     574                if ( bbp_is_get_request() && !empty( $_GET['bbp_topic_toggle_notice'] ) && in_array( $_GET['bbp_topic_toggle_notice'], array( 'opened', 'closed', 'super_sticked', 'sticked', 'unsticked', 'spammed', 'unspammed', 'approved', 'unapproved' ) ) && !empty( $_GET['topic_id'] ) ) {
    558575                        $notice     = $_GET['bbp_topic_toggle_notice'];         // Which notice?
    559576                        $topic_id   = (int) $_GET['topic_id'];                  // What's the topic id?
    560577                        $is_failure = !empty( $_GET['failed'] ) ? true : false; // Was that a failure?
    561578
    562                         // Bais if no topic_id or notice
    563                         if ( empty( $notice ) || empty( $topic_id ) )
     579                        // Bail if no topic_id or notice
     580                        if ( empty( $notice ) || empty( $topic_id ) ) {
    564581                                return;
     582                        }
    565583
    566584                        // Bail if topic is missing
    567585                        $topic = bbp_get_topic( $topic_id );
    568                         if ( empty( $topic ) )
     586                        if ( empty( $topic ) ) {
    569587                                return;
     588                        }
    570589
    571590                        $topic_title = bbp_get_topic_title( $topic->ID );
    572591
     
    598617                                case 'unspammed' :
    599618                                        $message = $is_failure === true ? sprintf( __( 'There was a problem unmarking the topic "%1$s" as spam.', 'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully unmarked as spam.', 'bbpress' ), $topic_title );
    600619                                        break;
     620
     621                                case 'approved'   :
     622                                        $message = $is_failure === true ? sprintf( __( 'There was a problem approving the topic "%1$s".',         'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully approved.',         'bbpress' ), $topic_title );
     623                                        break;
     624
     625                                case 'unapproved' :
     626                                        $message = $is_failure === true ? sprintf( __( 'There was a problem unapproving the topic "%1$s".',       'bbpress' ), $topic_title ) : sprintf( __( 'Topic "%1$s" successfully unapproved.',       'bbpress' ), $topic_title );
     627                                        break;
    601628                        }
    602629
    603630                        // Do additional topic toggle notice filters (admin side)
     
    768795         */
    769796        public function row_actions( $actions, $topic ) {
    770797
    771                 if ( $this->bail() ) return $actions;
     798                if ( $this->bail() ) return $actions; {
     799                        unset( $actions['inline hide-if-no-js'] );
     800                }
    772801
    773                 unset( $actions['inline hide-if-no-js'] );
    774 
    775802                // Show view link if it's not set, the topic is trashed and the user can view trashed topics
    776                 if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) )
     803                if ( empty( $actions['view'] ) && ( bbp_get_trash_status_id() === $topic->post_status ) && current_user_can( 'view_trash' ) ) {
    777804                        $actions['view'] = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
     805                }
    778806
    779807                // Only show the actions if the user is capable of viewing them :)
    780808                if ( current_user_can( 'moderate', $topic->ID ) ) {
    781809
     810                        // Pending
     811                        // Show the 'approve' and 'view' link on pending posts only and 'unapprove' on published posts only
     812                        $approve_uri = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_approve' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'approve-topic_' . $topic->ID );
     813                        if ( bbp_is_topic_published( $topic->ID ) ) {
     814                                $actions['unapproved'] = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Unapprove this topic', 'bbpress' ) . '">' . _x( 'Unapprove', 'Unapprove Topic', 'bbpress' ) . '</a>';
     815                        } elseif ( ! bbp_is_topic_private( $topic->ID ) ) {
     816                                $actions['approved']   = '<a href="' . esc_url( $approve_uri ) . '" title="' . esc_attr__( 'Approve this topic',   'bbpress' ) . '">' . _x( 'Approve',   'Approve Topic',   'bbpress' ) . '</a>';
     817                                $actions['view']       = '<a href="' . esc_url( bbp_get_topic_permalink( $topic->ID ) ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;', 'bbpress' ), bbp_get_topic_title( $topic->ID ) ) ) . '" rel="permalink">' . esc_html__( 'View', 'bbpress' ) . '</a>';
     818                        }
     819
    782820                        // Close
    783821                        // Show the 'close' and 'open' link on published and closed posts only
    784822                        if ( in_array( $topic->post_status, array( bbp_get_public_status_id(), bbp_get_closed_status_id() ) ) ) {
     
    789827                                        $actions['closed'] = '<a href="' . esc_url( $close_uri ) . '" title="' . esc_attr__( 'Open this topic',  'bbpress' ) . '">' . _x( 'Open',  'Open a Topic',  'bbpress' ) . '</a>';
    790828                        }
    791829
    792                         // Dont show sticky if topic links is spam or trash
    793                         if ( !bbp_is_topic_spam( $topic->ID ) && !bbp_is_topic_trash( $topic->ID ) ) {
     830                        // Dont show sticky if topic links is spam, trash or pending
     831                        if ( ! bbp_is_topic_spam( $topic->ID ) && ! bbp_is_topic_trash( $topic->ID ) && ! bbp_is_topic_pending( $topic->ID ) ) {
    794832
    795833                                // Sticky
    796834                                $stick_uri  = wp_nonce_url( add_query_arg( array( 'topic_id' => $topic->ID, 'action' => 'bbp_toggle_topic_stick' ), remove_query_arg( array( 'bbp_topic_toggle_notice', 'topic_id', 'failed', 'super' ) ) ), 'stick-topic_'  . $topic->ID );
  • src/includes/core/actions.php

     
    155155add_action( 'bbp_template_notices', 'bbp_notice_edit_user_success'           );
    156156add_action( 'bbp_template_notices', 'bbp_notice_edit_user_is_super_admin', 2 );
    157157
    158 // Before Delete/Trash/Untrash Topic
     158// Before Delete/Trash/Untrash Forum
    159159add_action( 'wp_trash_post', 'bbp_trash_forum'   );
    160160add_action( 'trash_post',    'bbp_trash_forum'   );
    161161add_action( 'untrash_post',  'bbp_untrash_forum' );
    162162add_action( 'delete_post',   'bbp_delete_forum'  );
    163163
    164 // After Deleted/Trashed/Untrashed Topic
     164// After Deleted/Trashed/Untrashed Forum
    165165add_action( 'trashed_post',   'bbp_trashed_forum'   );
    166166add_action( 'untrashed_post', 'bbp_untrashed_forum' );
    167167add_action( 'deleted_post',   'bbp_deleted_forum'   );
     
    242242add_action( 'bbp_deleted_topic',   'bbp_update_topic_walker' );
    243243add_action( 'bbp_spammed_topic',   'bbp_update_topic_walker' );
    244244add_action( 'bbp_unspammed_topic', 'bbp_update_topic_walker' );
     245add_action( 'bbp_approve_topic',   'bbp_update_topic_walker' );
     246add_action( 'bbp_unapprove_topic', 'bbp_update_topic_walker' );
    245247
    246248// Update reply branch
    247249add_action( 'bbp_trashed_reply',   'bbp_update_reply_walker' );
     
    249251add_action( 'bbp_deleted_reply',   'bbp_update_reply_walker' );
    250252add_action( 'bbp_spammed_reply',   'bbp_update_reply_walker' );
    251253add_action( 'bbp_unspammed_reply', 'bbp_update_reply_walker' );
     254add_action( 'bbp_approve_reply',   'bbp_update_reply_walker' );
     255add_action( 'bbp_unapprove_reply', 'bbp_update_reply_walker' );
    252256
    253257// Users topic & reply counts
    254258add_action( 'bbp_new_topic',     'bbp_increase_user_topic_count' );
     
    267271add_action( 'bbp_untrash_topic', 'bbp_untrash_topic_replies' );
    268272add_action( 'bbp_delete_topic',  'bbp_delete_topic_replies'  );
    269273add_action( 'bbp_spam_topic',    'bbp_spam_topic_replies'    );
    270 add_action( 'bbp_unspam_topic', ' bbp_unspam_topic_replies'  );
     274add_action( 'bbp_unspam_topic',  'bbp_unspam_topic_replies'  );
    271275
    272276// User status
    273277// @todo make these sub-actions
     
    332336// Maybe convert the users password
    333337add_action( 'bbp_login_form_login', 'bbp_user_maybe_convert_pass' );
    334338
    335 add_action( 'bbp_activation', 'bbp_add_activation_redirect' );
    336  No newline at end of file
     339add_action( 'bbp_activation', 'bbp_add_activation_redirect' );
  • src/includes/replies/functions.php

     
    11431143 * @return array
    11441144 */
    11451145function bbp_get_reply_ancestors( $reply_id = 0 ) {
    1146        
     1146
    11471147        // Validation
    11481148        $reply_id  = bbp_get_reply_id( $reply_id );
    11491149        $ancestors = array();
     
    14461446                bbp_update_reply_to( $child->ID, $parent );
    14471447
    14481448        // Remove reply_to from moved reply
    1449         delete_post_meta( $move_reply->ID, '_bbp_reply_to' ); 
     1449        delete_post_meta( $move_reply->ID, '_bbp_reply_to' );
    14501450
    14511451        // It is a new topic and we need to set some default metas to make
    14521452        // the topic display in bbp_has_topics() list
     
    15581558        // Setup possible get actions
    15591559        $possible_actions = array(
    15601560                'bbp_toggle_reply_spam',
    1561                 'bbp_toggle_reply_trash'
     1561                'bbp_toggle_reply_trash',
     1562                'bbp_toggle_reply_approve'
    15621563        );
    15631564
    15641565        // Bail if actions aren't meant for this function
     
    15851586        // What action are we trying to perform?
    15861587        switch ( $action ) {
    15871588
     1589                // Toggle approve
     1590                case 'bbp_toggle_reply_approve' :
     1591                        check_ajax_referer( 'approve-reply_' . $reply_id );
     1592
     1593                        $is_approve  = bbp_is_reply_pending( $reply_id );
     1594                        $success  = $is_approve ? bbp_approve_reply( $reply_id ) : bbp_unapprove_reply( $reply_id );
     1595                        $failure  = $is_approve ? __( '<strong>ERROR</strong>: There was a problem approving the reply!', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving thereply!', 'bbpress' );
     1596                        $view_all = !$is_approve;
     1597
     1598                        break;
     1599
    15881600                // Toggle spam
    15891601                case 'bbp_toggle_reply_spam' :
    15901602                        check_ajax_referer( 'spam-reply_' . $reply_id );
     
    17821794        return $reply_id;
    17831795}
    17841796
     1797/**
     1798 * Approves a reply
     1799 *
     1800 * @since bbPress (rXXXX)
     1801 *
     1802 * @param int $reply_id Reply id
     1803 * @uses bbp_get_reply() To get the reply
     1804 * @uses do_action() Calls 'bbp_approve_reply' with the reply id
     1805 /* @uses add_post_meta() To add the previous status to a meta
     1806 /* @uses delete_post_meta() To delete the previous status meta
     1807 * @uses wp_update_post() To update the reply with the new status
     1808 * @uses do_action() Calls 'bbp_approved_reply' with the reply id
     1809 * @return mixed False or {@link WP_Error} on failure, reply id on success
     1810 */
     1811function bbp_approve_reply( $reply_id = 0 ) {
     1812
     1813        // Get reply
     1814        $reply = bbp_get_reply( $reply_id );
     1815        if ( empty( $reply ) ) {
     1816                return $reply;
     1817        }
     1818
     1819        // Bail if already approved
     1820        if ( bbp_get_pending_status_id() !== $reply->post_status ) {
     1821                return false;
     1822        }
     1823
     1824        // Execute pre pending code
     1825        do_action( 'bbp_approve_reply', $reply_id );
     1826
     1827        // Set publish status
     1828        $reply->post_status = bbp_get_public_status_id();
     1829
     1830        // No revisions
     1831        remove_action( 'pre_post_update', 'wp_save_post_revision' );
     1832
     1833        // Update reply
     1834        $reply_id = wp_update_post( $reply );
     1835
     1836        // Execute post pending code
     1837        do_action( 'bbp_approved_reply', $reply_id );
     1838
     1839        // Return reply_id
     1840        return $reply_id;
     1841}
     1842
     1843/**
     1844 * Unapproves a reply
     1845 *
     1846 * @since bbPress (rXXXX)
     1847 *
     1848 * @param int $reply_id Reply id
     1849 * @uses bbp_get_reply() To get the reply
     1850 * @uses do_action() Calls 'bbp_unapprove_reply' with the reply id
     1851 /* @uses get_post_meta() To get the previous status
     1852 /* @uses delete_post_meta() To delete the previous status meta
     1853 * @uses wp_update_post() To update the reply with the new status
     1854 * @uses do_action() Calls 'bbp_unapproved_reply' with the reply id
     1855 * @return mixed False or {@link WP_Error} on failure, reply id on success
     1856 */
     1857function bbp_unapprove_reply( $reply_id = 0 ) {
     1858
     1859        // Get reply
     1860        $reply = bbp_get_reply( $reply_id );
     1861        if ( empty( $reply ) ) {
     1862                return $reply;
     1863        }
     1864
     1865        // Bail if already pending
     1866        if ( bbp_get_pending_status_id() === $reply->post_status ) {
     1867                return false;
     1868        }
     1869
     1870        // Execute pre open code
     1871        do_action( 'bbp_unapprove_reply', $reply_id );
     1872
     1873        // Set pending status
     1874        $reply->post_status = bbp_get_pending_status_id();
     1875
     1876        // No revisions
     1877        remove_action( 'pre_post_update', 'wp_save_post_revision' );
     1878
     1879        // Update reply
     1880        $reply_id = wp_update_post( $reply );
     1881
     1882        // Execute post open code
     1883        do_action( 'bbp_unapproved_reply', $reply_id );
     1884
     1885        // Return reply_id
     1886        return $reply_id;
     1887}
     1888
    17851889/** Before Delete/Trash/Untrash ***********************************************/
    17861890
    17871891/**
     
    22902394
    22912395/**
    22922396 * Validate a `reply_to` field for hierarchical replies
    2293  * 
     2397 *
    22942398 * Checks for 2 scenarios:
    22952399 * -- The reply to ID is actually a reply
    22962400 * -- The reply to ID does not match the current reply
  • src/includes/replies/template.php

     
    150150                        bbp_get_public_status_id(),
    151151                        bbp_get_closed_status_id(),
    152152                        bbp_get_spam_status_id(),
    153                         bbp_get_trash_status_id()
     153                        bbp_get_trash_status_id(),
     154                        bbp_get_pending_status_id()
    154155                );
    155156
    156157                // Add support for private status
     
    944945}
    945946
    946947/**
     948 * Is the reply pending?
     949 *
     950 * @since bbPress (rXXXX)
     951 *
     952 * @param int $reply_id Optional. Topic id
     953 * @uses bbp_get_reply_id() To get the reply id
     954 * @uses bbp_get_reply_status() To get the reply status
     955 * @uses apply_filters() Calls 'bbp_is_reply_pending' with the reply id
     956 * @return bool True if pending, false if not.
     957 */
     958function bbp_is_reply_pending( $reply_id = 0 ) {
     959        $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_pending_status_id();
     960        return (bool) apply_filters( 'bbp_is_reply_pending', (bool) $reply_status, $reply_id );
     961}
     962
     963/**
     964 * Is the reply private?
     965 *
     966 * @since bbPress (rXXXX)
     967 *
     968 * @param int $reply_id Optional. Topic id
     969 * @uses bbp_get_reply_id() To get the reply id
     970 * @uses bbp_get_reply_status() To get the reply status
     971 * @uses apply_filters() Calls 'bbp_is_reply_private' with the reply id
     972 * @return bool True if private, false if not.
     973 */
     974function bbp_is_reply_private( $reply_id = 0 ) {
     975        $reply_status = bbp_get_reply_status( bbp_get_reply_id( $reply_id ) ) === bbp_get_private_status_id();
     976        return (bool) apply_filters( 'bbp_is_reply_private', (bool) $reply_status, $reply_id );
     977}
     978
     979/**
    947980 * Is the reply by an anonymous user?
    948981 *
    949982 * @since bbPress (r2753)
     
    18391872                // If no links were passed, default to the standard
    18401873                if ( empty( $r['links'] ) ) {
    18411874                        $r['links'] = apply_filters( 'bbp_reply_admin_links', array(
    1842                                 'edit'  => bbp_get_reply_edit_link ( $r ),
    1843                                 'move'  => bbp_get_reply_move_link ( $r ),
    1844                                 'split' => bbp_get_topic_split_link( $r ),
    1845                                 'trash' => bbp_get_reply_trash_link( $r ),
    1846                                 'spam'  => bbp_get_reply_spam_link ( $r ),
    1847                                 'reply' => bbp_get_reply_to_link   ( $r )
     1875                                'edit'    => bbp_get_reply_edit_link   ( $r ),
     1876                                'move'    => bbp_get_reply_move_link   ( $r ),
     1877                                'split'   => bbp_get_topic_split_link  ( $r ),
     1878                                'trash'   => bbp_get_reply_trash_link  ( $r ),
     1879                                'spam'    => bbp_get_reply_spam_link   ( $r ),
     1880                                'approve' => bbp_get_reply_approve_link( $r ),
     1881                                'reply'   => bbp_get_reply_to_link     ( $r )
    18481882                        ), $r['id'] );
    18491883                }
    18501884
    18511885                // See if links need to be unset
    18521886                $reply_status = bbp_get_reply_status( $r['id'] );
    1853                 if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {
     1887                if ( in_array( $reply_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) {
    18541888
    18551889                        // Spam link shouldn't be visible on trashed topics
    18561890                        if ( bbp_get_trash_status_id() === $reply_status ) {
     
    22542288        }
    22552289
    22562290/**
     2291 * Output the approve link of the reply
     2292 *
     2293 * @since bbPress (rXXXX)
     2294 *
     2295 * @param mixed $args See {@link bbp_get_reply_approve_link()}
     2296 * @uses bbp_get_reply_approve_link() To get the reply approve link
     2297 */
     2298function bbp_reply_approve_link( $args = '' ) {
     2299        echo bbp_get_reply_approve_link( $args );
     2300}
     2301
     2302        /**
     2303         * Return the approve link of the reply
     2304         *
     2305         * @since bbPress (rXXXX)
     2306         *
     2307         * @param mixed $args This function supports these args:
     2308         *  - id: Optional. Reply id
     2309         *  - link_before: Before the link
     2310         *  - link_after: After the link
     2311         *  - sep: Separator between links
     2312         *  - approve_text: Approve text
     2313         *  - unapprove_text: Unapprove text
     2314         * @uses bbp_get_reply_id() To get the reply id
     2315         * @uses bbp_get_reply() To get the reply
     2316         * @uses current_user_can() To check if the current user can approve the reply
     2317         * @uses bbp_is_reply_pending() To check if the reply is pending
     2318         * @uses add_query_arg() To add custom args to the url
     2319         * @uses wp_nonce_url() To nonce the url
     2320         * @uses esc_url() To escape the url
     2321         * @uses apply_filters() Calls 'bbp_get_reply_approve_link' with the link
     2322         *                        and args
     2323         * @return string Reply approve link
     2324         */
     2325        function bbp_get_reply_approve_link( $args = '' ) {
     2326
     2327                // Parse arguments against default values
     2328                $r = bbp_parse_args( $args, array(
     2329                        'id'             => 0,
     2330                        'link_before'    => '',
     2331                        'link_after'     => '',
     2332                        'sep'            => ' | ',
     2333                        'approve_text'   => _x( 'Approve', 'Pending Status', 'bbpress' ),
     2334                        'unapprove_text' => _x( 'Unapprove',  'Pending Status', 'bbpress' )
     2335                ), 'get_reply_approve_link' );
     2336
     2337                $reply = bbp_get_reply( bbp_get_reply_id( (int) $r['id'] ) );
     2338
     2339                if ( empty( $reply ) || !current_user_can( 'moderate', $reply->ID ) )
     2340                        return;
     2341
     2342                $display = bbp_is_reply_pending( $reply->ID ) ? $r['approve_text'] : $r['unapprove_text'];
     2343                $uri     = add_query_arg( array( 'action' => 'bbp_toggle_reply_approve', 'reply_id' => $reply->ID ) );
     2344                $uri     = wp_nonce_url( $uri, 'approve-reply_' . $reply->ID );
     2345                $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-reply-approve-link">' . $display . '</a>' . $r['link_after'];
     2346
     2347                return apply_filters( 'bbp_get_reply_approve_link', $retval, $r );
     2348        }
     2349
     2350/**
    22572351 * Output the row class of a reply
    22582352 *
    22592353 * @since bbPress (r2678)
  • src/includes/topics/functions.php

     
    20682068                'bbp_toggle_topic_close',
    20692069                'bbp_toggle_topic_stick',
    20702070                'bbp_toggle_topic_spam',
    2071                 'bbp_toggle_topic_trash'
     2071                'bbp_toggle_topic_trash',
     2072                'bbp_toggle_topic_approve'
    20722073        );
    20732074
    20742075        // Bail if actions aren't meant for this function
     
    20962097        // What action are we trying to perform?
    20972098        switch ( $action ) {
    20982099
     2100                // Toggle approve/unapprove
     2101                case 'bbp_toggle_topic_approve' :
     2102                        check_ajax_referer( 'approve-topic_' . $topic_id );
     2103
     2104                        $is_pending = bbp_is_topic_pending( $topic_id );
     2105                        $success    = true === $is_pending ? bbp_approve_topic( $topic_id ) : bbp_unapprove_topic( $topic_id );
     2106                        $failure    = true === $is_pending ? __( '<strong>ERROR</strong>: There was a problem approving the topic.', 'bbpress' ) : __( '<strong>ERROR</strong>: There was a problem unapproving the topic.', 'bbpress' );
     2107
     2108                        break;
     2109
    20992110                // Toggle open/close
    21002111                case 'bbp_toggle_topic_close' :
    21012112                        check_ajax_referer( 'close-topic_' . $topic_id );
     
    31243135}
    31253136
    31263137/**
     3138 * Approves a topic
     3139 *
     3140 * @since bbPress (rXXXX)
     3141 *
     3142 * @param int $topic_id Topic id
     3143 * @uses bbp_get_topic() To get the topic
     3144 * @uses do_action() Calls 'bbp_approve_topic' with the topic id
     3145 /* @uses add_post_meta() To add the previous status to a meta
     3146 /* @uses delete_post_meta() To delete the previous status meta
     3147 * @uses wp_update_post() To update the topic with the new status
     3148 * @uses do_action() Calls 'bbp_approved_topic' with the topic id
     3149 * @return mixed False or {@link WP_Error} on failure, topic id on success
     3150 */
     3151function bbp_approve_topic( $topic_id = 0 ) {
     3152
     3153        // Get topic
     3154        $topic = bbp_get_topic( $topic_id );
     3155        if ( empty( $topic ) ) {
     3156                return $topic;
     3157        }
     3158
     3159        // Bail if already approved
     3160        if ( bbp_get_pending_status_id() !== $topic->post_status ) {
     3161                return false;
     3162        }
     3163
     3164        // Execute pre pending code
     3165        do_action( 'bbp_approve_topic', $topic_id );
     3166
     3167        // Set publish status
     3168        $topic->post_status = bbp_get_public_status_id();
     3169
     3170        // No revisions
     3171        remove_action( 'pre_post_update', 'wp_save_post_revision' );
     3172
     3173        // Update topic
     3174        $topic_id = wp_update_post( $topic );
     3175
     3176        // Execute post pending code
     3177        do_action( 'bbp_approved_topic', $topic_id );
     3178
     3179        // Return topic_id
     3180        return $topic_id;
     3181}
     3182
     3183/**
     3184 * Unapproves a topic
     3185 *
     3186 * @since bbPress (rXXXX)
     3187 *
     3188 * @param int $topic_id Topic id
     3189 * @uses bbp_get_topic() To get the topic
     3190 * @uses do_action() Calls 'bbp_unapprove_topic' with the topic id
     3191 /* @uses get_post_meta() To get the previous status
     3192 /* @uses delete_post_meta() To delete the previous status meta
     3193 * @uses wp_update_post() To update the topic with the new status
     3194 * @uses do_action() Calls 'bbp_unapproved_topic' with the topic id
     3195 * @return mixed False or {@link WP_Error} on failure, topic id on success
     3196 */
     3197function bbp_unapprove_topic( $topic_id = 0 ) {
     3198
     3199        // Get topic
     3200        $topic = bbp_get_topic( $topic_id );
     3201        if ( empty( $topic ) ) {
     3202                return $topic;
     3203        }
     3204
     3205        // Bail if already pending
     3206        if ( bbp_get_pending_status_id() === $topic->post_status ) {
     3207                return false;
     3208        }
     3209
     3210        // Execute pre open code
     3211        do_action( 'bbp_unapprove_topic', $topic_id );
     3212
     3213        // Set pending status
     3214        $topic->post_status = bbp_get_pending_status_id();
     3215
     3216        // No revisions
     3217        remove_action( 'pre_post_update', 'wp_save_post_revision' );
     3218
     3219        // Update topic
     3220        $topic_id = wp_update_post( $topic );
     3221
     3222        // Execute post open code
     3223        do_action( 'bbp_unapproved_topic', $topic_id );
     3224
     3225        // Return topic_id
     3226        return $topic_id;
     3227}
     3228
     3229/**
    31273230 * Unsticks a topic both from front and it's forum
    31283231 *
    31293232 * @since bbPress (r2754)
  • src/includes/topics/template.php

     
    170170                        bbp_get_public_status_id(),
    171171                        bbp_get_closed_status_id(),
    172172                        bbp_get_spam_status_id(),
    173                         bbp_get_trash_status_id()
     173                        bbp_get_trash_status_id(),
     174                        bbp_get_pending_status_id()
    174175                );
    175176
    176177                // Add support for private status
     
    12121213}
    12131214
    12141215/**
     1216 * Is the topic pending?
     1217 *
     1218 * @since bbPress (rXXXX)
     1219 *
     1220 * @param int $topic_id Optional. Topic id
     1221 * @uses bbp_get_topic_id() To get the topic id
     1222 * @uses bbp_get_topic_status() To get the topic status
     1223 * @uses apply_filters() Calls 'bbp_is_topic_pending' with the topic id
     1224 * @return bool True if pending, false if not.
     1225 */
     1226function bbp_is_topic_pending( $topic_id = 0 ) {
     1227        $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_pending_status_id();
     1228        return (bool) apply_filters( 'bbp_is_topic_pending', (bool) $topic_status, $topic_id );
     1229}
     1230
     1231/**
     1232 * Is the topic private?
     1233 *
     1234 * @since bbPress (rXXXX)
     1235 *
     1236 * @param int $topic_id Optional. Topic id
     1237 * @uses bbp_get_topic_id() To get the topic id
     1238 * @uses bbp_get_topic_status() To get the topic status
     1239 * @uses apply_filters() Calls 'bbp_is_topic_private' with the topic id
     1240 * @return bool True if private, false if not.
     1241 */
     1242function bbp_is_topic_private( $topic_id = 0 ) {
     1243        $topic_status = bbp_get_topic_status( bbp_get_topic_id( $topic_id ) ) === bbp_get_private_status_id();
     1244        return (bool) apply_filters( 'bbp_is_topic_private', (bool) $topic_status, $topic_id );
     1245}
     1246
     1247/**
    12151248 * Is the posted by an anonymous user?
    12161249 *
    12171250 * @since bbPress (r2753)
     
    24202453
    24212454                if ( empty( $r['links'] ) ) {
    24222455                        $r['links'] = apply_filters( 'bbp_topic_admin_links', array(
    2423                                 'edit'  => bbp_get_topic_edit_link ( $r ),
    2424                                 'close' => bbp_get_topic_close_link( $r ),
    2425                                 'stick' => bbp_get_topic_stick_link( $r ),
    2426                                 'merge' => bbp_get_topic_merge_link( $r ),
    2427                                 'trash' => bbp_get_topic_trash_link( $r ),
    2428                                 'spam'  => bbp_get_topic_spam_link ( $r ),
    2429                                 'reply' => bbp_get_topic_reply_link( $r )
     2456                                'edit'    => bbp_get_topic_edit_link   ( $r ),
     2457                                'close'   => bbp_get_topic_close_link  ( $r ),
     2458                                'stick'   => bbp_get_topic_stick_link  ( $r ),
     2459                                'merge'   => bbp_get_topic_merge_link  ( $r ),
     2460                                'trash'   => bbp_get_topic_trash_link  ( $r ),
     2461                                'spam'    => bbp_get_topic_spam_link   ( $r ),
     2462                                'approve' => bbp_get_topic_approve_link( $r ),
     2463                                'reply'   => bbp_get_topic_reply_link  ( $r )
    24302464                        ), $r['id'] );
    24312465                }
    24322466
    24332467                // See if links need to be unset
    24342468                $topic_status = bbp_get_topic_status( $r['id'] );
    2435                 if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id() ) ) ) {
     2469                if ( in_array( $topic_status, array( bbp_get_spam_status_id(), bbp_get_trash_status_id(), bbp_get_pending_status_id() ) ) ) {
    24362470
    2437                         // Close link shouldn't be visible on trashed/spammed topics
     2471                        // Close link shouldn't be visible on trashed/spammed/pending topics
    24382472                        unset( $r['links']['close'] );
    24392473
    24402474                        // Spam link shouldn't be visible on trashed topics
     
    27042738        }
    27052739
    27062740/**
     2741 * Output the approve link of the topic
     2742 *
     2743 * @since bbPress (rXXXX)
     2744 *
     2745 * @param mixed $args See {@link bbp_get_topic_approve_link()}
     2746 * @uses bbp_get_topic_approve_link() To get the topic approve link
     2747 */
     2748function bbp_topic_approve_link( $args = '' ) {
     2749        echo bbp_get_topic_approve_link( $args );
     2750}
     2751
     2752        /**
     2753         * Return the approve link of the topic
     2754         *
     2755         * @since bbPress (rXXXX)
     2756         *
     2757         * @param mixed $args This function supports these args:
     2758         *  - id: Optional. Topic id
     2759         *  - link_before: Before the link
     2760         *  - link_after: After the link
     2761         *  - sep: Separator between links
     2762         *  - approve_text: Approve text
     2763         *  - unapprove_text: Unapprove text
     2764         * @uses bbp_get_topic_id() To get the topic id
     2765         * @uses bbp_get_topic() To get the topic
     2766         * @uses current_user_can() To check if the current user can approve the topic
     2767         * @uses bbp_is_topic_pending() To check if the topic is pending
     2768         * @uses add_query_arg() To add custom args to the url
     2769         * @uses wp_nonce_url() To nonce the url
     2770         * @uses esc_url() To escape the url
     2771         * @uses apply_filters() Calls 'bbp_get_topic_approve_link' with the link
     2772         *                        and args
     2773         * @return string Topic approve link
     2774         */
     2775        function bbp_get_topic_approve_link( $args = '' ) {
     2776
     2777                // Parse arguments against default values
     2778                $r = bbp_parse_args( $args, array(
     2779                        'id'             => 0,
     2780                        'link_before'    => '',
     2781                        'link_after'     => '',
     2782                        'sep'            => ' | ',
     2783                        'approve_text'   => _x( 'Approve', 'Pending Status', 'bbpress' ),
     2784                        'unapprove_text' => _x( 'Unapprove',  'Pending Status', 'bbpress' )
     2785                ), 'get_topic_approve_link' );
     2786
     2787                $topic = bbp_get_topic( bbp_get_topic_id( (int) $r['id'] ) );
     2788
     2789                if ( empty( $topic ) || !current_user_can( 'moderate', $topic->ID ) )
     2790                        return;
     2791
     2792                $display = bbp_is_topic_pending( $topic->ID ) ? $r['approve_text'] : $r['unapprove_text'];
     2793                $uri     = add_query_arg( array( 'action' => 'bbp_toggle_topic_approve', 'topic_id' => $topic->ID ) );
     2794                $uri     = wp_nonce_url( $uri, 'approve-topic_' . $topic->ID );
     2795                $retval  = $r['link_before'] . '<a href="' . esc_url( $uri ) . '" class="bbp-topic-approve-link">' . $display . '</a>' . $r['link_after'];
     2796
     2797                return apply_filters( 'bbp_get_topic_approve_link', $retval, $r );
     2798        }
     2799
     2800/**
    27072801 * Output the stick link of the topic
    27082802 *
    27092803 * @since bbPress (r2754)
  • src/templates/default/css/bbpress.css

     
    5454        background-color: #fdd;
    5555}
    5656
     57#bbpress-forums .status-pending.even,
     58#bbpress-forums .status-pending.odd,
     59#bbpress-forums ul.status-pending a {
     60        background-color: #fef7f1;
     61}
     62
    5763#bbpress-forums ul.status-closed,
    5864#bbpress-forums ul.status-closed a {
    5965        color: #ccc;