WordPress 4.5
[autoinstalls/wordpress.git] / wp-includes / customize / class-wp-customize-site-icon-control.php
1 <?php
2 /**
3  * Customize API: WP_Customize_Site_Icon_Control class
4  *
5  * @package WordPress
6  * @subpackage Customize
7  * @since 4.4.0
8  */
9
10 /**
11  * Customize Site Icon control class.
12  *
13  * Used only for custom functionality in JavaScript.
14  *
15  * @since 4.3.0
16  *
17  * @see WP_Customize_Cropped_Image_Control
18  */
19 class WP_Customize_Site_Icon_Control extends WP_Customize_Cropped_Image_Control {
20
21         /**
22          * Control type.
23          *
24          * @since 4.3.0
25          * @access public
26          * @var string
27          */
28         public $type = 'site_icon';
29
30         /**
31          * Constructor.
32          *
33          * @since 4.3.0
34          * @access public
35          *
36          * @param WP_Customize_Manager $manager Customizer bootstrap instance.
37          * @param string               $id      Control ID.
38          * @param array                $args    Optional. Arguments to override class property defaults.
39          */
40         public function __construct( $manager, $id, $args = array() ) {
41                 parent::__construct( $manager, $id, $args );
42                 add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 );
43         }
44
45         /**
46          * Renders a JS template for the content of the site icon control.
47          *
48          * @since 4.5.0
49          * @access public
50          */
51         public function content_template() {
52                 ?>
53                 <label for="{{ data.settings['default'] }}-button">
54                         <# if ( data.label ) { #>
55                                 <span class="customize-control-title">{{ data.label }}</span>
56                         <# } #>
57                         <# if ( data.description ) { #>
58                                 <span class="description customize-control-description">{{{ data.description }}}</span>
59                         <# } #>
60                 </label>
61
62                 <# if ( data.attachment && data.attachment.id ) { #>
63                 <div class="current">
64                         <div class="container">
65                                 <div class="site-icon-preview">
66                                         <div class="favicon-preview">
67                                                 <img src="<?php echo esc_url( admin_url( 'images/browser.png' ) ); ?>" class="browser-preview" width="182" alt="<?php esc_attr_e( 'Browser interface preview' ); ?>" />
68
69                                                 <div class="favicon">
70                                                         <img id="preview-favicon" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/>
71                                                 </div>
72                                                 <span class="browser-title"><?php bloginfo( 'name' ); ?></span>
73                                         </div>
74                                         <img class="app-icon-preview" src="{{ data.attachment.sizes.full.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/>
75                                 </div>
76                         </div>
77                 </div>
78                 <div class="actions">
79                         <# if ( data.canUpload ) { #>
80                                 <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
81                                 <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['change']; ?></button>
82                                 <div style="clear:both"></div>
83                         <# } #>
84                 </div>
85                 <# } else { #>
86                 <div class="current">
87                         <div class="container">
88                                 <div class="placeholder">
89                                         <div class="inner">
90                                                 <span><?php echo $this->button_labels['placeholder']; ?></span>
91                                         </div>
92                                 </div>
93                         </div>
94                 </div>
95                 <div class="actions">
96                         <# if ( data.defaultAttachment ) { #>
97                                 <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button>
98                         <# } #>
99                         <# if ( data.canUpload ) { #>
100                                 <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['select']; ?></button>
101                         <# } #>
102                         <div style="clear:both"></div>
103                 </div>
104                 <# } #>
105                 <?php
106         }
107 }