wppaste
WordPress

WP_Customize_Site_Icon_Control

Since
4.3.0
Source
wp-includes/customize/class-wp-customize-site-icon-control.php:19
Customize Site Icon control class.

Description

Used only for custom functionality in JavaScript.

Compatibility

WordPress
since 4.3.0
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in every tracked release (6.7.7 to 7.1.0).

Properties · 1

$typestringpublic
Control type.

Methods · 2

Source code

class WP_Customize_Site_Icon_Control extends WP_Customize_Cropped_Image_Control { 	/**	 * Control type.	 *	 * @since 4.3.0	 * @var string	 */	public $type = 'site_icon'; 	/**	 * Constructor.	 *	 * @since 4.3.0	 *	 * @see WP_Customize_Control::__construct()	 *	 * @param WP_Customize_Manager $manager Customizer bootstrap instance.	 * @param string               $id      Control ID.	 * @param array                $args    Optional. Arguments to override class property defaults.	 *                                      See WP_Customize_Control::__construct() for information	 *                                      on accepted arguments. Default empty array.	 */	public function __construct( $manager, $id, $args = array() ) {		parent::__construct( $manager, $id, $args );		add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 );	} 	/**	 * Renders a JS template for the content of the site icon control.	 *	 * @since 4.5.0	 */	public function content_template() {		?>		<# if ( data.label ) { #>			<span class="customize-control-title">{{ data.label }}</span>		<# } #> 		<# if ( data.attachment && data.attachment.id ) { #>			<div class="attachment-media-view">				<# if ( data.attachment.sizes ) { #>					<style>						:root{							--site-icon-url: url( '{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}' );						}					</style>					<div class="site-icon-preview customizer">						<div class="direction-wrap">							<img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" class="app-icon-preview" alt="{{								data.attachment.alt ?									wp.i18n.sprintf(										<?php										/* translators: %s: The selected image alt text. */										echo wp_json_encode( __( 'App icon preview: Current image: %s' ) )										?>										,										data.attachment.alt									) :									wp.i18n.sprintf(										<?php										/* translators: %s: The selected image filename. */										echo wp_json_encode( __( 'App icon preview: The current image has no alternative text. The file name is: %s' ) );										?>										,										data.attachment.filename									)							}}" />							<div class="site-icon-preview-browser">								<svg role="img" aria-hidden="true" fill="none" xmlns="http://www.w3.org/2000/svg" class="browser-buttons"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 20a6 6 0 1 1 12 0 6 6 0 0 1-12 0Zm18 0a6 6 0 1 1 12 0 6 6 0 0 1-12 0Zm24-6a6 6 0 1 0 0 12 6 6 0 0 0 0-12Z" /></svg>								<div class="site-icon-preview-tab">									<img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" class="browser-icon-preview" alt="{{										data.attachment.alt ?											wp.i18n.sprintf(												<?php												/* translators: %s: The selected image alt text. */												echo wp_json_encode( __( 'Browser icon preview: Current image: %s' ) );												?>												,												data.attachment.alt

Changelog

Introduced in 4.3.0. Unchanged from 6.7.7 through 7.1.0.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/customize/class-wp-customize-site-icon-control.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.