[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

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] }}?ver={{ data.theme.version }}" 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 does not 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 does not 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 does not 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 does not 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 does not 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 does not 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                  <?php
 244                  wp_admin_notice(
 245                      _x( 'Installed', 'theme' ),
 246                      array(
 247                          'type'               => 'success',
 248                          'additional_classes' => array( 'notice-alt' ),
 249                      )
 250                  );
 251                  ?>
 252              <# } else if ( 'installed' === data.theme.type ) { #>
 253                  <# if ( data.theme.blockTheme ) { #>
 254                      <div class="theme-id-container">
 255                          <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 256                          <div class="theme-actions">
 257                              <# if ( data.theme.actions.activate ) { #>
 258                                  <?php
 259                                      /* translators: %s: Theme name. */
 260                                      $aria_label = sprintf( _x( 'Activate %s', 'theme' ), '{{ data.name }}' );
 261                                  ?>
 262                                  <a href="{{{ data.theme.actions.activate }}}" class="button button-primary activate" aria-label="<?php echo esc_attr( $aria_label ); ?>"><?php _e( 'Activate' ); ?></a>
 263                              <# } #>
 264                          </div>
 265                      </div>
 266                      <?php $customizer_not_supported_message = __( 'This theme doesn\'t support Customizer.' ); ?>
 267                      <# if ( data.theme.actions.activate ) { #>
 268                          <?php
 269                              $customizer_not_supported_message .= ' ' . sprintf(
 270                                  /* translators: %s: URL to the themes page (also it activates the theme). */
 271                                  __( 'However, you can still <a href="%s">activate this theme</a>, and use the Site Editor to customize it.' ),
 272                                  '{{{ data.theme.actions.activate }}}'
 273                              );
 274                          ?>
 275                      <# } #>
 276  
 277                      <?php
 278                      wp_admin_notice(
 279                          $customizer_not_supported_message,
 280                          array(
 281                              'type'               => 'error',
 282                              'additional_classes' => array( 'notice-alt' ),
 283                          )
 284                      );
 285                      ?>
 286                  <# } else { #>
 287                      <div class="theme-id-container">
 288                          <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 289                          <div class="theme-actions">
 290                              <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
 291                                  <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>
 292                              <# } else { #>
 293                                  <button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $preview_label ); ?>"><?php _e( 'Live Preview' ); ?></button>
 294                              <# } #>
 295                          </div>
 296                      </div>
 297                      <?php
 298                      wp_admin_notice(
 299                          _x( 'Installed', 'theme' ),
 300                          array(
 301                              'type'               => 'success',
 302                              'additional_classes' => array( 'notice-alt' ),
 303                          )
 304                      );
 305                      ?>
 306                  <# } #>
 307              <# } else { #>
 308                  <div class="theme-id-container">
 309                      <h3 class="theme-name" id="{{ data.section }}-{{ data.theme.id }}-name">{{ data.theme.name }}</h3>
 310                      <div class="theme-actions">
 311                          <# if ( data.theme.compatibleWP && data.theme.compatiblePHP ) { #>
 312                              <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>
 313                          <# } else { #>
 314                              <button type="button" class="button button-primary disabled" aria-label="<?php echo esc_attr( $install_label ); ?>" disabled><?php _e( 'Install &amp; Preview' ); ?></button>
 315                          <# } #>
 316                      </div>
 317                  </div>
 318              <# } #>
 319          </div>
 320          <?php
 321      }
 322  }


Generated : Thu Mar 28 08:20:01 2024 Cross-referenced by PHPXref