Unyson - Version 2.1.7

Version Description

  • Fixed real_path<->wp_filesystem_path conversion on installations with custom plugins directory (Bedrock WordPress Stack).
Download this release

Release Info

Developer Unyson
Plugin Icon 128x128 Unyson
Version 2.1.7
Comparing to
See all releases

Code changes from version 2.1.6 to 2.1.7

framework/core/components/extensions/manager/class--fw-extensions-manager.php CHANGED
@@ -1620,11 +1620,13 @@ final class _FW_Extensions_Manager
1620
  {
1621
  $extension = fw()->extensions->get(FW_Request::POST('fw_extension_name'));
1622
 
 
 
1623
  fw_set_db_ext_settings_option(
1624
  $extension->get_name(),
1625
  null,
1626
  array_merge(
1627
- (array)fw_get_db_ext_settings_option($extension->get_name()),
1628
  fw_get_options_values_from_input(
1629
  $extension->get_settings_options()
1630
  )
@@ -1639,6 +1641,8 @@ final class _FW_Extensions_Manager
1639
 
1640
  $data['redirect'] = fw_current_url();
1641
 
 
 
1642
  return $data;
1643
  }
1644
 
1620
  {
1621
  $extension = fw()->extensions->get(FW_Request::POST('fw_extension_name'));
1622
 
1623
+ $options_before_save = (array)fw_get_db_ext_settings_option($extension->get_name());
1624
+
1625
  fw_set_db_ext_settings_option(
1626
  $extension->get_name(),
1627
  null,
1628
  array_merge(
1629
+ $options_before_save,
1630
  fw_get_options_values_from_input(
1631
  $extension->get_settings_options()
1632
  )
1641
 
1642
  $data['redirect'] = fw_current_url();
1643
 
1644
+ do_action('fw_extension_settings_form_saved', $extension->get_name(), $options_before_save);
1645
+
1646
  return $data;
1647
  }
1648
 
framework/extensions/update/class-fw-extension-update.php CHANGED
@@ -12,12 +12,6 @@ class FW_Extension_Update extends FW_Extension
12
  return is_subclass_of($child_extension_instance, 'FW_Ext_Update_Service');
13
  }
14
 
15
- /**
16
- * For which directory to request write permissions from Filesystem API
17
- * @var string
18
- */
19
- private $context;
20
-
21
  /**
22
  * File names to skip (do not delete or change) during the update process
23
  * @var array
@@ -44,8 +38,6 @@ class FW_Extension_Update extends FW_Extension
44
  }
45
  }
46
 
47
- $this->context = get_template_directory();
48
-
49
  $this->add_actions();
50
  $this->add_filters();
51
  }
@@ -686,7 +678,7 @@ class FW_Extension_Update extends FW_Extension
686
  $skin->header();
687
 
688
  do {
689
- if (!FW_WP_Filesystem::request_access($this->context, fw_current_url(), array($nonce_name))) {
690
  break;
691
  }
692
 
@@ -754,7 +746,7 @@ class FW_Extension_Update extends FW_Extension
754
  $skin->header();
755
 
756
  do {
757
- if (!FW_WP_Filesystem::request_access($this->context, fw_current_url(), array($nonce_name))) {
758
  break;
759
  }
760
 
@@ -853,7 +845,11 @@ class FW_Extension_Update extends FW_Extension
853
  $_POST[$form_input_name] = wp_slash(json_encode($extensions_list));
854
  }
855
 
856
- if (!FW_WP_Filesystem::request_access($this->context, fw_current_url(), array($nonce_name, $form_input_name))) {
 
 
 
 
857
  { // revert hack changes
858
  $_POST[$form_input_name] = $original_post_value;
859
  unset($original_post_value);
12
  return is_subclass_of($child_extension_instance, 'FW_Ext_Update_Service');
13
  }
14
 
 
 
 
 
 
 
15
  /**
16
  * File names to skip (do not delete or change) during the update process
17
  * @var array
38
  }
39
  }
40
 
 
 
41
  $this->add_actions();
42
  $this->add_filters();
43
  }
678
  $skin->header();
679
 
680
  do {
681
+ if (!FW_WP_Filesystem::request_access(fw_get_framework_directory(), fw_current_url(), array($nonce_name))) {
682
  break;
683
  }
684
 
746
  $skin->header();
747
 
748
  do {
749
+ if (!FW_WP_Filesystem::request_access(get_template_directory(), fw_current_url(), array($nonce_name))) {
750
  break;
751
  }
752
 
845
  $_POST[$form_input_name] = wp_slash(json_encode($extensions_list));
846
  }
847
 
848
+ if (!FW_WP_Filesystem::request_access(
849
+ fw_get_framework_directory('/extensions'),
850
+ fw_current_url(),
851
+ array($nonce_name, $form_input_name))
852
+ ) {
853
  { // revert hack changes
854
  $_POST[$form_input_name] = $original_post_value;
855
  unset($original_post_value);
framework/extensions/update/extensions/github-update/class-fw-extension-github-update.php CHANGED
@@ -70,8 +70,35 @@ class FW_Extension_Github_Update extends FW_Ext_Update_Service
70
  return $response;
71
  }
72
 
73
- if (intval(wp_remote_retrieve_response_code($response)) !== 200) {
74
- return new WP_Error('fw_ext_update_github_fetch_failed', __('Failed to contact Github.', 'fw'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  $releases = json_decode($response['body'], true);
@@ -108,8 +135,7 @@ class FW_Extension_Github_Update extends FW_Ext_Update_Service
108
  );
109
  }
110
 
111
- $theme_id = preg_replace('[^a-z0-9_]', '_', fw()->theme->manifest->get_id());
112
- $transient_id = 'fw_ext_upd_gh_'. $theme_id .'_fw'; // the length must be 45 characters or less
113
 
114
  if ($force_check) {
115
  delete_site_transient($transient_id);
@@ -138,12 +164,20 @@ class FW_Extension_Github_Update extends FW_Ext_Update_Service
138
  }
139
 
140
  if (is_wp_error($latest_version)) {
141
- if ($latest_version->get_error_code() === 'http_request_failed') {
142
- // internet connection problems, use and cache fake version to prevent requests on every refresh
143
- $cache = array_merge($cache, array($user_slash_repo => $this->fake_latest_version));
144
- } else {
145
- return $latest_version;
146
- }
 
 
 
 
 
 
 
 
147
  } else {
148
  $cache = array_merge($cache, array($user_slash_repo => $latest_version));
149
  }
70
  return $response;
71
  }
72
 
73
+ if (($response_code = intval(wp_remote_retrieve_response_code($response))) !== 200) {
74
+ if ($response_code === 403) {
75
+ $json_response = json_decode($response['body'], true);
76
+
77
+ if ($json_response) {
78
+ return new WP_Error(
79
+ 'fw_ext_update_github_fetch_releases_failed',
80
+ __('Github error:', 'fw') .' '. $json_response['message']
81
+ );
82
+ }
83
+ }
84
+
85
+ if ($response_code) {
86
+ return new WP_Error(
87
+ 'fw_ext_update_github_fetch_releases_failed',
88
+ sprintf(
89
+ __( 'Failed to access Github repository "%s" releases. (Response code: %d)', 'fw' ),
90
+ $user_slash_repo, $response_code
91
+ )
92
+ );
93
+ } else {
94
+ return new WP_Error(
95
+ 'fw_ext_update_github_fetch_releases_failed',
96
+ sprintf(
97
+ __( 'Failed to access Github repository "%s" releases.', 'fw' ),
98
+ $user_slash_repo
99
+ )
100
+ );
101
+ }
102
  }
103
 
104
  $releases = json_decode($response['body'], true);
135
  );
136
  }
137
 
138
+ $transient_id = 'fw_ext_upd_gh_fw'; // the length must be 45 characters or less
 
139
 
140
  if ($force_check) {
141
  delete_site_transient($transient_id);
164
  }
165
 
166
  if (is_wp_error($latest_version)) {
167
+ /**
168
+ * Internet connection problems or Github API requests limit reached.
169
+ * Cache fake version to prevent requests to Github API on every refresh.
170
+ */
171
+ $cache = array_merge($cache, array($user_slash_repo => $this->fake_latest_version));
172
+
173
+ /**
174
+ * Show the error to the user because it is not visible elsewhere
175
+ */
176
+ FW_Flash_Messages::add(
177
+ 'fw_ext_github_update_error',
178
+ $latest_version->get_error_message(),
179
+ 'error'
180
+ );
181
  } else {
182
  $cache = array_merge($cache, array($user_slash_repo => $latest_version));
183
  }
framework/extensions/update/manifest.php CHANGED
@@ -6,5 +6,5 @@ $manifest['name'] = __('Update', 'fw');
6
  $manifest['description'] = __('Keep you framework, extensions and theme up to date.', 'fw');
7
  $manifest['standalone'] = true;
8
 
9
- $manifest['version'] = '1.0.2';
10
  $manifest['github_update'] = 'ThemeFuse/Unyson-Update-Extension';
6
  $manifest['description'] = __('Keep you framework, extensions and theme up to date.', 'fw');
7
  $manifest['standalone'] = true;
8
 
9
+ $manifest['version'] = '1.0.4';
10
  $manifest['github_update'] = 'ThemeFuse/Unyson-Update-Extension';
framework/extensions/update/views/updates-list.php CHANGED
@@ -63,6 +63,17 @@
63
  <?php else: ?>
64
  <?php
65
  $one_update_mode = fw()->extensions->get('update')->get_config('extensions_as_one_update');
 
 
 
 
 
 
 
 
 
 
 
66
  ?>
67
  <form id="fw-ext-update-extensions" method="post" action="update-core.php?action=fw-update-extensions">
68
  <div class="fw-ext-update-extensions-form-detailed" <?php if ($one_update_mode): ?>style="display: none;"<?php endif; ?>>
63
  <?php else: ?>
64
  <?php
65
  $one_update_mode = fw()->extensions->get('update')->get_config('extensions_as_one_update');
66
+
67
+ foreach ($updates['extensions'] as $extension) {
68
+ if (is_wp_error($extension)) {
69
+ /**
70
+ * Cancel the "One update mode" and display all extensions list table with details
71
+ * if at least one extension has an error that needs to be visible
72
+ */
73
+ $one_update_mode = false;
74
+ break;
75
+ }
76
+ }
77
  ?>
78
  <form id="fw-ext-update-extensions" method="post" action="update-core.php?action=fw-update-extensions">
79
  <div class="fw-ext-update-extensions-form-detailed" <?php if ($one_update_mode): ?>style="display: none;"<?php endif; ?>>
framework/helpers/class-fw-wp-filesystem.php CHANGED
@@ -81,10 +81,50 @@ class FW_WP_Filesystem
81
  }
82
  }
