Skip to:
Content

bbPress.org

Ticket #2732: 2732.2.diff

File 2732.2.diff, 1.5 KB (added by tharsheblows, 9 years ago)

adds in updating menu_order when approving reply

  • src/includes/replies/functions.php

     
    302302
    303303        /** Reply Status **********************************************************/
    304304
    305         // Maybe put into moderation
     305        // Maybe put into moderation and set the menu_order to zero
    306306        if ( !bbp_check_for_moderation( $anonymous_data, $reply_author, $reply_title, $reply_content ) ) {
    307307                $reply_status = bbp_get_pending_status_id();
     308                $menu_order = 0;
    308309
    309310        // Default
    310311        } else {
    311312                $reply_status = bbp_get_public_status_id();
     313                $menu_order = bbp_get_topic_reply_count( $topic_id, true ) + 1;
    312314        }
    313315
    314316        /** Reply To **************************************************************/
     
    361363                'post_parent'    => $topic_id,
    362364                'post_type'      => bbp_get_reply_post_type(),
    363365                'comment_status' => 'closed',
    364                 'menu_order'     => bbp_get_topic_reply_count( $topic_id, true ) + 1
     366                'menu_order'     => $menu_order
    365367        ) );
    366368
    367369        // Insert reply
     
    18601862        // Set publish status
    18611863        $reply->post_status = bbp_get_public_status_id();
    18621864
     1865        // Set the menu_order but only if going from original pending to publish, ie only if it has a menu_order == 0
     1866        if( $reply->menu_order == 0 ){
     1867                $topic_id = bbp_get_reply_topic_id( $reply->ID );
     1868                $reply->menu_order = bbp_get_topic_reply_count( $topic_id, true ) + 1;
     1869        }
     1870
    18631871        // No revisions
    18641872        remove_action( 'pre_post_update', 'wp_save_post_revision' );
    18651873