wp/wp-includes/customize/class-wp-customize-cropped-image-control.php
changeset 7 cf61fcea0001
child 21 48c4eec2b7e6
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     1 <?php
       
     2 /**
       
     3  * Customize API: WP_Customize_Cropped_Image_Control class
       
     4  *
       
     5  * @package WordPress
       
     6  * @subpackage Customize
       
     7  * @since 4.4.0
       
     8  */
       
     9 
       
    10 /**
       
    11  * Customize Cropped Image Control class.
       
    12  *
       
    13  * @since 4.3.0
       
    14  *
       
    15  * @see WP_Customize_Image_Control
       
    16  */
       
    17 class WP_Customize_Cropped_Image_Control extends WP_Customize_Image_Control {
       
    18 
       
    19 	/**
       
    20 	 * Control type.
       
    21 	 *
       
    22 	 * @since 4.3.0
       
    23 	 * @var string
       
    24 	 */
       
    25 	public $type = 'cropped_image';
       
    26 
       
    27 	/**
       
    28 	 * Suggested width for cropped image.
       
    29 	 *
       
    30 	 * @since 4.3.0
       
    31 	 * @var int
       
    32 	 */
       
    33 	public $width = 150;
       
    34 
       
    35 	/**
       
    36 	 * Suggested height for cropped image.
       
    37 	 *
       
    38 	 * @since 4.3.0
       
    39 	 * @var int
       
    40 	 */
       
    41 	public $height = 150;
       
    42 
       
    43 	/**
       
    44 	 * Whether the width is flexible.
       
    45 	 *
       
    46 	 * @since 4.3.0
       
    47 	 * @var bool
       
    48 	 */
       
    49 	public $flex_width = false;
       
    50 
       
    51 	/**
       
    52 	 * Whether the height is flexible.
       
    53 	 *
       
    54 	 * @since 4.3.0
       
    55 	 * @var bool
       
    56 	 */
       
    57 	public $flex_height = false;
       
    58 
       
    59 	/**
       
    60 	 * Enqueue control related scripts/styles.
       
    61 	 *
       
    62 	 * @since 4.3.0
       
    63 	 */
       
    64 	public function enqueue() {
       
    65 		wp_enqueue_script( 'customize-views' );
       
    66 
       
    67 		parent::enqueue();
       
    68 	}
       
    69 
       
    70 	/**
       
    71 	 * Refresh the parameters passed to the JavaScript via JSON.
       
    72 	 *
       
    73 	 * @since 4.3.0
       
    74 	 *
       
    75 	 * @see WP_Customize_Control::to_json()
       
    76 	 */
       
    77 	public function to_json() {
       
    78 		parent::to_json();
       
    79 
       
    80 		$this->json['width']       = absint( $this->width );
       
    81 		$this->json['height']      = absint( $this->height );
       
    82 		$this->json['flex_width']  = absint( $this->flex_width );
       
    83 		$this->json['flex_height'] = absint( $this->flex_height );
       
    84 	}
       
    85 
       
    86 }