Unyson - Version 2.4.4

Version Description

  • Fixed #757, #752
  • fw.OptionsModal: Prevent Reset button to change the value. It should reset only the form's html
  • Minor refactor in code that is responsible for auto-save post options save
Download this release

Release Info

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

Code changes from version 2.4.3 to 2.4.4

framework/core/components/backend.php CHANGED
@@ -169,7 +169,6 @@ final class _FW_Component_Backend {
169
  add_action('save_post', array($this, '_action_save_post'), 7, 3);
170
  add_action('wp_restore_post_revision', array($this, '_action_restore_post_revision'), 10, 2);
171
  add_action('_wp_put_post_revision', array($this, '_action__wp_put_post_revision'));
172
- add_action('wp_creating_autosave', array($this, '_action_trigger_wp_create_autosave'));
173
 
174
  add_action('customize_register', array($this, '_action_customize_register'), 7);
175
  }
@@ -764,6 +763,7 @@ final class _FW_Component_Backend {
764
  }
765
 
766
  /**
 
767
  * @param int $post_id
768
  * @param WP_Post $post
769
  * @param bool $update
@@ -815,18 +815,51 @@ final class _FW_Component_Backend {
815
  * Use the 'fw_post_options_update' action
816
  */
817
  do_action( 'fw_save_post_options', $post_id, $post, $old_values );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
