diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/themes.php --- a/wp/wp-admin/themes.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/themes.php Tue Dec 15 13:49:49 2020 +0100 @@ -7,7 +7,7 @@ */ /** WordPress Administration Bootstrap */ -require_once( dirname( __FILE__ ) . '/admin.php' ); +require_once __DIR__ . '/admin.php'; if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) { wp_die( @@ -18,7 +18,7 @@ } if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) { - if ( 'activate' == $_GET['action'] ) { + if ( 'activate' === $_GET['action'] ) { check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] ); $theme = wp_get_theme( $_GET['stylesheet'] ); @@ -53,7 +53,7 @@ wp_redirect( admin_url( 'themes.php?resumed=true' ) ); exit; - } elseif ( 'delete' == $_GET['action'] ) { + } elseif ( 'delete' === $_GET['action'] ) { check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] ); $theme = wp_get_theme( $_GET['stylesheet'] ); @@ -81,13 +81,52 @@ wp_redirect( admin_url( 'themes.php?deleted=true' ) ); } exit; + } elseif ( 'enable-auto-update' === $_GET['action'] ) { + if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) { + wp_die( __( 'Sorry, you are not allowed to enable themes automatic updates.' ) ); + } + + check_admin_referer( 'updates' ); + + $all_items = wp_get_themes(); + $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); + + $auto_updates[] = $_GET['stylesheet']; + $auto_updates = array_unique( $auto_updates ); + // Remove themes that have been deleted since the site option was last updated. + $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); + + update_site_option( 'auto_update_themes', $auto_updates ); + + wp_redirect( admin_url( 'themes.php?enabled-auto-update=true' ) ); + + exit; + } elseif ( 'disable-auto-update' === $_GET['action'] ) { + if ( ! ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) ) { + wp_die( __( 'Sorry, you are not allowed to disable themes automatic updates.' ) ); + } + + check_admin_referer( 'updates' ); + + $all_items = wp_get_themes(); + $auto_updates = (array) get_site_option( 'auto_update_themes', array() ); + + $auto_updates = array_diff( $auto_updates, array( $_GET['stylesheet'] ) ); + // Remove themes that have been deleted since the site option was last updated. + $auto_updates = array_intersect( $auto_updates, array_keys( $all_items ) ); + + update_site_option( 'auto_update_themes', $auto_updates ); + + wp_redirect( admin_url( 'themes.php?disabled-auto-update=true' ) ); + + exit; } } $title = __( 'Manage Themes' ); $parent_file = 'themes.php'; -// Help tab: Overview +// Help tab: Overview. if ( current_user_can( 'switch_themes' ) ) { $help_overview = '

' . __( 'This screen is used for managing your installed themes. Aside from the default theme(s) included with your WordPress installation, themes are designed and developed by third parties.' ) . '

' . '

' . __( 'From this screen you can:' ) . '

' . @@ -104,14 +143,18 @@ 'content' => $help_overview, ) ); -} // switch_themes +} // End if 'switch_themes'. -// Help tab: Adding Themes +// Help tab: Adding Themes. if ( current_user_can( 'install_themes' ) ) { if ( is_multisite() ) { $help_install = '

' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '

'; } else { - $help_install = '

' . sprintf( __( 'If you would like to see more themes to choose from, click on the “Add New” button and you will be able to browse or search for additional themes from the WordPress Theme Directory. Themes in the WordPress Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!' ), __( 'https://wordpress.org/themes/' ) ) . '

'; + $help_install = '

' . sprintf( + /* translators: %s: https://wordpress.org/themes/ */ + __( 'If you would like to see more themes to choose from, click on the “Add New” button and you will be able to browse or search for additional themes from the WordPress Theme Directory. Themes in the WordPress Theme Directory are designed and developed by third parties, and are compatible with the license WordPress uses. Oh, and they’re free!' ), + __( 'https://wordpress.org/themes/' ) + ) . '

'; } get_current_screen()->add_help_tab( @@ -121,9 +164,9 @@ 'content' => $help_install, ) ); -} // install_themes +} // End if 'install_themes'. -// Help tab: Previewing and Customizing +// Help tab: Previewing and Customizing. if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { $help_customize = '

' . __( 'Tap or hover on any theme then click the Live Preview button to see a live preview of that theme and change theme options in a separate, full-screen view. You can also find a Live Preview button at the bottom of the theme details screen. Any installed theme can be previewed and customized in this way.' ) . '

' . @@ -137,11 +180,31 @@ 'content' => $help_customize, ) ); -} // edit_theme_options && customize +} // End if 'edit_theme_options' && 'customize'. + +$help_sidebar_autoupdates = ''; + +// Help tab: Auto-updates. +if ( current_user_can( 'update_themes' ) && wp_is_auto_update_enabled_for_type( 'theme' ) ) { + $help_tab_autoupdates = + '

