3 * WordPress Theme Install Administration API
6 * @subpackage Administration
9 $themes_allowedtags = array('a' => array('href' => array(), 'title' => array(), 'target' => array()),
10 'abbr' => array('title' => array()), 'acronym' => array('title' => array()),
11 'code' => array(), 'pre' => array(), 'em' => array(), 'strong' => array(),
12 'div' => array(), 'p' => array(), 'ul' => array(), 'ol' => array(), 'li' => array(),
13 'h1' => array(), 'h2' => array(), 'h3' => array(), 'h4' => array(), 'h5' => array(), 'h6' => array(),
14 'img' => array('src' => array(), 'class' => array(), 'alt' => array())
17 $theme_field_defaults = array( 'description' => true, 'sections' => false, 'tested' => true, 'requires' => true,
18 'rating' => true, 'downloaded' => true, 'downloadlink' => true, 'last_updated' => true, 'homepage' => true,
19 'tags' => true, 'num_ratings' => true
23 * Retrieve list of WordPress theme features (aka theme tags)
27 * @deprecated since 3.1.0 Use get_theme_feature_list() instead.
31 function install_themes_feature_list( ) {
32 if ( !$cache = get_transient( 'wporg_theme_feature_list' ) )
33 set_transient( 'wporg_theme_feature_list', array( ), 10800);
38 $feature_list = themes_api( 'feature_list', array( ) );
39 if ( is_wp_error( $feature_list ) )
42 set_transient( 'wporg_theme_feature_list', $feature_list, 10800 );
48 * Display search form for searching themes.
52 function install_theme_search_form( $type_selector = true ) {
53 $type = isset( $_REQUEST['type'] ) ? stripslashes( $_REQUEST['type'] ) : 'term';
54 $term = isset( $_REQUEST['s'] ) ? stripslashes( $_REQUEST['s'] ) : '';
55 if ( ! $type_selector )
56 echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>';
58 <form id="search-themes" method="get" action="">
59 <input type="hidden" name="tab" value="search" />
60 <?php if ( $type_selector ) : ?>
61 <select name="type" id="typeselector">
62 <option value="term" <?php selected('term', $type) ?>><?php _e('Keyword'); ?></option>
63 <option value="author" <?php selected('author', $type) ?>><?php _e('Author'); ?></option>
64 <option value="tag" <?php selected('tag', $type) ?>><?php _ex('Tag', 'Theme Installer'); ?></option>
67 <input type="search" name="s" size="30" value="<?php echo esc_attr($term) ?>" />
68 <?php submit_button( __( 'Search' ), 'button', 'search', false ); ?>
74 * Display tags filter for themes.
78 function install_themes_dashboard() {
79 install_theme_search_form( false );
81 <h4><?php _e('Feature Filter') ?></h4>
82 <p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p>
84 <form method="get" action="">
85 <input type="hidden" name="tab" value="search" />
87 $feature_list = get_theme_feature_list( );
88 echo '<div class="feature-filter">';
90 foreach ( (array) $feature_list as $feature_name => $features ) {
91 $feature_name = esc_html( $feature_name );
92 echo '<div class="feature-name">' . $feature_name . '</div>';
94 echo '<ol class="feature-group">';
95 foreach ( $features as $feature => $feature_name ) {
96 $feature_name = esc_html( $feature_name );
97 $feature = esc_attr($feature);
101 <input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" />
102 <label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label>
113 <?php submit_button( __( 'Find Themes' ), 'button', 'search' ); ?>
117 add_action('install_themes_dashboard', 'install_themes_dashboard');
119 function install_themes_upload($page = 1) {
121 <h4><?php _e('Install a theme in .zip format') ?></h4>
122 <p class="install-help"><?php _e('If you have a theme in a .zip format, you may install it by uploading it here.') ?></p>
123 <form method="post" enctype="multipart/form-data" action="<?php echo self_admin_url('update.php?action=upload-theme') ?>">
124 <?php wp_nonce_field( 'theme-upload') ?>
125 <input type="file" name="themezip" />
126 <?php submit_button( __( 'Install Now' ), 'button', 'install-theme-submit', false ); ?>
130 add_action('install_themes_upload', 'install_themes_upload', 10, 1);
133 * Prints a theme on the Install Themes pages.
137 function display_theme( $theme ) {
138 _deprecated_function( __FUNCTION__, '3.4' );
139 global $wp_list_table;
140 return $wp_list_table->single_row( $theme );
144 * Display theme content based on theme list.
148 function display_themes() {
149 global $wp_list_table;
151 $wp_list_table->display();
153 add_action('install_themes_search', 'display_themes');
154 add_action('install_themes_featured', 'display_themes');
155 add_action('install_themes_new', 'display_themes');
156 add_action('install_themes_updated', 'display_themes');
159 * Display theme information in dialog box form.
163 function install_theme_information() {
164 global $tab, $themes_allowedtags, $wp_list_table;
166 $theme = themes_api( 'theme_information', array( 'slug' => stripslashes( $_REQUEST['theme'] ) ) );
168 if ( is_wp_error( $theme ) )
171 iframe_header( __('Theme Install') );
172 $wp_list_table->theme_installer_single( $theme );
176 add_action('install_themes_pre_theme-information', 'install_theme_information');