818
  } elseif ($original_post_id = wp_is_post_revision( $post_id )) {
819
  /**
820
  * Do nothing, the
821
  * - '_wp_put_post_revision'
822
  * - 'wp_restore_post_revision'
823
- * - 'wp_creating_autosave'
824
  * actions will handle this
825
  */
826
- } elseif ($original_post_id = wp_is_post_autosave( $post_id )) {
827
- // fixme: I don't know how to test this. The execution never entered here
828
- FW_Flash_Messages::add(fw_rand_md5(), 'Unhandled auto-save');
829
- } else {
830
  /**
831
  * This happens on:
832
  * - post add (auto-draft): do nothing
@@ -835,60 +868,6 @@ final class _FW_Component_Backend {
835
  }
836
  }
837
 
838
- /**
839
- * @param array $autosave
840
- *
841
- * @internal
842
- **/
843
- public function _action_trigger_wp_create_autosave( $autosave ) {
844
- add_action( 'save_post', array( $this, '_action_update_autosave_options' ), 10, 2 );
845
- }
846
-
847
- /**
848
- * Happens on post Preview
849
- *
850
- * @param int $post_id
851
- * @param WP_Post $post
852
- *
853
- * @internal
854
- **/
855
- public function _action_update_autosave_options( $post_id, $post ) {
856
- remove_action( 'save_post', array( $this, '_action_update_autosave_options' ) );
857
-
858
- remove_action( 'save_post', array( $this, '_action_save_post' ), 7 );
859
-
860
- do {
861
- $parent = get_post($post->post_parent);
862
-
863
- if ( ! $parent instanceof WP_Post ) {
864
- break;
865
- }
866
-
867
- if (empty($_POST[ FW_Option_Type::get_default_name_prefix() ])) {
868
- // this happens on Quick Edit
869
- break;
870
- }
871
-
872
- $current_values = fw_get_options_values_from_input(
873
- fw()->theme->get_post_options($parent->post_type)
874
- );
875
-
876
- fw_set_db_post_option(
877
- $post->ID,
878
- null,
879
- array_diff_key( // remove handled values
880
- $current_values,
881
- $this->process_options_handlers(
882
- fw()->theme->get_post_options($parent->post_type),
883
- $current_values
884
- )
885
- )
886
- );
887
- } while(false);
888
-
889
- add_action( 'save_post', array( $this, '_action_save_post' ), 7, 3 );
890
- }
891
-
892
  /**
893
  * @param $post_id
894
  * @param $revision_id
169
  add_action('save_post', array($this, '_action_save_post'), 7, 3);
170
  add_action('wp_restore_post_revision', array($this, '_action_restore_post_revision'), 10, 2);
171
  add_action('_wp_put_post_revision', array($this, '_action__wp_put_post_revision'));
 
172
 
173
  add_action('customize_register', array($this, '_action_customize_register'), 7);
174
  }
763
  }
764
 
765
  /**
766
+ * Save meta from $_POST to fw options (post meta)
767
  * @param int $post_id
768
  * @param WP_Post $post
769
  * @param bool $update
815
  * Use the 'fw_post_options_update' action
816
  */
817
  do_action( 'fw_save_post_options', $post_id, $post, $old_values );
818
+ } elseif ($original_post_id = wp_is_post_autosave( $post_id )) {
819
+ do {
820
+ $parent = get_post($post->post_parent);
821
+
822
+ if ( ! $parent instanceof WP_Post ) {
823
+ break;
824
+ }
825
+
826
+ if (
827
+ isset($_POST['post_ID'])
828
+ &&
829
+ intval($_POST['post_ID']) === intval($parent->ID)
830
+ ) {} else {
831
+ break;
832
+ }
833
+
834
+ if (empty($_POST[ FW_Option_Type::get_default_name_prefix() ])) {
835
+ // this happens on Quick Edit
836
+ break;
837
+ }
838
+
839
+ $current_values = fw_get_options_values_from_input(
840
+ fw()->theme->get_post_options($parent->post_type)
841
+ );
842
+
843
+ fw_set_db_post_option(
844
+ $post->ID,
845
+ null,
846
+ array_diff_key( // remove handled values
847
+ $current_values,
848
+ $this->process_options_handlers(
849
+ fw()->theme->get_post_options($parent->post_type),
850
+ $current_values
851
+ )
852
+ )
853
+ );
854
+ } while(false);
855
  } elseif ($original_post_id = wp_is_post_revision( $post_id )) {
856
  /**
857
  * Do nothing, the
858
  * - '_wp_put_post_revision'
859
  * - 'wp_restore_post_revision'
 
860
  * actions will handle this
861
  */
862
+ } else {
 
 
 
863
  /**
864
  * This happens on:
865
  * - post add (auto-draft): do nothing
868
  }
869
  }
870
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
871
  /**
872
  * @param $post_id
873
  * @param $revision_id
framework/helpers/database.php CHANGED
@@ -90,6 +90,21 @@
90
  } else {
91
  $post_id = $post->ID;
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
  $option_id = 'fw_options' . ( $option_id !== null ? '/' . $option_id : '' );
90
  } else {
91
  $post_id = $post->ID;
92
  }
93
+
94
+ /**
95
+ * Check if is Preview and use the preview post_id instead of real/current post id
96
+ *
97
+ * Note: WordPress changes the global $post content on preview:
98
+ * 1. https://github.com/WordPress/WordPress/blob/2096b451c704715db3c4faf699a1184260deade9/wp-includes/query.php#L3573-L3583
99
+ * 2. https://github.com/WordPress/WordPress/blob/4a31dd6fe8b774d56f901a29e72dcf9523e9ce85/wp-includes/revision.php#L485-L528
100
+ */
101
+ if (is_preview()) {
102
+ $preview = wp_get_post_autosave($post->ID);
103
+
104
+ if ( is_object($preview) ) {
105
+ $post_id = $preview->ID;
106
+ }
107
+ }
108
  }
109
 
110
  $option_id = 'fw_options' . ( $option_id !== null ? '/' . $option_id : '' );
framework/helpers/general.php CHANGED
@@ -220,6 +220,8 @@ function fw_print($value) {
220
  margin: 10px 30px;
221
  padding: 1px;
222
  border-radius: 5px;
 
 
223
  }
224
  div.fw_print_r_group div.fw_print_r {
225
  margin: 9px;
220
  margin: 10px 30px;
221
  padding: 1px;
222
  border-radius: 5px;
223
+ position: relative;
224
+ z-index: 11110;
225
  }
