author | ymh <ymh.work@gmail.com> |
Tue, 15 Oct 2019 15:48:13 +0200 | |
changeset 13 | d255fe9cd479 |
parent 9 | 177826044cd9 |
child 16 | a86126ab1dd4 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* 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 |
/** |
26 |
* Constructor. |
|
27 |
* |
|
28 |
* @since 3.1.0 |
|
29 |
* |
|
30 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
31 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
* |
5 | 35 |
* @param array $args An associative array of arguments. |
36 |
*/ |
|
37 |
public function __construct( $args = array() ) { |
|
0 | 38 |
global $status, $page; |
39 |
||
9 | 40 |
parent::__construct( |
41 |
array( |
|
42 |
'plural' => 'themes', |
|
43 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
44 |
) |
|
45 |
); |
|
0 | 46 |
|
47 |
$status = isset( $_REQUEST['theme_status'] ) ? $_REQUEST['theme_status'] : 'all'; |
|
9 | 48 |
if ( ! in_array( $status, array( 'all', 'enabled', 'disabled', 'upgrade', 'search', 'broken' ) ) ) { |
0 | 49 |
$status = 'all'; |
9 | 50 |
} |
0 | 51 |
|
52 |
$page = $this->get_pagenum(); |
|
53 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
$this->is_site_themes = ( 'site-themes-network' === $this->screen->id ) ? true : false; |
0 | 55 |
|
9 | 56 |
if ( $this->is_site_themes ) { |
0 | 57 |
$this->site_id = isset( $_REQUEST['id'] ) ? intval( $_REQUEST['id'] ) : 0; |
9 | 58 |
} |
0 | 59 |
} |
60 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
*/ |
5 | 64 |
protected function get_table_classes() { |
65 |
// todo: remove and add CSS for .themes |
|
66 |
return array( 'widefat', 'plugins' ); |
|
0 | 67 |
} |
68 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
*/ |
5 | 72 |
public function ajax_user_can() { |
9 | 73 |
if ( $this->is_site_themes ) { |
0 | 74 |
return current_user_can( 'manage_sites' ); |
9 | 75 |
} else { |
0 | 76 |
return current_user_can( 'manage_network_themes' ); |
9 | 77 |
} |
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 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
* @global int $page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
* @global string $orderby |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
* @global string $order |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
* @global string $s |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
*/ |
5 | 88 |
public function prepare_items() { |
0 | 89 |
global $status, $totals, $page, $orderby, $order, $s; |
90 |
||
91 |
wp_reset_vars( array( 'orderby', 'order', 's' ) ); |
|
92 |
||
93 |
$themes = array( |
|
5 | 94 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
* Filters the full array of WP_Theme objects to list in the Multisite |
5 | 96 |
* themes list table. |
97 |
* |
|
98 |
* @since 3.1.0 |
|
99 |
* |
|
9 | 100 |
* @param WP_Theme[] $all Array of WP_Theme objects to display in the list table. |
5 | 101 |
*/ |
9 | 102 |
'all' => apply_filters( 'all_themes', wp_get_themes() ), |
103 |
'search' => array(), |
|
104 |
'enabled' => array(), |
|
0 | 105 |
'disabled' => array(), |
9 | 106 |
'upgrade' => array(), |
107 |
'broken' => $this->is_site_themes ? array() : wp_get_themes( array( 'errors' => true ) ), |
|
0 | 108 |
); |
109 |
||
110 |
if ( $this->is_site_themes ) { |
|
111 |
$themes_per_page = $this->get_items_per_page( 'site_themes_network_per_page' ); |
|
9 | 112 |
$allowed_where = 'site'; |
0 | 113 |
} else { |
114 |
$themes_per_page = $this->get_items_per_page( 'themes_network_per_page' ); |
|
9 | 115 |
$allowed_where = 'network'; |
0 | 116 |
} |
117 |
||
118 |
$maybe_update = current_user_can( 'update_themes' ) && ! $this->is_site_themes && $current = get_site_transient( 'update_themes' ); |
|
119 |
||
120 |
foreach ( (array) $themes['all'] as $key => $theme ) { |
|
121 |
if ( $this->is_site_themes && $theme->is_allowed( 'network' ) ) { |
|
122 |
unset( $themes['all'][ $key ] ); |
|
123 |
continue; |
|
124 |
} |
|
125 |
||
126 |
if ( $maybe_update && isset( $current->response[ $key ] ) ) { |
|
127 |
$themes['all'][ $key ]->update = true; |
|
9 | 128 |
$themes['upgrade'][ $key ] = $themes['all'][ $key ]; |
0 | 129 |
} |
130 |
||
9 | 131 |
$filter = $theme->is_allowed( $allowed_where, $this->site_id ) ? 'enabled' : 'disabled'; |
0 | 132 |
$themes[ $filter ][ $key ] = $themes['all'][ $key ]; |
133 |
} |
|
134 |
||
135 |
if ( $s ) { |
|
9 | 136 |
$status = 'search'; |
0 | 137 |
$themes['search'] = array_filter( array_merge( $themes['all'], $themes['broken'] ), array( $this, '_search_callback' ) ); |
138 |
} |
|
139 |
||
140 |
$totals = array(); |
|
9 | 141 |
foreach ( $themes as $type => $list ) { |
0 | 142 |
$totals[ $type ] = count( $list ); |
9 | 143 |
} |
0 | 144 |
|
9 | 145 |
if ( empty( $themes[ $status ] ) && ! in_array( $status, array( 'all', 'search' ) ) ) { |
0 | 146 |
$status = 'all'; |
9 | 147 |
} |
0 | 148 |
|
149 |
$this->items = $themes[ $status ]; |
|
150 |
WP_Theme::sort_by_name( $this->items ); |
|
151 |
||
152 |
$this->has_items = ! empty( $themes['all'] ); |
|
153 |
$total_this_page = $totals[ $status ]; |
|
154 |
||
9 | 155 |
wp_localize_script( |
156 |
'updates', |
|
157 |
'_wpUpdatesItemCounts', |
|
158 |
array( |
|
159 |
'themes' => $totals, |
|
160 |
'totals' => wp_get_update_data(), |
|
161 |
) |
|
162 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
|
0 | 164 |
if ( $orderby ) { |
165 |
$orderby = ucfirst( $orderby ); |
|
9 | 166 |
$order = strtoupper( $order ); |
0 | 167 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
if ( $orderby === 'Name' ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
if ( 'ASC' === $order ) { |
0 | 170 |
$this->items = array_reverse( $this->items ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
} |
0 | 172 |
} else { |
173 |
uasort( $this->items, array( $this, '_order_callback' ) ); |
|
174 |
} |
|
175 |
} |
|
176 |
||
177 |
$start = ( $page - 1 ) * $themes_per_page; |
|
178 |
||
9 | 179 |
if ( $total_this_page > $themes_per_page ) { |
0 | 180 |
$this->items = array_slice( $this->items, $start, $themes_per_page, true ); |
9 | 181 |
} |
0 | 182 |
|
9 | 183 |
$this->set_pagination_args( |
184 |
array( |
|
185 |
'total_items' => $total_this_page, |
|
186 |
'per_page' => $themes_per_page, |
|
187 |
) |
|
188 |
); |
|
0 | 189 |
} |
190 |
||
5 | 191 |
/** |
192 |
* @staticvar string $term |
|
193 |
* @param WP_Theme $theme |
|
194 |
* @return bool |
|
195 |
*/ |
|
196 |
public function _search_callback( $theme ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
static $term = null; |
9 | 198 |
if ( is_null( $term ) ) { |
0 | 199 |
$term = wp_unslash( $_REQUEST['s'] ); |
9 | 200 |
} |
0 | 201 |
|
202 |
foreach ( array( 'Name', 'Description', 'Author', 'Author', 'AuthorURI' ) as $field ) { |
|
203 |
// Don't mark up; Do translate. |
|
9 | 204 |
if ( false !== stripos( $theme->display( $field, false, true ), $term ) ) { |
0 | 205 |
return true; |
9 | 206 |
} |
0 | 207 |
} |
208 |
||
9 | 209 |
if ( false !== stripos( $theme->get_stylesheet(), $term ) ) { |
0 | 210 |
return true; |
9 | 211 |
} |
0 | 212 |
|
9 | 213 |
if ( false !== stripos( $theme->get_template(), $term ) ) { |
0 | 214 |
return true; |
9 | 215 |
} |
0 | 216 |
|
217 |
return false; |
|
218 |
} |
|
219 |
||
220 |
// Not used by any core columns. |
|
5 | 221 |
/** |
222 |
* @global string $orderby |
|
223 |
* @global string $order |
|
224 |
* @param array $theme_a |
|
225 |
* @param array $theme_b |
|
226 |
* @return int |
|
227 |
*/ |
|
228 |
public function _order_callback( $theme_a, $theme_b ) { |
|
0 | 229 |
global $orderby, $order; |
230 |
||
231 |
$a = $theme_a[ $orderby ]; |
|
232 |
$b = $theme_b[ $orderby ]; |
|
233 |
||
9 | 234 |
if ( $a == $b ) { |
0 | 235 |
return 0; |
9 | 236 |
} |
0 | 237 |
|
9 | 238 |
if ( 'DESC' === $order ) { |
0 | 239 |
return ( $a < $b ) ? 1 : -1; |
9 | 240 |
} else { |
0 | 241 |
return ( $a < $b ) ? -1 : 1; |
9 | 242 |
} |
0 | 243 |
} |
244 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
245 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
246 |
*/ |
5 | 247 |
public function no_items() { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
248 |
if ( $this->has_items ) { |
0 | 249 |
_e( 'No themes found.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
} else { |
0 | 251 |
_e( 'You do not appear to have any themes available at this time.' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
} |
0 | 253 |
} |
254 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
255 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
256 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
*/ |
5 | 258 |
public function get_columns() { |
0 | 259 |
return array( |
260 |
'cb' => '<input type="checkbox" />', |
|
261 |
'name' => __( 'Theme' ), |
|
262 |
'description' => __( 'Description' ), |
|
263 |
); |
|
264 |
} |
|
265 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
266 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
268 |
*/ |
5 | 269 |
protected function get_sortable_columns() { |
0 | 270 |
return array( |
9 | 271 |
'name' => 'name', |
0 | 272 |
); |
273 |
} |
|
274 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
275 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
276 |
* Gets the name of the primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
* @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
|
281 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
protected function get_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
return 'name'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
284 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
285 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
286 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
*/ |
5 | 291 |
protected function get_views() { |
0 | 292 |
global $totals, $status; |
293 |
||
294 |
$status_links = array(); |
|
295 |
foreach ( $totals as $type => $count ) { |
|
9 | 296 |
if ( ! $count ) { |
0 | 297 |
continue; |
9 | 298 |
} |
0 | 299 |
|
300 |
switch ( $type ) { |
|
301 |
case 'all': |
|
302 |
$text = _nx( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $count, 'themes' ); |
|
303 |
break; |
|
304 |
case 'enabled': |
|
305 |
$text = _n( 'Enabled <span class="count">(%s)</span>', 'Enabled <span class="count">(%s)</span>', $count ); |
|
306 |
break; |
|
307 |
case 'disabled': |
|
308 |
$text = _n( 'Disabled <span class="count">(%s)</span>', 'Disabled <span class="count">(%s)</span>', $count ); |
|
309 |
break; |
|
310 |
case 'upgrade': |
|
311 |
$text = _n( 'Update Available <span class="count">(%s)</span>', 'Update Available <span class="count">(%s)</span>', $count ); |
|
312 |
break; |
|
9 | 313 |
case 'broken': |
0 | 314 |
$text = _n( 'Broken <span class="count">(%s)</span>', 'Broken <span class="count">(%s)</span>', $count ); |
315 |
break; |
|
316 |
} |
|
317 |
||
9 | 318 |
if ( $this->is_site_themes ) { |
0 | 319 |
$url = 'site-themes.php?id=' . $this->site_id; |
9 | 320 |
} else { |
0 | 321 |
$url = 'themes.php'; |
9 | 322 |
} |
0 | 323 |
|
324 |
if ( 'search' != $type ) { |
|
9 | 325 |
$status_links[ $type ] = sprintf( |
326 |
"<a href='%s'%s>%s</a>", |
|
327 |
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
|
328 |
( $type === $status ) ? ' class="current" aria-current="page"' : '', |
0 | 329 |
sprintf( $text, number_format_i18n( $count ) ) |
330 |
); |
|
331 |
} |
|
332 |
} |
|
333 |
||
334 |
return $status_links; |
|
335 |
} |
|
336 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
*/ |
5 | 342 |
protected function get_bulk_actions() { |
0 | 343 |
global $status; |
344 |
||
345 |
$actions = array(); |
|
9 | 346 |
if ( 'enabled' != $status ) { |
0 | 347 |
$actions['enable-selected'] = $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ); |
9 | 348 |
} |
349 |
if ( 'disabled' != $status ) { |
|
0 | 350 |
$actions['disable-selected'] = $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ); |
9 | 351 |
} |
0 | 352 |
if ( ! $this->is_site_themes ) { |
9 | 353 |
if ( current_user_can( 'update_themes' ) ) { |
0 | 354 |
$actions['update-selected'] = __( 'Update' ); |
9 | 355 |
} |
356 |
if ( current_user_can( 'delete_themes' ) ) { |
|
0 | 357 |
$actions['delete-selected'] = __( 'Delete' ); |
9 | 358 |
} |
0 | 359 |
} |
360 |
return $actions; |
|
361 |
} |
|
362 |
||
7
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 |
*/ |
5 | 365 |
public function display_rows() { |
9 | 366 |
foreach ( $this->items as $theme ) { |
0 | 367 |
$this->single_row( $theme ); |
9 | 368 |
} |
0 | 369 |
} |
370 |
||
5 | 371 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
* Handles the checkbox column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
* @param WP_Theme $theme The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
public function column_cb( $theme ) { |
9 | 379 |
$checkbox_id = 'checkbox_' . md5( $theme->get( 'Name' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
?> |
9 | 381 |
<input type="checkbox" name="checked[]" value="<?php echo esc_attr( $theme->get_stylesheet() ); ?>" id="<?php echo $checkbox_id; ?>" /> |
382 |
<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
|
383 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
* Handles the name column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
* |
5 | 391 |
* @global string $status |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
* @global int $page |
5 | 393 |
* @global string $s |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
* @param WP_Theme $theme The current WP_Theme object. |
5 | 396 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
public function column_name( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
global $status, $page, $s; |
0 | 399 |
|
400 |
$context = $status; |
|
401 |
||
402 |
if ( $this->is_site_themes ) { |
|
9 | 403 |
$url = "site-themes.php?id={$this->site_id}&"; |
0 | 404 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
405 |
} else { |
|
9 | 406 |
$url = 'themes.php?'; |
0 | 407 |
$allowed = $theme->is_allowed( 'network' ); |
408 |
} |
|
409 |
||
5 | 410 |
// Pre-order. |
0 | 411 |
$actions = array( |
9 | 412 |
'enable' => '', |
0 | 413 |
'disable' => '', |
9 | 414 |
'delete' => '', |
0 | 415 |
); |
416 |
||
417 |
$stylesheet = $theme->get_stylesheet(); |
|
9 | 418 |
$theme_key = urlencode( $stylesheet ); |
0 | 419 |
|
420 |
if ( ! $allowed ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
if ( ! $theme->errors() ) { |
9 | 422 |
$url = add_query_arg( |
423 |
array( |
|
424 |
'action' => 'enable', |
|
425 |
'theme' => $theme_key, |
|
426 |
'paged' => $page, |
|
427 |
's' => $s, |
|
428 |
), |
|
429 |
$url |
|
430 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
$aria_label = sprintf( __( 'Enable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
$aria_label = sprintf( __( 'Network Enable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
|
9 | 440 |
$actions['enable'] = sprintf( |
441 |
'<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
|
442 |
esc_url( wp_nonce_url( $url, 'enable-theme_' . $stylesheet ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
444 |
( $this->is_site_themes ? __( 'Enable' ) : __( 'Network Enable' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
} |
0 | 447 |
} else { |
9 | 448 |
$url = add_query_arg( |
449 |
array( |
|
450 |
'action' => 'disable', |
|
451 |
'theme' => $theme_key, |
|
452 |
'paged' => $page, |
|
453 |
's' => $s, |
|
454 |
), |
|
455 |
$url |
|
456 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
$aria_label = sprintf( __( 'Disable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
$aria_label = sprintf( __( 'Network Disable %s' ), $theme->display( 'Name' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
|
9 | 466 |
$actions['disable'] = sprintf( |
467 |
'<a href="%s" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
esc_url( wp_nonce_url( $url, 'disable-theme_' . $stylesheet ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
( $this->is_site_themes ? __( 'Disable' ) : __( 'Network Disable' ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
); |
0 | 472 |
} |
473 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
474 |
if ( ! $allowed && current_user_can( 'delete_themes' ) && ! $this->is_site_themes && $stylesheet != get_option( 'stylesheet' ) && $stylesheet != get_option( 'template' ) ) { |
9 | 475 |
$url = add_query_arg( |
476 |
array( |
|
477 |
'action' => 'delete-selected', |
|
478 |
'checked[]' => $theme_key, |
|
479 |
'theme_status' => $context, |
|
480 |
'paged' => $page, |
|
481 |
's' => $s, |
|
482 |
), |
|
483 |
'themes.php' |
|
484 |
); |
|
0 | 485 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
$aria_label = sprintf( _x( 'Delete %s', 'theme' ), $theme->display( 'Name' ) ); |
0 | 488 |
|
9 | 489 |
$actions['delete'] = sprintf( |
490 |
'<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
|
491 |
esc_url( wp_nonce_url( $url, 'bulk-themes' ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
492 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
493 |
__( 'Delete' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
494 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
495 |
} |
5 | 496 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
497 |
* Filters the action links displayed for each theme in the Multisite |
5 | 498 |
* themes list table. |
499 |
* |
|
500 |
* The action links displayed are determined by the theme's status, and |
|
501 |
* which Multisite themes list table is being displayed - the Network |
|
502 |
* themes list table (themes.php), which displays all installed themes, |
|
503 |
* or the Site themes list table (site-themes.php), which displays the |
|
504 |
* non-network enabled themes when editing a site in the Network admin. |
|
505 |
* |
|
506 |
* 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
|
507 |
* 'Network Enable', 'Network Disable', and 'Delete'. |
5 | 508 |
* |
509 |
* 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
|
510 |
* 'Enable', and 'Disable'. |
5 | 511 |
* |
512 |
* @since 2.8.0 |
|
513 |
* |
|
9 | 514 |
* @param string[] $actions An array of action links. |
5 | 515 |
* @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
|
516 |
* @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
5 | 517 |
*/ |
0 | 518 |
$actions = apply_filters( 'theme_action_links', array_filter( $actions ), $theme, $context ); |
5 | 519 |
|
520 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
521 |
* Filters the action links of a specific theme in the Multisite themes |
5 | 522 |
* list table. |
523 |
* |
|
524 |
* The dynamic portion of the hook name, `$stylesheet`, refers to the |
|
525 |
* directory name of the theme, which in most cases is synonymous |
|
526 |
* with the template name. |
|
527 |
* |
|
528 |
* @since 3.1.0 |
|
529 |
* |
|
9 | 530 |
* @param string[] $actions An array of action links. |
5 | 531 |
* @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
|
532 |
* @param string $context Status of the theme, one of 'all', 'enabled', or 'disabled'. |
5 | 533 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
534 |
$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
|
535 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
536 |
echo $this->row_actions( $actions, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
537 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
540 |
* Handles the description column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
541 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
542 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
543 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
544 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
545 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
546 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
547 |
* @param WP_Theme $theme The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
548 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
549 |
public function column_description( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
550 |
global $status, $totals; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
551 |
if ( $theme->errors() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
552 |
$pre = $status === 'broken' ? __( 'Broken Theme:' ) . ' ' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
553 |
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
|
554 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
555 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
556 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
558 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
559 |
$allowed = $theme->is_allowed( 'network' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
} |
0 | 561 |
|
562 |
$class = ! $allowed ? 'inactive' : 'active'; |
|
9 | 563 |
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
0 | 564 |
$class .= ' update'; |
9 | 565 |
} |
0 | 566 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
567 |
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
|
568 |
<div class='$class second theme-version-author-uri'>"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
569 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
$theme_meta = array(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
|
9 | 573 |
if ( $theme->get( 'Version' ) ) { |
574 |
$theme_meta[] = sprintf( __( 'Version %s' ), $theme->display( 'Version' ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
} |
9 | 576 |
$theme_meta[] = sprintf( __( 'By %s' ), $theme->display( 'Author' ) ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
577 |
|
9 | 578 |
if ( $theme->get( 'ThemeURI' ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
/* translators: %s: theme name */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
$aria_label = sprintf( __( 'Visit %s homepage' ), $theme->display( 'Name' ) ); |
0 | 581 |
|
9 | 582 |
$theme_meta[] = sprintf( |
583 |
'<a href="%s" aria-label="%s">%s</a>', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
$theme->display( 'ThemeURI' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
esc_attr( $aria_label ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
586 |
__( 'Visit Theme Site' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
587 |
); |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
590 |
* 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
|
591 |
* list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
592 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
593 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
594 |
* |
9 | 595 |
* @param string[] $theme_meta An array of the theme's metadata, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
* including the version, author, and |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
* theme URI. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
* @param string $stylesheet Directory name of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
* @param WP_Theme $theme WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
* @param string $status Status of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
601 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
602 |
$theme_meta = apply_filters( 'theme_row_meta', $theme_meta, $stylesheet, $theme, $status ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
echo implode( ' | ', $theme_meta ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
605 |
echo '</div>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
606 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
* Handles default column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
610 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
611 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
612 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
613 |
* @param WP_Theme $theme The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
614 |
* @param string $column_name The current column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
615 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
616 |
public function column_default( $theme, $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
620 |
* 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
|
621 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
622 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
623 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
624 |
* @param string $column_name Name of the column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
625 |
* @param string $stylesheet Directory name of the theme. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
626 |
* @param WP_Theme $theme Current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
627 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
628 |
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
|
629 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
630 |
|
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 |
* Handles the output for a single table row. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
633 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
634 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
635 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
636 |
* @param WP_Theme $item The current WP_Theme object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
637 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
638 |
public function single_row_columns( $item ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
list( $columns, $hidden, $sortable, $primary ) = $this->get_column_info(); |
0 | 640 |
|
641 |
foreach ( $columns as $column_name => $column_display_name ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
642 |
$extra_classes = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
643 |
if ( in_array( $column_name, $hidden ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
644 |
$extra_classes .= ' hidden'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
645 |
} |
0 | 646 |
|
647 |
switch ( $column_name ) { |
|
648 |
case 'cb': |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
649 |
echo '<th scope="row" class="check-column">'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
650 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
651 |
$this->column_cb( $item ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
652 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
653 |
echo '</th>'; |
0 | 654 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
655 |
|
0 | 656 |
case 'name': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
$active_theme_label = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
659 |
/* 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
|
660 |
if ( ! empty( $this->site_id ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
661 |
$stylesheet = get_blog_option( $this->site_id, 'stylesheet' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
$template = get_blog_option( $this->site_id, 'template' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
663 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
664 |
/* Add a label for the active template */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
665 |
if ( $item->get_template() === $template ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
666 |
$active_theme_label = ' — ' . __( 'Active Theme' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
667 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
668 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
/* In case this is a child theme, label it properly */ |
9 | 670 |
if ( $stylesheet !== $template && $item->get_stylesheet() === $stylesheet ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
$active_theme_label = ' — ' . __( 'Active Child Theme' ); |
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 |
} |
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 |
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
|
676 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
677 |
$this->column_name( $item ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
678 |
|
9 | 679 |
echo '</td>'; |
0 | 680 |
break; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
681 |
|
0 | 682 |
case 'description': |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
683 |
echo "<td class='column-description desc{$extra_classes}'>"; |
0 | 684 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
$this->column_description( $item ); |
0 | 686 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
echo '</td>'; |
0 | 688 |
break; |
689 |
||
690 |
default: |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
691 |
echo "<td class='$column_name column-$column_name{$extra_classes}'>"; |
5 | 692 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
693 |
$this->column_default( $item, $column_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
694 |
|
9 | 695 |
echo '</td>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
696 |
break; |
0 | 697 |
} |
698 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
699 |
} |
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 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
* @global string $status |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
703 |
* @global array $totals |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
704 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
* @param WP_Theme $theme |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
706 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
707 |
public function single_row( $theme ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
708 |
global $status, $totals; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
709 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
710 |
if ( $this->is_site_themes ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
711 |
$allowed = $theme->is_allowed( 'site', $this->site_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
712 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
713 |
$allowed = $theme->is_allowed( 'network' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
714 |
} |
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 |
$stylesheet = $theme->get_stylesheet(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
718 |
$class = ! $allowed ? 'inactive' : 'active'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
719 |
if ( ! empty( $totals['upgrade'] ) && ! empty( $theme->update ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
720 |
$class .= ' update'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
721 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
|
9 | 723 |
printf( |
724 |
'<tr class="%s" data-slug="%s">', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
725 |
esc_attr( $class ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
esc_attr( $stylesheet ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
727 |
); |
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 |
$this->single_row_columns( $theme ); |
0 | 730 |
|
9 | 731 |
echo '</tr>'; |
0 | 732 |
|
9 | 733 |
if ( $this->is_site_themes ) { |
0 | 734 |
remove_action( "after_theme_row_$stylesheet", 'wp_theme_update_row' ); |
9 | 735 |
} |
5 | 736 |
|
737 |
/** |
|
738 |
* Fires after each row in the Multisite themes list table. |
|
739 |
* |
|
740 |
* @since 3.1.0 |
|
741 |
* |
|
742 |
* @param string $stylesheet Directory name of the theme. |
|
743 |
* @param WP_Theme $theme Current WP_Theme object. |
|
744 |
* @param string $status Status of the theme. |
|
745 |
*/ |
|
0 | 746 |
do_action( 'after_theme_row', $stylesheet, $theme, $status ); |
5 | 747 |
|
748 |
/** |
|
749 |
* Fires after each specific row in the Multisite themes list table. |
|
750 |
* |
|
751 |
* The dynamic portion of the hook name, `$stylesheet`, refers to the |
|
752 |
* directory name of the theme, most often synonymous with the template |
|
753 |
* name of the theme. |
|
754 |
* |
|
755 |
* @since 3.5.0 |
|
756 |
* |
|
757 |
* @param string $stylesheet Directory name of the theme. |
|
758 |
* @param WP_Theme $theme Current WP_Theme object. |
|
759 |
* @param string $status Status of the theme. |
|
760 |
*/ |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
761 |
do_action( "after_theme_row_{$stylesheet}", $stylesheet, $theme, $status ); |
0 | 762 |
} |
763 |
} |