mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
Cap checks in the upgrader so we do not show links the user cannot access. props linuxologos for the initial patch. see #19824.
Also fixes a rare fatal error when theme_info is not set when updating a theme that is already up to date. git-svn-id: http://core.svn.wordpress.org/trunk@21195 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
81c22c98f8
commit
fffff45c25
@ -851,6 +851,8 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
foreach ( $themes as $theme ) {
|
||||
$this->update_current++;
|
||||
|
||||
$this->skin->theme_info = $this->theme_info($theme);
|
||||
|
||||
if ( !isset( $current->response[ $theme ] ) ) {
|
||||
$this->skin->set_result(false);
|
||||
$this->skin->before();
|
||||
@ -860,8 +862,6 @@ class Theme_Upgrader extends WP_Upgrader {
|
||||
continue;
|
||||
}
|
||||
|
||||
$this->skin->theme_info = $this->theme_info($theme);
|
||||
|
||||
// Get the URL to the zip file
|
||||
$r = $current->response[ $theme ];
|
||||
|
||||
@ -1351,6 +1351,8 @@ class Bulk_Plugin_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
||||
'plugins_page' => '<a href="' . self_admin_url('plugins.php') . '" title="' . esc_attr__('Go to plugins page') . '" target="_parent">' . __('Return to Plugins page') . '</a>',
|
||||
'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
|
||||
);
|
||||
if ( ! current_user_can( 'activate_plugins' ) )
|
||||
unset( $update_actions['plugins_page'] );
|
||||
|
||||
$update_actions = apply_filters('update_bulk_plugins_complete_actions', $update_actions, $this->plugin_info);
|
||||
if ( ! empty($update_actions) )
|
||||
@ -1384,6 +1386,8 @@ class Bulk_Theme_Upgrader_Skin extends Bulk_Upgrader_Skin {
|
||||
'themes_page' => '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Go to themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>',
|
||||
'updates_page' => '<a href="' . self_admin_url('update-core.php') . '" title="' . esc_attr__('Go to WordPress Updates page') . '" target="_parent">' . __('Return to WordPress Updates') . '</a>'
|
||||
);
|
||||
if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) )
|
||||
unset( $update_actions['themes_page'] );
|
||||
|
||||
$update_actions = apply_filters('update_bulk_theme_complete_actions', $update_actions, $this->theme_info );
|
||||
if ( ! empty($update_actions) )
|
||||
@ -1517,10 +1521,10 @@ class Theme_Installer_Skin extends WP_Upgrader_Skin {
|
||||
|
||||
if ( $this->type == 'web' )
|
||||
$install_actions['themes_page'] = '<a href="' . self_admin_url('theme-install.php') . '" title="' . esc_attr__('Return to Theme Installer') . '" target="_parent">' . __('Return to Theme Installer') . '</a>';
|
||||
else
|
||||
elseif ( current_user_can( 'switch_themes' ) || current_user_can( 'edit_theme_options' ) )
|
||||
$install_actions['themes_page'] = '<a href="' . self_admin_url('themes.php') . '" title="' . esc_attr__('Themes page') . '" target="_parent">' . __('Return to Themes page') . '</a>';
|
||||
|
||||
if ( ! $this->result || is_wp_error($this->result) || is_network_admin() )
|
||||
if ( ! $this->result || is_wp_error($this->result) || is_network_admin() || ! current_user_can( 'switch_themes' ) )
|
||||
unset( $install_actions['activate'], $install_actions['preview'] );
|
||||
|
||||
$install_actions = apply_filters('install_theme_complete_actions', $install_actions, $this->api, $stylesheet, $theme_info);
|
||||
@ -1572,8 +1576,9 @@ class Theme_Upgrader_Skin extends WP_Upgrader_Skin {
|
||||
$activate_link = wp_nonce_url( $activate_link, 'switch-theme_' . $stylesheet );
|
||||
|
||||
if ( get_stylesheet() == $stylesheet ) {
|
||||
$update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>';
|
||||
} else {
|
||||
if ( current_user_can( 'edit_theme_options' ) )
|
||||
$update_actions['preview'] = '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Customize “%s”'), $name ) ) . '">' . __('Customize') . '</a>';
|
||||
} elseif ( current_user_can( 'switch_themes' ) ) {
|
||||
$update_actions['preview'] = '<a href="' . esc_url( $preview_link ) . '" class="hide-if-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Preview') . '</a>';
|
||||
$update_actions['preview'] .= '<a href="' . wp_customize_url( $stylesheet ) . '" class="hide-if-no-customize load-customize" title="' . esc_attr( sprintf( __('Preview “%s”'), $name ) ) . '">' . __('Live Preview') . '</a>';
|
||||
$update_actions['activate'] = '<a href="' . esc_url( $activate_link ) . '" class="activatelink" title="' . esc_attr( sprintf( __('Activate “%s”'), $name ) ) . '">' . __('Activate') . '</a>';
|
||||
|
Loading…
Reference in New Issue
Block a user