[ Index ]

PHP Cross Reference of WordPress

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                  <# if ( data.theme.updateResponse.compatibleWP && data.theme.updateResponse.compatiblePHP ) { #>
  94                      <div class="update-message notice inline notice-warning notice-alt" data-slug="{{ data.theme.id }}">
  95                          <p>
  96                              <?php
  97                              if ( is_multisite() ) {
  98                                  _e( 'New version available.' );
  99                              } else {
 100                                  printf(
 101                                      /* translators: %s: "Update now" button. */
 102                                      __( 'New version available. %s' ),
 103                                      '<button class="button-link update-theme" type="button">' . __( 'Update now' ) . '</button>'
 104                                  );
 105                              }
 106                              ?>
 107                          </p>
 108                      </div>
 109                  <# } else { #>
 110                      <div class="update-message notice inline notice-error notice-alt" data-slug="{{ data.theme.id }}">
 111                          <p>
 112                              <# if ( ! data.theme.updateResponse.compatibleWP && ! data.theme.updateResponse.compatiblePHP ) { #>
 113                                  <?php
 114                                  printf(
 115                                      /* translators: %s: Theme name. */
 116                                      __( 'There is a new version of %s available, but it doesn&#8217;t work with your versions of WordPress and PHP.' ),
 117                                      '{{{ data.theme.name }}}'
 118                                  );
 119                                  if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 120                                      printf(
 121                                          /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 122                                          ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 123                                          self_admin_url( 'update-core.php' ),
 124                                          esc_url( wp_get_update_php_url() )
 125                                      );
 126                                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 127                                  } elseif ( current_user_can( 'update_core' ) ) {
 128                                      printf(
 129                                          /* translators: %s: URL to WordPress Updates screen. */
 130                                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 131                                          self_admin_url( 'update-core.php' )
 132                                      );
 133                                  } elseif ( current_user_can( 'update_php' ) ) {
 134                                      printf(
 135                                          /* translators: %s: URL to Update PHP page. */
 136                                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 137                                          esc_url( wp_get_update_php_url() )
 138                                      );
 139                                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 140                                  }
 141                                  ?>
 142                              <# } else if ( ! data.theme.updateResponse.compatibleWP ) { #>
 143                                  <?php
 144                                  printf(
 145                                      /* translators: %s: Theme name. */
 146                                      __( 'There is a new version of %s available, but it doesn&#8217;t work with your version of WordPress.' ),
 147                                      '{{{ data.theme.name }}}'
 148                                  );
 149                                  if ( current_user_can( 'update_core' ) ) {
 150                                      printf(
 151                                          /* translators: %s: URL to WordPress Updates screen. */
 152                                          ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 153                                          self_admin_url( 'update-core.php' )
 154                                      );
 155                                  }
 156                                  ?>
 157                              <# } else if ( ! data.theme.updateResponse.compatiblePHP ) { #>
 158                                  <?php
 159                                  printf(
 160                                      /* translators: %s: Theme name. */
 161                                      __( 'There is a new version of %s available, but it doesn&#8217;t work with your version of PHP.' ),
 162                                      '{{{ data.theme.name }}}'
 163                                  );
 164                                  if ( current_user_can( 'update_php' ) ) {
 165                                      printf(
 166                                          /* translators: %s: URL to Update PHP page. */
 167                                          ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 168                                          esc_url( wp_get_update_php_url() )
 169                                      );
 170                                      wp_update_php_annotation( '</p><p><em>', '</em>' );
 171                                  }
 172                                  ?>
 173                              <# } #>
 174                          </p>
 175                      </div>
 176                  <# } #>
 177              <# } #>
 178  
 179              <# if ( ! data.theme.compatibleWP || ! data.theme.compatiblePHP ) { #>
 180                  <div class="notice notice-error notice-alt"><p>
 181                      <# if ( ! data.theme.compatibleWP && ! data.theme.compatiblePHP ) { #>
 182                          <?php
 183                          _e( 'This theme doesn&#8217;t work with your versions of WordPress and PHP.' );
 184                          if ( current_user_can( 'update_core' ) && current_user_can( 'update_php' ) ) {
 185                              printf(
 186                                  /* translators: 1: URL to WordPress Updates screen, 2: URL to Update PHP page. */
 187                                  ' ' . __( '<a href="%1$s">Please update WordPress</a>, and then <a href="%2$s">learn more about updating PHP</a>.' ),
 188                                  self_admin_url( 'update-core.php' ),
 189                                  esc_url( wp_get_update_php_url() )
 190                              );
 191                              wp_update_php_annotation( '</p><p><em>', '</em>' );
 192                          } elseif ( current_user_can( 'update_core' ) ) {
 193                              printf(
 194                                  /* translators: %s: URL to WordPress Updates screen. */
 195                                  ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 196                                  self_admin_url( 'update-core.php' )
 197                              );
 198                          } elseif ( current_user_can( 'update_php' ) ) {
 199                              printf(
 200                                  /* translators: %s: URL to Update PHP page. */
 201                                  ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 202                                  esc_url( wp_get_update_php_url() )
 203                              );
 204                              wp_update_php_annotation( '</p><p><em>', '</em>' );
 205                          }
 206                          ?>
 207                      <# } else if ( ! data.theme.compatibleWP ) { #>
 208                          <?php
 209                          _e( 'This theme doesn&#8217;t work with your version of WordPress.' );
 210                          if ( current_user_can( 'update_core' ) ) {
 211                              printf(
 212                                  /* translators: %s: URL to WordPress Updates screen. */
 213                                  ' ' . __( '<a href="%s">Please update WordPress</a>.' ),
 214                                  self_admin_url( 'update-core.php' )
 215                              );
 216                          }
 217                          ?>
 218                      <# } else if ( ! data.theme.compatiblePHP ) { #>
 219                          <?php
 220                          _e( 'This theme doesn&#8217;t work with your version of PHP.' );
 221                          if ( current_user_can( 'update_php' ) ) {
 222                              printf(
 223                                  /* translators: %s: URL to Update PHP page. */
 224                                  ' ' . __( '<a href="%s">Learn more about updating PHP</a>.' ),
 225                                  esc_url( wp_get_update_php_url() )
 226                              );
 227                              wp_update_php_annotation( '</p><p><em>', '</em>' );
 228                          }
 229                          ?>
 230                      <# } #>
 231                  </p></div>
 232              <# } #>
 233  
 234              <# if ( data.theme.active ) { #>
 235                  <div class="theme-id-container">
 236                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">
 237                          <span><?php _ex( 'Previewing:', 'theme' ); ?></span> {{ data.theme.name }}
 238                      </h3>
 239                      <div class="theme-actions">
 240                          <button type="button" class="button button-primary customize-theme" aria-label="<?php echo esc_attr( $customize_label ); ?>"><?php _e( 'Customize' ); ?></button>
 241                      </div>
 242                  </div>
 243                  <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
 244              <# } else if ( 'installed' === data.theme.type ) { #>
 245                  <div class="theme-id-container">
 246                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 247                      <div class="theme-actions">
 248                          <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
 249                              <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>
 250                          <# } else { #>
 251                              <button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button>
 252                          <# } #>
 253                      </div>
 254                  </div>
 255                  <div class="notice notice-success notice-alt"><p><?php _ex( 'Installed', 'theme' ); ?></p></div>
 256              <# } else { #>
 257                  <div class="theme-id-container">
 258                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 259                      <div class="theme-actions">
 260                          <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
 261                              <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>
 262                          <# } else { #>
 263                              <button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $install_label ); ?>" disabled><?php _e( 'Install &amp; Preview' ); ?></button>
 264                          <# } #>
 265                      </div>
 266                  </div>
 267              <# } #>
 268          </div>
 269          <?php
 270      }
 271  }


Generated: Fri Sep 18 01:00:03 2020 Cross-referenced by PHPXref 0.7.1