author | ymh <ymh.work@gmail.com> |
Fri, 05 Sep 2025 18:52:52 +0200 | |
changeset 22 | 8c2e4d02f4ef |
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 |
* List Table API: WP_MS_Themes_List_Table class |
0 | 4 |
* |
5 |
* @package WordPress |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
* @subpackage Administration |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
* Core class used to implement displaying themes in a list table for the network admin. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
* |
0 | 13 |
* @since 3.1.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
* @see WP_List_Table |
0 | 16 |
*/ |
17 |
class WP_MS_Themes_List_Table extends WP_List_Table { |
|
18 |
||
5 | 19 |
public $site_id; |
20 |
public $is_site_themes; |
|
21 |
||
22 |
private $has_items; |
|
0 | 23 |
|
5 | 24 |
/** |
16 | 25 |
* Whether to show the auto-updates UI. |
26 |
* |
|
27 |
* @since 5.5.0 |
|
28 |
* |
|
29 |
* @var bool True if auto-updates UI is to be shown, false otherwise. |
|
30 |
*/ |
|
31 |
protected $show_autoupdates = true; |
|
32 |
||
33 |
/** |
|
5 | 34 |
* Constructor. |
35 |
* |
|
36 |
* @since 3.1.0 |
|
37 |
* |
|
38 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
39 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
* |
5 | 43 |
* @param array $args An associative array of arguments. |
44 |
*/ |
|
45 |
public function __construct( $args = array() ) { |
|
0 | 46 |
global $status, $page; |
47 |
||
9 | 48 |
parent::__construct( |
49 |
array( |
|
50 |
'plural' => 'themes', |
|
51 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
52 |
) |
|
53 |
); |
|
0 | 54 |
|
55 |
$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; |
|
16 | 56 |
if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken', 'auto-update-enabled', 'auto-update-disabled' ), true ) ) { |
0 | 57 |
$status = 'all'; |
9 | 58 |
} |
0 | 59 |
|
60 |
$page = $this->get_pagenum(); |
|
61 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false; |
0 | 63 |
|
9 | 64 |
if ( $this->is_site_themes ) { |
18 | 65 |
$this->site_id = isset( $_REQUEST['id'] ) ? (int) $_REQUEST['id'] : 0; |
9 | 66 |
} |
16 | 67 |
|
68 |
$this->show_autoupdates = wp_is_auto_update_enabled_for_type( 'theme' ) && |
|
69 |
! $this->is_site_themes && current_user_can( 'update_themes' ); |
|
0 | 70 |
} |
71 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
*/ |
5 | 75 |
protected function get_table_classes() { |
16 | 76 |
// @todo Remove and add CSS for .themes. |
5 | 77 |
return array( 'widefat', 'plugins' ); |
0 | 78 |
} |
79 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
*/ |
5 | 83 |
public function ajax_user_can() { |
9 | 84 |
if ( $this->is_site_themes ) { |
0 | 85 |
return current_user_can( 'manage_sites' ); |
9 | 86 |
} else { |
0 | 87 |
return current_user_can( 'manage_network_themes' ); |
9 | 88 |
} |
0 | 89 |
} |
90 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
* @global string $orderby |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
* @global string $order |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
* @global string $s |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
*/ |
5 | 99 |
public function prepare_items() { |
0 | 100 |
global $status, $totals, $page, $orderby, $order, $s; |
101 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
102 |
$orderby = ! empty( $_REQUEST['orderby'] ) ? sanitize_text_field( $_REQUEST['orderby'] ) : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
103 |
$order = ! empty( $_REQUEST['order'] ) ? sanitize_text_field( $_REQUEST['order'] ) : ''; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
104 |
$s = ! empty( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : ''; |
0 | 105 |
|
106 |
$themes = array( |
|
5 | 107 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
* Filters the full array of WP_Theme objects to list in the Multisite |
5 | 109 |
* themes list table. |
110 |
* |
|
111 |
* @since 3.1.0 |
|
112 |
* |
|
9 | 113 |
* @param WP_Theme[] $all Array of WP_Theme objects to display in the list table. |
5 | 114 |
*/ |
9 | 115 |
'all' => apply_filters( 'all_themes', wp_get_themes() ), |
116 |
'search' => array(), |
|
117 |
'enabled' => array(), |
|
0 | 118 |
'disabled' => array(), |
9 | 119 |
'upgrade' => array(), |
120 |
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), |
|
0 | 121 |
); |
122 |
||
16 | 123 |
if ( $this->show_autoupdates ) { |
124 |
$auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
125 |
||
126 |
$themes['auto-update-enabled'] = array(); |
|
127 |
$themes['auto-update-disabled'] = array(); |
|
128 |
} |
|
129 |
||
0 | 130 |
if ( $this->is_site_themes ) { |
131 |
$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); |
|
9 | 132 |
$allowed_where = 'site'; |
0 | 133 |
} else { |
134 |
$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); |
|
9 | 135 |
$allowed_where = 'network'; |
0 | 136 |
} |
137 |
||
16 | 138 |
$current = get_site_transient( 'update_themes' ); |
139 |
$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current; |
|
0 | 140 |
|
141 |
foreach ( (array) $themes['all'] as $key => $theme ) { |
|
142 |
if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { |
|
143 |
unset( $themes['all'][ $key ] ); |
|
144 |
continue; |
|
145 |
} |
|
146 |
||
147 |
if ( $maybe_update && isset( $current->response[ $key ] ) ) { |
|
148 |
$themes['all'][ $key ]->update = true; |
|
9 | 149 |
$themes['upgrade'][ $key ] = $themes['all'][ $key ]; |
0 | 150 |
} |
151 |
||
9 | 152 |
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; |
0 | 153 |
$themes[ $filter ][ $key ] = $themes['all'][ $key ]; |
16 | 154 |
|
155 |
$theme_data = array( |
|
156 |
'update_supported' => isset( $theme->update_supported ) ? $theme->update_supported : true, |
|
157 |
); |
|
158 |
||
159 |
// Extra info if known. array_merge() ensures $theme_data has precedence if keys collide. |
|
160 |
if ( isset( $current->response[ $key ] ) ) { |
|
161 |
$theme_data = array_merge( (array) $current->response[ $key ], $theme_data ); |
|
162 |
} elseif ( isset( $current->no_update[ $key ] ) ) { |
|
163 |
$theme_data = array_merge( (array) $current->no_update[ $key ], $theme_data ); |
|
164 |
} else { |
|
165 |
$theme_data['update_supported'] = false; |
|
166 |
} |
|
167 |
||
168 |
$theme->update_supported = $theme_data['update_supported']; |
|
169 |
||
170 |
/* |
|
171 |
* Create the expected payload for the auto_update_theme filter, this is the same data |
|
172 |
* as contained within $updates or $no_updates but used when the Theme is not known. |
|
173 |
*/ |
|
174 |
$filter_payload = array( |
|
175 |
'theme' => $key, |
|
176 |
'new_version' => '', |
|
177 |
'url' => '', |
|
178 |
'package' => '', |
|
179 |
'requires' => '', |
|
180 |
'requires_php' => '', |
|
181 |
); |
|
182 |
||
18 | 183 |
$filter_payload = (object) array_merge( $filter_payload, array_intersect_key( $theme_data, $filter_payload ) ); |
16 | 184 |
|
18 | 185 |
$auto_update_forced = wp_is_auto_update_forced_for_item( 'theme', null, $filter_payload ); |
16 | 186 |
|
187 |
if ( ! is_null( $auto_update_forced ) ) { |
|
188 |
$theme->auto_update_forced = $auto_update_forced; |
|
189 |
} |
|
190 |
||
191 |
if ( $this->show_autoupdates ) { |
|
192 |
$enabled = in_array( $key, $auto_updates, true ) && $theme->update_supported; |
|
193 |
if ( isset( $theme->auto_update_forced ) ) { |
|
194 |
$enabled = (bool) $theme->auto_update_forced; |
|
195 |
} |
|
196 |
||
197 |
if ( $enabled ) { |
|
198 |
$themes['auto-update-enabled'][ $key ] = $theme; |
|
199 |
} else { |
|
200 |
$themes['auto-update-disabled'][ $key ] = $theme; |
|
201 |
} |
|
202 |
} |
|
0 | 203 |
} |
204 |
||
205 |
if ( $s ) { |
|
9 | 206 |
$status = 'search'; |
0 | 207 |
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); |
208 |
} |
|
209 |
||
18 | 210 |
$totals = array(); |
211 |
$js_themes = array(); |
|
9 | 212 |
foreach ( $themes as $type => $list ) { |
18 | 213 |
$totals[ $type ] = count( $list ); |
214 |
$js_themes[ $type ] = array_keys( $list ); |
|
9 | 215 |
} |
0 | 216 |
|
16 | 217 |
if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ), true ) ) { |
0 | 218 |
$status = 'all'; |
9 | 219 |
} |
0 | 220 |
|
221 |
$this->items = $themes[ $status ]; |
|
222 |
WP_Theme::sort_by_name( $this->items ); |
|
223 |
||
224 |
$this->has_items = ! empty( $themes['all'] ); |
|
225 |
$total_this_page = $totals[ $status ]; |
|
226 |
||
9 | 227 |
wp_localize_script( |
228 |
'updates', |
|
229 |
'_wpUpdatesItemCounts', |
|
230 |
array( |
|
18 | 231 |
'themes' => $js_themes, |
9 | 232 |
'totals' => wp_get_update_data(), |
233 |
) |
|
234 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
|
0 | 236 |
if ( $orderby ) { |
237 |
$orderby = ucfirst( $orderby ); |
|
9 | 238 |
$order = strtoupper( $order ); |
0 | 239 |
|
16 | 240 |
if ( 'Name' === $orderby ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
if ( 'ASC' === $order ) { |
0 | 242 |
$this->items = array_reverse( $this->items ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
} |
0 | 244 |
} else { |
245 |
uasort( $this->items, array( $this, '_order_callback' ) ); |
|
246 |
} |
|
247 |
} |
|
248 |
||
249 |
$start = ( $page - 1 ) * $themes_per_page; |
|
250 |
||
9 | 251 |
if ( $total_this_page > $themes_per_page ) { |
0 | 252 |
$this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
9 | 253 |
} |
0 | 254 |
|
9 | 255 |
$this->set_pagination_args( |
256 |
array( |
|
257 |
'total_items' => $total_this_page, |
|
258 |
'per_page' => $themes_per_page, |
|
259 |
) |
|
260 |
); |
|
0 | 261 |
} |
262 |
||
5 | 263 |
/** |
264 |
* @param WP_Theme $theme |
|
265 |
* @return bool |
|
266 |
*/ |
|
267 |
public function _search_callback( $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
static $term = null; |
9 | 269 |
if ( is_null( $term ) ) { |
0 | 270 |
$term = wp_unslash( $_REQUEST['s'] ); |
9 | 271 |
} |
0 | 272 |
|
273 |
foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { |
|
274 |
// Don't mark up; Do translate. |
|
9 | 275 |
if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) { |
0 | 276 |
return true; |
9 | 277 |
} |
0 | 278 |
} |
279 |
||
9 | 280 |
if ( false !== stripos( $theme->get_stylesheet(), $term ) ) { |
0 | 281 |
return true; |
9 | 282 |
} |
0 | 283 |
|
9 | 284 |
if ( false !== stripos( $theme->get_template(), $term ) ) { |
0 | 285 |
return true; |
9 | 286 |
} |
0 | 287 |
|
288 |
return false; |
|
289 |
} |
|
290 |
||
291 |
// Not used by any core columns. |
|
5 | 292 |
/** |
293 |
* @global string $orderby |
|
294 |
* @global string $order |
|
295 |
* @param array $theme_a |
|
296 |
* @param array $theme_b |
|
297 |
* @return int |
|
298 |
*/ |
|
299 |
public function _order_callback( $theme_a, $theme_b ) { |
|
0 | 300 |
global $orderby, $order; |
301 |
||
302 |
$a = $theme_a[ $orderby ]; |
|
303 |
$b = $theme_b[ $orderby ]; |
|
304 |
||
18 | 305 |
if ( $a === $b ) { |
0 | 306 |
return 0; |
9 | 307 |
} |
0 | 308 |
|
9 | 309 |
if ( 'DESC' === $order ) { |
0 | 310 |
return ( $a < $b ) ? 1 : -1; |
9 | 311 |
} else { |
0 | 312 |
return ( $a < $b ) ? -1 : 1; |
9 | 313 |
} |
0 | 314 |
} |
315 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
*/ |
5 | 318 |
public function no_items() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
if ( $this->has_items ) { |
0 | 320 |
_e( 'No themes found.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
} else { |
16 | 322 |
_e( 'No themes are currently available.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
} |
0 | 324 |
} |
325 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
/** |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
327 |
* @return string[] Array of column titles keyed by their column name. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
*/ |
5 | 329 |
public function get_columns() { |
16 | 330 |
$columns = array( |
0 | 331 |
'cb' => '<input type="checkbox" />', |
332 |
'name' => __( 'Theme' ), |
|
333 |
'description' => __( 'Description' ), |
|
334 |
); |
|
16 | 335 |
|
336 |
if ( $this->show_autoupdates ) { |
|
337 |
$columns['auto-updates'] = __( 'Automatic Updates' ); |
|
338 |
} |
|
339 |
||
340 |
return $columns; |
|
0 | 341 |
} |
342 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
*/ |
5 | 346 |
protected function get_sortable_columns() { |
0 | 347 |
return array( |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
348 |
'name' => array( 'name', false, __( 'Theme' ), __( 'Table ordered by Theme Name.' ), 'asc' ), |
0 | 349 |
); |
350 |
} |
|
351 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
* Gets the name of the primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
* @return string Unalterable name of the primary column name, in this case, 'name'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
protected function get_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
return 'name'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
*/ |
5 | 368 |
protected function get_views() { |
0 | 369 |
global $totals, $status; |
370 |
||
371 |
$status_links = array(); |
|
372 |
foreach ( $totals as $type => $count ) { |
|
9 | 373 |
if ( ! $count ) { |
0 | 374 |
continue; |
9 | 375 |
} |
0 | 376 |
|
377 |
switch ( $type ) { |
|
378 |
case 'all': |
|
16 | 379 |
/* translators: %s: Number of themes. */ |
380 |
$text = _nx( |
|
381 |
'All <span class="count">(%s)</span>', |
|
382 |
'All <span class="count">(%s)</span>', |
|
383 |
$count, |
|
384 |
'themes' |
|
385 |
); |
|
0 | 386 |
break; |
387 |
case 'enabled': |
|
16 | 388 |
/* translators: %s: Number of themes. */ |
389 |
$text = _nx( |
|
390 |
'Enabled <span class="count">(%s)</span>', |
|
391 |
'Enabled <span class="count">(%s)</span>', |
|
392 |
$count, |
|
393 |
'themes' |
|
394 |
); |
|
0 | 395 |
break; |
396 |
case 'disabled': |
|
16 | 397 |
/* translators: %s: Number of themes. */ |
398 |
$text = _nx( |
|
399 |
'Disabled <span class="count">(%s)</span>', |
|
400 |
'Disabled <span class="count">(%s)</span>', |
|
401 |
$count, |
|
402 |
'themes' |
|
403 |
); |
|
0 | 404 |
break; |
405 |
case 'upgrade': |
|
16 | 406 |
/* translators: %s: Number of themes. */ |
407 |
$text = _nx( |
|
408 |
'Update Available <span class="count">(%s)</span>', |
|
409 |
'Update Available <span class="count">(%s)</span>', |
|
410 |
$count, |
|
411 |
'themes' |
|
412 |
); |
|
0 | 413 |
break; |
9 | 414 |
case 'broken': |
16 | 415 |
/* translators: %s: Number of themes. */ |
416 |
$text = _nx( |
|
417 |
'Broken <span class="count">(%s)</span>', |
|
418 |
'Broken <span class="count">(%s)</span>', |
|
419 |
$count, |
|
420 |
'themes' |
|
421 |
); |
|
422 |
break; |
|
423 |
case 'auto-update-enabled': |
|
424 |
/* translators: %s: Number of themes. */ |
|
425 |
$text = _n( |
|
426 |
'Auto-updates Enabled <span class="count">(%s)</span>', |
|
427 |
'Auto-updates Enabled <span class="count">(%s)</span>', |
|
428 |
$count |
|
429 |
); |
|
430 |
break; |
|
431 |
case 'auto-update-disabled': |
|
432 |
/* translators: %s: Number of themes. */ |
|
433 |
$text = _n( |
|
434 |
'Auto-updates Disabled <span class="count">(%s)</span>', |
|
435 |
'Auto-updates Disabled <span class="count">(%s)</span>', |
|
436 |
$count |
|
437 |
); |
|
0 | 438 |
break; |
439 |
} |
|
440 |
||
9 | 441 |
if ( $this->is_site_themes ) { |
0 | 442 |
$url = 'site-themes.php?id=' . $this->site_id; |
9 | 443 |
} else { |
0 | 444 |
$url = 'themes.php'; |
9 | 445 |
} |
0 | 446 |
|
16 | 447 |
if ( 'search' !== $type ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
448 |
$status_links[ $type ] = array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
449 |
'url' => esc_url( add_query_arg( 'theme_status', $type, $url ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
450 |
'label' => sprintf( $text, number_format_i18n( $count ) ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
451 |
'current' => $type === $status, |
0 | 452 |
); |
453 |
} |
|
454 |
} |
|
455 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
456 |
return $this->get_views_links( $status_links ); |
0 | 457 |
} |
458 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
*/ |
5 | 464 |
protected function get_bulk_actions() { |
0 | 465 |
global $status; |
466 |
||
467 |
$actions = array(); |
|
16 | 468 |
if ( 'enabled' !== $status ) { |
0 | 469 |
$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
9 | 470 |
} |
16 | 471 |
if ( 'disabled' !== $status ) { |
0 | 472 |
$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
9 | 473 |
} |
0 | 474 |
if ( ! $this->is_site_themes ) { |
9 | 475 |
if ( current_user_can( 'update_themes' ) ) { |
0 | 476 |
$actions['update-selected'] = __( 'Update' ); |
9 | 477 |
} |
478 |
if ( current_user_can( 'delete_themes' ) ) { |
|
0 | 479 |
$actions['delete-selected'] = __( 'Delete' ); |
9 | 480 |
} |
0 | 481 |
} |
16 | 482 |
|
483 |
if ( $this->show_autoupdates ) { |
|
484 |
if ( 'auto-update-enabled' !== $status ) { |
|
485 |
$actions['enable-auto-update-selected'] = __( 'Enable Auto-updates' ); |
|
486 |
} |
|
487 |
||
488 |
if ( 'auto-update-disabled' !== $status ) { |
|
489 |
$actions['disable-auto-update-selected'] = __( 'Disable Auto-updates' ); |
|
490 |
} |
|
491 |
} |
|
492 |
||
0 | 493 |
return $actions; |
494 |
} |
|
495 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
496 |
/** |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
497 |
* Generates the list table rows. |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
498 |
* |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
499 |
* @since 3.1.0 |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
500 |
*/ |
5 | 501 |
public function display_rows() { |
9 | 502 |
foreach ( $this->items as $theme ) { |
0 | 503 |
$this->single_row( $theme ); |
9 | 504 |
} |
0 | 505 |
} |
506 |
||
5 | 507 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
* Handles the checkbox column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
* @since 4.3.0 |
19 | 511 |
* @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
* |
19 | 513 |
* @param WP_Theme $item The current WP_Theme object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
*/ |
19 | 515 |
public function column_cb( $item ) { |
516 |
// Restores the more descriptive, specific name for use within this method. |
|
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
517 |
$theme = $item; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
518 |
|
9 | 519 |
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
520 |
?> |
9 | 521 |
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" /> |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
522 |
<label for="<?php echo $checkbox_id; ?>" > |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
523 |
<span class="screen-reader-text"> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
524 |
<?php |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
525 |
printf( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
526 |
/* translators: Hidden accessibility text. %s: Theme name */ |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
527 |
__( 'Select %s' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
528 |
$theme->display( 'Name' ) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
529 |
); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
530 |
?> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
531 |
</span> |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
532 |
</label> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
533 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
535 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
* Handles the name column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
538 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
539 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
* |
5 | 541 |
* @global string $status |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
* @global int $page |
5 | 543 |
* @global string $s |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
* @param WP_Theme $theme The current WP_Theme object. |
5 | 546 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
public function column_name( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
global $status, $page, $s; |
0 | 549 |
|
550 |
$context = $status; |
|
551 |
||
552 |
if ( $this->is_site_themes ) { |
|
9 | 553 |
$url = "site-themes.php?id={$this->site_id}&"; |
0 | 554 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
555 |
} else { |
|
9 | 556 |
$url = 'themes.php?'; |
0 | 557 |
$allowed = $theme->is_allowed( 'network' ); |
558 |
} |
|
559 |
||
5 | 560 |
// Pre-order. |
0 | 561 |
$actions = array( |
9 | 562 |
'enable' => '', |
0 | 563 |
'disable' => '', |
9 | 564 |
'delete' => '', |
0 | 565 |
); |
566 |
||
567 |
$stylesheet = $theme->get_stylesheet(); |
|
9 | 568 |
$theme_key = urlencode( $stylesheet ); |
0 | 569 |
|
570 |
if ( ! $allowed ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
if ( ! $theme->errors() ) { |
9 | 572 |
$url = add_query_arg( |
573 |
array( |
|
574 |
'action' => 'enable', |
|
575 |
'theme' => $theme_key, |
|
576 |
'paged' => $page, |
|
577 |
's' => $s, |
|
578 |
), |
|
579 |
$url |
|
580 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
581 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
if ( $this->is_site_themes ) { |
16 | 583 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
$aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
} else { |
16 | 586 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
$aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
588 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
589 |
|
9 | 590 |
$actions['enable'] = sprintf( |
591 |
'<a href="%s" class="edit" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
595 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
} |
0 | 597 |
} else { |
9 | 598 |
$url = add_query_arg( |
599 |
array( |
|
600 |
'action' => 'disable', |
|
601 |
'theme' => $theme_key, |
|
602 |
'paged' => $page, |
|
603 |
's' => $s, |
|
604 |
), |
|
605 |
$url |
|
606 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
if ( $this->is_site_themes ) { |
16 | 609 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
$aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
} else { |
16 | 612 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
$aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
|
9 | 616 |
$actions['disable'] = sprintf( |
617 |
'<a href="%s" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
); |
0 | 622 |
} |
623 |
||
16 | 624 |
if ( ! $allowed && ! $this->is_site_themes |
625 |
&& current_user_can( 'delete_themes' ) |
|
626 |
&& get_option( 'stylesheet' ) !== $stylesheet |
|
627 |
&& get_option( 'template' ) !== $stylesheet |
|
628 |
) { |
|
9 | 629 |
$url = add_query_arg( |
630 |
array( |
|
631 |
'action' => 'delete-selected', |
|
632 |
'checked[]' => $theme_key, |
|
633 |
'theme_status' => $context, |
|
634 |
'paged' => $page, |
|
635 |
's' => $s, |
|
636 |
), |
|
637 |
'themes.php' |
|
638 |
); |
|
0 | 639 |
|
16 | 640 |
/* translators: %s: Theme name. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
641 |
$aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) ); |
0 | 642 |
|
9 | 643 |
$actions['delete'] = sprintf( |
644 |
'<a href="%s" class="delete" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
esc_url( wp_nonce_url( $url, 'bulk-themes' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
646 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
647 |
__( 'Delete' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
648 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
} |
5 | 650 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
* Filters the action links displayed for each theme in the Multisite |
5 | 652 |
* themes list table. |
653 |
* |
|
654 |
* The action links displayed are determined by the theme's status, and |
|
655 |
* which Multisite themes list table is being displayed - the Network |
|
656 |
* themes list table (themes.php), which displays all installed themes, |
|
657 |
* or the Site themes list table (site-themes.php), which displays the |
|
658 |
* non-network enabled themes when editing a site in the Network admin. |
|
659 |
* |
|
660 |
* The default action links for the Network themes list table include |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
* 'Network Enable', 'Network Disable', and 'Delete'. |
5 | 662 |
* |
663 |
* The default action links for the Site themes list table include |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
* 'Enable', and 'Disable'. |
5 | 665 |
* |
666 |
* @since 2.8.0 |
|
667 |
* |
|
9 | 668 |
* @param string[] $actions An array of action links. |
5 | 669 |
* @param WP_Theme $theme The current WP_Theme object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
* @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
5 | 671 |
*/ |
0 | 672 |
$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
5 | 673 |
|
674 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
675 |
* Filters the action links of a specific theme in the Multisite themes |
5 | 676 |
* list table. |
677 |
* |
|
678 |
* The dynamic portion of the hook name, `$stylesheet`, refers to the |
|
679 |
* directory name of the theme, which in most cases is synonymous |
|
680 |
* with the template name. |
|
681 |
* |
|
682 |
* @since 3.1.0 |
|
683 |
* |
|
9 | 684 |
* @param string[] $actions An array of action links. |
5 | 685 |
* @param WP_Theme $theme The current WP_Theme object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
* @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
5 | 687 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
$actions = apply_filters( "theme_action_links_{$stylesheet}", $actions, $theme, $context ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
echo $this->row_actions( $actions, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
692 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
* Handles the description column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
695 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
698 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
700 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
701 |
* @param WP_Theme $theme The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
public function column_description( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
global $status, $totals; |
16 | 705 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
if ( $theme->errors() ) { |
22
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
707 |
$pre = 'broken' === $status ? '<strong class="error-message">' . __( 'Broken Theme:' ) . '</strong> ' : ''; |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
708 |
wp_admin_notice( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
709 |
$pre . $theme->errors()->get_error_message(), |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
710 |
array( |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
711 |
'type' => 'error', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
712 |
'additional_classes' => 'inline', |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
713 |
) |
8c2e4d02f4ef
Update WordPress to latest version (6.7)
ymh <ymh.work@gmail.com>
parents:
21
diff
changeset
|
714 |
); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
716 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
$allowed = $theme->is_allowed( 'network' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
} |
0 | 722 |
|
723 |
$class = ! $allowed ? 'inactive' : 'active'; |
|
9 | 724 |
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
0 | 725 |
$class .= ' update'; |
9 | 726 |
} |
0 | 727 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
728 |
echo "<div class='theme-description'><p>" . $theme->display( 'Description' ) . "</p></div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
729 |
<div class='$class second theme-version-author-uri'>"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
730 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
731 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
732 |
$theme_meta = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
733 |
|
9 | 734 |
if ( $theme->get( 'Version' ) ) { |
16 | 735 |
/* translators: %s: Theme version. */ |
9 | 736 |
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display( 'Version' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
737 |
} |
16 | 738 |
|
739 |
/* translators: %s: Theme author. */ |
|
9 | 740 |
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display( 'Author' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
741 |
|
9 | 742 |
if ( $theme->get( 'ThemeURI' ) ) { |
16 | 743 |
/* translators: %s: Theme name. */ |
19 | 744 |
$aria_label = sprintf( __( 'Visit theme site for %s' ), $theme->display( 'Name' ) ); |
0 | 745 |
|
9 | 746 |
$theme_meta[] = sprintf( |
747 |
'<a href="%s" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
748 |
$theme->display( 'ThemeURI' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
749 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
750 |
__( 'Visit Theme Site' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
751 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
752 |
} |
16 | 753 |
|
18 | 754 |
if ( $theme->parent() ) { |
755 |
$theme_meta[] = sprintf( |
|
756 |
/* translators: %s: Theme name. */ |
|
757 |
__( 'Child theme of %s' ), |
|
758 |
'<strong>' . $theme->parent()->display( 'Name' ) . '</strong>' |
|
759 |
); |
|
760 |
} |
|
761 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
763 |
* Filters the array of row meta for each theme in the Multisite themes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
764 |
* list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
765 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
766 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
767 |
* |
16 | 768 |
* @param string[] $theme_meta An array of the theme's metadata, including |
769 |
* the version, author, and theme URI. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
770 |
* @param string $stylesheet Directory name of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
771 |
* @param WP_Theme $theme WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
772 |
* @param string $status Status of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
773 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
774 |
$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
16 | 775 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
776 |
echo implode( ' | ', $theme_meta ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
777 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
778 |
echo '</div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
779 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
780 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
781 |
/** |
16 | 782 |
* Handles the auto-updates column output. |
783 |
* |
|
784 |
* @since 5.5.0 |
|
785 |
* |
|
786 |
* @global string $status |
|
787 |
* @global int $page |
|
788 |
* |
|
789 |
* @param WP_Theme $theme The current WP_Theme object. |
|
790 |
*/ |
|
791 |
public function column_autoupdates( $theme ) { |
|
792 |
global $status, $page; |
|
793 |
||
794 |
static $auto_updates, $available_updates; |
|
795 |
||
796 |
if ( ! $auto_updates ) { |
|
797 |
$auto_updates = (array) get_site_option( 'auto_update_themes', array() ); |
|
798 |
} |
|
799 |
if ( ! $available_updates ) { |
|
800 |
$available_updates = get_site_transient( 'update_themes' ); |
|
801 |
} |
|
802 |
||
803 |
$stylesheet = $theme->get_stylesheet(); |
|
804 |
||
805 |
if ( isset( $theme->auto_update_forced ) ) { |
|
806 |
if ( $theme->auto_update_forced ) { |
|
807 |
// Forced on. |
|
808 |
$text = __( 'Auto-updates enabled' ); |
|
809 |
} else { |
|
810 |
$text = __( 'Auto-updates disabled' ); |
|
811 |
} |
|
812 |
$action = 'unavailable'; |
|
813 |
$time_class = ' hidden'; |
|
814 |
} elseif ( empty( $theme->update_supported ) ) { |
|
815 |
$text = ''; |
|
816 |
$action = 'unavailable'; |
|
817 |
$time_class = ' hidden'; |
|
818 |
} elseif ( in_array( $stylesheet, $auto_updates, true ) ) { |
|
819 |
$text = __( 'Disable auto-updates' ); |
|
820 |
$action = 'disable'; |
|
821 |
$time_class = ''; |
|
822 |
} else { |
|
823 |
$text = __( 'Enable auto-updates' ); |
|
824 |
$action = 'enable'; |
|
825 |
$time_class = ' hidden'; |
|
826 |
} |
|
827 |
||
828 |
$query_args = array( |
|
829 |
'action' => "{$action}-auto-update", |
|
830 |
'theme' => $stylesheet, |
|
831 |
'paged' => $page, |
|
832 |
'theme_status' => $status, |
|
833 |
); |
|
834 |
||
835 |
$url = add_query_arg( $query_args, 'themes.php' ); |
|
836 |
||
837 |
if ( 'unavailable' === $action ) { |
|
838 |
$html[] = '<span class="label">' . $text . '</span>'; |
|
839 |
} else { |
|
840 |
$html[] = sprintf( |
|
841 |
'<a href="%s" class="toggle-auto-update aria-button-if-js" data-wp-action="%s">', |
|
842 |
wp_nonce_url( $url, 'updates' ), |
|
843 |
$action |
|
844 |
); |
|
845 |
||
846 |
$html[] = '<span class="dashicons dashicons-update spin hidden" aria-hidden="true"></span>'; |
|
847 |
$html[] = '<span class="label">' . $text . '</span>'; |
|
848 |
$html[] = '</a>'; |
|
849 |
||
850 |
} |
|
851 |
||
852 |
if ( isset( $available_updates->response[ $stylesheet ] ) ) { |
|
853 |
$html[] = sprintf( |
|
854 |
'<div class="auto-update-time%s">%s</div>', |
|
855 |
$time_class, |
|
856 |
wp_get_auto_update_message() |
|
857 |
); |
|
858 |
} |
|
859 |
||
860 |
$html = implode( '', $html ); |
|
861 |
||
862 |
/** |
|
863 |
* Filters the HTML of the auto-updates setting for each theme in the Themes list table. |
|
864 |
* |
|
865 |
* @since 5.5.0 |
|
866 |
* |
|
867 |
* @param string $html The HTML for theme's auto-update setting, including |
|
868 |
* toggle auto-update action link and time to next update. |
|
869 |
* @param string $stylesheet Directory name of the theme. |
|
870 |
* @param WP_Theme $theme WP_Theme object. |
|
871 |
*/ |
|
872 |
echo apply_filters( 'theme_auto_update_setting_html', $html, $stylesheet, $theme ); |
|
873 |
||
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
874 |
wp_admin_notice( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
875 |
'', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
876 |
array( |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
877 |
'type' => 'error', |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
878 |
'additional_classes' => array( 'notice-alt', 'inline', 'hidden' ), |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
879 |
) |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
880 |
); |
16 | 881 |
} |
882 |
||
883 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
* Handles default column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
885 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
* @since 4.3.0 |
19 | 887 |
* @since 5.9.0 Renamed `$theme` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
* |
19 | 889 |
* @param WP_Theme $item The current WP_Theme object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
* @param string $column_name The current column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
*/ |
19 | 892 |
public function column_default( $item, $column_name ) { |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
893 |
// Restores the more descriptive, specific name for use within this method. |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
894 |
$theme = $item; |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
895 |
|
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
896 |
$stylesheet = $theme->get_stylesheet(); |
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
897 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
898 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
899 |
* Fires inside each custom column of the Multisite themes list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
* @param string $column_name Name of the column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
904 |
* @param string $stylesheet Directory name of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
905 |
* @param WP_Theme $theme Current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
906 |
*/ |
21
48c4eec2b7e6
Add CLAUDE.md documentation and sync WordPress core files
ymh <ymh.work@gmail.com>
parents:
19
diff
changeset
|
907 |
do_action( 'manage_themes_custom_column', $column_name, $stylesheet, $theme ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
908 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
909 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
910 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
911 |
* Handles the output for a single table row. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
912 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
913 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
914 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
915 |
* @param WP_Theme $item The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
916 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
917 |
public function single_row_columns( $item ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
918 |
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
0 | 919 |
|
920 |
foreach ( $columns as $column_name => $column_display_name ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
921 |
$extra_classes = ''; |
16 | 922 |
if ( in_array( $column_name, $hidden, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
923 |
$extra_classes .= ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
924 |
} |
0 | 925 |
|
926 |
switch ( $column_name ) { |
|
927 |
case 'cb': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
928 |
echo '<th scope="row" class="check-column">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
929 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
930 |
$this->column_cb( $item ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
931 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
932 |
echo '</th>'; |
0 | 933 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
934 |
|
0 | 935 |
case 'name': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
936 |
$active_theme_label = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
937 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
938 |
/* The presence of the site_id property means that this is a subsite view and a label for the active theme needs to be added */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
939 |
if ( ! empty( $this->site_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
940 |
$stylesheet = get_blog_option( $this->site_id, 'stylesheet' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
941 |
$template = get_blog_option( $this->site_id, 'template' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
942 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
943 |
/* Add a label for the active template */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
944 |
if ( $item->get_template() === $template ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
945 |
$active_theme_label = ' — ' . __( 'Active Theme' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
946 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
947 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
948 |
/* In case this is a child theme, label it properly */ |
9 | 949 |
if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
950 |
$active_theme_label = ' — ' . __( 'Active Child Theme' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
951 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
952 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
953 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
954 |
echo "<td class='theme-title column-primary{$extra_classes}'><strong>" . $item->display( 'Name' ) . $active_theme_label . '</strong>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
955 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
956 |
$this->column_name( $item ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
957 |
|
9 | 958 |
echo '</td>'; |
0 | 959 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
960 |
|
0 | 961 |
case 'description': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
962 |
echo "<td class='column-description desc{$extra_classes}'>"; |
0 | 963 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
964 |
$this->column_description( $item ); |
0 | 965 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
966 |
echo '</td>'; |
0 | 967 |
break; |
968 |
||
16 | 969 |
case 'auto-updates': |
970 |
echo "<td class='column-auto-updates{$extra_classes}'>"; |
|
971 |
||
972 |
$this->column_autoupdates( $item ); |
|
973 |
||
974 |
echo '</td>'; |
|
975 |
break; |
|
0 | 976 |
default: |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
echo "<td class='$column_name column-$column_name{$extra_classes}'>"; |
5 | 978 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
979 |
$this->column_default( $item, $column_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
980 |
|
9 | 981 |
echo '</td>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
982 |
break; |
0 | 983 |
} |
984 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
985 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
986 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
987 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
988 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
989 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
990 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
991 |
* @param WP_Theme $theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
992 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
993 |
public function single_row( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
994 |
global $status, $totals; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
995 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
996 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
997 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
998 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
999 |
$allowed = $theme->is_allowed( 'network' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1000 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1004 |
$class = ! $allowed ? 'inactive' : 'active'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1005 |
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
$class .= ' update'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1007 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
|
9 | 1009 |
printf( |
1010 |
'<tr class="%s" data-slug="%s">', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1011 |
esc_attr( $class ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1012 |
esc_attr( $stylesheet ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1014 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1015 |
$this->single_row_columns( $theme ); |
0 | 1016 |
|
9 | 1017 |
echo '</tr>'; |
0 | 1018 |
|
9 | 1019 |
if ( $this->is_site_themes ) { |
0 | 1020 |
remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
9 | 1021 |
} |
5 | 1022 |
|
1023 |
/** |
|
1024 |
* Fires after each row in the Multisite themes list table. |
|
1025 |
* |
|
1026 |
* @since 3.1.0 |
|
1027 |
* |
|
1028 |
* @param string $stylesheet Directory name of the theme. |
|
1029 |
* @param WP_Theme $theme Current WP_Theme object. |
|
1030 |
* @param string $status Status of the theme. |
|
1031 |
*/ |
|
0 | 1032 |
do_action( 'after_theme_row', $stylesheet, $theme, $status ); |
5 | 1033 |
|
1034 |
/** |
|
1035 |
* Fires after each specific row in the Multisite themes list table. |
|
1036 |
* |
|
1037 |
* The dynamic portion of the hook name, `$stylesheet`, refers to the |
|
1038 |
* directory name of the theme, most often synonymous with the template |
|
1039 |
* name of the theme. |
|
1040 |
* |
|
1041 |
* @since 3.5.0 |
|
1042 |
* |
|
1043 |
* @param string $stylesheet Directory name of the theme. |
|
1044 |
* @param WP_Theme $theme Current WP_Theme object. |
|
1045 |
* @param string $status Status of the theme. |
|
1046 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status ); |
0 | 1048 |
} |
1049 |
} |