Changeset 10349
- Timestamp:
- 10/06/2020 04:13:41 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php
r10344 r10349 887 887 888 888 // Check the cache. 889 $cache_key = $slug;889 $cache_key = $slug; 890 890 $cache_group = $this->compat() . '-authors-slugs'; 891 $authors = wp_cache_get( $cache_key, $cache_group );892 if ( ! $authors) {893 891 $authors = wp_cache_get( $cache_key, $cache_group ); 892 if ( $authors === false ) { 893 $authors = array(); 894 894 if ( $this->compat() == 'theme' ) { 895 895 $theme = $this->get_object( $slug ); 896 $author = get_user_by( 'id', $theme->post_author ); 897 $authors = array( $author->user_nicename ); 896 if ( $theme ) { 897 $author = get_user_by( 'id', $theme->post_author ); 898 if ( $author ) { 899 $authors = array( $author->user_nicename ); 900 } 901 } 898 902 } else { 899 903 $plugin = $this->get_object( $slug ); 900 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 901 // Note: Intentionally not considering posts of 'plugin' post_type with 902 // 'post_author' matching this author because the field only relates to 903 // the user who submitted the plugin. It does not confer special access, 904 // rights, or ownership. 905 $authors = $wpdb->get_col( $wpdb->prepare( 904 if ( $plugin ) { 905 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 906 // Note: Intentionally not considering posts of 'plugin' post_type with 907 // 'post_author' matching this author because the field only relates to 908 // the user who submitted the plugin. It does not confer special access, 909 // rights, or ownership. 910 $authors = $wpdb->get_col( $wpdb->prepare( 911 "SELECT slug 912 FROM {$prefix}terms AS t 913 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 914 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 915 WHERE tt.taxonomy = 'plugin_committers' AND tr.object_id = %d", 916 $plugin->ID 917 ) ); 918 } 919 } 920 921 wp_cache_set( $cache_key, $authors, $cache_group, HOUR_IN_SECONDS ); 922 } 923 return $authors; 924 } 925 926 public function get_contributors( $slug ) { 927 global $wpdb; 928 929 if ( null !== $this->contributors ) { 930 return $this->contributors; 931 } 932 933 // Themes do not have contributors right now. 934 if ( $this->compat() == 'theme' ) { 935 $contributors = array(); 936 return $contributors; 937 } 938 939 // Check the cache. 940 $cache_key = $slug; 941 $cache_group = $this->compat() . '-contributors-slugs'; 942 $contributors = wp_cache_get( $cache_key, $cache_group ); 943 if ( $contributors === false ) { 944 $contributors = array(); 945 $plugin = $this->get_object( $slug ); 946 947 if ( $plugin ) { 948 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 949 $contributors = $wpdb->get_col( $wpdb->prepare( 906 950 "SELECT slug 907 951 FROM {$prefix}terms AS t 908 952 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 909 953 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 910 WHERE tt.taxonomy = 'plugin_co mmitters' AND tr.object_id = %d",954 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d", 911 955 $plugin->ID 912 956 ) ); 913 957 } 914 958 915 wp_cache_set( $cache_key, $authors, $cache_group, HOUR_IN_SECONDS );916 }917 return $authors;918 }919 920 public function get_contributors( $slug ) {921 global $wpdb;922 923 if ( null !== $this->contributors ) {924 return $this->contributors;925 }926 927 // Themes do not have contributors right now.928 if ( $this->compat() == 'theme' ) {929 $contributors = array();930 return $contributors;931 }932 933 // Check the cache.934 $cache_key = $slug;935 $cache_group = $this->compat() . '-contributors-slugs';936 $contributors = wp_cache_get( $cache_key, $cache_group );937 if ( ! $contributors ) {938 $plugin = $this->get_object( $slug );939 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';940 $contributors = $wpdb->get_col( $wpdb->prepare(941 "SELECT slug942 FROM {$prefix}terms AS t943 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id944 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id945 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d",946 $plugin->ID947 ) );948 949 959 wp_cache_set( $cache_key, $contributors, $cache_group, HOUR_IN_SECONDS ); 950 960 } 961 951 962 return $contributors; 952 963 } … … 966 977 967 978 // Check the cache. 968 $cache_key = $slug;969 $cache_group = $this->compat() . '-support-reps-slugs';979 $cache_key = $slug; 980 $cache_group = $this->compat() . '-support-reps-slugs'; 970 981 $support_reps = wp_cache_get( $cache_key, $cache_group ); 971 if ( ! $support_reps ) { 972 $plugin = $this->get_object( $slug ); 973 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 974 $support_reps = $wpdb->get_col( $wpdb->prepare( 975 "SELECT slug 976 FROM {$prefix}terms AS t 977 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 978 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 979 WHERE tt.taxonomy = 'plugin_support_reps' AND tr.object_id = %d", 980 $plugin->ID 981 ) ); 982 if ( $support_reps === false ) { 983 $support_reps = array(); 984 $plugin = $this->get_object( $slug ); 985 986 if ( $plugin ) { 987 $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_'; 988 $support_reps = $wpdb->get_col( $wpdb->prepare( 989 "SELECT slug 990 FROM {$prefix}terms AS t 991 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id 992 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id 993 WHERE tt.taxonomy = 'plugin_support_reps' AND tr.object_id = %d", 994 $plugin->ID 995 ) ); 996 } 982 997 983 998 wp_cache_set( $cache_key, $support_reps, $cache_group, HOUR_IN_SECONDS ); 984 999 } 1000 985 1001 return $support_reps; 986 1002 }
Note: See TracChangeset
for help on using the changeset viewer.