WordPress.org

Making WordPress.org

Changeset 4889


Ignore:
Timestamp:
02/07/2017 06:09:48 PM (5 years ago)
Author:
coffee2code
Message:

Support Forums: Add code for limiting no-replies view to 21 days.

The code is relocated from the wporg-support theme.

Props SergeyBiryukov.
See #2190.

File:
1 edited

Legend:

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

    r4613 r4889  
    3030        // Fix login url links
    3131        add_filter( 'login_url', array( $this, 'fix_login_url' ), 10, 3 );
     32
     33        // Limit no-replies view to certain number of days.
     34        add_filter( 'bbp_register_view_no_replies', array( $this, 'limit_no_replies_view' ) );
    3235    }
    3336
     
    149152    }
    150153
     154    /**
     155     * Limits No Replies view to 21 days by default.
     156     *
     157     * @param array $args Array of query args for the view.
     158     * @return array
     159     */
     160    public function limit_no_replies_view( $args ) {
     161        $days = 21;
     162
     163        if ( isset( $_GET['days'] ) ) {
     164            $days = (int) $_GET['days'];
     165        }
     166
     167        $args['date_query'] = array(
     168            array(
     169                'after'  => sprintf( '%s days ago', $days ),
     170            ),
     171        );
     172
     173        return $args;
     174    }
     175
    151176}
Note: See TracChangeset for help on using the changeset viewer.