Changeset 2755
- Timestamp:
- 03/17/2016 05:39:02 AM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
r2738 r2755 1 1 <?php 2 2 /* 3 Plugin Name: Theme Repository4 Plugin URI: 5 Description: Transforms a WordPress site in The Official Theme Directory.6 Version: 0.1 7 Author: wordpressdotorg8 Author URI: http://wordpress.org/9 Text Domain: wporg-themes10 License: GPLv211 License URI: http://opensource.org/licenses/gpl-2.0.php12 */3 * Plugin Name: Theme Repository 4 * Plugin URI: https://wordpress.org/themes/ 5 * Description: Transforms a WordPress site in The Official Theme Directory. 6 * Version: 1.0 7 * Author: wordpressdotorg 8 * Author URI: http://wordpress.org/ 9 * Text Domain: wporg-themes 10 * License: GPLv2 11 * License URI: http://opensource.org/licenses/gpl-2.0.php 12 */ 13 13 14 14 // Load base repo package. 15 include _once plugin_dir_path( __FILE__ ) . 'class-repo-package.php';15 include __DIR__ . '/class-repo-package.php'; 16 16 17 17 // Load theme repo package. 18 include _once plugin_dir_path( __FILE__ ) . 'class-wporg-themes-repo-package.php';18 include __DIR__ . '/class-wporg-themes-repo-package.php'; 19 19 20 20 // Load uploader. 21 include _once plugin_dir_path( __FILE__ ) . 'upload.php';21 include __DIR__ . '/upload.php'; 22 22 23 23 // Load Themes API adjustments. 24 include _once plugin_dir_path( __FILE__ ) . 'themes-api.php';24 include __DIR__ . '/themes-api.php'; 25 25 26 26 // Load adjustments to the edit.php screen for repopackage posts. 27 include_once plugin_dir_path( __FILE__ ) . 'admin-edit.php'; 27 include __DIR__ . '/admin-edit.php'; 28 29 // Load the query modifications needed for the directory. 30 include __DIR__ . '/query-modifications.php'; 28 31 29 32 /** … … 148 151 149 152 // Add the browse/* views 150 add_rewrite_tag( '%browse%', '(featured|popular|new| favorites)' );153 add_rewrite_tag( '%browse%', '(featured|popular|new|updated|favorites)' ); 151 154 add_permastruct( 'browse', 'browse/%browse%' ); 155 add_rewrite_tag( '%favorites_user%', '([^/]+)' ); 156 //add_permastruct( 'favorites_user', 'browse/favorites/%favorites_user%' ); // TODO: Implment in JS before enabling 152 157 153 158 if ( ! defined( 'WPORG_THEME_DIRECTORY_BLOGID' ) ) { … … 744 749 } 745 750 751 function wporg_themes_theme_information( $slug ) { 752 return wporg_themes_query_api( 'theme_information', array( 753 'slug' => $slug, 754 'fields' => array( 755 'description' => true, 756 'sections' => false, 757 'tested' => true, 758 'requires' => true, 759 'downloaded' => false, 760 'downloadlink' => true, 761 'last_updated' => true, 762 'homepage' => true, 763 'theme_url' => true, 764 'parent' => true, 765 'tags' => true, 766 'rating' => true, 767 'ratings' => true, 768 'num_ratings' => true, 769 'extended_author' => true, 770 'photon_screenshots' => true, 771 'active_installs' => true, 772 ) 773 ) ); 774 } 775 746 776 /** 747 777 * Makes a query against api.wordpress.org/themes/info/1.0/ without making a HTTP call … … 751 781 include_once API_WPORGPATH . 'themes/info/1.0/class-themes-api.php'; 752 782 753 switch_to_blog( WPORG_THEME_DIRECTORY_BLOGID );754 783 $api = new Themes_API( $method, $args ); 755 restore_current_blog();756 784 757 785 return $api->response; … … 966 994 967 995 /** 968 * Correct the post type for theme queries to be "repopackage". This fixes the post type for embeds. 969 */ 970 function wporg_themes_adjust_main_query( $query ) { 971 if ( $query->is_main_query() && $query->get( 'name' ) && ! $query->is_404() ) { 972 $query->query_vars['post_type'] = 'repopackage'; 973 } 974 } 975 add_action( 'pre_get_posts', 'wporg_themes_adjust_main_query'); 976 977 996 * Filter the URLs to use the current localized domain name, rather than WordPress.org. 997 * 998 * The Theme Directory is available at multiple URLs (internationalised domains), this method allows 999 * for the one blog (a single blog_id) to be presented at multiple URLs yet have correct localised links. 1000 * 1001 * This method works in conjunction with a filter in sunrise.php, duplicated here for transparency: 1002 * 1003 * // Make the Plugin Directory available at /plugins/ on all rosetta sites. 1004 * function wporg_themes_on_rosetta_domains( $site, $domain, $path, $segments ) { 1005 * // All non-rosetta networks define DOMAIN_CURRENT_SITE in wp-config.php 1006 * if ( ! defined( 'DOMAIN_CURRENT_SITE' ) && 'wordpress.org' != $domain && '/themes/' == substr( $path . '/', 0, 8 ) ) { 1007 * $site = get_blog_details( WPORG_THEME_DIRECTORY_BLOGID ); 1008 * if ( $site ) { 1009 * $site = clone $site; 1010 * // 6 = The Rosetta network, this causes the site to be loaded as part of the Rosetta network 1011 * $site->site_id = 6; 1012 * return $site; 1013 * } 1014 * } 1015 * 1016 * return $site; 1017 * } 1018 * add_filter( 'pre_get_site_by_path', 'wporg_themes_on_rosetta_domains', 10, 4 ); 1019 * 1020 * @param string $url The URL to be localized. 1021 * @return string 1022 */ 1023 function wporg_themes_rosetta_network_localize_url( $url ) { 1024 static $localized_url = null; 1025 1026 if ( get_current_blog_id() != WPORG_THEME_DIRECTORY_BLOGID ) { 1027 return $url; 1028 } 1029 1030 if ( is_null( $localized_url ) ) { 1031 $localized_url = 'https://' . preg_replace( '![^a-z.-]+!', '', $_SERVER['HTTP_HOST'] ); 1032 } 1033 1034 return preg_replace( '!^[https]+://wordpress\.org!i', $localized_url, $url ); 1035 } 1036 if ( 'wordpress.org' != $_SERVER['HTTP_HOST'] && defined( 'WPORG_THEME_DIRECTORY_BLOGID' ) ) { 1037 add_filter( 'option_home', 'wporg_themes_rosetta_network_localize_url' ); 1038 add_filter( 'option_siteurl', 'wporg_themes_rosetta_network_localize_url' ); 1039 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/upload.php
r1572 r2755 82 82 } 83 83 84 switch_to_blog( WPORG_THEME_DIRECTORY_BLOGID );85 86 84 $upload = new WPORG_Themes_Upload; 87 85 $message = $upload->process_upload(); 88 86 89 restore_current_blog();90 91 87 return $message; 92 88 } -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/embed.php
r2190 r2755 29 29 if ( have_posts() ) : 30 30 while ( have_posts() ) : the_post(); 31 32 // setup the theme variable 33 34 $themes = wporg_themes_get_themes_for_query(); 35 $theme = $themes['themes'][0]; 36 37 // note, $theme contains things like active installs and other data to be added eventually 31 // setup the theme variable 32 // note, $theme contains things like active installs and other data to be added eventually 33 $theme = wporg_themes_theme_information( $post->post_name ); 38 34 39 35 ?> … … 47 43 <p class="wp-embed-heading"> 48 44 <a href="<?php the_permalink(); ?>" target="_top"> 49 <?php the_title(); ?>45 <?php echo esc_html( $theme->name ); ?> 50 46 </a> 51 47 </p> 52 48 53 <div class="wp-embed-excerpt"><?php the_excerpt_embed(); ?></div>49 <div class="wp-embed-excerpt"><?php echo wp_trim_words( $theme->description, 55 ); ?></div> 54 50 55 51 <?php -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
r2681 r2755 127 127 } 128 128 add_filter( 'body_class', 'wporg_themes_body_class' ); 129 130 /**131 * Prevent 404 responses when we've got a theme via the API.132 */133 function wporg_themes_prevent_404() {134 global $wp_query;135 if ( ! is_404() ) {136 return;137 }138 $themes = wporg_themes_get_themes_for_query();139 if ( $themes['total'] ) {140 $wp_query->is_404 = false;141 status_header( 200 );142 }143 }144 add_filter( 'template_redirect', 'wporg_themes_prevent_404' );145 129 146 130 /** … … 252 236 return $template; 253 237 } 254 add_filter( 'embed_template', 'wporg_themes_embed_template');255 238 add_filter( 'embed_template', 'wporg_themes_embed_template' ); 239 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/header.php
r2459 r2755 6 6 */ 7 7 8 $GLOBALS['themes'] = wporg_themes_get_themes_for_query();9 8 $GLOBALS['pagetitle'] = __( 'Theme Directory — Free WordPress Themes', 'wporg-themes' ); 10 9 -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/index.php
r1813 r2755 12 12 */ 13 13 14 global $themes;15 16 14 get_header(); 17 15 ?> … … 19 17 <div class="wp-filter"> 20 18 <div class="filter-count"> 21 <span class="count theme-count"><?php echo number_format_i18n( $ themes['total']); ?></span>19 <span class="count theme-count"><?php echo number_format_i18n( $wp_query->found_posts ); ?></span> 22 20 </div> 23 21 … … 67 65 <?php 68 66 if ( get_query_var('name') && !is_404() ) { 69 $theme = reset( $themes['themes'] ); 70 include __DIR__ . '/theme-single.php'; 67 while ( have_posts() ) { 68 the_post(); 69 $theme = wporg_themes_theme_information( $post->post_name ); 70 include __DIR__ . '/theme-single.php'; 71 } 71 72 } else { 72 foreach ( $themes['themes'] as $theme ) { 73 while ( have_posts() ) { 74 the_post(); 75 $theme = wporg_themes_theme_information( $post->post_name ); 73 76 include __DIR__ . '/theme.php'; 74 77 } 75 78 76 79 // Add the navigation between pages 77 if ( $themes['pages'] > 1 ) { 78 echo '<nav class="posts-navigation">'; 79 echo paginate_links( array( 80 'total' => $themes['pages'], 81 'mid_size' => 3, 82 ) ); 83 echo '</nav>'; 84 } 80 echo '<nav class="posts-navigation">'; 81 echo paginate_links( array( 82 'mid_size' => 3, 83 ) ); 84 echo '</nav>'; 85 85 } 86 86 ?> 87 87 </div> 88 88 89 <?php /* TODO: Don't display this for no-js queries where $wp_query->post_count > 0, but JS needs it too. */ ?> 89 90 <p class="no-themes"><?php _e( 'No themes found. Try a different search.', 'wporg-themes' ); ?></p> 90 91 </div> -
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/rss.php
r1489 r2755 21 21 <?php 22 22 23 $themes = wporg_themes_get_themes_for_query(); 24 foreach ( $themes['themes'] as $theme ) : 23 while ( have_posts() ) : 24 the_post(); 25 $theme = wporg_themes_theme_information( $post->post_name ); 25 26 ?> 26 27 <item> … … 36 37 <content:encoded><![CDATA[<?php echo esc_html( $theme->description ); ?>]]></content:encoded> 37 38 </item> 38 <?php end foreach; ?>39 <?php endwhile; ?> 39 40 </channel> 40 41 </rss>
Note: See TracChangeset
for help on using the changeset viewer.