/wp-includes/customize/class-wp-customize-background-position-control.php

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