From d4b276db764d4166e0cd7bb6db82a98ded2eb97e Mon Sep 17 00:00:00 2001 From: Robin Cornett Date: Fri, 20 Oct 2017 14:25:11 -0400 Subject: [PATCH] Update hook filters for image output (backwards compatible) --- ...ass-displayfeaturedimagegenesis-output.php | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/includes/class-displayfeaturedimagegenesis-output.php b/includes/class-displayfeaturedimagegenesis-output.php index 75f34bb..a7b4b61 100644 --- a/includes/class-displayfeaturedimagegenesis-output.php +++ b/includes/class-displayfeaturedimagegenesis-output.php @@ -128,10 +128,8 @@ class Display_Featured_Image_Genesis_Output { ), $common->version, true ); add_action( 'wp_print_scripts', array( $this, 'localize_scripts' ) ); - - $hook = apply_filters( 'display_featured_image_move_backstretch_image', 'genesis_after_header' ); - $priority = apply_filters( 'display_featured_image_move_backstretch_image_priority', 10 ); - add_action( esc_attr( $hook ), array( $this, 'do_backstretch_image_title' ), $priority ); + $location = $this->get_hooks(); + add_action( esc_attr( $location['backstretch']['hook'] ), array( $this, 'do_backstretch_image_title' ), $location['backstretch']['priority'] ); } /** @@ -256,15 +254,8 @@ class Display_Featured_Image_Genesis_Output { remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' ); add_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description', 15 ); - $hook = apply_filters( 'display_featured_image_genesis_move_large_image', 'genesis_before_loop' ); - if ( ! is_singular() || is_page_template( 'page_blog.php' ) ) { - $check = strpos( $hook, 'entry' ) || strpos( $hook, 'post' ); - if ( false !== $check ) { - $hook = 'genesis_before_loop'; - } - } - $priority = apply_filters( 'display_featured_image_genesis_move_large_image_priority', 12 ); - add_action( esc_attr( $hook ), array( $this, 'do_large_image' ), $priority ); // works for both HTML5 and XHTML + $location = $this->get_hooks(); + add_action( esc_attr( $location['large']['hook'] ), array( $this, 'do_large_image' ), $location['large']['priority'] ); // works for both HTML5 and XHTML } /** @@ -503,6 +494,32 @@ class Display_Featured_Image_Genesis_Output { return $this->item; } + /** + * Define the hooks/priorities for image output. + * + * @return array + */ + protected function get_hooks() { + $large_hook = apply_filters( 'display_featured_image_genesis_move_large_image', 'genesis_before_loop' ); + if ( ! is_singular() || is_page_template( 'page_blog.php' ) ) { + $check = strpos( $large_hook, 'entry' ) || strpos( $large_hook, 'post' ); + if ( false !== $check ) { + $large_hook = 'genesis_before_loop'; + } + } + + return apply_filters( 'displayfeaturedimagegenesis_hooks', array( + 'backstretch' => array( + 'hook' => apply_filters( 'display_featured_image_move_backstretch_image', 'genesis_after_header' ), + 'priority' => apply_filters( 'display_featured_image_move_backstretch_image_priority', 10 ), + ), + 'large' => array( + 'hook' => $large_hook, + 'priority' => apply_filters( 'display_featured_image_genesis_move_large_image_priority', 12 ), + ), + ) ); + } + /** * Check the post_meta for singular posts/pages/posts page. *