mirror of
https://github.com/10h30/display-featured-image-genesis.git
synced 2026-06-05 15:08:20 +09:00
Merge branch 'feature/scriptless-banner' into develop
This commit is contained in:
@@ -34,17 +34,14 @@ function display_featured_image_genesis_require() {
|
||||
'class-displayfeaturedimagegenesis',
|
||||
'settings/class-displayfeaturedimagegenesis-getsetting',
|
||||
'settings/class-displayfeaturedimagegenesis-helper',
|
||||
'settings/class-displayfeaturedimagegenesis-settings-define',
|
||||
'class-displayfeaturedimagegenesis-admin',
|
||||
'class-displayfeaturedimagegenesis-author',
|
||||
'class-displayfeaturedimagegenesis-common',
|
||||
'settings/class-displayfeaturedimagegenesis-customizer',
|
||||
'class-displayfeaturedimagegenesis-description',
|
||||
'settings/class-displayfeaturedimagegenesis-helptabs',
|
||||
'class-displayfeaturedimagegenesis-output',
|
||||
'class-displayfeaturedimagegenesis-postmeta',
|
||||
'class-displayfeaturedimagegenesis-rss',
|
||||
'settings/class-displayfeaturedimagegenesis-settings',
|
||||
'settings/class-displayfeaturedimagegenesis-customizer',
|
||||
'class-displayfeaturedimagegenesis-taxonomies',
|
||||
'sixtenpress-shortcodes/sixtenpress-shortcodes',
|
||||
'widgets/class-displayfeaturedimagegenesis-widgets',
|
||||
@@ -57,27 +54,23 @@ function display_featured_image_genesis_require() {
|
||||
display_featured_image_genesis_require();
|
||||
|
||||
// Instantiate dependent classes
|
||||
$displayfeaturedimagegenesis_helper = new Display_Featured_Image_Genesis_Helper();
|
||||
$displayfeaturedimagegenesis_admin = new Display_Featured_Image_Genesis_Admin();
|
||||
$displayfeaturedimagegenesis_author = new Display_Featured_Image_Genesis_Author();
|
||||
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
|
||||
$displayfeaturedimagegenesis_customizer = new Display_Featured_Image_Genesis_Customizer();
|
||||
$displayfeaturedimagegenesis_description = new Display_Featured_Image_Genesis_Description();
|
||||
$displayfeaturedimagegenesis_helptabs = new Display_Featured_Image_Genesis_HelpTabs();
|
||||
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
|
||||
$displayfeaturedimagegenesis_post_meta = new Display_Featured_Image_Genesis_Post_Meta();
|
||||
$displayfeaturedimagegenesis_rss = new Display_Featured_Image_Genesis_RSS();
|
||||
$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
|
||||
$displayfeaturedimagegenesis_taxonomies = new Display_Featured_Image_Genesis_Taxonomies();
|
||||
$displayfeaturedimagegenesis_widgets = new DisplayFeaturedImageGenesisWidgets();
|
||||
$displayfeaturedimagegenesis_helper = new Display_Featured_Image_Genesis_Helper();
|
||||
$displayfeaturedimagegenesis_admin = new Display_Featured_Image_Genesis_Admin();
|
||||
$displayfeaturedimagegenesis_author = new Display_Featured_Image_Genesis_Author();
|
||||
$displayfeaturedimagegenesis_common = new Display_Featured_Image_Genesis_Common();
|
||||
$displayfeaturedimagegenesis_customizer = new Display_Featured_Image_Genesis_Customizer();
|
||||
$displayfeaturedimagegenesis_output = new Display_Featured_Image_Genesis_Output();
|
||||
$displayfeaturedimagegenesis_post_meta = new Display_Featured_Image_Genesis_Post_Meta();
|
||||
$displayfeaturedimagegenesis_rss = new Display_Featured_Image_Genesis_RSS();
|
||||
$displayfeaturedimagegenesis_settings = new Display_Featured_Image_Genesis_Settings();
|
||||
$displayfeaturedimagegenesis_taxonomies = new Display_Featured_Image_Genesis_Taxonomies();
|
||||
$displayfeaturedimagegenesis_widgets = new DisplayFeaturedImageGenesisWidgets();
|
||||
|
||||
$displayfeaturedimage = new Display_Featured_Image_Genesis(
|
||||
$displayfeaturedimagegenesis_admin,
|
||||
$displayfeaturedimagegenesis_author,
|
||||
$displayfeaturedimagegenesis_common,
|
||||
$displayfeaturedimagegenesis_customizer,
|
||||
$displayfeaturedimagegenesis_description,
|
||||
$displayfeaturedimagegenesis_helptabs,
|
||||
$displayfeaturedimagegenesis_output,
|
||||
$displayfeaturedimagegenesis_post_meta,
|
||||
$displayfeaturedimagegenesis_rss,
|
||||
|
||||
@@ -33,8 +33,8 @@ class Display_Featured_Image_Genesis_Description {
|
||||
$itemprop = ' itemprop="headline"';
|
||||
}
|
||||
|
||||
$setting = displayfeaturedimagegenesis_get_setting();
|
||||
if ( ! $setting['keep_titles'] ) {
|
||||
$setting = displayfeaturedimagegenesis_get_setting( 'keep_titles' );
|
||||
if ( ! $setting ) {
|
||||
$headline = sprintf( '<h1 class="entry-title"%s>%s</h1>', $itemprop, get_the_title() );
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,6 @@ class Display_Featured_Image_Genesis_Output {
|
||||
*/
|
||||
public function manage_output() {
|
||||
|
||||
$this->setting = displayfeaturedimagegenesis_get_setting();
|
||||
if ( $this->quit_now() ) {
|
||||
return;
|
||||
}
|
||||
@@ -57,7 +56,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
$css_file = apply_filters( 'display_featured_image_genesis_css_file', plugin_dir_url( __FILE__ ) . 'css/display-featured-image-genesis.css' );
|
||||
$common = $this->get_common_class();
|
||||
wp_enqueue_style( 'displayfeaturedimage-style', esc_url( $css_file ), array(), $common->version );
|
||||
if ( $this->setting['max_height'] ) {
|
||||
if ( $this->get_setting( 'max_height' ) ) {
|
||||
$this->add_inline_style();
|
||||
}
|
||||
add_filter( 'body_class', array( $this, 'add_body_class' ) );
|
||||
@@ -71,7 +70,12 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @uses is_in_array()
|
||||
*/
|
||||
if ( $width > $large || Display_Featured_Image_Genesis_Common::is_in_array( 'force_backstretch' ) ) {
|
||||
$this->do_backstretch_image_things();
|
||||
$scriptless = displayfeaturedimagegenesis_get_setting( 'scriptless' );
|
||||
if ( $scriptless ) {
|
||||
$this->launch_backstretch_image();
|
||||
} else {
|
||||
$this->do_backstretch_image_things();
|
||||
}
|
||||
} else {
|
||||
$this->do_large_image_things();
|
||||
}
|
||||
@@ -83,10 +87,31 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.6.0
|
||||
*/
|
||||
public function add_inline_style() {
|
||||
$css = sprintf( '.big-leader { max-height: %spx; }', $this->setting['max_height'] );
|
||||
$css = sprintf( '.big-leader, .big-leader--scriptless img { max-height: %spx; }', $this->get_setting('max_height' ) );
|
||||
$css .= $this->get_object_position();
|
||||
wp_add_inline_style( 'displayfeaturedimage-style', wp_strip_all_tags( $css ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Add object-position to scriptless banner if needed.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.1.0
|
||||
*/
|
||||
private function get_object_position() {
|
||||
$setting = displayfeaturedimagegenesis_get_setting();
|
||||
if ( ! $setting['scriptless'] ) {
|
||||
return '';
|
||||
}
|
||||
if ( $setting['centeredX'] && $setting['centeredY'] ) {
|
||||
return '';
|
||||
}
|
||||
$x = $setting['centeredX'] ? '50%' : '0';
|
||||
$y = $setting['centeredY'] ? '50%' : '0';
|
||||
|
||||
return ".big-leader--scriptless img {object-position: {$x} {$y};}";
|
||||
}
|
||||
|
||||
/**
|
||||
* set body class if featured images are displayed using the plugin
|
||||
*
|
||||
@@ -122,7 +147,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
$common = $this->get_common_class();
|
||||
$minify = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
wp_register_script( 'backstretch', plugins_url( "/includes/js/backstretch{$minify}.js", dirname( __FILE__ ) ), array( 'jquery' ), '2.1.16', true );
|
||||
wp_enqueue_script( 'displayfeaturedimage-backstretch-set', plugins_url( '/includes/js/backstretch-set.js', dirname( __FILE__ ) ), array(
|
||||
wp_enqueue_script( 'displayfeaturedimage-backstretch-set', plugins_url( "/includes/js/backstretch-set{$minify}.js", dirname( __FILE__ ) ), array(
|
||||
'jquery',
|
||||
'backstretch',
|
||||
), $common->version, true );
|
||||
@@ -146,11 +171,12 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function localize_scripts() {
|
||||
$setting = $this->get_setting();
|
||||
// backstretch settings which can be filtered
|
||||
$backstretch_vars = apply_filters( 'display_featured_image_genesis_backstretch_variables', array(
|
||||
'centeredX' => $this->setting['centeredX'] ? 'center' : 'left',
|
||||
'centeredY' => $this->setting['centeredY'] ? 'center' : 'top',
|
||||
'fade' => $this->setting['fade'],
|
||||
'centeredX' => $setting['centeredX'] ? 'center' : 'left',
|
||||
'centeredY' => $setting['centeredY'] ? 'center' : 'top',
|
||||
'fade' => $setting['fade'],
|
||||
) );
|
||||
|
||||
$image_id = Display_Featured_Image_Genesis_Common::set_image_id();
|
||||
@@ -174,7 +200,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
'large' => $large[3] ? $large[2] : '',
|
||||
'medium_large' => $medium_large[3] ? $medium_large[2] : '',
|
||||
),
|
||||
'height' => (int) $this->setting['less_header'],
|
||||
'height' => (int) $setting['less_header'],
|
||||
'alignX' => $backstretch_vars['centeredX'],
|
||||
'alignY' => $backstretch_vars['centeredY'],
|
||||
'fade' => (int) $backstretch_vars['fade'],
|
||||
@@ -190,14 +216,21 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public function do_backstretch_image_title() {
|
||||
|
||||
$this->description = new Display_Featured_Image_Genesis_Description();
|
||||
|
||||
if ( $this->move_title() ) {
|
||||
$this->remove_title_descriptions();
|
||||
}
|
||||
|
||||
echo '<div class="big-leader">';
|
||||
$class = 'big-leader';
|
||||
$scriptless = displayfeaturedimagegenesis_get_setting( 'scriptless' );
|
||||
if ( $scriptless ) {
|
||||
$class .= ' big-leader--scriptless';
|
||||
}
|
||||
echo '<div class="' . esc_attr( $class ) . '">';
|
||||
$image = $this->get_banner_image();
|
||||
if ( $scriptless ) {
|
||||
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
|
||||
echo $image;
|
||||
}
|
||||
echo '<div class="wrap">';
|
||||
|
||||
do_action( 'display_featured_image_genesis_before_title' );
|
||||
@@ -219,14 +252,9 @@ class Display_Featured_Image_Genesis_Output {
|
||||
// close wrap
|
||||
echo '</div>';
|
||||
|
||||
// if javascript not enabled, do a fallback featured image
|
||||
$image_id = Display_Featured_Image_Genesis_Common::set_image_id();
|
||||
$image = wp_get_attachment_image( $image_id, 'displayfeaturedimage_backstretch', false, array(
|
||||
'alt' => $this->get_image_alt_text( $image_id ),
|
||||
'class' => 'post-image',
|
||||
'aria-hidden' => 'true',
|
||||
) );
|
||||
printf( '<noscript><div class="backstretch no-js">%s</div></noscript>', $image );
|
||||
if ( ! $scriptless ) {
|
||||
printf( '<noscript><div class="backstretch no-js">%s</div></noscript>', $image );
|
||||
}
|
||||
|
||||
// close big-leader
|
||||
echo '</div>';
|
||||
@@ -234,6 +262,26 @@ class Display_Featured_Image_Genesis_Output {
|
||||
add_filter( 'jetpack_photon_override_image_downsize', '__return_false' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the banner/noscript image.
|
||||
* @since 3.1.0
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function get_banner_image() {
|
||||
$image_id = Display_Featured_Image_Genesis_Common::set_image_id();
|
||||
return wp_get_attachment_image(
|
||||
$image_id,
|
||||
'displayfeaturedimage_backstretch',
|
||||
false,
|
||||
array(
|
||||
'alt' => $this->get_image_alt_text( $image_id ),
|
||||
'class' => 'post-image',
|
||||
'aria-hidden' => 'true',
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the alt text for the featured image. Use the image alt text if filter is true.
|
||||
*
|
||||
@@ -288,7 +336,8 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.3.1
|
||||
*/
|
||||
protected function do_the_title() {
|
||||
if ( is_front_page() && ! $this->description->show_front_page_title() ) {
|
||||
$description = $this->get_description_class();
|
||||
if ( is_front_page() && ! $description->show_front_page_title() ) {
|
||||
return '';
|
||||
}
|
||||
$class = is_singular() ? 'entry-title' : 'archive-title';
|
||||
@@ -308,10 +357,10 @@ class Display_Featured_Image_Genesis_Output {
|
||||
*
|
||||
*/
|
||||
public function add_descriptions() {
|
||||
|
||||
$this->description->do_tax_description();
|
||||
$this->description->do_author_description();
|
||||
$this->description->do_cpt_archive_description();
|
||||
$description = $this->get_description_class();
|
||||
$description->do_tax_description();
|
||||
$description->do_author_description();
|
||||
$description->do_cpt_archive_description();
|
||||
|
||||
}
|
||||
|
||||
@@ -321,8 +370,9 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.3.1
|
||||
*/
|
||||
protected function do_title_descriptions() {
|
||||
$this->description->do_front_blog_excerpt();
|
||||
$this->description->do_excerpt();
|
||||
$description = $this->get_description_class();
|
||||
$description->do_front_blog_excerpt();
|
||||
$description->do_excerpt();
|
||||
genesis_do_taxonomy_title_description();
|
||||
genesis_do_author_title_description();
|
||||
genesis_do_cpt_archive_title_description();
|
||||
@@ -354,10 +404,11 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @return bool
|
||||
*/
|
||||
protected function quit_now() {
|
||||
$setting = $this->get_setting();
|
||||
$disable = false;
|
||||
$exclude_front = is_front_page() && $this->setting['exclude_front'];
|
||||
$exclude_front = is_front_page() && $setting['exclude_front'];
|
||||
$post_type = get_post_type();
|
||||
$skip_singular = is_singular() && isset( $this->setting['skip'][ $post_type ] ) && $this->setting['skip'][ $post_type ] ? true : false;
|
||||
$skip_singular = is_singular() && isset( $setting['skip'][ $post_type ] ) && $setting['skip'][ $post_type ] ? true : false;
|
||||
|
||||
if ( $this->get_skipped_posttypes() || $skip_singular || $exclude_front || 1 === (int) get_post_meta( get_the_ID(), '_displayfeaturedimagegenesis_disable', true ) ) {
|
||||
$disable = true;
|
||||
@@ -394,7 +445,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
$width = (int) $item->backstretch[1];
|
||||
|
||||
// check if they have enabled display on subsequent pages
|
||||
$is_paged = ! empty( $this->setting['is_paged'] ) ? $this->setting['is_paged'] : 0;
|
||||
$is_paged = $this->get_setting( 'is_paged' );
|
||||
// if there is no backstretch image set, or it is too small, or the image is in the content, or it's page 2+ and they didn't change the setting, die
|
||||
if ( empty( $item->backstretch ) || $width <= $medium || ( is_paged() && ! $is_paged ) || ( is_singular() && false !== $item->content ) ) {
|
||||
$can_do = false;
|
||||
@@ -409,7 +460,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.0.0 (deprecated old function from 1.3.3)
|
||||
*/
|
||||
protected function move_excerpts() {
|
||||
$move_excerpts = $this->setting['move_excerpts'];
|
||||
$move_excerpts = $this->get_setting( 'move_excerpts' );
|
||||
/**
|
||||
* Creates display_featured_image_genesis_omit_excerpt filter to check
|
||||
* whether get_post_type array should not move excerpts for this post type.
|
||||
@@ -428,7 +479,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.2.0
|
||||
*/
|
||||
protected function move_title() {
|
||||
$keep_titles = $this->setting['keep_titles'];
|
||||
$keep_titles = $this->get_setting( 'keep_titles' );
|
||||
/**
|
||||
* Creates display_featured_image_genesis_do_not_move_titles filter to check
|
||||
* whether get_post_type array should not move titles to overlay the featured image.
|
||||
@@ -451,7 +502,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
* @since 2.5.0
|
||||
*/
|
||||
public function change_thumbnail_fallback( $defaults ) {
|
||||
if ( ! isset( $this->setting['thumbnails'] ) || ! $this->setting['thumbnails'] ) {
|
||||
if ( ! $this->get_setting( 'thumbnails' ) ) {
|
||||
return $defaults;
|
||||
}
|
||||
remove_action( 'genesis_entry_content', 'display_featured_image_genesis_add_archive_thumbnails', 5 );
|
||||
@@ -489,6 +540,21 @@ class Display_Featured_Image_Genesis_Output {
|
||||
return $this->common;
|
||||
}
|
||||
|
||||
/**
|
||||
* Instantiate the description class as needed.
|
||||
* @return \Display_Featured_Image_Genesis_Description
|
||||
* @since 3.1.0
|
||||
*/
|
||||
protected function get_description_class() {
|
||||
if ( isset( $this->description ) ) {
|
||||
return $this->description;
|
||||
}
|
||||
include_once 'class-displayfeaturedimagegenesis-description.php';
|
||||
$this->description = new Display_Featured_Image_Genesis_Description();
|
||||
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current featured image and related variables.
|
||||
* @return \stdClass
|
||||
@@ -509,6 +575,7 @@ class Display_Featured_Image_Genesis_Output {
|
||||
*/
|
||||
protected function get_minimum_backstretch_width() {
|
||||
$common = $this->get_common_class();
|
||||
|
||||
return $common->minimum_backstretch_width();
|
||||
}
|
||||
|
||||
@@ -553,4 +620,20 @@ class Display_Featured_Image_Genesis_Output {
|
||||
|
||||
return (bool) ( is_home() || is_singular() ) && $post_meta;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the plugin setting.
|
||||
* @param string $key
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
private function get_setting( $key = '' ) {
|
||||
if ( isset( $this->setting ) ) {
|
||||
return $key ? $this->setting[ $key ] : $this->setting;
|
||||
}
|
||||
|
||||
$this->setting = displayfeaturedimagegenesis_get_setting();
|
||||
|
||||
return $key ? $this->setting[ $key ] : $this->setting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ class Display_Featured_Image_Genesis_Post_Meta {
|
||||
*/
|
||||
protected function get_checkboxes() {
|
||||
$checkboxes = array();
|
||||
$setting = displayfeaturedimagegenesis_get_setting();
|
||||
if ( ! $setting['keep_titles'] ) {
|
||||
$setting = displayfeaturedimagegenesis_get_setting( 'keep_titles' );
|
||||
if ( ! $setting ) {
|
||||
$checkboxes[] = array(
|
||||
'setting' => $this->move,
|
||||
'label' => __( 'Don\'t move the title to overlay the backstretch featured image on this post', 'display-featured-image-genesis' ),
|
||||
@@ -128,10 +128,13 @@ class Display_Featured_Image_Genesis_Post_Meta {
|
||||
0 => __( 'Content type default', 'display-featured-image-genesis' ),
|
||||
1 => __( 'Don\'t display the featured image', 'display-featured-image-genesis' ),
|
||||
);
|
||||
$image_sizes = apply_filters( 'displayfeaturedimagegenesis_image_size_choices', array(
|
||||
'displayfeaturedimage_backstretch' => __( 'Use a backstretch image if it exists', 'display-featured-image-genesis' ),
|
||||
'large' => __( 'Use a large (not backstretch) image', 'display-featured-image-genesis' ),
|
||||
) );
|
||||
$image_sizes = apply_filters(
|
||||
'displayfeaturedimagegenesis_image_size_choices',
|
||||
array(
|
||||
'displayfeaturedimage_backstretch' => __( 'Use a banner image if it exists', 'display-featured-image-genesis' ),
|
||||
'large' => __( 'Use a large (not banner) image', 'display-featured-image-genesis' ),
|
||||
)
|
||||
);
|
||||
|
||||
return array(
|
||||
array(
|
||||
|
||||
@@ -12,13 +12,11 @@ class Display_Featured_Image_Genesis_RSS {
|
||||
/**
|
||||
* Decide whether or not to add the featured image to the feed or the feed excerpt
|
||||
*
|
||||
* @return filter the_excerpt_rss (if summaries) or the_content_feed (full text)
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function maybe_do_feed() {
|
||||
|
||||
$displaysetting = displayfeaturedimagegenesis_get_setting();
|
||||
$feed_image = $displaysetting['feed_image'];
|
||||
$feed_image = displayfeaturedimagegenesis_get_setting( 'feed_image' );
|
||||
|
||||
// if the user isn't sending images to the feed, we're done
|
||||
if ( ! $feed_image || Display_Featured_Image_Genesis_Common::is_in_array( 'skipped_posttypes' ) ) {
|
||||
@@ -42,7 +40,8 @@ class Display_Featured_Image_Genesis_RSS {
|
||||
* add the featured image to the feed, unless it already exists
|
||||
* includes allowances for Send Images to RSS plugin, which processes before this
|
||||
*
|
||||
* @param return $content
|
||||
* @param $content
|
||||
* @return string
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public function add_image_to_feed( $content ) {
|
||||
|
||||
@@ -13,15 +13,16 @@
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_Genesis_Helper {
|
||||
|
||||
protected $settings;
|
||||
|
||||
/**
|
||||
* set up all actions for adding featured images to taxonomies
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function set_taxonomy_meta() {
|
||||
if ( ! function_exists( 'get_term_meta' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
register_meta( 'term', 'displayfeaturedimagegenesis', array( $this, 'validate_taxonomy_image' ) );
|
||||
register_meta( 'term', $this->page, array( $this, 'validate_taxonomy_image' ) );
|
||||
|
||||
$args = array(
|
||||
'public' => true,
|
||||
@@ -60,15 +61,12 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
|
||||
?>
|
||||
<div class="form-field term-image-wrap">
|
||||
<?php wp_nonce_field( 'displayfeaturedimagegenesis', 'displayfeaturedimagegenesis' ); ?>
|
||||
<label for="displayfeaturedimagegenesis[term_image]"><?php esc_attr_e( 'Featured Image', 'display-featured-image-genesis' ); ?></label>
|
||||
<input type="hidden" class="upload_image_id" id="term_image_id" name="displayfeaturedimagegenesis[term_image]" />
|
||||
<input id="upload_default_image" type="button" class="upload_default_image button-secondary" value="<?php esc_attr_e( 'Select Image', 'display-featured-image-genesis' ); ?>" />
|
||||
<input type="button" class="delete_image button-secondary" value="<?php esc_attr_e( 'Delete Image', 'display-featured-image-genesis' ); ?>" />
|
||||
<?php wp_nonce_field( $this->page, $this->page ); ?>
|
||||
<label for="<?php echo esc_attr( $this->page ); ?>[term_image]"><?php esc_attr_e( 'Featured Image', 'display-featured-image-genesis' ); ?></label>
|
||||
<?php $this->render_buttons( false, "{$this->page}[term_image]" ); ?>
|
||||
<p class="description"><?php esc_attr_e( 'Set Featured Image for new term.', 'display-featured-image-genesis' ); ?></p>
|
||||
</div>
|
||||
<?php
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,22 +81,25 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
$image_id = displayfeaturedimagegenesis_get_term_image( $term_id );
|
||||
|
||||
echo '<tr class="form-field term-image-wrap">';
|
||||
printf( '<th scope="row" valign="top"><label for="displayfeaturedimagegenesis[term_image]">%s</label></th>',
|
||||
esc_attr__( 'Featured Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
echo '<td>';
|
||||
$name = 'displayfeaturedimagegenesis[term_image]';
|
||||
if ( $image_id ) {
|
||||
echo wp_kses_post( $this->render_image_preview( $image_id, $term->name ) );
|
||||
}
|
||||
$this->render_buttons( $image_id, $name );
|
||||
echo '<p class="description">';
|
||||
printf(
|
||||
esc_attr__( 'Set Featured Image for %1$s.', 'display-featured-image-genesis' ),
|
||||
esc_attr( $term->name )
|
||||
);
|
||||
echo '</p>';
|
||||
echo '</td>';
|
||||
printf(
|
||||
'<th scope="row" ><label for="%s[term_image]">%s</label></th>',
|
||||
esc_attr( $this->page ),
|
||||
esc_attr__( 'Featured Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
echo '<td>';
|
||||
$name = "{$this->page}[term_image]";
|
||||
if ( $image_id ) {
|
||||
echo wp_kses_post( $this->render_image_preview( $image_id, $term->name ) );
|
||||
}
|
||||
$this->render_buttons( $image_id, $name );
|
||||
echo '<p class="description">';
|
||||
printf(
|
||||
/* translators: name of the term */
|
||||
esc_attr__( 'Set Featured Image for %1$s.', 'display-featured-image-genesis' ),
|
||||
esc_attr( $term->name )
|
||||
);
|
||||
echo '</p>';
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
||||
@@ -109,20 +110,20 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public function save_taxonomy_custom_meta( $term_id ) {
|
||||
|
||||
if ( ! isset( $_POST['displayfeaturedimagegenesis'] ) ) {
|
||||
$input = filter_input( INPUT_POST, $this->page, FILTER_DEFAULT, FILTER_FORCE_ARRAY );
|
||||
if ( ! $input ) {
|
||||
return;
|
||||
}
|
||||
$input = $_POST['displayfeaturedimagegenesis'];
|
||||
$displaysetting = get_option( "displayfeaturedimagegenesis_$term_id", false );
|
||||
$action = function_exists( 'get_term_meta' ) ? 'update_term_meta' : 'update_options_meta';
|
||||
$this->$action( $term_id, $input, $displaysetting );
|
||||
$displaysetting = get_option( "{$this->page}_{$term_id}", false );
|
||||
$this->update_term_meta( $term_id, $input, $displaysetting );
|
||||
}
|
||||
|
||||
/**
|
||||
* update/delete term meta
|
||||
* @param int $term_id term id
|
||||
* @param array $displaysetting old option, if it exists
|
||||
*
|
||||
* @param int $term_id term id
|
||||
* @param $input
|
||||
* @param array $displaysetting old option, if it exists
|
||||
*
|
||||
* @since 2.4.0
|
||||
*/
|
||||
@@ -130,17 +131,17 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
$new_image = $this->validate_taxonomy_image( $input['term_image'] );
|
||||
if ( null === $new_image ) {
|
||||
// if the new image is empty, delete term_meta and old option
|
||||
delete_term_meta( $term_id, 'displayfeaturedimagegenesis' );
|
||||
delete_option( "displayfeaturedimagegenesis_$term_id" );
|
||||
delete_term_meta( $term_id, $this->page );
|
||||
delete_option( "{$this->page}_{$term_id}" );
|
||||
} elseif ( false !== $new_image ) {
|
||||
// if the new image is different from the existing term meta
|
||||
$current_setting = get_term_meta( $term_id, 'displayfeaturedimagegenesis' );
|
||||
$current_setting = get_term_meta( $term_id, $this->page );
|
||||
if ( $current_setting !== $new_image ) {
|
||||
update_term_meta( $term_id, 'displayfeaturedimagegenesis', (int) $new_image );
|
||||
update_term_meta( $term_id, $this->page, (int) $new_image );
|
||||
}
|
||||
// if there is a valid image, and the old setting exists
|
||||
if ( $displaysetting ) {
|
||||
delete_option( "displayfeaturedimagegenesis_$term_id" );
|
||||
delete_option( "{$this->page}_{$term_id}" );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -153,6 +154,7 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
* @since 2.4.0
|
||||
*/
|
||||
protected function update_options_meta( $term_id, $input, $displaysetting ) {
|
||||
_deprecated_function( __FUNCTION__, '3.1.0' );
|
||||
$cat_keys = array_keys( $input );
|
||||
$is_updated = false;
|
||||
foreach ( $cat_keys as $key ) {
|
||||
@@ -163,7 +165,7 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
}
|
||||
$displaysetting[ $key ] = $this->validate_taxonomy_image( $input[ $key ] );
|
||||
if ( null === $displaysetting[ $key ] ) {
|
||||
delete_option( "displayfeaturedimagegenesis_$term_id" );
|
||||
delete_option( "{$this->page}_{$term_id}" );
|
||||
} elseif ( false !== $displaysetting[ $key ] ) {
|
||||
$is_updated = true;
|
||||
}
|
||||
@@ -171,7 +173,7 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
}
|
||||
// Save the option array.
|
||||
if ( $is_updated ) {
|
||||
update_option( "displayfeaturedimagegenesis_$term_id", $displaysetting );
|
||||
update_option( "{$this->page}_{$term_id}", $displaysetting );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,12 +212,13 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
$term_help = '<h3>' . __( 'Set Featured Image', 'display-featured-image-genesis' ) . '</h3>';
|
||||
$term_help .= '<p>' . __( 'You may set a featured image for your terms. This image will be used on the term archive page, and as a fallback image on a single post page if it does not have a featured image of its own.', 'display-featured-image-genesis' ) . '</p>';
|
||||
|
||||
$screen->add_help_tab( array(
|
||||
'id' => 'displayfeaturedimage_term-help',
|
||||
'title' => __( 'Featured Image', 'display-featured-image-genesis' ),
|
||||
'content' => $term_help,
|
||||
) );
|
||||
|
||||
$screen->add_help_tab(
|
||||
array(
|
||||
'id' => 'displayfeaturedimage_term-help',
|
||||
'title' => __( 'Featured Image', 'display-featured-image-genesis' ),
|
||||
'content' => $term_help,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,8 +234,8 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
*/
|
||||
public function split_shared_term( $old_term_id, $new_term_id ) {
|
||||
|
||||
$old_setting = get_option( "displayfeaturedimagegenesis_$old_term_id" );
|
||||
$new_setting = get_option( "displayfeaturedimagegenesis_$new_term_id" );
|
||||
$old_setting = get_option( "{$this->page}_{$old_term_id}" );
|
||||
$new_setting = get_option( "{$this->page}_{$new_term_id}" );
|
||||
|
||||
if ( ! isset( $old_setting ) ) {
|
||||
return;
|
||||
@@ -240,7 +243,6 @@ class Display_Featured_Image_Genesis_Taxonomies extends Display_Featured_Image_G
|
||||
|
||||
$new_setting = $old_setting;
|
||||
|
||||
update_option( "displayfeaturedimagegenesis_$new_term_id", $new_setting );
|
||||
|
||||
update_option( "{$this->page}_{$new_term_id}", $new_setting );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,12 +45,6 @@ class Display_Featured_Image_Genesis {
|
||||
*/
|
||||
protected $description;
|
||||
|
||||
/**
|
||||
* Manages help tabs for settings page.
|
||||
* @var $helptabs Display_Featured_Image_Genesis_HelpTabs
|
||||
*/
|
||||
protected $helptabs;
|
||||
|
||||
/**
|
||||
* Handles all image output functionality
|
||||
* @var Display_Featured_Image_Genesis_Output $output
|
||||
@@ -95,20 +89,16 @@ class Display_Featured_Image_Genesis {
|
||||
* @param $author
|
||||
* @param $common
|
||||
* @param $customizer
|
||||
* @param $description
|
||||
* @param $helptabs
|
||||
* @param $output
|
||||
* @param $rss
|
||||
* @param $settings
|
||||
* @param $taxonomies
|
||||
*/
|
||||
public function __construct( $admin, $author, $common, $customizer, $description, $helptabs, $output, $post_meta, $rss, $settings, $taxonomies, $widgets ) {
|
||||
public function __construct( $admin, $author, $common, $customizer, $output, $post_meta, $rss, $settings, $taxonomies, $widgets ) {
|
||||
$this->admin = $admin;
|
||||
$this->author = $author;
|
||||
$this->common = $common;
|
||||
$this->customizer = $customizer;
|
||||
$this->description = $description;
|
||||
$this->helptabs = $helptabs;
|
||||
$this->output = $output;
|
||||
$this->post_meta = $post_meta;
|
||||
$this->rss = $rss;
|
||||
@@ -155,7 +145,6 @@ class Display_Featured_Image_Genesis {
|
||||
// Settings
|
||||
add_action( 'admin_menu', array( $this->settings, 'do_submenu_page' ) );
|
||||
add_filter( 'displayfeaturedimagegenesis_get_setting', array( $this->settings, 'get_display_setting' ) );
|
||||
add_action( 'load-appearance_page_displayfeaturedimagegenesis', array( $this->helptabs, 'help' ) );
|
||||
|
||||
// Customizer
|
||||
add_action( 'customize_register', array( $this->customizer, 'customizer' ) );
|
||||
@@ -218,8 +207,8 @@ class Display_Featured_Image_Genesis {
|
||||
) );
|
||||
add_image_size( 'displayfeaturedimage_backstretch', (int) $args['width'], (int) $args['height'], (bool) $args['crop'] );
|
||||
|
||||
$displaysetting = displayfeaturedimagegenesis_get_setting();
|
||||
if ( $displaysetting['move_excerpts'] ) {
|
||||
$move_excerpts = displayfeaturedimagegenesis_get_setting( 'move_excerpts' );
|
||||
if ( $move_excerpts ) {
|
||||
add_post_type_support( 'page', 'excerpt' );
|
||||
}
|
||||
}
|
||||
@@ -241,9 +230,10 @@ class Display_Featured_Image_Genesis {
|
||||
public function enqueue_scripts() {
|
||||
|
||||
$version = $this->common->version;
|
||||
$minify = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
|
||||
|
||||
wp_register_script( 'displayfeaturedimage-upload', plugins_url( '/includes/js/settings-upload.js', dirname( __FILE__ ) ), array( 'jquery', 'media-upload', 'thickbox' ), $version );
|
||||
wp_register_script( 'widget_selector', plugins_url( '/includes/js/widget-selector.js', dirname( __FILE__ ) ), array( 'jquery' ), $version );
|
||||
wp_register_script( 'displayfeaturedimage-upload', plugins_url( "/includes/js/settings-upload{$minify}.js", dirname( __FILE__ ) ), array( 'jquery', 'media-upload', 'thickbox' ), $version, true );
|
||||
wp_register_script( 'widget_selector', plugins_url( "/includes/js/widget-selector{$minify}.js", dirname( __FILE__ ) ), array( 'jquery' ), $version, true );
|
||||
|
||||
$screen = get_current_screen();
|
||||
$screen_ids = array(
|
||||
@@ -255,9 +245,13 @@ class Display_Featured_Image_Genesis {
|
||||
if ( in_array( $screen->id, $screen_ids, true ) || ! empty( $screen->taxonomy ) ) {
|
||||
wp_enqueue_media();
|
||||
wp_enqueue_script( 'displayfeaturedimage-upload' );
|
||||
wp_localize_script( 'displayfeaturedimage-upload', 'objectL10n', array(
|
||||
'text' => __( 'Select Image', 'display-featured-image-genesis' ),
|
||||
) );
|
||||
wp_localize_script(
|
||||
'displayfeaturedimage-upload',
|
||||
'DisplayFeaturedImageGenesis',
|
||||
array(
|
||||
'text' => __( 'Select Image', 'display-featured-image-genesis' ),
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,66 +1 @@
|
||||
.has-leader .site-inner {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.big-leader {
|
||||
overflow: hidden;
|
||||
height: 600px;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.backstretch.no-js {
|
||||
background-size: cover;
|
||||
height: 600px;
|
||||
}
|
||||
|
||||
.big-leader .wrap {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.big-leader .entry-title.featured-image-overlay,
|
||||
.big-leader .archive-title.featured-image-overlay {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.big-leader .excerpt,
|
||||
.big-leader .archive-description {
|
||||
margin-bottom: 24px;
|
||||
padding: 24px;
|
||||
background: rgba(255,255,255,0.85);
|
||||
}
|
||||
|
||||
.big-leader p {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.home .big-leader p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.big-leader p,
|
||||
.big-leader .excerpt .entry-title,
|
||||
.big-leader .archive-description .archive-title,
|
||||
.home .big-leader p:last-child {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
img.featured {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
|
||||
@media only screen and (max-width: 768px) {
|
||||
|
||||
.big-leader,
|
||||
.backstretch.no-js {
|
||||
height: 300px;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
.has-leader .site-inner{margin-top:0}.big-leader{overflow:hidden;max-height:100vh;position:relative}.big-leader .wrap{position:absolute;right:0;bottom:0;left:0;width:100%;z-index:1}.big-leader--scriptless{height:auto}.big-leader--scriptless img{display:block;-o-object-fit:cover;object-fit:cover}.big-leader .entry-title.featured-image-overlay,.big-leader .archive-title.featured-image-overlay{color:#fff;text-align:center}.big-leader .excerpt,.big-leader .archive-description{margin-bottom:24px;padding:24px;background:rgba(255,255,255,.85)}.big-leader p{margin-top:18px;margin-bottom:0}.home .big-leader p{margin-top:0}.home .big-leader p:last-child{margin-bottom:0}.big-leader .excerpt .entry-title,.big-leader .archive-description .archive-title{margin-bottom:0}.backstretch.no-js{max-height:600px}img.featured{max-width:100%}
|
||||
@@ -120,7 +120,7 @@ function display_featured_image_genesis_get_default_image_url( $size = 'displayf
|
||||
function display_featured_image_genesis_get_cpt_image_id( $image_id = '' ) {
|
||||
|
||||
$post_type = '';
|
||||
$displaysetting = displayfeaturedimagegenesis_get_setting();
|
||||
$displaysetting = displayfeaturedimagegenesis_get_setting( 'post_type' );
|
||||
$object = get_queried_object();
|
||||
if ( ! $object || is_admin() ) {
|
||||
return '';
|
||||
@@ -133,8 +133,8 @@ function display_featured_image_genesis_get_cpt_image_id( $image_id = '' ) {
|
||||
} elseif ( $object->post_type ) { // on singular
|
||||
$post_type = $object->post_type;
|
||||
}
|
||||
if ( ! empty( $displaysetting['post_type'][ $post_type ] ) ) {
|
||||
$image_id = $displaysetting['post_type'][ $post_type ];
|
||||
if ( ! empty( $displaysetting[ $post_type ] ) ) {
|
||||
$image_id = $displaysetting[ $post_type ];
|
||||
}
|
||||
|
||||
return (int) $image_id;
|
||||
@@ -226,12 +226,14 @@ function displayfeaturedimagegenesis_check_image_id( $image_id = '' ) {
|
||||
|
||||
/**
|
||||
* Helper function to get the plugin settings.
|
||||
*
|
||||
* @param string $key
|
||||
* @return mixed
|
||||
*
|
||||
* @since 2.4.2
|
||||
*/
|
||||
function displayfeaturedimagegenesis_get_setting() {
|
||||
return apply_filters( 'displayfeaturedimagegenesis_get_setting', false );
|
||||
function displayfeaturedimagegenesis_get_setting( $key = '' ) {
|
||||
return apply_filters( 'displayfeaturedimagegenesis_get_setting', $key );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -50,13 +50,9 @@
|
||||
return source;
|
||||
}
|
||||
|
||||
$( document ).ready( function () {
|
||||
plugin.params = typeof BackStretchVars === 'undefined' ? '' : BackStretchVars;
|
||||
|
||||
if ( typeof plugin.params === 'undefined' ) {
|
||||
return;
|
||||
}
|
||||
plugin.params = typeof BackStretchVars === 'undefined' ? '' : BackStretchVars;
|
||||
if ( typeof plugin.params !== 'undefined' ) {
|
||||
plugin.init();
|
||||
} );
|
||||
}
|
||||
|
||||
})( document, jQuery );
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(a,r,e){"use strict";var i={};i.init=function(){!function(){var a=r(".big-leader");if(void 0===a)return!1;a.css({height:r(window).height()-[i.params.height]+"px"}),a.backstretch([function(){var a=i.params.source.backstretch,e=window.innerWidth,t=r(".big-leader").height();i.params.source.large&&i.params.width.large>=e&&i.params.image_height.large>=t&&(a=i.params.source.large);i.params.source.medium_large&&i.params.width.medium_large>=e&&i.params.image_height.medium_large>=t&&(a=i.params.source.medium_large);return a}()],{alignX:i.params.alignX,alignY:i.params.alignY,fade:parseInt(i.params.fade),scale:"cover"}),r(".big-leader .backstretch img").attr("alt",i.params.title).attr("aria-hidden",!0)}()},i.params="undefined"==typeof BackStretchVars?"":BackStretchVars,void 0!==i.params&&i.init()}(document,jQuery);
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(a,t,n){"use strict";var e={},i={wrap:"displayfeaturedimage-buttons-wrap",container:"displayfeaturedimage-wrapper",dashicon:"wp-media-buttons-icon dashicons dashicons-camera",buttons:"displayfeaturedimagegenesis"};function s(){var a=t(this),n=t("."+i.buttons);if(!(3>a.find(n).length)){var s=t("<div />",{class:i.container}),r=t("<button />",{text:e.params.text,class:"button show-buttons"}).prepend(t("<span />",{class:i.dashicon})),o=t("<div />",{class:i.wrap});a.find(n).wrapAll(o),a.find(t("."+i.wrap)).wrap(s).before(r)}}function r(a){a.preventDefault(),jQuery(this).parents("."+i.container).find("."+i.wrap).toggle()}e.init=function(){t(".wp-media-buttons").each(s),t("."+i.container+" button").on("click",r)},e.params="undefined"==typeof DisplayFeaturedImageVar?"":DisplayFeaturedImageVar,void 0!==e.params&&e.init()}(document,jQuery);
|
||||
@@ -1,70 +1,91 @@
|
||||
jQuery( document ).ready( function ( $ ) {
|
||||
;(function ( document, $, undefined ) {
|
||||
'use strict';
|
||||
|
||||
var custom_uploader,
|
||||
targetInputClass = '.upload-image-id',
|
||||
previewClass = 'upload-image-preview',
|
||||
target_input,
|
||||
preview;
|
||||
DFIG = {};
|
||||
|
||||
$( '.upload_default_image' ).click(function(e) {
|
||||
DFIG.upload = function () {
|
||||
$( '.upload-image' ).on( 'click.upload', _uploadMedia );
|
||||
$( '.delete-image' ).on( 'click.delete', _deleteMedia );
|
||||
$( '#addtag #submit' ).on( 'click.term', _termImages );
|
||||
|
||||
target_input = $(this).prev( '.upload_image_id' );
|
||||
function _uploadMedia( e ) {
|
||||
e.preventDefault();
|
||||
target_input = $( this ).prev( targetInputClass );
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
//If the uploader object has already been created, reopen the dialog
|
||||
if ( custom_uploader ) {
|
||||
custom_uploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
//Extend the wp.media object
|
||||
custom_uploader = wp.media.frames.file_frame = wp.media({
|
||||
title: ( [ objectL10n.text ] ),
|
||||
button: {
|
||||
text: ( [ objectL10n.text ] )
|
||||
},
|
||||
multiple: false,
|
||||
library: { type : 'image' }
|
||||
});
|
||||
|
||||
//When a file is selected, grab the URL and set it as the text field's value
|
||||
custom_uploader.on( 'select', function() {
|
||||
|
||||
var attachment = custom_uploader.state().get( 'selection' ).first().toJSON(),
|
||||
preview = $( target_input ).prevAll( '.upload_logo_preview' ),
|
||||
previewImage = $( '<div class="upload_logo_preview"><img width="300" src="' + attachment.url + '" /></div>' );
|
||||
$( target_input ).val( attachment.id );
|
||||
if ( preview.length ) {
|
||||
preview.remove();
|
||||
//If the uploader object has already been created, reopen the dialog
|
||||
if ( custom_uploader ) {
|
||||
custom_uploader.reset();
|
||||
}
|
||||
$( target_input ).before( previewImage );
|
||||
});
|
||||
|
||||
//Open the uploader dialog
|
||||
custom_uploader.open();
|
||||
//Extend the wp.media object
|
||||
custom_uploader = wp.media.frames.file_frame = wp.media( {
|
||||
title: ([DFIG.params.text]),
|
||||
button: {
|
||||
text: ([DFIG.params.text])
|
||||
},
|
||||
multiple: false,
|
||||
library: {type: 'image'}
|
||||
} );
|
||||
|
||||
});
|
||||
//When a file is selected, grab the URL and set it as the text field's value
|
||||
custom_uploader.on( 'select', function () {
|
||||
|
||||
$( '.delete_image' ).click( function() {
|
||||
var attachment = custom_uploader.state().get( 'selection' ).first().toJSON(),
|
||||
preview = $( target_input ).prevAll( '.' + previewClass ),
|
||||
deleteButton = $( target_input ).siblings( '.delete-image' ),
|
||||
previewImage = $( '<div />', {
|
||||
class: previewClass
|
||||
} ).append( $( '<img/>', {
|
||||
style: 'max-width:100%;',
|
||||
width: '300px',
|
||||
src: attachment.url,
|
||||
alt: ''
|
||||
} ) );
|
||||
$( target_input ).val( attachment.id );
|
||||
if ( preview.length ) {
|
||||
preview.remove();
|
||||
}
|
||||
$( target_input ).before( previewImage );
|
||||
$( deleteButton ).show();
|
||||
} );
|
||||
|
||||
target_input = $( this ).prevAll( '.upload_image_id' );
|
||||
var previewView = $( this ).prevAll( '.upload_logo_preview' );
|
||||
//Open the uploader dialog
|
||||
custom_uploader.open();
|
||||
|
||||
$( target_input ).val( '' );
|
||||
$( previewView ).remove();
|
||||
|
||||
});
|
||||
|
||||
$( '#submit' ).click( function() {
|
||||
var submitButton = $( this ).parentsUntil( '#addtag' ),
|
||||
previewView = submitButton.siblings( '.term-image-wrap' ).children( '.upload_logo_preview' ),
|
||||
clearInput = submitButton.siblings( '.term-image-wrap' ).children( '.upload_image_id' );
|
||||
|
||||
if ( $( previewView ).length && $( submitButton ).length ) {
|
||||
$( previewView ).delay( 1000 ).fadeOut( 200, function() {
|
||||
$(this).remove();
|
||||
$( clearInput ).val( '' );
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function _deleteMedia( e ) {
|
||||
e.preventDefault();
|
||||
target_input = $( this ).prevAll( targetInputClass );
|
||||
var previewView = $( this ).prevAll( '.' + previewClass );
|
||||
|
||||
$( target_input ).val( '' );
|
||||
$( previewView ).remove();
|
||||
$( this ).hide();
|
||||
}
|
||||
|
||||
function _termImages( e ) {
|
||||
e.preventDefault();
|
||||
var submitButton = $( this ).parentsUntil( '#addtag' ),
|
||||
previewView = submitButton.siblings( '.term-image-wrap' ).children( '.' + previewClass ),
|
||||
clearInput = submitButton.siblings( '.term-image-wrap' ).children( targetInputClass );
|
||||
|
||||
if ( $( previewView ).length && $( submitButton ).length ) {
|
||||
$( previewView ).delay( 1000 ).fadeOut( 200, function () {
|
||||
$( this ).remove();
|
||||
$( clearInput ).val( '' );
|
||||
} );
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
DFIG.params = typeof DisplayFeaturedImageGenesis === 'undefined' ? '' : DisplayFeaturedImageGenesis;
|
||||
if ( typeof DFIG.params !== 'undefined' ) {
|
||||
DFIG.upload();
|
||||
}
|
||||
|
||||
})( document, jQuery );
|
||||
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
!function(e,t,a){"use strict";var i,l,n=".upload-image-id",r="upload-image-preview",s={upload:function(){t(".upload-image").on("click.upload",function(e){e.preventDefault(),l=t(this).prev(n),i&&i.reset();(i=wp.media.frames.file_frame=wp.media({title:[s.params.text],button:{text:[s.params.text]},multiple:!1,library:{type:"image"}})).on("select",function(){var e=i.state().get("selection").first().toJSON(),a=t(l).prevAll("."+r),n=t(l).siblings(".delete-image"),s=t("<div />",{class:r}).append(t("<img/>",{style:"max-width:100%;",width:"300px",src:e.url,alt:""}));t(l).val(e.id),a.length&&a.remove(),t(l).before(s),t(n).show()}),i.open()}),t(".delete-image").on("click.delete",function(e){e.preventDefault(),l=t(this).prevAll(n);var a=t(this).prevAll("."+r);t(l).val(""),t(a).remove(),t(this).hide()}),t("#addtag #submit").on("click.term",function(e){e.preventDefault();var a=t(this).parentsUntil("#addtag"),i=a.siblings(".term-image-wrap").children("."+r),l=a.siblings(".term-image-wrap").children(n);t(i).length&&t(a).length&&t(i).delay(1e3).fadeOut(200,function(){t(this).remove(),t(l).val("")})})}};s.params="undefined"==typeof DisplayFeaturedImageGenesis?"":DisplayFeaturedImageGenesis,void 0!==s.params&&s.upload()}(document,jQuery);
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
function term_postback(e,t){"use strict";var a={action:"widget_selector",taxonomy:t};jQuery.post(displayfeaturedimagegenesis_ajax_object.ajax_url,a,function(t){var a=jQuery.parseJSON(t),r=jQuery("#"+e),o=r.val();r.empty(),jQuery.each(a,function(e,t){var a=jQuery("<option></option>").attr("value",e).text(t);t==o&&a.attr("selected",!0),r.append(a)})})}
|
||||
@@ -6,7 +6,7 @@
|
||||
* @package Display_Featured_Image_Genesis
|
||||
* @copyright 2016 Robin Cornett
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Customizer extends Display_Featured_Image_Genesis_Settings_Define {
|
||||
class Display_Featured_Image_Genesis_Customizer extends Display_Featured_Image_Genesis_Settings {
|
||||
|
||||
/**
|
||||
* Section for the Customizer.
|
||||
@@ -64,23 +64,23 @@ class Display_Featured_Image_Genesis_Customizer extends Display_Featured_Image_G
|
||||
array(
|
||||
'id' => 'main',
|
||||
'title' => __( 'Main', 'display-featured-image-genesis' ),
|
||||
'fields' => $this->define_main_fields(),
|
||||
'fields' => include 'fields-main.php',
|
||||
),
|
||||
array(
|
||||
'id' => 'backstretch',
|
||||
'title' => __( 'Backstretch Output', 'display-featured-image-genesis' ),
|
||||
'fields' => $this->define_style_fields(),
|
||||
'fields' => include 'fields-style.php',
|
||||
),
|
||||
array(
|
||||
'id' => 'cpt',
|
||||
'title' => __( 'Content Types', 'display-featured-image-genesis' ),
|
||||
'fields' => $this->define_cpt_fields(),
|
||||
'fields' => include 'fields-cpt.php',
|
||||
'description' => __( 'Optional: set a custom image for search results and 404 (no results found) pages, as well as content types.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'advanced',
|
||||
'title' => __( 'Advanced', 'display-featured-image-genesis' ),
|
||||
'fields' => $this->define_advanced_fields(),
|
||||
'fields' => include 'fields-advanced.php',
|
||||
),
|
||||
);
|
||||
foreach ( $sections as $section ) {
|
||||
|
||||
@@ -45,25 +45,27 @@ class DisplayFeaturedImageGenesisGetSetting {
|
||||
'large_priority' => 12,
|
||||
'large' => array(),
|
||||
'image_size' => 'displayfeaturedimage_backstretch',
|
||||
'scriptless' => 0,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve plugin setting.
|
||||
* @return array All plugin settings.
|
||||
*
|
||||
* @param string $key optional setting key
|
||||
* @return array All plugin settings.
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function get_display_setting() {
|
||||
public function get_display_setting( $key = '' ) {
|
||||
if ( isset( $this->setting ) ) {
|
||||
return $this->setting;
|
||||
return $key ? $this->setting[ $key ] : $this->setting;
|
||||
}
|
||||
$defaults = $this->defaults();
|
||||
$setting = get_option( 'displayfeaturedimagegenesis', $defaults );
|
||||
|
||||
$this->setting = wp_parse_args( $setting, $defaults );
|
||||
|
||||
return $this->setting;
|
||||
return $key ? $this->setting[ $key ] : $this->setting;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,6 @@
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Helper extends DisplayFeaturedImageGenesisGetSetting {
|
||||
|
||||
/**
|
||||
* Variable for the plugin setting.
|
||||
* @var $setting
|
||||
*/
|
||||
protected $setting;
|
||||
|
||||
/**
|
||||
* Base id/slug for the settings page.
|
||||
* @var string $page
|
||||
@@ -237,7 +231,7 @@ class Display_Featured_Image_Genesis_Helper extends DisplayFeaturedImageGenesisG
|
||||
$alt_text = sprintf( __( '%s featured image', 'display-featured-image-genesis' ), esc_attr( $alt ) );
|
||||
$preview = wp_get_attachment_image_src( (int) $id, 'medium' );
|
||||
|
||||
return sprintf( '<div class="upload_logo_preview"><img src="%s" alt="%s" /></div>', esc_url( $preview[0] ), esc_attr( $alt_text ) );
|
||||
return sprintf( '<div class="upload-image-preview"><img src="%s" alt="%s" /></div>', esc_url( $preview[0] ), esc_attr( $alt_text ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -250,16 +244,17 @@ class Display_Featured_Image_Genesis_Helper extends DisplayFeaturedImageGenesisG
|
||||
*/
|
||||
public function render_buttons( $id, $name ) {
|
||||
$id = $id ? (int) $id : '';
|
||||
printf( '<input type="hidden" class="upload_image_id" name="%1$s" value="%2$s" />', esc_attr( $name ), esc_attr( $id ) );
|
||||
printf( '<input id="%s" type="button" class="upload_default_image button-secondary" value="%s" />',
|
||||
printf( '<input type="hidden" class="upload-image-id" name="%1$s" value="%2$s" />', esc_attr( $name ), esc_attr( $id ) );
|
||||
printf(
|
||||
'<button id="%s" class="upload-image button-secondary">%s</button>',
|
||||
esc_attr( $name ),
|
||||
esc_attr__( 'Select Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
if ( ! empty( $id ) ) {
|
||||
printf( ' <input type="button" class="delete_image button-secondary" value="%s" />',
|
||||
esc_attr__( 'Delete Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
}
|
||||
printf(
|
||||
' <button class="delete-image button-secondary"%s>%s</button>',
|
||||
empty( $id ) ? 'style="display:none;"' : '',
|
||||
esc_attr__( 'Delete Image', 'display-featured-image-genesis' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -92,7 +92,7 @@ class Display_Featured_Image_Genesis_HelpTabs extends Display_Featured_Image_Gen
|
||||
array(
|
||||
'id' => $this->id . 'sitewide',
|
||||
'title' => __( 'Optional Sitewide Settings', 'display-featured-image-genesis' ),
|
||||
'content' => $this->image_size() . $this->skip_front() . $this->keep_titles() . $this->excerpts(),
|
||||
'content' => $this->image_size() . $this->javascript() . $this->skip_front() . $this->keep_titles() . $this->excerpts(),
|
||||
),
|
||||
array(
|
||||
'id' => $this->id . 'archives',
|
||||
@@ -117,9 +117,9 @@ class Display_Featured_Image_Genesis_HelpTabs extends Display_Featured_Image_Gen
|
||||
* @since 2.6.0
|
||||
*/
|
||||
protected function height() {
|
||||
$help = '<p>' . __( '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' ) . '</p>';
|
||||
$help .= '<p>' . __( 'The plugin determines the size of your backstretch image based on the size of the user\'s browser window. Changing the "Height" setting tells the plugin to subtract that number of pixels from the measured height of the user\'s window, regardless of the size of that window.', 'display-featured-image-genesis' ) . '</p>';
|
||||
$help .= '<p>' . __( 'If you need to control the size of the backstretch Featured Image output with more attention to the user\'s screen size, add a Maximum Height number, which affects the CSS.', 'display-featured-image-genesis' ) . '</p>';
|
||||
$help = '<p>' . __( 'Depending on how your header/nav are set up, or if you just do not want your backstretch banner 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 banner image, making it shorter.', 'display-featured-image-genesis' ) . '</p>';
|
||||
$help .= '<p>' . __( 'The plugin determines the size of your backstretch banner image based on the size of the user\'s browser window. Changing the "Height" setting tells the plugin to subtract that number of pixels from the measured height of the user\'s window, regardless of the size of that window.', 'display-featured-image-genesis' ) . '</p>';
|
||||
$help .= '<p>' . __( 'If you need to control the size of the backstretch banner image output with more attention to the user\'s screen size, add a Maximum Height number, which affects the CSS.', 'display-featured-image-genesis' ) . '</p>';
|
||||
|
||||
return $help;
|
||||
}
|
||||
@@ -165,7 +165,7 @@ class Display_Featured_Image_Genesis_HelpTabs extends Display_Featured_Image_Gen
|
||||
*/
|
||||
protected function keep_titles() {
|
||||
$help = '<h3>' . __( 'Do Not Move Titles', 'display-featured-image-genesis' ) . '</h3>';
|
||||
$help .= '<p>' . __( 'This setting applies to the backstretch Featured Image only. It allows you to keep the post/page titles in their original location, instead of overlaying the new image.', 'display-featured-image-genesis' ) . '</p>';
|
||||
$help .= '<p>' . __( 'This setting applies to the banner Featured Image only. It allows you to keep the post/page titles in their original location, instead of overlaying the new image.', 'display-featured-image-genesis' ) . '</p>';
|
||||
|
||||
return $help;
|
||||
}
|
||||
@@ -296,4 +296,16 @@ class Display_Featured_Image_Genesis_HelpTabs extends Display_Featured_Image_Gen
|
||||
|
||||
return $help;
|
||||
}
|
||||
|
||||
/**
|
||||
* Help text for the disable JavaScript setting.
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
protected function javascript() {
|
||||
$help = '<h3>' . __( 'Disable JavaScript', 'display-featured-image-genesis' ) . '</h3>';
|
||||
$help .= '<p>' . __( 'Optionally disable JavaScript for your banner images. The output will mostly be similar, although some behavior will change. For example, without the backstretch script, images will always display full width, regardless of screen size (with backstretch, you\'ll often only see the center of the image on small screens.', 'display-featured-image-genesis' ) . '</p>';
|
||||
|
||||
return $help;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,382 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class Display_Featured_Image_Genesis_Settings_Define
|
||||
* @package DisplayFeaturedImageGenesis
|
||||
* @copyright 2017 Robin Cornett
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Settings_Define extends Display_Featured_Image_Genesis_Helper {
|
||||
|
||||
/**
|
||||
* Register plugin settings page sections
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function register_sections() {
|
||||
return array(
|
||||
'main' => array(
|
||||
'id' => 'main',
|
||||
'title' => __( 'Optional Sitewide Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'archives' => array(
|
||||
'id' => 'archives',
|
||||
'title' => __( 'Optional Archive Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'default' => array(
|
||||
'id' => 'default',
|
||||
'title' => __( 'Optional Default Image', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'style' => array(
|
||||
'id' => 'style',
|
||||
'title' => __( 'Display Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'style',
|
||||
),
|
||||
'cpt_sitewide' => array(
|
||||
'id' => 'cpt_sitewide',
|
||||
'title' => __( 'Sitewide Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'cpt',
|
||||
),
|
||||
'cpt' => array(
|
||||
'id' => 'cpt',
|
||||
'title' => __( 'Featured Images for Custom Content Types', 'display-featured-image-genesis' ),
|
||||
'tab' => 'cpt',
|
||||
),
|
||||
'advanced' => array(
|
||||
'id' => 'advanced',
|
||||
'title' => __( 'Advanced Plugin Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'advanced',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register plugin settings fields
|
||||
* @return array all settings fields
|
||||
*
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public function register_fields() {
|
||||
|
||||
return array_merge( $this->define_main_fields(), $this->define_style_fields(), $this->define_cpt_fields(), $this->define_advanced_fields() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the fields for the main/first tab.
|
||||
* @return array
|
||||
*/
|
||||
protected function define_main_fields() {
|
||||
$common = new Display_Featured_Image_Genesis_Common();
|
||||
$large = $common->minimum_backstretch_width();
|
||||
|
||||
return array(
|
||||
array(
|
||||
'id' => 'default',
|
||||
'title' => __( 'Default Featured Image', 'display-featured-image-genesis' ),
|
||||
'callback' => 'set_default_image',
|
||||
'section' => 'default',
|
||||
'type' => 'image',
|
||||
),
|
||||
array(
|
||||
'id' => 'always_default',
|
||||
'title' => __( 'Always Use Default', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'default',
|
||||
'label' => __( 'Always use the default image, even if a featured image is set.', 'display-featured-image-genesis' ),
|
||||
'description' => sprintf(
|
||||
/* translators: placeholder is a number equivalent to the width of the site's Large image (Settings > Media) */
|
||||
esc_html__( 'If you would like to use a default image for the featured image, upload it here. Must be at least %1$s pixels wide.', 'display-featured-image-genesis' ),
|
||||
absint( $large + 1 )
|
||||
),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'image_size',
|
||||
'title' => __( 'Preferred Image Size', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'main',
|
||||
'choices' => apply_filters(
|
||||
'displayfeaturedimagegenesis_image_size_choices',
|
||||
array(
|
||||
'displayfeaturedimage_backstretch' => __( 'Backstretch (default)', 'display-featured-image-genesis' ),
|
||||
'large' => __( 'Large', 'display-featured-image-genesis' ),
|
||||
)
|
||||
),
|
||||
'type' => 'select',
|
||||
),
|
||||
array(
|
||||
'id' => 'exclude_front',
|
||||
'title' => __( 'Skip Front Page', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Do not show the Featured Image on the Front Page of the site.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'keep_titles',
|
||||
'title' => __( 'Do Not Move Titles', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Do not move the titles to overlay the backstretch Featured Image.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'move_excerpts',
|
||||
'title' => __( 'Move Excerpts/Archive Descriptions', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Move excerpts (if used) on single pages and move archive/taxonomy descriptions to overlay the Featured Image.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'is_paged',
|
||||
'title' => __( 'Show Featured Image on Subsequent Blog Pages', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Show featured image on pages 2+ of blogs and archives.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'feed_image',
|
||||
'title' => __( 'Add Featured Image to Feed?', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Optionally, add the featured image to your RSS feed.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'thumbnails',
|
||||
'title' => __( 'Archive Thumbnails', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Use term/post type fallback images for content archives?', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'shortcodes',
|
||||
'title' => __( 'Add Shortcode Buttons', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Add optional shortcode buttons to the post editor', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the fields for the style tab.
|
||||
* @return array
|
||||
*/
|
||||
protected function define_style_fields() {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'less_header',
|
||||
'title' => __( 'Height', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'style',
|
||||
'label' => __( 'pixels to remove', 'display-featured-image-genesis' ),
|
||||
'min' => 0,
|
||||
'max' => 400,
|
||||
'description' => __( 'Changing this number will reduce the backstretch image height by this number of pixels. Default is zero.', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
),
|
||||
array(
|
||||
'id' => 'max_height',
|
||||
'title' => __( 'Maximum Height', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'style',
|
||||
'label' => __( 'pixels', 'display-featured-image-genesis' ),
|
||||
'min' => 100,
|
||||
'max' => 1000,
|
||||
'description' => __( 'Optionally, set a max-height value for the header image; it will be added to your CSS.', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
),
|
||||
array(
|
||||
'id' => 'centeredX',
|
||||
'title' => __( 'Center Horizontally', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_radio_buttons',
|
||||
'section' => 'style',
|
||||
'choices' => $this->pick_center(),
|
||||
'legend' => __( 'Center the backstretch image on the horizontal axis?', 'display-featured-image-genesis' ),
|
||||
'type' => 'radio',
|
||||
),
|
||||
array(
|
||||
'id' => 'centeredY',
|
||||
'title' => __( 'Center Vertically', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_radio_buttons',
|
||||
'section' => 'style',
|
||||
'choices' => $this->pick_center(),
|
||||
'legend' => __( 'Center the backstretch image on the vertical axis?', 'display-featured-image-genesis' ),
|
||||
'type' => 'radio',
|
||||
),
|
||||
array(
|
||||
'id' => 'fade',
|
||||
'title' => __( 'Fade', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'style',
|
||||
'label' => __( 'milliseconds', 'display-featured-image-genesis' ),
|
||||
'min' => 0,
|
||||
'max' => 20000,
|
||||
'type' => 'number',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the fields for the content types tab.
|
||||
* @return array
|
||||
*/
|
||||
protected function define_cpt_fields() {
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => 'skip',
|
||||
'title' => __( 'Skip Content Types', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'fallback',
|
||||
'title' => __( 'Prefer Fallback Images', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'description' => __( 'Select content types which should always use a fallback image, even if a featured image has been set.', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large',
|
||||
'title' => __( 'Force Large Images', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'description' => __( 'Select content types which should always prefer to use the large image size instead of the backstretch, even if a backstretch size image is available (singular posts/pages, not archives).', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
|
||||
$custom_pages = array(
|
||||
'search' => __( 'Search Results', 'display-featured-image-genesis' ),
|
||||
'fourohfour' => __( '404 Page', 'display-featured-image-genesis' ),
|
||||
);
|
||||
$post_types = array_merge( $custom_pages, $this->get_post_types() );
|
||||
foreach ( $post_types as $post_type => $label ) {
|
||||
$fields[] = array(
|
||||
'id' => esc_attr( $post_type ),
|
||||
'title' => esc_attr( $label ),
|
||||
'callback' => 'set_cpt_image',
|
||||
'section' => 'cpt',
|
||||
'type' => 'image',
|
||||
);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the fields for the advanced tab.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function define_advanced_fields() {
|
||||
return array(
|
||||
array(
|
||||
'id' => 'backstretch_hook',
|
||||
'title' => __( 'Backstretch Image Hook', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'advanced',
|
||||
'choices' => array(
|
||||
'genesis_before_header' => 'genesis_before_header',
|
||||
'genesis_header' => 'genesis_header',
|
||||
'genesis_after_header' => 'genesis_after_header ' . __( '(default)', 'display-featured-image-genesis' ),
|
||||
'genesis_before_content_sidebar_wrap' => 'genesis_before_content_sidebar_wrap',
|
||||
'genesis_before_content' => 'genesis_before_content',
|
||||
),
|
||||
'type' => 'select',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'backstretch_priority',
|
||||
'title' => __( 'Backstretch Image Priority', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'advanced',
|
||||
'label' => '',
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
'description' => __( 'Default: 10', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large_hook',
|
||||
'title' => __( 'Large Image Hook', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'advanced',
|
||||
'choices' => $this->large_hook_options(),
|
||||
'description' => __( 'Changing this hook only affects single post/page output, due to overlap/conflict with archive page output.', 'display-featured-image-genesis' ),
|
||||
'type' => 'select',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large_priority',
|
||||
'title' => __( 'Large Image Priority', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'advanced',
|
||||
'label' => '',
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
'description' => __( 'Default: 12', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function pick_center() {
|
||||
return array(
|
||||
1 => __( 'Center', 'display-featured-image-genesis' ),
|
||||
0 => __( 'Do Not Center', 'display-featured-image-genesis' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post types as options.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_post_types() {
|
||||
$post_types = $this->get_content_types_built_in();
|
||||
$options = array();
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$object = get_post_type_object( $post_type );
|
||||
$options[ $post_type ] = $object->label;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hooks for the large image.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function large_hook_options() {
|
||||
$hooks = array(
|
||||
'genesis_before_loop' => 'genesis_before_loop ' . __( '(default)', 'display-featured-image-genesis' ),
|
||||
'genesis_after_header' => 'genesis_after_header',
|
||||
'genesis_before_content_sidebar_wrap' => 'genesis_before_content_sidebar_wrap',
|
||||
);
|
||||
$html5 = genesis_html5() ? array(
|
||||
'genesis_before_entry' => 'genesis_before_entry ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
'genesis_entry_header' => 'genesis_entry_header ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
'genesis_entry_content' => 'genesis_entry_content ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
) : array();
|
||||
|
||||
return array_merge( $hooks, $html5 );
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,6 @@
|
||||
*/
|
||||
class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Genesis_Helper {
|
||||
|
||||
/**
|
||||
* The common plugin class.
|
||||
* @var $common \Display_Featured_Image_Genesis_Common
|
||||
*/
|
||||
protected $common;
|
||||
|
||||
/**
|
||||
* The plugin admin page.
|
||||
* @var $page string
|
||||
@@ -37,7 +31,6 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
*/
|
||||
public function do_submenu_page() {
|
||||
|
||||
$this->common = new Display_Featured_Image_Genesis_Common();
|
||||
$this->setting = $this->get_display_setting();
|
||||
|
||||
add_theme_page(
|
||||
@@ -56,12 +49,27 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
* Build out the settings page sections/fields.
|
||||
*/
|
||||
public function build_settings_page() {
|
||||
include_once plugin_dir_path( __FILE__ ) . 'class-displayfeaturedimagegenesis-settings-define.php';
|
||||
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
|
||||
$sections = $definitions->register_sections();
|
||||
$this->fields = $definitions->register_fields();
|
||||
$sections = include 'sections.php';
|
||||
$this->fields = $this->get_fields();
|
||||
$this->add_sections( $sections );
|
||||
$this->add_fields( $this->fields, $sections );
|
||||
|
||||
include_once 'class-displayfeaturedimagegenesis-helptabs.php';
|
||||
$help = new Display_Featured_Image_Genesis_HelpTabs();
|
||||
$help->help();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the settings fields.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_fields() {
|
||||
$main = include 'fields-main.php';
|
||||
$style = include 'fields-style.php';
|
||||
$cpt = include 'fields-cpt.php';
|
||||
$advanced = include 'fields-advanced.php';
|
||||
|
||||
return array_merge( $main, $style, $cpt, $advanced );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -118,13 +126,28 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
* @since 2.5.0
|
||||
*/
|
||||
protected function do_tabs( $active_tab ) {
|
||||
$tabs = $this->define_tabs();
|
||||
$tabs = include 'tabs.php';
|
||||
$output = '<div class="nav-tab-wrapper">';
|
||||
$output .= sprintf( '<h2 id="settings-tabs" class="screen-reader-text">%s</h2>', __( 'Settings Tabs', 'display-featured-image-genesis' ) );
|
||||
$output .= '<ul>';
|
||||
foreach ( $tabs as $tab ) {
|
||||
$class = $active_tab === $tab['id'] ? ' nav-tab-active' : '';
|
||||
$output .= sprintf( '<li><a href="themes.php?page=%s&tab=%s" class="nav-tab%s">%s</a></li>', $this->page, $tab['id'], $class, $tab['tab'] );
|
||||
$class = 'nav-tab';
|
||||
if ( $active_tab === $tab['id'] ) {
|
||||
$class .= ' nav-tab-active';
|
||||
}
|
||||
$query = add_query_arg(
|
||||
array(
|
||||
'page' => $this->page,
|
||||
'tab' => $tab['id'],
|
||||
),
|
||||
'themes.php'
|
||||
);
|
||||
$output .= sprintf(
|
||||
'<li><a href="%s" class="%s">%s</a></li>',
|
||||
esc_url( $query ),
|
||||
$class,
|
||||
$tab['tab']
|
||||
);
|
||||
}
|
||||
$output .= '</ul>';
|
||||
$output .= '</div>';
|
||||
@@ -138,36 +161,7 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
* @since 1.1.0
|
||||
*/
|
||||
public function register_settings() {
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimagegenesis', array(
|
||||
$this,
|
||||
'do_validation_things',
|
||||
) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Define tabs for the settings page.
|
||||
* @return array
|
||||
* @since 2.6.0
|
||||
*/
|
||||
protected function define_tabs() {
|
||||
return array(
|
||||
'main' => array(
|
||||
'id' => 'main',
|
||||
'tab' => __( 'Main', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'style' => array(
|
||||
'id' => 'style',
|
||||
'tab' => __( 'Backstretch Output', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'cpt' => array(
|
||||
'id' => 'cpt',
|
||||
'tab' => __( 'Content Types', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'advanced' => array(
|
||||
'id' => 'advanced',
|
||||
'tab' => __( 'Advanced', 'display-featured-image-genesis' ),
|
||||
),
|
||||
);
|
||||
register_setting( 'displayfeaturedimagegenesis', 'displayfeaturedimagegenesis', array( $this, 'do_validation_things' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -183,7 +177,15 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
* Style section description
|
||||
*/
|
||||
public function style_section_description() {
|
||||
return __( 'These settings modify the output style/methods for the backstretch image.', 'display-featured-image-genesis' );
|
||||
return __( 'These settings modify the output style/methods for the banner image.', 'display-featured-image-genesis' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Backtretch section description
|
||||
* @return string
|
||||
*/
|
||||
public function backstretch_section_description() {
|
||||
return __( 'These settings apply only to the backstretch (script) banner image.', 'display-featured-image-genesis' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -287,6 +289,51 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
printf( '<p class="description">%s</p>', wp_kses_post( $description ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function pick_center() {
|
||||
return array(
|
||||
1 => __( 'Center', 'display-featured-image-genesis' ),
|
||||
0 => __( 'Do Not Center', 'display-featured-image-genesis' ),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the post types as options.
|
||||
* @return array
|
||||
*/
|
||||
protected function get_post_types() {
|
||||
$post_types = $this->get_content_types_built_in();
|
||||
$options = array();
|
||||
foreach ( $post_types as $post_type ) {
|
||||
$object = get_post_type_object( $post_type );
|
||||
$options[ $post_type ] = $object->label;
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hooks for the large image.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function large_hook_options() {
|
||||
$hooks = array(
|
||||
'genesis_before_loop' => 'genesis_before_loop ' . __( '(default)', 'display-featured-image-genesis' ),
|
||||
'genesis_after_header' => 'genesis_after_header',
|
||||
'genesis_before_content_sidebar_wrap' => 'genesis_before_content_sidebar_wrap',
|
||||
);
|
||||
$html5 = genesis_html5() ? array(
|
||||
'genesis_before_entry' => 'genesis_before_entry ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
'genesis_entry_header' => 'genesis_entry_header ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
'genesis_entry_content' => 'genesis_entry_content ' . __( '(HTML5 themes)', 'display-featured-image-genesis' ),
|
||||
) : array();
|
||||
|
||||
return array_merge( $hooks, $html5 );
|
||||
}
|
||||
|
||||
/**
|
||||
* validate all inputs
|
||||
*
|
||||
@@ -308,11 +355,8 @@ class Display_Featured_Image_Genesis_Settings extends Display_Featured_Image_Gen
|
||||
check_admin_referer( $action, $nonce );
|
||||
$new_value = array_merge( $this->setting, $new_value );
|
||||
|
||||
foreach ( array( 'define', 'validate' ) as $file ) {
|
||||
include_once plugin_dir_path( __FILE__ ) . "class-displayfeaturedimagegenesis-settings-{$file}.php";
|
||||
}
|
||||
$definitions = new Display_Featured_Image_Genesis_Settings_Define();
|
||||
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $definitions->register_fields(), $this->setting );
|
||||
include_once 'class-displayfeaturedimagegenesis-settings-validate.php';
|
||||
$validation = new Display_Featured_Image_Genesis_Settings_Validate( $this->get_fields(), $this->setting );
|
||||
|
||||
return $validation->validate( $new_value );
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
array(
|
||||
'id' => 'backstretch_hook',
|
||||
'title' => __( 'Backstretch Image Hook', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'advanced',
|
||||
'choices' => array(
|
||||
'genesis_before_header' => 'genesis_before_header',
|
||||
'genesis_header' => 'genesis_header',
|
||||
'genesis_after_header' => 'genesis_after_header ' . __( '(default)', 'display-featured-image-genesis' ),
|
||||
'genesis_before_content_sidebar_wrap' => 'genesis_before_content_sidebar_wrap',
|
||||
'genesis_before_content' => 'genesis_before_content',
|
||||
),
|
||||
'type' => 'select',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'backstretch_priority',
|
||||
'title' => __( 'Backstretch Image Priority', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'advanced',
|
||||
'label' => '',
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
'description' => __( 'Default: 10', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large_hook',
|
||||
'title' => __( 'Large Image Hook', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'advanced',
|
||||
'choices' => $this->large_hook_options(),
|
||||
'description' => __( 'Changing this hook only affects single post/page output, due to overlap/conflict with archive page output.', 'display-featured-image-genesis' ),
|
||||
'type' => 'select',
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large_priority',
|
||||
'title' => __( 'Large Image Priority', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'advanced',
|
||||
'label' => '',
|
||||
'min' => 1,
|
||||
'max' => 100,
|
||||
'description' => __( 'Default: 12', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
$fields = array(
|
||||
array(
|
||||
'id' => 'skip',
|
||||
'title' => __( 'Skip Content Types', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'fallback',
|
||||
'title' => __( 'Prefer Fallback Images', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'description' => __( 'Select content types which should always use a fallback image, even if a featured image has been set.', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
array(
|
||||
'id' => 'large',
|
||||
'title' => __( 'Force Large Images', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox_array',
|
||||
'section' => 'cpt_sitewide',
|
||||
'options' => $this->get_post_types(),
|
||||
'description' => __( 'Select content types which should always prefer to use the large image size instead of the banner, even if a banner size image is available (singular posts/pages, not archives).', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
|
||||
$custom_pages = array(
|
||||
'search' => __( 'Search Results', 'display-featured-image-genesis' ),
|
||||
'fourohfour' => __( '404 Page', 'display-featured-image-genesis' ),
|
||||
);
|
||||
$post_types = array_merge( $custom_pages, $this->get_post_types() );
|
||||
foreach ( $post_types as $post_type => $label ) {
|
||||
$fields[] = array(
|
||||
'id' => esc_attr( $post_type ),
|
||||
'title' => esc_attr( $label ),
|
||||
'callback' => 'set_cpt_image',
|
||||
'section' => 'cpt',
|
||||
'type' => 'image',
|
||||
);
|
||||
}
|
||||
|
||||
return $fields;
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
|
||||
$common = new Display_Featured_Image_Genesis_Common();
|
||||
$large = $common->minimum_backstretch_width();
|
||||
|
||||
return array(
|
||||
array(
|
||||
'id' => 'default',
|
||||
'title' => __( 'Default Featured Image', 'display-featured-image-genesis' ),
|
||||
'callback' => 'set_default_image',
|
||||
'section' => 'default',
|
||||
'type' => 'image',
|
||||
),
|
||||
array(
|
||||
'id' => 'always_default',
|
||||
'title' => __( 'Always Use Default', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'default',
|
||||
'label' => __( 'Always use the default image, even if a featured image is set.', 'display-featured-image-genesis' ),
|
||||
'description' => sprintf(
|
||||
/* translators: placeholder is a number equivalent to the width of the site's Large image (Settings > Media) */
|
||||
esc_html__( 'If you would like to use a default image for the featured image, upload it here. Must be at least %1$s pixels wide.', 'display-featured-image-genesis' ),
|
||||
absint( $large + 1 )
|
||||
),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'image_size',
|
||||
'title' => __( 'Preferred Image Size', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_select',
|
||||
'section' => 'main',
|
||||
'choices' => apply_filters(
|
||||
'displayfeaturedimagegenesis_image_size_choices',
|
||||
array(
|
||||
'displayfeaturedimage_backstretch' => __( 'Banner (default)', 'display-featured-image-genesis' ),
|
||||
'large' => __( 'Large', 'display-featured-image-genesis' ),
|
||||
)
|
||||
),
|
||||
'type' => 'select',
|
||||
),
|
||||
array(
|
||||
'id' => 'exclude_front',
|
||||
'title' => __( 'Skip Front Page', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Do not show the Featured Image on the Front Page of the site.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'keep_titles',
|
||||
'title' => __( 'Do Not Move Titles', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Do not move the titles to overlay the banner featured image.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'move_excerpts',
|
||||
'title' => __( 'Move Excerpts/Archive Descriptions', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Move excerpts (if used) on single pages and move archive/taxonomy descriptions to overlay the Featured Image.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'is_paged',
|
||||
'title' => __( 'Show Featured Image on Subsequent Blog Pages', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Show featured image on pages 2+ of blogs and archives.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'feed_image',
|
||||
'title' => __( 'Add Featured Image to Feed?', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Optionally, add the featured image to your RSS feed.', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'thumbnails',
|
||||
'title' => __( 'Archive Thumbnails', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'archives',
|
||||
'label' => __( 'Use term/post type fallback images for content archives?', 'display-featured-image-genesis' ),
|
||||
'type' => 'checkbox',
|
||||
),
|
||||
array(
|
||||
'id' => 'shortcodes',
|
||||
'title' => __( 'Add Shortcode Buttons', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'section' => 'main',
|
||||
'label' => __( 'Add optional shortcode buttons to the post editor', 'display-featured-image-genesis' ),
|
||||
'skip' => true,
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
array(
|
||||
'id' => 'scriptless',
|
||||
'title' => __( 'Disable JavaScript', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_checkbox',
|
||||
'type' => 'checkbox',
|
||||
'section' => 'style',
|
||||
'label' => __( 'Instead of using the Backstretch featured image, use a banner image which relies only on CSS.', 'display-featured-image-genesis' ),
|
||||
),
|
||||
array(
|
||||
'id' => 'less_header',
|
||||
'title' => __( 'Height', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'backstretch',
|
||||
'label' => __( 'pixels to remove', 'display-featured-image-genesis' ),
|
||||
'min' => 0,
|
||||
'max' => 400,
|
||||
'description' => __( 'Changing this number will reduce the backstretch banner image height by this number of pixels. Default is zero.', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
),
|
||||
array(
|
||||
'id' => 'max_height',
|
||||
'title' => __( 'Maximum Height', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'style',
|
||||
'label' => __( 'pixels', 'display-featured-image-genesis' ),
|
||||
'min' => 100,
|
||||
'max' => 1000,
|
||||
'description' => __( 'Optionally, set a max-height value for the header image; it will be added to your CSS.', 'display-featured-image-genesis' ),
|
||||
'type' => 'number',
|
||||
),
|
||||
array(
|
||||
'id' => 'centeredX',
|
||||
'title' => __( 'Center Horizontally', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_radio_buttons',
|
||||
'section' => 'backstretch',
|
||||
'choices' => $this->pick_center(),
|
||||
'legend' => __( 'Center the backstretch image on the horizontal axis?', 'display-featured-image-genesis' ),
|
||||
'type' => 'radio',
|
||||
),
|
||||
array(
|
||||
'id' => 'centeredY',
|
||||
'title' => __( 'Center Vertically', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_radio_buttons',
|
||||
'section' => 'backstretch',
|
||||
'choices' => $this->pick_center(),
|
||||
'legend' => __( 'Center the backstretch image on the vertical axis?', 'display-featured-image-genesis' ),
|
||||
'type' => 'radio',
|
||||
),
|
||||
array(
|
||||
'id' => 'fade',
|
||||
'title' => __( 'Fade', 'display-featured-image-genesis' ),
|
||||
'callback' => 'do_number',
|
||||
'section' => 'backstretch',
|
||||
'label' => __( 'milliseconds', 'display-featured-image-genesis' ),
|
||||
'min' => 0,
|
||||
'max' => 20000,
|
||||
'type' => 'number',
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'main' => array(
|
||||
'id' => 'main',
|
||||
'title' => __( 'Optional Sitewide Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'archives' => array(
|
||||
'id' => 'archives',
|
||||
'title' => __( 'Optional Archive Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'default' => array(
|
||||
'id' => 'default',
|
||||
'title' => __( 'Optional Default Image', 'display-featured-image-genesis' ),
|
||||
'tab' => 'main',
|
||||
),
|
||||
'style' => array(
|
||||
'id' => 'style',
|
||||
'title' => __( 'Display Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'style',
|
||||
),
|
||||
'backstretch' => array(
|
||||
'id' => 'backstretch',
|
||||
'title' => __( 'Backstretch Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'style',
|
||||
),
|
||||
'cpt_sitewide' => array(
|
||||
'id' => 'cpt_sitewide',
|
||||
'title' => __( 'Sitewide Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'cpt',
|
||||
),
|
||||
'cpt' => array(
|
||||
'id' => 'cpt',
|
||||
'title' => __( 'Featured Images for Custom Content Types', 'display-featured-image-genesis' ),
|
||||
'tab' => 'cpt',
|
||||
),
|
||||
'advanced' => array(
|
||||
'id' => 'advanced',
|
||||
'title' => __( 'Advanced Plugin Settings', 'display-featured-image-genesis' ),
|
||||
'tab' => 'advanced',
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'main' => array(
|
||||
'id' => 'main',
|
||||
'tab' => __( 'Main', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'style' => array(
|
||||
'id' => 'style',
|
||||
'tab' => __( 'Banner Output', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'cpt' => array(
|
||||
'id' => 'cpt',
|
||||
'tab' => __( 'Content Types', 'display-featured-image-genesis' ),
|
||||
),
|
||||
'advanced' => array(
|
||||
'id' => 'advanced',
|
||||
'tab' => __( 'Advanced', 'display-featured-image-genesis' ),
|
||||
),
|
||||
);
|
||||
@@ -0,0 +1,70 @@
|
||||
.has-leader .site-inner {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.big-leader {
|
||||
overflow: hidden;
|
||||
max-height: 100vh;
|
||||
position: relative;
|
||||
|
||||
.wrap {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
&--scriptless {
|
||||
height: auto;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
object-fit: cover;
|
||||
}
|
||||
}
|
||||
|
||||
.entry-title,
|
||||
.archive-title {
|
||||
&.featured-image-overlay {
|
||||
color: #fff;
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.excerpt,
|
||||
.archive-description {
|
||||
margin-bottom: 24px;
|
||||
padding: 24px;
|
||||
background: rgba(255,255,255,0.85);
|
||||
}
|
||||
|
||||
p {
|
||||
margin-top: 18px;
|
||||
margin-bottom: 0;
|
||||
|
||||
.home & {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
&:last-child {
|
||||
.home & {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.excerpt .entry-title,
|
||||
.archive-description .archive-title {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.backstretch.no-js {
|
||||
max-height: 600px;
|
||||
}
|
||||
|
||||
img.featured {
|
||||
max-width: 100%;
|
||||
}
|
||||
Reference in New Issue
Block a user