Update to Kirki 4.0.22

This commit is contained in:
AlxMedia 2022-03-15 14:29:17 +01:00
parent 2b6ac38550
commit 78edeb1b25
492 changed files with 29668 additions and 39884 deletions

View file

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 kirki-framework
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View file

@ -0,0 +1,2 @@
.customize-control-kirki[data-kirki-parent-control-type=kirki-typography]{margin-bottom:10px}.customize-control-kirki[data-kirki-parent-control-type=kirki-typography] .customize-control-title{font-size:12px;font-weight:500;margin-bottom:0}.customize-control-kirki[data-kirki-typography-css-prop=text-decoration]{margin-bottom:15px}.kirki-typography-end{margin-bottom:8px;margin-top:8px}.kirki-typography-end hr{margin-bottom:0;margin-top:0}
/*# sourceMappingURL=control.css.map */

View file

@ -0,0 +1,2 @@
!function(){function t(t,i){var n=wp.customize.control(t);if(void 0!==n){var o=(i=i||n.setting.get())["font-family"]&&kirkiGoogleFonts.items[i["font-family"]],a=i.variant?i.variant.toString():"regular",e=wp.customize.control(t+"[variant]"),r=[];if(o){var l=kirkiGoogleFonts.items[i["font-family"]].variants;l.sort((function(t,i){return t<i?-1:t>i?1:0})),kirkiFontVariants.complete.forEach((function(t){-1!==l.indexOf(t.value)&&r.push({value:t.value,label:t.label})}))}else{var c=t.replace(/]/g,"");c=c.replace(/\[/g,"_"),r=kirkiCustomVariants[c][i["font-family"]]?kirkiCustomVariants[c][i["font-family"]]:kirkiFontVariants.standard}-1!==a.indexOf("i")?i["font-style"]="italic":i["font-style"]="normal",i["font-weight"]="regular"===a||"italic"===a?400:parseInt(a,10),e&&(1<r.length&&n.active()?e.activate():e.deactivate(),e.params.choices=r,e.formattedOptions=[],e.destroy(),r.includes(a)?e.doSelectAction("selectOption",a):e.doSelectAction("selectOption","regular")),wp.hooks.addAction("kirki.dynamicControl.initKirkiControl","kirki",(function(t){e&&t.id}))}}jQuery(document).ready((function(){_.each(kirkiTypographyControls,(function(i){t(i),wp.customize(i,(function(n){n.bind((function(n){t(i,n)}))}))}))}))}();
//# sourceMappingURL=control.js.map

View file

