Version Description
- Tested with the latest WordPress version.
- Better handling of third-party provided fonts.
- Provide the pixelgrade_option() getter for better compatibility.
Download this release
Release Info
Developer | pixelgrade |
Plugin | Customify – A Theme Customizer Booster |
Version | 2.10.4 |
Comparing to | |
See all releases |
Code changes from version 2.10.3 to 2.10.4
- customify.php +2 -2
- includes/class-customify-fonts-global.php +62 -3
- includes/customizer-controls/class-Pix_Customize_Font_Control.php +1 -9
- includes/extras.php +257 -189
- js/customizer/font-fields.js +9 -2
- js/customizer/font-fields.min.js +1 -1
- js/jquery.cssUpdate.js +14 -2
- js/jquery.cssUpdate.min.js +1 -1
- readme.txt +8 -3
customify.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Customify
|
4 |
* Plugin URI: https://wordpress.org/plugins/customify/
|
5 |
* Description: A Theme Customizer Booster to easily and consistently customize Fonts, Colors, and other options for your site.
|
6 |
-
* Version: 2.10.
|
7 |
* Author: Pixelgrade
|
8 |
* Author URI: https://pixelgrade.com
|
9 |
* Author Email: contact@pixelgrade.com
|
@@ -33,7 +33,7 @@ require_once 'includes/extras.php';
|
|
33 |
function PixCustomifyPlugin() {
|
34 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-pixcustomify.php';
|
35 |
|
36 |
-
return PixCustomifyPlugin::instance( __FILE__, '2.10.
|
37 |
}
|
38 |
|
39 |
// Now get the party started.
|
3 |
* Plugin Name: Customify
|
4 |
* Plugin URI: https://wordpress.org/plugins/customify/
|
5 |
* Description: A Theme Customizer Booster to easily and consistently customize Fonts, Colors, and other options for your site.
|
6 |
+
* Version: 2.10.4
|
7 |
* Author: Pixelgrade
|
8 |
* Author URI: https://pixelgrade.com
|
9 |
* Author Email: contact@pixelgrade.com
|
33 |
function PixCustomifyPlugin() {
|
34 |
require_once plugin_dir_path( __FILE__ ) . 'includes/class-pixcustomify.php';
|
35 |
|
36 |
+
return PixCustomifyPlugin::instance( __FILE__, '2.10.4' );
|
37 |
}
|
38 |
|
39 |
// Now get the party started.
|
includes/class-customify-fonts-global.php
CHANGED
@@ -37,6 +37,16 @@ class Customify_Fonts_Global {
|
|
37 |
*/
|
38 |
protected $cloud_fonts = [];
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* The font categories list.
|
42 |
* @since 2.8.0
|
@@ -94,6 +104,16 @@ class Customify_Fonts_Global {
|
|
94 |
* Gather all fonts, by type.
|
95 |
*/
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
if ( PixCustomifyPlugin()->settings->get_plugin_setting( 'typography_cloud_fonts', 1 ) ) {
|
98 |
$this->cloud_fonts = self::standardizeFontsList( apply_filters( 'customify_cloud_fonts', [] ) );
|
99 |
// Add the fonts to selects of the Customizer controls.
|
@@ -339,6 +359,14 @@ class Customify_Fonts_Global {
|
|
339 |
return $this->cloud_fonts;
|
340 |
}
|
341 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
342 |
public function get_categories() {
|
343 |
if ( empty( $this->categories ) ) {
|
344 |
return [];
|
@@ -368,6 +396,11 @@ class Customify_Fonts_Global {
|
|
368 |
return $this->system_fonts[ $font_family ];
|
369 |
}
|
370 |
break;
|
|
|
|
|
|
|
|
|
|
|
371 |
default:
|
372 |
return false;
|
373 |
break;
|
@@ -376,6 +409,26 @@ class Customify_Fonts_Global {
|
|
376 |
return false;
|
377 |
}
|
378 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
379 |
function output_cloud_fonts_select_options_group( $active_font_family, $current_value ) {
|
380 |
// Allow others to add options here
|
381 |
do_action( 'customify_font_family_before_cloud_fonts_options', $active_font_family, $current_value );
|
@@ -713,6 +766,9 @@ class Customify_Fonts_Global {
|
|
713 |
}
|
714 |
|
715 |
if ( ! empty( $google_fonts ) ) {
|
|
|
|
|
|
|
716 |
$google_url = 'https://fonts.googleapis.com/css2';
|
717 |
// Add `family=` to each font family.
|
718 |
$google_fonts = array_map( function( $font_family ) {
|
@@ -1326,6 +1382,7 @@ if (typeof WebFont !== 'undefined') {
|
|
1326 |
|
1327 |
$localized['fonts']['floatPrecision'] =self::$floatPrecision;
|
1328 |
|
|
|
1329 |
$localized['fonts']['theme_fonts'] = $this->get_theme_fonts();
|
1330 |
$localized['fonts']['cloud_fonts'] = $this->get_cloud_fonts();
|
1331 |
$localized['fonts']['google_fonts'] = $this->get_google_fonts();
|
@@ -2000,17 +2057,19 @@ if (typeof WebFont !== 'undefined') {
|
|
2000 |
/**
|
2001 |
* Determine a font type based on its font family.
|
2002 |
*
|
2003 |
-
* We will follow a stack in the following order: cloud fonts, theme fonts, Google fonts, system fonts.
|
2004 |
*
|
2005 |
* @param string $fontFamily
|
2006 |
*
|
2007 |
-
* @return string The font type: google_font, theme_font, cloud_font, or system_font.
|
2008 |
*/
|
2009 |
public function determineFontType( $fontFamily ) {
|
2010 |
// The default is a standard font (aka no special loading or processing).
|
2011 |
$fontType = 'system_font';
|
2012 |
|
2013 |
-
if ( ! empty( $this->
|
|
|
|
|
2014 |
$fontType = 'cloud_font';
|
2015 |
} elseif ( ! empty( $this->theme_fonts[ $fontFamily ] ) ) {
|
2016 |
$fontType = 'theme_font';
|
37 |
*/
|
38 |
protected $cloud_fonts = [];
|
39 |
|
40 |
+
/**
|
41 |
+
* The third-party fonts list.
|
42 |
+
*
|
43 |
+
* These are fonts that can be populated by other plugins (like Fonto).
|
44 |
+
*
|
45 |
+
* @since 2.11.0
|
46 |
+
* @var array
|
47 |
+
*/
|
48 |
+
protected $third_party_fonts = [];
|
49 |
+
|
50 |
/**
|
51 |
* The font categories list.
|
52 |
* @since 2.8.0
|
104 |
* Gather all fonts, by type.
|
105 |
*/
|
106 |
|
107 |
+
$this->third_party_fonts = self::standardizeFontsList( apply_filters( 'customify_third_party_fonts', [] ) );
|
108 |
+
// Add the fonts to selects of the Customizer controls.
|
109 |
+
// Since these are quite advanced fonts, we will put them first since the user went through all that trouble for a reason.
|
110 |
+
if ( ! empty( $this->third_party_fonts ) ) {
|
111 |
+
add_action( 'customify_font_family_select_options', array(
|
112 |
+
$this,
|
113 |
+
'output_third_party_fonts_select_options_group'
|
114 |
+
), 15, 2 );
|
115 |
+
}
|
116 |
+
|
117 |
if ( PixCustomifyPlugin()->settings->get_plugin_setting( 'typography_cloud_fonts', 1 ) ) {
|
118 |
$this->cloud_fonts = self::standardizeFontsList( apply_filters( 'customify_cloud_fonts', [] ) );
|
119 |
// Add the fonts to selects of the Customizer controls.
|
359 |
return $this->cloud_fonts;
|
360 |
}
|
361 |
|
362 |
+
public function get_third_party_fonts() {
|
363 |
+
if ( empty( $this->third_party_fonts ) ) {
|
364 |
+
return [];
|
365 |
+
}
|
366 |
+
|
367 |
+
return $this->third_party_fonts;
|
368 |
+
}
|
369 |
+
|
370 |
public function get_categories() {
|
371 |
if ( empty( $this->categories ) ) {
|
372 |
return [];
|
396 |
return $this->system_fonts[ $font_family ];
|
397 |
}
|
398 |
break;
|
399 |
+
case 'third_party_font':
|
400 |
+
if ( isset( $this->third_party_fonts[ $font_family ] ) ) {
|
401 |
+
return $this->third_party_fonts[ $font_family ];
|
402 |
+
}
|
403 |
+
break;
|
404 |
default:
|
405 |
return false;
|
406 |
break;
|
409 |
return false;
|
410 |
}
|
411 |
|
412 |
+
function output_third_party_fonts_select_options_group( $active_font_family, $current_value ) {
|
413 |
+
// Allow others to add options here
|
414 |
+
do_action( 'customify_font_family_before_third_party_fonts_options', $active_font_family, $current_value );
|
415 |
+
|
416 |
+
if ( ! empty( $this->third_party_fonts ) ) {
|
417 |
+
$group_label = apply_filters( 'customify_third_party_font_group_label', esc_html__( 'Third-Party Fonts', '__plugin_txtd' ), $active_font_family, $current_value );
|
418 |
+
echo '<optgroup label="' . esc_attr( $group_label ) . '">';
|
419 |
+
foreach ( $this->get_third_party_fonts() as $font ) {
|
420 |
+
if ( ! empty( $font['family'] ) ) {
|
421 |
+
// Display the select option's HTML.
|
422 |
+
Pix_Customize_Font_Control::output_font_family_option( $font['family'], $active_font_family );
|
423 |
+
}
|
424 |
+
}
|
425 |
+
echo "</optgroup>";
|
426 |
+
}
|
427 |
+
|
428 |
+
// Allow others to add options here
|
429 |
+
do_action( 'customify_font_family_after_third_party_fonts_options', $active_font_family, $current_value );
|
430 |
+
}
|
431 |
+
|
432 |
function output_cloud_fonts_select_options_group( $active_font_family, $current_value ) {
|
433 |
// Allow others to add options here
|
434 |
do_action( 'customify_font_family_before_cloud_fonts_options', $active_font_family, $current_value );
|
766 |
}
|
767 |
|
768 |
if ( ! empty( $google_fonts ) ) {
|
769 |
+
// Avoid duplicate entries.
|
770 |
+
$google_fonts = array_unique( $google_fonts );
|
771 |
+
|
772 |
$google_url = 'https://fonts.googleapis.com/css2';
|
773 |
// Add `family=` to each font family.
|
774 |
$google_fonts = array_map( function( $font_family ) {
|
1382 |
|
1383 |
$localized['fonts']['floatPrecision'] =self::$floatPrecision;
|
1384 |
|
1385 |
+
$localized['fonts']['third_party_fonts'] = $this->get_third_party_fonts();
|
1386 |
$localized['fonts']['theme_fonts'] = $this->get_theme_fonts();
|
1387 |
$localized['fonts']['cloud_fonts'] = $this->get_cloud_fonts();
|
1388 |
$localized['fonts']['google_fonts'] = $this->get_google_fonts();
|
2057 |
/**
|
2058 |
* Determine a font type based on its font family.
|
2059 |
*
|
2060 |
+
* We will follow a stack in the following order: third-party fonts, cloud fonts, theme fonts, Google fonts, system fonts.
|
2061 |
*
|
2062 |
* @param string $fontFamily
|
2063 |
*
|
2064 |
+
* @return string The font type: third_party_font, google_font, theme_font, cloud_font, or system_font.
|
2065 |
*/
|
2066 |
public function determineFontType( $fontFamily ) {
|
2067 |
// The default is a standard font (aka no special loading or processing).
|
2068 |
$fontType = 'system_font';
|
2069 |
|
2070 |
+
if ( ! empty( $this->third_party_fonts[ $fontFamily ] ) ) {
|
2071 |
+
$fontType = 'third_party_font';
|
2072 |
+
} elseif ( ! empty( $this->cloud_fonts[ $fontFamily ] ) ) {
|
2073 |
$fontType = 'cloud_font';
|
2074 |
} elseif ( ! empty( $this->theme_fonts[ $fontFamily ] ) ) {
|
2075 |
$fontType = 'theme_font';
|
includes/customizer-controls/class-Pix_Customize_Font_Control.php
CHANGED
@@ -171,15 +171,7 @@ class Pix_Customize_Font_Control extends Pix_Customize_Control {
|
|
171 |
<li class="font-options__option customize-control">
|
172 |
<select id="select_font_font_family_<?php echo esc_attr( $this->CSSID ); ?>" class="customify_font_family"<?php echo $select_data; ?> data-value_entry="font_family">
|
173 |
|
174 |
-
<?php
|
175 |
-
// Allow others to add options here. This is mostly for backwards compatibility purposes.
|
176 |
-
do_action( 'customify_font_family_before_options', $current_font_family, $current_value, $this->id );
|
177 |
-
|
178 |
-
do_action( 'customify_font_family_select_options', $current_font_family, $current_value, $this->id );
|
179 |
-
|
180 |
-
// Allow others to add options here. This is mostly for backwards compatibility purposes.
|
181 |
-
do_action( 'customify_font_family_after_options', $current_font_family, $current_value, $this->id ); ?>
|
182 |
-
|
183 |
</select>
|
184 |
</li>
|
185 |
<?php
|
171 |
<li class="font-options__option customize-control">
|
172 |
<select id="select_font_font_family_<?php echo esc_attr( $this->CSSID ); ?>" class="customify_font_family"<?php echo $select_data; ?> data-value_entry="font_family">
|
173 |
|
174 |
+
<?php do_action( 'customify_font_family_select_options', $current_font_family, $current_value, $this->id ); ?>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
</select>
|
176 |
</li>
|
177 |
<?php
|
includes/extras.php
CHANGED
@@ -3,13 +3,14 @@
|
|
3 |
* Extra functionality.
|
4 |
*/
|
5 |
|
6 |
-
if ( ! function_exists('add_customify_base_options') ) {
|
7 |
/**
|
8 |
* This filter is used to change the Customizer Options
|
9 |
* You can also copy this function inside your functions.php
|
10 |
* file but DO NOT FORGET TO CHANGE ITS NAME
|
11 |
*
|
12 |
* @param $config array This holds required keys for the plugin config like 'opt-name', 'panels', 'settings'
|
|
|
13 |
* @return $config
|
14 |
*/
|
15 |
function add_customify_base_options( $config ) {
|
@@ -20,192 +21,191 @@ if ( ! function_exists('add_customify_base_options') ) {
|
|
20 |
/**
|
21 |
* Presets - This section will handle other options
|
22 |
*/
|
23 |
-
'presets_section'
|
24 |
-
'title'
|
25 |
'options' => array(
|
26 |
-
'theme_style'
|
27 |
-
'type'
|
28 |
-
'label'
|
29 |
-
'desc'
|
30 |
-
'default'
|
31 |
'choices_type' => 'awesome',
|
32 |
-
'choices'
|
33 |
-
'royal'
|
34 |
-
'label'
|
35 |
'preview' => array(
|
36 |
-
'color-text'
|
37 |
-
'background-card'
|
38 |
'background-label' => '#46414c',
|
39 |
-
'font-main'
|
40 |
-
'font-alt'
|
41 |
),
|
42 |
'options' => array(
|
43 |
-
'links_color'
|
44 |
-
'headings_color'
|
45 |
-
'body_color'
|
46 |
'page_background' => '#615375',
|
47 |
-
'headings_font'
|
48 |
-
'body_font'
|
49 |
-
)
|
50 |
),
|
51 |
'lovely' => array(
|
52 |
-
'label'
|
53 |
'preview' => array(
|
54 |
-
'color-text'
|
55 |
-
'background-card'
|
56 |
'background-label' => '#5c374b',
|
57 |
-
'font-main'
|
58 |
-
'font-alt'
|
59 |
),
|
60 |
'options' => array(
|
61 |
-
'links_color'
|
62 |
-
'headings_color'
|
63 |
-
'body_color'
|
64 |
'page_background' => '#d15c57',
|
65 |
-
'headings_font'
|
66 |
-
'body_font'
|
67 |
-
)
|
68 |
),
|
69 |
-
'queen'
|
70 |
-
'label'
|
71 |
'preview' => array(
|
72 |
-
'color-text'
|
73 |
-
'background-card'
|
74 |
'background-label' => '#41212a',
|
75 |
-
'font-main'
|
76 |
-
'font-alt'
|
77 |
),
|
78 |
'options' => array(
|
79 |
-
'links_color'
|
80 |
-
'headings_color'
|
81 |
-
'body_color'
|
82 |
'page_background' => '#fff',
|
83 |
-
'headings_font'
|
84 |
-
'body_font'
|
85 |
-
)
|
86 |
),
|
87 |
'carrot' => array(
|
88 |
-
'label'
|
89 |
'preview' => array(
|
90 |
-
'color-text'
|
91 |
-
'background-card'
|
92 |
'background-label' => '#85210a',
|
93 |
-
'font-main'
|
94 |
-
'font-alt'
|
95 |
),
|
96 |
'options' => array(
|
97 |
-
'links_color'
|
98 |
-
'headings_color'
|
99 |
-
'body_color'
|
100 |
'page_background' => '#fff',
|
101 |
-
'headings_font'
|
102 |
-
'body_font'
|
103 |
-
)
|
104 |
),
|
105 |
|
106 |
|
107 |
-
|
108 |
-
|
109 |
-
'label' => esc_html__( 'Adler', 'customify' ),
|
110 |
'preview' => array(
|
111 |
-
'color-text'
|
112 |
-
'background-card'
|
113 |
'background-label' => '#000000',
|
114 |
-
'font-main'
|
115 |
-
'font-alt'
|
116 |
),
|
117 |
'options' => array(
|
118 |
-
'links_color'
|
119 |
-
'headings_color'
|
120 |
-
'body_color'
|
121 |
'page_background' => '#ffffff',
|
122 |
-
'headings_font'
|
123 |
-
'body_font'
|
124 |
-
)
|
125 |
),
|
126 |
'velvet' => array(
|
127 |
-
'label'
|
128 |
'preview' => array(
|
129 |
-
'color-text'
|
130 |
-
'background-card'
|
131 |
'background-label' => '#000000',
|
132 |
-
'font-main'
|
133 |
-
'font-alt'
|
134 |
),
|
135 |
'options' => array(
|
136 |
-
'links_color'
|
137 |
-
'headings_color'
|
138 |
-
'body_color'
|
139 |
'page_background' => '#000000',
|
140 |
-
'headings_font'
|
141 |
-
'body_font'
|
142 |
-
)
|
143 |
),
|
144 |
|
145 |
-
)
|
146 |
),
|
147 |
-
)
|
148 |
),
|
149 |
|
150 |
/**
|
151 |
* COLORS - This section will handle different elements colors (eg. links, headings)
|
152 |
*/
|
153 |
-
'colors_section'
|
154 |
-
'title'
|
155 |
'options' => array(
|
156 |
-
'links_color'
|
157 |
-
'type'
|
158 |
-
'label'
|
159 |
-
'live'
|
160 |
-
'default'
|
161 |
-
'css'
|
162 |
array(
|
163 |
-
'property'
|
164 |
'selector' => 'a, .entry-meta a',
|
165 |
),
|
166 |
-
)
|
167 |
),
|
168 |
'headings_color' => array(
|
169 |
-
'type'
|
170 |
-
'label'
|
171 |
-
'live'
|
172 |
-
'default'
|
173 |
-
'css'
|
174 |
array(
|
175 |
-
'property'
|
176 |
'selector' => '.site-title a, h1, h2, h3, h4, h5, h6,
|
177 |
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
178 |
.widget-title,
|
179 |
-
a:hover, .entry-meta a:hover'
|
180 |
-
)
|
181 |
-
)
|
182 |
),
|
183 |
'body_color' => array(
|
184 |
-
'type'
|
185 |
-
'label'
|
186 |
-
'live'
|
187 |
-
'default'
|
188 |
-
'css'
|
189 |
array(
|
190 |
'selector' => 'body',
|
191 |
-
'property'
|
192 |
-
)
|
193 |
-
)
|
194 |
-
)
|
195 |
-
)
|
196 |
),
|
197 |
|
198 |
/**
|
199 |
* FONTS - This section will handle different elements fonts (eg. headings, body)
|
200 |
*/
|
201 |
-
'typography_section'
|
202 |
-
'title'
|
203 |
'options' => array(
|
204 |
'headings_font' => array(
|
205 |
-
'type'
|
206 |
-
'label'
|
207 |
-
'default'
|
208 |
-
'selector'
|
209 |
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
210 |
.widget-title',
|
211 |
'font_weight' => true,
|
@@ -228,14 +228,14 @@ if ( ! function_exists('add_customify_base_options') ) {
|
|
228 |
'Pacifico',
|
229 |
'Handlee',
|
230 |
'Satify',
|
231 |
-
'Pompiere'
|
232 |
-
)
|
233 |
),
|
234 |
'body_font' => array(
|
235 |
-
'type'
|
236 |
-
'label'
|
237 |
-
'default'
|
238 |
-
'selector'
|
239 |
'recommended' => array(
|
240 |
'Lato',
|
241 |
'Open Sans',
|
@@ -243,79 +243,79 @@ if ( ! function_exists('add_customify_base_options') ) {
|
|
243 |
'Cabin',
|
244 |
'Gentium Book Basic',
|
245 |
'PT Serif',
|
246 |
-
'Droid Serif'
|
247 |
-
)
|
248 |
-
)
|
249 |
-
)
|
250 |
),
|
251 |
|
252 |
/**
|
253 |
* BACKGROUNDS - This section will handle different elements colors (eg. links, headings)
|
254 |
*/
|
255 |
'backgrounds_section' => array(
|
256 |
-
'title'
|
257 |
'options' => array(
|
258 |
-
'page_background'
|
259 |
-
'type'
|
260 |
-
'label'
|
261 |
-
'live'
|
262 |
-
'default'
|
263 |
-
'css'
|
264 |
array(
|
265 |
-
'property'
|
266 |
'selector' => 'body, .site',
|
267 |
-
)
|
268 |
-
)
|
269 |
),
|
270 |
-
)
|
271 |
),
|
272 |
/**
|
273 |
* LAYOUTS - This section will handle different elements colors (eg. links, headings)
|
274 |
*/
|
275 |
-
'layout_options'
|
276 |
-
'title'
|
277 |
'options' => array(
|
278 |
-
'site_title_size'
|
279 |
-
'type'
|
280 |
-
'label'
|
281 |
-
'live'
|
282 |
'input_attrs' => array(
|
283 |
-
'min'
|
284 |
-
'max'
|
285 |
-
'step'
|
286 |
-
'data-preview' => true
|
287 |
),
|
288 |
-
'default'
|
289 |
-
'css'
|
290 |
array(
|
291 |
'property' => 'font-size',
|
292 |
'selector' => '.site-title',
|
293 |
-
'media'
|
294 |
-
'unit'
|
295 |
-
)
|
296 |
-
)
|
297 |
),
|
298 |
'page_content_spacing' => array(
|
299 |
-
'type'
|
300 |
-
'label'
|
301 |
-
'live'
|
302 |
'input_attrs' => array(
|
303 |
-
'min'
|
304 |
-
'max'
|
305 |
-
'step'
|
306 |
),
|
307 |
-
'default'
|
308 |
-
'css'
|
309 |
array(
|
310 |
'property' => 'padding',
|
311 |
'selector' => '.site-content',
|
312 |
-
'media'
|
313 |
-
'unit'
|
314 |
-
)
|
315 |
-
)
|
316 |
-
)
|
317 |
-
)
|
318 |
-
)
|
319 |
);
|
320 |
|
321 |
return $config;
|
@@ -323,7 +323,7 @@ if ( ! function_exists('add_customify_base_options') ) {
|
|
323 |
}
|
324 |
add_filter( 'customify_filter_fields', 'add_customify_base_options', 5, 1 );
|
325 |
|
326 |
-
add_action( 'after_switch_theme', function( $old_theme_name, $old_theme ) {
|
327 |
$current_theme = wp_get_theme();
|
328 |
// If the current theme is a child theme, show a notice.
|
329 |
if ( $current_theme->exists()
|
@@ -355,7 +355,7 @@ function customify_child_theme_migrate_theme_mods_notice() {
|
|
355 |
|
356 |
ob_start(); ?>
|
357 |
<div class="customify-notice__container updated notice fade is-dismissible">
|
358 |
-
<h3><?php echo sprintf( __( 'You have activated a child theme for "%s". Good for you!', 'customify' ), $parent_theme->get('Name') ); ?></h3>
|
359 |
<p>
|
360 |
<?php echo wp_kses_post( __( 'If you have already <strong>set up things in the Customizer,</strong> you may want to <strong>keep those customizations</strong> so you don\'t start over.', 'customify' ) ); ?>
|
361 |
</p>
|
@@ -370,9 +370,11 @@ function customify_child_theme_migrate_theme_mods_notice() {
|
|
370 |
|
371 |
<p>
|
372 |
<button class="customify-notice-button button button-primary js-handle-customify">
|
373 |
-
<span
|
|
|
374 |
</button>
|
375 |
-
<button type="submit"
|
|
|
376 |
<span class="message js-plugin-message" style="font-style:italic"></span>
|
377 |
</p>
|
378 |
|
@@ -389,9 +391,9 @@ function customify_child_theme_migrate_theme_mods_notice() {
|
|
389 |
$statusMessage = $noticeContainer.find('.js-plugin-message')
|
390 |
|
391 |
$button.on('click', function (e) {
|
392 |
-
e.preventDefault()
|
393 |
|
394 |
-
$buttonText.html("<?php esc_html_e( 'Migrating customizations..'
|
395 |
$button.attr('disabled', true)
|
396 |
$dismissButton.hide()
|
397 |
|
@@ -404,26 +406,26 @@ function customify_child_theme_migrate_theme_mods_notice() {
|
|
404 |
nonce_migrate: $noticeContainer.find('#nonce-customify_theme_mods_migrate').val()
|
405 |
}
|
406 |
})
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
})
|
421 |
|
422 |
// Dismiss the notice.
|
423 |
$dismissButton.on('click', function (e) {
|
424 |
-
e.preventDefault()
|
425 |
|
426 |
-
$noticeContainer.slideUp()
|
427 |
})
|
428 |
})
|
429 |
})(jQuery)
|
@@ -470,6 +472,7 @@ function customify_migrate_customizations_from_parent_to_child_theme() {
|
|
470 |
|
471 |
wp_send_json_success();
|
472 |
}
|
|
|
473 |
add_action( 'wp_ajax_customify_migrate_customizations_from_parent_to_child_theme', 'customify_migrate_customizations_from_parent_to_child_theme' );
|
474 |
|
475 |
/**
|
@@ -515,4 +518,69 @@ function customify_migrate_to_advanced_dark_mode_control() {
|
|
515 |
update_option( 'sm_dark_mode_advanced', 'off' );
|
516 |
}
|
517 |
}
|
|
|
518 |
add_action( 'admin_init', 'customify_migrate_to_advanced_dark_mode_control' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
* Extra functionality.
|
4 |
*/
|
5 |
|
6 |
+
if ( ! function_exists( 'add_customify_base_options' ) ) {
|
7 |
/**
|
8 |
* This filter is used to change the Customizer Options
|
9 |
* You can also copy this function inside your functions.php
|
10 |
* file but DO NOT FORGET TO CHANGE ITS NAME
|
11 |
*
|
12 |
* @param $config array This holds required keys for the plugin config like 'opt-name', 'panels', 'settings'
|
13 |
+
*
|
14 |
* @return $config
|
15 |
*/
|
16 |
function add_customify_base_options( $config ) {
|
21 |
/**
|
22 |
* Presets - This section will handle other options
|
23 |
*/
|
24 |
+
'presets_section' => array(
|
25 |
+
'title' => esc_html__( 'Style Presets', 'customify' ),
|
26 |
'options' => array(
|
27 |
+
'theme_style' => array(
|
28 |
+
'type' => 'preset',
|
29 |
+
'label' => esc_html__( 'Select a style:', 'customify' ),
|
30 |
+
'desc' => esc_html__( 'Conveniently change the design of your site with built-in style presets. Easy as pie.', 'customify' ),
|
31 |
+
'default' => 'royal',
|
32 |
'choices_type' => 'awesome',
|
33 |
+
'choices' => array(
|
34 |
+
'royal' => array(
|
35 |
+
'label' => esc_html__( 'Royal', 'customify' ),
|
36 |
'preview' => array(
|
37 |
+
'color-text' => '#ffffff',
|
38 |
+
'background-card' => '#615375',
|
39 |
'background-label' => '#46414c',
|
40 |
+
'font-main' => 'Abril Fatface',
|
41 |
+
'font-alt' => 'PT Serif',
|
42 |
),
|
43 |
'options' => array(
|
44 |
+
'links_color' => '#8eb2c5',
|
45 |
+
'headings_color' => '#725c92',
|
46 |
+
'body_color' => '#6f8089',
|
47 |
'page_background' => '#615375',
|
48 |
+
'headings_font' => 'Abril Fatface',
|
49 |
+
'body_font' => 'PT Serif',
|
50 |
+
),
|
51 |
),
|
52 |
'lovely' => array(
|
53 |
+
'label' => esc_html__( 'Lovely', 'customify' ),
|
54 |
'preview' => array(
|
55 |
+
'color-text' => '#ffffff',
|
56 |
+
'background-card' => '#d15c57',
|
57 |
'background-label' => '#5c374b',
|
58 |
+
'font-main' => 'Playfair Display',
|
59 |
+
'font-alt' => 'Playfair Display',
|
60 |
),
|
61 |
'options' => array(
|
62 |
+
'links_color' => '#cc3747',
|
63 |
+
'headings_color' => '#d15c57',
|
64 |
+
'body_color' => '#5c374b',
|
65 |
'page_background' => '#d15c57',
|
66 |
+
'headings_font' => 'Playfair Display',
|
67 |
+
'body_font' => 'Playfair Display',
|
68 |
+
),
|
69 |
),
|
70 |
+
'queen' => array(
|
71 |
+
'label' => esc_html__( 'Queen', 'customify' ),
|
72 |
'preview' => array(
|
73 |
+
'color-text' => '#fbedec',
|
74 |
+
'background-card' => '#773347',
|
75 |
'background-label' => '#41212a',
|
76 |
+
'font-main' => 'Cinzel Decorative',
|
77 |
+
'font-alt' => 'Gentium Basic',
|
78 |
),
|
79 |
'options' => array(
|
80 |
+
'links_color' => '#cd8085',
|
81 |
+
'headings_color' => '#54323c',
|
82 |
+
'body_color' => '#cd8085',
|
83 |
'page_background' => '#fff',
|
84 |
+
'headings_font' => 'Cinzel Decorative',
|
85 |
+
'body_font' => 'Gentium Basic',
|
86 |
+
),
|
87 |
),
|
88 |
'carrot' => array(
|
89 |
+
'label' => esc_html__( 'Carrot', 'customify' ),
|
90 |
'preview' => array(
|
91 |
+
'color-text' => '#ffffff',
|
92 |
+
'background-card' => '#df421d',
|
93 |
'background-label' => '#85210a',
|
94 |
+
'font-main' => 'Oswald',
|
95 |
+
'font-alt' => 'PT Sans Narrow',
|
96 |
),
|
97 |
'options' => array(
|
98 |
+
'links_color' => '#df421d',
|
99 |
+
'headings_color' => '#df421d',
|
100 |
+
'body_color' => '#7e7e7e',
|
101 |
'page_background' => '#fff',
|
102 |
+
'headings_font' => 'Oswald',
|
103 |
+
'body_font' => 'PT Sans Narrow',
|
104 |
+
),
|
105 |
),
|
106 |
|
107 |
|
108 |
+
'adler' => array(
|
109 |
+
'label' => esc_html__( 'Adler', 'customify' ),
|
|
|
110 |
'preview' => array(
|
111 |
+
'color-text' => '#fff',
|
112 |
+
'background-card' => '#0e364f',
|
113 |
'background-label' => '#000000',
|
114 |
+
'font-main' => 'Permanent Marker',
|
115 |
+
'font-alt' => 'Droid Sans Mono',
|
116 |
),
|
117 |
'options' => array(
|
118 |
+
'links_color' => '#68f3c8',
|
119 |
+
'headings_color' => '#0e364f',
|
120 |
+
'body_color' => '#45525a',
|
121 |
'page_background' => '#ffffff',
|
122 |
+
'headings_font' => 'Permanent Marker',
|
123 |
+
'body_font' => 'Droid Sans Mono',
|
124 |
+
),
|
125 |
),
|
126 |
'velvet' => array(
|
127 |
+
'label' => esc_html__( 'Velvet', 'customify' ),
|
128 |
'preview' => array(
|
129 |
+
'color-text' => '#ffffff',
|
130 |
+
'background-card' => '#282828',
|
131 |
'background-label' => '#000000',
|
132 |
+
'font-main' => 'Pinyon Script',
|
133 |
+
'font-alt' => 'Josefin Sans',
|
134 |
),
|
135 |
'options' => array(
|
136 |
+
'links_color' => '#000000',
|
137 |
+
'headings_color' => '#000000',
|
138 |
+
'body_color' => '#000000',
|
139 |
'page_background' => '#000000',
|
140 |
+
'headings_font' => 'Pinyon Script',
|
141 |
+
'body_font' => 'Josefin Sans',
|
142 |
+
),
|
143 |
),
|
144 |
|
145 |
+
),
|
146 |
),
|
147 |
+
),
|
148 |
),
|
149 |
|
150 |
/**
|
151 |
* COLORS - This section will handle different elements colors (eg. links, headings)
|
152 |
*/
|
153 |
+
'colors_section' => array(
|
154 |
+
'title' => esc_html__( 'Colors', 'customify' ),
|
155 |
'options' => array(
|
156 |
+
'links_color' => array(
|
157 |
+
'type' => 'color',
|
158 |
+
'label' => esc_html__( 'Links Color', 'customify' ),
|
159 |
+
'live' => true,
|
160 |
+
'default' => '#6c6e70',
|
161 |
+
'css' => array(
|
162 |
array(
|
163 |
+
'property' => 'color',
|
164 |
'selector' => 'a, .entry-meta a',
|
165 |
),
|
166 |
+
),
|
167 |
),
|
168 |
'headings_color' => array(
|
169 |
+
'type' => 'color',
|
170 |
+
'label' => esc_html__( 'Headings Color', 'customify' ),
|
171 |
+
'live' => true,
|
172 |
+
'default' => '#0aa0d9',
|
173 |
+
'css' => array(
|
174 |
array(
|
175 |
+
'property' => 'color',
|
176 |
'selector' => '.site-title a, h1, h2, h3, h4, h5, h6,
|
177 |
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
178 |
.widget-title,
|
179 |
+
a:hover, .entry-meta a:hover',
|
180 |
+
),
|
181 |
+
),
|
182 |
),
|
183 |
'body_color' => array(
|
184 |
+
'type' => 'color',
|
185 |
+
'label' => esc_html__( 'Body Color', 'customify' ),
|
186 |
+
'live' => true,
|
187 |
+
'default' => '#2d3033',
|
188 |
+
'css' => array(
|
189 |
array(
|
190 |
'selector' => 'body',
|
191 |
+
'property' => 'color',
|
192 |
+
),
|
193 |
+
),
|
194 |
+
),
|
195 |
+
),
|
196 |
),
|
197 |
|
198 |
/**
|
199 |
* FONTS - This section will handle different elements fonts (eg. headings, body)
|
200 |
*/
|
201 |
+
'typography_section' => array(
|
202 |
+
'title' => esc_html__( 'Fonts', 'customify' ),
|
203 |
'options' => array(
|
204 |
'headings_font' => array(
|
205 |
+
'type' => 'font',
|
206 |
+
'label' => esc_html__( 'Headings', 'customify' ),
|
207 |
+
'default' => 'Playfair Display',
|
208 |
+
'selector' => '.site-title a, h1, h2, h3, h4, h5, h6,
|
209 |
h1 a, h2 a, h3 a, h4 a, h5 a, h6 a,
|
210 |
.widget-title',
|
211 |
'font_weight' => true,
|
228 |
'Pacifico',
|
229 |
'Handlee',
|
230 |
'Satify',
|
231 |
+
'Pompiere',
|
232 |
+
),
|
233 |
),
|
234 |
'body_font' => array(
|
235 |
+
'type' => 'font',
|
236 |
+
'label' => esc_html__( 'Body Text', 'customify' ),
|
237 |
+
'default' => 'Lato',
|
238 |
+
'selector' => 'html body',
|
239 |
'recommended' => array(
|
240 |
'Lato',
|
241 |
'Open Sans',
|
243 |
'Cabin',
|
244 |
'Gentium Book Basic',
|
245 |
'PT Serif',
|
246 |
+
'Droid Serif',
|
247 |
+
),
|
248 |
+
),
|
249 |
+
),
|
250 |
),
|
251 |
|
252 |
/**
|
253 |
* BACKGROUNDS - This section will handle different elements colors (eg. links, headings)
|
254 |
*/
|
255 |
'backgrounds_section' => array(
|
256 |
+
'title' => esc_html__( 'Backgrounds', 'customify' ),
|
257 |
'options' => array(
|
258 |
+
'page_background' => array(
|
259 |
+
'type' => 'color',
|
260 |
+
'label' => esc_html__( 'Page Background', 'customify' ),
|
261 |
+
'live' => true,
|
262 |
+
'default' => '#ffffff',
|
263 |
+
'css' => array(
|
264 |
array(
|
265 |
+
'property' => 'background',
|
266 |
'selector' => 'body, .site',
|
267 |
+
),
|
268 |
+
),
|
269 |
),
|
270 |
+
),
|
271 |
),
|
272 |
/**
|
273 |
* LAYOUTS - This section will handle different elements colors (eg. links, headings)
|
274 |
*/
|
275 |
+
'layout_options' => array(
|
276 |
+
'title' => esc_html__( 'Layout', 'customify' ),
|
277 |
'options' => array(
|
278 |
+
'site_title_size' => array(
|
279 |
+
'type' => 'range',
|
280 |
+
'label' => esc_html__( 'Site Title Size', 'customify' ),
|
281 |
+
'live' => true,
|
282 |
'input_attrs' => array(
|
283 |
+
'min' => 24,
|
284 |
+
'max' => 100,
|
285 |
+
'step' => 1,
|
286 |
+
'data-preview' => true,
|
287 |
),
|
288 |
+
'default' => 24,
|
289 |
+
'css' => array(
|
290 |
array(
|
291 |
'property' => 'font-size',
|
292 |
'selector' => '.site-title',
|
293 |
+
'media' => 'screen and (min-width: 1000px)',
|
294 |
+
'unit' => 'px',
|
295 |
+
),
|
296 |
+
),
|
297 |
),
|
298 |
'page_content_spacing' => array(
|
299 |
+
'type' => 'range',
|
300 |
+
'label' => 'Page Content Spacing',
|
301 |
+
'live' => true,
|
302 |
'input_attrs' => array(
|
303 |
+
'min' => 0,
|
304 |
+
'max' => 100,
|
305 |
+
'step' => 1,
|
306 |
),
|
307 |
+
'default' => 18,
|
308 |
+
'css' => array(
|
309 |
array(
|
310 |
'property' => 'padding',
|
311 |
'selector' => '.site-content',
|
312 |
+
'media' => 'screen and (min-width: 1000px)',
|
313 |
+
'unit' => 'px',
|
314 |
+
),
|
315 |
+
),
|
316 |
+
),
|
317 |
+
),
|
318 |
+
),
|
319 |
);
|
320 |
|
321 |
return $config;
|
323 |
}
|
324 |
add_filter( 'customify_filter_fields', 'add_customify_base_options', 5, 1 );
|
325 |
|
326 |
+
add_action( 'after_switch_theme', function ( $old_theme_name, $old_theme ) {
|
327 |
$current_theme = wp_get_theme();
|
328 |
// If the current theme is a child theme, show a notice.
|
329 |
if ( $current_theme->exists()
|
355 |
|
356 |
ob_start(); ?>
|
357 |
<div class="customify-notice__container updated notice fade is-dismissible">
|
358 |
+
<h3><?php echo sprintf( __( 'You have activated a child theme for "%s". Good for you!', 'customify' ), $parent_theme->get( 'Name' ) ); ?></h3>
|
359 |
<p>
|
360 |
<?php echo wp_kses_post( __( 'If you have already <strong>set up things in the Customizer,</strong> you may want to <strong>keep those customizations</strong> so you don\'t start over.', 'customify' ) ); ?>
|
361 |
</p>
|
370 |
|
371 |
<p>
|
372 |
<button class="customify-notice-button button button-primary js-handle-customify">
|
373 |
+
<span
|
374 |
+
class="customify-notice-button__text"><?php esc_html_e( 'Yes, migrate customizations', 'customify' ); ?></span>
|
375 |
</button>
|
376 |
+
<button type="submit"
|
377 |
+
class="customify-dismiss-button button button-secondary js-dismiss-customify"><?php esc_html_e( 'No, thank you', 'customify' ); ?></button>
|
378 |
<span class="message js-plugin-message" style="font-style:italic"></span>
|
379 |
</p>
|
380 |
|
391 |
$statusMessage = $noticeContainer.find('.js-plugin-message')
|
392 |
|
393 |
$button.on('click', function (e) {
|
394 |
+
e.preventDefault()
|
395 |
|
396 |
+
$buttonText.html("<?php esc_html_e( 'Migrating customizations..', 'customify' ); ?>")
|
397 |
$button.attr('disabled', true)
|
398 |
$dismissButton.hide()
|
399 |
|
406 |
nonce_migrate: $noticeContainer.find('#nonce-customify_theme_mods_migrate').val()
|
407 |
}
|
408 |
})
|
409 |
+
.done(function (response) {
|
410 |
+
if (typeof response.success !== 'undefined' && response.success) {
|
411 |
+
$statusMessage.html("<?php esc_html_e( 'Successfully migrated the parent customizations! Enjoy crafting your site!', 'customify' ); ?>")
|
412 |
+
$buttonText.html("<?php esc_html_e( 'Finished migration', 'customify' ); ?>")
|
413 |
+
} else {
|
414 |
+
$statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.', 'customify' ); ?>")
|
415 |
+
$buttonText.html("<?php esc_html_e( 'Migration error', 'customify' ); ?>")
|
416 |
+
}
|
417 |
+
})
|
418 |
+
.fail(function () {
|
419 |
+
$statusMessage.html("<?php esc_html_e( 'Something went wrong and we couldn\'t migrate the customizations.', 'customify' ); ?>")
|
420 |
+
$buttonText.html("<?php esc_html_e( 'Migration error', 'customify' ); ?>")
|
421 |
+
})
|
422 |
})
|
423 |
|
424 |
// Dismiss the notice.
|
425 |
$dismissButton.on('click', function (e) {
|
426 |
+
e.preventDefault()
|
427 |
|
428 |
+
$noticeContainer.slideUp()
|
429 |
})
|
430 |
})
|
431 |
})(jQuery)
|
472 |
|
473 |
wp_send_json_success();
|
474 |
}
|
475 |
+
|
476 |
add_action( 'wp_ajax_customify_migrate_customizations_from_parent_to_child_theme', 'customify_migrate_customizations_from_parent_to_child_theme' );
|
477 |
|
478 |
/**
|
518 |
update_option( 'sm_dark_mode_advanced', 'off' );
|
519 |
}
|
520 |
}
|
521 |
+
|
522 |
add_action( 'admin_init', 'customify_migrate_to_advanced_dark_mode_control' );
|
523 |
+
|
524 |
+
if ( ! function_exists( 'pixelgrade_option' ) ) {
|
525 |
+
/**
|
526 |
+
* Get option from the database
|
527 |
+
*
|
528 |
+
* @param string $option_id The option name.
|
529 |
+
* @param mixed $default Optional. The default value to return when the option was not found or saved.
|
530 |
+
* @param bool $force_given_default Optional. When true, we will use the $default value provided for when the option was not saved at least once.
|
531 |
+
* When false, we will let the option's default set value (in the Customify settings) kick in first, then our $default.
|
532 |
+
* It basically, reverses the order of fallback, first the option's default, then our own.
|
533 |
+
* This is ignored when $default is null.
|
534 |
+
*
|
535 |
+
* @return mixed
|
536 |
+
*/
|
537 |
+
function pixelgrade_option( $option_id, $default = null, $force_given_default = false ) {
|
538 |
+
|
539 |
+
// We need to account for the case where a option has an 'active_callback' defined in it's config
|
540 |
+
$options_config = PixCustomifyPlugin()->get_options_configs();
|
541 |
+
if ( ! empty( $options_config ) && ! empty( $options_config[ $option_id ] ) ) {
|
542 |
+
if ( ! empty( $options_config[ $option_id ]['active_callback'] ) ) {
|
543 |
+
// This option has an active callback
|
544 |
+
// We need to "question" it
|
545 |
+
//
|
546 |
+
// IMPORTANT NOTICE:
|
547 |
+
//
|
548 |
+
// Be extra careful when setting up the options to not end up in a circular logic
|
549 |
+
// due to callbacks that get an option and that option has a callback that gets the initial option - INFINITE LOOPS :(
|
550 |
+
if ( is_callable( $options_config[ $option_id ]['active_callback'] ) ) {
|
551 |
+
// Now we call the function and if it returns false, this means that the control is not active
|
552 |
+
// Hence it's saved value doesn't matter
|
553 |
+
$active = call_user_func( $options_config[ $option_id ]['active_callback'] );
|
554 |
+
if ( empty( $active ) ) {
|
555 |
+
// If we need to force the default received; we respect that
|
556 |
+
if ( true === $force_given_default && null !== $default ) {
|
557 |
+
return $default;
|
558 |
+
} else {
|
559 |
+
// Else we return false
|
560 |
+
// because we treat the case when the active callback returns false as if the option would be non-existent
|
561 |
+
// We do not return the default configured value in this case
|
562 |
+
return false;
|
563 |
+
}
|
564 |
+
}
|
565 |
+
}
|
566 |
+
}
|
567 |
+
|
568 |
+
// Now that the option is truly active, we need to see if we are not supposed to force over the option's default value
|
569 |
+
if ( $default !== null && false === $force_given_default ) {
|
570 |
+
// We will not pass the received $default here so Customify will fallback on the option's default value, if set
|
571 |
+
$customify_value = PixCustomifyPlugin()->get_option( $option_id );
|
572 |
+
|
573 |
+
// We only fallback on the $default if none was given from Customify
|
574 |
+
if ( null === $customify_value ) {
|
575 |
+
return $default;
|
576 |
+
}
|
577 |
+
} else {
|
578 |
+
$customify_value = PixCustomifyPlugin()->get_option( $option_id, $default );
|
579 |
+
}
|
580 |
+
|
581 |
+
return $customify_value;
|
582 |
+
}
|
583 |
+
|
584 |
+
return $default;
|
585 |
+
}
|
586 |
+
}
|
js/customizer/font-fields.js
CHANGED
@@ -481,8 +481,10 @@ window.customify = window.customify || parent.customify || {};
|
|
481 |
// The default is a standard font (aka no special loading or processing).
|
482 |
let fontType = 'system_font'
|
483 |
|
484 |
-
// We will follow a stack in the following order: cloud fonts, theme fonts, Google fonts, standard fonts.
|
485 |
-
if (typeof customify.fonts.
|
|
|
|
|
486 |
fontType = 'cloud_font'
|
487 |
} else if (typeof customify.fonts.theme_fonts[fontFamily] !== 'undefined') {
|
488 |
fontType = 'theme_font'
|
@@ -514,6 +516,11 @@ window.customify = window.customify || parent.customify || {};
|
|
514 |
return customify.fonts.system_fonts[fontFamily]
|
515 |
}
|
516 |
break
|
|
|
|
|
|
|
|
|
|
|
517 |
default:
|
518 |
}
|
519 |
|
481 |
// The default is a standard font (aka no special loading or processing).
|
482 |
let fontType = 'system_font'
|
483 |
|
484 |
+
// We will follow a stack in the following order: third-party fonts, cloud fonts, theme fonts, Google fonts, standard fonts.
|
485 |
+
if (typeof customify.fonts.third_party_fonts[fontFamily] !== 'undefined') {
|
486 |
+
fontType = 'third_party_font'
|
487 |
+
} else if (typeof customify.fonts.cloud_fonts[fontFamily] !== 'undefined') {
|
488 |
fontType = 'cloud_font'
|
489 |
} else if (typeof customify.fonts.theme_fonts[fontFamily] !== 'undefined') {
|
490 |
fontType = 'theme_font'
|
516 |
return customify.fonts.system_fonts[fontFamily]
|
517 |
}
|
518 |
break
|
519 |
+
case 'third_party_font':
|
520 |
+
if (typeof customify.fonts.third_party_fonts[fontFamily] !== 'undefined') {
|
521 |
+
return customify.fonts.third_party_fonts[fontFamily]
|
522 |
+
}
|
523 |
+
break
|
524 |
default:
|
525 |
}
|
526 |
|
js/customizer/font-fields.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.customify=window.customify||parent.customify||{},function(t,e,n){void 0===e.fontFields&&(e.fontFields={}),_.extend(e.fontFields,function(){const i=".font-options__wrapper";let o,a;const s=n.customize,l={},c={},u=function(e,n=!1,o=""){if(e.length&&(t(e).data("touched",!1),t(e).on("input change",(function(e,n){if(void 0!==n&&"customify"===n);else{const n=t(e.target).closest(i),o=t(n.children(".customify_font_values")).data("customize-setting-link");t(e.target).data("touched",!0),v(n,o)}})),!0===n)){const n={};_.isEmpty(o)||(n.placeholder=o),t(e).select2(n)}},f=function(){const e=t("#customize-controls .js-font-option-toggle");e.on("click",(function(){const n=t(this);!0===n.prop("checked")&&e.not(n).prop("checked",!1)})),t("#customize-controls .customize-panel-back, #customize-controls .customize-section-back").on("click",(function(){e.prop("checked",!1)}))},
|
1 |
+
window.customify=window.customify||parent.customify||{},function(t,e,n){void 0===e.fontFields&&(e.fontFields={}),_.extend(e.fontFields,function(){const i=".font-options__wrapper";let o,a;const s=n.customize,l={},c={},u=function(e,n=!1,o=""){if(e.length&&(t(e).data("touched",!1),t(e).on("input change",(function(e,n){if(void 0!==n&&"customify"===n);else{const n=t(e.target).closest(i),o=t(n.children(".customify_font_values")).data("customize-setting-link");t(e.target).data("touched",!0),v(n,o)}})),!0===n)){const n={};_.isEmpty(o)||(n.placeholder=o),t(e).select2(n)}},f=function(){const e=t("#customize-controls .js-font-option-toggle");e.on("click",(function(){const n=t(this);!0===n.prop("checked")&&e.not(n).prop("checked",!1)})),t("#customize-controls .customize-panel-back, #customize-controls .customize-section-back").on("click",(function(){e.prop("checked",!1)}))},r=function(e,n){const i=n.find(".font-options__head .font-options__font-title");let o=e.family;"string"==typeof e.family_display&&e.family_display.length&&(o=e.family_display),t(i).html(o)},d=function(e,n){const i=void 0!==e.variants?e.variants:[],o=n.find(".customify_font_weight"),s=o.val()?o.val():"",l=[];if(o.val(null).empty(),o.hasClass("select2-hidden-accessible")&&o.select2("destroy"),o.data("touched",!1),void 0===i||Object.keys(i).length<2)return o.parent().hide(),o.parent().prev("label").hide(),void o.data("disabled",!0);l.push({id:"",text:a}),t.each(i,(function(t,e){let n={id:e,text:e};s==e&&(n.selected=!0),l.push(n)})),o.select2({data:l}),o.parent().show(),o.parent().prev("label").show(),o.data("disabled",!1)},v=function(e,n){if(!0===l[n])return;if(!0===c[n])return;l[n]=!0;const i=e.find(".font-options__options-list").find("[data-value_entry]"),o=s(n),a=o(),u=_.isEmpty(a)?{}:t.extend(!0,{},a);i.each((function(e,n){const i=t(n),o=i.data("value_entry");let a=i.val();if(!_.isUndefined(o)&&!i.data("disabled")&&(i.data("touched")||_.isUndefined(u[o]))){if("font_family"===o){const e=t(n.options[n.selectedIndex]).data("src");e?u.src=e:delete u.src}_.isUndefined(a)||_.isNull(a)||""===a?delete u[o]:(_.includes(["letter_spacing","line_height","font_size"],o)&&(a=m(a,n,!1)),u[o]=a)}})),delete u.variants,delete u.subsets;const f=y(u.font_family);void 0!==u.font_variant&&void 0!==f.variants&&Object.keys(f.variants).length>0?(u.font_variant=String(u.font_variant),_.includes(f.variants,u.font_variant)||delete u.font_variant):delete u.font_variant,o.set(u),l[n]=!1},p=function(n,i,o){if(!0===c[o])return;c[o]=!0;t(n).find(".font-options__options-list").find("[data-value_entry]").each((function(n,o){const a=t(o),s=a.data("value_entry");if(void 0!==s&&""!==s&&void 0!==i[s]){if(_.includes(["letter_spacing","line_height","font_size"],s)){const t=m(i[s],o);""!==t.unit&&(a.data("value_unit",t.unit),_.isEmpty(a.attr("unit"))&&a.attr("unit",t.unit));const n=16,l=a.attr("unit").trim().toLowerCase(),c=a.data("value_unit").trim().toLowerCase();l!=c&&(_.includes(["em","rem"],c)&&"px"===l?t.value=g(t.value*n,e.fonts.floatPrecision):_.includes(["em","rem"],l)&&"px"===c&&(t.value=g(t.value/n,e.fonts.floatPrecision))),a.attr("min")&&a.attr("min")>t.value&&a.attr("min",t.value),a.attr("max")&&a.attr("max")<t.value&&a.attr("max",t.value),a.val(t.value)}else a.val(i[s]);a.data("touched",!1),a.trigger("change",["customify"])}})),c[o]=!1},m=function(e,n=!1,i=!0){const o={value:!1,unit:!1};if(_.includes(["","false",!1],e))return o;if(isNaN(e)){if(void 0!==e.value)o.value=e.value,void 0!==e.unit&&(o.unit=e.unit);else if(void 0!==e[0])o.value=e[0],void 0!==e[1]&&(o.unit=e[1]);else if("string"==typeof e){const t=e.match(/^([\d.\-+]+)(.+)/i);null!==t&&void 0!==t[1]?(o.value=t[1],_.isEmpty(t[2])||(o.unit=t[2])):o.value=e}}else o.value=e;if(!1!==n&&(!1===o.unit||_.isEmpty(o.unit))){let e="";const a=t(n);i?_.isEmpty(a.data("value_unit"))?_.isEmpty(a.attr("unit"))||(e=a.attr("unit")):e=a.data("value_unit"):_.isEmpty(a.attr("unit"))?_.isEmpty(a.data("value_unit"))||(e=a.data("value_unit")):e=a.attr("unit"),o.unit=e}return isNaN(o.value)||(o.value=parseFloat(o.value)),o},h=function(t){let n="system_font";return void 0!==e.fonts.third_party_fonts[t]?n="third_party_font":void 0!==e.fonts.cloud_fonts[t]?n="cloud_font":void 0!==e.fonts.theme_fonts[t]?n="theme_font":void 0!==e.fonts.google_fonts[t]&&(n="google_font"),n},y=function(t,n=!1){switch(!1===n&&(n=h(t)),n){case"theme_font":return e.fonts.theme_fonts[t];case"cloud_font":return e.fonts.cloud_fonts[t];case"google_font":return e.fonts.google_fonts[t];case"system_font":if(void 0!==e.fonts.system_fonts[t])return e.fonts.system_fonts[t];break;case"third_party_font":if(void 0!==e.fonts.third_party_fonts[t])return e.fonts.third_party_fonts[t]}return!1},g=function(t,e){const n=Math.pow(10,e);return Math.round(t*n)/n};return{init:function(){o=e.l10n.fonts.familyPlaceholderText,a=e.l10n.fonts.variantAutoText;const n=t(".customify_font_family");void 0!==s.settings.google_fonts_opts&&n.each((function(e,n){const i=t(n).find(".google-fonts-opts-placeholder").first();if(i){i.replaceWith(s.settings.google_fonts_opts);const e=t(n).data("active_font_family");void 0!==e&&t(n).val(e)}})),n.select2({placeholder:o}),n.on("change",(function(e,n){const o=e.target.value,a=t(e.target).closest(i),l=t(a.children(".customify_font_values")).data("customize-setting-link"),c=(s(l),y(o));r(c,a),d(c,a),void 0!==n&&"customify"===n||(t(e.target).data("touched",!0),v(a,l))})),n.each((function(e,n){const o=t(n).closest(i),a=t(o.children(".customify_font_values")).data("customize-setting-link");s(a).bind((function(t,e){l[this.id]||p(o,t,this.id)}))})),u(t(".customify_font_weight"),!0),u(n.parents(i).find("select").not("select[class*=' select2'],select[class^='select2']"),!1),u(n.parents(i).find("input[type=range]"),!1),f()},selfUpdateValue:v,standardizeNumericalValue:m,determineFontType:h,getFontDetails:y,convertFontVariantToFVD:function(t){let e,n="n";switch(-1!==(t=String(t)).indexOf("italic")?(n="i",t=t.replace("italic","")):-1!==t.indexOf("oblique")&&(n="o",t=t.replace("oblique","")),t){case"100":e="1";break;case"200":e="2";break;case"300":e="3";break;case"500":e="5";break;case"600":e="6";break;case"700":case"bold":e="7";break;case"800":e="8";break;case"900":e="9";break;default:e="4"}return n+e},round:g}}())}(jQuery,customify,wp);
|
js/jquery.cssUpdate.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
/*
|
2 |
-
* cssUpdate - v1.
|
3 |
*/
|
4 |
|
5 |
/** @namespace customify */
|
@@ -28,6 +28,11 @@ window.customify = window.customify || parent.customify || {}
|
|
28 |
this.changeProperties()
|
29 |
},
|
30 |
|
|
|
|
|
|
|
|
|
|
|
31 |
changeProperties: function () {
|
32 |
|
33 |
const self = this,
|
@@ -91,7 +96,14 @@ window.customify = window.customify || parent.customify || {}
|
|
91 |
// Plugin wrapper
|
92 |
$.fn[pluginName] = function (options) {
|
93 |
this.each(function () {
|
94 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
})
|
96 |
|
97 |
// chain jQuery functions
|
1 |
/*
|
2 |
+
* cssUpdate - v1.0.0
|
3 |
*/
|
4 |
|
5 |
/** @namespace customify */
|
28 |
this.changeProperties()
|
29 |
},
|
30 |
|
31 |
+
update_plugin: function (options) {
|
32 |
+
this.settings = $.extend({}, defaults, options)
|
33 |
+
this.changeProperties()
|
34 |
+
},
|
35 |
+
|
36 |
changeProperties: function () {
|
37 |
|
38 |
const self = this,
|
96 |
// Plugin wrapper
|
97 |
$.fn[pluginName] = function (options) {
|
98 |
this.each(function () {
|
99 |
+
|
100 |
+
const old_plugin = $(this).data('plugin_cssUpdate')
|
101 |
+
|
102 |
+
if (typeof old_plugin !== 'undefined') {
|
103 |
+
old_plugin.update_plugin(options)
|
104 |
+
} else {
|
105 |
+
$.data(this, 'plugin_' + pluginName, new cssLiveUpdater(this, options))
|
106 |
+
}
|
107 |
})
|
108 |
|
109 |
// chain jQuery functions
|
js/jquery.cssUpdate.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
window.customify=window.customify||parent.customify||{},function(t,s,e){const i={properties:["color"],propertyValue:"pink",classes:"Null"};function n(s,e){this.element=s,this.settings=t.extend({},i,e),this._defaults=i,this._name="cssUpdate",this._cssproperties=CSSOM.parse(t(this.element).html()),this.init()}n.prototype={init:function(){this.changeProperties()},changeProperties:function(){const s=this,e=this._cssproperties.cssRules;void 0!==e[0]&&e[0].hasOwnProperty("media")?t.each(e,(function(i,n){t.each(n.cssRules,(function(t,n){const o=n.style[0];e[i].cssRules[t].style[o]=s.updateCssRule(o,s.settings,e[i].cssRules[t].selectorText)}))})):t.each(e,(function(t,i){if(i.hasOwnProperty("style")){const n=i.style[0];e[t].style[n]=s.updateCssRule(n,s.settings,e[t].selectorText)}})),t(this.element).html(this._cssproperties.toString())},updateCssRule:function(t,i,n){const o=i.propertyValue,c=i.negative_value?"-":"";let p=void 0!==this.settings.unit?this.settings.unit:"";return""===p&&-1!==e.config.px_dependent_css_props.indexOf(t)&&(p="px"),"function"==typeof s[i.properties.callback]?(s[i.properties.callback](o,n,t,p),""):c+o+p}},t.fn.cssUpdate=function(s){return this.each((function(){t.data(this,"plugin_cssUpdate",new n(this,s))})),this}}(jQuery,window,customify);
|
1 |
+
window.customify=window.customify||parent.customify||{},function(t,s,e){const i={properties:["color"],propertyValue:"pink",classes:"Null"};function n(s,e){this.element=s,this.settings=t.extend({},i,e),this._defaults=i,this._name="cssUpdate",this._cssproperties=CSSOM.parse(t(this.element).html()),this.init()}n.prototype={init:function(){this.changeProperties()},update_plugin:function(s){this.settings=t.extend({},i,s),this.changeProperties()},changeProperties:function(){const s=this,e=this._cssproperties.cssRules;void 0!==e[0]&&e[0].hasOwnProperty("media")?t.each(e,(function(i,n){t.each(n.cssRules,(function(t,n){const o=n.style[0];e[i].cssRules[t].style[o]=s.updateCssRule(o,s.settings,e[i].cssRules[t].selectorText)}))})):t.each(e,(function(t,i){if(i.hasOwnProperty("style")){const n=i.style[0];e[t].style[n]=s.updateCssRule(n,s.settings,e[t].selectorText)}})),t(this.element).html(this._cssproperties.toString())},updateCssRule:function(t,i,n){const o=i.propertyValue,c=i.negative_value?"-":"";let p=void 0!==this.settings.unit?this.settings.unit:"";return""===p&&-1!==e.config.px_dependent_css_props.indexOf(t)&&(p="px"),"function"==typeof s[i.properties.callback]?(s[i.properties.callback](o,n,t,p),""):c+o+p}},t.fn.cssUpdate=function(s){return this.each((function(){const e=t(this).data("plugin_cssUpdate");void 0!==e?e.update_plugin(s):t.data(this,"plugin_cssUpdate",new n(this,s))})),this}}(jQuery,window,customify);
|
readme.txt
CHANGED
@@ -2,9 +2,9 @@
|
|
2 |
Contributors: pixelgrade, vlad.olaru, babbardel, razvanonofrei, gorby31
|
3 |
Tags: design, customizer, fonts, colors, gutenberg, font palettes, color palettes
|
4 |
Requires at least: 4.9.14
|
5 |
-
Tested up to: 5.
|
6 |
-
Stable tag: 2.10.
|
7 |
-
Requires PHP: 5.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -30,6 +30,11 @@ This plugin is **primarily intended** to be used together with [Pixelgrade theme
|
|
30 |
|
31 |
== Changelog ==
|
32 |
|
|
|
|
|
|
|
|
|
|
|
33 |
= 2.10.3 =
|
34 |
* Avoid invisible text failure in the Customizer Preview when all webfonts fail to load.
|
35 |
* Better missing font-variants handling.
|
2 |
Contributors: pixelgrade, vlad.olaru, babbardel, razvanonofrei, gorby31
|
3 |
Tags: design, customizer, fonts, colors, gutenberg, font palettes, color palettes
|
4 |
Requires at least: 4.9.14
|
5 |
+
Tested up to: 5.7.2
|
6 |
+
Stable tag: 2.10.4
|
7 |
+
Requires PHP: 5.6.40
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
30 |
|
31 |
== Changelog ==
|
32 |
|
33 |
+
= 2.10.4 =
|
34 |
+
* Tested with the latest WordPress version.
|
35 |
+
* Better handling of third-party provided fonts.
|
36 |
+
* Provide the pixelgrade_option() getter for better compatibility.
|
37 |
+
|
38 |
= 2.10.3 =
|
39 |
* Avoid invisible text failure in the Customizer Preview when all webfonts fail to load.
|
40 |
* Better missing font-variants handling.
|