From 2deb62a69833b6e257ef5dd105354a84df3cff94 Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Thu, 12 Jul 2018 20:44:44 -0400 Subject: [PATCH 01/12] use underscores instead of dashes in filter names --- code-snippets.php | 54 ++++++++++++++++++++-------------------- public-filters.php | 62 +++++++++++++++++++++++----------------------- 2 files changed, 58 insertions(+), 58 deletions(-) diff --git a/code-snippets.php b/code-snippets.php index 134f111..941d308 100644 --- a/code-snippets.php +++ b/code-snippets.php @@ -12,7 +12,7 @@ * Append the term images to content + excerpt. */ function mytheme_append_the_term_images( $content ) { - return $content . apply_filters( 'taxonomy-images-list-the-terms', '', array( + return $content . apply_filters( 'taxonomy_images_list_the_terms', '', array( 'image_size' => 'detail', ) ); } @@ -34,38 +34,38 @@ function mytheme_append_the_term_images( $content ) { /* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN' ); -print '

taxonomy-images-queried-term-image

'; +$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN' ); +print '

taxonomy_images_queried_term_image

'; print '
' . htmlentities( $img ) . '
'; /* Inside a yellow box */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( 'before' => '
', 'after' => '
', ) ); -print '

taxonomy-images-queried-term-image - custom wrapper element.

'; +print '

taxonomy_images_queried_term_image - custom wrapper element.

'; print '
' . htmlentities( $img ) . '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'medium', ) ); -print '

taxonomy-images-queried-term-image - medium image size

'; +print '

taxonomy_images_queried_term_image - medium image size

'; print '
' . htmlentities( $img ) . '
'; /* Unrecognized size */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'this-is-probably-not-a-real-image-size', ) ); -print '

taxonomy-images-queried-term-image - unknown image size

'; +print '

taxonomy_images_queried_term_image - unknown image size

'; print '
' . htmlentities( $img ) . '
'; /* Custom attributes. */ -$img = apply_filters( 'taxonomy-images-queried-term-image', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( 'attr' => array( 'alt' => 'Custom alternative text', 'class' => 'my-class-list bunnies turtles', @@ -73,7 +73,7 @@ function mytheme_append_the_term_images( $content ) { 'title' => 'Custom Title', ), ) ); -print '

taxonomy-images-queried-term-image - custom attributes

'; +print '

taxonomy_images_queried_term_image - custom attributes

'; print '
' . htmlentities( $img ) . '
'; @@ -88,9 +88,9 @@ function mytheme_append_the_term_images( $content ) { * In the event that the Taxonomy Images plugin is not installed * apply_filters() will return it's second parameter. */ -$img = apply_filters( 'taxonomy-images-queried-term-image-id', 'PLEASE INSTALL PLUGIN' ); +$img = apply_filters( 'taxonomy_images_queried_term_image_id', 'PLEASE INSTALL PLUGIN' ); -print '

taxonomy-images-queried-term-image-id

'; +print '

taxonomy_images_queried_term_image_id

'; print '
'; var_dump( $img ); print '
'; @@ -106,9 +106,9 @@ function mytheme_append_the_term_images( $content ) { * In the event that the Taxonomy Images plugin is not installed * apply_filters() will return it's second parameter. */ -$img = apply_filters( 'taxonomy-images-queried-term-image-object', 'PLEASE INSTALL PLUGIN' ); +$img = apply_filters( 'taxonomy_images_queried_term_image_object', 'PLEASE INSTALL PLUGIN' ); -print '

taxonomy-images-queried-term-image-object

'; +print '

taxonomy_images_queried_term_image_object

'; print '
'; var_dump( $img ); print '
'; @@ -127,24 +127,24 @@ function mytheme_append_the_term_images( $content ) { /* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN' ); -print '

taxonomy-images-queried-term-image-url - Default

'; +$img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN' ); +print '

taxonomy_images_queried_term_image_url - Default

'; print '
'; var_dump( $img ); print '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'medium' ) ); -print '

taxonomy-images-queried-term-image-url - Medium

'; +print '

taxonomy_images_queried_term_image_url - Medium

'; print '
'; var_dump( $img ); print '
'; /* Unregistered Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-url', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'this-is-not-real-size-probably-I-hope' ) ); -print '

taxonomy-images-queried-term-image-url - Unregistered

'; +print '

taxonomy_images_queried_term_image_url - Unregistered