83
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
84
  /**
85
  * Convert real file path to WP Filesystem path
86
  * @param string $real_path
87
- * @return string
88
  */
89
  final public static function real_path_to_filesystem_path($real_path) {
90
  /** @var WP_Filesystem_Base $wp_filesystem */
@@ -95,18 +135,27 @@ class FW_WP_Filesystem
95
  }
96
 
97
  $real_path = fw_fix_path($real_path);
98
- $real_abspath = fw_fix_path(ABSPATH);
99
- $wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath());
100
 
101
- $relative_path = preg_replace('/^'. preg_quote($real_abspath, '/') .'/', '', $real_path);
 
102
 
103
- return $wp_filesystem_abspath . $relative_path;
 
 
 
 
 
 
 
 
 
 
104
  }
105
 
106
  /**
107
  * Convert WP Filesystem path to real file path
108
  * @param string $wp_filesystem_path
109
- * @return string
110
  */
111
  final public static function filesystem_path_to_real_path($wp_filesystem_path) {
112
  /** @var WP_Filesystem_Base $wp_filesystem */
@@ -117,12 +166,21 @@ class FW_WP_Filesystem
117
  }
118
 
119
  $wp_filesystem_path = fw_fix_path($wp_filesystem_path);
120
- $wp_filesystem_abspath = fw_fix_path($wp_filesystem->abspath());
121
- $real_abspath = fw_fix_path(ABSPATH);
122
 
