wp/wp-includes/customize/class-wp-customize-header-image-control.php
changeset 21 48c4eec2b7e6
parent 18 be944660c56a
child 22 8c2e4d02f4ef
equal deleted inserted replaced
20:7b1b88e27a20 21:48c4eec2b7e6
    13  * @since 3.4.0
    13  * @since 3.4.0
    14  *
    14  *
    15  * @see WP_Customize_Image_Control
    15  * @see WP_Customize_Image_Control
    16  */
    16  */
    17 class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
    17 class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
       
    18 
    18 	/**
    19 	/**
    19 	 * Customize control type.
    20 	 * Customize control type.
    20 	 *
    21 	 *
    21 	 * @since 4.2.0
    22 	 * @since 4.2.0
    22 	 * @var string
    23 	 * @var string
    59 				'section'  => 'header_image',
    60 				'section'  => 'header_image',
    60 				'removed'  => 'remove-header',
    61 				'removed'  => 'remove-header',
    61 				'get_url'  => 'get_header_image',
    62 				'get_url'  => 'get_header_image',
    62 			)
    63 			)
    63 		);
    64 		);
    64 
       
    65 	}
    65 	}
    66 
    66 
    67 	/**
    67 	/**
    68 	 */
    68 	 */
    69 	public function enqueue() {
    69 	public function enqueue() {
   128 			</button>
   128 			</button>
   129 
   129 
   130 			<# } else { #>
   130 			<# } else { #>
   131 
   131 
   132 			<button type="button" class="choice thumbnail"
   132 			<button type="button" class="choice thumbnail"
   133 				data-customize-image-value="{{{data.header.url}}}"
   133 				data-customize-image-value="{{data.header.url}}"
   134 				data-customize-header-image-data="{{JSON.stringify(data.header)}}">
   134 				data-customize-header-image-data="{{JSON.stringify(data.header)}}">
   135 				<span class="screen-reader-text"><?php _e( 'Set image' ); ?></span>
   135 				<span class="screen-reader-text">
   136 				<img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" />
   136 					<?php
       
   137 					/* translators: Hidden accessibility text. */
       
   138 					_e( 'Set image' );
       
   139 					?>
       
   140 				</span>
       
   141 				<img src="{{data.header.thumbnail_url}}" alt="{{data.header.alt_text || data.header.description}}" />
   137 			</button>
   142 			</button>
   138 
   143 
   139 			<# if ( data.type === 'uploaded' ) { #>
   144 			<# if ( data.type === 'uploaded' ) { #>
   140 				<button type="button" class="dashicons dashicons-no close"><span class="screen-reader-text"><?php _e( 'Remove image' ); ?></span></button>
   145 				<button type="button" class="dashicons dashicons-no close">
       
   146 					<span class="screen-reader-text">
       
   147 						<?php
       
   148 						/* translators: Hidden accessibility text. */
       
   149 						_e( 'Remove image' );
       
   150 						?>
       
   151 					</span>
       
   152 				</button>
   141 			<# } #>
   153 			<# } #>
   142 
   154 
   143 			<# } #>
   155 			<# } #>
   144 		</script>
   156 		</script>
   145 
   157 
   156 				<# } #>
   168 				<# } #>
   157 			</div>
   169 			</div>
   158 
   170 
   159 				<# } else { #>
   171 				<# } else { #>
   160 
   172 
   161 			<img src="{{{data.header.thumbnail_url}}}" alt="{{{data.header.alt_text || data.header.description}}}" />
   173 			<img src="{{data.header.thumbnail_url}}" alt="{{data.header.alt_text || data.header.description}}" />
   162 
   174 
   163 				<# } #>
   175 				<# } #>
   164 			<# } else { #>
   176 			<# } else { #>
   165 
   177 
   166 			<div class="placeholder">
   178 			<div class="placeholder">
   198 			?>
   210 			?>
   199 			<div class="customize-control-notifications-container"></div>
   211 			<div class="customize-control-notifications-container"></div>
   200 			<p class="customizer-section-intro customize-control-description">
   212 			<p class="customizer-section-intro customize-control-description">
   201 				<?php
   213 				<?php
   202 				if ( current_theme_supports( 'custom-header', 'video' ) ) {
   214 				if ( current_theme_supports( 'custom-header', 'video' ) ) {
   203 					_e( 'Click &#8220;Add new image&#8221; to upload an image file from your computer. Your theme works best with an image that matches the size of your video &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' );
   215 					_e( 'Click &#8220;Add New Image&#8221; to upload an image file from your computer. Your theme works best with an image that matches the size of your video &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' );
   204 				} elseif ( $width && $height ) {
   216 				} elseif ( $width && $height ) {
   205 					printf(
   217 					printf(
   206 						/* translators: %s: Header size in pixels. */
   218 						/* translators: %s: Header size in pixels. */
   207 						__( 'Click &#8220;Add new image&#8221; to upload an image file from your computer. Your theme works best with an image with a header size of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   219 						__( 'Click &#8220;Add New Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header size of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   208 						sprintf( '<strong>%s &times; %s</strong>', $width, $height )
   220 						sprintf( '<strong>%s &times; %s</strong>', $width, $height )
   209 					);
   221 					);
   210 				} elseif ( $width ) {
   222 				} elseif ( $width ) {
   211 					printf(
   223 					printf(
   212 						/* translators: %s: Header width in pixels. */
   224 						/* translators: %s: Header width in pixels. */
   213 						__( 'Click &#8220;Add new image&#8221; to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   225 						__( 'Click &#8220;Add New Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header width of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   214 						sprintf( '<strong>%s</strong>', $width )
   226 						sprintf( '<strong>%s</strong>', $width )
   215 					);
   227 					);
   216 				} else {
   228 				} else {
   217 					printf(
   229 					printf(
   218 						/* translators: %s: Header height in pixels. */
   230 						/* translators: %s: Header height in pixels. */
   219 						__( 'Click &#8220;Add new image&#8221; to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   231 						__( 'Click &#8220;Add New Image&#8221; to upload an image file from your computer. Your theme works best with an image with a header height of %s pixels &#8212; you&#8217;ll be able to crop your image once you upload it for a perfect fit.' ),
   220 						sprintf( '<strong>%s</strong>', $height )
   232 						sprintf( '<strong>%s</strong>', $height )
   221 					);
   233 					);
   222 				}
   234 				}
   223 				?>
   235 				?>
   224 			</p>
   236 			</p>
   232 				</div>
   244 				</div>
   233 			</div>
   245 			</div>
   234 			<div class="actions">
   246 			<div class="actions">
   235 				<?php if ( current_user_can( 'upload_files' ) ) : ?>
   247 				<?php if ( current_user_can( 'upload_files' ) ) : ?>
   236 				<button type="button"<?php echo $visibility; ?> class="button remove" aria-label="<?php esc_attr_e( 'Hide header image' ); ?>"><?php _e( 'Hide image' ); ?></button>
   248 				<button type="button"<?php echo $visibility; ?> class="button remove" aria-label="<?php esc_attr_e( 'Hide header image' ); ?>"><?php _e( 'Hide image' ); ?></button>
   237 				<button type="button" class="button new" id="header_image-button" aria-label="<?php esc_attr_e( 'Add new header image' ); ?>"><?php _e( 'Add new image' ); ?></button>
   249 				<button type="button" class="button new" id="header_image-button" aria-label="<?php esc_attr_e( 'Add New Header Image' ); ?>"><?php _e( 'Add New Image' ); ?></button>
   238 				<?php endif; ?>
   250 				<?php endif; ?>
   239 			</div>
   251 			</div>
   240 			<div class="choices">
   252 			<div class="choices">
   241 				<span class="customize-control-title header-previously-uploaded">
   253 				<span class="customize-control-title header-previously-uploaded">
   242 					<?php _ex( 'Previously uploaded', 'custom headers' ); ?>
   254 					<?php _ex( 'Previously uploaded', 'custom headers' ); ?>