X-Git-Url: https://scripts.mit.edu/gitweb/autoinstalls/wordpress.git/blobdiff_plain/53f4633144ed68c8b8fb5861f992b5489894a940..refs/heads/pristine:/wp-admin/themes.php?ds=sidebyside diff --git a/wp-admin/themes.php b/wp-admin/themes.php index 5c007df7..6aa129d7 100644 --- a/wp-admin/themes.php +++ b/wp-admin/themes.php @@ -9,23 +9,50 @@ /** WordPress Administration Bootstrap */ require_once( dirname( __FILE__ ) . '/admin.php' ); -if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); +if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '

', + 403 + ); +} if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) { if ( 'activate' == $_GET['action'] ) { check_admin_referer('switch-theme_' . $_GET['stylesheet']); $theme = wp_get_theme( $_GET['stylesheet'] ); - if ( ! $theme->exists() || ! $theme->is_allowed() ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + + if ( ! $theme->exists() || ! $theme->is_allowed() ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'The requested theme does not exist.' ) . '

', + 403 + ); + } + switch_theme( $theme->get_stylesheet() ); wp_redirect( admin_url('themes.php?activated=true') ); exit; } elseif ( 'delete' == $_GET['action'] ) { check_admin_referer('delete-theme_' . $_GET['stylesheet']); $theme = wp_get_theme( $_GET['stylesheet'] ); - if ( !current_user_can('delete_themes') || ! $theme->exists() ) - wp_die( __( 'Cheatin’ uh?' ), 403 ); + + if ( ! current_user_can( 'delete_themes' ) ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'Sorry, you are not allowed to delete this item.' ) . '

', + 403 + ); + } + + if ( ! $theme->exists() ) { + wp_die( + '

' . __( 'Cheatin’ uh?' ) . '

' . + '

' . __( 'The requested theme does not exist.' ) . '

', + 403 + ); + } + $active = wp_get_theme(); if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) { wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) ); @@ -62,7 +89,7 @@ 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.org Theme Directory. Themes in the WordPress.org 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( __('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( array( @@ -88,8 +115,8 @@ if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) get_current_screen()->set_help_sidebar( '

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

' . - '

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

' . - '

' . __( 'Support Forums' ) . '

' + '

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

' . + '

' . __( 'Support Forums' ) . '

' ); if ( current_user_can( 'switch_themes' ) ) { @@ -118,6 +145,7 @@ wp_localize_script( 'theme', '_wpThemeSettings', array( add_thickbox(); wp_enqueue_script( 'theme' ); +wp_enqueue_script( 'updates' ); wp_enqueue_script( 'customize-loader' ); require_once( ABSPATH . 'wp-admin/admin-header.php' ); @@ -135,9 +163,9 @@ if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?>

-

Visit site' ), home_url( '/' ) ); ?>

+

-

Visit site' ), home_url( '/' ) ); ?>

@@ -149,7 +177,7 @@ endif; $ct = wp_get_theme(); if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) { - echo '

' . sprintf( __( 'ERROR: %s' ), $ct->errors()->get_error_message() ) . '

'; + echo '

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

'; } /* @@ -172,17 +200,17 @@ if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() ) $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[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; else - $current_theme_actions[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; } 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[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; } elseif ( 'custom-background' === $menu_file ) { - $current_theme_actions[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; } } @@ -191,9 +219,9 @@ if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() ) } if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) { - $current_theme_actions[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; } else { - $current_theme_actions[] = "{$item[0]}"; + $current_theme_actions[] = "{$item[0]}"; } } } @@ -202,7 +230,7 @@ if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() ) ?>
-
+
+ + +
+ +

Update now' ); ?>

+ +

+ +
+ +
-

+

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

+ -

+

@@ -242,20 +281,19 @@ foreach ( $themes as $theme ) : - + +
- - -
-
-
@@ -269,10 +307,11 @@ if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_

-

+

@@ -281,7 +320,9 @@ $can_delete = current_user_can( 'delete_themes' ); - + + + @@ -296,9 +337,25 @@ $can_delete = current_user_can( 'delete_themes' ); ), admin_url( 'themes.php' ) ); $delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet ); ?> - + errors()->get_error_code() ) { + $parent_theme_name = $broken_theme->get( 'Template' ); + $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 = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name ); + ?> + + @@ -323,47 +380,59 @@ $can_delete = current_user_can( 'delete_themes' ); <# } else { #>
<# } #> + + <# if ( data.hasUpdate ) { #> + <# if ( data.hasPackage ) { #> +

Update now' ); ?>

+ <# } else { #> +

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

+

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

+ <# } else { #> -

{{{ data.name }}}

+

{{{ data.name }}}

<# } #>
- - <# if ( data.active ) { #> - <# if ( data.actions.customize ) { #> - + <# if ( data.active ) { #> + <# if ( data.actions.customize ) { #> + + <# } #> + <# } else { #> + + + <# } #> - <# } else { #> - - - <# } #> -
- - <# if ( data.hasUpdate ) { #> -
- <# } #> - wp_get_update_data(), +) ); + +require( ABSPATH . 'wp-admin/admin-footer.php' );