Changeset 2755 for sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/theme-directory.php
- Timestamp:
- 03/17/2016 05:39:02 AM (10 years ago)
- File:
-
- 1 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 }
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)