Ticket #2699: 2699.patch
File 2699.patch, 8.9 KB (added by , 7 years ago) |
---|
-
wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
23 23 var $loaded = false; 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; 28 29 … … 316 317 $this->{$this->compat()} = $this->get_object( $slug ); 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 321 323 // Add output filters and actions. … … 331 333 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 337 339 $this->loaded = true; … … 357 359 || 358 360 ( ! empty( $this->contributors ) && in_array( $user->user_nicename, $this->contributors ) ) 359 361 || 360 ( is_a( $user, 'WP_User' ) && $user->supportrep == $this->slug() )362 ( ! empty( $this->support_reps ) && in_array( $user->user_nicename, $this->support_reps ) ) 361 363 ) { 362 364 $retval = true; 363 365 } … … 901 903 } 902 904 return $contributors; 903 905 } 906 907 public function get_support_reps( $slug ) { 908 global $wpdb; 909 910 if ( null !== $this->support_reps ) { 911 return $this->support_reps; 912 } 913 914 // Themes do not have support reps right now. 915 if ( $this->compat() == 'theme' ) { 916 $support_reps = array(); 917 return $support_reps; 918 } 919 920 // Check the cache. 921 $cache_key = $slug; 922 $cache_group = $this->compat() . '-support-reps-slugs'; 923 $support_reps = wp_cache_get( $cache_key, $cache_group ); 924 if ( ! $support_reps ) { 925 $plugin = $this->get_object( $slug ); 926 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 927 $support_reps = $wpdb->get_col( $wpdb->prepare( 928 "SELECT slug 929 FROM {$prefix}terms AS t 930 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 931 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 932 WHERE tt.taxonomy = 'plugin_support_reps' AND tr.object_id = %d", 933 $plugin->ID 934 ) ); 935 936 wp_cache_set( $cache_key, $support_reps, $cache_group, HOUR_IN_SECONDS ); 937 } 938 return $support_reps; 939 } 904 940 } -
wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-plugin-directory-compat.php
78 78 $this->plugin = $plugin; 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 } 83 84 -
wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-stickies-compat.php
12 12 var $object = null; 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; 18 18 } … … 24 24 $this->term = $term; 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. 29 30 add_filter( 'bbp_get_super_stickies', array( $this, 'get_super_stickies' ) ); … … 247 248 if ( $this->contributors && in_array( $user->user_nicename, $this->contributors ) ) { 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; 252 258 } -
wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-theme-directory-compat.php
78 78 $this->theme = $theme; 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 } 83 84 -
wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-badges/inc/class-plugin.php
198 198 $contrib_type = 'author'; 199 199 } elseif ( $this->is_user_contributor( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 200 200 $contrib_type = 'contributor'; 201 } elseif ( $this->is_user_support_rep( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 202 $contrib_type = 'support-rep'; 201 203 } else { 202 204 $contrib_type = ''; 203 205 } … … 312 314 $help = __( 'This person is a contributor to this theme', 'wporg-forums' ); 313 315 } 314 316 } 317 elseif ( $this->is_user_support_rep( $info['user_nicename'], $info['type'], $info['slug'] ) ) { 318 if ( 'plugin' == $info['type'] ) { 319 $label = __( 'Plugin Support', 'wporg-forums' ); 320 $help = __( 'This person is a support representative for this plugin', 'wporg-forums' ); 321 } else { 322 $label = __( 'Theme Support', 'wporg-forums' ); 323 $help = __( 'This person is a support representative for this theme', 'wporg-forums' ); 324 } 325 } 315 326 316 327 return $label ? array( 'type' => $info['type'], 'label' => $label, 'help' => $help ) : false; 317 328 } … … 390 401 } 391 402 392 403 /** 404 * Checks if the specified user is a support rep for the specified plugin/theme. 405 * 406 * A support representative is someone assigned as such by the plugin or theme author. 407 * 408 * @param string $user_nicename User slug. 409 * @param string $type Either 'plugin' or 'theme'. 410 * @param string $slug Slug for the plugin or theme. 411 * @return bool True if user is a support rep, false otherwise. 412 */ 413 public function is_user_support_rep( $user_nicename, $type, $slug ) { 414 if ( class_exists( '\WordPressdotorg\Forums\Plugin' ) ) { 415 if ( 'plugin' === $type ) { 416 $compat = \WordPressdotorg\Forums\Plugin::get_instance()->plugins; 417 } else { 418 $compat = \WordPressdotorg\Forums\Plugin::get_instance()->themes; 419 } 420 } else { 421 $compat = null; 422 } 423 424 $support_reps = $compat ? $compat->get_support_reps( $slug ) : array(); 425 426 return $support_reps && in_array( $user_nicename, $support_reps ); 427 } 428 429 /** 393 430 * Checks if the specified user is a forum moderator or keymaster. 394 431 * 395 432 * By default, this considers a keymaster as being a moderator for the purpose -
wordpress.org/public_html/wp-content/themes/pub/wporg-support/sass/elements/_badges.scss
6 6 box-shadow: -4px 0 0 white, -6px 0 0 $color__moderator; 7 7 } 8 8 .by-plugin-author, 9 .by-plugin-contributor { 9 .by-plugin-contributor, 10 .by-plugin-support-rep { 10 11 box-shadow: -4px 0 0 white, -6px 0 0 $color__plugin-author; 11 12 } 12 13 13 14 .by-theme-author, 14 .by-theme-contributor { 15 .by-theme-contributor, 16 .by-theme-support-rep { 15 17 box-shadow: -4px 0 0 white, -6px 0 0 $color__theme-author; 16 18 } 17 19