diff --git a/.gitignore b/.gitignore index 5b70da7..34806bb 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ package-lock.json gridd-plus.zip inc/acf/plugin assets/css/*.css -assets/css/**/*.css \ No newline at end of file +assets/css/**/*.css +inc/acf/ \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d841661..3f3b3c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,14 @@ +## v3.0.0 +2020-05-24 + +* FIX: Nested Grid styles. +* FIX: Refactored scroll-to-top link & styles. +* FIX: Typography scales now using a slider. +* UPDATED: ACF-Pro v5.8.11. +* REMOVED: Custom grid metabox in posts & pages. +* REMOVED: Separate mobile grids. +* REMOVED: Grid parts padding options. + ## v1.0.7 2019-09-04 diff --git a/assets/css/anchor-links.scss b/assets/css/anchor-links.scss index b565eac..24c9b26 100644 --- a/assets/css/anchor-links.scss +++ b/assets/css/anchor-links.scss @@ -1,6 +1,9 @@ .anchor-injected { opacity: 0; transition: all 250ms; + text-decoration: none !important; + border-color: transparent !important; + box-shadow: none !important; &:before { content: "🔗"; diff --git a/assets/css/grid-part-breadcrumbs.scss b/assets/css/grid-part-breadcrumbs.scss deleted file mode 100644 index c7d6a9e..0000000 --- a/assets/css/grid-part-breadcrumbs.scss +++ /dev/null @@ -1,3 +0,0 @@ -.gridd-tp-breadcrumbs { - font-size: calc(var(--brd-fs) * 1em); -} diff --git a/assets/css/grid-part-offcanvas-sidebar.scss b/assets/css/grid-part-offcanvas-sidebar.scss deleted file mode 100644 index a0f4992..0000000 --- a/assets/css/grid-part-offcanvas-sidebar.scss +++ /dev/null @@ -1,134 +0,0 @@ -.gridd-tp-offcanvas-sidebar { - position: fixed; - top: 0; - display: block; - width: var(--ocnv-w); - max-width: 100vw; - padding: var(--ocnv-pd); - background-color: var(--ocnv-bg); - color: var(--ocnv-cl); - z-index: 999999; - height: 100vh; - overflow-y: scroll; - overflow-x: hidden; - - &.position-left { - left: calc(0px - var(--ocnv-w)); - transition: left 200ms; - } - - &.position-right { - right: calc(0px - var(--ocnv-w)); - transition: right 200ms; - } - - h1, - h2, - h3, - h4, - h5, - h6 { - color: var(--ocnv-cl); - } - - a, - a:hover, - a:focus, - a:visited { - color: var(--ocnv-lc) - } -} - -.toggle-gridd-plus-offcanvas-sidebar { - position: fixed; - top: 50%; - transform: translateY(-50%); - z-index: 1000000; - background-color: var(--ocnv-bg); - color: var(--ocnv-cl); - box-shadow: none; - border: none; - display: flex; - border-radius: 2em; - opacity: .7; - - svg { - fill: var(--ocnv-cl); - } - - &.toggled-on, - &[aria-expanded=true] { - opacity: 1; - box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22); - z-index: 100; - - svg { - transform: rotate(180deg); - } - - +.gridd-tp-offcanvas-sidebar { - box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25), 0 10px 10px rgba(0, 0, 0, 0.22); - } - } - - &.position-left { - left: -2em; - transition: left 200ms; - padding: 1em .5em 1em 2em; - - &:hover, - &:active, - &:focus { - left: -1.5em; - } - - &.toggled-on, - &[aria-expanded=true] { - left: calc(var(--ocnv-w) - 1.5em); - - svg { - transform: rotate(180deg); - } - - +.gridd-tp-offcanvas-sidebar { - left: 0; - } - } - } - - &.position-right { - right: -2em; - transition: right 200ms; - padding: 1em 2em 1em .5em; - - &:hover, - &:active, - &:focus { - right: -1.5em; - } - - svg { - transform: rotate(180deg); - } - - &.toggled-on, - &[aria-expanded=true] { - right: calc(var(--ocnv-w) - 1.5em); - - svg { - transform: rotate(0deg); - } - - +.gridd-tp-offcanvas-sidebar { - right: 0; - } - } - } - - &:hover, - &:active, - &:focus { - box-shadow: none; - opacity: 1; - } -} \ No newline at end of file diff --git a/assets/css/navigation-collapsed.scss b/assets/css/navigation-collapsed.scss deleted file mode 100644 index 197a414..0000000 --- a/assets/css/navigation-collapsed.scss +++ /dev/null @@ -1,23 +0,0 @@ -// We use the "ID" (all caps) as a placeholder. -// The ID will be replaced by the actual navigation-ID via PHP -// when the style is included inline in the document. -.gridd-tp.gridd-tp-nav_ID { - - .gridd-toggle-navigation { - &.gridd-toggle { - padding: var(--nv-ID-ipd); - height: var(--nv-ID-cis); - align-items: center; - - svg { - width: var(--nv-ID-cis); - } - } - - .icon { - &.close { - transform: translateX(calc(.01px - var(--nv-ID-cis))); - } - } - } -} \ No newline at end of file diff --git a/assets/css/navigation-main.scss b/assets/css/navigation-main.scss deleted file mode 100644 index d788a2f..0000000 --- a/assets/css/navigation-main.scss +++ /dev/null @@ -1,15 +0,0 @@ -// We use the "ID" (all caps) as a placeholder. -// The ID will be replaced by the actual navigation-ID via PHP -// when the style is included inline in the document. -.gridd-tp-nav_ID { - .gridd-navigation { - a { - padding: calc(var(--nv-ID-ipd) / 1.618) var(--nv-ID-ipd); - } - - .gridd-toggle { - padding-top: var(--nv-ID-ipd); - padding-bottom: var(--nv-ID-ipd); - } - } -} diff --git a/assets/css/navigation-vertical.scss b/assets/css/navigation-vertical.scss deleted file mode 100644 index 3499e41..0000000 --- a/assets/css/navigation-vertical.scss +++ /dev/null @@ -1,14 +0,0 @@ -// // We use the "ID" (all caps) as a placeholder. -// // The ID will be replaced by the actual navigation-ID via PHP -// // when the style is included inline in the document. -// .gridd-tp-nav_ID { -// li { - -// &.menu-item-has-children, -// &.page_item_has_children { -// >a { -// width: calc(100% - var(--nv-ID-ipd) - 1em - 0.01px); -// } -// } -// } -// } diff --git a/assets/css/nested-grid-default.scss b/assets/css/nested-grid-default.scss index 3baa9f9..5c18eb3 100644 --- a/assets/css/nested-grid-default.scss +++ b/assets/css/nested-grid-default.scss @@ -2,15 +2,15 @@ // The ID will be replaced by the actual nested-grid ID via PHP // when the style is included inline in the document. .gridd-tp-nested-grid-ID { - background-color: var(--ns-gr-ID-bg); - padding: var(--ns-gr-ID-pd); + background-color: var(--bg); + padding: 1em; display: flex; justify-content: center; overflow: visible; - box-shadow: var(--ns-gr-ID-bs); + box-shadow: var(--bs); > .inner { width: 100%; - max-width: var(--ns-gr-ID-mw); + max-width: var(--mw); } } diff --git a/assets/css/nested-grid-large.scss b/assets/css/nested-grid-large.scss index f8a9de8..ca235c9 100644 --- a/assets/css/nested-grid-large.scss +++ b/assets/css/nested-grid-large.scss @@ -5,6 +5,6 @@ > .inner { display:-ms-grid; display: grid; - grid-gap: var(--ns-gr-ID-gg); + grid-gap: var(--gg); } } diff --git a/assets/css/totop.scss b/assets/css/totop.scss index 6a1ff03..e6153b2 100644 --- a/assets/css/totop.scss +++ b/assets/css/totop.scss @@ -1,76 +1,36 @@ // CSS for this implementation is a slightly tweaked version of https://codepen.io/rolandtoth/pen/eMamVK/ -@mixin setScrolltopColors($bgColor: #333, $arrowColor: white, $bgColorHover: $bgColor, $arrowColorHover: $arrowColor) { - #scrolltop-bg { - fill: $bgColor; - } - - #scrolltop-arrow { - fill: $arrowColor; - } - - a:hover { - #scrolltop-bg { - fill: $bgColorHover; - } - - #scrolltop-arrow { - fill: $arrowColorHover; - } - } -} - .scrolltop-wrap { - $size: 3rem; - $offsetBottom: 2rem; - $offsetHorizontal: 2rem; - $scrollToRevealDistance: 35vh; // scroll offset to reveal scroll-to-top link box-sizing: border-box; - position: absolute; - top: $scrollToRevealDistance; - right: $offsetHorizontal; - bottom: 0; - pointer-events: none; - backface-visibility: hidden; - @include setScrolltopColors(var(--lc), white, var(--lch)); + position: fixed; + bottom: -2em; + right: 2em; + transition: all 200ms; + + .gridd-scroll-to-top & { + bottom: 0; + } - // prevent extra page height if content is smaller than viewport - // Firefox only - @supports (-moz-appearance: meterbar) { - clip: rect(0, $size, auto, 0); + body.rtl & { + right: auto; + left: 2em; } a { - $offset: - ($size + $offsetBottom); // pull up + add a small bottom space - position: fixed; // fallback - position: sticky; - top: $offset; - width: $size; - height: $size; - margin-bottom: $offset; - transform: translateY(100vh); // push to bottom from top (when stuck) - backface-visibility: hidden; - display: inline-block; + display: flex; + justify-content: center; + width: 2em; + height: 2em; + line-height: 1.2; + background: var(--lc); + color: var(--bg); text-decoration: none; - user-select: none; - pointer-events: all; - outline: none; - overflow: hidden; - - svg { - display: block; - border-radius: 50%; - width: 100%; - height: 100%; + transform: rotate(180deg); + border-radius: 0 0 4px 4px; - path { - transition: all 0.1s; - } - } - - #scrolltop-arrow { - transform: scale(0.66); - transform-origin: center; + &:hover { + background: var(--cl); + text-decoration: none; } } @@ -78,8 +38,3 @@ display: none !important; } } - -.q-scroll-totop { - bottom: 80; - padding: .5em; -} diff --git a/assets/css/woocommerce.scss b/assets/css/woocommerce.scss index 8e2a6cb..2f65544 100644 --- a/assets/css/woocommerce.scss +++ b/assets/css/woocommerce.scss @@ -19,7 +19,7 @@ } .widget { - padding: 0 1em; + padding: 1em 1em 0 1em; .total { border-top: none; diff --git a/assets/js/anchor-headers.js b/assets/js/anchor-headers.js index b809d08..3537008 100644 --- a/assets/js/anchor-headers.js +++ b/assets/js/anchor-headers.js @@ -1,16 +1,16 @@ ( function() { var headers = document.querySelectorAll( 'h1,h2,h3,h4,h5,h6' ), - id, - el, - i; -for ( i = 0; i < headers.length; i++ ) { - id = headers[ i ].getAttribute( 'id' ); - if ( id ) { - el = document.createElement( 'a' ); - el.setAttribute( 'class', 'anchor-injected' ); - el.setAttribute( 'href', '#' + id ); - el.setAttribute( 'aria-label', 'section anchor link' ); - headers[ i ].appendChild( el ); + id, + el, + i; + for ( i = 0; i < headers.length; i++ ) { + id = headers[ i ].getAttribute( 'id' ); + if ( id ) { + el = document.createElement( 'a' ); + el.setAttribute( 'class', 'anchor-injected' ); + el.setAttribute( 'href', '#' + id ); + el.setAttribute( 'aria-label', 'section anchor link' ); + headers[ i ].appendChild( el ); + } } -} } () ); diff --git a/composer.json b/composer.json index a8aefdf..3a3fed6 100644 --- a/composer.json +++ b/composer.json @@ -6,9 +6,13 @@ "license": "GPLv2 or later", "require": { "php": ">=7", - "composer/installers": "~1.0" + "wplemon/control-wcag-textcolor": "dev-master", + "wplemon/control-wcag-linkcolor": "dev-master", + "kirki-framework/control-base": "dev-master", + "kirki-framework/field": "dev-master" }, "require-dev": { + "composer/installers": "~1.0", "phpunit/phpunit": "*", "dealerdirect/phpcodesniffer-composer-installer": "*", "wp-coding-standards/wpcs": "*", diff --git a/gridd-plus.php b/gridd-plus.php index 92c459e..f52bc33 100644 --- a/gridd-plus.php +++ b/gridd-plus.php @@ -4,7 +4,7 @@ * Plugin URI: https://wplemon.com * Author: Ari Stathopoulos * Author URI: http://aristath.github.io - * Version: 1.0.7 + * Version: 3.0.0 * Description: Premium addon plugin for the Gridd theme. * Text Domain: gridd-plus * @@ -23,7 +23,7 @@ // Define the URL. if ( ! defined( 'GRIDD_PLUS_VERSION' ) ) { - define( 'GRIDD_PLUS_VERSION', '1.0.7' ); + define( 'GRIDD_PLUS_VERSION', '3.0.0' ); } // Define the path. @@ -52,3 +52,16 @@ function gridd_plus_bootstrap() { require_once GRIDD_PLUS_PATH . '/inc/bootstrap.php'; } add_action( 'gridd_setup', 'gridd_plus_bootstrap' ); + +/** + * Filter sidebars number. + * + * This needs to be in the main plugin file because of filter priorities. + * + * @since 2.0.0 + * @return int + */ +function gridd_plus_sidebars_number() { + return (int) get_theme_mod( 'widget_areas_number', 10 ); +} +add_filter( 'gridd_get_number_of_widget_areas', 'gridd_plus_sidebars_number' ); diff --git a/inc/acf/fields.php b/inc/acf/fields.php deleted file mode 100644 index 1d1a08b..0000000 --- a/inc/acf/fields.php +++ /dev/null @@ -1,231 +0,0 @@ -get_parts(); -$parts_array = []; -foreach ( $all_parts as $part ) { - if ( isset( $part['id'] ) ) { - $part['label'] = isset( $part['label'] ) ? $part['label'] : $part['id']; - $parts_array[ $part['id'] ] = $part['label']; - } -} - -if ( function_exists( 'acf_add_local_field_group' ) ) : - - acf_add_local_field_group( - array( - 'key' => 'group_5c976c1f62554', - 'title' => esc_html__( 'Gridd Plus', 'gridd-plus' ), - 'fields' => array( - array( - 'key' => 'field_5c976c83f3aca', - 'label' => esc_html__( 'Hide Title', 'gridd-plus' ), - 'name' => 'gridd_plus_hide_title', - 'type' => 'true_false', - 'instructions' => '', - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'message' => esc_html__( 'Enable this option to hide the page title', 'gridd-plus' ), - 'default_value' => 0, - 'ui' => 0, - 'ui_on_text' => '', - 'ui_off_text' => '', - ), - array( - 'key' => 'field_5c976e36561dd', - 'label' => esc_html__( 'Custom Grid Column Dimensions', 'gridd-plus' ), - 'name' => 'gridd_plus_custom_grid_column_dimensions', - 'type' => 'text', - 'instructions' => esc_html__( 'Enter comma-separated dimensions for the grid columns. If no values are entered in this field, values will be auto-calculated.', 'gridd-plus' ), - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'maxlength' => '', - ), - array( - 'key' => 'field_5c976e88561de', - 'label' => esc_html__( 'Custom Grid Row Dimensions', 'gridd-plus' ), - 'name' => 'gridd_plus_custom_grid_row_dimensions', - 'type' => 'text', - 'instructions' => esc_html__( 'Enter comma-separated dimensions for the grid rows. If no values are entered in this field, values will be auto-calculated.', 'gridd-plus' ), - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'maxlength' => '', - ), - array( - 'key' => 'field_5c976ebf3c525', - 'label' => esc_html__( 'Custom Grid', 'gridd-plus' ), - 'name' => 'gridd_plus_custom_grid', - 'type' => 'repeater', - 'instructions' => esc_html__( 'Add the grid-parts this page should have, and select where these parts should be placed in your grid.', 'gridd-plus' ), - 'required' => 0, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'collapsed' => 'field_5c976ef83c526', - 'min' => 0, - 'max' => 0, - 'layout' => 'table', - 'button_label' => '', - 'sub_fields' => array( - array( - 'key' => 'field_5c976ef83c526', - 'label' => esc_html__( 'Grid Part', 'gridd-plus' ), - 'name' => 'grid_part', - 'type' => 'select', - 'instructions' => '', - 'required' => 1, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'choices' => $parts_array, - 'default_value' => array(), - 'allow_null' => 0, - 'multiple' => 0, - 'ui' => 0, - 'return_format' => 'value', - 'ajax' => 0, - 'placeholder' => '', - ), - array( - 'key' => 'field_5c976f3f3c527', - 'label' => esc_html__( 'Start Column', 'gridd-plus' ), - 'name' => 'start_column', - 'type' => 'number', - 'instructions' => '', - 'required' => 1, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'min' => 1, - 'max' => '', - 'step' => 1, - ), - array( - 'key' => 'field_5c976f5b3c528', - 'label' => esc_html__( 'Column Span', 'gridd-plus' ), - 'name' => 'column_span', - 'type' => 'number', - 'instructions' => '', - 'required' => 1, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'min' => 1, - 'max' => '', - 'step' => 1, - ), - array( - 'key' => 'field_5c976f803c529', - 'label' => esc_html__( 'Start Row', 'gridd-plus' ), - 'name' => 'start_row', - 'type' => 'number', - 'instructions' => '', - 'required' => 1, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'min' => 1, - 'max' => '', - 'step' => 1, - ), - array( - 'key' => 'field_5c976fa53c52a', - 'label' => esc_html__( 'Row Span', 'gridd-plus' ), - 'name' => 'row_span', - 'type' => 'number', - 'instructions' => '', - 'required' => 1, - 'conditional_logic' => 0, - 'wrapper' => array( - 'width' => '', - 'class' => '', - 'id' => '', - ), - 'default_value' => '', - 'placeholder' => '', - 'prepend' => '', - 'append' => '', - 'min' => 1, - 'max' => '', - 'step' => 1, - ), - ), - ), - ), - 'location' => array( - array( - array( - 'param' => 'post_type', - 'operator' => '==', - 'value' => 'page', - ), - ), - ), - 'menu_order' => 0, - 'position' => 'normal', - 'style' => 'default', - 'label_placement' => 'top', - 'instruction_placement' => 'label', - 'hide_on_screen' => '', - 'active' => 1, - 'description' => '', - ) - ); - -endif; diff --git a/inc/acf/primer.json b/inc/acf/primer.json deleted file mode 100644 index 30cbf12..0000000 --- a/inc/acf/primer.json +++ /dev/null @@ -1,212 +0,0 @@ -[ - { - "key": "group_5c976c1f62554", - "title": "Gridd Plus", - "fields": [ - { - "key": "field_5c976c83f3aca", - "label": "Hide Title", - "name": "gridd_plus_hide_title", - "type": "true_false", - "instructions": "", - "required": 0, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "message": "Enable this option to hide the page title", - "default_value": 0, - "ui": 0, - "ui_on_text": "", - "ui_off_text": "" - }, - { - "key": "field_5c976e36561dd", - "label": "Custom Grid Column Dimensions", - "name": "gridd_plus_custom_grid_column_dimensions", - "type": "text", - "instructions": "Enter comma-separated dimensions for the grid columns. If no values are entered in this field, values will be auto-calculated.", - "required": 0, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "maxlength": "" - }, - { - "key": "field_5c976e88561de", - "label": "Custom Grid Row Dimensions", - "name": "gridd_plus_custom_grid_row_dimensions", - "type": "text", - "instructions": "Enter comma-separated dimensions for the grid rows. If no values are entered in this field, values will be auto-calculated.", - "required": 0, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "maxlength": "" - }, - { - "key": "field_5c976ebf3c525", - "label": "Custom Grid", - "name": "gridd_plus_custom_grid", - "type": "repeater", - "instructions": "Add the grid-parts this page should have, and select where these parts should be placed in your grid.", - "required": 0, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "collapsed": "field_5c976ef83c526", - "min": 0, - "max": 0, - "layout": "table", - "button_label": "", - "sub_fields": [ - { - "key": "field_5c976ef83c526", - "label": "Grid Part", - "name": "grid_part", - "type": "select", - "instructions": "", - "required": 1, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "choices": { - "foo": "Foo", - "bar": "Bar" - }, - "default_value": [], - "allow_null": 0, - "multiple": 0, - "ui": 0, - "return_format": "value", - "ajax": 0, - "placeholder": "" - }, - { - "key": "field_5c976f3f3c527", - "label": "Start Column", - "name": "start_column", - "type": "number", - "instructions": "", - "required": 1, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "min": 1, - "max": "", - "step": 1 - }, - { - "key": "field_5c976f5b3c528", - "label": "Column Span", - "name": "column_span", - "type": "number", - "instructions": "", - "required": 1, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "min": 1, - "max": "", - "step": 1 - }, - { - "key": "field_5c976f803c529", - "label": "Start Row", - "name": "start_row", - "type": "number", - "instructions": "", - "required": 1, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "min": 1, - "max": "", - "step": 1 - }, - { - "key": "field_5c976fa53c52a", - "label": "Row Span", - "name": "row_span", - "type": "number", - "instructions": "", - "required": 1, - "conditional_logic": 0, - "wrapper": { - "width": "", - "class": "", - "id": "" - }, - "default_value": "", - "placeholder": "", - "prepend": "", - "append": "", - "min": 1, - "max": "", - "step": 1 - } - ] - } - ], - "location": [ - [ - { - "param": "post_type", - "operator": "==", - "value": "page" - } - ] - ], - "menu_order": 0, - "position": "normal", - "style": "default", - "label_placement": "top", - "instruction_placement": "label", - "hide_on_screen": "", - "active": 1, - "description": "" - } -] \ No newline at end of file diff --git a/inc/bootstrap.php b/inc/bootstrap.php index df9d29c..01d9e06 100644 --- a/inc/bootstrap.php +++ b/inc/bootstrap.php @@ -8,6 +8,11 @@ namespace Gridd_Plus; +// Make sure we have everything we need. +if ( ! class_exists( '\Kirki\Field\ReactColor' ) ) { + return; +} + /** * The Gridd-Plus Autoloader. * @@ -54,7 +59,8 @@ function( $class ) { new Grid_Part\Nested_Grid(); new Grid_Part\Layer_Slider(); new Grid_Part\Slider_Revolution(); -new Grid_Part\Offcanvas_Sidebar(); +new \Gridd_Plus\Offcanvas_Sidebar(); +new \Gridd_Plus\Breadcrumbs(); /** * Add the customizer modifications. @@ -75,13 +81,6 @@ function( $class ) { */ new Scroll_To_Top(); -/** - * Add Grid mods. - * - * @since 1.0 - */ -new Grid(); - /** * Add styles. * @@ -110,10 +109,11 @@ function( $class ) { */ new Post(); +require_once GRIDD_PLUS_PATH . '/vendor/autoload.php'; + /** * Include the updater. * * @since 1.0 */ require_once GRIDD_PLUS_PATH . '/inc/updater/updater.php'; - diff --git a/inc/classes/ACF.php b/inc/classes/ACF.php index dbaab04..de78ec2 100644 --- a/inc/classes/ACF.php +++ b/inc/classes/ACF.php @@ -25,7 +25,6 @@ public function __construct() { if ( ! class_exists( 'acf_pro' ) ) { $this->include_acf(); } - add_action( 'after_setup_theme', [ $this, 'include_acf_fields' ] ); } /** @@ -41,7 +40,7 @@ public function include_acf() { add_filter( 'acf/settings/path', function() { - return GRIDD_PLUS_PATH . '/inc/acf/plugin/'; + return GRIDD_PLUS_PATH . '/inc/acf/'; } ); @@ -49,22 +48,11 @@ function() { add_filter( 'acf/settings/dir', function() { - return GRIDD_PLUS_URL . '/inc/acf/plugin/'; + return GRIDD_PLUS_URL . '/inc/acf/'; } ); // Include the plugin file. - include_once GRIDD_PLUS_PATH . '/inc/acf/plugin/acf.php'; - } - - /** - * Includes the ACD fields in after_setup_theme. - * - * @access public - * @since 1.0.2 - * @return void - */ - public function include_acf_fields() { - require_once GRIDD_PLUS_PATH . '/inc/acf/fields.php'; + include_once GRIDD_PLUS_PATH . '/inc/acf/acf.php'; } } diff --git a/inc/classes/Breadcrumbs.php b/inc/classes/Breadcrumbs.php new file mode 100644 index 0000000..7074d0f --- /dev/null +++ b/inc/classes/Breadcrumbs.php @@ -0,0 +1,63 @@ +customizer(); + } + + /** + * Add customizer options. + * + * @access protected + * @since 2.0.0 + * @return void + */ + protected function customizer() { + + new \Kirki\Field\Slider( + [ + 'settings' => 'breadcrumbs_font_size', + 'label' => esc_html__( 'Breadcrumbs Font Size', 'gridd-plus' ), + 'description' => esc_html__( 'Controls the font-size for your breadcrumbs, relative to the body font-size.', 'gridd-plus' ), + 'section' => 'breadcrumbs', + 'default' => 1, + 'transport' => 'postMessage', + 'priority' => 100, + 'output' => [ + [ + 'element' => '.gridd-tp-breadcrumbs', + 'property' => 'font-size', + 'value_pattern' => '$em', + ], + ], + 'choices' => [ + 'min' => .5, + 'max' => 2, + 'step' => .01, + 'suffix' => 'em', + ], + 'active_callback' => function() { + return \Gridd\Customizer::is_section_active_part( 'breadcrumbs' ) && get_theme_mod( 'breadcrumbs_custom_options', false ); + }, + ] + ); + } +} diff --git a/inc/classes/Customizer.php b/inc/classes/Customizer.php index 9e6d28e..4476fa8 100644 --- a/inc/classes/Customizer.php +++ b/inc/classes/Customizer.php @@ -22,11 +22,7 @@ class Customizer { public function __construct() { add_action( 'after_setup_theme', [ $this, 'include_files' ] ); - // Add filters for the kirki premium controls we're using. - add_filter( 'kirki_wcag_text_color_url', [ $this, 'wcag_text_color_url' ] ); - add_filter( 'kirki_wcag_link_color_url', [ $this, 'wcag_link_color_url' ] ); - - add_filter( 'gridd_field_args', [ $this, 'field_args' ] ); + add_action( 'customize_register', [ $this, 'customize_register' ], 999999999 ); add_action( 'customize_controls_print_styles', [ $this, 'customize_controls_print_styles' ] ); } @@ -39,15 +35,7 @@ public function __construct() { * @return void */ public function include_files() { - require_once GRIDD_PLUS_PATH . '/inc/customizer/controls/kirki-wcag-tc/kirki-wcag-tc.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/controls/kirki-wcag-lc/kirki-wcag-lc.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/breadcrumbs.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/features.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/footer.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/grid.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/header.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/layer-slider.php'; - require_once GRIDD_PLUS_PATH . '/inc/customizer/nav-handheld.php'; + require_once GRIDD_PLUS_PATH . '/inc/customizer/customizer.php'; require_once GRIDD_PLUS_PATH . '/inc/customizer/navigation.php'; require_once GRIDD_PLUS_PATH . '/inc/customizer/nested-grid.php'; require_once GRIDD_PLUS_PATH . '/inc/customizer/offcanvas-sidebar.php'; @@ -56,81 +44,19 @@ public function include_files() { require_once GRIDD_PLUS_PATH . '/inc/customizer/typography.php'; } - /** - * Change the URL for the kirki-wcag-tc control. - * - * @access public - * @since 1.0 - * @return string - */ - public function wcag_text_color_url() { - return GRIDD_PLUS_URL . '/inc/customizer/controls/kirki-wcag-tc'; - } - - /** - * Change the URL for the kirki-wcag-lc control. - * - * @access public - * @since 1.0 - * @return string - */ - public function wcag_link_color_url() { - return GRIDD_PLUS_URL . '/inc/customizer/controls/kirki-wcag-lc'; - } - /** * Modify field arguments. * * @access public * @since 1.0 - * @param array $args The field arguments. - * @return array + * @param WP_Customize_Manager $wp_customize The customizer object. + * @return void */ - public function field_args( $args ) { - switch ( $args['settings'] ) { - case 'gridd_header_grid': - $args['choices']['duplicate'] = 'gridd_grid_header_mobile'; - break; - - case 'gridd_footer_grid': - $args['choices']['duplicate'] = 'gridd_grid_footer_mobile'; - break; - - case 'gridd_grid_nav-handheld_parts': - $args['choices']['widget-area'] = esc_html__( 'Widget Area', 'gridd-plus' ); - // If WooCommerce is installed, add another item for the Cart. - if ( class_exists( 'WooCommerce' ) ) { - $args['choices']['woo-cart'] = esc_html__( 'Cart', 'gridd-plus' ); - } - break; + public function customize_register( $wp_customize ) { - case 'gridd_type_scale': - $args['type'] = 'slider'; - $args['label'] = ''; - $args['description'] = ''; - $args['choices'] = [ - 'min' => 1, - 'max' => 2.5, - 'step' => 0.0001, - ]; - break; - - case 'gridd_featured_image_mode_singular': - $args['choices']['fixed'] = esc_html__( 'Fixed', 'gridd-plus' ); - break; + if ( class_exists( 'WooCommerce' ) ) { + $wp_customize->get_control( 'nav-handheld_parts' )->choices['woo-cart'] = esc_html__( 'Cart', 'gridd-plus' ); } - - switch ( $args['type'] ) { - case 'gridd-wcag-lc': - $args['type'] = 'kirki-wcag-lc'; - break; - - case 'gridd-wcag-tc': - $args['type'] = 'kirki-wcag-tc'; - break; - } - - return $args; } /** @@ -141,6 +67,6 @@ public function field_args( $args ) { * @return void */ public function customize_controls_print_styles() { - wp_enqueue_style( 'gridd-plus-customizer', GRIDD_PLUS_URL . '/assets/css/customizer.css', array(), GRIDD_PLUS_VERSION ); + wp_enqueue_style( 'gridd-plus-customizer', GRIDD_PLUS_URL . '/assets/css/customizer.css', [], GRIDD_PLUS_VERSION ); } } diff --git a/inc/classes/Grid.php b/inc/classes/Grid.php deleted file mode 100644 index 17aa1db..0000000 --- a/inc/classes/Grid.php +++ /dev/null @@ -1,256 +0,0 @@ -get_parts(); - - foreach ( $all_parts as $part ) { - - // Check if we've got a custom grid for mobile. - if ( get_theme_mod( 'gridd_custom_mobile_grid', false ) ) { - - // Add mobile grid parts. - if ( Grid_Parts::is_grid_part_active( $part['id'], 'gridd_grid_mobile' ) && ! in_array( $part['id'], $grid_parts, true ) ) { - $grid_parts[] = $part['id']; - } - } - } - return $grid_parts; - } - - /** - * Add grid options for small viewports. - * - * @access public - * @since 1.0 - * @param array $args The existing arguments. - * @return array Modified arguments. - */ - public function styles_responsive_args( $args ) { - switch ( $args['context'] ) { - case 'main': - if ( get_theme_mod( 'gridd_custom_mobile_grid', false ) ) { - $args['small'] = \Gridd\Grid::get_options( 'gridd_grid_mobile' ); - } - break; - - case 'header': - if ( get_theme_mod( 'gridd_grid_header_mobile_override', true ) ) { - $args['small'] = \Gridd\Grid::get_options( 'gridd_grid_header_mobile' ); - } - break; - - case 'footer': - $args['small'] = \Gridd\Grid::get_options( 'gridd_grid_footer_mobile' ); - break; - - } - return $args; - } - - /** - * Modify default values for controls. - * We're using this in the theme for grid values. - * - * @access public - * @since 1.0 - * @param mixed $defaults The default value. - * @param string $theme_mod The theme-mod we're getting. - * @return mixed - */ - public function options_defaults( $defaults, $theme_mod ) { - switch ( $theme_mod ) { - case 'gridd_grid_mobile': - return [ - 'rows' => 5, - 'columns' => 1, - 'areas' => [ - 'header' => [ - 'cells' => [ [ 1, 1 ] ], - ], - 'breadcrumbs' => [ - 'cells' => [ [ 2, 1 ] ], - ], - 'content' => [ - 'cells' => [ [ 3, 1 ] ], - ], - 'sidebar_1' => [ - 'cells' => [ [ 4, 1 ] ], - ], - 'footer' => [ - 'cells' => [ [ 5, 1 ] ], - ], - ], - 'gridTemplate' => [ - 'rows' => [ 'auto', 'auto', 'auto', 'auto', 'auto' ], - 'columns' => [ 'auto' ], - ], - ]; - - case 'gridd_grid_header_mobile': - return get_theme_mod( - 'gridd_header_grid', - [ - 'rows' => 1, - 'columns' => 1, - 'areas' => [ - 'header_branding' => [ - 'cells' => [ [ 1, 1 ] ], - ], - ], - 'gridTemplate' => [ - 'rows' => [ 'auto' ], - 'columns' => [ 'auto' ], - ], - ] - ); - - case 'gridd_grid_footer_mobile': - return get_theme_mod( - 'gridd_footer_grid', - [ - 'rows' => 2, - 'columns' => 2, - 'areas' => [ - 'footer_sidebar_1' => [ - 'cells' => [ [ 1, 1 ] ], - ], - 'footer_sidebar_2' => [ - 'cells' => [ [ 1, 2 ] ], - ], - 'footer_copyright' => [ - 'cells' => [ [ 2, 1 ], [ 2, 2 ] ], - ], - ], - 'gridTemplate' => [ - 'rows' => [ 'auto', 'auto' ], - 'columns' => [ '1fr', '1fr', '1fr', '1fr' ], - ], - ] - ); - - default: - return $defaults; - } - } - - /** - * Applies custom Grids from post-meta. - * - * @access public - * @since 1.0 - * @param mixed $value The theme-mod value. - * @param string $theme_mod The theme-mod. - * @return array Modified grid - or the original value if we don't want custom grid. - */ - public function grid_from_post_meta( $value, $theme_mod ) { - if ( 'gridd_grid' === $theme_mod ) { - $custom_grid = get_field( 'gridd_plus_custom_grid' ); - $custom_grid_row_dimensions = get_field( 'gridd_plus_custom_grid_row_dimensions' ); - $custom_grid_col_dimensions = get_field( 'gridd_plus_custom_grid_column_dimensions' ); - $max_col = 1; - $max_row = 1; - if ( $custom_grid ) { - $areas = []; - foreach ( $custom_grid as $part ) { - $areas[ $part['grid_part'] ] = [ - 'cells' => [], - ]; - - // Get properties. - $start_col = (int) $part['start_column']; - $span_col = (int) $part['column_span']; - $start_row = (int) $part['start_row']; - $span_row = (int) $part['row_span']; - - for ( $col = $start_col; $col < $start_col + $span_col; $col++ ) { - if ( $col > $max_col ) { - $max_col = $col; - } - for ( $row = $start_row; $row < $start_row + $span_row; $row++ ) { - if ( $row > $max_row ) { - $max_row = $row; - } - $areas[ $part['grid_part'] ]['cells'][] = [ $row, $col ]; - } - } - } - $value['rows'] = $max_row; - $value['columns'] = $max_col; - $value['areas'] = $areas; - } - - // Add custom column dimensions. - $max_cols = max( $max_col, $value['columns'], count( $value['gridTemplate']['columns'] ) ); - if ( $custom_grid_col_dimensions ) { - $custom_grid_col_dimensions = explode( ',', $custom_grid_col_dimensions ); - foreach ( $custom_grid_col_dimensions as $key => $dimension ) { - $value['gridTemplate']['columns'][ $key ] = esc_attr( trim( $dimension ) ); - } - } - - // Fill-in the blanks with "auto" values. - if ( $value['columns'] < $max_cols ) { - for ( $i = 0; $i < $max_cols - $value['columns']; $i++ ) { - $value['gridTemplate']['columns'][] = 'auto'; - } - } - - // Add custom row dimensions. - $max_rows = max( $max_row, $value['rows'], count( $value['gridTemplate']['rows'] ) ); - if ( $custom_grid_row_dimensions ) { - $custom_grid_row_dimensions = explode( ',', $custom_grid_row_dimensions ); - foreach ( $custom_grid_row_dimensions as $key => $dimension ) { - $value['gridTemplate']['rows'][ $key ] = esc_attr( trim( $dimension ) ); - } - } - - // Fill-in the blanks with "auto" values. - if ( $value['rows'] < $max_rows ) { - for ( $i = 0; $i < $max_rows - $value['rows']; $i++ ) { - $value['gridTemplate']['rows'][] = 'auto'; - } - } - } - return $value; - } -} diff --git a/inc/classes/Grid_Part/Layer_Slider.php b/inc/classes/Grid_Part/Layer_Slider.php index e7c4cbd..8298340 100644 --- a/inc/classes/Grid_Part/Layer_Slider.php +++ b/inc/classes/Grid_Part/Layer_Slider.php @@ -7,7 +7,6 @@ namespace Gridd_Plus\Grid_Part; -use Gridd\Grid; use Gridd\Grid_Part; use Gridd\Theme; diff --git a/inc/classes/Grid_Part/Nested_Grid.php b/inc/classes/Grid_Part/Nested_Grid.php index 79e134c..9034b4a 100644 --- a/inc/classes/Grid_Part/Nested_Grid.php +++ b/inc/classes/Grid_Part/Nested_Grid.php @@ -7,9 +7,7 @@ namespace Gridd_Plus\Grid_Part; -use Gridd\Grid; use Gridd\Grid_Part; -use Gridd\Style; /** * The Gridd\Grid_Part\Nested_Grid object. @@ -81,11 +79,65 @@ public function add_template_part( $parts ) { public function render( $part ) { if ( 0 === strpos( $part, 'nested-grid-' ) && is_numeric( str_replace( 'nested-grid-', '', $part ) ) ) { $id = (int) str_replace( 'nested-grid-', '', $part ); - /** - * We use include( get_theme_file_path() ) here - * because we need to pass the $sidebar_id var to the template. - */ - include GRIDD_PLUS_PATH . '/inc/templates/nested-grid.php'; + + $settings = \Gridd\Grid::get_options( "gridd_nested_grid_$id" ); + $classes = [ + 'gridd-tp', + "gridd-tp-nested-grid-$id", + ]; + if ( get_theme_mod( "gridd_nested_grid_{$id}_sticky", false ) ) { + $classes[] = 'gridd-sticky'; + } + + $style = \Gridd\Style::get_instance( "grid-part/nested-grid-$id" ); + $style->add_string( + \Gridd\Grid::get_styles_responsive( + [ + 'context' => "nested-grid-$id", + 'large' => $settings, + 'small' => false, + 'breakpoint' => get_theme_mod( 'gridd_mobile_breakpoint', '800px' ), + 'selector' => '.gridd-tp-nested-grid-1 > .inner', + 'prefix' => true, + ] + ) + ); + $style->add_file( GRIDD_PLUS_PATH . '/assets/css/nested-grid-default.min.css' ); + + // Add styles for large screens. + $style->add_string( '@media only screen and (min-width:' . get_theme_mod( 'gridd_mobile_breakpoint', '800px' ) . '){' ); + $style->add_file( GRIDD_PLUS_PATH . '/assets/css/nested-grid-large.min.css' ); + $style->add_string( '}' ); + + // Generate grid styles for parts. + $style->add_string( \Gridd\Grid::get_styles( $settings, "gridd-tp-nested-grid-$id > .inner", true ) ); + $style->replace( 'ID', $id ); + $style->add_vars( + [ + "gridd-nested-grid-$id-background" => get_theme_mod( "gridd_nested_grid_{$id}_background_color", '#ffffff' ), + "gridd-nested-grid-$id-padding" => get_theme_mod( "gridd_nested_grid_{$id}_padding", 0 ), + "gridd-nested-grid-$id-box-shadow" => get_theme_mod( "gridd_nested_grid_{$id}_box_shadow", 'none' ), + "gridd-nested-grid-$id-max-width" => get_theme_mod( "gridd_nested_grid_{$id}_max_width", '' ), + "gridd-nested-grid-$id-grid-gap" => get_theme_mod( "gridd_nested_grid_{$id}_gap", 0 ), + ] + ); + ?> +
+ the_css( 'gridd-inline-css-nested-grid-' . $id ); + ?> +
+ + + + + +
+
+ register_rest_api_partials(); - add_action( 'widgets_init', [ $this, 'register_sidebars' ] ); - add_action( 'gridd_the_grid_part', [ $this, 'render' ] ); - add_action( 'get_sidebar', [ $this, 'get_sidebar' ] ); - add_action( 'gridd_the_partial', [ $this, 'the_partial' ] ); - } - - /** - * Returns the grid-part definition. - * - * @access protected - * @since 1.0 - * @return void - */ - protected function set_part() { - $this->part = [ - 'label' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), - 'color' => [ '#74BEA7', '#000' ], - 'priority' => 60, - 'hidden' => true, - 'id' => $this->id, - ]; - } - - /** - * Add action on the get_sidebar hook. - * - * @access public - * @since 1.0.3 - * @param string $name The sidebar name. - * @return void - */ - public function get_sidebar( $name ) { - $this->render( $name ); - } - - /** - * Render this grid-part. - * - * @access public - * @since 1.0 - * @param string $part The grid-part ID. - * @return void - */ - public function render( $part ) { - if ( 'offcanvas-sidebar' === $part ) { - if ( Rest::is_partial_deferred( $part ) ) { - echo '
'; - return; - } - $this->the_partial( $part ); - } - } - - /** - * Renders the grid-part partial. - * - * @access public - * @since 1.1 - * @param string $part The grid-part ID. - * @return void - */ - public function the_partial( $part ) { - if ( 'offcanvas-sidebar' === $part ) { - include GRIDD_PLUS_PATH . '/inc/templates/offcanvas-sidebar.php'; - } - } - - /** - * Register the sidebar(s). - * - * @access public - * @since 1.0 - * @return void - */ - public function register_sidebars() { - register_sidebar( - [ - 'name' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), - 'id' => 'offcanvas-sidebar', - 'description' => esc_html__( 'Add widgets here.', 'gridd-plus' ), - 'before_widget' => '
', - 'after_widget' => '
', - 'before_title' => '

', - 'after_title' => '

', - ] - ); - } - - /** - * Registers the partial(s) for the REST API. - * - * @access public - * @since 1.1 - * @return void - */ - public function register_rest_api_partials() { - Rest::register_partial( - [ - 'id' => 'offcanvas-sidebar', - 'label' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), - ] - ); - } -} - -/* Omit closing PHP tag to avoid "Headers already sent" issues. */ diff --git a/inc/classes/Grid_Part/Slider_Revolution.php b/inc/classes/Grid_Part/Slider_Revolution.php index 5ac7328..810f65c 100644 --- a/inc/classes/Grid_Part/Slider_Revolution.php +++ b/inc/classes/Grid_Part/Slider_Revolution.php @@ -7,7 +7,6 @@ namespace Gridd_Plus\Grid_Part; -use Gridd\Grid; use Gridd\Grid_Part; use Gridd\Theme; diff --git a/inc/classes/Offcanvas_Sidebar.php b/inc/classes/Offcanvas_Sidebar.php new file mode 100644 index 0000000..a4950c9 --- /dev/null +++ b/inc/classes/Offcanvas_Sidebar.php @@ -0,0 +1,255 @@ +register_rest_api_partials(); + add_action( 'widgets_init', [ $this, 'register_sidebars' ] ); + add_action( 'gridd_the_grid_part', [ $this, 'render' ] ); + add_action( 'get_sidebar', [ $this, 'get_sidebar' ] ); + add_action( 'gridd_the_partial', [ $this, 'the_partial' ] ); + add_filter( 'gridd_smart_grid_main_parts_order', [ $this, 'grid_parts_order' ] ); + + // Add script. + add_action( 'wp_footer', [ $this, 'footer_inline_script' ] ); + } + + /** + * Returns the grid-part definition. + * + * @access protected + * @since 1.0 + * @return void + */ + protected function set_part() { + $this->part = [ + 'label' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), + 'color' => [ '#74BEA7', '#000' ], + 'priority' => 10, + 'hidden' => true, + 'id' => $this->id, + ]; + } + + /** + * Add action on the get_sidebar hook. + * + * @access public + * @since 1.0.3 + * @param string $name The sidebar name. + * @return void + */ + public function get_sidebar( $name ) { + $this->render( $name ); + } + + /** + * Render this grid-part. + * + * @access public + * @since 1.0 + * @param string $part The grid-part ID. + * @return void + */ + public function render( $part ) { + if ( 'offcanvas-sidebar' === $part ) { + if ( \Gridd\Rest::is_partial_deferred( $part ) ) { + echo '
'; + return; + } + $this->the_partial( $part ); + } + } + + /** + * Renders the grid-part partial. + * + * @access public + * @since 1.1 + * @param string $part The grid-part ID. + * @return void + */ + public function the_partial( $part ) { + if ( 'offcanvas-sidebar' === $part ) { + // Early exit if we don't want to show the sidebar. + if ( ! is_active_sidebar( 'offcanvas-sidebar' ) && ! is_customize_preview() ) { + return; + } + if ( is_customize_preview() && ! is_active_sidebar( 'offcanvas-sidebar' ) ) { + echo ''; + } + ?> +
+ [ 'offcanvas-sidebar' ], + 'expanded_state_id' => 'griddPlusOffcanvasSidebar', + 'expanded' => 'false', + 'label' => '' . esc_html__( 'Toggle Sidebar', 'gridd-plus' ) . '', + 'classes' => [ 'toggle-gridd-plus-offcanvas-sidebar', 'position-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) ], + ] + ); + ?> + + +
'gridd-tp gridd-tp-sidebar gridd-tp-offcanvas-sidebar position-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) ], 'wrapper-offcanvas-sidebar' ); ?>> + add_string( '#offcanvas-wrapper{display:none;}' ); + + if ( 'desktop' === get_theme_mod( 'offcanvas_sidebar_visibility', 'always' ) ) { + $style->add_string( '@media only screen and (min-width:' . get_theme_mod( 'gridd_mobile_breakpoint', '992px' ) . '){' ); + $style->add_string( $this->get_styles() ); + $style->add_string( 'body{padding-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) . ':calc(2.25em + 2px);}#wpadminbar{padding-left:5em;}@media screen and (max-width:782px){#wpadminbar{padding-left:3em;}}' ); + $style->add_string( '}' ); + } elseif ( 'mobile' === get_theme_mod( 'offcanvas_sidebar_visibility', 'always' ) ) { + $style->add_string( '@media only screen and (max-width:' . get_theme_mod( 'gridd_mobile_breakpoint', '992px' ) . '){' ); + $style->add_string( $this->get_styles() ); + $style->add_string( 'body{padding-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) . ':calc(2.25em + 2px);}#wpadminbar{padding-left:5em;}@media screen and (max-width:782px){#wpadminbar{padding-left:3em;}}' ); + $style->add_string( '}' ); + } else { + $style->add_string( $this->get_styles() ); + $style->add_string( 'body{padding-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) . ':calc(2.25em + 2px);}#wpadminbar{padding-left:5em;}@media screen and (max-width:782px){#wpadminbar{padding-left:3em;}}' ); + } + + $style->the_css( 'gridd-inline-css-offcanvas-sidebar' ); + ?> +
+ +
+
+ +
+ esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), + 'id' => 'offcanvas-sidebar', + 'description' => esc_html__( 'Add widgets here.', 'gridd-plus' ), + 'before_widget' => '
', + 'after_widget' => '
', + 'before_title' => '

', + 'after_title' => '

', + ] + ); + } + + /** + * Registers the partial(s) for the REST API. + * + * @access public + * @since 1.1 + * @return void + */ + public function register_rest_api_partials() { + \Gridd\Rest::register_partial( + [ + 'id' => 'offcanvas-sidebar', + 'label' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), + ] + ); + } + + /** + * Change the position of the grid-part and put it right after the header. + * + * @access public + * @since 2.0.0 + * @param array $parts An array of our ordered grid-parts. + * @return array + */ + public function grid_parts_order( $parts ) { + $final_parts = []; + foreach ( $parts as $part ) { + $final_parts[] = $part; + if ( 'header' === $part ) { + $final_parts[] = 'offcanvas-sidebar'; + } + } + + return $final_parts; + } + + /** + * Adds the script to the footer. + * + * @access public + * @since 2.0.0 + * @return void + */ + public function footer_inline_script() { + if ( ! is_active_sidebar( 'offcanvas-sidebar' ) ) { + return; + } + echo ''; + } + + /** + * Gets the styles. + * + * @access public + * @since 2.0.0 + * @return string + */ + public function get_styles() { + return '#offcanvas-wrapper{position:fixed;height:100%;background-color:var(--bg);z-index:999999;display:-webkit-box;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;-webkit-box-align:start;-ms-flex-align:start;align-items:flex-start;color:var(--cl);top:0}#offcanvas-wrapper.position-left{left:-1px}#offcanvas-wrapper.position-right{right:-1px}#offcanvas-wrapper:after,#offcanvas-wrapper:before{background:var(--cl);opacity:.1;content:" ";width:1px;height:100%;left:0;position:absolute}#offcanvas-wrapper:after{left:auto;right:0}.toggle-gridd-plus-offcanvas-sidebar{background:0 0;-webkit-box-shadow:0;box-shadow:0;border-color:transparent;padding:.625em;border-radius:0}.toggle-gridd-plus-offcanvas-sidebar svg{fill:var(--cl);width:1em;height:1em}.toggle-gridd-plus-offcanvas-sidebar:active,.toggle-gridd-plus-offcanvas-sidebar:focus,.toggle-gridd-plus-offcanvas-sidebar:hover{-webkit-box-shadow:none;box-shadow:none;border-color:transparent}.toggle-gridd-plus-offcanvas-sidebar.toggled-on,.toggle-gridd-plus-offcanvas-sidebar:active,.toggle-gridd-plus-offcanvas-sidebar:focus,.toggle-gridd-plus-offcanvas-sidebar[aria-expanded=true]{background-color:var(--cl)}.toggle-gridd-plus-offcanvas-sidebar.toggled-on svg,.toggle-gridd-plus-offcanvas-sidebar:active svg,.toggle-gridd-plus-offcanvas-sidebar:focus svg,.toggle-gridd-plus-offcanvas-sidebar[aria-expanded=true] svg{fill:var(--bg)}.toggle-gridd-plus-offcanvas-sidebar.toggled-on+.gridd-tp-offcanvas-sidebar,.toggle-gridd-plus-offcanvas-sidebar[aria-expanded=true]+.gridd-tp-offcanvas-sidebar{display:-webkit-box;display:-ms-flexbox;display:flex}.gridd-tp.gridd-tp-offcanvas-sidebar{width:var(--sz);max-width:100vw;z-index:999999;height:100%;overflow-y:auto;overflow-x:hidden;display:none;position:relative;margin-left:-1px;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:start;-ms-flex-pack:start;justify-content:flex-start}.gridd-tp.gridd-tp-offcanvas-sidebar .inner{padding:1em;}.gridd-tp.gridd-tp-offcanvas-sidebar:before{background:var(--cl);opacity:.1;content:" ";width:1px;height:100%;left:0;position:absolute}.gridd-tp.gridd-tp-offcanvas-sidebar h1,.gridd-tp.gridd-tp-offcanvas-sidebar h2,.gridd-tp.gridd-tp-offcanvas-sidebar h3,.gridd-tp.gridd-tp-offcanvas-sidebar h4,.gridd-tp.gridd-tp-offcanvas-sidebar h5,.gridd-tp.gridd-tp-offcanvas-sidebar h6{color:var(--cl)}.gridd-tp.gridd-tp-offcanvas-sidebar a{color:var(--cl)}'; + } +} + +/* Omit closing PHP tag to avoid "Headers already sent" issues. */ diff --git a/inc/classes/Plugin.php b/inc/classes/Plugin.php index 7dfa681..5b2a02f 100644 --- a/inc/classes/Plugin.php +++ b/inc/classes/Plugin.php @@ -54,7 +54,6 @@ private function __construct() { // Gridd theme filters and actions. add_action( 'gridd_nav_handheld_part_template', [ $this, 'handheld_nav_widget_parts' ] ); - add_filter( 'gridd_featured_image_use_background', [ $this, 'featured_image_use_background' ] ); add_filter( 'gridd_render_grid_part', [ $this, 'gridd_render_grid_part' ], 10, 2 ); } @@ -68,36 +67,9 @@ private function __construct() { */ public function handheld_nav_widget_parts( $part ) { switch ( $part ) { - case 'widget-area': - $label_class = get_theme_mod( 'gridd_grid_nav-handheld_hide_labels', false ) ? 'screen-reader-text' : 'label'; - ?> -
- 'griddHandheldWidgetAreaWrapper', - 'expanded' => 'false', - 'label' => get_theme_mod( 'gridd_grid_nav-handheld_widget_area_icon', '' ) . '' . get_theme_mod( 'gridd_grid_nav-handheld_widget_area_label', esc_html__( 'Settings', 'gridd-plus' ) ) . '', - 'classes' => [ 'gridd-nav-handheld-btn' ], - ] - ); - ?> -
- - -
- -
-
- '; @@ -138,20 +110,6 @@ public function handheld_nav_widget_parts( $part ) { } } - /** - * Figure out if we want to use a background-image for featured images or not. - * - * @access public - * @since 1.0 - * @return bool - */ - public function featured_image_use_background() { - if ( 'fixed' === get_theme_mod( 'gridd_featured_image_mode_singular', 'alignwide' ) ) { - return true; - } - return false; - } - /** * Handles the visibility for grid-parts. * @@ -168,8 +126,8 @@ public function gridd_render_grid_part( $render, $part ) { $sidebars_number = Sidebar::get_number_of_sidebars(); for ( $i = 1; $i <= $sidebars_number; $i++ ) { $visibility_settings[ "sidebar_$i" ] = [ - 'post' => "gridd_grid_sidebar_{$i}_visibility_post_id", - 'term' => "gridd_grid_sidebar_{$i}_visibility_term_id", + 'post' => "sidebar_{$i}_visibility_post_id", + 'term' => "sidebar_{$i}_visibility_term_id", ]; } diff --git a/inc/classes/Scroll_To_Top.php b/inc/classes/Scroll_To_Top.php index 588d08a..6d96d06 100644 --- a/inc/classes/Scroll_To_Top.php +++ b/inc/classes/Scroll_To_Top.php @@ -31,7 +31,7 @@ public function __construct() { } // Add the HTML in the footer. - add_action( 'wp_footer', [ $this, 'the_html' ] ); + add_action( 'wp_footer', [ $this, 'the_html' ], 999 ); // Add the CSS in the footer. add_action( 'wp_footer', [ $this, 'the_css' ] ); @@ -47,24 +47,25 @@ public function __construct() { public function the_html() { ?> - - - + add_file( GRIDD_PLUS_PATH . '/assets/css/totop.min.css' ); - if ( 'large' === get_theme_mod( 'gridd_enable_totop', 'hidden' ) ) { - $style->add_string( '@media only screen and (max-width:' . esc_attr( $breakpoint ) . '){.gridd-scroll-totop{display:none;}}' ); - } + $style->add_string( '@media only screen and (max-width:' . esc_attr( $breakpoint ) . '){.scrolltop-wrap{display:none;}}' ); $style->the_css( 'gridd-inline-css-totop' ); } } diff --git a/inc/classes/Styles.php b/inc/classes/Styles.php index 78aee25..248ded9 100644 --- a/inc/classes/Styles.php +++ b/inc/classes/Styles.php @@ -56,10 +56,6 @@ public function print_footer_styles() { */ public function gridd_style( $style ) { switch ( $style->context ) { - case 'grid-part/breadcrumbs': - $style->add_file( GRIDD_PLUS_PATH . '/assets/css/grid-part-breadcrumbs.min.css' ); - break; - case 'main-styles': $style->add_file( GRIDD_PLUS_PATH . '/assets/css/typography.min.css' ); $style->add_file( GRIDD_PLUS_PATH . '/assets/css/links.min.css' ); @@ -73,40 +69,6 @@ public function gridd_style( $style ) { $style->add_file( GRIDD_PLUS_PATH . '/assets/css/nav-handheld-woo-cart.min.css' ); break; - case ( 0 === strpos( $style->context, 'grid-part/navigation/' ) ): - $nav_id = str_replace( 'grid-part/navigation/', '', $style->context ); - $responsive_mode = get_theme_mod( "gridd_grid_nav_{$nav_id}_responsive_behavior", 'desktop-normal-mobile-hidden' ); - $added_vertical_styles = false; - $style->add_file( GRIDD_PLUS_PATH . '/assets/css/navigation-main.min.css' ); - if ( false !== strpos( $responsive_mode, 'desktop-normal' ) ) { - if ( get_theme_mod( "gridd_grid_nav_{$nav_id}_vertical", false ) ) { - $style->add_file( GRIDD_PLUS_PATH . '/assets/css/navigation-vertical.min.css' ); - $added_vertical_styles = true; - } - } - - if ( false !== strpos( $responsive_mode, 'icon' ) ) { - if ( false !== strpos( $responsive_mode, 'desktop-normal' ) ) { - $style->add_string( '@media only screen and (max-width:' . get_theme_mod( 'gridd_mobile_breakpoint', '800px' ) . '){' ); - } - $style->add_file( GRIDD_PLUS_PATH . '/assets/css/navigation-collapsed.min.css' ); - if ( ! $added_vertical_styles ) { - $style->add_file( GRIDD_PLUS_PATH . '/assets/css/navigation-vertical.min.css' ); - } - if ( false !== strpos( $responsive_mode, 'desktop-normal' ) ) { - $style->add_string( '}' ); - } - } - $style->replace( 'ID', $nav_id ); - $style->add_vars( - [ - "--nv-$nav_id-fs" => get_theme_mod( "gridd_grid_nav_{$nav_id}_font_size", 1 ) . 'em', - "--nv-$nav_id-ipd" => get_theme_mod( "gridd_grid_nav_{$nav_id}_items_padding", 1 ) . 'em', - "--nv-$nav_id-cis" => get_theme_mod( "gridd_grid_nav_{$nav_id}_collapse_icon_size", 1 ) . 'em', - ] - ); - break; - case 'footer-late-styles': $style->add_file( GRIDD_PLUS_PATH . '/assets/css/posts-and-pages.min.css' ); } diff --git a/inc/classes/WooCommerce.php b/inc/classes/WooCommerce.php index e01062f..33952c8 100644 --- a/inc/classes/WooCommerce.php +++ b/inc/classes/WooCommerce.php @@ -8,8 +8,6 @@ namespace Gridd_Plus; -use Gridd\Theme; - /** * The Gridd_Plus object. * Takes care of initializing the plugin and doing what must be done. @@ -97,7 +95,7 @@ public function wp_nav_menu_items( $items, $args ) { $is_cart = ( function_exists( 'is_cart' ) && is_cart() ); $is_checkout = ( ( function_exists( 'is_checkout' ) && is_checkout() ) || ( function_exists( 'is_checkout_pay_page' ) && is_checkout_pay_page() ) ); $menu_id = absint( str_replace( 'menu-', '', $args->theme_location ) ); - $show_in_nav = get_theme_mod( "gridd_grid_nav_{$menu_id}_woo_cart", 1 === $menu_id ); + $show_in_nav = get_theme_mod( "nav_{$menu_id}_woo_cart", 1 === $menu_id ); if ( ! $is_cart && ! $is_checkout && $show_in_nav ) { ob_start(); diff --git a/inc/customizer/breadcrumbs.php b/inc/customizer/breadcrumbs.php deleted file mode 100644 index a690ddb..0000000 --- a/inc/customizer/breadcrumbs.php +++ /dev/null @@ -1,37 +0,0 @@ - 'slider', - 'settings' => 'gridd_grid_breadcrumbs_font_size', - 'label' => esc_html__( 'Font Size', 'gridd-plus' ), - 'description' => Customizer::get_control_description( - [ - 'short' => '', - 'details' => esc_html__( 'Controls the font-size for your breadcrumbs. This value is relative to the body font-size, so a value of 1em will have the same size as your content.', 'gridd-plus' ), - ] - ), - 'section' => 'gridd_grid_part_details_breadcrumbs', - 'default' => 1, - 'transport' => 'postMessage', - 'css_vars' => '--brd-fs', - 'choices' => [ - 'min' => .5, - 'max' => 2, - 'step' => .01, - 'suffix' => 'em', - ], - ] -); - -/* Omit closing PHP tag to avoid "Headers already sent" issues. */ diff --git a/inc/customizer/controls/kirki-wcag-lc/class-kirki-wcag-link-color.php b/inc/customizer/controls/kirki-wcag-lc/class-kirki-wcag-link-color.php deleted file mode 100644 index 5f660b2..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/class-kirki-wcag-link-color.php +++ /dev/null @@ -1,223 +0,0 @@ -json['default'] = $this->setting->default; - if ( isset( $this->default ) ) { - $this->json['default'] = $this->default; - } - - // Required. - $this->json['required'] = $this->required; - - // Output. - $this->json['output'] = $this->output; - - // Value. - $this->json['value'] = $this->value(); - - // Choices. - $this->json['choices'] = $this->choices; - - // The link. - $this->json['link'] = $this->get_link(); - - // The ID. - $this->json['id'] = $this->id; - - // The kirki-config. - $this->json['kirkiConfig'] = $this->kirki_config; - - // The option-type. - $this->json['kirkiOptionType'] = $this->option_type; - - // The option-name. - $this->json['kirkiOptionName'] = $this->option_name; - - // The CSS-Variables. - $this->json['css-var'] = $this->css_vars; - } - - /** - * An Underscore (JS) template for this control's content (but not its container). - * - * Class variables for this control class are available in the `data` JS object; - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. - * - * @see WP_Customize_Control::print_template() - * - * @access protected - */ - protected function content_template() { - ?> - <# if ( data.label ) { #> - - <# } #> - <# if ( data.description ) { #> - {{{ data.description }}} - <# } #> - -
- - -
- -
-
- - -
- - -
- - - - - - - - - -
-
-
- -
-
-
- - - - register_control_type( 'Kirki_WCAG_Link_Color' ); - } -} -add_action( 'customize_register', 'kirki_wcag_link_color_register_control_type' ); diff --git a/inc/customizer/controls/kirki-wcag-lc/readme.txt b/inc/customizer/controls/kirki-wcag-lc/readme.txt deleted file mode 100644 index a57328e..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -=== Kirki Accessible-Text Colorpicker === -Contributors: aristath, wplemon -Tags: customizer, kirki -Requires at least: 4.9 -Tested up to: 5.0 -Stable tag: 1.0 - - -== Description == - -description for this product can be found on https://wplemon.com/downloads/kirki-accessible-text-colorpicker/ - -== Changelog == - -= 1.0 = - -* Initial release diff --git a/inc/customizer/controls/kirki-wcag-lc/script.js b/inc/customizer/controls/kirki-wcag-lc/script.js deleted file mode 100644 index 837e111..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/script.js +++ /dev/null @@ -1,559 +0,0 @@ -/* global wcagColors */ -wp.customize.controlConstructor['kirki-wcag-lc'] = wp.customize.Control.extend({ - - /** - * The selected hue. - * - * @since 1.0 - * @var {int} - */ - hue: 0, - - /** - * An array of all colors for this hue. - * - * @since 1.0 - * @var {Array} - */ - allColors: false, - - /** - * An object containing the accessible colors for AAA, AA & A compliance. - * - * @since 1.0 - * @var {Object} - */ - colors: {}, - - /** - * Triggered when the control is ready. - * - * @since 1.0 - * @returns {void} - */ - ready: function() { - var control = this, - currentValue = this.setting.get(); - - // Set initial hue. - this.setHue(); - - // We use debounced methods to avoid over-calculating things. - this.updateHTMLDebounced = _.debounce( _.bind( control.updateControlHTML, this ), 5 ); - - // Get available colors. This is the initial run when the control gets init, - // no reason to run the debounced method here. - this.updateColors( false ); - - // Check if we're on auto mode or custom mode. - // If the selected color is one of the AAA or AA colors then we're on autopilot. - this.isAuto = ( this.colors && ( -1 !== this.colors.AAA.indexOf( currentValue ) || 20 < this.colors.AA.indexOf( currentValue ) ) ); - - // Init tabs. - this.initTabs(); - - // Init auto or custom mode depending on our selected color. - if ( this.isAuto ) { - control.destroyCustom(); - control.initAuto(); - } else { - control.destroyAuto(); - control.initCustom(); - } - }, - - /** - * Init the tabs. - * - * @since 1.0 - * @returns {void} - */ - initTabs: function() { - var control = this, - autoButton = control.container.find( '.tab-headers .trigger-auto' ), - customButton = control.container.find( '.tab-headers .trigger-custom' ); - - if ( control.isAuto ) { - autoButton.addClass( 'active' ); - } else { - customButton.addClass( 'active' ); - } - - autoButton.on( 'click', function( e ) { - e.preventDefault(); - customButton.removeClass( 'active' ); - autoButton.addClass( 'active' ); - control.destroyCustom(); - control.initAuto(); - }); - - customButton.on( 'click', function( e ) { - e.preventDefault(); - autoButton.removeClass( 'active' ); - customButton.addClass( 'active' ); - control.destroyAuto(); - control.initCustom(); - }); - }, - - /** - * Init functionality for auto. - * - * @since 1.0 - * @returns {Object} - this - */ - initAuto: function() { - var control = this; - this.isAuto = true; - - // Set the hue. - control.setHue(); - - // Update Colors. - this.updateColors( false ); - - // Show the Auto container. - this.container.find( '.kirki-input-container.auto' ).show(); - - // Add the input. - this.container.find( '.color-hue-container' ).html( '' ); - - // Init the colorpicker. - this.initHuePicker(); - - this.settingsWatchers = function() { - - // Watch for changes to the background color. - control.watchSetting( control.params.choices.backgroundColor ); - - // Watch for changes to the text color. - control.watchSetting( control.params.choices.textColor ); - - // Watch radio-inputs. - control.radioInputListeners(); - }; - - this.settingsWatchers(); - - this.updateHTMLDebounced( true ); - - // Expand color-selectors when requested. - control.container.find( '.expand-selectors' ).on( 'click', function( e ) { - e.preventDefault(); - control.container.find( '.rating-containers-wrapper' ).toggleClass( 'hidden' ); - }); - }, - - /** - * Init functionality for custom. - * - * @since 1.0 - * @returns {Object} - this - */ - initCustom: function() { - this.isAuto = false; - - // Add the input field. - this.container.find( '.color-hex-container' ).html( '' ); - - // Show the Custom container. - this.container.find( '.kirki-input-container.custom' ).show(); - - // Init the colorpicker. - this.initHexPicker(); - }, - - /** - * Destroy the hue colorpicker and remove any listeners we have. - * - * @since 1.0 - * @returns {Object} - this - */ - destroyAuto: function() { - - // Hide the Auto container. - this.container.find( '.kirki-input-container.auto' ).hide(); - - // Destroy the colorpicker. - if ( this.container.find( '.auto .color-hue' ).wpColorPicker( 'instance' ) ) { - this.container.find( '.auto .color-hue' ).wpColorPicker( 'destroy' ); - } - - // Remove the picker entirely. - this.container.find( '.color-hue-container' ).html( '' ); - - // Remove watchers added in the initAuto function. - this.settingsWatchers = function() {}; - - // Remove event watchers for the expand link. - this.container.find( '.expand-selectors' ).off(); - }, - - /** - * Destroy the hex colorpicker and any listeners we might have. - * - * @since 1.0 - * @returns {Object} - this - */ - destroyCustom: function() { - - // Hide the Custom container. - this.container.find( '.kirki-input-container.custom' ).hide(); - - // Destroy the colorpicker. - if ( this.container.find( '.custom .color-hex' ).wpColorPicker( 'instance' ) ) { - this.container.find( '.custom .color-hex' ).wpColorPicker( 'destroy' ); - } - - // Remove the colorpicker entirely. - this.container.find( '.color-hex-container' ).html( '' ); - }, - - /** - * Init the hex colorpicker. - * - * @since 1.0 - * @returns {void} - */ - initHexPicker: function() { - var control = this, - hexPicker = control.container.find( '.custom .color-hex' ); - - hexPicker.wpColorPicker({ - change: function() { - - // Small hack: the picker needs a small delay - setTimeout( function() { - - // Save the value. - control.setting.set( hexPicker.val() ); - }, 20 ); - } - }); - }, - - /** - * Initialize the hue colorpicker. - * - * @since 1.0 - * @returns {void} - */ - initHuePicker: function() { - var control = this, - huePicker = control.container.find( '.color-hue' ); - - huePicker.attr( 'value', this.hue ); - huePicker.wpColorPicker({ - change: function() { - - // Small hack: the picker needs a small delay - setTimeout( function() { - - // Set the hue. - control.hue = parseInt( huePicker.val(), 10 ); - - // Update colors. - // This gets triggered with a small delay so there's no reason to run the debounced version. - control.updateColors( true ); - }, 20 ); - } - }); - }, - - /** - * Set the hue in the control object as an integer. - * If no hue is defined it gets the saved value - * - * @param {int} hue - */ - setHue: function() { - var color = this.setting.get(); - this.hue = ( color ) ? wcagColors.getColorProperties( color ).h : 210; - }, - - /** - * Gets accessible colors accoring to their rating. - * - * @param {string} rating - Can be AAA, AA or A. - * @returns {Array} - */ - queryColors: function( rating ) { - var backgroundMinContrast, - surroundingTextMinContrast, - backgroundColor = wp.customize( this.params.choices.backgroundColor ).get(), - backgroundColorProps = wcagColors.getColorProperties( backgroundColor ); - - switch ( rating ) { - case 'AAA': - backgroundMinContrast = 7; - surroundingTextMinContrast = 3; - break; - case 'AA': - backgroundMinContrast = 4.5; - surroundingTextMinContrast = 2; - break; - case 'A': - backgroundMinContrast = 3; - surroundingTextMinContrast = 1; - break; - } - - if ( ! this.allColors ) { - this.allColors = wcagColors.getAll({ - hue: this.hue, - minHueDiff: 0, - maxHueDiff: 3, - stepDiff: 3, - stepSaturation: 0.025, - stepLightness: 0.025, - minLightness: 0.5 < backgroundColorProps.l ? 0 : 0.5, - maxLightness: 0.5 < backgroundColorProps.l ? 0.5 : 1 - }); - } - - return this.allColors.pluck({ // We want our color to have a minimum contrast of 7:1 with a white background. - color: backgroundColor, - minContrast: backgroundMinContrast - }).pluck({ // We want our color to have a minimum contrast of 3:1 with surrounding black text. - color: wp.customize( this.params.choices.textColor ).get(), - minContrast: surroundingTextMinContrast - }) - .sortBy( 's' ) // Sort colors by contrast. - .getHexArray(); - }, - - /** - * Updates the control.allColors and control.colors attributes. - * - * @since 1.0 - * @param {bool} updateValue - Whether we should update the selection or not. - * @returns {void} - */ - updateColors: function( updateValue ) { - var i; - this.allColors = false; - this.colors = { - AAA: this.queryColors( 'AAA' ), - AA: this.queryColors( 'AA' ), - A: this.queryColors( 'A' ) - }; - - // Remove duplicates from AA list. - for ( i = 0; i < this.colors.AAA.length; i++ ) { - this.colors.AA.splice( this.colors.AA.indexOf( this.colors.AAA[ i ] ), 1 ); - } - this.updateHTMLDebounced( updateValue ); - }, - - /** - * Updates the HTML in the control. - * - * @since 1.0 - * @param {bool} updateValue - Whether we should update the selection or not. - * @returns {void} - */ - updateControlHTML: function( updateValue ) { - var control = this, - html; - - // AAA colors. - if ( control.colors.AAA[0] ) { - control.container.find( '.rating-container-AAA' ).removeClass( 'hidden' ); - html = ''; - _.each( control.colors.AAA, function( color ) { - html += control.getChoiceMarkup( color ); - }); - control.container.find( '.rating-container-AAA .colors-container' ).html( html ); - } else { - control.container.find( '.rating-container-AAA' ).addClass( 'hidden' ); - } - - // AA colors. - if ( control.colors.AA[0] ) { - control.container.find( '.rating-container-AA' ).removeClass( 'hidden' ); - html = ''; - _.each( control.colors.AA, function( color ) { - html += control.getChoiceMarkup( color ); - }); - control.container.find( '.rating-container-AA .colors-container' ).html( html ); - } else { - control.container.find( '.rating-container-AA' ).addClass( 'hidden' ); - } - - // A colors. - if ( ! control.colors.AAA[0] && 20 > control.colors.AA.length && control.colors.A[0] ) { - control.container.find( '.rating-container-A' ).removeClass( 'hidden' ); - html = ''; - _.each( control.colors.A, function( color ) { - html += control.getChoiceMarkup( color ); - }); - control.container.find( '.rating-container-A .colors-container' ).html( html ); - } else { - control.container.find( '.rating-container-A' ).addClass( 'hidden' ); - } - - if ( updateValue ) { - - // Auto-update the selected color. - setTimeout( function() { - if ( control.getBest() ) { - control.container.find( 'input[value=' + control.getBest() + ']' ).attr( 'checked', true ).trigger( 'change' ); - } - }); - } - - // Update the indicated color & rating. - this.updateSelectedColorIndicators(); - - // Regenerate listeners. - this.radioInputListeners(); - }, - - /** - * Gets the HTMl for a single color option. Used by the updateControlHTML() function. - * - * @param {string} color - * @returns {string} - */ - getChoiceMarkup: function( color ) { - var control = this, - html = ''; - - html += ''; - return html; - }, - - /** - * Watch defined controls and re-trigger results calculations when there's a change. - * - * @since 1.0 - * @param {string} settingToWatch - The setting we're watching. This can either be the background or the text color. - * @returns {void} - */ - watchSetting: function( settingToWatch ) { - var control = this; - - wp.customize( settingToWatch, function( setting ) { - setting.bind( function() { - control.updateColors( true ); - }); - }); - - if ( -1 < settingToWatch.indexOf( '[' ) ) { - wp.customize( settingToWatch.split( '[' )[0], function( setting ) { - setting.bind( function() { - control.updateColors( true ); - }); - }); - } - }, - - /** - * Get the best available color for a11y. - * - * @since 1.0 - * @returns {string} - */ - getBest: function() { - if ( this.colors.AAA[0] ) { - return this.colors.AAA[0]; - } - if ( this.colors.AA[0] ) { - return this.colors.AA[0]; - } - if ( this.colors.A[0] ) { - return this.colors.A[0]; - } - }, - - /** - * Updates the indicators for selected color. - * - * @since 1.0 - * @returns {void} - */ - updateSelectedColorIndicators: function() { - var value = this.setting.get(), - rating = ''; - this.container.find( '.indicator .current-color' ).html( value ); - - if ( -1 !== this.colors.AAA.indexOf( value ) ) { - rating = ' - (AAA)'; - } else if ( -1 !== this.colors.AA.indexOf( value ) ) { - rating = ' - (AA)'; - } - - if ( ! rating ) { - this.container.find( '.indicator .current-color' ).html( '' + value + '' ); - } - - this.container.find( '.indicator .current-rating' ).html( rating ); - }, - - /** - * Destroy listeners for radios and add them anew. - * - * @since 1.0 - * @returns void - */ - radioInputListeners: function() { - var control = this; - - this.container.find( 'input[type="radio"]' ).off().on( 'click change keyup', function() { - var value = jQuery( this ).val(); - control.setting.set( value ); - control.container.find( '.hidden-value-hex' ).attr( 'value', value ).trigger( 'change' ); - control.isAuto = true; - control.updateSelectedColorIndicators(); - }); - }, - - /** - * Embed the control. - * - * Overrides the embed() method to do nothing, - * so that the control isn't embedded on load, - * unless the containing section is already expanded. - * - * @since 1.1.0 - * @returns {void} - */ - embed: function() { - var control = this, - sectionId = control.section(); - - if ( ! sectionId ) { - return; - } - wp.customize.section( sectionId, function( section ) { - section.expanded.bind( function( expanded ) { - if ( expanded ) { - control.actuallyEmbed(); - } - } ); - } ); - }, - - /** - * Deferred embedding of control. - * - * This function is called in Section.onChangeExpanded() so the control - * will only get embedded when the Section is first expanded. - * - * @since 1.1.0 - * @return {void} - */ - actuallyEmbed: function() { - if ( 'resolved' === this.deferred.embedded.state() ) { - return; - } - this.renderContent(); - this.deferred.embedded.resolve(); - } -}); diff --git a/inc/customizer/controls/kirki-wcag-lc/styles.css b/inc/customizer/controls/kirki-wcag-lc/styles.css deleted file mode 100644 index 5d6070b..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/styles.css +++ /dev/null @@ -1,81 +0,0 @@ -.customize-control-kirki-wcag-lc .rating-container { - clear: both; - display: block; } -.customize-control-kirki-wcag-lc .colors-container { - overflow-y: scroll; - padding: 12px; - margin-left: -12px; - margin-right: -12px; } -.customize-control-kirki-wcag-lc .kirki-input-container { - background: #fff; } -.customize-control-kirki-wcag-lc .color-hue-container, -.customize-control-kirki-wcag-lc .color-hex-container { - padding: 12px; } -.customize-control-kirki-wcag-lc .expand-selectors { - padding: 12px; - display: -webkit-box; - display: -ms-flexbox; - display: flex; - -webkit-box-pack: justify; - -ms-flex-pack: justify; - justify-content: space-between; } -.customize-control-kirki-wcag-lc .iris-picker.iris-only-strip { - width: 100% !important; } -.customize-control-kirki-wcag-lc .rating-containers-wrapper.hidden { - display: none; } -.customize-control-kirki-wcag-lc .rating-container { - padding: 12px; } - .customize-control-kirki-wcag-lc .rating-container label { - padding: 0; - float: left; - margin: 0; - line-height: 0; - position: relative; } - .customize-control-kirki-wcag-lc .rating-container label .a11y-text-selector-label { - border: 1px solid rgba(255, 255, 255, .1); - -webkit-box-sizing: border-box; - box-sizing: border-box; - width: 100%; - height: 100%; - display: block; } - .customize-control-kirki-wcag-lc .rating-container input[type="radio"] { - display: none; } - .customize-control-kirki-wcag-lc .rating-container input[type="radio"]:checked { - display: block; } - .customize-control-kirki-wcag-lc .rating-container input[type="radio"]:checked + .a11y-text-selector-label { - overflow: visible; - width: 150%; - height: 150%; - position: absolute; - z-index: 2; - left: -25%; - top: -25%; - -webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, .16), 0 3px 6px rgba(0, 0, 0, .23); - box-shadow: 0 3px 6px rgba(0, 0, 0, .16), 0 3px 6px rgba(0, 0, 0, .23); - outline: 1px solid #fff; } - .customize-control-kirki-wcag-lc .rating-container-AAA label { - width: 10%; - height: 30px; } - .customize-control-kirki-wcag-lc .rating-container-AA .colors-container { - max-height: 120px; } - .customize-control-kirki-wcag-lc .rating-container-AA label { - width: 7%; - height: 20px; } - .customize-control-kirki-wcag-lc .rating-container-A .colors-container { - max-height: 90px; } - .customize-control-kirki-wcag-lc .rating-container-A label { - width: 5%; - height: 16px; } - .customize-control-kirki-wcag-lc .rating-container.hidden { - display: none; } -.customize-control-kirki-wcag-lc .tab-headers .button { - background: #fff; - border-radius: 0; - -webkit-box-shadow: none; - box-shadow: none; - border: 1px solid #ccc; - margin-bottom: -1px; } - .customize-control-kirki-wcag-lc .tab-headers .button.active { - border-bottom: none; } -.customize-control-kirki-wcag-lc .tabs { - border: 1px solid #ccc; } diff --git a/inc/customizer/controls/kirki-wcag-lc/styles.scss b/inc/customizer/controls/kirki-wcag-lc/styles.scss deleted file mode 100644 index c32316e..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/styles.scss +++ /dev/null @@ -1,129 +0,0 @@ -.customize-control-kirki-wcag-lc { - .rating-container { - clear: both; - display: block; - } - - .colors-container { - overflow-y: scroll; - padding: 12px; - margin-left: -12px; - margin-right: -12px; - } - - .kirki-input-container { - background: #fff; - } - - .color-hue-container, - .color-hex-container { - padding: 12px; - } - - .expand-selectors { - padding: 12px; - display: flex; - justify-content: space-between; - } - - .iris-picker.iris-only-strip { - width: 100% !important; - } - - .rating-containers-wrapper { - &.hidden { - display: none; - } - } - - .rating-container { - padding: 12px; - - label { - padding: 0; - float: left; - margin: 0; - line-height: 0; - position: relative; - - .a11y-text-selector-label { - border: 1px solid rgba(255, 255, 255, .1); - box-sizing: border-box; - width: 100%; - height: 100%; - display: block; - } - } - - input[type="radio"] { - display: none; - - &:checked { - display: block; - - +.a11y-text-selector-label { - overflow: visible; - width: 150%; - height: 150%; - position: absolute; - z-index: 2; - left: -25%; - top: -25%; - box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); - outline: 1px solid #fff; - } - } - } - - &-AAA { - label { - width: 10%; - height: 30px; - } - } - - &-AA { - .colors-container { - max-height: 120px; - } - - label { - width: 7%; - height: 20px; - } - } - - &-A { - .colors-container { - max-height: 90px; - } - - label { - width: 5%; - height: 16px; - } - } - - &.hidden { - display: none; - } - } - - .tab-headers { - .button { - background: #fff; - border-radius: 0; - box-shadow: none; - border: 1px solid #ccc; - margin-bottom: -1px; - - &.active { - border-bottom: none; - } - } - } - - .tabs { - border: 1px solid #ccc; - } -} diff --git a/inc/customizer/controls/kirki-wcag-lc/wcagColors.js b/inc/customizer/controls/kirki-wcag-lc/wcagColors.js deleted file mode 100644 index 9f0e33b..0000000 --- a/inc/customizer/controls/kirki-wcag-lc/wcagColors.js +++ /dev/null @@ -1,466 +0,0 @@ -/** - * This script can get a list of colors that match some given criteria. - * It was created to handle getting readable colors. - * - * For more information read the docs on https://aristath.github.io/wcagColors/ - * - * @author Ari Stathopoulos - * @author wplemon - */ -/* jshint -W104 */ -var wcagColors = wcagColors || {}; -wcagColors = { - colors: [], - - /** - * Get all relative colors. - * - * @param {Object} params - The parameters for the colors. - * @param {string} params.color - A color formatted as RGB, HSL or HEX. - * @param {int} params.hue - If a color is not provided, we can alternatively provide a hue. - * @param {float} params.minSaturation - The minimum saturation the returned colors can have (0-1). - * @param {float} params.maxSaturation - The maximum saturation the returned colors can have (0-1). - * @param {float} params.stepSaturation - The increments in saturation while searching for colors (0-1). - * @param {float} params.stepLightness - Each lightness step. Smaller numbers are more detailed but slower. - * @param {int} params.minHueDiff - The minimum hue difference (0-359). - * @param {int} params.maxHueDiff - The maximum hue difference (0-359). - * @param {int} params.stepHue - How many degrees to turn the colorwheel on each iteration. - * @returns {Object} - this - */ - getAll: function( params ) { - var allColors = [], - hueOffset, - hueUp, - hueDown, - newColors, - i; - - // If we got a string color and not a hue make sure we get the hue. - if ( ! params.hue && params.color ) { - params.hue = this.getColorProperties( params.color ).h; - } - - params.minSaturation = params.minSaturation || 0; - params.maxSaturation = params.maxSaturation || 1; - params.stepSaturation = params.stepSaturation || 0.1; - params.stepLightness = params.stepLightness || 0.1; - params.minHueDiff = params.minHueDiff || 0; - params.maxHueDiff = params.maxHueDiff || 360; - params.stepHue = params.stepHue || 15; - params.minLightness = params.minLightness || 0; - params.maxLightness = params.maxLightness || 1.001; - - if ( 0 === params.maxHueDiff ) { - return this.getAllColorsForHue( params.hue, params ); - } - - for ( hueOffset = params.minHueDiff; hueOffset <= params.maxHueDiff; hueOffset += params.stepHue ) { - - // Calculate Hue Up. - hueUp = ( 359 < params.hue + hueOffset ) ? params.hue + hueOffset - 359 : params.hue + hueOffset; - - // Calculate Hue Down. - hueDown = ( 0 > params.hue + hueOffset ) ? params.hue + hueOffset + 360 : params.hue + hueOffset; - - // Add colors from the UP hue. - newColors = this.getAllColorsForHue( hueUp, params ); - for ( i = 0; i < newColors.length; i++ ) { - if ( -1 === allColors.indexOf( newColors[ i ] ) ) { - allColors.push( newColors[ i ] ); - } - } - - // Add colors from the DOWN hue. - newColors = this.getAllColorsForHue( hueDown, params ); - for ( i = 0; i < newColors.length; i++ ) { - if ( -1 === allColors.indexOf( newColors[ i ] ) ) { - allColors.push( newColors[ i ] ); - } - } - } - - return Object.assign({}, this, { - colors: this.removeDuplicateColors( allColors ) - }); - }, - - /** - * Get an array of colors that fulfil the provided criteria. - * - * @param {Object} criteria- The provided criteria. - * @param {string|Object} criteria.color - The color we want to check against. - * @param {int} criteria.minHueDiff - Minimum hue difference required. - * @param {int} criteria.maxHueDiff - Maximum hue difference required. - * @param {int} criteria.minContrast - The minimum contrast required to pass. - * @returns {Object} - this - */ - pluck: function( criteria ) { - var validColors = [], - pass, - i; - - if ( 'string' === typeof criteria.color ) { - criteria.color = this.getColorProperties( criteria.color ); - } else if ( criteria.color.r && criteria.color.g && criteria.color.b ) { - criteria.color = this.getColorProperties( 'rgb(' + criteria.color.r + ',' + criteria.color.g + ',' + criteria.color.b + ')' ); - } else if ( criteria.color.h && criteria.color.s && criteria.color.l ) { - criteria.color = this.getColorProperties( 'hsl(' + criteria.color.h + ',' + criteria.color.s + ',' + criteria.color.l + ')' ); - } - - for ( i = 0; i < this.colors.length; i++ ) { - pass = true; - - // Minimum hue-diff check. - if ( 'undefined' !== typeof criteria.minHueDiff && criteria.minHueDiff > Math.abs( this.colors[ i ].hue - criteria.color.hue ) ) { - pass = false; - } - - // Maximum hue-diff check. - if ( 'undefined' !== typeof criteria.maxHueDiff && criteria.maxHueDiff < Math.abs( this.colors[ i ].hue - criteria.color.hue ) ) { - pass = false; - } - - // Minimum contrast check. - if ( 'undefined' !== typeof criteria.minContrast ) { - this.colors[ i ].contrast = this.getContrast( criteria.color.lum, this.colors[ i ].lum ); - if ( criteria.minContrast > this.colors[ i ].contrast ) { - pass = false; - } - } - - // If we passed the tests add to array. - if ( pass ) { - validColors.push( this.colors[ i ] ); - } - } - - return Object.assign({}, this, { - colors: validColors - }); - }, - - /** - * Query a string color and get its properties. - * - * @param {string} color - The color we want to query. Can be formatted as hex, rgb, rgba, hsl, hsla. - * @returns {Object} - {r,g,b,h,s,l,hex,lum}. - */ - getColorProperties: function( color ) { - var hex, rgb, hsl, col; - - if ( -1 !== color.indexOf( 'hsl' ) ) { - col = color.replace( 'hsla', '' ).replace( '.hsl', '' ).replace( '(', '' ).replace( ')', '' ).split( ',' ); - hsl = { - h: parseInt( col[0], 10 ), - s: parseInt( col[1], 10 ) / 100, - l: parseInt( col[2], 10 ) / 100 - }; - rgb = this.hslToRgb( hsl.h, hsl.s, hsl.l ); - hex = this.rgbToHex( rgb.r, rgb.g, rgb.b ); - } else if ( -1 !== color.indexOf( 'rgb' ) ) { - col = color.replace( 'rgba', '' ).replace( '.rgb', '' ).replace( '(', '' ).replace( ')', '' ).split( ',' ); - rgb = { - r: col[0], - g: col[1], - b: col[2] - }; - hsl = this.rgbToHsl( rgb.r, rgb.g, rgb.b ); - hex = this.rgbToHex( rgb.r, rgb.g, rgb.b ); - } else { - hex = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test( color ) ? color : '#ffffff'; - rgb = this.hexToRgb( hex ); - hsl = this.rgbToHsl( rgb.r, rgb.g, rgb.b ); - } - return { - r: rgb.r, - g: rgb.g, - b: rgb.b, - h: hsl.h, - s: hsl.s, - l: hsl.l, - hex: hex, - lum: this.getRelativeLuminance( rgb ) - }; - }, - - /** - * Get all colors for a given hue. - * - * @param {int} hue - The hue of the color. - * @param {Object} args - Additional arguments. - * @param {float} args.minSaturation - The minimum saturation the returned colors can have (0-1). - * @param {float} args.maxSaturation - The maximum saturation the returned colors can have (0-1). - * @param {float} args.stepSaturation - The increments in saturation while searching for colors (0-1). - * @param {float} args.stepLightness - Each lightness step. - * smaller numbers are more detailed, - * larger numbers have bigger "steps" between colors. - * @returns {Array} - */ - getAllColorsForHue: function( hue, args ) { - var colors = [], - saturation, - lightness, - color; - - for ( saturation = args.minSaturation; args.maxSaturation >= saturation; saturation += args.stepSaturation ) { - for ( lightness = args.minLightness; args.maxLightness >= lightness; lightness += args.stepLightness ) { - if ( 0 <= hue && 359 >= hue ) { - color = this.hslToRgb( hue, saturation, lightness ); - colors.push({ - r: color.r, - g: color.g, - b: color.b, - h: hue, - s: saturation, - l: lightness, - hex: this.rgbToHex( color.r, color.g, color.b ), - lum: this.getRelativeLuminance( color ) - }); - } - } - } - return colors; - }, - - /** - * Converts an RGB object to a HEX string.\ - * - * @param {int} r - Red. - * @param {int} g - Green. - * @param {int} b - Blue. - * @returns {string} - */ - rgbToHex: function( r, g, b ) { - return '#' + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ).toString( 16 ).slice( 1 ); - }, - - /** - * Convert hex color to RGB. - * See https://stackoverflow.com/a/5624139 - * - * @since 1.0 - * @param {string} hex - The hex color. - * @returns {Object} - */ - hexToRgb: function( hex ) { - var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, - result; - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF"). - hex = hex.replace( shorthandRegex, function( m, r, g, b ) { - return r + r + g + g + b + b; - }); - - result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex ); - return result ? { - r: parseInt( result[1], 16 ), - g: parseInt( result[2], 16 ), - b: parseInt( result[3], 16 ) - } : null; - }, - - /** - * Converts an HSL color value to RGB. Conversion formula - * adapted from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes h, s, and l are contained in the set [0, 1] and - * returns r, g, and b in the set [0, 255]. - * - * @param {int} h - Hue - * @param {float} s - Saturation - * @param {float} l - Lightness - * @return {Array} - RGB representation - */ - hslToRgb: function( h, s, l ) { - var c, h_, x, r1, g1, b1, m; - - // Calculate chroma. - c = ( 1 - Math.abs( ( 2 * l ) - 1 ) ) * s; - - // Find a point (r1, g1, b1) along the bottom three faces of the RGB cube, - // with the same hue and chroma as our color - // using the intermediate value X for the second largest component of this color. - h_ = h / 60; - x = c * ( 1 - Math.abs( ( h_ % 2 ) - 1 ) ); - - if ( 'undefined' === typeof h || isNaN( h ) || null === h ) { - r1 = g1 = b1 = 0; - } else { - if ( 0 <= h_ && 1 > h_ ) { - r1 = c; - g1 = x; - b1 = 0; - } else if ( 1 <= h_ && 2 > h_ ) { - r1 = x; - g1 = c; - b1 = 0; - } else if ( 2 <= h_ && 3 > h_ ) { - r1 = 0; - g1 = c; - b1 = x; - } else if ( 3 <= h_ && 4 > h_ ) { - r1 = 0; - g1 = x; - b1 = c; - } else if ( 4 <= h_ && 5 > h_ ) { - r1 = x; - g1 = 0; - b1 = c; - } else if ( 5 <= h_ && 6 > h_ ) { - r1 = c; - g1 = 0; - b1 = x; - } - } - - // Find r, g, and b by adding the same amount to each component to match lightness. - m = l - ( c / 2 ); - - // Normalise to range [0,255] by multiplying with 255. - return { - r: Math.round( ( r1 + m ) * 255 ), - g: Math.round( ( g1 + m ) * 255 ), - b: Math.round( ( b1 + m ) * 255 ) - }; - }, - - /** - * Converts an RGB color value to HSL. Conversion formula - * adapted from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes r, g, and b are contained in the set [0, 255] and - * returns h (0-359), s (0-1), and l (0-1) - * - * @param {int} r - The red color value - * @param {int} g - The green color value - * @param {int} b - The blue color value - * @return {Array} - The HSL representation - */ - rgbToHsl: function( r, g, b ) { - var max, min, h, s, l, d; - - r /= 255; - g /= 255; - b /= 255; - max = Math.max( r, g, b ); - min = Math.min( r, g, b ); - l = ( max + min ) / 2; - - if ( max === min ) { // Achromatic. - return { - h: 0, - s: 0, - l: l - }; - } - d = max - min; - s = 0.5 < l ? d / ( 2 - max - min ) : d / ( max + min ); - switch ( max ) { - case r: h = ( g - b ) / d + ( g < b ? 6 : 0 ); break; - case g: h = ( b - r ) / d + 2; break; - case b: h = ( r - g ) / d + 4; break; - } - h /= 6; - - return { - h: h * 360, - s: s, - l: l - }; - }, - - /** - * Get contrast between 2 luminosities. - * - * @since 1.0 - * @param {float} lum1 - 1st Luminosity. - * @param {float} lum2 - 2nd Luminosity. - * @returns {float} - */ - getContrast: function( lum1, lum2 ) { - return this.roundFloat( Math.max( ( lum1 + 0.05 ) / ( lum2 + 0.05 ), ( lum2 + 0.05 ) / ( lum1 + 0.05 ) ) ); - }, - - /** - * Gets the relative luminance from RGB. - * Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef - * - * @since 1.0 - * @param {Object} color - an RGB color {r,g,b}. - * @returns {float} - */ - getRelativeLuminance: function( color ) { - return this.roundFloat( 0.2126 * this.getLumPart( color.r ) + 0.7152 * this.getLumPart( color.g ) + 0.0722 * this.getLumPart( color.b ) ); - }, - - /** - * Get luminocity for a part. - * - * @since 1.0 - * @param {int|float} val - The value. - * @returns {float} - */ - getLumPart: function( val ) { - val = val / 255; - if ( 0.03928 >= val ) { - return val / 12.92; - } - return Math.pow( ( ( val + 0.055 ) / 1.055 ), 2.4 ); - }, - - /** - * Round a float. - * See https://stackoverflow.com/a/5624139 - * - * @since 1.0 - * @param {float} number - The number we want to round. - * @returns {float} - */ - roundFloat: function( number ) { - return Math.round( number * 100 ) / 100; - }, - - /** - * Returns {this} with the colors array sorted. - * - * @param {string} sortBy - What do we want to sort by? - * Acceptable values: r,g,b,h,s,l,lum,hex,contrast - * @returns {Object} - */ - sortBy: function( sortBy ) { - return Object.assign({}, this, { - colors: this.colors.sort( function( a, b ) { - return b[ sortBy ] - a[ sortBy ]; - }) - }); - }, - - /** - * Removes duplicate entries from colors. - * - * @param {Array} colors - An array of colors. - * @return {Object} - */ - removeDuplicateColors: function( colors ) { - var uniques = {}, - i; - for ( i = 0; i < colors.length; i++ ) { - uniques[ colors[ i ].hex ] = colors[ i ]; - } - return Object.keys( uniques ).map( function( v ) { - return uniques[ v ]; - }); - }, - - /** - * Returns an array of Hex colors. - * - * @returns {Array} - */ - getHexArray: function() { - var hexes = [], - i; - for ( i = 0; i < this.colors.length; i++ ) { - hexes.push( this.colors[ i ].hex ); - } - return hexes; - } -}; diff --git a/inc/customizer/controls/kirki-wcag-tc/class-kirki-wcag-text-color.php b/inc/customizer/controls/kirki-wcag-tc/class-kirki-wcag-text-color.php deleted file mode 100644 index c917fcf..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/class-kirki-wcag-text-color.php +++ /dev/null @@ -1,243 +0,0 @@ -json['default'] = $this->setting->default; - if ( isset( $this->default ) ) { - $this->json['default'] = $this->default; - } - - // Required. - $this->json['required'] = $this->required; - - // Output. - $this->json['output'] = $this->output; - - // Value. - $this->json['value'] = $this->value(); - - // Choices. - $this->json['choices'] = (array) $this->choices; - - if ( ! isset( $this->json['choices']['show'] ) ) { - $this->json['choices']['show'] = [ - 'auto' => true, - 'recommended' => true, - 'custom' => true, - ]; - } - - // The link. - $this->json['link'] = $this->get_link(); - - // The ID. - $this->json['id'] = $this->id; - - // The kirki-config. - $this->json['kirkiConfig'] = $this->kirki_config; - - // The option-type. - $this->json['kirkiOptionType'] = $this->option_type; - - // The option-name. - $this->json['kirkiOptionName'] = $this->option_name; - - // The CSS-Variables. - $this->json['css-var'] = $this->css_vars; - } - - /** - * An Underscore (JS) template for this control's content (but not its container). - * - * Class variables for this control class are available in the `data` JS object; - * export custom variables by overriding {@see WP_Customize_Control::to_json()}. - * - * @see WP_Customize_Control::print_template() - * - * @access protected - */ - protected function content_template() { - ?> - <# if ( data.label ) { #> - - <# } #> - <# if ( data.description ) { #> - {{{ data.description }}} - <# } #> - - <# var modes = ( data.choices && data.choices.modes ) ? data.choices.modes : [ 'auto', 'recommended', 'custom' ]; #> - - <# if ( 2 <= modes.length ) { #> -
- <# _.each( modes, function( mode ) { #> - <# if ( 'auto' === mode ) { #> - - <# } else if ( 'recommended' === mode ) { #> - - <# } else { #> - - <# } #> - <# } ); #> -
- <# } #> -
- <# if ( -1 !== _.indexOf( modes, 'auto' ) ) { #> -
- ' - ); - ?> -
- <# } #> - <# if ( -1 !== _.indexOf( modes, 'recommended' ) ) { #> -
- {{ data.value }}' - ); - ?> -
-
- <# } #> - <# if ( -1 !== _.indexOf( modes, 'custom' ) ) { #> -
- -
- <# } #> -
- register_control_type( 'Kirki_WCAG_Text_Color' ); - } -} -add_action( 'customize_register', 'kirki_wcag_text_color_register_control_type' ); diff --git a/inc/customizer/controls/kirki-wcag-tc/readme.txt b/inc/customizer/controls/kirki-wcag-tc/readme.txt deleted file mode 100644 index a57328e..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/readme.txt +++ /dev/null @@ -1,17 +0,0 @@ -=== Kirki Accessible-Text Colorpicker === -Contributors: aristath, wplemon -Tags: customizer, kirki -Requires at least: 4.9 -Tested up to: 5.0 -Stable tag: 1.0 - - -== Description == - -description for this product can be found on https://wplemon.com/downloads/kirki-accessible-text-colorpicker/ - -== Changelog == - -= 1.0 = - -* Initial release diff --git a/inc/customizer/controls/kirki-wcag-tc/script.js b/inc/customizer/controls/kirki-wcag-tc/script.js deleted file mode 100644 index 493ea23..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/script.js +++ /dev/null @@ -1,495 +0,0 @@ -/* global wcagColors */ -wp.customize.controlConstructor['kirki-wcag-tc'] = wp.customize.Control.extend({ - - /** - * The current mode of operation. - * - * @since 1.0 - */ - a11ySelectorMode: false, - - /** - * An array of accessible colors. - * - * @since 1.0 - */ - colors: [], - - /** - * The maximum hue difference. - * - * @since 1.0 - */ - maxHueDiff: 30, - - /** - * The steps for hue. Integer. - * Smaller values make for a more detailed search. - * - * @since 1.0 - */ - stepHue: 15, - - /** - * The maximum Saturation for accessible colors. - * - * @since 1.0 - */ - maxSaturation: 0.3, - - /** - * The steps for saturation. Float value, 0 to 1. - * Smaller values make for a more detailed search. - * - * @since 1.0 - */ - stepSaturation: 0.2, - - /** - * The steps for lightness. Float value, 0 to 1. - * Smaller values make for a more detailed search. - * - * @since 1.0 - */ - stepLightness: 0.1, - - /** - * The contrast threshold. - * - * @since 1.0 - */ - contrastThreshold: 4.5, - - /** - * Triggered when the control is ready. - * - * @since 1.0 - * @returns {void} - */ - ready: function() { - var control = this; - - // Set the background color. - this.setBackgroundColorDetails(); - - // Get new array of accessible colors. - // this.setControlColors(); - - // Set control params if defined in the choices argument. - if ( 'undefined' !== typeof control.params.choices.maxHueDiff ) { - this.maxHueDiff = control.params.choices.maxHueDiff; - } - if ( 'undefined' !== typeof control.params.choices.stepHue ) { - this.stepHue = control.params.choices.stepHue; - } - if ( 'undefined' !== typeof control.params.choices.maxSaturation ) { - this.maxSaturation = control.params.choices.maxSaturation; - } - if ( 'undefined' !== typeof control.params.choices.stepSaturation ) { - this.stepSaturation = control.params.choices.stepSaturation; - } - if ( 'undefined' !== typeof control.params.choices.stepLightness ) { - this.stepLightness = control.params.choices.stepLightness; - } - if ( 'undefined' !== typeof control.params.choices.contrastThreshold ) { - this.contrastThreshold = control.params.choices.contrastThreshold; - } - - this.updateColorsDebounced = _.debounce( _.bind( this.updateColors, this ), 100 ); - this.watchSettingsDebounced = _.debounce( _.bind( this.watchSettings, this ), 100 ); - - this.visibility(); - - setTimeout( function() { - - // Init tabs. - control.initTabs(); - }, 300 ); - - // Init the colorpicker. - this.initColorpicker(); - - // Generate the control. - this.updateColorsDebounced(); - - // Watch for changes. - this.watchSettingsDebounced(); - }, - - /** - * Hides ts of the control if so defined. - * - * @since 1.1 - * @returns void - */ - visibility: function() { - var show = this.params.choices.show || {}; - - if ( 'undefined' === typeof show.auto ) { - show.auto = true; - } - if ( 'undefined' === typeof show.recommended ) { - show.recommended = true; - } - if ( 'undefined' === typeof show.custom ) { - show.custom = true; - } - if ( ! show.auto && ! show.recommended && ! show.custom ) { - this.container.hide(); - this.a11ySelectorMode = 'auto'; - } else { - if ( ! show.auto ) { - this.container.find( '.kirki-a11y-text-colorpicker-toggle-auto' ).addClass( 'hidden' ); - this.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id=auto]' ).addClass( 'hidden' ); - } - if ( ! show.recommended ) { - this.container.find( '.kirki-a11y-text-colorpicker-toggle-recommended' ).addClass( 'hidden' ); - this.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id=recommended]' ).addClass( 'hidden' ); - this.updateControlHTML = function() {}; - } - if ( ! show.custom ) { - this.container.find( '.kirki-a11y-text-colorpicker-toggle-custom' ).addClass( 'hidden' ); - this.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id=custom]' ).addClass( 'hidden' ); - this.initColorpicker = function() {}; - } - } - }, - - /** - * Init the tabs for recommended/custom colors. - * - * @since 1.0 - * @param {bool} forceTab - Whether we want to force the tab switch or not. - * @returns {void} - */ - initTabs: function( forceTab ) { - var control = this, - show = this.params.choices.show || {}; - - // Remove previous even listeners. - jQuery( control.container.find( '.tabs button' ) ).off(); - - // Handle clicking buttons. - jQuery( control.container.find( '.tabs button' ) ).on( 'click', function( event ) { - control.a11ySelectorMode = jQuery( event.target ).attr( 'data-mode' ); - control.initTabs( true ); - event.preventDefault(); - if ( 'auto' === control.a11ySelectorMode ) { - jQuery( '.kirki-color-control[data-id="' + control.id + '"]' ).attr( 'value', control.getAutoColor() ).trigger( 'change' ); - } - }); - - if ( ! forceTab && ! control.a11ySelectorMode ) { - - if ( control.setting._value === control.getAutoColor() && false !== show.auto ) { - control.a11ySelectorMode = 'auto'; - } else if ( control.isSelectedColorRecommended() && false !== show.recommended ) { - control.a11ySelectorMode = 'recommended'; - } else { - control.a11ySelectorMode = 'custom'; - } - control.initTabs(); - return; - } - - jQuery( control.container.find( '.tabs button' ) ).removeClass( 'active' ); - jQuery( control.container.find( '.tabs button[data-mode="' + control.a11ySelectorMode + '"]' ) ).addClass( 'active' ); - jQuery( control.container.find( '.mode-selectors' ) ).attr( 'data-value', control.a11ySelectorMode ); - jQuery( control.container.find( '.kirki-a11y-text-colorpicker-wrapper' ) ).hide(); - jQuery( control.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id="' + control.a11ySelectorMode + '"]' ) ).show(); - - if ( 'auto' === control.a11ySelectorMode ) { - jQuery( control.container.find( '.selected-color-previewer-auto' ) ) - .html( control.getAutoColor() ) - .css( 'background-color', this.getColor() ) - .css( 'color', control.getAutoColor() ); - } - }, - - /** - * Check if the selected color is one of the recommended colors or not. - * - * @since 1.0 - * @returns {bool} - */ - isSelectedColorRecommended: function() { - var isRecommended = false, - control = this; - - if ( this.colors ) { - if ( 'undefined' !== typeof this.colors[ this.setting._value ] ) { - isRecommended = true; - } - if ( ! isRecommended ) { - _.each( this.colors, function( color ) { - if ( ! isRecommended && color.hex && control.setting._value === color.hex ) { - isRecommended = true; - return true; - } - }); - } - } - - return isRecommended; - }, - - /** - * Init the colorpicker. - * - * @since 1.0 - * @returns {void} - */ - initColorpicker: function() { - var control = this, - picker = jQuery( control.container.find( '.kirki-color-control' ) ), - clear; - - // Tweaks to make the "clear" buttons work. - setTimeout( function() { - clear = jQuery( control.container.find( '.kirki-input-container[data-id="' + control.id + '"] .wp-picker-clear' ) ); - if ( clear.length ) { - clear.click( function() { - wp.customize.control( control.id ).setting.set( '' ); - }); - } - }, 200 ); - - // Saves our settings to the WP API - picker.wpColorPicker({ - change: function() { - - // Small hack: the picker needs a small delay - setTimeout( function() { - wp.customize.control( control.id ).setting.set( picker.val() ); - }, 20 ); - } - }); - }, - - /** - * The main init method. - * - * @since 1.0 - * @param {string} newColor - The new color. - * @returns {void} - */ - updateColors: function( newColor ) { - var show = this.params.choices.show || {}; - - if ( ! this.backgroundColorChanged( newColor ) ) { - return; - } - - // Update the colors in the object. - this.setBackgroundColorDetails(); - - // Handle auto mode. - if ( 'auto' === this.a11ySelectorMode ) { - - // Change the value in the colorpicker. - // Automatically sets the value in the customizer object - jQuery( '.kirki-color-control[data-id="' + this.id + '"]' ).attr( 'value', this.getAutoColor() ).trigger( 'change' ); - - // Display the value. - jQuery( this.container.find( '.selected-color-previewer-auto' ) ) - .html( this.getAutoColor() ) - .css( 'background-color', this.getColor() ) - .css( 'color', this.getAutoColor() ); - } else if ( show.recommended ) { - - // Get new array of accessible colors. - this.setControlColors(); - - // Update the HTML for the control. - this.updateControlHTML(); - } - }, - - /** - * Updates the HTML in the control. adding the colors we need. - * - * @since 1.0 - * @returns {void} - */ - updateControlHTML: function() { - var control = this, - colorsContainer = jQuery( control.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id="recommended"] .wrapper' ) ), - html = '', - borderColor; - - // Reset the HTML. - colorsContainer.html( '' ); - - // Add colors as radio-buttons. - _.each( control.colors, function( color ) { - borderColor = ( 0.5 < color.lum ) ? 'rgba(0,0,0,.15)' : 'rgba(255,255,255,.15)'; - html += ''; - }); - - colorsContainer.append( html ); - - // Watch for value changes and save if necessary. - control.saveColorValueWatcher(); - }, - - /** - * Watch defined controls and re-trigger results calculations when there's a change. - * - * @since 1.0 - * @returns {void} - */ - watchSettings: function() { - var control = this, - setting = this.params.choices.setting, - part = ( -1 < setting.indexOf( '[' ) ) ? setting.split( '[' )[1].replace( ']', '' ) : false; - - setting = ( part ) ? setting.split( '[' )[0] : setting; - - wp.customize( setting, function( watchSetting ) { - watchSetting.bind( function( to ) { - if ( 'string' === typeof to && -1 < to.indexOf( '{' ) && -1 < to.indexOf( '}' ) ) { - to = JSON.parse( to ); - } - to = ( part && to[ part ] ) ? to[ part ] : to; - if ( 'string' === typeof to ) { - control.updateColors( control.toHex( to ) ); - } - }); - }); - }, - - /** - * Sets items in the this.colors array. - * - * @since 1.0 - * @returns {void} - */ - setControlColors: function() { - this.colors = wcagColors.getAll({ - color: this.backgroundColor.hex, - maxHueDiff: this.backgroundColor.h ? this.maxHueDiff : 360, - stepHue: this.stepHue, - minSaturation: 0, - maxSaturation: this.maxSaturation, - stepSaturation: this.stepSaturation, - stepLightness: this.stepLightness - }).pluck({ - color: this.backgroundColor.hex, - minContrast: this.contrastThreshold - }).sortBy( 'contrast' ).colors; - }, - - /** - * Automatically gets the color with the most contrast. - * - * @since 1.0 - * @returns {string} - */ - getAutoColor: function() { - this.setBackgroundColorDetails(); - if ( wcagColors.getContrast( 0, this.backgroundColor.lum ) > wcagColors.getContrast( 1, this.backgroundColor.lum ) ) { - return '#000000'; - } - return '#ffffff'; - }, - - /** - * Set the object's colors property. - * - * @since 1.0 - * @returns {void} - */ - setBackgroundColorDetails: function() { - this.backgroundColor = wcagColors.getColorProperties( this.getColor() ); - }, - - /** - * Gets a color defined in the control's choices. - * - * @since 1.0 - * @returns {string} - */ - getColor: function() { - var setting = this.params.choices.setting, - part = ( -1 < setting.indexOf( '[' ) ) ? setting.split( '[' )[1].replace( ']', '' ) : false, - value; - - setting = ( part ) ? setting.split( '[' )[0] : setting; - value = wp.customize( setting ).get(); - - if ( 'string' === typeof to && -1 < value.indexOf( '{' ) && -1 < value.indexOf( '}' ) ) { - value = JSON.parse( value ); - } - - if ( part && value[ part ] ) { - value = value[ part ]; - } - - return this.toHex( value ); - }, - - /** - * Check if the background color has changed. - * - * @since 1.0 - * @param {string} newColor - The new color. - * @returns {bool} - */ - backgroundColorChanged: function( newColor ) { - var control = this, - colorChanged = false; - - if ( newColor !== control.backgroundColor.hex ) { - colorChanged = true; - if ( newColor ) { - control.backgroundColor = wcagColors.getColorProperties( newColor ); - } - } - return colorChanged; - }, - - toHex: function( color ) { - var rgb, r, g, b; - if ( -1 < color.indexOf( 'rgb' ) ) { - rgb = color.match( /^rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(,\s*(\d*)\.?(\d*)\s*)?\)$/ ); - if ( rgb ) { - r = ( '0' + parseInt( rgb[1], 10 ).toString( 16 ) ).slice( -2 ); - g = ( '0' + parseInt( rgb[2], 10 ).toString( 16 ) ).slice( -2 ); - b = ( '0' + parseInt( rgb[3], 10 ).toString( 16 ) ).slice( -2 ); - color = '#' + r + g + b; - } - } - return color; - }, - - /** - * Sets the value for this control. - * - * @returns {void} - */ - saveColorValueWatcher: function() { - var control = this; - - jQuery( control.container.find( '.kirki-a11y-text-colorpicker-wrapper[data-id="recommended"] input' ) ).on( 'change keyup paste click', function() { - - // Change the value in the colorpicker. - // Automatically sets the value in the customizer object - jQuery( '.kirki-color-control[data-id="' + control.id + '"]' ).attr( 'value', jQuery( this ).val() ).trigger( 'change' ); - - // Focus on this element. Enhases keyboard-navigation experience. - jQuery( this ).focus(); - }); - - // Update the indicator value. - this.setting.bind( 'change', function( to ) { - jQuery( control.container.find( '.selected-color' ) ).html( to ); - }); - } -}); diff --git a/inc/customizer/controls/kirki-wcag-tc/styles.css b/inc/customizer/controls/kirki-wcag-tc/styles.css deleted file mode 100644 index 2317c51..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/styles.css +++ /dev/null @@ -1,56 +0,0 @@ -.customize-control-kirki-wcag-tc .kirki-a11y-text-colorpicker-wrapper[data-id="recommended"] .wrapper { - min-height: 50px; - max-height: 250px; - overflow-y: scroll; - overflow-x: hidden; - padding: 12px; - margin-left: -10px; - margin-right: -10px; } -.customize-control-kirki-wcag-tc .kirki-a11y-text-colorpicker-wrapper[data-id="auto"] .selected-color-previewer-auto { - padding: 4px 10px; - border-radius: 3px; - border: 1px solid #dedede; } -.customize-control-kirki-wcag-tc .wrapper label { - height: 23px; - width: 10%; - display: inline-block; - position: relative; } -.customize-control-kirki-wcag-tc .a11y-text-selector-label { - display: block; - width: 100%; - height: 100%; - border: 1px solid transparent; } -.customize-control-kirki-wcag-tc input[type="radio"] { - display: none; } - .customize-control-kirki-wcag-tc input[type="radio"]:checked { - display: block; } - .customize-control-kirki-wcag-tc input[type="radio"]:checked + .a11y-text-selector-label { - overflow: visible; - width: 150%; - height: 150%; - position: absolute; - z-index: 2; - left: -25%; - top: -25%; - -webkit-box-shadow: 0 3px 6px rgba(0, 0, 0, .16), 0 3px 6px rgba(0, 0, 0, .23); - box-shadow: 0 3px 6px rgba(0, 0, 0, .16), 0 3px 6px rgba(0, 0, 0, .23); - outline: 1px solid #fff; } -.customize-control-kirki-wcag-tc .selected-color { - font-weight: 600; } -.customize-control-kirki-wcag-tc .tabs { - display: -webkit-box; - display: -ms-flexbox; - display: flex; } - .customize-control-kirki-wcag-tc .tabs .button { - width: 100%; - background: #fff; - -webkit-box-shadow: none; - box-shadow: none; - border-radius: 0; - margin-bottom: -1px; - border: 1px solid #ccc; } - .customize-control-kirki-wcag-tc .tabs .button.active { - background: #0085ba; - color: #fff; } -.customize-control-kirki-wcag-tc .mode-selectors { - padding-top: 12px; } diff --git a/inc/customizer/controls/kirki-wcag-tc/styles.scss b/inc/customizer/controls/kirki-wcag-tc/styles.scss deleted file mode 100644 index 5acb012..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/styles.scss +++ /dev/null @@ -1,89 +0,0 @@ -.customize-control-kirki-wcag-tc { - - .kirki-a11y-text-colorpicker-wrapper { - &[data-id="recommended"] { - .wrapper { - min-height: 50px; - max-height: 250px; - overflow-y: scroll; - overflow-x: hidden; - padding: 12px; - margin-left: -10px; - margin-right: -10px; - } - } - - &[data-id="auto"] { - .selected-color-previewer-auto { - padding: 4px 10px; - border-radius: 3px; - border: 1px solid #dedede; - } - } - } - - .wrapper { - label { - height: 23px; - width: 10%; - display: inline-block; - position: relative; - } - } - - .a11y-text-selector-label { - display: block; - width: 100%; - height: 100%; - border: 1px solid transparent; - } - - input[type="radio"] { - display: none; - - &:checked { - display: block; - - +.a11y-text-selector-label { - overflow: visible; - width: 150%; - height: 150%; - position: absolute; - z-index: 2; - left: -25%; - top: -25%; - box-shadow: 0 3px 6px rgba(0, 0, 0, 0.16), 0 3px 6px rgba(0, 0, 0, 0.23); - outline: 1px solid #fff; - } - } - } - - .selected-color { - font-weight: 600; - } - - .tabs { - display: flex; - - .button { - width: 100%; - background: #fff; - box-shadow: none; - border-radius: 0; - margin-bottom: -1px; - border: 1px solid #ccc; - - &.active { - background: #0085ba; - color: #fff; - } - } - } - - .mode-selectors { - padding-top: 12px; - // border: 1px solid #ccc; - // padding: 12px; - // background: #fff; - } -} diff --git a/inc/customizer/controls/kirki-wcag-tc/wcagColors.js b/inc/customizer/controls/kirki-wcag-tc/wcagColors.js deleted file mode 100644 index fd38ae3..0000000 --- a/inc/customizer/controls/kirki-wcag-tc/wcagColors.js +++ /dev/null @@ -1,465 +0,0 @@ -/** - * This script can get a list of colors that match some given criteria. - * It was created to handle getting readable colors. - * - * For more information read the docs on https://aristath.github.io/wcagColors/ - * - * @author Ari Stathopoulos - * @author wplemon - */ -/* jshint -W104 */ -var wcagColors = wcagColors || {}; -wcagColors = { - colors: [], - - /** - * Get all relative colors. - * - * @param {Object} params - The parameters for the colors. - * @param {string} params.color - A color formatted as RGB, HSL or HEX. - * @param {int} params.hue - If a color is not provided, we can alternatively provide a hue. - * @param {float} params.minSaturation - The minimum saturation the returned colors can have (0-1). - * @param {float} params.maxSaturation - The maximum saturation the returned colors can have (0-1). - * @param {float} params.stepSaturation - The increments in saturation while searching for colors (0-1). - * @param {float} params.stepLightness - Each lightness step. Smaller numbers are more detailed but slower. - * @param {int} params.minHueDiff - The minimum hue difference (0-359). - * @param {int} params.maxHueDiff - The maximum hue difference (0-359). - * @param {int} params.stepHue - How many degrees to turn the colorwheel on each iteration. - * @returns {Object} - this - */ - getAll( params ) { - var allColors = [], - hueOffset, - hueUp, - hueDown, - newColors, - i; - - // If we got a string color and not a hue make sure we get the hue. - if ( ! params.hue && params.color ) { - params.hue = this.getColorProperties( params.color ).h; - } - - params.minSaturation = params.minSaturation || 0; - params.maxSaturation = params.maxSaturation || 1; - params.stepSaturation = params.stepSaturation || 0.1; - params.stepLightness = params.stepLightness || 0.1; - params.minHueDiff = params.minHueDiff || 0; - params.maxHueDiff = params.maxHueDiff || 360; - params.stepHue = params.stepHue || 15; - - if ( 0 === params.maxHueDiff ) { - return this.getAllColorsForHue( params.hue, params ); - } - - for ( hueOffset = params.minHueDiff; hueOffset <= params.maxHueDiff; hueOffset += params.stepHue ) { - - // Calculate Hue Up. - hueUp = ( 359 < params.hue + hueOffset ) ? params.hue + hueOffset - 359 : params.hue + hueOffset; - - // Calculate Hue Down. - hueDown = ( 0 > params.hue + hueOffset ) ? params.hue + hueOffset + 360 : params.hue + hueOffset; - - // Add colors from the UP hue. - newColors = this.getAllColorsForHue( hueUp, params ); - for ( i = 0; i < newColors.length; i++ ) { - if ( -1 === allColors.indexOf( newColors[ i ] ) ) { - allColors.push( newColors[ i ] ); - } - } - - // Add colors from the DOWN hue. - newColors = this.getAllColorsForHue( hueDown, params ); - for ( i = 0; i < newColors.length; i++ ) { - if ( -1 === allColors.indexOf( newColors[ i ] ) ) { - allColors.push( newColors[ i ] ); - } - } - } - - return Object.assign({}, this, { - colors: this.removeDuplicateColors( allColors ) - }); - }, - - /** - * Get an array of colors that fulfil the provided criteria. - * - * @param {Object} criteria- The provided criteria. - * @param {string|Object} criteria.color - The color we want to check against. - * @param {int} criteria.minHueDiff - Minimum hue difference required. - * @param {int} criteria.maxHueDiff - Maximum hue difference required. - * @param {int} criteria.minContrast - The minimum contrast required to pass. - * @returns {Object} - this - */ - pluck( criteria ) { - var validColors = [], - pass, - i; - - if ( 'string' === typeof criteria.color ) { - criteria.color = this.getColorProperties( criteria.color ); - } else if ( criteria.color.r && criteria.color.g && criteria.color.b ) { - criteria.color = this.getColorProperties( 'rgb(' + criteria.color.r + ',' + criteria.color.g + ',' + criteria.color.b + ')' ); - } else if ( criteria.color.h && criteria.color.s && criteria.color.l ) { - criteria.color = this.getColorProperties( 'hsl(' + criteria.color.h + ',' + criteria.color.s + ',' + criteria.color.l + ')' ); - } - - for ( i = 0; i < this.colors.length; i++ ) { - pass = true; - - // Minimum hue-diff check. - if ( 'undefined' !== typeof criteria.minHueDiff && criteria.minHueDiff > Math.abs( this.colors[ i ].hue - criteria.color.hue ) ) { - pass = false; - } - - // Maximum hue-diff check. - if ( 'undefined' !== typeof criteria.maxHueDiff && criteria.maxHueDiff < Math.abs( this.colors[ i ].hue - criteria.color.hue ) ) { - pass = false; - } - - // Minimum contrast check. - if ( 'undefined' !== typeof criteria.minContrast ) { - this.colors[ i ].contrast = this.getContrast( criteria.color.lum, this.colors[ i ].lum ); - if ( criteria.minContrast > this.colors[ i ].contrast ) { - pass = false; - } - } - - // If we passed the tests add to array. - if ( pass ) { - validColors.push( this.colors[ i ] ); - } - } - - return Object.assign({}, this, { - colors: validColors - }); - }, - - /** - * Query a string color and get its properties. - * - * @param {string} color - The color we want to query. Can be formatted as hex, rgb, rgba, hsl, hsla. - * @returns {Object} - {r,g,b,h,s,l,hex,lum}. - */ - getColorProperties: function( color ) { - var hex, rgb, hsl, col; - - if ( -1 !== color.indexOf( 'hsl' ) ) { - col = color.replace( 'hsla', '' ).replace( '.hsl', '' ).replace( '(', '' ).replace( ')', '' ).split( ',' ); - hsl = { - h: parseInt( col[0], 10 ), - s: parseInt( col[1], 10 ) / 100, - l: parseInt( col[2], 10 ) / 100 - }; - rgb = this.hslToRgb( hsl.h, hsl.s, hsl.l ); - hex = this.rgbToHex( rgb.r, rgb.g, rgb.b ); - } else if ( -1 !== color.indexOf( 'rgb' ) ) { - col = color.replace( 'rgba', '' ).replace( '.rgb', '' ).replace( '(', '' ).replace( ')', '' ).split( ',' ); - rgb = { - r: col[0], - g: col[1], - b: col[2] - }; - hsl = this.rgbToHsl( rgb.r, rgb.g, rgb.b ); - hex = this.rgbToHex( rgb.r, rgb.g, rgb.b ); - } else { - hex = /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test( color ) ? color : '#ffffff'; - rgb = this.hexToRgb( hex ); - hsl = this.rgbToHsl( rgb.r, rgb.g, rgb.b ); - } - return { - r: rgb.r, - g: rgb.g, - b: rgb.b, - h: hsl.h, - s: hsl.s, - l: hsl.l, - hex: hex, - lum: this.getRelativeLuminance( rgb ) - }; - }, - - /** - * Get all colors for a given hue. - * - * @param {int} hue - The hue of the color. - * @param {Object} args - Additional arguments. - * @param {float} args.minSaturation - The minimum saturation the returned colors can have (0-1). - * @param {float} args.maxSaturation - The maximum saturation the returned colors can have (0-1). - * @param {float} args.stepSaturation - The increments in saturation while searching for colors (0-1). - * @param {float} args.stepLightness - Each lightness step. - * smaller numbers are more detailed, - * larger numbers have bigger "steps" between colors. - * @returns {Array} - */ - getAllColorsForHue: function( hue, args ) { - var colors = [], - saturation, - lightness, - color; - - for ( saturation = args.minSaturation; args.maxSaturation >= saturation; saturation += args.stepSaturation ) { - for ( lightness = 0; 1.001 >= lightness; lightness += args.stepLightness ) { - if ( 0 <= hue && 359 >= hue ) { - color = this.hslToRgb( hue, saturation, lightness ); - colors.push({ - r: color.r, - g: color.g, - b: color.b, - h: hue, - s: saturation, - l: lightness, - hex: this.rgbToHex( color.r, color.g, color.b ), - lum: this.getRelativeLuminance( color ) - }); - } - } - } - return colors; - }, - - /** - * Converts an RGB object to a HEX string.\ - * - * @param {int} r - Red. - * @param {int} g - Green. - * @param {int} b - Blue. - * @returns {string} - */ - rgbToHex: function( r, g, b ) { - return '#' + ( ( 1 << 24 ) + ( r << 16 ) + ( g << 8 ) + b ).toString( 16 ).slice( 1 ); - }, - - /** - * Convert hex color to RGB. - * See https://stackoverflow.com/a/5624139 - * - * @since 1.0 - * @param {string} hex - The hex color. - * @returns {Object} - */ - hexToRgb: function( hex ) { - var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i, - result; - - // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF"). - hex = hex.replace( shorthandRegex, function( m, r, g, b ) { - return r + r + g + g + b + b; - }); - - result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec( hex ); - return result ? { - r: parseInt( result[1], 16 ), - g: parseInt( result[2], 16 ), - b: parseInt( result[3], 16 ) - } : null; - }, - - /** - * Converts an HSL color value to RGB. Conversion formula - * adapted from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes h, s, and l are contained in the set [0, 1] and - * returns r, g, and b in the set [0, 255]. - * - * @param {int} h - Hue - * @param {float} s - Saturation - * @param {float} l - Lightness - * @return {Array} - RGB representation - */ - hslToRgb: function( h, s, l ) { - var c, h_, x, r1, g1, b1, m; - - // Calculate chroma. - c = ( 1 - Math.abs( ( 2 * l ) - 1 ) ) * s; - - // Find a point (r1, g1, b1) along the bottom three faces of the RGB cube, - // with the same hue and chroma as our color - // using the intermediate value X for the second largest component of this color. - h_ = h / 60; - x = c * ( 1 - Math.abs( ( h_ % 2 ) - 1 ) ); - r1, g1, b1; - - if ( 'undefined' === typeof h || isNaN( h ) || null === h ) { - r1 = g1 = b1 = 0; - } else { - if ( 0 <= h_ && 1 > h_ ) { - r1 = c; - g1 = x; - b1 = 0; - } else if ( 1 <= h_ && 2 > h_ ) { - r1 = x; - g1 = c; - b1 = 0; - } else if ( 2 <= h_ && 3 > h_ ) { - r1 = 0; - g1 = c; - b1 = x; - } else if ( 3 <= h_ && 4 > h_ ) { - r1 = 0; - g1 = x; - b1 = c; - } else if ( 4 <= h_ && 5 > h_ ) { - r1 = x; - g1 = 0; - b1 = c; - } else if ( 5 <= h_ && 6 > h_ ) { - r1 = c; - g1 = 0; - b1 = x; - } - } - - // Find r, g, and b by adding the same amount to each component to match lightness. - m = l - ( c / 2 ); - - // Normalise to range [0,255] by multiplying with 255. - return { - r: Math.round( ( r1 + m ) * 255 ), - g: Math.round( ( g1 + m ) * 255 ), - b: Math.round( ( b1 + m ) * 255 ) - }; - }, - - /** - * Converts an RGB color value to HSL. Conversion formula - * adapted from http://en.wikipedia.org/wiki/HSL_color_space. - * Assumes r, g, and b are contained in the set [0, 255] and - * returns h (0-359), s (0-1), and l (0-1) - * - * @param {int} r - The red color value - * @param {int} g - The green color value - * @param {int} b - The blue color value - * @return {Array} - The HSL representation - */ - rgbToHsl: function( r, g, b ) { - var max, min, h, s, l, d; - - r /= 255; - g /= 255; - b /= 255; - max = Math.max( r, g, b ); - min = Math.min( r, g, b ); - l = ( max + min ) / 2; - - if ( max === min ) { // Achromatic. - return { - h: 0, - s: 0, - l: l - }; - } - d = max - min; - s = 0.5 < l ? d / ( 2 - max - min ) : d / ( max + min ); - switch ( max ) { - case r: h = ( g - b ) / d + ( g < b ? 6 : 0 ); break; - case g: h = ( b - r ) / d + 2; break; - case b: h = ( r - g ) / d + 4; break; - } - h /= 6; - - return { - h: h * 360, - s: s, - l: l - }; - }, - - /** - * Get contrast between 2 luminosities. - * - * @since 1.0 - * @param {float} lum1 - 1st Luminosity. - * @param {float} lum2 - 2nd Luminosity. - * @returns {float} - */ - getContrast: function( lum1, lum2 ) { - return this.roundFloat( Math.max( ( lum1 + 0.05 ) / ( lum2 + 0.05 ), ( lum2 + 0.05 ) / ( lum1 + 0.05 ) ) ); - }, - - /** - * Gets the relative luminance from RGB. - * Formula: http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef - * - * @since 1.0 - * @param {Object} color - an RGB color {r,g,b}. - * @returns {float} - */ - getRelativeLuminance: function( color ) { - return this.roundFloat( 0.2126 * this.getLumPart( color.r ) + 0.7152 * this.getLumPart( color.g ) + 0.0722 * this.getLumPart( color.b ) ); - }, - - /** - * Get luminocity for a part. - * - * @since 1.0 - * @param {int|float} val - The value. - * @returns {float} - */ - getLumPart: function( val ) { - val = val / 255; - if ( 0.03928 >= val ) { - return val / 12.92; - } - return Math.pow( ( ( val + 0.055 ) / 1.055 ), 2.4 ); - }, - - /** - * Round a float. - * See https://stackoverflow.com/a/5624139 - * - * @since 1.0 - * @param {float} number - The number we want to round. - * @returns {float} - */ - roundFloat: function( number ) { - return Math.round( number * 100 ) / 100; - }, - - /** - * Returns {this} with the colors array sorted. - * - * @param {string} sortBy - What do we want to sort by? - * Acceptable values: r,g,b,h,s,l,lum,hex,contrast - * @returns {Object} - */ - sortBy: function( sortBy ) { - return Object.assign({}, this, { - colors: this.colors.sort( function( a, b ) { - return b[ sortBy ] - a[ sortBy ]; - }) - }); - }, - - /** - * Removes duplicate entries from colors. - * - * @param {Array} colors - An array of colors. - * @return {Object} - */ - removeDuplicateColors: function( colors ) { - var uniques = {}, - i; - for ( i = 0; i < colors.length; i++ ) { - uniques[ colors[ i ].hex ] = colors[ i ]; - } - return Object.keys( uniques ).map( function( v ) { - return uniques[ v ]; - }); - }, - - /** - * Returns an array of Hex colors. - * - * @returns {Array} - */ - getHexArray: function() { - var hexes = [], - i; - for ( i = 0; i < this.colors.length; i++ ) { - hexes.push( this.colors[ i ].hex ); - } - return hexes; - } -}; diff --git a/inc/customizer/customizer.php b/inc/customizer/customizer.php new file mode 100755 index 0000000..f5aa40a --- /dev/null +++ b/inc/customizer/customizer.php @@ -0,0 +1,49 @@ + esc_html__( 'Gridd Plus', 'gridd-plus' ), + 'description' => esc_html__( 'Includes generic options for gridd-plus. Options specific to a grid-part can be found in that grid-part\'s settings.', 'gridd-plus' ), + ] +); + +new \Kirki\Field\RadioButtonset( + [ + 'type' => 'radio', + 'settings' => 'gridd_enable_totop', + 'label' => esc_attr__( 'Enable scroll-to-top button.', 'gridd-plus' ), + 'description' => esc_html__( 'Shows a "Scroll-to-top" button on the bottom-right corner of the screen. Select "Hidden" to disable the button.', 'gridd-plus' ), + 'section' => 'gridd_plus', + 'default' => 'hidden', + 'priority' => 10, + 'transport' => 'refresh', + 'choices' => [ + 'hidden' => esc_attr__( 'Hidden', 'gridd-plus' ), + 'large' => esc_attr__( 'Large Screen Only', 'gridd-plus' ), + ], + ] +); + +new \Kirki\Field\Checkbox_Switch( + [ + 'settings' => 'gridd_headers_anchor_links', + 'label' => esc_attr__( 'Enable anchor links in headers', 'gridd-plus' ), + 'description' => esc_html__( 'Add a link icon next to headers that have an anchor defined.', 'gridd-plus' ), + 'section' => 'gridd_plus', + 'default' => true, + 'priority' => 20, + 'transport' => 'refresh', + ] +); diff --git a/inc/customizer/features.php b/inc/customizer/features.php deleted file mode 100644 index 4deafe5..0000000 --- a/inc/customizer/features.php +++ /dev/null @@ -1,101 +0,0 @@ - 'dimension', - 'settings' => 'gridd_featured_image_fixed_singular_height', - 'label' => esc_attr__( 'Fixed container maximum height', 'gridd-plus' ), - 'description' => esc_html__( 'Select how featured images will be displayed in single post-types (Applies to all post-types).', 'gridd-plus' ), - 'section' => 'gridd_features', - 'default' => '60vh', - 'priority' => 25, - 'transport' => 'refresh', - 'css_vars' => '--fimg-fh', - 'transport' => 'postMessage', - 'active_callback' => function() { - return ( is_singular() && 'fixed' === get_theme_mod( 'gridd_featured_image_mode_singular', 'alignwide' ) ); - }, - ] -); - -Customizer::add_field( - [ - 'type' => 'switch', - 'settings' => 'gridd_headers_anchor_links', - 'label' => esc_attr__( 'Enable anchor links in headers', 'gridd-plus' ), - 'description' => esc_html__( 'If a header block has an anchor defined, this will add a link icon at the end of the headers when they are hovered so that users can easier link to sections of your pages.', 'gridd-plus' ), - 'section' => 'gridd_features', - 'default' => true, - 'priority' => 70, - 'transport' => 'refresh', - ] -); - -Customizer::add_field( - [ - 'type' => 'radio', - 'settings' => 'gridd_enable_totop', - 'label' => esc_attr__( 'Enable scroll-to-top button.', 'gridd-plus' ), - 'description' => esc_html__( 'When on a long page shows a "Scroll-to-top" button on the bottom-right corner of the screen. Select "Desktop" to only show the button on large screens, "Show" to show the button on both large and small screens, or "Hidden" to disable the button.', 'gridd-plus' ), - 'section' => 'gridd_features', - 'default' => 'hidden', - 'priority' => 80, - 'transport' => 'refresh', - 'choices' => [ - 'hidden' => esc_attr__( 'Hidden', 'gridd-plus' ), - 'large' => esc_attr__( 'Desktop Only', 'gridd-plus' ), - 'all' => esc_attr__( 'Show', 'gridd-plus' ), - ], - ] -); - -Customizer::add_field( - [ - 'type' => 'slider', - 'settings' => 'gridd_grid_widget_areas_number', - 'label' => esc_attr__( 'Number of custom widget areas', 'gridd-plus' ), - 'description' => __( 'Select how many custom widget areas you want to add.', 'gridd-plus' ), - 'section' => 'gridd_features', - 'default' => 2, - 'priority' => 100, - 'transport' => 'postMessage', - 'choices' => [ - 'min' => 0, - 'max' => 15, - 'step' => 1, - ], - ] -); - -$range = range( 1, apply_filters( 'gridd_max_widget_areas', 15 ), 1 ); -foreach ( $range as $i ) { - Customizer::add_field( - [ - 'type' => 'text', - 'settings' => "gridd_grid_widget_area_{$i}_name", - /* translators: The widget-area number. */ - 'label' => sprintf( esc_html__( 'Widget Area %d Name', 'gridd-plus' ), absint( $i ) ), - 'tooltip' => esc_html__( 'Enter a custom name if you want to easier identify this widget-area. Please note that changes will only be visible after you save the Customizer options and refresh this page.', 'gridd-plus' ), - 'section' => 'gridd_features', - /* translators: The widget-area number. */ - 'default' => sprintf( esc_html__( 'Widget Area %d', 'gridd-plus' ), absint( $i ) ), - 'transport' => 'postMessage', - 'priority' => 101, - 'active_callback' => [ - [ - 'setting' => 'gridd_grid_widget_areas_number', - 'operator' => '>=', - 'value' => $i, - ], - ], - ] - ); -} diff --git a/inc/customizer/footer.php b/inc/customizer/footer.php deleted file mode 100644 index ac07106..0000000 --- a/inc/customizer/footer.php +++ /dev/null @@ -1,102 +0,0 @@ - 'gridd_footer_grid_toggle', - 'type' => 'radio-buttonset', - 'label' => esc_html__( 'Toggle between desktop & mobile grids.', 'gridd-plus' ), - 'section' => 'gridd_grid_part_details_footer', - 'default' => 'desktop', - 'priority' => -10, - 'transport' => 'postMessage', - 'choices' => [ - 'desktop' => esc_html__( 'Desktop', 'gridd-plus' ), - 'mobile' => esc_html__( 'Mobile', 'gridd-plus' ), - ], - 'sanitize_callback' => function() { - return 'desktop'; - }, - ] -); - -Customizer::add_field( - [ - 'settings' => 'gridd_copy_footer_grid_to_mobile', - 'type' => 'custom', - 'label' => esc_html__( 'Copy desktop grid setings to mobile grid', 'gridd-plus' ), - 'section' => 'gridd_grid_part_details_footer', - 'default' => '
', - 'active_callback' => [ - [ - 'setting' => 'gridd_footer_grid_toggle', - 'operator' => '===', - 'value' => 'mobile', - ], - ], - ] -); - -Customizer::add_field( - [ - 'settings' => 'gridd_grid_footer_mobile', - 'section' => 'gridd_grid_part_details_footer', - 'type' => 'gridd_grid', - 'grid-part' => 'footer', - 'label' => esc_html__( 'Footer Mobile Grid Settings', 'gridd-plus' ), - 'description' => sprintf( - /* translators: Link attributes. */ - __( 'Edit settings for the footer grid. For more information and documentation on how the grid works, please read this article.', 'gridd-plus' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - 'href="https://wplemon.com/documentation/gridd/the-grid-control/" target="_blank"' - ), - 'default' => [ - 'rows' => 2, - 'columns' => 2, - 'areas' => [ - 'footer_sidebar_1' => [ - 'cells' => [ [ 1, 1 ] ], - ], - 'footer_sidebar_2' => [ - 'cells' => [ [ 1, 2 ] ], - ], - 'footer_copyright' => [ - 'cells' => [ [ 2, 1 ], [ 2, 2 ] ], - ], - ], - 'gridTemplate' => [ - 'rows' => [ 'auto', 'auto' ], - 'columns' => [ '1fr', '1fr', '1fr', '1fr' ], - ], - ], - 'sanitize_callback' => [ $sanitization, 'grid' ], - 'choices' => [ - 'parts' => Footer::get_footer_grid_parts(), - 'duplicate' => 'gridd_footer_grid', - 'disablePartButtons' => [ 'edit' ], - ], - 'transport' => 'postMessage', - 'partial_refresh' => [ - 'gridd_footer_grid_mobile_template' => [ - 'selector' => '.gridd-tp-footer', - 'container_inclusive' => false, - 'render_callback' => function() { - do_action( 'gridd_the_grid_part', 'footer' ); - }, - ], - ], - ] -); diff --git a/inc/customizer/grid.php b/inc/customizer/grid.php deleted file mode 100644 index 35e4a23..0000000 --- a/inc/customizer/grid.php +++ /dev/null @@ -1,60 +0,0 @@ - 'gridd_custom_mobile_grid', - 'section' => 'gridd_grid', - 'type' => 'checkbox', - 'label' => esc_html__( 'Enable custom grid for small viewports', 'gridd-plus' ), - 'tooltip' => esc_html__( 'If you want to customize the way your grid will be shown in mobile and small devices, you can enable this option and create a separate grid for mobile.', 'gridd-plus' ), - 'default' => false, - 'priority' => 21, - 'choices' => [ - 'default' => esc_attr__( 'Default', 'gridd-plus' ), - 'custom' => esc_attr__( 'Custom', 'gridd-plus' ), - ], - ] -); - -Customizer::add_field( - [ - 'settings' => 'gridd_grid_mobile', - 'section' => 'gridd_grid', - 'type' => 'gridd_grid', - 'grid-part' => false, - 'priority' => 23, - 'label' => esc_html__( 'Mobile Grid Settings', 'gridd-plus' ), - 'description' => sprintf( - /* translators: Link attributes. */ - __( 'Edit settings for the grid. For more information and documentation on how the grid works, please read this article.', 'gridd-plus' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - 'href="https://wplemon.com/documentation/gridd/the-grid-control/" target="_blank"' - ), - 'default' => Grid::get_grid_default_value(), - 'sanitize_callback' => [ $sanitization, 'grid' ], - 'choices' => [ - 'parts' => Grid_Parts::get_instance()->get_parts(), - 'duplicate' => 'gridd_grid', - 'disablePartButtons' => [ 'edit' ], - ], - 'active_callback' => [ - [ - 'setting' => 'gridd_custom_mobile_grid', - 'value' => true, - 'operator' => '===', - ], - ], - ] -); diff --git a/inc/customizer/header.php b/inc/customizer/header.php deleted file mode 100644 index 4ef404c..0000000 --- a/inc/customizer/header.php +++ /dev/null @@ -1,59 +0,0 @@ - 'gridd_grid_header_mobile_override', - 'section' => 'gridd_grid_part_details_header', - 'type' => 'checkbox', - 'default' => true, - 'label' => esc_html__( 'Enable Separate Grid for Mobile', 'gridd-plus' ), - ] -); - -Customizer::add_field( - [ - 'settings' => 'gridd_grid_header_mobile', - 'section' => 'gridd_grid_part_details_header', - 'type' => 'gridd_grid', - 'grid-part' => 'header', - 'label' => esc_html__( 'Header Mobile Grid Settings', 'gridd-plus' ), - 'description' => sprintf( - /* translators: Link attributes. */ - __( 'Edit settings for the header grid. For more information and documentation on how the grid works, please read this article.', 'gridd-plus' ), // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped - 'href="https://wplemon.com/documentation/gridd/the-grid-control/" target="_blank"' - ), - 'default' => get_theme_mod( 'gridd_header_grid', Header::get_grid_defaults() ), - 'sanitize_callback' => [ $sanitization, 'grid' ], - 'choices' => [ - 'parts' => Header::get_header_grid_parts(), - 'duplicate' => 'gridd_header_grid', - 'disablePartButtons' => [ 'edit' ], - ], - 'active_callback' => function() { - return get_theme_mod( 'gridd_grid_header_mobile_override', true ); - }, - 'transport' => 'postMessage', - 'priority' => 15, - 'partial_refresh' => [ - 'gridd_header_mobile_grid_part_renderer' => [ - 'selector' => '.gridd-tp.gridd-tp-header', - 'container_inclusive' => true, - 'render_callback' => function() { - do_action( 'gridd_the_grid_part', 'header' ); - }, - ], - ], - ] -); diff --git a/inc/customizer/layer-slider.php b/inc/customizer/layer-slider.php deleted file mode 100644 index 54c0195..0000000 --- a/inc/customizer/layer-slider.php +++ /dev/null @@ -1,39 +0,0 @@ - sprintf( - /* translators: The grid-part label. */ - esc_attr__( '%s Options', 'gridd-plus' ), - /* translators: The Layer-Slider name. */ - sprintf( esc_html__( 'Layer Slider %s', 'gridd-plus' ), esc_html( $slider['name'] ) ) - ), - 'section' => 'gridd_grid', - ] - ); - - Customizer::add_field( - [ - 'type' => 'custom', - 'settings' => "gridd_layer_slider_no_settings_notice_{$slider['id']}", - 'label' => '', - 'description' => '', - 'section' => "gridd_grid_part_details_layer-slider-{$slider['id']}", - 'default' => esc_html__( "Layer Slider parts don't have any settings. If you want to modify your slider please use the LayerSlider plugin.", 'gridd-plus' ), - ] - ); -} diff --git a/inc/customizer/nav-handheld.php b/inc/customizer/nav-handheld.php deleted file mode 100644 index 3a131ad..0000000 --- a/inc/customizer/nav-handheld.php +++ /dev/null @@ -1,78 +0,0 @@ - 'text', - 'settings' => 'gridd_grid_nav-handheld_widget_area_label', - 'label' => esc_html__( 'Widget Area Button Label', 'gridd-plus' ), - 'description' => esc_html__( 'Please add a label for the widget area.', 'gridd-plus' ), - 'section' => 'gridd_mobile', - 'default' => esc_html__( 'Settings', 'gridd-plus' ), - 'transport' => 'postMessage', - 'partial_refresh' => [ - 'gridd_grid_nav-handheld_widget_area_label_template' => [ - 'selector' => '.gridd-tp-nav-handheld', - 'container_inclusive' => true, - 'render_callback' => function() { - do_action( 'gridd_the_grid_part', 'nav-handheld' ); - }, - ], - ], - 'active_callback' => [ - [ - 'setting' => 'gridd_grid_nav-handheld_enable', - 'operator' => '===', - 'value' => true, - ], - [ - 'setting' => 'gridd_grid_nav-handheld_parts', - 'operator' => 'contains', - 'value' => 'widget-area', - ], - ], - ] -); - -Customizer::add_field( - [ - 'type' => 'textarea', - 'settings' => 'gridd_grid_nav-handheld_widget_area_icon', - 'label' => esc_html__( 'Widget Area Button SVG Icon', 'gridd-plus' ), - 'description' => __( 'Paste SVG code for the icon you want to use. You can find a great collection of icons on the iconmonstr website or add your custom icon.', 'gridd-plus' ), - 'section' => 'gridd_mobile', - 'default' => '', - 'transport' => 'postMessage', - 'sanitize_callback' => function( $value ) { - return $value; - }, - 'partial_refresh' => [ - 'grid_part_handheld_widget_area_icon' => [ - 'selector' => '.gridd-tp-nav-handheld', - 'container_inclusive' => true, - 'render_callback' => function() { - do_action( 'gridd_the_grid_part', 'nav-handheld' ); - }, - ], - ], - 'active_callback' => [ - [ - 'setting' => 'gridd_grid_nav-handheld_parts', - 'operator' => 'contains', - 'value' => 'widget-area', - ], - [ - 'setting' => 'gridd_grid_nav-handheld_enable', - 'operator' => '===', - 'value' => true, - ], - ], - ] -); diff --git a/inc/customizer/navigation.php b/inc/customizer/navigation.php index 744dc36..11d9845 100644 --- a/inc/customizer/navigation.php +++ b/inc/customizer/navigation.php @@ -8,19 +8,22 @@ use Gridd\Customizer; use Gridd\Grid_Part\Navigation; -/** - * Register the menus. - * - * @since 1.0 - * @return void - */ -function gridd_plus_add_nav_parts() { - $number = Navigation::get_number_of_nav_menus(); - for ( $i = 1; $i <= $number; $i++ ) { - gridd_plus_nav_customizer_options( $i ); - } -} -add_action( 'after_setup_theme', 'gridd_plus_add_nav_parts', 20 ); +add_action( + 'after_setup_theme', + /** + * Register the menus. + * + * @since 1.0 + * @return void + */ + function() { + $number = Navigation::get_number_of_nav_menus(); + for ( $i = 1; $i <= $number; $i++ ) { + gridd_plus_nav_customizer_options( $i ); + } + }, + 20 +); /** * This function creates all options for a navigation. @@ -31,50 +34,39 @@ function gridd_plus_add_nav_parts() { * @return void */ function gridd_plus_nav_customizer_options( $id ) { - Customizer::add_field( + new \Kirki\Field\Slider( [ - 'type' => 'slider', - 'settings' => "gridd_grid_nav_{$id}_font_size", - 'label' => esc_html__( 'Menu Font Size', 'gridd-plus' ), - 'description' => esc_html__( 'The font-size for this menu. This value is relevant to your body font-size, so a value of 1em will be the same size as you content.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nav_$id", - 'default' => 1, - 'transport' => 'postMessage', - 'css_vars' => [ "--nv-$id-fs", '$em' ], - 'choices' => [ + 'settings' => "nav_{$id}_font_size", + 'label' => esc_html__( 'Menu Font Size', 'gridd-plus' ), + 'description' => esc_html__( 'The font-size for this menu. This value is relevant to your body font-size, so a value of 1em will be the same size as you content.', 'gridd-plus' ), + 'section' => "nav_$id", + 'default' => 1, + 'transport' => 'auto', + 'output' => [ + [ + 'element' => ".gridd-tp-nav_$id", + 'property' => '--fs', + 'value_pattern' => '$em', + ], + ], + 'choices' => [ 'min' => 0.5, 'max' => 2.5, 'step' => 0.01, 'suffix' => 'em', ], - ] - ); - - Customizer::add_field( - [ - 'type' => 'slider', - 'settings' => "gridd_grid_nav_{$id}_items_padding", - 'label' => esc_html__( 'Items Padding', 'gridd-plus' ), - 'description' => esc_html__( 'The inner padding for menu items. This setting affects the spacing between your menu items.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nav_$id", - 'default' => 1, - 'transport' => 'postMessage', - 'css_vars' => [ "--nv-$id-ipd", '$em' ], - 'choices' => [ - 'min' => 0.2, - 'max' => 3, - 'step' => 0.01, - 'suffix' => 'em', - ], + 'active_callback' => function() use ( $id ) { + return get_theme_mod( "nav_{$id}_custom_options", false ); + }, ] ); Customizer::add_field( [ 'type' => 'slider', - 'settings' => "gridd_grid_nav_{$id}_collapse_icon_size", + 'settings' => "nav_{$id}_collapse_icon_size", 'label' => esc_html__( 'Collapse Icon Size', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nav_$id", + 'section' => "nav_$id", 'default' => 1, 'transport' => 'postMessage', 'choices' => [ @@ -83,35 +75,37 @@ function gridd_plus_nav_customizer_options( $id ) { 'step' => .01, 'suffix' => 'em', ], - 'css_vars' => [ "--nv-$id-cis", '$em' ], - 'active_callback' => [ + 'output' => [ [ - 'setting' => "gridd_grid_nav_{$id}_responsive_behavior", - 'value' => 'desktop-normal mobile-normal', - 'operator' => '!==', - ], - [ - 'setting' => "gridd_grid_nav_{$id}_responsive_behavior", - 'value' => 'desktop-normal mobile-hidden', - 'operator' => '!==', + 'element' => ".gridd-tp-nav_$id", + 'property' => '--cis', + 'value_pattern' => '$em', ], ], + 'active_callback' => function() use ( $id ) { + $responsive = get_theme_mod( "nav_{$id}_responsive_behavior" ); + if ( 'desktop-normal mobile-normal' === $responsive || 'desktop-normal mobile-hidden' === $responsive ) { + return false; + } + + return get_theme_mod( "nav_{$id}_custom_options", false ); + }, ] ); if ( class_exists( 'WooCommerce' ) ) { - Customizer::add_field( + new \Kirki\Field\Checkbox_Switch( [ 'type' => 'switch', - 'settings' => "gridd_grid_nav_{$id}_woo_cart", + 'settings' => "nav_{$id}_woo_cart", 'label' => esc_html__( 'Show WooCommerce Cart', 'gridd-plus' ), 'description' => __( 'If enabled, the cart will be added as a dropdown at the end of the menu.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nav_$id", + 'section' => "nav_$id", 'default' => 1 === $id, 'transport' => 'auto', 'transport' => 'postMessage', 'partial_refresh' => [ - "gridd_grid_nav_{$id}_woo_cart_template" => [ + "nav_{$id}_woo_cart_template" => [ 'selector' => ".gridd-tp-nav_{$id}", 'container_inclusive' => true, 'render_callback' => function() use ( $id ) { diff --git a/inc/customizer/nested-grid.php b/inc/customizer/nested-grid.php index d40e03c..fc782d4 100644 --- a/inc/customizer/nested-grid.php +++ b/inc/customizer/nested-grid.php @@ -19,17 +19,17 @@ function gridd_add_nested_grid_options( $id ) { $sanitization = new Sanitize(); - Customizer::add_section( - "gridd_grid_part_details_nested-grid-{$id}", + new \Kirki\Section( + "nested-grid-{$id}", [ - 'title' => sprintf( - /* translators: The grid-part label. */ - esc_attr__( '%s Options', 'gridd-plus' ), - /* translators: Number of a nested-grid. */ - sprintf( esc_html__( 'Nested Grid %d', 'gridd-plus' ), $id ) - ), - 'description' => '' . esc_html__( 'Learn more about these settings', 'gridd-plus' ), - 'section' => 'gridd_grid', + /* translators: Number of a nested-grid. */ + 'title' => sprintf( esc_html__( 'Nested Grid %d', 'gridd-plus' ), $id ), + 'description' => '' . esc_html__( 'Learn more about these settings', 'gridd-plus' ), + 'panel' => 'theme_options', + 'type' => 'kirki-expanded', + 'active_callback' => function() use ( $id ) { + return \Gridd\Customizer::is_section_active_part( "nested-grid-$id" ); + }, ] ); @@ -54,7 +54,7 @@ function gridd_add_nested_grid_options( $id ) { Customizer::add_field( [ 'settings' => "gridd_nested_grid_$id", - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'type' => 'gridd_grid', 'grid-part' => "nested-grid-$id", 'label' => esc_html__( 'Grid Settings', 'gridd-plus' ), @@ -81,7 +81,7 @@ function gridd_add_nested_grid_options( $id ) { "gridd_nested_grid_{$id}_template" => [ 'selector' => ".gridd-tp-nested-grid-{$id}", 'container_inclusive' => true, - 'render_callback' => function() { + 'render_callback' => function() use ( $id ) { do_action( 'gridd_the_grid_part', "nested-grid-{$id}" ); }, ], @@ -89,29 +89,22 @@ function gridd_add_nested_grid_options( $id ) { ] ); - Customizer::add_field( - [ - 'type' => 'dimension', - 'settings' => "gridd_nested_grid_{$id}_padding", - 'label' => esc_attr__( 'Grid Container Padding', 'gridd-plus' ), - 'description' => '', - 'section' => "gridd_grid_part_details_nested-grid-$id", - 'default' => '0', - 'transport' => 'postMessage', - 'css_vars' => "--ns-gr-$id-pd", - ] - ); - Customizer::add_field( [ 'type' => 'dimension', 'settings' => "gridd_nested_grid_{$id}_gap", 'label' => esc_attr__( 'Grid Container Gap', 'gridd-plus' ), 'tooltip' => esc_html__( 'If you have a background-color defined for this grid, then that color will be visible through these gaps which creates a unique appearance since each grid-part looks separate.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'default' => '0', 'transport' => 'postMessage', - 'css_vars' => "--ns-gr-$id-gg", + 'transport' => 'auto', + 'output' => [ + [ + 'element' => ".gridd-tp-nested-grid-$id", + 'property' => '--gg', + ], + ], ] ); @@ -122,25 +115,34 @@ function gridd_add_nested_grid_options( $id ) { 'label' => esc_attr__( 'Grid Container max-width', 'gridd-plus' ), 'description' => esc_html__( 'The maximum width for this grid.', 'gridd-plus' ), 'tooltip' => esc_html__( 'By setting the max-width to something other than 100% you get a boxed layout.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'default' => '', - 'transport' => 'postMessage', - 'css_vars' => "--ns-gr-$id-mw", + 'transport' => 'auto', + 'output' => [ + [ + 'element' => ".gridd-tp-nested-grid-$id", + 'property' => '--mw', + ], + ], ] ); - Customizer::add_field( + new \Kirki\Field\ReactColor( [ - 'type' => 'color', 'settings' => "gridd_nested_grid_{$id}_background_color", 'label' => esc_attr__( 'Grid Container background-color', 'gridd-plus' ), 'description' => '', - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'default' => '#ffffff', - 'transport' => 'postMessage', - 'css_vars' => "--ns-gr-$id-bg", + 'transport' => 'auto', + 'output' => [ + [ + 'element' => ".gridd-tp-nested-grid-$id", + 'property' => '--bg', + ], + ], 'choices' => [ - 'alpha' => true, + 'formComponent' => 'ChromePicker', ], ] ); @@ -151,10 +153,15 @@ function gridd_add_nested_grid_options( $id ) { 'settings' => "gridd_nested_grid_{$id}_box_shadow", 'label' => esc_html__( 'Drop Shadow Intensity', 'gridd-plus' ), 'description' => esc_html__( 'Set to "None" if you want to disable the shadow for this grid-part, or increase the intensity for a more dramatic effect.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'default' => 'none', - 'transport' => 'postMessage', - 'css_vars' => "--ns-gr-$id-bs", + 'transport' => 'auto', + 'output' => [ + [ + 'element' => ".gridd-tp-nested-grid-$id", + 'property' => '--bs', + ], + ], 'priority' => 200, 'choices' => [ 'none' => esc_html__( 'None', 'gridd-plus' ), @@ -172,7 +179,7 @@ function gridd_add_nested_grid_options( $id ) { 'type' => 'switch', 'settings' => "gridd_nested_grid_{$id}_sticky", 'label' => esc_attr__( 'Sticky', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_nested-grid-$id", + 'section' => "nested-grid-$id", 'default' => false, 'transport' => 'auto', 'priority' => 300, diff --git a/inc/customizer/offcanvas-sidebar.php b/inc/customizer/offcanvas-sidebar.php index 99d4dbc..bc51467 100644 --- a/inc/customizer/offcanvas-sidebar.php +++ b/inc/customizer/offcanvas-sidebar.php @@ -13,35 +13,36 @@ /** * Add Customizer Sections. */ -Customizer::add_section( +new \Kirki\Section( 'gridd_plus_offcanvas_sidebar', [ 'title' => esc_html__( 'Offcanvas Sidebar', 'gridd-plus' ), 'priority' => 27, - 'panel' => 'gridd_options', ] ); -Customizer::add_field( - [ - 'type' => 'custom', - 'settings' => 'gridd_plus_offcanvas_sidebar_important_note', - 'label' => esc_html__( 'Important Note', 'gridd-plus' ), - 'description' => esc_html__( 'You will need to assign some widgets to the "Offcanvas Sidebar" widget-area in order for the area to be visible.', 'gridd-plus' ), - 'section' => 'gridd_plus_offcanvas_sidebar', - 'default' => false, - 'transport' => 'refresh', - ] -); - -Customizer::add_field( +new \Kirki\Field\ReactColor( [ - 'type' => 'checkbox', - 'settings' => 'gridd_pluss_offcanvas_sidebar_enable', - 'label' => esc_html__( 'Enable Off-Canvas Sidebar', 'gridd-plus' ), - 'section' => 'gridd_plus_offcanvas_sidebar', - 'default' => false, - 'transport' => 'refresh', + 'type' => 'color', + 'label' => esc_html__( 'Background Color', 'gridd-plus' ), + 'settings' => 'gridd_plus_offcanvas_sidebar_bg_color', + 'section' => 'gridd_plus_offcanvas_sidebar', + 'default' => '#ffffff', + 'priority' => 30, + 'transport' => 'auto', + 'output' => [ + [ + 'element' => '#offcanvas-wrapper', + 'property' => '--bg', + ], + ], + 'choices' => [ + 'formComponent' => 'TwitterPicker', + 'colors' => \Gridd\Theme::get_colorpicker_palette(), + ], + 'active_callback' => function() { + return is_active_sidebar( 'offcanvas-sidebar' ); + }, ] ); @@ -49,24 +50,25 @@ [ 'type' => 'dimension', 'settings' => 'gridd_pluss_offcanvas_sidebar_width', - 'label' => esc_html__( 'Width', 'gridd-plus' ), + 'label' => esc_html__( 'Size', 'gridd-plus' ), 'section' => 'gridd_plus_offcanvas_sidebar', 'default' => '300px', - 'transport' => 'postMessage', - 'css_vars' => '--ocnv-w', - 'active_callback' => [ + 'transport' => 'auto', + 'output' => [ [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, + 'element' => '#offcanvas-wrapper', + 'property' => '--sz', ], ], + 'active_callback' => function() { + return is_active_sidebar( 'offcanvas-sidebar' ); + }, + 'priority' => 40, ] ); -Customizer::add_field( +new \Kirki\Field\RadioButtonset( [ - 'type' => 'radio-buttonset', 'settings' => 'gridd_pluss_offcanvas_sidebar_position', 'label' => esc_html__( 'Position', 'gridd-plus' ), 'section' => 'gridd_plus_offcanvas_sidebar', @@ -76,103 +78,54 @@ 'left' => esc_html__( 'Left', 'gridd-plus' ), 'right' => esc_html__( 'Right', 'gridd-plus' ), ], - 'active_callback' => [ - [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, - ], - ], - ] -); - -Customizer::add_field( - [ - 'type' => 'dimension', - 'settings' => 'gridd_pluss_offcanvas_sidebar_padding', - 'label' => esc_html__( 'Padding', 'gridd-plus' ), - 'description' => __( 'Inner padding for this grid-part. Use any valid CSS value. For details on how padding works, please refer to this article.', 'gridd-plus' ), - 'section' => 'gridd_plus_offcanvas_sidebar', - 'default' => '1em', - 'transport' => 'postMessage', - 'css_vars' => '--ocnv-pd', - 'active_callback' => [ - [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, - ], - ], + 'active_callback' => function() { + return is_active_sidebar( 'offcanvas-sidebar' ); + }, + 'priority' => 50, ] ); -Customizer::add_field( - [ - 'type' => 'color', - 'label' => esc_html__( 'Background Color', 'gridd-plus' ), - 'settings' => 'gridd_plus_offcanvas_sidebar_bg_color', - 'section' => 'gridd_plus_offcanvas_sidebar', - 'default' => '#ffffff', - 'transport' => 'postMessage', - 'css_vars' => '--ocnv-bg', - 'choices' => [ - 'alpha' => true, - ], - 'active_callback' => [ - [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, - ], - ], - ] -); - -Customizer::add_field( +new \WPLemon\Field\WCAGTextColor( [ - 'type' => 'gridd-wcag-tc', 'label' => esc_html__( 'Text Color', 'gridd-plus' ), 'description' => esc_html__( 'Select the color used for your menu items. Please choose a color with sufficient contrast with the selected background-color.', 'gridd-plus' ), 'settings' => 'gridd_plus_offcanvas_sidebar_color', 'section' => 'gridd_plus_offcanvas_sidebar', 'choices' => [ - 'setting' => 'gridd_plus_offcanvas_sidebar_bg_color', + 'backgroundColor' => 'gridd_plus_offcanvas_sidebar_bg_color', ], 'default' => '#000000', - 'transport' => 'postMessage', - 'css_vars' => '--ocnv-cl', - 'sanitize_callback' => [ $sanitization, 'color_hex' ], - 'active_callback' => [ + 'transport' => 'auto', + 'output' => [ [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, + 'element' => '#offcanvas-wrapper', + 'property' => '--cl', ], ], + 'sanitize_callback' => [ $sanitization, 'color_hex' ], + 'active_callback' => function() { + return is_active_sidebar( 'offcanvas-sidebar' ); + }, + 'priority' => 70, ] ); -Customizer::add_field( +new \Kirki\Field\RadioButtonset( [ - 'type' => 'gridd-wcag-lc', - 'label' => esc_html__( 'Links Color', 'gridd-plus' ), - 'settings' => 'gridd_plus_offcanvas_sidebar_links_color', - 'section' => 'gridd_plus_offcanvas_sidebar', - 'default' => '#0f5e97', - 'transport' => 'postMessage', - 'css_vars' => '--ocnv-lc', - 'choices' => [ - 'backgroundColor' => 'gridd_plus_offcanvas_sidebar_bg_color', - 'textColor' => 'gridd_plus_offcanvas_sidebar_color', - ], - 'sanitize_callback' => [ $sanitization, 'color_hex' ], - 'active_callback' => [ - [ - 'setting' => 'gridd_pluss_offcanvas_sidebar_enable', - 'operator' => '===', - 'value' => true, - ], + 'settings' => 'offcanvas_sidebar_visibility', + 'label' => esc_html__( 'Visibility', 'gridd-plus' ), + 'section' => 'gridd_plus_offcanvas_sidebar', + 'default' => 'always', + 'transport' => 'refresh', + 'choices' => [ + 'desktop' => esc_html__( 'Desktop', 'gridd-plus' ), + 'mobile' => esc_html__( 'Mobile', 'gridd-plus' ), + 'always' => esc_html__( 'Always', 'gridd-plus' ), ], + 'active_callback' => function() { + return is_active_sidebar( 'offcanvas-sidebar' ); + }, + 'priority' => 80, ] ); diff --git a/inc/customizer/sidebar.php b/inc/customizer/sidebar.php index 448857e..12de008 100644 --- a/inc/customizer/sidebar.php +++ b/inc/customizer/sidebar.php @@ -26,10 +26,10 @@ function gridd_plus_sidebar_customizer_options( $id ) { Customizer::add_field( [ 'type' => 'slider', - 'settings' => "gridd_grid_sidebar_{$id}_font_size", + 'settings' => "sidebar_{$id}_font_size", 'label' => esc_attr__( 'Font Size', 'gridd-plus' ), 'description' => '', - 'section' => "gridd_grid_part_details_sidebar_$id", + 'section' => "sidebar_$id", 'priority' => 47, 'default' => 1, 'choices' => [ @@ -51,10 +51,10 @@ function gridd_plus_sidebar_customizer_options( $id ) { Customizer::add_field( [ 'type' => 'text', - 'settings' => "gridd_grid_sidebar_{$id}_visibility_post_id", + 'settings' => "sidebar_{$id}_visibility_post_id", 'label' => esc_attr__( 'Visibility: Post-IDs', 'gridd-plus' ), 'description' => esc_html__( 'If you only want to show this grid-part in a specific page, enter its post-ID here. If you want to add multiple posts separate them with a comma.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_sidebar_$id", + 'section' => "sidebar_$id", 'priority' => 300, 'default' => '', ] @@ -63,10 +63,10 @@ function gridd_plus_sidebar_customizer_options( $id ) { Customizer::add_field( [ 'type' => 'text', - 'settings' => "gridd_grid_sidebar_{$id}_visibility_term_id", - 'label' => esc_attr__( 'Visibility: Post-IDs', 'gridd-plus' ), + 'settings' => "sidebar_{$id}_visibility_term_id", + 'label' => esc_attr__( 'Visibility: Term-IDs', 'gridd-plus' ), 'description' => esc_html__( 'If you only want to show this grid-part in a specific category, tag etc, enter the term-ID here. If you want to add multiple terms separate them with a comma.', 'gridd-plus' ), - 'section' => "gridd_grid_part_details_sidebar_$id", + 'section' => "sidebar_$id", 'priority' => 301, 'default' => '', ] diff --git a/inc/customizer/slider-revolution.php b/inc/customizer/slider-revolution.php index f14ea8c..71ab27b 100644 --- a/inc/customizer/slider-revolution.php +++ b/inc/customizer/slider-revolution.php @@ -13,8 +13,8 @@ } $sliders = new \RevSliderSlider(); foreach ( $sliders->getArrSliders() as $slider ) { - Customizer::add_section( - 'gridd_grid_part_details_slider-revolution-' . $slider->getAlias(), + new \Kirki\Section( + 'slider-revolution-' . $slider->getAlias(), [ 'title' => sprintf( /* translators: The grid-part label. */ @@ -29,10 +29,10 @@ Customizer::add_field( [ 'type' => 'custom', - 'settings' => 'gridd_grid_part_details_slider-revolution-no-options-notice' . $slider->getAlias(), + 'settings' => 'gridd_slider-revolution-no-options-notice' . $slider->getAlias(), 'label' => '', 'description' => '', - 'section' => 'gridd_grid_part_details_slider-revolution-' . $slider->getAlias(), + 'section' => 'slider-revolution-' . $slider->getAlias(), 'default' => esc_html__( "Slider Revolution parts don't have any settings. If you want to modify your slider please use the Slider Revolution plugin.", 'gridd-plus' ), ] ); diff --git a/inc/customizer/typography.php b/inc/customizer/typography.php index 7049ec8..1f5ac8b 100644 --- a/inc/customizer/typography.php +++ b/inc/customizer/typography.php @@ -8,107 +8,60 @@ use Gridd\Customizer; -Customizer::add_field( +new \WPLemon\Field\WCAGTextColor( [ - 'type' => 'kirki-wcag-tc', - 'settings' => 'gridd_headers_color', - 'label' => esc_attr__( 'Headers Color', 'gridd-plus' ), - 'section' => 'gridd_grid_part_details_content', - 'default' => '#000000', - 'css_vars' => '--hdcl', - 'transport' => 'postMessage', - 'priority' => 45, - 'choices' => [ - 'setting' => 'gridd_grid_content_background_color', + 'settings' => 'gridd_headers_color', + 'label' => esc_attr__( 'Headers Color', 'gridd-plus' ), + 'section' => 'content', + 'default' => '#000000', + 'output' => [ + [ + 'element' => ':root', + 'property' => '--hdcl', + ], ], + 'transport' => 'postMessage', + 'priority' => 45, + 'choices' => [ + 'backgroundColor' => 'content_background_color', + ], + 'active_callback' => function() { + return get_theme_mod( 'content_custom_options', false ); + }, ] ); /** * Type Scale */ -$scales = [ - /* Translators: Numeric representation of the scale. */ - '1.067' => sprintf( esc_attr__( '%s - Minor Second', 'gridd-plus' ), '1.067' ), - /* Translators: Numeric representation of the scale. */ - '1.125' => sprintf( esc_attr__( '%s - Major Second', 'gridd-plus' ), '1.125' ), - /* Translators: Numeric representation of the scale. */ - '1.149' => sprintf( esc_attr__( '%s - Musical Pentatonic (classic)', 'gridd-plus' ), '1.149' ), - /* Translators: Numeric representation of the scale. */ - '1.189' => sprintf( esc_attr__( '%s - Musical Tetratonic', 'gridd-plus' ), '1.189' ), - /* Translators: Numeric representation of the scale. */ - '1.25' => sprintf( esc_attr__( '%s - Major Third', 'gridd-plus' ), '1.25' ), - /* Translators: Numeric representation of the scale. */ - '1.26' => sprintf( esc_attr__( '%s - Musical Tritonic', 'gridd-plus' ), '1.26' ), - /* Translators: Numeric representation of the scale. */ - '1.272' => sprintf( esc_attr__( '%s - Golden Ditonic', 'gridd-plus' ), '1.272' ), - /* Translators: Numeric representation of the scale. */ - '1.333' => sprintf( esc_attr__( '%s - Perfect Fourth', 'gridd-plus' ), '1.333' ), - /* Translators: Numeric representation of the scale. */ - '1.444' => sprintf( esc_attr__( '%s - Augmented Fourth', 'gridd-plus' ), '1.444' ), - /* Translators: Numeric representation of the scale. */ - '1.5' => sprintf( esc_attr__( '%s - Perfect Fifth', 'gridd-plus' ), '1.5' ), - /* Translators: Numeric representation of the scale. */ - '1.618' => sprintf( esc_attr__( '%s - Golden Ratio', 'gridd-plus' ), '1.618' ), - // Custom. - 'custom' => 'custom', -]; - -$scales_presets = []; -foreach ( array_keys( $scales ) as $scale ) { - $scales_presets[ $scale ] = [ - 'settings' => [ - 'gridd_type_scale' => (float) $scale, - ], - ]; -} -Customizer::add_field( +new \Kirki\Field\Slider( [ - 'settings' => 'gridd_type_scale_preset', - 'type' => 'radio', - 'label' => esc_attr__( 'Headers Size Scale', 'gridd-plus' ), - 'description' => esc_attr__( 'Controls the size relations between your headers and your main typography font-size.', 'gridd-plus' ), - 'section' => 'gridd_typography', - 'default' => '1.26', - 'choices' => $scales, - 'transport' => 'postMessage', - 'priority' => 79, - 'preset' => $scales_presets, + 'settings' => 'gridd_type_scale', + 'label' => esc_attr__( 'Typography Scale', 'gridd-plus' ), + 'description' => esc_attr__( 'Controls the size relations between your headers and your main typography font-size.', 'gridd-plus' ), + 'section' => 'gridd_typography', + 'default' => '1.26', + 'transport' => 'postMessage', + 'output' => [ + [ + 'element' => ':root', + 'property' => '--gridd-typo-scale', + ], + get_theme_mod( 'disable_editor_styles' ) ? [] : [ + 'element' => '.edit-post-visual-editor.editor-styles-wrapper', + 'property' => '--gridd-typo-scale', + 'context' => [ 'editor' ], + ], + ], + 'priority' => 80, + 'choices' => [ + 'min' => 1, + 'max' => 2.5, + 'step' => 0.001, + ], + 'priority' => 80, + 'sanitize_callback' => function( $value ) { + return is_numeric( $value ) ? $value : '1.26'; + }, ] ); - -// Customizer::add_field( -// [ -// 'settings' => 'gridd_links_decoration', -// 'type' => 'radio', -// 'label' => esc_attr__( 'Links decoration', 'gridd-plus' ), -// 'description' => esc_html__( 'Select if you want links to be underlined or not. For increased accessibility it is recommended to underline links as this offers a more clear visual queue.', 'gridd-plus' ), -// 'section' => 'gridd_typography', -// 'default' => 'underline', -// 'priority' => 110, -// 'css_vars' => '--ltd', -// 'transport' => 'postMessage', -// 'choices' => [ -// 'none' => esc_attr__( 'None', 'gridd-plus' ), -// 'underline' => esc_attr__( 'Underline', 'gridd-plus' ), -// ], -// ] -// ); - -// Customizer::add_field( -// [ -// 'settings' => 'gridd_header_links_decoration', -// 'type' => 'radio', -// 'label' => esc_attr__( 'Header Links Decoration', 'gridd-plus' ), -// 'description' => esc_html__( 'Select if you want links inside headers to be underlined or not.', 'gridd-plus' ), -// 'section' => 'gridd_typography', -// 'default' => 'none', -// 'priority' => 120, -// 'css_vars' => '--hltd', -// 'transport' => 'postMessage', -// 'choices' => [ -// 'none' => esc_attr__( 'None', 'gridd-plus' ), -// 'underline' => esc_attr__( 'Underline', 'gridd-plus' ), -// ], -// ] -// ); diff --git a/inc/templates/nested-grid.php b/inc/templates/nested-grid.php deleted file mode 100644 index c64862f..0000000 --- a/inc/templates/nested-grid.php +++ /dev/null @@ -1,68 +0,0 @@ -add_string( - Grid::get_styles_responsive( - [ - 'context' => "nested-grid-$id", - 'large' => $settings, - 'small' => false, - 'breakpoint' => get_theme_mod( 'gridd_mobile_breakpoint', '800px' ), - 'selector' => '.gridd-tp-nested-grid-1 > .inner', - 'prefix' => true, - ] - ) -); -$style->add_file( GRIDD_PLUS_PATH . '/assets/css/nested-grid-default.min.css' ); - -// Add styles for large screens. -$style->add_string( '@media only screen and (min-width:' . get_theme_mod( 'gridd_mobile_breakpoint', '800px' ) . '){' ); -$style->add_file( GRIDD_PLUS_PATH . '/assets/css/nested-grid-large.min.css' ); -$style->add_string( '}' ); - -// Generate grid styles for parts. -$style->add_string( Grid::get_styles( $settings, "gridd-tp-nested-grid-$id > .inner", true ) ); -$style->replace( 'ID', $id ); -$style->add_vars( - [ - "gridd-nested-grid-$id-background" => get_theme_mod( "gridd_nested_grid_{$id}_background_color", '#ffffff' ), - "gridd-nested-grid-$id-padding" => get_theme_mod( "gridd_nested_grid_{$id}_padding", 0 ), - "gridd-nested-grid-$id-box-shadow" => get_theme_mod( "gridd_nested_grid_{$id}_box_shadow", 'none' ), - "gridd-nested-grid-$id-max-width" => get_theme_mod( "gridd_nested_grid_{$id}_max_width", '' ), - "gridd-nested-grid-$id-grid-gap" => get_theme_mod( "gridd_nested_grid_{$id}_gap", 0 ), - ] -); -?> -
- the_css( 'gridd-inline-css-nested-grid-' . $id ); - ?> -
- - - - - -
-
diff --git a/inc/templates/offcanvas-sidebar.php b/inc/templates/offcanvas-sidebar.php deleted file mode 100644 index 60850eb..0000000 --- a/inc/templates/offcanvas-sidebar.php +++ /dev/null @@ -1,43 +0,0 @@ - - [ 'offcanvas-sidebar' ], - 'expanded_state_id' => 'griddPlusOffcanvasSidebar', - 'expanded' => 'false', - 'label' => '' . esc_html__( 'Toggle Sidebar', 'gridd-plus' ) . '', - 'classes' => [ 'toggle-gridd-plus-offcanvas-sidebar', 'position-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) ], - ] -); -?> - -
'gridd-tp gridd-tp-sidebar gridd-tp-offcanvas-sidebar position-' . get_theme_mod( 'gridd_pluss_offcanvas_sidebar_position', 'left' ) ], 'wrapper-offcanvas-sidebar' ); ?>> - add_file( GRIDD_PLUS_PATH . '/assets/css/grid-part-offcanvas-sidebar.min.css' ); - $style->the_css( 'gridd-inline-css-offcanvas-sidebar' ); - ?> - -
diff --git a/inc/updater/updater.php b/inc/updater/updater.php index 31babc0..2895f93 100755 --- a/inc/updater/updater.php +++ b/inc/updater/updater.php @@ -40,13 +40,13 @@ function() { $edd_updater = new EDD_SL_Plugin_Updater( WPLEMON_STORE_URL, GRIDD_PLUS_PLUGIN_FILE, - array( + [ 'version' => GRIDD_PLUS_VERSION, 'license' => trim( get_option( GRIDD_PLUS_PLUGIN_DB_PREFIX . '_key' ) ), 'item_id' => 3438, 'author' => 'Ari Stathopoulos', 'beta' => false, - ) + ] ); }, 0 @@ -183,21 +183,21 @@ function() { $license = trim( get_option( GRIDD_PLUS_PLUGIN_DB_PREFIX . '_key' ) ); // Data to send in our API request. - $api_params = array( + $api_params = [ 'edd_action' => 'activate_license', 'license' => $license, 'item_name' => urlencode( GRIDD_PLUS_ITEM_NAME ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions 'url' => home_url(), - ); + ]; // Call the custom API. $response = wp_remote_post( WPLEMON_STORE_URL, - array( + [ 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, - ) + ] ); // Make sure the response came back okay. @@ -257,10 +257,10 @@ function() { if ( ! empty( $message ) ) { $base_url = admin_url( 'plugins.php?page=' . GRIDD_PLUS_PLUGIN_LICENSE_PAGE ); $redirect = add_query_arg( - array( + [ 'sl_activation' => 'false', 'message' => urlencode( $message ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions - ), + ], $base_url ); @@ -291,21 +291,21 @@ function() { $license = trim( get_option( GRIDD_PLUS_PLUGIN_DB_PREFIX . '_key' ) ); // Data to send in our API request. - $api_params = array( + $api_params = [ 'edd_action' => 'deactivate_license', 'license' => $license, 'item_name' => urlencode( GRIDD_PLUS_ITEM_NAME ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions 'url' => home_url(), - ); + ]; // Call the custom API. $response = wp_remote_post( WPLEMON_STORE_URL, - array( + [ 'timeout' => 15, 'sslverify' => false, 'body' => $api_params, - ) + ] ); // Make sure the response came back okay. @@ -318,10 +318,10 @@ function() { $base_url = admin_url( 'plugins.php?page=' . GRIDD_PLUS_PLUGIN_LICENSE_PAGE ); $redirect = add_query_arg( - array( + [ 'sl_activation' => 'false', 'message' => urlencode( $message ), // phpcs:ignore WordPress.PHP.DiscouragedPHPFunctions - ), + ], $base_url ); diff --git a/package.json b/package.json index a10ce0b..de162d7 100644 --- a/package.json +++ b/package.json @@ -34,5 +34,9 @@ "grunt-wp-i18n": "*", "postcss-clean": "*", "postcss-cssnext": "*" + }, + "scripts": { + "cloneACF": "rm -rf inc/acf && git clone git@github.com:wplemon/acf-pro.git inc/acf", + "build": "composer install --no-dev && npm run cloneACF && grunt" } } diff --git a/phpcs.xml.dist b/phpcs.xml.dist index 61708a3..15bde4d 100755 --- a/phpcs.xml.dist +++ b/phpcs.xml.dist @@ -27,7 +27,10 @@ . - + + + +