Making WordPress.org

Changeset 2716


Ignore:
Timestamp:
03/08/2016 10:11:58 PM (9 years ago)
Author:
Otto42
Message:

Themes Directory: Eliminate the wporg_themes_embed_request_post_id function by making the post type public so it can be queried properly.

File:
1 edited

Legend:

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

    r2696 r2716  
    114114            'supports'    => array( 'title', 'editor', 'author', 'custom-fields', 'page-attributes' ),
    115115            'taxonomies'  => array( 'category', 'post_tag', 'type' ),
    116             'public'      => false,
     116            'public'      => true,
    117117            'show_ui'     => true,
    118118            'has_archive' => true,
     
    905905
    906906/**
    907  * Correct the post type for theme queries to be "repopackage".
     907 * Correct the post type for theme queries to be "repopackage". This fixes the post type for embeds.
    908908 */
    909909function wporg_themes_adjust_main_query( $query ) {
     
    914914add_action( 'pre_get_posts', 'wporg_themes_adjust_main_query');
    915915
    916 /**
    917  * Fix the oembed post finder to find the theme post id from the url properly
    918  */
    919 function wporg_themes_embed_request_post_id( $post_id, $url ) {
    920     if ( preg_match('|https://wordpress\.org/themes/(.*)/|', $url, $matches) ){
    921         $name = $matches[1];
    922         $query = new WP_Query( array(
    923             'name' => $name,
    924             'post_type' => 'repopackage',
    925             'fields' => 'ids',
    926         ));
    927         if ( $query->posts ) {
    928             $post_id = $query->posts[0];
    929         }
    930     }
    931     return $post_id;
    932 }
    933 add_filter( 'oembed_request_post_id', 'wporg_themes_embed_request_post_id', 10, 2 );
    934 
    935 
     916
Note: See TracChangeset for help on using the changeset viewer.