class-wp-customize-cropped-image-control.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. * Customize Cropped Image Control class.
  11. *
  12. * @since 4.3.0
  13. *
  14. * @see WP_Customize_Image_Control
  15. */
  16. class WP_Customize_Cropped_Image_Control extends WP_Customize_Image_Control {
  17. /**
  18. * Control type.
  19. *
  20. * @since 4.3.0
  21. * @var string
  22. */
  23. public $type = 'cropped_image';
  24. /**
  25. * Suggested width for cropped image.
  26. *
  27. * @since 4.3.0
  28. * @var int
  29. */
  30. public $width = 150;
  31. /**
  32. * Suggested height for cropped image.
  33. *
  34. * @since 4.3.0
  35. * @var int
  36. */
  37. public $height = 150;
  38. /**
  39. * Whether the width is flexible.
  40. *
  41. * @since 4.3.0
  42. * @var bool
  43. */
  44. public $flex_width = false;
  45. /**
  46. * Whether the height is flexible.
  47. *
  48. * @since 4.3.0
  49. * @var bool
  50. */
  51. public $flex_height = false;
  52. /**
  53. * Enqueue control related scripts/styles.
  54. *
  55. * @since 4.3.0
  56. */
  57. public function enqueue() {
  58. wp_enqueue_script( 'customize-views' );
  59. parent::enqueue();
  60. }
  61. /**
  62. * Refresh the parameters passed to the JavaScript via JSON.
  63. *
  64. * @since 4.3.0
  65. *
  66. * @see WP_Customize_Control::to_json()
  67. */
  68. public function to_json() {
  69. parent::to_json();
  70. $this->json['width'] = absint( $this->width );
  71. $this->json['height'] = absint( $this->height );
  72. $this->json['flex_width'] = absint( $this->flex_width );
  73. $this->json['flex_height'] = absint( $this->flex_height );
  74. }
  75. }