wp/wp-admin/includes/class-wp-posts-list-table.php
changeset 18 be944660c56a
parent 16 a86126ab1dd4
child 19 3d72ae0968f4
equal deleted inserted replaced
17:34716fd837a4 18:be944660c56a
    82 		);
    82 		);
    83 
    83 
    84 		$post_type        = $this->screen->post_type;
    84 		$post_type        = $this->screen->post_type;
    85 		$post_type_object = get_post_type_object( $post_type );
    85 		$post_type_object = get_post_type_object( $post_type );
    86 
    86 
    87 		$exclude_states         = get_post_stati(
    87 		$exclude_states = get_post_stati(
    88 			array(
    88 			array(
    89 				'show_in_admin_all_list' => false,
    89 				'show_in_admin_all_list' => false,
    90 			)
    90 			)
    91 		);
    91 		);
    92 		$this->user_posts_count = intval(
    92 
    93 			$wpdb->get_var(
    93 		$this->user_posts_count = (int) $wpdb->get_var(
    94 				$wpdb->prepare(
    94 			$wpdb->prepare(
    95 					"
    95 				"SELECT COUNT( 1 )
    96 			SELECT COUNT( 1 )
    96 				FROM $wpdb->posts
    97 			FROM $wpdb->posts
    97 				WHERE post_type = %s
    98 			WHERE post_type = %s
    98 				AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
    99 			AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
    99 				AND post_author = %d",
   100 			AND post_author = %d
   100 				$post_type,
   101 		",
   101 				get_current_user_id()
   102 					$post_type,
       
   103 					get_current_user_id()
       
   104 				)
       
   105 			)
   102 			)
   106 		);
   103 		);
   107 
   104 
   108 		if ( $this->user_posts_count && ! current_user_can( $post_type_object->cap->edit_others_posts ) && empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] ) && empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] ) ) {
   105 		if ( $this->user_posts_count
       
   106 			&& ! current_user_can( $post_type_object->cap->edit_others_posts )
       
   107 			&& empty( $_REQUEST['post_status'] ) && empty( $_REQUEST['all_posts'] )
       
   108 			&& empty( $_REQUEST['author'] ) && empty( $_REQUEST['show_sticky'] )
       
   109 		) {
   109 			$_GET['author'] = get_current_user_id();
   110 			$_GET['author'] = get_current_user_id();
   110 		}
   111 		}
   111 
   112 
   112 		$sticky_posts = get_option( 'sticky_posts' );
   113 		$sticky_posts = get_option( 'sticky_posts' );
       
   114 
   113 		if ( 'post' === $post_type && $sticky_posts ) {
   115 		if ( 'post' === $post_type && $sticky_posts ) {
   114 			$sticky_posts             = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
   116 			$sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
   115 			$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 ) );
   117 
       
   118 			$this->sticky_posts_count = (int) $wpdb->get_var(
       
   119 				$wpdb->prepare(
       
   120 					"SELECT COUNT( 1 )
       
   121 					FROM $wpdb->posts
       
   122 					WHERE post_type = %s
       
   123 					AND post_status NOT IN ('trash', 'auto-draft')
       
   124 					AND ID IN ($sticky_posts)",
       
   125 					$post_type
       
   126 				)
       
   127 			);
   116 		}
   128 		}
   117 	}
   129 	}
   118 
   130 
   119 	/**
   131 	/**
   120 	 * Sets whether the table layout should be hierarchical or not.
   132 	 * Sets whether the table layout should be hierarchical or not.
   151 		}
   163 		}
   152 
   164 
   153 		// Is going to call wp().
   165 		// Is going to call wp().
   154 		$avail_post_stati = wp_edit_posts_query();
   166 		$avail_post_stati = wp_edit_posts_query();
   155 
   167 
   156 		$this->set_hierarchical_display( is_post_type_hierarchical( $this->screen->post_type ) && 'menu_order title' === $wp_query->query['orderby'] );
   168 		$this->set_hierarchical_display(
       
   169 			is_post_type_hierarchical( $this->screen->post_type )
       
   170 			&& 'menu_order title' === $wp_query->query['orderby']
       
   171 		);
   157 
   172 
   158 		$post_type = $this->screen->post_type;
   173 		$post_type = $this->screen->post_type;
   159 		$per_page  = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
   174 		$per_page  = $this->get_items_per_page( 'edit_' . $post_type . '_per_page' );
   160 
   175 
   161 		/** This filter is documented in wp-admin/includes/post.php */
   176 		/** This filter is documented in wp-admin/includes/post.php */
   170 
   185 
   171 			if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) {
   186 			if ( isset( $_REQUEST['post_status'] ) && in_array( $_REQUEST['post_status'], $avail_post_stati, true ) ) {
   172 				$total_items = $post_counts[ $_REQUEST['post_status'] ];
   187 				$total_items = $post_counts[ $_REQUEST['post_status'] ];
   173 			} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
   188 			} elseif ( isset( $_REQUEST['show_sticky'] ) && $_REQUEST['show_sticky'] ) {
   174 				$total_items = $this->sticky_posts_count;
   189 				$total_items = $this->sticky_posts_count;
   175 			} elseif ( isset( $_GET['author'] ) && get_current_user_id() == $_GET['author'] ) {
   190 			} elseif ( isset( $_GET['author'] ) && get_current_user_id() === (int) $_GET['author'] ) {
   176 				$total_items = $this->user_posts_count;
   191 				$total_items = $this->user_posts_count;
   177 			} else {
   192 			} else {
   178 				$total_items = array_sum( $post_counts );
   193 				$total_items = array_sum( $post_counts );
   179 
   194 
   180 				// Subtract post types that are not included in the admin all list.
   195 				// Subtract post types that are not included in the admin all list.
   244 	protected function get_edit_link( $args, $label, $class = '' ) {
   259 	protected function get_edit_link( $args, $label, $class = '' ) {
   245 		$url = add_query_arg( $args, 'edit.php' );
   260 		$url = add_query_arg( $args, 'edit.php' );
   246 
   261 
   247 		$class_html   = '';
   262 		$class_html   = '';
   248 		$aria_current = '';
   263 		$aria_current = '';
       
   264 
   249 		if ( ! empty( $class ) ) {
   265 		if ( ! empty( $class ) ) {
   250 			$class_html = sprintf(
   266 			$class_html = sprintf(
   251 				' class="%s"',
   267 				' class="%s"',
   252 				esc_attr( $class )
   268 				esc_attr( $class )
   253 			);
   269 			);
   293 		foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
   309 		foreach ( get_post_stati( array( 'show_in_admin_all_list' => false ) ) as $state ) {
   294 			$total_posts -= $num_posts->$state;
   310 			$total_posts -= $num_posts->$state;
   295 		}
   311 		}
   296 
   312 
   297 		if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
   313 		if ( $this->user_posts_count && $this->user_posts_count !== $total_posts ) {
   298 			if ( isset( $_GET['author'] ) && ( $_GET['author'] == $current_user_id ) ) {
   314 			if ( isset( $_GET['author'] ) && ( $current_user_id === (int) $_GET['author'] ) ) {
   299 				$class = 'current';
   315 				$class = 'current';
   300 			}
   316 			}
   301 
   317 
   302 			$mine_args = array(
   318 			$mine_args = array(
   303 				'post_type' => $post_type,
   319 				'post_type' => $post_type,
   335 			),
   351 			),
   336 			number_format_i18n( $total_posts )
   352 			number_format_i18n( $total_posts )
   337 		);
   353 		);
   338 
   354 
   339 		$status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
   355 		$status_links['all'] = $this->get_edit_link( $all_args, $all_inner_html, $class );
       
   356 
   340 		if ( $mine ) {
   357 		if ( $mine ) {
   341 			$status_links['mine'] = $mine;
   358 			$status_links['mine'] = $mine;
   342 		}
   359 		}
   343 
   360 
   344 		foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
   361 		foreach ( get_post_stati( array( 'show_in_admin_status_list' => true ), 'objects' ) as $status ) {
   456 				'show_count'      => 0,
   473 				'show_count'      => 0,
   457 				'orderby'         => 'name',
   474 				'orderby'         => 'name',
   458 				'selected'        => $cat,
   475 				'selected'        => $cat,
   459 			);
   476 			);
   460 
   477 
   461 			echo '<label class="screen-reader-text" for="cat">' . __( 'Filter by category' ) . '</label>';
   478 			echo '<label class="screen-reader-text" for="cat">' . get_taxonomy( 'category' )->labels->filter_by_item . '</label>';
       
   479 
   462 			wp_dropdown_categories( $dropdown_options );
   480 			wp_dropdown_categories( $dropdown_options );
   463 		}
   481 		}
   464 	}
   482 	}
   465 
   483 
   466 	/**
   484 	/**
   512 			foreach ( $used_post_formats as $used_post_format ) {
   530 			foreach ( $used_post_formats as $used_post_format ) {
   513 				// Post format slug.
   531 				// Post format slug.
   514 				$slug = str_replace( 'post-format-', '', $used_post_format->slug );
   532 				$slug = str_replace( 'post-format-', '', $used_post_format->slug );
   515 				// Pretty, translated version of the post format slug.
   533 				// Pretty, translated version of the post format slug.
   516 				$pretty_name = get_post_format_string( $slug );
   534 				$pretty_name = get_post_format_string( $slug );
       
   535 
   517 				// Skip the standard post format.
   536 				// Skip the standard post format.
   518 				if ( 'standard' === $slug ) {
   537 				if ( 'standard' === $slug ) {
   519 					continue;
   538 					continue;
   520 				}
   539 				}
   521 				?>
   540 				?>
   564 				echo $output;
   583 				echo $output;
   565 				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
   584 				submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'post-query-submit' ) );
   566 			}
   585 			}
   567 		}
   586 		}
   568 
   587 
   569 		if ( $this->is_trash && current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts ) && $this->has_items() ) {
   588 		if ( $this->is_trash && $this->has_items()
       
   589 			&& current_user_can( get_post_type_object( $this->screen->post_type )->cap->edit_others_posts )
       
   590 		) {
   570 			submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
   591 			submit_button( __( 'Empty Trash' ), 'apply', 'delete_all', false );
   571 		}
   592 		}
   572 		?>
   593 		?>
   573 		</div>
   594 		</div>
   574 		<?php
   595 		<?php
   602 	protected function get_table_classes() {
   623 	protected function get_table_classes() {
   603 		global $mode;
   624 		global $mode;
   604 
   625 
   605 		$mode_class = esc_attr( 'table-view-' . $mode );
   626 		$mode_class = esc_attr( 'table-view-' . $mode );
   606 
   627 
   607 		return array( 'widefat', 'fixed', 'striped', $mode_class, is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts' );
   628 		return array(
       
   629 			'widefat',
       
   630 			'fixed',
       
   631 			'striped',
       
   632 			$mode_class,
       
   633 			is_post_type_hierarchical( $this->screen->post_type ) ? 'pages' : 'posts',
       
   634 		);
   608 	}
   635 	}
   609 
   636 
   610 	/**
   637 	/**
   611 	 * @return array
   638 	 * @return array
   612 	 */
   639 	 */
   630 		/**
   657 		/**
   631 		 * Filters the taxonomy columns in the Posts list table.
   658 		 * Filters the taxonomy columns in the Posts list table.
   632 		 *
   659 		 *
   633 		 * The dynamic portion of the hook name, `$post_type`, refers to the post
   660 		 * The dynamic portion of the hook name, `$post_type`, refers to the post
   634 		 * type slug.
   661 		 * type slug.
       
   662 		 *
       
   663 		 * Possible hook names include:
       
   664 		 *
       
   665 		 *  - `manage_taxonomies_for_post_columns`
       
   666 		 *  - `manage_taxonomies_for_page_columns`
   635 		 *
   667 		 *
   636 		 * @since 3.5.0
   668 		 * @since 3.5.0
   637 		 *
   669 		 *
   638 		 * @param string[] $taxonomies Array of taxonomy names to show columns for.
   670 		 * @param string[] $taxonomies Array of taxonomy names to show columns for.
   639 		 * @param string   $post_type  The post type.
   671 		 * @param string   $post_type  The post type.
   652 
   684 
   653 			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
   685 			$posts_columns[ $column_key ] = get_taxonomy( $taxonomy )->labels->name;
   654 		}
   686 		}
   655 
   687 
   656 		$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
   688 		$post_status = ! empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all';
   657 		if ( post_type_supports( $post_type, 'comments' ) && ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true ) ) {
   689 
   658 			$posts_columns['comments'] = '<span class="vers comment-grey-bubble" title="' . esc_attr__( 'Comments' ) . '"><span class="screen-reader-text">' . __( 'Comments' ) . '</span></span>';
   690 		if ( post_type_supports( $post_type, 'comments' )
       
   691 			&& ! in_array( $post_status, array( 'pending', 'draft', 'future' ), true )
       
   692 		) {
       
   693 			$posts_columns['comments'] = sprintf(
       
   694 				'<span class="vers comment-grey-bubble" title="%1$s"><span class="screen-reader-text">%2$s</span></span>',
       
   695 				esc_attr__( 'Comments' ),
       
   696 				__( 'Comments' )
       
   697 			);
   659 		}
   698 		}
   660 
   699 
   661 		$posts_columns['date'] = __( 'Date' );
   700 		$posts_columns['date'] = __( 'Date' );
   662 
   701 
   663 		if ( 'page' === $post_type ) {
   702 		if ( 'page' === $post_type ) {
   686 		/**
   725 		/**
   687 		 * Filters the columns displayed in the Posts list table for a specific post type.
   726 		 * Filters the columns displayed in the Posts list table for a specific post type.
   688 		 *
   727 		 *
   689 		 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
   728 		 * The dynamic portion of the hook name, `$post_type`, refers to the post type slug.
   690 		 *
   729 		 *
       
   730 		 * Possible hook names include:
       
   731 		 *
       
   732 		 *  - `manage_post_posts_columns`
       
   733 		 *  - `manage_page_posts_columns`
       
   734 		 *
   691 		 * @since 3.0.0
   735 		 * @since 3.0.0
   692 		 *
   736 		 *
   693 		 * @param string[] $post_columns An associative array of column headings.
   737 		 * @param string[] $post_columns An associative array of column headings.
   694 		 */
   738 		 */
   695 		return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
   739 		return apply_filters( "manage_{$post_type}_posts_columns", $posts_columns );
   778 		 * children_pages[10][] contains all sub-pages whose parent is 10.
   822 		 * children_pages[10][] contains all sub-pages whose parent is 10.
   779 		 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
   823 		 * It only takes O( N ) to arrange this and it takes O( 1 ) for subsequent lookup operations
   780 		 * If searching, ignore hierarchy and treat everything as top level
   824 		 * If searching, ignore hierarchy and treat everything as top level
   781 		 */
   825 		 */
   782 		if ( empty( $_REQUEST['s'] ) ) {
   826 		if ( empty( $_REQUEST['s'] ) ) {
   783 
       
   784 			$top_level_pages = array();
   827 			$top_level_pages = array();
   785 			$children_pages  = array();
   828 			$children_pages  = array();
   786 
   829 
   787 			foreach ( $pages as $page ) {
   830 			foreach ( $pages as $page ) {
   788 
       
   789 				// Catch and repair bad pages.
   831 				// Catch and repair bad pages.
   790 				if ( $page->post_parent == $page->ID ) {
   832 				if ( $page->post_parent === $page->ID ) {
   791 					$page->post_parent = 0;
   833 					$page->post_parent = 0;
   792 					$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
   834 					$wpdb->update( $wpdb->posts, array( 'post_parent' => 0 ), array( 'ID' => $page->ID ) );
   793 					clean_post_cache( $page );
   835 					clean_post_cache( $page );
   794 				}
   836 				}
   795 
   837 
   796 				if ( 0 == $page->post_parent ) {
   838 				if ( $page->post_parent > 0 ) {
       
   839 					$children_pages[ $page->post_parent ][] = $page;
       
   840 				} else {
   797 					$top_level_pages[] = $page;
   841 					$top_level_pages[] = $page;
   798 				} else {
       
   799 					$children_pages[ $page->post_parent ][] = $page;
       
   800 				}
   842 				}
   801 			}
   843 			}
   802 
   844 
   803 			$pages = &$top_level_pages;
   845 			$pages = &$top_level_pages;
   804 		}
   846 		}
   881 			if ( $count >= $end ) {
   923 			if ( $count >= $end ) {
   882 				break;
   924 				break;
   883 			}
   925 			}
   884 
   926 
   885 			// If the page starts in a subtree, print the parents.
   927 			// If the page starts in a subtree, print the parents.
   886 			if ( $count == $start && $page->post_parent > 0 ) {
   928 			if ( $count === $start && $page->post_parent > 0 ) {
   887 				$my_parents = array();
   929 				$my_parents = array();
   888 				$my_parent  = $page->post_parent;
   930 				$my_parent  = $page->post_parent;
       
   931 
   889 				while ( $my_parent ) {
   932 				while ( $my_parent ) {
   890 					// Get the ID from the list or the attribute if my_parent is an object.
   933 					// Get the ID from the list or the attribute if my_parent is an object.
   891 					$parent_id = $my_parent;
   934 					$parent_id = $my_parent;
       
   935 
   892 					if ( is_object( $my_parent ) ) {
   936 					if ( is_object( $my_parent ) ) {
   893 						$parent_id = $my_parent->ID;
   937 						$parent_id = $my_parent->ID;
   894 					}
   938 					}
   895 
   939 
   896 					$my_parent    = get_post( $parent_id );
   940 					$my_parent    = get_post( $parent_id );
   897 					$my_parents[] = $my_parent;
   941 					$my_parents[] = $my_parent;
       
   942 
   898 					if ( ! $my_parent->post_parent ) {
   943 					if ( ! $my_parent->post_parent ) {
   899 						break;
   944 						break;
   900 					}
   945 					}
       
   946 
   901 					$my_parent = $my_parent->post_parent;
   947 					$my_parent = $my_parent->post_parent;
   902 				}
   948 				}
       
   949 
   903 				$num_parents = count( $my_parents );
   950 				$num_parents = count( $my_parents );
       
   951 
   904 				while ( $my_parent = array_pop( $my_parents ) ) {
   952 				while ( $my_parent = array_pop( $my_parents ) ) {
   905 					$to_display[ $my_parent->ID ] = $level - $num_parents;
   953 					$to_display[ $my_parent->ID ] = $level - $num_parents;
   906 					$num_parents--;
   954 					$num_parents--;
   907 				}
   955 				}
   908 			}
   956 			}
   925 	 * @since 4.3.0
   973 	 * @since 4.3.0
   926 	 *
   974 	 *
   927 	 * @param WP_Post $post The current WP_Post object.
   975 	 * @param WP_Post $post The current WP_Post object.
   928 	 */
   976 	 */
   929 	public function column_cb( $post ) {
   977 	public function column_cb( $post ) {
   930 		if ( current_user_can( 'edit_post', $post->ID ) ) :
   978 		$show = current_user_can( 'edit_post', $post->ID );
       
   979 
       
   980 		/**
       
   981 		 * Filters whether to show the bulk edit checkbox for a post in its list table.
       
   982 		 *
       
   983 		 * By default the checkbox is only shown if the current user can edit the post.
       
   984 		 *
       
   985 		 * @since 5.7.0
       
   986 		 *
       
   987 		 * @param bool    $show Whether to show the checkbox.
       
   988 		 * @param WP_Post $post The current WP_Post object.
       
   989 		 */
       
   990 		if ( apply_filters( 'wp_list_table_show_post_checkbox', $show, $post ) ) :
   931 			?>
   991 			?>
   932 			<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
   992 			<label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>">
   933 				<?php
   993 				<?php
   934 					/* translators: %s: Post title. */
   994 					/* translators: %s: Post title. */
   935 					printf( __( 'Select %s' ), _draft_or_post_title() );
   995 					printf( __( 'Select %s' ), _draft_or_post_title() );
   981 
  1041 
   982 		if ( $this->hierarchical_display ) {
  1042 		if ( $this->hierarchical_display ) {
   983 			if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
  1043 			if ( 0 === $this->current_level && (int) $post->post_parent > 0 ) {
   984 				// Sent level 0 by accident, by default, or because we don't know the actual level.
  1044 				// Sent level 0 by accident, by default, or because we don't know the actual level.
   985 				$find_main_page = (int) $post->post_parent;
  1045 				$find_main_page = (int) $post->post_parent;
       
  1046 
   986 				while ( $find_main_page > 0 ) {
  1047 				while ( $find_main_page > 0 ) {
   987 					$parent = get_post( $find_main_page );
  1048 					$parent = get_post( $find_main_page );
   988 
  1049 
   989 					if ( is_null( $parent ) ) {
  1050 					if ( is_null( $parent ) ) {
   990 						break;
  1051 						break;
  1044 
  1105 
  1045 		if ( isset( $parent_name ) ) {
  1106 		if ( isset( $parent_name ) ) {
  1046 			$post_type_object = get_post_type_object( $post->post_type );
  1107 			$post_type_object = get_post_type_object( $post->post_type );
  1047 			echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
  1108 			echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
  1048 		}
  1109 		}
       
  1110 
  1049 		echo "</strong>\n";
  1111 		echo "</strong>\n";
  1050 
  1112 
  1051 		if ( 'excerpt' === $mode
  1113 		if ( 'excerpt' === $mode
  1052 			&& ! is_post_type_hierarchical( $this->screen->post_type )
  1114 			&& ! is_post_type_hierarchical( $this->screen->post_type )
  1053 			&& current_user_can( 'read_post', $post->ID )
  1115 			&& current_user_can( 'read_post', $post->ID )
  1079 			$time_diff = 0;
  1141 			$time_diff = 0;
  1080 		} else {
  1142 		} else {
  1081 			$t_time = sprintf(
  1143 			$t_time = sprintf(
  1082 				/* translators: 1: Post date, 2: Post time. */
  1144 				/* translators: 1: Post date, 2: Post time. */
  1083 				__( '%1$s at %2$s' ),
  1145 				__( '%1$s at %2$s' ),
  1084 				/* translators: Post date format. See https://www.php.net/date */
  1146 				/* translators: Post date format. See https://www.php.net/manual/datetime.format.php */
  1085 				get_the_time( __( 'Y/m/d' ), $post ),
  1147 				get_the_time( __( 'Y/m/d' ), $post ),
  1086 				/* translators: Post time format. See https://www.php.net/date */
  1148 				/* translators: Post time format. See https://www.php.net/manual/datetime.format.php */
  1087 				get_the_time( __( 'g:i a' ), $post )
  1149 				get_the_time( __( 'g:i a' ), $post )
  1088 			);
  1150 			);
  1089 
  1151 
  1090 			$time      = get_post_timestamp( $post );
  1152 			$time      = get_post_timestamp( $post );
  1091 			$time_diff = time() - $time;
  1153 			$time_diff = time() - $time;
  1185 		} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
  1247 		} elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) {
  1186 			$taxonomy = substr( $column_name, 9 );
  1248 			$taxonomy = substr( $column_name, 9 );
  1187 		} else {
  1249 		} else {
  1188 			$taxonomy = false;
  1250 			$taxonomy = false;
  1189 		}
  1251 		}
       
  1252 
  1190 		if ( $taxonomy ) {
  1253 		if ( $taxonomy ) {
  1191 			$taxonomy_object = get_taxonomy( $taxonomy );
  1254 			$taxonomy_object = get_taxonomy( $taxonomy );
  1192 			$terms           = get_the_terms( $post->ID, $taxonomy );
  1255 			$terms           = get_the_terms( $post->ID, $taxonomy );
       
  1256 
  1193 			if ( is_array( $terms ) ) {
  1257 			if ( is_array( $terms ) ) {
  1194 				$term_links = array();
  1258 				$term_links = array();
       
  1259 
  1195 				foreach ( $terms as $t ) {
  1260 				foreach ( $terms as $t ) {
  1196 					$posts_in_term_qv = array();
  1261 					$posts_in_term_qv = array();
       
  1262 
  1197 					if ( 'post' !== $post->post_type ) {
  1263 					if ( 'post' !== $post->post_type ) {
  1198 						$posts_in_term_qv['post_type'] = $post->post_type;
  1264 						$posts_in_term_qv['post_type'] = $post->post_type;
  1199 					}
  1265 					}
       
  1266 
  1200 					if ( $taxonomy_object->query_var ) {
  1267 					if ( $taxonomy_object->query_var ) {
  1201 						$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
  1268 						$posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug;
  1202 					} else {
  1269 					} else {
  1203 						$posts_in_term_qv['taxonomy'] = $taxonomy;
  1270 						$posts_in_term_qv['taxonomy'] = $taxonomy;
  1204 						$posts_in_term_qv['term']     = $t->slug;
  1271 						$posts_in_term_qv['term']     = $t->slug;
  1219 				 * @param WP_Term[] $terms      Array of term objects appearing in the post row.
  1286 				 * @param WP_Term[] $terms      Array of term objects appearing in the post row.
  1220 				 */
  1287 				 */
  1221 				$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
  1288 				$term_links = apply_filters( 'post_column_taxonomy_links', $term_links, $taxonomy, $terms );
  1222 
  1289 
  1223 				/* translators: Used between list items, there is a space after the comma. */
  1290 				/* translators: Used between list items, there is a space after the comma. */
  1224 				echo join( __( ', ' ), $term_links );
  1291 				echo implode( __( ', ' ), $term_links );
  1225 			} else {
  1292 			} else {
  1226 				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
  1293 				echo '<span aria-hidden="true">&#8212;</span><span class="screen-reader-text">' . $taxonomy_object->labels->no_terms . '</span>';
  1227 			}
  1294 			}
  1228 			return;
  1295 			return;
  1229 		}
  1296 		}
  1261 		/**
  1328 		/**
  1262 		 * Fires for each custom column of a specific post type in the Posts list table.
  1329 		 * Fires for each custom column of a specific post type in the Posts list table.
  1263 		 *
  1330 		 *
  1264 		 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
  1331 		 * The dynamic portion of the hook name, `$post->post_type`, refers to the post type.
  1265 		 *
  1332 		 *
       
  1333 		 * Possible hook names include:
       
  1334 		 *
       
  1335 		 *  - `manage_post_posts_custom_column`
       
  1336 		 *  - `manage_page_posts_custom_column`
       
  1337 		 *
  1266 		 * @since 3.1.0
  1338 		 * @since 3.1.0
  1267 		 *
  1339 		 *
  1268 		 * @param string $column_name The name of the column to display.
  1340 		 * @param string $column_name The name of the column to display.
  1269 		 * @param int    $post_id     The current post ID.
  1341 		 * @param int    $post_id     The current post ID.
  1270 		 */
  1342 		 */
  1284 		$this->current_level = $level;
  1356 		$this->current_level = $level;
  1285 
  1357 
  1286 		$GLOBALS['post'] = $post;
  1358 		$GLOBALS['post'] = $post;
  1287 		setup_postdata( $post );
  1359 		setup_postdata( $post );
  1288 
  1360 
  1289 		$classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
  1361 		$classes = 'iedit author-' . ( get_current_user_id() === (int) $post->post_author ? 'self' : 'other' );
  1290 
  1362 
  1291 		$lock_holder = wp_check_post_lock( $post->ID );
  1363 		$lock_holder = wp_check_post_lock( $post->ID );
       
  1364 
  1292 		if ( $lock_holder ) {
  1365 		if ( $lock_holder ) {
  1293 			$classes .= ' wp-locked';
  1366 			$classes .= ' wp-locked';
  1294 		}
  1367 		}
  1295 
  1368 
  1296 		if ( $post->post_parent ) {
  1369 		if ( $post->post_parent ) {
  1321 	/**
  1394 	/**
  1322 	 * Generates and displays row action links.
  1395 	 * Generates and displays row action links.
  1323 	 *
  1396 	 *
  1324 	 * @since 4.3.0
  1397 	 * @since 4.3.0
  1325 	 *
  1398 	 *
  1326 	 * @param object $post        Post being acted upon.
  1399 	 * @param WP_Post $post        Post being acted upon.
  1327 	 * @param string $column_name Current column name.
  1400 	 * @param string  $column_name Current column name.
  1328 	 * @param string $primary     Primary column name.
  1401 	 * @param string  $primary     Primary column name.
  1329 	 * @return string Row actions output for posts, or an empty string
  1402 	 * @return string Row actions output for posts, or an empty string
  1330 	 *                if the current column is not the primary column.
  1403 	 *                if the current column is not the primary column.
  1331 	 */
  1404 	 */
  1332 	protected function handle_row_actions( $post, $column_name, $primary ) {
  1405 	protected function handle_row_actions( $post, $column_name, $primary ) {
  1333 		if ( $primary !== $column_name ) {
  1406 		if ( $primary !== $column_name ) {
  1374 					/* translators: %s: Post title. */
  1447 					/* translators: %s: Post title. */
  1375 					esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash' ), $title ) ),
  1448 					esc_attr( sprintf( __( 'Move &#8220;%s&#8221; to the Trash' ), $title ) ),
  1376 					_x( 'Trash', 'verb' )
  1449 					_x( 'Trash', 'verb' )
  1377 				);
  1450 				);
  1378 			}
  1451 			}
       
  1452 
  1379 			if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) {
  1453 			if ( 'trash' === $post->post_status || ! EMPTY_TRASH_DAYS ) {
  1380 				$actions['delete'] = sprintf(
  1454 				$actions['delete'] = sprintf(
  1381 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
  1455 					'<a href="%s" class="submitdelete" aria-label="%s">%s</a>',
  1382 					get_delete_post_link( $post->ID, '', true ),
  1456 					get_delete_post_link( $post->ID, '', true ),
  1383 					/* translators: %s: Post title. */
  1457 					/* translators: %s: Post title. */
  1473 		$taxonomy_names          = get_object_taxonomies( $screen->post_type );
  1547 		$taxonomy_names          = get_object_taxonomies( $screen->post_type );
  1474 		$hierarchical_taxonomies = array();
  1548 		$hierarchical_taxonomies = array();
  1475 		$flat_taxonomies         = array();
  1549 		$flat_taxonomies         = array();
  1476 
  1550 
  1477 		foreach ( $taxonomy_names as $taxonomy_name ) {
  1551 		foreach ( $taxonomy_names as $taxonomy_name ) {
  1478 
       
  1479 			$taxonomy = get_taxonomy( $taxonomy_name );
  1552 			$taxonomy = get_taxonomy( $taxonomy_name );
  1480 
  1553 
  1481 			$show_in_quick_edit = $taxonomy->show_in_quick_edit;
  1554 			$show_in_quick_edit = $taxonomy->show_in_quick_edit;
  1482 
  1555 
  1483 			/**
  1556 			/**
  1509 			'categories' => true,
  1582 			'categories' => true,
  1510 			'tags'       => true,
  1583 			'tags'       => true,
  1511 			'comments'   => true,
  1584 			'comments'   => true,
  1512 			'author'     => true,
  1585 			'author'     => true,
  1513 		);
  1586 		);
  1514 
       
  1515 		?>
  1587 		?>
  1516 
  1588 
  1517 		<form method="get">
  1589 		<form method="get">
  1518 		<table style="display: none"><tbody id="inlineedit">
  1590 		<table style="display: none"><tbody id="inlineedit">
  1519 		<?php
  1591 		<?php
  1521 		$inline_edit_classes = "inline-edit-row inline-edit-row-$hclass";
  1593 		$inline_edit_classes = "inline-edit-row inline-edit-row-$hclass";
  1522 		$bulk_edit_classes   = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}";
  1594 		$bulk_edit_classes   = "bulk-edit-row bulk-edit-row-$hclass bulk-edit-{$screen->post_type}";
  1523 		$quick_edit_classes  = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
  1595 		$quick_edit_classes  = "quick-edit-row quick-edit-row-$hclass inline-edit-{$screen->post_type}";
  1524 
  1596 
  1525 		$bulk = 0;
  1597 		$bulk = 0;
       
  1598 
  1526 		while ( $bulk < 2 ) :
  1599 		while ( $bulk < 2 ) :
  1527 			$classes  = $inline_edit_classes . ' ';
  1600 			$classes  = $inline_edit_classes . ' ';
  1528 			$classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes;
  1601 			$classes .= $bulk ? $bulk_edit_classes : $quick_edit_classes;
  1529 			?>
  1602 			?>
  1530 			<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none">
  1603 			<tr id="<?php echo $bulk ? 'bulk-edit' : 'inline-edit'; ?>" class="<?php echo $classes; ?>" style="display: none">
  1569 					</fieldset>
  1642 					</fieldset>
  1570 					<br class="clear" />
  1643 					<br class="clear" />
  1571 				<?php endif; // $bulk ?>
  1644 				<?php endif; // $bulk ?>
  1572 
  1645 
  1573 				<?php
  1646 				<?php
  1574 				if ( post_type_supports( $screen->post_type, 'author' ) ) :
  1647 				if ( post_type_supports( $screen->post_type, 'author' ) ) {
  1575 					$authors_dropdown = '';
  1648 					$authors_dropdown = '';
  1576 
  1649 
  1577 					if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) :
  1650 					if ( current_user_can( $post_type_object->cap->edit_others_posts ) ) {
  1578 						$users_opt = array(
  1651 						$users_opt = array(
  1579 							'hide_if_only_one_author' => false,
  1652 							'hide_if_only_one_author' => false,
  1580 							'who'                     => 'authors',
  1653 							'who'                     => 'authors',
  1581 							'name'                    => 'post_author',
  1654 							'name'                    => 'post_author',
  1582 							'class'                   => 'authors',
  1655 							'class'                   => 'authors',
  1587 
  1660 
  1588 						if ( $bulk ) {
  1661 						if ( $bulk ) {
  1589 							$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
  1662 							$users_opt['show_option_none'] = __( '&mdash; No Change &mdash;' );
  1590 						}
  1663 						}
  1591 
  1664 
       
  1665 						/**
       
  1666 						 * Filters the arguments used to generate the Quick Edit authors drop-down.
       
  1667 						 *
       
  1668 						 * @since 5.6.0
       
  1669 						 *
       
  1670 						 * @see wp_dropdown_users()
       
  1671 						 *
       
  1672 						 * @param array $users_opt An array of arguments passed to wp_dropdown_users().
       
  1673 						 * @param bool  $bulk      A flag to denote if it's a bulk action.
       
  1674 						 */
       
  1675 						$users_opt = apply_filters( 'quick_edit_dropdown_authors_args', $users_opt, $bulk );
       
  1676 
  1592 						$authors = wp_dropdown_users( $users_opt );
  1677 						$authors = wp_dropdown_users( $users_opt );
  1593 						if ( $authors ) :
  1678 
       
  1679 						if ( $authors ) {
  1594 							$authors_dropdown  = '<label class="inline-edit-author">';
  1680 							$authors_dropdown  = '<label class="inline-edit-author">';
  1595 							$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
  1681 							$authors_dropdown .= '<span class="title">' . __( 'Author' ) . '</span>';
  1596 							$authors_dropdown .= $authors;
  1682 							$authors_dropdown .= $authors;
  1597 							$authors_dropdown .= '</label>';
  1683 							$authors_dropdown .= '</label>';
  1598 						endif;
  1684 						}
  1599 					endif; // current_user_can( 'edit_others_posts' )
  1685 					} // current_user_can( 'edit_others_posts' )
  1600 					?>
  1686 
  1601 
       
  1602 					<?php
       
  1603 					if ( ! $bulk ) {
  1687 					if ( ! $bulk ) {
  1604 						echo $authors_dropdown;
  1688 						echo $authors_dropdown;
  1605 					}
  1689 					}
  1606 				endif; // post_type_supports( ... 'author' )
  1690 				} // post_type_supports( ... 'author' )
  1607 				?>
  1691 				?>
  1608 
  1692 
  1609 				<?php if ( ! $bulk && $can_publish ) : ?>
  1693 				<?php if ( ! $bulk && $can_publish ) : ?>
  1610 
  1694 
  1611 					<div class="inline-edit-group wp-clearfix">
  1695 					<div class="inline-edit-group wp-clearfix">
  1682 
  1766 
  1683 							/**
  1767 							/**
  1684 							 * Filters the arguments used to generate the Quick Edit page-parent drop-down.
  1768 							 * Filters the arguments used to generate the Quick Edit page-parent drop-down.
  1685 							 *
  1769 							 *
  1686 							 * @since 2.7.0
  1770 							 * @since 2.7.0
       
  1771 							 * @since 5.6.0 The `$bulk` parameter was added.
  1687 							 *
  1772 							 *
  1688 							 * @see wp_dropdown_pages()
  1773 							 * @see wp_dropdown_pages()
  1689 							 *
  1774 							 *
  1690 							 * @param array $dropdown_args An array of arguments.
  1775 							 * @param array $dropdown_args An array of arguments passed to wp_dropdown_pages().
       
  1776 							 * @param bool  $bulk          A flag to denote if it's a bulk action.
  1691 							 */
  1777 							 */
  1692 							$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args );
  1778 							$dropdown_args = apply_filters( 'quick_edit_dropdown_pages_args', $dropdown_args, $bulk );
  1693 
  1779 
  1694 							wp_dropdown_pages( $dropdown_args );
  1780 							wp_dropdown_pages( $dropdown_args );
  1695 							?>
  1781 							?>
  1696 						</label>
  1782 						</label>
  1697 
  1783