|
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 * @var string |
|
26 */ |
|
27 public $type = 'site_icon'; |
|
28 |
|
29 /** |
|
30 * Constructor. |
|
31 * |
|
32 * @since 4.3.0 |
|
33 * |
|
34 * @param WP_Customize_Manager $manager Customizer bootstrap instance. |
|
35 * @param string $id Control ID. |
|
36 * @param array $args Optional. Arguments to override class property defaults. |
|
37 */ |
|
38 public function __construct( $manager, $id, $args = array() ) { |
|
39 parent::__construct( $manager, $id, $args ); |
|
40 add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 ); |
|
41 } |
|
42 |
|
43 /** |
|
44 * Renders a JS template for the content of the site icon control. |
|
45 * |
|
46 * @since 4.5.0 |
|
47 */ |
|
48 public function content_template() { |
|
49 ?> |
|
50 <label for="{{ data.settings['default'] }}-button"> |
|
51 <# if ( data.label ) { #> |
|
52 <span class="customize-control-title">{{ data.label }}</span> |
|
53 <# } #> |
|
54 <# if ( data.description ) { #> |
|
55 <span class="description customize-control-description">{{{ data.description }}}</span> |
|
56 <# } #> |
|
57 </label> |
|
58 |
|
59 <# if ( data.attachment && data.attachment.id ) { #> |
|
60 <div class="attachment-media-view"> |
|
61 <# if ( data.attachment.sizes ) { #> |
|
62 <div class="site-icon-preview wp-clearfix"> |
|
63 <div class="favicon-preview"> |
|
64 <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" alt="" /> |
|
65 |
|
66 <div class="favicon"> |
|
67 <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> |
|
68 </div> |
|
69 <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span> |
|
70 </div> |
|
71 <img class="app-icon-preview" src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="<?php esc_attr_e( 'Preview as an app icon' ); ?>"/> |
|
72 </div> |
|
73 <# } #> |
|
74 <div class="actions"> |
|
75 <# if ( data.canUpload ) { #> |
|
76 <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button> |
|
77 <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['change']; ?></button> |
|
78 <# } #> |
|
79 </div> |
|
80 </div> |
|
81 <# } else { #> |
|
82 <div class="attachment-media-view"> |
|
83 <div class="placeholder"> |
|
84 <?php echo $this->button_labels['placeholder']; ?> |
|
85 </div> |
|
86 <div class="actions"> |
|
87 <# if ( data.defaultAttachment ) { #> |
|
88 <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button> |
|
89 <# } #> |
|
90 <# if ( data.canUpload ) { #> |
|
91 <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['select']; ?></button> |
|
92 <# } #> |
|
93 </div> |
|
94 </div> |
|
95 <# } #> |
|
96 <?php |
|
97 } |
|
98 } |