]> scripts.mit.edu Git - autoinstalls/wordpress.git/blobdiff - wp-admin/includes/class-wp-posts-list-table.php
Wordpress 3.7
[autoinstalls/wordpress.git] / wp-admin / includes / class-wp-posts-list-table.php
index c772fa63c977a9c7d9866011c50193323e7802ef..016a726b74b1270709ae84a1ae1258c3a7b6133f 100644 (file)
@@ -57,9 +57,10 @@ class WP_Posts_List_Table extends WP_List_Table {
                $post_type_object = get_post_type_object( $post_type );
 
                if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
                $post_type_object = get_post_type_object( $post_type );
 
                if ( !current_user_can( $post_type_object->cap->edit_others_posts ) ) {
+                       $exclude_states = get_post_stati( array( 'show_in_admin_all_list' => false ) );
                        $this->user_posts_count = $wpdb->get_var( $wpdb->prepare( "
                                SELECT COUNT( 1 ) FROM $wpdb->posts
                        $this->user_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' )
+                               WHERE post_type = %s AND post_status NOT IN ( '" . implode( "','", $exclude_states ) . "' )
                                AND post_author = %d
                        ", $post_type, get_current_user_id() ) );
 
                                AND post_author = %d
                        ", $post_type, get_current_user_id() ) );
 
@@ -69,7 +70,7 @@ class WP_Posts_List_Table extends WP_List_Table {
 
                if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
                        $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
 
                if ( 'post' == $post_type && $sticky_posts = get_option( 'sticky_posts' ) ) {
                        $sticky_posts = implode( ', ', array_map( 'absint', (array) $sticky_posts ) );
-                       $this->sticky_posts_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT( 1 ) FROM $wpdb->posts WHERE post_type = %s AND post_status != 'trash' AND ID IN ($sticky_posts)", $post_type ) );
+                       $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 ) );
                }
        }
 
                }
        }
 
@@ -382,8 +383,10 @@ class WP_Posts_List_Table extends WP_List_Table {
                        if ( $count >= $end )
                                break;
 
                        if ( $count >= $end )
                                break;
 
-                       if ( $count >= $start )
-                               echo "\t" . $this->single_row( $page, $level );
+                       if ( $count >= $start ) {
+                               echo "\t";
+                               $this->single_row( $page, $level );
+                       }
 
                        $count++;
 
 
                        $count++;
 
@@ -397,8 +400,12 @@ class WP_Posts_List_Table extends WP_List_Table {
                                foreach ( $orphans as $op ) {
                                        if ( $count >= $end )
                                                break;
                                foreach ( $orphans as $op ) {
                                        if ( $count >= $end )
                                                break;
-                                       if ( $count >= $start )
-                                               echo "\t" . $this->single_row( $op, 0 );
+
+                                       if ( $count >= $start ) {
+                                               echo "\t";
+                                               $this->single_row( $op, 0 );
+                                       }
+
                                        $count++;
                                }
                        }
                                        $count++;
                                }
                        }
@@ -411,12 +418,12 @@ class WP_Posts_List_Table extends WP_List_Table {
         *
         * @since 3.1.0 (Standalone function exists since 2.6.0)
         *
         *
         * @since 3.1.0 (Standalone function exists since 2.6.0)
         *
-        * @param unknown_type $children_pages
-        * @param unknown_type $count
-        * @param unknown_type $parent
-        * @param unknown_type $level
-        * @param unknown_type $pagenum
-        * @param unknown_type $per_page
+        * @param array $children_pages
+        * @param int $count
+        * @param int $parent
+        * @param int $level
+        * @param int $pagenum
+        * @param int $per_page
         */
        function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
 
         */
        function _page_rows( &$children_pages, &$count, $parent, $level, $pagenum, $per_page ) {
 
@@ -444,13 +451,16 @@ class WP_Posts_List_Table extends WP_List_Table {
                                }
                                $num_parents = count( $my_parents );
                                while ( $my_parent = array_pop( $my_parents ) ) {
                                }
                                $num_parents = count( $my_parents );
                                while ( $my_parent = array_pop( $my_parents ) ) {
-                                       echo "\t" . $this->single_row( $my_parent, $level - $num_parents );
+                                       echo "\t";
+                                       $this->single_row( $my_parent, $level - $num_parents );
                                        $num_parents--;
                                }
                        }
 
                                        $num_parents--;
                                }
                        }
 
-                       if ( $count >= $start )
-                               echo "\t" . $this->single_row( $page, $level );
+                       if ( $count >= $start ) {
+                               echo "\t";
+                               $this->single_row( $page, $level );
+                       }
 
                        $count++;
 
 
                        $count++;
 
