wp/wp-includes/customize/class-wp-customize-background-position-control.php
changeset 7 cf61fcea0001
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
       
     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 	 * @var string
       
    24 	 */
       
    25 	public $type = 'background_position';
       
    26 
       
    27 	/**
       
    28 	 * Don't render the control content from PHP, as it's rendered via JS on load.
       
    29 	 *
       
    30 	 * @since 4.7.0
       
    31 	 */
       
    32 	public function render_content() {}
       
    33 
       
    34 	/**
       
    35 	 * Render a JS template for the content of the position control.
       
    36 	 *
       
    37 	 * @since 4.7.0
       
    38 	 */
       
    39 	public function content_template() {
       
    40 		$options = array(
       
    41 			array(
       
    42 				'left top'   => array( 'label' => __( 'Top Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
       
    43 				'center top' => array( 'label' => __( 'Top' ), 'icon' => 'dashicons dashicons-arrow-up-alt' ),
       
    44 				'right top'  => array( 'label' => __( 'Top Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
       
    45 			),
       
    46 			array(
       
    47 				'left center'   => array( 'label' => __( 'Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
       
    48 				'center center' => array( 'label' => __( 'Center' ), 'icon' => 'background-position-center-icon' ),
       
    49 				'right center'  => array( 'label' => __( 'Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
       
    50 			),
       
    51 			array(
       
    52 				'left bottom'   => array( 'label' => __( 'Bottom Left' ), 'icon' => 'dashicons dashicons-arrow-left-alt' ),
       
    53 				'center bottom' => array( 'label' => __( 'Bottom' ), 'icon' => 'dashicons dashicons-arrow-down-alt' ),
       
    54 				'right bottom'  => array( 'label' => __( 'Bottom Right' ), 'icon' => 'dashicons dashicons-arrow-right-alt' ),
       
    55 			),
       
    56 		);
       
    57 		?>
       
    58 		<# if ( data.label ) { #>
       
    59 			<span class="customize-control-title">{{{ data.label }}}</span>
       
    60 		<# } #>
       
    61 		<# if ( data.description ) { #>
       
    62 			<span class="description customize-control-description">{{{ data.description }}}</span>
       
    63 		<# } #>
       
    64 		<div class="customize-control-content">
       
    65 			<fieldset>
       
    66 				<legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend>
       
    67 				<div class="background-position-control">
       
    68 				<?php foreach ( $options as $group ) : ?>
       
    69 					<div class="button-group">
       
    70 					<?php foreach ( $group as $value => $input ) : ?>
       
    71 						<label>
       
    72 							<input class="screen-reader-text" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>">
       
    73 							<span class="button display-options position"><span class="<?php echo esc_attr( $input['icon'] ); ?>" aria-hidden="true"></span></span>
       
    74 							<span class="screen-reader-text"><?php echo $input['label']; ?></span>
       
    75 						</label>
       
    76 					<?php endforeach; ?>
       
    77 					</div>
       
    78 				<?php endforeach; ?>
       
    79 				</div>
       
    80 			</fieldset>
       
    81 		</div>
       
    82 		<?php
       
    83 	}
       
    84 }