Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

213 rindas
6.1 KiB

  1. <?php
  2. /**
  3. * WordPress Theme Install Administration API
  4. *
  5. * @package WordPress
  6. * @subpackage Administration
  7. */
  8. $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
  9. 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
  10. 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
  11. 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
  12. 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
  13. 'img' => array('src' => array(), 'class' => array(), 'alt' => array())
  14. );
  15. $theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
  16. 'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
  17. 'tags' => true, 'num_ratings' => true
  18. );
  19. /**
  20. * Retrieve list of WordPress theme features (aka theme tags)
  21. *
  22. * @since 2.8.0
  23. *
  24. * @deprecated since 3.1.0 Use get_theme_feature_list() instead.
  25. *
  26. * @return array
  27. */
  28. function install_themes_feature_list() {
  29. _deprecated_function( __FUNCTION__, '3.1.0', 'get_theme_feature_list()' );
  30. if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
  31. set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS );
  32. if ( $cache )
  33. return $cache;
  34. $feature_list = themes_api( 'feature_list', array() );
  35. if ( is_wp_error( $feature_list ) )
  36. return array();
  37. set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS );
  38. return $feature_list;
  39. }
  40. /**
  41. * Display search form for searching themes.
  42. *
  43. * @since 2.8.0
  44. *
  45. * @param bool $type_selector
  46. */
  47. function install_theme_search_form( $type_selector = true ) {
  48. $type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term';
  49. $term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : '';
  50. if ( ! $type_selector )
  51. echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
  52. ?>
  53. <form id="search-themes" method="get">
  54. <input type="hidden" name="tab" value="search" />
  55. <?php if ( $type_selector ) : ?>
  56. <label class="screen-reader-text" for="typeselector"><?php _e('Type of search'); ?></label>
  57. <select name="type" id="typeselector">
  58. <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
  59. <option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
  60. <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
  61. </select>
  62. <label class="screen-reader-text" for="s"><?php
  63. switch ( $type ) {
  64. case 'term':
  65. _e( 'Search by keyword' );
  66. break;
  67. case 'author':
  68. _e( 'Search by author' );
  69. break;
  70. case 'tag':
  71. _e( 'Search by tag' );
  72. break;
  73. }
  74. ?></label>
  75. <?php else : ?>
  76. <label class="screen-reader-text" for="s"><?php _e('Search by keyword'); ?></label>
  77. <?php endif; ?>
  78. <input type="search" name="s" id="s" size="30" value="<?php echo esc_attr($term) ?>" autofocus="autofocus" />
  79. <?php submit_button( __( 'Search' ), '', 'search', false ); ?>
  80. </form>
  81. <?php
  82. }
  83. /**
  84. * Display tags filter for themes.
  85. *
  86. * @since 2.8.0
  87. */
  88. function install_themes_dashboard() {
  89. install_theme_search_form( false );
  90. ?>
  91. <h4><?php _e('Feature Filter') ?></h4>
  92. <p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
  93. <form method="get">
  94. <input type="hidden" name="tab" value="search" />
  95. <?php
  96. $feature_list = get_theme_feature_list();
  97. echo '<div class="feature-filter">';
  98. foreach ( (array) $feature_list as $feature_name => $features ) {
  99. $feature_name = esc_html( $feature_name );
  100. echo '<div class="feature-name">' . $feature_name . '</div>';
  101. echo '<ol class="feature-group">';
  102. foreach ( $features as $feature => $feature_name ) {
  103. $feature_name = esc_html( $feature_name );
  104. $feature = esc_attr($feature);
  105. ?>
  106. <li>
  107. <input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
  108. <label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
  109. </li>
  110. <?php } ?>
  111. </ol>
  112. <br class="clear" />
  113. <?php
  114. } ?>
  115. </div>
  116. <br class="clear" />
  117. <?php submit_button( __( 'Find Themes' ), '', 'search' ); ?>
  118. </form>
  119. <?php
  120. }
  121. /**
  122. * @since 2.8.0
  123. */
  124. function install_themes_upload() {
  125. ?>
  126. <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.'); ?></p>
  127. <form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo self_admin_url('update.php?action=upload-theme'); ?>">
  128. <?php wp_nonce_field( 'theme-upload' ); ?>
  129. <label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label>
  130. <input type="file" id="themezip" name="themezip" />
  131. <?php submit_button( __( 'Install Now' ), '', 'install-theme-submit', false ); ?>
  132. </form>
  133. <?php
  134. }
  135. /**
  136. * Prints a theme on the Install Themes pages.
  137. *
  138. * @deprecated 3.4.0
  139. *
  140. * @global WP_Theme_Install_List_Table $wp_list_table
  141. *
  142. * @param object $theme
  143. */
  144. function display_theme( $theme ) {
  145. _deprecated_function( __FUNCTION__, '3.4.0' );
  146. global $wp_list_table;
  147. if ( ! isset( $wp_list_table ) ) {
  148. $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  149. }
  150. $wp_list_table->prepare_items();
  151. $wp_list_table->single_row( $theme );
  152. }
  153. /**
  154. * Display theme content based on theme list.
  155. *
  156. * @since 2.8.0
  157. *
  158. * @global WP_Theme_Install_List_Table $wp_list_table
  159. */
  160. function display_themes() {
  161. global $wp_list_table;
  162. if ( ! isset( $wp_list_table ) ) {
  163. $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  164. }
  165. $wp_list_table->prepare_items();
  166. $wp_list_table->display();
  167. }
  168. /**
  169. * Display theme information in dialog box form.
  170. *
  171. * @since 2.8.0
  172. *
  173. * @global WP_Theme_Install_List_Table $wp_list_table
  174. */
  175. function install_theme_information() {
  176. global $wp_list_table;
  177. $theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) );
  178. if ( is_wp_error( $theme ) )
  179. wp_die( $theme );
  180. iframe_header( __('Theme Install') );
  181. if ( ! isset( $wp_list_table ) ) {
  182. $wp_list_table = _get_list_table('WP_Theme_Install_List_Table');
  183. }
  184. $wp_list_table->theme_installer_single( $theme );
  185. iframe_footer();
  186. exit;
  187. }