From 550fe7ef202c64bd0cbdea03b27e2f974ee29a28 Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Fri, 15 Sep 2017 12:01:50 -0400 Subject: [PATCH 1/6] =?UTF-8?q?CPT=20archive=20images=20would=20not=20disp?= =?UTF-8?q?lay=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when using custom archive settings if Mai Content Archives images were not set to display. --- lib/structure/archives.php | 9 +++++++++ lib/structure/singular.php | 1 + 2 files changed, 10 insertions(+) diff --git a/lib/structure/archives.php b/lib/structure/archives.php index 4760d9c..2c57f00 100644 --- a/lib/structure/archives.php +++ b/lib/structure/archives.php @@ -384,6 +384,15 @@ function mai_do_content_archive_archive_options() { // Add the image back, in a custom location mai_do_archive_image( $image_location ); + /** + * Content Archive Thumbnail. + * We need to force this option because genesis_do_post_image() checks if 'content_archive_thumbnail' is enabled, + * even though Mai Pro has its own requirements to display, it won't without forcing this. + */ + add_filter( 'genesis_pre_get_option_content_archive_thumbnail', function( $option ) use ( $content_archive_thumbnail ) { + return $content_archive_thumbnail; + }); + // Image Size add_filter( 'genesis_pre_get_option_image_size', function( $option ) use ( $image_size ) { return $image_size; diff --git a/lib/structure/singular.php b/lib/structure/singular.php index d97e369..f6c6f0f 100755 --- a/lib/structure/singular.php +++ b/lib/structure/singular.php @@ -46,6 +46,7 @@ function mai_woo_remove_featured_image() { if ( ! is_product() ) { return; } + // Get post types to display featured image on. $key = sprintf( 'singular_image_%s', get_post_type() ); $display = genesis_get_option( $key ); From 57d66f1aeac3a1164427b6340f785e4ff8329606 Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Fri, 15 Sep 2017 12:02:12 -0400 Subject: [PATCH 2/6] =?UTF-8?q?Some=20default=20settings=20were=20getting?= =?UTF-8?q?=20changed=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when updating/saving via Genesis > Theme Settings. --- lib/options.php | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/lib/options.php b/lib/options.php index 51da8d8..7bb836e 100644 --- a/lib/options.php +++ b/lib/options.php @@ -9,23 +9,34 @@ * * @return array */ -add_filter( 'pre_update_option_genesis-settings', 'mai_enforce_custom_genesis_settings', 99, 2 ); +add_filter( 'pre_update_option_genesis-settings', 'mai_enforce_custom_genesis_settings', 10, 2 ); function mai_enforce_custom_genesis_settings( $new_value, $old_value ) { + + // Bail if this isn't happening from a form submission page. + if ( ! isset( $_POST ) || empty( $_POST ) ) { + return $new_value; + } + + // Bail if this isn't happening on a page that's submitting a 'genesis-settings' form. + if ( ! isset( $_POST['genesis-settings'] ) || empty( $_POST['genesis-settings'] ) ) { + return $new_value; + } + + // Get the submitted and existing settings values. + $values = $_POST[ 'genesis-settings' ]; $settings = get_option( 'genesis-settings' ); - foreach ( (array) $settings as $setting => $value ) { + + // Loop through em. + foreach ( (array) $settings as $key => $value ) { /** - * Header/Footer scripts get wp_slash sanitization automatically, we need to unslash before that gets re-applied. - * - * @see genesis/lib/admin/theme-settings save() method. + * If a custom setting is not part of the $_POST submission, + * we need to add to the $new_value array it so it's not lost. */ - if ( in_array( $setting, array( 'header_scripts', 'footer_scripts' ) ) ) { - $new_value[ $setting ] = wp_unslash( $value ); - } - // If a custom setting is not here, we need to add it so it's not lost. - if ( ! isset( $new_value[ $setting ] ) ) { - $new_value[ $setting ] = $value; + if ( ! isset( $values[ $key ] ) ) { + $new_value[ $key ] = genesis_get_option( $key ); } } + return $new_value; } From bd386da599892c975284d96f9fe7f840e735f97f Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Fri, 15 Sep 2017 12:02:35 -0400 Subject: [PATCH 3/6] Cleanup theme settings metabox & update changelog --- CHANGES.md | 4 ++++ lib/settings/metaboxes/metaboxes.php | 16 +++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 4a97c4b..f02f455 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,9 @@ ### Changelog +#### 1.1.4 (9/15/17) +* Fixed: CPT archive images would not display when using custom archive settings if Mai Content Archives images were not set to display. +* Fixed: Some default settings were getting changed when updating/saving via Genesis > Theme Settings. + #### 1.1.3.1 (9/14/17) * Fixed: Header/Footer scripts getting slashed when updating settings via the Customizer. diff --git a/lib/settings/metaboxes/metaboxes.php b/lib/settings/metaboxes/metaboxes.php index 4d381c2..6b2293a 100755 --- a/lib/settings/metaboxes/metaboxes.php +++ b/lib/settings/metaboxes/metaboxes.php @@ -143,11 +143,13 @@ function mai_theme_settings_customizer_link( $pagehook ) { function mai_do_theme_settings_customizer_links() { // Mai Settings. printf( '

%s

', __( 'Edit theme settings in the customizer:', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'mai_settings' ), __( 'Mai Settings', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'mai_banner_area' ), __( 'Mai Banner Area', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'mai_content_archives' ), __( 'Mai Content Archives', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'mai_content_singular' ), __( 'Mai Content Singular', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'mai_site_layouts' ), __( 'Mai Site Layouts', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'genesis_breadcrumbs' ), __( 'Breadcrumbs', 'mai-pro-engine' ) ); - printf( '

%s

', mai_get_customizer_section_link( 'genesis_comments' ), __( 'Comments & Trackbacks', 'mai-pro-engine' ) ); + echo '

'; + printf( '%s  ', mai_get_customizer_section_link( 'mai_settings' ), __( 'Mai Settings', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'mai_banner_area' ), __( 'Mai Banner Area', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'mai_content_archives' ), __( 'Mai Content Archives', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'mai_content_singular' ), __( 'Mai Content Singular', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'mai_site_layouts' ), __( 'Mai Site Layouts', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'genesis_breadcrumbs' ), __( 'Breadcrumbs', 'mai-pro-engine' ) ); + printf( '%s  ', mai_get_customizer_section_link( 'genesis_comments' ), __( 'Comments & Trackbacks', 'mai-pro-engine' ) ); + echo '

'; } From 9239ae1f95ab73b9f288f038d8690c2c308d35ed Mon Sep 17 00:00:00 2001 From: Mike Hemberger Date: Fri, 15 Sep 2017 12:49:54 -0400 Subject: [PATCH 4/6] Update Slick to 1.8.0 force Slick focusOnChange to false to remove jumps --- assets/js/slick-init.js | 7 ++++--- assets/js/slick-init.min.js | 2 +- assets/js/slick.js | 38 +++++++++++++++++++++++-------------- assets/js/slick.min.js | 2 +- lib/scripts.php | 2 +- 5 files changed, 31 insertions(+), 20 deletions(-) diff --git a/assets/js/slick-init.js b/assets/js/slick-init.js index 5f30812..b81b126 100755 --- a/assets/js/slick-init.js +++ b/assets/js/slick-init.js @@ -76,16 +76,17 @@ jQuery(document).ready(function($) { } $(this).slick({ - adaptiveHeight: false, // true breaks things on image-bg aspect-ratio resize + adaptiveHeight: false, // true breaks things on image-bg aspect-ratio resize. arrows: arrows, autoplay: autoPlay, dots: dots, - fade: fade, // Things seem to blow up if columns is > 1 + fade: fade, // Things seem to blow up if columns is > 1. + focusOnChange: false, // This is Slick default as of 1.8.0, but i want to make sure, cause if true it makes things really jumpy. infinite: infinite, slidesToShow: slidesToShow, slidesToScroll: slidesToScroll, autoplaySpeed: speed, - cssEase: fade ? 'linear' : 'ease', // Use linear if fade is true, otherwise default is ease + cssEase: fade ? 'linear' : 'ease', // Use linear if fade is true, otherwise default is ease. responsive: [{ breakpoint: 1200, settings: { diff --git a/assets/js/slick-init.min.js b/assets/js/slick-init.min.js index c55bba7..e5bcd37 100755 --- a/assets/js/slick-init.min.js +++ b/assets/js/slick-init.min.js @@ -1 +1 @@ -jQuery(document).ready(function(e){var s=e(".mai-slider");s.length&&e.each(s,function(){var s=Boolean(e(this).data("arrows")),a=Boolean(e(this).data("autoplay")),t=Boolean(e(this).data("centermode")),o=Boolean(e(this).data("dots")),i=Boolean(e(this).data("fade")),d=Boolean(e(this).data("infinite")),l=parseInt(e(this).data("slidestoscroll")),n=parseInt(e(this).data("slidestoshow"));speed=parseInt(e(this).data("speed"));var r,h,c,p,S,B;B=(p=(h=l>(r=n>3?n-1:n)?r:l)>(c=r>2?r-1:r)?c:h)>(S=c>1?c-1:c)?S:p,e(this).slick({adaptiveHeight:!1,arrows:s,autoplay:a,dots:o,fade:i,infinite:d,slidesToShow:n,slidesToScroll:l,autoplaySpeed:speed,cssEase:i?"linear":"ease",responsive:[{breakpoint:1200,settings:{slidesToShow:r,slidesToScroll:h,centerMode:t}},{breakpoint:992,settings:{slidesToShow:c,slidesToScroll:p,centerMode:t}},{breakpoint:768,settings:{slidesToShow:S,slidesToScroll:B,centerMode:t}}]});var T=e(this).find(".slick-track"),f=Boolean(e(this).data("center")),u=Boolean(e(this).data("middle"));f&&T.addClass("center-xs"),u&&T.addClass("middle-xs")})}); \ No newline at end of file +jQuery(document).ready(function(e){var s=e(".mai-slider");s.length&&e.each(s,function(){var s=Boolean(e(this).data("arrows")),a=Boolean(e(this).data("autoplay")),t=Boolean(e(this).data("centermode")),o=Boolean(e(this).data("dots")),i=Boolean(e(this).data("fade")),d=Boolean(e(this).data("infinite")),l=parseInt(e(this).data("slidestoscroll")),n=parseInt(e(this).data("slidestoshow"));speed=parseInt(e(this).data("speed"));var r,h,c,p,S,f;f=(p=(h=l>(r=n>3?n-1:n)?r:l)>(c=r>2?r-1:r)?c:h)>(S=c>1?c-1:c)?S:p,e(this).slick({adaptiveHeight:!1,arrows:s,autoplay:a,dots:o,fade:i,focusOnChange:!1,infinite:d,slidesToShow:n,slidesToScroll:l,autoplaySpeed:speed,cssEase:i?"linear":"ease",responsive:[{breakpoint:1200,settings:{slidesToShow:r,slidesToScroll:h,centerMode:t}},{breakpoint:992,settings:{slidesToShow:c,slidesToScroll:p,centerMode:t}},{breakpoint:768,settings:{slidesToShow:S,slidesToScroll:f,centerMode:t}}]});var u=e(this).find(".slick-track"),B=Boolean(e(this).data("center")),T=Boolean(e(this).data("middle"));B&&u.addClass("center-xs"),T&&u.addClass("middle-xs")})}); \ No newline at end of file diff --git a/assets/js/slick.js b/assets/js/slick.js index bcd2fbc..9529989 100755 --- a/assets/js/slick.js +++ b/assets/js/slick.js @@ -6,7 +6,7 @@ |___/_|_|\___|_|\_(_)/ |___/ |__/ - Version: 1.7.1 + Version: 1.8.0 Author: Ken Wheeler Website: http://kenwheeler.github.io Docs: http://kenwheeler.github.io/slick @@ -61,6 +61,7 @@ edgeFriction: 0.35, fade: false, focusOnSelect: false, + focusOnChange: false, infinite: true, initialSlide: 0, lazyLoad: 'ondemand', @@ -773,8 +774,8 @@ _.$nextArrow && _.$nextArrow.off('click.slick', _.changeSlide); if (_.options.accessibility === true) { - _.$prevArrow.off('keydown.slick', _.keyHandler); - _.$nextArrow.off('keydown.slick', _.keyHandler); + _.$prevArrow && _.$prevArrow.off('keydown.slick', _.keyHandler); + _.$nextArrow && _.$nextArrow.off('keydown.slick', _.keyHandler); } } @@ -1079,7 +1080,8 @@ targetLeft, verticalHeight, verticalOffset = 0, - targetSlide; + targetSlide, + coef; _.slideOffset = 0; verticalHeight = _.$slides.first().outerHeight(true); @@ -1087,7 +1089,16 @@ if (_.options.infinite === true) { if (_.slideCount > _.options.slidesToShow) { _.slideOffset = (_.slideWidth * _.options.slidesToShow) * -1; - verticalOffset = (verticalHeight * _.options.slidesToShow) * -1; + coef = -1 + + if (_.options.vertical === true && _.options.centerMode === true) { + if (_.options.slidesToShow === 2) { + coef = -1.5; + } else if (_.options.slidesToShow === 1) { + coef = -2 + } + } + verticalOffset = (verticalHeight * _.options.slidesToShow) * coef; } if (_.slideCount % _.options.slidesToScroll !== 0) { if (slideIndex + _.options.slidesToScroll > _.slideCount && _.slideCount > _.options.slidesToShow) { @@ -1686,12 +1697,10 @@ if (_.options.accessibility === true) { _.initADA(); - // for non-autoplay: once active slide (group) has updated, set focus on first newly showing slide - if (!_.options.autoplay) { - var $currentSlide = $(_.$slides.get(_.currentSlide)); - var x = window.scrollX, y = window.scrollY; - $currentSlide.attr('tabindex', 0).focus(); - window.scrollTo(x, y); + + if (_.options.focusOnChange) { + var $currentSlide = $(_.$slides.get(_.currentSlide)); + $currentSlide.attr('tabindex', 0).focus(); } } @@ -2287,14 +2296,15 @@ if (_.options.centerMode === true) { + var evenCoef = _.options.slidesToShow % 2 === 0 ? 1 : 0; + centerOffset = Math.floor(_.options.slidesToShow / 2); if (_.options.infinite === true) { if (index >= centerOffset && index <= (_.slideCount - 1) - centerOffset) { - _.$slides - .slice(index - centerOffset, index + centerOffset + 1) + .slice(index - centerOffset + evenCoef, index + centerOffset + 1) .addClass('slick-active') .attr('aria-hidden', 'false'); @@ -2302,7 +2312,7 @@ indexOffset = _.options.slidesToShow + index; allSlides - .slice(indexOffset - centerOffset + 1, indexOffset + centerOffset + 2) + .slice(indexOffset - centerOffset + 1 + evenCoef, indexOffset + centerOffset + 2) .addClass('slick-active') .attr('aria-hidden', 'false'); diff --git a/assets/js/slick.min.js b/assets/js/slick.min.js index 812efe2..42172c2 100755 --- a/assets/js/slick.min.js +++ b/assets/js/slick.min.js @@ -1 +1 @@ -!function(i){"use strict";"function"==typeof define&&define.amd?define(["jquery"],i):"undefined"!=typeof exports?module.exports=i(require("jquery")):i(jQuery)}(function(i){"use strict";var e=window.Slick||{};(e=function(){var e=0;return function(t,o){var s,n=this;n.defaults={accessibility:!0,adaptiveHeight:!1,appendArrows:i(t),appendDots:i(t),arrows:!0,asNavFor:null,prevArrow:'',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('',nextArrow:'',autoplay:!1,autoplaySpeed:3e3,centerMode:!1,centerPadding:"50px",cssEase:"ease",customPaging:function(e,t){return i('