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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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. /**
  18. * Customize control type.
  19. *
  20. * @since 4.1.0
  21. * @var string
  22. */
  23. public $type = 'background';
  24. /**
  25. * Constructor.
  26. *
  27. * @since 3.4.0
  28. * @uses WP_Customize_Image_Control::__construct()
  29. *
  30. * @param WP_Customize_Manager $manager Customizer bootstrap instance.
  31. */
  32. public function __construct( $manager ) {
  33. parent::__construct(
  34. $manager,
  35. 'background_image',
  36. array(
  37. 'label' => __( 'Background Image' ),
  38. 'section' => 'background_image',
  39. )
  40. );
  41. }
  42. /**
  43. * Enqueue control related scripts/styles.
  44. *
  45. * @since 4.1.0
  46. */
  47. public function enqueue() {
  48. parent::enqueue();
  49. $custom_background = get_theme_support( 'custom-background' );
  50. wp_localize_script(
  51. 'customize-controls',
  52. '_wpCustomizeBackground',
  53. array(
  54. 'defaults' => ! empty( $custom_background[0] ) ? $custom_background[0] : array(),
  55. 'nonces' => array(
  56. 'add' => wp_create_nonce( 'background-add' ),
  57. ),
  58. )
  59. );
  60. }
  61. }