Changeset 5868
- Timestamp:
- 09/03/2017 09:46:04 PM (7 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
r5636 r5868 24 24 var $authors = null; 25 25 var $contributors = null; 26 var $support_reps = null; 26 27 var $query = null; 27 28 var $term = null; … … 317 318 $this->authors = $this->get_authors( $slug ); 318 319 $this->contributors = $this->get_contributors( $slug ); 320 $this->support_reps = $this->get_support_reps( $slug ); 319 321 $this->term = $terms[0]; 320 322 … … 332 334 // Instantiate WPORG_Stickies mode for topic view. 333 335 if ( class_exists( 'WordPressdotorg\Forums\Stickies_Compat' ) ) { 334 $this->stickies = new Stickies_Compat( $this->compat(), $this->slug(), $this->taxonomy(), $this->get_object( $this->slug() ), $this->term, $this->authors, $this->contributors );336 $this->stickies = new Stickies_Compat( $this->compat(), $this->slug(), $this->taxonomy(), $this->get_object( $this->slug() ), $this->term, $this->authors, $this->contributors, $this->support_reps ); 335 337 } 336 338 … … 341 343 342 344 /** 343 * Allow plugin/theme authors and contributors to resolve a topic on their support forum. 345 * Allow plugin/theme authors, contributors, and support reps to resolve a topic 346 * on their support forum. 344 347 * 345 348 * @param bool $retval If the user can set a topic resolution for the topic … … 358 361 ( ! empty( $this->contributors ) && in_array( $user->user_nicename, $this->contributors ) ) 359 362 || 363 ( ! empty( $this->support_reps ) && in_array( $user->user_nicename, $this->support_reps ) ) 364 || 365 // Back-compat for support reps added before https://meta.trac.wordpress.org/changeset/5867, 366 // can be removed once they are re-added via the Plugin Directory UI. 360 367 ( is_a( $user, 'WP_User' ) && $user->supportrep == $this->slug() ) 361 368 ) { … … 902 909 return $contributors; 903 910 } 911 912 public function get_support_reps( $slug ) { 913 global $wpdb; 914 915 if ( null !== $this->support_reps ) { 916 return $this->support_reps; 917 } 918 919 // Themes do not have support reps right now. 920 if ( $this->compat() == 'theme' ) { 921 $support_reps = array(); 922 return $support_reps; 923 } 924 925 // Check the cache. 926 $cache_key = $slug; 927 $cache_group = $this->compat() . '-support-reps-slugs'; 928 $support_reps = wp_cache_get( $cache_key, $cache_group ); 929 if ( ! $support_reps ) { 930 $plugin = $this->get_object( $slug ); 931 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 932 $support_reps = $wpdb->get_col( $wpdb->prepare( 933 "SELECT slug 934 FROM {$prefix}terms AS t 935 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 936 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 937 WHERE tt.taxonomy = 'plugin_support_reps' AND tr.object_id = %d", 938 $plugin->ID 939 ) ); 940 941 wp_cache_set( $cache_key, $support_reps, $cache_group, HOUR_IN_SECONDS ); 942 } 943 return $support_reps; 944 } 904 945 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php
r5755 r5868 79 79 $this->authors = $this->get_authors( $slug ); 80 80 $this->contributors = $this->get_contributors( $slug ); 81 $this->support_reps = $this->get_support_reps( $slug ); 81 82 } 82 83 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-stickies-compat.php
r5749 r5868 13 13 var $term = null; 14 14 15 public function __construct( $compat, $slug, $taxonomy, $object, $term, $authors = array(), $contributors = array() ) {15 public function __construct( $compat, $slug, $taxonomy, $object, $term, $authors = array(), $contributors = array(), $support_reps = array() ) { 16 16 if ( empty( $compat ) || empty( $slug ) || empty( $taxonomy ) || empty( $object ) || empty( $term ) ) { 17 17 return; … … 25 25 $this->authors = $authors; 26 26 $this->contributors = $contributors; 27 $this->support_reps = $support_reps; 27 28 28 29 // Remove global stickies from sticky array. … … 248 249 $retval = true; 249 250 } 251 252 // Compat support reps. 253 if ( $this->support_reps && in_array( $user->user_nicename, $this->support_reps ) ) { 254 $retval = true; 255 } 250 256 } 251 257 return $retval; -
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
r5755 r5868 79 79 $this->authors = $this->get_authors( $slug ); 80 80 $this->contributors = $this->get_contributors( $slug ); 81 $this->support_reps = $this->get_support_reps( $slug ); 81 82 } 82 83 }
Note: See TracChangeset
for help on using the changeset viewer.