@@ -471,10 +481,16 @@ class WP_Posts_List_Table extends WP_List_Table {
                $edit_link = get_edit_post_link( $post->ID );
                $title = _draft_or_post_title();
                $post_type_object = get_post_type_object( $post->post_type );
                $edit_link = get_edit_post_link( $post->ID );
                $title = _draft_or_post_title();
                $post_type_object = get_post_type_object( $post->post_type );
-               $can_edit_post = current_user_can( $post_type_object->cap->edit_post, $post->ID );
+               $can_edit_post = current_user_can( 'edit_post', $post->ID );
 
                $alternate = 'alternate' == $alternate ? '' : 'alternate';
                $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
 
                $alternate = 'alternate' == $alternate ? '' : 'alternate';
                $classes = $alternate . ' iedit author-' . ( get_current_user_id() == $post->post_author ? 'self' : 'other' );
+
+               $lock_holder = wp_check_post_lock( $post->ID );
+               if ( $lock_holder ) {
+                       $classes .= ' wp-locked';
+                       $lock_holder = get_userdata( $lock_holder );
+               }
        ?>
                <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
        <?php
        ?>
                <tr id="post-<?php echo $post->ID; ?>" class="<?php echo implode( ' ', get_post_class( $classes, $post->ID ) ); ?>" valign="top">
        <?php
@@ -495,18 +511,23 @@ class WP_Posts_List_Table extends WP_List_Table {
                        case 'cb':
                        ?>
                        <th scope="row" class="check-column">
                        case 'cb':
                        ?>
                        <th scope="row" class="check-column">
-                               <?php if ( $can_edit_post ) { ?>
+                               <?php
+                               if ( $can_edit_post ) {
+
+                               ?>
                                <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
                                <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
                                <label class="screen-reader-text" for="cb-select-<?php the_ID(); ?>"><?php printf( __( 'Select %s' ), $title ); ?></label>
                                <input id="cb-select-<?php the_ID(); ?>" type="checkbox" name="post[]" value="<?php the_ID(); ?>" />
-                               <?php } ?>
+                               <div class="locked-indicator"></div>
+                               <?php
+                               }
+                               ?>
                        </th>
                        <?php
                        break;
 
                        case 'title':
                        </th>
                        <?php
                        break;
 
                        case 'title':
+                               $attributes = 'class="post-title page-title column-title"' . $style;
                                if ( $this->hierarchical_display ) {
                                if ( $this->hierarchical_display ) {
-                                       $attributes = 'class="post-title page-title column-title"' . $style;
-
                                        if ( 0 == $level && (int) $post->post_parent > 0 ) {
                                                //sent level 0 by accident, by default, or because we don't know the actual level
                                                $find_main_page = (int) $post->post_parent;
                                        if ( 0 == $level && (int) $post->post_parent > 0 ) {
                                                //sent level 0 by accident, by default, or because we don't know the actual level
                                                $find_main_page = (int) $post->post_parent;
@@ -519,33 +540,55 @@ class WP_Posts_List_Table extends WP_List_Table {
                                                        $level++;
                                                        $find_main_page = (int) $parent->post_parent;
 
                                                        $level++;
                                                        $find_main_page = (int) $parent->post_parent;
 
-                                                       if ( !isset( $parent_name ) )
+                                                       if ( !isset( $parent_name ) ) {
+                                                               /** This filter is documented in wp-includes/post-template.php */
                                                                $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
                                                                $parent_name = apply_filters( 'the_title', $parent->post_title, $parent->ID );
+                                                       }
                                                }
                                        }
                                                }
                                        }
+                               }
 
 
-                                       $pad = str_repeat( '&#8212; ', $level );
-?>
-                       <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); echo isset( $parent_name ) ? ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name ) : ''; ?></strong>
-<?php
+                               $pad = str_repeat( '&#8212; ', $level );
+                               echo "<td $attributes><strong>";
+
+                               if ( $format = get_post_format( $post->ID ) ) {
+                                       $label = get_post_format_string( $format );
+
+                                       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> ";
                                }
                                }
