Version Description
-
Customizer options: Added
wp-customizer-args
parameter. #1097, #1082$options
Download this release
Release Info
Developer | Unyson |
Plugin | Unyson |
Version | 2.4.14 |
Comparing to | |
See all releases |
Code changes from version 2.4.13 to 2.4.14
- framework/core/components/backend.php +8 -0
- framework/core/components/extensions/manager/class--fw-extensions-manager.php +12 -11
- framework/core/extends/class-fw-option-type.php +1 -1
- framework/helpers/class-fw-flash-messages.php +12 -1
- framework/helpers/class-fw-wp-filesystem.php +35 -19
- framework/includes/option-types/multi-picker/static/js/multi-picker.js +1 -3
- framework/includes/option-types/switch/class-fw-option-type-switch.php +25 -83
- framework/includes/option-types/switch/static/js/scripts.js +21 -32
- framework/manifest.php +1 -1
- readme.txt +20 -1
- unyson.php +1 -1
framework/core/components/backend.php
CHANGED
@@ -1949,6 +1949,10 @@ final class _FW_Component_Backend {
|
|
1949 |
: $opt['option']['desc'],
|
1950 |
);
|
1951 |
|
|
|
|
|
|
|
|
|
1952 |
if ($has_containers) {
|
1953 |
if ($parent_data) {
|
1954 |
trigger_error($opt['id'] .' panel can\'t have a parent ('. $parent_data['id'] .')', E_USER_WARNING);
|
@@ -1995,6 +1999,10 @@ final class _FW_Component_Backend {
|
|
1995 |
'settings' => $setting_id,
|
1996 |
);
|
1997 |
|
|
|
|
|
|
|
|
|
1998 |
if ($parent_data) {
|
1999 |
if ($parent_data['customizer_type'] === 'section') {
|
2000 |
$args['section'] = $parent_data['id'];
|
1949 |
: $opt['option']['desc'],
|
1950 |
);
|
1951 |
|
1952 |
+
if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
|
1953 |
+
$args = array_merge($opt['option']['wp-customizer-args'], $args);
|
1954 |
+
}
|
1955 |
+
|
1956 |
if ($has_containers) {
|
1957 |
if ($parent_data) {
|
1958 |
trigger_error($opt['id'] .' panel can\'t have a parent ('. $parent_data['id'] .')', E_USER_WARNING);
|
1999 |
'settings' => $setting_id,
|
2000 |
);
|
2001 |
|
2002 |
+
if (isset($opt['option']['wp-customizer-args']) && is_array($opt['option']['wp-customizer-args'])) {
|
2003 |
+
$args = array_merge($opt['option']['wp-customizer-args'], $args);
|
2004 |
+
}
|
2005 |
+
|
2006 |
if ($parent_data) {
|
2007 |
if ($parent_data['customizer_type'] === 'section') {
|
2008 |
$args['section'] = $parent_data['id'];
|
framework/core/components/extensions/manager/class--fw-extensions-manager.php
CHANGED
@@ -331,7 +331,7 @@ final class _FW_Extensions_Manager
|
|
331 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
332 |
global $wp_filesystem;
|
333 |
|
334 |
-
if (!$wp_filesystem) {
|
335 |
return;
|
336 |
}
|
337 |
|
@@ -380,7 +380,7 @@ final class _FW_Extensions_Manager
|
|
380 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
381 |
global $wp_filesystem;
|
382 |
|
383 |
-
if (
|
384 |
return;
|
385 |
}
|
386 |
|
@@ -1047,7 +1047,7 @@ final class _FW_Extensions_Manager
|
|
1047 |
|
1048 |
global $wp_filesystem;
|
1049 |
|
1050 |
-
if (!$wp_filesystem) {
|
1051 |
return new WP_Error(
|
1052 |
'fs_not_initialized',
|
1053 |
__('WP Filesystem is not initialized', 'fw')
|
@@ -1521,7 +1521,7 @@ final class _FW_Extensions_Manager
|
|
1521 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
1522 |
global $wp_filesystem;
|
1523 |
|
1524 |
-
if (!$wp_filesystem) {
|
1525 |
return new WP_Error(
|
1526 |
'fs_not_initialized',
|
1527 |
__('WP Filesystem is not initialized', 'fw')
|
@@ -3184,17 +3184,18 @@ final class _FW_Extensions_Manager
|
|
3184 |
if (
|
3185 |
!isset($_GET['supported']) // already on 'Install Supported Extensions' page
|
3186 |
&&
|
3187 |
-
fw()->manifest->get_version() === '2.4.13'
|
3188 |
-
&&
|
3189 |
$this->can_install()
|
3190 |
&&
|
|
|
|
|
|
|
|
|
3191 |
$this->get_supported_extensions_for_install()
|
3192 |
) {
|
3193 |
-
echo '<div class="
|
3194 |
-
|
3195 |
-
'
|
3196 |
-
|
3197 |
-
echo '</p></div>';
|
3198 |
}
|
3199 |
}
|
3200 |
}
|
331 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
332 |
global $wp_filesystem;
|
333 |
|
334 |
+
if (!$wp_filesystem || (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())) {
|
335 |
return;
|
336 |
}
|
337 |
|
380 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
381 |
global $wp_filesystem;
|
382 |
|
383 |
+
if ( !$wp_filesystem || (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) ) {
|
384 |
return;
|
385 |
}
|
386 |
|
1047 |
|
1048 |
global $wp_filesystem;
|
1049 |
|
1050 |
+
if (!$wp_filesystem || (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())) {
|
1051 |
return new WP_Error(
|
1052 |
'fs_not_initialized',
|
1053 |
__('WP Filesystem is not initialized', 'fw')
|
1521 |
/** @var WP_Filesystem_Base $wp_filesystem */
|
1522 |
global $wp_filesystem;
|
1523 |
|
1524 |
+
if (!$wp_filesystem || (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())) {
|
1525 |
return new WP_Error(
|
1526 |
'fs_not_initialized',
|
1527 |
__('WP Filesystem is not initialized', 'fw')
|
3184 |
if (
|
3185 |
!isset($_GET['supported']) // already on 'Install Supported Extensions' page
|
3186 |
&&
|
|
|
|
|
3187 |
$this->can_install()
|
3188 |
&&
|
3189 |
+
(($installed_extensions = $this->get_installed_extensions()) || true)
|
3190 |
+
&&
|
3191 |
+
!isset($installed_extensions['page-builder'])
|
3192 |
+
&&
|
3193 |
$this->get_supported_extensions_for_install()
|
3194 |
) {
|
3195 |
+
echo '<div class="error"> <p>'
|
3196 |
+
, fw_html_tag('a', array('href' => $this->get_link() .'&sub-page=install&supported'),
|
3197 |
+
__('Install theme compatible extensions', 'fw'))
|
3198 |
+
, '</p></div>';
|
|
|
3199 |
}
|
3200 |
}
|
3201 |
}
|
framework/core/extends/class-fw-option-type.php
CHANGED
@@ -277,7 +277,7 @@ abstract class FW_Option_Type
|
|
277 |
|
278 |
$option['type'] = $this->get_type();
|
279 |
|
280 |
-
if (!
|
281 |
FW_Flash_Messages::add(
|
282 |
'fw-option-type-no-default-value',
|
283 |
sprintf(__('Option type %s has no default value', 'fw'), $this->get_type()),
|
277 |
|
278 |
$option['type'] = $this->get_type();
|
279 |
|
280 |
+
if (!array_key_exists('value', $option)) {
|
281 |
FW_Flash_Messages::add(
|
282 |
'fw-option-type-no-default-value',
|
283 |
sprintf(__('Option type %s has no default value', 'fw'), $this->get_type()),
|
framework/helpers/class-fw-flash-messages.php
CHANGED
@@ -226,7 +226,18 @@ if (is_admin()) {
|
|
226 |
* @internal
|
227 |
*/
|
228 |
function _action_fw_flash_message_frontend_prepare() {
|
229 |
-
if (
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
session_start();
|
231 |
}
|
232 |
}
|
226 |
* @internal
|
227 |
*/
|
228 |
function _action_fw_flash_message_frontend_prepare() {
|
229 |
+
if (
|
230 |
+
/**
|
231 |
+
* In ajax it's not possible to call flash message after headers were sent,
|
232 |
+
* so there will be no "headers already sent" warning.
|
233 |
+
* Also in the Backups extension, are made many internal ajax request,
|
234 |
+
* each creating a new independent request that don't remember/use session cookie from previous request,
|
235 |
+
* thus on server side are created many (not used) new sessions.
|
236 |
+
*/
|
237 |
+
!(defined('DOING_AJAX') && DOING_AJAX)
|
238 |
+
&&
|
239 |
+
!session_id()
|
240 |
+
) {
|
241 |
session_start();
|
242 |
}
|
243 |
}
|
framework/helpers/class-fw-wp-filesystem.php
CHANGED
@@ -18,49 +18,53 @@ class FW_WP_Filesystem
|
|
18 |
global $wp_filesystem;
|
19 |
|
20 |
if ($wp_filesystem) {
|
21 |
-
|
22 |
-
|
|
|
|
|
|
|
|
|
|
|
23 |
}
|
24 |
|
25 |
-
if (empty($url)) {
|
26 |
$url = fw_current_url();
|
27 |
}
|
28 |
|
29 |
-
if (get_filesystem_method() === 'direct') {
|
30 |
// in case if direct access is available
|
31 |
|
32 |
/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
|
33 |
-
$creds = request_filesystem_credentials(site_url() . '/wp-admin/', '', false, false, null);
|
34 |
|
35 |
/* initialize the API */
|
36 |
-
if ( ! WP_Filesystem($creds) ) {
|
37 |
/* any problems and we exit */
|
38 |
-
trigger_error(__('Cannot connect to Filesystem directly', 'fw'), E_USER_WARNING);
|
|
|
39 |
return false;
|
40 |
}
|
41 |
} else {
|
42 |
-
$creds = request_filesystem_credentials($url, '', false, $context, $extra_fields);
|
43 |
|
44 |
-
if (
|
45 |
// the form was printed to the user
|
46 |
return null;
|
47 |
}
|
48 |
|
49 |
/* initialize the API */
|
50 |
-
if ( ! WP_Filesystem($creds) ) {
|
51 |
/* any problems and we exit */
|
52 |
-
request_filesystem_credentials($url, '', true, $context, $extra_fields); // the third parameter is true to show error to the user
|
53 |
return false;
|
54 |
}
|
55 |
}
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
if ( is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code() ) {
|
64 |
return false;
|
65 |
}
|
66 |
|
@@ -91,6 +95,8 @@ class FW_WP_Filesystem
|
|
91 |
|
92 |
if (!$wp_filesystem) {
|
93 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
|
|
|
|
94 |
}
|
95 |
|
96 |
try {
|
@@ -132,6 +138,8 @@ class FW_WP_Filesystem
|
|
132 |
|
133 |
if (!$wp_filesystem) {
|
134 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
|
|
|
|
135 |
}
|
136 |
|
137 |
$real_path = fw_fix_path($real_path);
|
@@ -167,6 +175,8 @@ class FW_WP_Filesystem
|
|
167 |
|
168 |
if (!$wp_filesystem) {
|
169 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
|
|
|
|
170 |
}
|
171 |
|
172 |
$wp_filesystem_path = fw_fix_path($wp_filesystem_path);
|
@@ -202,7 +212,11 @@ class FW_WP_Filesystem
|
|
202 |
global $wp_filesystem;
|
203 |
|
204 |
if ($wp_filesystem) {
|
205 |
-
|
|
|
|
|
|
|
|
|
206 |
}
|
207 |
|
208 |
if (get_filesystem_method(array(), $context) === 'direct') {
|
@@ -231,6 +245,8 @@ class FW_WP_Filesystem
|
|
231 |
|
232 |
if (!$wp_filesystem) {
|
233 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
|
|
|
|
234 |
}
|
235 |
|
236 |
$wp_filesystem_dir_path = fw_fix_path($wp_filesystem_dir_path);
|
18 |
global $wp_filesystem;
|
19 |
|
20 |
if ($wp_filesystem) {
|
21 |
+
if (
|
22 |
+
is_object($wp_filesystem)
|
23 |
+
&&
|
24 |
+
!(is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())
|
25 |
+
) {
|
26 |
+
return true; // already initialized
|
27 |
+
}
|
28 |
}
|
29 |
|
30 |
+
if ( empty( $url ) ) {
|
31 |
$url = fw_current_url();
|
32 |
}
|
33 |
|
34 |
+
if ( get_filesystem_method() === 'direct' ) {
|
35 |
// in case if direct access is available
|
36 |
|
37 |
/* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
|
38 |
+
$creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, null );
|
39 |
|
40 |
/* initialize the API */
|
41 |
+
if ( ! WP_Filesystem( $creds ) ) {
|
42 |
/* any problems and we exit */
|
43 |
+
trigger_error( __( 'Cannot connect to Filesystem directly', 'fw' ), E_USER_WARNING );
|
44 |
+
|
45 |
return false;
|
46 |
}
|
47 |
} else {
|
48 |
+
$creds = request_filesystem_credentials( $url, '', false, $context, $extra_fields );
|
49 |
|
50 |
+
if ( ! $creds ) {
|
51 |
// the form was printed to the user
|
52 |
return null;
|
53 |
}
|
54 |
|
55 |
/* initialize the API */
|
56 |
+
if ( ! WP_Filesystem( $creds ) ) {
|
57 |
/* any problems and we exit */
|
58 |
+
request_filesystem_credentials( $url, '', true, $context, $extra_fields ); // the third parameter is true to show error to the user
|
59 |
return false;
|
60 |
}
|
61 |
}
|
62 |
|
63 |
+
if (
|
64 |
+
! is_object($wp_filesystem)
|
65 |
+
||
|
66 |
+
(is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code())
|
67 |
+
) {
|
|
|
|
|
68 |
return false;
|
69 |
}
|
70 |
|
95 |
|
96 |
if (!$wp_filesystem) {
|
97 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
98 |
+
} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
99 |
+
trigger_error('Filesystem: '. $wp_filesystem->errors->get_error_message(), E_USER_ERROR);
|
100 |
}
|
101 |
|
102 |
try {
|
138 |
|
139 |
if (!$wp_filesystem) {
|
140 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
141 |
+
} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
142 |
+
trigger_error('Filesystem: '. $wp_filesystem->errors->get_error_message(), E_USER_ERROR);
|
143 |
}
|
144 |
|
145 |
$real_path = fw_fix_path($real_path);
|
175 |
|
176 |
if (!$wp_filesystem) {
|
177 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
178 |
+
} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
179 |
+
trigger_error('Filesystem: '. $wp_filesystem->errors->get_error_message(), E_USER_ERROR);
|
180 |
}
|
181 |
|
182 |
$wp_filesystem_path = fw_fix_path($wp_filesystem_path);
|
212 |
global $wp_filesystem;
|
213 |
|
214 |
if ($wp_filesystem) {
|
215 |
+
if (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
216 |
+
return false;
|
217 |
+
} else {
|
218 |
+
return $wp_filesystem->method === 'direct';
|
219 |
+
}
|
220 |
}
|
221 |
|
222 |
if (get_filesystem_method(array(), $context) === 'direct') {
|
245 |
|
246 |
if (!$wp_filesystem) {
|
247 |
trigger_error('Filesystem is not available', E_USER_ERROR);
|
248 |
+
} elseif (is_wp_error($wp_filesystem->errors) && $wp_filesystem->errors->get_error_code()) {
|
249 |
+
trigger_error('Filesystem: '. $wp_filesystem->errors->get_error_message(), E_USER_ERROR);
|
250 |
}
|
251 |
|
252 |
$wp_filesystem_dir_path = fw_fix_path($wp_filesystem_dir_path);
|
framework/includes/option-types/multi-picker/static/js/multi-picker.js
CHANGED
@@ -39,9 +39,7 @@
|
|
39 |
elements.$pickerGroup.find(':checkbox').on('change', function() {
|
40 |
var $this = $(this),
|
41 |
checked = $(this).is(':checked'),
|
42 |
-
value = checked
|
43 |
-
? $this.attr('data-switch-right-value')
|
44 |
-
: $this.attr('data-switch-left-value');
|
45 |
|
46 |
chooseGroup(value);
|
47 |
}).trigger('change');
|
39 |
elements.$pickerGroup.find(':checkbox').on('change', function() {
|
40 |
var $this = $(this),
|
41 |
checked = $(this).is(':checked'),
|
42 |
+
value = JSON.parse($this.attr('data-switch-'+ (checked ? 'right' : 'left') +'-value-json'));
|
|
|
|
|
43 |
|
44 |
chooseGroup(value);
|
45 |
}).trigger('change');
|
framework/includes/option-types/switch/class-fw-option-type-switch.php
CHANGED
@@ -55,6 +55,10 @@ class FW_Option_Type_Switch extends FW_Option_Type
|
|
55 |
*/
|
56 |
protected function _render($id, $option, $data)
|
57 |
{
|
|
|
|
|
|
|
|
|
58 |
{
|
59 |
$input_attr = array(
|
60 |
'name' => $option['attr']['name'],
|
@@ -64,81 +68,15 @@ class FW_Option_Type_Switch extends FW_Option_Type
|
|
64 |
);
|
65 |
|
66 |
foreach (array('left', 'right') as $value_type) {
|
67 |
-
|
68 |
-
$input_attr['data-switch-'. $value_type .'-bool-value'] = $option[$value_type. '-choice']['value']
|
69 |
-
? 'true'
|
70 |
-
: 'false';
|
71 |
-
} else {
|
72 |
-
$input_attr['data-switch-'. $value_type .'-value'] = $option[$value_type .'-choice']['value'];
|
73 |
-
}
|
74 |
}
|
75 |
}
|
76 |
|
77 |
-
if (
|
78 |
-
|
79 |
-
&&
|
80 |
-
is_string($data['value'])
|
81 |
-
&&
|
82 |
-
in_array($data['value'], array('false', 'true'))
|
83 |
-
&&
|
84 |
-
// do not transform if there is an exact match with a choice
|
85 |
-
(
|
86 |
-
$option['left-choice']['value'] !== $data['value']
|
87 |
-
&&
|
88 |
-
$option['right-choice']['value'] !== $data['value']
|
89 |
-
)
|
90 |
-
) {
|
91 |
-
/**
|
92 |
-
* This happens on fw.OptionsModal open/render
|
93 |
-
* When the switch is used by other option types
|
94 |
-
* then this script http://bit.ly/1QshDoS can't fix nested values
|
95 |
-
*
|
96 |
-
* Check if values is 'true' or 'false' and one of the choices values is a boolean that matches it
|
97 |
-
* then transform/fix it to boolean
|
98 |
-
*/
|
99 |
-
if (
|
100 |
-
$data['value'] === 'true'
|
101 |
-
&&
|
102 |
-
(
|
103 |
-
(
|
104 |
-
is_bool($option['right-choice']['value'])
|
105 |
-
&&
|
106 |
-
$option['right-choice']['value'] === true
|
107 |
-
)
|
108 |
-
||
|
109 |
-
(
|
110 |
-
is_bool($option['left-choice']['value'])
|
111 |
-
&&
|
112 |
-
$option['left-choice']['value'] === true
|
113 |
-
)
|
114 |
-
)
|
115 |
-
) {
|
116 |
-
$data['value'] = true;
|
117 |
-
} elseif (
|
118 |
-
$data['value'] === 'false'
|
119 |
-
&&
|
120 |
-
(
|
121 |
-
(
|
122 |
-
is_bool($option['right-choice']['value'])
|
123 |
-
&&
|
124 |
-
$option['right-choice']['value'] === false
|
125 |
-
)
|
126 |
-
||
|
127 |
-
(
|
128 |
-
is_bool($option['left-choice']['value'])
|
129 |
-
&&
|
130 |
-
$option['left-choice']['value'] === false
|
131 |
-
)
|
132 |
-
)
|
133 |
-
) {
|
134 |
-
$data['value'] = false;
|
135 |
-
}
|
136 |
}
|
137 |
|
138 |
-
|
139 |
-
// right choice means checked
|
140 |
-
$input_attr['checked'] = 'checked';
|
141 |
-
}
|
142 |
|
143 |
unset(
|
144 |
$option['attr']['name'],
|
@@ -148,12 +86,12 @@ class FW_Option_Type_Switch extends FW_Option_Type
|
|
148 |
);
|
149 |
|
150 |
return '<div '. fw_attr_to_html($option['attr']) .'>'.
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
'<input type="checkbox" '. fw_attr_to_html($input_attr) .' />'.
|
158 |
'</div>';
|
159 |
}
|
@@ -164,15 +102,19 @@ class FW_Option_Type_Switch extends FW_Option_Type
|
|
164 |
protected function _get_value_from_input($option, $input_value)
|
165 |
{
|
166 |
if (is_null($input_value)) {
|
167 |
-
|
168 |
-
|
169 |
-
if ($input_value) {
|
170 |
-
// checked
|
171 |
-
return $option['right-choice']['value'];
|
172 |
} else {
|
173 |
-
// unchecked
|
174 |
return $option['left-choice']['value'];
|
175 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
}
|
177 |
}
|
178 |
|
@@ -190,7 +132,7 @@ class FW_Option_Type_Switch extends FW_Option_Type
|
|
190 |
protected function _get_defaults()
|
191 |
{
|
192 |
return array(
|
193 |
-
'value' =>
|
194 |
'left-choice' => array(
|
195 |
'value' => false,
|
196 |
'label' => __('No', 'fw'),
|
55 |
*/
|
56 |
protected function _render($id, $option, $data)
|
57 |
{
|
58 |
+
if (is_null($data['value'])) {
|
59 |
+
$data['value'] = $this->get_value_from_input($option, null);
|
60 |
+
}
|
61 |
+
|
62 |
{
|
63 |
$input_attr = array(
|
64 |
'name' => $option['attr']['name'],
|
68 |
);
|
69 |
|
70 |
foreach (array('left', 'right') as $value_type) {
|
71 |
+
$input_attr['data-switch-'. $value_type .'-value-json'] = json_encode($option[$value_type .'-choice']['value']);
|
|
|
|
|
|
|
|
|
|
|
|
|
72 |
}
|
73 |
}
|
74 |
|
75 |
+
if ($checked = ($data['value'] === $option['right-choice']['value'])) {
|
76 |
+
$input_attr['checked'] = 'checked'; // right choice means checked
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
}
|
78 |
|
79 |
+
$input_attr['value'] = json_encode($option[ ($checked ? 'right' : 'left') .'-choice' ]['value']);
|
|
|
|
|
|
|
80 |
|
81 |
unset(
|
82 |
$option['attr']['name'],
|
86 |
);
|
87 |
|
88 |
return '<div '. fw_attr_to_html($option['attr']) .'>'.
|
89 |
+
'<!-- note: value is json encoded, if want to use it in js, do: var val = JSON.parse($input.val()); -->'.
|
90 |
+
($checked ? '' : fw_html_tag('input', array(
|
91 |
+
'type' => 'hidden',
|
92 |
+
'name' => $input_attr['name'],
|
93 |
+
'value' => $input_attr['data-switch-left-value-json'],
|
94 |
+
))).
|
95 |
'<input type="checkbox" '. fw_attr_to_html($input_attr) .' />'.
|
96 |
'</div>';
|
97 |
}
|
102 |
protected function _get_value_from_input($option, $input_value)
|
103 |
{
|
104 |
if (is_null($input_value)) {
|
105 |
+
if (in_array($option['value'], array($option['left-choice']['value'], $option['right-choice']['value']), true)) {
|
106 |
+
return $option['value'];
|
|
|
|
|
|
|
107 |
} else {
|
|
|
108 |
return $option['left-choice']['value'];
|
109 |
}
|
110 |
+
} else {
|
111 |
+
$input_value = json_decode($input_value);
|
112 |
+
|
113 |
+
if (in_array($input_value, array($option['left-choice']['value'], $option['right-choice']['value']), true)) {
|
114 |
+
return $input_value;
|
115 |
+
} else {
|
116 |
+
return $option['value'];
|
117 |
+
}
|
118 |
}
|
119 |
}
|
120 |
|
132 |
protected function _get_defaults()
|
133 |
{
|
134 |
return array(
|
135 |
+
'value' => null,
|
136 |
'left-choice' => array(
|
137 |
'value' => false,
|
138 |
'label' => __('No', 'fw'),
|
framework/includes/option-types/switch/static/js/scripts.js
CHANGED
@@ -1,46 +1,35 @@
|
|
1 |
jQuery(document).ready(function ($) {
|
2 |
-
var optionTypeClass = 'fw-option-type-switch'
|
3 |
-
|
4 |
|
5 |
fwEvents.on('fw:options:init', function (data) {
|
6 |
-
|
7 |
-
|
8 |
-
$elements.find('input[type="checkbox"]')
|
9 |
.on('change', function(){
|
10 |
-
var $this = $(this)
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
if ($this.prop('checked')) {
|
15 |
-
value = $this.attr('data-switch-right-bool-value');
|
16 |
|
17 |
-
|
18 |
-
value = value == 'true';
|
19 |
-
} else {
|
20 |
-
value = $this.attr('data-switch-right-value')
|
21 |
-
}
|
22 |
|
23 |
-
|
24 |
-
$this.prev('input[type="hidden"]').
|
25 |
} else {
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
// make hidden value sent in POST
|
35 |
-
$this.prev('input[type="hidden"]').attr('name', $this.attr('name'));
|
36 |
}
|
37 |
|
38 |
$this.closest('.'+ optionTypeClass).trigger(customEventPrefix +'change', {
|
39 |
-
value: value
|
40 |
});
|
41 |
})
|
42 |
-
.adaptiveSwitch()
|
43 |
-
|
44 |
-
$elements.addClass('fw-option-initialized');
|
45 |
});
|
46 |
});
|
1 |
jQuery(document).ready(function ($) {
|
2 |
+
var optionTypeClass = 'fw-option-type-switch',
|
3 |
+
customEventPrefix = 'fw:option-type:switch:';
|
4 |
|
5 |
fwEvents.on('fw:options:init', function (data) {
|
6 |
+
data.$elements.find('.'+ optionTypeClass +':not(.fw-option-initialized)')
|
7 |
+
.find('input[type="checkbox"]')
|
|
|
8 |
.on('change', function(){
|
9 |
+
var $this = $(this),
|
10 |
+
checked = $this.prop('checked'),
|
11 |
+
value = $this.attr('data-switch-'+ (checked ? 'right' : 'left') +'-value-json');
|
|
|
|
|
|
|
12 |
|
13 |
+
$this.val(value);
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
if (checked) {
|
16 |
+
$this.prev('input[type="hidden"]').remove();
|
17 |
} else {
|
18 |
+
/**
|
19 |
+
* When checkbox is not checked, it is not sent in POST so create a hidden input for that
|
20 |
+
*/
|
21 |
+
$('<input>').attr({
|
22 |
+
'type': 'hidden',
|
23 |
+
'name': $this.attr('name'),
|
24 |
+
'value': value
|
25 |
+
}).insertBefore($this);
|
|
|
|
|
26 |
}
|
27 |
|
28 |
$this.closest('.'+ optionTypeClass).trigger(customEventPrefix +'change', {
|
29 |
+
value: JSON.parse(value)
|
30 |
});
|
31 |
})
|
32 |
+
.adaptiveSwitch()
|
33 |
+
.addClass('fw-option-initialized');
|
|
|
34 |
});
|
35 |
});
|
framework/manifest.php
CHANGED
@@ -4,4 +4,4 @@ $manifest = array();
|
|
4 |
|
5 |
$manifest['name'] = __('Unyson', 'fw');
|
6 |
|
7 |
-
$manifest['version'] = '2.4.
|
4 |
|
5 |
$manifest['name'] = __('Unyson', 'fw');
|
6 |
|
7 |
+
$manifest['version'] = '2.4.14';
|
readme.txt
CHANGED
@@ -3,7 +3,7 @@ Contributors: unyson, themefusecom
|
|
3 |
Tags: page builder, cms, grid, layout, responsive, back up, backup, db backup, dump, migrate, schedule, search engine optimization, seo, media, slideshow, shortcode, slide, slideshare, slideshow, google sitemaps, sitemaps, analytics, google analytics, calendar, event, events, google maps, learning, lessons, sidebars, breadcrumbs, review, portfolio, framework
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.4
|
6 |
-
Stable tag: 2.4.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
@@ -83,6 +83,25 @@ Yes; Unyson will work with any theme.
|
|
83 |
|
84 |
== Changelog ==
|
85 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
= 2.4.13 =
|
87 |
* **IMPORTANT!!!** Updating from v2.4.12 to any newer version will uninstall all extensions [#1105](https://github.com/ThemeFuse/Unyson/issues/1105#issuecomment-163966468)
|
88 |
|
3 |
Tags: page builder, cms, grid, layout, responsive, back up, backup, db backup, dump, migrate, schedule, search engine optimization, seo, media, slideshow, shortcode, slide, slideshare, slideshow, google sitemaps, sitemaps, analytics, google analytics, calendar, event, events, google maps, learning, lessons, sidebars, breadcrumbs, review, portfolio, framework
|
4 |
Requires at least: 4.0.0
|
5 |
Tested up to: 4.4
|
6 |
+
Stable tag: 2.4.14
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
83 |
|
84 |
== Changelog ==
|
85 |
|
86 |
+
= 2.4.14 =
|
87 |
+
* Customizer options: Added `wp-customizer-args` parameter. [#1097](https://github.com/ThemeFuse/Unyson/issues/1097), [#1082](https://github.com/ThemeFuse/Unyson/issues/1082)
|
88 |
+
|
89 |
+
$options = array(
|
90 |
+
'b' => array(
|
91 |
+
'wp-customizer-args' => array( // <---
|
92 |
+
'priority' => 10,
|
93 |
+
'active_callback' => 'is_front_page',
|
94 |
+
),
|
95 |
+
'type' => 'box',
|
96 |
+
'options' => array(
|
97 |
+
'o' => array('type' => 'text')
|
98 |
+
)
|
99 |
+
)
|
100 |
+
);
|
101 |
+
|
102 |
+
* Option type `switch`: Changed html input value structure. [#1083](https://github.com/ThemeFuse/Unyson/issues/1083)
|
103 |
+
* Improved the `FW_WP_Filesystem` helper. [#1127](https://github.com/ThemeFuse/Unyson/issues/1127)
|
104 |
+
|
105 |
= 2.4.13 =
|
106 |
* **IMPORTANT!!!** Updating from v2.4.12 to any newer version will uninstall all extensions [#1105](https://github.com/ThemeFuse/Unyson/issues/1105#issuecomment-163966468)
|
107 |
|
unyson.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Unyson
|
4 |
* Plugin URI: http://unyson.io/
|
5 |
* Description: A free drag & drop framework that comes with a bunch of built in extensions that will help you develop premium themes fast & easy.
|
6 |
-
* Version: 2.4.
|
7 |
* Author: ThemeFuse
|
8 |
* Author URI: http://themefuse.com
|
9 |
* License: GPL2+
|
3 |
* Plugin Name: Unyson
|
4 |
* Plugin URI: http://unyson.io/
|
5 |
* Description: A free drag & drop framework that comes with a bunch of built in extensions that will help you develop premium themes fast & easy.
|
6 |
+
* Version: 2.4.14
|
7 |
* Author: ThemeFuse
|
8 |
* Author URI: http://themefuse.com
|
9 |
* License: GPL2+
|