class-wp-customize-themes-panel.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. <?php
  2. /**
  3. * Customize API: WP_Customize_Themes_Panel class
  4. *
  5. * @package WordPress
  6. * @subpackage Customize
  7. * @since 4.9.0
  8. */
  9. /**
  10. * Customize Themes Panel Class
  11. *
  12. * @since 4.9.0
  13. *
  14. * @see WP_Customize_Panel
  15. */
  16. class WP_Customize_Themes_Panel extends WP_Customize_Panel {
  17. /**
  18. * Panel type.
  19. *
  20. * @since 4.9.0
  21. * @var string
  22. */
  23. public $type = 'themes';
  24. /**
  25. * An Underscore (JS) template for rendering this panel's container.
  26. *
  27. * The themes panel renders a custom panel heading with the active theme and a switch themes button.
  28. *
  29. * @see WP_Customize_Panel::print_template()
  30. *
  31. * @since 4.9.0
  32. */
  33. protected function render_template() {
  34. ?>
  35. <li id="accordion-section-{{ data.id }}" class="accordion-section control-panel-themes">
  36. <h3 class="accordion-section-title">
  37. <?php
  38. if ( $this->manager->is_theme_active() ) {
  39. echo '<span class="customize-action">' . __( 'Active theme' ) . '</span> {{ data.title }}';
  40. } else {
  41. echo '<span class="customize-action">' . __( 'Previewing theme' ) . '</span> {{ data.title }}';
  42. }
  43. ?>
  44. <?php if ( current_user_can( 'switch_themes' ) ) : ?>
  45. <button type="button" class="button change-theme" aria-label="<?php esc_attr_e( 'Change theme' ); ?>"><?php _ex( 'Change', 'theme' ); ?></button>
  46. <?php endif; ?>
  47. </h3>
  48. <ul class="accordion-sub-container control-panel-content"></ul>
  49. </li>
  50. <?php
  51. }
  52. /**
  53. * An Underscore (JS) template for this panel's content (but not its container).
  54. *
  55. * Class variables for this panel class are available in the `data` JS object;
  56. * export custom variables by overriding WP_Customize_Panel::json().
  57. *
  58. * @since 4.9.0
  59. *
  60. * @see WP_Customize_Panel::print_template()
  61. */
  62. protected function content_template() {
  63. ?>
  64. <li class="panel-meta customize-info accordion-section <# if ( ! data.description ) { #> cannot-expand<# } #>">
  65. <button class="customize-panel-back" tabindex="-1" type="button"><span class="screen-reader-text"><?php _e( 'Back' ); ?></span></button>
  66. <div class="accordion-section-title">
  67. <span class="preview-notice">
  68. <?php
  69. printf(
  70. /* translators: %s: Themes panel title in the Customizer. */
  71. __( 'You are browsing %s' ),
  72. '<strong class="panel-title">' . __( 'Themes' ) . '</strong>'
  73. ); // Separate strings for consistency with other panels.
  74. ?>
  75. </span>
  76. <?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
  77. <# if ( data.description ) { #>
  78. <button class="customize-help-toggle dashicons dashicons-editor-help" type="button" aria-expanded="false"><span class="screen-reader-text"><?php _e( 'Help' ); ?></span></button>
  79. <# } #>
  80. <?php endif; ?>
  81. </div>
  82. <?php if ( current_user_can( 'install_themes' ) && ! is_multisite() ) : ?>
  83. <# if ( data.description ) { #>
  84. <div class="description customize-panel-description">
  85. {{{ data.description }}}
  86. </div>
  87. <# } #>
  88. <?php endif; ?>
  89. <div class="customize-control-notifications-container"></div>
  90. </li>
  91. <li class="customize-themes-full-container-container">
  92. <div class="customize-themes-full-container">
  93. <div class="customize-themes-notifications"></div>
  94. </div>
  95. </li>
  96. <?php
  97. }
  98. }