Unyson - Version 2.4.5

Version Description

  • Fixed #768
  • Create ABSPATH .'/fw-update.log' on plugin update to help solve #263
Download this release

Release Info

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

Code changes from version 2.4.4 to 2.4.5

framework/includes/option-types/simple.php CHANGED
@@ -1007,7 +1007,8 @@ class FW_Option_Type_Unique extends FW_Option_Type
1007
  protected function _get_defaults()
1008
  {
1009
  return array(
1010
- 'value' => ''
 
1011
  );
1012
  }
1013
 
@@ -1024,6 +1025,21 @@ class FW_Option_Type_Unique extends FW_Option_Type
1024
  add_action('save_post', array($this, '_action_reset_post_ids'), 8);
1025
  }
1026
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1027
  /**
1028
  * After the post has been saved
1029
  * other scripts may call wp_update_post() and the save will start again
@@ -1049,13 +1065,13 @@ class FW_Option_Type_Unique extends FW_Option_Type
1049
 
1050
  protected function _get_value_from_input($option, $input_value) {
1051
  if (is_null($input_value)) {
1052
- $id = empty($option['value']) ? fw_rand_md5() : $option['value'];
1053
  } else {
1054
  $id = $input_value;
1055
  }
1056
 
1057
  if (empty($id) || !is_string($id)) {
1058
- $id = fw_rand_md5();
1059
  }
1060
 
1061
  /**
@@ -1075,7 +1091,7 @@ class FW_Option_Type_Unique extends FW_Option_Type
1075
  }
1076
 
1077
  while (isset(self::$ids[$post_id][$id])) {
1078
- $id = fw_rand_md5();
1079
  }
1080
 
1081
  self::$ids[$post_id][$id] = true;
1007
  protected function _get_defaults()
1008
  {
1009
  return array(
1010
+ 'value' => '',
1011
+ 'length' => 0, // Limit id length
1012
  );
1013
  }
1014
 
1025
  add_action('save_post', array($this, '_action_reset_post_ids'), 8);
1026
  }
1027
 
1028
+ /**
1029
+ * @param null|int $length_limit
1030
+ * @return string
1031
+ */
1032
+ protected function generate_id($length_limit = null)
1033
+ {
1034
+ $id = fw_rand_md5();
1035
+
1036
+ if ($length_limit) {
1037
+ $id = substr($id, 0, (int)$length_limit);
1038
+ }
1039
+
1040
+ return $id;
1041
+ }
1042
+
1043
  /**
1044
  * After the post has been saved
1045
  * other scripts may call wp_update_post() and the save will start again
1065
 
1066
  protected function _get_value_from_input($option, $input_value) {
1067
  if (is_null($input_value)) {
1068
+ $id = empty($option['value']) ? $this->generate_id($option['length']) : $option['value'];
1069
  } else {
1070
  $id = $input_value;
1071
  }
1072
 
1073
  if (empty($id) || !is_string($id)) {
1074
+ $id = $this->generate_id($option['length']);
1075
  }
1076
 
1077
  /**
1091
  }
1092
 
1093
  while (isset(self::$ids[$post_id][$id])) {
1094
+ $id = $this->generate_id($option['length']);
1095
  }
1096
 
1097
  self::$ids[$post_id][$id] = true;
framework/manifest.php CHANGED
@@ -4,4 +4,4 @@ $manifest = array();
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
- $manifest['version'] = '2.4.4';
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
+ $manifest['version'] = '2.4.5';
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.2
6
- Stable tag: 2.4.4
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -82,6 +82,10 @@ Yes; Unyson will work with any theme.
82
 
83
  == Changelog ==
84
 
 
 
 
 
85
  = 2.4.4 =
86
  * Fixed [#757](https://github.com/ThemeFuse/Unyson/issues/757), [#752](https://github.com/ThemeFuse/Unyson/issues/752#issuecomment-124839194)
87
  * fw.OptionsModal: Prevent Reset button to change the value. It should reset only the form's html
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.2
6
+ Stable tag: 2.4.5
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
82
 
83
  == Changelog ==
84
 
85
+ = 2.4.5 =
86
+ * Fixed [#768](https://github.com/ThemeFuse/Unyson/issues/768)
87
+ * Create `ABSPATH .'/fw-update.log'` on plugin update to help solve [#263](https://github.com/ThemeFuse/Unyson/issues/263)
88
+
89
  = 2.4.4 =
90
  * Fixed [#757](https://github.com/ThemeFuse/Unyson/issues/757), [#752](https://github.com/ThemeFuse/Unyson/issues/752#issuecomment-124839194)
91
  * fw.OptionsModal: Prevent Reset button to change the value. It should reset only the form's html
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.4.4
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+
@@ -101,32 +101,6 @@ if (defined('FW')) {
101
  }
102
  add_action( 'delete_blog', '_action_fw_delete_blog', 10, 2 );
103
 
104
- /** @internal */
105
- function _filter_fw_check_if_plugin_pre_update( $result, $data ) {
106
- if ( isset( $data['plugin'] ) && $data['plugin'] === plugin_basename( __FILE__ ) ) {
107
- /**
108
- * Before plugin update
109
- */
110
- do_action( 'fw_plugin_pre_update' );
111
- }
112
-
113
- return $result;
114
- }
115
- add_filter( 'upgrader_pre_install', '_filter_fw_check_if_plugin_pre_update', 10, 2 );
116
-
117
- /** @internal */
118
- function _filter_fw_check_if_plugin_post_update( $result, $data ) {
119
- if ( isset( $data['plugin'] ) && $data['plugin'] === plugin_basename( __FILE__ ) ) {
120
- /**
121
- * After plugin update
122
- */
123
- do_action( 'fw_plugin_post_update' );
124
- }
125
-
126
- return $result;
127
- }
128
- add_filter( 'upgrader_post_install', '_filter_fw_check_if_plugin_post_update', 10, 2 );
129
-
130
  /** @internal */
