Changeset 4583 for sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
- Timestamp:
- 12/23/2016 07:11:25 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-support-compat.php
r4331 r4583 12 12 var $user = null; 13 13 14 /** 15 * Forums to be hidden from main forum listing. 16 * 17 * @var array 18 */ 19 const HIDDEN_FORUMS = array( 20 21261, // Themes and Templates 21 21262, // Plugins and Hacks 22 21267, // Your WordPress 23 21270, // Meetups 24 21272, // Reviews 25 ); 26 14 27 public function __construct() { 15 28 if ( ! $this->loaded ) { … … 40 53 add_action( 'template_redirect', array( $this, 'redirect_old_topic_id' ), 9 ); 41 54 55 // Exclude certain forums from forum queries. 56 add_action( 'pre_get_posts', array( $this, 'exclude_hidden_forums' ), 1 ); 57 42 58 $this->loaded = true; 59 } 60 } 61 62 /** 63 * Excludes certain forums from queries for forums. 64 * 65 * Notes: 66 * - The forums themselves are still meant to be directly accessible. 67 * - A hidden forum may not necessarily be closed. 68 * 69 * @param WP_Query $q Query object. 70 */ 71 public function exclude_hidden_forums( $q ) { 72 if ( 73 ! is_admin() 74 && 75 ! empty( $q->query_vars['post_type'] ) 76 && 77 bbp_get_forum_post_type() === $q->query_vars['post_type'] 78 && 79 empty( $q->query_vars['forum'] ) 80 ) { 81 $q->query_vars['post__not_in'] = array_merge( $q->query_vars['post__not_in'], self::HIDDEN_FORUMS ); 43 82 } 44 83 }
Note: See TracChangeset
for help on using the changeset viewer.