/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. * Renders a JS template for the content of the site icon control. 
  46. * 
  47. * @since 4.5.0 
  48. * @access public 
  49. */ 
  50. public function content_template() { 
  51. ?> 
  52. <label for="{{ data.settings['default'] }}-button"> 
  53. <# if ( data.label ) { #> 
  54. <span class="customize-control-title">{{ data.label }}</span> 
  55. <# } #> 
  56. <# if ( data.description ) { #> 
  57. <span class="description customize-control-description">{{{ data.description }}}</span> 
  58. <# } #> 
  59. </label> 
  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"> 
  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="<?php esc_attr_e( 'Preview as a browser icon' ); ?>"/> 
  70. </div> 
  71. <span class="browser-title" aria-hidden="true"><?php bloginfo( 'name' ); ?></span> 
  72. </div> 
  73. <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' ); ?>"/> 
  74. </div> 
  75. <# } #> 
  76. <div class="actions"> 
  77. <# if ( data.canUpload ) { #> 
  78. <button type="button" class="button remove-button"><?php echo $this->button_labels['remove']; ?></button> 
  79. <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['change']; ?></button> 
  80. <div style="clear:both"></div> 
  81. <# } #> 
  82. </div> 
  83. </div> 
  84. <# } else { #> 
  85. <div class="attachment-media-view"> 
  86. <div class="placeholder"> 
  87. <?php echo $this->button_labels['placeholder']; ?> 
  88. </div> 
  89. <div class="actions"> 
  90. <# if ( data.defaultAttachment ) { #> 
  91. <button type="button" class="button default-button"><?php echo $this->button_labels['default']; ?></button> 
  92. <# } #> 
  93. <# if ( data.canUpload ) { #> 
  94. <button type="button" class="button upload-button" id="{{ data.settings['default'] }}-button"><?php echo $this->button_labels['select']; ?></button> 
  95. <# } #> 
  96. <div style="clear:both"></div> 
  97. </div> 
  98. </div> 
  99. <# } #> 
  100. <?php 
.