author | ymh <ymh.work@gmail.com> |
Mon, 08 Sep 2025 19:44:41 +0200 | |
changeset 23 | 417f20492bf7 |
parent 21 | 48c4eec2b7e6 |
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 |
/** |
|
19 | 54 |
* Retrieves the list of WordPress theme features (aka theme tags). |
0 | 55 |
* |
56 |
* @since 2.8.0 |
|
57 |
* |
|
16 | 58 |
* @deprecated 3.1.0 Use get_theme_feature_list() instead. |
0 | 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 |
|
16 | 65 |
$cache = get_transient( 'wporg_theme_feature_list' ); |
66 |
if ( ! $cache ) { |
|
0 | 67 |
set_transient( 'wporg_theme_feature_list', array(), 3 * HOUR_IN_SECONDS ); |
9 | 68 |
} |
0 | 69 |
|
9 | 70 |
if ( $cache ) { |
0 | 71 |
return $cache; |
9 | 72 |
} |
0 | 73 |
|
74 |
$feature_list = themes_api( 'feature_list', array() ); |
|
9 | 75 |
if ( is_wp_error( $feature_list ) ) { |
0 | 76 |
return array(); |
9 | 77 |
} |
0 | 78 |
|
79 |
set_transient( 'wporg_theme_feature_list', $feature_list, 3 * HOUR_IN_SECONDS ); |
|
80 |
||
81 |
return $feature_list; |
|
82 |
} |
|
83 |
||
84 |
/** |
|
19 | 85 |
* Displays search form for searching themes. |
0 | 86 |
* |
87 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
* @param bool $type_selector |
0 | 90 |
*/ |
91 |
function install_theme_search_form( $type_selector = true ) { |
|
92 |
$type = isset( $_REQUEST['type'] ) ? wp_unslash( $_REQUEST['type'] ) : 'term'; |
|
93 |
$term = isset( $_REQUEST['s'] ) ? wp_unslash( $_REQUEST['s'] ) : ''; |
|
9 | 94 |
if ( ! $type_selector ) { |
0 | 95 |
echo '<p class="install-help">' . __( 'Search for themes by keyword.' ) . '</p>'; |
9 | 96 |
} |
0 | 97 |
?> |
5 | 98 |
<form id="search-themes" method="get"> |
0 | 99 |
<input type="hidden" name="tab" value="search" /> |
100 |
<?php if ( $type_selector ) : ?> |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
101 |
<label class="screen-reader-text" for="typeselector"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
102 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
103 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
104 |
_e( 'Type of search' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
105 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
106 |
</label> |
0 | 107 |
<select name="type" id="typeselector"> |
9 | 108 |
<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> |
109 |
<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> |
|
110 |
<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option> |
|
0 | 111 |
</select> |
9 | 112 |
<label class="screen-reader-text" for="s"> |
113 |
<?php |
|
114 |
switch ( $type ) { |
|
115 |
case 'term': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
116 |
/* translators: Hidden accessibility text. */ |
9 | 117 |
_e( 'Search by keyword' ); |
118 |
break; |
|
119 |
case 'author': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
120 |
/* translators: Hidden accessibility text. */ |
9 | 121 |
_e( 'Search by author' ); |
122 |
break; |
|
123 |
case 'tag': |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
124 |
/* translators: Hidden accessibility text. */ |
9 | 125 |
_e( 'Search by tag' ); |
126 |
break; |
|
127 |
} |
|
128 |
?> |
|
129 |
</label> |
|
0 | 130 |
<?php else : ?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
131 |
<label class="screen-reader-text" for="s"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
132 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
133 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
134 |
_e( 'Search by keyword' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
135 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
136 |
</label> |
0 | 137 |
<?php endif; ?> |
9 | 138 |
<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
|
139 |
<?php submit_button( __( 'Search' ), '', 'search', false ); ?> |
0 | 140 |
</form> |
9 | 141 |
<?php |
0 | 142 |
} |
143 |
||
144 |
/** |
|
19 | 145 |
* Displays tags filter for themes. |
0 | 146 |
* |
147 |
* @since 2.8.0 |
|
148 |
*/ |
|
149 |
function install_themes_dashboard() { |
|
150 |
install_theme_search_form( false ); |
|
9 | 151 |
?> |
152 |
<h4><?php _e( 'Feature Filter' ); ?></h4> |
|
0 | 153 |
<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p> |
154 |
||
5 | 155 |
<form method="get"> |
0 | 156 |
<input type="hidden" name="tab" value="search" /> |
157 |
<?php |
|
158 |
$feature_list = get_theme_feature_list(); |
|
159 |
echo '<div class="feature-filter">'; |
|
160 |
||
161 |
foreach ( (array) $feature_list as $feature_name => $features ) { |
|
162 |
$feature_name = esc_html( $feature_name ); |
|
163 |
echo '<div class="feature-name">' . $feature_name . '</div>'; |
|
164 |
||
165 |
echo '<ol class="feature-group">'; |
|
166 |
foreach ( $features as $feature => $feature_name ) { |
|
167 |
$feature_name = esc_html( $feature_name ); |
|
9 | 168 |
$feature = esc_attr( $feature ); |
169 |
?> |
|
0 | 170 |
|
171 |
<li> |
|
172 |
<input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" /> |
|
173 |
<label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label> |
|
174 |
</li> |
|
175 |
||
176 |
<?php } ?> |
|
177 |
</ol> |
|
178 |
<br class="clear" /> |
|
9 | 179 |
<?php |
180 |
} |
|
181 |
?> |
|
0 | 182 |
|
183 |
</div> |
|
184 |
<br class="clear" /> |
|
9 | 185 |
<?php submit_button( __( 'Find Themes' ), '', 'search' ); ?> |
0 | 186 |
</form> |
9 | 187 |
<?php |
0 | 188 |
} |
189 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
190 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
191 |
* Displays a form to upload themes from zip files. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
192 |
* |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
*/ |
5 | 195 |
function install_themes_upload() { |
9 | 196 |
?> |
16 | 197 |
<p class="install-help"><?php _e( 'If you have a theme in a .zip format, you may install or update it by uploading it here.' ); ?></p> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
198 |
<form method="post" enctype="multipart/form-data" class="wp-upload-form" action="<?php echo esc_url( self_admin_url( 'update.php?action=upload-theme' ) ); ?>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
<?php wp_nonce_field( 'theme-upload' ); ?> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
200 |
<label class="screen-reader-text" for="themezip"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
201 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
202 |
/* translators: Hidden accessibility text. */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
203 |
_e( 'Theme zip file' ); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
204 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
205 |
</label> |
18 | 206 |
<input type="file" id="themezip" name="themezip" accept=".zip" /> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
207 |
<?php submit_button( _x( 'Install Now', 'theme' ), '', 'install-theme-submit', false ); ?> |
0 | 208 |
</form> |
209 |
<?php |
|
210 |
} |
|
211 |
||
212 |
/** |
|
213 |
* Prints a theme on the Install Themes pages. |
|
214 |
* |
|
215 |
* @deprecated 3.4.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
217 |
* @global WP_Theme_Install_List_Table $wp_list_table |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
218 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
* @param object $theme |
0 | 220 |
*/ |
221 |
function display_theme( $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
222 |
_deprecated_function( __FUNCTION__, '3.4.0' ); |
0 | 223 |
global $wp_list_table; |
5 | 224 |
if ( ! isset( $wp_list_table ) ) { |
9 | 225 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 226 |
} |
227 |
$wp_list_table->prepare_items(); |
|
0 | 228 |
$wp_list_table->single_row( $theme ); |
229 |
} |
|
230 |
||
231 |
/** |
|
19 | 232 |
* Displays theme content based on theme list. |
0 | 233 |
* |
234 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
* @global WP_Theme_Install_List_Table $wp_list_table |
0 | 237 |
*/ |
238 |
function display_themes() { |
|
239 |
global $wp_list_table; |
|
240 |
||
5 | 241 |
if ( ! isset( $wp_list_table ) ) { |
9 | 242 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 243 |
} |
244 |
$wp_list_table->prepare_items(); |
|
0 | 245 |
$wp_list_table->display(); |
246 |
} |
|
247 |
||
248 |
/** |
|
19 | 249 |
* Displays theme information in dialog box form. |
0 | 250 |
* |
251 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
* @global WP_Theme_Install_List_Table $wp_list_table |
0 | 254 |
*/ |
255 |
function install_theme_information() { |
|
5 | 256 |
global $wp_list_table; |
0 | 257 |
|
258 |
$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) ); |
|
259 |
||
9 | 260 |
if ( is_wp_error( $theme ) ) { |
0 | 261 |
wp_die( $theme ); |
9 | 262 |
} |
0 | 263 |
|
9 | 264 |
iframe_header( __( 'Theme Installation' ) ); |
5 | 265 |
if ( ! isset( $wp_list_table ) ) { |
9 | 266 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 267 |
} |
0 | 268 |
$wp_list_table->theme_installer_single( $theme ); |
269 |
iframe_footer(); |
|
270 |
exit; |
|
271 |
} |