wp/wp-admin/themes.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
   168 
   168 
   169 // Help tab: Previewing and Customizing.
   169 // Help tab: Previewing and Customizing.
   170 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   170 if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
   171 	$help_customize =
   171 	$help_customize =
   172 		'<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>' .
   172 		'<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>' .
   173 		'<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>' .
   173 		'<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 Activate &amp; Publish button above the menu.' ) . '</p>' .
   174 		'<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>';
   174 		'<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>';
   175 
   175 
   176 	get_current_screen()->add_help_tab(
   176 	get_current_screen()->add_help_tab(
   177 		array(
   177 		array(
   178 			'id'      => 'customize-preview-themes',
   178 			'id'      => 'customize-preview-themes',
   248 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   248 	<h1 class="wp-heading-inline"><?php esc_html_e( 'Themes' ); ?>
   249 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   249 		<span class="title-count theme-count"><?php echo ! empty( $_GET['search'] ) ? __( '&hellip;' ) : count( $themes ); ?></span>
   250 	</h1>
   250 	</h1>
   251 
   251 
   252 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   252 	<?php if ( ! is_multisite() && current_user_can( 'install_themes' ) ) : ?>
   253 		<a href="<?php echo admin_url( 'theme-install.php' ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
   253 		<a href="<?php echo esc_url( admin_url( 'theme-install.php' ) ); ?>" class="hide-if-no-js page-title-action"><?php echo esc_html_x( 'Add New', 'theme' ); ?></a>
   254 	<?php endif; ?>
   254 	<?php endif; ?>
   255 
   255 
   256 	<form class="search-form"></form>
   256 	<form class="search-form"></form>
   257 
   257 
   258 	<hr class="wp-header-end">
   258 	<hr class="wp-header-end">
   295 	?>
   295 	?>
   296 	<div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
   296 	<div id="message8" class="updated notice is-dismissible"><p><?php _e( 'Theme will no longer be auto-updated.' ); ?></p></div>
   297 	<?php
   297 	<?php
   298 }
   298 }
   299 
   299 
   300 $ct = wp_get_theme();
   300 $current_theme = wp_get_theme();
   301 
   301 
   302 if ( $ct->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   302 if ( $current_theme->errors() && ( ! is_multisite() || current_user_can( 'manage_network_themes' ) ) ) {
   303 	echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $ct->errors()->get_error_message() . '</p></div>';
   303 	echo '<div class="error"><p>' . __( 'Error:' ) . ' ' . $current_theme->errors()->get_error_message() . '</p></div>';
   304 }
   304 }
   305 
   305 
   306 /*
   306 $current_theme_actions = array();
   307 // Certain error codes are less fatal than others. We can still display theme information in most cases.
   307 
   308 if ( ! $ct->errors() || ( 1 === count( $ct->errors()->get_error_codes() )
       
   309 	&& in_array( $ct->errors()->get_error_code(), array( 'theme_no_parent', 'theme_parent_invalid', 'theme_no_index' ) ) ) ) : ?>
       
   310 */
       
   311 
       
   312 	// Pretend you didn't see this.
       
   313 	$current_theme_actions = array();
       
   314 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   308 if ( is_array( $submenu ) && isset( $submenu['themes.php'] ) ) {
   315 	foreach ( (array) $submenu['themes.php'] as $item ) {
   309 	foreach ( (array) $submenu['themes.php'] as $item ) {
   316 		$class = '';
   310 		$class = '';
   317 		if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
   311 		if ( 'themes.php' === $item[2] || 'theme-editor.php' === $item[2] || 0 === strpos( $item[2], 'customize.php' ) ) {
   318 			continue;
   312 			continue;
   352 			}
   346 			}
   353 		}
   347 		}
   354 	}
   348 	}
   355 }
   349 }
   356 
   350 
   357 ?>
       
   358 
       
   359 <?php
       
   360 $class_name = 'theme-browser';
   351 $class_name = 'theme-browser';
   361 if ( ! empty( $_GET['search'] ) ) {
   352 if ( ! empty( $_GET['search'] ) ) {
   362 	$class_name .= ' search-loading';
   353 	$class_name .= ' search-loading';
   363 }
   354 }
   364 ?>
   355 ?>
   377 	$active_class = '';
   368 	$active_class = '';
   378 	if ( $theme['active'] ) {
   369 	if ( $theme['active'] ) {
   379 		$active_class = ' active';
   370 		$active_class = ' active';
   380 	}
   371 	}
   381 	?>
   372 	?>
   382 <div class="theme<?php echo $active_class; ?>" tabindex="0" aria-describedby="<?php echo $aria_action . ' ' . $aria_name; ?>">
   373 <div class="theme<?php echo $active_class; ?>">
   383 	<?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
   374 	<?php if ( ! empty( $theme['screenshot'][0] ) ) { ?>
   384 		<div class="theme-screenshot">
   375 		<div class="theme-screenshot">
   385 			<img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
   376 			<img src="<?php echo $theme['screenshot'][0]; ?>" alt="" />
   386 		</div>
   377 		</div>
   387 	<?php } else { ?>
   378 	<?php } else { ?>
   510 		}
   501 		}
   511 		echo '</p></div>';
   502 		echo '</p></div>';
   512 	}
   503 	}
   513 	?>
   504 	?>
   514 
   505 
   515 	<span class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></span>
   506 	<?php
       
   507 	/* translators: %s: Theme name. */
       
   508 	$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), $theme['name'] );
       
   509 	?>
       
   510 	<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="<?php echo $aria_action; ?>"><?php _e( 'Theme Details' ); ?></button>
   516 	<div class="theme-author">
   511 	<div class="theme-author">
   517 		<?php
   512 		<?php
   518 		/* translators: %s: Theme author name. */
   513 		/* translators: %s: Theme author name. */
   519 		printf( __( 'By %s' ), $theme['author'] );
   514 		printf( __( 'By %s' ), $theme['author'] );
   520 		?>
   515 		?>
   529 			<h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
   524 			<h2 class="theme-name" id="<?php echo $aria_name; ?>"><?php echo $theme['name']; ?></h2>
   530 		<?php } ?>
   525 		<?php } ?>
   531 
   526 
   532 		<div class="theme-actions">
   527 		<div class="theme-actions">
   533 		<?php if ( $theme['active'] ) { ?>
   528 		<?php if ( $theme['active'] ) { ?>
   534 			<?php if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   529 			<?php
   535 				<a class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
   530 			if ( $theme['actions']['customize'] && current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
       
   531 				/* translators: %s: Theme name. */
       
   532 				$customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), $theme['name'] );
       
   533 				?>
       
   534 				<a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Customize' ); ?></a>
   536 			<?php } ?>
   535 			<?php } ?>
   537 		<?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
   536 		<?php } elseif ( $theme['compatibleWP'] && $theme['compatiblePHP'] ) { ?>
   538 			<?php
   537 			<?php
   539 			/* translators: %s: Theme name. */
   538 			/* translators: %s: Theme name. */
   540 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   539 			$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   541 			?>
   540 			?>
   542 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   541 			<a class="button activate" href="<?php echo $theme['actions']['activate']; ?>" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
   543 			<?php if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) { ?>
   542 			<?php
   544 				<a class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   543 			if ( current_user_can( 'edit_theme_options' ) && current_user_can( 'customize' ) ) {
       
   544 				/* translators: %s: Theme name. */
       
   545 				$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
       
   546 				?>
       
   547 				<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="<?php echo $theme['actions']['customize']; ?>"><?php _e( 'Live Preview' ); ?></a>
   545 			<?php } ?>
   548 			<?php } ?>
   546 		<?php } else { ?>
   549 		<?php } else { ?>
   547 			<?php
   550 			<?php
   548 			/* translators: %s: Theme name. */
   551 			/* translators: %s: Theme name. */
   549 			$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   552 			$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   857 				?>
   860 				?>
   858 			<# } #>
   861 			<# } #>
   859 		</p></div>
   862 		</p></div>
   860 	<# } #>
   863 	<# } #>
   861 
   864 
   862 	<span class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></span>
   865 	<?php
       
   866 	/* translators: %s: Theme name. */
       
   867 	$details_aria_label = sprintf( _x( 'View Theme Details for %s', 'theme' ), '{{ data.name }}' );
       
   868 	?>
       
   869 	<button type="button" aria-label="<?php echo esc_attr( $details_aria_label ); ?>" class="more-details" id="{{ data.id }}-action"><?php _e( 'Theme Details' ); ?></button>
   863 	<div class="theme-author">
   870 	<div class="theme-author">
   864 		<?php
   871 		<?php
   865 		/* translators: %s: Theme author name. */
   872 		/* translators: %s: Theme author name. */
   866 		printf( __( 'By %s' ), '{{{ data.author }}}' );
   873 		printf( __( 'By %s' ), '{{{ data.author }}}' );
   867 		?>
   874 		?>
   877 		<# } #>
   884 		<# } #>
   878 
   885 
   879 		<div class="theme-actions">
   886 		<div class="theme-actions">
   880 			<# if ( data.active ) { #>
   887 			<# if ( data.active ) { #>
   881 				<# if ( data.actions.customize ) { #>
   888 				<# if ( data.actions.customize ) { #>
   882 					<a class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
   889 					<?php
       
   890 					/* translators: %s: Theme name. */
       
   891 					$customize_aria_label = sprintf( _x( 'Customize %s', 'theme' ), '{{ data.name }}' );
       
   892 					?>
       
   893 					<a aria-label="<?php echo esc_attr( $customize_aria_label ); ?>" class="button button-primary customize load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Customize' ); ?></a>
   883 				<# } #>
   894 				<# } #>
   884 			<# } else { #>
   895 			<# } else { #>
   885 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
   896 				<# if ( data.compatibleWP && data.compatiblePHP ) { #>
   886 					<?php
   897 					<?php
   887 					/* translators: %s: Theme name. */
   898 					/* translators: %s: Theme name. */
   888 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   899 					$aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
   889 					?>
   900 					?>
   890 					<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
   901 					<a class="button activate" href="{{{ data.actions.activate }}}" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Activate' ); ?></a>
   891 					<a class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
   902 					<?php
       
   903 					/* translators: %s: Theme name. */
       
   904 					$live_preview_aria_label = sprintf( _x( 'Live Preview %s', 'theme' ), '{{ data.name }}' );
       
   905 					?>
       
   906 					<a aria-label="<?php echo esc_attr( $live_preview_aria_label ); ?>" class="button button-primary load-customize hide-if-no-customize" href="{{{ data.actions.customize }}}"><?php _e( 'Live Preview' ); ?></a>
   892 				<# } else { #>
   907 				<# } else { #>
   893 					<?php
   908 					<?php
   894 					/* translators: %s: Theme name. */
   909 					/* translators: %s: Theme name. */
   895 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   910 					$aria_label = sprintf( _x( 'Cannot Activate %s', 'theme' ), '{{ data.name }}' );
   896 					?>
   911 					?>
  1115 					<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
  1130 					<a class="button button-primary hide-if-no-customize disabled"><?php _e( 'Live Preview' ); ?></a>
  1116 				<# } #>
  1131 				<# } #>
  1117 			</div>
  1132 			</div>
  1118 
  1133 
  1119 			<# if ( ! data.active && data.actions['delete'] ) { #>
  1134 			<# if ( ! data.active && data.actions['delete'] ) { #>
  1120 				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme"><?php _e( 'Delete' ); ?></a>
  1135 				<?php
       
  1136 				/* translators: %s: Theme name. */
       
  1137 				$aria_label = sprintf( _x( 'Delete %s', 'theme' ), '{{ data.name }}' );
       
  1138 				?>
       
  1139 				<a href="{{{ data.actions['delete'] }}}" class="button delete-theme" aria-label="<?php echo $aria_label; ?>"><?php _e( 'Delete' ); ?></a>
  1121 			<# } #>
  1140 			<# } #>
  1122 		</div>
  1141 		</div>
  1123 	</div>
  1142 	</div>
  1124 </script>
  1143 </script>
  1125 
  1144