class-wp-customize-background-image-control.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * Customize API: WP_Customize_Background_Image_Control class
  4. *
  5. * @package WordPress
  6. * @subpackage Customize
  7. * @since 4.4.0
  8. */
  9. /**
  10. * Customize Background Image Control class.
  11. *
  12. * @since 3.4.0
  13. *
  14. * @see WP_Customize_Image_Control
  15. */
  16. class WP_Customize_Background_Image_Control extends WP_Customize_Image_Control {
  17. public $type = 'background';
  18. /**
  19. * Constructor.
  20. *
  21. * @since 3.4.0
  22. * @uses WP_Customize_Image_Control::__construct()
  23. *
  24. * @param WP_Customize_Manager $manager Customizer bootstrap instance.
  25. */
  26. public function __construct( $manager ) {
  27. parent::__construct( $manager, 'background_image', array(
  28. 'label' => __( 'Background Image' ),
  29. 'section' => 'background_image',
  30. ) );
  31. }
  32. /**
  33. * Enqueue control related scripts/styles.
  34. *
  35. * @since 4.1.0
  36. */
  37. public function enqueue() {
  38. parent::enqueue();
  39. $custom_background = get_theme_support( 'custom-background' );
  40. wp_localize_script( 'customize-controls', '_wpCustomizeBackground', array(
  41. 'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(),
  42. 'nonces' => array(
  43. 'add' => wp_create_nonce( 'background-add' ),
  44. ),
  45. ) );
  46. }
  47. }