Changeset 1001 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
- Timestamp:
- 11/21/2014 10:04:40 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-themes/functions.php
r887 r1001 1 1 <?php 2 /** 3 * WP.org Themes' functions and definitions. 4 * 5 * @package wporg-themes 6 */ 7 8 /** 9 * Sets up theme defaults and registers support for various WordPress features. 10 * 11 * Note that this function is hooked into the after_setup_theme hook, which 12 * runs before the init hook. The init hook is too late for some features, such 13 * as indicating support for post thumbnails. 14 */ 15 2 16 function wporg_themes_setup() { 3 17 // load_theme_textdomain( 'wporg-themes', get_template_directory() . '/languages' ); … … 15 29 add_action( 'after_setup_theme', 'wporg_themes_setup' ); 16 30 17 function wporg_themes_style() { 18 //<link rel="stylesheet" href="http://localhost/repotest/wp-admin/css/themes.css" /> 31 /** 32 * Enqueue scripts and styles. 33 */ 34 function wporg_themes_scripts() { 35 36 wp_enqueue_style( 'global-style', '//s.w.org/style/wp4.css', array(), '14' ); 37 wp_enqueue_style( 'themes-style', self_admin_url( 'css/themes.css' ) ); 19 38 wp_enqueue_style( 'wporg-themes-style', get_stylesheet_uri() ); 39 40 wp_enqueue_script( 'theme', self_admin_url( 'js/theme.js' ), array( 'wp-backbone' ), false, 1 ); 41 wp_enqueue_script( 'wporg-theme', get_template_directory_uri() . '/js/theme.js', array( 'theme' ), false, 1 ); 42 43 wp_localize_script( 'theme', '_wpThemeSettings', array( 44 'themes' => false, 45 'settings' => array( 46 'isInstall' => true, 47 'canInstall' => false, 48 'installURI' => null, 49 'adminUrl' => '', 50 ), 51 'l10n' => array( 52 'addNew' => __( 'Add New Theme' ), 53 'search' => __( 'Search Themes' ), 54 'searchPlaceholder' => __( 'Search themes...' ), // placeholder (no ellipsis) 55 'upload' => __( 'Upload Theme' ), 56 'back' => __( 'Back' ), 57 'error' => __( 'An unexpected error occurred. Something may be wrong with WordPress.org or this server’s configuration. If you continue to have problems, please try the <a href="https://wordpress.org/support/">support forums</a>.' ) 58 ), 59 'installedThemes' => array(), 60 ) ); 20 61 } 21 add_action( 'wp_enqueue_scripts', 'wporg_themes_s tyle' );62 add_action( 'wp_enqueue_scripts', 'wporg_themes_scripts' ); 22 63 23 // force the post type to the repopackages 24 // TODO smarter 25 function wporg_themes_pregetposts( &$q ) { 26 $q->set('post_type', 'repopackage'); 64 /** 65 * Removes Core's built-in query-themes handler, so we can safely add ours later on. 66 */ 67 function wporg_themes_remove_ajax_action() { 68 remove_action( 'wp_ajax_query-themes', 'wp_ajax_query_themes', 1 ); 27 69 } 28 add_action( 'pre_get_posts', 'wporg_themes_pregetposts' ); 70 add_action( 'wp_ajax_query-themes', 'wporg_themes_remove_ajax_action', -1 ); 71 72 /** 73 * A recreation of Core's implementation without capability check, since there is nothing to install. 74 */ 75 function wporg_themes_query_themes() { 76 global $themes_allowedtags, $theme_field_defaults; 77 78 $args = wp_parse_args( wp_unslash( $_REQUEST['request'] ), array( 79 'per_page' => 20, 80 'fields' => $theme_field_defaults, 81 ) ); 82 83 $old_filter = isset( $args['browse'] ) ? $args['browse'] : 'search'; 84 85 /** This filter is documented in wp-admin/includes/class-wp-theme-install-list-table.php */ 86 $args = apply_filters( 'install_themes_table_api_args_' . $old_filter, $args ); 87 88 $api = themes_api( 'query_themes', $args ); 89 90 if ( is_wp_error( $api ) ) { 91 wp_send_json_error(); 92 } 93 94 foreach ( $api->themes as &$theme ) { 95 $theme->name = wp_kses( $theme->name, $themes_allowedtags ); 96 $theme->author = wp_kses( $theme->author, $themes_allowedtags ); 97 $theme->version = wp_kses( $theme->version, $themes_allowedtags ); 98 $theme->description = wp_kses( $theme->description, $themes_allowedtags ); 99 $theme->num_ratings = sprintf( _n( '(based on %s rating)', '(based on %s ratings)', $theme->num_ratings ), number_format_i18n( $theme->num_ratings ) ); 100 $theme->preview_url = set_url_scheme( $theme->preview_url ); 101 } 102 103 wp_send_json_success( $api ); 104 } 105 add_action( 'wp_ajax_query-themes', 'wporg_themes_query_themes' ); 106 add_action( 'wp_ajax_nopriv_query-themes', 'wporg_themes_query_themes' ); 107 108 /** 109 * Include view templates in the footer. 110 */ 111 function wporg_themes_view_templates() { 112 get_template_part( 'view-templates/theme' ); 113 get_template_part( 'view-templates/theme-preview' ); 114 get_template_part( 'view-templates/theme-single' ); 115 } 116 add_action( 'wp_footer', 'wporg_themes_view_templates' );
Note: See TracChangeset
for help on using the changeset viewer.