Making WordPress.org


Ignore:
Timestamp:
05/08/2023 02:46:30 AM (3 years ago)
Author:
dd32
Message:

Support Forums: Also Viewing: Change it to be privacy-by-default. This allows for only mods to see other mods, and for plugin support reps to see other support reps for the same plugins/themes.

See #6431.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

    r12531 r12574  
    10561056                return $support_reps;
    10571057        }
     1058
     1059        /**
     1060         * Get the plugin or theme object slugs for a given user.
     1061         *
     1062         * @param int $user_id The user id.
     1063         * @return array
     1064         */
     1065        public function get_user_object_slugs( $user_id ) {
     1066                global $wpdb;
     1067
     1068                // Check the cache.
     1069                $cache_key   = $user_id;
     1070                $cache_group = $this->compat() . '-user-object-slugs';
     1071                $slugs       = wp_cache_get( $cache_key, $cache_group );
     1072                if ( $slugs !== false ) {
     1073                        return $slugs;
     1074                }
     1075                $slugs = [];
     1076
     1077                // Themes.
     1078                if ( 'theme' == $this->compat() ) {
     1079                        $slugs = $wpdb->get_col( $wpdb->prepare(
     1080                                "SELECT post_name
     1081                                        FROM %i
     1082                                        WHERE post_type = 'repopackage' AND post_author = %d",
     1083                                $wpdb->base_prefix . WPORG_THEME_DIRECTORY_BLOGID . '_posts',
     1084                                $user_id
     1085                        ) );
     1086                }
     1087
     1088                // Plugins
     1089                if ( 'plugin' == $this->compat() ) {
     1090                        $slugs = $wpdb->get_col( $wpdb->prepare(
     1091                                "SELECT DISTINCT p.post_name
     1092                                        FROM %i AS t
     1093                                                LEFT JOIN %i AS tt ON tt.term_id = t.term_id
     1094                                                LEFT JOIN %i AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
     1095                                                LEFT JOIN %i AS p ON tr.object_id = p.ID
     1096                                        WHERE tt.taxonomy IN( 'plugin_contributors', 'plugin_support_reps', 'plugin_committers' ) AND t.name = %s",
     1097                                        $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_terms',
     1098                                        $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_term_taxonomy',
     1099                                        $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_term_relationships',
     1100                                        $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_posts',
     1101                                        get_user_by( 'id', $user_id )->user_nicename
     1102                        ) );
     1103                }
     1104
     1105                wp_cache_set( $cache_key, $slugs, $cache_group, HOUR_IN_SECONDS );
     1106
     1107                return $slugs;
     1108        }
    10581109}
Note: See TracChangeset for help on using the changeset viewer.