ru-se.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs

class-wp-customize-background-position-control.php (2960B)


      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(
     43 					'label' => __( 'Top Left' ),
     44 					'icon'  => 'dashicons dashicons-arrow-left-alt',
     45 				),
     46 				'center top' => array(
     47 					'label' => __( 'Top' ),
     48 					'icon'  => 'dashicons dashicons-arrow-up-alt',
     49 				),
     50 				'right top'  => array(
     51 					'label' => __( 'Top Right' ),
     52 					'icon'  => 'dashicons dashicons-arrow-right-alt',
     53 				),
     54 			),
     55 			array(
     56 				'left center'   => array(
     57 					'label' => __( 'Left' ),
     58 					'icon'  => 'dashicons dashicons-arrow-left-alt',
     59 				),
     60 				'center center' => array(
     61 					'label' => __( 'Center' ),
     62 					'icon'  => 'background-position-center-icon',
     63 				),
     64 				'right center'  => array(
     65 					'label' => __( 'Right' ),
     66 					'icon'  => 'dashicons dashicons-arrow-right-alt',
     67 				),
     68 			),
     69 			array(
     70 				'left bottom'   => array(
     71 					'label' => __( 'Bottom Left' ),
     72 					'icon'  => 'dashicons dashicons-arrow-left-alt',
     73 				),
     74 				'center bottom' => array(
     75 					'label' => __( 'Bottom' ),
     76 					'icon'  => 'dashicons dashicons-arrow-down-alt',
     77 				),
     78 				'right bottom'  => array(
     79 					'label' => __( 'Bottom Right' ),
     80 					'icon'  => 'dashicons dashicons-arrow-right-alt',
     81 				),
     82 			),
     83 		);
     84 		?>
     85 		<# if ( data.label ) { #>
     86 			<span class="customize-control-title">{{{ data.label }}}</span>
     87 		<# } #>
     88 		<# if ( data.description ) { #>
     89 			<span class="description customize-control-description">{{{ data.description }}}</span>
     90 		<# } #>
     91 		<div class="customize-control-content">
     92 			<fieldset>
     93 				<legend class="screen-reader-text"><span><?php _e( 'Image Position' ); ?></span></legend>
     94 				<div class="background-position-control">
     95 				<?php foreach ( $options as $group ) : ?>
     96 					<div class="button-group">
     97 					<?php foreach ( $group as $value => $input ) : ?>
     98 						<label>
     99 							<input class="ui-helper-hidden-accessible" name="background-position" type="radio" value="<?php echo esc_attr( $value ); ?>">
    100 							<span class="button display-options position"><span class="<?php echo esc_attr( $input['icon'] ); ?>" aria-hidden="true"></span></span>
    101 							<span class="screen-reader-text"><?php echo $input['label']; ?></span>
    102 						</label>
    103 					<?php endforeach; ?>
    104 					</div>
    105 				<?php endforeach; ?>
    106 				</div>
    107 			</fieldset>
    108 		</div>
    109 		<?php
    110 	}
    111 }