changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
6:490d5cc509ed | 7:cf61fcea0001 |
---|---|
1 <?php |
1 <?php |
2 /** |
2 /** |
3 * Posts List Table class. |
3 * List Table API: WP_Posts_List_Table class |
4 * |
4 * |
5 * @package WordPress |
5 * @package WordPress |
6 * @subpackage List_Table |
6 * @subpackage Administration |
7 * @since 3.1.0 |
|
8 */ |
|
9 |
|
10 /** |
|
11 * Core class used to implement displaying posts in a list table. |
|
12 * |
|
7 * @since 3.1.0 |
13 * @since 3.1.0 |
8 * @access private |
14 * @access private |
15 * |
|
16 * @see WP_List_Table |
|
9 */ |
17 */ |
10 class WP_Posts_List_Table extends WP_List_Table { |
18 class WP_Posts_List_Table extends WP_List_Table { |
11 |
19 |
12 /** |
20 /** |
13 * Whether the items should be displayed hierarchically or linearly |
21 * Whether the items should be displayed hierarchically or linearly. |
14 * |
22 * |
15 * @since 3.1.0 |
23 * @since 3.1.0 |
16 * @var bool |
24 * @var bool |
17 * @access protected |
|
18 */ |
25 */ |
19 protected $hierarchical_display; |
26 protected $hierarchical_display; |
20 |
27 |
21 /** |
28 /** |
22 * Holds the number of pending comments for each post |
29 * Holds the number of pending comments for each post. |
30 * |
|
31 * @since 3.1.0 |
|
32 * @var array |
|
33 */ |
|
34 protected $comment_pending_count; |
|
35 |
|
36 /** |
|
37 * Holds the number of posts for this user. |
|
23 * |
38 * |
24 * @since 3.1.0 |
39 * @since 3.1.0 |
25 * @var int |
40 * @var int |
26 * @access protected |
41 */ |
27 */ |
42 private $user_posts_count; |
28 protected $comment_pending_count; |
43 |
29 |
44 /** |
30 /** |
45 * Holds the number of posts which are sticky. |
31 * Holds the number of posts for this user |
|
32 * |
46 * |
33 * @since 3.1.0 |
47 * @since 3.1.0 |
34 * @var int |
48 * @var int |
35 * @access private |
49 */ |
36 */ |
50 private $sticky_posts_count = 0; |
37 private $user_posts_count; |
51 |
38 |
52 private $is_trash; |
39 /** |
53 |
40 * Holds the number of posts which are sticky. |
54 /** |
55 * Current level for output. |
|
56 * |
|
57 * @since 4.3.0 |
|
58 * @var int |
|
59 */ |
|
60 protected $current_level = 0; |
|
61 |
|
62 /** |
|
63 * Constructor. |
|
41 * |
64 * |
42 * @since 3.1.0 |
65 * @since 3.1.0 |
43 * @var int |
|
44 * @access private |
|
45 */ |
|
46 private $sticky_posts_count = 0; |
|
47 |
|
48 private $is_trash; |
|
49 |
|
50 /** |
|
51 * Constructor. |
|
52 * |
|
53 * @since 3.1.0 |
|
54 * @access public |
|
55 * |
66 * |
56 * @see WP_List_Table::__construct() for more information on default arguments. |
67 * @see WP_List_Table::__construct() for more information on default arguments. |
68 * |
|
69 * @global WP_Post_Type $post_type_object |
|
70 * @global wpdb $wpdb |
|
57 * |
71 * |
58 * @param array $args An associative array of arguments. |
72 * @param array $args An associative array of arguments. |
59 */ |
73 */ |
60 public function __construct( $args = array() ) { |
74 public function __construct( $args = array() ) { |
61 global $post_type_object, $wpdb; |
75 global $post_type_object, $wpdb; |
63 parent::__construct( array( |
77 parent::__construct( array( |
64 'plural' => 'posts', |
78 'plural' => 'posts', |
65 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
79 'screen' => isset( $args['screen'] ) ? $args['screen'] : null, |
66 ) ); |
80 ) ); |
67 |
81 |
68 $post_type = $this->screen->post_type; |
82 $post_type = $this->screen->post_type; |
69 $post_type_object = get_post_type_object( $post_type ); |
83 $post_type_object = get_post_type_object( $post_type ); |
70 |
84 |
71 if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) { |
85 $exclude_states = get_post_stati( array( |
72 $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) ); |
86 'show_in_admin_all_list' => false, |
73 $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( " |
87 ) ); |
74 SELECT COUNT( 1 ) FROM $wpdb->posts |
88 $this->user_posts_count = intval( $wpdb->get_var( $wpdb->prepare( " |
75 WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
89 SELECT COUNT( 1 ) |
76 AND post_author = %d |
90 FROM $wpdb->posts |
77 ", $post_type, get_current_user_id() ) ); |
91 WHERE post_type = %s |
78 |
92 AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' ) |
79 if ( $this->user_posts_count && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) |
93 AND post_author = %d |
80 $_GET['author'] = get_current_user_id(); |
94 ", $post_type, get_current_user_id() ) ) ); |
81 } |
95 |
82 |
96 if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) { |
83 if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
97 $_GET['author'] = get_current_user_id(); |
98 } |
|
99 |
|
100 if ( 'post' === $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) { |
|
84 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
101 $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) ); |
85 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) ); |
102 $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status NOT IN ('trash', 'auto-draft') AND ID IN ($sticky_posts)", $post_type ) ); |
86 } |
103 } |
87 } |
104 } |
88 |
105 |
95 */ |
112 */ |
96 public function set_hierarchical_display( $display ) { |
113 public function set_hierarchical_display( $display ) { |
97 $this->hierarchical_display = $display; |
114 $this->hierarchical_display = $display; |
98 } |
115 } |
99 |
116 |
117 /** |
|
118 * |
|
119 * @return bool |
|
120 */ |
|
100 public function ajax_user_can() { |
121 public function ajax_user_can() { |
101 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
122 return current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_posts ); |
102 } |
123 } |
103 |
124 |
125 /** |
|
126 * |
|
127 * @global array $avail_post_stati |
|
128 * @global WP_Query $wp_query |
|
129 * @global int $per_page |
|
130 * @global string $mode |
|
131 */ |
|
104 public function prepare_items() { |
132 public function prepare_items() { |
105 global $avail_post_stati, $wp_query, $per_page, $mode; |
133 global $avail_post_stati, $wp_query, $per_page, $mode; |
106 |
134 |
135 // is going to call wp() |
|
107 $avail_post_stati = wp_edit_posts_query(); |
136 $avail_post_stati = wp_edit_posts_query(); |
108 |
137 |
109 $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' == $wp_query->query['orderby'] ); |
138 $this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] ); |
110 |
|
111 $total_items = $this->hierarchical_display ? $wp_query->post_count : $wp_query->found_posts; |
|
112 |
139 |
113 $post_type = $this->screen->post_type; |
140 $post_type = $this->screen->post_type; |
114 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
141 $per_page = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' ); |
115 |
142 |
116 /** This filter is documented in wp-admin/includes/post.php */ |
143 /** This filter is documented in wp-admin/includes/post.php */ |
117 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
144 $per_page = apply_filters( 'edit_posts_per_page', $per_page, $post_type ); |
118 |
145 |
119 if ( $this->hierarchical_display ) |
146 if ( $this->hierarchical_display ) { |
120 $total_pages = ceil( $total_items / $per_page ); |
147 $total_items = $wp_query->post_count; |
121 else |
148 } elseif ( $wp_query->found_posts || $this->get_pagenum() === 1 ) { |
122 $total_pages = $wp_query->max_num_pages; |
149 $total_items = $wp_query->found_posts; |
150 } else { |
|
151 $post_counts = (array) wp_count_posts( $post_type, 'readable' ); |
|
152 |
|
153 if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'] , $avail_post_stati ) ) { |
|
154 $total_items = $post_counts[ $_REQUEST['post_status'] ]; |
|
155 } elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) { |
|
156 $total_items = $this->sticky_posts_count; |
|
157 } elseif ( isset( $_GET['author'] ) && $_GET['author'] == get_current_user_id() ) { |
|
158 $total_items = $this->user_posts_count; |
|
159 } else { |
|
160 $total_items = array_sum( $post_counts ); |
|
161 |
|
162 // Subtract post types that are not included in the admin all list. |
|
163 foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
|
164 $total_items -= $post_counts[ $state ]; |
|
165 } |
|
166 } |
|
167 } |
|
123 |
168 |
124 if ( ! empty( $_REQUEST['mode'] ) ) { |
169 if ( ! empty( $_REQUEST['mode'] ) ) { |
125 $mode = $_REQUEST['mode'] == 'excerpt' ? 'excerpt' : 'list'; |
170 $mode = $_REQUEST['mode'] === 'excerpt' ? 'excerpt' : 'list'; |
126 set_user_setting ( 'posts_list_mode', $mode ); |
171 set_user_setting( 'posts_list_mode', $mode ); |
127 } else { |
172 } else { |
128 $mode = get_user_setting ( 'posts_list_mode', 'list' ); |
173 $mode = get_user_setting( 'posts_list_mode', 'list' ); |
129 } |
174 } |
130 |
175 |
131 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] == 'trash'; |
176 $this->is_trash = isset( $_REQUEST['post_status'] ) && $_REQUEST['post_status'] === 'trash'; |
132 |
177 |
133 $this->set_pagination_args( array( |
178 $this->set_pagination_args( array( |
134 'total_items' => $total_items, |
179 'total_items' => $total_items, |
135 'total_pages' => $total_pages, |
|
136 'per_page' => $per_page |
180 'per_page' => $per_page |
137 ) ); |
181 ) ); |
138 } |
182 } |
139 |
183 |
184 /** |
|
185 * |
|
186 * @return bool |
|
187 */ |
|
140 public function has_items() { |
188 public function has_items() { |
141 return have_posts(); |
189 return have_posts(); |
142 } |
190 } |
143 |
191 |
192 /** |
|
193 */ |
|
144 public function no_items() { |
194 public function no_items() { |
145 if ( isset( $_REQUEST['post_status'] ) && 'trash' == $_REQUEST['post_status'] ) |
195 if ( isset( $_REQUEST['post_status'] ) && 'trash' === $_REQUEST['post_status'] ) |
146 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
196 echo get_post_type_object( $this->screen->post_type )->labels->not_found_in_trash; |
147 else |
197 else |
148 echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
198 echo get_post_type_object( $this->screen->post_type )->labels->not_found; |
149 } |
199 } |
150 |
200 |
151 /** |
201 /** |
152 * Determine if the current view is the "All" view. |
202 * Determine if the current view is the "All" view. |
153 * |
203 * |
154 * @since 4.2.0 |
204 * @since 4.2.0 |
155 * |
205 * |
156 * @return bool Whether the current ivew is the "All" view. |
206 * @return bool Whether the current view is the "All" view. |
157 */ |
207 */ |
158 protected function is_base_request() { |
208 protected function is_base_request() { |
159 if ( empty( $_GET ) ) { |
209 $vars = $_GET; |
210 unset( $vars['paged'] ); |
|
211 |
|
212 if ( empty( $vars ) ) { |
|
160 return true; |
213 return true; |
161 } elseif ( 1 === count( $_GET ) && ! empty( $_GET['post_type'] ) ) { |
214 } elseif ( 1 === count( $vars ) && ! empty( $vars['post_type'] ) ) { |
162 return $this->screen->post_type === $_GET['post_type']; |
215 return $this->screen->post_type === $vars['post_type']; |
163 } |
216 } |
164 } |
217 |
165 |
218 return 1 === count( $vars ) && ! empty( $vars['mode'] ); |
219 } |
|
220 |
|
221 /** |
|
222 * Helper to create links to edit.php with params. |
|
223 * |
|
224 * @since 4.4.0 |
|
225 * |
|
226 * @param array $args URL parameters for the link. |
|
227 * @param string $label Link text. |
|
228 * @param string $class Optional. Class attribute. Default empty string. |
|
229 * @return string The formatted link string. |
|
230 */ |
|
231 protected function get_edit_link( $args, $label, $class = '' ) { |
|
232 $url = add_query_arg( $args, 'edit.php' ); |
|
233 |
|
234 $class_html = $aria_current = ''; |
|
235 if ( ! empty( $class ) ) { |
|
236 $class_html = sprintf( |
|
237 ' class="%s"', |
|
238 esc_attr( $class ) |
|
239 ); |
|
240 |
|
241 if ( 'current' === $class ) { |
|
242 $aria_current = ' aria-current="page"'; |
|
243 } |
|
244 } |
|
245 |
|
246 return sprintf( |
|
247 '<a href="%s"%s%s>%s</a>', |
|
248 esc_url( $url ), |
|
249 $class_html, |
|
250 $aria_current, |
|
251 $label |
|
252 ); |
|
253 } |
|
254 |
|
255 /** |
|
256 * |
|
257 * @global array $locked_post_status This seems to be deprecated. |
|
258 * @global array $avail_post_stati |
|
259 * @return array |
|
260 */ |
|
166 protected function get_views() { |
261 protected function get_views() { |
167 global $locked_post_status, $avail_post_stati; |
262 global $locked_post_status, $avail_post_stati; |
168 |
263 |
169 $post_type = $this->screen->post_type; |
264 $post_type = $this->screen->post_type; |
170 |
265 |
171 if ( !empty($locked_post_status) ) |
266 if ( !empty($locked_post_status) ) |
172 return array(); |
267 return array(); |
173 |
268 |
174 $status_links = array(); |
269 $status_links = array(); |
175 $num_posts = wp_count_posts( $post_type, 'readable' ); |
270 $num_posts = wp_count_posts( $post_type, 'readable' ); |
271 $total_posts = array_sum( (array) $num_posts ); |
|
176 $class = ''; |
272 $class = ''; |
177 $allposts = ''; |
|
178 |
273 |
179 $current_user_id = get_current_user_id(); |
274 $current_user_id = get_current_user_id(); |
180 |
275 $all_args = array( 'post_type' => $post_type ); |
181 if ( $this->user_posts_count ) { |
276 $mine = ''; |
182 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) |
277 |
183 $class = ' class="current"'; |
278 // Subtract post types that are not included in the admin all list. |
184 $status_links['mine'] = "<a href='edit.php?post_type=$post_type&author=$current_user_id'$class>" . sprintf( _nx( 'Mine <span class="count">(%s)</span>', 'Mine <span class="count">(%s)</span>', $this->user_posts_count, 'posts' ), number_format_i18n( $this->user_posts_count ) ) . '</a>'; |
279 foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) { |
185 $allposts = '&all_posts=1'; |
280 $total_posts -= $num_posts->$state; |
281 } |
|
282 |
|
283 if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) { |
|
284 if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) { |
|
285 $class = 'current'; |
|
286 } |
|
287 |
|
288 $mine_args = array( |
|
289 'post_type' => $post_type, |
|
290 'author' => $current_user_id |
|
291 ); |
|
292 |
|
293 $mine_inner_html = sprintf( |
|
294 _nx( |
|
295 'Mine <span class="count">(%s)</span>', |
|
296 'Mine <span class="count">(%s)</span>', |
|
297 $this->user_posts_count, |
|
298 'posts' |
|
299 ), |
|
300 number_format_i18n( $this->user_posts_count ) |
|
301 ); |
|
302 |
|
303 $mine = $this->get_edit_link( $mine_args, $mine_inner_html, $class ); |
|
304 |
|
305 $all_args['all_posts'] = 1; |
|
186 $class = ''; |
306 $class = ''; |
187 } |
307 } |
188 |
308 |
189 $total_posts = array_sum( (array) $num_posts ); |
309 if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_posts'] ) ) ) { |
190 |
310 $class = 'current'; |
191 // Subtract post types that are not included in the admin all list. |
|
192 foreach ( get_post_stati( array('show_in_admin_all_list' => false) ) as $state ) |
|
193 $total_posts -= $num_posts->$state; |
|
194 |
|
195 if ( empty( $class ) && $this->is_base_request() && ! $this->user_posts_count ) { |
|
196 $class = ' class="current"'; |
|
197 } |
311 } |
198 |
312 |
199 $all_inner_html = sprintf( |
313 $all_inner_html = sprintf( |
200 _nx( |
314 _nx( |
201 'All <span class="count">(%s)</span>', |
315 'All <span class="count">(%s)</span>', |
204 'posts' |
318 'posts' |
205 ), |
319 ), |
206 number_format_i18n( $total_posts ) |
320 number_format_i18n( $total_posts ) |
207 ); |
321 ); |
208 |
322 |
209 $status_links['all'] = "<a href='edit.php?post_type=$post_type{$allposts}'$class>" . $all_inner_html . '</a>'; |
323 $status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class ); |
324 if ( $mine ) { |
|
325 $status_links['mine'] = $mine; |
|
326 } |
|
210 |
327 |
211 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { |
328 foreach ( get_post_stati(array('show_in_admin_status_list' => true), 'objects') as $status ) { |
212 $class = ''; |
329 $class = ''; |
213 |
330 |
214 $status_name = $status->name; |
331 $status_name = $status->name; |
215 |
332 |
216 if ( !in_array( $status_name, $avail_post_stati ) ) |
333 if ( ! in_array( $status_name, $avail_post_stati ) || empty( $num_posts->$status_name ) ) { |
217 continue; |
334 continue; |
218 |
335 } |
219 if ( empty( $num_posts->$status_name ) ) |
336 |
220 continue; |
337 if ( isset($_REQUEST['post_status']) && $status_name === $_REQUEST['post_status'] ) { |
221 |
338 $class = 'current'; |
222 if ( isset($_REQUEST['post_status']) && $status_name == $_REQUEST['post_status'] ) |
339 } |
223 $class = ' class="current"'; |
340 |
224 |
341 $status_args = array( |
225 $status_links[$status_name] = "<a href='edit.php?post_status=$status_name&post_type=$post_type'$class>" . sprintf( translate_nooped_plural( $status->label_count, $num_posts->$status_name ), number_format_i18n( $num_posts->$status_name ) ) . '</a>'; |
342 'post_status' => $status_name, |
343 'post_type' => $post_type, |
|
344 ); |
|
345 |
|
346 $status_label = sprintf( |
|
347 translate_nooped_plural( $status->label_count, $num_posts->$status_name ), |
|
348 number_format_i18n( $num_posts->$status_name ) |
|
349 ); |
|
350 |
|
351 $status_links[ $status_name ] = $this->get_edit_link( $status_args, $status_label, $class ); |
|
226 } |
352 } |
227 |
353 |
228 if ( ! empty( $this->sticky_posts_count ) ) { |
354 if ( ! empty( $this->sticky_posts_count ) ) { |
229 $class = ! empty( $_REQUEST['show_sticky'] ) ? ' class="current"' : ''; |
355 $class = ! empty( $_REQUEST['show_sticky'] ) ? 'current' : ''; |
230 |
356 |
231 $sticky_link = array( 'sticky' => "<a href='edit.php?post_type=$post_type&show_sticky=1'$class>" . sprintf( _nx( 'Sticky <span class="count">(%s)</span>', 'Sticky <span class="count">(%s)</span>', $this->sticky_posts_count, 'posts' ), number_format_i18n( $this->sticky_posts_count ) ) . '</a>' ); |
357 $sticky_args = array( |
358 'post_type' => $post_type, |
|
359 'show_sticky' => 1 |
|
360 ); |
|
361 |
|
362 $sticky_inner_html = sprintf( |
|
363 _nx( |
|
364 'Sticky <span class="count">(%s)</span>', |
|
365 'Sticky <span class="count">(%s)</span>', |
|
366 $this->sticky_posts_count, |
|
367 'posts' |
|
368 ), |
|
369 number_format_i18n( $this->sticky_posts_count ) |
|
370 ); |
|
371 |
|
372 $sticky_link = array( |
|
373 'sticky' => $this->get_edit_link( $sticky_args, $sticky_inner_html, $class ) |
|
374 ); |
|
232 |
375 |
233 // Sticky comes after Publish, or if not listed, after All. |
376 // Sticky comes after Publish, or if not listed, after All. |
234 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); |
377 $split = 1 + array_search( ( isset( $status_links['publish'] ) ? 'publish' : 'all' ), array_keys( $status_links ) ); |
235 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
378 $status_links = array_merge( array_slice( $status_links, 0, $split ), $sticky_link, array_slice( $status_links, $split ) ); |
236 } |
379 } |
237 |
380 |
238 return $status_links; |
381 return $status_links; |
239 } |
382 } |
240 |
383 |
384 /** |
|
385 * |
|
386 * @return array |
|
387 */ |
|
241 protected function get_bulk_actions() { |
388 protected function get_bulk_actions() { |
242 $actions = array(); |
389 $actions = array(); |
243 $post_type_obj = get_post_type_object( $this->screen->post_type ); |
390 $post_type_obj = get_post_type_object( $this->screen->post_type ); |
244 |
391 |
245 if ( $this->is_trash ) { |
392 if ( current_user_can( $post_type_obj->cap->edit_posts ) ) { |
246 $actions['untrash'] = __( 'Restore' ); |
393 if ( $this->is_trash ) { |
247 } else { |
394 $actions['untrash'] = __( 'Restore' ); |
248 $actions['edit'] = __( 'Edit' ); |
395 } else { |
396 $actions['edit'] = __( 'Edit' ); |
|
397 } |
|
249 } |
398 } |
250 |
399 |
251 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
400 if ( current_user_can( $post_type_obj->cap->delete_posts ) ) { |
252 if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
401 if ( $this->is_trash || ! EMPTY_TRASH_DAYS ) { |
253 $actions['delete'] = __( 'Delete Permanently' ); |
402 $actions['delete'] = __( 'Delete Permanently' ); |
258 |
407 |
259 return $actions; |
408 return $actions; |
260 } |
409 } |
261 |
410 |
262 /** |
411 /** |
263 * @global int $cat |
412 * Displays a categories drop-down for filtering on the Posts list table. |
413 * |
|
414 * @since 4.6.0 |
|
415 * |
|
416 * @global int $cat Currently selected category. |
|
417 * |
|
418 * @param string $post_type Post type slug. |
|
419 */ |
|
420 protected function categories_dropdown( $post_type ) { |
|
421 global $cat; |
|
422 |
|
423 /** |
|
424 * Filters whether to remove the 'Categories' drop-down from the post list table. |
|
425 * |
|
426 * @since 4.6.0 |
|
427 * |
|
428 * @param bool $disable Whether to disable the categories drop-down. Default false. |
|
429 * @param string $post_type Post type slug. |
|
430 */ |
|
431 if ( false !== apply_filters( 'disable_categories_dropdown', false, $post_type ) ) { |
|
432 return; |
|
433 } |
|
434 |
|
435 if ( is_object_in_taxonomy( $post_type, 'category' ) ) { |
|
436 $dropdown_options = array( |
|
437 'show_option_all' => get_taxonomy( 'category' )->labels->all_items, |
|
438 'hide_empty' => 0, |
|
439 'hierarchical' => 1, |
|
440 'show_count' => 0, |
|
441 'orderby' => 'name', |
|
442 'selected' => $cat |
|
443 ); |
|
444 |
|
445 echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; |
|
446 wp_dropdown_categories( $dropdown_options ); |
|
447 } |
|
448 } |
|
449 |
|
450 /** |
|
264 * @param string $which |
451 * @param string $which |
265 */ |
452 */ |
266 protected function extra_tablenav( $which ) { |
453 protected function extra_tablenav( $which ) { |
267 global $cat; |
|
268 ?> |
454 ?> |
269 <div class="alignleft actions"> |
455 <div class="alignleft actions"> |
270 <?php |
456 <?php |
271 if ( 'top' == $which && !is_singular() ) { |
457 if ( 'top' === $which && !is_singular() ) { |
458 ob_start(); |
|
272 |
459 |
273 $this->months_dropdown( $this->screen->post_type ); |
460 $this->months_dropdown( $this->screen->post_type ); |
274 |
461 $this->categories_dropdown( $this->screen->post_type ); |
275 if ( is_object_in_taxonomy( $this->screen->post_type, 'category' ) ) { |
|
276 $dropdown_options = array( |
|
277 'show_option_all' => __( 'All categories' ), |
|
278 'hide_empty' => 0, |
|
279 'hierarchical' => 1, |
|
280 'show_count' => 0, |
|
281 'orderby' => 'name', |
|
282 'selected' => $cat |
|
283 ); |
|
284 |
|
285 echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>'; |
|
286 wp_dropdown_categories( $dropdown_options ); |
|
287 } |
|
288 |
462 |
289 /** |
463 /** |
290 * Fires before the Filter button on the Posts and Pages list tables. |
464 * Fires before the Filter button on the Posts and Pages list tables. |
291 * |
465 * |
292 * The Filter button allows sorting by date and/or category on the |
466 * The Filter button allows sorting by date and/or category on the |
293 * Posts list table, and sorting by date on the Pages list table. |
467 * Posts list table, and sorting by date on the Pages list table. |
294 * |
468 * |
295 * @since 2.1.0 |
469 * @since 2.1.0 |
470 * @since 4.4.0 The `$post_type` parameter was added. |
|
471 * @since 4.6.0 The `$which` parameter was added. |
|
472 * |
|
473 * @param string $post_type The post type slug. |
|
474 * @param string $which The location of the extra table nav markup: |
|
475 * 'top' or 'bottom' for WP_Posts_List_Table, |
|
476 * 'bar' for WP_Media_List_Table. |
|
296 */ |
477 */ |
297 do_action( 'restrict_manage_posts' ); |
478 do_action( 'restrict_manage_posts', $this->screen->post_type, $which ); |
298 |
479 |
299 submit_button( __( 'Filter' ), 'button', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
480 $output = ob_get_clean(); |
300 } |
481 |
301 |
482 if ( ! empty( $output ) ) { |
302 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) ) { |
483 echo $output; |
484 submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) ); |
|
485 } |
|
486 } |
|
487 |
|
488 if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) { |
|
303 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
489 submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false ); |
304 } |
490 } |
305 ?> |
491 ?> |
306 </div> |
492 </div> |
307 <?php |
493 <?php |
308 } |
494 /** |
309 |
495 * Fires immediately following the closing "actions" div in the tablenav for the posts |
496 * list table. |
|
497 * |
|
498 * @since 4.4.0 |
|
499 * |
|
500 * @param string $which The location of the extra table nav markup: 'top' or 'bottom'. |
|
501 */ |
|
502 do_action( 'manage_posts_extra_tablenav', $which ); |
|
503 } |
|
504 |
|
505 /** |
|
506 * |
|
507 * @return string |
|
508 */ |
|
310 public function current_action() { |
509 public function current_action() { |
311 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
510 if ( isset( $_REQUEST['delete_all'] ) || isset( $_REQUEST['delete_all2'] ) ) |
312 return 'delete_all'; |
511 return 'delete_all'; |
313 |
512 |
314 return parent::current_action(); |
513 return parent::current_action(); |
315 } |
514 } |
316 |
515 |
317 /** |
516 /** |
318 * @global string $mode |
517 * |
319 * @param string $which |
518 * @return array |
320 */ |
519 */ |
321 protected function pagination( $which ) { |
|
322 global $mode; |
|
323 |
|
324 parent::pagination( $which ); |
|
325 |
|
326 if ( 'top' == $which && ! is_post_type_hierarchical( $this->screen->post_type ) ) |
|
327 $this->view_switcher( $mode ); |
|
328 } |
|
329 |
|
330 protected function get_table_classes() { |
520 protected function get_table_classes() { |
331 return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
521 return array( 'widefat', 'fixed', 'striped', is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' ); |
332 } |
522 } |
333 |
523 |
524 /** |
|
525 * |
|
526 * @return array |
|
527 */ |
|
334 public function get_columns() { |
528 public function get_columns() { |
335 $post_type = $this->screen->post_type; |
529 $post_type = $this->screen->post_type; |
336 |
530 |
337 $posts_columns = array(); |
531 $posts_columns = array(); |
338 |
532 |
347 |
541 |
348 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
542 $taxonomies = get_object_taxonomies( $post_type, 'objects' ); |
349 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
543 $taxonomies = wp_filter_object_list( $taxonomies, array( 'show_admin_column' => true ), 'and', 'name' ); |
350 |
544 |
351 /** |
545 /** |
352 * Filter the taxonomy columns in the Posts list table. |
546 * Filters the taxonomy columns in the Posts list table. |
353 * |
547 * |
354 * The dynamic portion of the hook name, `$post_type`, refers to the post |
548 * The dynamic portion of the hook name, `$post_type`, refers to the post |
355 * type slug. |
549 * type slug. |
356 * |
550 * |
357 * @since 3.5.0 |
551 * @since 3.5.0 |
361 */ |
555 */ |
362 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
556 $taxonomies = apply_filters( "manage_taxonomies_for_{$post_type}_columns", $taxonomies, $post_type ); |
363 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
557 $taxonomies = array_filter( $taxonomies, 'taxonomy_exists' ); |
364 |
558 |
365 foreach ( $taxonomies as $taxonomy ) { |
559 foreach ( $taxonomies as $taxonomy ) { |
366 if ( 'category' == $taxonomy ) |
560 if ( 'category' === $taxonomy ) |
367 $column_key = 'categories'; |
561 $column_key = 'categories'; |
368 elseif ( 'post_tag' == $taxonomy ) |
562 elseif ( 'post_tag' === $taxonomy ) |
369 $column_key = 'tags'; |
563 $column_key = 'tags'; |
370 else |
564 else |
371 $column_key = 'taxonomy-' . $taxonomy; |
565 $column_key = 'taxonomy-' . $taxonomy; |
372 |
566 |
373 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
567 $posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name; |
377 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
571 if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) |
378 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
572 $posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>'; |
379 |
573 |
380 $posts_columns['date'] = __( 'Date' ); |
574 $posts_columns['date'] = __( 'Date' ); |
381 |
575 |
382 if ( 'page' == $post_type ) { |
576 if ( 'page' === $post_type ) { |
383 |
577 |
384 /** |
578 /** |
385 * Filter the columns displayed in the Pages list table. |
579 * Filters the columns displayed in the Pages list table. |
386 * |
580 * |
387 * @since 2.5.0 |
581 * @since 2.5.0 |
388 * |
582 * |
389 * @param array $post_columns An array of column names. |
583 * @param array $post_columns An array of column names. |
390 */ |
584 */ |
391 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
585 $posts_columns = apply_filters( 'manage_pages_columns', $posts_columns ); |
392 } else { |
586 } else { |
393 |
587 |
394 /** |
588 /** |
395 * Filter the columns displayed in the Posts list table. |
589 * Filters the columns displayed in the Posts list table. |
396 * |
590 * |
397 * @since 1.5.0 |
591 * @since 1.5.0 |
398 * |
592 * |
399 * @param array $posts_columns An array of column names. |
593 * @param array $posts_columns An array of column names. |
400 * @param string $post_type The post type slug. |
594 * @param string $post_type The post type slug. |
401 */ |
595 */ |
402 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
596 $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); |
403 } |
597 } |
404 |
598 |
405 /** |
599 /** |
406 * Filter the columns displayed in the Posts list table for a specific post type. |
600 * Filters the columns displayed in the Posts list table for a specific post type. |
407 * |
601 * |
408 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug. |
602 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug. |
409 * |
603 * |
410 * @since 3.0.0 |
604 * @since 3.0.0 |
411 * |
605 * |
412 * @param array $post_columns An array of column names. |
606 * @param array $post_columns An array of column names. |
413 */ |
607 */ |
414 $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
608 return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); |
415 |
609 } |
416 return $posts_columns; |
610 |
417 } |
611 /** |
418 |
612 * |
613 * @return array |
|
614 */ |
|
419 protected function get_sortable_columns() { |
615 protected function get_sortable_columns() { |
420 return array( |
616 return array( |
421 'title' => 'title', |
617 'title' => 'title', |
422 'parent' => 'parent', |
618 'parent' => 'parent', |
423 'comments' => 'comment_count', |
619 'comments' => 'comment_count', |
445 $this->_display_rows( $posts, $level ); |
641 $this->_display_rows( $posts, $level ); |
446 } |
642 } |
447 } |
643 } |
448 |
644 |
449 /** |
645 /** |
450 * @global string $mode |
|
451 * @param array $posts |
646 * @param array $posts |
452 * @param int $level |
647 * @param int $level |
453 */ |
648 */ |
454 private function _display_rows( $posts, $level = 0 ) { |
649 private function _display_rows( $posts, $level = 0 ) { |
455 global $mode; |
|
456 |
|
457 // Create array of post IDs. |
650 // Create array of post IDs. |
458 $post_ids = array(); |
651 $post_ids = array(); |
459 |
652 |
460 foreach ( $posts as $a_post ) |
653 foreach ( $posts as $a_post ) |
461 $post_ids[] = $a_post->ID; |
654 $post_ids[] = $a_post->ID; |
465 foreach ( $posts as $post ) |
658 foreach ( $posts as $post ) |
466 $this->single_row( $post, $level ); |
659 $this->single_row( $post, $level ); |
467 } |
660 } |
468 |
661 |
469 /** |
662 /** |
470 * @global wpdb $wpdb |
663 * @global wpdb $wpdb |
664 * @global WP_Post $post |
|
471 * @param array $pages |
665 * @param array $pages |
472 * @param int $pagenum |
666 * @param int $pagenum |
473 * @param int $per_page |
667 * @param int $per_page |
474 * @return false|null |
|
475 */ |
668 */ |
476 private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
669 private function _display_rows_hierarchical( $pages, $pagenum = 1, $per_page = 20 ) { |
477 global $wpdb; |
670 global $wpdb; |
478 |
671 |
479 $level = 0; |
672 $level = 0; |
480 |
673 |
481 if ( ! $pages ) { |
674 if ( ! $pages ) { |
482 $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
675 $pages = get_pages( array( 'sort_column' => 'menu_order' ) ); |
483 |
676 |
484 if ( ! $pages ) |
677 if ( ! $pages ) |
485 return false; |
678 return; |
486 } |
679 } |
487 |
680 |
488 /* |
681 /* |
489 * Arrange pages into two parts: top level pages and children_pages |
682 * Arrange pages into two parts: top level pages and children_pages |
490 * children_pages is two dimensional array, eg. |
683 * children_pages is two dimensional array, eg. |
577 * @param int $pagenum |
770 * @param int $pagenum |
578 * @param int $per_page |
771 * @param int $per_page |
579 * @param array $to_display List of pages to be displayed. Passed by reference. |
772 * @param array $to_display List of pages to be displayed. Passed by reference. |
580 */ |
773 */ |
581 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
774 private function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page, &$to_display ) { |
582 |
|
583 if ( ! isset( $children_pages[$parent] ) ) |
775 if ( ! isset( $children_pages[$parent] ) ) |
584 return; |
776 return; |
585 |
777 |
586 $start = ( $pagenum - 1 ) * $per_page; |
778 $start = ( $pagenum - 1 ) * $per_page; |
587 $end = $start + $per_page; |
779 $end = $start + $per_page; |
588 |
780 |
589 foreach ( $children_pages[$parent] as $page ) { |
781 foreach ( $children_pages[$parent] as $page ) { |
590 |
|
591 if ( $count >= $end ) |
782 if ( $count >= $end ) |
592 break; |
783 break; |
593 |
784 |
594 // If the page starts in a subtree, print the parents. |
785 // If the page starts in a subtree, print the parents. |
595 if ( $count == $start && $page->post_parent > 0 ) { |
786 if ( $count == $start && $page->post_parent > 0 ) { |
626 |
817 |
627 unset( $children_pages[$parent] ); //required in order to keep track of orphans |
818 unset( $children_pages[$parent] ); //required in order to keep track of orphans |
628 } |
819 } |
629 |
820 |
630 /** |
821 /** |
631 * @global string $mode |
822 * Handles the checkbox column output. |
823 * |
|
824 * @since 4.3.0 |
|
825 * |
|
826 * @param WP_Post $post The current WP_Post object. |
|
827 */ |
|
828 public function column_cb( $post ) { |
|
829 if ( current_user_can( 'edit_post', $post->ID ) ): ?> |
|
830 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php |
|
831 printf( __( 'Select %s' ), _draft_or_post_title() ); |
|
832 ?></label> |
|
833 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
|
834 <div class="locked-indicator"> |
|
835 <span class="locked-indicator-icon" aria-hidden="true"></span> |
|
836 <span class="screen-reader-text"><?php |
|
837 printf( |
|
838 /* translators: %s: post title */ |
|
839 __( '“%s” is locked' ), |
|
840 _draft_or_post_title() |
|
841 ); |
|
842 ?></span> |
|
843 </div> |
|
844 <?php endif; |
|
845 } |
|
846 |
|
847 /** |
|
848 * @since 4.3.0 |
|
849 * |
|
632 * @param WP_Post $post |
850 * @param WP_Post $post |
633 * @param int $level |
851 * @param string $classes |
852 * @param string $data |
|
853 * @param string $primary |
|
854 */ |
|
855 protected function _column_title( $post, $classes, $data, $primary ) { |
|
856 echo '<td class="' . $classes . ' page-title" ', $data, '>'; |
|
857 echo $this->column_title( $post ); |
|
858 echo $this->handle_row_actions( $post, 'title', $primary ); |
|
859 echo '</td>'; |
|
860 } |
|
861 |
|
862 /** |
|
863 * Handles the title column output. |
|
864 * |
|
865 * @since 4.3.0 |
|
866 * |
|
867 * @global string $mode List table view mode. |
|
868 * |
|
869 * @param WP_Post $post The current WP_Post object. |
|
870 */ |
|
871 public function column_title( $post ) { |
|
872 global $mode; |
|
873 |
|
874 if ( $this->hierarchical_display ) { |
|
875 if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) { |
|
876 // Sent level 0 by accident, by default, or because we don't know the actual level. |
|
877 $find_main_page = (int) $post->post_parent; |
|
878 while ( $find_main_page > 0 ) { |
|
879 $parent = get_post( $find_main_page ); |
|
880 |
|
881 if ( is_null( $parent ) ) { |
|
882 break; |
|
883 } |
|
884 |
|
885 $this->current_level++; |
|
886 $find_main_page = (int) $parent->post_parent; |
|
887 |
|
888 if ( ! isset( $parent_name ) ) { |
|
889 /** This filter is documented in wp-includes/post-template.php */ |
|
890 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
|
891 } |
|
892 } |
|
893 } |
|
894 } |
|
895 |
|
896 $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
897 |
|
898 if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
899 $lock_holder = wp_check_post_lock( $post->ID ); |
|
900 |
|
901 if ( $lock_holder ) { |
|
902 $lock_holder = get_userdata( $lock_holder ); |
|
903 $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
|
904 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
905 } else { |
|
906 $locked_avatar = $locked_text = ''; |
|
907 } |
|
908 |
|
909 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
|
910 } |
|
911 |
|
912 $pad = str_repeat( '— ', $this->current_level ); |
|
913 echo "<strong>"; |
|
914 |
|
915 $format = get_post_format( $post->ID ); |
|
916 if ( $format ) { |
|
917 $label = get_post_format_string( $format ); |
|
918 |
|
919 $format_class = 'post-state-format post-format-icon post-format-' . $format; |
|
920 |
|
921 $format_args = array( |
|
922 'post_format' => $format, |
|
923 'post_type' => $post->post_type |
|
924 ); |
|
925 |
|
926 echo $this->get_edit_link( $format_args, $label . ':', $format_class ); |
|
927 } |
|
928 |
|
929 $title = _draft_or_post_title(); |
|
930 |
|
931 if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
932 printf( |
|
933 '<a class="row-title" href="%s" aria-label="%s">%s%s</a>', |
|
934 get_edit_post_link( $post->ID ), |
|
935 /* translators: %s: post title */ |
|
936 esc_attr( sprintf( __( '“%s” (Edit)' ), $title ) ), |
|
937 $pad, |
|
938 $title |
|
939 ); |
|
940 } else { |
|
941 echo $pad . $title; |
|
942 } |
|
943 _post_states( $post ); |
|
944 |
|
945 if ( isset( $parent_name ) ) { |
|
946 $post_type_object = get_post_type_object( $post->post_type ); |
|
947 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
|
948 } |
|
949 echo "</strong>\n"; |
|
950 |
|
951 if ( ! is_post_type_hierarchical( $this->screen->post_type ) && 'excerpt' === $mode && current_user_can( 'read_post', $post->ID ) ) { |
|
952 if ( post_password_required( $post ) ) { |
|
953 echo '<span class="protected-post-excerpt">' . esc_html( get_the_excerpt() ) . '</span>'; |
|
954 } else { |
|
955 echo esc_html( get_the_excerpt() ); |
|
956 } |
|
957 } |
|
958 |
|
959 get_inline_data( $post ); |
|
960 } |
|
961 |
|
962 /** |
|
963 * Handles the post date column output. |
|
964 * |
|
965 * @since 4.3.0 |
|
966 * |
|
967 * @global string $mode List table view mode. |
|
968 * |
|
969 * @param WP_Post $post The current WP_Post object. |
|
970 */ |
|
971 public function column_date( $post ) { |
|
972 global $mode; |
|
973 |
|
974 if ( '0000-00-00 00:00:00' === $post->post_date ) { |
|
975 $t_time = $h_time = __( 'Unpublished' ); |
|
976 $time_diff = 0; |
|
977 } else { |
|
978 $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
979 $m_time = $post->post_date; |
|
980 $time = get_post_time( 'G', true, $post ); |
|
981 |
|
982 $time_diff = time() - $time; |
|
983 |
|
984 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) { |
|
985 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
986 } else { |
|
987 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
988 } |
|
989 } |
|
990 |
|
991 if ( 'publish' === $post->post_status ) { |
|
992 $status = __( 'Published' ); |
|
993 } elseif ( 'future' === $post->post_status ) { |
|
994 if ( $time_diff > 0 ) { |
|
995 $status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>'; |
|
996 } else { |
|
997 $status = __( 'Scheduled' ); |
|
998 } |
|
999 } else { |
|
1000 $status = __( 'Last Modified' ); |
|
1001 } |
|
1002 |
|
1003 /** |
|
1004 * Filters the status text of the post. |
|
1005 * |
|
1006 * @since 4.8.0 |
|
1007 * |
|
1008 * @param string $status The status text. |
|
1009 * @param WP_Post $post Post object. |
|
1010 * @param string $column_name The column name. |
|
1011 * @param string $mode The list display mode ('excerpt' or 'list'). |
|
1012 */ |
|
1013 $status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode ); |
|
1014 |
|
1015 if ( $status ) { |
|
1016 echo $status . '<br />'; |
|
1017 } |
|
1018 |
|
1019 if ( 'excerpt' === $mode ) { |
|
1020 /** |
|
1021 * Filters the published time of the post. |
|
1022 * |
|
1023 * If `$mode` equals 'excerpt', the published time and date are both displayed. |
|
1024 * If `$mode` equals 'list' (default), the publish date is displayed, with the |
|
1025 * time and date together available as an abbreviation definition. |
|
1026 * |
|
1027 * @since 2.5.1 |
|
1028 * |
|
1029 * @param string $t_time The published time. |
|
1030 * @param WP_Post $post Post object. |
|
1031 * @param string $column_name The column name. |
|
1032 * @param string $mode The list display mode ('excerpt' or 'list'). |
|
1033 */ |
|
1034 echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
|
1035 } else { |
|
1036 |
|
1037 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
|
1038 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>'; |
|
1039 } |
|
1040 } |
|
1041 |
|
1042 /** |
|
1043 * Handles the comments column output. |
|
1044 * |
|
1045 * @since 4.3.0 |
|
1046 * |
|
1047 * @param WP_Post $post The current WP_Post object. |
|
1048 */ |
|
1049 public function column_comments( $post ) { |
|
1050 ?> |
|
1051 <div class="post-com-count-wrapper"> |
|
1052 <?php |
|
1053 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
|
1054 |
|
1055 $this->comments_bubble( $post->ID, $pending_comments ); |
|
1056 ?> |
|
1057 </div> |
|
1058 <?php |
|
1059 } |
|
1060 |
|
1061 /** |
|
1062 * Handles the post author column output. |
|
1063 * |
|
1064 * @since 4.3.0 |
|
1065 * |
|
1066 * @param WP_Post $post The current WP_Post object. |
|
1067 */ |
|
1068 public function column_author( $post ) { |
|
1069 $args = array( |
|
1070 'post_type' => $post->post_type, |
|
1071 'author' => get_the_author_meta( 'ID' ) |
|
1072 ); |
|
1073 echo $this->get_edit_link( $args, get_the_author() ); |
|
1074 } |
|
1075 |
|
1076 /** |
|
1077 * Handles the default column output. |
|
1078 * |
|
1079 * @since 4.3.0 |
|
1080 * |
|
1081 * @param WP_Post $post The current WP_Post object. |
|
1082 * @param string $column_name The current column name. |
|
1083 */ |
|
1084 public function column_default( $post, $column_name ) { |
|
1085 if ( 'categories' === $column_name ) { |
|
1086 $taxonomy = 'category'; |
|
1087 } elseif ( 'tags' === $column_name ) { |
|
1088 $taxonomy = 'post_tag'; |
|
1089 } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
|
1090 $taxonomy = substr( $column_name, 9 ); |
|
1091 } else { |
|
1092 $taxonomy = false; |
|
1093 } |
|
1094 if ( $taxonomy ) { |
|
1095 $taxonomy_object = get_taxonomy( $taxonomy ); |
|
1096 $terms = get_the_terms( $post->ID, $taxonomy ); |
|
1097 if ( is_array( $terms ) ) { |
|
1098 $out = array(); |
|
1099 foreach ( $terms as $t ) { |
|
1100 $posts_in_term_qv = array(); |
|
1101 if ( 'post' != $post->post_type ) { |
|
1102 $posts_in_term_qv['post_type'] = $post->post_type; |
|
1103 } |
|
1104 if ( $taxonomy_object->query_var ) { |
|
1105 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
1106 } else { |
|
1107 $posts_in_term_qv['taxonomy'] = $taxonomy; |
|
1108 $posts_in_term_qv['term'] = $t->slug; |
|
1109 } |
|
1110 |
|
1111 $label = esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ); |
|
1112 $out[] = $this->get_edit_link( $posts_in_term_qv, $label ); |
|
1113 } |
|
1114 /* translators: used between list items, there is a space after the comma */ |
|
1115 echo join( __( ', ' ), $out ); |
|
1116 } else { |
|
1117 echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>'; |
|
1118 } |
|
1119 return; |
|
1120 } |
|
1121 |
|
1122 if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
1123 |
|
1124 /** |
|
1125 * Fires in each custom column on the Posts list table. |
|
1126 * |
|
1127 * This hook only fires if the current post type is hierarchical, |
|
1128 * such as pages. |
|
1129 * |
|
1130 * @since 2.5.0 |
|
1131 * |
|
1132 * @param string $column_name The name of the column to display. |
|
1133 * @param int $post_id The current post ID. |
|
1134 */ |
|
1135 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
|
1136 } else { |
|
1137 |
|
1138 /** |
|
1139 * Fires in each custom column in the Posts list table. |
|
1140 * |
|
1141 * This hook only fires if the current post type is non-hierarchical, |
|
1142 * such as posts. |
|
1143 * |
|
1144 * @since 1.5.0 |
|
1145 * |
|
1146 * @param string $column_name The name of the column to display. |
|
1147 * @param int $post_id The current post ID. |
|
1148 */ |
|
1149 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
|
1150 } |
|
1151 |
|
1152 /** |
|
1153 * Fires for each custom column of a specific post type in the Posts list table. |
|
1154 * |
|
1155 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
|
1156 * |
|
1157 * @since 3.1.0 |
|
1158 * |
|
1159 * @param string $column_name The name of the column to display. |
|
1160 * @param int $post_id The current post ID. |
|
1161 */ |
|
1162 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
|
1163 } |
|
1164 |
|
1165 /** |
|
1166 * @global WP_Post $post |
|
1167 * |
|
1168 * @param int|WP_Post $post |
|
1169 * @param int $level |
|
634 */ |
1170 */ |
635 public function single_row( $post, $level = 0 ) { |
1171 public function single_row( $post, $level = 0 ) { |
636 global $mode; |
|
637 |
|
638 $global_post = get_post(); |
1172 $global_post = get_post(); |
639 |
1173 |
640 $post = get_post( $post ); |
1174 $post = get_post( $post ); |
1175 $this->current_level = $level; |
|
641 |
1176 |
642 $GLOBALS['post'] = $post; |
1177 $GLOBALS['post'] = $post; |
643 setup_postdata( $post ); |
1178 setup_postdata( $post ); |
644 |
|
645 $edit_link = get_edit_post_link( $post->ID ); |
|
646 $title = _draft_or_post_title(); |
|
647 $post_type_object = get_post_type_object( $post->post_type ); |
|
648 $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
649 |
1179 |
650 $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); |
1180 $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); |
651 |
1181 |
652 $lock_holder = wp_check_post_lock( $post->ID ); |
1182 $lock_holder = wp_check_post_lock( $post->ID ); |
653 if ( $lock_holder ) { |
1183 if ( $lock_holder ) { |
654 $classes .= ' wp-locked'; |
1184 $classes .= ' wp-locked'; |
655 $lock_holder = get_userdata( $lock_holder ); |
|
656 } |
1185 } |
657 |
1186 |
658 if ( $post->post_parent ) { |
1187 if ( $post->post_parent ) { |
659 $count = count( get_post_ancestors( $post->ID ) ); |
1188 $count = count( get_post_ancestors( $post->ID ) ); |
660 $classes .= ' level-'. $count; |
1189 $classes .= ' level-'. $count; |
661 } else { |
1190 } else { |
662 $classes .= ' level-0'; |
1191 $classes .= ' level-0'; |
663 } |
1192 } |
664 ?> |
1193 ?> |
665 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
1194 <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>"> |
666 <?php |
1195 <?php $this->single_row_columns( $post ); ?> |
667 |
|
668 list( $columns, $hidden ) = $this->get_column_info(); |
|
669 |
|
670 foreach ( $columns as $column_name => $column_display_name ) { |
|
671 $class = "class=\"$column_name column-$column_name\""; |
|
672 |
|
673 $style = ''; |
|
674 if ( in_array( $column_name, $hidden ) ) |
|
675 $style = ' style="display:none;"'; |
|
676 |
|
677 $attributes = "$class$style"; |
|
678 |
|
679 switch ( $column_name ) { |
|
680 |
|
681 case 'cb': |
|
682 ?> |
|
683 <th scope="row" class="check-column"> |
|
684 <?php |
|
685 if ( $can_edit_post ) { |
|
686 |
|
687 ?> |
|
688 <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label> |
|
689 <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
|
690 <div class="locked-indicator"></div> |
|
691 <?php |
|
692 } |
|
693 ?> |
|
694 </th> |
|
695 <?php |
|
696 break; |
|
697 |
|
698 case 'title': |
|
699 $attributes = 'class="post-title page-title column-title"' . $style; |
|
700 if ( $this->hierarchical_display ) { |
|
701 if ( 0 == $level && (int) $post->post_parent > 0 ) { |
|
702 // Sent level 0 by accident, by default, or because we don't know the actual level. |
|
703 $find_main_page = (int) $post->post_parent; |
|
704 while ( $find_main_page > 0 ) { |
|
705 $parent = get_post( $find_main_page ); |
|
706 |
|
707 if ( is_null( $parent ) ) |
|
708 break; |
|
709 |
|
710 $level++; |
|
711 $find_main_page = (int) $parent->post_parent; |
|
712 |
|
713 if ( !isset( $parent_name ) ) { |
|
714 /** This filter is documented in wp-includes/post-template.php */ |
|
715 $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
|
716 } |
|
717 } |
|
718 } |
|
719 } |
|
720 |
|
721 $pad = str_repeat( '— ', $level ); |
|
722 echo "<td $attributes><strong>"; |
|
723 |
|
724 if ( $format = get_post_format( $post->ID ) ) { |
|
725 $label = get_post_format_string( $format ); |
|
726 |
|
727 echo '<a href="' . esc_url( add_query_arg( array( 'post_format' => $format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> "; |
|
728 } |
|
729 |
|
730 if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
731 echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>'; |
|
732 } else { |
|
733 echo $pad . $title; |
|
734 } |
|
735 _post_states( $post ); |
|
736 |
|
737 if ( isset( $parent_name ) ) |
|
738 echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
|
739 |
|
740 echo "</strong>\n"; |
|
741 |
|
742 if ( $can_edit_post && $post->post_status != 'trash' ) { |
|
743 if ( $lock_holder ) { |
|
744 $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
|
745 $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
|
746 } else { |
|
747 $locked_avatar = $locked_text = ''; |
|
748 } |
|
749 |
|
750 echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n"; |
|
751 } |
|
752 |
|
753 if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) |
|
754 the_excerpt(); |
|
755 |
|
756 $actions = array(); |
|
757 if ( $can_edit_post && 'trash' != $post->post_status ) { |
|
758 $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID ) . '" title="' . esc_attr__( 'Edit this item' ) . '">' . __( 'Edit' ) . '</a>'; |
|
759 $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr__( 'Edit this item inline' ) . '">' . __( 'Quick Edit' ) . '</a>'; |
|
760 } |
|
761 if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
762 if ( 'trash' == $post->post_status ) |
|
763 $actions['untrash'] = "<a title='" . esc_attr__( 'Restore this item from the Trash' ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>"; |
|
764 elseif ( EMPTY_TRASH_DAYS ) |
|
765 $actions['trash'] = "<a class='submitdelete' title='" . esc_attr__( 'Move this item to the Trash' ) . "' href='" . get_delete_post_link( $post->ID ) . "'>" . __( 'Trash' ) . "</a>"; |
|
766 if ( 'trash' == $post->post_status || !EMPTY_TRASH_DAYS ) |
|
767 $actions['delete'] = "<a class='submitdelete' title='" . esc_attr__( 'Delete this item permanently' ) . "' href='" . get_delete_post_link( $post->ID, '', true ) . "'>" . __( 'Delete Permanently' ) . "</a>"; |
|
768 } |
|
769 if ( $post_type_object->public ) { |
|
770 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
771 if ( $can_edit_post ) { |
|
772 $preview_link = set_url_scheme( get_permalink( $post->ID ) ); |
|
773 /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
|
774 $preview_link = apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ), $post ); |
|
775 $actions['view'] = '<a href="' . esc_url( $preview_link ) . '" title="' . esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>'; |
|
776 } |
|
777 } elseif ( 'trash' != $post->post_status ) { |
|
778 $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View “%s”' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>'; |
|
779 } |
|
780 } |
|
781 |
|
782 if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
783 |
|
784 /** |
|
785 * Filter the array of row action links on the Pages list table. |
|
786 * |
|
787 * The filter is evaluated only for hierarchical post types. |
|
788 * |
|
789 * @since 2.8.0 |
|
790 * |
|
791 * @param array $actions An array of row action links. Defaults are |
|
792 * 'Edit', 'Quick Edit', 'Restore, 'Trash', |
|
793 * 'Delete Permanently', 'Preview', and 'View'. |
|
794 * @param WP_Post $post The post object. |
|
795 */ |
|
796 $actions = apply_filters( 'page_row_actions', $actions, $post ); |
|
797 } else { |
|
798 |
|
799 /** |
|
800 * Filter the array of row action links on the Posts list table. |
|
801 * |
|
802 * The filter is evaluated only for non-hierarchical post types. |
|
803 * |
|
804 * @since 2.8.0 |
|
805 * |
|
806 * @param array $actions An array of row action links. Defaults are |
|
807 * 'Edit', 'Quick Edit', 'Restore, 'Trash', |
|
808 * 'Delete Permanently', 'Preview', and 'View'. |
|
809 * @param WP_Post $post The post object. |
|
810 */ |
|
811 $actions = apply_filters( 'post_row_actions', $actions, $post ); |
|
812 } |
|
813 |
|
814 echo $this->row_actions( $actions ); |
|
815 |
|
816 get_inline_data( $post ); |
|
817 echo '</td>'; |
|
818 break; |
|
819 |
|
820 case 'date': |
|
821 if ( '0000-00-00 00:00:00' == $post->post_date ) { |
|
822 $t_time = $h_time = __( 'Unpublished' ); |
|
823 $time_diff = 0; |
|
824 } else { |
|
825 $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
|
826 $m_time = $post->post_date; |
|
827 $time = get_post_time( 'G', true, $post ); |
|
828 |
|
829 $time_diff = time() - $time; |
|
830 |
|
831 if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) |
|
832 $h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) ); |
|
833 else |
|
834 $h_time = mysql2date( __( 'Y/m/d' ), $m_time ); |
|
835 } |
|
836 |
|
837 echo '<td ' . $attributes . '>'; |
|
838 if ( 'excerpt' == $mode ) { |
|
839 |
|
840 /** |
|
841 * Filter the published time of the post. |
|
842 * |
|
843 * If $mode equals 'excerpt', the published time and date are both displayed. |
|
844 * If $mode equals 'list' (default), the publish date is displayed, with the |
|
845 * time and date together available as an abbreviation definition. |
|
846 * |
|
847 * @since 2.5.1 |
|
848 * |
|
849 * @param array $t_time The published time. |
|
850 * @param WP_Post $post Post object. |
|
851 * @param string $column_name The column name. |
|
852 * @param string $mode The list display mode ('excerpt' or 'list'). |
|
853 */ |
|
854 echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode ); |
|
855 } else { |
|
856 |
|
857 /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
|
858 echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>'; |
|
859 } |
|
860 echo '<br />'; |
|
861 if ( 'publish' == $post->post_status ) { |
|
862 _e( 'Published' ); |
|
863 } elseif ( 'future' == $post->post_status ) { |
|
864 if ( $time_diff > 0 ) |
|
865 echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>'; |
|
866 else |
|
867 _e( 'Scheduled' ); |
|
868 } else { |
|
869 _e( 'Last Modified' ); |
|
870 } |
|
871 echo '</td>'; |
|
872 break; |
|
873 |
|
874 case 'comments': |
|
875 ?> |
|
876 <td <?php echo $attributes ?>><div class="post-com-count-wrapper"> |
|
877 <?php |
|
878 $pending_comments = isset( $this->comment_pending_count[$post->ID] ) ? $this->comment_pending_count[$post->ID] : 0; |
|
879 |
|
880 $this->comments_bubble( $post->ID, $pending_comments ); |
|
881 ?> |
|
882 </div></td> |
|
883 <?php |
|
884 break; |
|
885 |
|
886 case 'author': |
|
887 ?> |
|
888 <td <?php echo $attributes ?>><?php |
|
889 printf( '<a href="%s">%s</a>', |
|
890 esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )), |
|
891 get_the_author() |
|
892 ); |
|
893 ?></td> |
|
894 <?php |
|
895 break; |
|
896 |
|
897 default: |
|
898 if ( 'categories' == $column_name ) |
|
899 $taxonomy = 'category'; |
|
900 elseif ( 'tags' == $column_name ) |
|
901 $taxonomy = 'post_tag'; |
|
902 elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) |
|
903 $taxonomy = substr( $column_name, 9 ); |
|
904 else |
|
905 $taxonomy = false; |
|
906 |
|
907 if ( $taxonomy ) { |
|
908 $taxonomy_object = get_taxonomy( $taxonomy ); |
|
909 echo '<td ' . $attributes . '>'; |
|
910 if ( $terms = get_the_terms( $post->ID, $taxonomy ) ) { |
|
911 $out = array(); |
|
912 foreach ( $terms as $t ) { |
|
913 $posts_in_term_qv = array(); |
|
914 if ( 'post' != $post->post_type ) |
|
915 $posts_in_term_qv['post_type'] = $post->post_type; |
|
916 if ( $taxonomy_object->query_var ) { |
|
917 $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
|
918 } else { |
|
919 $posts_in_term_qv['taxonomy'] = $taxonomy; |
|
920 $posts_in_term_qv['term'] = $t->slug; |
|
921 } |
|
922 |
|
923 $out[] = sprintf( '<a href="%s">%s</a>', |
|
924 esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
|
925 esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
|
926 ); |
|
927 } |
|
928 /* translators: used between list items, there is a space after the comma */ |
|
929 echo join( __( ', ' ), $out ); |
|
930 } else { |
|
931 echo '—'; |
|
932 } |
|
933 echo '</td>'; |
|
934 break; |
|
935 } |
|
936 ?> |
|
937 <td <?php echo $attributes ?>><?php |
|
938 if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
939 |
|
940 /** |
|
941 * Fires in each custom column on the Posts list table. |
|
942 * |
|
943 * This hook only fires if the current post type is hierarchical, |
|
944 * such as pages. |
|
945 * |
|
946 * @since 2.5.0 |
|
947 * |
|
948 * @param string $column_name The name of the column to display. |
|
949 * @param int $post_id The current post ID. |
|
950 */ |
|
951 do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
|
952 } else { |
|
953 |
|
954 /** |
|
955 * Fires in each custom column in the Posts list table. |
|
956 * |
|
957 * This hook only fires if the current post type is non-hierarchical, |
|
958 * such as posts. |
|
959 * |
|
960 * @since 1.5.0 |
|
961 * |
|
962 * @param string $column_name The name of the column to display. |
|
963 * @param int $post_id The current post ID. |
|
964 */ |
|
965 do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
|
966 } |
|
967 |
|
968 /** |
|
969 * Fires for each custom column of a specific post type in the Posts list table. |
|
970 * |
|
971 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
|
972 * |
|
973 * @since 3.1.0 |
|
974 * |
|
975 * @param string $column_name The name of the column to display. |
|
976 * @param int $post_id The current post ID. |
|
977 */ |
|
978 do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
|
979 ?></td> |
|
980 <?php |
|
981 break; |
|
982 } |
|
983 } |
|
984 ?> |
|
985 </tr> |
1196 </tr> |
986 <?php |
1197 <?php |
987 $GLOBALS['post'] = $global_post; |
1198 $GLOBALS['post'] = $global_post; |
988 } |
1199 } |
989 |
1200 |
990 /** |
1201 /** |
1202 * Gets the name of the default primary column. |
|
1203 * |
|
1204 * @since 4.3.0 |
|
1205 * |
|
1206 * @return string Name of the default primary column, in this case, 'title'. |
|
1207 */ |
|
1208 protected function get_default_primary_column_name() { |
|
1209 return 'title'; |
|
1210 } |
|
1211 |
|
1212 /** |
|
1213 * Generates and displays row action links. |
|
1214 * |
|
1215 * @since 4.3.0 |
|
1216 * |
|
1217 * @param object $post Post being acted upon. |
|
1218 * @param string $column_name Current column name. |
|
1219 * @param string $primary Primary column name. |
|
1220 * @return string Row actions output for posts. |
|
1221 */ |
|
1222 protected function handle_row_actions( $post, $column_name, $primary ) { |
|
1223 if ( $primary !== $column_name ) { |
|
1224 return ''; |
|
1225 } |
|
1226 |
|
1227 $post_type_object = get_post_type_object( $post->post_type ); |
|
1228 $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
|
1229 $actions = array(); |
|
1230 $title = _draft_or_post_title(); |
|
1231 |
|
1232 if ( $can_edit_post && 'trash' != $post->post_status ) { |
|
1233 $actions['edit'] = sprintf( |
|
1234 '<a href="%s" aria-label="%s">%s</a>', |
|
1235 get_edit_post_link( $post->ID ), |
|
1236 /* translators: %s: post title */ |
|
1237 esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ), |
|
1238 __( 'Edit' ) |
|
1239 ); |
|
1240 $actions['inline hide-if-no-js'] = sprintf( |
|
1241 '<a href="#" class="editinline" aria-label="%s">%s</a>', |
|
1242 /* translators: %s: post title */ |
|
1243 esc_attr( sprintf( __( 'Quick edit “%s” inline' ), $title ) ), |
|
1244 __( 'Quick Edit' ) |
|
1245 ); |
|
1246 } |
|
1247 |
|
1248 if ( current_user_can( 'delete_post', $post->ID ) ) { |
|
1249 if ( 'trash' === $post->post_status ) { |
|
1250 $actions['untrash'] = sprintf( |
|
1251 '<a href="%s" aria-label="%s">%s</a>', |
|
1252 wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ), |
|
1253 /* translators: %s: post title */ |
|
1254 esc_attr( sprintf( __( 'Restore “%s” from the Trash' ), $title ) ), |
|
1255 __( 'Restore' ) |
|
1256 ); |
|
1257 } elseif ( EMPTY_TRASH_DAYS ) { |
|
1258 $actions['trash'] = sprintf( |
|
1259 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
|
1260 get_delete_post_link( $post->ID ), |
|
1261 /* translators: %s: post title */ |
|
1262 esc_attr( sprintf( __( 'Move “%s” to the Trash' ), $title ) ), |
|
1263 _x( 'Trash', 'verb' ) |
|
1264 ); |
|
1265 } |
|
1266 if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) { |
|
1267 $actions['delete'] = sprintf( |
|
1268 '<a href="%s" class="submitdelete" aria-label="%s">%s</a>', |
|
1269 get_delete_post_link( $post->ID, '', true ), |
|
1270 /* translators: %s: post title */ |
|
1271 esc_attr( sprintf( __( 'Delete “%s” permanently' ), $title ) ), |
|
1272 __( 'Delete Permanently' ) |
|
1273 ); |
|
1274 } |
|
1275 } |
|
1276 |
|
1277 if ( is_post_type_viewable( $post_type_object ) ) { |
|
1278 if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) { |
|
1279 if ( $can_edit_post ) { |
|
1280 $preview_link = get_preview_post_link( $post ); |
|
1281 $actions['view'] = sprintf( |
|
1282 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
|
1283 esc_url( $preview_link ), |
|
1284 /* translators: %s: post title */ |
|
1285 esc_attr( sprintf( __( 'Preview “%s”' ), $title ) ), |
|
1286 __( 'Preview' ) |
|
1287 ); |
|
1288 } |
|
1289 } elseif ( 'trash' != $post->post_status ) { |
|
1290 $actions['view'] = sprintf( |
|
1291 '<a href="%s" rel="bookmark" aria-label="%s">%s</a>', |
|
1292 get_permalink( $post->ID ), |
|
1293 /* translators: %s: post title */ |
|
1294 esc_attr( sprintf( __( 'View “%s”' ), $title ) ), |
|
1295 __( 'View' ) |
|
1296 ); |
|
1297 } |
|
1298 } |
|
1299 |
|
1300 if ( is_post_type_hierarchical( $post->post_type ) ) { |
|
1301 |
|
1302 /** |
|
1303 * Filters the array of row action links on the Pages list table. |
|
1304 * |
|
1305 * The filter is evaluated only for hierarchical post types. |
|
1306 * |
|
1307 * @since 2.8.0 |
|
1308 * |
|
1309 * @param array $actions An array of row action links. Defaults are |
|
1310 * 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1311 * 'Delete Permanently', 'Preview', and 'View'. |
|
1312 * @param WP_Post $post The post object. |
|
1313 */ |
|
1314 $actions = apply_filters( 'page_row_actions', $actions, $post ); |
|
1315 } else { |
|
1316 |
|
1317 /** |
|
1318 * Filters the array of row action links on the Posts list table. |
|
1319 * |
|
1320 * The filter is evaluated only for non-hierarchical post types. |
|
1321 * |
|
1322 * @since 2.8.0 |
|
1323 * |
|
1324 * @param array $actions An array of row action links. Defaults are |
|
1325 * 'Edit', 'Quick Edit', 'Restore', 'Trash', |
|
1326 * 'Delete Permanently', 'Preview', and 'View'. |
|
1327 * @param WP_Post $post The post object. |
|
1328 */ |
|
1329 $actions = apply_filters( 'post_row_actions', $actions, $post ); |
|
1330 } |
|
1331 |
|
1332 return $this->row_actions( $actions ); |
|
1333 } |
|
1334 |
|
1335 /** |
|
991 * Outputs the hidden row displayed when inline editing |
1336 * Outputs the hidden row displayed when inline editing |
992 * |
1337 * |
993 * @since 3.1.0 |
1338 * @since 3.1.0 |
1339 * |
|
1340 * @global string $mode List table view mode. |
|
994 */ |
1341 */ |
995 public function inline_edit() { |
1342 public function inline_edit() { |
996 global $mode; |
1343 global $mode; |
997 |
1344 |
998 $screen = $this->screen; |
1345 $screen = $this->screen; |
1008 $taxonomy = get_taxonomy( $taxonomy_name ); |
1355 $taxonomy = get_taxonomy( $taxonomy_name ); |
1009 |
1356 |
1010 $show_in_quick_edit = $taxonomy->show_in_quick_edit; |
1357 $show_in_quick_edit = $taxonomy->show_in_quick_edit; |
1011 |
1358 |
1012 /** |
1359 /** |
1013 * Filter whether the current taxonomy should be shown in the Quick Edit panel. |
1360 * Filters whether the current taxonomy should be shown in the Quick Edit panel. |
1014 * |
1361 * |
1015 * @since 4.2.0 |
1362 * @since 4.2.0 |
1016 * |
1363 * |
1017 * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. |
1364 * @param bool $show_in_quick_edit Whether to show the current taxonomy in Quick Edit. |
1018 * @param string $taxonomy_name Taxonomy name. |
1365 * @param string $taxonomy_name Taxonomy name. |
1026 $hierarchical_taxonomies[] = $taxonomy; |
1373 $hierarchical_taxonomies[] = $taxonomy; |
1027 else |
1374 else |
1028 $flat_taxonomies[] = $taxonomy; |
1375 $flat_taxonomies[] = $taxonomy; |
1029 } |
1376 } |
1030 |
1377 |
1031 $m = ( isset( $mode ) && 'excerpt' == $mode ) ? 'excerpt' : 'list'; |
1378 $m = ( isset( $mode ) && 'excerpt' === $mode ) ? 'excerpt' : 'list'; |
1032 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
1379 $can_publish = current_user_can( $post_type_object->cap->publish_posts ); |
1033 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); |
1380 $core_columns = array( 'cb' => true, 'date' => true, 'title' => true, 'categories' => true, 'tags' => true, 'comments' => true, 'author' => true ); |
1034 |
1381 |
1035 ?> |
1382 ?> |
1036 |
1383 |
1037 <form method="get"><table style="display: none"><tbody id="inlineedit"> |
1384 <form method="get"><table style="display: none"><tbody id="inlineedit"> |
1038 <?php |
1385 <?php |
1039 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
1386 $hclass = count( $hierarchical_taxonomies ) ? 'post' : 'page'; |
1387 $inline_edit_classes = "inline-edit-row inline-edit-row-$hclass"; |
|
1388 $bulk_edit_classes = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}"; |
|
1389 $quick_edit_classes = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
|
1390 |
|
1040 $bulk = 0; |
1391 $bulk = 0; |
1041 while ( $bulk < 2 ) { ?> |
1392 while ( $bulk < 2 ) { ?> |
1042 |
1393 |
1043 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="inline-edit-row inline-edit-row-<?php echo "$hclass inline-edit-" . $screen->post_type; |
1394 <tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $inline_edit_classes . ' '; |
1044 echo $bulk ? " bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}" : " quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}"; |
1395 echo $bulk ? $bulk_edit_classes : $quick_edit_classes; |
1045 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
1396 ?>" style="display: none"><td colspan="<?php echo $this->get_column_count(); ?>" class="colspanchange"> |
1046 |
1397 |
1047 <fieldset class="inline-edit-col-left"><div class="inline-edit-col"> |
1398 <fieldset class="inline-edit-col-left"> |
1048 <h4><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></h4> |
1399 <legend class="inline-edit-legend"><?php echo $bulk ? __( 'Bulk Edit' ) : __( 'Quick Edit' ); ?></legend> |
1400 <div class="inline-edit-col"> |
|
1049 <?php |
1401 <?php |
1050 |
1402 |
1051 if ( post_type_supports( $screen->post_type, 'title' ) ) : |
1403 if ( post_type_supports( $screen->post_type, 'title' ) ) : |
1052 if ( $bulk ) : ?> |
1404 if ( $bulk ) : ?> |
1053 <div id="bulk-title-div"> |
1405 <div id="bulk-title-div"> |
1068 |
1420 |
1069 <?php endif; // $bulk |
1421 <?php endif; // $bulk |
1070 endif; // post_type_supports title ?> |
1422 endif; // post_type_supports title ?> |
1071 |
1423 |
1072 <?php if ( !$bulk ) : ?> |
1424 <?php if ( !$bulk ) : ?> |
1073 <label><span class="title"><?php _e( 'Date' ); ?></span></label> |
1425 <fieldset class="inline-edit-date"> |
1074 <div class="inline-edit-date"> |
1426 <legend><span class="title"><?php _e( 'Date' ); ?></span></legend> |
1075 <?php touch_time( 1, 1, 0, 1 ); ?> |
1427 <?php touch_time( 1, 1, 0, 1 ); ?> |
1076 </div> |
1428 </fieldset> |
1077 <br class="clear" /> |
1429 <br class="clear" /> |
1078 <?php endif; // $bulk |
1430 <?php endif; // $bulk |
1079 |
1431 |
1080 if ( post_type_supports( $screen->post_type, 'author' ) ) : |
1432 if ( post_type_supports( $screen->post_type, 'author' ) ) : |
1081 $authors_dropdown = ''; |
1433 $authors_dropdown = ''; |
1082 |
1434 |
1083 if ( is_super_admin() || current_user_can( $post_type_object->cap->edit_others_posts ) ) : |
1435 if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) : |
1084 $users_opt = array( |
1436 $users_opt = array( |
1085 'hide_if_only_one_author' => false, |
1437 'hide_if_only_one_author' => false, |
1086 'who' => 'authors', |
1438 'who' => 'authors', |
1087 'name' => 'post_author', |
1439 'name' => 'post_author', |
1088 'class'=> 'authors', |
1440 'class'=> 'authors', |
1089 'multi' => 1, |
1441 'multi' => 1, |
1090 'echo' => 0 |
1442 'echo' => 0, |
1443 'show' => 'display_name_with_login', |
|
1091 ); |
1444 ); |
1092 if ( $bulk ) |
1445 if ( $bulk ) |
1093 $users_opt['show_option_none'] = __( '— No Change —' ); |
1446 $users_opt['show_option_none'] = __( '— No Change —' ); |
1094 |
1447 |
1095 if ( $authors = wp_dropdown_users( $users_opt ) ) : |
1448 if ( $authors = wp_dropdown_users( $users_opt ) ) : |
1105 endif; // post_type_supports author |
1458 endif; // post_type_supports author |
1106 |
1459 |
1107 if ( !$bulk && $can_publish ) : |
1460 if ( !$bulk && $can_publish ) : |
1108 ?> |
1461 ?> |
1109 |
1462 |
1110 <div class="inline-edit-group"> |
1463 <div class="inline-edit-group wp-clearfix"> |
1111 <label class="alignleft"> |
1464 <label class="alignleft"> |
1112 <span class="title"><?php _e( 'Password' ); ?></span> |
1465 <span class="title"><?php _e( 'Password' ); ?></span> |
1113 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
1466 <span class="input-text-wrap"><input type="text" name="post_password" class="inline-edit-password-input" value="" /></span> |
1114 </label> |
1467 </label> |
1115 |
1468 |
1116 <em class="alignleft inline-edit-or"> |
1469 <em class="alignleft inline-edit-or"> |
1117 <?php |
1470 <?php |
1118 /* translators: Between password field and private checkbox on post quick edit interface */ |
1471 /* translators: Between password field and private checkbox on post quick edit interface */ |
1119 echo __( '–OR–' ); |
1472 _e( '–OR–' ); |
1120 ?> |
1473 ?> |
1121 </em> |
1474 </em> |
1122 <label class="alignleft inline-edit-private"> |
1475 <label class="alignleft inline-edit-private"> |
1123 <input type="checkbox" name="keep_private" value="private" /> |
1476 <input type="checkbox" name="keep_private" value="private" /> |
1124 <span class="checkbox-title"><?php echo __( 'Private' ); ?></span> |
1477 <span class="checkbox-title"><?php _e( 'Private' ); ?></span> |
1125 </label> |
1478 </label> |
1126 </div> |
1479 </div> |
1127 |
1480 |
1128 <?php endif; ?> |
1481 <?php endif; ?> |
1129 |
1482 |
1134 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> |
1487 <fieldset class="inline-edit-col-center inline-edit-categories"><div class="inline-edit-col"> |
1135 |
1488 |
1136 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
1489 <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?> |
1137 |
1490 |
1138 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
1491 <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
1139 <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
1492 <input type="hidden" name="<?php echo ( $taxonomy->name === 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" /> |
1140 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist"> |
1493 <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist"> |
1141 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?> |
1494 <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?> |
1142 </ul> |
1495 </ul> |
1143 |
1496 |
1144 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> |
1497 <?php endforeach; //$hierarchical_taxonomies as $taxonomy ?> |
1171 |
1524 |
1172 if ( $bulk ) |
1525 if ( $bulk ) |
1173 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
1526 $dropdown_args['show_option_no_change'] = __( '— No Change —' ); |
1174 |
1527 |
1175 /** |
1528 /** |
1176 * Filter the arguments used to generate the Quick Edit page-parent drop-down. |
1529 * Filters the arguments used to generate the Quick Edit page-parent drop-down. |
1177 * |
1530 * |
1178 * @since 2.7.0 |
1531 * @since 2.7.0 |
1179 * |
1532 * |
1180 * @see wp_dropdown_pages() |
1533 * @see wp_dropdown_pages() |
1181 * |
1534 * |
1195 <label> |
1548 <label> |
1196 <span class="title"><?php _e( 'Order' ); ?></span> |
1549 <span class="title"><?php _e( 'Order' ); ?></span> |
1197 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> |
1550 <span class="input-text-wrap"><input type="text" name="menu_order" class="inline-edit-menu-order-input" value="<?php echo $post->menu_order ?>" /></span> |
1198 </label> |
1551 </label> |
1199 |
1552 |
1200 <?php endif; // !$bulk |
|
1201 |
|
1202 if ( 'page' == $screen->post_type ) : |
|
1203 ?> |
|
1204 |
|
1205 <label> |
|
1206 <span class="title"><?php _e( 'Template' ); ?></span> |
|
1207 <select name="page_template"> |
|
1208 <?php if ( $bulk ) : ?> |
|
1209 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1210 <?php endif; // $bulk ?> |
|
1211 <?php |
|
1212 /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
|
1213 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
|
1214 ?> |
|
1215 <option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
1216 <?php page_template_dropdown() ?> |
|
1217 </select> |
|
1218 </label> |
|
1219 |
|
1220 <?php |
1553 <?php |
1221 endif; // page post_type |
1554 endif; // !$bulk |
1222 endif; // page-attributes |
1555 endif; // page-attributes |
1223 ?> |
1556 ?> |
1224 |
1557 |
1558 <?php if ( 0 < count( get_page_templates( null, $screen->post_type ) ) ) : ?> |
|
1559 <label> |
|
1560 <span class="title"><?php _e( 'Template' ); ?></span> |
|
1561 <select name="page_template"> |
|
1562 <?php if ( $bulk ) : ?> |
|
1563 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
|
1564 <?php endif; // $bulk ?> |
|
1565 <?php |
|
1566 /** This filter is documented in wp-admin/includes/meta-boxes.php */ |
|
1567 $default_title = apply_filters( 'default_page_template_title', __( 'Default Template' ), 'quick-edit' ); |
|
1568 ?> |
|
1569 <option value="default"><?php echo esc_html( $default_title ); ?></option> |
|
1570 <?php page_template_dropdown( '', $screen->post_type ) ?> |
|
1571 </select> |
|
1572 </label> |
|
1573 <?php endif; ?> |
|
1574 |
|
1225 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?> |
1575 <?php if ( count( $flat_taxonomies ) && !$bulk ) : ?> |
1226 |
1576 |
1227 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
1577 <?php foreach ( $flat_taxonomies as $taxonomy ) : ?> |
1228 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : ?> |
1578 <?php if ( current_user_can( $taxonomy->cap->assign_terms ) ) : |
1579 $taxonomy_name = esc_attr( $taxonomy->name ); |
|
1580 |
|
1581 ?> |
|
1229 <label class="inline-edit-tags"> |
1582 <label class="inline-edit-tags"> |
1230 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
1583 <span class="title"><?php echo esc_html( $taxonomy->labels->name ) ?></span> |
1231 <textarea cols="22" rows="1" name="tax_input[<?php echo esc_attr( $taxonomy->name )?>]" class="tax_input_<?php echo esc_attr( $taxonomy->name )?>"></textarea> |
1584 <textarea data-wp-taxonomy="<?php echo $taxonomy_name; ?>" cols="22" rows="1" name="tax_input[<?php echo $taxonomy_name; ?>]" class="tax_input_<?php echo $taxonomy_name; ?>"></textarea> |
1232 </label> |
1585 </label> |
1233 <?php endif; ?> |
1586 <?php endif; ?> |
1234 |
1587 |
1235 <?php endforeach; //$flat_taxonomies as $taxonomy ?> |
1588 <?php endforeach; //$flat_taxonomies as $taxonomy ?> |
1236 |
1589 |
1237 <?php endif; // count( $flat_taxonomies ) && !$bulk ?> |
1590 <?php endif; // count( $flat_taxonomies ) && !$bulk ?> |
1238 |
1591 |
1239 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : |
1592 <?php if ( post_type_supports( $screen->post_type, 'comments' ) || post_type_supports( $screen->post_type, 'trackbacks' ) ) : |
1240 if ( $bulk ) : ?> |
1593 if ( $bulk ) : ?> |
1241 |
1594 |
1242 <div class="inline-edit-group"> |
1595 <div class="inline-edit-group wp-clearfix"> |
1243 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
1596 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
1244 <label class="alignleft"> |
1597 <label class="alignleft"> |
1245 <span class="title"><?php _e( 'Comments' ); ?></span> |
1598 <span class="title"><?php _e( 'Comments' ); ?></span> |
1246 <select name="comment_status"> |
1599 <select name="comment_status"> |
1247 <option value=""><?php _e( '— No Change —' ); ?></option> |
1600 <option value=""><?php _e( '— No Change —' ); ?></option> |
1261 <?php endif; ?> |
1614 <?php endif; ?> |
1262 </div> |
1615 </div> |
1263 |
1616 |
1264 <?php else : // $bulk ?> |
1617 <?php else : // $bulk ?> |
1265 |
1618 |
1266 <div class="inline-edit-group"> |
1619 <div class="inline-edit-group wp-clearfix"> |
1267 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
1620 <?php if ( post_type_supports( $screen->post_type, 'comments' ) ) : ?> |
1268 <label class="alignleft"> |
1621 <label class="alignleft"> |
1269 <input type="checkbox" name="comment_status" value="open" /> |
1622 <input type="checkbox" name="comment_status" value="open" /> |
1270 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
1623 <span class="checkbox-title"><?php _e( 'Allow Comments' ); ?></span> |
1271 </label> |
1624 </label> |
1278 </div> |
1631 </div> |
1279 |
1632 |
1280 <?php endif; // $bulk |
1633 <?php endif; // $bulk |
1281 endif; // post_type_supports comments or pings ?> |
1634 endif; // post_type_supports comments or pings ?> |
1282 |
1635 |
1283 <div class="inline-edit-group"> |
1636 <div class="inline-edit-group wp-clearfix"> |
1284 <label class="inline-edit-status alignleft"> |
1637 <label class="inline-edit-status alignleft"> |
1285 <span class="title"><?php _e( 'Status' ); ?></span> |
1638 <span class="title"><?php _e( 'Status' ); ?></span> |
1286 <select name="_status"> |
1639 <select name="_status"> |
1287 <?php if ( $bulk ) : ?> |
1640 <?php if ( $bulk ) : ?> |
1288 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
1641 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
1297 <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
1650 <option value="pending"><?php _e( 'Pending Review' ); ?></option> |
1298 <option value="draft"><?php _e( 'Draft' ); ?></option> |
1651 <option value="draft"><?php _e( 'Draft' ); ?></option> |
1299 </select> |
1652 </select> |
1300 </label> |
1653 </label> |
1301 |
1654 |
1302 <?php if ( 'post' == $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
1655 <?php if ( 'post' === $screen->post_type && $can_publish && current_user_can( $post_type_object->cap->edit_others_posts ) ) : ?> |
1303 |
1656 |
1304 <?php if ( $bulk ) : ?> |
1657 <?php if ( $bulk ) : ?> |
1305 |
1658 |
1306 <label class="alignright"> |
1659 <label class="alignright"> |
1307 <span class="title"><?php _e( 'Sticky' ); ?></span> |
1660 <span class="title"><?php _e( 'Sticky' ); ?></span> |
1329 |
1682 |
1330 if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) { |
1683 if ( $bulk && current_theme_supports( 'post-formats' ) && post_type_supports( $screen->post_type, 'post-formats' ) ) { |
1331 $post_formats = get_theme_support( 'post-formats' ); |
1684 $post_formats = get_theme_support( 'post-formats' ); |
1332 |
1685 |
1333 ?> |
1686 ?> |
1334 <label class="alignleft" for="post_format"> |
1687 <label class="alignleft"> |
1335 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
1688 <span class="title"><?php _ex( 'Format', 'post format' ); ?></span> |
1336 <select name="post_format"> |
1689 <select name="post_format"> |
1337 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
1690 <option value="-1"><?php _e( '— No Change —' ); ?></option> |
1338 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
1691 <option value="0"><?php echo get_post_format_string( 'standard' ); ?></option> |
1339 <?php |
1692 <?php |
1340 |
1693 if ( is_array( $post_formats[0] ) ) { |
1341 foreach ( $post_formats[0] as $format ) { |
1694 foreach ( $post_formats[0] as $format ) { |
1342 ?> |
1695 ?> |
1343 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
1696 <option value="<?php echo esc_attr( $format ); ?>"><?php echo esc_html( get_post_format_string( $format ) ); ?></option> |
1344 <?php |
1697 <?php |
1345 } |
1698 } |
1346 |
1699 } |
1347 ?> |
1700 ?> |
1348 </select></label> |
1701 </select></label> |
1349 <?php |
1702 <?php |
1350 |
1703 |
1351 } |
1704 } |
1377 /** |
1730 /** |
1378 * Fires once for each column in Quick Edit mode. |
1731 * Fires once for each column in Quick Edit mode. |
1379 * |
1732 * |
1380 * @since 2.7.0 |
1733 * @since 2.7.0 |
1381 * |
1734 * |
1382 * @param string $column_name Name of the column to edit. |
1735 * @param string $column_name Name of the column to edit. |
1383 * @param WP_Post $post_type The post type slug. |
1736 * @param string $post_type The post type slug, or current screen name if this is a taxonomy list table. |
1737 * @param string taxonomy The taxonomy name, if any. |
|
1384 */ |
1738 */ |
1385 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type ); |
1739 do_action( 'quick_edit_custom_box', $column_name, $screen->post_type, '' ); |
1386 } |
1740 } |
1387 |
1741 |
1388 } |
1742 } |
1389 ?> |
1743 ?> |
1390 <p class="submit inline-edit-save"> |
1744 <div class="submit inline-edit-save"> |
1391 <a href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a> |
1745 <button type="button" class="button cancel alignleft"><?php _e( 'Cancel' ); ?></button> |
1392 <?php if ( ! $bulk ) { |
1746 <?php if ( ! $bulk ) { |
1393 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
1747 wp_nonce_field( 'inlineeditnonce', '_inline_edit', false ); |
1394 ?> |
1748 ?> |
1395 <a href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a> |
1749 <button type="button" class="button button-primary save alignright"><?php _e( 'Update' ); ?></button> |
1396 <span class="spinner"></span> |
1750 <span class="spinner"></span> |
1397 <?php } else { |
1751 <?php } else { |
1398 submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false ); |
1752 submit_button( __( 'Update' ), 'primary alignright', 'bulk_edit', false ); |
1399 } ?> |
1753 } ?> |
1400 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
1754 <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" /> |
1401 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
1755 <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" /> |
1402 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> |
1756 <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?> |
1403 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
1757 <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" /> |
1404 <?php } ?> |
1758 <?php } ?> |
1405 <span class="error" style="display:none"></span> |
|
1406 <br class="clear" /> |
1759 <br class="clear" /> |
1407 </p> |
1760 <div class="notice notice-error notice-alt inline hidden"> |
1761 <p class="error"></p> |
|
1762 </div> |
|
1763 </div> |
|
1408 </td></tr> |
1764 </td></tr> |
1409 <?php |
1765 <?php |
1410 $bulk++; |
1766 $bulk++; |
1411 } |
1767 } |
1412 ?> |
1768 ?> |