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