wp/wp-admin/includes/class-custom-image-header.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    15 class Custom_Image_Header {
    15 class Custom_Image_Header {
    16 
    16 
    17 	/**
    17 	/**
    18 	 * Callback for administration header.
    18 	 * Callback for administration header.
    19 	 *
    19 	 *
       
    20 	 * @since 2.1.0
    20 	 * @var callable
    21 	 * @var callable
    21 	 * @since 2.1.0
       
    22 	 */
    22 	 */
    23 	public $admin_header_callback;
    23 	public $admin_header_callback;
    24 
    24 
    25 	/**
    25 	/**
    26 	 * Callback for header div.
    26 	 * Callback for header div.
    27 	 *
    27 	 *
       
    28 	 * @since 3.0.0
    28 	 * @var callable
    29 	 * @var callable
       
    30 	 */
       
    31 	public $admin_image_div_callback;
       
    32 
       
    33 	/**
       
    34 	 * Holds default headers.
       
    35 	 *
    29 	 * @since 3.0.0
    36 	 * @since 3.0.0
    30 	 */
       
    31 	public $admin_image_div_callback;
       
    32 
       
    33 	/**
       
    34 	 * Holds default headers.
       
    35 	 *
       
    36 	 * @var array
    37 	 * @var array
    37 	 * @since 3.0.0
       
    38 	 */
    38 	 */
    39 	public $default_headers = array();
    39 	public $default_headers = array();
    40 
    40 
    41 	/**
    41 	/**
    42 	 * Used to trigger a success message when settings updated and set to true.
    42 	 * Used to trigger a success message when settings updated and set to true.
   662 	<p>
   662 	<p>
   663 		<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
   663 		<label for="upload"><?php _e( 'Choose an image from your computer:' ); ?></label><br />
   664 		<input type="file" id="upload" name="import" />
   664 		<input type="file" id="upload" name="import" />
   665 		<input type="hidden" name="action" value="save" />
   665 		<input type="hidden" name="action" value="save" />
   666 			<?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?>
   666 			<?php wp_nonce_field( 'custom-header-upload', '_wpnonce-custom-header-upload' ); ?>
   667 			<?php submit_button( __( 'Upload' ), '', 'submit', false ); ?>
   667 			<?php submit_button( _x( 'Upload', 'verb' ), '', 'submit', false ); ?>
   668 	</p>
   668 	</p>
   669 			<?php
   669 			<?php
   670 			$modal_update_href = add_query_arg(
   670 			$modal_update_href = add_query_arg(
   671 				array(
   671 				array(
   672 					'page'                          => 'custom-header',
   672 					'page'                          => 'custom-header',
   828 	public function step_2() {
   828 	public function step_2() {
   829 		check_admin_referer( 'custom-header-upload', '_wpnonce-custom-header-upload' );
   829 		check_admin_referer( 'custom-header-upload', '_wpnonce-custom-header-upload' );
   830 
   830 
   831 		if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
   831 		if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
   832 			wp_die(
   832 			wp_die(
   833 				'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
   833 				'<h1>' . __( 'An error occurred while processing your header image.' ) . '</h1>' .
   834 				'<p>' . __( 'The active theme does not support uploading a custom header image.' ) . '</p>',
   834 				'<p>' . __( 'The active theme does not support uploading a custom header image. Please ensure your theme supports custom headers and try again.' ) . '</p>',
   835 				403
   835 				403
   836 			);
   836 			);
   837 		}
   837 		}
   838 
   838 
   839 		if ( empty( $_POST ) && isset( $_GET['file'] ) ) {
   839 		if ( empty( $_POST ) && isset( $_GET['file'] ) ) {
  1016 	public function step_3() {
  1016 	public function step_3() {
  1017 		check_admin_referer( 'custom-header-crop-image' );
  1017 		check_admin_referer( 'custom-header-crop-image' );
  1018 
  1018 
  1019 		if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
  1019 		if ( ! current_theme_supports( 'custom-header', 'uploads' ) ) {
  1020 			wp_die(
  1020 			wp_die(
  1021 				'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
  1021 				'<h1>' . __( 'An error occurred while processing your header image.' ) . '</h1>' .
  1022 				'<p>' . __( 'The active theme does not support uploading a custom header image.' ) . '</p>',
  1022 				'<p>' . __( 'The active theme does not support uploading a custom header image. Please ensure your theme supports custom headers and try again.' ) . '</p>',
  1023 				403
  1023 				403
  1024 			);
  1024 			);
  1025 		}
  1025 		}
  1026 
  1026 
  1027 		if ( ! empty( $_POST['skip-cropping'] )
  1027 		if ( ! empty( $_POST['skip-cropping'] )
  1028 			&& ! current_theme_supports( 'custom-header', 'flex-height' )
  1028 			&& ! current_theme_supports( 'custom-header', 'flex-height' )
  1029 			&& ! current_theme_supports( 'custom-header', 'flex-width' )
  1029 			&& ! current_theme_supports( 'custom-header', 'flex-width' )
  1030 		) {
  1030 		) {
  1031 			wp_die(
  1031 			wp_die(
  1032 				'<h1>' . __( 'Something went wrong.' ) . '</h1>' .
  1032 				'<h1>' . __( 'An error occurred while processing your header image.' ) . '</h1>' .
  1033 				'<p>' . __( 'The active theme does not support a flexible sized header image.' ) . '</p>',
  1033 				'<p>' . __( 'The active theme does not support a flexible sized header image.' ) . '</p>',
  1034 				403
  1034 				403
  1035 			);
  1035 			);
  1036 		}
  1036 		}
  1037 
  1037