class-wp-posts-list-table.php 56 KB

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