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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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(
  28. $manager,
  29. 'background_image',
  30. array(
  31. 'label' => __( 'Background Image' ),
  32. 'section' => 'background_image',
  33. )
  34. );
  35. }
  36. /**
  37. * Enqueue control related scripts/styles.
  38. *
  39. * @since 4.1.0
  40. */
  41. public function enqueue() {
  42. parent::enqueue();
  43. $custom_background = get_theme_support( 'custom-background' );
  44. wp_localize_script(
  45. 'customize-controls',
  46. '_wpCustomizeBackground',
  47. array(
  48. 'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(),
  49. 'nonces' => array(
  50. 'add' => wp_create_nonce( 'background-add' ),
  51. ),
  52. )
  53. );
  54. }
  55. }