123
- $relative_path = preg_replace('/^'. preg_quote($wp_filesystem_abspath, '/') .'/', '', $wp_filesystem_path);
 
 
 
 
 
 
 
 
 
 
 
124
 
125
- return $real_abspath . $relative_path;
126
  }
127
 
128
  /**
@@ -169,27 +227,38 @@ class FW_WP_Filesystem
169
 
170
  $wp_filesystem_dir_path = fw_fix_path($wp_filesystem_dir_path);
171
 
172
- /**
173
- * Begin path verification starting with ABSPATH not the root '/' path.
174
- * On servers where user has permissions only in his home directory.
175
- * When you try to check a directory (outside home directory) that you have no permissions,
176
- * the $wp_filesystem->is_dir($path) or $wp_filesystem->exists($path) will always return false.
177
- */
178
- $path = fw_fix_path($wp_filesystem->abspath());
179
 
180
- if (
181
- $wp_filesystem_dir_path === $path
182
- ||
183
- fw_strlen($wp_filesystem_dir_path) < fw_strlen($path)
184
- ) {
185
- trigger_error('Cannot create directory outside the abspath: '. $wp_filesystem_dir_path, E_USER_WARNING);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  return false;
187
  }
188
 
189
- $abs_rel_path = preg_replace('/^'. preg_quote($path, '/') .'/', '', $wp_filesystem_dir_path);
190
 
 
191
  $check_if_exists = true;