131
  function _filter_fw_plugin_action_list( $actions ) {
132
  return apply_filters( 'fw_plugin_action_list', $actions );
@@ -151,17 +125,106 @@ if (defined('FW')) {
151
  add_filter( 'fw_tmp_dir', '_filter_fw_tmp_dir' );
152
 
153
  /** @internal */
154
- function _filter_fw_disable_auto_update ( $update, $item ) {
155
- if ('unyson' === strtolower($item->slug)) {
156
- /**
157
- * Prevent Unyson auto-update
158
- * An attempt to fix https://github.com/ThemeFuse/Unyson/issues/263
159
- */
160
- return false;
161
- } else {
162
- return $update;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
163
  }
164
  }
165
- add_filter( 'auto_update_plugin', '_filter_fw_disable_auto_update', 10, 2 );
166
  }
167
  }
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.4.5
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+
101
  }
102
  add_action( 'delete_blog', '_action_fw_delete_blog', 10, 2 );
103
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
104
  /** @internal */
105
  function _filter_fw_plugin_action_list( $actions ) {
106
  return apply_filters( 'fw_plugin_action_list', $actions );
125
  add_filter( 'fw_tmp_dir', '_filter_fw_tmp_dir' );
126
 
127
  /** @internal */
128
+ final class _FW_Update_Hooks {
129
+ public static function _init() {
130
+ add_filter( 'upgrader_pre_install', array(__CLASS__, '_filter_fw_check_if_plugin_pre_update'), 9999, 2 );
131
+ add_filter( 'upgrader_post_install', array(__CLASS__, '_filter_fw_check_if_plugin_post_update'), 9999, 2 );
132
+ add_action( 'automatic_updates_complete', array(__CLASS__, '_action_fw_automatic_updates_complete') );
133
+ add_filter( 'auto_update_plugin', array(__CLASS__, '_filter_fw_disable_auto_update'), 10, 2 );
134
+ }
135
+
136
+ public static function _filter_fw_check_if_plugin_pre_update( $result, $data ) {
137
+ if (
138
+ !is_wp_error($result)
139
+ &&
140
+ isset( $data['plugin'] )
141
+ &&
142
+ plugin_basename( __FILE__ ) === $data['plugin']
143
+ ) {
144
+ /**
145
+ * Before plugin update
146
+ * The plugin was already download and extracted to a temp directory
147
+ * and it's right before being replaced with the new downloaded version
148
+ */
149
+ do_action( 'fw_plugin_pre_update' ); self::_fw_update_debug_log('fw_plugin_pre_update');
150
+ }
151
+
152
+ return $result;
153
+ }
154
+
155
+ public static function _filter_fw_check_if_plugin_post_update( $result, $data ) {
156
+ if (
157
+ !is_wp_error($result)
158
+ &&
159
+ isset( $data['plugin'] )
160
+ &&
161
+ plugin_basename( __FILE__ ) === $data['plugin']
162
+ ) {
163
+ /**
164
+ * After plugin successfully updated
165
+ */
166
+ do_action( 'fw_plugin_post_update' ); self::_fw_update_debug_log('fw_plugin_post_update');
167
+ }
168
+
169
+ return $result;
170
+ }
171
+
172
+ public static function _action_fw_automatic_updates_complete($results) {
173
+ if (!isset($results['plugin'])) {
174
+ return;
175
+ }
176
+
177
+ foreach ($results['plugin'] as $plugin) {
178
+ if ('unyson' === strtolower($plugin->item->slug)) {
179
+ do_action( 'fw_automatic_update_complete', $plugin->result ); self::_fw_update_debug_log('fw_automatic_update_complete '. ($plugin->result ? 'OK' : 'NOT OK'));
180
+ break;
181
+ }
182
+ }
183
+ }
184
+
185
+ public static function _filter_fw_disable_auto_update ( $update, $item ) {
186
+ if ('unyson' === strtolower($item->slug)) {
187
+ /**
188
+ * Prevent Unyson auto update
189
+ * An attempt to fix https://github.com/ThemeFuse/Unyson/issues/263
190
+ */
191
+ do_action('fw_plugin_auto_update_stop'); self::_fw_update_debug_log('fw_plugin_auto_update_stop');
192
+ return false;
193
+ } else {
194
+ return $update;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Log debug information in ABSPATH/fw-update.log
200
+ * @param string $message
201
+ * @return bool|void
202
+ */
203
+ private static function _fw_update_debug_log($message) {
204
+ /** @var WP_Filesystem_Base $wp_filesystem */
205
+ global $wp_filesystem;
206
+
207
+ if (!$wp_filesystem) {
208
+ return;
209
+ }
210
+
211
+ $file_fs_path = fw_fix_path($wp_filesystem->abspath()) .'/fw-update.log';
212
+
213
+ if ($wp_filesystem->exists($file_fs_path)) {
214
+ $current_log = $wp_filesystem->get_contents($file_fs_path);
215
+
216
+ if ($current_log === false) {
217
+ return false;
218
+ }
219
+ } else {
220
+ $current_log = '';
221
+ }
222
+
223
+ $message = '['. date('Y-m-d H:i:s') .'] '. $message;
224
+
225
+ $wp_filesystem->put_contents($file_fs_path, $current_log . $message ."\n");
226
  }
227
  }
228
+ _FW_Update_Hooks::_init();
229
  }
230
  }