* 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 ) );
}
/**
* @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.
}
if ( ! isset( $args->locale ) ) {
- $args->locale = get_locale();
+ $args->locale = get_user_locale();
}
/**
$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 <a href="https://wordpress.org/support/">support forums</a>.' ) . ' ' . __( '(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 <a href="%s">support forums</a>.' ),
+ __( '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 <a href="https://wordpress.org/support/">support forums</a>.' ), $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 <a href="%s">support forums</a>.' ),
+ __( '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 <a href="https://wordpress.org/support/">support forums</a>.' ), 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 <a href="%s">support forums</a>.' ),
+ __( 'https://wordpress.org/support/' )
+ ),
+ wp_remote_retrieve_body( $request )
+ );
+ }
}
}
'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,