192
- foreach (explode('/', ltrim($abs_rel_path, '/')) as $dir_name) {
 
193
  $path .= '/' . $dir_name;
194
 
195
  if ($check_if_exists) {
@@ -197,7 +266,7 @@ class FW_WP_Filesystem
197
  // do nothing if exists
198
  continue;
199
  } else {
200
- // do not check anymore, next directories sure does not exists
201
  $check_if_exists = false;
202
  }
203
  }
81
  }
82
  }
83
 
84
+ /**
85
+ * @return array {base_dir_real_path => base_dir_wp_filesystem_path}
86
+ */
87
+ public static function get_base_dirs_map()
88
+ {
89
+ /** @var WP_Filesystem_Base $wp_filesystem */
90
+ global $wp_filesystem;
91
+
92
+ if (!$wp_filesystem) {
93
+ trigger_error('Filesystem is not available', E_USER_ERROR);
94
+ }
95
+
96
+ try {
97
+ $cache_key = 'fw_wp_filesystem/base_dirs_map';
98
+
99
+ return FW_Cache::get($cache_key);
100
+ } catch (FW_Cache_Not_Found_Exception $e) {
101
+ // code from $wp_filesystem->wp_themes_dir()
102
+ {
103
+ $themes_dir = get_theme_root();
104
+
105
+ // Account for relative theme roots
106
+ if ( '/themes' == $themes_dir || ! is_dir( $themes_dir ) ) {
107
+ $themes_dir = WP_CONTENT_DIR . $themes_dir;
108
+ }
109
+ }
110
+
111
+ $dirs = array(
112
+ fw_fix_path(ABSPATH) => fw_fix_path($wp_filesystem->abspath()),
113
+ fw_fix_path(WP_CONTENT_DIR) => fw_fix_path($wp_filesystem->wp_content_dir()),
114
+ fw_fix_path(WP_PLUGIN_DIR) => fw_fix_path($wp_filesystem->wp_plugins_dir()),
115
+ fw_fix_path($themes_dir) => fw_fix_path($wp_filesystem->wp_themes_dir()),
116
+ );
117
+
118
+ FW_Cache::set($cache_key, $dirs);
119
+
120
+ return $dirs;
121
+ }
122
+ }
123
+
124
  /**
125
  * Convert real file path to WP Filesystem path
126
  * @param string $real_path
127
+ * @return string|false
128
  */
129
  final public static function real_path_to_filesystem_path($real_path) {
130
  /** @var WP_Filesystem_Base $wp_filesystem */
135
  }
136
 
137
  $real_path = fw_fix_path($real_path);
 
 
138
 
139
+ foreach (self::get_base_dirs_map() as $base_real_path => $base_wp_filesystem_path) {
140
+ $prefix_regex = '/^'. preg_quote($base_real_path, '/') .'/';
141
 
142
+ // check if path is inside base path
143
+ if (!preg_match($prefix_regex, $real_path)) {
144
+ continue;
145
+ }
146
+
147
+ $relative_path = preg_replace($prefix_regex, '', $real_path);
148
+
149
+ return $base_wp_filesystem_path . $relative_path;
150
+ }
151
+
152
+ return false;
153
  }
154
 
155
  /**
156
  * Convert WP Filesystem path to real file path
157
  * @param string $wp_filesystem_path
158
+ * @return string|false
159
  */
160
  final public static function filesystem_path_to_real_path($wp_filesystem_path) {
161
  /** @var WP_Filesystem_Base $wp_filesystem */
166
  }
167
 
168
  $wp_filesystem_path = fw_fix_path($wp_filesystem_path);
 
 
169
 
170
+ foreach (self::get_base_dirs_map() as $base_real_path => $base_wp_filesystem_path) {
171
+ $prefix_regex = '/^'. preg_quote($base_wp_filesystem_path, '/') .'/';
172
+
173
+ // check if path is inside base path
174
+ if (!preg_match($prefix_regex, $wp_filesystem_path)) {
175
+ continue;
176
+ }
177
+
178
+ $relative_path = preg_replace($prefix_regex, '', $wp_filesystem_path);
179
+
180
+ return $base_real_path . $relative_path;
181
+ }
182
 
183
+ return false;
184
  }
