Permalink
Browse files

Use show_admin_column for taxonomies.

Introduced in 3.5, the show_admin_column option cuts down on the amount
of extra code we would otherwise need to render these columns in the
administrative interface.
  • Loading branch information...
1 parent 1479c84 commit 1134ddff62f8428d6539b0a3420e841e154c86cf Michael Sisk committed Feb 4, 2013
Showing with 13 additions and 55 deletions.
  1. +4 −34 -/php/posts.php
  2. +3 −18 -/php/transcripts.php
  3. +6 −3 webcomic.php
View
@@ -368,36 +368,6 @@ public function manage_webcomic_posts_custom_column( $column, $id ) {
} else {
_e( '—', 'webcomic' );
}
- } elseif ( 'webcomic_storylines' === $column ) {
- if ( $storylines = wp_get_object_terms( $id, "{$post->post_type}_storyline" ) ) {
- $terms = array();
-
- foreach ( $storylines as $storyline ) {
- $terms[] = sprintf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, "{$post->post_type}_storyline" => $storyline->slug ), admin_url( 'edit.php' ) ) ),
- esc_html( sanitize_term_field( 'name', $storyline->name, $storyline->term_id, "{$post->post_type}_storyline", 'display' ) )
- );
- }
-
- echo join( ', ', $terms );
- } else {
- _e( '&mdash;', 'webcomic' );
- }
- } elseif ( 'webcomic_characters' === $column ) {
- if ( $characters = wp_get_object_terms( $id, "{$post->post_type}_character" ) ) {
- $terms = array();
-
- foreach ( $characters as $character ) {
- $terms[] = sprintf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, "{$post->post_type}_character" => $character->slug ), admin_url( 'edit.php' ) ) ),
- esc_html( sanitize_term_field( 'name', $character->name, $character->term_id, "{$post->post_type}_character", 'display' ) )
- );
- }
-
- echo join( ', ', $terms );
- } else {
- _e( '&mdash;', 'webcomic' );
- }
}
}
@@ -438,13 +408,13 @@ public function view_edit_webcomic( $views ) {
*/
public function manage_edit_webcomic_columns( $columns ) {
$pre = array_slice( $columns, 0, 1 );
- $mid = array_slice( $columns, 1, 2 );
+ //$mid = array_slice( $columns, 1, 2 );
$pre[ 'webcomic_attachments' ] = '';
- $mid[ 'webcomic_storylines' ] = __( 'Storylines', 'webcomic' );
- $mid[ 'webcomic_characters' ] = __( 'Characters', 'webcomic' );
+ $columns[ "taxonomy-{$_GET[ 'post_type' ]}_character" ] = __( 'Characters', 'webcomic' );
+ $columns[ "taxonomy-{$_GET[ 'post_type' ]}_storyline" ] = __( 'Storylines', 'webcomic' );
- return array_merge( $pre, $mid, $columns );
+ return array_merge( $pre, $columns );
}
/** Render the webcomic media meta box.
View
@@ -253,21 +253,6 @@ public function manage_webcomic_transcript_posts_custom_column( $column, $id ) {
}
echo join( ', ', $authors );
- } elseif ( 'webcomic_languages' === $column ) {
- if ( $languages = wp_get_object_terms( $id, 'webcomic_language' ) ) {
- $terms = array();
-
- foreach ( $languages as $language ) {
- $terms[] = sprintf( '<a href="%s">%s</a>',
- esc_url( add_query_arg( array( 'post_type' => $post->post_type, 'webcomic_language' => $language->slug ), admin_url( 'edit.php' ) ) ),
- esc_html( sanitize_term_field( 'name', $language->name, $language->term_id, 'webcomic_language', 'display' ) )
- );
- }
-
- echo join( ', ', $terms );
- } else {
- _e( 'No Languages', 'webcomic' );
- }
} elseif ( 'webcomic_parent' === $column ) {
echo $post->post_parent ? sprintf( '<strong><a href="%s">%s</a> - %s</strong>, %s',
esc_url( add_query_arg( array( 'post_type' => get_post_type( $post->post_parent ) ), admin_url( 'edit.php' ) ) ),
@@ -371,9 +356,9 @@ public function manage_edit_webcomic_transcript_columns( $columns ) {
$pre = array_slice( $columns, 0, 2 );
- $pre[ 'webcomic_author' ] = __( 'Author', 'webcomic' );
- $pre[ 'webcomic_languages' ] = __( 'Languages', 'webcomic' );
- $pre[ 'webcomic_parent' ] = __( 'Webcomic', 'webcomic' );
+ $pre[ 'webcomic_author' ] = __( 'Author', 'webcomic' );
+ $pre[ 'webcomic_parent' ] = __( 'Webcomic', 'webcomic' );
+ $columns[ 'taxonomy-webcomic_language' ] = __( 'Languages', 'webcomic' );
return array_merge( $pre, $columns );
}
View
@@ -29,7 +29,7 @@
/** Comic Publishing Power for the Web
*
- * @todo Future Bulk media actions; see core.trac.wordpress.org/ticket/16031
+ * @todo core.trac.wordpress.org/ticket/16031
*
* @package Webcomic
* @copyright 2008 - 2013 Michael Sisk
@@ -239,6 +239,7 @@ public function init() {
'menu_name' => __( 'Storylines', 'webcomic' )
),
'hierarchical' => true,
+ 'show_admin_column' => true,
'rewrite' => array(
'slug' => $v[ 'slugs' ][ 'storyline' ],
'with_front' => false,
@@ -262,6 +263,7 @@ public function init() {
'choose_from_most_used' => __( 'Choose from the most used characters', 'webcomic' ),
'menu_name' => __( 'Characters', 'webcomic' )
),
+ 'show_admin_column' => true,
'rewrite' => array(
'slug' => $v[ 'slugs' ][ 'character' ],
'with_front' => false
@@ -307,7 +309,8 @@ public function init() {
'menu_name' => __( 'Languages', 'webcomic' )
),
'rewrite' => false,
- 'show_in_nav_menus' => false
+ 'show_in_nav_menus' => false,
+ 'show_admin_column' => true
) );
}
@@ -1210,7 +1213,7 @@ public function get_the_terms( $terms, $id, $taxonomy ) {
/** Handle custom permalink tokens.
*
- * @todo Future: Use get_term_parents; see core.trac.wordpress.org/ticket/17069
+ * @todo Use get_term_parents; see core.trac.wordpress.org/ticket/17069
*
* @param string $link Permalink to swap tokens in.
* @param object $post Post object.

0 comments on commit 1134ddf

Please sign in to comment.