' . __( 'Auto-updates can be enabled or disabled for each individual theme. Themes with auto-updates enabled will display the estimated date of the next auto-update. Auto-updates depends on the WP-Cron task scheduling system.' ) . '

' . + '

' . __( 'Please note: Third-party themes and plugins, or custom code, may override WordPress scheduling.' ) . '

'; + + get_current_screen()->add_help_tab( + array( + 'id' => 'plugins-themes-auto-updates', + 'title' => __( 'Auto-updates' ), + 'content' => $help_tab_autoupdates, + ) + ); + + $help_sidebar_autoupdates = '

' . __( 'Learn more: Auto-updates documentation' ) . '

'; +} // End if 'update_themes' && 'wp_is_auto_update_enabled_for_type'. get_current_screen()->set_help_sidebar( '

' . __( 'For more information:' ) . '

' . - '

' . __( 'Documentation on Using Themes' ) . '

' . + '

' . __( 'Documentation on Using Themes' ) . '

' . + $help_sidebar_autoupdates . '

' . __( 'Support' ) . '

' ); @@ -166,7 +229,8 @@ 'l10n' => array( 'addNew' => __( 'Add New Theme' ), 'search' => __( 'Search Installed Themes' ), - 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis) + 'searchPlaceholder' => __( 'Search installed themes...' ), // Placeholder (no ellipsis). + /* translators: %d: Number of themes. */ 'themesFound' => __( 'Number of Themes found: %d' ), 'noThemesFound' => __( 'No themes found. Try a different search.' ), ), @@ -177,7 +241,7 @@ wp_enqueue_script( 'theme' ); wp_enqueue_script( 'updates' ); -require_once( ABSPATH . 'wp-admin/admin-header.php' ); +require_once ABSPATH . 'wp-admin/admin-header.php'; ?>
@@ -186,7 +250,7 @@ - +
@@ -223,17 +287,25 @@ ?>

fatal error.' ); ?>

+

+ +

+ errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) { - echo '

' . __( 'ERROR:' ) . ' ' . $ct->errors()->get_error_message() . '

'; + echo '

' . __( 'Error:' ) . ' ' . $ct->errors()->get_error_message() . '

'; } /* // Certain error codes are less fatal than others. We can still display theme information in most cases. -if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() ) +if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() ) && in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?> */ @@ -242,10 +314,10 @@ if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) { foreach ( (array) $submenu['themes.php'] as $item ) { $class = ''; - if ( 'themes.php' == $item[2] || 'theme-editor.php' == $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { + if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) { continue; } - // 0 = name, 1 = capability, 2 = file + // 0 = name, 1 = capability, 2 = file. if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) { $class = ' current'; } @@ -268,7 +340,8 @@ } } - if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) { + $pos = strpos( $menu_file, '?' ); + if ( false !== $pos ) { $menu_file = substr( $menu_file, 0, $pos ); } @@ -316,25 +389,141 @@ -
- -

Update now' ); ?>

+ +

+ + Update now' ); ?> + + + +

-

+

+ Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } elseif ( ! $theme['updateResponse']['compatibleWP'] ) { + printf( + /* translators: %s: Theme name. */ + __( 'There is a new version of %s available, but it doesn’t work with your version of WordPress.' ), + $theme['name'] + ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + } elseif ( ! $theme['updateResponse']['compatiblePHP'] ) { + printf( + /* translators: %s: Theme name. */ + __( 'There is a new version of %s available, but it doesn’t work with your version of PHP.' ), + $theme['name'] + ); + if ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } + ?> +

-
+

'; + if ( ! $theme['compatibleWP'] && ! $theme['compatiblePHP'] ) { + _e( 'This theme doesn’t work with your versions of WordPress and PHP.' ); + if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) { + printf( + /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */ + ' ' . __( 'Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } elseif ( ! $theme['compatibleWP'] ) { + _e( 'This theme doesn’t work with your version of WordPress.' ); + if ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + } elseif ( ! $theme['compatiblePHP'] ) { + _e( 'This theme doesn’t work with your version of PHP.' ); + if ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + } + echo '

'; + } + ?> + -
+
+ +

- Active: %s' ), $theme['name'] ); - ?> +

