Version Description
- Fixed WordPress 4.7 incompatibilities
Download this release
Release Info
Developer | vlad.olaru |
Plugin | Customify – A Theme Customizer Booster |
Version | 1.2.5 |
Comparing to | |
See all releases |
Code changes from version 1.2.3 to 1.2.5
- class-pixcustomify.php +89 -19
- customify.php +1 -1
- features/class-CSS_Editor.php +26 -0
- features/customizer/controls/class-Pix_Customize_Preset_Control.php +1 -1
- features/customizer/controls/class-Pix_Customize_Typography_Control.php +84 -42
- js/customizer.js +115 -67
- readme.txt +11 -3
class-pixcustomify.php
CHANGED
@@ -20,7 +20,7 @@ class PixCustomifyPlugin {
|
|
20 |
* @since 1.0.0
|
21 |
* @const string
|
22 |
*/
|
23 |
-
protected $version = '1.2.
|
24 |
/**
|
25 |
* Unique identifier for your plugin.
|
26 |
* Use this value (not the variable name) as the text domain when internationalizing strings of text. It should
|
@@ -425,7 +425,8 @@ class PixCustomifyPlugin {
|
|
425 |
wp_enqueue_script( 'jquery-react', plugins_url( 'js/jquery-react.js', __FILE__ ), array( 'jquery' ), $this->version );
|
426 |
wp_enqueue_script( $this->plugin_slug . '-customizer-scripts', plugins_url( 'js/customizer.js', __FILE__ ), array(
|
427 |
'jquery',
|
428 |
-
'select2'
|
|
|
429 |
), $this->version );
|
430 |
|
431 |
wp_localize_script( $this->plugin_slug . '-customizer-scripts', 'customify_settings', self::$localized );
|
@@ -694,7 +695,7 @@ class PixCustomifyPlugin {
|
|
694 |
$font['value'] = json_encode( $font['value'] );
|
695 |
}
|
696 |
|
697 |
-
$value = json_decode( wp_unslash( $font['value'] ), true );
|
698 |
|
699 |
// in case the value is still null, try default value(mostly for google fonts)
|
700 |
if ( ! is_array( $value ) || $value === null ) {
|
@@ -787,7 +788,7 @@ class PixCustomifyPlugin {
|
|
787 |
|
788 |
if ( isset( $font['selector'] ) && isset( $font['value'] ) && ! empty( $font['value'] ) ) {
|
789 |
|
790 |
-
$value = json_decode( $font['value'], true );
|
791 |
// in case the value is still null, try default value(mostly for google fonts)
|
792 |
if ( $value === null ) {
|
793 |
$value = $this->get_font_defaults_value( $font['value'] );
|
@@ -803,37 +804,69 @@ class PixCustomifyPlugin {
|
|
803 |
$value = $this->process_a_not_associative_font_default( $value );
|
804 |
}
|
805 |
|
806 |
-
|
807 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
808 |
|
809 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
810 |
|
811 |
-
|
812 |
-
|
813 |
-
|
814 |
-
$the_weight = $value['selected_variants'];
|
815 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
816 |
|
817 |
$italic_font = false;
|
818 |
|
819 |
-
if
|
820 |
-
|
|
|
821 |
$italic_font = true;
|
822 |
}
|
823 |
|
824 |
-
if ( ! empty( $
|
825 |
-
|
826 |
-
|
|
|
827 |
}
|
828 |
-
echo "
|
829 |
}
|
830 |
|
831 |
if ( $italic_font ) {
|
832 |
-
echo "
|
833 |
}
|
834 |
}
|
835 |
|
836 |
-
echo "
|
837 |
}
|
838 |
}
|
839 |
} ?>
|
@@ -1740,4 +1773,41 @@ class PixCustomifyPlugin {
|
|
1740 |
function get_options_configs () {
|
1741 |
return self::$options_list;
|
1742 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1743 |
}
|
20 |
* @since 1.0.0
|
21 |
* @const string
|
22 |
*/
|
23 |
+
protected $version = '1.2.5';
|
24 |
/**
|
25 |
* Unique identifier for your plugin.
|
26 |
* Use this value (not the variable name) as the text domain when internationalizing strings of text. It should
|
425 |
wp_enqueue_script( 'jquery-react', plugins_url( 'js/jquery-react.js', __FILE__ ), array( 'jquery' ), $this->version );
|
426 |
wp_enqueue_script( $this->plugin_slug . '-customizer-scripts', plugins_url( 'js/customizer.js', __FILE__ ), array(
|
427 |
'jquery',
|
428 |
+
'select2',
|
429 |
+
'underscore',
|
430 |
), $this->version );
|
431 |
|
432 |
wp_localize_script( $this->plugin_slug . '-customizer-scripts', 'customify_settings', self::$localized );
|
695 |
$font['value'] = json_encode( $font['value'] );
|
696 |
}
|
697 |
|
698 |
+
$value = json_decode( wp_unslash( PixCustomifyPlugin::decodeURIComponent( $font['value'] ) ), true );
|
699 |
|
700 |
// in case the value is still null, try default value(mostly for google fonts)
|
701 |
if ( ! is_array( $value ) || $value === null ) {
|
788 |
|
789 |
if ( isset( $font['selector'] ) && isset( $font['value'] ) && ! empty( $font['value'] ) ) {
|
790 |
|
791 |
+
$value = json_decode( PixCustomifyPlugin::decodeURIComponent( $font['value'] ), true );
|
792 |
// in case the value is still null, try default value(mostly for google fonts)
|
793 |
if ( $value === null ) {
|
794 |
$value = $this->get_font_defaults_value( $font['value'] );
|
804 |
$value = $this->process_a_not_associative_font_default( $value );
|
805 |
}
|
806 |
|
807 |
+
$selected_variant = '';
|
808 |
+
if ( ! empty( $value['selected_variants'] ) ) {
|
809 |
+
if ( is_array( $value['selected_variants'] ) ) {
|
810 |
+
$selected_variant = $value['selected_variants'][0];
|
811 |
+
} else {
|
812 |
+
$selected_variant = $value['selected_variants'];
|
813 |
+
}
|
814 |
+
}
|
815 |
|
816 |
+
// First handle the case where we have the font-family in the selected variant (usually this means a custom font from our Fonto plugin)
|
817 |
+
if ( ! empty( $selected_variant ) && is_array( $selected_variant ) && ! empty( $selected_variant['font-family'] ) ) {
|
818 |
+
//the variant's font-family
|
819 |
+
echo $font['selector'] . " {\nfont-family: " . $selected_variant['font-family'] . ";\n";
|
820 |
+
|
821 |
+
if ( ! $load_all_weights ) {
|
822 |
+
// if this is a custom font (like from our plugin Fonto) with individual styles & weights - i.e. the font-family says it all
|
823 |
+
// we need to "force" the font-weight and font-style
|
824 |
+
if ( ! empty( $value['type'] ) && 'custom_individual' == $value['type'] ) {
|
825 |
+
$selected_variant['font-weight'] = '400 !important';
|
826 |
+
$selected_variant['font-style'] = 'normal !important';
|
827 |
+
}
|
828 |
+
|
829 |
+
// output the font weight, if available
|
830 |
+
if ( ! empty( $selected_variant['font-weight'] ) ) {
|
831 |
+
echo "font-weight: " . $selected_variant['font-weight'] . ";\n";
|
832 |
+
}
|
833 |
|
834 |
+
// output the font style, if available
|
835 |
+
if ( ! empty( $selected_variant['font-style'] ) ) {
|
836 |
+
echo "font-style: " . $selected_variant['font-style'] . ";\n";
|
|
|
837 |
}
|
838 |
+
}
|
839 |
+
|
840 |
+
echo "}\n";
|
841 |
+
} elseif ( isset( $value['font_family'] ) ) {
|
842 |
+
// the selected font family
|
843 |
+
echo $font['selector'] . " {\n font-family: " . $value['font_family'] . ";\n";
|
844 |
+
|
845 |
+
if ( ! empty( $selected_variant ) && ! $load_all_weights ) {
|
846 |
+
$weight_and_style = strtolower( $selected_variant );
|
847 |
|
848 |
$italic_font = false;
|
849 |
|
850 |
+
//determine if this is an italic font (the $weight_and_style is usually like '400' or '400italic' )
|
851 |
+
if ( strpos( $weight_and_style, 'italic' ) !== false ) {
|
852 |
+
$weight_and_style = str_replace( 'italic', '', $weight_and_style);
|
853 |
$italic_font = true;
|
854 |
}
|
855 |
|
856 |
+
if ( ! empty( $weight_and_style ) ) {
|
857 |
+
//a little bit of sanity check - in case it's not a number
|
858 |
+
if( $weight_and_style === 'regular' ) {
|
859 |
+
$weight_and_style = 'normal';
|
860 |
}
|
861 |
+
echo "font-weight: " . $weight_and_style . ";\n";
|
862 |
}
|
863 |
|
864 |
if ( $italic_font ) {
|
865 |
+
echo "font-style: italic;\n";
|
866 |
}
|
867 |
}
|
868 |
|
869 |
+
echo "}\n";
|
870 |
}
|
871 |
}
|
872 |
} ?>
|
1773 |
function get_options_configs () {
|
1774 |
return self::$options_list;
|
1775 |
}
|
1776 |
+
|
1777 |
+
/**
|
1778 |
+
* Does the same thing the JS encodeURIComponent() does
|
1779 |
+
*
|
1780 |
+
* @param string $str
|
1781 |
+
*
|
1782 |
+
* @return string
|
1783 |
+
*/
|
1784 |
+
public static function encodeURIComponent( $str ) {
|
1785 |
+
//if we get an array we just let it be
|
1786 |
+
if ( is_string( $str ) ) {
|
1787 |
+
$revert = array( '%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')' );
|
1788 |
+
|
1789 |
+
$str = strtr( rawurlencode( $str ), $revert );
|
1790 |
+
} else {
|
1791 |
+
var_dump('boooom');die;
|
1792 |
+
}
|
1793 |
+
|
1794 |
+
return $str;
|
1795 |
+
}
|
1796 |
+
|
1797 |
+
/**
|
1798 |
+
* Does the same thing the JS decodeURIComponent() does
|
1799 |
+
*
|
1800 |
+
* @param string $str
|
1801 |
+
*
|
1802 |
+
* @return string
|
1803 |
+
*/
|
1804 |
+
public static function decodeURIComponent( $str ) {
|
1805 |
+
//if we get an array we just let it be
|
1806 |
+
if ( is_string( $str ) ) {
|
1807 |
+
$revert = array( '!' => '%21', '*' => '%2A', "'" => '%27', '(' => '%28', ')' => '%29' );
|
1808 |
+
$str = rawurldecode( strtr( $str, $revert ) );
|
1809 |
+
}
|
1810 |
+
|
1811 |
+
return $str;
|
1812 |
+
}
|
1813 |
}
|
customify.php
CHANGED
@@ -10,7 +10,7 @@
|
|
10 |
Plugin Name: Customify
|
11 |
Plugin URI: http://pixelgrade.com
|
12 |
Description: A Theme Customizer Booster
|
13 |
-
Version: 1.2.
|
14 |
Author: PixelGrade
|
15 |
Author URI: http://pixelgrade.com
|
16 |
Author Email: contact@pixelgrade.com
|
10 |
Plugin Name: Customify
|
11 |
Plugin URI: http://pixelgrade.com
|
12 |
Description: A Theme Customizer Booster
|
13 |
+
Version: 1.2.5
|
14 |
Author: PixelGrade
|
15 |
Author URI: http://pixelgrade.com
|
16 |
Author Email: contact@pixelgrade.com
|
features/class-CSS_Editor.php
CHANGED
@@ -17,6 +17,9 @@ class Customify_CSS_Live_Editor {
|
|
17 |
|
18 |
$load_location = PixCustomifyPlugin::get_plugin_option( 'style_resources_location', 'wp_head' );
|
19 |
add_action( $load_location, array( $this, 'output_dynamic_style' ), 999999999 );
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
/**
|
@@ -45,6 +48,10 @@ class Customify_CSS_Live_Editor {
|
|
45 |
}
|
46 |
|
47 |
function cle_create_custom_control( $wp_customize ) {
|
|
|
|
|
|
|
|
|
48 |
|
49 |
$wp_customize->add_section( 'live_css_edit_section', array(
|
50 |
'priority' => 11,
|
@@ -95,6 +102,11 @@ selector {
|
|
95 |
}
|
96 |
|
97 |
function output_dynamic_style() {
|
|
|
|
|
|
|
|
|
|
|
98 |
$store_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
|
99 |
if ( $store_type === 'option' ) {
|
100 |
$output = get_option( 'live_css_edit' );
|
@@ -110,6 +122,20 @@ selector {
|
|
110 |
</style>
|
111 |
<?php
|
112 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
}
|
114 |
|
115 |
$customify_CSS_Editor = Customify_CSS_Live_Editor::get_instance();
|
17 |
|
18 |
$load_location = PixCustomifyPlugin::get_plugin_option( 'style_resources_location', 'wp_head' );
|
19 |
add_action( $load_location, array( $this, 'output_dynamic_style' ), 999999999 );
|
20 |
+
|
21 |
+
//Check the WordPress version and if there are known problems disable it
|
22 |
+
add_filter( 'customify_css_live_editor_enabled', array( $this, 'disable_if_wp_incompatible' ), 10, 1 );
|
23 |
}
|
24 |
|
25 |
/**
|
48 |
}
|
49 |
|
50 |
function cle_create_custom_control( $wp_customize ) {
|
51 |
+
// Allow others to short-circuit us
|
52 |
+
if ( ! apply_filters( 'customify_css_live_editor_enabled', true ) ) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
|
56 |
$wp_customize->add_section( 'live_css_edit_section', array(
|
57 |
'priority' => 11,
|
102 |
}
|
103 |
|
104 |
function output_dynamic_style() {
|
105 |
+
// Allow others to short-circuit us
|
106 |
+
if ( ! apply_filters( 'customify_css_live_editor_enabled', true ) ) {
|
107 |
+
return;
|
108 |
+
}
|
109 |
+
|
110 |
$store_type = PixCustomifyPlugin::get_plugin_option( 'values_store_mod', 'option' );
|
111 |
if ( $store_type === 'option' ) {
|
112 |
$output = get_option( 'live_css_edit' );
|
122 |
</style>
|
123 |
<?php
|
124 |
}
|
125 |
+
|
126 |
+
function disable_if_wp_incompatible( $enabled ) {
|
127 |
+
global $wp_version;
|
128 |
+
|
129 |
+
// WordPress 4.7 introduced a Customizer CSS editor that conflicts with our own
|
130 |
+
// It's best to leave only the one in core
|
131 |
+
// So only load our CSS editor for WP version smaller than 4.7
|
132 |
+
// We use 4.6.9 to catch the release candidates also
|
133 |
+
if ( version_compare( $wp_version, '4.6.9', '>=' ) ) {
|
134 |
+
return false;
|
135 |
+
}
|
136 |
+
|
137 |
+
return $enabled;
|
138 |
+
}
|
139 |
}
|
140 |
|
141 |
$customify_CSS_Editor = Customify_CSS_Live_Editor::get_instance();
|
features/customizer/controls/class-Pix_Customize_Preset_Control.php
CHANGED
@@ -189,7 +189,7 @@ class Pix_Customize_Preset_Control extends Pix_Customize_Control {
|
|
189 |
|
190 |
// ok now we have our preview fonts, let's ask them from google
|
191 |
// note that we request only these chars "AaBbCc" so it should be a small request
|
192 |
-
echo '<link href="
|
193 |
</div>
|
194 |
|
195 |
<?php
|
189 |
|
190 |
// ok now we have our preview fonts, let's ask them from google
|
191 |
// note that we request only these chars "AaBbCc" so it should be a small request
|
192 |
+
echo '<link href="//fonts.googleapis.com/css?family=' . implode('|', $google_links ) . '&text=AaBbCc' . substr( get_bloginfo('name'), 0, 2) . '" rel=\'stylesheet\' type=\'text/css\'>';?>
|
193 |
</div>
|
194 |
|
195 |
<?php
|
features/customizer/controls/class-Pix_Customize_Typography_Control.php
CHANGED
@@ -101,34 +101,40 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
101 |
* @since 3.4.0
|
102 |
*/
|
103 |
public function render_content() {
|
104 |
-
|
105 |
$current_value = $this->value();
|
106 |
-
|
|
|
|
|
|
|
107 |
$current_value = $this->get_default_values();
|
108 |
}
|
109 |
-
// if this value was an array,
|
110 |
if ( is_array( $current_value ) ) {
|
111 |
if ( isset( $current_value['font-family'] ) ) {
|
112 |
$current_value['font_family'] = $current_value['font-family'];
|
113 |
unset( $current_value['font-family'] );
|
114 |
}
|
115 |
-
|
|
|
|
|
116 |
}
|
117 |
-
|
|
|
|
|
118 |
|
119 |
$font_family = '';
|
120 |
-
if ( isset( $
|
121 |
-
$font_family = $
|
122 |
}
|
123 |
|
124 |
-
if ( isset( $
|
125 |
-
$this->load_all_weights = $
|
126 |
} ?>
|
127 |
<label class="customify_typography">
|
128 |
<?php if ( ! empty( $this->label ) ) : ?>
|
129 |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
|
130 |
-
<?php endif;
|
131 |
-
|
132 |
$this_id = str_replace( '[', '_', $this->id );
|
133 |
$this_id = str_replace( ']', '_', $this_id );
|
134 |
$select_data = '';
|
@@ -139,10 +145,14 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
139 |
/**
|
140 |
* This input will hold the values of this typography field
|
141 |
*/ ?>
|
142 |
-
<input class="customify_typography_values" id="<?php echo $this_id; ?>" type="hidden" <?php $this->link(); ?> value=
|
143 |
<select class="customify_typography_font_family"<?php echo $select_data; ?>>
|
|
|
144 |
<?php
|
|
|
|
|
145 |
|
|
|
146 |
if ( ! empty( $this->typekit_fonts ) ) {
|
147 |
echo '<optgroup label="' . __( 'Typekit', 'customify_txtd' ) . '">';
|
148 |
foreach ( $this->typekit_fonts as $key => $font ) {
|
@@ -151,6 +161,9 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
151 |
echo "</optgroup>";
|
152 |
}
|
153 |
|
|
|
|
|
|
|
154 |
if ( ! empty( $this->recommended ) ) {
|
155 |
|
156 |
echo '<optgroup label="' . __( 'Recommended', 'customify_txtd' ) . '">';
|
@@ -172,6 +185,9 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
172 |
echo "</optgroup>";
|
173 |
}
|
174 |
|
|
|
|
|
|
|
175 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_standard_fonts' ) ) {
|
176 |
|
177 |
echo '<optgroup label="' . __( 'Standard fonts', 'customify_txtd' ) . '">';
|
@@ -181,6 +197,9 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
181 |
echo "</optgroup>";
|
182 |
}
|
183 |
|
|
|
|
|
|
|
184 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_google_fonts' ) ) {
|
185 |
|
186 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_group_google_fonts' ) ) {
|
@@ -221,12 +240,12 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
221 |
<select class="customify_typography_font_weight">
|
222 |
<?php
|
223 |
$selected = array();
|
224 |
-
if ( isset( $
|
225 |
-
$selected = $
|
226 |
}
|
227 |
|
228 |
-
if ( isset( $
|
229 |
-
foreach ( $
|
230 |
$attrs = '';
|
231 |
if ( in_array( $weight, (array) $selected ) ) {
|
232 |
$attrs = ' selected="selected"';
|
@@ -239,19 +258,19 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
239 |
</li>
|
240 |
<?php
|
241 |
$display = 'none';
|
242 |
-
if ( $this->subsets && ! empty( $
|
243 |
$display = 'inline-block';
|
244 |
}?>
|
245 |
<li class="customify_subsets_wrapper" style="display: <?php echo $display; ?>">
|
246 |
<select multiple class="customify_typography_font_subsets">
|
247 |
<?php
|
248 |
$selected = array();
|
249 |
-
if ( isset( $
|
250 |
-
$selected = $
|
251 |
}
|
252 |
|
253 |
-
if ( isset( $
|
254 |
-
foreach ( $
|
255 |
$attrs = '';
|
256 |
if ( in_array( $subset, (array) $selected ) ) {
|
257 |
$attrs .= ' selected="selected"';
|
@@ -270,47 +289,70 @@ class Pix_Customize_Typography_Control extends Pix_Customize_Control {
|
|
270 |
<?php }
|
271 |
|
272 |
/**
|
273 |
-
* This method
|
274 |
*
|
275 |
-
* @param $key
|
276 |
-
* @param $
|
277 |
-
* @param $font
|
278 |
-
* @param string $type
|
279 |
*/
|
280 |
-
|
|
|
281 |
$data = '';
|
282 |
|
283 |
-
$data .= ' data-type="' . $type . '"';
|
284 |
|
|
|
285 |
if ( $type === 'google' ) {
|
286 |
-
|
287 |
if ( isset( $font['variants'] ) && ! empty( $font['variants'] ) ) {
|
288 |
-
$data .= ' data-variants
|
289 |
}
|
290 |
|
291 |
if ( isset( $font['subsets'] ) && ! empty( $font['subsets'] ) ) {
|
292 |
-
$data .= ' data-subsets
|
293 |
}
|
294 |
|
295 |
-
|
|
|
|
|
|
|
296 |
echo '<option value="' . $font['family'] . '"' . $selected . $data . '>' . $font['family'] . '</option>';
|
297 |
} elseif ( $type === 'typekit' ) {
|
|
|
|
|
298 |
|
299 |
-
|
300 |
-
echo '<option class="typekit_font" value="' . $key . '"' . $selected . $data . '>' . $font['name'] . '</option>';
|
301 |
} else {
|
302 |
-
|
303 |
-
if ( is_array($font) && isset( $font['variants'] ) && ! empty( $font['variants'] ) ) {
|
304 |
-
$data .= ' data-variants
|
305 |
}
|
306 |
|
|
|
|
|
|
|
307 |
if ( is_array( $font ) && isset( $font['font_family'] ) ) {
|
308 |
-
$
|
309 |
-
|
310 |
-
|
311 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
}
|
313 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
}
|
315 |
}
|
316 |
|
101 |
* @since 3.4.0
|
102 |
*/
|
103 |
public function render_content() {
|
|
|
104 |
$current_value = $this->value();
|
105 |
+
//maybe we need to decode it
|
106 |
+
$current_value = PixCustomifyPlugin::decodeURIComponent( $current_value );
|
107 |
+
|
108 |
+
if ( empty( $current_value ) || ( is_array( $current_value ) && ( ! isset( $current_value['font_family'] ) || ! isset( $current_value['font-family'] ) ) ) ) {
|
109 |
$current_value = $this->get_default_values();
|
110 |
}
|
111 |
+
// if this value was an array, make sure it is ok
|
112 |
if ( is_array( $current_value ) ) {
|
113 |
if ( isset( $current_value['font-family'] ) ) {
|
114 |
$current_value['font_family'] = $current_value['font-family'];
|
115 |
unset( $current_value['font-family'] );
|
116 |
}
|
117 |
+
} else {
|
118 |
+
//if we've got a string then it is clear we need to decode it
|
119 |
+
$current_value = json_decode( $current_value );
|
120 |
}
|
121 |
+
|
122 |
+
//make sure it is an object from here going forward
|
123 |
+
$current_value = (object) $current_value;
|
124 |
|
125 |
$font_family = '';
|
126 |
+
if ( isset( $current_value->font_family ) ) {
|
127 |
+
$font_family = $current_value->font_family;
|
128 |
}
|
129 |
|
130 |
+
if ( isset( $current_value->load_all_weights ) ) {
|
131 |
+
$this->load_all_weights = $current_value->font_load_all_weights;
|
132 |
} ?>
|
133 |
<label class="customify_typography">
|
134 |
<?php if ( ! empty( $this->label ) ) : ?>
|
135 |
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
|
136 |
+
<?php endif;
|
137 |
+
|
138 |
$this_id = str_replace( '[', '_', $this->id );
|
139 |
$this_id = str_replace( ']', '_', $this_id );
|
140 |
$select_data = '';
|
145 |
/**
|
146 |
* This input will hold the values of this typography field
|
147 |
*/ ?>
|
148 |
+
<input class="customify_typography_values" id="<?php echo esc_attr( $this_id ); ?>" type="hidden" <?php $this->link(); ?> value="<?php echo esc_attr( PixCustomifyPlugin::encodeURIComponent( json_encode( $current_value ) ) ); ?>" data-default="<?php echo esc_attr( PixCustomifyPlugin::encodeURIComponent( json_encode( $current_value ) ) ); ?>"/>
|
149 |
<select class="customify_typography_font_family"<?php echo $select_data; ?>>
|
150 |
+
|
151 |
<?php
|
152 |
+
// Allow others to add options here
|
153 |
+
do_action( 'customify_typography_font_family_before_options', $font_family, $current_value ); ?>
|
154 |
|
155 |
+
<?php
|
156 |
if ( ! empty( $this->typekit_fonts ) ) {
|
157 |
echo '<optgroup label="' . __( 'Typekit', 'customify_txtd' ) . '">';
|
158 |
foreach ( $this->typekit_fonts as $key => $font ) {
|
161 |
echo "</optgroup>";
|
162 |
}
|
163 |
|
164 |
+
// Allow others to add options here
|
165 |
+
do_action( 'customify_typography_font_family_before_recommended_fonts_options', $font_family, $current_value );
|
166 |
+
|
167 |
if ( ! empty( $this->recommended ) ) {
|
168 |
|
169 |
echo '<optgroup label="' . __( 'Recommended', 'customify_txtd' ) . '">';
|
185 |
echo "</optgroup>";
|
186 |
}
|
187 |
|
188 |
+
// Allow others to add options here
|
189 |
+
do_action( 'customify_typography_font_family_before_standard_fonts_options', $font_family, $current_value );
|
190 |
+
|
191 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_standard_fonts' ) ) {
|
192 |
|
193 |
echo '<optgroup label="' . __( 'Standard fonts', 'customify_txtd' ) . '">';
|
197 |
echo "</optgroup>";
|
198 |
}
|
199 |
|
200 |
+
// Allow others to add options here
|
201 |
+
do_action( 'customify_typography_font_family_before_google_fonts_options' );
|
202 |
+
|
203 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_google_fonts' ) ) {
|
204 |
|
205 |
if ( PixCustomifyPlugin::get_plugin_option( 'typography_group_google_fonts' ) ) {
|
240 |
<select class="customify_typography_font_weight">
|
241 |
<?php
|
242 |
$selected = array();
|
243 |
+
if ( isset( $current_value->selected_variants ) ) {
|
244 |
+
$selected = $current_value->selected_variants;
|
245 |
}
|
246 |
|
247 |
+
if ( isset( $current_value->variants ) && ! empty( $current_value->variants ) && is_array( $current_value->variants ) ) {
|
248 |
+
foreach ( $current_value->variants as $weight ) {
|
249 |
$attrs = '';
|
250 |
if ( in_array( $weight, (array) $selected ) ) {
|
251 |
$attrs = ' selected="selected"';
|
258 |
</li>
|
259 |
<?php
|
260 |
$display = 'none';
|
261 |
+
if ( $this->subsets && ! empty( $current_value->subsets ) ) {
|
262 |
$display = 'inline-block';
|
263 |
}?>
|
264 |
<li class="customify_subsets_wrapper" style="display: <?php echo $display; ?>">
|
265 |
<select multiple class="customify_typography_font_subsets">
|
266 |
<?php
|
267 |
$selected = array();
|
268 |
+
if ( isset( $current_value->selected_subsets ) ) {
|
269 |
+
$selected = $current_value->selected_subsets;
|
270 |
}
|
271 |
|
272 |
+
if ( isset( $current_value->subsets ) && ! empty( $current_value->subsets ) && is_array( $current_value->variants ) ) {
|
273 |
+
foreach ( $current_value->subsets as $key => $subset ) {
|
274 |
$attrs = '';
|
275 |
if ( in_array( $subset, (array) $selected ) ) {
|
276 |
$attrs .= ' selected="selected"';
|
289 |
<?php }
|
290 |
|
291 |
/**
|
292 |
+
* This method displays an <option> tag from the given params
|
293 |
*
|
294 |
+
* @param string $key
|
295 |
+
* @param string $active_font_family
|
296 |
+
* @param string|array $font
|
297 |
+
* @param string string $type
|
298 |
*/
|
299 |
+
public static function output_font_option( $key, $active_font_family, $font, $type = 'google' ) {
|
300 |
+
//initialize data attributes
|
301 |
$data = '';
|
302 |
|
303 |
+
$data .= ' data-type="' . esc_attr( $type ) . '"';
|
304 |
|
305 |
+
//we will handle Google Fonts separately
|
306 |
if ( $type === 'google' ) {
|
307 |
+
// Handle the font variants markup, if available
|
308 |
if ( isset( $font['variants'] ) && ! empty( $font['variants'] ) ) {
|
309 |
+
$data .= ' data-variants="' . PixCustomifyPlugin::encodeURIComponent( json_encode( (object) $font['variants'] ) ) . '"';
|
310 |
}
|
311 |
|
312 |
if ( isset( $font['subsets'] ) && ! empty( $font['subsets'] ) ) {
|
313 |
+
$data .= ' data-subsets="' . PixCustomifyPlugin::encodeURIComponent( json_encode( (object) $font['subsets'] ) ) . '"';
|
314 |
}
|
315 |
|
316 |
+
//determine if it's selected
|
317 |
+
$selected = ( $active_font_family === $font['family'] ) ? ' selected="selected" ' : '';
|
318 |
+
|
319 |
+
//output the markup
|
320 |
echo '<option value="' . $font['family'] . '"' . $selected . $data . '>' . $font['family'] . '</option>';
|
321 |
} elseif ( $type === 'typekit' ) {
|
322 |
+
//we will handle TypeKit Fonts separately
|
323 |
+
$selected = ( $active_font_family === $key ) ? ' selected="selected" ' : '';
|
324 |
|
325 |
+
echo '<option class="typekit_font" value="' . $key . '" ' . $selected . $data . '>' . $font['name'] . '</option>';
|
|
|
326 |
} else {
|
327 |
+
// Handle the font variants markup, if available
|
328 |
+
if ( is_array( $font ) && isset( $font['variants'] ) && ! empty( $font['variants'] ) ) {
|
329 |
+
$data .= ' data-variants="' . PixCustomifyPlugin::encodeURIComponent( json_encode( (object) $font['variants'] ) ) . '"';
|
330 |
}
|
331 |
|
332 |
+
// by default, we assume we only get a font family string
|
333 |
+
$font_family = $font;
|
334 |
+
// when we get an array we expect to get a font_family entry
|
335 |
if ( is_array( $font ) && isset( $font['font_family'] ) ) {
|
336 |
+
$font_family = $font['font_family'];
|
337 |
+
}
|
338 |
+
|
339 |
+
//determine if it's selected
|
340 |
+
$selected = ( $active_font_family === $font_family ) ? ' selected="selected" ' : '';
|
341 |
+
|
342 |
+
//now determine if we have a "pretty" display for this font family
|
343 |
+
$font_family_display = $font_family;
|
344 |
+
if ( is_array( $font ) && isset( $font['font_family_display'] ) ) {
|
345 |
+
$font_family_display = $font['font_family_display'];
|
346 |
}
|
347 |
+
|
348 |
+
//determine the option class
|
349 |
+
if ( empty( $type ) ) {
|
350 |
+
$type = 'std';
|
351 |
+
}
|
352 |
+
$option_class = $type . '_font';
|
353 |
+
|
354 |
+
//output the markup
|
355 |
+
echo '<option class="' . esc_attr( $option_class ) . '" value="' . esc_attr( $font_family ) . '" ' . $selected . $data . '>' . $font_family_display . '</option>';
|
356 |
}
|
357 |
}
|
358 |
|
js/customizer.js
CHANGED
@@ -85,7 +85,7 @@
|
|
85 |
var id = key.replace( '_control', '' );
|
86 |
var setting = customify_settings.settings[id];
|
87 |
|
88 |
-
if (
|
89 |
|
90 |
var start_pos = id.indexOf( '[' ) + 1;
|
91 |
var end_pos = id.indexOf( ']', start_pos );
|
@@ -130,7 +130,7 @@
|
|
130 |
var id = ctrl.id.replace( '_control', '' ),
|
131 |
setting = customify_settings.settings[id];
|
132 |
|
133 |
-
if (
|
134 |
|
135 |
var start_pos = id.indexOf( '[' ) + 1,
|
136 |
end_pos = id.indexOf( ']', start_pos );
|
@@ -149,11 +149,11 @@
|
|
149 |
var section = $( this ).parent(),
|
150 |
section_id = section.attr( 'id' );
|
151 |
|
152 |
-
if ( (
|
153 |
return;
|
154 |
}
|
155 |
|
156 |
-
if (
|
157 |
var id = section_id.replace( 'accordion-section-', '' );
|
158 |
$( this ).prepend( '<button class="reset_section button" data-section="' + id + '">Section\'s defaults</button>' );
|
159 |
}
|
@@ -178,7 +178,7 @@
|
|
178 |
var id = ctrl.id.replace( '_control', '' ),
|
179 |
setting = customify_settings.settings[id];
|
180 |
|
181 |
-
if (
|
182 |
|
183 |
var start_pos = id.indexOf( '[' ) + 1,
|
184 |
end_pos = id.indexOf( ']', start_pos );
|
@@ -201,10 +201,12 @@
|
|
201 |
var $input = $( this ).parents( '.options' ).siblings( '.customify_typography' ).children( '.customify_typography_values' ),
|
202 |
current_val = $input.val();
|
203 |
|
204 |
-
current_val = JSON.parse( current_val );
|
205 |
-
current_val.selected_subsets = $( this ).val();
|
206 |
|
207 |
-
|
|
|
|
|
|
|
208 |
|
209 |
$input.trigger( 'change' );
|
210 |
} );
|
@@ -214,12 +216,14 @@
|
|
214 |
var $input = $( this ).parents( '.options' ).siblings( '.customify_typography' ).children( '.customify_typography_values' ),
|
215 |
current_val = $input.val();
|
216 |
|
217 |
-
current_val =
|
218 |
// @todo currently the font weight selector works for one value only
|
219 |
// maybe make this a multiselect
|
220 |
-
current_val.selected_variants = {0: $( this ).val()};
|
221 |
|
222 |
-
|
|
|
|
|
|
|
223 |
$input.trigger( 'change' );
|
224 |
} );
|
225 |
|
@@ -229,7 +233,7 @@
|
|
229 |
this_option = $( this ).children( '[value="' + $( this ).val() + '"]' ),
|
230 |
data = $( this_option ).data( 'options' );
|
231 |
|
232 |
-
if (
|
233 |
$.each( data, function( id, value ) {
|
234 |
api_set_setting_value( id, value );
|
235 |
} );
|
@@ -243,7 +247,7 @@
|
|
243 |
var this_option = this;//$(this).children('[value="' + $(this).val() + '"]');
|
244 |
var data = $( this_option ).data( 'options' );
|
245 |
|
246 |
-
if (
|
247 |
$.each( data, function( id, value ) {
|
248 |
api_set_setting_value( id, value );
|
249 |
} );
|
@@ -271,10 +275,10 @@
|
|
271 |
/// calculate the number of steps
|
272 |
var steps = [];
|
273 |
|
274 |
-
if (
|
275 |
|
276 |
$.each( customify_settings.settings[key].imports, function( i, import_setts, k ) {
|
277 |
-
if (
|
278 |
steps.push( {id: i, type: import_setts.type} );
|
279 |
} else {
|
280 |
var count = import_setts.steps;
|
@@ -309,7 +313,7 @@
|
|
309 |
*/
|
310 |
var customifyFoldingFields = function() {
|
311 |
|
312 |
-
if (
|
313 |
return ; // bail
|
314 |
}
|
315 |
|
@@ -338,7 +342,7 @@
|
|
338 |
|
339 |
var process_a_target = function( parent_id, field ) {
|
340 |
|
341 |
-
if (
|
342 |
return ; // no id, no fun
|
343 |
}
|
344 |
|
@@ -351,15 +355,15 @@
|
|
351 |
var target_type = customify_settings.settings[ target_key ].type;
|
352 |
|
353 |
|
354 |
-
if (
|
355 |
value = field[1];
|
356 |
}
|
357 |
|
358 |
-
if (
|
359 |
compare = field[2];
|
360 |
}
|
361 |
|
362 |
-
if (
|
363 |
action = field[3];
|
364 |
}
|
365 |
|
@@ -406,9 +410,9 @@
|
|
406 |
* The 'show_on' can be a simple array with one target like: [ id, value, comparison, action ]
|
407 |
* Or it could be an array of multiple targets and we need to process both cases
|
408 |
*/
|
409 |
-
if (
|
410 |
process_a_target( parent_id, field.show_on );
|
411 |
-
} else if (
|
412 |
$.each( field.show_on, function (i, j) {
|
413 |
process_a_target( parent_id, j );
|
414 |
});
|
@@ -427,7 +431,7 @@
|
|
427 |
return {font_family: font_family_value};
|
428 |
}
|
429 |
|
430 |
-
if (
|
431 |
return font_family_value.font_family;
|
432 |
}
|
433 |
|
@@ -459,15 +463,15 @@
|
|
459 |
field = $( '[data-customize-setting-link="' + setting_id + '"]' ),
|
460 |
field_class = $( field ).parent().attr( 'class' );
|
461 |
|
462 |
-
if (
|
463 |
|
464 |
var family_select = field.siblings( 'select' );
|
465 |
|
466 |
-
if (
|
467 |
var this_option = family_select.find( 'option[value="' + value + '"]' );
|
468 |
$( this_option[0] ).attr( 'selected', 'selected' );
|
469 |
update_siblings_selects( family_select );
|
470 |
-
} else if (
|
471 |
var this_family_option = family_select.find( 'option[value="' + value['font_family'] + '"]' );
|
472 |
$( this_family_option[0] ).attr( 'selected', 'selected' );
|
473 |
|
@@ -502,15 +506,15 @@
|
|
502 |
|
503 |
if ( current_val === '[object Object]' ) {
|
504 |
current_val = $input.data( 'default' );
|
505 |
-
} else if (
|
506 |
// a rare case when the value isn't a json but is a representative string like [family,weight]
|
507 |
current_val = current_val.split( ',' );
|
508 |
var new_current_value = {};
|
509 |
-
if (
|
510 |
new_current_value['font_family'] = current_val[0];
|
511 |
}
|
512 |
|
513 |
-
if (
|
514 |
new_current_value['selected_variants'] = current_val[1];
|
515 |
}
|
516 |
|
@@ -521,11 +525,11 @@
|
|
521 |
$font_subsets = $( font_select ).parent().siblings( 'ul.options' ).find( '.customify_typography_font_subsets' );
|
522 |
|
523 |
try {
|
524 |
-
current_val = JSON.parse( current_val );
|
525 |
} catch ( e ) {
|
526 |
|
527 |
// in case of an error, force the rebuild of the json
|
528 |
-
if (
|
529 |
|
530 |
$( font_select ).data( 'bound_once', true );
|
531 |
//var api = wp.customize;
|
@@ -536,9 +540,10 @@
|
|
536 |
$font_subsets.change();
|
537 |
}
|
538 |
}
|
|
|
539 |
// first try to get the font from sure sources, not from the recommended list.
|
540 |
var option_data = $( font_select ).find( ':not(optgroup[label=Recommended]) option[value="' + selected_font + '"]' );
|
541 |
-
//
|
542 |
if ( option_data.length < 1 ) {
|
543 |
option_data = $( font_select ).find( 'option[value="' + selected_font + '"]' );
|
544 |
}
|
@@ -552,17 +557,20 @@
|
|
552 |
|
553 |
if ( font_type == 'std' ) {
|
554 |
variants = { 0: '100', 1: '200', 3: '300', 4: '400', 5: '500', 6: '600', 7: '700', 8: '800', 9: '900' };
|
555 |
-
if (
|
556 |
-
|
|
|
557 |
}
|
558 |
-
|
559 |
} else {
|
560 |
-
|
561 |
-
|
|
|
|
|
|
|
562 |
}
|
563 |
|
564 |
// make the variants selector
|
565 |
-
if (
|
566 |
|
567 |
value_to_add['variants'] = variants;
|
568 |
// when a font is selected force the first weight to load
|
@@ -571,18 +579,43 @@
|
|
571 |
var variants_options = '',
|
572 |
count_weights = 0;
|
573 |
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
is_selected = '
|
578 |
-
|
579 |
-
|
580 |
-
|
|
|
|
|
581 |
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
586 |
$font_weight.html( variants_options );
|
587 |
// if there is no weight or just 1 we hide the weight select ... cuz is useless
|
588 |
if ( $( font_select ).data( 'load_all_weights' ) === true || count_weights <= 1 ) {
|
@@ -591,12 +624,12 @@
|
|
591 |
$font_weight.parent().css( 'display', 'inline-block' );
|
592 |
}
|
593 |
}
|
594 |
-
} else if (
|
595 |
$font_weight.parent().css( 'display', 'none' );
|
596 |
}
|
597 |
|
598 |
// make the subsets selector
|
599 |
-
if (
|
600 |
|
601 |
value_to_add['subsets'] = subsets;
|
602 |
// when a font is selected force the first subset to load
|
@@ -605,7 +638,7 @@
|
|
605 |
count_subsets = 0;
|
606 |
$.each( subsets, function( key, el ) {
|
607 |
var is_selected = '';
|
608 |
-
if (
|
609 |
is_selected = ' selected="selected"';
|
610 |
}
|
611 |
|
@@ -613,7 +646,7 @@
|
|
613 |
count_subsets++;
|
614 |
} );
|
615 |
|
616 |
-
if (
|
617 |
$font_subsets.html( subsets_options );
|
618 |
|
619 |
// if there is no subset or just 1 we hide the subsets select ... cuz is useless
|
@@ -623,11 +656,11 @@
|
|
623 |
$font_subsets.parent().css( 'display', 'inline-block' );
|
624 |
}
|
625 |
}
|
626 |
-
} else if (
|
627 |
$font_subsets.parent().css( 'display', 'none' );
|
628 |
}
|
629 |
|
630 |
-
$input.val( JSON.stringify( value_to_add ) );
|
631 |
}
|
632 |
};
|
633 |
|
@@ -640,13 +673,28 @@
|
|
640 |
var inObject = function( value, obj ) {
|
641 |
for ( var k in obj ) {
|
642 |
if ( !obj.hasOwnProperty( k ) ) continue;
|
643 |
-
if ( obj[k]
|
644 |
return true;
|
645 |
}
|
646 |
}
|
647 |
return false;
|
648 |
};
|
649 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
650 |
var customifyBackgroundJsControl = (function() {
|
651 |
"use strict";
|
652 |
|
@@ -718,9 +766,9 @@
|
|
718 |
selector.find( '.upload-width' ).attr( 'value', attachment.attributes.width );
|
719 |
|
720 |
var thumbSrc = attachment.attributes.url;
|
721 |
-
if (
|
722 |
thumbSrc = attachment.attributes.sizes.thumbnail.url;
|
723 |
-
} else if (
|
724 |
var height = attachment.attributes.height;
|
725 |
for ( var key in attachment.attributes.sizes ) {
|
726 |
var object = attachment.attributes.sizes[key];
|
@@ -755,7 +803,7 @@
|
|
755 |
var $parent = selector.parents( '.customize-control-custom_background:first' );
|
756 |
|
757 |
if ( selector.hasClass( 'customize-control-custom_background' ) ) {
|
758 |
-
|
759 |
}
|
760 |
|
761 |
if ( $parent.length > 0 ) {
|
@@ -847,13 +895,13 @@
|
|
847 |
vars[hash[0]] = hash[1];
|
848 |
}
|
849 |
|
850 |
-
if (
|
851 |
return vars[name];
|
852 |
}
|
853 |
return false;
|
854 |
};
|
855 |
|
856 |
-
var
|
857 |
try {
|
858 |
JSON.parse( str );
|
859 |
} catch ( e ) {
|
@@ -881,7 +929,7 @@
|
|
881 |
this.process_remote_step = function( key, data, step ) {
|
882 |
var self = this;
|
883 |
|
884 |
-
if (
|
885 |
return false;
|
886 |
}
|
887 |
|
@@ -916,7 +964,7 @@ debugger;
|
|
916 |
|
917 |
this.queue = function( key, data, step_key ) {
|
918 |
var self = this;
|
919 |
-
if (
|
920 |
this.log_action( 'start', step_key );
|
921 |
}
|
922 |
|
@@ -936,11 +984,11 @@ debugger;
|
|
936 |
option_key: key
|
937 |
};
|
938 |
|
939 |
-
if (
|
940 |
data_args.recall_data = step.recall_data;
|
941 |
}
|
942 |
|
943 |
-
if (
|
944 |
data_args.recall_type = step.recall_type;
|
945 |
}
|
946 |
|
@@ -954,14 +1002,14 @@ debugger;
|
|
954 |
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
955 |
data: data_args
|
956 |
} ).done( function( response ) {
|
957 |
-
if (
|
958 |
var results = response.data;
|
959 |
if ( step.type === 'remote' ) {
|
960 |
self.process_remote_step( key, results, step );
|
961 |
}
|
962 |
}
|
963 |
|
964 |
-
if (
|
965 |
self.log_action( 'end', step_key, response.message );
|
966 |
}
|
967 |
} );
|
85 |
var id = key.replace( '_control', '' );
|
86 |
var setting = customify_settings.settings[id];
|
87 |
|
88 |
+
if ( ! _.isUndefined( setting ) && ! _.isUndefined( setting.default ) ) {
|
89 |
|
90 |
var start_pos = id.indexOf( '[' ) + 1;
|
91 |
var end_pos = id.indexOf( ']', start_pos );
|
130 |
var id = ctrl.id.replace( '_control', '' ),
|
131 |
setting = customify_settings.settings[id];
|
132 |
|
133 |
+
if ( ! _.isUndefined( setting ) && ! _.isUndefined( setting.default ) ) {
|
134 |
|
135 |
var start_pos = id.indexOf( '[' ) + 1,
|
136 |
end_pos = id.indexOf( ']', start_pos );
|
149 |
var section = $( this ).parent(),
|
150 |
section_id = section.attr( 'id' );
|
151 |
|
152 |
+
if ( ( ( ! _.isUndefined( section_id ) ) ? section_id.indexOf( customify_settings.options_name ) : -1 ) === -1 ) {
|
153 |
return;
|
154 |
}
|
155 |
|
156 |
+
if ( ! _.isUndefined( section_id ) && section_id.indexOf( 'accordion-section-' ) > -1 ) {
|
157 |
var id = section_id.replace( 'accordion-section-', '' );
|
158 |
$( this ).prepend( '<button class="reset_section button" data-section="' + id + '">Section\'s defaults</button>' );
|
159 |
}
|
178 |
var id = ctrl.id.replace( '_control', '' ),
|
179 |
setting = customify_settings.settings[id];
|
180 |
|
181 |
+
if ( ! _.isUndefined( setting ) && ! _.isUndefined( setting.default ) ) {
|
182 |
|
183 |
var start_pos = id.indexOf( '[' ) + 1,
|
184 |
end_pos = id.indexOf( ']', start_pos );
|
201 |
var $input = $( this ).parents( '.options' ).siblings( '.customify_typography' ).children( '.customify_typography_values' ),
|
202 |
current_val = $input.val();
|
203 |
|
204 |
+
current_val = JSON.parse( decodeURIComponent( current_val ) );
|
|
|
205 |
|
206 |
+
//maybe the selected option holds a JSON in its value
|
207 |
+
current_val.selected_subsets = maybeJsonParse( $( this ).val() );
|
208 |
+
|
209 |
+
$input.val( encodeURIComponent( JSON.stringify( current_val ) ) );
|
210 |
|
211 |
$input.trigger( 'change' );
|
212 |
} );
|
216 |
var $input = $( this ).parents( '.options' ).siblings( '.customify_typography' ).children( '.customify_typography_values' ),
|
217 |
current_val = $input.val();
|
218 |
|
219 |
+
current_val = maybeJsonParse( current_val );
|
220 |
// @todo currently the font weight selector works for one value only
|
221 |
// maybe make this a multiselect
|
|
|
222 |
|
223 |
+
//maybe the selected option holds a JSON in its value
|
224 |
+
current_val.selected_variants = {0: maybeJsonParse( $( this ).val() ) };
|
225 |
+
|
226 |
+
$input.val( encodeURIComponent( JSON.stringify( current_val ) ) );
|
227 |
$input.trigger( 'change' );
|
228 |
} );
|
229 |
|
233 |
this_option = $( this ).children( '[value="' + $( this ).val() + '"]' ),
|
234 |
data = $( this_option ).data( 'options' );
|
235 |
|
236 |
+
if ( ! _.isUndefined( data ) ) {
|
237 |
$.each( data, function( id, value ) {
|
238 |
api_set_setting_value( id, value );
|
239 |
} );
|
247 |
var this_option = this;//$(this).children('[value="' + $(this).val() + '"]');
|
248 |
var data = $( this_option ).data( 'options' );
|
249 |
|
250 |
+
if ( ! _.isUndefined( data ) ) {
|
251 |
$.each( data, function( id, value ) {
|
252 |
api_set_setting_value( id, value );
|
253 |
} );
|
275 |
/// calculate the number of steps
|
276 |
var steps = [];
|
277 |
|
278 |
+
if ( ! _.isUndefined( customify_settings.settings[key].imports ) ) {
|
279 |
|
280 |
$.each( customify_settings.settings[key].imports, function( i, import_setts, k ) {
|
281 |
+
if ( _.isUndefined( import_setts.steps ) ) {
|
282 |
steps.push( {id: i, type: import_setts.type} );
|
283 |
} else {
|
284 |
var count = import_setts.steps;
|
313 |
*/
|
314 |
var customifyFoldingFields = function() {
|
315 |
|
316 |
+
if ( _.isUndefined( customify_settings ) || _.isUndefined( customify_settings.settings ) ) {
|
317 |
return ; // bail
|
318 |
}
|
319 |
|
342 |
|
343 |
var process_a_target = function( parent_id, field ) {
|
344 |
|
345 |
+
if ( _.isUndefined( field[0] ) ) {
|
346 |
return ; // no id, no fun
|
347 |
}
|
348 |
|
355 |
var target_type = customify_settings.settings[ target_key ].type;
|
356 |
|
357 |
|
358 |
+
if ( ! _.isUndefined( field[1] ) ) {
|
359 |
value = field[1];
|
360 |
}
|
361 |
|
362 |
+
if ( ! _.isUndefined( field[2] ) ) {
|
363 |
compare = field[2];
|
364 |
}
|
365 |
|
366 |
+
if ( ! _.isUndefined( field[3] ) ) {
|
367 |
action = field[3];
|
368 |
}
|
369 |
|
410 |
* The 'show_on' can be a simple array with one target like: [ id, value, comparison, action ]
|
411 |
* Or it could be an array of multiple targets and we need to process both cases
|
412 |
*/
|
413 |
+
if ( _.isString( field.show_on[0] ) ) {
|
414 |
process_a_target( parent_id, field.show_on );
|
415 |
+
} else if ( _.isObject( field.show_on[0] ) ) {
|
416 |
$.each( field.show_on, function (i, j) {
|
417 |
process_a_target( parent_id, j );
|
418 |
});
|
431 |
return {font_family: font_family_value};
|
432 |
}
|
433 |
|
434 |
+
if ( ! _.isUndefined( font_family_value.font_family ) ) {
|
435 |
return font_family_value.font_family;
|
436 |
}
|
437 |
|
463 |
field = $( '[data-customize-setting-link="' + setting_id + '"]' ),
|
464 |
field_class = $( field ).parent().attr( 'class' );
|
465 |
|
466 |
+
if ( ! _.isUndefined( field_class ) && field_class === 'customify_typography' ) {
|
467 |
|
468 |
var family_select = field.siblings( 'select' );
|
469 |
|
470 |
+
if ( _.isString( value ) ) {
|
471 |
var this_option = family_select.find( 'option[value="' + value + '"]' );
|
472 |
$( this_option[0] ).attr( 'selected', 'selected' );
|
473 |
update_siblings_selects( family_select );
|
474 |
+
} else if ( _.isObject( value ) ) {
|
475 |
var this_family_option = family_select.find( 'option[value="' + value['font_family'] + '"]' );
|
476 |
$( this_family_option[0] ).attr( 'selected', 'selected' );
|
477 |
|
506 |
|
507 |
if ( current_val === '[object Object]' ) {
|
508 |
current_val = $input.data( 'default' );
|
509 |
+
} else if ( _.isString( current_val ) && !isJsonString( current_val ) && current_val.substr(0,1) == '[' ) {
|
510 |
// a rare case when the value isn't a json but is a representative string like [family,weight]
|
511 |
current_val = current_val.split( ',' );
|
512 |
var new_current_value = {};
|
513 |
+
if ( ! _.isUndefined( current_val[0] ) ) {
|
514 |
new_current_value['font_family'] = current_val[0];
|
515 |
}
|
516 |
|
517 |
+
if ( ! _.isUndefined( current_val[1] ) ) {
|
518 |
new_current_value['selected_variants'] = current_val[1];
|
519 |
}
|
520 |
|
525 |
$font_subsets = $( font_select ).parent().siblings( 'ul.options' ).find( '.customify_typography_font_subsets' );
|
526 |
|
527 |
try {
|
528 |
+
current_val = JSON.parse( decodeURIComponent( current_val ) );
|
529 |
} catch ( e ) {
|
530 |
|
531 |
// in case of an error, force the rebuild of the json
|
532 |
+
if ( _.isUndefined( $( font_select ).data( 'bound_once' ) ) ) {
|
533 |
|
534 |
$( font_select ).data( 'bound_once', true );
|
535 |
//var api = wp.customize;
|
540 |
$font_subsets.change();
|
541 |
}
|
542 |
}
|
543 |
+
|
544 |
// first try to get the font from sure sources, not from the recommended list.
|
545 |
var option_data = $( font_select ).find( ':not(optgroup[label=Recommended]) option[value="' + selected_font + '"]' );
|
546 |
+
// however, if there isn't an option found, get what you can
|
547 |
if ( option_data.length < 1 ) {
|
548 |
option_data = $( font_select ).find( 'option[value="' + selected_font + '"]' );
|
549 |
}
|
557 |
|
558 |
if ( font_type == 'std' ) {
|
559 |
variants = { 0: '100', 1: '200', 3: '300', 4: '400', 5: '500', 6: '600', 7: '700', 8: '800', 9: '900' };
|
560 |
+
if ( ! _.isUndefined( $( option_data[0] ).data( 'variants' ) ) ) {
|
561 |
+
//maybe the variants are a JSON
|
562 |
+
variants = maybeJsonParse( $( option_data[0] ).data( 'variants' ) );
|
563 |
}
|
|
|
564 |
} else {
|
565 |
+
//maybe the variants are a JSON
|
566 |
+
variants = maybeJsonParse( $( option_data[0] ).data( 'variants' ) );
|
567 |
+
|
568 |
+
//maybe the subsets are a JSON
|
569 |
+
subsets = maybeJsonParse( $( option_data[0] ).data( 'subsets' ) );
|
570 |
}
|
571 |
|
572 |
// make the variants selector
|
573 |
+
if ( ! _.isUndefined( variants ) && ! _.isNull( variants ) && ! _.isEmpty( variants ) ) {
|
574 |
|
575 |
value_to_add['variants'] = variants;
|
576 |
// when a font is selected force the first weight to load
|
579 |
var variants_options = '',
|
580 |
count_weights = 0;
|
581 |
|
582 |
+
if ( _.isArray( variants ) || _.isObject( variants ) ) {
|
583 |
+
// Take each variant and produce the option markup
|
584 |
+
$.each(variants, function (key, el) {
|
585 |
+
var is_selected = '';
|
586 |
+
if (_.isObject(current_val.selected_variants) && inObject(el, current_val.selected_variants)) {
|
587 |
+
is_selected = ' selected="selected"';
|
588 |
+
} else if (_.isString(current_val.selected_variants) && el === current_val.selected_variants) {
|
589 |
+
is_selected = ' selected="selected"';
|
590 |
+
}
|
591 |
|
592 |
+
// initialize
|
593 |
+
var variant_option_value = el,
|
594 |
+
variant_option_display = el;
|
595 |
+
|
596 |
+
// If we are dealing with a object variant then it means things get tricky (probably it's our fault but bear with us)
|
597 |
+
// This probably comes from our Fonto plugin - a font with individually named variants - hence each has its own font-family
|
598 |
+
if (_.isObject(el)) {
|
599 |
+
//put the entire object in the variation value - we will need it when outputting the custom CSS
|
600 |
+
variant_option_value = encodeURIComponent(JSON.stringify(el));
|
601 |
+
variant_option_display = '';
|
602 |
+
|
603 |
+
//if we have weight and style then "compose" them into something standard
|
604 |
+
if (!_.isUndefined(el['font-weight'])) {
|
605 |
+
variant_option_display += el['font-weight'];
|
606 |
+
}
|
607 |
+
|
608 |
+
if (_.isString(el['font-style']) && $.inArray(el['font-style'].toLowerCase(), ["normal", "regular"]) < 0) { //this comparison means it hasn't been found
|
609 |
+
variant_option_display += el['font-style'];
|
610 |
+
}
|
611 |
+
}
|
612 |
+
|
613 |
+
variants_options += '<option value="' + variant_option_value + '"' + is_selected + '>' + variant_option_display + '</option>';
|
614 |
+
count_weights++;
|
615 |
+
});
|
616 |
+
}
|
617 |
+
|
618 |
+
if ( ! _.isUndefined( $font_weight ) ) {
|
619 |
$font_weight.html( variants_options );
|
620 |
// if there is no weight or just 1 we hide the weight select ... cuz is useless
|
621 |
if ( $( font_select ).data( 'load_all_weights' ) === true || count_weights <= 1 ) {
|
624 |
$font_weight.parent().css( 'display', 'inline-block' );
|
625 |
}
|
626 |
}
|
627 |
+
} else if ( ! _.isUndefined( $font_weight ) ) {
|
628 |
$font_weight.parent().css( 'display', 'none' );
|
629 |
}
|
630 |
|
631 |
// make the subsets selector
|
632 |
+
if ( ! _.isUndefined( subsets ) && ! _.isNull( subsets ) && ! _.isEmpty( subsets ) ) {
|
633 |
|
634 |
value_to_add['subsets'] = subsets;
|
635 |
// when a font is selected force the first subset to load
|
638 |
count_subsets = 0;
|
639 |
$.each( subsets, function( key, el ) {
|
640 |
var is_selected = '';
|
641 |
+
if ( _.isObject( current_val.selected_subsets ) && inObject( el, current_val.selected_subsets ) ) {
|
642 |
is_selected = ' selected="selected"';
|
643 |
}
|
644 |
|
646 |
count_subsets++;
|
647 |
} );
|
648 |
|
649 |
+
if ( ! _.isUndefined( $font_subsets ) ) {
|
650 |
$font_subsets.html( subsets_options );
|
651 |
|
652 |
// if there is no subset or just 1 we hide the subsets select ... cuz is useless
|
656 |
$font_subsets.parent().css( 'display', 'inline-block' );
|
657 |
}
|
658 |
}
|
659 |
+
} else if ( ! _.isUndefined( $font_subsets ) ) {
|
660 |
$font_subsets.parent().css( 'display', 'none' );
|
661 |
}
|
662 |
|
663 |
+
$input.val( encodeURIComponent( JSON.stringify( value_to_add ) ) );
|
664 |
}
|
665 |
};
|
666 |
|
673 |
var inObject = function( value, obj ) {
|
674 |
for ( var k in obj ) {
|
675 |
if ( !obj.hasOwnProperty( k ) ) continue;
|
676 |
+
if ( _.isEqual( obj[k], value ) ) {
|
677 |
return true;
|
678 |
}
|
679 |
}
|
680 |
return false;
|
681 |
};
|
682 |
|
683 |
+
var maybeJsonParse = function( value ) {
|
684 |
+
var parsed;
|
685 |
+
|
686 |
+
//try and parse it, with decodeURIComponent
|
687 |
+
try {
|
688 |
+
parsed = JSON.parse( decodeURIComponent( value ) );
|
689 |
+
} catch ( e ) {
|
690 |
+
|
691 |
+
// in case of an error, treat is as a string
|
692 |
+
parsed = value;
|
693 |
+
}
|
694 |
+
|
695 |
+
return parsed;
|
696 |
+
};
|
697 |
+
|
698 |
var customifyBackgroundJsControl = (function() {
|
699 |
"use strict";
|
700 |
|
766 |
selector.find( '.upload-width' ).attr( 'value', attachment.attributes.width );
|
767 |
|
768 |
var thumbSrc = attachment.attributes.url;
|
769 |
+
if ( ! _.isUndefined( attachment.attributes.sizes ) && ! _.isUndefined( attachment.attributes.sizes.thumbnail ) ) {
|
770 |
thumbSrc = attachment.attributes.sizes.thumbnail.url;
|
771 |
+
} else if ( ! _.isUndefined( attachment.attributes.sizes ) ) {
|
772 |
var height = attachment.attributes.height;
|
773 |
for ( var key in attachment.attributes.sizes ) {
|
774 |
var object = attachment.attributes.sizes[key];
|
803 |
var $parent = selector.parents( '.customize-control-custom_background:first' );
|
804 |
|
805 |
if ( selector.hasClass( 'customize-control-custom_background' ) ) {
|
806 |
+
$parent = selector;
|
807 |
}
|
808 |
|
809 |
if ( $parent.length > 0 ) {
|
895 |
vars[hash[0]] = hash[1];
|
896 |
}
|
897 |
|
898 |
+
if ( ! _.isUndefined( vars[name] ) ) {
|
899 |
return vars[name];
|
900 |
}
|
901 |
return false;
|
902 |
};
|
903 |
|
904 |
+
var isJsonString = function( str ) {
|
905 |
try {
|
906 |
JSON.parse( str );
|
907 |
} catch ( e ) {
|
929 |
this.process_remote_step = function( key, data, step ) {
|
930 |
var self = this;
|
931 |
|
932 |
+
if ( _.isUndefined( data ) || _.isNull( data ) ) {
|
933 |
return false;
|
934 |
}
|
935 |
|
964 |
|
965 |
this.queue = function( key, data, step_key ) {
|
966 |
var self = this;
|
967 |
+
if ( ! _.isUndefined( step_key ) ) {
|
968 |
this.log_action( 'start', step_key );
|
969 |
}
|
970 |
|
984 |
option_key: key
|
985 |
};
|
986 |
|
987 |
+
if ( ! _.isUndefined( step.recall_data ) ) {
|
988 |
data_args.recall_data = step.recall_data;
|
989 |
}
|
990 |
|
991 |
+
if ( ! _.isUndefined( step.recall_type ) ) {
|
992 |
data_args.recall_type = step.recall_type;
|
993 |
}
|
994 |
|
1002 |
contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
|
1003 |
data: data_args
|
1004 |
} ).done( function( response ) {
|
1005 |
+
if ( ! _.isUndefined( response.success ) && response.success ) {
|
1006 |
var results = response.data;
|
1007 |
if ( step.type === 'remote' ) {
|
1008 |
self.process_remote_step( key, results, step );
|
1009 |
}
|
1010 |
}
|
1011 |
|
1012 |
+
if ( ! _.isUndefined( step_key ) && ! _.isUndefined( response.message ) ) {
|
1013 |
self.log_action( 'end', step_key, response.message );
|
1014 |
}
|
1015 |
} );
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== Customify - A Theme Customizer Booster ===
|
2 |
-
Contributors: pixelgrade, euthelup, babbardel
|
3 |
Tags: customizer, css, editor, live, preview, customise
|
4 |
Requires at least: 4.3.0
|
5 |
-
Tested up to: 4.
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -33,6 +33,14 @@ With [Customify](https://github.com/pixelgrade/customify), developers can easily
|
|
33 |
|
34 |
== Changelog ==
|
35 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
= 1.2.3 =
|
37 |
* Added: Support for conditional fields display
|
38 |
* Fixed weights for local fonts
|
1 |
=== Customify - A Theme Customizer Booster ===
|
2 |
+
Contributors: pixelgrade, euthelup, babbardel, vlad.olaru
|
3 |
Tags: customizer, css, editor, live, preview, customise
|
4 |
Requires at least: 4.3.0
|
5 |
+
Tested up to: 4.7.0
|
6 |
+
Stable tag: 1.2.5
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
33 |
|
34 |
== Changelog ==
|
35 |
|
36 |
+
= 1.2.5 =
|
37 |
+
* Fixed WordPress 4.7 incompatibilities
|
38 |
+
|
39 |
+
= 1.2.4 =
|
40 |
+
* Added: Support for Fonto plugin
|
41 |
+
* Improved the font selector
|
42 |
+
* Fixed presets on ssl
|
43 |
+
|
44 |
= 1.2.3 =
|
45 |
* Added: Support for conditional fields display
|
46 |
* Fixed weights for local fonts
|