author | ymh <ymh.work@gmail.com> |
Wed, 21 Sep 2022 18:19:35 +0200 | |
changeset 18 | be944660c56a |
parent 16 | a86126ab1dd4 |
child 19 | 3d72ae0968f4 |
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 |
* |
|
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 |
/** |
|
85 |
* Display search form for searching themes. |
|
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 ) : ?> |
|
9 | 101 |
<label class="screen-reader-text" for="typeselector"><?php _e( 'Type of search' ); ?></label> |
0 | 102 |
<select name="type" id="typeselector"> |
9 | 103 |
<option value="term" <?php selected( 'term', $type ); ?>><?php _e( 'Keyword' ); ?></option> |
104 |
<option value="author" <?php selected( 'author', $type ); ?>><?php _e( 'Author' ); ?></option> |
|
105 |
<option value="tag" <?php selected( 'tag', $type ); ?>><?php _ex( 'Tag', 'Theme Installer' ); ?></option> |
|
0 | 106 |
</select> |
9 | 107 |
<label class="screen-reader-text" for="s"> |
108 |
<?php |
|
109 |
switch ( $type ) { |
|
110 |
case 'term': |
|
111 |
_e( 'Search by keyword' ); |
|
112 |
break; |
|
113 |
case 'author': |
|
114 |
_e( 'Search by author' ); |
|
115 |
break; |
|
116 |
case 'tag': |
|
117 |
_e( 'Search by tag' ); |
|
118 |
break; |
|
119 |
} |
|
120 |
?> |
|
121 |
</label> |
|
0 | 122 |
<?php else : ?> |
9 | 123 |
<label class="screen-reader-text" for="s"><?php _e( 'Search by keyword' ); ?></label> |
0 | 124 |
<?php endif; ?> |
9 | 125 |
<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
|
126 |
<?php submit_button( __( 'Search' ), '', 'search', false ); ?> |
0 | 127 |
</form> |
9 | 128 |
<?php |
0 | 129 |
} |
130 |
||
131 |
/** |
|
132 |
* Display tags filter for themes. |
|
133 |
* |
|
134 |
* @since 2.8.0 |
|
135 |
*/ |
|
136 |
function install_themes_dashboard() { |
|
137 |
install_theme_search_form( false ); |
|
9 | 138 |
?> |
139 |
<h4><?php _e( 'Feature Filter' ); ?></h4> |
|
0 | 140 |
<p class="install-help"><?php _e( 'Find a theme based on specific features.' ); ?></p> |
141 |
||
5 | 142 |
<form method="get"> |
0 | 143 |
<input type="hidden" name="tab" value="search" /> |
144 |
<?php |
|
145 |
$feature_list = get_theme_feature_list(); |
|
146 |
echo '<div class="feature-filter">'; |
|
147 |
||
148 |
foreach ( (array) $feature_list as $feature_name => $features ) { |
|
149 |
$feature_name = esc_html( $feature_name ); |
|
150 |
echo '<div class="feature-name">' . $feature_name . '</div>'; |
|
151 |
||
152 |
echo '<ol class="feature-group">'; |
|
153 |
foreach ( $features as $feature => $feature_name ) { |
|
154 |
$feature_name = esc_html( $feature_name ); |
|
9 | 155 |
$feature = esc_attr( $feature ); |
156 |
?> |
|
0 | 157 |
|
158 |
<li> |
|
159 |
<input type="checkbox" name="features[]" id="feature-id-<?php echo $feature; ?>" value="<?php echo $feature; ?>" /> |
|
160 |
<label for="feature-id-<?php echo $feature; ?>"><?php echo $feature_name; ?></label> |
|
161 |
</li> |
|
162 |
||
163 |
<?php } ?> |
|
164 |
</ol> |
|
165 |
<br class="clear" /> |
|
9 | 166 |
<?php |
167 |
} |
|
168 |
?> |
|
0 | 169 |
|
170 |
</div> |
|
171 |
<br class="clear" /> |
|
9 | 172 |
<?php submit_button( __( 'Find Themes' ), '', 'search' ); ?> |
0 | 173 |
</form> |
9 | 174 |
<?php |
0 | 175 |
} |
176 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
*/ |
5 | 180 |
function install_themes_upload() { |
9 | 181 |
?> |
16 | 182 |
<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> |
9 | 183 |
<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
|
184 |
<?php wp_nonce_field( 'theme-upload' ); ?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
<label class="screen-reader-text" for="themezip"><?php _e( 'Theme zip file' ); ?></label> |
18 | 186 |
<input type="file" id="themezip" name="themezip" accept=".zip" /> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
<?php submit_button( __( 'Install Now' ), '', 'install-theme-submit', false ); ?> |
0 | 188 |
</form> |
189 |
<?php |
|
190 |
} |
|
191 |
||
192 |
/** |
|
193 |
* Prints a theme on the Install Themes pages. |
|
194 |
* |
|
195 |
* @deprecated 3.4.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
* @global WP_Theme_Install_List_Table $wp_list_table |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
* @param object $theme |
0 | 200 |
*/ |
201 |
function display_theme( $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
_deprecated_function( __FUNCTION__, '3.4.0' ); |
0 | 203 |
global $wp_list_table; |
5 | 204 |
if ( ! isset( $wp_list_table ) ) { |
9 | 205 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 206 |
} |
207 |
$wp_list_table->prepare_items(); |
|
0 | 208 |
$wp_list_table->single_row( $theme ); |
209 |
} |
|
210 |
||
211 |
/** |
|
212 |
* Display theme content based on theme list. |
|
213 |
* |
|
214 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
215 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
216 |
* @global WP_Theme_Install_List_Table $wp_list_table |
0 | 217 |
*/ |
218 |
function display_themes() { |
|
219 |
global $wp_list_table; |
|
220 |
||
5 | 221 |
if ( ! isset( $wp_list_table ) ) { |
9 | 222 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 223 |
} |
224 |
$wp_list_table->prepare_items(); |
|
0 | 225 |
$wp_list_table->display(); |
5 | 226 |
|
0 | 227 |
} |
228 |
||
229 |
/** |
|
230 |
* Display theme information in dialog box form. |
|
231 |
* |
|
232 |
* @since 2.8.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
233 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
234 |
* @global WP_Theme_Install_List_Table $wp_list_table |
0 | 235 |
*/ |
236 |
function install_theme_information() { |
|
5 | 237 |
global $wp_list_table; |
0 | 238 |
|
239 |
$theme = themes_api( 'theme_information', array( 'slug' => wp_unslash( $_REQUEST['theme'] ) ) ); |
|
240 |
||
9 | 241 |
if ( is_wp_error( $theme ) ) { |
0 | 242 |
wp_die( $theme ); |
9 | 243 |
} |
0 | 244 |
|
9 | 245 |
iframe_header( __( 'Theme Installation' ) ); |
5 | 246 |
if ( ! isset( $wp_list_table ) ) { |
9 | 247 |
$wp_list_table = _get_list_table( 'WP_Theme_Install_List_Table' ); |
5 | 248 |
} |
0 | 249 |
$wp_list_table->theme_installer_single( $theme ); |
250 |
iframe_footer(); |
|
251 |
exit; |
|
252 |
} |