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