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