Changeset 2189
- Timestamp:
- 12/13/2015 03:44:12 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r2094 r2189 893 893 } 894 894 add_action( 'admin_init', 'wporg_themes_maybe_schedule_daily_job' ); 895 896 /** 897 * Fix the query to allow embeds to work on single theme pages 898 */ 899 function wporg_themes_embed_handler() { 900 global $wp_query; 901 902 $themes = wporg_themes_get_themes_for_query(); 903 if ( $themes['total'] == 1 ) { 904 $wp_query = new WP_Query( array( 905 'name' => get_query_var('name'), 906 'post_type' => 'repopackage', 907 )); 908 wp_reset_postdata(); 909 } 910 } 911 add_action( 'embed_head', 'wporg_themes_embed_handler' ); 912 add_action( 'wp_head', 'wporg_themes_embed_handler', 1 ); 913 914 /** 915 * Fix the singular check to allow embed info to be added to head for single theme pages 916 */ 917 function wporg_themes_singular_fix() { 918 global $wp_query; 919 if ( get_query_var('name') && !is_404() ) { 920 $wp_query->is_singular = true; 921 } 922 } 923 add_action( 'template_redirect', 'wporg_themes_singular_fix', 20 ); 924 925 /** 926 * Fix the oembed post finder to find the theme post id from the url properly 927 */ 928 function wporg_themes_embed_request_post_id( $post_id, $url ) { 929 if ( preg_match('|https://wordpress\.org/themes/(.*)/|', $url, $matches) ){ 930 $name = $matches[1]; 931 $query = new WP_Query( array( 932 'name' => $name, 933 'post_type' => 'repopackage', 934 'fields' => 'ids', 935 )); 936 if ( $query->posts ) { 937 $post_id = $query->posts[0]; 938 } 939 } 940 return $post_id; 941 } 942 add_filter( 'oembed_request_post_id', 'wporg_themes_embed_request_post_id', 10, 2 ); 943 944
Note: See TracChangeset
for help on using the changeset viewer.