'; print '
'; var_dump( $img ); print '
'; @@ -163,22 +163,22 @@ function mytheme_append_the_term_images( $content ) { /* Default */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN' ); -print '

taxonomy-images-queried-term-image-data - Default

'; +$img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN' ); +print '

taxonomy_images_queried_term_image_data - Default

'; print '
'; var_dump( $img ); print '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'medium' ) ); -print '

taxonomy-images-queried-term-image-data - Medium

'; +print '

taxonomy_images_queried_term_image_data - Medium

'; print '
'; var_dump( $img ); print '
'; /* Unregistered Size */ -$img = apply_filters( 'taxonomy-images-queried-term-image-data', 'PLEASE INSTALL PLUGIN', array( +$img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( 'image_size' => 'this-is-not-real-size-probably-I-hope' ) ); -print '

taxonomy-images-queried-term-image-data - Unregistered

'; +print '

taxonomy_images_queried_term_image_data - Unregistered

'; print '
'; var_dump( $img ); print '
'; diff --git a/public-filters.php b/public-filters.php index b02d486..dee5673 100644 --- a/public-filters.php +++ b/public-filters.php @@ -18,15 +18,15 @@ */ -add_filter( 'taxonomy-images-get-terms', 'taxonomy_images_plugin_get_terms', 10, 2 ); -add_filter( 'taxonomy-images-get-the-terms', 'taxonomy_images_plugin_get_the_terms', 10, 2 ); -add_filter( 'taxonomy-images-list-the-terms', 'taxonomy_images_plugin_list_the_terms', 10, 2 ); +add_filter( 'taxonomy_images_get_terms', 'taxonomy_images_plugin_get_terms', 10, 2 ); +add_filter( 'taxonomy_images_get_the_terms', 'taxonomy_images_plugin_get_the_terms', 10, 2 ); +add_filter( 'taxonomy_images_list_the_terms', 'taxonomy_images_plugin_list_the_terms', 10, 2 ); -add_filter( 'taxonomy-images-queried-term-image', 'taxonomy_images_plugin_get_queried_term_image', 10, 2 ); -add_filter( 'taxonomy-images-queried-term-image-data', 'taxonomy_images_plugin_get_queried_term_image_data', 10, 2 ); -add_filter( 'taxonomy-images-queried-term-image-id', 'taxonomy_images_plugin_get_queried_term_image_id' ); -add_filter( 'taxonomy-images-queried-term-image-object', 'taxonomy_images_plugin_get_queried_term_image_object' ); -add_filter( 'taxonomy-images-queried-term-image-url', 'taxonomy_images_plugin_get_queried_term_image_url', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image', 'taxonomy_images_plugin_get_queried_term_image', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image_data', 'taxonomy_images_plugin_get_queried_term_image_data', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image_id', 'taxonomy_images_plugin_get_queried_term_image_id' ); +add_filter( 'taxonomy_images_queried_term_image_object', 'taxonomy_images_plugin_get_queried_term_image_object' ); +add_filter( 'taxonomy_images_queried_term_image_url', 'taxonomy_images_plugin_get_queried_term_image_url', 10, 2 ); /** @@ -63,11 +63,11 @@ * @param array Named arguments. Please see above for explantion. * @return array List of term objects. * - * @access private Use the 'taxonomy-images-get-terms' filter. + * @access private Use the 'taxonomy_images_get_terms' filter. * @since 0.7 */ function taxonomy_images_plugin_get_terms( $default, $args = array() ) { - $filter = 'taxonomy-images-get-terms'; + $filter = 'taxonomy_images_get_terms'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -155,11 +155,11 @@ function taxonomy_images_plugin_get_terms( $default, $args = array() ) { * @param array Named arguments. Please see above for explantion. * @return array List of term objects. Empty array if none were found. * - * @access private Use the 'taxonomy-images-get-the-terms' filter. + * @access private Use the 'taxonomy_images_get_the_terms' filter. * @since 0.7 */ function taxonomy_images_plugin_get_the_terms( $default, $args = array() ) { - $filter = 'taxonomy-images-get-the-terms'; + $filter = 'taxonomy_images_get_the_terms'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -245,11 +245,11 @@ function taxonomy_images_plugin_get_the_terms( $default, $args = array() ) { * @param array Named arguments. Please see above for explantion. * @return string HTML markup. * - * @access private Use the 'taxonomy-images-list-the-terms' filter. + * @access private Use the 'taxonomy_images_list_the_terms' filter. * @since 0.7 */ function taxonomy_images_plugin_list_the_terms( $default, $args = array() ) { - $filter = 'taxonomy-images-list-the-terms'; + $filter = 'taxonomy_images_list_the_terms'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -270,7 +270,7 @@ function taxonomy_images_plugin_list_the_terms( $default, $args = array() ) { return ''; } - $terms = apply_filters( 'taxonomy-images-get-the-terms', '', $args ); + $terms = apply_filters( 'taxonomy_images_get_the_terms', '', $args ); if ( empty( $terms ) ) { return ''; @@ -319,11 +319,11 @@ function taxonomy_images_plugin_list_the_terms( $default, $args = array() ) { * @param array Named array of arguments. * @return string HTML markup for the associated image. * - * @access private Use the 'taxonomy-images-queried-term-image' filter. + * @access private Use the 'taxonomy_images_queried_term_image' filter. * @since 0.7 */ function taxonomy_images_plugin_get_queried_term_image( $default, $args = array() ) { - $filter = 'taxonomy-images-queried-term-image'; + $filter = 'taxonomy_images_queried_term_image'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -335,7 +335,7 @@ function taxonomy_images_plugin_get_queried_term_image( $default, $args = array( 'image_size' => 'thumbnail', ) ); - $ID = apply_filters( 'taxonomy-images-queried-term-image-id', 0 ); + $ID = apply_filters( 'taxonomy_images_queried_term_image_id', 0 ); if ( empty( $ID ) ) { return ''; @@ -364,16 +364,16 @@ function taxonomy_images_plugin_get_queried_term_image( $default, $args = array( * * This function should never be called directly in any file * however it may be access in any template file via the - * 'taxonomy-images-queried-term-image-id' filter. + * 'taxonomy_images_queried_term_image_id' filter. * * @param mixed Default value for apply_filters() to return. Unused. * @return int Image attachment's ID. * - * @access private Use the 'taxonomy-images-queried-term-image-id' filter. + * @access private Use the 'taxonomy_images_queried_term_image_id' filter. * @since 0.7 */ function taxonomy_images_plugin_get_queried_term_image_id( $default ) { - $filter = 'taxonomy-images-queried-term-image-id'; + $filter = 'taxonomy_images_queried_term_image_id'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -419,21 +419,21 @@ function taxonomy_images_plugin_get_queried_term_image_id( $default ) { * * This function should never be called directly in any file * however it may be access in any template file via the - * 'taxonomy-images-queried-term-image' filter. + * 'taxonomy_images_queried_term_image' filter. * * @param mixed Default value for apply_filters() to return. Unused. * @return stdClass WordPress Post object. * - * @access private Use the 'taxonomy-images-queried-term-image-object' filter. + * @access private Use the 'taxonomy_images_queried_term_image_object' filter. * @since 0.7 */ function taxonomy_images_plugin_get_queried_term_image_object( $default ) { - $filter = 'taxonomy-images-queried-term-image-object'; + $filter = 'taxonomy_images_queried_term_image_object'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } - $ID = apply_filters( 'taxonomy-images-queried-term-image-id', 0 ); + $ID = apply_filters( 'taxonomy_images_queried_term_image_id', 0 ); $image = new stdClass; if ( ! empty( $ID ) ) { @@ -464,11 +464,11 @@ function taxonomy_images_plugin_get_queried_term_image_object( $default ) { * @param array Named Arguments. * @return string Image URL. * - * @access private Use the 'taxonomy-images-queried-term-image-url' filter. + * @access private Use the 'taxonomy_images_queried_term_image_url' filter. * @since 0.7 */ function taxonomy_images_plugin_get_queried_term_image_url( $default, $args = array() ) { - $filter = 'taxonomy-images-queried-term-image-url'; + $filter = 'taxonomy_images_queried_term_image_url'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -477,7 +477,7 @@ function taxonomy_images_plugin_get_queried_term_image_url( $default, $args = ar 'image_size' => 'thumbnail', ) ); - $data = apply_filters( 'taxonomy-images-queried-term-image-data', array(), $args ); + $data = apply_filters( 'taxonomy_images_queried_term_image_data', array(), $args ); $url = ''; if ( isset( $data['url'] ) ) { @@ -509,12 +509,12 @@ function taxonomy_images_plugin_get_queried_term_image_url( $default, $args = ar * @param array Named Arguments. * @return array Image data: url, width and height. * - * @access private Use the 'taxonomy-images-queried-term-image-data' filter. + * @access private Use the 'taxonomy_images_queried_term_image_data' filter. * @since 0.7 * @alter 0.7.2 */ function taxonomy_images_plugin_get_queried_term_image_data( $default, $args = array() ) { - $filter = 'taxonomy-images-queried-term-image-data'; + $filter = 'taxonomy_images_queried_term_image_data'; if ( $filter !== current_filter() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } @@ -523,7 +523,7 @@ function taxonomy_images_plugin_get_queried_term_image_data( $default, $args = a 'image_size' => 'thumbnail', ) ); - $ID = apply_filters( 'taxonomy-images-queried-term-image-id', 0 ); + $ID = apply_filters( 'taxonomy_images_queried_term_image_id', 0 ); if ( empty( $ID ) ) { return array(); From d4386e4d2e6d46005909db35347cd61d7d641f75 Mon Sep 17 00:00:00 2001 From: Paul Schreiber Date: Thu, 12 Jul 2018 20:46:04 -0400 Subject: [PATCH 02/12] PHPCBF fixes --- code-snippets.php | 114 +++++++---- deprecated.php | 42 ++-- public-filters.php | 128 ++++++------ taxonomy-images.php | 467 ++++++++++++++++++++++++++------------------ 4 files changed, 445 insertions(+), 306 deletions(-) diff --git a/code-snippets.php b/code-snippets.php index 941d308..52bc4c7 100644 --- a/code-snippets.php +++ b/code-snippets.php @@ -12,9 +12,11 @@ * Append the term images to content + excerpt. */ function mytheme_append_the_term_images( $content ) { - return $content . apply_filters( 'taxonomy_images_list_the_terms', '', array( - 'image_size' => 'detail', - ) ); + return $content . apply_filters( + 'taxonomy_images_list_the_terms', '', array( + 'image_size' => 'detail', + ) + ); } add_filter( 'the_content', 'mytheme_append_the_term_images' ); add_filter( 'the_excerpt', 'mytheme_append_the_term_images' ); @@ -40,39 +42,47 @@ function mytheme_append_the_term_images( $content ) { /* Inside a yellow box */ -$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( - 'before' => '
', - 'after' => '
', - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( + 'before' => '
', + 'after' => '
', + ) +); print '

taxonomy_images_queried_term_image - custom wrapper element.

'; print '
' . htmlentities( $img ) . '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium', - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'medium', + ) +); print '

taxonomy_images_queried_term_image - medium image size

'; print '
' . htmlentities( $img ) . '
'; /* Unrecognized size */ -$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-probably-not-a-real-image-size', - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'this-is-probably-not-a-real-image-size', + ) +); print '

taxonomy_images_queried_term_image - unknown image size

'; print '
' . htmlentities( $img ) . '
'; /* Custom attributes. */ -$img = apply_filters( 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( - 'attr' => array( - 'alt' => 'Custom alternative text', - 'class' => 'my-class-list bunnies turtles', - 'src' => 'this-is-where-the-image-lives.png', - 'title' => 'Custom Title', +$img = apply_filters( + 'taxonomy_images_queried_term_image', 'PLEASE INSTALL PLUGIN', array( + 'attr' => array( + 'alt' => 'Custom alternative text', + 'class' => 'my-class-list bunnies turtles', + 'src' => 'this-is-where-the-image-lives.png', + 'title' => 'Custom Title', ), - ) ); + ) +); print '

taxonomy_images_queried_term_image - custom attributes

'; print '
' . htmlentities( $img ) . '
'; @@ -91,7 +101,9 @@ function mytheme_append_the_term_images( $content ) { $img = apply_filters( 'taxonomy_images_queried_term_image_id', 'PLEASE INSTALL PLUGIN' ); print '

taxonomy_images_queried_term_image_id

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; @@ -109,7 +121,9 @@ function mytheme_append_the_term_images( $content ) { $img = apply_filters( 'taxonomy_images_queried_term_image_object', 'PLEASE INSTALL PLUGIN' ); print '

taxonomy_images_queried_term_image_object

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; @@ -129,23 +143,33 @@ function mytheme_append_the_term_images( $content ) { /* Default */ $img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN' ); print '

taxonomy_images_queried_term_image_url - Default

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium' - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'medium', + ) +); print '

taxonomy_images_queried_term_image_url - Medium

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; /* Unregistered Size */ -$img = apply_filters( 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-not-real-size-probably-I-hope' - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image_url', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'this-is-not-real-size-probably-I-hope', + ) +); print '

taxonomy_images_queried_term_image_url - Unregistered

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; @@ -165,20 +189,30 @@ function mytheme_append_the_term_images( $content ) { /* Default */ $img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN' ); print '

taxonomy_images_queried_term_image_data - Default

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; /* Medium Size */ -$img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'medium' - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'medium', + ) +); print '

taxonomy_images_queried_term_image_data - Medium

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; /* Unregistered Size */ -$img = apply_filters( 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( - 'image_size' => 'this-is-not-real-size-probably-I-hope' - ) ); +$img = apply_filters( + 'taxonomy_images_queried_term_image_data', 'PLEASE INSTALL PLUGIN', array( + 'image_size' => 'this-is-not-real-size-probably-I-hope', + ) +); print '

taxonomy_images_queried_term_image_data - Unregistered

'; -print '
'; var_dump( $img ); print '
'; +print '
';
+var_dump( $img );
+print '
'; diff --git a/deprecated.php b/deprecated.php index 9dce9d0..ce662c7 100644 --- a/deprecated.php +++ b/deprecated.php @@ -6,13 +6,14 @@ * @return void * @access private */ -function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEPRECATED - $o = ''; +function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { + // DEPRECATED + $o = ''; $defaults = array( 'taxonomy' => 'category', 'size' => 'detail', - 'template' => 'list' - ); + 'template' => 'list', + ); extract( shortcode_atts( $defaults, $atts ) ); @@ -22,11 +23,11 @@ function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEP return ''; } - $terms = get_terms( $taxonomy ); + $terms = get_terms( $taxonomy ); $associations = taxonomy_image_plugin_get_associations( $refresh = false ); if ( ! is_wp_error( $terms ) ) { - foreach( (array) $terms as $term ) { + foreach ( (array) $terms as $term ) { $url = get_term_link( $term, $term->taxonomy ); $title = apply_filters( 'the_title', $term->name ); $title_attr = esc_attr( $term->name . ' (' . $term->count . ')' ); @@ -34,20 +35,20 @@ function taxonomy_images_plugin_shortcode_deprecated( $atts = array() ) { // DEP $img = ''; if ( array_key_exists( $term->term_taxonomy_id, $associations ) ) { - $img = wp_get_attachment_image( $associations[$term->term_taxonomy_id], 'detail', false ); + $img = wp_get_attachment_image( $associations[ $term->term_taxonomy_id ], 'detail', false ); } - if( $template === 'grid' ) { - $o.= "\n\t" . '
'; - $o.= "\n\t\t" . '' . $img . ''; - $o.= "\n\t" . '
'; - } - else { - $o.= "\n\t\t" . '' . $img . '';; - $o.= "\n\t\t" . '

' . $title . '

'; - $o.= $description; - $o.= "\n\t" . '
'; - $o.= "\n"; + if ( $template === 'grid' ) { + $o .= "\n\t" . '
'; + $o .= "\n\t\t" . '' . $img . ''; + $o .= "\n\t" . '
'; + } else { + $o .= "\n\t\t" . '' . $img . ''; + ; + $o .= "\n\t\t" . '

' . $title . '

'; + $o .= $description; + $o .= "\n\t" . '
'; + $o .= "\n"; } } } @@ -82,8 +83,7 @@ public function get_image_html( $size = 'medium', $term_tax_id = false, $title = $obj = $wp_query->get_queried_object(); if ( isset( $obj->term_taxonomy_id ) ) { $term_tax_id = $obj->term_taxonomy_id; - } - else { + } else { return false; } } @@ -93,7 +93,7 @@ public function get_image_html( $size = 'medium', $term_tax_id = false, $title = $alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true ); $attachment = get_post( $attachment_id ); /* Just in case an attachment was deleted, but there is still a record for it in this plugins settings. */ - if ( $attachment !== NULL ) { + if ( $attachment !== null ) { $o = get_image_tag( $attachment_id, $alt, '', $align, $size ); } } diff --git a/public-filters.php b/public-filters.php index dee5673..e2e1130 100644 --- a/public-filters.php +++ b/public-filters.php @@ -18,15 +18,15 @@ */ -add_filter( 'taxonomy_images_get_terms', 'taxonomy_images_plugin_get_terms', 10, 2 ); -add_filter( 'taxonomy_images_get_the_terms', 'taxonomy_images_plugin_get_the_terms', 10, 2 ); +add_filter( 'taxonomy_images_get_terms', 'taxonomy_images_plugin_get_terms', 10, 2 ); +add_filter( 'taxonomy_images_get_the_terms', 'taxonomy_images_plugin_get_the_terms', 10, 2 ); add_filter( 'taxonomy_images_list_the_terms', 'taxonomy_images_plugin_list_the_terms', 10, 2 ); -add_filter( 'taxonomy_images_queried_term_image', 'taxonomy_images_plugin_get_queried_term_image', 10, 2 ); -add_filter( 'taxonomy_images_queried_term_image_data', 'taxonomy_images_plugin_get_queried_term_image_data', 10, 2 ); -add_filter( 'taxonomy_images_queried_term_image_id', 'taxonomy_images_plugin_get_queried_term_image_id' ); +add_filter( 'taxonomy_images_queried_term_image', 'taxonomy_images_plugin_get_queried_term_image', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image_data', 'taxonomy_images_plugin_get_queried_term_image_data', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image_id', 'taxonomy_images_plugin_get_queried_term_image_id' ); add_filter( 'taxonomy_images_queried_term_image_object', 'taxonomy_images_plugin_get_queried_term_image_object' ); -add_filter( 'taxonomy_images_queried_term_image_url', 'taxonomy_images_plugin_get_queried_term_image_url', 10, 2 ); +add_filter( 'taxonomy_images_queried_term_image_url', 'taxonomy_images_plugin_get_queried_term_image_url', 10, 2 ); /** @@ -72,12 +72,14 @@ function taxonomy_images_plugin_get_terms( $default, $args = array() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } - $args = wp_parse_args( $args, array( - 'cache_images' => true, - 'having_images' => true, - 'taxonomy' => 'category', - 'term_args' => array(), - ) ); + $args = wp_parse_args( + $args, array( + 'cache_images' => true, + 'having_images' => true, + 'taxonomy' => 'category', + 'term_args' => array(), + ) + ); $args['taxonomy'] = explode( ',', $args['taxonomy'] ); $args['taxonomy'] = array_map( 'trim', $args['taxonomy'] ); @@ -98,15 +100,15 @@ function taxonomy_images_plugin_get_terms( $default, $args = array() ) { return array(); } - $image_ids = array(); + $image_ids = array(); $terms_with_images = array(); foreach ( (array) $terms as $key => $term ) { - $terms[$key]->image_id = 0; + $terms[ $key ]->image_id = 0; if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) { - $terms[$key]->image_id = $assoc[$term->term_taxonomy_id]; - $image_ids[] = $assoc[$term->term_taxonomy_id]; + $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ]; + $image_ids[] = $assoc[ $term->term_taxonomy_id ]; if ( ! empty( $args['having_images'] ) ) { - $terms_with_images[] = $terms[$key]; + $terms_with_images[] = $terms[ $key ]; } } } @@ -164,11 +166,13 @@ function taxonomy_images_plugin_get_the_terms( $default, $args = array() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } - $args = wp_parse_args( $args, array( - 'having_images' => true, - 'post_id' => 0, - 'taxonomy' => 'category', - ) ); + $args = wp_parse_args( + $args, array( + 'having_images' => true, + 'post_id' => 0, + 'taxonomy' => 'category', + ) + ); if ( ! taxonomy_image_plugin_check_taxonomy( $args['taxonomy'], $filter ) ) { return array(); @@ -192,11 +196,11 @@ function taxonomy_images_plugin_get_the_terms( $default, $args = array() ) { $terms_with_images = array(); foreach ( (array) $terms as $key => $term ) { - $terms[$key]->image_id = 0; + $terms[ $key ]->image_id = 0; if ( array_key_exists( $term->term_taxonomy_id, $assoc ) ) { - $terms[$key]->image_id = $assoc[$term->term_taxonomy_id]; + $terms[ $key ]->image_id = $assoc[ $term->term_taxonomy_id ]; if ( ! empty( $args['having_images'] ) ) { - $terms_with_images[] = $terms[$key]; + $terms_with_images[] = $terms[ $key ]; } } } @@ -254,15 +258,17 @@ function taxonomy_images_plugin_list_the_terms( $default, $args = array() ) { taxonomy_image_plugin_please_use_filter( __FUNCTION__, $filter ); } - $args = wp_parse_args( $args, array( - 'after' => '', - 'after_image' => '', - 'before' => '', + 'after_image' => '', + 'before' => '