[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/customize/ -> class-wp-customize-site-icon-control.php (source)

   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       * @see WP_Customize_Control::__construct()
  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       *                                      See WP_Customize_Control::__construct() for information
  40       *                                      on accepted arguments. Default empty array.
  41       */
  42  	public function __construct( $manager, $id, $args = array() ) {
  43          parent::__construct( $manager, $id, $args );
  44          add_action( 'customize_controls_print_styles', 'wp_site_icon', 99 );
  45      }
  46  
  47      /**
  48       * Renders a JS template for the content of the site icon control.
  49       *
  50       * @since 4.5.0
  51       */
  52  	public function content_template() {
  53          ?>
  54          <# if ( data.label ) { #>
  55              <span class="customize-control-title">{{ data.label }}</span>
  56          <# } #>
  57  
  58          <# if ( data.attachment && data.attachment.id ) { #>
  59              <div class="attachment-media-view">
  60                  <# if ( data.attachment.sizes ) { #>
  61                      <style>
  62                          :root{
  63                              --site-icon-url: url( '{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}' );
  64                          }
  65                      </style>
  66                      <div class="site-icon-preview customizer">
  67                          <div class="direction-wrap">
  68                              <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" class="app-icon-preview" alt="{{
  69                                  data.attachment.alt ?
  70                                      wp.i18n.sprintf(
  71                                          <?php
  72                                          /* translators: %s: The selected image alt text. */
  73                                          echo wp_json_encode( __( 'App icon preview: Current image: %s' ) )
  74                                          ?>
  75                                          ,
  76                                          data.attachment.alt
  77                                      ) :
  78                                      wp.i18n.sprintf(
  79                                          <?php
  80                                          /* translators: %s: The selected image filename. */
  81                                          echo wp_json_encode( __( 'App icon preview: The current image has no alternative text. The file name is: %s' ) );
  82                                          ?>
  83                                          ,
  84                                          data.attachment.filename
  85                                      )
  86                              }}" />
  87                              <div class="site-icon-preview-browser">
  88                                  <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>
  89                                  <div class="site-icon-preview-tab">
  90                                      <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" class="browser-icon-preview" alt="{{
  91                                          data.attachment.alt ?
  92                                              wp.i18n.sprintf(
  93                                                  <?php
  94                                                  /* translators: %s: The selected image alt text. */
  95                                                  echo wp_json_encode( __( 'Browser icon preview: Current image: %s' ) );
  96                                                  ?>
  97                                                  ,
  98                                                  data.attachment.alt
  99                                              ) :
 100                                              wp.i18n.sprintf(
 101                                                  <?php
 102                                                  /* translators: %s: The selected image filename. */
 103                                                  echo wp_json_encode( __( 'Browser icon preview: The current image has no alternative text. The file name is: %s' ) );
 104                                                  ?>
 105                                                  ,
 106                                                  data.attachment.filename
 107                                              )
 108                                      }}" />
 109                                      <div class="site-icon-preview-site-title" aria-hidden="true"><# print( '<?php echo esc_js( get_bloginfo( 'name' ) ); ?>' ) #></div>
 110                                          <svg role="img" aria-hidden="true" fill="none" xmlns="http://www.w3.org/2000/svg" class="close-button">
 111                                              <path d="M12 13.0607L15.7123 16.773L16.773 15.7123L13.0607 12L16.773 8.28772L15.7123 7.22706L12 10.9394L8.28771 7.22705L7.22705 8.28771L10.9394 12L7.22706 15.7123L8.28772 16.773L12 13.0607Z" />
 112                                          </svg>
 113                                      </div>
 114                                  </div>
 115                              </div>
 116                          </div>
 117                      </div>
 118                  <# } #>
 119                  <div class="actions">
 120                      <# if ( data.canUpload ) { #>
 121                          <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
 122                          <button type="button" class="button upload-button"><?php echo $this->button_labels['change']; ?></button>
 123                      <# } #>
 124                  </div>
 125              </div>
 126          <# } else { #>
 127              <div class="attachment-media-view">
 128                  <# if ( data.canUpload ) { #>
 129                      <button type="button" class="upload-button button-add-media"><?php echo $this->button_labels['site_icon']; ?></button>
 130                  <# } #>
 131                  <div class="actions">
 132                      <# if ( data.defaultAttachment ) { #>
 133                          <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button>
 134                      <# } #>
 135                  </div>
 136              </div>
 137          <# } #>
 138          <# if ( data.description ) { #>
 139              <span class="description customize-control-description">{{{ data.description }}}</span>
 140          <# } #>
 141          <?php
 142      }
 143  }


Generated : Sat Dec 21 08:20:01 2024 Cross-referenced by PHPXref