X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/607b7e02d77e7326161e8ec15639052d2040f745..16e7b37c7914d753890c1a05a9335f3b43751eb8:/wp-admin/includes/theme.php
diff --git a/wp-admin/includes/theme.php b/wp-admin/includes/theme.php
index 73567e1f..822fb5b6 100644
--- a/wp-admin/includes/theme.php
+++ b/wp-admin/includes/theme.php
@@ -102,12 +102,14 @@ function delete_theme($stylesheet, $redirect = '') {
* Get the Page Templates available in this theme
*
* @since 1.5.0
+ * @since 4.7.0 Added the `$post_type` parameter.
*
- * @param WP_Post|null $post Optional. The post being edited, provided for context.
+ * @param WP_Post|null $post Optional. The post being edited, provided for context.
+ * @param string $post_type Optional. Post type to get the templates for. Default 'page'.
* @return array Key is the template name, value is the filename of the template
*/
-function get_page_templates( $post = null ) {
- return array_flip( wp_get_theme()->get_page_templates( $post ) );
+function get_page_templates( $post = null, $post_type = 'page' ) {
+ return array_flip( wp_get_theme()->get_page_templates( $post, $post_type ) );
}
/**
@@ -360,9 +362,9 @@ function get_theme_feature_list( $api = true ) {
* @param string $action API action to perform: 'query_themes', 'theme_information',
* 'hot_tags' or 'feature_list'.
* @param array|object $args {
- * Optional. Array or object of arguments to serialize for the Plugin Info API.
+ * Optional. Array or object of arguments to serialize for the Themes API.
*
- * @type string $slug The plugin slug. Default empty.
+ * @type string $slug The theme slug. Default empty.
* @type int $per_page Number of themes per page. Default 24.
* @type int $page Number of current page. Default 1.
* @type int $number Number of tags to be queried.
@@ -412,7 +414,7 @@ function themes_api( $action, $args = array() ) {
}
if ( ! isset( $args->locale ) ) {
- $args->locale = get_locale();
+ $args->locale = get_user_locale();
}
/**
@@ -459,18 +461,40 @@ function themes_api( $action, $args = array() ) {
$request = wp_remote_post( $url, $http_args );
if ( $ssl && is_wp_error( $request ) ) {
- if ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) {
- trigger_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 support forums.' ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ), headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE );
+ if ( ! wp_doing_ajax() ) {
+ trigger_error(
+ sprintf(
+ /* translators: %s: support forums URL */
+ __( '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 support forums.' ),
+ __( 'https://wordpress.org/support/' )
+ ) . ' ' . __( '(WordPress could not establish a secure connection to WordPress.org. Please contact your server administrator.)' ),
+ headers_sent() || WP_DEBUG ? E_USER_WARNING : E_USER_NOTICE
+ );
}
$request = wp_remote_post( $http_url, $http_args );
}
if ( is_wp_error($request) ) {
- $res = new WP_Error('themes_api_failed', __( '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 support forums.' ), $request->get_error_message() );
+ $res = new WP_Error( 'themes_api_failed',
+ sprintf(
+ /* translators: %s: support forums URL */
+ __( '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 support forums.' ),
+ __( 'https://wordpress.org/support/' )
+ ),
+ $request->get_error_message()
+ );
} else {
$res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
- if ( ! is_object( $res ) && ! is_array( $res ) )
- $res = new WP_Error('themes_api_failed', __( '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 support forums.' ), wp_remote_retrieve_body( $request ) );
+ if ( ! is_object( $res ) && ! is_array( $res ) ) {
+ $res = new WP_Error( 'themes_api_failed',
+ sprintf(
+ /* translators: %s: support forums URL */
+ __( '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 support forums.' ),
+ __( 'https://wordpress.org/support/' )
+ ),
+ wp_remote_retrieve_body( $request )
+ );
+ }
}
}
@@ -572,6 +596,7 @@ function wp_prepare_themes_for_js( $themes = null ) {
'parent' => $parent,
'active' => $slug === $current_theme,
'hasUpdate' => isset( $updates[ $slug ] ),
+ 'hasPackage' => isset( $updates[ $slug ] ) && ! empty( $updates[ $slug ][ 'package' ] ),
'update' => get_theme_update_available( $theme ),
'actions' => array(
'activate' => current_user_can( 'switch_themes' ) ? wp_nonce_url( admin_url( 'themes.php?action=activate&stylesheet=' . $encoded_slug ), 'switch-theme_' . $slug ) : null,