@@ -345,15 +534,24 @@ - + + + + + + +
@@ -368,7 +566,8 @@ true ) ) ) { +$broken_themes = wp_get_themes( array( 'errors' => true ) ); +if ( ! is_multisite() && $broken_themes ) { ?>
@@ -396,7 +595,7 @@ - get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?> + get( 'Name' ) ? $broken_theme->display( 'Name' ) : esc_html( $broken_theme->get_stylesheet() ); ?> errors()->get_error_message(); ?> + <# if ( data.autoupdate.supported ) { #> + <# if ( data.autoupdate.forced === false ) { #> + ' . __( 'Auto-updates disabled' ) . ' + <# } else if ( data.autoupdate.forced ) { #> + ' . __( 'Auto-updates enabled' ) . ' + <# } else if ( data.autoupdate.enabled ) { #> + + <# } else { #> + + <# } #> + <# } #> + <# if ( data.hasUpdate ) { #> + <# if ( data.autoupdate.supported && data.autoupdate.enabled ) { #> + + <# } else { #> + + <# } #> + +
+ '; + + /** + * Filters the JavaScript template used to display the auto-update setting for a theme (in the overlay). + * + * See {@see wp_prepare_themes_for_js()} for the properties of the `data` object. + * + * @since 5.5.0 + * + * @param string $template The template for displaying the auto-update setting link. + */ + return apply_filters( 'theme_auto_update_setting_template', $template ); +} + /* * The tmpl-theme template is synchronized with PHP above! */ @@ -479,17 +728,141 @@ <# } #> <# if ( data.hasUpdate ) { #> - <# if ( data.hasPackage ) { #> -

Update now' ); ?>

+ <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #> +

+ <# if ( data.hasPackage ) { #> + Update now' ); ?> + <# } else { #> + + <# } #> +

<# } else { #> -

+

+ <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #> + Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } else if ( ! data.updateResponse.compatibleWP ) { #> + Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + ?> + <# } else if ( ! data.updateResponse.compatiblePHP ) { #> + Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } #> +

<# } #> <# } #> + <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #> +

+ <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #> + Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } else if ( ! data.compatibleWP ) { #> + Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + ?> + <# } else if ( ! data.compatiblePHP ) { #> + Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } #> +

+ <# } #> +
@@ -497,10 +870,7 @@
<# if ( data.active ) { #>

- Active: %s' ), '{{{ data.name }}}' ); - ?> + {{{ data.name }}}

<# } else { #>

{{{ data.name }}}

@@ -512,12 +882,21 @@ <# } #> <# } else { #> - - - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + + + <# } else { #> + + + + <# } #> <# } #>
@@ -544,19 +923,164 @@ <# if ( data.active ) { #> <# } #> -

{{{ data.name }}}

-

+

{{{ data.name }}} + +

+

+ +

+ + <# if ( ! data.compatibleWP || ! data.compatiblePHP ) { #> +

+ <# if ( ! data.compatibleWP && ! data.compatiblePHP ) { #> + Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } else if ( ! data.compatibleWP ) { #> + Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + ?> + <# } else if ( ! data.compatiblePHP ) { #> + Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } #> +

+ <# } #> <# if ( data.hasUpdate ) { #> -
-

- {{{ data.update }}} -
+ <# if ( data.updateResponse.compatibleWP && data.updateResponse.compatiblePHP ) { #> +
+

+ {{{ data.update }}} +
+ <# } else { #> +
+

+

+ <# if ( ! data.updateResponse.compatibleWP && ! data.updateResponse.compatiblePHP ) { #> + Please update WordPress, and then learn more about updating PHP.' ), + self_admin_url( 'update-core.php' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } elseif ( current_user_can( 'update_core' ) ) { + printf( + /* translators: %s: URL to WordPress Updates screen. */ + ' ' . __( 'Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } elseif ( current_user_can( 'update_php' ) ) { + printf( + /* translators: %s: URL to Update PHP page. */ + ' ' . __( 'Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } else if ( ! data.updateResponse.compatibleWP ) { #> + Please update WordPress.' ), + self_admin_url( 'update-core.php' ) + ); + } + ?> + <# } else if ( ! data.updateResponse.compatiblePHP ) { #> + Learn more about updating PHP.' ), + esc_url( wp_get_update_php_url() ) + ); + wp_update_php_annotation( '

', '' ); + } + ?> + <# } #> +

+
+ <# } #> <# } #> + + <# if ( data.actions.autoupdate ) { #> + + <# } #> +

{{{ data.description }}}

<# if ( data.parent ) { #> -

{{{ data.parent }}}' ); ?>

+

+ {{{ data.parent }}}' ); + ?> +

<# } #> <# if ( data.tags ) { #> @@ -571,14 +1095,25 @@
- - <# if ( data.actions.activate ) { #> - + <# if ( data.compatibleWP && data.compatiblePHP ) { #> + + <# if ( data.actions.activate ) { #> + + <# } #> + + <# } else { #> + + <# if ( data.actions.activate ) { #> + + <# } #> + <# } #> -
<# if ( ! data.active && data.actions['delete'] ) { #> @@ -601,4 +1136,4 @@ ) ); -require( ABSPATH . 'wp-admin/admin-footer.php' ); +require_once ABSPATH . 'wp-admin/admin-footer.php';