wp/wp-includes/customize/class-wp-customize-theme-control.php
changeset 16 a86126ab1dd4
parent 9 177826044cd9
child 19 3d72ae0968f4
equal deleted inserted replaced
15:3d4e9c994f10 16:a86126ab1dd4
    55 	 * Render a JS template for theme display.
    55 	 * Render a JS template for theme display.
    56 	 *
    56 	 *
    57 	 * @since 4.2.0
    57 	 * @since 4.2.0
    58 	 */
    58 	 */
    59 	public function content_template() {
    59 	public function content_template() {
    60 		/* translators: %s: theme name */
    60 		/* translators: %s: Theme name. */
    61 		$details_label = sprintf( __( 'Details for theme: %s' ), '{{ data.theme.name }}' );
    61 		$details_label = sprintf( __( 'Details for theme: %s' ), '{{ data.theme.name }}' );
    62 		/* translators: %s: theme name */
    62 		/* translators: %s: Theme name. */
    63 		$customize_label = sprintf( __( 'Customize theme: %s' ), '{{ data.theme.name }}' );
    63 		$customize_label = sprintf( __( 'Customize theme: %s' ), '{{ data.theme.name }}' );
    64 		/* translators: %s: theme name */
    64 		/* translators: %s: Theme name. */
    65 		$preview_label = sprintf( __( 'Live preview theme: %s' ), '{{ data.theme.name }}' );
    65 		$preview_label = sprintf( __( 'Live preview theme: %s' ), '{{ data.theme.name }}' );
    66 		/* translators: %s: theme name */
    66 		/* translators: %s: Theme name. */
    67 		$install_label = sprintf( __( 'Install and preview theme: %s' ), '{{ data.theme.name }}' );
    67 		$install_label = sprintf( __( 'Install and preview theme: %s' ), '{{ data.theme.name }}' );
    68 		?>
    68 		?>
    69 		<# if ( data.theme.active ) { #>
    69 		<# if ( data.theme.active ) { #>
    70 			<div class="theme active" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action">
    70 			<div class="theme active" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action">
    71 		<# } else { #>
    71 		<# } else { #>
    82 
    82 
    83 			<span class="more-details theme-details" id="{{ data.section }}-{{ data.theme.id }}-action" aria-label="<?php echo esc_attr( $details_label ); ?>"><?php _e( 'Theme Details' ); ?></span>
    83 			<span class="more-details theme-details" id="{{ data.section }}-{{ data.theme.id }}-action" aria-label="<?php echo esc_attr( $details_label ); ?>"><?php _e( 'Theme Details' ); ?></span>
    84 
    84 
    85 			<div class="theme-author">
    85 			<div class="theme-author">
    86 			<?php
    86 			<?php
    87 				/* translators: Theme author name */
    87 				/* translators: Theme author name. */
    88 				printf( _x( 'By %s', 'theme author' ), '{{ data.theme.author }}' );
    88 				printf( _x( 'By %s', 'theme author' ), '{{ data.theme.author }}' );
    89 			?>
    89 			?>
    90 			</div>
    90 			</div>
    91 
    91 
    92 			<# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
    92 			<# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
    93 				<div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
    93 				<# if ( data.theme.updateResponse.compatibleWP && data.theme.updateResponse.compatiblePHP ) { #>
    94 					<p>
    94 					<div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
       
    95 						<p>
       
    96 							<?php
       
    97 							if ( is_multisite() ) {
       
    98 								_e( 'New version available.' );
       
    99 							} else {
       
   100 								printf(
       
   101 									/* translators: %s: "Update now" button. */
       
   102 									__( 'New version available. %s' ),
       
   103 									'<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
       
   104 								);
       
   105 							}
       
   106 							?>
       
   107 						</p>
       
   108 					</div>
       
   109 				<# } else { #>
       
   110 					<div class="update-message notice inline notice-error notice-alt" data-slug="{{ data.theme.id }}">
       
   111 						<p>
       
   112 							<# if ( ! data.theme.updateResponse.compatibleWP && ! data.theme.updateResponse.compatiblePHP ) { #>
       
   113 								<?php
       
   114 								printf(
       
   115 									/* translators: %s: Theme name. */
       
   116 									__( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
       
   117 									'{{{ data.theme.name }}}'
       
   118 								);
       
   119 								if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
       
   120 									printf(
       
   121 										/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
       
   122 										' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
       
   123 										self_admin_url( 'update-core.php' ),
       
   124 										esc_url( wp_get_update_php_url() )
       
   125 									);
       
   126 									wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   127 								} elseif ( current_user_can( 'update_core' ) ) {
       
   128 									printf(
       
   129 										/* translators: %s: URL to WordPress Updates screen. */
       
   130 										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   131 										self_admin_url( 'update-core.php' )
       
   132 									);
       
   133 								} elseif ( current_user_can( 'update_php' ) ) {
       
   134 									printf(
       
   135 										/* translators: %s: URL to Update PHP page. */
       
   136 										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   137 										esc_url( wp_get_update_php_url() )
       
   138 									);
       
   139 									wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   140 								}
       
   141 								?>
       
   142 							<# } else if ( ! data.theme.updateResponse.compatibleWP ) { #>
       
   143 								<?php
       
   144 								printf(
       
   145 									/* translators: %s: Theme name. */
       
   146 									__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
       
   147 									'{{{ data.theme.name }}}'
       
   148 								);
       
   149 								if ( current_user_can( 'update_core' ) ) {
       
   150 									printf(
       
   151 										/* translators: %s: URL to WordPress Updates screen. */
       
   152 										' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   153 										self_admin_url( 'update-core.php' )
       
   154 									);
       
   155 								}
       
   156 								?>
       
   157 							<# } else if ( ! data.theme.updateResponse.compatiblePHP ) { #>
       
   158 								<?php
       
   159 								printf(
       
   160 									/* translators: %s: Theme name. */
       
   161 									__( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
       
   162 									'{{{ data.theme.name }}}'
       
   163 								);
       
   164 								if ( current_user_can( 'update_php' ) ) {
       
   165 									printf(
       
   166 										/* translators: %s: URL to Update PHP page. */
       
   167 										' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   168 										esc_url( wp_get_update_php_url() )
       
   169 									);
       
   170 									wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   171 								}
       
   172 								?>
       
   173 							<# } #>
       
   174 						</p>
       
   175 					</div>
       
   176 				<# } #>
       
   177 			<# } #>
       
   178 
       
   179 			<# if ( ! data.theme.compatibleWP || ! data.theme.compatiblePHP ) { #>
       
   180 				<div class="notice notice-error notice-alt"><p>
       
   181 					<# if ( ! data.theme.compatibleWP && ! data.theme.compatiblePHP ) { #>
    95 						<?php
   182 						<?php
    96 						if ( is_multisite() ) {
   183 						_e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
    97 							_e( 'New version available.' );
   184 						if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
    98 						} else {
   185 							printf(
    99 							printf(
   186 								/* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
   100 								/* translators: %s: "Update now" button */
   187 								' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
   101 								__( 'New version available. %s' ),
   188 								self_admin_url( 'update-core.php' ),
   102 								'<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
   189 								esc_url( wp_get_update_php_url() )
   103 							);
   190 							);
       
   191 							wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   192 						} elseif ( current_user_can( 'update_core' ) ) {
       
   193 							printf(
       
   194 								/* translators: %s: URL to WordPress Updates screen. */
       
   195 								' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   196 								self_admin_url( 'update-core.php' )
       
   197 							);
       
   198 						} elseif ( current_user_can( 'update_php' ) ) {
       
   199 							printf(
       
   200 								/* translators: %s: URL to Update PHP page. */
       
   201 								' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   202 								esc_url( wp_get_update_php_url() )
       
   203 							);
       
   204 							wp_update_php_annotation( '</p><p><em>', '</em>' );
   104 						}
   205 						}
   105 						?>
   206 						?>
   106 					</p>
   207 					<# } else if ( ! data.theme.compatibleWP ) { #>
   107 				</div>
   208 						<?php
       
   209 						_e( 'This theme doesn&#8217;t work with your version of WordPress.' );
       
   210 						if ( current_user_can( 'update_core' ) ) {
       
   211 							printf(
       
   212 								/* translators: %s: URL to WordPress Updates screen. */
       
   213 								' ' . __( '<a href="%s">Please update WordPress</a>.' ),
       
   214 								self_admin_url( 'update-core.php' )
       
   215 							);
       
   216 						}
       
   217 						?>
       
   218 					<# } else if ( ! data.theme.compatiblePHP ) { #>
       
   219 						<?php
       
   220 						_e( 'This theme doesn&#8217;t work with your version of PHP.' );
       
   221 						if ( current_user_can( 'update_php' ) ) {
       
   222 							printf(
       
   223 								/* translators: %s: URL to Update PHP page. */
       
   224 								' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
       
   225 								esc_url( wp_get_update_php_url() )
       
   226 							);
       
   227 							wp_update_php_annotation( '</p><p><em>', '</em>' );
       
   228 						}
       
   229 						?>
       
   230 					<# } #>
       
   231 				</p></div>
   108 			<# } #>
   232 			<# } #>
   109 
   233 
   110 			<# if ( data.theme.active ) { #>
   234 			<# if ( data.theme.active ) { #>
   111 				<div class="theme-id-container">
   235 				<div class="theme-id-container">
   112 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">
   236 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">
   113 						<?php
   237 						<span><?php _ex( 'Previewing:', 'theme' ); ?></span> {{ data.theme.name }}
   114 						/* translators: %s: theme name */
       
   115 						printf( __( '<span>Previewing:</span> %s' ), '{{ data.theme.name }}' );
       
   116 						?>
       
   117 					</h3>
   238 					</h3>
   118 					<div class="theme-actions">
   239 					<div class="theme-actions">
   119 						<button type="button" class="button button-primary customize-theme" aria-label="<?php echo esc_attr( $customize_label ); ?>"><?php _e( 'Customize' ); ?></button>
   240 						<button type="button" class="button button-primary customize-theme" aria-label="<?php echo esc_attr( $customize_label ); ?>"><?php _e( 'Customize' ); ?></button>
   120 					</div>
   241 					</div>
   121 				</div>
   242 				</div>
   122 				<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
   243 				<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
   123 			<# } else if ( 'installed' === data.theme.type ) { #>
   244 			<# } else if ( 'installed' === data.theme.type ) { #>
   124 				<div class="theme-id-container">
   245 				<div class="theme-id-container">
   125 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
   246 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
   126 					<div class="theme-actions">
   247 					<div class="theme-actions">
   127 						<button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
   248 						<# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
       
   249 							<button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
       
   250 						<# } else { #>
       
   251 							<button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button>
       
   252 						<# } #>
   128 					</div>
   253 					</div>
   129 				</div>
   254 				</div>
   130 				<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
   255 				<div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
   131 			<# } else { #>
   256 			<# } else { #>
   132 				<div class="theme-id-container">
   257 				<div class="theme-id-container">
   133 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
   258 					<h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
   134 					<div class="theme-actions">
   259 					<div class="theme-actions">
   135 						<button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
   260 						<# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
       
   261 							<button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
       
   262 						<# } else { #>
       
   263 							<button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $install_label ); ?>" disabled><?php _e( 'Install &amp; Preview' ); ?></button>
       
   264 						<# } #>
   136 					</div>
   265 					</div>
   137 				</div>
   266 				</div>
   138 			<# } #>
   267 			<# } #>
   139 		</div>
   268 		</div>
   140 		<?php
   269 		<?php