From 2e9099e285ba0088c9d119d821e587f1b8199b77 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Wed, 1 May 2019 16:33:40 +0200 Subject: [PATCH 01/41] Prevent form creation attempts if WPForms Lite version is < 1.5.2 Creating a working form via the WPForms API requires 1.5.2 or higher. If the site already has WPForms Lite installed but it's an older version, form creation will fail, breaking the onboarding process. --- lib/wpforms.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/wpforms.php b/lib/wpforms.php index e0bb3d12..68df1260 100644 --- a/lib/wpforms.php +++ b/lib/wpforms.php @@ -24,6 +24,18 @@ function studiopress_maybe_create_wpforms_form() { // phpcs:ignore -- studiopres return; } + // Form creation requires WPForms 1.5.2 or higher. + // If the site already as an earlier version of the plugin installed, don't create a form. + // Plugins do not get upgraded during one-click theme setup. + if ( function_exists( 'get_plugins' ) ) { + $plugin_data = get_plugins(); + $wpforms_lite_version = isset( $plugin_data['wpforms-lite/wpforms.php']['Version'] ) ? $plugin_data['wpforms-lite/wpforms.php']['Version'] : ''; + + if ( version_compare( $wpforms_lite_version, '1.5.2', '<' ) ) { + return; + } + } + $existing_form_id = get_option( 'genesis_onboarding_wpforms_id' ); if ( $existing_form_id ) { From 972580c7be678604cc361fbc037af906b0f2330c Mon Sep 17 00:00:00 2001 From: Jen Baumann Date: Fri, 3 May 2019 08:37:02 -0400 Subject: [PATCH 02/41] Switch to sticky positioning --- style.css | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/style.css b/style.css index 2527bcde..88b941c0 100755 --- a/style.css +++ b/style.css @@ -1461,11 +1461,15 @@ p.entry-meta { --------------------------------------------- */ .site-header { - position: fixed; - width: 100%; + position: sticky; + top: 0; z-index: 9999; } + .admin-bar .site-header { + top: 32px; + } + /* Genesis Menu --------------------------------------------- */ @@ -1553,7 +1557,6 @@ p.entry-meta { --------------------------------------------- */ .site-inner { - margin-top: 70px; max-width: 1140px; } From a102bf16d3b272b8a38c0e23ba47306af1b61486 Mon Sep 17 00:00:00 2001 From: Jen Baumann Date: Fri, 3 May 2019 08:37:36 -0400 Subject: [PATCH 03/41] Remove margin script --- functions.php | 8 ------ js/genesis-sample.js | 59 -------------------------------------------- 2 files changed, 67 deletions(-) delete mode 100644 js/genesis-sample.js diff --git a/functions.php b/functions.php index f022adfa..44786345 100755 --- a/functions.php +++ b/functions.php @@ -92,14 +92,6 @@ function genesis_sample_enqueue_scripts_styles() { genesis_sample_responsive_menu_settings() ); - wp_enqueue_script( - 'genesis-sample', - get_stylesheet_directory_uri() . '/js/genesis-sample.js', - array( 'jquery' ), - CHILD_THEME_VERSION, - true - ); - } /** diff --git a/js/genesis-sample.js b/js/genesis-sample.js deleted file mode 100644 index 8d600de9..00000000 --- a/js/genesis-sample.js +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Genesis Sample entry point. - * - * @package GenesisSample\JS - * @author StudioPress - * @license GPL-2.0-or-later - */ - -var genesisSample = ( function( $ ) { - 'use strict'; - - /** - * Adjust site inner margin top to compensate for sticky header height. - * - * @since 2.6.0 - */ - var moveContentBelowFixedHeader = function() { - var siteInnerMarginTop = 0; - - if ( 'fixed' === $( '.site-header' ).css( 'position' ) ) { - siteInnerMarginTop = $( '.site-header' ).outerHeight(); - } - - $( '.site-inner' ).css( 'margin-top', siteInnerMarginTop ); - }, - - /** - * Initialize Genesis Sample. - * - * Internal functions to execute on full page load. - * - * @since 2.6.0 - */ - load = function() { - moveContentBelowFixedHeader(); - - $( window ).resize( function() { - moveContentBelowFixedHeader(); - }); - - // Run after the Customizer updates. - // 1.5s delay is to allow logo area reflow. - if ( 'undefined' != typeof wp && 'undefined' != typeof wp.customize ) { - wp.customize.bind( 'change', function( setting ) { - setTimeout( function() { - moveContentBelowFixedHeader(); - }, 1500 ); - }); - } - }; - - // Expose the load and ready functions. - return { - load: load - }; - -}( jQuery ) ); - -jQuery( window ).on( 'load', genesisSample.load ); From 299214ee91b6b3aa909bb665ba0ce04967cae8a4 Mon Sep 17 00:00:00 2001 From: Jen Baumann Date: Fri, 3 May 2019 08:39:45 -0400 Subject: [PATCH 04/41] Autoprefix sticky positioning --- style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/style.css b/style.css index 88b941c0..f3c47e37 100755 --- a/style.css +++ b/style.css @@ -1461,6 +1461,7 @@ p.entry-meta { --------------------------------------------- */ .site-header { + position: -webkit-sticky; position: sticky; top: 0; z-index: 9999; From 66c03e60cbbb063d1f37182fd6dd2a47d7c7f357 Mon Sep 17 00:00:00 2001 From: Jen Baumann Date: Wed, 8 May 2019 09:41:38 -0400 Subject: [PATCH 05/41] Update CSS for WordPress 5.2 column fixes --- lib/gutenberg/front-end.css | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 deletions(-) diff --git a/lib/gutenberg/front-end.css b/lib/gutenberg/front-end.css index 85999b79..6f5ad3c3 100644 --- a/lib/gutenberg/front-end.css +++ b/lib/gutenberg/front-end.css @@ -388,35 +388,18 @@ hr.wp-block-separator { /* Media Queries ---------------------------------------------------------------------------- */ -@media only screen and (min-width: 600px) { - .site-container .wp-block-columns { - flex-wrap: nowrap; - } +@media only screen and (max-width: 781px) { - .site-container .wp-block-columns[class*="has-"] > * { - margin-right: 36px; + .has-3-columns .wp-block-column, + .has-5-columns .wp-block-column { + flex-basis: 100%; margin-left: 0; - } - - .site-container .wp-block-columns[class*="has-"] > *:last-child { margin-right: 0; } } -@media only screen and (min-width: 768px) { - - .site-container .wp-block-columns .wp-block-column > *:first-child { - margin-top: 0; - } - - .site-container .wp-block-columns .wp-block-column > *:last-child { - margin-bottom: 0; - } - -} - @media only screen and (min-width: 960px) { .full-width-content .site-container .alignwide { From 0fb48ee6abf2f05f5ff346291fa0c5b6b621be74 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Mon, 20 May 2019 16:51:24 +0200 Subject: [PATCH 06/41] Remove 404 page support from accessibility config This is no longer used in Genesis, so has no effect. --- config/accessibility.php | 1 - 1 file changed, 1 deletion(-) diff --git a/config/accessibility.php b/config/accessibility.php index 9b4ba59d..d2949d8c 100644 --- a/config/accessibility.php +++ b/config/accessibility.php @@ -12,7 +12,6 @@ * Genesis Accessibility features to support. */ return array( - '404-page', 'drop-down-menu', 'headings', 'search-form', From 8bba7d23abc09b452f60fa94be323d34ec2e76c8 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Mon, 6 May 2019 14:34:08 +0200 Subject: [PATCH 07/41] Replace responsive menu scripts with genesis_register_responsive_menus function --- functions.php | 55 +++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/functions.php b/functions.php index 44786345..ed8e7e05 100755 --- a/functions.php +++ b/functions.php @@ -60,6 +60,22 @@ function genesis_child_gutenberg_support() { // phpcs:ignore WordPress.NamingCon require_once get_stylesheet_directory() . '/lib/gutenberg/init.php'; } +// Registers the responsive menus. +if ( function_exists( 'genesis_register_responsive_menus' ) ) { + genesis_register_responsive_menus( + array( + 'script' => array( + 'menuClasses' => array( + 'others' => array( '.nav-primary' ), + ), + ), + 'extras' => array( + 'media_query_width' => '960px', + ), + ) + ); +} + add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' ); /** * Enqueues scripts and styles. @@ -77,45 +93,6 @@ function genesis_sample_enqueue_scripts_styles() { wp_enqueue_style( 'dashicons' ); - $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min'; - wp_enqueue_script( - 'genesis-sample-responsive-menu', - get_stylesheet_directory_uri() . "/js/responsive-menus{$suffix}.js", - array( 'jquery' ), - CHILD_THEME_VERSION, - true - ); - - wp_localize_script( - 'genesis-sample-responsive-menu', - 'genesis_responsive_menu', - genesis_sample_responsive_menu_settings() - ); - -} - -/** - * Defines responsive menu settings. - * - * @since 2.3.0 - */ -function genesis_sample_responsive_menu_settings() { - - $settings = array( - 'mainMenu' => __( 'Menu', 'genesis-sample' ), - 'menuIconClass' => 'dashicons-before dashicons-menu', - 'subMenu' => __( 'Submenu', 'genesis-sample' ), - 'subMenuIconClass' => 'dashicons-before dashicons-arrow-down-alt2', - 'menuClasses' => array( - 'combine' => array( - '.nav-primary', - ), - 'others' => array(), - ), - ); - - return $settings; - } // Adds support for HTML5 markup structure. From d16bbaf91b7b8d755d82aed7007c59a10fdc3b7a Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Thu, 9 May 2019 10:49:43 +0200 Subject: [PATCH 08/41] Extract responsive menu config --- config/responsive-menus.php | 23 +++++++++++++++++++++++ functions.php | 13 +------------ 2 files changed, 24 insertions(+), 12 deletions(-) create mode 100644 config/responsive-menus.php diff --git a/config/responsive-menus.php b/config/responsive-menus.php new file mode 100644 index 00000000..401b35c7 --- /dev/null +++ b/config/responsive-menus.php @@ -0,0 +1,23 @@ + array( + 'menuClasses' => array( + 'others' => array( '.nav-primary' ), + ), + ), + 'extras' => array( + 'media_query_width' => '960px', + ), +); diff --git a/functions.php b/functions.php index ed8e7e05..37fc22c5 100755 --- a/functions.php +++ b/functions.php @@ -62,18 +62,7 @@ function genesis_child_gutenberg_support() { // phpcs:ignore WordPress.NamingCon // Registers the responsive menus. if ( function_exists( 'genesis_register_responsive_menus' ) ) { - genesis_register_responsive_menus( - array( - 'script' => array( - 'menuClasses' => array( - 'others' => array( '.nav-primary' ), - ), - ), - 'extras' => array( - 'media_query_width' => '960px', - ), - ) - ); + genesis_register_responsive_menus( genesis_get_config( 'responsive-menus' ) ); } add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' ); From b939531733ee96fd66781846b66ab7f8f87842b8 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Thu, 9 May 2019 12:17:43 +0200 Subject: [PATCH 09/41] Conditionally load AMP CSS fixes if AMP is active Loads these files from the Genesis AMP plugin (relocated to the theme): - theme-fixer/genesis-amp-animated.css - theme-fixer/themes/genesis-sample/stylesheet.css (omits .woocommerce) This allows the menu to function on AMP and regular versions when used with this version of the Genesis AMP plugin that omits all 'theme fixer' functionality: https://github.com/nickcernis/genesis-amp/tree/suppress-theme-fixer Still need to: - Discuss if genesis-amp-animated.css belongs in Genesis or the theme. - Look into not loading a separate stylesheet conditionally for AMP. It would be easier to maintain if the AMP menu CSS was part of the theme's main style.css. --- functions.php | 9 +++++ lib/amp/amp.css | 89 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 lib/amp/amp.css diff --git a/functions.php b/functions.php index 37fc22c5..36847f6f 100755 --- a/functions.php +++ b/functions.php @@ -82,6 +82,15 @@ function genesis_sample_enqueue_scripts_styles() { wp_enqueue_style( 'dashicons' ); + if ( genesis_is_amp() ) { + wp_enqueue_style( + 'genesis-sample-amp', + get_stylesheet_directory_uri() . '/lib/amp/amp.css', + array( CHILD_THEME_HANDLE ), + CHILD_THEME_VERSION + ); + } + } // Adds support for HTML5 markup structure. diff --git a/lib/amp/amp.css b/lib/amp/amp.css new file mode 100644 index 00000000..8c889395 --- /dev/null +++ b/lib/amp/amp.css @@ -0,0 +1,89 @@ +/* +Genesis AMP styling. +This currently loads only on AMP pages. +*/ + +/* Reveals the submenu upon parent hover. +--------------------------------------------- */ +.genesis-nav-menu .menu-item .sub-menu { + display: block; + -webkit-transform: scaleY(0); + -moz-transform: scaleY(0); + -ms-transform: scaleY(0); + -o-transform: scaleY(0); + transform: scaleY(0); + transform-origin: top; + -webkit-transition: transform 0.5s ease 0.2s; + -moz-transition: transform 0.5s ease 0.2s; + transition: transform 0.5s ease 0.2s; +} + +.genesis-nav-menu .menu-item:hover > .sub-menu { + -webkit-transform: scaleY(1); + -moz-transform: scaleY(1); + -ms-transform: scaleY(1); + -o-transform: scaleY(1); + transform: scaleY(1); +} + +/* Reveals the submenu upon tabbing with keyboard. +--------------------------------------------- */ + +/* + * :focus-within needs it own selector. + * Why? If the event a browser does not recognize this pseudo-class, only this selector and its declarations + * are ignored. Isolating it ensures the submenu animation works on :hover. + */ +.menu .menu-item:focus-within > .sub-menu { + -webkit-transform: scaleY(1); + -moz-transform: scaleY(1); + -ms-transform: scaleY(1); + -o-transform: scaleY(1); + transform: scaleY(1); + left: auto; + opacity: 1; +} + +/* Overrides for different breakpoint to follow non-AMP implementation. */ +@media only screen and (max-width: 959px) { + + .genesis-responsive-menu { + display: block; + position: absolute; + left: -9999px; + opacity: 0; + -webkit-transform: scaleY(0); + -moz-transform: scaleY(0); + -ms-transform: scaleY(0); + -o-transform: scaleY(0); + transform: scaleY(0); + transform-origin: top; + -webkit-transition: transform .2s ease; + -moz-transition: transform .2s ease; + transition: transform .2s ease; + } + + .genesis-responsive-menu.toggled-on { + opacity: 1; + position: relative; + left: auto; + -webkit-transform: scaleY(1); + -moz-transform: scaleY(1); + -ms-transform: scaleY(1); + -o-transform: scaleY(1); + transform: scaleY(1); + } + + .genesis-responsive-menu.toggled-on .menu-item .sub-menu, + .genesis-responsive-menu.toggled-on .menu-item:hover > .sub-menu { + display: none; + } + + .genesis-responsive-menu.toggled-on .sub-menu-toggle.toggled-on + .sub-menu { + display: block; + -moz-transform: scaleY(1); + -ms-transform: scaleY(1); + -o-transform: scaleY(1); + transform: scaleY(1); + } +} From 05ad8b8f8a4f3e5f8edcb28568620caa616fd465 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Thu, 9 May 2019 12:20:20 +0200 Subject: [PATCH 10/41] Remove unneeded prefixes These are not needed for modern AMP-ready browsers. --- lib/amp/amp.css | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/lib/amp/amp.css b/lib/amp/amp.css index 8c889395..dcf72b70 100644 --- a/lib/amp/amp.css +++ b/lib/amp/amp.css @@ -7,22 +7,12 @@ This currently loads only on AMP pages. --------------------------------------------- */ .genesis-nav-menu .menu-item .sub-menu { display: block; - -webkit-transform: scaleY(0); - -moz-transform: scaleY(0); - -ms-transform: scaleY(0); - -o-transform: scaleY(0); transform: scaleY(0); transform-origin: top; - -webkit-transition: transform 0.5s ease 0.2s; - -moz-transition: transform 0.5s ease 0.2s; transition: transform 0.5s ease 0.2s; } .genesis-nav-menu .menu-item:hover > .sub-menu { - -webkit-transform: scaleY(1); - -moz-transform: scaleY(1); - -ms-transform: scaleY(1); - -o-transform: scaleY(1); transform: scaleY(1); } @@ -35,10 +25,6 @@ This currently loads only on AMP pages. * are ignored. Isolating it ensures the submenu animation works on :hover. */ .menu .menu-item:focus-within > .sub-menu { - -webkit-transform: scaleY(1); - -moz-transform: scaleY(1); - -ms-transform: scaleY(1); - -o-transform: scaleY(1); transform: scaleY(1); left: auto; opacity: 1; @@ -52,14 +38,8 @@ This currently loads only on AMP pages. position: absolute; left: -9999px; opacity: 0; - -webkit-transform: scaleY(0); - -moz-transform: scaleY(0); - -ms-transform: scaleY(0); - -o-transform: scaleY(0); transform: scaleY(0); transform-origin: top; - -webkit-transition: transform .2s ease; - -moz-transition: transform .2s ease; transition: transform .2s ease; } @@ -67,10 +47,6 @@ This currently loads only on AMP pages. opacity: 1; position: relative; left: auto; - -webkit-transform: scaleY(1); - -moz-transform: scaleY(1); - -ms-transform: scaleY(1); - -o-transform: scaleY(1); transform: scaleY(1); } @@ -81,9 +57,6 @@ This currently loads only on AMP pages. .genesis-responsive-menu.toggled-on .sub-menu-toggle.toggled-on + .sub-menu { display: block; - -moz-transform: scaleY(1); - -ms-transform: scaleY(1); - -o-transform: scaleY(1); transform: scaleY(1); } } From 1fae08ecf548c59c2f61ab05e9cb971102cc4cdf Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Thu, 9 May 2019 12:21:24 +0200 Subject: [PATCH 11/41] CSS standards --- lib/amp/amp.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/amp/amp.css b/lib/amp/amp.css index dcf72b70..b31874db 100644 --- a/lib/amp/amp.css +++ b/lib/amp/amp.css @@ -40,7 +40,7 @@ This currently loads only on AMP pages. opacity: 0; transform: scaleY(0); transform-origin: top; - transition: transform .2s ease; + transition: transform 0.2s ease; } .genesis-responsive-menu.toggled-on { From de7ae3bea0ce518ee84359cedc2ea215d4206060 Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Mon, 13 May 2019 12:49:19 +0200 Subject: [PATCH 12/41] Fix submenu hover on AMP version Ensures submenus appear on hover instead of only on focus. Props @dreamwhisper. --- lib/amp/amp.css | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/amp/amp.css b/lib/amp/amp.css index b31874db..6a87798f 100644 --- a/lib/amp/amp.css +++ b/lib/amp/amp.css @@ -12,7 +12,8 @@ This currently loads only on AMP pages. transition: transform 0.5s ease 0.2s; } -.genesis-nav-menu .menu-item:hover > .sub-menu { +.genesis-responsive-menu .genesis-nav-menu .menu-item:hover > .sub-menu { + display: block; transform: scaleY(1); } From 3777f22f640665557c41a4442283dd87692ee50e Mon Sep 17 00:00:00 2001 From: Nick Cernis Date: Wed, 15 May 2019 11:09:55 +0200 Subject: [PATCH 13/41] Remove responsive menus script This will be served from Genesis itself from Genesis 3.0.0+ and enqueued automatically when using the `genesis_register_responsive_menus` function. --- .eslintignore | 1 - js/responsive-menus.js | 452 ------------------------------------- js/responsive-menus.min.js | 11 - 3 files changed, 464 deletions(-) delete mode 100644 js/responsive-menus.js delete mode 100644 js/responsive-menus.min.js diff --git a/.eslintignore b/.eslintignore index c47488d7..5d8b60d8 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,4 +1,3 @@ node_modules vendor *.min.js -js/responsive-menus.js diff --git a/js/responsive-menus.js b/js/responsive-menus.js deleted file mode 100644 index cdd226a8..00000000 --- a/js/responsive-menus.js +++ /dev/null @@ -1,452 +0,0 @@ -/** - * Add the accessible responsive menu. - * - * @version 1.1.3 - * - * @author StudioPress - * @link https://github.com/copyblogger/responsive-menus/ - * @license GPL-2.0-or-later - * @package GenesisSample - */ - -( function ( document, $, undefined ) { - - 'use strict'; - - var genesisMenuParams = typeof genesis_responsive_menu === 'undefined' ? '' : genesis_responsive_menu, - genesisMenusUnchecked = genesisMenuParams.menuClasses, - genesisMenus = {}, - menusToCombine = []; - - /** - * Validate the menus passed by the theme with what's being loaded on the page, - * and pass the new and accurate information to our new data. - * - * @param {genesisMenusUnchecked} Raw data from the localized script in the theme. - * @return {array} genesisMenus array gets populated with updated data. - * @return {array} menusToCombine array gets populated with relevant data. - */ - $.each( - genesisMenusUnchecked, function( group ) { - - // Mirror our group object to populate. - genesisMenus[group] = []; - - // Loop through each instance of the specified menu on the page. - $.each( - this, function( key, value ) { - - var menuString = value, - $menu = $( value ); - - // If there is more than one instance, append the index and update array. - if ( $menu.length > 1 ) { - - $.each( - $menu, function( key, value ) { - - var newString = menuString + '-' + key; - - $( this ).addClass( newString.replace( '.','' ) ); - - genesisMenus[group].push( newString ); - - if ( 'combine' === group ) { - menusToCombine.push( newString ); - } - - } - ); - - } else if ( $menu.length == 1 ) { - - genesisMenus[group].push( menuString ); - - if ( 'combine' === group ) { - menusToCombine.push( menuString ); - } - - } - - } - ); - - } - ); - - // Make sure there is something to use for the 'others' array. - if ( typeof genesisMenus.others == 'undefined' ) { - genesisMenus.others = []; - } - - // If there's only one menu on the page for combining, push it to the 'others' array and nullify our 'combine' variable. - if ( menusToCombine.length == 1 ) { - genesisMenus.others.push( menusToCombine[0] ); - genesisMenus.combine = null; - menusToCombine = null; - } - - var genesisMenu = {}, - mainMenuButtonClass = 'menu-toggle', - subMenuButtonClass = 'sub-menu-toggle', - responsiveMenuClass = 'genesis-responsive-menu'; - - // Initialize. - genesisMenu.init = function() { - - // Exit early if there are no menus to do anything. - if ( $( _getAllMenusArray() ).length == 0 ) { - return; - } - - var menuIconClass = typeof genesisMenuParams.menuIconClass !== 'undefined' ? genesisMenuParams.menuIconClass : 'dashicons-before dashicons-menu'; - var subMenuIconClass = typeof genesisMenuParams.subMenuIconClass !== 'undefined' ? genesisMenuParams.subMenuIconClass : 'dashicons-before dashicons-arrow-down-alt2'; - var toggleButtons = { - menu : $( '