185
 
186
  /**
227
 
228
  $wp_filesystem_dir_path = fw_fix_path($wp_filesystem_dir_path);
229
 
230
+ $path = false;
 
 
 
 
 
 
231
 
232
+ foreach (self::get_base_dirs_map() as $base_real_path => $base_wp_filesystem_path) {
233
+ $prefix_regex = '/^'. preg_quote($base_wp_filesystem_path, '/') .'/';
234
+
235
+ // check if path is inside base path
236
+ if (!preg_match($prefix_regex, $wp_filesystem_dir_path)) {
237
+ continue;
238
+ }
239
+
240
+ $path = $base_wp_filesystem_path;
241
+ break;
242
+ }
243
+
244
+ if (!$path) {
245
+ trigger_error(
246
+ sprintf(
247
+ __('Cannot create directory "%s". It must be inside "%s"', 'fw'),
248
+ $wp_filesystem_dir_path,
249
+ implode(__('" or "', 'fw'), self::get_base_dirs_map())
250
+ ),
251
+ E_USER_WARNING
252
+ );
253
  return false;
254
  }
255
 
256
+ $rel_path = preg_replace('/^'. preg_quote($path, '/') .'/', '', $wp_filesystem_dir_path);
257
 
258
+ // improvement: do not check directory for existence if it's known that sure it doesn't exist
259
  $check_if_exists = true;
260
+
261
+ foreach (explode('/', ltrim($rel_path, '/')) as $dir_name) {
262
  $path .= '/' . $dir_name;
263
 
264
  if ($check_if_exists) {
266
  // do nothing if exists
267
  continue;
268
  } else {
269
+ // do not check anymore, next directories sure doesn't exist
270
  $check_if_exists = false;
271
  }
272
  }
framework/includes/option-types/multi-picker/static/css/multi-picker.css CHANGED
@@ -27,7 +27,8 @@
27
  border-bottom-width: 0px !important;
28
  }
29
 
30
- .fw-option-type-multi-picker > .picker-group {
 
31
  border-bottom-width: 0px;
32
  padding-bottom: 0;
33
  }
@@ -37,7 +38,7 @@
37
  }
38
 
39
  .fw-option-type-multi-picker .fw-option-type-multi > .fw-backend-option,
40
- .fw-option-type-multi-picker.has-choice > .picker-group {
41
  padding-bottom: 0;
42
  }
43
 
27
  border-bottom-width: 0px !important;
28
  }
29
 
30
+ .fw-option-type-multi-picker:not(.fw-option-type-multi-picker-with-borders) > .picker-group,
31
+ .fw-option-type-multi-picker.fw-option-type-multi-picker-with-borders:not(.has-choice) > .picker-group {
32
  border-bottom-width: 0px;
33
  padding-bottom: 0;
34
  }
38
  }
39
 
40
  .fw-option-type-multi-picker .fw-option-type-multi > .fw-backend-option,
41
+ .fw-option-type-multi-picker.has-choice:not(.fw-option-type-multi-picker-with-borders) > .picker-group {
42
  padding-bottom: 0;
43
  }
44
 
framework/manifest.php CHANGED
@@ -4,4 +4,4 @@ $manifest = array();
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
- $manifest['version'] = '2.1.6';
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
+ $manifest['version'] = '2.1.7';
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
4
  Requires at least: 4.0.0
5
  Tested up to: 4.0.1
6
- Stable tag: 2.1.6
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -84,6 +84,9 @@ Yes; Unyson will work with any theme.
84
 
85
  == Changelog ==
86
 
 
 
 
87
  = 2.1.6 =
88
  * Fixed the "Cannot create temporary directory" error that happened on some servers where the user have no permissions to access files outside the abspath or home directory.
89
 
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
4
  Requires at least: 4.0.0
5
  Tested up to: 4.0.1
6
+ Stable tag: 2.1.7
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
84
 
85
  == Changelog ==
86
 
87
+ = 2.1.7 =
88
+ * Fixed real_path&lt;-&gt;wp_filesystem_path conversion on installations with custom plugins directory (Bedrock WordPress Stack).
89
+
90
  = 2.1.6 =
91
  * Fixed the "Cannot create temporary directory" error that happened on some servers where the user have no permissions to access files outside the abspath or home directory.
92
 
unyson.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: Unyson
4
  * Plugin URI: http://unyson.themefuse.com/
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.1.6
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+
3
  * Plugin Name: Unyson
4
  * Plugin URI: http://unyson.themefuse.com/
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.1.7
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+