226
  div.fw_print_r_group div.fw_print_r {
227
  margin: 9px;
framework/includes/option-types/wp-editor/class-fw-option-type-wp-editor.php CHANGED
@@ -51,7 +51,15 @@ class FW_Option_Type_Wp_Editor extends FW_Option_Type {
51
  * Set the editor size: small - small box, large - full size
52
  * string
53
  */
54
- 'size' => 'small' // small, large
 
 
 
 
 
 
 
 
55
  );
56
  }
57
 
@@ -184,18 +192,22 @@ class FW_Option_Type_Wp_Editor extends FW_Option_Type {
184
  'data-tmce-teeny' => json_encode( $this->get_teeny_preset( $option ) ),
185
  'data-tmce-extended' => json_encode( $this->get_extended_preset( $option ) ),
186
  'data-width-type' => $option['size'],
 
187
  ) );
188
 
189
  echo '<div ' . fw_attr_to_html( $wrapper_attr ) . '>';
190
 
191
  $option['editor_css'] .= '<style>#wp-link-wrap{z-index: 160105} #wp-link-backdrop{z-index: 160100} .mce-container.mce-panel.mce-floatpanel.mce-menu, .mce-container.mce-panel.mce-floatpanel.mce-popover, .mce-container.mce-panel.mce-floatpanel.mce-window {z-index: 160105 !important;}</style>';
192
 
193
- wp_editor( $value, $textarea_id, array(
194
  'teeny' => $option['teeny'],
195
  'media_buttons' => $option['media_buttons'],
196
  'tinymce' => $option['tinymce'],
197
- 'editor_css' => $option['editor_css']
198
- ) );
 
 
 
199
 
200
  echo '</div>';
201
  }
51
  * Set the editor size: small - small box, large - full size
52
  * string
53
  */
54
+ 'size' => 'small', // small, large
55
+ /**
56
+ * Set editor type : 'tinymce' or 'html'
57
+ */
58
+ 'editor_type' => wp_default_editor(),
59
+ /**
60
+ * Set the editor height, must be int
61
+ */
62
+ 'editor_height' => 400
63
  );
64
  }
65
 
192
  'data-tmce-teeny' => json_encode( $this->get_teeny_preset( $option ) ),
193
  'data-tmce-extended' => json_encode( $this->get_extended_preset( $option ) ),
194
  'data-width-type' => $option['size'],
195
+ 'data-editor-type' =>$option['editor_type']
196
  ) );
197
 
198
  echo '<div ' . fw_attr_to_html( $wrapper_attr ) . '>';
199
 
200
  $option['editor_css'] .= '<style>#wp-link-wrap{z-index: 160105} #wp-link-backdrop{z-index: 160100} .mce-container.mce-panel.mce-floatpanel.mce-menu, .mce-container.mce-panel.mce-floatpanel.mce-popover, .mce-container.mce-panel.mce-floatpanel.mce-window {z-index: 160105 !important;}</style>';
201
 
202
+ $settings = array(
203
  'teeny' => $option['teeny'],
204
  'media_buttons' => $option['media_buttons'],
205
  'tinymce' => $option['tinymce'],
206
+ 'editor_css' => $option['editor_css'],
207
+ 'editor_height' => (int) $option['editor_height']
208
+ );
209
+
210
+ wp_editor( $value, $textarea_id, $settings );
211
 
212
  echo '</div>';
213
  }
framework/includes/option-types/wp-editor/static/js/scripts.js CHANGED
@@ -42,12 +42,11 @@
42
 
