diff --git a/README.md b/README.md index 135fce2..92a282f 100644 --- a/README.md +++ b/README.md @@ -76,7 +76,13 @@ Additionally/alternatively, you could set a max-height for the backstretch image ## Changelog +###1.1.2 +* plugin properly deactivates if Genesis isn't running + ###1.1.1 +* corrected XHTML hooks + +###1.1.0 * added a setting in the admin to optionally reduce the height of the backstretch image * refactoring diff --git a/display-featured-image-genesis.php b/display-featured-image-genesis.php index aea101d..feee32a 100644 --- a/display-featured-image-genesis.php +++ b/display-featured-image-genesis.php @@ -12,7 +12,7 @@ * Plugin Name: Display Featured Image for Genesis * Plugin URI: http://github.com/robincornett/display-featured-image-genesis/ * Description: This plugin requires the Genesis Framework. It varies the display of the post or page featured image, depending on size. - * Version: 1.1.0 + * Version: 1.1.2 * Author: Robin Cornett * Author URI: http://robincornett.com * License: GPL-2.0+ diff --git a/includes/class-displayfeaturedimagegenesis-output.php b/includes/class-displayfeaturedimagegenesis-output.php index dc5afd6..f86612c 100644 --- a/includes/class-displayfeaturedimagegenesis-output.php +++ b/includes/class-displayfeaturedimagegenesis-output.php @@ -18,7 +18,7 @@ class Display_Featured_Image_Genesis_Output { $item = new stdClass(); global $post; if ( is_home() ) { - $postspage = get_option( 'page_for_posts' ); + $postspage = get_option( 'page_for_posts' ); $item->original = wp_get_attachment_image_src( get_post_thumbnail_id( $postspage ), 'original' ); } else { @@ -113,7 +113,8 @@ class Display_Featured_Image_Genesis_Output { add_action( 'genesis_after_header', array( $this, 'do_backstretch_image' ) ); } elseif ( ( $item->original[1] <= $item->large ) && ( $item->original[1] > $item->medium ) ) { - add_action( 'genesis_before_entry', array( $this, 'do_large_image' ) ); + add_action( 'genesis_before_entry', array( $this, 'do_large_image' ) ); // HTML5 + add_action( 'genesis_before_post', array( $this, 'do_large_image' ) ); // XHTML } } @@ -130,7 +131,8 @@ class Display_Featured_Image_Genesis_Output { $item = $this->get_image_variables(); if ( ! is_home() ) { - remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); + remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); // HTML5 + remove_action( 'genesis_post_title', 'genesis_do_post_title' ); // XHTML } echo '
'; @@ -153,7 +155,7 @@ class Display_Featured_Image_Genesis_Output { */ public function do_large_image() { global $post; - echo get_the_post_thumbnail( $post->ID, 'large', array( 'class' => 'aligncenter', 'alt' => the_title_attribute( 'echo=0' ) ) ); + echo get_the_post_thumbnail( $post->ID, 'large', array( 'class' => 'aligncenter featured', 'alt' => the_title_attribute( 'echo=0' ) ) ); } } diff --git a/includes/class-displayfeaturedimagegenesis.php b/includes/class-displayfeaturedimagegenesis.php index 5f550ff..d391d4f 100644 --- a/includes/class-displayfeaturedimagegenesis.php +++ b/includes/class-displayfeaturedimagegenesis.php @@ -22,6 +22,7 @@ class Display_Featured_Image_Genesis { public function run() { if ( basename( get_template_directory() ) !== 'genesis' ) { + add_action( 'admin_init', array( $this, 'deactivate' ) ); add_action( 'admin_notices', array( $this, 'error_message' ) ); return; } @@ -32,17 +33,41 @@ class Display_Featured_Image_Genesis { add_filter( 'body_class', array( $this->output, 'add_body_class' ) ); } + /** + * deactivates the plugin if Genesis isn't running + * + * @since 1.1.2 + * + */ + public function deactivate() { + if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) { + deactivate_plugins( plugin_basename( dirname( __DIR__ ) ) . '/display-featured-image-genesis.php' ); // __DIR__ is a magic constant introduced in PHP 5.3 + } + else { + deactivate_plugins( plugin_basename( dirname( dirname( __FILE__ ) ) ) . '/display-featured-image-genesis.php' ); + } + } + /** * Error message if we're not using the Genesis Framework. * * @since 1.1.0 */ public function error_message() { - echo '

' . sprintf( - __( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. You can deactivate the plugin, since it is not working anyway, or you can activate a Genesis child theme.', 'display-featured-image-genesis' ), - esc_url( admin_url( 'plugins.php' ) ), - esc_url( admin_url( 'themes.php' ) ) - ) . '

