Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 
 
 

104 lignes
3.2 KiB

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