Update WP and plugins

This commit is contained in:
Oliver Davies 2019-04-16 20:56:22 +01:00
parent 10a4713229
commit 1fb77fc4ff
864 changed files with 101724 additions and 78262 deletions

View file

@ -17,9 +17,9 @@ if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_op
);
}
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,10 @@ if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
}
switch_theme( $theme->get_stylesheet() );
wp_redirect( admin_url('themes.php?activated=true') );
wp_redirect( admin_url( 'themes.php?activated=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 +64,12 @@ if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
}
}
$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,40 +77,46 @@ if ( current_user_can( 'switch_themes' ) ) {
'<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 &#8220;Add New&#8221; 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&#8217;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 &#8220;Add New&#8221; 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&#8217;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 &mdash; 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 &amp; 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(
@ -126,22 +132,26 @@ if ( current_user_can( 'switch_themes' ) ) {
}
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 +173,29 @@ require_once( ABSPATH . 'wp-admin/admin-header.php' );
<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
}
$ct = wp_get_theme();
@ -192,44 +211,47 @@ if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
// 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 +272,13 @@ if ( ! empty( $_GET['search'] ) ) {
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 +340,21 @@ foreach ( $themes as $theme ) :
<?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_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_delete ) { ?>
<td></td>
<?php } ?>
@ -342,10 +369,13 @@ $can_install = current_user_can( 'install_themes' );
<?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 +384,16 @@ $can_install = current_user_can( 'install_themes' );
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 +406,7 @@ $can_install = current_user_can( 'install_themes' );
</table>
</div>
<?php
<?php
}
?>
</div><!-- .wrap -->
@ -507,8 +540,12 @@ wp_print_request_filesystem_credentials_modal();
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' );