Making WordPress.org

Changeset 3962


Ignore:
Timestamp:
09/05/2016 06:49:00 PM (8 years ago)
Author:
jmdodd
Message:

Support Forums: Add star ratings display.

Adds filter by star ratings, and visual ratings in individual topic and plugin/theme reviews forums.

File:
1 edited

Legend:

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

    r3925 r3962  
    1717    abstract protected function do_view_header();
    1818
     19    var $loaded       = false;
    1920    var $authors      = null;
    2021    var $contributors = null;
     
    3334
    3435            // Check to see if an individual topic is compat.
    35             add_action( 'template_redirect', array( $this, 'check_topic_for_compat' ) );
     36            add_action( 'wp', array( $this, 'check_topic_for_compat' ) );
    3637
    3738            // Always check to see if a topic title needs a compat prefix.
     
    4849        add_filter( 'query_vars',            array( $this, 'add_query_var' ) );
    4950        add_action( 'bbp_add_rewrite_rules', array( $this, 'add_rewrite_rules' ) );
    50 
    51     }
    52 
     51    }
     52
     53    /**
     54     * At this point, compat, slug, and object should be loaded.
     55     */
    5356    public function maybe_load() {
    54         if ( false !== $this->slug() ) {
     57        if ( false !== $this->slug() && false == $this->loaded ) {
    5558            // This must run before bbPress's parse_query at priority 2.
    5659            $this->register_views();
     
    5861            // Add theme-specific filters and actions.
    5962            add_action( 'wporg_compat_view_sidebar', array( $this, 'do_view_sidebar' ) );
     63            add_action( 'wporg_compat_before_single_view', array( $this, 'do_view_header' ) );
    6064
    6165            // Add output filters and actions.
    6266            add_filter( 'bbp_get_view_link', array( $this, 'get_view_link' ), 10, 2 );
    6367            add_filter( 'bbp_breadcrumbs',   array( $this, 'breadcrumbs' ) );
    64 
    65             add_action( 'wporg_compat_before_single_view', array( $this, 'do_view_header' ) );
    6668
    6769            // Handle new topic form at the bottom of support view.
     
    6971            add_action( 'bbp_theme_before_topic_form_content', array( $this, 'add_topic_form_content' ) );
    7072            add_filter( 'bbp_current_user_can_access_create_topic_form', array( $this, 'current_user_can_access_create_topic_form' ) );
     73
     74            // Instantiate WPORG_Ratings compat mode for reviews.
     75            if ( class_exists( 'WPORG_Ratings' ) && class_exists( 'WordPressdotorg\Forums\Ratings_Compat' ) ) {
     76                $this->ratings = new Ratings_Compat( $this->compat(), $this->slug(), $this->get_object( $this->slug() ) );
     77            }
     78
     79            $this->loaded = true;
    7180        }
    7281    }
    7382
    7483    public function check_topic_for_compat() {
    75         if ( bbp_is_single_topic() ) {
     84        if ( ( bbp_is_single_topic() || bbp_is_topic_edit() ) && false == $this->loaded ) {
    7685            $terms = get_the_terms( bbp_get_topic_id(), $this->taxonomy() );
    7786            if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) {
     
    9099                }
    91100                add_action( 'wporg_compat_single_topic_sidebar_pre', array( $this, 'do_topic_sidebar' ) );
     101
     102                // Instantiate WPORG_Ratings compat mode for reviews.
     103                if ( class_exists( 'WPORG_Ratings' ) && class_exists( 'WordPressdotorg\Forums\Ratings_Compat' ) ) {
     104                    $this->ratings = new Ratings_Compat( $this->compat(), $this->slug(), $this->get_object( $this->slug() ) );
     105                }
     106
     107                $this->loaded = true;
    92108            }
    93109        }
     
    97113        if (
    98114            ( bbp_is_single_forum() && bbp_get_forum_id() == $this->forum_id() )
     115        ||
     116            ( bbp_is_single_forum() && Plugin::REVIEWS_FORUM_ID == bbp_get_forum_id() )
    99117        ||
    100118            ( bbp_is_single_view() && ! in_array( bbp_get_view_id(), array( 'plugin', 'theme', 'reviews', 'active' ) ) )
Note: See TracChangeset for help on using the changeset viewer.