Making WordPress.org

Changeset 2680


Ignore:
Timestamp:
03/03/2016 07:04:56 PM (11 years ago)
Author:
Otto42
Message:

Simplify oembed logic now that is correctly populated. Fix the post_type variable for theme queries

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php

    r2670 r2680  
    905905
    906906/**
    907  * Fix the query to allow embeds to work on single theme pages
    908  */
    909 function wporg_themes_embed_handler() {
    910         global $wp_query;
    911 
    912         $themes = wporg_themes_get_themes_for_query();
    913         if ( $themes['total'] == 1 ) {
    914                 $wp_query = new WP_Query( array(
    915                         'name' => get_query_var('name'),
    916                         'post_type' => 'repopackage',
    917                 ));
    918                 wp_reset_postdata();
    919         }
    920 }
    921 add_action( 'embed_head', 'wporg_themes_embed_handler' );
    922 add_action( 'wp_head', 'wporg_themes_embed_handler', 1 );
    923 
    924 /**
    925  * Fix the singular check to allow embed info to be added to head for single theme pages
    926  */
    927 function wporg_themes_singular_fix() {
    928         global $wp_query;
     907 * Correct the post type for theme queries to be "repopackage"
     908 */
     909function wporg_themes_adjust_main_query( $query ) {
    929910        if ( get_query_var('name') && !is_404() ) {
    930                 $wp_query->is_singular = true;
    931         }
    932 }
    933 add_action( 'template_redirect', 'wporg_themes_singular_fix', 20 );
     911                $query->query_vars['post_type'] = 'repopackage';
     912        }
     913}
     914add_action( 'pre_get_posts', 'wporg_themes_adjust_main_query');
    934915
    935916/**
Note: See TracChangeset for help on using the changeset viewer.