wp/wp-admin/themes.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     7  */
     7  */
     8 
     8 
     9 /** WordPress Administration Bootstrap */
     9 /** WordPress Administration Bootstrap */
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 require_once( dirname( __FILE__ ) . '/admin.php' );
    11 
    11 
    12 if ( !current_user_can('switch_themes') && !current_user_can('edit_theme_options') )
    12 if ( ! current_user_can( 'switch_themes' ) && ! current_user_can( 'edit_theme_options' ) ) {
    13 	wp_die( __( 'Cheatin’ uh?' ), 403 );
    13 	wp_die(
       
    14 		'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
       
    15 		'<p>' . __( 'Sorry, you are not allowed to edit theme options on this site.' ) . '</p>',
       
    16 		403
       
    17 	);
       
    18 }
    14 
    19 
    15 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
    20 if ( current_user_can( 'switch_themes' ) && isset($_GET['action'] ) ) {
    16 	if ( 'activate' == $_GET['action'] ) {
    21 	if ( 'activate' == $_GET['action'] ) {
    17 		check_admin_referer('switch-theme_' . $_GET['stylesheet']);
    22 		check_admin_referer('switch-theme_' . $_GET['stylesheet']);
    18 		$theme = wp_get_theme( $_GET['stylesheet'] );
    23 		$theme = wp_get_theme( $_GET['stylesheet'] );
    19 		if ( ! $theme->exists() || ! $theme->is_allowed() )
    24 
    20 			wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
    25 		if ( ! $theme->exists() || ! $theme->is_allowed() ) {
       
    26 			wp_die(
       
    27 				'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
       
    28 				'<p>' . __( 'The requested theme does not exist.' ) . '</p>',
       
    29 				403
       
    30 			);
       
    31 		}
       
    32 
    21 		switch_theme( $theme->get_stylesheet() );
    33 		switch_theme( $theme->get_stylesheet() );
    22 		wp_redirect( admin_url('themes.php?activated=true') );
    34 		wp_redirect( admin_url('themes.php?activated=true') );
    23 		exit;
    35 		exit;
    24 	} elseif ( 'delete' == $_GET['action'] ) {
    36 	} elseif ( 'delete' == $_GET['action'] ) {
    25 		check_admin_referer('delete-theme_' . $_GET['stylesheet']);
    37 		check_admin_referer('delete-theme_' . $_GET['stylesheet']);
    26 		$theme = wp_get_theme( $_GET['stylesheet'] );
    38 		$theme = wp_get_theme( $_GET['stylesheet'] );
    27 		if ( !current_user_can('delete_themes') || ! $theme->exists() )
    39 
    28 			wp_die( __( 'Cheatin&#8217; uh?' ), 403 );
    40 		if ( ! current_user_can( 'delete_themes' ) ) {
       
    41 			wp_die(
       
    42 				'<h1>' . __( 'You need a higher level of permission.' ) . '</h1>' .
       
    43 				'<p>' . __( 'Sorry, you are not allowed to delete this item.' ) . '</p>',
       
    44 				403
       
    45 			);
       
    46 		}
       
    47 
       
    48 		if ( ! $theme->exists() ) {
       
    49 			wp_die(
       
    50 				'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
       
    51 				'<p>' . __( 'The requested theme does not exist.' ) . '</p>',
       
    52 				403
       
    53 			);
       
    54 		}
       
    55 
    29 		$active = wp_get_theme();
    56 		$active = wp_get_theme();
    30 		if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) {
    57 		if ( $active->get( 'Template' ) == $_GET['stylesheet'] ) {
    31 			wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) );
    58 			wp_redirect( admin_url( 'themes.php?delete-active-child=true' ) );
    32 		} else {
    59 		} else {
    33 			delete_theme( $_GET['stylesheet'] );
    60 			delete_theme( $_GET['stylesheet'] );
    60 // Help tab: Adding Themes
    87 // Help tab: Adding Themes
    61 if ( current_user_can( 'install_themes' ) ) {
    88 if ( current_user_can( 'install_themes' ) ) {
    62 	if ( is_multisite() ) {
    89 	if ( is_multisite() ) {
    63 		$help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
    90 		$help_install = '<p>' . __('Installing themes on Multisite can only be done from the Network Admin section.') . '</p>';
    64 	} else {
    91 	} else {
    65 		$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" target="_blank">WordPress.org Theme Directory</a>. 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&#8217;re free!'), 'https://wordpress.org/themes/' ) . '</p>';
    92 		$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>';
    66 	}
    93 	}
    67 
    94 
    68 	get_current_screen()->add_help_tab( array(
    95 	get_current_screen()->add_help_tab( array(
    69 		'id'      => 'adding-themes',
    96 		'id'      => 'adding-themes',
    70 		'title'   => __('Adding Themes'),
    97 		'title'   => __('Adding Themes'),
    74 
   101 
    75 // Help tab: Previewing and Customizing
   102 // Help tab: Previewing and Customizing
    76 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   103 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
    77 	$help_customize =
   104 	$help_customize =
    78 		'<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>'.
   105 		'<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>'.
    79 		'<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 Save &amp; Activate button above the menu.' ) . '</p>' .
   106 		'<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>' .
    80 		'<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>';
   107 		'<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>';
    81 
   108 
    82 	get_current_screen()->add_help_tab( array(
   109 	get_current_screen()->add_help_tab( array(
    83 		'id'		=> 'customize-preview-themes',
   110 		'id'		=> 'customize-preview-themes',
    84 		'title'		=> __( 'Previewing and Customizing' ),
   111 		'title'		=> __( 'Previewing and Customizing' ),
    86 	) );
   113 	) );
    87 } // edit_theme_options && customize
   114 } // edit_theme_options && customize
    88 
   115 
    89 get_current_screen()->set_help_sidebar(
   116 get_current_screen()->set_help_sidebar(
    90 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
   117 	'<p><strong>' . __( 'For more information:' ) . '</strong></p>' .
    91 	'<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes" target="_blank">Documentation on Using Themes</a>' ) . '</p>' .
   118 	'<p>' . __( '<a href="https://codex.wordpress.org/Using_Themes">Documentation on Using Themes</a>' ) . '</p>' .
    92 	'<p>' . __( '<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>' ) . '</p>'
   119 	'<p>' . __( '<a href="https://wordpress.org/support/">Support Forums</a>' ) . '</p>'
    93 );
   120 );
    94 
   121 
    95 if ( current_user_can( 'switch_themes' ) ) {
   122 if ( current_user_can( 'switch_themes' ) ) {
    96 	$themes = wp_prepare_themes_for_js();
   123 	$themes = wp_prepare_themes_for_js();
    97 } else {
   124 } else {
   116   	),
   143   	),
   117 ) );
   144 ) );
   118 
   145 
   119 add_thickbox();
   146 add_thickbox();
   120 wp_enqueue_script( 'theme' );
   147 wp_enqueue_script( 'theme' );
   121 wp_enqueue_script( 'customize-loader' );
   148 wp_enqueue_script( 'updates' );
   122 
   149 
   123 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   150 require_once( ABSPATH . 'wp-admin/admin-header.php' );
   124 ?>
   151 ?>
   125 
   152 
   126 <div class="wrap">
   153 <div class="wrap">
   127 	<h2><?php esc_html_e( 'Themes' ); ?>
   154 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   128 		<span class="title-count theme-count"><?php echo count( $themes ); ?></span>
   155 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
       
   156 	</h1>
       
   157 
   129 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   158 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   130 		<a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js add-new-h2"><?php echo esc_html_x( 'Add New', 'Add new theme' ); ?></a>
   159 		<a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'Add new theme' ); ?></a>
   131 	<?php endif; ?>
   160 	<?php endif; ?>
   132 	</h2>
   161 
       
   162 	<form class="search-form"></form>
       
   163 
       
   164 	<hr class="wp-header-end">
   133 <?php
   165 <?php
   134 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?>
   166 if ( ! validate_current_theme() || isset( $_GET['broken'] ) ) : ?>
   135 <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
   167 <div id="message1" class="updated notice is-dismissible"><p><?php _e('The active theme is broken. Reverting to the default theme.'); ?></p></div>
   136 <?php elseif ( isset($_GET['activated']) ) :
   168 <?php elseif ( isset($_GET['activated']) ) :
   137 		if ( isset( $_GET['previewed'] ) ) { ?>
   169 		if ( isset( $_GET['previewed'] ) ) { ?>
   138 		<div id="message2" class="updated notice is-dismissible"><p><?php printf( __( 'Settings saved and theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div>
   170 		<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>
   139 		<?php } else { ?>
   171 		<?php } else { ?>
   140 <div id="message2" class="updated notice is-dismissible"><p><?php printf( __( 'New theme activated. <a href="%s">Visit site</a>' ), home_url( '/' ) ); ?></p></div><?php
   172 <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
   141 		}
   173 		}
   142 	elseif ( isset($_GET['deleted']) ) : ?>
   174 	elseif ( isset($_GET['deleted']) ) : ?>
   143 <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div>
   175 <div id="message3" class="updated notice is-dismissible"><p><?php _e('Theme deleted.') ?></p></div>
   144 <?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?>
   176 <?php elseif ( isset( $_GET['delete-active-child'] ) ) : ?>
   145 	<div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
   177 	<div id="message4" class="error"><p><?php _e( 'You cannot delete a theme while it has an active child theme.' ); ?></p></div>
   147 endif;
   179 endif;
   148 
   180 
   149 $ct = wp_get_theme();
   181 $ct = wp_get_theme();
   150 
   182 
   151 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   183 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   152 	echo '<div class="error"><p>' . sprintf( __( 'ERROR: %s' ), $ct->errors()->get_error_message() ) . '</p></div>';
   184 	echo '<div class="error"><p>' . __( 'ERROR:' ) . ' ' . $ct->errors()->get_error_message() . '</p></div>';
   153 }
   185 }
   154 
   186 
   155 /*
   187 /*
   156 // Certain error codes are less fatal than others. We can still display theme information in most cases.
   188 // Certain error codes are less fatal than others. We can still display theme information in most cases.
   157 if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
   189 if ( ! $ct->errors() || ( 1 == count( $ct->errors()->get_error_codes() )
   170 				$class = ' current';
   202 				$class = ' current';
   171 			if ( !empty($submenu[$item[2]]) ) {
   203 			if ( !empty($submenu[$item[2]]) ) {
   172 				$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
   204 				$submenu[$item[2]] = array_values($submenu[$item[2]]); // Re-index.
   173 				$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
   205 				$menu_hook = get_plugin_page_hook($submenu[$item[2]][0][2], $item[2]);
   174 				if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
   206 				if ( file_exists(WP_PLUGIN_DIR . "/{$submenu[$item[2]][0][2]}") || !empty($menu_hook))
   175 					$current_theme_actions[] = "<a class='button button-secondary$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
   207 					$current_theme_actions[] = "<a class='button$class' href='admin.php?page={$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
   176 				else
   208 				else
   177 					$current_theme_actions[] = "<a class='button button-secondary$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
   209 					$current_theme_actions[] = "<a class='button$class' href='{$submenu[$item[2]][0][2]}'>{$item[0]}</a>";
   178 			} elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
   210 			} elseif ( ! empty( $item[2] ) && current_user_can( $item[1] ) ) {
   179 				$menu_file = $item[2];
   211 				$menu_file = $item[2];
   180 
   212 
   181 				if ( current_user_can( 'customize' ) ) {
   213 				if ( current_user_can( 'customize' ) ) {
   182 					if ( 'custom-header' === $menu_file ) {
   214 					if ( 'custom-header' === $menu_file ) {
   183 						$current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
   215 						$current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=header_image'>{$item[0]}</a>";
   184 					} elseif ( 'custom-background' === $menu_file ) {
   216 					} elseif ( 'custom-background' === $menu_file ) {
   185 						$current_theme_actions[] = "<a class='button button-secondary hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
   217 						$current_theme_actions[] = "<a class='button hide-if-no-customize$class' href='customize.php?autofocus[control]=background_image'>{$item[0]}</a>";
   186 					}
   218 					}
   187 				}
   219 				}
   188 
   220 
   189 				if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) {
   221 				if ( false !== ( $pos = strpos( $menu_file, '?' ) ) ) {
   190 					$menu_file = substr( $menu_file, 0, $pos );
   222 					$menu_file = substr( $menu_file, 0, $pos );
   191 				}
   223 				}
   192 
   224 
   193 				if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
   225 				if ( file_exists( ABSPATH . "wp-admin/$menu_file" ) ) {
   194 					$current_theme_actions[] = "<a class='button button-secondary$class' href='{$item[2]}'>{$item[0]}</a>";
   226 					$current_theme_actions[] = "<a class='button$class' href='{$item[2]}'>{$item[0]}</a>";
   195 				} else {
   227 				} else {
   196 					$current_theme_actions[] = "<a class='button button-secondary$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
   228 					$current_theme_actions[] = "<a class='button$class' href='themes.php?page={$item[2]}'>{$item[0]}</a>";
   197 				}
   229 				}
   198 			}
   230 			}
   199 		}
   231 		}
   200 	}
   232 	}
   201 
   233 
   202 ?>
   234 ?>
   203 
   235 
   204 <div class="theme-browser">
   236 <?php
   205 	<div class="themes">
   237 $class_name = 'theme-browser';
       
   238 if ( ! empty( $_GET['search'] ) ) {
       
   239 	$class_name .= ' search-loading';
       
   240 }
       
   241 ?>
       
   242 <div class="<?php echo esc_attr( $class_name ); ?>">
       
   243 	<div class="themes wp-clearfix">
   206 
   244 
   207 <?php
   245 <?php
   208 /*
   246 /*
   209  * This PHP is synchronized with the tmpl-theme template below!
   247  * This PHP is synchronized with the tmpl-theme template below!
   210  */
   248  */
   219 			<img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
   257 			<img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
   220 		</div>
   258 		</div>
   221 	<?php } else { ?>
   259 	<?php } else { ?>
   222 		<div class="theme-screenshot blank"></div>
   260 		<div class="theme-screenshot blank"></div>
   223 	<?php } ?>
   261 	<?php } ?>
       
   262 
       
   263 	<?php if ( $theme['hasUpdate'] ) : ?>
       
   264 		<div class="update-message notice inline notice-warning notice-alt">
       
   265 		<?php if ( $theme['hasPackage'] ) : ?>
       
   266 			<p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p>
       
   267 		<?php else : ?>
       
   268 			<p><?php _e( 'New version available.' ); ?></p>
       
   269 		<?php endif; ?>
       
   270 		</div>
       
   271 	<?php endif; ?>
       
   272 
   224 	<span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
   273 	<span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
   225 	<div class="theme-author"><?php printf( __( 'By %s' ), $theme['author'] ); ?></div>
   274 	<div class="theme-author"><?php printf( __( 'By %s' ), $theme['author'] ); ?></div>
   226 
   275 
   227 	<?php if ( $theme['active'] ) { ?>
   276 	<div class="theme-id-container">
   228 		<h3 class="theme-name" id="<?php echo $aria_name; ?>">
   277 		<?php if ( $theme['active'] ) { ?>
       
   278 			<h2 class="theme-name" id="<?php echo $aria_name; ?>">
       
   279 				<?php
       
   280 				/* translators: %s: theme name */
       
   281 				printf( __( '<span>Active:</span> %s' ), $theme['name'] );
       
   282 				?>
       
   283 			</h2>
       
   284 		<?php } else { ?>
       
   285 			<h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
       
   286 		<?php } ?>
       
   287 
       
   288 		<div class="theme-actions">
       
   289 		<?php if ( $theme['active'] ) { ?>
       
   290 			<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
       
   291 				<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
       
   292 			<?php } ?>
       
   293 		<?php } else { ?>
   229 			<?php
   294 			<?php
   230 			/* translators: %s: theme name */
   295 			/* translators: %s: Theme name */
   231 			printf( __( '<span>Active:</span> %s' ), $theme['name'] );
   296 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   232 			?>
   297 			?>
   233 		</h3>
   298 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   234 	<?php } else { ?>
   299 			<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   235 		<h3 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h3>
   300 				<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   236 	<?php } ?>
   301 			<?php } ?>
   237 
       
   238 	<div class="theme-actions">
       
   239 
       
   240 	<?php if ( $theme['active'] ) { ?>
       
   241 		<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
       
   242 			<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
       
   243 		<?php } ?>
   302 		<?php } ?>
   244 	<?php } else { ?>
   303 
   245 		<a class="button button-secondary activate" href="<?php echo $theme['actions']['activate']; ?>"><?php _e( 'Activate' ); ?></a>
   304 		</div>
   246 		<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
       
   247 			<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
       
   248 			<a class="button button-secondary hide-if-customize" href="<?php echo $theme['actions']['preview']; ?>"><?php _e( 'Preview' ); ?></a>
       
   249 		<?php } ?>
       
   250 	<?php } ?>
       
   251 
       
   252 	</div>
   305 	</div>
   253 
       
   254 	<?php if ( $theme['hasUpdate'] ) { ?>
       
   255 		<div class="theme-update"><?php _e( 'Update Available' ); ?></div>
       
   256 	<?php } ?>
       
   257 </div>
   306 </div>
   258 <?php endforeach; ?>
   307 <?php endforeach; ?>
   259 	<br class="clear" />
       
   260 	</div>
   308 	</div>
   261 </div>
   309 </div>
   262 <div class="theme-overlay"></div>
   310 <div class="theme-overlay" tabindex="0" role="dialog" aria-label="<?php esc_attr_e( 'Theme Details' ); ?>"></div>
   263 
   311 
   264 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
   312 <p class="no-themes"><?php _e( 'No themes found. Try a different search.' ); ?></p>
   265 
   313 
   266 <?php
   314 <?php
   267 // List broken themes, if any.
   315 // List broken themes, if any.
   268 if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
   316 if ( ! is_multisite() && current_user_can('edit_themes') && $broken_themes = wp_get_themes( array( 'errors' => true ) ) ) {
   269 ?>
   317 ?>
   270 
   318 
   271 <div class="broken-themes">
   319 <div class="broken-themes">
   272 <h3><?php _e('Broken Themes'); ?></h3>
   320 <h3><?php _e('Broken Themes'); ?></h3>
   273 <p><?php _e('The following themes are installed but incomplete. Themes must have a stylesheet and a template.'); ?></p>
   321 <p><?php _e( 'The following themes are installed but incomplete.' ); ?></p>
   274 
   322 
   275 <?php
   323 <?php
   276 $can_delete = current_user_can( 'delete_themes' );
   324 $can_delete = current_user_can( 'delete_themes' );
       
   325 $can_install = current_user_can( 'install_themes' );
   277 ?>
   326 ?>
   278 <table>
   327 <table>
   279 	<tr>
   328 	<tr>
   280 		<th><?php _ex('Name', 'theme name'); ?></th>
   329 		<th><?php _ex('Name', 'theme name'); ?></th>
   281 		<th><?php _e('Description'); ?></th>
   330 		<th><?php _e('Description'); ?></th>
   282 		<?php if ( $can_delete ) { ?>
   331 		<?php if ( $can_delete ) { ?>
   283 			<th></th>
   332 			<td></td>
   284 		<?php } ?>
   333 		<?php } ?>
   285 		</tr>
   334 		<?php if ( $can_install ) { ?>
       
   335 			<td></td>
       
   336 		<?php } ?>
   286 	</tr>
   337 	</tr>
   287 	<?php foreach ( $broken_themes as $broken_theme ) : ?>
   338 	<?php foreach ( $broken_themes as $broken_theme ) : ?>
   288 		<tr>
   339 		<tr>
   289 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
   340 			<td><?php echo $broken_theme->get( 'Name' ) ? $broken_theme->display( 'Name' ) : $broken_theme->get_stylesheet(); ?></td>
   290 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   341 			<td><?php echo $broken_theme->errors()->get_error_message(); ?></td>
   295 					'action'     => 'delete',
   346 					'action'     => 'delete',
   296 					'stylesheet' => urlencode( $stylesheet ),
   347 					'stylesheet' => urlencode( $stylesheet ),
   297 				), admin_url( 'themes.php' ) );
   348 				), admin_url( 'themes.php' ) );
   298 				$delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
   349 				$delete_url = wp_nonce_url( $delete_url, 'delete-theme_' . $stylesheet );
   299 				?>
   350 				?>
   300 				<td><a href="<?php echo esc_url( $delete_url ); ?>" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a></td>
   351 				<td><a href="<?php echo esc_url( $delete_url ); ?>" class="button delete-theme"><?php _e( 'Delete' ); ?></a></td>
   301 				<?php
   352 				<?php
       
   353 			}
       
   354 
       
   355 			if ( $can_install && 'theme_no_parent' === $broken_theme->errors()->get_error_code() ) {
       
   356 				$parent_theme_name = $broken_theme->get( 'Template' );
       
   357 				$parent_theme = themes_api( 'theme_information', array( 'slug' => urlencode( $parent_theme_name ) ) );
       
   358 
       
   359 				if ( ! is_wp_error( $parent_theme ) ) {
       
   360 					$install_url = add_query_arg( array(
       
   361 						'action' => 'install-theme',
       
   362 						'theme'  => urlencode( $parent_theme_name ),
       
   363 					), admin_url( 'update.php' ) );
       
   364 					$install_url = wp_nonce_url( $install_url, 'install-theme_' . $parent_theme_name );
       
   365 					?>
       
   366 					<td><a href="<?php echo esc_url( $install_url ); ?>" class="button install-theme"><?php _e( 'Install Parent Theme' ); ?></a></td>
       
   367 					<?php
       
   368 				}
   302 			}
   369 			}
   303 			?>
   370 			?>
   304 		</tr>
   371 		</tr>
   305 	<?php endforeach; ?>
   372 	<?php endforeach; ?>
   306 </table>
   373 </table>
   322 			<img src="{{ data.screenshot[0] }}" alt="" />
   389 			<img src="{{ data.screenshot[0] }}" alt="" />
   323 		</div>
   390 		</div>
   324 	<# } else { #>
   391 	<# } else { #>
   325 		<div class="theme-screenshot blank"></div>
   392 		<div class="theme-screenshot blank"></div>
   326 	<# } #>
   393 	<# } #>
       
   394 
       
   395 	<# if ( data.hasUpdate ) { #>
       
   396 		<# if ( data.hasPackage ) { #>
       
   397 			<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available. <button class="button-link" type="button">Update now</button>' ); ?></p></div>
       
   398 		<# } else { #>
       
   399 			<div class="update-message notice inline notice-warning notice-alt"><p><?php _e( 'New version available.' ); ?></p></div>
       
   400 		<# } #>
       
   401 	<# } #>
       
   402 
   327 	<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
   403 	<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
   328 	<div class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.author }}}' ); ?></div>
   404 	<div class="theme-author">
   329 
   405 		<?php
   330 	<# if ( data.active ) { #>
   406 		/* translators: %s: Theme author name */
   331 		<h3 class="theme-name" id="{{ data.id }}-name">
   407 		printf( __( 'By %s' ), '{{{ data.author }}}' );
   332 			<?php
   408 		?>
   333 			/* translators: %s: theme name */
   409 	</div>
   334 			printf( __( '<span>Active:</span> %s' ), '{{ data.name }}' );
   410 
   335 			?>
   411 	<div class="theme-id-container">
   336 		</h3>
   412 		<# if ( data.active ) { #>
   337 	<# } else { #>
   413 			<h2 class="theme-name" id="{{ data.id }}-name">
   338 		<h3 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h3>
   414 				<?php
   339 	<# } #>
   415 				/* translators: %s: Theme name */
   340 
   416 				printf( __( '<span>Active:</span> %s' ), '{{{ data.name }}}' );
   341 	<div class="theme-actions">
   417 				?>
   342 
   418 			</h2>
   343 	<# if ( data.active ) { #>
   419 		<# } else { #>
   344 		<# if ( data.actions.customize ) { #>
   420 			<h2 class="theme-name" id="{{ data.id }}-name">{{{ data.name }}}</h2>
   345 			<a class="button button-primary customize load-customize hide-if-no-customize" href="{{ data.actions.customize }}"><?php _e( 'Customize' ); ?></a>
       
   346 		<# } #>
   421 		<# } #>
   347 	<# } else { #>
   422 
   348 		<a class="button button-secondary activate" href="{{{ data.actions.activate }}}"><?php _e( 'Activate' ); ?></a>
   423 		<div class="theme-actions">
   349 		<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
   424 			<# if ( data.active ) { #>
   350 		<a class="button button-secondary hide-if-customize" href="{{{ data.actions.preview }}}"><?php _e( 'Preview' ); ?></a>
   425 				<# if ( data.actions.customize ) { #>
   351 	<# } #>
   426 					<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
   352 
   427 				<# } #>
       
   428 			<# } else { #>
       
   429 				<?php
       
   430 				/* translators: %s: Theme name */
       
   431 				$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
       
   432 				?>
       
   433 				<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
       
   434 				<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
       
   435 			<# } #>
       
   436 		</div>
   353 	</div>
   437 	</div>
   354 
       
   355 	<# if ( data.hasUpdate ) { #>
       
   356 		<div class="theme-update"><?php _e( 'Update Available' ); ?></div>
       
   357 	<# } #>
       
   358 </script>
   438 </script>
   359 
   439 
   360 <script id="tmpl-theme-single" type="text/template">
   440 <script id="tmpl-theme-single" type="text/template">
   361 	<div class="theme-backdrop"></div>
   441 	<div class="theme-backdrop"></div>
   362 	<div class="theme-wrap">
   442 	<div class="theme-wrap wp-clearfix" role="document">
   363 		<div class="theme-header">
   443 		<div class="theme-header">
   364 			<button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
   444 			<button class="left dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show previous theme' ); ?></span></button>
   365 			<button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
   445 			<button class="right dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Show next theme' ); ?></span></button>
   366 			<button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close overlay' ); ?></span></button>
   446 			<button class="close dashicons dashicons-no"><span class="screen-reader-text"><?php _e( 'Close details dialog' ); ?></span></button>
   367 		</div>
   447 		</div>
   368 		<div class="theme-about">
   448 		<div class="theme-about wp-clearfix">
   369 			<div class="theme-screenshots">
   449 			<div class="theme-screenshots">
   370 			<# if ( data.screenshot[0] ) { #>
   450 			<# if ( data.screenshot[0] ) { #>
   371 				<div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
   451 				<div class="screenshot"><img src="{{ data.screenshot[0] }}" alt="" /></div>
   372 			<# } else { #>
   452 			<# } else { #>
   373 				<div class="screenshot blank"></div>
   453 				<div class="screenshot blank"></div>
   376 
   456 
   377 			<div class="theme-info">
   457 			<div class="theme-info">
   378 				<# if ( data.active ) { #>
   458 				<# if ( data.active ) { #>
   379 					<span class="current-label"><?php _e( 'Current Theme' ); ?></span>
   459 					<span class="current-label"><?php _e( 'Current Theme' ); ?></span>
   380 				<# } #>
   460 				<# } #>
   381 				<h3 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h3>
   461 				<h2 class="theme-name">{{{ data.name }}}<span class="theme-version"><?php printf( __( 'Version: %s' ), '{{ data.version }}' ); ?></span></h2>
   382 				<h4 class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></h4>
   462 				<p class="theme-author"><?php printf( __( 'By %s' ), '{{{ data.authorAndUri }}}' ); ?></p>
   383 
   463 
   384 				<# if ( data.hasUpdate ) { #>
   464 				<# if ( data.hasUpdate ) { #>
   385 				<div class="theme-update-message">
   465 				<div class="notice notice-warning notice-alt notice-large">
   386 					<h4 class="theme-update"><?php _e( 'Update Available' ); ?></h4>
   466 					<h3 class="notice-title"><?php _e( 'Update Available' ); ?></h3>
   387 					{{{ data.update }}}
   467 					{{{ data.update }}}
   388 				</div>
   468 				</div>
   389 				<# } #>
   469 				<# } #>
   390 				<p class="theme-description">{{{ data.description }}}</p>
   470 				<p class="theme-description">{{{ data.description }}}</p>
   391 
   471 
   403 			<div class="active-theme">
   483 			<div class="active-theme">
   404 				<a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
   484 				<a href="{{{ data.actions.customize }}}" class="button button-primary customize load-customize hide-if-no-customize"><?php _e( 'Customize' ); ?></a>
   405 				<?php echo implode( ' ', $current_theme_actions ); ?>
   485 				<?php echo implode( ' ', $current_theme_actions ); ?>
   406 			</div>
   486 			</div>
   407 			<div class="inactive-theme">
   487 			<div class="inactive-theme">
       
   488 				<?php
       
   489 				/* translators: %s: Theme name */
       
   490 				$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
       
   491 				?>
   408 				<# if ( data.actions.activate ) { #>
   492 				<# if ( data.actions.activate ) { #>
   409 					<a href="{{{ data.actions.activate }}}" class="button button-secondary activate"><?php _e( 'Activate' ); ?></a>
   493 					<a href="{{{ data.actions.activate }}}" class="button activate" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
   410 				<# } #>
   494 				<# } #>
   411 				<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
   495 				<a href="{{{ data.actions.customize }}}" class="button button-primary load-customize hide-if-no-customize"><?php _e( 'Live Preview' ); ?></a>
   412 				<a href="{{{ data.actions.preview }}}" class="button button-secondary hide-if-customize"><?php _e( 'Preview' ); ?></a>
       
   413 			</div>
   496 			</div>
   414 
   497 
   415 			<# if ( ! data.active && data.actions['delete'] ) { #>
   498 			<# if ( ! data.active && data.actions['delete'] ) { #>
   416 				<a href="{{{ data.actions['delete'] }}}" class="button button-secondary delete-theme"><?php _e( 'Delete' ); ?></a>
   499 				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php _e( 'Delete' ); ?></a>
   417 			<# } #>
   500 			<# } #>
   418 		</div>
   501 		</div>
   419 	</div>
   502 	</div>
   420 </script>
   503 </script>
   421 
   504 
   422 <?php require( ABSPATH . 'wp-admin/admin-footer.php' );
   505 <?php
       
   506 wp_print_request_filesystem_credentials_modal();
       
   507 wp_print_admin_notice_templates();
       
   508 wp_print_update_row_templates();
       
   509 
       
   510 wp_localize_script( 'updates', '_wpUpdatesItemCounts', array(
       
   511 	'totals'  => wp_get_update_data(),
       
   512 ) );
       
   513 
       
   514 require( ABSPATH . 'wp-admin/admin-footer.php' );