Changeset 3990
- Timestamp:
- 09/07/2016 03:15:35 PM (9 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
r3986 r3990 13 13 if ( ! $this->loaded ) { 14 14 15 // Exclude compat forums from forum dropdown. 16 add_filter( 'bbp_after_get_dropdown_parse_args', array( $this, 'get_dropdown' ) ); 17 15 18 // Topic resolution modifications. 16 19 add_filter( 'wporg_bbp_topic_resolution_is_enabled_on_forum', array( $this, 'is_enabled_on_forum' ), 10, 2 ); … … 18 21 $this->loaded = true; 19 22 } 23 } 24 25 /** 26 * Remove compat forums from forum dropdown. 27 * 28 * @param array $r The function args 29 * @return array The filtered args 30 */ 31 public function get_dropdown( $r ) { 32 if ( ! isset( $r['post_type'] ) || ! $r['post_type'] == bbp_get_forum_post_type() ) { 33 return $r; 34 } 35 36 // Set up compat forum exclusion. 37 if ( bbp_is_topic_edit() || bbp_is_single_view() ) { 38 $r['exclude'] = array_unique( array_merge( $r['exclude'], self::get_compat_forums() ) ); 39 40 if ( self::is_compat_forum( $r['selected'] ) ) { 41 // Prevent forum changes for topics in compat forums. 42 add_filter( 'bbp_get_dropdown', array( $this, 'dropdown' ), 10, 2 ); 43 } 44 } 45 return $r; 46 } 47 48 /** 49 * Disable forum changes on topics in the compat forums. 50 * 51 * @param string $retval The dropdown 52 * @param array $r The function arguments 53 * @return string The dropdown, or substituted hidden input 54 */ 55 public function dropdown( $retval, $r ) { 56 if ( self::is_compat_forum( $r['selected'] ) ) { 57 $retval = esc_html( bbp_get_forum_title( $r['selected'] ) ); 58 $retval .= sprintf( '<input type="hidden" name="bbp_forum_id" id="bbp_forum_id" value="%d" />', (int) $r['selected'] ); 59 } 60 return $retval; 20 61 } 21 62 … … 45 86 return $retval; 46 87 } 88 89 public static function get_compat_forums() { 90 return array( Plugin::PLUGINS_FORUM_ID, Plugin::THEMES_FORUM_ID, Plugin::REVIEWS_FORUM_ID ); 91 } 92 93 public static function is_compat_forum( $post_id = 0 ) { 94 if ( empty( $post_id ) ) { 95 return false; 96 } 97 return in_array( $post_id, self::get_compat_forums() ); 98 } 47 99 }
Note: See TracChangeset
for help on using the changeset viewer.