--- a/wp/wp-admin/includes/theme.php Thu Sep 29 08:06:27 2022 +0200
+++ b/wp/wp-admin/includes/theme.php Fri Sep 05 18:40:08 2025 +0200
@@ -66,7 +66,7 @@
return new WP_Error( 'fs_error', __( 'Filesystem error.' ), $wp_filesystem->errors );
}
- // Get the base plugin folder.
+ // Get the base theme folder.
$themes_dir = $wp_filesystem->wp_themes_dir();
if ( empty( $themes_dir ) ) {
return new WP_Error( 'fs_no_themes_dir', __( 'Unable to locate WordPress theme directory.' ) );
@@ -81,6 +81,8 @@
*/
do_action( 'delete_theme', $stylesheet );
+ $theme = wp_get_theme( $stylesheet );
+
$themes_dir = trailingslashit( $themes_dir );
$theme_dir = trailingslashit( $themes_dir . $stylesheet );
$deleted = $wp_filesystem->delete( $theme_dir, true );
@@ -112,6 +114,7 @@
foreach ( $translations as $translation => $data ) {
$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.po' );
$wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.mo' );
+ $wp_filesystem->delete( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '.l10n.php' );
$json_translation_files = glob( WP_LANG_DIR . '/themes/' . $stylesheet . '-' . $translation . '-*.json' );
if ( $json_translation_files ) {
@@ -125,6 +128,9 @@
WP_Theme::network_disable_theme( $stylesheet );
}
+ // Clear theme caches.
+ $theme->cache_delete();
+
// Force refresh of theme update information.
delete_site_transient( 'update_themes' );
@@ -156,7 +162,7 @@
* @return string
*/
function _get_template_edit_filename( $fullpath, $containingfolder ) {
- return str_replace( dirname( dirname( $containingfolder ) ), '', $fullpath );
+ return str_replace( dirname( $containingfolder, 2 ), '', $fullpath );
}
/**
@@ -299,6 +305,8 @@
* and 'Full Site Editing' features.
* @since 5.5.0 Added 'Wide Blocks' layout option.
* @since 5.8.1 Added 'Template Editing' feature.
+ * @since 6.1.1 Replaced 'Full Site Editing' feature name with 'Site Editor'.
+ * @since 6.2.0 Added 'Style Variations' feature.
*
* @param bool $api Optional. Whether try to fetch tags from the WordPress.org API. Defaults to true.
* @return array Array of features keyed by category with translations keyed by slug.
@@ -331,10 +339,11 @@
'featured-image-header' => __( 'Featured Image Header' ),
'featured-images' => __( 'Featured Images' ),
'footer-widgets' => __( 'Footer Widgets' ),
- 'full-site-editing' => __( 'Full Site Editing' ),
+ 'full-site-editing' => __( 'Site Editor' ),
'full-width-template' => __( 'Full Width Template' ),
'post-formats' => __( 'Post Formats' ),
'sticky-post' => __( 'Sticky Post' ),
+ 'style-variations' => __( 'Style Variations' ),
'template-editing' => __( 'Template Editing' ),
'theme-options' => __( 'Theme Options' ),
),
@@ -439,10 +448,10 @@
*
* @since 2.8.0
*
- * @param string $action API action to perform: 'query_themes', 'theme_information',
+ * @param string $action API action to perform: Accepts 'query_themes', 'theme_information',
* 'hot_tags' or 'feature_list'.
* @param array|object $args {
- * Optional. Array or object of arguments to serialize for the Themes API.
+ * Optional. Array or object of arguments to serialize for the Themes API. Default empty array.
*
* @type string $slug The theme slug. Default empty.
* @type int $per_page Number of themes per page. Default 24.
@@ -552,13 +561,15 @@
}
$http_args = array(
+ 'timeout' => 15,
'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
);
$request = wp_remote_get( $url, $http_args );
if ( $ssl && is_wp_error( $request ) ) {
if ( ! wp_doing_ajax() ) {
- trigger_error(
+ wp_trigger_error(
+ __FUNCTION__,
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>.' ),
@@ -707,16 +718,21 @@
$is_block_theme = $theme->is_block_theme();
if ( $is_block_theme && $can_edit_theme_options ) {
- $customize_action = esc_url( admin_url( 'site-editor.php' ) );
+ $customize_action = admin_url( 'site-editor.php' );
+ if ( $current_theme !== $slug ) {
+ $customize_action = add_query_arg( 'wp_theme_preview', $slug, $customize_action );
+ }
} elseif ( ! $is_block_theme && $can_customize && $can_edit_theme_options ) {
- $customize_action = esc_url(
- add_query_arg(
- array(
- 'return' => urlencode( esc_url_raw( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
- ),
- wp_customize_url( $slug )
- )
+ $customize_action = wp_customize_url( $slug );
+ }
+ if ( null !== $customize_action ) {
+ $customize_action = add_query_arg(
+ array(
+ 'return' => urlencode( sanitize_url( remove_query_arg( wp_removable_query_args(), wp_unslash( $_SERVER['REQUEST_URI'] ) ) ) ),
+ ),
+ $customize_action
);
+ $customize_action = esc_url( $customize_action );
}
$update_requires_wp = isset( $updates[ $slug ]['requires'] ) ? $updates[ $slug ]['requires'] : null;
@@ -816,9 +832,24 @@
<div class="theme-backdrop"></div>
<div class="theme-wrap wp-clearfix" role="document">
<div class="theme-header">
- <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
- <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
- <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
+ <button type="button" class="left dashicons dashicons-no"><span class="screen-reader-text">
+ <?php
+ /* translators: Hidden accessibility text. */
+ _e( 'Show previous theme' );
+ ?>
+ </span></button>
+ <button type="button" class="right dashicons dashicons-no"><span class="screen-reader-text">
+ <?php
+ /* translators: Hidden accessibility text. */
+ _e( 'Show next theme' );
+ ?>
+ </span></button>
+ <button type="button" class="close dashicons dashicons-no"><span class="screen-reader-text">
+ <?php
+ /* translators: Hidden accessibility text. */
+ _e( 'Close details dialog' );
+ ?>
+ </span></button>
</div>
<div class="theme-about wp-clearfix">
<div class="theme-screenshots">
@@ -855,7 +886,7 @@
'%1$s <span class="screen-reader-text">%2$s</span>',
/* translators: %s: Number of ratings. */
sprintf( __( '(%s ratings)' ), '{{ data.num_ratings }}' ),
- /* translators: Accessibility text. */
+ /* translators: Hidden accessibility text. */
__( '(opens in a new tab)' )
);
?>
@@ -1034,12 +1065,7 @@
<# if ( data.active ) { #>
<button type="button" class="button button-primary customize-theme"><?php _e( 'Customize' ); ?></button>
<# } else if ( 'installed' === data.type ) { #>
- <?php if ( current_user_can( 'delete_themes' ) ) { ?>
- <# if ( data.actions && data.actions['delete'] ) { #>
- <a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
- <# } #>
- <?php } ?>
-
+ <div class="theme-inactive-actions">
<# if ( data.blockTheme ) { #>
<?php
/* translators: %s: Theme name. */
@@ -1055,6 +1081,12 @@
<button class="button button-primary disabled"><?php _e( 'Live Preview' ); ?></button>
<# } #>
<# } #>
+ </div>
+ <?php if ( current_user_can( 'delete_themes' ) ) { ?>
+ <# if ( data.actions && data.actions['delete'] ) { #>
+ <a href="{{{ data.actions['delete'] }}}" data-slug="{{ data.id }}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
+ <# } #>
+ <?php } ?>
<# } else { #>
<# if ( data.compatibleWP && data.compatiblePHP ) { #>
<button type="button" class="button theme-install" data-slug="{{ data.id }}"><?php _e( 'Install' ); ?></button>
@@ -1080,6 +1112,8 @@
*
* @since 5.2.0
*
+ * @global WP_Paused_Extensions_Storage $_paused_themes
+ *
* @param string $theme Path to the theme directory relative to the themes directory.
* @return bool True, if in the list of paused themes. False, not in the list.
*/
@@ -1100,6 +1134,8 @@
*
* @since 5.2.0
*
+ * @global WP_Paused_Extensions_Storage $_paused_themes
+ *
* @param string $theme Path to the theme directory relative to the themes
* directory.
* @return array|false Array of error information as it was returned by
@@ -1129,12 +1165,17 @@
*
* @since 5.2.0
*
+ * @global string $wp_stylesheet_path Path to current theme's stylesheet directory.
+ * @global string $wp_template_path Path to current theme's template directory.
+ *
* @param string $theme Single theme to resume.
* @param string $redirect Optional. URL to redirect to. Default empty string.
* @return bool|WP_Error True on success, false if `$theme` was not paused,
* `WP_Error` on failure.
*/
function resume_theme( $theme, $redirect = '' ) {
+ global $wp_stylesheet_path, $wp_template_path;
+
list( $extension ) = explode( '/', $theme );
/*
@@ -1143,10 +1184,10 @@
*/
if ( ! empty( $redirect ) ) {
$functions_path = '';
- if ( strpos( STYLESHEETPATH, $extension ) ) {
- $functions_path = STYLESHEETPATH . '/functions.php';
- } elseif ( strpos( TEMPLATEPATH, $extension ) ) {
- $functions_path = TEMPLATEPATH . '/functions.php';
+ if ( str_contains( $wp_stylesheet_path, $extension ) ) {
+ $functions_path = $wp_stylesheet_path . '/functions.php';
+ } elseif ( str_contains( $wp_template_path, $extension ) ) {
+ $functions_path = $wp_template_path . '/functions.php';
}
if ( ! empty( $functions_path ) ) {
@@ -1185,7 +1226,8 @@
*
* @since 5.2.0
*
- * @global string $pagenow The filename of the current screen.
+ * @global string $pagenow The filename of the current screen.
+ * @global WP_Paused_Extensions_Storage $_paused_themes
*/
function paused_themes_notice() {
if ( 'themes.php' === $GLOBALS['pagenow'] ) {
@@ -1200,11 +1242,18 @@
return;
}
- printf(
- '<div class="notice notice-error"><p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p></div>',
+ $message = sprintf(
+ '<p><strong>%s</strong><br>%s</p><p><a href="%s">%s</a></p>',
__( 'One or more themes failed to load properly.' ),
__( 'You can find more details and make changes on the Themes screen.' ),
esc_url( admin_url( 'themes.php' ) ),
__( 'Go to the Themes screen' )
);
+ wp_admin_notice(
+ $message,
+ array(
+ 'type' => 'error',
+ 'paragraph_wrap' => false,
+ )
+ );
}