WP_Customize_Background_Position_Control

Customize Background Position Control class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/customize/class-wp-customize-background-position-control.php  
  1. class WP_Customize_Background_Position_Control extends WP_Customize_Control { 
  2.  
  3. /** 
  4. * Type. 
  5. * @since 4.7.0 
  6. * @access public 
  7. * @var string 
  8. */ 
  9. public $type = 'background_position'; 
  10.  
  11. /** 
  12. * Don't render the control content from PHP, as it's rendered via JS on load. 
  13. * @since 4.7.0 
  14. * @access public 
  15. */ 
  16. public function render_content() {} 
  17.  
  18. /** 
  19. * Render a JS template for the content of the position control. 
  20. * @since 4.7.0 
  21. * @access public 
  22. */ 
  23. public function content_template() { 
  24. $options = array( 
  25. array( 
  26. 'left top' => array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),  
  27. 'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ),  
  28. 'right top' => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),  
  29. ),  
  30. array( 
  31. 'left center' => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),  
  32. 'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ),  
  33. 'right center' => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),  
  34. ),  
  35. array( 
  36. 'left bottom' => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),  
  37. 'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ),  
  38. 'right bottom' => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),  
  39. ),  
  40. ); 
  41. ?> 
  42. <# if ( data.label ) { #> 
  43. <span class="customize-control-title">{{{ data.label }}}</span> 
  44. <# } #> 
  45. <# if ( data.description ) { #> 
  46. <span class="description customize-control-description">{{{ data.description }}}</span> 
  47. <# } #> 
  48. <div class="customize-control-content"> 
  49. <fieldset> 
  50. <legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend> 
  51. <div class="background-position-control"> 
  52. <?php foreach ( $options as $group ) : ?> 
  53. <div class="button-group"> 
  54. <?php foreach ( $group as $value => $input ) : ?> 
  55. <label> 
  56. <input class="screen-reader-text" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>"> 
  57. <span class="button display-options position"><span class="<?php echo esc_attr( $input['icon'] ); ?>" aria-hidden="true"></span></span> 
  58. <span class="screen-reader-text"><?php echo $input['label']; ?></span> 
  59. </label> 
  60. <?php endforeach; ?> 
  61. </div> 
  62. <?php endforeach; ?> 
  63. </div> 
  64. </fieldset> 
  65. </div> 
  66. <?php