@ -0,0 +1,2 @@
jQuery(document).ready((function(){wp.hooks.addFilter("kirkiPostMessageStylesOutput","kirki",(function(i,a,e,t){var n,r="";return a.variant&&(a["font-weight"]="regular"===a.variant||"italic"===a.variant?400:parseInt(a.variant,10),a["font-style"]=a.variant.includes("italic")?"italic":"normal"),"kirki-typography"===t&&(i+=e.element+"{",_.each(a,(function(a,t){e.choice&&t!==e.choice||"variant"!==t&&!1!==(n=window.kirkiPostMessage.util.processValue(e,a))&&(i+=t+":"+n+";")})),i+="}",!_.isUndefined(window.WebFont)&&a["font-family"]&&kirkiGoogleFontNames.includes(a["font-family"])&&(r=a["font-family"].replace(/\"/g,"&quot;"),a.variant&&("regular"===a.variant?r+=":400":"italic"===a.variant?r+=":400i":r+=":"+a.variant),r+=":cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai",window.WebFont.load({google:{families:[r]}}))),i}))}));
//# sourceMappingURL=preview.js.map

View file

@ -0,0 +1,95 @@
<?php
/**
* Handles CSS output for typography fields.
*
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
namespace Kirki\Field\CSS;
use Kirki\Module\CSS\Output;
/**
* Output overrides.
*/
class Typography extends Output {
/**
* Processes a single item from the `output` array.
*
* @access protected
* @param array $output The `output` item.
* @param array $value The field's value.
*/
protected function process_output( $output, $value ) {
$output['media_query'] = ( isset( $output['media_query'] ) ) ? $output['media_query'] : 'global';
$output['element'] = ( isset( $output['element'] ) ) ? $output['element'] : 'body';
$output['prefix'] = ( isset( $output['prefix'] ) ) ? $output['prefix'] : '';
$output['suffix'] = ( isset( $output['suffix'] ) ) ? $output['suffix'] : '';
$properties = [
'font-family',
'font-size',
'variant',
'font-weight',
'font-style',
'letter-spacing',
'word-spacing',
'line-height',
'text-align',
'text-transform',
'text-decoration',
'color',
'margin-top',
'margin-bottom',
];
foreach ( $properties as $property ) {
// Early exit if the value is not in the defaults.
if ( ! isset( $this->field['default'][ $property ] ) ) {
continue;
}
// Early exit if the value is not saved in the values.
if ( ! isset( $value[ $property ] ) || ! $value[ $property ] ) {
continue;
}
// Early exit if we use "choice" but not for this property.
if ( isset( $output['choice'] ) && $output['choice'] !== $property ) {
continue;
}
// Take care of variants.
if ( 'variant' === $property && isset( $value['variant'] ) && ! empty( $value['variant'] ) ) {
// Get the font_weight.
$font_weight = str_replace( 'italic', '', $value['variant'] );
$font_weight = ( in_array( $font_weight, [ '', 'regular' ], true ) ) ? '400' : $font_weight;
// Is this italic?
$is_italic = ( false !== strpos( $value['variant'], 'italic' ) );
$this->styles[ $output['media_query'] ][ $output['element'] ]['font-weight'] = $font_weight;
if ( $is_italic ) {
$this->styles[ $output['media_query'] ][ $output['element'] ]['font-style'] = 'italic';
}
continue;
}
$property_value = $this->process_property_value( $property, $value[ $property ] );
$property = ( isset( $output['choice'] ) && isset( $output['property'] ) ) ? $output['property'] : $property;
$property_value = ( is_array( $property_value ) && isset( $property_value[0] ) ) ? $property_value[0] : $property_value;
$this->styles[ $output['media_query'] ][ $output['element'] ][ $property ] = $output['prefix'] . $property_value . $output['suffix'];
}
}
}

View file

@ -0,0 +1,105 @@
import "./control.scss";
/* global kirkiTypographyControls, kirkiGoogleFonts, kirkiFontVariants */
function kirkiTypographyCompositeControlFontProperties(id, value) {
const control = wp.customize.control(id);
if ("undefined" === typeof control) {
return;
}
value = value || control.setting.get();
const isGoogle =
value["font-family"] && kirkiGoogleFonts.items[value["font-family"]];
const variantValue = value["variant"]
? value["variant"].toString()
: "regular";
const variantControl = wp.customize.control(id + "[variant]");
const sortVariants = function (a, b) {
if (a < b) return -1;
if (a > b) return 1;
return 0;
};
let variants = [];
if (isGoogle) {
let gFontVariants = kirkiGoogleFonts.items[value["font-family"]].variants;
gFontVariants.sort(sortVariants);
kirkiFontVariants.complete.forEach(function (variant) {
if (-1 !== gFontVariants.indexOf(variant.value)) {
variants.push({
value: variant.value,
label: variant.label,
});
}
});
} else {
let customVariantKey = id.replace(/]/g, '');
customVariantKey = customVariantKey.replace(/\[/g, '_');
if (kirkiCustomVariants[customVariantKey][value["font-family"]]) {
variants = kirkiCustomVariants[customVariantKey][value["font-family"]];
} else {
variants = kirkiFontVariants.standard;
}
}
// Set the font-style value.
if (-1 !== variantValue.indexOf("i")) {
value["font-style"] = "italic";
} else {
value["font-style"] = "normal";
}
// Set the font-weight value.
value["font-weight"] =
"regular" === variantValue || "italic" === variantValue
? 400
: parseInt(variantValue, 10);
if (variantControl) {
// Hide/show variant options depending on which are available for this font-family.
if (1 < variants.length && control.active()) {
variantControl.activate();
} else {
// If there's only 1 variant to choose from, we can hide the control.
variantControl.deactivate();
}
variantControl.params.choices = variants;
variantControl.formattedOptions = [];
variantControl.destroy();
if (!variants.includes(variantValue)) {
// If the selected font-family doesn't support the currently selected variant, switch to "regular".
variantControl.doSelectAction("selectOption", "regular");
} else {
variantControl.doSelectAction("selectOption", variantValue);
}
}
wp.hooks.addAction(
"kirki.dynamicControl.initKirkiControl",
"kirki",
function (controlInit) {
if (variantControl && id + "[variant]" === controlInit.id) {
}
}
);
}
jQuery(document).ready(function () {
_.each(kirkiTypographyControls, function (id) {
kirkiTypographyCompositeControlFontProperties(id);
wp.customize(id, function (value) {
value.bind(function (newval) {
kirkiTypographyCompositeControlFontProperties(id, newval);
});
});
});
});

View file

@ -0,0 +1,92 @@
/**
* Hook in the kirkiPostMessageStylesOutput filter.
*
* Handles postMessage styles for typography controls.
*/
jQuery(document).ready(function () {
wp.hooks.addFilter(
"kirkiPostMessageStylesOutput",
"kirki",
/**
* Append styles for this control.
*
* @param {string} styles - The styles.
* @param {Object} value - The control value.
* @param {Object} output - The control's "output" argument.
* @param {string} controlType - The control type.
* @returns {string} - Returns the CSS as a string.
*/
function (styles, value, output, controlType) {
var googleFont = "",
processedValue;
if (value.variant) {
value["font-weight"] =
"regular" === value.variant || "italic" === value.variant
? 400
: parseInt(value.variant, 10);
value["font-style"] = value.variant.includes("italic")
? "italic"
: "normal";
}
if ("kirki-typography" === controlType) {
styles += output.element + "{";
_.each(value, function (val, key) {
if (output.choice && key !== output.choice) {
return;
}
if ("variant" === key) {
return;
}
processedValue = window.kirkiPostMessage.util.processValue(
output,
val
);
if (false !== processedValue) {
styles += key + ":" + processedValue + ";";
}
});
styles += "}";
// Check if this is a googlefont so that we may load it.
if (
!_.isUndefined(window.WebFont) &&
value["font-family"] &&
kirkiGoogleFontNames.includes(value["font-family"])
) {
// Calculate the googlefont params.
googleFont = value["font-family"].replace(/\"/g, "&quot;"); // eslint-disable-line no-useless-escape
if (value.variant) {
if ("regular" === value.variant) {
googleFont += ":400";
} else if ("italic" === value.variant) {
googleFont += ":400i";
} else {
googleFont += ":" + value.variant;
}
}
googleFont +=
":cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai";
window.WebFont.load({
google: {
families: [googleFont],
},
});
}
}
return styles;
}
);
});