--- a/wp/wp-admin/themes.php Mon Oct 14 18:06:33 2019 +0200
+++ b/wp/wp-admin/themes.php Mon Oct 14 18:28:13 2019 +0200
@@ -17,9 +17,9 @@
);
}
-if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
+if ( current_user_can( 'switch_themes' ) && isset( $_GET['action'] ) ) {
if ( 'activate' == $_GET['action'] ) {
- check_admin_referer('switch-theme_' . $_GET['stylesheet']);
+ check_admin_referer( 'switch-theme_' . $_GET['stylesheet'] );
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( ! $theme->exists() || ! $theme->is_allowed() ) {
@@ -31,10 +31,30 @@
}
switch_theme( $theme->get_stylesheet() );
- wp_redirect( admin_url('themes.php?activated=true') );
+ wp_redirect( admin_url( 'themes.php?activated=true' ) );
+ exit;
+ } elseif ( 'resume' === $_GET['action'] ) {
+ check_admin_referer( 'resume-theme_' . $_GET['stylesheet'] );
+ $theme = wp_get_theme( $_GET['stylesheet'] );
+
+ if ( ! current_user_can( 'resume_theme', $_GET['stylesheet'] ) ) {
+ wp_die(
+ '<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
+ '<p>' . __( 'Sorry, you are not allowed to resume this theme.' ) . '</p>',
+ 403
+ );
+ }
+
+ $result = resume_theme( $theme->get_stylesheet(), self_admin_url( 'themes.php?error=resuming' ) );
+
+ if ( is_wp_error( $result ) ) {
+ wp_die( $result );
+ }
+
+ wp_redirect( admin_url( 'themes.php?resumed=true' ) );
exit;
} elseif ( 'delete' == $_GET['action'] ) {
- check_admin_referer('delete-theme_' . $_GET['stylesheet']);
+ check_admin_referer( 'delete-theme_' . $_GET['stylesheet'] );
$theme = wp_get_theme( $_GET['stylesheet'] );
if ( ! current_user_can( 'delete_themes' ) ) {
@@ -64,12 +84,12 @@
}
}
-$title = __('Manage Themes');
+$title = __( 'Manage Themes' );
$parent_file = 'themes.php';
// Help tab: Overview
if ( current_user_can( 'switch_themes' ) ) {
- $help_overview = '<p>' . __( '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.' ) . '</p>' .
+ $help_overview = '<p>' . __( '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.' ) . '</p>' .
'<p>' . __( 'From this screen you can:' ) . '</p>' .
'<ul><li>' . __( 'Hover or tap to see Activate and Live Preview buttons' ) . '</li>' .
'<li>' . __( 'Click on the theme to see the theme name, version, author, description, tags, and the Delete link' ) . '</li>' .
@@ -77,46 +97,52 @@
'<p>' . __( 'The current theme is displayed highlighted as the first theme.' ) . '</p>' .
'<p>' . __( 'The search for installed themes will search for terms in their name, description, author, or tag.' ) . ' <span id="live-search-desc">' . __( 'The search results will be updated as you type.' ) . '</span></p>';
- get_current_screen()->add_help_tab( array(
- 'id' => 'overview',
- 'title' => __( 'Overview' ),
- 'content' => $help_overview
- ) );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'overview',
+ 'title' => __( 'Overview' ),
+ 'content' => $help_overview,
+ )
+ );
} // switch_themes
// Help tab: Adding Themes
if ( current_user_can( 'install_themes' ) ) {
if ( is_multisite() ) {
- $help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
+ $help_install = '<p>' . __( 'Installing themes on Multisite can only be done from the Network Admin section.' ) . '</p>';
} else {
- $help_install = '<p>' . 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 <a href="%s">WordPress Theme Directory</a>. 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/' ) ) . '</p>';
+ $help_install = '<p>' . 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 <a href="%s">WordPress Theme Directory</a>. 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/' ) ) . '</p>';
}
- get_current_screen()->add_help_tab( array(
- 'id' => 'adding-themes',
- 'title' => __('Adding Themes'),
- 'content' => $help_install
- ) );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'adding-themes',
+ 'title' => __( 'Adding Themes' ),
+ 'content' => $help_install,
+ )
+ );
} // install_themes
// Help tab: Previewing and Customizing
if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
$help_customize =
- '<p>' . __( '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.' ) . '</p>'.
+ '<p>' . __( '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.' ) . '</p>' .
'<p>' . __( 'The theme being previewed is fully interactive — navigate to different pages to see how the theme handles posts, archives, and other page templates. The settings may differ depending on what theme features the theme being previewed supports. To accept the new settings and activate the theme all in one step, click the Publish & Activate button above the menu.' ) . '</p>' .
'<p>' . __( 'When previewing on smaller monitors, you can use the collapse icon at the bottom of the left-hand pane. This will hide the pane, giving you more room to preview your site in the new theme. To bring the pane back, click on the collapse icon again.' ) . '</p>';
- get_current_screen()->add_help_tab( array(
- 'id' => 'customize-preview-themes',
- 'title' => __( 'Previewing and Customizing' ),
- 'content' => $help_customize
- ) );
+ get_current_screen()->add_help_tab(
+ array(
+ 'id' => 'customize-preview-themes',
+ 'title' => __( 'Previewing and Customizing' ),
+ 'content' => $help_customize,
+ )
+ );
} // edit_theme_options && customize
get_current_screen()->set_help_sidebar(
'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
'<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>' ) . '</p>' .
- '<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
+ '<p>' . __( '<a href="https://wordpress.org/support/">Support</a>' ) . '</p>'
);
if ( current_user_can( 'switch_themes' ) ) {
@@ -126,22 +152,26 @@
}
wp_reset_vars( array( 'theme', 'search' ) );
-wp_localize_script( 'theme', '_wpThemeSettings', array(
- 'themes' => $themes,
- 'settings' => array(
- 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
- 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
- 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
- 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ),
- ),
- 'l10n' => array(
- 'addNew' => __( 'Add New Theme' ),
- 'search' => __( 'Search Installed Themes' ),
- 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis)
- 'themesFound' => __( 'Number of Themes found: %d' ),
- 'noThemesFound' => __( 'No themes found. Try a different search.' ),
- ),
-) );
+wp_localize_script(
+ 'theme',
+ '_wpThemeSettings',
+ array(
+ 'themes' => $themes,
+ 'settings' => array(
+ 'canInstall' => ( ! is_multisite() && current_user_can( 'install_themes' ) ),
+ 'installURI' => ( ! is_multisite() && current_user_can( 'install_themes' ) ) ? admin_url( 'theme-install.php' ) : null,
+ 'confirmDelete' => __( "Are you sure you want to delete this theme?\n\nClick 'Cancel' to go back, 'OK' to confirm the delete." ),
+ 'adminUrl' => parse_url( admin_url(), PHP_URL_PATH ),
+ ),
+ 'l10n' => array(
+ 'addNew' => __( 'Add New Theme' ),
+ 'search' => __( 'Search Installed Themes' ),
+ 'searchPlaceholder' => __( 'Search installed themes...' ), // placeholder (no ellipsis)
+ 'themesFound' => __( 'Number of Themes found: %d' ),
+ 'noThemesFound' => __( 'No themes found. Try a different search.' ),
+ ),
+ )
+);
add_thickbox();
wp_enqueue_script( 'theme' );
@@ -163,20 +193,37 @@
<hr class="wp-header-end">
<?php
-if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?>
-<div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
-<?php elseif ( isset($_GET['activated']) ) :
- if ( isset( $_GET['previewed'] ) ) { ?>
+if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) {
+ ?>
+ <div id="message1" class="updated notice is-dismissible"><p><?php _e( 'The active theme is broken. Reverting to the default theme.' ); ?></p></div>
+ <?php
+} elseif ( isset( $_GET['activated'] ) ) {
+ if ( isset( $_GET['previewed'] ) ) {
+ ?>
<div id="message2" class="updated notice is-dismissible"><p><?php _e( 'Settings saved and theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
- <?php } else { ?>
-<div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div><?php
- }
- elseif ( isset($_GET['deleted']) ) : ?>
-<div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div>
-<?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?>
+ <?php
+ } else {
+ ?>
+ <div id="message2" class="updated notice is-dismissible"><p><?php _e( 'New theme activated.' ); ?> <a href="<?php echo home_url( '/' ); ?>"><?php _e( 'Visit site' ); ?></a></p></div>
+ <?php
+ }
+} elseif ( isset( $_GET['deleted'] ) ) {
+ ?>
+ <div id="message3" class="updated notice is-dismissible"><p><?php _e( 'Theme deleted.' ); ?></p></div>
+ <?php
+} elseif ( isset( $_GET['delete-active-child'] ) ) {
+ ?>
<div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
-<?php
-endif;
+ <?php
+} elseif ( isset( $_GET['resumed'] ) ) {
+ ?>
+ <div id="message5" class="updated notice is-dismissible"><p><?php _e( 'Theme resumed.' ); ?></p></div>
+ <?php
+} elseif ( isset( $_GET['error'] ) && 'resuming' === $_GET['error'] ) {
+ ?>
+ <div id="message6" class="error"><p><?php _e( 'Theme could not be resumed because it triggered a <strong>fatal error</strong>.' ); ?></p></div>
+ <?php
+}
$ct = wp_get_theme();
@@ -192,44 +239,47 @@
// Pretend you didn't see this.
$current_theme_actions = array();
- 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' ) )
- continue;
- // 0 = name, 1 = capability, 2 = file
- if ( ( strcmp($self, $item[2]) == 0 && empty($parent_file)) || ($parent_file && ($item[2] == $parent_file)) )
- $class = ' current';
- if ( !empty($submenu[$item[2]]) ) {
- $submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
- $menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
- if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
- $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
- else
- $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
- } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
- $menu_file = $item[2];
+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' ) ) {
+ continue;
+ }
+ // 0 = name, 1 = capability, 2 = file
+ if ( ( strcmp( $self, $item[2] ) == 0 && empty( $parent_file ) ) || ( $parent_file && ( $item[2] == $parent_file ) ) ) {
+ $class = ' current';
+ }
+ if ( ! empty( $submenu[ $item[2] ] ) ) {
+ $submenu[ $item[2] ] = array_values( $submenu[ $item[2] ] ); // Re-index.
+ $menu_hook = get_plugin_page_hook( $submenu[ $item[2] ][0][2], $item[2] );
+ if ( file_exists( WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}" ) || ! empty( $menu_hook ) ) {
+ $current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
+ } else {
+ $current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
+ }
+ } elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
+ $menu_file = $item[2];
- if ( current_user_can( 'customize' ) ) {
- if ( 'custom-header' === $menu_file ) {
- $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
- } elseif ( 'custom-background' === $menu_file ) {
- $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
- }
+ if ( current_user_can( 'customize' ) ) {
+ if ( 'custom-header' === $menu_file ) {
+ $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
+ } elseif ( 'custom-background' === $menu_file ) {
+ $current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
}
+ }
- if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) {
- $menu_file = substr( $menu_file, 0, $pos );
- }
+ if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) {
+ $menu_file = substr( $menu_file, 0, $pos );
+ }
- if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
- $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
- } else {
- $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
- }
+ if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
+ $current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
+ } else {
+ $current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
}
}
}
+}
?>
@@ -250,8 +300,13 @@
foreach ( $themes as $theme ) :
$aria_action = esc_attr( $theme['id'] . '-action' );
$aria_name = esc_attr( $theme['id'] . '-name' );
+
+ $active_class = '';
+ if ( $theme['active'] ) {
+ $active_class = ' active';
+ }
?>
-<div class="theme<?php if ( $theme['active'] ) echo ' active'; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>">
+<div class="theme<?php echo $active_class; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>">
<?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
<div class="theme-screenshot">
<img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
@@ -313,21 +368,25 @@
<?php
// List broken themes, if any.
-if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
-?>
+if ( ! is_multisite() && current_user_can( 'edit_themes' ) && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
+ ?>
<div class="broken-themes">
-<h3><?php _e('Broken Themes'); ?></h3>
+<h3><?php _e( 'Broken Themes' ); ?></h3>
<p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
-<?php
-$can_delete = current_user_can( 'delete_themes' );
-$can_install = current_user_can( 'install_themes' );
-?>
+ <?php
+ $can_resume = current_user_can( 'resume_themes' );
+ $can_delete = current_user_can( 'delete_themes' );
+ $can_install = current_user_can( 'install_themes' );
+ ?>
<table>
<tr>
- <th><?php _ex('Name', 'theme name'); ?></th>
- <th><?php _e('Description'); ?></th>
+ <th><?php _ex( 'Name', 'theme name' ); ?></th>
+ <th><?php _e( 'Description' ); ?></th>
+ <?php if ( $can_resume ) { ?>
+ <td></td>
+ <?php } ?>
<?php if ( $can_delete ) { ?>
<td></td>
<?php } ?>
@@ -340,12 +399,36 @@
<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
<?php
+ if ( $can_resume ) {
+ if ( 'theme_paused' === $broken_theme->errors()->get_error_code() ) {
+ $stylesheet = $broken_theme->get_stylesheet();
+ $resume_url = add_query_arg(
+ array(
+ 'action' => 'resume',
+ 'stylesheet' => urlencode( $stylesheet ),
+ ),
+ admin_url( 'themes.php' )
+ );
+ $resume_url = wp_nonce_url( $resume_url, 'resume-theme_' . $stylesheet );
+ ?>
+ <td><a href="<?php echo esc_url( $resume_url ); ?>" class="button resume-theme"><?php _e( 'Resume' ); ?></a></td>
+ <?php
+ } else {
+ ?>
+ <td></td>
+ <?php
+ }
+ }
+
if ( $can_delete ) {
$stylesheet = $broken_theme->get_stylesheet();
- $delete_url = add_query_arg( array(
- 'action' => 'delete',
- 'stylesheet' => urlencode( $stylesheet ),
- ), admin_url( 'themes.php' ) );
+ $delete_url = add_query_arg(
+ array(
+ 'action' => 'delete',
+ 'stylesheet' => urlencode( $stylesheet ),
+ ),
+ admin_url( 'themes.php' )
+ );
$delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
?>
<td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td>
@@ -354,13 +437,16 @@
if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
$parent_theme_name = $broken_theme->get( 'Template' );
- $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
+ $parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
if ( ! is_wp_error( $parent_theme ) ) {
- $install_url = add_query_arg( array(
- 'action' => 'install-theme',
- 'theme' => urlencode( $parent_theme_name ),
- ), admin_url( 'update.php' ) );
+ $install_url = add_query_arg(
+ array(
+ 'action' => 'install-theme',
+ 'theme' => urlencode( $parent_theme_name ),
+ ),
+ admin_url( 'update.php' )
+ );
$install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
?>
<td><a href="<?php echo esc_url( $install_url ); ?>" class="button install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
@@ -373,7 +459,7 @@
</table>
</div>
-<?php
+ <?php
}
?>
</div><!-- .wrap -->
@@ -507,8 +593,12 @@
wp_print_admin_notice_templates();
wp_print_update_row_templates();
-wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
- 'totals' => wp_get_update_data(),
-) );
+wp_localize_script(
+ 'updates',
+ '_wpUpdatesItemCounts',
+ array(
+ 'totals' => wp_get_update_data(),
+ )
+);
require( ABSPATH . 'wp-admin/admin-footer.php' );