Making WordPress.org

Changeset 12860


Ignore:
Timestamp:
08/24/2023 05:54:28 PM (8 months ago)
Author:
Clorith
Message:

Support Forums: Limit No Replies by voices over reply counts.

When any reply is made to a topic, they will be removed from the No Replies view, but this both limited OPs from adding details after the fact, and also means the Support Team needed guidelines to prevent "bumping".

This change converts the No Replies query to looking for "voices" (participants within a topic) over reply counts, which will allow additional details to be posted, and remove the need for rules against "bumping".

Fixes #4577.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-hooks.php

    r12810 r12860  
    7676        add_filter( 'bbp_register_view_no_replies', array( $this, 'limit_no_replies_view' ) );
    7777
     78        // Allow topics with the OP adding more details to show up in no-replies view.
     79        add_filter( 'bbp_register_view_no_replies', array( $this, 'make_no_replies_consider_voices' ), 20 );
     80
    7881        // Remove the description from the CPT to avoid Jetpack using it as the og:description.
    7982        add_filter( 'bbp_register_forum_post_type', array( $this, 'bbp_register_forum_post_type' ) );
     
    333336     *  - /users/$id & /profile/$slug to /users/$slug
    334337     *  - /users/profile/* => /users/$slug/*
    335      * 
     338     *
    336339     * See also: Support_Compat in inc/class-support-compat.php
    337340     */
     
    627630        if ( bbp_is_single_topic() ) {
    628631            $topic_id = bbp_get_topic_id();
    629    
     632
    630633            // Prepend label if thread is closed.
    631634            if ( bbp_is_topic_closed( $topic_id ) ) {
     
    931934
    932935    /**
     936     * Modifies the No Replies view to look at the amount of voices instead of replies.
     937     *
     938     * This allows a topic OP to provide additional details without their topic
     939     * going away from the No Replies view.
     940     *
     941     * @param array $args Array of query args for the view.
     942     * @return array
     943     */
     944    public function make_no_replies_consider_voices( $args ) {
     945        /*
     946         * Remove the default view arguments, in favor of a new meta_query instead.
     947         * Looping over an array of defined keys allows us to be forward compatible
     948         * if bbPress implements meta queries in the future.
     949         */
     950        $default_keys = array( 'meta_key', 'meta_type', 'meta_value', 'meta_compare' );
     951        foreach ( $default_keys as $key ) {
     952            if ( isset( $args[ $key ] ) ) {
     953                unset( $args[ $key ] );
     954            }
     955        }
     956
     957        $args['meta_query'][] = array(
     958            'key'     => '_bbp_voice_count',
     959            'type'    => 'NUMERIC',
     960            'value'   => 2,
     961            'compare' => '<',
     962        );
     963
     964        return $args;
     965    }
     966
     967    /**
    933968     * Remove the Forum CPT description field to prevent Jetpack using it as the og:description on /forums/.
    934969     */
     
    12711306        return $content;
    12721307    }
    1273    
     1308
    12741309    /**
    12751310     * Alter the bbPress topic freshness links to use the date in the title attribute rather than thread title.
     
    13041339
    13051340    /**
    1306      * Filter the topic subscription message to 
     1341     * Filter the topic subscription message to
    13071342     */
    13081343    public function bbp_subscription_mail_message( $message, $reply_id, $topic_id ) {
Note: See TracChangeset for help on using the changeset viewer.