From aca975db0986f28d46d3adf74d64ec7407e4eb6c Mon Sep 17 00:00:00 2001
From: Robin Cornett
Date: Tue, 28 Oct 2014 18:12:44 -0400
Subject: [PATCH] excerpt display optional
---
README.md | 6 +-
display-featured-image-genesis.php | 9 +-
...ass-displayfeaturedimagegenesis-common.php | 27 +++-
...isplayfeaturedimagegenesis-description.php | 136 ++++++++++++++++++
...ass-displayfeaturedimagegenesis-output.php | 63 +++++---
...s-displayfeaturedimagegenesis-settings.php | 50 ++++++-
.../class-displayfeaturedimagegenesis.php | 3 +-
.../css/display-featured-image-genesis.css | 3 +-
languages/display-featured-image-genesis.pot | 68 +++++----
readme.txt | 6 +-
10 files changed, 309 insertions(+), 62 deletions(-)
create mode 100644 includes/class-displayfeaturedimagegenesis-description.php
diff --git a/README.md b/README.md
index d96deab..2e0dd81 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ This plugin takes a different approach to how we use and display featured images
* display _nothing_ if your featured image is already displayed in your content (the original image, not a resized version).
* display a _default featured image_ as a backstretch image if one is uploaded.
-__New in 1.3.0:__ optional Genesis archive headlines, descriptions, and excerpts for single posts/pages will display over the backstretch featured image.
+__New in 1.3.0:__ optional Genesis archive headlines will display over the leader image. Archive descriptions and optional excerpts may display there, or above the content.
__New in 1.2.0:__ on the Media Settings page, you can now upload a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set, plus archive and taxonomy pages.
@@ -121,8 +121,8 @@ _Note: styling for the post title with excerpt is styled to be consistent with t
## Changelog
###1.3.0
-* optional taxonomy/author/CPT headline/description now show over leader image
-* optional excerpt displays on single posts/pages as part of overlay; output is the same as taxonomy/author/CPT
+* optional taxonomy/author/CPT headline now shows over leader image
+* optional taxonomy/author/CPT description and single post excerpt display optionally over leader image as well
###1.2.2
* default image validation
diff --git a/display-featured-image-genesis.php b/display-featured-image-genesis.php
index 4943fcc..00e800c 100644
--- a/display-featured-image-genesis.php
+++ b/display-featured-image-genesis.php
@@ -27,16 +27,19 @@ if ( ! defined( 'WPINC' ) ) {
// Include classes
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-common.php';
+require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-description.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-output.php';
require plugin_dir_path( __FILE__ ) . 'includes/class-displayfeaturedimagegenesis-settings.php';
// Instantiate dependent classes
-$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
-$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
-$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
+$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
+$displayfeaturedimagegenesis_description = new Display_Featured_Image_Genesis_Description();
+$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
+$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
$displayfeaturedimage = new Display_Featured_Image_Genesis(
$displayfeaturedimagegenesis_common,
+ $displayfeaturedimagegenesis_description,
$displayfeaturedimagegenesis_output,
$displayfeaturedimagegenesis_settings
);
diff --git a/includes/class-displayfeaturedimagegenesis-common.php b/includes/class-displayfeaturedimagegenesis-common.php
index 78ea5e3..fa6cee0 100644
--- a/includes/class-displayfeaturedimagegenesis-common.php
+++ b/includes/class-displayfeaturedimagegenesis-common.php
@@ -19,9 +19,10 @@ class Display_Featured_Image_Genesis_Common {
global $post;
// variables internal to this function
- $frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
- $postspage = get_option( 'page_for_posts' );
- $postspage_image = get_post_thumbnail_id( $postspage );
+ $frontpage = get_option( 'show_on_front' ); // either 'posts' or 'page'
+ $postspage = get_option( 'page_for_posts' );
+ $move_excerpts = get_option( 'displayfeaturedimage_excerpts' );
+ $postspage_image = get_post_thumbnail_id( $postspage );
if ( is_singular() ) {
$post_thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'displayfeaturedimage_backstretch' );
}
@@ -49,10 +50,30 @@ class Display_Featured_Image_Genesis_Common {
// Set Post/Page Title
if ( is_singular() && ! is_front_page() ) {
$item->title = get_the_title();
+ if ( has_excerpt() ) {
+ $item->description = get_the_excerpt();
+ }
}
elseif ( is_home() && $frontpage === 'page' ) {
$item->title = get_post( $postspage )->post_title;
}
+ elseif ( is_category() || is_tag() || is_tax() ) {
+ $term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : get_queried_object();
+ if ( ! $term || ! isset( $term->meta ) ) {
+ return;
+ }
+ $item->title = $term->meta['headline'];
+ $item->description = $term->meta['intro_text'];
+
+ }
+ elseif ( is_author() ) {
+ $item->title = get_the_author_meta( 'headline', (int) get_query_var( 'author' ) );
+ $item->description = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) );
+ }
+ elseif ( is_post_type_archive() && genesis_has_post_type_archive_support() && !empty( $item->fallback ) ) {
+ $item->title = genesis_get_cpt_option( 'headline' );
+ $item->description = genesis_get_cpt_option( 'intro_text' );
+ }
else {
$item->title = '';
}
diff --git a/includes/class-displayfeaturedimagegenesis-description.php b/includes/class-displayfeaturedimagegenesis-description.php
new file mode 100644
index 0000000..1a8e2bd
--- /dev/null
+++ b/includes/class-displayfeaturedimagegenesis-description.php
@@ -0,0 +1,136 @@
+
%s
%s', $item->title, $item->description );
+ }
+ }
+
+ /**
+ * Add custom description to category / tag / taxonomy archive pages.
+ *
+ * If the page is not a category, tag or taxonomy term archive, or we're not on the first page, or there's no term, or
+ * no term meta set, then nothing extra is displayed.
+ *
+ * If there's a description to display, it runs through `wpautop()` before being added to a div.
+ *
+ * @since 1.3.0
+ *
+ * @global WP_Query $wp_query Query object.
+ *
+ * @return null Return early if not the correct archive page, not page one, or no term meta is set.
+ */
+
+ public static function do_tax_description() {
+
+ global $wp_query;
+
+ if ( ! is_category() && ! is_tag() && ! is_tax() )
+ return;
+
+ if ( get_query_var( 'paged' ) >= 2 )
+ return;
+
+ $term = is_tax() ? get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ) : $wp_query->get_queried_object();
+
+ if ( ! $term || ! isset( $term->meta ) )
+ return;
+
+ $intro_text = '';
+
+
+ if ( $term->meta['intro_text'] )
+ $intro_text = apply_filters( 'genesis_term_intro_text_output', $term->meta['intro_text'] );
+
+ if ( $intro_text )
+ printf( '
%s
', $intro_text );
+
+ }
+
+ /**
+ * Add custom headline and description to author archive pages.
+ *
+ * If we're not on an author archive page, or not on page 1, then nothing extra is displayed.
+ *
+ * If there's a custom headline to display, it is marked up as a level 1 heading.
+ *
+ * If there's a description (intro text) to display, it is run through `wpautop()` before being added to a div.
+ *
+ * @since 1.4.0
+ *
+ * @return null Return early if not author archive or not page one.
+ */
+
+ public static function do_author_description() {
+
+ if ( ! is_author() )
+ return;
+
+ if ( get_query_var( 'paged' ) >= 2 )
+ return;
+
+ $intro_text = get_the_author_meta( 'intro_text', (int) get_query_var( 'author' ) );
+
+ $intro_text = $intro_text ? apply_filters( 'genesis_author_intro_text_output', $intro_text ) : '';
+
+ if ( $intro_text )
+ printf( '
%s
', $intro_text );
+
+
+ }
+
+
+ /**
+ * Add custom headline and description to relevant custom post type archive pages.
+ *
+ * If we're not on a post type archive page, or not on page 1, then nothing extra is displayed.
+ *
+ * If there's a custom headline to display, it is marked up as a level 1 heading.
+ *
+ * If there's a description (intro text) to display, it is run through wpautop() before being added to a div.
+ *
+ * @since 2.0.0
+ *
+ * @uses genesis_has_post_type_archive_support() Check if a post type should potentially support an archive setting page.
+ * @uses genesis_get_cpt_option() Get list of custom post types which need an archive settings page.
+ *
+ * @return null Return early if not on relevant post type archive.
+ */
+
+ public static function do_cpt_archive_description() {
+
+ if ( ! is_post_type_archive() || ! genesis_has_post_type_archive_support() )
+ return;
+
+ if ( get_query_var( 'paged' ) >= 2 )
+ return;
+
+ $intro_text = genesis_get_cpt_option( 'intro_text' );
+
+ $intro_text = $intro_text ? apply_filters( 'genesis_cpt_archive_intro_text_output', $intro_text ) : '';
+
+ if ( $intro_text )
+ printf( '
' . __( 'The Display Featured Image for Genesis plugin has two optional settings: 1) change the height of the backstretch effect, and 2) set a default backstretch image to use if no featured image is set.', 'display-featured-image-genesis' ) . '
';
+ echo '
' . __( 'The Display Featured Image for Genesis plugin has three optional settings. Check the Help tab for more information. ', 'display-featured-image-genesis' ) . '
' . __( 'Depending on how your header/nav are set up, or if you just do not want your backstretch image to extend to the bottom of the user screen, you may want to change this number. It will raise the bottom line of the backstretch image, making it shorter.', 'display-featured-image-genesis' ) . '
' .
'
' . __( 'Set a Default Featured Image', 'display-featured-image-genesis' ) . '
' .
@@ -179,7 +215,9 @@ class Display_Featured_Image_Genesis_Settings {
'
' . sprintf(
__( 'Supported file types are: jpg, jpeg, png, and gif. The image must be at least %1$s pixels wide.', 'display-featured-image-genesis' ),
$large+1
- ) . '
' . __( '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, archives with both a Headline and Intro Text will output both in a box overlaying the Featured Image. Posts which use an optional Excerpt will behave the same way.', 'display-featured-image-genesis' ) . '
';
$screen->add_help_tab( array(
'id' => 'displayfeaturedimage-help',
diff --git a/includes/class-displayfeaturedimagegenesis.php b/includes/class-displayfeaturedimagegenesis.php
index e66d748..9fb728a 100644
--- a/includes/class-displayfeaturedimagegenesis.php
+++ b/includes/class-displayfeaturedimagegenesis.php
@@ -16,8 +16,9 @@
*/
class Display_Featured_Image_Genesis {
- function __construct( $common, $output, $settings ) {
+ function __construct( $common, $description, $output, $settings ) {
$this->common = $common;
+ $this->archive = $description;
$this->output = $output;
$this->settings = $settings;
}
diff --git a/includes/css/display-featured-image-genesis.css b/includes/css/display-featured-image-genesis.css
index ca4172f..73f78d8 100644
--- a/includes/css/display-featured-image-genesis.css
+++ b/includes/css/display-featured-image-genesis.css
@@ -1,6 +1,5 @@
.has-leader .site-inner {
margin-top: 0;
- padding-top: 0;
}
.big-leader {
@@ -20,7 +19,7 @@
text-align: center;
}
-.big-leader .entry-header,
+.big-leader .excerpt,
.big-leader .archive-description {
background: rgba(255,255,255,.85);
color: #333;
diff --git a/languages/display-featured-image-genesis.pot b/languages/display-featured-image-genesis.pot
index 0a73b4b..8c136c2 100644
--- a/languages/display-featured-image-genesis.pot
+++ b/languages/display-featured-image-genesis.pot
@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: Display Featured Image for Genesis 1.3.0\n"
"POT-Creation-Date: 2014-09-17 21:11-0500\n"
-"PO-Revision-Date: 2014-10-27 17:03-0500\n"
+"PO-Revision-Date: 2014-10-28 17:23-0500\n"
"Last-Translator: Robin Cornett \n"
"Language-Team: Robin Cornett \n"
"Language: en_US\n"
@@ -25,55 +25,66 @@ msgstr ""
"X-Poedit-SearchPath-0: .\n"
"X-Textdomain-Support: yes\n"
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:25
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:186
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:26
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:224
msgid "Display Featured Image for Genesis"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:32
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:33
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:210
msgid "Height"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:40
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:41
msgid "Default Featured Image"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:57
-msgid ""
-"The Display Featured Image for Genesis plugin has two optional settings: 1) "
-"change the height of the backstretch effect, and 2) set a default "
-"backstretch image to use if no featured image is set."
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:49
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:219
+msgid "Move Excerpts/Archive Descriptions"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:69
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:66
+msgid ""
+"The Display Featured Image for Genesis plugin has three optional settings. "
+"Check the Help tab for more information. "
+msgstr ""
+
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:78
msgid "Pixels to remove "
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:71
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:80
msgid ""
"Changing this number will reduce the backstretch image height by this number "
"of pixels. Default is zero."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:91
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:100
msgid "Select Default Image"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:93
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:102
#, php-format
msgid ""
"If you would like to use a default image for the featured image, upload it "
"here. Must be at least %1$s pixels wide."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:120
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:116
+msgid ""
+"Move excerpts (if used) on single pages and move archive/taxonomy "
+"descriptions to overlay the Featured Image."
+msgstr ""
+
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:141
#, php-format
msgid ""
"Sorry, that is an invalid file type. Return to the Media "
"Settings page and try again."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:128
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:149
#, php-format
msgid ""
"Sorry, that image is too small to use as your Default Featured Image. Your "
@@ -81,11 +92,11 @@ msgid ""
"Media Settings page and try again."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:174
-msgid "Reducto!"
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:209
+msgid "Display Featured Image for Genesis has three optional settings:"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:175
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:211
msgid ""
"Depending on how your header/nav are set up, or if you just do not want your "
"backstretch image to extend to the bottom of the user screen, you may want "
@@ -93,30 +104,39 @@ msgid ""
"image, making it shorter."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:177
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:213
msgid "Set a Default Featured Image"
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:178
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:214
msgid ""
"You may set a large image to be used sitewide if a featured image is not "
"available. This image will show on posts, pages, and archives."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis-settings.php:180
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:216
#, php-format
msgid ""
"Supported file types are: jpg, jpeg, png, and gif. The image must be at "
"least %1$s pixels wide."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis.php:64
+#: ../includes/class-displayfeaturedimagegenesis-settings.php:220
+msgid ""
+"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, archives with both a Headline and "
+"Intro Text will output both in a box overlaying the Featured Image. Posts "
+"which use an optional Excerpt will behave the same way."
+msgstr ""
+
+#: ../includes/class-displayfeaturedimagegenesis.php:65
msgid ""
"Sorry, Display Featured Image for Genesis works only with the Genesis "
"Framework. It has been deactivated."
msgstr ""
-#: ../includes/class-displayfeaturedimagegenesis.php:68
+#: ../includes/class-displayfeaturedimagegenesis.php:69
#, php-format
msgid ""
"Sorry, Display Featured Image for Genesis works only with the Genesis "
diff --git a/readme.txt b/readme.txt
index 73ca218..c5ee9c7 100644
--- a/readme.txt
+++ b/readme.txt
@@ -20,7 +20,7 @@ This plugin takes a different approach to how we use and display featured images
* display _nothing_ if your featured image width is less than or equal to your Medium Media Setting.
* display a _default featured image_ as a backstretch image if one is uploaded.
-__New in 1.3.0:__ optional Genesis archive headlines, descriptions, and excerpts for single posts/pages will display over the backstretch featured image.
+__New in 1.3.0:__ optional Genesis archive headlines will display over the leader image. Archive descriptions and optional excerpts may display there, or above the content.
__New in 1.2.0:__ on the Media Settings page, you can now upload a _Default Featured Image_ to be used site-wide. This image will be used on any post/page/custom post type which does not have a featured image set, plus archive and taxonomy pages.
@@ -100,8 +100,8 @@ New feature: Set a Default Featured Image (1.2.0); show archive headlines/descri
== Changelog ==
= 1.3.0 =
-* optional taxonomy/author/CPT headline/description now show over leader image
-* optional excerpt displays on single posts/pages as part of overlay; output is the same as taxonomy/author/CPT
+* optional taxonomy/author/CPT headline now shows over leader image
+* optional taxonomy/author/CPT description and single post excerpt display optionally over leader image as well
= 1.2.2 =
* default image validation