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/.github/ISSUE_TEMPLATE/release.md b/.github/ISSUE_TEMPLATE/release.md index 17a06eaf..97712802 100644 --- a/.github/ISSUE_TEMPLATE/release.md +++ b/.github/ISSUE_TEMPLATE/release.md @@ -10,7 +10,7 @@ assignees: '' **Update version** - [ ] style.css - [ ] package.json -- [ ] .pot file (regenerate) +- [ ] .pot file (`npm install` then `npm run makepot`) - [ ] Changelog (include changes) **Check standards** diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f690b17..9b423ca7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Genesis Sample Theme Changelog +## [3.0.0] - 2019-06-19 +Requires Genesis 3.0.0+. + +### Added +* AMP support. (Optional, off by default, requires Genesis 3.0.0 and the [AMP plugin](https://wordpress.org/plugins/amp/).) +* New `composer run phpcbf` command to fix simple PHP linting violations. ([GitHub version](https://github.com/studiopress/genesis-sample/) only.) + +### Changed +* Use `position: sticky` for the header and remove JavaScript that adjusted header height and content position. This prevents content reflow after page load. +* Reorganized config folder for easier reading and maintenance. +* Use new `genesis_get_theme_handle()` and `genesis_get_theme_version()` functions from Genesis 3.0.0 in place of declaring `CHILD_THEME_HANDLE` and `CHILD_THEME_VERSION` constants. +* Update developer dependencies. + +### Fixed +* Improved block column CSS for WordPress 5.2+. + +### Removed +* Responsive menu scripts have been replaced with `genesis_register_responsive_menus()`, which loads required JavaScript from Genesis 3.0.0. +* `genesis-responsive-viewport` theme support declaration. This is now added by default in Genesis 3.0.0. +* Deleted Genesis nav extras filter and metabox removal. These are no longer present in Genesis 3.0.0. +* `child-theme-settings-genesis.php` file and filter. Genesis 3.0.0 no longer includes a settings admin page or `genesis_theme_settings_defaults` filter. +* `404-page` accessibility support, as this no longer has an effect. + ## [2.10.0] - 2019-05-01 Requires Genesis 2.10.0+. @@ -116,10 +139,14 @@ Requires Genesis 2.8.0+. * Set localization. * Update XML file. -[2.8.0]: https://github.com/copyblogger/genesis-sample/compare/2.7.1...2.8.0 -[2.7.1]: https://github.com/copyblogger/genesis-sample/compare/2.7.0...2.7.1 -[2.7.0]: https://github.com/copyblogger/genesis-sample/compare/2.6.0...2.7.0 -[2.6.0]: https://github.com/copyblogger/genesis-sample/compare/2.3.0...2.6.0 -[2.3.0]: https://github.com/copyblogger/genesis-sample/compare/2.2.4...2.3.0 -[2.2.4]: https://github.com/copyblogger/genesis-sample/compare/2.2.3...2.2.4 -[2.2.3]: https://github.com/copyblogger/genesis-sample/compare/014deb3689323b7bbd4ddbfff4f5f9279a38f741...2.2.3 +[3.0.0]: https://github.com/studiopress/genesis-sample/compare/2.10.0...3.0.0 +[2.10.0]: https://github.com/studiopress/genesis-sample/compare/2.9.1...2.10.0 +[2.9.1]: https://github.com/studiopress/genesis-sample/compare/2.9.0...2.9.1 +[2.9.0]: https://github.com/studiopress/genesis-sample/compare/2.8.0...2.9.0 +[2.8.0]: https://github.com/studiopress/genesis-sample/compare/2.7.1...2.8.0 +[2.7.1]: https://github.com/studiopress/genesis-sample/compare/2.7.0...2.7.1 +[2.7.0]: https://github.com/studiopress/genesis-sample/compare/2.6.0...2.7.0 +[2.6.0]: https://github.com/studiopress/genesis-sample/compare/2.3.0...2.6.0 +[2.3.0]: https://github.com/studiopress/genesis-sample/compare/2.2.4...2.3.0 +[2.2.4]: https://github.com/studiopress/genesis-sample/compare/2.2.3...2.2.4 +[2.2.3]: https://github.com/studiopress/genesis-sample/compare/014deb3689323b7bbd4ddbfff4f5f9279a38f741...2.2.3 diff --git a/README.md b/README.md index adb17029..4505761a 100644 --- a/README.md +++ b/README.md @@ -25,6 +25,8 @@ The version of [Genesis Sample on GitHub](https://github.com/studiopress/genesis You'll see output highlighting issues with PHP files that do not conform to Genesis Sample coding standards. +Run `composer phpcbf` if you see “phpcbf can fix the x marked sniff violations automatically” in the output of `composer phpcs`. + ### npm scripts Scripts are also provided to help with CSS linting, CSS autoprefixing, and creation of pot language files. To use them: diff --git a/composer.json b/composer.json index 70635c7c..8b4a3dd8 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,8 @@ }, "scripts": { "install-codestandards": "Dealerdirect\\Composer\\Plugin\\Installers\\PHPCodeSniffer\\Plugin::run", - "phpcs": "phpcs" + "phpcs": "phpcs", + "phpcbf": "phpcbf" }, "support": { "issues": "https://github.com/studiopress/genesis-sample/issues", diff --git a/config/block-editor-settings.php b/config/appearance.php similarity index 52% rename from config/block-editor-settings.php rename to config/appearance.php index aa3b582f..570c9bbe 100644 --- a/config/block-editor-settings.php +++ b/config/appearance.php @@ -1,6 +1,6 @@ '#0073e5', + 'accent' => '#0073e5', +); + +$genesis_sample_link_color = get_theme_mod( + 'genesis_sample_link_color', + $genesis_sample_default_colors['link'] +); + +$genesis_sample_accent_color = get_theme_mod( + 'genesis_sample_accent_color', + $genesis_sample_default_colors['accent'] +); + $genesis_sample_link_color_contrast = genesis_sample_color_contrast( $genesis_sample_link_color ); $genesis_sample_link_color_brightness = genesis_sample_color_brightness( $genesis_sample_link_color, 35 ); return array( - 'admin-fonts-url' => 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700', - 'content-width' => 1062, - 'default-button-bg' => $genesis_sample_link_color, - 'default-button-color' => $genesis_sample_link_color_contrast, - 'default-button-outline-hover' => $genesis_sample_link_color_brightness, - 'default-link-color' => $genesis_sample_link_color, - 'editor-color-palette' => array( + 'fonts-url' => 'https://fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700&display=swap', + 'content-width' => 1062, + 'button-bg' => $genesis_sample_link_color, + 'button-color' => $genesis_sample_link_color_contrast, + 'button-outline-hover' => $genesis_sample_link_color_brightness, + 'link-color' => $genesis_sample_link_color, + 'default-colors' => $genesis_sample_default_colors, + 'editor-color-palette' => array( array( 'name' => __( 'Custom color', 'genesis-sample' ), // Called “Link Color” in the Customizer options. Renamed because “Link Color” implies it can only be used for links. 'slug' => 'theme-primary', - 'color' => get_theme_mod( 'genesis_sample_link_color', genesis_sample_customizer_get_default_link_color() ), + 'color' => $genesis_sample_link_color, ), array( 'name' => __( 'Accent color', 'genesis-sample' ), 'slug' => 'theme-secondary', - 'color' => get_theme_mod( 'genesis_sample_accent_color', genesis_sample_customizer_get_default_accent_color() ), + 'color' => $genesis_sample_accent_color, ), ), - 'editor-font-sizes' => array( + 'editor-font-sizes' => array( array( 'name' => __( 'Small', 'genesis-sample' ), 'size' => 12, diff --git a/config/child-theme-settings-genesis.php b/config/child-theme-settings-genesis.php deleted file mode 100644 index 2970066d..00000000 --- a/config/child-theme-settings-genesis.php +++ /dev/null @@ -1,32 +0,0 @@ - 6, - 'breadcrumb_home' => 0, - 'breadcrumb_front_page' => 0, - 'breadcrumb_posts_page' => 0, - 'breadcrumb_single' => 0, - 'breadcrumb_page' => 0, - 'breadcrumb_archive' => 0, - 'breadcrumb_404' => 0, - 'breadcrumb_attachment' => 0, - 'content_archive' => 'full', - 'content_archive_limit' => 0, - 'content_archive_thumbnail' => 0, - 'image_size' => '', - 'image_alignment' => 'alignleft', - 'posts_nav' => 'numeric', - 'site_layout' => 'content-sidebar', -); diff --git a/config/child-theme-settings.php b/config/child-theme-settings.php index e60b9ba6..7b9ae750 100644 --- a/config/child-theme-settings.php +++ b/config/child-theme-settings.php @@ -11,6 +11,23 @@ */ return array( - GENESIS_SETTINGS_FIELD => genesis_get_config( 'child-theme-settings-genesis' ), + GENESIS_SETTINGS_FIELD => array( + 'blog_cat_num' => 6, + 'breadcrumb_home' => 0, + 'breadcrumb_front_page' => 0, + 'breadcrumb_posts_page' => 0, + 'breadcrumb_single' => 0, + 'breadcrumb_page' => 0, + 'breadcrumb_archive' => 0, + 'breadcrumb_404' => 0, + 'breadcrumb_attachment' => 0, + 'content_archive' => 'full', + 'content_archive_limit' => 0, + 'content_archive_thumbnail' => 0, + 'image_size' => '', + 'image_alignment' => 'alignleft', + 'posts_nav' => 'numeric', + 'site_layout' => 'content-sidebar', + ), 'posts_per_page' => 6, ); diff --git a/config/custom-logo.php b/config/custom-logo.php deleted file mode 100644 index 7c19a85d..00000000 --- a/config/custom-logo.php +++ /dev/null @@ -1,19 +0,0 @@ - 120, - 'width' => 700, - 'flex-height' => true, - 'flex-width' => true, -); diff --git a/config/html5.php b/config/html5.php deleted file mode 100644 index 44b12ce4..00000000 --- a/config/html5.php +++ /dev/null @@ -1,20 +0,0 @@ - __( 'Header Menu', 'genesis-sample' ), - 'secondary' => __( 'Footer Menu', 'genesis-sample' ), -); diff --git a/config/accessibility.php b/config/responsive-menus.php similarity index 50% rename from config/accessibility.php rename to config/responsive-menus.php index 9b4ba59d..401b35c7 100644 --- a/config/accessibility.php +++ b/config/responsive-menus.php @@ -9,12 +9,15 @@ */ /** - * Genesis Accessibility features to support. + * Genesis responsive menus settings. (Requires Genesis 3.0+.) */ return array( - '404-page', - 'drop-down-menu', - 'headings', - 'search-form', - 'skip-links', + 'script' => array( + 'menuClasses' => array( + 'others' => array( '.nav-primary' ), + ), + ), + 'extras' => array( + 'media_query_width' => '960px', + ), ); diff --git a/config/theme-supports.php b/config/theme-supports.php new file mode 100644 index 00000000..756d98d5 --- /dev/null +++ b/config/theme-supports.php @@ -0,0 +1,39 @@ + array( + 'height' => 120, + 'width' => 700, + 'flex-height' => true, + 'flex-width' => true, + ), + 'html5' => array( + 'caption', + 'comment-form', + 'comment-list', + 'gallery', + 'search-form', + ), + 'genesis-accessibility' => array( + 'drop-down-menu', + 'headings', + 'search-form', + 'skip-links', + ), + 'genesis-after-entry-widget-area' => '', + 'genesis-footer-widgets' => 3, + 'genesis-menus' => array( + 'primary' => __( 'Header Menu', 'genesis-sample' ), + 'secondary' => __( 'Footer Menu', 'genesis-sample' ), + ), +); diff --git a/functions.php b/functions.php index f022adfa..3071f286 100755 --- a/functions.php +++ b/functions.php @@ -13,10 +13,6 @@ // Starts the engine. require_once get_template_directory() . '/lib/init.php'; -// Defines constants to help enqueue scripts and styles. -define( 'CHILD_THEME_HANDLE', sanitize_title_with_dashes( wp_get_theme()->get( 'Name' ) ) ); -define( 'CHILD_THEME_VERSION', wp_get_theme()->get( 'Version' ) ); - // Sets up the Theme. require_once get_stylesheet_directory() . '/lib/theme-defaults.php'; @@ -28,7 +24,7 @@ */ function genesis_sample_localization_setup() { - load_child_theme_textdomain( 'genesis-sample', get_stylesheet_directory() . '/languages' ); + load_child_theme_textdomain( genesis_get_theme_handle(), get_stylesheet_directory() . '/languages' ); } @@ -60,6 +56,11 @@ 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( genesis_get_config( 'responsive-menus' ) ); +} + add_action( 'wp_enqueue_scripts', 'genesis_sample_enqueue_scripts_styles' ); /** * Enqueues scripts and styles. @@ -68,75 +69,45 @@ function genesis_child_gutenberg_support() { // phpcs:ignore WordPress.NamingCon */ function genesis_sample_enqueue_scripts_styles() { + $appearance = genesis_get_config( 'appearance' ); + wp_enqueue_style( - 'genesis-sample-fonts', - '//fonts.googleapis.com/css?family=Source+Sans+Pro:400,400i,600,700', + genesis_get_theme_handle() . '-fonts', + $appearance['fonts-url'], array(), - CHILD_THEME_VERSION + genesis_get_theme_version() ); 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() - ); - - wp_enqueue_script( - 'genesis-sample', - get_stylesheet_directory_uri() . '/js/genesis-sample.js', - array( 'jquery' ), - CHILD_THEME_VERSION, - true - ); + if ( genesis_is_amp() ) { + wp_enqueue_style( + genesis_get_theme_handle() . '-amp', + get_stylesheet_directory_uri() . '/lib/amp/amp.css', + array( genesis_get_theme_handle() ), + genesis_get_theme_version() + ); + } } +add_action( 'after_setup_theme', 'genesis_sample_theme_support', 9 ); /** - * Defines responsive menu settings. + * Add desired theme supports. * - * @since 2.3.0 + * See config file at `config/theme-supports.php`. + * + * @since 3.0.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. -add_theme_support( 'html5', genesis_get_config( 'html5' ) ); +function genesis_sample_theme_support() { -// Adds support for accessibility. -add_theme_support( 'genesis-accessibility', genesis_get_config( 'accessibility' ) ); + $theme_supports = genesis_get_config( 'theme-supports' ); -// Adds viewport meta tag for mobile browsers. -add_theme_support( 'genesis-responsive-viewport' ); + foreach ( $theme_supports as $feature => $args ) { + add_theme_support( $feature, $args ); + } -// Adds custom logo in Customizer > Site Identity. -add_theme_support( 'custom-logo', genesis_get_config( 'custom-logo' ) ); +} add_filter( 'genesis_seo_title', 'genesis_sample_header_title', 10, 3 ); /** @@ -162,18 +133,9 @@ function genesis_sample_header_title( $title, $inside, $wrap ) { } -// Renames primary and secondary navigation menus. -add_theme_support( 'genesis-menus', genesis_get_config( 'menus' ) ); - // Adds image sizes. add_image_size( 'sidebar-featured', 75, 75, true ); -// Adds support for after entry widget. -add_theme_support( 'genesis-after-entry-widget-area' ); - -// Adds support for 3-column footer widgets. -add_theme_support( 'genesis-footer-widgets', 3 ); - // Removes header right widget area. unregister_sidebar( 'header-right' ); @@ -185,25 +147,6 @@ function genesis_sample_header_title( $title, $inside, $wrap ) { genesis_unregister_layout( 'sidebar-content-sidebar' ); genesis_unregister_layout( 'sidebar-sidebar-content' ); -// Removes output of primary navigation right extras. -remove_filter( 'genesis_nav_items', 'genesis_nav_right', 10, 2 ); -remove_filter( 'wp_nav_menu_items', 'genesis_nav_right', 10, 2 ); - -add_action( 'genesis_theme_settings_metaboxes', 'genesis_sample_remove_metaboxes' ); -/** - * Removes output of unused admin settings metaboxes. - * - * @since 2.6.0 - * - * @param string $_genesis_admin_settings The admin screen to remove meta boxes from. - */ -function genesis_sample_remove_metaboxes( $_genesis_admin_settings ) { - - remove_meta_box( 'genesis-theme-settings-header', $_genesis_admin_settings, 'main' ); - remove_meta_box( 'genesis-theme-settings-nav', $_genesis_admin_settings, 'main' ); - -} - add_filter( 'genesis_customizer_theme_settings_config', 'genesis_sample_remove_customizer_settings' ); /** * Removes output of header and front page breadcrumb settings in the Customizer. 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 ); 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 : $( '