mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-07-19 22:43:24 +09:00
new setting (exclude front page)
This commit is contained in:
@@ -126,7 +126,17 @@ class Display_Featured_Image_Genesis_Common {
|
||||
* @since 1.0.1
|
||||
*/
|
||||
public static function get_skipped_posttypes() {
|
||||
return apply_filters( 'display_featured_image_genesis_skipped_posttypes', array( 'attachment', 'revision', 'nav_menu_item' ) );
|
||||
|
||||
$skip = get_option( 'displayfeaturedimage_exclude_front' );
|
||||
|
||||
$post_types = array();
|
||||
$post_types[] = 'attachment';
|
||||
$post_types[] = 'revision';
|
||||
$post_types[] = 'nav_menu_item';
|
||||
if ( $skip ) $post_types[] = is_front_page();
|
||||
|
||||
return apply_filters( 'display_featured_image_genesis_skipped_posttypes', $post_types );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -136,7 +146,14 @@ class Display_Featured_Image_Genesis_Common {
|
||||
* @since 1.2.0
|
||||
*/
|
||||
public static function use_fallback_image() {
|
||||
return apply_filters( 'display_featured_image_genesis_use_default', array( 'attachment', 'revision', 'nav_menu_item' ) );
|
||||
|
||||
$post_types = array();
|
||||
$post_types[] = 'attachment';
|
||||
$post_types[] = 'revision';
|
||||
$post_types[] = 'nav_menu_item';
|
||||
|
||||
return apply_filters( 'display_featured_image_genesis_use_default', $post_types );
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,7 +163,14 @@ class Display_Featured_Image_Genesis_Common {
|
||||
* @since 1.3.0
|
||||
*/
|
||||
public static function omit_excerpt() {
|
||||
return apply_filters( 'display_featured_image_genesis_omit_excerpt', array( 'attachment', 'revision', 'nav_menu_item' ) );
|
||||
|
||||
$post_types = array();
|
||||
$post_types[] = 'attachment';
|
||||
$post_types[] = 'revision';
|
||||
$post_types[] = 'nav_menu_item';
|
||||
|
||||
return apply_filters( 'display_featured_image_genesis_omit_excerpt', $post_types );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,17 +51,16 @@ class Display_Featured_Image_Genesis_Description {
|
||||
return;
|
||||
}
|
||||
|
||||
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
|
||||
$frontpage = get_option( 'show_on_front' );
|
||||
$headline = $intro_text = '';
|
||||
$item = Display_Featured_Image_Genesis_Common::get_image_variables();
|
||||
$frontpage = get_option( 'show_on_front' );
|
||||
$headline = '';
|
||||
$intro_text = wpautop( get_bloginfo( 'description' ) );
|
||||
|
||||
if ( is_home() && 'page' === $frontpage ) {
|
||||
$headline = sprintf( '<h1 class="entry-title">%s</h1>', esc_attr( $item->title ) );
|
||||
$intro_text = wpautop( $item->description );
|
||||
}
|
||||
else {
|
||||
$intro_text = wpautop( get_bloginfo( 'description' ) );
|
||||
}
|
||||
|
||||
if ( $headline || $intro_text ) {
|
||||
printf( '<div class="excerpt">%s</div>', $headline . $intro_text );
|
||||
}
|
||||
|
||||
@@ -19,10 +19,10 @@ class Display_Featured_Image_Genesis_Output {
|
||||
if ( ( empty( $fallback ) && ! is_home() && ! is_singular() ) || ( in_array( get_post_type(), Display_Featured_Image_Genesis_Common::get_skipped_posttypes() ) ) ) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
add_filter( 'body_class', array( $this, 'add_body_class' ) );
|
||||
}
|
||||
|
||||
add_action( 'wp_enqueue_scripts', array( $this, 'load_scripts' ) );
|
||||
add_filter( 'body_class', array( $this, 'add_body_class' ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ class Display_Featured_Image_Genesis_Output {
|
||||
) );
|
||||
|
||||
add_action( 'genesis_after_header', array( $this, 'do_backstretch_image_title' ) );
|
||||
add_action( 'genesis_before_loop', array( $this, 'move_titles' ) );
|
||||
|
||||
}
|
||||
|
||||
@@ -117,6 +116,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
}
|
||||
|
||||
else {
|
||||
|
||||
if ( ! empty( $item->title ) && ! is_front_page() ) {
|
||||
echo '<h1 class="entry-title featured-image-overlay">' . esc_attr( $item->title ) . '</h1>';
|
||||
}
|
||||
@@ -124,6 +124,9 @@ class Display_Featured_Image_Genesis_Output {
|
||||
remove_action( 'genesis_before_loop', 'genesis_do_cpt_archive_title_description' );
|
||||
remove_action( 'genesis_before_loop', 'genesis_do_taxonomy_title_description', 15 );
|
||||
remove_action( 'genesis_before_loop', 'genesis_do_author_title_description', 15 );
|
||||
|
||||
add_action( 'genesis_before_loop', array( $this, 'move_titles' ) );
|
||||
|
||||
}
|
||||
echo '</div></div>';
|
||||
}
|
||||
@@ -151,16 +154,11 @@ class Display_Featured_Image_Genesis_Output {
|
||||
*
|
||||
*/
|
||||
public function move_titles() {
|
||||
$move_excerpts = get_option( 'displayfeaturedimage_excerpts' );
|
||||
|
||||
if ( $move_excerpts ) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
Display_Featured_Image_Genesis_Description::do_tax_description();
|
||||
Display_Featured_Image_Genesis_Description::do_author_description();
|
||||
Display_Featured_Image_Genesis_Description::do_cpt_archive_description();
|
||||
}
|
||||
Display_Featured_Image_Genesis_Description::do_tax_description();
|
||||
Display_Featured_Image_Genesis_Description::do_author_description();
|
||||
Display_Featured_Image_Genesis_Description::do_cpt_archive_description();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -44,8 +44,10 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function register_settings() {
|
||||
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimage_less_header', 'absint' );
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimage_default', array( $this, 'validate_image' ) );
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimage_exclude_front', array( $this, 'one_zero' ) );
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimage_excerpts', array( $this, 'one_zero' ) );
|
||||
|
||||
add_settings_section(
|
||||
@@ -71,6 +73,14 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
'display_featured_image_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'displayfeaturedimage_exclude_front',
|
||||
'<label for="displayfeaturedimage_exclude_front">' . __( 'Skip Front Page', 'display-featured-image-genesis' ) . '</label>',
|
||||
array( $this, 'exclude_front' ),
|
||||
'displayfeaturedimagegenesis',
|
||||
'display_featured_image_section'
|
||||
);
|
||||
|
||||
add_settings_field(
|
||||
'displayfeaturedimage_excerpts',
|
||||
'<label for="displayfeaturedimage_excerpts">' . __( 'Move Excerpts/Archive Descriptions', 'display-featured-image-genesis' ) . '</label>',
|
||||
@@ -90,7 +100,7 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function section_description() {
|
||||
echo '<p>' . __( 'The Display Featured Image for Genesis plugin has three optional settings. Check the Help tab for more information. ', 'display-featured-image-genesis' ) . '</p>';
|
||||
echo '<p>' . __( 'The Display Featured Image for Genesis plugin has just a few optional settings. Check the Help tab for more information. ', 'display-featured-image-genesis' ) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -132,6 +142,18 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
) . '</p>';
|
||||
}
|
||||
|
||||
/**
|
||||
* option to exclude default featured image on front page
|
||||
* @return 0 1 checkbox
|
||||
*
|
||||
* @since x.y.z
|
||||
*/
|
||||
public function exclude_front() {
|
||||
$value = get_option( 'displayfeaturedimage_exclude_front' );
|
||||
|
||||
echo '<input type="checkbox" name="displayfeaturedimage_exclude_front" id="displayfeaturedimage_exclude_front" value="1"' . checked( 1, $value, false ) . ' class="code" /> <label for="displayfeaturedimage_exclude_front">' . __( 'Do not show the Featured Image on the Front Page of the site.', 'display-featured-image-genesis' ) . '</label>';
|
||||
}
|
||||
|
||||
/**
|
||||
* option to move excerpts to leader image area
|
||||
* @return 0 1 checkbox
|
||||
@@ -246,6 +268,14 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
absint( $large+1 )
|
||||
) . '</p>';
|
||||
|
||||
$skipfront_help =
|
||||
'<h3>' . __( 'Show on Front Page', 'display-featured-image-genesis' ) . '</h3>' .
|
||||
'<p>' . __( 'If you set a Default Featured Image, it will show on every post/page of your site. This may not be desirable on child themes with a front page constructed with widgets, so you can select this option to prevent the Featured Image from showing on the front page.', 'display-featured-image-genesis' ) . '</p>' .
|
||||
'<p>' . sprintf(
|
||||
__( 'If you want to prevent entire groups of posts from not using the Featured Image, you will want to <a href="%s" target="_blank">add a filter</a> to your theme functions.php file.', 'display-featured-image-genesis' ),
|
||||
esc_url( 'https://github.com/robincornett/display-featured-image-genesis#how-do-i-stop-the-featured-image-action-from-showing-on-my-custom-post-types' )
|
||||
) . '</p>';
|
||||
|
||||
$excerpts_help =
|
||||
'<h3>' . __( 'Move Excerpts/Archive Descriptions', 'display-featured-image-genesis' ) . '</h3>' .
|
||||
'<p>' . __( 'By default, archive descriptions (set on the Genesis Archive Settings pages) show below the Default Featured Image, while the archive title displays on top of the image. If you check this box, all headlines, descriptions, and optional excerpts will display in a box overlaying the Featured Image.', 'display-featured-image-genesis' ) . '</p>';
|
||||
@@ -263,6 +293,12 @@ class Display_Featured_Image_Genesis_Settings {
|
||||
'content' => $default_help,
|
||||
) );
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'displayfeaturedimage_exclude_front-help',
|
||||
'title' => __( 'Show on Front Page', 'display-featured-image-genesis' ),
|
||||
'content' => $skipfront_help,
|
||||
) );
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'displayfeaturedimage_excerpts-help',
|
||||
'title' => __( 'Move Excerpts', 'display-featured-image-genesis' ),
|
||||
|
||||
Reference in New Issue
Block a user