diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/theme.php --- 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 support forums.' ), @@ -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 @@
%s
%s
%s
%s