43
  var reachTexEditorReinit = function($textarea){
44
  var parent = $textarea.parents('.wp-editor-wrap:eq(0)'),
45
- $activeEditorBtn = parent.hasClass('tmce-active') ? parent.find('.switch-tmce') : parent.find('.switch-html'),
46
  $btnTabs = parent.find('.wp-switch-editor').removeAttr("onclick"),
47
  id = $textarea.attr('id'),
48
  settings = {id: id , buttons: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'};
49
 
50
-
51
  var tmceCustomSettings = $textarea.parents('.fw-option-type-wp-editor').data('tinymce'),
52
  tmce_teeny = $textarea.parents('.fw-option-type-wp-editor').data('tmce-teeny'),
53
  tmce_extended = $textarea.parents('.fw-option-type-wp-editor').data('tmce-extended'),
42
 
43
  var reachTexEditorReinit = function($textarea){
44
  var parent = $textarea.parents('.wp-editor-wrap:eq(0)'),
45
+ $activeEditorBtn =$textarea.parents('.fw-option-type-wp-editor').data('editor-type') === 'tinymce' ? parent.find('.switch-tmce') : parent.find('.switch-html'),
46
  $btnTabs = parent.find('.wp-switch-editor').removeAttr("onclick"),
47
  id = $textarea.attr('id'),
48
  settings = {id: id , buttons: 'strong,em,link,block,del,ins,img,ul,ol,li,code,more,close'};
49
 
 
50
  var tmceCustomSettings = $textarea.parents('.fw-option-type-wp-editor').data('tinymce'),
51
  tmce_teeny = $textarea.parents('.fw-option-type-wp-editor').data('tmce-teeny'),
52
  tmce_extended = $textarea.parents('.fw-option-type-wp-editor').data('tmce-extended'),
framework/manifest.php CHANGED
@@ -4,4 +4,4 @@ $manifest = array();
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
- $manifest['version'] = '2.4.3';
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
+ $manifest['version'] = '2.4.4';
framework/static/css/fw.css CHANGED
@@ -3098,11 +3098,15 @@ body.rtl .fw-modal .media-frame-content > form .fw-options-tabs-contents .fw-opt
3098
  font-style: italic;
3099
  }
3100
 
3101
- .qtip.qtip-fw .qtip-content a {
3102
  color: #5fc5ee;
3103
  text-decoration: underline;
3104
  }
3105
 
 
 
 
 
3106
  .qtip.qtip-fw .qtip-content a:hover {
3107
  text-decoration: none;
3108
  }
3098
  font-style: italic;
3099
  }
3100
 
3101
+ .qtip-fw .qtip-content a {
3102
  color: #5fc5ee;
3103
  text-decoration: underline;
3104
  }
3105
 
3106
+ .qtip-fw .qtip-content a.button.button-primary {
3107
+ color: #ffffff;
3108
+ }
3109
+
3110
  .qtip.qtip-fw .qtip-content a:hover {
3111
  text-decoration: none;
3112
  }
framework/static/js/fw.js CHANGED
@@ -958,7 +958,7 @@ fw.getQueryString = function(name) {
958
  }
959
  });
960
  },
961
- resetValues: function() {
962
  var loadingId = fwLoadingId +':reset';
963
 
964
  fw.loading.show(loadingId);
@@ -985,14 +985,12 @@ fw.getQueryString = function(name) {
985
  return;
986
  }
987
 
988
- this.model.set('values', response.data.values);
989
-
990
- // make sure on the above open, the html 'change' will be fired
991
  this.model.set('html', '', {
992
- silent: true // right now we don't need modal reRender, only when the open above
993
  });
994
 
995
- this.model.open();
996
  }, this),
997
  error: function (xhr, status, error) {
998
  fw.loading.hide(loadingId);
@@ -1064,7 +1062,7 @@ fw.getQueryString = function(name) {
1064
  text: _fw_localized.l10n.reset,
1065
  priority: -1,
1066
  click: function () {
1067
- modal.content.resetValues();
1068
  }
1069
  }
1070
  ]
@@ -1073,24 +1071,24 @@ fw.getQueryString = function(name) {
1073
  });
1074
  },
