diff --git a/includes/plugins/kirki/.codeclimate.yml b/includes/plugins/kirki/.codeclimate.yml new file mode 100644 index 0000000..68a859b --- /dev/null +++ b/includes/plugins/kirki/.codeclimate.yml @@ -0,0 +1,10 @@ +languages: + Ruby: false + JavaScript: true + PHP: true +exclude_paths: + - "assets/*" + - "sample-config.php" + - "kirki-user-tests.php" + - "tests/*" + - "bin/*" diff --git a/includes/plugins/kirki/.coveralls.yml b/includes/plugins/kirki/.coveralls.yml new file mode 100644 index 0000000..2c3f292 --- /dev/null +++ b/includes/plugins/kirki/.coveralls.yml @@ -0,0 +1,3 @@ +coverage_clover: build/logs/clover.xml +service_name: travis-ci +src_dir: . diff --git a/includes/plugins/kirki/.editorconfig b/includes/plugins/kirki/.editorconfig new file mode 100644 index 0000000..0a198c7 --- /dev/null +++ b/includes/plugins/kirki/.editorconfig @@ -0,0 +1,25 @@ +# This file is for unifying the coding style for different editors and IDEs +# editorconfig.org + +# WordPress Coding Standards +# http://make.wordpress.org/core/handbook/coding-standards/ + +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +indent_style = tab + +[*.json] +indent_style = space +indent_size = 2 + +[*.css] +indent_style = space +indent_size = 2 + +[*.txt] +end_of_line = crlf diff --git a/includes/plugins/kirki/.gitignore b/includes/plugins/kirki/.gitignore new file mode 100644 index 0000000..01c4c50 --- /dev/null +++ b/includes/plugins/kirki/.gitignore @@ -0,0 +1,18 @@ +# npm # +####### +node_modules +npm-debug.log + +# grunt-contrib-sass # +###################### +.sass-cache + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db \ No newline at end of file diff --git a/includes/plugins/kirki/.simplecov b/includes/plugins/kirki/.simplecov new file mode 100644 index 0000000..3acacc8 --- /dev/null +++ b/includes/plugins/kirki/.simplecov @@ -0,0 +1,7 @@ +require 'simplecov' +require 'coveralls' + +SimpleCov.formatter = Coveralls::SimpleCov::Formatter +SimpleCov.start do + add_filter "/test/" +end diff --git a/includes/plugins/kirki/.travis.yml b/includes/plugins/kirki/.travis.yml new file mode 100644 index 0000000..379a10f --- /dev/null +++ b/includes/plugins/kirki/.travis.yml @@ -0,0 +1,40 @@ +language: php + +sudo: false + +notifications: + on_success: never + on_failure: change + +php: + - 5.3 + - 5.4 + - 5.5 + - 5.6 + - hhvm + - nightly + +env: + - WP_VERSION=latest WP_MULTISITE=0 + +matrix: + include: + - php: 5.3 + env: WP_VERSION=latest WP_MULTISITE=1 + +before_script: + - bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION + - curl -s http://getcomposer.org/installer | php + - php composer.phar install --dev --no-interaction + +script: + - mkdir -p build/logs + - phpunit --coverage-clover build/logs/clover.xml + - find . \( -name '*kirki*.php' \) -exec php -lf {} \; + +after_script: + - php vendor/bin/coveralls -v + +after_success: + - coveralls + - bash <(curl -s https://codecov.io/bash) diff --git a/includes/plugins/kirki/Gruntfile.js b/includes/plugins/kirki/Gruntfile.js new file mode 100644 index 0000000..c794cd9 --- /dev/null +++ b/includes/plugins/kirki/Gruntfile.js @@ -0,0 +1,22 @@ +'use strict'; +module.exports = function(grunt) { + + grunt.initConfig({ + sass: { + dist: { + files: [{ + expand: true, + cwd: 'includes/controls/', + src: ['**/*.scss'], + dest: 'includes/controls/', + ext: '.css' + }] + } + } + }); + + grunt.loadNpmTasks('grunt-contrib-sass'); + + grunt.registerTask('default', ['sass']); + +}; diff --git a/includes/plugins/kirki/LICENSE b/includes/plugins/kirki/LICENSE old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/README.md b/includes/plugins/kirki/README.md new file mode 100644 index 0000000..d9042e2 --- /dev/null +++ b/includes/plugins/kirki/README.md @@ -0,0 +1,61 @@ +# [Kirki](http://kirki.org) # + +[![Build Status](https://travis-ci.org/reduxframework/kirki.svg?branch=master)](https://travis-ci.org/reduxframework/kirki) [![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/reduxframework/kirki/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/reduxframework/kirki/?branch=master) [![Code Climate](https://codeclimate.com/github/aristath/kirki/badges/gpa.svg)](https://codeclimate.com/github/aristath/kirki) [![Coverage Status](https://coveralls.io/repos/reduxframework/kirki/badge.svg?branch=master)](https://coveralls.io/r/reduxframework/kirki?branch=master) [![License](https://img.shields.io/badge/license-GPL--2.0%2B-red.svg)](https://raw.githubusercontent.com/reduxframework/kirki/master/LICENSE) + +## The Kirki Toolkit + +Kirki allows developers to add advanced controls to their customizer as well as customize the way the customizer looks and feels. + +You can add beautiful options to your theme's customizer panel and allow your users to tweak any aspect of their theme. +You've got 23 control types that you can use, [styling options for the customizer](https://github.com/reduxframework/kirki/wiki/Styling-the-Customizer), as well as [automatic calculations for your styles](https://github.com/reduxframework/kirki/wiki/output) using the `output` argument on your controls. + +You can use the default WordPress customizer syntax or one of the 2 alternative syntaxes that we have provided for you. Each project has different needs and we understand that, so the choice is up to you. + +Converting from the default customizer to the syntax used by Kirki will only take a few minutes and will save you a lot of time in the long run. :) + +The following controls are included in the Kirki Toolkit: + +* checkbox +* color-alpha +* color +* custom +* dropdown-pages +* editor +* image +* multicheck +* number +* palette +* radio-buttonset +* radio-image +* radio +* select +* select2 +* select2-multiple +* slider +* sortable +* switch +* text +* textarea +* toggle +* upload + +For documentation and examples on how to use these controls, please visit [kirki.org](http://kirki.org/#fields). + + +## Installation + +### Method 1: Use as a plugin +From your dashboard go to Plugins => Add New. +Search for "Kirki" and install it. +Once you install it, activate it. +For configuration instructions please visit [the wiki](https://github.com/reduxframework/kirki/wiki) + +### Method 2: Embed in your theme +Please visit [the wiki page](https://github.com/reduxframework/kirki/wiki/Embedding-in-a-theme) for documentation and instructions. + + +### Sample data + +The 2 last lines on the [kirki.php](https://github.com/reduxframework/kirki/blob/master/kirki.php) file are commented-out but if you uncomment them you will see your customizer flood with dummy controls. + +[Changelog](https://github.com/aristath/kirki/wiki/Changelog) diff --git a/includes/plugins/kirki/assets/css/customizer.css b/includes/plugins/kirki/assets/css/customizer.css old mode 100755 new mode 100644 index 92ac535..b6df8e0 --- a/includes/plugins/kirki/assets/css/customizer.css +++ b/includes/plugins/kirki/assets/css/customizer.css @@ -73,7 +73,7 @@ li.customize-control { display: block; position: absolute; top: 5px; - right: -20px; + right: -10px; border-radius: 50%; color: #999; border: none; @@ -81,344 +81,10 @@ li.customize-control { width: 20px; height: 20px; } -.customize-control-radio-image .image.ui-buttonset input[type=radio] { - height: auto; } -.customize-control-radio-image .image.ui-buttonset label { - border: 1px solid transparent; - display: inline-block; - margin-right: 5px; - margin-bottom: 5px; } - .customize-control-radio-image .image.ui-buttonset label.ui-state-active { - background: none; - border-color: #333; } - -.customize-control-multicheck input[type="checkbox"] { - position: relative; - margin: 0 1rem 0 0; - cursor: pointer; - margin-bottom: 5px; - width: 22px; - height: 22px; } - .customize-control-multicheck input[type="checkbox"]:before { - content: ""; - position: absolute; - left: 0; - z-index: 1; - width: 100%; - height: 100%; - border: none; } - .customize-control-multicheck input[type="checkbox"]:after { - content: ""; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background: #fff; - cursor: pointer; } - .customize-control-multicheck input[type="checkbox"]:checked:before { - border: 4px solid #4caf50; - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); - width: 14px; - height: 6px; - top: 6px; - left: 5px; - border-top-style: none; - border-right-style: none; } - .customize-control-multicheck input[type="checkbox"]:checked:after { - background: #f2f2f2; } - -.customize-control-checkbox input[type="checkbox"] { - position: relative; - margin: 0 1rem 0 0; - cursor: pointer; - margin-bottom: 5px; - width: 22px; - height: 22px; } - .customize-control-checkbox input[type="checkbox"]:before { - content: ""; - position: absolute; - left: 0; - z-index: 1; - width: 100%; - height: 100%; - border: none; } - .customize-control-checkbox input[type="checkbox"]:after { - content: ""; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background: #fff; - cursor: pointer; } - .customize-control-checkbox input[type="checkbox"]:checked:before { - border: 4px solid #4caf50; - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); - width: 14px; - height: 6px; - top: 6px; - left: 5px; - border-top-style: none; - border-right-style: none; } - .customize-control-checkbox input[type="checkbox"]:checked:after { - background: #f2f2f2; } - -.customize-control-radio-buttonset label { - padding: 5px 10px; - background: #f7f7f7; - border-left: 1px solid #dedede; } - .customize-control-radio-buttonset label.ui-state-active { - background: #dedede; } - .customize-control-radio-buttonset label.ui-corner-left { - border-radius: 3px 0 0 3px; - border-left: 0; } - .customize-control-radio-buttonset label.ui-corner-right { - border-radius: 0 3px 3px 0; } - -.customize-control-switch .Switch, -.customize-control-toggle .Switch { - position: relative; - display: inline-block; - font-size: 16px; - font-weight: bold; - color: #aaa; - height: 18px; - line-height: 27px; - padding: 6px; - border: 1px solid #ccc; - border: 1px solid rgba(0, 0, 0, 0.2); - background: #f2f2f2; - cursor: pointer; - float: right; - transition: all 0.15s ease-in-out; } - .customize-control-switch .Switch .Toggle, - .customize-control-toggle .Switch .Toggle { - position: absolute; - top: 1px; - width: 37px; - height: 25px; - border: 1px solid #aaa; - border: 1px solid rgba(0, 0, 0, 0.2); - background: #fff; - z-index: 989; - transition: all 0.15s ease-in-out; } - .customize-control-switch .Switch .On, - .customize-control-switch .Switch .Off, - .customize-control-toggle .Switch .On, - .customize-control-toggle .Switch .Off { - display: inline-block; - width: 35px; - position: relative; - top: -5px; } - .customize-control-switch .Switch .On, - .customize-control-toggle .Switch .On { - color: #333; } - .customize-control-switch .Switch.On .Toggle, - .customize-control-toggle .Switch.On .Toggle { - left: 54%; } - .customize-control-switch .Switch.Off .Toggle, - .customize-control-toggle .Switch.Off .Toggle { - left: 2%; } - .customize-control-switch .Switch.Round, - .customize-control-toggle .Switch.Round { - padding: 0 20px; - border-radius: 40px; - margin-top: 5px; } - .customize-control-switch .Switch.Round .Toggle, - .customize-control-toggle .Switch.Round .Toggle { - border-radius: 40px; - width: 14px; - height: 14px; } - .customize-control-switch .Switch.Round.Off .Toggle, - .customize-control-toggle .Switch.Round.Off .Toggle { - left: 3%; } - .customize-control-switch .Switch.Round.On, - .customize-control-toggle .Switch.Round.On { - color: #fff; - background: #333; } - .customize-control-switch .Switch.Round.On .Toggle, - .customize-control-toggle .Switch.Round.On .Toggle { - left: 58%; } - -body.IE7 .Switch { - width: 78px; } - -body.IE7 .Switch.Round { - width: 1px; } - -.customize-control-sortable ul.ui-sortable li { - padding: 5px 10px; - border: 1px solid #333; - background: #fff; } - .customize-control-sortable ul.ui-sortable li .dashicons.dashicons-menu { - float: right; } - .customize-control-sortable ul.ui-sortable li .dashicons.visibility { - margin-right: 10px; } - .customize-control-sortable ul.ui-sortable li.invisible { - color: #aaa; - border: 1px dashed #aaa; } - .customize-control-sortable ul.ui-sortable li.invisible .dashicons.visibility { - color: #aaa; } - -.customize-control-palette label.ui-button.ui-widget { - width: 95%; - background: none; - padding: 0; } - .customize-control-palette label.ui-button.ui-widget .ui-button-text { - border-top: 3px solid transparent; - border-bottom: 3px solid transparent; - margin-bottom: 5px; - display: flex; } - .customize-control-palette label.ui-button.ui-widget .ui-button-text span { - padding: 10px 0; - flex-grow: 1; - font-size: 0; - line-height: 10px; - color: transparent; - -webkit-transition: all 200ms ease-in-out; - -moz-transition: all 200ms ease-in-out; - -ms-transition: all 200ms ease-in-out; - -o-transition: all 200ms ease-in-out; - transition: all 200ms ease-in-out; } - .customize-control-palette label.ui-button.ui-widget .ui-button-text span:hover { - padding: 10px; - flex-grow: 3; - min-width: 60px; - font-size: 10px; - line-height: 10px; - color: #000; } -.customize-control-palette label.ui-state-active.ui-button.ui-widget span.ui-button-text { - border: 3px solid #333; } - -.customize-control-slider input[type="text"] { - border: none; - text-align: center; - padding: 0; - margin: 0; - font-size: 12px; - box-shadow: none; - color: #333; } -.customize-control-slider .ui-slider { - position: relative; - text-align: left; - height: 7px; - border-radius: 3px; - background: #f2f2f2; - border: 1px solid #dedede; - margin-top: 10px; - margin-bottom: 20px; } - .customize-control-slider .ui-slider .ui-slider-handle { - position: absolute; - z-index: 2; - width: 15px; - height: 15px; - top: -5px; - border-radius: 50%; - cursor: default; - -ms-touch-action: none; - touch-action: none; - background: #333; - border: 1px solid #333; } - .customize-control-slider .ui-slider .ui-slider-range { - position: absolute; - z-index: 1; - font-size: 0.7em; - display: block; - border: 0; - background-position: 0 0; } - -.customize-control-color-alpha .kirki-alpha-container { - box-sizing: padding-box; - display: none; - border: 1px solid #dfdfdf; - border-top: none; - background: #fff; - padding: 0 11px 6px; } - .customize-control-color-alpha .kirki-alpha-container .transparency { - height: 24px; - width: 100%; - background-color: #fff; - background-image: url("../images/transparency-grid.png"); - box-shadow: 0 0 5px rgba(0, 0, 0, 0.4) inset; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - padding: 0; } - .customize-control-color-alpha .kirki-alpha-container .ui-slider-handle { - color: #777; - background-color: #fff; - text-shadow: 0 1px 0 #fff; - text-decoration: none; - position: absolute; - z-index: 2; - box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); - border: 1px solid #aaa; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - opacity: 0.9; - margin-top: -2px; - height: 20px; - cursor: ew-resize; - font-size: 12px; - padding: 3px; } - .customize-control-color-alpha .kirki-alpha-container .ui-slider { - position: relative; - text-align: center; - width: 88%; } -.customize-control-color-alpha .wp-picker-container a.wp-picker-open ~ div.kirki-alpha-container { - display: block; } -.customize-control-color-alpha .customize-control-alphacolor .wp-picker-container .iris-picker { - border-bottom: none; } - -.customize-control-number .stepper { - border-radius: 0px; - margin: 0 0 10px 0; - overflow: hidden; - position: relative; - width: 50%; } - .customize-control-number .stepper .stepper-input { - background: #F9F9F9; - border: 1px solid #ccc; - border-radius: 0px; - color: #333; - font-size: 13px; - line-height: 1.2; - margin: 0; - overflow: hidden; - padding: 9px 10px 10px; - width: 100%; - z-index: 49; - -moz-appearance: textfield; } - .customize-control-number .stepper .stepper-input::-webkit-inner-spin-button, .customize-control-number .stepper .stepper-input::-webkit-outer-spin-button { - -webkit-appearance: none; - margin: 0; } - .customize-control-number .stepper .stepper-input:focus { - background-color: #fff; } - .customize-control-number .stepper .stepper-arrow { - background: #eee url("../images/jquery.fs.stepper-arrows.png") no-repeat; - border: 1px solid #ccc; - cursor: pointer; - display: block; - height: 50%; - position: absolute; - right: 0; - text-indent: -99999px; - width: 20px; - z-index: 50; } - .customize-control-number .stepper .stepper-arrow.up { - background-position: center top; - border-bottom: none; - top: 0; } - .customize-control-number .stepper .stepper-arrow.down { - background-position: center bottom; - bottom: 0; } +.select2-container { + min-width: 100px; + width: 100% !important; } + .select2-container--open .select2-dropdown--below, + .select2-container--open .select2-dropdown--above { + z-index: 9999999; + min-width: 100px; } diff --git a/includes/plugins/kirki/assets/css/customizer.scss b/includes/plugins/kirki/assets/css/customizer.scss index 1e41786..54d822e 100644 --- a/includes/plugins/kirki/assets/css/customizer.scss +++ b/includes/plugins/kirki/assets/css/customizer.scss @@ -1,49 +1,3 @@ -@mixin custom-checkbox() { - position: relative; - margin: 0 1rem 0 0; - cursor: pointer; - margin-bottom: 5px; - width: 22px; - height: 22px; - &:before { - content: ""; - position: absolute; - left: 0; - z-index: 1; - width: 100%; - height: 100%; - border: none; - } - &:after { - content: ""; - position: absolute; - left: 0; - top: 0; - width: 100%; - height: 100%; - background: #fff; - cursor: pointer; - } - &:checked { - &:before { - border: 4px solid #4caf50; - -webkit-transform: rotate(-45deg); - -moz-transform: rotate(-45deg); - -ms-transform: rotate(-45deg); - -o-transform: rotate(-45deg); - transform: rotate(-45deg); - width: 14px; - height: 6px; - top: 6px; - left: 5px; - border-top-style: none; - border-right-style: none; - } - &:after { - background: #f2f2f2; - } - } -} // Generic styles #customize-controls { #customize-header-actions { @@ -148,7 +102,7 @@ li.customize-control { display: block; position: absolute; top: 5px; - right: -20px; + right: -10px; border-radius: 50%; color: #999; border: none; @@ -157,350 +111,15 @@ li.customize-control { height: 20px; } } -// Radio-Image Controls -.customize-control-radio-image { - .image.ui-buttonset { - input[type=radio] { - height: auto; - } - label { - border: 1px solid transparent; - display: inline-block; - margin-right: 5px; - margin-bottom: 5px; - &.ui-state-active { - background: none; - border-color: #333; - } - } - } -} -// Multicheck Controls -.customize-control-multicheck { - input[type="checkbox"] { - @include custom-checkbox(); - } -} -// Checkbox Controls -// Multicheck Controls -.customize-control-checkbox { - input[type="checkbox"] { - @include custom-checkbox(); - } -} -// Radio-Buttonset Controls -.customize-control-radio-buttonset { - input[type=radio] { - } - label { - padding: 5px 10px; - background: #f7f7f7; - border-left: 1px solid #dedede; - &.ui-state-active { - background: #dedede; - } - &.ui-corner-left { - border-radius: 3px 0 0 3px; - border-left: 0; - } - &.ui-corner-right { - border-radius: 0 3px 3px 0; - } - } -} -// Switch & toggle Controls -.customize-control-switch, -.customize-control-toggle { - .Switch { - position: relative; - display: inline-block; - font-size: 16px; - font-weight: bold; - color: #aaa; - height: 18px; - line-height: 27px; - padding: 6px; - border: 1px solid #ccc; - border: 1px solid rgba(0,0,0,0.2); - background: #f2f2f2; - cursor: pointer; - float: right; - transition: all 0.15s ease-in-out; - .Toggle { - position: absolute; - top: 1px; - width: 37px; - height: 25px; - border: 1px solid #aaa; - border: 1px solid rgba(0,0,0,0.2); - background: #fff; - z-index: 989; - transition: all 0.15s ease-in-out; - } - .On, - .Off { - display: inline-block; - width: 35px; - position: relative; - top: -5px; - } - .On { - color: #333; - } - &.On { - .Toggle { - left: 54%; - } - } - &.Off { - .Toggle { - left: 2%; - } - } - &.Round { - padding: 0 20px; - border-radius: 40px; - margin-top: 5px; - .Toggle { - border-radius: 40px; - width: 14px; - height: 14px; - } - &.Off { - .Toggle { - left: 3%; - } - } - &.On { - color: #fff; - background: #333; - .Toggle { - left: 58%; - } - } - } - } -} -body.IE7 .Switch { - width: 78px; -} -body.IE7 .Switch.Round { - width: 1px; -} -// Sortable Controls -.customize-control-sortable { - ul.ui-sortable { - li { - padding: 5px 10px; - border: 1px solid #333; - background: #fff; - .dashicons { - &.dashicons-menu { - float: right; - } - &.visibility { - margin-right: 10px; - } - } - &.invisible { - color: #aaa; - border: 1px dashed #aaa; - .dashicons.visibility { - color: #aaa; - } - } - } - } -} -// Palette controls -.customize-control-palette { - label { - &.ui-button.ui-widget { - width: 95%; - background: none; - padding: 0; - .ui-button-text { - border-top: 3px solid transparent; - border-bottom: 3px solid transparent; - margin-bottom: 5px; - display: flex; - span { - padding: 10px 0; - flex-grow: 1; - font-size: 0; - line-height: 10px; - color: rgba(0,0,0,0); - -webkit-transition: all 200ms ease-in-out; - -moz-transition: all 200ms ease-in-out; - -ms-transition: all 200ms ease-in-out; - -o-transition: all 200ms ease-in-out; - transition: all 200ms ease-in-out; - &:hover { - padding: 10px; - flex-grow: 3; - min-width: 60px; - font-size: 10px; - line-height: 10px; - color: #000; - } - } - } - } - &.ui-state-active { - &.ui-button.ui-widget { - span.ui-button-text { - border: 3px solid #333; - } - } - } - } -} -// Slider Controls -.customize-control-slider { - input[type="text"] { - border: none; - text-align: center; - padding: 0; - margin: 0; - font-size: 12px; - box-shadow: none; - color: #333; - } - .ui-slider { - position: relative; - text-align: left; - height: 7px; - border-radius: 3px; - background: #f2f2f2; - border: 1px solid #dedede; - margin-top: 10px; - margin-bottom: 20px; - .ui-slider-handle { - position: absolute; - z-index: 2; - width: 15px; - height: 15px; - top: -5px; - border-radius: 50%; - cursor: default; - -ms-touch-action: none; - touch-action: none; - background: #333; - border: 1px solid #333; - } - .ui-slider-range { - position: absolute; - z-index: 1; - font-size: 0.7em; - display: block; - border: 0; - background-position: 0 0; - } - } -} -// Color-Alpha Controls -.customize-control-color-alpha { - .kirki-alpha-container { - box-sizing: padding-box; - display: none; - border: 1px solid #dfdfdf; - border-top: none; - background: #fff; - padding: 0 11px 6px; - .transparency { - height: 24px; - width: 100%; - background-color: #fff; - background-image: url("../images/transparency-grid.png"); - box-shadow: 0 0 5px rgba(0,0,0,0.4) inset; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - padding: 0; - } - .ui-slider-handle { - color: #777; - background-color: #fff; - text-shadow: 0 1px 0 #fff; - text-decoration: none; - position: absolute; - z-index: 2; - box-shadow: 0 1px 2px rgba(0,0,0,0.2); - border: 1px solid #aaa; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - opacity: 0.9; - margin-top: -2px; - height: 20px; - cursor: ew-resize; - font-size: 12px; - padding: 3px; - } - .ui-slider { - position: relative; - text-align: center; - width: 88%; - } - } - .wp-picker-container a.wp-picker-open ~ div.kirki-alpha-container { - display: block; - } - .customize-control-alphacolor .wp-picker-container .iris-picker { - border-bottom: none; - } -} - -// Number Controls -.customize-control-number { - .stepper { - border-radius: 0px; - margin: 0 0 10px 0; - overflow: hidden; - position: relative; - width: 50%; - .stepper-input { - background: #F9F9F9; - border: 1px solid #ccc; - border-radius: 0px; - color: #333; - font-size: 13px; - line-height: 1.2; - margin: 0; - overflow: hidden; - padding: 9px 10px 10px; - width: 100%; - z-index: 49; - -moz-appearance: textfield; - &::-webkit-inner-spin-button, - &::-webkit-outer-spin-button { - -webkit-appearance: none; margin: 0; - } - &:focus { - background-color: #fff; - } - } - .stepper-arrow { - background: #eee url("../images/jquery.fs.stepper-arrows.png") no-repeat; - border: 1px solid #ccc; - cursor: pointer; - display: block; - height: 50%; - position: absolute; - right: 0; - text-indent: -99999px; - width: 20px; - z-index: 50; - &.up { - background-position: center top; - border-bottom: none; - top: 0; - } - &.down { - background-position: center bottom; - bottom: 0; - } - } - } +.select2-container { + min-width: 100px; + width: 100% !important; + &--open { + .select2-dropdown--below, + .select2-dropdown--above { + z-index: 9999999; + min-width: 100px; + } + } } diff --git a/includes/plugins/kirki/assets/css/jquery-ui-1.10.0.custom.css b/includes/plugins/kirki/assets/css/jquery-ui-1.10.0.custom.css deleted file mode 100755 index e69de29..0000000 diff --git a/includes/plugins/kirki/assets/css/select2.min.css b/includes/plugins/kirki/assets/css/select2.min.css new file mode 100644 index 0000000..b4ba6bb --- /dev/null +++ b/includes/plugins/kirki/assets/css/select2.min.css @@ -0,0 +1 @@ +.select2-container{box-sizing:border-box;display:inline-block;margin:0;position:relative;vertical-align:middle;}.select2-container .select2-selection--single{box-sizing:border-box;cursor:pointer;display:block;height:28px;user-select:none;-webkit-user-select:none;}.select2-container .select2-selection--single .select2-selection__rendered{display:block;padding-left:8px;padding-right:20px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}.select2-container[dir="rtl"] .select2-selection--single .select2-selection__rendered{padding-right:8px;padding-left:20px;}.select2-container .select2-selection--multiple{box-sizing:border-box;cursor:pointer;display:block;min-height:32px;user-select:none;-webkit-user-select:none;}.select2-container .select2-selection--multiple .select2-selection__rendered{display:inline-block;overflow:hidden;padding-left:8px;text-overflow:ellipsis;white-space:nowrap;}.select2-container .select2-search--inline{float:left;}.select2-container .select2-search--inline .select2-search__field{box-sizing:border-box;border:none;font-size:100%;margin-top:5px;}.select2-container .select2-search--inline .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none;}.select2-dropdown{background-color:white;border:1px solid #aaa;border-radius:4px;box-sizing:border-box;display:block;position:absolute;left:-100000px;width:100%;z-index:1051;}.select2-results{display:block;}.select2-results__options{list-style:none;margin:0;padding:0;}.select2-results__option{padding:6px;user-select:none;-webkit-user-select:none;}.select2-results__option[aria-selected]{cursor:pointer;}.select2-container--open .select2-dropdown{left:0;}.select2-container--open .select2-dropdown--above{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;}.select2-container--open .select2-dropdown--below{border-top:none;border-top-left-radius:0;border-top-right-radius:0;}.select2-search--dropdown{display:block;padding:4px;}.select2-search--dropdown .select2-search__field{padding:4px;width:100%;box-sizing:border-box;}.select2-search--dropdown .select2-search__field::-webkit-search-cancel-button{-webkit-appearance:none;}.select2-search--dropdown.select2-search--hide{display:none;}.select2-close-mask{border:0;margin:0;padding:0;display:block;position:fixed;left:0;top:0;min-height:100%;min-width:100%;height:auto;width:auto;opacity:0;z-index:99;background-color:#fff;filter:alpha(opacity=0);}.select2-hidden-accessible{border:0 !important;clip:rect(0 0 0 0) !important;height:1px !important;margin:-1px !important;overflow:hidden !important;padding:0 !important;position:absolute !important;width:1px !important;}.select2-container--default .select2-selection--single{background-color:#fff;border:1px solid #aaa;border-radius:4px;}.select2-container--default .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px;}.select2-container--default .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;}.select2-container--default .select2-selection--single .select2-selection__placeholder{color:#999;}.select2-container--default .select2-selection--single .select2-selection__arrow{height:26px;position:absolute;top:1px;right:1px;width:20px;}.select2-container--default .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0;}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left;}.select2-container--default[dir="rtl"] .select2-selection--single .select2-selection__arrow{left:1px;right:auto;}.select2-container--default.select2-container--disabled .select2-selection--single{background-color:#eee;cursor:default;}.select2-container--default.select2-container--disabled .select2-selection--single .select2-selection__clear{display:none;}.select2-container--default.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px;}.select2-container--default .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;}.select2-container--default .select2-selection--multiple .select2-selection__rendered{box-sizing:border-box;list-style:none;margin:0;padding:0 5px;width:100%;}.select2-container--default .select2-selection--multiple .select2-selection__placeholder{color:#999;margin-top:5px;float:left;}.select2-container--default .select2-selection--multiple .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-top:5px;margin-right:10px;}.select2-container--default .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px;}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove{color:#999;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px;}.select2-container--default .select2-selection--multiple .select2-selection__choice__remove:hover{color:#333;}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice,.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__placeholder{float:right;}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto;}.select2-container--default[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto;}.select2-container--default.select2-container--focus .select2-selection--multiple{border:solid black 1px;outline:0;}.select2-container--default.select2-container--disabled .select2-selection--multiple{background-color:#eee;cursor:default;}.select2-container--default.select2-container--disabled .select2-selection__choice__remove{display:none;}.select2-container--default.select2-container--open.select2-container--above .select2-selection--single,.select2-container--default.select2-container--open.select2-container--above .select2-selection--multiple{border-top-left-radius:0;border-top-right-radius:0;}.select2-container--default.select2-container--open.select2-container--below .select2-selection--single,.select2-container--default.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom-left-radius:0;border-bottom-right-radius:0;}.select2-container--default .select2-search--dropdown .select2-search__field{border:1px solid #aaa;}.select2-container--default .select2-search--inline .select2-search__field{background:transparent;border:none;outline:0;}.select2-container--default .select2-results>.select2-results__options{max-height:200px;overflow-y:auto;}.select2-container--default .select2-results__option[role=group]{padding:0;}.select2-container--default .select2-results__option[aria-disabled=true]{color:#999;}.select2-container--default .select2-results__option[aria-selected=true]{background-color:#ddd;}.select2-container--default .select2-results__option .select2-results__option{padding-left:1em;}.select2-container--default .select2-results__option .select2-results__option .select2-results__group{padding-left:0;}.select2-container--default .select2-results__option .select2-results__option .select2-results__option{margin-left:-1em;padding-left:2em;}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-2em;padding-left:3em;}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-3em;padding-left:4em;}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-4em;padding-left:5em;}.select2-container--default .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option .select2-results__option{margin-left:-5em;padding-left:6em;}.select2-container--default .select2-results__option--highlighted[aria-selected]{background-color:#5897fb;color:white;}.select2-container--default .select2-results__group{cursor:default;display:block;padding:6px;}.select2-container--classic .select2-selection--single{background-color:#f6f6f6;border:1px solid #aaa;border-radius:4px;outline:0;background-image:-webkit-linear-gradient(top, #ffffff 50%, #eeeeee 100%);background-image:-o-linear-gradient(top, #ffffff 50%, #eeeeee 100%);background-image:linear-gradient(to bottom, #ffffff 50%, #eeeeee 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0);}.select2-container--classic .select2-selection--single:focus{border:1px solid #5897fb;}.select2-container--classic .select2-selection--single .select2-selection__rendered{color:#444;line-height:28px;}.select2-container--classic .select2-selection--single .select2-selection__clear{cursor:pointer;float:right;font-weight:bold;margin-right:10px;}.select2-container--classic .select2-selection--single .select2-selection__placeholder{color:#999;}.select2-container--classic .select2-selection--single .select2-selection__arrow{background-color:#ddd;border:none;border-left:1px solid #aaa;border-top-right-radius:4px;border-bottom-right-radius:4px;height:26px;position:absolute;top:1px;right:1px;width:20px;background-image:-webkit-linear-gradient(top, #eeeeee 50%, #cccccc 100%);background-image:-o-linear-gradient(top, #eeeeee 50%, #cccccc 100%);background-image:linear-gradient(to bottom, #eeeeee 50%, #cccccc 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFCCCCCC', GradientType=0);}.select2-container--classic .select2-selection--single .select2-selection__arrow b{border-color:#888 transparent transparent transparent;border-style:solid;border-width:5px 4px 0 4px;height:0;left:50%;margin-left:-4px;margin-top:-2px;position:absolute;top:50%;width:0;}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__clear{float:left;}.select2-container--classic[dir="rtl"] .select2-selection--single .select2-selection__arrow{border:none;border-right:1px solid #aaa;border-radius:0;border-top-left-radius:4px;border-bottom-left-radius:4px;left:1px;right:auto;}.select2-container--classic.select2-container--open .select2-selection--single{border:1px solid #5897fb;}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow{background:transparent;border:none;}.select2-container--classic.select2-container--open .select2-selection--single .select2-selection__arrow b{border-color:transparent transparent #888 transparent;border-width:0 4px 5px 4px;}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--single{border-top:none;border-top-left-radius:0;border-top-right-radius:0;background-image:-webkit-linear-gradient(top, #ffffff 0%, #eeeeee 50%);background-image:-o-linear-gradient(top, #ffffff 0%, #eeeeee 50%);background-image:linear-gradient(to bottom, #ffffff 0%, #eeeeee 50%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFEEEEEE', GradientType=0);}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--single{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;background-image:-webkit-linear-gradient(top, #eeeeee 50%, #ffffff 100%);background-image:-o-linear-gradient(top, #eeeeee 50%, #ffffff 100%);background-image:linear-gradient(to bottom, #eeeeee 50%, #ffffff 100%);background-repeat:repeat-x;filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFEEEEEE', endColorstr='#FFFFFFFF', GradientType=0);}.select2-container--classic .select2-selection--multiple{background-color:white;border:1px solid #aaa;border-radius:4px;cursor:text;outline:0;}.select2-container--classic .select2-selection--multiple:focus{border:1px solid #5897fb;}.select2-container--classic .select2-selection--multiple .select2-selection__rendered{list-style:none;margin:0;padding:0 5px;}.select2-container--classic .select2-selection--multiple .select2-selection__clear{display:none;}.select2-container--classic .select2-selection--multiple .select2-selection__choice{background-color:#e4e4e4;border:1px solid #aaa;border-radius:4px;cursor:default;float:left;margin-right:5px;margin-top:5px;padding:0 5px;}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove{color:#888;cursor:pointer;display:inline-block;font-weight:bold;margin-right:2px;}.select2-container--classic .select2-selection--multiple .select2-selection__choice__remove:hover{color:#555;}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{float:right;}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice{margin-left:5px;margin-right:auto;}.select2-container--classic[dir="rtl"] .select2-selection--multiple .select2-selection__choice__remove{margin-left:2px;margin-right:auto;}.select2-container--classic.select2-container--open .select2-selection--multiple{border:1px solid #5897fb;}.select2-container--classic.select2-container--open.select2-container--above .select2-selection--multiple{border-top:none;border-top-left-radius:0;border-top-right-radius:0;}.select2-container--classic.select2-container--open.select2-container--below .select2-selection--multiple{border-bottom:none;border-bottom-left-radius:0;border-bottom-right-radius:0;}.select2-container--classic .select2-search--dropdown .select2-search__field{border:1px solid #aaa;outline:0;}.select2-container--classic .select2-search--inline .select2-search__field{outline:0;}.select2-container--classic .select2-dropdown{background-color:white;border:1px solid transparent;}.select2-container--classic .select2-dropdown--above{border-bottom:none;}.select2-container--classic .select2-dropdown--below{border-top:none;}.select2-container--classic .select2-results>.select2-results__options{max-height:200px;overflow-y:auto;}.select2-container--classic .select2-results__option[role=group]{padding:0;}.select2-container--classic .select2-results__option[aria-disabled=true]{color:grey;}.select2-container--classic .select2-results__option--highlighted[aria-selected]{background-color:#3875d7;color:white;}.select2-container--classic .select2-results__group{cursor:default;display:block;padding:6px;}.select2-container--classic.select2-container--open .select2-dropdown{border-color:#5897fb;} \ No newline at end of file diff --git a/includes/plugins/kirki/assets/images/1c.png b/includes/plugins/kirki/assets/images/1c.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/images/2cl.png b/includes/plugins/kirki/assets/images/2cl.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/images/2cr.png b/includes/plugins/kirki/assets/images/2cr.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/images/3cl.png b/includes/plugins/kirki/assets/images/3cl.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/images/3cm.png b/includes/plugins/kirki/assets/images/3cm.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/images/3cr.png b/includes/plugins/kirki/assets/images/3cr.png old mode 100755 new mode 100644 diff --git a/includes/plugins/kirki/assets/js/customizer.js b/includes/plugins/kirki/assets/js/customizer.js deleted file mode 100755 index 6890b8e..0000000 --- a/includes/plugins/kirki/assets/js/customizer.js +++ /dev/null @@ -1,215 +0,0 @@ -jQuery.noConflict(); -/** Fire up jQuery - let's dance! */ -jQuery(document).ready(function($) { - $("a.tooltip").tooltip(); -}); - -jQuery(document).ready(function($) { - "use strict"; - // initialize - $('.kirki-sortable > ul ~ input').each(function() { - var value = $(this).val(); - try { - value = unserialize(value); - } catch (err) { - return; - } - var ul = $(this).siblings('ul:eq(0)'); - ul.find('li').addClass('invisible').find('i.visibility').toggleClass('dashicons-visibility-faint'); - $.each(value, function(i, val) { - ul.find('li[data-value=' + val + ']').removeClass('invisible').find('i.visibility').toggleClass('dashicons-visibility-faint'); - }); - }); - $('.kirki-sortable > ul').each(function() { - $(this).sortable() - .disableSelection() - .on("sortstop", function(event, ui) { - kirkiUpdateSortable(ui.item.parent()); - }) - .find('li').each(function() { - $(this).find('i.visibility').click(function() { - $(this).toggleClass('dashicons-visibility-faint').parents('li:eq(0)').toggleClass('invisible'); - }); - }) - .click(function() { - kirkiUpdateSortable($(this).parents('ul:eq(0)')); - }) - }); - - - // Switch Click - $('.Switch').click(function() { - if ($(this).hasClass('On')) { - $(this).parent().find('input:checkbox').attr('checked', true); - $(this).removeClass('On').addClass('Off'); - } else { - $(this).parent().find('input:checkbox').attr('checked', false); - $(this).removeClass('Off').addClass('On'); - } - }); - -}); - -function kirkiUpdateSortable(ul) { - "use strict"; - var $ = jQuery; - var values = []; - ul.find('li').each(function() { - if (!$(this).is('.invisible')) { - values.push($(this).attr('data-value')); - } - }); - ul.siblings('input').eq(0).val(serialize(values)).trigger('change'); -} - - -(function($) { - wp.customizerCtrlEditor = { - - init: function() { - - $(window).load(function() { - - $('textarea.wp-editor-area').each(function() { - var tArea = $(this), - id = tArea.attr('id'), - input = $('input[data-customize-setting-link="' + id + '"]'), - editor = tinyMCE.get(id), - setChange, - content; - - if (editor) { - editor.onChange.add(function(ed, e) { - ed.save(); - content = editor.getContent(); - clearTimeout(setChange); - setChange = setTimeout(function() { - input.val(content).trigger('change'); - }, 500); - }); - } - - if (editor) { - editor.onChange.add(function(ed, e) { - ed.save(); - content = editor.getContent(); - clearTimeout(setChange); - setChange = setTimeout(function() { - input.val(content).trigger('change'); - }, 500); - }); - } - - tArea.css({ - visibility: 'visible' - }).on('keyup', function() { - content = tArea.val(); - clearTimeout(setChange); - setChange = setTimeout(function() { - input.val(content).trigger('change'); - }, 500); - }); - }); - }); - } - - }; - - wp.customizerCtrlEditor.init(); - -})(jQuery); - -jQuery(document).ready(function($) { - - Color.prototype.toString = function(remove_alpha) { - if (remove_alpha == 'no-alpha') { - return this.toCSS('rgba', '1').replace(/\s+/g, ''); - } - if (this._alpha < 1) { - return this.toCSS('rgba', this._alpha).replace(/\s+/g, ''); - } - var hex = parseInt(this._color, 10).toString(16); - if (this.error) return ''; - if (hex.length < 6) { - for (var i = 6 - hex.length - 1; i >= 0; i--) { - hex = '0' + hex; - } - } - return '#' + hex; - }; - - $('.kirki-color-control').each(function() { - var $control = $(this), - value = $control.val().replace(/\s+/g, ''); - // Manage Palettes - var palette_input = $control.attr('data-palette'); - if (palette_input == 'false' || palette_input == false) { - var palette = false; - } else if (palette_input == 'true' || palette_input == true) { - var palette = true; - } else { - var palette = $control.attr('data-palette').split(","); - } - $control.wpColorPicker({ // change some things with the color picker - clear: function(event, ui) { - // TODO reset Alpha Slider to 100 - }, - change: function(event, ui) { - // send ajax request to wp.customizer to enable Save & Publish button - var _new_value = $control.val(); - var key = $control.attr('data-customize-setting-link'); - wp.customize(key, function(obj) { - obj.set(_new_value); - }); - // change the background color of our transparency container whenever a color is updated - var $transparency = $control.parents('.wp-picker-container:first').find('.transparency'); - // we only want to show the color at 100% alpha - $transparency.css('backgroundColor', ui.color.toString('no-alpha')); - }, - palettes: palette // remove the color palettes - }); - $('
').appendTo($control.parents('.wp-picker-container')); - var $alpha_slider = $control.parents('.wp-picker-container:first').find('.slider-alpha'); - // if in format RGBA - grab A channel value - if (value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)) { - var alpha_val = parseFloat(value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]) * 100; - var alpha_val = parseInt(alpha_val); - } else { - var alpha_val = 100; - } - $alpha_slider.slider({ - slide: function(event, ui) { - $(this).find('.ui-slider-handle').text(ui.value); // show value on slider handle - // send ajax request to wp.customizer to enable Save & Publish button - var _new_value = $control.val(); - var key = $control.attr('data-customize-setting-link'); - wp.customize(key, function(obj) { - obj.set(_new_value); - }); - }, - create: function(event, ui) { - var v = $(this).slider('value'); - $(this).find('.ui-slider-handle').text(v); - }, - value: alpha_val, - range: "max", - step: 1, - min: 1, - max: 100 - }); // slider - $alpha_slider.slider().on('slidechange', function(event, ui) { - var new_alpha_val = parseFloat(ui.value), - iris = $control.data('a8cIris'), - color_picker = $control.data('wpWpColorPicker'); - iris._color._alpha = new_alpha_val / 100.0; - $control.val(iris._color.toString()); - color_picker.toggler.css({ - backgroundColor: $control.val() - }); - // fix relationship between alpha slider and the 'side slider not updating. - var get_val = $control.val(); - $($control).wpColorPicker('color', get_val); - }); - }); // each - -}); diff --git a/includes/plugins/kirki/assets/js/jquery.fs.stepper.min.js b/includes/plugins/kirki/assets/js/jquery.fs.stepper.min.js deleted file mode 100644 index 5d2d34e..0000000 --- a/includes/plugins/kirki/assets/js/jquery.fs.stepper.min.js +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Stepper v3.0.7 - 2014-11-25 - * A jQuery plugin for cross browser number inputs. Part of the Formstone Library. - * http://formstone.it/stepper/ - * - * Copyright 2014 Ben Plum; MIT Licensed - */ - -!function(a){"use strict";function b(b){b=a.extend({},l,b||{});for(var d=a(this),e=0,f=d.length;f>e;e++)c(d.eq(e),b);return d}function c(b,c){if(!b.hasClass("stepper-input")){c=a.extend({},c,b.data("stepper-options"));var f=parseFloat(b.attr("min")),g=parseFloat(b.attr("max")),h=parseFloat(b.attr("step"))||1;b.addClass("stepper-input").wrap('
').after(''+c.labels.up+''+c.labels.down+"");var i=b.parent(".stepper"),k=a.extend({$stepper:i,$input:b,$arrow:i.find(".stepper-arrow"),min:void 0===typeof f||isNaN(f)?!1:f,max:void 0===typeof g||isNaN(g)?!1:g,step:void 0===typeof h||isNaN(h)?1:h,timer:null},c);k.digits=j(k.step),b.is(":disabled")&&i.addClass("disabled"),i.on("keypress",".stepper-input",k,d),i.on("touchstart.stepper mousedown.stepper",".stepper-arrow",k,e),b.data("stepper",k)}}function d(a){var b=a.data;(38===a.keyCode||40===a.keyCode)&&(a.preventDefault(),g(b,38===a.keyCode?b.step:-b.step))}function e(b){b.preventDefault(),b.stopPropagation(),f(b);var c=b.data;if(!c.$input.is(":disabled")&&!c.$stepper.hasClass("disabled")){var d=a(b.target).hasClass("up")?c.step:-c.step;c.timer=h(c.timer,125,function(){g(c,d,!1)}),g(c,d),a("body").on("touchend.stepper mouseup.stepper",c,f)}}function f(b){b.preventDefault(),b.stopPropagation();var c=b.data;i(c.timer),a("body").off(".stepper")}function g(a,b){var c=parseFloat(a.$input.val()),d=b;void 0===typeof c||isNaN(c)?d=a.min!==!1?a.min:0:a.min!==!1&&ca.max&&(d-=a.step),d!==c&&(d=k(d,a.digits),a.$input.val(d).trigger("change"))}function h(a,b,c){return i(a),setInterval(c,b)}function i(a){a&&(clearInterval(a),a=null)}function j(a){var b=String(a);return b.indexOf(".")>-1?b.length-b.indexOf(".")-1:0}function k(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}var l={customClass:"",labels:{up:"Up",down:"Down"}},m={defaults:function(b){return l=a.extend(l,b||{}),"object"==typeof this?a(this):!0},destroy:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$stepper.off(".stepper").find(".stepper-arrow").remove(),b.$input.unwrap().removeClass("stepper-input"))})},disable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled","disabled"),b.$stepper.addClass("disabled"))})},enable:function(){return a(this).each(function(){var b=a(this).data("stepper");b&&(b.$input.attr("disabled",null),b.$stepper.removeClass("disabled"))})}};a.fn.stepper=function(a){return m[a]?m[a].apply(this,Array.prototype.slice.call(arguments,1)):"object"!=typeof a&&a?this:b.apply(this,arguments)},a.stepper=function(a){"defaults"===a&&m.defaults.apply(this,Array.prototype.slice.call(arguments,1))}}(jQuery,this); \ No newline at end of file diff --git a/includes/plugins/kirki/assets/js/kirki-tooltip.js b/includes/plugins/kirki/assets/js/kirki-tooltip.js new file mode 100644 index 0000000..a1dc562 --- /dev/null +++ b/includes/plugins/kirki/assets/js/kirki-tooltip.js @@ -0,0 +1,4 @@ +/** Fire up jQuery - let's dance! */ +jQuery(document).ready(function($) { + $("a.tooltip").tooltip(); +}); diff --git a/includes/plugins/kirki/assets/js/select2.full.min.js b/includes/plugins/kirki/assets/js/select2.full.min.js new file mode 100644 index 0000000..59d8c1a --- /dev/null +++ b/includes/plugins/kirki/assets/js/select2.full.min.js @@ -0,0 +1,3 @@ +/*! Select2 4.0.0 | https://github.com/select2/select2/blob/master/LICENSE.md */!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):a("object"==typeof exports?require("jquery"):jQuery)}(function(a){var b=function(){if(a&&a.fn&&a.fn.select2&&a.fn.select2.amd)var b=a.fn.select2.amd;var b;return function(){if(!b||!b.requirejs){b?c=b:b={};var a,c,d;!function(b){function e(a,b){return u.call(a,b)}function f(a,b){var c,d,e,f,g,h,i,j,k,l,m,n=b&&b.split("/"),o=s.map,p=o&&o["*"]||{};if(a&&"."===a.charAt(0))if(b){for(n=n.slice(0,n.length-1),a=a.split("/"),g=a.length-1,s.nodeIdCompat&&w.test(a[g])&&(a[g]=a[g].replace(w,"")),a=n.concat(a),k=0;k0&&(a.splice(k-1,2),k-=2)}a=a.join("/")}else 0===a.indexOf("./")&&(a=a.substring(2));if((n||p)&&o){for(c=a.split("/"),k=c.length;k>0;k-=1){if(d=c.slice(0,k).join("/"),n)for(l=n.length;l>0;l-=1)if(e=o[n.slice(0,l).join("/")],e&&(e=e[d])){f=e,h=k;break}if(f)break;!i&&p&&p[d]&&(i=p[d],j=k)}!f&&i&&(f=i,h=j),f&&(c.splice(0,h,f),a=c.join("/"))}return a}function g(a,c){return function(){return n.apply(b,v.call(arguments,0).concat([a,c]))}}function h(a){return function(b){return f(b,a)}}function i(a){return function(b){q[a]=b}}function j(a){if(e(r,a)){var c=r[a];delete r[a],t[a]=!0,m.apply(b,c)}if(!e(q,a)&&!e(t,a))throw new Error("No "+a);return q[a]}function k(a){var b,c=a?a.indexOf("!"):-1;return c>-1&&(b=a.substring(0,c),a=a.substring(c+1,a.length)),[b,a]}function l(a){return function(){return s&&s.config&&s.config[a]||{}}}var m,n,o,p,q={},r={},s={},t={},u=Object.prototype.hasOwnProperty,v=[].slice,w=/\.js$/;o=function(a,b){var c,d=k(a),e=d[0];return a=d[1],e&&(e=f(e,b),c=j(e)),e?a=c&&c.normalize?c.normalize(a,h(b)):f(a,b):(a=f(a,b),d=k(a),e=d[0],a=d[1],e&&(c=j(e))),{f:e?e+"!"+a:a,n:a,pr:e,p:c}},p={require:function(a){return g(a)},exports:function(a){var b=q[a];return"undefined"!=typeof b?b:q[a]={}},module:function(a){return{id:a,uri:"",exports:q[a],config:l(a)}}},m=function(a,c,d,f){var h,k,l,m,n,s,u=[],v=typeof d;if(f=f||a,"undefined"===v||"function"===v){for(c=!c.length&&d.length?["require","exports","module"]:c,n=0;n0&&(b.call(arguments,a.prototype.constructor),e=c.prototype.constructor),e.apply(this,arguments)}function e(){this.constructor=d}var f=b(c),g=b(a);c.displayName=a.displayName,d.prototype=new e;for(var h=0;hc;c++)a[c].apply(this,b)},c.Observable=d,c.generateChars=function(a){for(var b="",c=0;a>c;c++){var d=Math.floor(36*Math.random());b+=d.toString(36)}return b},c.bind=function(a,b){return function(){a.apply(b,arguments)}},c._convertData=function(a){for(var b in a){var c=b.split("-"),d=a;if(1!==c.length){for(var e=0;e":">",'"':""","'":"'","/":"/"};return"string"!=typeof a?a:String(a).replace(/[&<>"'\/\\]/g,function(a){return b[a]})},c.appendMany=function(b,c){if("1.7"===a.fn.jquery.substr(0,3)){var d=a();a.map(c,function(a){d=d.add(a)}),c=d}b.append(c)},c}),b.define("select2/results",["jquery","./utils"],function(a,b){function c(a,b,d){this.$element=a,this.data=d,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('
    ');return this.options.get("multiple")&&b.attr("aria-multiselectable","true"),this.$results=b,b},c.prototype.clear=function(){this.$results.empty()},c.prototype.displayMessage=function(b){var c=this.options.get("escapeMarkup");this.clear(),this.hideLoading();var d=a('
  • '),e=this.options.get("translations").get(b.message);d.append(c(e(b.args))),this.$results.append(d)},c.prototype.append=function(a){this.hideLoading();var b=[];if(null==a.results||0===a.results.length)return void(0===this.$results.children().length&&this.trigger("results:message",{message:"noResults"}));a.results=this.sort(a.results);for(var c=0;c-1?b.attr("aria-selected","true"):b.attr("aria-selected","false")});var f=e.filter("[aria-selected=true]");f.length>0?f.first().trigger("mouseenter"):e.first().trigger("mouseenter")})},c.prototype.showLoading=function(a){this.hideLoading();var b=this.options.get("translations").get("searching"),c={disabled:!0,loading:!0,text:b(a)},d=this.option(c);d.className+=" loading-results",this.$results.prepend(d)},c.prototype.hideLoading=function(){this.$results.find(".loading-results").remove()},c.prototype.option=function(b){var c=document.createElement("li");c.className="select2-results__option";var d={role:"treeitem","aria-selected":"false"};b.disabled&&(delete d["aria-selected"],d["aria-disabled"]="true"),null==b.id&&delete d["aria-selected"],null!=b._resultId&&(c.id=b._resultId),b.title&&(c.title=b.title),b.children&&(d.role="group",d["aria-label"]=b.text,delete d["aria-selected"]);for(var e in d){var f=d[e];c.setAttribute(e,f)}if(b.children){var g=a(c),h=document.createElement("strong");h.className="select2-results__group";{a(h)}this.template(b,h);for(var i=[],j=0;j",{"class":"select2-results__options select2-results__options--nested"});m.append(i),g.append(h),g.append(m)}else this.template(b,c);return a.data(c,"data",b),c},c.prototype.bind=function(b){var c=this,d=b.id+"-results";this.$results.attr("id",d),b.on("results:all",function(a){c.clear(),c.append(a.data),b.isOpen()&&c.setClasses()}),b.on("results:append",function(a){c.append(a.data),b.isOpen()&&c.setClasses()}),b.on("query",function(a){c.showLoading(a)}),b.on("select",function(){b.isOpen()&&c.setClasses()}),b.on("unselect",function(){b.isOpen()&&c.setClasses()}),b.on("open",function(){c.$results.attr("aria-expanded","true"),c.$results.attr("aria-hidden","false"),c.setClasses(),c.ensureHighlightVisible()}),b.on("close",function(){c.$results.attr("aria-expanded","false"),c.$results.attr("aria-hidden","true"),c.$results.removeAttr("aria-activedescendant")}),b.on("results:toggle",function(){var a=c.getHighlightedResults();0!==a.length&&a.trigger("mouseup")}),b.on("results:select",function(){var a=c.getHighlightedResults();if(0!==a.length){var b=a.data("data");"true"==a.attr("aria-selected")?c.trigger("close"):c.trigger("select",{data:b})}}),b.on("results:previous",function(){var a=c.getHighlightedResults(),b=c.$results.find("[aria-selected]"),d=b.index(a);if(0!==d){var e=d-1;0===a.length&&(e=0);var f=b.eq(e);f.trigger("mouseenter");var g=c.$results.offset().top,h=f.offset().top,i=c.$results.scrollTop()+(h-g);0===e?c.$results.scrollTop(0):0>h-g&&c.$results.scrollTop(i)}}),b.on("results:next",function(){var a=c.getHighlightedResults(),b=c.$results.find("[aria-selected]"),d=b.index(a),e=d+1;if(!(e>=b.length)){var f=b.eq(e);f.trigger("mouseenter");var g=c.$results.offset().top+c.$results.outerHeight(!1),h=f.offset().top+f.outerHeight(!1),i=c.$results.scrollTop()+h-g;0===e?c.$results.scrollTop(0):h>g&&c.$results.scrollTop(i)}}),b.on("results:focus",function(a){a.element.addClass("select2-results__option--highlighted")}),b.on("results:message",function(a){c.displayMessage(a)}),a.fn.mousewheel&&this.$results.on("mousewheel",function(a){var b=c.$results.scrollTop(),d=c.$results.get(0).scrollHeight-c.$results.scrollTop()+a.deltaY,e=a.deltaY>0&&b-a.deltaY<=0,f=a.deltaY<0&&d<=c.$results.height();e?(c.$results.scrollTop(0),a.preventDefault(),a.stopPropagation()):f&&(c.$results.scrollTop(c.$results.get(0).scrollHeight-c.$results.height()),a.preventDefault(),a.stopPropagation())}),this.$results.on("mouseup",".select2-results__option[aria-selected]",function(b){var d=a(this),e=d.data("data");return"true"===d.attr("aria-selected")?void(c.options.get("multiple")?c.trigger("unselect",{originalEvent:b,data:e}):c.trigger("close")):void c.trigger("select",{originalEvent:b,data:e})}),this.$results.on("mouseenter",".select2-results__option[aria-selected]",function(){var b=a(this).data("data");c.getHighlightedResults().removeClass("select2-results__option--highlighted"),c.trigger("results:focus",{data:b,element:a(this)})})},c.prototype.getHighlightedResults=function(){var a=this.$results.find(".select2-results__option--highlighted");return a},c.prototype.destroy=function(){this.$results.remove()},c.prototype.ensureHighlightVisible=function(){var a=this.getHighlightedResults();if(0!==a.length){var b=this.$results.find("[aria-selected]"),c=b.index(a),d=this.$results.offset().top,e=a.offset().top,f=this.$results.scrollTop()+(e-d),g=e-d;f-=2*a.outerHeight(!1),2>=c?this.$results.scrollTop(0):(g>this.$results.outerHeight()||0>g)&&this.$results.scrollTop(f)}},c.prototype.template=function(b,c){var d=this.options.get("templateResult"),e=this.options.get("escapeMarkup"),f=d(b);null==f?c.style.display="none":"string"==typeof f?c.innerHTML=e(f):a(c).append(f)},c}),b.define("select2/keys",[],function(){var a={BACKSPACE:8,TAB:9,ENTER:13,SHIFT:16,CTRL:17,ALT:18,ESC:27,SPACE:32,PAGE_UP:33,PAGE_DOWN:34,END:35,HOME:36,LEFT:37,UP:38,RIGHT:39,DOWN:40,DELETE:46};return a}),b.define("select2/selection/base",["jquery","../utils","../keys"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,b.Observable),d.prototype.render=function(){var b=a('');return this._tabindex=0,null!=this.$element.data("old-tabindex")?this._tabindex=this.$element.data("old-tabindex"):null!=this.$element.attr("tabindex")&&(this._tabindex=this.$element.attr("tabindex")),b.attr("title",this.$element.attr("title")),b.attr("tabindex",this._tabindex),this.$selection=b,b},d.prototype.bind=function(a){var b=this,d=(a.id+"-container",a.id+"-results");this.container=a,this.$selection.on("focus",function(a){b.trigger("focus",a)}),this.$selection.on("blur",function(a){b.trigger("blur",a)}),this.$selection.on("keydown",function(a){b.trigger("keypress",a),a.which===c.SPACE&&a.preventDefault()}),a.on("results:focus",function(a){b.$selection.attr("aria-activedescendant",a.data._resultId)}),a.on("selection:update",function(a){b.update(a.data)}),a.on("open",function(){b.$selection.attr("aria-expanded","true"),b.$selection.attr("aria-owns",d),b._attachCloseHandler(a)}),a.on("close",function(){b.$selection.attr("aria-expanded","false"),b.$selection.removeAttr("aria-activedescendant"),b.$selection.removeAttr("aria-owns"),b.$selection.focus(),b._detachCloseHandler(a)}),a.on("enable",function(){b.$selection.attr("tabindex",b._tabindex)}),a.on("disable",function(){b.$selection.attr("tabindex","-1")})},d.prototype._attachCloseHandler=function(b){a(document.body).on("mousedown.select2."+b.id,function(b){var c=a(b.target),d=c.closest(".select2"),e=a(".select2.select2-container--open");e.each(function(){var b=a(this);if(this!=d[0]){var c=b.data("element");c.select2("close")}})})},d.prototype._detachCloseHandler=function(b){a(document.body).off("mousedown.select2."+b.id)},d.prototype.position=function(a,b){var c=b.find(".selection");c.append(a)},d.prototype.destroy=function(){this._detachCloseHandler(this.container)},d.prototype.update=function(){throw new Error("The `update` method must be defined in child classes.")},d}),b.define("select2/selection/single",["jquery","./base","../utils","../keys"],function(a,b,c){function d(){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--single"),a.html(''),a},d.prototype.bind=function(a){var b=this;d.__super__.bind.apply(this,arguments);var c=a.id+"-container";this.$selection.find(".select2-selection__rendered").attr("id",c),this.$selection.attr("aria-labelledby",c),this.$selection.on("mousedown",function(a){1===a.which&&b.trigger("toggle",{originalEvent:a})}),this.$selection.on("focus",function(){}),this.$selection.on("blur",function(){}),a.on("selection:update",function(a){b.update(a.data)})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a){var b=this.options.get("templateSelection"),c=this.options.get("escapeMarkup");return c(b(a))},d.prototype.selectionContainer=function(){return a("")},d.prototype.update=function(a){if(0===a.length)return void this.clear();var b=a[0],c=this.display(b),d=this.$selection.find(".select2-selection__rendered");d.empty().append(c),d.prop("title",b.title||b.text)},d}),b.define("select2/selection/multiple",["jquery","./base","../utils"],function(a,b,c){function d(){d.__super__.constructor.apply(this,arguments)}return c.Extend(d,b),d.prototype.render=function(){var a=d.__super__.render.call(this);return a.addClass("select2-selection--multiple"),a.html('
      '),a},d.prototype.bind=function(){var b=this;d.__super__.bind.apply(this,arguments),this.$selection.on("click",function(a){b.trigger("toggle",{originalEvent:a})}),this.$selection.on("click",".select2-selection__choice__remove",function(c){var d=a(this),e=d.parent(),f=e.data("data");b.trigger("unselect",{originalEvent:c,data:f})})},d.prototype.clear=function(){this.$selection.find(".select2-selection__rendered").empty()},d.prototype.display=function(a){var b=this.options.get("templateSelection"),c=this.options.get("escapeMarkup");return c(b(a))},d.prototype.selectionContainer=function(){var b=a('
    • ×
    • ');return b},d.prototype.update=function(a){if(this.clear(),0!==a.length){for(var b=[],d=0;d1;if(d||c)return a.call(this,b);this.clear();var e=this.createPlaceholder(this.placeholder);this.$selection.find(".select2-selection__rendered").append(e)},a}),b.define("select2/selection/allowClear",["jquery","../keys"],function(a,b){function c(){}return c.prototype.bind=function(a,b,c){var d=this;a.call(this,b,c),null==this.placeholder&&this.options.get("debug")&&window.console&&console.error&&console.error("Select2: The `allowClear` option should be used in combination with the `placeholder` option."),this.$selection.on("mousedown",".select2-selection__clear",function(a){d._handleClear(a)}),b.on("keypress",function(a){d._handleKeyboardClear(a,b)})},c.prototype._handleClear=function(a,b){if(!this.options.get("disabled")){var c=this.$selection.find(".select2-selection__clear");if(0!==c.length){b.stopPropagation();for(var d=c.data("data"),e=0;e0||0===c.length)){var d=a('×');d.data("data",c),this.$selection.find(".select2-selection__rendered").prepend(d)}},c}),b.define("select2/selection/search",["jquery","../utils","../keys"],function(a,b,c){function d(a,b,c){a.call(this,b,c)}return d.prototype.render=function(b){var c=a('');this.$searchContainer=c,this.$search=c.find("input");var d=b.call(this);return d},d.prototype.bind=function(a,b,d){var e=this;a.call(this,b,d),b.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus()}),b.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val(""),e.$search.focus()}),b.on("enable",function(){e.$search.prop("disabled",!1)}),b.on("disable",function(){e.$search.prop("disabled",!0)}),this.$selection.on("focusin",".select2-search--inline",function(a){e.trigger("focus",a)}),this.$selection.on("focusout",".select2-search--inline",function(a){e.trigger("blur",a)}),this.$selection.on("keydown",".select2-search--inline",function(a){a.stopPropagation(),e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented();var b=a.which;if(b===c.BACKSPACE&&""===e.$search.val()){var d=e.$searchContainer.prev(".select2-selection__choice");if(d.length>0){var f=d.data("data");e.searchRemoveChoice(f),a.preventDefault()}}}),this.$selection.on("input",".select2-search--inline",function(){e.$selection.off("keyup.search")}),this.$selection.on("keyup.search input",".select2-search--inline",function(a){e.handleSearch(a)})},d.prototype.createPlaceholder=function(a,b){this.$search.attr("placeholder",b.text)},d.prototype.update=function(a,b){this.$search.attr("placeholder",""),a.call(this,b),this.$selection.find(".select2-selection__rendered").append(this.$searchContainer),this.resizeSearch()},d.prototype.handleSearch=function(){if(this.resizeSearch(),!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},d.prototype.searchRemoveChoice=function(a,b){this.trigger("unselect",{data:b}),this.trigger("open"),this.$search.val(b.text+" ")},d.prototype.resizeSearch=function(){this.$search.css("width","25px");var a="";if(""!==this.$search.attr("placeholder"))a=this.$selection.find(".select2-selection__rendered").innerWidth();else{var b=this.$search.val().length+1;a=.75*b+"em"}this.$search.css("width",a)},d}),b.define("select2/selection/eventRelay",["jquery"],function(a){function b(){}return b.prototype.bind=function(b,c,d){var e=this,f=["open","opening","close","closing","select","selecting","unselect","unselecting"],g=["opening","closing","selecting","unselecting"];b.call(this,c,d),c.on("*",function(b,c){if(-1!==a.inArray(b,f)){c=c||{};var d=a.Event("select2:"+b,{params:c});e.$element.trigger(d),-1!==a.inArray(b,g)&&(c.prevented=d.isDefaultPrevented())}})},b}),b.define("select2/translation",["jquery","require"],function(a,b){function c(a){this.dict=a||{}}return c.prototype.all=function(){return this.dict},c.prototype.get=function(a){return this.dict[a]},c.prototype.extend=function(b){this.dict=a.extend({},b.all(),this.dict)},c._cache={},c.loadPath=function(a){if(!(a in c._cache)){var d=b(a);c._cache[a]=d}return new c(c._cache[a])},c}),b.define("select2/diacritics",[],function(){var a={"Ⓐ":"A","A":"A","À":"A","Á":"A","Â":"A","Ầ":"A","Ấ":"A","Ẫ":"A","Ẩ":"A","Ã":"A","Ā":"A","Ă":"A","Ằ":"A","Ắ":"A","Ẵ":"A","Ẳ":"A","Ȧ":"A","Ǡ":"A","Ä":"A","Ǟ":"A","Ả":"A","Å":"A","Ǻ":"A","Ǎ":"A","Ȁ":"A","Ȃ":"A","Ạ":"A","Ậ":"A","Ặ":"A","Ḁ":"A","Ą":"A","Ⱥ":"A","Ɐ":"A","Ꜳ":"AA","Æ":"AE","Ǽ":"AE","Ǣ":"AE","Ꜵ":"AO","Ꜷ":"AU","Ꜹ":"AV","Ꜻ":"AV","Ꜽ":"AY","Ⓑ":"B","B":"B","Ḃ":"B","Ḅ":"B","Ḇ":"B","Ƀ":"B","Ƃ":"B","Ɓ":"B","Ⓒ":"C","C":"C","Ć":"C","Ĉ":"C","Ċ":"C","Č":"C","Ç":"C","Ḉ":"C","Ƈ":"C","Ȼ":"C","Ꜿ":"C","Ⓓ":"D","D":"D","Ḋ":"D","Ď":"D","Ḍ":"D","Ḑ":"D","Ḓ":"D","Ḏ":"D","Đ":"D","Ƌ":"D","Ɗ":"D","Ɖ":"D","Ꝺ":"D","DZ":"DZ","DŽ":"DZ","Dz":"Dz","Dž":"Dz","Ⓔ":"E","E":"E","È":"E","É":"E","Ê":"E","Ề":"E","Ế":"E","Ễ":"E","Ể":"E","Ẽ":"E","Ē":"E","Ḕ":"E","Ḗ":"E","Ĕ":"E","Ė":"E","Ë":"E","Ẻ":"E","Ě":"E","Ȅ":"E","Ȇ":"E","Ẹ":"E","Ệ":"E","Ȩ":"E","Ḝ":"E","Ę":"E","Ḙ":"E","Ḛ":"E","Ɛ":"E","Ǝ":"E","Ⓕ":"F","F":"F","Ḟ":"F","Ƒ":"F","Ꝼ":"F","Ⓖ":"G","G":"G","Ǵ":"G","Ĝ":"G","Ḡ":"G","Ğ":"G","Ġ":"G","Ǧ":"G","Ģ":"G","Ǥ":"G","Ɠ":"G","Ꞡ":"G","Ᵹ":"G","Ꝿ":"G","Ⓗ":"H","H":"H","Ĥ":"H","Ḣ":"H","Ḧ":"H","Ȟ":"H","Ḥ":"H","Ḩ":"H","Ḫ":"H","Ħ":"H","Ⱨ":"H","Ⱶ":"H","Ɥ":"H","Ⓘ":"I","I":"I","Ì":"I","Í":"I","Î":"I","Ĩ":"I","Ī":"I","Ĭ":"I","İ":"I","Ï":"I","Ḯ":"I","Ỉ":"I","Ǐ":"I","Ȉ":"I","Ȋ":"I","Ị":"I","Į":"I","Ḭ":"I","Ɨ":"I","Ⓙ":"J","J":"J","Ĵ":"J","Ɉ":"J","Ⓚ":"K","K":"K","Ḱ":"K","Ǩ":"K","Ḳ":"K","Ķ":"K","Ḵ":"K","Ƙ":"K","Ⱪ":"K","Ꝁ":"K","Ꝃ":"K","Ꝅ":"K","Ꞣ":"K","Ⓛ":"L","L":"L","Ŀ":"L","Ĺ":"L","Ľ":"L","Ḷ":"L","Ḹ":"L","Ļ":"L","Ḽ":"L","Ḻ":"L","Ł":"L","Ƚ":"L","Ɫ":"L","Ⱡ":"L","Ꝉ":"L","Ꝇ":"L","Ꞁ":"L","LJ":"LJ","Lj":"Lj","Ⓜ":"M","M":"M","Ḿ":"M","Ṁ":"M","Ṃ":"M","Ɱ":"M","Ɯ":"M","Ⓝ":"N","N":"N","Ǹ":"N","Ń":"N","Ñ":"N","Ṅ":"N","Ň":"N","Ṇ":"N","Ņ":"N","Ṋ":"N","Ṉ":"N","Ƞ":"N","Ɲ":"N","Ꞑ":"N","Ꞥ":"N","NJ":"NJ","Nj":"Nj","Ⓞ":"O","O":"O","Ò":"O","Ó":"O","Ô":"O","Ồ":"O","Ố":"O","Ỗ":"O","Ổ":"O","Õ":"O","Ṍ":"O","Ȭ":"O","Ṏ":"O","Ō":"O","Ṑ":"O","Ṓ":"O","Ŏ":"O","Ȯ":"O","Ȱ":"O","Ö":"O","Ȫ":"O","Ỏ":"O","Ő":"O","Ǒ":"O","Ȍ":"O","Ȏ":"O","Ơ":"O","Ờ":"O","Ớ":"O","Ỡ":"O","Ở":"O","Ợ":"O","Ọ":"O","Ộ":"O","Ǫ":"O","Ǭ":"O","Ø":"O","Ǿ":"O","Ɔ":"O","Ɵ":"O","Ꝋ":"O","Ꝍ":"O","Ƣ":"OI","Ꝏ":"OO","Ȣ":"OU","Ⓟ":"P","P":"P","Ṕ":"P","Ṗ":"P","Ƥ":"P","Ᵽ":"P","Ꝑ":"P","Ꝓ":"P","Ꝕ":"P","Ⓠ":"Q","Q":"Q","Ꝗ":"Q","Ꝙ":"Q","Ɋ":"Q","Ⓡ":"R","R":"R","Ŕ":"R","Ṙ":"R","Ř":"R","Ȑ":"R","Ȓ":"R","Ṛ":"R","Ṝ":"R","Ŗ":"R","Ṟ":"R","Ɍ":"R","Ɽ":"R","Ꝛ":"R","Ꞧ":"R","Ꞃ":"R","Ⓢ":"S","S":"S","ẞ":"S","Ś":"S","Ṥ":"S","Ŝ":"S","Ṡ":"S","Š":"S","Ṧ":"S","Ṣ":"S","Ṩ":"S","Ș":"S","Ş":"S","Ȿ":"S","Ꞩ":"S","Ꞅ":"S","Ⓣ":"T","T":"T","Ṫ":"T","Ť":"T","Ṭ":"T","Ț":"T","Ţ":"T","Ṱ":"T","Ṯ":"T","Ŧ":"T","Ƭ":"T","Ʈ":"T","Ⱦ":"T","Ꞇ":"T","Ꜩ":"TZ","Ⓤ":"U","U":"U","Ù":"U","Ú":"U","Û":"U","Ũ":"U","Ṹ":"U","Ū":"U","Ṻ":"U","Ŭ":"U","Ü":"U","Ǜ":"U","Ǘ":"U","Ǖ":"U","Ǚ":"U","Ủ":"U","Ů":"U","Ű":"U","Ǔ":"U","Ȕ":"U","Ȗ":"U","Ư":"U","Ừ":"U","Ứ":"U","Ữ":"U","Ử":"U","Ự":"U","Ụ":"U","Ṳ":"U","Ų":"U","Ṷ":"U","Ṵ":"U","Ʉ":"U","Ⓥ":"V","V":"V","Ṽ":"V","Ṿ":"V","Ʋ":"V","Ꝟ":"V","Ʌ":"V","Ꝡ":"VY","Ⓦ":"W","W":"W","Ẁ":"W","Ẃ":"W","Ŵ":"W","Ẇ":"W","Ẅ":"W","Ẉ":"W","Ⱳ":"W","Ⓧ":"X","X":"X","Ẋ":"X","Ẍ":"X","Ⓨ":"Y","Y":"Y","Ỳ":"Y","Ý":"Y","Ŷ":"Y","Ỹ":"Y","Ȳ":"Y","Ẏ":"Y","Ÿ":"Y","Ỷ":"Y","Ỵ":"Y","Ƴ":"Y","Ɏ":"Y","Ỿ":"Y","Ⓩ":"Z","Z":"Z","Ź":"Z","Ẑ":"Z","Ż":"Z","Ž":"Z","Ẓ":"Z","Ẕ":"Z","Ƶ":"Z","Ȥ":"Z","Ɀ":"Z","Ⱬ":"Z","Ꝣ":"Z","ⓐ":"a","a":"a","ẚ":"a","à":"a","á":"a","â":"a","ầ":"a","ấ":"a","ẫ":"a","ẩ":"a","ã":"a","ā":"a","ă":"a","ằ":"a","ắ":"a","ẵ":"a","ẳ":"a","ȧ":"a","ǡ":"a","ä":"a","ǟ":"a","ả":"a","å":"a","ǻ":"a","ǎ":"a","ȁ":"a","ȃ":"a","ạ":"a","ậ":"a","ặ":"a","ḁ":"a","ą":"a","ⱥ":"a","ɐ":"a","ꜳ":"aa","æ":"ae","ǽ":"ae","ǣ":"ae","ꜵ":"ao","ꜷ":"au","ꜹ":"av","ꜻ":"av","ꜽ":"ay","ⓑ":"b","b":"b","ḃ":"b","ḅ":"b","ḇ":"b","ƀ":"b","ƃ":"b","ɓ":"b","ⓒ":"c","c":"c","ć":"c","ĉ":"c","ċ":"c","č":"c","ç":"c","ḉ":"c","ƈ":"c","ȼ":"c","ꜿ":"c","ↄ":"c","ⓓ":"d","d":"d","ḋ":"d","ď":"d","ḍ":"d","ḑ":"d","ḓ":"d","ḏ":"d","đ":"d","ƌ":"d","ɖ":"d","ɗ":"d","ꝺ":"d","dz":"dz","dž":"dz","ⓔ":"e","e":"e","è":"e","é":"e","ê":"e","ề":"e","ế":"e","ễ":"e","ể":"e","ẽ":"e","ē":"e","ḕ":"e","ḗ":"e","ĕ":"e","ė":"e","ë":"e","ẻ":"e","ě":"e","ȅ":"e","ȇ":"e","ẹ":"e","ệ":"e","ȩ":"e","ḝ":"e","ę":"e","ḙ":"e","ḛ":"e","ɇ":"e","ɛ":"e","ǝ":"e","ⓕ":"f","f":"f","ḟ":"f","ƒ":"f","ꝼ":"f","ⓖ":"g","g":"g","ǵ":"g","ĝ":"g","ḡ":"g","ğ":"g","ġ":"g","ǧ":"g","ģ":"g","ǥ":"g","ɠ":"g","ꞡ":"g","ᵹ":"g","ꝿ":"g","ⓗ":"h","h":"h","ĥ":"h","ḣ":"h","ḧ":"h","ȟ":"h","ḥ":"h","ḩ":"h","ḫ":"h","ẖ":"h","ħ":"h","ⱨ":"h","ⱶ":"h","ɥ":"h","ƕ":"hv","ⓘ":"i","i":"i","ì":"i","í":"i","î":"i","ĩ":"i","ī":"i","ĭ":"i","ï":"i","ḯ":"i","ỉ":"i","ǐ":"i","ȉ":"i","ȋ":"i","ị":"i","į":"i","ḭ":"i","ɨ":"i","ı":"i","ⓙ":"j","j":"j","ĵ":"j","ǰ":"j","ɉ":"j","ⓚ":"k","k":"k","ḱ":"k","ǩ":"k","ḳ":"k","ķ":"k","ḵ":"k","ƙ":"k","ⱪ":"k","ꝁ":"k","ꝃ":"k","ꝅ":"k","ꞣ":"k","ⓛ":"l","l":"l","ŀ":"l","ĺ":"l","ľ":"l","ḷ":"l","ḹ":"l","ļ":"l","ḽ":"l","ḻ":"l","ſ":"l","ł":"l","ƚ":"l","ɫ":"l","ⱡ":"l","ꝉ":"l","ꞁ":"l","ꝇ":"l","lj":"lj","ⓜ":"m","m":"m","ḿ":"m","ṁ":"m","ṃ":"m","ɱ":"m","ɯ":"m","ⓝ":"n","n":"n","ǹ":"n","ń":"n","ñ":"n","ṅ":"n","ň":"n","ṇ":"n","ņ":"n","ṋ":"n","ṉ":"n","ƞ":"n","ɲ":"n","ʼn":"n","ꞑ":"n","ꞥ":"n","nj":"nj","ⓞ":"o","o":"o","ò":"o","ó":"o","ô":"o","ồ":"o","ố":"o","ỗ":"o","ổ":"o","õ":"o","ṍ":"o","ȭ":"o","ṏ":"o","ō":"o","ṑ":"o","ṓ":"o","ŏ":"o","ȯ":"o","ȱ":"o","ö":"o","ȫ":"o","ỏ":"o","ő":"o","ǒ":"o","ȍ":"o","ȏ":"o","ơ":"o","ờ":"o","ớ":"o","ỡ":"o","ở":"o","ợ":"o","ọ":"o","ộ":"o","ǫ":"o","ǭ":"o","ø":"o","ǿ":"o","ɔ":"o","ꝋ":"o","ꝍ":"o","ɵ":"o","ƣ":"oi","ȣ":"ou","ꝏ":"oo","ⓟ":"p","p":"p","ṕ":"p","ṗ":"p","ƥ":"p","ᵽ":"p","ꝑ":"p","ꝓ":"p","ꝕ":"p","ⓠ":"q","q":"q","ɋ":"q","ꝗ":"q","ꝙ":"q","ⓡ":"r","r":"r","ŕ":"r","ṙ":"r","ř":"r","ȑ":"r","ȓ":"r","ṛ":"r","ṝ":"r","ŗ":"r","ṟ":"r","ɍ":"r","ɽ":"r","ꝛ":"r","ꞧ":"r","ꞃ":"r","ⓢ":"s","s":"s","ß":"s","ś":"s","ṥ":"s","ŝ":"s","ṡ":"s","š":"s","ṧ":"s","ṣ":"s","ṩ":"s","ș":"s","ş":"s","ȿ":"s","ꞩ":"s","ꞅ":"s","ẛ":"s","ⓣ":"t","t":"t","ṫ":"t","ẗ":"t","ť":"t","ṭ":"t","ț":"t","ţ":"t","ṱ":"t","ṯ":"t","ŧ":"t","ƭ":"t","ʈ":"t","ⱦ":"t","ꞇ":"t","ꜩ":"tz","ⓤ":"u","u":"u","ù":"u","ú":"u","û":"u","ũ":"u","ṹ":"u","ū":"u","ṻ":"u","ŭ":"u","ü":"u","ǜ":"u","ǘ":"u","ǖ":"u","ǚ":"u","ủ":"u","ů":"u","ű":"u","ǔ":"u","ȕ":"u","ȗ":"u","ư":"u","ừ":"u","ứ":"u","ữ":"u","ử":"u","ự":"u","ụ":"u","ṳ":"u","ų":"u","ṷ":"u","ṵ":"u","ʉ":"u","ⓥ":"v","v":"v","ṽ":"v","ṿ":"v","ʋ":"v","ꝟ":"v","ʌ":"v","ꝡ":"vy","ⓦ":"w","w":"w","ẁ":"w","ẃ":"w","ŵ":"w","ẇ":"w","ẅ":"w","ẘ":"w","ẉ":"w","ⱳ":"w","ⓧ":"x","x":"x","ẋ":"x","ẍ":"x","ⓨ":"y","y":"y","ỳ":"y","ý":"y","ŷ":"y","ỹ":"y","ȳ":"y","ẏ":"y","ÿ":"y","ỷ":"y","ẙ":"y","ỵ":"y","ƴ":"y","ɏ":"y","ỿ":"y","ⓩ":"z","z":"z","ź":"z","ẑ":"z","ż":"z","ž":"z","ẓ":"z","ẕ":"z","ƶ":"z","ȥ":"z","ɀ":"z","ⱬ":"z","ꝣ":"z","Ά":"Α","Έ":"Ε","Ή":"Η","Ί":"Ι","Ϊ":"Ι","Ό":"Ο","Ύ":"Υ","Ϋ":"Υ","Ώ":"Ω","ά":"α","έ":"ε","ή":"η","ί":"ι","ϊ":"ι","ΐ":"ι","ό":"ο","ύ":"υ","ϋ":"υ","ΰ":"υ","ω":"ω","ς":"σ"};return a}),b.define("select2/data/base",["../utils"],function(a){function b(){b.__super__.constructor.call(this)}return a.Extend(b,a.Observable),b.prototype.current=function(){throw new Error("The `current` method must be defined in child classes.")},b.prototype.query=function(){throw new Error("The `query` method must be defined in child classes.")},b.prototype.bind=function(){},b.prototype.destroy=function(){},b.prototype.generateResultId=function(b,c){var d=b.id+"-result-";return d+=a.generateChars(4),d+=null!=c.id?"-"+c.id.toString():"-"+a.generateChars(4)},b}),b.define("select2/data/select",["./base","../utils","jquery"],function(a,b,c){function d(a,b){this.$element=a,this.options=b,d.__super__.constructor.call(this)}return b.Extend(d,a),d.prototype.current=function(a){var b=[],d=this;this.$element.find(":selected").each(function(){var a=c(this),e=d.item(a);b.push(e)}),a(b)},d.prototype.select=function(a){var b=this;if(a.selected=!0,c(a.element).is("option"))return a.element.selected=!0,void this.$element.trigger("change");if(this.$element.prop("multiple"))this.current(function(d){var e=[];a=[a],a.push.apply(a,d);for(var f=0;f=0){var k=f.filter(d(j)),l=this.item(k),m=(c.extend(!0,{},l,j),this.option(l));k.replaceWith(m)}else{var n=this.option(j);if(j.children){var o=this.convertToOptions(j.children);b.appendMany(n,o)}h.push(n)}}return h},d}),b.define("select2/data/ajax",["./array","../utils","jquery"],function(a,b,c){function d(b,c){this.ajaxOptions=this._applyDefaults(c.get("ajax")),null!=this.ajaxOptions.processResults&&(this.processResults=this.ajaxOptions.processResults),a.__super__.constructor.call(this,b,c)}return b.Extend(d,a),d.prototype._applyDefaults=function(a){var b={data:function(a){return{q:a.term}},transport:function(a,b,d){var e=c.ajax(a);return e.then(b),e.fail(d),e}};return c.extend({},b,a,!0)},d.prototype.processResults=function(a){return a},d.prototype.query=function(a,b){function d(){var d=f.transport(f,function(d){var f=e.processResults(d,a);e.options.get("debug")&&window.console&&console.error&&(f&&f.results&&c.isArray(f.results)||console.error("Select2: The AJAX results did not return an array in the `results` key of the response.")),b(f)},function(){});e._request=d}var e=this;null!=this._request&&(c.isFunction(this._request.abort)&&this._request.abort(),this._request=null);var f=c.extend({type:"GET"},this.ajaxOptions);"function"==typeof f.url&&(f.url=f.url(a)),"function"==typeof f.data&&(f.data=f.data(a)),this.ajaxOptions.delay&&""!==a.term?(this._queryTimeout&&window.clearTimeout(this._queryTimeout),this._queryTimeout=window.setTimeout(d,this.ajaxOptions.delay)):d()},d}),b.define("select2/data/tags",["jquery"],function(a){function b(b,c,d){var e=d.get("tags"),f=d.get("createTag");if(void 0!==f&&(this.createTag=f),b.call(this,c,d),a.isArray(e))for(var g=0;g0&&b.term.length>this.maximumInputLength?void this.trigger("results:message",{message:"inputTooLong",args:{maximum:this.maximumInputLength,input:b.term,params:b}}):void a.call(this,b,c)},a}),b.define("select2/data/maximumSelectionLength",[],function(){function a(a,b,c){this.maximumSelectionLength=c.get("maximumSelectionLength"),a.call(this,b,c)}return a.prototype.query=function(a,b,c){var d=this;this.current(function(e){var f=null!=e?e.length:0;return d.maximumSelectionLength>0&&f>=d.maximumSelectionLength?void d.trigger("results:message",{message:"maximumSelected",args:{maximum:d.maximumSelectionLength}}):void a.call(d,b,c)})},a}),b.define("select2/dropdown",["jquery","./utils"],function(a,b){function c(a,b){this.$element=a,this.options=b,c.__super__.constructor.call(this)}return b.Extend(c,b.Observable),c.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$dropdown=b,b},c.prototype.position=function(){},c.prototype.destroy=function(){this.$dropdown.remove()},c}),b.define("select2/dropdown/search",["jquery","../utils"],function(a){function b(){}return b.prototype.render=function(b){var c=b.call(this),d=a('');return this.$searchContainer=d,this.$search=d.find("input"),c.prepend(d),c},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),this.$search.on("keydown",function(a){e.trigger("keypress",a),e._keyUpPrevented=a.isDefaultPrevented()}),this.$search.on("input",function(){a(this).off("keyup")}),this.$search.on("keyup input",function(a){e.handleSearch(a)}),c.on("open",function(){e.$search.attr("tabindex",0),e.$search.focus(),window.setTimeout(function(){e.$search.focus()},0)}),c.on("close",function(){e.$search.attr("tabindex",-1),e.$search.val("")}),c.on("results:all",function(a){if(null==a.query.term||""===a.query.term){var b=e.showSearch(a);b?e.$searchContainer.removeClass("select2-search--hide"):e.$searchContainer.addClass("select2-search--hide")}})},b.prototype.handleSearch=function(){if(!this._keyUpPrevented){var a=this.$search.val();this.trigger("query",{term:a})}this._keyUpPrevented=!1},b.prototype.showSearch=function(){return!0},b}),b.define("select2/dropdown/hidePlaceholder",[],function(){function a(a,b,c,d){this.placeholder=this.normalizePlaceholder(c.get("placeholder")),a.call(this,b,c,d)}return a.prototype.append=function(a,b){b.results=this.removePlaceholder(b.results),a.call(this,b)},a.prototype.normalizePlaceholder=function(a,b){return"string"==typeof b&&(b={id:"",text:b}),b},a.prototype.removePlaceholder=function(a,b){for(var c=b.slice(0),d=b.length-1;d>=0;d--){var e=b[d];this.placeholder.id===e.id&&c.splice(d,1)}return c},a}),b.define("select2/dropdown/infiniteScroll",["jquery"],function(a){function b(a,b,c,d){this.lastParams={},a.call(this,b,c,d),this.$loadingMore=this.createLoadingMore(),this.loading=!1}return b.prototype.append=function(a,b){this.$loadingMore.remove(),this.loading=!1,a.call(this,b),this.showLoadingMore(b)&&this.$results.append(this.$loadingMore)},b.prototype.bind=function(b,c,d){var e=this;b.call(this,c,d),c.on("query",function(a){e.lastParams=a,e.loading=!0}),c.on("query:append",function(a){e.lastParams=a,e.loading=!0}),this.$results.on("scroll",function(){var b=a.contains(document.documentElement,e.$loadingMore[0]);if(!e.loading&&b){var c=e.$results.offset().top+e.$results.outerHeight(!1),d=e.$loadingMore.offset().top+e.$loadingMore.outerHeight(!1);c+50>=d&&e.loadMore()}})},b.prototype.loadMore=function(){this.loading=!0;var b=a.extend({},{page:1},this.lastParams);b.page++,this.trigger("query:append",b)},b.prototype.showLoadingMore=function(a,b){return b.pagination&&b.pagination.more},b.prototype.createLoadingMore=function(){var b=a('
    • '),c=this.options.get("translations").get("loadingMore");return b.html(c(this.lastParams)),b},b}),b.define("select2/dropdown/attachBody",["jquery","../utils"],function(a,b){function c(a,b,c){this.$dropdownParent=c.get("dropdownParent")||document.body,a.call(this,b,c)}return c.prototype.bind=function(a,b,c){var d=this,e=!1;a.call(this,b,c),b.on("open",function(){d._showDropdown(),d._attachPositioningHandler(b),e||(e=!0,b.on("results:all",function(){d._positionDropdown(),d._resizeDropdown()}),b.on("results:append",function(){d._positionDropdown(),d._resizeDropdown()}))}),b.on("close",function(){d._hideDropdown(),d._detachPositioningHandler(b)}),this.$dropdownContainer.on("mousedown",function(a){a.stopPropagation()})},c.prototype.position=function(a,b,c){b.attr("class",c.attr("class")),b.removeClass("select2"),b.addClass("select2-container--open"),b.css({position:"absolute",top:-999999}),this.$container=c},c.prototype.render=function(b){var c=a(""),d=b.call(this);return c.append(d),this.$dropdownContainer=c,c},c.prototype._hideDropdown=function(){this.$dropdownContainer.detach()},c.prototype._attachPositioningHandler=function(c){var d=this,e="scroll.select2."+c.id,f="resize.select2."+c.id,g="orientationchange.select2."+c.id,h=this.$container.parents().filter(b.hasScroll);h.each(function(){a(this).data("select2-scroll-position",{x:a(this).scrollLeft(),y:a(this).scrollTop()})}),h.on(e,function(){var b=a(this).data("select2-scroll-position");a(this).scrollTop(b.y)}),a(window).on(e+" "+f+" "+g,function(){d._positionDropdown(),d._resizeDropdown()})},c.prototype._detachPositioningHandler=function(c){var d="scroll.select2."+c.id,e="resize.select2."+c.id,f="orientationchange.select2."+c.id,g=this.$container.parents().filter(b.hasScroll);g.off(d),a(window).off(d+" "+e+" "+f)},c.prototype._positionDropdown=function(){var b=a(window),c=this.$dropdown.hasClass("select2-dropdown--above"),d=this.$dropdown.hasClass("select2-dropdown--below"),e=null,f=(this.$container.position(),this.$container.offset());f.bottom=f.top+this.$container.outerHeight(!1);var g={height:this.$container.outerHeight(!1)};g.top=f.top,g.bottom=f.top+g.height;var h={height:this.$dropdown.outerHeight(!1)},i={top:b.scrollTop(),bottom:b.scrollTop()+b.height()},j=i.topf.bottom+h.height,l={left:f.left,top:g.bottom};c||d||(e="below"),k||!j||c?!j&&k&&c&&(e="below"):e="above",("above"==e||c&&"below"!==e)&&(l.top=g.top-h.height),null!=e&&(this.$dropdown.removeClass("select2-dropdown--below select2-dropdown--above").addClass("select2-dropdown--"+e),this.$container.removeClass("select2-container--below select2-container--above").addClass("select2-container--"+e)),this.$dropdownContainer.css(l)},c.prototype._resizeDropdown=function(){this.$dropdownContainer.width();var a={width:this.$container.outerWidth(!1)+"px"};this.options.get("dropdownAutoWidth")&&(a.minWidth=a.width,a.width="auto"),this.$dropdown.css(a)},c.prototype._showDropdown=function(){this.$dropdownContainer.appendTo(this.$dropdownParent),this._positionDropdown(),this._resizeDropdown()},c}),b.define("select2/dropdown/minimumResultsForSearch",[],function(){function a(b){for(var c=0,d=0;d0&&(l.dataAdapter=j.Decorate(l.dataAdapter,r)),l.maximumInputLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,s)),l.maximumSelectionLength>0&&(l.dataAdapter=j.Decorate(l.dataAdapter,t)),l.tags&&(l.dataAdapter=j.Decorate(l.dataAdapter,p)),(null!=l.tokenSeparators||null!=l.tokenizer)&&(l.dataAdapter=j.Decorate(l.dataAdapter,q)),null!=l.query){var C=b(l.amdBase+"compat/query");l.dataAdapter=j.Decorate(l.dataAdapter,C)}if(null!=l.initSelection){var D=b(l.amdBase+"compat/initSelection");l.dataAdapter=j.Decorate(l.dataAdapter,D)}}if(null==l.resultsAdapter&&(l.resultsAdapter=c,null!=l.ajax&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,x)),null!=l.placeholder&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,w)),l.selectOnClose&&(l.resultsAdapter=j.Decorate(l.resultsAdapter,A))),null==l.dropdownAdapter){if(l.multiple)l.dropdownAdapter=u;else{var E=j.Decorate(u,v);l.dropdownAdapter=E}if(0!==l.minimumResultsForSearch&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,z)),l.closeOnSelect&&(l.dropdownAdapter=j.Decorate(l.dropdownAdapter,B)),null!=l.dropdownCssClass||null!=l.dropdownCss||null!=l.adaptDropdownCssClass){var F=b(l.amdBase+"compat/dropdownCss");l.dropdownAdapter=j.Decorate(l.dropdownAdapter,F)}l.dropdownAdapter=j.Decorate(l.dropdownAdapter,y)}if(null==l.selectionAdapter){if(l.selectionAdapter=l.multiple?e:d,null!=l.placeholder&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,f)),l.allowClear&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,g)),l.multiple&&(l.selectionAdapter=j.Decorate(l.selectionAdapter,h)),null!=l.containerCssClass||null!=l.containerCss||null!=l.adaptContainerCssClass){var G=b(l.amdBase+"compat/containerCss");l.selectionAdapter=j.Decorate(l.selectionAdapter,G)}l.selectionAdapter=j.Decorate(l.selectionAdapter,i)}if("string"==typeof l.language)if(l.language.indexOf("-")>0){var H=l.language.split("-"),I=H[0];l.language=[l.language,I]}else l.language=[l.language];if(a.isArray(l.language)){var J=new k;l.language.push("en");for(var K=l.language,L=0;L0){for(var f=a.extend(!0,{},e),g=e.children.length-1;g>=0;g--){var h=e.children[g],i=c(d,h);null==i&&f.children.splice(g,1)}return f.children.length>0?f:c(d,f)}var j=b(e.text).toUpperCase(),k=b(d.term).toUpperCase();return j.indexOf(k)>-1?e:null}this.defaults={amdBase:"./",amdLanguageBase:"./i18n/",closeOnSelect:!0,debug:!1,dropdownAutoWidth:!1,escapeMarkup:j.escapeMarkup,language:C,matcher:c,minimumInputLength:0,maximumInputLength:0,maximumSelectionLength:0,minimumResultsForSearch:0,selectOnClose:!1,sorter:function(a){return a},templateResult:function(a){return a.text},templateSelection:function(a){return a.text},theme:"default",width:"resolve"}},D.prototype.set=function(b,c){var d=a.camelCase(b),e={};e[d]=c;var f=j._convertData(e);a.extend(this.defaults,f)};var E=new D;return E}),b.define("select2/options",["require","jquery","./defaults","./utils"],function(a,b,c,d){function e(b,e){if(this.options=b,null!=e&&this.fromElement(e),this.options=c.apply(this.options),e&&e.is("input")){var f=a(this.get("amdBase")+"compat/inputData");this.options.dataAdapter=d.Decorate(this.options.dataAdapter,f)}}return e.prototype.fromElement=function(a){var c=["select2"];null==this.options.multiple&&(this.options.multiple=a.prop("multiple")),null==this.options.disabled&&(this.options.disabled=a.prop("disabled")),null==this.options.language&&(a.prop("lang")?this.options.language=a.prop("lang").toLowerCase():a.closest("[lang]").prop("lang")&&(this.options.language=a.closest("[lang]").prop("lang"))),null==this.options.dir&&(this.options.dir=a.prop("dir")?a.prop("dir"):a.closest("[dir]").prop("dir")?a.closest("[dir]").prop("dir"):"ltr"),a.prop("disabled",this.options.disabled),a.prop("multiple",this.options.multiple),a.data("select2Tags")&&(this.options.debug&&window.console&&console.warn&&console.warn('Select2: The `data-select2-tags` attribute has been changed to use the `data-data` and `data-tags="true"` attributes and will be removed in future versions of Select2.'),a.data("data",a.data("select2Tags")),a.data("tags",!0)),a.data("ajaxUrl")&&(this.options.debug&&window.console&&console.warn&&console.warn("Select2: The `data-ajax-url` attribute has been changed to `data-ajax--url` and support for the old attribute will be removed in future versions of Select2."),a.attr("ajax--url",a.data("ajaxUrl")),a.data("ajax--url",a.data("ajaxUrl")));var e={};e=b.fn.jquery&&"1."==b.fn.jquery.substr(0,2)&&a[0].dataset?b.extend(!0,{},a[0].dataset,a.data()):a.data();var f=b.extend(!0,{},e);f=d._convertData(f);for(var g in f)b.inArray(g,c)>-1||(b.isPlainObject(this.options[g])?b.extend(this.options[g],f[g]):this.options[g]=f[g]);return this},e.prototype.get=function(a){return this.options[a]},e.prototype.set=function(a,b){this.options[a]=b},e}),b.define("select2/core",["jquery","./options","./utils","./keys"],function(a,b,c,d){var e=function(a,c){null!=a.data("select2")&&a.data("select2").destroy(),this.$element=a,this.id=this._generateId(a),c=c||{},this.options=new b(c,a),e.__super__.constructor.call(this);var d=a.attr("tabindex")||0;a.data("old-tabindex",d),a.attr("tabindex","-1");var f=this.options.get("dataAdapter");this.dataAdapter=new f(a,this.options);var g=this.render();this._placeContainer(g);var h=this.options.get("selectionAdapter");this.selection=new h(a,this.options),this.$selection=this.selection.render(),this.selection.position(this.$selection,g);var i=this.options.get("dropdownAdapter");this.dropdown=new i(a,this.options),this.$dropdown=this.dropdown.render(),this.dropdown.position(this.$dropdown,g);var j=this.options.get("resultsAdapter");this.results=new j(a,this.options,this.dataAdapter),this.$results=this.results.render(),this.results.position(this.$results,this.$dropdown);var k=this;this._bindAdapters(),this._registerDomEvents(),this._registerDataEvents(),this._registerSelectionEvents(),this._registerDropdownEvents(),this._registerResultsEvents(),this._registerEvents(),this.dataAdapter.current(function(a){k.trigger("selection:update",{data:a})}),a.addClass("select2-hidden-accessible"),a.attr("aria-hidden","true"),this._syncAttributes(),a.data("select2",this)};return c.Extend(e,c.Observable),e.prototype._generateId=function(a){var b="";return b=null!=a.attr("id")?a.attr("id"):null!=a.attr("name")?a.attr("name")+"-"+c.generateChars(2):c.generateChars(4),b="select2-"+b},e.prototype._placeContainer=function(a){a.insertAfter(this.$element);var b=this._resolveWidth(this.$element,this.options.get("width"));null!=b&&a.css("width",b)},e.prototype._resolveWidth=function(a,b){var c=/^width:(([-+]?([0-9]*\.)?[0-9]+)(px|em|ex|%|in|cm|mm|pt|pc))/i;if("resolve"==b){var d=this._resolveWidth(a,"style");return null!=d?d:this._resolveWidth(a,"element")}if("element"==b){var e=a.outerWidth(!1);return 0>=e?"auto":e+"px"}if("style"==b){var f=a.attr("style");if("string"!=typeof f)return null;for(var g=f.split(";"),h=0,i=g.length;i>h;h+=1){var j=g[h].replace(/\s/g,""),k=j.match(c);if(null!==k&&k.length>=1)return k[1]}return null}return b},e.prototype._bindAdapters=function(){this.dataAdapter.bind(this,this.$container),this.selection.bind(this,this.$container),this.dropdown.bind(this,this.$container),this.results.bind(this,this.$container)},e.prototype._registerDomEvents=function(){var b=this;this.$element.on("change.select2",function(){b.dataAdapter.current(function(a){b.trigger("selection:update",{data:a})})}),this._sync=c.bind(this._syncAttributes,this),this.$element[0].attachEvent&&this.$element[0].attachEvent("onpropertychange",this._sync);var d=window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver;null!=d?(this._observer=new d(function(c){a.each(c,b._sync)}),this._observer.observe(this.$element[0],{attributes:!0,subtree:!1})):this.$element[0].addEventListener&&this.$element[0].addEventListener("DOMAttrModified",b._sync,!1)},e.prototype._registerDataEvents=function(){var a=this;this.dataAdapter.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerSelectionEvents=function(){var b=this,c=["toggle"];this.selection.on("toggle",function(){b.toggleDropdown()}),this.selection.on("*",function(d,e){-1===a.inArray(d,c)&&b.trigger(d,e)})},e.prototype._registerDropdownEvents=function(){var a=this;this.dropdown.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerResultsEvents=function(){var a=this;this.results.on("*",function(b,c){a.trigger(b,c)})},e.prototype._registerEvents=function(){var a=this;this.on("open",function(){a.$container.addClass("select2-container--open")}),this.on("close",function(){a.$container.removeClass("select2-container--open")}),this.on("enable",function(){a.$container.removeClass("select2-container--disabled")}),this.on("disable",function(){a.$container.addClass("select2-container--disabled")}),this.on("focus",function(){a.$container.addClass("select2-container--focus")}),this.on("blur",function(){a.$container.removeClass("select2-container--focus")}),this.on("query",function(b){a.isOpen()||a.trigger("open"),this.dataAdapter.query(b,function(c){a.trigger("results:all",{data:c,query:b})})}),this.on("query:append",function(b){this.dataAdapter.query(b,function(c){a.trigger("results:append",{data:c,query:b})})}),this.on("keypress",function(b){var c=b.which;a.isOpen()?c===d.ENTER?(a.trigger("results:select"),b.preventDefault()):c===d.SPACE&&b.ctrlKey?(a.trigger("results:toggle"),b.preventDefault()):c===d.UP?(a.trigger("results:previous"),b.preventDefault()):c===d.DOWN?(a.trigger("results:next"),b.preventDefault()):(c===d.ESC||c===d.TAB)&&(a.close(),b.preventDefault()):(c===d.ENTER||c===d.SPACE||(c===d.DOWN||c===d.UP)&&b.altKey)&&(a.open(),b.preventDefault())})},e.prototype._syncAttributes=function(){this.options.set("disabled",this.$element.prop("disabled")),this.options.get("disabled")?(this.isOpen()&&this.close(),this.trigger("disable")):this.trigger("enable")},e.prototype.trigger=function(a,b){var c=e.__super__.trigger,d={open:"opening",close:"closing",select:"selecting",unselect:"unselecting"};if(a in d){var f=d[a],g={prevented:!1,name:a,args:b};if(c.call(this,f,g),g.prevented)return void(b.prevented=!0)}c.call(this,a,b)},e.prototype.toggleDropdown=function(){this.options.get("disabled")||(this.isOpen()?this.close():this.open())},e.prototype.open=function(){this.isOpen()||(this.trigger("query",{}),this.trigger("open"))},e.prototype.close=function(){this.isOpen()&&this.trigger("close")},e.prototype.isOpen=function(){return this.$container.hasClass("select2-container--open")},e.prototype.enable=function(a){this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("enable")` method has been deprecated and will be removed in later Select2 versions. Use $element.prop("disabled") instead.'),(null==a||0===a.length)&&(a=[!0]);var b=!a[0];this.$element.prop("disabled",b)},e.prototype.data=function(){this.options.get("debug")&&arguments.length>0&&window.console&&console.warn&&console.warn('Select2: Data can no longer be set using `select2("data")`. You should consider setting the value instead using `$element.val()`.');var a=[];return this.dataAdapter.current(function(b){a=b}),a},e.prototype.val=function(b){if(this.options.get("debug")&&window.console&&console.warn&&console.warn('Select2: The `select2("val")` method has been deprecated and will be removed in later Select2 versions. Use $element.val() instead.'),null==b||0===b.length)return this.$element.val();var c=b[0];a.isArray(c)&&(c=a.map(c,function(a){return a.toString()})),this.$element.val(c).trigger("change")},e.prototype.destroy=function(){this.$container.remove(),this.$element[0].detachEvent&&this.$element[0].detachEvent("onpropertychange",this._sync),null!=this._observer?(this._observer.disconnect(),this._observer=null):this.$element[0].removeEventListener&&this.$element[0].removeEventListener("DOMAttrModified",this._sync,!1),this._sync=null,this.$element.off(".select2"),this.$element.attr("tabindex",this.$element.data("old-tabindex")),this.$element.removeClass("select2-hidden-accessible"),this.$element.attr("aria-hidden","false"),this.$element.removeData("select2"),this.dataAdapter.destroy(),this.selection.destroy(),this.dropdown.destroy(),this.results.destroy(),this.dataAdapter=null,this.selection=null,this.dropdown=null,this.results=null},e.prototype.render=function(){var b=a('');return b.attr("dir",this.options.get("dir")),this.$container=b,this.$container.addClass("select2-container--"+this.options.get("theme")),b.data("element",this.$element),b},e}),b.define("select2/compat/utils",["jquery"],function(a){function b(b,c,d){var e,f,g=[];e=a.trim(b.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0===this.indexOf("select2-")&&g.push(this)})),e=a.trim(c.attr("class")),e&&(e=""+e,a(e.split(/\s+/)).each(function(){0!==this.indexOf("select2-")&&(f=d(this),null!=f&&g.push(f))})),b.attr("class",g.join(" "))}return{syncCssClasses:b}}),b.define("select2/compat/containerCss",["jquery","./utils"],function(a,b){function c(){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("containerCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptContainerCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("containerCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/dropdownCss",["jquery","./utils"],function(a,b){function c(){return null}function d(){}return d.prototype.render=function(d){var e=d.call(this),f=this.options.get("dropdownCssClass")||"";a.isFunction(f)&&(f=f(this.$element));var g=this.options.get("adaptDropdownCssClass");if(g=g||c,-1!==f.indexOf(":all:")){f=f.replace(":all","");var h=g;g=function(a){var b=h(a);return null!=b?b+" "+a:a}}var i=this.options.get("dropdownCss")||{};return a.isFunction(i)&&(i=i(this.$element)),b.syncCssClasses(e,this.$element,g),e.css(i),e.addClass(f),e},d}),b.define("select2/compat/initSelection",["jquery"],function(a){function b(a,b,c){c.get("debug")&&window.console&&console.warn&&console.warn("Select2: The `initSelection` option has been deprecated in favor of a custom data adapter that overrides the `current` method. This method is now called multiple times instead of a single time when the instance is initialized. Support will be removed for the `initSelection` option in future versions of Select2"),this.initSelection=c.get("initSelection"),this._isInitialized=!1,a.call(this,b,c)}return b.prototype.current=function(b,c){var d=this;return this._isInitialized?void b.call(this,c):void this.initSelection.call(null,this.$element,function(b){d._isInitialized=!0,a.isArray(b)||(b=[b]),c(b)})},b}),b.define("select2/compat/inputData",["jquery"],function(a){function b(a,b,c){this._currentData=[],this._valueSeparator=c.get("valueSeparator")||",","hidden"===b.prop("type")&&c.get("debug")&&console&&console.warn&&console.warn("Select2: Using a hidden input with Select2 is no longer supported and may stop working in the future. It is recommended to use a `link(); ?> /> - - - - - - - value() ) ) { - $savedValueCSV = implode( ',', $this->value() ); - $values = $this->value(); - } else { - $savedValueCSV = $this->value(); - $values = explode( ',', $this->value() ); - } - - if ( self::$firstLoad ) { - self::$firstLoad = false; - - ?> - - - - - - - choices ) ) { - return; - } - - $name = '_customize-radio-' . $this->id; - - ?> - - - label; ?> - description ) ) : ?> - - description; ?> - - - -
      - choices as $value => $label ) : ?> - link(); checked( $this->value(), $value ); ?>> - - - -
      - - choices ) ) { - return; - } - - $name = '_customize-radio-' . $this->id; - - ?> - - - label; ?> - description ) ) : ?> - - description; ?> - - - -
      - choices as $value => $label ) : ?> - link(); checked( $this->value(), $value ); ?>> - - - -
      - - - - -
      - - - - - - - id ) ); + $class = 'customize-control customize-control-'.$this->type; ?> +
    • + render_content(); ?> +
    • + + + = 0; i--) { + hex = '0' + hex; + } + } + return '#' + hex; + }; + + $('.kirki-color-control').each(function() { + var $control = $(this), + value = $control.val().replace(/\s+/g, ''); + // Manage Palettes + var palette_input = $control.attr('data-palette'); + if (palette_input == 'false' || palette_input == false) { + var palette = false; + } else if (palette_input == 'true' || palette_input == true) { + var palette = true; + } else { + var palette = $control.attr('data-palette').split(","); + } + $control.wpColorPicker({ // change some things with the color picker + clear: function(event, ui) { + // TODO reset Alpha Slider to 100 + }, + change: function(event, ui) { + // send ajax request to wp.customizer to enable Save & Publish button + var _new_value = $control.val(); + var key = $control.attr('data-customize-setting-link'); + wp.customize(key, function(obj) { + obj.set(_new_value); + }); + // change the background color of our transparency container whenever a color is updated + var $transparency = $control.parents('.wp-picker-container:first').find('.transparency'); + // we only want to show the color at 100% alpha + $transparency.css('backgroundColor', ui.color.toString('no-alpha')); + }, + palettes: palette // remove the color palettes + }); + $('
      ').appendTo($control.parents('.wp-picker-container')); + var $alpha_slider = $control.parents('.wp-picker-container:first').find('.slider-alpha'); + // if in format RGBA - grab A channel value + if (value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)) { + var alpha_val = parseFloat(value.match(/rgba\(\d+\,\d+\,\d+\,([^\)]+)\)/)[1]) * 100; + var alpha_val = parseInt(alpha_val); + } else { + var alpha_val = 100; + } + $alpha_slider.slider({ + slide: function(event, ui) { + $(this).find('.ui-slider-handle').text(ui.value); // show value on slider handle + // send ajax request to wp.customizer to enable Save & Publish button + var _new_value = $control.val(); + var key = $control.attr('data-customize-setting-link'); + wp.customize(key, function(obj) { + obj.set(_new_value); + }); + }, + create: function(event, ui) { + var v = $(this).slider('value'); + $(this).find('.ui-slider-handle').text(v); + }, + value: alpha_val, + range: "max", + step: 1, + min: 1, + max: 100 + }); // slider + $alpha_slider.slider().on('slidechange', function(event, ui) { + var new_alpha_val = parseFloat(ui.value), + iris = $control.data('a8cIris'), + color_picker = $control.data('wpWpColorPicker'); + iris._color._alpha = new_alpha_val / 100.0; + $control.val(iris._color.toString()); + color_picker.toggler.css({ + backgroundColor: $control.val() + }); + // fix relationship between alpha slider and the 'side slider not updating. + var get_val = $control.val(); + $($control).wpColorPicker('color', get_val); + }); + }); // each + } +}); diff --git a/includes/plugins/kirki/includes/Controls/color-alpha/style.css b/includes/plugins/kirki/includes/Controls/color-alpha/style.css new file mode 100644 index 0000000..ce8e1f0 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/color-alpha/style.css @@ -0,0 +1,45 @@ +.customize-control-color-alpha .kirki-alpha-container { + box-sizing: padding-box; + display: none; + border: 1px solid #dfdfdf; + border-top: none; + background: #fff; + padding: 0 11px 6px; } + .customize-control-color-alpha .kirki-alpha-container .transparency { + height: 24px; + width: 100%; + background-color: #fff; + background-image: url("transparency-grid.png"); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.4) inset; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + padding: 0; } + .customize-control-color-alpha .kirki-alpha-container .ui-slider-handle { + color: #777; + background-color: #fff; + text-shadow: 0 1px 0 #fff; + text-decoration: none; + position: absolute; + z-index: 2; + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2); + border: 1px solid #aaa; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + opacity: 0.9; + margin-top: -2px; + height: 20px; + cursor: ew-resize; + font-size: 12px; + padding: 3px; } + .customize-control-color-alpha .kirki-alpha-container .ui-slider { + position: relative; + text-align: center; + width: 88%; } +.customize-control-color-alpha .wp-picker-container a.wp-picker-open ~ div.kirki-alpha-container { + display: block; } +.customize-control-color-alpha .customize-control-alphacolor .wp-picker-container .iris-picker { + border-bottom: none; } + +/*# sourceMappingURL=style.css.map */ diff --git a/includes/plugins/kirki/includes/Controls/color-alpha/style.css.map b/includes/plugins/kirki/includes/Controls/color-alpha/style.css.map new file mode 100644 index 0000000..46decd2 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/color-alpha/style.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAEI,qDAAuB;EACnB,UAAU,EAAE,WAAW;EACvB,OAAO,EAAE,IAAI;EACb,MAAM,EAAE,iBAAiB;EACzB,UAAU,EAAE,IAAI;EAChB,UAAU,EAAE,IAAI;EAChB,OAAO,EAAE,UAAU;EACnB,mEAAc;IACV,MAAM,EAAE,IAAI;IACZ,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,IAAI;IACtB,gBAAgB,EAAE,4BAA4B;IAC9C,UAAU,EAAE,gCAA6B;IACzC,qBAAqB,EAAE,GAAG;IAC1B,kBAAkB,EAAE,GAAG;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,CAAC;EAEd,uEAAkB;IACd,KAAK,EAAE,IAAI;IACX,gBAAgB,EAAE,IAAI;IACtB,WAAW,EAAE,YAAY;IACzB,eAAe,EAAE,IAAI;IACrB,QAAQ,EAAE,QAAQ;IAClB,OAAO,EAAE,CAAC;IACV,UAAU,EAAE,4BAAyB;IACrC,MAAM,EAAE,cAAc;IACtB,qBAAqB,EAAE,GAAG;IAC1B,kBAAkB,EAAE,GAAG;IACvB,aAAa,EAAE,GAAG;IAClB,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,IAAI;IAChB,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,SAAS;IACjB,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,GAAG;EAEhB,gEAAW;IACP,QAAQ,EAAE,QAAQ;IAClB,UAAU,EAAE,MAAM;IAClB,KAAK,EAAE,GAAG;AAGlB,gGAAkE;EAC9D,OAAO,EAAE,KAAK;AAElB,8FAAgE;EAC5D,aAAa,EAAE,IAAI", +"sources": ["style.scss"], +"names": [], +"file": "style.css" +} diff --git a/includes/plugins/kirki/includes/Controls/color-alpha/style.scss b/includes/plugins/kirki/includes/Controls/color-alpha/style.scss new file mode 100644 index 0000000..bf95a37 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/color-alpha/style.scss @@ -0,0 +1,52 @@ +// Color-Alpha Controls +.customize-control-color-alpha { + .kirki-alpha-container { + box-sizing: padding-box; + display: none; + border: 1px solid #dfdfdf; + border-top: none; + background: #fff; + padding: 0 11px 6px; + .transparency { + height: 24px; + width: 100%; + background-color: #fff; + background-image: url("transparency-grid.png"); + box-shadow: 0 0 5px rgba(0,0,0,0.4) inset; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + padding: 0; + } + .ui-slider-handle { + color: #777; + background-color: #fff; + text-shadow: 0 1px 0 #fff; + text-decoration: none; + position: absolute; + z-index: 2; + box-shadow: 0 1px 2px rgba(0,0,0,0.2); + border: 1px solid #aaa; + -webkit-border-radius: 4px; + -moz-border-radius: 4px; + border-radius: 4px; + opacity: 0.9; + margin-top: -2px; + height: 20px; + cursor: ew-resize; + font-size: 12px; + padding: 3px; + } + .ui-slider { + position: relative; + text-align: center; + width: 88%; + } + } + .wp-picker-container a.wp-picker-open ~ div.kirki-alpha-container { + display: block; + } + .customize-control-alphacolor .wp-picker-container .iris-picker { + border-bottom: none; + } +} diff --git a/includes/plugins/kirki/assets/images/transparency-grid.png b/includes/plugins/kirki/includes/Controls/color-alpha/transparency-grid.png similarity index 100% rename from includes/plugins/kirki/assets/images/transparency-grid.png rename to includes/plugins/kirki/includes/Controls/color-alpha/transparency-grid.png diff --git a/includes/plugins/kirki/includes/Controls/custom/class-kirki-controls-custom-control.php b/includes/plugins/kirki/includes/Controls/custom/class-kirki-controls-custom-control.php new file mode 100644 index 0000000..b714dd0 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/custom/class-kirki-controls-custom-control.php @@ -0,0 +1,53 @@ + + + + + + choices ) ) { + return; + } + ?> + + label ) ) : ?> + label ); ?> + + + description ) ) : ?> + description; ?> + + + value() ) ) ? explode( ',', $this->value() ) : $this->value(); ?> + +
        + choices as $value => $label ) : ?> +
      • + +
      • + +
      + + link(); ?> value="" /> + choices ) ) { + $min = ( isset( $this->choices['min'] ) ) ? ' min="'.esc_attr( $this->choices['min'] ).'"' : ''; + $max = ( isset( $this->choices['max'] ) ) ? ' max="'.esc_attr( $this->choices['max'] ).'"' : ''; + $step = ( isset( $this->choices['step'] ) ) ? ' step="'.esc_attr( $this->choices['step'] ).'"' : ''; + } else { + $min = ''; + $max = ''; + $step = ''; + } + ?> + + + + + h;h++){var k=g.eq(h);if(!i(k)){var l=k.data(c+"-options"),m=a.extend(!0,{$el:k},b,"object"===a.type(l)?l:{});k.addClass(d.classes.raw.element).data(s,m),e(c),d.methods._construct.apply(k,[m].concat(Array.prototype.slice.call(arguments,f?1:0)))}}return g}function h(a){d.functions.iterate.apply(this,[d.methods._destruct].concat(Array.prototype.slice.call(arguments,1))),this.removeClass(d.classes.raw.element).removeData(s)}function i(a){return a.data(s)}function k(b){if(this instanceof a){var c=d.methods[b];return"object"!==a.type(b)&&b?c&&0!==b.indexOf("_")?d.functions.iterate.apply(this,[c].concat(Array.prototype.slice.call(arguments,1))):this:g.apply(this,arguments)}}function p(c){var e=d.utilities[c]||d.utilities._initialize||!1;return e?e.apply(b,Array.prototype.slice.call(arguments,"object"===a.type(c)?0:1)):void 0}function q(b){d.defaults=a.extend(!0,d.defaults,b||{})}function r(b){for(var c=this,d=0,e=c.length;e>d;d++){var f=c.eq(d),g=i(f)||{};"undefined"!==a.type(g.$el)&&b.apply(f,[g].concat(Array.prototype.slice.call(arguments,1)))}return c}var s="fs-"+c;return d.initialized=!1,d.priority=d.priority||10,d.classes=f("classes",s,n,d.classes),d.events=f("events",c,o,d.events),d.functions=a.extend({getData:i,iterate:r},l,d.functions),d.methods=a.extend(!0,{_setup:a.noop,_construct:a.noop,_destruct:a.noop,_resize:!1,destroy:h},d.methods),d.utilities=a.extend(!0,{_initialize:!1,_delegate:!1,defaults:q},d.utilities),d.widget&&(a.fn[c]=k),a[c]=d.utilities._delegate||p,d.namespace=c,d.methods._resize&&(m.ResizeHandlers.push({namespace:c,priority:d.priority,callback:d.methods._resize}),m.ResizeHandlers.sort(j)),d}(c,d),m.Plugins[c]};var p=null,q=20;return m.$window.on("resize.fs",h),h(),a(function(){m.$body=a("body");for(var b in m.Plugins)m.Plugins.hasOwnProperty(b)&&e(b)}),o.clickTouchStart=o.click+" "+o.touchStart,g(),m}(jQuery,this,document); diff --git a/includes/plugins/kirki/includes/Controls/number/formstone-number.js b/includes/plugins/kirki/includes/Controls/number/formstone-number.js new file mode 100644 index 0000000..fbea979 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/number/formstone-number.js @@ -0,0 +1,3 @@ +/*! formstone v0.6.1 [number.js] 2015-05-22 | MIT License | formstone.it */ + +!function(a,b,c){"use strict";function d(){t=b.$body}function e(a){var b=parseFloat(this.attr("min")),c=parseFloat(this.attr("max"));a.min=b||0===b?b:!1,a.max=c||0===c?c:!1,a.step=parseFloat(this.attr("step"))||1,a.timer=null,a.digits=m(a.step),a.disabled=this.prop("disabled");var d="";d+='",d+='",this.wrap('
      ').after(d),a.$container=this.parent(p.base),a.$arrows=a.$container.find(p.arrow),this.on(r.keyPress,p.element,a,i),a.$container.on([r.touchStart,r.mouseDown].join(" "),p.arrow,a,j)}function f(a){a.$arrows.remove(),this.unwrap().off(r.namespace)}function g(a){a.disabled&&(this.prop("disabled",!1),a.$container.removeClass(q.disabled),a.disabled=!1)}function h(a){a.disabled||(this.prop("disabled",!0),a.$container.addClass(q.disabled),a.disabled=!0)}function i(a){var b=a.data;(38===a.keyCode||40===a.keyCode)&&(a.preventDefault(),l(b,38===a.keyCode?b.step:-b.step))}function j(b){s.killEvent(b),k(b);var c=b.data;if(!c.disabled){var d=a(b.target).hasClass(q.up)?c.step:-c.step;c.timer=s.startTimer(c.timer,110,function(){l(c,d,!1)},!0),l(c,d),t.on([r.touchEnd,r.mouseUp].join(" "),c,k)}}function k(a){s.killEvent(a);var b=a.data;s.clearTimer(b.timer,!0),t.off(r.namespace)}function l(b,c){var d=parseFloat(b.$el.val()),e=c;"undefined"===a.type(d)||isNaN(d)?e=b.min!==!1?b.min:0:b.min!==!1&&db.max&&(e-=b.step),e!==d&&(e=n(e,b.digits),b.$el.val(e).trigger(r.raw.change))}function m(a){var b=String(a);return b.indexOf(".")>-1?b.length-b.indexOf(".")-1:0}function n(a,b){var c=Math.pow(10,b);return Math.round(a*c)/c}var o=b.Plugin("number",{widget:!0,defaults:{customClass:"",labels:{up:"Up",down:"Down"}},classes:["arrow","up","down","disabled"],methods:{_setup:d,_construct:e,_destruct:f,enable:g,disable:h},events:{tap:"tap"}}),p=o.classes,q=p.raw,r=o.events,s=o.functions,t=null}(jQuery,Formstone); diff --git a/includes/plugins/kirki/includes/Controls/number/style.css b/includes/plugins/kirki/includes/Controls/number/style.css new file mode 100644 index 0000000..1a41c06 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/number/style.css @@ -0,0 +1,88 @@ +.customize-control-number .fs-number { + position: relative; + border-radius: 3px; + margin: 0 0 10px 0; + overflow: hidden; } +.customize-control-number .fs-number, +.customize-control-number .fs-number:after, +.customize-control-number .fs-number:before, +.customize-control-number .fs-number *, +.customize-control-number .fs-number *:after, +.customize-control-number .fs-number *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; } +.customize-control-number .fs-number-element { + width: 100%; + height: 2.5em; + background: #ffffff; + border: 1px solid #cccccc; + border-bottom-width: 2px; + border-radius: 3px; + color: #222222; + font-size: 15px; + line-height: 1; + overflow: hidden; + padding: 0 10px; + -moz-appearance: textfield; } + .customize-control-number .fs-number-element::-webkit-inner-spin-button, .customize-control-number .fs-number-element::-webkit-outer-spin-button { + margin: 0; + -webkit-appearance: none; } + .customize-control-number .fs-number-element::-ms-clear { + display: none; } + .customize-control-number .fs-number-element:focus { + background-color: #ffffff; } +.customize-control-number .fs-number-disabled .fs-number-element { + background: #ffffff; + border-color: #cccccc; + color: #cccccc; } +.customize-control-number .fs-number-arrow { + width: 25px; + height: 50%; + position: absolute; + right: 0; + z-index: 1; + background: #ffffff; + border: 1px solid #cccccc; + cursor: pointer; + display: block; + overflow: hidden; + text-indent: 200%; + white-space: nowrap; } + .customize-control-number .fs-number-arrow:focus { + outline: none; } + .customize-control-number .fs-number-arrow:after { + width: 0; + height: 0; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + content: ''; + display: block; + margin: auto; } + .customize-control-number .fs-number-arrow.fs-number-up { + top: 0; } + .customize-control-number .fs-number-arrow.fs-number-up:after { + border-bottom: 5px solid #666666; } + .customize-control-number .fs-number-arrow.fs-number-down { + bottom: 0; + border-top: none; } + .customize-control-number .fs-number-arrow.fs-number-down:after { + border-top: 5px solid #666666; } +.customize-control-number .no-opacity .fs-number-arrow { + text-indent: -999999px; } +.customize-control-number .fs-number-disabled .fs-number-arrow { + cursor: default; } + .customize-control-number .fs-number-disabled .fs-number-arrow:after { + border-top-color: #cccccc; + border-bottom-color: #cccccc; } + +/*# sourceMappingURL=style.css.map */ diff --git a/includes/plugins/kirki/includes/Controls/number/style.css.map b/includes/plugins/kirki/includes/Controls/number/style.css.map new file mode 100644 index 0000000..b3fd3af --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/number/style.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAEI,oCAAW;EACP,QAAQ,EAAE,QAAQ;EAClB,aAAa,EAAE,GAAG;EAClB,MAAM,EAAE,UAAU;EAClB,QAAQ,EAAE,MAAM;AAEpB;;;;;6CAKoB;EAChB,UAAU,EAAE,UAAU;EACtB,kBAAkB,EAAE,IAAI;EACxB,UAAU,EAAE,IAAI;EAChB,mBAAmB,EAAE,eAAe;EACpC,gBAAgB,EAAE,eAAe;EACjC,eAAe,EAAE,eAAe;EAChC,WAAW,EAAE,eAAe;AAEhC,4CAAmB;EACf,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,KAAK;EACb,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,iBAAiB;EACzB,mBAAmB,EAAE,GAAG;EACxB,aAAa,EAAE,GAAG;EAClB,KAAK,EAAE,OAAO;EACd,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,CAAC;EACd,QAAQ,EAAE,MAAM;EAChB,OAAO,EAAE,MAAM;EACf,eAAe,EAAE,SAAS;EAC1B,gJAC6B;IACzB,MAAM,EAAE,CAAC;IACT,kBAAkB,EAAE,IAAI;EAE5B,uDAAa;IACT,OAAO,EAAE,IAAI;EAEjB,kDAAQ;IACJ,gBAAgB,EAAE,OAAO;AAGjC,gEAAuC;EACnC,UAAU,EAAE,OAAO;EACnB,YAAY,EAAE,OAAO;EACrB,KAAK,EAAE,OAAO;AAElB,0CAAiB;EACb,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,GAAG;EACX,QAAQ,EAAE,QAAQ;EAClB,KAAK,EAAE,CAAC;EACR,OAAO,EAAE,CAAC;EACV,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,iBAAiB;EACzB,MAAM,EAAE,OAAO;EACf,OAAO,EAAE,KAAK;EACd,QAAQ,EAAE,MAAM;EAChB,WAAW,EAAE,IAAI;EACjB,WAAW,EAAE,MAAM;EACnB,gDAAQ;IACJ,OAAO,EAAE,IAAI;EAEjB,gDAAQ;IACJ,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,CAAC;IACN,KAAK,EAAE,CAAC;IACR,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,CAAC;IACP,WAAW,EAAE,qBAAqB;IAClC,YAAY,EAAE,qBAAqB;IACnC,OAAO,EAAE,EAAE;IACX,OAAO,EAAE,KAAK;IACd,MAAM,EAAE,IAAI;EAEhB,uDAAe;IACX,GAAG,EAAE,CAAC;EAEV,6DAAqB;IACjB,aAAa,EAAE,iBAAiB;EAEpC,yDAAiB;IACb,MAAM,EAAE,CAAC;IACT,UAAU,EAAE,IAAI;IAChB,+DAAQ;MACJ,UAAU,EAAE,iBAAiB;AAIzC,sDAA6B;EACzB,WAAW,EAAE,SAAS;AAGtB,8DAAiB;EACb,MAAM,EAAE,OAAO;EACf,oEAAQ;IACJ,gBAAgB,EAAE,OAAO;IACzB,mBAAmB,EAAE,OAAO", +"sources": ["style.scss"], +"names": [], +"file": "style.css" +} diff --git a/includes/plugins/kirki/includes/Controls/number/style.scss b/includes/plugins/kirki/includes/Controls/number/style.scss new file mode 100644 index 0000000..74b0119 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/number/style.scss @@ -0,0 +1,109 @@ +// Number Controls +.customize-control-number { + .fs-number { + position: relative; + border-radius: 3px; + margin: 0 0 10px 0; + overflow: hidden; + } + .fs-number, + .fs-number:after, + .fs-number:before, + .fs-number *, + .fs-number *:after, + .fs-number *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; + } + .fs-number-element { + width: 100%; + height: 2.5em; + background: #ffffff; + border: 1px solid #cccccc; + border-bottom-width: 2px; + border-radius: 3px; + color: #222222; + font-size: 15px; + line-height: 1; + overflow: hidden; + padding: 0 10px; + -moz-appearance: textfield; + &::-webkit-inner-spin-button, + &::-webkit-outer-spin-button { + margin: 0; + -webkit-appearance: none; + } + &::-ms-clear { + display: none; + } + &:focus { + background-color: #ffffff; + } + } + .fs-number-disabled .fs-number-element { + background: #ffffff; + border-color: #cccccc; + color: #cccccc; + } + .fs-number-arrow { + width: 25px; + height: 50%; + position: absolute; + right: 0; + z-index: 1; + background: #ffffff; + border: 1px solid #cccccc; + cursor: pointer; + display: block; + overflow: hidden; + text-indent: 200%; + white-space: nowrap; + &:focus { + outline: none; + } + &:after { + width: 0; + height: 0; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + border-left: 5px solid transparent; + border-right: 5px solid transparent; + content: ''; + display: block; + margin: auto; + } + &.fs-number-up { + top: 0; + } + &.fs-number-up:after { + border-bottom: 5px solid #666666; + } + &.fs-number-down { + bottom: 0; + border-top: none; + &:after { + border-top: 5px solid #666666; + } + } + } + .no-opacity .fs-number-arrow { + text-indent: -999999px; + } + .fs-number-disabled { + .fs-number-arrow { + cursor: default; + &:after { + border-top-color: #cccccc; + border-bottom-color: #cccccc; + } + } + } +} diff --git a/includes/plugins/kirki/includes/Controls/PaletteControl.php b/includes/plugins/kirki/includes/Controls/palette/class-kirki-controls-palette-control.php similarity index 51% rename from includes/plugins/kirki/includes/Controls/PaletteControl.php rename to includes/plugins/kirki/includes/Controls/palette/class-kirki-controls-palette-control.php index 5d593ff..b05fd1f 100644 --- a/includes/plugins/kirki/includes/Controls/PaletteControl.php +++ b/includes/plugins/kirki/includes/Controls/palette/class-kirki-controls-palette-control.php @@ -1,13 +1,33 @@ id; + $name = '_customize-palette-'.$this->id; ?> - - label; ?> + label ); ?> description ) ) : ?> - + description; ?>
      choices as $value => $colorSet ) : ?> - link(); checked( $this->value(), $value ); ?>> -
      ",d.length?d.addClass(p.label).wrap('
      ').before(f):this.before('
      '+f+"
      "),b.$checkbox=d.length?d.parents(o.base):this.prev(o.base),b.$marker=b.$checkbox.find(o.marker),b.$states=b.$checkbox.find(o.state),b.$label=d,this.is(":checked")&&b.$checkbox.addClass(p.checked),this.is(":disabled")&&b.$checkbox.addClass(p.disabled),this.wrap('
      '),this.on(q.focus,b,l).on(q.blur,b,m).on(q.change,b,i).on(q.click,b,h).on(q.deselect,b,k),b.$checkbox.touch({tap:!0}).on(q.tap,b,h)}function d(a){a.$checkbox.off(q.namespace).touch("destroy"),a.$marker.remove(),a.$states.remove(),a.$label.unwrap().removeClass(p.label),this.unwrap().off(q.namespace)}function e(a){this.prop("disabled",!1),a.$checkbox.removeClass(p.disabled)}function f(a){this.prop("disabled",!0),a.$checkbox.addClass(p.disabled)}function g(a){var b=a.$el.is(":disabled"),c=a.$el.is(":checked");b||(c?j({data:a}):k({data:a}))}function h(b){b.stopPropagation();var c=b.data;a(b.target).is(c.$el)||(b.preventDefault(),c.$el.trigger("click"))}function i(a){var b=a.data,c=b.$el.is(":disabled"),d=b.$el.is(":checked");c||(b.radio?j(a):d?j(a):k(a))}function j(b){b.data.radio&&a('input[name="'+b.data.group+'"]').not(b.data.$el).trigger("deselect"),b.data.$checkbox.addClass(p.checked)}function k(a){a.data.$checkbox.removeClass(p.checked)}function l(a){a.data.$checkbox.addClass(p.focus)}function m(a){a.data.$checkbox.removeClass(p.focus)}{var n=b.Plugin("checkbox",{widget:!0,defaults:{customClass:"",toggle:!1,labels:{on:"ON",off:"OFF"}},classes:["element_wrapper","label","marker","flag","radio","focus","checked","disabled","toggle","state","state_on","state_off"],methods:{_construct:c,_destruct:d,enable:e,disable:f,update:g},events:{deselect:"deselect",tap:"tap"}}),o=n.classes,p=o.raw,q=n.events;n.functions}}(jQuery,Formstone); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/switch/formstone-core.js b/includes/plugins/kirki/includes/Controls/switch/formstone-core.js new file mode 100644 index 0000000..bcd7108 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/switch/formstone-core.js @@ -0,0 +1,3 @@ +/*! formstone v0.6.14 [core.js] 2015-06-23 | MIT License | formstone.it */ + +var Formstone=this.Formstone=function(a,b,c){"use strict";function d(a){l.Plugins[a].initialized||(l.Plugins[a].methods._setup.call(c),l.Plugins[a].initialized=!0)}function e(a,b,c,d){var e,f={raw:{}};d=d||{};for(e in d)d.hasOwnProperty(e)&&("classes"===a?(f.raw[d[e]]=b+"-"+d[e],f[d[e]]="."+b+"-"+d[e]):(f.raw[e]=d[e],f[e]=d[e]+"."+b));for(e in c)c.hasOwnProperty(e)&&("classes"===a?(f.raw[e]=c[e].replace(/{ns}/g,b),f[e]=c[e].replace(/{ns}/g,"."+b)):(f.raw[e]=c[e].replace(/.{ns}/g,""),f[e]=c[e].replace(/{ns}/g,b)));return f}function f(){var a,b={transition:"transitionend",MozTransition:"transitionend",OTransition:"otransitionend",WebkitTransition:"webkitTransitionEnd"},d=["transition","-webkit-transition"],e={transform:"transform",MozTransform:"-moz-transform",OTransform:"-o-transform",msTransform:"-ms-transform",webkitTransform:"-webkit-transform"},f="transitionend",g="",h="",i=c.createElement("div");for(a in b)if(b.hasOwnProperty(a)&&a in i.style){f=b[a],l.support.transition=!0;break}o.transitionEnd=f+".{ns}";for(a in d)if(d.hasOwnProperty(a)&&d[a]in i.style){g=d[a];break}l.transition=g;for(a in e)if(e.hasOwnProperty(a)&&e[a]in i.style){l.support.transform=!0,h=e[a];break}l.transform=h}function g(){l.windowWidth=l.$window.width(),l.windowHeight=l.$window.height(),p=k.startTimer(p,q,h)}function h(){for(var a in l.ResizeHandlers)l.ResizeHandlers.hasOwnProperty(a)&&l.ResizeHandlers[a].callback.call(b,l.windowWidth,l.windowHeight)}function i(a,b){return parseInt(a.priority)-parseInt(b.priority)}var j=function(){this.Version="0.6.14",this.Plugins={},this.ResizeHandlers=[],this.window=b,this.$window=a(b),this.document=c,this.$document=a(c),this.$body=null,this.windowWidth=0,this.windowHeight=0,this.userAgent=b.navigator.userAgent||b.navigator.vendor||b.opera,this.isFirefox=/Firefox/i.test(this.userAgent),this.isChrome=/Chrome/i.test(this.userAgent),this.isSafari=/Safari/i.test(this.userAgent)&&!this.isChrome,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(this.userAgent),this.isFirefoxMobile=this.isFirefox&&this.isMobile,this.transform=null,this.transition=null,this.support={file:!!(b.File&&b.FileList&&b.FileReader),history:!!(b.history&&b.history.pushState&&b.history.replaceState),matchMedia:!(!b.matchMedia&&!b.msMatchMedia),raf:!(!b.requestAnimationFrame||!b.cancelAnimationFrame),touch:!!("ontouchstart"in b||b.DocumentTouch&&c instanceof b.DocumentTouch),transition:!1,transform:!1}},k={killEvent:function(a,b){try{a.preventDefault(),a.stopPropagation(),b&&a.stopImmediatePropagation()}catch(c){}},startTimer:function(a,b,c,d){return k.clearTimer(a),d?setInterval(c,b):setTimeout(c,b)},clearTimer:function(a,b){a&&(b?clearInterval(a):clearTimeout(a),a=null)},sortAsc:function(a,b){return parseInt(b)-parseInt(a)},sortDesc:function(a,b){return parseInt(b)-parseInt(a)}},l=new j,m=a.Deferred(),n={base:"{ns}",element:"{ns}-element"},o={namespace:".{ns}",blur:"blur.{ns}",change:"change.{ns}",click:"click.{ns}",dblClick:"dblclick.{ns}",drag:"drag.{ns}",dragEnd:"dragend.{ns}",dragEnter:"dragenter.{ns}",dragLeave:"dragleave.{ns}",dragOver:"dragover.{ns}",dragStart:"dragstart.{ns}",drop:"drop.{ns}",error:"error.{ns}",focus:"focus.{ns}",focusIn:"focusin.{ns}",focusOut:"focusout.{ns}",input:"input.{ns}",keyDown:"keydown.{ns}",keyPress:"keypress.{ns}",keyUp:"keyup.{ns}",load:"load.{ns}",mouseDown:"mousedown.{ns}",mouseEnter:"mouseenter.{ns}",mouseLeave:"mouseleave.{ns}",mouseMove:"mousemove.{ns}",mouseOut:"mouseout.{ns}",mouseOver:"mouseover.{ns}",mouseUp:"mouseup.{ns}",resize:"resize.{ns}",scroll:"scroll.{ns}",select:"select.{ns}",touchCancel:"touchcancel.{ns}",touchEnd:"touchend.{ns}",touchLeave:"touchleave.{ns}",touchMove:"touchmove.{ns}",touchStart:"touchstart.{ns}"};j.prototype.Plugin=function(c,f){return l.Plugins[c]=function(c,d){function f(b){var e="object"===a.type(b);b=a.extend(!0,{},d.defaults||{},e?b:{});for(var f=this,g=0,i=f.length;i>g;g++){var j=f.eq(g);if(!h(j)){var k="__"+d.guid++,l=d.classes.raw.base+k,m=j.data(c+"-options"),n=a.extend(!0,{$el:j,guid:k,rawGuid:l,dotGuid:"."+l},b,"object"===a.type(m)?m:{});j.addClass(d.classes.raw.element).data(s,n),d.methods._construct.apply(j,[n].concat(Array.prototype.slice.call(arguments,e?1:0)))}}return f}function g(){d.functions.iterate.apply(this,[d.methods._destruct].concat(Array.prototype.slice.call(arguments,1))),this.removeClass(d.classes.raw.element).removeData(s)}function h(a){return a.data(s)}function j(b){if(this instanceof a){var c=d.methods[b];return"object"!==a.type(b)&&b?c&&0!==b.indexOf("_")?d.functions.iterate.apply(this,[c].concat(Array.prototype.slice.call(arguments,1))):this:f.apply(this,arguments)}}function m(c){var e=d.utilities[c]||d.utilities._initialize||!1;return e?e.apply(b,Array.prototype.slice.call(arguments,"object"===a.type(c)?0:1)):void 0}function p(b){d.defaults=a.extend(!0,d.defaults,b||{})}function q(b){for(var c=this,d=0,e=c.length;e>d;d++){var f=c.eq(d),g=h(f)||{};"undefined"!==a.type(g.$el)&&b.apply(f,[g].concat(Array.prototype.slice.call(arguments,1)))}return c}var r="fs-"+c,s="fs"+c.replace(/(^|\s)([a-z])/g,function(a,b,c){return b+c.toUpperCase()});return d.initialized=!1,d.priority=d.priority||10,d.classes=e("classes",r,n,d.classes),d.events=e("events",c,o,d.events),d.functions=a.extend({getData:h,iterate:q},k,d.functions),d.methods=a.extend(!0,{_setup:a.noop,_construct:a.noop,_destruct:a.noop,_resize:!1,destroy:g},d.methods),d.utilities=a.extend(!0,{_initialize:!1,_delegate:!1,defaults:p},d.utilities),d.widget&&(a.fn[c]=a.fn[s]=j),a[c]=a[s]=d.utilities._delegate||m,d.namespace=c,d.namespaceClean=s,d.guid=0,d.methods._resize&&(l.ResizeHandlers.push({namespace:c,priority:d.priority,callback:d.methods._resize}),l.ResizeHandlers.sort(i)),d}(c,f),m.then(function(){d(c)}),l.Plugins[c]};var p=null,q=20;return l.$window.on("resize.fs",g),g(),a(function(){l.$body=a("body"),m.resolve()}),o.clickTouchStart=o.click+" "+o.touchStart,f(),l}(jQuery,this,document); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/switch/formstone-touch.js b/includes/plugins/kirki/includes/Controls/switch/formstone-touch.js new file mode 100644 index 0000000..f1f355b --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/switch/formstone-touch.js @@ -0,0 +1,3 @@ +/*! formstone v0.6.14 [touch.js] 2015-06-23 | MIT License | formstone.it */ + +!function(a,b){"use strict";function c(a){a.touches=[],a.touching=!1,this.on(r.dragStart,s.killEvent),a.tap?(a.pan=!1,a.scale=!1,a.swipe=!1,b.support.touch?this.on([r.touchStart,r.pointerDown].join(" "),a,f):this.on(r.click,a,k)):(a.pan||a.swipe||a.scale)&&(a.tap=!1,a.swipe&&(a.pan=!0),a.scale&&(a.axis=!1),a.axis?(a.axisX="x"===a.axis,a.axisY="y"===a.axis):o(this,"none"),this.on([r.touchStart,r.pointerDown].join(" "),a,e),a.pan&&!b.support.touch&&this.on(r.mouseDown,a,f))}function d(){this.off(r.namespace),o(this,"")}function e(a){a.preventManipulation&&a.preventManipulation();var b=a.data,c=a.originalEvent;if(c.type.match(/(up|end)$/i))return void j(a);if(c.pointerId){var d=!1;for(var e in b.touches)b.touches[e].id===c.pointerId&&(d=!0,b.touches[e].pageX=c.clientX,b.touches[e].pageY=c.clientY);d||b.touches.push({id:c.pointerId,pageX:c.clientX,pageY:c.clientY})}else b.touches=c.touches;c.type.match(/(down|start)$/i)?f(a):c.type.match(/move$/i)&&g(a)}function f(b){var c=b.data,d="undefined"!==a.type(c.touches)?c.touches[0]:null;if(c.touching||(c.startE=b.originalEvent,c.startX=d?d.pageX:b.pageX,c.startY=d?d.pageY:b.pageY,c.startT=(new Date).getTime(),c.scaleD=1,c.passed=!1),c.tap)c.clicked=!1,c.$el.on([r.touchMove,r.pointerMove].join(" "),c,e).on([r.touchEnd,r.touchCancel,r.pointerUp,r.pointerCancel].join(" "),c,e);else if(c.pan||c.scale){c.$links&&c.$links.off(r.click);var f=l(c.scale?r.scaleStart:r.panStart,b,c.startX,c.startY,c.scaleD,0,0,"","");if(c.scale&&c.touches&&c.touches.length>=2){var h=c.touches;c.pinch={startX:m(h[0].pageX,h[1].pageX),startY:m(h[0].pageY,h[1].pageY),startD:n(h[1].pageX-h[0].pageX,h[1].pageY-h[0].pageY)},f.pageX=c.startX=c.pinch.startX,f.pageY=c.startY=c.pinch.startY}c.touching||(c.touching=!0,c.pan&&t.on(r.mouseMove,c,g).on(r.mouseUp,c,j),t.on([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel].join(" "),c,e),c.$el.trigger(f))}}function g(b){var c=b.data,d="undefined"!==a.type(c.touches)?c.touches[0]:null,e=d?d.pageX:b.pageX,f=d?d.pageY:b.pageY,g=e-c.startX,h=f-c.startY,i=g>0?"right":"left",k=h>0?"down":"up",o=Math.abs(g)>u,p=Math.abs(h)>u;if(c.tap)(o||p)&&c.$el.off([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel].join(" "));else if(c.pan||c.scale)if(!c.passed&&c.axis&&(c.axisX&&p||c.axisY&&o))j(b);else{!c.passed&&(!c.axis||c.axis&&c.axisX&&o||c.axisY&&p)&&(c.passed=!0),c.passed&&(s.killEvent(b),s.killEvent(c.startE));var q=!0,t=l(c.scale?r.scale:r.pan,b,e,f,c.scaleD,g,h,i,k);if(c.scale)if(c.touches&&c.touches.length>=2){var v=c.touches;c.pinch.endX=m(v[0].pageX,v[1].pageX),c.pinch.endY=m(v[0].pageY,v[1].pageY),c.pinch.endD=n(v[1].pageX-v[0].pageX,v[1].pageY-v[0].pageY),c.scaleD=c.pinch.endD/c.pinch.startD,t.pageX=c.pinch.endX,t.pageY=c.pinch.endY,t.scale=c.scaleD,t.deltaX=c.pinch.endX-c.pinch.startX,t.deltaY=c.pinch.endY-c.pinch.startY}else c.pan||(q=!1);q&&c.$el.trigger(t)}}function h(b,c){b.on(r.click,c,i);var d=a._data(b[0],"events").click;d.unshift(d.pop())}function i(a){s.killEvent(a,!0),a.data.$links.off(r.click)}function j(b){var c=b.data;if(c.tap)c.$el.off([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel,r.mouseMove,r.mouseUp].join(" ")),c.startE.preventDefault(),k(b);else if(c.pan||c.scale){var d="undefined"!==a.type(c.touches)?c.touches[0]:null,e=d?d.pageX:b.pageX,f=d?d.pageY:b.pageY,g=e-c.startX,i=f-c.startY,j=(new Date).getTime(),m=c.scale?r.scaleEnd:r.panEnd,n=g>0?"right":"left",o=i>0?"down":"up",p=Math.abs(g)>1,q=Math.abs(i)>1;if(c.swipe&&Math.abs(g)>u&&j-c.startTs;s++)h(c.$links.eq(s),c)}var x=l(m,b,e,f,c.scaleD,g,i,n,o);t.off([r.touchMove,r.touchEnd,r.touchCancel,r.mouseMove,r.mouseUp,r.pointerMove,r.pointerUp,r.pointerCancel].join(" ")),c.$el.trigger(x),c.touches=[],c.scale}c.touching=!1}function k(a){s.killEvent(a);var b=a.data;if(!b.clicked){"click"!==a.type&&(b.clicked=!0);var c=b.startE?b.startX:a.pageX,d=b.startE?b.startY:a.pageY,e=l(r.tap,a.originalEvent,c,d,1,0,0);b.$el.trigger(e)}}function l(b,c,d,e,f,g,h,i,j){return a.Event(b,{originalEvent:c,bubbles:!0,pageX:d,pageY:e,scale:f,deltaX:g,deltaY:h,directionX:i,directionY:j})}function m(a,b){return(a+b)/2}function n(a,b){return Math.sqrt(a*a+b*b)}function o(a,b){a.css({"-ms-touch-action":b,"touch-action":b})}var p=!b.window.PointerEvent,q=b.Plugin("touch",{widget:!0,defaults:{axis:!1,pan:!1,scale:!1,swipe:!1,tap:!1},methods:{_construct:c,_destruct:d},events:{pointerDown:p?"MSPointerDown":"pointerdown",pointerUp:p?"MSPointerUp":"pointerup",pointerMove:p?"MSPointerMove":"pointermove",pointerCancel:p?"MSPointerCancel":"pointercancel"}}),r=q.events,s=q.functions,t=b.$window,u=10,v=50;r.tap="tap",r.pan="pan",r.panStart="panstart",r.panEnd="panend",r.scale="scale",r.scaleStart="scalestart",r.scaleEnd="scaleend",r.swipe="swipe"}(jQuery,Formstone); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/switch/style.css b/includes/plugins/kirki/includes/Controls/switch/style.css new file mode 100644 index 0000000..32dd8f6 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/switch/style.css @@ -0,0 +1,189 @@ +.customize-control-switch .fs-checkbox.fs-checkbox-enabled { + cursor: pointer; + margin: 0 0 10px 0; + overflow: hidden; } + .customize-control-switch .fs-checkbox.fs-checkbox-enabled:focus { + box-shadow: none; + outline: none; } +.customize-control-switch .fs-checkbox-element_wrapper { + position: relative; + border: 0; + height: 0; + margin: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; } +.customize-control-switch .fs-checkbox-element { + position: absolute; + top: 0; + left: 0; + z-index: -1; + pointer-events: none; + -webkit-transition: none; + transition: none; } +.customize-control-switch .fs-checkbox-label { + color: #666666; + cursor: pointer; + display: block; + font-size: 14px; + line-height: 20px; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } +.customize-control-switch .fs-checkbox-marker { + width: 20px; + height: 20px; + background: #ffffff; + border: 1px solid #cccccc; + border-radius: 3px; + cursor: pointer; + display: block; + float: left; + margin: 0 10px 0 0; + float: right; } +.customize-control-switch .fs-checkbox-flag { + width: 100%; + height: 100%; + margin: 0; } + .customize-control-switch .fs-checkbox-flag:before { + width: 5px; + height: 10px; + border: 2px solid #999999; + border-top: 0; + border-left: 0; + content: ''; + display: block; + margin: 3px 0 0 6px; + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + -webkit-transform: rotate(45deg) scale(0); + -ms-transform: rotate(45deg) scale(0); + transform: rotate(45deg) scale(0); } +.customize-control-switch .fs-checkbox-checked .fs-checkbox-flag:before { + -webkit-transform: rotate(45deg) scale(1); + -ms-transform: rotate(45deg) scale(1); + transform: rotate(45deg) scale(1); } +.customize-control-switch .fs-checkbox, +.customize-control-switch .fs-checkbox:after, +.customize-control-switch .fs-checkbox:before, +.customize-control-switch .fs-checkbox *, +.customize-control-switch .fs-checkbox *:after, +.customize-control-switch .fs-checkbox *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; } +.customize-control-switch .no-csstransforms .fs-checkbox-flag:before { + width: 100%; + height: 100%; + content: "\2713"; + display: none; + line-height: 1; + text-align: center; } +.customize-control-switch .no-csstransforms .fs-checkbox-checked .fs-checkbox-flag:before { + display: block; } +.customize-control-switch .fs-checkbox-radio .fs-checkbox-marker { + border-radius: 100%; } +.customize-control-switch .fs-checkbox-radio .fs-checkbox-flag { + background: #999999; + border: 3px solid #ffffff; + border-radius: 100%; + -webkit-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; } + .customize-control-switch .fs-checkbox-radio .fs-checkbox-flag:before { + display: none; } +.customize-control-switch .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag { + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); } + .customize-control-switch .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag:before { + display: none; } +.customize-control-switch .no-csstransforms .fs-checkbox-radio .fs-checkbox-flag:before { + display: none; } +.customize-control-switch .no-csstransforms .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag:before { + display: block; } +.customize-control-switch .fs-checkbox-focus .fs-checkbox-label { + color: #333333; } +.customize-control-switch .fs-checkbox-focus .fs-checkbox-marker { + border-color: #999999; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } +.customize-control-switch .fs-checkbox-disabled { + cursor: default; + opacity: 0.5; } +.customize-control-switch .fs-checkbox-disabled .fs-checkbox-label { + color: #666666; + cursor: default; } +.customize-control-switch .fs-checkbox-disabled .fs-checkbox-marker { + border-color: #cccccc; + cursor: default; } +.customize-control-switch .fs-checkbox-toggle { + position: relative; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-label { + line-height: 40px; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-marker { + width: 100px; + height: 40px; + position: relative; + border-radius: 3px; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-marker:after { + clear: both; + content: ''; + display: table; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-flag { + width: 50%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #999999; + border: 2px solid #ffffff; + border-radius: 3px; + display: block; + margin: 0; + -webkit-transition: left 0.15s ease; + transition: left 0.15s ease; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-flag:before { + display: none; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-flag:after { + width: 2px; + height: 10px; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #ffffff; + box-shadow: 3px 0 0 #ffffff, -3px 0 0 #ffffff; + content: ''; + margin: auto; + opacity: 0.75; } + .customize-control-switch .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag { + left: 50%; } + .customize-control-switch .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag:before { + display: none; } + .customize-control-switch .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag:after { + display: none; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-state { + width: 50%; + color: #666666; + display: block; + font-size: 12px; + line-height: 40px; + margin: 0; + text-align: center; + text-transform: uppercase; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-state_on { + float: left; } + .customize-control-switch .fs-checkbox-toggle .fs-checkbox-state_off { + float: right; } +.customize-control-switch .no-touch .fs-checkbox-toggle:hover .fs-checkbox-flag:after { + opacity: 1; } diff --git a/includes/plugins/kirki/includes/Controls/switch/style.css.map b/includes/plugins/kirki/includes/Controls/switch/style.css.map new file mode 100644 index 0000000..51bd72e --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/switch/style.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAGI;iCAAQ;EACJ,QAAQ,EAAE,QAAQ;EAClB,OAAO,EAAE,YAAY;EACrB,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,IAAI;EACjB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,GAAG;EACZ,MAAM,EAAE,cAAc;EACtB,MAAM,EAAE,4BAAyB;EACjC,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,KAAK;EACZ,UAAU,EAAE,qBAAqB;EACjC;2CAAQ;IACJ,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,4BAAyB;IACjC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,qBAAqB;EAErC;;;wCACK;IACD,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,IAAI;EAEb;uCAAI;IACA,KAAK,EAAE,IAAI;EAGX;8CAAQ;IACJ,IAAI,EAAE,GAAG;EAIb;+CAAQ;IACJ,IAAI,EAAE,EAAE;EAGhB;yCAAQ;IACJ,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,GAAG;IACf;mDAAQ;MACJ,aAAa,EAAE,IAAI;MACnB,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,IAAI;IAGZ;uDAAQ;MACJ,IAAI,EAAE,EAAE;IAGhB;8CAAK;MACD,KAAK,EAAE,IAAI;MACX,UAAU,EAAE,IAAI;MAChB;wDAAQ;QACJ,IAAI,EAAE,GAAG;;AAM7B,gBAAiB;EACb,KAAK,EAAE,IAAI;;AAEf,sBAAuB;EACnB,KAAK,EAAE,GAAG", +"sources": ["style.scss"], +"names": [], +"file": "style.css" +} diff --git a/includes/plugins/kirki/includes/Controls/switch/style.scss b/includes/plugins/kirki/includes/Controls/switch/style.scss new file mode 100644 index 0000000..0c5ae73 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/switch/style.scss @@ -0,0 +1,267 @@ +.customize-control-switch { + .fs-checkbox { + &.fs-checkbox-enabled { + cursor: pointer; + margin: 0 0 10px 0; + overflow: hidden; + &:focus { + box-shadow: none; + outline: none; + } + } + &-element_wrapper { + position: relative; + border: 0; + height: 0; + margin: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; + } + &-element { + position: absolute; + top: 0; + left: 0; + z-index: -1; + pointer-events: none; + -webkit-transition: none; + transition: none; + } + &-label { + color: #666666; + cursor: pointer; + display: block; + font-size: 14px; + line-height: 20px; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + &-marker { + width: 20px; + height: 20px; + background: #ffffff; + border: 1px solid #cccccc; + border-radius: 3px; + cursor: pointer; + display: block; + float: left; + margin: 0 10px 0 0; + float: right; + } + &-flag { + width: 100%; + height: 100%; + margin: 0; + &:before { + width: 5px; + height: 10px; + border: 2px solid #999999; + border-top: 0; + border-left: 0; + content: ''; + display: block; + margin: 3px 0 0 6px; + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + -webkit-transform: rotate(45deg) scale(0); + -ms-transform: rotate(45deg) scale(0); + transform: rotate(45deg) scale(0); + } + } + &-checked { + .fs-checkbox-flag:before { + -webkit-transform: rotate(45deg) scale(1); + -ms-transform: rotate(45deg) scale(1); + transform: rotate(45deg) scale(1); + } + } + } + + .fs-checkbox, + .fs-checkbox:after, + .fs-checkbox:before, + .fs-checkbox *, + .fs-checkbox *:after, + .fs-checkbox *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; + } + + .no-csstransforms { + .fs-checkbox-flag { + &:before { + width: 100%; + height: 100%; + content: "\2713"; + display: none; + line-height: 1; + text-align: center; + } + } + .fs-checkbox-checked { + .fs-checkbox-flag{ + &:before { + display: block; + } + } + } + } + + .fs-checkbox-radio { + .fs-checkbox-marker { + border-radius: 100%; + } + .fs-checkbox-flag { + background: #999999; + border: 3px solid #ffffff; + border-radius: 100%; + -webkit-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + &:before { + display: none; + } + } + &.fs-checkbox-checked { + .fs-checkbox-flag { + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); + &:before { + display: none; + } + } + } + } + + .no-csstransforms { + .fs-checkbox-radio { + .fs-checkbox-flag { + &:before { + display: none; + } + } + &.fs-checkbox-checked .fs-checkbox-flag:before { + display: block; + } + } + } + + .fs-checkbox-focus { + .fs-checkbox-label { + color: #333333; + } + .fs-checkbox-marker { + border-color: #999999; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); + } + } + + .fs-checkbox-disabled { + cursor: default; + opacity: 0.5; + } + + .fs-checkbox-disabled { + .fs-checkbox-label { + color: #666666; + cursor: default; + } + .fs-checkbox-marker { + border-color: #cccccc; + cursor: default; + } + } + + .fs-checkbox-toggle { + position: relative; + .fs-checkbox-label { + line-height: 40px; + } + .fs-checkbox-marker { + width: 100px; + height: 40px; + position: relative; + border-radius: 3px; + } + .fs-checkbox-marker:after { + clear: both; + content: ''; + display: table; + } + .fs-checkbox-flag { + width: 50%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #999999; + border: 2px solid #ffffff; + border-radius: 3px; + display: block; + margin: 0; + -webkit-transition: left 0.15s ease; + transition: left 0.15s ease; + &:before { + display: none; + } + &:after { + width: 2px; + height: 10px; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #ffffff; + box-shadow: 3px 0 0 #ffffff, -3px 0 0 #ffffff; + content: ''; + margin: auto; + opacity: 0.75; + } + } + &.fs-checkbox-checked { + .fs-checkbox-flag { + left: 50%; + &:before { + display: none; + } + &:after { + display: none; + } + } + } + .fs-checkbox-state { + width: 50%; + color: #666666; + display: block; + font-size: 12px; + line-height: 40px; + margin: 0; + text-align: center; + text-transform: uppercase; + } + .fs-checkbox-state_on { + float: left; + } + .fs-checkbox-state_off { + float: right; + } + } + .no-touch { + .fs-checkbox-toggle:hover .fs-checkbox-flag:after { + opacity: 1; + } + } +} diff --git a/includes/plugins/kirki/includes/Controls/toggle/class-kirki-controls-toggle-control.php b/includes/plugins/kirki/includes/Controls/toggle/class-kirki-controls-toggle-control.php new file mode 100644 index 0000000..d203934 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/class-kirki-controls-toggle-control.php @@ -0,0 +1,51 @@ + + + + link(); checked( $this->value() ); ?> /> + + ',f+='
      ',b.toggle&&(e+=" "+p.toggle,f+=''+b.labels.on+"",f+=''+b.labels.off+""),b.radio&&(e+=" "+p.radio),f+="
      ",d.length?d.addClass(p.label).wrap('
      ').before(f):this.before('
      '+f+"
      "),b.$checkbox=d.length?d.parents(o.base):this.prev(o.base),b.$marker=b.$checkbox.find(o.marker),b.$states=b.$checkbox.find(o.state),b.$label=d,this.is(":checked")&&b.$checkbox.addClass(p.checked),this.is(":disabled")&&b.$checkbox.addClass(p.disabled),this.wrap('
      '),this.on(q.focus,b,l).on(q.blur,b,m).on(q.change,b,i).on(q.click,b,h).on(q.deselect,b,k),b.$checkbox.touch({tap:!0}).on(q.tap,b,h)}function d(a){a.$checkbox.off(q.namespace).touch("destroy"),a.$marker.remove(),a.$states.remove(),a.$label.unwrap().removeClass(p.label),this.unwrap().off(q.namespace)}function e(a){this.prop("disabled",!1),a.$checkbox.removeClass(p.disabled)}function f(a){this.prop("disabled",!0),a.$checkbox.addClass(p.disabled)}function g(a){var b=a.$el.is(":disabled"),c=a.$el.is(":checked");b||(c?j({data:a}):k({data:a}))}function h(b){b.stopPropagation();var c=b.data;a(b.target).is(c.$el)||(b.preventDefault(),c.$el.trigger("click"))}function i(a){var b=a.data,c=b.$el.is(":disabled"),d=b.$el.is(":checked");c||(b.radio?j(a):d?j(a):k(a))}function j(b){b.data.radio&&a('input[name="'+b.data.group+'"]').not(b.data.$el).trigger("deselect"),b.data.$checkbox.addClass(p.checked)}function k(a){a.data.$checkbox.removeClass(p.checked)}function l(a){a.data.$checkbox.addClass(p.focus)}function m(a){a.data.$checkbox.removeClass(p.focus)}{var n=b.Plugin("checkbox",{widget:!0,defaults:{customClass:"",toggle:!1,labels:{on:"ON",off:"OFF"}},classes:["element_wrapper","label","marker","flag","radio","focus","checked","disabled","toggle","state","state_on","state_off"],methods:{_construct:c,_destruct:d,enable:e,disable:f,update:g},events:{deselect:"deselect",tap:"tap"}}),o=n.classes,p=o.raw,q=n.events;n.functions}}(jQuery,Formstone); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/toggle/formstone-core.js b/includes/plugins/kirki/includes/Controls/toggle/formstone-core.js new file mode 100644 index 0000000..bcd7108 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/formstone-core.js @@ -0,0 +1,3 @@ +/*! formstone v0.6.14 [core.js] 2015-06-23 | MIT License | formstone.it */ + +var Formstone=this.Formstone=function(a,b,c){"use strict";function d(a){l.Plugins[a].initialized||(l.Plugins[a].methods._setup.call(c),l.Plugins[a].initialized=!0)}function e(a,b,c,d){var e,f={raw:{}};d=d||{};for(e in d)d.hasOwnProperty(e)&&("classes"===a?(f.raw[d[e]]=b+"-"+d[e],f[d[e]]="."+b+"-"+d[e]):(f.raw[e]=d[e],f[e]=d[e]+"."+b));for(e in c)c.hasOwnProperty(e)&&("classes"===a?(f.raw[e]=c[e].replace(/{ns}/g,b),f[e]=c[e].replace(/{ns}/g,"."+b)):(f.raw[e]=c[e].replace(/.{ns}/g,""),f[e]=c[e].replace(/{ns}/g,b)));return f}function f(){var a,b={transition:"transitionend",MozTransition:"transitionend",OTransition:"otransitionend",WebkitTransition:"webkitTransitionEnd"},d=["transition","-webkit-transition"],e={transform:"transform",MozTransform:"-moz-transform",OTransform:"-o-transform",msTransform:"-ms-transform",webkitTransform:"-webkit-transform"},f="transitionend",g="",h="",i=c.createElement("div");for(a in b)if(b.hasOwnProperty(a)&&a in i.style){f=b[a],l.support.transition=!0;break}o.transitionEnd=f+".{ns}";for(a in d)if(d.hasOwnProperty(a)&&d[a]in i.style){g=d[a];break}l.transition=g;for(a in e)if(e.hasOwnProperty(a)&&e[a]in i.style){l.support.transform=!0,h=e[a];break}l.transform=h}function g(){l.windowWidth=l.$window.width(),l.windowHeight=l.$window.height(),p=k.startTimer(p,q,h)}function h(){for(var a in l.ResizeHandlers)l.ResizeHandlers.hasOwnProperty(a)&&l.ResizeHandlers[a].callback.call(b,l.windowWidth,l.windowHeight)}function i(a,b){return parseInt(a.priority)-parseInt(b.priority)}var j=function(){this.Version="0.6.14",this.Plugins={},this.ResizeHandlers=[],this.window=b,this.$window=a(b),this.document=c,this.$document=a(c),this.$body=null,this.windowWidth=0,this.windowHeight=0,this.userAgent=b.navigator.userAgent||b.navigator.vendor||b.opera,this.isFirefox=/Firefox/i.test(this.userAgent),this.isChrome=/Chrome/i.test(this.userAgent),this.isSafari=/Safari/i.test(this.userAgent)&&!this.isChrome,this.isMobile=/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(this.userAgent),this.isFirefoxMobile=this.isFirefox&&this.isMobile,this.transform=null,this.transition=null,this.support={file:!!(b.File&&b.FileList&&b.FileReader),history:!!(b.history&&b.history.pushState&&b.history.replaceState),matchMedia:!(!b.matchMedia&&!b.msMatchMedia),raf:!(!b.requestAnimationFrame||!b.cancelAnimationFrame),touch:!!("ontouchstart"in b||b.DocumentTouch&&c instanceof b.DocumentTouch),transition:!1,transform:!1}},k={killEvent:function(a,b){try{a.preventDefault(),a.stopPropagation(),b&&a.stopImmediatePropagation()}catch(c){}},startTimer:function(a,b,c,d){return k.clearTimer(a),d?setInterval(c,b):setTimeout(c,b)},clearTimer:function(a,b){a&&(b?clearInterval(a):clearTimeout(a),a=null)},sortAsc:function(a,b){return parseInt(b)-parseInt(a)},sortDesc:function(a,b){return parseInt(b)-parseInt(a)}},l=new j,m=a.Deferred(),n={base:"{ns}",element:"{ns}-element"},o={namespace:".{ns}",blur:"blur.{ns}",change:"change.{ns}",click:"click.{ns}",dblClick:"dblclick.{ns}",drag:"drag.{ns}",dragEnd:"dragend.{ns}",dragEnter:"dragenter.{ns}",dragLeave:"dragleave.{ns}",dragOver:"dragover.{ns}",dragStart:"dragstart.{ns}",drop:"drop.{ns}",error:"error.{ns}",focus:"focus.{ns}",focusIn:"focusin.{ns}",focusOut:"focusout.{ns}",input:"input.{ns}",keyDown:"keydown.{ns}",keyPress:"keypress.{ns}",keyUp:"keyup.{ns}",load:"load.{ns}",mouseDown:"mousedown.{ns}",mouseEnter:"mouseenter.{ns}",mouseLeave:"mouseleave.{ns}",mouseMove:"mousemove.{ns}",mouseOut:"mouseout.{ns}",mouseOver:"mouseover.{ns}",mouseUp:"mouseup.{ns}",resize:"resize.{ns}",scroll:"scroll.{ns}",select:"select.{ns}",touchCancel:"touchcancel.{ns}",touchEnd:"touchend.{ns}",touchLeave:"touchleave.{ns}",touchMove:"touchmove.{ns}",touchStart:"touchstart.{ns}"};j.prototype.Plugin=function(c,f){return l.Plugins[c]=function(c,d){function f(b){var e="object"===a.type(b);b=a.extend(!0,{},d.defaults||{},e?b:{});for(var f=this,g=0,i=f.length;i>g;g++){var j=f.eq(g);if(!h(j)){var k="__"+d.guid++,l=d.classes.raw.base+k,m=j.data(c+"-options"),n=a.extend(!0,{$el:j,guid:k,rawGuid:l,dotGuid:"."+l},b,"object"===a.type(m)?m:{});j.addClass(d.classes.raw.element).data(s,n),d.methods._construct.apply(j,[n].concat(Array.prototype.slice.call(arguments,e?1:0)))}}return f}function g(){d.functions.iterate.apply(this,[d.methods._destruct].concat(Array.prototype.slice.call(arguments,1))),this.removeClass(d.classes.raw.element).removeData(s)}function h(a){return a.data(s)}function j(b){if(this instanceof a){var c=d.methods[b];return"object"!==a.type(b)&&b?c&&0!==b.indexOf("_")?d.functions.iterate.apply(this,[c].concat(Array.prototype.slice.call(arguments,1))):this:f.apply(this,arguments)}}function m(c){var e=d.utilities[c]||d.utilities._initialize||!1;return e?e.apply(b,Array.prototype.slice.call(arguments,"object"===a.type(c)?0:1)):void 0}function p(b){d.defaults=a.extend(!0,d.defaults,b||{})}function q(b){for(var c=this,d=0,e=c.length;e>d;d++){var f=c.eq(d),g=h(f)||{};"undefined"!==a.type(g.$el)&&b.apply(f,[g].concat(Array.prototype.slice.call(arguments,1)))}return c}var r="fs-"+c,s="fs"+c.replace(/(^|\s)([a-z])/g,function(a,b,c){return b+c.toUpperCase()});return d.initialized=!1,d.priority=d.priority||10,d.classes=e("classes",r,n,d.classes),d.events=e("events",c,o,d.events),d.functions=a.extend({getData:h,iterate:q},k,d.functions),d.methods=a.extend(!0,{_setup:a.noop,_construct:a.noop,_destruct:a.noop,_resize:!1,destroy:g},d.methods),d.utilities=a.extend(!0,{_initialize:!1,_delegate:!1,defaults:p},d.utilities),d.widget&&(a.fn[c]=a.fn[s]=j),a[c]=a[s]=d.utilities._delegate||m,d.namespace=c,d.namespaceClean=s,d.guid=0,d.methods._resize&&(l.ResizeHandlers.push({namespace:c,priority:d.priority,callback:d.methods._resize}),l.ResizeHandlers.sort(i)),d}(c,f),m.then(function(){d(c)}),l.Plugins[c]};var p=null,q=20;return l.$window.on("resize.fs",g),g(),a(function(){l.$body=a("body"),m.resolve()}),o.clickTouchStart=o.click+" "+o.touchStart,f(),l}(jQuery,this,document); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/toggle/formstone-touch.js b/includes/plugins/kirki/includes/Controls/toggle/formstone-touch.js new file mode 100644 index 0000000..f1f355b --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/formstone-touch.js @@ -0,0 +1,3 @@ +/*! formstone v0.6.14 [touch.js] 2015-06-23 | MIT License | formstone.it */ + +!function(a,b){"use strict";function c(a){a.touches=[],a.touching=!1,this.on(r.dragStart,s.killEvent),a.tap?(a.pan=!1,a.scale=!1,a.swipe=!1,b.support.touch?this.on([r.touchStart,r.pointerDown].join(" "),a,f):this.on(r.click,a,k)):(a.pan||a.swipe||a.scale)&&(a.tap=!1,a.swipe&&(a.pan=!0),a.scale&&(a.axis=!1),a.axis?(a.axisX="x"===a.axis,a.axisY="y"===a.axis):o(this,"none"),this.on([r.touchStart,r.pointerDown].join(" "),a,e),a.pan&&!b.support.touch&&this.on(r.mouseDown,a,f))}function d(){this.off(r.namespace),o(this,"")}function e(a){a.preventManipulation&&a.preventManipulation();var b=a.data,c=a.originalEvent;if(c.type.match(/(up|end)$/i))return void j(a);if(c.pointerId){var d=!1;for(var e in b.touches)b.touches[e].id===c.pointerId&&(d=!0,b.touches[e].pageX=c.clientX,b.touches[e].pageY=c.clientY);d||b.touches.push({id:c.pointerId,pageX:c.clientX,pageY:c.clientY})}else b.touches=c.touches;c.type.match(/(down|start)$/i)?f(a):c.type.match(/move$/i)&&g(a)}function f(b){var c=b.data,d="undefined"!==a.type(c.touches)?c.touches[0]:null;if(c.touching||(c.startE=b.originalEvent,c.startX=d?d.pageX:b.pageX,c.startY=d?d.pageY:b.pageY,c.startT=(new Date).getTime(),c.scaleD=1,c.passed=!1),c.tap)c.clicked=!1,c.$el.on([r.touchMove,r.pointerMove].join(" "),c,e).on([r.touchEnd,r.touchCancel,r.pointerUp,r.pointerCancel].join(" "),c,e);else if(c.pan||c.scale){c.$links&&c.$links.off(r.click);var f=l(c.scale?r.scaleStart:r.panStart,b,c.startX,c.startY,c.scaleD,0,0,"","");if(c.scale&&c.touches&&c.touches.length>=2){var h=c.touches;c.pinch={startX:m(h[0].pageX,h[1].pageX),startY:m(h[0].pageY,h[1].pageY),startD:n(h[1].pageX-h[0].pageX,h[1].pageY-h[0].pageY)},f.pageX=c.startX=c.pinch.startX,f.pageY=c.startY=c.pinch.startY}c.touching||(c.touching=!0,c.pan&&t.on(r.mouseMove,c,g).on(r.mouseUp,c,j),t.on([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel].join(" "),c,e),c.$el.trigger(f))}}function g(b){var c=b.data,d="undefined"!==a.type(c.touches)?c.touches[0]:null,e=d?d.pageX:b.pageX,f=d?d.pageY:b.pageY,g=e-c.startX,h=f-c.startY,i=g>0?"right":"left",k=h>0?"down":"up",o=Math.abs(g)>u,p=Math.abs(h)>u;if(c.tap)(o||p)&&c.$el.off([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel].join(" "));else if(c.pan||c.scale)if(!c.passed&&c.axis&&(c.axisX&&p||c.axisY&&o))j(b);else{!c.passed&&(!c.axis||c.axis&&c.axisX&&o||c.axisY&&p)&&(c.passed=!0),c.passed&&(s.killEvent(b),s.killEvent(c.startE));var q=!0,t=l(c.scale?r.scale:r.pan,b,e,f,c.scaleD,g,h,i,k);if(c.scale)if(c.touches&&c.touches.length>=2){var v=c.touches;c.pinch.endX=m(v[0].pageX,v[1].pageX),c.pinch.endY=m(v[0].pageY,v[1].pageY),c.pinch.endD=n(v[1].pageX-v[0].pageX,v[1].pageY-v[0].pageY),c.scaleD=c.pinch.endD/c.pinch.startD,t.pageX=c.pinch.endX,t.pageY=c.pinch.endY,t.scale=c.scaleD,t.deltaX=c.pinch.endX-c.pinch.startX,t.deltaY=c.pinch.endY-c.pinch.startY}else c.pan||(q=!1);q&&c.$el.trigger(t)}}function h(b,c){b.on(r.click,c,i);var d=a._data(b[0],"events").click;d.unshift(d.pop())}function i(a){s.killEvent(a,!0),a.data.$links.off(r.click)}function j(b){var c=b.data;if(c.tap)c.$el.off([r.touchMove,r.touchEnd,r.touchCancel,r.pointerMove,r.pointerUp,r.pointerCancel,r.mouseMove,r.mouseUp].join(" ")),c.startE.preventDefault(),k(b);else if(c.pan||c.scale){var d="undefined"!==a.type(c.touches)?c.touches[0]:null,e=d?d.pageX:b.pageX,f=d?d.pageY:b.pageY,g=e-c.startX,i=f-c.startY,j=(new Date).getTime(),m=c.scale?r.scaleEnd:r.panEnd,n=g>0?"right":"left",o=i>0?"down":"up",p=Math.abs(g)>1,q=Math.abs(i)>1;if(c.swipe&&Math.abs(g)>u&&j-c.startTs;s++)h(c.$links.eq(s),c)}var x=l(m,b,e,f,c.scaleD,g,i,n,o);t.off([r.touchMove,r.touchEnd,r.touchCancel,r.mouseMove,r.mouseUp,r.pointerMove,r.pointerUp,r.pointerCancel].join(" ")),c.$el.trigger(x),c.touches=[],c.scale}c.touching=!1}function k(a){s.killEvent(a);var b=a.data;if(!b.clicked){"click"!==a.type&&(b.clicked=!0);var c=b.startE?b.startX:a.pageX,d=b.startE?b.startY:a.pageY,e=l(r.tap,a.originalEvent,c,d,1,0,0);b.$el.trigger(e)}}function l(b,c,d,e,f,g,h,i,j){return a.Event(b,{originalEvent:c,bubbles:!0,pageX:d,pageY:e,scale:f,deltaX:g,deltaY:h,directionX:i,directionY:j})}function m(a,b){return(a+b)/2}function n(a,b){return Math.sqrt(a*a+b*b)}function o(a,b){a.css({"-ms-touch-action":b,"touch-action":b})}var p=!b.window.PointerEvent,q=b.Plugin("touch",{widget:!0,defaults:{axis:!1,pan:!1,scale:!1,swipe:!1,tap:!1},methods:{_construct:c,_destruct:d},events:{pointerDown:p?"MSPointerDown":"pointerdown",pointerUp:p?"MSPointerUp":"pointerup",pointerMove:p?"MSPointerMove":"pointermove",pointerCancel:p?"MSPointerCancel":"pointercancel"}}),r=q.events,s=q.functions,t=b.$window,u=10,v=50;r.tap="tap",r.pan="pan",r.panStart="panstart",r.panEnd="panend",r.scale="scale",r.scaleStart="scalestart",r.scaleEnd="scaleend",r.swipe="swipe"}(jQuery,Formstone); \ No newline at end of file diff --git a/includes/plugins/kirki/includes/Controls/toggle/style.css b/includes/plugins/kirki/includes/Controls/toggle/style.css new file mode 100644 index 0000000..b8ceee1 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/style.css @@ -0,0 +1,190 @@ +.customize-control-toggle .fs-checkbox.fs-checkbox-enabled { + cursor: pointer; + margin: 0 0 10px 0; + overflow: hidden; } + .customize-control-toggle .fs-checkbox.fs-checkbox-enabled:focus { + box-shadow: none; + outline: none; } +.customize-control-toggle .fs-checkbox-element_wrapper { + position: relative; + border: 0; + height: 0; + margin: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; } +.customize-control-toggle .fs-checkbox-element { + position: absolute; + top: 0; + left: 0; + z-index: -1; + pointer-events: none; + -webkit-transition: none; + transition: none; } +.customize-control-toggle .fs-checkbox-label { + color: #666666; + cursor: pointer; + display: block; + font-size: 14px; + line-height: 20px; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } +.customize-control-toggle .fs-checkbox-marker { + width: 20px; + height: 20px; + background: #ffffff; + border: 1px solid #cccccc; + border-radius: 3px; + cursor: pointer; + display: block; + float: left; + margin: 0 10px 0 0; + float: right; } +.customize-control-toggle .fs-checkbox-flag { + width: 100%; + height: 100%; + margin: 0; } + .customize-control-toggle .fs-checkbox-flag:before { + width: 5px; + height: 10px; + border: 2px solid #999999; + border-top: 0; + border-left: 0; + content: ''; + display: block; + margin: 3px 0 0 6px; + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + -webkit-transform: rotate(45deg) scale(0); + -ms-transform: rotate(45deg) scale(0); + transform: rotate(45deg) scale(0); } +.customize-control-toggle .fs-checkbox-checked .fs-checkbox-flag:before { + -webkit-transform: rotate(45deg) scale(1); + -ms-transform: rotate(45deg) scale(1); + transform: rotate(45deg) scale(1); } +.customize-control-toggle .fs-checkbox, +.customize-control-toggle .fs-checkbox:after, +.customize-control-toggle .fs-checkbox:before, +.customize-control-toggle .fs-checkbox *, +.customize-control-toggle .fs-checkbox *:after, +.customize-control-toggle .fs-checkbox *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; } +.customize-control-toggle .no-csstransforms .fs-checkbox-flag:before { + width: 100%; + height: 100%; + content: "\2713"; + display: none; + line-height: 1; + text-align: center; } +.customize-control-toggle .no-csstransforms .fs-checkbox-checked .fs-checkbox-flag:before { + display: block; } +.customize-control-toggle .fs-checkbox-radio .fs-checkbox-marker { + border-radius: 100%; } +.customize-control-toggle .fs-checkbox-radio .fs-checkbox-flag { + background: #999999; + border: 3px solid #ffffff; + border-radius: 100%; + -webkit-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; } + .customize-control-toggle .fs-checkbox-radio .fs-checkbox-flag:before { + display: none; } +.customize-control-toggle .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag { + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); } + .customize-control-toggle .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag:before { + display: none; } +.customize-control-toggle .no-csstransforms .fs-checkbox-radio .fs-checkbox-flag:before { + display: none; } +.customize-control-toggle .no-csstransforms .fs-checkbox-radio.fs-checkbox-checked .fs-checkbox-flag:before { + display: block; } +.customize-control-toggle .fs-checkbox-focus .fs-checkbox-label { + color: #333333; } +.customize-control-toggle .fs-checkbox-focus .fs-checkbox-marker { + border-color: #999999; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); } +.customize-control-toggle .fs-checkbox-disabled { + cursor: default; + opacity: 0.5; } +.customize-control-toggle .fs-checkbox-disabled .fs-checkbox-label { + color: #666666; + cursor: default; } +.customize-control-toggle .fs-checkbox-disabled .fs-checkbox-marker { + border-color: #cccccc; + cursor: default; } +.customize-control-toggle .fs-checkbox-toggle { + position: relative; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-label { + line-height: 40px; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-marker { + width: 50px; + height: 20px; + position: relative; + border-radius: 3px; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-marker:after { + clear: both; + content: ''; + display: table; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-flag { + width: 50%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #999999; + border: 2px solid #ffffff; + border-radius: 3px; + display: block; + margin: 0; + -webkit-transition: left 0.15s ease; + transition: left 0.15s ease; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-flag:before { + display: none; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-flag:after { + width: 2px; + height: 10px; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #ffffff; + box-shadow: 3px 0 0 #ffffff, -3px 0 0 #ffffff; + content: ''; + margin: auto; + opacity: 0.75; } + .customize-control-toggle .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag { + left: 50%; } + .customize-control-toggle .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag:before { + display: none; } + .customize-control-toggle .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag:after { + display: none; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-state { + width: 50%; + color: #666666; + display: block; + font-size: 12px; + line-height: 40px; + margin: 0; + text-align: center; + text-transform: uppercase; + text-indent: -9999px; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-state_on { + float: left; } + .customize-control-toggle .fs-checkbox-toggle .fs-checkbox-state_off { + float: right; } +.customize-control-toggle .no-touch .fs-checkbox-toggle:hover .fs-checkbox-flag:after { + opacity: 1; } diff --git a/includes/plugins/kirki/includes/Controls/toggle/style.css.map b/includes/plugins/kirki/includes/Controls/toggle/style.css.map new file mode 100644 index 0000000..51bd72e --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/style.css.map @@ -0,0 +1,7 @@ +{ +"version": 3, +"mappings": "AAGI;iCAAQ;EACJ,QAAQ,EAAE,QAAQ;EAClB,OAAO,EAAE,YAAY;EACrB,SAAS,EAAE,IAAI;EACf,WAAW,EAAE,IAAI;EACjB,KAAK,EAAE,IAAI;EACX,MAAM,EAAE,IAAI;EACZ,WAAW,EAAE,IAAI;EACjB,OAAO,EAAE,GAAG;EACZ,MAAM,EAAE,cAAc;EACtB,MAAM,EAAE,4BAAyB;EACjC,UAAU,EAAE,OAAO;EACnB,MAAM,EAAE,OAAO;EACf,KAAK,EAAE,KAAK;EACZ,UAAU,EAAE,qBAAqB;EACjC;2CAAQ;IACJ,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,GAAG;IACR,KAAK,EAAE,IAAI;IACX,MAAM,EAAE,IAAI;IACZ,MAAM,EAAE,cAAc;IACtB,MAAM,EAAE,4BAAyB;IACjC,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE,GAAG;IACZ,UAAU,EAAE,qBAAqB;EAErC;;;wCACK;IACD,OAAO,EAAE,YAAY;IACrB,KAAK,EAAE,IAAI;IACX,QAAQ,EAAE,QAAQ;IAClB,GAAG,EAAE,IAAI;EAEb;uCAAI;IACA,KAAK,EAAE,IAAI;EAGX;8CAAQ;IACJ,IAAI,EAAE,GAAG;EAIb;+CAAQ;IACJ,IAAI,EAAE,EAAE;EAGhB;yCAAQ;IACJ,OAAO,EAAE,MAAM;IACf,aAAa,EAAE,IAAI;IACnB,UAAU,EAAE,GAAG;IACf;mDAAQ;MACJ,aAAa,EAAE,IAAI;MACnB,KAAK,EAAE,IAAI;MACX,MAAM,EAAE,IAAI;IAGZ;uDAAQ;MACJ,IAAI,EAAE,EAAE;IAGhB;8CAAK;MACD,KAAK,EAAE,IAAI;MACX,UAAU,EAAE,IAAI;MAChB;wDAAQ;QACJ,IAAI,EAAE,GAAG;;AAM7B,gBAAiB;EACb,KAAK,EAAE,IAAI;;AAEf,sBAAuB;EACnB,KAAK,EAAE,GAAG", +"sources": ["style.scss"], +"names": [], +"file": "style.css" +} diff --git a/includes/plugins/kirki/includes/Controls/toggle/style.scss b/includes/plugins/kirki/includes/Controls/toggle/style.scss new file mode 100644 index 0000000..064c2d5 --- /dev/null +++ b/includes/plugins/kirki/includes/Controls/toggle/style.scss @@ -0,0 +1,268 @@ +.customize-control-toggle { + .fs-checkbox { + &.fs-checkbox-enabled { + cursor: pointer; + margin: 0 0 10px 0; + overflow: hidden; + &:focus { + box-shadow: none; + outline: none; + } + } + &-element_wrapper { + position: relative; + border: 0; + height: 0; + margin: 0; + opacity: 0; + overflow: hidden; + padding: 0; + width: 0; + } + &-element { + position: absolute; + top: 0; + left: 0; + z-index: -1; + pointer-events: none; + -webkit-transition: none; + transition: none; + } + &-label { + color: #666666; + cursor: pointer; + display: block; + font-size: 14px; + line-height: 20px; + overflow: hidden; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + } + &-marker { + width: 20px; + height: 20px; + background: #ffffff; + border: 1px solid #cccccc; + border-radius: 3px; + cursor: pointer; + display: block; + float: left; + margin: 0 10px 0 0; + float: right; + } + &-flag { + width: 100%; + height: 100%; + margin: 0; + &:before { + width: 5px; + height: 10px; + border: 2px solid #999999; + border-top: 0; + border-left: 0; + content: ''; + display: block; + margin: 3px 0 0 6px; + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + -webkit-transform: rotate(45deg) scale(0); + -ms-transform: rotate(45deg) scale(0); + transform: rotate(45deg) scale(0); + } + } + &-checked { + .fs-checkbox-flag:before { + -webkit-transform: rotate(45deg) scale(1); + -ms-transform: rotate(45deg) scale(1); + transform: rotate(45deg) scale(1); + } + } + } + + .fs-checkbox, + .fs-checkbox:after, + .fs-checkbox:before, + .fs-checkbox *, + .fs-checkbox *:after, + .fs-checkbox *:before { + box-sizing: border-box; + -webkit-transition: none; + transition: none; + -webkit-user-select: none !important; + -moz-user-select: none !important; + -ms-user-select: none !important; + user-select: none !important; + } + + .no-csstransforms { + .fs-checkbox-flag { + &:before { + width: 100%; + height: 100%; + content: "\2713"; + display: none; + line-height: 1; + text-align: center; + } + } + .fs-checkbox-checked { + .fs-checkbox-flag{ + &:before { + display: block; + } + } + } + } + + .fs-checkbox-radio { + .fs-checkbox-marker { + border-radius: 100%; + } + .fs-checkbox-flag { + background: #999999; + border: 3px solid #ffffff; + border-radius: 100%; + -webkit-transform: scale(0); + -ms-transform: scale(0); + transform: scale(0); + -webkit-transition: -webkit-transform 0.15s ease; + transition: transform 0.15s ease; + &:before { + display: none; + } + } + &.fs-checkbox-checked { + .fs-checkbox-flag { + -webkit-transform: scale(1); + -ms-transform: scale(1); + transform: scale(1); + &:before { + display: none; + } + } + } + } + + .no-csstransforms { + .fs-checkbox-radio { + .fs-checkbox-flag { + &:before { + display: none; + } + } + &.fs-checkbox-checked .fs-checkbox-flag:before { + display: block; + } + } + } + + .fs-checkbox-focus { + .fs-checkbox-label { + color: #333333; + } + .fs-checkbox-marker { + border-color: #999999; + box-shadow: 0 0 5px rgba(0, 0, 0, 0.1); + } + } + + .fs-checkbox-disabled { + cursor: default; + opacity: 0.5; + } + + .fs-checkbox-disabled { + .fs-checkbox-label { + color: #666666; + cursor: default; + } + .fs-checkbox-marker { + border-color: #cccccc; + cursor: default; + } + } + + .fs-checkbox-toggle { + position: relative; + .fs-checkbox-label { + line-height: 40px; + } + .fs-checkbox-marker { + width: 50px; + height: 20px; + position: relative; + border-radius: 3px; + } + .fs-checkbox-marker:after { + clear: both; + content: ''; + display: table; + } + .fs-checkbox-flag { + width: 50%; + height: 100%; + position: absolute; + top: 0; + left: 0; + background: #999999; + border: 2px solid #ffffff; + border-radius: 3px; + display: block; + margin: 0; + -webkit-transition: left 0.15s ease; + transition: left 0.15s ease; + &:before { + display: none; + } + &:after { + width: 2px; + height: 10px; + position: absolute; + top: 0; + right: 0; + bottom: 0; + left: 0; + background: #ffffff; + box-shadow: 3px 0 0 #ffffff, -3px 0 0 #ffffff; + content: ''; + margin: auto; + opacity: 0.75; + } + } + &.fs-checkbox-checked { + .fs-checkbox-flag { + left: 50%; + &:before { + display: none; + } + &:after { + display: none; + } + } + } + .fs-checkbox-state { + width: 50%; + color: #666666; + display: block; + font-size: 12px; + line-height: 40px; + margin: 0; + text-align: center; + text-transform: uppercase; + text-indent: -9999px; + } + .fs-checkbox-state_on { + float: left; + } + .fs-checkbox-state_off { + float: right; + } + } + .no-touch { + .fs-checkbox-toggle:hover .fs-checkbox-flag:after { + opacity: 1; + } + } +} diff --git a/includes/plugins/kirki/includes/Fields.php b/includes/plugins/kirki/includes/Fields.php deleted file mode 100644 index 3aed35b..0000000 --- a/includes/plugins/kirki/includes/Fields.php +++ /dev/null @@ -1,585 +0,0 @@ -fields == null ) { - - $fields = apply_filters( 'kirki/controls', array() ); - $fields = apply_filters( 'kirki/fields', $fields ); - $fields = $this->build_background_fields( $fields ); - - $this->fields = array(); - foreach ( $fields as $field ) { - $field = $this->sanitize_field( $field ); - $this->fields[$field['settings']] = $field; - } - - } - - return $this->fields; - } - - /** - * Sanitizes the field - * - * @param array the field definition - * @return array - */ - public function sanitize_field( $field ) { - - $field['default'] = $this->sanitize_default( $field ); - $field['label'] = $this->sanitize_label( $field ); - $field['help'] = $this->sanitize_help( $field ); - $field['description'] = $this->sanitize_description( $field ); - $field['required'] = $this->sanitize_required( $field ); - $field['transport'] = $this->sanitize_transport( $field ); - $field['type'] = $this->sanitize_control_type( $field ); - $field['option_type'] = $this->sanitize_type( $field ); - $field['section'] = $this->sanitize_section( $field ); - $field['settings'] = $this->sanitize_settings( $field ); - $field['priority'] = $this->sanitize_priority( $field ); - $field['choices'] = $this->sanitize_choices( $field ); - $field['output'] = $this->sanitize_output( $field ); - $field['sanitize_callback'] = $this->sanitize_callback( $field ); - $field['js_vars'] = $this->sanitize_js_vars( $field ); - $field['id'] = $this->sanitize_id( $field ); - $field['capability'] = $this->sanitize_capability( $field ); - - return $field; - - } - - /** - * Sanitizes the control type. - * - * @param array the field definition - * @return string. If not set, then defaults to text. - */ - public function sanitize_control_type( $field ) { - - if ( ! isset( $field['type'] ) ) { - return 'text'; - } - - if ( 'checkbox' == $field['type'] ) { - - $field['type'] = ( isset( $field['mode'] ) && 'switch' == $field['mode'] ) ? 'switch' : $field['type']; - $field['type'] = ( isset( $field['mode'] ) && 'toggle' == $field['mode'] ) ? 'toggle' : $field['type']; - - } elseif ( 'radio' == $field['type'] ) { - - $field['type'] = ( isset( $field['mode'] ) && 'buttonset' == $field['mode'] ) ? 'radio-buttonset' : $field['type']; - $field['type'] = ( isset( $field['mode'] ) && 'image' == $field['mode'] ) ? 'radio-image' : $field['type']; - - } elseif ( 'group-title' == $field['type'] || 'group_title' == $field['type'] ) { - - $field['type'] = 'custom'; - - } elseif ( 'color' == $field['type'] && false !== strpos( $field['default'], 'rgba' ) ) { - - $field['type'] = 'color-alpha'; - - } - - return esc_attr( $field['type'] ); - - } - - /** - * Sanitizes the setting type. - * - * @param array the field definition - * @return string. (theme_mod|option) - */ - public function sanitize_type( $field ) { - $config = Kirki::config()->get_all(); - return esc_attr( $config['options_type'] ); - } - - /** - * Sanitizes the setting permissions. - * - * @param array the field definition - * @return string. (theme_mod|option) - */ - public function sanitize_capability( $field ) { - if ( ! isset( $field['capability'] ) ) { - $config = Kirki::config()->get_all(); - return esc_attr( $config['capability'] ); - } else { - return esc_attr( $field['capability'] ); - } - } - - /** - * Sanitizes the setting name - * - * @param array the field definition - * @return string. - */ - public function sanitize_settings( $field ) { - - /** - * Compatibility tweak - * Previous versions of the Kirki customizer used 'setting' istead of 'settings'. - */ - if ( ! isset( $field['settings'] ) && isset( $field['setting'] ) ) { - $field['settings'] = $field['setting']; - } - - return esc_attr( $field['settings'] ); - - } - - /** - * Sanitizes the control label. - * - * @param array the field definition - * @return string - */ - public function sanitize_label( $field ) { - return ( isset( $field['label'] ) ) ? esc_html( $field['label'] ) : ''; - } - - /** - * Sanitizes the control section - * - * @param array the field definition - * @return string - */ - public function sanitize_section( $field ) { - return sanitize_key( $field['section'] ); - } - - /** - * Sanitizes the control id - * - * @param array the field definition - * @return string - */ - public function sanitize_id( $field ) { - $id = str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ); - return sanitize_key( $id ); - } - - /** - * Sanitizes the setting default value - * - * @param array the field definition - * @return mixed - */ - public function sanitize_default( $field ) { - // If ['default'] is not set, set an empty value - if ( ! isset( $field['default'] ) ) { - $field['default'] = ''; - } - - /** - * Sortable controls need a serialized array as the default value. - * Since we're using normal arrays to set our defaults when defining the fields, we need to serialize that value here. - */ - if ( 'sortable' == $field['type'] && isset( $field['default'] ) && ! empty( $field['default'] ) ) { - $field['default'] = maybe_serialize( $field['default'] ); - } - - return $field['default']; - - } - - /** - * Sanitizes the control description - * - * @param array the field definition - * @return string - */ - public function sanitize_description( $field ) { - - /** - * Compatibility tweak - * - * Previous verions of the Kirki Customizer had the 'description' field mapped to the new 'help' - * and instead of 'description' we were using 'subtitle'. - * This has been deprecated in favor of WordPress core's 'description' field that was recently introduced. - * - */ - if ( isset( $field['subtitle'] ) ) { - $field['description'] = $field['subtitle']; - } - - return ( isset( $field['description'] ) ) ? esc_html( $field['description'] ) : ''; - - } - - /** - * Sanitizes the control help - * - * @param array the field definition - * @return string - */ - public function sanitize_help( $field ) { - - /** - * Compatibility tweak - * - * Previous verions of the Kirki Customizer had the 'description' field mapped to the new 'help' - * and instead of 'description' we were using 'subtitle'. - * This has been deprecated in favor of WordPress core's 'description' field that was recently introduced. - * - */ - if ( isset( $field['subtitle'] ) ) { - // Use old arguments form. - $field['help'] = ( isset( $field['description'] ) ) ? $field['description'] : ''; - } - return isset( $field['help'] ) ? esc_html( $field['help'] ) : ''; - - } - - /** - * Sanitizes the control choices. - * - * @param array the field definition - * @return array - */ - public function sanitize_choices( $field ) { - return isset( $field['choices'] ) ? $field['choices'] : array(); - } - - /** - * Sanitizes the control output - * - * @param array the field definition - * @return array - */ - public function sanitize_output( $field ) { - // Further sanitization on the values of the array happens near the output. - // This just makes sure the value is defined to avoid errors. - return isset( $field['output'] ) ? $field['output'] : null; - } - - /** - * Sanitizes the control transport. - * - * @param array the field definition - * @return string postMessage|refresh (defaults to refresh) - */ - public function sanitize_transport( $field ) { - return ( isset( $field['transport'] ) && 'postMessage' == $field['transport'] ) ? 'postMessage' : 'refresh'; - } - - /** - * Sanitizes the setting sanitize_callback - * - * @param array the field definition - * @return mixed the sanitization callback for this setting - */ - public function sanitize_callback( $field ) { - - if ( isset( $field['sanitize_callback'] ) && ! empty( $field['sanitize_callback'] ) ) { - return $field['sanitize_callback']; - } else { // Fallback callback - return self::fallback_callback( $field['type'] ); - } - - } - - /** - * Sanitizes the control js_vars. - * - * @param array the field definition - * @return array - */ - public function sanitize_js_vars( $field ) { - if ( isset( $field['js_vars'] ) ) { - return $field['js_vars']; - } else { - return null; - } - } - - /** - * Sanitizes the control required argument. - * - * @param array the field definition - * @return array - */ - public function sanitize_required( $field ) { - // The individual options of the array get sanitized in the Required class. - // We're just making sure this is defined here. - return isset( $field['required'] ) ? $field['required'] : array(); - } - - /** - * Sanitizes the control priority - * - * @param array the field definition - * @return int - */ - public function sanitize_priority( $field ) { - - if ( isset( $field['priority'] ) ) { - return intval( $field['priority'] ); - } else { - return 10; - } - - } - - /** - * Build the background fields. - * Takes a single field with type = background and explodes it to multiple controls. - */ - public function build_background_fields( $fields ) { - $i18n = Kirki::i18n(); - - foreach ( $fields as $field ) { - - if ( 'background' == $field['type'] ) { - - // Set any unset values to avoid PHP warnings below. - $field['settings'] = ( ! isset( $field['settings'] ) && isset( $field['setting'] ) ) ? $field['setting'] : $field['settings']; - $field['section'] = ( isset( $field['section'] ) ) ? $field['section'] : 'background'; - $field['help'] = ( isset( $field['help'] ) ) ? $field['help'] : ''; - $field['description'] = ( isset( $field['description'] ) ) ? $field['description'] : $i18n['background-color']; - $field['required'] = ( isset( $field['required'] ) ) ? $field['required'] : array(); - $field['transport'] = ( isset( $field['transport'] ) ) ? $field['transport'] : 'refresh'; - $field['default'] = ( isset( $field['default'] ) ) ? $field['default'] : array(); - $field['priority'] = ( isset( $field['priority'] ) ) ? $field['priority'] : 10; - - if ( isset( $field['default']['color'] ) ) { - $color_mode = ( false !== strpos( $field['default']['color'], 'rgba' ) ) ? 'color-alpha' : 'color'; - $fields[] = array( - 'type' => $color_mode, - 'label' => isset( $field['label'] ) ? $field['label'] : '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_color', - 'priority' => $field['priority'], - 'help' => $field['help'], - 'description' => $field['description'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['color'], - ); - } - - if ( isset( $field['default']['image'] ) ) { - $fields[] = array( - 'type' => 'image', - 'label' => '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_image', - 'priority' => $field['priority'] + 1, - 'help' => '', - 'description' => $i18n['background-image'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['image'], - ); - } - - if ( isset( $field['default']['repeat'] ) ) { - $fields[] = array( - 'type' => 'select', - 'label' => '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_', - 'priority' => $field['priority'] + 2, - 'choices' => array( - 'no-repeat' => $i18n['no-repeat'], - 'repeat' => $i18n['repeat-all'], - 'repeat-x' => $i18n['repeat-x'], - 'repeat-y' => $i18n['repeat-y'], - 'inherit' => $i18n['inherit'], - ), - 'help' => '', - 'description' => $i18n['background-repeat'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['repeat'], - ); - } - - if ( isset( $field['default']['size'] ) ) { - $fields[] = array( - 'type' => 'radio-buttonset', - 'label' => '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_size', - 'priority' => $field['priority'] + 3, - 'choices' => array( - 'inherit' => $i18n['inherit'], - 'cover' => $i18n['cover'], - 'contain' => $i18n['contain'], - ), - 'help' => '', - 'description' => $i18n['background-size'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['size'], - ); - } - - if ( isset( $field['default']['attach'] ) ) { - $fields[] = array( - 'label' => '', - 'type' => 'radio-buttonset', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_attach', - 'priority' => $field['priority'] + 4, - 'choices' => array( - 'inherit' => $i18n['inherit'], - 'fixed' => $i18n['fixed'], - 'scroll' => $i18n['scroll'], - ), - 'help' => '', - 'description' => $i18n['background-attachment'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['attach'], - ); - } - - if ( isset( $field['default']['position'] ) ) { - $fields[] = array( - 'type' => 'select', - 'label' => '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_position', - 'priority' => $field['priority'] + 5, - 'choices' => array( - 'left-top' => $i18n['left-top'], - 'left-center' => $i18n['left-center'], - 'left-bottom' => $i18n['left-bottom'], - 'right-top' => $i18n['right-top'], - 'right-center' => $i18n['right-center'], - 'right-bottom' => $i18n['right-bottom'], - 'center-top' => $i18n['center-top'], - 'center-center' => $i18n['center-center'], - 'center-bottom' => $i18n['center-bottom'], - ), - 'help' => '', - 'description' => $i18n['background-position'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['position'], - ); - } - - if ( isset( $field['default']['opacity'] ) && $field['default']['opacity'] ) { - $fields[] = array( - 'type' => 'slider', - 'label' => '', - 'section' => $field['section'], - 'settings' => $field['settings'] . '_opacity', - 'priority' => $field['priority'] + 6, - 'choices' => array( - 'min' => 0, - 'max' => 100, - 'step' => 1, - ), - 'help' => '', - 'description' => $i18n['background-opacity'], - 'required' => $field['required'], - 'transport' => $field['transport'], - 'default' => $field['default']['opacity'], - ); - - } - - } - - } - - return $fields; - - } - - /** - * Sanitizes the control transport. - * - * @param string the control type - * @return string the function name of a sanitization callback - */ - public static function fallback_callback( $field_type ) { - - switch ( $field_type ) { - case 'checkbox' : - $sanitize_callback = 'kirki_sanitize_checkbox'; - break; - case 'color' : - $sanitize_callback = 'sanitize_hex_color'; - break; - case 'color-alpha' : - $sanitize_callback = 'esc_js'; - break; - case 'image' : - $sanitize_callback = 'esc_url_raw'; - break; - case 'radio' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - case 'radio-image' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - case 'radio-buttonset' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - case 'toggle' : - $sanitize_callback = 'kirki_sanitize_checkbox'; - break; - case 'switch' : - $sanitize_callback = 'kirki_sanitize_checkbox'; - break; - case 'select' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - case 'dropdown-pages' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - case 'slider' : - $sanitize_callback = 'kirki_sanitize_number'; - break; - case 'text' : - $sanitize_callback = 'esc_textarea'; - break; - case 'textarea' : - $sanitize_callback = 'esc_textarea'; - break; - case 'editor' : - $sanitize_callback = 'esc_textarea'; - break; - case 'upload' : - $sanitize_callback = 'esc_url_raw'; - break; - case 'number' : - $sanitize_callback = 'kirki_sanitize_number'; - break; - case 'multicheck' : - $sanitize_callback = 'esc_attr'; - break; - case 'sortable' : - $sanitize_callback = 'kirki_sanitize_sortable'; - break; - case 'palette' : - $sanitize_callback = 'kirki_sanitize_choice'; - break; - default : - $sanitize_callback = 'kirki_sanitize_unfiltered'; - } - - return $sanitize_callback; - - } - -} diff --git a/includes/plugins/kirki/includes/Helpers/deprecated.php b/includes/plugins/kirki/includes/Helpers/deprecated.php deleted file mode 100644 index 1f6513c..0000000 --- a/includes/plugins/kirki/includes/Helpers/deprecated.php +++ /dev/null @@ -1,79 +0,0 @@ -get_all_fonts(); - } - - public static function get_font_choices() { - $font_registry = Kirki::fonts(); - return $font_registry->get_font_choices(); - } - - public static function is_google_font( $font ) { - $font_registry = Kirki::fonts(); - return $font_registray->is_google_font( $font ); - } - - public static function get_google_font_uri( $fonts, $weight = 400, $subset = 'all' ) { - $font_registry = Kirki::fonts(); - return $font_registry->get_google_font_uri( $fonts, $weight, $subset ); - } - - public static function get_google_font_subsets() { - $font_registry = Kirki::fonts(); - return $font_registry->get_google_font_subsets(); - } - - public static function choose_google_font_variants( $font, $variants = array() ) { - $font_registry = Kirki::fonts(); - return $font_registry->choose_google_font_variants( $font, $variants ); - } - - public static function get_standard_fonts() { - $font_registry = Kirki::fonts(); - return $font_registry->get_standard_fonts(); - } - - public static function get_font_stack( $font ) { - $font_registry = Kirki::fonts(); - return $font_registry->get_font_stack( $font ); - } - - public static function sanitize_font_choice( $value ) { - $font_registry = Kirki::fonts(); - return $font_registry->sanitize_font_choice( $value ); - } - - public static function get_google_fonts() { - $font_registry = Kirki::fonts(); - return $font_registry->get_google_fonts(); - } - - } - -} diff --git a/includes/plugins/kirki/includes/Helpers/helpers.php b/includes/plugins/kirki/includes/Helpers/helpers.php deleted file mode 100644 index fef62f0..0000000 --- a/includes/plugins/kirki/includes/Helpers/helpers.php +++ /dev/null @@ -1,129 +0,0 @@ - 0.6.2 - if ( ! $version ) { - /** - * In versions 0.6.0 & 0.6.1 there was a bug and some fields were saved as ID_opacity istead if ID - * This will fix the wrong settings naming and save new settings. - */ - $field_ids = array(); - $fields = Kirki::fields()->get_all(); - - foreach ( $fields as $field ) { - $field = Kirki::field()->sanitize( $field ); - - if ( 'background' != $field['type'] ) { - $field_ids[] = $field['settings']; - } - - } - - foreach ( $field_ids as $field_id ) { - - if ( get_theme_mod( $field_id . '_opacity' ) && ! get_theme_mod( $field_id ) ) { - set_theme_mod( $field_id, get_theme_mod( $field_id . '_opacity' ) ); - } - - } - - } - - if ( ! $version || version_compare( Kirki::$version, $version ) ) { - update_option( 'kirki_version', Kirki::$version ); - } - -} -// add_action( 'wp', 'kirki_update' ); - -/** - * Get the value of a field. - */ -function kirki_get_option( $option = '' ) { - - // Make sure the class is instanciated - Kirki::get_instance(); - - // Get the array of all the fields. - $fields = Kirki::fields()->get_all(); - // Get the config. - $config = Kirki::config()->get_all(); - - /** - * If no setting has been defined then return all. - */ - if ( '' == $option ) { - if ( 'option' == $config['options_type'] ) { - $values = array(); - foreach ( $fields as $field ) { - $values[] = get_option( $field['settings'], $field['default'] ); - } - } else { - $values = get_theme_mods(); - } - - return $values; - - } - // If a value has been defined then we proceed. - - // Early exit if this option does not exist - if ( ! isset( $fields[$option] ) ) { - return; - } - - $option_name = $fields[$option]['settings']; - $default = $fields[$option]['default']; - - if ( 'option' == $config['options_type'] ) { - $value = get_option( $option_name, $default ); - } else { - $value = get_theme_mod( $option_name, $default ); - } - - return $value; - -} - -/** - * Load plugin textdomain. - * - * @since 0.8.0 - */ -function kirki_load_textdomain() { - $textdomain = 'kirki'; - - // Look for WP_LANG_DIR/{$domain}-{$locale}.mo - if ( file_exists( WP_LANG_DIR . '/' . $textdomain . '-' . get_locale() . '.mo' ) ) { - $file = WP_LANG_DIR . '/' . $textdomain . '-' . get_locale() . '.mo'; - } - // Look for KIRKI_PATH/languages/{$domain}-{$locale}.mo - if ( ! isset( $file ) && file_exists( KIRKI_PATH . '/languages/' . $textdomain . '-' . get_locale() . '.mo' ) ) { - $file = KIRKI_PATH . '/languages/' . $textdomain . '-' . get_locale() . '.mo'; - } - - if ( isset( $file ) ) { - load_textdomain( $textdomain, $file ); - } - - load_plugin_textdomain( $textdomain, false, KIRKI_PATH . '/languages' ); -} -add_action( 'plugins_loaded', 'kirki_load_textdomain' ); diff --git a/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-color.php b/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-color.php deleted file mode 100755 index f82c87b..0000000 --- a/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-color.php +++ /dev/null @@ -1,475 +0,0 @@ -= 100 ) { - $opacity = 100; - } elseif ( $opacity < 0 ) { - $opacity = 0; - } elseif ( $opacity < 1 && $opacity != 0 ) { - $opacity = ( $opacity * 100 ); - } else { - $opacity = $opacity; - } - - // Divide the opacity by 100 to end-up with a CSS value for the opacity - $opacity = ( $opacity / 100 ); - - $color = 'rgba(' . self::get_rgb( $hex, true ) . ', ' . $opacity . ')'; - - return $color; - - } - - /** - * Gets the brightness of the $hex color. - * - * @var string The hex value of a color - * @return int value between 0 and 255 - */ - public static function get_brightness( $hex ) { - - $hex = self::sanitize_hex( $hex, false ); - // returns brightness value from 0 to 255 - - $red = hexdec( substr( $hex, 0, 2 ) ); - $green = hexdec( substr( $hex, 2, 2 ) ); - $blue = hexdec( substr( $hex, 4, 2 ) ); - - return ( ( $red * 299 ) + ( $green * 587 ) + ( $blue * 114 ) ) / 1000; - - } - - /** - * Adjusts brightness of the $hex color. - * - * @var string The hex value of a color - * @param int a value between -255 (darken) and 255 (lighten) - * @return string returns hex color - */ - public static function adjust_brightness( $hex, $steps ) { - - $hex = self::sanitize_hex( $hex, false ); - // Steps should be between -255 and 255. Negative = darker, positive = lighter - $steps = max( -255, min( 255, $steps ) ); - - // Get decimal values - $red = hexdec( substr( $hex, 0, 2 ) ); - $green = hexdec( substr( $hex, 2, 2 ) ); - $blue = hexdec( substr( $hex, 4, 2 ) ); - - // Adjust number of steps and keep it inside 0 to 255 - $red = max( 0, min( 255, $red + $steps ) ); - $green = max( 0, min( 255, $green + $steps ) ); - $blue = max( 0, min( 255, $blue + $steps ) ); - - $red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT ); - $green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT ); - $blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT ); - - return self::sanitize_hex( $red_hex . $green_hex . $blue_hex ); - - } - - /** - * Mixes 2 hex colors. - * the "percentage" variable is the percent of the first color - * to be used it the mix. default is 50 (equal mix) - * - * @var string The hex value of color 1 - * @var string The hex value of color 2 - * @param int a value between 0 and 100 - * @return string returns hex color - */ - public static function mix_colors( $hex1, $hex2, $percentage ) { - - $hex1 = self::sanitize_hex( $hex1, false ); - $hex2 = self::sanitize_hex( $hex2, false ); - - // Get decimal values - $red_1 = hexdec( substr( $hex1, 0, 2 ) ); - $green_1 = hexdec( substr( $hex1, 2, 2 ) ); - $blue_1 = hexdec( substr( $hex1, 4, 2 ) ); - $red_2 = hexdec( substr( $hex2, 0, 2 ) ); - $green_2 = hexdec( substr( $hex2, 2, 2 ) ); - $blue_2 = hexdec( substr( $hex2, 4, 2 ) ); - - $red = ( $percentage * $red_1 + ( 100 - $percentage ) * $red_2 ) / 100; - $green = ( $percentage * $green_1 + ( 100 - $percentage ) * $green_2 ) / 100; - $blue = ( $percentage * $blue_1 + ( 100 - $percentage ) * $blue_2 ) / 100; - - $red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT ); - $green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT ); - $blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT ); - - return self::sanitize_hex( $red_hex . $green_hex . $blue_hex ); - - } - - /** - * Convert hex color to hsv - * - * @var string The hex value of color 1 - * @return array returns array( 'h', 's', 'v' ) - */ - public static function hex_to_hsv( $hex ) { - - $hex = self::sanitize_hex( $hex, false ); - $rgb = self::get_rgb( $hex ); - $hsv = self::rgb_to_hsv( $rgb ); - - return $hsv; - - } - - /** - * Convert hex color to hsv - * - * @var array The rgb color to conver array( 'r', 'g', 'b' ) - * @return array returns array( 'h', 's', 'v' ) - */ - public static function rgb_to_hsv( $color = array() ) { - $r = $color[0]; - $g = $color[1]; - $b = $color[2]; - - $hsl = array(); - - $var_r = ( $r / 255 ); - $var_g = ( $g / 255 ); - $var_b = ( $b / 255 ); - - $var_min = min( $var_r, $var_g, $var_b); - $var_max = max( $var_r, $var_g, $var_b); - $del_max = $var_max - $var_min; - - $v = $var_max; - - if ( $del_max == 0 ) { - $h = 0; - $s = 0; - } else { - $s = $del_max / $var_max; - - $del_r = ( ( ( $var_max - $var_r ) / 6 ) + ( $del_max / 2 ) ) / $del_max; - $del_g = ( ( ( $var_max - $var_g ) / 6 ) + ( $del_max / 2 ) ) / $del_max; - $del_b = ( ( ( $var_max - $var_b ) / 6 ) + ( $del_max / 2 ) ) / $del_max; - - if ( $var_r == $var_max ) { - $h = $del_b - $del_g; - } elseif ( $var_g == $var_max ) { - $h = ( 1 / 3 ) + $del_r - $del_b; - } elseif ( $var_b == $var_max ) { - $h = ( 2 / 3 ) + $del_g - $del_r; - } - - if ( $h < 0 ) { - $h++; - } - - if ( $h > 1 ) { - $h--; - } - } - - $hsl['h'] = $h; - $hsl['s'] = $s; - $hsl['v'] = $v; - - return $hsl; - } - - /** - * Get the brightest color from an array of colors. - * Return the key of the array if $context = 'key' - * Return the hex value of the color if $context = 'value' - * - * @var array flat array of hex colors - * @param string 'key' or 'value' - * @return mixed int|string - */ - public static function brightest_color( $colors = array(), $context = 'key' ) { - - $brightest = false; - - foreach ( $colors as $color ) { - $color = self::sanitize_hex( $color, false ); - $brightness = self::get_brightness( $color ); - - if ( ! $brightest || self::get_brightness( $color ) > self::get_brightness( $brightest ) ) { - $brightest = $color; - } - } - - if ( $context == 'key' ) { - return array_search( $brightest, $colors ); - } elseif ( $context == 'value' ) { - return $brightest; - } - - } - - /* - * Get the most saturated color from an array of colors. - * Return the key of the array if $context = 'key' - * Return the hex value of the color if $context = 'value' - */ - public static function most_saturated_color( $colors = array(), $context = 'key' ) { - - $most_saturated = false; - - foreach ( $colors as $color ) { - $color = self::sanitize_hex( $color, false ); - $hsv = self::hex_to_hsv( $hex ); - $saturation = $hsv['s']; - - if ( $most_saturated ) { - $hsv_old = self::hex_to_hsv( $most_saturated ); - } - - if ( ! $most_saturated || $saturation > $hsv_old['s'] ) { - $most_saturated = $hex; - } - } - - if ( $context == 'key' ) { - return array_search( $most_saturated, $colors ); - } elseif ( $context == 'value' ) { - return $most_saturated; - } - - } - - /* - * Get the most intense color from an array of colors. - * Return the key of the array if $context = 'key' - * Return the hex value of the color if $context = 'value' - */ - public static function most_intense_color( $colors = array(), $context = 'key' ) { - - $most_intense = false; - - foreach ( $colors as $color ) { - $color = self::sanitize_hex( $color, false ); - $hsv = self::hex_to_hsv( $hex ); - $saturation = $hsv['s']; - - if ( $most_intense ) { - $hsv_old = self::hex_to_hsv( $most_intense ); - } - - if ( ! $most_intense || $saturation > $hsv_old['s'] ) { - $most_intense = $hex; - } - } - - if ( $context == 'key' ) { - return array_search( $most_intense, $colors ); - } elseif ( $context == 'value' ) { - return $most_intense; - } - - } - - /* - * Get the brightest color from an array of colors. - * Return the key of the array if $context = 'key' - * Return the hex value of the color if $context = 'value' - */ - public static function brightest_dull_color( $colors = array(), $context = 'key' ) { - - $brightest_dull = false; - - foreach ( $colors as $color ) { - $color = self::sanitize_hex( $color, false ); - $hsv = self::hex_to_hsv( $hex ); - - $brightness = self::get_brightness( $hex ); - // Prevent "division by zero" messages. - $hsv['s'] = ( $hsv['s'] == 0 ) ? 0.0001 : $hsv['s']; - $dullness = 1 / $hsv['s']; - - if ( $brightest_dull ) { - $hsv_old = self::hex_to_hsv( $brightest_dull ); - // Prevent "division by zero" messages. - $hsv_old['s'] = ( $hsv_old['s'] == 0 ) ? 0.0001 : $hsv_old['s']; - $dullness_old = 1 / $hsv_old['s']; - } - - if ( ! $brightest_dull || self::get_brightness( $hex ) * $dullness > self::get_brightness( $brightest_dull ) * $dullness_old ) { - $brightest_dull = $hex; - } - } - - if ( $context == 'key' ) { - return array_search( $brightest_dull, $colors ); - } elseif ( $context == 'value' ) { - return $brightest_dull; - } - - } - - /* - * This is a very simple algorithm that works by summing up the differences between the three color components red, green and blue. - * A value higher than 500 is recommended for good readability. - */ - public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { - - $color_1 = self::sanitize_hex( $color_1, false ); - $color_2 = self::sanitize_hex( $color_2, flase ); - - $color_1_rgb = self::get_rgb( $color_1 ); - $color_2_rgb = self::get_rgb( $color_2 ); - - $r1 = $color_1_rgb[0]; - $g1 = $color_1_rgb[1]; - $b1 = $color_1_rgb[2]; - - $r2 = $color_2_rgb[0]; - $g2 = $color_2_rgb[1]; - $b2 = $color_2_rgb[2]; - - $r_diff = max( $r1, $r2 ) - min( $r1, $r2 ); - $g_diff = max( $g1, $g2 ) - min( $g1, $g2 ); - $b_diff = max( $b1, $b2 ) - min( $b1, $b2 ); - - $color_diff = $r_diff + $g_diff + $b_diff; - - return $color_diff; - - } - - /* - * This function tries to compare the brightness of the colors. - * A return value of more than 125 is recommended. - * Combining it with the color_difference function above might make sense. - */ - public static function brightness_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { - - $color_1 = self::sanitize_hex( $color_1, false ); - $color_2 = self::sanitize_hex( $color_2, false ); - - $color_1_rgb = self::get_rgb( $color_1 ); - $color_2_rgb = self::get_rgb( $color_2 ); - - $r1 = $color_1_rgb[0]; - $g1 = $color_1_rgb[1]; - $b1 = $color_1_rgb[2]; - - $r2 = $color_2_rgb[0]; - $g2 = $color_2_rgb[1]; - $b2 = $color_2_rgb[2]; - - $br_1 = ( 299 * $r1 + 587 * $g1 + 114 * $b1 ) / 1000; - $br_2 = ( 299 * $r2 + 587 * $g2 + 114 * $b2 ) / 1000; - - return abs( $br_1 - $br_2 ); - - } - - /* - * Uses the luminosity to calculate the difference between the given colors. - * The returned value should be bigger than 5 for best readability. - */ - public static function lumosity_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { - - $color_1 = self::sanitize_hex( $color_1, false ); - $color_2 = self::sanitize_hex( $color_2, false ); - - $color_1_rgb = self::get_rgb( $color_1 ); - $color_2_rgb = self::get_rgb( $color_2 ); - - $r1 = $color_1_rgb[0]; - $g1 = $color_1_rgb[1]; - $b1 = $color_1_rgb[2]; - - $r2 = $color_2_rgb[0]; - $g2 = $color_2_rgb[1]; - $b2 = $color_2_rgb[2]; - - $l1 = 0.2126 * pow( $r1 / 255, 2.2 ) + 0.7152 * pow( $g1 / 255, 2.2 ) + 0.0722 * pow( $b1 / 255, 2.2 ); - $l2 = 0.2126 * pow( $r2 / 255, 2.2 ) + 0.7152 * pow( $g2 / 255, 2.2 ) + 0.0722 * pow( $b2 / 255, 2.2 ); - - $lum_diff = ( $l1 > $l2 ) ? ( $l1 + 0.05 ) / ( $l2 + 0.05 ) : ( $l2 + 0.05 ) / ( $l1 + 0.05 ); - - return $lum_diff; - - } - -} diff --git a/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-colourlovers.php b/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-colourlovers.php deleted file mode 100644 index 2e594c3..0000000 --- a/includes/plugins/kirki/includes/Helpers/libraries/class-kirki-colourlovers.php +++ /dev/null @@ -1,189 +0,0 @@ -palette as $result ) { - $id = $result->id; - $content = $result->content; - $title = $result->title; - $badgeurl = $result->badgeUrl; - $imageurl = $result->imageUrl; - $palette = (array) $result->colors->hex; - - $palettes[] = $palette; - - } - - return $palettes; - - } - - public static function order_by( $palette = array(), $order = 'none' ) { - - $palette = ( empty( $palette ) ) ? array() : $palette; - - if ( 'none' == $order ) { - - $palette = array( - Kirki_Color::sanitize_hex( $palette[0] ), - Kirki_Color::sanitize_hex( $palette[1] ), - Kirki_Color::sanitize_hex( $palette[2] ), - Kirki_Color::sanitize_hex( $palette[3] ), - Kirki_Color::sanitize_hex( $palette[4] ), - - ); - - } elseif ( 'brightness' == $order ) { - - // Get the ligtness of all the colors in our palette and arrange them according to it. - $colors_array_0b = $palette; - $brightest_0_key = Kirki_Color::brightest_color( $colors_array_0b, 'key' ); - $brightest_0_val = Kirki_Color::brightest_color( $colors_array_0b, 'value' ); - - $colors_array_1b = kirki_array_delete( $brightest_0_key, $colors_array_0b ); - $brightest_1_key = Kirki_Color::brightest_color( $colors_array_1b, 'key' ); - $brightest_1_val = Kirki_Color::brightest_color( $colors_array_1b, 'value' ); - - $colors_array_2b = kirki_array_delete( $brightest_1_key, $colors_array_1b ); - $brightest_2_key = Kirki_Color::brightest_color( $colors_array_2b, 'key' ); - $brightest_2_val = Kirki_Color::brightest_color( $colors_array_2b, 'value' ); - - $colors_array_3b = kirki_array_delete( $brightest_2_key, $colors_array_2b ); - $brightest_3_key = Kirki_Color::brightest_color( $colors_array_3b, 'key' ); - $brightest_3_val = Kirki_Color::brightest_color( $colors_array_3b, 'value' ); - - $colors_array_4b = kirki_array_delete( $brightest_3_key, $colors_array_3b ); - $brightest_4_key = Kirki_Color::brightest_color( $colors_array_4b, 'key' ); - $brightest_4_val = Kirki_Color::brightest_color( $colors_array_4b, 'value' ); - - $palette = array( - Kirki_Color::sanitize_hex( $brightest_0_val ), - Kirki_Color::sanitize_hex( $brightest_1_val ), - Kirki_Color::sanitize_hex( $brightest_2_val ), - Kirki_Color::sanitize_hex( $brightest_3_val ), - Kirki_Color::sanitize_hex( $brightest_4_val ), - ); - - } elseif ( 'saturation' == $order ) { - - // Get the saturation of all the colors in our palette and arrange them according to it. - $colors_array_0s = $palette; - $most_saturated_0_key = Kirki_Color::most_saturated_color( $colors_array_0s, 'key' ); - $most_saturated_0_val = Kirki_Color::most_saturated_color( $colors_array_0s, 'value' ); - - $colors_array_1s = kirki_array_delete( $most_saturated_0_key, $colors_array_0s ); - $most_saturated_1_key = Kirki_Color::most_saturated_color( $colors_array_1s, 'key' ); - $most_saturated_1_val = Kirki_Color::most_saturated_color( $colors_array_1s, 'value' ); - - $colors_array_2s = kirki_array_delete( $most_saturated_1_key, $colors_array_1s ); - $most_saturated_2_key = Kirki_Color::most_saturated_color( $colors_array_2s, 'key' ); - $most_saturated_2_val = Kirki_Color::most_saturated_color( $colors_array_2s, 'value' ); - - $colors_array_3s = kirki_array_delete( $most_saturated_2_key, $colors_array_2s ); - $most_saturated_3_key = Kirki_Color::most_saturated_color( $colors_array_3s, 'key' ); - $most_saturated_3_val = Kirki_Color::most_saturated_color( $colors_array_3s, 'value' ); - - $colors_array_4s = kirki_array_delete( $most_saturated_3_key, $colors_array_3s ); - $most_saturated_3_key = Kirki_Color::most_saturated_color( $colors_array_4s, 'key' ); - $most_saturated_4_val = Kirki_Color::most_saturated_color( $colors_array_4s, 'value' ); - - $palette = array( - Kirki_Color::sanitize_hex( $most_saturated_0_val ), - Kirki_Color::sanitize_hex( $most_saturated_1_val ), - Kirki_Color::sanitize_hex( $most_saturated_2_val ), - Kirki_Color::sanitize_hex( $most_saturated_3_val ), - Kirki_Color::sanitize_hex( $most_saturated_4_val ), - ); - - } elseif ( 'intensity' == $order ) { - - // Get the intensity of all the colors in our palette and arrange them according to it. - $colors_array_0i = $palette; - $most_intense_0_key = Kirki_Color::most_intense_color( $colors_array_0i, 'key' ); - $most_intense_0_val = Kirki_Color::most_intense_color( $colors_array_0i, 'value' ); - - $colors_array_1i = kirki_array_delete( $most_intense_0_key, $colors_array_0i ); - $most_intense_1_key = Kirki_Color::most_intense_color( $colors_array_1i, 'key' ); - $most_intense_1_val = Kirki_Color::most_intense_color( $colors_array_1i, 'value' ); - - $colors_array_2i = kirki_array_delete( $most_intense_1_key, $colors_array_1i ); - $most_intense_2_key = Kirki_Color::most_intense_color( $colors_array_2i, 'key' ); - $most_intense_2_val = Kirki_Color::most_intense_color( $colors_array_2i, 'value' ); - - $colors_array_3i = kirki_array_delete( $most_intense_2_key, $colors_array_2i ); - $most_intense_3_key = Kirki_Color::most_intense_color( $colors_array_3i, 'key' ); - $most_intense_3_val = Kirki_Color::most_intense_color( $colors_array_3i, 'value' ); - - $colors_array_4i = kirki_array_delete( $most_intense_3_key, $colors_array_3i ); - $most_intense_3_key = Kirki_Color::most_intense_color( $colors_array_4i, 'key' ); - $most_intense_4_val = Kirki_Color::most_intense_color( $colors_array_4i, 'value' ); - - $palette = array( - Kirki_Color::sanitize_hex( $most_intense_0_val ), - Kirki_Color::sanitize_hex( $most_intense_1_val ), - Kirki_Color::sanitize_hex( $most_intense_2_val ), - Kirki_Color::sanitize_hex( $most_intense_3_val ), - Kirki_Color::sanitize_hex( $most_intense_4_val ), - ); - - } elseif ( 'dullness' == $order ) { - - // Get the lightness and "dullness" of all the colors in our palette and arrange them according to it. - $colors_array_0d = $palette; - $bright_dull_0_key = Kirki_Color::brightest_dull_color( $colors_array_0d, 'key' ); - $bright_dull_0_val = Kirki_Color::brightest_dull_color( $colors_array_0d, 'value' ); - - $colors_array_1d = kirki_array_delete( $bright_dull_0_key, $colors_array_0d ); - $bright_dull_1_key = Kirki_Color::brightest_dull_color( $colors_array_1d, 'key' ); - $bright_dull_1_val = Kirki_Color::brightest_dull_color( $colors_array_1d, 'value' ); - - $colors_array_2d = kirki_array_delete( $bright_dull_1_key, $colors_array_1d ); - $bright_dull_2_key = Kirki_Color::brightest_dull_color( $colors_array_2d, 'key' ); - $bright_dull_2_val = Kirki_Color::brightest_dull_color( $colors_array_2d, 'value' ); - - $colors_array_3d = kirki_array_delete( $bright_dull_2_key, $colors_array_2d ); - $bright_dull_3_key = Kirki_Color::brightest_dull_color( $colors_array_3d, 'key' ); - $bright_dull_3_val = Kirki_Color::brightest_dull_color( $colors_array_3d, 'value' ); - - $colors_array_4d = kirki_array_delete( $bright_dull_3_key, $colors_array_3d ); - $bright_dull_3_key = Kirki_Color::brightest_dull_color( $colors_array_4d, 'key' ); - $bright_dull_4_val = Kirki_Color::brightest_dull_color( $colors_array_4d, 'value' ); - - $palette = array( - Kirki_Color::sanitize_hex( $bright_dull_0_val ), - Kirki_Color::sanitize_hex( $bright_dull_1_val ), - Kirki_Color::sanitize_hex( $bright_dull_2_val ), - Kirki_Color::sanitize_hex( $bright_dull_3_val ), - Kirki_Color::sanitize_hex( $bright_dull_4_val ), - ); - - } - - return $palette; - - } - -} diff --git a/includes/plugins/kirki/includes/Helpers/sanitize.php b/includes/plugins/kirki/includes/Helpers/sanitize.php deleted file mode 100644 index 25016de..0000000 --- a/includes/plugins/kirki/includes/Helpers/sanitize.php +++ /dev/null @@ -1,134 +0,0 @@ -get_control( $setting->id ); - - return ( array_key_exists( $input, $field->choices ) ) ? $input : $setting->default; - -} - -/** - * Sanitize background repeat values - * - * @since 0.5 - */ -function kirki_sanitize_bg_repeat( $value ) { - $i18n = Kirki::i18n(); - $valid = array( - 'no-repeat' => $i18n['no-repeat'], - 'repeat' => $i18n['repeat-all'], - 'repeat-x' => $i18n['repeat-x'], - 'repeat-y' => $i18n['repeat-y'], - 'inherit' => $i18n['inherit'], - ); - - return ( array_key_exists( $value, $valid ) ) ? $value : 'inherit'; - -} - -/** - * Sanitize background size values - * - * @since 0.5 - */ -function kirki_sanitize_bg_size( $value ) { - $i18n = Kirki::i18n(); - $valid = array( - 'inherit' => $i18n['inherit'], - 'cover' => $i18n['cover'], - 'contain' => $i18n['contain'], - ); - - return ( array_key_exists( $value, $valid ) ) ? $value : 'inherit'; - -} - -/** - * Sanitize background attachment values - * - * @since 0.5 - */ -function kirki_sanitize_bg_attach( $value ) { - $i18n = Kirki::i18n(); - $valid = array( - 'inherit' => $i18n['inherit'], - 'fixed' => $i18n['fixed'], - 'scroll' => $i18n['scroll'], - ); - - return ( array_key_exists( $value, $valid ) ) ? $value : 'inherit'; - -} - -/** - * Sanitize background position values - * - * @since 0.5 - */ -function kirki_sanitize_bg_position( $value ) { - $i18n = Kirki::i18n(); - $valid = array( - 'left-top' => $i18n['left-top'], - 'left-center' => $i18n['left-center'], - 'left-bottom' => $i18n['left-bottom'], - 'right-top' => $i18n['right-top'], - 'right-center' => $i18n['right-center'], - 'right-bottom' => $i18n['right-bottom'], - 'center-top' => $i18n['center-top'], - 'center-center' => $i18n['center-center'], - 'center-bottom' => $i18n['center-bottom'], - ); - - return ( array_key_exists( $value, $valid ) ) ? $value : 'center-center'; - -} - -/** - * Sanitize sortable controls - * - * @since 0.8.3 - */ - -function kirki_sanitize_sortable( $value ) { - if ( is_serialized( $value ) ) { - return $value; - } else { - return serialize( $value ); - } -} -/** - * DOES NOT SANITIZE ANYTHING. - * - * @since 0.5 - */ -function kirki_sanitize_unfiltered( $value ) { - return $value; -} diff --git a/includes/plugins/kirki/includes/Kirki.php b/includes/plugins/kirki/includes/Kirki.php deleted file mode 100644 index 8b8a05a..0000000 --- a/includes/plugins/kirki/includes/Kirki.php +++ /dev/null @@ -1,99 +0,0 @@ -fields; - } - - /** - * Shortcut method to get the configuration of the single instance. - */ - public static function config() { - return self::get_instance()->config; - } - - /** - * Shortcut method to get the translation strings - */ - public static function i18n() { - $config = self::config(); - $options = $config->get_all(); - return $options['i18n']; - } - - /** - * Shortcut method to get the font registry. - */ - public static function fonts() { - return self::get_instance()->font_registry; - } - - /** - * Constructor is private, should only be called by get_instance() - */ - private function __construct() { - - // Create our main objects - $this->font_registry = new FontRegistry(); - $this->config = new Config(); - $this->fields = new Fields(); - $this->scripts = new ScriptRegistry(); - $this->styles = new Styles(); - - // Hook into WP - $init = new Builder(); - - } - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/Branding.php b/includes/plugins/kirki/includes/Scripts/Customizer/Branding.php deleted file mode 100644 index 316c243..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/Branding.php +++ /dev/null @@ -1,42 +0,0 @@ -get_all(); - $script = ''; - if ( '' != $options['logo_image'] || '' != $options['description'] ) { - - if ( '' != $options['logo_image'] ) { - $script .= '$( \'div#customize-info .preview-notice\' ).replaceWith( \'\' );'; - } - if ( '' != $options['description'] ) { - $script .= '$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'
      ' . $options['description'] . '
      \' );'; - } - - } - - if ( '' != $script ) { - echo ScriptRegistry::prepare( $script ); - } - - } - - public function customize_controls_enqueue_scripts() {} - - public function customize_controls_print_footer_scripts() {} - - public function wp_footer() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/Dependencies.php b/includes/plugins/kirki/includes/Scripts/Customizer/Dependencies.php deleted file mode 100644 index a16cd35..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/Dependencies.php +++ /dev/null @@ -1,33 +0,0 @@ -get_all(); - $kirki_url = ( '' != $config['url_path'] )? $config['url_path'] : KIRKI_URL; - - wp_enqueue_script( 'kirki_customizer_js', trailingslashit( $kirki_url ) . 'assets/js/customizer.js', array( 'jquery', 'customize-controls' ) ); - wp_enqueue_script( 'serialize-js', trailingslashit( $kirki_url ) . 'assets/js/serialize.js' ); - wp_enqueue_script( 'jquery-stepper-min-js', trailingslashit( $kirki_url ) . 'assets/js/jquery.fs.stepper.min.js', array( 'jquery' ) ); - wp_enqueue_script( 'jquery-ui-core' ); - wp_enqueue_script( 'jquery-ui-tooltip' ); - wp_enqueue_script( 'jquery-stepper-min-js' ); - - } - - public function customize_controls_print_scripts() {} - - public function customize_controls_print_footer_scripts() {} - - public function wp_footer() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/PostMessage.php b/includes/plugins/kirki/includes/Scripts/Customizer/PostMessage.php deleted file mode 100644 index a0e85fe..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/PostMessage.php +++ /dev/null @@ -1,72 +0,0 @@ - 'postMessage', - 'js_vars' => array( - array( - 'element' => 'body', - 'function' => 'css', - 'property' => 'color', - ), - array( - 'element' => '#content', - 'function' => 'css', - 'property' => 'background-color', - ), - array( - 'element' => 'body', - 'function' => 'html', - ) - ) - * - */ - public function wp_footer() { - - global $wp_customize; - // Early exit if we're not in the customizer - if ( ! isset( $wp_customize ) ) { - return; - } - - $fields = Kirki::fields()->get_all(); - $script = ''; - foreach ( $fields as $field ) { - if ( isset( $field['transport'] ) && ! is_null( $field['js_vars'] ) && 'postMessage' == $field['transport'] ) { - foreach ( $field['js_vars'] as $js_vars ) { - $script .= 'wp.customize( \'' . $field['settings'] . '\', function( value ) {'; - $script .= 'value.bind( function( newval ) {'; - if ( 'html' == $js_vars['function'] ) { - $script .= '$( \'' . esc_js( $js_vars["element"] ) . '\' ).html( newval );'; - } elseif ( 'css' == $js_vars['function'] ) { - $script .= '$(\'' . esc_js( $js_vars["element"] ) . '\').css(\'' . esc_js( $js_vars["property"] ) . '\', newval );'; - } - $script .= '}); });'; - } - } - } - - if ( '' != $script ) { - echo ScriptRegistry::prepare( $script ); - } - - } - - public function customize_controls_print_scripts() {} - - public function customize_controls_enqueue_scripts() {} - - public function customize_controls_print_footer_scripts() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/Required.php b/includes/plugins/kirki/includes/Scripts/Customizer/Required.php deleted file mode 100644 index 066b2d2..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/Required.php +++ /dev/null @@ -1,136 +0,0 @@ -get_all(); - - // Early exit if no controls are defined - if ( empty( $fields ) ) { - return; - } - - $script = ''; - - foreach ( $fields as $field ) { - - $required = ( isset( $field['required'] ) ) ? $field['required'] : false; - - if ( $required ) { - - $show = false; - foreach ( $required as $dependency ) { - // Find the type of the dependency control - $type = $fields[$dependency['setting']]['type']; - - // If "operator" is not set then set it to "==" - if ( ! isset( $dependency['operator'] ) ) { - $dependency['operator'] = '=='; - } - $dependency['operator'] = esc_js( $dependency['operator'] ); - - // Set the control type - $type = ( 'dropdown-pages' == $type ) ? 'select' : $type; - $type = ( 'radio-image' == $type ) ? 'radio' : $type; - $type = ( 'radio-buttonset' == $type ) ? 'radio' : $type; - $type = ( 'toggle' == $type ) ? 'checkbox' : $type; - $type = ( 'switch' == $type ) ? 'checkbox' : $type; - - // Set the controller used in the script - $controller = '#customize-control-' . $dependency['setting'] . ' input'; - if ( 'select' == $type ) { - $controller = '#customize-control-' . $dependency['setting'] . ' select'; - } elseif ( 'radio' == $type ) { - $controller = '#customize-control-' . $dependency['setting'] . ' input[value="' . $dependency['value'] . '"]'; - } - - // The target element - $target = '#customize-control-' . $field['settings']; - // if this is a background control then make sure we target all sub-controls - if ( 'background' == $field['type'] ) { - $target = '#customize-control-' . $control['settings'] . '_color, '; - $target .= '#customize-control-' . $control['settings'] . '_image, '; - $target .= '#customize-control-' . $control['settings'] . '_repeat, '; - $target .= '#customize-control-' . $control['settings'] . '_size, '; - $target .= '#customize-control-' . $control['settings'] . '_position, '; - $target .= '#customize-control-' . $control['settings'] . '_attach'; - } - - if ( ! isset( $dependency['operator'] ) ) { - $dependency['operator'] = '=='; - } - - $action_1 = '.show()'; - $action_2 = '.hide()'; - // Allow checking both checked and unchecked checkboxes - if ( 'checkbox' == $type ) { - if ( 0 == $dependency['value'] && '==' == $dependency['operator'] ) { - $action_1 = '.hide()'; - $action_2 = '.show()'; - $show = true; - } - if ( 1 == $dependency['value'] && '!=' == $dependency['operator'] ) { - $action_1 = '.hide()'; - $action_2 = '.show()'; - } - } - - // Get the initial status - $value = kirki_get_option( $field['settings'] ); - if ( '==' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] == $value ) ) ? true : $show; - } elseif ( '!=' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] != $value ) ) ? true : $show; - } elseif ( '>=' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] >= $value ) ) ? true : $show; - } elseif ( '<=' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] <= $value ) ) ? true : $show; - } elseif ( '>' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] > $value ) ) ? true : $show; - } elseif ( '<' == $dependency['operator'] ) { - $show = ( $show && ( $dependency['value'] < $value ) ) ? true : $show; - } - - // if initial status is hidden then hide the control - if ( false == $show ) { - $script .= '$("' . $target . '").hide();'; - } - - $script .= '$("' . $controller . '").'; - $script .= ( 'checkbox' == $type ) ? 'click' : 'change'; - $script .= '(function(){'; - $script .= 'if ($("' . $controller . '").'; - $script .= ( 'checkbox' == $type ) ? 'is(":checked") ) {' : 'val() ' . $dependency['operator'] . ' "' . $dependency['value'] . '") {'; - $script .= '$("' . $target . '")' . $action_1 . ';'; - $script .= '} else {'; - $script .= '$("' . $target . '")' . $action_2 . ';'; - $script .= '}});'; - $script .= ( 'checkbox' != $type ) ? '$("' . $controller . '").trigger("change");' : ''; - } - } - } - - // If there's a script then echo it wrapped. - if ( ! empty( $script ) ) { - echo ScriptRegistry::prepare( $script ); - } - - } - - public function customize_controls_print_scripts() {} - - public function customize_controls_enqueue_scripts() {} - - public function wp_footer() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/Stepper.php b/includes/plugins/kirki/includes/Scripts/Customizer/Stepper.php deleted file mode 100644 index 9e45a52..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/Stepper.php +++ /dev/null @@ -1,47 +0,0 @@ -get_all(); - $scripts = array(); - - foreach ( $fields as $field ) { - - if ( 'number' == $field['type'] ) { - $scripts[] = '$( "#customize-control-' . $field['settings'] . ' input[type=\'number\']").stepper();'; - } - - } - - // No need to echo anything if the script is empty - if ( empty( $scripts ) ) { - return; - } - - // Make sure we don't add any duplicates - $scripts = array_unique( $scripts ); - // Convert array to string - $script = implode( '', $scripts ); - - echo ScriptRegistry::prepare( $script ); - - } - - public function customize_controls_print_scripts() {} - - public function customize_controls_enqueue_scripts() {} - - public function wp_footer() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/Customizer/Tooltips.php b/includes/plugins/kirki/includes/Scripts/Customizer/Tooltips.php deleted file mode 100644 index 147c9d0..0000000 --- a/includes/plugins/kirki/includes/Scripts/Customizer/Tooltips.php +++ /dev/null @@ -1,51 +0,0 @@ -get_all(); - - $scripts = array(); - $script = ''; - - foreach ( $fields as $field ) { - - if ( ! empty( $field['help'] ) ) { - $bubble_content = $field['help']; - $content = ""; - $scripts[] = '$( "' . $content . '" ).prependTo( "#customize-control-' . $field['settings'] . '" );'; - } - - } - - // No need to echo anything if the script is empty - if ( empty( $scripts ) ) { - return; - } - - // Make sure we don't add any duplicates - $scripts = array_unique( $scripts ); - // Convert array to string - $script = implode( '', $scripts ); - - echo ScriptRegistry::prepare( $script ); - - } - - public function customize_controls_print_scripts() {} - - public function customize_controls_enqueue_scripts() {} - - public function wp_footer() {} - -} diff --git a/includes/plugins/kirki/includes/Scripts/EnqueueScript.php b/includes/plugins/kirki/includes/Scripts/EnqueueScript.php deleted file mode 100644 index 8e526f6..0000000 --- a/includes/plugins/kirki/includes/Scripts/EnqueueScript.php +++ /dev/null @@ -1,22 +0,0 @@ -get_all(); - - // Early exit if no fields are found. - if ( ! $fields || empty( $fields ) ) { - return; - } - - // Get an array of all the google fonts - $google_fonts = Kirki::fonts()->get_google_fonts(); - - $fonts = array(); - foreach ( $fields as $field ) { - - if ( isset( $field['output'] ) ) { - - // Check if this is a font-family control - $is_font_family = isset( $field['output']['property'] ) && 'font-family' == $field['output']['property'] ? true : false; - - // Check if this is a font-weight control - $is_font_weight = isset( $field['output']['property'] ) && 'font-weight' == $field['output']['property'] ? true : false; - - // Check if this is a font subset control - $is_font_subset = isset( $field['output']['property'] ) && 'font-subset' == $field['output']['property'] ? true : false; - - if ( $is_font_family || $is_font_weight || $is_font_subset ) { - // The value of this control - $value = kirki_get_option( $field['settings'] ); - - if ( $is_font_family ) { - $fonts[]['font-family'] = $value; - } else if ( $is_font_weight ) { - $fonts[]['font-weight'] = $value; - } else if ( $is_font_subset ) { - $fonts[]['subsets'] = $value; - } - - } - - } - - } - - foreach ( $fonts as $font ) { - - if ( isset( $font['font-family'] ) ) { - - $font_families = ( ! isset( $font_families ) ) ? array() : $font_families; - $font_families[] = $font['font-family']; - - if ( Kirki::fonts()->is_google_font( $font['font-family'] ) ) { - $has_google_font = true; - } - - } - - if ( isset( $font['font-weight'] ) ) { - - $font_weights = ( ! isset( $font_weights ) ) ? array() : $font_weights; - $font_weights[] = $font['font-weight']; - - } - - if ( isset( $font['subsets'] ) ) { - - $font_subsets = ( ! isset( $font_subsets ) ) ? array() : $font_subsets; - $font_subsets[] = $font['subsets']; - - } - - } - - $font_families = ( ! isset( $font_families ) || empty( $font_families ) ) ? false : $font_families; - $font_weights = ( ! isset( $font_weights ) || empty( $font_weights ) ) ? '400' : $font_weights; - $font_subsets = ( ! isset( $font_subsets ) || empty( $font_subsets ) ) ? 'all' : $font_subsets; - - if ( ! isset( $has_google_font ) || ! $has_google_font ) { - $font_families = false; - } - - return ( $font_families ) ? Kirki::fonts()->get_google_font_uri( $font_families, $font_weights, $font_subsets ) : false; - - } - - /** - * Enqueue Google fonts if necessary - */ - function google_font() { - $google_link = $this->google_link(); - - if ( $google_link ) { - wp_register_style( 'kirki_google_fonts', $google_link ); - wp_enqueue_style( 'kirki_google_fonts' ); - } - } - -} diff --git a/includes/plugins/kirki/includes/Scripts/ScriptRegistry.php b/includes/plugins/kirki/includes/Scripts/ScriptRegistry.php deleted file mode 100644 index 16216cd..0000000 --- a/includes/plugins/kirki/includes/Scripts/ScriptRegistry.php +++ /dev/null @@ -1,31 +0,0 @@ -jQuery(document).ready(function($) { "use strict"; ' . $script . '});'; - } - -} diff --git a/includes/plugins/kirki/includes/Settings.php b/includes/plugins/kirki/includes/Settings.php deleted file mode 100644 index a83fde5..0000000 --- a/includes/plugins/kirki/includes/Settings.php +++ /dev/null @@ -1,40 +0,0 @@ -add_setting( $wp_customize, $field ); - } - - } - - public function add_setting( $wp_customize, $field, $id_override = null, $default_override = null, $callback = null ) { - - $id = ( ! is_null( $id_override ) ) ? $id_override : $field['settings']; - $default = ( ! is_null( $default_override ) ) ? $default_override : $field['default']; - $callback = ( ! is_null( $callback ) ) ? $callback : $field['sanitize_callback']; - - $wp_customize->add_setting( $id, array( - 'default' => $default, - 'type' => $field['option_type'], - 'capability' => 'edit_theme_options', - 'transport' => $field['transport'], - 'sanitize_callback' => $callback, - ) ); - - } - -} diff --git a/includes/plugins/kirki/includes/Styles.php b/includes/plugins/kirki/includes/Styles.php deleted file mode 100644 index 0c7f29a..0000000 --- a/includes/plugins/kirki/includes/Styles.php +++ /dev/null @@ -1,16 +0,0 @@ -get_all(); - $root = ( '' != $config['url_path'] ) ? $config['url_path'] : KIRKI_URL; - wp_enqueue_style( 'kirki-customizer-css', trailingslashit( $root ) . 'assets/css/customizer.css', NULL, '0.5' ); - } - - /** - * Add custom CSS rules to the head, applying our custom styles - */ - function custom_css() { - - $color = $this->get_admin_colors(); - $config = Kirki::config(); - - $color_font = false; - $color_accent = $config->get( 'color_accent', $color['icon_colors']['focus']); - $color_back = $config->get( 'color_back', '#ffffff' ); - $color_font = ( 170 > \Kirki_Color::get_brightness( $color_back ) ) ? '#f2f2f2' : '#222'; - - $styles = ''; - - echo $styles; - - } - - /** - * Get the admin color theme - */ - function get_admin_colors() { - - // Get the active admin theme - global $_wp_admin_css_colors; - - // Get the user's admin colors - $color = get_user_option( 'admin_color' ); - // If no theme is active set it to 'fresh' - if ( empty( $color ) || ! isset( $_wp_admin_css_colors[$color] ) ) { - $color = 'fresh'; - } - - $color = (array) $_wp_admin_css_colors[$color]; - - return $color; - - } - -} diff --git a/includes/plugins/kirki/includes/Styles/Frontend.php b/includes/plugins/kirki/includes/Styles/Frontend.php deleted file mode 100644 index ebec46f..0000000 --- a/includes/plugins/kirki/includes/Styles/Frontend.php +++ /dev/null @@ -1,239 +0,0 @@ -getOrThrow( 'stylesheet_id' ), $this->styles_parse() ); - } - - - /** - * Add a dummy, empty stylesheet if no stylesheet_id has been defined and we need one. - */ - function frontend_styles() { - $config = Kirki::config()->get_all(); - $fields = Kirki::fields()->get_all(); - - $kirki_stylesheet = Kirki::config()->getOrThrow( 'stylesheet_id' ); - - foreach( $fields as $field ) { - if ( isset( $field['output'] ) ) { - $uses_output = true; - } - } - - $root = ( '' != $config['url_path'] ) ? $config['url_path'] : KIRKI_URL; - - if ( isset( $uses_output ) && $uses_output && $kirki_stylesheet === 'kirki-styles' ) { - wp_enqueue_style( 'kirki-styles', trailingslashit( $root ) . 'assets/css/kirki-styles.css', NULL, NULL ); - } - - } - - - function styles_parse() { - - $styles = $this->loop_controls(); - $css = ''; - - // Early exit if styles are empty or not an array - if ( empty( $styles ) || ! is_array( $styles ) ) { - return; - } - - foreach ( $styles as $style => $style_array ) { - $css .= $style . '{'; - foreach ( $style_array as $property => $value ) { - $css .= $property . ':' . $value . ';'; - } - $css .= '}'; - } - - return $css; - - } - - - function setting_styles( $field, $styles, $element, $property, $units ) { - - $value = kirki_get_option( $field['settings'] ); - - // Color controls - if ( 'color' == $field['type'] ) { - - $color = \Kirki_Color::sanitize_hex( $value ); - $styles[$element][$property] = $color; - - } - - // Background Controls - elseif ( 'background' == $field['type'] ) { - - if ( isset( $field['default']['color'] ) ) { - $color_mode = ( false !== strpos( $field['default']['color'], 'rgba' ) ) ? 'color-alpha' : 'color'; - $value = kirki_get_option( $field['settings'] . '_color' ); - if ( 'color-alpha' == $color_mode ) { - $bg_color = esc_js( $value ); - } else { - $bg_color = \Kirki_Color::sanitize_hex( $value ); - } - } - if ( isset( $field['default']['image'] ) ) { - $bg_image = kirki_get_option( $field['settings'] . '_image' ); - $bg_image = esc_url_raw( $bg_image ); - } - if ( isset( $field['default']['repeat'] ) ) { - $bg_repeat = kirki_get_option( $field['settings'] . '_repeat' ); - $bg_repeat = kirki_sanitize_bg_repeat( $bg_repeat ); - } - if ( isset( $field['default']['size'] ) ) { - $bg_size = kirki_get_option( $field['settings'] . '_size' ); - $bg_size = kirki_sanitize_bg_size( $bg_size ); - } - if ( isset( $field['default']['attach'] ) ) { - $bg_attach = kirki_get_option( $field['settings'] . '_attach' ); - $bg_attach = kirki_sanitize_bg_attach( $bg_attach ); - } - if ( isset( $field['default']['position'] ) ) { - $bg_position = kirki_get_option( $field['settings'] . '_position' ); - $bg_position = kirki_sanitize_bg_position( $bg_position ); - } - if ( isset( $field['default']['opacity'] ) && $field['default']['opacity'] ) { - $bg_opacity = kirki_get_option( $field['settings'] . '_opacity' ); - $bg_opacity = kirki_sanitize_number( $bg_opacity ); - if ( isset( $bg_color ) ) { - // If we're using an opacity other than 100, then convert the color to RGBA. - $bg_color = ( 100 != $bg_opacity ) ? \Kirki_Color::get_rgba( $bg_color, $bg_opacity ) : $bg_color; - } elseif ( isset( $bg_image ) ) { - $element_opacity = ( $bg_opacity / 100 ); - } - - } - - if ( isset( $bg_color ) ) { - $styles[$element]['background-color'] = $bg_color; - } - if ( isset( $bg_image ) && '' != $bg_image ) { - $styles[$element]['background-image'] = 'url("' . $bg_image . '")'; - if ( isset( $bg_repeat ) ) { - $styles[$element]['background-repeat'] = $bg_repeat; - } - if ( isset( $bg_size ) ) { - $styles[$element]['background-size'] = $bg_size; - } - if ( isset( $bg_attach ) ) { - $styles[$element]['background-attachment'] = $bg_attach; - } - if ( isset( $bg_position ) ) { - $styles[$element]['background-position'] = str_replace( '-', ' ', $bg_position ); - } - } - - } - - // Font controls - elseif ( array( $field['output'] ) && isset( $field['output']['property'] ) && in_array( $field['output']['property'], array( 'font-family', 'font-size', 'font-weight' ) ) ) { - - $is_font_family = isset( $field['output']['property'] ) && 'font-family' == $field['output']['property'] ? true : false; - $is_font_size = isset( $field['output']['property'] ) && 'font-size' == $field['output']['property'] ? true : false; - $is_font_weight = isset( $field['output']['property'] ) && 'font-weight' == $field['output']['property'] ? true : false; - - if ( 'font-family' == $property ) { - - $styles[$field['output']['element']]['font-family'] = $value; - - } else if ( 'font-size' == $property ) { - - // Get the unit we're going to use for the font-size. - $units = empty( $units ) ? 'px' : $units; - $styles[$element]['font-size'] = $value . $units; - - } else if ( 'font-weight' == $property ) { - - $styles[$element]['font-weight'] = $value; - - } - - } else { - - $styles[$element][$property] = $value . $units; - - } - - return $styles; - - } - - - function loop_controls() { - - $fields = Kirki::fields()->get_all(); - $styles = array(); - - // Early exit if no fields are found. - if ( ! $fields || empty( $fields ) ) { - return; - } - - foreach ( $fields as $field ) { - $element = ''; - $property = ''; - $units = ''; - - // Only continue if $field['output'] is set - if ( isset( $field['output'] ) ) { - - // Check if this is an array of style definitions - $multiple_styles = isset( $field['output'][0]['element'] ) ? true : false; - - if ( ! $multiple_styles ) { // single style - - // If $field['output'] is not an array, then use the string as the target element - if ( is_string( $field['output'] ) ) { - $element = $field['output']; - } else { - $element = isset( $field['output']['element'] ) ? $field['output']['element'] : ''; - $property = isset( $field['output']['property'] ) ? $field['output']['property'] : ''; - $units = isset( $field['output']['units'] ) ? $field['output']['units'] : ''; - } - - $styles = $this->setting_styles( $field, $styles, $element, $property, $units ); - - } else { // Multiple styles set - - foreach ( $field['output'] as $style ) { - - if ( ! array( $style ) ) { - $element = $style; - } else { - $element = isset( $style['element'] ) ? $style['element'] : ''; - $property = isset( $style['property'] ) ? $style['property'] : ''; - $units = isset( $style['units'] ) ? $style['units'] : ''; - } - - $styles = $this->setting_styles( $field, $styles, $element, $property, $units ); - - } - - } - - } - - } - - return $styles; - - } - -} diff --git a/includes/plugins/kirki/includes/class-kirki-color.php b/includes/plugins/kirki/includes/class-kirki-color.php new file mode 100644 index 0000000..c692361 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-color.php @@ -0,0 +1,338 @@ += $opacity && 0 < $opacity ) ? $opacity * 100 : $opacity; + $opacity = max( 0, min( 100, $opacity ) ); + + // Divide the opacity by 100 to end-up with a CSS value for the opacity + $opacity = ( $opacity / 100 ); + + $color = 'rgba('.self::get_rgb( $hex, true ).','.$opacity.')'; + + return $color; + + } + + /** + * Gets the brightness of the $hex color. + * + * @var string The hex value of a color + * @return int value between 0 and 255 + */ + public static function get_brightness( $hex ) { + + $hex = self::sanitize_hex( $hex, false ); + // returns brightness value from 0 to 255 + return intval( ( ( hexdec( substr( $hex, 0, 2 ) ) * 299 ) + ( hexdec( substr( $hex, 2, 2 ) ) * 587 ) + ( hexdec( substr( $hex, 4, 2 ) ) * 114 ) ) / 1000 ); + + } + + /** + * Adjusts brightness of the $hex color. + * + * @var string The hex value of a color + * @var int a value between -255 (darken) and 255 (lighten) + * @return string returns hex color + */ + public static function adjust_brightness( $hex, $steps ) { + + $hex = self::sanitize_hex( $hex, false ); + // Steps should be between -255 and 255. Negative = darker, positive = lighter + $steps = max( -255, min( 255, $steps ) ); + // Adjust number of steps and keep it inside 0 to 255 + $red = max( 0, min( 255, hexdec( substr( $hex, 0, 2 ) ) + $steps ) ); + $green = max( 0, min( 255, hexdec( substr( $hex, 2, 2 ) ) + $steps ) ); + $blue = max( 0, min( 255, hexdec( substr( $hex, 4, 2 ) ) + $steps ) ); + + $red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT ); + $green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT ); + $blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT ); + + return self::sanitize_hex( $red_hex.$green_hex.$blue_hex ); + + } + + /** + * Mixes 2 hex colors. + * the "percentage" variable is the percent of the first color + * to be used it the mix. default is 50 (equal mix) + * + * @var string The hex value of color 1 + * @var string The hex value of color 2 + * @var int a value between 0 and 100 + * @return string returns hex color + */ + public static function mix_colors( $hex1, $hex2, $percentage ) { + + $hex1 = self::sanitize_hex( $hex1, false ); + $hex2 = self::sanitize_hex( $hex2, false ); + + $red = ( $percentage * hexdec( substr( $hex1, 0, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 0, 2 ) ) ) / 100; + $green = ( $percentage * hexdec( substr( $hex1, 2, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 2, 2 ) ) ) / 100; + $blue = ( $percentage * hexdec( substr( $hex1, 4, 2 ) ) + ( 100 - $percentage ) * hexdec( substr( $hex2, 4, 2 ) ) ) / 100; + + $red_hex = str_pad( dechex( $red ), 2, '0', STR_PAD_LEFT ); + $green_hex = str_pad( dechex( $green ), 2, '0', STR_PAD_LEFT ); + $blue_hex = str_pad( dechex( $blue ), 2, '0', STR_PAD_LEFT ); + + return self::sanitize_hex( $red_hex.$green_hex.$blue_hex ); + + } + + /** + * Convert hex color to hsv + * + * @var string The hex value of color 1 + * @return array returns array( 'h', 's', 'v' ) + */ + public static function hex_to_hsv( $hex ) { + $rgb = (array) (array) self::get_rgb( self::sanitize_hex( $hex, false ) ); + return self::rgb_to_hsv( $rgb ); + } + + /** + * Convert hex color to hsv + * + * @var array The rgb color to conver array( 'r', 'g', 'b' ) + * @return array returns array( 'h', 's', 'v' ) + */ + public static function rgb_to_hsv( $color = array() ) { + + $var_r = ( $color[0] / 255 ); + $var_g = ( $color[1] / 255 ); + $var_b = ( $color[2] / 255 ); + + $var_min = min( $var_r, $var_g, $var_b ); + $var_max = max( $var_r, $var_g, $var_b ); + $del_max = $var_max - $var_min; + + $h = 0; + $s = 0; + $v = $var_max; + + if ( 0 != $del_max ) { + $s = $del_max / $var_max; + + $del_r = ( ( ( $var_max - $var_r ) / 6 ) + ( $del_max / 2 ) ) / $del_max; + $del_g = ( ( ( $var_max - $var_g ) / 6 ) + ( $del_max / 2 ) ) / $del_max; + $del_b = ( ( ( $var_max - $var_b ) / 6 ) + ( $del_max / 2 ) ) / $del_max; + + if ( $var_r == $var_max ) { + $h = $del_b - $del_g; + } elseif ( $var_g == $var_max ) { + $h = ( 1 / 3 ) + $del_r - $del_b; + } elseif ( $var_b == $var_max ) { + $h = ( 2 / 3 ) + $del_g - $del_r; + } + + if ( $h < 0 ) { + $h++; + } + + if ( $h > 1 ) { + $h--; + } + } + + return array( 'h' => round( $h, 2 ), 's' => round( $s, 2 ), 'v' => round( $v, 2 ) ); + + } + + /* + * This is a very simple algorithm that works by summing up the differences between the three color components red, green and blue. + * A value higher than 500 is recommended for good readability. + */ + public static function color_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { + + $color_1 = self::sanitize_hex( $color_1, false ); + $color_2 = self::sanitize_hex( $color_2, false ); + + $color_1_rgb = self::get_rgb( $color_1 ); + $color_2_rgb = self::get_rgb( $color_2 ); + + $r_diff = max( $color_1_rgb[0], $color_2_rgb[0] ) - min( $color_1_rgb[0], $color_2_rgb[0] ); + $g_diff = max( $color_1_rgb[1], $color_2_rgb[1] ) - min( $color_1_rgb[1], $color_2_rgb[1] ); + $b_diff = max( $color_1_rgb[2], $color_2_rgb[2] ) - min( $color_1_rgb[2], $color_2_rgb[2] ); + + $color_diff = $r_diff + $g_diff + $b_diff; + + return $color_diff; + + } + + /* + * This function tries to compare the brightness of the colors. + * A return value of more than 125 is recommended. + * Combining it with the color_difference function above might make sense. + */ + public static function brightness_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { + + $color_1 = self::sanitize_hex( $color_1, false ); + $color_2 = self::sanitize_hex( $color_2, false ); + + $color_1_rgb = self::get_rgb( $color_1 ); + $color_2_rgb = self::get_rgb( $color_2 ); + + $br_1 = ( 299 * $color_1_rgb[0] + 587 * $color_1_rgb[1] + 114 * $color_1_rgb[2] ) / 1000; + $br_2 = ( 299 * $color_2_rgb[0] + 587 * $color_2_rgb[1] + 114 * $color_2_rgb[2] ) / 1000; + + return intval( abs( $br_1 - $br_2 ) ); + + } + + /* + * Uses the luminosity to calculate the difference between the given colors. + * The returned value should be bigger than 5 for best readability. + */ + public static function lumosity_difference( $color_1 = '#ffffff', $color_2 = '#000000' ) { + + $color_1 = self::sanitize_hex( $color_1, false ); + $color_2 = self::sanitize_hex( $color_2, false ); + + $color_1_rgb = self::get_rgb( $color_1 ); + $color_2_rgb = self::get_rgb( $color_2 ); + + $l1 = 0.2126 * pow( $color_1_rgb[0] / 255, 2.2 ) + 0.7152 * pow( $color_1_rgb[1] / 255, 2.2 ) + 0.0722 * pow( $color_1_rgb[2] / 255, 2.2 ); + $l2 = 0.2126 * pow( $color_2_rgb[0] / 255, 2.2 ) + 0.7152 * pow( $color_2_rgb[1] / 255, 2.2 ) + 0.0722 * pow( $color_2_rgb[2] / 255, 2.2 ); + + $lum_diff = ( $l1 > $l2 ) ? ( $l1 + 0.05 ) / ( $l2 + 0.05 ) : ( $l2 + 0.05 ) / ( $l1 + 0.05 ); + + return round( $lum_diff, 2 ); + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-colourlovers.php b/includes/plugins/kirki/includes/class-kirki-colourlovers.php new file mode 100644 index 0000000..ddb4518 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-colourlovers.php @@ -0,0 +1,61 @@ + $value ) { + $palettes[ $i ][ $key ] = Kirki_Color::sanitize_hex( $value ); + } + $i++; + } + + return $palettes; + + } + + /** + * @param string|null $xml + */ + public static function parse( $xml = null ) { + + // XML copied from http://www.colourlovers.com/api/palettes/top?numResults=100 + $xml_url = ( is_null( $xml ) ) ? trailingslashit( kirki_url() ).'assets/xml/colourlovers-top.xml' : $xml; + $feed_xml = simplexml_load_file( $xml_url ); + $palettes = array(); + + foreach ( $feed_xml->palette as $result ) { + $palettes[] = (array) $result->colors->hex; + } + + return $palettes; + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-explode-background-field.php b/includes/plugins/kirki/includes/class-kirki-explode-background-field.php new file mode 100644 index 0000000..b7a9124 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-explode-background-field.php @@ -0,0 +1,147 @@ + + */ + public static function explode( $field ) { + $i18n = Kirki_Toolkit::i18n(); + $choices = self::background_choices(); + + // Early exit if this is not a background field. + if ( 'background' != $field['type'] ) { + return; + } + + // Sanitize field + $field = Kirki_Field::sanitize_field( $field ); + // No need to proceed any further if no defaults have been set. + // We build the array of fields based on what default values have been defined. + if ( ! isset( $field['default'] ) || ! is_array( $field['default'] ) ) { + return; + } + + $fields = array(); + $i = 0; + foreach ( $field['default'] as $key => $value ) { + + // No need to process the opacity, it is factored in the color control. + if ( 'opacity' == $key ) { + continue; + } + + $key = esc_attr( $key ); + $setting = $key; + $help = $field['help']; + $description = isset( $i18n[ 'background-'.$key ] ) ? $i18n[ 'background-'.$key ] : ''; + $output_property = 'background-'.$key; + $label = ( 0 === $i ) ? $field['label'] : ''; + $type = 'select'; + + switch ( $key ) { + case 'color': + $type = ( false !== strpos( $field['default']['color'], 'rgba' ) ) ? 'color-alpha' : 'color'; + $type = ( isset( $field['default']['opacity'] ) ) ? 'color-alpha' : $type; + break; + case 'image': + $type = 'image'; + break; + case 'attach': + $output_property = 'background-attachment'; + $description = $i18n['background-attachment']; + break; + default: + $help = ''; + break; + } + + $fields[ $field['settings'].'_'.$setting ] = array_merge( $field, array( + 'type' => $type, + 'label' => $label, + 'settings' => $field['settings'].'_'.$setting, + 'help' => $help, + 'section' => $field['section'], + 'priority' => $field['priority'], + 'required' => $field['required'], + 'description' => $description, + 'default' => $value, + 'id' => Kirki_Field::sanitize_id( array( 'settings' => Kirki_Field::sanitize_settings( array( 'settings' => $field['settings'].'_'.$setting ) ) ) ), + 'choices' => isset( $choices[ $key ] ) ? $choices[ $key ] : array(), + 'output' => ( '' != $field['output'] ) ? array( + array( + 'element' => $field['output'], + 'property' => $output_property, + ), + ) : '', + 'sanitize_callback' => Kirki_Field::fallback_callback( $type ), + ) ); + $i++; + } + + return $fields; + + } + + /** + * Parse all fields and add the new background fields + * + * @param array + * @return array + */ + public static function process_fields( $fields ) { + foreach ( $fields as $field ) { + if ( isset( $field['type'] ) && 'background' == $field['type'] ) { + $explode = self::explode( $field ); + $fields = array_merge( $fields, $explode ); + } + } + return $fields; + } + + + /** + * The background choices. + * @return array + */ + public static function background_choices() { + + $i18n = Kirki_Toolkit::i18n(); + + return array( + 'repeat' => array( + 'no-repeat' => $i18n['no-repeat'], + 'repeat' => $i18n['repeat-all'], + 'repeat-x' => $i18n['repeat-x'], + 'repeat-y' => $i18n['repeat-y'], + 'inherit' => $i18n['inherit'], + ), + 'size' => array( + 'inherit' => $i18n['inherit'], + 'cover' => $i18n['cover'], + 'contain' => $i18n['contain'], + ), + 'attach' => array( + 'inherit' => $i18n['inherit'], + 'fixed' => $i18n['fixed'], + 'scroll' => $i18n['scroll'], + ), + 'position' => array( + 'left-top' => $i18n['left-top'], + 'left-center' => $i18n['left-center'], + 'left-bottom' => $i18n['left-bottom'], + 'right-top' => $i18n['right-top'], + 'right-center' => $i18n['right-center'], + 'right-bottom' => $i18n['right-bottom'], + 'center-top' => $i18n['center-top'], + 'center-center' => $i18n['center-center'], + 'center-bottom' => $i18n['center-bottom'], + ), + ); + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-field.php b/includes/plugins/kirki/includes/class-kirki-field.php new file mode 100644 index 0000000..18e3385 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-field.php @@ -0,0 +1,598 @@ + self::sanitize_settings_raw( $field ), + 'default' => self::sanitize_default( $field ), + 'label' => self::sanitize_label( $field ), + 'help' => self::sanitize_help( $field ), + 'description' => self::sanitize_description( $field ), + 'required' => self::sanitize_required( $field ), + 'transport' => self::sanitize_transport( $field ), + 'type' => self::sanitize_control_type( $field ), + 'option_type' => self::sanitize_type( $field ), + 'section' => self::sanitize_section( $field ), + 'settings' => self::sanitize_settings( $field ), + 'priority' => self::sanitize_priority( $field ), + 'choices' => self::sanitize_choices( $field ), + 'output' => self::sanitize_output( $field ), + 'sanitize_callback' => self::sanitize_callback( $field ), + 'js_vars' => self::sanitize_js_vars( $field ), + 'id' => self::sanitize_id( $field ), + 'capability' => self::sanitize_capability( $field ), + 'variables' => self::sanitize_variables( $field ), + 'active_callback' => self::sanitize_active_callback( $field ) + ); + + return array_merge( $field, $sanitized ); + + } + + /** + * Sanitizes the control type. + * + * @param array the field definition + * @return string If not set, then defaults to text. + */ + public static function sanitize_control_type( $field ) { + + // If no field type has been defined then fallback to text + if ( ! isset( $field['type'] ) ) { + return 'text'; + } + + switch ( $field['type'] ) { + + case 'checkbox' : + /** + * Tweaks for backwards-compatibility: + * Prior to version 0.8 switch & toggle were part of the checkbox control. + */ + if ( isset( $field['mode'] ) && 'switch' == $field['mode'] ) { + $field['type'] = 'switch'; + } elseif ( isset( $field['mode'] ) && 'toggle' == $field['mode'] ) { + $field['type'] = 'toggle'; + } + break; + case 'radio' : + /** + * Tweaks for backwards-compatibility: + * Prior to version 0.8 radio-buttonset & radio-image were part of the checkbox control. + */ + if ( isset( $field['mode'] ) && 'buttonset' == $field['mode'] ) { + $field['type'] = 'radio-buttonset'; + } elseif ( isset( $field['mode'] ) && 'image' == $field['mode'] ) { + $field['type'] = 'radio-image'; + } + break; + case 'group-title' : + case 'group_title' : + /** + * Tweaks for backwards-compatibility: + * Prior to version 0.8 there was a group-title control. + */ + $field['type'] = 'custom'; + break; + case 'color_alpha' : + // Just making sure that common mistakes will still work. + $field['type'] = 'color-alpha'; + break; + case 'color' : + // If a default value of rgba() is defined for a color control then use color-alpha instead. + if ( isset( $field['default'] ) && false !== strpos( $field['default'], 'rgba' ) ) { + $field['type'] = 'color-alpha'; + } + break; + } + + return esc_attr( $field['type'] ); + + } + + /** + * Sanitizes the setting type. + * + * @param array the field definition + * @return string (theme_mod|option) + */ + public static function sanitize_type( $field ) { + + if ( isset( $field['option_type'] ) ) { + return esc_attr( $field['option_type'] ); + } + // If no 'option_type' has been defined then try to get the option from the kirki/config filter. + $config = apply_filters( 'kirki/config', array() ); + if ( isset( $config['option_type'] ) ) { + return esc_attr( $config['option_type'] ); + } + // Fallback to theme_mod + return 'theme_mod'; + + } + + /** + * Sanitizes the setting variables. + * + * @param array the field definition + * @return mixed + */ + public static function sanitize_variables( $field ) { + + if ( isset( $field['variables'] ) && is_array( $field['variables'] ) ) { + return $field['variables']; + } + // fallback to null + return null; + + } + + /** + * Sanitizes the setting active callback. + * + * @param array the field definition + * @return string callable function name. + */ + public static function sanitize_active_callback( $field ) { + + if ( isset( $field['active_callback'] ) ) { + return $field['active_callback']; + } + // If the 'required' argument is set then we'll need to auto-calculate things. + if ( isset( $field['required'] ) ) { + return 'kirki_active_callback'; + } + // fallback to __return_true + return '__return_true'; + + } + + /** + * Sanitizes the setting permissions. + * + * @param array the field definition + * @return string (theme_mod|option) + */ + public static function sanitize_capability( $field ) { + + if ( ! isset( $field['capability'] ) ) { + // Try to get a value from the kirki/config filter + $config = apply_filters( 'kirki/config', array() ); + if ( isset( $config['capability'] ) ) { + return esc_attr( $config['capability'] ); + } + // fallback to edit_theme_options + return 'edit_theme_options'; + } + // All good, a capability has been defined so return that escaped. + return esc_attr( $field['capability'] ); + + } + + /** + * Sanitizes the raw setting name. + * + * @param array the field definition + * @return string + */ + public static function sanitize_settings_raw( $field ) { + + /** + * Compatibility tweak + * Previous versions of the Kirki customizer used 'setting' istead of 'settings'. + */ + if ( ! isset( $field['settings'] ) && isset( $field['setting'] ) ) { + return sanitize_key( $field['setting'] ); + } + + // Sanitize the field's settings attribute. + return sanitize_key( $field['settings'] ); + + } + + /** + * Sanitizes the setting name + * + * @param array the field definition + * @return string + */ + public static function sanitize_settings( $field ) { + + // If the value of 'option_name' is not empty, then we're also using options instead of theme_mods. + if ( ( isset( $field['option_name'] ) ) && ! empty( $field['option_name'] ) ) { + $field['settings'] = esc_attr( $field['option_name'] ).'['.esc_attr( $field['settings'] ).']'; + } + return $field['settings']; + + } + + /** + * Sanitizes the control label. + * + * @param array the field definition + * @return string + */ + public static function sanitize_label( $field ) { + + if ( isset( $field['label'] ) ) { + return esc_html( $field['label'] ); + } + return ''; + + } + + /** + * Sanitizes the control section + * + * @param array the field definition + * @return string + */ + public static function sanitize_section( $field ) { + + // If no section is defined then make sure we add the one section that is ALWAYS present: title_tagline + if ( ! isset( $field['section'] ) ) { + return 'title_tagline'; + } + return sanitize_key( $field['section'] ); + + } + + /** + * Sanitizes the control id. + * Sanitizing the ID should happen after the 'settings' sanitization. + * This way we can also properly handle cases where the option_type is set to 'option' + * and we're using an array instead of individual options. + * + * @param array the field definition + * @return string + */ + public static function sanitize_id( $field ) { + return sanitize_key( str_replace( '[', '-', str_replace( ']', '', $field['settings'] ) ) ); + } + + /** + * Sanitizes the setting default value + * + * @param array the field definition + * @return mixed + */ + public static function sanitize_default( $field ) { + + // make sure a default value is defined. + if ( ! isset( $field['default'] ) ) { + return ''; + } + // If an array then sanitize the array items separately + if ( is_array( $field['default'] ) ) { + array_walk_recursive( $field['default'], array( 'Kirki_Field', 'sanitize_defaults_array' ) ); + return $field['default']; + } + // Return raw & unfiltered for custom controls + if ( isset( $field['type'] ) && 'custom' == $field['type'] ) { + return $field['default']; + } + // fallback to escaping the default value. + return esc_textarea( $field['default'] ); + + } + + /** + * Sanitizes the control description + * + * @param array the field definition + * @return string + */ + public static function sanitize_description( $field ) { + + if ( ! isset( $field['description'] ) && ! isset( $field['subtitle'] ) ) { + return ''; + } + + /** + * Compatibility tweak + * + * Previous verions of the Kirki Customizer had the 'description' field mapped to the new 'help' + * and instead of 'description' we were using 'subtitle'. + * This has been deprecated in favor of WordPress core's 'description' field that was recently introduced. + * + */ + if ( isset( $field['subtitle'] ) ) { + return wp_strip_all_tags( $field['subtitle'] ); + } + return wp_strip_all_tags( $field['description'] ); + + } + + /** + * Sanitizes the control help + * + * @param array the field definition + * @return string + */ + public static function sanitize_help( $field ) { + + /** + * Compatibility tweak + * + * Previous verions of the Kirki Customizer had the 'description' field mapped to the new 'help' + * and instead of 'description' we were using 'subtitle'. + * This has been deprecated in favor of WordPress core's 'description' field that was recently introduced. + * + */ + if ( isset( $field['subtitle'] ) ) { + // Use old arguments form. + if ( isset( $field['description'] ) ) { + return wp_strip_all_tags( $field['description'] ); + } + return ''; + } + // Return empty string if not set. + if ( ! isset( $field['help'] ) ) { + return ''; + } + // Fallback to stripping all tags and returning. + return wp_strip_all_tags( $field['help'] ); + + } + + /** + * Sanitizes the control choices. + * + * @param array the field definition + * @return array|string + */ + public static function sanitize_choices( $field ) { + + // If not set then return an empty array. + if ( ! isset( $field['choices'] ) ) { + return array(); + } + // sanitize the array recursively. + if ( is_array( $field['choices'] ) ) { + array_walk_recursive( $field['choices'], array( 'Kirki_Field', 'sanitize_defaults_array' ) ); + return $field['choices']; + } + // this is a string so fallback to escaping the value and return. + return esc_attr( $field['choices'] ); + + } + + /** + * Sanitizes the control output + * + * @param array the field definition + * @return array + */ + public static function sanitize_output( $field ) { + + // Early exit if output is not set + if ( ! isset( $field['output'] ) ) { + return null; + } + // sanitize using esc_attr if output is string. + if ( ! is_array( $field['output'] ) ) { + return esc_attr( $field['output'] ); + } + $output_sanitized = array(); + // convert to multidimentional array if necessary + if ( isset( $field['output']['element'] ) ) { + $field['output'] = array( $field['output'] ); + } + // sanitize array items individually + foreach ( $field['output'] as $output ) { + if ( ! isset( $output['media_query'] ) ) { + if ( isset( $output['prefix'] ) && ( false !== strpos( $output['prefix'], '@media' ) ) ) { + $output['media_query'] = $output['prefix']; + $output['prefix'] = ''; + $output['suffix'] = ''; + } else { + $output['media_query'] = 'global'; + } + } + $output_sanitized[] = array( + 'element' => ( isset( $output['element'] ) ) ? sanitize_text_field( $output['element'] ) : '', + 'property' => ( isset( $output['property'] ) ) ? sanitize_text_field( $output['property'] ) : '', + 'units' => ( isset( $output['units'] ) ) ? sanitize_text_field( $output['units'] ) : '', + 'media_query' => trim( sanitize_text_field( str_replace( '{', '', $output['media_query'] ) ) ), + ); + } + return $output_sanitized; + + } + + /** + * Sanitizes the control transport. + * + * @param array the field definition + * @return string postMessage|refresh (defaults to refresh) + */ + public static function sanitize_transport( $field ) { + + if ( isset( $field['transport'] ) && 'postMessage' == $field['transport'] ) { + return 'postMessage'; + } + // fallback to 'refresh' + return 'refresh'; + + } + + /** + * Sanitizes the setting sanitize_callback + * + * @param array the field definition + * @return mixed the sanitization callback for this setting + */ + public static function sanitize_callback( $field ) { + + if ( isset( $field['sanitize_callback'] ) && ! empty( $field['sanitize_callback'] ) ) { + return $field['sanitize_callback']; + } + // Fallback callback + return self::fallback_callback( $field['type'] ); + + } + + /** + * Sanitizes the control js_vars. + * + * @param array the field definition + * @return array|null + */ + public static function sanitize_js_vars( $field ) { + + $js_vars_sanitized = null; + if ( isset( $field['js_vars'] ) && is_array( $field['js_vars'] ) ) { + $js_vars_sanitized = array(); + if ( isset( $field['js_vars']['element'] ) ) { + $field['js_vars'] = array( $field['js_vars'] ); + } + foreach ( $field['js_vars'] as $js_vars ) { + $js_vars_sanitized[] = array( + 'element' => ( isset( $js_vars['element'] ) ) ? sanitize_text_field( $js_vars['element'] ) : '', + 'function' => ( isset( $js_vars['function'] ) ) ? esc_js( $js_vars['function'] ) : '', + 'property' => ( isset( $js_vars['property'] ) ) ? esc_js( $js_vars['property'] ) : '', + 'units' => ( isset( $js_vars['units'] ) ) ? esc_js( $js_vars['units'] ) : '', + ); + } + } + return $js_vars_sanitized; + + } + + /** + * Sanitizes the control required argument. + * + * @param array the field definition + * @return array|null + */ + public static function sanitize_required( $field ) { + + $required_sanitized = null; + if ( isset( $field['required'] ) && is_array( $field['required'] ) ) { + $required_sanitized = array(); + if ( isset( $field['required']['setting'] ) ) { + $field['required'] = array( $field['required'] ); + } + foreach ( $field['required'] as $required ) { + $required_sanitized[] = array( + 'setting' => ( isset( $required['setting'] ) ) ? sanitize_text_field( $required['setting'] ) : '', + 'operator' => ( isset( $required['operator'] ) && in_array( $required['operator'], array( '==', '===', '!=', '!==', '>=', '<=', '>', '<' ) ) ) ? $required['operator'] : '==', + 'value' => ( isset( $required['value'] ) ) ? sanitize_text_field( $required['value'] ) : true, + ); + } + } + return $required_sanitized; + + } + + /** + * Sanitizes the control priority + * + * @param array the field definition + * @return int + */ + public static function sanitize_priority( $field ) { + + if ( ! isset( $field['priority'] ) || '0' == absint( intval( $field['priority'] ) ) ) { + return 10; + } + return absint( intval( $field['priority'] ) ); + + } + + /** + * Sanitizes the control transport. + * + * @param string the control type + * @return string|string[] the function name of a sanitization callback + */ + public static function fallback_callback( $field_type ) { + + switch ( $field_type ) { + case 'checkbox' : + case 'toggle' : + case 'switch' : + $sanitize_callback = array( 'Kirki_Sanitize', 'checkbox' ); + break; + case 'color' : + case 'color-alpha' : + $sanitize_callback = array( 'Kirki_Sanitize', 'color' ); + break; + case 'image' : + case 'upload' : + $sanitize_callback = 'esc_url_raw'; + break; + case 'radio' : + case 'radio-image' : + case 'radio-buttonset' : + case 'select' : + case 'palette' : + $sanitize_callback = array( 'Kirki_Sanitize', 'choice' ); + break; + case 'dropdown-pages' : + $sanitize_callback = array( 'Kirki_Sanitize', 'dropdown_pages' ); + break; + case 'slider' : + case 'number' : + $sanitize_callback = array( 'Kirki_Sanitize', 'number' ); + break; + case 'text' : + case 'textarea' : + case 'editor' : + $sanitize_callback = 'esc_textarea'; + break; + case 'multicheck' : + $sanitize_callback = array( 'Kirki_Sanitize', 'multicheck' ); + break; + case 'sortable' : + $sanitize_callback = array( 'Kirki_Sanitize', 'sortable' ); + break; + default : + $sanitize_callback = array( 'Kirki_Sanitize', 'unfiltered' ); + break; + } + + return $sanitize_callback; + + } + + /** + * Sanitizes the defaults array. + * This is used as a callback function in the sanitize_default method. + */ + public static function sanitize_defaults_array( $value = '', $key = '' ) { + + $value = esc_textarea( $value ); + $key = esc_attr( $key ); + + } + +} diff --git a/includes/plugins/kirki/includes/Fonts/FontRegistry.php b/includes/plugins/kirki/includes/class-kirki-fonts-font-registry.php similarity index 64% rename from includes/plugins/kirki/includes/Fonts/FontRegistry.php rename to includes/plugins/kirki/includes/class-kirki-fonts-font-registry.php index 8d26a43..f511ef2 100644 --- a/includes/plugins/kirki/includes/Fonts/FontRegistry.php +++ b/includes/plugins/kirki/includes/class-kirki-fonts-font-registry.php @@ -1,16 +1,26 @@ get_standard_fonts(); $google_fonts = $this->get_google_fonts(); - return apply_filters('kirki/fonts/all', array_merge($standard_fonts, $google_fonts)); + return apply_filters( 'kirki/fonts/all', array_merge( $standard_fonts, $google_fonts ) ); } /** @@ -58,9 +68,8 @@ public function get_font_choices() { * * @return boolean */ - public function is_google_font($font) { - $allowed_fonts = $this->get_google_fonts(); - return ( array_key_exists( $font, $allowed_fonts ) ) ? true : false; + public function is_google_font( $font ) { + return ( array_key_exists( $font, $this->get_google_fonts() ) ); } @@ -77,12 +86,10 @@ public function get_google_font_uri( $fonts, $weight = 400, $subset = 'all' ) { // Validate each font and convert to URL format foreach ( $fonts as $font ) { - $font = trim( $font ); - // Verify that the font exists if ( $this->is_google_font( $font ) ) { // Build the family name and variant string (e.g., "Open+Sans:regular,italic,700") - $family[] = urlencode( $font . ':' . join( ',', $this->choose_google_font_variants( $font, $allowed_fonts[ $font ]['variants'] ) ) ); + $family[] = $font.':'.join( ',', $this->choose_google_font_variants( $font, $allowed_fonts[ $font ]['variants'] ) ).','; } } @@ -90,30 +97,32 @@ public function get_google_font_uri( $fonts, $weight = 400, $subset = 'all' ) { if ( empty( $family ) ) { return ''; } else { - $request = '//fonts.googleapis.com/css?family=' . implode( '|', $family ); + $request = str_replace( ' ', '+', '//fonts.googleapis.com/css?family='.implode( '|', $family ) ); } // load the font weight - $weight = ( is_array( $weight ) ) ? implode( ',', $weight ) : $weight; - $request .= $weight; + $weight = ( is_array( $weight ) ) ? implode( ',', $weight ) : $weight; + $request .= trim( $weight ); // Load the font subset - if ( 'all' === $subset ) { - $subsets_available = $this->get_google_font_subsets(); + if ( 'all' == $subset ) { + $subsets_available = $this->get_google_font_subsets(); // Remove the all set unset( $subsets_available['all'] ); - // Build the array $subsets = array_keys( $subsets_available ); + } else { - $subsets = (array)$subset; + + $subsets = (array) $subset; + } // Append the subset string - $request .= ( ! empty( $subsets ) ) ? '&subset=' . join( ',', $subsets ) : ''; + $request .= ( ! empty( $subsets ) ) ? '&subset='.join( ',', $subsets ) : ''; - return esc_url( $request ); + return $request; } /** @@ -122,7 +131,8 @@ public function get_google_font_uri( $fonts, $weight = 400, $subset = 'all' ) { * @return array The available subsets. */ public function get_google_font_subsets() { - $i18n = Kirki::i18n(); + + $i18n = Kirki_Toolkit::i18n(); return array( 'all' => $i18n['all'], 'cyrillic' => $i18n['cyrillic'], @@ -135,6 +145,7 @@ public function get_google_font_subsets() { 'latin-ext' => $i18n['latin-ext'], 'vietnamese' => $i18n['vietnamese'], ); + } /** @@ -147,7 +158,8 @@ public function get_google_font_subsets() { * @param array $variants The variants for the font. * @return array The chosen variants. */ - public function choose_google_font_variants($font, $variants = array()) { + public function choose_google_font_variants( $font, $variants = array() ) { + $chosen_variants = array(); if ( empty( $variants ) ) { @@ -158,12 +170,7 @@ public function choose_google_font_variants($font, $variants = array()) { } // If a "regular" variant is not found, get the first variant - if ( ! in_array( 'regular', $variants ) ) { - $chosen_variants[] = $variants[0]; - } else { - $chosen_variants[] = 'regular'; - } - + $chosen_variants[] = ( ! in_array( 'regular', $variants ) ) ? $variants[0] : 'regular'; // Only add "italic" if it exists if ( in_array( 'italic', $variants ) ) { $chosen_variants[] = 'italic'; @@ -174,7 +181,8 @@ public function choose_google_font_variants($font, $variants = array()) { $chosen_variants[] = '700'; } - return apply_filters( 'kirki/font/variants', array_unique($chosen_variants), $font, $variants ); + return apply_filters( 'kirki/font/variants', array_unique( $chosen_variants ), $font, $variants ); + } /** @@ -183,25 +191,28 @@ public function choose_google_font_variants($font, $variants = array()) { * @return array Standard websafe fonts. */ public function get_standard_fonts() { - $i18n = Kirki::i18n(); - if ($this->standard_fonts==null) { - $this->standard_fonts = apply_filters('kirki/fonts/standard_fonts', array( - 'serif' => array( + + $i18n = Kirki_Toolkit::i18n(); + + if ( null == $this->standard_fonts ) { + $this->standard_fonts = apply_filters( 'kirki/fonts/standard_fonts', array( + 'serif' => array( 'label' => $i18n['serif'], - 'stack' => 'Georgia,Times,"Times New Roman",serif' + 'stack' => 'Georgia,Times,"Times New Roman",serif', ), 'sans-serif' => array( - 'label' => $i18n['sans-serif'], - 'stack' => '"Helvetica Neue",Helvetica,Arial,sans-serif' + 'label' => $i18n['sans-serif'], + 'stack' => '"Helvetica Neue",Helvetica,Arial,sans-serif', ), - 'monospace' => array( + 'monospace' => array( 'label' => $i18n['monospace'], - 'stack' => 'Monaco,"Lucida Sans Typewriter","Lucida Typewriter","Courier New",Courier,monospace' - ) - )); + 'stack' => 'Monaco,"Lucida Sans Typewriter","Lucida Typewriter","Courier New",Courier,monospace', + ), + ) ); } return $this->standard_fonts; + } @@ -212,6 +223,7 @@ public function get_standard_fonts() { * @return string The full font stack. */ public function get_font_stack( $font ) { + $all_fonts = $this->get_all_fonts(); // Sanitize font choice @@ -220,12 +232,10 @@ public function get_font_stack( $font ) { // Use stack if one is identified if ( isset( $all_fonts[ $font ]['stack'] ) && ! empty( $all_fonts[ $font ]['stack'] ) ) { - $stack = $all_fonts[ $font ]['stack']; - } else { - $stack = '"' . $font . '",' . $sans; + return $all_fonts[ $font ]['stack']; } + return '"'.$font.'",'.$sans; - return $stack; } /** @@ -235,14 +245,16 @@ public function get_font_stack( $font ) { * @return string The sanitized font choice. */ public function sanitize_font_choice( $value ) { + + // The array key is an integer, so the chosen option is a heading, not a real choice if ( is_int( $value ) ) { - // The array key is an integer, so the chosen option is a heading, not a real choice return ''; - } else if ( array_key_exists( $value, $this->get_font_choices() ) ) { + } + if ( array_key_exists( $value, $this->get_font_choices() ) ) { return $value; } - return ''; + } /** @@ -251,23 +263,35 @@ public function sanitize_font_choice( $value ) { * @return array All Google Fonts. */ public function get_google_fonts() { - if ($this->google_fonts==null) { + + global $wp_filesystem; + // Initialize the WP filesystem, no more using 'file-put-contents' function + if ( empty( $wp_filesystem ) ) { + require_once ( ABSPATH.'/wp-admin/includes/file.php' ); + WP_Filesystem(); + } + + if ( null == $this->google_fonts ) { + + $json = $wp_filesystem->get_contents( KIRKI_PATH.'/assets/json/webfonts.json' ); // Get the list of fonts from our json file and convert to an array - $fonts = json_decode(file_get_contents(KIRKI_PATH . '/assets/json/webfonts.json'), true); + $fonts = json_decode( $json, true ); $google_fonts = array(); - foreach ($fonts['items'] as $font) { - $google_fonts[$font['family']] = array( + foreach ( $fonts['items'] as $font ) { + $google_fonts[ $font['family'] ] = array( 'label' => $font['family'], 'variants' => $font['variants'], 'subsets' => $font['subsets'], ); } - $this->google_fonts = apply_filters('kirki/fonts/google_fonts', $google_fonts); + $this->google_fonts = apply_filters( 'kirki/fonts/google_fonts', $google_fonts ); + } return $this->google_fonts; + } } diff --git a/includes/plugins/kirki/includes/class-kirki-helper.php b/includes/plugins/kirki/includes/class-kirki-helper.php new file mode 100644 index 0000000..5ba1d71 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-helper.php @@ -0,0 +1,94 @@ +get_col( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE guid='%s';", $url ) ); + return $attachment[0]; + + } + + /** + * Returns an array of the attachment's properties. + * + * @var string URL to the image + * @return array array() + */ + public static function get_image_from_url( $url ) { + + $image_id = self::get_image_id( $url ); + $image = wp_get_attachment_image_src( $image_id, 'full' ); + + return array( + 'url' => $image[0], + 'width' => $image[1], + 'height' => $image[2], + 'thumbnail' => $image[3], + ); + + } + + /** + * Helper function that gets posts and fomats them in a way so they can be used in select fields etc. + */ + public static function get_posts( $args ) { + + // Get the posts + $posts = get_posts( $args ); + + // properly format the array. + $items = array(); + foreach ( $posts as $post ) { + $items[ $post->ID ] = $post->post_title; + } + + return $items; + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-output.php b/includes/plugins/kirki/includes/class-kirki-output.php new file mode 100644 index 0000000..fbe40d5 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-output.php @@ -0,0 +1,218 @@ + $output ) ); + self::$value = self::get_value(); + self::$callback = $callback; + + return ( true === $return_array ) ? self::styles() : self::styles_parse( self::add_prefixes( self::styles() ) ); + + } + + /** + * Gets the value + */ + public static function get_value() { + + // Get the default value + $default = ''; + if ( isset( Kirki::$fields[ self::$settings ] ) && isset( Kirki::$fields[ self::$settings ]['default'] ) ) { + if ( ! is_array( Kirki::$fields[ self::$settings ]['default'] ) ) { + $default = Kirki::$fields[ self::$settings ]['default']; + } + } + + if ( 'theme_mod' == self::$type ) { // This is a theme_mod + $value = get_theme_mod( self::$settings, $default ); + } else { // This is an option + $value = get_option( self::$settings, $default ); + } + + return $value; + + } + + /** + * Gets the array of generated styles and creates the minimized, inline CSS + * + * @param array + * @return string|null the generated CSS. + */ + public static function styles_parse( $css = array() ) { + + /** + * Process the array of CSS properties and produce the final CSS + */ + $final_css = ''; + foreach ( $css as $media_query => $styles ) { + + $final_css .= ( 'global' != $media_query ) ? $media_query . '{' : ''; + + foreach ( $styles as $style => $style_array ) { + $final_css .= $style . '{'; + foreach ( $style_array as $property => $value ) { + // Take care of formatting the URL for background-image statements. + if ( 'background-image' == $property || 'background' == $property && false !== filter_var( $value, FILTER_VALIDATE_URL, FILTER_FLAG_PATH_REQUIRED ) ) { + $value = 'url("'.$value.'")'; + } + // Make sure the background-position property is properly formatted + if ( 'background-position' == $property ) { + $value = str_replace( array( '_', '-' ), ' ', $value ); + } + $final_css .= $property . ':' . $value . ';'; + } + $final_css .= '}'; + } + + $final_css .= ( 'global' != $media_query ) ? '}' : ''; + + } + + + return $final_css; + + } + + /** + * Get the styles as an array. + */ + public static function styles() { + + $styles = array(); + + foreach ( self::$output as $output ) { + // Do we have units? + $units = ( isset( $output['units'] ) ) ? $output['units'] : ''; + // Do we need to run this through a callback action? + $value = ( '' != self::$callback ) ? call_user_func( self::$callback, self::$value ) : self::$value; + + $styles[ $output['media_query'] ][ $output['element'] ][ $output['property'] ] = $value.$units; + } + + return $styles; + + } + + /** + * Add prefixes if necessary + */ + public static function add_prefixes( $css ) { + + if ( ! is_array( $css ) ) { + return; + } + + foreach ( $css as $media_query => $elements ) { + + foreach ( $elements as $element => $style_array ) { + + foreach ( $style_array as $property => $value ) { + + // border-radius + if ( 'border-radius' == $property ) { + $css[$media_query][$element]['-webkit-border-radius'] = $value; + $css[$media_query][$element]['-moz-border-radius'] = $value; + } + // box-shadow + if ( 'box-shadow' == $property ) { + $css[$media_query][$element]['-webkit-box-shadow'] = $value; + $css[$media_query][$element]['-moz-box-shadow'] = $value; + } + // box-sizing + elseif ( 'box-sizing' == $property ) { + $css[$media_query][$element]['-webkit-box-sizing'] = $value; + $css[$media_query][$element]['-moz-box-sizing'] = $value; + } + // text-shadow + elseif ( 'text-shadow' == $property ) { + $css[$media_query][$element]['-webkit-text-shadow'] = $value; + $css[$media_query][$element]['-moz-text-shadow'] = $value; + } + // transform + elseif ( 'transform' == $property ) { + $css[$media_query][$element]['-webkit-transform'] = $value; + $css[$media_query][$element]['-moz-transform'] = $value; + $css[$media_query][$element]['-ms-transform'] = $value; + $css[$media_query][$element]['-o-transform'] = $value; + } + // background-size + elseif ( 'background-size' == $property ) { + $css[$media_query][$element]['-webkit-background-size'] = $value; + $css[$media_query][$element]['-moz-background-size'] = $value; + $css[$media_query][$element]['-ms-background-size'] = $value; + $css[$media_query][$element]['-o-background-size'] = $value; + } + // transition + elseif ( 'transition' == $property ) { + $css[$media_query][$element]['-webkit-transition'] = $value; + $css[$media_query][$element]['-moz-transition'] = $value; + $css[$media_query][$element]['-ms-transition'] = $value; + $css[$media_query][$element]['-o-transition'] = $value; + } + // transition-property + elseif ( 'transition-property' == $property ) { + $css[$media_query][$element]['-webkit-transition-property'] = $value; + $css[$media_query][$element]['-moz-transition-property'] = $value; + $css[$media_query][$element]['-ms-transition-property'] = $value; + $css[$media_query][$element]['-o-transition-property'] = $value; + } + + } + + } + + } + + return $css; + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-sanitize.php b/includes/plugins/kirki/includes/class-kirki-sanitize.php new file mode 100644 index 0000000..f9a5210 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-sanitize.php @@ -0,0 +1,180 @@ +get_control() https://developer.wordpress.org/reference/classes/wp_customize_manager/get_control/ + * + * @param string $input Slug to sanitize. + * @param WP_Customize_Setting $setting Setting instance. + * @return string Sanitized slug if it is a valid choice; otherwise, the setting default. + */ + public static function choice( $input, $setting ) { + + // Ensure input is a slug. + $input = sanitize_key( $input ); + + if ( ! is_object( $setting->manager->get_control( $setting->id ) ) || null == $setting->manager->get_control( $setting->id ) ) { + return $input; + } else { + // Get list of choices from the control associated with the setting. + $choices = $setting->manager->get_control( $setting->id )->choices; + + return ( ! is_array( $choices ) || ! is_object( $setting ) || array_key_exists( $input, $choices ) ? $input : $setting->default ); + } + } + + /** + * Drop-down Pages sanitization callback. + * + * - Sanitization: dropdown-pages + * - Control: dropdown-pages + * + * Sanitization callback for 'dropdown-pages' type controls. This callback sanitizes `$page_id` + * as an absolute integer, and then validates that $input is the ID of a published page. + * + * @see absint() https://developer.wordpress.org/reference/functions/absint/ + * @see get_post_status() https://developer.wordpress.org/reference/functions/get_post_status/ + * + * @param int $page_id Page ID. + * @param WP_Customize_Setting $setting Setting instance. + * @return int|string Page ID if the page is published; otherwise, the setting default. + */ + public static function dropdown_pages( $page_id, $setting ) { + // Ensure $input is an absolute integer. + $page_id = absint( $page_id ); + + // If $page_id is an ID of a published page, return it; otherwise, return the default. + return ( 'publish' == get_post_status( $page_id ) ? $page_id : $setting->default ); + } + + /** + * Sanitize sortable controls + * + * @since 0.8.3 + */ + + public static function sortable( $value ) { + if ( is_serialized( $value ) ) { + return $value; + } else { + return serialize( $value ); + } + } + + /** + * Sanitize RGBA colors + * + * @since 0.8.5 + */ + public static function rgba( $value ) { + + // If empty or an array return transparent + if ( empty( $value ) || is_array( $value ) ) { + return 'rgba(0,0,0,0)'; + } + + // If string does not start with 'rgba', then treat as hex + // sanitize the hex color and finally convert hex to rgba + if ( false === strpos( $value, 'rgba' ) ) { + return Kirki_Color::get_rgba( Kirki_Color::sanitize_hex( $value ) ); + } + + // By now we know the string is formatted as an rgba color so we need to further sanitize it. + $value = str_replace( ' ', '', $value ); + sscanf( $value, 'rgba(%d,%d,%d,%f)', $red, $green, $blue, $alpha ); + return 'rgba('.$red.','.$green.','.$blue.','.$alpha.')'; + + } + + /** + * Sanitize colors. + * Determine if the current value is a hex or an rgba color and call the appropriate method. + * + * @since 0.8.5 + * @return string + */ + public static function color( $value ) { + + // Is this an rgba color or a hex? + $mode = ( false === strpos( $value, 'rgba' ) ) ? 'rgba' : 'hex'; + + if ( 'rgba' == $mode ) { + return Kirki_Color::sanitize_hex( $value ); + } else { + return self::rgba( $value ); + } + + } + + /** + * multicheck callback + */ + public static function multicheck( $values ) { + + $multi_values = ( ! is_array( $values ) ) ? explode( ',', $values ) : $values; + return ( ! empty( $multi_values ) ) ? array_map( 'sanitize_text_field', $multi_values ) : array(); + + } + + /** + * DOES NOT SANITIZE ANYTHING. + * + * @since 0.5 + */ + public static function unfiltered( $value ) { + return $value; + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-scripts-customizer-branding.php b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-branding.php new file mode 100644 index 0000000..99db75f --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-branding.php @@ -0,0 +1,63 @@ +\' );'; + } + if ( isset( $config['description'] ) && '' != $config['description'] ) { + $config['description'] = esc_textarea( $config['description'] ); + $script .= '$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'
      '.$config['description'].'
      \' );'; + } + } + + return $script; + + } + + public function customize_controls_print_scripts() { + $script = $this->generate_script(); + if ( '' != $script ) { + echo Kirki_Scripts_Registry::prepare( $script ); + } + } + + public function customize_controls_enqueue_scripts() {} + + public function customize_controls_print_footer_scripts() {} + + public function wp_footer() {} + +} diff --git a/includes/plugins/kirki/includes/class-kirki-scripts-customizer-default-scripts.php b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-default-scripts.php new file mode 100644 index 0000000..fc095f5 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-default-scripts.php @@ -0,0 +1,50 @@ +generate_script(); + if ( '' != $script ) { + echo Kirki_Scripts_Registry::prepare( $script ); + } + } + + public function customize_controls_print_scripts() {} + + public function customize_controls_enqueue_scripts() {} + + public function customize_controls_print_footer_scripts() {} + +} diff --git a/includes/plugins/kirki/includes/class-kirki-scripts-customizer-tooltips.php b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-tooltips.php new file mode 100644 index 0000000..8b561b8 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-scripts-customizer-tooltips.php @@ -0,0 +1,73 @@ +"; + $scripts[] = '$( "'.$content.'" ).prependTo( "#customize-control-'.$field['settings'].'" );'; + } + + } + + // No need to echo anything if the script is empty + if ( empty( $scripts ) ) { + return; + } + + // Make sure we don't add any duplicates + $scripts = array_unique( $scripts ); + // Convert array to string + $script = implode( '', $scripts ); + + return $script; + + } + + public function customize_controls_print_footer_scripts() { + $script = $this->generate_script(); + if ( '' != $script ) { + echo Kirki_Scripts_Registry::prepare( $script ); + } + } + + public function customize_controls_print_scripts() {} + + public function customize_controls_enqueue_scripts() {} + + public function wp_footer() {} + +} diff --git a/includes/plugins/kirki/includes/class-kirki-scripts-enqueue-script.php b/includes/plugins/kirki/includes/class-kirki-scripts-enqueue-script.php new file mode 100644 index 0000000..7bf18a3 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-scripts-enqueue-script.php @@ -0,0 +1,60 @@ +is_google_font( $font['font-family'] ) ) { + $has_google_font = true; + } + + } + + // Do we have font-weights? + if ( isset( $font['font-weight'] ) ) { + + $font_weights = ( ! isset( $font_weights ) ) ? array() : $font_weights; + $font_weights[] = $font['font-weight']; + + } + + // Do we have font-subsets? + if ( isset( $font['subsets'] ) ) { + + $font_subsets = ( ! isset( $font_subsets ) ) ? array() : $font_subsets; + $font_subsets[] = $font['subsets']; + + } + + } + + // Make sure there are no empty values and define defaults. + $font_families = ( ! isset( $font_families ) || empty( $font_families ) ) ? false : $font_families; + $font_weights = ( ! isset( $font_weights ) || empty( $font_weights ) ) ? '400' : $font_weights; + $font_subsets = ( ! isset( $font_subsets ) || empty( $font_subsets ) ) ? 'all' : $font_subsets; + + if ( ! isset( $has_google_font ) || ! $has_google_font ) { + $font_families = false; + } + + // Return the font URL. + return ( $font_families ) ? Kirki_Toolkit::fonts()->get_google_font_uri( $font_families, $font_weights, $font_subsets ) : false; + + } + + /** + * Enqueue Google fonts if necessary + */ + public function google_font() { + if ( $this->google_link() ) { + $google_link = str_replace( '%3A', ':', $this->google_link() ); + wp_enqueue_style( 'kirki_google_fonts', $google_link, array(), null ); + } + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-scripts-registry.php b/includes/plugins/kirki/includes/class-kirki-scripts-registry.php new file mode 100644 index 0000000..1f444f9 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-scripts-registry.php @@ -0,0 +1,48 @@ +dependencies = new Kirki_Scripts_Customizer_Default_Scripts(); + $this->branding = new Kirki_Scripts_Customizer_Branding(); + $this->postmessage = new Kirki_Scripts_Customizer_PostMessage(); + $this->tooltips = new Kirki_Scripts_Customizer_Tooltips(); + $this->googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + + } + + /** + * @param string $script + */ + public static function prepare( $script ) { + return ''; + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-styles-customizer.php b/includes/plugins/kirki/includes/class-kirki-styles-customizer.php new file mode 100644 index 0000000..3939abb --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-styles-customizer.php @@ -0,0 +1,182 @@ +custom_css() ); + } + + /** + * Add custom CSS rules to the head, applying our custom styles + */ + public function custom_css() { + + $color = $this->get_admin_colors(); + $config = apply_filters( 'kirki/config', array() ); + + // Calculate the accent color + $color_accent = ( isset( $color['icon_colors'] ) && isset( $color['icon_colos']['focus'] ) ) ? $color['icon_colors']['focus'] : '#3498DB'; + if ( isset( $config['color_accent'] ) ) { + $color_accent = Kirki_Color::sanitize_hex( $config['color_accent'] ); + } + + // Calculate the background & font colors + $color_back = false; + $color_font = false; + if ( isset( $config['color_back'] ) ) { + $color_back = Kirki_Color::sanitize_hex( $config['color_back'] ); + $color_font = ( 170 > Kirki_Color::get_brightness( $color_back ) ) ? '#f2f2f2' : '#222'; + } + + $styles = ''; + + // Width + if ( isset( $config['width'] ) ) { + $styles .= '.wp-full-overlay-sidebar{width:'.esc_attr( $config['width'] ).';}'; + $styles .= '.wp-full-overlay.expanded{margin-left:'.esc_attr( $config['width'] ).';}'; + } + + if ( false !== $color_back && false !== $color_font ) { + + // Generic background color + $styles .= '.wp-full-overlay-sidebar{background:'.$color_back.';}'; + + // Title background color + $styles .= '#customize-controls .customize-info .accordion-section-title, #customize-controls .panel-meta.customize-info .accordion-section-title:hover{background:'.$color_back.';}'; + + // Borders + $border_color = ( 170 > Kirki_Color::get_brightness( $color_back ) ) ? 'rgba(255,255,255,.2)' : 'rgba(0,0,0,.2)'; + $styles .= '#customize-controls .customize-info{border-top-color:'.$border_color.';border-bottom-color:'.$border_color.';}'; + $styles .= '.customize-section-title{border-bottom-color:'.$border_color.';}'; + $styles .= '.customize-panel-back, .customize-section-back{border-right-color:'.$border_color.';}'; + $styles .= '#customize-header-actions{border-bottom-color:'.$border_color.';}'; + $styles .= '.customize-controls-close, .customize-overlay-close{border-right-color:'.$border_color.'!important;}'; + + // back & close buttons color + if ( 170 > Kirki_Color::get_brightness( $color_back ) ) { + $color = Kirki_Color::adjust_brightness( $color_back, 80 ); + } else { + $color = Kirki_Color::adjust_brightness( $color_back, -80 ); + } + $styles .= '.customize-panel-back:focus, .customize-panel-back:hover, .customize-section-back:focus, .customize-section-back:hover, .customize-panel-back, .customize-section-back, .customize-controls-close, .customize-overlay-close{background:'.$color.';}'; + $styles .= '.control-panel-back:focus, .control-panel-back:hover, .customize-controls-close:focus, .customize-controls-close:hover, .customize-controls-preview-toggle:focus, .customize-controls-preview-toggle:hover, .customize-overlay-close:focus, .customize-overlay-close:hover{background:'.$color.'}'; + + // Sections list titles + $styles .= '#customize-theme-controls .accordion-section-title{background:'.$color_back.';color:'.$color_font.';}'; + $color = ( ( 170 > Kirki_Color::get_brightness( $color_accent ) ) ) ? 'color:#ffffff;' : ''; + $styles .= '#customize-controls .control-section .accordion-section-title:focus, #customize-controls .control-section .accordion-section-title:hover, #customize-controls .control-section.open .accordion-section-title, #customize-controls .control-section:hover>.accordion-section-title{background:'.$color_accent.';'.$color.'}'; + + // Arrows + if ( 170 > Kirki_Color::get_brightness( $color_back ) ) { + $color = Kirki_Color::adjust_brightness( $color_back, 120 ); + } else { + $color = Kirki_Color::adjust_brightness( $color_back, -120 ); + } + $styles .= '.accordion-section-title:after, .handlediv, .item-edit, .sidebar-name-arrow, .widget-action{color:'.$color.'}'; + if ( 170 > Kirki_Color::get_brightness( $color_accent ) ) { + $color = Kirki_Color::adjust_brightness( $color_accent, 120 ); + } else { + $color = Kirki_Color::adjust_brightness( $color_accent, -120 ); + } + $styles .= '#customize-theme-controls .control-section .accordion-section-title:focus:after, #customize-theme-controls .control-section .accordion-section-title:hover:after, #customize-theme-controls .control-section.open .accordion-section-title:after, #customize-theme-controls .control-section:hover>.accordion-section-title:after{color:'.$color.'}'; + + // Title for active section + $styles .= '.customize-section-title{background:'.$color_back.';}'; + $styles .= '.customize-section-title h3, h3.customize-section-title{color:'.$color_font.';}'; + + // Active section background + $styles .= '#customize-theme-controls .accordion-section-content{background:'.Kirki_Color::mix_colors( $color_back, '#ffffff', 10 ).';}'; + + // Title color for active panels etc. + $styles .= '#customize-controls .customize-info .preview-notice{color:'.$color_font.';}'; + + } + + // Button styles + $color = ( ( 170 > Kirki_Color::get_brightness( $color_accent ) ) ) ? '#fff' : '#222'; + $styles .= '.wp-core-ui .button-primary-disabled, .wp-core-ui .button-primary.disabled, .wp-core-ui .button-primary:disabled, .wp-core-ui .button-primary[disabled]{background:'.$color_accent.' !important;color:'.$color.' !important;border-color:rgba(0,0,0,.1) !important;opacity:.7;}'; + $styles .= '.wp-core-ui .button-primary{background-color:'.$color_accent.';color:'.$color.';opacity:1;}'; + + // Tooltip styles + $styles .= '#customize-controls .customize-info .customize-help-toggle{color:'.$color_accent.';}'; + + // Image-Radio styles + $styles .= '.customize-control-radio-image .image.ui-buttonset label.ui-state-active{border:2px solid '.$color_accent.';}'; + + // Buttonset-Radio styles + $color = ( ( 170 > Kirki_Color::get_brightness( $color_accent ) ) ) ? '#fff;' : '#222'; + $styles .= '.customize-control-radio-buttonset label.ui-state-active{background-color:'.$color_accent.';color:'.$color.';}'; + + // Slider Controls + $styles .= '.customize-control-slider .ui-slider .ui-slider-handle{background-color:'.$color_accent.';}'; + + // Switch Controls + $styles .= '.customize-control-switch .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag{background:'.$color_accent.';}'; + + // Toggle Controls + $styles .= '.customize-control-toggle .fs-checkbox-toggle.fs-checkbox-checked .fs-checkbox-flag{background:'.$color_accent.';}'; + + // Sortable Controls + $styles .= '.customize-control-sortable ul.ui-sortable li .dashicons.visibility{color:'.$color_accent.';}'; + + // Palette Controls + $styles .= '.customize-control-palette label.ui-state-active.ui-button.ui-widget span.ui-button-text{border-color:'.$color_accent.';}'; + + return $styles; + + } + + + /** + * Get the admin color theme + */ + public function get_admin_colors() { + + // Get the active admin theme + global $_wp_admin_css_colors; + + // Get the user's admin colors + $color = get_user_option( 'admin_color' ); + // If no theme is active set it to 'fresh' + if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) { + $color = 'fresh'; + } + + $color = (array) $_wp_admin_css_colors[ $color ]; + + return $color; + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-styles-frontend.php b/includes/plugins/kirki/includes/class-kirki-styles-frontend.php new file mode 100644 index 0000000..e2fa7a0 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-styles-frontend.php @@ -0,0 +1,83 @@ +loop_controls() ); + } + + /** + * Add a dummy, empty stylesheet. + */ + public function frontend_styles() { + wp_enqueue_style( 'kirki-styles', trailingslashit( kirki_url() ).'assets/css/kirki-styles.css', null, null ); + + } + + /** + * loop through all fields and create an array of style definitions + */ + public function loop_controls() { + + $fields = Kirki::$fields; + $css = array(); + + // Early exit if no fields are found. + if ( empty( $fields ) ) { + return; + } + + foreach ( $fields as $field ) { + + // Only continue if $field['output'] is set + if ( isset( $field['output'] ) && 'background' != $field['type'] ) { + + $css = array_merge_recursive( $css, Kirki_Output::css( + Kirki_Field::sanitize_settings_raw( $field ), + Kirki_Field::sanitize_type( $field ), + Kirki_Field::sanitize_output( $field ), + isset( $field['output']['callback'] ) ? $field['output']['callback'] : '', + true + ) ); + + } + + } + + return Kirki_Output::styles_parse( Kirki_Output::add_prefixes( $css ) ); + + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki-toolkit.php b/includes/plugins/kirki/includes/class-kirki-toolkit.php new file mode 100644 index 0000000..386c0ef --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki-toolkit.php @@ -0,0 +1,117 @@ + __( 'Background Color', 'kirki' ), + 'background-image' => __( 'Background Image', 'kirki' ), + 'no-repeat' => __( 'No Repeat', 'kirki' ), + 'repeat-all' => __( 'Repeat All', 'kirki' ), + 'repeat-x' => __( 'Repeat Horizontally', 'kirki' ), + 'repeat-y' => __( 'Repeat Vertically', 'kirki' ), + 'inherit' => __( 'Inherit', 'kirki' ), + 'background-repeat' => __( 'Background Repeat', 'kirki' ), + 'cover' => __( 'Cover', 'kirki' ), + 'contain' => __( 'Contain', 'kirki' ), + 'background-size' => __( 'Background Size', 'kirki' ), + 'fixed' => __( 'Fixed', 'kirki' ), + 'scroll' => __( 'Scroll', 'kirki' ), + 'background-attachment' => __( 'Background Attachment', 'kirki' ), + 'left-top' => __( 'Left Top', 'kirki' ), + 'left-center' => __( 'Left Center', 'kirki' ), + 'left-bottom' => __( 'Left Bottom', 'kirki' ), + 'right-top' => __( 'Right Top', 'kirki' ), + 'right-center' => __( 'Right Center', 'kirki' ), + 'right-bottom' => __( 'Right Bottom', 'kirki' ), + 'center-top' => __( 'Center Top', 'kirki' ), + 'center-center' => __( 'Center Center', 'kirki' ), + 'center-bottom' => __( 'Center Bottom', 'kirki' ), + 'background-position' => __( 'Background Position', 'kirki' ), + 'background-opacity' => __( 'Background Opacity', 'kirki' ), + 'ON' => __( 'ON', 'kirki' ), + 'OFF' => __( 'OFF', 'kirki' ), + 'all' => __( 'All', 'kirki' ), + 'cyrillic' => __( 'Cyrillic', 'kirki' ), + 'cyrillic-ext' => __( 'Cyrillic Extended', 'kirki' ), + 'devanagari' => __( 'Devanagari', 'kirki' ), + 'greek' => __( 'Greek', 'kirki' ), + 'greek-ext' => __( 'Greek Extended', 'kirki' ), + 'khmer' => __( 'Khmer', 'kirki' ), + 'latin' => __( 'Latin', 'kirki' ), + 'latin-ext' => __( 'Latin Extended', 'kirki' ), + 'vietnamese' => __( 'Vietnamese', 'kirki' ), + 'serif' => _x( 'Serif', 'font style', 'kirki' ), + 'sans-serif' => _x( 'Sans Serif', 'font style', 'kirki' ), + 'monospace' => _x( 'Monospace', 'font style', 'kirki' ), + ); + + $config = apply_filters( 'kirki/config', array() ); + + if ( isset( $config['i18n'] ) ) { + $i18n = wp_parse_args( $config['i18n'], $i18n ); + } + + return $i18n; + + } + + /** + * Shortcut method to get the font registry. + */ + public static function fonts() { + return self::get_instance()->font_registry; + } + + /** + * Constructor is private, should only be called by get_instance() + */ + private function __construct() { + } + +} diff --git a/includes/plugins/kirki/includes/class-kirki.php b/includes/plugins/kirki/includes/class-kirki.php new file mode 100644 index 0000000..8454d65 --- /dev/null +++ b/includes/plugins/kirki/includes/class-kirki.php @@ -0,0 +1,410 @@ +fields_from_filters(); + add_action( 'customize_register', array( $this, 'add_panels' ), 97 ); + add_action( 'customize_register', array( $this, 'add_sections' ), 98 ); + add_action( 'customize_register', array( $this, 'add_fields' ), 99 ); + } + + /** + * Process fields added using the 'kirki/fields' and 'kirki/controls' filter. + * These filters are no longer used, this is simply for backwards-compatibility + */ + public function fields_from_filters() { + + $fields = apply_filters( 'kirki/controls', array() ); + $fields = apply_filters( 'kirki/fields', $fields ); + + if ( ! empty( $fields ) ) { + foreach ( $fields as $field ) { + self::add_field( 'global', $field ); + } + } + + } + + /** + * Get the value of an option from the db. + * + * @var string the ID of the configuration corresponding to this field + * @var string the field_id (defined as 'settings' in the field arguments) + * + * @return mixed the saved value of the field. + * + */ + public static function get_option( $config_id = '', $field_id = '' ) { + + $value = ''; + + if ( ( '' == $field_id ) && '' != $config_id ) { + $field_id = $config_id; + $config_id = 'global'; + } + + $config_id = ( '' == $config_id ) ? 'global' : $config_id; + + // Are we using options or theme_mods? + $mode = self::$config[ $config_id ]['option_type']; + // Is there an option name set? + $option_name = false; + if ( 'option' == $mode && isset( self::$config[ $config_id ]['option'] ) ) { + $option_name = self::$config[ $config_id ]['option']; + } + + if ( 'theme_mod' == $mode ) { + + // We're using theme_mods + $value = get_theme_mod( $field_id, self::$fields[ $field_id ]['default'] ); + + } elseif ( 'option' == $mode ) { + + // We're using options + if ( $option_name ) { + + // Options are serialized as a single option in the db + $options = get_option( $option_name ); + $value = ( isset( $options[ $field_id ] ) ) ? $options[ $field_id ] : self::$fields[ $field_id ]['default']; + $value = maybe_unserialize( $value ); + + } else { + + // Each option separately saved in the db + $value = get_option( $field_id, self::$fields[ $field_id ]['default'] ); + + } + + } + + if ( defined( 'KIRKI_REDUX_COMPATIBILITY' ) && KIRKI_REDUX_COMPATIBILITY ) { + + switch ( self::$fields[ $field_id ]['type'] ) { + + case 'image' : + $value = Kirki_Helper::get_image_from_url( $value ); + break; + + } + + } + + return $value; + + } + + /** + * Sets the configuration options. + * + * @var string the configuration ID. + * @var array the configuration options. + */ + public static function add_config( $config_id, $args = array() ) { + + $default_args = array( + 'capability' => 'edit_theme_options', + 'option_type' => 'theme_mod', + 'option' => '', + 'compiler' => array(), + ); + $args = array_merge( $default_args, $args ); + + // Allow empty value as the config ID by setting the id to global. + $config_id = ( '' == $config_id ) ? 'global' : $config_id; + + // Set the config + self::$config[ $config_id ] = $args; + + } + + /** + * register our panels to the WordPress Customizer + * @var object The WordPress Customizer object + */ + public function add_panels( $wp_customize ) { + + if ( ! empty( self::$panels ) ) { + + foreach ( self::$panels as $panel ) { + $wp_customize->add_panel( sanitize_key( $panel['id'] ), array( + 'title' => esc_textarea( $panel['title'] ), + 'priority' => esc_attr( $panel['priority'] ), + 'description' => esc_textarea( $panel['description'] ), + 'active_callback' => $panel['active_callback'], + ) ); + } + + } + } + + /** + * register our sections to the WordPress Customizer + * @var object The WordPress Customizer object + */ + public function add_sections( $wp_customize ) { + + if ( ! empty( self::$sections ) ) { + + foreach ( self::$sections as $section ) { + $wp_customize->add_section( sanitize_key( $section['id'] ), array( + 'title' => esc_textarea( $section['title'] ), + 'priority' => esc_attr( $section['priority'] ), + 'panel' => esc_attr( $section['panel'] ), + 'description' => esc_textarea( $section['description'] ), + 'active_callback' => $section['active_callback'], + ) ); + } + + } + + } + + /** + * Create the settings and controls from the $fields array and register them. + * @var object The WordPress Customizer object + */ + public function add_fields( $wp_customize ) { + + $control_types = apply_filters( 'kirki/control_types', array( + 'color' => 'WP_Customize_Color_Control', + 'color-alpha' => 'Kirki_Controls_Color_Alpha_Control', + 'image' => 'WP_Customize_Image_Control', + 'upload' => 'WP_Customize_Upload_Control', + 'switch' => 'Kirki_Controls_Switch_Control', + 'toggle' => 'Kirki_Controls_Toggle_Control', + 'radio-buttonset' => 'Kirki_Controls_Radio_ButtonSet_Control', + 'radio-image' => 'Kirki_Controls_Radio_Image_Control', + 'sortable' => 'Kirki_Controls_Sortable_Control', + 'slider' => 'Kirki_Controls_Slider_Control', + 'number' => 'Kirki_Controls_Number_Control', + 'multicheck' => 'Kirki_Controls_MultiCheck_Control', + 'palette' => 'Kirki_Controls_Palette_Control', + 'custom' => 'Kirki_Controls_Custom_Control', + 'editor' => 'Kirki_Controls_Editor_Control', + 'select2' => 'Kirki_Controls_Select2_Control', + 'select2-multiple' => 'Kirki_Controls_Select2_Multiple_Control' + ) ); + + foreach ( self::$fields as $field ) { + + if ( 'background' == $field['type'] ) { + continue; + } + + $wp_customize->add_setting( Kirki_Field::sanitize_settings( $field ), array( + 'default' => Kirki_Field::sanitize_default( $field ), + 'type' => Kirki_Field::sanitize_type( $field ), + 'capability' => Kirki_Field::sanitize_capability( $field ), + 'transport' => Kirki_Field::sanitize_transport( $field ), + 'sanitize_callback' => Kirki_Field::sanitize_callback( $field ), + ) ); + + if ( array_key_exists( $field['type'], $control_types ) ) { + + $class_name = $control_types[ $field['type'] ]; + $wp_customize->add_control( new $class_name( + $wp_customize, + Kirki_Field::sanitize_id( $field ), + Kirki_Field::sanitize_field( $field ) + ) ); + + } else { + + $wp_customize->add_control( new WP_Customize_Control( + $wp_customize, + Kirki_Field::sanitize_id( $field ), + Kirki_Field::sanitize_field( $field ) + ) ); + + } + + } + + } + + /** + * Create a new panel + * + * @var string the ID for this panel + * @var array the panel arguments + */ + public static function add_panel( $id = '', $args = array() ) { + + // Add the section to the $fields variable + $args['id'] = esc_attr( $id ); + $args['description'] = ( isset( $args['description'] ) ) ? esc_textarea( $args['description'] ) : ''; + $args['priority'] = ( isset( $args['priority'] ) ) ? esc_attr( $args['priority'] ) : 10; + if ( ! isset( $args['active_callback'] ) ) { + $args['active_callback'] = ( isset( $args['required'] ) ) ? 'kirki_active_callback' : '__return_true'; + } + + self::$panels[$args['id']] = $args; + + } + + /** + * Create a new section + * + * @var string the ID for this section + * @var array the section arguments + */ + public static function add_section( $id, $args ) { + + // Add the section to the $fields variable + $args['id'] = esc_attr( $id ); + $args['panel'] = ( isset( $args['panel'] ) ) ? esc_attr( $args['panel'] ) : ''; + $args['description'] = ( isset( $args['description'] ) ) ? esc_textarea( $args['description'] ) : ''; + $args['priority'] = ( isset( $args['priority'] ) ) ? esc_attr( $args['priority'] ) : 10; + if ( ! isset( $args['active_callback'] ) ) { + $args['active_callback'] = ( isset( $args['required'] ) ) ? 'kirki_active_callback' : '__return_true'; + } + + self::$sections[ $args['id'] ] = $args; + + } + + /** + * Create a new field + * + * @var string the configuration ID for this field + * @var array the field arguments + */ + public static function add_field( $config_id, $args ) { + + if ( is_array( $config_id ) && empty( $args ) ) { + $args = $config_id; + $config_id = 'global'; + } + + $config_id = ( '' == $config_id ) ? 'global' : $config_id; + + // Get the configuration options + $config = self::$config[ $config_id ]; + + /** + * If we've set an option in the configuration + * then make sure we're using options and not theme_mods + */ + if ( '' != $config['option'] ) { + $config['option_type'] = 'option'; + } + + /** + * If no option name has been set for the field, + * use the one from the configuration + */ + if ( ! isset( $args['option'] ) ) { + $args['option'] = $config['option']; + } + + /** + * If no capability has been set for the field, + * use the one from the configuration + */ + if ( ! isset( $args['capability'] ) ) { + $args['capability'] = $config['capability']; + } + + /** + * Check if [settings] is set. + * If not set, check for [setting] + */ + if ( ! isset( $args['settings'] ) && isset( $args['setting'] ) ) { + $args['settings'] = $args['setting']; + } + + /** + * If no option-type has been set for the field, + * use the one from the configuration + */ + if ( ! isset( $args['option_type'] ) ) { + $args['option_type'] = $config['option_type']; + } + + // Add the field to the static $fields variable properly indexed + self::$fields[ Kirki_Field::sanitize_settings( $args ) ] = $args; + + if ( 'background' == $args['type'] ) { + // Build the background fields + self::$fields = Kirki_Explode_Background_Field::process_fields( self::$fields ); + } + + } + + /** + * Build the variables. + * + * @return array ('variable-name' => value) + */ + public function get_variables() { + + $variables = array(); + + foreach ( self::$fields as $field ) { + + if ( isset( $field['variables'] ) && false != $field['variables'] ) { + + foreach ( $field['variables'] as $field_variable ) { + + if ( isset( $field_variable['name'] ) ) { + $variable_name = esc_attr( $field_variable['name'] ); + $variable_callback = ( isset( $field_variable['callback'] ) && is_callable( $field_variable['callback'] ) ) ? $field_variable['callback'] : false; + + if ( $variable_callback ) { + $variables[ $variable_name ] = call_user_func( $field_variable['callback'], self::get_option( Kirki_Field::sanitize_settings( $field ) ) ); + } else { + $variables[ $variable_name ] = self::get_option( $field['settings'] ); + } + + } + + } + + } + + } + + return apply_filters( 'kirki/variable', $variables ); + + } + +} diff --git a/includes/plugins/kirki/includes/deprecated.php b/includes/plugins/kirki/includes/deprecated.php new file mode 100644 index 0000000..e987b06 --- /dev/null +++ b/includes/plugins/kirki/includes/deprecated.php @@ -0,0 +1,205 @@ + isset( $values[$option.'_color'] ) ? $values[$option.'_color'] : null, + 'background-repeat' => isset( $values[$option.'_repeat'] ) ? $values[$option.'_repeat'] : null, + 'background-attachment' => isset( $values[$option.'_attach'] ) ? $values[$option.'_attach'] : null, + 'background-image' => isset( $values[$option.'_image'] ) ? $values[$option.'_image'] : null, + 'background-position' => isset( $values[$option.'_position'] ) ? $values[$option.'_position'] : null, + 'background-clip' => isset( $values[$option.'_clip'] ) ? $values[$option.'_clip'] : null, + 'background-size' => isset( $values[$option.'_size'] ) ? $values[$option.'_size'] : null, + ); + } else { + $value = array( + 'background-color' => isset( $fields[$field_id]['default']['color'] ) ? get_theme_mod( $option.'_color', $fields[$field_id]['default']['color'] ) : null, + 'background-repeat' => isset( $fields[$field_id]['default']['repeat'] ) ? get_theme_mod( $option.'_repeat', $fields[$field_id]['default']['repeat'] ) : null, + 'background-attachment' => isset( $fields[$field_id]['default']['attach'] ) ? get_theme_mod( $option.'_attach', $fields[$field_id]['default']['attach'] ) : null, + 'background-image' => isset( $fields[$field_id]['default']['image'] ) ? get_theme_mod( $option.'_image', $fields[$field_id]['default']['image'] ) : null, + 'background-position' => isset( $fields[$field_id]['default']['position'] ) ? get_theme_mod( $option.'_position', $fields[$field_id]['default']['position'] ) : null, + 'background-clip' => isset( $fields[$field_id]['default']['clip'] ) ? get_theme_mod( $option.'_clip', $fields[$field_id]['default']['clip'] ) : null, + 'background-size' => isset( $fields[$field_id]['default']['size'] ) ? get_theme_mod( $option.'_size', $fields[$field_id]['default']['size'] ) : null, + ); + } + } + + // Return the single value. + // Pass it through maybe_unserialize so we're sure we get a proper value. + return maybe_unserialize( $value ); + + } +} + +if ( ! function_exists( 'kirki_sanitize_hex' ) ) { + function kirki_sanitize_hex( $color ) { + return Kirki_Color::sanitize_hex( $color ); + } +} + +if ( ! function_exists( 'kirki_get_rgb' ) ) { + function kirki_get_rgb( $hex, $implode = false ) { + return Kirki_Color::get_rgb( $hex, $implode ); + } +} + +if ( ! function_exists( 'kirki_get_rgba' ) ) { + function kirki_get_rgba( $hex = '#fff', $opacity = 100 ) { + return Kirki_Color::get_rgba( $hex, $opacity ); + } +} + +if ( ! function_exists( 'kirki_get_brightness' ) ) { + function kirki_get_brightness( $hex ) { + return Kirki_Color::get_brightness( $hex ); + } +} + +if ( ! class_exists( 'Kirki_Fonts' ) ) { + + class Kirki_Fonts { + + public static function get_all_fonts() { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_all_fonts(); + } + + public static function get_font_choices() { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_font_choices(); + } + + public static function is_google_font( $font ) { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->is_google_font( $font ); + } + + public static function get_google_font_uri( $fonts, $weight = 400, $subset = 'all' ) { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_google_font_uri( $fonts, $weight, $subset ); + } + + public static function get_google_font_subsets() { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_google_font_subsets(); + } + + public static function choose_google_font_variants( $font, $variants = array() ) { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->choose_google_font_variants( $font, $variants ); + } + + public static function get_standard_fonts() { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_standard_fonts(); + } + + public static function get_font_stack( $font ) { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_font_stack( $font ); + } + + public static function sanitize_font_choice( $value ) { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->sanitize_font_choice( $value ); + } + + public static function get_google_fonts() { + $font_registry = Kirki_Toolkit::fonts(); + return $font_registry->get_google_fonts(); + } + + } + +} diff --git a/includes/plugins/kirki/includes/functions.php b/includes/plugins/kirki/includes/functions.php new file mode 100644 index 0000000..b2b4f9b --- /dev/null +++ b/includes/plugins/kirki/includes/functions.php @@ -0,0 +1,97 @@ +id ] ) ) { + return true; + } + + $current_object = $fields[ $object->id ]; + + if ( isset( $current_object['required'] ) ) { + + foreach ( $current_object['required'] as $requirement ) { + + if ( ! is_object( $object->manager->get_setting( $fields[ $requirement['setting'] ]['settings'] ) ) ) { + return true; + } + + if ( isset( $show ) && ! $show ) { + return false; + } + + $value = $object->manager->get_setting( $fields[ $requirement['setting'] ]['settings'] )->value(); + switch ( $requirement['operator'] ) { + case '===' : + $show = ( $requirement['value'] === $value ) ? true : false; + break; + case '==' : + $show = ( $requirement['value'] == $value ) ? true : false; + break; + case '!==' : + $show = ( $requirement['value'] !== $value ) ? true : false; + break; + case '!=' : + $show = ( $requirement['value'] != $value ) ? true : false; + break; + case '>=' : + $show = ( $requirement['value'] >= $value ) ? true : false; + break; + case '<=' : + $show = ( $requirement['value'] <= $value ) ? true : false; + break; + case '>' : + $show = ( $requirement['value'] > $value ) ? true : false; + break; + case '<' : + $show = ( $requirement['value'] < $value ) ? true : false; + break; + default : + $show = ( $requirement['value'] == $value ) ? true : false; + + } + + } + + } + + return ( isset( $show ) && ( false === $show ) ) ? false : true; + + } +} diff --git a/includes/plugins/kirki/includes/redux-compatibility.php b/includes/plugins/kirki/includes/redux-compatibility.php new file mode 100644 index 0000000..42fa528 --- /dev/null +++ b/includes/plugins/kirki/includes/redux-compatibility.php @@ -0,0 +1,199 @@ + 'option', + 'option_name' => $args['opt_name'], + ) ); + } + + public static function setSection( $config_id, $args = array() ) { + + if ( ! isset( $args['fields'] ) || ! isset( $args['subsection'] ) || ( isset( $args['subsection'] ) && ! $args['subsection'] ) ) { // This is a panel + Kirki::$panels[] = array( + 'id' => isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( 'abcdefghijklmnopqrstuvwxyz-_' ), 0, 7 ), + 'title' => isset( $args['title'] ) ? $args['title'] : '', + 'priority' => ( isset( $args['priority'] ) ) ? $args['priority'] : 10, + 'description' => ( isset( $args['desc'] ) ) ? $args['desc'] : '', + ); + } else { // This is a section + // Get the section ID + if ( isset( $args['subsection'] ) && $args['subsection'] ) { + $panel = end( array_values( Kirki::$panels ) ); + $panel_id = $panel['id']; + } + + Kirki::$sections[] = array( + 'id' => isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( "abcdefghijklmnopqrstuvwxyz-_" ), 0, 7 ), + 'title' => $args['title'], + 'priority' => ( isset( $args['priority'] ) ) ? $args['priority'] : 10, + 'panel' => ( isset( $panel_id ) ) ? $panel_id : '', + 'description' => ( isset( $args['desc'] ) ) ? $args['desc'] : '', + ); + + foreach ( $args['fields'] as $field ) { + + $field['section'] = isset( $args['id'] ) ? sanitize_key( $args['id'] ) : substr( str_shuffle( "abcdefghijklmnopqrstuvwxyz-_" ), 0, 7 ); + $field['settings'] = $field['id']; + $field['help'] = ( isset( $field['desc'] ) ) ? $field['desc'] : ''; + $field['description'] = ( isset( $field['subtitle'] ) ) ? $field['subtitle'] : ''; + $field['choices'] = ( isset( $field['options'] ) ) ? $field['options'] : ''; + $field['label'] = ( isset( $field['title'] ) ) ? $field['title'] : ''; + + switch ( $field['type'] ) { + + case 'ace_editor' : + $field['type'] = 'textarea'; + break; + case 'button_set' : + $field['type'] = 'radio-buttonset'; + break; + case 'checkbox' : + if ( isset( $field['options'] ) && is_array( $field['options'] ) ) { + $field['type'] = 'multicheck'; + } + case 'color_rgba' : + $field['type'] = 'color-alpha'; + if ( isset( $field['default'] ) && is_array( $field['default'] ) ) { + $field['default']['color'] = isset( $field['default']['color'] ) ? Kirki_Color::sanitize_hex( $field['default']['color'], true ) : '#ffffff'; + $field['default']['alpha'] = isset( $field['default']['alpha'] ) ? $field['default']['alpha'] : '1'; + $field['default'] = Kirki_Color::get_rgba( $field['default']['color'], $field['default']['alpha'] ); + } + break; + case 'image_select' : + $field['type'] = 'radio-image'; + break; + case 'info' : + $fiel['label'] = ''; + $field['help'] = ''; + $field['type'] = 'custom'; + $background_color = '#fcf8e3'; + $border_color = '#faebcc'; + $text_color = '#8a6d3b'; + if ( isset( $field['style'] ) ) { + if ( 'success' == $field['style'] ) { + $background_color = '#dff0d8'; + $border_color = '#d6e9c6'; + $text_color = '#3c763d'; + } elseif ( 'critical' == $field['style'] ) { + $background_color = '#f2dede'; + $border_color = '#ebccd1'; + $text_color = '#a94442'; + } + } + $field['default'] = '
      '; + $field['default'] .= ( isset( $field['title'] ) ) ? '

      '.$field['title'].'

      ' : ''; + $field['default'] .= ( isset( $field['desc'] ) ) ? $field['desc'] : ''; + $field['default'] .= '
      '; + break; + case 'palette' : + $field['choices'] = $field['palettes']; + break; + case 'raw' : + $field['default'] = $field['content']; + break; + case 'select' : + if ( is_array( $field['choices'] ) ) { + foreach ( $field['choices'] as $key => $value ) { + if ( is_array( $value ) ) { + foreach ( $value as $child_key => $child_value ) { + $field['choices'][$child_key] = $child_value; + } + unset( $field['choices'][$key] ); + } + } + } + break; + case 'slider' : + $field['choices'] = array( + 'min' => $field['min'], + 'max' => $field['max'], + 'step' => $field['step'], + ); + break; + case 'spinner' : + $field['type'] = 'number'; + break; + case 'background' : + case 'border' : + case 'color_gradient' : + case 'date' : + case 'dimensions' : + case 'divide' : + case 'gallery' : + case 'import_export' : + case 'link_color' : + case 'media' : + case 'multi_text' : + case 'password' : + case 'section' : + case 'select_image' : + case 'sortable' : + case 'sorter' : + case 'spacing' : + case 'spinner' : + case 'switch' : + case 'typography' : + case 'slides' : + // TODO + break; + + } + + Kirki::add_field( $config_id, $field ); + + } + + } + + } + + public static function setHelpTab() {} + + public static function setHelpSidebar() {} + + /** + * Helper function that adds the fields, sections and panels to the customizer. + */ + public function add_to_customizer( $wp_customize ) { + add_filter( 'kirki/fields', array( $this, 'merge_fields' ) ); + add_action( 'customize_register', array( $this, 'add_panels' ), 998 ); + add_action( 'customize_register', array( $this, 'add_sections' ), 999 ); + } + +} diff --git a/includes/plugins/kirki/kirki-user-tests.php b/includes/plugins/kirki/kirki-user-tests.php new file mode 100644 index 0000000..0db941a --- /dev/null +++ b/includes/plugins/kirki/kirki-user-tests.php @@ -0,0 +1,153 @@ +field = $field_args; + $this->create_section(); + $this->add_fields_via_api(); + + add_filter( 'kirki/fields', array( $this, 'add_filter_fields' ) ); + + } + + /** + * Create the Section + */ + public function create_section() { + Kirki::add_section( sanitize_key( $this->field['type'] ), array( + 'priority' => 10, + 'title' => sprintf( __( '%s test', 'kirki' ), $this->field['type'] ), + ) ); + } + + /** + * Add the field using the + */ + public function add_filter_fields( $fields ) { + + $args = $this->field; + $args['section'] = sanitize_key( $this->field['type'] ); + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_0'; + $args['label'] = sprintf( __( '%s theme_mod via filter', 'kirki' ), $args['type'] ); + $args['options_type'] = 'theme_mod'; + $fields[] = $args; + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_1'; + $args['label'] = sprintf( __( '%s single option via filter', 'kirki' ), $args['type'] ); + $args['options_type'] = 'option'; + $fields[] = $args; + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_2'; + $args['options_type'] = 'option'; + $args['label'] = sprintf( __( '%s serialized option via filter', 'kirki' ), $args['type'] ); + $args['option_name'] = 'kirki_test'; + $fields[] = $args; + + return $fields; + + } + + /** + * Add fields using the Kirki API + */ + public function add_fields_via_api() { + + $args = $this->field; + $args['section'] = sanitize_key( $this->field['type'] ); + $args['capability'] = 'read'; + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_3'; + $args['label'] = sprintf( __( '%s theme_mod via API', 'kirki' ), $args['type'] ); + $args['options_type'] = 'theme_mod'; + Kirki::add_field( '', $args ); + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_4'; + $args['label'] = sprintf( __( '%s single option via API', 'kirki' ), $args['type'] ); + $args['options_type'] = 'option'; + Kirki::add_field( '', $args ); + + $args['settings'] = sanitize_key( $this->field['type'] ).'_demo_5'; + $args['options_type'] = 'option'; + $args['label'] = sprintf( __( '%s serialized option via API', 'kirki' ), $args['type'] ); + $args['option_name'] = 'kirki_test'; + Kirki::add_field( '', $args ); + + } + +} + +// checkbox +$checkbox = new Kirki_Test_Field( array( 'type' => 'checkbox', 'default' => 1 ) ); + +// color-alpha +$color_alpha = new Kirki_Test_Field( array( 'type' => 'color-alpha', 'default' => 'rgba(255,0,0,.75)', 'output' => array( 'element' => 'body a', 'property' => 'color' ) ) ); + +// color +$color = new Kirki_Test_Field( array( 'type' => 'color', 'default' => '#0000ff', 'output' => array( 'element' => 'a:hover', 'property' => 'color' ) ) ); + +// custom +$custom = new Kirki_Test_Field( array( 'type' => 'custom', 'default' => '

      Custom Control Test

      ' ) ); + +// dropdown-pages +$dropdown_pages = new Kirki_Test_Field( array( 'type' => 'dropdown-pages', 'default' => 1 ) ); + +// editor +$editor = new Kirki_Test_Field( array( 'type' => 'editor', 'default' => 'This is the standard TinyMCE editor.' ) ); + +// image +$image = new Kirki_Test_Field( array( 'type' => 'image', 'default' => '' ) ); + +// multicheck +$multicheck = new Kirki_Test_Field( array( 'type' => 'multicheck', 'default' => array( 'option1' ), 'choices' => array( 'option1' => __( 'Option 1', 'kirki' ), 'option2' => __( 'Option 2', 'kirki' ), 'option3' => __( 'Option 3', 'kirki' ) ) ) ); + +// number +$number = new Kirki_Test_Field( array( 'type' => 'number', 'default' => '99' ) ); + +// palette +$palette = new Kirki_Test_Field( array( 'type' => 'palette', 'default' => 'red', 'choices' => array( 'red' => array( '#F9BAAF', '#FB9D8C', '#FD8069' ), 'green' => array( '#C9F7C4', '#B3F9AC', '#9DFA94' ), 'blue' => array( '#D9E3F6', '#CCDAF7', '#BED1F8' ) ) ) ); + +// radio-buttonset +$radio_buttonset = new Kirki_Test_Field( array( 'type' => 'radio-buttonset', 'default' => 'option2', 'choices' => array( 'option1' => __( 'Option 1', 'kirki' ), 'option2' => __( 'Option 2', 'kirki' ), 'option-3' => __( 'Option 3', 'kirki' ) ) ) ); + +// radio-image +$radio_image = new Kirki_Test_Field( array( 'type' => 'radio-image', 'default' => 'option3', 'choices' => array( 'option1' => admin_url().'/images/align-left-2x.png', 'option2' => admin_url().'/images/align-center-2x.png', 'option3' => admin_url().'/images/align-right-2x.png' ) ) ); + +// radio +$radio = new Kirki_Test_Field( array( 'type' => 'radio', 'default' => 'option1', 'choices' => array( 'option1' => __( 'Option 1', 'kirki' ), 'option2' => __( 'Option 2', 'kirki' ), 'option3' => __( 'Option 3', 'kirki' ) ) ) ); + +// select +$select = new Kirki_Test_Field( array( 'type' => 'select', 'default' => 'option2', 'choices' => array( 'option1' => __( 'Option 1', 'kirki' ), 'option2' => __( 'Option 2', 'kirki' ), 'option3' => __( 'Option 3', 'kirki' ) ) ) ); + +// slider +$slider = new Kirki_Test_Field( array( 'type' => 'slider', 'default' => 0, 'choices' => array( 'min' => -100, 'max' => 100, 'step' => 1 ) ) ); + +// sortable +$sortable = new Kirki_Test_Field( array( 'type' => 'sortable', 'default' => array( 'option2', 'option1' ), 'choices' => array( 'option1' => __( 'Option 1', 'kirki' ), 'option2' => __( 'Option 2', 'kirki' ), 'option3' => __( 'Option 3', 'kirki' ), 'option4' => __( 'Option 4', 'kirki' ) ) ) ); + +// switch +$switch = new Kirki_Test_Field( array( 'type' => 'switch', 'default' => '1' ) ); + +// text +$text = new Kirki_Test_Field( array( 'type' => 'text', 'default' => __( 'This is some default text for the text control.', 'kirki' ) ) ); + +// textarea +$textarea = new Kirki_Test_Field( array( 'type' => 'textarea', 'default' => __( 'This is some default text for the textarea control.', 'kirki' ) ) ); + +// toggle +$toggle = new Kirki_Test_Field( array( 'type' => 'toggle', 'default' => '1' ) ); + +// upload +$upload = new Kirki_Test_Field( array( 'type' => 'upload', 'default' => '' ) ); diff --git a/includes/plugins/kirki/kirki.php b/includes/plugins/kirki/kirki.php old mode 100755 new mode 100644 index 3ef90cb..19da965 --- a/includes/plugins/kirki/kirki.php +++ b/includes/plugins/kirki/kirki.php @@ -1,30 +1,128 @@ font_registry = new Kirki_Fonts_Font_Registry(); + $kirki->scripts = new Kirki_Scripts_Registry(); + $kirki->api = new Kirki(); + $kirki->styles = array( + 'back' => new Kirki_Styles_Customizer(), + 'front' => new Kirki_Styles_Frontend(), + ); + + + return $kirki; + + } + + global $kirki; + $kirki = Kirki(); +} + +if ( defined( 'KIRKI_REDUX_COMPATIBILITY' ) && KIRKI_REDUX_COMPATIBILITY ) { + include_once( KIRKI_PATH.'/includes/redux-compatibility.php' ); +} + +if ( ! function_exists( 'kirki_load_textdomain' ) ) { + /** + * Load plugin textdomain. + * + * @since 0.8.0 + */ + function kirki_load_textdomain() { + $textdomain = 'kirki'; + + // Look for WP_LANG_DIR/{$domain}-{$locale}.mo + if ( file_exists( WP_LANG_DIR.'/'.$textdomain.'-'.get_locale().'.mo' ) ) { + $file = WP_LANG_DIR.'/'.$textdomain.'-'.get_locale().'.mo'; + } + // Look for KIRKI_PATH/languages/{$domain}-{$locale}.mo + if ( ! isset( $file ) && file_exists( KIRKI_PATH.'/languages/'.$textdomain.'-'.get_locale().'.mo' ) ) { + $file = KIRKI_PATH.'/languages/'.$textdomain.'-'.get_locale().'.mo'; + } + + if ( isset( $file ) ) { + load_textdomain( $textdomain, $file ); + } + + load_plugin_textdomain( $textdomain, false, KIRKI_PATH.'/languages' ); + } + add_action( 'plugins_loaded', 'kirki_load_textdomain' ); +} -// Include the main kirki class -include_once( KIRKI_PATH . '/includes/Kirki.php' ); +// Add an empty config for global fields +Kirki::add_config( '' ); -// Make sure the class is instanciated -Kirki::get_instance(); +/** + * The 2 following commented-out lines are for testing purposes. + * You can uncomment whichever you want and fields will flood the customizer. + */ +// include_once( KIRKI_PATH . '/sample-config.php' ); +// include_once( KIRKI_PATH . '/kirki-user-tests.php' ); diff --git a/includes/plugins/kirki/languages/kirki-en_US.mo b/includes/plugins/kirki/languages/kirki-en_US.mo index 38e27e7..6fb6395 100644 Binary files a/includes/plugins/kirki/languages/kirki-en_US.mo and b/includes/plugins/kirki/languages/kirki-en_US.mo differ diff --git a/includes/plugins/kirki/languages/kirki-en_US.po b/includes/plugins/kirki/languages/kirki-en_US.po index 00e3111..7c33210 100644 --- a/includes/plugins/kirki/languages/kirki-en_US.po +++ b/includes/plugins/kirki/languages/kirki-en_US.po @@ -1,15 +1,15 @@ msgid "" msgstr "" "Project-Id-Version: Kirki Framework\n" -"POT-Creation-Date: 2015-03-30 01:57+0200\n" -"PO-Revision-Date: 2015-03-30 01:57+0200\n" +"POT-Creation-Date: 2015-04-24 16:51+0200\n" +"PO-Revision-Date: 2015-04-24 16:52+0200\n" "Last-Translator: Stathopoulos Aristeides \n" "Language-Team: Stathopoulos Aristeides \n" "Language: en_US\n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Generator: Poedit 1.7.5\n" +"X-Generator: Poedit 1.8beta1\n" "X-Poedit-Basepath: ..\n" "X-Poedit-SourceCharset: UTF-8\n" "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;" @@ -19,167 +19,170 @@ msgstr "" "X-Poedit-SearchPath-0: .\n" "X-Poedit-SearchPathExcluded-0: *.js\n" -#: includes/Control.php:179 +#: includes/class-kirki-config.php:43 +#, php-format +msgid "Configuration key %s is mandatory and has not been specified" +msgstr "Configuration key %s is mandatory and has not been specified" + +#: includes/class-kirki-config.php:107 msgid "Background Color" msgstr "Background Color" -#: includes/Control.php:192 +#: includes/class-kirki-config.php:108 msgid "Background Image" msgstr "Background Image" -#: includes/Control.php:206 includes/Helpers/sanitize.php:45 +#: includes/class-kirki-config.php:109 msgid "No Repeat" msgstr "No Repeat" -#: includes/Control.php:207 includes/Helpers/sanitize.php:46 +#: includes/class-kirki-config.php:110 msgid "Repeat All" msgstr "Repeat All" -#: includes/Control.php:208 includes/Helpers/sanitize.php:47 +#: includes/class-kirki-config.php:111 msgid "Repeat Horizontally" msgstr "Repeat Horizontally" -#: includes/Control.php:209 includes/Helpers/sanitize.php:48 +#: includes/class-kirki-config.php:112 msgid "Repeat Vertically" msgstr "Repeat Vertically" -#: includes/Control.php:210 includes/Control.php:227 -#: includes/Control.php:247 includes/Helpers/sanitize.php:49 -#: includes/Helpers/sanitize.php:63 includes/Helpers/sanitize.php:79 +#: includes/class-kirki-config.php:113 msgid "Inherit" msgstr "Inherit" -#: includes/Control.php:213 +#: includes/class-kirki-config.php:114 msgid "Background Repeat" msgstr "Background Repeat" -#: includes/Control.php:228 includes/Helpers/sanitize.php:64 +#: includes/class-kirki-config.php:115 msgid "Cover" msgstr "Cover" -#: includes/Control.php:229 includes/Helpers/sanitize.php:65 +#: includes/class-kirki-config.php:116 msgid "Contain" msgstr "Contain" -#: includes/Control.php:233 +#: includes/class-kirki-config.php:117 msgid "Background Size" msgstr "Background Size" -#: includes/Control.php:248 includes/Helpers/sanitize.php:80 +#: includes/class-kirki-config.php:118 msgid "Fixed" msgstr "Fixed" -#: includes/Control.php:249 includes/Helpers/sanitize.php:81 +#: includes/class-kirki-config.php:119 msgid "Scroll" msgstr "Scroll" -#: includes/Control.php:253 +#: includes/class-kirki-config.php:120 msgid "Background Attachment" msgstr "Background Attachment" -#: includes/Control.php:267 includes/Helpers/sanitize.php:95 +#: includes/class-kirki-config.php:121 msgid "Left Top" msgstr "Left Top" -#: includes/Control.php:268 includes/Helpers/sanitize.php:96 +#: includes/class-kirki-config.php:122 msgid "Left Center" msgstr "Left Center" -#: includes/Control.php:269 includes/Helpers/sanitize.php:97 +#: includes/class-kirki-config.php:123 msgid "Left Bottom" msgstr "Left Bottom" -#: includes/Control.php:270 includes/Helpers/sanitize.php:98 +#: includes/class-kirki-config.php:124 msgid "Right Top" msgstr "Right Top" -#: includes/Control.php:271 includes/Helpers/sanitize.php:99 +#: includes/class-kirki-config.php:125 msgid "Right Center" msgstr "Right Center" -#: includes/Control.php:272 includes/Helpers/sanitize.php:100 +#: includes/class-kirki-config.php:126 msgid "Right Bottom" msgstr "Right Bottom" -#: includes/Control.php:273 includes/Helpers/sanitize.php:101 +#: includes/class-kirki-config.php:127 msgid "Center Top" msgstr "Center Top" -#: includes/Control.php:274 includes/Helpers/sanitize.php:102 +#: includes/class-kirki-config.php:128 msgid "Center Center" msgstr "Center Center" -#: includes/Control.php:275 includes/Helpers/sanitize.php:103 +#: includes/class-kirki-config.php:129 msgid "Center Bottom" msgstr "Center Bottom" -#: includes/Control.php:278 +#: includes/class-kirki-config.php:130 msgid "Background Position" msgstr "Background Position" -#: includes/Control.php:296 +#: includes/class-kirki-config.php:131 msgid "Background Opacity" msgstr "Background Opacity" -#: includes/Controls/SwitchControl.php:26 +#: includes/class-kirki-config.php:132 msgid "ON" msgstr "ON" -#: includes/Controls/SwitchControl.php:27 +#: includes/class-kirki-config.php:133 msgid "OFF" msgstr "OFF" -#: includes/Fonts/FontRegistry.php:125 +#: includes/class-kirki-config.php:134 msgid "All" msgstr "All" -#: includes/Fonts/FontRegistry.php:126 +#: includes/class-kirki-config.php:135 msgid "Cyrillic" msgstr "Cyrillic" -#: includes/Fonts/FontRegistry.php:127 +#: includes/class-kirki-config.php:136 msgid "Cyrillic Extended" msgstr "Cyrillic Extended" -#: includes/Fonts/FontRegistry.php:128 +#: includes/class-kirki-config.php:137 msgid "Devanagari" msgstr "Devanagari" -#: includes/Fonts/FontRegistry.php:129 +#: includes/class-kirki-config.php:138 msgid "Greek" msgstr "Greek" -#: includes/Fonts/FontRegistry.php:130 +#: includes/class-kirki-config.php:139 msgid "Greek Extended" msgstr "Greek Extended" -#: includes/Fonts/FontRegistry.php:131 +#: includes/class-kirki-config.php:140 msgid "Khmer" msgstr "Khmer" -#: includes/Fonts/FontRegistry.php:132 +#: includes/class-kirki-config.php:141 msgid "Latin" msgstr "Latin" -#: includes/Fonts/FontRegistry.php:133 +#: includes/class-kirki-config.php:142 msgid "Latin Extended" msgstr "Latin Extended" -#: includes/Fonts/FontRegistry.php:134 +#: includes/class-kirki-config.php:143 msgid "Vietnamese" msgstr "Vietnamese" -#: includes/Fonts/FontRegistry.php:187 +#: includes/class-kirki-config.php:144 msgctxt "font style" msgid "Serif" msgstr "Serif" -#: includes/Fonts/FontRegistry.php:191 +#: includes/class-kirki-config.php:145 msgctxt "font style" msgid "Sans Serif" msgstr "Sans Serif" -#: includes/Fonts/FontRegistry.php:195 +#: includes/class-kirki-config.php:146 msgctxt "font style" -msgid "Monospaced" -msgstr "Monospaced" +msgid "Monospace" +msgstr "Monospace" diff --git a/includes/plugins/kirki/package.json b/includes/plugins/kirki/package.json new file mode 100644 index 0000000..c69afdb --- /dev/null +++ b/includes/plugins/kirki/package.json @@ -0,0 +1,24 @@ +{ + "name": "kirki-toolkit", + "version": "1.0.0-beta1", + "author": "Aristeides Stathopoulos", + "homepage": "http://kirki.org", + "repository": { + "type": "git", + "url": "https://github.com/reduxframework/kirki" + }, + "bugs": { + "url" : "https://github.com/reduxframework/kirki/issues" + }, + "licenses": [{ + "type": "GPL v2", + "url": "http://www.gnu.org/licenses/gpl-2.0.html" + }], + "engines": { + "node": ">= 0.10.0" + }, + "devDependencies": { + "grunt": "~0.4.1", + "grunt-contrib-sass": "~0.9.0" + } +} diff --git a/includes/plugins/kirki/phpunit.xml b/includes/plugins/kirki/phpunit.xml new file mode 100644 index 0000000..8916b3a --- /dev/null +++ b/includes/plugins/kirki/phpunit.xml @@ -0,0 +1,18 @@ + + + + ./tests/ + + + + + + + diff --git a/includes/plugins/kirki/readme.txt b/includes/plugins/kirki/readme.txt old mode 100755 new mode 100644 index c7aac1d..a1a9839 --- a/includes/plugins/kirki/readme.txt +++ b/includes/plugins/kirki/readme.txt @@ -1,243 +1,284 @@ -=== Kirki === -Contributors: aristath, fovoc -Tags: customizer, options famework, theme mods -Donate link: http://kirki.org/ -Requires at least: 4.0 -Tested up to: 4.2 -Stable tag: 0.8.4 -License: GPLv2 or later -License URI: http://www.gnu.org/licenses/gpl-2.0.html - -Tired of all the bloated options frameworks? You can use the WordPress Customizer instead, and extend it using Kirki! - - -== Description == -Kirki allows developers to add advanced controls to their customizer as well as customize the way the customizer looks and feels. - -You can add beautiful options to your theme\'s customizer panel and allow your users to tweak any aspect of their theme. You\'ve got 18 control types that you can use ( 9 default + 9 custom-made ), styling options for the customizer, as well as automatic calculations for your styles using the `output` argument on your controls. - -Converting from the default customizer to the syntax used by Kirki will only take a few minutes and will save you a lot of time in the long run. :) - -**CAUTION**: This plugin requires PHP 5.3 and is not compatible with PHP 5.2 - -The following controls are included: - -* Radio-Buttonset -* Radio-Image -* Radio -* Checkbox -* Color -* Color-Alpha -* Dropdown Pages -* Image -* Background -* Multicheck -* Select -* Slider -* Text -* Textarea -* Upload -* Switch -* Toggle -* Sortable -* Number -* Palette -* Editor (TinyMCE) - -For documentation and examples on how to use these controls, please visit [kirki.org](http://kirki.org/#fields). - - -== Installation == - -**Method 1: Use as a plugin** -From your dashboard go to Plugins => Add New. -Search for "Kirki" and install it. -Once you install it, activate it. -For configuration instructions please visit http://kirki.org/#configuration - -**Method 2: Embed in your theme** -Please visit http://kirki.org for documentation and instructions. - -== Changelog == - -= 0.8.4 = - -April 6, 2014, dev time: 0.5 hours - -* Fix: Color sanitization was distorting 0 characters in the color hex. -* Fix: Properly sanitizing ColorAlpha controls -* Fix: Sanitizing more properties in the Fields class -* Fix: removing remnant double-sanitization calls from the controls classes - -= 0.8.3 = - -April 5, 2014, dev time: 28 hours - -* New: Introduce a Field class -* New: Introduce a Builder class -* Tweak: Code Cleanups -* New: Added ability to use 'option' as the setting type -* Fix : Bugs in the color calculation class -* Tweak: Everything gets sanitized in the "Field" class -* Fix: Bugs in sortable field -* Fix: Editor control had no description -* New: Added a color-alpha control. To use it just set an rgba color as the default value. -* Tweak: SCSS & CSS improvements -* Fix: Various PHP notices and warnings when no fields are defined -* Tweak: More efficient color sanitization method -* Tweak: Improved number control presentation -* Tweak: Improved the way background fields are handled -* Tweak: Checkboxes styling -* New: Allow using rgba values for background colors -* Fix: CSS fix - :focus color for active section -* New: Add a static 'prepare' method to the ScriptRegistry class -* Fix: Issues with the URL when Kirki is embedded in a theme - -= 0.8.2 = - -March 30, 2015, dev time: 5 minutes - -* Fix: Autoloader could not properly include files due to strtolower() - -= 0.8.1 = - -March 30, 2015, dev time: 30 minutes - -* Fix: Translation strings now overridable using the config filter. - -= 0.8.0 = - -March 30, 2015, dev time: 32 hours - -* Improvement: OOP redesign (props @vpratfr) -* New: Added Palette control -* New: Added Editor control (WYSIWYG - uses TinyMCE) -* New: Added Custom control (free html) -* New: Added a Kirki_Colourlovers class to use palettes from the colourlovers API -* New: Added a composer file (props @vpratfr) -* Fix: Wrong settings IDs -* Fix: Color calculation on RGBA functions were off -* Tweak: Restructuring the plugin (props @vpratfr) -* New: added a functional kirki_get_option() function -* Tweak: Simplified configuration options. -* New: Turn Kirki into a singleton and a facade (props @vpratfr) -* Tweak: Completely re-written the customizer styles -* New: Using SASS for customizer styles -* Tweak: Deprecating the group_title control in favor of the new custom control -* Tweak: Changed the CSS for checkboxes - -= 0.7.1 = - -March 15, 2015, dev time: 2 hours - -* Removed: Remove the `kirki_get_option` function that was introduced in 0.7 as it's not working properly yet. -* Fix: Undefined index notice when a default value for the control was not defined -* Tweak: `logo_image` now injects an `img` element instead of a `div` with custom background -* New: Added `description` argument in the kirki configuration (replaces the theme description) - -= 0.7 = - -March 14, 2015, dev time: 10 hours - -* Fix: Array to string conversion that happened conditionally when used with googlefonts. (props @groucho75) -* Fix: Background opacity affects background-position of bg image -* Fix: font-weight not being applied on google fonts -* New: Added `kirki_get_option( $setting );` function that also gets default values -* Tweak: Singleton for main plugin class -* Fix: Prevent empty help tooltips -* New: Added `toggle` control -* New: Added `switch` control -* Fix: Color controls were not being reset to default: -* Tweak: Tooltips now loaded via jQuery -* Tweak: Renamed `setting` to settings for consistency with WordPress core -* Tweak: Renamed `description` to `help` and `subtitle` to `description for consistency with WordPress core -* Tweak: Backwards-compatibility improvements -* New: Allow hiding background control elements by not including default values for them -* Tweak: Performance improvements -* Tweak: Using WordPress core controls instead of custom ones when those are available -* Tweak: Separate logic for multiple-type controls that were using the "mode" argument. This has been deprecated in favor of completely separate control types. - -= 0.6.2 = - -March 2, 2015, dev time: 3 hours - -* Fix: Frontend styles were not properly enqueued (props @dmgawel) -* New: Allow multiple output styles per control defined as an array of arrays. -* Fix: Background control styles -* Fix: Serialise default values for the sortable control. Now you can define default values as an array. -* Fix: Required script -* Fix: \'_opacity\' was added to a lot of controls by mistake. Removed it and wrote a migration script. - -= 0.6.1 = - -February 25, 2015, dev time: 1 hours - -* Fix: Sortables controls had a JS conflict -* Fix: Switches & Toggles were not properly working - -= 0.6.0 = - -February 25, 2015, dev time: 9 hours - -* Fix: Tooltips now properly working -* New: Added checkbox switches -* New: Added checkbox toggles -* Fix: Generated CSS is not properly combined & minified -* Fix: Re-structuring files hierarchy -* Fix: Simplify the way controls are loaded -* New: Only load control classes when they are needed -* New: Introducing Kirki_Customize_Control class -* Fix: CSS tweaks -* New: Sortable control (creating one is identical to a select control, but with `\'type\' => \'sortable\'`) -* Fix: Double output CSS (props @agusmu) -* New: Google fonts now parsed from a json file. - -= 0.5.1 = - -January 22, 2015 - -* Fix: Transport defaults to refresh instead of postMessage -* Fix: undefined index notice. - -= 0.5 = - -January 21, 2015 - -* New: Automatic output of styles for generic controls. -* New: Automatic output of styles + scripts for fonts (including googlefonts ) -* New: The \'output\' argument on background controls is now an array for consistency with other controls. Older syntax is still compatible though. :) -* New: Add the ability to auto-generate styles for colors. -* Fix: Add a blank stylesheet if we need one and no stylesheet_id has been defined in the config options. -* Fix: CSS-only tooltips. Fixes issue with tooltips now showing up on WP >= 4.1 -* Fix: Code cleanups -* New: Added support for WordPress\'s transport arguments -* Fix: All controls now have a sanitization callback. Users can override the default sanitizations by adding their own \'sanitize_callback\' argument. -* Fix: OOP rewrite -* Fix: Strip protocol from Google API link -* Fix: Loading order for some files -* Fix: Removed deprecated less_var argument - -= 0.4 = - -October 25, 2014 - -* Fix: bugfix for selector -* New: Change the Kirki theme based on which admin theme is selected. -* Fix: Tranlsation domain issue -* New: Added a \"group_title\" control -* Fix: Updated the required script -* Fix: Updating CSS -* Other minor improvements and bugfixes - -= 0.3 = - -May 26, 2014 - -* new: added background field -* new: added \'output\' argument to directly output the CSS - -= 0.2 = - -May 9, 2014 - -* Initial version +=== Kirki === +Contributors: aristath, fovoc +Tags: customizer, options framework, theme, mods, toolkit +Donate link: http://kirki.org/ +Requires at least: 4.0 +Tested up to: 4.2 +Stable tag: 0.8.4 +License: GPLv2 or later +License URI: http://www.gnu.org/licenses/gpl-2.0.html + +Tired of all the bloated options frameworks? You can use the WordPress Customizer instead, and extend it using Kirki! + + +== Description == +Kirki allows developers to add advanced controls to their customizer as well as customize the way the customizer looks and feels. + +You can add beautiful options to your theme\'s customizer panel and allow your users to tweak any aspect of their theme. You\'ve got 18 control types that you can use ( 9 default + 9 custom-made ), styling options for the customizer, as well as automatic calculations for your styles using the `output` argument on your controls. + +Converting from the default customizer to the syntax used by Kirki will only take a few minutes and will save you a lot of time in the long run. :) + +**CAUTION**: This plugin requires PHP 5.3 and is not compatible with PHP 5.2 + +The following controls are included: + +* Radio-Buttonset +* Radio-Image +* Radio +* Checkbox +* Color +* Color-Alpha +* Dropdown Pages +* Image +* Background +* Multicheck +* Select +* Slider +* Text +* Textarea +* Upload +* Switch +* Toggle +* Sortable +* Number +* Palette +* Editor (TinyMCE) +* Select2 + +For documentation and examples on how to use these controls, please visit the [Kirki Wiki on Github](https://github.com/aristath/kirki/wiki). + + +== Installation == + +**Method 1: Use as a plugin** +From your dashboard go to Plugins => Add New. +Search for "Kirki" and install it. +Once you install it, activate it. +For configuration instructions please visit the [Kirki Wiki on Github](https://github.com/aristath/kirki/wiki). + +**Method 2: Embed in your theme** +Please visit https://github.com/aristath/kirki/wiki/Embedding-in-a-theme for documentation and instructions. + +== Sample Theme == + +To get an idea on how to include Kirki in your next project, a [sample theme](https://github.com/aristath/kirki/wiki/Sample-Theme-with-Kirki) has been created. + +== Changelog == + += 1.0.0-beta1 = + +* NEW: Added a new API. See https://github.com/aristath/kirki/wiki for documentation. +* NEW: Minimum PHP requirement is now PHP 5.2 +* NEW: Added a Select2 field type. +* NEW: Introducing the Kirki::get_option() method to get values. +* NEW: added 'prefix' and 'suffix' arguments to output. See https://github.com/aristath/kirki/issues/200#issuecomment-95994419 +* NEW: Added ability to get variables for CSS preprocessors from the customizer values +* NEW: $units to all outputs to support '!important' +* NEW: Ability to create panels & sections using the new API. +* NEW: added a get_posts method to the Kirki class. +* NEW: Implement width argument in the styling options. See https://github.com/aristath/kirki/wiki/Styling-the-Customizer +* NEW: add kirki/control_types filter +* FIX: avoid errors when Color is undefined +* FIX: Use WP_Filesystem to get the google fonts array from a json file +* FIX: Radio-Button styling +* FIX: PHP Notices +* FIX: Typos +* FIX: Properly sanitising rgba colors +* FIX: Properly sanitize numbers +* FIX: Make sure all variables are escaped on output +* TWEAK: allow using serialized options. +* TWEAK: Use active_callback for required arguments instead of custom JS +* TWEAK: Adding some more inline docs +* TWEAK: Updated translation files +* TWEAK: Better color manipulation in the Kirki_Color class +* TWEAK: Move secondary classes instantiation to the Kirki() function. +* TWEAK: set a $kirki global +* TWEAK: deprecate getOrThrow method in the Kirki_Config class. +* TWEAK: Move sanitisation functions to a Kirki_Sanitize class. +* TWEAK: Rename Kirki_Framework to Kirki_Toolkit. +* TWEAK: Move variables to the new API +* TWEAK: simplify Kirki_Controls class +* TWEAK: move the kirki/fields & kirki/controls filters to the new API +* REMOVED: remove the 'stylesheet_id' from the configuration. + += 0.8.4 = + +April 6, 2014, dev time: 0.5 hours + +* FIX: Color sanitization was distorting 0 characters in the color hex. +* FIX: Properly sanitizing ColorAlpha controls +* FIX: Sanitizing more properties in the Fields class +* FIX: removing remnant double-sanitization calls from the controls classes + += 0.8.3 = + +April 5, 2014, dev time: 28 hours + +* NEW: Introduce a Field class +* NEW: Introduce a Builder class +* TWEAK: Code Cleanups +* NEW: Added ability to use 'option' as the setting type +* Fix : Bugs in the color calculation class +* TWEAK: Everything gets sanitized in the "Field" class +* FIX: Bugs in sortable field +* FIX: Editor control had no description +* NEW: Added a color-alpha control. To use it just set an rgba color as the default value. +* TWEAK: SCSS & CSS improvements +* FIX: Various PHP notices and warnings when no fields are defined +* TWEAK: More efficient color sanitization method +* TWEAK: Improved number control presentation +* TWEAK: Improved the way background fields are handled +* TWEAK: Checkboxes styling +* NEW: Allow using rgba values for background colors +* FIX: CSS fix - :focus color for active section +* NEW: Add a static 'prepare' method to the ScriptRegistry class +* FIX: Issues with the URL when Kirki is embedded in a theme + += 0.8.2 = + +March 30, 2015, dev time: 5 minutes + +* FIX: Autoloader could not properly include files due to strtolower() + += 0.8.1 = + +March 30, 2015, dev time: 30 minutes + +* FIX: Translation strings now overridable using the config filter. + += 0.8.0 = + +March 30, 2015, dev time: 32 hours + +* Improvement: OOP redesign (props @vpratfr) +* NEW: Added Palette control +* NEW: Added Editor control (WYSIWYG - uses TinyMCE) +* NEW: Added Custom control (free html) +* NEW: Added a Kirki_Colourlovers class to use palettes from the colourlovers API +* NEW: Added a composer file (props @vpratfr) +* FIX: Wrong settings IDs +* FIX: Color calculation on RGBA functions were off +* TWEAK: Restructuring the plugin (props @vpratfr) +* NEW: added a functional kirki_get_option() function +* TWEAK: Simplified configuration options. +* NEW: Turn Kirki into a singleton and a facade (props @vpratfr) +* TWEAK: Completely re-written the customizer styles +* NEW: Using SASS for customizer styles +* TWEAK: Deprecating the group_title control in favor of the new custom control +* TWEAK: Changed the CSS for checkboxes + += 0.7.1 = + +March 15, 2015, dev time: 2 hours + +* REMOVED: Remove the `kirki_get_option` function that was introduced in 0.7 as it's not working properly yet. +* FIX: Undefined index notice when a default value for the control was not defined +* TWEAK: `logo_image` now injects an `img` element instead of a `div` with custom background +* NEW: Added `description` argument in the kirki configuration (replaces the theme description) + += 0.7 = + +March 14, 2015, dev time: 10 hours + +* FIX: Array to string conversion that happened conditionally when used with googlefonts. (props @groucho75) +* FIX: Background opacity affects background-position of bg image +* FIX: font-weight not being applied on google fonts +* NEW: Added `kirki_get_option( $setting );` function that also gets default values +* TWEAK: Singleton for main plugin class +* FIX: Prevent empty help tooltips +* NEW: Added `toggle` control +* NEW: Added `switch` control +* FIX: Color controls were not being reset to default: +* TWEAK: Tooltips now loaded via jQuery +* TWEAK: Renamed `setting` to settings for consistency with WordPress core +* TWEAK: Renamed `description` to `help` and `subtitle` to `description for consistency with WordPress core +* TWEAK: Backwards-compatibility improvements +* NEW: Allow hiding background control elements by not including default values for them +* TWEAK: Performance improvements +* TWEAK: Using WordPress core controls instead of custom ones when those are available +* TWEAK: Separate logic for multiple-type controls that were using the "mode" argument. This has been deprecated in favor of completely separate control types. + += 0.6.2 = + +March 2, 2015, dev time: 3 hours + +* FIX: Frontend styles were not properly enqueued (props @dmgawel) +* NEW: Allow multiple output styles per control defined as an array of arrays. +* FIX: Background control styles +* FIX: Serialise default values for the sortable control. Now you can define default values as an array. +* FIX: Required script +* FIX: \'_opacity\' was added to a lot of controls by mistake. Removed it and wrote a migration script. + += 0.6.1 = + +February 25, 2015, dev time: 1 hours + +* FIX: Sortables controls had a JS conflict +* FIX: Switches & Toggles were not properly working + += 0.6.0 = + +February 25, 2015, dev time: 9 hours + +* FIX: Tooltips now properly working +* NEW: Added checkbox switches +* NEW: Added checkbox toggles +* FIX: Generated CSS is not properly combined & minified +* FIX: Re-structuring files hierarchy +* FIX: Simplify the way controls are loaded +* NEW: Only load control classes when they are needed +* NEW: Introducing Kirki_Customize_Control class +* FIX: CSS tweaks +* NEW: Sortable control (creating one is identical to a select control, but with `\'type\' => \'sortable\'`) +* FIX: Double output CSS (props @agusmu) +* NEW: Google fonts now parsed from a json file. + += 0.5.1 = + +January 22, 2015 + +* FIX: Transport defaults to refresh instead of postMessage +* FIX: undefined index notice. + += 0.5 = + +January 21, 2015 + +* NEW: Automatic output of styles for generic controls. +* NEW: Automatic output of styles + scripts for fonts (including googlefonts ) +* NEW: The \'output\' argument on background controls is now an array for consistency with other controls. Older syntax is still compatible though. :) +* NEW: Add the ability to auto-generate styles for colors. +* FIX: Add a blank stylesheet if we need one and no stylesheet_id has been defined in the config options. +* FIX: CSS-only tooltips. Fixes issue with tooltips now showing up on WP >= 4.1 +* FIX: Code cleanups +* NEW: Added support for WordPress\'s transport arguments +* FIX: All controls now have a sanitization callback. Users can override the default sanitizations by adding their own \'sanitize_callback\' argument. +* FIX: OOP rewrite +* FIX: Strip protocol from Google API link +* FIX: Loading order for some files +* FIX: Removed deprecated less_var argument + += 0.4 = + +October 25, 2014 + +* FIX: bugfix for selector +* NEW: Change the Kirki theme based on which admin theme is selected. +* FIX: Tranlsation domain issue +* NEW: Added a \"group_title\" control +* FIX: Updated the required script +* FIX: Updating CSS +* Other minor improvements and bugfixes + += 0.3 = + +May 26, 2014 + +* NEW: added background field +* NEW: added \'output\' argument to directly output the CSS + += 0.2 = + +May 9, 2014 + +* Initial version diff --git a/includes/plugins/kirki/sample-config.php b/includes/plugins/kirki/sample-config.php new file mode 100644 index 0000000..c228de9 --- /dev/null +++ b/includes/plugins/kirki/sample-config.php @@ -0,0 +1,594 @@ +add_section( 'controls_with_choices', array( + 'title' => __( 'Controls with Choices', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'color_section', array( + 'title' => __( 'Color Controls', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'file_controls_section', array( + 'title' => __( 'File & Image Controls', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'text_section', array( + 'title' => __( 'Text Control', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'background_section', array( + 'title' => __( 'Background Control', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'numeric', array( + 'title' => __( 'Numeric Controls', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + + $wp_customize->add_section( 'custom_section', array( + 'title' => __( 'Custom Control', 'kirki' ), + 'priority' => 10, + 'description' => __( 'This is the section description', 'kirki' ), + ) ); + +} +add_action( 'customize_register', 'kirki_demo_sections' ); + +/** + * Create panels using the Kirki API + */ +Kirki::add_section( 'boolean_controls', array( + 'priority' => 10, + 'title' => __( 'Boolean Controls', 'kirki' ), + 'description' => __( 'This panel contains controls that return true/false Controls', 'kirki' ), +) ); + +/** + * Add controls using the 'kirki/fields' filter. + */ +function kirki_controls_with_choices_fields( $fields ) { + + $fields[] = array( + 'type' => 'radio', + 'settings' => 'radio_demo', + 'label' => __( 'Radio Control', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + 'option-4' => __( 'Option 4', 'kirki' ), + ), + ); + + $fields[] = array( + 'type' => 'dropdown-pages', + 'settings' => 'dropdown_pages_demo', + 'label' => __( 'Dropdown Pages', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'priority' => 10, + ); + + $fields[] = array( + 'type' => 'select', + 'settings' => 'select_demo', + 'label' => __( 'Select', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + 'option-4' => __( 'Option 4', 'kirki' ), + ), + ); + + $fields[] = array( + 'type' => 'radio-image', + 'settings' => 'radio_image_demo', + 'label' => __( 'Radio-Image', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => array( + 'option-1' => admin_url().'/images/align-left-2x.png', + 'option-2' => admin_url().'/images/align-center-2x.png', + 'option-3' => admin_url().'/images/align-right-2x.png', + ), + ); + + $fields[] = array( + 'type' => 'radio-buttonset', + 'settings' => 'radio_buttonset_demo', + 'label' => __( 'Radio-Buttonset', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + ), + ); + + $fields[] = array( + 'type' => 'multicheck', + 'settings' => 'multicheck_demo', + 'label' => __( 'Multicheck', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => array( + 'option-1', + 'option-2' + ), + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + 'option-4' => __( 'Option 4', 'kirki' ), + ), + ); + + $fields[] = array( + 'type' => 'sortable', + 'settings' => 'sortable_demo', + 'label' => __( 'Sortable', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => array( + 'option-3', + 'option-1', + 'option-4' + ), + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + 'option-4' => __( 'Option 4', 'kirki' ), + 'option-5' => __( 'Option 5', 'kirki' ), + 'option-6' => __( 'Option 6', 'kirki' ), + ), + ); + + // Define custom palettes + $fields[] = array( + 'type' => 'palette', + 'settings' => 'palette_demo', + 'label' => __( 'Palette', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'red', + 'priority' => 10, + 'choices' => array( + 'red' => array( + '#ef9a9a', + '#f44336', + '#ff1744', + ), + 'pink' => array( + '#fce4ec', + '#f06292', + '#e91e63', + '#ad1457', + '#f50057', + ), + 'cyan' => array( + '#e0f7fa', + '#80deea', + '#26c6da', + '#0097a7', + '#00e5ff', + ), + ), + ); + + // Define custom palettes + $fields[] = array( + 'type' => 'palette', + 'settings' => 'palette_demo_colourlovers', + 'label' => __( 'Palettes from Colourlovers', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'red', + 'priority' => 10, + 'choices' => Kirki_Colourlovers::get_palettes( 5 ), + ); + + $fields[] = array( + 'type' => 'select2', + 'settings' => 'select_demo_2', + 'label' => __( 'Select2', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => Kirki_Fonts::get_font_choices(), + 'output' => array( + array( + 'element' => 'body p', + 'property' => 'font-family', + ) + ) + ); + + $fields[] = array( + 'type' => 'select2-multiple', + 'settings' => 'select_demo_3', + 'label' => __( 'Select2 - multiple', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'controls_with_choices', + 'default' => 'option-1', + 'priority' => 10, + 'choices' => array( + 'option-1' => __( 'Option 1', 'kirki' ), + 'option-2' => __( 'Option 2', 'kirki' ), + 'option-3' => __( 'Option 3', 'kirki' ), + 'option-4' => __( 'Option 4', 'kirki' ), + ), + ); + + return $fields; + +} +add_filter( 'kirki/fields', 'kirki_controls_with_choices_fields' ); + +/** + * Add file controls + */ +function kirki_file_controls_fields( $fields ) { + + $fields[] = array( + 'type' => 'image', + 'settings' => 'image_demo', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'file_controls_section', + 'default' => '', + 'priority' => 10, + 'output' => array( + array( + 'element' => 'p', + 'property' => 'background-image', + ), + ), + ); + + $fields[] = array( + 'type' => 'upload', + 'settings' => 'file_controls_section', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'file_controls_section', + 'default' => '', + 'priority' => 10, + ); + + return $fields; + +} +add_filter( 'kirki/fields', 'kirki_file_controls_fields' ); + +/** + * Add text fields + */ +function kirki_text_controls_fields( $fields ) { + + $fields[] = array( + 'type' => 'text', + 'settings' => 'text_demo', + 'label' => __( 'Text', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'text_section', + 'default' => 'This is some default text', + 'priority' => 10, + ); + + $fields[] = array( + 'type' => 'textarea', + 'settings' => 'textarea_demo', + 'label' => __( 'Textarea', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'text_section', + 'default' => 'This is some default text', + 'priority' => 10, + ); + + $fields[] = array( + 'type' => 'editor', + 'settings' => 'wysiwyg', + 'label' => __( 'Editor', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'default' => '', + 'section' => 'text_section', + ); + + return $fields; + +} +add_filter( 'kirki/fields', 'kirki_text_controls_fields' ); + +/** + * Add numeric fields + */ +function kirki_numeric_fields( $fields ) { + + // step = 10 + $fields[] = array( + 'type' => 'slider', + 'settings' => 'slider_demo', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'numeric', + 'default' => 20, + 'priority' => 10, + 'choices' => array( + 'min' => -100, + 'max' => 100, + 'step' => 10 + ), + ); + + // step = 0.01 + $fields[] = array( + 'type' => 'slider', + 'settings' => 'slider_demo_2', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'numeric', + 'default' => 1.58, + 'priority' => 20, + 'choices' => array( + 'min' => 0, + 'max' => 5, + 'step' => .01 + ), + ); + + $fields[] = array( + 'type' => 'number', + 'settings' => 'number_demo', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'numeric', + 'default' => '42', + 'priority' => 10, + ); + + return $fields; + +} +add_filter( 'kirki/fields', 'kirki_numeric_fields' ); + +/** + * Create a config instance that will be used by fields added via the static methods. + * For this example we'll be defining our options to be serialized in the db, under the 'kirki_demo' option. + */ +Kirki::add_config( 'kirki_demo', array( + 'options_type' => 'option', + 'option_name' => 'kirki_demo' +) ); + +/** + * Create Custom field using the Kirki API static functions + */ +Kirki::add_field( 'kirki_demo', array( + 'type' => 'custom', + 'settings' => 'custom_demo', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'custom_section', + 'default' => '
      You can enter custom markup in this control and use it however you want
      ', + 'priority' => 10, +) ); + +/** + * Create Color fields using the Kirki API static functions + */ +Kirki::add_field( 'kirki_demo', array( + 'type' => 'color', + 'settings' => 'color_demo', + 'label' => __( 'Color Control', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users.', 'kirki' ), + 'section' => 'color_section', + 'default' => '#0088cc', + 'priority' => 10, + 'output' => array( + array( + 'element' => 'a, a:visited', + 'property' => 'color', + 'units' => ' !important' + ), + array( + 'element' => '#content', + 'property' => 'border-color' + ), + ), + 'transport' => 'postMessage', + 'js_vars' => array( + array( + 'element' => 'a, a:visited', + 'function' => 'css', + 'property' => 'color', + ), + array( + 'element' => '#content', + 'function' => 'css', + 'property' => 'background-color', + ), + ) +) ); + +Kirki::add_field( 'kirki_demo', array( + 'type' => 'color-alpha', + 'settings' => 'color_alpha_demo', + 'label' => __( 'Color-Alpha Control', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users.', 'kirki' ), + 'section' => 'color_section', + 'default' => '#0088cc', + 'priority' => 10, + 'output' => array( + array( + 'element' => 'a, a:visited', + 'property' => 'color', + 'units' => ' !important' + ), + array( + 'element' => '#content', + 'property' => 'border-color' + ), + ), + 'transport' => 'postMessage', + 'js_vars' => array( + array( + 'element' => 'a, a:visited', + 'function' => 'css', + 'property' => 'color', + ), + array( + 'element' => '#content', + 'function' => 'css', + 'property' => 'background-color', + ), + ) +) ); + +/** + * Create Boolean fields using the Kirki API static functions + */ +// Checkbox +Kirki::add_field( 'kirki_demo', array( + 'type' => 'checkbox', + 'settings' => 'checkbox_demo_0', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users.', 'kirki' ), + 'section' => 'boolean_controls', + 'default' => 1, + 'priority' => 10, +) ); + +// Switch +Kirki::add_field( 'kirki_demo', array( + 'type' => 'switch', + 'settings' => 'switch_demo_0', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users.', 'kirki' ), + 'section' => 'boolean_controls', + 'default' => '1', + 'priority' => 10, +) ); + +// Toggle +Kirki::add_field( 'kirki_demo', array( + 'type' => 'toggle', + 'settings' => 'toggle_demo_1', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users.', 'kirki' ), + 'section' => 'boolean_controls', + 'default' => 1, + 'priority' => 10, +) ); + +/** + * Add the background field + */ +Kirki::add_field( 'kirki_demo', array( + 'type' => 'background', + 'settings' => 'background_demo', + 'label' => __( 'This is the label', 'kirki' ), + 'description' => __( 'This is the control description', 'kirki' ), + 'help' => __( 'This is some extra help. You can use this to add some additional instructions for users. The main description should go in the "description" of the field, this is only to be used for help tips.', 'kirki' ), + 'section' => 'background_section', + 'default' => array( + 'color' => '#ffffff', + 'image' => '', + 'repeat' => 'no-repeat', + 'size' => 'cover', + 'attach' => 'fixed', + 'position' => 'left-top', + 'opacity' => 90, + ), + 'priority' => 10, + 'output' => '.hentry', +) ); + +/** + * Configuration sample for the Kirki Customizer. + */ +function kirki_demo_configuration_sample() { + + $args = array( + 'logo_image' => 'http://kirki.org/img/kirki-new-logo-white.png', + 'description' => __( 'This is the theme description. You can edit it in the Kirki configuration and add whatever you want here.', 'kirki' ), + 'color_accent' => '#00bcd4', + 'color_back' => '#455a64', + ); + + return $args; + +} + +add_filter( 'kirki/config', 'kirki_demo_configuration_sample' ); diff --git a/includes/plugins/kirki/tests/test-bootstrap.php b/includes/plugins/kirki/tests/test-bootstrap.php new file mode 100644 index 0000000..779a6ef --- /dev/null +++ b/includes/plugins/kirki/tests/test-bootstrap.php @@ -0,0 +1,15 @@ + 'text', + 'settings' => 'the_mod_option', + 'section' => 'my_section', + 'default' => 'foo', + 'priority' => 20, + 'option_type' => 'theme_mod', + ) ); + } + + public function test_kirki_get_option() { + $this->add_theme_mod_field(); + $this->assertEquals( 'foo', kirki_get_option( 'the_mod_option' ) ); + set_theme_mod( 'the_mod_option', 'bar' ); + $this->assertEquals( 'bar', kirki_get_option( 'the_mod_option' ) ); + } + + public function test_kirki_sanitize_hex() { + $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT); + $this->assertEquals( kirki_sanitize_hex( $random_color ), Kirki_Color::sanitize_hex( $random_color ) ); + } + + public function test_kirki_get_rgb() { + $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT); + $this->assertEquals( kirki_get_rgb( $random_color ), Kirki_Color::get_rgb( $random_color ) ); + } + + public function test_kirki_get_rgba() { + $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT); + $this->assertEquals( kirki_get_rgba( $random_color ), Kirki_Color::get_rgba( $random_color ) ); + } + + public function test_kirki_get_brightness() { + $random_color = str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT) . str_pad( dechex( mt_rand( 0, 255 ) ), 2, '0', STR_PAD_LEFT); + $this->assertEquals( kirki_get_brightness( $random_color ), Kirki_Color::get_brightness( $random_color ) ); + } + + public function test_kirki_fonts() { + $this->assertEquals( Kirki_Fonts::get_all_fonts(), Kirki_Toolkit::fonts()->get_all_fonts() ); + $this->assertEquals( Kirki_Fonts::get_font_choices(), Kirki_Toolkit::fonts()->get_font_choices() ); + $this->assertEquals( Kirki_Fonts::is_google_font( 'Open Sans' ), Kirki_Toolkit::fonts()->is_google_font( 'Open Sans' ) ); + $this->assertEquals( Kirki_Fonts::get_google_font_uri( array( 'Roboto' ) ), Kirki_Toolkit::fonts()->get_google_font_uri( array( 'Roboto' ) ) ); + $this->assertEquals( Kirki_Fonts::get_google_font_subsets(), Kirki_Toolkit::fonts()->get_google_font_subsets() ); + $this->assertEquals( Kirki_Fonts::choose_google_font_variants( 'Roboto' ), Kirki_Toolkit::fonts()->choose_google_font_variants( 'Roboto' ) ); + $this->assertEquals( Kirki_Fonts::get_standard_fonts(), Kirki_Toolkit::fonts()->get_standard_fonts() ); + $this->assertEquals( Kirki_Fonts::get_font_stack( '' ), Kirki_Toolkit::fonts()->get_font_stack( '' ) ); + $this->assertEquals( Kirki_Fonts::sanitize_font_choice( '' ), Kirki_Toolkit::fonts()->sanitize_font_choice( '' ) ); + $this->assertEquals( Kirki_Fonts::get_google_fonts(), Kirki_Toolkit::fonts()->get_google_fonts() ); + } +} diff --git a/includes/plugins/kirki/tests/test-kirki-color.php b/includes/plugins/kirki/tests/test-kirki-color.php new file mode 100644 index 0000000..76757b7 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-color.php @@ -0,0 +1,188 @@ +assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'f' ) ); + // 2-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'ff' ) ); + // 3-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'fff' ) ); + // 4-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'ffff' ) ); + // 5-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'fffff' ) ); + // 6-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'ffffff' ) ); + // 7-letter hex + $this->assertEquals( '#ffffff', Kirki_Color::sanitize_hex( 'fffffff' ) ); + + /** + * Black + */ + // 1-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '0' ) ); + // 2-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '00' ) ); + // 3-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '000' ) ); + // 4-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '0000' ) ); + // 5-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '00000' ) ); + // 6-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '000000' ) ); + // 7-letter hex + $this->assertEquals( '#000000', Kirki_Color::sanitize_hex( '0000000' ) ); + + /** + * Invalid color characters + */ + $this->assertEquals( '#ff8855', Kirki_Color::sanitize_hex( 'fg8p5m' ) ); + + } + + public function test_get_rgb() { + /** + * White + */ + $this->assertEquals( array( 255, 255, 255 ), Kirki_Color::get_rgb( '#ffffff' ) ); + $this->assertEquals( '255,255,255', Kirki_Color::get_rgb( '#ffffff', true ) ); + /** + * Black + */ + $this->assertEquals( array( 0, 0, 0 ), Kirki_Color::get_rgb( '#000000' ) ); + $this->assertEquals( '0,0,0', Kirki_Color::get_rgb( '#000000', true ) ); + } + + public function test_rgba2hex() { + /** + * White + */ + $this->assertEquals( '#ffffff', Kirki_Color::rgba2hex( 'rgba(255,255,255,1)' ) ); + $this->assertEquals( '#ffffff', Kirki_Color::rgba2hex( 'rgba(255,255,255,0)' ) ); + $this->assertEquals( '#ffffff', Kirki_Color::rgba2hex( 'rgba( 255, 255, 255, 0 ) ' ) ); + $this->assertEquals( true, ( '#ffffff' != Kirki_Color::rgba2hex( 'rgba(255,230,255,1)' ) ) ); + /** + * Black + */ + $this->assertEquals( '#000000', Kirki_Color::rgba2hex( 'rgba(0,0,0,1)' ) ); + $this->assertEquals( '#000000', Kirki_Color::rgba2hex( 'rgba( 0, 0, 0, 1)' ) ); + $this->assertEquals( true, ( '#000000' != Kirki_Color::rgba2hex( 'rgba(0,0,0,.1)' ) ) ); + /** + * Opacity + */ + $this->assertEquals( '#7f7f7f', Kirki_Color::rgba2hex( 'rgba(0,0,0,.5)' ) ); + $this->assertEquals( '#ff7f7f', Kirki_Color::rgba2hex( 'rgba(255,0,0,.5)' ) ); + $this->assertEquals( '#7fff7f', Kirki_Color::rgba2hex( 'rgba(0,255,0,.5)' ) ); + $this->assertEquals( '#7f7fff', Kirki_Color::rgba2hex( 'rgba(0,0,255,.5)' ) ); + /** + * invalid + */ + $this->assertEquals( '#ffffff', Kirki_Color::rgba2hex( 'rgba(0,.5)' ) ); + $this->assertEquals( '#ffffff', Kirki_Color::rgba2hex( '#ffffff' ) ); + } + + public function test_get_rgba() { + // White + $this->assertEquals( 'rgba(255,255,255,1)', Kirki_Color::get_rgba( '#ffffff', 1 ) ); + $this->assertEquals( 'rgba(255,255,255,1)', Kirki_Color::get_rgba( '#ffffff', 100 ) ); + // Transparent + $this->assertEquals( 'rgba(255,255,255,0)', Kirki_Color::get_rgba( '#ffffff', 0 ) ); + // grey + $this->assertEquals( 'rgba(0,0,0,0.5)', Kirki_Color::get_rgba( '#000000', .5 ) ); + // colors + $this->assertEquals( 'rgba(255,0,0,0.5)', Kirki_Color::get_rgba( '#ff0000', .5 ) ); + $this->assertEquals( 'rgba(0,255,0,0.5)', Kirki_Color::get_rgba( '#00ff00', .5 ) ); + $this->assertEquals( 'rgba(0,0,255,0.5)', Kirki_Color::get_rgba( '#0000ff', .5 ) ); + } + + public function test_get_brightness() { + $this->assertEquals( '0', Kirki_Color::get_brightness( '#000000' ) ); + $this->assertEquals( '255', Kirki_Color::get_brightness( '#ffffff' ) ); + $this->assertEquals( 127, Kirki_Color::get_brightness( '#7f7f7f' ) ); + $this->assertEquals( 105, Kirki_Color::get_brightness( '#ff00ff' ) ); + } + + public function test_adjust_brightness() { + $this->assertEquals( '#ffffff', Kirki_Color::adjust_brightness( '#000000', 255 ) ); + $this->assertEquals( '#000000', Kirki_Color::adjust_brightness( '#000000', 0 ) ); + $this->assertEquals( '#ffffff', Kirki_Color::adjust_brightness( '#fff', 0 ) ); + $this->assertEquals( '#000000', Kirki_Color::adjust_brightness( '#fff', -255 ) ); + $this->assertEquals( '#7f7f7f', Kirki_Color::adjust_brightness( '#fff', (0 - 255/2) ) ); + } + + public function test_mix_colors() { + $this->assertEquals( '#ffffff', Kirki_Color::mix_colors( '#ffffff', 'fff', 100 ) ); + $this->assertEquals( '#ffffff', Kirki_Color::mix_colors( '#ffffff', 'fff', 0 ) ); + $this->assertEquals( '#ffffff', Kirki_Color::mix_colors( '#ffffff', 'fff', 37 ) ); + + $this->assertEquals( '#000000', Kirki_Color::mix_colors( '#000000', '000', 100 ) ); + $this->assertEquals( '#000000', Kirki_Color::mix_colors( '#000000', '000', 0 ) ); + $this->assertEquals( '#000000', Kirki_Color::mix_colors( '#000000', '0000', 37 ) ); + + $this->assertEquals( '#7f7f7f', Kirki_Color::mix_colors( '#ffffff', '000', 50 ) ); + $this->assertEquals( '#7f7f7f', Kirki_Color::mix_colors( '#ffffff', '#000000', 50 ) ); + $this->assertEquals( '#7f7f7f', Kirki_Color::mix_colors( '#000000', '#ffffff', 50 ) ); + } + + public function test_hex_to_hsv() { + + $white = array( 'h' => 0, 's' => 0, 'v' => 1 ); + $black = array( 'h' => 0, 's' => 0, 'v' => 0 ); + $red = array( 'h' => 0, 's' => 1, 'v' => 1 ); + $green = array( 'h' => 0.33, 's' => 1, 'v' => 1 ); + $blue = array( 'h' => 0.67, 's' => 1, 'v' => 1 ); + + $this->assertEquals( $white, Kirki_Color::hex_to_hsv( '#ffffff' ) ); + $this->assertEquals( $black, Kirki_Color::hex_to_hsv( '#000000' ) ); + $this->assertEquals( $red, Kirki_Color::hex_to_hsv( '#ff0000' ) ); + $this->assertEquals( $green, Kirki_Color::hex_to_hsv( '#00ff00' ) ); + $this->assertEquals( $blue, Kirki_Color::hex_to_hsv( '#0000ff' ) ); + } + + public function test_rgb_to_hsv() { + + $white = array( 'h' => 0, 's' => 0, 'v' => 1 ); + $black = array( 'h' => 0, 's' => 0, 'v' => 0 ); + $red = array( 'h' => 0, 's' => 1, 'v' => 1 ); + $green = array( 'h' => 0.33, 's' => 1, 'v' => 1 ); + $blue = array( 'h' => 0.67, 's' => 1, 'v' => 1 ); + + $this->assertEquals( $white, Kirki_Color::rgb_to_hsv( array( 255, 255, 255 ) ) ); + $this->assertEquals( $black, Kirki_Color::rgb_to_hsv( array( 0, 0, 0 ) ) ); + $this->assertEquals( $red, Kirki_Color::rgb_to_hsv( array( 255, 0, 0 ) ) ); + $this->assertEquals( $green, Kirki_Color::rgb_to_hsv( array( 0, 255, 0 ) ) ); + $this->assertEquals( $blue, Kirki_Color::rgb_to_hsv( array( 0, 0, 255 ) ) ); + } + + public function test_color_difference() { + $this->assertEquals( '0', Kirki_Color::color_difference( 'fff', '#ffffff' ) ); + $this->assertEquals( '765', Kirki_Color::color_difference( 'fff', '000' ) ); + $this->assertEquals( '765', Kirki_Color::color_difference( '#000000', '#ffffff' ) ); + $this->assertEquals( '522', Kirki_Color::color_difference( '#f2f2f2', '#c00' ) ); + $this->assertEquals( '39', Kirki_Color::color_difference( '#f2f2f2', '#ffffff' ) ); + } + + public function test_brightness_difference() { + $this->assertEquals( '0', Kirki_Color::brightness_difference( 'fff', '#ffffff' ) ); + $this->assertEquals( '255', Kirki_Color::brightness_difference( 'fff', '000' ) ); + $this->assertEquals( '255', Kirki_Color::brightness_difference( '#000000', '#ffffff' ) ); + $this->assertEquals( '181', Kirki_Color::brightness_difference( '#f2f2f2', '#c00' ) ); + $this->assertEquals( '13', Kirki_Color::brightness_difference( '#f2f2f2', '#ffffff' ) ); + } + + public function test_lumosity_difference() { + $this->assertEquals( '1', Kirki_Color::lumosity_difference( 'fff', '#ffffff' ) ); + $this->assertEquals( '21', Kirki_Color::lumosity_difference( 'fff', '000' ) ); + $this->assertEquals( '21', Kirki_Color::lumosity_difference( '#000000', '#ffffff' ) ); + $this->assertEquals( '5.23', Kirki_Color::lumosity_difference( '#f2f2f2', '#c00' ) ); + $this->assertEquals( '1.12', Kirki_Color::lumosity_difference( '#f2f2f2', '#ffffff' ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-explode-background-field.php b/includes/plugins/kirki/tests/test-kirki-explode-background-field.php new file mode 100644 index 0000000..c925261 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-explode-background-field.php @@ -0,0 +1,222 @@ + 'background', + 'settings' => 'my_setting', + 'label' => 'Control Title', + 'section' => 'my_section', + 'default' => array( + 'image' => 'http://example.com/foo.png', + 'color' => 'rgba(255,230,34,1)', + 'repeat' => 'no-repeat', + 'size' => 'cover', + 'attach' => 'fixed', + 'position' => 'left-top', + 'opacity' => 1 + ), + 'priority' => 20, + 'output' => 'body', + ) ); + } + + public function final_fields() { + $initial_fields = $this->initial_fields(); + return array( + $initial_fields[0], + 'my_setting_color' => array( + 'type' => 'color-alpha', + 'label' => '', + 'section' => 'my_section', + 'settings' => 'my_setting_color', + 'priority' => 20, + 'help' => '', + 'description' => 'Background Color', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'rgba(255,230,34,1)', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-color', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'choices' => array(), + 'sanitize_callback' => array( 'Kirki_Sanitize', 'color' ), + 'js_vars' => null, + 'id' => 'my_setting_color', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + 'my_setting_image' => array( + 'type' => 'image', + 'label' => 'Control Title', + 'section' => 'my_section', + 'settings' => 'my_setting_image', + 'priority' => 20, + 'help' => '', + 'description' => 'Background Image', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'http://example.com/foo.png', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-image', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'choices' => array(), + 'sanitize_callback' => 'esc_url_raw', + 'js_vars' => null, + 'id' => 'my_setting_image', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + 'my_setting_repeat' => array( + 'type' => 'select', + 'label' => '', + 'section' => 'my_section', + 'settings' => 'my_setting_repeat', + 'priority' => 20, + 'choices' => array( + 'no-repeat' => 'No Repeat', + 'repeat' => 'Repeat All', + 'repeat-x' => 'Repeat Horizontally', + 'repeat-y' => 'Repeat Vertically', + 'inherit' => 'Inherit', + ), + 'help' => '', + 'description' => 'Background Repeat', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'no-repeat', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-repeat', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'sanitize_callback' => array( 'Kirki_Sanitize', 'choice' ), + 'js_vars' => null, + 'id' => 'my_setting_repeat', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + 'my_setting_size' => array( + 'type' => 'select', + 'label' => '', + 'section' => 'my_section', + 'settings' => 'my_setting_size', + 'priority' => 20, + 'choices' => array( + 'inherit' => 'Inherit', + 'cover' => 'Cover', + 'contain' => 'Contain', + ), + 'help' => '', + 'description' => 'Background Size', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'cover', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-size', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'sanitize_callback' => array( 'Kirki_Sanitize', 'choice' ), + 'js_vars' => null, + 'id' => 'my_setting_size', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + 'my_setting_attach' => array( + 'type' => 'select', + 'label' => '', + 'section' => 'my_section', + 'settings' => 'my_setting_attach', + 'priority' => 20, + 'choices' => array( + 'inherit' => 'Inherit', + 'fixed' => 'Fixed', + 'scroll' => 'Scroll', + ), + 'help' => '', + 'description' => 'Background Attachment', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'fixed', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-attachment', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'sanitize_callback' => array( 'Kirki_Sanitize', 'choice' ), + 'js_vars' => null, + 'id' => 'my_setting_attach', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + 'my_setting_position' => array( + 'type' => 'select', + 'label' => '', + 'section' => 'my_section', + 'settings' => 'my_setting_position', + 'priority' => 20, + 'choices' => array( + 'left-top' => 'Left Top', + 'left-center' => 'Left Center', + 'left-bottom' => 'Left Bottom', + 'right-top' => 'Right Top', + 'right-center' => 'Right Center', + 'right-bottom' => 'Right Bottom', + 'center-top' => 'Center Top', + 'center-center' => 'Center Center', + 'center-bottom' => 'Center Bottom', + ), + 'help' => '', + 'description' => 'Background Position', + 'required' => null, + 'transport' => 'refresh', + 'default' => 'left-top', + 'output' => array( + array( + 'element' => 'body', + 'property' => 'background-position', + ), + ), + 'settings_raw' => 'my_setting', + 'option_type' => 'theme_mod', + 'sanitize_callback' => array( 'Kirki_Sanitize', 'choice' ), + 'js_vars' => null, + 'id' => 'my_setting_position', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ) + ); + } + + public function test_build_background_fields() { + $this->assertEquals( $this->final_fields(), Kirki_Explode_Background_Field::process_fields( $this->initial_fields() ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-field.php b/includes/plugins/kirki/tests/test-kirki-field.php new file mode 100644 index 0000000..3e511bf --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-field.php @@ -0,0 +1,386 @@ +assertEquals( 'checkbox', Kirki_Field::sanitize_control_type( array( 'type' => 'checkbox' ) ) ); + + $this->assertEquals( 'color-alpha', Kirki_Field::sanitize_control_type( array( 'type' => 'color-alpha' ) ) ); + $this->assertEquals( 'color-alpha', Kirki_Field::sanitize_control_type( array( 'type' => 'color_alpha' ) ) ); + $this->assertEquals( 'color-alpha', Kirki_Field::sanitize_control_type( array( 'type' => 'color', 'default' => 'rgba(0,0,0,1)' ) ) ); + $this->assertEquals( 'color', Kirki_Field::sanitize_control_type( array( 'type' => 'color' ) ) ); + $this->assertEquals( 'custom', Kirki_Field::sanitize_control_type( array( 'type' => 'custom' ) ) ); + $this->assertEquals( 'custom', Kirki_Field::sanitize_control_type( array( 'type' => 'group-title' ) ) ); + $this->assertEquals( 'custom', Kirki_Field::sanitize_control_type( array( 'type' => 'group_title' ) ) ); + $this->assertEquals( 'dropdown-pages', Kirki_Field::sanitize_control_type( array( 'type' => 'dropdown-pages' ) ) ); + $this->assertEquals( 'editor', Kirki_Field::sanitize_control_type( array( 'type' => 'editor' ) ) ); + $this->assertEquals( 'image', Kirki_Field::sanitize_control_type( array( 'type' => 'image' ) ) ); + $this->assertEquals( 'multicheck', Kirki_Field::sanitize_control_type( array( 'type' => 'multicheck' ) ) ); + $this->assertEquals( 'number', Kirki_Field::sanitize_control_type( array( 'type' => 'number' ) ) ); + $this->assertEquals( 'palette', Kirki_Field::sanitize_control_type( array( 'type' => 'palette' ) ) ); + $this->assertEquals( 'radio-buttonset', Kirki_Field::sanitize_control_type( array( 'type' => 'radio-buttonset' ) ) ); + $this->assertEquals( 'radio-buttonset', Kirki_Field::sanitize_control_type( array( 'type' => 'radio', 'mode' => 'buttonset' ) ) ); + $this->assertEquals( 'radio-image', Kirki_Field::sanitize_control_type( array( 'type' => 'radio-image' ) ) ); + $this->assertEquals( 'radio-image', Kirki_Field::sanitize_control_type( array( 'type' => 'radio', 'mode' => 'image' ) ) ); + $this->assertEquals( 'radio', Kirki_Field::sanitize_control_type( array( 'type' => 'radio' ) ) ); + $this->assertEquals( 'select', Kirki_Field::sanitize_control_type( array( 'type' => 'select' ) ) ); + $this->assertEquals( 'slider', Kirki_Field::sanitize_control_type( array( 'type' => 'slider' ) ) ); + $this->assertEquals( 'sortable', Kirki_Field::sanitize_control_type( array( 'type' => 'sortable' ) ) ); + $this->assertEquals( 'switch', Kirki_Field::sanitize_control_type( array( 'type' => 'switch' ) ) ); + $this->assertEquals( 'switch', Kirki_Field::sanitize_control_type( array( 'type' => 'checkbox', 'mode' => 'switch' ) ) ); + $this->assertEquals( 'text', Kirki_Field::sanitize_control_type( array( 'type' => 'text' ) ) ); + $this->assertEquals( 'textarea', Kirki_Field::sanitize_control_type( array( 'type' => 'textarea' ) ) ); + $this->assertEquals( 'toggle', Kirki_Field::sanitize_control_type( array( 'type' => 'toggle' ) ) ); + $this->assertEquals( 'toggle', Kirki_Field::sanitize_control_type( array( 'type' => 'checkbox', 'mode' => 'toggle' ) ) ); + $this->assertEquals( 'upload', Kirki_Field::sanitize_control_type( array( 'type' => 'upload' ) ) ); + + $this->assertEquals( 'text', Kirki_Field::sanitize_control_type( array() ) ); + + } + + public function test_sanitize_field() { + $this->assertEquals( + array( + 'settings' => 'foo', + 'section' => 'foo', + 'type' => 'text', + 'settings_raw' => 'foo', + 'default' => '', + 'label' => '', + 'help' => '', + 'description' => '', + 'required' => null, + 'transport' => 'refresh', + 'option_type' => 'theme_mod', + 'priority' => 10, + 'choices' => array(), + 'output' => null, + 'sanitize_callback' => 'esc_textarea', + 'js_vars' => null, + 'id' => 'foo', + 'capability' => 'edit_theme_options', + 'variables' => false, + 'active_callback' => '__return_true', + ), + Kirki_Field::sanitize_field( array( + 'settings' => 'foo', + 'section' => 'foo', + 'type' => 'text', + ) ) ); + } + + public function test_sanitize_type() { + $this->assertEquals( 'theme_mod', Kirki_Field::sanitize_type( array( 'option_type' => 'theme_mod' ) ) ); + $this->assertEquals( 'option', Kirki_Field::sanitize_type( array( 'option_type' => 'option' ) ) ); + $this->assertEquals( 'theme_mod', Kirki_Field::sanitize_type( array() ) ); + add_filter( 'kirki/config', function() { + return array( + 'option_type' => 'option', + ); + }); + $this->assertEquals( 'option', Kirki_Field::sanitize_type( array() ) ); + } + + public function test_sanitize_variables() { + $this->assertEquals( false, Kirki_Field::sanitize_variables( array() ) ); + $this->assertEquals( array(), Kirki_Field::sanitize_variables( array( 'variables' => array() ) ) ); + } + + public function test_sanitize_active_callback() { + $this->assertEquals( '__return_true', Kirki_Field::sanitize_active_callback( array( 'active_callback' => '__return_true' ) ) ); + $this->assertEquals( '__return_true', Kirki_Field::sanitize_active_callback( array() ) ); + $this->assertEquals( 'kirki_active_callback', Kirki_Field::sanitize_active_callback( array( 'required' => array() ) ) ); + } + + public function test_sanitize_capability() { + $capabilities = array( + 'activate_plugins', + 'delete_others_pages', + 'delete_others_posts', + 'delete_pages', + 'delete_posts', + 'delete_private_pages', + 'delete_private_posts', + 'delete_published_pages', + 'delete_published_posts', + 'edit_dashboard', + 'edit_others_pages', + 'edit_others_posts', + 'edit_pages', + 'edit_posts', + 'edit_private_pages', + 'edit_private_posts', + 'edit_published_pages', + 'edit_published_posts', + 'edit_theme_options', + 'export', + 'import', + 'list_users', + 'manage_categories', + 'manage_links', + 'manage_options', + 'moderate_comments', + 'promote_users', + 'publish_pages', + 'publish_posts', + 'read_private_pages', + 'read_private_posts', + 'read', + ); + foreach ( $capabilities as $capability ) { + $this->assertEquals( $capability, Kirki_Field::sanitize_capability( array( 'capability' => $capability ) ) ); + } + + $this->assertEquals( 'edit_theme_options', Kirki_Field::sanitize_capability( array() ) ); + + add_filter( 'kirki/config', function() { + return array( + 'capability' => 'activate_plugins', + ); + }); + $this->assertEquals( 'activate_plugins', Kirki_Field::sanitize_capability( array() ) ); + } + + public function test_sanitize_settings_raw() { + $this->assertEquals( 'my_settingsub-setting', Kirki_Field::sanitize_settings_raw( array( 'settings' => 'my_setting[sub-setting]' ) ) ); + $this->assertEquals( 'my_settingsub-setting', Kirki_Field::sanitize_settings_raw( array( 'settings' => 'my_setting["sub-setting"]' ) ) ); + $this->assertEquals( 'my_settingsub-setting', Kirki_Field::sanitize_settings_raw( array( 'settings' => 'my_setting sub-setting' ) ) ); + + $this->assertEquals( 'my_settingsub-setting', Kirki_Field::sanitize_settings_raw( array( 'setting' => 'my_setting sub-setting' ) ) ); + } + + public function test_sanitize_settings() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_settings( array( 'settings' => 'foo' ) ) ); + $this->assertEquals( 'foo[bar]', Kirki_Field::sanitize_settings( array( 'settings' => 'bar', 'option_type' => 'option', 'option_name' => 'foo' ) ) ); + $this->assertEquals( 'foo[bar]', Kirki_Field::sanitize_settings( array( 'settings' => 'foo[bar]' ) ) ); + } + + public function test_sanitize_label() { + $this->assertEquals( 'This is my LABEL', Kirki_Field::sanitize_label( array( 'label' => 'This is my LABEL' ) ) ); + } + + public function test_sanitize_section() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_section( array( 'section' => 'foo' ) ) ); + $this->assertEquals( 'title_tagline', Kirki_Field::sanitize_section( array() ) ); + } + + public function test_sanitize_id() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_id( array( 'settings' => 'foo' ) ) ); + $this->assertEquals( 'foo-bar', Kirki_Field::sanitize_id( array( 'settings' => 'foo[bar]' ) ) ); + $this->assertEquals( 'foo-bar', Kirki_Field::sanitize_id( array( 'settings' => 'foo[ bar ]' ) ) ); + } + + public function test_sanitize_default() { + $this->assertEquals( '
      bar
      ', Kirki_Field::sanitize_default( array( 'type' => 'custom', 'default' => '
      bar
      ' ) ) ); + $this->assertEquals( 'foo', Kirki_Field::sanitize_default( array( 'default' => 'foo' ) ) ); + $this->assertEquals( array( 'foo', 'bar' ), Kirki_Field::sanitize_default( array( 'default' => array( 'foo', 'bar' ) ) ) ); + $this->assertEquals( 'rgba(0,0,0,0)', Kirki_Field::sanitize_default( array( 'default' => 'rgba(0,0,0,0)' ) ) ); + $this->assertEquals( 'foo', Kirki_Field::sanitize_default( array( 'type' => 'text', 'default' => 'foo', ) ) ); + } + + public function test_sanitize_description() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_description( array( 'description' => 'foo' ) ) ); + $this->assertEquals( 'foo', Kirki_Field::sanitize_description( array( 'subtitle' => 'foo' ) ) ); + $this->assertEquals( 'bar', Kirki_Field::sanitize_description( array( 'description' => '
      bar
      ' ) ) ); + $this->assertEquals( '', Kirki_Field::sanitize_description( array() ) ); + } + + public function test_sanitize_help() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_help( array( 'help' => 'foo' ) ) ); + $this->assertEquals( 'bar', Kirki_Field::sanitize_help( array( 'subtitle' => 'foo', 'description' => 'bar' ) ) ); + $this->assertEquals( 'bar', Kirki_Field::sanitize_help( array( 'help' => '
      bar
      ' ) ) ); + $this->assertEquals( '', Kirki_Field::sanitize_help( array( 'subtitle' => 'foo' ) ) ); + } + + public function test_sanitize_choices() { + $this->assertEquals( + array( 'min' => -10, 'max' => 999, 'step' => 3 ), + Kirki_Field::sanitize_choices( + array( 'choices' => array( 'min' => -10, 'max' => 999, 'step' => 3 ) ) + ) + ); + $this->assertEquals( + array( 'foo', 'bar' ), + Kirki_Field::sanitize_choices( array( 'choices' => array( 'foo', 'bar' ) ) ) + ); + $this->assertEquals( array(), Kirki_Field::sanitize_choices( array() ) ); + + $this->assertEquals( 'foo', Kirki_Field::sanitize_choices( array( 'choices' => 'foo' ) ) ); + } + + public function test_sanitize_output() { + $this->assertEquals( 'foo', Kirki_Field::sanitize_output( array( 'output' => 'foo' ) ) ); + $this->assertEquals( + array( + array( + 'element' => 'body > #main', + 'property' => 'font-family', + 'units' => '', + 'media_query' => 'global', + ) + ), + Kirki_Field::sanitize_output( array( 'output' => array( + 'element' => 'body > #main', + 'property' => 'font-family', + ) ) ) + ); + $this->assertEquals( + array( + array( + 'element' => 'body > #main', + 'property' => 'font-size', + 'units' => 'px !important', + 'media_query' => '@media (min-width: 700px) and (orientation: landscape)', + ) + ), + Kirki_Field::sanitize_output( array( 'output' => array( + array( + 'element' => 'body > #main', + 'property' => 'font-size', + 'units' => 'px !important', + 'prefix' => '@media (min-width: 700px) and (orientation: landscape) {', + 'suffix' => '}', + ) + ) ) ) + ); + } + + public function test_sanitize_transport() { + $this->assertEquals( 'refresh', Kirki_Field::sanitize_transport( array() ) ); + $this->assertEquals( 'refresh', Kirki_Field::sanitize_transport( array( 'transport' => '' ) ) ); + $this->assertEquals( 'refresh', Kirki_Field::sanitize_transport( array( 'transport' => 'invalid' ) ) ); + $this->assertEquals( 'postMessage', Kirki_Field::sanitize_transport( array( 'transport' => 'postMessage' ) ) ); + } + + public function test_sanitize_callback() { + $this->assertEquals( '__return_true', Kirki_Field::sanitize_callback( array( 'sanitize_callback' => '__return_true' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::sanitize_callback( array( 'type' => 'checkbox' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'color' ), Kirki_Field::sanitize_callback( array( 'type' => 'color-alpha' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'color' ), Kirki_Field::sanitize_callback( array( 'type' => 'color' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'unfiltered' ), Kirki_Field::sanitize_callback( array( 'type' => 'custom' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'dropdown_pages' ), Kirki_Field::sanitize_callback( array( 'type' => 'dropdown-pages' ) ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::sanitize_callback( array( 'type' => 'editor' ) ) ); + $this->assertEquals( 'esc_url_raw', Kirki_Field::sanitize_callback( array( 'type' => 'image' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'multicheck' ), Kirki_Field::sanitize_callback( array( 'type' => 'multicheck' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'number' ), Kirki_Field::sanitize_callback( array( 'type' => 'number' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::sanitize_callback( array( 'type' => 'palette' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::sanitize_callback( array( 'type' => 'radio-buttonset' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::sanitize_callback( array( 'type' => 'radio-image' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::sanitize_callback( array( 'type' => 'radio' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::sanitize_callback( array( 'type' => 'select' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'number' ), Kirki_Field::sanitize_callback( array( 'type' => 'slider' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'sortable' ), Kirki_Field::sanitize_callback( array( 'type' => 'sortable' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::sanitize_callback( array( 'type' => 'switch' ) ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::sanitize_callback( array( 'type' => 'text' ) ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::sanitize_callback( array( 'type' => 'textarea' ) ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::sanitize_callback( array( 'type' => 'toggle' ) ) ); + $this->assertEquals( 'esc_url_raw', Kirki_Field::sanitize_callback( array( 'type' => 'upload' ) ) ); + } + + public function test_sanitize_js_vars() { + $this->assertEquals( null, Kirki_Field::sanitize_js_vars( array() ) ); + $this->assertEquals( null, Kirki_Field::sanitize_js_vars( array( 'js_vars' => 'foo' ) ) ); + $this->assertEquals( + array( + array( + 'element' => '#main', + 'function' => 'css', + 'property' => 'color', + 'units' => '', + ) + ), + Kirki_Field::sanitize_js_vars( array( 'js_vars' => array( + 'element' => '#main', + 'function' => 'css', + 'property' => 'color', + ) ) ) + ); + $this->assertEquals( + array( + array( + 'element' => 'body > #main', + 'function' => 'css', + 'property' => 'font-size', + 'units' => 'px' + ) + ), + Kirki_Field::sanitize_js_vars( array( 'js_vars' => array( + array( + 'element' => 'body > #main', + 'function' => 'css', + 'property' => 'font-size', + 'units' => 'px' + ) + ) ) ) + ); + } + + public function test_sanitize_required() { + $this->assertEquals( + array( + array( + 'setting' => 'my-setting', + 'operator' => '==', + 'value' => '1', + ) + ), + Kirki_Field::sanitize_required( array( 'required' => array( + 'setting' => 'my-setting', + ) ) ) + ); + $this->assertEquals( + array( + array( + 'setting' => 'my-setting', + 'operator' => '>=', + 'value' => '#333ff2' + ) + ), + Kirki_Field::sanitize_required( array( 'required' => array( + array( + 'setting' => 'my-setting', + 'operator' => '>=', + 'value' => '#333ff2' + ) + ) ) ) + ); + + $this->assertEquals( null, Kirki_Field::sanitize_required( array() ) ); + } + + public function test_sanitize_priority() { + $this->assertEquals( 10, Kirki_Field::sanitize_priority( array() ) ); + $this->assertEquals( 10, Kirki_Field::sanitize_priority( array( 'priority' => 'invalid priority' ) ) ); + $this->assertEquals( 20, Kirki_Field::sanitize_priority( array( 'priority' => '-20' ) ) ); + $this->assertEquals( 20, Kirki_Field::sanitize_priority( array( 'priority' => -20 ) ) ); + $this->assertEquals( 20, Kirki_Field::sanitize_priority( array( 'priority' => 20 ) ) ); + $this->assertEquals( 20, Kirki_Field::sanitize_priority( array( 'priority' => 20.356 ) ) ); + $this->assertEquals( 20, Kirki_Field::sanitize_priority( array( 'priority' => '20.356' ) ) ); + } + + public function test_fallback_callback() { + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::fallback_callback( 'checkbox' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'color' ), Kirki_Field::fallback_callback( 'color-alpha' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'color' ), Kirki_Field::fallback_callback( 'color' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'unfiltered' ), Kirki_Field::fallback_callback( 'custom' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'dropdown_pages' ), Kirki_Field::fallback_callback( 'dropdown-pages' ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::fallback_callback( 'editor' ) ); + $this->assertEquals( 'esc_url_raw', Kirki_Field::fallback_callback( 'image' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'multicheck' ), Kirki_Field::fallback_callback( 'multicheck' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'number' ), Kirki_Field::fallback_callback( 'number' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::fallback_callback( 'palette' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::fallback_callback( 'radio-buttonset' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::fallback_callback( 'radio-image' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::fallback_callback( 'radio' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'choice' ), Kirki_Field::fallback_callback( 'select' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'number' ), Kirki_Field::fallback_callback( 'slider' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'sortable' ), Kirki_Field::fallback_callback( 'sortable' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::fallback_callback( 'switch' ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::fallback_callback( 'text' ) ); + $this->assertEquals( 'esc_textarea', Kirki_Field::fallback_callback( 'textarea' ) ); + $this->assertEquals( array( 'Kirki_Sanitize', 'checkbox' ), Kirki_Field::fallback_callback( 'toggle' ) ); + $this->assertEquals( 'esc_url_raw', Kirki_Field::fallback_callback( 'upload' ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-functions.php b/includes/plugins/kirki/tests/test-kirki-functions.php new file mode 100644 index 0000000..7bb7541 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-functions.php @@ -0,0 +1,18 @@ +assertEquals( KIRKI_PATH, kirki_path() ); + } + + public function test_kirki_url() { + $this->assertEquals( KIRKI_URL, kirki_url() ); + add_filter( 'kirki/config', function( $config ) { + $config['url_path'] = get_stylesheet_directory_uri().'/inc'; + return $config; + }); + $this->assertEquals( get_stylesheet_directory_uri().'/inc', kirki_url() ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-output.php b/includes/plugins/kirki/tests/test-kirki-output.php new file mode 100644 index 0000000..7e56e65 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-output.php @@ -0,0 +1,159 @@ +assertEquals( + '@media (min-width: 700px){body > #foo{background-color:#333!important;}body > #foo a:after{color:#333;}}#bar{color:#333;}', + Kirki_Output::css( + 'foo', + 'theme_mod', + array( + array( + 'element' => 'body > #foo', + 'property' => 'background-color', + 'units' => '!important', + 'prefix' => '@media (min-width: 700px) {', + 'suffix' => '}', + ), + array( + 'element' => '#bar', + 'property' => 'color', + ), + array( + 'element' => 'body > #foo a:after', + 'property' => 'color', + 'media_query' => '@media (min-width: 700px)', + ), + ), + '' + ) + ); + } + + public function test_css() { + $this->assertEquals( null, Kirki_Output::css() ); + set_theme_mod( 'foo', '3' ); + $this->assertEquals( 'body{font-size:6px;}', + Kirki_Output::css( + 'foo', + 'theme_mod', + array( array( + 'element' => 'body', + 'property' => 'font-size', + 'units' => 'px', + + ) ), + array( $this, 'timestwo' ) + ) + ); + + set_theme_mod( 'foo', 'http://foo.com/bar.png' ); + $this->assertEquals( 'body{background-image:url("http://foo.com/bar.png");}', + Kirki_Output::css( + 'foo', + 'theme_mod', + array( array( + 'element' => 'body', + 'property' => 'background-image', + + ) ), + '' + ) + ); + + set_theme_mod( 'foo', 'left-top' ); + $this->assertEquals( 'body{background-position:left top;}', + Kirki_Output::css( + 'foo', + 'theme_mod', + array( array( + 'element' => 'body', + 'property' => 'background-position', + + ) ), + '' + ) + ); + } + + public function test_add_prefixes() { + $this->assertEquals( null, Kirki_Output::add_prefixes( '' ) ); + $css = array(); + $css['global']['body']['border-radius'] = '3px'; + $css['global']['body']['box-shadow'] = '10px 10px 5px 0px rgba(0,0,0,0.75)'; + $css['global']['body']['box-sizing'] = 'border-box'; + $css['global']['body']['text-shadow'] = '0'; + $css['global']['body']['transform'] = 'rotate(30deg)'; + $css['global']['body']['background-size'] = 'cover'; + $css['global']['body']['transition'] = 'width 1s'; + $css['global']['body']['transition-property'] = 'width'; + $this->assertEquals( + array( 'global' => array( 'body' => array( + 'border-radius' => '3px', + '-moz-border-radius' => '3px', + '-webkit-border-radius' => '3px', + 'box-shadow' => '10px 10px 5px 0px rgba(0,0,0,0.75)', + '-moz-box-shadow' => '10px 10px 5px 0px rgba(0,0,0,0.75)', + '-webkit-box-shadow' => '10px 10px 5px 0px rgba(0,0,0,0.75)', + 'box-sizing' => 'border-box', + '-moz-box-sizing' => 'border-box', + '-webkit-box-sizing' => 'border-box', + 'text-shadow' => '0', + '-moz-text-shadow' => '0', + '-webkit-text-shadow' => '0', + 'transform' => 'rotate(30deg)', + '-moz-transform' => 'rotate(30deg)', + '-webkit-transform' => 'rotate(30deg)', + '-ms-transform' => 'rotate(30deg)', + '-o-transform' => 'rotate(30deg)', + 'background-size' => 'cover', + '-moz-background-size' => 'cover', + '-webkit-background-size' => 'cover', + '-ms-background-size' => 'cover', + '-o-background-size' => 'cover', + 'transition' => 'width 1s', + '-moz-transition' => 'width 1s', + '-webkit-transition' => 'width 1s', + '-ms-transition' => 'width 1s', + '-o-transition' => 'width 1s', + 'transition-property' => 'width', + '-moz-transition-property' => 'width', + '-webkit-transition-property' => 'width', + '-ms-transition-property' => 'width', + '-o-transition-property' => 'width', + ) ) ), + Kirki_Output::add_prefixes( $css ) + ); + } + + public function test_css_option() { + update_option( 'foo', '#333' ); + $this->assertEquals( + '@media (min-width: 700px) and (orientation: landscape){body > #foo{background-color:#333!important;}}#bar{color:#333;}', + Kirki_Output::css( + 'foo', + 'option', + array( + array( + 'element' => 'body > #foo', + 'property' => 'background-color', + 'units' => '!important', + 'prefix' => '@media (min-width: 700px) and (orientation: landscape) {', + 'suffix' => '}', + ), + array( + 'element' => '#bar', + 'property' => 'color', + ), + ), null + ) + ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-scripts-customizer-branding.php b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-branding.php new file mode 100644 index 0000000..a269f20 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-branding.php @@ -0,0 +1,35 @@ + 'http://foo.com/bar.png', + 'description' => 'Lorem ipsum dolor sit amet', + ); + }); + $this->assertEquals( + '$( \'div#customize-info .preview-notice\' ).replaceWith( \'\' );$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'
      Lorem ipsum dolor sit amet
      \' );', + Kirki()->scripts->branding->generate_script() + ); + } + + public function test_customize_controls_print_scripts() { + add_filter( 'kirki/config', function() { + return array(); + }); + $this->expectOutputString( '' ); + print ''; + + add_filter( 'kirki/config', function() { + return array( + 'logo_image' => 'http://foo.com/bar.png', + 'description' => 'Lorem ipsum dolor sit amet', + ); + }); + $script = '$( \'div#customize-info .preview-notice\' ).replaceWith( \'\' );$( \'div#customize-info .accordion-section-content\' ).replaceWith( \'
      Lorem ipsum dolor sit amet
      \' );'; + $this->expectOutputString( '' ); + Kirki()->scripts->branding->customize_controls_print_scripts(); + } +} diff --git a/includes/plugins/kirki/tests/test-kirki-scripts-customizer-postmessage.php b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-postmessage.php new file mode 100644 index 0000000..51f93a7 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-postmessage.php @@ -0,0 +1,44 @@ + 'body', + 'function' => 'css', + 'property' => 'color', + ); + Kirki::add_field( '', array( 'settings' => 'foo', 'type' => 'text', 'transport' => 'postMessage', 'js_vars' => $js_vars ) ); + set_theme_mod( 'foo', '#333' ); + $wp_customize = $this->init_customizer(); + + $this->assertEquals( + 'wp.customize( \'foo\', function( value ) {value.bind( function( newval ) {$(\'body\').css(\'color\', newval );}); });', + Kirki()->scripts->postmessage->generate_script() + ); + + $js_vars = array( + 'element' => 'body', + 'function' => 'html', + ); + Kirki::add_field( '', array( 'settings' => 'foo', 'type' => 'text', 'transport' => 'postMessage', 'js_vars' => $js_vars ) ); + set_theme_mod( 'foo', 'this is a string' ); + $wp_customize = $this->init_customizer(); + + $this->assertEquals( + 'wp.customize( \'foo\', function( value ) {value.bind( function( newval ) {$(\'body\').html( newval );}); });', + Kirki()->scripts->postmessage->generate_script() + ); + } +} diff --git a/includes/plugins/kirki/tests/test-kirki-scripts-customizer-tooltips.php b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-tooltips.php new file mode 100644 index 0000000..4985b2d --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-scripts-customizer-tooltips.php @@ -0,0 +1,29 @@ + 'foo', + 'type' => 'text', + 'section' => 'bar', + 'help' => 'Lorem Ipsum', + ) ); + $this->assertEquals( + '$( "" ).prependTo( "#customize-control-foo" );', + Kirki()->scripts->tooltips->generate_script() + ); + } + + public function test_customize_controls_print_scripts() { + Kirki::add_field( '', array( + 'settings' => 'foo', + 'type' => 'text', + 'section' => 'bar', + 'help' => 'Lorem Ipsum', + ) ); + $script = '$( "" ).prependTo( "#customize-control-foo" );'; + $this->expectOutputString( '' ); + Kirki()->scripts->tooltips->customize_controls_print_footer_scripts(); + } +} diff --git a/includes/plugins/kirki/tests/test-kirki-scripts-frontend-google-fonts.php b/includes/plugins/kirki/tests/test-kirki-scripts-frontend-google-fonts.php new file mode 100644 index 0000000..f0240e4 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-scripts-frontend-google-fonts.php @@ -0,0 +1,152 @@ + 'select', + 'setting' => 'font_family', + 'label' => __( 'Font Family', 'example' ), + 'section' => 'base_typography', + 'default' => 'Roboto', + 'priority' => 20, + 'choices' => Kirki_Fonts::get_font_choices(), + 'output' => array( + 'element' => 'body', + 'property' => 'font-family', + ), + ) ); + } + + public function add_font_subsets_field() { + Kirki::add_field( '', array( + 'type' => 'multicheck', + 'setting' => 'subsets', + 'label' => __( 'Google-Font subsets', 'example' ), + 'description' => __( 'The subsets used from Google\'s API.', 'example' ), + 'section' => 'base_typography', + 'default' => 'all', + 'priority' => 22, + 'choices' => Kirki_Fonts::get_google_font_subsets(), + 'output' => array( + 'element' => 'body', + 'property' => 'font-subset', + ), + ) ); + } + + public function add_font_weight_field() { + Kirki::add_field( '', array( + 'type' => 'slider', + 'setting' => 'font_weight', + 'label' => __( 'Font Weight', 'example' ), + 'section' => 'base_typography', + 'default' => 300, + 'priority' => 24, + 'choices' => array( + 'min' => 100, + 'max' => 900, + 'step' => 100, + ), + 'output' => array( + 'element' => 'body', + 'property' => 'font-weight', + ), + ) ); + } + + public function test_google_link_font_family_roboto() { + $this->add_font_family_field(); + set_theme_mod( 'font_family', 'Roboto' ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Roboto:regular,italic,700,400&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese' + ); + } + + public function test_google_link_font_family_open_sans() { + $this->add_font_family_field(); + set_theme_mod( 'font_family', 'Open Sans' ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Open+Sans:regular,italic,700,400&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese' + ); + } + + public function test_google_link_font_subset_roboto() { + $this->add_font_family_field(); + $this->add_font_subsets_field(); + set_theme_mod( 'font_family', 'Roboto' ); + set_theme_mod( 'subsets', 'greek' ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Roboto:regular,italic,700,400&subset=greek' + ); + } + + public function test_google_link_font_subset_open_sans() { + $this->add_font_family_field(); + $this->add_font_subsets_field(); + set_theme_mod( 'font_family', 'Open Sans' ); + set_theme_mod( 'subsets', 'devangari' ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Open+Sans:regular,italic,700,400&subset=devangari' + ); + } + + public function test_google_link_font_combo_roboto() { + $this->add_font_family_field(); + $this->add_font_subsets_field(); + $this->add_font_weight_field(); + set_theme_mod( 'font_family', 'Roboto' ); + set_theme_mod( 'subsets', 'greek' ); + set_theme_mod( 'font_weight', '900' ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Roboto:regular,italic,700,900&subset=greek' + ); + } + + public function test_google_link_font_combo_open_sans() { + $this->add_font_family_field(); + $this->add_font_subsets_field(); + $this->add_font_weight_field(); + set_theme_mod( 'font_family', 'Open Sans' ); + set_theme_mod( 'subsets', 'devangari' ); + set_theme_mod( 'font_weight', 100 ); + $googlefonts = new Kirki_Scripts_Frontend_Google_Fonts(); + $link = $googlefonts->google_link(); + $this->assertEquals( + $link, + '//fonts.googleapis.com/css?family=Open+Sans:regular,italic,700,100&subset=devangari' + ); + } + + public function test_google_font_enqueued() { + $this->add_font_family_field(); + $this->add_font_subsets_field(); + $this->add_font_weight_field(); + set_theme_mod( 'font_family', 'Open Sans' ); + set_theme_mod( 'subsets', 'devangari' ); + set_theme_mod( 'font_weight', 100 ); + + Kirki(); + + $this->go_to( home_url() ); + do_action( 'wp_enqueue_scripts' ); + $styles = $GLOBALS['wp_styles']->registered; + $this->assertTrue( isset( $styles['kirki_google_fonts'] ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-styles-customizer.php b/includes/plugins/kirki/tests/test-kirki-styles-customizer.php new file mode 100644 index 0000000..f530065 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-styles-customizer.php @@ -0,0 +1,26 @@ +registered; + $this->assertTrue( isset( $styles['kirki-customizer-css'] ) ); + } + + public function test_custom_css() { + add_filter( 'kirki/config', function( $config ) { + $config['color_accent'] = '#00bcd4'; + $config['color_back'] = '#455a64'; + $config['width'] = '20%'; + return $config; + }); + + do_action( 'customize_controls_print_styles' ); + $this->assertTrue( false !== strpos( Kirki()->styles['back']->custom_css(), '#00bcd4' ) ); + $this->assertTrue( false !== strpos( Kirki()->styles['back']->custom_css(), '#455a64' ) ); + $this->assertTrue( false !== strpos( Kirki()->styles['back']->custom_css(), '20%' ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-kirki-toolkit.php b/includes/plugins/kirki/tests/test-kirki-toolkit.php new file mode 100644 index 0000000..800e79f --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki-toolkit.php @@ -0,0 +1,32 @@ +assertTrue( is_object( Kirki()->font_registry ) ); + } + + function test_scripts() { + $this->assertTrue( is_object( Kirki()->scripts ) ); + } + + function test_api() { + $this->assertTrue( is_object( Kirki()->api ) ); + } + + function test_styles() { + $this->assertTrue( is_array( Kirki()->styles ) ); + } + + function test_styles_back() { + $this->assertTrue( is_object( Kirki()->styles['back'] ) ); + } + + function test_styles_front() { + $this->assertTrue( is_object( Kirki()->styles['front'] ) ); + } + + function test_i18n() { + $this->assertTrue( is_array( Kirki_Toolkit::i18n() ) ); + } +} diff --git a/includes/plugins/kirki/tests/test-kirki.php b/includes/plugins/kirki/tests/test-kirki.php new file mode 100644 index 0000000..4836970 --- /dev/null +++ b/includes/plugins/kirki/tests/test-kirki.php @@ -0,0 +1,217 @@ + 'option', + 'option_name' => 'my_option', + 'capability' => 'edit_posts', + ) ); + Kirki::add_config( 'my_config2', array( + 'option_type' => 'theme_mod', + 'capability' => 'edit_posts', + ) ); + Kirki::add_config( 'my_config3', array( + 'option_type' => 'option', + 'capability' => 'edit_posts', + ) ); + } + + public function add_panel() { + Kirki::add_panel( 'panel_id', array( + 'priority' => 10, + 'title' => 'My Title', + 'description' => 'My Description', + ) ); + } + + public function add_section() { + Kirki::add_section( 'section_id', array( + 'title' => 'My Title', + 'description' => 'My Description', + 'panel' => 'panel_id', + 'priority' => 160, + 'capability' => 'edit_theme_options', + ) ); + } + + public function add_field() { + + Kirki::add_field( 'my_config', array( + 'settings' => 'my_setting', + 'label' => __( 'My custom control', 'translation_domain' ), + 'section' => 'my_section', + 'type' => 'text', + 'priority' => 10, + 'default' => 'some-default-value', + ) ); + + Kirki::add_field( 'my_config', array( + 'settings' => 'my_setting0', + 'label' => __( 'My custom control', 'translation_domain' ), + 'section' => 'my_section', + 'type' => 'text', + 'priority' => 10, + 'default' => 'some-default-value', + ) ); + + Kirki::add_field( 'my_config2', array( + 'settings' => 'my_setting1', + 'label' => __( 'My custom control', 'translation_domain' ), + 'section' => 'my_section', + 'type' => 'text', + 'priority' => 10, + 'default' => 'some-default-value', + ) ); + + Kirki::add_field( 'my_config3', array( + 'settings' => 'my_setting2', + 'label' => __( 'My custom control', 'translation_domain' ), + 'section' => 'my_section', + 'type' => 'text', + 'priority' => 10, + 'default' => 'some-default-value', + ) ); + + Kirki::add_field( 'my_config', array( + 'settings' => 'my_setting_2', + 'label' => __( 'My custom control 2', 'translation_domain' ), + 'section' => 'my_section', + 'type' => 'checkbox', + 'priority' => 20, + 'default' => '1', + 'capability' => 'edit_theme_options', + + ) ); + + } + + function add_controls_via_filter( $fields ) { + + // Add the controls + $fields[] = array( + 'label' => __( 'My custom control', 'translation_domain' ), + 'section' => 'my_section', + 'settings' => 'my_setting_3', + 'type' => 'text', + 'priority' => 10, + 'options_type' => 'theme_mod', + 'capability' => 'edit_posts', + 'default' => 'some-default-value', + ); + + $fields[] = array( + 'label' => __( 'My custom control 2', 'translation_domain' ), + 'section' => 'my_section', + 'settings' => 'my_setting_4', + 'type' => 'checkbox', + 'priority' => 20, + 'options_type' => 'theme_mod', + 'capability' => 'edit_theme_options', + 'default' => '0', + ); + + return $fields; + + } + + public function test_config() { + $this->add_config(); + // Default config + $this->assertArrayHasKey( 'global', Kirki::$config ); + $this->assertEquals( 'edit_theme_options', Kirki::$config['global']['capability'] ); + $this->assertEquals( 'theme_mod', Kirki::$config['global']['option_type'] ); + // Custom config + $this->assertArrayHasKey( 'my_config', Kirki::$config ); + $this->assertEquals( 'edit_posts', Kirki::$config['my_config']['capability'] ); + $this->assertEquals( 'option', Kirki::$config['my_config']['option_type'] ); + $this->assertEquals( 'my_option', Kirki::$config['my_config']['option_name'] ); + } + + public function test_panels() { + $this->add_panel(); + $this->assertArrayHasKey( 'panel_id', Kirki::$panels ); + $this->assertEquals( 'panel_id', Kirki::$panels['panel_id']['id'] ); + $this->assertEquals( 10, Kirki::$panels['panel_id']['priority'] ); + $this->assertEquals( 'My Title', Kirki::$panels['panel_id']['title'] ); + $this->assertEquals( 'My Description', Kirki::$panels['panel_id']['description'] ); + } + + public function test_sections() { + $this->add_section(); + $this->assertArrayHasKey( 'section_id', Kirki::$sections ); + $this->assertEquals( 'section_id', Kirki::$sections['section_id']['id'] ); + $this->assertEquals( 160, Kirki::$sections['section_id']['priority'] ); + $this->assertEquals( 'My Title', Kirki::$sections['section_id']['title'] ); + $this->assertEquals( 'My Description', Kirki::$sections['section_id']['description'] ); + } + + public function test_fields() { + $this->add_config(); + $this->add_field(); + // my_setting + $this->assertArrayHasKey( 'my_setting', Kirki::$fields ); + $this->assertEquals( 'My custom control', Kirki::$fields['my_setting']['label'] ); + $this->assertEquals( 'my_section', Kirki::$fields['my_setting']['section'] ); + $this->assertEquals( 'text', Kirki::$fields['my_setting']['type'] ); + $this->assertEquals( 10, Kirki::$fields['my_setting']['priority'] ); + $this->assertEquals( 'some-default-value', Kirki::$fields['my_setting']['default'] ); + $this->assertEquals( 'edit_posts', Kirki::$fields['my_setting']['capability'] ); + // Inherited from config + $this->assertEquals( 'option', Kirki::$fields['my_setting']['option_type'] ); + + // my_setting + $this->assertArrayHasKey( 'my_setting_2', Kirki::$fields ); + $this->assertEquals( 'My custom control 2', Kirki::$fields['my_setting_2']['label'] ); + $this->assertEquals( 'my_section', Kirki::$fields['my_setting_2']['section'] ); + $this->assertEquals( 'checkbox', Kirki::$fields['my_setting_2']['type'] ); + $this->assertEquals( 20, Kirki::$fields['my_setting_2']['priority'] ); + $this->assertEquals( '1', Kirki::$fields['my_setting_2']['default'] ); + // Inherited from config + $this->assertEquals( 'edit_theme_options', Kirki::$fields['my_setting_2']['capability'] ); + $this->assertEquals( 'option', Kirki::$fields['my_setting_2']['option_type'] ); + } + + public function test_fields_via_filter() { + add_filter( 'kirki/fields', array( $this, 'add_controls_via_filter' ) ); + do_action( 'wp_loaded' ); + + // my_setting + $this->assertArrayHasKey( 'my_setting', Kirki::$fields ); + $this->assertEquals( 'My custom control', Kirki::$fields['my_setting_3']['label'] ); + $this->assertEquals( 'my_section', Kirki::$fields['my_setting_3']['section'] ); + $this->assertEquals( 'text', Kirki::$fields['my_setting_3']['type'] ); + $this->assertEquals( 10, Kirki::$fields['my_setting_3']['priority'] ); + $this->assertEquals( 'some-default-value', Kirki::$fields['my_setting_3']['default'] ); + $this->assertEquals( 'edit_posts', Kirki::$fields['my_setting_3']['capability'] ); + + // my_setting + $this->assertArrayHasKey( 'my_setting_2', Kirki::$fields ); + $this->assertEquals( 'My custom control 2', Kirki::$fields['my_setting_4']['label'] ); + $this->assertEquals( 'my_section', Kirki::$fields['my_setting_4']['section'] ); + $this->assertEquals( 'checkbox', Kirki::$fields['my_setting_4']['type'] ); + $this->assertEquals( 20, Kirki::$fields['my_setting_4']['priority'] ); + $this->assertEquals( '0', Kirki::$fields['my_setting_4']['default'] ); + } + + public function test_get_option() { + $this->add_config(); + $this->add_field(); + $this->assertEquals( 'some-default-value', Kirki::get_option( 'my_config', 'my_setting0' ) ); + $this->assertEquals( 'some-default-value', Kirki::get_option( 'my_config2', 'my_setting1' ) ); + $this->assertEquals( 'some-default-value', Kirki::get_option( 'my_config3', 'my_setting2' ) ); + } + +} diff --git a/includes/plugins/kirki/tests/test-textdomain.php b/includes/plugins/kirki/tests/test-textdomain.php new file mode 100644 index 0000000..79d6f7b --- /dev/null +++ b/includes/plugins/kirki/tests/test-textdomain.php @@ -0,0 +1,12 @@ +assertEquals( 10, has_action( 'plugins_loaded', 'kirki_load_textdomain' ) ); + global $l10n; + $this->assertEquals( true, isset( $l10n['kirki'] ) ); + } + +}