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