mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-17 21:43:20 +09:00
add blog page 2+ setting
originally the featured image doesn't show on subsequent pages, but some people might want it to. needs documentation.
This commit is contained in:
@@ -50,11 +50,15 @@ class Display_Featured_Image_Genesis_Output {
|
||||
$medium = absint( get_option( 'medium_size_w' ) );
|
||||
$width = absint( $item->backstretch[1] );
|
||||
|
||||
//* if there is no backstretch image set, or it is too small, die
|
||||
if ( empty( $item->backstretch ) || $width <= $medium || is_paged() ) {
|
||||
// check if they have enabled display on subsequent pages
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
$is_paged = $displaysetting['is_paged'];
|
||||
|
||||
// if there is no backstretch image set, or it is too small, or it's page 2+ and they didn't change the setting, die
|
||||
if ( empty( $item->backstretch ) || $width <= $medium || ( is_paged() && ! $is_paged ) ) {
|
||||
return;
|
||||
}
|
||||
//* if the featured image is not part of the content, or we're not on a singular page, carry on
|
||||
// if the featured image is not part of the content, or we're not on a singular page, carry on
|
||||
if ( false === $item->content || ! is_singular() ) {
|
||||
|
||||
$css_file = apply_filters( 'display_featured_image_genesis_css_file', plugin_dir_url( __FILE__ ) . 'css/display-featured-image-genesis.css' );
|
||||
@@ -62,7 +66,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
|
||||
$post_types = array();
|
||||
$force_backstretch = apply_filters( 'display_featured_image_genesis_force_backstretch', $post_types );
|
||||
//* check if the image is large enough for backstretch
|
||||
// check if the image is large enough for backstretch
|
||||
if ( $width > $large || in_array( get_post_type(), $force_backstretch ) ) {
|
||||
|
||||
wp_enqueue_script( 'displayfeaturedimage-backstretch', plugins_url( '/includes/js/backstretch.js', dirname( __FILE__ ) ), array( 'jquery' ), $version, true );
|
||||
@@ -73,7 +77,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
|
||||
}
|
||||
|
||||
//* otherwise it's a large image.
|
||||
// otherwise it's a large image.
|
||||
elseif ( $width <= $large ) {
|
||||
|
||||
remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
|
||||
@@ -101,7 +105,12 @@ class Display_Featured_Image_Genesis_Output {
|
||||
$medium = absint( get_option( 'medium_size_w' ) );
|
||||
$width = absint( $item->backstretch[1] );
|
||||
|
||||
if ( empty( $item->backstretch ) || $width <= $medium || is_paged() ) {
|
||||
// check if they have enabled display on subsequent pages
|
||||
$displaysetting = get_option( 'displayfeaturedimagegenesis' );
|
||||
$is_paged = $displaysetting['is_paged'];
|
||||
|
||||
// if there is no backstretch image set, or it is too small, or it's page 2+ and they didn't change the setting, die
|
||||
if ( empty( $item->backstretch ) || $width <= $medium || ( is_paged() && ! $is_paged ) ) {
|
||||
return $classes;
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,8 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
'exclude_front' => 0,
|
||||
'keep_titles' => 0,
|
||||
'move_excerpts' => 0,
|
||||
'feed_image' => 0
|
||||
'is_paged' => 0,
|
||||
'feed_image' => 0,
|
||||
);
|
||||
|
||||
$this->displaysetting = get_option( 'displayfeaturedimagegenesis', $defaults );
|
||||
@@ -126,6 +127,14 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
'display_featured_image_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'displayfeaturedimagegenesis[is_paged]',
|
||||
'<label for="displayfeaturedimagegenesis[is_paged]">' . __( 'Show Featured Image on Subsequent Blog Pages', 'display-featured-image-genesis' ) . '</label>',
|
||||
array( $this, 'check_is_paged' ),
|
||||
'displayfeaturedimagegenesis',
|
||||
'display_featured_image_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'displayfeaturedimagegenesis[feed_image]',
|
||||
'<label for="displayfeaturedimagegenesis[feed_image]">' . __( 'Add Featured Image to Feed?', 'display-featured-image-genesis' ) . '</label>',
|
||||
@@ -263,6 +272,17 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
echo '<label for="displayfeaturedimagegenesis[move_excerpts]"><input type="checkbox" name="displayfeaturedimagegenesis[move_excerpts]" id="displayfeaturedimagegenesis[move_excerpts]" value="1"' . checked( 1, esc_attr( $this->displaysetting['move_excerpts'] ), false ) . ' class="code" />' . __( 'Move excerpts (if used) on single pages and move archive/taxonomy descriptions to overlay the Featured Image.', 'display-featured-image-genesis' ) . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* option to show featured image on page 2+ of blog/archives
|
||||
* @return 0 1 checkbox
|
||||
*
|
||||
* @since 2.2.0
|
||||
*/
|
||||
public function check_is_paged() {
|
||||
echo '<input type="hidden" name="displayfeaturedimagegenesis[is_paged]" value="0" />';
|
||||
echo '<label for="displayfeaturedimagegenesis[is_paged]"><input type="checkbox" name="displayfeaturedimagegenesis[is_paged]" id="displayfeaturedimagegenesis[is_paged]" value="1"' . checked( 1, esc_attr( $this->displaysetting['is_paged'] ), false ) . ' class="code" />' . __( 'Show featured image on pages 2+ of blogs and archives.', 'display-featured-image-genesis' ) . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* option to add images to feed
|
||||
* @return 0 1 checkbox
|
||||
@@ -377,6 +397,8 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
|
||||
$new_value['move_excerpts'] = $this->one_zero( $new_value['move_excerpts'] );
|
||||
|
||||
$new_value['is_paged'] = $this->one_zero( $new_value['is_paged'] );
|
||||
|
||||
$new_value['feed_image'] = $this->one_zero( $new_value['feed_image'] );
|
||||
|
||||
foreach ( $this->post_types as $post_type ) {
|
||||
|
||||
@@ -123,13 +123,20 @@ class Display_Featured_Image_Genesis {
|
||||
) );
|
||||
}
|
||||
|
||||
//* new setting for titles added in 2.0.0
|
||||
// new setting for titles added in 2.0.0
|
||||
if ( empty( $displaysetting['keep_titles'] ) ) {
|
||||
$this->update_settings( array(
|
||||
'keep_titles' => 0
|
||||
) );
|
||||
}
|
||||
|
||||
// new setting for subsequent pages added in 2.2.0
|
||||
if ( empty( $displaysetting['is_paged'] ) ) {
|
||||
$this->update_settings( array(
|
||||
'is_paged' => 0
|
||||
) );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user