[ 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          <# if ( data.description ) { #>
  58              <span class="description customize-control-description">{{{ data.description }}}</span>
  59          <# } #>
  60  
  61          <# if ( data.attachment && data.attachment.id ) { #>
  62              <div class="attachment-media-view">
  63                  <# if ( data.attachment.sizes ) { #>
  64                      <div class="site-icon-preview wp-clearfix">
  65                          <div class="favicon-preview">
  66                              <img src="<?php echo esc_url( admin_url( 'images/' . ( is_rtl() ? 'browser-rtl.png' : 'browser.png' ) ) ); ?>" class="browser-preview" width="182" alt="" />
  67  
  68                              <div class="favicon">
  69                                  <img src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="{{
  70                                      data.attachment.alt ?
  71                                          wp.i18n.sprintf(
  72                                              <?php
  73                                              /* translators: %s: The selected image alt text. */
  74                                              echo wp_json_encode( __( 'Browser icon preview: Current image: %s' ) );
  75                                              ?>
  76                                              ,
  77                                              data.attachment.alt
  78                                          ) :
  79                                          wp.i18n.sprintf(
  80                                              <?php
  81                                              /* translators: %s: The selected image filename. */
  82                                              echo wp_json_encode( __( 'Browser icon preview: The current image has no alternative text. The file name is: %s' ) );
  83                                              ?>
  84                                              ,
  85                                              data.attachment.filename
  86                                          )
  87                                  }}" />
  88                              </div>
  89                              <span class="browser-title" aria-hidden="true"><# print( '<?php echo esc_js( get_bloginfo( 'name' ) ); ?>' ) #></span>
  90                          </div>
  91                          <img class="app-icon-preview" src="{{ data.attachment.sizes.full ? data.attachment.sizes.full.url : data.attachment.url }}" alt="{{
  92                              data.attachment.alt ?
  93                                  wp.i18n.sprintf(
  94                                      <?php
  95                                      /* translators: %s: The selected image alt text. */
  96                                      echo wp_json_encode( __( 'App icon preview: Current image: %s' ) )
  97                                      ?>
  98                                      ,
  99                                      data.attachment.alt
 100                                  ) :
 101                                  wp.i18n.sprintf(
 102                                      <?php
 103                                      /* translators: %s: The selected image filename. */
 104                                      echo wp_json_encode( __( 'App icon preview: The current image has no alternative text. The file name is: %s' ) );
 105                                      ?>
 106                                      ,
 107                                      data.attachment.filename
 108                                  )
 109                          }}"/>
 110                      </div>
 111                  <# } #>
 112                  <div class="actions">
 113                      <# if ( data.canUpload ) { #>
 114                          <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button>
 115                          <button type="button" class="button upload-button"><?php echo $this->button_labels['change']; ?></button>
 116                      <# } #>
 117                  </div>
 118              </div>
 119          <# } else { #>
 120              <div class="attachment-media-view">
 121                  <# if ( data.canUpload ) { #>
 122                      <button type="button" class="upload-button button-add-media"><?php echo $this->button_labels['site_icon']; ?></button>
 123                  <# } #>
 124                  <div class="actions">
 125                      <# if ( data.defaultAttachment ) { #>
 126                          <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button>
 127                      <# } #>
 128                  </div>
 129              </div>
 130          <# } #>
 131          <?php
 132      }
 133  }


Generated : Tue May 7 08:20:01 2024 Cross-referenced by PHPXref