680 | | public function single_row( $post, $level = 0 ) { |
| 680 | public function column_cb( $post ) { |
| 681 | $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
| 682 | $title = _draft_or_post_title(); |
| 683 | ?> |
| 684 | <th scope="row" class="check-column"> |
| 685 | <?php if ( $can_edit_post ) { ?> |
| 686 | <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label> |
| 687 | <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" /> |
| 688 | <div class="locked-indicator"></div> |
| 689 | <?php } ?> |
| 690 | </th> |
| 691 | <?php |
| 692 | } |
| 693 | |
| 694 | /** |
| 695 | * @since 4.3.0 |
| 696 | * |
| 697 | * @global string $mode |
| 698 | * |
| 699 | * @param WP_Post $post |
| 700 | */ |
| 701 | public function column_title( $post ) { |
690 | | $edit_link = get_edit_post_link( $post->ID ); |
691 | | $title = _draft_or_post_title(); |
692 | | $post_type_object = get_post_type_object( $post->post_type ); |
693 | | $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
| 718 | if ( ! isset( $parent_name ) ) { |
| 719 | /** This filter is documented in wp-includes/post-template.php */ |
| 720 | $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
| 721 | } |
| 722 | } |
| 723 | } |
| 724 | } |
703 | | if ( $post->post_parent ) { |
704 | | $count = count( get_post_ancestors( $post->ID ) ); |
705 | | $classes .= ' level-'. $count; |
| 736 | $can_edit_post = current_user_can( 'edit_post', $post->ID ); |
| 737 | $title = _draft_or_post_title(); |
| 738 | |
| 739 | if ( $can_edit_post && $post->post_status != 'trash' ) { |
| 740 | $edit_link = get_edit_post_link( $post->ID ); |
| 741 | echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit “%s”' ), $title ) ) . '">' . $pad . $title . '</a>'; |
746 | | case 'title': |
747 | | if ( $this->hierarchical_display ) { |
748 | | if ( 0 == $level && (int) $post->post_parent > 0 ) { |
749 | | // Sent level 0 by accident, by default, or because we don't know the actual level. |
750 | | $find_main_page = (int) $post->post_parent; |
751 | | while ( $find_main_page > 0 ) { |
752 | | $parent = get_post( $find_main_page ); |
| 784 | if ( '0000-00-00 00:00:00' == $post->post_date ) { |
| 785 | $t_time = $h_time = __( 'Unpublished' ); |
| 786 | $time_diff = 0; |
| 787 | } else { |
| 788 | $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
| 789 | $m_time = $post->post_date; |
| 790 | $time = get_post_time( 'G', true, $post ); |
760 | | if ( !isset( $parent_name ) ) { |
761 | | /** This filter is documented in wp-includes/post-template.php */ |
762 | | $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID ); |
763 | | } |
764 | | } |
765 | | } |
766 | | } |
| 801 | if ( 'excerpt' == $mode ) { |
| 802 | /** |
| 803 | * Filter the published time of the post. |
| 804 | * |
| 805 | * If $mode equals 'excerpt', the published time and date are both displayed. |
| 806 | * If $mode equals 'list' (default), the publish date is displayed, with the |
| 807 | * time and date together available as an abbreviation definition. |
| 808 | * |
| 809 | * @since 2.5.1 |
| 810 | * |
| 811 | * @param array $t_time The published time. |
| 812 | * @param WP_Post $post Post object. |
| 813 | * @param string $column_name The column name. |
| 814 | * @param string $mode The list display mode ('excerpt' or 'list'). |
| 815 | */ |
| 816 | echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode ); |
| 817 | } else { |
768 | | $pad = str_repeat( '— ', $level ); |
769 | | echo "<strong>"; |
| 819 | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
| 820 | echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>'; |
| 821 | } |
| 822 | echo '<br />'; |
| 823 | if ( 'publish' == $post->post_status ) { |
| 824 | _e( 'Published' ); |
| 825 | } elseif ( 'future' == $post->post_status ) { |
| 826 | if ( $time_diff > 0 ) { |
| 827 | echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>'; |
| 828 | } else { |
| 829 | _e( 'Scheduled' ); |
| 830 | } |
| 831 | } else { |
| 832 | _e( 'Last Modified' ); |
| 833 | } |
| 834 | } |
774 | | echo '<a href="' . esc_url( add_query_arg( array( 'post_format' => $format, 'post_type' => $post->post_type ), 'edit.php' ) ) . '" class="post-state-format post-format-icon post-format-' . $format . '" title="' . $label . '">' . $label . ":</a> "; |
| 847 | $this->comments_bubble( $post->ID, $pending_comments ); |
| 848 | ?> |
| 849 | </div> |
| 850 | <?php |
| 851 | } |
| 852 | |
| 853 | /** |
| 854 | * @since 4.3.0 |
| 855 | * |
| 856 | * @param WP_Post $post |
| 857 | */ |
| 858 | public function column_author( $post ) { |
| 859 | printf( '<a href="%s">%s</a>', |
| 860 | esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'author' => get_the_author_meta( 'ID' ) ), 'edit.php' )), |
| 861 | get_the_author() |
| 862 | ); |
| 863 | } |
| 864 | |
| 865 | /** |
| 866 | * @since 4.3.0 |
| 867 | * |
| 868 | * @param WP_Post $post |
| 869 | * @param string $column_name |
| 870 | */ |
| 871 | public function column_default( $post, $column_name ) { |
| 872 | if ( 'categories' == $column_name ) { |
| 873 | $taxonomy = 'category'; |
| 874 | } elseif ( 'tags' == $column_name ) { |
| 875 | $taxonomy = 'post_tag'; |
| 876 | } elseif ( 0 === strpos( $column_name, 'taxonomy-' ) ) { |
| 877 | $taxonomy = substr( $column_name, 9 ); |
| 878 | } else { |
| 879 | $taxonomy = false; |
| 880 | } |
| 881 | if ( $taxonomy ) { |
| 882 | $taxonomy_object = get_taxonomy( $taxonomy ); |
| 883 | $terms = get_the_terms( $post->ID, $taxonomy ); |
| 884 | if ( is_array( $terms ) ) { |
| 885 | $out = array(); |
| 886 | foreach ( $terms as $t ) { |
| 887 | $posts_in_term_qv = array(); |
| 888 | if ( 'post' != $post->post_type ) { |
| 889 | $posts_in_term_qv['post_type'] = $post->post_type; |
784 | | if ( isset( $parent_name ) ) |
785 | | echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ); |
| 898 | $out[] = sprintf( '<a href="%s">%s</a>', |
| 899 | esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
| 900 | esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
| 901 | ); |
| 902 | } |
| 903 | /* translators: used between list items, there is a space after the comma */ |
| 904 | echo join( __( ', ' ), $out ); |
| 905 | } else { |
| 906 | echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->not_found . '</span>'; |
| 907 | } |
| 908 | return; |
| 909 | } |
789 | | if ( $can_edit_post && $post->post_status != 'trash' ) { |
790 | | if ( $lock_holder ) { |
791 | | $locked_avatar = get_avatar( $lock_holder->ID, 18 ); |
792 | | $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) ); |
793 | | } else { |
794 | | $locked_avatar = $locked_text = ''; |
795 | | } |
| 913 | /** |
| 914 | * Fires in each custom column on the Posts list table. |
| 915 | * |
| 916 | * This hook only fires if the current post type is hierarchical, |
| 917 | * such as pages. |
| 918 | * |
| 919 | * @since 2.5.0 |
| 920 | * |
| 921 | * @param string $column_name The name of the column to display. |
| 922 | * @param int $post_id The current post ID. |
| 923 | */ |
| 924 | do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
| 925 | } else { |
800 | | if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) ) |
801 | | the_excerpt(); |
| 941 | /** |
| 942 | * Fires for each custom column of a specific post type in the Posts list table. |
| 943 | * |
| 944 | * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
| 945 | * |
| 946 | * @since 3.1.0 |
| 947 | * |
| 948 | * @param string $column_name The name of the column to display. |
| 949 | * @param int $post_id The current post ID. |
| 950 | */ |
| 951 | do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
| 952 | } |
806 | | case 'date': |
807 | | if ( '0000-00-00 00:00:00' == $post->post_date ) { |
808 | | $t_time = $h_time = __( 'Unpublished' ); |
809 | | $time_diff = 0; |
810 | | } else { |
811 | | $t_time = get_the_time( __( 'Y/m/d g:i:s a' ) ); |
812 | | $m_time = $post->post_date; |
813 | | $time = get_post_time( 'G', true, $post ); |
| 962 | foreach ( $columns as $column_name => $column_display_name ) { |
| 963 | $classes = "$column_name column-$column_name"; |
| 964 | if ( $primary === $column_name ) { |
| 965 | $classes .= ' has-row-actions column-primary'; |
| 966 | } |
825 | | /** |
826 | | * Filter the published time of the post. |
827 | | * |
828 | | * If $mode equals 'excerpt', the published time and date are both displayed. |
829 | | * If $mode equals 'list' (default), the publish date is displayed, with the |
830 | | * time and date together available as an abbreviation definition. |
831 | | * |
832 | | * @since 2.5.1 |
833 | | * |
834 | | * @param array $t_time The published time. |
835 | | * @param WP_Post $post Post object. |
836 | | * @param string $column_name The column name. |
837 | | * @param string $mode The list display mode ('excerpt' or 'list'). |
838 | | */ |
839 | | echo apply_filters( 'post_date_column_time', $t_time, $post, $column_name, $mode ); |
840 | | } else { |
| 978 | if ( 'cb' === $column_name ) { |
| 979 | $this->column_cb( $item ); |
| 980 | } else { |
| 981 | echo "<td $attributes>"; |
842 | | /** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */ |
843 | | echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, $column_name, $mode ) . '</abbr>'; |
844 | | } |
845 | | echo '<br />'; |
846 | | if ( 'publish' == $post->post_status ) { |
847 | | _e( 'Published' ); |
848 | | } elseif ( 'future' == $post->post_status ) { |
849 | | if ( $time_diff > 0 ) |
850 | | echo '<strong class="attention">' . __( 'Missed schedule' ) . '</strong>'; |
851 | | else |
852 | | _e( 'Scheduled' ); |
853 | | } else { |
854 | | _e( 'Last Modified' ); |
855 | | } |
856 | | break; |
| 983 | if ( method_exists( $this, 'column_' . $column_name ) ) { |
| 984 | call_user_func( array( $this, 'column_' . $column_name ), $item ); |
| 985 | } else { |
| 986 | $this->column_default( $item, $column_name ); |
| 987 | } |
887 | | if ( $taxonomy ) { |
888 | | $taxonomy_object = get_taxonomy( $taxonomy ); |
889 | | $terms = get_the_terms( $post->ID, $taxonomy ); |
890 | | if ( is_array( $terms ) ) { |
891 | | $out = array(); |
892 | | foreach ( $terms as $t ) { |
893 | | $posts_in_term_qv = array(); |
894 | | if ( 'post' != $post->post_type ) |
895 | | $posts_in_term_qv['post_type'] = $post->post_type; |
896 | | if ( $taxonomy_object->query_var ) { |
897 | | $posts_in_term_qv[ $taxonomy_object->query_var ] = $t->slug; |
898 | | } else { |
899 | | $posts_in_term_qv['taxonomy'] = $taxonomy; |
900 | | $posts_in_term_qv['term'] = $t->slug; |
901 | | } |
| 1010 | $classes = 'iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' ); |
903 | | $out[] = sprintf( '<a href="%s">%s</a>', |
904 | | esc_url( add_query_arg( $posts_in_term_qv, 'edit.php' ) ), |
905 | | esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) |
906 | | ); |
907 | | } |
908 | | /* translators: used between list items, there is a space after the comma */ |
909 | | echo join( __( ', ' ), $out ); |
910 | | } else { |
911 | | echo '<span aria-hidden="true">—</span><span class="screen-reader-text">' . $taxonomy_object->labels->not_found . '</span>'; |
912 | | } |
913 | | break; |
914 | | } |
| 1012 | $lock_holder = wp_check_post_lock( $post->ID ); |
| 1013 | if ( $lock_holder ) { |
| 1014 | $classes .= ' wp-locked'; |
| 1015 | $lock_holder = get_userdata( $lock_holder ); |
| 1016 | } |
916 | | if ( is_post_type_hierarchical( $post->post_type ) ) { |
917 | | |
918 | | /** |
919 | | * Fires in each custom column on the Posts list table. |
920 | | * |
921 | | * This hook only fires if the current post type is hierarchical, |
922 | | * such as pages. |
923 | | * |
924 | | * @since 2.5.0 |
925 | | * |
926 | | * @param string $column_name The name of the column to display. |
927 | | * @param int $post_id The current post ID. |
928 | | */ |
929 | | do_action( 'manage_pages_custom_column', $column_name, $post->ID ); |
930 | | } else { |
931 | | |
932 | | /** |
933 | | * Fires in each custom column in the Posts list table. |
934 | | * |
935 | | * This hook only fires if the current post type is non-hierarchical, |
936 | | * such as posts. |
937 | | * |
938 | | * @since 1.5.0 |
939 | | * |
940 | | * @param string $column_name The name of the column to display. |
941 | | * @param int $post_id The current post ID. |
942 | | */ |
943 | | do_action( 'manage_posts_custom_column', $column_name, $post->ID ); |
944 | | } |
945 | | |
946 | | /** |
947 | | * Fires for each custom column of a specific post type in the Posts list table. |
948 | | * |
949 | | * The dynamic portion of the hook name, `$post->post_type`, refers to the post type. |
950 | | * |
951 | | * @since 3.1.0 |
952 | | * |
953 | | * @param string $column_name The name of the column to display. |
954 | | * @param int $post_id The current post ID. |
955 | | */ |
956 | | do_action( "manage_{$post->post_type}_posts_custom_column", $column_name, $post->ID ); |
957 | | break; |
958 | | } |
959 | | |
960 | | echo $this->handle_row_actions( $post, $column_name, $primary ); |
961 | | echo '</td>'; |
962 | | } |
| 1018 | if ( $post->post_parent ) { |
| 1019 | $count = count( get_post_ancestors( $post->ID ) ); |
| 1020 | $classes .= ' level-'. $count; |
| 1021 | } else { |
| 1022 | $classes .= ' level-0'; |