Unyson - Version 2.1.21

Version Description

  • Made forms and mailer extensions hidden.
Download this release

Release Info

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

Code changes from version 2.1.20 to 2.1.21

framework/core/components/backend.php CHANGED
@@ -329,6 +329,7 @@ final class _FW_Component_Backend
329
  wp_register_script(
330
  'fw-uri',
331
  fw_get_framework_directory_uri('/static/libs/uri/URI.js'),
 
332
  fw()->manifest->get_version(),
333
  true
334
  );
@@ -338,6 +339,17 @@ final class _FW_Component_Backend
338
  wp_register_script(
339
  'fw-moment',
340
  fw_get_framework_directory_uri('/static/libs/moment/moment.min.js'),
 
 
 
 
 
 
 
 
 
 
 
341
  fw()->manifest->get_version(),
342
  true
343
  );
@@ -801,12 +813,6 @@ final class _FW_Component_Backend
801
 
802
  public function _settings_form_render($data)
803
  {
804
- /**
805
- * wp moves flash message error with js after first h2
806
- * if there are no h2 on the page it shows them wrong
807
- */
808
- echo '<h2 class="fw-hidden"></h2>';
809
-
810
  $options = fw()->theme->get_settings_options();
811
 
812
  if (empty($options)) {
@@ -821,7 +827,14 @@ final class _FW_Component_Backend
821
  $values = fw_get_db_settings_option();
822
  }
823
 
824
- echo fw()->backend->render_options($options, $values);
 
 
 
 
 
 
 
825
 
826
  $data['submit']['html'] =
827
  fw_html_tag('input', array(
@@ -836,52 +849,8 @@ final class _FW_Component_Backend
836
  'name' => '_fw_reset_options',
837
  'value' => __('Reset', 'fw'),
838
  'class' => 'button-secondary button-large',
839
- 'onclick' => "if (!confirm('". esc_js(
840
- __("Click OK to reset.\nAll settings will be lost and replaced with default settings!", 'fw')
841
- ) ."')) return false;"
842
- ));
843
-
844
- {
845
- $focus_tab_input_name = '_focus_tab';
846
- $focus_tab_id = trim( FW_Request::POST($focus_tab_input_name, FW_Request::GET($focus_tab_input_name, '')) );
847
-
848
- echo fw_html_tag('input', array(
849
- 'type' => 'hidden',
850
- 'name' => $focus_tab_input_name,
851
- 'value' => $focus_tab_id,
852
  ));
853
 
854
- echo
855
- '<script type="text/javascript">' .
856
- 'jQuery(function($){' .
857
- ' fwEvents.one("fw:options:init", function(){' .
858
- ' var $form = $("form.fw_form_fw_settings:first");'.
859
- ' var inputName = "'. esc_js($focus_tab_input_name) .'";'.
860
- ' $form.on("click", ".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a", function(){'.
861
- ' var tabId = $(this).attr("href").replace(/^\\#/, "");'.
862
- ' $form.find("input[name=\'"+ inputName +"\']").val(tabId);'.
863
- ' });'.
864
- ' '.
865
- ' /* "wait" after tabs initialized */' .
866
- ' setTimeout(function(){' .
867
- ' var focusTabId = $.trim("'. esc_js($focus_tab_id) .'");'.
868
- ' if (!focusTabId.length) return;'.
869
- ' var $tabLink = $(".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a[href=\'#"+ focusTabId +"\']");'.
870
- ' while ($tabLink.length) {'.
871
- ' $tabLink.trigger("click");'.
872
- ' $tabLink = $tabLink'.
873
- ' .closest(".fw-options-tabs-wrapper").parent().closest(".fw-options-tabs-wrapper")'.
874
- ' .find("> .fw-options-tabs-list > ul > li > a[href=\'#"+ $tabLink.closest(".fw-options-tab").attr("id") +"\']");'.
875
- ' }'.
876
- ' '.
877
- ' /* click again on focus tab to update the input value */'.
878
- ' $(".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a[href=\'#"+ focusTabId +"\']").trigger("click");;'.
879
- ' }, 200);' .
880
- ' });' .
881
- '});' .
882
- '</script>';
883
- }
884
-
885
  return $data;
886
  }
