This commit is contained in:
Alexander Agnarson 2020-02-25 18:04:54 +01:00
parent 62def2a89b
commit 7ad333b360
167 changed files with 2955 additions and 2493 deletions

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.28
*/
@ -90,6 +90,11 @@ class Kirki_Modules_CSS_Vars {
continue;
}
$val = Kirki_Values::get_value( $args['kirki_config'], $id );
if ( isset( $args['type'] ) && in_array( $args['type'], array( 'typography', 'kirki-typography' ), true ) ) {
if ( isset( $val['font-weight'] ) && 'regular' === $val['font-weight'] ) {
$val['font-weight'] = '400';
}
}
foreach ( $args['css_vars'] as $css_var ) {
if ( isset( $css_var[2] ) && is_array( $val ) && isset( $val[ $css_var[2] ] ) ) {
$this->vars[ $css_var[0] ] = str_replace( '$', $val[ $css_var[2] ], $css_var[1] );

View file

@ -7,7 +7,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
@ -84,15 +84,6 @@ final class Kirki_Modules_CSS_Generator {
*/
public static $google_fonts = null;
/**
* Standard Fonts
*
* @static
* @access public
* @var array
*/
public static $backup_fonts = null;
/**
* CSS
*
@ -118,9 +109,6 @@ final class Kirki_Modules_CSS_Generator {
if ( is_null( self::$google_fonts ) ) {
self::$google_fonts = Kirki_Fonts::get_google_fonts();
}
if ( is_null( self::$backup_fonts ) ) {
self::$backup_fonts = Kirki_Fonts::get_backup_fonts();
}
}
/**

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/
@ -33,16 +33,6 @@ class Kirki_Modules_CSS {
*/
public static $css_array = array();
/**
* Should we enqueue font-awesome?
*
* @static
* @access protected
* @since 3.0.26
* @var bool
*/
protected static $enqueue_fa = false;
/**
* Constructor
*
@ -154,11 +144,6 @@ class Kirki_Modules_CSS {
array(),
KIRKI_VERSION
);
// Enqueue FA if needed (I hope not, this FA version is pretty old, only kept here for backwards-compatibility purposes).
if ( self::$enqueue_fa && apply_filters( 'kirki_load_fontawesome', true ) ) {
wp_enqueue_script( 'kirki-fontawesome-font', 'https://use.fontawesome.com/30858dc40a.js', array(), '4.0.7', true );
}
}
/**
@ -286,27 +271,26 @@ class Kirki_Modules_CSS {
}
/**
* Runs when we're adding a font-awesome field to allow enqueueing the
* fontawesome script on the frontend.
* The FA field got deprecated in v3.0.42.
* This is here for backwards-compatibility in case a theme was calling it directly.
*
* @static
* @since 3.0.26
* @access public
* @return void
*/
public static function add_fontawesome_script() {
self::$enqueue_fa = true;
}
public static function add_fontawesome_script() {}
/**
* Check if FontAwesome should be loaded.
* The FA field got deprecated in v3.0.42.
* This is here for backwards-compatibility in case a theme was calling it directly.
*
* @static
* @since 3.0.35
* @access public
* @return bool
* @return false
*/
public static function get_enqueue_fa() {
return self::$enqueue_fa;
return false;
}
}

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.10
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/
@ -21,13 +21,10 @@ class Kirki_Output_Property_Font_Family extends Kirki_Output_Property {
*/
protected function process_value() {
$google_fonts_array = Kirki_Fonts::get_google_fonts();
$backup_fonts = Kirki_Fonts::get_backup_fonts();
$family = $this->value;
$backup = '';
if ( is_array( $this->value ) && isset( $this->value[0] ) && isset( $this->value[1] ) ) {
$family = $this->value[0];
$backup = $this->value[1];
}
// Make sure the value is a string.
@ -39,22 +36,6 @@ class Kirki_Output_Property_Font_Family extends Kirki_Output_Property {
// Hack for standard fonts.
$family = str_replace( '"', '"', $family );
// Add backup font.
if ( Kirki_Fonts::is_google_font( $family ) ) {
if ( '' === $backup && isset( $google_fonts_array[ $family ] ) && isset( $backup_fonts[ $google_fonts_array[ $family ]['category'] ] ) ) {
$backup = $backup_fonts[ $google_fonts_array[ $family ]['category'] ];
}
// Add double quotes if needed.
if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) {
$this->value = '"' . $family . '", ' . $backup;
return;
}
$this->value = $family . ', ' . $backup;
return;
}
// Add double quotes if needed.
if ( false !== strpos( $family, ' ' ) && false === strpos( $family, '"' ) ) {
$this->value = '"' . $family . '"';

View file

@ -6,7 +6,7 @@
* @package Kirki
* @subpackage Controls
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -7,7 +7,7 @@
* @subpackage Custom Sections Module
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Custom Sections Module
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -1,22 +1,29 @@
#customize-theme-controls .control-section-kirki-expanded .accordion-section-title {
display: none; }
display: none;
}
#customize-theme-controls .control-section-kirki-expanded .customize-section-back {
display: none; }
display: none;
}
#customize-theme-controls .customize-pane-child.control-section-kirki-expanded {
position: relative;
visibility: visible;
height: auto;
margin-left: -100%; }
#customize-theme-controls .customize-pane-child.control-section-kirki-expanded h3 .customize-action {
display: none; }
margin-left: -100%;
}
#customize-theme-controls .customize-pane-child.control-section-kirki-expanded h3 .customize-action {
display: none;
}
#customize-theme-controls .control-section-kirki-link .button {
margin-top: -3px; }
margin-top: -3px;
}
#customize-theme-controls .customize-pane-child.current-section-parent,
.in-sub-panel #customize-theme-controls .customize-pane-child.current-panel-parent {
transform: translateX(-100%); }
transform: translateX(-100%);
}
.control-section-kirki-nested {
margin: 0 -12px; }
margin: 0 -12px;
}
/*# sourceMappingURL=sections.css.map */

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Custom Sections Module
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Custom Sections Module
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Custom Sections Module
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 2.2.0
*/

