From f8777553dc4707003183d40679421e201932ba64 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Thu, 1 Jan 2015 17:28:19 -0500 Subject: [PATCH] add featured image column to taxonomies also changed how hooks were called to use "{$taxonomy->name}_etc --- ...displayfeaturedimagegenesis-taxonomies.php | 40 ++++++++++++++++--- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-taxonomies.php b/includes/class-displayfeaturedimagegenesis-taxonomies.php index 4dc5d4d..97ff232 100644 --- a/includes/class-displayfeaturedimagegenesis-taxonomies.php +++ b/includes/class-displayfeaturedimagegenesis-taxonomies.php @@ -13,10 +13,13 @@ class Display_Featured_Image_Genesis_Taxonomies { $output = 'objects'; $taxonomies = get_taxonomies( $args, $output ); foreach ( $taxonomies as $taxonomy ) { - add_action( $taxonomy->name . '_add_form_fields', array( $this, 'add_taxonomy_meta_fields' ), 5, 2 ); - add_action( $taxonomy->name . '_edit_form_fields', array( $this, 'edit_taxonomy_meta_fields' ), 5, 2 ); - add_action( 'edited_' . $taxonomy->name, array( $this, 'save_taxonomy_custom_meta' ), 10, 2 ); - add_action( 'create_' . $taxonomy->name, array( $this, 'save_taxonomy_custom_meta' ), 10, 2 ); + add_action( "{$taxonomy->name}_add_form_fields", array( $this, 'add_taxonomy_meta_fields' ), 5, 2 ); + add_action( "{$taxonomy->name}_edit_form_fields", array( $this, 'edit_taxonomy_meta_fields' ), 5, 2 ); + add_action( "edited_{$taxonomy->name}", array( $this, 'save_taxonomy_custom_meta' ), 10, 2 ); + add_action( "create_{$taxonomy->name}", array( $this, 'save_taxonomy_custom_meta' ), 10, 2 ); + + add_filter( "manage_edit-{$taxonomy->name}_columns", array( $this, 'add_column' ) ); + add_action( "manage_{$taxonomy->name}_custom_column", array( $this, 'manage_column' ), 10, 3 ); } } @@ -134,4 +137,31 @@ class Display_Featured_Image_Genesis_Taxonomies { return ( $file_ext && in_array( $file_ext, $this->valid ) ); } -} \ No newline at end of file + public function add_column( $columns ) { + + $columns = array( + 'cb' => '', + 'featured_image' => __( 'Featured Image', 'display-featured-image-genesis' ), + 'name' => __( 'Name', 'display-featured-image-genesis' ), + 'description' => __( 'Description', 'display-featured-image-genesis' ), + 'slug' => __( 'Slug', 'display-featured-image-genesis' ), + 'posts' => __( 'Count', 'display-featured-image-genesis' ) + ); + + return $columns; + + } + + public function manage_column( $value, $column, $term_id ) { + + if ( 'featured_image' === $column ) { + $term_meta = get_option( "taxonomy_$term_id" ); + if ( ! empty( $term_meta['dfig_image'] ) ) { + $id = Display_Featured_Image_Genesis_Common::get_image_id( $term_meta['dfig_image'] ); + $preview = wp_get_attachment_image_src( $id, array( 75,75 ) ); + echo ''; + } + } + } + +}