author | ymh <ymh.work@gmail.com> |
Tue, 27 Sep 2022 16:37:53 +0200 | |
changeset 19 | 3d72ae0968f4 |
parent 18 | be944660c56a |
child 21 | 48c4eec2b7e6 |
permissions | -rw-r--r-- |
0 | 1 |
<?php |
2 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
3 |
* List Table API: WP_Posts_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 posts in a list table. |
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_Posts_List_Table extends WP_List_Table { |
|
19 |
||
20 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
* Whether the items should be displayed hierarchically or linearly. |
0 | 22 |
* |
23 |
* @since 3.1.0 |
|
24 |
* @var bool |
|
25 |
*/ |
|
5 | 26 |
protected $hierarchical_display; |
0 | 27 |
|
28 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
* Holds the number of pending comments for each post. |
0 | 30 |
* |
31 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
* @var array |
0 | 33 |
*/ |
5 | 34 |
protected $comment_pending_count; |
0 | 35 |
|
36 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
* Holds the number of posts for this user. |
0 | 38 |
* |
39 |
* @since 3.1.0 |
|
40 |
* @var int |
|
41 |
*/ |
|
5 | 42 |
private $user_posts_count; |
0 | 43 |
|
44 |
/** |
|
45 |
* Holds the number of posts which are sticky. |
|
46 |
* |
|
47 |
* @since 3.1.0 |
|
48 |
* @var int |
|
49 |
*/ |
|
5 | 50 |
private $sticky_posts_count = 0; |
51 |
||
52 |
private $is_trash; |
|
0 | 53 |
|
5 | 54 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
* Current level for output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
* @var int |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
protected $current_level = 0; |
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 |
/** |
5 | 63 |
* Constructor. |
64 |
* |
|
65 |
* @since 3.1.0 |
|
66 |
* |
|
67 |
* @see WP_List_Table::__construct() for more information on default arguments. |
|
68 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
* @global WP_Post_Type $post_type_object |
16 | 70 |
* @global wpdb $wpdb WordPress database abstraction object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
* |
5 | 72 |
* @param array $args An associative array of arguments. |
73 |
*/ |
|
74 |
public function __construct( $args = array() ) { |
|
0 | 75 |
global $post_type_object, $wpdb; |
76 |
||
9 | 77 |
parent::__construct( |
78 |
array( |
|
79 |
'plural' => 'posts', |
|
80 |
'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
|
81 |
) |
|
82 |
); |
|
0 | 83 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
$post_type = $this->screen->post_type; |
0 | 85 |
$post_type_object = get_post_type_object( $post_type ); |
86 |
||
18 | 87 |
$exclude_states = get_post_stati( |
9 | 88 |
array( |
89 |
'show_in_admin_all_list' => false, |
|
90 |
) |
|
91 |
); |
|
18 | 92 |
|
93 |
$this->user_posts_count = (int) $wpdb->get_var( |
|
94 |
$wpdb->prepare( |
|
95 |
"SELECT COUNT( 1 ) |
|
96 |
FROM $wpdb->posts |
|
97 |
WHERE post_type = %s |
|
98 |
AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
|
99 |
AND post_author = %d", |
|
100 |
$post_type, |
|
101 |
get_current_user_id() |
|
9 | 102 |
) |
103 |
); |
|
0 | 104 |
|
18 | 105 |
if ( $this->user_posts_count |
106 |
&& ! current_user_can( $post_type_object->cap->edit_others_posts ) |
|
107 |
&& empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) |
|
108 |
&& empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) |
|
109 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
$_GET['author'] = get_current_user_id(); |
0 | 111 |
} |
112 |
||
16 | 113 |
$sticky_posts = get_option( 'sticky_posts' ); |
18 | 114 |
|
16 | 115 |
if ( 'post' === $post_type && $sticky_posts ) { |
18 | 116 |
$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
117 |
||
118 |
$this->sticky_posts_count = (int) $wpdb->get_var( |
|
119 |
$wpdb->prepare( |
|
120 |
"SELECT COUNT( 1 ) |
|
121 |
FROM $wpdb->posts |
|
122 |
WHERE post_type = %s |
|
123 |
AND post_status NOT IN ('trash', 'auto-draft') |
|
124 |
AND ID IN ($sticky_posts)", |
|
125 |
$post_type |
|
126 |
) |
|
127 |
); |
|
0 | 128 |
} |
129 |
} |
|
130 |
||
5 | 131 |
/** |
132 |
* Sets whether the table layout should be hierarchical or not. |
|
133 |
* |
|
134 |
* @since 4.2.0 |
|
135 |
* |
|
136 |
* @param bool $display Whether the table layout should be hierarchical. |
|
137 |
*/ |
|
138 |
public function set_hierarchical_display( $display ) { |
|
139 |
$this->hierarchical_display = $display; |
|
140 |
} |
|
141 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
*/ |
5 | 145 |
public function ajax_user_can() { |
0 | 146 |
return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
147 |
} |
|
148 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
/** |
16 | 150 |
* @global string $mode List table view mode. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
* @global array $avail_post_stati |
16 | 152 |
* @global WP_Query $wp_query WordPress Query object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
* @global int $per_page |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
*/ |
5 | 155 |
public function prepare_items() { |
16 | 156 |
global $mode, $avail_post_stati, $wp_query, $per_page; |
0 | 157 |
|
16 | 158 |
if ( ! empty( $_REQUEST['mode'] ) ) { |
159 |
$mode = 'excerpt' === $_REQUEST['mode'] ? 'excerpt' : 'list'; |
|
160 |
set_user_setting( 'posts_list_mode', $mode ); |
|
161 |
} else { |
|
162 |
$mode = get_user_setting( 'posts_list_mode', 'list' ); |
|
163 |
} |
|
164 |
||
165 |
// Is going to call wp(). |
|
0 | 166 |
$avail_post_stati = wp_edit_posts_query(); |
167 |
||
18 | 168 |
$this->set_hierarchical_display( |
169 |
is_post_type_hierarchical( $this->screen->post_type ) |
|
170 |
&& 'menu_order title' === $wp_query->query['orderby'] |
|
171 |
); |
|
0 | 172 |
|
173 |
$post_type = $this->screen->post_type; |
|
9 | 174 |
$per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
5 | 175 |
|
176 |
/** This filter is documented in wp-admin/includes/post.php */ |
|
9 | 177 |
$per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
0 | 178 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
if ( $this->hierarchical_display ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
$total_items = $wp_query->post_count; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
} elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
$total_items = $wp_query->found_posts; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
$post_counts = (array) wp_count_posts( $post_type, 'readable' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
|
16 | 186 |
if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
187 |
$total_items = $post_counts[ $_REQUEST['post_status'] ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
188 |
} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
189 |
$total_items = $this->sticky_posts_count; |
18 | 190 |
} elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
191 |
$total_items = $this->user_posts_count; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
192 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
193 |
$total_items = array_sum( $post_counts ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
194 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
// Subtract post types that are not included in the admin all list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
$total_items -= $post_counts[ $state ]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
} |
0 | 201 |
|
16 | 202 |
$this->is_trash = isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status']; |
0 | 203 |
|
9 | 204 |
$this->set_pagination_args( |
205 |
array( |
|
206 |
'total_items' => $total_items, |
|
207 |
'per_page' => $per_page, |
|
208 |
) |
|
209 |
); |
|
0 | 210 |
} |
211 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
* @return bool |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
*/ |
5 | 215 |
public function has_items() { |
0 | 216 |
return have_posts(); |
217 |
} |
|
218 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
219 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
220 |
*/ |
5 | 221 |
public function no_items() { |
9 | 222 |
if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) { |
0 | 223 |
echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
9 | 224 |
} else { |
0 | 225 |
echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
9 | 226 |
} |
0 | 227 |
} |
228 |
||
5 | 229 |
/** |
230 |
* Determine if the current view is the "All" view. |
|
231 |
* |
|
232 |
* @since 4.2.0 |
|
233 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
234 |
* @return bool Whether the current view is the "All" view. |
5 | 235 |
*/ |
236 |
protected function is_base_request() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
$vars = $_GET; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
unset( $vars['paged'] ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
if ( empty( $vars ) ) { |
5 | 241 |
return true; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
} elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
243 |
return $this->screen->post_type === $vars['post_type']; |
5 | 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 |
return 1 === count( $vars ) && ! empty( $vars['mode'] ); |
5 | 247 |
} |
248 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
249 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
250 |
* Helper to create links to edit.php with params. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
251 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
252 |
* @since 4.4.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
253 |
* |
19 | 254 |
* @param string[] $args Associative array of URL parameters for the link. |
255 |
* @param string $link_text Link text. |
|
256 |
* @param string $css_class Optional. Class attribute. Default empty string. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
257 |
* @return string The formatted link string. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
258 |
*/ |
19 | 259 |
protected function get_edit_link( $args, $link_text, $css_class = '' ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
260 |
$url = add_query_arg( $args, 'edit.php' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
261 |
|
16 | 262 |
$class_html = ''; |
263 |
$aria_current = ''; |
|
18 | 264 |
|
19 | 265 |
if ( ! empty( $css_class ) ) { |
9 | 266 |
$class_html = sprintf( |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
267 |
' class="%s"', |
19 | 268 |
esc_attr( $css_class ) |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
269 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
270 |
|
19 | 271 |
if ( 'current' === $css_class ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
272 |
$aria_current = ' aria-current="page"'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
273 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
274 |
} |
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 |
return sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
277 |
'<a href="%s"%s%s>%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
278 |
esc_url( $url ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
279 |
$class_html, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
280 |
$aria_current, |
19 | 281 |
$link_text |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
282 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
283 |
} |
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 |
* @global array $locked_post_status This seems to be deprecated. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
287 |
* @global array $avail_post_stati |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
288 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
289 |
*/ |
5 | 290 |
protected function get_views() { |
0 | 291 |
global $locked_post_status, $avail_post_stati; |
292 |
||
293 |
$post_type = $this->screen->post_type; |
|
294 |
||
9 | 295 |
if ( ! empty( $locked_post_status ) ) { |
0 | 296 |
return array(); |
9 | 297 |
} |
0 | 298 |
|
299 |
$status_links = array(); |
|
9 | 300 |
$num_posts = wp_count_posts( $post_type, 'readable' ); |
301 |
$total_posts = array_sum( (array) $num_posts ); |
|
302 |
$class = ''; |
|
0 | 303 |
|
304 |
$current_user_id = get_current_user_id(); |
|
9 | 305 |
$all_args = array( 'post_type' => $post_type ); |
306 |
$mine = ''; |
|
0 | 307 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
// Subtract post types that are not included in the admin all list. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
$total_posts -= $num_posts->$state; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { |
18 | 314 |
if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
$class = 'current'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
$mine_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
'post_type' => $post_type, |
9 | 320 |
'author' => $current_user_id, |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
$mine_inner_html = sprintf( |
16 | 324 |
/* translators: %s: Number of posts. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
_nx( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
'Mine <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
'Mine <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
$this->user_posts_count, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
'posts' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
number_format_i18n( $this->user_posts_count ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
$mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
$all_args['all_posts'] = 1; |
9 | 337 |
$class = ''; |
0 | 338 |
} |
339 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
$class = 'current'; |
5 | 342 |
} |
343 |
||
344 |
$all_inner_html = sprintf( |
|
16 | 345 |
/* translators: %s: Number of posts. */ |
5 | 346 |
_nx( |
347 |
'All <span class="count">(%s)</span>', |
|
348 |
'All <span class="count">(%s)</span>', |
|
349 |
$total_posts, |
|
350 |
'posts' |
|
351 |
), |
|
352 |
number_format_i18n( $total_posts ) |
|
353 |
); |
|
354 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
$status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); |
18 | 356 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
if ( $mine ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
$status_links['mine'] = $mine; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
} |
0 | 360 |
|
9 | 361 |
foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) { |
0 | 362 |
$class = ''; |
363 |
||
364 |
$status_name = $status->name; |
|
365 |
||
16 | 366 |
if ( ! in_array( $status_name, $avail_post_stati, true ) || empty( $num_posts->$status_name ) ) { |
0 | 367 |
continue; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
} |
0 | 369 |
|
9 | 370 |
if ( isset( $_REQUEST['post_status'] ) && $status_name === $_REQUEST['post_status'] ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
371 |
$class = 'current'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
} |
0 | 373 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
$status_args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
'post_status' => $status_name, |
9 | 376 |
'post_type' => $post_type, |
7
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 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
$status_label = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
translate_nooped_plural( $status->label_count, $num_posts->$status_name ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
number_format_i18n( $num_posts->$status_name ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
$status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class ); |
0 | 385 |
} |
386 |
||
387 |
if ( ! empty( $this->sticky_posts_count ) ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
$class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
$sticky_args = array( |
9 | 391 |
'post_type' => $post_type, |
392 |
'show_sticky' => 1, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
); |
0 | 394 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
$sticky_inner_html = sprintf( |
16 | 396 |
/* translators: %s: Number of posts. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
_nx( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
'Sticky <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
'Sticky <span class="count">(%s)</span>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
$this->sticky_posts_count, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
'posts' |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
number_format_i18n( $this->sticky_posts_count ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
$sticky_link = array( |
9 | 407 |
'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
); |
0 | 409 |
|
410 |
// Sticky comes after Publish, or if not listed, after All. |
|
16 | 411 |
$split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ), true ); |
0 | 412 |
$status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
413 |
} |
|
414 |
||
415 |
return $status_links; |
|
416 |
} |
|
417 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
*/ |
5 | 421 |
protected function get_bulk_actions() { |
9 | 422 |
$actions = array(); |
5 | 423 |
$post_type_obj = get_post_type_object( $this->screen->post_type ); |
0 | 424 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
if ( $this->is_trash ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
$actions['untrash'] = __( 'Restore' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
$actions['edit'] = __( 'Edit' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
} |
5 | 431 |
} |
0 | 432 |
|
5 | 433 |
if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
434 |
if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
|
16 | 435 |
$actions['delete'] = __( 'Delete permanently' ); |
5 | 436 |
} else { |
437 |
$actions['trash'] = __( 'Move to Trash' ); |
|
438 |
} |
|
439 |
} |
|
0 | 440 |
|
441 |
return $actions; |
|
442 |
} |
|
443 |
||
5 | 444 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
445 |
* Displays a categories drop-down for filtering on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
* @global int $cat Currently selected category. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
450 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
* @param string $post_type Post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
protected function categories_dropdown( $post_type ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
454 |
global $cat; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
455 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
* Filters whether to remove the 'Categories' drop-down from the post list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
* @since 4.6.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
* @param bool $disable Whether to disable the categories drop-down. Default false. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
* @param string $post_type Post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
463 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
if ( is_object_in_taxonomy( $post_type, 'category' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
$dropdown_options = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
470 |
'show_option_all' => get_taxonomy( 'category' )->labels->all_items, |
9 | 471 |
'hide_empty' => 0, |
472 |
'hierarchical' => 1, |
|
473 |
'show_count' => 0, |
|
474 |
'orderby' => 'name', |
|
475 |
'selected' => $cat, |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
476 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
477 |
|
18 | 478 |
echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>'; |
479 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
480 |
wp_dropdown_categories( $dropdown_options ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
/** |
9 | 485 |
* Displays a formats drop-down for filtering items. |
486 |
* |
|
487 |
* @since 5.2.0 |
|
488 |
* @access protected |
|
489 |
* |
|
16 | 490 |
* @param string $post_type Post type slug. |
9 | 491 |
*/ |
492 |
protected function formats_dropdown( $post_type ) { |
|
493 |
/** |
|
494 |
* Filters whether to remove the 'Formats' drop-down from the post list table. |
|
495 |
* |
|
496 |
* @since 5.2.0 |
|
16 | 497 |
* @since 5.5.0 The `$post_type` parameter was added. |
9 | 498 |
* |
16 | 499 |
* @param bool $disable Whether to disable the drop-down. Default false. |
500 |
* @param string $post_type Post type slug. |
|
9 | 501 |
*/ |
16 | 502 |
if ( apply_filters( 'disable_formats_dropdown', false, $post_type ) ) { |
503 |
return; |
|
504 |
} |
|
505 |
||
506 |
// Return if the post type doesn't have post formats or if we're in the Trash. |
|
507 |
if ( ! is_object_in_taxonomy( $post_type, 'post_format' ) || $this->is_trash ) { |
|
9 | 508 |
return; |
509 |
} |
|
510 |
||
511 |
// Make sure the dropdown shows only formats with a post count greater than 0. |
|
512 |
$used_post_formats = get_terms( |
|
513 |
array( |
|
514 |
'taxonomy' => 'post_format', |
|
515 |
'hide_empty' => true, |
|
516 |
) |
|
517 |
); |
|
518 |
||
16 | 519 |
// Return if there are no posts using formats. |
520 |
if ( ! $used_post_formats ) { |
|
9 | 521 |
return; |
522 |
} |
|
523 |
||
524 |
$displayed_post_format = isset( $_GET['post_format'] ) ? $_GET['post_format'] : ''; |
|
525 |
?> |
|
526 |
<label for="filter-by-format" class="screen-reader-text"><?php _e( 'Filter by post format' ); ?></label> |
|
527 |
<select name="post_format" id="filter-by-format"> |
|
528 |
<option<?php selected( $displayed_post_format, '' ); ?> value=""><?php _e( 'All formats' ); ?></option> |
|
529 |
<?php |
|
530 |
foreach ( $used_post_formats as $used_post_format ) { |
|
531 |
// Post format slug. |
|
532 |
$slug = str_replace( 'post-format-', '', $used_post_format->slug ); |
|
533 |
// Pretty, translated version of the post format slug. |
|
534 |
$pretty_name = get_post_format_string( $slug ); |
|
18 | 535 |
|
9 | 536 |
// Skip the standard post format. |
537 |
if ( 'standard' === $slug ) { |
|
538 |
continue; |
|
539 |
} |
|
540 |
?> |
|
541 |
<option<?php selected( $displayed_post_format, $slug ); ?> value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $pretty_name ); ?></option> |
|
542 |
<?php |
|
543 |
} |
|
544 |
?> |
|
545 |
</select> |
|
546 |
<?php |
|
547 |
} |
|
548 |
||
549 |
/** |
|
5 | 550 |
* @param string $which |
551 |
*/ |
|
552 |
protected function extra_tablenav( $which ) { |
|
9 | 553 |
?> |
0 | 554 |
<div class="alignleft actions"> |
9 | 555 |
<?php |
16 | 556 |
if ( 'top' === $which ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
557 |
ob_start(); |
0 | 558 |
|
559 |
$this->months_dropdown( $this->screen->post_type ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
560 |
$this->categories_dropdown( $this->screen->post_type ); |
9 | 561 |
$this->formats_dropdown( $this->screen->post_type ); |
5 | 562 |
|
563 |
/** |
|
564 |
* Fires before the Filter button on the Posts and Pages list tables. |
|
565 |
* |
|
566 |
* The Filter button allows sorting by date and/or category on the |
|
567 |
* Posts list table, and sorting by date on the Pages list table. |
|
568 |
* |
|
569 |
* @since 2.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
570 |
* @since 4.4.0 The `$post_type` parameter was added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
571 |
* @since 4.6.0 The `$which` parameter was added. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
572 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
573 |
* @param string $post_type The post type slug. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
574 |
* @param string $which The location of the extra table nav markup: |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
575 |
* 'top' or 'bottom' for WP_Posts_List_Table, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
* 'bar' for WP_Media_List_Table. |
5 | 577 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
578 |
do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
579 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
580 |
$output = ob_get_clean(); |
5 | 581 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
582 |
if ( ! empty( $output ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
echo $output; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
584 |
submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
585 |
} |
0 | 586 |
} |
587 |
||
18 | 588 |
if ( $this->is_trash && $this->has_items() |
589 |
&& current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) |
|
590 |
) { |
|
0 | 591 |
submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
592 |
} |
|
9 | 593 |
?> |
0 | 594 |
</div> |
9 | 595 |
<?php |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
596 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
597 |
* Fires immediately following the closing "actions" div in the tablenav for the posts |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
598 |
* list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
599 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
600 |
* @since 4.4.0 |
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 |
* @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
603 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
604 |
do_action( 'manage_posts_extra_tablenav', $which ); |
0 | 605 |
} |
606 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
607 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
608 |
* @return string |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
609 |
*/ |
5 | 610 |
public function current_action() { |
9 | 611 |
if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) { |
0 | 612 |
return 'delete_all'; |
9 | 613 |
} |
0 | 614 |
|
615 |
return parent::current_action(); |
|
616 |
} |
|
617 |
||
5 | 618 |
/** |
16 | 619 |
* @global string $mode List table view mode. |
620 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
621 |
* @return array |
5 | 622 |
*/ |
623 |
protected function get_table_classes() { |
|
16 | 624 |
global $mode; |
625 |
||
626 |
$mode_class = esc_attr( 'table-view-' . $mode ); |
|
627 |
||
18 | 628 |
return array( |
629 |
'widefat', |
|
630 |
'fixed', |
|
631 |
'striped', |
|
632 |
$mode_class, |
|
633 |
is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts', |
|
634 |
); |
|
0 | 635 |
} |
636 |
||
7
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 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
639 |
*/ |
5 | 640 |
public function get_columns() { |
0 | 641 |
$post_type = $this->screen->post_type; |
642 |
||
643 |
$posts_columns = array(); |
|
644 |
||
645 |
$posts_columns['cb'] = '<input type="checkbox" />'; |
|
646 |
||
16 | 647 |
/* translators: Posts screen column name. */ |
0 | 648 |
$posts_columns['title'] = _x( 'Title', 'column name' ); |
649 |
||
5 | 650 |
if ( post_type_supports( $post_type, 'author' ) ) { |
0 | 651 |
$posts_columns['author'] = __( 'Author' ); |
5 | 652 |
} |
0 | 653 |
|
654 |
$taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
|
655 |
$taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
|
656 |
||
5 | 657 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
* Filters the taxonomy columns in the Posts list table. |
5 | 659 |
* |
660 |
* The dynamic portion of the hook name, `$post_type`, refers to the post |
|
661 |
* type slug. |
|
662 |
* |
|
18 | 663 |
* Possible hook names include: |
664 |
* |
|
665 |
* - `manage_taxonomies_for_post_columns` |
|
666 |
* - `manage_taxonomies_for_page_columns` |
|
667 |
* |
|
5 | 668 |
* @since 3.5.0 |
669 |
* |
|
9 | 670 |
* @param string[] $taxonomies Array of taxonomy names to show columns for. |
671 |
* @param string $post_type The post type. |
|
5 | 672 |
*/ |
0 | 673 |
$taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
674 |
$taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
|
675 |
||
676 |
foreach ( $taxonomies as $taxonomy ) { |
|
9 | 677 |
if ( 'category' === $taxonomy ) { |
0 | 678 |
$column_key = 'categories'; |
9 | 679 |
} elseif ( 'post_tag' === $taxonomy ) { |
0 | 680 |
$column_key = 'tags'; |
9 | 681 |
} else { |
0 | 682 |
$column_key = 'taxonomy-' . $taxonomy; |
9 | 683 |
} |
0 | 684 |
|
685 |
$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
|
686 |
} |
|
687 |
||
9 | 688 |
$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; |
18 | 689 |
|
690 |
if ( post_type_supports( $post_type, 'comments' ) |
|
691 |
&& ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) |
|
692 |
) { |
|
693 |
$posts_columns['comments'] = sprintf( |
|
694 |
'<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%2$s</span></span>', |
|
695 |
esc_attr__( 'Comments' ), |
|
696 |
__( 'Comments' ) |
|
697 |
); |
|
9 | 698 |
} |
0 | 699 |
|
700 |
$posts_columns['date'] = __( 'Date' ); |
|
701 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
if ( 'page' === $post_type ) { |
5 | 703 |
|
704 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
705 |
* Filters the columns displayed in the Pages list table. |
5 | 706 |
* |
707 |
* @since 2.5.0 |
|
708 |
* |
|
9 | 709 |
* @param string[] $post_columns An associative array of column headings. |
5 | 710 |
*/ |
0 | 711 |
$posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
5 | 712 |
} else { |
713 |
||
714 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
715 |
* Filters the columns displayed in the Posts list table. |
5 | 716 |
* |
717 |
* @since 1.5.0 |
|
718 |
* |
|
9 | 719 |
* @param string[] $post_columns An associative array of column headings. |
720 |
* @param string $post_type The post type slug. |
|
5 | 721 |
*/ |
0 | 722 |
$posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
5 | 723 |
} |
724 |
||
725 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
726 |
* Filters the columns displayed in the Posts list table for a specific post type. |
5 | 727 |
* |
728 |
* The dynamic portion of the hook name, `$post_type`, refers to the post type slug. |
|
729 |
* |
|
18 | 730 |
* Possible hook names include: |
731 |
* |
|
732 |
* - `manage_post_posts_columns` |
|
733 |
* - `manage_page_posts_columns` |
|
734 |
* |
|
5 | 735 |
* @since 3.0.0 |
736 |
* |
|
9 | 737 |
* @param string[] $post_columns An associative array of column headings. |
5 | 738 |
*/ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
739 |
return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
0 | 740 |
} |
741 |
||
7
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 |
* @return array |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
744 |
*/ |
5 | 745 |
protected function get_sortable_columns() { |
0 | 746 |
return array( |
747 |
'title' => 'title', |
|
748 |
'parent' => 'parent', |
|
749 |
'comments' => 'comment_count', |
|
9 | 750 |
'date' => array( 'date', true ), |
0 | 751 |
); |
752 |
} |
|
753 |
||
5 | 754 |
/** |
16 | 755 |
* @global WP_Query $wp_query WordPress Query object. |
5 | 756 |
* @global int $per_page |
757 |
* @param array $posts |
|
16 | 758 |
* @param int $level |
5 | 759 |
*/ |
760 |
public function display_rows( $posts = array(), $level = 0 ) { |
|
0 | 761 |
global $wp_query, $per_page; |
762 |
||
9 | 763 |
if ( empty( $posts ) ) { |
0 | 764 |
$posts = $wp_query->posts; |
9 | 765 |
} |
0 | 766 |
|
767 |
add_filter( 'the_title', 'esc_html' ); |
|
768 |
||
769 |
if ( $this->hierarchical_display ) { |
|
770 |
$this->_display_rows_hierarchical( $posts, $this->get_pagenum(), $per_page ); |
|
771 |
} else { |
|
772 |
$this->_display_rows( $posts, $level ); |
|
773 |
} |
|
774 |
} |
|
775 |
||
5 | 776 |
/** |
777 |
* @param array $posts |
|
16 | 778 |
* @param int $level |
5 | 779 |
*/ |
780 |
private function _display_rows( $posts, $level = 0 ) { |
|
9 | 781 |
$post_type = $this->screen->post_type; |
782 |
||
0 | 783 |
// Create array of post IDs. |
784 |
$post_ids = array(); |
|
785 |
||
9 | 786 |
foreach ( $posts as $a_post ) { |
0 | 787 |
$post_ids[] = $a_post->ID; |
9 | 788 |
} |
0 | 789 |
|
9 | 790 |
if ( post_type_supports( $post_type, 'comments' ) ) { |
791 |
$this->comment_pending_count = get_pending_comments_num( $post_ids ); |
|
792 |
} |
|
0 | 793 |
|
9 | 794 |
foreach ( $posts as $post ) { |
0 | 795 |
$this->single_row( $post, $level ); |
9 | 796 |
} |
0 | 797 |
} |
798 |
||
5 | 799 |
/** |
16 | 800 |
* @global wpdb $wpdb WordPress database abstraction object. |
801 |
* @global WP_Post $post Global post object. |
|
5 | 802 |
* @param array $pages |
16 | 803 |
* @param int $pagenum |
804 |
* @param int $per_page |
|
5 | 805 |
*/ |
806 |
private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
|
0 | 807 |
global $wpdb; |
808 |
||
809 |
$level = 0; |
|
810 |
||
811 |
if ( ! $pages ) { |
|
812 |
$pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
|
813 |
||
9 | 814 |
if ( ! $pages ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
815 |
return; |
9 | 816 |
} |
0 | 817 |
} |
818 |
||
819 |
/* |
|
19 | 820 |
* Arrange pages into two parts: top level pages and children_pages. |
821 |
* children_pages is two dimensional array. Example: |
|
0 | 822 |
* children_pages[10][] contains all sub-pages whose parent is 10. |
823 |
* It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations |
|
824 |
* If searching, ignore hierarchy and treat everything as top level |
|
825 |
*/ |
|
826 |
if ( empty( $_REQUEST['s'] ) ) { |
|
827 |
$top_level_pages = array(); |
|
9 | 828 |
$children_pages = array(); |
0 | 829 |
|
830 |
foreach ( $pages as $page ) { |
|
5 | 831 |
// Catch and repair bad pages. |
18 | 832 |
if ( $page->post_parent === $page->ID ) { |
0 | 833 |
$page->post_parent = 0; |
834 |
$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) ); |
|
835 |
clean_post_cache( $page ); |
|
836 |
} |
|
837 |
||
18 | 838 |
if ( $page->post_parent > 0 ) { |
839 |
$children_pages[ $page->post_parent ][] = $page; |
|
840 |
} else { |
|
0 | 841 |
$top_level_pages[] = $page; |
9 | 842 |
} |
0 | 843 |
} |
844 |
||
845 |
$pages = &$top_level_pages; |
|
846 |
} |
|
847 |
||
9 | 848 |
$count = 0; |
849 |
$start = ( $pagenum - 1 ) * $per_page; |
|
850 |
$end = $start + $per_page; |
|
5 | 851 |
$to_display = array(); |
0 | 852 |
|
853 |
foreach ( $pages as $page ) { |
|
9 | 854 |
if ( $count >= $end ) { |
0 | 855 |
break; |
9 | 856 |
} |
0 | 857 |
|
858 |
if ( $count >= $start ) { |
|
9 | 859 |
$to_display[ $page->ID ] = $level; |
0 | 860 |
} |
861 |
||
862 |
$count++; |
|
863 |
||
9 | 864 |
if ( isset( $children_pages ) ) { |
5 | 865 |
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
9 | 866 |
} |
0 | 867 |
} |
868 |
||
5 | 869 |
// If it is the last pagenum and there are orphaned pages, display them with paging as well. |
9 | 870 |
if ( isset( $children_pages ) && $count < $end ) { |
871 |
foreach ( $children_pages as $orphans ) { |
|
0 | 872 |
foreach ( $orphans as $op ) { |
9 | 873 |
if ( $count >= $end ) { |
0 | 874 |
break; |
9 | 875 |
} |
0 | 876 |
|
877 |
if ( $count >= $start ) { |
|
9 | 878 |
$to_display[ $op->ID ] = 0; |
0 | 879 |
} |
880 |
||
881 |
$count++; |
|
882 |
} |
|
883 |
} |
|
884 |
} |
|
5 | 885 |
|
886 |
$ids = array_keys( $to_display ); |
|
887 |
_prime_post_caches( $ids ); |
|
888 |
||
889 |
if ( ! isset( $GLOBALS['post'] ) ) { |
|
890 |
$GLOBALS['post'] = reset( $ids ); |
|
891 |
} |
|
892 |
||
893 |
foreach ( $to_display as $page_id => $level ) { |
|
894 |
echo "\t"; |
|
895 |
$this->single_row( $page_id, $level ); |
|
896 |
} |
|
0 | 897 |
} |
898 |
||
899 |
/** |
|
900 |
* Given a top level page ID, display the nested hierarchy of sub-pages |
|
901 |
* together with paging support |
|
902 |
* |
|
903 |
* @since 3.1.0 (Standalone function exists since 2.6.0) |
|
5 | 904 |
* @since 4.2.0 Added the `$to_display` parameter. |
0 | 905 |
* |
906 |
* @param array $children_pages |
|
16 | 907 |
* @param int $count |
19 | 908 |
* @param int $parent_page |
16 | 909 |
* @param int $level |
910 |
* @param int $pagenum |
|
911 |
* @param int $per_page |
|
5 | 912 |
* @param array $to_display List of pages to be displayed. Passed by reference. |
0 | 913 |
*/ |
19 | 914 |
private function _page_rows( &$children_pages, &$count, $parent_page, $level, $pagenum, $per_page, &$to_display ) { |
915 |
if ( ! isset( $children_pages[ $parent_page ] ) ) { |
|
0 | 916 |
return; |
9 | 917 |
} |
0 | 918 |
|
919 |
$start = ( $pagenum - 1 ) * $per_page; |
|
9 | 920 |
$end = $start + $per_page; |
0 | 921 |
|
19 | 922 |
foreach ( $children_pages[ $parent_page ] as $page ) { |
9 | 923 |
if ( $count >= $end ) { |
0 | 924 |
break; |
9 | 925 |
} |
0 | 926 |
|
927 |
// If the page starts in a subtree, print the parents. |
|
18 | 928 |
if ( $count === $start && $page->post_parent > 0 ) { |
0 | 929 |
$my_parents = array(); |
9 | 930 |
$my_parent = $page->post_parent; |
18 | 931 |
|
0 | 932 |
while ( $my_parent ) { |
16 | 933 |
// Get the ID from the list or the attribute if my_parent is an object. |
5 | 934 |
$parent_id = $my_parent; |
18 | 935 |
|
5 | 936 |
if ( is_object( $my_parent ) ) { |
937 |
$parent_id = $my_parent->ID; |
|
938 |
} |
|
939 |
||
9 | 940 |
$my_parent = get_post( $parent_id ); |
0 | 941 |
$my_parents[] = $my_parent; |
18 | 942 |
|
9 | 943 |
if ( ! $my_parent->post_parent ) { |
0 | 944 |
break; |
9 | 945 |
} |
18 | 946 |
|
0 | 947 |
$my_parent = $my_parent->post_parent; |
948 |
} |
|
18 | 949 |
|
0 | 950 |
$num_parents = count( $my_parents ); |
18 | 951 |
|
0 | 952 |
while ( $my_parent = array_pop( $my_parents ) ) { |
9 | 953 |
$to_display[ $my_parent->ID ] = $level - $num_parents; |
0 | 954 |
$num_parents--; |
955 |
} |
|
956 |
} |
|
957 |
||
958 |
if ( $count >= $start ) { |
|
9 | 959 |
$to_display[ $page->ID ] = $level; |
0 | 960 |
} |
961 |
||
962 |
$count++; |
|
963 |
||
5 | 964 |
$this->_page_rows( $children_pages, $count, $page->ID, $level + 1, $pagenum, $per_page, $to_display ); |
0 | 965 |
} |
966 |
||
19 | 967 |
unset( $children_pages[ $parent_page ] ); // Required in order to keep track of orphans. |
0 | 968 |
} |
969 |
||
5 | 970 |
/** |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
971 |
* Handles the checkbox column output. |
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 |
* @since 4.3.0 |
19 | 974 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
975 |
* |
19 | 976 |
* @param WP_Post $item The current WP_Post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
977 |
*/ |
19 | 978 |
public function column_cb( $item ) { |
979 |
// Restores the more descriptive, specific name for use within this method. |
|
980 |
$post = $item; |
|
18 | 981 |
$show = current_user_can( 'edit_post', $post->ID ); |
982 |
||
983 |
/** |
|
984 |
* Filters whether to show the bulk edit checkbox for a post in its list table. |
|
985 |
* |
|
986 |
* By default the checkbox is only shown if the current user can edit the post. |
|
987 |
* |
|
988 |
* @since 5.7.0 |
|
989 |
* |
|
990 |
* @param bool $show Whether to show the checkbox. |
|
991 |
* @param WP_Post $post The current WP_Post object. |
|
992 |
*/ |
|
993 |
if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) : |
|
9 | 994 |
?> |
995 |
<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"> |
|
16 | 996 |
<?php |
997 |
/* translators: %s: Post title. */ |
|
998 |
printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
999 |
?> |
|
9 | 1000 |
</label> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1001 |
<input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1002 |
<div class="locked-indicator"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1003 |
<span class="locked-indicator-icon" aria-hidden="true"></span> |
9 | 1004 |
<span class="screen-reader-text"> |
1005 |
<?php |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1006 |
printf( |
16 | 1007 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1008 |
__( '“%s” is locked' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1009 |
_draft_or_post_title() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1010 |
); |
9 | 1011 |
?> |
1012 |
</span> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1013 |
</div> |
9 | 1014 |
<?php |
1015 |
endif; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1016 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1017 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1018 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1019 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1020 |
* |
5 | 1021 |
* @param WP_Post $post |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1022 |
* @param string $classes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1023 |
* @param string $data |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1024 |
* @param string $primary |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1025 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1026 |
protected function _column_title( $post, $classes, $data, $primary ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1027 |
echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1028 |
echo $this->column_title( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1029 |
echo $this->handle_row_actions( $post, 'title', $primary ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1030 |
echo '</td>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1031 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1032 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1033 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1034 |
* Handles the title column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1035 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1036 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1037 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1038 |
* @global string $mode List table view mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1039 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1040 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1041 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1042 |
public function column_title( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1043 |
global $mode; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1044 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1045 |
if ( $this->hierarchical_display ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1046 |
if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1047 |
// Sent level 0 by accident, by default, or because we don't know the actual level. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1048 |
$find_main_page = (int) $post->post_parent; |
18 | 1049 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1050 |
while ( $find_main_page > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1051 |
$parent = get_post( $find_main_page ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1052 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1053 |
if ( is_null( $parent ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1054 |
break; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1055 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1056 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1057 |
$this->current_level++; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1058 |
$find_main_page = (int) $parent->post_parent; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1059 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1060 |
if ( ! isset( $parent_name ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1061 |
/** This filter is documented in wp-includes/post-template.php */ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1062 |
$parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1063 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1064 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1065 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1066 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1067 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1068 |
$can_edit_post = current_user_can( 'edit_post', $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1069 |
|
16 | 1070 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1071 |
$lock_holder = wp_check_post_lock( $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1072 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1073 |
if ( $lock_holder ) { |
9 | 1074 |
$lock_holder = get_userdata( $lock_holder ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1075 |
$locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
16 | 1076 |
/* translators: %s: User's display name. */ |
1077 |
$locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1078 |
} else { |
16 | 1079 |
$locked_avatar = ''; |
1080 |
$locked_text = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1081 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1082 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1083 |
echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1084 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1085 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1086 |
$pad = str_repeat( '— ', $this->current_level ); |
9 | 1087 |
echo '<strong>'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1088 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1089 |
$title = _draft_or_post_title(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1090 |
|
16 | 1091 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1092 |
printf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1093 |
'<a class="row-title" href="%s" aria-label="%s">%s%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1094 |
get_edit_post_link( $post->ID ), |
16 | 1095 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1096 |
esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1097 |
$pad, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1098 |
$title |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1099 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1100 |
} else { |
9 | 1101 |
printf( |
1102 |
'<span>%s%s</span>', |
|
1103 |
$pad, |
|
1104 |
$title |
|
1105 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1106 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1107 |
_post_states( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1108 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1109 |
if ( isset( $parent_name ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1110 |
$post_type_object = get_post_type_object( $post->post_type ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1111 |
echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1112 |
} |
18 | 1113 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1114 |
echo "</strong>\n"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1115 |
|
16 | 1116 |
if ( 'excerpt' === $mode |
1117 |
&& ! is_post_type_hierarchical( $this->screen->post_type ) |
|
1118 |
&& current_user_can( 'read_post', $post->ID ) |
|
1119 |
) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1120 |
if ( post_password_required( $post ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1121 |
echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1122 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1123 |
echo esc_html( get_the_excerpt() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1124 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1125 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1126 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1127 |
get_inline_data( $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1128 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1129 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1130 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1131 |
* Handles the post date column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1132 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1133 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1134 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1135 |
* @global string $mode List table view mode. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1136 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1137 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1138 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1139 |
public function column_date( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1140 |
global $mode; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1141 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1142 |
if ( '0000-00-00 00:00:00' === $post->post_date ) { |
16 | 1143 |
$t_time = __( 'Unpublished' ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1144 |
$time_diff = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1145 |
} else { |
16 | 1146 |
$t_time = sprintf( |
1147 |
/* translators: 1: Post date, 2: Post time. */ |
|
1148 |
__( '%1$s at %2$s' ), |
|
18 | 1149 |
/* translators: Post date format. See https://www.php.net/manual/datetime.format.php */ |
16 | 1150 |
get_the_time( __( 'Y/m/d' ), $post ), |
18 | 1151 |
/* translators: Post time format. See https://www.php.net/manual/datetime.format.php */ |
16 | 1152 |
get_the_time( __( 'g:i a' ), $post ) |
1153 |
); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1154 |
|
16 | 1155 |
$time = get_post_timestamp( $post ); |
1156 |
$time_diff = time() - $time; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1157 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1158 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1159 |
if ( 'publish' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1160 |
$status = __( 'Published' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1161 |
} elseif ( 'future' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1162 |
if ( $time_diff > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1163 |
$status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1164 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1165 |
$status = __( 'Scheduled' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1166 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1167 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1168 |
$status = __( 'Last Modified' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1169 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1170 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1171 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1172 |
* Filters the status text of the post. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1173 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1174 |
* @since 4.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1175 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1176 |
* @param string $status The status text. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1177 |
* @param WP_Post $post Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1178 |
* @param string $column_name The column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1179 |
* @param string $mode The list display mode ('excerpt' or 'list'). |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1180 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1181 |
$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1182 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1183 |
if ( $status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1184 |
echo $status . '<br />'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1185 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1186 |
|
16 | 1187 |
/** |
1188 |
* Filters the published time of the post. |
|
1189 |
* |
|
1190 |
* @since 2.5.1 |
|
1191 |
* @since 5.5.0 Removed the difference between 'excerpt' and 'list' modes. |
|
1192 |
* The published time and date are both displayed now, |
|
1193 |
* which is equivalent to the previous 'excerpt' mode. |
|
1194 |
* |
|
1195 |
* @param string $t_time The published time. |
|
1196 |
* @param WP_Post $post Post object. |
|
1197 |
* @param string $column_name The column name. |
|
1198 |
* @param string $mode The list display mode ('excerpt' or 'list'). |
|
1199 |
*/ |
|
1200 |
echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1201 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1202 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1203 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1204 |
* Handles the comments column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1205 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1206 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1207 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1208 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1209 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1210 |
public function column_comments( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1211 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1212 |
<div class="post-com-count-wrapper"> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1213 |
<?php |
9 | 1214 |
$pending_comments = isset( $this->comment_pending_count[ $post->ID ] ) ? $this->comment_pending_count[ $post->ID ] : 0; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1215 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1216 |
$this->comments_bubble( $post->ID, $pending_comments ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1217 |
?> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1218 |
</div> |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1219 |
<?php |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1220 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1221 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1222 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1223 |
* Handles the post author column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1224 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1225 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1226 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1227 |
* @param WP_Post $post The current WP_Post object. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1228 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1229 |
public function column_author( $post ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1230 |
$args = array( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1231 |
'post_type' => $post->post_type, |
9 | 1232 |
'author' => get_the_author_meta( 'ID' ), |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1233 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1234 |
echo $this->get_edit_link( $args, get_the_author() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1235 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1236 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1237 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1238 |
* Handles the default column output. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1239 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1240 |
* @since 4.3.0 |
19 | 1241 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1242 |
* |
19 | 1243 |
* @param WP_Post $item The current WP_Post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1244 |
* @param string $column_name The current column name. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1245 |
*/ |
19 | 1246 |
public function column_default( $item, $column_name ) { |
1247 |
// Restores the more descriptive, specific name for use within this method. |
|
1248 |
$post = $item; |
|
1249 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1250 |
if ( 'categories' === $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1251 |
$taxonomy = 'category'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1252 |
} elseif ( 'tags' === $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1253 |
$taxonomy = 'post_tag'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1254 |
} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1255 |
$taxonomy = substr( $column_name, 9 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1256 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1257 |
$taxonomy = false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1258 |
} |
18 | 1259 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1260 |
if ( $taxonomy ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1261 |
$taxonomy_object = get_taxonomy( $taxonomy ); |
9 | 1262 |
$terms = get_the_terms( $post->ID, $taxonomy ); |
18 | 1263 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1264 |
if ( is_array( $terms ) ) { |
9 | 1265 |
$term_links = array(); |
18 | 1266 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1267 |
foreach ( $terms as $t ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1268 |
$posts_in_term_qv = array(); |
18 | 1269 |
|
16 | 1270 |
if ( 'post' !== $post->post_type ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1271 |
$posts_in_term_qv['post_type'] = $post->post_type; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1272 |
} |
18 | 1273 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1274 |
if ( $taxonomy_object->query_var ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1275 |
$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1276 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1277 |
$posts_in_term_qv['taxonomy'] = $taxonomy; |
9 | 1278 |
$posts_in_term_qv['term'] = $t->slug; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1279 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1280 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1281 |
$label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); |
9 | 1282 |
|
1283 |
$term_links[] = $this->get_edit_link( $posts_in_term_qv, $label ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1284 |
} |
9 | 1285 |
|
1286 |
/** |
|
1287 |
* Filters the links in `$taxonomy` column of edit.php. |
|
1288 |
* |
|
1289 |
* @since 5.2.0 |
|
1290 |
* |
|
16 | 1291 |
* @param string[] $term_links Array of term editing links. |
1292 |
* @param string $taxonomy Taxonomy name. |
|
1293 |
* @param WP_Term[] $terms Array of term objects appearing in the post row. |
|
9 | 1294 |
*/ |
1295 |
$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms ); |
|
1296 |
||
19 | 1297 |
echo implode( wp_get_list_item_separator(), $term_links ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1298 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1299 |
echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1300 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1301 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1302 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1303 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1304 |
if ( is_post_type_hierarchical( $post->post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1305 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1306 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1307 |
* Fires in each custom column on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1308 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1309 |
* This hook only fires if the current post type is hierarchical, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1310 |
* such as pages. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1311 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1312 |
* @since 2.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1313 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1314 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1315 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1316 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1317 |
do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1318 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1319 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1320 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1321 |
* Fires in each custom column in the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1322 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1323 |
* This hook only fires if the current post type is non-hierarchical, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1324 |
* such as posts. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1325 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1326 |
* @since 1.5.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1327 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1328 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1329 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1330 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1331 |
do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1332 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1333 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1334 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1335 |
* Fires for each custom column of a specific post type in the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1336 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1337 |
* The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1338 |
* |
18 | 1339 |
* Possible hook names include: |
1340 |
* |
|
1341 |
* - `manage_post_posts_custom_column` |
|
1342 |
* - `manage_page_posts_custom_column` |
|
1343 |
* |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1344 |
* @since 3.1.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1345 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1346 |
* @param string $column_name The name of the column to display. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1347 |
* @param int $post_id The current post ID. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1348 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1349 |
do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1350 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1351 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1352 |
/** |
16 | 1353 |
* @global WP_Post $post Global post object. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1354 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1355 |
* @param int|WP_Post $post |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1356 |
* @param int $level |
5 | 1357 |
*/ |
1358 |
public function single_row( $post, $level = 0 ) { |
|
0 | 1359 |
$global_post = get_post(); |
5 | 1360 |
|
9 | 1361 |
$post = get_post( $post ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1362 |
$this->current_level = $level; |
5 | 1363 |
|
0 | 1364 |
$GLOBALS['post'] = $post; |
1365 |
setup_postdata( $post ); |
|
1366 |
||
18 | 1367 |
$classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' ); |
0 | 1368 |
|
1369 |
$lock_holder = wp_check_post_lock( $post->ID ); |
|
18 | 1370 |
|
0 | 1371 |
if ( $lock_holder ) { |
1372 |
$classes .= ' wp-locked'; |
|
1373 |
} |
|
5 | 1374 |
|
1375 |
if ( $post->post_parent ) { |
|
9 | 1376 |
$count = count( get_post_ancestors( $post->ID ) ); |
1377 |
$classes .= ' level-' . $count; |
|
5 | 1378 |
} else { |
9 | 1379 |
$classes .= ' level-0'; |
5 | 1380 |
} |
9 | 1381 |
?> |
5 | 1382 |
<tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1383 |
<?php $this->single_row_columns( $post ); ?> |
0 | 1384 |
</tr> |
9 | 1385 |
<?php |
0 | 1386 |
$GLOBALS['post'] = $global_post; |
1387 |
} |
|
1388 |
||
1389 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1390 |
* Gets the name of the default primary column. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1391 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1392 |
* @since 4.3.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1393 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1394 |
* @return string Name of the default primary column, in this case, 'title'. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1395 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1396 |
protected function get_default_primary_column_name() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1397 |
return 'title'; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1398 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1399 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1400 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1401 |
* Generates and displays row action links. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1402 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1403 |
* @since 4.3.0 |
19 | 1404 |
* @since 5.9.0 Renamed `$post` to `$item` to match parent class for PHP 8 named parameter support. |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1405 |
* |
19 | 1406 |
* @param WP_Post $item Post being acted upon. |
18 | 1407 |
* @param string $column_name Current column name. |
1408 |
* @param string $primary Primary column name. |
|
16 | 1409 |
* @return string Row actions output for posts, or an empty string |
1410 |
* if the current column is not the primary column. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1411 |
*/ |
19 | 1412 |
protected function handle_row_actions( $item, $column_name, $primary ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1413 |
if ( $primary !== $column_name ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1414 |
return ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1415 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1416 |
|
19 | 1417 |
// Restores the more descriptive, specific name for use within this method. |
1418 |
$post = $item; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1419 |
$post_type_object = get_post_type_object( $post->post_type ); |
9 | 1420 |
$can_edit_post = current_user_can( 'edit_post', $post->ID ); |
1421 |
$actions = array(); |
|
1422 |
$title = _draft_or_post_title(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1423 |
|
16 | 1424 |
if ( $can_edit_post && 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1425 |
$actions['edit'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1426 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1427 |
get_edit_post_link( $post->ID ), |
16 | 1428 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1429 |
esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1430 |
__( 'Edit' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1431 |
); |
9 | 1432 |
|
1433 |
if ( 'wp_block' !== $post->post_type ) { |
|
1434 |
$actions['inline hide-if-no-js'] = sprintf( |
|
1435 |
'<button type="button" class="button-link editinline" aria-label="%s" aria-expanded="false">%s</button>', |
|
16 | 1436 |
/* translators: %s: Post title. */ |
9 | 1437 |
esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), |
1438 |
__( 'Quick Edit' ) |
|
1439 |
); |
|
1440 |
} |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1441 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1442 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1443 |
if ( current_user_can( 'delete_post', $post->ID ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1444 |
if ( 'trash' === $post->post_status ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1445 |
$actions['untrash'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1446 |
'<a href="%s" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1447 |
wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), |
16 | 1448 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1449 |
esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1450 |
__( 'Restore' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1451 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1452 |
} elseif ( EMPTY_TRASH_DAYS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1453 |
$actions['trash'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1454 |
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1455 |
get_delete_post_link( $post->ID ), |
16 | 1456 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1457 |
esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1458 |
_x( 'Trash', 'verb' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1459 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1460 |
} |
18 | 1461 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1462 |
if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1463 |
$actions['delete'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1464 |
'<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1465 |
get_delete_post_link( $post->ID, '', true ), |
16 | 1466 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1467 |
esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1468 |
__( 'Delete Permanently' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1469 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1470 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1471 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1472 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1473 |
if ( is_post_type_viewable( $post_type_object ) ) { |
16 | 1474 |
if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ), true ) ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1475 |
if ( $can_edit_post ) { |
9 | 1476 |
$preview_link = get_preview_post_link( $post ); |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1477 |
$actions['view'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1478 |
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1479 |
esc_url( $preview_link ), |
16 | 1480 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1481 |
esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1482 |
__( 'Preview' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1483 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1484 |
} |
16 | 1485 |
} elseif ( 'trash' !== $post->post_status ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1486 |
$actions['view'] = sprintf( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1487 |
'<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1488 |
get_permalink( $post->ID ), |
16 | 1489 |
/* translators: %s: Post title. */ |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1490 |
esc_attr( sprintf( __( 'View “%s”' ), $title ) ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1491 |
__( 'View' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1492 |
); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1493 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1494 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1495 |
|
9 | 1496 |
if ( 'wp_block' === $post->post_type ) { |
1497 |
$actions['export'] = sprintf( |
|
1498 |
'<button type="button" class="wp-list-reusable-blocks__export button-link" data-id="%s" aria-label="%s">%s</button>', |
|
1499 |
$post->ID, |
|
16 | 1500 |
/* translators: %s: Post title. */ |
9 | 1501 |
esc_attr( sprintf( __( 'Export “%s” as JSON' ), $title ) ), |
1502 |
__( 'Export as JSON' ) |
|
1503 |
); |
|
1504 |
} |
|
1505 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1506 |
if ( is_post_type_hierarchical( $post->post_type ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1507 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1508 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1509 |
* Filters the array of row action links on the Pages list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1510 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1511 |
* The filter is evaluated only for hierarchical post types. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1512 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1513 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1514 |
* |
9 | 1515 |
* @param string[] $actions An array of row action links. Defaults are |
1516 |
* 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1517 |
* 'Delete Permanently', 'Preview', and 'View'. |
|
1518 |
* @param WP_Post $post The post object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1519 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1520 |
$actions = apply_filters( 'page_row_actions', $actions, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1521 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1522 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1523 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1524 |
* Filters the array of row action links on the Posts list table. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1525 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1526 |
* The filter is evaluated only for non-hierarchical post types. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1527 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1528 |
* @since 2.8.0 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1529 |
* |
9 | 1530 |
* @param string[] $actions An array of row action links. Defaults are |
1531 |
* 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1532 |
* 'Delete Permanently', 'Preview', and 'View'. |
|
1533 |
* @param WP_Post $post The post object. |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1534 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1535 |
$actions = apply_filters( 'post_row_actions', $actions, $post ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1536 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1537 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1538 |
return $this->row_actions( $actions ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1539 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1540 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1541 |
/** |
0 | 1542 |
* Outputs the hidden row displayed when inline editing |
1543 |
* |
|
1544 |
* @since 3.1.0 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1545 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1546 |
* @global string $mode List table view mode. |
0 | 1547 |
*/ |
5 | 1548 |
public function inline_edit() { |
0 | 1549 |
global $mode; |
1550 |
||
1551 |
$screen = $this->screen; |
|
1552 |
||
9 | 1553 |
$post = get_default_post_to_edit( $screen->post_type ); |
0 | 1554 |
$post_type_object = get_post_type_object( $screen->post_type ); |
1555 |
||
9 | 1556 |
$taxonomy_names = get_object_taxonomies( $screen->post_type ); |
0 | 1557 |
$hierarchical_taxonomies = array(); |
9 | 1558 |
$flat_taxonomies = array(); |
16 | 1559 |
|
0 | 1560 |
foreach ( $taxonomy_names as $taxonomy_name ) { |
1561 |
$taxonomy = get_taxonomy( $taxonomy_name ); |
|
1562 |
||
5 | 1563 |
$show_in_quick_edit = $taxonomy->show_in_quick_edit; |
1564 |
||
1565 |
/** |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1566 |
* Filters whether the current taxonomy should be shown in the Quick Edit panel. |
5 | 1567 |
* |
1568 |
* @since 4.2.0 |
|
1569 |
* |
|
1570 |
* @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. |
|
1571 |
* @param string $taxonomy_name Taxonomy name. |
|
1572 |
* @param string $post_type Post type of current Quick Edit post. |
|
1573 |
*/ |
|
1574 |
if ( ! apply_filters( 'quick_edit_show_taxonomy', $show_in_quick_edit, $taxonomy_name, $screen->post_type ) ) { |
|
0 | 1575 |
continue; |
5 | 1576 |
} |
0 | 1577 |
|
9 | 1578 |
if ( $taxonomy->hierarchical ) { |
0 | 1579 |
$hierarchical_taxonomies[] = $taxonomy; |
9 | 1580 |
} else { |
0 | 1581 |
$flat_taxonomies[] = $taxonomy; |
9 | 1582 |
} |
0 | 1583 |
} |
1584 |
||
9 | 1585 |
$m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
1586 |
$can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
|
1587 |
$core_columns = array( |
|
1588 |
'cb' => true, |
|
1589 |
'date' => true, |
|
1590 |
'title' => true, |
|
1591 |
'categories' => true, |
|
1592 |
'tags' => true, |
|
1593 |
'comments' => true, |
|
1594 |
'author' => true, |
|
1595 |
); |
|
1596 |
?> |
|
0 | 1597 |
|
16 | 1598 |
<form method="get"> |
1599 |
<table style="display: none"><tbody id="inlineedit"> |
|
0 | 1600 |
<?php |
9 | 1601 |
$hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1602 |
$inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1603 |
$bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1604 |
$quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1605 |
|
0 | 1606 |
$bulk = 0; |
18 | 1607 |
|
16 | 1608 |
while ( $bulk < 2 ) : |
1609 |
$classes = $inline_edit_classes . ' '; |
|
1610 |
$classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes; |
|
9 | 1611 |
?> |
16 | 1612 |
<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none"> |
1613 |
<td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
|
19 | 1614 |
<div class="inline-edit-wrapper" role="region" aria-labelledby="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"> |
16 | 1615 |
<fieldset class="inline-edit-col-left"> |
19 | 1616 |
<legend class="inline-edit-legend" id="<?php echo $bulk ? 'bulk' : 'quick'; ?>-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
16 | 1617 |
<div class="inline-edit-col"> |
1618 |
||
1619 |
<?php if ( post_type_supports( $screen->post_type, 'title' ) ) : ?> |
|
1620 |
||
1621 |
<?php if ( $bulk ) : ?> |
|
1622 |
||
1623 |
<div id="bulk-title-div"> |
|
1624 |
<div id="bulk-titles"></div> |
|
1625 |
</div> |
|
1626 |
||
1627 |
<?php else : // $bulk ?> |
|
1628 |
||
1629 |
<label> |
|
1630 |
<span class="title"><?php _e( 'Title' ); ?></span> |
|
1631 |
<span class="input-text-wrap"><input type="text" name="post_title" class="ptitle" value="" /></span> |
|
1632 |
</label> |
|
1633 |
||
1634 |
<?php if ( is_post_type_viewable( $screen->post_type ) ) : ?> |
|
1635 |
||
1636 |
<label> |
|
1637 |
<span class="title"><?php _e( 'Slug' ); ?></span> |
|
19 | 1638 |
<span class="input-text-wrap"><input type="text" name="post_name" value="" autocomplete="off" spellcheck="false" /></span> |
16 | 1639 |
</label> |
1640 |
||
1641 |
<?php endif; // is_post_type_viewable() ?> |
|
1642 |
||
1643 |
<?php endif; // $bulk ?> |
|
0 | 1644 |
|
16 | 1645 |
<?php endif; // post_type_supports( ... 'title' ) ?> |
1646 |
||
1647 |
<?php if ( ! $bulk ) : ?> |
|
1648 |
<fieldset class="inline-edit-date"> |
|
1649 |
<legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
|
1650 |
<?php touch_time( 1, 1, 0, 1 ); ?> |
|
1651 |
</fieldset> |
|
1652 |
<br class="clear" /> |
|
1653 |
<?php endif; // $bulk ?> |
|
1654 |
||
1655 |
<?php |
|
18 | 1656 |
if ( post_type_supports( $screen->post_type, 'author' ) ) { |
16 | 1657 |
$authors_dropdown = ''; |
0 | 1658 |
|
18 | 1659 |
if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
19 | 1660 |
$dropdown_name = 'post_author'; |
1661 |
$dropdown_class = 'authors'; |
|
1662 |
if ( wp_is_large_user_count() ) { |
|
1663 |
$authors_dropdown = sprintf( '<select name="%s" class="%s hidden"></select>', esc_attr( $dropdown_name ), esc_attr( $dropdown_class ) ); |
|
1664 |
} else { |
|
1665 |
$users_opt = array( |
|
1666 |
'hide_if_only_one_author' => false, |
|
1667 |
'capability' => array( $post_type_object->cap->edit_posts ), |
|
1668 |
'name' => $dropdown_name, |
|
1669 |
'class' => $dropdown_class, |
|
1670 |
'multi' => 1, |
|
1671 |
'echo' => 0, |
|
1672 |
'show' => 'display_name_with_login', |
|
1673 |
); |
|
0 | 1674 |
|
19 | 1675 |
if ( $bulk ) { |
1676 |
$users_opt['show_option_none'] = __( '— No Change —' ); |
|
1677 |
} |
|
16 | 1678 |
|
19 | 1679 |
/** |
1680 |
* Filters the arguments used to generate the Quick Edit authors drop-down. |
|
1681 |
* |
|
1682 |
* @since 5.6.0 |
|
1683 |
* |
|
1684 |
* @see wp_dropdown_users() |
|
1685 |
* |
|
1686 |
* @param array $users_opt An array of arguments passed to wp_dropdown_users(). |
|
1687 |
* @param bool $bulk A flag to denote if it's a bulk action. |
|
1688 |
*/ |
|
1689 |
$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk ); |
|
18 | 1690 |
|
19 | 1691 |
$authors = wp_dropdown_users( $users_opt ); |
18 | 1692 |
|
19 | 1693 |
if ( $authors ) { |
1694 |
$authors_dropdown = '<label class="inline-edit-author">'; |
|
1695 |
$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>'; |
|
1696 |
$authors_dropdown .= $authors; |
|
1697 |
$authors_dropdown .= '</label>'; |
|
1698 |
} |
|
18 | 1699 |
} |
1700 |
} // current_user_can( 'edit_others_posts' ) |
|
0 | 1701 |
|
16 | 1702 |
if ( ! $bulk ) { |
1703 |
echo $authors_dropdown; |
|
9 | 1704 |
} |
18 | 1705 |
} // post_type_supports( ... 'author' ) |
9 | 1706 |
?> |
0 | 1707 |
|
16 | 1708 |
<?php if ( ! $bulk && $can_publish ) : ?> |
0 | 1709 |
|
16 | 1710 |
<div class="inline-edit-group wp-clearfix"> |
1711 |
<label class="alignleft"> |
|
1712 |
<span class="title"><?php _e( 'Password' ); ?></span> |
|
1713 |
<span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
|
1714 |
</label> |
|
0 | 1715 |
|
16 | 1716 |
<span class="alignleft inline-edit-or"> |
1717 |
<?php |
|
1718 |
/* translators: Between password field and private checkbox on post quick edit interface. */ |
|
1719 |
_e( '–OR–' ); |
|
1720 |
?> |
|
1721 |
</span> |
|
1722 |
<label class="alignleft inline-edit-private"> |
|
1723 |
<input type="checkbox" name="keep_private" value="private" /> |
|
1724 |
<span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
|
1725 |
</label> |
|
1726 |
</div> |
|
0 | 1727 |
|
9 | 1728 |
<?php endif; ?> |
0 | 1729 |
|
16 | 1730 |
</div> |
1731 |
</fieldset> |
|
0 | 1732 |
|
9 | 1733 |
<?php if ( count( $hierarchical_taxonomies ) && ! $bulk ) : ?> |
0 | 1734 |
|
16 | 1735 |
<fieldset class="inline-edit-col-center inline-edit-categories"> |
1736 |
<div class="inline-edit-col"> |
|
0 | 1737 |
|
16 | 1738 |
<?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
0 | 1739 |
|
16 | 1740 |
<span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
1741 |
<input type="hidden" name="<?php echo ( 'category' === $taxonomy->name ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
|
1742 |
<ul class="cat-checklist <?php echo esc_attr( $taxonomy->name ); ?>-checklist"> |
|
19 | 1743 |
<?php wp_terms_checklist( 0, array( 'taxonomy' => $taxonomy->name ) ); ?> |
16 | 1744 |
</ul> |
0 | 1745 |
|
16 | 1746 |
<?php endforeach; // $hierarchical_taxonomies as $taxonomy ?> |
0 | 1747 |
|
16 | 1748 |
</div> |
1749 |
</fieldset> |
|
0 | 1750 |
|
16 | 1751 |
<?php endif; // count( $hierarchical_taxonomies ) && ! $bulk ?> |
0 | 1752 |
|
16 | 1753 |
<fieldset class="inline-edit-col-right"> |
1754 |
<div class="inline-edit-col"> |
|
0 | 1755 |
|
9 | 1756 |
<?php |
16 | 1757 |
if ( post_type_supports( $screen->post_type, 'author' ) && $bulk ) { |
1758 |
echo $authors_dropdown; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
1759 |
} |
9 | 1760 |
?> |
16 | 1761 |
|
1762 |
<?php if ( post_type_supports( $screen->post_type, 'page-attributes' ) ) : ?> |
|
1763 |
||
1764 |
<?php if ( $post_type_object->hierarchical ) : ?> |
|
1765 |
||
1766 |
<label> |
|
1767 |
<span class="title"><?php _e( 'Parent' ); ?></span> |
|
1768 |
<?php |
|
1769 |
$dropdown_args = array( |
|
1770 |
'post_type' => $post_type_object->name, |
|
1771 |
'selected' => $post->post_parent, |
|
1772 |
'name' => 'post_parent', |
|
1773 |
'show_option_none' => __( 'Main Page (no parent)' ), |
|
1774 |
'option_none_value' => 0, |
|
1775 |
'sort_column' => 'menu_order, post_title', |
|
1776 |
); |
|
1777 |
||
1778 |
if ( $bulk ) { |
|
1779 |
$dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
|
1780 |
} |
|
1781 |
||
1782 |
/** |
|
1783 |
* Filters the arguments used to generate the Quick Edit page-parent drop-down. |
|
1784 |
* |
|
1785 |
* @since 2.7.0 |
|
18 | 1786 |
* @since 5.6.0 The `$bulk` parameter was added. |
16 | 1787 |
* |
1788 |
* @see wp_dropdown_pages() |
|
1789 |
* |
|
18 | 1790 |
* @param array $dropdown_args An array of arguments passed to wp_dropdown_pages(). |
1791 |
* @param bool $bulk A flag to denote if it's a bulk action. |
|
16 | 1792 |
*/ |
18 | 1793 |
$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk ); |
16 | 1794 |
|
1795 |
wp_dropdown_pages( $dropdown_args ); |
|
1796 |
?> |
|
1797 |
</label> |
|
1798 |
||
1799 |
<?php endif; // hierarchical ?> |
|
1800 |
||
1801 |
<?php if ( ! $bulk ) : ?> |
|
1802 |
||
1803 |
<label> |
|
1804 |
<span class="title"><?php _e( 'Order' ); ?></span> |
|
1805 |
<span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order; ?>" /></span> |
|
1806 |
</label> |
|
1807 |
||
1808 |
<?php endif; // ! $bulk ?> |
|
1809 |
||
1810 |
<?php endif; // post_type_supports( ... 'page-attributes' ) ?> |
|
1811 |
||
1812 |
<?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> |
|
1813 |
||
1814 |
<label> |
|
1815 |
<span class="title"><?php _e( 'Template' ); ?></span> |
|
1816 |
<select name="page_template"> |
|
1817 |
<?php if ( $bulk ) : ?> |
|
1818 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1819 |
<?php endif; // $bulk ?> |
|
1820 |
<?php |
|
1821 |
/** This filter is documented in wp-admin/includes/meta-boxes.php */ |
|
1822 |
$default_title = apply_filters( 'default_page_template_title', __( 'Default template' ), 'quick-edit' ); |
|
1823 |
?> |
|
1824 |
<option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
1825 |
<?php page_template_dropdown( '', $screen->post_type ); ?> |
|
1826 |
</select> |
|
1827 |
</label> |
|
1828 |
||
1829 |
<?php endif; ?> |
|
1830 |
||
1831 |
<?php if ( count( $flat_taxonomies ) && ! $bulk ) : ?> |
|
1832 |
||
1833 |
<?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
|
1834 |
||
1835 |
<?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
|
1836 |
<?php $taxonomy_name = esc_attr( $taxonomy->name ); ?> |
|
19 | 1837 |
<div class="inline-edit-tags-wrap"> |
16 | 1838 |
<label class="inline-edit-tags"> |
1839 |
<span class="title"><?php echo esc_html( $taxonomy->labels->name ); ?></span> |
|
19 | 1840 |
<textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name ); ?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name ); ?>" aria-describedby="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"></textarea> |
16 | 1841 |
</label> |
19 | 1842 |
<p class="howto" id="inline-edit-<?php echo esc_attr( $taxonomy->name ); ?>-desc"><?php echo esc_html( $taxonomy->labels->separate_items_with_commas ); ?></p> |
1843 |
</div> |
|
16 | 1844 |
<?php endif; // current_user_can( 'assign_terms' ) ?> |
1845 |
||
1846 |
<?php endforeach; // $flat_taxonomies as $taxonomy ?> |
|
1847 |
||
1848 |
<?php endif; // count( $flat_taxonomies ) && ! $bulk ?> |
|
1849 |
||
1850 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1851 |
||
1852 |
<?php if ( $bulk ) : ?> |
|
1853 |
||
1854 |
<div class="inline-edit-group wp-clearfix"> |
|
1855 |
||
1856 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1857 |
||
1858 |
<label class="alignleft"> |
|
1859 |
<span class="title"><?php _e( 'Comments' ); ?></span> |
|
1860 |
<select name="comment_status"> |
|
1861 |
<option value=""><?php _e( '— No Change —' ); ?></option> |
|
1862 |
<option value="open"><?php _e( 'Allow' ); ?></option> |
|
1863 |
<option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1864 |
</select> |
|
1865 |
</label> |
|
1866 |
||
1867 |
<?php endif; ?> |
|
1868 |
||
1869 |
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
9 | 1870 |
|
16 | 1871 |
<label class="alignright"> |
1872 |
<span class="title"><?php _e( 'Pings' ); ?></span> |
|
1873 |
<select name="ping_status"> |
|
1874 |
<option value=""><?php _e( '— No Change —' ); ?></option> |
|
1875 |
<option value="open"><?php _e( 'Allow' ); ?></option> |
|
1876 |
<option value="closed"><?php _e( 'Do not allow' ); ?></option> |
|
1877 |
</select> |
|
1878 |
</label> |
|
1879 |
||
1880 |
<?php endif; ?> |
|
1881 |
||
1882 |
</div> |
|
1883 |
||
1884 |
<?php else : // $bulk ?> |
|
1885 |
||
1886 |
<div class="inline-edit-group wp-clearfix"> |
|
1887 |
||
1888 |
<?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
|
1889 |
||
1890 |
<label class="alignleft"> |
|
1891 |
<input type="checkbox" name="comment_status" value="open" /> |
|
1892 |
<span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
|
1893 |
</label> |
|
1894 |
||
1895 |
<?php endif; ?> |
|
1896 |
||
1897 |
<?php if ( post_type_supports( $screen->post_type, 'trackbacks' ) ) : ?> |
|
1898 |
||
1899 |
<label class="alignleft"> |
|
1900 |
<input type="checkbox" name="ping_status" value="open" /> |
|
1901 |
<span class="checkbox-title"><?php _e( 'Allow Pings' ); ?></span> |
|
1902 |
</label> |
|
1903 |
||
1904 |
<?php endif; ?> |
|
1905 |
||
1906 |
</div> |
|
1907 |
||
1908 |
<?php endif; // $bulk ?> |
|
1909 |
||
1910 |
<?php endif; // post_type_supports( ... comments or pings ) ?> |
|
1911 |
||
1912 |
<div class="inline-edit-group wp-clearfix"> |
|
1913 |
||
1914 |
<label class="inline-edit-status alignleft"> |
|
1915 |
<span class="title"><?php _e( 'Status' ); ?></span> |
|
1916 |
<select name="_status"> |
|
1917 |
<?php if ( $bulk ) : ?> |
|
1918 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1919 |
<?php endif; // $bulk ?> |
|
9 | 1920 |
|
16 | 1921 |
<?php if ( $can_publish ) : // Contributors only get "Unpublished" and "Pending Review". ?> |
1922 |
<option value="publish"><?php _e( 'Published' ); ?></option> |
|
1923 |
<option value="future"><?php _e( 'Scheduled' ); ?></option> |
|
1924 |
<?php if ( $bulk ) : ?> |
|
1925 |
<option value="private"><?php _e( 'Private' ); ?></option> |
|
1926 |
<?php endif; // $bulk ?> |
|
1927 |
<?php endif; ?> |
|
1928 |
||
1929 |
<option value="pending"><?php _e( 'Pending Review' ); ?></option> |
|
1930 |
<option value="draft"><?php _e( 'Draft' ); ?></option> |
|
1931 |
</select> |
|
1932 |
</label> |
|
1933 |
||
1934 |
<?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
|
1935 |
||
1936 |
<?php if ( $bulk ) : ?> |
|
1937 |
||
1938 |
<label class="alignright"> |
|
1939 |
<span class="title"><?php _e( 'Sticky' ); ?></span> |
|
1940 |
<select name="sticky"> |
|
1941 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1942 |
<option value="sticky"><?php _e( 'Sticky' ); ?></option> |
|
1943 |
<option value="unsticky"><?php _e( 'Not Sticky' ); ?></option> |
|
1944 |
</select> |
|
1945 |
</label> |
|
1946 |
||
1947 |
<?php else : // $bulk ?> |
|
0 | 1948 |
|
16 | 1949 |
<label class="alignleft"> |
1950 |
<input type="checkbox" name="sticky" value="sticky" /> |
|
1951 |
<span class="checkbox-title"><?php _e( 'Make this post sticky' ); ?></span> |
|
1952 |
</label> |
|
1953 |
||
1954 |
<?php endif; // $bulk ?> |
|
1955 |
||
1956 |
<?php endif; // 'post' && $can_publish && current_user_can( 'edit_others_posts' ) ?> |
|
1957 |
||
1958 |
</div> |
|
1959 |
||
1960 |
<?php if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) : ?> |
|
1961 |
<?php $post_formats = get_theme_support( 'post-formats' ); ?> |
|
1962 |
||
1963 |
<label class="alignleft"> |
|
1964 |
<span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
|
1965 |
<select name="post_format"> |
|
1966 |
<option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1967 |
<option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
|
1968 |
<?php if ( is_array( $post_formats[0] ) ) : ?> |
|
1969 |
<?php foreach ( $post_formats[0] as $format ) : ?> |
|
1970 |
<option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
|
1971 |
<?php endforeach; ?> |
|
1972 |
<?php endif; ?> |
|
1973 |
</select> |
|
1974 |
</label> |
|
1975 |
||
1976 |
<?php endif; ?> |
|
1977 |
||
1978 |
</div> |
|
1979 |
</fieldset> |
|
0 | 1980 |
|
9 | 1981 |
<?php |
1982 |
list( $columns ) = $this->get_column_info(); |
|
0 | 1983 |
|
9 | 1984 |
foreach ( $columns as $column_name => $column_display_name ) { |
1985 |
if ( isset( $core_columns[ $column_name ] ) ) { |
|
1986 |
continue; |
|
1987 |
} |
|
5 | 1988 |
|
9 | 1989 |
if ( $bulk ) { |
5 | 1990 |
|
9 | 1991 |
/** |
1992 |
* Fires once for each column in Bulk Edit mode. |
|
1993 |
* |
|
1994 |
* @since 2.7.0 |
|
1995 |
* |
|
16 | 1996 |
* @param string $column_name Name of the column to edit. |
1997 |
* @param string $post_type The post type slug. |
|
9 | 1998 |
*/ |
1999 |
do_action( 'bulk_edit_custom_box', $column_name, $screen->post_type ); |
|
2000 |
} else { |
|
5 | 2001 |
|
9 | 2002 |
/** |
2003 |
* Fires once for each column in Quick Edit mode. |
|
2004 |
* |
|
2005 |
* @since 2.7.0 |
|
2006 |
* |
|
2007 |
* @param string $column_name Name of the column to edit. |
|
2008 |
* @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. |
|
16 | 2009 |
* @param string $taxonomy The taxonomy name, if any. |
9 | 2010 |
*/ |
2011 |
do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); |
|
2012 |
} |
|
5 | 2013 |
} |
9 | 2014 |
?> |
16 | 2015 |
|
2016 |
<div class="submit inline-edit-save"> |
|
2017 |
<?php if ( ! $bulk ) : ?> |
|
2018 |
<?php wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); ?> |
|
19 | 2019 |
<button type="button" class="button button-primary save"><?php _e( 'Update' ); ?></button> |
2020 |
<?php else : ?> |
|
2021 |
<?php submit_button( __( 'Update' ), 'primary', 'bulk_edit', false ); ?> |
|
2022 |
<?php endif; ?> |
|
2023 |
||
2024 |
<button type="button" class="button cancel"><?php _e( 'Cancel' ); ?></button> |
|
2025 |
||
2026 |
<?php if ( ! $bulk ) : ?> |
|
16 | 2027 |
<span class="spinner"></span> |
2028 |
<?php endif; ?> |
|
2029 |
||
2030 |
<input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
|
2031 |
<input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
|
2032 |
<?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) : ?> |
|
2033 |
<input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
|
2034 |
<?php endif; ?> |
|
2035 |
||
2036 |
<div class="notice notice-error notice-alt inline hidden"> |
|
2037 |
<p class="error"></p> |
|
2038 |
</div> |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
2039 |
</div> |
19 | 2040 |
</div> <!-- end of .inline-edit-wrapper --> |
16 | 2041 |
|
2042 |
</td></tr> |
|
2043 |
||
9 | 2044 |
<?php |
2045 |
$bulk++; |
|
16 | 2046 |
endwhile; |
9 | 2047 |
?> |
16 | 2048 |
</tbody></table> |
2049 |
</form> |
|
9 | 2050 |
<?php |
0 | 2051 |
} |
2052 |
} |