View file

@ -8,7 +8,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -9,7 +9,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -127,7 +127,6 @@ class Kirki_Modules_Gutenberg {
protected function add_hooks() {
if ( ! $this->is_disabled() ) {
add_action( 'after_setup_theme', array( $this, 'add_theme_support' ), 999 );
add_action( 'enqueue_block_editor_assets', array( $this, 'enqueue_fontawesome' ) );
add_filter( 'block_editor_settings', array( $this, 'enqueue' ) );
}
}
@ -224,27 +223,6 @@ class Kirki_Modules_Gutenberg {
return false;
}
/**
* Enqueue fontawesome in Gutenberg Editor.
*
* @access public
* @since 3.0.35
*/
public function enqueue_fontawesome() {
foreach ( $this->configs as $config_id => $args ) {
if ( $this->is_disabled( $args ) ) {
continue;
}
$modules_css = $this->modules_css;
if ( $modules_css::get_enqueue_fa() && apply_filters( 'kirki_load_fontawesome', true ) ) { // phpcs:ignore PHPCompatibility.Syntax.NewDynamicAccessToStatic
wp_enqueue_script( 'kirki-fontawesome-font', 'https://use.fontawesome.com/30858dc40a.js', array(), '4.0.7', true );
}
return;
}
}
/**
* Set class property for $configs.
*

View file

@ -6,7 +6,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -5,7 +5,7 @@
* @package Kirki
* @subpackage Modules
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.26
*/

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

View file

@ -1,30 +1,36 @@
@charset "UTF-8";
.tooltip-wrapper {
float: right;
position: relative; }
.tooltip-wrapper .tooltip-trigger {
text-decoration: none;
cursor: help; }
.tooltip-wrapper .tooltip-content {
position: absolute;
width: 200px;
height: auto;
top: -10px;
left: -225px;
background: #FFC107;
color: #000;
padding: 10px;
z-index: 99999;
border-radius: 3px;
line-height: 1.4em; }
.tooltip-wrapper .tooltip-content a {
color: #000; }
.tooltip-wrapper .tooltip-content:after {
content: "\f139";
font-family: dashicons;
position: absolute;
right: -12px;
top: 11px;
color: #FFC107;
font-size: 20px; }
position: relative;
}
.tooltip-wrapper .tooltip-trigger {
text-decoration: none;
cursor: help;
}
.tooltip-wrapper .tooltip-content {
position: absolute;
width: 200px;
height: auto;
top: -10px;
left: -225px;
background: #FFC107;
color: #000;
padding: 10px;
z-index: 99999;
border-radius: 3px;
line-height: 1.4em;
}
.tooltip-wrapper .tooltip-content a {
color: #000;
}
.tooltip-wrapper .tooltip-content:after {
content: "";
font-family: dashicons;
position: absolute;
right: -12px;
top: 11px;
color: #FFC107;
font-size: 20px;
}
/*# sourceMappingURL=tooltip.css.map */

View file

@ -7,7 +7,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.26
*/

View file

@ -7,7 +7,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
@ -213,7 +213,7 @@ final class Kirki_Fonts_Google {
// If this is not a valid variant for this font-family
// then unset it and move on to the next one.
if ( ! in_array( $variant, $font_variants, true ) ) {
if ( ! in_array( strval( $variant ), $font_variants, true ) ) {
$variant_key = array_search( $variant, $this->fonts[ $font ], true );
unset( $this->fonts[ $font ][ $variant_key ] );
continue;

View file

@ -96,6 +96,11 @@ final class Kirki_Fonts_Helper {
*/
public static function download_font_file( $url ) {
$saved_fonts = get_option( 'kirki_font_local_filenames', array() );
if ( isset( $saved_fonts[ $url ] ) && file_exists( $saved_fonts[ $url ]['file'] ) ) {
return $saved_fonts[ $url ]['url'];
}
// Gives us access to the download_url() and wp_handle_sideload() functions.
require_once ABSPATH . 'wp-admin/includes/file.php';
@ -118,6 +123,7 @@ final class Kirki_Fonts_Helper {
);
$overrides = array(
'test_type' => false,
'test_form' => false,
'test_size' => true,
);
@ -126,6 +132,8 @@ final class Kirki_Fonts_Helper {
$results = wp_handle_sideload( $file, $overrides );
if ( empty( $results['error'] ) ) {
$saved_fonts[ $url ] = $results;
update_option( 'kirki_font_local_filenames', $saved_fonts );
return $results['url'];
}
return false;

View file

@ -6,7 +6,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 1.0
*/
@ -96,22 +96,6 @@ final class Kirki_Fonts {
return apply_filters( 'kirki_fonts_standard_fonts', $standard_fonts );
}
/**
* Return an array of backup fonts based on the font-category
*
* @return array
*/
public static function get_backup_fonts() {
$backup_fonts = array(
'sans-serif' => 'Helvetica, Arial, sans-serif',
'serif' => 'Georgia, serif',
'display' => '"Comic Sans MS", cursive, sans-serif',
'handwriting' => '"Comic Sans MS", cursive, sans-serif',
'monospace' => '"Lucida Console", Monaco, monospace',
);
return apply_filters( 'kirki_fonts_backup_fonts', $backup_fonts );
}
/**
* Return an array of all available Google Fonts.
*
@ -122,8 +106,13 @@ final class Kirki_Fonts {
// Get fonts from cache.
self::$google_fonts = get_site_transient( 'kirki_googlefonts_cache' );
// If we're debugging, don't use cached.
if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
/**
* Reset the cache if we're using action=kirki-reset-cache in the URL.
*
* Note to code reviewers:
* There's no need to check nonces or anything else, this is a simple true/false evaluation.
*/
if ( ! empty( $_GET['action'] ) && 'kirki-reset-cache' === $_GET['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification
self::$google_fonts = false;
}
@ -154,7 +143,7 @@ final class Kirki_Fonts {
self::$google_fonts = apply_filters( 'kirki_fonts_google_fonts', $google_fonts );
// Save the array in cache.
$cache_time = apply_filters( 'kirki_googlefonts_transient_time', HOUR_IN_SECONDS );
$cache_time = apply_filters( 'kirki_googlefonts_transient_time', DAY_IN_SECONDS );
set_site_transient( 'kirki_googlefonts_cache', self::$google_fonts, $cache_time );
return self::$google_fonts;

View file

@ -6,7 +6,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0
*/

View file

@ -6,7 +6,7 @@
* @category Core
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0
*/
@ -146,8 +146,11 @@ final class Kirki_Modules_Webfonts_Embed {
$url = "https://fonts.googleapis.com/css?family={$family}:{$weights}&subset=cyrillic,cyrillic-ext,devanagari,greek,greek-ext,khmer,latin,latin-ext,vietnamese,hebrew,arabic,bengali,gujarati,tamil,telugu,thai";
$transient_id = 'kirki_gfonts_' . md5( $url );
$contents = get_site_transient( $transient_id );
$contents = get_transient( $transient_id );
/**
* Reset the cache if we're using action=kirki-reset-cache in the URL.
*
* Note to code reviewers:
* There's no need to check nonces or anything else, this is a simple true/false evaluation.
*/
@ -193,8 +196,15 @@ final class Kirki_Modules_Webfonts_Embed {
$contents = $this->use_local_files( $contents );
}
// Set the transient for a week.
set_site_transient( $transient_id, $contents, WEEK_IN_SECONDS );
// Remove protocol to fix http/https issues.
$contents = str_replace(
array( 'http://', 'https://' ),
array( '//', '//' ),
$contents
);
// Set the transient for a day.
set_transient( $transient_id, $contents, DAY_IN_SECONDS );
}
}
if ( $contents ) {
@ -222,7 +232,10 @@ final class Kirki_Modules_Webfonts_Embed {
* @return string The CSS with local URLs.
*/
private function use_local_files( $css ) {
preg_match( '/https\:.*?\.woff/', $css, $matches );
preg_match_all( '/https\:.*?\.woff/', $css, $matches );
$matches = array_shift( $matches );
foreach ( $matches as $match ) {
if ( 0 === strpos( $match, 'https://fonts.gstatic.com' ) ) {
$new_url = Kirki_Fonts_Helper::download_font_file( $match );

View file

@ -6,7 +6,7 @@
* @category Modules
* @author Ari Stathopoulos (@aristath)
* @copyright Copyright (c) 2019, Ari Stathopoulos (@aristath)
* @license https://opensource.org/licenses/MIT
* @license https://opensource.org/licenses/MIT
* @since 3.0.0
*/

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long