887
 
329
  wp_register_script(
330
  'fw-uri',
331
  fw_get_framework_directory_uri('/static/libs/uri/URI.js'),
332
+ array(),
333
  fw()->manifest->get_version(),
334
  true
335
  );
339
  wp_register_script(
340
  'fw-moment',
341
  fw_get_framework_directory_uri('/static/libs/moment/moment.min.js'),
342
+ array(),
343
+ fw()->manifest->get_version(),
344
+ true
345
+ );
346
+ }
347
+
348
+ {
349
+ wp_register_script(
350
+ 'fw-form-helpers',
351
+ fw_get_framework_directory_uri('/static/js/fw-form-helpers.js'),
352
+ array('jquery'),
353
  fw()->manifest->get_version(),
354
  true
355
  );
813
 
814
  public function _settings_form_render($data)
815
  {
 
 
 
 
 
 
816
  $options = fw()->theme->get_settings_options();
817
 
818
  if (empty($options)) {
827
  $values = fw_get_db_settings_option();
828
  }
829
 
830
+ wp_enqueue_script('fw-form-helpers');
831
+
832
+ fw_render_view(fw_get_framework_directory('/views/backend-settings-form.php'), array(
833
+ 'options' => $options,
834
+ 'values' => $values,
835
+ 'focus_tab_input_name' => '_focus_tab',
836
+ 'reset_input_name' => '_fw_reset_options'
837
+ ), false);
838
 
839
  $data['submit']['html'] =
840
  fw_html_tag('input', array(
849
  'name' => '_fw_reset_options',
850
  'value' => __('Reset', 'fw'),
851
  'class' => 'button-secondary button-large',
 
 
 
 
 
 
 
 
 
 
 
 
 
852
  ));
853
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
854
  return $data;
855
  }
856
 
framework/core/components/extensions/manager/available-extensions.php CHANGED
@@ -211,7 +211,7 @@ $extensions = array(
211
  ),
212
  ),
213
  'forms' => array(
214
- 'display' => true,
215
  'parent' => null,
216
  'name' => __( 'Forms', 'fw' ),
217
  'description' => __( 'This extension adds the possibility to create a contact form. Use the drag & drop form builder to create any contact form you\'ll ever want or need.', 'fw' ),
@@ -223,7 +223,7 @@ $extensions = array(
223
  ),
224
  ),
225
  'mailer' => array(
226
- 'display' => true,
227
  'parent' => null,
228
  'name' => __( 'Mailer', 'fw' ),
229
  'description' => __( 'This extension will let you set some global email options and it is used by other extensions (like Forms) to send emails.', 'fw' ),
211
  ),
212
  ),
213
  'forms' => array(
214
+ 'display' => false,
215
  'parent' => null,
216
  'name' => __( 'Forms', 'fw' ),
217
  'description' => __( 'This extension adds the possibility to create a contact form. Use the drag & drop form builder to create any contact form you\'ll ever want or need.', 'fw' ),
223
  ),
224
  ),
