Making WordPress.org

Ticket #2710: 2710.patch

File 2710.patch, 4.2 KB (added by SergeyBiryukov, 8 years ago)
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/support-forums/inc/class-directory-compat.php

     
    837837                if ( ! $authors ) {
    838838
    839839                        if ( $this->compat() == 'theme' ) {
    840                                 $theme = $this->theme;
    841                                 $author = get_user_by( 'id', $this->theme->post_author );
     840                                $theme = $this->get_object( $slug );
     841                                $author = get_user_by( 'id', $theme->post_author );
    842842                                $authors = array( $author->user_nicename );
    843843                        } else {
     844                                $plugin = $this->get_object( $slug );
    844845                                $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
    845846                                // Note: Intentionally not considering posts of 'plugin' post_type with
    846847                                // 'post_author' matching this author because the field only relates to
     
    852853                                         LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
    853854                                         LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
    854855                                         WHERE tt.taxonomy = 'plugin_committers' AND tr.object_id = %d",
    855                                          $this->plugin->ID
     856                                         $plugin->ID
    856857                                ) );
    857858                        }
    858859
     
    879880                $cache_group = $this->compat() . '-contributors-slugs';
    880881                $contributors = wp_cache_get( $cache_key, $cache_group );
    881882                if ( ! $contributors ) {
     883                        $plugin = $this->get_object( $slug );
    882884                        $prefix = $wpdb->base_prefix . WPORG_PLUGIN_DIRECTORY_BLOGID . '_';
    883885                        $contributors = $wpdb->get_col( $wpdb->prepare(
    884886                                "SELECT slug
     
    886888                                 LEFT JOIN {$prefix}term_taxonomy AS tt ON tt.term_id = t.term_id
    887889                                 LEFT JOIN {$prefix}term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id
    888890                                 WHERE tt.taxonomy = 'plugin_contributors' AND tr.object_id = %d",
    889                                  $this->plugin->ID
     891                                 $plugin->ID
    890892                        ) );
    891893
    892894                        wp_cache_set( $cache_key, $contributors, $cache_group, HOUR_IN_SECONDS );
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/wporg-bbp-user-badges/inc/class-plugin.php

     
    347347         * @return bool                 True if user is an author, false otherwise.
    348348         */
    349349        public function is_user_author( $user_nicename, $type, $slug ) {
    350                 if ( 'plugin' === $type ) {
    351                         $compat = class_exists( '\WordPressdotorg\Forums\Plugin' ) ? \WordPressdotorg\Forums\Plugin::get_instance()->plugins : '';
     350                if ( class_exists( '\WordPressdotorg\Forums\Plugin' ) ) {
     351                        if ( 'plugin' === $type ) {
     352                                $compat = \WordPressdotorg\Forums\Plugin::get_instance()->plugins;
     353                        } else {
     354                                $compat = \WordPressdotorg\Forums\Plugin::get_instance()->themes;
     355                        }
    352356                } else {
    353                         $compat = class_exists( '\WordPressdotorg\Forums\Theme' ) ? \WordPressdotorg\Forums\Theme::get_instance()->themes : '';
     357                        $compat = null;
    354358                }
     359
    355360                $authors = $compat ? $compat->get_authors( $slug ) : array();
    356361
    357362                return $authors && in_array( $user_nicename, $authors );
     
    369374         * @return bool                 True if user is a contributor, false otherwise.
    370375         */
    371376        public function is_user_contributor( $user_nicename, $type, $slug ) {
    372                 if ( 'plugin' === $type ) {
    373                         $compat = class_exists( '\WordPressdotorg\Forums\Plugin' ) ? \WordPressdotorg\Forums\Plugin::get_instance()->plugins : '';
     377                if ( class_exists( '\WordPressdotorg\Forums\Plugin' ) ) {
     378                        if ( 'plugin' === $type ) {
     379                                $compat = \WordPressdotorg\Forums\Plugin::get_instance()->plugins;
     380                        } else {
     381                                $compat = \WordPressdotorg\Forums\Plugin::get_instance()->themes;
     382                        }
    374383                } else {
    375                         $compat = class_exists( '\WordPressdotorg\Forums\Theme' ) ? \WordPressdotorg\Forums\Theme::get_instance()->themes : '';
     384                        $compat = null;
    376385                }
     386
    377387                $contributors = $compat ? $compat->get_contributors( $slug ) : array();
    378388
    379389                return $contributors && in_array( $user_nicename, $contributors );