Making WordPress.org


Ignore:
Timestamp:
04/10/2019 05:20:19 AM (6 years ago)
Author:
dd32
Message:

Support Forums: Create the plugin/theme term Just-in-time earlier in the page load to avoid the first-ever pageview for a plugin/theme support forum showing irrelevant topics.

This change also only creates terms for valid objects of that type, previously it was possible to create terms for objects that didn't yet exist.

Fixes #4342.

File:
1 edited

Legend:

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

    r8617 r8620  
    290290            $this->term = get_term_by( 'slug', $this->slug(), $this->taxonomy() );
    291291
     292            // New compats won't have any support topics or reviews, so will
     293            // not yet exist as a compat term.
     294            if ( ! $this->term && $this->get_object( $this->slug() ) ) {
     295                $term = wp_insert_term( $this->slug(), $this->taxonomy() );
     296                $this->term = get_term( $term['term_id'] );
     297            }
     298
    292299            // Add plugin- and theme-specific filters and actions.
    293300            add_action( 'wporg_compat_view_sidebar',       array( $this, 'do_view_sidebar' ) );
     
    742749
    743750        $term_subscription = '';
    744         $term = $this->term;
    745         if ( ! $term ) {
     751        if ( ! $this->term && $this->get_object( $this->slug() ) ) {
    746752            // New compats won't have any support topics or reviews, so will
    747753            // not yet exist as a compat term.
    748754            $term = wp_insert_term( $this->slug(), $this->taxonomy() );
    749             $term = get_term( $term['term_id'] );
    750         }
    751         if ( $term ) {
    752             $this->term = $term;
     755            $this->term = get_term( $term['term_id'] );
     756        }
     757        if ( $this->term ) {
    753758            $subscribe = $unsubscribe = '';
    754759            if ( 'plugin' == $this->compat() ) {
     
    760765            }
    761766            $term_subscription = Term_Subscription\Plugin::get_subscription_link( array(
    762                 'term_id'     => $term->term_id,
     767                'term_id'     => $this->term->term_id,
    763768                'taxonomy'    => $this->taxonomy(),
    764769                'subscribe'   => $subscribe,
Note: See TracChangeset for help on using the changeset viewer.