diff --git a/src/wp-content/themes/twentytwenty/404.php b/src/wp-content/themes/twentytwenty/404.php
index f00ae375d8..fbf509aa83 100644
--- a/src/wp-content/themes/twentytwenty/404.php
+++ b/src/wp-content/themes/twentytwenty/404.php
@@ -14,23 +14,23 @@ get_header();
-
+
-
+
_x( '404 not found', 'Label', 'twentytwenty' ),
+ 'label' => __( '404 not found', 'twentytwenty' ),
)
);
?>
-
-
+
+
.editor-block-list__block-edit > div > .wp-block-group.has-background > .wp-block-group__inner-container > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"],
+.wp-block[data-type="core/group"][data-align="full"] > .editor-block-list__block-edit > div > .wp-block-group.has-background > .wp-block-group__inner-container > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] {
+ margin-right: 0;
+ width: 100%;
+}
+
/* Block: Paragraph -------------------------- */
@@ -1041,6 +1061,25 @@ hr.wp-block-separator.is-style-dots::before {
@media ( min-width: 600px ) {
+ /* BLOCK: SHARED MEDIA STYLES */
+
+ .wp-block[data-type*="core-embed"][data-align="full"] figcaption,
+ .wp-block[data-type="core/image"][data-align="full"] figcaption,
+ .wp-block[data-type="core/gallery"][data-align="full"] .blocks-gallery-caption {
+ padding: 0 45px;
+ }
+
+ /* BLOCK: COLUMNS */
+
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h1,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h2,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h3,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h4,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h5,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h6 {
+ margin: 35px 0 20px 0;
+ }
+
/* BLOCK: PULLQUOTE */
.editor-styles-wrapper .wp-block[data-type="core/pullquote"][data-align="right"] .block-editor-block-list__block-edit {
@@ -1228,13 +1267,6 @@ hr.wp-block-separator.is-style-dots::before {
font-size: 18px;
}
- /* BLOCK: COVER */
-
- .editor-styles-wrapper .wp-block-cover-image .wp-block-cover__inner-container,
- .editor-styles-wrapper .wp-block-cover .wp-block-cover__inner-container {
- width: calc(100% - 100px);
- }
-
/* BLOCK: GROUP */
.wp-block[data-align="wide"] .wp-block-group.has-background,
diff --git a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css
index c6ff478998..054b1017ad 100644
--- a/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css
+++ b/src/wp-content/themes/twentytwenty/assets/css/editor-style-block.css
@@ -73,12 +73,26 @@ Inter variable font. Usage:
max-width: 610px;
}
-.wp-block[data-align="wide"] .wp-block-group .wp-block {
- max-width: 100%;
+.wp-block[data-align="wide"] .wp-block,
+.wp-block[data-align="full"] .wp-block {
+ max-width: none;
}
-.wp-block[data-align="full"] .wp-block-group .wp-block {
- max-width: 100%;
+.wp-block[data-align="wide"] .wp-block[data-align="wide"],
+.wp-block[data-align="full"] .wp-block[data-align="wide"] {
+ max-width: 1200px;
+}
+
+.wp-block .wp-block[data-type="core/group"]:not([data-align="full"]):not([data-align="wide"]):not([data-align="left"]):not([data-align="right"]),
+.wp-block .wp-block[data-type="core/cover"]:not([data-align="full"]):not([data-align="wide"]):not([data-align="left"]):not([data-align="right"]) {
+ margin-left: auto;
+ margin-right: auto;
+ max-width: 610px;
+}
+
+.wp-block .wp-block[data-align="full"] {
+ margin-left: 0;
+ margin-right: 0;
}
*[data-align="right"] .wp-block-edit,
@@ -641,7 +655,7 @@ hr.wp-block-separator.is-style-dots::before {
.editor-styles-wrapper .wp-block-cover .wp-block-cover__inner-container {
margin: 0 auto;
max-width: 1200px;
- width: calc(100% - 50px);
+ width: calc(100% - 40px);
}
[data-align="left"] .wp-block-cover,
@@ -651,8 +665,6 @@ hr.wp-block-separator.is-style-dots::before {
max-width: 260px;
}
-.editor-styles-wrapper .wp-block-cover-image .wp-block,
-.editor-styles-wrapper .wp-block-cover .wp-block,
.wp-block-cover-image .wp-block-cover-image-text,
.wp-block-cover-image .wp-block-cover-text,
.wp-block-cover-image h2,
@@ -660,17 +672,19 @@ hr.wp-block-separator.is-style-dots::before {
.wp-block-cover .wp-block-cover-text,
.wp-block-cover h2 {
max-width: 100%;
- padding: 0;
-}
-
-.editor-styles-wrapper .wp-block-cover p {
- font-family: inherit;
}
.editor-styles-wrapper .wp-block-cover a {
color: inherit;
}
+/* Block: Shared Media Styles ---------------- */
+
+.wp-block[data-type*="core-embed"][data-align="full"] figcaption,
+.wp-block[data-type="core/image"][data-align="full"] figcaption,
+.wp-block[data-type="core/gallery"][data-align="full"] .blocks-gallery-caption {
+ padding: 0 14px;
+}
/* Block: Paragraph -------------------------- */
@@ -982,6 +996,12 @@ hr.wp-block-separator.is-style-dots::before {
margin-top: 0;
}
+.wp-block[data-type="core/group"] > .editor-block-list__block-edit > div > .wp-block-group.has-background > .wp-block-group__inner-container > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"],
+.wp-block[data-type="core/group"][data-align="full"] > .editor-block-list__block-edit > div > .wp-block-group.has-background > .wp-block-group__inner-container > .editor-inner-blocks > .editor-block-list__layout > .wp-block[data-align="full"] {
+ margin-left: 0;
+ width: 100%;
+}
+
/* Block: Paragraph -------------------------- */
@@ -1041,6 +1061,25 @@ hr.wp-block-separator.is-style-dots::before {
@media ( min-width: 600px ) {
+ /* BLOCK: SHARED MEDIA STYLES */
+
+ .wp-block[data-type*="core-embed"][data-align="full"] figcaption,
+ .wp-block[data-type="core/image"][data-align="full"] figcaption,
+ .wp-block[data-type="core/gallery"][data-align="full"] .blocks-gallery-caption {
+ padding: 0 45px;
+ }
+
+ /* BLOCK: COLUMNS */
+
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h1,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h2,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h3,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h4,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h5,
+ .editor-styles-wrapper .wp-block[data-type="core/column"] h6 {
+ margin: 35px 0 20px 0;
+ }
+
/* BLOCK: PULLQUOTE */
.editor-styles-wrapper .wp-block[data-type="core/pullquote"][data-align="right"] .block-editor-block-list__block-edit {
@@ -1228,13 +1267,6 @@ hr.wp-block-separator.is-style-dots::before {
font-size: 18px;
}
- /* BLOCK: COVER */
-
- .editor-styles-wrapper .wp-block-cover-image .wp-block-cover__inner-container,
- .editor-styles-wrapper .wp-block-cover .wp-block-cover__inner-container {
- width: calc(100% - 100px);
- }
-
/* BLOCK: GROUP */
.wp-block[data-align="wide"] .wp-block-group.has-background,
diff --git a/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic-rtl.css b/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic-rtl.css
index 343f59415a..3f4fb91e0e 100644
--- a/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic-rtl.css
+++ b/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic-rtl.css
@@ -8,8 +8,8 @@
/*
* Chrome renders extra-wide characters for the Hoefler Text font.
- * This results in a jumping cursor when typing in both the Classic and block
- * editors. The following font-face override fixes the issue by manually
+ * This results in a jumping cursor when typing in both the classic editor and
+ * block editor. The following font-face override fixes the issue by manually
* inserting a custom font that includes just a Hoefler Text space replacement
* for that character instead.
*/
@@ -65,8 +65,6 @@ body#tinymce.wp-editor { /* stylelint-disable-line no-duplicate-selectors */
}
body#tinymce.wp-editor * {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
@@ -373,13 +371,13 @@ body#tinymce.wp-editor .wp-caption .alignright {
}
body#tinymce.wp-editor .alignleft {
- float: right;
+ float: left;
margin-left: 25px;
max-width: 260px;
}
body#tinymce.wp-editor .alignright {
- float: left;
+ float: right;
margin-right: 25px;
max-width: 260px;
}
diff --git a/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic.css b/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic.css
index 57718e44d1..6e6f2960b7 100644
--- a/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic.css
+++ b/src/wp-content/themes/twentytwenty/assets/css/editor-style-classic.css
@@ -8,8 +8,8 @@
/*
* Chrome renders extra-wide characters for the Hoefler Text font.
- * This results in a jumping cursor when typing in both the Classic and block
- * editors. The following font-face override fixes the issue by manually
+ * This results in a jumping cursor when typing in both the classic editor and
+ * block editor. The following font-face override fixes the issue by manually
* inserting a custom font that includes just a Hoefler Text space replacement
* for that character instead.
*/
@@ -65,8 +65,6 @@ body#tinymce.wp-editor { /* stylelint-disable-line no-duplicate-selectors */
}
body#tinymce.wp-editor * {
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-font-smoothing: antialiased;
}
@@ -373,12 +371,16 @@ body#tinymce.wp-editor .wp-caption .alignright {
}
body#tinymce.wp-editor .alignleft {
+
+ /*rtl:ignore*/
float: left;
margin-right: 25px;
max-width: 260px;
}
body#tinymce.wp-editor .alignright {
+
+ /*rtl:ignore*/
float: right;
margin-left: 25px;
max-width: 260px;
diff --git a/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js b/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js
index 9780797433..8ea6a7f94e 100644
--- a/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js
+++ b/src/wp-content/themes/twentytwenty/assets/js/color-calculations.js
@@ -133,7 +133,7 @@ _twentyTwentyColor.prototype.getAccentColor = function() {
* @param {number} accentHue - The hue for our accent color.
* @return {Object} - this
*/
-function twentyTwentyColor( backgroundColor, accentHue ) { // jshint ignore:line
+function twentyTwentyColor( backgroundColor, accentHue ) {// jshint ignore:line
var color = new _twentyTwentyColor( backgroundColor, accentHue );
color.setAccentColorsArray();
return color;
diff --git a/src/wp-content/themes/twentytwenty/assets/js/customize.js b/src/wp-content/themes/twentytwenty/assets/js/customize.js
new file mode 100755
index 0000000000..2a38ace1d8
--- /dev/null
+++ b/src/wp-content/themes/twentytwenty/assets/js/customize.js
@@ -0,0 +1,27 @@
+/* global wp, jQuery */
+
+( function( $, api ) {
+ $( document ).ready( function() {
+ // Make it possible to reset the color based on a radio input's value.
+ // `active` can be either `custom` or `default`.
+ api.control( 'accent_hue_active' ).setting.bind( function( active ) {
+ var control = api.control( 'accent_hue' ); // Get the accent hue control.
+
+ if ( 'custom' === active ) {
+ // Activate the hue color picker control and focus it.
+ control.activate( {
+ completeCallback: function() {
+ control.focus();
+ }
+ } );
+ } else {
+ // If the `custom` option isn't selected, deactivate the hue color picker and set a default.
+ control.deactivate( {
+ completeCallback: function() {
+ control.setting.set( control.params.defaultValue );
+ }
+ } );
+ }
+ } );
+ } );
+}( jQuery, wp.customize ) );
diff --git a/src/wp-content/themes/twentytwenty/assets/js/index.js b/src/wp-content/themes/twentytwenty/assets/js/index.js
index 3046247a20..17290b38fa 100644
--- a/src/wp-content/themes/twentytwenty/assets/js/index.js
+++ b/src/wp-content/themes/twentytwenty/assets/js/index.js
@@ -4,6 +4,9 @@
var twentytwenty = twentytwenty || {};
+// Set a default value for scrolled.
+twentytwenty.scrolled = 0;
+
// polyfill closest
// https://developer.mozilla.org/en-US/docs/Web/API/Element/closest#Polyfill
if ( ! Element.prototype.closest ) {
@@ -37,7 +40,6 @@ if ( window.NodeList && ! NodeList.prototype.forEach ) {
}
// event "polyfill"
-
twentytwenty.createEvent = function( eventName ) {
var event;
if ( typeof window.Event === 'function' ) {
@@ -51,7 +53,6 @@ twentytwenty.createEvent = function( eventName ) {
// matches "polyfill"
// https://developer.mozilla.org/es/docs/Web/API/Element/matches
-
if ( ! Element.prototype.matches ) {
Element.prototype.matches =
Element.prototype.matchesSelector ||
@@ -137,27 +138,36 @@ twentytwenty.coverModals = {
// Hide and show modals before and after their animations have played out
hideAndShowModals: function() {
- var modals = document.querySelectorAll( '.cover-modal' ),
- htmlStyle = document.documentElement.style;
+ var modals, htmlStyle, adminBar, _doc, _win;
- var getAdminBarHeight = function( negativeValue ) {
- var adminBar = document.querySelector( '#wpadminbar' );
+ _doc = document;
+ _win = window;
+ modals = _doc.querySelectorAll( '.cover-modal' );
+ htmlStyle = _doc.documentElement.style;
+ adminBar = _doc.querySelector( '#wpadminbar' );
+
+ function getAdminBarHeight( negativeValue ) {
+ var currentScroll, height;
+
+ currentScroll = _win.pageYOffset;
if ( adminBar ) {
- return ( negativeValue ? '-' : '' ) + adminBar.getBoundingClientRect().height + 'px';
+ height = currentScroll + adminBar.getBoundingClientRect().height;
+
+ return negativeValue ? -height : height;
}
- return 0;
- };
+ return currentScroll === 0 ? 0 : -currentScroll;
+ }
function htmlStyles() {
- var overflow = window.innerHeight > document.documentElement.getBoundingClientRect().height;
+ var overflow = _win.innerHeight > _doc.documentElement.getBoundingClientRect().height;
return {
'overflow-y': overflow ? 'hidden' : 'scroll',
position: 'fixed',
width: '100%',
- top: getAdminBarHeight( true ),
+ top: getAdminBarHeight( true ) + 'px',
left: 0
};
}
@@ -165,17 +175,34 @@ twentytwenty.coverModals = {
// Show the modal
modals.forEach( function( modal ) {
modal.addEventListener( 'toggle-target-before-inactive', function( event ) {
+ var styles, paddingTop, offsetY, mQuery;
+
+ styles = htmlStyles();
+ offsetY = _win.pageYOffset;
+ paddingTop = ( Math.abs( getAdminBarHeight() ) - offsetY ) + 'px';
+ mQuery = _win.matchMedia( '(max-width: 600px)' );
+
if ( event.target !== modal ) {
return;
}
- window.scrollTo( { top: 0 } );
-
- Object.keys( htmlStyles() ).forEach( function( styleKey ) {
- htmlStyle.setProperty( styleKey, htmlStyles()[ styleKey ] );
+ Object.keys( styles ).forEach( function( styleKey ) {
+ htmlStyle.setProperty( styleKey, styles[ styleKey ] );
} );
- document.body.style.setProperty( 'padding-top', getAdminBarHeight() );
+ _win.twentytwenty.scrolled = parseInt( styles.top );
+
+ if ( adminBar ) {
+ _doc.body.style.setProperty( 'padding-top', paddingTop );
+
+ if ( mQuery.matches ) {
+ if ( offsetY >= getAdminBarHeight() ) {
+ modal.style.setProperty( 'top', 0 );
+ } else {
+ modal.style.setProperty( 'top', ( getAdminBarHeight() - offsetY ) + 'px' );
+ }
+ }
+ }
modal.classList.add( 'show-modal' );
} );
@@ -187,13 +214,29 @@ twentytwenty.coverModals = {
}
setTimeout( function() {
+ var clickedEl;
+
+ clickedEl = twentytwenty.toggles.clickedEl;
+
modal.classList.remove( 'show-modal' );
Object.keys( htmlStyles() ).forEach( function( styleKey ) {
htmlStyle.removeProperty( styleKey );
} );
- document.body.style.removeProperty( 'padding-top' );
+ if ( adminBar ) {
+ _doc.body.style.removeProperty( 'padding-top' );
+ modal.style.removeProperty( 'top' );
+ }
+
+ _win.scrollTo( 0, Math.abs( _win.twentytwenty.scrolled + getAdminBarHeight() ) );
+
+ _win.twentytwenty.scrolled = 0;
+
+ if ( clickedEl !== false ) {
+ clickedEl.focus();
+ clickedEl = false;
+ }
}, 500 );
} );
} );
@@ -393,39 +436,72 @@ twentytwenty.modalMenu = {
// If the current menu item is the last one, return to close button when tab
goBackToCloseButton: function() {
document.addEventListener( 'keydown', function( event ) {
- var desktopMenuButton = document.querySelector( '.toggle.close-nav-toggle' );
- var mobileMenuButton = document.querySelector( '.toggle.mobile-nav-toggle' );
- var isMobileMenu = desktopMenuButton ? window.getComputedStyle( desktopMenuButton, null ).getPropertyValue( 'display' ) === 'none' : false;
- var firstMenuItem = isMobileMenu ? mobileMenuButton : desktopMenuButton;
+ var closeMenuButton, mobileMenu, isDesktop, menuLinks, firstLevelmenuLinks, lastMenuLinkToggleButton, lastToogleSubMenuLinkNotOpened, lastMenuLinkHasSubClosedMenu, socialLinks, hasSocialMenu, lastModalMenuItems, focusedElementParentLi, focusedElementIsInsideModal, lastMenuItem, isFirstModalItem, isLastModalItem;
- var menuLinks = isMobileMenu ?
- document.querySelectorAll( '.menu-modal .mobile-menu li' ) :
- document.querySelectorAll( '.menu-modal .expanded-menu li' );
+ closeMenuButton = document.querySelector( '.toggle.close-nav-toggle' );
+ mobileMenu = document.querySelector( '.mobile-menu' );
- var socialLinks = document.querySelectorAll( '.menu-modal .social-menu > li' );
- var hasSocialMenu = document.querySelectorAll( '.menu-modal .social-menu' ).length > 0;
- var lastModalMenuItems = hasSocialMenu ? socialLinks : menuLinks;
- var focusedElementParentLi = twentytwentyFindParents( event.target, 'li' );
- var focusedElementIsInsideModal = twentytwentyFindParents( event.target, '.menu-modal' ).length > 0;
- var lastMenuItem = lastModalMenuItems[lastModalMenuItems.length - 1];
+ if ( mobileMenu ) {
+ return false;
+ }
- var isFirstModalItem = isMobileMenu ?
- event.target === mobileMenuButton :
- focusedElementIsInsideModal && event.target === desktopMenuButton;
+ isDesktop = window.getComputedStyle( mobileMenu, null ).getPropertyValue( 'display' ) === 'none';
- var isLastModalItem = focusedElementIsInsideModal && focusedElementParentLi[0] ?
+ menuLinks = isDesktop ?
+ document.querySelectorAll( '.menu-modal .expanded-menu .modal-menu li' ) :
+ document.querySelectorAll( '.menu-modal .mobile-menu .modal-menu li' );
+
+ firstLevelmenuLinks = isDesktop ?
+ document.querySelectorAll( '.menu-modal .expanded-menu .modal-menu > li' ) :
+ document.querySelectorAll( '.menu-modal .mobile-menu .modal-menu > li' );
+
+ if ( firstLevelmenuLinks ) {
+ return false;
+ }
+
+ lastMenuLinkToggleButton = firstLevelmenuLinks[firstLevelmenuLinks.length - 1].querySelector( '.sub-menu-toggle' ) || undefined;
+ lastMenuLinkHasSubClosedMenu = lastMenuLinkToggleButton && ! lastMenuLinkToggleButton.classList.contains( 'active' );
+
+ lastToogleSubMenuLinkNotOpened = isDesktop ?
+ document.querySelector( '.menu-modal .expanded-menu .modal-menu .sub-menu .sub-menu-toggle:not(.active)' ) :
+ document.querySelector( '.menu-modal .mobile-menu .sub-menu .sub-menu-toggle:not(.active)' );
+
+ socialLinks = document.querySelectorAll( '.menu-modal .social-menu li' );
+ hasSocialMenu = document.querySelectorAll( '.menu-modal .social-menu' ).length > 0;
+ lastModalMenuItems = hasSocialMenu ? socialLinks : menuLinks;
+ focusedElementParentLi = twentytwentyFindParents( event.target, 'li' );
+ focusedElementIsInsideModal = twentytwentyFindParents( event.target, '.menu-modal' ).length > 0;
+
+ lastMenuItem = lastModalMenuItems[lastModalMenuItems.length - 1];
+
+ isFirstModalItem = event.target === closeMenuButton;
+
+ isLastModalItem = focusedElementIsInsideModal && focusedElementParentLi[0] ?
focusedElementParentLi[0].className === lastMenuItem.className :
undefined;
+ if ( lastMenuLinkToggleButton && lastMenuLinkHasSubClosedMenu && ! hasSocialMenu ) { // Last 1st level item has submenu and is closed
+ isLastModalItem = event.target === lastMenuLinkToggleButton;
+ lastMenuItem = lastMenuLinkToggleButton;
+ }
+ if ( lastMenuLinkToggleButton && ! lastMenuLinkHasSubClosedMenu && ! hasSocialMenu ) { // Last 1st level item has submenu is opened
+ isLastModalItem = event.target === lastToogleSubMenuLinkNotOpened || event.target === menuLinks[menuLinks.length - 1].querySelector( 'a' );
+ lastMenuItem = lastToogleSubMenuLinkNotOpened || menuLinks[menuLinks.length - 1].querySelector( 'a' );
+ }
+
if ( ! event.shiftKey && event.key === 'Tab' && isLastModalItem ) {
// Forward
event.preventDefault();
- firstMenuItem.focus();
+ closeMenuButton.focus();
}
if ( event.shiftKey && event.key === 'Tab' && isFirstModalItem ) {
// Backward
event.preventDefault();
- lastMenuItem.querySelector( 'a' ).focus();
+ if ( lastMenuItem.querySelector( 'a' ) ) {
+ lastMenuItem.querySelector( 'a' ).focus();
+ } else {
+ lastMenuItem.focus();
+ }
}
} );
}
@@ -445,9 +521,15 @@ twentytwenty.primaryMenu = {
// by adding the '.focus' class to all 'li.menu-item-has-children' when the focus is on the 'a' element.
focusMenuWithChildren: function() {
// Get all the link elements within the primary menu.
- var menu = document.querySelector( '.primary-menu-wrapper' );
- var links = menu.getElementsByTagName( 'a' );
- var i, len;
+ var menu, links, i, len;
+
+ menu = document.querySelector( '.primary-menu-wrapper' );
+
+ if ( ! menu ) {
+ return false;
+ }
+
+ links = menu.getElementsByTagName( 'a' );
// Each time a menu link is focused or blurred, toggle focus.
for ( i = 0, len = links.length; i < len; i++ ) {
@@ -481,6 +563,8 @@ twentytwenty.primaryMenu = {
twentytwenty.toggles = {
+ clickedEl: false,
+
init: function() {
// Do the toggle
this.toggle();
@@ -493,17 +577,25 @@ twentytwenty.toggles = {
},
performToggle: function( element, instantly ) {
- var toggle, targetString, target, timeOutTime, classToToggle, activeClass;
+ var self, toggle, _doc, targetString, target, timeOutTime, classToToggle, activeClass;
+
+ self = this;
+ _doc = document;
// Get our targets
toggle = element;
targetString = toggle.dataset.toggleTarget;
activeClass = 'active';
+ // Elements to focus after modals are closed
+ if ( ! _doc.querySelectorAll( '.show-modal' ).length ) {
+ self.clickedEl = _doc.activeElement;
+ }
+
if ( targetString === 'next' ) {
target = toggle.nextSibling;
} else {
- target = document.querySelector( targetString );
+ target = _doc.querySelector( targetString );
}
// Trigger events on the toggle targets before they are toggled
@@ -544,7 +636,7 @@ twentytwenty.toggles = {
toggle.classList.toggle( activeClass );
} else {
// If not, toggle all toggles with this toggle target
- document.querySelector( '*[data-toggle-target="' + targetString + '"]' ).classList.toggle( activeClass );
+ _doc.querySelector( '*[data-toggle-target="' + targetString + '"]' ).classList.toggle( activeClass );
}
// Toggle aria-expanded on the target
@@ -555,12 +647,12 @@ twentytwenty.toggles = {
// Toggle body class
if ( toggle.dataset.toggleBodyClass ) {
- document.querySelector( 'body' ).classList.toggle( toggle.dataset.toggleBodyClass );
+ _doc.querySelector( 'body' ).classList.toggle( toggle.dataset.toggleBodyClass );
}
// Check whether to set focus
if ( toggle.dataset.setFocus ) {
- focusElement = document.querySelector( toggle.dataset.setFocus );
+ focusElement = _doc.querySelector( toggle.dataset.setFocus );
if ( focusElement ) {
if ( target.classList.contains( activeClass ) ) {
@@ -588,7 +680,8 @@ twentytwenty.toggles = {
var self = this;
document.querySelectorAll( '*[data-toggle-target]' ).forEach( function( element ) {
- element.addEventListener( 'click', function() {
+ element.addEventListener( 'click', function( event ) {
+ event.preventDefault();
self.performToggle( element );
} );
} );
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
index a0ee4710e0..d87c3f2636 100644
--- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
+++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
@@ -90,12 +90,36 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize,
'header_footer_background_color',
array(
- 'label' => esc_html__( 'Header & Footer Background Color', 'twentytwenty' ),
+ 'label' => __( 'Header & Footer Background Color', 'twentytwenty' ),
'section' => 'colors',
)
)
);
+ // Enable picking an accent color.
+ $wp_customize->add_setting(
+ 'accent_hue_active',
+ array(
+ 'capability' => 'edit_theme_options',
+ 'sanitize_callback' => array( __CLASS__, 'sanitize_select' ),
+ 'transport' => 'postMessage',
+ 'default' => 'default',
+ )
+ );
+
+ $wp_customize->add_control(
+ 'accent_hue_active',
+ array(
+ 'type' => 'radio',
+ 'section' => 'colors',
+ 'label' => __( 'Primary Color', 'twentytwenty' ),
+ 'choices' => array(
+ 'default' => __( 'Default', 'twentytwenty' ),
+ 'custom' => __( 'Custom', 'twentytwenty' ),
+ ),
+ )
+ );
+
/**
* Implementation for the accent color.
* This is different to all other color options because of the accessibility enhancements.
@@ -136,7 +160,7 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
),
'type' => 'theme_mod',
'transport' => 'postMessage',
- 'sanitize_callback' => array( 'TwentyTwenty_Customize', 'sanitize_accent_accessible_colors' ),
+ 'sanitize_callback' => array( __CLASS__, 'sanitize_accent_accessible_colors' ),
)
);
@@ -146,10 +170,13 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize,
'accent_hue',
array(
- 'label' => esc_html__( 'Accent Color Hue', 'twentytwenty' ),
- 'section' => 'colors',
- 'settings' => 'accent_hue',
- 'mode' => 'hue',
+ 'section' => 'colors',
+ 'settings' => 'accent_hue',
+ 'description' => __( 'Apply a custom color for links, buttons, featured images.', 'twentytwenty' ),
+ 'mode' => 'hue',
+ 'active_callback' => function() use ( $wp_customize ) {
+ return ( 'custom' === $wp_customize->get_setting( 'accent_hue_active' )->value() );
+ },
)
)
);
@@ -164,10 +191,9 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize->add_section(
'options',
array(
- 'title' => __( 'Theme Options', 'twentytwenty' ),
- 'priority' => 40,
- 'capability' => 'edit_theme_options',
- 'description' => __( 'Specific settings for the Twenty Twenty theme.', 'twentytwenty' ),
+ 'title' => __( 'Theme Options', 'twentytwenty' ),
+ 'priority' => 40,
+ 'capability' => 'edit_theme_options',
)
);
@@ -225,7 +251,7 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
array(
'title' => __( 'Cover Template', 'twentytwenty' ),
'capability' => 'edit_theme_options',
- 'description' => __( 'Settings for the "Cover Template" page template.', 'twentytwenty' ),
+ 'description' => __( 'Settings for the "Cover Template" page template. Add a featured image to use as background.', 'twentytwenty' ),
'priority' => 42,
)
);
@@ -294,8 +320,8 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize,
'cover_template_overlay_background_color',
array(
- 'label' => __( 'Image Overlay Background Color', 'twentytwenty' ),
- 'description' => __( 'The color used for the featured image overlay. Defaults to the accent color.', 'twentytwenty' ),
+ 'label' => __( 'Overlay Background Color', 'twentytwenty' ),
+ 'description' => __( 'The color used for the overlay. Defaults to the accent color.', 'twentytwenty' ),
'section' => 'cover_template_options',
)
)
@@ -316,8 +342,8 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize,
'cover_template_overlay_text_color',
array(
- 'label' => __( 'Image Overlay Text Color', 'twentytwenty' ),
- 'description' => __( 'The color used for the text in the featured image overlay.', 'twentytwenty' ),
+ 'label' => __( 'Overlay Text Color', 'twentytwenty' ),
+ 'description' => __( 'The color used for the text in the overlay.', 'twentytwenty' ),
'section' => 'cover_template_options',
)
)
@@ -337,7 +363,7 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
$wp_customize->add_control(
'cover_template_overlay_opacity',
array(
- 'label' => __( 'Image Overlay Opacity', 'twentytwenty' ),
+ 'label' => __( 'Overlay Opacity', 'twentytwenty' ),
'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'twentytwenty' ),
'section' => 'cover_template_options',
'type' => 'range',
@@ -383,6 +409,8 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
*
* @param string $input The input from the setting.
* @param object $setting The selected setting.
+ *
+ * @return string $input|$setting->default The input from the setting or the default setting.
*/
public static function sanitize_select( $input, $setting ) {
$input = sanitize_key( $input );
@@ -393,7 +421,9 @@ if ( ! class_exists( 'TwentyTwenty_Customize' ) ) {
/**
* Sanitize boolean for checkbox.
*
- * @param bool $checked Wethere or not a blox is checked.
+ * @param bool $checked Whether or not a box is checked.
+ *
+ * @return bool
*/
public static function sanitize_checkbox( $checked ) {
return ( ( isset( $checked ) && true === $checked ) ? true : false );
diff --git a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php
index 3ccccfa48d..c2d9766232 100644
--- a/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php
+++ b/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-svg-icons.php
@@ -18,10 +18,17 @@ if ( ! class_exists( 'TwentyTwenty_SVG_Icons' ) ) {
* Get the SVG code for the specified icon
*
* @param string $icon Icon name.
+ * @param string $group Icon group.
* @param string $color Color.
*/
- public static function get_svg( $icon, $color = '#1A1A1B' ) {
- $arr = apply_filters( 'twentytwenty_svg_icons', self::$icons );
+ public static function get_svg( $icon, $group = 'ui', $color = '#1A1A1B' ) {
+ if ( 'ui' === $group ) {
+ $arr = self::$ui_icons;
+ } elseif ( 'social' === $group ) {
+ $arr = self::$social_icons;
+ } else {
+ $arr = array();
+ }
if ( array_key_exists( $icon, $arr ) ) {
$repl = '
new TwentyTwenty_Walker_Comment(), @@ -80,16 +77,15 @@ if ( $comments ) { ); if ( $comment_pagination ) { + $pagination_classes = ''; // If we're only showing the "Next" link, add a class indicating so. - if ( strpos( $comment_pagination, 'prev page-numbers' ) === false ) { + if ( false === strpos( $comment_pagination, 'prev page-numbers' ) ) { $pagination_classes = ' only-next'; - } else { - $pagination_classes = ''; } ?> -