WP_Customize_Theme_Control

Customize Theme Control class.

Defined (1)

The class is defined in the following location(s).

/wp-includes/customize/class-wp-customize-theme-control.php  
  1. class WP_Customize_Theme_Control extends WP_Customize_Control { 
  2.  
  3. /** 
  4. * Customize control type. 
  5. * @since 4.2.0 
  6. * @access public 
  7. * @var string 
  8. */ 
  9. public $type = 'theme'; 
  10.  
  11. /** 
  12. * Theme object. 
  13. * @since 4.2.0 
  14. * @access public 
  15. * @var WP_Theme 
  16. */ 
  17. public $theme; 
  18.  
  19. /** 
  20. * Refresh the parameters passed to the JavaScript via JSON. 
  21. * @since 4.2.0 
  22. * @access public 
  23. * @see WP_Customize_Control::to_json() 
  24. */ 
  25. public function to_json() { 
  26. parent::to_json(); 
  27. $this->json['theme'] = $this->theme; 
  28.  
  29. /** 
  30. * Don't render the control content from PHP, as it's rendered via JS on load. 
  31. * @since 4.2.0 
  32. * @access public 
  33. */ 
  34. public function render_content() {} 
  35.  
  36. /** 
  37. * Render a JS template for theme display. 
  38. * @since 4.2.0 
  39. * @access public 
  40. */ 
  41. public function content_template() { 
  42. $current_url = set_url_scheme( 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] ); 
  43. $active_url = esc_url( remove_query_arg( 'theme', $current_url ) ); 
  44. $preview_url = esc_url( add_query_arg( 'theme', '__THEME__', $current_url ) ); // Token because esc_url() strips curly braces. 
  45. $preview_url = str_replace( '__THEME__', '{{ data.theme.id }}', $preview_url ); 
  46. ?> 
  47. <# if ( data.theme.isActiveTheme ) { #> 
  48. <div class="theme active" tabindex="0" data-preview-url="<?php echo esc_attr( $active_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name"> 
  49. <# } else { #> 
  50. <div class="theme" tabindex="0" data-preview-url="<?php echo esc_attr( $preview_url ); ?>" aria-describedby="{{ data.theme.id }}-action {{ data.theme.id }}-name"> 
  51. <# } #> 
  52.  
  53. <# if ( data.theme.screenshot[0] ) { #> 
  54. <div class="theme-screenshot"> 
  55. <img data-src="{{ data.theme.screenshot[0] }}" alt="" /> 
  56. </div> 
  57. <# } else { #> 
  58. <div class="theme-screenshot blank"></div> 
  59. <# } #> 
  60.  
  61. <# if ( data.theme.isActiveTheme ) { #> 
  62. <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Customize' ); ?></span> 
  63. <# } else { #> 
  64. <span class="more-details" id="{{ data.theme.id }}-action"><?php _e( 'Live Preview' ); ?></span> 
  65. <# } #> 
  66.  
  67. <div class="theme-author"><?php printf( __( 'By %s' ), '{{ data.theme.author }}' ); ?></div> 
  68.  
  69. <# if ( data.theme.isActiveTheme ) { #> 
  70. <h3 class="theme-name" id="{{ data.theme.id }}-name"> 
  71. <?php 
  72. /** translators: %s: theme name */ 
  73. printf( __( '<span>Active:</span> %s' ), '{{{ data.theme.name }}}' ); 
  74. ?> 
  75. </h3> 
  76. <# } else { #> 
  77. <h3 class="theme-name" id="{{ data.theme.id }}-name">{{{ data.theme.name }}}</h3> 
  78. <div class="theme-actions"> 
  79. <button type="button" class="button theme-details"><?php _e( 'Theme Details' ); ?></button> 
  80. </div> 
  81. <# } #> 
  82. </div> 
  83. <?php