Ticket #21240: 21240.3.diff

File 21240.3.diff, 8.4 KB (added by jtsternberg, 10 months ago)

One more diff where I add the 'show_taxonomy_columns' taxonomies to an object variable for access in the other methods

  • wp-includes/post.php

     
    2727                'capability_type' => 'post', 
    2828                'map_meta_cap' => true, 
    2929                'hierarchical' => false, 
     30                'show_taxonomy_columns' => array( 'category', 'post_tag' ), 
    3031                'rewrite' => false, 
    3132                'query_var' => false, 
    3233                'delete_with_user' => true, 
     
    977978        $defaults = array( 
    978979                'labels' => array(), 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, 
    979980                'capability_type' => 'post', 'capabilities' => array(), 'map_meta_cap' => null, 
    980                 '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 
     981                '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'hierarchical' => false, 'show_taxonomy_columns' => false, 
    981982                'public' => false, 'rewrite' => true, 'has_archive' => false, 'query_var' => true, 
    982983                'supports' => array(), 'register_meta_box_cb' => null, 
    983984                'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 
     
    12851286        if ( !isset( $object->labels['all_items'] ) && isset( $object->labels['menu_name'] ) ) 
    12861287                $object->labels['all_items'] = $object->labels['menu_name']; 
    12871288 
     1289        if ( !isset( $object->labels['no_items'] ) && isset( $object->labels['menu_name'] ) ) 
     1290                $object->labels['no_items'] = 'No ' . $object->labels['menu_name']; 
     1291 
    12881292        foreach ( $nohier_vs_hier_defaults as $key => $value ) 
    12891293                        $defaults[$key] = $object->hierarchical ? $value[1] : $value[0]; 
    12901294 
  • wp-includes/taxonomy.php

     
    4343 
    4444        register_taxonomy( 'category', 'post', array( 
    4545                'hierarchical' => true, 
     46                'labels' => array( 
     47                        'no_items' => __( 'Uncategorized' ), 
     48                ), 
    4649                'query_var' => 'category_name', 
    4750                'rewrite' => $rewrite['category'], 
    4851                'public' => true, 
     
    416419                'search_items' => array( __( 'Search Tags' ), __( 'Search Categories' ) ), 
    417420                'popular_items' => array( __( 'Popular Tags' ), null ), 
    418421                'all_items' => array( __( 'All Tags' ), __( 'All Categories' ) ), 
     422                'no_items' => array( __( 'No Tags' ), __( 'No Categories' ) ), 
    419423                'parent_item' => array( null, __( 'Parent Category' ) ), 
    420424                'parent_item_colon' => array( null, __( 'Parent Category:' ) ), 
    421425                'edit_item' => array( __( 'Edit Tag' ), __( 'Edit Category' ) ), 
  • wp-admin/includes/class-wp-posts-list-table.php

     
    270270                        $posts_columns['author'] = __( 'Author' ); 
    271271 
    272272                if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'category' ) ) 
    273                         $posts_columns['categories'] = __( 'Categories' ); 
     273                        $posts_columns['category'] = __( 'Categories' ); 
    274274 
    275275                if ( empty( $post_type ) || is_object_in_taxonomy( $post_type, 'post_tag' ) ) 
    276                         $posts_columns['tags'] = __( 'Tags' ); 
     276                        $posts_columns['post_tag'] = __( 'Tags' ); 
    277277 
    278278                $post_status = !empty( $_REQUEST['post_status'] ) ? $_REQUEST['post_status'] : 'all'; 
    279279                if ( post_type_supports( $post_type, 'comments' ) && !in_array( $post_status, array( 'pending', 'draft', 'future' ) ) ) 
     
    287287                        $posts_columns = apply_filters( 'manage_posts_columns', $posts_columns, $post_type ); 
    288288                $posts_columns = apply_filters( "manage_{$post_type}_posts_columns", $posts_columns ); 
    289289 
     290                if ( !empty( $post_type ) ) { 
     291                        $post_type_object = get_post_type_object( $post_type ); 
     292 
     293                        if ( $post_type_object->show_taxonomy_columns ) { 
     294 
     295                                if ( is_array( $post_type_object->show_taxonomy_columns ) ) 
     296                                                $taxonomies = $post_type_object->show_taxonomy_columns; 
     297                                else 
     298                                        $taxonomies = get_object_taxonomies( $post_type ); 
     299 
     300                                if ( empty( $taxonomies ) ) 
     301                                        return $posts_columns; 
     302                                $this->taxonomy_columns = $taxonomies; 
     303 
     304                                foreach ( $taxonomies as $registered_taxonomy ) { 
     305 
     306                                        if ( $registered_taxonomy == 'post_tag' || $registered_taxonomy == 'category' ) continue; 
     307 
     308                                        $taxonomy_object = get_taxonomy( $registered_taxonomy ); 
     309                                        $posts_columns[$registered_taxonomy] = apply_filters( 'taxonomy_column_header', __( $taxonomy_object->label ), $post_type_object, $taxonomy_object ); 
     310 
     311                                } 
     312                        } 
     313                } 
     314 
    290315                return $posts_columns; 
    291316        } 
    292317 
     
    529554                                } 
    530555                                else { 
    531556                                        $attributes = 'class="post-title page-title column-title"' . $style; 
    532                                          
    533557                                        $pad = str_repeat( '— ', $level ); 
    534558?> 
    535559                        <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> 
     
    603627                                echo '</td>'; 
    604628                        break; 
    605629 
    606                         case 'categories': 
    607                         ?> 
    608                         <td <?php echo $attributes ?>><?php 
    609                                 $categories = get_the_category(); 
    610                                 if ( !empty( $categories ) ) { 
    611                                         $out = array(); 
    612                                         foreach ( $categories as $c ) { 
    613                                                 $out[] = sprintf( '<a href="%s">%s</a>', 
    614                                                         esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'category_name' => $c->slug ), 'edit.php' ) ), 
    615                                                         esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'category', 'display' ) ) 
    616                                                 ); 
    617                                         } 
    618                                         /* translators: used between list items, there is a space after the comma */ 
    619                                         echo join( __( ', ' ), $out ); 
    620                                 } else { 
    621                                         _e( 'Uncategorized' ); 
    622                                 } 
    623                         ?></td> 
    624                         <?php 
    625                         break; 
     630                        case ( is_array( $this->taxonomy_columns ) && in_array( $column_name, $this->taxonomy_columns ) ) : 
    626631 
    627                         case 'tags': 
    628                         ?> 
    629                         <td <?php echo $attributes ?>><?php 
    630                                 $tags = get_the_tags( $post->ID ); 
    631                                 if ( !empty( $tags ) ) { 
    632                                         $out = array(); 
    633                                         foreach ( $tags as $c ) { 
    634                                                 $out[] = sprintf( '<a href="%s">%s</a>', 
    635                                                         esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'tag' => $c->slug ), 'edit.php' ) ), 
    636                                                         esc_html( sanitize_term_field( 'name', $c->name, $c->term_id, 'tag', 'display' ) ) 
    637                                                 ); 
    638                                         } 
    639                                         /* translators: used between list items, there is a space after the comma */ 
    640                                         echo join( __( ', ' ), $out ); 
    641                                 } else { 
    642                                         _e( 'No Tags' ); 
    643                                 } 
    644                         ?></td> 
    645                         <?php 
     632                        $defaults = array( 
     633                                'taxonomy' => $column_name, 
     634                                'attributes' => $attributes, 
     635                        ); 
     636                        $args = apply_filters( 'taxonomy_column_args', $defaults, $post_type_object, $column_name  ); 
     637 
     638                        $this->taxonomy_column( $args ); 
    646639                        break; 
    647640 
    648641                        case 'comments': 
     
    679672                        ?></td> 
    680673                        <?php 
    681674                        break; 
     675                        } 
    682676                } 
    683         } 
    684677        ?> 
    685678                </tr> 
    686679        <?php 
     
    688681        } 
    689682 
    690683        /** 
     684         * Creates internal taxonomy columns as well as registered taxonomies 
     685         * 
     686         * @since 3.5.0 
     687         */ 
     688        function taxonomy_column( $atts = array() ) { 
     689                global $post; 
     690 
     691                $defaults = array( 
     692                        'taxonomy' => 'category', 
     693                        'attributes' => '', 
     694                        'empty' => '', 
     695                ); 
     696                $args = wp_parse_args( (array) $atts, $defaults ); 
     697                extract( $args, EXTR_SKIP ); 
     698 
     699                $attributes = !empty( $attributes ) ? $attributes : 'class="column-'. $taxonomy .'"'; 
     700                $taxonomy_object = get_taxonomy( $taxonomy ); 
     701 
     702                ?> 
     703                <td <?php echo $attributes ?>><?php 
     704                        $terms = get_the_terms( $post->ID, $taxonomy ); 
     705                        if ( !empty( $terms ) ) { 
     706                                $out = array(); 
     707                                foreach ( $terms as $t ) { 
     708                                        $out[] = sprintf( '<a href="%s">%s</a>', 
     709                                                esc_url( add_query_arg( array( 'post_type' => $post->post_type, $taxonomy_object->query_var => $t->slug ), 'edit.php' ) ), 
     710                                                esc_html( sanitize_term_field( 'name', $t->name, $t->term_id, $taxonomy, 'display' ) ) 
     711                                        ); 
     712                                } 
     713                                /* translators: used between list items, there is a space after the comma */ 
     714                                echo join( __( ', ' ), $out ); 
     715                        } else { 
     716                                echo $taxonomy_object->labels->no_items; 
     717                        } 
     718                ?></td> 
     719                <?php 
     720        } 
     721 
     722        /** 
    691723         * Outputs the hidden row displayed when inline editing 
    692724         * 
    693725         * @since 3.1.0 
  • wp-admin/css/wp-admin.dev.css

     
    23502350 
    23512351.fixed .column-response, 
    23522352.fixed .column-author, 
    2353 .fixed .column-categories, 
    2354 .fixed .column-tags, 
     2353.fixed .column-category, 
     2354.fixed .column-post_tag, 
    23552355.fixed .column-rel, 
    23562356.fixed .column-role { 
    23572357        width: 15%;