Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 
 
 
 

112 righe
3.0 KiB

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