1075
  /**
1076
- * @param {Object} options used for fw()->backend->render_options(json_decode(options, true))
1077
  */
1078
- open: function() {
1079
  fw.Modal.prototype.open.call(this);
1080
 
1081
- this.updateHtml();
1082
 
1083
  return this;
1084
  },
1085
- getHtmlCacheId: function() {
1086
  return fw.md5(
1087
  JSON.stringify(this.get('options')) +
1088
  '~' +
1089
- JSON.stringify(this.get('values'))
1090
  );
1091
  },
1092
- updateHtml: function() {
1093
- var cacheId = this.getHtmlCacheId();
1094
 
1095
  if (typeof htmlCache[cacheId] != 'undefined') {
1096
  this.set('html', htmlCache[cacheId]);
@@ -1109,7 +1107,7 @@ fw.getQueryString = function(name) {
1109
  data: {
1110
  action: 'fw_backend_options_render',
1111
  options: JSON.stringify(this.get('options')),
1112
- values: this.get('values'),
1113
  data: {
1114
  name_prefix: 'fw_edit_options_modal',
1115
  id_prefix: 'fw-edit-options-modal-'
958
  }
959
  });
960
  },
961
+ resetForm: function() {
962
  var loadingId = fwLoadingId +':reset';
963
 
964
  fw.loading.show(loadingId);
985
  return;
986
  }
987
 
988
+ // make sure on the below open, the html 'change' will be fired
 
 
989
  this.model.set('html', '', {
990
+ silent: true // right now we don't need modal reRender, only when the open below
991
  });
992
 
993
+ this.model.open(response.data.values);
994
  }, this),
995
  error: function (xhr, status, error) {
996
  fw.loading.hide(loadingId);
1062
  text: _fw_localized.l10n.reset,
1063
  priority: -1,
1064
  click: function () {
1065
+ modal.content.resetForm();
1066
  }
1067
  }
1068
  ]
1071
  });
1072
  },
1073
  /**
1074
+ * @param {Object} [values] Offer custom values for display. The user can reject them by closing the modal
1075
  */
1076
+ open: function(values) {
1077
  fw.Modal.prototype.open.call(this);
1078
 
1079
+ this.updateHtml(values);
1080
 
1081
  return this;
1082
  },
1083
+ getHtmlCacheId: function(values) {
1084
  return fw.md5(
1085
  JSON.stringify(this.get('options')) +
1086
  '~' +
1087
+ JSON.stringify(typeof values == 'undefined' ? this.get('values') : values)
1088
  );
1089
  },
1090
+ updateHtml: function(values) {
1091
+ var cacheId = this.getHtmlCacheId(values);
1092
 
1093
  if (typeof htmlCache[cacheId] != 'undefined') {
1094
  this.set('html', htmlCache[cacheId]);
1107
  data: {
1108
  action: 'fw_backend_options_render',
1109
  options: JSON.stringify(this.get('options')),
1110
+ values: typeof values == 'undefined' ? this.get('values') : values,
1111
  data: {
1112
  name_prefix: 'fw_edit_options_modal',
1113
  id_prefix: 'fw-edit-options-modal-'
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.3
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -82,6 +82,11 @@ Yes; Unyson will work with any theme.
82
 
83
  == Changelog ==
84
 
 
 
 
 
 
85
  = 2.4.3 =
86
  * [An attempt](https://github.com/ThemeFuse/Unyson/commit/9985875d56520caae4ce72c7111aea1e326777a5) to fix [#263](https://github.com/ThemeFuse/Unyson/issues/263)
87
 
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
 
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
88
+ * Minor refactor in code that is responsible for auto-save post options save
89
+
90
  = 2.4.3 =
91
  * [An attempt](https://github.com/ThemeFuse/Unyson/commit/9985875d56520caae4ce72c7111aea1e326777a5) to fix [#263](https://github.com/ThemeFuse/Unyson/issues/263)
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.4.3
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.4.4
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+