[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

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

   1  <?php
   2  /**
   3   * Customize API: WP_Customize_Theme_Control class
   4   *
   5   * @package WordPress
   6   * @subpackage Customize
   7   * @since 4.4.0
   8   */
   9  
  10  /**
  11   * Customize Theme Control class.
  12   *
  13   * @since 4.2.0
  14   *
  15   * @see WP_Customize_Control
  16   */
  17  class WP_Customize_Theme_Control extends WP_Customize_Control {
  18  
  19      /**
  20       * Customize control type.
  21       *
  22       * @since 4.2.0
  23       * @var string
  24       */
  25      public $type = 'theme';
  26  
  27      /**
  28       * Theme object.
  29       *
  30       * @since 4.2.0
  31       * @var WP_Theme
  32       */
  33      public $theme;
  34  
  35      /**
  36       * Refresh the parameters passed to the JavaScript via JSON.
  37       *
  38       * @since 4.2.0
  39       *
  40       * @see WP_Customize_Control::to_json()
  41       */
  42  	public function to_json() {
  43          parent::to_json();
  44          $this->json['theme'] = $this->theme;
  45      }
  46  
  47      /**
  48       * Don't render the control content from PHP, as it's rendered via JS on load.
  49       *
  50       * @since 4.2.0
  51       */
  52  	public function render_content() {}
  53  
  54      /**
  55       * Render a JS template for theme display.
  56       *
  57       * @since 4.2.0
  58       */
  59  	public function content_template() {
  60          /* translators: %s: Theme name. */
  61          $details_label = sprintf( __( 'Details for theme: %s' ), '{{ data.theme.name }}' );
  62          /* translators: %s: Theme name. */
  63          $customize_label = sprintf( __( 'Customize theme: %s' ), '{{ data.theme.name }}' );
  64          /* translators: %s: Theme name. */
  65          $preview_label = sprintf( __( 'Live preview theme: %s' ), '{{ data.theme.name }}' );
  66          /* translators: %s: Theme name. */
  67          $install_label = sprintf( __( 'Install and preview theme: %s' ), '{{ data.theme.name }}' );
  68          ?>
  69          <# if ( data.theme.active ) { #>
  70              <div class="theme active" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action">
  71          <# } else { #>
  72              <div class="theme" tabindex="0" aria-describedby="{{ data.section }}-{{ data.theme.id }}-action">
  73          <# } #>
  74  
  75              <# if ( data.theme.screenshot && data.theme.screenshot[0] ) { #>
  76                  <div class="theme-screenshot">
  77                      <img data-src="{{ data.theme.screenshot[0] }}" alt="" />
  78                  </div>
  79              <# } else { #>
  80                  <div class="theme-screenshot blank"></div>
  81              <# } #>
  82  
  83              <span class="more-details theme-details" id="{{ data.section }}-{{ data.theme.id }}-action" aria-label="<?php echo esc_attr( $details_label ); ?>"><?php _e( 'Theme Details' ); ?></span>
  84  
  85              <div class="theme-author">
  86              <?php
  87                  /* translators: Theme author name. */
  88                  printf( _x( 'By %s', 'theme author' ), '{{ data.theme.author }}' );
  89              ?>
  90              </div>
  91  
  92              <# if ( 'installed' === data.theme.type && data.theme.hasUpdate ) { #>
  93                  <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
  94                      <p>
  95                          <?php
  96                          if ( is_multisite() ) {
  97                              _e( 'New version available.' );
  98                          } else {
  99                              printf(
 100                                  /* translators: %s: "Update now" button. */
 101                                  __( 'New version available. %s' ),
 102                                  '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
 103                              );
 104                          }
 105                          ?>
 106                      </p>
 107                  </div>
 108              <# } #>
 109  
 110              <# if ( data.theme.active ) { #>
 111                  <div class="theme-id-container">
 112                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">
 113                          <span><?php _e( 'Previewing:' ); ?></span> {{ data.theme.name }}
 114                      </h3>
 115                      <div class="theme-actions">
 116                          <button type="button" class="button button-primary customize-theme" aria-label="<?php echo esc_attr( $customize_label ); ?>"><?php _e( 'Customize' ); ?></button>
 117                      </div>
 118                  </div>
 119                  <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
 120              <# } else if ( 'installed' === data.theme.type ) { #>
 121                  <div class="theme-id-container">
 122                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 123                      <div class="theme-actions">
 124                          <button type="button" class="button button-primary preview-theme" aria-label="<?php echo esc_attr( $preview_label ); ?>" data-slug="{{ data.theme.id }}"><?php _e( 'Live Preview' ); ?></button>
 125                      </div>
 126                  </div>
 127                  <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
 128              <# } else { #>
 129                  <div class="theme-id-container">
 130                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 131                      <div class="theme-actions">
 132                          <button type="button" class="button button-primary theme-install preview" aria-label="<?php echo esc_attr( $install_label ); ?>" data-slug="{{ data.theme.id }}" data-name="{{ data.theme.name }}"><?php _e( 'Install &amp; Preview' ); ?></button>
 133                      </div>
 134                  </div>
 135              <# } #>
 136          </div>
 137          <?php
 138      }
 139  }


Generated: Sat Nov 23 20:47:33 2019 Cross-referenced by PHPXref 0.7