225
  'mailer' => array(
226
+ 'display' => false,
227
  'parent' => null,
228
  'name' => __( 'Mailer', 'fw' ),
229
  'description' => __( 'This extension will let you set some global email options and it is used by other extensions (like Forms) to send emails.', 'fw' ),
framework/manifest.php CHANGED
@@ -4,4 +4,4 @@ $manifest = array();
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
- $manifest['version'] = '2.1.20';
4
 
5
  $manifest['name'] = __('Unyson', 'fw');
6
 
7
+ $manifest['version'] = '2.1.21';
framework/static/js/fw-form-helpers.js ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * FW_Form helpers
3
+ * Dependencies: jQuery
4
+ * Note: You can include this script in frontend (for e.g. to make you contact forms ajax submittable)
5
+ */
6
+
7
+ var fwForm = {
8
+ /**
9
+ * @type {Boolean}
10
+ */
11
+ isAdminPage: function() {
12
+ return typeof ajaxurl != 'undefined'
13
+ && typeof adminpage != 'undefined'
14
+ && typeof pagenow != 'undefined'
15
+ && jQuery(document.body).hasClass('wp-admin');
16
+ },
17
+ /**
18
+ * Make forms ajax submittable
19
+ * @param {Object} [opts]
20
+ */
21
+ initAjaxSubmit: function(opts) {
22
+ var $ = jQuery,
23
+ opts = $.extend({
24
+ selector: 'form[data-fw-form-id]',
25
+ ajaxUrl: '/wp-admin/admin-ajax.php',
26
+ loading: function (show, $form) {
27
+ $form.css('position', 'relative');
28
+ $form.find('> .fw-form-loading').remove();
29
+
30
+ if (show) {
31
+ $form.append(
32
+ '<div'+
33
+ ' class="fw-form-loading"'+
34
+ ' style="position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(255,255,255,0.5);"'+
35
+ '></div>'
36
+ );
37
+ }
38
+ },
39
+ showErrors: function ($form, errors) {
40
+ // Frontend
41
+ $.each(errors, function(inputName, message) {
42
+ var $input = $form.find('[name="'+ inputName +'"]').last();
43
+ message = '<p class="form-error" style="color: #9b4c4c;">{message}</p>'.replace('{message}', message);
44
+
45
+ if ($input.length) {
46
+ // error message under input
47
+ $input.parent().after(message);
48
+ } else {
49
+ // if input not found, show message in form
50
+ $form.prepend(message);
51
+ }
52
+ });
53
+ },
54
+ hideErrors: function ($form) {
55
+ $form.find('.form-error').remove();
56
+ },
57
+ onAjaxError: function(jqXHR, textStatus, errorThrown) {
58
+ console.error(jqXHR, textStatus, errorThrown);
59
+ },
60
+ onSuccess: function ($form, ajaxData) {
61
+ if (fwForm.isAdminPage()) {
62
+ var html = [],
63
+ typeHtml = [],
64
+ messageClass = '';
65
+
66
+ $.each(ajaxData.flash_messages, function(type, messages){
67
+ typeHtml = [];
68
+
69
+ switch (type) {
70
+ case 'error':
71
+ messageClass = 'error';
72
+ break;
73
+ case 'warning':
74
+ messageClass = 'update-nag';
75
+ break;
76
+ default:
77
+ messageClass = 'updated';
78
+ }
79
+
80
+ $.each(messages, function(messageId, messageData){
81
+ typeHtml.push('<p>'+ messageData.message +'</p>');
82
+ });
83
+
84
+ if (typeHtml.length) {
85
+ html.push(
86
+ '<div class="fw-flash-messages '+ messageClass +'">'+ typeHtml.join('</div><div class="fw-flash-messages '+ messageClass +'">') +'</div>'
87
+ );
88
+ }
89
+
90
+ var $pageTitle = jQuery('.wrap h2:first');
91
+
92
+ while ($pageTitle.next().is('.fw-flash-message, .fw-flash-messages, .updated, .update-nag, .error')) {
93
+ $pageTitle.next().remove();
94
+ }
95
+
96
+ var scrollTop = jQuery(document.body).scrollTop();
97
+
98
+ $pageTitle.after(
99
+ '<div class="fw-flash-messages">'+
100
+ html.join('') +
101
+ (scrollTop > 300
102
+ ? '<p><a href="#" onclick="jQuery(document.body).animate({scrollTop: '+ scrollTop +'}, 300); jQuery(this).parent().remove();">Go back</a></p>'
103
+ : ''
104
+ )+
105
+ '</div>');
106
+
107
+ jQuery(document.body).animate({scrollTop: 0}, 300);
108
+ });
109
+ } else {
110
+ var html = [],
111
+ typeHtml = [];
112
+
113
+ $.each(ajaxData.flash_messages, function(type, messages){
114
+ typeHtml = [];
115
+
116
+ $.each(messages, function(messageId, messageData){
117
+ typeHtml.push(messageData.message);
118
+ });
119
+
120
+ if (typeHtml.length) {
121
+ html.push(
122
+ '<ul class="flash-messages-'+ type +'">'+
123
+ ' <li>'+ typeHtml.join('</li><li>') +'</li>'+
124
+ '</ul>'
125
+ );
126
+ }
127
+ });
128
+
129
+ if (html.length) {
130
+ html = html.join('');
131
+ } else {
132
+ html = '<p>Success</p>';
133
+ }
134
+
135
+ $form.fadeOut(function(){
136
+ $form.html(html).fadeIn();
137
+ });
138
+
139
+ // prevent multiple submit
140
+ $form.on('submit', function(e){ e.preventDefault(); e.stopPropagation(); });
141
+ }
142
+ }
143
+ }, opts || {}),
144
+ isBusy = false;
145
+
146
+ $(document.body).on('submit', opts.selector, function(e){
147
+ e.preventDefault();
148
+
149
+ if (isBusy) {
150
+ console.warn('Working... Try again later.')
151
+ return;
152
+ }
153
+
154
+ var $form = $(this),
155
+ $submitButton = $form.find('input[type="submit"][name]:focus');
156
+
157
+ if (!$submitButton.length) {
158
+ // in case you use this solution http://stackoverflow.com/a/5721762
159
+ $submitButton = $form.find('input[type="submit"][name][clicked]');
160
+ }
161
+
162
+ if (!$form.is('form[data-fw-form-id]')) {
163
+ console.error('This is not a FW_Form');
164
+ return;
165
+ }
166
+
167
+ opts.hideErrors($form);
168
+ opts.loading(true, $form);
169
+ isBusy = true;
170
+
171
+ jQuery.ajax({
172
+ type: "POST",
173
+ url: opts.ajaxUrl,
174
+ data: $form.serialize() + ($submitButton.length ? '&'+ $submitButton.attr('name') +'='+ $submitButton.attr('value') : ''),
175
+ dataType: 'json'
176
+ }).done(function(r){
177
+ isBusy = false;
178
+ opts.loading(false, $form);
179
+
180
+ if (r.success) {
181
+ opts.onSuccess($form, r.data);
182
+ } else {
183
+ opts.showErrors($form, r.data.errors);
184
+ }
185
+ }).fail(function(jqXHR, textStatus, errorThrown){
186
+ isBusy = false;
187
+ opts.loading(false, $form);
188
+ opts.onAjaxError(jqXHR, textStatus, errorThrown);
189
+ });
190
+ });
191
+ }
192
+ };
193
+
194
+ // Usage example
195
+ if (false) {
196
+ jQuery(function ($) {
197
+ fwForm.initAjaxSubmit({
198
+ selector: 'form[data-fw-form-id][data-fw-ext-forms-type="contact-forms"]',
199
+ ajaxUrl: ajaxurl || '/wp-admin/admin-ajax.php'
200
+ });
201
+ });
202
+ }
framework/views/backend-settings-form.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php if (!defined('FW')) die('Forbidden');
2
+ /**
3
+ * @var array $options
4
+ * @var array $values
5
+ * @var string $focus_tab_input_name
6
+ * @var string $reset_input_name
7
+ */
8
+ ?>
9
+ <!--
10
+ wp moves flash message error with js after first h2
11
+ if there are no h2 on the page it shows them wrong
12
+ -->
13
+ <h2 class="fw-hidden"></h2>
14
+
15
+ <?php echo fw()->backend->render_options($options, $values); ?>
16
+
17
+ <!-- focus tab -->
18
+ <?php
19
+ $focus_tab_id = trim( FW_Request::POST($focus_tab_input_name, FW_Request::GET($focus_tab_input_name, '')) );
20
+ echo fw_html_tag('input', array(
21
+ 'type' => 'hidden',
22
+ 'name' => $focus_tab_input_name,
23
+ 'value' => $focus_tab_id,
24
+ ));
25
+ ?>
26
+ <script type="text/javascript">
27
+ jQuery(function($){
28
+ fwEvents.one("fw:options:init", function(){
29
+ var $form = $('form[data-fw-form-id="fw_settings"]:first');
30
+
31
+ $form.on("click", ".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a", function(){
32
+ $form.find("input[name='<?php echo esc_js($focus_tab_input_name); ?>']").val(
33
+ $(this).attr("href").replace(/^\\#/, "") // tab id
34
+ );
35
+ });
36
+
37
+ /* "wait" after tabs initialized */
38
+ setTimeout(function(){
39
+ var focusTabId = $.trim("<?php echo esc_js($focus_tab_id) ?>");
40
+
41
+ if (!focusTabId.length) {
42
+ return;
43
+ }
44
+
45
+ var $tabLink = $(".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a[href=\'#"+ focusTabId +"\']");
46
+
47
+ while ($tabLink.length) {
48
+ $tabLink.trigger("click");
49
+ $tabLink = $tabLink
50
+ .closest(".fw-options-tabs-wrapper").parent().closest(".fw-options-tabs-wrapper")
51
+ .find("> .fw-options-tabs-list > ul > li > a[href=\'#"+ $tabLink.closest(".fw-options-tab").attr("id") +"\']");
52
+ }
53
+
54
+ // click again on focus tab to update the input value
55
+ $(".fw-options-tabs-wrapper > .fw-options-tabs-list > ul > li > a[href=\'#"+ focusTabId +"\']").trigger("click");;
56
+ }, 200);
57
+ });
58
+ });
59
+ </script>
60
+ <!-- end: focus tab -->
61
+
62
+ <!-- reset warning -->
63
+ <script type="text/javascript">
64
+ jQuery(function($){
65
+ $('form[data-fw-form-id="fw_settings"] input[name="<?php echo esc_js($reset_input_name) ?>"]').on('click.fw-reset-warning', function(e){
66
+ /**
67
+ * on confirm() the submit input looses focus
68
+ * fwForm.isAdminPage() must be able to select the input to send it in _POST
69
+ * so use alternative solution http://stackoverflow.com/a/5721762
70
+ */
71
+ {
72
+ $(this).closest('form').find('input[type="submit"]').removeAttr('clicked');
73
+ $(this).attr('clicked', '');
74
+ }
75
+
76
+ if (!confirm('<?php
77
+ echo esc_js(__("Click OK to reset.\nAll settings will be lost and replaced with default settings!", 'fw'))
78
+ ?>')) {
79
+ e.preventDefault();
80
+ }
81
+ });
82
+ });
83
+ </script>
84
+ <!-- end: reset warning -->
85
+
86
+ <!-- ajax submit -->
87
+ <!--
88
+ <script type="text/javascript">
89
+ jQuery(function ($) {
90
+ fwForm.initAjaxSubmit({
91
+ selector: 'form[data-fw-form-id="fw_settings"]',
92
+ ajaxUrl: ajaxurl
93
+ });
94
+ });
95
+ </script>
96
+ -->
97
+ <!-- end: ajax submit -->
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === Unyson ===
2
  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.1
6
- Stable tag: 2.1.20
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -86,6 +86,9 @@ Yes; Unyson will work with any theme.
86
 
87
  == Changelog ==
88
 
 
 
 
89
  = 2.1.20 =
90
  * Added warning on Theme Settings reset [^](http://static.md/0fcf01628eddab75fdbedb3a24784db3.png)
91
  * `FW_Form`: Form attributes can be changed in the render method
1
  === Unyson ===
2
  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.1
6
+ Stable tag: 2.1.21
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
86
 
87
  == Changelog ==
88
 
89
+ = 2.1.21 =
90
+ * Made `forms` and `mailer` extensions hidden.
91
+
92
  = 2.1.20 =
93
  * Added warning on Theme Settings reset [^](http://static.md/0fcf01628eddab75fdbedb3a24784db3.png)
94
  * `FW_Form`: Form attributes can be changed in the render method
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.20
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.21
7
  * Author: ThemeFuse
8
  * Author URI: http://themefuse.com
9
  * License: GPL2+