From 7ff9accb71559ac692e0e90077e474edf90adb44 Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Thu, 1 Jan 2015 19:17:41 -0500 Subject: [PATCH] add documentation --- README.md | 5 +- ...displayfeaturedimagegenesis-taxonomies.php | 58 +++++++++---------- 2 files changed, 32 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index de785d0..d2c2506 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ _Note: although this plugin requires the [Genesis Framework by StudioPress](http __Display Featured Image for Genesis__ now allows you to select a default, or fallback, Featured Image, which will be used if a post/page does not have a Featured Image set, or if the post/page's Featured Image is too small (smaller than your medium image setting), and on archive pages. You may set the Default Featured Image under Appearance > Display Featured Image Settings. -As of version x.y.z, you can now set a Featured Image for each taxonomy (categories, tags, and any taxonomy for custom post types). This image will be used on taxonomy archives, and as a fallback image for posts within that taxonomy if no featured image exists (or if the featured image is too small). +As of version x.y.z, you can now set a Featured Image for each taxonomy (categories, tags, and any taxonomy for custom post types). This image will be used on taxonomy archives, and as a fallback image for posts within that taxonomy if no featured image exists (or if the featured image is too small). If a post is assigned to multiple terms, the most used term will be the one used. -#### New: Add Your Featured Image to Your RSS Feed +#### Add Your Featured Image to Your RSS Feed Now you can add the Featured Image from each post to your RSS feed. This is an optional setting and applied intelligently: @@ -155,6 +155,7 @@ _Note:_ unless you check the option to __Move Excerpts/Archive Descriptions__, a ### x.y.z * added featured images to taxonomies! +* added featured images to admin archive pages! * added new setting to not move post titles to overlay Featured Image ### 1.5.0 - 2014-12-13 diff --git a/includes/class-displayfeaturedimagegenesis-taxonomies.php b/includes/class-displayfeaturedimagegenesis-taxonomies.php index 3f1d313..86d399e 100644 --- a/includes/class-displayfeaturedimagegenesis-taxonomies.php +++ b/includes/class-displayfeaturedimagegenesis-taxonomies.php @@ -8,8 +8,13 @@ */ class Display_Featured_Image_Genesis_Taxonomies { - function set_taxonomy_meta() { - $args = array( 'public' => true ); + /** + * set up all actions for adding featured images to taxonomies + */ + public function set_taxonomy_meta() { + $args = array( + 'public' => true + ); $output = 'names'; $taxonomies = get_taxonomies( $args, $output ); foreach ( $taxonomies as $taxonomy ) { @@ -20,25 +25,11 @@ class Display_Featured_Image_Genesis_Taxonomies { } } - function add_columns_post_types() { - $args = array( - 'public' => true, - '_builtin' => false, - ); - $output = 'names'; - $post_types = get_post_types( $args, $output ); - $post_types['post'] = 'post'; - $post_types['page'] = 'page'; - foreach ( $post_types as $post_type ) { - add_filter( "manage_{$post_type}_posts_columns", array( $this, 'add_post_columns' ) ); - add_action( "manage_{$post_type}_posts_custom_column", array( $this, 'custom_post_columns' ), 10, 2 ); - } - } + /** + * add featured image uploader to new taxonomy add + */ + public function add_taxonomy_meta_fields() { - - function add_taxonomy_meta_fields() { - - //* this will add the custom meta field to the add new term page echo '
'; echo ''; echo ''; @@ -48,15 +39,16 @@ class Display_Featured_Image_Genesis_Taxonomies { } - //* Edit term page - function edit_taxonomy_meta_fields( $term ) { + /** + * edit term page + * @param term $term featured image input/display for individual term page + * @return preview/uploader upload/preview featured image for term + */ + public function edit_taxonomy_meta_fields( $term ) { - //* put the term ID into a variable - $t_id = $term->term_id; - - //* retrieve the existing value(s) for this meta field. This returns an array + $t_id = $term->term_id; $term_meta = get_option( "taxonomy_$t_id" ); - //* this will add the custom meta field to the add new term page + echo ''; echo ''; echo ''; @@ -77,8 +69,15 @@ class Display_Featured_Image_Genesis_Taxonomies { echo ''; } - //* Save extra taxonomy fields callback function. - function save_taxonomy_custom_meta( $term_id ) { + /** + * Save extra taxonomy fields callback function. + * @param term id $term_id the id of the term + * @return updated option updated option for term featured image + * + * @since x.y.z + */ + public function save_taxonomy_custom_meta( $term_id ) { + if ( isset( $_POST['term_meta'] ) ) { $t_id = $term_id; $term_meta = get_option( "taxonomy_$t_id" ); @@ -94,6 +93,7 @@ class Display_Featured_Image_Genesis_Taxonomies { //* Save the option array. update_option( "taxonomy_$t_id", $term_meta ); } + } /**