'; + if ( version_compare( PHP_VERSION, '5.3', '>=' ) ) { + echo '

' . sprintf( + __( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. It has been deactivated.', 'display-featured-image-genesis' ) ) . '

'; + } + else { + echo '

' . sprintf( + __( 'Sorry, Display Featured Image for Genesis works only with the Genesis Framework. It has been deactivated. But since we're talking anyway, did you know that your server is running PHP version %1$s, which is outdated? You should ask your host to update that for you.', 'display-featured-image-genesis' ), + PHP_VERSION + ) . '

'; + } + + if ( isset( $_GET['activate'] ) ) { + unset( $_GET['activate'] ); + } } /** diff --git a/includes/css/display-featured-image-genesis.css b/includes/css/display-featured-image-genesis.css index 7c25fc7..3c8881c 100644 --- a/includes/css/display-featured-image-genesis.css +++ b/includes/css/display-featured-image-genesis.css @@ -15,3 +15,7 @@ left: 0; text-align: center; } + +img.featured { + max-width: 100%; +} diff --git a/includes/js/backstretch-set.js b/includes/js/backstretch-set.js index ea59e9c..ed5eb4f 100644 --- a/includes/js/backstretch-set.js +++ b/includes/js/backstretch-set.js @@ -1,5 +1,5 @@ jQuery(document).ready(function($) { $(".big-leader").css({'height':($(window).height())-([BackStretchVars.height])+'px'}); - $(".big-leader").backstretch([BackStretchVars.src],{'fade':750,'centeredY':false}); + $(".big-leader").backstretch([BackStretchVars.src],{'fade':750}); }); \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..3191038 --- /dev/null +++ b/index.php @@ -0,0 +1,3 @@ + Media page to change the default behavior of the plugin. + +== Frequently Asked Questions == + += How do I stop the featured image action from showing on my custom post types? = + +You'll want to add a filter to your theme (functions.php file). Here's an example: + + add_filter( 'display_featured_image_genesis_skipped_posttypes', 'rgc_skip_post_types' ); + function rgc_skip_post_types( $post_types ) { + $post_types[] = 'listing'; + $post_types[] = 'staff'; + + return $post_types; + } + += The backstretch image is a little too tall. = + +If you do not want the height of the backstretch image to be quite the height of the user's window, you can reduce it by just a hair. Go to Settings > Media and change the 'Reduction amount' number from the default of 0. The higher this number is, the shorter your image will be. Feel free to experiment, as no images are harmed by changing this number. + +Additionally/alternatively, you could set a max-height for the backstretch image via css: + + + .backstretch { + max-height: 700px; + } + + +== Screenshots == +1. Screenshot of a page using the Backstretch Featured Image + +== Upgrade Notice == += 1.1.1 = +corrected XHTML hooks +== Changelog == + += 1.1.1 = +* corrected XHTML hooks + += 1.1.0 = +* added a setting in the admin to optionally reduce the height of the backstretch image (eg. due to header height issues) +* refactoring +* wp.org release + += 1.0.1 = +* added the filter for certain post types, and optional filter for other custom post types + += 1.0.0 = +* Initial release on Github \ No newline at end of file