-                               else {
-                                       $attributes = 'class="post-title page-title column-title"' . $style;
 
 
-                                       $pad = str_repeat( '&#8212; ', $level );
-?>
-                       <td <?php echo $attributes ?>><strong><?php if ( $can_edit_post && $post->post_status != 'trash' ) { ?><a class="row-title" href="<?php echo $edit_link; ?>" title="<?php echo esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ); ?>"><?php echo $pad; echo $title ?></a><?php } else { echo $pad; echo $title; }; _post_states( $post ); ?></strong>
-<?php
-                                       if ( 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
-                                               the_excerpt();
+                               if ( $can_edit_post && $post->post_status != 'trash' ) {
+                                       echo '<a class="row-title" href="' . $edit_link . '" title="' . esc_attr( sprintf( __( 'Edit &#8220;%s&#8221;' ), $title ) ) . '">' . $pad . $title . '</a>';
+                               } else {
+                                       echo $pad . $title;
                                }
                                }
+                               _post_states( $post );
+
+                               if ( isset( $parent_name ) )
+                                       echo ' | ' . $post_type_object->labels->parent_item_colon . ' ' . esc_html( $parent_name );
+
+                               echo "</strong>\n";
+
+                               if ( $can_edit_post && $post->post_status != 'trash' ) {
+                                       if ( $lock_holder ) {
+                                               $locked_avatar = get_avatar( $lock_holder->ID, 18 );
+                                               $locked_text = esc_html( sprintf( __( '%s is currently editing' ), $lock_holder->display_name ) );
+                                       } else {
+                                               $locked_avatar = $locked_text = '';
+                                       }
+
+                                       echo '<div class="locked-info"><span class="locked-avatar">' . $locked_avatar . '</span> <span class="locked-text">' . $locked_text . "</span></div>\n";
+                               }
+
+                               if ( ! $this->hierarchical_display && 'excerpt' == $mode && current_user_can( 'read_post', $post->ID ) )
+                                               the_excerpt();
 
                                $actions = array();
                                if ( $can_edit_post && 'trash' != $post->post_status ) {
                                        $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
                                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
                                }
 
                                $actions = array();
                                if ( $can_edit_post && 'trash' != $post->post_status ) {
                                        $actions['edit'] = '<a href="' . get_edit_post_link( $post->ID, true ) . '" title="' . esc_attr( __( 'Edit this item' ) ) . '">' . __( 'Edit' ) . '</a>';
                                        $actions['inline hide-if-no-js'] = '<a href="#" class="editinline" title="' . esc_attr( __( 'Edit this item inline' ) ) . '">' . __( 'Quick&nbsp;Edit' ) . '</a>';
                                }
-                               if ( current_user_can( $post_type_object->cap->delete_post, $post->ID ) ) {
+                               if ( current_user_can( 'delete_post', $post->ID ) ) {
                                        if ( 'trash' == $post->post_status )
                                                $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
                                        elseif ( EMPTY_TRASH_DAYS )
                                        if ( 'trash' == $post->post_status )
                                                $actions['untrash'] = "<a title='" . esc_attr( __( 'Restore this item from the Trash' ) ) . "' href='" . wp_nonce_url( admin_url( sprintf( $post_type_object->_edit_link . '&amp;action=untrash', $post->ID ) ), 'untrash-post_' . $post->ID ) . "'>" . __( 'Restore' ) . "</a>";
                                        elseif ( EMPTY_TRASH_DAYS )
@@ -556,7 +599,7 @@ class WP_Posts_List_Table extends WP_List_Table {
                                if ( $post_type_object->public ) {
                                        if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
                                                if ( $can_edit_post )
                                if ( $post_type_object->public ) {
                                        if ( in_array( $post->post_status, array( 'pending', 'draft', 'future' ) ) ) {
                                                if ( $can_edit_post )
-                                                       $actions['view'] = '<a href="' . esc_url( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
+                                                       $actions['view'] = '<a href="' . esc_url( apply_filters( 'preview_post_link', set_url_scheme( add_query_arg( 'preview', 'true', get_permalink( $post->ID ) ) ) ) ) . '" title="' . esc_attr( sprintf( __( 'Preview &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'Preview' ) . '</a>';
                                        } elseif ( 'trash' != $post->post_status ) {
                                                $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
                                        }
                                        } elseif ( 'trash' != $post->post_status ) {
                                                $actions['view'] = '<a href="' . get_permalink( $post->ID ) . '" title="' . esc_attr( sprintf( __( 'View &#8220;%s&#8221;' ), $title ) ) . '" rel="permalink">' . __( 'View' ) . '</a>';
                                        }
@@ -820,10 +863,7 @@ class WP_Posts_List_Table extends WP_List_Table {
 
        <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
 
 
        <?php foreach ( $hierarchical_taxonomies as $taxonomy ) : ?>
 
-                       <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?>
-                               <span class="catshow"><?php _e( '[more]' ); ?></span>
-                               <span class="cathide" style="display:none;"><?php _e( '[less]' ); ?></span>
-                       </span>
+                       <span class="title inline-edit-categories-label"><?php echo esc_html( $taxonomy->labels->name ) ?></span>
                        <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
                        <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
                                <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
                        <input type="hidden" name="<?php echo ( $taxonomy->name == 'category' ) ? 'post_category[]' : 'tax_input[' . esc_attr( $taxonomy->name ) . '][]'; ?>" value="0" />
                        <ul class="cat-checklist <?php echo esc_attr( $taxonomy->name )?>-checklist">
                                <?php wp_terms_checklist( null, array( 'taxonomy' => $taxonomy->name ) ) ?>
@@ -998,30 +1038,31 @@ class WP_Posts_List_Table extends WP_List_Table {
 
                        </div>
 
 
                        </div>
 
-       <?php if ( post_type_supports( $screen->post_type, 'post-formats' ) && current_theme_supports( 'post-formats' ) ) :
-               $post_formats = get_theme_support( 'post-formats' );
-               if ( isset( $post_formats[0] ) && is_array( $post_formats[0] ) ) :
-                       $all_post_formats = get_post_format_strings();
-                       unset( $all_post_formats['standard'] ); ?>
-                       <div class="inline-edit-group">
-                               <label class="alignleft" for="post_format">
-                               <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
-                               <select name="post_format">
-                               <?php if ( $bulk ) : ?>
-                                       <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
-                               <?php endif; ?>
-                                       <option value="0"><?php _ex( 'Standard', 'Post format' ); ?></option>
-                               <?php foreach ( $all_post_formats as $slug => $format ) :
-                                       $unsupported = ! in_array( $slug, $post_formats[0] );
-                                       if ( $bulk && $unsupported )
-                                               continue;
-                                       ?>
-                                       <option value="<?php echo esc_attr( $slug ); ?>"<?php if ( $unsupported ) echo ' class="unsupported"'; ?>><?php echo esc_html( $format ); ?></option>
-                               <?php endforeach; ?>
-                               </select></label>
-                       </div>
-               <?php endif; ?>
-       <?php endif; // post-formats ?>
+       <?php
+
+       if ( $bulk && post_type_supports( $screen->post_type, 'post-formats' ) ) {
+               $all_post_formats = get_post_format_strings();
+
+               ?>
+               <label class="alignleft" for="post_format">
+               <span class="title"><?php _ex( 'Format', 'post format' ); ?></span>
+               <select name="post_format">
+                       <option value="-1"><?php _e( '&mdash; No Change &mdash;' ); ?></option>
+                       <?php
+
+                       foreach ( $all_post_formats as $slug => $format ) {
+                               ?>
+                               <option value="<?php echo esc_attr( $slug ); ?>"><?php echo esc_html( $format ); ?></option>
+                               <?php
+                       }
+
+                       ?>
+               </select></label>
+       <?php
+
+       }
+
+       ?>
 
                </div></fieldset>
 
 
                </div></fieldset>
 
@@ -1035,18 +1076,20 @@ class WP_Posts_List_Table extends WP_List_Table {
                }
        ?>
                <p class="submit inline-edit-save">
                }
        ?>
                <p class="submit inline-edit-save">
-                       <a accesskey="c" href="#inline-edit" title="<?php esc_attr_e( 'Cancel' ); ?>" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
+                       <a accesskey="c" href="#inline-edit" class="button-secondary cancel alignleft"><?php _e( 'Cancel' ); ?></a>
                        <?php if ( ! $bulk ) {
                                wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
                        <?php if ( ! $bulk ) {
                                wp_nonce_field( 'inlineeditnonce', '_inline_edit', false );
-                               $update_text = __( 'Update' );
                                ?>
                                ?>
-                               <a accesskey="s" href="#inline-edit" title="<?php esc_attr_e( 'Update' ); ?>" class="button-primary save alignright"><?php echo esc_attr( $update_text ); ?></a>
+                               <a accesskey="s" href="#inline-edit" class="button-primary save alignright"><?php _e( 'Update' ); ?></a>
                                <span class="spinner"></span>
                        <?php } else {
                                submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
                        } ?>
                        <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
                        <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
                                <span class="spinner"></span>
                        <?php } else {
                                submit_button( __( 'Update' ), 'button-primary alignright', 'bulk_edit', false, array( 'accesskey' => 's' ) );
                        } ?>
                        <input type="hidden" name="post_view" value="<?php echo esc_attr( $m ); ?>" />
                        <input type="hidden" name="screen" value="<?php echo esc_attr( $screen->id ); ?>" />
+                       <?php if ( ! $bulk && ! post_type_supports( $screen->post_type, 'author' ) ) { ?>
+                               <input type="hidden" name="post_author" value="<?php echo esc_attr( $post->post_author ); ?>" />
+                       <?php } ?>
                        <span class="error" style="display:none"></span>
                        <br class="clear" />
                </p>
                        <span class="error" style="display:none"></span>
                        <br class="clear" />
                </p>