YITH WooCommerce Ajax Product Filter - Version 2.9.0

Version Description

  • Released: May 02, 2016 =

  • Fixed: Filtering issue with YITH WooCommerce Brands Add-on Premium

  • Fixed: HTML5 Validation (attribute name not allowed in ul element)

  • Fixed: z-index not set to -1 when user close dropdown filters with click in page area

Download this release

Release Info

Developer yithemes
Plugin Icon 128x128 YITH WooCommerce Ajax Product Filter
Version 2.9.0
Comparing to
See all releases

Code changes from version 2.8.1 to 2.9.0

Files changed (76) hide show
  1. README.txt +10 -3
  2. assets/css/admin.css +6 -0
  3. assets/css/frontend.css +50 -2
  4. assets/js/yith-wcan-admin.js +14 -7
  5. assets/js/yith-wcan-editor.js +7 -7
  6. assets/js/yith-wcan-frontend.js +25 -6
  7. assets/js/yith-wcan-frontend.min.js +15 -15
  8. includes/class.yith-wcan-frontend.php +7 -6
  9. includes/functions.yith-wcan.php +89 -22
  10. init.php +2 -2
  11. plugin-fw/assets/css/colorbox.css +66 -0
  12. plugin-fw/assets/css/metaboxes.css +663 -663
  13. plugin-fw/assets/css/yit-plugin-panel-sidebar.css +377 -0
  14. plugin-fw/assets/css/yit-plugin-panel.css +713 -664
  15. plugin-fw/assets/css/yit-upgrade-to-pro.css +77 -0
  16. plugin-fw/assets/css/yit-upgrader.css +13 -13
  17. plugin-fw/assets/images/colorbox/border1.png +0 -0
  18. plugin-fw/assets/images/colorbox/border2.png +0 -0
  19. plugin-fw/assets/images/colorbox/loading.gif +0 -0
  20. plugin-fw/assets/images/upgrade-page/01.jpg +0 -0
  21. plugin-fw/assets/images/upgrade-page/02.jpg +0 -0
  22. plugin-fw/assets/images/upgrade-page/03.jpg +0 -0
  23. plugin-fw/assets/images/upgrade-page/04.jpg +0 -0
  24. plugin-fw/assets/images/upgrade-page/05.jpg +0 -0
  25. plugin-fw/assets/images/upgrade-page/06.jpg +0 -0
  26. plugin-fw/assets/images/upgrade-page/07.jpg +0 -0
  27. plugin-fw/assets/images/upgrade-page/08.jpg +0 -0
  28. plugin-fw/assets/images/upgrade-page/09.jpg +0 -0
  29. plugin-fw/assets/images/widgets/box-icon.png +0 -0
  30. plugin-fw/assets/images/widgets/box-white-icon.png +0 -0
  31. plugin-fw/assets/images/widgets/despacho.png +0 -0
  32. plugin-fw/assets/images/widgets/info-icon.png +0 -0
  33. plugin-fw/assets/images/widgets/link-bg.png +0 -0
  34. plugin-fw/assets/images/widgets/link-bg2.png +0 -0
  35. plugin-fw/assets/images/widgets/link-icon.png +0 -0
  36. plugin-fw/assets/images/widgets/membership-bg.png +0 -0
  37. plugin-fw/assets/js/jquery.colorbox.js +1105 -0
  38. plugin-fw/assets/js/metabox.js +354 -354
  39. plugin-fw/assets/js/multisite-updater.js +216 -216
  40. plugin-fw/assets/js/multisite-updater.min.js +3 -3
  41. plugin-fw/assets/js/yit-cpt-unlimited.js +78 -78
  42. plugin-fw/assets/js/yit-cptu-sortable-posts.js +31 -31
  43. plugin-fw/assets/js/yit-plugin-panel-sidebar.js +56 -0
  44. plugin-fw/assets/js/yit-plugin-panel-sidebar.min.js +1 -0
  45. plugin-fw/assets/js/yit-plugin-panel.js +328 -328
  46. plugin-fw/assets/js/yit-wp-pointer.js +83 -83
  47. plugin-fw/assets/js/yit-wp-pointer.min.js +2 -2
  48. plugin-fw/init.php +56 -56
  49. plugin-fw/languages/yith-plugin-fw-it_IT.mo +0 -0
  50. plugin-fw/languages/yith-plugin-fw-it_IT.po +147 -17
  51. plugin-fw/lib/yit-ajax.php +76 -0
  52. plugin-fw/lib/yit-cpt-unlimited.php +1774 -1774
  53. plugin-fw/lib/yit-metabox.php +549 -549
  54. plugin-fw/lib/yit-plugin-common.php +1259 -1259
  55. plugin-fw/lib/yit-plugin-gradients.php +535 -535
  56. plugin-fw/lib/yit-plugin-panel-sidebar.php +427 -0
  57. plugin-fw/lib/yit-plugin-panel-wc.php +450 -427
  58. plugin-fw/lib/yit-plugin-panel.php +920 -830
  59. plugin-fw/lib/yit-plugin-subpanel.php +164 -164
  60. plugin-fw/lib/yit-pointers.php +389 -389
  61. plugin-fw/lib/yit-upgrade.php +556 -556
  62. plugin-fw/lib/yit-video.php +199 -199
  63. plugin-fw/licence/assets/css/yit-licence.css +439 -439
  64. plugin-fw/licence/assets/js/yit-licence.js +195 -195
  65. plugin-fw/licence/assets/js/yit-licence.min.js +6 -6
  66. plugin-fw/licence/lib/yit-licence.php +708 -708
  67. plugin-fw/licence/lib/yit-plugin-licence.php +160 -160
  68. plugin-fw/licence/lib/yit-theme-licence.php +190 -190
  69. plugin-fw/licence/templates/panel/activation/activation-panel.php +237 -237
  70. plugin-fw/templates/metaboxes/tab.php +72 -72
  71. plugin-fw/templates/metaboxes/types/ajax-products.php +62 -62
  72. plugin-fw/templates/metaboxes/types/categories.php +87 -87
  73. plugin-fw/templates/metaboxes/types/checkbox.php +22 -22
  74. plugin-fw/templates/metaboxes/types/chosen.php +31 -31
  75. plugin-fw/templates/metaboxes/types/colorpicker.php +21 -21
  76. plugin-fw/templates/metaboxes/types/contactform.php +508 -557
README.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: yithemes
4
  Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
5
  Requires at least: 4.0
6
  Tested up to: 4.5.1
7
- Stable tag: 2.8.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -159,7 +159,14 @@ If you want to see a demonstration version of the premium plugin, you can see it
159
 
160
  == Changelog ==
161
 
162
- = 2.8.1 =
 
 
 
 
 
 
 
163
 
164
  * Fixed: Dropdown issue with Remy Theme
165
  * Fixed: $.fn.slider is not a function after click on reset filter
@@ -408,4 +415,4 @@ New plugin core added.
408
 
409
  = 1.0.0 =
410
 
411
- Initial release
4
  Tags: woocommerce ajax product filter download, woocommerce, widget, ajax, ajax filtered nav, ajax navigation, ajax filtered navigation, woocommerce layered navigation, woocommerce layered nav, product filter, product filters, ajax product filter, woocommerce ajax product filter, woocommerce filters, sidebar filter, sidebar ajax filter, ajax price filter, price filter, product sorting, woocommerce filter, taxonomy filter, attribute filter, attributes filter, woocommerce product sort, ajax sort, woocommerce ajax product filter, advanced product filters, ajax product filters, filters, woocommerce ajax product filters, woocommerce product filters, woocommerce product filters, category filter, attribute filters, woocommerce products filter, woocommerce price filter, yit, yith, yithemes
5
  Requires at least: 4.0
6
  Tested up to: 4.5.1
7
+ Stable tag: 2.9.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
159
 
160
  == Changelog ==
161
 
162
+ = 2.9.0 - Released: May 02, 2016 =
163
+
164
+ * Fixed: Filtering issue with YITH WooCommerce Brands Add-on Premium
165
+ * Fixed: HTML5 Validation (attribute name not allowed in ul element)
166
+ * Fixed: z-index not set to -1 when user close dropdown filters with click in page area
167
+
168
+
169
+ = 2.8.1 - Released: Mar 10, 2016 =
170
 
171
  * Fixed: Dropdown issue with Remy Theme
172
  * Fixed: $.fn.slider is not a function after click on reset filter
415
 
416
  = 1.0.0 =
417
 
418
+ Initial release
assets/css/admin.css CHANGED
@@ -191,6 +191,7 @@ input#yit_wcan_options_yith_wcan_ajax_shop_result_container,
191
  input#yit_wcan_options_yith_wcan_ajax_widget_title_class,
192
  input#yit_wcan_options_yith_wcan_ajax_scroll_top_class,
193
  input#yit_wcan_options_yith_wcan_ajax_shop_pagination_anchor_class,
 
194
  input#yit_wcan_options_yith_wcan_ajax_widget_title_tag {
195
  width: 230px;
196
  }
@@ -228,3 +229,8 @@ div#yit_wcan_options_yith_wcan_seo_value-container .option .select_wrapper,
228
  .yit-plugins_page_yith_wcan_panel .yit_options input:not(.button):not(.number):not(#export-file):not(#delete-cache):not(#reset-theme-options):not(#delete-custom-sidebars):not(#delete-resized-images):not(#install-sampledata) {
229
  margin-bottom: 10px;
230
  }
 
 
 
 
 
191
  input#yit_wcan_options_yith_wcan_ajax_widget_title_class,
192
  input#yit_wcan_options_yith_wcan_ajax_scroll_top_class,
193
  input#yit_wcan_options_yith_wcan_ajax_shop_pagination_anchor_class,
194
+ input#yit_wcan_options_yith_wcan_enable_see_all_categories_link_text,
195
  input#yit_wcan_options_yith_wcan_ajax_widget_title_tag {
196
  width: 230px;
197
  }
229
  .yit-plugins_page_yith_wcan_panel .yit_options input:not(.button):not(.number):not(#export-file):not(#delete-cache):not(#reset-theme-options):not(#delete-custom-sidebars):not(#delete-resized-images):not(#install-sampledata) {
230
  margin-bottom: 10px;
231
  }
232
+
233
+ .yith-wcan-see-all-taxonomies-text-default,
234
+ .yith-wcan-see-all-taxonomies-text-description {
235
+ display: block;
236
+ }
assets/css/frontend.css CHANGED
@@ -168,14 +168,30 @@
168
  }
169
 
170
  /* Hierarchical Order */
171
- .widget.widget_layered_nav li.yit-wcan-child-terms {
172
  padding-left: 30px;
173
  }
174
 
175
- .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li.yit-wcan-child-terms {
 
 
 
 
 
 
 
 
176
  padding-left: 30px;
177
  }
178
 
 
 
 
 
 
 
 
 
179
  /* widget dropdown */
180
  .widget h1.with-dropdown,
181
  .widget h2.with-dropdown,
@@ -287,6 +303,9 @@ a.yith-wcan-price-link.active:before {
287
  list-style-type: none;
288
  padding-left: 0;
289
  }
 
 
 
290
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a:before{
291
  content: '';
292
  display: inline-block;
@@ -297,6 +316,11 @@ a.yith-wcan-price-link.active:before {
297
  height: 11px;
298
  margin-right: 5px;
299
  }
 
 
 
 
 
300
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.active:before,
301
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.chosen:before,
302
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li.active a:before,
@@ -315,4 +339,28 @@ a.yith-wcan-price-link.active:before {
315
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li.chosen a:after{
316
  content: '';
317
  display: none;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
318
  }
168
  }
169
 
170
  /* Hierarchical Order */
171
+ .widget.widget_layered_nav li.yit-wcan-child-terms.level-1 {
172
  padding-left: 30px;
173
  }
174
 
175
+ .widget.widget_layered_nav li.yit-wcan-child-terms.level-2 {
176
+ padding-left: 60px;
177
+ }
178
+
179
+ .widget.widget_layered_nav li.yit-wcan-child-terms.level-3 {
180
+ padding-left: 90px;
181
+ }
182
+
183
+ .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li.yit-wcan-child-terms.level-1 {
184
  padding-left: 30px;
185
  }
186
 
187
+ .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li.yit-wcan-child-terms.level-2 {
188
+ padding-left: 60px;
189
+ }
190
+
191
+ .yith-wcan-select-wrapper ul.yith-wcan-select.yith-wcan li.yit-wcan-child-terms.level-2 {
192
+ padding-left: 90px;
193
+ }
194
+
195
  /* widget dropdown */
196
  .widget h1.with-dropdown,
197
  .widget h2.with-dropdown,
303
  list-style-type: none;
304
  padding-left: 0;
305
  }
306
+ .yith-woocommerce-ajax-product-filter.yith-wcan-sort-by.with-checkbox ul{
307
+ margin-left: 0;
308
+ }
309
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a:before{
310
  content: '';
311
  display: inline-block;
316
  height: 11px;
317
  margin-right: 5px;
318
  }
319
+
320
+ .yith-woocommerce-ajax-product-filter.yith-wcan-sort-by.with-checkbox ul li a:before{
321
+ background-image: url("../images/radio_sprite.png");
322
+ }
323
+
324
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.active:before,
325
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li a.chosen:before,
326
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li.active a:before,
339
  .yith-woocommerce-ajax-product-filter.with-checkbox ul li.chosen a:after{
340
  content: '';
341
  display: none;
342
+ }
343
+
344
+ /*-------------------------------
345
+ SEE ALL CATEGORIES AND TAGS
346
+ --------------------------------*/
347
+
348
+ .widget .yith-wcan-show-all-categories,
349
+ .widget .yith-wcan-show-all-tags {
350
+ margin-bottom: 15px;
351
+ display: inline-block;
352
+ }
353
+
354
+ .widget .yith-wcan-show-all-categories a,
355
+ .widget .yith-wcan-show-all-tags a{
356
+ font-size: 10px;
357
+ text-transform: uppercase;
358
+ }
359
+
360
+ .widget .yith-wcan-show-all-categories a:before,
361
+ .widget .yith-wcan-show-all-tags a:before{
362
+ content: "<";
363
+ margin-right: 5px;
364
+ font-weight: bold;
365
+ font-size: 12px;
366
  }
assets/js/yith-wcan-admin.js CHANGED
@@ -26,13 +26,14 @@ jQuery(function ($) {
26
 
27
  $(document).on('change', '.yith_wcan_type, .yith_wcan_attributes', function (e) {
28
  var t = this,
29
- container = $(this).parents('.widget-content').find('.yith_wcan_placeholder').html(''),
30
- spinner = container.next('.spinner').show(),
31
- display = $(this).parents('.widget-content').find('#yit-wcan-display'),
32
- style = $(this).parents('.widget-content').find('#yit-wcan-style'),
33
- show_count = $(this).parents('.widget-content').find('#yit-wcan-show-count'),
34
- attributes = $(this).parents('.widget-content').find('.yith-wcan-attribute-list'),
35
- tag_list = $(this).parents('.widget-content').find('.yit-wcan-widget-tag-list');
 
36
 
37
  var data = {
38
  action : 'yith_wcan_select_type',
@@ -74,6 +75,12 @@ jQuery(function ($) {
74
  tag_list.hide();
75
  }
76
 
 
 
 
 
 
 
77
  $.post(ajaxurl, data, function (response) {
78
  spinner.hide();
79
  container.html(response.content);
26
 
27
  $(document).on('change', '.yith_wcan_type, .yith_wcan_attributes', function (e) {
28
  var t = this,
29
+ container = $(this).parents('.widget-content').find('.yith_wcan_placeholder').html(''),
30
+ spinner = container.next('.spinner').show(),
31
+ display = $(this).parents('.widget-content').find('#yit-wcan-display'),
32
+ style = $(this).parents('.widget-content').find('#yit-wcan-style'),
33
+ show_count = $(this).parents('.widget-content').find('#yit-wcan-show-count'),
34
+ attributes = $(this).parents('.widget-content').find('.yith-wcan-attribute-list'),
35
+ tag_list = $(this).parents('.widget-content').find('.yit-wcan-widget-tag-list'),
36
+ see_all_text = $(this).parents('.widget-content').find('.yit-wcan-see-all-taxonomies-text');
37
 
38
  var data = {
39
  action : 'yith_wcan_select_type',
75
  tag_list.hide();
76
  }
77
 
78
+ if( data.value == 'tags' || data.value == 'categories' ){
79
+ see_all_text.show();
80
+ } else {
81
+ see_all_text.hide();
82
+ }
83
+
84
  $.post(ajaxurl, data, function (response) {
85
  spinner.hide();
86
  container.html(response.content);
assets/js/yith-wcan-editor.js CHANGED
@@ -1,8 +1,8 @@
1
- var editor = CodeMirror.fromTextArea(document.getElementById("yit_wcan_options_yith_wcan_custom_style"), {
2
- lineNumbers: true,
3
- mode: "text/css",
4
- indentUnit: 4,
5
- tabSize: 4,
6
- indentWithTabs: true,
7
- showCursorWhenSelecting: true
8
  });
1
+ var editor = CodeMirror.fromTextArea(document.getElementById("yit_wcan_options_yith_wcan_custom_style"), {
2
+ lineNumbers: true,
3
+ mode: "text/css",
4
+ indentUnit: 4,
5
+ tabSize: 4,
6
+ indentWithTabs: true,
7
+ showCursorWhenSelecting: true
8
  });
assets/js/yith-wcan-frontend.js CHANGED
@@ -96,6 +96,17 @@ jQuery(function ($) {
96
 
97
  var ajax_call = false;
98
 
 
 
 
 
 
 
 
 
 
 
 
99
  $.fn.yith_wcan_ajax_filters = function (e, obj) {
100
  e.preventDefault();
101
  var href = obj.href,
@@ -134,7 +145,7 @@ jQuery(function ($) {
134
 
135
  t.parents('div.yith-woo-ajax-navigation').find('a.yit-wcan-select-open').removeClass('active');
136
 
137
- t.parent().find('div.yith-wcan-select-wrapper').animate({
138
 
139
  visibility: "hidden",
140
  opacity : 0
@@ -151,7 +162,7 @@ jQuery(function ($) {
151
  }
152
 
153
  if( yith_wcan.is_mobile == 1 ){
154
- $('body').scrollTop( $(yith_wcan.scroll_top).offset().top );
155
  }
156
 
157
  $(yith_wcan.pagination).hide();
@@ -165,6 +176,7 @@ jQuery(function ($) {
165
  ajax_call = $.ajax({
166
  url : href,
167
  success: function (response) {
 
168
  ajax_call = false;
169
  $(yith_wcan.container).not('.ywcps-products').removeClass('yith-wcan-loading');
170
 
@@ -218,7 +230,7 @@ jQuery(function ($) {
218
  });
219
 
220
  //update browser history (IE doesn't support it)
221
- if (!navigator.userAgent.match(/msie/i)) {
222
  window.history.pushState({"pageTitle": response.pageTitle}, "", href);
223
  }
224
 
@@ -235,13 +247,19 @@ jQuery(function ($) {
235
  }
236
  $(document).trigger("yith-wcan-ajax-reset-filtered");
237
  }
 
 
 
238
  }
239
  });
240
  };
241
 
242
  //wrap the container
243
  $(yith_wcan.container).not('.ywcps-products').wrap('<div class="yit-wcan-container"></div>');
244
- $(yith_wcan.container).not('.ywcps-products').wrap('<div class="yit-wcan-container"></div>');
 
 
 
245
 
246
  $(document).trigger( 'yith-wcan-wrapped' );
247
 
@@ -249,8 +267,9 @@ jQuery(function ($) {
249
  $(this).yith_wcan_ajax_filters(e, this);
250
  });
251
 
252
- /*AJAX NAVIGATION DROPDOWN STYLE*/
253
 
 
 
254
  function yit_open_select_dropdown(element) {
255
 
256
  $(element).parent().find('div.yith-wcan-select-wrapper').css("z-index", "1").animate({
@@ -278,7 +297,7 @@ jQuery(function ($) {
278
 
279
  var yit_hidden_filters_wrapper = function () {
280
 
281
- $('div.yith-wcan-select-wrapper').animate({
282
 
283
  visibility: "hidden",
284
  opacity : 0
96
 
97
  var ajax_call = false;
98
 
99
+ var see_all_taxonomies = function(){
100
+
101
+ var categories_link = $('#yith-wcan-reset-all-categories').find('a.yith-wcan-reset-categories-link');
102
+ var tags_link = $('#yith-wcan-reset-all-tags').find('a.yith-wcan-reset-tags-link');
103
+ categories_link.add(tags_link).on('click', function (e) {
104
+ $(this).yith_wcan_ajax_filters(e, this);
105
+ });
106
+ };
107
+
108
+
109
+
110
  $.fn.yith_wcan_ajax_filters = function (e, obj) {
111
  e.preventDefault();
112
  var href = obj.href,
145
 
146
  t.parents('div.yith-woo-ajax-navigation').find('a.yit-wcan-select-open').removeClass('active');
147
 
148
+ t.parent().find('div.yith-wcan-select-wrapper').css('z-index', '-1').animate({
149
 
150
  visibility: "hidden",
151
  opacity : 0
162
  }
163
 
164
  if( yith_wcan.is_mobile == 1 ){
165
+ $(window).scrollTop( $(yith_wcan.scroll_top).offset().top );
166
  }
167
 
168
  $(yith_wcan.pagination).hide();
176
  ajax_call = $.ajax({
177
  url : href,
178
  success: function (response) {
179
+
180
  ajax_call = false;
181
  $(yith_wcan.container).not('.ywcps-products').removeClass('yith-wcan-loading');
182
 
230
  });
231
 
232
  //update browser history (IE doesn't support it)
233
+ if (yith_wcan.change_browser_url == 1 && !navigator.userAgent.match(/msie/i)) {
234
  window.history.pushState({"pageTitle": response.pageTitle}, "", href);
235
  }
236
 
247
  }
248
  $(document).trigger("yith-wcan-ajax-reset-filtered");
249
  }
250
+
251
+ //See al categories in ajax
252
+ see_all_taxonomies()
253
  }
254
  });
255
  };
256
 
257
  //wrap the container
258
  $(yith_wcan.container).not('.ywcps-products').wrap('<div class="yit-wcan-container"></div>');
259
+
260
+ $(document).on( 'yith-wcan-wrapped', function(){
261
+ see_all_taxonomies();
262
+ });
263
 
264
  $(document).trigger( 'yith-wcan-wrapped' );
265
 
267
  $(this).yith_wcan_ajax_filters(e, this);
268
  });
269
 
 
270
 
271
+
272
+ /*AJAX NAVIGATION DROPDOWN STYLE*/
273
  function yit_open_select_dropdown(element) {
274
 
275
  $(element).parent().find('div.yith-wcan-select-wrapper').css("z-index", "1").animate({
297
 
298
  var yit_hidden_filters_wrapper = function () {
299
 
300
+ $('div.yith-wcan-select-wrapper').css("z-index", "-1").animate({
301
 
302
  visibility: "hidden",
303
  opacity : 0
assets/js/yith-wcan-frontend.min.js CHANGED
@@ -1,15 +1,15 @@
1
- jQuery(function(a){function u(a,p){return a.replace(new RegExp("[?&]"+p+"=[^&#]*(#.*)?$"),"$1").replace(new RegExp("([?&])"+p+"=[^&]*&"),"$1")}var x=/(?!(\[))(\.)[^.#[]*/g,y=/(#)[^.#[]*/,z=/^[\w]+/,A=/^[\w]+$/,v=function(h,p){var b=[];if(A.test(h))b=[{tag:h}];else{for(var b=h,d={sel:[],val:[]},f=[],k=!1,g="",l=[],c=0,m=b.length;c<m;c++){var e=b.charAt(c);if(k)if("\\"===e&&c+1<b.length)l.push(b.charAt(++c));else if(g===e)g="",l.push(e);else if(("'"===e||'"'===e)&&""===g)g=e,l.push(e);else if("]"===
2
- e&&""===g)d.val.push(l.join("")),l=[],k=!1;else{if("]"!==e||""!==g)""===g&&","===e?(d.val.push(l.join("")),l=[]):l.push(e)}else"\\"===e&&c+1<b.length?k&&l.push(b.charAt(++c)):"["===e&&""===g?k=!0:" "===e||"+"===e?(d.sel=d.sel.join(""),f.push(d),"+"===e&&f.push({sel:"+",val:""}),d={sel:[],val:[]}):" "!==e&&"]"!==e&&d.sel.push(e)}if(0!=d.sel.length||0!=d.val.length)d.sel=d.sel.join(""),f.push(d);for(c=0;c<f.length;c++){d=f[c].sel;if("+"===d)n.tag=d;else{var n=[];n.tag=z.exec(d);n.id=y.exec(d);n.id&&
3
- a.isArray(n.id)&&(n.id=n.id[0].substr(1));n.tag||(n.tag="div");n.vars=[];for(b=0;b<f[c].val.length;b++)g=f[c].val[b].indexOf("="),k=f[c].val[b].substr(0,g),g=f[c].val[b].substr(g+1),g=g.replace(/^[\s]*[\"\']*|[\"\']*[\s]*$/g,""),"text"===k?n.text=g:n.vars.push([k,g]);d=d.match(x);k=[];if(d){for(b=0;b<d.length;b++)k.push(d[b].substr(1));n.className=k.join(" ")}}f[c]=n}b=f}n=[];"undefined"===typeof p&&(p=1);d=[];f=[];k=[];g=document.createElement("div");for(c=l=0;c<b.length;c++){if("+"==b[c].tag)f=
4
- k.slice(),--l;else{for(m=0;m<p;m++)if("input"==b[c].tag){e=[];e.push("<"+b[c].tag);b[c].id&&e.push("id='"+b[c].id+"'");b[c].className&&(e.push("class='"+b[c].className),c+1===b.length&&e.push(lastClass),e.push("'"));if(b[c].vars)for(var q=0;q<b[c].vars.length;q++)e.push(b[c].vars[q][0]+"='"+b[c].vars[q][1]+"'");b[c].text&&e.push("value='"+b[c].text+"'");e.push("/>");k[m]=f[m];f[m]?(f[m].innerHTML+=e.join(" "),f[m]=f[m].lastChild):(g.innerHTML=e.join(" "),f[m]=g.removeChild(g.firstChild))}else{e=document.createElement(b[c].tag);
5
- if(b[c].vars)for(q=0;q<b[c].vars.length;q++)console.log(b[c].tag,b[c].vars[q]),e.setAttribute(b[c].vars[q][0],b[c].vars[q][1]);b[c].id&&(e.id=b[c].id);b[c].className&&(e.className=b[c].className);b[c].text&&e.appendChild(document.createTextNode(b[c].text));k[m]=f[m];f[m]=f[m]?f[m].appendChild(e):e}l++||Array.prototype.push.apply(d,f)}n=a.merge(n,f)}return a(d)},w=function(h,p,b){for(var d=h.match(/%[^%]*%/g)||[],f=[],k=0;k<p.length;k++){for(var g=h,l=0;l<d.length;l++)var c=d[l].substr(1,d[l].length-
6
- 2),g=g.replace(d[l],p[k][c]);f=a.merge(f,v(g,b))}return a(f)};a.jseldom=function(h){if(2==arguments.length&&a.isPlainObject(arguments[1]))return w.apply(this,[arguments[0],[arguments[1]]]);if(1==arguments.length||2==arguments.length&&!a.isArray(arguments[1]))return v.apply(this,arguments);if(2==arguments.length)return w.apply(this,arguments)};var r=!1;a.fn.yith_wcan_ajax_filters=function(h,p){h.preventDefault();var b=p.href,d=a(p),f=d.hasClass("yith-wcan-reset-navigation");if("undefined"==typeof b&&
7
- d.parents().hasClass("price_slider_wrapper")){d.parents("form");var k=window.location,g=k.origin+k.pathname,l=g!=k.href,c=a(".price_slider_amount #min_price").val(),m=a(".price_slider_amount #max_price").val(),b=k.href;1==l&&(b=u(b,"min_price"),b=u(b,"max_price"));b=b+(g==b?"?":"&")+a.param({min_price:c,max_price:m})}"select"==d.data("type")&&(d.parents("div.yith-woo-ajax-navigation").find("a.yit-wcan-select-open").removeClass("active"),d.parent().find("div.yith-wcan-select-wrapper").animate({visibility:"hidden",
8
- opacity:0},300));a(yith_wcan.container).not(".ywcps-products").html("").addClass("yith-wcan-loading");a(document).trigger("yith-wcan-ajax-loading");"undefined"!=typeof yith_wcan_frontend&&a(yith_wcan.container).not(".ywcps-products").css("backgroundImage","url("+yith_wcan_frontend.loader_url+")");1==yith_wcan.is_mobile&&a("body").scrollTop(a(yith_wcan.scroll_top).offset().top);a(yith_wcan.pagination).hide();a(yith_wcan.result_count).hide();0!=r&&(r.abort(),r=!1);r=a.ajax({url:b,success:function(c){r=
9
- !1;a(yith_wcan.container).not(".ywcps-products").removeClass("yith-wcan-loading");0<a(c).find(yith_wcan.container).not(".ywcps-products").length?a(".yit-wcan-container").html(a(c).find(yith_wcan.container).not(".ywcps-products")):a(".yit-wcan-container").html(a(c).find(".woocommerce-info"));0<a(c).find(yith_wcan.pagination).length?(0==a(yith_wcan.pagination).length&&a.jseldom(yith_wcan.pagination).insertAfter(a(yith_wcan.container).not(".ywcps-products")),a(yith_wcan.pagination).html(a(c).find(yith_wcan.pagination).html()).show()):
10
- a(yith_wcan.pagination).empty();a("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');0<a(c).find(yith_wcan.result_count).length&&a(yith_wcan.result_count).html(a(c).find(yith_wcan.result_count).html()).show();a(".yith-woo-ajax-navigation").add(".yith-wcan-sort-by").add(".yith-wcan-stock-on-sale").add(".yith-wcan-list-price-filter").each(function(){var b=
11
- a(this),d=b.attr("id");b.html(a(c).find("#"+d).html());""==b.text()?b.hide():b.show()});navigator.userAgent.match(/msie/i)||window.history.pushState({pageTitle:c.pageTitle},"",b);a(document).trigger("ready");a(document).trigger("yith-wcan-ajax-filtered");a(window).trigger("scroll");if(f){if("undefined"!=typeof a.fn.slider){var d=parseInt(a(yith_wcan.wc_price_slider.min_price).data("min")),g=parseInt(a(yith_wcan.wc_price_slider.max_price).data("max"));a(yith_wcan.wc_price_slider.wrapper).slider("values",
12
- [d,g]);a(document.body).trigger("price_slider_slide",[d,g])}a(document).trigger("yith-wcan-ajax-reset-filtered")}}})};a(yith_wcan.container).not(".ywcps-products").wrap('<div class="yit-wcan-container"></div>');a(yith_wcan.container).not(".ywcps-products").wrap('<div class="yit-wcan-container"></div>');a(document).trigger("yith-wcan-wrapped");a(document).on("click",".yith-wcan a",function(h){a(this).yith_wcan_ajax_filters(h,this)});var t=function(){a("div.yith-wcan-select-wrapper").animate({visibility:"hidden",
13
- opacity:0},0);a("a.yit-wcan-select-open").removeClass("active")};a(document).on("click","a.yit-wcan-select-open.active",function(h){h.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},300);a(this).parent().find("a.yit-wcan-select-open").removeClass("active")});a(document).on("click","a.yit-wcan-select-open:not(.active)",function(h){h.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index",
14
- "1").animate({visibility:"visible",opacity:1},300);a(this).parent().find("a.yit-wcan-select-open").addClass("active")});a(document).on("ready yith-wcan-ajax-filtered",function(){a("div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen");t();a("div.yith-wcan-select-wrapper").each(function(){var h="";a(this).find("ul.yith-wcan-select li.chosen").each(function(){h+=a(this).text()+", "});h=h.substring(0,h.length-2);""!=h&&a(this).parent().find("a.yit-wcan-select-open").text(h)})});a(document).on("ready",
15
- t);a("body").on("click",function(h){a(h.target).hasClass("yit-wcan-select-open")||t()})});
1
+ jQuery(function(a){function u(a,p){return a.replace(new RegExp("[?&]"+p+"=[^&#]*(#.*)?$"),"$1").replace(new RegExp("([?&])"+p+"=[^&]*&"),"$1")}var y=/(?!(\[))(\.)[^.#[]*/g,z=/(#)[^.#[]*/,A=/^[\w]+/,B=/^[\w]+$/,v=function(g,p){var b=[];if(B.test(g))b=[{tag:g}];else{for(var b=g,d={sel:[],val:[]},f=[],k=!1,h="",l=[],c=0,m=b.length;c<m;c++){var e=b.charAt(c);if(k)if("\\"===e&&c+1<b.length)l.push(b.charAt(++c));else if(h===e)h="",l.push(e);else if(("'"===e||'"'===e)&&""===h)h=e,l.push(e);else if("]"===
2
+ e&&""===h)d.val.push(l.join("")),l=[],k=!1;else{if("]"!==e||""!==h)""===h&&","===e?(d.val.push(l.join("")),l=[]):l.push(e)}else"\\"===e&&c+1<b.length?k&&l.push(b.charAt(++c)):"["===e&&""===h?k=!0:" "===e||"+"===e?(d.sel=d.sel.join(""),f.push(d),"+"===e&&f.push({sel:"+",val:""}),d={sel:[],val:[]}):" "!==e&&"]"!==e&&d.sel.push(e)}if(0!=d.sel.length||0!=d.val.length)d.sel=d.sel.join(""),f.push(d);for(c=0;c<f.length;c++){d=f[c].sel;if("+"===d)n.tag=d;else{var n=[];n.tag=A.exec(d);n.id=z.exec(d);n.id&&
3
+ a.isArray(n.id)&&(n.id=n.id[0].substr(1));n.tag||(n.tag="div");n.vars=[];for(b=0;b<f[c].val.length;b++)h=f[c].val[b].indexOf("="),k=f[c].val[b].substr(0,h),h=f[c].val[b].substr(h+1),h=h.replace(/^[\s]*[\"\']*|[\"\']*[\s]*$/g,""),"text"===k?n.text=h:n.vars.push([k,h]);d=d.match(y);k=[];if(d){for(b=0;b<d.length;b++)k.push(d[b].substr(1));n.className=k.join(" ")}}f[c]=n}b=f}n=[];"undefined"===typeof p&&(p=1);d=[];f=[];k=[];h=document.createElement("div");for(c=l=0;c<b.length;c++){if("+"==b[c].tag)f=
4
+ k.slice(),--l;else{for(m=0;m<p;m++)if("input"==b[c].tag){e=[];e.push("<"+b[c].tag);b[c].id&&e.push("id='"+b[c].id+"'");b[c].className&&(e.push("class='"+b[c].className),c+1===b.length&&e.push(lastClass),e.push("'"));if(b[c].vars)for(var q=0;q<b[c].vars.length;q++)e.push(b[c].vars[q][0]+"='"+b[c].vars[q][1]+"'");b[c].text&&e.push("value='"+b[c].text+"'");e.push("/>");k[m]=f[m];f[m]?(f[m].innerHTML+=e.join(" "),f[m]=f[m].lastChild):(h.innerHTML=e.join(" "),f[m]=h.removeChild(h.firstChild))}else{e=document.createElement(b[c].tag);
5
+ if(b[c].vars)for(q=0;q<b[c].vars.length;q++)console.log(b[c].tag,b[c].vars[q]),e.setAttribute(b[c].vars[q][0],b[c].vars[q][1]);b[c].id&&(e.id=b[c].id);b[c].className&&(e.className=b[c].className);b[c].text&&e.appendChild(document.createTextNode(b[c].text));k[m]=f[m];f[m]=f[m]?f[m].appendChild(e):e}l++||Array.prototype.push.apply(d,f)}n=a.merge(n,f)}return a(d)},w=function(g,p,b){for(var d=g.match(/%[^%]*%/g)||[],f=[],k=0;k<p.length;k++){for(var h=g,l=0;l<d.length;l++)var c=d[l].substr(1,d[l].length-
6
+ 2),h=h.replace(d[l],p[k][c]);f=a.merge(f,v(h,b))}return a(f)};a.jseldom=function(g){if(2==arguments.length&&a.isPlainObject(arguments[1]))return w.apply(this,[arguments[0],[arguments[1]]]);if(1==arguments.length||2==arguments.length&&!a.isArray(arguments[1]))return v.apply(this,arguments);if(2==arguments.length)return w.apply(this,arguments)};var r=!1,x=function(){var g=a("#yith-wcan-reset-all-categories").find("a.yith-wcan-reset-categories-link"),p=a("#yith-wcan-reset-all-tags").find("a.yith-wcan-reset-tags-link");
7
+ g.add(p).on("click",function(b){a(this).yith_wcan_ajax_filters(b,this)})};a.fn.yith_wcan_ajax_filters=function(g,p){g.preventDefault();var b=p.href,d=a(p),f=d.hasClass("yith-wcan-reset-navigation");if("undefined"==typeof b&&d.parents().hasClass("price_slider_wrapper")){d.parents("form");var k=window.location,h=k.origin+k.pathname,l=h!=k.href,c=a(".price_slider_amount #min_price").val(),m=a(".price_slider_amount #max_price").val(),b=k.href;1==l&&(b=u(b,"min_price"),b=u(b,"max_price"));b=b+(h==b?"?":
8
+ "&")+a.param({min_price:c,max_price:m})}"select"==d.data("type")&&(d.parents("div.yith-woo-ajax-navigation").find("a.yit-wcan-select-open").removeClass("active"),d.parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},300));a(yith_wcan.container).not(".ywcps-products").html("").addClass("yith-wcan-loading");a(document).trigger("yith-wcan-ajax-loading");"undefined"!=typeof yith_wcan_frontend&&a(yith_wcan.container).not(".ywcps-products").css("backgroundImage",
9
+ "url("+yith_wcan_frontend.loader_url+")");1==yith_wcan.is_mobile&&a(window).scrollTop(a(yith_wcan.scroll_top).offset().top);a(yith_wcan.pagination).hide();a(yith_wcan.result_count).hide();0!=r&&(r.abort(),r=!1);r=a.ajax({url:b,success:function(c){r=!1;a(yith_wcan.container).not(".ywcps-products").removeClass("yith-wcan-loading");0<a(c).find(yith_wcan.container).not(".ywcps-products").length?a(".yit-wcan-container").html(a(c).find(yith_wcan.container).not(".ywcps-products")):a(".yit-wcan-container").html(a(c).find(".woocommerce-info"));
10
+ 0<a(c).find(yith_wcan.pagination).length?(0==a(yith_wcan.pagination).length&&a.jseldom(yith_wcan.pagination).insertAfter(a(yith_wcan.container).not(".ywcps-products")),a(yith_wcan.pagination).html(a(c).find(yith_wcan.pagination).html()).show()):a(yith_wcan.pagination).empty();a("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');0<a(c).find(yith_wcan.result_count).length&&
11
+ a(yith_wcan.result_count).html(a(c).find(yith_wcan.result_count).html()).show();a(".yith-woo-ajax-navigation").add(".yith-wcan-sort-by").add(".yith-wcan-stock-on-sale").add(".yith-wcan-list-price-filter").each(function(){var b=a(this),d=b.attr("id");b.html(a(c).find("#"+d).html());""==b.text()?b.hide():b.show()});1!=yith_wcan.change_browser_url||navigator.userAgent.match(/msie/i)||window.history.pushState({pageTitle:c.pageTitle},"",b);a(document).trigger("ready");a(document).trigger("yith-wcan-ajax-filtered");
12
+ a(window).trigger("scroll");if(f){if("undefined"!=typeof a.fn.slider){var d=parseInt(a(yith_wcan.wc_price_slider.min_price).data("min")),g=parseInt(a(yith_wcan.wc_price_slider.max_price).data("max"));a(yith_wcan.wc_price_slider.wrapper).slider("values",[d,g]);a(document.body).trigger("price_slider_slide",[d,g])}a(document).trigger("yith-wcan-ajax-reset-filtered")}x()}})};a(yith_wcan.container).not(".ywcps-products").wrap('<div class="yit-wcan-container"></div>');a(document).on("yith-wcan-wrapped",
13
+ function(){x()});a(document).trigger("yith-wcan-wrapped");a(document).on("click",".yith-wcan a",function(g){a(this).yith_wcan_ajax_filters(g,this)});var t=function(){a("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",opacity:0},0);a("a.yit-wcan-select-open").removeClass("active")};a(document).on("click","a.yit-wcan-select-open.active",function(g){g.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","-1").animate({visibility:"hidden",
14
+ opacity:0},300);a(this).parent().find("a.yit-wcan-select-open").removeClass("active")});a(document).on("click","a.yit-wcan-select-open:not(.active)",function(g){g.preventDefault();a(this).parent().find("div.yith-wcan-select-wrapper").css("z-index","1").animate({visibility:"visible",opacity:1},300);a(this).parent().find("a.yit-wcan-select-open").addClass("active")});a(document).on("ready yith-wcan-ajax-filtered",function(){a("div.yith-wcan-select-wrapper ul.yith-wcan-select li.chosen");t();a("div.yith-wcan-select-wrapper").each(function(){var g=
15
+ "";a(this).find("ul.yith-wcan-select li.chosen").each(function(){g+=a(this).text()+", "});g=g.substring(0,g.length-2);""!=g&&a(this).parent().find("a.yit-wcan-select-open").text(g)})});a(document).on("ready",t);a("body").on("click",function(g){a(g.target).hasClass("yit-wcan-select-open")||t()})});
includes/class.yith-wcan-frontend.php CHANGED
@@ -66,16 +66,17 @@ if ( ! class_exists( 'YITH_WCAN_Frontend' ) ) {
66
  ! empty( $custom_style ) && wp_add_inline_style( 'yith-wcan-frontend', sanitize_text_field( $custom_style ) );
67
 
68
  $args = apply_filters( 'yith_wcan_ajax_frontend_classes', array(
69
- 'container' => yith_wcan_get_option( 'yith_wcan_ajax_shop_container', '.products' ),
70
- 'pagination' => yith_wcan_get_option( 'yith_wcan_ajax_shop_pagination', 'nav.woocommerce-pagination' ),
71
- 'result_count' => yith_wcan_get_option( 'yith_wcan_ajax_shop_result_container', '.woocommerce-result-count' ),
72
- 'wc_price_slider' => array(
73
  'wrapper' => '.price_slider',
74
  'min_price' => '.price_slider_amount #min_price',
75
  'max_price' => '.price_slider_amount #max_price',
76
  ),
77
- 'is_mobile' => wp_is_mobile(),
78
- 'scroll_top' => yith_wcan_get_option( 'yith_wcan_ajax_scroll_top_class', '.yit-wcan-container' ),
 
79
  )
80
  );
81
 
66
  ! empty( $custom_style ) && wp_add_inline_style( 'yith-wcan-frontend', sanitize_text_field( $custom_style ) );
67
 
68
  $args = apply_filters( 'yith_wcan_ajax_frontend_classes', array(
69
+ 'container' => yith_wcan_get_option('yith_wcan_ajax_shop_container', '.products'),
70
+ 'pagination' => yith_wcan_get_option('yith_wcan_ajax_shop_pagination', 'nav.woocommerce-pagination'),
71
+ 'result_count' => yith_wcan_get_option('yith_wcan_ajax_shop_result_container', '.woocommerce-result-count'),
72
+ 'wc_price_slider' => array(
73
  'wrapper' => '.price_slider',
74
  'min_price' => '.price_slider_amount #min_price',
75
  'max_price' => '.price_slider_amount #max_price',
76
  ),
77
+ 'is_mobile' => wp_is_mobile(),
78
+ 'scroll_top' => yith_wcan_get_option('yith_wcan_ajax_scroll_top_class', '.yit-wcan-container'),
79
+ 'change_browser_url' => 'yes' == yith_wcan_get_option( 'yith_wcan_change_browser_url', 'yes' ) ? true : false
80
  )
81
  );
82
 
includes/functions.yith-wcan.php CHANGED
@@ -474,8 +474,13 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
474
  */
475
  function yit_get_woocommerce_layered_nav_link() {
476
  $return = false;
477
- if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() && ! is_product_taxonomy() ) ) {
478
- $return = get_post_type_archive_link( 'product' );
 
 
 
 
 
479
  return apply_filters( 'yith_wcan_untrailingslashit', true ) ? untrailingslashit( $return ) : $return;
480
  }
481
 
@@ -489,7 +494,7 @@ if ( ! function_exists( 'yit_get_woocommerce_layered_nav_link' ) ) {
489
  $brands_taxonomy = yit_get_brands_taxonomy();
490
 
491
  if( ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy ){
492
- $return = get_post_type_archive_link( 'product' );
493
  }
494
 
495
  else {
@@ -570,29 +575,91 @@ if( ! function_exists( 'yit_get_brands_taxonomy' ) ){
570
  * @author Andrea Grillo <andrea.grillo@yithemes.com>
571
  */
572
  function yit_get_brands_taxonomy(){
573
- return defined( 'YITH_WCBR_PREMIUM_INIT' ) && YITH_WCBR_PREMIUM_INIT ? YITH_WCBR::$brands_taxonomy : '';
 
 
 
 
 
 
 
 
 
 
 
574
  }
575
  }
576
 
577
- function yit_test( $parent_term_id ){
578
- $childs = get_terms(
579
- 'product_cat',
580
- array(
581
- 'parent' => $parent_term_id,
582
- 'hierarchical' => true,
583
- 'hide_empty' => false
584
- )
585
- );
586
-
587
- if( ! empty( $childs ) ){
588
- $temp = array();
589
- foreach( $childs as $child ){
590
- $temp[ $child->term_id ] = yit_test( $child->term_id );
591
- }
592
- return $temp;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
593
  }
 
594
 
595
- else{
596
- return array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
597
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
598
  }
474
  */
475
  function yit_get_woocommerce_layered_nav_link() {
476
  $return = false;
477
+ if ( defined( 'SHOP_IS_ON_FRONT' ) || ( is_shop() && ! is_product_category() ) ) {
478
+ $taxonomy = get_query_var( 'taxonomy' );
479
+ $brands_taxonomy = yit_get_brands_taxonomy();
480
+ $return = get_post_type_archive_link( 'product' );
481
+ if( ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy ){
482
+ $return = add_query_arg( array( $taxonomy => get_query_var( 'term' ) ), $return );
483
+ }
484
  return apply_filters( 'yith_wcan_untrailingslashit', true ) ? untrailingslashit( $return ) : $return;
485
  }
486
 
494
  $brands_taxonomy = yit_get_brands_taxonomy();
495
 
496
  if( ! empty( $brands_taxonomy ) && $brands_taxonomy == $taxonomy ){
497
+ $return = add_query_arg( array( $taxonomy => get_query_var( 'term' ) ), get_post_type_archive_link( 'product' ) );
498
  }
499
 
500
  else {
575
  * @author Andrea Grillo <andrea.grillo@yithemes.com>
576
  */
577
  function yit_get_brands_taxonomy(){
578
+ $taxonomy = '';
579
+
580
+ //Support to YITH WooCommerce Brands Add-on
581
+ if( defined( 'YITH_WCBR_PREMIUM_INIT' ) && YITH_WCBR_PREMIUM_INIT ){
582
+ $taxonomy = YITH_WCBR::$brands_taxonomy;
583
+ }
584
+
585
+ //Support to Ultimate WooCommerce Brands PRO
586
+ elseif( class_exists( 'MGWB' ) ){
587
+ $taxonomy = "product_brand";
588
+ }
589
+ return $taxonomy;
590
  }
591
  }
592
 
593
+ if( ! function_exists( 'yit_reorder_hierachical_categories' ) ) {
594
+ /**
595
+ * Enable multi level taxonomies management
596
+ *
597
+ * @return array the full terms array
598
+ *
599
+ * @since 2.8.1
600
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
601
+ */
602
+ function yit_reorder_hierachical_categories( $parent_term_id, $taxonomy = 'product_cat' ) {
603
+ $childs = get_terms(
604
+ $taxonomy,
605
+ array(
606
+ 'parent' => $parent_term_id,
607
+ 'hierarchical' => true,
608
+ 'hide_empty' => false
609
+ )
610
+ );
611
+
612
+ if ( !empty( $childs ) ) {
613
+ $temp = array();
614
+ foreach ( $childs as $child ) {
615
+ $temp[$child->term_id] = yit_reorder_hierachical_categories( $child->term_id, $taxonomy );
616
+ }
617
+ return $temp;
618
+ }
619
+
620
+ else {
621
+ return array();
622
+ }
623
  }
624
+ }
625
 
626
+ if( ! function_exists( 'remove_premium_query_arg' ) ) {
627
+ /**
628
+ * Remove Premium query args
629
+ *
630
+ * @return array the full terms array
631
+ *
632
+ * @since 2.8.1
633
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
634
+ */
635
+ function remove_premium_query_arg( $link ) {
636
+ $reset = array( 'orderby', 'onsale_filter', 'instock_filter', 'product_tag', 'product_cat' );
637
+ $brands_taxonomy = yit_get_brands_taxonomy();
638
+ if ( ! empty( $brands_taxonomy ) ) {
639
+ $reset[] = $brands_taxonomy;
640
+ }
641
+
642
+ return remove_query_arg( $reset, $link );
643
  }
644
+ }
645
+
646
+ if( ! function_exists( 'yit_is_filtered_uri' ) ){
647
+ /**
648
+ * Get is the current uri are filtered
649
+ *
650
+ * @return bool true if the url are filtered, false otherwise
651
+ *
652
+ * @since 2.8.6
653
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
654
+ */
655
+ function yit_is_filtered_uri(){
656
+ global $_chosen_attributes;
657
+ $brands = yit_get_brands_taxonomy();
658
+ $show_all_categories_link_enabled = 'yes' == yith_wcan_get_option( 'yith_wcan_enable_see_all_categories_link', 'no' );
659
+ //check if current page is filtered
660
+ $is_filtered_uri = isset( $_GET['product_cat'] ) || count( $_chosen_attributes ) > 0 || isset( $_GET['min_price'] ) || isset( $_GET['max_price'] ) || isset( $_GET['orderby'] ) || isset( $_GET['instock_filter'] ) || isset( $_GET['onsale_filter'] ) || isset( $_GET['product_tag'] ) || isset( $_GET[ $brands ] );
661
+
662
+ return apply_filters( 'yit_wcan_is_filtered_uri', $is_filtered_uri );
663
+ }
664
+
665
  }
init.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: YITH WooCommerce Ajax Product Filter
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
- * Version: 2.8.1
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith_wc_ajxnav
@@ -64,7 +64,7 @@ load_plugin_textdomain( 'yith-woocommerce-ajax-navigation', false, dirname( plug
64
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
- ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.8.1' );
68
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
 
3
  * Plugin Name: YITH WooCommerce Ajax Product Filter
4
  * Plugin URI: http://yithemes.com/
5
  * Description: YITH WooCommerce Ajax Product Filter offers the perfect way to filter all the products of your shop.
6
+ * Version: 2.9.0
7
  * Author: YITHEMES
8
  * Author URI: http://yithemes.com/
9
  * Text Domain: yith_wc_ajxnav
64
  ! defined( 'YITH_WCAN' ) && define( 'YITH_WCAN', true );
65
  ! defined( 'YITH_WCAN_URL' ) && define( 'YITH_WCAN_URL', plugin_dir_url( __FILE__ ) );
66
  ! defined( 'YITH_WCAN_DIR' ) && define( 'YITH_WCAN_DIR', plugin_dir_path( __FILE__ ) );
67
+ ! defined( 'YITH_WCAN_VERSION' ) && define( 'YITH_WCAN_VERSION', '2.9.0' );
68
  ! defined( 'YITH_WCAN_FREE_INIT') && define( 'YITH_WCAN_FREE_INIT', plugin_basename( __FILE__ ) );
69
  ! defined( 'YITH_WCAN_FILE' ) && define( 'YITH_WCAN_FILE', __FILE__ );
70
 
plugin-fw/assets/css/colorbox.css ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Colorbox Core Style:
3
+ The following CSS is consistent between example themes and should not be altered.
4
+ */
5
+ #colorbox, #cboxOverlay, #cboxWrapper{position:absolute; top:0; left:0; z-index:9999; overflow:hidden; -webkit-transform: translate3d(0,0,0);}
6
+ #cboxWrapper {max-width:none;}
7
+ #cboxOverlay{position:fixed; width:100%; height:100%;}
8
+ #cboxMiddleLeft, #cboxBottomLeft{clear:left;}
9
+ #cboxContent{position:relative;}
10
+ #cboxLoadedContent{overflow:auto; -webkit-overflow-scrolling: touch;}
11
+ #cboxTitle{margin:0;}
12
+ #cboxLoadingOverlay, #cboxLoadingGraphic{position:absolute; top:0; left:0; width:100%; height:100%;}
13
+ #cboxPrevious, #cboxNext, #cboxClose, #cboxSlideshow{cursor:pointer;}
14
+ .cboxPhoto{float:left; margin:auto; border:0; display:block; max-width:none; -ms-interpolation-mode:bicubic;}
15
+ .cboxIframe{width:100%; height:100%; display:block; border:0; padding:0; margin:0;}
16
+ #colorbox, #cboxContent, #cboxLoadedContent{box-sizing:content-box; -moz-box-sizing:content-box; -webkit-box-sizing:content-box;}
17
+
18
+ /*
19
+ User Style:
20
+ Change the following styles to modify the appearance of Colorbox. They are
21
+ ordered & tabbed in a way that represents the nesting of the generated HTML.
22
+ */
23
+ #cboxOverlay{background:#fff; opacity: 0.9; filter: alpha(opacity = 90);}
24
+ #colorbox{outline:0;}
25
+ #cboxTopLeft{width:25px; height:25px; background:url(../images/colorbox/border1.png) no-repeat 0 0;}
26
+ #cboxTopCenter{height:25px; background:url(../images/colorbox/border1.png) repeat-x 0 -50px;}
27
+ #cboxTopRight{width:25px; height:25px; background:url(../images/colorbox/border1.png) no-repeat -25px 0;}
28
+ #cboxBottomLeft{width:25px; height:25px; background:url(../images/colorbox/border1.png) no-repeat 0 -25px;}
29
+ #cboxBottomCenter{height:25px; background:url(../images/colorbox/border1.png) repeat-x 0 -75px;}
30
+ #cboxBottomRight{width:25px; height:25px; background:url(../images/colorbox/border1.png) no-repeat -25px -25px;}
31
+ #cboxMiddleLeft{width:25px; background:url(../images/colorbox/border2.png) repeat-y 0 0;}
32
+ #cboxMiddleRight{width:25px; background:url(../images/colorbox/border2.png) repeat-y -25px 0;}
33
+ #cboxContent{background:#fff; overflow:hidden;}
34
+ .cboxIframe{background:#fff;}
35
+ #cboxError{padding:50px; border:1px solid #ccc;}
36
+ #cboxLoadedContent{margin-bottom:20px;}
37
+ #cboxTitle{position:absolute; bottom:0px; left:0; text-align:center; width:100%; color:#999;}
38
+ #cboxCurrent{position:absolute; bottom:0px; left:100px; color:#999;}
39
+ #cboxLoadingOverlay{background:#fff url(../images/colorbox/loading.gif) no-repeat 5px 5px;}
40
+
41
+ /* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
42
+ #cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose {border:0; padding:0; margin:0; overflow:visible; width:auto; background:none; }
43
+
44
+ /* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
45
+ #cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active {outline:0;}
46
+
47
+ #cboxSlideshow{position:absolute; bottom:0px; right:42px; color:#444;}
48
+ #cboxPrevious{position:absolute; bottom:0px; left:0; color:#444;}
49
+ #cboxNext{position:absolute; bottom:0px; left:63px; color:#444;}
50
+ #cboxClose{position:absolute; bottom:0; right:0; display:block; color:#444;}
51
+
52
+ /*
53
+ The following fixes a problem where IE7 and IE8 replace a PNG's alpha transparency with a black fill
54
+ when an alpha filter (opacity change) is set on the element or ancestor element. This style is not applied to or needed in IE9.
55
+ See: http://jacklmoore.com/notes/ie-transparency-problems/
56
+ */
57
+ .cboxIE #cboxTopLeft,
58
+ .cboxIE #cboxTopCenter,
59
+ .cboxIE #cboxTopRight,
60
+ .cboxIE #cboxBottomLeft,
61
+ .cboxIE #cboxBottomCenter,
62
+ .cboxIE #cboxBottomRight,
63
+ .cboxIE #cboxMiddleLeft,
64
+ .cboxIE #cboxMiddleRight {
65
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#00FFFFFF,endColorstr=#00FFFFFF);
66
+ }
plugin-fw/assets/css/metaboxes.css CHANGED
@@ -1,664 +1,664 @@
1
- /* self-clear floats */
2
- .clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; overflow:hidden; }
3
- /* ie.css */
4
- * html .clearfix { /* IE6 */
5
- height:1%;
6
- }
7
- *:first-child+html .clearfix { /* IE7 */
8
- min-height:1%;
9
- }
10
-
11
- .clearboth { clear: both }
12
-
13
- /* === TAB STYLE */
14
- .metaboxes-tab { margin:-6px -12px -8px; }
15
- .metaboxes-tab div.tabs-panel { height:auto; overflow:visible; margin-top:0px; padding:0 10px; background:none; border:0; border-top:1px solid #D4D4D4; }
16
- .metaboxes-tab ul.metaboxes-tabs { background:#F5F5F5; margin:0; padding:10px 0 0 5px; }
17
- .metaboxes-tab ul.metaboxes-tabs li { padding:8px 15px; border:1px solid #D4D4D4; float:left; background:#EDEDED; border-bottom-color:#EDEDED; margin:0 0 -1px 5px; box-shadow:1px 1px 1px 0 #FFFFFF inset; }
18
- .metaboxes-tab ul.metaboxes-tabs li a { color:#555; text-decoration:none; }
19
- .metaboxes-tab ul.metaboxes-tabs li.tabs { background:#F6F6F6; border-bottom:1px solid #F6F6F6; }
20
- .metaboxes-tab p.field-row { margin:20px 0; }
21
- .metaboxes-tab div.sep { height:1px; background:#DFDFDF; clear:both; margin-left:-10px; margin-right:-10px; }
22
- .metaboxes-tab label { font-weight:bold; width:160px; float:left; line-height:23px; margin-left:-184px; }
23
- .metaboxes-tab label small { font-weight:normal; line-height:15px; font-style:italic; color:#999; display:block; }
24
- .metaboxes-tab input[type="text"], .metaboxes-tab select, .metaboxes-tab textarea { width:30%; }
25
- .metaboxes-tab input[type="checkbox"] { vertical-align: middle }
26
- .metaboxes-tab select {padding:0;}
27
- .metaboxes-tab input.button-secondary, .metaboxes-tab input.checkbox { width:auto; }
28
- .metaboxes-tab .description { color:#AFAFAF; font-size:90%; font-style:italic; line-height:23px; padding-left:5px; }
29
- .metaboxes-tab p.field-row.textarea .description { vertical-align:top; }
30
- .metaboxes-tab p.field-row.checkbox {background:none;}
31
-
32
- .metaboxes-tab .the-metabox { margin:20px 0; margin-left:184px;}
33
- .metaboxes-tab .the-metabox.no-label { margin:20px 0; margin-left:0;}
34
- .metaboxes-tab hr { height: 0px; border-top: 1px solid #dadada; width: auto; margin-left: -10px; margin-right: -10px; }
35
- .metaboxes-tab .the-metabox p { margin:0;}
36
- .metaboxes-tab .the-metabox:last-child { border-bottom: 0px; }
37
- .metaboxes-tab .the-metabox.checkbox { background:none; }
38
- .metaboxes-tab .the-metabox.slider .ui-slider { margin-right:15px; }
39
-
40
- .metaboxes-tab span.desc { font-size: 11px; color: #AFAFAF; }
41
- .metaboxes-tab span.desc.inline { display: inline-block; vertical-align: top; line-height: 23px; }
42
- .metaboxes-tab .onoff span.desc, .metaboxes-tab .onoff label { padding:6px 0; }
43
- .metaboxes-tab .select span.desc, .metaboxes-tab .select label { padding:2px 0; }
44
- .metaboxes-tab .slider span.desc, .metaboxes-tab .slider label { padding:15px 0; }
45
- .metaboxes-tab .slider span.desc { display:block; padding:20px 0; }
46
-
47
- .metaboxes-tab ul.metaboxes-tabs li {
48
- -webkit-border-top-left-radius: 3px;
49
- -webkit-border-top-right-radius: 3px;
50
- -moz-border-radius-topleft: 3px;
51
- -moz-border-radius-topright: 3px;
52
- border-top-left-radius: 3px;
53
- border-top-right-radius: 3px;
54
- }
55
-
56
- /* image gallery */
57
- .metaboxes-tab .image-gallery ul li{
58
- display: inline-block;
59
- width: 80px;
60
- margin-left: 10px;
61
- position: relative;
62
- }
63
- .metaboxes-tab .image-gallery ul li img{
64
- width: 80px;
65
- border: 1px solid #ccc;
66
- }
67
- .metaboxes-tab .image-gallery ul li ul{
68
- position: absolute;
69
- top: -6px;
70
- right: -1px;
71
- width: 20px;
72
- height: 20px;
73
- }
74
- .metaboxes-tab .image-gallery ul a.delete{
75
- background: url(../images/x.png) no-repeat;
76
- width: 20px;
77
- height: 20px;
78
- display: block;
79
- text-indent: -99999px;
80
- }
81
- /* sidebar layout */
82
- .yit-sidebar-layout input[type="radio"] {
83
- display: none;
84
- width: 0px;
85
- }
86
- .yit-sidebar-layout input[type="radio"]:first-child {
87
- margin-right: -2px;
88
- }
89
-
90
- .yit-sidebar-layout input[type="radio"] + img {
91
- border: 2px solid #fff;
92
- padding: 1px;
93
- }
94
-
95
- .yit-sidebar-layout input[type="radio"] + img:hover {
96
- cursor: pointer;
97
- }
98
-
99
- .yit-sidebar-layout input[checked] + img {
100
- border: 2px solid #f2ad35;
101
- padding: 1px;
102
- }
103
-
104
- .yit-sidebar-layout select {
105
- vertical-align: 12px;
106
- width: inherit !important;
107
- }
108
-
109
- /* wp editor */
110
- .the-metabox.textarea-editor .mceIframeContainer {
111
- background:#fff;
112
- }
113
- .the-metabox.textarea-editor label {
114
- margin-top:24px;
115
- }
116
-
117
- /* categories */
118
- .categories-panel { width:30%; float:left; margin-right:4px; }
119
- .categories-panel .box { height:200px; border:1px solid #DFDFDF; background:#fff; padding:6px 10px; overflow: auto; }
120
- .categories-panel ul { list-style:none; margin:0; }
121
- .categories-panel ul li { line-height: 19px; margin: 0; padding: 0; word-wrap: break-word; }
122
- .categories-panel ul li label { font-weight:normal !important; margin-left:0 !important; }
123
- .categories-panel input.newcategory { width:100%; margin-bottom:3px; }
124
-
125
- /* contact form */
126
- .contactform_item {
127
- border-style: solid;
128
- border-width: 1px;
129
- line-height: 1;
130
- margin-bottom: 20px;
131
- padding: 0;
132
- background-color: #F5F5F5;
133
- background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
134
- border-color: #DFDFDF;
135
- border-radius: 3px 3px 3px 3px;
136
- box-shadow: 0 1px 0 #FFFFFF inset;
137
- min-width: 255px;
138
- position: relative;
139
- }
140
- .contactform_item .handlediv { position:relative; top: -4px; }
141
- .contactform_item h3 { min-height: 21px }
142
- .contactform_item .inside { padding: 10px !important; }
143
- .contactform_item .deps { display: none; }
144
- .contactform_item .addoptions p.option { margin: 5px 0 5px 200px }
145
- .contactform_item .addoptions p label { width: 80px !important; }
146
- .contactform_item .add-field-option { margin-bottom: 10px !important; }
147
- .remove_item { float: right; }
148
- .metabox-sortable-placeholder { border: 1px dotted #dedede; margin: 10px 0 }
149
-
150
- /* features tab */
151
- .featurestab_item{
152
- border-style: solid;
153
- border-width: 1px;
154
- line-height: 1;
155
- margin-bottom: 20px;
156
- padding: 0;
157
- background-color: #F5F5F5;
158
- background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
159
- border-color: #DFDFDF;
160
- border-radius: 3px 3px 3px 3px;
161
- box-shadow: 0 1px 0 #FFFFFF inset;
162
- min-width: 255px;
163
- position: relative;
164
- }
165
- .featurestab_item .handlediv { position:relative; top: -4px; }
166
- .featurestab_item h3 { min-height: 21px }
167
- .featurestab_item .inside { padding: 10px !important; }
168
- .featurestab_item .deps { display: none; }
169
- .featurestab_item .addoptions p.option { margin: 5px 0 5px 200px }
170
- .featurestab_item .addoptions p label { width: 80px !important; }
171
- .featurestab_item .add-field-option { margin-bottom: 10px !important; }
172
-
173
- /* slider */
174
- .the-metabox.slider { padding-top:20px; }
175
-
176
- /* on off */
177
- .the-metabox .rm_onoff span.onoff { float:left; margin-right:5px; margin-left:-4px; /* image fix */ }
178
-
179
- /* onoff */
180
- .rm_onoff input {
181
- display: none;
182
- }
183
-
184
- .rm_onoff input + span {
185
- cursor: pointer;
186
- text-indent: -9999px;
187
- display: block;
188
- width: 85px;
189
- height: 37px;
190
- background: transparent url(../images/off.png);
191
- }
192
-
193
- .rm_onoff input:checked + span {
194
- background: transparent url(../images/on.png);
195
- }
196
-
197
- .rm_onoff input.onoffchecked + span {
198
- background: transparent url(../images/on.png);
199
- }
200
-
201
- .messages-panel.updated {
202
- margin: 10px 0px 10px !important;
203
- max-width: 1200px;
204
- border-radius: 5px;
205
- -webkit-box-sizing: border-box;
206
- box-sizing: border-box;
207
- }
208
-
209
- .ui-widget-overlay { background-image: none !important; }
210
-
211
-
212
-
213
- /* select */
214
- .the-metabox .select_wrapper { width:341px; background-color:#fff; }
215
- .the-metabox .select_wrapper select { width:100%; }
216
- .the-metabox .icon_type{ width:30%; float: left; margin-right: 40px }
217
- .the-metabox .icon_type select, .the-metabox div.option .select_wrapper select{ width: 100% }
218
-
219
- #post-type-settings .category-list label { width: 187px; }
220
- .remove_cat { float: right; text-align:center; display: block; width: 20px; height: 20px; border-radius: 20px; font-weight: bold; font-size: 10px; background: #efefef; text-decoration: none; }
221
-
222
- .the-metabox .select_wrapper {
223
- background: url("../images/select.png") no-repeat scroll right center #FAFAFA;
224
- border-color: #CCCCCC #EEEEEE #EEEEEE #CCCCCC;
225
- border-radius: 4px 4px 4px 4px;
226
- border-style: solid;
227
- border-width: 1px;
228
- color: #555555;
229
- display: block;
230
- float: left;
231
- font-family: sans-serif;
232
- font-size: 12px;
233
- min-height: 26px;
234
- margin-bottom: 9px !important;
235
- margin-left: 0;
236
- margin-right: 5px;
237
- margin-top: 0;
238
- width: 400px;
239
- position: relative;
240
- }
241
-
242
- /*chosen*/
243
-
244
- .chosen .select_wrapper {
245
- background: none;
246
- border: none;
247
- }
248
- .chosen .select_wrapper .chosen-container{
249
- width: 338px!important;
250
- }
251
- .chosen .select_wrapper .chosen-container .search-field input{
252
- height: 27px!important;
253
- color: #333;
254
- }
255
- .chosen .select_wrapper .chosen-container .chosen-choices{
256
- border: 1px solid #ddd;
257
- box-shadow: none;
258
- }
259
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice{
260
- height: 15px!important;
261
- min-width: 105px;
262
- }
263
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice span{
264
- line-height: 15px;
265
- height: 15px;
266
- padding-top: 2px;
267
- }
268
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice a.search-choice-close{
269
- top: 5px;
270
- }
271
- .chosen .select_wrapper .chosen-container .chosen-drop .chosen-search input{
272
- width: 100%!important;
273
- }
274
- .select_wrapper span {
275
- height: 26px;
276
- line-height: 26px;
277
- padding-left: 6px;
278
- position: absolute;
279
- z-index: 2;
280
- overflow: hidden;
281
- }
282
-
283
- .the-metabox .select_wrapper select {
284
- cursor: pointer;
285
- height: 28px;
286
- margin: 0;
287
- opacity: 0;
288
- padding: 0;
289
- position: relative;
290
- width: inherit;
291
- z-index: 4;
292
- background-color: #FAFAFA;
293
- }
294
-
295
-
296
- /* typography */
297
- .the-metabox.typography .select_wrapper.font-family { width:200px; }
298
- .the-metabox.typography .spinner_container { float:left; margin-right:10px; }
299
- .the-metabox.typography .spinner_container input.number {
300
- width:50px !important;
301
- -webkit-border-top-right-radius: 0px;
302
- -webkit-border-bottom-right-radius: 0px;
303
- -moz-border-radius-topright: 0px;
304
- -moz-border-radius-bottomright: 0px;
305
- border-top-right-radius: 0px;
306
- border-bottom-right-radius: 0px;
307
- }
308
-
309
- /* number */
310
- .the-metabox.number input.number { width:50px !important; }
311
- /* number */
312
- .rm_number .number {
313
- width: 70px;
314
- text-align: right;
315
- -webkit-border-top-right-radius: 0px;
316
- -webkit-border-bottom-right-radius: 0px;
317
- -moz-border-radius-topright: 0px;
318
- -moz-border-radius-bottomright: 0px;
319
- border-top-right-radius: 0px;
320
- border-bottom-right-radius: 0px;
321
- }
322
-
323
- .spinner-wrapper { position: relative; height: 23px; overflow: hidden; }
324
- .spinner-wrapper input.number { float: left; }
325
- .spinner-wrapper .spinner-button { cursor:pointer; float: left; position: absolute; left: 69px; width: 15px; height: 12px; border: 1px solid #DFDFDF; background: #fff; margin: 0; padding: 0; line-height: 9999px; overflow: hidden; background: url('../images/spinner.png') no-repeat center -11px }
326
- .spinner-wrapper .spinner-button.button-plus { top: 0; -webkit-border-top-right-radius: 3px !important; -moz-border-radius-topright: 3px !important; border-top-right-radius: 3px !important; }
327
- .spinner-wrapper .spinner-button.button-minus { bottom: 0; background-position: center -30px; -webkit-border-bottom-right-radius: 3px !important; -moz-border-radius-bottomright: 3px !important; border-bottom-right-radius: 3px !important; }
328
-
329
-
330
- .spinner-wrapper .spinner-button.button-plus:active { background-position: center 0px; }
331
- .spinner-wrapper .spinner-button.button-minus:active { background-position: center -20px; }
332
-
333
-
334
- .rm_typography .spinner_container { float: left; margin-right: 10px; }
335
- .rm_typography .spinner-wrapper { height: 28px; }
336
- .rm_typography .spinner-wrapper input.number { height: 28px; }
337
- .rm_typography .spinner-wrapper .spinner-button.button-plus { height: 15px; background-position: center -10px; }
338
- .rm_typography .spinner-wrapper .spinner-button.button-minus { height: 14px; }
339
-
340
- .the-metabox .spinner-wrapper .spinner-button { left: 49px; }
341
- .the-metabox.typography .spinner-wrapper .spinner-button { left: 35px; }
342
-
343
- /* colorpicker */
344
- .the-metabox.colorpicker { display:block; width: auto; height: auto; overflow: visible; background-image: none; position: static; font-family: inherit;}
345
- .the-metabox.colorpicker input { background-color: transparent; border: 1px solid #DFDFDF; position: static; font-size: inherit; font-family: inherit; color: inherit; text-align: center; margin: 0 5px 0px; padding: 0; outline: none; width: auto; }
346
-
347
- /* images */
348
- .the-metabox.images, .the-metabox.images label { margin-left:0; display:block; }
349
- .the-metabox.images .slides-wrapper { clear:both; }
350
- .the-metabox.images .slides-wrapper li { position:relative; }
351
- .the-metabox.images a.delete { display:block; margin-left:4px; text-decoration:none; font-weight:bold; color:red; position:absolute; top:0; right:0; width:10px; height:18px; z-index:10; cursor:pointer !important; }
352
-
353
- /* wp editor */
354
- .wp_themeSkin iframe { background: #fff !important; }
355
-
356
- /* custom tabs */
357
- .customtab_item {
358
- border-style: solid;
359
- border-width: 1px;
360
- line-height: 1;
361
- margin-bottom: 20px;
362
- padding: 0;
363
- background-color: #F5F5F5;
364
- background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
365
- border-color: #DFDFDF;
366
- border-radius: 3px 3px 3px 3px;
367
- box-shadow: 0 1px 0 #FFFFFF inset;
368
- min-width: 255px;
369
- position: relative;
370
- }
371
- .customtab_item .handlediv { position:relative; top: -4px; }
372
- .customtab_item h3 { min-height: 21px }
373
- .customtab_item .inside { padding: 10px !important; }
374
- .customtab_item .deps { display: none; }
375
- .customtab_item .addoptions p.option { margin: 5px 0 5px 200px }
376
- .customtab_item .addoptions p label { width: 80px !important; }
377
- .customtab_item .add-field-option { margin-bottom: 10px !important; }
378
- .customtab_item .remove_item { float: right; }
379
- .metabox-sortable-placeholder { border: 1px dotted #dedede; margin: 10px 0 }
380
-
381
- .the-metabox.customtabs {
382
- margin-left: 0;
383
- }
384
-
385
- #customtab_item_sample {
386
- display: none;
387
- }
388
-
389
- .the-metabox.customtabs .field-row {
390
- margin-bottom: 10px;
391
- }
392
-
393
- #yit_custom_tabs label {
394
- font-weight: normal;
395
- width: auto;
396
- float: none;
397
- line-height: auto;
398
- margin-left: 0;
399
- }
400
-
401
-
402
- .wp-admin p label input[type=radio]{
403
- width: 16px;
404
- margin-right: 10px;
405
- margin-top: 3px;
406
- }
407
- .wp-admin .form-field._preset_onsale_icon_field label input[type=radio]{
408
- margin-top: 0;
409
- }
410
-
411
- .the-metabox .spinner {
412
- margin-top: 5px;
413
- float: none;
414
- }
415
-
416
- /* slider */
417
- /*numbers*/
418
- .ui-slider .maxCaption, .ui-slider .minCaption {
419
- margin-bottom: 5px;
420
- }
421
- .ui-slider .feedback {
422
- background: url(../images/slider/tooltip.png) no-repeat center top;
423
- position: absolute;
424
- top: -25px;
425
- width: 35px;
426
- height: 43px;
427
- text-align: center;
428
- width: 100%;
429
- display: block;
430
- }
431
- .ui-slider .feedback strong {
432
- display: inline-block;
433
- padding-top: 4px;
434
- top: -30px;
435
- }
436
- /*handle*/
437
- .ui-slider-horizontal .ui-slider-handle{
438
- background: transparent url(../images/slider/handle.png) no-repeat left top !important;
439
- border: 0px !important;
440
- top: -.35em !important;
441
- width: 18px !important;
442
- height: 19px !important;
443
- }
444
-
445
- /*bg on the left:grey*/
446
- .ui-slider.ui-widget-content {
447
- background: url(../images/slider/grey.gif) repeat-x left center !important;
448
- border-color: #c1c1c0 !important;
449
- height: 10px !important;
450
- }
451
-
452
- .iris-slider-offset.ui-slider.ui-widget-content {
453
- background: transparent!important;
454
- height: auto!important;
455
- }
456
-
457
- /*bg on the right:orange*/
458
- .ui-slider.ui-widget-content .ui-widget-header {
459
- background: url(../images/slider/orange.gif) repeat-x left center !important;
460
- left: 2px !important;
461
- -webkit-border-radius: 15px;
462
- -moz-border-radius: 15px;
463
- -khtml-border-radius: 15px;
464
- border-radius: 15px;
465
- }
466
-
467
-
468
- /*sidebars*/
469
-
470
- #choose-sidebars.choose{
471
- margin-left: 0px;
472
- }
473
-
474
-
475
- #_active_page_options-container label, #_active_page_options-container p{
476
- display: inline-block;
477
- margin: 0px;
478
- }
479
- #_active_page_options-container label{
480
- margin-right: 10px;
481
- margin-top: 3px;
482
- }
483
- #_active_page_options-container {
484
- float: right;
485
- margin-right: 20px;
486
- margin-top: 5px;
487
- }
488
-
489
- /* sortable table posts */
490
-
491
- #the-list.ui-sortable tr:hover {
492
- cursor: move;
493
- }
494
-
495
-
496
- /*datepicker*/
497
- /*! jQuery UI - v1.11.2 - 2015-01-21
498
- * http://jqueryui.com
499
- * Includes: core.css, datepicker.css, theme.css
500
- * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=0px&bgColorHeader=%23dddddd&bgTextureHeader=flat&bgImgOpacityHeader=60&borderColorHeader=%23aaaaaa&fcHeader=%23222222&iconColorHeader=%23222222&bgColorContent=%23ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=%23aaaaaa&fcContent=%23222222&iconColorContent=%23222222&bgColorDefault=%23e9e9e9&bgTextureDefault=flat&bgImgOpacityDefault=75&borderColorDefault=%23d3d3d3&fcDefault=%23555555&iconColorDefault=%23888888&bgColorHover=%23dadada&bgTextureHover=flat&bgImgOpacityHover=75&borderColorHover=%23999999&fcHover=%23212121&iconColorHover=%23454545&bgColorActive=%23ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=%23aaaaaa&fcActive=%23212121&iconColorActive=%23454545&bgColorHighlight=%23fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=%2389b17e&fcHighlight=%23363636&iconColorHighlight=%232e83ff&bgColorError=%23fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=%23cd0a0a&fcError=%23cd0a0a&iconColorError=%23cd0a0a&bgColorOverlay=%23aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=%23aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
501
- * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
502
-
503
- /* Layout helpers
504
- ----------------------------------*/
505
- .ui-helper-hidden {
506
- display: none;
507
- }
508
- .ui-helper-hidden-accessible {
509
- border: 0;
510
- clip: rect(0 0 0 0);
511
- height: 1px;
512
- margin: -1px;
513
- overflow: hidden;
514
- padding: 0;
515
- position: absolute;
516
- width: 1px;
517
- }
518
- .ui-helper-reset {
519
- margin: 0;
520
- padding: 0;
521
- border: 0;
522
- outline: 0;
523
- line-height: 1.3;
524
- text-decoration: none;
525
- font-size: 100%;
526
- list-style: none;
527
- }
528
- .ui-helper-clearfix:before,
529
- .ui-helper-clearfix:after {
530
- content: "";
531
- display: table;
532
- border-collapse: collapse;
533
- }
534
- .ui-helper-clearfix:after {
535
- clear: both;
536
- }
537
- .ui-helper-clearfix {
538
- min-height: 0; /* support: IE7 */
539
- }
540
- .ui-helper-zfix {
541
- width: 100%;
542
- height: 100%;
543
- top: 0;
544
- left: 0;
545
- position: absolute;
546
- opacity: 0;
547
- filter:Alpha(Opacity=0); /* support: IE8 */
548
- }
549
-
550
- .ui-front {
551
- z-index: 100;
552
- }
553
-
554
-
555
- /* Interaction Cues
556
- ----------------------------------*/
557
- .ui-state-disabled {
558
- cursor: default !important;
559
- }
560
-
561
-
562
- /* Icons
563
- ----------------------------------*/
564
-
565
- /* states and images */
566
- .ui-icon {
567
- display: block;
568
- text-indent: -99999px;
569
- overflow: hidden;
570
- background-repeat: no-repeat;
571
- }
572
-
573
-
574
- /* DATE PICKER
575
- ----------------------------------*/
576
-
577
- .ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}
578
- .ui-datepicker{width:17em;padding:.2em .2em 0;display:none;z-index:100!important;}
579
- .ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}
580
- .ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}
581
- .ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}
582
- .ui-datepicker .ui-datepicker-prev{left:2px}
583
- .ui-datepicker .ui-datepicker-next{right:2px}
584
- .ui-datepicker .ui-datepicker-prev-hover{left:1px}
585
- .ui-datepicker .ui-datepicker-next-hover{right:1px}
586
- .ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}
587
- .ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}
588
- .ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}
589
- .ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:45%}
590
- .ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}
591
- .ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:700;border:0}
592
- .ui-datepicker td{border:0;padding:1px}
593
- .ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}
594
- .ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}
595
- .ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em;width:auto;overflow:visible}
596
- .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}
597
- .ui-datepicker.ui-datepicker-multi{width:auto}
598
- .ui-datepicker-multi .ui-datepicker-group{float:left}
599
- .ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}
600
- .ui-datepicker-multi-2 .ui-datepicker-group{width:50%}
601
- .ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}
602
- .ui-datepicker-multi-4 .ui-datepicker-group{width:25%}
603
- .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}
604
- .ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}
605
- .ui-datepicker-row-break{clear:both;width:100%;font-size:0}
606
- .ui-datepicker-rtl{direction:rtl}
607
- .ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}
608
- .ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}
609
- .ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}
610
- .ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}
611
- .ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}
612
- .ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}
613
- .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}
614
- .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}
615
- .ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}
616
- .ui-widget .ui-widget{font-size:1em}
617
- .ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}
618
- .ui-widget-content{border:1px solid #aaa;background:#fff 50% 50% repeat-x;color:#222}
619
- .ui-widget-content a{color:#222}
620
- .ui-widget-header{border:1px solid #aaa;background:#ddd 50% 50% repeat-x;color:#222;font-weight:700}
621
- .ui-widget-header a{color:#222}
622
- .ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:0 solid #d3d3d3;background:#e9e9e9 50% 50% repeat-x;font-weight:400;color:#555}
623
- .ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555;text-decoration:none}
624
- .ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:0 solid #999;background:#dadada 50% 50% repeat-x;font-weight:400;color:#212121}
625
- .ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#212121;text-decoration:none}
626
- .ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:0 solid #aaa;background:#fff 50% 50% repeat-x;font-weight:400;color:#212121}
627
- .ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}
628
- .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:0 solid #89b17e;background:#fbf9ee 50% 50% repeat-x;color:#363636}
629
- .ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}
630
- .ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:0 solid #cd0a0a;background:#fef1ec 50% 50% repeat-x;color:#cd0a0a}
631
- .ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#cd0a0a}
632
- .ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#cd0a0a}
633
- .ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:700}
634
- .ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:400}
635
- .ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}
636
- .ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}
637
- .ui-icon{width:16px;height:16px}
638
- .ui-icon,.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_222222_256x240.png)}
639
- .ui-widget-header .ui-icon{background-image:url(../images/ui-icons_222222_256x240.png)}
640
- .ui-state-default .ui-icon{background-image:url(../images/ui-icons_888888_256x240.png)}
641
- .ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_454545_256x240.png)}
642
- .ui-state-active .ui-icon{background-image:url(../images/ui-icons_454545_256x240.png)}
643
- .ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_2e83ff_256x240.png)}
644
- .ui-icon-circle-triangle-e{background-position:-48px -192px}
645
- .ui-icon-circle-triangle-s{background-position:-64px -192px}
646
- .ui-icon-circle-triangle-w{background-position:-80px -192px}
647
- .ui-icon-circle-triangle-n{background-position:-96px -192px}
648
- .ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:0}
649
- .ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:0}
650
- .ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:0}
651
- .ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:0}
652
- .ui-widget-overlay{background:#aaa 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30)}
653
- .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);border-radius:8px}
654
-
655
-
656
- .the-metabox.preview{
657
- float: none;
658
- }
659
- .metaboxes-tab .the-metabox.no-label.preview{
660
- margin-left: 184px;
661
- }
662
- .metaboxes-tab .the-metabox.no-label.preview img{
663
- box-shadow: 0 1px 8px rgba(0,0,0,0.2);
664
  }
1
+ /* self-clear floats */
2
+ .clearfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; overflow:hidden; }
3
+ /* ie.css */
4
+ * html .clearfix { /* IE6 */
5
+ height:1%;
6
+ }
7
+ *:first-child+html .clearfix { /* IE7 */
8
+ min-height:1%;
9
+ }
10
+
11
+ .clearboth { clear: both }
12
+
13
+ /* === TAB STYLE */
14
+ .metaboxes-tab { margin:-6px -12px -8px; }
15
+ .metaboxes-tab div.tabs-panel { height:auto; overflow:visible; margin-top:0px; padding:0 10px; background:none; border:0; border-top:1px solid #D4D4D4; }
16
+ .metaboxes-tab ul.metaboxes-tabs { background:#F5F5F5; margin:0; padding:10px 0 0 5px; }
17
+ .metaboxes-tab ul.metaboxes-tabs li { padding:8px 15px; border:1px solid #D4D4D4; float:left; background:#EDEDED; border-bottom-color:#EDEDED; margin:0 0 -1px 5px; box-shadow:1px 1px 1px 0 #FFFFFF inset; }
18
+ .metaboxes-tab ul.metaboxes-tabs li a { color:#555; text-decoration:none; }
19
+ .metaboxes-tab ul.metaboxes-tabs li.tabs { background:#F6F6F6; border-bottom:1px solid #F6F6F6; }
20
+ .metaboxes-tab p.field-row { margin:20px 0; }
21
+ .metaboxes-tab div.sep { height:1px; background:#DFDFDF; clear:both; margin-left:-10px; margin-right:-10px; }
22
+ .metaboxes-tab label { font-weight:bold; width:160px; float:left; line-height:23px; margin-left:-184px; }
23
+ .metaboxes-tab label small { font-weight:normal; line-height:15px; font-style:italic; color:#999; display:block; }
24
+ .metaboxes-tab input[type="text"], .metaboxes-tab select, .metaboxes-tab textarea { width:30%; }
25
+ .metaboxes-tab input[type="checkbox"] { vertical-align: middle }
26
+ .metaboxes-tab select {padding:0;}
27
+ .metaboxes-tab input.button-secondary, .metaboxes-tab input.checkbox { width:auto; }
28
+ .metaboxes-tab .description { color:#AFAFAF; font-size:90%; font-style:italic; line-height:23px; padding-left:5px; }
29
+ .metaboxes-tab p.field-row.textarea .description { vertical-align:top; }
30
+ .metaboxes-tab p.field-row.checkbox {background:none;}
31
+
32
+ .metaboxes-tab .the-metabox { margin:20px 0; margin-left:184px;}
33
+ .metaboxes-tab .the-metabox.no-label { margin:20px 0; margin-left:0;}
34
+ .metaboxes-tab hr { height: 0px; border-top: 1px solid #dadada; width: auto; margin-left: -10px; margin-right: -10px; }
35
+ .metaboxes-tab .the-metabox p { margin:0;}
36
+ .metaboxes-tab .the-metabox:last-child { border-bottom: 0px; }
37
+ .metaboxes-tab .the-metabox.checkbox { background:none; }
38
+ .metaboxes-tab .the-metabox.slider .ui-slider { margin-right:15px; }
39
+
40
+ .metaboxes-tab span.desc { font-size: 11px; color: #AFAFAF; }
41
+ .metaboxes-tab span.desc.inline { display: inline-block; vertical-align: top; line-height: 23px; }
42
+ .metaboxes-tab .onoff span.desc, .metaboxes-tab .onoff label { padding:6px 0; }
43
+ .metaboxes-tab .select span.desc, .metaboxes-tab .select label { padding:2px 0; }
44
+ .metaboxes-tab .slider span.desc, .metaboxes-tab .slider label { padding:15px 0; }
45
+ .metaboxes-tab .slider span.desc { display:block; padding:20px 0; }
46
+
47
+ .metaboxes-tab ul.metaboxes-tabs li {
48
+ -webkit-border-top-left-radius: 3px;
49
+ -webkit-border-top-right-radius: 3px;
50
+ -moz-border-radius-topleft: 3px;
51
+ -moz-border-radius-topright: 3px;
52
+ border-top-left-radius: 3px;
53
+ border-top-right-radius: 3px;
54
+ }
55
+
56
+ /* image gallery */
57
+ .metaboxes-tab .image-gallery ul li{
58
+ display: inline-block;
59
+ width: 80px;
60
+ margin-left: 10px;
61
+ position: relative;
62
+ }
63
+ .metaboxes-tab .image-gallery ul li img{
64
+ width: 80px;
65
+ border: 1px solid #ccc;
66
+ }
67
+ .metaboxes-tab .image-gallery ul li ul{
68
+ position: absolute;
69
+ top: -6px;
70
+ right: -1px;
71
+ width: 20px;
72
+ height: 20px;
73
+ }
74
+ .metaboxes-tab .image-gallery ul a.delete{
75
+ background: url(../images/x.png) no-repeat;
76
+ width: 20px;
77
+ height: 20px;
78
+ display: block;
79
+ text-indent: -99999px;
80
+ }
81
+ /* sidebar layout */
82
+ .yit-sidebar-layout input[type="radio"] {
83
+ display: none;
84
+ width: 0px;
85
+ }
86
+ .yit-sidebar-layout input[type="radio"]:first-child {
87
+ margin-right: -2px;
88
+ }
89
+
90
+ .yit-sidebar-layout input[type="radio"] + img {
91
+ border: 2px solid #fff;
92
+ padding: 1px;
93
+ }
94
+
95
+ .yit-sidebar-layout input[type="radio"] + img:hover {
96
+ cursor: pointer;
97
+ }
98
+
99
+ .yit-sidebar-layout input[checked] + img {
100
+ border: 2px solid #f2ad35;
101
+ padding: 1px;
102
+ }
103
+
104
+ .yit-sidebar-layout select {
105
+ vertical-align: 12px;
106
+ width: inherit !important;
107
+ }
108
+
109
+ /* wp editor */
110
+ .the-metabox.textarea-editor .mceIframeContainer {
111
+ background:#fff;
112
+ }
113
+ .the-metabox.textarea-editor label {
114
+ margin-top:24px;
115
+ }
116
+
117
+ /* categories */
118
+ .categories-panel { width:30%; float:left; margin-right:4px; }
119
+ .categories-panel .box { height:200px; border:1px solid #DFDFDF; background:#fff; padding:6px 10px; overflow: auto; }
120
+ .categories-panel ul { list-style:none; margin:0; }
121
+ .categories-panel ul li { line-height: 19px; margin: 0; padding: 0; word-wrap: break-word; }
122
+ .categories-panel ul li label { font-weight:normal !important; margin-left:0 !important; }
123
+ .categories-panel input.newcategory { width:100%; margin-bottom:3px; }
124
+
125
+ /* contact form */
126
+ .contactform_item {
127
+ border-style: solid;
128
+ border-width: 1px;
129
+ line-height: 1;
130
+ margin-bottom: 20px;
131
+ padding: 0;
132
+ background-color: #F5F5F5;
133
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
134
+ border-color: #DFDFDF;
135
+ border-radius: 3px 3px 3px 3px;
136
+ box-shadow: 0 1px 0 #FFFFFF inset;
137
+ min-width: 255px;
138
+ position: relative;
139
+ }
140
+ .contactform_item .handlediv { position:relative; top: -4px; }
141
+ .contactform_item h3 { min-height: 21px }
142
+ .contactform_item .inside { padding: 10px !important; }
143
+ .contactform_item .deps { display: none; }
144
+ .contactform_item .addoptions p.option { margin: 5px 0 5px 200px }
145
+ .contactform_item .addoptions p label { width: 80px !important; }
146
+ .contactform_item .add-field-option { margin-bottom: 10px !important; }
147
+ .remove_item { float: right; }
148
+ .metabox-sortable-placeholder { border: 1px dotted #dedede; margin: 10px 0 }
149
+
150
+ /* features tab */
151
+ .featurestab_item{
152
+ border-style: solid;
153
+ border-width: 1px;
154
+ line-height: 1;
155
+ margin-bottom: 20px;
156
+ padding: 0;
157
+ background-color: #F5F5F5;
158
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
159
+ border-color: #DFDFDF;
160
+ border-radius: 3px 3px 3px 3px;
161
+ box-shadow: 0 1px 0 #FFFFFF inset;
162
+ min-width: 255px;
163
+ position: relative;
164
+ }
165
+ .featurestab_item .handlediv { position:relative; top: -4px; }
166
+ .featurestab_item h3 { min-height: 21px }
167
+ .featurestab_item .inside { padding: 10px !important; }
168
+ .featurestab_item .deps { display: none; }
169
+ .featurestab_item .addoptions p.option { margin: 5px 0 5px 200px }
170
+ .featurestab_item .addoptions p label { width: 80px !important; }
171
+ .featurestab_item .add-field-option { margin-bottom: 10px !important; }
172
+
173
+ /* slider */
174
+ .the-metabox.slider { padding-top:20px; }
175
+
176
+ /* on off */
177
+ .the-metabox .rm_onoff span.onoff { float:left; margin-right:5px; margin-left:-4px; /* image fix */ }
178
+
179
+ /* onoff */
180
+ .rm_onoff input {
181
+ display: none;
182
+ }
183
+
184
+ .rm_onoff input + span {
185
+ cursor: pointer;
186
+ text-indent: -9999px;
187
+ display: block;
188
+ width: 85px;
189
+ height: 37px;
190
+ background: transparent url(../images/off.png);
191
+ }
192
+
193
+ .rm_onoff input:checked + span {
194
+ background: transparent url(../images/on.png);
195
+ }
196
+
197
+ .rm_onoff input.onoffchecked + span {
198
+ background: transparent url(../images/on.png);
199
+ }
200
+
201
+ .messages-panel.updated {
202
+ margin: 10px 0px 10px !important;
203
+ max-width: 1200px;
204
+ border-radius: 5px;
205
+ -webkit-box-sizing: border-box;
206
+ box-sizing: border-box;
207
+ }
208
+
209
+ .ui-widget-overlay { background-image: none !important; }
210
+
211
+
212
+
213
+ /* select */
214
+ .the-metabox .select_wrapper { width:341px; background-color:#fff; }
215
+ .the-metabox .select_wrapper select { width:100%; }
216
+ .the-metabox .icon_type{ width:30%; float: left; margin-right: 40px }
217
+ .the-metabox .icon_type select, .the-metabox div.option .select_wrapper select{ width: 100% }
218
+
219
+ #post-type-settings .category-list label { width: 187px; }
220
+ .remove_cat { float: right; text-align:center; display: block; width: 20px; height: 20px; border-radius: 20px; font-weight: bold; font-size: 10px; background: #efefef; text-decoration: none; }
221
+
222
+ .the-metabox .select_wrapper {
223
+ background: url("../images/select.png") no-repeat scroll right center #FAFAFA;
224
+ border-color: #CCCCCC #EEEEEE #EEEEEE #CCCCCC;
225
+ border-radius: 4px 4px 4px 4px;
226
+ border-style: solid;
227
+ border-width: 1px;
228
+ color: #555555;
229
+ display: block;
230
+ float: left;
231
+ font-family: sans-serif;
232
+ font-size: 12px;
233
+ min-height: 26px;
234
+ margin-bottom: 9px !important;
235
+ margin-left: 0;
236
+ margin-right: 5px;
237
+ margin-top: 0;
238
+ width: 400px;
239
+ position: relative;
240
+ }
241
+
242
+ /*chosen*/
243
+
244
+ .chosen .select_wrapper {
245
+ background: none;
246
+ border: none;
247
+ }
248
+ .chosen .select_wrapper .chosen-container{
249
+ width: 338px!important;
250
+ }
251
+ .chosen .select_wrapper .chosen-container .search-field input{
252
+ height: 27px!important;
253
+ color: #333;
254
+ }
255
+ .chosen .select_wrapper .chosen-container .chosen-choices{
256
+ border: 1px solid #ddd;
257
+ box-shadow: none;
258
+ }
259
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice{
260
+ height: 15px!important;
261
+ min-width: 105px;
262
+ }
263
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice span{
264
+ line-height: 15px;
265
+ height: 15px;
266
+ padding-top: 2px;
267
+ }
268
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice a.search-choice-close{
269
+ top: 5px;
270
+ }
271
+ .chosen .select_wrapper .chosen-container .chosen-drop .chosen-search input{
272
+ width: 100%!important;
273
+ }
274
+ .select_wrapper span {
275
+ height: 26px;
276
+ line-height: 26px;
277
+ padding-left: 6px;
278
+ position: absolute;
279
+ z-index: 2;
280
+ overflow: hidden;
281
+ }
282
+
283
+ .the-metabox .select_wrapper select {
284
+ cursor: pointer;
285
+ height: 28px;
286
+ margin: 0;
287
+ opacity: 0;
288
+ padding: 0;
289
+ position: relative;
290
+ width: inherit;
291
+ z-index: 4;
292
+ background-color: #FAFAFA;
293
+ }
294
+
295
+
296
+ /* typography */
297
+ .the-metabox.typography .select_wrapper.font-family { width:200px; }
298
+ .the-metabox.typography .spinner_container { float:left; margin-right:10px; }
299
+ .the-metabox.typography .spinner_container input.number {
300
+ width:50px !important;
301
+ -webkit-border-top-right-radius: 0px;
302
+ -webkit-border-bottom-right-radius: 0px;
303
+ -moz-border-radius-topright: 0px;
304
+ -moz-border-radius-bottomright: 0px;
305
+ border-top-right-radius: 0px;
306
+ border-bottom-right-radius: 0px;
307
+ }
308
+
309
+ /* number */
310
+ .the-metabox.number input.number { width:50px !important; }
311
+ /* number */
312
+ .rm_number .number {
313
+ width: 70px;
314
+ text-align: right;
315
+ -webkit-border-top-right-radius: 0px;
316
+ -webkit-border-bottom-right-radius: 0px;
317
+ -moz-border-radius-topright: 0px;
318
+ -moz-border-radius-bottomright: 0px;
319
+ border-top-right-radius: 0px;
320
+ border-bottom-right-radius: 0px;
321
+ }
322
+
323
+ .spinner-wrapper { position: relative; height: 23px; overflow: hidden; }
324
+ .spinner-wrapper input.number { float: left; }
325
+ .spinner-wrapper .spinner-button { cursor:pointer; float: left; position: absolute; left: 69px; width: 15px; height: 12px; border: 1px solid #DFDFDF; background: #fff; margin: 0; padding: 0; line-height: 9999px; overflow: hidden; background: url('../images/spinner.png') no-repeat center -11px }
326
+ .spinner-wrapper .spinner-button.button-plus { top: 0; -webkit-border-top-right-radius: 3px !important; -moz-border-radius-topright: 3px !important; border-top-right-radius: 3px !important; }
327
+ .spinner-wrapper .spinner-button.button-minus { bottom: 0; background-position: center -30px; -webkit-border-bottom-right-radius: 3px !important; -moz-border-radius-bottomright: 3px !important; border-bottom-right-radius: 3px !important; }
328
+
329
+
330
+ .spinner-wrapper .spinner-button.button-plus:active { background-position: center 0px; }
331
+ .spinner-wrapper .spinner-button.button-minus:active { background-position: center -20px; }
332
+
333
+
334
+ .rm_typography .spinner_container { float: left; margin-right: 10px; }
335
+ .rm_typography .spinner-wrapper { height: 28px; }
336
+ .rm_typography .spinner-wrapper input.number { height: 28px; }
337
+ .rm_typography .spinner-wrapper .spinner-button.button-plus { height: 15px; background-position: center -10px; }
338
+ .rm_typography .spinner-wrapper .spinner-button.button-minus { height: 14px; }
339
+
340
+ .the-metabox .spinner-wrapper .spinner-button { left: 49px; }
341
+ .the-metabox.typography .spinner-wrapper .spinner-button { left: 35px; }
342
+
343
+ /* colorpicker */
344
+ .the-metabox.colorpicker { display:block; width: auto; height: auto; overflow: visible; background-image: none; position: static; font-family: inherit;}
345
+ .the-metabox.colorpicker input { background-color: transparent; border: 1px solid #DFDFDF; position: static; font-size: inherit; font-family: inherit; color: inherit; text-align: center; margin: 0 5px 0px; padding: 0; outline: none; width: auto; }
346
+
347
+ /* images */
348
+ .the-metabox.images, .the-metabox.images label { margin-left:0; display:block; }
349
+ .the-metabox.images .slides-wrapper { clear:both; }
350
+ .the-metabox.images .slides-wrapper li { position:relative; }
351
+ .the-metabox.images a.delete { display:block; margin-left:4px; text-decoration:none; font-weight:bold; color:red; position:absolute; top:0; right:0; width:10px; height:18px; z-index:10; cursor:pointer !important; }
352
+
353
+ /* wp editor */
354
+ .wp_themeSkin iframe { background: #fff !important; }
355
+
356
+ /* custom tabs */
357
+ .customtab_item {
358
+ border-style: solid;
359
+ border-width: 1px;
360
+ line-height: 1;
361
+ margin-bottom: 20px;
362
+ padding: 0;
363
+ background-color: #F5F5F5;
364
+ background-image: -moz-linear-gradient(center top , #F9F9F9, #F5F5F5);
365
+ border-color: #DFDFDF;
366
+ border-radius: 3px 3px 3px 3px;
367
+ box-shadow: 0 1px 0 #FFFFFF inset;
368
+ min-width: 255px;
369
+ position: relative;
370
+ }
371
+ .customtab_item .handlediv { position:relative; top: -4px; }
372
+ .customtab_item h3 { min-height: 21px }
373
+ .customtab_item .inside { padding: 10px !important; }
374
+ .customtab_item .deps { display: none; }
375
+ .customtab_item .addoptions p.option { margin: 5px 0 5px 200px }
376
+ .customtab_item .addoptions p label { width: 80px !important; }
377
+ .customtab_item .add-field-option { margin-bottom: 10px !important; }
378
+ .customtab_item .remove_item { float: right; }
379
+ .metabox-sortable-placeholder { border: 1px dotted #dedede; margin: 10px 0 }
380
+
381
+ .the-metabox.customtabs {
382
+ margin-left: 0;
383
+ }
384
+
385
+ #customtab_item_sample {
386
+ display: none;
387
+ }
388
+
389
+ .the-metabox.customtabs .field-row {
390
+ margin-bottom: 10px;
391
+ }
392
+
393
+ #yit_custom_tabs label {
394
+ font-weight: normal;
395
+ width: auto;
396
+ float: none;
397
+ line-height: auto;
398
+ margin-left: 0;
399
+ }
400
+
401
+
402
+ .wp-admin p label input[type=radio]{
403
+ width: 16px;
404
+ margin-right: 10px;
405
+ margin-top: 3px;
406
+ }
407
+ .wp-admin .form-field._preset_onsale_icon_field label input[type=radio]{
408
+ margin-top: 0;
409
+ }
410
+
411
+ .the-metabox .spinner {
412
+ margin-top: 5px;
413
+ float: none;
414
+ }
415
+
416
+ /* slider */
417
+ /*numbers*/
418
+ .ui-slider .maxCaption, .ui-slider .minCaption {
419
+ margin-bottom: 5px;
420
+ }
421
+ .ui-slider .feedback {
422
+ background: url(../images/slider/tooltip.png) no-repeat center top;
423
+ position: absolute;
424
+ top: -25px;
425
+ width: 35px;
426
+ height: 43px;
427
+ text-align: center;
428
+ width: 100%;
429
+ display: block;
430
+ }
431
+ .ui-slider .feedback strong {
432
+ display: inline-block;
433
+ padding-top: 4px;
434
+ top: -30px;
435
+ }
436
+ /*handle*/
437
+ .ui-slider-horizontal .ui-slider-handle{
438
+ background: transparent url(../images/slider/handle.png) no-repeat left top !important;
439
+ border: 0px !important;
440
+ top: -.35em !important;
441
+ width: 18px !important;
442
+ height: 19px !important;
443
+ }
444
+
445
+ /*bg on the left:grey*/
446
+ .ui-slider.ui-widget-content {
447
+ background: url(../images/slider/grey.gif) repeat-x left center !important;
448
+ border-color: #c1c1c0 !important;
449
+ height: 10px !important;
450
+ }
451
+
452
+ .iris-slider-offset.ui-slider.ui-widget-content {
453
+ background: transparent!important;
454
+ height: auto!important;
455
+ }
456
+
457
+ /*bg on the right:orange*/
458
+ .ui-slider.ui-widget-content .ui-widget-header {
459
+ background: url(../images/slider/orange.gif) repeat-x left center !important;
460
+ left: 2px !important;
461
+ -webkit-border-radius: 15px;
462
+ -moz-border-radius: 15px;
463
+ -khtml-border-radius: 15px;
464
+ border-radius: 15px;
465
+ }
466
+
467
+
468
+ /*sidebars*/
469
+
470
+ #choose-sidebars.choose{
471
+ margin-left: 0px;
472
+ }
473
+
474
+
475
+ #_active_page_options-container label, #_active_page_options-container p{
476
+ display: inline-block;
477
+ margin: 0px;
478
+ }
479
+ #_active_page_options-container label{
480
+ margin-right: 10px;
481
+ margin-top: 3px;
482
+ }
483
+ #_active_page_options-container {
484
+ float: right;
485
+ margin-right: 20px;
486
+ margin-top: 5px;
487
+ }
488
+
489
+ /* sortable table posts */
490
+
491
+ #the-list.ui-sortable tr:hover {
492
+ cursor: move;
493
+ }
494
+
495
+
496
+ /*datepicker*/
497
+ /*! jQuery UI - v1.11.2 - 2015-01-21
498
+ * http://jqueryui.com
499
+ * Includes: core.css, datepicker.css, theme.css
500
+ * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Verdana%2CArial%2Csans-serif&fwDefault=normal&fsDefault=1.1em&cornerRadius=0px&bgColorHeader=%23dddddd&bgTextureHeader=flat&bgImgOpacityHeader=60&borderColorHeader=%23aaaaaa&fcHeader=%23222222&iconColorHeader=%23222222&bgColorContent=%23ffffff&bgTextureContent=flat&bgImgOpacityContent=75&borderColorContent=%23aaaaaa&fcContent=%23222222&iconColorContent=%23222222&bgColorDefault=%23e9e9e9&bgTextureDefault=flat&bgImgOpacityDefault=75&borderColorDefault=%23d3d3d3&fcDefault=%23555555&iconColorDefault=%23888888&bgColorHover=%23dadada&bgTextureHover=flat&bgImgOpacityHover=75&borderColorHover=%23999999&fcHover=%23212121&iconColorHover=%23454545&bgColorActive=%23ffffff&bgTextureActive=glass&bgImgOpacityActive=65&borderColorActive=%23aaaaaa&fcActive=%23212121&iconColorActive=%23454545&bgColorHighlight=%23fbf9ee&bgTextureHighlight=glass&bgImgOpacityHighlight=55&borderColorHighlight=%2389b17e&fcHighlight=%23363636&iconColorHighlight=%232e83ff&bgColorError=%23fef1ec&bgTextureError=glass&bgImgOpacityError=95&borderColorError=%23cd0a0a&fcError=%23cd0a0a&iconColorError=%23cd0a0a&bgColorOverlay=%23aaaaaa&bgTextureOverlay=flat&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=%23aaaaaa&bgTextureShadow=flat&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px
501
+ * Copyright 2015 jQuery Foundation and other contributors; Licensed MIT */
502
+
503
+ /* Layout helpers
504
+ ----------------------------------*/
505
+ .ui-helper-hidden {
506
+ display: none;
507
+ }
508
+ .ui-helper-hidden-accessible {
509
+ border: 0;
510
+ clip: rect(0 0 0 0);
511
+ height: 1px;
512
+ margin: -1px;
513
+ overflow: hidden;
514
+ padding: 0;
515
+ position: absolute;
516
+ width: 1px;
517
+ }
518
+ .ui-helper-reset {
519
+ margin: 0;
520
+ padding: 0;
521
+ border: 0;
522
+ outline: 0;
523
+ line-height: 1.3;
524
+ text-decoration: none;
525
+ font-size: 100%;
526
+ list-style: none;
527
+ }
528
+ .ui-helper-clearfix:before,
529
+ .ui-helper-clearfix:after {
530
+ content: "";
531
+ display: table;
532
+ border-collapse: collapse;
533
+ }
534
+ .ui-helper-clearfix:after {
535
+ clear: both;
536
+ }
537
+ .ui-helper-clearfix {
538
+ min-height: 0; /* support: IE7 */
539
+ }
540
+ .ui-helper-zfix {
541
+ width: 100%;
542
+ height: 100%;
543
+ top: 0;
544
+ left: 0;
545
+ position: absolute;
546
+ opacity: 0;
547
+ filter:Alpha(Opacity=0); /* support: IE8 */
548
+ }
549
+
550
+ .ui-front {
551
+ z-index: 100;
552
+ }
553
+
554
+
555
+ /* Interaction Cues
556
+ ----------------------------------*/
557
+ .ui-state-disabled {
558
+ cursor: default !important;
559
+ }
560
+
561
+
562
+ /* Icons
563
+ ----------------------------------*/
564
+
565
+ /* states and images */
566
+ .ui-icon {
567
+ display: block;
568
+ text-indent: -99999px;
569
+ overflow: hidden;
570
+ background-repeat: no-repeat;
571
+ }
572
+
573
+
574
+ /* DATE PICKER
575
+ ----------------------------------*/
576
+
577
+ .ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}
578
+ .ui-datepicker{width:17em;padding:.2em .2em 0;display:none;z-index:100!important;}
579
+ .ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}
580
+ .ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}
581
+ .ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}
582
+ .ui-datepicker .ui-datepicker-prev{left:2px}
583
+ .ui-datepicker .ui-datepicker-next{right:2px}
584
+ .ui-datepicker .ui-datepicker-prev-hover{left:1px}
585
+ .ui-datepicker .ui-datepicker-next-hover{right:1px}
586
+ .ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}
587
+ .ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}
588
+ .ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}
589
+ .ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:45%}
590
+ .ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}
591
+ .ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:700;border:0}
592
+ .ui-datepicker td{border:0;padding:1px}
593
+ .ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}
594
+ .ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}
595
+ .ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em;width:auto;overflow:visible}
596
+ .ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}
597
+ .ui-datepicker.ui-datepicker-multi{width:auto}
598
+ .ui-datepicker-multi .ui-datepicker-group{float:left}
599
+ .ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}
600
+ .ui-datepicker-multi-2 .ui-datepicker-group{width:50%}
601
+ .ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}
602
+ .ui-datepicker-multi-4 .ui-datepicker-group{width:25%}
603
+ .ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}
604
+ .ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}
605
+ .ui-datepicker-row-break{clear:both;width:100%;font-size:0}
606
+ .ui-datepicker-rtl{direction:rtl}
607
+ .ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}
608
+ .ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}
609
+ .ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}
610
+ .ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}
611
+ .ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}
612
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}
613
+ .ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}
614
+ .ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}
615
+ .ui-widget{font-family:Verdana,Arial,sans-serif;font-size:1.1em}
616
+ .ui-widget .ui-widget{font-size:1em}
617
+ .ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:Verdana,Arial,sans-serif;font-size:1em}
618
+ .ui-widget-content{border:1px solid #aaa;background:#fff 50% 50% repeat-x;color:#222}
619
+ .ui-widget-content a{color:#222}
620
+ .ui-widget-header{border:1px solid #aaa;background:#ddd 50% 50% repeat-x;color:#222;font-weight:700}
621
+ .ui-widget-header a{color:#222}
622
+ .ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:0 solid #d3d3d3;background:#e9e9e9 50% 50% repeat-x;font-weight:400;color:#555}
623
+ .ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#555;text-decoration:none}
624
+ .ui-state-hover,.ui-widget-content .ui-state-hover,.ui-widget-header .ui-state-hover,.ui-state-focus,.ui-widget-content .ui-state-focus,.ui-widget-header .ui-state-focus{border:0 solid #999;background:#dadada 50% 50% repeat-x;font-weight:400;color:#212121}
625
+ .ui-state-hover a,.ui-state-hover a:hover,.ui-state-hover a:link,.ui-state-hover a:visited,.ui-state-focus a,.ui-state-focus a:hover,.ui-state-focus a:link,.ui-state-focus a:visited{color:#212121;text-decoration:none}
626
+ .ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:0 solid #aaa;background:#fff 50% 50% repeat-x;font-weight:400;color:#212121}
627
+ .ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#212121;text-decoration:none}
628
+ .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:0 solid #89b17e;background:#fbf9ee 50% 50% repeat-x;color:#363636}
629
+ .ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#363636}
630
+ .ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:0 solid #cd0a0a;background:#fef1ec 50% 50% repeat-x;color:#cd0a0a}
631
+ .ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#cd0a0a}
632
+ .ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#cd0a0a}
633
+ .ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:700}
634
+ .ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:400}
635
+ .ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}
636
+ .ui-state-disabled .ui-icon{filter:Alpha(Opacity=35)}
637
+ .ui-icon{width:16px;height:16px}
638
+ .ui-icon,.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_222222_256x240.png)}
639
+ .ui-widget-header .ui-icon{background-image:url(../images/ui-icons_222222_256x240.png)}
640
+ .ui-state-default .ui-icon{background-image:url(../images/ui-icons_888888_256x240.png)}
641
+ .ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_454545_256x240.png)}
642
+ .ui-state-active .ui-icon{background-image:url(../images/ui-icons_454545_256x240.png)}
643
+ .ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_2e83ff_256x240.png)}
644
+ .ui-icon-circle-triangle-e{background-position:-48px -192px}
645
+ .ui-icon-circle-triangle-s{background-position:-64px -192px}
646
+ .ui-icon-circle-triangle-w{background-position:-80px -192px}
647
+ .ui-icon-circle-triangle-n{background-position:-96px -192px}
648
+ .ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{border-top-left-radius:0}
649
+ .ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{border-top-right-radius:0}
650
+ .ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{border-bottom-left-radius:0}
651
+ .ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{border-bottom-right-radius:0}
652
+ .ui-widget-overlay{background:#aaa 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30)}
653
+ .ui-widget-shadow{margin:-8px 0 0 -8px;padding:8px;background:#aaa 50% 50% repeat-x;opacity:.3;filter:Alpha(Opacity=30);border-radius:8px}
654
+
655
+
656
+ .the-metabox.preview{
657
+ float: none;
658
+ }
659
+ .metaboxes-tab .the-metabox.no-label.preview{
660
+ margin-left: 184px;
661
+ }
662
+ .metaboxes-tab .the-metabox.no-label.preview img{
663
+ box-shadow: 0 1px 8px rgba(0,0,0,0.2);
664
  }
plugin-fw/assets/css/yit-plugin-panel-sidebar.css ADDED
@@ -0,0 +1,377 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This file belongs to the YIT Plugin Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+ /* === Panel Sidebar === */
11
+ #yit-panel-sidebar {
12
+ width : 275px;
13
+ float : right;
14
+ margin : 10px 0 0 10px;
15
+ }
16
+
17
+ #yit-panel-sidebar.yith-panel-sidebar-hidden {
18
+ position : absolute;
19
+ top : 0;
20
+ right : 0;
21
+ }
22
+
23
+ #yit-panel-sidebar.yith-panel-sidebar-hidden #yit-panel-sidebar-widgets-container{
24
+ display: none;
25
+ }
26
+
27
+ .yit-panel-sidebar-widget-wrapper {
28
+ position : relative;
29
+ margin : 10px 0 30px 0;
30
+ }
31
+
32
+ .yit-panel-sidebar-widget-container {
33
+ border-radius : 5px;
34
+ border : 1px solid #ddd;
35
+ background : #fff;
36
+ box-shadow : 0 2px 1px -1px #ccc;
37
+ overflow : hidden;
38
+ }
39
+
40
+ .yit-panel-sidebar-widget-container a {
41
+ text-decoration : none;
42
+ }
43
+
44
+ .yit-panel-sidebar-widget-container img.yit-panel-sidebar-widget-image {
45
+ width : 100%;
46
+ position : relative;
47
+ bottom : -5px;
48
+ }
49
+
50
+ .yit-panel-sidebar-widget-title {
51
+ padding : 12px 10px;
52
+ background : #f4f4f4;
53
+ font-size : 10px;
54
+ text-transform : uppercase;
55
+ font-weight : 700;
56
+ }
57
+
58
+ .yit-panel-sidebar-widget-title.dashicons {
59
+ width : auto !important;
60
+ height : auto !important;
61
+ display : block;
62
+ font-family : "Open Sans", sans-serif;
63
+ text-align : left;
64
+ }
65
+
66
+ .yit-panel-sidebar-widget-title.dashicons::before {
67
+ font-family : "Dashicons";
68
+ font-size : 18px;
69
+ display : inline-block;
70
+ vertical-align : middle;
71
+ margin-right : 10px;
72
+ font-weight : normal;
73
+ }
74
+
75
+ .yit-panel-sidebar-widget-title.orange {
76
+ background : #ff643e;
77
+ color : #fff;
78
+ }
79
+
80
+ .yit-panel-sidebar-widget-title.green {
81
+ background : #a3c401;
82
+ color : #fff;
83
+ }
84
+
85
+ .yit-panel-sidebar-widget-title.red {
86
+ background : #e4313c;
87
+ color : #fff;
88
+ }
89
+
90
+ .yit-panel-sidebar-widget-title.yellow {
91
+ background : #ffc400;
92
+ color : #333;
93
+ }
94
+
95
+ .yit-panel-sidebar-widget-title.center {
96
+ text-align : center;
97
+ }
98
+
99
+ .yit-panel-sidebar-widget-title.right {
100
+ text-align : right;
101
+ }
102
+
103
+ .yit-panel-sidebar-widget-content {
104
+ padding : 15px;
105
+ }
106
+
107
+ .yit-panel-sidebar-widget-content p {
108
+ font-size : 11px;
109
+ line-height : 18px;
110
+ margin : 0;
111
+ text-align : justify;
112
+ }
113
+
114
+ .yit-panel-sidebar-widget-badge.gift-tape {
115
+ color : #000;
116
+ font-family : "Open Sans", sans-serif;
117
+ box-sizing : border-box;
118
+ position : absolute;
119
+ background-color : transparent;
120
+ width : 70px;
121
+ height : 70px;
122
+ overflow : hidden;
123
+ top : 0;
124
+ right : 0;
125
+ }
126
+
127
+ .yit-panel-sidebar-widget-badge.gift-tape div.yit-panel-sidebar-widget-badge-text {
128
+ background : #ffd600;
129
+ background : -webkit-linear-gradient(left, #fe8502, #ffe400); /* For Safari 5.1 to 6.0 */
130
+ background : -o-linear-gradient(right, #fe8502, #ffe400); /* For Opera 11.1 to 12.0 */
131
+ background : -moz-linear-gradient(right, #fe8502, #ffe400); /* For Firefox 3.6 to 15 */
132
+ background : linear-gradient(to right, #fe8502, #ffe400); /* Standard syntax */
133
+ font-size : 10px;
134
+ font-weight : bold;
135
+ line-height : 24px;
136
+ position : absolute;
137
+ text-align : center;
138
+ z-index : 100;
139
+ -webkit-transform : rotate(45deg);
140
+ -ms-transform : rotate(45deg);
141
+ transform : rotate(45deg);
142
+ top : 15px;
143
+ left : -6px;
144
+ width : 100px;
145
+ text-shadow : 1px 1px 1px #fff;
146
+ }
147
+
148
+ img.yit-panel-sidebar-widget-despacho-image {
149
+ background : #ffffff;
150
+ background : -webkit-linear-gradient(#ffffff, #a5b7c5); /* For Safari 5.1 to 6.0 */
151
+ background : -o-linear-gradient(#ffffff, #a5b7c5); /* For Opera 11.1 to 12.0 */
152
+ background : -moz-linear-gradient(#ffffff, #a5b7c5); /* For Firefox 3.6 to 15 */
153
+ background : linear-gradient(#ffffff, #a5b7c5); /* Standard syntax */
154
+ }
155
+
156
+ /* ==== Buttons ==== */
157
+ #yit-panel-sidebar .button {
158
+ color : #ffffff;
159
+ border : none;
160
+ background : #666666;
161
+ -webkit-box-shadow : none;
162
+ box-shadow : none;
163
+ vertical-align : middle;
164
+ text-transform : uppercase;
165
+ font-size : 11px;
166
+ font-weight : 700;
167
+ height : 32px;
168
+ line-height : 32px;
169
+ padding : 0 18px 1px;
170
+ }
171
+
172
+ #yit-panel-sidebar .button.orange {
173
+ background : #ff6340;
174
+ }
175
+
176
+ #yit-panel-sidebar .button.green {
177
+ background : #a3c401;
178
+ }
179
+
180
+ #yit-panel-sidebar .button.red {
181
+ background : #e4313c;
182
+ }
183
+
184
+ #yit-panel-sidebar .button.yellow {
185
+ background : #ffc400;
186
+ }
187
+
188
+ /* === Title Icons === */
189
+ #yit-panel-sidebar .yit-panel-sidebar-widget-icon:before {
190
+ content : " ";
191
+ width : 16px;
192
+ height : 16px;
193
+ display : inline-block;
194
+ vertical-align : middle;
195
+ margin-right : 10px;
196
+ }
197
+
198
+ #yit-panel-sidebar .yit-panel-sidebar-widget-icon.link-icon:before {
199
+ background : transparent url('../images/widgets/link-icon.png') no-repeat;
200
+ background-size : contain;
201
+ }
202
+
203
+ #yit-panel-sidebar .yit-panel-sidebar-widget-icon.info-icon:before {
204
+ background : transparent url('../images/widgets/info-icon.png') no-repeat;
205
+ background-size : contain;
206
+ }
207
+
208
+ #yit-panel-sidebar .yit-panel-sidebar-widget-icon.box-icon:before {
209
+ background : transparent url('../images/widgets/box-icon.png') no-repeat;
210
+ background-size : contain;
211
+ }
212
+
213
+ #yit-panel-sidebar .yit-panel-sidebar-widget-icon.box-white-icon:before {
214
+ background : transparent url('../images/widgets/box-white-icon.png') no-repeat;
215
+ background-size : contain;
216
+ }
217
+
218
+ /* ==== Membership Widget ==== */
219
+ #yit-panel-sidebar-membership-widget {
220
+
221
+ }
222
+
223
+ #yit-panel-sidebar-membership-widget .yit-panel-sidebar-widget-title {
224
+ text-align : center;
225
+ }
226
+
227
+ #yit-panel-sidebar-membership-widget .yit-panel-sidebar-widget-content {
228
+ background : transparent url('../images/widgets/membership-bg.png') no-repeat;
229
+ background-position : 100% 180%;
230
+ background-size : 50%;
231
+ }
232
+
233
+ #yit-panel-sidebar-membership-widget .membership-total-price {
234
+ font-size : 25px;
235
+ font-weight : 700;
236
+ display : inline-block;
237
+
238
+ }
239
+
240
+ #yit-panel-sidebar-membership-widget .membership-offer-text {
241
+ display : inline-block;
242
+ font-size : 10px;
243
+ text-transform : uppercase;
244
+ width : 130px;
245
+ line-height : 14px;
246
+ }
247
+
248
+ #yit-panel-sidebar-membership-widget .membership-offer-text2 {
249
+ display : inline-block;
250
+ font-size : 10px;
251
+ text-transform : uppercase;
252
+ width : 36%;
253
+ text-align : right;
254
+ vertical-align : middle;
255
+ margin : 17px 0;
256
+ }
257
+
258
+ #yit-panel-sidebar-membership-widget .membership-offer-sale-text {
259
+ display : inline-block;
260
+ font-size : 24px;
261
+ color : #ff6340;
262
+ text-transform : uppercase;
263
+ width : 55%;
264
+ text-align : left;
265
+ vertical-align : middle;
266
+ margin : 17px 0;
267
+ font-weight : 700;
268
+ }
269
+
270
+ #yit-panel-sidebar-membership-widget .membership-buttons {
271
+ text-align : center;
272
+ margin-bottom : 10px;
273
+ }
274
+
275
+ /* ==== Important Links Widget ==== */
276
+ #yit-panel-sidebar-links-widget .yit-panel-sidebar-widget-content {
277
+ background : transparent url('../images/widgets/link-bg.png') no-repeat;
278
+ background-position : 110% 120%;
279
+ background-size : 50%;
280
+ }
281
+
282
+ ul.yit-panel-sidebar-links-list {
283
+ margin : 0;
284
+ }
285
+
286
+ ul.yit-panel-sidebar-links-list li {
287
+ margin : 0 0 10px 0;
288
+ }
289
+
290
+ ul.yit-panel-sidebar-links-list li:before {
291
+ content : " ";
292
+ width : 15px;
293
+ height : 13px;
294
+ display : inline-block;
295
+ background : transparent url('../images/ui-icons_454545_256x240.png') no-repeat -64px -144px;
296
+ margin-right : 7px;
297
+ }
298
+
299
+ /* === Sidebar Actions ===*/
300
+ #yit-panel-sidebar-actions {
301
+ text-align : right;
302
+ }
303
+
304
+ .yit-panel-sidebar-action-title {
305
+ margin-right : 5px;
306
+ text-transform : uppercase;
307
+ font-size : 11px;
308
+ }
309
+
310
+ #yit-panel-sidebar-action-hide {
311
+ text-align : right;
312
+ cursor : pointer;
313
+ }
314
+
315
+ .yit-panel-sidebar-action-hide-icon {
316
+ color : #f4f4f4;
317
+ background : #565656;
318
+ border-radius : 50%;
319
+ }
320
+
321
+ #yit-panel-sidebar-action-hide:hover .yit-panel-sidebar-action-title{
322
+ color: #000;
323
+ }
324
+
325
+ #yit-panel-sidebar-action-hide:hover .yit-panel-sidebar-action-hide-icon{
326
+ background: #000;
327
+ }
328
+
329
+ .hide-on-click .yit-panel-sidebar-action-hide-icon:before {
330
+ content : "\f139" !important;
331
+ }
332
+
333
+ /* === Responsive === */
334
+
335
+ @media (min-width : 767px) {
336
+ #wpbody-content #yit-panel-sidebar {
337
+ margin-right : 15px;
338
+ }
339
+ }
340
+
341
+ @media (max-width : 767px) {
342
+ #yit-panel-sidebar {
343
+ width : 275px;
344
+ margin : 20px auto 0 auto;
345
+ float : none;
346
+ display : block;
347
+ }
348
+
349
+ #yit-panel-sidebar.yith-panel-sidebar-hidden {
350
+ position : static;
351
+ }
352
+
353
+ #yit-panel-sidebar-actions {
354
+ text-align : center;
355
+ }
356
+
357
+ #yit-panel-sidebar-action-hide {
358
+ text-align : center;
359
+ }
360
+ }
361
+
362
+ @media (max-width : 480px) {
363
+
364
+ }
365
+
366
+ @media (min-width : 768px) and (max-width : 992px) {
367
+ }
368
+
369
+ @media (min-width : 980px) and (max-width : 1199px) {
370
+ }
371
+
372
+ @media (min-width : 1200px) {
373
+
374
+ }
375
+
376
+ @media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (-o-min-device-pixel-ratio : 3/2), only screen and (min--moz-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {
377
+ }
plugin-fw/assets/css/yit-plugin-panel.css CHANGED
@@ -1,664 +1,713 @@
1
- /*
2
- * This file belongs to the YIT Plugin Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
- /* onoff */
11
- .rm_onoff input {
12
- display: none;
13
- }
14
-
15
- .rm_onoff input + span {
16
- cursor: pointer;
17
- text-indent: -9999px;
18
- display: block;
19
- width: 85px;
20
- height: 37px;
21
- background: transparent url(../images/off.png);
22
- }
23
-
24
- .rm_onoff input:checked + span {
25
- background: transparent url(../images/on.png);
26
- }
27
-
28
- .rm_onoff input.onoffchecked + span {
29
- background: transparent url(../images/on.png);
30
- }
31
-
32
- /* slider */
33
- /*numbers*/
34
- .ui-slider .maxCaption, .ui-slider .minCaption {
35
- margin-bottom: 5px;
36
- }
37
- .ui-slider .feedback {
38
- background: url(../images/slider/tooltip.png) no-repeat center top;
39
- position: absolute;
40
- top: -25px;
41
- width: 35px;
42
- height: 43px;
43
- text-align: center;
44
- width: 100%;
45
- display: block;
46
- }
47
- .ui-slider .feedback strong {
48
- display: inline-block;
49
- padding-top: 4px;
50
- top: -30px;
51
- }
52
- /*handle*/
53
- .yit-options .ui-slider-horizontal .ui-slider-handle,
54
- .yit_options .ui-slider-horizontal .ui-slider-handle {
55
- background: transparent url(../images/slider/handle.png) no-repeat left top !important;
56
- border: 0px !important;
57
- top: -.35em !important;
58
- width: 18px !important;
59
- height: 19px !important;
60
- }
61
-
62
- /*bg on the left:grey*/
63
- .yit-options .ui-slider.ui-widget-content,
64
- .yit_options .ui-slider.ui-widget-content {
65
- background: url(../images/slider/grey.gif) repeat-x left center !important;
66
- border-color: #c1c1c0 !important;
67
- height: 10px !important;
68
- }
69
-
70
- .iris-slider-offset.ui-slider.ui-widget-content {
71
- background: transparent!important;
72
- height: auto!important;
73
- }
74
-
75
- /*bg on the right:orange*/
76
- .ui-slider.ui-widget-content .ui-widget-header {
77
- background: url(../images/slider/orange.gif) repeat-x left center !important;
78
- left: 2px !important;
79
- -webkit-border-radius: 15px;
80
- -moz-border-radius: 15px;
81
- -khtml-border-radius: 15px;
82
- border-radius: 15px;
83
- }
84
-
85
- .plugin-option tr{
86
- border-bottom: 1px solid #ccc;
87
- }
88
- .plugin-option .yit_options,
89
- .plugin-option .yit-options{
90
- border-bottom: 0px;
91
- }
92
- .plugin-option .yit-options .option,
93
- .plugin-option .yit_options .option {
94
- width: 600px;
95
- float: left;
96
- }
97
-
98
- .plugin-option .form-table td{
99
- padding: 25px 10px;
100
- }
101
-
102
- .yit_options .select_wrapper,
103
- .yit-options .select_wrapper {
104
- background: url("../images/select.png") no-repeat scroll right center #FAFAFA;
105
- border-color: #CCCCCC #EEEEEE #EEEEEE #CCCCCC;
106
- border-radius: 4px 4px 4px 4px;
107
- border-style: solid;
108
- border-width: 1px;
109
- color: #555555;
110
- display: block;
111
- float: left;
112
- font-family: sans-serif;
113
- font-size: 12px;
114
- height: 26px;
115
- margin-bottom: 9px !important;
116
- margin-left: 0;
117
- margin-right: 5px;
118
- margin-top: 0;
119
- width: 400px;
120
- }
121
- .chosen .select_wrapper {
122
- background: none;
123
- border: none;
124
- }
125
- .chosen .select_wrapper .chosen-container{
126
- width: 338px!important;
127
- }
128
- .chosen .select_wrapper .chosen-container .search-field input{
129
- height: 27px!important;
130
- color: #333;
131
- }
132
- .chosen .select_wrapper .chosen-container .chosen-choices{
133
- border: 1px solid #ddd;
134
- box-shadow: none;
135
- }
136
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice{
137
- height: 15px!important;
138
- min-width: 105px;
139
- }
140
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice span{
141
- line-height: 15px;
142
- height: 15px;
143
- padding-top: 2px;
144
- }
145
- .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice a.search-choice-close{
146
- top: 5px;
147
- }
148
- .chosen .select_wrapper .chosen-container .chosen-drop .chosen-search input{
149
- width: 100%!important;
150
- }
151
-
152
- /* === Multiple Chosen Customizzation === */
153
-
154
- .yith-choosen .chosen-choices {
155
- line-height: 27px;
156
- min-height: 27px;
157
- border: 1px solid #ddd;
158
- }
159
-
160
- .yith-choosen .chosen-container-active .chosen-choices{
161
- border: 1px solid #5b9dd9;
162
- -webkit-box-shadow: 0 0 2px rgba(30,140,190,.8);
163
- box-shadow: 0 0 2px rgba(30,140,190,.8);
164
- }
165
-
166
- .select_wrapper span {
167
- height: 26px;
168
- line-height: 26px;
169
- padding-left: 6px;
170
- position: absolute;
171
- z-index: 2;
172
- overflow: hidden;
173
- }
174
- .ie8 .yit_options select,
175
- .ie8 .yit-options select {
176
- height: 26px;
177
- }
178
- .yit_options select, .yit-options select, .the-metabox .select_wrapper select {
179
- cursor: pointer;
180
- height: 28px;
181
- margin: 0;
182
- opacity: 0;
183
- padding: 0;
184
- position: relative;
185
- width: inherit;
186
- z-index: 4;
187
- background-color: #FAFAFA;
188
- }
189
-
190
- /* === Single Chosen Customizzation === */
191
-
192
- .yith-choosen .chosen-container-single .chosen-default {
193
- background: transparent;
194
- border-color: #ddd;
195
- }
196
-
197
- .yith-choosen .chosen-search > input[type=text]{
198
- width: 100% !important;
199
- }
200
-
201
- .yith-choosen .chosen-container-single .chosen-single {
202
- background: transparent;
203
- border-color: #ddd;
204
- }
205
-
206
-
207
- /* Style to woocommerce panel*/
208
-
209
- #plugin-fw-wc{
210
- padding-top: 20px;
211
- }
212
- #plugin-fw-wc table.form-table{
213
- background-color: #fff;
214
- margin-bottom: 20px;
215
- }
216
- #plugin-fw-wc table.form-table th {
217
- padding: 20px;
218
- }
219
- #plugin-fw-wc h3{
220
- padding:0px 10px 10px ;
221
- border-bottom: 1px solid #eee;
222
- }
223
-
224
- /* === VIDEO BOX === */
225
-
226
- .yith-videobox-wrapper {
227
- padding-top: 20px;
228
- }
229
- .yith-videobox-wrapper h3{
230
- padding:0px 10px 10px ;
231
- border-bottom: 1px solid #eee;
232
- }
233
-
234
- .yith-videobox-wrapper .postbox {
235
- display: inline-block;
236
- }
237
- .yith-videobox-wrapper .yith_videobox .column {
238
- width: 45%;
239
- float: left;
240
- padding-right: 2.5%;
241
- border-right: 1px solid #ebebeb;
242
- padding-bottom: 2em;
243
- }
244
- .yith-videobox-wrapper .yith_videobox .column.two {
245
- margin-right: 0;
246
- padding-right: 0;
247
- padding-left: 2.5%;
248
- border: 0;
249
- max-width: 49%;
250
- }
251
- .yith-videobox-wrapper .yith_videobox h2{
252
- font-size: 16px;
253
- margin-bottom: 20px;
254
- }
255
- .yith-videobox-wrapper .yith-video-link {
256
- width: 100%;
257
- max-width: 200px;
258
- float: left;
259
- margin: 0 1.5em 1.5em 0;
260
- }
261
- .yith-videobox-wrapper .yith-video-link {
262
- width: 100%;
263
- max-width: 200px;
264
- float: left;
265
- margin: 0 1.5em 1.5em 0;
266
- }
267
- .yith-videobox-wrapper .yith-image-frame img {
268
- max-width: 100%;
269
- height: auto;
270
- }
271
- .yith-videobox-wrapper .yith-video-link img {
272
- max-width: 100%;
273
- height: auto;
274
- }
275
- .yith-videobox-wrapper .yith-video-iframe {
276
- display: none;
277
-
278
- }
279
-
280
- /* === Plugins Upgrader === */
281
-
282
- .yit-plugin-changelog-wrapper {
283
- display: none;
284
- }
285
-
286
- .yit-plugin-changelog-title {
287
- text-transform: uppercase;
288
- }
289
-
290
- .yit-plugin-changelog {
291
- background: #fcfcfc;
292
- height: 97%;
293
- z-index: 999;
294
- overflow: auto;
295
- }
296
-
297
- /* === Plugins Licence Activation === */
298
-
299
- .yit-container.plugin-licence-activation {
300
- font-family: 'Raleway', sans-serif;
301
- }
302
-
303
- .yit-container.plugin-licence-activation .to-active-wrapper {
304
- margin-bottom: 60px;
305
- }
306
-
307
- .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form {
308
- position: relative;
309
- border-color: #e1e1e1;
310
- border-style: solid;
311
- border-width: 0;
312
- }
313
-
314
- .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form:first-child {
315
- border-top-width: 1px;
316
- }
317
-
318
- .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form:last-child {
319
- border-bottom-width: 1px;
320
- }
321
-
322
- .yit-container.plugin-licence-activation .to-active-wrapper table.to-active-table {
323
- border-width: 0;
324
- border-spacing: 0;
325
- width: 100%;
326
- }
327
-
328
- .yit-container.plugin-licence-activation .message {
329
- display: none;
330
- line-height: normal;
331
- background: #ffffff url(../images/licence-error.png) 15px center no-repeat;
332
- padding-left: 65px;
333
- padding-right: 15px;
334
- width: 150px;
335
- }
336
-
337
- .yit-container.plugin-licence-activation .message-wrapper {
338
- height: 75px;
339
- display: none;
340
- position: absolute;
341
- top: 0;
342
- right: -250px;
343
- border: 1px solid #ff3838;
344
- }
345
-
346
- .yit-container.plugin-licence-activation .message-wrapper.visible {
347
- display: table;
348
- }
349
-
350
- .yit-container.plugin-licence-activation .message {
351
- display: table-cell;
352
- vertical-align: middle;
353
- }
354
-
355
- .yit-container.plugin-licence-activation .arrow-left:after,
356
- .yit-container.plugin-licence-activation .arrow-left:before {
357
- content: "";
358
- display: block;
359
- width: 0;
360
- height: 0;
361
- position: absolute;
362
- }
363
-
364
- .yit-container.plugin-licence-activation .arrow-left:before {
365
- border-top: 9px solid transparent;
366
- border-bottom: 9px solid transparent;
367
- border-right: 9px solid #ff3838;
368
- top: 26px;
369
- left: -9px;
370
- }
371
-
372
- .yit-container.plugin-licence-activation .arrow-left:after {
373
- border-top: 8px solid transparent;
374
- border-bottom: 8px solid transparent;
375
- border-right: 8px solid #fff;
376
- left: -8px;
377
- top: 27px;
378
- }
379
-
380
- .yit-container.plugin-licence-activation h2,
381
- .yit-container.plugin-licence-activation h3 {
382
- text-transform: uppercase;
383
- font-weight: 800;
384
- margin-bottom: 30px;
385
- }
386
-
387
- .yit-container.plugin-licence-activation h2 {
388
- color: #808a97;
389
- font-size: 25px;
390
- }
391
- .yit-container.plugin-licence-activation h3 {
392
- color: #313131;
393
- font-size: 15px;
394
- height: 20px;
395
- }
396
-
397
- .yit-container.plugin-licence-activation h3.to-active {
398
- height: 20px;
399
- position: relative;
400
- vertical-align: top;
401
- }
402
-
403
- .yit-container.plugin-licence-activation .spinner.show{
404
- display: inline-block;
405
- vertical-align: middle;
406
- float: none;
407
- }
408
-
409
- .yit-container.plugin-licence-activation h3.to-active > .spinner.show {
410
- display: inline-block;
411
- float: none;
412
- top: -3px;
413
- position: relative;
414
- }
415
-
416
- .yit-container.plugin-licence-activation .licence-check-section{
417
- margin-bottom: 60px;
418
- }
419
-
420
- .yit-container.plugin-licence-activation span.licence-label {
421
- font-weight: 500;
422
- color: #606060;
423
- margin-bottom: 30px;
424
- }
425
-
426
- .yit-container.plugin-licence-activation .button-licence {
427
- border: 0;
428
- font-size: 13px;
429
- text-transform: uppercase;
430
- background-color: #808a97;
431
- color: #fff;
432
- font-weight: 700;
433
- border-radius: 3px;
434
- cursor: pointer;
435
- text-decoration: none;
436
- padding: 5px 7px;
437
- -webkit-transition: background-color 0.3s ease;
438
- -moz-transition: background-color 0.3s ease;
439
- -ms-transition: background-color 0.3s ease;
440
- -o-transition: background-color 0.3s ease;
441
- transition: background-color 0.3s ease;
442
- }
443
-
444
- .yit-container.plugin-licence-activation .button-licence:hover {
445
- background-color: #4d5c6f;
446
- }
447
-
448
- .yit-container.plugin-licence-activation .button-licence.clicked {
449
- cursor: not-allowed;
450
- background-color: #e2e2e2 !important;
451
- }
452
-
453
- .yit-container.plugin-licence-activation .button-licence.licence-check {
454
- font-weight: 400;
455
- padding: 12px 19px;
456
- }
457
-
458
- .yit-container.plugin-licence-activation .button-licence.licence-renew {
459
- text-decoration: none;
460
- padding: 7px 12px;
461
- font-size: 9px;
462
- }
463
-
464
- .yit-container.plugin-licence-activation .button-licence.licence-renew:focus {
465
- box-shadow: none;
466
- }
467
-
468
- .yit-container.plugin-licence-activation table:not(.to-active-table) {
469
- width: 100%;
470
- border: 1px solid #dcdcdc;
471
- border-spacing: 0;
472
- border-radius: 5px;
473
- border-collapse: separate;
474
- overflow: hidden;
475
- }
476
-
477
- .yit-container.plugin-licence-activation table:not(.to-active-table) th {
478
- border-bottom: 1px solid #dcdcdc;
479
- }
480
-
481
- .yit-container.plugin-licence-activation table:not(.to-active-table) td,
482
- .yit-container.plugin-licence-activation table:not(.to-active-table) th {
483
- border-right: 1px solid #dcdcdc;
484
- }
485
- .yit-container.plugin-licence-activation table td:last-child,
486
- .yit-container.plugin-licence-activation table th:last-child {
487
- border-right: 0;
488
- }
489
-
490
- .yit-container.plugin-licence-activation table thead tr {
491
- background-color: #f6f4f4;
492
- }
493
-
494
- .yit-container.plugin-licence-activation table tbody tr {
495
- background-color: #ffffff;
496
- }
497
-
498
- .yit-container.plugin-licence-activation table thead tr th {
499
- font-size: 13px;
500
- color: #313131;
501
- text-transform: uppercase;
502
- font-weight: bold;
503
- }
504
-
505
- .yit-container.plugin-licence-activation table thead tr,
506
- .yit-container.plugin-licence-activation table tbody tr {
507
- line-height: 60px;
508
- }
509
-
510
- .yit-container.plugin-licence-activation table tbody tr td{
511
- text-align: center;
512
- line-height: 20px;
513
- padding: 10px 5px;
514
- }
515
-
516
- .yit-container.plugin-licence-activation .button-licence.licence-activation {
517
- padding: 12px 18px;
518
- }
519
-
520
- .yit-container.plugin-licence-activation .to-active-table tr {
521
- line-height: 75px;
522
- }
523
-
524
- .yit-container.plugin-licence-activation .to-active-table tr.plugin-row {
525
- background-color: transparent;
526
- -webkit-transition: all 0.3s ease;
527
- -moz-transition: all 0.3s ease;
528
- -ms-transition: all 0.3s ease;
529
- -o-transition: all 0.3s ease;
530
- transition: all 0.3s ease;
531
- }
532
-
533
- .yit-container.plugin-licence-activation .to-active-table tr.plugin-row.error {
534
- background-color: #ffdcdc;
535
- }
536
-
537
- .yit-container.plugin-licence-activation .to-active-table td {
538
- padding-right: 12px;
539
- width: 33%;
540
- }
541
-
542
-
543
- .yit-container.plugin-licence-activation .to-active-table td.plugin-name {
544
- color: #808a97;
545
- font-size: 12px;
546
- text-transform: uppercase;
547
- font-weight: bold;
548
- line-height: 20px;
549
- width: 20%;
550
- padding-left: 20px;
551
- }
552
-
553
- .yit-container.plugin-licence-activation .to-active-table td.activate-button {
554
- width: 15%;
555
- position: relative;
556
- }
557
-
558
- .yit-container.plugin-licence-activation input[type=text],
559
- .yit-container.plugin-licence-activation input[type=email]{
560
- -webkit-transition: all 0.3s ease;
561
- -moz-transition: all 0.3s ease;
562
- -ms-transition: all 0.3s ease;
563
- -o-transition: all 0.3s ease;
564
- transition: all 0.3s ease;
565
-
566
- border: 1px solid #dcdcdc;
567
- padding: 0 15px;
568
- border-radius: 3px;
569
- height: 41px;
570
- width: 100%;
571
- }
572
-
573
- .yit-container.plugin-licence-activation input[type=text].require,
574
- .yit-container.plugin-licence-activation input[type=email].require {
575
- border: 1px solid #ff3838;
576
- }
577
-
578
- .yit-container.plugin-licence-activation input[type=text]:focus,
579
- .yit-container.plugin-licence-activation input[type=email]:focus{
580
- webkit-box-shadow: 0 0 1px rgba(30,140,190,.8);
581
- box-shadow: 0 0 1px rgba(30,140,190,.8);
582
- }
583
-
584
- .yit-container.plugin-licence-activation input[type=text]{
585
- text-transform: uppercase;
586
- text-align: center;
587
- }
588
-
589
- .yit-container.plugin-licence-activation input[type=email] {
590
- text-align: left;
591
- }
592
-
593
- .yit-container.plugin-licence-activation input[type=submit]:focus{
594
- outline: 0;
595
- }
596
-
597
- /* === Woocommerce panel === */
598
- #plugin-fw-wc .yit_options{
599
- padding: 0;
600
- border: 0;
601
- }
602
- #plugin-fw-wc .yit_options input.upload_button, .yit_options input.button{
603
- background: none;
604
- border: 1px solid #ccc;
605
- }
606
-
607
- /* === WP Pointers === */
608
-
609
- #adminmenu li.menu-top.yit-pointer-selected-row,
610
- #adminmenu li.menu-top.yit-pointer-selected-row:hover,
611
- #adminmenu li.yit-pointer-selected-row a.menu-top {
612
- background-color: #acc327;
613
- color: #000;
614
- }
615
-
616
- #adminmenu a.menu-top.toplevel_page_yit_plugin_panel.yit-pointer{
617
- color: #000;
618
- }
619
-
620
- #adminmenu a.menu-top.toplevel_page_yit_plugin_panel.yit-pointer:hover,
621
- #adminmenu .wp-submenu a.yit-pointer-selected-row {
622
- color: #fff;
623
- }
624
-
625
- #adminmenu .wp-submenu a.yit-pointer-selected-row:hover {
626
- color: #45bbe6;
627
- }
628
-
629
- /* WooCommerce 2.4 Support */
630
- .woocommerce table.form-table .colorpick{
631
- width: 6em;
632
- }
633
-
634
- #wpwrap h2.nav-tab-wrapper , #wpbody-content h2.nav-tab-wrapper {
635
- border-bottom: 1px solid #ccc;
636
- }
637
-
638
- /* === YIT FRAMEWORK === */
639
- .plugin-card .plugin-icon img {
640
- max-width: 100%;
641
- width: auto;
642
- height: auto;
643
- }
644
-
645
- /* === Responsive === */
646
-
647
- @media (max-width: 767px) {}
648
-
649
- @media (max-width: 480px) {}
650
-
651
- @media (min-width: 768px) and (max-width: 992px) {}
652
-
653
- @media (min-width: 980px) and (max-width: 1199px) {}
654
-
655
- @media (min-width: 1200px) {
656
- .yit-container.plugin-licence-activation{
657
- width: 900px;
658
- }
659
- }
660
-
661
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
662
- only screen and (-o-min-device-pixel-ratio: 3/2),
663
- only screen and (min--moz-device-pixel-ratio: 1.5),
664
- only screen and (min-device-pixel-ratio: 1.5) {}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * This file belongs to the YIT Plugin Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+ /* onoff */
11
+ .rm_onoff input {
12
+ display : none;
13
+ }
14
+
15
+ .rm_onoff input + span {
16
+ cursor : pointer;
17
+ text-indent : -9999px;
18
+ display : block;
19
+ width : 85px;
20
+ height : 37px;
21
+ background : transparent url(../images/off.png);
22
+ }
23
+
24
+ .rm_onoff input:checked + span {
25
+ background : transparent url(../images/on.png);
26
+ }
27
+
28
+ .rm_onoff input.onoffchecked + span {
29
+ background : transparent url(../images/on.png);
30
+ }
31
+
32
+ /* slider */
33
+ /*numbers*/
34
+ .ui-slider .maxCaption, .ui-slider .minCaption {
35
+ margin-bottom : 5px;
36
+ }
37
+
38
+ .ui-slider .feedback {
39
+ background : url(../images/slider/tooltip.png) no-repeat center top;
40
+ position : absolute;
41
+ top : -25px;
42
+ width : 35px;
43
+ height : 43px;
44
+ text-align : center;
45
+ width : 100%;
46
+ display : block;
47
+ }
48
+
49
+ .ui-slider .feedback strong {
50
+ display : inline-block;
51
+ padding-top : 4px;
52
+ top : -30px;
53
+ }
54
+
55
+ /*handle*/
56
+ .yit-options .ui-slider-horizontal .ui-slider-handle,
57
+ .yit_options .ui-slider-horizontal .ui-slider-handle {
58
+ background : transparent url(../images/slider/handle.png) no-repeat left top !important;
59
+ border : 0px !important;
60
+ top : -.35em !important;
61
+ width : 18px !important;
62
+ height : 19px !important;
63
+ }
64
+
65
+ /*bg on the left:grey*/
66
+ .yit-options .ui-slider.ui-widget-content,
67
+ .yit_options .ui-slider.ui-widget-content {
68
+ background : url(../images/slider/grey.gif) repeat-x left center !important;
69
+ border-color : #c1c1c0 !important;
70
+ height : 10px !important;
71
+ }
72
+
73
+ .iris-slider-offset.ui-slider.ui-widget-content {
74
+ background : transparent !important;
75
+ height : auto !important;
76
+ }
77
+
78
+ /*bg on the right:orange*/
79
+ .ui-slider.ui-widget-content .ui-widget-header {
80
+ background : url(../images/slider/orange.gif) repeat-x left center !important;
81
+ left : 2px !important;
82
+ -webkit-border-radius : 15px;
83
+ -moz-border-radius : 15px;
84
+ -khtml-border-radius : 15px;
85
+ border-radius : 15px;
86
+ }
87
+
88
+ .plugin-option tr {
89
+ border-bottom : 1px solid #ccc;
90
+ }
91
+
92
+ .plugin-option .yit_options,
93
+ .plugin-option .yit-options {
94
+ border-bottom : 0px;
95
+ }
96
+
97
+ .plugin-option .yit-options .option,
98
+ .plugin-option .yit_options .option {
99
+ width : 600px;
100
+ float : left;
101
+ }
102
+
103
+ .plugin-option .form-table td {
104
+ padding : 25px 10px;
105
+ }
106
+
107
+ .yit_options .select_wrapper,
108
+ .yit-options .select_wrapper {
109
+ background : url("../images/select.png") no-repeat scroll right center #FAFAFA;
110
+ border-color : #CCCCCC #EEEEEE #EEEEEE #CCCCCC;
111
+ border-radius : 4px 4px 4px 4px;
112
+ border-style : solid;
113
+ border-width : 1px;
114
+ color : #555555;
115
+ display : block;
116
+ float : left;
117
+ font-family : sans-serif;
118
+ font-size : 12px;
119
+ height : 26px;
120
+ margin-bottom : 9px !important;
121
+ margin-left : 0;
122
+ margin-right : 5px;
123
+ margin-top : 0;
124
+ width : 400px;
125
+ }
126
+
127
+ .chosen .select_wrapper {
128
+ background : none;
129
+ border : none;
130
+ }
131
+
132
+ .chosen .select_wrapper .chosen-container {
133
+ width : 338px !important;
134
+ }
135
+
136
+ .chosen .select_wrapper .chosen-container .search-field input {
137
+ height : 27px !important;
138
+ color : #333;
139
+ }
140
+
141
+ .chosen .select_wrapper .chosen-container .chosen-choices {
142
+ border : 1px solid #ddd;
143
+ box-shadow : none;
144
+ }
145
+
146
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice {
147
+ height : 15px !important;
148
+ min-width : 105px;
149
+ }
150
+
151
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice span {
152
+ line-height : 15px;
153
+ height : 15px;
154
+ padding-top : 2px;
155
+ }
156
+
157
+ .chosen .select_wrapper .chosen-container .chosen-choices li.search-choice a.search-choice-close {
158
+ top : 5px;
159
+ }
160
+
161
+ .chosen .select_wrapper .chosen-container .chosen-drop .chosen-search input {
162
+ width : 100% !important;
163
+ }
164
+
165
+ /* === Multiple Chosen Customizzation === */
166
+
167
+ .yith-choosen .chosen-choices {
168
+ line-height : 27px;
169
+ min-height : 27px;
170
+ border : 1px solid #ddd;
171
+ }
172
+
173
+ .yith-choosen .chosen-container-active .chosen-choices {
174
+ border : 1px solid #5b9dd9;
175
+ -webkit-box-shadow : 0 0 2px rgba(30, 140, 190, .8);
176
+ box-shadow : 0 0 2px rgba(30, 140, 190, .8);
177
+ }
178
+
179
+ .select_wrapper span {
180
+ height : 26px;
181
+ line-height : 26px;
182
+ padding-left : 6px;
183
+ position : absolute;
184
+ z-index : 2;
185
+ overflow : hidden;
186
+ }
187
+
188
+ .ie8 .yit_options select,
189
+ .ie8 .yit-options select {
190
+ height : 26px;
191
+ }
192
+
193
+ .yit_options select, .yit-options select, .the-metabox .select_wrapper select {
194
+ cursor : pointer;
195
+ height : 28px;
196
+ margin : 0;
197
+ opacity : 0;
198
+ padding : 0;
199
+ position : relative;
200
+ width : inherit;
201
+ z-index : 4;
202
+ background-color : #FAFAFA;
203
+ }
204
+
205
+ /* === Single Chosen Customizzation === */
206
+
207
+ .yith-choosen .chosen-container-single .chosen-default {
208
+ background : transparent;
209
+ border-color : #ddd;
210
+ }
211
+
212
+ .yith-choosen .chosen-search > input[type=text] {
213
+ width : 100% !important;
214
+ }
215
+
216
+ .yith-choosen .chosen-container-single .chosen-single {
217
+ background : transparent;
218
+ border-color : #ddd;
219
+ }
220
+
221
+ /* Style to woocommerce panel*/
222
+
223
+ #plugin-fw-wc {
224
+ padding-top : 20px;
225
+ }
226
+
227
+ #plugin-fw-wc table.form-table {
228
+ background-color : #fff;
229
+ margin-bottom : 20px;
230
+ }
231
+
232
+ #plugin-fw-wc table.form-table th {
233
+ padding : 20px;
234
+ }
235
+
236
+ #plugin-fw-wc h3 {
237
+ padding : 0px 10px 10px;
238
+ border-bottom : 1px solid #eee;
239
+ }
240
+
241
+ /* === VIDEO BOX === */
242
+
243
+ .yith-videobox-wrapper {
244
+ padding-top : 20px;
245
+ }
246
+
247
+ .yith-videobox-wrapper h3 {
248
+ padding : 0px 10px 10px;
249
+ border-bottom : 1px solid #eee;
250
+ }
251
+
252
+ .yith-videobox-wrapper .postbox {
253
+ display : inline-block;
254
+ }
255
+
256
+ .yith-videobox-wrapper .yith_videobox .column {
257
+ width : 45%;
258
+ float : left;
259
+ padding-right : 2.5%;
260
+ border-right : 1px solid #ebebeb;
261
+ padding-bottom : 2em;
262
+ }
263
+
264
+ .yith-videobox-wrapper .yith_videobox .column.two {
265
+ margin-right : 0;
266
+ padding-right : 0;
267
+ padding-left : 2.5%;
268
+ border : 0;
269
+ max-width : 49%;
270
+ }
271
+
272
+ .yith-videobox-wrapper .yith_videobox h2 {
273
+ font-size : 16px;
274
+ margin-bottom : 20px;
275
+ }
276
+
277
+ .yith-videobox-wrapper .yith-video-link {
278
+ width : 100%;
279
+ max-width : 200px;
280
+ float : left;
281
+ margin : 0 1.5em 1.5em 0;
282
+ }
283
+
284
+ .yith-videobox-wrapper .yith-video-link {
285
+ width : 100%;
286
+ max-width : 200px;
287
+ float : left;
288
+ margin : 0 1.5em 1.5em 0;
289
+ }
290
+
291
+ .yith-videobox-wrapper .yith-image-frame img {
292
+ max-width : 100%;
293
+ height : auto;
294
+ }
295
+
296
+ .yith-videobox-wrapper .yith-video-link img {
297
+ max-width : 100%;
298
+ height : auto;
299
+ }
300
+
301
+ .yith-videobox-wrapper .yith-video-iframe {
302
+ display : none;
303
+
304
+ }
305
+
306
+ /* === Plugins Upgrader === */
307
+
308
+ .yit-plugin-changelog-wrapper {
309
+ display : none;
310
+ }
311
+
312
+ .yit-plugin-changelog-title {
313
+ text-transform : uppercase;
314
+ }
315
+
316
+ .yit-plugin-changelog {
317
+ background : #fcfcfc;
318
+ height : 97%;
319
+ z-index : 999;
320
+ overflow : auto;
321
+ }
322
+
323
+ /* === Plugins Licence Activation === */
324
+
325
+ .yit-container.plugin-licence-activation {
326
+ font-family : 'Raleway', sans-serif;
327
+ }
328
+
329
+ .yit-container.plugin-licence-activation .to-active-wrapper {
330
+ margin-bottom : 60px;
331
+ }
332
+
333
+ .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form {
334
+ position : relative;
335
+ border-color : #e1e1e1;
336
+ border-style : solid;
337
+ border-width : 0;
338
+ }
339
+
340
+ .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form:first-child {
341
+ border-top-width : 1px;
342
+ }
343
+
344
+ .yit-container.plugin-licence-activation .to-active-wrapper form.to-active-form:last-child {
345
+ border-bottom-width : 1px;
346
+ }
347
+
348
+ .yit-container.plugin-licence-activation .to-active-wrapper table.to-active-table {
349
+ border-width : 0;
350
+ border-spacing : 0;
351
+ width : 100%;
352
+ }
353
+
354
+ .yit-container.plugin-licence-activation .message {
355
+ display : none;
356
+ line-height : normal;
357
+ background : #ffffff url(../images/licence-error.png) 15px center no-repeat;
358
+ padding-left : 65px;
359
+ padding-right : 15px;
360
+ width : 150px;
361
+ }
362
+
363
+ .yit-container.plugin-licence-activation .message-wrapper {
364
+ height : 75px;
365
+ display : none;
366
+ position : absolute;
367
+ top : 0;
368
+ right : -250px;
369
+ border : 1px solid #ff3838;
370
+ }
371
+
372
+ .yit-container.plugin-licence-activation .message-wrapper.visible {
373
+ display : table;
374
+ }
375
+
376
+ .yit-container.plugin-licence-activation .message {
377
+ display : table-cell;
378
+ vertical-align : middle;
379
+ }
380
+
381
+ .yit-container.plugin-licence-activation .arrow-left:after,
382
+ .yit-container.plugin-licence-activation .arrow-left:before {
383
+ content : "";
384
+ display : block;
385
+ width : 0;
386
+ height : 0;
387
+ position : absolute;
388
+ }
389
+
390
+ .yit-container.plugin-licence-activation .arrow-left:before {
391
+ border-top : 9px solid transparent;
392
+ border-bottom : 9px solid transparent;
393
+ border-right : 9px solid #ff3838;
394
+ top : 26px;
395
+ left : -9px;
396
+ }
397
+
398
+ .yit-container.plugin-licence-activation .arrow-left:after {
399
+ border-top : 8px solid transparent;
400
+ border-bottom : 8px solid transparent;
401
+ border-right : 8px solid #fff;
402
+ left : -8px;
403
+ top : 27px;
404
+ }
405
+
406
+ .yit-container.plugin-licence-activation h2,
407
+ .yit-container.plugin-licence-activation h3 {
408
+ text-transform : uppercase;
409
+ font-weight : 800;
410
+ margin-bottom : 30px;
411
+ }
412
+
413
+ .yit-container.plugin-licence-activation h2 {
414
+ color : #808a97;
415
+ font-size : 25px;
416
+ }
417
+
418
+ .yit-container.plugin-licence-activation h3 {
419
+ color : #313131;
420
+ font-size : 15px;
421
+ height : 20px;
422
+ }
423
+
424
+ .yit-container.plugin-licence-activation h3.to-active {
425
+ height : 20px;
426
+ position : relative;
427
+ vertical-align : top;
428
+ }
429
+
430
+ .yit-container.plugin-licence-activation .spinner.show {
431
+ display : inline-block;
432
+ vertical-align : middle;
433
+ float : none;
434
+ }
435
+
436
+ .yit-container.plugin-licence-activation h3.to-active > .spinner.show {
437
+ display : inline-block;
438
+ float : none;
439
+ top : -3px;
440
+ position : relative;
441
+ }
442
+
443
+ .yit-container.plugin-licence-activation .licence-check-section {
444
+ margin-bottom : 60px;
445
+ }
446
+
447
+ .yit-container.plugin-licence-activation span.licence-label {
448
+ font-weight : 500;
449
+ color : #606060;
450
+ margin-bottom : 30px;
451
+ }
452
+
453
+ .yit-container.plugin-licence-activation .button-licence {
454
+ border : 0;
455
+ font-size : 13px;
456
+ text-transform : uppercase;
457
+ background-color : #808a97;
458
+ color : #fff;
459
+ font-weight : 700;
460
+ border-radius : 3px;
461
+ cursor : pointer;
462
+ text-decoration : none;
463
+ padding : 5px 7px;
464
+ -webkit-transition : background-color 0.3s ease;
465
+ -moz-transition : background-color 0.3s ease;
466
+ -ms-transition : background-color 0.3s ease;
467
+ -o-transition : background-color 0.3s ease;
468
+ transition : background-color 0.3s ease;
469
+ }
470
+
471
+ .yit-container.plugin-licence-activation .button-licence:hover {
472
+ background-color : #4d5c6f;
473
+ }
474
+
475
+ .yit-container.plugin-licence-activation .button-licence.clicked {
476
+ cursor : not-allowed;
477
+ background-color : #e2e2e2 !important;
478
+ }
479
+
480
+ .yit-container.plugin-licence-activation .button-licence.licence-check {
481
+ font-weight : 400;
482
+ padding : 12px 19px;
483
+ }
484
+
485
+ .yit-container.plugin-licence-activation .button-licence.licence-renew {
486
+ text-decoration : none;
487
+ padding : 7px 12px;
488
+ font-size : 9px;
489
+ }
490
+
491
+ .yit-container.plugin-licence-activation .button-licence.licence-renew:focus {
492
+ box-shadow : none;
493
+ }
494
+
495
+ .yit-container.plugin-licence-activation table:not(.to-active-table) {
496
+ width : 100%;
497
+ border : 1px solid #dcdcdc;
498
+ border-spacing : 0;
499
+ border-radius : 5px;
500
+ border-collapse : separate;
501
+ overflow : hidden;
502
+ }
503
+
504
+ .yit-container.plugin-licence-activation table:not(.to-active-table) th {
505
+ border-bottom : 1px solid #dcdcdc;
506
+ }
507
+
508
+ .yit-container.plugin-licence-activation table:not(.to-active-table) td,
509
+ .yit-container.plugin-licence-activation table:not(.to-active-table) th {
510
+ border-right : 1px solid #dcdcdc;
511
+ }
512
+
513
+ .yit-container.plugin-licence-activation table td:last-child,
514
+ .yit-container.plugin-licence-activation table th:last-child {
515
+ border-right : 0;
516
+ }
517
+
518
+ .yit-container.plugin-licence-activation table thead tr {
519
+ background-color : #f6f4f4;
520
+ }
521
+
522
+ .yit-container.plugin-licence-activation table tbody tr {
523
+ background-color : #ffffff;
524
+ }
525
+
526
+ .yit-container.plugin-licence-activation table thead tr th {
527
+ font-size : 13px;
528
+ color : #313131;
529
+ text-transform : uppercase;
530
+ font-weight : bold;
531
+ }
532
+
533
+ .yit-container.plugin-licence-activation table thead tr,
534
+ .yit-container.plugin-licence-activation table tbody tr {
535
+ line-height : 60px;
536
+ }
537
+
538
+ .yit-container.plugin-licence-activation table tbody tr td {
539
+ text-align : center;
540
+ line-height : 20px;
541
+ padding : 10px 5px;
542
+ }
543
+
544
+ .yit-container.plugin-licence-activation .button-licence.licence-activation {
545
+ padding : 12px 18px;
546
+ }
547
+
548
+ .yit-container.plugin-licence-activation .to-active-table tr {
549
+ line-height : 75px;
550
+ }
551
+
552
+ .yit-container.plugin-licence-activation .to-active-table tr.plugin-row {
553
+ background-color : transparent;
554
+ -webkit-transition : all 0.3s ease;
555
+ -moz-transition : all 0.3s ease;
556
+ -ms-transition : all 0.3s ease;
557
+ -o-transition : all 0.3s ease;
558
+ transition : all 0.3s ease;
559
+ }
560
+
561
+ .yit-container.plugin-licence-activation .to-active-table tr.plugin-row.error {
562
+ background-color : #ffdcdc;
563
+ }
564
+
565
+ .yit-container.plugin-licence-activation .to-active-table td {
566
+ padding-right : 12px;
567
+ width : 33%;
568
+ }
569
+
570
+ .yit-container.plugin-licence-activation .to-active-table td.plugin-name {
571
+ color : #808a97;
572
+ font-size : 12px;
573
+ text-transform : uppercase;
574
+ font-weight : bold;
575
+ line-height : 20px;
576
+ width : 20%;
577
+ padding-left : 20px;
578
+ }
579
+
580
+ .yit-container.plugin-licence-activation .to-active-table td.activate-button {
581
+ width : 15%;
582
+ position : relative;
583
+ }
584
+
585
+ .yit-container.plugin-licence-activation input[type=text],
586
+ .yit-container.plugin-licence-activation input[type=email] {
587
+ -webkit-transition : all 0.3s ease;
588
+ -moz-transition : all 0.3s ease;
589
+ -ms-transition : all 0.3s ease;
590
+ -o-transition : all 0.3s ease;
591
+ transition : all 0.3s ease;
592
+
593
+ border : 1px solid #dcdcdc;
594
+ padding : 0 15px;
595
+ border-radius : 3px;
596
+ height : 41px;
597
+ width : 100%;
598
+ }
599
+
600
+ .yit-container.plugin-licence-activation input[type=text].require,
601
+ .yit-container.plugin-licence-activation input[type=email].require {
602
+ border : 1px solid #ff3838;
603
+ }
604
+
605
+ .yit-container.plugin-licence-activation input[type=text]:focus,
606
+ .yit-container.plugin-licence-activation input[type=email]:focus {
607
+ webkit-box-shadow : 0 0 1px rgba(30, 140, 190, .8);
608
+ box-shadow : 0 0 1px rgba(30, 140, 190, .8);
609
+ }
610
+
611
+ .yit-container.plugin-licence-activation input[type=text] {
612
+ text-transform : uppercase;
613
+ text-align : center;
614
+ }
615
+
616
+ .yit-container.plugin-licence-activation input[type=email] {
617
+ text-align : left;
618
+ }
619
+
620
+ .yit-container.plugin-licence-activation input[type=submit]:focus {
621
+ outline : 0;
622
+ }
623
+
624
+ /* === Woocommerce panel === */
625
+ #plugin-fw-wc .yit_options {
626
+ padding : 0;
627
+ border : 0;
628
+ }
629
+
630
+ #plugin-fw-wc .yit_options input.upload_button, .yit_options input.button {
631
+ background : none;
632
+ border : 1px solid #ccc;
633
+ }
634
+
635
+ /* === WP Pointers === */
636
+
637
+ #adminmenu li.menu-top.yit-pointer-selected-row,
638
+ #adminmenu li.menu-top.yit-pointer-selected-row:hover,
639
+ #adminmenu li.yit-pointer-selected-row a.menu-top {
640
+ background-color : #acc327;
641
+ color : #000;
642
+ }
643
+
644
+ #adminmenu a.menu-top.toplevel_page_yit_plugin_panel.yit-pointer {
645
+ color : #000;
646
+ }
647
+
648
+ #adminmenu a.menu-top.toplevel_page_yit_plugin_panel.yit-pointer:hover,
649
+ #adminmenu .wp-submenu a.yit-pointer-selected-row {
650
+ color : #fff;
651
+ }
652
+
653
+ #adminmenu .wp-submenu a.yit-pointer-selected-row:hover {
654
+ color : #45bbe6;
655
+ }
656
+
657
+ /* WooCommerce 2.4 Support */
658
+ .woocommerce table.form-table .colorpick {
659
+ width : 6em;
660
+ }
661
+
662
+ #wpwrap h2.nav-tab-wrapper , #wpbody-content h2.nav-tab-wrapper {
663
+ border-bottom: 1px solid #ccc;
664
+ }
665
+
666
+ /* === YIT FRAMEWORK === */
667
+ .plugin-card .plugin-icon img {
668
+ max-width : 100%;
669
+ width : auto;
670
+ height : auto;
671
+ }
672
+
673
+ /* === Panel Content and Container === */
674
+ .yit-admin-panel-container{
675
+ position:relative;
676
+ }
677
+ .yit-admin-panel-content-wrap {
678
+ width : calc(100% - 300px);
679
+ display : inline-block;
680
+ }
681
+
682
+ .yit-admin-panel-content-wrap.yit-admin-panel-content-wrap-full {
683
+ width : 100%;
684
+ display : block;
685
+ }
686
+
687
+ /* === Responsive === */
688
+
689
+ @media (max-width : 767px) {
690
+ .yit-admin-panel-content-wrap {
691
+ width : 100%;
692
+ display : block;
693
+ }
694
+ }
695
+
696
+ @media (max-width : 480px) {
697
+
698
+ }
699
+
700
+ @media (min-width : 768px) and (max-width : 992px) {
701
+ }
702
+
703
+ @media (min-width : 980px) and (max-width : 1199px) {
704
+ }
705
+
706
+ @media (min-width : 1200px) {
707
+ .yit-container.plugin-licence-activation {
708
+ width : 900px;
709
+ }
710
+ }
711
+
712
+ @media only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (-o-min-device-pixel-ratio : 3/2), only screen and (min--moz-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5) {
713
+ }
plugin-fw/assets/css/yit-upgrade-to-pro.css ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* === Upgrade to Premium Landing page === */
2
+
3
+ #upgrade-to-premium{
4
+ width: 900px;
5
+ }
6
+ #upgrade-to-premium h1{
7
+ font-family: 'Raleway',san-serif;
8
+ text-transform: uppercase;
9
+ font-size: 30px;
10
+ font-weight: 700;
11
+ color: #808a97;
12
+ }
13
+
14
+ #upgrade-to-premium h3{
15
+ font-family: 'Raleway',san-serif;
16
+ font-size: 20px;
17
+ line-height: 29px;
18
+ font-weight: 700;
19
+ color: #808a97;
20
+ }
21
+
22
+ #upgrade-to-premium p{
23
+ font-family: 'Open Sans',san-serif;
24
+ font-size: 15px;
25
+ line-height: 29px;
26
+ font-weight: 400;
27
+ color: #6a6a6b;
28
+ }
29
+ #upgrade-to-premium p.highlighted{
30
+ font-family: 'Raleway',san-serif;
31
+ font-size: 20px;
32
+ line-height: 27px;
33
+ color: #808a97;
34
+ font-weight: 400;
35
+ }
36
+ #upgrade-to-premium ol{
37
+ counter-reset: item;
38
+ list-style-type: none;
39
+ margin-left: 0;
40
+ }
41
+ #upgrade-to-premium li.step{
42
+ font-family: 'open sans',san-serif;
43
+ font-size: 15px;
44
+ color: #6a6a6b;
45
+ font-weight: 400;
46
+ position: relative;
47
+ padding-left: 50px;
48
+ line-height: 25px;
49
+ margin-bottom: 25px;
50
+ }
51
+ #upgrade-to-premium li.step:before{
52
+ content: counters(item, ".") " ";
53
+ counter-increment: item;
54
+ position: absolute;
55
+ left: 0;
56
+ top: 0;
57
+ border: 1px solid #808a97;
58
+ width: 30px;
59
+ height: 30px;
60
+ border-radius: 16px;
61
+ background-color: #808a97;
62
+ color: #ffffff;
63
+ font-weight: 700;
64
+ font-size: 18px;
65
+ text-align: center;
66
+ line-height: 27px;
67
+ }
68
+ #upgrade-to-premium li.step img{
69
+ border: 1px solid #b8b8b8;
70
+ width: 600px;
71
+ display: block;
72
+ margin: 15px 0 25px 0;
73
+ }
74
+
75
+ #cboxLoadedContent {
76
+ margin-bottom: 60px!important;
77
+ }
plugin-fw/assets/css/yit-upgrader.css CHANGED
@@ -1,14 +1,14 @@
1
- /* === Plugins Upgrader === */
2
-
3
- .yit-plugin-changelog-wrapper {
4
- display: none;
5
- }
6
-
7
- .yit-plugin-changelog-title {
8
- text-transform: uppercase;
9
- }
10
-
11
- .yit-plugin-changelog {
12
- background: #fcfcfc;
13
- height: 97%;
14
  }
1
+ /* === Plugins Upgrader === */
2
+
3
+ .yit-plugin-changelog-wrapper {
4
+ display: none;
5
+ }
6
+
7
+ .yit-plugin-changelog-title {
8
+ text-transform: uppercase;
9
+ }
10
+
11
+ .yit-plugin-changelog {
12
+ background: #fcfcfc;
13
+ height: 97%;
14
  }
plugin-fw/assets/images/colorbox/border1.png ADDED
Binary file
plugin-fw/assets/images/colorbox/border2.png ADDED
Binary file
plugin-fw/assets/images/colorbox/loading.gif ADDED
Binary file
plugin-fw/assets/images/upgrade-page/01.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/02.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/03.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/04.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/05.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/06.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/07.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/08.jpg ADDED
Binary file
plugin-fw/assets/images/upgrade-page/09.jpg ADDED
Binary file
plugin-fw/assets/images/widgets/box-icon.png ADDED
Binary file
plugin-fw/assets/images/widgets/box-white-icon.png ADDED
Binary file
plugin-fw/assets/images/widgets/despacho.png ADDED
Binary file
plugin-fw/assets/images/widgets/info-icon.png ADDED
Binary file
plugin-fw/assets/images/widgets/link-bg.png ADDED
Binary file
plugin-fw/assets/images/widgets/link-bg2.png ADDED
Binary file
plugin-fw/assets/images/widgets/link-icon.png ADDED
Binary file
plugin-fw/assets/images/widgets/membership-bg.png ADDED
Binary file
plugin-fw/assets/js/jquery.colorbox.js ADDED
@@ -0,0 +1,1105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Colorbox 1.6.3
3
+ license: MIT
4
+ http://www.jacklmoore.com/colorbox
5
+ */
6
+ (function ($, document, window) {
7
+ var
8
+ // Default settings object.
9
+ // See http://jacklmoore.com/colorbox for details.
10
+ defaults = {
11
+ // data sources
12
+ html: false,
13
+ photo: false,
14
+ iframe: false,
15
+ inline: false,
16
+
17
+ // behavior and appearance
18
+ transition: "elastic",
19
+ speed: 300,
20
+ fadeOut: 300,
21
+ width: false,
22
+ initialWidth: "600",
23
+ innerWidth: false,
24
+ maxWidth: false,
25
+ height: false,
26
+ initialHeight: "450",
27
+ innerHeight: false,
28
+ maxHeight: false,
29
+ scalePhotos: true,
30
+ scrolling: true,
31
+ opacity: 0.9,
32
+ preloading: true,
33
+ className: false,
34
+ overlayClose: true,
35
+ escKey: true,
36
+ arrowKey: true,
37
+ top: false,
38
+ bottom: false,
39
+ left: false,
40
+ right: false,
41
+ fixed: false,
42
+ data: undefined,
43
+ closeButton: true,
44
+ fastIframe: true,
45
+ open: false,
46
+ reposition: true,
47
+ loop: true,
48
+ slideshow: false,
49
+ slideshowAuto: true,
50
+ slideshowSpeed: 2500,
51
+ slideshowStart: "start slideshow",
52
+ slideshowStop: "stop slideshow",
53
+ photoRegex: /\.(gif|png|jp(e|g|eg)|bmp|ico|webp|jxr|svg)((#|\?).*)?$/i,
54
+
55
+ // alternate image paths for high-res displays
56
+ retinaImage: false,
57
+ retinaUrl: false,
58
+ retinaSuffix: '@2x.$1',
59
+
60
+ // internationalization
61
+ current: "image {current} of {total}",
62
+ previous: "previous",
63
+ next: "next",
64
+ close: "close",
65
+ xhrError: "This content failed to load.",
66
+ imgError: "This image failed to load.",
67
+
68
+ // accessbility
69
+ returnFocus: true,
70
+ trapFocus: true,
71
+
72
+ // callbacks
73
+ onOpen: false,
74
+ onLoad: false,
75
+ onComplete: false,
76
+ onCleanup: false,
77
+ onClosed: false,
78
+
79
+ rel: function() {
80
+ return this.rel;
81
+ },
82
+ href: function() {
83
+ // using this.href would give the absolute url, when the href may have been inteded as a selector (e.g. '#container')
84
+ return $(this).attr('href');
85
+ },
86
+ title: function() {
87
+ return this.title;
88
+ },
89
+ createImg: function() {
90
+ var img = new Image();
91
+ var attrs = $(this).data('cbox-img-attrs');
92
+
93
+ if (typeof attrs === 'object') {
94
+ $.each(attrs, function(key, val){
95
+ img[key] = val;
96
+ });
97
+ }
98
+
99
+ return img;
100
+ },
101
+ createIframe: function() {
102
+ var iframe = document.createElement('iframe');
103
+ var attrs = $(this).data('cbox-iframe-attrs');
104
+
105
+ if (typeof attrs === 'object') {
106
+ $.each(attrs, function(key, val){
107
+ iframe[key] = val;
108
+ });
109
+ }
110
+
111
+ if ('frameBorder' in iframe) {
112
+ iframe.frameBorder = 0;
113
+ }
114
+ if ('allowTransparency' in iframe) {
115
+ iframe.allowTransparency = "true";
116
+ }
117
+ iframe.name = (new Date()).getTime(); // give the iframe a unique name to prevent caching
118
+ iframe.allowFullscreen = true;
119
+
120
+ return iframe;
121
+ }
122
+ },
123
+
124
+ // Abstracting the HTML and event identifiers for easy rebranding
125
+ colorbox = 'colorbox',
126
+ prefix = 'cbox',
127
+ boxElement = prefix + 'Element',
128
+
129
+ // Events
130
+ event_open = prefix + '_open',
131
+ event_load = prefix + '_load',
132
+ event_complete = prefix + '_complete',
133
+ event_cleanup = prefix + '_cleanup',
134
+ event_closed = prefix + '_closed',
135
+ event_purge = prefix + '_purge',
136
+
137
+ // Cached jQuery Object Variables
138
+ $overlay,
139
+ $box,
140
+ $wrap,
141
+ $content,
142
+ $topBorder,
143
+ $leftBorder,
144
+ $rightBorder,
145
+ $bottomBorder,
146
+ $related,
147
+ $window,
148
+ $loaded,
149
+ $loadingBay,
150
+ $loadingOverlay,
151
+ $title,
152
+ $current,
153
+ $slideshow,
154
+ $next,
155
+ $prev,
156
+ $close,
157
+ $groupControls,
158
+ $events = $('<a/>'), // $({}) would be prefered, but there is an issue with jQuery 1.4.2
159
+
160
+ // Variables for cached values or use across multiple functions
161
+ settings,
162
+ interfaceHeight,
163
+ interfaceWidth,
164
+ loadedHeight,
165
+ loadedWidth,
166
+ index,
167
+ photo,
168
+ open,
169
+ active,
170
+ closing,
171
+ loadingTimer,
172
+ publicMethod,
173
+ div = "div",
174
+ requests = 0,
175
+ previousCSS = {},
176
+ init;
177
+
178
+ // ****************
179
+ // HELPER FUNCTIONS
180
+ // ****************
181
+
182
+ // Convenience function for creating new jQuery objects
183
+ function $tag(tag, id, css) {
184
+ var element = document.createElement(tag);
185
+
186
+ if (id) {
187
+ element.id = prefix + id;
188
+ }
189
+
190
+ if (css) {
191
+ element.style.cssText = css;
192
+ }
193
+
194
+ return $(element);
195
+ }
196
+
197
+ // Get the window height using innerHeight when available to avoid an issue with iOS
198
+ // http://bugs.jquery.com/ticket/6724
199
+ function winheight() {
200
+ return window.innerHeight ? window.innerHeight : $(window).height();
201
+ }
202
+
203
+ function Settings(element, options) {
204
+ if (options !== Object(options)) {
205
+ options = {};
206
+ }
207
+
208
+ this.cache = {};
209
+ this.el = element;
210
+
211
+ this.value = function(key) {
212
+ var dataAttr;
213
+
214
+ if (this.cache[key] === undefined) {
215
+ dataAttr = $(this.el).attr('data-cbox-'+key);
216
+
217
+ if (dataAttr !== undefined) {
218
+ this.cache[key] = dataAttr;
219
+ } else if (options[key] !== undefined) {
220
+ this.cache[key] = options[key];
221
+ } else if (defaults[key] !== undefined) {
222
+ this.cache[key] = defaults[key];
223
+ }
224
+ }
225
+
226
+ return this.cache[key];
227
+ };
228
+
229
+ this.get = function(key) {
230
+ var value = this.value(key);
231
+ return $.isFunction(value) ? value.call(this.el, this) : value;
232
+ };
233
+ }
234
+
235
+ // Determine the next and previous members in a group.
236
+ function getIndex(increment) {
237
+ var
238
+ max = $related.length,
239
+ newIndex = (index + increment) % max;
240
+
241
+ return (newIndex < 0) ? max + newIndex : newIndex;
242
+ }
243
+
244
+ // Convert '%' and 'px' values to integers
245
+ function setSize(size, dimension) {
246
+ return Math.round((/%/.test(size) ? ((dimension === 'x' ? $window.width() : winheight()) / 100) : 1) * parseInt(size, 10));
247
+ }
248
+
249
+ // Checks an href to see if it is a photo.
250
+ // There is a force photo option (photo: true) for hrefs that cannot be matched by the regex.
251
+ function isImage(settings, url) {
252
+ return settings.get('photo') || settings.get('photoRegex').test(url);
253
+ }
254
+
255
+ function retinaUrl(settings, url) {
256
+ return settings.get('retinaUrl') && window.devicePixelRatio > 1 ? url.replace(settings.get('photoRegex'), settings.get('retinaSuffix')) : url;
257
+ }
258
+
259
+ function trapFocus(e) {
260
+ if ('contains' in $box[0] && !$box[0].contains(e.target) && e.target !== $overlay[0]) {
261
+ e.stopPropagation();
262
+ $box.focus();
263
+ }
264
+ }
265
+
266
+ function setClass(str) {
267
+ if (setClass.str !== str) {
268
+ $box.add($overlay).removeClass(setClass.str).addClass(str);
269
+ setClass.str = str;
270
+ }
271
+ }
272
+
273
+ function getRelated(rel) {
274
+ index = 0;
275
+
276
+ if (rel && rel !== false && rel !== 'nofollow') {
277
+ $related = $('.' + boxElement).filter(function () {
278
+ var options = $.data(this, colorbox);
279
+ var settings = new Settings(this, options);
280
+ return (settings.get('rel') === rel);
281
+ });
282
+ index = $related.index(settings.el);
283
+
284
+ // Check direct calls to Colorbox.
285
+ if (index === -1) {
286
+ $related = $related.add(settings.el);
287
+ index = $related.length - 1;
288
+ }
289
+ } else {
290
+ $related = $(settings.el);
291
+ }
292
+ }
293
+
294
+ function trigger(event) {
295
+ // for external use
296
+ $(document).trigger(event);
297
+ // for internal use
298
+ $events.triggerHandler(event);
299
+ }
300
+
301
+ var slideshow = (function(){
302
+ var active,
303
+ className = prefix + "Slideshow_",
304
+ click = "click." + prefix,
305
+ timeOut;
306
+
307
+ function clear () {
308
+ clearTimeout(timeOut);
309
+ }
310
+
311
+ function set() {
312
+ if (settings.get('loop') || $related[index + 1]) {
313
+ clear();
314
+ timeOut = setTimeout(publicMethod.next, settings.get('slideshowSpeed'));
315
+ }
316
+ }
317
+
318
+ function start() {
319
+ $slideshow
320
+ .html(settings.get('slideshowStop'))
321
+ .unbind(click)
322
+ .one(click, stop);
323
+
324
+ $events
325
+ .bind(event_complete, set)
326
+ .bind(event_load, clear);
327
+
328
+ $box.removeClass(className + "off").addClass(className + "on");
329
+ }
330
+
331
+ function stop() {
332
+ clear();
333
+
334
+ $events
335
+ .unbind(event_complete, set)
336
+ .unbind(event_load, clear);
337
+
338
+ $slideshow
339
+ .html(settings.get('slideshowStart'))
340
+ .unbind(click)
341
+ .one(click, function () {
342
+ publicMethod.next();
343
+ start();
344
+ });
345
+
346
+ $box.removeClass(className + "on").addClass(className + "off");
347
+ }
348
+
349
+ function reset() {
350
+ active = false;
351
+ $slideshow.hide();
352
+ clear();
353
+ $events
354
+ .unbind(event_complete, set)
355
+ .unbind(event_load, clear);
356
+ $box.removeClass(className + "off " + className + "on");
357
+ }
358
+
359
+ return function(){
360
+ if (active) {
361
+ if (!settings.get('slideshow')) {
362
+ $events.unbind(event_cleanup, reset);
363
+ reset();
364
+ }
365
+ } else {
366
+ if (settings.get('slideshow') && $related[1]) {
367
+ active = true;
368
+ $events.one(event_cleanup, reset);
369
+ if (settings.get('slideshowAuto')) {
370
+ start();
371
+ } else {
372
+ stop();
373
+ }
374
+ $slideshow.show();
375
+ }
376
+ }
377
+ };
378
+
379
+ }());
380
+
381
+
382
+ function launch(element) {
383
+ var options;
384
+
385
+ if (!closing) {
386
+
387
+ options = $(element).data(colorbox);
388
+
389
+ settings = new Settings(element, options);
390
+
391
+ getRelated(settings.get('rel'));
392
+
393
+ if (!open) {
394
+ open = active = true; // Prevents the page-change action from queuing up if the visitor holds down the left or right keys.
395
+
396
+ setClass(settings.get('className'));
397
+
398
+ // Show colorbox so the sizes can be calculated in older versions of jQuery
399
+ $box.css({visibility:'hidden', display:'block', opacity:''});
400
+
401
+ $loaded = $tag(div, 'LoadedContent', 'width:0; height:0; overflow:hidden; visibility:hidden');
402
+ $content.css({width:'', height:''}).append($loaded);
403
+
404
+ // Cache values needed for size calculations
405
+ interfaceHeight = $topBorder.height() + $bottomBorder.height() + $content.outerHeight(true) - $content.height();
406
+ interfaceWidth = $leftBorder.width() + $rightBorder.width() + $content.outerWidth(true) - $content.width();
407
+ loadedHeight = $loaded.outerHeight(true);
408
+ loadedWidth = $loaded.outerWidth(true);
409
+
410
+ // Opens inital empty Colorbox prior to content being loaded.
411
+ var initialWidth = setSize(settings.get('initialWidth'), 'x');
412
+ var initialHeight = setSize(settings.get('initialHeight'), 'y');
413
+ var maxWidth = settings.get('maxWidth');
414
+ var maxHeight = settings.get('maxHeight');
415
+
416
+ settings.w = Math.max((maxWidth !== false ? Math.min(initialWidth, setSize(maxWidth, 'x')) : initialWidth) - loadedWidth - interfaceWidth, 0);
417
+ settings.h = Math.max((maxHeight !== false ? Math.min(initialHeight, setSize(maxHeight, 'y')) : initialHeight) - loadedHeight - interfaceHeight, 0);
418
+
419
+ $loaded.css({width:'', height:settings.h});
420
+ publicMethod.position();
421
+
422
+ trigger(event_open);
423
+ settings.get('onOpen');
424
+
425
+ $groupControls.add($title).hide();
426
+
427
+ $box.focus();
428
+
429
+ if (settings.get('trapFocus')) {
430
+ // Confine focus to the modal
431
+ // Uses event capturing that is not supported in IE8-
432
+ if (document.addEventListener) {
433
+
434
+ document.addEventListener('focus', trapFocus, true);
435
+
436
+ $events.one(event_closed, function () {
437
+ document.removeEventListener('focus', trapFocus, true);
438
+ });
439
+ }
440
+ }
441
+
442
+ // Return focus on closing
443
+ if (settings.get('returnFocus')) {
444
+ $events.one(event_closed, function () {
445
+ $(settings.el).focus();
446
+ });
447
+ }
448
+ }
449
+
450
+ var opacity = parseFloat(settings.get('opacity'));
451
+ $overlay.css({
452
+ opacity: opacity === opacity ? opacity : '',
453
+ cursor: settings.get('overlayClose') ? 'pointer' : '',
454
+ visibility: 'visible'
455
+ }).show();
456
+
457
+ if (settings.get('closeButton')) {
458
+ $close.html(settings.get('close')).appendTo($content);
459
+ } else {
460
+ $close.appendTo('<div/>'); // replace with .detach() when dropping jQuery < 1.4
461
+ }
462
+
463
+ load();
464
+ }
465
+ }
466
+
467
+ // Colorbox's markup needs to be added to the DOM prior to being called
468
+ // so that the browser will go ahead and load the CSS background images.
469
+ function appendHTML() {
470
+ if (!$box) {
471
+ init = false;
472
+ $window = $(window);
473
+ $box = $tag(div).attr({
474
+ id: colorbox,
475
+ 'class': $.support.opacity === false ? prefix + 'IE' : '', // class for optional IE8 & lower targeted CSS.
476
+ role: 'dialog',
477
+ tabindex: '-1'
478
+ }).hide();
479
+ $overlay = $tag(div, "Overlay").hide();
480
+ $loadingOverlay = $([$tag(div, "LoadingOverlay")[0],$tag(div, "LoadingGraphic")[0]]);
481
+ $wrap = $tag(div, "Wrapper");
482
+ $content = $tag(div, "Content").append(
483
+ $title = $tag(div, "Title"),
484
+ $current = $tag(div, "Current"),
485
+ $prev = $('<button type="button"/>').attr({id:prefix+'Previous'}),
486
+ $next = $('<button type="button"/>').attr({id:prefix+'Next'}),
487
+ $slideshow = $tag('button', "Slideshow"),
488
+ $loadingOverlay
489
+ );
490
+
491
+ $close = $('<button type="button"/>').attr({id:prefix+'Close'});
492
+
493
+ $wrap.append( // The 3x3 Grid that makes up Colorbox
494
+ $tag(div).append(
495
+ $tag(div, "TopLeft"),
496
+ $topBorder = $tag(div, "TopCenter"),
497
+ $tag(div, "TopRight")
498
+ ),
499
+ $tag(div, false, 'clear:left').append(
500
+ $leftBorder = $tag(div, "MiddleLeft"),
501
+ $content,
502
+ $rightBorder = $tag(div, "MiddleRight")
503
+ ),
504
+ $tag(div, false, 'clear:left').append(
505
+ $tag(div, "BottomLeft"),
506
+ $bottomBorder = $tag(div, "BottomCenter"),
507
+ $tag(div, "BottomRight")
508
+ )
509
+ ).find('div div').css({'float': 'left'});
510
+
511
+ $loadingBay = $tag(div, false, 'position:absolute; width:9999px; visibility:hidden; display:none; max-width:none;');
512
+
513
+ $groupControls = $next.add($prev).add($current).add($slideshow);
514
+ }
515
+ if (document.body && !$box.parent().length) {
516
+ $(document.body).append($overlay, $box.append($wrap, $loadingBay));
517
+ }
518
+ }
519
+
520
+ // Add Colorbox's event bindings
521
+ function addBindings() {
522
+ function clickHandler(e) {
523
+ // ignore non-left-mouse-clicks and clicks modified with ctrl / command, shift, or alt.
524
+ // See: http://jacklmoore.com/notes/click-events/
525
+ if (!(e.which > 1 || e.shiftKey || e.altKey || e.metaKey || e.ctrlKey)) {
526
+ e.preventDefault();
527
+ launch(this);
528
+ }
529
+ }
530
+
531
+ if ($box) {
532
+ if (!init) {
533
+ init = true;
534
+
535
+ // Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
536
+ $next.click(function () {
537
+ publicMethod.next();
538
+ });
539
+ $prev.click(function () {
540
+ publicMethod.prev();
541
+ });
542
+ $close.click(function () {
543
+ publicMethod.close();
544
+ });
545
+ $overlay.click(function () {
546
+ if (settings.get('overlayClose')) {
547
+ publicMethod.close();
548
+ }
549
+ });
550
+
551
+ // Key Bindings
552
+ $(document).bind('keydown.' + prefix, function (e) {
553
+ var key = e.keyCode;
554
+ if (open && settings.get('escKey') && key === 27) {
555
+ e.preventDefault();
556
+ publicMethod.close();
557
+ }
558
+ if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
559
+ if (key === 37) {
560
+ e.preventDefault();
561
+ $prev.click();
562
+ } else if (key === 39) {
563
+ e.preventDefault();
564
+ $next.click();
565
+ }
566
+ }
567
+ });
568
+
569
+ if ($.isFunction($.fn.on)) {
570
+ // For jQuery 1.7+
571
+ $(document).on('click.'+prefix, '.'+boxElement, clickHandler);
572
+ } else {
573
+ // For jQuery 1.3.x -> 1.6.x
574
+ // This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed.
575
+ // This is not here for jQuery 1.9, it's here for legacy users.
576
+ $('.'+boxElement).live('click.'+prefix, clickHandler);
577
+ }
578
+ }
579
+ return true;
580
+ }
581
+ return false;
582
+ }
583
+
584
+ // Don't do anything if Colorbox already exists.
585
+ if ($[colorbox]) {
586
+ return;
587
+ }
588
+
589
+ // Append the HTML when the DOM loads
590
+ $(appendHTML);
591
+
592
+
593
+ // ****************
594
+ // PUBLIC FUNCTIONS
595
+ // Usage format: $.colorbox.close();
596
+ // Usage from within an iframe: parent.jQuery.colorbox.close();
597
+ // ****************
598
+
599
+ publicMethod = $.fn[colorbox] = $[colorbox] = function (options, callback) {
600
+ var settings;
601
+ var $obj = this;
602
+
603
+ options = options || {};
604
+
605
+ if ($.isFunction($obj)) { // assume a call to $.colorbox
606
+ $obj = $('<a/>');
607
+ options.open = true;
608
+ }
609
+
610
+ if (!$obj[0]) { // colorbox being applied to empty collection
611
+ return $obj;
612
+ }
613
+
614
+ appendHTML();
615
+
616
+ if (addBindings()) {
617
+
618
+ if (callback) {
619
+ options.onComplete = callback;
620
+ }
621
+
622
+ $obj.each(function () {
623
+ var old = $.data(this, colorbox) || {};
624
+ $.data(this, colorbox, $.extend(old, options));
625
+ }).addClass(boxElement);
626
+
627
+ settings = new Settings($obj[0], options);
628
+
629
+ if (settings.get('open')) {
630
+ launch($obj[0]);
631
+ }
632
+ }
633
+
634
+ return $obj;
635
+ };
636
+
637
+ publicMethod.position = function (speed, loadedCallback) {
638
+ var
639
+ css,
640
+ top = 0,
641
+ left = 0,
642
+ offset = $box.offset(),
643
+ scrollTop,
644
+ scrollLeft;
645
+
646
+ $window.unbind('resize.' + prefix);
647
+
648
+ // remove the modal so that it doesn't influence the document width/height
649
+ $box.css({top: -9e4, left: -9e4});
650
+
651
+ scrollTop = $window.scrollTop();
652
+ scrollLeft = $window.scrollLeft();
653
+
654
+ if (settings.get('fixed')) {
655
+ offset.top -= scrollTop;
656
+ offset.left -= scrollLeft;
657
+ $box.css({position: 'fixed'});
658
+ } else {
659
+ top = scrollTop;
660
+ left = scrollLeft;
661
+ $box.css({position: 'absolute'});
662
+ }
663
+
664
+ // keeps the top and left positions within the browser's viewport.
665
+ if (settings.get('right') !== false) {
666
+ left += Math.max($window.width() - settings.w - loadedWidth - interfaceWidth - setSize(settings.get('right'), 'x'), 0);
667
+ } else if (settings.get('left') !== false) {
668
+ left += setSize(settings.get('left'), 'x');
669
+ } else {
670
+ left += Math.round(Math.max($window.width() - settings.w - loadedWidth - interfaceWidth, 0) / 2);
671
+ }
672
+
673
+ if (settings.get('bottom') !== false) {
674
+ top += Math.max(winheight() - settings.h - loadedHeight - interfaceHeight - setSize(settings.get('bottom'), 'y'), 0);
675
+ } else if (settings.get('top') !== false) {
676
+ top += setSize(settings.get('top'), 'y');
677
+ } else {
678
+ top += Math.round(Math.max(winheight() - settings.h - loadedHeight - interfaceHeight, 0) / 2);
679
+ }
680
+
681
+ $box.css({top: offset.top, left: offset.left, visibility:'visible'});
682
+
683
+ // this gives the wrapper plenty of breathing room so it's floated contents can move around smoothly,
684
+ // but it has to be shrank down around the size of div#colorbox when it's done. If not,
685
+ // it can invoke an obscure IE bug when using iframes.
686
+ $wrap[0].style.width = $wrap[0].style.height = "9999px";
687
+
688
+ function modalDimensions() {
689
+ $topBorder[0].style.width = $bottomBorder[0].style.width = $content[0].style.width = (parseInt($box[0].style.width,10) - interfaceWidth)+'px';
690
+ $content[0].style.height = $leftBorder[0].style.height = $rightBorder[0].style.height = (parseInt($box[0].style.height,10) - interfaceHeight)+'px';
691
+ }
692
+
693
+ css = {width: settings.w + loadedWidth + interfaceWidth, height: settings.h + loadedHeight + interfaceHeight, top: top, left: left};
694
+
695
+ // setting the speed to 0 if the content hasn't changed size or position
696
+ if (speed) {
697
+ var tempSpeed = 0;
698
+ $.each(css, function(i){
699
+ if (css[i] !== previousCSS[i]) {
700
+ tempSpeed = speed;
701
+ return;
702
+ }
703
+ });
704
+ speed = tempSpeed;
705
+ }
706
+
707
+ previousCSS = css;
708
+
709
+ if (!speed) {
710
+ $box.css(css);
711
+ }
712
+
713
+ $box.dequeue().animate(css, {
714
+ duration: speed || 0,
715
+ complete: function () {
716
+ modalDimensions();
717
+
718
+ active = false;
719
+
720
+ // shrink the wrapper down to exactly the size of colorbox to avoid a bug in IE's iframe implementation.
721
+ $wrap[0].style.width = (settings.w + loadedWidth + interfaceWidth) + "px";
722
+ $wrap[0].style.height = (settings.h + loadedHeight + interfaceHeight) + "px";
723
+
724
+ if (settings.get('reposition')) {
725
+ setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
726
+ $window.bind('resize.' + prefix, publicMethod.position);
727
+ }, 1);
728
+ }
729
+
730
+ if ($.isFunction(loadedCallback)) {
731
+ loadedCallback();
732
+ }
733
+ },
734
+ step: modalDimensions
735
+ });
736
+ };
737
+
738
+ publicMethod.resize = function (options) {
739
+ var scrolltop;
740
+
741
+ if (open) {
742
+ options = options || {};
743
+
744
+ if (options.width) {
745
+ settings.w = setSize(options.width, 'x') - loadedWidth - interfaceWidth;
746
+ }
747
+
748
+ if (options.innerWidth) {
749
+ settings.w = setSize(options.innerWidth, 'x');
750
+ }
751
+
752
+ $loaded.css({width: settings.w});
753
+
754
+ if (options.height) {
755
+ settings.h = setSize(options.height, 'y') - loadedHeight - interfaceHeight;
756
+ }
757
+
758
+ if (options.innerHeight) {
759
+ settings.h = setSize(options.innerHeight, 'y');
760
+ }
761
+
762
+ if (!options.innerHeight && !options.height) {
763
+ scrolltop = $loaded.scrollTop();
764
+ $loaded.css({height: "auto"});
765
+ settings.h = $loaded.height();
766
+ }
767
+
768
+ $loaded.css({height: settings.h});
769
+
770
+ if(scrolltop) {
771
+ $loaded.scrollTop(scrolltop);
772
+ }
773
+
774
+ publicMethod.position(settings.get('transition') === "none" ? 0 : settings.get('speed'));
775
+ }
776
+ };
777
+
778
+ publicMethod.prep = function (object) {
779
+ if (!open) {
780
+ return;
781
+ }
782
+
783
+ var callback, speed = settings.get('transition') === "none" ? 0 : settings.get('speed');
784
+
785
+ $loaded.remove();
786
+
787
+ $loaded = $tag(div, 'LoadedContent').append(object);
788
+
789
+ function getWidth() {
790
+ settings.w = settings.w || $loaded.width();
791
+ settings.w = settings.mw && settings.mw < settings.w ? settings.mw : settings.w;
792
+ return settings.w;
793
+ }
794
+ function getHeight() {
795
+ settings.h = settings.h || $loaded.height();
796
+ settings.h = settings.mh && settings.mh < settings.h ? settings.mh : settings.h;
797
+ return settings.h;
798
+ }
799
+
800
+ $loaded.hide()
801
+ .appendTo($loadingBay.show())// content has to be appended to the DOM for accurate size calculations.
802
+ .css({width: getWidth(), overflow: settings.get('scrolling') ? 'auto' : 'hidden'})
803
+ .css({height: getHeight()})// sets the height independently from the width in case the new width influences the value of height.
804
+ .prependTo($content);
805
+
806
+ $loadingBay.hide();
807
+
808
+ // floating the IMG removes the bottom line-height and fixed a problem where IE miscalculates the width of the parent element as 100% of the document width.
809
+
810
+ $(photo).css({'float': 'none'});
811
+
812
+ setClass(settings.get('className'));
813
+
814
+ callback = function () {
815
+ var total = $related.length,
816
+ iframe,
817
+ complete;
818
+
819
+ if (!open) {
820
+ return;
821
+ }
822
+
823
+ function removeFilter() { // Needed for IE8 in versions of jQuery prior to 1.7.2
824
+ if ($.support.opacity === false) {
825
+ $box[0].style.removeAttribute('filter');
826
+ }
827
+ }
828
+
829
+ complete = function () {
830
+ clearTimeout(loadingTimer);
831
+ $loadingOverlay.hide();
832
+ trigger(event_complete);
833
+ settings.get('onComplete');
834
+ };
835
+
836
+
837
+ $title.html(settings.get('title')).show();
838
+ $loaded.show();
839
+
840
+ if (total > 1) { // handle grouping
841
+ if (typeof settings.get('current') === "string") {
842
+ $current.html(settings.get('current').replace('{current}', index + 1).replace('{total}', total)).show();
843
+ }
844
+
845
+ $next[(settings.get('loop') || index < total - 1) ? "show" : "hide"]().html(settings.get('next'));
846
+ $prev[(settings.get('loop') || index) ? "show" : "hide"]().html(settings.get('previous'));
847
+
848
+ slideshow();
849
+
850
+ // Preloads images within a rel group
851
+ if (settings.get('preloading')) {
852
+ $.each([getIndex(-1), getIndex(1)], function(){
853
+ var img,
854
+ i = $related[this],
855
+ settings = new Settings(i, $.data(i, colorbox)),
856
+ src = settings.get('href');
857
+
858
+ if (src && isImage(settings, src)) {
859
+ src = retinaUrl(settings, src);
860
+ img = document.createElement('img');
861
+ img.src = src;
862
+ }
863
+ });
864
+ }
865
+ } else {
866
+ $groupControls.hide();
867
+ }
868
+
869
+ if (settings.get('iframe')) {
870
+
871
+ iframe = settings.get('createIframe');
872
+
873
+ if (!settings.get('scrolling')) {
874
+ iframe.scrolling = "no";
875
+ }
876
+
877
+ $(iframe)
878
+ .attr({
879
+ src: settings.get('href'),
880
+ 'class': prefix + 'Iframe'
881
+ })
882
+ .one('load', complete)
883
+ .appendTo($loaded);
884
+
885
+ $events.one(event_purge, function () {
886
+ iframe.src = "//about:blank";
887
+ });
888
+
889
+ if (settings.get('fastIframe')) {
890
+ $(iframe).trigger('load');
891
+ }
892
+ } else {
893
+ complete();
894
+ }
895
+
896
+ if (settings.get('transition') === 'fade') {
897
+ $box.fadeTo(speed, 1, removeFilter);
898
+ } else {
899
+ removeFilter();
900
+ }
901
+ };
902
+
903
+ if (settings.get('transition') === 'fade') {
904
+ $box.fadeTo(speed, 0, function () {
905
+ publicMethod.position(0, callback);
906
+ });
907
+ } else {
908
+ publicMethod.position(speed, callback);
909
+ }
910
+ };
911
+
912
+ function load () {
913
+ var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;
914
+
915
+ active = true;
916
+
917
+ photo = false;
918
+
919
+ trigger(event_purge);
920
+ trigger(event_load);
921
+ settings.get('onLoad');
922
+
923
+ settings.h = settings.get('height') ?
924
+ setSize(settings.get('height'), 'y') - loadedHeight - interfaceHeight :
925
+ settings.get('innerHeight') && setSize(settings.get('innerHeight'), 'y');
926
+
927
+ settings.w = settings.get('width') ?
928
+ setSize(settings.get('width'), 'x') - loadedWidth - interfaceWidth :
929
+ settings.get('innerWidth') && setSize(settings.get('innerWidth'), 'x');
930
+
931
+ // Sets the minimum dimensions for use in image scaling
932
+ settings.mw = settings.w;
933
+ settings.mh = settings.h;
934
+
935
+ // Re-evaluate the minimum width and height based on maxWidth and maxHeight values.
936
+ // If the width or height exceed the maxWidth or maxHeight, use the maximum values instead.
937
+ if (settings.get('maxWidth')) {
938
+ settings.mw = setSize(settings.get('maxWidth'), 'x') - loadedWidth - interfaceWidth;
939
+ settings.mw = settings.w && settings.w < settings.mw ? settings.w : settings.mw;
940
+ }
941
+ if (settings.get('maxHeight')) {
942
+ settings.mh = setSize(settings.get('maxHeight'), 'y') - loadedHeight - interfaceHeight;
943
+ settings.mh = settings.h && settings.h < settings.mh ? settings.h : settings.mh;
944
+ }
945
+
946
+ href = settings.get('href');
947
+
948
+ loadingTimer = setTimeout(function () {
949
+ $loadingOverlay.show();
950
+ }, 100);
951
+
952
+ if (settings.get('inline')) {
953
+ var $target = $(href);
954
+ // Inserts an empty placeholder where inline content is being pulled from.
955
+ // An event is bound to put inline content back when Colorbox closes or loads new content.
956
+ $inline = $('<div>').hide().insertBefore($target);
957
+
958
+ $events.one(event_purge, function () {
959
+ $inline.replaceWith($target);
960
+ });
961
+
962
+ prep($target);
963
+ } else if (settings.get('iframe')) {
964
+ // IFrame element won't be added to the DOM until it is ready to be displayed,
965
+ // to avoid problems with DOM-ready JS that might be trying to run in that iframe.
966
+ prep(" ");
967
+ } else if (settings.get('html')) {
968
+ prep(settings.get('html'));
969
+ } else if (isImage(settings, href)) {
970
+
971
+ href = retinaUrl(settings, href);
972
+
973
+ photo = settings.get('createImg');
974
+
975
+ $(photo)
976
+ .addClass(prefix + 'Photo')
977
+ .bind('error.'+prefix,function () {
978
+ prep($tag(div, 'Error').html(settings.get('imgError')));
979
+ })
980
+ .one('load', function () {
981
+ if (request !== requests) {
982
+ return;
983
+ }
984
+
985
+ // A small pause because some browsers will occassionaly report a
986
+ // img.width and img.height of zero immediately after the img.onload fires
987
+ setTimeout(function(){
988
+ var percent;
989
+
990
+ if (settings.get('retinaImage') && window.devicePixelRatio > 1) {
991
+ photo.height = photo.height / window.devicePixelRatio;
992
+ photo.width = photo.width / window.devicePixelRatio;
993
+ }
994
+
995
+ if (settings.get('scalePhotos')) {
996
+ setResize = function () {
997
+ photo.height -= photo.height * percent;
998
+ photo.width -= photo.width * percent;
999
+ };
1000
+ if (settings.mw && photo.width > settings.mw) {
1001
+ percent = (photo.width - settings.mw) / photo.width;
1002
+ setResize();
1003
+ }
1004
+ if (settings.mh && photo.height > settings.mh) {
1005
+ percent = (photo.height - settings.mh) / photo.height;
1006
+ setResize();
1007
+ }
1008
+ }
1009
+
1010
+ if (settings.h) {
1011
+ photo.style.marginTop = Math.max(settings.mh - photo.height, 0) / 2 + 'px';
1012
+ }
1013
+
1014
+ if ($related[1] && (settings.get('loop') || $related[index + 1])) {
1015
+ photo.style.cursor = 'pointer';
1016
+
1017
+ $(photo).bind('click.'+prefix, function () {
1018
+ publicMethod.next();
1019
+ });
1020
+ }
1021
+
1022
+ photo.style.width = photo.width + 'px';
1023
+ photo.style.height = photo.height + 'px';
1024
+ prep(photo);
1025
+ }, 1);
1026
+ });
1027
+
1028
+ photo.src = href;
1029
+
1030
+ } else if (href) {
1031
+ $loadingBay.load(href, settings.get('data'), function (data, status) {
1032
+ if (request === requests) {
1033
+ prep(status === 'error' ? $tag(div, 'Error').html(settings.get('xhrError')) : $(this).contents());
1034
+ }
1035
+ });
1036
+ }
1037
+ }
1038
+
1039
+ // Navigates to the next page/image in a set.
1040
+ publicMethod.next = function () {
1041
+ if (!active && $related[1] && (settings.get('loop') || $related[index + 1])) {
1042
+ index = getIndex(1);
1043
+ launch($related[index]);
1044
+ }
1045
+ };
1046
+
1047
+ publicMethod.prev = function () {
1048
+ if (!active && $related[1] && (settings.get('loop') || index)) {
1049
+ index = getIndex(-1);
1050
+ launch($related[index]);
1051
+ }
1052
+ };
1053
+
1054
+ // Note: to use this within an iframe use the following format: parent.jQuery.colorbox.close();
1055
+ publicMethod.close = function () {
1056
+ if (open && !closing) {
1057
+
1058
+ closing = true;
1059
+ open = false;
1060
+ trigger(event_cleanup);
1061
+ settings.get('onCleanup');
1062
+ $window.unbind('.' + prefix);
1063
+ $overlay.fadeTo(settings.get('fadeOut') || 0, 0);
1064
+
1065
+ $box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
1066
+ $box.hide();
1067
+ $overlay.hide();
1068
+ trigger(event_purge);
1069
+ $loaded.remove();
1070
+
1071
+ setTimeout(function () {
1072
+ closing = false;
1073
+ trigger(event_closed);
1074
+ settings.get('onClosed');
1075
+ }, 1);
1076
+ });
1077
+ }
1078
+ };
1079
+
1080
+ // Removes changes Colorbox made to the document, but does not remove the plugin.
1081
+ publicMethod.remove = function () {
1082
+ if (!$box) { return; }
1083
+
1084
+ $box.stop();
1085
+ $[colorbox].close();
1086
+ $box.stop(false, true).remove();
1087
+ $overlay.remove();
1088
+ closing = false;
1089
+ $box = null;
1090
+ $('.' + boxElement)
1091
+ .removeData(colorbox)
1092
+ .removeClass(boxElement);
1093
+
1094
+ $(document).unbind('click.'+prefix).unbind('keydown.'+prefix);
1095
+ };
1096
+
1097
+ // A method for fetching the current element Colorbox is referencing.
1098
+ // returns a jQuery object.
1099
+ publicMethod.element = function () {
1100
+ return $(settings.el);
1101
+ };
1102
+
1103
+ publicMethod.settings = defaults;
1104
+
1105
+ }(jQuery, document, window));
plugin-fw/assets/js/metabox.js CHANGED
@@ -1,355 +1,355 @@
1
- /**
2
- * This file belongs to the YIT Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
- (function ($) {
10
-
11
- $('.metaboxes-tab').each(function () {
12
- $('.tabs-panel', this).hide();
13
-
14
- var active_tab = wpCookies.get('active_metabox_tab');
15
- if (active_tab == null) {
16
- active_tab = $('ul.metaboxes-tabs li:first-child a', this).attr('href');
17
- } else {
18
- active_tab = '#' + active_tab;
19
- }
20
-
21
- $(active_tab).show();
22
-
23
- $('.metaboxes-tabs a', this).click(function (e) {
24
- if ($(this).parent().hasClass('tabs')) {
25
- e.preventDefault();
26
- return;
27
- }
28
-
29
- var t = $(this).attr('href');
30
- $(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
31
- $(this).closest('.metaboxes-tab').find('.tabs-panel').slideUp('fast');
32
- $(t).delay(350).slideDown('fast');
33
-
34
- return false;
35
- });
36
- });
37
-
38
- //upload
39
- var _custom_media = true,
40
- _orig_send_attachment = wp.media.editor.send.attachment;
41
-
42
- $(document).on('click', '.metaboxes-tab .upload_button', function(e) {
43
- var send_attachment_bkp = wp.media.editor.send.attachment;
44
- var button = $(this);
45
- if( typeof button.attr('id') != 'undefined' ) {
46
-
47
- var id = button.attr('id').replace('-button', '');
48
- _custom_media = true;
49
- wp.media.editor.send.attachment = function(props, attachment){
50
- if ( _custom_media ) {
51
- if( $("#"+id).is('input[type=text]') ) {
52
- $("#"+id).val(attachment.url);
53
- } else {
54
- $("#"+id + '_custom').val(attachment.url);
55
- }
56
- } else {
57
- return _orig_send_attachment.apply( this, [props, attachment] );
58
- };
59
- }
60
-
61
- wp.media.editor.open(button);
62
- return false;
63
- }
64
-
65
- });
66
-
67
- $('.metaboxes-tab .add_media').on('click', function(){
68
- _custom_media = false;
69
- });
70
-
71
- //colorpicker
72
- $('.metaboxes-tab .panel-colorpicker').wpColorPicker({
73
- onInit: function(){ console.log('test');},
74
- change: function(event, ui){
75
- },
76
- clear: function(){
77
- var input = $(this);
78
- input.val(input.data('default-color'));
79
- input.change();
80
- }
81
- });
82
-
83
-
84
- $('.metaboxes-tab .panel-colorpicker').each( function() {
85
- var select_label = $(this).data('variations-label');
86
- $(this).parent().parent().find('a.wp-color-result').attr('title', select_label);
87
- });
88
-
89
- //datepicker
90
- $('.metaboxes-tab .panel-datepicker').each( function() {
91
- $(this).datepicker();
92
- });
93
-
94
-
95
- // select
96
- var select_value = function() {
97
- var value = '';
98
-
99
- if( $(this).attr('multiple')){
100
- $(this).children("option:selected").each(function(i,v){
101
- if( i != 0)
102
- value += ', ';
103
-
104
- value += $(v).text();
105
- });
106
-
107
- if( value == '' ){
108
- $(this).children().children("option:selected").each(function(i,v){
109
- if( i != 0)
110
- value += ', ';
111
-
112
- value += $(v).text();
113
- });
114
- }
115
- }
116
- else{
117
- value = $(this).children("option:selected").text();
118
-
119
- if( value == '' )
120
- value = $(this).children().children("option:selected").text();
121
- }
122
-
123
-
124
- if ( $(this).parent().find('span').length <= 0 ) {
125
- $(this).before('<span></span>');
126
- }
127
-
128
- $(this).parent().children('span').replaceWith('<span>'+value +'</span>');
129
- };
130
- $('.metaboxes-tab .select_wrapper select').not('.chosen').each(select_value).change(select_value);
131
-
132
- //Open select multiple
133
- $('.metaboxes-tab .select_wrapper').click( function(e){
134
- e.stopPropagation();
135
- $(this).find('select[multiple]').not('.chosen').toggle();
136
- });
137
- //Stops click propagation on select, to prevent select hide
138
- $('.metaboxes-tab .select_wrapper select[multiple]').not('.chosen').click( function(e){
139
- e.stopPropagation();
140
- });
141
- //Hides select on window click
142
- $(window).click(function(){
143
- $('.metaboxes-tab .select_wrapper select[multiple]').not('.chosen').hide();
144
- })
145
-
146
- //chosen
147
- $('.metaboxes-tab .chosen .select_wrapper select').chosen();
148
-
149
-
150
- $('.metaboxes-tab .slider_container .ui-slider-horizontal').each(function(){
151
- var val = $(this).data('val');
152
- var minValue = $(this).data('min');
153
- var maxValue = $(this).data('max');
154
- var step = $(this).data('step');
155
- var labels = $(this).data('labels');
156
-
157
- $(this).slider({
158
- value: val,
159
- min: minValue,
160
- max: maxValue,
161
- range: 'min',
162
- step: step,
163
-
164
- slide: function( event, ui ) {
165
- $(this).find('input').val( ui.value );
166
- $(this).siblings('.feedback').find('strong' ).text( ui.value + labels );
167
- }
168
- });
169
- });
170
-
171
-
172
- var act_page_option = $('#_active_page_options-container').parent().html();
173
- $('#_active_page_options-container').parent().remove();
174
- $(act_page_option).insertAfter('#yit-post-setting .handlediv');
175
- $(act_page_option).insertAfter('#yit-page-setting .handlediv');
176
-
177
-
178
- $('#_active_page_options-container').on('click', function(){
179
- if( $('#_active_page_options').is(":checked") ){
180
- $('#yit-page-setting .inside .metaboxes-tab, #yit-post-setting .inside .metaboxes-tab').css( { 'opacity' : 1 , 'pointer-events' : 'auto' } );
181
- }else{
182
- $('#yit-page-setting .inside .metaboxes-tab, #yit-post-setting .inside .metaboxes-tab').css( { 'opacity' : 0.5 , 'pointer-events' : 'none' } );
183
- }
184
- }).click();
185
-
186
-
187
- //dependencies handler
188
- $('.metaboxes-tab [data-field]').each(function(){
189
- var t = $(this);
190
-
191
- var field = '#' + t.data('field'),
192
- dep = '#' + t.data('dep'),
193
- value = t.data('value');
194
-
195
-
196
- dependencies_handler( field, dep, value.toString() );
197
-
198
- $(dep).on('change', function(){
199
- dependencies_handler( field, dep, value.toString() );
200
- }).change();
201
- });
202
-
203
- //Handle dependencies.
204
- function dependencies_handler ( id, deps, values ) {
205
- var result = true;
206
-
207
-
208
- //Single dependency
209
- if( typeof( deps ) == 'string' ) {
210
- if( deps.substr( 0, 6 ) == ':radio' )
211
- {deps = deps + ':checked'; }
212
-
213
- var val = $( deps ).val();
214
-
215
- if( $(deps).attr('type') == 'checkbox'){
216
- var thisCheck = $(deps);
217
- if ( thisCheck.is ( ':checked' ) ) {
218
- val = 'yes';
219
- }
220
- else {
221
- val = 'no';
222
- }
223
- }
224
-
225
- var values = values.split( ',' );
226
-
227
- for( var i = 0; i < values.length; i++ ) {
228
- if( val != values[i] )
229
- { result = false; }
230
- else
231
- { result = true; break; }
232
- }
233
- }
234
-
235
- if( !result ) {
236
- $( id + '-container' ).parent().hide();
237
- } else {
238
- $( id + '-container' ).parent().show();
239
- }
240
- };
241
-
242
- // Image gallery
243
- $(document).on('click', '.image-gallery-button', function (e) {
244
- var $t = $(this),
245
- $container = $t.closest('.image-gallery'),
246
- $image_gallery_ids = $container.find('.image_gallery_ids'),
247
- attachment_ids = $image_gallery_ids.val(),
248
- $gallery_images_wrapper = $container.find('ul.slides-wrapper');
249
-
250
-
251
- // Create the media frame.
252
- var image_gallery_frame = wp.media.frames.image_gallery = wp.media({
253
- // Set the title of the modal.
254
- title : $t.data('choose'),
255
- button: {
256
- text: $t.data('update')
257
- },
258
- states: [
259
- new wp.media.controller.Library({
260
- title : $t.data('choose'),
261
- filterable: 'all',
262
- multiple : true
263
- })
264
- ]
265
- });
266
-
267
- // When an image is selected, run a callback.
268
- image_gallery_frame.on('select', function () {
269
- var selection = image_gallery_frame.state().get('selection');
270
- selection.map(function (attachment) {
271
- attachment = attachment.toJSON();
272
-
273
- if (attachment.id) {
274
- attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
275
- $gallery_images_wrapper.append('<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data('delete') + '">x</a></li></ul></li>');
276
- }
277
- });
278
-
279
- $image_gallery_ids.val(attachment_ids);
280
- });
281
-
282
- image_gallery_frame.open();
283
-
284
- });
285
-
286
- // Image ordering
287
- $('.image-gallery ul.slides-wrapper').each(function(){
288
- var $t = $(this);
289
- $t.sortable({
290
- items : 'li.image',
291
- cursor : 'move',
292
- scrollSensitivity : 40,
293
- forcePlaceholderSize: true,
294
- forceHelperSize : false,
295
- helper : 'clone',
296
- opacity : 0.65,
297
- start : function (event, ui) {
298
- ui.item.css('background-color', '#f6f6f6');
299
- },
300
- stop : function (event, ui) {
301
- ui.item.removeAttr('style');
302
- },
303
- update : function (event, ui) {
304
- var attachment_ids = '';
305
-
306
- $t.find('li.image').css('cursor', 'default').each(function () {
307
- var attachment_id = $(this).attr('data-attachment_id');
308
- attachment_ids = attachment_ids + attachment_id + ',';
309
- });
310
-
311
- $t.closest('.image-gallery').find('.image_gallery_ids').val(attachment_ids);
312
- }
313
- });
314
- });
315
-
316
- // Remove images
317
- $('.image-gallery ul.slides-wrapper').on( 'click', 'a.delete', function() {
318
-
319
- var $wrapper = $(this).closest('.image-gallery'),
320
- $gallery = $(this).closest('.image-gallery ul.slides-wrapper'),
321
- $image_gallery_ids = $wrapper.find('.image_gallery_ids'),
322
- attachment_ids = '';
323
-
324
- $(this).closest('li.image').remove();
325
-
326
- $gallery.find('li.image').css('cursor','default').each(function() {
327
- var attachment_id = $(this).attr( 'data-attachment_id' );
328
- attachment_ids = attachment_ids + attachment_id + ',';
329
- });
330
-
331
- $image_gallery_ids.val( attachment_ids );
332
-
333
- return false;
334
- });
335
-
336
-
337
- //on-off
338
- $('.the-metabox .rm_onoff.onoff_container span').on('click', function(ev){
339
-
340
- var input = $( this ).prev( 'input' );
341
- var checked = input.prop( 'checked' );
342
-
343
- if( checked ) {
344
- input.prop( 'checked', false ).attr( 'value', 'no' ).removeClass('onoffchecked');
345
- } else {
346
- input.prop( 'checked', true ).attr( 'value', 'yes' ).addClass('onoffchecked');
347
- }
348
-
349
- input.change();
350
- });
351
-
352
-
353
-
354
-
355
  })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+ (function ($) {
10
+
11
+ $('.metaboxes-tab').each(function () {
12
+ $('.tabs-panel', this).hide();
13
+
14
+ var active_tab = wpCookies.get('active_metabox_tab');
15
+ if (active_tab == null) {
16
+ active_tab = $('ul.metaboxes-tabs li:first-child a', this).attr('href');
17
+ } else {
18
+ active_tab = '#' + active_tab;
19
+ }
20
+
21
+ $(active_tab).show();
22
+
23
+ $('.metaboxes-tabs a', this).click(function (e) {
24
+ if ($(this).parent().hasClass('tabs')) {
25
+ e.preventDefault();
26
+ return;
27
+ }
28
+
29
+ var t = $(this).attr('href');
30
+ $(this).parent().addClass('tabs').siblings('li').removeClass('tabs');
31
+ $(this).closest('.metaboxes-tab').find('.tabs-panel').slideUp('fast');
32
+ $(t).delay(350).slideDown('fast');
33
+
34
+ return false;
35
+ });
36
+ });
37
+
38
+ //upload
39
+ var _custom_media = true,
40
+ _orig_send_attachment = wp.media.editor.send.attachment;
41
+
42
+ $(document).on('click', '.metaboxes-tab .upload_button', function(e) {
43
+ var send_attachment_bkp = wp.media.editor.send.attachment;
44
+ var button = $(this);
45
+ if( typeof button.attr('id') != 'undefined' ) {
46
+
47
+ var id = button.attr('id').replace('-button', '');
48
+ _custom_media = true;
49
+ wp.media.editor.send.attachment = function(props, attachment){
50
+ if ( _custom_media ) {
51
+ if( $("#"+id).is('input[type=text]') ) {
52
+ $("#"+id).val(attachment.url);
53
+ } else {
54
+ $("#"+id + '_custom').val(attachment.url);
55
+ }
56
+ } else {
57
+ return _orig_send_attachment.apply( this, [props, attachment] );
58
+ };
59
+ }
60
+
61
+ wp.media.editor.open(button);
62
+ return false;
63
+ }
64
+
65
+ });
66
+
67
+ $('.metaboxes-tab .add_media').on('click', function(){
68
+ _custom_media = false;
69
+ });
70
+
71
+ //colorpicker
72
+ $('.metaboxes-tab .panel-colorpicker').wpColorPicker({
73
+ onInit: function(){ console.log('test');},
74
+ change: function(event, ui){
75
+ },
76
+ clear: function(){
77
+ var input = $(this);
78
+ input.val(input.data('default-color'));
79
+ input.change();
80
+ }
81
+ });
82
+
83
+
84
+ $('.metaboxes-tab .panel-colorpicker').each( function() {
85
+ var select_label = $(this).data('variations-label');
86
+ $(this).parent().parent().find('a.wp-color-result').attr('title', select_label);
87
+ });
88
+
89
+ //datepicker
90
+ $('.metaboxes-tab .panel-datepicker').each( function() {
91
+ $(this).datepicker();
92
+ });
93
+
94
+
95
+ // select
96
+ var select_value = function() {
97
+ var value = '';
98
+
99
+ if( $(this).attr('multiple')){
100
+ $(this).children("option:selected").each(function(i,v){
101
+ if( i != 0)
102
+ value += ', ';
103
+
104
+ value += $(v).text();
105
+ });
106
+
107
+ if( value == '' ){
108
+ $(this).children().children("option:selected").each(function(i,v){
109
+ if( i != 0)
110
+ value += ', ';
111
+
112
+ value += $(v).text();
113
+ });
114
+ }
115
+ }
116
+ else{
117
+ value = $(this).children("option:selected").text();
118
+
119
+ if( value == '' )
120
+ value = $(this).children().children("option:selected").text();
121
+ }
122
+
123
+
124
+ if ( $(this).parent().find('span').length <= 0 ) {
125
+ $(this).before('<span></span>');
126
+ }
127
+
128
+ $(this).parent().children('span').replaceWith('<span>'+value +'</span>');
129
+ };
130
+ $('.metaboxes-tab .select_wrapper select').not('.chosen').each(select_value).change(select_value);
131
+
132
+ //Open select multiple
133
+ $('.metaboxes-tab .select_wrapper').click( function(e){
134
+ e.stopPropagation();
135
+ $(this).find('select[multiple]').not('.chosen').toggle();
136
+ });
137
+ //Stops click propagation on select, to prevent select hide
138
+ $('.metaboxes-tab .select_wrapper select[multiple]').not('.chosen').click( function(e){
139
+ e.stopPropagation();
140
+ });
141
+ //Hides select on window click
142
+ $(window).click(function(){
143
+ $('.metaboxes-tab .select_wrapper select[multiple]').not('.chosen').hide();
144
+ })
145
+
146
+ //chosen
147
+ $('.metaboxes-tab .chosen .select_wrapper select').chosen();
148
+
149
+
150
+ $('.metaboxes-tab .slider_container .ui-slider-horizontal').each(function(){
151
+ var val = $(this).data('val');
152
+ var minValue = $(this).data('min');
153
+ var maxValue = $(this).data('max');
154
+ var step = $(this).data('step');
155
+ var labels = $(this).data('labels');
156
+
157
+ $(this).slider({
158
+ value: val,
159
+ min: minValue,
160
+ max: maxValue,
161
+ range: 'min',
162
+ step: step,
163
+
164
+ slide: function( event, ui ) {
165
+ $(this).find('input').val( ui.value );
166
+ $(this).siblings('.feedback').find('strong' ).text( ui.value + labels );
167
+ }
168
+ });
169
+ });
170
+
171
+
172
+ var act_page_option = $('#_active_page_options-container').parent().html();
173
+ $('#_active_page_options-container').parent().remove();
174
+ $(act_page_option).insertAfter('#yit-post-setting .handlediv');
175
+ $(act_page_option).insertAfter('#yit-page-setting .handlediv');
176
+
177
+
178
+ $('#_active_page_options-container').on('click', function(){
179
+ if( $('#_active_page_options').is(":checked") ){
180
+ $('#yit-page-setting .inside .metaboxes-tab, #yit-post-setting .inside .metaboxes-tab').css( { 'opacity' : 1 , 'pointer-events' : 'auto' } );
181
+ }else{
182
+ $('#yit-page-setting .inside .metaboxes-tab, #yit-post-setting .inside .metaboxes-tab').css( { 'opacity' : 0.5 , 'pointer-events' : 'none' } );
183
+ }
184
+ }).click();
185
+
186
+
187
+ //dependencies handler
188
+ $('.metaboxes-tab [data-field]').each(function(){
189
+ var t = $(this);
190
+
191
+ var field = '#' + t.data('field'),
192
+ dep = '#' + t.data('dep'),
193
+ value = t.data('value');
194
+
195
+
196
+ dependencies_handler( field, dep, value.toString() );
197
+
198
+ $(dep).on('change', function(){
199
+ dependencies_handler( field, dep, value.toString() );
200
+ }).change();
201
+ });
202
+
203
+ //Handle dependencies.
204
+ function dependencies_handler ( id, deps, values ) {
205
+ var result = true;
206
+
207
+
208
+ //Single dependency
209
+ if( typeof( deps ) == 'string' ) {
210
+ if( deps.substr( 0, 6 ) == ':radio' )
211
+ {deps = deps + ':checked'; }
212
+
213
+ var val = $( deps ).val();
214
+
215
+ if( $(deps).attr('type') == 'checkbox'){
216
+ var thisCheck = $(deps);
217
+ if ( thisCheck.is ( ':checked' ) ) {
218
+ val = 'yes';
219
+ }
220
+ else {
221
+ val = 'no';
222
+ }
223
+ }
224
+
225
+ var values = values.split( ',' );
226
+
227
+ for( var i = 0; i < values.length; i++ ) {
228
+ if( val != values[i] )
229
+ { result = false; }
230
+ else
231
+ { result = true; break; }
232
+ }
233
+ }
234
+
235
+ if( !result ) {
236
+ $( id + '-container' ).parent().hide();
237
+ } else {
238
+ $( id + '-container' ).parent().show();
239
+ }
240
+ };
241
+
242
+ // Image gallery
243
+ $(document).on('click', '.image-gallery-button', function (e) {
244
+ var $t = $(this),
245
+ $container = $t.closest('.image-gallery'),
246
+ $image_gallery_ids = $container.find('.image_gallery_ids'),
247
+ attachment_ids = $image_gallery_ids.val(),
248
+ $gallery_images_wrapper = $container.find('ul.slides-wrapper');
249
+
250
+
251
+ // Create the media frame.
252
+ var image_gallery_frame = wp.media.frames.image_gallery = wp.media({
253
+ // Set the title of the modal.
254
+ title : $t.data('choose'),
255
+ button: {
256
+ text: $t.data('update')
257
+ },
258
+ states: [
259
+ new wp.media.controller.Library({
260
+ title : $t.data('choose'),
261
+ filterable: 'all',
262
+ multiple : true
263
+ })
264
+ ]
265
+ });
266
+
267
+ // When an image is selected, run a callback.
268
+ image_gallery_frame.on('select', function () {
269
+ var selection = image_gallery_frame.state().get('selection');
270
+ selection.map(function (attachment) {
271
+ attachment = attachment.toJSON();
272
+
273
+ if (attachment.id) {
274
+ attachment_ids = attachment_ids ? attachment_ids + "," + attachment.id : attachment.id;
275
+ $gallery_images_wrapper.append('<li class="image" data-attachment_id="' + attachment.id + '"><img src="' + attachment.sizes.thumbnail.url + '"/><ul class="actions"><li><a href="#" class="delete" title="' + $t.data('delete') + '">x</a></li></ul></li>');
276
+ }
277
+ });
278
+
279
+ $image_gallery_ids.val(attachment_ids);
280
+ });
281
+
282
+ image_gallery_frame.open();
283
+
284
+ });
285
+
286
+ // Image ordering
287
+ $('.image-gallery ul.slides-wrapper').each(function(){
288
+ var $t = $(this);
289
+ $t.sortable({
290
+ items : 'li.image',
291
+ cursor : 'move',
292
+ scrollSensitivity : 40,
293
+ forcePlaceholderSize: true,
294
+ forceHelperSize : false,
295
+ helper : 'clone',
296
+ opacity : 0.65,
297
+ start : function (event, ui) {
298
+ ui.item.css('background-color', '#f6f6f6');
299
+ },
300
+ stop : function (event, ui) {
301
+ ui.item.removeAttr('style');
302
+ },
303
+ update : function (event, ui) {
304
+ var attachment_ids = '';
305
+
306
+ $t.find('li.image').css('cursor', 'default').each(function () {
307
+ var attachment_id = $(this).attr('data-attachment_id');
308
+ attachment_ids = attachment_ids + attachment_id + ',';
309
+ });
310
+
311
+ $t.closest('.image-gallery').find('.image_gallery_ids').val(attachment_ids);
312
+ }
313
+ });
314
+ });
315
+
316
+ // Remove images
317
+ $('.image-gallery ul.slides-wrapper').on( 'click', 'a.delete', function() {
318
+
319
+ var $wrapper = $(this).closest('.image-gallery'),
320
+ $gallery = $(this).closest('.image-gallery ul.slides-wrapper'),
321
+ $image_gallery_ids = $wrapper.find('.image_gallery_ids'),
322
+ attachment_ids = '';
323
+
324
+ $(this).closest('li.image').remove();
325
+
326
+ $gallery.find('li.image').css('cursor','default').each(function() {
327
+ var attachment_id = $(this).attr( 'data-attachment_id' );
328
+ attachment_ids = attachment_ids + attachment_id + ',';
329
+ });
330
+
331
+ $image_gallery_ids.val( attachment_ids );
332
+
333
+ return false;
334
+ });
335
+
336
+
337
+ //on-off
338
+ $('.the-metabox .rm_onoff.onoff_container span').on('click', function(ev){
339
+
340
+ var input = $( this ).prev( 'input' );
341
+ var checked = input.prop( 'checked' );
342
+
343
+ if( checked ) {
344
+ input.prop( 'checked', false ).attr( 'value', 'no' ).removeClass('onoffchecked');
345
+ } else {
346
+ input.prop( 'checked', true ).attr( 'value', 'yes' ).addClass('onoffchecked');
347
+ }
348
+
349
+ input.change();
350
+ });
351
+
352
+
353
+
354
+
355
  })(jQuery);
plugin-fw/assets/js/multisite-updater.js CHANGED
@@ -1,216 +1,216 @@
1
- /**
2
- * This file belongs to the YIT Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
- (function ($) {
10
-
11
- var plugins_menu_item = $( '#menu-plugins' ),
12
- update = plugins_menu_item.find('.update-plugins'),
13
- count = update.find(".update-count").text(),
14
- registered = plugins.registered,
15
- activated = plugins.activated;
16
-
17
- if( count == 0 || count == ''){
18
- var update_row = '<span class="update-plugins"><span class="plugin-count"></span></span>';
19
- count = 0;
20
- plugins_menu_item.find( '.wp-menu-name').append( update_row );
21
- }
22
-
23
- /**
24
- * Add the plugin update rows for old plugins
25
- */
26
- update_plugins_row( registered, activated, count, plugins );
27
-
28
- /**
29
- *
30
- * Add the update plugin rows for old plugin
31
- *
32
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
33
- *
34
- * @param registered Registred plugins
35
- * @param activated Activated plugins
36
- * @param count Number of old plugins
37
- * @param localize Localize strings array
38
- *
39
- * @return void
40
- */
41
- function update_plugins_row( registered, activated, count, localize ){
42
- for( var init in registered ){
43
- var plugin = registered[init];
44
- for( var headers in plugin ){
45
-
46
- if( headers == 'slug' || version_compare( plugin[headers].Version, plugin[headers].Latest, '>=' ) ) {
47
- continue;
48
- }
49
-
50
- count = parseInt(count) + 1;
51
- $(".plugin-count").empty().html(count);
52
-
53
- var regex = new RegExp(' ', 'g'),
54
- info = plugin[headers],
55
- name = '' + info.Name,
56
- id = name.replace(regex, '-').trim(),
57
- row = '#' + id.toLowerCase();
58
-
59
- $(row).addClass("update");
60
-
61
- var html = '<tr class="plugin-update-tr">' +
62
- '<td colspan="3" class="plugin-update colspanchange">' +
63
- '<div class="update-message">' + localize.strings.new_version.replace( '%plugin_name%', name ) +
64
- '<a class="thickbox" href="' + localize.details_url[init] + '">' + localize.strings.latest.replace( '%latest%', plugin[headers].Latest ) + '</a>';
65
-
66
- if( typeof activated[init] == "undefined" ) {
67
-
68
- html = html +
69
- ' <em>' + localize.strings.unavailable + '</em>' +
70
- localize.strings.activate.replace( '%activate_link%', localize.licence_activation_url ).replace( '%plugin_name%', name );
71
- } else {
72
- html = html +
73
- '. <a href="' + localize.update_url[init] + '">' + localize.strings.update_now + '</a>';
74
- }
75
-
76
- if( typeof localize.changelogs[init] != 'undefined' ){
77
- html = html + localize.changelogs[init];
78
- }
79
-
80
- html = html +
81
- '</div>' +
82
- '</td>' +
83
- '</tr>';
84
-
85
- $(html).insertAfter(row);
86
- }
87
- }
88
- }
89
-
90
- /**
91
- *
92
- * @param v1 Version 1
93
- * @param v2 Version 2
94
- * @param operator Compare type
95
- * @returns bool
96
- *
97
- * @see php.js library http://phpjs.org/
98
- */
99
- function version_compare(v1, v2, operator) {
100
- // discuss at: http://phpjs.org/functions/version_compare/
101
- // original by: Philippe Jausions (http://pear.php.net/user/jausions)
102
- // original by: Aidan Lister (http://aidanlister.com/)
103
- // reimplemented by: Kankrelune (http://www.webfaktory.info/)
104
- // improved by: Brett Zamir (http://brett-zamir.me)
105
- // improved by: Scott Baker
106
- // improved by: Theriault
107
- // example 1: version_compare('8.2.5rc', '8.2.5a');
108
- // returns 1: 1
109
- // example 2: version_compare('8.2.50', '8.2.52', '<');
110
- // returns 2: true
111
- // example 3: version_compare('5.3.0-dev', '5.3.0');
112
- // returns 3: -1
113
- // example 4: version_compare('4.1.0.52','4.01.0.51');
114
- // returns 4: 1
115
-
116
- this.php_js = this.php_js || {};
117
- this.php_js.ENV = this.php_js.ENV || {};
118
- // END REDUNDANT
119
- // Important: compare must be initialized at 0.
120
- var i = 0,
121
- x = 0,
122
- compare = 0,
123
- // vm maps textual PHP versions to negatives so they're less than 0.
124
- // PHP currently defines these as CASE-SENSITIVE. It is important to
125
- // leave these as negatives so that they can come before numerical versions
126
- // and as if no letters were there to begin with.
127
- // (1alpha is < 1 and < 1.1 but > 1dev1)
128
- // If a non-numerical value can't be mapped to this table, it receives
129
- // -7 as its value.
130
- vm = {
131
- 'dev' : -6,
132
- 'alpha': -5,
133
- 'a' : -5,
134
- 'beta' : -4,
135
- 'b' : -4,
136
- 'RC' : -3,
137
- 'rc' : -3,
138
- '#' : -2,
139
- 'p' : 1,
140
- 'pl' : 1
141
- },
142
- // This function will be called to prepare each version argument.
143
- // It replaces every _, -, and + with a dot.
144
- // It surrounds any nonsequence of numbers/dots with dots.
145
- // It replaces sequences of dots with a single dot.
146
- // version_compare('4..0', '4.0') == 0
147
- // Important: A string of 0 length needs to be converted into a value
148
- // even less than an unexisting value in vm (-7), hence [-8].
149
- // It's also important to not strip spaces because of this.
150
- // version_compare('', ' ') == 1
151
- prepVersion = function (v) {
152
- v = ('' + v)
153
- .replace(/[_\-+]/g, '.');
154
- v = v.replace(/([^.\d]+)/g, '.$1.')
155
- .replace(/\.{2,}/g, '.');
156
- return (!v.length ? [-8] : v.split('.'));
157
- };
158
- // This converts a version component to a number.
159
- // Empty component becomes 0.
160
- // Non-numerical component becomes a negative number.
161
- // Numerical component becomes itself as an integer.
162
- numVersion = function (v) {
163
- return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
164
- };
165
- v1 = prepVersion(v1);
166
- v2 = prepVersion(v2);
167
- x = Math.max(v1.length, v2.length);
168
- for (i = 0; i < x; i++) {
169
- if (v1[i] == v2[i]) {
170
- continue;
171
- }
172
- v1[i] = numVersion(v1[i]);
173
- v2[i] = numVersion(v2[i]);
174
- if (v1[i] < v2[i]) {
175
- compare = -1;
176
- break;
177
- } else if (v1[i] > v2[i]) {
178
- compare = 1;
179
- break;
180
- }
181
- }
182
- if (!operator) {
183
- return compare;
184
- }
185
-
186
- // Important: operator is CASE-SENSITIVE.
187
- // "No operator" seems to be treated as "<."
188
- // Any other values seem to make the function return null.
189
- switch (operator) {
190
- case '>':
191
- case 'gt':
192
- return (compare > 0);
193
- case '>=':
194
- case 'ge':
195
- return (compare >= 0);
196
- case '<=':
197
- case 'le':
198
- return (compare <= 0);
199
- case '==':
200
- case '=':
201
- case 'eq':
202
- return (compare === 0);
203
- case '<>':
204
- case '!=':
205
- case 'ne':
206
- return (compare !== 0);
207
- case '':
208
- case '<':
209
- case 'lt':
210
- return (compare < 0);
211
- default:
212
- return null;
213
- }
214
- }
215
-
216
- })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+ (function ($) {
10
+
11
+ var plugins_menu_item = $( '#menu-plugins' ),
12
+ update = plugins_menu_item.find('.update-plugins'),
13
+ count = update.find(".update-count").text(),
14
+ registered = plugins.registered,
15
+ activated = plugins.activated;
16
+
17
+ if( count == 0 || count == ''){
18
+ var update_row = '<span class="update-plugins"><span class="plugin-count"></span></span>';
19
+ count = 0;
20
+ plugins_menu_item.find( '.wp-menu-name').append( update_row );
21
+ }
22
+
23
+ /**
24
+ * Add the plugin update rows for old plugins
25
+ */
26
+ update_plugins_row( registered, activated, count, plugins );
27
+
28
+ /**
29
+ *
30
+ * Add the update plugin rows for old plugin
31
+ *
32
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
33
+ *
34
+ * @param registered Registred plugins
35
+ * @param activated Activated plugins
36
+ * @param count Number of old plugins
37
+ * @param localize Localize strings array
38
+ *
39
+ * @return void
40
+ */
41
+ function update_plugins_row( registered, activated, count, localize ){
42
+ for( var init in registered ){
43
+ var plugin = registered[init];
44
+ for( var headers in plugin ){
45
+
46
+ if( headers == 'slug' || version_compare( plugin[headers].Version, plugin[headers].Latest, '>=' ) ) {
47
+ continue;
48
+ }
49
+
50
+ count = parseInt(count) + 1;
51
+ $(".plugin-count").empty().html(count);
52
+
53
+ var regex = new RegExp(' ', 'g'),
54
+ info = plugin[headers],
55
+ name = '' + info.Name,
56
+ id = name.replace(regex, '-').trim(),
57
+ row = '#' + id.toLowerCase();
58
+
59
+ $(row).addClass("update");
60
+
61
+ var html = '<tr class="plugin-update-tr">' +
62
+ '<td colspan="3" class="plugin-update colspanchange">' +
63
+ '<div class="update-message">' + localize.strings.new_version.replace( '%plugin_name%', name ) +
64
+ '<a class="thickbox" href="' + localize.details_url[init] + '">' + localize.strings.latest.replace( '%latest%', plugin[headers].Latest ) + '</a>';
65
+
66
+ if( typeof activated[init] == "undefined" ) {
67
+
68
+ html = html +
69
+ ' <em>' + localize.strings.unavailable + '</em>' +
70
+ localize.strings.activate.replace( '%activate_link%', localize.licence_activation_url ).replace( '%plugin_name%', name );
71
+ } else {
72
+ html = html +
73
+ '. <a href="' + localize.update_url[init] + '">' + localize.strings.update_now + '</a>';
74
+ }
75
+
76
+ if( typeof localize.changelogs[init] != 'undefined' ){
77
+ html = html + localize.changelogs[init];
78
+ }
79
+
80
+ html = html +
81
+ '</div>' +
82
+ '</td>' +
83
+ '</tr>';
84
+
85
+ $(html).insertAfter(row);
86
+ }
87
+ }
88
+ }
89
+
90
+ /**
91
+ *
92
+ * @param v1 Version 1
93
+ * @param v2 Version 2
94
+ * @param operator Compare type
95
+ * @returns bool
96
+ *
97
+ * @see php.js library http://phpjs.org/
98
+ */
99
+ function version_compare(v1, v2, operator) {
100
+ // discuss at: http://phpjs.org/functions/version_compare/
101
+ // original by: Philippe Jausions (http://pear.php.net/user/jausions)
102
+ // original by: Aidan Lister (http://aidanlister.com/)
103
+ // reimplemented by: Kankrelune (http://www.webfaktory.info/)
104
+ // improved by: Brett Zamir (http://brett-zamir.me)
105
+ // improved by: Scott Baker
106
+ // improved by: Theriault
107
+ // example 1: version_compare('8.2.5rc', '8.2.5a');
108
+ // returns 1: 1
109
+ // example 2: version_compare('8.2.50', '8.2.52', '<');
110
+ // returns 2: true
111
+ // example 3: version_compare('5.3.0-dev', '5.3.0');
112
+ // returns 3: -1
113
+ // example 4: version_compare('4.1.0.52','4.01.0.51');
114
+ // returns 4: 1
115
+
116
+ this.php_js = this.php_js || {};
117
+ this.php_js.ENV = this.php_js.ENV || {};
118
+ // END REDUNDANT
119
+ // Important: compare must be initialized at 0.
120
+ var i = 0,
121
+ x = 0,
122
+ compare = 0,
123
+ // vm maps textual PHP versions to negatives so they're less than 0.
124
+ // PHP currently defines these as CASE-SENSITIVE. It is important to
125
+ // leave these as negatives so that they can come before numerical versions
126
+ // and as if no letters were there to begin with.
127
+ // (1alpha is < 1 and < 1.1 but > 1dev1)
128
+ // If a non-numerical value can't be mapped to this table, it receives
129
+ // -7 as its value.
130
+ vm = {
131
+ 'dev' : -6,
132
+ 'alpha': -5,
133
+ 'a' : -5,
134
+ 'beta' : -4,
135
+ 'b' : -4,
136
+ 'RC' : -3,
137
+ 'rc' : -3,
138
+ '#' : -2,
139
+ 'p' : 1,
140
+ 'pl' : 1
141
+ },
142
+ // This function will be called to prepare each version argument.
143
+ // It replaces every _, -, and + with a dot.
144
+ // It surrounds any nonsequence of numbers/dots with dots.
145
+ // It replaces sequences of dots with a single dot.
146
+ // version_compare('4..0', '4.0') == 0
147
+ // Important: A string of 0 length needs to be converted into a value
148
+ // even less than an unexisting value in vm (-7), hence [-8].
149
+ // It's also important to not strip spaces because of this.
150
+ // version_compare('', ' ') == 1
151
+ prepVersion = function (v) {
152
+ v = ('' + v)
153
+ .replace(/[_\-+]/g, '.');
154
+ v = v.replace(/([^.\d]+)/g, '.$1.')
155
+ .replace(/\.{2,}/g, '.');
156
+ return (!v.length ? [-8] : v.split('.'));
157
+ };
158
+ // This converts a version component to a number.
159
+ // Empty component becomes 0.
160
+ // Non-numerical component becomes a negative number.
161
+ // Numerical component becomes itself as an integer.
162
+ numVersion = function (v) {
163
+ return !v ? 0 : (isNaN(v) ? vm[v] || -7 : parseInt(v, 10));
164
+ };
165
+ v1 = prepVersion(v1);
166
+ v2 = prepVersion(v2);
167
+ x = Math.max(v1.length, v2.length);
168
+ for (i = 0; i < x; i++) {
169
+ if (v1[i] == v2[i]) {
170
+ continue;
171
+ }
172
+ v1[i] = numVersion(v1[i]);
173
+ v2[i] = numVersion(v2[i]);
174
+ if (v1[i] < v2[i]) {
175
+ compare = -1;
176
+ break;
177
+ } else if (v1[i] > v2[i]) {
178
+ compare = 1;
179
+ break;
180
+ }
181
+ }
182
+ if (!operator) {
183
+ return compare;
184
+ }
185
+
186
+ // Important: operator is CASE-SENSITIVE.
187
+ // "No operator" seems to be treated as "<."
188
+ // Any other values seem to make the function return null.
189
+ switch (operator) {
190
+ case '>':
191
+ case 'gt':
192
+ return (compare > 0);
193
+ case '>=':
194
+ case 'ge':
195
+ return (compare >= 0);
196
+ case '<=':
197
+ case 'le':
198
+ return (compare <= 0);
199
+ case '==':
200
+ case '=':
201
+ case 'eq':
202
+ return (compare === 0);
203
+ case '<>':
204
+ case '!=':
205
+ case 'ne':
206
+ return (compare !== 0);
207
+ case '':
208
+ case '<':
209
+ case 'lt':
210
+ return (compare < 0);
211
+ default:
212
+ return null;
213
+ }
214
+ }
215
+
216
+ })(jQuery);
plugin-fw/assets/js/multisite-updater.min.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(m){function n(c,d,k){this.php_js=this.php_js||{};this.php_js.ENV=this.php_js.ENV||{};var a=0,e=0,b=0,f={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},a=function(a){a=(""+a).replace(/[_\-+]/g,".");a=a.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,".");return a.length?a.split("."):[-8]};numVersion=function(a){return a?isNaN(a)?f[a]||-7:parseInt(a,10):0};c=a(c);d=a(d);e=Math.max(c.length,d.length);for(a=0;a<e;a++)if(c[a]!=d[a])if(c[a]=numVersion(c[a]),d[a]=numVersion(d[a]),
2
- c[a]<d[a]){b=-1;break}else if(c[a]>d[a]){b=1;break}if(!k)return b;switch(k){case ">":case "gt":return 0<b;case ">=":case "ge":return 0<=b;case "<=":case "le":return 0>=b;case "==":case "=":case "eq":return 0===b;case "<>":case "!=":case "ne":return 0!==b;case "":case "<":case "lt":return 0>b;default:return null}}var l=m("#menu-plugins"),g=l.find(".update-plugins").find(".update-count").text(),p=plugins.registered,q=plugins.activated;if(0==g||""==g)g=0,l.find(".wp-menu-name").append('<span class="update-plugins"><span class="plugin-count"></span></span>');
3
- (function(c,d,k,a){for(var e in c){var b=c[e],f;for(f in b)if("slug"!=f&&!n(b[f].Version,b[f].Latest,">=")){k=parseInt(k)+1;m(".plugin-count").empty().html(k);var g=""+b[f].Name,l="#"+g.replace(RegExp(" ","g"),"-").trim().toLowerCase();m(l).addClass("update");var h='<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">'+a.strings.new_version.replace("%plugin_name%",g)+'<a class="thickbox" href="'+a.details_url[e]+'">'+a.strings.latest.replace("%latest%",
4
  b[f].Latest)+"</a>",h="undefined"==typeof d[e]?h+" <em>"+a.strings.unavailable+"</em>"+a.strings.activate.replace("%activate_link%",a.licence_activation_url).replace("%plugin_name%",g):h+'. <a href="'+a.update_url[e]+'">'+a.strings.update_now+"</a>";"undefined"!=typeof a.changelogs[e]&&(h+=a.changelogs[e]);h+="</div></td></tr>";m(h).insertAfter(l)}}})(p,q,g,plugins)})(jQuery);
1
+ (function(m){function n(c,d,k){this.php_js=this.php_js||{};this.php_js.ENV=this.php_js.ENV||{};var a=0,e=0,b=0,f={dev:-6,alpha:-5,a:-5,beta:-4,b:-4,RC:-3,rc:-3,"#":-2,p:1,pl:1},a=function(a){a=(""+a).replace(/[_\-+]/g,".");a=a.replace(/([^.\d]+)/g,".$1.").replace(/\.{2,}/g,".");return a.length?a.split("."):[-8]};numVersion=function(a){return a?isNaN(a)?f[a]||-7:parseInt(a,10):0};c=a(c);d=a(d);e=Math.max(c.length,d.length);for(a=0;a<e;a++)if(c[a]!=d[a])if(c[a]=numVersion(c[a]),d[a]=numVersion(d[a]),
2
+ c[a]<d[a]){b=-1;break}else if(c[a]>d[a]){b=1;break}if(!k)return b;switch(k){case ">":case "gt":return 0<b;case ">=":case "ge":return 0<=b;case "<=":case "le":return 0>=b;case "==":case "=":case "eq":return 0===b;case "<>":case "!=":case "ne":return 0!==b;case "":case "<":case "lt":return 0>b;default:return null}}var l=m("#menu-plugins"),g=l.find(".update-plugins").find(".update-count").text(),p=plugins.registered,q=plugins.activated;if(0==g||""==g)g=0,l.find(".wp-menu-name").append('<span class="update-plugins"><span class="plugin-count"></span></span>');
3
+ (function(c,d,k,a){for(var e in c){var b=c[e],f;for(f in b)if("slug"!=f&&!n(b[f].Version,b[f].Latest,">=")){k=parseInt(k)+1;m(".plugin-count").empty().html(k);var g=""+b[f].Name,l="#"+g.replace(RegExp(" ","g"),"-").trim().toLowerCase();m(l).addClass("update");var h='<tr class="plugin-update-tr"><td colspan="3" class="plugin-update colspanchange"><div class="update-message">'+a.strings.new_version.replace("%plugin_name%",g)+'<a class="thickbox" href="'+a.details_url[e]+'">'+a.strings.latest.replace("%latest%",
4
  b[f].Latest)+"</a>",h="undefined"==typeof d[e]?h+" <em>"+a.strings.unavailable+"</em>"+a.strings.activate.replace("%activate_link%",a.licence_activation_url).replace("%plugin_name%",g):h+'. <a href="'+a.update_url[e]+'">'+a.strings.update_now+"</a>";"undefined"!=typeof a.changelogs[e]&&(h+=a.changelogs[e]);h+="</div></td></tr>";m(h).insertAfter(l)}}})(p,q,g,plugins)})(jQuery);
plugin-fw/assets/js/yit-cpt-unlimited.js CHANGED
@@ -1,79 +1,79 @@
1
- /**
2
- * This file belongs to the YIT Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
- (function($) {
11
- "use strict";
12
- // Author code here
13
-
14
- // open media box
15
- $('.wrap h1, .wrap h2').on( 'click', 'a.multi-uploader', function(event){
16
- event.preventDefault();
17
-
18
- var file_frame,
19
- button = $(this),
20
- selected = false;
21
-
22
- // spinner
23
- button.next('span.spinner').css( 'display', 'inline-block' );
24
-
25
- // If the media frame already exists, reopen it.
26
- if ( file_frame ) {
27
- file_frame.open();
28
- return;
29
- }
30
-
31
- // Create the media frame.
32
- file_frame = wp.media.frames.file_frame = wp.media({
33
- title: button.data( 'uploader_title' ),
34
- button: {
35
- text: button.data( 'uploader_button_text' )
36
- },
37
- library: {
38
- type: 'image'
39
- },
40
- multiple: true // Set to true to allow multiple files to be selected
41
- });
42
-
43
- // When an image is selected, run a callback.
44
- file_frame.on( 'select', function() {
45
- var selection = file_frame.state().get('selection'),
46
- images = [];
47
-
48
- selection.map( function( attachment ) {
49
- attachment = attachment.toJSON();
50
-
51
- // Do something with attachment.id and/or attachment.url here
52
- images.push( { id: attachment.id, url: attachment.url, title: attachment.title } );
53
- });
54
-
55
- // make AJAX request
56
- $.post( ajaxurl, {
57
- images: images,
58
- post_type: typenow,
59
- action: 'yit_cptu_multiuploader'
60
- }, function( data ){
61
- location.reload();
62
- });
63
-
64
- button.next('span.spinner').css( 'display', 'inline-block' );
65
-
66
- // flag
67
- selected = true;
68
- });
69
-
70
- // when close
71
- file_frame.on( 'close', function() {
72
- if ( ! selected ) button.next('span.spinner').hide();
73
- });
74
-
75
- // Finally, open the modal
76
- file_frame.open();
77
- });
78
-
79
  })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+ (function($) {
11
+ "use strict";
12
+ // Author code here
13
+
14
+ // open media box
15
+ $('.wrap h1, .wrap h2').on( 'click', 'a.multi-uploader', function(event){
16
+ event.preventDefault();
17
+
18
+ var file_frame,
19
+ button = $(this),
20
+ selected = false;
21
+
22
+ // spinner
23
+ button.next('span.spinner').css( 'display', 'inline-block' );
24
+
25
+ // If the media frame already exists, reopen it.
26
+ if ( file_frame ) {
27
+ file_frame.open();
28
+ return;
29
+ }
30
+
31
+ // Create the media frame.
32
+ file_frame = wp.media.frames.file_frame = wp.media({
33
+ title: button.data( 'uploader_title' ),
34
+ button: {
35
+ text: button.data( 'uploader_button_text' )
36
+ },
37
+ library: {
38
+ type: 'image'
39
+ },
40
+ multiple: true // Set to true to allow multiple files to be selected
41
+ });
42
+
43
+ // When an image is selected, run a callback.
44
+ file_frame.on( 'select', function() {
45
+ var selection = file_frame.state().get('selection'),
46
+ images = [];
47
+
48
+ selection.map( function( attachment ) {
49
+ attachment = attachment.toJSON();
50
+
51
+ // Do something with attachment.id and/or attachment.url here
52
+ images.push( { id: attachment.id, url: attachment.url, title: attachment.title } );
53
+ });
54
+
55
+ // make AJAX request
56
+ $.post( ajaxurl, {
57
+ images: images,
58
+ post_type: typenow,
59
+ action: 'yit_cptu_multiuploader'
60
+ }, function( data ){
61
+ location.reload();
62
+ });
63
+
64
+ button.next('span.spinner').css( 'display', 'inline-block' );
65
+
66
+ // flag
67
+ selected = true;
68
+ });
69
+
70
+ // when close
71
+ file_frame.on( 'close', function() {
72
+ if ( ! selected ) button.next('span.spinner').hide();
73
+ });
74
+
75
+ // Finally, open the modal
76
+ file_frame.open();
77
+ });
78
+
79
  })(jQuery);
plugin-fw/assets/js/yit-cptu-sortable-posts.js CHANGED
@@ -1,32 +1,32 @@
1
- /**
2
- * This file belongs to the YIT Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
- (function($) {
11
- "use strict";
12
- // Author code here
13
-
14
- $("#the-list").sortable({
15
- items : 'tr',
16
- axis : 'y',
17
- helper : function(e, ui) {
18
- ui.children().children().each(function() {
19
- $(this).width( $(this).width() );
20
- });
21
- return ui;
22
- },
23
- update : function(e, ui) {
24
- $.post( ajaxurl, {
25
- action: 'cpt_sort_posts',
26
- order: $("#the-list").sortable("serialize"),
27
- post_type: typenow
28
- });
29
- }
30
- });
31
-
32
  })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+ (function($) {
11
+ "use strict";
12
+ // Author code here
13
+
14
+ $("#the-list").sortable({
15
+ items : 'tr',
16
+ axis : 'y',
17
+ helper : function(e, ui) {
18
+ ui.children().children().each(function() {
19
+ $(this).width( $(this).width() );
20
+ });
21
+ return ui;
22
+ },
23
+ update : function(e, ui) {
24
+ $.post( ajaxurl, {
25
+ action: 'cpt_sort_posts',
26
+ order: $("#the-list").sortable("serialize"),
27
+ post_type: typenow
28
+ });
29
+ }
30
+ });
31
+
32
  })(jQuery);
plugin-fw/assets/js/yit-plugin-panel-sidebar.js ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * This file belongs to the YIT Plugin Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+
11
+ (function ( $ ) {
12
+ var hide_sidebar_btn = $( '#yit-panel-sidebar-action-hide' ),
13
+ hide_sidebar_text = hide_sidebar_btn.find( '.yit-panel-sidebar-action-title' ),
14
+ sidebar = $( '#yit-panel-sidebar' ),
15
+ panel_wrapper = $( '.' + sidebar_labels.wrapper_class ),
16
+ ajax_hide_option_save_call,
17
+ ajax_hide_option_save = function ( option ) {
18
+ if ( ajax_hide_option_save_call ) {
19
+ ajax_hide_option_save_call.abort();
20
+ }
21
+
22
+ var post_data = {
23
+ option: option,
24
+ action: 'yith_plugin_panel_sidebar_set_collapse_option'
25
+ };
26
+
27
+ ajax_hide_option_save_call = $.ajax( {
28
+ type: "POST",
29
+ data: post_data,
30
+ url: ajaxurl
31
+ } );
32
+ },
33
+ hide_sidebar = function () {
34
+ hide_sidebar_btn.removeClass( 'hide-on-click' );
35
+ hide_sidebar_text.html( sidebar_labels.show_sidebar );
36
+ sidebar.addClass( 'yith-panel-sidebar-hidden' );
37
+ panel_wrapper.addClass( 'yit-admin-panel-content-wrap-full' );
38
+ ajax_hide_option_save( 'yes' );
39
+ },
40
+ show_sidebar = function () {
41
+ hide_sidebar_btn.addClass( 'hide-on-click' );
42
+ hide_sidebar_text.html( sidebar_labels.hide_sidebar );
43
+ sidebar.removeClass( 'yith-panel-sidebar-hidden' );
44
+ panel_wrapper.removeClass( 'yit-admin-panel-content-wrap-full' );
45
+ ajax_hide_option_save( 'no' );
46
+ };
47
+
48
+ hide_sidebar_btn.on( 'click', function () {
49
+ if ( $( this ).is( '.hide-on-click' ) ) {
50
+ hide_sidebar();
51
+ } else {
52
+ show_sidebar();
53
+ }
54
+ } );
55
+
56
+ })( jQuery );
plugin-fw/assets/js/yit-plugin-panel-sidebar.min.js ADDED
@@ -0,0 +1 @@
 
1
+ !function(a){var i,e=a("#yit-panel-sidebar-action-hide"),n=e.find(".yit-panel-sidebar-action-title"),l=a("#yit-panel-sidebar"),s=a("."+sidebar_labels.wrapper_class),t=function(e){i&&i.abort();var n={option:e,action:"yith_plugin_panel_sidebar_set_collapse_option"};i=a.ajax({type:"POST",data:n,url:ajaxurl})},d=function(){e.removeClass("hide-on-click"),n.html(sidebar_labels.show_sidebar),l.addClass("yith-panel-sidebar-hidden"),s.addClass("yit-admin-panel-content-wrap-full"),t("yes")},o=function(){e.addClass("hide-on-click"),n.html(sidebar_labels.hide_sidebar),l.removeClass("yith-panel-sidebar-hidden"),s.removeClass("yit-admin-panel-content-wrap-full"),t("no")};e.on("click",function(){a(this).is(".hide-on-click")?d():o()})}(jQuery);
plugin-fw/assets/js/yit-plugin-panel.js CHANGED
@@ -1,329 +1,329 @@
1
- /**
2
- * This file belongs to the YIT Plugin Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
-
11
- (function ($) {
12
-
13
- // select
14
- var select_value = function () {
15
-
16
- var value = '';
17
-
18
- if ($(this).attr('multiple')) {
19
- $(this).children("option:selected").each(function (i, v) {
20
- if (i != 0)
21
- value += ', ';
22
-
23
- value += $(v).text();
24
- });
25
-
26
- if (value == '') {
27
- $(this).children().children("option:selected").each(function (i, v) {
28
- if (i != 0)
29
- value += ', ';
30
-
31
- value += $(v).text();
32
- });
33
- }
34
- }
35
- else {
36
- value = $(this).children("option:selected").text();
37
-
38
- if (value == '')
39
- value = $(this).children().children("option:selected").text();
40
- }
41
-
42
-
43
- if ($(this).parent().find('span').length <= 0) {
44
- $(this).before('<span></span>');
45
- }
46
-
47
- $(this).parent().children('span').replaceWith('<span>' + value + '</span>');
48
- };
49
- $('.plugin-option .select_wrapper select').not('.chosen').each(select_value).change(select_value);
50
-
51
- //Open select multiple
52
- $('.plugin-option .select_wrapper').click(function (e) {
53
- e.stopPropagation();
54
- $(this).find('select[multiple]').not('.chosen').toggle();
55
- });
56
- //Stops click propagation on select, to prevent select hide
57
- $('.plugin-option .select_wrapper select[multiple]').not('.chosen').click(function (e) {
58
- e.stopPropagation();
59
- });
60
- //Hides select on window click
61
- $(window).click(function () {
62
- $('.plugin-option .select_wrapper select[multiple]').not('.chosen').hide();
63
- })
64
- //chosen
65
- $('.plugin-option .chosen .select_wrapper select').chosen();
66
-
67
- // on-off
68
- $('.plugin-option .onoff_container span').on('click', function () {
69
- var input = $(this).prev('input');
70
- var checked = input.prop('checked');
71
-
72
- if (checked) {
73
- input.prop('checked', false).attr('value', 'no').removeClass('onoffchecked');
74
- } else {
75
- input.prop('checked', true).attr('value', 'yes').addClass('onoffchecked');
76
- }
77
-
78
- input.change();
79
- });
80
-
81
-
82
- //slider
83
- $('.plugin-option .slider_container .ui-slider-horizontal').each(function () {
84
- var val = $(this).data('val');
85
- var minValue = $(this).data('min');
86
- var maxValue = $(this).data('max');
87
- var step = $(this).data('step');
88
- var labels = $(this).data('labels');
89
-
90
- $(this).slider({
91
- value: val,
92
- min : minValue,
93
- max : maxValue,
94
- range: 'min',
95
- step : step,
96
-
97
- slide: function (event, ui) {
98
- $(this).find('input').val(ui.value);
99
- $(this).siblings('.feedback').find('strong').text(ui.value + labels);
100
- }
101
- });
102
- });
103
-
104
-
105
- if (typeof wp !== 'undefined' && typeof wp.media !== 'undefined') {
106
-
107
- //upload
108
- var _custom_media = true,
109
- _orig_send_attachment = wp.media.editor.send.attachment;
110
-
111
- // preview
112
- $('.plugin-option .upload_img_url').change(function () {
113
- var url = $(this).val();
114
- var re = new RegExp("(http|ftp|https)://[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico)");
115
-
116
- var preview = $(this).parents().siblings('.upload_img_preview');
117
- if (re.test(url)) {
118
- preview.html('<img src="' + url + '" style="max-width:600px; max-height:300px;" />');
119
- } else {
120
- preview.html('');
121
- }
122
- }).trigger( 'change' );
123
-
124
- $( document ).on( 'click', '.plugin-option .upload_button', function(e) {
125
- e.preventDefault();
126
-
127
- var t = $(this),
128
- custom_uploader,
129
- id = t.attr('id').replace(/-button$/, '');
130
-
131
- //If the uploader object has already been created, reopen the dialog
132
- if (custom_uploader) {
133
- custom_uploader.open();
134
- return;
135
- }
136
-
137
- var custom_uploader_states = [
138
- // Main states.
139
- new wp.media.controller.Library({
140
- library: wp.media.query(),
141
- multiple: false,
142
- title: 'Choose Image',
143
- priority: 20,
144
- filterable: 'uploaded'
145
- })
146
- ];
147
-
148
- // Create the media frame.
149
- custom_uploader = wp.media.frames.downloadable_file = wp.media({
150
- // Set the title of the modal.
151
- title: 'Choose Image',
152
- library: {
153
- type: ''
154
- },
155
- button: {
156
- text: 'Choose Image'
157
- },
158
- multiple: false,
159
- states: custom_uploader_states
160
- });
161
-
162
-
163
- //When a file is selected, grab the URL and set it as the text field's value
164
- custom_uploader.on( 'select' , function() {
165
- var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
166
-
167
- $("#" + id).val( attachment.url );
168
- // Save the id of the selected element to an element which name is the same with
169
- // a suffix "-yith-attachment-id"
170
- if ($("#" + id + "-yith-attachment-id")) {
171
- $("#" + id + "-yith-attachment-id").val(attachment.id);
172
- }
173
-
174
- $('.plugin-option .upload_img_url').trigger('change');
175
- });
176
-
177
- //Open the uploader dialog
178
- custom_uploader.open();
179
- });
180
-
181
- $( document).on( 'click', '.plugin-option .upload_button_reset', function(e){
182
- var t = $(this),
183
- id = t.attr('id'),
184
- input_id = t.attr('id').replace(/-button_reset$/, ''),
185
- default_value = $('#' + id).data('default');
186
-
187
- $("#" + input_id).val( default_value );
188
- $('.plugin-option .upload_img_url').trigger('change');
189
- } );
190
- }
191
-
192
- $('.plugin-option .add_media').on('click', function () {
193
- _custom_media = false;
194
- });
195
-
196
- //dependencies handler
197
- $('[data-field]').each(function () {
198
- var t = $(this);
199
-
200
- var field = '#' + t.data('field'),
201
- dep = '#' + t.data('dep'),
202
- value = t.data('value');
203
-
204
- $(dep).on('change',function () {
205
- dependencies_handler(field, dep, value.toString());
206
- }).change();
207
- });
208
-
209
- //Handle dependencies.
210
- function dependencies_handler(id, deps, values) {
211
- var result = true;
212
-
213
- //Single dependency
214
- if (typeof( deps ) == 'string') {
215
- if (deps.substr(0, 6) == ':radio') {
216
- deps = deps + ':checked';
217
- }
218
-
219
- var values = values.split(',');
220
-
221
- for (var i = 0; i < values.length; i++) {
222
-
223
- if ($(deps).val() != values[i]) {
224
- result = false;
225
- }
226
- else {
227
- result = true;
228
- break;
229
- }
230
- }
231
- }
232
-
233
- if (!result) {
234
- $(id + '-container').closest('tr').hide();
235
- } else {
236
- $(id + '-container').closest('tr').show();
237
- }
238
- };
239
-
240
- //connected list
241
- $('.rm_connectedlist').each(function () {
242
- var ul = $(this).find('ul');
243
- var input = $(this).find(':hidden');
244
- var sortable = ul.sortable({
245
- connectWith: ul,
246
- update : function (event, ui) {
247
- var value = {};
248
-
249
- ul.each(function () {
250
- var options = {};
251
-
252
- $(this).children().each(function () {
253
- options[ $(this).data('option') ] = $(this).text();
254
- });
255
-
256
- value[ $(this).data('list') ] = options;
257
- });
258
-
259
- input.val((JSON.stringify(value)).replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0'));
260
- }
261
- }).disableSelection();
262
- });
263
-
264
- $(document).ready(function () {
265
-
266
- $('.yith-video-link').click(function (event) {
267
- event.preventDefault();
268
- var target = $(this).data('video-id');
269
-
270
- $('.' + target).dialog({
271
- dialogClass : 'wp-dialog yit-dialog yit-video-dialog',
272
- modal : true,
273
- closeOnEscape: true,
274
- width : 'auto',
275
- resizable : false,
276
- draggable : false,
277
- create : function (event, ui) {
278
- $(this).css("maxWidth", "853px");
279
- },
280
- open : function (event, ui) {
281
-
282
- $('.ui-widget-overlay').bind('click', function () {
283
- $(this).siblings('.ui-dialog').find('.ui-dialog-content').dialog('close');
284
- });
285
-
286
- }
287
-
288
- });
289
-
290
- $('.ui-dialog :button').blur();
291
-
292
- });
293
- });
294
-
295
- //codemirror
296
- $(document).ready(function () {
297
- $('.codemirror').each(function (i, v) {
298
- var editor = CodeMirror.fromTextArea(v, {
299
- lineNumbers : 1,
300
- mode : 'javascript',
301
- showCursorWhenSelecting: true
302
- })
303
-
304
- $(v).data('codemirrorInstance', editor);
305
- })
306
- })
307
-
308
- //google analytics generation
309
- $(document).ready(function () {
310
- $('.google-analytic-generate').click(function () {
311
- var editor = $('#' + $(this).data('textarea')).data('codemirrorInstance');
312
- var gatc = $('#' + $(this).data('input')).val();
313
- var basename = $(this).data('basename');
314
-
315
- var text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n";
316
- text += "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\n";
317
- text += "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n";
318
- text += "})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n";
319
- text += "ga('create', '" + gatc + "', '" + basename + "');\n";
320
- text += "ga('send', 'pageview');\n";
321
- editor.replaceRange(
322
- text,
323
- editor.getCursor('start'),
324
- editor.getCursor('end')
325
- )
326
- })
327
- })
328
-
329
  })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Plugin Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+
11
+ (function ($) {
12
+
13
+ // select
14
+ var select_value = function () {
15
+
16
+ var value = '';
17
+
18
+ if ($(this).attr('multiple')) {
19
+ $(this).children("option:selected").each(function (i, v) {
20
+ if (i != 0)
21
+ value += ', ';
22
+
23
+ value += $(v).text();
24
+ });
25
+
26
+ if (value == '') {
27
+ $(this).children().children("option:selected").each(function (i, v) {
28
+ if (i != 0)
29
+ value += ', ';
30
+
31
+ value += $(v).text();
32
+ });
33
+ }
34
+ }
35
+ else {
36
+ value = $(this).children("option:selected").text();
37
+
38
+ if (value == '')
39
+ value = $(this).children().children("option:selected").text();
40
+ }
41
+
42
+
43
+ if ($(this).parent().find('span').length <= 0) {
44
+ $(this).before('<span></span>');
45
+ }
46
+
47
+ $(this).parent().children('span').replaceWith('<span>' + value + '</span>');
48
+ };
49
+ $('.plugin-option .select_wrapper select').not('.chosen').each(select_value).change(select_value);
50
+
51
+ //Open select multiple
52
+ $('.plugin-option .select_wrapper').click(function (e) {
53
+ e.stopPropagation();
54
+ $(this).find('select[multiple]').not('.chosen').toggle();
55
+ });
56
+ //Stops click propagation on select, to prevent select hide
57
+ $('.plugin-option .select_wrapper select[multiple]').not('.chosen').click(function (e) {
58
+ e.stopPropagation();
59
+ });
60
+ //Hides select on window click
61
+ $(window).click(function () {
62
+ $('.plugin-option .select_wrapper select[multiple]').not('.chosen').hide();
63
+ })
64
+ //chosen
65
+ $('.plugin-option .chosen .select_wrapper select').chosen();
66
+
67
+ // on-off
68
+ $('.plugin-option .onoff_container span').on('click', function () {
69
+ var input = $(this).prev('input');
70
+ var checked = input.prop('checked');
71
+
72
+ if (checked) {
73
+ input.prop('checked', false).attr('value', 'no').removeClass('onoffchecked');
74
+ } else {
75
+ input.prop('checked', true).attr('value', 'yes').addClass('onoffchecked');
76
+ }
77
+
78
+ input.change();
79
+ });
80
+
81
+
82
+ //slider
83
+ $('.plugin-option .slider_container .ui-slider-horizontal').each(function () {
84
+ var val = $(this).data('val');
85
+ var minValue = $(this).data('min');
86
+ var maxValue = $(this).data('max');
87
+ var step = $(this).data('step');
88
+ var labels = $(this).data('labels');
89
+
90
+ $(this).slider({
91
+ value: val,
92
+ min : minValue,
93
+ max : maxValue,
94
+ range: 'min',
95
+ step : step,
96
+
97
+ slide: function (event, ui) {
98
+ $(this).find('input').val(ui.value);
99
+ $(this).siblings('.feedback').find('strong').text(ui.value + labels);
100
+ }
101
+ });
102
+ });
103
+
104
+
105
+ if (typeof wp !== 'undefined' && typeof wp.media !== 'undefined') {
106
+
107
+ //upload
108
+ var _custom_media = true,
109
+ _orig_send_attachment = wp.media.editor.send.attachment;
110
+
111
+ // preview
112
+ $('.plugin-option .upload_img_url').change(function () {
113
+ var url = $(this).val();
114
+ var re = new RegExp("(http|ftp|https)://[a-zA-Z0-9@?^=%&amp;:/~+#-_.]*.(gif|jpg|jpeg|png|ico)");
115
+
116
+ var preview = $(this).parents().siblings('.upload_img_preview');
117
+ if (re.test(url)) {
118
+ preview.html('<img src="' + url + '" style="max-width:600px; max-height:300px;" />');
119
+ } else {
120
+ preview.html('');
121
+ }
122
+ }).trigger( 'change' );
123
+
124
+ $( document ).on( 'click', '.plugin-option .upload_button', function(e) {
125
+ e.preventDefault();
126
+
127
+ var t = $(this),
128
+ custom_uploader,
129
+ id = t.attr('id').replace(/-button$/, '');
130
+
131
+ //If the uploader object has already been created, reopen the dialog
132
+ if (custom_uploader) {
133
+ custom_uploader.open();
134
+ return;
135
+ }
136
+
137
+ var custom_uploader_states = [
138
+ // Main states.
139
+ new wp.media.controller.Library({
140
+ library: wp.media.query(),
141
+ multiple: false,
142
+ title: 'Choose Image',
143
+ priority: 20,
144
+ filterable: 'uploaded'
145
+ })
146
+ ];
147
+
148
+ // Create the media frame.
149
+ custom_uploader = wp.media.frames.downloadable_file = wp.media({
150
+ // Set the title of the modal.
151
+ title: 'Choose Image',
152
+ library: {
153
+ type: ''
154
+ },
155
+ button: {
156
+ text: 'Choose Image'
157
+ },
158
+ multiple: false,
159
+ states: custom_uploader_states
160
+ });
161
+
162
+
163
+ //When a file is selected, grab the URL and set it as the text field's value
164
+ custom_uploader.on( 'select' , function() {
165
+ var attachment = custom_uploader.state().get( 'selection' ).first().toJSON();
166
+
167
+ $("#" + id).val( attachment.url );
168
+ // Save the id of the selected element to an element which name is the same with
169
+ // a suffix "-yith-attachment-id"
170
+ if ($("#" + id + "-yith-attachment-id")) {
171
+ $("#" + id + "-yith-attachment-id").val(attachment.id);
172
+ }
173
+
174
+ $('.plugin-option .upload_img_url').trigger('change');
175
+ });
176
+
177
+ //Open the uploader dialog
178
+ custom_uploader.open();
179
+ });
180
+
181
+ $( document).on( 'click', '.plugin-option .upload_button_reset', function(e){
182
+ var t = $(this),
183
+ id = t.attr('id'),
184
+ input_id = t.attr('id').replace(/-button_reset$/, ''),
185
+ default_value = $('#' + id).data('default');
186
+
187
+ $("#" + input_id).val( default_value );
188
+ $('.plugin-option .upload_img_url').trigger('change');
189
+ } );
190
+ }
191
+
192
+ $('.plugin-option .add_media').on('click', function () {
193
+ _custom_media = false;
194
+ });
195
+
196
+ //dependencies handler
197
+ $('[data-field]').each(function () {
198
+ var t = $(this);
199
+
200
+ var field = '#' + t.data('field'),
201
+ dep = '#' + t.data('dep'),
202
+ value = t.data('value');
203
+
204
+ $(dep).on('change',function () {
205
+ dependencies_handler(field, dep, value.toString());
206
+ }).change();
207
+ });
208
+
209
+ //Handle dependencies.
210
+ function dependencies_handler(id, deps, values) {
211
+ var result = true;
212
+
213
+ //Single dependency
214
+ if (typeof( deps ) == 'string') {
215
+ if (deps.substr(0, 6) == ':radio') {
216
+ deps = deps + ':checked';
217
+ }
218
+
219
+ var values = values.split(',');
220
+
221
+ for (var i = 0; i < values.length; i++) {
222
+
223
+ if ($(deps).val() != values[i]) {
224
+ result = false;
225
+ }
226
+ else {
227
+ result = true;
228
+ break;
229
+ }
230
+ }
231
+ }
232
+
233
+ if (!result) {
234
+ $(id + '-container').closest('tr').hide();
235
+ } else {
236
+ $(id + '-container').closest('tr').show();
237
+ }
238
+ };
239
+
240
+ //connected list
241
+ $('.rm_connectedlist').each(function () {
242
+ var ul = $(this).find('ul');
243
+ var input = $(this).find(':hidden');
244
+ var sortable = ul.sortable({
245
+ connectWith: ul,
246
+ update : function (event, ui) {
247
+ var value = {};
248
+
249
+ ul.each(function () {
250
+ var options = {};
251
+
252
+ $(this).children().each(function () {
253
+ options[ $(this).data('option') ] = $(this).text();
254
+ });
255
+
256
+ value[ $(this).data('list') ] = options;
257
+ });
258
+
259
+ input.val((JSON.stringify(value)).replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0'));
260
+ }
261
+ }).disableSelection();
262
+ });
263
+
264
+ $(document).ready(function () {
265
+
266
+ $('.yith-video-link').click(function (event) {
267
+ event.preventDefault();
268
+ var target = $(this).data('video-id');
269
+
270
+ $('.' + target).dialog({
271
+ dialogClass : 'wp-dialog yit-dialog yit-video-dialog',
272
+ modal : true,
273
+ closeOnEscape: true,
274
+ width : 'auto',
275
+ resizable : false,
276
+ draggable : false,
277
+ create : function (event, ui) {
278
+ $(this).css("maxWidth", "853px");
279
+ },
280
+ open : function (event, ui) {
281
+
282
+ $('.ui-widget-overlay').bind('click', function () {
283
+ $(this).siblings('.ui-dialog').find('.ui-dialog-content').dialog('close');
284
+ });
285
+
286
+ }
287
+
288
+ });
289
+
290
+ $('.ui-dialog :button').blur();
291
+
292
+ });
293
+ });
294
+
295
+ //codemirror
296
+ $(document).ready(function () {
297
+ $('.codemirror').each(function (i, v) {
298
+ var editor = CodeMirror.fromTextArea(v, {
299
+ lineNumbers : 1,
300
+ mode : 'javascript',
301
+ showCursorWhenSelecting: true
302
+ })
303
+
304
+ $(v).data('codemirrorInstance', editor);
305
+ })
306
+ })
307
+
308
+ //google analytics generation
309
+ $(document).ready(function () {
310
+ $('.google-analytic-generate').click(function () {
311
+ var editor = $('#' + $(this).data('textarea')).data('codemirrorInstance');
312
+ var gatc = $('#' + $(this).data('input')).val();
313
+ var basename = $(this).data('basename');
314
+
315
+ var text = "(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n";
316
+ text += "(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement( o ),\n";
317
+ text += "m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n";
318
+ text += "})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n\n";
319
+ text += "ga('create', '" + gatc + "', '" + basename + "');\n";
320
+ text += "ga('send', 'pageview');\n";
321
+ editor.replaceRange(
322
+ text,
323
+ editor.getCursor('start'),
324
+ editor.getCursor('end')
325
+ )
326
+ })
327
+ })
328
+
329
  })(jQuery);
plugin-fw/assets/js/yit-wp-pointer.js CHANGED
@@ -1,84 +1,84 @@
1
- jQuery(document).ready( function($) {
2
-
3
- var pointers = custom_pointer.pointers[0],
4
- options = pointers.options,
5
- target = $(pointers.target),
6
- pointer_id = pointers.pointer_id;
7
-
8
- $(target).find('.wp-submenu li a').each(function () {
9
-
10
- var t = $(this),
11
- href = t.attr('href');
12
-
13
- href = href.replace('admin.php?page=', '');
14
-
15
- if( href == pointer_id ){
16
-
17
- var selected_plugin_row = t.add( target ),
18
- top_level_menu = target.find( pointers.target.replace( '#', '.' ) );
19
-
20
- target.toggleClass('wp-no-current-submenu wp-menu-open wp-has-current-submenu');
21
-
22
- t.pointer({
23
- pointerClass: 'yit-wp-pointer',
24
- content : options.content,
25
- position: options.position,
26
- open : function () {
27
- selected_plugin_row.toggleClass( 'yit-pointer-selected-row' );
28
- top_level_menu.addClass( 'yit-pointer' );
29
- },
30
-
31
-
32
- close : function () {
33
- target.toggleClass('wp-no-current-submenu wp-menu-open wp-has-current-submenu');
34
- selected_plugin_row.toggleClass( 'yit-pointer-selected-row' );
35
- top_level_menu.removeClass( 'yit-pointer' );
36
-
37
- $.ajax({
38
- type : 'POST',
39
- url : ajaxurl,
40
- data : {
41
- "action" : "dismiss-wp-pointer",
42
- "pointer": pointer_id
43
- },
44
- success: function (response) {
45
- }
46
- });
47
-
48
- }
49
- }).pointer('open');
50
- } else if( 'yith_default_pointer' == pointer_id ) {
51
-
52
- var selected_plugin_row = t.add( target ),
53
- top_level_menu = target.find( pointers.target.replace( '#', '.' )),
54
- yit_plugins = $( pointers.target );
55
-
56
- yit_plugins.addClass('wp-has-current-submenu');
57
-
58
- top_level_menu.pointer({
59
- pointerClass: 'yit-wp-pointer',
60
- content : options.content,
61
- position: options.position,
62
-
63
- open : function () {
64
- yit_plugins.addClass( 'yit-pointer-selected-row' );
65
- },
66
-
67
- close : function () {
68
- yit_plugins.removeClass( 'yit-pointer-selected-row wp-has-current-submenu' );
69
-
70
- $.ajax({
71
- type : 'POST',
72
- url : ajaxurl,
73
- data : {
74
- "action" : "dismiss-wp-pointer",
75
- "pointer": pointer_id
76
- },
77
- success: function (response) {
78
- }
79
- });
80
- }
81
- }).pointer('open');
82
- }
83
- });
84
  });
1
+ jQuery(document).ready( function($) {
2
+
3
+ var pointers = custom_pointer.pointers[0],
4
+ options = pointers.options,
5
+ target = $(pointers.target),
6
+ pointer_id = pointers.pointer_id;
7
+
8
+ $(target).find('.wp-submenu li a').each(function () {
9
+
10
+ var t = $(this),
11
+ href = t.attr('href');
12
+
13
+ href = href.replace('admin.php?page=', '');
14
+
15
+ if( href == pointer_id ){
16
+
17
+ var selected_plugin_row = t.add( target ),
18
+ top_level_menu = target.find( pointers.target.replace( '#', '.' ) );
19
+
20
+ target.toggleClass('wp-no-current-submenu wp-menu-open wp-has-current-submenu');
21
+
22
+ t.pointer({
23
+ pointerClass: 'yit-wp-pointer',
24
+ content : options.content,
25
+ position: options.position,
26
+ open : function () {
27
+ selected_plugin_row.toggleClass( 'yit-pointer-selected-row' );
28
+ top_level_menu.addClass( 'yit-pointer' );
29
+ },
30
+
31
+
32
+ close : function () {
33
+ target.toggleClass('wp-no-current-submenu wp-menu-open wp-has-current-submenu');
34
+ selected_plugin_row.toggleClass( 'yit-pointer-selected-row' );
35
+ top_level_menu.removeClass( 'yit-pointer' );
36
+
37
+ $.ajax({
38
+ type : 'POST',
39
+ url : ajaxurl,
40
+ data : {
41
+ "action" : "dismiss-wp-pointer",
42
+ "pointer": pointer_id
43
+ },
44
+ success: function (response) {
45
+ }
46
+ });
47
+
48
+ }
49
+ }).pointer('open');
50
+ } else if( 'yith_default_pointer' == pointer_id ) {
51
+
52
+ var selected_plugin_row = t.add( target ),
53
+ top_level_menu = target.find( pointers.target.replace( '#', '.' )),
54
+ yit_plugins = $( pointers.target );
55
+
56
+ yit_plugins.addClass('wp-has-current-submenu');
57
+
58
+ top_level_menu.pointer({
59
+ pointerClass: 'yit-wp-pointer',
60
+ content : options.content,
61
+ position: options.position,
62
+
63
+ open : function () {
64
+ yit_plugins.addClass( 'yit-pointer-selected-row' );
65
+ },
66
+
67
+ close : function () {
68
+ yit_plugins.removeClass( 'yit-pointer-selected-row wp-has-current-submenu' );
69
+
70
+ $.ajax({
71
+ type : 'POST',
72
+ url : ajaxurl,
73
+ data : {
74
+ "action" : "dismiss-wp-pointer",
75
+ "pointer": pointer_id
76
+ },
77
+ success: function (response) {
78
+ }
79
+ });
80
+ }
81
+ }).pointer('open');
82
+ }
83
+ });
84
  });
plugin-fw/assets/js/yit-wp-pointer.min.js CHANGED
@@ -1,3 +1,3 @@
1
- jQuery(document).ready(function(b){var c=custom_pointer.pointers[0],d=c.options,a=b(c.target),e=c.pointer_id;b(a).find(".wp-submenu li a").each(function(){var f=b(this),h=f.attr("href"),h=h.replace("admin.php?page=","");if(h==e){var k=f.add(a),g=a.find(c.target.replace("#","."));a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");f.pointer({pointerClass:"yit-wp-pointer",content:d.content,position:d.position,open:function(){console.log("here");k.toggleClass("yit-pointer-selected-row");
2
- g.addClass("yit-pointer")},close:function(){a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");k.toggleClass("yit-pointer-selected-row");g.removeClass("yit-pointer");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}else if("yith_default_pointer"==e){var k=f.add(a),g=a.find(c.target.replace("#",".")),l=b(c.target);l.addClass("wp-has-current-submenu");g.pointer({pointerClass:"yit-wp-pointer",content:d.content,
3
  position:d.position,open:function(){l.addClass("yit-pointer-selected-row")},close:function(){l.removeClass("yit-pointer-selected-row wp-has-current-submenu");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}})});
1
+ jQuery(document).ready(function(b){var c=custom_pointer.pointers[0],d=c.options,a=b(c.target),e=c.pointer_id;b(a).find(".wp-submenu li a").each(function(){var f=b(this),h=f.attr("href"),h=h.replace("admin.php?page=","");if(h==e){var k=f.add(a),g=a.find(c.target.replace("#","."));a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");f.pointer({pointerClass:"yit-wp-pointer",content:d.content,position:d.position,open:function(){console.log("here");k.toggleClass("yit-pointer-selected-row");
2
+ g.addClass("yit-pointer")},close:function(){a.toggleClass("wp-no-current-submenu wp-menu-open wp-has-current-submenu");k.toggleClass("yit-pointer-selected-row");g.removeClass("yit-pointer");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}else if("yith_default_pointer"==e){var k=f.add(a),g=a.find(c.target.replace("#",".")),l=b(c.target);l.addClass("wp-has-current-submenu");g.pointer({pointerClass:"yit-wp-pointer",content:d.content,
3
  position:d.position,open:function(){l.addClass("yit-pointer-selected-row")},close:function(){l.removeClass("yit-pointer-selected-row wp-has-current-submenu");b.ajax({type:"POST",url:ajaxurl,data:{action:"dismiss-wp-pointer",pointer:e},success:function(a){}})}}).pointer("open")}})});
plugin-fw/init.php CHANGED
@@ -1,57 +1,57 @@
1
- <?php
2
- /**
3
- * Framework Name: YIT Plugin Framework
4
- * Version: 2.9.13
5
- * Author: Yithemes
6
- * Text Domain: yith-plugin-fw
7
- * Domain Path: /languages/
8
- *
9
- * @author Your Inspiration Themes
10
- * @package YITH WooCommerce Ajax Navigation
11
- * @version 2.0
12
- */
13
- /**
14
- * This file belongs to the YIT Plugin Framework.
15
- *
16
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
17
- * that is bundled with this package in the file LICENSE.txt.
18
- * It is also available through the world-wide-web at this URL:
19
- * http://www.gnu.org/licenses/gpl-3.0.txt
20
- */
21
-
22
-
23
- if ( ! defined ( 'ABSPATH' ) ) {
24
- exit;
25
- } // Exit if accessed directly
26
-
27
- if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
28
- /**
29
- * YITH WooCommerce Ajax Navigation
30
- *
31
- * @since 1.0.0
32
- */
33
- function yit_maybe_plugin_fw_loader ( $plugin_path ) {
34
- global $plugin_fw_data;
35
-
36
- $default_headers = array (
37
- 'Name' => 'Framework Name',
38
- 'Version' => 'Version',
39
- 'Author' => 'Author',
40
- 'TextDomain' => 'Text Domain',
41
- 'DomainPath' => 'Domain Path',
42
- );
43
-
44
- $framework_data = get_file_data ( trailingslashit ( $plugin_path ) . 'plugin-fw/init.php', $default_headers );
45
- $plugin_fw_main_file = trailingslashit ( $plugin_path ) . 'plugin-fw/yit-plugin.php';
46
-
47
- if ( ! empty( $plugin_fw_data ) ) {
48
- foreach ( $plugin_fw_data as $version => $path ) {
49
- if ( version_compare ( $version, $framework_data[ 'Version' ], '<' ) ) {
50
- $plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
51
- }
52
- }
53
- } else {
54
- $plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
55
- }
56
- }
57
  }
1
+ <?php
2
+ /**
3
+ * Framework Name: YIT Plugin Framework
4
+ * Version: 2.9.22
5
+ * Author: Yithemes
6
+ * Text Domain: yith-plugin-fw
7
+ * Domain Path: /languages/
8
+ *
9
+ * @author Your Inspiration Themes
10
+ * @package YITH WooCommerce Ajax Navigation
11
+ * @version 2.0
12
+ */
13
+ /**
14
+ * This file belongs to the YIT Plugin Framework.
15
+ *
16
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
17
+ * that is bundled with this package in the file LICENSE.txt.
18
+ * It is also available through the world-wide-web at this URL:
19
+ * http://www.gnu.org/licenses/gpl-3.0.txt
20
+ */
21
+
22
+
23
+ if ( ! defined ( 'ABSPATH' ) ) {
24
+ exit;
25
+ } // Exit if accessed directly
26
+
27
+ if ( ! function_exists ( 'yit_maybe_plugin_fw_loader' ) ) {
28
+ /**
29
+ * YITH WooCommerce Ajax Navigation
30
+ *
31
+ * @since 1.0.0
32
+ */
33
+ function yit_maybe_plugin_fw_loader ( $plugin_path ) {
34
+ global $plugin_fw_data;
35
+
36
+ $default_headers = array (
37
+ 'Name' => 'Framework Name',
38
+ 'Version' => 'Version',
39
+ 'Author' => 'Author',
40
+ 'TextDomain' => 'Text Domain',
41
+ 'DomainPath' => 'Domain Path',
42
+ );
43
+
44
+ $framework_data = get_file_data ( trailingslashit ( $plugin_path ) . 'plugin-fw/init.php', $default_headers );
45
+ $plugin_fw_main_file = trailingslashit ( $plugin_path ) . 'plugin-fw/yit-plugin.php';
46
+
47
+ if ( ! empty( $plugin_fw_data ) ) {
48
+ foreach ( $plugin_fw_data as $version => $path ) {
49
+ if ( version_compare ( $version, $framework_data[ 'Version' ], '<' ) ) {
50
+ $plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
51
+ }
52
+ }
53
+ } else {
54
+ $plugin_fw_data = array ( $framework_data[ 'Version' ] => $plugin_fw_main_file );
55
+ }
56
+ }
57
  }
plugin-fw/languages/yith-plugin-fw-it_IT.mo CHANGED
Binary file
plugin-fw/languages/yith-plugin-fw-it_IT.po CHANGED
@@ -4,8 +4,8 @@ msgid ""
4
  msgstr ""
5
  "Project-Id-Version: YITH Plugin Starter 1.0.0 Plugin FW\n"
6
  "Report-Msgid-Bugs-To: Your Inspiration Themes <plugins@yithemes.com>\n"
7
- "POT-Creation-Date: 2016-03-07 15:11+0100\n"
8
- "PO-Revision-Date: 2016-03-07 15:11+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: YIThemes <plugins@yithemes.com>\n"
11
  "Language: it_IT\n"
@@ -224,7 +224,7 @@ msgstr "Aggiungi %s dalla immagini"
224
  msgid "Upload multiple files"
225
  msgstr ""
226
 
227
- #: lib/yit-plugin-panel-wc.php:341
228
  msgid "The changes you have made will be lost if you leave this page."
229
  msgstr "Perderai tutti i cambiamenti effettuati se lasci questa pagina."
230
 
@@ -236,63 +236,67 @@ msgstr "Impostazioni plugin"
236
  msgid "YITH Plugins"
237
  msgstr "YITH Plugins"
238
 
239
- #: lib/yit-plugin-panel.php:297 lib/yit-plugin-subpanel.php:146
 
 
 
 
240
  #: templates/panel/woocommerce/woocommerce-form.php:5
241
  msgid "Save Changes"
242
  msgstr "Salva modifiche"
243
 
244
- #: lib/yit-plugin-panel.php:300 templates/panel/woocommerce/woocommerce-form.php:8
245
  msgid "If you continue with this action, you will reset all options in this page."
246
  msgstr ""
247
  "Se prosegui con questa azione, tutte le opzioni di questa pagina saranno "
248
  "reimpostate."
249
 
250
- #: lib/yit-plugin-panel.php:302 lib/yit-plugin-subpanel.php:151
251
  msgid "Reset to default"
252
  msgstr ""
253
 
254
- #: lib/yit-plugin-panel.php:302 lib/yit-plugin-subpanel.php:151
255
  #: templates/panel/woocommerce/woocommerce-form.php:11
256
  msgid "Are you sure?"
257
  msgstr "Sei sicuro?"
258
 
259
- #: lib/yit-plugin-panel.php:436
260
  msgid "The element you have entered already exists. Please, enter another name."
261
  msgstr "L'elemento inserito esiste già. Per favore, inserisci un altro nome."
262
 
263
- #: lib/yit-plugin-panel.php:437
264
  msgid "Settings saved"
265
  msgstr "Impostazioni salvate"
266
 
267
- #: lib/yit-plugin-panel.php:438
268
  msgid "Settings reset"
269
  msgstr "Impostazioni azzerate"
270
 
271
- #: lib/yit-plugin-panel.php:439
272
  msgid "Element deleted correctly."
273
  msgstr "Elemento rimosso correttamente."
274
 
275
- #: lib/yit-plugin-panel.php:440 lib/yit-plugin-panel.php:441
276
  msgid "Element updated correctly."
277
  msgstr "Elemento aggiornato correttamente."
278
 
279
- #: lib/yit-plugin-panel.php:442
280
  msgid "Database imported correctly."
281
  msgstr "Database importato correttamente."
282
 
283
- #: lib/yit-plugin-panel.php:443
284
  msgid "An error has occurred during import. Please try again."
285
  msgstr "Si è verificato un errore durante l'importazione. Prova di nuovo."
286
 
287
- #: lib/yit-plugin-panel.php:444
288
  msgid "The added file is not valid."
289
  msgstr "Il file aggiunto non è valido."
290
 
291
- #: lib/yit-plugin-panel.php:445
292
  msgid "Sorry, import is disabled."
293
  msgstr "Ci dispiace, l'importazione è disabilitata."
294
 
295
- #: lib/yit-plugin-panel.php:446
296
  msgid "Sorting successful."
297
  msgstr "Ordinamento effettuato con successo."
298
 
@@ -1007,6 +1011,132 @@ msgstr ""
1007
  msgid "Reset Defaults"
1008
  msgstr "Ripristina impostazioni iniziali"
1009
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1010
  #~ msgid "YIT Plugins"
1011
  #~ msgstr "YIT Plugins"
1012
 
4
  msgstr ""
5
  "Project-Id-Version: YITH Plugin Starter 1.0.0 Plugin FW\n"
6
  "Report-Msgid-Bugs-To: Your Inspiration Themes <plugins@yithemes.com>\n"
7
+ "POT-Creation-Date: 2016-03-18 15:29+0100\n"
8
+ "PO-Revision-Date: 2016-03-18 15:34+0100\n"
9
  "Last-Translator: \n"
10
  "Language-Team: YIThemes <plugins@yithemes.com>\n"
11
  "Language: it_IT\n"
224
  msgid "Upload multiple files"
225
  msgstr ""
226
 
227
+ #: lib/yit-plugin-panel-wc.php:345
228
  msgid "The changes you have made will be lost if you leave this page."
229
  msgstr "Perderai tutti i cambiamenti effettuati se lasci questa pagina."
230
 
236
  msgid "YITH Plugins"
237
  msgstr "YITH Plugins"
238
 
239
+ #: lib/yit-plugin-panel.php:276
240
+ msgid "Premium version upgrade"
241
+ msgstr ""
242
+
243
+ #: lib/yit-plugin-panel.php:322 lib/yit-plugin-subpanel.php:146
244
  #: templates/panel/woocommerce/woocommerce-form.php:5
245
  msgid "Save Changes"
246
  msgstr "Salva modifiche"
247
 
248
+ #: lib/yit-plugin-panel.php:325 templates/panel/woocommerce/woocommerce-form.php:8
249
  msgid "If you continue with this action, you will reset all options in this page."
250
  msgstr ""
251
  "Se prosegui con questa azione, tutte le opzioni di questa pagina saranno "
252
  "reimpostate."
253
 
254
+ #: lib/yit-plugin-panel.php:327 lib/yit-plugin-subpanel.php:151
255
  msgid "Reset to default"
256
  msgstr ""
257
 
258
+ #: lib/yit-plugin-panel.php:327 lib/yit-plugin-subpanel.php:151
259
  #: templates/panel/woocommerce/woocommerce-form.php:11
260
  msgid "Are you sure?"
261
  msgstr "Sei sicuro?"
262
 
263
+ #: lib/yit-plugin-panel.php:461
264
  msgid "The element you have entered already exists. Please, enter another name."
265
  msgstr "L'elemento inserito esiste già. Per favore, inserisci un altro nome."
266
 
267
+ #: lib/yit-plugin-panel.php:462
268
  msgid "Settings saved"
269
  msgstr "Impostazioni salvate"
270
 
271
+ #: lib/yit-plugin-panel.php:463
272
  msgid "Settings reset"
273
  msgstr "Impostazioni azzerate"
274
 
275
+ #: lib/yit-plugin-panel.php:464
276
  msgid "Element deleted correctly."
277
  msgstr "Elemento rimosso correttamente."
278
 
279
+ #: lib/yit-plugin-panel.php:465 lib/yit-plugin-panel.php:466
280
  msgid "Element updated correctly."
281
  msgstr "Elemento aggiornato correttamente."
282
 
283
+ #: lib/yit-plugin-panel.php:467
284
  msgid "Database imported correctly."
285
  msgstr "Database importato correttamente."
286
 
287
+ #: lib/yit-plugin-panel.php:468
288
  msgid "An error has occurred during import. Please try again."
289
  msgstr "Si è verificato un errore durante l'importazione. Prova di nuovo."
290
 
291
+ #: lib/yit-plugin-panel.php:469
292
  msgid "The added file is not valid."
293
  msgstr "Il file aggiunto non è valido."
294
 
295
+ #: lib/yit-plugin-panel.php:470
296
  msgid "Sorry, import is disabled."
297
  msgstr "Ci dispiace, l'importazione è disabilitata."
298
 
299
+ #: lib/yit-plugin-panel.php:471
300
  msgid "Sorting successful."
301
  msgstr "Ordinamento effettuato con successo."
302
 
1011
  msgid "Reset Defaults"
1012
  msgstr "Ripristina impostazioni iniziali"
1013
 
1014
+ #: templates/upgrade/upgrade-to-pro-version.php:2
1015
+ msgid "Upgrade to Premium Version"
1016
+ msgstr ""
1017
+
1018
+ #: templates/upgrade/upgrade-to-pro-version.php:3
1019
+ msgid ""
1020
+ "Have you purchased the premium version of a plugin? Don't you know how to activate "
1021
+ "the license after the purchase?"
1022
+ msgstr ""
1023
+ "Hai comprato la versione premium di un plugin ? Dopo l'acquisto non trovi dove "
1024
+ "attivare la licenza del tuo plugin premium ? "
1025
+
1026
+ #: templates/upgrade/upgrade-to-pro-version.php:5
1027
+ msgid ""
1028
+ "To upgrade from a FREE to a PREMIUM plugin is not suffice to insert the license "
1029
+ "key provided after the purchase.\n"
1030
+ " The reason is that they are two distinct products, with significant "
1031
+ "differences both for available options and for number of files included in the "
1032
+ "plugin package.\n"
1033
+ " To start to use the PREMIUM version of the plugin, you simply need to "
1034
+ "download the PREMIUM packet and install it on your site."
1035
+ msgstr ""
1036
+ "Per passare da un plugin FREE ad uno PREMIUM non basta semplicemnete inserire la "
1037
+ "chiave di licenza che ti è stata fornita dopo aver completato l'acquisto. Questo "
1038
+ "perchè fisicamente si tratta di due prodotti diversi, con differenze sostanziali "
1039
+ "sia nelle opzioni disponibili sia sul numero di file presenti all'interno del "
1040
+ "pacchetto del plugin stesso. \n"
1041
+ "Per iniziare ad usare il plugin PREMIUM che hai appena acquistato devi "
1042
+ "semplicemente scaricare il pacchetto PREMIUM ed installarlo sul tuo sito."
1043
+
1044
+ #: templates/upgrade/upgrade-to-pro-version.php:9
1045
+ #, php-format
1046
+ msgid ""
1047
+ "%1$sDo you need to know how to do it?%2$s Easy! %1$sFollow this list of steps%2$s "
1048
+ "and in a few minutes the plugin you purchased will be installed on your site"
1049
+ msgstr ""
1050
+ "%1$sNon sai come fare ?%2$s Non è un problema%1$s, segui i passi elencati qui sotto"
1051
+ "%2$s ed in pochi minuti avrai il plugin acquistato correttamente installato sul "
1052
+ "tuo sito."
1053
+
1054
+ #: templates/upgrade/upgrade-to-pro-version.php:12
1055
+ msgid "Go to yithemes.com and login to \"My Account\" page"
1056
+ msgstr "Vai su yithemes.com ed effettua il login alla sezione \"My Account \""
1057
+
1058
+ #: templates/upgrade/upgrade-to-pro-version.php:18
1059
+ msgid ""
1060
+ "From the menu on the left, click on \"My Downloads\", look for the plugin you want "
1061
+ "to install among the available downloads and click on \"Download\" button"
1062
+ msgstr ""
1063
+ "Dal menù di sinistra clicca su \"My Downloads\" e cerca tra i download disponibili "
1064
+ "il plugin che vuoi installare, e clicca su \"Download\""
1065
+
1066
+ #: templates/upgrade/upgrade-to-pro-version.php:24
1067
+ msgid ""
1068
+ "After downloading the packet, go to your website and login to WordPress "
1069
+ "administration area."
1070
+ msgstr ""
1071
+ "Non appena il download del pacchetto sarà completato recati sul tuo sito web ed "
1072
+ "effettua il login all'area amministrazione di WordPress."
1073
+
1074
+ #: templates/upgrade/upgrade-to-pro-version.php:30
1075
+ msgid ""
1076
+ "From the menu on the left, click on \"Plugins\". You will be redirected to the "
1077
+ "page where you will find the complete list of all the plugins available on your "
1078
+ "site. Click on \"Add New\" button that you find above on the left to add a new "
1079
+ "plugin"
1080
+ msgstr ""
1081
+ "Dal menù di sinistra clicca sulla voce Plugins. Verrai indirizzato su una pagina "
1082
+ "con la lista dei plugin disponibili sul tuo sito. Clicca sul pulsante \"Add New\" "
1083
+ "che trovi in alto a sinistra vicino al titolo della pagina."
1084
+
1085
+ #: templates/upgrade/upgrade-to-pro-version.php:36
1086
+ msgid ""
1087
+ "You will be redirected to a new page where you will find, above on the left next "
1088
+ "to the page title, the \"Upload Plugin\" button."
1089
+ msgstr ""
1090
+ "Verrai indirizzato su una nuova pagina dove trovi, in alto a sinistra vicino al "
1091
+ "titolo della pagina, il pulsante \"Upload Plugin\"."
1092
+
1093
+ #: templates/upgrade/upgrade-to-pro-version.php:42
1094
+ msgid ""
1095
+ "Click on \"Upload Plugins\" button to start the upload of the PREMIUM version of "
1096
+ "the plugin previously downloaded. Click on \"Select File\", search for the "
1097
+ "download folder related to the plugin and upload the package. Now you only need to "
1098
+ "wait a few minutes for the upload and the installation on your site. (We used YITH "
1099
+ "Live Chat plugin by way of example)"
1100
+ msgstr ""
1101
+ "Cliccando su \"Upload Plugins\", ti troverai in una pagina dove poter effettuare "
1102
+ "l'upload del pacchetto del plugin PREMIUM da te precedentemente scaricato. Clicca "
1103
+ "quindi su \"Scegli File\", cerca la cartella di download dove hai scaricato il "
1104
+ "plugin ed effettua il caricamento del pacchetto. A questo punto ti basta attendere "
1105
+ "qualche minuto che il pacchetto venga caricato ed installato sul tuo sito. "
1106
+ "(Abbiamo usato YITH Live Chat come esempio) "
1107
+
1108
+ #: templates/upgrade/upgrade-to-pro-version.php:48
1109
+ msgid "After completing the installation, click on \"Activate plugin\""
1110
+ msgstr "Al termine della procedura di installazione clicca su \"Attiva\""
1111
+
1112
+ #: templates/upgrade/upgrade-to-pro-version.php:52
1113
+ msgid ""
1114
+ "If everything worked allright, your plugin is now correctly installed on your "
1115
+ "website. Enjoy it :-)"
1116
+ msgstr ""
1117
+ "Se tutto è andato per il meglio il tuo plugin è correttamente installato sul tuo "
1118
+ "sito web. Enjoy it :-)"
1119
+
1120
+ #: templates/upgrade/upgrade-to-pro-version.php:55
1121
+ msgid ""
1122
+ "The last step is the activation of the plugin through its license key you received "
1123
+ "after the purchase. Click on \"License Activation\" that you find in \"YITH Plugins"
1124
+ "\" and insert the license key and the email address you used during the purchas."
1125
+ msgstr ""
1126
+ "Ultimo step è attivare il plugin con la chiave di licenza che hai ricevuto dopo "
1127
+ "l'acquisto. Clicca quindi sul link \"License Activation\" che trovi sotto \"YITH "
1128
+ "Plugins\" ed inserisci la license key in tuo possesso ed email utilizzata in fase "
1129
+ "di acquisto."
1130
+
1131
+ #: templates/upgrade/upgrade-to-pro-version.php:61
1132
+ msgid ""
1133
+ "In case you had difficulty to recover the license key we sent you by email, you "
1134
+ "can easily find it in \"My Licenses\" section of your account on yithemes.com"
1135
+ msgstr ""
1136
+ "Se non trovi l'email che ti abbiamo inviato contenete la license key puoi "
1137
+ "facilmente recuperarla dalla sezione \"My Licenses\" all'interno della sezione My "
1138
+ "Account del nostro sito yithemes.com."
1139
+
1140
  #~ msgid "YIT Plugins"
1141
  #~ msgstr "YIT Plugins"
1142
 
plugin-fw/lib/yit-ajax.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( !class_exists( 'YIT_Ajax' ) ) {
16
+ /**
17
+ * YIT Ajax
18
+ *
19
+ * @class YIT_Ajax
20
+ * @package Yithemes
21
+ * @since 1.0
22
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
23
+ */
24
+ class YIT_Ajax {
25
+ /**
26
+ * @var string version of class
27
+ */
28
+ public $version = '1.0.0';
29
+
30
+ /**
31
+ * @var object The single instance of the class
32
+ * @since 1.0
33
+ */
34
+ protected static $_instance = null;
35
+
36
+ /**
37
+ * Constructor
38
+ *
39
+ * @since 1.0
40
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
41
+ */
42
+ private function __construct() {
43
+ add_action( 'wp_ajax_yith_plugin_panel_sidebar_set_collapse_option', array( $this, 'set_ajax_sidebar_collapse_option' ) );
44
+ }
45
+
46
+ /**
47
+ * get single instance
48
+ *
49
+ * @static
50
+ * @return YIT_Ajax
51
+ *
52
+ * @since 1.0
53
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
54
+ */
55
+ public static function instance() {
56
+ if ( is_null( self::$_instance ) ) {
57
+ self::$_instance = new self();
58
+ }
59
+
60
+ return self::$_instance;
61
+ }
62
+
63
+ /**
64
+ * Set Sidebar collapse option [AJAX]
65
+ */
66
+ public function set_ajax_sidebar_collapse_option() {
67
+ if ( isset( $_REQUEST[ 'option' ] ) ) {
68
+ $option = $_REQUEST[ 'option' ];
69
+ update_option( YIT_Plugin_Panel_Sidebar::$collapse_option, $option );
70
+ }
71
+ die();
72
+ }
73
+ }
74
+ }
75
+
76
+ YIT_Ajax::instance();
plugin-fw/lib/yit-cpt-unlimited.php CHANGED
@@ -1,1775 +1,1775 @@
1
- <?php
2
- /*
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
- if (!defined('ABSPATH')) {exit('Direct access forbidden.');
11
- }
12
-
13
- /**
14
- * Manage the custom post types as Portfolio, Contact Forms and similar (called CPTU)
15
- *
16
- * @class YIT_CPT_Unlimited
17
- * @package Yithemes
18
- * @since 2.0.0
19
- * @author Your Inspiration Themes
20
- *
21
- */
22
-
23
- class YIT_CPT_Unlimited {
24
-
25
- /**
26
- * @var string The name of main post type of CPTU
27
- * @since 1.0
28
- */
29
- protected $_name = '';
30
-
31
- /**
32
- * @var string The prefix of each post type created by the post of main CPTU
33
- * @since 1.0
34
- */
35
- protected $_prefix_cpt = '';
36
-
37
- /**
38
- * @var string The labels defined for the main CPTU
39
- * @since 1.0
40
- */
41
- protected $_labels = '';
42
-
43
- /**
44
- * @var string The configuration arguments of post type
45
- * @since 1.0
46
- */
47
- protected $_args = '';
48
-
49
- /**
50
- * @var array All post types created by the post of main CPTU
51
- * @since 1.0
52
- */
53
- public $post_types = array();
54
-
55
- /**
56
- * @var array $layouts Array with all portfolio layouts available for this site
57
- * @since 1.0
58
- */
59
- public $layouts = array();
60
-
61
- /**
62
- * @var string $template_path The pathname of template folder
63
- * @since 1.0
64
- */
65
- protected $template_path = '';
66
-
67
- /**
68
- * @var string $template_url The URL of template folder
69
- * @since 1.0
70
- */
71
- protected $template_url = '';
72
-
73
- /**
74
- * @var int $_index Unique sequential ID to differentiate same shortcodes in the same page
75
- */
76
- public $index = 0;
77
-
78
- /**
79
- * @var string $_layout Temporary attribute to load automatically the settings for each layout
80
- * @since 1.0
81
- */
82
- private $_layout = '';
83
-
84
-
85
- /**
86
- * Constructor
87
- *
88
- * Accept an array of arguments to define the characteristics of CPTU to register.
89
- *
90
- * @since 1.0
91
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
92
- */
93
- public function __construct( $args = array() ) {
94
-
95
- $defaults = array(
96
- 'name' => '',
97
- 'post_type_prefix' => '',
98
- 'labels' => array(
99
- 'main_name' => '',
100
- 'singular' => '',
101
- 'plural' => '',
102
- 'menu' => ''
103
- ),
104
- 'manage_layouts' => false,
105
- 'add_multiuploader' => false,
106
- 'sortable' => false,
107
- 'has_single' => false,
108
- 'has_taxonomy' => false,
109
- 'label_item_sing' => '',
110
- 'label_item_plur' => '',
111
- 'shortcode_name' => '',
112
- 'shortcode_icon' => '', // URL or icon name from http://melchoyce.github.io/dashicons/
113
- 'layout_option' => '_type' // the option ID of layout metabox
114
- );
115
- $this->_args = wp_parse_args( $args, $defaults );
116
-
117
- // fix labels
118
- if ( empty( $this->_args['labels']['main_name'] ) ) {
119
- $this->_args['labels']['main_name'] = $this->_args['labels']['singular'];
120
- }
121
- if ( empty( $this->_args['labels']['menu'] ) ) {
122
- $this->_args['labels']['menu'] = $this->_args['labels']['singular'];
123
- }
124
-
125
- /* populate */
126
- $this->_name = $this->_args['name'];
127
- $this->_prefix_cpt = $this->_args['post_type_prefix'];
128
- $this->_labels = $this->_args['labels'];
129
-
130
- add_action( 'init', array( $this, 'register_post_type' ) );
131
- add_action( 'init', array( $this, 'register_cptu_post_types' ) );
132
-
133
- add_action( 'save_post', array( $this, 'rewrite_flush') );
134
-
135
- // admin interface
136
- add_action( 'admin_head', array( $this, 'add_cptu_menu_item' ) );
137
- add_action( 'admin_init', array( $this, 'add_quick_links_metaboxes' ) );
138
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
139
-
140
- // metaboxes
141
- add_action( 'after_setup_theme', array( $this, 'add_metabox_cptu' ), 2 );
142
- add_action( 'after_setup_theme', array( $this, 'add_metabox_item_fields' ), 2 );
143
-
144
- // multiuploader
145
- if ( $this->_args['add_multiuploader'] ) {
146
- add_action( 'admin_footer', array( $this, 'add_button_multiuploader' ) );
147
- add_action( 'wp_ajax_yit_cptu_multiuploader', array( $this, 'post_multiuploader' ) );
148
- }
149
-
150
- // layouts
151
- if ( $this->_args['manage_layouts'] ) {
152
- // get all layouts available
153
- $this->get_layouts();
154
- }
155
-
156
- // single layout
157
- if ( $this->_args['has_single'] ) {
158
- add_action( 'yit_loop', array( $this, 'single_template' ) );
159
- add_action( 'wp', array( $this, 'single_template_config' ) );
160
-
161
- if ( defined('DOING_AJAX') && DOING_AJAX ) {
162
- add_action( 'init', array( $this, 'single_template_config' ) );
163
- }
164
- }
165
-
166
- // archive template
167
- add_action( 'wp', array( $this, 'archive_template' ) );
168
-
169
- // enqueue the assets of each layout
170
- add_action( 'wp_enqueue_scripts', array( $this, 'frontend_assets' ) );
171
-
172
- // add the shortcode, used to show the frontend
173
- if ( ! empty( $this->_args['shortcode_name'] ) ) {
174
- add_shortcode( $this->_args['shortcode_name'], array( &$this, 'add_shortcode' ) );
175
- add_filter( 'yit_shortcode_' . $this->_args['shortcode_name'] . '_icon', array( $this, 'shortcode_icon') );
176
- add_filter( 'yit-shortcode-plugin-init', array( $this, 'add_shortcode_to_box' ) );
177
- }
178
-
179
- // add sortable feature
180
- if ( $this->_args['sortable'] ) {
181
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_sortable_assets' ) );
182
- add_action( 'wp_ajax_cpt_sort_posts', array( $this, 'sort_posts' ) );
183
- add_action( 'admin_init', array( $this, 'init_menu_order' ) );
184
- add_filter( 'pre_get_posts', array( $this, 'filter_active' ) );
185
- add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
186
- add_filter( 'get_next_post_where', array( $this, 'sorted_next_post_where' ) );
187
- add_filter( 'get_previous_post_where', array( $this, 'sorted_prev_post_where' ) );
188
- add_filter( 'get_next_post_sort', array( $this, 'sorted_next_post_sort' ) );
189
- add_filter( 'get_previous_post_sort', array( $this, 'sorted_prev_post_sort' ) );
190
- }
191
-
192
- // add default columns to post type table list
193
- add_filter( 'manage_edit-' . $this->_name . '_columns', array( $this, 'cptu_define_columns' ) );
194
- add_action( 'manage_' . $this->_name . '_posts_custom_column' , array( $this, 'cptu_change_columns' ), 10, 2 );
195
-
196
- // add required post type for wordpress importer
197
- add_filter( 'wp_import_post_data_raw', array( $this, 'add_importer_required_post_type' ) );
198
- add_filter( 'wp_import_terms', array( $this, 'add_importer_required_taxonomy' ) );
199
- add_action( 'wp_import_set_post_terms', array( $this, 'recount_terms_post' ), 10, 3 );
200
-
201
- }
202
-
203
- /**
204
- * Enqueue the assets for the sortable feature
205
- *
206
- * @return void
207
- * @since 1.0
208
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
209
- */
210
- public function admin_sortable_assets() {
211
- global $post;
212
-
213
- if ( ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
214
- return;
215
- }
216
-
217
- wp_enqueue_script( 'yit-cptu-sortable-posts', YIT_CORE_PLUGIN_URL . '/assets/js/yit-cptu-sortable-posts.js', array( 'jquery', 'jquery-ui-sortable' ), '1.0', true );
218
- }
219
-
220
- public function init_menu_order( $post_types = array() ) {
221
- global $wpdb;
222
-
223
- if ( empty( $post_types ) ) {
224
- $post_types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_type LIKE %s", str_replace( '_', '\_', $this->_prefix_cpt ) . '%' ) );
225
- } elseif ( ! is_array( $post_types ) ) {
226
- $post_types = array( $post_types );
227
- }
228
-
229
- foreach ( $post_types as $post_type ) {
230
- $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = '{$post_type}' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') AND menu_order = 0" );
231
-
232
- if ( empty( $count ) ) {
233
- continue;
234
- }
235
-
236
- $sql = "SELECT ID
237
- FROM $wpdb->posts
238
- WHERE post_type = '" . $post_type . "'
239
- AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
240
- ORDER BY post_date DESC
241
- ";
242
-
243
- $results = $wpdb->get_results( $sql );
244
-
245
- foreach ( $results as $key => $result ) {
246
- $wpdb->update( $wpdb->posts, array( 'menu_order' => $key + 1 ), array( 'ID' => $result->ID ) );
247
- }
248
- }
249
- }
250
-
251
- /**
252
- * Save the order of posts from sortable feature
253
- *
254
- * @return void
255
- * @since 1.0
256
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
257
- */
258
- public function sort_posts() {
259
- global $wpdb;
260
-
261
- parse_str( $_REQUEST['order'], $data );
262
-
263
- if ( is_array( $data ) ) {
264
- //$this->init_menu_order( $_REQUEST['post_type'] );
265
-
266
- $id_arr = array( );
267
- foreach ( $data as $key => $values ) {
268
- foreach ( $values as $position => $id ) {
269
- $id_arr[] = $id;
270
- }
271
- }
272
-
273
-
274
- $menu_order_arr = array( );
275
- foreach ( $id_arr as $key => $id ) {
276
- $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . $id );
277
- foreach ( $results as $result ) {
278
- $menu_order_arr[] = $result->menu_order;
279
- }
280
- }
281
-
282
- sort( $menu_order_arr );
283
-
284
- foreach ( $data as $key => $values ) {
285
- foreach ( $values as $position => $id ) {
286
- $wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order_arr[$position] ), array( 'ID' => $id ) );
287
- }
288
- }
289
- }
290
-
291
- die();
292
- }
293
-
294
- public function filter_active( $wp_query ) {
295
- if ( is_admin() && isset( $wp_query->query['suppress_filters'] ) )
296
- $wp_query->query['suppress_filters'] = false;
297
- if ( is_admin() && isset( $wp_query->query_vars['suppress_filters'] ) )
298
- $wp_query->query_vars['suppress_filters'] = false;
299
- return $wp_query;
300
- }
301
-
302
- public function pre_get_posts( $wp_query ) {
303
- if ( is_admin() && !defined( 'DOING_AJAX' ) ) {
304
- if ( isset( $wp_query->query['post_type'] ) ) {
305
- $post_types = (array) $wp_query->query['post_type'];
306
- foreach ( $post_types as $post_type ) {
307
- if ( $this->_is_valid( $post_type ) ) {
308
- $wp_query->set( 'orderby', 'menu_order' );
309
- $wp_query->set( 'order', 'ASC' );
310
- }
311
- }
312
- }
313
-
314
- } else {
315
-
316
- $active = false;
317
-
318
- if ( isset( $wp_query->query['suppress_filters'] ) || isset( $wp_query->query['post_type'] ) ) {
319
- $post_types = (array) $wp_query->query['post_type'];
320
- foreach ( $post_types as $post_type ) {
321
- if ( $this->_is_valid( $post_type ) ) {
322
- $active = true;
323
- }
324
- }
325
- }
326
-
327
- if ( $active ) {
328
- if ( !isset( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] == 'post_date' )
329
- $wp_query->set( 'orderby', 'menu_order' );
330
- if ( !isset( $wp_query->query['order'] ) || $wp_query->query['order'] == 'DESC' )
331
- $wp_query->set( 'order', 'ASC' );
332
- }
333
- }
334
- }
335
-
336
- /**
337
- * Filters where clause for get next post
338
- *
339
- * @param $where
340
- *
341
- * @return string
342
- * @since 1.0
343
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
344
- */
345
- public function sorted_next_post_where( $where ){
346
- global $post;
347
- if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
348
- $post = get_post( intval( $_REQUEST['post_id'] ) );
349
- }
350
- else{
351
- $post = get_post();
352
- }
353
-
354
- if( ! $post || ! $this->_is_valid( $post->post_type ) ){
355
- return $where;
356
- }
357
-
358
- $result = str_replace( "'" . $post->post_date . "'", $post->menu_order, $where );
359
- $result = str_replace( 'p.post_date', 'p.menu_order', $result );
360
-
361
- return $result;
362
- }
363
-
364
- /**
365
- * Filters where clause for get prev post
366
- *
367
- * @param $where
368
- *
369
- * @return string
370
- * @since 1.0
371
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
372
- */
373
- public function sorted_prev_post_where( $where ){
374
- global $post;
375
-
376
- if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
377
- $post = get_post( intval( $_REQUEST['post_id'] ) );
378
- }
379
- else{
380
- $post = get_post();
381
- }
382
-
383
- if( ! $post || ! $this->_is_valid( $post->post_type ) ){
384
- return $where;
385
- }
386
-
387
- $result = str_replace( "'" . $post->post_date . "'", $post->menu_order, $where );
388
- $result = str_replace( 'p.post_date', 'p.menu_order', $result );
389
-
390
- return $result;
391
- }
392
-
393
- /**
394
- * Filters sort clause for get next post
395
- *
396
- * @param $sort
397
- *
398
- * @return string
399
- * @since 1.0
400
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
401
- */
402
- public function sorted_next_post_sort( $sort ){
403
- global $post;
404
-
405
- if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
406
- $post = get_post( intval( $_REQUEST['post_id'] ) );
407
- }
408
- else{
409
- $post = get_post();
410
- }
411
-
412
- if( ! $post || ! $this->_is_valid( $post->post_type ) ){
413
- return $sort;
414
- }
415
-
416
- $result = str_replace( 'p.post_date', 'p.menu_order', $sort );
417
- return $result;
418
- }
419
-
420
- /**
421
- * Filters sort clause for get prev post
422
- *
423
- * @param $sort
424
- *
425
- * @return string
426
- * @since 1.0
427
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
428
- */
429
- public function sorted_prev_post_sort( $sort ){
430
- global $post;
431
-
432
- if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
433
- $post = get_post( intval( $_REQUEST['post_id'] ) );
434
- }
435
- else{
436
- $post = get_post();
437
- }
438
-
439
- if( ! $post || ! $this->_is_valid( $post->post_type ) ){
440
- return $sort;
441
- }
442
-
443
- $result = str_replace( 'p.post_date', 'p.menu_order', $sort );
444
- return $result;
445
- }
446
-
447
- /**
448
- * Register post type
449
- *
450
- * Register the post type for the creation of portfolios
451
- *
452
- * @return void
453
- * @since 1.0
454
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
455
- */
456
- public function register_post_type() {
457
- $labels = array(
458
- 'name' => ucfirst( $this->_labels['main_name'] ),
459
- 'singular_name' => ucfirst( $this->_labels['singular'] ),
460
- 'add_new' => sprintf( __( 'Add %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
461
- 'add_new_item' => sprintf( __( 'Add New %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
462
- 'edit_item' => sprintf( __( 'Edit %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
463
- 'new_item' => sprintf( __( 'New %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
464
- 'all_items' => sprintf( __( 'All %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
465
- 'view_item' => sprintf( __( 'View %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
466
- 'search_items' => sprintf( __( 'Search %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
467
- 'not_found' => sprintf( __( 'No %s found', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
468
- 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
469
- 'parent_item_colon' => '',
470
- 'menu_name' => ucfirst( $this->_labels['menu'] )
471
- );
472
-
473
- $args = array(
474
- 'labels' => apply_filters( 'yit_' . $this->_name . '_labels', $labels ),
475
- 'public' => false,
476
- 'publicly_queryable' => false,
477
- 'show_ui' => true,
478
- 'show_in_menu' => true,
479
- 'query_var' => false,
480
- 'capability_type' => 'post',
481
- 'hierarchical' => false,
482
- 'menu_position' => null,
483
- 'supports' => array( 'title' )
484
- );
485
-
486
- if ( ! empty( $this->_args['menu_icon'] ) ) {
487
- $args['menu_icon'] = $this->_args['menu_icon'];
488
- }
489
-
490
- register_post_type( $this->_name, apply_filters( 'yit_' . $this->_name . '_args', $args ) );
491
- }
492
-
493
- /**
494
- * Retrieve the values configured inside the custom post type
495
- *
496
- * @param $post /WP_Query The post where get the arguments configured in the cpt
497
- *
498
- * @return array
499
- * @since 1.0
500
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
501
- */
502
- protected function _cpt_args( $post ) {
503
- if ( ! isset( $post->ID ) ) {
504
- return;
505
- }
506
-
507
- $args = apply_filters( 'yit_cptu_register_post_type_args', array(
508
- 'layout' => get_post_meta( $post->ID, $this->_args['layout_option'], true ),
509
- 'rewrite' => get_post_meta( $post->ID, '_rewrite', true ),
510
- 'label_singular' => ! empty( $this->_args['label_item_sing'] ) ? $this->_args['label_item_sing'] : get_post_meta( $post->ID, '_label_singular', true ),
511
- 'label_plural' => ! empty( $this->_args['label_item_plur'] ) ? $this->_args['label_item_plur'] : get_post_meta( $post->ID, '_label_plural', true ),
512
- 'taxonomy' => get_post_meta( $post->ID, '_taxonomy', true ),
513
- 'taxonomy_rewrite' => get_post_meta( $post->ID, '_taxonomy_rewrite', true ),
514
- ), $this->_name, $post );
515
-
516
- $title = $post->post_title;
517
-
518
- if ( empty( $args['label_singular'] ) ) {
519
- $args['label_singular'] = $title;
520
- }
521
-
522
- if ( empty( $args['label_plural'] ) ) {
523
- $args['label_plural'] = $title;
524
- }
525
-
526
- return $args;
527
- }
528
-
529
- /**
530
- * Retrieve the post types created for this CPTU
531
- *
532
- * @return array The link changed
533
- * @since 1.0
534
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
535
- */
536
- public function get_post_types() {
537
- if ( ! empty( $this->post_types ) ) {
538
- return $this->post_types;
539
- }
540
-
541
- $args = array(
542
- 'post_type' => $this->_name,
543
- 'posts_per_page' => -1,
544
- 'post_status' => 'publish'
545
- );
546
- $this->post_types = get_posts( $args );
547
-
548
- return $this->post_types;
549
- }
550
-
551
- /**
552
- * Register portfolio post types
553
- *
554
- * Register the post types for each portfolio created by admin
555
- *
556
- * @return void
557
- * @since 1.0
558
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
559
- */
560
- public function register_cptu_post_types() {
561
- $post_types = $this->get_post_types();
562
- $pts = array();
563
-
564
- foreach ( $post_types as $pt ) {
565
-
566
- extract( $this->_cpt_args( $pt ) );
567
-
568
- $name = $pt->post_name;
569
- $title = $pt->post_title;
570
-
571
- $labels = array(
572
- 'name' => $title,
573
- 'singular_name' => $label_singular,
574
- 'add_new' => sprintf( __( 'Add %s', 'yith-plugin-fw' ), $label_singular ),
575
- 'add_new_item' => sprintf( __( 'Add New %s', 'yith-plugin-fw' ), $label_singular ),
576
- 'edit_item' => sprintf( __( 'Edit %s', 'yith-plugin-fw' ), $label_singular ),
577
- 'new_item' => sprintf( __( 'New %s', 'yith-plugin-fw' ), $label_singular ),
578
- 'all_items' => sprintf( __( 'All %s', 'yith-plugin-fw' ), $label_plural ),
579
- 'view_item' => sprintf( __( 'View %s', 'yith-plugin-fw' ), $label_singular ),
580
- 'search_items' => sprintf( __( 'Search %s', 'yith-plugin-fw' ), $label_plural ),
581
- 'not_found' => sprintf( __( 'No %s found', 'yith-plugin-fw' ), $label_plural ),
582
- 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'yith-plugin-fw' ), $label_plural ),
583
- 'parent_item_colon' => '',
584
- 'menu_name' => $title
585
- );
586
-
587
- $args = array(
588
- 'labels' => apply_filters( 'yit_' . $this->_prefix_cpt . $name . '_labels', $labels ),
589
- 'public' => true,
590
- 'publicly_queryable' => true,
591
- 'show_ui' => true,
592
- 'show_in_menu' => false,
593
- 'query_var' => true,
594
- 'capability_type' => 'post',
595
- 'hierarchical' => false,
596
- 'menu_position' => null,
597
- 'supports' => array( 'title', 'editor', 'thumbnail' )
598
- );
599
-
600
- if ( ! $this->_args['has_single'] ) {
601
- $args['public'] = false;
602
- $args['publicly_queryable'] = false;
603
- $args['query_var'] = false;
604
- }
605
-
606
- if ( $this->_args['manage_layouts'] && isset($this->layouts[ $layout ]) && ! $this->layouts[ $layout ]['support']['description'] ) {
607
- unset( $args['supports'][1] ); // remove 'editor'
608
- }
609
-
610
- if ( ! empty( $rewrite ) ) {
611
- $args['rewrite'] = array( 'slug' => $rewrite );
612
- }
613
-
614
- // register post type
615
- $post_type = yit_avoid_duplicate( str_replace( '-', '_', substr( $this->_prefix_cpt . $name, 0, 16) ), $post_types );
616
- register_post_type( $post_type, apply_filters( 'yit_' . $this->_prefix_cpt . $name . '_args', $args, $pt ) ); // save the post type in post meta
617
-
618
- update_post_meta( $pt->ID, '_post_type', $post_type );
619
- $pts[] = $post_type;
620
-
621
- // register taxonomy
622
- if ( $this->_args['has_taxonomy'] && ! empty( $taxonomy ) ) {
623
-
624
- $labels = array(
625
- 'name' => sprintf( _x( '%s Categories', 'taxonomy general name', 'yith-plugin-fw' ), $label_singular ),
626
- 'singular_name' => _x( 'Category', 'taxonomy singular name', 'yith-plugin-fw' ),
627
- 'search_items' => __( 'Search Categories', 'yith-plugin-fw' ),
628
- 'all_items' => __( 'All Categories', 'yith-plugin-fw' ),
629
- 'parent_item' => __( 'Parent Category', 'yith-plugin-fw' ),
630
- 'parent_item_colon' => __( 'Parent Category:', 'yith-plugin-fw' ),
631
- 'edit_item' => __( 'Edit Category', 'yith-plugin-fw' ),
632
- 'update_item' => __( 'Update Category', 'yith-plugin-fw' ),
633
- 'add_new_item' => __( 'Add New Category', 'yith-plugin-fw' ),
634
- 'new_item_name' => __( 'New Category Name', 'yith-plugin-fw' ),
635
- 'menu_name' => __( 'Category', 'yith-plugin-fw' ),
636
- );
637
-
638
- $args = array(
639
- 'hierarchical' => true,
640
- 'labels' => $labels,
641
- 'show_ui' => true,
642
- 'show_admin_column' => true,
643
- 'query_var' => true,
644
- );
645
-
646
- if ( ! empty( $taxonomy_rewrite ) ) {
647
- $args['rewrite'] = array( 'slug' => $taxonomy_rewrite );
648
- }
649
-
650
- register_taxonomy( substr( $taxonomy, 0, 32 ), $post_type, $args );
651
-
652
- }
653
-
654
- }
655
-
656
- wp_cache_set( 'yit_cptu_post_types', $post_types );
657
- }
658
-
659
- /**
660
- * Flush Rewrite Rules
661
- *
662
- * rewrite rules when a cpt unlimited is saved
663
- *
664
- * @return void
665
- * @since 1.0
666
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
667
- */
668
-
669
- public function rewrite_flush( $post ){
670
-
671
- if ( isset( $post ) && $this->_is_valid( get_post_type( intval( $post ) ) ) ) {
672
- flush_rewrite_rules();
673
- }
674
-
675
- }
676
-
677
- /**
678
- * Add the item for each portfolio under "Portfolios"
679
- *
680
- * @return void
681
- * @since 1.0
682
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
683
- */
684
- public function add_cptu_menu_item() {
685
- global $submenu, $post, $parent_file, $pagenow;
686
-
687
- // get current post type
688
- if ( isset( $post->post_type ) ) {
689
- $post_type = $post->post_type;
690
- } else if ( isset( $_REQUEST['post_type'] ) ) {
691
- $post_type = $_REQUEST['post_type'];
692
- } else {
693
- return;
694
- }
695
-
696
- $item = 'edit.php?post_type=' . $this->_name;
697
-
698
- // add new items
699
- if ( strpos( $post_type, $this->_prefix_cpt ) !== false ) {
700
- global $wpdb;
701
- $portfolio = $wpdb->get_row( $wpdb->prepare( "SELECT p.* FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post_type, $this->_name ) );
702
-
703
- if ( ! isset( $portfolio->ID ) ) {
704
- return;
705
- }
706
-
707
- $label_singular = ! empty( $this->_args['label_item_sing'] ) ? $this->_args['label_item_sing'] : get_post_meta( $portfolio->ID, '_label_singular', true );
708
- $label_plural = ! empty( $this->_args['label_item_plur'] ) ? $this->_args['label_item_plur'] : get_post_meta( $portfolio->ID, '_label_plural', true );
709
-
710
- if ( empty( $label_plural ) ) {
711
- $label_plural = $portfolio->post_title;
712
- }
713
-
714
- if ( empty( $label_singular ) ) {
715
- $label_singular = $portfolio->post_title;
716
- }
717
-
718
- $submenu[ $item ][15] = array( ucfirst( $label_plural ), 'edit_posts', 'edit.php?post_type=' . $post_type );
719
- $submenu[ $item ][20] = array( sprintf( __('Add %s', 'yith-plugin-fw'), ucfirst( $label_singular ) ), 'edit_posts', 'post-new.php?post_type=' . $post_type );
720
-
721
- global $wp_taxonomies;
722
- $taxonomy = get_post_meta( $portfolio->ID, '_taxonomy', true );
723
- if ( isset( $wp_taxonomies[ $taxonomy ] ) ) {
724
- $submenu[ $item ][25] = array( __('Categories', 'yith-plugin-fw'), 'edit_posts', 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=' . $post_type );
725
- }
726
- }
727
-
728
- // set the parent item inside the single of each post type
729
- if ( $pagenow == 'post.php' && isset( $_GET['post'] ) && $this->_is_valid( get_post_type( intval( $_GET['post'] ) ) ) ) {
730
- $parent_file = 'edit.php?post_type=' . $this->_name;
731
- }
732
- }
733
-
734
- /**
735
- * Locate folder of CPTU templates, if there isn't a layouts management
736
- *
737
- * @return string
738
- * @since 1.0
739
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
740
- */
741
- public function template_path() {
742
- if ( ! empty( $this->template_path ) ) {
743
- return $this->template_path;
744
- }
745
-
746
- // paths
747
- $stylesheet_path_1 = get_stylesheet_directory() . '/theme/templates/' . $this->_name . '/';
748
- $stylesheet_path_2 = get_template_directory() . '/theme/templates/' . $this->_name . '/';
749
- $template_path_1 = get_stylesheet_directory() . '/' . $this->_name . '/';
750
- $template_path_2 = get_template_directory() . '/' . $this->_name . '/';
751
- $plugin_path = $this->_args['plugin_path'] . '/templates/';
752
-
753
- foreach ( array( 'stylesheet_path_1', 'stylesheet_path_2', 'template_path_1', 'template_path_2', 'plugin_path' ) as $var ) {
754
- $path = ${$var};
755
-
756
- if ( file_exists( $path ) ) {
757
- $this->template_path = $path;
758
- }
759
- }
760
-
761
- return $this->template_path;
762
- }
763
-
764
- /**
765
- * Locate folder of CPTU templates, if there isn't a layouts management
766
- *
767
- * @return string
768
- * @since 1.0
769
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
770
- */
771
- public function template_url() {
772
- if ( ! empty( $this->template_url ) ) {
773
- return $this->template_path;
774
- }
775
-
776
- $this->template_url = str_replace( array(
777
- get_stylesheet_directory(),
778
- get_template_directory(),
779
- $this->_args['plugin_path']
780
- ), array(
781
- get_stylesheet_directory_uri(),
782
- get_template_directory_uri(),
783
- $this->_args['plugin_url']
784
- ), $this->template_path() );
785
-
786
- return $this->template_url;
787
- }
788
-
789
- /**
790
- * Retrieve all layouts to manage by custom post type added in the site in this order:
791
- * 1. Child theme (if exists)
792
- * 2. Theme
793
- * 3. Plugin
794
- *
795
- * It also load the config.php file of each layout
796
- *
797
- * @return void
798
- * @since 1.0
799
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
800
- */
801
- public function get_layouts() {
802
-
803
- // paths
804
- $stylesheet_path_1 = get_stylesheet_directory() . '/theme/templates/' . $this->_name . '/';
805
- $stylesheet_path_2 = get_template_directory() . '/theme/templates/' . $this->_name . '/';
806
- $template_path_1 = get_stylesheet_directory() . '/' . $this->_name . '/';
807
- $template_path_2 = get_template_directory() . '/' . $this->_name . '/';
808
- $plugin_path = $this->_args['plugin_path'] . '/templates/';
809
-
810
- foreach ( array( 'stylesheet_path_1', 'stylesheet_path_2', 'template_path_1', 'template_path_2', 'plugin_path' ) as $var ) {
811
- $path = ${$var};
812
-
813
- if ( file_exists( $path ) ) {
814
- foreach ( scandir( $path ) as $scan ) {
815
- if ( ! isset( $this->layouts[$scan] ) && is_dir( $path . $scan ) && ! in_array( $scan, array( '.', '..', '.svn' ) ) && $scan[0] != '_' ) {
816
- $this->layouts[$scan] = array(
817
- 'name' => ucfirst( str_replace( '-', ' ', $scan ) ),
818
- 'path' => $path . $scan,
819
- 'url' => str_replace( array(
820
- get_stylesheet_directory(),
821
- get_template_directory(),
822
- $this->_args['plugin_path']
823
- ), array(
824
- get_stylesheet_directory_uri(),
825
- get_template_directory_uri(),
826
- $this->_args['plugin_url']
827
- ), $path . $scan ),
828
- 'css' => array(),
829
- 'js' => array(),
830
- 'support' => array(
831
- 'description' => true
832
- ),
833
- 'columns' => array()
834
- );
835
-
836
- // set the vars for config.php
837
- $layout = $scan;
838
- $this->_layout = $layout; // temporary attribute to load automatically the configuration inside the config.php, for this layout
839
-
840
- // TODO Fare in modo di caricare il file config.php soltanto quando realmente serve
841
- if ( ! in_array( $scan, array( 'single' ) ) && file_exists( $path . $scan . '/config.php' ) ) {
842
- include_once( $path . $scan . '/config.php' );
843
- }
844
- }
845
- }
846
- }
847
-
848
- }
849
- }
850
-
851
- /**
852
- * Say if you want to set description for the current layout or not. This method must be used only inside the
853
- * config.php file of layout
854
- *
855
- * @param $v string 'yes' or 'no'
856
- *
857
- * @return void
858
- * @since 1.0
859
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
860
- */
861
- public function add_description_field( $v ) {
862
- $this->layouts[ $this->_layout ]['support']['description'] = $v == 'yes' ? true : false;
863
- }
864
-
865
- /**
866
- * Add the extra fields for the specific layout type of portfolio
867
- *
868
- * @param array $fields The fields to add
869
- *
870
- * @return void
871
- * @since 1.0
872
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
873
- */
874
- public function add_layout_fields( $fields = array() ) {
875
- // change the ID
876
- foreach ( $fields as $id => $val ) {
877
- unset( $fields[ $id ] );
878
- $id = $this->_layout . '_' . $id;
879
- $fields[ $id ] = $val;
880
- }
881
-
882
- $this->layouts[ $this->_layout ]['fields'] = $fields;
883
- }
884
-
885
- /**
886
- * Add fields to add to the metabox of each item of each post type created
887
- *
888
- * @param array $fields The fields to add
889
- *
890
- * @return void
891
- * @since 1.0
892
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
893
- */
894
- public function add_item_fields( $fields = array() ) {
895
- // change the ID
896
- foreach ( $fields as $id => $val ) {
897
- unset( $fields[ $id ] );
898
- //$id = $this->_layout . '_' . $id;
899
- $fields[ $id ] = $val;
900
- }
901
- $this->layouts[ $this->_layout ]['item_fields'] = $fields;
902
- }
903
-
904
- /**
905
- * Add columns to the table list
906
- *
907
- * @param array $columns The columns to add in the table list
908
- *
909
- * @return void
910
- * @since 1.0
911
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
912
- */
913
- public function add_table_columns( $columns ) {
914
- $this->layouts[ $this->_layout ]['columns'] = $columns;
915
- }
916
-
917
- /**
918
- * Enqueue the css files of layout
919
- *
920
- * @param string $handle Name of the stylesheet.
921
- * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
922
- * @param array $deps An array of registered style handles this stylesheet depends on. Default empty array.
923
- * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter is used
924
- * to ensure that the correct version is sent to the client regardless of caching, and so
925
- * should be included if a version number is available and makes sense for the stylesheet.
926
- * @param string $media Optional. The media for which this stylesheet has been defined.
927
- * Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
928
- * 'screen', 'tty', or 'tv'.
929
- *
930
- * @return void
931
- * @since 1.0
932
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
933
- */
934
- public function enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
935
- $this->layouts[ $this->_layout ]['css'][] = compact( 'handle', 'src', 'deps', 'ver', 'media' );
936
- }
937
-
938
- /**
939
- * Enqueue the js files of layout
940
- *
941
- * @param string $handle Name of the script.
942
- * @param string|bool $src Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
943
- * @param array $deps An array of registered handles this script depends on. Default empty array.
944
- * @param string|bool $ver Optional. String specifying the script version number, if it has one. This parameter
945
- * is used to ensure that the correct version is sent to the client regardless of caching,
946
- * and so should be included if a version number is available and makes sense for the script.
947
- * @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
948
- * Default 'false'. Accepts 'false' or 'true'.
949
- *
950
- * @return void
951
- * @since 1.0
952
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
953
- */
954
- public function enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
955
- $this->layouts[ $this->_layout ]['js'][] = compact( 'handle', 'src', 'deps', 'ver', 'in_footer' );
956
- }
957
-
958
- /**
959
- * Enqueue the assets for the frontend
960
- *
961
- * @return void
962
- * @since 1.0
963
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
964
- */
965
- public function frontend_assets() {
966
- global $post;
967
-
968
- // not single
969
- if ( ! is_single() || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
970
- $posts = get_posts(array(
971
- 'post_type' => $this->_name,
972
- 'posts_per_page' => -1,
973
- 'post_status' => 'publish',
974
- 'fields' => 'ids'
975
- ));
976
-
977
- $enqueued = array();
978
-
979
- foreach ( $posts as $post_id ) {
980
- $layout = get_post_meta( $post_id, $this->_args['layout_option'], true );
981
-
982
- if ( in_array( $layout, array( $enqueued ) ) || ! isset( $this->layouts[ $layout ]['css'] ) ) {
983
- continue;
984
- }
985
-
986
- foreach ( $this->layouts[ $layout ]['css'] as $asset ) {
987
- if ( empty( $asset ) ) {
988
- continue;
989
- }
990
- yit_enqueue_style( $asset['handle'], empty( $asset['src'] ) ? false : $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['media'] );
991
- }
992
-
993
- $enqueued[] = $layout;
994
- }
995
- }
996
-
997
- // load assets of single template
998
- else {
999
- $layout = 'single';
1000
-
1001
- if ( ! isset( $this->layouts[ $layout ]['css'] ) ) {
1002
- return;
1003
- }
1004
-
1005
- foreach ( $this->layouts[ $layout ]['css'] as $asset ) {
1006
- if ( empty( $asset ) ) {
1007
- continue;
1008
- }
1009
- yit_enqueue_style( $asset['handle'], $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['media'] );
1010
- }
1011
- }
1012
-
1013
- }
1014
-
1015
- /**
1016
- * Register Metaboxes options
1017
- *
1018
- * Add the metabox for the portfolio settings
1019
- *
1020
- * @return void
1021
- * @since 1.0
1022
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1023
- */
1024
- public function add_metabox_cptu() {
1025
-
1026
- // Reorganize layouts
1027
- if ( $this->_args['manage_layouts'] ) {
1028
- $layouts = array();
1029
- foreach ( $this->layouts as $layout_id => $layout ) {
1030
- if ( 'single' == $layout_id ) {
1031
- continue;
1032
- }
1033
- $layouts[ $layout_id ] = $layout['name'];
1034
- }
1035
-
1036
- $layouts = apply_filters( 'yit_cptu_' . $this->_name . '_layout_values', $layouts );
1037
- }
1038
-
1039
- $single_layouts = apply_filters( 'yit_cptu_' . $this->_name . '_single_layout_values', array() );
1040
-
1041
- $metabox_args = array(
1042
- 'label' => sprintf( __( '%s Settings', 'yith-plugin-fw' ), $this->_labels['singular'] ),
1043
- 'pages' => $this->_name, //or array( 'post-type1', 'post-type2')
1044
- 'context' => 'normal', //('normal', 'advanced', or 'side')
1045
- 'priority' => 'default',
1046
- 'tabs' => array(
1047
- 'settings' => array(
1048
- 'label' => __( 'Settings', 'yith-plugin-fw' ),
1049
- 'fields' => apply_filters( 'yit_cptu_fields', array(
1050
- 'type' => array(
1051
- 'label' => __( 'Type', 'yith-plugin-fw' ),
1052
- 'desc' => sprintf( __( 'Layout for this %s' , 'yith-plugin-fw' ), strtolower( $this->_labels['singular'] ) ),
1053
- 'type' => 'select',
1054
- 'options' => isset( $layouts ) ? $layouts : array(),
1055
- 'std' => '' ),
1056
-
1057
- 'rewrite' => array(
1058
- 'label' => __( 'Rewrite', 'yith-plugin-fw' ),
1059
- 'desc' => __( 'Univocal identification name in the URL for each product (slug from post if empty)', 'yith-plugin-fw' ),
1060
- 'type' => 'text',
1061
- 'std' => '' ),
1062
-
1063
- 'label_singular' => array(
1064
- 'label' => __( 'Label in Singular', 'yith-plugin-fw' ),
1065
- 'desc' => __( 'Set a label in singular (title of portfolio if empty)', 'yith-plugin-fw' ),
1066
- 'type' => 'text',
1067
- 'std' => '' ),
1068
-
1069
- 'label_plural' => array(
1070
- 'label' => __( 'Label in Plural', 'yith-plugin-fw' ),
1071
- 'desc' => __( 'Set a label in plural (title of portfolio if empty)', 'yith-plugin-fw' ),
1072
- 'type' => 'text',
1073
- 'std' => '' ),
1074
-
1075
- 'taxonomy' => array(
1076
- 'label' => __( 'Taxonomy', 'yith-plugin-fw' ),
1077
- 'desc' => __( 'If you want to use categories in the portfolio, set a name for taxonomy. Name should be a slug (must not contain capital letters nor spaces) and must not be more than 32 characters long (database structure restriction).', 'yith-plugin-fw' ),
1078
- 'type' => 'text',
1079
- 'std' => '' ),
1080
-
1081
- 'taxonomy_rewrite' => array(
1082
- 'label' => __( 'Taxonomy Rewrite', 'yith-plugin-fw' ),
1083
- 'desc' => __( 'Set univocal name for each category page URL.', 'yith-plugin-fw' ),
1084
- 'type' => 'text',
1085
- 'std' => '' ),
1086
-
1087
- 'single_layout' => array(
1088
- 'label' => __( 'Single layout', 'yith-plugin-fw' ),
1089
- 'desc' => __( 'Layout for single page of this portfolio', 'yith-plugin-fw' ),
1090
- 'type' => 'select',
1091
- 'options' => $single_layouts,
1092
- 'std' => '' ),
1093
- ) )
1094
- )
1095
- )
1096
-
1097
- );
1098
-
1099
- if ( ! $this->_args['has_single'] ) {
1100
- unset( $metabox_args['tabs']['settings']['fields']['rewrite'] );
1101
- }
1102
-
1103
- if ( ! $this->_args['has_taxonomy'] ) {
1104
- unset( $metabox_args['tabs']['settings']['fields']['taxonomy'] );
1105
- unset( $metabox_args['tabs']['settings']['fields']['taxonomy_rewrite'] );
1106
- }
1107
-
1108
- if ( ! empty( $this->_args['label_item_sing'] ) ) {
1109
- unset( $metabox_args['tabs']['settings']['fields']['label_singular'] );
1110
- }
1111
-
1112
- if ( ! empty( $this->_args['label_item_plur'] ) ) {
1113
- unset( $metabox_args['tabs']['settings']['fields']['label_plural'] );
1114
- }
1115
-
1116
- if ( $this->_args['manage_layouts'] ) {
1117
-
1118
- if ( count( $layouts ) < 1 ) {
1119
- unset( $metabox_args['tabs']['settings']['fields']['type'] );
1120
- }
1121
-
1122
- // Layouts options
1123
- foreach ( $this->layouts as $layout => $args ) {
1124
- if ( ! isset( $args['fields'] ) ) {
1125
- continue;
1126
- }
1127
-
1128
- // Section title
1129
- $metabox_args['tabs']['settings']['fields'][ $layout . '_title' ] = array(
1130
- 'desc' => $args['name'] . ' ' . __( 'layout settings', 'yith-plugin-fw' ),
1131
- 'type' => 'title',
1132
- 'deps' => array(
1133
- 'ids' => '_type',
1134
- 'values' => $layout
1135
- )
1136
- );
1137
-
1138
- // Options
1139
- foreach( $args['fields'] as $field_id => $field ) {
1140
- $metabox_args['tabs']['settings']['fields'][ $field_id ] = $field;
1141
- $metabox_args['tabs']['settings']['fields'][ $field_id ]['deps'] = array(
1142
- 'ids' => '_type',
1143
- 'values' => $layout
1144
- );
1145
- }
1146
- }
1147
- }else {
1148
- unset( $metabox_args['tabs']['settings']['fields']['type'] );
1149
- }
1150
-
1151
- if( count( $single_layouts ) < 1 ){
1152
- unset( $metabox_args['tabs']['settings']['fields']['single_layout'] );
1153
- }
1154
-
1155
- // undo if tab empty
1156
- if ( empty( $metabox_args['tabs']['settings']['fields'] ) ) {
1157
- return;
1158
- }
1159
-
1160
- $metabox = YIT_Metabox( $this->_name . '_cptu_settings' );
1161
- $metabox->init( $metabox_args );
1162
- }
1163
-
1164
- /**
1165
- * Register Metaboxes options
1166
- *
1167
- * Add the metabox for the portfolio settings
1168
- *
1169
- * @return void
1170
- * @since 1.0
1171
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1172
- */
1173
- public function add_metabox_item_fields() {
1174
- global $pagenow, $post_type;
1175
-
1176
- // get the actual post type, to add the metabox only if necessary
1177
- if ( $pagenow == 'post.php' && isset( $_REQUEST['post'] ) ) {
1178
- $post_type = get_post_type( intval( $_REQUEST['post'] ) );
1179
- }
1180
- elseif( $pagenow == 'post.php' && isset( $_REQUEST['post_ID'] ) ){
1181
- $post_type = get_post_type( intval( $_REQUEST['post_ID'] ) );
1182
- }
1183
- elseif ( $pagenow == 'post-new.php' && isset( $_REQUEST['post_type'] ) ) {
1184
- $post_type = $_REQUEST['post_type'];
1185
- } else {
1186
- return;
1187
- }
1188
-
1189
- $layout = get_post_meta( $this->_get_id_by_name( $post_type ), $this->_args['layout_option'], true );
1190
-
1191
- if ( empty( $this->layouts[ $layout ]['item_fields'] ) ) {
1192
- return;
1193
- }
1194
-
1195
- $metabox_args = array(
1196
- 'label' => __( 'Settings', 'yith-plugin-fw' ),
1197
- 'pages' => $post_type, //or array( 'post-type1', 'post-type2')
1198
- 'context' => 'normal', //('normal', 'advanced', or 'side')
1199
- 'priority' => 'default',
1200
- 'tabs' => array(
1201
- 'settings' => array(
1202
- 'label' => __( 'Settings', 'yith-plugin-fw' ),
1203
- 'fields' => $this->layouts[ $layout ]['item_fields']
1204
- )
1205
- )
1206
- );
1207
-
1208
- $metabox = YIT_Metabox( $post_type . '_item_fields' );
1209
- $metabox->init( $metabox_args );
1210
-
1211
- }
1212
-
1213
- /**
1214
- * Add quick links inside the editing page of CPTU and Custom Post Types
1215
- *
1216
- * @return void
1217
- * @since 1.0
1218
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1219
- */
1220
- public function add_quick_links_metaboxes() {
1221
- // CPTU
1222
- add_meta_box( $this->_name . '_quick_links', __( 'Quick links', 'yith-plugin-fw' ), array( $this, 'quick_links_cptu_inner' ), $this->_name, 'side', 'high' );
1223
-
1224
- // CPTs
1225
- $args = array(
1226
- 'post_type' => $this->_name,
1227
- 'posts_per_page' => -1,
1228
- 'post_status' => 'publish'
1229
- );
1230
- $post_types = get_posts( $args );
1231
-
1232
- foreach ( $post_types as $post ) {
1233
- $post_type = get_post_meta( $post->ID, '_post_type', true );
1234
- extract( $this->_cpt_args( $post ) );
1235
- add_meta_box( $post->post_type . '_quick_links', __( 'Quick links', 'yith-plugin-fw' ), array( $this, 'quick_links_cpt_inner' ), $post_type, 'side', 'high' );
1236
- }
1237
- }
1238
-
1239
- /**
1240
- * Link to: "View Items", inside the CPTU
1241
- *
1242
- * @param $post
1243
- *
1244
- * @return void
1245
- * @since 1.0
1246
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1247
- */
1248
- public function quick_links_cptu_inner( $post ) {
1249
- extract( $this->_cpt_args( $post ) );
1250
- ?>
1251
- <a href="<?php echo admin_url( 'edit.php?post_type=' . get_post_meta( $post->ID, '_post_type', true ) ) ?>"><?php printf( __( 'View %s', 'yith-plugin-fw' ), $label_plural ) ?></a>
1252
- <?php
1253
- }
1254
-
1255
- /**
1256
- * Link to: "Edit %s", inside the CPTU
1257
- *
1258
- * @param $post
1259
- *
1260
- * @return void
1261
- * @since 1.0
1262
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1263
- */
1264
- public function quick_links_cpt_inner( $post ) {
1265
- $post = get_post( $this->_get_id_by_name( $post->post_type ) );
1266
- ?>
1267
- <a href="<?php echo admin_url( "post.php?post={$post->ID}&action=edit" ) ?>"><?php printf( __( 'Edit %s', 'yith-plugin-fw' ), $post->post_title ) ?></a>
1268
- <?php
1269
- }
1270
-
1271
- /**
1272
- * Define the columns to use in the list table of main sliders post type
1273
- *
1274
- * @param $columns array The columns used in the list table
1275
- *
1276
- * @return array
1277
- * @since 1.0
1278
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1279
- */
1280
- public function cptu_define_columns( $columns ) {
1281
- unset( $columns['date'] );
1282
-
1283
- $columns['actions'] = '';
1284
-
1285
- return $columns;
1286
- }
1287
-
1288
- /**
1289
- * Change the content of each column of the table list
1290
- *
1291
- * @param $column string The current column
1292
- * @param $post_id int The current post ID
1293
- *
1294
- * @return void
1295
- * @since 1.0
1296
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1297
- */
1298
- public function cptu_change_columns( $column, $post_id ) {
1299
- $post = get_post( $post_id );
1300
- extract( $this->_cpt_args( $post ) );
1301
-
1302
- switch ( $column ) {
1303
- case 'actions' :
1304
- echo '<a href="' . admin_url( "post.php?post={$post_id}&action=edit" ) . '" class="button-secondary">' . sprintf( __( 'Edit %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ) . '</a> ';
1305
- echo '<a href="' . admin_url( 'edit.php?post_type=' . get_post_meta( $post_id, '_post_type', true ) ) . '" class="button-secondary">' . sprintf( __( 'View %s', 'yith-plugin-fw' ), $label_plural ) . '</a> ';
1306
- break;
1307
- }
1308
- }
1309
-
1310
- /**
1311
- * Retrieve the path of layout specified in parameter
1312
- *
1313
- * @param $layout
1314
- * @param $file string The file to find
1315
- *
1316
- * @return bool|string
1317
- * @since 1.0
1318
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1319
- */
1320
- public function locate_file( $layout, $file = '' ) {
1321
- if ( ! $this->_args['manage_layouts'] ) {
1322
- return $this->template_path(). '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1323
- }
1324
-
1325
- if ( ! isset( $this->layouts[ $layout ] ) ) {
1326
- $layout = 'default';
1327
- }
1328
-
1329
- return $this->layouts[ $layout ]['path'] . '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1330
- }
1331
-
1332
- /**
1333
- * Retrieve the URL of layout specified in parameter
1334
- *
1335
- * @param $layout
1336
- * @param $file string The file to find
1337
- *
1338
- * @return bool|string
1339
- * @since 1.0
1340
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1341
- */
1342
- public function locate_url( $layout, $file = '' ) {
1343
- if ( ! $this->_args['manage_layouts'] ) {
1344
- return $this->template_url();
1345
-
1346
- }
1347
-
1348
- if ( ! isset( $this->layouts[ $layout ] ) ) {
1349
- $layout = 'default';
1350
- }
1351
-
1352
- return $this->layouts[ $layout ]['url'] . '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1353
- }
1354
-
1355
- /**
1356
- * Retrieve the post ID relative to the post of post type
1357
- *
1358
- * @param $name string
1359
- *
1360
- * @return mixed
1361
- * @since 1.0
1362
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1363
- */
1364
- protected function _get_id_by_name( $name ) {
1365
- global $wpdb;
1366
- return $wpdb->get_var( $wpdb->prepare( "SELECT pm.post_id FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $name, $this->_name ) );
1367
- }
1368
-
1369
- /**
1370
- * Retrieve the post_type of portfolio by portfolio name
1371
- *
1372
- * @param $name string
1373
- *
1374
- * @return mixed
1375
- * @since 1.0
1376
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1377
- */
1378
- protected function _get_post_type_by_name( $name ) {
1379
- global $wpdb;
1380
- return $wpdb->get_var( $wpdb->prepare( "SELECT pm.meta_value FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_name = %s AND p.post_type = %s", '_post_type', $name, $this->_name ) );
1381
- }
1382
-
1383
- /**
1384
- * The shortcode used to show the frontend
1385
- *
1386
- * @param array $atts
1387
- * @param null $content
1388
- *
1389
- * @return string|null
1390
- * @since 1.0
1391
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1392
- */
1393
- public function add_shortcode( $atts, $content = null ) {
1394
- $atts = wp_parse_args( $atts, array(
1395
- 'name' => null,
1396
- 'cat' => array(),
1397
- 'posts_per_page' => false,
1398
- 'style' => null,
1399
- ) );
1400
-
1401
- // don't show the slider if 'name' is empty or is 'none'
1402
- if ( empty( $atts['name'] ) || 'none' == $atts['name'] ) return null;
1403
-
1404
- // compatibility fix: remove prefix if exists in portfolio object
1405
- if( function_exists( 'YIT_Portfolio' ) && method_exists( YIT_Portfolio(), 'is' ) && YIT_Portfolio()->is( $atts['name'] ) ){
1406
- $atts['name'] = str_replace( YIT_Portfolio()->post_type_prefix, '', $atts['name'] );
1407
- }
1408
-
1409
- // pass vars to template
1410
- $atts['post_type'] = $this->_get_post_type_by_name( $atts['name'] );
1411
- $atts['layout'] = $this->_args['manage_layouts'] ? get_post_meta( $this->_get_id_by_name( $atts['post_type'] ), $this->_args['layout_option'], true ) : '';
1412
- extract( apply_filters( 'yit_cptu_frontend_vars', $atts, $this->_name ) );
1413
-
1414
- // add the javascript assets
1415
- if ( $this->_args['manage_layouts'] && isset( $this->layouts[ $layout ]['js'] ) && ! empty( $this->layouts[ $layout ]['js'] ) ) {
1416
- foreach ( $this->layouts[ $layout ]['js'] as $asset ) {
1417
- if ( empty( $asset ) ) continue;
1418
-
1419
- if ( empty( $asset['src'] ) ) {
1420
- wp_enqueue_script( $asset['handle'] );
1421
- continue;
1422
- }
1423
-
1424
- yit_enqueue_script( $asset['handle'], $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['in_footer'] );
1425
- }
1426
- }
1427
-
1428
- // Unique sequential index to differentiate more cpt in the same page
1429
- ++$this->index;
1430
-
1431
- ob_start();
1432
-
1433
- include( $this->locate_file( $layout, 'markup' ) );
1434
-
1435
- return ob_get_clean();
1436
-
1437
- }
1438
-
1439
- /**
1440
- * Shortcode icon
1441
- *
1442
- * Return the shortcode icone to display on shortcode panel
1443
- *
1444
- * @param $icon_url string Icone url found by yit_shortcode plugin
1445
- *
1446
- * @return string
1447
- * @since 1.0.0
1448
- * @author Antonino Scarfi' <antonio.scarfi@yithemes.it>
1449
- */
1450
- public function shortcode_icon( $icon_url ) {
1451
- return ! empty( $this->_args['shortcode_icon'] ) ? $this->_args['shortcode_icon'] : $icon_url;
1452
- }
1453
-
1454
- /**
1455
- * Return an array with cptu options to shortcode panel
1456
- *
1457
- * All definition settings to add cptu shortcode to Yit Shortcode Panel
1458
- *
1459
- * @param array $shortcodes
1460
- *
1461
- * @return array
1462
- * @since 1.0
1463
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1464
- */
1465
- public function add_shortcode_to_box( $shortcodes ) {
1466
- $post_types = array();
1467
-
1468
- foreach ( $this->get_post_types() as $post ) {
1469
- $post_types[ $post->post_name ] = $post->post_title;
1470
- }
1471
-
1472
- $args = array(
1473
- $this->_args['shortcode_name'] => array(
1474
- 'title' => $this->_labels['singular'],
1475
- 'description' => sprintf( __( 'Show frontend of the %s', 'yith-plugin-fw' ), $this->_labels['main_name'] ),
1476
- 'tab' => 'cpt',
1477
- 'create' => false,
1478
- 'has_content' => false,
1479
- 'in_visual_composer' => true,
1480
- 'attributes' => array(
1481
- 'name' => array(
1482
- 'title' => __( 'Name', 'yith-plugin-fw' ),
1483
- 'type' => 'select',
1484
- 'options' => $post_types,
1485
- 'std' => ''
1486
- ),
1487
- )
1488
- )
1489
- );
1490
-
1491
- return array_merge( $shortcodes, $args );
1492
- }
1493
-
1494
- /**
1495
- * Check the post type passed in parameter, if is generated by this CPTU
1496
- *
1497
- * @param $post_type string The post type to check
1498
- *
1499
- * @return bool
1500
- * @since 1.0
1501
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1502
- */
1503
- protected function _is_valid( $post_type ) {
1504
- return (bool)( strpos( $post_type, $this->_args['post_type_prefix'] ) !== false );
1505
- }
1506
-
1507
- /**
1508
- * Add as a valid post type all cptu when importing dummy data
1509
- *
1510
- * @param $post array The post object
1511
- *
1512
- * @return array
1513
- * @since 1.0
1514
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1515
- */
1516
- public function add_importer_required_post_type( $post ){
1517
- global $wp_post_types, $wp_taxonomies;
1518
-
1519
- if( strpos( $post['post_type'], $this->_prefix_cpt ) === FALSE ){
1520
- return $post;
1521
- }
1522
-
1523
- if( ! isset( $wp_post_types[ $post['post_type'] ] ) ){
1524
- $wp_post_types[ $post['post_type'] ] = array(
1525
- 'name' => ''
1526
- );
1527
- }
1528
-
1529
- if( ! empty( $post['terms'] ) ){
1530
- foreach( $post['terms'] as $term ){
1531
- if( ! isset( $wp_taxonomies[ $term['domain'] ] ) ){
1532
- $wp_taxonomies[ $term['domain'] ] = array(
1533
- 'name' => ''
1534
- );
1535
- }
1536
- }
1537
- }
1538
-
1539
-
1540
- return $post;
1541
- }
1542
-
1543
- /**
1544
- * Add taxonomy when importing dummy data
1545
- *
1546
- * @param $terms array Array of terms
1547
- *
1548
- * @return array
1549
- * @since 1.0
1550
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1551
- */
1552
- public function add_importer_required_taxonomy( $terms ){
1553
- global $wp_taxonomies;
1554
-
1555
- if( ! empty( $terms ) ){
1556
- foreach ( $terms as $term ) {
1557
- if( isset( $term['domain'] ) && ! isset( $wp_taxonomies[ $term['domain'] ] ) ){
1558
- $wp_taxonomies[ $term['domain'] ] = array(
1559
- 'name' => ''
1560
- );
1561
- }
1562
- }
1563
- }
1564
-
1565
- return $terms;
1566
- }
1567
-
1568
- /**
1569
- * Force terms recount for imported taxonomy
1570
- *
1571
- * @param $tt_ids array Terms ids
1572
- * @param $ids array Post ids
1573
- * @param $tax string Taxonomy name
1574
- *
1575
- * @return void
1576
- * @since 1.0
1577
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1578
- */
1579
- public function recount_terms_post( $tt_ids, $ids, $tax ){
1580
- wp_update_term_count( $tt_ids, $tax );
1581
- }
1582
-
1583
- // ### ASSETS ###
1584
-
1585
- /**
1586
- * Enqueue the assets for the admin
1587
- *
1588
- * @return void
1589
- * @since 1.0
1590
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1591
- */
1592
- public function admin_assets() {
1593
- wp_enqueue_media();
1594
- wp_enqueue_script( 'yit-cptu', YIT_CORE_PLUGIN_URL . '/assets/js/yit-cpt-unlimited.js', array('jquery'), '', true );
1595
- }
1596
-
1597
- /**
1598
- * Add the button to the top of the list table page of CPTU
1599
- *
1600
- * @return void
1601
- * @since 1.0
1602
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1603
- */
1604
- public function add_button_multiuploader() {
1605
- global $pagenow, $post_type, $wpdb;
1606
-
1607
- if( $pagenow != 'edit.php' ){
1608
- return;
1609
- }
1610
-
1611
- $cptu = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_type FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s", '_post_type', $post_type ) );
1612
-
1613
- $post = get_post( $this->_get_id_by_name( $post_type ) );
1614
- if ( empty( $post ) ) {
1615
- return;
1616
- }
1617
- extract( $this->_cpt_args( $post ) );
1618
-
1619
- if ( $cptu != $this->_name || ! $this->_is_valid( $post_type ) ) {
1620
- return;
1621
- }
1622
- ?>
1623
- <script>
1624
- (function($) {
1625
- "use strict";
1626
- // Author code here
1627
-
1628
- var button = $('<a />', {
1629
- href: '#',
1630
- class: 'multi-uploader add-new-h2',
1631
- 'data-uploader_title': '<?php printf( __( 'Add %s from images', 'yith-plugin-fw' ), $label_plural ) ?>',
1632
- 'data-uploader_button_text': '<?php printf( __( 'Add %s', 'yith-plugin-fw' ), $label_plural ) ?>'
1633
- }).text('<?php _e( 'Upload multiple files', 'yith-plugin-fw' ) ?>');
1634
-
1635
- var spinner = $('<span />', {
1636
- class: 'spinner',
1637
- style: 'float: none;'
1638
- });
1639
-
1640
- button.appendTo('.wrap h2, .wrap h1').after(spinner);
1641
-
1642
- })(jQuery);
1643
- </script>
1644
- <?php
1645
- }
1646
-
1647
- /**
1648
- * Add more posts by multiupload
1649
- *
1650
- * @return void
1651
- * @since 1.0
1652
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1653
- */
1654
- public function post_multiuploader() {
1655
- if ( ! isset( $_REQUEST['images'] ) || ! isset( $_REQUEST['post_type'] ) && $this->_is_valid( $_REQUEST['post_type'] ) ) {
1656
- return;
1657
- }
1658
-
1659
- foreach ( $_REQUEST['images'] as $the ) {
1660
-
1661
- // Create post object
1662
- $arg = array(
1663
- 'post_title' => $the['title'],
1664
- 'post_type' => $_REQUEST['post_type']
1665
- );
1666
- $post_id = wp_insert_post( $arg );
1667
-
1668
- set_post_thumbnail( $post_id, $the['id'] );
1669
-
1670
- }
1671
-
1672
- die();
1673
- }
1674
-
1675
-
1676
- // ###### SINGLE TEMPLATE ######
1677
-
1678
- /**
1679
- * Load the single template file
1680
- *
1681
- * @return void
1682
- * @since 1.0
1683
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1684
- */
1685
- public function single_template() {
1686
- global $post, $wpdb;
1687
-
1688
- // if ( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ) {
1689
- // $post = get_post( $_REQUEST['post_id'] );
1690
- // }
1691
-
1692
- if ( ( ( ! defined('DOING_AJAX') || ! DOING_AJAX ) && ! is_single() ) || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
1693
- return;
1694
- }
1695
-
1696
- // add the javascript assets
1697
- if ( $this->_args['manage_layouts'] ) {
1698
- foreach ( $this->layouts[ 'single' ]['js'] as $asset ) {
1699
- yit_enqueue_script( $asset['handle'], $this->locate_url( 'single' ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['in_footer'] );
1700
- }
1701
- }
1702
-
1703
- $post_name = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post->post_type, $this->_name ) );
1704
- extract( apply_filters( 'yit_cptu_frontend_vars', array( 'name' => $post_name ), $this->_name ) );
1705
-
1706
- include( $this->locate_file( 'single', 'markup' ) );
1707
- }
1708
-
1709
- /**
1710
- * Load a file for the configuration of single template page of portfolio
1711
- *
1712
- * @return void
1713
- * @since 1.0
1714
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1715
- */
1716
- public function single_template_config() {
1717
- global $post, $wpdb;
1718
-
1719
- if ( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ) {
1720
- $post = get_post( $_REQUEST['post_id'] );
1721
- }
1722
-
1723
- if ( ( ( ! defined('DOING_AJAX') || ! DOING_AJAX ) && ! is_single() ) || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
1724
- return;
1725
- }
1726
-
1727
- $this->_layout = 'single';
1728
- $path = $this->locate_file( 'single', 'config' );
1729
-
1730
- if ( file_exists( $path ) ) {
1731
- $post_name = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post->post_type, $this->_name ) );
1732
- extract( apply_filters( 'yit_cptu_frontend_vars', array( 'name' => $post_name ), $this->_name ) );
1733
-
1734
- include( $path );
1735
- }
1736
- }
1737
-
1738
-
1739
- // ########################## ARCHIVE TEMPLATE ###############################
1740
-
1741
-
1742
- /**
1743
- * Load the template for archive page
1744
- *
1745
- * @return void
1746
- * @since 1.0
1747
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1748
- */
1749
- public function archive_template() {
1750
- global $wp_query;
1751
-
1752
-
1753
- // check if we are in archive template
1754
- if ( !( ! is_admin() && is_archive() && isset($wp_query->post) && $this->_is_valid( $wp_query->post->post_type ) ) ) {
1755
- return;
1756
- }
1757
-
1758
- // remove the action from loop of theme
1759
- remove_action( 'yit_content_loop', 'yit_content_loop', 10 );
1760
- add_action( 'yit_content_loop', array( $this, 'archive_template_loop' ), 10 );
1761
-
1762
- }
1763
-
1764
- /**
1765
- * Load loop for the archive template
1766
- *
1767
- * @return void
1768
- * @since 1.0
1769
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1770
- */
1771
- public function archive_template_loop() {
1772
- echo $this->add_shortcode( array( 'name' => $GLOBALS['wp_query']->post->post_type ) );
1773
- }
1774
-
1775
  }
1
+ <?php
2
+ /*
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+ if (!defined('ABSPATH')) {exit('Direct access forbidden.');
11
+ }
12
+
13
+ /**
14
+ * Manage the custom post types as Portfolio, Contact Forms and similar (called CPTU)
15
+ *
16
+ * @class YIT_CPT_Unlimited
17
+ * @package Yithemes
18
+ * @since 2.0.0
19
+ * @author Your Inspiration Themes
20
+ *
21
+ */
22
+
23
+ class YIT_CPT_Unlimited {
24
+
25
+ /**
26
+ * @var string The name of main post type of CPTU
27
+ * @since 1.0
28
+ */
29
+ protected $_name = '';
30
+
31
+ /**
32
+ * @var string The prefix of each post type created by the post of main CPTU
33
+ * @since 1.0
34
+ */
35
+ protected $_prefix_cpt = '';
36
+
37
+ /**
38
+ * @var string The labels defined for the main CPTU
39
+ * @since 1.0
40
+ */
41
+ protected $_labels = '';
42
+
43
+ /**
44
+ * @var string The configuration arguments of post type
45
+ * @since 1.0
46
+ */
47
+ protected $_args = '';
48
+
49
+ /**
50
+ * @var array All post types created by the post of main CPTU
51
+ * @since 1.0
52
+ */
53
+ public $post_types = array();
54
+
55
+ /**
56
+ * @var array $layouts Array with all portfolio layouts available for this site
57
+ * @since 1.0
58
+ */
59
+ public $layouts = array();
60
+
61
+ /**
62
+ * @var string $template_path The pathname of template folder
63
+ * @since 1.0
64
+ */
65
+ protected $template_path = '';
66
+
67
+ /**
68
+ * @var string $template_url The URL of template folder
69
+ * @since 1.0
70
+ */
71
+ protected $template_url = '';
72
+
73
+ /**
74
+ * @var int $_index Unique sequential ID to differentiate same shortcodes in the same page
75
+ */
76
+ public $index = 0;
77
+
78
+ /**
79
+ * @var string $_layout Temporary attribute to load automatically the settings for each layout
80
+ * @since 1.0
81
+ */
82
+ private $_layout = '';
83
+
84
+
85
+ /**
86
+ * Constructor
87
+ *
88
+ * Accept an array of arguments to define the characteristics of CPTU to register.
89
+ *
90
+ * @since 1.0
91
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
92
+ */
93
+ public function __construct( $args = array() ) {
94
+
95
+ $defaults = array(
96
+ 'name' => '',
97
+ 'post_type_prefix' => '',
98
+ 'labels' => array(
99
+ 'main_name' => '',
100
+ 'singular' => '',
101
+ 'plural' => '',
102
+ 'menu' => ''
103
+ ),
104
+ 'manage_layouts' => false,
105
+ 'add_multiuploader' => false,
106
+ 'sortable' => false,
107
+ 'has_single' => false,
108
+ 'has_taxonomy' => false,
109
+ 'label_item_sing' => '',
110
+ 'label_item_plur' => '',
111
+ 'shortcode_name' => '',
112
+ 'shortcode_icon' => '', // URL or icon name from http://melchoyce.github.io/dashicons/
113
+ 'layout_option' => '_type' // the option ID of layout metabox
114
+ );
115
+ $this->_args = wp_parse_args( $args, $defaults );
116
+
117
+ // fix labels
118
+ if ( empty( $this->_args['labels']['main_name'] ) ) {
119
+ $this->_args['labels']['main_name'] = $this->_args['labels']['singular'];
120
+ }
121
+ if ( empty( $this->_args['labels']['menu'] ) ) {
122
+ $this->_args['labels']['menu'] = $this->_args['labels']['singular'];
123
+ }
124
+
125
+ /* populate */
126
+ $this->_name = $this->_args['name'];
127
+ $this->_prefix_cpt = $this->_args['post_type_prefix'];
128
+ $this->_labels = $this->_args['labels'];
129
+
130
+ add_action( 'init', array( $this, 'register_post_type' ) );
131
+ add_action( 'init', array( $this, 'register_cptu_post_types' ) );
132
+
133
+ add_action( 'save_post', array( $this, 'rewrite_flush') );
134
+
135
+ // admin interface
136
+ add_action( 'admin_head', array( $this, 'add_cptu_menu_item' ) );
137
+ add_action( 'admin_init', array( $this, 'add_quick_links_metaboxes' ) );
138
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_assets' ) );
139
+
140
+ // metaboxes
141
+ add_action( 'after_setup_theme', array( $this, 'add_metabox_cptu' ), 2 );
142
+ add_action( 'after_setup_theme', array( $this, 'add_metabox_item_fields' ), 2 );
143
+
144
+ // multiuploader
145
+ if ( $this->_args['add_multiuploader'] ) {
146
+ add_action( 'admin_footer', array( $this, 'add_button_multiuploader' ) );
147
+ add_action( 'wp_ajax_yit_cptu_multiuploader', array( $this, 'post_multiuploader' ) );
148
+ }
149
+
150
+ // layouts
151
+ if ( $this->_args['manage_layouts'] ) {
152
+ // get all layouts available
153
+ $this->get_layouts();
154
+ }
155
+
156
+ // single layout
157
+ if ( $this->_args['has_single'] ) {
158
+ add_action( 'yit_loop', array( $this, 'single_template' ) );
159
+ add_action( 'wp', array( $this, 'single_template_config' ) );
160
+
161
+ if ( defined('DOING_AJAX') && DOING_AJAX ) {
162
+ add_action( 'init', array( $this, 'single_template_config' ) );
163
+ }
164
+ }
165
+
166
+ // archive template
167
+ add_action( 'wp', array( $this, 'archive_template' ) );
168
+
169
+ // enqueue the assets of each layout
170
+ add_action( 'wp_enqueue_scripts', array( $this, 'frontend_assets' ) );
171
+
172
+ // add the shortcode, used to show the frontend
173
+ if ( ! empty( $this->_args['shortcode_name'] ) ) {
174
+ add_shortcode( $this->_args['shortcode_name'], array( &$this, 'add_shortcode' ) );
175
+ add_filter( 'yit_shortcode_' . $this->_args['shortcode_name'] . '_icon', array( $this, 'shortcode_icon') );
176
+ add_filter( 'yit-shortcode-plugin-init', array( $this, 'add_shortcode_to_box' ) );
177
+ }
178
+
179
+ // add sortable feature
180
+ if ( $this->_args['sortable'] ) {
181
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_sortable_assets' ) );
182
+ add_action( 'wp_ajax_cpt_sort_posts', array( $this, 'sort_posts' ) );
183
+ add_action( 'admin_init', array( $this, 'init_menu_order' ) );
184
+ add_filter( 'pre_get_posts', array( $this, 'filter_active' ) );
185
+ add_filter( 'pre_get_posts', array( $this, 'pre_get_posts' ) );
186
+ add_filter( 'get_next_post_where', array( $this, 'sorted_next_post_where' ) );
187
+ add_filter( 'get_previous_post_where', array( $this, 'sorted_prev_post_where' ) );
188
+ add_filter( 'get_next_post_sort', array( $this, 'sorted_next_post_sort' ) );
189
+ add_filter( 'get_previous_post_sort', array( $this, 'sorted_prev_post_sort' ) );
190
+ }
191
+
192
+ // add default columns to post type table list
193
+ add_filter( 'manage_edit-' . $this->_name . '_columns', array( $this, 'cptu_define_columns' ) );
194
+ add_action( 'manage_' . $this->_name . '_posts_custom_column' , array( $this, 'cptu_change_columns' ), 10, 2 );
195
+
196
+ // add required post type for wordpress importer
197
+ add_filter( 'wp_import_post_data_raw', array( $this, 'add_importer_required_post_type' ) );
198
+ add_filter( 'wp_import_terms', array( $this, 'add_importer_required_taxonomy' ) );
199
+ add_action( 'wp_import_set_post_terms', array( $this, 'recount_terms_post' ), 10, 3 );
200
+
201
+ }
202
+
203
+ /**
204
+ * Enqueue the assets for the sortable feature
205
+ *
206
+ * @return void
207
+ * @since 1.0
208
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
209
+ */
210
+ public function admin_sortable_assets() {
211
+ global $post;
212
+
213
+ if ( ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
214
+ return;
215
+ }
216
+
217
+ wp_enqueue_script( 'yit-cptu-sortable-posts', YIT_CORE_PLUGIN_URL . '/assets/js/yit-cptu-sortable-posts.js', array( 'jquery', 'jquery-ui-sortable' ), '1.0', true );
218
+ }
219
+
220
+ public function init_menu_order( $post_types = array() ) {
221
+ global $wpdb;
222
+
223
+ if ( empty( $post_types ) ) {
224
+ $post_types = $wpdb->get_col( $wpdb->prepare( "SELECT DISTINCT post_type FROM $wpdb->posts WHERE post_type LIKE %s", str_replace( '_', '\_', $this->_prefix_cpt ) . '%' ) );
225
+ } elseif ( ! is_array( $post_types ) ) {
226
+ $post_types = array( $post_types );
227
+ }
228
+
229
+ foreach ( $post_types as $post_type ) {
230
+ $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = '{$post_type}' AND post_status IN ('publish', 'pending', 'draft', 'private', 'future') AND menu_order = 0" );
231
+
232
+ if ( empty( $count ) ) {
233
+ continue;
234
+ }
235
+
236
+ $sql = "SELECT ID
237
+ FROM $wpdb->posts
238
+ WHERE post_type = '" . $post_type . "'
239
+ AND post_status IN ('publish', 'pending', 'draft', 'private', 'future')
240
+ ORDER BY post_date DESC
241
+ ";
242
+
243
+ $results = $wpdb->get_results( $sql );
244
+
245
+ foreach ( $results as $key => $result ) {
246
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $key + 1 ), array( 'ID' => $result->ID ) );
247
+ }
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Save the order of posts from sortable feature
253
+ *
254
+ * @return void
255
+ * @since 1.0
256
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
257
+ */
258
+ public function sort_posts() {
259
+ global $wpdb;
260
+
261
+ parse_str( $_REQUEST['order'], $data );
262
+
263
+ if ( is_array( $data ) ) {
264
+ //$this->init_menu_order( $_REQUEST['post_type'] );
265
+
266
+ $id_arr = array( );
267
+ foreach ( $data as $key => $values ) {
268
+ foreach ( $values as $position => $id ) {
269
+ $id_arr[] = $id;
270
+ }
271
+ }
272
+
273
+
274
+ $menu_order_arr = array( );
275
+ foreach ( $id_arr as $key => $id ) {
276
+ $results = $wpdb->get_results( "SELECT menu_order FROM $wpdb->posts WHERE ID = " . $id );
277
+ foreach ( $results as $result ) {
278
+ $menu_order_arr[] = $result->menu_order;
279
+ }
280
+ }
281
+
282
+ sort( $menu_order_arr );
283
+
284
+ foreach ( $data as $key => $values ) {
285
+ foreach ( $values as $position => $id ) {
286
+ $wpdb->update( $wpdb->posts, array( 'menu_order' => $menu_order_arr[$position] ), array( 'ID' => $id ) );
287
+ }
288
+ }
289
+ }
290
+
291
+ die();
292
+ }
293
+
294
+ public function filter_active( $wp_query ) {
295
+ if ( is_admin() && isset( $wp_query->query['suppress_filters'] ) )
296
+ $wp_query->query['suppress_filters'] = false;
297
+ if ( is_admin() && isset( $wp_query->query_vars['suppress_filters'] ) )
298
+ $wp_query->query_vars['suppress_filters'] = false;
299
+ return $wp_query;
300
+ }
301
+
302
+ public function pre_get_posts( $wp_query ) {
303
+ if ( is_admin() && !defined( 'DOING_AJAX' ) ) {
304
+ if ( isset( $wp_query->query['post_type'] ) ) {
305
+ $post_types = (array) $wp_query->query['post_type'];
306
+ foreach ( $post_types as $post_type ) {
307
+ if ( $this->_is_valid( $post_type ) ) {
308
+ $wp_query->set( 'orderby', 'menu_order' );
309
+ $wp_query->set( 'order', 'ASC' );
310
+ }
311
+ }
312
+ }
313
+
314
+ } else {
315
+
316
+ $active = false;
317
+
318
+ if ( isset( $wp_query->query['suppress_filters'] ) || isset( $wp_query->query['post_type'] ) ) {
319
+ $post_types = (array) $wp_query->query['post_type'];
320
+ foreach ( $post_types as $post_type ) {
321
+ if ( $this->_is_valid( $post_type ) ) {
322
+ $active = true;
323
+ }
324
+ }
325
+ }
326
+
327
+ if ( $active ) {
328
+ if ( !isset( $wp_query->query['orderby'] ) || $wp_query->query['orderby'] == 'post_date' )
329
+ $wp_query->set( 'orderby', 'menu_order' );
330
+ if ( !isset( $wp_query->query['order'] ) || $wp_query->query['order'] == 'DESC' )
331
+ $wp_query->set( 'order', 'ASC' );
332
+ }
333
+ }
334
+ }
335
+
336
+ /**
337
+ * Filters where clause for get next post
338
+ *
339
+ * @param $where
340
+ *
341
+ * @return string
342
+ * @since 1.0
343
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
344
+ */
345
+ public function sorted_next_post_where( $where ){
346
+ global $post;
347
+ if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
348
+ $post = get_post( intval( $_REQUEST['post_id'] ) );
349
+ }
350
+ else{
351
+ $post = get_post();
352
+ }
353
+
354
+ if( ! $post || ! $this->_is_valid( $post->post_type ) ){
355
+ return $where;
356
+ }
357
+
358
+ $result = str_replace( "'" . $post->post_date . "'", $post->menu_order, $where );
359
+ $result = str_replace( 'p.post_date', 'p.menu_order', $result );
360
+
361
+ return $result;
362
+ }
363
+
364
+ /**
365
+ * Filters where clause for get prev post
366
+ *
367
+ * @param $where
368
+ *
369
+ * @return string
370
+ * @since 1.0
371
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
372
+ */
373
+ public function sorted_prev_post_where( $where ){
374
+ global $post;
375
+
376
+ if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
377
+ $post = get_post( intval( $_REQUEST['post_id'] ) );
378
+ }
379
+ else{
380
+ $post = get_post();
381
+ }
382
+
383
+ if( ! $post || ! $this->_is_valid( $post->post_type ) ){
384
+ return $where;
385
+ }
386
+
387
+ $result = str_replace( "'" . $post->post_date . "'", $post->menu_order, $where );
388
+ $result = str_replace( 'p.post_date', 'p.menu_order', $result );
389
+
390
+ return $result;
391
+ }
392
+
393
+ /**
394
+ * Filters sort clause for get next post
395
+ *
396
+ * @param $sort
397
+ *
398
+ * @return string
399
+ * @since 1.0
400
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
401
+ */
402
+ public function sorted_next_post_sort( $sort ){
403
+ global $post;
404
+
405
+ if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
406
+ $post = get_post( intval( $_REQUEST['post_id'] ) );
407
+ }
408
+ else{
409
+ $post = get_post();
410
+ }
411
+
412
+ if( ! $post || ! $this->_is_valid( $post->post_type ) ){
413
+ return $sort;
414
+ }
415
+
416
+ $result = str_replace( 'p.post_date', 'p.menu_order', $sort );
417
+ return $result;
418
+ }
419
+
420
+ /**
421
+ * Filters sort clause for get prev post
422
+ *
423
+ * @param $sort
424
+ *
425
+ * @return string
426
+ * @since 1.0
427
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
428
+ */
429
+ public function sorted_prev_post_sort( $sort ){
430
+ global $post;
431
+
432
+ if( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ){
433
+ $post = get_post( intval( $_REQUEST['post_id'] ) );
434
+ }
435
+ else{
436
+ $post = get_post();
437
+ }
438
+
439
+ if( ! $post || ! $this->_is_valid( $post->post_type ) ){
440
+ return $sort;
441
+ }
442
+
443
+ $result = str_replace( 'p.post_date', 'p.menu_order', $sort );
444
+ return $result;
445
+ }
446
+
447
+ /**
448
+ * Register post type
449
+ *
450
+ * Register the post type for the creation of portfolios
451
+ *
452
+ * @return void
453
+ * @since 1.0
454
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
455
+ */
456
+ public function register_post_type() {
457
+ $labels = array(
458
+ 'name' => ucfirst( $this->_labels['main_name'] ),
459
+ 'singular_name' => ucfirst( $this->_labels['singular'] ),
460
+ 'add_new' => sprintf( __( 'Add %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
461
+ 'add_new_item' => sprintf( __( 'Add New %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
462
+ 'edit_item' => sprintf( __( 'Edit %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
463
+ 'new_item' => sprintf( __( 'New %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
464
+ 'all_items' => sprintf( __( 'All %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
465
+ 'view_item' => sprintf( __( 'View %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ),
466
+ 'search_items' => sprintf( __( 'Search %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
467
+ 'not_found' => sprintf( __( 'No %s found', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
468
+ 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'yith-plugin-fw' ), ucfirst( $this->_labels['plural'] ) ),
469
+ 'parent_item_colon' => '',
470
+ 'menu_name' => ucfirst( $this->_labels['menu'] )
471
+ );
472
+
473
+ $args = array(
474
+ 'labels' => apply_filters( 'yit_' . $this->_name . '_labels', $labels ),
475
+ 'public' => false,
476
+ 'publicly_queryable' => false,
477
+ 'show_ui' => true,
478
+ 'show_in_menu' => true,
479
+ 'query_var' => false,
480
+ 'capability_type' => 'post',
481
+ 'hierarchical' => false,
482
+ 'menu_position' => null,
483
+ 'supports' => array( 'title' )
484
+ );
485
+
486
+ if ( ! empty( $this->_args['menu_icon'] ) ) {
487
+ $args['menu_icon'] = $this->_args['menu_icon'];
488
+ }
489
+
490
+ register_post_type( $this->_name, apply_filters( 'yit_' . $this->_name . '_args', $args ) );
491
+ }
492
+
493
+ /**
494
+ * Retrieve the values configured inside the custom post type
495
+ *
496
+ * @param $post /WP_Query The post where get the arguments configured in the cpt
497
+ *
498
+ * @return array
499
+ * @since 1.0
500
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
501
+ */
502
+ protected function _cpt_args( $post ) {
503
+ if ( ! isset( $post->ID ) ) {
504
+ return;
505
+ }
506
+
507
+ $args = apply_filters( 'yit_cptu_register_post_type_args', array(
508
+ 'layout' => get_post_meta( $post->ID, $this->_args['layout_option'], true ),
509
+ 'rewrite' => get_post_meta( $post->ID, '_rewrite', true ),
510
+ 'label_singular' => ! empty( $this->_args['label_item_sing'] ) ? $this->_args['label_item_sing'] : get_post_meta( $post->ID, '_label_singular', true ),
511
+ 'label_plural' => ! empty( $this->_args['label_item_plur'] ) ? $this->_args['label_item_plur'] : get_post_meta( $post->ID, '_label_plural', true ),
512
+ 'taxonomy' => get_post_meta( $post->ID, '_taxonomy', true ),
513
+ 'taxonomy_rewrite' => get_post_meta( $post->ID, '_taxonomy_rewrite', true ),
514
+ ), $this->_name, $post );
515
+
516
+ $title = $post->post_title;
517
+
518
+ if ( empty( $args['label_singular'] ) ) {
519
+ $args['label_singular'] = $title;
520
+ }
521
+
522
+ if ( empty( $args['label_plural'] ) ) {
523
+ $args['label_plural'] = $title;
524
+ }
525
+
526
+ return $args;
527
+ }
528
+
529
+ /**
530
+ * Retrieve the post types created for this CPTU
531
+ *
532
+ * @return array The link changed
533
+ * @since 1.0
534
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
535
+ */
536
+ public function get_post_types() {
537
+ if ( ! empty( $this->post_types ) ) {
538
+ return $this->post_types;
539
+ }
540
+
541
+ $args = array(
542
+ 'post_type' => $this->_name,
543
+ 'posts_per_page' => -1,
544
+ 'post_status' => 'publish'
545
+ );
546
+ $this->post_types = get_posts( $args );
547
+
548
+ return $this->post_types;
549
+ }
550
+
551
+ /**
552
+ * Register portfolio post types
553
+ *
554
+ * Register the post types for each portfolio created by admin
555
+ *
556
+ * @return void
557
+ * @since 1.0
558
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
559
+ */
560
+ public function register_cptu_post_types() {
561
+ $post_types = $this->get_post_types();
562
+ $pts = array();
563
+
564
+ foreach ( $post_types as $pt ) {
565
+
566
+ extract( $this->_cpt_args( $pt ) );
567
+
568
+ $name = $pt->post_name;
569
+ $title = $pt->post_title;
570
+
571
+ $labels = array(
572
+ 'name' => $title,
573
+ 'singular_name' => $label_singular,
574
+ 'add_new' => sprintf( __( 'Add %s', 'yith-plugin-fw' ), $label_singular ),
575
+ 'add_new_item' => sprintf( __( 'Add New %s', 'yith-plugin-fw' ), $label_singular ),
576
+ 'edit_item' => sprintf( __( 'Edit %s', 'yith-plugin-fw' ), $label_singular ),
577
+ 'new_item' => sprintf( __( 'New %s', 'yith-plugin-fw' ), $label_singular ),
578
+ 'all_items' => sprintf( __( 'All %s', 'yith-plugin-fw' ), $label_plural ),
579
+ 'view_item' => sprintf( __( 'View %s', 'yith-plugin-fw' ), $label_singular ),
580
+ 'search_items' => sprintf( __( 'Search %s', 'yith-plugin-fw' ), $label_plural ),
581
+ 'not_found' => sprintf( __( 'No %s found', 'yith-plugin-fw' ), $label_plural ),
582
+ 'not_found_in_trash' => sprintf( __( 'No %s found in Trash', 'yith-plugin-fw' ), $label_plural ),
583
+ 'parent_item_colon' => '',
584
+ 'menu_name' => $title
585
+ );
586
+
587
+ $args = array(
588
+ 'labels' => apply_filters( 'yit_' . $this->_prefix_cpt . $name . '_labels', $labels ),
589
+ 'public' => true,
590
+ 'publicly_queryable' => true,
591
+ 'show_ui' => true,
592
+ 'show_in_menu' => false,
593
+ 'query_var' => true,
594
+ 'capability_type' => 'post',
595
+ 'hierarchical' => false,
596
+ 'menu_position' => null,
597
+ 'supports' => array( 'title', 'editor', 'thumbnail' )
598
+ );
599
+
600
+ if ( ! $this->_args['has_single'] ) {
601
+ $args['public'] = false;
602
+ $args['publicly_queryable'] = false;
603
+ $args['query_var'] = false;
604
+ }
605
+
606
+ if ( $this->_args['manage_layouts'] && isset($this->layouts[ $layout ]) && ! $this->layouts[ $layout ]['support']['description'] ) {
607
+ unset( $args['supports'][1] ); // remove 'editor'
608
+ }
609
+
610
+ if ( ! empty( $rewrite ) ) {
611
+ $args['rewrite'] = array( 'slug' => $rewrite );
612
+ }
613
+
614
+ // register post type
615
+ $post_type = yit_avoid_duplicate( str_replace( '-', '_', substr( $this->_prefix_cpt . $name, 0, 16) ), $post_types );
616
+ register_post_type( $post_type, apply_filters( 'yit_' . $this->_prefix_cpt . $name . '_args', $args, $pt ) ); // save the post type in post meta
617
+
618
+ update_post_meta( $pt->ID, '_post_type', $post_type );
619
+ $pts[] = $post_type;
620
+
621
+ // register taxonomy
622
+ if ( $this->_args['has_taxonomy'] && ! empty( $taxonomy ) ) {
623
+
624
+ $labels = array(
625
+ 'name' => sprintf( _x( '%s Categories', 'taxonomy general name', 'yith-plugin-fw' ), $label_singular ),
626
+ 'singular_name' => _x( 'Category', 'taxonomy singular name', 'yith-plugin-fw' ),
627
+ 'search_items' => __( 'Search Categories', 'yith-plugin-fw' ),
628
+ 'all_items' => __( 'All Categories', 'yith-plugin-fw' ),
629
+ 'parent_item' => __( 'Parent Category', 'yith-plugin-fw' ),
630
+ 'parent_item_colon' => __( 'Parent Category:', 'yith-plugin-fw' ),
631
+ 'edit_item' => __( 'Edit Category', 'yith-plugin-fw' ),
632
+ 'update_item' => __( 'Update Category', 'yith-plugin-fw' ),
633
+ 'add_new_item' => __( 'Add New Category', 'yith-plugin-fw' ),
634
+ 'new_item_name' => __( 'New Category Name', 'yith-plugin-fw' ),
635
+ 'menu_name' => __( 'Category', 'yith-plugin-fw' ),
636
+ );
637
+
638
+ $args = array(
639
+ 'hierarchical' => true,
640
+ 'labels' => $labels,
641
+ 'show_ui' => true,
642
+ 'show_admin_column' => true,
643
+ 'query_var' => true,
644
+ );
645
+
646
+ if ( ! empty( $taxonomy_rewrite ) ) {
647
+ $args['rewrite'] = array( 'slug' => $taxonomy_rewrite );
648
+ }
649
+
650
+ register_taxonomy( substr( $taxonomy, 0, 32 ), $post_type, $args );
651
+
652
+ }
653
+
654
+ }
655
+
656
+ wp_cache_set( 'yit_cptu_post_types', $post_types );
657
+ }
658
+
659
+ /**
660
+ * Flush Rewrite Rules
661
+ *
662
+ * rewrite rules when a cpt unlimited is saved
663
+ *
664
+ * @return void
665
+ * @since 1.0
666
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
667
+ */
668
+
669
+ public function rewrite_flush( $post ){
670
+
671
+ if ( isset( $post ) && $this->_is_valid( get_post_type( intval( $post ) ) ) ) {
672
+ flush_rewrite_rules();
673
+ }
674
+
675
+ }
676
+
677
+ /**
678
+ * Add the item for each portfolio under "Portfolios"
679
+ *
680
+ * @return void
681
+ * @since 1.0
682
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
683
+ */
684
+ public function add_cptu_menu_item() {
685
+ global $submenu, $post, $parent_file, $pagenow;
686
+
687
+ // get current post type
688
+ if ( isset( $post->post_type ) ) {
689
+ $post_type = $post->post_type;
690
+ } else if ( isset( $_REQUEST['post_type'] ) ) {
691
+ $post_type = $_REQUEST['post_type'];
692
+ } else {
693
+ return;
694
+ }
695
+
696
+ $item = 'edit.php?post_type=' . $this->_name;
697
+
698
+ // add new items
699
+ if ( strpos( $post_type, $this->_prefix_cpt ) !== false ) {
700
+ global $wpdb;
701
+ $portfolio = $wpdb->get_row( $wpdb->prepare( "SELECT p.* FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post_type, $this->_name ) );
702
+
703
+ if ( ! isset( $portfolio->ID ) ) {
704
+ return;
705
+ }
706
+
707
+ $label_singular = ! empty( $this->_args['label_item_sing'] ) ? $this->_args['label_item_sing'] : get_post_meta( $portfolio->ID, '_label_singular', true );
708
+ $label_plural = ! empty( $this->_args['label_item_plur'] ) ? $this->_args['label_item_plur'] : get_post_meta( $portfolio->ID, '_label_plural', true );
709
+
710
+ if ( empty( $label_plural ) ) {
711
+ $label_plural = $portfolio->post_title;
712
+ }
713
+
714
+ if ( empty( $label_singular ) ) {
715
+ $label_singular = $portfolio->post_title;
716
+ }
717
+
718
+ $submenu[ $item ][15] = array( ucfirst( $label_plural ), 'edit_posts', 'edit.php?post_type=' . $post_type );
719
+ $submenu[ $item ][20] = array( sprintf( __('Add %s', 'yith-plugin-fw'), ucfirst( $label_singular ) ), 'edit_posts', 'post-new.php?post_type=' . $post_type );
720
+
721
+ global $wp_taxonomies;
722
+ $taxonomy = get_post_meta( $portfolio->ID, '_taxonomy', true );
723
+ if ( isset( $wp_taxonomies[ $taxonomy ] ) ) {
724
+ $submenu[ $item ][25] = array( __('Categories', 'yith-plugin-fw'), 'edit_posts', 'edit-tags.php?taxonomy=' . $taxonomy . '&post_type=' . $post_type );
725
+ }
726
+ }
727
+
728
+ // set the parent item inside the single of each post type
729
+ if ( $pagenow == 'post.php' && isset( $_GET['post'] ) && $this->_is_valid( get_post_type( intval( $_GET['post'] ) ) ) ) {
730
+ $parent_file = 'edit.php?post_type=' . $this->_name;
731
+ }
732
+ }
733
+
734
+ /**
735
+ * Locate folder of CPTU templates, if there isn't a layouts management
736
+ *
737
+ * @return string
738
+ * @since 1.0
739
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
740
+ */
741
+ public function template_path() {
742
+ if ( ! empty( $this->template_path ) ) {
743
+ return $this->template_path;
744
+ }
745
+
746
+ // paths
747
+ $stylesheet_path_1 = get_stylesheet_directory() . '/theme/templates/' . $this->_name . '/';
748
+ $stylesheet_path_2 = get_template_directory() . '/theme/templates/' . $this->_name . '/';
749
+ $template_path_1 = get_stylesheet_directory() . '/' . $this->_name . '/';
750
+ $template_path_2 = get_template_directory() . '/' . $this->_name . '/';
751
+ $plugin_path = $this->_args['plugin_path'] . '/templates/';
752
+
753
+ foreach ( array( 'stylesheet_path_1', 'stylesheet_path_2', 'template_path_1', 'template_path_2', 'plugin_path' ) as $var ) {
754
+ $path = ${$var};
755
+
756
+ if ( file_exists( $path ) ) {
757
+ $this->template_path = $path;
758
+ }
759
+ }
760
+
761
+ return $this->template_path;
762
+ }
763
+
764
+ /**
765
+ * Locate folder of CPTU templates, if there isn't a layouts management
766
+ *
767
+ * @return string
768
+ * @since 1.0
769
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
770
+ */
771
+ public function template_url() {
772
+ if ( ! empty( $this->template_url ) ) {
773
+ return $this->template_path;
774
+ }
775
+
776
+ $this->template_url = str_replace( array(
777
+ get_stylesheet_directory(),
778
+ get_template_directory(),
779
+ $this->_args['plugin_path']
780
+ ), array(
781
+ get_stylesheet_directory_uri(),
782
+ get_template_directory_uri(),
783
+ $this->_args['plugin_url']
784
+ ), $this->template_path() );
785
+
786
+ return $this->template_url;
787
+ }
788
+
789
+ /**
790
+ * Retrieve all layouts to manage by custom post type added in the site in this order:
791
+ * 1. Child theme (if exists)
792
+ * 2. Theme
793
+ * 3. Plugin
794
+ *
795
+ * It also load the config.php file of each layout
796
+ *
797
+ * @return void
798
+ * @since 1.0
799
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
800
+ */
801
+ public function get_layouts() {
802
+
803
+ // paths
804
+ $stylesheet_path_1 = get_stylesheet_directory() . '/theme/templates/' . $this->_name . '/';
805
+ $stylesheet_path_2 = get_template_directory() . '/theme/templates/' . $this->_name . '/';
806
+ $template_path_1 = get_stylesheet_directory() . '/' . $this->_name . '/';
807
+ $template_path_2 = get_template_directory() . '/' . $this->_name . '/';
808
+ $plugin_path = $this->_args['plugin_path'] . '/templates/';
809
+
810
+ foreach ( array( 'stylesheet_path_1', 'stylesheet_path_2', 'template_path_1', 'template_path_2', 'plugin_path' ) as $var ) {
811
+ $path = ${$var};
812
+
813
+ if ( file_exists( $path ) ) {
814
+ foreach ( scandir( $path ) as $scan ) {
815
+ if ( ! isset( $this->layouts[$scan] ) && is_dir( $path . $scan ) && ! in_array( $scan, array( '.', '..', '.svn' ) ) && $scan[0] != '_' ) {
816
+ $this->layouts[$scan] = array(
817
+ 'name' => ucfirst( str_replace( '-', ' ', $scan ) ),
818
+ 'path' => $path . $scan,
819
+ 'url' => str_replace( array(
820
+ get_stylesheet_directory(),
821
+ get_template_directory(),
822
+ $this->_args['plugin_path']
823
+ ), array(
824
+ get_stylesheet_directory_uri(),
825
+ get_template_directory_uri(),
826
+ $this->_args['plugin_url']
827
+ ), $path . $scan ),
828
+ 'css' => array(),
829
+ 'js' => array(),
830
+ 'support' => array(
831
+ 'description' => true
832
+ ),
833
+ 'columns' => array()
834
+ );
835
+
836
+ // set the vars for config.php
837
+ $layout = $scan;
838
+ $this->_layout = $layout; // temporary attribute to load automatically the configuration inside the config.php, for this layout
839
+
840
+ // TODO Fare in modo di caricare il file config.php soltanto quando realmente serve
841
+ if ( ! in_array( $scan, array( 'single' ) ) && file_exists( $path . $scan . '/config.php' ) ) {
842
+ include_once( $path . $scan . '/config.php' );
843
+ }
844
+ }
845
+ }
846
+ }
847
+
848
+ }
849
+ }
850
+
851
+ /**
852
+ * Say if you want to set description for the current layout or not. This method must be used only inside the
853
+ * config.php file of layout
854
+ *
855
+ * @param $v string 'yes' or 'no'
856
+ *
857
+ * @return void
858
+ * @since 1.0
859
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
860
+ */
861
+ public function add_description_field( $v ) {
862
+ $this->layouts[ $this->_layout ]['support']['description'] = $v == 'yes' ? true : false;
863
+ }
864
+
865
+ /**
866
+ * Add the extra fields for the specific layout type of portfolio
867
+ *
868
+ * @param array $fields The fields to add
869
+ *
870
+ * @return void
871
+ * @since 1.0
872
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
873
+ */
874
+ public function add_layout_fields( $fields = array() ) {
875
+ // change the ID
876
+ foreach ( $fields as $id => $val ) {
877
+ unset( $fields[ $id ] );
878
+ $id = $this->_layout . '_' . $id;
879
+ $fields[ $id ] = $val;
880
+ }
881
+
882
+ $this->layouts[ $this->_layout ]['fields'] = $fields;
883
+ }
884
+
885
+ /**
886
+ * Add fields to add to the metabox of each item of each post type created
887
+ *
888
+ * @param array $fields The fields to add
889
+ *
890
+ * @return void
891
+ * @since 1.0
892
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
893
+ */
894
+ public function add_item_fields( $fields = array() ) {
895
+ // change the ID
896
+ foreach ( $fields as $id => $val ) {
897
+ unset( $fields[ $id ] );
898
+ //$id = $this->_layout . '_' . $id;
899
+ $fields[ $id ] = $val;
900
+ }
901
+ $this->layouts[ $this->_layout ]['item_fields'] = $fields;
902
+ }
903
+
904
+ /**
905
+ * Add columns to the table list
906
+ *
907
+ * @param array $columns The columns to add in the table list
908
+ *
909
+ * @return void
910
+ * @since 1.0
911
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
912
+ */
913
+ public function add_table_columns( $columns ) {
914
+ $this->layouts[ $this->_layout ]['columns'] = $columns;
915
+ }
916
+
917
+ /**
918
+ * Enqueue the css files of layout
919
+ *
920
+ * @param string $handle Name of the stylesheet.
921
+ * @param string|bool $src Path to the stylesheet from the root directory of WordPress. Example: '/css/mystyle.css'.
922
+ * @param array $deps An array of registered style handles this stylesheet depends on. Default empty array.
923
+ * @param string|bool $ver String specifying the stylesheet version number, if it has one. This parameter is used
924
+ * to ensure that the correct version is sent to the client regardless of caching, and so
925
+ * should be included if a version number is available and makes sense for the stylesheet.
926
+ * @param string $media Optional. The media for which this stylesheet has been defined.
927
+ * Default 'all'. Accepts 'all', 'aural', 'braille', 'handheld', 'projection', 'print',
928
+ * 'screen', 'tty', or 'tv'.
929
+ *
930
+ * @return void
931
+ * @since 1.0
932
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
933
+ */
934
+ public function enqueue_style( $handle, $src = false, $deps = array(), $ver = false, $media = 'all' ) {
935
+ $this->layouts[ $this->_layout ]['css'][] = compact( 'handle', 'src', 'deps', 'ver', 'media' );
936
+ }
937
+
938
+ /**
939
+ * Enqueue the js files of layout
940
+ *
941
+ * @param string $handle Name of the script.
942
+ * @param string|bool $src Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
943
+ * @param array $deps An array of registered handles this script depends on. Default empty array.
944
+ * @param string|bool $ver Optional. String specifying the script version number, if it has one. This parameter
945
+ * is used to ensure that the correct version is sent to the client regardless of caching,
946
+ * and so should be included if a version number is available and makes sense for the script.
947
+ * @param bool $in_footer Optional. Whether to enqueue the script before </head> or before </body>.
948
+ * Default 'false'. Accepts 'false' or 'true'.
949
+ *
950
+ * @return void
951
+ * @since 1.0
952
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
953
+ */
954
+ public function enqueue_script( $handle, $src = false, $deps = array(), $ver = false, $in_footer = false ) {
955
+ $this->layouts[ $this->_layout ]['js'][] = compact( 'handle', 'src', 'deps', 'ver', 'in_footer' );
956
+ }
957
+
958
+ /**
959
+ * Enqueue the assets for the frontend
960
+ *
961
+ * @return void
962
+ * @since 1.0
963
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
964
+ */
965
+ public function frontend_assets() {
966
+ global $post;
967
+
968
+ // not single
969
+ if ( ! is_single() || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
970
+ $posts = get_posts(array(
971
+ 'post_type' => $this->_name,
972
+ 'posts_per_page' => -1,
973
+ 'post_status' => 'publish',
974
+ 'fields' => 'ids'
975
+ ));
976
+
977
+ $enqueued = array();
978
+
979
+ foreach ( $posts as $post_id ) {
980
+ $layout = get_post_meta( $post_id, $this->_args['layout_option'], true );
981
+
982
+ if ( in_array( $layout, array( $enqueued ) ) || ! isset( $this->layouts[ $layout ]['css'] ) ) {
983
+ continue;
984
+ }
985
+
986
+ foreach ( $this->layouts[ $layout ]['css'] as $asset ) {
987
+ if ( empty( $asset ) ) {
988
+ continue;
989
+ }
990
+ yit_enqueue_style( $asset['handle'], empty( $asset['src'] ) ? false : $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['media'] );
991
+ }
992
+
993
+ $enqueued[] = $layout;
994
+ }
995
+ }
996
+
997
+ // load assets of single template
998
+ else {
999
+ $layout = 'single';
1000
+
1001
+ if ( ! isset( $this->layouts[ $layout ]['css'] ) ) {
1002
+ return;
1003
+ }
1004
+
1005
+ foreach ( $this->layouts[ $layout ]['css'] as $asset ) {
1006
+ if ( empty( $asset ) ) {
1007
+ continue;
1008
+ }
1009
+ yit_enqueue_style( $asset['handle'], $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['media'] );
1010
+ }
1011
+ }
1012
+
1013
+ }
1014
+
1015
+ /**
1016
+ * Register Metaboxes options
1017
+ *
1018
+ * Add the metabox for the portfolio settings
1019
+ *
1020
+ * @return void
1021
+ * @since 1.0
1022
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1023
+ */
1024
+ public function add_metabox_cptu() {
1025
+
1026
+ // Reorganize layouts
1027
+ if ( $this->_args['manage_layouts'] ) {
1028
+ $layouts = array();
1029
+ foreach ( $this->layouts as $layout_id => $layout ) {
1030
+ if ( 'single' == $layout_id ) {
1031
+ continue;
1032
+ }
1033
+ $layouts[ $layout_id ] = $layout['name'];
1034
+ }
1035
+
1036
+ $layouts = apply_filters( 'yit_cptu_' . $this->_name . '_layout_values', $layouts );
1037
+ }
1038
+
1039
+ $single_layouts = apply_filters( 'yit_cptu_' . $this->_name . '_single_layout_values', array() );
1040
+
1041
+ $metabox_args = array(
1042
+ 'label' => sprintf( __( '%s Settings', 'yith-plugin-fw' ), $this->_labels['singular'] ),
1043
+ 'pages' => $this->_name, //or array( 'post-type1', 'post-type2')
1044
+ 'context' => 'normal', //('normal', 'advanced', or 'side')
1045
+ 'priority' => 'default',
1046
+ 'tabs' => array(
1047
+ 'settings' => array(
1048
+ 'label' => __( 'Settings', 'yith-plugin-fw' ),
1049
+ 'fields' => apply_filters( 'yit_cptu_fields', array(
1050
+ 'type' => array(
1051
+ 'label' => __( 'Type', 'yith-plugin-fw' ),
1052
+ 'desc' => sprintf( __( 'Layout for this %s' , 'yith-plugin-fw' ), strtolower( $this->_labels['singular'] ) ),
1053
+ 'type' => 'select',
1054
+ 'options' => isset( $layouts ) ? $layouts : array(),
1055
+ 'std' => '' ),
1056
+
1057
+ 'rewrite' => array(
1058
+ 'label' => __( 'Rewrite', 'yith-plugin-fw' ),
1059
+ 'desc' => __( 'Univocal identification name in the URL for each product (slug from post if empty)', 'yith-plugin-fw' ),
1060
+ 'type' => 'text',
1061
+ 'std' => '' ),
1062
+
1063
+ 'label_singular' => array(
1064
+ 'label' => __( 'Label in Singular', 'yith-plugin-fw' ),
1065
+ 'desc' => __( 'Set a label in singular (title of portfolio if empty)', 'yith-plugin-fw' ),
1066
+ 'type' => 'text',
1067
+ 'std' => '' ),
1068
+
1069
+ 'label_plural' => array(
1070
+ 'label' => __( 'Label in Plural', 'yith-plugin-fw' ),
1071
+ 'desc' => __( 'Set a label in plural (title of portfolio if empty)', 'yith-plugin-fw' ),
1072
+ 'type' => 'text',
1073
+ 'std' => '' ),
1074
+
1075
+ 'taxonomy' => array(
1076
+ 'label' => __( 'Taxonomy', 'yith-plugin-fw' ),
1077
+ 'desc' => __( 'If you want to use categories in the portfolio, set a name for taxonomy. Name should be a slug (must not contain capital letters nor spaces) and must not be more than 32 characters long (database structure restriction).', 'yith-plugin-fw' ),
1078
+ 'type' => 'text',
1079
+ 'std' => '' ),
1080
+
1081
+ 'taxonomy_rewrite' => array(
1082
+ 'label' => __( 'Taxonomy Rewrite', 'yith-plugin-fw' ),
1083
+ 'desc' => __( 'Set univocal name for each category page URL.', 'yith-plugin-fw' ),
1084
+ 'type' => 'text',
1085
+ 'std' => '' ),
1086
+
1087
+ 'single_layout' => array(
1088
+ 'label' => __( 'Single layout', 'yith-plugin-fw' ),
1089
+ 'desc' => __( 'Layout for single page of this portfolio', 'yith-plugin-fw' ),
1090
+ 'type' => 'select',
1091
+ 'options' => $single_layouts,
1092
+ 'std' => '' ),
1093
+ ) )
1094
+ )
1095
+ )
1096
+
1097
+ );
1098
+
1099
+ if ( ! $this->_args['has_single'] ) {
1100
+ unset( $metabox_args['tabs']['settings']['fields']['rewrite'] );
1101
+ }
1102
+
1103
+ if ( ! $this->_args['has_taxonomy'] ) {
1104
+ unset( $metabox_args['tabs']['settings']['fields']['taxonomy'] );
1105
+ unset( $metabox_args['tabs']['settings']['fields']['taxonomy_rewrite'] );
1106
+ }
1107
+
1108
+ if ( ! empty( $this->_args['label_item_sing'] ) ) {
1109
+ unset( $metabox_args['tabs']['settings']['fields']['label_singular'] );
1110
+ }
1111
+
1112
+ if ( ! empty( $this->_args['label_item_plur'] ) ) {
1113
+ unset( $metabox_args['tabs']['settings']['fields']['label_plural'] );
1114
+ }
1115
+
1116
+ if ( $this->_args['manage_layouts'] ) {
1117
+
1118
+ if ( count( $layouts ) < 1 ) {
1119
+ unset( $metabox_args['tabs']['settings']['fields']['type'] );
1120
+ }
1121
+
1122
+ // Layouts options
1123
+ foreach ( $this->layouts as $layout => $args ) {
1124
+ if ( ! isset( $args['fields'] ) ) {
1125
+ continue;
1126
+ }
1127
+
1128
+ // Section title
1129
+ $metabox_args['tabs']['settings']['fields'][ $layout . '_title' ] = array(
1130
+ 'desc' => $args['name'] . ' ' . __( 'layout settings', 'yith-plugin-fw' ),
1131
+ 'type' => 'title',
1132
+ 'deps' => array(
1133
+ 'ids' => '_type',
1134
+ 'values' => $layout
1135
+ )
1136
+ );
1137
+
1138
+ // Options
1139
+ foreach( $args['fields'] as $field_id => $field ) {
1140
+ $metabox_args['tabs']['settings']['fields'][ $field_id ] = $field;
1141
+ $metabox_args['tabs']['settings']['fields'][ $field_id ]['deps'] = array(
1142
+ 'ids' => '_type',
1143
+ 'values' => $layout
1144
+ );
1145
+ }
1146
+ }
1147
+ }else {
1148
+ unset( $metabox_args['tabs']['settings']['fields']['type'] );
1149
+ }
1150
+
1151
+ if( count( $single_layouts ) < 1 ){
1152
+ unset( $metabox_args['tabs']['settings']['fields']['single_layout'] );
1153
+ }
1154
+
1155
+ // undo if tab empty
1156
+ if ( empty( $metabox_args['tabs']['settings']['fields'] ) ) {
1157
+ return;
1158
+ }
1159
+
1160
+ $metabox = YIT_Metabox( $this->_name . '_cptu_settings' );
1161
+ $metabox->init( $metabox_args );
1162
+ }
1163
+
1164
+ /**
1165
+ * Register Metaboxes options
1166
+ *
1167
+ * Add the metabox for the portfolio settings
1168
+ *
1169
+ * @return void
1170
+ * @since 1.0
1171
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1172
+ */
1173
+ public function add_metabox_item_fields() {
1174
+ global $pagenow, $post_type;
1175
+
1176
+ // get the actual post type, to add the metabox only if necessary
1177
+ if ( $pagenow == 'post.php' && isset( $_REQUEST['post'] ) ) {
1178
+ $post_type = get_post_type( intval( $_REQUEST['post'] ) );
1179
+ }
1180
+ elseif( $pagenow == 'post.php' && isset( $_REQUEST['post_ID'] ) ){
1181
+ $post_type = get_post_type( intval( $_REQUEST['post_ID'] ) );
1182
+ }
1183
+ elseif ( $pagenow == 'post-new.php' && isset( $_REQUEST['post_type'] ) ) {
1184
+ $post_type = $_REQUEST['post_type'];
1185
+ } else {
1186
+ return;
1187
+ }
1188
+
1189
+ $layout = get_post_meta( $this->_get_id_by_name( $post_type ), $this->_args['layout_option'], true );
1190
+
1191
+ if ( empty( $this->layouts[ $layout ]['item_fields'] ) ) {
1192
+ return;
1193
+ }
1194
+
1195
+ $metabox_args = array(
1196
+ 'label' => __( 'Settings', 'yith-plugin-fw' ),
1197
+ 'pages' => $post_type, //or array( 'post-type1', 'post-type2')
1198
+ 'context' => 'normal', //('normal', 'advanced', or 'side')
1199
+ 'priority' => 'default',
1200
+ 'tabs' => array(
1201
+ 'settings' => array(
1202
+ 'label' => __( 'Settings', 'yith-plugin-fw' ),
1203
+ 'fields' => $this->layouts[ $layout ]['item_fields']
1204
+ )
1205
+ )
1206
+ );
1207
+
1208
+ $metabox = YIT_Metabox( $post_type . '_item_fields' );
1209
+ $metabox->init( $metabox_args );
1210
+
1211
+ }
1212
+
1213
+ /**
1214
+ * Add quick links inside the editing page of CPTU and Custom Post Types
1215
+ *
1216
+ * @return void
1217
+ * @since 1.0
1218
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1219
+ */
1220
+ public function add_quick_links_metaboxes() {
1221
+ // CPTU
1222
+ add_meta_box( $this->_name . '_quick_links', __( 'Quick links', 'yith-plugin-fw' ), array( $this, 'quick_links_cptu_inner' ), $this->_name, 'side', 'high' );
1223
+
1224
+ // CPTs
1225
+ $args = array(
1226
+ 'post_type' => $this->_name,
1227
+ 'posts_per_page' => -1,
1228
+ 'post_status' => 'publish'
1229
+ );
1230
+ $post_types = get_posts( $args );
1231
+
1232
+ foreach ( $post_types as $post ) {
1233
+ $post_type = get_post_meta( $post->ID, '_post_type', true );
1234
+ extract( $this->_cpt_args( $post ) );
1235
+ add_meta_box( $post->post_type . '_quick_links', __( 'Quick links', 'yith-plugin-fw' ), array( $this, 'quick_links_cpt_inner' ), $post_type, 'side', 'high' );
1236
+ }
1237
+ }
1238
+
1239
+ /**
1240
+ * Link to: "View Items", inside the CPTU
1241
+ *
1242
+ * @param $post
1243
+ *
1244
+ * @return void
1245
+ * @since 1.0
1246
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1247
+ */
1248
+ public function quick_links_cptu_inner( $post ) {
1249
+ extract( $this->_cpt_args( $post ) );
1250
+ ?>
1251
+ <a href="<?php echo admin_url( 'edit.php?post_type=' . get_post_meta( $post->ID, '_post_type', true ) ) ?>"><?php printf( __( 'View %s', 'yith-plugin-fw' ), $label_plural ) ?></a>
1252
+ <?php
1253
+ }
1254
+
1255
+ /**
1256
+ * Link to: "Edit %s", inside the CPTU
1257
+ *
1258
+ * @param $post
1259
+ *
1260
+ * @return void
1261
+ * @since 1.0
1262
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1263
+ */
1264
+ public function quick_links_cpt_inner( $post ) {
1265
+ $post = get_post( $this->_get_id_by_name( $post->post_type ) );
1266
+ ?>
1267
+ <a href="<?php echo admin_url( "post.php?post={$post->ID}&action=edit" ) ?>"><?php printf( __( 'Edit %s', 'yith-plugin-fw' ), $post->post_title ) ?></a>
1268
+ <?php
1269
+ }
1270
+
1271
+ /**
1272
+ * Define the columns to use in the list table of main sliders post type
1273
+ *
1274
+ * @param $columns array The columns used in the list table
1275
+ *
1276
+ * @return array
1277
+ * @since 1.0
1278
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1279
+ */
1280
+ public function cptu_define_columns( $columns ) {
1281
+ unset( $columns['date'] );
1282
+
1283
+ $columns['actions'] = '';
1284
+
1285
+ return $columns;
1286
+ }
1287
+
1288
+ /**
1289
+ * Change the content of each column of the table list
1290
+ *
1291
+ * @param $column string The current column
1292
+ * @param $post_id int The current post ID
1293
+ *
1294
+ * @return void
1295
+ * @since 1.0
1296
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1297
+ */
1298
+ public function cptu_change_columns( $column, $post_id ) {
1299
+ $post = get_post( $post_id );
1300
+ extract( $this->_cpt_args( $post ) );
1301
+
1302
+ switch ( $column ) {
1303
+ case 'actions' :
1304
+ echo '<a href="' . admin_url( "post.php?post={$post_id}&action=edit" ) . '" class="button-secondary">' . sprintf( __( 'Edit %s', 'yith-plugin-fw' ), ucfirst( $this->_labels['singular'] ) ) . '</a> ';
1305
+ echo '<a href="' . admin_url( 'edit.php?post_type=' . get_post_meta( $post_id, '_post_type', true ) ) . '" class="button-secondary">' . sprintf( __( 'View %s', 'yith-plugin-fw' ), $label_plural ) . '</a> ';
1306
+ break;
1307
+ }
1308
+ }
1309
+
1310
+ /**
1311
+ * Retrieve the path of layout specified in parameter
1312
+ *
1313
+ * @param $layout
1314
+ * @param $file string The file to find
1315
+ *
1316
+ * @return bool|string
1317
+ * @since 1.0
1318
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1319
+ */
1320
+ public function locate_file( $layout, $file = '' ) {
1321
+ if ( ! $this->_args['manage_layouts'] ) {
1322
+ return $this->template_path(). '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1323
+ }
1324
+
1325
+ if ( ! isset( $this->layouts[ $layout ] ) ) {
1326
+ $layout = 'default';
1327
+ }
1328
+
1329
+ return $this->layouts[ $layout ]['path'] . '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1330
+ }
1331
+
1332
+ /**
1333
+ * Retrieve the URL of layout specified in parameter
1334
+ *
1335
+ * @param $layout
1336
+ * @param $file string The file to find
1337
+ *
1338
+ * @return bool|string
1339
+ * @since 1.0
1340
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1341
+ */
1342
+ public function locate_url( $layout, $file = '' ) {
1343
+ if ( ! $this->_args['manage_layouts'] ) {
1344
+ return $this->template_url();
1345
+
1346
+ }
1347
+
1348
+ if ( ! isset( $this->layouts[ $layout ] ) ) {
1349
+ $layout = 'default';
1350
+ }
1351
+
1352
+ return $this->layouts[ $layout ]['url'] . '/' . ( ! empty( $file ) ? $file . '.php' : '' );
1353
+ }
1354
+
1355
+ /**
1356
+ * Retrieve the post ID relative to the post of post type
1357
+ *
1358
+ * @param $name string
1359
+ *
1360
+ * @return mixed
1361
+ * @since 1.0
1362
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1363
+ */
1364
+ protected function _get_id_by_name( $name ) {
1365
+ global $wpdb;
1366
+ return $wpdb->get_var( $wpdb->prepare( "SELECT pm.post_id FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $name, $this->_name ) );
1367
+ }
1368
+
1369
+ /**
1370
+ * Retrieve the post_type of portfolio by portfolio name
1371
+ *
1372
+ * @param $name string
1373
+ *
1374
+ * @return mixed
1375
+ * @since 1.0
1376
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1377
+ */
1378
+ protected function _get_post_type_by_name( $name ) {
1379
+ global $wpdb;
1380
+ return $wpdb->get_var( $wpdb->prepare( "SELECT pm.meta_value FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND p.post_name = %s AND p.post_type = %s", '_post_type', $name, $this->_name ) );
1381
+ }
1382
+
1383
+ /**
1384
+ * The shortcode used to show the frontend
1385
+ *
1386
+ * @param array $atts
1387
+ * @param null $content
1388
+ *
1389
+ * @return string|null
1390
+ * @since 1.0
1391
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1392
+ */
1393
+ public function add_shortcode( $atts, $content = null ) {
1394
+ $atts = wp_parse_args( $atts, array(
1395
+ 'name' => null,
1396
+ 'cat' => array(),
1397
+ 'posts_per_page' => false,
1398
+ 'style' => null,
1399
+ ) );
1400
+
1401
+ // don't show the slider if 'name' is empty or is 'none'
1402
+ if ( empty( $atts['name'] ) || 'none' == $atts['name'] ) return null;
1403
+
1404
+ // compatibility fix: remove prefix if exists in portfolio object
1405
+ if( function_exists( 'YIT_Portfolio' ) && method_exists( YIT_Portfolio(), 'is' ) && YIT_Portfolio()->is( $atts['name'] ) ){
1406
+ $atts['name'] = str_replace( YIT_Portfolio()->post_type_prefix, '', $atts['name'] );
1407
+ }
1408
+
1409
+ // pass vars to template
1410
+ $atts['post_type'] = $this->_get_post_type_by_name( $atts['name'] );
1411
+ $atts['layout'] = $this->_args['manage_layouts'] ? get_post_meta( $this->_get_id_by_name( $atts['post_type'] ), $this->_args['layout_option'], true ) : '';
1412
+ extract( apply_filters( 'yit_cptu_frontend_vars', $atts, $this->_name ) );
1413
+
1414
+ // add the javascript assets
1415
+ if ( $this->_args['manage_layouts'] && isset( $this->layouts[ $layout ]['js'] ) && ! empty( $this->layouts[ $layout ]['js'] ) ) {
1416
+ foreach ( $this->layouts[ $layout ]['js'] as $asset ) {
1417
+ if ( empty( $asset ) ) continue;
1418
+
1419
+ if ( empty( $asset['src'] ) ) {
1420
+ wp_enqueue_script( $asset['handle'] );
1421
+ continue;
1422
+ }
1423
+
1424
+ yit_enqueue_script( $asset['handle'], $this->locate_url( $layout ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['in_footer'] );
1425
+ }
1426
+ }
1427
+
1428
+ // Unique sequential index to differentiate more cpt in the same page
1429
+ ++$this->index;
1430
+
1431
+ ob_start();
1432
+
1433
+ include( $this->locate_file( $layout, 'markup' ) );
1434
+
1435
+ return ob_get_clean();
1436
+
1437
+ }
1438
+
1439
+ /**
1440
+ * Shortcode icon
1441
+ *
1442
+ * Return the shortcode icone to display on shortcode panel
1443
+ *
1444
+ * @param $icon_url string Icone url found by yit_shortcode plugin
1445
+ *
1446
+ * @return string
1447
+ * @since 1.0.0
1448
+ * @author Antonino Scarfi' <antonio.scarfi@yithemes.it>
1449
+ */
1450
+ public function shortcode_icon( $icon_url ) {
1451
+ return ! empty( $this->_args['shortcode_icon'] ) ? $this->_args['shortcode_icon'] : $icon_url;
1452
+ }
1453
+
1454
+ /**
1455
+ * Return an array with cptu options to shortcode panel
1456
+ *
1457
+ * All definition settings to add cptu shortcode to Yit Shortcode Panel
1458
+ *
1459
+ * @param array $shortcodes
1460
+ *
1461
+ * @return array
1462
+ * @since 1.0
1463
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1464
+ */
1465
+ public function add_shortcode_to_box( $shortcodes ) {
1466
+ $post_types = array();
1467
+
1468
+ foreach ( $this->get_post_types() as $post ) {
1469
+ $post_types[ $post->post_name ] = $post->post_title;
1470
+ }
1471
+
1472
+ $args = array(
1473
+ $this->_args['shortcode_name'] => array(
1474
+ 'title' => $this->_labels['singular'],
1475
+ 'description' => sprintf( __( 'Show frontend of the %s', 'yith-plugin-fw' ), $this->_labels['main_name'] ),
1476
+ 'tab' => 'cpt',
1477
+ 'create' => false,
1478
+ 'has_content' => false,
1479
+ 'in_visual_composer' => true,
1480
+ 'attributes' => array(
1481
+ 'name' => array(
1482
+ 'title' => __( 'Name', 'yith-plugin-fw' ),
1483
+ 'type' => 'select',
1484
+ 'options' => $post_types,
1485
+ 'std' => ''
1486
+ ),
1487
+ )
1488
+ )
1489
+ );
1490
+
1491
+ return array_merge( $shortcodes, $args );
1492
+ }
1493
+
1494
+ /**
1495
+ * Check the post type passed in parameter, if is generated by this CPTU
1496
+ *
1497
+ * @param $post_type string The post type to check
1498
+ *
1499
+ * @return bool
1500
+ * @since 1.0
1501
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1502
+ */
1503
+ protected function _is_valid( $post_type ) {
1504
+ return (bool)( strpos( $post_type, $this->_args['post_type_prefix'] ) !== false );
1505
+ }
1506
+
1507
+ /**
1508
+ * Add as a valid post type all cptu when importing dummy data
1509
+ *
1510
+ * @param $post array The post object
1511
+ *
1512
+ * @return array
1513
+ * @since 1.0
1514
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1515
+ */
1516
+ public function add_importer_required_post_type( $post ){
1517
+ global $wp_post_types, $wp_taxonomies;
1518
+
1519
+ if( strpos( $post['post_type'], $this->_prefix_cpt ) === FALSE ){
1520
+ return $post;
1521
+ }
1522
+
1523
+ if( ! isset( $wp_post_types[ $post['post_type'] ] ) ){
1524
+ $wp_post_types[ $post['post_type'] ] = array(
1525
+ 'name' => ''
1526
+ );
1527
+ }
1528
+
1529
+ if( ! empty( $post['terms'] ) ){
1530
+ foreach( $post['terms'] as $term ){
1531
+ if( ! isset( $wp_taxonomies[ $term['domain'] ] ) ){
1532
+ $wp_taxonomies[ $term['domain'] ] = array(
1533
+ 'name' => ''
1534
+ );
1535
+ }
1536
+ }
1537
+ }
1538
+
1539
+
1540
+ return $post;
1541
+ }
1542
+
1543
+ /**
1544
+ * Add taxonomy when importing dummy data
1545
+ *
1546
+ * @param $terms array Array of terms
1547
+ *
1548
+ * @return array
1549
+ * @since 1.0
1550
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1551
+ */
1552
+ public function add_importer_required_taxonomy( $terms ){
1553
+ global $wp_taxonomies;
1554
+
1555
+ if( ! empty( $terms ) ){
1556
+ foreach ( $terms as $term ) {
1557
+ if( isset( $term['domain'] ) && ! isset( $wp_taxonomies[ $term['domain'] ] ) ){
1558
+ $wp_taxonomies[ $term['domain'] ] = array(
1559
+ 'name' => ''
1560
+ );
1561
+ }
1562
+ }
1563
+ }
1564
+
1565
+ return $terms;
1566
+ }
1567
+
1568
+ /**
1569
+ * Force terms recount for imported taxonomy
1570
+ *
1571
+ * @param $tt_ids array Terms ids
1572
+ * @param $ids array Post ids
1573
+ * @param $tax string Taxonomy name
1574
+ *
1575
+ * @return void
1576
+ * @since 1.0
1577
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
1578
+ */
1579
+ public function recount_terms_post( $tt_ids, $ids, $tax ){
1580
+ wp_update_term_count( $tt_ids, $tax );
1581
+ }
1582
+
1583
+ // ### ASSETS ###
1584
+
1585
+ /**
1586
+ * Enqueue the assets for the admin
1587
+ *
1588
+ * @return void
1589
+ * @since 1.0
1590
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1591
+ */
1592
+ public function admin_assets() {
1593
+ wp_enqueue_media();
1594
+ wp_enqueue_script( 'yit-cptu', YIT_CORE_PLUGIN_URL . '/assets/js/yit-cpt-unlimited.js', array('jquery'), '', true );
1595
+ }
1596
+
1597
+ /**
1598
+ * Add the button to the top of the list table page of CPTU
1599
+ *
1600
+ * @return void
1601
+ * @since 1.0
1602
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1603
+ */
1604
+ public function add_button_multiuploader() {
1605
+ global $pagenow, $post_type, $wpdb;
1606
+
1607
+ if( $pagenow != 'edit.php' ){
1608
+ return;
1609
+ }
1610
+
1611
+ $cptu = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_type FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s", '_post_type', $post_type ) );
1612
+
1613
+ $post = get_post( $this->_get_id_by_name( $post_type ) );
1614
+ if ( empty( $post ) ) {
1615
+ return;
1616
+ }
1617
+ extract( $this->_cpt_args( $post ) );
1618
+
1619
+ if ( $cptu != $this->_name || ! $this->_is_valid( $post_type ) ) {
1620
+ return;
1621
+ }
1622
+ ?>
1623
+ <script>
1624
+ (function($) {
1625
+ "use strict";
1626
+ // Author code here
1627
+
1628
+ var button = $('<a />', {
1629
+ href: '#',
1630
+ class: 'multi-uploader add-new-h2',
1631
+ 'data-uploader_title': '<?php printf( __( 'Add %s from images', 'yith-plugin-fw' ), $label_plural ) ?>',
1632
+ 'data-uploader_button_text': '<?php printf( __( 'Add %s', 'yith-plugin-fw' ), $label_plural ) ?>'
1633
+ }).text('<?php _e( 'Upload multiple files', 'yith-plugin-fw' ) ?>');
1634
+
1635
+ var spinner = $('<span />', {
1636
+ class: 'spinner',
1637
+ style: 'float: none;'
1638
+ });
1639
+
1640
+ button.appendTo('.wrap h2, .wrap h1').after(spinner);
1641
+
1642
+ })(jQuery);
1643
+ </script>
1644
+ <?php
1645
+ }
1646
+
1647
+ /**
1648
+ * Add more posts by multiupload
1649
+ *
1650
+ * @return void
1651
+ * @since 1.0
1652
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1653
+ */
1654
+ public function post_multiuploader() {
1655
+ if ( ! isset( $_REQUEST['images'] ) || ! isset( $_REQUEST['post_type'] ) && $this->_is_valid( $_REQUEST['post_type'] ) ) {
1656
+ return;
1657
+ }
1658
+
1659
+ foreach ( $_REQUEST['images'] as $the ) {
1660
+
1661
+ // Create post object
1662
+ $arg = array(
1663
+ 'post_title' => $the['title'],
1664
+ 'post_type' => $_REQUEST['post_type']
1665
+ );
1666
+ $post_id = wp_insert_post( $arg );
1667
+
1668
+ set_post_thumbnail( $post_id, $the['id'] );
1669
+
1670
+ }
1671
+
1672
+ die();
1673
+ }
1674
+
1675
+
1676
+ // ###### SINGLE TEMPLATE ######
1677
+
1678
+ /**
1679
+ * Load the single template file
1680
+ *
1681
+ * @return void
1682
+ * @since 1.0
1683
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1684
+ */
1685
+ public function single_template() {
1686
+ global $post, $wpdb;
1687
+
1688
+ // if ( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ) {
1689
+ // $post = get_post( $_REQUEST['post_id'] );
1690
+ // }
1691
+
1692
+ if ( ( ( ! defined('DOING_AJAX') || ! DOING_AJAX ) && ! is_single() ) || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
1693
+ return;
1694
+ }
1695
+
1696
+ // add the javascript assets
1697
+ if ( $this->_args['manage_layouts'] ) {
1698
+ foreach ( $this->layouts[ 'single' ]['js'] as $asset ) {
1699
+ yit_enqueue_script( $asset['handle'], $this->locate_url( 'single' ) . $asset['src'], $asset['deps'], $asset['ver'], $asset['in_footer'] );
1700
+ }
1701
+ }
1702
+
1703
+ $post_name = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post->post_type, $this->_name ) );
1704
+ extract( apply_filters( 'yit_cptu_frontend_vars', array( 'name' => $post_name ), $this->_name ) );
1705
+
1706
+ include( $this->locate_file( 'single', 'markup' ) );
1707
+ }
1708
+
1709
+ /**
1710
+ * Load a file for the configuration of single template page of portfolio
1711
+ *
1712
+ * @return void
1713
+ * @since 1.0
1714
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1715
+ */
1716
+ public function single_template_config() {
1717
+ global $post, $wpdb;
1718
+
1719
+ if ( defined('DOING_AJAX') && DOING_AJAX && isset( $_REQUEST['post_id'] ) ) {
1720
+ $post = get_post( $_REQUEST['post_id'] );
1721
+ }
1722
+
1723
+ if ( ( ( ! defined('DOING_AJAX') || ! DOING_AJAX ) && ! is_single() ) || ! isset( $post->post_type ) || ! $this->_is_valid( $post->post_type ) ) {
1724
+ return;
1725
+ }
1726
+
1727
+ $this->_layout = 'single';
1728
+ $path = $this->locate_file( 'single', 'config' );
1729
+
1730
+ if ( file_exists( $path ) ) {
1731
+ $post_name = $wpdb->get_var( $wpdb->prepare( "SELECT p.post_name FROM $wpdb->postmeta AS pm INNER JOIN $wpdb->posts AS p ON p.ID = pm.post_id WHERE pm.meta_key = %s AND pm.meta_value = %s AND p.post_type = %s", '_post_type', $post->post_type, $this->_name ) );
1732
+ extract( apply_filters( 'yit_cptu_frontend_vars', array( 'name' => $post_name ), $this->_name ) );
1733
+
1734
+ include( $path );
1735
+ }
1736
+ }
1737
+
1738
+
1739
+ // ########################## ARCHIVE TEMPLATE ###############################
1740
+
1741
+
1742
+ /**
1743
+ * Load the template for archive page
1744
+ *
1745
+ * @return void
1746
+ * @since 1.0
1747
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1748
+ */
1749
+ public function archive_template() {
1750
+ global $wp_query;
1751
+
1752
+
1753
+ // check if we are in archive template
1754
+ if ( !( ! is_admin() && is_archive() && isset($wp_query->post) && $this->_is_valid( $wp_query->post->post_type ) ) ) {
1755
+ return;
1756
+ }
1757
+
1758
+ // remove the action from loop of theme
1759
+ remove_action( 'yit_content_loop', 'yit_content_loop', 10 );
1760
+ add_action( 'yit_content_loop', array( $this, 'archive_template_loop' ), 10 );
1761
+
1762
+ }
1763
+
1764
+ /**
1765
+ * Load loop for the archive template
1766
+ *
1767
+ * @return void
1768
+ * @since 1.0
1769
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
1770
+ */
1771
+ public function archive_template_loop() {
1772
+ echo $this->add_shortcode( array( 'name' => $GLOBALS['wp_query']->post->post_type ) );
1773
+ }
1774
+
1775
  }
plugin-fw/lib/yit-metabox.php CHANGED
@@ -1,549 +1,549 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
-
12
- if (!defined('ABSPATH')) {
13
- exit;
14
- } // Exit if accessed directly
15
-
16
- if (!class_exists('YIT_Metabox')) {
17
- /**
18
- * YIT Metabox
19
- *
20
- * the metabox can be created using this code
21
- * <code>
22
- * $args1 = array(
23
- * 'label' => __( 'Metabox Label', 'yith-plugin-fw' ),
24
- * 'pages' => 'page', //or array( 'post-type1', 'post-type2')
25
- * 'context' => 'normal', //('normal', 'advanced', or 'side')
26
- * 'priority' => 'default',
27
- * 'tabs' => array(
28
- * 'settings' => array( //tab
29
- * 'label' => __( 'Settings', 'yith-plugin-fw' ),
30
- * 'fields' => array(
31
- * 'meta_checkbox' => array(
32
- * 'label' => __( 'Show title', 'yith-plugin-fw' ),
33
- * 'desc' => __( 'Choose whether to show title of the page or not.', 'yith-plugin-fw' ),
34
- * 'type' => 'checkbox',
35
- * 'private' => false,
36
- * 'std' => '1'),
37
- * ),
38
- * ),
39
- * );
40
- *
41
- * $metabox1 = YIT_Metabox( 'yit-metabox-id' );
42
- * $metabox1->init( $args );
43
- * </code>
44
- *
45
- * @class YIT_Metaboxes
46
- * @package Yithemes
47
- * @since 1.0.0
48
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
49
- *
50
- */
51
- class YIT_Metabox
52
- {
53
-
54
- /**
55
- * @var string the id of metabox
56
- *
57
- * @since 1.0
58
- */
59
-
60
- public $id;
61
-
62
- /**
63
- * @var array An array where are saved all metabox settings options
64
- *
65
- * @since 1.0
66
- */
67
- private $options = array();
68
-
69
- /**
70
- * @var array An array where are saved all tabs of metabox
71
- *
72
- * @since 1.0
73
- */
74
- private $tabs = array();
75
-
76
- /**
77
- * @var object The single instance of the class
78
- * @since 1.0
79
- */
80
- protected static $_instance = array();
81
-
82
- /**
83
- * Main Instance
84
- *
85
- * @static
86
- *
87
- * @param $id
88
- *
89
- * @return object Main instance
90
- *
91
- * @since 1.0
92
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
93
- */
94
- public static function instance($id)
95
- {
96
- if (!isset(self::$_instance[$id])) {
97
- self::$_instance[$id] = new self($id);
98
- }
99
- return self::$_instance[$id];
100
- }
101
-
102
- /**
103
- * Constructor
104
- *
105
- * @param string $id
106
- *
107
- * @return \YIT_Metabox
108
- * @since 1.0
109
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
110
- */
111
- function __construct($id = '')
112
- {
113
- $this->id = $id;
114
-
115
- }
116
-
117
-
118
- /**
119
- * Init
120
- *
121
- * set options and tabs, add actions to register metabox, scripts and save data
122
- *
123
- * @param array $options
124
- *
125
- * @return void
126
- * @since 1.0
127
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
128
- */
129
- public function init($options = array())
130
- {
131
-
132
- $this->set_options($options);
133
- $this->set_tabs();
134
-
135
-
136
- add_action('add_meta_boxes', array($this, 'register_metabox'));
137
- add_action('save_post', array($this, 'save_postdata'));
138
- add_action('admin_enqueue_scripts', array($this, 'enqueue'), 15);
139
-
140
- }
141
-
142
- /**
143
- * Enqueue script and styles in admin side
144
- *
145
- * Add style and scripts to administrator
146
- *
147
- * @return void
148
- * @since 1.0
149
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
150
- */
151
- public function enqueue()
152
- {
153
-
154
- wp_enqueue_media();
155
- wp_enqueue_style('wp-color-picker');
156
- wp_enqueue_style('yit-plugin-metaboxes', YIT_CORE_PLUGIN_URL . '/assets/css/metaboxes.css');
157
- wp_enqueue_style('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css');
158
- wp_enqueue_script('jquery-ui-datepicker');
159
- wp_enqueue_script('yit-spinner', YIT_CORE_PLUGIN_URL . '/assets/js/panel.spinner.js', array('jquery'), '0.0.1', true);
160
- wp_enqueue_script('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array('jquery'), '1.1.0', true);
161
- wp_enqueue_script('ajax-chosen', yit_load_js_file(YIT_CORE_PLUGIN_URL . '/assets/js/chosen/ajax-chosen.jquery.js'), array('jquery'), '1.1.0', true);
162
- wp_enqueue_script('yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox.js', array('jquery', 'wp-color-picker'), '1.0.0', true);
163
- wp_enqueue_style('jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-custom/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all');
164
- }
165
-
166
- /**
167
- * Set Options
168
- *
169
- * Set the variable options
170
- *
171
- * @param array $options
172
- *
173
- * @return void
174
- * @since 1.0
175
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
176
- */
177
- public function set_options($options = array())
178
- {
179
- $this->options = $options;
180
-
181
- }
182
-
183
- /**
184
- * Set Tabs
185
- *
186
- * Set the variable tabs
187
- *
188
- * @internal param array $tabs
189
- *
190
- * @return void
191
- * @since 1.0
192
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
193
- */
194
- public function set_tabs()
195
- {
196
- if (!isset($this->options['tabs'])) {
197
- return;
198
- }
199
- $this->tabs = $this->options['tabs'];
200
- if (isset($this->tabs['settings']['fields'])) {
201
- $this->tabs['settings']['fields'] = array_filter($this->tabs['settings']['fields']);
202
- }
203
- }
204
-
205
-
206
- /**
207
- * Add Tab
208
- *
209
- * Add a tab inside the metabox
210
- *
211
- * @internal param array $tabs
212
- *
213
- * @param array $tab the new tab to add to the metabox
214
- * @param string $where tell where insert the tab if after or before a $refer
215
- * @param null $refer an existent tab inside metabox
216
- *
217
- * @return void
218
- * @since 1.0
219
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
220
- */
221
- public function add_tab($tab, $where = 'after', $refer = null)
222
- {
223
- if (!is_null($refer)) {
224
- $ref_pos = array_search($refer, array_keys($this->tabs));
225
- if ($ref_pos !== false) {
226
- if ($where == 'after') {
227
- $this->tabs = array_slice($this->tabs, 0, $ref_pos + 1, true) +
228
- $tab +
229
- array_slice($this->tabs, $ref_pos + 1, count($this->tabs) - 1, true);
230
- } else {
231
- $this->tabs = array_slice($this->tabs, 0, $ref_pos, true) +
232
- $tab +
233
- array_slice($this->tabs, $ref_pos, count($this->tabs), true);
234
- }
235
- }
236
- } else {
237
- $this->tabs = array_merge($tab, $this->tabs);
238
- }
239
-
240
- }
241
-
242
- /**
243
- * Remove Tab
244
- *
245
- * Remove a tab from the tabs of metabox
246
- *
247
- * @internal param array $tabs
248
- *
249
- * @param $id_tab
250
- *
251
- * @return void
252
- * @since 1.0
253
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
254
- */
255
- public function remove_tab($id_tab)
256
- {
257
- if (isset($this->tabs[$id_tab])) {
258
- unset ($this->tabs[$id_tab]);
259
- }
260
- }
261
-
262
-
263
- /**
264
- * Add Field
265
- *
266
- * Add a field inside a tab of metabox
267
- *
268
- * @internal param array $tabs
269
- *
270
- * @param string $tab_id the id of the tabs where add the field
271
- * @param array $args the field to add
272
- * @param string $where tell where insert the field if after or before a $refer
273
- * @param null $refer an existent field inside tab
274
- *
275
- * @return void
276
- * @since 1.0
277
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
278
- */
279
- public function add_field($tab_id, $args, $where = 'after', $refer = null)
280
- {
281
- if (isset($this->tabs[$tab_id])) {
282
-
283
- $cf = $this->tabs[$tab_id]['fields'];
284
- if (!is_null($refer)) {
285
- $ref_pos = array_search($refer, array_keys($cf));
286
- if ($ref_pos !== false) {
287
- if ($where == 'after') {
288
- $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos + 1, true) +
289
- $args +
290
- array_slice($cf, $ref_pos, count($cf) - 1, true);
291
-
292
- } elseif ($where == 'before') {
293
- $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos, true) +
294
- $args +
295
- array_slice($cf, $ref_pos, count($cf), true);
296
-
297
- }
298
- }
299
- } else {
300
- if ($where == 'first') {
301
- $this->tabs[$tab_id]['fields'] = $args + $cf;
302
-
303
- } else {
304
- $this->tabs[$tab_id]['fields'] = array_merge($this->tabs[$tab_id]['fields'], $args);
305
- }
306
- }
307
-
308
- }
309
-
310
-
311
- }
312
-
313
- /**
314
- * Remove Field
315
- *
316
- * Remove a field from the metabox, search inside the tabs and remove it if exists
317
- *
318
- * @param $id_field
319
- *
320
- * @return void
321
- * @since 1.0
322
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
323
- */
324
- public function remove_field($id_field)
325
- {
326
- foreach ($this->tabs as $tab_name => $tab) {
327
- if (isset($tab['fields'][$id_field])) {
328
- unset ($this->tabs[$tab_name]['fields'][$id_field]);
329
- }
330
- }
331
- }
332
-
333
- /**
334
- * Reorder tabs
335
- *
336
- * Order the tabs and fields and set id and name to each field
337
- *
338
- * @internal param $id_field
339
- *
340
- * @return void
341
- * @since 1.0
342
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
343
- */
344
- public function reorder_tabs()
345
- {
346
- foreach ($this->tabs as $tab_name => $tab) {
347
- foreach ($tab['fields'] as $id_field => $field) {
348
- $this->tabs[$tab_name]['fields'][$id_field]['private'] = (isset($field['private'])) ? $field['private'] : true;
349
- $this->tabs[$tab_name]['fields'][$id_field]['id'] = $this->get_option_metabox_id($id_field, $this->tabs[$tab_name]['fields'][$id_field]['private']);
350
- $this->tabs[$tab_name]['fields'][$id_field]['name'] = $this->get_option_metabox_name($this->tabs[$tab_name]['fields'][$id_field]['id']);
351
- }
352
- }
353
-
354
- }
355
-
356
-
357
- /**
358
- * Get Option Metabox ID
359
- *
360
- * return the id of the field
361
- *
362
- * @param string $id_field
363
- * @param bool $private if private add an _befor the id
364
- *
365
- * @return string
366
- * @since 1.0
367
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
368
- */
369
- public function get_option_metabox_id($id_field, $private = true)
370
- {
371
- if ($private) {
372
- return '_' . $id_field;
373
- } else {
374
- return $id_field;
375
- }
376
- }
377
-
378
- /**
379
- * Get Option Metabox Name
380
- *
381
- * return the name of the field, this name will be used as attribute name of the input field
382
- *
383
- * @param string $id_field
384
- * @param bool $private if private add an _befor the id
385
- *
386
- * @return string
387
- * @since 1.0
388
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
389
- */
390
- public function get_option_metabox_name($id_field, $private = true)
391
- {
392
- $db_name = apply_filters('yit_metaboxes_option_main_name', 'yit_metaboxes');
393
- $return = $db_name . '[';
394
-
395
- if (!strpos($id_field, '[')) {
396
- return $return . $id_field . ']';
397
- }
398
- $return .= substr($id_field, 0, strpos($id_field, '['));
399
- $return .= ']';
400
- $return .= substr($id_field, strpos($id_field, '['));
401
-
402
- return $return;
403
- }
404
-
405
- /**
406
- * Register the metabox
407
- *
408
- * call the wp function add_metabox to add the metabox
409
- *
410
- *
411
- * @return void
412
- * @since 1.0
413
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
414
- */
415
- public function register_metabox($post_type)
416
- {
417
- if (in_array($post_type, (array)$this->options['pages'])) {
418
- add_meta_box($this->id, $this->options['label'], array($this, 'show'), $post_type, $this->options['context'], $this->options['priority']);
419
- }
420
- }
421
-
422
- /**
423
- * Show metabox
424
- *
425
- * show the html of metabox
426
- *
427
- *
428
- * @return void
429
- * @since 1.0
430
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
431
- */
432
- public function show()
433
- {
434
- $this->reorder_tabs();
435
-
436
- yit_plugin_get_template(YIT_CORE_PLUGIN_PATH, 'metaboxes/tab.php', array('tabs' => $this->tabs));
437
- }
438
-
439
- /**
440
- * Save Post Data
441
- *
442
- * Save the post data in the database when save the post
443
- *
444
- * @param $post_id
445
- *
446
- * @return int
447
- * @since 1.0
448
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
449
- */
450
- public function save_postdata($post_id)
451
- {
452
-
453
-
454
- if (!isset($_POST['yit_metaboxes_nonce']) || !wp_verify_nonce($_POST['yit_metaboxes_nonce'], 'metaboxes-fields-nonce')) {
455
- return $post_id;
456
- }
457
-
458
-
459
- if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX)) {
460
- return $post_id;
461
- }
462
-
463
- if (isset($_POST['post_type'])) {
464
- $post_type = $_POST['post_type'];
465
- } else {
466
- return $post_id;
467
- }
468
-
469
- if ('page' == $post_type) {
470
- if (!current_user_can('edit_page', $post_id)) {
471
- return $post_id;
472
- }
473
- } else {
474
- if (!current_user_can('edit_post', $post_id)) {
475
- return $post_id;
476
- }
477
- }
478
-
479
- if (!in_array($post_type, (array)$this->options['pages'])) {
480
- return $post_id;
481
- }
482
-
483
- $this->reorder_tabs();
484
-
485
-
486
- foreach ($this->tabs as $tab) {
487
-
488
- foreach ($tab['fields'] as $field) {
489
-
490
- if (in_array($field['type'], array('title'))) {
491
- continue;
492
- }
493
-
494
- if (isset($_POST['yit_metaboxes'][$field['id']])) {
495
-
496
- add_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']], true) || update_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']]);
497
- } elseif (in_array($field['type'], array('onoff', 'checkbox'))) {
498
- update_post_meta($post_id, $field['id'], '0');
499
- } else {
500
- delete_post_meta($post_id, $field['id']);
501
- }
502
- }
503
- }
504
-
505
-
506
- }
507
-
508
- /**
509
- * Remove Fields
510
- *
511
- * Remove a fields list from the metabox, search inside the tabs and remove it if exists
512
- *
513
- * @param $id_fields
514
- *
515
- * @return void
516
- * @since 2.0.0
517
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
518
- */
519
- public function remove_fields($id_fields)
520
- {
521
- foreach ($id_fields as $k => $field) {
522
- $this->remove_field($field);
523
- }
524
- }
525
- }
526
- }
527
-
528
- if (!function_exists('YIT_Metabox')) {
529
-
530
- /**
531
- * Main instance of plugin
532
- *
533
- * @param $id
534
- *
535
- * @return \YIT_Metabox
536
- * @since 1.0
537
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
538
- */
539
-
540
-
541
- function YIT_Metabox($id)
542
- {
543
- return YIT_Metabox::instance($id);
544
- }
545
- }
546
-
547
-
548
-
549
-
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+
12
+ if (!defined('ABSPATH')) {
13
+ exit;
14
+ } // Exit if accessed directly
15
+
16
+ if (!class_exists('YIT_Metabox')) {
17
+ /**
18
+ * YIT Metabox
19
+ *
20
+ * the metabox can be created using this code
21
+ * <code>
22
+ * $args1 = array(
23
+ * 'label' => __( 'Metabox Label', 'yith-plugin-fw' ),
24
+ * 'pages' => 'page', //or array( 'post-type1', 'post-type2')
25
+ * 'context' => 'normal', //('normal', 'advanced', or 'side')
26
+ * 'priority' => 'default',
27
+ * 'tabs' => array(
28
+ * 'settings' => array( //tab
29
+ * 'label' => __( 'Settings', 'yith-plugin-fw' ),
30
+ * 'fields' => array(
31
+ * 'meta_checkbox' => array(
32
+ * 'label' => __( 'Show title', 'yith-plugin-fw' ),
33
+ * 'desc' => __( 'Choose whether to show title of the page or not.', 'yith-plugin-fw' ),
34
+ * 'type' => 'checkbox',
35
+ * 'private' => false,
36
+ * 'std' => '1'),
37
+ * ),
38
+ * ),
39
+ * );
40
+ *
41
+ * $metabox1 = YIT_Metabox( 'yit-metabox-id' );
42
+ * $metabox1->init( $args );
43
+ * </code>
44
+ *
45
+ * @class YIT_Metaboxes
46
+ * @package Yithemes
47
+ * @since 1.0.0
48
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
49
+ *
50
+ */
51
+ class YIT_Metabox
52
+ {
53
+
54
+ /**
55
+ * @var string the id of metabox
56
+ *
57
+ * @since 1.0
58
+ */
59
+
60
+ public $id;
61
+
62
+ /**
63
+ * @var array An array where are saved all metabox settings options
64
+ *
65
+ * @since 1.0
66
+ */
67
+ private $options = array();
68
+
69
+ /**
70
+ * @var array An array where are saved all tabs of metabox
71
+ *
72
+ * @since 1.0
73
+ */
74
+ private $tabs = array();
75
+
76
+ /**
77
+ * @var object The single instance of the class
78
+ * @since 1.0
79
+ */
80
+ protected static $_instance = array();
81
+
82
+ /**
83
+ * Main Instance
84
+ *
85
+ * @static
86
+ *
87
+ * @param $id
88
+ *
89
+ * @return object Main instance
90
+ *
91
+ * @since 1.0
92
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
93
+ */
94
+ public static function instance($id)
95
+ {
96
+ if (!isset(self::$_instance[$id])) {
97
+ self::$_instance[$id] = new self($id);
98
+ }
99
+ return self::$_instance[$id];
100
+ }
101
+
102
+ /**
103
+ * Constructor
104
+ *
105
+ * @param string $id
106
+ *
107
+ * @return \YIT_Metabox
108
+ * @since 1.0
109
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
110
+ */
111
+ function __construct($id = '')
112
+ {
113
+ $this->id = $id;
114
+
115
+ }
116
+
117
+
118
+ /**
119
+ * Init
120
+ *
121
+ * set options and tabs, add actions to register metabox, scripts and save data
122
+ *
123
+ * @param array $options
124
+ *
125
+ * @return void
126
+ * @since 1.0
127
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
128
+ */
129
+ public function init($options = array())
130
+ {
131
+
132
+ $this->set_options($options);
133
+ $this->set_tabs();
134
+
135
+
136
+ add_action('add_meta_boxes', array($this, 'register_metabox'));
137
+ add_action('save_post', array($this, 'save_postdata'));
138
+ add_action('admin_enqueue_scripts', array($this, 'enqueue'), 15);
139
+
140
+ }
141
+
142
+ /**
143
+ * Enqueue script and styles in admin side
144
+ *
145
+ * Add style and scripts to administrator
146
+ *
147
+ * @return void
148
+ * @since 1.0
149
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
150
+ */
151
+ public function enqueue()
152
+ {
153
+
154
+ wp_enqueue_media();
155
+ wp_enqueue_style('wp-color-picker');
156
+ wp_enqueue_style('yit-plugin-metaboxes', YIT_CORE_PLUGIN_URL . '/assets/css/metaboxes.css');
157
+ wp_enqueue_style('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css');
158
+ wp_enqueue_script('jquery-ui-datepicker');
159
+ wp_enqueue_script('yit-spinner', YIT_CORE_PLUGIN_URL . '/assets/js/panel.spinner.js', array('jquery'), '0.0.1', true);
160
+ wp_enqueue_script('jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array('jquery'), '1.1.0', true);
161
+ wp_enqueue_script('ajax-chosen', yit_load_js_file(YIT_CORE_PLUGIN_URL . '/assets/js/chosen/ajax-chosen.jquery.js'), array('jquery'), '1.1.0', true);
162
+ wp_enqueue_script('yit-metabox', YIT_CORE_PLUGIN_URL . '/assets/js/metabox.js', array('jquery', 'wp-color-picker'), '1.0.0', true);
163
+ wp_enqueue_style('jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-custom/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all');
164
+ }
165
+
166
+ /**
167
+ * Set Options
168
+ *
169
+ * Set the variable options
170
+ *
171
+ * @param array $options
172
+ *
173
+ * @return void
174
+ * @since 1.0
175
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
176
+ */
177
+ public function set_options($options = array())
178
+ {
179
+ $this->options = $options;
180
+
181
+ }
182
+
183
+ /**
184
+ * Set Tabs
185
+ *
186
+ * Set the variable tabs
187
+ *
188
+ * @internal param array $tabs
189
+ *
190
+ * @return void
191
+ * @since 1.0
192
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
193
+ */
194
+ public function set_tabs()
195
+ {
196
+ if (!isset($this->options['tabs'])) {
197
+ return;
198
+ }
199
+ $this->tabs = $this->options['tabs'];
200
+ if (isset($this->tabs['settings']['fields'])) {
201
+ $this->tabs['settings']['fields'] = array_filter($this->tabs['settings']['fields']);
202
+ }
203
+ }
204
+
205
+
206
+ /**
207
+ * Add Tab
208
+ *
209
+ * Add a tab inside the metabox
210
+ *
211
+ * @internal param array $tabs
212
+ *
213
+ * @param array $tab the new tab to add to the metabox
214
+ * @param string $where tell where insert the tab if after or before a $refer
215
+ * @param null $refer an existent tab inside metabox
216
+ *
217
+ * @return void
218
+ * @since 1.0
219
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
220
+ */
221
+ public function add_tab($tab, $where = 'after', $refer = null)
222
+ {
223
+ if (!is_null($refer)) {
224
+ $ref_pos = array_search($refer, array_keys($this->tabs));
225
+ if ($ref_pos !== false) {
226
+ if ($where == 'after') {
227
+ $this->tabs = array_slice($this->tabs, 0, $ref_pos + 1, true) +
228
+ $tab +
229
+ array_slice($this->tabs, $ref_pos + 1, count($this->tabs) - 1, true);
230
+ } else {
231
+ $this->tabs = array_slice($this->tabs, 0, $ref_pos, true) +
232
+ $tab +
233
+ array_slice($this->tabs, $ref_pos, count($this->tabs), true);
234
+ }
235
+ }
236
+ } else {
237
+ $this->tabs = array_merge($tab, $this->tabs);
238
+ }
239
+
240
+ }
241
+
242
+ /**
243
+ * Remove Tab
244
+ *
245
+ * Remove a tab from the tabs of metabox
246
+ *
247
+ * @internal param array $tabs
248
+ *
249
+ * @param $id_tab
250
+ *
251
+ * @return void
252
+ * @since 1.0
253
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
254
+ */
255
+ public function remove_tab($id_tab)
256
+ {
257
+ if (isset($this->tabs[$id_tab])) {
258
+ unset ($this->tabs[$id_tab]);
259
+ }
260
+ }
261
+
262
+
263
+ /**
264
+ * Add Field
265
+ *
266
+ * Add a field inside a tab of metabox
267
+ *
268
+ * @internal param array $tabs
269
+ *
270
+ * @param string $tab_id the id of the tabs where add the field
271
+ * @param array $args the field to add
272
+ * @param string $where tell where insert the field if after or before a $refer
273
+ * @param null $refer an existent field inside tab
274
+ *
275
+ * @return void
276
+ * @since 1.0
277
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
278
+ */
279
+ public function add_field($tab_id, $args, $where = 'after', $refer = null)
280
+ {
281
+ if (isset($this->tabs[$tab_id])) {
282
+
283
+ $cf = $this->tabs[$tab_id]['fields'];
284
+ if (!is_null($refer)) {
285
+ $ref_pos = array_search($refer, array_keys($cf));
286
+ if ($ref_pos !== false) {
287
+ if ($where == 'after') {
288
+ $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos + 1, true) +
289
+ $args +
290
+ array_slice($cf, $ref_pos, count($cf) - 1, true);
291
+
292
+ } elseif ($where == 'before') {
293
+ $this->tabs[$tab_id]['fields'] = array_slice($cf, 0, $ref_pos, true) +
294
+ $args +
295
+ array_slice($cf, $ref_pos, count($cf), true);
296
+
297
+ }
298
+ }
299
+ } else {
300
+ if ($where == 'first') {
301
+ $this->tabs[$tab_id]['fields'] = $args + $cf;
302
+
303
+ } else {
304
+ $this->tabs[$tab_id]['fields'] = array_merge($this->tabs[$tab_id]['fields'], $args);
305
+ }
306
+ }
307
+
308
+ }
309
+
310
+
311
+ }
312
+
313
+ /**
314
+ * Remove Field
315
+ *
316
+ * Remove a field from the metabox, search inside the tabs and remove it if exists
317
+ *
318
+ * @param $id_field
319
+ *
320
+ * @return void
321
+ * @since 1.0
322
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
323
+ */
324
+ public function remove_field($id_field)
325
+ {
326
+ foreach ($this->tabs as $tab_name => $tab) {
327
+ if (isset($tab['fields'][$id_field])) {
328
+ unset ($this->tabs[$tab_name]['fields'][$id_field]);
329
+ }
330
+ }
331
+ }
332
+
333
+ /**
334
+ * Reorder tabs
335
+ *
336
+ * Order the tabs and fields and set id and name to each field
337
+ *
338
+ * @internal param $id_field
339
+ *
340
+ * @return void
341
+ * @since 1.0
342
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
343
+ */
344
+ public function reorder_tabs()
345
+ {
346
+ foreach ($this->tabs as $tab_name => $tab) {
347
+ foreach ($tab['fields'] as $id_field => $field) {
348
+ $this->tabs[$tab_name]['fields'][$id_field]['private'] = (isset($field['private'])) ? $field['private'] : true;
349
+ $this->tabs[$tab_name]['fields'][$id_field]['id'] = $this->get_option_metabox_id($id_field, $this->tabs[$tab_name]['fields'][$id_field]['private']);
350
+ $this->tabs[$tab_name]['fields'][$id_field]['name'] = $this->get_option_metabox_name($this->tabs[$tab_name]['fields'][$id_field]['id']);
351
+ }
352
+ }
353
+
354
+ }
355
+
356
+
357
+ /**
358
+ * Get Option Metabox ID
359
+ *
360
+ * return the id of the field
361
+ *
362
+ * @param string $id_field
363
+ * @param bool $private if private add an _befor the id
364
+ *
365
+ * @return string
366
+ * @since 1.0
367
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
368
+ */
369
+ public function get_option_metabox_id($id_field, $private = true)
370
+ {
371
+ if ($private) {
372
+ return '_' . $id_field;
373
+ } else {
374
+ return $id_field;
375
+ }
376
+ }
377
+
378
+ /**
379
+ * Get Option Metabox Name
380
+ *
381
+ * return the name of the field, this name will be used as attribute name of the input field
382
+ *
383
+ * @param string $id_field
384
+ * @param bool $private if private add an _befor the id
385
+ *
386
+ * @return string
387
+ * @since 1.0
388
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
389
+ */
390
+ public function get_option_metabox_name($id_field, $private = true)
391
+ {
392
+ $db_name = apply_filters('yit_metaboxes_option_main_name', 'yit_metaboxes');
393
+ $return = $db_name . '[';
394
+
395
+ if (!strpos($id_field, '[')) {
396
+ return $return . $id_field . ']';
397
+ }
398
+ $return .= substr($id_field, 0, strpos($id_field, '['));
399
+ $return .= ']';
400
+ $return .= substr($id_field, strpos($id_field, '['));
401
+
402
+ return $return;
403
+ }
404
+
405
+ /**
406
+ * Register the metabox
407
+ *
408
+ * call the wp function add_metabox to add the metabox
409
+ *
410
+ *
411
+ * @return void
412
+ * @since 1.0
413
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
414
+ */
415
+ public function register_metabox($post_type)
416
+ {
417
+ if (in_array($post_type, (array)$this->options['pages'])) {
418
+ add_meta_box($this->id, $this->options['label'], array($this, 'show'), $post_type, $this->options['context'], $this->options['priority']);
419
+ }
420
+ }
421
+
422
+ /**
423
+ * Show metabox
424
+ *
425
+ * show the html of metabox
426
+ *
427
+ *
428
+ * @return void
429
+ * @since 1.0
430
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
431
+ */
432
+ public function show()
433
+ {
434
+ $this->reorder_tabs();
435
+
436
+ yit_plugin_get_template(YIT_CORE_PLUGIN_PATH, 'metaboxes/tab.php', array('tabs' => $this->tabs));
437
+ }
438
+
439
+ /**
440
+ * Save Post Data
441
+ *
442
+ * Save the post data in the database when save the post
443
+ *
444
+ * @param $post_id
445
+ *
446
+ * @return int
447
+ * @since 1.0
448
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
449
+ */
450
+ public function save_postdata($post_id)
451
+ {
452
+
453
+
454
+ if (!isset($_POST['yit_metaboxes_nonce']) || !wp_verify_nonce($_POST['yit_metaboxes_nonce'], 'metaboxes-fields-nonce')) {
455
+ return $post_id;
456
+ }
457
+
458
+
459
+ if ((defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) || (defined('DOING_AJAX') && DOING_AJAX)) {
460
+ return $post_id;
461
+ }
462
+
463
+ if (isset($_POST['post_type'])) {
464
+ $post_type = $_POST['post_type'];
465
+ } else {
466
+ return $post_id;
467
+ }
468
+
469
+ if ('page' == $post_type) {
470
+ if (!current_user_can('edit_page', $post_id)) {
471
+ return $post_id;
472
+ }
473
+ } else {
474
+ if (!current_user_can('edit_post', $post_id)) {
475
+ return $post_id;
476
+ }
477
+ }
478
+
479
+ if (!in_array($post_type, (array)$this->options['pages'])) {
480
+ return $post_id;
481
+ }
482
+
483
+ $this->reorder_tabs();
484
+
485
+
486
+ foreach ($this->tabs as $tab) {
487
+
488
+ foreach ($tab['fields'] as $field) {
489
+
490
+ if (in_array($field['type'], array('title'))) {
491
+ continue;
492
+ }
493
+
494
+ if (isset($_POST['yit_metaboxes'][$field['id']])) {
495
+
496
+ add_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']], true) || update_post_meta($post_id, $field['id'], $_POST['yit_metaboxes'][$field['id']]);
497
+ } elseif (in_array($field['type'], array('onoff', 'checkbox'))) {
498
+ update_post_meta($post_id, $field['id'], '0');
499
+ } else {
500
+ delete_post_meta($post_id, $field['id']);
501
+ }
502
+ }
503
+ }
504
+
505
+
506
+ }
507
+
508
+ /**
509
+ * Remove Fields
510
+ *
511
+ * Remove a fields list from the metabox, search inside the tabs and remove it if exists
512
+ *
513
+ * @param $id_fields
514
+ *
515
+ * @return void
516
+ * @since 2.0.0
517
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
518
+ */
519
+ public function remove_fields($id_fields)
520
+ {
521
+ foreach ($id_fields as $k => $field) {
522
+ $this->remove_field($field);
523
+ }
524
+ }
525
+ }
526
+ }
527
+
528
+ if (!function_exists('YIT_Metabox')) {
529
+
530
+ /**
531
+ * Main instance of plugin
532
+ *
533
+ * @param $id
534
+ *
535
+ * @return \YIT_Metabox
536
+ * @since 1.0
537
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
538
+ */
539
+
540
+
541
+ function YIT_Metabox($id)
542
+ {
543
+ return YIT_Metabox::instance($id);
544
+ }
545
+ }
546
+
547
+
548
+
549
+
plugin-fw/lib/yit-plugin-common.php CHANGED
@@ -1,1260 +1,1260 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! class_exists( 'YIT_Plugin_Common' ) ) :
12
-
13
- /**
14
- * Core configuration class
15
- *
16
- * @since 1.0.0
17
- */
18
- class YIT_Plugin_Common {
19
-
20
- /**
21
- * Config array
22
- *
23
- * @var array
24
- */
25
- protected static $_config = array(
26
- 'slider' => array( 'nivo', 'elegant' ),
27
-
28
-
29
- 'awesome_icons' => array(
30
- '' => 'no-icon',
31
- 'f042' => 'adjust',
32
- 'f170' => 'adn',
33
- 'f037' => 'align-center',
34
- 'f039' => 'align-justify',
35
- 'f036' => 'align-left',
36
- 'f038' => 'align-right',
37
- 'f0f9' => 'ambulance',
38
- 'f13d' => 'anchor',
39
- 'f17b' => 'android',
40
- 'f103' => 'angle-double-down',
41
- 'f100' => 'angle-double-left',
42
- 'f101' => 'angle-double-right',
43
- 'f102' => 'angle-double-up',
44
- 'f107' => 'angle-down',
45
- 'f104' => 'angle-left',
46
- 'f105' => 'angle-right',
47
- 'f106' => 'angle-up',
48
- 'f179' => 'apple',
49
- 'f187' => 'archive',
50
- 'f0ab' => 'arrow-circle-down',
51
- 'f0a8' => 'arrow-circle-left',
52
- 'f01a' => 'arrow-circle-o-down',
53
- 'f190' => 'arrow-circle-o-left',
54
- 'f18e' => 'arrow-circle-o-right',
55
- 'f01b' => 'arrow-circle-o-up',
56
- 'f0a9' => 'arrow-circle-right',
57
- 'f0aa' => 'arrow-circle-up',
58
- 'f063' => 'arrow-down',
59
- 'f060' => 'arrow-left',
60
- 'f061' => 'arrow-right',
61
- 'f062' => 'arrow-up',
62
- 'f047' => 'arrows',
63
- 'f0b2' => 'arrows-alt',
64
- 'f07e' => 'arrows-h',
65
- 'f07d' => 'arrows-v',
66
- 'f069' => 'asterisk',
67
- 'f04a' => 'backward',
68
- 'f05e' => 'ban',
69
- 'f080' => 'bar-chart-o',
70
- 'f02a' => 'barcode',
71
- 'f0c9' => 'bars',
72
- 'f0fc' => 'beer',
73
- 'f0f3' => 'bell',
74
- 'f0a2' => 'bell-o',
75
- 'f171' => 'bitbucket',
76
- 'f172' => 'bitbucket-square',
77
- 'f032' => 'bold',
78
- 'f0e7' => 'bolt',
79
- 'f02d' => 'book',
80
- 'f02e' => 'bookmark',
81
- 'f097' => 'bookmark-o',
82
- 'f0b1' => 'briefcase',
83
- 'f15a' => 'btc',
84
- 'f188' => 'bug',
85
- 'f0f7' => 'building-o',
86
- 'f0a1' => 'bullhorn',
87
- 'f140' => 'bullseye',
88
- 'f073' => 'calendar',
89
- 'f133' => 'calendar-o',
90
- 'f030' => 'camera',
91
- 'f083' => 'camera-retro',
92
- 'f0d7' => 'caret-down',
93
- 'f0d9' => 'caret-left',
94
- 'f0da' => 'caret-right',
95
- 'f150' => 'caret-square-o-down',
96
- 'f191' => 'caret-square-o-left',
97
- 'f152' => 'caret-square-o-right',
98
- 'f151' => 'caret-square-o-up',
99
- 'f0d8' => 'caret-up',
100
- 'f0a3' => 'certificate',
101
- 'f127' => 'chain-broken',
102
- 'f00c' => 'check',
103
- 'f058' => 'check-circle',
104
- 'f05d' => 'check-circle-o',
105
- 'f14a' => 'check-square',
106
- 'f046' => 'check-square-o',
107
- 'f13a' => 'chevron-circle-down',
108
- 'f137' => 'chevron-circle-left',
109
- 'f138' => 'chevron-circle-right',
110
- 'f139' => 'chevron-circle-up',
111
- 'f078' => 'chevron-down',
112
- 'f053' => 'chevron-left',
113
- 'f054' => 'chevron-right',
114
- 'f077' => 'chevron-up',
115
- 'f10c' => 'circle-o',
116
- 'f0ea' => 'clipboard',
117
- 'f017' => 'clock-o',
118
- 'f0c2' => 'cloud',
119
- 'f0ed' => 'cloud-download',
120
- 'f0ee' => 'cloud-upload',
121
- 'f121' => 'code',
122
- 'f126' => 'code-fork',
123
- 'f0f4' => 'coffee',
124
- 'f013' => 'cog',
125
- 'f085' => 'cogs',
126
- 'f0db' => 'columns',
127
- 'f075' => 'comment',
128
- 'f0e5' => 'comment-o',
129
- 'f086' => 'comments',
130
- 'f0e6' => 'comments-o',
131
- 'f14e' => 'compass',
132
- 'f066' => 'compress',
133
- 'f09d' => 'credit-card',
134
- 'f125' => 'crop',
135
- 'f05b' => 'crosshairs',
136
- 'f13c' => 'css3',
137
- 'f0f5' => 'cutlery',
138
- 'f108' => 'desktop',
139
- 'f192' => 'dot-circle-o',
140
- 'f019' => 'download',
141
- 'f17d' => 'dribbble',
142
- 'f16b' => 'dropbox',
143
- 'f052' => 'eject',
144
- 'f141' => 'ellipsis-h',
145
- 'f142' => 'ellipsis-v',
146
- 'f0e0' => 'envelope',
147
- 'f003' => 'envelope-o',
148
- 'f12d' => 'eraser',
149
- 'f153' => 'eur',
150
- 'f0ec' => 'exchange',
151
- 'f12a' => 'exclamation',
152
- 'f06a' => 'exclamation-circle',
153
- 'f071' => 'exclamation-triangle',
154
- 'f065' => 'expand',
155
- 'f08e' => 'external-link',
156
- 'f14c' => 'external-link-square',
157
- 'f06e' => 'eye',
158
- 'f070' => 'eye-slash',
159
- 'f09a' => 'facebook',
160
- 'f082' => 'facebook-square',
161
- 'f049' => 'fast-backward',
162
- 'f050' => 'fast-forward',
163
- 'f182' => 'female',
164
- 'f0fb' => 'fighter-jet',
165
- 'f15b' => 'file',
166
- 'f016' => 'file-o',
167
- 'f15c' => 'file-text',
168
- 'f0f6' => 'file-text-o',
169
- 'f0c5' => 'files-o',
170
- 'f008' => 'film',
171
- 'f0b0' => 'filter',
172
- 'f06d' => 'fire',
173
- 'f134' => 'fire-extinguisher',
174
- 'f024' => 'flag',
175
- 'f11e' => 'flag-checkered',
176
- 'f11d' => 'flag-o',
177
- 'f0c3' => 'flask',
178
- 'f16e' => 'flickr',
179
- 'f0c7' => 'floppy-o',
180
- 'f07b' => 'folder',
181
- 'f114' => 'folder-o',
182
- 'f07c' => 'folder-open',
183
- 'f115' => 'folder-open-o',
184
- 'f031' => 'font',
185
- 'f04e' => 'forward',
186
- 'f180' => 'foursquare',
187
- 'f119' => 'frown-o',
188
- 'f11b' => 'gamepad',
189
- 'f0e3' => 'gavel',
190
- 'f154' => 'gbp',
191
- 'f06b' => 'gift',
192
- 'f09b' => 'github',
193
- 'f113' => 'github-alt',
194
- 'f092' => 'github-square',
195
- 'f184' => 'gittip',
196
- 'f000' => 'glass',
197
- 'f0ac' => 'globe',
198
- 'f0d5' => 'google-plus',
199
- 'f0d4' => 'google-plus-square',
200
- 'f0fd' => 'h-square',
201
- 'f0a7' => 'hand-o-down',
202
- 'f0a5' => 'hand-o-left',
203
- 'f0a4' => 'hand-o-right',
204
- 'f0a6' => 'hand-o-up',
205
- 'f0a0' => 'hdd-o',
206
- 'f025' => 'headphones',
207
- 'f004' => 'heart',
208
- 'f08a' => 'heart-o',
209
- 'f015' => 'home',
210
- 'f0f8' => 'hospital-o',
211
- 'f13b' => 'html5',
212
- 'f01c' => 'inbox',
213
- 'f03c' => 'indent',
214
- 'f129' => 'info',
215
- 'f05a' => 'info-circle',
216
- 'f156' => 'inr',
217
- 'f16d' => 'instagram',
218
- 'f033' => 'italic',
219
- 'f157' => 'jpy',
220
- 'f084' => 'key',
221
- 'f11c' => 'keyboard-o',
222
- 'f159' => 'krw',
223
- 'f109' => 'laptop',
224
- 'f06c' => 'leaf',
225
- 'f094' => 'lemon-o',
226
- 'f149' => 'level-down',
227
- 'f148' => 'level-up',
228
- 'f0eb' => 'lightbulb-o',
229
- 'f0c1' => 'link',
230
- 'f0e1' => 'linkedin',
231
- 'f08c' => 'linkedin-square',
232
- 'f17c' => 'linux',
233
- 'f03a' => 'list',
234
- 'f022' => 'list-alt',
235
- 'f0cb' => 'list-ol',
236
- 'f0ca' => 'list-ul',
237
- 'f124' => 'location-arrow',
238
- 'f023' => 'lock',
239
- 'f175' => 'long-arrow-down',
240
- 'f177' => 'long-arrow-left',
241
- 'f178' => 'long-arrow-right',
242
- 'f176' => 'long-arrow-up',
243
- 'f0d0' => 'magic',
244
- 'f076' => 'magnet',
245
- 'f122' => 'mail-reply-all',
246
- 'f183' => 'male',
247
- 'f041' => 'map-marker',
248
- 'f136' => 'maxcdn',
249
- 'f0fa' => 'medkit',
250
- 'f11a' => 'meh-o',
251
- 'f130' => 'microphone',
252
- 'f131' => 'microphone-slash',
253
- 'f068' => 'minus',
254
- 'f056' => 'minus-circle',
255
- 'f146' => 'minus-square',
256
- 'f147' => 'minus-square-o',
257
- 'f10b' => 'mobile',
258
- 'f0d6' => 'money',
259
- 'f186' => 'moon-o',
260
- 'f001' => 'music',
261
- 'f03b' => 'outdent',
262
- 'f18c' => 'pagelines',
263
- 'f0c6' => 'paperclip',
264
- 'f04c' => 'pause',
265
- 'f040' => 'pencil',
266
- 'f14b' => 'pencil-square',
267
- 'f044' => 'pencil-square-o',
268
- 'f095' => 'phone',
269
- 'f098' => 'phone-square',
270
- 'f03e' => 'picture-o',
271
- 'f0d2' => 'pinterest',
272
- 'f0d3' => 'pinterest-square',
273
- 'f072' => 'plane',
274
- 'f04b' => 'play',
275
- 'f144' => 'play-circle',
276
- 'f01d' => 'play-circle-o',
277
- 'f067' => 'plus',
278
- 'f055' => 'plus-circle',
279
- 'f0fe' => 'plus-square',
280
- 'f196' => 'plus-square-o',
281
- 'f011' => 'power-off',
282
- 'f02f' => 'print',
283
- 'f12e' => 'puzzle-piece',
284
- 'f029' => 'qrcode',
285
- 'f128' => 'question',
286
- 'f059' => 'question-circle',
287
- 'f10d' => 'quote-left',
288
- 'f10e' => 'quote-right',
289
- 'f074' => 'random',
290
- 'f021' => 'refresh',
291
- 'f18b' => 'renren',
292
- 'f01e' => 'repeat',
293
- 'f112' => 'reply',
294
- 'f122' => 'reply-all',
295
- 'f079' => 'retweet',
296
- 'f018' => 'road',
297
- 'f135' => 'rocket',
298
- 'f09e' => 'rss',
299
- 'f143' => 'rss-square',
300
- 'f158' => 'rub',
301
- 'f0c4' => 'scissors',
302
- 'f002' => 'search',
303
- 'f010' => 'search-minus',
304
- 'f00e' => 'search-plus',
305
- 'f064' => 'share',
306
- 'f14d' => 'share-square',
307
- 'f045' => 'share-square-o',
308
- 'f132' => 'shield',
309
- 'f07a' => 'shopping-cart',
310
- 'f090' => 'sign-in',
311
- 'f08b' => 'sign-out',
312
- 'f012' => 'signal',
313
- 'f0e8' => 'sitemap',
314
- 'f17e' => 'skype',
315
- 'f118' => 'smile-o',
316
- 'f0dc' => 'sort',
317
- 'f15d' => 'sort-alpha-asc',
318
- 'f15e' => 'sort-alpha-desc',
319
- 'f160' => 'sort-amount-asc',
320
- 'f161' => 'sort-amount-desc',
321
- 'f0dd' => 'sort-asc',
322
- 'f0de' => 'sort-desc',
323
- 'f162' => 'sort-numeric-asc',
324
- 'f163' => 'sort-numeric-desc',
325
- 'f110' => 'spinner',
326
- 'f0c8' => 'square',
327
- 'f096' => 'square-o',
328
- 'f18d' => 'stack-exchange',
329
- 'f16c' => 'stack-overflow',
330
- 'f005' => 'star',
331
- 'f089' => 'star-half',
332
- 'f123' => 'star-half-o',
333
- 'f006' => 'star-o',
334
- 'f048' => 'step-backward',
335
- 'f051' => 'step-forward',
336
- 'f0f1' => 'stethoscope',
337
- 'f04d' => 'stop',
338
- 'f0cc' => 'strikethrough',
339
- 'f12c' => 'subscript',
340
- 'f0f2' => 'suitcase',
341
- 'f185' => 'sun-o',
342
- 'f12b' => 'superscript',
343
- 'f0ce' => 'table',
344
- 'f10a' => 'tablet',
345
- 'f0e4' => 'tachometer',
346
- 'f02b' => 'tag',
347
- 'f02c' => 'tags',
348
- 'f0ae' => 'tasks',
349
- 'f120' => 'terminal',
350
- 'f034' => 'text-height',
351
- 'f035' => 'text-width',
352
- 'f00a' => 'th',
353
- 'f009' => 'th-large',
354
- 'f00b' => 'th-list',
355
- 'f08d' => 'thumb-tack',
356
- 'f165' => 'thumbs-down',
357
- 'f088' => 'thumbs-o-down',
358
- 'f087' => 'thumbs-o-up',
359
- 'f164' => 'thumbs-up',
360
- 'f145' => 'ticket',
361
- 'f00d' => 'times',
362
- 'f057' => 'times-circle',
363
- 'f05c' => 'times-circle-o',
364
- 'f043' => 'tint',
365
- 'f014' => 'trash-o',
366
- 'f181' => 'trello',
367
- 'f091' => 'trophy',
368
- 'f0d1' => 'truck',
369
- 'f195' => 'try',
370
- 'f173' => 'tumblr',
371
- 'f174' => 'tumblr-square',
372
- 'f099' => 'twitter',
373
- 'f081' => 'twitter-square',
374
- 'f0e9' => 'umbrella',
375
- 'f0cd' => 'underline',
376
- 'f0e2' => 'undo',
377
- 'f09c' => 'unlock',
378
- 'f13e' => 'unlock-alt',
379
- 'f093' => 'upload',
380
- 'f155' => 'usd',
381
- 'f007' => 'user',
382
- 'f0f0' => 'user-md',
383
- 'f0c0' => 'users',
384
- 'f03d' => 'video-camera',
385
- 'f194' => 'vimeo-square',
386
- 'f189' => 'vk',
387
- 'f027' => 'volume-down',
388
- 'f026' => 'volume-off',
389
- 'f028' => 'volume-up',
390
- 'f18a' => 'weibo',
391
- 'f193' => 'wheelchair',
392
- 'f17a' => 'windows',
393
- 'f0ad' => 'wrench',
394
- 'f168' => 'xing',
395
- 'f169' => 'xing-square',
396
- 'f167' => 'youtube',
397
- 'f16a' => 'youtube-play',
398
- 'f166' => 'youtube-square'
399
- ),
400
- 'awesome_icons2' => array(
401
- '\f042' => 'adjust',
402
- '\f170' => 'adn',
403
- '\f037' => 'align-center',
404
- '\f039' => 'align-justify',
405
- '\f036' => 'align-left',
406
- '\f038' => 'align-right',
407
- '\f0f9' => 'ambulance',
408
- '\f13d' => 'anchor',
409
- '\f17b' => 'android',
410
- '\f209' => 'angellist',
411
- '\f103' => 'angle-double-down',
412
- '\f100' => 'angle-double-left',
413
- '\f101' => 'angle-double-right',
414
- '\f102' => 'angle-double-up',
415
- '\f107' => 'angle-down',
416
- '\f104' => 'angle-left',
417
- '\f105' => 'angle-right',
418
- '\f106' => 'angle-up',
419
- '\f179' => 'apple',
420
- '\f187' => 'archive',
421
- '\f1fe' => 'area-chart',
422
- '\f0ab' => 'arrow-circle-down',
423
- '\f0a8' => 'arrow-circle-left',
424
- '\f01a' => 'arrow-circle-o-down',
425
- '\f190' => 'arrow-circle-o-left',
426
- '\f18e' => 'arrow-circle-o-right',
427
- '\f01b' => 'arrow-circle-o-up',
428
- '\f0a9' => 'arrow-circle-right',
429
- '\f0aa' => 'arrow-circle-up',
430
- '\f063' => 'arrow-down',
431
- '\f060' => 'arrow-left',
432
- '\f061' => 'arrow-right',
433
- '\f062' => 'arrow-up',
434
- '\f047' => 'arrows',
435
- '\f0b2' => 'arrows-alt',
436
- '\f07e' => 'arrows-h',
437
- '\f07d' => 'arrows-v',
438
- '\f069' => 'asterisk',
439
- '\f1fa' => 'at',
440
- '\f1b9' => 'automobile',
441
- '\f04a' => 'backward',
442
- '\f05e' => 'ban',
443
- '\f19c' => 'bank',
444
- '\f080' => 'bar-chart',
445
- '\f080' => 'bar-chart-o',
446
- '\f02a' => 'barcode',
447
- '\f0c9' => 'bars',
448
- '\f236' => 'bed',
449
- '\f0fc' => 'beer',
450
- '\f1b4' => 'behance',
451
- '\f1b5' => 'behance-square',
452
- '\f0f3' => 'bell',
453
- '\f0a2' => 'bell-o',
454
- '\f1f6' => 'bell-slash',
455
- '\f1f7' => 'bell-slash-o',
456
- '\f206' => 'bicycle',
457
- '\f1e5' => 'binoculars',
458
- '\f1fd' => 'birthday-cake',
459
- '\f171' => 'bitbucket',
460
- '\f172' => 'bitbucket-square',
461
- '\f15a' => 'bitcoin',
462
- '\f032' => 'bold',
463
- '\f0e7' => 'bolt',
464
- '\f1e2' => 'bomb',
465
- '\f02d' => 'book',
466
- '\f02e' => 'bookmark',
467
- '\f097' => 'bookmark-o',
468
- '\f0b1' => 'briefcase',
469
- '\f15a' => 'btc',
470
- '\f188' => 'bug',
471
- '\f1ad' => 'building',
472
- '\f0f7' => 'building-o',
473
- '\f0a1' => 'bullhorn',
474
- '\f140' => 'bullseye',
475
- '\f207' => 'bus',
476
- '\f20d' => 'buysellads',
477
- '\f1ba' => 'cab',
478
- '\f1ec' => 'calculator',
479
- '\f073' => 'calendar',
480
- '\f133' => 'calendar-o',
481
- '\f030' => 'camera',
482
- '\f083' => 'camera-retro',
483
- '\f1b9' => 'car',
484
- '\f0d7' => 'caret-down',
485
- '\f0d9' => 'caret-left',
486
- '\f0da' => 'caret-right',
487
- '\f150' => 'caret-square-o-down',
488
- '\f191' => 'caret-square-o-left',
489
- '\f152' => 'caret-square-o-right',
490
- '\f151' => 'caret-square-o-up',
491
- '\f0d8' => 'caret-up',
492
- '\f218' => 'cart-arrow-down',
493
- '\f217' => 'cart-plus',
494
- '\f20a' => 'cc',
495
- '\f1f3' => 'cc-amex',
496
- '\f1f2' => 'cc-discover',
497
- '\f1f1' => 'cc-mastercard',
498
- '\f1f4' => 'cc-paypal',
499
- '\f1f5' => 'cc-stripe',
500
- '\f1f0' => 'cc-visa',
501
- '\f0a3' => 'certificate',
502
- '\f0c1' => 'chain',
503
- '\f127' => 'chain-broken',
504
- '\f00c' => 'check',
505
- '\f058' => 'check-circle',
506
- '\f05d' => 'check-circle-o',
507
- '\f14a' => 'check-square',
508
- '\f046' => 'check-square-o',
509
- '\f13a' => 'chevron-circle-down',
510
- '\f137' => 'chevron-circle-left',
511
- '\f138' => 'chevron-circle-right',
512
- '\f139' => 'chevron-circle-up',
513
- '\f078' => 'chevron-down',
514
- '\f053' => 'chevron-left',
515
- '\f054' => 'chevron-right',
516
- '\f077' => 'chevron-up',
517
- '\f1ae' => 'child',
518
- '\f111' => 'circle',
519
- '\f10c' => 'circle-o',
520
- '\f1ce' => 'circle-o-notch',
521
- '\f1db' => 'circle-thin',
522
- '\f0ea' => 'clipboard',
523
- '\f017' => 'clock-o',
524
- '\f00d' => 'close',
525
- '\f0c2' => 'cloud',
526
- '\f0ed' => 'cloud-download',
527
- '\f0ee' => 'cloud-upload',
528
- '\f157' => 'cny',
529
- '\f121' => 'code',
530
- '\f126' => 'code-fork',
531
- '\f1cb' => 'codepen',
532
- '\f0f4' => 'coffee',
533
- '\f013' => 'cog',
534
- '\f085' => 'cogs',
535
- '\f0db' => 'columns',
536
- '\f075' => 'comment',
537
- '\f0e5' => 'comment-o',
538
- '\f086' => 'comments',
539
- '\f0e6' => 'comments-o',
540
- '\f14e' => 'compass',
541
- '\f066' => 'compress',
542
- '\f20e' => 'connectdevelop',
543
- '\f0c5' => 'copy',
544
- '\f1f9' => 'copyright',
545
- '\f09d' => 'credit-card',
546
- '\f125' => 'crop',
547
- '\f05b' => 'crosshairs',
548
- '\f13c' => 'css3',
549
- '\f1b2' => 'cube',
550
- '\f1b3' => 'cubes',
551
- '\f0c4' => 'cut',
552
- '\f0f5' => 'cutlery',
553
- '\f0e4' => 'dashboard',
554
- '\f210' => 'dashcube',
555
- '\f1c0' => 'database',
556
- '\f03b' => 'dedent',
557
- '\f1a5' => 'delicious',
558
- '\f108' => 'desktop',
559
- '\f1bd' => 'deviantart',
560
- '\f219' => 'diamond',
561
- '\f1a6' => 'digg',
562
- '\f155' => 'dollar',
563
- '\f192' => 'dot-circle-o',
564
- '\f019' => 'download',
565
- '\f17d' => 'dribbble',
566
- '\f16b' => 'dropbox',
567
- '\f1a9' => 'drupal',
568
- '\f044' => 'edit',
569
- '\f052' => 'eject',
570
- '\f141' => 'ellipsis-h',
571
- '\f142' => 'ellipsis-v',
572
- '\f1d1' => 'empire',
573
- '\f0e0' => 'envelope',
574
- '\f003' => 'envelope-o',
575
- '\f199' => 'envelope-square',
576
- '\f12d' => 'eraser',
577
- '\f153' => 'eur',
578
- '\f153' => 'euro',
579
- '\f0ec' => 'exchange',
580
- '\f12a' => 'exclamation',
581
- '\f06a' => 'exclamation-circle',
582
- '\f071' => 'exclamation-triangle',
583
- '\f065' => 'expand',
584
- '\f08e' => 'external-link',
585
- '\f14c' => 'external-link-square',
586
- '\f06e' => 'eye',
587
- '\f070' => 'eye-slash',
588
- '\f1fb' => 'eyedropper',
589
- '\f09a' => 'facebook',
590
- '\f09a' => 'facebook-f',
591
- '\f230' => 'facebook-official',
592
- '\f082' => 'facebook-square',
593
- '\f049' => 'fast-backward',
594
- '\f050' => 'fast-forward',
595
- '\f1ac' => 'fax',
596
- '\f182' => 'female',
597
- '\f0fb' => 'fighter-jet',
598
- '\f15b' => 'file',
599
- '\f1c6' => 'file-archive-o',
600
- '\f1c7' => 'file-audio-o',
601
- '\f1c9' => 'file-code-o',
602
- '\f1c3' => 'file-excel-o',
603
- '\f1c5' => 'file-image-o',
604
- '\f1c8' => 'file-movie-o',
605
- '\f016' => 'file-o',
606
- '\f1c1' => 'file-pdf-o',
607
- '\f1c5' => 'file-photo-o',
608
- '\f1c5' => 'file-picture-o',
609
- '\f1c4' => 'file-powerpoint-o',
610
- '\f1c7' => 'file-sound-o',
611
- '\f15c' => 'file-text',
612
- '\f0f6' => 'file-text-o',
613
- '\f1c8' => 'file-video-o',
614
- '\f1c2' => 'file-word-o',
615
- '\f1c6' => 'file-zip-o',
616
- '\f0c5' => 'files-o',
617
- '\f008' => 'film',
618
- '\f0b0' => 'filter',
619
- '\f06d' => 'fire',
620
- '\f134' => 'fire-extinguisher',
621
- '\f024' => 'flag',
622
- '\f11e' => 'flag-checkered',
623
- '\f11d' => 'flag-o',
624
- '\f0e7' => 'flash',
625
- '\f0c3' => 'flask',
626
- '\f16e' => 'flickr',
627
- '\f0c7' => 'floppy-o',
628
- '\f07b' => 'folder',
629
- '\f114' => 'folder-o',
630
- '\f07c' => 'folder-open',
631
- '\f115' => 'folder-open-o',
632
- '\f031' => 'font',
633
- '\f211' => 'forumbee',
634
- '\f04e' => 'forward',
635
- '\f180' => 'foursquare',
636
- '\f119' => 'frown-o',
637
- '\f1e3' => 'futbol-o',
638
- '\f11b' => 'gamepad',
639
- '\f0e3' => 'gavel',
640
- '\f154' => 'gbp',
641
- '\f1d1' => 'ge',
642
- '\f013' => 'gear',
643
- '\f085' => 'gears',
644
- '\f1db' => 'genderless',
645
- '\f06b' => 'gift',
646
- '\f1d3' => 'git',
647
- '\f1d2' => 'git-square',
648
- '\f09b' => 'github',
649
- '\f113' => 'github-alt',
650
- '\f092' => 'github-square',
651
- '\f184' => 'gittip',
652
- '\f000' => 'glass',
653
- '\f0ac' => 'globe',
654
- '\f1a0' => 'google',
655
- '\f0d5' => 'google-plus',
656
- '\f0d4' => 'google-plus-square',
657
- '\f1ee' => 'google-wallet',
658
- '\f19d' => 'graduation-cap',
659
- '\f184' => 'gratipay',
660
- '\f0c0' => 'group',
661
- '\f0fd' => 'h-square',
662
- '\f1d4' => 'hacker-news',
663
- '\f0a7' => 'hand-o-down',
664
- '\f0a5' => 'hand-o-left',
665
- '\f0a4' => 'hand-o-right',
666
- '\f0a6' => 'hand-o-up',
667
- '\f0a0' => 'hdd-o',
668
- '\f1dc' => 'header',
669
- '\f025' => 'headphones',
670
- '\f004' => 'heart',
671
- '\f08a' => 'heart-o',
672
- '\f21e' => 'heartbeat',
673
- '\f1da' => 'history',
674
- '\f015' => 'home',
675
- '\f0f8' => 'hospital-o',
676
- '\f236' => 'hotel',
677
- '\f13b' => 'html5',
678
- '\f20b' => 'ils',
679
- '\f03e' => 'image',
680
- '\f01c' => 'inbox',
681
- '\f03c' => 'indent',
682
- '\f129' => 'info',
683
- '\f05a' => 'info-circle',
684
- '\f156' => 'inr',
685
- '\f16d' => 'instagram',
686
- '\f19c' => 'institution',
687
- '\f208' => 'ioxhost',
688
- '\f033' => 'italic',
689
- '\f1aa' => 'joomla',
690
- '\f157' => 'jpy',
691
- '\f1cc' => 'jsfiddle',
692
- '\f084' => 'key',
693
- '\f11c' => 'keyboard-o',
694
- '\f159' => 'krw',
695
- '\f1ab' => 'language',
696
- '\f109' => 'laptop',
697
- '\f202' => 'lastfm',
698
- '\f203' => 'lastfm-square',
699
- '\f06c' => 'leaf',
700
- '\f212' => 'leanpub',
701
- '\f0e3' => 'legal',
702
- '\f094' => 'lemon-o',
703
- '\f149' => 'level-down',
704
- '\f148' => 'level-up',
705
- '\f1cd' => 'life-bouy',
706
- '\f1cd' => 'life-buoy',
707
- '\f1cd' => 'life-ring',
708
- '\f1cd' => 'life-saver',
709
- '\f0eb' => 'lightbulb-o',
710
- '\f201' => 'line-chart',
711
- '\f0c1' => 'link',
712
- '\f0e1' => 'linkedin',
713
- '\f08c' => 'linkedin-square',
714
- '\f17c' => 'linux',
715
- '\f03a' => 'list',
716
- '\f022' => 'list-alt',
717
- '\f0cb' => 'list-ol',
718
- '\f0ca' => 'list-ul',
719
- '\f124' => 'location-arrow',
720
- '\f023' => 'lock',
721
- '\f175' => 'long-arrow-down',
722
- '\f177' => 'long-arrow-left',
723
- '\f178' => 'long-arrow-right',
724
- '\f176' => 'long-arrow-up',
725
- '\f0d0' => 'magic',
726
- '\f076' => 'magnet',
727
- '\f064' => 'mail-forward',
728
- '\f112' => 'mail-reply',
729
- '\f122' => 'mail-reply-all',
730
- '\f183' => 'male',
731
- '\f041' => 'map-marker',
732
- '\f222' => 'mars',
733
- '\f227' => 'mars-double',
734
- '\f229' => 'mars-stroke',
735
- '\f22b' => 'mars-stroke-h',
736
- '\f22a' => 'mars-stroke-v',
737
- '\f136' => 'maxcdn',
738
- '\f20c' => 'meanpath',
739
- '\f23a' => 'medium',
740
- '\f0fa' => 'medkit',
741
- '\f11a' => 'meh-o',
742
- '\f223' => 'mercury',
743
- '\f130' => 'microphone',
744
- '\f131' => 'microphone-slash',
745
- '\f068' => 'minus',
746
- '\f056' => 'minus-circle',
747
- '\f146' => 'minus-square',
748
- '\f147' => 'minus-square-o',
749
- '\f10b' => 'mobile',
750
- '\f10b' => 'mobile-phone',
751
- '\f0d6' => 'money',
752
- '\f186' => 'moon-o',
753
- '\f19d' => 'mortar-board',
754
- '\f21c' => 'motorcycle',
755
- '\f001' => 'music',
756
- '\f0c9' => 'navicon',
757
- '\f22c' => 'neuter',
758
- '\f1ea' => 'newspaper-o',
759
- '\f19b' => 'openid',
760
- '\f03b' => 'outdent',
761
- '\f18c' => 'pagelines',
762
- '\f1fc' => 'paint-brush',
763
- '\f1d8' => 'paper-plane',
764
- '\f1d9' => 'paper-plane-o',
765
- '\f0c6' => 'paperclip',
766
- '\f1dd' => 'paragraph',
767
- '\f0ea' => 'paste',
768
- '\f04c' => 'pause',
769
- '\f1b0' => 'paw',
770
- '\f1ed' => 'paypal',
771
- '\f040' => 'pencil',
772
- '\f14b' => 'pencil-square',
773
- '\f044' => 'pencil-square-o',
774
- '\f095' => 'phone',
775
- '\f098' => 'phone-square',
776
- '\f03e' => 'photo',
777
- '\f03e' => 'picture-o',
778
- '\f200' => 'pie-chart',
779
- '\f1a7' => 'pied-piper',
780
- '\f1a8' => 'pied-piper-alt',
781
- '\f0d2' => 'pinterest',
782
- '\f231' => 'pinterest-p',
783
- '\f0d3' => 'pinterest-square',
784
- '\f072' => 'plane',
785
- '\f04b' => 'play',
786
- '\f144' => 'play-circle',
787
- '\f01d' => 'play-circle-o',
788
- '\f1e6' => 'plug',
789
- '\f067' => 'plus',
790
- '\f055' => 'plus-circle',
791
- '\f0fe' => 'plus-square',
792
- '\f196' => 'plus-square-o',
793
- '\f011' => 'power-off',
794
- '\f02f' => 'print',
795
- '\f12e' => 'puzzle-piece',
796
- '\f1d6' => 'qq',
797
- '\f029' => 'qrcode',
798
- '\f128' => 'question',
799
- '\f059' => 'question-circle',
800
- '\f10d' => 'quote-left',
801
- '\f10e' => 'quote-right',
802
- '\f1d0' => 'ra',
803
- '\f074' => 'random',
804
- '\f1d0' => 'rebel',
805
- '\f1b8' => 'recycle',
806
- '\f1a1' => 'reddit',
807
- '\f1a2' => 'reddit-square',
808
- '\f021' => 'refresh',
809
- '\f00d' => 'remove',
810
- '\f18b' => 'renren',
811
- '\f0c9' => 'reorder',
812
- '\f01e' => 'repeat',
813
- '\f112' => 'reply',
814
- '\f122' => 'reply-all',
815
- '\f079' => 'retweet',
816
- '\f157' => 'rmb',
817
- '\f018' => 'road',
818
- '\f135' => 'rocket',
819
- '\f0e2' => 'rotate-left',
820
- '\f01e' => 'rotate-right',
821
- '\f158' => 'rouble',
822
- '\f09e' => 'rss',
823
- '\f143' => 'rss-square',
824
- '\f158' => 'rub',
825
- '\f158' => 'ruble',
826
- '\f156' => 'rupee',
827
- '\f0c7' => 'save',
828
- '\f0c4' => 'scissors',
829
- '\f002' => 'search',
830
- '\f010' => 'search-minus',
831
- '\f00e' => 'search-plus',
832
- '\f213' => 'sellsy',
833
- '\f1d8' => 'send',
834
- '\f1d9' => 'send-o',
835
- '\f233' => 'server',
836
- '\f064' => 'share',
837
- '\f1e0' => 'share-alt',
838
- '\f1e1' => 'share-alt-square',
839
- '\f14d' => 'share-square',
840
- '\f045' => 'share-square-o',
841
- '\f20b' => 'shekel',
842
- '\f20b' => 'sheqel',
843
- '\f132' => 'shield',
844
- '\f21a' => 'ship',
845
- '\f214' => 'shirtsinbulk',
846
- '\f07a' => 'shopping-cart',
847
- '\f090' => 'sign-in',
848
- '\f08b' => 'sign-out',
849
- '\f012' => 'signal',
850
- '\f215' => 'simplybuilt',
851
- '\f0e8' => 'sitemap',
852
- '\f216' => 'skyatlas',
853
- '\f17e' => 'skype',
854
- '\f198' => 'slack',
855
- '\f1de' => 'sliders',
856
- '\f1e7' => 'slideshare',
857
- '\f118' => 'smile-o',
858
- '\f1e3' => 'soccer-ball-o',
859
- '\f0dc' => 'sort',
860
- '\f15d' => 'sort-alpha-asc',
861
- '\f15e' => 'sort-alpha-desc',
862
- '\f160' => 'sort-amount-asc',
863
- '\f161' => 'sort-amount-desc',
864
- '\f0de' => 'sort-asc',
865
- '\f0dd' => 'sort-desc',
866
- '\f0dd' => 'sort-down',
867
- '\f162' => 'sort-numeric-asc',
868
- '\f163' => 'sort-numeric-desc',
869
- '\f0de' => 'sort-up',
870
- '\f1be' => 'soundcloud',
871
- '\f197' => 'space-shuttle',
872
- '\f110' => 'spinner',
873
- '\f1b1' => 'spoon',
874
- '\f1bc' => 'spotify',
875
- '\f0c8' => 'square',
876
- '\f096' => 'square-o',
877
- '\f18d' => 'stack-exchange',
878
- '\f16c' => 'stack-overflow',
879
- '\f005' => 'star',
880
- '\f089' => 'star-half',
881
- '\f123' => 'star-half-empty',
882
- '\f123' => 'star-half-full',
883
- '\f123' => 'star-half-o',
884
- '\f006' => 'star-o',
885
- '\f1b6' => 'steam',
886
- '\f1b7' => 'steam-square',
887
- '\f048' => 'step-backward',
888
- '\f051' => 'step-forward',
889
- '\f0f1' => 'stethoscope',
890
- '\f04d' => 'stop',
891
- '\f21d' => 'street-view',
892
- '\f0cc' => 'strikethrough',
893
- '\f1a4' => 'stumbleupon',
894
- '\f1a3' => 'stumbleupon-circle',
895
- '\f12c' => 'subscript',
896
- '\f239' => 'subway',
897
- '\f0f2' => 'suitcase',
898
- '\f185' => 'sun-o',
899
- '\f12b' => 'superscript',
900
- '\f1cd' => 'support',
901
- '\f0ce' => 'table',
902
- '\f10a' => 'tablet',
903
- '\f0e4' => 'tachometer',
904
- '\f02b' => 'tag',
905
- '\f02c' => 'tags',
906
- '\f0ae' => 'tasks',
907
- '\f1ba' => 'taxi',
908
- '\f1d5' => 'tencent-weibo',
909
- '\f120' => 'terminal',
910
- '\f034' => 'text-height',
911
- '\f035' => 'text-width',
912
- '\f00a' => 'th',
913
- '\f009' => 'th-large',
914
- '\f00b' => 'th-list',
915
- '\f08d' => 'thumb-tack',
916
- '\f165' => 'thumbs-down',
917
- '\f088' => 'thumbs-o-down',
918
- '\f087' => 'thumbs-o-up',
919
- '\f164' => 'thumbs-up',
920
- '\f145' => 'ticket',
921
- '\f00d' => 'times',
922
- '\f057' => 'times-circle',
923
- '\f05c' => 'times-circle-o',
924
- '\f043' => 'tint',
925
- '\f150' => 'toggle-down',
926
- '\f191' => 'toggle-left',
927
- '\f204' => 'toggle-off',
928
- '\f205' => 'toggle-on',
929
- '\f152' => 'toggle-right',
930
- '\f151' => 'toggle-up',
931
- '\f238' => 'train',
932
- '\f224' => 'transgender',
933
- '\f225' => 'transgender-alt',
934
- '\f1f8' => 'trash',
935
- '\f014' => 'trash-o',
936
- '\f1bb' => 'tree',
937
- '\f181' => 'trello',
938
- '\f091' => 'trophy',
939
- '\f0d1' => 'truck',
940
- '\f195' => 'try',
941
- '\f1e4' => 'tty',
942
- '\f173' => 'tumblr',
943
- '\f174' => 'tumblr-square',
944
- '\f195' => 'turkish-lira',
945
- '\f1e8' => 'twitch',
946
- '\f099' => 'twitter',
947
- '\f081' => 'twitter-square',
948
- '\f0e9' => 'umbrella',
949
- '\f0cd' => 'underline',
950
- '\f0e2' => 'undo',
951
- '\f19c' => 'university',
952
- '\f127' => 'unlink',
953
- '\f09c' => 'unlock',
954
- '\f13e' => 'unlock-alt',
955
- '\f0dc' => 'unsorted',
956
- '\f093' => 'upload',
957
- '\f155' => 'usd',
958
- '\f007' => 'user',
959
- '\f0f0' => 'user-md',
960
- '\f234' => 'user-plus',
961
- '\f21b' => 'user-secret',
962
- '\f235' => 'user-times',
963
- '\f0c0' => 'users',
964
- '\f221' => 'venus',
965
- '\f226' => 'venus-double',
966
- '\f228' => 'venus-mars',
967
- '\f237' => 'viacoin',
968
- '\f03d' => 'video-camera',
969
- '\f194' => 'vimeo-square',
970
- '\f1ca' => 'vine',
971
- '\f189' => 'vk',
972
- '\f027' => 'volume-down',
973
- '\f026' => 'volume-off',
974
- '\f028' => 'volume-up',
975
- '\f071' => 'warning',
976
- '\f1d7' => 'wechat',
977
- '\f18a' => 'weibo',
978
- '\f1d7' => 'weixin',
979
- '\f232' => 'whatsapp',
980
- '\f193' => 'wheelchair',
981
- '\f1eb' => 'wifi',
982
- '\f17a' => 'windows',
983
- '\f159' => 'won',
984
- '\f19a' => 'wordpress',
985
- '\f0ad' => 'wrench',
986
- '\f168' => 'xing',
987
- '\f169' => 'xing-square',
988
- '\f19e' => 'yahoo',
989
- '\f1e9' => 'yelp',
990
- '\f157' => 'yen',
991
- '\f167' => 'youtube',
992
- '\f16a' => 'youtube-play',
993
- '\f166' => 'youtube-square',
994
- ),
995
-
996
- 'awesome_icons_socials' =>array(
997
- 'f170' => 'adn',
998
- 'f17b' => 'android',
999
- 'f179' => 'apple',
1000
- 'f171' => 'bitbucket',
1001
- 'f171' => 'bitbucket-square',
1002
- 'f02e' => 'bookmark',
1003
- 'f097' => 'bookmark-o',
1004
- 'f15a' => 'btc',
1005
- 'f13c' => 'css3',
1006
- 'f17d' => 'dribble',
1007
- 'f16b' => 'dropbox',
1008
- 'f09a' => 'facebook',
1009
- 'f082' => 'facebook-square',
1010
- 'f16e' => 'flickr',
1011
- 'f180' => 'foursquare',
1012
- 'f09b'=> 'github' ,
1013
- 'f113'=> 'github-alt',
1014
- 'f092' => 'github-square',
1015
- 'f184' => 'gittip',
1016
- 'f0d5' => 'google-plus',
1017
- 'f0d4' => 'google-plus-square',
1018
- 'f13b' => 'html5',
1019
- 'f16d' => 'instagram',
1020
- 'f0e1' => 'linkedin',
1021
- 'f08c' => 'linkedin-square',
1022
- 'f17c' => 'Linux',
1023
- 'f136' => 'maxcdn',
1024
- 'f18c' => 'pagelines',
1025
- 'f0d2' => 'pinterest',
1026
- 'f0d3' => 'pinterest-square',
1027
- 'f18b' => 'renren',
1028
- 'f09e' => 'rss',
1029
- 'f17e' => 'skype',
1030
- 'f18d' => 'stack-exchange',
1031
- 'f16c' => 'stack-overflow',
1032
- 'f181' => 'trello',
1033
- 'f173' => 'tumblr',
1034
- 'f174' => 'Tumblr Square',
1035
- 'f099' => 'twitter',
1036
- 'f081' => 'twitter-square',
1037
- 'f194' => 'vimeo-square',
1038
- 'f189' => 'vk',
1039
- 'f18a' => 'weibo',
1040
- 'f17a' => 'windows',
1041
- 'f168' => 'xing',
1042
- 'f169' => 'xing-square',
1043
- 'f167' => 'youtube'
1044
- ),
1045
- 'header_backgrounds' => array(),
1046
- 'body_backgrounds' => array(),
1047
-
1048
- // tags used in theme options (e.g. %tag%) to have some common informations
1049
- 'tag' => array( //'themeurl' => get_template_directory_uri()
1050
- ),
1051
-
1052
- 'cycle_fx' => array(
1053
- 'blindX' => 'blindX', 'blindY' => 'blindY', 'blindZ' => 'blindZ', 'cover' => 'cover', 'curtainX' => 'curtainX',
1054
- 'curtainY' => 'curtainY', 'fade' => 'fade', 'fadeZoom' => 'fadeZoom', 'growX' => 'growX', 'growY' => 'growY',
1055
- 'scrollUp' => 'scrollUp', 'scrollDown' => 'scrollDown', 'scrollLeft' => 'scrollLeft', 'scrollRight' => 'scrollRight', 'scrollHorz' => 'scrollHorz',
1056
- 'shuffle' => 'shuffle', 'slideX' => 'slideX', 'slideY' => 'slideY', 'toss' => 'toss', 'turnUp' => 'turnUp',
1057
- 'turnLeft' => 'turnLeft', 'turnRight' => 'turnRight', 'uncover' => 'uncover', 'wipe' => 'wipe', 'zoom' => 'zoom',
1058
- 'none' => 'none', 'turnDown' => 'turnDown', 'scrollVert' => 'scrollVert'
1059
- ),
1060
-
1061
- 'animate' => array(
1062
- '' => "none",
1063
- "bounce" => "bounce",
1064
- "flash" =>"flash",
1065
- "pulse" =>"pulse",
1066
- //"rubberBand"=>"rubberBand",
1067
- "shake" =>"shake",
1068
- "swing"=>"swing",
1069
- "tada" =>"tada",
1070
- "wobble"=>"wobble",
1071
- "bounceIn"=>"bounceIn",
1072
- "bounceInDown"=>"bounceInDown",
1073
- "bounceInLeft"=>"bounceInLeft",
1074
- "bounceInRight"=>"bounceInRight",
1075
- "bounceInUp"=>"bounceInUp",
1076
- "fadeIn"=>"fadeIn",
1077
- "fadeInDown"=>"fadeInDown",
1078
- "fadeInDownBig"=>"fadeInDownBig",
1079
- "fadeInLeft"=>"fadeInLeft",
1080
- "fadeInLeftBig"=>"fadeInLeftBig",
1081
- "fadeInRight"=>"fadeInRight",
1082
- "fadeInRightBig"=>"fadeInRightBig",
1083
- "fadeInUp"=>"fadeInUp",
1084
- "fadeInUpBig"=>"fadeInUpBig",
1085
- "flip"=>"flip",
1086
- "flipInX"=>"flipInX",
1087
- "flipInY"=>"flipInY",
1088
- "lightSpeedIn"=>"lightSpeedIn",
1089
- "rotateIn"=>"rotateIn",
1090
- "rotateInDownLeft"=>"rotateInDownLeft",
1091
- "rotateInDownRight"=>"rotateInDownRight",
1092
- "rotateInUpLeft"=>"rotateInUpLeft",
1093
- "rotateInUpRight"=>"rotateInUpRight",
1094
- //"slideInDown"=>"slideInDown",
1095
- //"slideInLeft"=>"slideInLeft",
1096
- //"slideInRight"=>"slideInRight",
1097
- "rollIn"=>"rollIn",
1098
- ),
1099
-
1100
- 'easings' => array(
1101
- FALSE => 'none',
1102
- 'easeInQuad' => 'easeInQuad',
1103
- 'easeOutQuad' => 'easeOutQuad',
1104
- 'easeInOutQuad' => 'easeInOutQuad',
1105
- 'easeInCubic' => 'easeInCubic',
1106
- 'easeOutCubic' => 'easeOutCubic',
1107
- 'easeInOutCubic' => 'easeInOutCubic',
1108
- 'easeInQuart' => 'easeInQuart',
1109
- 'easeOutQuart' => 'easeOutQuart',
1110
- 'easeInOutQuart' => 'easeInOutQuart',
1111
- 'easeInQuint' => 'easeInQuint',
1112
- 'easeOutQuint' => 'easeOutQuint',
1113
- 'easeInOutQuint' => 'easeInOutQuint',
1114
- 'easeInSine' => 'easeInSine',
1115
- 'easeOutSine' => 'easeOutSine',
1116
- 'easeInOutSine' => 'easeInOutSine',
1117
- 'easeInExpo' => 'easeInExpo',
1118
- 'easeOutExpo' => 'easeOutExpo',
1119
- 'easeInOutExpo' => 'easeInOutExpo',
1120
- 'easeInCirc' => 'easeInCirc',
1121
- 'easeOutCirc' => 'easeOutCirc',
1122
- 'easeInOutCirc' => 'easeInOutCirc',
1123
- 'easeInElastic' => 'easeInElastic',
1124
- 'easeOutElastic' => 'easeOutElastic',
1125
- 'easeInOutElastic' => 'easeInOutElastic',
1126
- 'easeInBack' => 'easeInBack',
1127
- 'easeOutBack' => 'easeOutBack',
1128
- 'easeInOutBack' => 'easeInOutBack',
1129
- 'easeInBounce' => 'easeInBounce',
1130
- 'easeOutBounce' => 'easeOutBounce',
1131
- 'easeInOutBounce' => 'easeInOutBounce'
1132
- )
1133
- );
1134
-
1135
- /**
1136
- * Get configuration array
1137
- *
1138
- * @return array
1139
- */
1140
- public static function load() {
1141
- self::_loadThemeInfo();
1142
- //ksort( self::$_config['awesome_icons'] );
1143
-
1144
- return self::$_config;
1145
- }
1146
-
1147
- /**
1148
- * Return theme data
1149
- *
1150
- * First the method checks if the wp_get_theme() function exists (WP 3.4.0 at least).
1151
- * If not, the method calls the deprecated function get_template_directory()
1152
- *
1153
- * @return array
1154
- */
1155
- protected static function _loadThemeInfo() {
1156
- $theme = wp_get_theme();
1157
-
1158
- self::$_config['theme'] = array(
1159
- 'name' => $theme->Name,
1160
- 'description' => $theme->Description,
1161
- 'author' => $theme->Author,
1162
- 'authoruri' => $theme->{'Author URI'},
1163
- 'version' => $theme->Version,
1164
- 'template' => $theme->Template,
1165
- 'status' => $theme->Status,
1166
- 'tags' => $theme->Tags
1167
- );
1168
- }
1169
-
1170
-
1171
- public function init() {
1172
- self::$_config['header_backgrounds'] = apply_filters( 'yit_header_backgrounds', self::$_config['header_backgrounds'] );
1173
- self::$_config['body_backgrounds'] = apply_filters( 'yit_body_backgrounds', self::$_config['body_backgrounds'] );
1174
- }
1175
-
1176
- /**
1177
- * Return the font awesome array icon
1178
- *
1179
- * @return string Array
1180
- * @access public
1181
- * @since 1.0.0
1182
- */
1183
- public static function get_awesome_icons() {
1184
- return self::$_config['awesome_icons'];
1185
- }
1186
-
1187
- /**
1188
- * Return the font awesome array socials icon
1189
- *
1190
- * @return string Array
1191
- * @access public
1192
- * @since 1.0.0
1193
- */
1194
- public static function get_awesome_icons_socials() {
1195
- return self::$_config['awesome_icons_socials'];
1196
- }
1197
-
1198
-
1199
- /**
1200
- * Return the list of icons
1201
- *
1202
- * @return string Array
1203
- * @access public
1204
- * @since 1.0.0
1205
- */
1206
- public static function get_icon_list() {
1207
-
1208
- $standard_icon_list = array(
1209
- 'FontAwesome' => self::$_config['awesome_icons2']
1210
- );
1211
-
1212
- return apply_filters( 'yit_icon_list', $standard_icon_list );
1213
- }
1214
-
1215
- /**
1216
- * Return the data of icon
1217
- *
1218
- * @return string Array
1219
- * @access public
1220
- * @since 1.0.0
1221
- */
1222
- public static function get_icon( $icon ) {
1223
-
1224
- $icon_list = self::get_icon_list();
1225
- $icon_data = '';
1226
- if ( $icon != '' ) {
1227
- $ic = explode( ':', $icon );
1228
- $icon_code = array_search( $ic[1], $icon_list[$ic[0]] );
1229
-
1230
- if( $icon_code ){
1231
- $icon_code = ( strpos( $icon_code, '\\' ) === 0 ) ? '&#x' . substr( $icon_code, 1 ) . ';' : $icon_code;
1232
- }
1233
-
1234
- $icon_data = 'data-font="' . $ic[0] . '" data-key="' . $ic[1] . '" data-icon="' . $icon_code . '"';
1235
- }
1236
-
1237
- return $icon_data;
1238
- }
1239
-
1240
-
1241
- /*
1242
- * Return the code of the relative awesome class name
1243
- *
1244
- * @return string
1245
- * @access public
1246
- * @since 1.0.0
1247
- */
1248
- public static function get_awesome_icons_code_by_value($class){
1249
- $awesome_icons=self::$_config['awesome_icons'];
1250
- foreach($awesome_icons as $key => $value){
1251
- if($class==$value) {
1252
- return $key;
1253
- }
1254
- }
1255
-
1256
- return "";
1257
- }
1258
- }
1259
-
1260
  endif;
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! class_exists( 'YIT_Plugin_Common' ) ) :
12
+
13
+ /**
14
+ * Core configuration class
15
+ *
16
+ * @since 1.0.0
17
+ */
18
+ class YIT_Plugin_Common {
19
+
20
+ /**
21
+ * Config array
22
+ *
23
+ * @var array
24
+ */
25
+ protected static $_config = array(
26
+ 'slider' => array( 'nivo', 'elegant' ),
27
+
28
+
29
+ 'awesome_icons' => array(
30
+ '' => 'no-icon',
31
+ 'f042' => 'adjust',
32
+ 'f170' => 'adn',
33
+ 'f037' => 'align-center',
34
+ 'f039' => 'align-justify',
35
+ 'f036' => 'align-left',
36
+ 'f038' => 'align-right',
37
+ 'f0f9' => 'ambulance',
38
+ 'f13d' => 'anchor',
39
+ 'f17b' => 'android',
40
+ 'f103' => 'angle-double-down',
41
+ 'f100' => 'angle-double-left',
42
+ 'f101' => 'angle-double-right',
43
+ 'f102' => 'angle-double-up',
44
+ 'f107' => 'angle-down',
45
+ 'f104' => 'angle-left',
46
+ 'f105' => 'angle-right',
47
+ 'f106' => 'angle-up',
48
+ 'f179' => 'apple',
49
+ 'f187' => 'archive',
50
+ 'f0ab' => 'arrow-circle-down',
51
+ 'f0a8' => 'arrow-circle-left',
52
+ 'f01a' => 'arrow-circle-o-down',
53
+ 'f190' => 'arrow-circle-o-left',
54
+ 'f18e' => 'arrow-circle-o-right',
55
+ 'f01b' => 'arrow-circle-o-up',
56
+ 'f0a9' => 'arrow-circle-right',
57
+ 'f0aa' => 'arrow-circle-up',
58
+ 'f063' => 'arrow-down',
59
+ 'f060' => 'arrow-left',
60
+ 'f061' => 'arrow-right',
61
+ 'f062' => 'arrow-up',
62
+ 'f047' => 'arrows',
63
+ 'f0b2' => 'arrows-alt',
64
+ 'f07e' => 'arrows-h',
65
+ 'f07d' => 'arrows-v',
66
+ 'f069' => 'asterisk',
67
+ 'f04a' => 'backward',
68
+ 'f05e' => 'ban',
69
+ 'f080' => 'bar-chart-o',
70
+ 'f02a' => 'barcode',
71
+ 'f0c9' => 'bars',
72
+ 'f0fc' => 'beer',
73
+ 'f0f3' => 'bell',
74
+ 'f0a2' => 'bell-o',
75
+ 'f171' => 'bitbucket',
76
+ 'f172' => 'bitbucket-square',
77
+ 'f032' => 'bold',
78
+ 'f0e7' => 'bolt',
79
+ 'f02d' => 'book',
80
+ 'f02e' => 'bookmark',
81
+ 'f097' => 'bookmark-o',
82
+ 'f0b1' => 'briefcase',
83
+ 'f15a' => 'btc',
84
+ 'f188' => 'bug',
85
+ 'f0f7' => 'building-o',
86
+ 'f0a1' => 'bullhorn',
87
+ 'f140' => 'bullseye',
88
+ 'f073' => 'calendar',
89
+ 'f133' => 'calendar-o',
90
+ 'f030' => 'camera',
91
+ 'f083' => 'camera-retro',
92
+ 'f0d7' => 'caret-down',
93
+ 'f0d9' => 'caret-left',
94
+ 'f0da' => 'caret-right',
95
+ 'f150' => 'caret-square-o-down',
96
+ 'f191' => 'caret-square-o-left',
97
+ 'f152' => 'caret-square-o-right',
98
+ 'f151' => 'caret-square-o-up',
99
+ 'f0d8' => 'caret-up',
100
+ 'f0a3' => 'certificate',
101
+ 'f127' => 'chain-broken',
102
+ 'f00c' => 'check',
103
+ 'f058' => 'check-circle',
104
+ 'f05d' => 'check-circle-o',
105
+ 'f14a' => 'check-square',
106
+ 'f046' => 'check-square-o',
107
+ 'f13a' => 'chevron-circle-down',
108
+ 'f137' => 'chevron-circle-left',
109
+ 'f138' => 'chevron-circle-right',
110
+ 'f139' => 'chevron-circle-up',
111
+ 'f078' => 'chevron-down',
112
+ 'f053' => 'chevron-left',
113
+ 'f054' => 'chevron-right',
114
+ 'f077' => 'chevron-up',
115
+ 'f10c' => 'circle-o',
116
+ 'f0ea' => 'clipboard',
117
+ 'f017' => 'clock-o',
118
+ 'f0c2' => 'cloud',
119
+ 'f0ed' => 'cloud-download',
120
+ 'f0ee' => 'cloud-upload',
121
+ 'f121' => 'code',
122
+ 'f126' => 'code-fork',
123
+ 'f0f4' => 'coffee',
124
+ 'f013' => 'cog',
125
+ 'f085' => 'cogs',
126
+ 'f0db' => 'columns',
127
+ 'f075' => 'comment',
128
+ 'f0e5' => 'comment-o',
129
+ 'f086' => 'comments',
130
+ 'f0e6' => 'comments-o',
131
+ 'f14e' => 'compass',
132
+ 'f066' => 'compress',
133
+ 'f09d' => 'credit-card',
134
+ 'f125' => 'crop',
135
+ 'f05b' => 'crosshairs',
136
+ 'f13c' => 'css3',
137
+ 'f0f5' => 'cutlery',
138
+ 'f108' => 'desktop',
139
+ 'f192' => 'dot-circle-o',
140
+ 'f019' => 'download',
141
+ 'f17d' => 'dribbble',
142
+ 'f16b' => 'dropbox',
143
+ 'f052' => 'eject',
144
+ 'f141' => 'ellipsis-h',
145
+ 'f142' => 'ellipsis-v',
146
+ 'f0e0' => 'envelope',
147
+ 'f003' => 'envelope-o',
148
+ 'f12d' => 'eraser',
149
+ 'f153' => 'eur',
150
+ 'f0ec' => 'exchange',
151
+ 'f12a' => 'exclamation',
152
+ 'f06a' => 'exclamation-circle',
153
+ 'f071' => 'exclamation-triangle',
154
+ 'f065' => 'expand',
155
+ 'f08e' => 'external-link',
156
+ 'f14c' => 'external-link-square',
157
+ 'f06e' => 'eye',
158
+ 'f070' => 'eye-slash',
159
+ 'f09a' => 'facebook',
160
+ 'f082' => 'facebook-square',
161
+ 'f049' => 'fast-backward',
162
+ 'f050' => 'fast-forward',
163
+ 'f182' => 'female',
164
+ 'f0fb' => 'fighter-jet',
165
+ 'f15b' => 'file',
166
+ 'f016' => 'file-o',
167
+ 'f15c' => 'file-text',
168
+ 'f0f6' => 'file-text-o',
169
+ 'f0c5' => 'files-o',
170
+ 'f008' => 'film',
171
+ 'f0b0' => 'filter',
172
+ 'f06d' => 'fire',
173
+ 'f134' => 'fire-extinguisher',
174
+ 'f024' => 'flag',
175
+ 'f11e' => 'flag-checkered',
176
+ 'f11d' => 'flag-o',
177
+ 'f0c3' => 'flask',
178
+ 'f16e' => 'flickr',
179
+ 'f0c7' => 'floppy-o',
180
+ 'f07b' => 'folder',
181
+ 'f114' => 'folder-o',
182
+ 'f07c' => 'folder-open',
183
+ 'f115' => 'folder-open-o',
184
+ 'f031' => 'font',
185
+ 'f04e' => 'forward',
186
+ 'f180' => 'foursquare',
187
+ 'f119' => 'frown-o',
188
+ 'f11b' => 'gamepad',
189
+ 'f0e3' => 'gavel',
190
+ 'f154' => 'gbp',
191
+ 'f06b' => 'gift',
192
+ 'f09b' => 'github',
193
+ 'f113' => 'github-alt',
194
+ 'f092' => 'github-square',
195
+ 'f184' => 'gittip',
196
+ 'f000' => 'glass',
197
+ 'f0ac' => 'globe',
198
+ 'f0d5' => 'google-plus',
199
+ 'f0d4' => 'google-plus-square',
200
+ 'f0fd' => 'h-square',
201
+ 'f0a7' => 'hand-o-down',
202
+ 'f0a5' => 'hand-o-left',
203
+ 'f0a4' => 'hand-o-right',
204
+ 'f0a6' => 'hand-o-up',
205
+ 'f0a0' => 'hdd-o',
206
+ 'f025' => 'headphones',
207
+ 'f004' => 'heart',
208
+ 'f08a' => 'heart-o',
209
+ 'f015' => 'home',
210
+ 'f0f8' => 'hospital-o',
211
+ 'f13b' => 'html5',
212
+ 'f01c' => 'inbox',
213
+ 'f03c' => 'indent',
214
+ 'f129' => 'info',
215
+ 'f05a' => 'info-circle',
216
+ 'f156' => 'inr',
217
+ 'f16d' => 'instagram',
218
+ 'f033' => 'italic',
219
+ 'f157' => 'jpy',
220
+ 'f084' => 'key',
221
+ 'f11c' => 'keyboard-o',
222
+ 'f159' => 'krw',
223
+ 'f109' => 'laptop',
224
+ 'f06c' => 'leaf',
225
+ 'f094' => 'lemon-o',
226
+ 'f149' => 'level-down',
227
+ 'f148' => 'level-up',
228
+ 'f0eb' => 'lightbulb-o',
229
+ 'f0c1' => 'link',
230
+ 'f0e1' => 'linkedin',
231
+ 'f08c' => 'linkedin-square',
232
+ 'f17c' => 'linux',
233
+ 'f03a' => 'list',
234
+ 'f022' => 'list-alt',
235
+ 'f0cb' => 'list-ol',
236
+ 'f0ca' => 'list-ul',
237
+ 'f124' => 'location-arrow',
238
+ 'f023' => 'lock',
239
+ 'f175' => 'long-arrow-down',
240
+ 'f177' => 'long-arrow-left',
241
+ 'f178' => 'long-arrow-right',
242
+ 'f176' => 'long-arrow-up',
243
+ 'f0d0' => 'magic',
244
+ 'f076' => 'magnet',
245
+ 'f122' => 'mail-reply-all',
246
+ 'f183' => 'male',
247
+ 'f041' => 'map-marker',
248
+ 'f136' => 'maxcdn',
249
+ 'f0fa' => 'medkit',
250
+ 'f11a' => 'meh-o',
251
+ 'f130' => 'microphone',
252
+ 'f131' => 'microphone-slash',
253
+ 'f068' => 'minus',
254
+ 'f056' => 'minus-circle',
255
+ 'f146' => 'minus-square',
256
+ 'f147' => 'minus-square-o',
257
+ 'f10b' => 'mobile',
258
+ 'f0d6' => 'money',
259
+ 'f186' => 'moon-o',
260
+ 'f001' => 'music',
261
+ 'f03b' => 'outdent',
262
+ 'f18c' => 'pagelines',
263
+ 'f0c6' => 'paperclip',
264
+ 'f04c' => 'pause',
265
+ 'f040' => 'pencil',
266
+ 'f14b' => 'pencil-square',
267
+ 'f044' => 'pencil-square-o',
268
+ 'f095' => 'phone',
269
+ 'f098' => 'phone-square',
270
+ 'f03e' => 'picture-o',
271
+ 'f0d2' => 'pinterest',
272
+ 'f0d3' => 'pinterest-square',
273
+ 'f072' => 'plane',
274
+ 'f04b' => 'play',
275
+ 'f144' => 'play-circle',
276
+ 'f01d' => 'play-circle-o',
277
+ 'f067' => 'plus',
278
+ 'f055' => 'plus-circle',
279
+ 'f0fe' => 'plus-square',
280
+ 'f196' => 'plus-square-o',
281
+ 'f011' => 'power-off',
282
+ 'f02f' => 'print',
283
+ 'f12e' => 'puzzle-piece',
284
+ 'f029' => 'qrcode',
285
+ 'f128' => 'question',
286
+ 'f059' => 'question-circle',
287
+ 'f10d' => 'quote-left',
288
+ 'f10e' => 'quote-right',
289
+ 'f074' => 'random',
290
+ 'f021' => 'refresh',
291
+ 'f18b' => 'renren',
292
+ 'f01e' => 'repeat',
293
+ 'f112' => 'reply',
294
+ 'f122' => 'reply-all',
295
+ 'f079' => 'retweet',
296
+ 'f018' => 'road',
297
+ 'f135' => 'rocket',
298
+ 'f09e' => 'rss',
299
+ 'f143' => 'rss-square',
300
+ 'f158' => 'rub',
301
+ 'f0c4' => 'scissors',
302
+ 'f002' => 'search',
303
+ 'f010' => 'search-minus',
304
+ 'f00e' => 'search-plus',
305
+ 'f064' => 'share',
306
+ 'f14d' => 'share-square',
307
+ 'f045' => 'share-square-o',
308
+ 'f132' => 'shield',
309
+ 'f07a' => 'shopping-cart',
310
+ 'f090' => 'sign-in',
311
+ 'f08b' => 'sign-out',
312
+ 'f012' => 'signal',
313
+ 'f0e8' => 'sitemap',
314
+ 'f17e' => 'skype',
315
+ 'f118' => 'smile-o',
316
+ 'f0dc' => 'sort',
317
+ 'f15d' => 'sort-alpha-asc',
318
+ 'f15e' => 'sort-alpha-desc',
319
+ 'f160' => 'sort-amount-asc',
320
+ 'f161' => 'sort-amount-desc',
321
+ 'f0dd' => 'sort-asc',
322
+ 'f0de' => 'sort-desc',
323
+ 'f162' => 'sort-numeric-asc',
324
+ 'f163' => 'sort-numeric-desc',
325
+ 'f110' => 'spinner',
326
+ 'f0c8' => 'square',
327
+ 'f096' => 'square-o',
328
+ 'f18d' => 'stack-exchange',
329
+ 'f16c' => 'stack-overflow',
330
+ 'f005' => 'star',
331
+ 'f089' => 'star-half',
332
+ 'f123' => 'star-half-o',
333
+ 'f006' => 'star-o',
334
+ 'f048' => 'step-backward',
335
+ 'f051' => 'step-forward',
336
+ 'f0f1' => 'stethoscope',
337
+ 'f04d' => 'stop',
338
+ 'f0cc' => 'strikethrough',
339
+ 'f12c' => 'subscript',
340
+ 'f0f2' => 'suitcase',
341
+ 'f185' => 'sun-o',
342
+ 'f12b' => 'superscript',
343
+ 'f0ce' => 'table',
344
+ 'f10a' => 'tablet',
345
+ 'f0e4' => 'tachometer',
346
+ 'f02b' => 'tag',
347
+ 'f02c' => 'tags',
348
+ 'f0ae' => 'tasks',
349
+ 'f120' => 'terminal',
350
+ 'f034' => 'text-height',
351
+ 'f035' => 'text-width',
352
+ 'f00a' => 'th',
353
+ 'f009' => 'th-large',
354
+ 'f00b' => 'th-list',
355
+ 'f08d' => 'thumb-tack',
356
+ 'f165' => 'thumbs-down',
357
+ 'f088' => 'thumbs-o-down',
358
+ 'f087' => 'thumbs-o-up',
359
+ 'f164' => 'thumbs-up',
360
+ 'f145' => 'ticket',
361
+ 'f00d' => 'times',
362
+ 'f057' => 'times-circle',
363
+ 'f05c' => 'times-circle-o',
364
+ 'f043' => 'tint',
365
+ 'f014' => 'trash-o',
366
+ 'f181' => 'trello',
367
+ 'f091' => 'trophy',
368
+ 'f0d1' => 'truck',
369
+ 'f195' => 'try',
370
+ 'f173' => 'tumblr',
371
+ 'f174' => 'tumblr-square',
372
+ 'f099' => 'twitter',
373
+ 'f081' => 'twitter-square',
374
+ 'f0e9' => 'umbrella',
375
+ 'f0cd' => 'underline',
376
+ 'f0e2' => 'undo',
377
+ 'f09c' => 'unlock',
378
+ 'f13e' => 'unlock-alt',
379
+ 'f093' => 'upload',
380
+ 'f155' => 'usd',
381
+ 'f007' => 'user',
382
+ 'f0f0' => 'user-md',
383
+ 'f0c0' => 'users',
384
+ 'f03d' => 'video-camera',
385
+ 'f194' => 'vimeo-square',
386
+ 'f189' => 'vk',
387
+ 'f027' => 'volume-down',
388
+ 'f026' => 'volume-off',
389
+ 'f028' => 'volume-up',
390
+ 'f18a' => 'weibo',
391
+ 'f193' => 'wheelchair',
392
+ 'f17a' => 'windows',
393
+ 'f0ad' => 'wrench',
394
+ 'f168' => 'xing',
395
+ 'f169' => 'xing-square',
396
+ 'f167' => 'youtube',
397
+ 'f16a' => 'youtube-play',
398
+ 'f166' => 'youtube-square'
399
+ ),
400
+ 'awesome_icons2' => array(
401
+ '\f042' => 'adjust',
402
+ '\f170' => 'adn',
403
+ '\f037' => 'align-center',
404
+ '\f039' => 'align-justify',
405
+ '\f036' => 'align-left',
406
+ '\f038' => 'align-right',
407
+ '\f0f9' => 'ambulance',
408
+ '\f13d' => 'anchor',
409
+ '\f17b' => 'android',
410
+ '\f209' => 'angellist',
411
+ '\f103' => 'angle-double-down',
412
+ '\f100' => 'angle-double-left',
413
+ '\f101' => 'angle-double-right',
414
+ '\f102' => 'angle-double-up',
415
+ '\f107' => 'angle-down',
416
+ '\f104' => 'angle-left',
417
+ '\f105' => 'angle-right',
418
+ '\f106' => 'angle-up',
419
+ '\f179' => 'apple',
420
+ '\f187' => 'archive',
421
+ '\f1fe' => 'area-chart',
422
+ '\f0ab' => 'arrow-circle-down',
423
+ '\f0a8' => 'arrow-circle-left',
424
+ '\f01a' => 'arrow-circle-o-down',
425
+ '\f190' => 'arrow-circle-o-left',
426
+ '\f18e' => 'arrow-circle-o-right',
427
+ '\f01b' => 'arrow-circle-o-up',
428
+ '\f0a9' => 'arrow-circle-right',
429
+ '\f0aa' => 'arrow-circle-up',
430
+ '\f063' => 'arrow-down',
431
+ '\f060' => 'arrow-left',
432
+ '\f061' => 'arrow-right',
433
+ '\f062' => 'arrow-up',
434
+ '\f047' => 'arrows',
435
+ '\f0b2' => 'arrows-alt',
436
+ '\f07e' => 'arrows-h',
437
+ '\f07d' => 'arrows-v',
438
+ '\f069' => 'asterisk',
439
+ '\f1fa' => 'at',
440
+ '\f1b9' => 'automobile',
441
+ '\f04a' => 'backward',
442
+ '\f05e' => 'ban',
443
+ '\f19c' => 'bank',
444
+ '\f080' => 'bar-chart',
445
+ '\f080' => 'bar-chart-o',
446
+ '\f02a' => 'barcode',
447
+ '\f0c9' => 'bars',
448
+ '\f236' => 'bed',
449
+ '\f0fc' => 'beer',
450
+ '\f1b4' => 'behance',
451
+ '\f1b5' => 'behance-square',
452
+ '\f0f3' => 'bell',
453
+ '\f0a2' => 'bell-o',
454
+ '\f1f6' => 'bell-slash',
455
+ '\f1f7' => 'bell-slash-o',
456
+ '\f206' => 'bicycle',
457
+ '\f1e5' => 'binoculars',
458
+ '\f1fd' => 'birthday-cake',
459
+ '\f171' => 'bitbucket',
460
+ '\f172' => 'bitbucket-square',
461
+ '\f15a' => 'bitcoin',
462
+ '\f032' => 'bold',
463
+ '\f0e7' => 'bolt',
464
+ '\f1e2' => 'bomb',
465
+ '\f02d' => 'book',
466
+ '\f02e' => 'bookmark',
467
+ '\f097' => 'bookmark-o',
468
+ '\f0b1' => 'briefcase',
469
+ '\f15a' => 'btc',
470
+ '\f188' => 'bug',
471
+ '\f1ad' => 'building',
472
+ '\f0f7' => 'building-o',
473
+ '\f0a1' => 'bullhorn',
474
+ '\f140' => 'bullseye',
475
+ '\f207' => 'bus',
476
+ '\f20d' => 'buysellads',
477
+ '\f1ba' => 'cab',
478
+ '\f1ec' => 'calculator',
479
+ '\f073' => 'calendar',
480
+ '\f133' => 'calendar-o',
481
+ '\f030' => 'camera',
482
+ '\f083' => 'camera-retro',
483
+ '\f1b9' => 'car',
484
+ '\f0d7' => 'caret-down',
485
+ '\f0d9' => 'caret-left',
486
+ '\f0da' => 'caret-right',
487
+ '\f150' => 'caret-square-o-down',
488
+ '\f191' => 'caret-square-o-left',
489
+ '\f152' => 'caret-square-o-right',
490
+ '\f151' => 'caret-square-o-up',
491
+ '\f0d8' => 'caret-up',
492
+ '\f218' => 'cart-arrow-down',
493
+ '\f217' => 'cart-plus',
494
+ '\f20a' => 'cc',
495
+ '\f1f3' => 'cc-amex',
496
+ '\f1f2' => 'cc-discover',
497
+ '\f1f1' => 'cc-mastercard',
498
+ '\f1f4' => 'cc-paypal',
499
+ '\f1f5' => 'cc-stripe',
500
+ '\f1f0' => 'cc-visa',
501
+ '\f0a3' => 'certificate',
502
+ '\f0c1' => 'chain',
503
+ '\f127' => 'chain-broken',
504
+ '\f00c' => 'check',
505
+ '\f058' => 'check-circle',
506
+ '\f05d' => 'check-circle-o',
507
+ '\f14a' => 'check-square',
508
+ '\f046' => 'check-square-o',
509
+ '\f13a' => 'chevron-circle-down',
510
+ '\f137' => 'chevron-circle-left',
511
+ '\f138' => 'chevron-circle-right',
512
+ '\f139' => 'chevron-circle-up',
513
+ '\f078' => 'chevron-down',
514
+ '\f053' => 'chevron-left',
515
+ '\f054' => 'chevron-right',
516
+ '\f077' => 'chevron-up',
517
+ '\f1ae' => 'child',
518
+ '\f111' => 'circle',
519
+ '\f10c' => 'circle-o',
520
+ '\f1ce' => 'circle-o-notch',
521
+ '\f1db' => 'circle-thin',
522
+ '\f0ea' => 'clipboard',
523
+ '\f017' => 'clock-o',
524
+ '\f00d' => 'close',
525
+ '\f0c2' => 'cloud',
526
+ '\f0ed' => 'cloud-download',
527
+ '\f0ee' => 'cloud-upload',
528
+ '\f157' => 'cny',
529
+ '\f121' => 'code',
530
+ '\f126' => 'code-fork',
531
+ '\f1cb' => 'codepen',
532
+ '\f0f4' => 'coffee',
533
+ '\f013' => 'cog',
534
+ '\f085' => 'cogs',
535
+ '\f0db' => 'columns',
536
+ '\f075' => 'comment',
537
+ '\f0e5' => 'comment-o',
538
+ '\f086' => 'comments',
539
+ '\f0e6' => 'comments-o',
540
+ '\f14e' => 'compass',
541
+ '\f066' => 'compress',
542
+ '\f20e' => 'connectdevelop',
543
+ '\f0c5' => 'copy',
544
+ '\f1f9' => 'copyright',
545
+ '\f09d' => 'credit-card',
546
+ '\f125' => 'crop',
547
+ '\f05b' => 'crosshairs',
548
+ '\f13c' => 'css3',
549
+ '\f1b2' => 'cube',
550
+ '\f1b3' => 'cubes',
551
+ '\f0c4' => 'cut',
552
+ '\f0f5' => 'cutlery',
553
+ '\f0e4' => 'dashboard',
554
+ '\f210' => 'dashcube',
555
+ '\f1c0' => 'database',
556
+ '\f03b' => 'dedent',
557
+ '\f1a5' => 'delicious',
558
+ '\f108' => 'desktop',
559
+ '\f1bd' => 'deviantart',
560
+ '\f219' => 'diamond',
561
+ '\f1a6' => 'digg',
562
+ '\f155' => 'dollar',
563
+ '\f192' => 'dot-circle-o',
564
+ '\f019' => 'download',
565
+ '\f17d' => 'dribbble',
566
+ '\f16b' => 'dropbox',
567
+ '\f1a9' => 'drupal',
568
+ '\f044' => 'edit',
569
+ '\f052' => 'eject',
570
+ '\f141' => 'ellipsis-h',
571
+ '\f142' => 'ellipsis-v',
572
+ '\f1d1' => 'empire',
573
+ '\f0e0' => 'envelope',
574
+ '\f003' => 'envelope-o',
575
+ '\f199' => 'envelope-square',
576
+ '\f12d' => 'eraser',
577
+ '\f153' => 'eur',
578
+ '\f153' => 'euro',
579
+ '\f0ec' => 'exchange',
580
+ '\f12a' => 'exclamation',
581
+ '\f06a' => 'exclamation-circle',
582
+ '\f071' => 'exclamation-triangle',
583
+ '\f065' => 'expand',
584
+ '\f08e' => 'external-link',
585
+ '\f14c' => 'external-link-square',
586
+ '\f06e' => 'eye',
587
+ '\f070' => 'eye-slash',
588
+ '\f1fb' => 'eyedropper',
589
+ '\f09a' => 'facebook',
590
+ '\f09a' => 'facebook-f',
591
+ '\f230' => 'facebook-official',
592
+ '\f082' => 'facebook-square',
593
+ '\f049' => 'fast-backward',
594
+ '\f050' => 'fast-forward',
595
+ '\f1ac' => 'fax',
596
+ '\f182' => 'female',
597
+ '\f0fb' => 'fighter-jet',
598
+ '\f15b' => 'file',
599
+ '\f1c6' => 'file-archive-o',
600
+ '\f1c7' => 'file-audio-o',
601
+ '\f1c9' => 'file-code-o',
602
+ '\f1c3' => 'file-excel-o',
603
+ '\f1c5' => 'file-image-o',
604
+ '\f1c8' => 'file-movie-o',
605
+ '\f016' => 'file-o',
606
+ '\f1c1' => 'file-pdf-o',
607
+ '\f1c5' => 'file-photo-o',
608
+ '\f1c5' => 'file-picture-o',
609
+ '\f1c4' => 'file-powerpoint-o',
610
+ '\f1c7' => 'file-sound-o',
611
+ '\f15c' => 'file-text',
612
+ '\f0f6' => 'file-text-o',
613
+ '\f1c8' => 'file-video-o',
614
+ '\f1c2' => 'file-word-o',
615
+ '\f1c6' => 'file-zip-o',
616
+ '\f0c5' => 'files-o',
617
+ '\f008' => 'film',
618
+ '\f0b0' => 'filter',
619
+ '\f06d' => 'fire',
620
+ '\f134' => 'fire-extinguisher',
621
+ '\f024' => 'flag',
622
+ '\f11e' => 'flag-checkered',
623
+ '\f11d' => 'flag-o',
624
+ '\f0e7' => 'flash',
625
+ '\f0c3' => 'flask',
626
+ '\f16e' => 'flickr',
627
+ '\f0c7' => 'floppy-o',
628
+ '\f07b' => 'folder',
629
+ '\f114' => 'folder-o',
630
+ '\f07c' => 'folder-open',
631
+ '\f115' => 'folder-open-o',
632
+ '\f031' => 'font',
633
+ '\f211' => 'forumbee',
634
+ '\f04e' => 'forward',
635
+ '\f180' => 'foursquare',
636
+ '\f119' => 'frown-o',
637
+ '\f1e3' => 'futbol-o',
638
+ '\f11b' => 'gamepad',
639
+ '\f0e3' => 'gavel',
640
+ '\f154' => 'gbp',
641
+ '\f1d1' => 'ge',
642
+ '\f013' => 'gear',
643
+ '\f085' => 'gears',
644
+ '\f1db' => 'genderless',
645
+ '\f06b' => 'gift',
646
+ '\f1d3' => 'git',
647
+ '\f1d2' => 'git-square',
648
+ '\f09b' => 'github',
649
+ '\f113' => 'github-alt',
650
+ '\f092' => 'github-square',
651
+ '\f184' => 'gittip',
652
+ '\f000' => 'glass',
653
+ '\f0ac' => 'globe',
654
+ '\f1a0' => 'google',
655
+ '\f0d5' => 'google-plus',
656
+ '\f0d4' => 'google-plus-square',
657
+ '\f1ee' => 'google-wallet',
658
+ '\f19d' => 'graduation-cap',
659
+ '\f184' => 'gratipay',
660
+ '\f0c0' => 'group',
661
+ '\f0fd' => 'h-square',
662
+ '\f1d4' => 'hacker-news',
663
+ '\f0a7' => 'hand-o-down',
664
+ '\f0a5' => 'hand-o-left',
665
+ '\f0a4' => 'hand-o-right',
666
+ '\f0a6' => 'hand-o-up',
667
+ '\f0a0' => 'hdd-o',
668
+ '\f1dc' => 'header',
669
+ '\f025' => 'headphones',
670
+ '\f004' => 'heart',
671
+ '\f08a' => 'heart-o',
672
+ '\f21e' => 'heartbeat',
673
+ '\f1da' => 'history',
674
+ '\f015' => 'home',
675
+ '\f0f8' => 'hospital-o',
676
+ '\f236' => 'hotel',
677
+ '\f13b' => 'html5',
678
+ '\f20b' => 'ils',
679
+ '\f03e' => 'image',
680
+ '\f01c' => 'inbox',
681
+ '\f03c' => 'indent',
682
+ '\f129' => 'info',
683
+ '\f05a' => 'info-circle',
684
+ '\f156' => 'inr',
685
+ '\f16d' => 'instagram',
686
+ '\f19c' => 'institution',
687
+ '\f208' => 'ioxhost',
688
+ '\f033' => 'italic',
689
+ '\f1aa' => 'joomla',
690
+ '\f157' => 'jpy',
691
+ '\f1cc' => 'jsfiddle',
692
+ '\f084' => 'key',
693
+ '\f11c' => 'keyboard-o',
694
+ '\f159' => 'krw',
695
+ '\f1ab' => 'language',
696
+ '\f109' => 'laptop',
697
+ '\f202' => 'lastfm',
698
+ '\f203' => 'lastfm-square',
699
+ '\f06c' => 'leaf',
700
+ '\f212' => 'leanpub',
701
+ '\f0e3' => 'legal',
702
+ '\f094' => 'lemon-o',
703
+ '\f149' => 'level-down',
704
+ '\f148' => 'level-up',
705
+ '\f1cd' => 'life-bouy',
706
+ '\f1cd' => 'life-buoy',
707
+ '\f1cd' => 'life-ring',
708
+ '\f1cd' => 'life-saver',
709
+ '\f0eb' => 'lightbulb-o',
710
+ '\f201' => 'line-chart',
711
+ '\f0c1' => 'link',
712
+ '\f0e1' => 'linkedin',
713
+ '\f08c' => 'linkedin-square',
714
+ '\f17c' => 'linux',
715
+ '\f03a' => 'list',
716
+ '\f022' => 'list-alt',
717
+ '\f0cb' => 'list-ol',
718
+ '\f0ca' => 'list-ul',
719
+ '\f124' => 'location-arrow',
720
+ '\f023' => 'lock',
721
+ '\f175' => 'long-arrow-down',
722
+ '\f177' => 'long-arrow-left',
723
+ '\f178' => 'long-arrow-right',
724
+ '\f176' => 'long-arrow-up',
725
+ '\f0d0' => 'magic',
726
+ '\f076' => 'magnet',
727
+ '\f064' => 'mail-forward',
728
+ '\f112' => 'mail-reply',
729
+ '\f122' => 'mail-reply-all',
730
+ '\f183' => 'male',
731
+ '\f041' => 'map-marker',
732
+ '\f222' => 'mars',
733
+ '\f227' => 'mars-double',
734
+ '\f229' => 'mars-stroke',
735
+ '\f22b' => 'mars-stroke-h',
736
+ '\f22a' => 'mars-stroke-v',
737
+ '\f136' => 'maxcdn',
738
+ '\f20c' => 'meanpath',
739
+ '\f23a' => 'medium',
740
+ '\f0fa' => 'medkit',
741
+ '\f11a' => 'meh-o',
742
+ '\f223' => 'mercury',
743
+ '\f130' => 'microphone',
744
+ '\f131' => 'microphone-slash',
745
+ '\f068' => 'minus',
746
+ '\f056' => 'minus-circle',
747
+ '\f146' => 'minus-square',
748
+ '\f147' => 'minus-square-o',
749
+ '\f10b' => 'mobile',
750
+ '\f10b' => 'mobile-phone',
751
+ '\f0d6' => 'money',
752
+ '\f186' => 'moon-o',
753
+ '\f19d' => 'mortar-board',
754
+ '\f21c' => 'motorcycle',
755
+ '\f001' => 'music',
756
+ '\f0c9' => 'navicon',
757
+ '\f22c' => 'neuter',
758
+ '\f1ea' => 'newspaper-o',
759
+ '\f19b' => 'openid',
760
+ '\f03b' => 'outdent',
761
+ '\f18c' => 'pagelines',
762
+ '\f1fc' => 'paint-brush',
763
+ '\f1d8' => 'paper-plane',
764
+ '\f1d9' => 'paper-plane-o',
765
+ '\f0c6' => 'paperclip',
766
+ '\f1dd' => 'paragraph',
767
+ '\f0ea' => 'paste',
768
+ '\f04c' => 'pause',
769
+ '\f1b0' => 'paw',
770
+ '\f1ed' => 'paypal',
771
+ '\f040' => 'pencil',
772
+ '\f14b' => 'pencil-square',
773
+ '\f044' => 'pencil-square-o',
774
+ '\f095' => 'phone',
775
+ '\f098' => 'phone-square',
776
+ '\f03e' => 'photo',
777
+ '\f03e' => 'picture-o',
778
+ '\f200' => 'pie-chart',
779
+ '\f1a7' => 'pied-piper',
780
+ '\f1a8' => 'pied-piper-alt',
781
+ '\f0d2' => 'pinterest',
782
+ '\f231' => 'pinterest-p',
783
+ '\f0d3' => 'pinterest-square',
784
+ '\f072' => 'plane',
785
+ '\f04b' => 'play',
786
+ '\f144' => 'play-circle',
787
+ '\f01d' => 'play-circle-o',
788
+ '\f1e6' => 'plug',
789
+ '\f067' => 'plus',
790
+ '\f055' => 'plus-circle',
791
+ '\f0fe' => 'plus-square',
792
+ '\f196' => 'plus-square-o',
793
+ '\f011' => 'power-off',
794
+ '\f02f' => 'print',
795
+ '\f12e' => 'puzzle-piece',
796
+ '\f1d6' => 'qq',
797
+ '\f029' => 'qrcode',
798
+ '\f128' => 'question',
799
+ '\f059' => 'question-circle',
800
+ '\f10d' => 'quote-left',
801
+ '\f10e' => 'quote-right',
802
+ '\f1d0' => 'ra',
803
+ '\f074' => 'random',
804
+ '\f1d0' => 'rebel',
805
+ '\f1b8' => 'recycle',
806
+ '\f1a1' => 'reddit',
807
+ '\f1a2' => 'reddit-square',
808
+ '\f021' => 'refresh',
809
+ '\f00d' => 'remove',
810
+ '\f18b' => 'renren',
811
+ '\f0c9' => 'reorder',
812
+ '\f01e' => 'repeat',
813
+ '\f112' => 'reply',
814
+ '\f122' => 'reply-all',
815
+ '\f079' => 'retweet',
816
+ '\f157' => 'rmb',
817
+ '\f018' => 'road',
818
+ '\f135' => 'rocket',
819
+ '\f0e2' => 'rotate-left',
820
+ '\f01e' => 'rotate-right',
821
+ '\f158' => 'rouble',
822
+ '\f09e' => 'rss',
823
+ '\f143' => 'rss-square',
824
+ '\f158' => 'rub',
825
+ '\f158' => 'ruble',
826
+ '\f156' => 'rupee',
827
+ '\f0c7' => 'save',
828
+ '\f0c4' => 'scissors',
829
+ '\f002' => 'search',
830
+ '\f010' => 'search-minus',
831
+ '\f00e' => 'search-plus',
832
+ '\f213' => 'sellsy',
833
+ '\f1d8' => 'send',
834
+ '\f1d9' => 'send-o',
835
+ '\f233' => 'server',
836
+ '\f064' => 'share',
837
+ '\f1e0' => 'share-alt',
838
+ '\f1e1' => 'share-alt-square',
839
+ '\f14d' => 'share-square',
840
+ '\f045' => 'share-square-o',
841
+ '\f20b' => 'shekel',
842
+ '\f20b' => 'sheqel',
843
+ '\f132' => 'shield',
844
+ '\f21a' => 'ship',
845
+ '\f214' => 'shirtsinbulk',
846
+ '\f07a' => 'shopping-cart',
847
+ '\f090' => 'sign-in',
848
+ '\f08b' => 'sign-out',
849
+ '\f012' => 'signal',
850
+ '\f215' => 'simplybuilt',
851
+ '\f0e8' => 'sitemap',
852
+ '\f216' => 'skyatlas',
853
+ '\f17e' => 'skype',
854
+ '\f198' => 'slack',
855
+ '\f1de' => 'sliders',
856
+ '\f1e7' => 'slideshare',
857
+ '\f118' => 'smile-o',
858
+ '\f1e3' => 'soccer-ball-o',
859
+ '\f0dc' => 'sort',
860
+ '\f15d' => 'sort-alpha-asc',
861
+ '\f15e' => 'sort-alpha-desc',
862
+ '\f160' => 'sort-amount-asc',
863
+ '\f161' => 'sort-amount-desc',
864
+ '\f0de' => 'sort-asc',
865
+ '\f0dd' => 'sort-desc',
866
+ '\f0dd' => 'sort-down',
867
+ '\f162' => 'sort-numeric-asc',
868
+ '\f163' => 'sort-numeric-desc',
869
+ '\f0de' => 'sort-up',
870
+ '\f1be' => 'soundcloud',
871
+ '\f197' => 'space-shuttle',
872
+ '\f110' => 'spinner',
873
+ '\f1b1' => 'spoon',
874
+ '\f1bc' => 'spotify',
875
+ '\f0c8' => 'square',
876
+ '\f096' => 'square-o',
877
+ '\f18d' => 'stack-exchange',
878
+ '\f16c' => 'stack-overflow',
879
+ '\f005' => 'star',
880
+ '\f089' => 'star-half',
881
+ '\f123' => 'star-half-empty',
882
+ '\f123' => 'star-half-full',
883
+ '\f123' => 'star-half-o',
884
+ '\f006' => 'star-o',
885
+ '\f1b6' => 'steam',
886
+ '\f1b7' => 'steam-square',
887
+ '\f048' => 'step-backward',
888
+ '\f051' => 'step-forward',
889
+ '\f0f1' => 'stethoscope',
890
+ '\f04d' => 'stop',
891
+ '\f21d' => 'street-view',
892
+ '\f0cc' => 'strikethrough',
893
+ '\f1a4' => 'stumbleupon',
894
+ '\f1a3' => 'stumbleupon-circle',
895
+ '\f12c' => 'subscript',
896
+ '\f239' => 'subway',
897
+ '\f0f2' => 'suitcase',
898
+ '\f185' => 'sun-o',
899
+ '\f12b' => 'superscript',
900
+ '\f1cd' => 'support',
901
+ '\f0ce' => 'table',
902
+ '\f10a' => 'tablet',
903
+ '\f0e4' => 'tachometer',
904
+ '\f02b' => 'tag',
905
+ '\f02c' => 'tags',
906
+ '\f0ae' => 'tasks',
907
+ '\f1ba' => 'taxi',
908
+ '\f1d5' => 'tencent-weibo',
909
+ '\f120' => 'terminal',
910
+ '\f034' => 'text-height',
911
+ '\f035' => 'text-width',
912
+ '\f00a' => 'th',
913
+ '\f009' => 'th-large',
914
+ '\f00b' => 'th-list',
915
+ '\f08d' => 'thumb-tack',
916
+ '\f165' => 'thumbs-down',
917
+ '\f088' => 'thumbs-o-down',
918
+ '\f087' => 'thumbs-o-up',
919
+ '\f164' => 'thumbs-up',
920
+ '\f145' => 'ticket',
921
+ '\f00d' => 'times',
922
+ '\f057' => 'times-circle',
923
+ '\f05c' => 'times-circle-o',
924
+ '\f043' => 'tint',
925
+ '\f150' => 'toggle-down',
926
+ '\f191' => 'toggle-left',
927
+ '\f204' => 'toggle-off',
928
+ '\f205' => 'toggle-on',
929
+ '\f152' => 'toggle-right',
930
+ '\f151' => 'toggle-up',
931
+ '\f238' => 'train',
932
+ '\f224' => 'transgender',
933
+ '\f225' => 'transgender-alt',
934
+ '\f1f8' => 'trash',
935
+ '\f014' => 'trash-o',
936
+ '\f1bb' => 'tree',
937
+ '\f181' => 'trello',
938
+ '\f091' => 'trophy',
939
+ '\f0d1' => 'truck',
940
+ '\f195' => 'try',
941
+ '\f1e4' => 'tty',
942
+ '\f173' => 'tumblr',
943
+ '\f174' => 'tumblr-square',
944
+ '\f195' => 'turkish-lira',
945
+ '\f1e8' => 'twitch',
946
+ '\f099' => 'twitter',
947
+ '\f081' => 'twitter-square',
948
+ '\f0e9' => 'umbrella',
949
+ '\f0cd' => 'underline',
950
+ '\f0e2' => 'undo',
951
+ '\f19c' => 'university',
952
+ '\f127' => 'unlink',
953
+ '\f09c' => 'unlock',
954
+ '\f13e' => 'unlock-alt',
955
+ '\f0dc' => 'unsorted',
956
+ '\f093' => 'upload',
957
+ '\f155' => 'usd',
958
+ '\f007' => 'user',
959
+ '\f0f0' => 'user-md',
960
+ '\f234' => 'user-plus',
961
+ '\f21b' => 'user-secret',
962
+ '\f235' => 'user-times',
963
+ '\f0c0' => 'users',
964
+ '\f221' => 'venus',
965
+ '\f226' => 'venus-double',
966
+ '\f228' => 'venus-mars',
967
+ '\f237' => 'viacoin',
968
+ '\f03d' => 'video-camera',
969
+ '\f194' => 'vimeo-square',
970
+ '\f1ca' => 'vine',
971
+ '\f189' => 'vk',
972
+ '\f027' => 'volume-down',
973
+ '\f026' => 'volume-off',
974
+ '\f028' => 'volume-up',
975
+ '\f071' => 'warning',
976
+ '\f1d7' => 'wechat',
977
+ '\f18a' => 'weibo',
978
+ '\f1d7' => 'weixin',
979
+ '\f232' => 'whatsapp',
980
+ '\f193' => 'wheelchair',
981
+ '\f1eb' => 'wifi',
982
+ '\f17a' => 'windows',
983
+ '\f159' => 'won',
984
+ '\f19a' => 'wordpress',
985
+ '\f0ad' => 'wrench',
986
+ '\f168' => 'xing',
987
+ '\f169' => 'xing-square',
988
+ '\f19e' => 'yahoo',
989
+ '\f1e9' => 'yelp',
990
+ '\f157' => 'yen',
991
+ '\f167' => 'youtube',
992
+ '\f16a' => 'youtube-play',
993
+ '\f166' => 'youtube-square',
994
+ ),
995
+
996
+ 'awesome_icons_socials' =>array(
997
+ 'f170' => 'adn',
998
+ 'f17b' => 'android',
999
+ 'f179' => 'apple',
1000
+ 'f171' => 'bitbucket',
1001
+ 'f171' => 'bitbucket-square',
1002
+ 'f02e' => 'bookmark',
1003
+ 'f097' => 'bookmark-o',
1004
+ 'f15a' => 'btc',
1005
+ 'f13c' => 'css3',
1006
+ 'f17d' => 'dribble',
1007
+ 'f16b' => 'dropbox',
1008
+ 'f09a' => 'facebook',
1009
+ 'f082' => 'facebook-square',
1010
+ 'f16e' => 'flickr',
1011
+ 'f180' => 'foursquare',
1012
+ 'f09b'=> 'github' ,
1013
+ 'f113'=> 'github-alt',
1014
+ 'f092' => 'github-square',
1015
+ 'f184' => 'gittip',
1016
+ 'f0d5' => 'google-plus',
1017
+ 'f0d4' => 'google-plus-square',
1018
+ 'f13b' => 'html5',
1019
+ 'f16d' => 'instagram',
1020
+ 'f0e1' => 'linkedin',
1021
+ 'f08c' => 'linkedin-square',
1022
+ 'f17c' => 'Linux',
1023
+ 'f136' => 'maxcdn',
1024
+ 'f18c' => 'pagelines',
1025
+ 'f0d2' => 'pinterest',
1026
+ 'f0d3' => 'pinterest-square',
1027
+ 'f18b' => 'renren',
1028
+ 'f09e' => 'rss',
1029
+ 'f17e' => 'skype',
1030
+ 'f18d' => 'stack-exchange',
1031
+ 'f16c' => 'stack-overflow',
1032
+ 'f181' => 'trello',
1033
+ 'f173' => 'tumblr',
1034
+ 'f174' => 'Tumblr Square',
1035
+ 'f099' => 'twitter',
1036
+ 'f081' => 'twitter-square',
1037
+ 'f194' => 'vimeo-square',
1038
+ 'f189' => 'vk',
1039
+ 'f18a' => 'weibo',
1040
+ 'f17a' => 'windows',
1041
+ 'f168' => 'xing',
1042
+ 'f169' => 'xing-square',
1043
+ 'f167' => 'youtube'
1044
+ ),
1045
+ 'header_backgrounds' => array(),
1046
+ 'body_backgrounds' => array(),
1047
+
1048
+ // tags used in theme options (e.g. %tag%) to have some common informations
1049
+ 'tag' => array( //'themeurl' => get_template_directory_uri()
1050
+ ),
1051
+
1052
+ 'cycle_fx' => array(
1053
+ 'blindX' => 'blindX', 'blindY' => 'blindY', 'blindZ' => 'blindZ', 'cover' => 'cover', 'curtainX' => 'curtainX',
1054
+ 'curtainY' => 'curtainY', 'fade' => 'fade', 'fadeZoom' => 'fadeZoom', 'growX' => 'growX', 'growY' => 'growY',
1055
+ 'scrollUp' => 'scrollUp', 'scrollDown' => 'scrollDown', 'scrollLeft' => 'scrollLeft', 'scrollRight' => 'scrollRight', 'scrollHorz' => 'scrollHorz',
1056
+ 'shuffle' => 'shuffle', 'slideX' => 'slideX', 'slideY' => 'slideY', 'toss' => 'toss', 'turnUp' => 'turnUp',
1057
+ 'turnLeft' => 'turnLeft', 'turnRight' => 'turnRight', 'uncover' => 'uncover', 'wipe' => 'wipe', 'zoom' => 'zoom',
1058
+ 'none' => 'none', 'turnDown' => 'turnDown', 'scrollVert' => 'scrollVert'
1059
+ ),
1060
+
1061
+ 'animate' => array(
1062
+ '' => "none",
1063
+ "bounce" => "bounce",
1064
+ "flash" =>"flash",
1065
+ "pulse" =>"pulse",
1066
+ //"rubberBand"=>"rubberBand",
1067
+ "shake" =>"shake",
1068
+ "swing"=>"swing",
1069
+ "tada" =>"tada",
1070
+ "wobble"=>"wobble",
1071
+ "bounceIn"=>"bounceIn",
1072
+ "bounceInDown"=>"bounceInDown",
1073
+ "bounceInLeft"=>"bounceInLeft",
1074
+ "bounceInRight"=>"bounceInRight",
1075
+ "bounceInUp"=>"bounceInUp",
1076
+ "fadeIn"=>"fadeIn",
1077
+ "fadeInDown"=>"fadeInDown",
1078
+ "fadeInDownBig"=>"fadeInDownBig",
1079
+ "fadeInLeft"=>"fadeInLeft",
1080
+ "fadeInLeftBig"=>"fadeInLeftBig",
1081
+ "fadeInRight"=>"fadeInRight",
1082
+ "fadeInRightBig"=>"fadeInRightBig",
1083
+ "fadeInUp"=>"fadeInUp",
1084
+ "fadeInUpBig"=>"fadeInUpBig",
1085
+ "flip"=>"flip",
1086
+ "flipInX"=>"flipInX",
1087
+ "flipInY"=>"flipInY",
1088
+ "lightSpeedIn"=>"lightSpeedIn",
1089
+ "rotateIn"=>"rotateIn",
1090
+ "rotateInDownLeft"=>"rotateInDownLeft",
1091
+ "rotateInDownRight"=>"rotateInDownRight",
1092
+ "rotateInUpLeft"=>"rotateInUpLeft",
1093
+ "rotateInUpRight"=>"rotateInUpRight",
1094
+ //"slideInDown"=>"slideInDown",
1095
+ //"slideInLeft"=>"slideInLeft",
1096
+ //"slideInRight"=>"slideInRight",
1097
+ "rollIn"=>"rollIn",
1098
+ ),
1099
+
1100
+ 'easings' => array(
1101
+ FALSE => 'none',
1102
+ 'easeInQuad' => 'easeInQuad',
1103
+ 'easeOutQuad' => 'easeOutQuad',
1104
+ 'easeInOutQuad' => 'easeInOutQuad',
1105
+ 'easeInCubic' => 'easeInCubic',
1106
+ 'easeOutCubic' => 'easeOutCubic',
1107
+ 'easeInOutCubic' => 'easeInOutCubic',
1108
+ 'easeInQuart' => 'easeInQuart',
1109
+ 'easeOutQuart' => 'easeOutQuart',
1110
+ 'easeInOutQuart' => 'easeInOutQuart',
1111
+ 'easeInQuint' => 'easeInQuint',
1112
+ 'easeOutQuint' => 'easeOutQuint',
1113
+ 'easeInOutQuint' => 'easeInOutQuint',
1114
+ 'easeInSine' => 'easeInSine',
1115
+ 'easeOutSine' => 'easeOutSine',
1116
+ 'easeInOutSine' => 'easeInOutSine',
1117
+ 'easeInExpo' => 'easeInExpo',
1118
+ 'easeOutExpo' => 'easeOutExpo',
1119
+ 'easeInOutExpo' => 'easeInOutExpo',
1120
+ 'easeInCirc' => 'easeInCirc',
1121
+ 'easeOutCirc' => 'easeOutCirc',
1122
+ 'easeInOutCirc' => 'easeInOutCirc',
1123
+ 'easeInElastic' => 'easeInElastic',
1124
+ 'easeOutElastic' => 'easeOutElastic',
1125
+ 'easeInOutElastic' => 'easeInOutElastic',
1126
+ 'easeInBack' => 'easeInBack',
1127
+ 'easeOutBack' => 'easeOutBack',
1128
+ 'easeInOutBack' => 'easeInOutBack',
1129
+ 'easeInBounce' => 'easeInBounce',
1130
+ 'easeOutBounce' => 'easeOutBounce',
1131
+ 'easeInOutBounce' => 'easeInOutBounce'
1132
+ )
1133
+ );
1134
+
1135
+ /**
1136
+ * Get configuration array
1137
+ *
1138
+ * @return array
1139
+ */
1140
+ public static function load() {
1141
+ self::_loadThemeInfo();
1142
+ //ksort( self::$_config['awesome_icons'] );
1143
+
1144
+ return self::$_config;
1145
+ }
1146
+
1147
+ /**
1148
+ * Return theme data
1149
+ *
1150
+ * First the method checks if the wp_get_theme() function exists (WP 3.4.0 at least).
1151
+ * If not, the method calls the deprecated function get_template_directory()
1152
+ *
1153
+ * @return array
1154
+ */
1155
+ protected static function _loadThemeInfo() {
1156
+ $theme = wp_get_theme();
1157
+
1158
+ self::$_config['theme'] = array(
1159
+ 'name' => $theme->Name,
1160
+ 'description' => $theme->Description,
1161
+ 'author' => $theme->Author,
1162
+ 'authoruri' => $theme->{'Author URI'},
1163
+ 'version' => $theme->Version,
1164
+ 'template' => $theme->Template,
1165
+ 'status' => $theme->Status,
1166
+ 'tags' => $theme->Tags
1167
+ );
1168
+ }
1169
+
1170
+
1171
+ public function init() {
1172
+ self::$_config['header_backgrounds'] = apply_filters( 'yit_header_backgrounds', self::$_config['header_backgrounds'] );
1173
+ self::$_config['body_backgrounds'] = apply_filters( 'yit_body_backgrounds', self::$_config['body_backgrounds'] );
1174
+ }
1175
+
1176
+ /**
1177
+ * Return the font awesome array icon
1178
+ *
1179
+ * @return string Array
1180
+ * @access public
1181
+ * @since 1.0.0
1182
+ */
1183
+ public static function get_awesome_icons() {
1184
+ return self::$_config['awesome_icons'];
1185
+ }
1186
+
1187
+ /**
1188
+ * Return the font awesome array socials icon
1189
+ *
1190
+ * @return string Array
1191
+ * @access public
1192
+ * @since 1.0.0
1193
+ */
1194
+ public static function get_awesome_icons_socials() {
1195
+ return self::$_config['awesome_icons_socials'];
1196
+ }
1197
+
1198
+
1199
+ /**
1200
+ * Return the list of icons
1201
+ *
1202
+ * @return string Array
1203
+ * @access public
1204
+ * @since 1.0.0
1205
+ */
1206
+ public static function get_icon_list() {
1207
+
1208
+ $standard_icon_list = array(
1209
+ 'FontAwesome' => self::$_config['awesome_icons2']
1210
+ );
1211
+
1212
+ return apply_filters( 'yit_icon_list', $standard_icon_list );
1213
+ }
1214
+
1215
+ /**
1216
+ * Return the data of icon
1217
+ *
1218
+ * @return string Array
1219
+ * @access public
1220
+ * @since 1.0.0
1221
+ */
1222
+ public static function get_icon( $icon ) {
1223
+
1224
+ $icon_list = self::get_icon_list();
1225
+ $icon_data = '';
1226
+ if ( $icon != '' ) {
1227
+ $ic = explode( ':', $icon );
1228
+ $icon_code = array_search( $ic[1], $icon_list[$ic[0]] );
1229
+
1230
+ if( $icon_code ){
1231
+ $icon_code = ( strpos( $icon_code, '\\' ) === 0 ) ? '&#x' . substr( $icon_code, 1 ) . ';' : $icon_code;
1232
+ }
1233
+
1234
+ $icon_data = 'data-font="' . $ic[0] . '" data-key="' . $ic[1] . '" data-icon="' . $icon_code . '"';
1235
+ }
1236
+
1237
+ return $icon_data;
1238
+ }
1239
+
1240
+
1241
+ /*
1242
+ * Return the code of the relative awesome class name
1243
+ *
1244
+ * @return string
1245
+ * @access public
1246
+ * @since 1.0.0
1247
+ */
1248
+ public static function get_awesome_icons_code_by_value($class){
1249
+ $awesome_icons=self::$_config['awesome_icons'];
1250
+ foreach($awesome_icons as $key => $value){
1251
+ if($class==$value) {
1252
+ return $key;
1253
+ }
1254
+ }
1255
+
1256
+ return "";
1257
+ }
1258
+ }
1259
+
1260
  endif;
plugin-fw/lib/yit-plugin-gradients.php CHANGED
@@ -1,536 +1,536 @@
1
- <?php
2
- /**
3
- * Your Inspiration Themes
4
- *
5
- * In this files there is a collection of a functions useful for the core
6
- * of the framework.
7
- *
8
- * @package WordPress
9
- * @subpackage Your Inspiration Themes
10
- * @author Your Inspiration Themes Team <info@yithemes.com>
11
- *
12
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
13
- * that is bundled with this package in the file LICENSE.txt.
14
- * It is also available through the world-wide-web at this URL:
15
- * http://www.gnu.org/licenses/gpl-3.0.txt
16
- */
17
-
18
- /**
19
- * Handles colors
20
- *
21
- * @since 1.0
22
- */
23
- /**
24
- * Generates CSS 3 gradients for all browsers.
25
- *
26
- * @since 1.0
27
- */
28
-
29
- if ( ! class_exists( 'YIT_Gradients' ) ) {
30
-
31
- class YIT_Gradients {
32
-
33
- /**
34
- * An array of colors to use for a gradient.
35
- *
36
- * @var array
37
- * @since 1.0
38
- */
39
- public $colors_gradient = array();
40
-
41
- /**
42
- * Set properties
43
- *
44
- * @param string $key
45
- * @param $value
46
- *
47
- * @internal param array $colors_gradient
48
- * @return void
49
- * @since 1.0
50
- */
51
- public function set( $key, $value ) {
52
- if ( property_exists( $this, $key ) ) {
53
- $this->{$key} = $value;
54
- }
55
- }
56
-
57
- /**
58
- * Get properties
59
- *
60
- * @param string $key
61
- *
62
- * @return mixed
63
- * @since 1.0
64
- */
65
- public function get( $key ) {
66
- if ( property_exists( $this, $key ) ) {
67
- return $this->{$key};
68
- }
69
- }
70
-
71
- /**
72
- * Add a color to use in a gradient.
73
- *
74
- * @param string $color
75
- * @param int $position
76
- *
77
- * @return void
78
- * @since 1.0
79
- */
80
- public function add_color_gradient( $color, $position ) {
81
- $the_color['color'] = $color;
82
- $the_color['position'] = $position;
83
-
84
- array_push( $this->colors_gradient, $the_color );
85
- }
86
-
87
- /**
88
- * Generate the CSS code for a gradient.
89
- *
90
- * @param string $role
91
- * @param string $direction
92
- *
93
- * @return string|bool
94
- * @since 1.0
95
- */
96
- public function gradient( $role, $direction ) {
97
- if ( ! empty( $this->colors_gradient ) ) {
98
-
99
- $css = array(
100
- 'old' => $this->_make_old_gradient( $this->colors_gradient[0]['color'] ), //old browser
101
- 'ff3' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'moz' ), //firefox 3.6+
102
- 'chr_saf4' => $this->_make_chr_saf4_gradient( $this->colors_gradient, $direction ), //chrome and safari4+
103
- 'chr10_saf5' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'webkit' ), //chrome10+ and safari5+
104
- 'opera' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'o' ), //opera11.10+
105
- 'ie10' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'ms' ), //internet explorer 10+
106
- 'w3c' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'w3c' ), //w3c
107
- 'ie6_9' => $this->_make_ie6_gradient( $this->colors_gradient, $direction ) //ie6-9
108
- );
109
-
110
- $css = $role . '{' . implode( ';', $css ) . '}';
111
-
112
- $this->colors_gradient = array();
113
-
114
- return $css;
115
- }
116
- }
117
-
118
- /**
119
- * Reverse a gradient. This method should be used only before calling ::make_gradient(). Otherwise it will not works.
120
- *
121
- * @return void
122
- * @since 1.0
123
- */
124
- public function reverse_gradient() {
125
- $colors_gradient = array_reverse( $this->get( 'colors_gradient' ) );
126
-
127
- for ( $i = 0; $i < count( $colors_gradient ); $i ++ ) {
128
- $colors_gradient[$i]['position'] = 100 - $colors_gradient[$i]['position'];
129
- }
130
-
131
- $this->set( 'colors_gradient', $colors_gradient );
132
- }
133
-
134
- /**
135
- * Generate the CSS code for a gradient.
136
- *
137
- * @param string $role
138
- * @param string $direction
139
- *
140
- * @return string|bool
141
- * @since 1.0
142
- */
143
- public function get_gradient( $role, $direction ) {
144
- return $this->gradient( $role, $direction );
145
- }
146
-
147
- /**
148
- * Generate the CSS code for a gradient.
149
- *
150
- * @param string $role
151
- * @param string $direction
152
- *
153
- * @return void
154
- * @since 1.0
155
- */
156
- public function the_gradient( $role, $direction ) {
157
- echo $this->get_gradient( $role, $direction );
158
- }
159
-
160
- /**
161
- * Generate the CSS code for a gradient.
162
- *
163
- * @param string $role
164
- * @param string $from
165
- * @param string $to
166
- * @param string $direction
167
- *
168
- * @return string|bool
169
- * @since 1.0
170
- */
171
- public function gradient_from_to( $role, $from, $to, $direction ) {
172
-
173
- $colors = array(
174
- array(
175
- 'color' => $from,
176
- 'position' => 0
177
- ),
178
- array(
179
- 'color' => $to,
180
- 'position' => 100
181
- ),
182
- );
183
-
184
- $this->set( 'colors_gradient', $colors );
185
- return $this->get_gradient( $role, $direction );
186
- }
187
-
188
- /**
189
- * Generate the CSS code for a gradient.
190
- *
191
- * @param string $role
192
- * @param string $color
193
- * @param string $direction
194
- * @param int|string $factor
195
- *
196
- * @return string|bool
197
- * @since 1.0
198
- */
199
- public function gradient_darker( $role, $color, $direction, $factor = 30 ) {
200
-
201
- $colors = array(
202
- array(
203
- 'color' => $color,
204
- 'position' => 0
205
- ),
206
- array(
207
- 'color' => $this->hex_darker( $color, $factor ),
208
- 'position' => 100
209
- ),
210
- );
211
-
212
- $this->set( 'colors_gradient', $colors );
213
- return $this->get_gradient( $role, $direction );
214
- }
215
-
216
- /**
217
- * Generate the CSS code for a gradient.
218
- *
219
- * @param string $role
220
- * @param string $color
221
- * @param string $direction
222
- * @param int|string $factor
223
- *
224
- * @return string|bool
225
- * @since 1.0
226
- */
227
- public function gradient_lighter( $role, $color, $direction, $factor = 30 ) {
228
-
229
- $colors = array(
230
- array(
231
- 'color' => $color,
232
- 'position' => 0
233
- ),
234
- array(
235
- 'color' => $this->hex_lighter( $color, $factor ),
236
- 'position' => 100
237
- ),
238
- );
239
-
240
- $this->set( 'colors_gradient', $colors );
241
- return $this->get_gradient( $role, $direction );
242
- }
243
-
244
- /**
245
- * Generate the CSS code for a gradient that not supports gradients (add only a background color).
246
- *
247
- * @param $color
248
- *
249
- * @internal param string $role
250
- * @return string|bool
251
- * @access private
252
- * @since 1.0
253
- */
254
- private function _make_old_gradient( $color ) {
255
- return 'background:' . $color;
256
- }
257
-
258
- /**
259
- * Generate the CSS code for a gradient in IE6-9.
260
- *
261
- * @param $colors
262
- * @param $direction
263
- *
264
- * @internal param string $role
265
- * @return string|bool
266
- * @access private
267
- * @since 1.0
268
- */
269
- private function _make_ie6_gradient( $colors, $direction ) {
270
- $css = 'filter:progid:DXImageTransform.Microsoft.gradient(';
271
- $css .= 'startColorstr=\'' . $colors[0]['color'] . '\',';
272
- $css .= 'endColorstr=\'' . $colors[count( $colors ) - 1]['color'] . '\',';
273
-
274
- if ( $direction == 'horizontal' ) {
275
- $css .= 'GradientType=1';
276
- }
277
- else {
278
- $css .= 'GradientType=0';
279
- } //vertical
280
-
281
- $css .= ')';
282
-
283
- return $css;
284
- }
285
-
286
- /**
287
- * Make the CSS 3 for a gradient in modern browsers( FF3.6+, Chrome, Safari5+, Opera11.10+, IE10+ )
288
- *
289
- * @param array $colors
290
- * @param string $direction
291
- * @param $browser
292
- *
293
- * @return string
294
- * @access private
295
- * @since 1.0
296
- */
297
- private function _make_modern_gradient( $colors, $direction, $browser ) {
298
- $css = 'background:';
299
-
300
- //Add the browser suffix
301
- if ( $browser != 'w3c' ) {
302
- $browser = '-' . $browser . '-';
303
- }
304
- else {
305
- $browser = '';
306
- }
307
-
308
- switch ( $direction ) {
309
- case 'vertical' :
310
- $css .= $browser . 'linear-gradient(top,';
311
- break;
312
- case 'horizontal' :
313
- $css .= $browser . 'linear-gradient(left,';
314
- break;
315
- case 'diagonal-bottom':
316
- $css .= $browser . 'linear-gradient(-45deg,';
317
- break;
318
- case 'diagonal-top' :
319
- $css .= $browser . 'linear-gradient(45deg,';
320
- break;
321
- case 'radial' :
322
- $css .= $browser . 'radial-gradient(center, ellipse cover,';
323
- break;
324
- }
325
-
326
- foreach ( $colors as $stop ) {
327
- $css .= $stop['color'] . ' ' . $stop['position'] . '%, ';
328
- }
329
-
330
- $css = rtrim( $css );
331
- $css = rtrim( $css, ',' );
332
- $css .= ')';
333
-
334
- return $css;
335
- }
336
-
337
- /**
338
- * Make the CSS 3 for a gradient in Chrome and Safari 4+
339
- *
340
- * @param array $colors
341
- * @param string $direction
342
- *
343
- * @return string
344
- * @access private
345
- * @since 1.0
346
- */
347
- private function _make_chr_saf4_gradient( $colors, $direction ) {
348
- $css = 'background:';
349
-
350
- switch ( $direction ) {
351
- case 'vertical' :
352
- $css .= '-webkit-gradient(linear,left top,left bottom,';
353
- break;
354
- case 'horizontal' :
355
- $css .= '-webkit-gradient(linear,left top,right top,';
356
- break;
357
- case 'diagonal-bottom':
358
- $css .= '-webkit-gradient(linear,left top,right bottom,';
359
- break;
360
- case 'diagonal-top' :
361
- $css .= '-webkit-gradient(linear,left bottom,right top,';
362
- break;
363
- case 'radial' :
364
- $css .= '-webkit-gradient(radial,center center, 0px, center center, 100%,';
365
- break;
366
- }
367
-
368
- foreach ( $colors as $stop ) {
369
- $css .= 'color-stop(' . $stop['position'] . '%, ' . $stop['color'] . '), ';
370
- }
371
-
372
- $css = rtrim( $css );
373
- $css = rtrim( $css, ',' );
374
- $css .= ')';
375
-
376
- return $css;
377
- }
378
-
379
-
380
- /**
381
- * Return an instance of the model called
382
- *
383
- * @param string $class The name of class that I want the instance
384
- *
385
- * @since 2.0.0
386
- * @author Simone D'Amico <simone.damico@yithemes.com>
387
- * @return mixed
388
- */
389
- public function getModel( $class ) {
390
- return YIT_Registry::get_instance()->$class;
391
- }
392
-
393
-
394
- /**
395
- * Return a color darker then $color.
396
- *
397
- * @param string $color
398
- * @param int $factor
399
- *
400
- * @return string
401
- * @since 1.0
402
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
403
- */
404
- public function hex_darker( $color, $factor = 30 ) {
405
- $color = str_replace( '#', '', $color );
406
-
407
- $base['R'] = hexdec( substr( $color, 0, 2 ) );
408
- $base['G'] = hexdec( substr( $color, 2, 2 ) );
409
- $base['B'] = hexdec( substr( $color, 4, 2 ) );
410
-
411
- $color = '#';
412
-
413
- foreach ( $base as $k => $v ) {
414
- $amount = $v / 100;
415
- $amount = round( $amount * $factor );
416
- $new_decimal = $v - $amount;
417
-
418
- $new_hex_component = dechex( $new_decimal );
419
-
420
- if ( strlen( $new_hex_component ) < 2 ) {
421
- $new_hex_component = "0" . $new_hex_component;
422
- }
423
-
424
- $color .= $new_hex_component;
425
- }
426
-
427
- return $color;
428
- }
429
-
430
- /**
431
- * Return a color lighter then $color.
432
- *
433
- * @param string $color
434
- * @param int $factor
435
- *
436
- * @return string
437
- * @since 1.0
438
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
439
- */
440
- public function hex_lighter( $color, $factor = 30 ) {
441
- $color = str_replace( '#', '', $color );
442
-
443
- $base['R'] = hexdec( $color{0} . $color{1} );
444
- $base['G'] = hexdec( $color{2} . $color{3} );
445
- $base['B'] = hexdec( $color{4} . $color{5} );
446
-
447
- $color = '#';
448
-
449
- foreach ( $base as $k => $v ) {
450
- $amount = 255 - $v;
451
- $amount = $amount / 100;
452
- $amount = round( $amount * $factor );
453
- $new_decimal = $v + $amount;
454
-
455
- $new_hex_component = dechex( $new_decimal );
456
-
457
- if ( strlen( $new_hex_component ) < 2 ) {
458
- $new_hex_component = "0" . $new_hex_component;
459
- }
460
-
461
- $color .= $new_hex_component;
462
- }
463
-
464
- return $color;
465
- }
466
-
467
- /**
468
- * Detect if we must use a color darker or lighter then the background.
469
- *
470
- * @param string $color
471
- * @param string $dark
472
- * @param string $light
473
- *
474
- * @return string
475
- * @since 1.0
476
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
477
- */
478
- public function light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
479
- $hex = str_replace( '#', '', $color );
480
-
481
- $c_r = hexdec( substr( $hex, 0, 2 ) );
482
- $c_g = hexdec( substr( $hex, 2, 2 ) );
483
- $c_b = hexdec( substr( $hex, 4, 2 ) );
484
- $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
485
-
486
- return ( $brightness > 155 ) ? $dark : $light;
487
- }
488
-
489
- /**
490
- * Detect if we must use a color darker or lighter then the background.
491
- *
492
- * @param $hex
493
- *
494
- * @internal param string $color
495
- * @return string
496
- * @since 1.0
497
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
498
- */
499
- public function hex2rgb( $hex ) {
500
- $hex = str_replace( "#", "", $hex );
501
-
502
- if ( strlen( $hex ) == 3 ) {
503
- $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
504
- $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
505
- $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
506
- }
507
- else {
508
- $r = hexdec( substr( $hex, 0, 2 ) );
509
- $g = hexdec( substr( $hex, 2, 2 ) );
510
- $b = hexdec( substr( $hex, 4, 2 ) );
511
- }
512
- $rgb = array( $r, $g, $b );
513
- //return implode(",", $rgb); // returns the rgb values separated by commas
514
- return $rgb; // returns an array with the rgb values
515
- }
516
-
517
- /**
518
- * Magic method for this class
519
- *
520
- * @param $name string The name of magic property
521
- *
522
- * @since 2.0.0
523
- * @author Simone D'Amico <simone.damico@yithemes.com>
524
- * @return mixed
525
- */
526
- public function __get( $name ) {
527
- if ( $name == 'request' ) {
528
- if ( ! $this->_request instanceof YIT_Request ) {
529
- $this->_request = YIT_Registry::get_instance()->request;
530
- }
531
-
532
- return $this->_request;
533
- }
534
- }
535
- }
536
  }
1
+ <?php
2
+ /**
3
+ * Your Inspiration Themes
4
+ *
5
+ * In this files there is a collection of a functions useful for the core
6
+ * of the framework.
7
+ *
8
+ * @package WordPress
9
+ * @subpackage Your Inspiration Themes
10
+ * @author Your Inspiration Themes Team <info@yithemes.com>
11
+ *
12
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
13
+ * that is bundled with this package in the file LICENSE.txt.
14
+ * It is also available through the world-wide-web at this URL:
15
+ * http://www.gnu.org/licenses/gpl-3.0.txt
16
+ */
17
+
18
+ /**
19
+ * Handles colors
20
+ *
21
+ * @since 1.0
22
+ */
23
+ /**
24
+ * Generates CSS 3 gradients for all browsers.
25
+ *
26
+ * @since 1.0
27
+ */
28
+
29
+ if ( ! class_exists( 'YIT_Gradients' ) ) {
30
+
31
+ class YIT_Gradients {
32
+
33
+ /**
34
+ * An array of colors to use for a gradient.
35
+ *
36
+ * @var array
37
+ * @since 1.0
38
+ */
39
+ public $colors_gradient = array();
40
+
41
+ /**
42
+ * Set properties
43
+ *
44
+ * @param string $key
45
+ * @param $value
46
+ *
47
+ * @internal param array $colors_gradient
48
+ * @return void
49
+ * @since 1.0
50
+ */
51
+ public function set( $key, $value ) {
52
+ if ( property_exists( $this, $key ) ) {
53
+ $this->{$key} = $value;
54
+ }
55
+ }
56
+
57
+ /**
58
+ * Get properties
59
+ *
60
+ * @param string $key
61
+ *
62
+ * @return mixed
63
+ * @since 1.0
64
+ */
65
+ public function get( $key ) {
66
+ if ( property_exists( $this, $key ) ) {
67
+ return $this->{$key};
68
+ }
69
+ }
70
+
71
+ /**
72
+ * Add a color to use in a gradient.
73
+ *
74
+ * @param string $color
75
+ * @param int $position
76
+ *
77
+ * @return void
78
+ * @since 1.0
79
+ */
80
+ public function add_color_gradient( $color, $position ) {
81
+ $the_color['color'] = $color;
82
+ $the_color['position'] = $position;
83
+
84
+ array_push( $this->colors_gradient, $the_color );
85
+ }
86
+
87
+ /**
88
+ * Generate the CSS code for a gradient.
89
+ *
90
+ * @param string $role
91
+ * @param string $direction
92
+ *
93
+ * @return string|bool
94
+ * @since 1.0
95
+ */
96
+ public function gradient( $role, $direction ) {
97
+ if ( ! empty( $this->colors_gradient ) ) {
98
+
99
+ $css = array(
100
+ 'old' => $this->_make_old_gradient( $this->colors_gradient[0]['color'] ), //old browser
101
+ 'ff3' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'moz' ), //firefox 3.6+
102
+ 'chr_saf4' => $this->_make_chr_saf4_gradient( $this->colors_gradient, $direction ), //chrome and safari4+
103
+ 'chr10_saf5' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'webkit' ), //chrome10+ and safari5+
104
+ 'opera' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'o' ), //opera11.10+
105
+ 'ie10' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'ms' ), //internet explorer 10+
106
+ 'w3c' => $this->_make_modern_gradient( $this->colors_gradient, $direction, 'w3c' ), //w3c
107
+ 'ie6_9' => $this->_make_ie6_gradient( $this->colors_gradient, $direction ) //ie6-9
108
+ );
109
+
110
+ $css = $role . '{' . implode( ';', $css ) . '}';
111
+
112
+ $this->colors_gradient = array();
113
+
114
+ return $css;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Reverse a gradient. This method should be used only before calling ::make_gradient(). Otherwise it will not works.
120
+ *
121
+ * @return void
122
+ * @since 1.0
123
+ */
124
+ public function reverse_gradient() {
125
+ $colors_gradient = array_reverse( $this->get( 'colors_gradient' ) );
126
+
127
+ for ( $i = 0; $i < count( $colors_gradient ); $i ++ ) {
128
+ $colors_gradient[$i]['position'] = 100 - $colors_gradient[$i]['position'];
129
+ }
130
+
131
+ $this->set( 'colors_gradient', $colors_gradient );
132
+ }
133
+
134
+ /**
135
+ * Generate the CSS code for a gradient.
136
+ *
137
+ * @param string $role
138
+ * @param string $direction
139
+ *
140
+ * @return string|bool
141
+ * @since 1.0
142
+ */
143
+ public function get_gradient( $role, $direction ) {
144
+ return $this->gradient( $role, $direction );
145
+ }
146
+
147
+ /**
148
+ * Generate the CSS code for a gradient.
149
+ *
150
+ * @param string $role
151
+ * @param string $direction
152
+ *
153
+ * @return void
154
+ * @since 1.0
155
+ */
156
+ public function the_gradient( $role, $direction ) {
157
+ echo $this->get_gradient( $role, $direction );
158
+ }
159
+
160
+ /**
161
+ * Generate the CSS code for a gradient.
162
+ *
163
+ * @param string $role
164
+ * @param string $from
165
+ * @param string $to
166
+ * @param string $direction
167
+ *
168
+ * @return string|bool
169
+ * @since 1.0
170
+ */
171
+ public function gradient_from_to( $role, $from, $to, $direction ) {
172
+
173
+ $colors = array(
174
+ array(
175
+ 'color' => $from,
176
+ 'position' => 0
177
+ ),
178
+ array(
179
+ 'color' => $to,
180
+ 'position' => 100
181
+ ),
182
+ );
183
+
184
+ $this->set( 'colors_gradient', $colors );
185
+ return $this->get_gradient( $role, $direction );
186
+ }
187
+
188
+ /**
189
+ * Generate the CSS code for a gradient.
190
+ *
191
+ * @param string $role
192
+ * @param string $color
193
+ * @param string $direction
194
+ * @param int|string $factor
195
+ *
196
+ * @return string|bool
197
+ * @since 1.0
198
+ */
199
+ public function gradient_darker( $role, $color, $direction, $factor = 30 ) {
200
+
201
+ $colors = array(
202
+ array(
203
+ 'color' => $color,
204
+ 'position' => 0
205
+ ),
206
+ array(
207
+ 'color' => $this->hex_darker( $color, $factor ),
208
+ 'position' => 100
209
+ ),
210
+ );
211
+
212
+ $this->set( 'colors_gradient', $colors );
213
+ return $this->get_gradient( $role, $direction );
214
+ }
215
+
216
+ /**
217
+ * Generate the CSS code for a gradient.
218
+ *
219
+ * @param string $role
220
+ * @param string $color
221
+ * @param string $direction
222
+ * @param int|string $factor
223
+ *
224
+ * @return string|bool
225
+ * @since 1.0
226
+ */
227
+ public function gradient_lighter( $role, $color, $direction, $factor = 30 ) {
228
+
229
+ $colors = array(
230
+ array(
231
+ 'color' => $color,
232
+ 'position' => 0
233
+ ),
234
+ array(
235
+ 'color' => $this->hex_lighter( $color, $factor ),
236
+ 'position' => 100
237
+ ),
238
+ );
239
+
240
+ $this->set( 'colors_gradient', $colors );
241
+ return $this->get_gradient( $role, $direction );
242
+ }
243
+
244
+ /**
245
+ * Generate the CSS code for a gradient that not supports gradients (add only a background color).
246
+ *
247
+ * @param $color
248
+ *
249
+ * @internal param string $role
250
+ * @return string|bool
251
+ * @access private
252
+ * @since 1.0
253
+ */
254
+ private function _make_old_gradient( $color ) {
255
+ return 'background:' . $color;
256
+ }
257
+
258
+ /**
259
+ * Generate the CSS code for a gradient in IE6-9.
260
+ *
261
+ * @param $colors
262
+ * @param $direction
263
+ *
264
+ * @internal param string $role
265
+ * @return string|bool
266
+ * @access private
267
+ * @since 1.0
268
+ */
269
+ private function _make_ie6_gradient( $colors, $direction ) {
270
+ $css = 'filter:progid:DXImageTransform.Microsoft.gradient(';
271
+ $css .= 'startColorstr=\'' . $colors[0]['color'] . '\',';
272
+ $css .= 'endColorstr=\'' . $colors[count( $colors ) - 1]['color'] . '\',';
273
+
274
+ if ( $direction == 'horizontal' ) {
275
+ $css .= 'GradientType=1';
276
+ }
277
+ else {
278
+ $css .= 'GradientType=0';
279
+ } //vertical
280
+
281
+ $css .= ')';
282
+
283
+ return $css;
284
+ }
285
+
286
+ /**
287
+ * Make the CSS 3 for a gradient in modern browsers( FF3.6+, Chrome, Safari5+, Opera11.10+, IE10+ )
288
+ *
289
+ * @param array $colors
290
+ * @param string $direction
291
+ * @param $browser
292
+ *
293
+ * @return string
294
+ * @access private
295
+ * @since 1.0
296
+ */
297
+ private function _make_modern_gradient( $colors, $direction, $browser ) {
298
+ $css = 'background:';
299
+
300
+ //Add the browser suffix
301
+ if ( $browser != 'w3c' ) {
302
+ $browser = '-' . $browser . '-';
303
+ }
304
+ else {
305
+ $browser = '';
306
+ }
307
+
308
+ switch ( $direction ) {
309
+ case 'vertical' :
310
+ $css .= $browser . 'linear-gradient(top,';
311
+ break;
312
+ case 'horizontal' :
313
+ $css .= $browser . 'linear-gradient(left,';
314
+ break;
315
+ case 'diagonal-bottom':
316
+ $css .= $browser . 'linear-gradient(-45deg,';
317
+ break;
318
+ case 'diagonal-top' :
319
+ $css .= $browser . 'linear-gradient(45deg,';
320
+ break;
321
+ case 'radial' :
322
+ $css .= $browser . 'radial-gradient(center, ellipse cover,';
323
+ break;
324
+ }
325
+
326
+ foreach ( $colors as $stop ) {
327
+ $css .= $stop['color'] . ' ' . $stop['position'] . '%, ';
328
+ }
329
+
330
+ $css = rtrim( $css );
331
+ $css = rtrim( $css, ',' );
332
+ $css .= ')';
333
+
334
+ return $css;
335
+ }
336
+
337
+ /**
338
+ * Make the CSS 3 for a gradient in Chrome and Safari 4+
339
+ *
340
+ * @param array $colors
341
+ * @param string $direction
342
+ *
343
+ * @return string
344
+ * @access private
345
+ * @since 1.0
346
+ */
347
+ private function _make_chr_saf4_gradient( $colors, $direction ) {
348
+ $css = 'background:';
349
+
350
+ switch ( $direction ) {
351
+ case 'vertical' :
352
+ $css .= '-webkit-gradient(linear,left top,left bottom,';
353
+ break;
354
+ case 'horizontal' :
355
+ $css .= '-webkit-gradient(linear,left top,right top,';
356
+ break;
357
+ case 'diagonal-bottom':
358
+ $css .= '-webkit-gradient(linear,left top,right bottom,';
359
+ break;
360
+ case 'diagonal-top' :
361
+ $css .= '-webkit-gradient(linear,left bottom,right top,';
362
+ break;
363
+ case 'radial' :
364
+ $css .= '-webkit-gradient(radial,center center, 0px, center center, 100%,';
365
+ break;
366
+ }
367
+
368
+ foreach ( $colors as $stop ) {
369
+ $css .= 'color-stop(' . $stop['position'] . '%, ' . $stop['color'] . '), ';
370
+ }
371
+
372
+ $css = rtrim( $css );
373
+ $css = rtrim( $css, ',' );
374
+ $css .= ')';
375
+
376
+ return $css;
377
+ }
378
+
379
+
380
+ /**
381
+ * Return an instance of the model called
382
+ *
383
+ * @param string $class The name of class that I want the instance
384
+ *
385
+ * @since 2.0.0
386
+ * @author Simone D'Amico <simone.damico@yithemes.com>
387
+ * @return mixed
388
+ */
389
+ public function getModel( $class ) {
390
+ return YIT_Registry::get_instance()->$class;
391
+ }
392
+
393
+
394
+ /**
395
+ * Return a color darker then $color.
396
+ *
397
+ * @param string $color
398
+ * @param int $factor
399
+ *
400
+ * @return string
401
+ * @since 1.0
402
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
403
+ */
404
+ public function hex_darker( $color, $factor = 30 ) {
405
+ $color = str_replace( '#', '', $color );
406
+
407
+ $base['R'] = hexdec( substr( $color, 0, 2 ) );
408
+ $base['G'] = hexdec( substr( $color, 2, 2 ) );
409
+ $base['B'] = hexdec( substr( $color, 4, 2 ) );
410
+
411
+ $color = '#';
412
+
413
+ foreach ( $base as $k => $v ) {
414
+ $amount = $v / 100;
415
+ $amount = round( $amount * $factor );
416
+ $new_decimal = $v - $amount;
417
+
418
+ $new_hex_component = dechex( $new_decimal );
419
+
420
+ if ( strlen( $new_hex_component ) < 2 ) {
421
+ $new_hex_component = "0" . $new_hex_component;
422
+ }
423
+
424
+ $color .= $new_hex_component;
425
+ }
426
+
427
+ return $color;
428
+ }
429
+
430
+ /**
431
+ * Return a color lighter then $color.
432
+ *
433
+ * @param string $color
434
+ * @param int $factor
435
+ *
436
+ * @return string
437
+ * @since 1.0
438
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
439
+ */
440
+ public function hex_lighter( $color, $factor = 30 ) {
441
+ $color = str_replace( '#', '', $color );
442
+
443
+ $base['R'] = hexdec( $color{0} . $color{1} );
444
+ $base['G'] = hexdec( $color{2} . $color{3} );
445
+ $base['B'] = hexdec( $color{4} . $color{5} );
446
+
447
+ $color = '#';
448
+
449
+ foreach ( $base as $k => $v ) {
450
+ $amount = 255 - $v;
451
+ $amount = $amount / 100;
452
+ $amount = round( $amount * $factor );
453
+ $new_decimal = $v + $amount;
454
+
455
+ $new_hex_component = dechex( $new_decimal );
456
+
457
+ if ( strlen( $new_hex_component ) < 2 ) {
458
+ $new_hex_component = "0" . $new_hex_component;
459
+ }
460
+
461
+ $color .= $new_hex_component;
462
+ }
463
+
464
+ return $color;
465
+ }
466
+
467
+ /**
468
+ * Detect if we must use a color darker or lighter then the background.
469
+ *
470
+ * @param string $color
471
+ * @param string $dark
472
+ * @param string $light
473
+ *
474
+ * @return string
475
+ * @since 1.0
476
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
477
+ */
478
+ public function light_or_dark( $color, $dark = '#000000', $light = '#FFFFFF' ) {
479
+ $hex = str_replace( '#', '', $color );
480
+
481
+ $c_r = hexdec( substr( $hex, 0, 2 ) );
482
+ $c_g = hexdec( substr( $hex, 2, 2 ) );
483
+ $c_b = hexdec( substr( $hex, 4, 2 ) );
484
+ $brightness = ( ( $c_r * 299 ) + ( $c_g * 587 ) + ( $c_b * 114 ) ) / 1000;
485
+
486
+ return ( $brightness > 155 ) ? $dark : $light;
487
+ }
488
+
489
+ /**
490
+ * Detect if we must use a color darker or lighter then the background.
491
+ *
492
+ * @param $hex
493
+ *
494
+ * @internal param string $color
495
+ * @return string
496
+ * @since 1.0
497
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
498
+ */
499
+ public function hex2rgb( $hex ) {
500
+ $hex = str_replace( "#", "", $hex );
501
+
502
+ if ( strlen( $hex ) == 3 ) {
503
+ $r = hexdec( substr( $hex, 0, 1 ) . substr( $hex, 0, 1 ) );
504
+ $g = hexdec( substr( $hex, 1, 1 ) . substr( $hex, 1, 1 ) );
505
+ $b = hexdec( substr( $hex, 2, 1 ) . substr( $hex, 2, 1 ) );
506
+ }
507
+ else {
508
+ $r = hexdec( substr( $hex, 0, 2 ) );
509
+ $g = hexdec( substr( $hex, 2, 2 ) );
510
+ $b = hexdec( substr( $hex, 4, 2 ) );
511
+ }
512
+ $rgb = array( $r, $g, $b );
513
+ //return implode(",", $rgb); // returns the rgb values separated by commas
514
+ return $rgb; // returns an array with the rgb values
515
+ }
516
+
517
+ /**
518
+ * Magic method for this class
519
+ *
520
+ * @param $name string The name of magic property
521
+ *
522
+ * @since 2.0.0
523
+ * @author Simone D'Amico <simone.damico@yithemes.com>
524
+ * @return mixed
525
+ */
526
+ public function __get( $name ) {
527
+ if ( $name == 'request' ) {
528
+ if ( ! $this->_request instanceof YIT_Request ) {
529
+ $this->_request = YIT_Registry::get_instance()->request;
530
+ }
531
+
532
+ return $this->_request;
533
+ }
534
+ }
535
+ }
536
  }
plugin-fw/lib/yit-plugin-panel-sidebar.php ADDED
@@ -0,0 +1,427 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( !class_exists( 'YIT_Plugin_Panel_Sidebar' ) ) {
16
+ /**
17
+ * YIT Plugin Panel Sidebar
18
+ *
19
+ * @class YIT_Plugin_Panel_Sidebar
20
+ * @package Yithemes
21
+ * @since 1.0
22
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
23
+ */
24
+ class YIT_Plugin_Panel_Sidebar {
25
+ /**
26
+ * @var string version of class
27
+ */
28
+ public $version = '1.0.1';
29
+
30
+
31
+ /**
32
+ * @var array array of widgets
33
+ */
34
+ public $widgets = array();
35
+
36
+ /**
37
+ * @type string
38
+ */
39
+ protected $_remote_widget_xml = 'http://bit.ly/1UJ83xN';
40
+
41
+ /**
42
+ * default priority for Remote Widgets
43
+ *
44
+ * @type int
45
+ */
46
+ public $default_remote_widget_priority = 40;
47
+
48
+ /**
49
+ * parent panel
50
+ *
51
+ * @var YIT_Plugin_Panel
52
+ */
53
+ public $panel;
54
+
55
+ private $_is_collapsed;
56
+
57
+ /**
58
+ * @type string
59
+ */
60
+ public static $transient_remote_widgets = 'yit_panel_sidebar_remote_widgets';
61
+
62
+ /**
63
+ * @type string
64
+ */
65
+ public static $transient_updated_remote_widgets = 'yit_panel_sidebar_remote_widgets_update';
66
+
67
+ /**
68
+ * @type string
69
+ */
70
+ public static $collapse_option = 'yith_plugin_panel_sidebar_collapse';
71
+
72
+ /**
73
+ * Constructor
74
+ *
75
+ * @param YIT_Plugin_Panel $panel the parent panel
76
+ *
77
+ * @since 1.0
78
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
79
+ */
80
+ private function __construct( $panel ) {
81
+ $this->panel = $panel;
82
+
83
+ /* load and sort default widgets and remote widgets */
84
+ $this->load_widgets();
85
+
86
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
87
+ add_filter( 'yit_admin_panel_content_class', array( $this, 'filter_admin_panel_content_class' ) );
88
+ }
89
+
90
+ /**
91
+ * get instance
92
+ *
93
+ * @static
94
+ * @return YIT_Plugin_Panel_Sidebar
95
+ *
96
+ * @since 1.0
97
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
98
+ */
99
+ public static function instance( $panel ) {
100
+ return new self( $panel );
101
+ }
102
+
103
+ /**
104
+ * return true if is collapsed by option
105
+ *
106
+ * @return bool
107
+ */
108
+ public function is_collapsed() {
109
+ if ( !isset( $this->_is_collapsed ) ) {
110
+ $this->_is_collapsed = get_option( self::$collapse_option, 'no' ) === 'yes';
111
+ }
112
+
113
+ return $this->_is_collapsed;
114
+ }
115
+
116
+ /**
117
+ * if is collapsed add a class to panel wrapper
118
+ *
119
+ * @param $class
120
+ *
121
+ * @return string
122
+ */
123
+ public function filter_admin_panel_content_class( $class ) {
124
+ if ( $this->is_collapsed() ) {
125
+ $class .= ' yit-admin-panel-content-wrap-full';
126
+ }
127
+
128
+ return $class;
129
+ }
130
+
131
+ /**
132
+ * Add one or more widgets to $this->widgets
133
+ *
134
+ * @param array $widgets
135
+ */
136
+ public function add_widgets( $widgets ) {
137
+ $this->widgets = array_merge( $this->widgets, $widgets );
138
+ }
139
+
140
+ /**
141
+ * delete transients
142
+ */
143
+ public static function delete_transients() {
144
+ delete_transient( self::$transient_remote_widgets );
145
+ delete_transient( self::$transient_updated_remote_widgets );
146
+ }
147
+
148
+ /**
149
+ * filter and sort widgets
150
+ */
151
+ private function _filter_and_sort_widgets() {
152
+ /* filter widgets */
153
+ $page_name = isset( $this->panel->settings[ 'page' ] ) ? $this->panel->settings[ 'page' ] : '';
154
+ $this->widgets = apply_filters( 'yit_plugin_panel_sidebar_widgets', $this->widgets, $page_name );
155
+
156
+ /*sort widgets*/
157
+ uasort( $this->widgets, array( $this, 'sort_widgets' ) );
158
+ }
159
+
160
+ /**
161
+ * get Remote Widget by XML from YIThemes
162
+ *
163
+ * @return array
164
+ *
165
+ * @since 1.0
166
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
167
+ */
168
+ public function get_remote_widgets() {
169
+ $remote_widgets = get_transient( self::$transient_remote_widgets );
170
+ $updated = get_transient( self::$transient_updated_remote_widgets );
171
+ $is_debug = defined( 'YIT_FW_REMOTE_WIDGETS_DEBUG' ) && YIT_FW_REMOTE_WIDGETS_DEBUG;
172
+
173
+ if ( $is_debug || $updated === false || $remote_widgets === false ) {
174
+ $remote_widgets = array();
175
+ } else {
176
+ return $remote_widgets;
177
+ }
178
+
179
+ $expiration = 1 * DAY_IN_SECONDS;
180
+ $updated_expiration = DAY_IN_SECONDS; // update frequency
181
+
182
+ $remote_xml = wp_remote_get( $this->_remote_widget_xml );
183
+ if ( !is_wp_error( $remote_xml ) && isset( $remote_xml[ 'response' ][ 'code' ] ) && '200' == $remote_xml[ 'response' ][ 'code' ] ) {
184
+ try {
185
+ // suppress all XML errors when loading the document
186
+ libxml_use_internal_errors( true );
187
+
188
+ $xml_data = new SimpleXmlElement( $remote_xml[ 'body' ] );
189
+ $xml_remote_widgets = isset( $xml_data->widget ) ? $xml_data->widget : array();
190
+
191
+ $enabled_args = array(
192
+ 'title',
193
+ 'icon',
194
+ 'content',
195
+ 'class',
196
+ 'title_class',
197
+ 'badge',
198
+ 'badge_text',
199
+ 'image',
200
+ 'image_class',
201
+ 'priority',
202
+ 'starting',
203
+ 'expiration',
204
+ );
205
+
206
+ $last_remote_priority = $this->default_remote_widget_priority;
207
+
208
+ foreach ( $xml_remote_widgets as $xml_widget ) {
209
+ if ( !isset( $xml_widget->id ) )
210
+ continue;
211
+
212
+ $widget_id = (string)$xml_widget->id;
213
+ $widget_array = array();
214
+ foreach ( $enabled_args as $key ) {
215
+ if ( isset( $xml_widget->$key ) ) {
216
+ $widget_array[ $key ] = (string)$xml_widget->$key;
217
+ } else {
218
+ if ( $key == 'priority' ) {
219
+ $widget_array[ $key ] = $last_remote_priority;
220
+ $last_remote_priority += 10;
221
+ }
222
+ }
223
+ }
224
+ $remote_widgets[ $widget_id ] = $widget_array;
225
+ }
226
+
227
+ $xml_expiration = isset( $xml_data->expiration ) ? (string)$xml_data->expiration : '';
228
+ if ( !empty( $xml_expiration ) ) {
229
+ $expiration = strtotime( $xml_expiration ) - strtotime( 'now' );
230
+ // if the XML is expired removes widgets
231
+ if ( $expiration < 1 )
232
+ $remote_widgets = array();
233
+
234
+ $is_urgent = isset( $xml_data->urgent ) ? !!$xml_data->urgent : false;
235
+ $is_urgent = true;
236
+ if ( !$is_urgent ) {
237
+ $four_days_random = mt_rand( 0, 4 * DAY_IN_SECONDS );
238
+ $expiration += $four_days_random;
239
+ } else {
240
+ /**
241
+ * - - - - - U R G E N T - - - - -
242
+ * it will be updated the exact day, BUT in different time! :)
243
+ * [to prevent too many request at the same time]
244
+ */
245
+ $one_day_random = mt_rand( 0, DAY_IN_SECONDS );
246
+ $expiration += $one_day_random;
247
+ }
248
+ }
249
+
250
+ $four_days_random = mt_rand( 0, 4 * DAY_IN_SECONDS );
251
+
252
+ /* to prevent multiple request if it's expired */
253
+ if ( $expiration < 1 ) {
254
+ $expiration = 1 * DAY_IN_SECONDS + $four_days_random;
255
+ }
256
+ }
257
+ catch ( Exception $e ) {
258
+
259
+ }
260
+
261
+ //$updated_expiration = 30 * DAY_IN_SECONDS + $four_days_random;
262
+ }
263
+
264
+ set_transient( self::$transient_remote_widgets, $remote_widgets, $expiration );
265
+ set_transient( self::$transient_updated_remote_widgets, true, $updated_expiration );
266
+
267
+ return $remote_widgets;
268
+ }
269
+
270
+ /**
271
+ * load and sort default widgets and remote widgets
272
+ *
273
+ * @since 1.0
274
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
275
+ */
276
+ public function load_widgets() {
277
+ /* get static widgets */
278
+ $this->widgets = include( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/sidebar/widgets/widgets.php' );
279
+
280
+ /* get remote widgets */
281
+ $remote_widgets = $this->get_remote_widgets();
282
+ $this->add_widgets( $remote_widgets );
283
+ }
284
+
285
+ /**
286
+ * Print the panel sidebar
287
+ *
288
+ * @return void
289
+ *
290
+ * @since 1.0
291
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
292
+ */
293
+ public function print_panel_sidebar() {
294
+ do_action( 'yit_panel_before_sidebar' );
295
+
296
+ include( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/sidebar/sidebar.php' );
297
+
298
+ do_action( 'yit_panel_after_sidebar' );
299
+ }
300
+
301
+ /**
302
+ * Print the panel sidebar widgets
303
+ *
304
+ * @return void
305
+ *
306
+ * @since 1.0
307
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
308
+ */
309
+ public function print_panel_sidebar_widgets() {
310
+ $basename = YIT_CORE_PLUGIN_PATH;
311
+ $path = '/panel/sidebar/widget.php';
312
+
313
+ $default_args = array(
314
+ 'id' => '',
315
+ 'title' => '',
316
+ 'icon' => '',
317
+ 'content' => '',
318
+ 'class' => '',
319
+ 'title_class' => '',
320
+ 'template' => '',
321
+ 'badge' => '',
322
+ 'badge_text' => '',
323
+ 'image' => '',
324
+ 'image_class' => '',
325
+ 'args' => array(),
326
+ 'hide_if_empty_args' => '',
327
+ 'priority' => 10,
328
+ 'starting' => '',
329
+ 'expiration' => '',
330
+ );
331
+
332
+ $this->_filter_and_sort_widgets();
333
+
334
+ foreach ( $this->widgets as $widget_id => $widget ) {
335
+ $args = array_merge( $widget, array( 'id' => $widget_id ) );
336
+ $args = wp_parse_args( $args, $default_args );
337
+
338
+ $is_started = empty( $args[ 'starting' ] ) || strtotime( $args[ 'starting' ] . ' midnight' ) <= strtotime( 'midnight' );
339
+ $is_expired = !empty( $args[ 'expiration' ] ) && strtotime( $args[ 'expiration' ] . ' midnight' ) < strtotime( 'midnight' );
340
+
341
+ if ( $is_expired || !$is_started )
342
+ continue;
343
+
344
+ if ( !empty( $args[ 'hide_if_empty_args' ] ) ) {
345
+ $hide_if_empty_args = $args[ 'hide_if_empty_args' ];
346
+ $continue = false;
347
+ foreach ( $hide_if_empty_args as $hide_if_empty_arg ) {
348
+ if ( empty( $args[ 'args' ][ $hide_if_empty_arg ] ) ) {
349
+ $continue = true;
350
+ break;
351
+ }
352
+ }
353
+ if ( $continue )
354
+ continue;
355
+ }
356
+
357
+ do_action( 'yit_panel_sidebar_before_widget', $widget_id, $widget );
358
+
359
+ yit_plugin_get_template( $basename, $path, $args );
360
+
361
+ do_action( 'yit_panel_sidebar_after_widget', $widget_id, $widget );
362
+ }
363
+ }
364
+
365
+ /**
366
+ * set transient for first activation
367
+ * to prevent too many calls to YIThemes
368
+ */
369
+ public static function set_transient_for_first_activation() {
370
+ $remote_widgets = get_transient( self::$transient_remote_widgets );
371
+ $updated = get_transient( self::$transient_updated_remote_widgets );
372
+
373
+ $first_activation = $updated === false && $remote_widgets === false;
374
+ if ( $first_activation ) {
375
+ $seven_days_random = mt_rand( 0, 7 * DAY_IN_SECONDS );
376
+ $expiration = 1 * DAY_IN_SECONDS + $seven_days_random;
377
+
378
+ set_transient( self::$transient_remote_widgets, array(), $expiration );
379
+ set_transient( self::$transient_updated_remote_widgets, true, $expiration );
380
+ }
381
+ }
382
+
383
+ /**
384
+ * Sort widgets by priority
385
+ *
386
+ * @param $a
387
+ * @param $b
388
+ *
389
+ * @return bool
390
+ *
391
+ * @since 1.0
392
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
393
+ */
394
+ public function sort_widgets( $a, $b ) {
395
+ $priority_a = isset( $a[ 'priority' ] ) ? intval( $a[ 'priority' ] ) : $this->default_remote_widget_priority;
396
+ $priority_b = isset( $b[ 'priority' ] ) ? intval( $b[ 'priority' ] ) : $this->default_remote_widget_priority;
397
+ if ( $priority_a == $priority_b ) {
398
+ return 0;
399
+ } elseif ( $priority_a > $priority_b ) {
400
+ return 1;
401
+ } else {
402
+ return -1;
403
+ }
404
+ }
405
+
406
+ /**
407
+ * Add Admin WC Style and Scripts
408
+ *
409
+ * @return void
410
+ *
411
+ * @since 1.0
412
+ * @author Leanza Francesco <leanzafrancesco@gmail.com
413
+ */
414
+ public function admin_enqueue_scripts() {
415
+ $min = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
416
+
417
+ wp_enqueue_style( 'opensans-font', '//fonts.googleapis.com/css?family=Open+Sans:400,500,600,700,800,100,200,300,900' );
418
+ wp_enqueue_style( 'yit-plugin-sidebar-style', YIT_CORE_PLUGIN_URL . '/assets/css/yit-plugin-panel-sidebar.css', $this->version );
419
+ wp_enqueue_script( 'yit-plugin-sidebar-js', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel-sidebar' . $min . '.js', array( 'jquery' ), $this->version, true );
420
+ wp_localize_script( 'yit-plugin-sidebar-js', 'sidebar_labels', array(
421
+ 'hide_sidebar' => __( 'Hide sidebar', 'yith-plugin-fw' ),
422
+ 'show_sidebar' => __( 'Show sidebar', 'yith-plugin-fw' ),
423
+ 'wrapper_class' => 'yit-admin-panel-content-wrap',
424
+ ) );
425
+ }
426
+ }
427
+ }
plugin-fw/lib/yit-plugin-panel-wc.php CHANGED
@@ -1,428 +1,451 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
16
- /**
17
- * YIT Plugin Panel for WooCommerce
18
- *
19
- * Setting Page to Manage Plugins
20
- *
21
- * @class YIT_Plugin_Panel
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
26
- */
27
-
28
- class YIT_Plugin_Panel_WooCommerce extends YIT_Plugin_Panel {
29
-
30
- /**
31
- * @var string version of class
32
- */
33
- public $version = '1.0.0';
34
-
35
- /**
36
- * @var array a setting list of parameters
37
- */
38
- public $settings = array();
39
-
40
- /**
41
- * @var array a setting list of parameters
42
- */
43
- public $wc_type = array();
44
-
45
- /**
46
- * @var array
47
- */
48
- protected $_tabs_path_files;
49
-
50
- /**
51
- * Constructor
52
- *
53
- * @since 1.0
54
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
55
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
56
- */
57
- public function __construct( $args = array() ) {
58
-
59
- $this->wc_type = array(
60
- 'checkbox',
61
- 'textarea',
62
- 'multiselect',
63
- 'multi_select_countries',
64
- 'image_width'
65
- );
66
-
67
- if ( ! empty( $args ) ) {
68
- $this->settings = $args;
69
- $this->_tabs_path_files = $this->get_tabs_path_files();
70
-
71
- if( isset( $this->settings['create_menu_page'] ) && $this->settings[ 'create_menu_page'] ){
72
- $this->add_menu_page();
73
- }
74
- add_action( 'admin_init', array( $this, 'set_default_options') );
75
- add_action( 'admin_menu', array( $this, 'add_setting_page' ) );
76
- add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
77
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
78
- add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
79
- add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
80
- add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
81
-
82
- /* Add VideoBox and InfoBox */
83
- add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
84
- add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
85
-
86
- /* WooCommerce 2.4 Support */
87
- add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
88
- }
89
- }
90
-
91
-
92
- /**
93
- * Show a tabbed panel to setting page
94
- *
95
- * a callback function called by add_setting_page => add_submenu_page
96
- *
97
- * @return void
98
- * @since 1.0
99
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
100
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
101
- */
102
- public function yit_panel() {
103
- $additional_info = array(
104
- 'current_tab' => $this->get_current_tab(),
105
- 'available_tabs' => $this->settings['admin-tabs'],
106
- 'default_tab' => $this->get_available_tabs( true ), //get default tabs
107
- 'page' => $this->settings['page']
108
- );
109
-
110
- $additional_info = apply_filters( 'yith_admin_tab_params', $additional_info );
111
- $additional_info['additional_info'] = $additional_info;
112
-
113
- extract( $additional_info );
114
- require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-panel.php' );
115
- }
116
-
117
- /**
118
- * Show a input fields to upload images
119
- *
120
- *
121
- * @return void
122
- * @since 1.0
123
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
124
- */
125
-
126
- public function yit_upload_update( $option_value ) {
127
- return $option_value;
128
- }
129
-
130
- /**
131
- * Show a input fields to upload images
132
- *
133
- *
134
- * @return void
135
- * @since 1.0
136
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
137
- */
138
-
139
- public function yit_upload( $args = array() ) {
140
- if ( ! empty( $args ) ) {
141
- $args['value'] = ( get_option($args['id'])) ? get_option($args['id']) : $args['default'];
142
- extract( $args );
143
-
144
- include( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-upload.php' );
145
- }
146
- }
147
-
148
- /**
149
- * Add the plugin woocommerce page settings in the screen ids of woocommerce
150
- *
151
- * @param $screen_ids
152
- *
153
- * @return mixed
154
- * @since 1.0.0
155
- * @author Antonino Scarfì <antonino.scarfi@yithemes.com>
156
- */
157
- public function add_allowed_screen_id( $screen_ids ) {
158
- global $admin_page_hooks;
159
-
160
- if ( ! isset( $admin_page_hooks[ $this->settings['parent_page'] ] ) ) {
161
- return $screen_ids;
162
- }
163
-
164
- $screen_ids[] = $admin_page_hooks[ $this->settings['parent_page'] ] . '_page_' . $this->settings['page'];
165
-
166
- return $screen_ids;
167
- }
168
-
169
- /**
170
- * Returns current active tab slug
171
- *
172
- * @return string
173
- * @since 2.0.0
174
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
175
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
176
- */
177
- public function get_current_tab() {
178
- global $pagenow;
179
- $tabs = $this->get_available_tabs();
180
-
181
- if ( $pagenow == 'admin.php' && isset( $_REQUEST['tab'] ) && in_array( $_REQUEST['tab'], $tabs ) ) {
182
- return $_REQUEST['tab'];
183
- }
184
- else {
185
- return $tabs[0];
186
- }
187
- }
188
-
189
- /**
190
- * Return available tabs
191
- *
192
- * read all options and show sections and fields
193
- *
194
- * @param bool false for all tabs slug, true for current tab
195
- *
196
- * @return mixed Array tabs | String current tab
197
- * @since 1.0
198
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
199
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
200
- */
201
- public function get_available_tabs( $default = false ) {
202
- $tabs = array_keys( $this->settings['admin-tabs'] );
203
- return $default ? $tabs[0] : $tabs;
204
- }
205
-
206
-
207
- /**
208
- * Add sections and fields to setting panel
209
- *
210
- * read all options and show sections and fields
211
- *
212
- * @return void
213
- * @since 1.0
214
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
215
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
216
- */
217
- public function add_fields() {
218
- $yit_options = $this->get_main_array_options();
219
- $current_tab = $this->get_current_tab();
220
-
221
- if ( ! $current_tab ) {
222
- return;
223
- }
224
-
225
- woocommerce_admin_fields( $yit_options[$current_tab] );
226
- }
227
-
228
- /**
229
- * Print the panel content
230
- *
231
- * check if the tab is a wc options tab or custom tab and print the content
232
- *
233
- * @return void
234
- * @since 1.0
235
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
236
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
237
- */
238
- public function print_panel_content() {
239
- $yit_options = $this->get_main_array_options();
240
- $current_tab = $this->get_current_tab();
241
- $custom_tab_action = $this->is_custom_tab( $yit_options, $current_tab );
242
-
243
- if ( $custom_tab_action ) {
244
- $this->print_custom_tab( $custom_tab_action );
245
- return;
246
- }
247
- else {
248
- require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-form.php' );
249
- }
250
- }
251
-
252
- /**
253
- * Update options
254
- *
255
- * @return void
256
- * @since 1.0
257
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
258
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
259
- * @see woocommerce_update_options function
260
- * @internal fire two action (before and after update): yit_panel_wc_before_update and yit_panel_wc_after_update
261
- */
262
- public function woocommerce_update_options() {
263
-
264
- if ( isset( $_POST['yit_panel_wc_options_nonce'] ) && wp_verify_nonce( $_POST['yit_panel_wc_options_nonce'], 'yit_panel_wc_options_'.$this->settings['page'] ) ) {
265
-
266
- do_action( 'yit_panel_wc_before_update' );
267
-
268
- $yit_options = $this->get_main_array_options();
269
- $current_tab = $this->get_current_tab();
270
-
271
- if( version_compare( WC()->version, '2.4.0', '>=' ) ) {
272
- if ( ! empty( $yit_options[ $current_tab ] ) ) {
273
- foreach ( $yit_options[ $current_tab ] as $option ) {
274
- if ( isset( $option['id'] ) && isset( $_POST[ $option['id'] ] ) && isset( $option['type' ] ) && ! in_array( $option['type'], $this->wc_type ) ) {
275
- $_POST[ $option['id'] ] = maybe_serialize( $_POST[ $option['id'] ] );
276
- }
277
- }
278
- }
279
- }
280
-
281
- foreach($_POST as $name => $value) {
282
-
283
- // Check if current POST var name ends with a specific needle and make some stuff here
284
- $attachment_id_needle = "-yith-attachment-id";
285
- $is_hidden_input = (($temp = strlen($name) - strlen($attachment_id_needle)) >= 0 && strpos($name, $attachment_id_needle, $temp) !== FALSE);
286
- if ($is_hidden_input){
287
- // Is an input element of type "hidden" coupled with an input element for selecting an element from the media gallery
288
- $yit_options[ $current_tab ][$name] = array(
289
- "type" => "text",
290
- "id" => $name
291
- );
292
- }
293
- }
294
-
295
- woocommerce_update_options( $yit_options[ $current_tab ] );
296
-
297
- do_action( 'yit_panel_wc_after_update' );
298
-
299
- } elseif( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'wc-options-reset'
300
- && isset( $_POST['yith_wc_reset_options_nonce'] ) && wp_verify_nonce( $_POST['yith_wc_reset_options_nonce'], 'yith_wc_reset_options_'.$this->settings['page'] )){
301
-
302
- $yit_options = $this->get_main_array_options();
303
- $current_tab = $this->get_current_tab();
304
-
305
- foreach( $yit_options[ $current_tab ] as $id => $option ){
306
- if( isset( $option['default'] ) ){
307
- update_option( $option['id'], $option['default'] );
308
- }
309
- }
310
- }
311
- }
312
-
313
- /**
314
- * Add Admin WC Style and Scripts
315
- *
316
- * @return void
317
- * @since 1.0
318
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
319
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
320
- */
321
- public function admin_enqueue_scripts() {
322
- global $woocommerce, $pagenow;
323
-
324
- wp_enqueue_style( 'raleway-font', '//fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,100,200,300,900' );
325
-
326
- wp_enqueue_media();
327
- wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css', array(), $woocommerce->version );
328
- wp_register_style( 'yit-plugin-style', YIT_CORE_PLUGIN_URL . '/assets/css/yit-plugin-panel.css', $woocommerce->version );
329
-
330
- if ( 'customize.php' != $pagenow ){
331
-
332
- wp_enqueue_style ( 'wp-jquery-ui-dialog' );
333
-
334
- }
335
-
336
- wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
337
- wp_enqueue_script( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array( 'jquery' ), '1.1.0', true );
338
- wp_enqueue_script( 'woocommerce_settings', $woocommerce->plugin_url() . '/assets/js/admin/settings.min.js', array( 'jquery', 'jquery-ui-datepicker','jquery-ui-dialog', 'jquery-ui-sortable', 'iris', 'chosen' ), $woocommerce->version, true );
339
- wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.min.js', array( 'jquery', 'jquery-chosen' ), $this->version, true );
340
- wp_localize_script( 'woocommerce_settings', 'woocommerce_settings_params', array(
341
- 'i18n_nav_warning' => __( 'The changes you have made will be lost if you leave this page.', 'yith-plugin-fw' )
342
- ) );
343
-
344
- if( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yit-plugins_page' ) !== false ){
345
- wp_enqueue_style( 'yit-plugin-style' );
346
- wp_enqueue_script( 'yit-plugin-panel' );
347
- }
348
- }
349
-
350
- /**
351
- * Default options
352
- *
353
- * Sets up the default options used on the settings page
354
- *
355
- * @access public
356
- * @return void
357
- * @since 1.0.0
358
- */
359
- public function set_default_options() {
360
-
361
- $default_options = $this->get_main_array_options();
362
-
363
- foreach ($default_options as $section) {
364
- foreach ( $section as $value ) {
365
- if ( ( isset( $value['std'] ) || isset( $value['default'] ) ) && isset( $value['id'] ) ) {
366
- $default_value = ( isset( $value['default'] ) ) ? $value['default'] : $value['std'];
367
-
368
- if ( $value['type'] == 'image_width' ) {
369
- add_option($value['id'].'_width', $default_value);
370
- add_option($value['id'].'_height', $default_value);
371
- } else {
372
- add_option($value['id'], $default_value);
373
- }
374
- }
375
-
376
- }
377
- }
378
-
379
- }
380
-
381
- /**
382
- * Add the woocommerce body class in plugin panel page
383
- *
384
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
385
- * @since 2.0
386
- * @param $classes The body classes
387
- *
388
- * @return array Filtered body classes
389
- */
390
- public function admin_body_class( $admin_body_classes ){
391
- global $pagenow;
392
- return 'admin.php' == $pagenow && substr_count( $admin_body_classes, 'woocommerce' ) == 0 ? $admin_body_classes .= ' woocommerce ' : $admin_body_classes;
393
- }
394
-
395
- /**
396
- * Maybe unserialize panel data
397
- *
398
- * @param $value mixed Option value
399
- * @param $option mixed Option settings array
400
- * @param $raw_value string Raw option value
401
- *
402
- * @return mixed Filtered return value
403
- * @author Antonio La Rocca <antonio.larocca@yithemes.com>
404
- * @since 2.0
405
- */
406
- public function maybe_unserialize_panel_data( $value, $option, $raw_value ) {
407
-
408
-
409
- if( ! version_compare( WC()->version, '2.4.0', '>=' ) || ! isset( $option['type' ] ) || in_array( $option['type'], $this->wc_type ) ) {
410
- return $value;
411
- }
412
-
413
- $yit_options = $this->get_main_array_options();
414
- $current_tab = $this->get_current_tab();
415
-
416
- if( ! empty( $yit_options[ $current_tab ] ) ){
417
- foreach( $yit_options[ $current_tab ] as $option_array ){
418
- if( isset( $option_array['id'] ) && isset( $option['id'] ) && $option_array['id'] == $option['id'] ){
419
- return maybe_unserialize( $value );
420
- }
421
- }
422
- }
423
-
424
- return $value;
425
- }
426
-
427
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
428
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
16
+ /**
17
+ * YIT Plugin Panel for WooCommerce
18
+ *
19
+ * Setting Page to Manage Plugins
20
+ *
21
+ * @class YIT_Plugin_Panel
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
26
+ */
27
+
28
+ class YIT_Plugin_Panel_WooCommerce extends YIT_Plugin_Panel {
29
+
30
+ /**
31
+ * @var string version of class
32
+ */
33
+ public $version = '1.0.0';
34
+
35
+ /**
36
+ * @var array a setting list of parameters
37
+ */
38
+ public $settings = array();
39
+
40
+ /**
41
+ * @var array a setting list of parameters
42
+ */
43
+ public $wc_type = array();
44
+
45
+ /**
46
+ * @var array
47
+ */
48
+ protected $_tabs_path_files;
49
+
50
+ /**
51
+ * Constructor
52
+ *
53
+ * @since 1.0
54
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
55
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
56
+ */
57
+ public function __construct( $args = array() ) {
58
+
59
+ $this->wc_type = array(
60
+ 'checkbox',
61
+ 'textarea',
62
+ 'multiselect',
63
+ 'multi_select_countries',
64
+ 'image_width'
65
+ );
66
+
67
+ if ( ! empty( $args ) ) {
68
+ $this->settings = $args;
69
+ $this->_tabs_path_files = $this->get_tabs_path_files();
70
+
71
+ if( isset( $this->settings['create_menu_page'] ) && $this->settings[ 'create_menu_page'] ){
72
+ $this->add_menu_page();
73
+ }
74
+
75
+ if ( !empty( $this->settings[ 'links' ] ) ) {
76
+ $this->links = $this->settings[ 'links' ];
77
+ }
78
+
79
+ add_action( 'admin_init', array( $this, 'set_default_options') );
80
+ add_action( 'admin_menu', array( $this, 'add_setting_page' ) );
81
+ add_action( 'admin_menu', array( $this, 'add_premium_version_upgrade_to_menu' ), 100 );
82
+ add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
83
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
84
+ add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
85
+ add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
86
+ add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
87
+
88
+ /* Add VideoBox and InfoBox */
89
+ add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
90
+ add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
91
+
92
+ /* WooCommerce 2.4 Support */
93
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
94
+ }
95
+
96
+ /* add YIT Plugin sidebar */
97
+ $this->sidebar = YIT_Plugin_Panel_Sidebar::instance( $this );
98
+ }
99
+
100
+
101
+ /**
102
+ * Show a tabbed panel to setting page
103
+ *
104
+ * a callback function called by add_setting_page => add_submenu_page
105
+ *
106
+ * @return void
107
+ * @since 1.0
108
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
109
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
110
+ */
111
+ public function yit_panel() {
112
+ $additional_info = array(
113
+ 'current_tab' => $this->get_current_tab(),
114
+ 'available_tabs' => $this->settings['admin-tabs'],
115
+ 'default_tab' => $this->get_available_tabs( true ), //get default tabs
116
+ 'page' => $this->settings['page']
117
+ );
118
+
119
+ $additional_info = apply_filters( 'yith_admin_tab_params', $additional_info );
120
+ $additional_info['additional_info'] = $additional_info;
121
+
122
+ extract( $additional_info );
123
+ require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-panel.php' );
124
+ }
125
+
126
+ /**
127
+ * Show a input fields to upload images
128
+ *
129
+ *
130
+ * @return void
131
+ * @since 1.0
132
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
133
+ */
134
+
135
+ public function yit_upload_update( $option_value ) {
136
+ return $option_value;
137
+ }
138
+
139
+ /**
140
+ * Show a input fields to upload images
141
+ *
142
+ *
143
+ * @return void
144
+ * @since 1.0
145
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
146
+ */
147
+
148
+ public function yit_upload( $args = array() ) {
149
+ if ( ! empty( $args ) ) {
150
+ $args['value'] = ( get_option($args['id'])) ? get_option($args['id']) : $args['default'];
151
+ extract( $args );
152
+
153
+ include( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-upload.php' );
154
+ }
155
+ }
156
+
157
+ /**
158
+ * Add the plugin woocommerce page settings in the screen ids of woocommerce
159
+ *
160
+ * @param $screen_ids
161
+ *
162
+ * @return mixed
163
+ * @since 1.0.0
164
+ * @author Antonino Scarfì <antonino.scarfi@yithemes.com>
165
+ */
166
+ public function add_allowed_screen_id( $screen_ids ) {
167
+ global $admin_page_hooks;
168
+
169
+ if ( ! isset( $admin_page_hooks[ $this->settings['parent_page'] ] ) ) {
170
+ return $screen_ids;
171
+ }
172
+
173
+ $screen_ids[] = $admin_page_hooks[ $this->settings['parent_page'] ] . '_page_' . $this->settings['page'];
174
+
175
+ return $screen_ids;
176
+ }
177
+
178
+ /**
179
+ * Returns current active tab slug
180
+ *
181
+ * @return string
182
+ * @since 2.0.0
183
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
184
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
185
+ */
186
+ public function get_current_tab() {
187
+ global $pagenow;
188
+ $tabs = $this->get_available_tabs();
189
+
190
+ if ( $pagenow == 'admin.php' && isset( $_REQUEST['tab'] ) && in_array( $_REQUEST['tab'], $tabs ) ) {
191
+ return $_REQUEST['tab'];
192
+ }
193
+ else {
194
+ return $tabs[0];
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Return available tabs
200
+ *
201
+ * read all options and show sections and fields
202
+ *
203
+ * @param bool false for all tabs slug, true for current tab
204
+ *
205
+ * @return mixed Array tabs | String current tab
206
+ * @since 1.0
207
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
208
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
209
+ */
210
+ public function get_available_tabs( $default = false ) {
211
+ $tabs = array_keys( $this->settings['admin-tabs'] );
212
+ return $default ? $tabs[0] : $tabs;
213
+ }
214
+
215
+
216
+ /**
217
+ * Add sections and fields to setting panel
218
+ *
219
+ * read all options and show sections and fields
220
+ *
221
+ * @return void
222
+ * @since 1.0
223
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
224
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
225
+ */
226
+ public function add_fields() {
227
+ $yit_options = $this->get_main_array_options();
228
+ $current_tab = $this->get_current_tab();
229
+
230
+ if ( ! $current_tab ) {
231
+ return;
232
+ }
233
+
234
+ woocommerce_admin_fields( $yit_options[$current_tab] );
235
+ }
236
+
237
+ /**
238
+ * Print the panel content
239
+ *
240
+ * check if the tab is a wc options tab or custom tab and print the content
241
+ *
242
+ * @return void
243
+ * @since 1.0
244
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
245
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
246
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
247
+ */
248
+ public function print_panel_content() {
249
+ $yit_options = $this->get_main_array_options();
250
+ $current_tab = $this->get_current_tab();
251
+ $custom_tab_action = $this->is_custom_tab( $yit_options, $current_tab );
252
+ $hide_sidebar = $this->hide_sidebar( $yit_options, $current_tab );
253
+
254
+ if ( $custom_tab_action ) {
255
+ $this->print_custom_tab( $custom_tab_action, $hide_sidebar );
256
+ return;
257
+ }
258
+ else {
259
+ require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/woocommerce/woocommerce-form.php' );
260
+ }
261
+ }
262
+
263
+ /**
264
+ * Update options
265
+ *
266
+ * @return void
267
+ * @since 1.0
268
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
269
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
270
+ * @see woocommerce_update_options function
271
+ * @internal fire two action (before and after update): yit_panel_wc_before_update and yit_panel_wc_after_update
272
+ */
273
+ public function woocommerce_update_options() {
274
+
275
+ if ( isset( $_POST['yit_panel_wc_options_nonce'] ) && wp_verify_nonce( $_POST['yit_panel_wc_options_nonce'], 'yit_panel_wc_options_'.$this->settings['page'] ) ) {
276
+
277
+ do_action( 'yit_panel_wc_before_update' );
278
+
279
+ $yit_options = $this->get_main_array_options();
280
+ $current_tab = $this->get_current_tab();
281
+
282
+ if( version_compare( WC()->version, '2.4.0', '>=' ) ) {
283
+ if ( ! empty( $yit_options[ $current_tab ] ) ) {
284
+ foreach ( $yit_options[ $current_tab ] as $option ) {
285
+ if ( isset( $option['id'] ) && isset( $_POST[ $option['id'] ] ) && isset( $option['type' ] ) && ! in_array( $option['type'], $this->wc_type ) ) {
286
+ $_POST[ $option['id'] ] = maybe_serialize( $_POST[ $option['id'] ] );
287
+ }
288
+ }
289
+ }
290
+ }
291
+
292
+ foreach($_POST as $name => $value) {
293
+
294
+ // Check if current POST var name ends with a specific needle and make some stuff here
295
+ $attachment_id_needle = "-yith-attachment-id";
296
+ $is_hidden_input = (($temp = strlen($name) - strlen($attachment_id_needle)) >= 0 && strpos($name, $attachment_id_needle, $temp) !== FALSE);
297
+ if ($is_hidden_input){
298
+ // Is an input element of type "hidden" coupled with an input element for selecting an element from the media gallery
299
+ $yit_options[ $current_tab ][$name] = array(
300
+ "type" => "text",
301
+ "id" => $name
302
+ );
303
+ }
304
+ }
305
+
306
+ woocommerce_update_options( $yit_options[ $current_tab ] );
307
+
308
+ do_action( 'yit_panel_wc_after_update' );
309
+
310
+ } elseif( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'wc-options-reset'
311
+ && isset( $_POST['yith_wc_reset_options_nonce'] ) && wp_verify_nonce( $_POST['yith_wc_reset_options_nonce'], 'yith_wc_reset_options_'.$this->settings['page'] )){
312
+
313
+ do_action( 'yit_panel_wc_before_reset' );
314
+
315
+ $yit_options = $this->get_main_array_options();
316
+ $current_tab = $this->get_current_tab();
317
+
318
+ foreach( $yit_options[ $current_tab ] as $id => $option ){
319
+ if( isset( $option['default'] ) ){
320
+ update_option( $option['id'], $option['default'] );
321
+ }
322
+ }
323
+
324
+ do_action( 'yit_panel_wc_after_reset' );
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Add Admin WC Style and Scripts
330
+ *
331
+ * @return void
332
+ * @since 1.0
333
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
334
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
335
+ */
336
+ public function admin_enqueue_scripts() {
337
+ global $woocommerce, $pagenow;
338
+
339
+ wp_enqueue_style( 'raleway-font', '//fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,100,200,300,900' );
340
+
341
+ wp_enqueue_media();
342
+ wp_enqueue_style( 'woocommerce_admin_styles', $woocommerce->plugin_url() . '/assets/css/admin.css', array(), $woocommerce->version );
343
+ wp_register_style( 'yit-plugin-style', YIT_CORE_PLUGIN_URL . '/assets/css/yit-plugin-panel.css', $woocommerce->version );
344
+ wp_register_style( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/css/colorbox.css', array(), $woocommerce->version );
345
+ wp_register_style( 'yit-upgrade-to-pro', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrade-to-pro.css', array( 'colorbox' ), $woocommerce->version );
346
+
347
+ if ( 'customize.php' != $pagenow ){
348
+
349
+ wp_enqueue_style ( 'wp-jquery-ui-dialog' );
350
+
351
+ }
352
+
353
+ wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
354
+ wp_enqueue_script( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array( 'jquery' ), '1.1.0', true );
355
+ wp_enqueue_script( 'woocommerce_settings', $woocommerce->plugin_url() . '/assets/js/admin/settings.min.js', array( 'jquery', 'jquery-ui-datepicker','jquery-ui-dialog', 'jquery-ui-sortable', 'iris', 'chosen' ), $woocommerce->version, true );
356
+ wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox.js', array( 'jquery' ), '1.6.3', true );
357
+ wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.min.js', array( 'jquery', 'jquery-chosen' ), $this->version, true );
358
+ wp_localize_script( 'woocommerce_settings', 'woocommerce_settings_params', array(
359
+ 'i18n_nav_warning' => __( 'The changes you have made will be lost if you leave this page.', 'yith-plugin-fw' )
360
+ ) );
361
+
362
+ if( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yith-plugins_page' ) !== false ){
363
+ wp_enqueue_style( 'yit-plugin-style' );
364
+ wp_enqueue_script( 'yit-plugin-panel' );
365
+ }
366
+
367
+ if( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yith_upgrade_premium_version' ) !== false ){
368
+ wp_enqueue_style( 'yit-upgrade-to-pro' );
369
+ wp_enqueue_script( 'colorbox' );
370
+ }
371
+ }
372
+
373
+ /**
374
+ * Default options
375
+ *
376
+ * Sets up the default options used on the settings page
377
+ *
378
+ * @access public
379
+ * @return void
380
+ * @since 1.0.0
381
+ */
382
+ public function set_default_options() {
383
+
384
+ $default_options = $this->get_main_array_options();
385
+
386
+ foreach ($default_options as $section) {
387
+ foreach ( $section as $value ) {
388
+ if ( ( isset( $value['std'] ) || isset( $value['default'] ) ) && isset( $value['id'] ) ) {
389
+ $default_value = ( isset( $value['default'] ) ) ? $value['default'] : $value['std'];
390
+
391
+ if ( $value['type'] == 'image_width' ) {
392
+ add_option($value['id'].'_width', $default_value);
393
+ add_option($value['id'].'_height', $default_value);
394
+ } else {
395
+ add_option($value['id'], $default_value);
396
+ }
397
+ }
398
+
399
+ }
400
+ }
401
+
402
+ }
403
+
404
+ /**
405
+ * Add the woocommerce body class in plugin panel page
406
+ *
407
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
408
+ * @since 2.0
409
+ * @param $classes The body classes
410
+ *
411
+ * @return array Filtered body classes
412
+ */
413
+ public function admin_body_class( $admin_body_classes ){
414
+ global $pagenow;
415
+ return 'admin.php' == $pagenow && substr_count( $admin_body_classes, 'woocommerce' ) == 0 ? $admin_body_classes .= ' woocommerce ' : $admin_body_classes;
416
+ }
417
+
418
+ /**
419
+ * Maybe unserialize panel data
420
+ *
421
+ * @param $value mixed Option value
422
+ * @param $option mixed Option settings array
423
+ * @param $raw_value string Raw option value
424
+ *
425
+ * @return mixed Filtered return value
426
+ * @author Antonio La Rocca <antonio.larocca@yithemes.com>
427
+ * @since 2.0
428
+ */
429
+ public function maybe_unserialize_panel_data( $value, $option, $raw_value ) {
430
+
431
+
432
+ if( ! version_compare( WC()->version, '2.4.0', '>=' ) || ! isset( $option['type' ] ) || in_array( $option['type'], $this->wc_type ) ) {
433
+ return $value;
434
+ }
435
+
436
+ $yit_options = $this->get_main_array_options();
437
+ $current_tab = $this->get_current_tab();
438
+
439
+ if( ! empty( $yit_options[ $current_tab ] ) ){
440
+ foreach( $yit_options[ $current_tab ] as $option_array ){
441
+ if( isset( $option_array['id'] ) && isset( $option['id'] ) && $option_array['id'] == $option['id'] ){
442
+ return maybe_unserialize( $value );
443
+ }
444
+ }
445
+ }
446
+
447
+ return $value;
448
+ }
449
+
450
+ }
451
  }
plugin-fw/lib/yit-plugin-panel.php CHANGED
@@ -1,831 +1,921 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
16
- /**
17
- * YIT Plugin Panel
18
- *
19
- * Setting Page to Manage Plugins
20
- *
21
- * @class YIT_Plugin_Panel
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Your Inspiration Themes
25
- */
26
-
27
- class YIT_Plugin_Panel {
28
-
29
- /**
30
- * @var string version of class
31
- */
32
- public $version = '1.0.0';
33
-
34
- /**
35
- * @var array a setting list of parameters
36
- */
37
- public $settings = array();
38
-
39
- /**
40
- * @var array
41
- */
42
- protected $_tabs_path_files;
43
-
44
- /**
45
- * @var array
46
- */
47
- private $_main_array_options = array();
48
-
49
- /**
50
- * Constructor
51
- *
52
- * @since 1.0
53
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
54
- *
55
- * @param array $args
56
- */
57
- public function __construct( $args = array() ) {
58
-
59
- if ( ! empty( $args ) ) {
60
-
61
- $default_args = array(
62
- 'parent_slug' => 'edit.php?',
63
- 'page_title' => __( 'Plugin Settings', 'yith-plugin-fw' ),
64
- 'menu_title' => __( 'Settings', 'yith-plugin-fw' ),
65
- 'capability' => 'manage_options',
66
- 'icon_url' => '',
67
- 'position' => null
68
- );
69
-
70
- $this->settings = wp_parse_args( $args, $default_args );
71
- $this->_tabs_path_files = $this->get_tabs_path_files();
72
-
73
- if ( isset( $this->settings['create_menu_page'] ) && $this->settings['create_menu_page'] ) {
74
- $this->add_menu_page();
75
- }
76
-
77
- add_action( 'admin_init', array( $this, 'register_settings' ) );
78
- add_action( 'admin_menu', array( $this, 'add_setting_page' ), 20 );
79
- add_action( 'admin_menu', array( $this, 'add_premium_version_upgrade_to_menu' ), 100 );
80
- add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
81
- add_action( 'admin_init', array( $this, 'add_fields' ) );
82
- add_filter( 'yit_show_upgrade_to_premium_version', '__return_false' );
83
-
84
- }
85
-
86
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
87
- }
88
-
89
- /**
90
- * Add Menu page link
91
- *
92
- * @return void
93
- * @since 1.0
94
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
95
- */
96
- public function add_menu_page() {
97
- global $admin_page_hooks;
98
-
99
- if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ){
100
- $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
101
- add_menu_page( 'yit_plugin_panel', __( 'YITH Plugins', 'yith-plugin-fw' ), 'manage_options', 'yit_plugin_panel', NULL, YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png', $position );
102
- }
103
- }
104
-
105
- /**
106
- * Remove duplicate submenu
107
- *
108
- * Submenu page hack: Remove the duplicate YIT Plugin link on subpages
109
- *
110
- * @return void
111
- * @since 1.0
112
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
113
- */
114
- public function remove_duplicate_submenu_page() {
115
- /* === Duplicate Items Hack === */
116
- remove_submenu_page( 'yit_plugin_panel', 'yit_plugin_panel' );
117
- }
118
-
119
- /**
120
- * Enqueue script and styles in admin side
121
- *
122
- * Add style and scripts to administrator
123
- *
124
- * @return void
125
- * @since 1.0
126
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
127
- */
128
- public function admin_enqueue_scripts() {
129
-
130
- global $wp_scripts, $pagenow;
131
-
132
- //scripts
133
- wp_enqueue_media();
134
- wp_enqueue_script( 'jquery-ui' );
135
- wp_enqueue_script( 'jquery-ui-core' );
136
- wp_enqueue_script( 'jquery-ui-slider' );
137
- wp_enqueue_script( 'jquery-ui-dialog' );
138
- wp_enqueue_script( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array( 'jquery' ), '1.1.0', true );
139
- wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.js', array( 'jquery', 'jquery-chosen' ), $this->version, true );
140
- wp_register_script( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/codemirror.js', array( 'jquery' ), $this->version, true );
141
- wp_register_script( 'codemirror-javascript', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/javascript.js', array( 'jquery', 'codemirror' ), $this->version, true );
142
-
143
- //styles
144
- $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2';
145
- wp_register_style( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/css/codemirror/codemirror.css' );
146
- wp_enqueue_style( 'jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-custom/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all' );
147
- wp_register_style( 'yit-plugin-style', YIT_CORE_PLUGIN_URL . '/assets/css/yit-plugin-panel.css', $this->version );
148
- wp_enqueue_style( 'raleway-font', '//fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,100,200,300,900' );
149
- wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
150
- wp_enqueue_style( 'yit-jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version );
151
-
152
- if( ( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yith-plugins_page' ) !== false ) || apply_filters( 'yit_plugin_panel_asset_loading', false ) ){
153
- wp_enqueue_style( 'yit-plugin-style' );
154
- wp_enqueue_script( 'yit-plugin-panel' );
155
- }
156
- }
157
-
158
- /**
159
- * Register Settings
160
- *
161
- * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output
162
- *
163
- * @return void
164
- * @since 1.0
165
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
166
- */
167
- public function register_settings() {
168
- register_setting( 'yit_' . $this->settings['parent'] . '_options', 'yit_' . $this->settings['parent'] . '_options', array( $this, 'options_validate' ) );
169
- }
170
-
171
- /**
172
- * Options Validate
173
- *
174
- * a callback function called by Register Settings function
175
- *
176
- * @param $input
177
- *
178
- * @return array validate input fields
179
- * @since 1.0
180
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
181
- */
182
- public function options_validate( $input ) {
183
-
184
- $current_tab = ! empty( $input['current_tab'] ) ? $input['current_tab'] : 'general';
185
-
186
- $yit_options = $this->get_main_array_options();
187
-
188
- // default
189
- $valid_input = $this->get_options();
190
-
191
- $submit = ( ! empty( $input['submit-general'] ) ? true : false );
192
- $reset = ( ! empty( $input['reset-general'] ) ? true : false );
193
-
194
- foreach ( $yit_options[$current_tab] as $section => $data ) {
195
- foreach ( $data as $option ) {
196
- if ( isset( $option['sanitize_call'] ) && isset( $option['id'] ) ) { //yiw_debug($option, false);
197
- if ( is_array( $option['sanitize_call'] ) ) :
198
- foreach ( $option['sanitize_call'] as $callback ) {
199
- if ( is_array( $input[$option['id']] ) ) {
200
- $valid_input[$option['id']] = array_map( $callback, $input[$option['id']] );
201
- }
202
- else {
203
- $valid_input[$option['id']] = call_user_func( $callback, $input[$option['id']] );
204
- }
205
- }
206
- else :
207
- if ( is_array( $input[$option['id']] ) ) {
208
- $valid_input[$option['id']] = array_map( $option['sanitize_call'], $input[$option['id']] );
209
- }
210
- else {
211
- $valid_input[$option['id']] = call_user_func( $option['sanitize_call'], $input[$option['id']] );
212
- }
213
- endif;
214
- }
215
- else {
216
- if ( isset( $option['id'] ) ) {
217
- if ( isset( $input[$option['id']] ) ) {
218
- $valid_input[$option['id']] = $input[$option['id']];
219
- }
220
- else {
221
- $valid_input[$option['id']] = 'no';
222
- }
223
-
224
- }
225
- }
226
-
227
- }
228
- }
229
-
230
- return $valid_input;
231
- }
232
-
233
- /**
234
- * Add Setting SubPage
235
- *
236
- * add Setting SubPage to wordpress administrator
237
- *
238
- * @return array validate input fields
239
- * @since 1.0
240
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
241
- */
242
- public function add_setting_page() {
243
- $this->settings['icon_url'] = isset( $this->settings['icon_url'] ) ? $this->settings['icon_url'] : '';
244
- $this->settings['position'] = isset( $this->settings['position'] ) ? $this->settings['position'] : null;
245
- $parent = $this->settings['parent_slug'] . $this->settings['parent_page'];
246
-
247
- if ( ! empty( $parent ) ) {
248
- add_submenu_page( $parent, $this->settings['page_title'], $this->settings['menu_title'], $this->settings['capability'], $this->settings['page'], array( $this, 'yit_panel' ) );
249
- } else {
250
- add_menu_page( $this->settings['page_title'], $this->settings['menu_title'], $this->settings['capability'], $this->settings['page'], array( $this, 'yit_panel' ), $this->settings['icon_url'], $this->settings['position'] );
251
- }
252
- /* === Duplicate Items Hack === */
253
- $this->remove_duplicate_submenu_page();
254
- do_action( 'yit_after_add_settings_page' );
255
-
256
-
257
- }
258
-
259
- /**
260
- * Add Premium Version upgrade menu item
261
- *
262
- * @return void
263
- * @since 2.9.13
264
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
265
- */
266
- public function add_premium_version_upgrade_to_menu(){
267
- global $_parent_pages;
268
-
269
- if( apply_filters( 'yit_show_upgrade_to_premium_version', ! isset( $_parent_pages['yith_upgrade_premium_version'] ) ) ){
270
- add_submenu_page( 'yit_plugin_panel', __( 'Premium version upgrade', 'yith-plugin-fw' ), __( 'Premium version upgrade', 'yith-plugin-fw' ), 'install_plugins', 'yith_upgrade_premium_version', array( $this, 'show_premium_version_upgrade' ) );
271
- }
272
- }
273
-
274
- /**
275
- * Show a tabbed panel to setting page
276
- *
277
- * a callback function called by add_setting_page => add_submenu_page
278
- *
279
- * @return void
280
- * @since 1.0
281
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
282
- */
283
- public function yit_panel() {
284
-
285
- $tabs = '';
286
- $current_tab = $this->get_current_tab();
287
- $yit_options = $this->get_main_array_options();
288
-
289
- // tabs
290
- foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) {
291
- $active_class = ( $current_tab == $tab ) ? ' nav-tab-active' : '';
292
- $tabs .= '<a class="nav-tab' . $active_class . '" href="?' . $this->settings['parent_page'] . '&page=' . $this->settings['page'] . '&tab=' . $tab . '">' . $tab_value . '</a>';
293
- }
294
- ?>
295
- <div id="icon-themes" class="icon32"><br /></div>
296
- <h2 class="nav-tab-wrapper">
297
- <?php echo $tabs ?>
298
- </h2>
299
- <?php
300
- $custom_tab_action = $this->is_custom_tab( $yit_options, $current_tab );
301
- if ( $custom_tab_action ) {
302
- $this->print_custom_tab( $custom_tab_action );
303
- return;
304
- }
305
- ?>
306
- <?php $this->print_video_box(); ?>
307
- <div id="wrap" class="plugin-option">
308
- <?php $this->message(); ?>
309
- <h2><?php echo $this->get_tab_title() ?></h2>
310
- <?php if ( $this->is_show_form() ) : ?>
311
- <form method="post" action="options.php">
312
- <?php do_settings_sections( 'yit' ); ?>
313
- <p>&nbsp;</p>
314
- <?php settings_fields( 'yit_' . $this->settings['parent'] . '_options' ); ?>
315
- <input type="hidden" name="<?php echo $this->get_name_field( 'current_tab' ) ?>" value="<?php echo esc_attr( $current_tab ) ?>" />
316
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'yith-plugin-fw' ) ?>" style="float:left;margin-right:10px;" />
317
- </form>
318
- <form method="post">
319
- <?php $warning = __( 'If you continue with this action, you will reset all options in this page.', 'yith-plugin-fw' ) ?>
320
- <input type="hidden" name="yit-action" value="reset" />
321
- <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset to default', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
322
- </form>
323
- <p>&nbsp;</p>
324
- <?php endif ?>
325
- </div>
326
- <?php
327
- }
328
-
329
- public function is_custom_tab( $options, $current_tab ) {
330
- foreach ( $options[$current_tab] as $section => $option ) {
331
- if ( isset( $option['type'] ) && isset( $option['action'] ) && 'custom_tab' == $option['type'] && ! empty( $option['action'] ) ) {
332
- return $option['action'];
333
- }
334
- else {
335
- return false;
336
- }
337
- }
338
- }
339
-
340
- /**
341
- * Fire the action to print the custom tab
342
- *
343
- *
344
- * @param $action Action to fire
345
- *
346
- * @return void
347
- * @since 1.0
348
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
349
- */
350
- public function print_custom_tab( $action ) {
351
- do_action( $action );
352
- }
353
-
354
- /**
355
- * Add sections and fields to setting panel
356
- *
357
- * read all options and show sections and fields
358
- *
359
- * @return void
360
- * @since 1.0
361
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
362
- */
363
- public function add_fields() {
364
- $yit_options = $this->get_main_array_options();
365
- $current_tab = $this->get_current_tab();
366
-
367
- if ( ! $current_tab ) {
368
- return;
369
- }
370
- foreach ( $yit_options[$current_tab] as $section => $data ) {
371
- add_settings_section( "yit_settings_{$current_tab}_{$section}", $this->get_section_title( $section ), $this->get_section_description( $section ), 'yit' );
372
- foreach ( $data as $option ) {
373
- if ( isset( $option['id'] ) && isset( $option['type'] ) && isset( $option['name'] ) ) {
374
- add_settings_field( "yit_setting_" . $option['id'], $option['name'], array( $this, 'render_field' ), 'yit', "yit_settings_{$current_tab}_{$section}", array( 'option' => $option, 'label_for' => $this->get_id_field( $option['id'] ) ) );
375
- }
376
- }
377
- }
378
- }
379
-
380
-
381
- /**
382
- * Add the tabs to admin bar menu
383
- *
384
- * set all tabs of settings page on wp admin bar
385
- *
386
- * @return void|array return void when capability is false
387
- * @since 1.0
388
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
389
- */
390
- public function add_admin_bar_menu() {
391
-
392
- global $wp_admin_bar;
393
-
394
- if ( ! current_user_can( 'manage_options' ) ) {
395
- return;
396
- }
397
-
398
- if ( ! empty( $this->settings['admin_tabs'] ) ) {
399
- foreach ( $this->settings['admin-tabs'] as $item => $title ) {
400
-
401
- $wp_admin_bar->add_menu( array(
402
- 'parent' => $this->settings['parent'],
403
- 'title' => $title,
404
- 'id' => $this->settings['parent'] . '-' . $item,
405
- 'href' => admin_url( 'themes.php' ) . '?page=' . $this->settings['parent_page'] . '&tab=' . $item
406
- ) );
407
- }
408
- }
409
- }
410
-
411
-
412
- /**
413
- * Get current tab
414
- *
415
- * get the id of tab showed, return general is the current tab is not defined
416
- *
417
- * @return string
418
- * @since 1.0
419
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
420
- */
421
- function get_current_tab() {
422
- $admin_tabs = array_keys( $this->settings['admin-tabs'] );
423
-
424
- if ( ! isset( $_GET['page'] ) || $_GET['page'] != $this->settings['page'] ) {
425
- return false;
426
- }
427
- if ( isset( $_REQUEST['yit_tab_options'] ) ) {
428
- return $_REQUEST['yit_tab_options'];
429
- }
430
- elseif ( isset( $_GET['tab'] ) && isset( $this->_tabs_path_files[$_GET['tab']] ) ) {
431
- return $_GET['tab'];
432
- }
433
- elseif ( isset( $admin_tabs[0] ) ) {
434
- return $admin_tabs[0];
435
- }
436
- else {
437
- return 'general';
438
- }
439
- }
440
-
441
-
442
- /**
443
- * Message
444
- *
445
- * define an array of message and show the content od message if
446
- * is find in the query string
447
- *
448
- * @return void
449
- * @since 1.0
450
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
451
- */
452
- public function message() {
453
-
454
- $message = array(
455
- 'element_exists' => $this->get_message( '<strong>' . __( 'The element you have entered already exists. Please, enter another name.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
456
- 'saved' => $this->get_message( '<strong>' . __( 'Settings saved', 'yith-plugin-fw' ) . '.</strong>', 'updated', false ),
457
- 'reset' => $this->get_message( '<strong>' . __( 'Settings reset', 'yith-plugin-fw' ) . '.</strong>', 'updated', false ),
458
- 'delete' => $this->get_message( '<strong>' . __( 'Element deleted correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
459
- 'updated' => $this->get_message( '<strong>' . __( 'Element updated correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
460
- 'settings-updated' => $this->get_message( '<strong>' . __( 'Element updated correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
461
- 'imported' => $this->get_message( '<strong>' . __( 'Database imported correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
462
- 'no-imported' => $this->get_message( '<strong>' . __( 'An error has occurred during import. Please try again.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
463
- 'file-not-valid' => $this->get_message( '<strong>' . __( 'The added file is not valid.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
464
- 'cant-import' => $this->get_message( '<strong>' . __( 'Sorry, import is disabled.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
465
- 'ord' => $this->get_message( '<strong>' . __( 'Sorting successful.', 'yith-plugin-fw' ) . '</strong>', 'updated', false )
466
- );
467
-
468
- foreach ( $message as $key => $value ) {
469
- if ( isset( $_GET[$key] ) ) {
470
- echo $message[$key];
471
- }
472
- }
473
-
474
- }
475
-
476
- /**
477
- * Get Message
478
- *
479
- * return html code of message
480
- *
481
- * @param $message
482
- * @param string $type can be 'error' or 'updated'
483
- * @param bool $echo
484
- *
485
- * @return void|string
486
- * @since 1.0
487
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
488
- */
489
- public function get_message( $message, $type = 'error', $echo = true ) {
490
- $message = '<div id="message" class="' . $type . ' fade"><p>' . $message . '</p></div>';
491
- if ( $echo ) {
492
- echo $message;
493
- }
494
- return $message;
495
- }
496
-
497
-
498
- /**
499
- * Get Tab Path Files
500
- *
501
- * return an array with filenames of tabs
502
- *
503
- * @return array
504
- * @since 1.0
505
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
506
- */
507
- function get_tabs_path_files() {
508
-
509
- $option_files_path = $this->settings['options-path'] . '/';
510
-
511
- $tabs = array();
512
-
513
- foreach ( ( array ) glob( $option_files_path . '*.php' ) as $filename ) {
514
- preg_match( '/(.*)-options\.(.*)/', basename( $filename ), $filename_parts );
515
-
516
- if ( ! isset( $filename_parts[1] ) ) {
517
- continue;
518
- }
519
-
520
- $tab = $filename_parts[1];
521
-
522
- $tabs[$tab] = $filename;
523
- }
524
-
525
- return $tabs;
526
- }
527
-
528
- /**
529
- * Get main array options
530
- *
531
- * return an array with all options defined on options-files
532
- *
533
- * @return array
534
- * @since 1.0
535
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
536
- */
537
- function get_main_array_options() {
538
- if ( ! empty( $this->_main_array_options ) ) {
539
- return $this->_main_array_options;
540
- }
541
-
542
- foreach ( $this->settings['admin-tabs'] as $item => $v ) {
543
- $path = $this->settings['options-path'] . '/' . $item . '-options.php';
544
- if ( file_exists( $path ) ) {
545
- $this->_main_array_options = array_merge( $this->_main_array_options, include $path );
546
- }
547
- }
548
-
549
- return $this->_main_array_options;
550
- }
551
-
552
-
553
- /**
554
- * Set an array with all default options
555
- *
556
- * put default options in an array
557
- *
558
- * @return array
559
- * @since 1.0
560
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
561
- */
562
- public function get_default_options() {
563
- $yit_options = $this->get_main_array_options();
564
- $default_options = array();
565
-
566
- foreach ( $yit_options as $tab => $sections ) {
567
- foreach ( $sections as $section ) {
568
- foreach ( $section as $id => $value ) {
569
- if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
570
- $default_options[$value['id']] = $value['std'];
571
- }
572
- }
573
- }
574
- }
575
-
576
- unset( $yit_options );
577
- return $default_options;
578
- }
579
-
580
-
581
- /**
582
- * Get the title of the tab
583
- *
584
- * return the title of tab
585
- *
586
- * @return string
587
- * @since 1.0
588
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
589
- */
590
- function get_tab_title() {
591
- $yit_options = $this->get_main_array_options();
592
- $current_tab = $this->get_current_tab();
593
-
594
- foreach ( $yit_options[$current_tab] as $sections => $data ) {
595
- foreach ( $data as $option ) {
596
- if ( isset( $option['type'] ) && $option['type'] == 'title' ) {
597
- return $option['name'];
598
- }
599
- }
600
- }
601
- }
602
-
603
- /**
604
- * Get the title of the section
605
- *
606
- * return the title of section
607
- *
608
- * @param $section
609
- *
610
- * @return string
611
- * @since 1.0
612
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
613
- */
614
- function get_section_title( $section ) {
615
- $yit_options = $this->get_main_array_options();
616
- $current_tab = $this->get_current_tab();
617
-
618
- foreach ( $yit_options[$current_tab][$section] as $option ) {
619
- if ( isset( $option['type'] ) && $option['type'] == 'section' ) {
620
- return $option['name'];
621
- }
622
- }
623
- }
624
-
625
- /**
626
- * Get the description of the section
627
- *
628
- * return the description of section if is set
629
- *
630
- * @param $section
631
- *
632
- * @return string
633
- * @since 1.0
634
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
635
- */
636
- function get_section_description( $section ) {
637
- $yit_options = $this->get_main_array_options();
638
- $current_tab = $this->get_current_tab();
639
-
640
- foreach ( $yit_options[$current_tab][$section] as $option ) {
641
- if ( isset( $option['type'] ) && $option['type'] == 'section' && isset( $option['desc'] ) ) {
642
- return '<p>' . $option['desc'] . '</p>';
643
- }
644
- }
645
- }
646
-
647
-
648
- /**
649
- * Show form when necessary
650
- *
651
- * return true if 'showform' is not defined
652
- *
653
- * @return bool
654
- * @since 1.0
655
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
656
- */
657
- function is_show_form() {
658
- $yit_options = $this->get_main_array_options();
659
- $current_tab = $this->get_current_tab();
660
-
661
- foreach ( $yit_options[$current_tab] as $sections => $data ) {
662
- foreach ( $data as $option ) {
663
- if ( ! isset( $option['type'] ) || $option['type'] != 'title' ) {
664
- continue;
665
- }
666
- if ( isset( $option['showform'] ) ) {
667
- return $option['showform'];
668
- }
669
- else {
670
- return true;
671
- }
672
- }
673
- }
674
- }
675
-
676
- /**
677
- * Get name field
678
- *
679
- * return a string with the name of the input field
680
- *
681
- * @param string $name
682
- *
683
- * @return string
684
- * @since 1.0
685
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
686
- */
687
- function get_name_field( $name = '' ) {
688
- return 'yit_' . $this->settings['parent'] . '_options[' . $name . ']';
689
- }
690
-
691
- /**
692
- * Get id field
693
- *
694
- * return a string with the id of the input field
695
- *
696
- * @param string $id
697
- *
698
- * @return string
699
- * @since 1.0
700
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
701
- */
702
- function get_id_field( $id ) {
703
- return 'yit_' . $this->settings['parent'] . '_options_' . $id;
704
- }
705
-
706
-
707
- /**
708
- * Render the field showed in the setting page
709
- *
710
- * include the file of the option type, if file do not exists
711
- * return a text area
712
- *
713
- * @param array $param
714
- *
715
- * @return void
716
- * @since 1.0
717
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
718
- */
719
- function render_field( $param ) {
720
-
721
- if ( ! empty( $param ) && isset( $param ['option'] ) ) {
722
- $option = $param ['option'];
723
- $db_options = $this->get_options();
724
-
725
- $custom_attributes = array();
726
-
727
- if ( ! empty( $option['custom_attributes'] ) && is_array( $option['custom_attributes'] ) ) {
728
- foreach ( $option['custom_attributes'] as $attribute => $attribute_value ) {
729
- $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
730
- }
731
- }
732
-
733
- $custom_attributes = implode( ' ', $custom_attributes );
734
- $std = isset( $option['std'] ) ? $option['std'] : '';
735
- $db_value = ( isset( $db_options[$option['id']] ) ) ? $db_options[$option['id']] : $std;
736
-
737
- if ( isset( $option['deps'] ) ) {
738
- $deps = $option['deps'];
739
- }
740
- $type = YIT_CORE_PLUGIN_PATH . '/templates/panel/types/' . $option['type'] . '.php';
741
- if ( file_exists( $type ) ) {
742
- include $type;
743
- }
744
- else {
745
- do_action( "yit_panel_{$option['type']}", $option, $db_value, $custom_attributes );
746
- }
747
- }
748
- }
749
-
750
- /**
751
- * Get options from db
752
- *
753
- * return the options from db, if the options aren't defined in the db,
754
- * get the default options ad add the options in the db
755
- *
756
- * @return array
757
- * @since 1.0
758
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
759
- */
760
- public function get_options() {
761
- $options = get_option( 'yit_' . $this->settings['parent'] . '_options' );
762
- if ( $options === false || ( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'reset' ) ) {
763
- $options = $this->get_default_options();
764
- }
765
- return $options;
766
- }
767
-
768
- /**
769
- * Show a box panel with specific content in two columns as a new woocommerce type
770
- *
771
- *
772
- * @param array $args
773
- *
774
- * @return void
775
- * @since 1.0
776
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
777
- */
778
- public function add_infobox( $args = array() ) {
779
- if ( ! empty( $args ) ) {
780
- extract( $args );
781
- require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/boxinfo.php' );
782
- }
783
- }
784
-
785
- /**
786
- * Show a box panel with specific content in two columns as a new woocommerce type
787
- *
788
- * @param array $args
789
- *
790
- * @return void
791
- * @since 1.0
792
- * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
793
- */
794
- public function add_videobox( $args = array() ) {
795
- if ( ! empty( $args ) ) {
796
- extract( $args );
797
- require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/videobox.php' );
798
- }
799
- }
800
-
801
- /**
802
- * Fire the action to print the custom tab
803
- *
804
- * @return void
805
- * @since 1.0
806
- * @author Antonino Scarfì <antonino.scarfi@yithemes.com>
807
- */
808
- public function print_video_box() {
809
- $file = $this->settings['options-path'] . '/video-box.php';
810
-
811
- if ( ! file_exists( $file ) ) {
812
- return;
813
- }
814
-
815
- $args = include_once( $file );
816
-
817
- $this->add_videobox( $args );
818
- }
819
-
820
- /**
821
- * Show the upgrade to pro version page
822
- *
823
- * @return void
824
- * @since 2.9.13
825
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
826
- */
827
- public function show_premium_version_upgrade() {
828
- yit_plugin_get_template ( YIT_CORE_PLUGIN_PATH, 'upgrade/upgrade-to-pro-version.php' ) ;
829
- }
830
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
831
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Plugin_Panel' ) ) {
16
+ /**
17
+ * YIT Plugin Panel
18
+ *
19
+ * Setting Page to Manage Plugins
20
+ *
21
+ * @class YIT_Plugin_Panel
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Your Inspiration Themes
25
+ */
26
+
27
+ class YIT_Plugin_Panel {
28
+
29
+ /**
30
+ * @var string version of class
31
+ */
32
+ public $version = '1.0.0';
33
+
34
+ /**
35
+ * @var array a setting list of parameters
36
+ */
37
+ public $settings = array();
38
+
39
+ /**
40
+ * @var array
41
+ */
42
+ protected $_tabs_path_files;
43
+
44
+ /**
45
+ * @var array
46
+ */
47
+ private $_main_array_options = array();
48
+
49
+ /**
50
+ * @var YIT_Plugin_Panel_Sidebar
51
+ */
52
+ public $sidebar;
53
+
54
+ /**
55
+ * @var array
56
+ */
57
+ public $links;
58
+
59
+ /**
60
+ * Constructor
61
+ *
62
+ * @since 1.0
63
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
64
+ *
65
+ * @param array $args
66
+ */
67
+ public function __construct( $args = array() ) {
68
+
69
+ if ( ! empty( $args ) ) {
70
+
71
+ $default_args = array(
72
+ 'parent_slug' => 'edit.php?',
73
+ 'page_title' => __( 'Plugin Settings', 'yith-plugin-fw' ),
74
+ 'menu_title' => __( 'Settings', 'yith-plugin-fw' ),
75
+ 'capability' => 'manage_options',
76
+ 'icon_url' => '',
77
+ 'position' => null
78
+ );
79
+
80
+ $this->settings = wp_parse_args( $args, $default_args );
81
+ $this->_tabs_path_files = $this->get_tabs_path_files();
82
+
83
+ if ( isset( $this->settings['create_menu_page'] ) && $this->settings['create_menu_page'] ) {
84
+ $this->add_menu_page();
85
+ }
86
+
87
+ if ( !empty( $this->settings[ 'links' ] ) ) {
88
+ $this->links = $this->settings[ 'links' ];
89
+ }
90
+
91
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
92
+ add_action( 'admin_menu', array( $this, 'add_setting_page' ), 20 );
93
+ add_action( 'admin_menu', array( $this, 'add_premium_version_upgrade_to_menu' ), 100 );
94
+ add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_menu' ), 100 );
95
+ add_action( 'admin_init', array( $this, 'add_fields' ) );
96
+ }
97
+
98
+ /* add YIT Plugin sidebar */
99
+ $this->sidebar = YIT_Plugin_Panel_Sidebar::instance( $this );
100
+
101
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
102
+ }
103
+
104
+ /**
105
+ * Add Menu page link
106
+ *
107
+ * @return void
108
+ * @since 1.0
109
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
110
+ */
111
+ public function add_menu_page() {
112
+ global $admin_page_hooks;
113
+
114
+ if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ){
115
+ $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
116
+ add_menu_page( 'yit_plugin_panel', __( 'YITH Plugins', 'yith-plugin-fw' ), 'manage_options', 'yit_plugin_panel', NULL, YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png', $position );
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Remove duplicate submenu
122
+ *
123
+ * Submenu page hack: Remove the duplicate YIT Plugin link on subpages
124
+ *
125
+ * @return void
126
+ * @since 1.0
127
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
128
+ */
129
+ public function remove_duplicate_submenu_page() {
130
+ /* === Duplicate Items Hack === */
131
+ remove_submenu_page( 'yit_plugin_panel', 'yit_plugin_panel' );
132
+ }
133
+
134
+ /**
135
+ * Enqueue script and styles in admin side
136
+ *
137
+ * Add style and scripts to administrator
138
+ *
139
+ * @return void
140
+ * @since 1.0
141
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
142
+ */
143
+ public function admin_enqueue_scripts() {
144
+
145
+ global $wp_scripts, $pagenow;
146
+
147
+ //scripts
148
+ wp_enqueue_media();
149
+ wp_enqueue_script( 'jquery-ui' );
150
+ wp_enqueue_script( 'jquery-ui-core' );
151
+ wp_enqueue_script( 'jquery-ui-slider' );
152
+ wp_enqueue_script( 'jquery-ui-dialog' );
153
+ wp_enqueue_script( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/js/chosen/chosen.jquery.js', array( 'jquery' ), '1.1.0', true );
154
+ wp_register_script( 'yit-plugin-panel', YIT_CORE_PLUGIN_URL . '/assets/js/yit-plugin-panel.js', array( 'jquery', 'jquery-chosen' ), $this->version, true );
155
+ wp_register_script( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/codemirror.js', array( 'jquery' ), $this->version, true );
156
+ wp_register_script( 'codemirror-javascript', YIT_CORE_PLUGIN_URL . '/assets/js/codemirror/javascript.js', array( 'jquery', 'codemirror' ), $this->version, true );
157
+ wp_register_script( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/js/jquery.colorbox.js', array( 'jquery' ), '1.6.3', true );
158
+
159
+ //styles
160
+ $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.9.2';
161
+ wp_register_style( 'codemirror', YIT_CORE_PLUGIN_URL . '/assets/css/codemirror/codemirror.css' );
162
+ wp_enqueue_style( 'jquery-ui-overcast', YIT_CORE_PLUGIN_URL . '/assets/css/overcast/jquery-ui-custom/jquery-ui-1.8.9.custom.css', false, '1.8.9', 'all' );
163
+ wp_register_style( 'yit-plugin-style', YIT_CORE_PLUGIN_URL . '/assets/css/yit-plugin-panel.css', array(), $this->version );
164
+ wp_enqueue_style( 'raleway-font', '//fonts.googleapis.com/css?family=Raleway:400,500,600,700,800,100,200,300,900' );
165
+ wp_enqueue_style( 'jquery-chosen', YIT_CORE_PLUGIN_URL . '/assets/css/chosen/chosen.css' );
166
+ wp_enqueue_style( 'yit-jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui.css', array(), $jquery_version );
167
+ wp_register_style( 'colorbox', YIT_CORE_PLUGIN_URL . '/assets/css/colorbox.css', array(), $this->version );
168
+ wp_register_style( 'yit-upgrade-to-pro', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrade-to-pro.css', array( 'colorbox' ), $this->version );
169
+
170
+ if( ( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yith-plugins_page' ) !== false ) || apply_filters( 'yit_plugin_panel_asset_loading', false ) ){
171
+ wp_enqueue_style( 'yit-plugin-style' );
172
+ wp_enqueue_script( 'yit-plugin-panel' );
173
+ }
174
+
175
+ if( 'admin.php' == $pagenow && strpos( get_current_screen()->id, 'yith_upgrade_premium_version' ) !== false ){
176
+ wp_enqueue_style( 'yit-upgrade-to-pro' );
177
+ wp_enqueue_script( 'colorbox' );
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Register Settings
183
+ *
184
+ * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output
185
+ *
186
+ * @return void
187
+ * @since 1.0
188
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
189
+ */
190
+ public function register_settings() {
191
+ register_setting( 'yit_' . $this->settings['parent'] . '_options', 'yit_' . $this->settings['parent'] . '_options', array( $this, 'options_validate' ) );
192
+ }
193
+
194
+ /**
195
+ * Options Validate
196
+ *
197
+ * a callback function called by Register Settings function
198
+ *
199
+ * @param $input
200
+ *
201
+ * @return array validate input fields
202
+ * @since 1.0
203
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
204
+ */
205
+ public function options_validate( $input ) {
206
+
207
+ $current_tab = ! empty( $input['current_tab'] ) ? $input['current_tab'] : 'general';
208
+
209
+ $yit_options = $this->get_main_array_options();
210
+
211
+ // default
212
+ $valid_input = $this->get_options();
213
+
214
+ $submit = ( ! empty( $input['submit-general'] ) ? true : false );
215
+ $reset = ( ! empty( $input['reset-general'] ) ? true : false );
216
+
217
+ foreach ( $yit_options[$current_tab] as $section => $data ) {
218
+ foreach ( $data as $option ) {
219
+ if ( isset( $option['sanitize_call'] ) && isset( $option['id'] ) ) { //yiw_debug($option, false);
220
+ if ( is_array( $option['sanitize_call'] ) ) :
221
+ foreach ( $option['sanitize_call'] as $callback ) {
222
+ if ( is_array( $input[$option['id']] ) ) {
223
+ $valid_input[$option['id']] = array_map( $callback, $input[$option['id']] );
224
+ }
225
+ else {
226
+ $valid_input[$option['id']] = call_user_func( $callback, $input[$option['id']] );
227
+ }
228
+ }
229
+ else :
230
+ if ( is_array( $input[$option['id']] ) ) {
231
+ $valid_input[$option['id']] = array_map( $option['sanitize_call'], $input[$option['id']] );
232
+ }
233
+ else {
234
+ $valid_input[$option['id']] = call_user_func( $option['sanitize_call'], $input[$option['id']] );
235
+ }
236
+ endif;
237
+ }
238
+ else {
239
+ if ( isset( $option['id'] ) ) {
240
+ if ( isset( $input[$option['id']] ) ) {
241
+ $valid_input[$option['id']] = $input[$option['id']];
242
+ }
243
+ else {
244
+ $valid_input[$option['id']] = 'no';
245
+ }
246
+
247
+ }
248
+ }
249
+
250
+ }
251
+ }
252
+
253
+ return $valid_input;
254
+ }
255
+
256
+ /**
257
+ * Add Setting SubPage
258
+ *
259
+ * add Setting SubPage to wordpress administrator
260
+ *
261
+ * @return array validate input fields
262
+ * @since 1.0
263
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
264
+ */
265
+ public function add_setting_page() {
266
+ $this->settings['icon_url'] = isset( $this->settings['icon_url'] ) ? $this->settings['icon_url'] : '';
267
+ $this->settings['position'] = isset( $this->settings['position'] ) ? $this->settings['position'] : null;
268
+ $parent = $this->settings['parent_slug'] . $this->settings['parent_page'];
269
+
270
+ if ( ! empty( $parent ) ) {
271
+ add_submenu_page( $parent, $this->settings['page_title'], $this->settings['menu_title'], $this->settings['capability'], $this->settings['page'], array( $this, 'yit_panel' ) );
272
+ } else {
273
+ add_menu_page( $this->settings['page_title'], $this->settings['menu_title'], $this->settings['capability'], $this->settings['page'], array( $this, 'yit_panel' ), $this->settings['icon_url'], $this->settings['position'] );
274
+ }
275
+ /* === Duplicate Items Hack === */
276
+ $this->remove_duplicate_submenu_page();
277
+ do_action( 'yit_after_add_settings_page' );
278
+
279
+
280
+ }
281
+
282
+ /**
283
+ * Add Premium Version upgrade menu item
284
+ *
285
+ * @return void
286
+ * @since 2.9.13
287
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
288
+ */
289
+ public function add_premium_version_upgrade_to_menu(){
290
+ global $_parent_pages;
291
+
292
+ if( apply_filters( 'yit_show_upgrade_to_premium_version', ! isset( $_parent_pages['yith_upgrade_premium_version'] ) ) ){
293
+ add_submenu_page( 'yit_plugin_panel', __( 'Premium version upgrade', 'yith-plugin-fw' ), __( 'Premium version upgrade', 'yith-plugin-fw' ), 'install_plugins', 'yith_upgrade_premium_version', array( $this, 'show_premium_version_upgrade' ) );
294
+ }
295
+ }
296
+
297
+ /**
298
+ * Show a tabbed panel to setting page
299
+ *
300
+ * a callback function called by add_setting_page => add_submenu_page
301
+ *
302
+ * @return void
303
+ * @since 1.0
304
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
305
+ */
306
+ public function yit_panel() {
307
+
308
+ $tabs = '';
309
+ $current_tab = $this->get_current_tab();
310
+ $yit_options = $this->get_main_array_options();
311
+
312
+ // tabs
313
+ foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) {
314
+ $active_class = ( $current_tab == $tab ) ? ' nav-tab-active' : '';
315
+ $tabs .= '<a class="nav-tab' . $active_class . '" href="?' . $this->settings['parent_page'] . '&page=' . $this->settings['page'] . '&tab=' . $tab . '">' . $tab_value . '</a>';
316
+ }
317
+ ?>
318
+ <div id="icon-themes" class="icon32"><br /></div>
319
+ <h2 class="nav-tab-wrapper">
320
+ <?php echo $tabs ?>
321
+ </h2>
322
+ <?php
323
+ $custom_tab_action = $this->is_custom_tab( $yit_options, $current_tab );
324
+ $hide_sidebar = $this->hide_sidebar();
325
+ if ( $custom_tab_action ) {
326
+ $this->print_custom_tab( $custom_tab_action, $hide_sidebar );
327
+ return;
328
+ }
329
+ ?>
330
+ <?php $this->print_video_box(); ?>
331
+ <?php
332
+ $panel_content_class = !$hide_sidebar ? apply_filters( 'yit_admin_panel_content_class', 'yit-admin-panel-content-wrap' ) : 'yit-admin-panel-content-wrap-no-sidebar';
333
+ ?>
334
+ <div id="wrap" class="plugin-option yit-admin-panel-container">
335
+ <?php $this->message(); ?>
336
+ <div class="<?php echo $panel_content_class; ?>">
337
+ <h2><?php echo $this->get_tab_title() ?></h2>
338
+ <?php if ( $this->is_show_form() ) : ?>
339
+ <form method="post" action="options.php">
340
+ <?php do_settings_sections( 'yit' ); ?>
341
+ <p>&nbsp;</p>
342
+ <?php settings_fields( 'yit_' . $this->settings['parent'] . '_options' ); ?>
343
+ <input type="hidden" name="<?php echo $this->get_name_field( 'current_tab' ) ?>" value="<?php echo esc_attr( $current_tab ) ?>" />
344
+ <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'yith-plugin-fw' ) ?>" style="float:left;margin-right:10px;" />
345
+ </form>
346
+ <form method="post">
347
+ <?php $warning = __( 'If you continue with this action, you will reset all options in this page.', 'yith-plugin-fw' ) ?>
348
+ <input type="hidden" name="yit-action" value="reset" />
349
+ <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset to default', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
350
+ </form>
351
+ <p>&nbsp;</p>
352
+ <?php endif ?>
353
+ </div>
354
+ <?php
355
+ /**
356
+ * Add panel Sidebar
357
+ */
358
+ if ( !$hide_sidebar )
359
+ $this->print_panel_sidebar();
360
+ ?>
361
+ </div>
362
+ <?php
363
+ }
364
+
365
+ public function is_custom_tab( $options, $current_tab ) {
366
+ foreach ( $options[$current_tab] as $section => $option ) {
367
+ if ( isset( $option['type'] ) && isset( $option['action'] ) && 'custom_tab' == $option['type'] && ! empty( $option['action'] ) ) {
368
+ return $option['action'];
369
+ }
370
+ else {
371
+ return false;
372
+ }
373
+ }
374
+ return false;
375
+ }
376
+
377
+ /**
378
+ * Print the panel sidebar
379
+ *
380
+ * @return void
381
+ * @since 1.0
382
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
383
+ */
384
+ public function print_panel_sidebar() {
385
+ $this->sidebar->print_panel_sidebar();
386
+ }
387
+
388
+ /**
389
+ * @param $options
390
+ * @param $current_tab
391
+ *
392
+ * @return bool
393
+ *
394
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
395
+ */
396
+ public function hide_sidebar( $options = '', $current_tab = '' ) {
397
+ if ( $options === '' )
398
+ $options = $this->get_main_array_options();
399
+ if ( $current_tab === '' )
400
+ $current_tab = $this->get_current_tab();
401
+
402
+ $hide = false;
403
+
404
+ foreach ( $options[ $current_tab ] as $section => $option ) {
405
+ if ( isset( $option[ 'hide_sidebar' ] ) ) {
406
+ $hide = !!$option[ 'hide_sidebar' ];
407
+ }
408
+ break;
409
+ }
410
+
411
+ $page = isset( $this->settings[ 'page' ] ) ? $this->settings[ 'page' ] : '';
412
+
413
+ return apply_filters( 'yit_panel_hide_sidebar', $hide, $page );
414
+ }
415
+
416
+ /**
417
+ * Fire the action to print the custom tab
418
+ *
419
+ *
420
+ * @param string $action Action to fire
421
+ * @param bool $hide_sidebar
422
+ *
423
+ * @return void
424
+ * @since 1.0
425
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
426
+ * @author Leanza Francesco <leanzafrancesco@gmail.com>
427
+ */
428
+ public function print_custom_tab( $action, $hide_sidebar = false ) {
429
+ if ( !$hide_sidebar ) {
430
+ $panel_content_class = apply_filters( 'yit_admin_panel_content_class', 'yit-admin-panel-content-wrap' ) ;
431
+ echo "<div class='yit-admin-panel-container'>";
432
+ echo "<div class='$panel_content_class'>";
433
+
434
+ do_action( $action );
435
+
436
+ echo "</div>";
437
+ $this->print_panel_sidebar();
438
+ echo "</div>";
439
+ } else {
440
+ do_action( $action );
441
+ }
442
+ }
443
+
444
+ /**
445
+ * Add sections and fields to setting panel
446
+ *
447
+ * read all options and show sections and fields
448
+ *
449
+ * @return void
450
+ * @since 1.0
451
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
452
+ */
453
+ public function add_fields() {
454
+ $yit_options = $this->get_main_array_options();
455
+ $current_tab = $this->get_current_tab();
456
+
457
+ if ( ! $current_tab ) {
458
+ return;
459
+ }
460
+ foreach ( $yit_options[$current_tab] as $section => $data ) {
461
+ add_settings_section( "yit_settings_{$current_tab}_{$section}", $this->get_section_title( $section ), $this->get_section_description( $section ), 'yit' );
462
+ foreach ( $data as $option ) {
463
+ if ( isset( $option['id'] ) && isset( $option['type'] ) && isset( $option['name'] ) ) {
464
+ add_settings_field( "yit_setting_" . $option['id'], $option['name'], array( $this, 'render_field' ), 'yit', "yit_settings_{$current_tab}_{$section}", array( 'option' => $option, 'label_for' => $this->get_id_field( $option['id'] ) ) );
465
+ }
466
+ }
467
+ }
468
+ }
469
+
470
+
471
+ /**
472
+ * Add the tabs to admin bar menu
473
+ *
474
+ * set all tabs of settings page on wp admin bar
475
+ *
476
+ * @return void|array return void when capability is false
477
+ * @since 1.0
478
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
479
+ */
480
+ public function add_admin_bar_menu() {
481
+
482
+ global $wp_admin_bar;
483
+
484
+ if ( ! current_user_can( 'manage_options' ) ) {
485
+ return;
486
+ }
487
+
488
+ if ( ! empty( $this->settings['admin_tabs'] ) ) {
489
+ foreach ( $this->settings['admin-tabs'] as $item => $title ) {
490
+
491
+ $wp_admin_bar->add_menu( array(
492
+ 'parent' => $this->settings['parent'],
493
+ 'title' => $title,
494
+ 'id' => $this->settings['parent'] . '-' . $item,
495
+ 'href' => admin_url( 'themes.php' ) . '?page=' . $this->settings['parent_page'] . '&tab=' . $item
496
+ ) );
497
+ }
498
+ }
499
+ }
500
+
501
+
502
+ /**
503
+ * Get current tab
504
+ *
505
+ * get the id of tab showed, return general is the current tab is not defined
506
+ *
507
+ * @return string
508
+ * @since 1.0
509
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
510
+ */
511
+ function get_current_tab() {
512
+ $admin_tabs = array_keys( $this->settings['admin-tabs'] );
513
+
514
+ if ( ! isset( $_GET['page'] ) || $_GET['page'] != $this->settings['page'] ) {
515
+ return false;
516
+ }
517
+ if ( isset( $_REQUEST['yit_tab_options'] ) ) {
518
+ return $_REQUEST['yit_tab_options'];
519
+ }
520
+ elseif ( isset( $_GET['tab'] ) && isset( $this->_tabs_path_files[$_GET['tab']] ) ) {
521
+ return $_GET['tab'];
522
+ }
523
+ elseif ( isset( $admin_tabs[0] ) ) {
524
+ return $admin_tabs[0];
525
+ }
526
+ else {
527
+ return 'general';
528
+ }
529
+ }
530
+
531
+
532
+ /**
533
+ * Message
534
+ *
535
+ * define an array of message and show the content od message if
536
+ * is find in the query string
537
+ *
538
+ * @return void
539
+ * @since 1.0
540
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
541
+ */
542
+ public function message() {
543
+
544
+ $message = array(
545
+ 'element_exists' => $this->get_message( '<strong>' . __( 'The element you have entered already exists. Please, enter another name.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
546
+ 'saved' => $this->get_message( '<strong>' . __( 'Settings saved', 'yith-plugin-fw' ) . '.</strong>', 'updated', false ),
547
+ 'reset' => $this->get_message( '<strong>' . __( 'Settings reset', 'yith-plugin-fw' ) . '.</strong>', 'updated', false ),
548
+ 'delete' => $this->get_message( '<strong>' . __( 'Element deleted correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
549
+ 'updated' => $this->get_message( '<strong>' . __( 'Element updated correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
550
+ 'settings-updated' => $this->get_message( '<strong>' . __( 'Element updated correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
551
+ 'imported' => $this->get_message( '<strong>' . __( 'Database imported correctly.', 'yith-plugin-fw' ) . '</strong>', 'updated', false ),
552
+ 'no-imported' => $this->get_message( '<strong>' . __( 'An error has occurred during import. Please try again.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
553
+ 'file-not-valid' => $this->get_message( '<strong>' . __( 'The added file is not valid.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
554
+ 'cant-import' => $this->get_message( '<strong>' . __( 'Sorry, import is disabled.', 'yith-plugin-fw' ) . '</strong>', 'error', false ),
555
+ 'ord' => $this->get_message( '<strong>' . __( 'Sorting successful.', 'yith-plugin-fw' ) . '</strong>', 'updated', false )
556
+ );
557
+
558
+ foreach ( $message as $key => $value ) {
559
+ if ( isset( $_GET[$key] ) ) {
560
+ echo $message[$key];
561
+ }
562
+ }
563
+
564
+ }
565
+
566
+ /**
567
+ * Get Message
568
+ *
569
+ * return html code of message
570
+ *
571
+ * @param $message
572
+ * @param string $type can be 'error' or 'updated'
573
+ * @param bool $echo
574
+ *
575
+ * @return void|string
576
+ * @since 1.0
577
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
578
+ */
579
+ public function get_message( $message, $type = 'error', $echo = true ) {
580
+ $message = '<div id="message" class="' . $type . ' fade"><p>' . $message . '</p></div>';
581
+ if ( $echo ) {
582
+ echo $message;
583
+ }
584
+ return $message;
585
+ }
586
+
587
+
588
+ /**
589
+ * Get Tab Path Files
590
+ *
591
+ * return an array with filenames of tabs
592
+ *
593
+ * @return array
594
+ * @since 1.0
595
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
596
+ */
597
+ function get_tabs_path_files() {
598
+
599
+ $option_files_path = $this->settings['options-path'] . '/';
600
+
601
+ $tabs = array();
602
+
603
+ foreach ( ( array ) glob( $option_files_path . '*.php' ) as $filename ) {
604
+ preg_match( '/(.*)-options\.(.*)/', basename( $filename ), $filename_parts );
605
+
606
+ if ( ! isset( $filename_parts[1] ) ) {
607
+ continue;
608
+ }
609
+
610
+ $tab = $filename_parts[1];
611
+
612
+ $tabs[$tab] = $filename;
613
+ }
614
+
615
+ return $tabs;
616
+ }
617
+
618
+ /**
619
+ * Get main array options
620
+ *
621
+ * return an array with all options defined on options-files
622
+ *
623
+ * @return array
624
+ * @since 1.0
625
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
626
+ */
627
+ function get_main_array_options() {
628
+ if ( ! empty( $this->_main_array_options ) ) {
629
+ return $this->_main_array_options;
630
+ }
631
+
632
+ foreach ( $this->settings['admin-tabs'] as $item => $v ) {
633
+ $path = $this->settings['options-path'] . '/' . $item . '-options.php';
634
+ if ( file_exists( $path ) ) {
635
+ $this->_main_array_options = array_merge( $this->_main_array_options, include $path );
636
+ }
637
+ }
638
+
639
+ return $this->_main_array_options;
640
+ }
641
+
642
+
643
+ /**
644
+ * Set an array with all default options
645
+ *
646
+ * put default options in an array
647
+ *
648
+ * @return array
649
+ * @since 1.0
650
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
651
+ */
652
+ public function get_default_options() {
653
+ $yit_options = $this->get_main_array_options();
654
+ $default_options = array();
655
+
656
+ foreach ( $yit_options as $tab => $sections ) {
657
+ foreach ( $sections as $section ) {
658
+ foreach ( $section as $id => $value ) {
659
+ if ( isset( $value['std'] ) && isset( $value['id'] ) ) {
660
+ $default_options[$value['id']] = $value['std'];
661
+ }
662
+ }
663
+ }
664
+ }
665
+
666
+ unset( $yit_options );
667
+ return $default_options;
668
+ }
669
+
670
+
671
+ /**
672
+ * Get the title of the tab
673
+ *
674
+ * return the title of tab
675
+ *
676
+ * @return string
677
+ * @since 1.0
678
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
679
+ */
680
+ function get_tab_title() {
681
+ $yit_options = $this->get_main_array_options();
682
+ $current_tab = $this->get_current_tab();
683
+
684
+ foreach ( $yit_options[$current_tab] as $sections => $data ) {
685
+ foreach ( $data as $option ) {
686
+ if ( isset( $option['type'] ) && $option['type'] == 'title' ) {
687
+ return $option['name'];
688
+ }
689
+ }
690
+ }
691
+ }
692
+
693
+ /**
694
+ * Get the title of the section
695
+ *
696
+ * return the title of section
697
+ *
698
+ * @param $section
699
+ *
700
+ * @return string
701
+ * @since 1.0
702
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
703
+ */
704
+ function get_section_title( $section ) {
705
+ $yit_options = $this->get_main_array_options();
706
+ $current_tab = $this->get_current_tab();
707
+
708
+ foreach ( $yit_options[$current_tab][$section] as $option ) {
709
+ if ( isset( $option['type'] ) && $option['type'] == 'section' ) {
710
+ return $option['name'];
711
+ }
712
+ }
713
+ }
714
+
715
+ /**
716
+ * Get the description of the section
717
+ *
718
+ * return the description of section if is set
719
+ *
720
+ * @param $section
721
+ *
722
+ * @return string
723
+ * @since 1.0
724
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
725
+ */
726
+ function get_section_description( $section ) {
727
+ $yit_options = $this->get_main_array_options();
728
+ $current_tab = $this->get_current_tab();
729
+
730
+ foreach ( $yit_options[$current_tab][$section] as $option ) {
731
+ if ( isset( $option['type'] ) && $option['type'] == 'section' && isset( $option['desc'] ) ) {
732
+ return '<p>' . $option['desc'] . '</p>';
733
+ }
734
+ }
735
+ }
736
+
737
+
738
+ /**
739
+ * Show form when necessary
740
+ *
741
+ * return true if 'showform' is not defined
742
+ *
743
+ * @return bool
744
+ * @since 1.0
745
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
746
+ */
747
+ function is_show_form() {
748
+ $yit_options = $this->get_main_array_options();
749
+ $current_tab = $this->get_current_tab();
750
+
751
+ foreach ( $yit_options[$current_tab] as $sections => $data ) {
752
+ foreach ( $data as $option ) {
753
+ if ( ! isset( $option['type'] ) || $option['type'] != 'title' ) {
754
+ continue;
755
+ }
756
+ if ( isset( $option['showform'] ) ) {
757
+ return $option['showform'];
758
+ }
759
+ else {
760
+ return true;
761
+ }
762
+ }
763
+ }
764
+ }
765
+
766
+ /**
767
+ * Get name field
768
+ *
769
+ * return a string with the name of the input field
770
+ *
771
+ * @param string $name
772
+ *
773
+ * @return string
774
+ * @since 1.0
775
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
776
+ */
777
+ function get_name_field( $name = '' ) {
778
+ return 'yit_' . $this->settings['parent'] . '_options[' . $name . ']';
779
+ }
780
+
781
+ /**
782
+ * Get id field
783
+ *
784
+ * return a string with the id of the input field
785
+ *
786
+ * @param string $id
787
+ *
788
+ * @return string
789
+ * @since 1.0
790
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
791
+ */
792
+ function get_id_field( $id ) {
793
+ return 'yit_' . $this->settings['parent'] . '_options_' . $id;
794
+ }
795
+
796
+
797
+ /**
798
+ * Render the field showed in the setting page
799
+ *
800
+ * include the file of the option type, if file do not exists
801
+ * return a text area
802
+ *
803
+ * @param array $param
804
+ *
805
+ * @return void
806
+ * @since 1.0
807
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
808
+ */
809
+ function render_field( $param ) {
810
+
811
+ if ( ! empty( $param ) && isset( $param ['option'] ) ) {
812
+ $option = $param ['option'];
813
+ $db_options = $this->get_options();
814
+
815
+ $custom_attributes = array();
816
+
817
+ if ( ! empty( $option['custom_attributes'] ) && is_array( $option['custom_attributes'] ) ) {
818
+ foreach ( $option['custom_attributes'] as $attribute => $attribute_value ) {
819
+ $custom_attributes[] = esc_attr( $attribute ) . '="' . esc_attr( $attribute_value ) . '"';
820
+ }
821
+ }
822
+
823
+ $custom_attributes = implode( ' ', $custom_attributes );
824
+ $std = isset( $option['std'] ) ? $option['std'] : '';
825
+ $db_value = ( isset( $db_options[$option['id']] ) ) ? $db_options[$option['id']] : $std;
826
+
827
+ if ( isset( $option['deps'] ) ) {
828
+ $deps = $option['deps'];
829
+ }
830
+ $type = YIT_CORE_PLUGIN_PATH . '/templates/panel/types/' . $option['type'] . '.php';
831
+ if ( file_exists( $type ) ) {
832
+ include $type;
833
+ }
834
+ else {
835
+ do_action( "yit_panel_{$option['type']}", $option, $db_value, $custom_attributes );
836
+ }
837
+ }
838
+ }
839
+
840
+ /**
841
+ * Get options from db
842
+ *
843
+ * return the options from db, if the options aren't defined in the db,
844
+ * get the default options ad add the options in the db
845
+ *
846
+ * @return array
847
+ * @since 1.0
848
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
849
+ */
850
+ public function get_options() {
851
+ $options = get_option( 'yit_' . $this->settings['parent'] . '_options' );
852
+ if ( $options === false || ( isset( $_REQUEST['yit-action'] ) && $_REQUEST['yit-action'] == 'reset' ) ) {
853
+ $options = $this->get_default_options();
854
+ }
855
+ return $options;
856
+ }
857
+
858
+ /**
859
+ * Show a box panel with specific content in two columns as a new woocommerce type
860
+ *
861
+ *
862
+ * @param array $args
863
+ *
864
+ * @return void
865
+ * @since 1.0
866
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
867
+ */
868
+ public function add_infobox( $args = array() ) {
869
+ if ( ! empty( $args ) ) {
870
+ extract( $args );
871
+ require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/boxinfo.php' );
872
+ }
873
+ }
874
+
875
+ /**
876
+ * Show a box panel with specific content in two columns as a new woocommerce type
877
+ *
878
+ * @param array $args
879
+ *
880
+ * @return void
881
+ * @since 1.0
882
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.com>
883
+ */
884
+ public function add_videobox( $args = array() ) {
885
+ if ( ! empty( $args ) ) {
886
+ extract( $args );
887
+ require_once( YIT_CORE_PLUGIN_TEMPLATE_PATH . '/panel/videobox.php' );
888
+ }
889
+ }
890
+
891
+ /**
892
+ * Fire the action to print the custom tab
893
+ *
894
+ * @return void
895
+ * @since 1.0
896
+ * @author Antonino Scarfì <antonino.scarfi@yithemes.com>
897
+ */
898
+ public function print_video_box() {
899
+ $file = $this->settings['options-path'] . '/video-box.php';
900
+
901
+ if ( ! file_exists( $file ) ) {
902
+ return;
903
+ }
904
+
905
+ $args = include_once( $file );
906
+
907
+ $this->add_videobox( $args );
908
+ }
909
+
910
+ /**
911
+ * Show the upgrade to pro version page
912
+ *
913
+ * @return void
914
+ * @since 2.9.13
915
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
916
+ */
917
+ public function show_premium_version_upgrade() {
918
+ yit_plugin_get_template ( YIT_CORE_PLUGIN_PATH, 'upgrade/upgrade-to-pro-version.php', array( 'core_plugin_url' => YIT_CORE_PLUGIN_URL ) ) ;
919
+ }
920
+ }
921
  }
plugin-fw/lib/yit-plugin-subpanel.php CHANGED
@@ -1,164 +1,164 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( ! class_exists( 'YIT_Plugin_SubPanel' ) ) {
16
- /**
17
- * YIT Plugin Panel
18
- *
19
- * Setting Page to Manage Plugins
20
- *
21
- * @class YIT_Plugin_Panel
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Your Inspiration Themes
25
- */
26
-
27
- class YIT_Plugin_SubPanel extends YIT_Plugin_Panel {
28
-
29
- /**
30
- * @var string version of class
31
- */
32
- public $version = '1.0.0';
33
-
34
- /**
35
- * @var array a setting list of parameters
36
- */
37
- public $settings = array();
38
-
39
-
40
- /**
41
- * @var array
42
- */
43
- private $_main_array_options = array();
44
-
45
- /**
46
- * Constructor
47
- *
48
- * @since 1.0
49
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
50
- */
51
-
52
- public function __construct( $args = array() ) {
53
- if ( ! empty( $args ) ) {
54
- $this->settings = $args;
55
- $this->settings['parent'] = $this->settings['page'];
56
- $this->_tabs_path_files = $this->get_tabs_path_files();
57
-
58
- add_action( 'admin_init', array( $this, 'register_settings' ) );
59
- add_action( 'admin_menu', array( &$this, 'add_setting_page' ) );
60
- add_action( 'admin_bar_menu', array( &$this, 'add_admin_bar_menu' ), 100 );
61
- add_action( 'admin_init', array( &$this, 'add_fields' ) );
62
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
63
- }
64
- }
65
-
66
-
67
- /**
68
- * Register Settings
69
- *
70
- * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output
71
- *
72
- * @return void
73
- * @since 1.0
74
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
75
- */
76
- public function register_settings() {
77
- register_setting( 'yit_' . $this->settings['page'] . '_options', 'yit_' . $this->settings['page'] . '_options', array( &$this, 'options_validate' ) );
78
- }
79
-
80
-
81
-
82
- /**
83
- * Add Setting SubPage
84
- *
85
- * add Setting SubPage to wordpress administrator
86
- *
87
- * @return array validate input fields
88
- * @since 1.0
89
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
90
- */
91
- public function add_setting_page() {
92
- global $admin_page_hooks;
93
- $logo = YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png';
94
-
95
- $admin_logo = function_exists( 'yit_get_option' ) ? yit_get_option( 'admin-logo-menu' ) : '';
96
-
97
- if ( isset( $admin_logo ) && !empty( $admin_logo ) && $admin_logo != '' && $admin_logo ) {
98
- $logo = $admin_logo;
99
- }
100
-
101
- if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ) {
102
- $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
103
- add_menu_page( 'yit_plugin_panel', __( 'YITH Plugins', 'yith-plugin-fw' ), 'nosuchcapability', 'yit_plugin_panel', NULL, $logo, $position );
104
- }
105
-
106
- add_submenu_page( 'yit_plugin_panel', $this->settings['label'], $this->settings['label'], 'manage_options', $this->settings['page'], array( $this, 'yit_panel' ) );
107
- remove_submenu_page( 'yit_plugin_panel', 'yit_plugin_panel' );
108
-
109
- }
110
-
111
- /**
112
- * Show a tabbed panel to setting page
113
- *
114
- * a callback function called by add_setting_page => add_submenu_page
115
- *
116
- * @return void
117
- * @since 1.0
118
- * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
119
- */
120
- public function yit_panel() {
121
-
122
- $tabs = '';
123
- $current_tab = $this->get_current_tab();
124
-
125
- // tabs
126
- foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) {
127
- $active_class = ( $current_tab == $tab ) ? ' nav-tab-active' : '';
128
- $tabs .= '<a class="nav-tab' . $active_class . '" href="?page=' . $this->settings['page'] . '&tab=' . $tab . '">' . $tab_value . '</a>';
129
- }
130
- ?>
131
- <div id="icon-themes" class="icon32"><br /></div>
132
- <h2 class="nav-tab-wrapper">
133
- <?php echo $tabs ?>
134
- </h2>
135
-
136
- <div id="wrap" class="plugin-option">
137
- <?php $this->message(); ?>
138
- <h2><?php echo $this->get_tab_title() ?></h2>
139
-
140
- <?php if ( $this->is_show_form() ) : ?>
141
- <form method="post" action="options.php">
142
- <?php do_settings_sections( 'yit' ); ?>
143
- <p>&nbsp;</p>
144
- <?php settings_fields( 'yit_' . $this->settings['page'] . '_options' ); ?>
145
- <input type="hidden" name="<?php echo $this->get_name_field( 'current_tab' ) ?>" value="<?php echo esc_attr( $current_tab ) ?>" />
146
- <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'yith-plugin-fw' ) ?>" style="float:left;margin-right:10px;" />
147
- </form>
148
- <form method="post">
149
- <?php $warning = __( 'If you continue with this action, you will reset all the options in this page.', 'yith-plugin-fw' ) ?>
150
- <input type="hidden" name="yit-action" value="reset" />
151
- <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset to default', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
152
- </form>
153
- <p>&nbsp;</p>
154
- <?php endif ?>
155
- </div>
156
- <?php
157
- }
158
-
159
-
160
-
161
- }
162
-
163
- }
164
-
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Plugin_SubPanel' ) ) {
16
+ /**
17
+ * YIT Plugin Panel
18
+ *
19
+ * Setting Page to Manage Plugins
20
+ *
21
+ * @class YIT_Plugin_Panel
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Your Inspiration Themes
25
+ */
26
+
27
+ class YIT_Plugin_SubPanel extends YIT_Plugin_Panel {
28
+
29
+ /**
30
+ * @var string version of class
31
+ */
32
+ public $version = '1.0.0';
33
+
34
+ /**
35
+ * @var array a setting list of parameters
36
+ */
37
+ public $settings = array();
38
+
39
+
40
+ /**
41
+ * @var array
42
+ */
43
+ private $_main_array_options = array();
44
+
45
+ /**
46
+ * Constructor
47
+ *
48
+ * @since 1.0
49
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
50
+ */
51
+
52
+ public function __construct( $args = array() ) {
53
+ if ( ! empty( $args ) ) {
54
+ $this->settings = $args;
55
+ $this->settings['parent'] = $this->settings['page'];
56
+ $this->_tabs_path_files = $this->get_tabs_path_files();
57
+
58
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
59
+ add_action( 'admin_menu', array( &$this, 'add_setting_page' ) );
60
+ add_action( 'admin_bar_menu', array( &$this, 'add_admin_bar_menu' ), 100 );
61
+ add_action( 'admin_init', array( &$this, 'add_fields' ) );
62
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
63
+ }
64
+ }
65
+
66
+
67
+ /**
68
+ * Register Settings
69
+ *
70
+ * Generate wp-admin settings pages by registering your settings and using a few callbacks to control the output
71
+ *
72
+ * @return void
73
+ * @since 1.0
74
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
75
+ */
76
+ public function register_settings() {
77
+ register_setting( 'yit_' . $this->settings['page'] . '_options', 'yit_' . $this->settings['page'] . '_options', array( &$this, 'options_validate' ) );
78
+ }
79
+
80
+
81
+
82
+ /**
83
+ * Add Setting SubPage
84
+ *
85
+ * add Setting SubPage to wordpress administrator
86
+ *
87
+ * @return array validate input fields
88
+ * @since 1.0
89
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
90
+ */
91
+ public function add_setting_page() {
92
+ global $admin_page_hooks;
93
+ $logo = YIT_CORE_PLUGIN_URL . '/assets/images/yithemes-icon.png';
94
+
95
+ $admin_logo = function_exists( 'yit_get_option' ) ? yit_get_option( 'admin-logo-menu' ) : '';
96
+
97
+ if ( isset( $admin_logo ) && !empty( $admin_logo ) && $admin_logo != '' && $admin_logo ) {
98
+ $logo = $admin_logo;
99
+ }
100
+
101
+ if( ! isset( $admin_page_hooks['yit_plugin_panel'] ) ) {
102
+ $position = apply_filters( 'yit_plugins_menu_item_position', '62.32' );
103
+ add_menu_page( 'yit_plugin_panel', __( 'YITH Plugins', 'yith-plugin-fw' ), 'nosuchcapability', 'yit_plugin_panel', NULL, $logo, $position );
104
+ }
105
+
106
+ add_submenu_page( 'yit_plugin_panel', $this->settings['label'], $this->settings['label'], 'manage_options', $this->settings['page'], array( $this, 'yit_panel' ) );
107
+ remove_submenu_page( 'yit_plugin_panel', 'yit_plugin_panel' );
108
+
109
+ }
110
+
111
+ /**
112
+ * Show a tabbed panel to setting page
113
+ *
114
+ * a callback function called by add_setting_page => add_submenu_page
115
+ *
116
+ * @return void
117
+ * @since 1.0
118
+ * @author Emanuela Castorina <emanuela.castorina@yithemes.it>
119
+ */
120
+ public function yit_panel() {
121
+
122
+ $tabs = '';
123
+ $current_tab = $this->get_current_tab();
124
+
125
+ // tabs
126
+ foreach ( $this->settings['admin-tabs'] as $tab => $tab_value ) {
127
+ $active_class = ( $current_tab == $tab ) ? ' nav-tab-active' : '';
128
+ $tabs .= '<a class="nav-tab' . $active_class . '" href="?page=' . $this->settings['page'] . '&tab=' . $tab . '">' . $tab_value . '</a>';
129
+ }
130
+ ?>
131
+ <div id="icon-themes" class="icon32"><br /></div>
132
+ <h2 class="nav-tab-wrapper">
133
+ <?php echo $tabs ?>
134
+ </h2>
135
+
136
+ <div id="wrap" class="plugin-option">
137
+ <?php $this->message(); ?>
138
+ <h2><?php echo $this->get_tab_title() ?></h2>
139
+
140
+ <?php if ( $this->is_show_form() ) : ?>
141
+ <form method="post" action="options.php">
142
+ <?php do_settings_sections( 'yit' ); ?>
143
+ <p>&nbsp;</p>
144
+ <?php settings_fields( 'yit_' . $this->settings['page'] . '_options' ); ?>
145
+ <input type="hidden" name="<?php echo $this->get_name_field( 'current_tab' ) ?>" value="<?php echo esc_attr( $current_tab ) ?>" />
146
+ <input type="submit" class="button-primary" value="<?php _e( 'Save Changes', 'yith-plugin-fw' ) ?>" style="float:left;margin-right:10px;" />
147
+ </form>
148
+ <form method="post">
149
+ <?php $warning = __( 'If you continue with this action, you will reset all the options in this page.', 'yith-plugin-fw' ) ?>
150
+ <input type="hidden" name="yit-action" value="reset" />
151
+ <input type="submit" name="yit-reset" class="button-secondary" value="<?php _e( 'Reset to default', 'yith-plugin-fw' ) ?>" onclick="return confirm('<?php echo $warning . '\n' . __( 'Are you sure?', 'yith-plugin-fw' ) ?>');" />
152
+ </form>
153
+ <p>&nbsp;</p>
154
+ <?php endif ?>
155
+ </div>
156
+ <?php
157
+ }
158
+
159
+
160
+
161
+ }
162
+
163
+ }
164
+
plugin-fw/lib/yit-pointers.php CHANGED
@@ -1,390 +1,390 @@
1
- <?php
2
- /*
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- } // Exit if accessed directly
13
-
14
- /**
15
- *
16
- *
17
- * @class yit-pointers
18
- * @package Yithemes
19
- * @since Version 2.0.0
20
- * @author Your Inspiration Themes
21
- *
22
- */
23
- if ( ! class_exists( 'YIT_Pointers' ) ) {
24
- /**
25
- * YIT Pointers
26
- *
27
- * Initializes the new feature pointers.
28
- *
29
- * @class YIT_Pointers
30
- * @package Yithemes
31
- * @since 1.0
32
- * @author Your Inspiration Themes
33
- * @see WP_Internal_Pointers
34
- */
35
- class YIT_Pointers {
36
-
37
- /**
38
- * @var YIT_Upgrade The main instance
39
- */
40
- protected static $_instance;
41
-
42
- /**
43
- * @var screen id where to show pointer
44
- */
45
- public $screen_ids = array();
46
-
47
- public $pointers = array();
48
-
49
- public $special_screen = array();
50
-
51
- protected $_plugins_registered = array();
52
-
53
- protected $_default_pointer = array();
54
-
55
- protected $_default_position = array( 'edge' => 'left', 'align' => 'center' );
56
-
57
- /**
58
- * Construct
59
- *
60
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
61
- * @since 1.0
62
- */
63
- public function __construct() {
64
-
65
- $this->_default_pointer['plugins'] = array(
66
- 'screen_id' => 'plugins',
67
- 'options' => array(
68
- 'content' => sprintf( '<h3> %s </h3> <p> %s </p> <p> %s <a href="http://yithemes.com/product-category/plugins/" target="_blank">Yithemes.com</a> %s
69
- <a href="https://profiles.wordpress.org/yithemes/" target="_blank">Wordpress.org</a></p>',
70
- __( 'Plugins Activated', 'yith-plugin-fw' ),
71
- __( 'From now on, you can find all plugin options in YIT Plugin menu.
72
- For each plugin installed, customization settings will be available as a new entry in YIT Plugin menu.', 'yith-plugin-fw' ),
73
- __( 'Discover all our plugins available on:', 'yith-plugin-fw' ),
74
- __( 'and', 'yith-plugin-fw' )
75
- ),
76
- ),
77
- );
78
-
79
- $this->_default_pointer['update'] = array(
80
- 'screen_id' => 'update',
81
- 'options' => array(
82
- 'content' => sprintf( '<h3> %s </h3> <p> %s </p> <p> %s <a href="http://yithemes.com/product-category/plugins/" target="_blank">Yithemes.com</a> %s
83
- <a href="https://profiles.wordpress.org/yithemes/" target="_blank">Wordpress.org</a></p>',
84
- __( 'Plugins Upgraded', 'yith-plugin-fw' ),
85
- __( 'From now on, you can find all options of your plugins in YIT Plugin menu.
86
- Any time one of our plugins is updated, a new entry will be added to this menu.
87
- For example, after the update, plugin options (such as for YITH WooCommerce Wishlist, YITH WooCommerce Ajax Search, etc.)
88
- will be moved from previous location to YIT Plugin tab.', 'yith-plugin-fw' ),
89
- __( 'Discover all our plugins available on:', 'yith-plugin-fw' ),
90
- __( 'and', 'yith-plugin-fw' )
91
- ),
92
- ),
93
- );
94
-
95
- $this->_default_pointer = $this->parse_args( $this->_default_pointer );
96
-
97
- /**
98
- * Screens that require a particular action
99
- */
100
- $this->special_screen = apply_filters( 'yit-pointer-special-screen', array( 'plugins', 'update' ) );
101
-
102
- add_action( 'admin_enqueue_scripts', array( $this, 'pointer_load' ) );
103
- add_action( 'admin_init', array( $this, 'add_pointers' ), 100 );
104
- }
105
-
106
- public function parse_args( $args ) {
107
- $default = array(
108
- 'pointer_id' => 'yith_default_pointer',
109
- 'target' => '#toplevel_page_yit_plugin_panel',
110
- 'init' => null
111
- );
112
-
113
- foreach ( $args as $id => $pointer ) {
114
- $args[ $id ] = wp_parse_args( $pointer, $default );
115
- $args[ $id ]['options']['position'] = $this->_default_position;
116
- }
117
-
118
- return $args;
119
- }
120
-
121
- public function add_pointers(){
122
- if( ! empty( $this->screen_ids ) ){
123
- foreach( $this->screen_ids as $screen_id ){
124
- add_filter( "yit_pointers-{$screen_id}", array( $this, 'pointers' ) );
125
- }
126
- }
127
- }
128
-
129
- /**
130
- * Main plugin Instance
131
- *
132
- * @static
133
- * @return object Main instance
134
- *
135
- * @since 1.0
136
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
137
- */
138
- public static function instance() {
139
- if ( is_null( self::$_instance ) ) {
140
- self::$_instance = new self();
141
- }
142
-
143
- return self::$_instance;
144
- }
145
-
146
- public function register( $args ) {
147
-
148
- foreach ( $args as $id => $pointer ) {
149
-
150
- extract( $pointer );
151
-
152
- if ( ! isset( $screen_id ) && ! empty( $screen_id ) && ! isset( $init ) && ! empty( $init ) ) {
153
- return;
154
- }
155
-
156
- if ( ! in_array( $screen_id, $this->screen_ids ) ) {
157
- $this->screen_ids[] = $screen_id;
158
- }
159
-
160
- $this->pointers[$screen_id][$pointer_id] = array(
161
- 'target' => $target,
162
- 'options' => array(
163
- 'content' => $content,
164
- 'position' => $position,
165
- ),
166
- 'init' => isset( $init ) ? $init : false
167
- );
168
- }
169
- }
170
-
171
- public function get_plugins_init( $screen_id ) {
172
-
173
- $registered = array();
174
-
175
- foreach( $this->pointers[ $screen_id ] as $pointer_id => $pointer ){
176
- $registered[ $pointer['init'] ] = $pointer_id;
177
- }
178
-
179
- return $registered;
180
- }
181
-
182
- public function pointer_load( $hook_suffix ) {
183
-
184
- /**
185
- * Get pointers for this screen
186
- */
187
- $screen = get_current_screen();
188
- $pointers = apply_filters( "yit_pointers-{$screen->id}", array() );
189
-
190
- if ( ! $pointers || ! is_array( $pointers ) ) {
191
- return;
192
- }
193
-
194
- /**
195
- * Get dismissed pointers
196
- */
197
- $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
198
- $valid_pointers = array();
199
- //$point_id = null;
200
-
201
- /**
202
- * show pointers only on plugin activate action
203
- */
204
- if( in_array( $screen->id, $this->special_screen ) ){
205
-
206
- $show = false;
207
- $registered = $this->get_plugins_init( $screen->id );
208
- $recently_activate = get_option( 'yit_recently_activated', array() );
209
-
210
- /**
211
- * For "plugins" screen
212
- */
213
- $is_single_activate = ( isset( $_GET['activate'] ) && 'true' == $_GET['activate'] ) ? true : false;
214
- $is_multi_activate = ( isset( $_GET['activate-multi'] ) && 'true' == $_GET['activate-multi'] ) ? true : false;
215
-
216
- /**
217
- * For "update" screen
218
- *
219
- * Single plugin update use GET method
220
- *
221
- * Multi update plugins with bulk action send two post args called "action" and "action2"
222
- * action refer to first bulk action button (at the top of plugins table)
223
- * action2 refer to last bulk action button (at the bottom of plugins table)
224
- *
225
- */
226
- $is_single_upgrade = ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) ? true : false;
227
- $is_multi_upgrade = ( isset( $_POST['action'] ) && 'update-selected' == $_POST['action'] ) || ( isset( $_POST['action2'] ) && 'update-selected' == $_POST['action2'] ) ? true: false;
228
-
229
- if( $is_single_activate || $is_single_upgrade ){
230
-
231
- $point_id = '';
232
-
233
- /**
234
- * Single activation plugin
235
- * Single update plugin
236
- */
237
- foreach( $registered as $init => $p_id ){
238
- if ( in_array( $init, $recently_activate ) ) {
239
- $point_id = $p_id;
240
- $pointer = $pointers[ $point_id ];
241
-
242
- /**
243
- * Sanity check
244
- */
245
- if ( ! ( in_array( $point_id, $dismissed ) || empty( $pointer ) || empty( $point_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) ) {
246
- /**
247
- * Add the pointer to $valid_pointers array
248
- */
249
- $pointer['pointer_id'] = $point_id;
250
- $valid_pointers['pointers'][] = $pointer;
251
- $show = true;
252
- }
253
- break;
254
- }
255
- }
256
- } else if( $is_multi_activate || $is_multi_upgrade ){
257
-
258
- /**
259
- * Bulk Action: multi plugins activation
260
- * Bulk Action: multi plugins update
261
- */
262
- $point_id = array();
263
- $screen_id = $screen->id;
264
-
265
- if( $is_multi_upgrade && isset( $_POST['checked'] ) && ( count( $_POST['checked'] ) > 0 ) ){
266
- $recently_activate = $_POST['checked'];
267
- $screen_id = 'update';
268
- $pointers = apply_filters( "yit_pointers-{$screen_id}", array() );
269
- }
270
-
271
- foreach ( $registered as $init => $p_id ) {
272
- if ( in_array( $init, $recently_activate ) ) {
273
- $point_id[] = $p_id;
274
- }
275
- }
276
-
277
- /**
278
- * Bulk Action: Activate Plugins
279
- *
280
- * count( $point_id ) is the number of YITH plugins that have registered specific pointers
281
- * case 0 -> No pointers -> Exit
282
- * case 1 -> Only one pointers to show -> Use the specific plugin pointer
283
- * defautl -> Two or more plugins need to show a pointer -> use a generic pointers
284
- *
285
- */
286
- switch ( count( $point_id ) ) {
287
- case 0:
288
- $show = false;
289
- break;
290
-
291
- case 1:
292
- $point_id = array_pop( $point_id );
293
- $pointer = $pointers[$point_id];
294
- /**
295
- * Sanity check
296
- */
297
- if ( ! ( in_array( $point_id, $dismissed ) || empty( $pointer ) || empty( $point_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) ) {
298
- /**
299
- * Add the pointer to $valid_pointers array
300
- */
301
- $pointer['pointer_id'] = $point_id;
302
- $valid_pointers['pointers'][] = $pointer;
303
- $show = true;
304
- }
305
- break;
306
-
307
- default:
308
- $valid_pointers['pointers'][] = $this->_default_pointer[ $screen_id ];
309
- $show = true;
310
- break;
311
- }
312
- }
313
-
314
- update_option( 'yit_recently_activated', array() );
315
-
316
- if( ! $show ){
317
- return;
318
- }
319
-
320
- } else {
321
- /**
322
- * Check pointers and remove dismissed ones.
323
- */
324
- foreach ( $pointers as $pointer_id => $pointer ) {
325
-
326
- /**
327
- * Sanity check
328
- */
329
- if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) {
330
- continue;
331
- }
332
-
333
- $pointer['pointer_id'] = $pointer_id;
334
-
335
- /**
336
- * Add the pointer to $valid_pointers array
337
- */
338
- $valid_pointers['pointers'][] = $pointer;
339
- }
340
- }
341
-
342
- /**
343
- * No valid pointers? Stop here.
344
- */
345
- if ( empty( $valid_pointers ) ) {
346
- return;
347
- }
348
-
349
- $script_file = function_exists( 'yit_load_js_file' ) ? yit_load_js_file( 'yit-wp-pointer.js' ) : 'yit-wp-pointer.min.js';
350
-
351
- /**
352
- * Enqueue wp-pointer script and style
353
- */
354
- wp_enqueue_style( 'wp-pointer' );
355
- wp_enqueue_script( 'wp-pointer' );
356
-
357
- wp_enqueue_script( 'yit-wp-pointer', YIT_CORE_PLUGIN_URL . '/assets/js/' . $script_file, array( 'wp-pointer' ), false, true );
358
- wp_localize_script( 'yit-wp-pointer', 'custom_pointer', $valid_pointers );
359
- }
360
-
361
- public function pointers( $pointers ){
362
- $screen_id = str_replace( 'yit_pointers-', '', current_filter() );
363
- $pointers_to_add = $this->get_pointers( $screen_id );
364
-
365
- return ! empty( $pointers_to_add ) ? array_merge( $pointers, $pointers_to_add ) : $pointers;
366
- }
367
-
368
- public function get_pointers( $screen_id ){
369
- return isset( $this->pointers[ $screen_id ] ) ? $this->pointers[ $screen_id ] : array();
370
- }
371
- }
372
- }
373
-
374
- if ( ! function_exists( 'YIT_Pointers' ) ) {
375
- /**
376
- * Main instance of plugin
377
- *
378
- * @return object YIT_Pointers
379
- * @since 1.0
380
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
381
- */
382
- function YIT_Pointers() {
383
- return YIT_Pointers::instance();
384
- }
385
- }
386
-
387
- /**
388
- * Instance a YIT_Pointers object
389
- */
390
  YIT_Pointers();
1
+ <?php
2
+ /*
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+ /**
15
+ *
16
+ *
17
+ * @class yit-pointers
18
+ * @package Yithemes
19
+ * @since Version 2.0.0
20
+ * @author Your Inspiration Themes
21
+ *
22
+ */
23
+ if ( ! class_exists( 'YIT_Pointers' ) ) {
24
+ /**
25
+ * YIT Pointers
26
+ *
27
+ * Initializes the new feature pointers.
28
+ *
29
+ * @class YIT_Pointers
30
+ * @package Yithemes
31
+ * @since 1.0
32
+ * @author Your Inspiration Themes
33
+ * @see WP_Internal_Pointers
34
+ */
35
+ class YIT_Pointers {
36
+
37
+ /**
38
+ * @var YIT_Upgrade The main instance
39
+ */
40
+ protected static $_instance;
41
+
42
+ /**
43
+ * @var screen id where to show pointer
44
+ */
45
+ public $screen_ids = array();
46
+
47
+ public $pointers = array();
48
+
49
+ public $special_screen = array();
50
+
51
+ protected $_plugins_registered = array();
52
+
53
+ protected $_default_pointer = array();
54
+
55
+ protected $_default_position = array( 'edge' => 'left', 'align' => 'center' );
56
+
57
+ /**
58
+ * Construct
59
+ *
60
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
61
+ * @since 1.0
62
+ */
63
+ public function __construct() {
64
+
65
+ $this->_default_pointer['plugins'] = array(
66
+ 'screen_id' => 'plugins',
67
+ 'options' => array(
68
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p> <p> %s <a href="http://yithemes.com/product-category/plugins/" target="_blank">Yithemes.com</a> %s
69
+ <a href="https://profiles.wordpress.org/yithemes/" target="_blank">Wordpress.org</a></p>',
70
+ __( 'Plugins Activated', 'yith-plugin-fw' ),
71
+ __( 'From now on, you can find all plugin options in YIT Plugin menu.
72
+ For each plugin installed, customization settings will be available as a new entry in YIT Plugin menu.', 'yith-plugin-fw' ),
73
+ __( 'Discover all our plugins available on:', 'yith-plugin-fw' ),
74
+ __( 'and', 'yith-plugin-fw' )
75
+ ),
76
+ ),
77
+ );
78
+
79
+ $this->_default_pointer['update'] = array(
80
+ 'screen_id' => 'update',
81
+ 'options' => array(
82
+ 'content' => sprintf( '<h3> %s </h3> <p> %s </p> <p> %s <a href="http://yithemes.com/product-category/plugins/" target="_blank">Yithemes.com</a> %s
83
+ <a href="https://profiles.wordpress.org/yithemes/" target="_blank">Wordpress.org</a></p>',
84
+ __( 'Plugins Upgraded', 'yith-plugin-fw' ),
85
+ __( 'From now on, you can find all options of your plugins in YIT Plugin menu.
86
+ Any time one of our plugins is updated, a new entry will be added to this menu.
87
+ For example, after the update, plugin options (such as for YITH WooCommerce Wishlist, YITH WooCommerce Ajax Search, etc.)
88
+ will be moved from previous location to YIT Plugin tab.', 'yith-plugin-fw' ),
89
+ __( 'Discover all our plugins available on:', 'yith-plugin-fw' ),
90
+ __( 'and', 'yith-plugin-fw' )
91
+ ),
92
+ ),
93
+ );
94
+
95
+ $this->_default_pointer = $this->parse_args( $this->_default_pointer );
96
+
97
+ /**
98
+ * Screens that require a particular action
99
+ */
100
+ $this->special_screen = apply_filters( 'yit-pointer-special-screen', array( 'plugins', 'update' ) );
101
+
102
+ add_action( 'admin_enqueue_scripts', array( $this, 'pointer_load' ) );
103
+ add_action( 'admin_init', array( $this, 'add_pointers' ), 100 );
104
+ }
105
+
106
+ public function parse_args( $args ) {
107
+ $default = array(
108
+ 'pointer_id' => 'yith_default_pointer',
109
+ 'target' => '#toplevel_page_yit_plugin_panel',
110
+ 'init' => null
111
+ );
112
+
113
+ foreach ( $args as $id => $pointer ) {
114
+ $args[ $id ] = wp_parse_args( $pointer, $default );
115
+ $args[ $id ]['options']['position'] = $this->_default_position;
116
+ }
117
+
118
+ return $args;
119
+ }
120
+
121
+ public function add_pointers(){
122
+ if( ! empty( $this->screen_ids ) ){
123
+ foreach( $this->screen_ids as $screen_id ){
124
+ add_filter( "yit_pointers-{$screen_id}", array( $this, 'pointers' ) );
125
+ }
126
+ }
127
+ }
128
+
129
+ /**
130
+ * Main plugin Instance
131
+ *
132
+ * @static
133
+ * @return object Main instance
134
+ *
135
+ * @since 1.0
136
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
137
+ */
138
+ public static function instance() {
139
+ if ( is_null( self::$_instance ) ) {
140
+ self::$_instance = new self();
141
+ }
142
+
143
+ return self::$_instance;
144
+ }
145
+
146
+ public function register( $args ) {
147
+
148
+ foreach ( $args as $id => $pointer ) {
149
+
150
+ extract( $pointer );
151
+
152
+ if ( ! isset( $screen_id ) && ! empty( $screen_id ) && ! isset( $init ) && ! empty( $init ) ) {
153
+ return;
154
+ }
155
+
156
+ if ( ! in_array( $screen_id, $this->screen_ids ) ) {
157
+ $this->screen_ids[] = $screen_id;
158
+ }
159
+
160
+ $this->pointers[$screen_id][$pointer_id] = array(
161
+ 'target' => $target,
162
+ 'options' => array(
163
+ 'content' => $content,
164
+ 'position' => $position,
165
+ ),
166
+ 'init' => isset( $init ) ? $init : false
167
+ );
168
+ }
169
+ }
170
+
171
+ public function get_plugins_init( $screen_id ) {
172
+
173
+ $registered = array();
174
+
175
+ foreach( $this->pointers[ $screen_id ] as $pointer_id => $pointer ){
176
+ $registered[ $pointer['init'] ] = $pointer_id;
177
+ }
178
+
179
+ return $registered;
180
+ }
181
+
182
+ public function pointer_load( $hook_suffix ) {
183
+
184
+ /**
185
+ * Get pointers for this screen
186
+ */
187
+ $screen = get_current_screen();
188
+ $pointers = apply_filters( "yit_pointers-{$screen->id}", array() );
189
+
190
+ if ( ! $pointers || ! is_array( $pointers ) ) {
191
+ return;
192
+ }
193
+
194
+ /**
195
+ * Get dismissed pointers
196
+ */
197
+ $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
198
+ $valid_pointers = array();
199
+ //$point_id = null;
200
+
201
+ /**
202
+ * show pointers only on plugin activate action
203
+ */
204
+ if( in_array( $screen->id, $this->special_screen ) ){
205
+
206
+ $show = false;
207
+ $registered = $this->get_plugins_init( $screen->id );
208
+ $recently_activate = get_option( 'yit_recently_activated', array() );
209
+
210
+ /**
211
+ * For "plugins" screen
212
+ */
213
+ $is_single_activate = ( isset( $_GET['activate'] ) && 'true' == $_GET['activate'] ) ? true : false;
214
+ $is_multi_activate = ( isset( $_GET['activate-multi'] ) && 'true' == $_GET['activate-multi'] ) ? true : false;
215
+
216
+ /**
217
+ * For "update" screen
218
+ *
219
+ * Single plugin update use GET method
220
+ *
221
+ * Multi update plugins with bulk action send two post args called "action" and "action2"
222
+ * action refer to first bulk action button (at the top of plugins table)
223
+ * action2 refer to last bulk action button (at the bottom of plugins table)
224
+ *
225
+ */
226
+ $is_single_upgrade = ( isset( $_GET['action'] ) && 'upgrade-plugin' == $_GET['action'] ) ? true : false;
227
+ $is_multi_upgrade = ( isset( $_POST['action'] ) && 'update-selected' == $_POST['action'] ) || ( isset( $_POST['action2'] ) && 'update-selected' == $_POST['action2'] ) ? true: false;
228
+
229
+ if( $is_single_activate || $is_single_upgrade ){
230
+
231
+ $point_id = '';
232
+
233
+ /**
234
+ * Single activation plugin
235
+ * Single update plugin
236
+ */
237
+ foreach( $registered as $init => $p_id ){
238
+ if ( in_array( $init, $recently_activate ) ) {
239
+ $point_id = $p_id;
240
+ $pointer = $pointers[ $point_id ];
241
+
242
+ /**
243
+ * Sanity check
244
+ */
245
+ if ( ! ( in_array( $point_id, $dismissed ) || empty( $pointer ) || empty( $point_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) ) {
246
+ /**
247
+ * Add the pointer to $valid_pointers array
248
+ */
249
+ $pointer['pointer_id'] = $point_id;
250
+ $valid_pointers['pointers'][] = $pointer;
251
+ $show = true;
252
+ }
253
+ break;
254
+ }
255
+ }
256
+ } else if( $is_multi_activate || $is_multi_upgrade ){
257
+
258
+ /**
259
+ * Bulk Action: multi plugins activation
260
+ * Bulk Action: multi plugins update
261
+ */
262
+ $point_id = array();
263
+ $screen_id = $screen->id;
264
+
265
+ if( $is_multi_upgrade && isset( $_POST['checked'] ) && ( count( $_POST['checked'] ) > 0 ) ){
266
+ $recently_activate = $_POST['checked'];
267
+ $screen_id = 'update';
268
+ $pointers = apply_filters( "yit_pointers-{$screen_id}", array() );
269
+ }
270
+
271
+ foreach ( $registered as $init => $p_id ) {
272
+ if ( in_array( $init, $recently_activate ) ) {
273
+ $point_id[] = $p_id;
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Bulk Action: Activate Plugins
279
+ *
280
+ * count( $point_id ) is the number of YITH plugins that have registered specific pointers
281
+ * case 0 -> No pointers -> Exit
282
+ * case 1 -> Only one pointers to show -> Use the specific plugin pointer
283
+ * defautl -> Two or more plugins need to show a pointer -> use a generic pointers
284
+ *
285
+ */
286
+ switch ( count( $point_id ) ) {
287
+ case 0:
288
+ $show = false;
289
+ break;
290
+
291
+ case 1:
292
+ $point_id = array_pop( $point_id );
293
+ $pointer = $pointers[$point_id];
294
+ /**
295
+ * Sanity check
296
+ */
297
+ if ( ! ( in_array( $point_id, $dismissed ) || empty( $pointer ) || empty( $point_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) ) {
298
+ /**
299
+ * Add the pointer to $valid_pointers array
300
+ */
301
+ $pointer['pointer_id'] = $point_id;
302
+ $valid_pointers['pointers'][] = $pointer;
303
+ $show = true;
304
+ }
305
+ break;
306
+
307
+ default:
308
+ $valid_pointers['pointers'][] = $this->_default_pointer[ $screen_id ];
309
+ $show = true;
310
+ break;
311
+ }
312
+ }
313
+
314
+ update_option( 'yit_recently_activated', array() );
315
+
316
+ if( ! $show ){
317
+ return;
318
+ }
319
+
320
+ } else {
321
+ /**
322
+ * Check pointers and remove dismissed ones.
323
+ */
324
+ foreach ( $pointers as $pointer_id => $pointer ) {
325
+
326
+ /**
327
+ * Sanity check
328
+ */
329
+ if ( in_array( $pointer_id, $dismissed ) || empty( $pointer ) || empty( $pointer_id ) || empty( $pointer['target'] ) || empty( $pointer['options'] ) ) {
330
+ continue;
331
+ }
332
+
333
+ $pointer['pointer_id'] = $pointer_id;
334
+
335
+ /**
336
+ * Add the pointer to $valid_pointers array
337
+ */
338
+ $valid_pointers['pointers'][] = $pointer;
339
+ }
340
+ }
341
+
342
+ /**
343
+ * No valid pointers? Stop here.
344
+ */
345
+ if ( empty( $valid_pointers ) ) {
346
+ return;
347
+ }
348
+
349
+ $script_file = function_exists( 'yit_load_js_file' ) ? yit_load_js_file( 'yit-wp-pointer.js' ) : 'yit-wp-pointer.min.js';
350
+
351
+ /**
352
+ * Enqueue wp-pointer script and style
353
+ */
354
+ wp_enqueue_style( 'wp-pointer' );
355
+ wp_enqueue_script( 'wp-pointer' );
356
+
357
+ wp_enqueue_script( 'yit-wp-pointer', YIT_CORE_PLUGIN_URL . '/assets/js/' . $script_file, array( 'wp-pointer' ), false, true );
358
+ wp_localize_script( 'yit-wp-pointer', 'custom_pointer', $valid_pointers );
359
+ }
360
+
361
+ public function pointers( $pointers ){
362
+ $screen_id = str_replace( 'yit_pointers-', '', current_filter() );
363
+ $pointers_to_add = $this->get_pointers( $screen_id );
364
+
365
+ return ! empty( $pointers_to_add ) ? array_merge( $pointers, $pointers_to_add ) : $pointers;
366
+ }
367
+
368
+ public function get_pointers( $screen_id ){
369
+ return isset( $this->pointers[ $screen_id ] ) ? $this->pointers[ $screen_id ] : array();
370
+ }
371
+ }
372
+ }
373
+
374
+ if ( ! function_exists( 'YIT_Pointers' ) ) {
375
+ /**
376
+ * Main instance of plugin
377
+ *
378
+ * @return object YIT_Pointers
379
+ * @since 1.0
380
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
381
+ */
382
+ function YIT_Pointers() {
383
+ return YIT_Pointers::instance();
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Instance a YIT_Pointers object
389
+ */
390
  YIT_Pointers();
plugin-fw/lib/yit-upgrade.php CHANGED
@@ -1,556 +1,556 @@
1
- <?php
2
- /*
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- } // Exit if accessed directly
13
-
14
- if ( ! class_exists( 'YIT_Upgrade' ) ) {
15
- /**
16
- * YIT Upgrade
17
- *
18
- * Notify and Update plugin
19
- *
20
- * @class YIT_Upgrade
21
- * @package Yithemes
22
- * @since 1.0
23
- * @author Your Inspiration Themes
24
- * @see WP_Updater Class
25
- */
26
-
27
- class YIT_Upgrade {
28
-
29
- /**
30
- * @var string XML notifier update
31
- */
32
- protected $_xml = 'http://update.yithemes.com/plugins/%plugin_slug%.xml';
33
-
34
- /**
35
- * @var string api server url
36
- */
37
- protected $_package_url = 'http://www.yithemes.com';
38
-
39
- /**
40
- * @var array The registered plugins
41
- */
42
- protected $_plugins = array();
43
-
44
- /**
45
- * @var YIT_Upgrade The main instance
46
- */
47
- protected static $_instance;
48
-
49
- /**
50
- * Construct
51
- *
52
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
53
- * @since 1.0
54
- */
55
- public function __construct() {
56
- add_filter( 'upgrader_pre_download', array( $this, 'upgrader_pre_download') , 10, 3 );
57
- add_action( 'update-custom_upgrade-plugin-multisite', array( $this, 'upgrade_plugin_multisite' ) );
58
-
59
- if( is_network_admin() ){
60
- add_action( 'admin_enqueue_scripts', array( $this, 'network_admin_enqueue_scripts' ) );
61
- }
62
-
63
- $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
64
- if ( $is_debug_enabled ) {
65
- $this->_package_url = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
66
- add_filter( 'block_local_requests', '__return_false' );
67
- }
68
- }
69
-
70
- /**
71
- * Main plugin Instance
72
- *
73
- * @param $plugin_slug | string The plugin slug
74
- * @param $plugin_init | string The plugin init file
75
- *
76
- * @return void
77
- *
78
- * @since 1.0
79
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
80
- */
81
- public function register( $plugin_slug, $plugin_init ) {
82
-
83
- if( ! function_exists( 'get_plugins' ) ){
84
- include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
85
- }
86
-
87
- $plugins = get_plugins();
88
- $plugin_info = $plugins[ $plugin_init ];
89
-
90
- $this->_plugins[ $plugin_init ] = array(
91
- 'info' => $plugin_info,
92
- 'slug' => $plugin_slug,
93
- );
94
-
95
- /* === HOOKS === */
96
- if( ! is_multisite() || is_plugin_active_for_network( $plugin_init ) ){
97
- add_action( 'admin_init', array( $this, 'remove_wp_plugin_update_row' ), 15 );
98
- add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
99
- } else if( is_multisite() && current_user_can( 'update_plugins' ) ) {
100
- $transient = 'yith_register_' . md5( $plugin_slug );
101
- if( apply_filters( 'yith_register_delete_transient', false ) ){
102
- delete_transient( $transient );
103
- }
104
- $info = get_transient( $transient );
105
- if( false === $info || apply_filters( 'yith_register_delete_transient', false ) ){
106
- $xml = str_replace( '%plugin_slug%', $plugin_slug, $this->_xml );
107
- $remote_xml = wp_remote_get( $xml );
108
-
109
- if( ! is_wp_error( $remote_xml ) && isset( $remote_xml['response']['code'] ) && '200' == $remote_xml['response']['code'] ) {
110
- $plugin_remote_info = new SimpleXmlElement( $remote_xml['body'] );
111
- $info['Latest'] = (string) $plugin_remote_info->latest;
112
- $info['changelog'] = (string) $plugin_remote_info->changelog;
113
- YIT_Plugin_Licence()->check( $plugin_slug, false );
114
- set_transient( $transient, $info, DAY_IN_SECONDS );
115
- }
116
- }
117
-
118
- $this->_plugins[ $plugin_init ]['info']['Latest'] = $info['Latest'];
119
- $this->_plugins[ $plugin_init ]['info']['changelog'] = $info['changelog'];
120
- add_action( 'admin_enqueue_scripts', array( $this, 'multisite_updater_script' ) );
121
- }
122
- }
123
-
124
- /**
125
- * Add the multisite updater scripts
126
- *
127
- * @return void
128
- *
129
- * @since 1.0
130
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
131
- */
132
- public function multisite_updater_script(){
133
-
134
- $update_url = $changelogs = $details_url = array();
135
- $strings = array(
136
- 'new_version' => __( 'There is a new version of %plugin_name% available.', 'yith-plugin-fw' ),
137
- 'latest' => __( 'View version %latest% details.', 'yith-plugin-fw' ),
138
- 'unavailable' => __( 'Automatic update is unavailable for this plugin,', 'yith-plugin-fw' ),
139
- 'activate' => __( 'please <a href="%activate_link%">activate</a> your copy of %plugin_name%.', 'yith-plugin-fw' ),
140
- 'update_now' => __( 'Update now.', 'yith-plugin-fw' )
141
-
142
- );
143
-
144
- foreach( $this->_plugins as $init => $info ){
145
- $update_url[ $init ] = wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin-multisite&plugin=') . $init, 'upgrade-plugin-multisite_' . $init );
146
- $changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
147
- $details_url[ $init ] = '#TB_inline' . esc_url( add_query_arg( array( 'width' => 722, 'height' => 914, 'inlineId' => $changelog_id ) , '' ) );
148
- $plugin_changelog = isset( $this->_plugins[ $init ]['info']['changelog'] ) ? $this->_plugins[ $init ]['info']['changelog'] : '';
149
- $changelogs[ $init ] = $this->in_theme_update_message( $this->_plugins[ $init ], $plugin_changelog, $changelog_id, false );
150
- }
151
-
152
- $localize_script_args = array(
153
- 'registered' => $this->_plugins,
154
- 'activated' => YIT_Plugin_Licence()->get_activated_products(),
155
- 'licence_activation_url' => YIT_Plugin_Licence()->get_licence_activation_page_url(),
156
- 'update_url' => $update_url,
157
- 'details_url' => $details_url,
158
- 'strings' => $strings,
159
- 'changelogs' => $changelogs
160
- );
161
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
162
- yit_enqueue_script( 'yit-multisite-updater', YIT_CORE_PLUGIN_URL . '/assets/js/multisite-updater' . $suffix . '.js', array( 'jquery' ), false, true );
163
-
164
- wp_localize_script( 'yit-multisite-updater', 'plugins', $localize_script_args );
165
- }
166
-
167
- public function network_admin_enqueue_scripts(){
168
- yit_enqueue_style( 'yit-upgrader', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrader.css' );
169
- }
170
-
171
- /**
172
- * Retrive the zip package file
173
- *
174
- * @param bool $reply Whether to bail without returning the package. Default false.
175
- * @param string $package The package file name.
176
- * @param \WP_Upgrader $upgrader WP_Upgrader instance.
177
- *
178
- * @return string | The download file
179
- *
180
- * @since 1.0
181
- * @see wp-admin/includes/class-wp-upgrader.php
182
- * @access public
183
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
184
- */
185
- public function upgrader_pre_download( $reply, $package, $upgrader ) {
186
- $plugin = false;
187
- $is_bulk = $upgrader->skin instanceof Bulk_Plugin_Upgrader_Skin;
188
-
189
- if( ! $is_bulk ){
190
- $plugin = isset( $upgrader->skin->plugin ) ? $upgrader->skin->plugin : false;
191
- }
192
-
193
- else {
194
- //Bulk action upgrade
195
- $action_url = parse_url( $upgrader->skin->options['url'] );
196
- parse_str( rawurldecode( htmlspecialchars_decode( $action_url['query'] ) ) );
197
- $plugins = explode( ',', $plugins );
198
- foreach( $plugins as $plugin_init ){
199
- $to_upgrade = get_plugin_data( WP_PLUGIN_DIR . DIRECTORY_SEPARATOR . $plugin_init );
200
- if( $to_upgrade['Name'] == $upgrader->skin->plugin_info['Name'] ){
201
- $plugin = $plugin_init;
202
- }
203
- }
204
- }
205
-
206
- /**
207
- * It isn't YITH Premium plugins, please wordpress update it for me!
208
- */
209
- if( ! $plugin ) {
210
- return $reply;
211
- }
212
-
213
- $plugin_info = YIT_Plugin_Licence()->get_product( $plugin );
214
-
215
- /**
216
- * False ? It isn't YITH Premium plugins, please wordpress update it for me!
217
- */
218
- if( false === $plugin_info ) {
219
- return $reply;
220
- }
221
-
222
- $licence = YIT_Plugin_Licence()->get_licence();
223
- $product_id = $plugin_info['product_id'];
224
- $args = array(
225
- 'email' => $licence[ $product_id ]['email'],
226
- 'licence_key' => $licence[$product_id]['licence_key'],
227
- 'product_id' => $plugin_info['product_id'],
228
- 'secret_key' => $plugin_info['secret_key'],
229
- 'instance' => YIT_Plugin_Licence()->get_home_url(),
230
- 'wc-api' => 'download-api',
231
- 'request' => 'download'
232
- );
233
-
234
- if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) {
235
- //Local file or remote?
236
- return $package;
237
- }
238
-
239
- if ( empty( $package ) ) {
240
- return new WP_Error( 'no_package', $upgrader->strings['no_package'] );
241
- }
242
-
243
- $upgrader->skin->feedback( 'downloading_package', __( 'YIThemes Repository', 'yith-plugin-fw' ) );
244
-
245
- $download_file = $this->_download_url( $package, $args );
246
-
247
- /**
248
- * Regenerate update_plugins transient
249
- */
250
- $this->force_regenerate_update_transient();
251
-
252
- if ( is_wp_error( $download_file ) ) {
253
- return new WP_Error( 'download_failed', $upgrader->strings['download_failed'], $download_file->get_error_message() );
254
- }
255
-
256
- return $download_file;
257
- }
258
-
259
- /**
260
- * Retrive the temp filename
261
- *
262
- * @param string $url The package url
263
- * @param string $body The post data fields
264
- * @param int $timeout Execution timeout (default: 300)
265
- *
266
- * @return string | The temp filename
267
- *
268
- * @since 1.0
269
- * @see wp-admin/includes/class-wp-upgrader.php
270
- * @access protected
271
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
272
- */
273
- protected function _download_url( $url, $body, $timeout = 300 ) {
274
-
275
- //WARNING: The file is not automatically deleted, The script must unlink() the file.
276
- if ( ! $url ) {
277
- return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.', 'yit' ) );
278
- }
279
-
280
- $tmpfname = wp_tempnam( $url );
281
-
282
- $args = array(
283
- 'timeout' => $timeout,
284
- 'stream' => true,
285
- 'filename' => $tmpfname,
286
- 'body' => $body
287
- );
288
-
289
- if ( ! $tmpfname ) {
290
- return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.', 'yit' ) );
291
- }
292
-
293
- $response = wp_safe_remote_post( $url, $args );
294
-
295
- if ( is_wp_error( $response ) ) {
296
- unlink( $tmpfname );
297
- return $response;
298
- }
299
-
300
- if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
301
- unlink( $tmpfname );
302
- return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
303
- }
304
-
305
- $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
306
-
307
- if ( $content_md5 ) {
308
- $md5_check = verify_file_md5( $tmpfname, $content_md5 );
309
- if ( is_wp_error( $md5_check ) ) {
310
- unlink( $tmpfname );
311
- return $md5_check;
312
- }
313
- }
314
-
315
- return $tmpfname;
316
- }
317
-
318
- /**
319
- * Main plugin Instance
320
- *
321
- * @static
322
- * @return object Main instance
323
- *
324
- * @since 1.0
325
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
326
- */
327
- public static function instance() {
328
- if ( is_null( self::$_instance ) ) {
329
- self::$_instance = new self();
330
- }
331
-
332
- return self::$_instance;
333
- }
334
-
335
- /**
336
- * Delete the update plugins transient
337
- *
338
- * @return void
339
- *
340
- * @since 1.0
341
- * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
342
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
343
- */
344
- public function force_regenerate_update_transient(){
345
- delete_site_transient( 'update_plugins' );
346
- }
347
-
348
- /**
349
- * Check for plugins update
350
- *
351
- * If a new plugin version is available set it in the pre_set_site_transient_update_plugins hooks
352
- *
353
- * @param mixed $transient | update_plugins transient value
354
- * @param bool $save | Default: false. Set true to regenerate the update_transient plugins
355
- *
356
- * @return mixed $transient | The new update_plugins transient value
357
- *
358
- * @since 1.0
359
- * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
360
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
361
- */
362
- public function check_update( $transient, $save = false ) {
363
-
364
- foreach ($this->_plugins as $init => $plugin) {
365
- $xml = str_replace('%plugin_slug%', $this->_plugins[$init]['slug'], $this->_xml);
366
- $remote_xml = wp_remote_get($xml);
367
-
368
- if (!is_wp_error($remote_xml) && isset($remote_xml['response']['code']) && '200' == $remote_xml['response']['code']) {
369
-
370
-
371
- $plugin_remote_info = new SimpleXmlElement($remote_xml['body']);
372
-
373
- if (version_compare($plugin_remote_info->latest, $plugin['info']['Version'], '>') && !isset($transient->response[$init])) {
374
-
375
- $package = YIT_Plugin_Licence()->check($init) ? $this->_package_url : null;
376
-
377
- $obj = new stdClass();
378
- $obj->slug = (string)$init;
379
- $obj->new_version = (string)$plugin_remote_info->latest;
380
- $obj->changelog = (string)$plugin_remote_info->changelog;
381
- $obj->package = $package;
382
- $obj->plugin = $init;
383
- $transient->response[$init] = $obj;
384
- }
385
-
386
- }
387
- }
388
-
389
- if( $save ) {
390
- set_site_transient( 'update_plugins', $transient );
391
- }
392
-
393
- return $transient;
394
- }
395
-
396
- /**
397
- * Add the plugin update row in plugin page
398
- *
399
- * @return void
400
- * @fire "in_theme_update_message-{$init}" action
401
- *
402
- * @since 1.0
403
- * @see after_plugin_row_{$init} action
404
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
405
- */
406
- public function plugin_update_row() {
407
-
408
- $current = get_site_transient( 'update_plugins' );
409
- $init = str_replace( 'after_plugin_row_', '', current_filter() );
410
-
411
- if ( ! isset( $current->response[ $init ] ) ) {
412
- return false;
413
- }
414
-
415
- /**
416
- * stdClass Object
417
- */
418
- $r = $current->response[ $init ];
419
-
420
- $changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
421
- $details_url = '#TB_inline' . esc_url( add_query_arg( array( 'width' => 722, 'height' => 914, 'inlineId' => $changelog_id ) , '' ) );
422
-
423
- /**
424
- * @see wp_plugin_update_rows() in wp-single\wp-admin\includes\update.php
425
- */
426
- $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
427
-
428
- if( is_network_admin() || ! is_multisite() || true ) {
429
- echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
430
-
431
- if( ! current_user_can( 'update_plugins' ) ){
432
- printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>.', 'yith-plugin-fw'), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
433
- }elseif( is_plugin_active_for_network( $init ) ){
434
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>. <em>You have to activate the plugin on a single site of the network to benefit from automatic updates.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
435
- }elseif ( empty( $r->package ) ) {
436
- printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin, please <a href="%5$s" title="License activation">activate</a> your copy of %6s.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, YIT_Plugin_Licence()->get_licence_activation_page_url(), $this->_plugins[ $init ]['info']['Name'] );
437
- } else {
438
- printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.', 'yith-plugin-fw'), $this->_plugins[ $init ]['info']['Name'], esc_url($details_url), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $init, 'upgrade-plugin_' . $init ) );
439
- }
440
-
441
- /**
442
- * Fires at the end of the update message container in each
443
- * row of the themes list table.
444
- *
445
- * The dynamic portion of the hook name, `$theme_key`, refers to
446
- * the theme slug as found in the WordPress.org themes repository.
447
- *
448
- * @since Wordpress 3.1.0
449
- * }
450
- */
451
- do_action( "in_theme_update_message-{$init}", $this->_plugins[ $init ], $r->changelog, $changelog_id );
452
-
453
- echo '</div></td></tr>';
454
- }
455
- }
456
-
457
- /**
458
- * Remove the standard plugin_update_row
459
- *
460
- * Remove the standard plugin_update_row and Add a custom plugin update row in plugin page.
461
- *
462
- * @return void
463
- * @fire "in_theme_update_message-{$init}" action
464
- *
465
- * @since 1.0
466
- * @see after_plugin_row_{$init} action
467
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
468
- */
469
- public function remove_wp_plugin_update_row() {
470
- foreach( $this->_plugins as $init => $plugin ){
471
- remove_action( "after_plugin_row_{$init}", 'wp_plugin_update_row', 10, 2 );
472
- add_action( "after_plugin_row_{$init}", array( $this, 'plugin_update_row' ) );
473
- add_action( "in_theme_update_message-{$init}", array( $this, 'in_theme_update_message' ), 10, 3 );
474
- }
475
- }
476
-
477
- public function in_theme_update_message( $plugin, $changelog, $changelog_id, $echo = true ){
478
-
479
- $res = "<div id='{$changelog_id}' class='yit-plugin-changelog-wrapper'>
480
- <div class='yit-plugin-changelog'>
481
- <h2 class='yit-plugin-changelog-title'>{$plugin['info']['Name']} - Changelog</h2>
482
- <p>{$changelog}</p>
483
- </div>
484
- </div>";
485
-
486
- if( $echo ){
487
- echo $res;
488
- }
489
- else{
490
- return $res;
491
- }
492
- }
493
-
494
- /**
495
- * Auto-Update Plugin in multisite
496
- *
497
- * Manage the non standard upgrade-plugin-multisite action
498
- *
499
- * @return void
500
- *
501
- * @since 1.0
502
- * @see upgrade-plugin action
503
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
504
- */
505
- public function upgrade_plugin_multisite(){
506
-
507
- $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
508
- $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
509
-
510
- if( 'upgrade-plugin-multisite' != $action ){
511
- wp_die( __( 'You can\'t update the plugins for this site.', 'yith-plugin-fw' ) );
512
- }
513
-
514
- if ( ! current_user_can( 'update_plugins' ) ) {
515
- wp_die( __( 'You do not have sufficient permissions to update the plugins for this site.', 'yith-plugin-fw' ) );
516
- }
517
-
518
- $this->check_update( get_site_transient( 'update_plugins') , true );
519
-
520
- check_admin_referer( 'upgrade-plugin-multisite_' . $plugin );
521
-
522
- $title = __( 'Update Plugin', 'yith-plugin-fw' );
523
- $parent_file = 'plugins.php';
524
- $submenu_file = 'plugins.php';
525
-
526
- wp_enqueue_script( 'updates' );
527
- require_once( ABSPATH . 'wp-admin/admin-header.php' );
528
-
529
- $nonce = 'upgrade-plugin-multisite_' . $plugin;
530
- $url = 'update.php?action=upgrade-plugin-multisite&plugin=' . urlencode( $plugin );
531
-
532
- $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
533
- $upgrader->upgrade( $plugin );
534
-
535
- include( ABSPATH . 'wp-admin/admin-footer.php' );
536
- }
537
- }
538
- }
539
-
540
- if ( ! function_exists( 'YIT_Upgrade' ) ) {
541
- /**
542
- * Main instance of plugin
543
- *
544
- * @return object
545
- * @since 1.0
546
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
547
- */
548
- function YIT_Upgrade() {
549
- return YIT_Upgrade::instance();
550
- }
551
- }
552
-
553
- /**
554
- * Instance a YIT_Upgrade object
555
- */
556
- YIT_Upgrade();
1
+ <?php
2
+ /*
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+ if ( ! class_exists( 'YIT_Upgrade' ) ) {
15
+ /**
16
+ * YIT Upgrade
17
+ *
18
+ * Notify and Update plugin
19
+ *
20
+ * @class YIT_Upgrade
21
+ * @package Yithemes
22
+ * @since 1.0
23
+ * @author Your Inspiration Themes
24
+ * @see WP_Updater Class
25
+ */
26
+
27
+ class YIT_Upgrade {
28
+
29
+ /**
30
+ * @var string XML notifier update
31
+ */
32
+ protected $_xml = 'http://update.yithemes.com/plugins/%plugin_slug%.xml';
33
+
34
+ /**
35
+ * @var string api server url
36
+ */
37
+ protected $_package_url = 'http://www.yithemes.com';
38
+
39
+ /**
40
+ * @var array The registered plugins
41
+ */
42
+ protected $_plugins = array();
43
+
44
+ /**
45
+ * @var YIT_Upgrade The main instance
46
+ */
47
+ protected static $_instance;
48
+
49
+ /**
50
+ * Construct
51
+ *
52
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
53
+ * @since 1.0
54
+ */
55
+ public function __construct() {
56
+ add_filter( 'upgrader_pre_download', array( $this, 'upgrader_pre_download') , 10, 3 );
57
+ add_action( 'update-custom_upgrade-plugin-multisite', array( $this, 'upgrade_plugin_multisite' ) );
58
+
59
+ if( is_network_admin() ){
60
+ add_action( 'admin_enqueue_scripts', array( $this, 'network_admin_enqueue_scripts' ) );
61
+ }
62
+
63
+ $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
64
+ if ( $is_debug_enabled ) {
65
+ $this->_package_url = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
66
+ add_filter( 'block_local_requests', '__return_false' );
67
+ }
68
+ }
69
+
70
+ /**
71
+ * Main plugin Instance
72
+ *
73
+ * @param $plugin_slug | string The plugin slug
74
+ * @param $plugin_init | string The plugin init file
75
+ *
76
+ * @return void
77
+ *
78
+ * @since 1.0
79
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
80
+ */
81
+ public function register( $plugin_slug, $plugin_init ) {
82
+
83
+ if( ! function_exists( 'get_plugins' ) ){
84
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
85
+ }
86
+
87
+ $plugins = get_plugins();
88
+ $plugin_info = $plugins[ $plugin_init ];
89
+
90
+ $this->_plugins[ $plugin_init ] = array(
91
+ 'info' => $plugin_info,
92
+ 'slug' => $plugin_slug,
93
+ );
94
+
95
+ /* === HOOKS === */
96
+ if( ! is_multisite() || is_plugin_active_for_network( $plugin_init ) ){
97
+ add_action( 'admin_init', array( $this, 'remove_wp_plugin_update_row' ), 15 );
98
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
99
+ } else if( is_multisite() && current_user_can( 'update_plugins' ) ) {
100
+ $transient = 'yith_register_' . md5( $plugin_slug );
101
+ if( apply_filters( 'yith_register_delete_transient', false ) ){
102
+ delete_transient( $transient );
103
+ }
104
+ $info = get_transient( $transient );
105
+ if( false === $info || apply_filters( 'yith_register_delete_transient', false ) ){
106
+ $xml = str_replace( '%plugin_slug%', $plugin_slug, $this->_xml );
107
+ $remote_xml = wp_remote_get( $xml );
108
+
109
+ if( ! is_wp_error( $remote_xml ) && isset( $remote_xml['response']['code'] ) && '200' == $remote_xml['response']['code'] ) {
110
+ $plugin_remote_info = new SimpleXmlElement( $remote_xml['body'] );
111
+ $info['Latest'] = (string) $plugin_remote_info->latest;
112
+ $info['changelog'] = (string) $plugin_remote_info->changelog;
113
+ YIT_Plugin_Licence()->check( $plugin_slug, false );
114
+ set_transient( $transient, $info, DAY_IN_SECONDS );
115
+ }
116
+ }
117
+
118
+ $this->_plugins[ $plugin_init ]['info']['Latest'] = $info['Latest'];
119
+ $this->_plugins[ $plugin_init ]['info']['changelog'] = $info['changelog'];
120
+ add_action( 'admin_enqueue_scripts', array( $this, 'multisite_updater_script' ) );
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Add the multisite updater scripts
126
+ *
127
+ * @return void
128
+ *
129
+ * @since 1.0
130
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
131
+ */
132
+ public function multisite_updater_script(){
133
+
134
+ $update_url = $changelogs = $details_url = array();
135
+ $strings = array(
136
+ 'new_version' => __( 'There is a new version of %plugin_name% available.', 'yith-plugin-fw' ),
137
+ 'latest' => __( 'View version %latest% details.', 'yith-plugin-fw' ),
138
+ 'unavailable' => __( 'Automatic update is unavailable for this plugin,', 'yith-plugin-fw' ),
139
+ 'activate' => __( 'please <a href="%activate_link%">activate</a> your copy of %plugin_name%.', 'yith-plugin-fw' ),
140
+ 'update_now' => __( 'Update now.', 'yith-plugin-fw' )
141
+
142
+ );
143
+
144
+ foreach( $this->_plugins as $init => $info ){
145
+ $update_url[ $init ] = wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin-multisite&plugin=') . $init, 'upgrade-plugin-multisite_' . $init );
146
+ $changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
147
+ $details_url[ $init ] = '#TB_inline' . esc_url( add_query_arg( array( 'width' => 722, 'height' => 914, 'inlineId' => $changelog_id ) , '' ) );
148
+ $plugin_changelog = isset( $this->_plugins[ $init ]['info']['changelog'] ) ? $this->_plugins[ $init ]['info']['changelog'] : '';
149
+ $changelogs[ $init ] = $this->in_theme_update_message( $this->_plugins[ $init ], $plugin_changelog, $changelog_id, false );
150
+ }
151
+
152
+ $localize_script_args = array(
153
+ 'registered' => $this->_plugins,
154
+ 'activated' => YIT_Plugin_Licence()->get_activated_products(),
155
+ 'licence_activation_url' => YIT_Plugin_Licence()->get_licence_activation_page_url(),
156
+ 'update_url' => $update_url,
157
+ 'details_url' => $details_url,
158
+ 'strings' => $strings,
159
+ 'changelogs' => $changelogs
160
+ );
161
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
162
+ yit_enqueue_script( 'yit-multisite-updater', YIT_CORE_PLUGIN_URL . '/assets/js/multisite-updater' . $suffix . '.js', array( 'jquery' ), false, true );
163
+
164
+ wp_localize_script( 'yit-multisite-updater', 'plugins', $localize_script_args );
165
+ }
166
+
167
+ public function network_admin_enqueue_scripts(){
168
+ yit_enqueue_style( 'yit-upgrader', YIT_CORE_PLUGIN_URL . '/assets/css/yit-upgrader.css' );
169
+ }
170
+
171
+ /**
172
+ * Retrive the zip package file
173
+ *
174
+ * @param bool $reply Whether to bail without returning the package. Default false.
175
+ * @param string $package The package file name.
176
+ * @param \WP_Upgrader $upgrader WP_Upgrader instance.
177
+ *
178
+ * @return string | The download file
179
+ *
180
+ * @since 1.0
181
+ * @see wp-admin/includes/class-wp-upgrader.php
182
+ * @access public
183
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
184
+ */
185
+ public function upgrader_pre_download( $reply, $package, $upgrader ) {
186
+ $plugin = false;
187
+ $is_bulk = $upgrader->skin instanceof Bulk_Plugin_Upgrader_Skin;
188
+
189
+ if( ! $is_bulk ){
190
+ $plugin = isset( $upgrader->skin->plugin ) ? $upgrader->skin->plugin : false;
191
+ }
192
+
193
+ else {
194
+ //Bulk action upgrade
195
+ $action_url = parse_url( $upgrader->skin->options['url'] );
196
+ parse_str( rawurldecode( htmlspecialchars_decode( $action_url['query'] ) ) );
197
+ $plugins = explode( ',', $plugins );
198
+ foreach( $plugins as $plugin_init ){
199
+ $to_upgrade = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_init );
200
+ if( $to_upgrade['Name'] == $upgrader->skin->plugin_info['Name'] ){
201
+ $plugin = $plugin_init;
202
+ }
203
+ }
204
+ }
205
+
206
+ /**
207
+ * It isn't YITH Premium plugins, please wordpress update it for me!
208
+ */
209
+ if( ! $plugin ) {
210
+ return $reply;
211
+ }
212
+
213
+ $plugin_info = YIT_Plugin_Licence()->get_product( $plugin );
214
+
215
+ /**
216
+ * False ? It isn't YITH Premium plugins, please wordpress update it for me!
217
+ */
218
+ if( false === $plugin_info ) {
219
+ return $reply;
220
+ }
221
+
222
+ $licence = YIT_Plugin_Licence()->get_licence();
223
+ $product_id = $plugin_info['product_id'];
224
+ $args = array(
225
+ 'email' => $licence[ $product_id ]['email'],
226
+ 'licence_key' => $licence[$product_id]['licence_key'],
227
+ 'product_id' => $plugin_info['product_id'],
228
+ 'secret_key' => $plugin_info['secret_key'],
229
+ 'instance' => YIT_Plugin_Licence()->get_home_url(),
230
+ 'wc-api' => 'download-api',
231
+ 'request' => 'download'
232
+ );
233
+
234
+ if ( ! preg_match( '!^(http|https|ftp)://!i', $package ) && file_exists( $package ) ) {
235
+ //Local file or remote?
236
+ return $package;
237
+ }
238
+
239
+ if ( empty( $package ) ) {
240
+ return new WP_Error( 'no_package', $upgrader->strings['no_package'] );
241
+ }
242
+
243
+ $upgrader->skin->feedback( 'downloading_package', __( 'YIThemes Repository', 'yith-plugin-fw' ) );
244
+
245
+ $download_file = $this->_download_url( $package, $args );
246
+
247
+ /**
248
+ * Regenerate update_plugins transient
249
+ */
250
+ $this->force_regenerate_update_transient();
251
+
252
+ if ( is_wp_error( $download_file ) ) {
253
+ return new WP_Error( 'download_failed', $upgrader->strings['download_failed'], $download_file->get_error_message() );
254
+ }
255
+
256
+ return $download_file;
257
+ }
258
+
259
+ /**
260
+ * Retrive the temp filename
261
+ *
262
+ * @param string $url The package url
263
+ * @param string $body The post data fields
264
+ * @param int $timeout Execution timeout (default: 300)
265
+ *
266
+ * @return string | The temp filename
267
+ *
268
+ * @since 1.0
269
+ * @see wp-admin/includes/class-wp-upgrader.php
270
+ * @access protected
271
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
272
+ */
273
+ protected function _download_url( $url, $body, $timeout = 300 ) {
274
+
275
+ //WARNING: The file is not automatically deleted, The script must unlink() the file.
276
+ if ( ! $url ) {
277
+ return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.', 'yit' ) );
278
+ }
279
+
280
+ $tmpfname = wp_tempnam( $url );
281
+
282
+ $args = array(
283
+ 'timeout' => $timeout,
284
+ 'stream' => true,
285
+ 'filename' => $tmpfname,
286
+ 'body' => $body
287
+ );
288
+
289
+ if ( ! $tmpfname ) {
290
+ return new WP_Error( 'http_no_file', __( 'Could not create Temporary file.', 'yit' ) );
291
+ }
292
+
293
+ $response = wp_safe_remote_post( $url, $args );
294
+
295
+ if ( is_wp_error( $response ) ) {
296
+ unlink( $tmpfname );
297
+ return $response;
298
+ }
299
+
300
+ if ( 200 != wp_remote_retrieve_response_code( $response ) ) {
301
+ unlink( $tmpfname );
302
+ return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ) );
303
+ }
304
+
305
+ $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' );
306
+
307
+ if ( $content_md5 ) {
308
+ $md5_check = verify_file_md5( $tmpfname, $content_md5 );
309
+ if ( is_wp_error( $md5_check ) ) {
310
+ unlink( $tmpfname );
311
+ return $md5_check;
312
+ }
313
+ }
314
+
315
+ return $tmpfname;
316
+ }
317
+
318
+ /**
319
+ * Main plugin Instance
320
+ *
321
+ * @static
322
+ * @return object Main instance
323
+ *
324
+ * @since 1.0
325
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
326
+ */
327
+ public static function instance() {
328
+ if ( is_null( self::$_instance ) ) {
329
+ self::$_instance = new self();
330
+ }
331
+
332
+ return self::$_instance;
333
+ }
334
+
335
+ /**
336
+ * Delete the update plugins transient
337
+ *
338
+ * @return void
339
+ *
340
+ * @since 1.0
341
+ * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
342
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
343
+ */
344
+ public function force_regenerate_update_transient(){
345
+ delete_site_transient( 'update_plugins' );
346
+ }
347
+
348
+ /**
349
+ * Check for plugins update
350
+ *
351
+ * If a new plugin version is available set it in the pre_set_site_transient_update_plugins hooks
352
+ *
353
+ * @param mixed $transient | update_plugins transient value
354
+ * @param bool $save | Default: false. Set true to regenerate the update_transient plugins
355
+ *
356
+ * @return mixed $transient | The new update_plugins transient value
357
+ *
358
+ * @since 1.0
359
+ * @see update_plugins transient and pre_set_site_transient_update_plugins hooks
360
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
361
+ */
362
+ public function check_update( $transient, $save = false ) {
363
+
364
+ foreach ($this->_plugins as $init => $plugin) {
365
+ $xml = str_replace('%plugin_slug%', $this->_plugins[$init]['slug'], $this->_xml);
366
+ $remote_xml = wp_remote_get($xml);
367
+
368
+ if (!is_wp_error($remote_xml) && isset($remote_xml['response']['code']) && '200' == $remote_xml['response']['code']) {
369
+
370
+
371
+ $plugin_remote_info = new SimpleXmlElement($remote_xml['body']);
372
+
373
+ if (version_compare($plugin_remote_info->latest, $plugin['info']['Version'], '>') && !isset($transient->response[$init])) {
374
+
375
+ $package = YIT_Plugin_Licence()->check($init) ? $this->_package_url : null;
376
+
377
+ $obj = new stdClass();
378
+ $obj->slug = (string)$init;
379
+ $obj->new_version = (string)$plugin_remote_info->latest;
380
+ $obj->changelog = (string)$plugin_remote_info->changelog;
381
+ $obj->package = $package;
382
+ $obj->plugin = $init;
383
+ $transient->response[$init] = $obj;
384
+ }
385
+
386
+ }
387
+ }
388
+
389
+ if( $save ) {
390
+ set_site_transient( 'update_plugins', $transient );
391
+ }
392
+
393
+ return $transient;
394
+ }
395
+
396
+ /**
397
+ * Add the plugin update row in plugin page
398
+ *
399
+ * @return void
400
+ * @fire "in_theme_update_message-{$init}" action
401
+ *
402
+ * @since 1.0
403
+ * @see after_plugin_row_{$init} action
404
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
405
+ */
406
+ public function plugin_update_row() {
407
+
408
+ $current = get_site_transient( 'update_plugins' );
409
+ $init = str_replace( 'after_plugin_row_', '', current_filter() );
410
+
411
+ if ( ! isset( $current->response[ $init ] ) ) {
412
+ return false;
413
+ }
414
+
415
+ /**
416
+ * stdClass Object
417
+ */
418
+ $r = $current->response[ $init ];
419
+
420
+ $changelog_id = str_replace( array( '/', '.php', '.' ), array( '-', '', '-' ), $init );
421
+ $details_url = '#TB_inline' . esc_url( add_query_arg( array( 'width' => 722, 'height' => 914, 'inlineId' => $changelog_id ) , '' ) );
422
+
423
+ /**
424
+ * @see wp_plugin_update_rows() in wp-single\wp-admin\includes\update.php
425
+ */
426
+ $wp_list_table = _get_list_table( 'WP_MS_Themes_List_Table' );
427
+
428
+ if( is_network_admin() || ! is_multisite() || true ) {
429
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
430
+
431
+ if( ! current_user_can( 'update_plugins' ) ){
432
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>.', 'yith-plugin-fw'), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
433
+ }elseif( is_plugin_active_for_network( $init ) ){
434
+ printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>. <em>You have to activate the plugin on a single site of the network to benefit from automatic updates.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version );
435
+ }elseif ( empty( $r->package ) ) {
436
+ printf( __( 'There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a>. <em>Automatic update is unavailable for this plugin, please <a href="%5$s" title="License activation">activate</a> your copy of %6s.</em>', 'yith-plugin-fw' ), $this->_plugins[ $init ]['info']['Name'], esc_url( $details_url ), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, YIT_Plugin_Licence()->get_licence_activation_page_url(), $this->_plugins[ $init ]['info']['Name'] );
437
+ } else {
438
+ printf( __('There is a new version of %1$s available. <a href="%2$s" class="thickbox yit-changelog-button" title="%3$s">View version %4$s details</a> or <a href="%5$s">update now</a>.', 'yith-plugin-fw'), $this->_plugins[ $init ]['info']['Name'], esc_url($details_url), esc_attr( $this->_plugins[ $init ]['info']['Name'] ), $r->new_version, wp_nonce_url( self_admin_url('update.php?action=upgrade-plugin&plugin=') . $init, 'upgrade-plugin_' . $init ) );
439
+ }
440
+
441
+ /**
442
+ * Fires at the end of the update message container in each
443
+ * row of the themes list table.
444
+ *
445
+ * The dynamic portion of the hook name, `$theme_key`, refers to
446
+ * the theme slug as found in the WordPress.org themes repository.
447
+ *
448
+ * @since Wordpress 3.1.0
449
+ * }
450
+ */
451
+ do_action( "in_theme_update_message-{$init}", $this->_plugins[ $init ], $r->changelog, $changelog_id );
452
+
453
+ echo '</div></td></tr>';
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Remove the standard plugin_update_row
459
+ *
460
+ * Remove the standard plugin_update_row and Add a custom plugin update row in plugin page.
461
+ *
462
+ * @return void
463
+ * @fire "in_theme_update_message-{$init}" action
464
+ *
465
+ * @since 1.0
466
+ * @see after_plugin_row_{$init} action
467
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
468
+ */
469
+ public function remove_wp_plugin_update_row() {
470
+ foreach( $this->_plugins as $init => $plugin ){
471
+ remove_action( "after_plugin_row_{$init}", 'wp_plugin_update_row', 10, 2 );
472
+ add_action( "after_plugin_row_{$init}", array( $this, 'plugin_update_row' ) );
473
+ add_action( "in_theme_update_message-{$init}", array( $this, 'in_theme_update_message' ), 10, 3 );
474
+ }
475
+ }
476
+
477
+ public function in_theme_update_message( $plugin, $changelog, $changelog_id, $echo = true ){
478
+
479
+ $res = "<div id='{$changelog_id}' class='yit-plugin-changelog-wrapper'>
480
+ <div class='yit-plugin-changelog'>
481
+ <h2 class='yit-plugin-changelog-title'>{$plugin['info']['Name']} - Changelog</h2>
482
+ <p>{$changelog}</p>
483
+ </div>
484
+ </div>";
485
+
486
+ if( $echo ){
487
+ echo $res;
488
+ }
489
+ else{
490
+ return $res;
491
+ }
492
+ }
493
+
494
+ /**
495
+ * Auto-Update Plugin in multisite
496
+ *
497
+ * Manage the non standard upgrade-plugin-multisite action
498
+ *
499
+ * @return void
500
+ *
501
+ * @since 1.0
502
+ * @see upgrade-plugin action
503
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
504
+ */
505
+ public function upgrade_plugin_multisite(){
506
+
507
+ $plugin = isset($_REQUEST['plugin']) ? trim($_REQUEST['plugin']) : '';
508
+ $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
509
+
510
+ if( 'upgrade-plugin-multisite' != $action ){
511
+ wp_die( __( 'You can\'t update the plugins for this site.', 'yith-plugin-fw' ) );
512
+ }
513
+
514
+ if ( ! current_user_can( 'update_plugins' ) ) {
515
+ wp_die( __( 'You do not have sufficient permissions to update the plugins for this site.', 'yith-plugin-fw' ) );
516
+ }
517
+
518
+ $this->check_update( get_site_transient( 'update_plugins') , true );
519
+
520
+ check_admin_referer( 'upgrade-plugin-multisite_' . $plugin );
521
+
522
+ $title = __( 'Update Plugin', 'yith-plugin-fw' );
523
+ $parent_file = 'plugins.php';
524
+ $submenu_file = 'plugins.php';
525
+
526
+ wp_enqueue_script( 'updates' );
527
+ require_once( ABSPATH . 'wp-admin/admin-header.php' );
528
+
529
+ $nonce = 'upgrade-plugin-multisite_' . $plugin;
530
+ $url = 'update.php?action=upgrade-plugin-multisite&plugin=' . urlencode( $plugin );
531
+
532
+ $upgrader = new Plugin_Upgrader( new Plugin_Upgrader_Skin( compact( 'title', 'nonce', 'url', 'plugin' ) ) );
533
+ $upgrader->upgrade( $plugin );
534
+
535
+ include( ABSPATH . 'wp-admin/admin-footer.php' );
536
+ }
537
+ }
538
+ }
539
+
540
+ if ( ! function_exists( 'YIT_Upgrade' ) ) {
541
+ /**
542
+ * Main instance of plugin
543
+ *
544
+ * @return YIT_Upgrade
545
+ * @since 1.0
546
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
547
+ */
548
+ function YIT_Upgrade() {
549
+ return YIT_Upgrade::instance();
550
+ }
551
+ }
552
+
553
+ /**
554
+ * Instance a YIT_Upgrade object
555
+ */
556
+ YIT_Upgrade();
plugin-fw/lib/yit-video.php CHANGED
@@ -1,200 +1,200 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
-
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- } // Exit if accessed directly
15
-
16
- if ( ! class_exists( 'YIT_Video' ) ) {
17
- /**
18
- * YIT Video
19
- *
20
- * Class to manage the video from youtube and vimeo or other services
21
- *
22
- * @class YIT_Video
23
- * @package Yithemes
24
- * @since 1.0.0
25
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
26
- *
27
- */
28
-
29
- class YIT_Video {
30
-
31
- /**
32
- * Generate the HTML for a youtube video
33
- *
34
- * @static
35
- *
36
- * @param array $args Array of arguments to configure the video to generate
37
- *
38
- * @return string
39
- * @since 1.0
40
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
41
- */
42
- public static function youtube( $args = array() ) {
43
- $defaults = array(
44
- 'id' => '',
45
- 'url' => '',
46
- 'width' => 425,
47
- 'height' => 356,
48
- 'echo' => false
49
- );
50
- $args = wp_parse_args( $args, $defaults );
51
- extract( $args );
52
-
53
- // get video ID if you have only URL
54
- if ( empty( $id ) && ! empty( $url ) ) {
55
- $id = self::video_id_by_url( $url );
56
- } elseif ( empty( $id ) && empty( $url ) ) {
57
- return;
58
- }
59
-
60
- ob_start();
61
-
62
- $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
63
- $id = preg_replace( '/(youtube|vimeo):/', '', $id ); ?>
64
-
65
- <div class="post_video youtube">
66
- <iframe wmode="transparent" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="https://www.youtube.com/embed/<?php echo $id; ?>?wmode=transparent" frameborder="0" allowfullscreen></iframe>
67
- </div>
68
-
69
- <?php
70
- $html = apply_filters( 'yit_video_youtube', ob_get_clean() );
71
-
72
- if( $echo ) echo $html;
73
-
74
- return $html;
75
- }
76
-
77
- /**
78
- * Generate the HTML for a vimeo video
79
- *
80
- * @static
81
- *
82
- * @param array $args Array of arguments to configure the video to generate
83
- *
84
- * @return string
85
- * @since 1.0
86
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
87
- */
88
- public static function vimeo( $args = array() ) {
89
- $defaults = array(
90
- 'id' => '',
91
- 'url' => '',
92
- 'width' => 425,
93
- 'height' => 356,
94
- 'echo' => false
95
- );
96
- $args = wp_parse_args( $args, $defaults );
97
- extract( $args );
98
-
99
- // get video ID if you have only URL
100
- if ( empty( $id ) && ! empty( $url ) ) {
101
- $id = self::video_id_by_url( $url );
102
- }
103
-
104
- ob_start();
105
-
106
- $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
107
- $id = preg_replace( '/(youtube|vimeo):/', '', $id ); ?>
108
-
109
- <div class="post_video vimeo">
110
- <iframe wmode="transparent" src="http://player.vimeo.com/video/<?php echo $id; ?>?title=0&amp;byline=0&amp;portrait=0" width="<?php echo $width; ?>" height="<?php echo $height; ?>" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
111
- </div>
112
-
113
- <?php
114
- $html = apply_filters( 'yit_video_vimeo', ob_get_clean() );
115
-
116
- if( $echo ) echo $html;
117
-
118
- return $html;
119
- }
120
-
121
- /**
122
- * Retrieve video ID from URL
123
- *
124
- * @static
125
- *
126
- * @param array $url The URL of video
127
- *
128
- * @return bool|string
129
- * @since 1.0
130
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
131
- */
132
- public static function video_id_by_url( $url ) {
133
- $parsed = parse_url( esc_url( $url ) );
134
- if ( ! isset( $parsed['host'] ) ) {
135
- return false;
136
- }
137
-
138
-
139
- switch ( $parsed['host'] ) {
140
- case 'youtube.com' :
141
- case 'www.youtube.com' :
142
- case 'youtu.be' :
143
- case 'www.youtu.be' :
144
- $id = self::youtube_id_by_url( $url );
145
- return "youtube:$id";
146
-
147
- case 'www.vimeo.com' :
148
- case 'vimeo.com' :
149
- preg_match( '/http(s)?:\/\/(\w+.)?vimeo\.com\/(.*)?(\/[0-9]+)/', $url, $matches );
150
- $id = trim( $matches[4], '/' );
151
- return "vimeo:$id";
152
-
153
- default :
154
- return false;
155
-
156
- }
157
- }
158
-
159
- /**
160
- * Retrieve video ID from URL
161
- *
162
- * @static
163
- *
164
- * @param array $url The URL of video
165
- *
166
- * @return bool|string
167
- * @since 1.0
168
- * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
169
- */
170
- protected static function youtube_id_by_url( $url ) {
171
- if ( preg_match( '/http(s)?:\/\/youtu.be/', $url, $matches) ) {
172
- $url = parse_url($url, PHP_URL_PATH);
173
- $url = str_replace( '/', '', $url);
174
- return $url;
175
-
176
- } elseif ( preg_match( '/watch/', $url, $matches) ) {
177
- $arr = parse_url($url);
178
- $url = str_replace( 'v=', '', $arr['query'] );
179
- return $url;
180
-
181
- } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/v/', $url, $matches) ) {
182
- $arr = parse_url($url);
183
- $url = str_replace( '/v/', '', $arr['path'] );
184
- return $url;
185
-
186
- } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/embed/', $url, $matches) ) {
187
- $arr = parse_url($url);
188
- $url = str_replace( '/embed/', '', $arr['path'] );
189
- return $url;
190
-
191
- } elseif ( preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+#", $url, $matches) ) {
192
- return $matches[0];
193
-
194
- } else {
195
- return false;
196
- }
197
- }
198
-
199
- }
200
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ } // Exit if accessed directly
15
+
16
+ if ( ! class_exists( 'YIT_Video' ) ) {
17
+ /**
18
+ * YIT Video
19
+ *
20
+ * Class to manage the video from youtube and vimeo or other services
21
+ *
22
+ * @class YIT_Video
23
+ * @package Yithemes
24
+ * @since 1.0.0
25
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
26
+ *
27
+ */
28
+
29
+ class YIT_Video {
30
+
31
+ /**
32
+ * Generate the HTML for a youtube video
33
+ *
34
+ * @static
35
+ *
36
+ * @param array $args Array of arguments to configure the video to generate
37
+ *
38
+ * @return string
39
+ * @since 1.0
40
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
41
+ */
42
+ public static function youtube( $args = array() ) {
43
+ $defaults = array(
44
+ 'id' => '',
45
+ 'url' => '',
46
+ 'width' => 425,
47
+ 'height' => 356,
48
+ 'echo' => false
49
+ );
50
+ $args = wp_parse_args( $args, $defaults );
51
+ extract( $args );
52
+
53
+ // get video ID if you have only URL
54
+ if ( empty( $id ) && ! empty( $url ) ) {
55
+ $id = self::video_id_by_url( $url );
56
+ } elseif ( empty( $id ) && empty( $url ) ) {
57
+ return;
58
+ }
59
+
60
+ ob_start();
61
+
62
+ $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
63
+ $id = preg_replace( '/(youtube|vimeo):/', '', $id ); ?>
64
+
65
+ <div class="post_video youtube">
66
+ <iframe wmode="transparent" width="<?php echo $width; ?>" height="<?php echo $height; ?>" src="https://www.youtube.com/embed/<?php echo $id; ?>?wmode=transparent" frameborder="0" allowfullscreen></iframe>
67
+ </div>
68
+
69
+ <?php
70
+ $html = apply_filters( 'yit_video_youtube', ob_get_clean() );
71
+
72
+ if( $echo ) echo $html;
73
+
74
+ return $html;
75
+ }
76
+
77
+ /**
78
+ * Generate the HTML for a vimeo video
79
+ *
80
+ * @static
81
+ *
82
+ * @param array $args Array of arguments to configure the video to generate
83
+ *
84
+ * @return string
85
+ * @since 1.0
86
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
87
+ */
88
+ public static function vimeo( $args = array() ) {
89
+ $defaults = array(
90
+ 'id' => '',
91
+ 'url' => '',
92
+ 'width' => 425,
93
+ 'height' => 356,
94
+ 'echo' => false
95
+ );
96
+ $args = wp_parse_args( $args, $defaults );
97
+ extract( $args );
98
+
99
+ // get video ID if you have only URL
100
+ if ( empty( $id ) && ! empty( $url ) ) {
101
+ $id = self::video_id_by_url( $url );
102
+ }
103
+
104
+ ob_start();
105
+
106
+ $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
107
+ $id = preg_replace( '/(youtube|vimeo):/', '', $id ); ?>
108
+
109
+ <div class="post_video vimeo">
110
+ <iframe wmode="transparent" src="http://player.vimeo.com/video/<?php echo $id; ?>?title=0&amp;byline=0&amp;portrait=0" width="<?php echo $width; ?>" height="<?php echo $height; ?>" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>
111
+ </div>
112
+
113
+ <?php
114
+ $html = apply_filters( 'yit_video_vimeo', ob_get_clean() );
115
+
116
+ if( $echo ) echo $html;
117
+
118
+ return $html;
119
+ }
120
+
121
+ /**
122
+ * Retrieve video ID from URL
123
+ *
124
+ * @static
125
+ *
126
+ * @param array $url The URL of video
127
+ *
128
+ * @return bool|string
129
+ * @since 1.0
130
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
131
+ */
132
+ public static function video_id_by_url( $url ) {
133
+ $parsed = parse_url( esc_url( $url ) );
134
+ if ( ! isset( $parsed['host'] ) ) {
135
+ return false;
136
+ }
137
+
138
+
139
+ switch ( $parsed['host'] ) {
140
+ case 'youtube.com' :
141
+ case 'www.youtube.com' :
142
+ case 'youtu.be' :
143
+ case 'www.youtu.be' :
144
+ $id = self::youtube_id_by_url( $url );
145
+ return "youtube:$id";
146
+
147
+ case 'www.vimeo.com' :
148
+ case 'vimeo.com' :
149
+ preg_match( '/http(s)?:\/\/(\w+.)?vimeo\.com\/(.*)?(\/[0-9]+)/', $url, $matches );
150
+ $id = trim( $matches[4], '/' );
151
+ return "vimeo:$id";
152
+
153
+ default :
154
+ return false;
155
+
156
+ }
157
+ }
158
+
159
+ /**
160
+ * Retrieve video ID from URL
161
+ *
162
+ * @static
163
+ *
164
+ * @param array $url The URL of video
165
+ *
166
+ * @return bool|string
167
+ * @since 1.0
168
+ * @author Antonino Scarfi' <antonino.scarfi@yithemes.com>
169
+ */
170
+ protected static function youtube_id_by_url( $url ) {
171
+ if ( preg_match( '/http(s)?:\/\/youtu.be/', $url, $matches) ) {
172
+ $url = parse_url($url, PHP_URL_PATH);
173
+ $url = str_replace( '/', '', $url);
174
+ return $url;
175
+
176
+ } elseif ( preg_match( '/watch/', $url, $matches) ) {
177
+ $arr = parse_url($url);
178
+ $url = str_replace( 'v=', '', $arr['query'] );
179
+ return $url;
180
+
181
+ } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/v/', $url, $matches) ) {
182
+ $arr = parse_url($url);
183
+ $url = str_replace( '/v/', '', $arr['path'] );
184
+ return $url;
185
+
186
+ } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/embed/', $url, $matches) ) {
187
+ $arr = parse_url($url);
188
+ $url = str_replace( '/embed/', '', $arr['path'] );
189
+ return $url;
190
+
191
+ } elseif ( preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+#", $url, $matches) ) {
192
+ return $matches[0];
193
+
194
+ } else {
195
+ return false;
196
+ }
197
+ }
198
+
199
+ }
200
  }
plugin-fw/licence/assets/css/yit-licence.css CHANGED
@@ -1,439 +1,439 @@
1
- /* === Plugins Upgrader === */
2
-
3
- .yit-plugin-changelog-wrapper {
4
- display: none;
5
- }
6
-
7
- .yit-plugin-changelog-title {
8
- text-transform: uppercase;
9
- }
10
-
11
- .yit-plugin-changelog {
12
- background: #fcfcfc;
13
- height: 97%;
14
- z-index: 999;
15
- overflow: auto;
16
- }
17
-
18
- /* === Plugins Licence Activation === */
19
-
20
- .yit-container.product-licence-activation {
21
- font-family: 'Raleway', sans-serif;
22
- }
23
-
24
- .yit-container.product-licence-activation .to-active-wrapper {
25
- margin-bottom: 60px;
26
- max-width: 900px;
27
- }
28
-
29
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form {
30
- position: relative;
31
- border-color: #e1e1e1;
32
- border-style: solid;
33
- border-width: 0;
34
- }
35
-
36
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:first-child {
37
- border-top-width: 1px;
38
- }
39
-
40
- .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:last-child {
41
- border-bottom-width: 1px;
42
- }
43
-
44
- .yit-container.product-licence-activation .to-active-wrapper table.to-active-table {
45
- border-width: 0;
46
- border-spacing: 0;
47
- width: 100%;
48
- }
49
-
50
- .yit-container.product-licence-activation .message {
51
- display: none;
52
- line-height: normal;
53
- background: #ffffff url(../images/licence-error.png) 15px center no-repeat;
54
- padding-left: 65px;
55
- padding-right: 15px;
56
- width: 150px;
57
- }
58
-
59
- .yit-container.product-licence-activation .message-wrapper {
60
- height: 75px;
61
- display: none;
62
- position: absolute;
63
- top: 0;
64
- right: -250px;
65
- border: 1px solid #ff3838;
66
- }
67
-
68
- .yit-container.product-licence-activation .message-wrapper.visible {
69
- display: table;
70
- }
71
-
72
- .yit-container.product-licence-activation .message {
73
- display: table-cell;
74
- vertical-align: middle;
75
- }
76
-
77
- .yit-container.product-licence-activation .arrow-left:after,
78
- .yit-container.product-licence-activation .arrow-left:before {
79
- content: "";
80
- display: block;
81
- width: 0;
82
- height: 0;
83
- position: absolute;
84
- }
85
-
86
- .yit-container.product-licence-activation .arrow-left:before {
87
- border-top: 9px solid transparent;
88
- border-bottom: 9px solid transparent;
89
- border-right: 9px solid #ff3838;
90
- top: 26px;
91
- left: -9px;
92
- }
93
-
94
- .yit-container.product-licence-activation .arrow-left:after {
95
- border-top: 8px solid transparent;
96
- border-bottom: 8px solid transparent;
97
- border-right: 8px solid #fff;
98
- left: -8px;
99
- top: 27px;
100
- }
101
-
102
- .yit-container.product-licence-activation h2,
103
- .yit-container.product-licence-activation h3 {
104
- text-transform: uppercase;
105
- font-weight: 800;
106
- margin-bottom: 30px;
107
- }
108
-
109
- .yit-container.product-licence-activation h2 {
110
- color: #808a97;
111
- font-size: 25px;
112
- }
113
- .yit-container.product-licence-activation h3 {
114
- color: #313131;
115
- font-size: 15px;
116
- height: 20px;
117
- }
118
-
119
- .yit-container.product-licence-activation h3.to-active {
120
- height: 20px;
121
- position: relative;
122
- vertical-align: top;
123
- }
124
-
125
- .yit-container.product-licence-activation .spinner{
126
- vertical-align: -5px;
127
- float: none;
128
- }
129
-
130
- .yit-container.product-licence-activation .spinner.show{
131
- visibility: visible;
132
- }
133
-
134
- .yit-container.product-licence-activation .licence-check-section{
135
- margin-bottom: 60px;
136
- }
137
-
138
- .yit-container.product-licence-activation span.licence-label {
139
- font-weight: 500;
140
- color: #606060;
141
- margin-bottom: 30px;
142
- }
143
-
144
- .yit-container.product-licence-activation .button-licence {
145
- border: 0;
146
- font-size: 13px;
147
- text-transform: uppercase;
148
- background-color: #808a97;
149
- color: #fff;
150
- font-weight: 700;
151
- border-radius: 3px;
152
- cursor: pointer;
153
- text-decoration: none;
154
- padding: 5px 7px;
155
- -webkit-transition: background-color 0.3s ease;
156
- -moz-transition: background-color 0.3s ease;
157
- -ms-transition: background-color 0.3s ease;
158
- -o-transition: background-color 0.3s ease;
159
- transition: background-color 0.3s ease;
160
- }
161
-
162
- .yit-container.product-licence-activation .button-licence:hover {
163
- background-color: #4d5c6f;
164
- }
165
-
166
- .yit-container.product-licence-activation .button-licence.clicked {
167
- cursor: not-allowed;
168
- background-color: #e2e2e2 !important;
169
- }
170
-
171
- .yit-container.product-licence-activation .button-licence.licence-check {
172
- font-weight: 400;
173
- padding: 12px 19px;
174
- }
175
-
176
- .yit-container.product-licence-activation .button-licence.licence-deactive,
177
- .yit-container.product-licence-activation .button-licence.licence-renew {
178
- text-decoration: none;
179
- padding: 7px 12px;
180
- font-size: 9px;
181
- }
182
-
183
- .yit-container.product-licence-activation table:not(.expired-table) .button-licence.licence-renew {
184
- margin-left: 10px;
185
- }
186
-
187
- .yit-container.product-licence-activation .button-licence.licence-deactive:focus,
188
- .yit-container.product-licence-activation .button-licence.licence-renew:focus {
189
- box-shadow: none;
190
- }
191
-
192
- .yit-container.product-licence-activation table:not(.to-active-table) {
193
- width: auto;
194
- border: 1px solid #dcdcdc;
195
- border-spacing: 0;
196
- border-radius: 5px;
197
- border-collapse: separate;
198
- overflow: hidden;
199
- }
200
-
201
- .yit-container.product-licence-activation table:not(.to-active-table) th {
202
- border-bottom: 1px solid #dcdcdc;
203
- padding: 0 10px;
204
- }
205
-
206
- .yit-container.product-licence-activation table tbody tr td.product-licence-key {
207
- text-transform: lowercase;
208
- }
209
-
210
- .yit-container.product-licence-activation table:not(.to-active-table) td,
211
- .yit-container.product-licence-activation table:not(.to-active-table) th {
212
- border-right: 1px solid #dcdcdc;
213
- }
214
-
215
- .yit-container.product-licence-activation table td:last-child,
216
- .yit-container.product-licence-activation table th:last-child {
217
- border-right: 0;
218
- }
219
-
220
- .yit-container.product-licence-activation table thead tr {
221
- background-color: #f6f4f4;
222
- }
223
-
224
- .yit-container.product-licence-activation table tbody tr {
225
- background-color: #ffffff;
226
- }
227
-
228
- .yit-container.product-licence-activation table tbody tr:nth-child(2n) {
229
- background-color: #f4f4f4;
230
- }
231
-
232
- .yit-container.product-licence-activation table thead tr th {
233
- font-size: 11px;
234
- color: #313131;
235
- text-transform: uppercase;
236
- font-weight: bold;
237
- }
238
-
239
- .yit-container.product-licence-activation table thead tr,
240
- .yit-container.product-licence-activation table tbody tr {
241
- line-height: 60px;
242
- }
243
-
244
- .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-no-alt {
245
- color: #b20015;
246
- }
247
-
248
- .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-yes {
249
- color: #1ca800;
250
- }
251
-
252
- .yit-container.product-licence-activation table tbody tr td{
253
- text-align: center;
254
- line-height: 20px;
255
- padding: 10px 5px;
256
- }
257
-
258
- .yit-container.product-licence-activation .button-licence.licence-activation {
259
- padding: 12px 18px;
260
- }
261
-
262
- .yit-container.product-licence-activation .to-active-table tr {
263
- line-height: 75px;
264
- }
265
-
266
- .yit-container.product-licence-activation .to-active-table tr.product-row {
267
- background-color: transparent;
268
- -webkit-transition: all 0.3s ease;
269
- -moz-transition: all 0.3s ease;
270
- -ms-transition: all 0.3s ease;
271
- -o-transition: all 0.3s ease;
272
- transition: all 0.3s ease;
273
- }
274
-
275
- .yit-container.product-licence-activation .to-active-table tr.product-row.error {
276
- background-color: #ffdcdc;
277
- }
278
-
279
- .yit-container.product-licence-activation .to-active-table td {
280
- padding-right: 12px;
281
- width: 33%;
282
- }
283
-
284
- .yit-container.product-licence-activation td.product-name {
285
- color: #808a97;
286
- font-size: 12px;
287
- text-transform: uppercase;
288
- font-weight: bold;
289
- line-height: 20px;
290
- padding: 10px 20px;
291
- }
292
-
293
- .yit-container.product-licence-activation .to-active-table td.product-name {
294
- width: 20%;
295
- }
296
-
297
- .yit-container.product-licence-activation .to-active-table td.activate-button {
298
- width: 15%;
299
- position: relative;
300
- }
301
-
302
- .yit-container.product-licence-activation input[type=text],
303
- .yit-container.product-licence-activation input[type=email]{
304
- -webkit-transition: all 0.3s ease;
305
- -moz-transition: all 0.3s ease;
306
- -ms-transition: all 0.3s ease;
307
- -o-transition: all 0.3s ease;
308
- transition: all 0.3s ease;
309
-
310
- border: 1px solid #dcdcdc;
311
- padding: 0 15px;
312
- border-radius: 3px;
313
- height: 41px;
314
- width: 100%;
315
- }
316
-
317
- .yit-container.product-licence-activation input[type=text].require,
318
- .yit-container.product-licence-activation input[type=email].require {
319
- border: 1px solid #ff3838;
320
- }
321
-
322
- .yit-container.product-licence-activation input[type=text]:focus,
323
- .yit-container.product-licence-activation input[type=email]:focus{
324
- webkit-box-shadow: 0 0 1px rgba(30,140,190,.8);
325
- box-shadow: 0 0 1px rgba(30,140,190,.8);
326
- }
327
-
328
- .yit-container.product-licence-activation input[type=text],
329
- .yit-container.product-licence-activation input[type=email]{
330
- text-transform: uppercase;
331
- text-align: center;
332
- }
333
-
334
- .yit-container.product-licence-activation input[type=submit]:focus{
335
- outline: 0;
336
- }
337
-
338
- /* Licence FAQ */
339
- .yit-container.product-licence-activation .activation-faq {
340
- background: #ffffff;
341
- margin-bottom: 20px;
342
- border: 1px solid #dcdcdc;
343
- padding: 0 15px;
344
- border-radius: 3px;
345
- }
346
-
347
- .yit-container.product-licence-activation .activation-faq h3{
348
- color: #808a97;
349
- }
350
-
351
- #yith-licence-notice {
352
- margin-left: 0;
353
- visibility: hidden;
354
- min-height: 38px;
355
- }
356
-
357
- #yith-licence-notice.visible {
358
- visibility: visible;
359
- }
360
-
361
- /* === Responsive === */
362
-
363
- @media (max-width: 767px) {
364
- .yit-container.product-licence-activation .activation-faq {
365
- margin-right: 5px;
366
- }
367
- }
368
-
369
- @media (max-width: 480px) {
370
- .yit-container.product-licence-activation .activation-faq {
371
- margin-right: 5px;
372
- }
373
- }
374
-
375
- @media (min-width: 768px) and (max-width: 992px) {
376
- .yit-container.product-licence-activation .button-licence.licence-deactive,
377
- .yit-container.product-licence-activation .button-licence.licence-renew {
378
- margin-bottom: 10px;
379
- display: block;
380
- margin-left: 0;
381
- padding: 5px 7px;
382
- }
383
-
384
- .yit-container.product-licence-activation .button-licence.licence-deactive {
385
- margin-bottom: 10px;
386
- }
387
-
388
- .yit-container.product-licence-activation table:not(.to-active-table) th {
389
- line-height: 20px;
390
- }
391
-
392
- .yit-container.product-licence-activation table tbody tr td {
393
- padding: 5px;
394
- }
395
-
396
- .yit-container.product-licence-activation .activation-faq {
397
- margin-right: 20px;
398
- }
399
- }
400
-
401
- @media (min-width: 980px) and (max-width: 1199px) {
402
- .yit-container.product-licence-activation .button-licence.licence-deactive,
403
- .yit-container.product-licence-activation .button-licence.licence-renew {
404
- display: block;
405
- margin-left: 0;
406
- padding: 5px 7px;
407
- }
408
-
409
- .yit-container.product-licence-activation .button-licence.licence-renew {
410
- margin-top: 10px;
411
- }
412
-
413
- .yit-container.product-licence-activation table:not(.to-active-table) th {
414
- line-height: 20px;
415
- }
416
-
417
- .yit-container.product-licence-activation table tbody tr td {
418
- padding: 5px;
419
- }
420
-
421
- .yit-container.product-licence-activation .activation-faq {
422
- width: 75%;
423
- }
424
- }
425
-
426
- @media (min-width: 1200px) {
427
- .yit-container.product-licence-activation{
428
- width: auto;
429
- }
430
-
431
- .yit-container.product-licence-activation .activation-faq {
432
- width: 50%;
433
- }
434
- }
435
-
436
- @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
437
- only screen and (-o-min-device-pixel-ratio: 3/2),
438
- only screen and (min--moz-device-pixel-ratio: 1.5),
439
- only screen and (min-device-pixel-ratio: 1.5) {}
1
+ /* === Plugins Upgrader === */
2
+
3
+ .yit-plugin-changelog-wrapper {
4
+ display: none;
5
+ }
6
+
7
+ .yit-plugin-changelog-title {
8
+ text-transform: uppercase;
9
+ }
10
+
11
+ .yit-plugin-changelog {
12
+ background: #fcfcfc;
13
+ height: 97%;
14
+ z-index: 999;
15
+ overflow: auto;
16
+ }
17
+
18
+ /* === Plugins Licence Activation === */
19
+
20
+ .yit-container.product-licence-activation {
21
+ font-family: 'Raleway', sans-serif;
22
+ }
23
+
24
+ .yit-container.product-licence-activation .to-active-wrapper {
25
+ margin-bottom: 60px;
26
+ max-width: 900px;
27
+ }
28
+
29
+ .yit-container.product-licence-activation .to-active-wrapper form.to-active-form {
30
+ position: relative;
31
+ border-color: #e1e1e1;
32
+ border-style: solid;
33
+ border-width: 0;
34
+ }
35
+
36
+ .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:first-child {
37
+ border-top-width: 1px;
38
+ }
39
+
40
+ .yit-container.product-licence-activation .to-active-wrapper form.to-active-form:last-child {
41
+ border-bottom-width: 1px;
42
+ }
43
+
44
+ .yit-container.product-licence-activation .to-active-wrapper table.to-active-table {
45
+ border-width: 0;
46
+ border-spacing: 0;
47
+ width: 100%;
48
+ }
49
+
50
+ .yit-container.product-licence-activation .message {
51
+ display: none;
52
+ line-height: normal;
53
+ background: #ffffff url(../images/licence-error.png) 15px center no-repeat;
54
+ padding-left: 65px;
55
+ padding-right: 15px;
56
+ width: 150px;
57
+ }
58
+
59
+ .yit-container.product-licence-activation .message-wrapper {
60
+ height: 75px;
61
+ display: none;
62
+ position: absolute;
63
+ top: 0;
64
+ right: -250px;
65
+ border: 1px solid #ff3838;
66
+ }
67
+
68
+ .yit-container.product-licence-activation .message-wrapper.visible {
69
+ display: table;
70
+ }
71
+
72
+ .yit-container.product-licence-activation .message {
73
+ display: table-cell;
74
+ vertical-align: middle;
75
+ }
76
+
77
+ .yit-container.product-licence-activation .arrow-left:after,
78
+ .yit-container.product-licence-activation .arrow-left:before {
79
+ content: "";
80
+ display: block;
81
+ width: 0;
82
+ height: 0;
83
+ position: absolute;
84
+ }
85
+
86
+ .yit-container.product-licence-activation .arrow-left:before {
87
+ border-top: 9px solid transparent;
88
+ border-bottom: 9px solid transparent;
89
+ border-right: 9px solid #ff3838;
90
+ top: 26px;
91
+ left: -9px;
92
+ }
93
+
94
+ .yit-container.product-licence-activation .arrow-left:after {
95
+ border-top: 8px solid transparent;
96
+ border-bottom: 8px solid transparent;
97
+ border-right: 8px solid #fff;
98
+ left: -8px;
99
+ top: 27px;
100
+ }
101
+
102
+ .yit-container.product-licence-activation h2,
103
+ .yit-container.product-licence-activation h3 {
104
+ text-transform: uppercase;
105
+ font-weight: 800;
106
+ margin-bottom: 30px;
107
+ }
108
+
109
+ .yit-container.product-licence-activation h2 {
110
+ color: #808a97;
111
+ font-size: 25px;
112
+ }
113
+ .yit-container.product-licence-activation h3 {
114
+ color: #313131;
115
+ font-size: 15px;
116
+ height: 20px;
117
+ }
118
+
119
+ .yit-container.product-licence-activation h3.to-active {
120
+ height: 20px;
121
+ position: relative;
122
+ vertical-align: top;
123
+ }
124
+
125
+ .yit-container.product-licence-activation .spinner{
126
+ vertical-align: -5px;
127
+ float: none;
128
+ }
129
+
130
+ .yit-container.product-licence-activation .spinner.show{
131
+ visibility: visible;
132
+ }
133
+
134
+ .yit-container.product-licence-activation .licence-check-section{
135
+ margin-bottom: 60px;
136
+ }
137
+
138
+ .yit-container.product-licence-activation span.licence-label {
139
+ font-weight: 500;
140
+ color: #606060;
141
+ margin-bottom: 30px;
142
+ }
143
+
144
+ .yit-container.product-licence-activation .button-licence {
145
+ border: 0;
146
+ font-size: 13px;
147
+ text-transform: uppercase;
148
+ background-color: #808a97;
149
+ color: #fff;
150
+ font-weight: 700;
151
+ border-radius: 3px;
152
+ cursor: pointer;
153
+ text-decoration: none;
154
+ padding: 5px 7px;
155
+ -webkit-transition: background-color 0.3s ease;
156
+ -moz-transition: background-color 0.3s ease;
157
+ -ms-transition: background-color 0.3s ease;
158
+ -o-transition: background-color 0.3s ease;
159
+ transition: background-color 0.3s ease;
160
+ }
161
+
162
+ .yit-container.product-licence-activation .button-licence:hover {
163
+ background-color: #4d5c6f;
164
+ }
165
+
166
+ .yit-container.product-licence-activation .button-licence.clicked {
167
+ cursor: not-allowed;
168
+ background-color: #e2e2e2 !important;
169
+ }
170
+
171
+ .yit-container.product-licence-activation .button-licence.licence-check {
172
+ font-weight: 400;
173
+ padding: 12px 19px;
174
+ }
175
+
176
+ .yit-container.product-licence-activation .button-licence.licence-deactive,
177
+ .yit-container.product-licence-activation .button-licence.licence-renew {
178
+ text-decoration: none;
179
+ padding: 7px 12px;
180
+ font-size: 9px;
181
+ }
182
+
183
+ .yit-container.product-licence-activation table:not(.expired-table) .button-licence.licence-renew {
184
+ margin-left: 10px;
185
+ }
186
+
187
+ .yit-container.product-licence-activation .button-licence.licence-deactive:focus,
188
+ .yit-container.product-licence-activation .button-licence.licence-renew:focus {
189
+ box-shadow: none;
190
+ }
191
+
192
+ .yit-container.product-licence-activation table:not(.to-active-table) {
193
+ width: auto;
194
+ border: 1px solid #dcdcdc;
195
+ border-spacing: 0;
196
+ border-radius: 5px;
197
+ border-collapse: separate;
198
+ overflow: hidden;
199
+ }
200
+
201
+ .yit-container.product-licence-activation table:not(.to-active-table) th {
202
+ border-bottom: 1px solid #dcdcdc;
203
+ padding: 0 10px;
204
+ }
205
+
206
+ .yit-container.product-licence-activation table tbody tr td.product-licence-key {
207
+ text-transform: lowercase;
208
+ }
209
+
210
+ .yit-container.product-licence-activation table:not(.to-active-table) td,
211
+ .yit-container.product-licence-activation table:not(.to-active-table) th {
212
+ border-right: 1px solid #dcdcdc;
213
+ }
214
+
215
+ .yit-container.product-licence-activation table td:last-child,
216
+ .yit-container.product-licence-activation table th:last-child {
217
+ border-right: 0;
218
+ }
219
+
220
+ .yit-container.product-licence-activation table thead tr {
221
+ background-color: #f6f4f4;
222
+ }
223
+
224
+ .yit-container.product-licence-activation table tbody tr {
225
+ background-color: #ffffff;
226
+ }
227
+
228
+ .yit-container.product-licence-activation table tbody tr:nth-child(2n) {
229
+ background-color: #f4f4f4;
230
+ }
231
+
232
+ .yit-container.product-licence-activation table thead tr th {
233
+ font-size: 11px;
234
+ color: #313131;
235
+ text-transform: uppercase;
236
+ font-weight: bold;
237
+ }
238
+
239
+ .yit-container.product-licence-activation table thead tr,
240
+ .yit-container.product-licence-activation table tbody tr {
241
+ line-height: 60px;
242
+ }
243
+
244
+ .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-no-alt {
245
+ color: #b20015;
246
+ }
247
+
248
+ .yit-container.product-licence-activation table tbody tr td.product-licence-membership .dashicons-yes {
249
+ color: #1ca800;
250
+ }
251
+
252
+ .yit-container.product-licence-activation table tbody tr td{
253
+ text-align: center;
254
+ line-height: 20px;
255
+ padding: 10px 5px;
256
+ }
257
+
258
+ .yit-container.product-licence-activation .button-licence.licence-activation {
259
+ padding: 12px 18px;
260
+ }
261
+
262
+ .yit-container.product-licence-activation .to-active-table tr {
263
+ line-height: 75px;
264
+ }
265
+
266
+ .yit-container.product-licence-activation .to-active-table tr.product-row {
267
+ background-color: transparent;
268
+ -webkit-transition: all 0.3s ease;
269
+ -moz-transition: all 0.3s ease;
270
+ -ms-transition: all 0.3s ease;
271
+ -o-transition: all 0.3s ease;
272
+ transition: all 0.3s ease;
273
+ }
274
+
275
+ .yit-container.product-licence-activation .to-active-table tr.product-row.error {
276
+ background-color: #ffdcdc;
277
+ }
278
+
279
+ .yit-container.product-licence-activation .to-active-table td {
280
+ padding-right: 12px;
281
+ width: 33%;
282
+ }
283
+
284
+ .yit-container.product-licence-activation td.product-name {
285
+ color: #808a97;
286
+ font-size: 12px;
287
+ text-transform: uppercase;
288
+ font-weight: bold;
289
+ line-height: 20px;
290
+ padding: 10px 20px;
291
+ }
292
+
293
+ .yit-container.product-licence-activation .to-active-table td.product-name {
294
+ width: 20%;
295
+ }
296
+
297
+ .yit-container.product-licence-activation .to-active-table td.activate-button {
298
+ width: 15%;
299
+ position: relative;
300
+ }
301
+
302
+ .yit-container.product-licence-activation input[type=text],
303
+ .yit-container.product-licence-activation input[type=email]{
304
+ -webkit-transition: all 0.3s ease;
305
+ -moz-transition: all 0.3s ease;
306
+ -ms-transition: all 0.3s ease;
307
+ -o-transition: all 0.3s ease;
308
+ transition: all 0.3s ease;
309
+
310
+ border: 1px solid #dcdcdc;
311
+ padding: 0 15px;
312
+ border-radius: 3px;
313
+ height: 41px;
314
+ width: 100%;
315
+ }
316
+
317
+ .yit-container.product-licence-activation input[type=text].require,
318
+ .yit-container.product-licence-activation input[type=email].require {
319
+ border: 1px solid #ff3838;
320
+ }
321
+
322
+ .yit-container.product-licence-activation input[type=text]:focus,
323
+ .yit-container.product-licence-activation input[type=email]:focus{
324
+ webkit-box-shadow: 0 0 1px rgba(30,140,190,.8);
325
+ box-shadow: 0 0 1px rgba(30,140,190,.8);
326
+ }
327
+
328
+ .yit-container.product-licence-activation input[type=text],
329
+ .yit-container.product-licence-activation input[type=email]{
330
+ text-transform: uppercase;
331
+ text-align: center;
332
+ }
333
+
334
+ .yit-container.product-licence-activation input[type=submit]:focus{
335
+ outline: 0;
336
+ }
337
+
338
+ /* Licence FAQ */
339
+ .yit-container.product-licence-activation .activation-faq {
340
+ background: #ffffff;
341
+ margin-bottom: 20px;
342
+ border: 1px solid #dcdcdc;
343
+ padding: 0 15px;
344
+ border-radius: 3px;
345
+ }
346
+
347
+ .yit-container.product-licence-activation .activation-faq h3{
348
+ color: #808a97;
349
+ }
350
+
351
+ #yith-licence-notice {
352
+ margin-left: 0;
353
+ visibility: hidden;
354
+ min-height: 38px;
355
+ }
356
+
357
+ #yith-licence-notice.visible {
358
+ visibility: visible;
359
+ }
360
+
361
+ /* === Responsive === */
362
+
363
+ @media (max-width: 767px) {
364
+ .yit-container.product-licence-activation .activation-faq {
365
+ margin-right: 5px;
366
+ }
367
+ }
368
+
369
+ @media (max-width: 480px) {
370
+ .yit-container.product-licence-activation .activation-faq {
371
+ margin-right: 5px;
372
+ }
373
+ }
374
+
375
+ @media (min-width: 768px) and (max-width: 992px) {
376
+ .yit-container.product-licence-activation .button-licence.licence-deactive,
377
+ .yit-container.product-licence-activation .button-licence.licence-renew {
378
+ margin-bottom: 10px;
379
+ display: block;
380
+ margin-left: 0;
381
+ padding: 5px 7px;
382
+ }
383
+
384
+ .yit-container.product-licence-activation .button-licence.licence-deactive {
385
+ margin-bottom: 10px;
386
+ }
387
+
388
+ .yit-container.product-licence-activation table:not(.to-active-table) th {
389
+ line-height: 20px;
390
+ }
391
+
392
+ .yit-container.product-licence-activation table tbody tr td {
393
+ padding: 5px;
394
+ }
395
+
396
+ .yit-container.product-licence-activation .activation-faq {
397
+ margin-right: 20px;
398
+ }
399
+ }
400
+
401
+ @media (min-width: 980px) and (max-width: 1199px) {
402
+ .yit-container.product-licence-activation .button-licence.licence-deactive,
403
+ .yit-container.product-licence-activation .button-licence.licence-renew {
404
+ display: block;
405
+ margin-left: 0;
406
+ padding: 5px 7px;
407
+ }
408
+
409
+ .yit-container.product-licence-activation .button-licence.licence-renew {
410
+ margin-top: 10px;
411
+ }
412
+
413
+ .yit-container.product-licence-activation table:not(.to-active-table) th {
414
+ line-height: 20px;
415
+ }
416
+
417
+ .yit-container.product-licence-activation table tbody tr td {
418
+ padding: 5px;
419
+ }
420
+
421
+ .yit-container.product-licence-activation .activation-faq {
422
+ width: 75%;
423
+ }
424
+ }
425
+
426
+ @media (min-width: 1200px) {
427
+ .yit-container.product-licence-activation{
428
+ width: auto;
429
+ }
430
+
431
+ .yit-container.product-licence-activation .activation-faq {
432
+ width: 50%;
433
+ }
434
+ }
435
+
436
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5),
437
+ only screen and (-o-min-device-pixel-ratio: 3/2),
438
+ only screen and (min--moz-device-pixel-ratio: 1.5),
439
+ only screen and (min-device-pixel-ratio: 1.5) {}
plugin-fw/licence/assets/js/yit-licence.js CHANGED
@@ -1,196 +1,196 @@
1
- /**
2
- * This file belongs to the YIT Plugin Framework.
3
- *
4
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
- * that is bundled with this package in the file LICENSE.txt.
6
- * It is also available through the world-wide-web at this URL:
7
- * http://www.gnu.org/licenses/gpl-3.0.txt
8
- */
9
-
10
-
11
- (function ($) {
12
-
13
- /* === Licence API === */
14
-
15
- var licence_activation = function (button) {
16
- button.on('click', function (e, button) {
17
- e.preventDefault();
18
-
19
- var t = $(this),
20
- form_id = t.data('formid'),
21
- form = $('#' + form_id),
22
- data = form.serialize(),
23
- message = $(form).find('.message'),
24
- message_wrapper = $(form).find('.message-wrapper'),
25
- email = form.find('.user-email'),
26
- licence_key = form.find('.licence-key'),
27
- email_val = form.find('.user-email').val(),
28
- licence_key_val = form.find('.licence-key').val(),
29
- error = false,
30
- error_fields = new Array(),
31
- product_row = form.find('.product-row'),
32
- licence_activation = $('.licence-activation'),
33
- spinner = $('#products-to-active').find('.spinner');
34
-
35
- /* Init Input Fields */
36
- message.empty();
37
- message_wrapper.removeClass('visible')
38
- email.removeClass('require');
39
- licence_key.removeClass('require');
40
- product_row.removeClass('error');
41
- spinner.addClass('show');
42
- t.add(licence_activation).prop("disabled", true).addClass('clicked');
43
-
44
- if ('' == email_val) {
45
- error = true;
46
- error_fields[ error_fields.length ] = licence_message.email;
47
- email.addClass('require');
48
- }
49
-
50
- if ('' == licence_key_val) {
51
- error = true;
52
- error_fields[ error_fields.length ] = licence_message.license_key;
53
- licence_key.addClass('require');
54
- }
55
-
56
- if (false == error) {
57
- jQuery.ajax({
58
- type : 'POST',
59
- url : ajaxurl,
60
- data : data,
61
- success: function (response) {
62
-
63
- spinner.removeClass('show');
64
- t.add(licence_activation).prop("disabled", false).removeClass('clicked');
65
-
66
- if (true == response.activated) {
67
- $('.product-licence-activation').empty().replaceWith(response.template);
68
- licence_api();
69
- } else if (false != response) {
70
- message.text(response.error);
71
- message_wrapper.addClass('visible');
72
- product_row.addClass('error');
73
- } else {
74
- message.text(licence_message.server);
75
- message_wrapper.addClass('visible');
76
- product_row.addClass('error');
77
- }
78
- }
79
- });
80
- } else {
81
- if (error_fields.length == 1) {
82
- message.text(licence_message.error.replace('%field%', error_fields[0]));
83
- message_wrapper.addClass('visible');
84
- product_row.addClass('error');
85
- } else {
86
- var message_text = licence_message.errors;
87
- for (var i = 0; i < error_fields.length; i++) {
88
- message_text = message_text.replace('%field_' + ( i + 1) + '%', error_fields[i]);
89
- message_wrapper.addClass('visible');
90
- }
91
- message.text(message_text);
92
- message_wrapper.addClass('visible');
93
- product_row.addClass('error');
94
- }
95
-
96
- spinner.removeClass('show');
97
- t.add(licence_activation).prop("disabled", false).removeClass('clicked');
98
- }
99
- });
100
- };
101
-
102
- var licence_update = function (button) {
103
- button.on('click', function (e) {
104
- e.preventDefault();
105
-
106
- var t = $(this),
107
- form = $('#licence-check-update'),
108
- data = form.serialize();
109
-
110
- t.prop("disabled", true).addClass('clicked');
111
- form.find('div.spinner').addClass('show');
112
-
113
- jQuery.ajax({
114
- type : 'POST',
115
- url : ajaxurl,
116
- data : data,
117
- success: function (response) {
118
- $('.product-licence-activation').empty().replaceWith(response.template);
119
- licence_api();
120
- }
121
- });
122
- });
123
- };
124
-
125
- var licence_deactivate = function (button) {
126
- button.on('click', function (e) {
127
- e.preventDefault();
128
-
129
- var check = script_info.is_debug == true ? true : confirm( licence_message.are_you_sure );
130
-
131
- if( check == true ){
132
- var t = $(this),
133
- licence_key = t.data('licence-key'),
134
- licence_email = t.data('licence-email'),
135
- product_init = t.data('product-init'),
136
- action = t.data('action'),
137
- renew = $('.licence-renew'),
138
- deactive = $('.licence-deactive'),
139
- message = $('#yith-licence-notice'),
140
- activated_table = $('.activated-table');
141
-
142
- t.add(renew).add(deactive).prop("disabled", true).addClass('clicked');
143
- $('#activated-products').find('.spinner').addClass('show');
144
-
145
- jQuery.ajax({
146
- type : 'POST',
147
- url : ajaxurl,
148
- data : {
149
- action: action,
150
- licence_key: licence_key,
151
- email: licence_email,
152
- product_init: product_init
153
- },
154
- success: function (response) {
155
- message.css( 'maxWidth', activated_table.width() );
156
- if (false == response.activated && typeof response.error == 'undefined') {
157
- $('.product-licence-activation').empty().replaceWith(response.template);
158
- licence_api();
159
- }
160
-
161
- if (false == response.activated && typeof response.error != 'undefined') {
162
- message.find('p.yith-licence-notice-message').html(response.error);
163
- message.removeClass('notice-success').addClass('notice-error visible');
164
- t.add(renew).add(deactive).add(renew).prop("disabled", false).removeClass('clicked');
165
- $('#activated-products').find('.spinner').removeClass('show');
166
- }
167
-
168
- else if (false == response) {
169
- message.find('p.yith-licence-notice-message').html(licence_message.server);
170
- message.removeClass('notice-success').addClass('notice-error visible');
171
- t.add(renew).add(deactive).add(renew).prop("disabled", false).removeClass('clicked');
172
- $('#activated-products').find('.spinner').removeClass('show');
173
- }
174
- }
175
- });
176
- }
177
- });
178
- };
179
-
180
- var licence_api = function () {
181
- var button = $('.licence-activation'),
182
- check = $('.licence-check'),
183
- deactivated = $('.licence-deactive');
184
-
185
- licence_activation(button);
186
- licence_update(check);
187
- licence_deactivate(deactivated);
188
- };
189
-
190
- licence_api();
191
-
192
- $('body').on('click', '.yit-changelog-button', function (e) {
193
- $('#TB_window').remove();
194
- });
195
-
196
  })(jQuery);
1
+ /**
2
+ * This file belongs to the YIT Plugin Framework.
3
+ *
4
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
5
+ * that is bundled with this package in the file LICENSE.txt.
6
+ * It is also available through the world-wide-web at this URL:
7
+ * http://www.gnu.org/licenses/gpl-3.0.txt
8
+ */
9
+
10
+
11
+ (function ($) {
12
+
13
+ /* === Licence API === */
14
+
15
+ var licence_activation = function (button) {
16
+ button.on('click', function (e, button) {
17
+ e.preventDefault();
18
+
19
+ var t = $(this),
20
+ form_id = t.data('formid'),
21
+ form = $('#' + form_id),
22
+ data = form.serialize(),
23
+ message = $(form).find('.message'),
24
+ message_wrapper = $(form).find('.message-wrapper'),
25
+ email = form.find('.user-email'),
26
+ licence_key = form.find('.licence-key'),
27
+ email_val = form.find('.user-email').val(),
28
+ licence_key_val = form.find('.licence-key').val(),
29
+ error = false,
30
+ error_fields = new Array(),
31
+ product_row = form.find('.product-row'),
32
+ licence_activation = $('.licence-activation'),
33
+ spinner = $('#products-to-active').find('.spinner');
34
+
35
+ /* Init Input Fields */
36
+ message.empty();
37
+ message_wrapper.removeClass('visible')
38
+ email.removeClass('require');
39
+ licence_key.removeClass('require');
40
+ product_row.removeClass('error');
41
+ spinner.addClass('show');
42
+ t.add(licence_activation).prop("disabled", true).addClass('clicked');
43
+
44
+ if ('' == email_val) {
45
+ error = true;
46
+ error_fields[ error_fields.length ] = licence_message.email;
47
+ email.addClass('require');
48
+ }
49
+
50
+ if ('' == licence_key_val) {
51
+ error = true;
52
+ error_fields[ error_fields.length ] = licence_message.license_key;
53
+ licence_key.addClass('require');
54
+ }
55
+
56
+ if (false == error) {
57
+ jQuery.ajax({
58
+ type : 'POST',
59
+ url : ajaxurl,
60
+ data : data,
61
+ success: function (response) {
62
+
63
+ spinner.removeClass('show');
64
+ t.add(licence_activation).prop("disabled", false).removeClass('clicked');
65
+
66
+ if (true == response.activated) {
67
+ $('.product-licence-activation').empty().replaceWith(response.template);
68
+ licence_api();
69
+ } else if (false != response) {
70
+ message.text(response.error);
71
+ message_wrapper.addClass('visible');
72
+ product_row.addClass('error');
73
+ } else {
74
+ message.text(licence_message.server);
75
+ message_wrapper.addClass('visible');
76
+ product_row.addClass('error');
77
+ }
78
+ }
79
+ });
80
+ } else {
81
+ if (error_fields.length == 1) {
82
+ message.text(licence_message.error.replace('%field%', error_fields[0]));
83
+ message_wrapper.addClass('visible');
84
+ product_row.addClass('error');
85
+ } else {
86
+ var message_text = licence_message.errors;
87
+ for (var i = 0; i < error_fields.length; i++) {
88
+ message_text = message_text.replace('%field_' + ( i + 1) + '%', error_fields[i]);
89
+ message_wrapper.addClass('visible');
90
+ }
91
+ message.text(message_text);
92
+ message_wrapper.addClass('visible');
93
+ product_row.addClass('error');
94
+ }
95
+
96
+ spinner.removeClass('show');
97
+ t.add(licence_activation).prop("disabled", false).removeClass('clicked');
98
+ }
99
+ });
100
+ };
101
+
102
+ var licence_update = function (button) {
103
+ button.on('click', function (e) {
104
+ e.preventDefault();
105
+
106
+ var t = $(this),
107
+ form = $('#licence-check-update'),
108
+ data = form.serialize();
109
+
110
+ t.prop("disabled", true).addClass('clicked');
111
+ form.find('div.spinner').addClass('show');
112
+
113
+ jQuery.ajax({
114
+ type : 'POST',
115
+ url : ajaxurl,
116
+ data : data,
117
+ success: function (response) {
118
+ $('.product-licence-activation').empty().replaceWith(response.template);
119
+ licence_api();
120
+ }
121
+ });
122
+ });
123
+ };
124
+
125
+ var licence_deactivate = function (button) {
126
+ button.on('click', function (e) {
127
+ e.preventDefault();
128
+
129
+ var check = script_info.is_debug == true ? true : confirm( licence_message.are_you_sure );
130
+
131
+ if( check == true ){
132
+ var t = $(this),
133
+ licence_key = t.data('licence-key'),
134
+ licence_email = t.data('licence-email'),
135
+ product_init = t.data('product-init'),
136
+ action = t.data('action'),
137
+ renew = $('.licence-renew'),
138
+ deactive = $('.licence-deactive'),
139
+ message = $('#yith-licence-notice'),
140
+ activated_table = $('.activated-table');
141
+
142
+ t.add(renew).add(deactive).prop("disabled", true).addClass('clicked');
143
+ $('#activated-products').find('.spinner').addClass('show');
144
+
145
+ jQuery.ajax({
146
+ type : 'POST',
147
+ url : ajaxurl,
148
+ data : {
149
+ action: action,
150
+ licence_key: licence_key,
151
+ email: licence_email,
152
+ product_init: product_init
153
+ },
154
+ success: function (response) {
155
+ message.css( 'maxWidth', activated_table.width() );
156
+ if (false == response.activated && typeof response.error == 'undefined') {
157
+ $('.product-licence-activation').empty().replaceWith(response.template);
158
+ licence_api();
159
+ }
160
+
161
+ if (false == response.activated && typeof response.error != 'undefined') {
162
+ message.find('p.yith-licence-notice-message').html(response.error);
163
+ message.removeClass('notice-success').addClass('notice-error visible');
164
+ t.add(renew).add(deactive).add(renew).prop("disabled", false).removeClass('clicked');
165
+ $('#activated-products').find('.spinner').removeClass('show');
166
+ }
167
+
168
+ else if (false == response) {
169
+ message.find('p.yith-licence-notice-message').html(licence_message.server);
170
+ message.removeClass('notice-success').addClass('notice-error visible');
171
+ t.add(renew).add(deactive).add(renew).prop("disabled", false).removeClass('clicked');
172
+ $('#activated-products').find('.spinner').removeClass('show');
173
+ }
174
+ }
175
+ });
176
+ }
177
+ });
178
+ };
179
+
180
+ var licence_api = function () {
181
+ var button = $('.licence-activation'),
182
+ check = $('.licence-check'),
183
+ deactivated = $('.licence-deactive');
184
+
185
+ licence_activation(button);
186
+ licence_update(check);
187
+ licence_deactivate(deactivated);
188
+ };
189
+
190
+ licence_api();
191
+
192
+ $('body').on('click', '.yit-changelog-button', function (e) {
193
+ $('#TB_window').remove();
194
+ });
195
+
196
  })(jQuery);
plugin-fw/licence/assets/js/yit-licence.min.js CHANGED
@@ -1,7 +1,7 @@
1
- (function(b){var k=function(a){a.on("click",function(v,e){v.preventDefault();var a=b(this),c=a.data("formid"),d=b("#"+c),f=d.serialize(),h=b(d).find(".message"),g=b(d).find(".message-wrapper"),m=d.find(".user-email"),u=d.find(".licence-key"),k=d.find(".user-email").val(),t=d.find(".licence-key").val(),n=!1,c=[],p=d.find(".product-row"),q=b(".licence-activation"),r=b("#products-to-active").find(".spinner");h.empty();g.removeClass("visible");m.removeClass("require");u.removeClass("require");p.removeClass("error");
2
- r.addClass("show");a.add(q).prop("disabled",!0).addClass("clicked");""==k&&(n=!0,c[c.length]=licence_message.email,m.addClass("require"));""==t&&(n=!0,c[c.length]=licence_message.license_key,u.addClass("require"));if(0==n)jQuery.ajax({type:"POST",url:ajaxurl,data:f,success:function(c){r.removeClass("show");a.add(q).prop("disabled",!1).removeClass("clicked");1==c.activated?(b(".product-licence-activation").empty().replaceWith(c.template),l()):(0!=c?h.text(c.error):h.text(licence_message.server),g.addClass("visible"),
3
- p.addClass("error"))}});else{if(1==c.length)h.text(licence_message.error.replace("%field%",c[0]));else{d=licence_message.errors;for(f=0;f<c.length;f++)d=d.replace("%field_"+(f+1)+"%",c[f]),g.addClass("visible");h.text(d)}g.addClass("visible");p.addClass("error");r.removeClass("show");a.add(q).prop("disabled",!1).removeClass("clicked")}})},t=function(a){a.on("click",function(a){a.preventDefault();a=b(this);var e=b("#licence-check-update"),k=e.serialize();a.prop("disabled",!0).addClass("clicked");e.find("div.spinner").addClass("show");
4
- jQuery.ajax({type:"POST",url:ajaxurl,data:k,success:function(c){b(".product-licence-activation").empty().replaceWith(c.template);l()}})})},w=function(a){a.on("click",function(a){a.preventDefault();if(1==(1==script_info.is_debug?!0:confirm(licence_message.are_you_sure))){var e=b(this);a=e.data("licence-key");var k=e.data("licence-email"),c=e.data("product-init"),d=e.data("action"),f=b(".licence-renew"),h=b(".licence-deactive"),g=b("#yith-licence-notice"),m=b(".activated-table");e.add(f).add(h).prop("disabled",
5
- !0).addClass("clicked");b("#activated-products").find(".spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:{action:d,licence_key:a,email:k,product_init:c},success:function(a){g.css("maxWidth",m.width());0==a.activated&&"undefined"==typeof a.error&&(b(".product-licence-activation").empty().replaceWith(a.template),l());0==a.activated&&"undefined"!=typeof a.error?(g.find("p.yith-licence-notice-message").html(a.error),g.removeClass("notice-success").addClass("notice-error visible"),
6
- e.add(f).add(h).add(f).prop("disabled",!1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show")):0==a&&(g.find("p.yith-licence-notice-message").html(licence_message.server),g.removeClass("notice-success").addClass("notice-error visible"),e.add(f).add(h).add(f).prop("disabled",!1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show"))}})}})},l=function(){var a=b(".licence-activation"),l=b(".licence-check"),e=b(".licence-deactive");k(a);
7
  t(l);w(e)};l();b("body").on("click",".yit-changelog-button",function(a){b("#TB_window").remove()})})(jQuery);
1
+ (function(b){var k=function(a){a.on("click",function(v,e){v.preventDefault();var a=b(this),c=a.data("formid"),d=b("#"+c),f=d.serialize(),h=b(d).find(".message"),g=b(d).find(".message-wrapper"),m=d.find(".user-email"),u=d.find(".licence-key"),k=d.find(".user-email").val(),t=d.find(".licence-key").val(),n=!1,c=[],p=d.find(".product-row"),q=b(".licence-activation"),r=b("#products-to-active").find(".spinner");h.empty();g.removeClass("visible");m.removeClass("require");u.removeClass("require");p.removeClass("error");
2
+ r.addClass("show");a.add(q).prop("disabled",!0).addClass("clicked");""==k&&(n=!0,c[c.length]=licence_message.email,m.addClass("require"));""==t&&(n=!0,c[c.length]=licence_message.license_key,u.addClass("require"));if(0==n)jQuery.ajax({type:"POST",url:ajaxurl,data:f,success:function(c){r.removeClass("show");a.add(q).prop("disabled",!1).removeClass("clicked");1==c.activated?(b(".product-licence-activation").empty().replaceWith(c.template),l()):(0!=c?h.text(c.error):h.text(licence_message.server),g.addClass("visible"),
3
+ p.addClass("error"))}});else{if(1==c.length)h.text(licence_message.error.replace("%field%",c[0]));else{d=licence_message.errors;for(f=0;f<c.length;f++)d=d.replace("%field_"+(f+1)+"%",c[f]),g.addClass("visible");h.text(d)}g.addClass("visible");p.addClass("error");r.removeClass("show");a.add(q).prop("disabled",!1).removeClass("clicked")}})},t=function(a){a.on("click",function(a){a.preventDefault();a=b(this);var e=b("#licence-check-update"),k=e.serialize();a.prop("disabled",!0).addClass("clicked");e.find("div.spinner").addClass("show");
4
+ jQuery.ajax({type:"POST",url:ajaxurl,data:k,success:function(c){b(".product-licence-activation").empty().replaceWith(c.template);l()}})})},w=function(a){a.on("click",function(a){a.preventDefault();if(1==(1==script_info.is_debug?!0:confirm(licence_message.are_you_sure))){var e=b(this);a=e.data("licence-key");var k=e.data("licence-email"),c=e.data("product-init"),d=e.data("action"),f=b(".licence-renew"),h=b(".licence-deactive"),g=b("#yith-licence-notice"),m=b(".activated-table");e.add(f).add(h).prop("disabled",
5
+ !0).addClass("clicked");b("#activated-products").find(".spinner").addClass("show");jQuery.ajax({type:"POST",url:ajaxurl,data:{action:d,licence_key:a,email:k,product_init:c},success:function(a){g.css("maxWidth",m.width());0==a.activated&&"undefined"==typeof a.error&&(b(".product-licence-activation").empty().replaceWith(a.template),l());0==a.activated&&"undefined"!=typeof a.error?(g.find("p.yith-licence-notice-message").html(a.error),g.removeClass("notice-success").addClass("notice-error visible"),
6
+ e.add(f).add(h).add(f).prop("disabled",!1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show")):0==a&&(g.find("p.yith-licence-notice-message").html(licence_message.server),g.removeClass("notice-success").addClass("notice-error visible"),e.add(f).add(h).add(f).prop("disabled",!1).removeClass("clicked"),b("#activated-products").find(".spinner").removeClass("show"))}})}})},l=function(){var a=b(".licence-activation"),l=b(".licence-check"),e=b(".licence-deactive");k(a);
7
  t(l);w(e)};l();b("body").on("click",".yit-changelog-button",function(a){b("#TB_window").remove()})})(jQuery);
plugin-fw/licence/lib/yit-licence.php CHANGED
@@ -1,709 +1,709 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( ! class_exists( 'YIT_Licence' ) ) {
16
- /**
17
- * YIT Licence Panel
18
- *
19
- * Setting Page to Manage Products
20
- *
21
- * @class YIT_Licence
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
- */
26
-
27
- abstract class YIT_Licence {
28
-
29
- /**
30
- * @var mixed array The registered products info
31
- * @since 1.0
32
- */
33
- protected $_products = array();
34
-
35
- /**
36
- * @var array The settings require to add the submenu page "Activation"
37
- * @since 1.0
38
- */
39
- protected $_settings = array();
40
-
41
- /**
42
- * @var string Option name
43
- * @since 1.0
44
- */
45
- protected $_licence_option = 'yit_products_licence_activation';
46
-
47
- /**
48
- * @var string The yithemes api uri
49
- * @since 1.0
50
- */
51
- protected $_api_uri = 'http://yithemes.com';
52
-
53
- /**
54
- * @var string The yithemes api uri query args
55
- * @since 1.0
56
- */
57
- protected $_api_uri_query_args = '?wc-api=software-api&request=%request%';
58
-
59
-
60
- /**
61
- * @var string check for show extra info
62
- * @since 1.0
63
- */
64
- public $show_extra_info = false;
65
-
66
- /**
67
- * @var string check for show extra info
68
- * @since 1.0
69
- */
70
- public $show_renew_button = true;
71
-
72
- /**
73
- * Constructor
74
- *
75
- * @since 1.0
76
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
77
- */
78
- public function __construct() {
79
- $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
80
- if ( $is_debug_enabled ) {
81
- $this->_api_uri = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
82
- add_filter( 'block_local_requests', '__return_false' );
83
- }
84
-
85
- /* Style adn Script */
86
- add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
87
- if( $is_debug_enabled ) {
88
- //show extra info and renew button in debug mode
89
- $this->show_extra_info = $this->show_renew_button = true;
90
- }
91
-
92
- else {
93
- $this->show_extra_info = defined( 'YIT_SHOW_EXTRA_LICENCE_INFO' ) && YIT_SHOW_EXTRA_LICENCE_INFO;
94
- $this->show_renew_button = ! ( defined( 'YIT_HIDE_LICENCE_RENEW_BUTTON' ) && YIT_HIDE_LICENCE_RENEW_BUTTON );
95
- }
96
-
97
- /* Update Licence Information */
98
- add_action( 'core_upgrade_preamble', array( $this, 'check_all' ) );
99
- add_action( 'wp_maybe_auto_update', array( $this, 'check_all' ) );
100
-
101
- }
102
-
103
- /**
104
- * Premium products registration
105
- *
106
- * @param $init string | The products identifier
107
- * @param $secret_key string | The secret key
108
- * @param $product_id string | The product id
109
- *
110
- * @return void
111
- *
112
- * @since 1.0
113
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
114
- */
115
- abstract public function register( $init, $secret_key, $product_id );
116
-
117
- /**
118
- * Get protected array products
119
- *
120
- * @return mixed array
121
- *
122
- * @since 1.0
123
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
124
- */
125
- public function get_products() {
126
- return $this->_products;
127
- }
128
-
129
- /**
130
- * Get The home url without protocol
131
- *
132
- * @return string | The home url
133
- *
134
- * @since 1.0
135
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
136
- */
137
- public function get_home_url() {
138
- $home_url = home_url();
139
- $schemes = apply_filters( 'yit_licence_url_schemes', array( 'https://', 'http://' ) );
140
-
141
- foreach( $schemes as $scheme ){
142
- $home_url = str_replace( $scheme, '', $home_url );
143
- }
144
-
145
- return $home_url;
146
- }
147
-
148
- /**
149
- * Check if the request is ajax
150
- *
151
- * @return bool true if the request is ajax, false otherwise
152
- *
153
- * @since 1.0
154
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
155
- */
156
- public function is_ajax() {
157
- return defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
158
- }
159
-
160
- /**
161
- * Admin Enqueue Scripts
162
- *
163
- * @return void
164
- *
165
- * @since 1.0
166
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
167
- */
168
- public function admin_enqueue_scripts(){
169
-
170
- /**
171
- * Support to YIT Framework < 2.0
172
- */
173
- $filename = function_exists( 'yit_load_js_file' ) ? yit_load_js_file( 'yit-licence.js' ) : 'yit-licence.js';
174
- $script_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
175
- $style_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
176
-
177
- wp_enqueue_script( 'yit-licence', $script_path . '/licence/assets/js/' . $filename, array( 'jquery' ), '1.0.0', true );
178
- wp_enqueue_style( 'yit-theme-licence', $style_path . '/licence/assets/css/yit-licence.css' );
179
-
180
- /* Localize Scripts */
181
- wp_localize_script( 'yit-licence', 'licence_message', array(
182
- 'error' => sprintf( _x( '%s field cannot be empty', '%s = field name', 'yith-plugin-fw' ), '%field%' ), // sprintf must be used to avoid errors with '%field%' string in translation in .po file
183
- 'errors' => sprintf( __( '%s and %s fields cannot be empty', 'yith-plugin-fw' ), '%field_1%', '%field_2%' ),
184
- 'server' => __( 'Unable to contact the remote server, please try again later. Thanks!', 'yith-plugin-fw' ),
185
- 'email' => __( 'Email', 'yith-plugin-fw' ),
186
- 'license_key' => __( 'License Key', 'yith-plugin-fw' ),
187
- 'are_you_sure' => __( 'Are you sure you want to deactivate the license for current site?', 'yith-plugin-fw' )
188
- )
189
- );
190
-
191
- wp_localize_script( 'yit-licence', 'script_info', array(
192
- 'is_debug' => defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG
193
- )
194
- );
195
- }
196
-
197
- /**
198
- * Activate Plugins
199
- *
200
- * Send a request to API server to activate plugins
201
- *
202
- * @return void
203
- * @use wp_send_json
204
- *
205
- * @since 1.0
206
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
207
- */
208
- public function activate() {
209
- $product_init = $_REQUEST['product_init'];
210
- $product = $this->get_product( $product_init );
211
-
212
- $args = array(
213
- 'email' => urlencode( sanitize_email( $_REQUEST['email'] ) ),
214
- 'licence_key' => sanitize_text_field( $_REQUEST['licence_key'] ),
215
- 'product_id' => sanitize_text_field( $product['product_id'] ),
216
- 'secret_key' => sanitize_text_field( $product['secret_key'] ),
217
- 'instance' => $this->get_home_url()
218
- );
219
-
220
- $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'activation' ) ) );
221
- $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
222
-
223
- if ( is_wp_error( $response ) ) {
224
- $body = false;
225
- }
226
- else {
227
- $body = json_decode( $response['body'] );
228
- $body = is_object( $body ) ? get_object_vars( $body ) : false;
229
- }
230
-
231
- if ( $body && is_array( $body ) && isset( $body['activated'] ) && $body['activated'] ) {
232
-
233
- $option[$product['product_id']] = array(
234
- 'email' => urldecode( $args['email'] ),
235
- 'licence_key' => $args['licence_key'],
236
- 'licence_expires' => $body['licence_expires'],
237
- 'message' => $body['message'],
238
- 'activated' => true,
239
- 'activation_limit' => $body['activation_limit'],
240
- 'activation_remaining' => $body['activation_remaining'],
241
- 'is_membership' => isset( $body['is_membership'] ) ? $body['is_membership'] : false,
242
- );
243
-
244
- /* === Check for other plugins activation === */
245
- $options = $this->get_licence();
246
- $options[$product['product_id']] = $option[$product['product_id']];
247
-
248
- update_option( $this->_licence_option, $options );
249
-
250
- /* === Update Plugin Licence Information === */
251
- YIT_Upgrade()->force_regenerate_update_transient();
252
-
253
- /* === Licence Activation Template === */
254
- $body['template'] = $this->show_activation_panel( $this->get_response_code_message( 200 ) );
255
- }
256
-
257
- wp_send_json( $body );
258
- }
259
-
260
- /**
261
- * Deactivate Plugins
262
- *
263
- * Send a request to API server to activate plugins
264
- *
265
- * @return void
266
- * @use wp_send_json
267
- *
268
- * @since 1.0
269
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
270
- */
271
- public function deactivate() {
272
- $product_init = $_REQUEST['product_init'];
273
- $product = $this->get_product( $product_init );
274
-
275
- $args = array(
276
- 'email' => urlencode( sanitize_email( $_REQUEST['email'] ) ),
277
- 'licence_key' => sanitize_text_field( $_REQUEST['licence_key'] ),
278
- 'product_id' => sanitize_text_field( $product['product_id'] ),
279
- 'secret_key' => sanitize_text_field( $product['secret_key'] ),
280
- 'instance' => $this->get_home_url()
281
- );
282
-
283
- $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'deactivation' ) ) );
284
- $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
285
-
286
- if ( is_wp_error( $response ) ) {
287
- $body = false;
288
- }
289
- else {
290
- $body = json_decode( $response['body'] );
291
- $body = is_object( $body ) ? get_object_vars( $body ) : false;
292
- }
293
-
294
- if ( $body && is_array( $body ) && isset( $body['activated'] ) && ! $body['activated'] && ! isset( $body['error'] ) ) {
295
-
296
- $option[$product['product_id']] = array(
297
- 'activated' => false,
298
- 'email' => urldecode( $args['email'] ),
299
- 'licence_key' => $args['licence_key'],
300
- 'licence_expires' => $body['licence_expires'],
301
- 'message' => $body['message'],
302
- 'activation_limit' => $body['activation_limit'],
303
- 'activation_remaining' => $body['activation_remaining'],
304
- 'is_membership' => isset( $body['is_membership'] ) ? $body['is_membership'] : false,
305
- );
306
-
307
- /* === Check for other plugins activation === */
308
- $options = $this->get_licence();
309
- $options[$product['product_id']] = $option[$product['product_id']];
310
-
311
- update_option( $this->_licence_option, $options );
312
-
313
- /* === Update Plugin Licence Information === */
314
- YIT_Upgrade()->force_regenerate_update_transient();
315
-
316
- /* === Licence Activation Template === */
317
- $body['template'] = $this->show_activation_panel( $this->get_response_code_message( 'deactivated', array( 'instance' => $body['instance'] ) ) );
318
- }
319
-
320
- else {
321
- $body['error'] = $this->get_response_code_message( $body['code'] );
322
- }
323
-
324
- wp_send_json( $body );
325
- }
326
-
327
- /**
328
- * Check Plugins Licence
329
- *
330
- * Send a request to API server to check if plugins is activated
331
- *
332
- * @param string|The plugin init slug $plugin_init
333
- *
334
- * @return bool | true if activated, false otherwise
335
- *
336
- * @since 1.0
337
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
338
- */
339
- public function check( $product_init, $regenerate_transient = true ) {
340
-
341
- $status = false;
342
- $body = false;
343
- $product = $this->get_product( $product_init );
344
- $licence = $this->get_licence();
345
- $product_id = $product['product_id'];
346
-
347
- if( ! isset( $licence[ $product_id ] ) ) {
348
- return false;
349
- }
350
-
351
- $args = array(
352
- 'email' => urlencode( $licence[$product_id]['email'] ),
353
- 'licence_key' => $licence[$product_id]['licence_key'],
354
- 'product_id' => $product_id,
355
- 'secret_key' => $product['secret_key'],
356
- 'instance' => $this->get_home_url()
357
- );
358
-
359
- $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'check' ) ) );
360
- $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
361
-
362
- if ( ! is_wp_error( $response ) ) {
363
- $body = json_decode( $response['body'] );
364
- $body = is_object( $body ) ? get_object_vars( $body ) : false;
365
- }
366
-
367
- if ( $body && is_array( $body ) && isset( $body['success'] ) ) {
368
- if ( $body['success'] ) {
369
-
370
- /**
371
- * Code 200 -> Licence key is valid
372
- */
373
- $licence[ $product_id ]['status_code'] = '200';
374
- $licence[ $product_id ]['activated'] = $body['activated'];
375
- $licence[ $product_id ]['licence_expires'] = $body['licence_expires'];
376
- $licence[ $product_id ]['activation_remaining'] = $body['activation_remaining'];
377
- $licence[ $product_id ]['activation_limit'] = $body['activation_limit'];
378
- $licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
379
- $status = (bool) $body['activated'];
380
- }
381
- elseif ( isset( $body['code'] ) ) {
382
-
383
- switch ( $body['code'] ) {
384
-
385
- /**
386
- * Error Code List:
387
- *
388
- * 100 -> Invalid Request
389
- * 101 -> Invalid licence key
390
- * 102 -> Software has been deactivate
391
- * 103 -> Exceeded maximum number of activations
392
- * 104 -> Invalid instance ID
393
- * 105 -> Invalid security key
394
- * 106 -> Licence key has expired
395
- * 107 -> Licence key has be banned
396
- *
397
- * Only code 101, 106 and 107 have effect on DB during activation
398
- * All error code have effect on DB during deactivation
399
- *
400
- */
401
-
402
- case '101':
403
- case '102':
404
- unset( $licence[ $product_id ] );
405
- break;
406
-
407
- case '106':
408
- $licence[ $product_id ]['activated'] = false;
409
- $licence[ $product_id ]['message'] = $body['error'];
410
- $licence[ $product_id ]['status_code'] = $body['code'];
411
- $licence[ $product_id ]['licence_expires'] = $body['licence_expires'];
412
- //$licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
413
- break;
414
-
415
- case '107':
416
- $licence[ $product_id ]['activated'] = false;
417
- $licence[ $product_id ]['message'] = $body['error'];
418
- $licence[ $product_id ]['status_code'] = $body['code'];
419
- //$licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
420
- break;
421
- }
422
- }
423
-
424
- /* === Update Plugin Licence Information === */
425
- update_option( $this->_licence_option, $licence );
426
-
427
- /* === Update Plugin Licence Information === */
428
- if( $regenerate_transient ) {
429
- YIT_Upgrade()->force_regenerate_update_transient();
430
- }
431
- }
432
- return $status;
433
- }
434
-
435
- /**
436
- * Check for licence update
437
- *
438
- * @return void
439
- * @since 2.5
440
- *
441
- * @use YIT_Theme_Licence->check()
442
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
443
- */
444
- public function check_all(){
445
- foreach ( $this->_products as $init => $info ) {
446
- $this->check( $init );
447
- }
448
- }
449
-
450
- /**
451
- * Update Plugins Information
452
- *
453
- * Send a request to API server to check activate plugins and update the informations
454
- *
455
- * @return void
456
- * @use YIT_Theme_Licence->check()
457
- *
458
- * @since 1.0
459
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
460
- */
461
- public function update_licence_information() {
462
- /* Check licence information for alla products */
463
- $this->check_all();
464
-
465
- /* === Regenerate Update Plugins Transient === */
466
- YIT_Upgrade()->force_regenerate_update_transient();
467
-
468
- do_action( 'yit_licence_after_check' );
469
-
470
- if( $this->is_ajax() ) {
471
- $response['template'] = $this->show_activation_panel();
472
- wp_send_json( $response );
473
- }
474
- }
475
-
476
- /**
477
- * Include activation page template
478
- *
479
- * @return mixed void | string the contents of the output buffer and end output buffering.
480
- *
481
- * @since 1.0
482
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
483
- */
484
- public function show_activation_panel( $notice = '' ) {
485
-
486
- $path = defined( 'YIT_CORE_PLUGIN_PATH' ) ? YIT_CORE_PLUGIN_PATH : get_template_directory() . '/core/plugin-fw/';
487
-
488
- if ( $this->is_ajax() ) {
489
- ob_start();
490
- require_once( $path . '/licence/templates/panel/activation/activation-panel.php' );
491
- return ob_get_clean();
492
- }
493
- else {
494
- require_once( $path . '/licence/templates/panel/activation/activation-panel.php' );
495
- }
496
- }
497
-
498
- /**
499
- * Get activated products
500
- *
501
- * @return array
502
- *
503
- * @since 1.0
504
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
505
- */
506
- public function get_activated_products() {
507
- $activated_products = array();
508
- $licence = $this->get_licence();
509
-
510
- if ( is_array( $licence ) ) {
511
- foreach ( $this->_products as $init => $info ) {
512
- if ( in_array( $info['product_id'], array_keys( $licence ) ) && isset( $licence[$info['product_id']]['activated'] ) && $licence[$info['product_id']]['activated'] ) {
513
- $product[$init] = $this->_products[$init];
514
- $product[$init]['licence'] = $licence[$info['product_id']];
515
- $activated_products[$init] = $product[$init];
516
- }
517
- }
518
- }
519
-
520
- return $activated_products;
521
- }
522
-
523
- /**
524
- * Get to active products
525
- *
526
- * @return array
527
- *
528
- * @since 1.0
529
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
530
- */
531
- public function get_to_active_products() {
532
- return array_diff_key( $this->get_products(), $this->get_activated_products() );
533
- }
534
-
535
- /**
536
- * Get no active products
537
- *
538
- * @return array
539
- *
540
- * @since 1.0
541
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
542
- */
543
- public function get_no_active_licence_key() {
544
- $unactive_products = $this->get_to_active_products();
545
- $licence = $this->get_licence();
546
- $licence_key = array();
547
-
548
- /**
549
- * Remove banned licence key
550
- */
551
- foreach ( $unactive_products as $init => $info ) {
552
- $product_id = $unactive_products[$init]['product_id'];
553
- if ( isset( $licence[$product_id]['activated'] ) && ! $licence[$product_id]['activated'] && isset( $licence[$product_id]['status_code'] ) ) {
554
- $status_code = $licence[$product_id]['status_code'];
555
-
556
- switch ( $status_code ) {
557
- case '106':
558
- $licence_key[$status_code][$init] = $unactive_products[$init];
559
- $licence_key[$status_code][$init]['licence'] = $licence[$product_id];
560
- break;
561
-
562
- case '107':
563
- $licence_key[$status_code][$init] = $unactive_products[$init];
564
- $licence_key[$status_code][$init]['licence'] = $licence[$product_id];
565
- break;
566
- }
567
- }
568
- }
569
- return $licence_key;
570
- }
571
-
572
- /**
573
- * Get a specific product information
574
- *
575
- * @param $product_init | product init file
576
- *
577
- * @return mixed array
578
- *
579
- * @since 1.0
580
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
581
- */
582
- public function get_product( $init ) {
583
- return isset( $this->_products[$init] ) ? $this->_products[$init] : false;
584
- }
585
-
586
- /**
587
- * Get product product id information
588
- *
589
- * @param $product_init | product init file
590
- *
591
- * @return mixed array
592
- *
593
- * @since 1.0
594
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
595
- */
596
- public function get_product_id( $init ) {
597
- return isset( $this->_products[$init]['product_id'] ) ? $this->_products[$init]['product_id'] : false;
598
- }
599
-
600
- /**
601
- * Get Renewing uri
602
- *
603
- * @param $licence_key The licence key to renew
604
- *
605
- * @return mixed The renewing uri if licence_key exists, false otherwise
606
- *
607
- * @since 1.0
608
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
609
- */
610
- public function get_renewing_uri( $licence_key ) {
611
- return ! empty( $licence_key ) ? str_replace( 'www.', '', $this->_api_uri ) . '?renewing_key=' . $licence_key : false;
612
- }
613
-
614
- /**
615
- * Get protected yithemes api uri
616
- *
617
- * @param $request
618
- *
619
- * @return mixed array
620
- *
621
- * @since 1.0
622
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
623
- */
624
- public function get_api_uri( $request ) {
625
- return str_replace( '%request%', $request, $this->_api_uri . $this->_api_uri_query_args );
626
- }
627
-
628
- /**
629
- * Get the activation page url
630
- *
631
- * @return String | Activation page url
632
- *
633
- * @since 1.0
634
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
635
- */
636
- public function get_licence_activation_page_url() {
637
- return esc_url( add_query_arg( array( 'page' => $this->_settings['page'] ), admin_url( 'admin.php' ) ) );
638
- }
639
-
640
-
641
- /**
642
- * Get the licence information
643
- *
644
- * @return array | licence array
645
- *
646
- * @since 1.0
647
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
648
- */
649
- public function get_licence() {
650
- return get_option( $this->_licence_option );
651
- }
652
-
653
- /**
654
- * Get the licence information
655
- *
656
- * @param $code string The error code
657
- *
658
- * @return string | Error code message
659
- *
660
- * @since 1.0
661
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
662
- */
663
- public function get_response_code_message( $code, $args = array() ) {
664
- extract( $args );
665
-
666
- $messages = array(
667
- '100' => __( 'Invalid Request', 'yith-plugin-fw' ),
668
- '101' => __( 'Invalid license key', 'yith-plugin-fw' ),
669
- '102' => __( 'Software has been deactivated', 'yith-plugin-fw' ),
670
- '103' => __( 'Maximum number of activations exceeded', 'yith-plugin-fw' ),
671
- '104' => __( 'Invalid instance ID', 'yith-plugin-fw' ),
672
- '105' => __( 'Invalid security key', 'yith-plugin-fw' ),
673
- '106' => __( 'License key has expired', 'yith-plugin-fw' ),
674
- '107' => __( 'License key has been banned', 'yith-plugin-fw' ),
675
- '108' => __( 'Current product is not included with your membership key', 'woocommerce-software-add-on' ),
676
- '200' => sprintf( '<strong>%s</strong>! %s',__( 'Great', 'yith-plugin-fw' ), __( 'License successfully activated', 'yith-plugin-fw' ) ),
677
- 'deactivated' => sprintf( '%s <strong>%s</strong>', __( 'License key deactivated for website', 'woocommerce-software-add-on' ), isset( $instance ) ? $instance : '' )
678
- );
679
-
680
- return isset( $messages[$code] ) ? $messages[$code] : false;
681
- }
682
-
683
- /**
684
- * Get the product name to display
685
- *
686
- * @param $product_name
687
- *
688
- * @return string the product name
689
- *
690
- * @since 2.2
691
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
692
- */
693
- public function display_product_name( $product_name ){
694
- return str_replace( array( 'YITH', 'WooCommerce', 'Premium', 'Theme' ), '', $product_name );
695
- }
696
-
697
- public function get_number_of_membership_products(){
698
- $activated_products = $this->get_activated_products();
699
- $num_members_products_activate = 0;
700
- foreach( $activated_products as $activated_product ){
701
- if( isset( $activated_product['licence']['is_membership'] ) && $activated_product['licence']['is_membership'] ){
702
- $num_members_products_activate++;
703
- }
704
- }
705
- return $num_members_products_activate;
706
- }
707
-
708
- }
709
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( ! class_exists( 'YIT_Licence' ) ) {
16
+ /**
17
+ * YIT Licence Panel
18
+ *
19
+ * Setting Page to Manage Products
20
+ *
21
+ * @class YIT_Licence
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ */
26
+
27
+ abstract class YIT_Licence {
28
+
29
+ /**
30
+ * @var mixed array The registered products info
31
+ * @since 1.0
32
+ */
33
+ protected $_products = array();
34
+
35
+ /**
36
+ * @var array The settings require to add the submenu page "Activation"
37
+ * @since 1.0
38
+ */
39
+ protected $_settings = array();
40
+
41
+ /**
42
+ * @var string Option name
43
+ * @since 1.0
44
+ */
45
+ protected $_licence_option = 'yit_products_licence_activation';
46
+
47
+ /**
48
+ * @var string The yithemes api uri
49
+ * @since 1.0
50
+ */
51
+ protected $_api_uri = 'http://yithemes.com';
52
+
53
+ /**
54
+ * @var string The yithemes api uri query args
55
+ * @since 1.0
56
+ */
57
+ protected $_api_uri_query_args = '?wc-api=software-api&request=%request%';
58
+
59
+
60
+ /**
61
+ * @var string check for show extra info
62
+ * @since 1.0
63
+ */
64
+ public $show_extra_info = false;
65
+
66
+ /**
67
+ * @var string check for show extra info
68
+ * @since 1.0
69
+ */
70
+ public $show_renew_button = true;
71
+
72
+ /**
73
+ * Constructor
74
+ *
75
+ * @since 1.0
76
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
77
+ */
78
+ public function __construct() {
79
+ $is_debug_enabled = defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG;
80
+ if ( $is_debug_enabled ) {
81
+ $this->_api_uri = defined( 'YIT_LICENCE_DEBUG_LOCALHOST' ) ? YIT_LICENCE_DEBUG_LOCALHOST : 'http://dev.yithemes.com';
82
+ add_filter( 'block_local_requests', '__return_false' );
83
+ }
84
+
85
+ /* Style adn Script */
86
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
87
+ if( $is_debug_enabled ) {
88
+ //show extra info and renew button in debug mode
89
+ $this->show_extra_info = $this->show_renew_button = true;
90
+ }
91
+
92
+ else {
93
+ $this->show_extra_info = defined( 'YIT_SHOW_EXTRA_LICENCE_INFO' ) && YIT_SHOW_EXTRA_LICENCE_INFO;
94
+ $this->show_renew_button = ! ( defined( 'YIT_HIDE_LICENCE_RENEW_BUTTON' ) && YIT_HIDE_LICENCE_RENEW_BUTTON );
95
+ }
96
+
97
+ /* Update Licence Information */
98
+ add_action( 'core_upgrade_preamble', array( $this, 'check_all' ) );
99
+ add_action( 'wp_maybe_auto_update', array( $this, 'check_all' ) );
100
+
101
+ }
102
+
103
+ /**
104
+ * Premium products registration
105
+ *
106
+ * @param $init string | The products identifier
107
+ * @param $secret_key string | The secret key
108
+ * @param $product_id string | The product id
109
+ *
110
+ * @return void
111
+ *
112
+ * @since 1.0
113
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
114
+ */
115
+ abstract public function register( $init, $secret_key, $product_id );
116
+
117
+ /**
118
+ * Get protected array products
119
+ *
120
+ * @return mixed array
121
+ *
122
+ * @since 1.0
123
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
124
+ */
125
+ public function get_products() {
126
+ return $this->_products;
127
+ }
128
+
129
+ /**
130
+ * Get The home url without protocol
131
+ *
132
+ * @return string | The home url
133
+ *
134
+ * @since 1.0
135
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
136
+ */
137
+ public function get_home_url() {
138
+ $home_url = home_url();
139
+ $schemes = apply_filters( 'yit_licence_url_schemes', array( 'https://', 'http://' ) );
140
+
141
+ foreach( $schemes as $scheme ){
142
+ $home_url = str_replace( $scheme, '', $home_url );
143
+ }
144
+
145
+ return $home_url;
146
+ }
147
+
148
+ /**
149
+ * Check if the request is ajax
150
+ *
151
+ * @return bool true if the request is ajax, false otherwise
152
+ *
153
+ * @since 1.0
154
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
155
+ */
156
+ public function is_ajax() {
157
+ return defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
158
+ }
159
+
160
+ /**
161
+ * Admin Enqueue Scripts
162
+ *
163
+ * @return void
164
+ *
165
+ * @since 1.0
166
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
167
+ */
168
+ public function admin_enqueue_scripts(){
169
+
170
+ /**
171
+ * Support to YIT Framework < 2.0
172
+ */
173
+ $filename = function_exists( 'yit_load_js_file' ) ? yit_load_js_file( 'yit-licence.js' ) : 'yit-licence.js';
174
+ $script_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
175
+ $style_path = defined( 'YIT_CORE_PLUGIN_URL' ) ? YIT_CORE_PLUGIN_URL : get_template_directory_uri() . '/core/plugin-fw';
176
+
177
+ wp_enqueue_script( 'yit-licence', $script_path . '/licence/assets/js/' . $filename, array( 'jquery' ), '1.0.0', true );
178
+ wp_enqueue_style( 'yit-theme-licence', $style_path . '/licence/assets/css/yit-licence.css' );
179
+
180
+ /* Localize Scripts */
181
+ wp_localize_script( 'yit-licence', 'licence_message', array(
182
+ 'error' => sprintf( _x( '%s field cannot be empty', '%s = field name', 'yith-plugin-fw' ), '%field%' ), // sprintf must be used to avoid errors with '%field%' string in translation in .po file
183
+ 'errors' => sprintf( __( '%s and %s fields cannot be empty', 'yith-plugin-fw' ), '%field_1%', '%field_2%' ),
184
+ 'server' => __( 'Unable to contact the remote server, please try again later. Thanks!', 'yith-plugin-fw' ),
185
+ 'email' => __( 'Email', 'yith-plugin-fw' ),
186
+ 'license_key' => __( 'License Key', 'yith-plugin-fw' ),
187
+ 'are_you_sure' => __( 'Are you sure you want to deactivate the license for current site?', 'yith-plugin-fw' )
188
+ )
189
+ );
190
+
191
+ wp_localize_script( 'yit-licence', 'script_info', array(
192
+ 'is_debug' => defined( 'YIT_LICENCE_DEBUG' ) && YIT_LICENCE_DEBUG
193
+ )
194
+ );
195
+ }
196
+
197
+ /**
198
+ * Activate Plugins
199
+ *
200
+ * Send a request to API server to activate plugins
201
+ *
202
+ * @return void
203
+ * @use wp_send_json
204
+ *
205
+ * @since 1.0
206
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
207
+ */
208
+ public function activate() {
209
+ $product_init = $_REQUEST['product_init'];
210
+ $product = $this->get_product( $product_init );
211
+
212
+ $args = array(
213
+ 'email' => urlencode( sanitize_email( $_REQUEST['email'] ) ),
214
+ 'licence_key' => sanitize_text_field( $_REQUEST['licence_key'] ),
215
+ 'product_id' => sanitize_text_field( $product['product_id'] ),
216
+ 'secret_key' => sanitize_text_field( $product['secret_key'] ),
217
+ 'instance' => $this->get_home_url()
218
+ );
219
+
220
+ $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'activation' ) ) );
221
+ $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
222
+
223
+ if ( is_wp_error( $response ) ) {
224
+ $body = false;
225
+ }
226
+ else {
227
+ $body = json_decode( $response['body'] );
228
+ $body = is_object( $body ) ? get_object_vars( $body ) : false;
229
+ }
230
+
231
+ if ( $body && is_array( $body ) && isset( $body['activated'] ) && $body['activated'] ) {
232
+
233
+ $option[$product['product_id']] = array(
234
+ 'email' => urldecode( $args['email'] ),
235
+ 'licence_key' => $args['licence_key'],
236
+ 'licence_expires' => $body['licence_expires'],
237
+ 'message' => $body['message'],
238
+ 'activated' => true,
239
+ 'activation_limit' => $body['activation_limit'],
240
+ 'activation_remaining' => $body['activation_remaining'],
241
+ 'is_membership' => isset( $body['is_membership'] ) ? $body['is_membership'] : false,
242
+ );
243
+
244
+ /* === Check for other plugins activation === */
245
+ $options = $this->get_licence();
246
+ $options[$product['product_id']] = $option[$product['product_id']];
247
+
248
+ update_option( $this->_licence_option, $options );
249
+
250
+ /* === Update Plugin Licence Information === */
251
+ YIT_Upgrade()->force_regenerate_update_transient();
252
+
253
+ /* === Licence Activation Template === */
254
+ $body['template'] = $this->show_activation_panel( $this->get_response_code_message( 200 ) );
255
+ }
256
+
257
+ wp_send_json( $body );
258
+ }
259
+
260
+ /**
261
+ * Deactivate Plugins
262
+ *
263
+ * Send a request to API server to activate plugins
264
+ *
265
+ * @return void
266
+ * @use wp_send_json
267
+ *
268
+ * @since 1.0
269
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
270
+ */
271
+ public function deactivate() {
272
+ $product_init = $_REQUEST['product_init'];
273
+ $product = $this->get_product( $product_init );
274
+
275
+ $args = array(
276
+ 'email' => urlencode( sanitize_email( $_REQUEST['email'] ) ),
277
+ 'licence_key' => sanitize_text_field( $_REQUEST['licence_key'] ),
278
+ 'product_id' => sanitize_text_field( $product['product_id'] ),
279
+ 'secret_key' => sanitize_text_field( $product['secret_key'] ),
280
+ 'instance' => $this->get_home_url()
281
+ );
282
+
283
+ $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'deactivation' ) ) );
284
+ $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
285
+
286
+ if ( is_wp_error( $response ) ) {
287
+ $body = false;
288
+ }
289
+ else {
290
+ $body = json_decode( $response['body'] );
291
+ $body = is_object( $body ) ? get_object_vars( $body ) : false;
292
+ }
293
+
294
+ if ( $body && is_array( $body ) && isset( $body['activated'] ) && ! $body['activated'] && ! isset( $body['error'] ) ) {
295
+
296
+ $option[$product['product_id']] = array(
297
+ 'activated' => false,
298
+ 'email' => urldecode( $args['email'] ),
299
+ 'licence_key' => $args['licence_key'],
300
+ 'licence_expires' => $body['licence_expires'],
301
+ 'message' => $body['message'],
302
+ 'activation_limit' => $body['activation_limit'],
303
+ 'activation_remaining' => $body['activation_remaining'],
304
+ 'is_membership' => isset( $body['is_membership'] ) ? $body['is_membership'] : false,
305
+ );
306
+
307
+ /* === Check for other plugins activation === */
308
+ $options = $this->get_licence();
309
+ $options[$product['product_id']] = $option[$product['product_id']];
310
+
311
+ update_option( $this->_licence_option, $options );
312
+
313
+ /* === Update Plugin Licence Information === */
314
+ YIT_Upgrade()->force_regenerate_update_transient();
315
+
316
+ /* === Licence Activation Template === */
317
+ $body['template'] = $this->show_activation_panel( $this->get_response_code_message( 'deactivated', array( 'instance' => $body['instance'] ) ) );
318
+ }
319
+
320
+ else {
321
+ $body['error'] = $this->get_response_code_message( $body['code'] );
322
+ }
323
+
324
+ wp_send_json( $body );
325
+ }
326
+
327
+ /**
328
+ * Check Plugins Licence
329
+ *
330
+ * Send a request to API server to check if plugins is activated
331
+ *
332
+ * @param string|The plugin init slug $plugin_init
333
+ *
334
+ * @return bool | true if activated, false otherwise
335
+ *
336
+ * @since 1.0
337
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
338
+ */
339
+ public function check( $product_init, $regenerate_transient = true ) {
340
+
341
+ $status = false;
342
+ $body = false;
343
+ $product = $this->get_product( $product_init );
344
+ $licence = $this->get_licence();
345
+ $product_id = $product['product_id'];
346
+
347
+ if( ! isset( $licence[ $product_id ] ) ) {
348
+ return false;
349
+ }
350
+
351
+ $args = array(
352
+ 'email' => urlencode( $licence[$product_id]['email'] ),
353
+ 'licence_key' => $licence[$product_id]['licence_key'],
354
+ 'product_id' => $product_id,
355
+ 'secret_key' => $product['secret_key'],
356
+ 'instance' => $this->get_home_url()
357
+ );
358
+
359
+ $api_uri = esc_url_raw( add_query_arg( $args, $this->get_api_uri( 'check' ) ) );
360
+ $response = wp_remote_get( $api_uri, array( 'timeout' => 30 ) );
361
+
362
+ if ( ! is_wp_error( $response ) ) {
363
+ $body = json_decode( $response['body'] );
364
+ $body = is_object( $body ) ? get_object_vars( $body ) : false;
365
+ }
366
+
367
+ if ( $body && is_array( $body ) && isset( $body['success'] ) ) {
368
+ if ( $body['success'] ) {
369
+
370
+ /**
371
+ * Code 200 -> Licence key is valid
372
+ */
373
+ $licence[ $product_id ]['status_code'] = '200';
374
+ $licence[ $product_id ]['activated'] = $body['activated'];
375
+ $licence[ $product_id ]['licence_expires'] = $body['licence_expires'];
376
+ $licence[ $product_id ]['activation_remaining'] = $body['activation_remaining'];
377
+ $licence[ $product_id ]['activation_limit'] = $body['activation_limit'];
378
+ $licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
379
+ $status = (bool) $body['activated'];
380
+ }
381
+ elseif ( isset( $body['code'] ) ) {
382
+
383
+ switch ( $body['code'] ) {
384
+
385
+ /**
386
+ * Error Code List:
387
+ *
388
+ * 100 -> Invalid Request
389
+ * 101 -> Invalid licence key
390
+ * 102 -> Software has been deactivate
391
+ * 103 -> Exceeded maximum number of activations
392
+ * 104 -> Invalid instance ID
393
+ * 105 -> Invalid security key
394
+ * 106 -> Licence key has expired
395
+ * 107 -> Licence key has be banned
396
+ *
397
+ * Only code 101, 106 and 107 have effect on DB during activation
398
+ * All error code have effect on DB during deactivation
399
+ *
400
+ */
401
+
402
+ case '101':
403
+ case '102':
404
+ unset( $licence[ $product_id ] );
405
+ break;
406
+
407
+ case '106':
408
+ $licence[ $product_id ]['activated'] = false;
409
+ $licence[ $product_id ]['message'] = $body['error'];
410
+ $licence[ $product_id ]['status_code'] = $body['code'];
411
+ $licence[ $product_id ]['licence_expires'] = $body['licence_expires'];
412
+ //$licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
413
+ break;
414
+
415
+ case '107':
416
+ $licence[ $product_id ]['activated'] = false;
417
+ $licence[ $product_id ]['message'] = $body['error'];
418
+ $licence[ $product_id ]['status_code'] = $body['code'];
419
+ //$licence[ $product_id ]['is_membership'] = isset( $body['is_membership'] ) ? $body['is_membership'] : false;
420
+ break;
421
+ }
422
+ }
423
+
424
+ /* === Update Plugin Licence Information === */
425
+ update_option( $this->_licence_option, $licence );
426
+
427
+ /* === Update Plugin Licence Information === */
428
+ if( $regenerate_transient ) {
429
+ YIT_Upgrade()->force_regenerate_update_transient();
430
+ }
431
+ }
432
+ return $status;
433
+ }
434
+
435
+ /**
436
+ * Check for licence update
437
+ *
438
+ * @return void
439
+ * @since 2.5
440
+ *
441
+ * @use YIT_Theme_Licence->check()
442
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
443
+ */
444
+ public function check_all(){
445
+ foreach ( $this->_products as $init => $info ) {
446
+ $this->check( $init );
447
+ }
448
+ }
449
+
450
+ /**
451
+ * Update Plugins Information
452
+ *
453
+ * Send a request to API server to check activate plugins and update the informations
454
+ *
455
+ * @return void
456
+ * @use YIT_Theme_Licence->check()
457
+ *
458
+ * @since 1.0
459
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
460
+ */
461
+ public function update_licence_information() {
462
+ /* Check licence information for alla products */
463
+ $this->check_all();
464
+
465
+ /* === Regenerate Update Plugins Transient === */
466
+ YIT_Upgrade()->force_regenerate_update_transient();
467
+
468
+ do_action( 'yit_licence_after_check' );
469
+
470
+ if( $this->is_ajax() ) {
471
+ $response['template'] = $this->show_activation_panel();
472
+ wp_send_json( $response );
473
+ }
474
+ }
475
+
476
+ /**
477
+ * Include activation page template
478
+ *
479
+ * @return mixed void | string the contents of the output buffer and end output buffering.
480
+ *
481
+ * @since 1.0
482
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
483
+ */
484
+ public function show_activation_panel( $notice = '' ) {
485
+
486
+ $path = defined( 'YIT_CORE_PLUGIN_PATH' ) ? YIT_CORE_PLUGIN_PATH : get_template_directory() . '/core/plugin-fw/';
487
+
488
+ if ( $this->is_ajax() ) {
489
+ ob_start();
490
+ require_once( $path . '/licence/templates/panel/activation/activation-panel.php' );
491
+ return ob_get_clean();
492
+ }
493
+ else {
494
+ require_once( $path . '/licence/templates/panel/activation/activation-panel.php' );
495
+ }
496
+ }
497
+
498
+ /**
499
+ * Get activated products
500
+ *
501
+ * @return array
502
+ *
503
+ * @since 1.0
504
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
505
+ */
506
+ public function get_activated_products() {
507
+ $activated_products = array();
508
+ $licence = $this->get_licence();
509
+
510
+ if ( is_array( $licence ) ) {
511
+ foreach ( $this->_products as $init => $info ) {
512
+ if ( in_array( $info['product_id'], array_keys( $licence ) ) && isset( $licence[$info['product_id']]['activated'] ) && $licence[$info['product_id']]['activated'] ) {
513
+ $product[$init] = $this->_products[$init];
514
+ $product[$init]['licence'] = $licence[$info['product_id']];
515
+ $activated_products[$init] = $product[$init];
516
+ }
517
+ }
518
+ }
519
+
520
+ return $activated_products;
521
+ }
522
+
523
+ /**
524
+ * Get to active products
525
+ *
526
+ * @return array
527
+ *
528
+ * @since 1.0
529
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
530
+ */
531
+ public function get_to_active_products() {
532
+ return array_diff_key( $this->get_products(), $this->get_activated_products() );
533
+ }
534
+
535
+ /**
536
+ * Get no active products
537
+ *
538
+ * @return array
539
+ *
540
+ * @since 1.0
541
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
542
+ */
543
+ public function get_no_active_licence_key() {
544
+ $unactive_products = $this->get_to_active_products();
545
+ $licence = $this->get_licence();
546
+ $licence_key = array();
547
+
548
+ /**
549
+ * Remove banned licence key
550
+ */
551
+ foreach ( $unactive_products as $init => $info ) {
552
+ $product_id = $unactive_products[$init]['product_id'];
553
+ if ( isset( $licence[$product_id]['activated'] ) && ! $licence[$product_id]['activated'] && isset( $licence[$product_id]['status_code'] ) ) {
554
+ $status_code = $licence[$product_id]['status_code'];
555
+
556
+ switch ( $status_code ) {
557
+ case '106':
558
+ $licence_key[$status_code][$init] = $unactive_products[$init];
559
+ $licence_key[$status_code][$init]['licence'] = $licence[$product_id];
560
+ break;
561
+
562
+ case '107':
563
+ $licence_key[$status_code][$init] = $unactive_products[$init];
564
+ $licence_key[$status_code][$init]['licence'] = $licence[$product_id];
565
+ break;
566
+ }
567
+ }
568
+ }
569
+ return $licence_key;
570
+ }
571
+
572
+ /**
573
+ * Get a specific product information
574
+ *
575
+ * @param $product_init | product init file
576
+ *
577
+ * @return mixed array
578
+ *
579
+ * @since 1.0
580
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
581
+ */
582
+ public function get_product( $init ) {
583
+ return isset( $this->_products[$init] ) ? $this->_products[$init] : false;
584
+ }
585
+
586
+ /**
587
+ * Get product product id information
588
+ *
589
+ * @param $product_init | product init file
590
+ *
591
+ * @return mixed array
592
+ *
593
+ * @since 1.0
594
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
595
+ */
596
+ public function get_product_id( $init ) {
597
+ return isset( $this->_products[$init]['product_id'] ) ? $this->_products[$init]['product_id'] : false;
598
+ }
599
+
600
+ /**
601
+ * Get Renewing uri
602
+ *
603
+ * @param $licence_key The licence key to renew
604
+ *
605
+ * @return mixed The renewing uri if licence_key exists, false otherwise
606
+ *
607
+ * @since 1.0
608
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
609
+ */
610
+ public function get_renewing_uri( $licence_key ) {
611
+ return ! empty( $licence_key ) ? str_replace( 'www.', '', $this->_api_uri ) . '?renewing_key=' . $licence_key : false;
612
+ }
613
+
614
+ /**
615
+ * Get protected yithemes api uri
616
+ *
617
+ * @param $request
618
+ *
619
+ * @return mixed array
620
+ *
621
+ * @since 1.0
622
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
623
+ */
624
+ public function get_api_uri( $request ) {
625
+ return str_replace( '%request%', $request, $this->_api_uri . $this->_api_uri_query_args );
626
+ }
627
+
628
+ /**
629
+ * Get the activation page url
630
+ *
631
+ * @return String | Activation page url
632
+ *
633
+ * @since 1.0
634
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
635
+ */
636
+ public function get_licence_activation_page_url() {
637
+ return esc_url( add_query_arg( array( 'page' => $this->_settings['page'] ), admin_url( 'admin.php' ) ) );
638
+ }
639
+
640
+
641
+ /**
642
+ * Get the licence information
643
+ *
644
+ * @return array | licence array
645
+ *
646
+ * @since 1.0
647
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
648
+ */
649
+ public function get_licence() {
650
+ return get_option( $this->_licence_option );
651
+ }
652
+
653
+ /**
654
+ * Get the licence information
655
+ *
656
+ * @param $code string The error code
657
+ *
658
+ * @return string | Error code message
659
+ *
660
+ * @since 1.0
661
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
662
+ */
663
+ public function get_response_code_message( $code, $args = array() ) {
664
+ extract( $args );
665
+
666
+ $messages = array(
667
+ '100' => __( 'Invalid Request', 'yith-plugin-fw' ),
668
+ '101' => __( 'Invalid license key', 'yith-plugin-fw' ),
669
+ '102' => __( 'Software has been deactivated', 'yith-plugin-fw' ),
670
+ '103' => __( 'Maximum number of activations exceeded', 'yith-plugin-fw' ),
671
+ '104' => __( 'Invalid instance ID', 'yith-plugin-fw' ),
672
+ '105' => __( 'Invalid security key', 'yith-plugin-fw' ),
673
+ '106' => __( 'License key has expired', 'yith-plugin-fw' ),
674
+ '107' => __( 'License key has been banned', 'yith-plugin-fw' ),
675
+ '108' => __( 'Current product is not included with your membership key', 'woocommerce-software-add-on' ),
676
+ '200' => sprintf( '<strong>%s</strong>! %s',__( 'Great', 'yith-plugin-fw' ), __( 'License successfully activated', 'yith-plugin-fw' ) ),
677
+ 'deactivated' => sprintf( '%s <strong>%s</strong>', __( 'License key deactivated for website', 'woocommerce-software-add-on' ), isset( $instance ) ? $instance : '' )
678
+ );
679
+
680
+ return isset( $messages[$code] ) ? $messages[$code] : false;
681
+ }
682
+
683
+ /**
684
+ * Get the product name to display
685
+ *
686
+ * @param $product_name
687
+ *
688
+ * @return string the product name
689
+ *
690
+ * @since 2.2
691
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
692
+ */
693
+ public function display_product_name( $product_name ){
694
+ return str_replace( array( 'YITH', 'WooCommerce', 'Premium', 'Theme' ), '', $product_name );
695
+ }
696
+
697
+ public function get_number_of_membership_products(){
698
+ $activated_products = $this->get_activated_products();
699
+ $num_members_products_activate = 0;
700
+ foreach( $activated_products as $activated_product ){
701
+ if( isset( $activated_product['licence']['is_membership'] ) && $activated_product['licence']['is_membership'] ){
702
+ $num_members_products_activate++;
703
+ }
704
+ }
705
+ return $num_members_products_activate;
706
+ }
707
+
708
+ }
709
  }
plugin-fw/licence/lib/yit-plugin-licence.php CHANGED
@@ -1,161 +1,161 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( !defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( !class_exists( 'YIT_Plugin_Licence' ) ) {
16
- /**
17
- * YIT Plugin Licence Panel
18
- *
19
- * Setting Page to Manage Plugins
20
- *
21
- * @class YIT_Plugin_Licence
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
- */
26
- class YIT_Plugin_Licence extends YIT_Licence {
27
-
28
- /**
29
- * @var array The settings require to add the submenu page "Activation"
30
- * @since 1.0
31
- */
32
- protected $_settings = array();
33
-
34
- /**
35
- * @var object The single instance of the class
36
- * @since 1.0
37
- */
38
- protected static $_instance = null;
39
-
40
- /**
41
- * @var string Option name
42
- * @since 1.0
43
- */
44
- protected $_licence_option = 'yit_plugin_licence_activation';
45
-
46
- /**
47
- * @var string product type
48
- * @since 1.0
49
- */
50
- protected $_product_type = 'plugin';
51
-
52
- /**
53
- * Constructor
54
- *
55
- * @since 1.0
56
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
57
- */
58
- public function __construct() {
59
- parent::__construct();
60
-
61
- if ( !is_admin() ) {
62
- return;
63
- }
64
-
65
- $this->_settings = array(
66
- 'parent_page' => 'yit_plugin_panel',
67
- 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
68
- 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
69
- 'capability' => 'manage_options',
70
- 'page' => 'yith_plugins_activation',
71
- );
72
-
73
- add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
74
- add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
75
- add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
76
- add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
77
- add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
78
- }
79
-
80
-
81
- public function licence_after_check() {
82
- /* === Regenerate Update Plugins Transient === */
83
- YIT_Upgrade()->force_regenerate_update_transient();
84
- }
85
-
86
- /**
87
- * Main plugin Instance
88
- *
89
- * @static
90
- * @return object Main instance
91
- *
92
- * @since 1.0
93
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
94
- */
95
- public static function instance() {
96
- if ( is_null( self::$_instance ) ) {
97
- self::$_instance = new self();
98
- }
99
-
100
- return self::$_instance;
101
- }
102
-
103
- /**
104
- * Add "Activation" submenu page under YITH Plugins
105
- *
106
- * @return void
107
- * @since 1.0
108
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
109
- */
110
- public function add_submenu_page() {
111
- add_submenu_page(
112
- $this->_settings['parent_page'],
113
- $this->_settings['page_title'],
114
- $this->_settings['menu_title'],
115
- $this->_settings['capability'],
116
- $this->_settings['page'],
117
- array( $this, 'show_activation_panel' )
118
- );
119
- }
120
-
121
- /**
122
- * Premium plugin registration
123
- *
124
- * @param $plugin_init | string | The plugin init file
125
- * @param $secret_key | string | The product secret key
126
- * @param $product_id | string | The plugin slug (product_id)
127
- *
128
- * @return void
129
- *
130
- * @since 1.0
131
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
132
- */
133
- public function register( $plugin_init, $secret_key, $product_id ) {
134
- if ( !function_exists( 'get_plugins' ) ) {
135
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
- }
137
-
138
- $plugins = get_plugins();
139
- $plugins[$plugin_init]['secret_key'] = $secret_key;
140
- $plugins[$plugin_init]['product_id'] = $product_id;
141
- $this->_products[$plugin_init] = $plugins[$plugin_init];
142
- }
143
-
144
- public function get_product_type() {
145
- return $this->_product_type;
146
- }
147
- }
148
- }
149
-
150
- /**
151
- * Main instance of plugin
152
- *
153
- * @return object
154
- * @since 1.0
155
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
156
- */
157
- if ( !function_exists( 'YIT_Plugin_Licence' ) ) {
158
- function YIT_Plugin_Licence() {
159
- return YIT_Plugin_Licence::instance();
160
- }
161
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( !class_exists( 'YIT_Plugin_Licence' ) ) {
16
+ /**
17
+ * YIT Plugin Licence Panel
18
+ *
19
+ * Setting Page to Manage Plugins
20
+ *
21
+ * @class YIT_Plugin_Licence
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ */
26
+ class YIT_Plugin_Licence extends YIT_Licence {
27
+
28
+ /**
29
+ * @var array The settings require to add the submenu page "Activation"
30
+ * @since 1.0
31
+ */
32
+ protected $_settings = array();
33
+
34
+ /**
35
+ * @var object The single instance of the class
36
+ * @since 1.0
37
+ */
38
+ protected static $_instance = null;
39
+
40
+ /**
41
+ * @var string Option name
42
+ * @since 1.0
43
+ */
44
+ protected $_licence_option = 'yit_plugin_licence_activation';
45
+
46
+ /**
47
+ * @var string product type
48
+ * @since 1.0
49
+ */
50
+ protected $_product_type = 'plugin';
51
+
52
+ /**
53
+ * Constructor
54
+ *
55
+ * @since 1.0
56
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
57
+ */
58
+ public function __construct() {
59
+ parent::__construct();
60
+
61
+ if ( !is_admin() ) {
62
+ return;
63
+ }
64
+
65
+ $this->_settings = array(
66
+ 'parent_page' => 'yit_plugin_panel',
67
+ 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
68
+ 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
69
+ 'capability' => 'manage_options',
70
+ 'page' => 'yith_plugins_activation',
71
+ );
72
+
73
+ add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
74
+ add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
75
+ add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
76
+ add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
77
+ add_action( 'yit_licence_after_check', array( $this, 'licence_after_check' ) );
78
+ }
79
+
80
+
81
+ public function licence_after_check() {
82
+ /* === Regenerate Update Plugins Transient === */
83
+ YIT_Upgrade()->force_regenerate_update_transient();
84
+ }
85
+
86
+ /**
87
+ * Main plugin Instance
88
+ *
89
+ * @static
90
+ * @return object Main instance
91
+ *
92
+ * @since 1.0
93
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
94
+ */
95
+ public static function instance() {
96
+ if ( is_null( self::$_instance ) ) {
97
+ self::$_instance = new self();
98
+ }
99
+
100
+ return self::$_instance;
101
+ }
102
+
103
+ /**
104
+ * Add "Activation" submenu page under YITH Plugins
105
+ *
106
+ * @return void
107
+ * @since 1.0
108
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
109
+ */
110
+ public function add_submenu_page() {
111
+ add_submenu_page(
112
+ $this->_settings['parent_page'],
113
+ $this->_settings['page_title'],
114
+ $this->_settings['menu_title'],
115
+ $this->_settings['capability'],
116
+ $this->_settings['page'],
117
+ array( $this, 'show_activation_panel' )
118
+ );
119
+ }
120
+
121
+ /**
122
+ * Premium plugin registration
123
+ *
124
+ * @param $plugin_init | string | The plugin init file
125
+ * @param $secret_key | string | The product secret key
126
+ * @param $product_id | string | The plugin slug (product_id)
127
+ *
128
+ * @return void
129
+ *
130
+ * @since 1.0
131
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
132
+ */
133
+ public function register( $plugin_init, $secret_key, $product_id ) {
134
+ if ( !function_exists( 'get_plugins' ) ) {
135
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
136
+ }
137
+
138
+ $plugins = get_plugins();
139
+ $plugins[$plugin_init]['secret_key'] = $secret_key;
140
+ $plugins[$plugin_init]['product_id'] = $product_id;
141
+ $this->_products[$plugin_init] = $plugins[$plugin_init];
142
+ }
143
+
144
+ public function get_product_type() {
145
+ return $this->_product_type;
146
+ }
147
+ }
148
+ }
149
+
150
+ /**
151
+ * Main instance of plugin
152
+ *
153
+ * @return object
154
+ * @since 1.0
155
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
156
+ */
157
+ if ( !function_exists( 'YIT_Plugin_Licence' ) ) {
158
+ function YIT_Plugin_Licence() {
159
+ return YIT_Plugin_Licence::instance();
160
+ }
161
  }
plugin-fw/licence/lib/yit-theme-licence.php CHANGED
@@ -1,191 +1,191 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( !defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- if ( !class_exists( 'YIT_Theme_Licence' ) ) {
16
- /**
17
- * YIT Plugin Licence Panel
18
- *
19
- * Setting Page to Manage Plugins
20
- *
21
- * @class YIT_Theme_Licence
22
- * @package Yithemes
23
- * @since 1.0
24
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
- */
26
- class YIT_Theme_Licence extends YIT_Licence {
27
-
28
- /**
29
- * @var array The settings require to add the submenu page "Activation"
30
- * @since 1.0
31
- */
32
- protected $_settings = array();
33
-
34
- /**
35
- * @var object The single instance of the class
36
- * @since 1.0
37
- */
38
- protected static $_instance = null;
39
-
40
- /**
41
- * @var string Option name
42
- * @since 1.0
43
- */
44
- protected $_licence_option = 'yit_theme_licence_activation';
45
-
46
- /**
47
- * @var string product type
48
- * @since 1.0
49
- */
50
- protected $_product_type = 'theme';
51
-
52
- /**
53
- * @var string Old theme licence works until 28 January 2016
54
- * @since 1.0
55
- */
56
- protected $_old_licence_expires = 1453939200; //28 January 2016
57
-
58
- /**
59
- * Constructor
60
- *
61
- * @since 1.0
62
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
63
- */
64
- public function __construct() {
65
- parent::__construct();
66
-
67
- $this->_settings = array(
68
- 'parent_page' => 'yit_product_panel',
69
- 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
70
- 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
71
- 'capability' => 'manage_options',
72
- 'page' => 'yith_plugins_activation',
73
- );
74
-
75
- add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
76
- add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
77
- add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
78
- add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
79
- }
80
-
81
- /**
82
- * Main plugin Instance
83
- *
84
- * @static
85
- * @return object Main instance
86
- *
87
- * @since 1.0
88
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
89
- */
90
- public static function instance() {
91
- if ( is_null( self::$_instance ) ) {
92
- self::$_instance = new self();
93
- }
94
-
95
- return self::$_instance;
96
- }
97
-
98
- /**
99
- * Add "Activation" submenu page under YITH Plugins
100
- *
101
- * @return void
102
- * @since 1.0
103
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
104
- */
105
- public function add_submenu_page() {
106
-
107
- $admin_tree = array(
108
- 'parent_slug' => apply_filters( 'yit_licence_parent_slug', 'yit_panel' ),
109
- 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
110
- 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
111
- 'capability' => 'manage_options',
112
- 'menu_slug' => 'yit_panel_license',
113
- 'function' => 'show_activation_panel'
114
- );
115
-
116
- add_submenu_page( $admin_tree['parent_slug'],
117
- sprintf( __( '%s', 'yith-plugin-fw' ), $admin_tree['page_title'] ),
118
- sprintf( __( '%s', 'yith-plugin-fw' ), $admin_tree['menu_title'] ),
119
- $admin_tree['capability'],
120
- $admin_tree['menu_slug'],
121
- array( $this, $admin_tree['function'] )
122
- );
123
- }
124
-
125
- /**
126
- * Premium product registration
127
- *
128
- * @param $product_init | string | The product init file
129
- * @param $secret_key | string | The product secret key
130
- * @param $product_id | string | The product slug (product_id)
131
- *
132
- * @return void
133
- *
134
- * @since 1.0
135
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
136
- */
137
- public function register( $product_init, $secret_key, $product_id ) {
138
- $theme = wp_get_theme();
139
- $products[$product_init]['Name'] = $theme->Name;
140
- $products[$product_init]['secret_key'] = $secret_key;
141
- $products[$product_init]['product_id'] = $product_id;
142
- $this->_products[$product_init] = $products[$product_init];
143
- }
144
-
145
- /**
146
- * Check for old licence
147
- *
148
- * @return bool True for old licence period, false otherwise
149
- * @since 2.2
150
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
151
- */
152
- public function show_old_licence_message() {
153
- return time() < $this->_old_licence_expires;
154
- }
155
-
156
- public function get_old_licence_message() {
157
- ob_start(); ?>
158
- <div class="activation-faq">
159
- <h3><?php _e( 'I cannot find the license key for activating the theme I have bought some time ago. Where can I find it?', 'yith-plugin-fw' ) ?></h3>
160
-
161
- <p>
162
- <?php
163
- _e( 'If you have purchased one of our products before 27 January 2015, you can benefit from support and updates (the services offered with the license)
164
- until 27 January 2016 and you do not have to purchase it again to get a new license key, because, before this date, your license used to be activated automatically by our system.
165
- After 27 January 2016, instead, if you want to benefit from support and updates you have to buy a new license and activate it through the license key you will be
166
- provided with and that you can find in your YIThemes account, in section "My licenses".', 'yith-plugin-fw' )
167
- ?>
168
- </p>
169
- </div>
170
- <?php
171
- echo ob_get_clean();
172
- }
173
-
174
- public function get_product_type() {
175
- return $this->_product_type;
176
- }
177
- }
178
- }
179
-
180
- /**
181
- * Main instance
182
- *
183
- * @return object
184
- * @since 1.0
185
- * @author Andrea Grillo <andrea.grillo@yithemes.com>
186
- */
187
- if ( !function_exists( 'YIT_Theme_Licence' ) ) {
188
- function YIT_Theme_Licence() {
189
- return YIT_Theme_Licence::instance();
190
- }
191
  }
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( !defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ if ( !class_exists( 'YIT_Theme_Licence' ) ) {
16
+ /**
17
+ * YIT Plugin Licence Panel
18
+ *
19
+ * Setting Page to Manage Plugins
20
+ *
21
+ * @class YIT_Theme_Licence
22
+ * @package Yithemes
23
+ * @since 1.0
24
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
25
+ */
26
+ class YIT_Theme_Licence extends YIT_Licence {
27
+
28
+ /**
29
+ * @var array The settings require to add the submenu page "Activation"
30
+ * @since 1.0
31
+ */
32
+ protected $_settings = array();
33
+
34
+ /**
35
+ * @var object The single instance of the class
36
+ * @since 1.0
37
+ */
38
+ protected static $_instance = null;
39
+
40
+ /**
41
+ * @var string Option name
42
+ * @since 1.0
43
+ */
44
+ protected $_licence_option = 'yit_theme_licence_activation';
45
+
46
+ /**
47
+ * @var string product type
48
+ * @since 1.0
49
+ */
50
+ protected $_product_type = 'theme';
51
+
52
+ /**
53
+ * @var string Old theme licence works until 28 January 2016
54
+ * @since 1.0
55
+ */
56
+ protected $_old_licence_expires = 1453939200; //28 January 2016
57
+
58
+ /**
59
+ * Constructor
60
+ *
61
+ * @since 1.0
62
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
63
+ */
64
+ public function __construct() {
65
+ parent::__construct();
66
+
67
+ $this->_settings = array(
68
+ 'parent_page' => 'yit_product_panel',
69
+ 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
70
+ 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
71
+ 'capability' => 'manage_options',
72
+ 'page' => 'yith_plugins_activation',
73
+ );
74
+
75
+ add_action( 'admin_menu', array( $this, 'add_submenu_page' ), 99 );
76
+ add_action( "wp_ajax_activate-{$this->_product_type}", array( $this, 'activate' ) );
77
+ add_action( "wp_ajax_deactivate-{$this->_product_type}", array( $this, 'deactivate' ) );
78
+ add_action( "wp_ajax_update_licence_information-{$this->_product_type}", array( $this, 'update_licence_information' ) );
79
+ }
80
+
81
+ /**
82
+ * Main plugin Instance
83
+ *
84
+ * @static
85
+ * @return object Main instance
86
+ *
87
+ * @since 1.0
88
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
89
+ */
90
+ public static function instance() {
91
+ if ( is_null( self::$_instance ) ) {
92
+ self::$_instance = new self();
93
+ }
94
+
95
+ return self::$_instance;
96
+ }
97
+
98
+ /**
99
+ * Add "Activation" submenu page under YITH Plugins
100
+ *
101
+ * @return void
102
+ * @since 1.0
103
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
104
+ */
105
+ public function add_submenu_page() {
106
+
107
+ $admin_tree = array(
108
+ 'parent_slug' => apply_filters( 'yit_licence_parent_slug', 'yit_panel' ),
109
+ 'page_title' => __( 'License Activation', 'yith-plugin-fw' ),
110
+ 'menu_title' => __( 'License Activation', 'yith-plugin-fw' ),
111
+ 'capability' => 'manage_options',
112
+ 'menu_slug' => 'yit_panel_license',
113
+ 'function' => 'show_activation_panel'
114
+ );
115
+
116
+ add_submenu_page( $admin_tree['parent_slug'],
117
+ sprintf( __( '%s', 'yith-plugin-fw' ), $admin_tree['page_title'] ),
118
+ sprintf( __( '%s', 'yith-plugin-fw' ), $admin_tree['menu_title'] ),
119
+ $admin_tree['capability'],
120
+ $admin_tree['menu_slug'],
121
+ array( $this, $admin_tree['function'] )
122
+ );
123
+ }
124
+
125
+ /**
126
+ * Premium product registration
127
+ *
128
+ * @param $product_init | string | The product init file
129
+ * @param $secret_key | string | The product secret key
130
+ * @param $product_id | string | The product slug (product_id)
131
+ *
132
+ * @return void
133
+ *
134
+ * @since 1.0
135
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
136
+ */
137
+ public function register( $product_init, $secret_key, $product_id ) {
138
+ $theme = wp_get_theme();
139
+ $products[$product_init]['Name'] = $theme->Name;
140
+ $products[$product_init]['secret_key'] = $secret_key;
141
+ $products[$product_init]['product_id'] = $product_id;
142
+ $this->_products[$product_init] = $products[$product_init];
143
+ }
144
+
145
+ /**
146
+ * Check for old licence
147
+ *
148
+ * @return bool True for old licence period, false otherwise
149
+ * @since 2.2
150
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
151
+ */
152
+ public function show_old_licence_message() {
153
+ return time() < $this->_old_licence_expires;
154
+ }
155
+
156
+ public function get_old_licence_message() {
157
+ ob_start(); ?>
158
+ <div class="activation-faq">
159
+ <h3><?php _e( 'I cannot find the license key for activating the theme I have bought some time ago. Where can I find it?', 'yith-plugin-fw' ) ?></h3>
160
+
161
+ <p>
162
+ <?php
163
+ _e( 'If you have purchased one of our products before 27 January 2015, you can benefit from support and updates (the services offered with the license)
164
+ until 27 January 2016 and you do not have to purchase it again to get a new license key, because, before this date, your license used to be activated automatically by our system.
165
+ After 27 January 2016, instead, if you want to benefit from support and updates you have to buy a new license and activate it through the license key you will be
166
+ provided with and that you can find in your YIThemes account, in section "My licenses".', 'yith-plugin-fw' )
167
+ ?>
168
+ </p>
169
+ </div>
170
+ <?php
171
+ echo ob_get_clean();
172
+ }
173
+
174
+ public function get_product_type() {
175
+ return $this->_product_type;
176
+ }
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Main instance
182
+ *
183
+ * @return object
184
+ * @since 1.0
185
+ * @author Andrea Grillo <andrea.grillo@yithemes.com>
186
+ */
187
+ if ( !function_exists( 'YIT_Theme_Licence' ) ) {
188
+ function YIT_Theme_Licence() {
189
+ return YIT_Theme_Licence::instance();
190
+ }
191
  }
plugin-fw/licence/templates/panel/activation/activation-panel.php CHANGED
@@ -1,238 +1,238 @@
1
- <?php
2
- /*
3
- * This file belongs to the YIT Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- $to_active_products = $this->get_to_active_products();
12
- $activated_products = $this->get_activated_products();
13
- $no_active_products = $this->get_no_active_licence_key();
14
- $expired_products = isset( $no_active_products[ '106' ] ) ? $no_active_products[ '106' ] : array();
15
- $banned_products = isset( $no_active_products[ '107' ] ) ? $no_active_products[ '107' ] : array();
16
- $notice = isset( $notice ) ? $notice : '';
17
- $notice_class = ! empty( $notice ) ? 'notice notice-success visible' : 'notice notice-success';
18
- $to_activate_check = $this instanceof YIT_Theme_Licence ? 1 : 2;
19
- $num_members_products_activate = $this->get_number_of_membership_products();
20
- ?>
21
-
22
- <div class="yit-container product-licence-activation">
23
- <h2><?php _e( 'Yithemes License Activation', 'yith-plugin-fw' ) ?></h2>
24
-
25
- <div class="licence-check-section">
26
- <form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
27
- <span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
28
- <input type="hidden" name="action" value="update_licence_information-<?php echo $this->get_product_type(); ?>" />
29
- <input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
30
- <div class="spinner"></div>
31
- </form>
32
- </div>
33
-
34
- <div id="yith-licence-notice" class="<?php echo $notice_class ?>">
35
- <p class="yith-licence-notice-message"><?php echo $notice ?></p>
36
- </div>
37
-
38
- <!-- To Active Products -->
39
-
40
- <?php if( ! empty( $to_active_products ) ) : ?>
41
- <h3 id="products-to-active" class="to-active">
42
- <?php echo _n( 'Product to activate', 'Products to activate', $to_activate_check, 'yith-plugin-fw' ) ?>
43
- <span class="spinner"></span>
44
- </h3>
45
- <div class="to-active-wrapper">
46
- <?php foreach( $to_active_products as $init => $info ) : ?>
47
- <form class="to-active-form" method="post" id="<?php echo $info['product_id'] ?>" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
48
- <table class="to-active-table">
49
- <tbody>
50
- <tr class="product-row">
51
- <td class="product-name">
52
- <?php echo $this->display_product_name( $info['Name'] ) ?>
53
- </td>
54
- <td>
55
- <input type="email" name="email" placeholder="Your email on Yithemes.com" value="" class="user-email" />
56
- </td>
57
- <td>
58
- <input type="text" name="licence_key" placeholder="License Key" value="" class="licence-key" />
59
- </td>
60
- <td class="activate-button">
61
- <input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
62
- </td>
63
- </tr>
64
- <input type="hidden" name="action" value="activate-<?php echo $this->get_product_type(); ?>" />
65
- <input type="hidden" name="product_init" value="<?php echo $init ?>" />
66
- </tbody>
67
- </table>
68
- <div class="message-wrapper">
69
- <span class="message arrow-left"></span>
70
- </div>
71
- </form>
72
- <?php endforeach; ?>
73
- </div>
74
- <?php endif; ?>
75
-
76
- <!-- Activated Products -->
77
-
78
- <?php if( ! empty( $activated_products ) ) : ?>
79
- <h3 id="activated-products">
80
- <?php _e( 'Activated', 'yith-plugin-fw' ) ?>
81
- <span class="spinner"></span>
82
- </h3>
83
- <table class="activated-table">
84
- <thead>
85
- <tr>
86
- <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
87
- <?php if( $this->show_extra_info ) : ?>
88
- <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
89
- <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
90
- <?php endif; ?>
91
-
92
- <th><?php _e( 'Expires', 'yith-plugin-fw' ) ?></th>
93
-
94
- <?php if( $this->show_extra_info ) : ?>
95
- <th><?php _e( 'Remaining', 'yith-plugin-fw' ) ?></th>
96
- <?php if( $num_members_products_activate ) : ?>
97
- <th><?php _e( 'Membership', 'yith-plugin-fw' ) ?></th>
98
- <?php endif; ?>
99
- <?php endif; ?>
100
-
101
- <th><?php _e( 'License Actions', 'yith-plugin-fw' ) ?></th>
102
- </tr>
103
- </thead>
104
- <tbody>
105
- <?php foreach( $activated_products as $init => $info ) : ?>
106
- <tr>
107
- <td class="product-name">
108
- <?php echo $this->display_product_name( $info['Name'] ) ?>
109
- </td>
110
-
111
- <?php if( $this->show_extra_info ) : ?>
112
- <td class="product-licence-email">
113
- <?php echo $info['licence']['email'] ?>
114
- </td>
115
- <td class="product-licence-key">
116
- <?php echo $info['licence']['licence_key'] ?>
117
- </td>
118
- <?php endif; ?>
119
-
120
- <td class="product-licence-expires">
121
- <?php echo date("F j, Y", $info['licence']['licence_expires'] ); ?>
122
- </td>
123
-
124
- <?php if( $this->show_extra_info ) : ?>
125
- <td class="product-licence-remaining">
126
- <?php printf( __( '%1s out of %2s', 'yith-plugin-fw' ), $info['licence']['activation_remaining'], $info['licence']['activation_limit'] ); ?>
127
- </td>
128
- <?php if( $num_members_products_activate ) : ?>
129
- <td class="product-licence-membership">
130
- <span class="dashicons dashicons-<?php echo $info['licence']['is_membership'] ? 'yes' : 'no-alt' ?>"></span>
131
- </td>
132
- <?php endif; ?>
133
- <?php endif; ?>
134
-
135
- <td>
136
- <a class="button-licence licence-deactive"
137
- href="#"
138
- data-licence-email="<?php echo $info['licence']['email'] ?>"
139
- data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
140
- data-product-init="<?php echo $init ?>"
141
- data-action="deactivate-<?php echo $this->get_product_type(); ?>">
142
- <?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
143
- </a>
144
-
145
- <?php if( ! $info['licence']['is_membership'] && $this->show_renew_button ) : ?>
146
- <a class="button-licence licence-renew" href="<?php echo $this->get_renewing_uri( $info['licence']['licence_key'] ) ?>" target="_blank">
147
- <?php _e( 'Renew', 'yith-plugin-fw' ) ?>
148
- </a>
149
- <?php endif; ?>
150
- </td>
151
- </tr>
152
- <?php endforeach; ?>
153
- </tbody>
154
- </table>
155
- <?php endif;?>
156
-
157
- <!-- Banned Products -->
158
-
159
- <?php if( ! empty( $banned_products ) ) : ?>
160
- <h3><?php _e( 'Banned', 'yith-plugin-fw' ) ?></h3>
161
- <table class="expired-table">
162
- <thead>
163
- <tr>
164
- <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
165
- <?php if( $this->show_extra_info ) : ?>
166
- <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
167
- <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
168
- <?php endif; ?>
169
- </tr>
170
- </thead>
171
- <tbody>
172
- <?php foreach( $banned_products as $init => $info ) : ?>
173
- <tr>
174
- <td class="product-name">
175
- <?php echo $this->display_product_name( $info['Name'] ) ?>
176
- </td>
177
- <?php if( $this->show_extra_info ) : ?>
178
- <td class="product-licence-email"><?php echo $info['licence']['email'] ?></td>
179
- <td class="product-licence-key"><?php echo $info['licence']['licence_key'] ?></td>
180
- <?php endif; ?>
181
- </tr>
182
- <?php endforeach; ?>
183
- </tbody>
184
- </table>
185
- <?php endif;?>
186
-
187
- <!-- Expired Products -->
188
-
189
- <?php if( ! empty( $expired_products ) ) : ?>
190
- <h3><?php _e( 'Expired', 'yith-plugin-fw' ) ?></h3>
191
- <table class="expired-table">
192
- <thead>
193
- <tr>
194
- <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
195
-
196
- <?php if( $this->show_extra_info ) : ?>
197
- <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
198
- <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
199
- <?php endif; ?>
200
-
201
- <th><?php _e( 'Expires', 'yith-plugin-fw' ) ?></th>
202
-
203
- <?php if( $this->show_renew_button ) : ?>
204
- <th><?php _e( 'Renew', 'yith-plugin-fw' ) ?></th>
205
- <?php endif; ?>
206
- </tr>
207
- </thead>
208
- <tbody>
209
- <?php foreach( $expired_products as $init => $info ) : ?>
210
- <tr>
211
- <td class="product-name">
212
- <?php echo $this->display_product_name( $info['Name'] ) ?>
213
- </td>
214
-
215
- <?php if( $this->show_extra_info ) : ?>
216
- <td class="product-licence-email"><?php echo $info['licence']['email'] ?></td>
217
- <td class="product-licence-key"><?php echo $info['licence']['licence_key'] ?></td>
218
- <?php endif; ?>
219
-
220
- <td class="product-licence-expires"><?php echo date("F j, Y", $info['licence']['licence_expires'] ); ?></td>
221
-
222
- <?php if( $this->show_renew_button ) : ?>
223
- <td>
224
- <a class="button-licence licence-renew" href="<?php echo $this->get_renewing_uri( $info['licence']['licence_key'] ) ?>" target="_blank">
225
- <?php if( $info['licence']['is_membership'] ) : ?>
226
- <?php _e( 'Order again', 'yith-plugin-fw' ) ?>
227
- <?php else : ?>
228
- <?php __( 'Renew license', 'yith-plugin-fw' ) ?>
229
- <?php endif; ?>
230
- </a>
231
- </td>
232
- <?php endif; ?>
233
- </tr>
234
- <?php endforeach; ?>
235
- </tbody>
236
- </table>
237
- <?php endif;?>
238
  </div>
1
+ <?php
2
+ /*
3
+ * This file belongs to the YIT Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ $to_active_products = $this->get_to_active_products();
12
+ $activated_products = $this->get_activated_products();
13
+ $no_active_products = $this->get_no_active_licence_key();
14
+ $expired_products = isset( $no_active_products[ '106' ] ) ? $no_active_products[ '106' ] : array();
15
+ $banned_products = isset( $no_active_products[ '107' ] ) ? $no_active_products[ '107' ] : array();
16
+ $notice = isset( $notice ) ? $notice : '';
17
+ $notice_class = ! empty( $notice ) ? 'notice notice-success visible' : 'notice notice-success';
18
+ $to_activate_check = $this instanceof YIT_Theme_Licence ? 1 : 2;
19
+ $num_members_products_activate = $this->get_number_of_membership_products();
20
+ ?>
21
+
22
+ <div class="yit-container product-licence-activation">
23
+ <h2><?php _e( 'Yithemes License Activation', 'yith-plugin-fw' ) ?></h2>
24
+
25
+ <div class="licence-check-section">
26
+ <form method="post" id="licence-check-update" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
27
+ <span class="licence-label" style="display: block;"><?php _e( 'Have you updated your licenses? Have you asked for an extension? Update information concerning your products.', 'yith-plugin-fw' ); ?></span>
28
+ <input type="hidden" name="action" value="update_licence_information-<?php echo $this->get_product_type(); ?>" />
29
+ <input type="submit" name="submit" value="<?php _e( 'Update license information', 'yith-plugin-fw' ) ?>" class="button-licence licence-check" />
30
+ <div class="spinner"></div>
31
+ </form>
32
+ </div>
33
+
34
+ <div id="yith-licence-notice" class="<?php echo $notice_class ?>">
35
+ <p class="yith-licence-notice-message"><?php echo $notice ?></p>
36
+ </div>
37
+
38
+ <!-- To Active Products -->
39
+
40
+ <?php if( ! empty( $to_active_products ) ) : ?>
41
+ <h3 id="products-to-active" class="to-active">
42
+ <?php echo _n( 'Product to activate', 'Products to activate', $to_activate_check, 'yith-plugin-fw' ) ?>
43
+ <span class="spinner"></span>
44
+ </h3>
45
+ <div class="to-active-wrapper">
46
+ <?php foreach( $to_active_products as $init => $info ) : ?>
47
+ <form class="to-active-form" method="post" id="<?php echo $info['product_id'] ?>" action="<?php echo admin_url( 'admin-ajax.php' ) ?>">
48
+ <table class="to-active-table">
49
+ <tbody>
50
+ <tr class="product-row">
51
+ <td class="product-name">
52
+ <?php echo $this->display_product_name( $info['Name'] ) ?>
53
+ </td>
54
+ <td>
55
+ <input type="email" name="email" placeholder="Your email on Yithemes.com" value="" class="user-email" />
56
+ </td>
57
+ <td>
58
+ <input type="text" name="licence_key" placeholder="License Key" value="" class="licence-key" />
59
+ </td>
60
+ <td class="activate-button">
61
+ <input type="submit" name="submit" value="<?php _e( 'Activate', 'yith-plugin-fw' )?>" class="button-licence licence-activation" data-formid="<?php echo $info['product_id'] ?>"/>
62
+ </td>
63
+ </tr>
64
+ <input type="hidden" name="action" value="activate-<?php echo $this->get_product_type(); ?>" />
65
+ <input type="hidden" name="product_init" value="<?php echo $init ?>" />
66
+ </tbody>
67
+ </table>
68
+ <div class="message-wrapper">
69
+ <span class="message arrow-left"></span>
70
+ </div>
71
+ </form>
72
+ <?php endforeach; ?>
73
+ </div>
74
+ <?php endif; ?>
75
+
76
+ <!-- Activated Products -->
77
+
78
+ <?php if( ! empty( $activated_products ) ) : ?>
79
+ <h3 id="activated-products">
80
+ <?php _e( 'Activated', 'yith-plugin-fw' ) ?>
81
+ <span class="spinner"></span>
82
+ </h3>
83
+ <table class="activated-table">
84
+ <thead>
85
+ <tr>
86
+ <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
87
+ <?php if( $this->show_extra_info ) : ?>
88
+ <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
89
+ <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
90
+ <?php endif; ?>
91
+
92
+ <th><?php _e( 'Expires', 'yith-plugin-fw' ) ?></th>
93
+
94
+ <?php if( $this->show_extra_info ) : ?>
95
+ <th><?php _e( 'Remaining', 'yith-plugin-fw' ) ?></th>
96
+ <?php if( $num_members_products_activate ) : ?>
97
+ <th><?php _e( 'Membership', 'yith-plugin-fw' ) ?></th>
98
+ <?php endif; ?>
99
+ <?php endif; ?>
100
+
101
+ <th><?php _e( 'License Actions', 'yith-plugin-fw' ) ?></th>
102
+ </tr>
103
+ </thead>
104
+ <tbody>
105
+ <?php foreach( $activated_products as $init => $info ) : ?>
106
+ <tr>
107
+ <td class="product-name">
108
+ <?php echo $this->display_product_name( $info['Name'] ) ?>
109
+ </td>
110
+
111
+ <?php if( $this->show_extra_info ) : ?>
112
+ <td class="product-licence-email">
113
+ <?php echo $info['licence']['email'] ?>
114
+ </td>
115
+ <td class="product-licence-key">
116
+ <?php echo $info['licence']['licence_key'] ?>
117
+ </td>
118
+ <?php endif; ?>
119
+
120
+ <td class="product-licence-expires">
121
+ <?php echo date("F j, Y", $info['licence']['licence_expires'] ); ?>
122
+ </td>
123
+
124
+ <?php if( $this->show_extra_info ) : ?>
125
+ <td class="product-licence-remaining">
126
+ <?php printf( __( '%1s out of %2s', 'yith-plugin-fw' ), $info['licence']['activation_remaining'], $info['licence']['activation_limit'] ); ?>
127
+ </td>
128
+ <?php if( $num_members_products_activate ) : ?>
129
+ <td class="product-licence-membership">
130
+ <span class="dashicons dashicons-<?php echo $info['licence']['is_membership'] ? 'yes' : 'no-alt' ?>"></span>
131
+ </td>
132
+ <?php endif; ?>
133
+ <?php endif; ?>
134
+
135
+ <td>
136
+ <a class="button-licence licence-deactive"
137
+ href="#"
138
+ data-licence-email="<?php echo $info['licence']['email'] ?>"
139
+ data-licence-key="<?php echo $info['licence']['licence_key'] ?>"
140
+ data-product-init="<?php echo $init ?>"
141
+ data-action="deactivate-<?php echo $this->get_product_type(); ?>">
142
+ <?php _e( 'Deactivate', 'yith-plugin-fw' ) ?>
143
+ </a>
144
+
145
+ <?php if( ! $info['licence']['is_membership'] && $this->show_renew_button ) : ?>
146
+ <a class="button-licence licence-renew" href="<?php echo $this->get_renewing_uri( $info['licence']['licence_key'] ) ?>" target="_blank">
147
+ <?php _e( 'Renew', 'yith-plugin-fw' ) ?>
148
+ </a>
149
+ <?php endif; ?>
150
+ </td>
151
+ </tr>
152
+ <?php endforeach; ?>
153
+ </tbody>
154
+ </table>
155
+ <?php endif;?>
156
+
157
+ <!-- Banned Products -->
158
+
159
+ <?php if( ! empty( $banned_products ) ) : ?>
160
+ <h3><?php _e( 'Banned', 'yith-plugin-fw' ) ?></h3>
161
+ <table class="expired-table">
162
+ <thead>
163
+ <tr>
164
+ <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
165
+ <?php if( $this->show_extra_info ) : ?>
166
+ <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
167
+ <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
168
+ <?php endif; ?>
169
+ </tr>
170
+ </thead>
171
+ <tbody>
172
+ <?php foreach( $banned_products as $init => $info ) : ?>
173
+ <tr>
174
+ <td class="product-name">
175
+ <?php echo $this->display_product_name( $info['Name'] ) ?>
176
+ </td>
177
+ <?php if( $this->show_extra_info ) : ?>
178
+ <td class="product-licence-email"><?php echo $info['licence']['email'] ?></td>
179
+ <td class="product-licence-key"><?php echo $info['licence']['licence_key'] ?></td>
180
+ <?php endif; ?>
181
+ </tr>
182
+ <?php endforeach; ?>
183
+ </tbody>
184
+ </table>
185
+ <?php endif;?>
186
+
187
+ <!-- Expired Products -->
188
+
189
+ <?php if( ! empty( $expired_products ) ) : ?>
190
+ <h3><?php _e( 'Expired', 'yith-plugin-fw' ) ?></h3>
191
+ <table class="expired-table">
192
+ <thead>
193
+ <tr>
194
+ <th><?php _e( 'Product Name', 'yith-plugin-fw' ) ?></th>
195
+
196
+ <?php if( $this->show_extra_info ) : ?>
197
+ <th><?php _e( 'Email', 'yith-plugin-fw' ) ?></th>
198
+ <th><?php _e( 'License Key', 'yith-plugin-fw' ) ?></th>
199
+ <?php endif; ?>
200
+
201
+ <th><?php _e( 'Expires', 'yith-plugin-fw' ) ?></th>
202
+
203
+ <?php if( $this->show_renew_button ) : ?>
204
+ <th><?php _e( 'Renew', 'yith-plugin-fw' ) ?></th>
205
+ <?php endif; ?>
206
+ </tr>
207
+ </thead>
208
+ <tbody>
209
+ <?php foreach( $expired_products as $init => $info ) : ?>
210
+ <tr>
211
+ <td class="product-name">
212
+ <?php echo $this->display_product_name( $info['Name'] ) ?>
213
+ </td>
214
+
215
+ <?php if( $this->show_extra_info ) : ?>
216
+ <td class="product-licence-email"><?php echo $info['licence']['email'] ?></td>
217
+ <td class="product-licence-key"><?php echo $info['licence']['licence_key'] ?></td>
218
+ <?php endif; ?>
219
+
220
+ <td class="product-licence-expires"><?php echo date("F j, Y", $info['licence']['licence_expires'] ); ?></td>
221
+
222
+ <?php if( $this->show_renew_button ) : ?>
223
+ <td>
224
+ <a class="button-licence licence-renew" href="<?php echo $this->get_renewing_uri( $info['licence']['licence_key'] ) ?>" target="_blank">
225
+ <?php if( $info['licence']['is_membership'] ) : ?>
226
+ <?php _e( 'Order again', 'yith-plugin-fw' ) ?>
227
+ <?php else : ?>
228
+ <?php __( 'Renew license', 'yith-plugin-fw' ) ?>
229
+ <?php endif; ?>
230
+ </a>
231
+ </td>
232
+ <?php endif; ?>
233
+ </tr>
234
+ <?php endforeach; ?>
235
+ </tbody>
236
+ </table>
237
+ <?php endif;?>
238
  </div>
plugin-fw/templates/metaboxes/tab.php CHANGED
@@ -1,73 +1,73 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- global $post;
16
-
17
- do_action( 'yit_before_metaboxes_tab' ) ?>
18
- <div class="metaboxes-tab">
19
- <?php do_action( 'yit_before_metaboxes_labels' ) ?>
20
- <ul class="metaboxes-tabs clearfix"<?php if ( count( $tabs ) <= 1 ) : ?> style="display:none;"<?php endif; ?>>
21
- <?php
22
- $i = 0;
23
- foreach ( $tabs as $tab ) :
24
- if ( ! isset( $tab['fields'] ) || empty( $tab['fields'] ) ) {
25
- continue;
26
- }
27
- ?>
28
- <li<?php if ( ! $i ) : ?> class="tabs"<?php endif ?>>
29
- <a href="#<?php echo urldecode( sanitize_title( $tab['label'] ) ) ?>"><?php echo $tab['label'] ?></a></li><?php
30
- $i ++;
31
- endforeach;
32
- ?>
33
- </ul>
34
- <?php do_action( 'yit_after_metaboxes_labels' ) ?>
35
- <?php if( isset( $tab['label'] ) ) : ?>
36
- <?php do_action( 'yit_before_metabox_option_' . urldecode( sanitize_title( $tab['label'] ) ) ); ?>
37
- <?php endif ?>
38
-
39
- <?php
40
- // Use nonce for verification
41
- wp_nonce_field( 'metaboxes-fields-nonce', 'yit_metaboxes_nonce' );
42
- ?>
43
- <?php foreach ( $tabs as $tab ) :
44
-
45
- ?>
46
- <div class="tabs-panel" id="<?php echo urldecode( sanitize_title( $tab['label'] ) ) ?>">
47
- <?php
48
- if ( ! isset( $tab['fields'] ) ) {
49
- continue;
50
- }
51
-
52
- $tab['fields'] = apply_filters( 'yit_metabox_' . sanitize_title( $tab['label'] ) . '_tab_fields', $tab['fields'] );
53
-
54
- foreach ( $tab['fields'] as $id_tab=>$field ) :
55
- $value = yit_get_post_meta( $post->ID, $field['id'] );
56
- $field['value'] = $value != '' ? $value : ( isset( $field['std'] ) ? $field['std'] : '' );
57
- ?>
58
- <div class="the-metabox <?php echo $field['type'] ?> clearfix<?php if ( empty( $field['label'] ) ) : ?> no-label<?php endif; ?>">
59
- <?php $args = apply_filters('yit_fw_metaboxes_type_args', array(
60
- 'basename' => YIT_CORE_PLUGIN_PATH,
61
- 'path' => '/metaboxes/types/',
62
- 'type' => $field['type'],
63
- 'args' => array('args' => $field)
64
- )
65
- );
66
- extract( $args );
67
- ?>
68
- <?php yit_plugin_get_template( $basename, $path . $type . '.php' , $args ) ?>
69
- </div>
70
- <?php endforeach ?>
71
- </div>
72
- <?php endforeach ?>
73
  </div>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ global $post;
16
+
17
+ do_action( 'yit_before_metaboxes_tab' ) ?>
18
+ <div class="metaboxes-tab">
19
+ <?php do_action( 'yit_before_metaboxes_labels' ) ?>
20
+ <ul class="metaboxes-tabs clearfix"<?php if ( count( $tabs ) <= 1 ) : ?> style="display:none;"<?php endif; ?>>
21
+ <?php
22
+ $i = 0;
23
+ foreach ( $tabs as $tab ) :
24
+ if ( ! isset( $tab['fields'] ) || empty( $tab['fields'] ) ) {
25
+ continue;
26
+ }
27
+ ?>
28
+ <li<?php if ( ! $i ) : ?> class="tabs"<?php endif ?>>
29
+ <a href="#<?php echo urldecode( sanitize_title( $tab['label'] ) ) ?>"><?php echo $tab['label'] ?></a></li><?php
30
+ $i ++;
31
+ endforeach;
32
+ ?>
33
+ </ul>
34
+ <?php do_action( 'yit_after_metaboxes_labels' ) ?>
35
+ <?php if( isset( $tab['label'] ) ) : ?>
36
+ <?php do_action( 'yit_before_metabox_option_' . urldecode( sanitize_title( $tab['label'] ) ) ); ?>
37
+ <?php endif ?>
38
+
39
+ <?php
40
+ // Use nonce for verification
41
+ wp_nonce_field( 'metaboxes-fields-nonce', 'yit_metaboxes_nonce' );
42
+ ?>
43
+ <?php foreach ( $tabs as $tab ) :
44
+
45
+ ?>
46
+ <div class="tabs-panel" id="<?php echo urldecode( sanitize_title( $tab['label'] ) ) ?>">
47
+ <?php
48
+ if ( ! isset( $tab['fields'] ) ) {
49
+ continue;
50
+ }
51
+
52
+ $tab['fields'] = apply_filters( 'yit_metabox_' . sanitize_title( $tab['label'] ) . '_tab_fields', $tab['fields'] );
53
+
54
+ foreach ( $tab['fields'] as $id_tab=>$field ) :
55
+ $value = yit_get_post_meta( $post->ID, $field['id'] );
56
+ $field['value'] = $value != '' ? $value : ( isset( $field['std'] ) ? $field['std'] : '' );
57
+ ?>
58
+ <div class="the-metabox <?php echo $field['type'] ?> clearfix<?php if ( empty( $field['label'] ) ) : ?> no-label<?php endif; ?>">
59
+ <?php $args = apply_filters('yit_fw_metaboxes_type_args', array(
60
+ 'basename' => YIT_CORE_PLUGIN_PATH,
61
+ 'path' => '/metaboxes/types/',
62
+ 'type' => $field['type'],
63
+ 'args' => array('args' => $field)
64
+ )
65
+ );
66
+ extract( $args );
67
+ ?>
68
+ <?php yit_plugin_get_template( $basename, $path . $type . '.php' , $args ) ?>
69
+ </div>
70
+ <?php endforeach ?>
71
+ </div>
72
+ <?php endforeach ?>
73
  </div>
plugin-fw/templates/metaboxes/types/ajax-products.php CHANGED
@@ -1,63 +1,63 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
- wp_enqueue_script( 'woocommerce_admin' );
15
- extract( $args );
16
- $is_multiple = isset( $multiple ) && $multiple;
17
- $multiple = ( $is_multiple ) ? ' multiple' : '';
18
- ?>
19
- <div id="<?php echo $id ?>-container" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
20
-
21
- <label for="<?php echo $id ?>"><?php echo $label ?></label>
22
-
23
- <select id="<?php echo $id ?>" name="<?php echo $name ?><?php if( $is_multiple ) echo "[]" ?>" class="ajax_chosen_select_products" multiple="multiple" data-placeholder="<?php _e('Search for a product','yith-plugin-fw') ?>">
24
- <?php
25
- if ( $value ) {
26
- foreach ( $value as $product_id ) {
27
- $product = wc_get_product( $product_id );
28
- if ( $product ) {
29
- echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $product->get_formatted_name() ) . '</option>';
30
- }
31
- }
32
- }
33
- ?>
34
- </select>
35
-
36
- <span class="desc inline"><?php echo $desc ?></span>
37
- </div>
38
- <script>
39
-
40
- (function ($) {
41
- $(document).ready(function(){
42
- $("select.ajax_chosen_select_products").ajaxChosen({
43
- method: 'GET',
44
- url: '<?php echo admin_url('admin-ajax.php') ?>',
45
- dataType: 'json',
46
- afterTypeDelay: 100,
47
- data: {
48
- action: 'woocommerce_json_search_products',
49
- security: '<?php echo wp_create_nonce("search-products") ?>'
50
- }
51
- }, function (data) {
52
- var terms = {};
53
-
54
- $.each(data, function (i, val) {
55
- terms[i] = val;
56
- });
57
-
58
- return terms;
59
- });
60
- })
61
-
62
- })(jQuery);
63
  </script>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+ wp_enqueue_script( 'woocommerce_admin' );
15
+ extract( $args );
16
+ $is_multiple = isset( $multiple ) && $multiple;
17
+ $multiple = ( $is_multiple ) ? ' multiple' : '';
18
+ ?>
19
+ <div id="<?php echo $id ?>-container" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
20
+
21
+ <label for="<?php echo $id ?>"><?php echo $label ?></label>
22
+
23
+ <select id="<?php echo $id ?>" name="<?php echo $name ?><?php if( $is_multiple ) echo "[]" ?>" class="ajax_chosen_select_products" multiple="multiple" data-placeholder="<?php _e('Search for a product','yith-plugin-fw') ?>">
24
+ <?php
25
+ if ( $value ) {
26
+ foreach ( $value as $product_id ) {
27
+ $product = wc_get_product( $product_id );
28
+ if ( $product ) {
29
+ echo '<option value="' . esc_attr( $product_id ) . '" selected="selected">' . esc_html( $product->get_formatted_name() ) . '</option>';
30
+ }
31
+ }
32
+ }
33
+ ?>
34
+ </select>
35
+
36
+ <span class="desc inline"><?php echo $desc ?></span>
37
+ </div>
38
+ <script>
39
+
40
+ (function ($) {
41
+ $(document).ready(function(){
42
+ $("select.ajax_chosen_select_products").ajaxChosen({
43
+ method: 'GET',
44
+ url: '<?php echo admin_url('admin-ajax.php') ?>',
45
+ dataType: 'json',
46
+ afterTypeDelay: 100,
47
+ data: {
48
+ action: 'woocommerce_json_search_products',
49
+ security: '<?php echo wp_create_nonce("search-products") ?>'
50
+ }
51
+ }, function (data) {
52
+ var terms = {};
53
+
54
+ $.each(data, function (i, val) {
55
+ terms[i] = val;
56
+ });
57
+
58
+ return terms;
59
+ });
60
+ })
61
+
62
+ })(jQuery);
63
  </script>
plugin-fw/templates/metaboxes/types/categories.php CHANGED
@@ -1,88 +1,88 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- global $post;
16
-
17
- extract( $args );
18
-
19
- if ( empty( $value ) || ! is_array( $value ) )
20
- $value = array();
21
-
22
- $categories = yit_get_model('cpt_unlimited')->get_setting( 'categories', $post->ID );
23
- ?>
24
- <div id="<?php echo $id ?>-container" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
25
- <label for="<?php echo $id ?>"><?php echo $label ?></label>
26
- <div class="categories-panel">
27
- <div class="box">
28
- <ul id="<?php echo $id ?>-category-list" class="category-list">
29
- <?php if ( ! empty( $categories ) ) : ?>
30
- <?php foreach ( $categories as $cat_slug => $cat_name ) : ?>
31
- <li>
32
- <label class="selectit"><input type="checkbox" name="<?php echo $name ?>[]" value="<?php echo esc_attr( $cat_slug ) ?>"<?php checked( in_array( $cat_slug, $value ) ) ?> /> <?php echo $cat_name ?> <a class="remove_cat" href="#">X</a></label>
33
- </li>
34
- <?php endforeach; ?>
35
- <?php else : ?>
36
- <li class="remove-after-add"><i><?php _e( 'No categories.', 'yith-plugin-fw' ); ?></i></li>
37
- <?php endif; ?>
38
- </ul>
39
- </div>
40
- <div class="wp-hidden-children">
41
- <h4>
42
- <a tabindex="3" class="hide-if-no-js" href="#category-add" id="<?php echo $id ?>-category-add"><?php _e( '+ Add New Category', 'yith-plugin-fw' ); ?></a>
43
- </h4>
44
- <p class="category-add-field" id="<?php echo $id ?>-category-field">
45
- <input type="text" class="newcategory" name="newcategory" style="width:100%;" id="<?php echo $id ?>-new-category" />
46
- <input type="button" value="<?php esc_attr_e( 'Add', 'yit' ); ?>" class="add:categorychecklist:category-add button category-add-submit" id="<?php echo $id ?>-category-add-submit" />
47
- </p>
48
- </div>
49
- </div>
50
- <span class="desc inline"><?php echo $desc ?></span>
51
- </div>
52
- <script type="text/javascript">
53
- jQuery(document).ready(function($){
54
- $('#<?php echo $id ?>-category-field').hide();
55
- $(document).on('click', '#<?php echo $id ?>-category-add', function(){
56
- $('#<?php echo $id ?>-category-field').toggle();
57
- return false;
58
- });
59
-
60
- $(document).on('click', '#<?php echo $id ?>-category-add-submit', function(){
61
- var t = $(this);
62
- var new_category = $('#<?php echo $id ?>-new-category').val();
63
-
64
- var data = {
65
- action: 'add_category_post_type',
66
- post_id: <?php echo $post->ID; ?>,
67
- new_category: new_category
68
- };
69
-
70
- $.post(ajaxurl, data, function(response) {
71
- t.prev().val('');
72
- var new_cat = response;
73
-
74
- $('.remove-after-add').hide();
75
- $('.category-list').each(function(){
76
- var this_post_id = $(this).attr('id');
77
- var name = '<?php echo $name ?>';
78
- this_post_id = this_post_id.match( /([0-9]+)/gi );
79
- name = name.replace( /[0-9]+/g, this_post_id[0] );
80
- $(this).prepend('<li><label class="selectit"><input type="checkbox" name="'+name+'[]" value="'+new_cat.slug+'" /> '+new_cat.name+' <a class="remove_cat" href="#">X</a></label></li>');
81
- $('#<?php echo $id ?>-category-list li:first-child .selectit input').attr('checked', true);
82
- });
83
- }, 'json');
84
-
85
- });
86
-
87
- });
88
  </script>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ global $post;
16
+
17
+ extract( $args );
18
+
19
+ if ( empty( $value ) || ! is_array( $value ) )
20
+ $value = array();
21
+
22
+ $categories = yit_get_model('cpt_unlimited')->get_setting( 'categories', $post->ID );
23
+ ?>
24
+ <div id="<?php echo $id ?>-container" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
25
+ <label for="<?php echo $id ?>"><?php echo $label ?></label>
26
+ <div class="categories-panel">
27
+ <div class="box">
28
+ <ul id="<?php echo $id ?>-category-list" class="category-list">
29
+ <?php if ( ! empty( $categories ) ) : ?>
30
+ <?php foreach ( $categories as $cat_slug => $cat_name ) : ?>
31
+ <li>
32
+ <label class="selectit"><input type="checkbox" name="<?php echo $name ?>[]" value="<?php echo esc_attr( $cat_slug ) ?>"<?php checked( in_array( $cat_slug, $value ) ) ?> /> <?php echo $cat_name ?> <a class="remove_cat" href="#">X</a></label>
33
+ </li>
34
+ <?php endforeach; ?>
35
+ <?php else : ?>
36
+ <li class="remove-after-add"><i><?php _e( 'No categories.', 'yith-plugin-fw' ); ?></i></li>
37
+ <?php endif; ?>
38
+ </ul>
39
+ </div>
40
+ <div class="wp-hidden-children">
41
+ <h4>
42
+ <a tabindex="3" class="hide-if-no-js" href="#category-add" id="<?php echo $id ?>-category-add"><?php _e( '+ Add New Category', 'yith-plugin-fw' ); ?></a>
43
+ </h4>
44
+ <p class="category-add-field" id="<?php echo $id ?>-category-field">
45
+ <input type="text" class="newcategory" name="newcategory" style="width:100%;" id="<?php echo $id ?>-new-category" />
46
+ <input type="button" value="<?php esc_attr_e( 'Add', 'yit' ); ?>" class="add:categorychecklist:category-add button category-add-submit" id="<?php echo $id ?>-category-add-submit" />
47
+ </p>
48
+ </div>
49
+ </div>
50
+ <span class="desc inline"><?php echo $desc ?></span>
51
+ </div>
52
+ <script type="text/javascript">
53
+ jQuery(document).ready(function($){
54
+ $('#<?php echo $id ?>-category-field').hide();
55
+ $(document).on('click', '#<?php echo $id ?>-category-add', function(){
56
+ $('#<?php echo $id ?>-category-field').toggle();
57
+ return false;
58
+ });
59
+
60
+ $(document).on('click', '#<?php echo $id ?>-category-add-submit', function(){
61
+ var t = $(this);
62
+ var new_category = $('#<?php echo $id ?>-new-category').val();
63
+
64
+ var data = {
65
+ action: 'add_category_post_type',
66
+ post_id: <?php echo $post->ID; ?>,
67
+ new_category: new_category
68
+ };
69
+
70
+ $.post(ajaxurl, data, function(response) {
71
+ t.prev().val('');
72
+ var new_cat = response;
73
+
74
+ $('.remove-after-add').hide();
75
+ $('.category-list').each(function(){
76
+ var this_post_id = $(this).attr('id');
77
+ var name = '<?php echo $name ?>';
78
+ this_post_id = this_post_id.match( /([0-9]+)/gi );
79
+ name = name.replace( /[0-9]+/g, this_post_id[0] );
80
+ $(this).prepend('<li><label class="selectit"><input type="checkbox" name="'+name+'[]" value="'+new_cat.slug+'" /> '+new_cat.name+' <a class="remove_cat" href="#">X</a></label></li>');
81
+ $('#<?php echo $id ?>-category-list li:first-child .selectit input').attr('checked', true);
82
+ });
83
+ }, 'json');
84
+
85
+ });
86
+
87
+ });
88
  </script>
plugin-fw/templates/metaboxes/types/checkbox.php CHANGED
@@ -1,23 +1,23 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- } // Exit if accessed directly
13
-
14
-
15
- extract( $args );
16
- ?>
17
- <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
18
- <label for="<?php echo $id ?>"><?php echo $label ?></label>
19
- <p>
20
- <input type="checkbox" id="<?php echo $id ?>" name="<?php echo $name ?>" value="1" <?php if( isset( $std ) ) : ?>data-std="<?php echo $std ?>" <?php endif; checked( $value, 1 ) ?> />
21
- <span class="desc inline"><?php echo $desc ?></span>
22
- </p>
23
  </div>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ } // Exit if accessed directly
13
+
14
+
15
+ extract( $args );
16
+ ?>
17
+ <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
18
+ <label for="<?php echo $id ?>"><?php echo $label ?></label>
19
+ <p>
20
+ <input type="checkbox" id="<?php echo $id ?>" name="<?php echo $name ?>" value="1" <?php if( isset( $std ) ) : ?>data-std="<?php echo $std ?>" <?php endif; checked( $value, 1 ) ?> />
21
+ <span class="desc inline"><?php echo $desc ?></span>
22
+ </p>
23
  </div>
plugin-fw/templates/metaboxes/types/chosen.php CHANGED
@@ -1,32 +1,32 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- extract( $args );
16
- $is_multiple = isset( $multiple ) && $multiple;
17
- $multiple = ( $is_multiple ) ? ' multiple' : '';
18
- ?>
19
- <div id="<?php echo $id ?>-container" class="chosen" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
20
-
21
- <label for="<?php echo $id ?>"><?php echo $label ?></label>
22
-
23
- <div class="select_wrapper">
24
- <select<?php echo $multiple ?> id="<?php echo $id ?>" class="chosen" name="<?php echo $name ?><?php if( $is_multiple ) echo "[]" ?>" <?php if ( isset( $std ) ) : ?>data-std="<?php echo ( $is_multiple )? implode(' ,', $std) : $std ?>"<?php endif ?>>
25
- <?php foreach ( $options as $key => $item ) : ?>
26
- <option value="<?php echo esc_attr( $key ) ?>" <?php if( $is_multiple ): selected( true, in_array( $key, $value ) ); else: selected( $key, $value ); endif; ?> ><?php echo $item ?></option>
27
- <?php endforeach; ?>
28
- </select>
29
- </div>
30
-
31
- <span class="desc inline"><?php echo $desc ?></span>
32
  </div>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ extract( $args );
16
+ $is_multiple = isset( $multiple ) && $multiple;
17
+ $multiple = ( $is_multiple ) ? ' multiple' : '';
18
+ ?>
19
+ <div id="<?php echo $id ?>-container" class="chosen" <?php if ( isset( $deps ) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
20
+
21
+ <label for="<?php echo $id ?>"><?php echo $label ?></label>
22
+
23
+ <div class="select_wrapper">
24
+ <select<?php echo $multiple ?> id="<?php echo $id ?>" class="chosen" name="<?php echo $name ?><?php if( $is_multiple ) echo "[]" ?>" <?php if ( isset( $std ) ) : ?>data-std="<?php echo ( $is_multiple )? implode(' ,', $std) : $std ?>"<?php endif ?>>
25
+ <?php foreach ( $options as $key => $item ) : ?>
26
+ <option value="<?php echo esc_attr( $key ) ?>" <?php if( $is_multiple ): selected( true, in_array( $key, $value ) ); else: selected( $key, $value ); endif; ?> ><?php echo $item ?></option>
27
+ <?php endforeach; ?>
28
+ </select>
29
+ </div>
30
+
31
+ <span class="desc inline"><?php echo $desc ?></span>
32
  </div>
plugin-fw/templates/metaboxes/types/colorpicker.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
- /**
3
- * This file belongs to the YIT Plugin Framework.
4
- *
5
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
- * that is bundled with this package in the file LICENSE.txt.
7
- * It is also available through the world-wide-web at this URL:
8
- * http://www.gnu.org/licenses/gpl-3.0.txt
9
- */
10
-
11
- if ( ! defined( 'ABSPATH' ) ) {
12
- exit;
13
- } // Exit if accessed directly
14
-
15
- extract( $args );
16
- ?>
17
- <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
18
- <label for="<?php echo $id ?>"><?php echo $label ?></label>
19
-
20
- <input type="text" name="<?php echo $name ?>" id="<?php echo $id ?>" value="<?php echo esc_attr( $value ) ?>" <?php if( isset( $std ) ) : ?>data-default-color="<?php echo $std ?>"<?php endif ?> class="panel-colorpicker"/>
21
- <span class="desc inline"><?php echo $desc ?></span>
22
  </div>
1
+ <?php
2
+ /**
3
+ * This file belongs to the YIT Plugin Framework.
4
+ *
5
+ * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
6
+ * that is bundled with this package in the file LICENSE.txt.
7
+ * It is also available through the world-wide-web at this URL:
8
+ * http://www.gnu.org/licenses/gpl-3.0.txt
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ } // Exit if accessed directly
14
+
15
+ extract( $args );
16
+ ?>
17
+ <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
18
+ <label for="<?php echo $id ?>"><?php echo $label ?></label>
19
+
20
+ <input type="text" name="<?php echo $name ?>" id="<?php echo $id ?>" value="<?php echo esc_attr( $value ) ?>" <?php if( isset( $std ) ) : ?>data-default-color="<?php echo $std ?>"<?php endif ?> class="panel-colorpicker"/>
21
+ <span class="desc inline"><?php echo $desc ?></span>
22
  </div>
plugin-fw/templates/metaboxes/types/contactform.php CHANGED
@@ -1,557 +1,557 @@
1
- <?php
2
-
3
-
4
- extract( $args );
5
-
6
- $types = array(
7
- 'text' => __( 'Text Input', 'yith-plugin-fw' ),
8
- 'checkbox' => __( 'Checkbox', 'yith-plugin-fw' ),
9
- 'select' => __( 'Select', 'yith-plugin-fw' ),
10
- 'textarea' => __( 'Textarea', 'yith-plugin-fw' ),
11
- 'radio' => __( 'Radio Input', 'yith-plugin-fw' ),
12
- 'password' => __( 'Password Field', 'yith-plugin-fw' ),
13
- 'file' => __( 'File Upload', 'yith-plugin-fw' ),
14
- );
15
-
16
- $defaults = array(
17
- 'order' => 0,
18
- 'title' => '',
19
- 'data_name' => '',
20
- 'type' => 'text',
21
- 'already_checked' => '',
22
- 'options' => array(),
23
- 'option_selected' => '',
24
- 'error' => '',
25
- 'required' => '',
26
- 'is_email' => '',
27
- 'reply_to' => '',
28
- 'class' => '',
29
- 'select-icon' => 'none',
30
- 'icon' => '',
31
- 'custom-icon' => ''
32
- );
33
-
34
- if ( ! is_array( $value ) ) {
35
- $value = array();
36
- }
37
- foreach ( $value as $i => $v ) {
38
- $value[$i] = wp_parse_args( $value[$i], $defaults );
39
- }
40
-
41
- $index = 1;
42
-
43
-
44
- /* Select Font Awesome */
45
-
46
- $options["select"]=array(
47
- 'icon' => __( 'Theme Icon', 'yith-plugin-fw' ),
48
- 'custom' => __( 'Custom Icon', 'yith-plugin-fw' ),
49
- 'none' => __( 'None', 'yith-plugin-fw' )
50
- );
51
-
52
- $options["icon"] = YIT_Plugin_Common::get_awesome_icons();
53
-
54
- /* End select Font Awesome */
55
- ?>
56
- <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
57
- <?php if( isset( $label ) ):?><label for="<?php echo $id ?>"><?php echo $label ?></label><?php endif;?>
58
-
59
- <p class="field-row">
60
- <a href="" class="button-secondary add-items"><?php _e( 'Add field', 'yith-plugin-fw' ) ?></a>
61
- <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="add-items-ajax-loading" alt="" />
62
- </p>
63
-
64
-
65
- <div class="contactform_items panel" id="panel_form">
66
- <?php while ( $index <= count( $value ) ): ?>
67
- <div class="contactform_item closed">
68
- <h3>
69
- <button type="button" class="remove_item button" rel=""><?php _e( 'Remove', 'yith-plugin-fw' ) ?></button>
70
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'yith-plugin-fw' ) ?>"></div>
71
- <strong><?php echo $value[$index]['title'] ?> <?php yit_string( '(', $types[$value[$index]['type']], ')' ) ?></strong>
72
- <input type="hidden" class="contactform_menu_order" name="<?php echo $name ?>[<?php echo $index ?>][order]" value="<?php echo esc_attr( $index ) ?>" />
73
- </h3>
74
- <div class="inside">
75
-
76
- <div class="the-metabox text clearfix">
77
- <label for="<?php echo $id ?>_title_<?php echo $index ?>"><?php _e( 'Field Title', 'yith-plugin-fw' ) ?></label>
78
-
79
- <p>
80
- <input type="text" value="<?php echo esc_attr( $value[$index]['title'] ) ?>" id="<?php echo $id ?>_title_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][title]" />
81
- <span class="desc inline"><?php _e( 'Insert the title for the field.', 'yith-plugin-fw' ) ?></span>
82
- </p>
83
- </div>
84
-
85
- <div class="the-metabox text clearfix">
86
- <label for="<?php echo $id ?>_data_name_<?php echo $index ?>"><?php _e( 'Data Name', 'yith-plugin-fw' ) ?></label>
87
-
88
- <p>
89
- <input type="text" value="<?php echo esc_attr( $value[$index]['data_name'] ) ?>" id="<?php echo $id ?>_data_name_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][data_name]" />
90
- <span class="desc inline"><?php _e( 'REQUIRED: Field identification name to be entered into email body. <strong>Note:</strong>Use only lowercase characters and underscores.', 'yith-plugin-fw' ) ?></span>
91
- </p>
92
- </div>
93
-
94
- <div class="the-metabox select clearfix text-field-type">
95
- <label for="<?php echo $id ?>_type_<?php echo $index ?>"><?php _e( 'Field Type', 'yith-plugin-fw' ) ?></label>
96
-
97
- <p>
98
- <select id="<?php echo $id ?>_type_<?php echo $index ?>" name="<?php echo $name . '[' . $index . ']' ?>[type]">
99
- <?php foreach ( $types as $type => $name_type ) : ?>
100
- <option value="<?php echo esc_attr( $type ) ?>"<?php selected( $type, $value[$index]['type'] ) ?>><?php echo $name_type ?></option>
101
- <?php endforeach; ?>
102
- </select>
103
- <span class="desc inline"><?php _e( 'Select the type for this field.', 'yith-plugin-fw' ) ?></span>
104
- </p>
105
- </div>
106
-
107
- <div class="the-metabox checkbox clearfix deps_checkbox deps">
108
- <label for="<?php echo $id ?>_already_checked_<?php echo $index ?>"><?php _e( 'Checked', 'yith-plugin-fw' ) ?></label>
109
-
110
- <p>
111
- <input type="checkbox" id="<?php echo $id ?>_already_checked_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][already_checked]" value="1"<?php checked( $value[$index]['already_checked'] ) ?> />
112
- <span class="desc inline"><?php _e( 'Select this option if you want this field appears as already checked.', 'yith-plugin-fw' ) ?></span>
113
- </p>
114
- </div>
115
-
116
- <div id="<?php echo $id ?>_addoptions" class="the-metabox addoptions clearfix deps_radio deps_select deps">
117
- <label for=""><?php _e( 'Add options ', 'yith-plugin-fw' ) ?></label>
118
- <a href="#" class="add-field-option button-secondary" data-index="<?php echo $index ?>"><?php _e( 'Add option', 'yith-plugin-fw' ) ?></a><br /><br />
119
- <?php foreach ( $value[$index]['options'] as $key => $option ) : ?>
120
- <p class="option">
121
- <label><input type="radio" name="<?php echo $name ?>[<?php echo $index ?>][option_selected]" value="<?php echo esc_attr( $key ) ?>"<?php checked( $value[$index]['option_selected'], $key ) ?> /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?>
122
- </label>
123
- <input type="text" name="<?php echo $name ?>[<?php echo $index ?>][options][]" value="<?php echo $option ?>" style="width:200px" />
124
- <a href="#" class="del-field-option button-secondary"><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a>
125
- </p>
126
- <?php endforeach; ?>
127
- </div>
128
-
129
- <div class="the-metabox text clearfix">
130
- <label for="<?php echo $id ?>_error_<?php echo $index ?>"><?php _e( 'Error Message', 'yith-plugin-fw' ) ?></label>
131
-
132
- <p>
133
- <input type="text" value="<?php echo esc_attr( $value[$index]['error'] ) ?>" id="<?php echo $id ?>_error_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][error]" />
134
- <span class="desc inline"><?php _e( 'Insert the error message for validation.', 'yith-plugin-fw' ) ?></span>
135
- </p>
136
- </div>
137
-
138
- <div class="the-metabox checkbox clearfix">
139
- <label for="<?php echo $id ?>_required_<?php echo $index ?>"><?php _e( 'Required', 'yith-plugin-fw' ) ?></label>
140
-
141
- <p>
142
- <input type="checkbox" id="<?php echo $id ?>_required_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][required]" value="1"<?php checked( $value[$index]['required'] ) ?> />
143
- <span class="desc inline"><?php _e( 'Select this option if it must be required.', 'yith-plugin-fw' ) ?></span>
144
- </p>
145
- </div>
146
-
147
- <div class="the-metabox checkbox clearfix">
148
- <label for="<?php echo $id ?>_is_email_<?php echo $index ?>"><?php _e( 'Email', 'yith-plugin-fw' ) ?></label>
149
-
150
- <p>
151
- <input type="checkbox" id="<?php echo $id ?>_is_email_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][is_email]" value="1"<?php checked( $value[$index]['is_email'] ) ?> />
152
- <span class="desc inline"><?php _e( 'Select this option if the email must be valid.', 'yith-plugin-fw' ) ?></span>
153
- </p>
154
- </div>
155
-
156
- <div class="the-metabox checkbox clearfix">
157
- <label for="<?php echo $id ?>_reply_to_<?php echo $index ?>"><?php _e( 'Reply To', 'yith-plugin-fw' ) ?></label>
158
-
159
- <p>
160
- <input type="checkbox" id="<?php echo $id ?>_reply_to_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][reply_to]" value="1"<?php checked( $value[$index]['reply_to'] ) ?> />
161
- <span class="desc inline"><?php _e( 'Select this if it is the email you can reply to.', 'yith-plugin-fw' ) ?></span>
162
- </p>
163
- </div>
164
-
165
- <div class="the-metabox text clearfix">
166
- <label for="<?php echo $id ?>_class_<?php echo $index ?>"><?php _e( 'Class', 'yith-plugin-fw' ) ?></label>
167
-
168
- <p>
169
- <input type="text" value="<?php echo esc_attr( $value[$index]['class'] ) ?>" id="<?php echo $id ?>_class_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][class]" />
170
- <span class="desc inline"><?php _e( 'Insert additional class(es) (separated by commas) for more personalization.', 'yith-plugin-fw' ) ?></span>
171
- </p>
172
- </div>
173
-
174
- <div class="the-metabox text clearfix">
175
- <label for="<?php echo $id ?>_icon_<?php echo $index ?>"><?php _e( 'Icon', 'yith-plugin-fw' ) ?></label>
176
-
177
- <p>
178
-
179
- <div class="option">
180
-
181
- <div class="icon_type">
182
- <select name="<?php echo $name ?>[<?php echo $index ?>][select-icon]" id="<?php echo $id ?>_icon_<?php echo $index ?>">
183
- <?php foreach ( $options['select'] as $val => $option ) { ?>
184
- <option value="<?php echo esc_attr( $val ) ?>"<?php selected( $value[$index]['select-icon'], $val ) ?>><?php echo $option; ?></option>
185
- <?php } ?>
186
- </select>
187
- </div>
188
-
189
-
190
-
191
- <div class="awesome_icon" style="font-family: 'FontAwesome'">
192
- <select style="font-family: 'FontAwesome'" name="<?php echo $name ?>[<?php echo $index ?>][icon]" id="<?php echo $id ?>_icon_<?php echo $index ?>[icon]">
193
- <?php foreach ( $options['icon'] as $option => $val ) { ?>
194
- <option value="<?php echo esc_attr( $val ) ?>"<?php selected( $value[$index]['icon'], $val ); ?>>
195
- <?php echo '&#x' . $option . '; ' . $val; ?>
196
- </option>
197
- <?php } ?>
198
- </select>
199
- </div>
200
-
201
- <div class="input_wrapper custom_icon">
202
- <input type="text" name="<?php echo $name ?>[<?php echo $index ?>][custom]" id="<?php echo $id ?>_icon_<?php echo $index ?>[custom-icon]" value="<?php echo esc_attr( $value[$index]['custom'] ); ?>" class="upload_img_url upload_custom_icon" />
203
- <input type="button" name="<?php echo $name ?>[<?php echo $index ?>][custom]-button" value="<?php _e( 'Upload', 'yith-plugin-fw' ) ?>" id="<?php echo $id ?>_icon_<?php echo $index ?>[custom-icon]-button" class="upload_button button" />
204
-
205
- <div class="upload_img_preview" style="margin-top:10px;">
206
- <?php
207
- $file = $current_options['custom'];
208
- if ( preg_match( '/(jpg|jpeg|png|gif|ico)$/', $file ) ) {
209
- echo __('Image preview', 'yith-plugin-fw') . ': ' . "<img src=\"" . YIT_CORE_ASSETS_URL . "/images/sleep.png\" data-src=\"$file\" />";
210
- }
211
- ?>
212
- </div>
213
-
214
- </div>
215
- </div>
216
-
217
- <span class="desc inline"><?php _e( 'Insert an icon for more personalization.', 'yith-plugin-fw' ) ?></span>
218
- </p>
219
- </div>
220
-
221
- <div class="the-metabox text clearfix">
222
- <label for="<?php echo $id ?>_width_<?php echo $index ?>"><?php _e( 'Width', 'yith-plugin-fw' ) ?></label>
223
-
224
- <p>
225
- <select id="<?php echo $id ?>_width_<?php echo $index ?>" name="<?php echo $name . '[' . $index . ']' ?>[width]">
226
- <?php
227
- for ( $i = 1; $i < 13; $i ++ ) {
228
- ?>
229
- <option value="col-sm-<?php echo $i ?>"
230
- <?php
231
- if ( isset( $value[$index]['width'] ) ) {
232
- selected( 'col-sm-' . $i, $value[$index]['width'] );
233
- }
234
- else {
235
- if ( $value['type'] == 'textarea' ) {
236
- selected( 'col-sm-' . $i, 'col-sm-9' );
237
- }
238
- else {
239
- selected( 'col-sm-' . $i, 'col-sm-3' );
240
- }
241
- }
242
- ?>><?php echo $i ?></option>
243
- <?php
244
- }
245
- ?>
246
- </select>
247
- <span class="desc inline"><?php _e( 'Set field length.', 'yith-plugin-fw' ) ?></span>
248
- </p>
249
- </div>
250
- </div>
251
- </div>
252
- <?php
253
- $index ++;
254
- endwhile;
255
- ?>
256
-
257
- </div>
258
-
259
- <div class="contactform_item closed" id="stamp_form" style="display:none;">
260
- <h3>
261
- <button type="button" class="remove_item button" rel=""><?php _e( 'Remove', 'yith-plugin-fw' ) ?></button>
262
- <div class="handlediv" title="<?php _e( 'Click to toggle', 'yith-plugin-fw' ) ?>"></div>
263
- <strong></strong>
264
- <input disabled type="hidden" class="contactform_menu_order" name="<?php echo $name ?>[][order]" value=""/>
265
- </h3>
266
- <div class="inside">
267
-
268
- <div class="the-metabox text clearfix">
269
- <label for="<?php echo $id ?>_title"><?php _e( 'Field Title', 'yith-plugin-fw' ) ?></label>
270
-
271
- <p>
272
- <input disabled type="text" value="" id="<?php echo $id ?>_title" name="<?php echo $name ?>[][title]" />
273
- <span class="desc inline"><?php _e( 'Insert the title for the field.', 'yith-plugin-fw' ) ?></span>
274
- </p>
275
- </div>
276
-
277
- <div class="the-metabox text clearfix">
278
- <label for="<?php echo $id ?>_data_name"><?php _e( 'Data Name', 'yith-plugin-fw' ) ?></label>
279
-
280
- <p>
281
- <input disabled type="text" value="" id="<?php echo $id ?>_data_name" name="<?php echo $name ?>[][data_name]" />
282
- <span class="desc inline"><?php _e( 'REQUIRED: Field identification name to be entered into email body. <strong>Note:</strong>Use only lowercase characters and underscores.', 'yith-plugin-fw' ) ?></span>
283
- </p>
284
- </div>
285
-
286
- <div class="the-metabox select clearfix text-field-type">
287
- <label for="<?php echo $id ?>_type"><?php _e( 'Field Type', 'yith-plugin-fw' ) ?></label>
288
-
289
- <p>
290
- <select disabled id="<?php echo $id ?>_type" name="<?php echo $name ?>[][type]">
291
- <?php foreach ( $types as $type => $name_type ) : ?>
292
- <option value="<?php echo esc_attr( $type ) ?>"><?php echo $name_type ?></option>
293
- <?php endforeach; ?>
294
- </select>
295
- <span class="desc inline"><?php _e( 'Select the type for this field.', 'yith-plugin-fw' ) ?></span>
296
- </p>
297
- </div>
298
-
299
- <div class="the-metabox checkbox clearfix deps_checkbox deps">
300
- <label for="<?php echo $id ?>_already_checked"><?php _e( 'Checked', 'yith-plugin-fw' ) ?></label>
301
-
302
- <p>
303
- <input disabled type="checkbox" id="<?php echo $id ?>_already_checked" name="<?php echo $name ?>[][already_checked]" value="1" />
304
- <span class="desc inline"><?php _e( 'Select this option if you want this field appears as already checked.', 'yith-plugin-fw' ) ?></span>
305
- </p>
306
- </div>
307
-
308
- <div id="<?php echo $id ?>_addoptions" class="the-metabox addoptions clearfix deps_radio deps_select deps">
309
- <label for=""><?php _e( 'Add options ', 'yith-plugin-fw' ) ?></label>
310
- <a href="#" class="add-field-option button-secondary"><?php _e( 'Add option', 'yith-plugin-fw' ) ?></a><br /><br />
311
-
312
- <p class="option">
313
- <label><input disabled type="radio" name="<?php echo $name ?>[][option_selected]" value="" /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?>
314
- </label>
315
- <input disabled type="text" name="<?php echo $name ?>[][options][]" value="" style="width:200px" />
316
- <a href="#" class="del-field-option button-secondary"><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a>
317
- </p>
318
-
319
- </div>
320
-
321
- <div class="the-metabox text clearfix">
322
- <label for="<?php echo $id ?>_error"><?php _e( 'Error Message', 'yith-plugin-fw' ) ?></label>
323
-
324
- <p>
325
- <input disabled type="text" value="" id="<?php echo $id ?>_error" name="<?php echo $name ?>[][error]" />
326
- <span class="desc inline"><?php _e( 'Insert the error message for validation.', 'yith-plugin-fw' ) ?></span>
327
- </p>
328
- </div>
329
-
330
- <div class="the-metabox checkbox clearfix">
331
- <label for="<?php echo $id ?>_required"><?php _e( 'Required', 'yith-plugin-fw' ) ?></label>
332
-
333
- <p>
334
- <input disabled type="checkbox" id="<?php echo $id ?>_required" name="<?php echo $name ?>[][required]" value="1" />
335
- <span class="desc inline"><?php _e( 'Select this option if it must be required.', 'yith-plugin-fw' ) ?></span>
336
- </p>
337
- </div>
338
-
339
- <div class="the-metabox checkbox clearfix">
340
- <label for="<?php echo $id ?>_is_email"><?php _e( 'Email', 'yith-plugin-fw' ) ?></label>
341
-
342
- <p>
343
- <input disabled type="checkbox" id="<?php echo $id ?>_is_email" name="<?php echo $name ?>[][is_email]" value="1" />
344
- <span class="desc inline"><?php _e( 'Select this option if the email must be valid.', 'yith-plugin-fw' ) ?></span>
345
- </p>
346
- </div>
347
-
348
- <div class="the-metabox checkbox clearfix">
349
- <label for="<?php echo $id ?>_reply_to"><?php _e( 'Reply To', 'yith-plugin-fw' ) ?></label>
350
-
351
- <p>
352
- <input disabled type="checkbox" id="<?php echo $id ?>_reply_to" name="<?php echo $name ?>[][reply_to]" value="1" />
353
- <span class="desc inline"><?php _e( 'Select this if it is the email you can reply to.', 'yith-plugin-fw' ) ?></span>
354
- </p>
355
- </div>
356
-
357
- <div class="the-metabox text clearfix">
358
- <label for="<?php echo $id ?>_class"><?php _e( 'Class', 'yith-plugin-fw' ) ?></label>
359
-
360
- <p>
361
- <input disabled type="text" value="" id="<?php echo $id ?>_class" name="<?php echo $name ?>[][class]" />
362
- <span class="desc inline"><?php _e( 'Insert additional class(es) (separated by commas) for more personalization.', 'yith-plugin-fw' ) ?></span>
363
- </p>
364
- </div>
365
-
366
- <div class="the-metabox text clearfix">
367
- <label for="<?php echo $id ?>_icon"><?php _e( 'Icon', 'yith-plugin-fw' ) ?></label>
368
-
369
- <div class="option">
370
-
371
- <div class="icon_type">
372
- <select disabled name="<?php echo $name ?>[][select-icon]" id="<?php echo $id ?>_icon">
373
- <?php foreach ( $options['select'] as $val => $option ) { ?>
374
- <option value="<?php echo esc_attr( $val ) ?>"><?php echo $option; ?></option>
375
- <?php } ?>
376
- </select>
377
- </div>
378
-
379
- <div class="awesome_icon" style="font-family: 'FontAwesome'">
380
- <select disabled style="font-family: 'FontAwesome'" name="<?php echo $name ?>[][icon]" id="<?php echo $id ?>_icon[icon]">
381
- <?php foreach ( $options['icon'] as $option => $val ) { ?>
382
- <option value="<?php echo esc_attr( $val ) ?>">
383
- <?php echo '&#x' . $option . '; ' . $val; ?>
384
- </option>
385
- <?php } ?>
386
- </select>
387
- </div>
388
-
389
- <div class="input_wrapper custom_icon">
390
- <input disabled type="text" name="<?php echo $name ?>[][custom]" id="<?php echo $id ?>_icon[custom-icon]" value="" class="upload_img_url upload_custom_icon" />
391
- <input disabled type="button" name="<?php echo $name ?>[][custom]-button" value="<?php _e( 'Upload', 'yith-plugin-fw' ) ?>" id="<?php echo $id ?>_icon[custom-icon]-button" class="upload_button button" />
392
-
393
- <div class="upload_img_preview" style="margin-top:10px;">
394
- <?php
395
- $file = '';
396
- if ( preg_match( '/(jpg|jpeg|png|gif|ico)$/', $file ) ) {
397
- echo __('Image preview', 'yith-plugin-fw') . ': ' . "<img src=\"" . YIT_CORE_ASSETS_URL . "/images/sleep.png\" data-src=\"$file\" />";
398
- }
399
- ?>
400
- </div>
401
-
402
- </div>
403
- </div>
404
-
405
- <span class="desc inline"><?php _e( 'Insert an icon for more personalization.', 'yith-plugin-fw' ) ?></span>
406
- </div>
407
-
408
- <div class="the-metabox text clearfix">
409
- <label for="<?php echo $id ?>_width"><?php _e( 'Width', 'yith-plugin-fw' ) ?></label>
410
-
411
- <p>
412
- <select disabled id="<?php echo $id ?>_width" name="<?php echo $name?>[][width]">
413
- <?php
414
- for ( $i = 1; $i < 13; $i ++ ) {
415
- ?>
416
- <option value="col-sm-<?php echo $i ?>"> <?php echo $i ?> </option>
417
- <?php
418
- }
419
- ?>
420
- </select>
421
- <span class="desc inline"><?php _e( 'Set field length.', 'yith-plugin-fw' ) ?></span>
422
- </p>
423
- </div>
424
- </div>
425
- </div>
426
- </div>
427
-
428
- <script>
429
-
430
- var index = <?php echo $index ?>;
431
-
432
- jQuery(document).ready(function ($) {
433
-
434
- $(document).on('click', '#<?php echo $id ?>_addoptions .add-field-option', function(){
435
- var select_index = $(this).data('index');
436
- var option = "<p class='option'><label><input type='radio' name='<?php echo $name ?>[option_selected]' value='' /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?></label><input type='text' name='<?php echo $name ?>[" + select_index + "][options][]' style='width:200px' /> <a href='#' class='del-field-option button-secondary'><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a></p>";
437
-
438
- $(option).appendTo( $(this).parents('#<?php echo $id ?>_addoptions') );
439
- return false;
440
- });
441
-
442
- //toggle items
443
- $(document).on('click', '.contactform_item h3, .contactform_item .handlediv', function () {
444
- var p = $(this).parent('.contactform_item'), id = p.attr('id');
445
- p.toggleClass('closed');
446
-
447
- if (!p.hasClass('closed')) {
448
- p.find('.inside').show();
449
- } else {
450
- p.find('.inside').hide();
451
- }
452
-
453
- });
454
-
455
- //add item
456
- $(".add-items").click(function () {
457
-
458
-
459
- var a = $("#stamp_form").clone();
460
- a.appendTo("#panel_form").attr("id", "").show();
461
-
462
- a.find("input, select").each(function(){
463
- $(this).prop('disabled', false);
464
- var str = $(this).attr("name");
465
-
466
- var nam = str.replace("[]","["+ index +"]");
467
- $(this).attr("name", nam );
468
- });
469
-
470
- index++;
471
-
472
- $('body').trigger('yit_contact_form_added_item');
473
-
474
- return false;
475
- });
476
-
477
- //remove item
478
- $(document).on('click', '.remove_item', function () {
479
- if ($('.remove_item').length > 1) {
480
- var str = $(this).parents('.contactform_item').find("input:first-child").attr("name").match( /(.*)\[(.*)\](.*)\[(.*)\]/ );
481
-
482
- var i = parseInt(str[2]);
483
-
484
- $('.contactform_item:gt('+ --i +')').find("input, select").each(function(){
485
- var str = $(this).attr("name").match( /(.*)\[(.*)\](.*)\[(.*)\]/ );
486
- var indice = parseInt(str[2]);
487
- var nam = $(this).attr('name').replace("[" + indice + "]", "[" + --indice + "]");
488
- $(this).attr("name", nam );
489
- });
490
-
491
- $(this).parents('.contactform_item').remove();
492
-
493
- index--;
494
-
495
- $('body').trigger('yit_contact_form_removed_item');
496
- }
497
-
498
- return false;
499
- });
500
-
501
- //sortable
502
- $('.contactform_items').sortable({
503
- items:'.contactform_item',
504
- cursor:'move',
505
- axis:'y',
506
- handle: 'h3',
507
- scrollSensitivity:60,
508
- forcePlaceholderSize: true,
509
- helper: 'clone',
510
- opacity: 0.65,
511
- placeholder: 'metabox-sortable-placeholder',
512
- start:function(event,ui){
513
- ui.item.css('background-color','#f6f6f6');
514
- },
515
- stop:function(event,ui){
516
- ui.item.removeAttr('style');
517
-
518
-
519
- variation_row_indexes();
520
- }
521
- });
522
-
523
-
524
- function variation_row_indexes() {
525
- $('.contactform_items .contactform_item').each(function(index){
526
- index++;
527
- $(this).find("input,select").each(function(){
528
- var str = $(this).attr('name').match( /(.*)\[(.*)\](.*)\[(.*)\]/ );
529
- var nam = $(this).attr('name').replace("[" +parseInt(str[2])+ "]", "[" +index+ "]");
530
- $(this).attr('name', nam);
531
- });
532
- });
533
- }
534
-
535
- //
536
- var field_type_handler = function(){
537
- var this_item = $(this);
538
- $(this_item).on('change', '.text-field-type select', function(){
539
- var val = $(this).val();
540
- $('.deps', this_item).hide().filter(function(i){ return $(this).hasClass( 'deps_' + val ); }).show();
541
- });
542
- $('.text-field-type select').change();
543
- };
544
- $('.contactform_item').each(field_type_handler);
545
-
546
-
547
- //
548
- $(document).on('click', '.del-field-option', function(){
549
- if( $('.option').length > 1 ) {
550
- $(this).parents('.option').remove();
551
- }
552
-
553
- return false;
554
- });
555
-
556
- });
557
- </script>
1
+ <?php
2
+
3
+
4
+ extract( $args );
5
+
6
+ $types = array(
7
+ 'text' => __( 'Text Input', 'yith-plugin-fw' ),
8
+ 'checkbox' => __( 'Checkbox', 'yith-plugin-fw' ),
9
+ 'select' => __( 'Select', 'yith-plugin-fw' ),
10
+ 'textarea' => __( 'Textarea', 'yith-plugin-fw' ),
11
+ 'radio' => __( 'Radio Input', 'yith-plugin-fw' ),
12
+ 'password' => __( 'Password Field', 'yith-plugin-fw' ),
13
+ 'file' => __( 'File Upload', 'yith-plugin-fw' ),
14
+ );
15
+
16
+ $defaults = array(
17
+ 'order' => 0,
18
+ 'title' => '',
19
+ 'data_name' => '',
20
+ 'type' => 'text',
21
+ 'already_checked' => '',
22
+ 'options' => array(),
23
+ 'option_selected' => '',
24
+ 'error' => '',
25
+ 'required' => '',
26
+ 'is_email' => '',
27
+ 'reply_to' => '',
28
+ 'class' => '',
29
+ 'select-icon' => 'none',
30
+ 'icon' => '',
31
+ 'custom-icon' => ''
32
+ );
33
+
34
+ if ( ! is_array( $value ) ) {
35
+ $value = array();
36
+ }
37
+ foreach ( $value as $i => $v ) {
38
+ $value[$i] = wp_parse_args( $value[$i], $defaults );
39
+ }
40
+
41
+ $index = 1;
42
+
43
+
44
+ /* Select Font Awesome */
45
+
46
+ $options["select"]=array(
47
+ 'icon' => __( 'Theme Icon', 'yith-plugin-fw' ),
48
+ 'custom' => __( 'Custom Icon', 'yith-plugin-fw' ),
49
+ 'none' => __( 'None', 'yith-plugin-fw' )
50
+ );
51
+
52
+ $options["icon"] = YIT_Plugin_Common::get_awesome_icons();
53
+
54
+ /* End select Font Awesome */
55
+ ?>
56
+ <div id="<?php echo $id ?>-container" <?php if ( isset($deps) ): ?>data-field="<?php echo $id ?>" data-dep="<?php echo $deps['ids'] ?>" data-value="<?php echo $deps['values'] ?>" <?php endif ?>>
57
+ <?php if( isset( $label ) ):?><label for="<?php echo $id ?>"><?php echo $label ?></label><?php endif;?>
58
+
59
+ <p class="field-row">
60
+ <a href="" class="button-secondary add-items"><?php _e( 'Add field', 'yith-plugin-fw' ) ?></a>
61
+ <img src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" class="ajax-loading" id="add-items-ajax-loading" alt="" />
62
+ </p>
63
+
64
+
65
+ <div class="contactform_items panel" id="panel_form">
66
+ <?php while ( $index <= count( $value ) ): ?>
67
+ <div class="contactform_item closed">
68
+ <h3>
69
+ <button type="button" class="remove_item button" rel=""><?php _e( 'Remove', 'yith-plugin-fw' ) ?></button>
70
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'yith-plugin-fw' ) ?>"></div>
71
+ <strong><?php echo $value[$index]['title'] ?> <?php yit_string( '(', $types[$value[$index]['type']], ')' ) ?></strong>
72
+ <input type="hidden" class="contactform_menu_order" name="<?php echo $name ?>[<?php echo $index ?>][order]" value="<?php echo esc_attr( $index ) ?>" />
73
+ </h3>
74
+ <div class="inside">
75
+
76
+ <div class="the-metabox text clearfix">
77
+ <label for="<?php echo $id ?>_title_<?php echo $index ?>"><?php _e( 'Field Title', 'yith-plugin-fw' ) ?></label>
78
+
79
+ <p>
80
+ <input type="text" value="<?php echo esc_attr( $value[$index]['title'] ) ?>" id="<?php echo $id ?>_title_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][title]" />
81
+ <span class="desc inline"><?php _e( 'Insert the title for the field.', 'yith-plugin-fw' ) ?></span>
82
+ </p>
83
+ </div>
84
+
85
+ <div class="the-metabox text clearfix">
86
+ <label for="<?php echo $id ?>_data_name_<?php echo $index ?>"><?php _e( 'Data Name', 'yith-plugin-fw' ) ?></label>
87
+
88
+ <p>
89
+ <input type="text" value="<?php echo esc_attr( $value[$index]['data_name'] ) ?>" id="<?php echo $id ?>_data_name_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][data_name]" />
90
+ <span class="desc inline"><?php _e( 'REQUIRED: Field identification name to be entered into email body. <strong>Note:</strong>Use only lowercase characters and underscores.', 'yith-plugin-fw' ) ?></span>
91
+ </p>
92
+ </div>
93
+
94
+ <div class="the-metabox select clearfix text-field-type">
95
+ <label for="<?php echo $id ?>_type_<?php echo $index ?>"><?php _e( 'Field Type', 'yith-plugin-fw' ) ?></label>
96
+
97
+ <p>
98
+ <select id="<?php echo $id ?>_type_<?php echo $index ?>" name="<?php echo $name . '[' . $index . ']' ?>[type]">
99
+ <?php foreach ( $types as $type => $name_type ) : ?>
100
+ <option value="<?php echo esc_attr( $type ) ?>"<?php selected( $type, $value[$index]['type'] ) ?>><?php echo $name_type ?></option>
101
+ <?php endforeach; ?>
102
+ </select>
103
+ <span class="desc inline"><?php _e( 'Select the type for this field.', 'yith-plugin-fw' ) ?></span>
104
+ </p>
105
+ </div>
106
+
107
+ <div class="the-metabox checkbox clearfix deps_checkbox deps">
108
+ <label for="<?php echo $id ?>_already_checked_<?php echo $index ?>"><?php _e( 'Checked', 'yith-plugin-fw' ) ?></label>
109
+
110
+ <p>
111
+ <input type="checkbox" id="<?php echo $id ?>_already_checked_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][already_checked]" value="1"<?php checked( $value[$index]['already_checked'] ) ?> />
112
+ <span class="desc inline"><?php _e( 'Select this option if you want this field appears as already checked.', 'yith-plugin-fw' ) ?></span>
113
+ </p>
114
+ </div>
115
+
116
+ <div id="<?php echo $id ?>_addoptions" class="the-metabox addoptions clearfix deps_radio deps_select deps">
117
+ <label for=""><?php _e( 'Add options ', 'yith-plugin-fw' ) ?></label>
118
+ <a href="#" class="add-field-option button-secondary" data-index="<?php echo $index ?>"><?php _e( 'Add option', 'yith-plugin-fw' ) ?></a><br /><br />
119
+ <?php foreach ( $value[$index]['options'] as $key => $option ) : ?>
120
+ <p class="option">
121
+ <label><input type="radio" name="<?php echo $name ?>[<?php echo $index ?>][option_selected]" value="<?php echo esc_attr( $key ) ?>"<?php checked( $value[$index]['option_selected'], $key ) ?> /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?>
122
+ </label>
123
+ <input type="text" name="<?php echo $name ?>[<?php echo $index ?>][options][]" value="<?php echo $option ?>" style="width:200px" />
124
+ <a href="#" class="del-field-option button-secondary"><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a>
125
+ </p>
126
+ <?php endforeach; ?>
127
+ </div>
128
+
129
+ <div class="the-metabox text clearfix">
130
+ <label for="<?php echo $id ?>_error_<?php echo $index ?>"><?php _e( 'Error Message', 'yith-plugin-fw' ) ?></label>
131
+
132
+ <p>
133
+ <input type="text" value="<?php echo esc_attr( $value[$index]['error'] ) ?>" id="<?php echo $id ?>_error_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][error]" />
134
+ <span class="desc inline"><?php _e( 'Insert the error message for validation.', 'yith-plugin-fw' ) ?></span>
135
+ </p>
136
+ </div>
137
+
138
+ <div class="the-metabox checkbox clearfix">
139
+ <label for="<?php echo $id ?>_required_<?php echo $index ?>"><?php _e( 'Required', 'yith-plugin-fw' ) ?></label>
140
+
141
+ <p>
142
+ <input type="checkbox" id="<?php echo $id ?>_required_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][required]" value="1"<?php checked( $value[$index]['required'] ) ?> />
143
+ <span class="desc inline"><?php _e( 'Select this option if it must be required.', 'yith-plugin-fw' ) ?></span>
144
+ </p>
145
+ </div>
146
+
147
+ <div class="the-metabox checkbox clearfix">
148
+ <label for="<?php echo $id ?>_is_email_<?php echo $index ?>"><?php _e( 'Email', 'yith-plugin-fw' ) ?></label>
149
+
150
+ <p>
151
+ <input type="checkbox" id="<?php echo $id ?>_is_email_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][is_email]" value="1"<?php checked( $value[$index]['is_email'] ) ?> />
152
+ <span class="desc inline"><?php _e( 'Select this option if the email must be valid.', 'yith-plugin-fw' ) ?></span>
153
+ </p>
154
+ </div>
155
+
156
+ <div class="the-metabox checkbox clearfix">
157
+ <label for="<?php echo $id ?>_reply_to_<?php echo $index ?>"><?php _e( 'Reply To', 'yith-plugin-fw' ) ?></label>
158
+
159
+ <p>
160
+ <input type="checkbox" id="<?php echo $id ?>_reply_to_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][reply_to]" value="1"<?php checked( $value[$index]['reply_to'] ) ?> />
161
+ <span class="desc inline"><?php _e( 'Select this if it is the email you can reply to.', 'yith-plugin-fw' ) ?></span>
162
+ </p>
163
+ </div>
164
+
165
+ <div class="the-metabox text clearfix">
166
+ <label for="<?php echo $id ?>_class_<?php echo $index ?>"><?php _e( 'Class', 'yith-plugin-fw' ) ?></label>
167
+
168
+ <p>
169
+ <input type="text" value="<?php echo esc_attr( $value[$index]['class'] ) ?>" id="<?php echo $id ?>_class_<?php echo $index ?>" name="<?php echo $name ?>[<?php echo $index ?>][class]" />
170
+ <span class="desc inline"><?php _e( 'Insert additional class(es) (separated by commas) for more personalization.', 'yith-plugin-fw' ) ?></span>
171
+ </p>
172
+ </div>
173
+
174
+ <div class="the-metabox text clearfix">
175
+ <label for="<?php echo $id ?>_icon_<?php echo $index ?>"><?php _e( 'Icon', 'yith-plugin-fw' ) ?></label>
176
+
177
+ <p>
178
+
179
+ <div class="option">
180
+
181
+ <div class="icon_type">
182
+ <select name="<?php echo $name ?>[<?php echo $index ?>][select-icon]" id="<?php echo $id ?>_icon_<?php echo $index ?>">
183
+ <?php foreach ( $options['select'] as $val => $option ) { ?>
184
+ <option value="<?php echo esc_attr( $val ) ?>"<?php selected( $value[$index]['select-icon'], $val ) ?>><?php echo $option; ?></option>
185
+ <?php } ?>
186
+ </select>
187
+ </div>
188
+
189
+
190
+
191
+ <div class="awesome_icon" style="font-family: 'FontAwesome'">
192
+ <select style="font-family: 'FontAwesome'" name="<?php echo $name ?>[<?php echo $index ?>][icon]" id="<?php echo $id ?>_icon_<?php echo $index ?>[icon]">
193
+ <?php foreach ( $options['icon'] as $option => $val ) { ?>
194
+ <option value="<?php echo esc_attr( $val ) ?>"<?php selected( $value[$index]['icon'], $val ); ?>>
195
+ <?php echo '&#x' . $option . '; ' . $val; ?>
196
+ </option>
197
+ <?php } ?>
198
+ </select>
199
+ </div>
200
+
201
+ <div class="input_wrapper custom_icon">
202
+ <input type="text" name="<?php echo $name ?>[<?php echo $index ?>][custom]" id="<?php echo $id ?>_icon_<?php echo $index ?>[custom-icon]" value="<?php echo esc_attr( $value[$index]['custom'] ); ?>" class="upload_img_url upload_custom_icon" />
203
+ <input type="button" name="<?php echo $name ?>[<?php echo $index ?>][custom]-button" value="<?php _e( 'Upload', 'yith-plugin-fw' ) ?>" id="<?php echo $id ?>_icon_<?php echo $index ?>[custom-icon]-button" class="upload_button button" />
204
+
205
+ <div class="upload_img_preview" style="margin-top:10px;">
206
+ <?php
207
+ $file = $current_options['custom'];
208
+ if ( preg_match( '/(jpg|jpeg|png|gif|ico)$/', $file ) ) {
209
+ echo __('Image preview', 'yith-plugin-fw') . ': ' . "<img src=\"" . YIT_CORE_ASSETS_URL . "/images/sleep.png\" data-src=\"$file\" />";
210
+ }
211
+ ?>
212
+ </div>
213
+
214
+ </div>
215
+ </div>
216
+
217
+ <span class="desc inline"><?php _e( 'Insert an icon for more personalization.', 'yith-plugin-fw' ) ?></span>
218
+ </p>
219
+ </div>
220
+
221
+ <div class="the-metabox text clearfix">
222
+ <label for="<?php echo $id ?>_width_<?php echo $index ?>"><?php _e( 'Width', 'yith-plugin-fw' ) ?></label>
223
+
224
+ <p>
225
+ <select id="<?php echo $id ?>_width_<?php echo $index ?>" name="<?php echo $name . '[' . $index . ']' ?>[width]">
226
+ <?php
227
+ for ( $i = 1; $i < 13; $i ++ ) {
228
+ ?>
229
+ <option value="col-sm-<?php echo $i ?>"
230
+ <?php
231
+ if ( isset( $value[$index]['width'] ) ) {
232
+ selected( 'col-sm-' . $i, $value[$index]['width'] );
233
+ }
234
+ else {
235
+ if ( $value['type'] == 'textarea' ) {
236
+ selected( 'col-sm-' . $i, 'col-sm-9' );
237
+ }
238
+ else {
239
+ selected( 'col-sm-' . $i, 'col-sm-3' );
240
+ }
241
+ }
242
+ ?>><?php echo $i ?></option>
243
+ <?php
244
+ }
245
+ ?>
246
+ </select>
247
+ <span class="desc inline"><?php _e( 'Set field length.', 'yith-plugin-fw' ) ?></span>
248
+ </p>
249
+ </div>
250
+ </div>
251
+ </div>
252
+ <?php
253
+ $index ++;
254
+ endwhile;
255
+ ?>
256
+
257
+ </div>
258
+
259
+ <div class="contactform_item closed" id="stamp_form" style="display:none;">
260
+ <h3>
261
+ <button type="button" class="remove_item button" rel=""><?php _e( 'Remove', 'yith-plugin-fw' ) ?></button>
262
+ <div class="handlediv" title="<?php _e( 'Click to toggle', 'yith-plugin-fw' ) ?>"></div>
263
+ <strong></strong>
264
+ <input disabled type="hidden" class="contactform_menu_order" name="<?php echo $name ?>[][order]" value=""/>
265
+ </h3>
266
+ <div class="inside">
267
+
268
+ <div class="the-metabox text clearfix">
269
+ <label for="<?php echo $id ?>_title"><?php _e( 'Field Title', 'yith-plugin-fw' ) ?></label>
270
+
271
+ <p>
272
+ <input disabled type="text" value="" id="<?php echo $id ?>_title" name="<?php echo $name ?>[][title]" />
273
+ <span class="desc inline"><?php _e( 'Insert the title for the field.', 'yith-plugin-fw' ) ?></span>
274
+ </p>
275
+ </div>
276
+
277
+ <div class="the-metabox text clearfix">
278
+ <label for="<?php echo $id ?>_data_name"><?php _e( 'Data Name', 'yith-plugin-fw' ) ?></label>
279
+
280
+ <p>
281
+ <input disabled type="text" value="" id="<?php echo $id ?>_data_name" name="<?php echo $name ?>[][data_name]" />
282
+ <span class="desc inline"><?php _e( 'REQUIRED: Field identification name to be entered into email body. <strong>Note:</strong>Use only lowercase characters and underscores.', 'yith-plugin-fw' ) ?></span>
283
+ </p>
284
+ </div>
285
+
286
+ <div class="the-metabox select clearfix text-field-type">
287
+ <label for="<?php echo $id ?>_type"><?php _e( 'Field Type', 'yith-plugin-fw' ) ?></label>
288
+
289
+ <p>
290
+ <select disabled id="<?php echo $id ?>_type" name="<?php echo $name ?>[][type]">
291
+ <?php foreach ( $types as $type => $name_type ) : ?>
292
+ <option value="<?php echo esc_attr( $type ) ?>"><?php echo $name_type ?></option>
293
+ <?php endforeach; ?>
294
+ </select>
295
+ <span class="desc inline"><?php _e( 'Select the type for this field.', 'yith-plugin-fw' ) ?></span>
296
+ </p>
297
+ </div>
298
+
299
+ <div class="the-metabox checkbox clearfix deps_checkbox deps">
300
+ <label for="<?php echo $id ?>_already_checked"><?php _e( 'Checked', 'yith-plugin-fw' ) ?></label>
301
+
302
+ <p>
303
+ <input disabled type="checkbox" id="<?php echo $id ?>_already_checked" name="<?php echo $name ?>[][already_checked]" value="1" />
304
+ <span class="desc inline"><?php _e( 'Select this option if you want this field appears as already checked.', 'yith-plugin-fw' ) ?></span>
305
+ </p>
306
+ </div>
307
+
308
+ <div id="<?php echo $id ?>_addoptions" class="the-metabox addoptions clearfix deps_radio deps_select deps">
309
+ <label for=""><?php _e( 'Add options ', 'yith-plugin-fw' ) ?></label>
310
+ <a href="#" class="add-field-option button-secondary"><?php _e( 'Add option', 'yith-plugin-fw' ) ?></a><br /><br />
311
+
312
+ <p class="option">
313
+ <label><input disabled type="radio" name="<?php echo $name ?>[][option_selected]" value="" /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?>
314
+ </label>
315
+ <input disabled type="text" name="<?php echo $name ?>[][options][]" value="" style="width:200px" />
316
+ <a href="#" class="del-field-option button-secondary"><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a>
317
+ </p>
318
+
319
+ </div>
320
+
321
+ <div class="the-metabox text clearfix">
322
+ <label for="<?php echo $id ?>_error"><?php _e( 'Error Message', 'yith-plugin-fw' ) ?></label>
323
+
324
+ <p>
325
+ <input disabled type="text" value="" id="<?php echo $id ?>_error" name="<?php echo $name ?>[][error]" />
326
+ <span class="desc inline"><?php _e( 'Insert the error message for validation.', 'yith-plugin-fw' ) ?></span>
327
+ </p>
328
+ </div>
329
+
330
+ <div class="the-metabox checkbox clearfix">
331
+ <label for="<?php echo $id ?>_required"><?php _e( 'Required', 'yith-plugin-fw' ) ?></label>
332
+
333
+ <p>
334
+ <input disabled type="checkbox" id="<?php echo $id ?>_required" name="<?php echo $name ?>[][required]" value="1" />
335
+ <span class="desc inline"><?php _e( 'Select this option if it must be required.', 'yith-plugin-fw' ) ?></span>
336
+ </p>
337
+ </div>
338
+
339
+ <div class="the-metabox checkbox clearfix">
340
+ <label for="<?php echo $id ?>_is_email"><?php _e( 'Email', 'yith-plugin-fw' ) ?></label>
341
+
342
+ <p>
343
+ <input disabled type="checkbox" id="<?php echo $id ?>_is_email" name="<?php echo $name ?>[][is_email]" value="1" />
344
+ <span class="desc inline"><?php _e( 'Select this option if the email must be valid.', 'yith-plugin-fw' ) ?></span>
345
+ </p>
346
+ </div>
347
+
348
+ <div class="the-metabox checkbox clearfix">
349
+ <label for="<?php echo $id ?>_reply_to"><?php _e( 'Reply To', 'yith-plugin-fw' ) ?></label>
350
+
351
+ <p>
352
+ <input disabled type="checkbox" id="<?php echo $id ?>_reply_to" name="<?php echo $name ?>[][reply_to]" value="1" />
353
+ <span class="desc inline"><?php _e( 'Select this if it is the email you can reply to.', 'yith-plugin-fw' ) ?></span>
354
+ </p>
355
+ </div>
356
+
357
+ <div class="the-metabox text clearfix">
358
+ <label for="<?php echo $id ?>_class"><?php _e( 'Class', 'yith-plugin-fw' ) ?></label>
359
+
360
+ <p>
361
+ <input disabled type="text" value="" id="<?php echo $id ?>_class" name="<?php echo $name ?>[][class]" />
362
+ <span class="desc inline"><?php _e( 'Insert additional class(es) (separated by commas) for more personalization.', 'yith-plugin-fw' ) ?></span>
363
+ </p>
364
+ </div>
365
+
366
+ <div class="the-metabox text clearfix">
367
+ <label for="<?php echo $id ?>_icon"><?php _e( 'Icon', 'yith-plugin-fw' ) ?></label>
368
+
369
+ <div class="option">
370
+
371
+ <div class="icon_type">
372
+ <select disabled name="<?php echo $name ?>[][select-icon]" id="<?php echo $id ?>_icon">
373
+ <?php foreach ( $options['select'] as $val => $option ) { ?>
374
+ <option value="<?php echo esc_attr( $val ) ?>"><?php echo $option; ?></option>
375
+ <?php } ?>
376
+ </select>
377
+ </div>
378
+
379
+ <div class="awesome_icon" style="font-family: 'FontAwesome'">
380
+ <select disabled style="font-family: 'FontAwesome'" name="<?php echo $name ?>[][icon]" id="<?php echo $id ?>_icon[icon]">
381
+ <?php foreach ( $options['icon'] as $option => $val ) { ?>
382
+ <option value="<?php echo esc_attr( $val ) ?>">
383
+ <?php echo '&#x' . $option . '; ' . $val; ?>
384
+ </option>
385
+ <?php } ?>
386
+ </select>
387
+ </div>
388
+
389
+ <div class="input_wrapper custom_icon">
390
+ <input disabled type="text" name="<?php echo $name ?>[][custom]" id="<?php echo $id ?>_icon[custom-icon]" value="" class="upload_img_url upload_custom_icon" />
391
+ <input disabled type="button" name="<?php echo $name ?>[][custom]-button" value="<?php _e( 'Upload', 'yith-plugin-fw' ) ?>" id="<?php echo $id ?>_icon[custom-icon]-button" class="upload_button button" />
392
+
393
+ <div class="upload_img_preview" style="margin-top:10px;">
394
+ <?php
395
+ $file = '';
396
+ if ( preg_match( '/(jpg|jpeg|png|gif|ico)$/', $file ) ) {
397
+ echo __('Image preview', 'yith-plugin-fw') . ': ' . "<img src=\"" . YIT_CORE_ASSETS_URL . "/images/sleep.png\" data-src=\"$file\" />";
398
+ }
399
+ ?>
400
+ </div>
401
+
402
+ </div>
403
+ </div>
404
+
405
+ <span class="desc inline"><?php _e( 'Insert an icon for more personalization.', 'yith-plugin-fw' ) ?></span>
406
+ </div>
407
+
408
+ <div class="the-metabox text clearfix">
409
+ <label for="<?php echo $id ?>_width"><?php _e( 'Width', 'yith-plugin-fw' ) ?></label>
410
+
411
+ <p>
412
+ <select disabled id="<?php echo $id ?>_width" name="<?php echo $name?>[][width]">
413
+ <?php
414
+ for ( $i = 1; $i < 13; $i ++ ) {
415
+ ?>
416
+ <option value="col-sm-<?php echo $i ?>"> <?php echo $i ?> </option>
417
+ <?php
418
+ }
419
+ ?>
420
+ </select>
421
+ <span class="desc inline"><?php _e( 'Set field length.', 'yith-plugin-fw' ) ?></span>
422
+ </p>
423
+ </div>
424
+ </div>
425
+ </div>
426
+ </div>
427
+
428
+ <script>
429
+
430
+ var index = <?php echo $index ?>;
431
+
432
+ jQuery(document).ready(function ($) {
433
+
434
+ $(document).on('click', '#<?php echo $id ?>_addoptions .add-field-option', function(){
435
+ var select_index = $(this).data('index');
436
+ var option = "<p class='option'><label><input type='radio' name='<?php echo $name ?>[option_selected]' value='' /> <?php _e( 'Selected', 'yith-plugin-fw' ) ?></label><input type='text' name='<?php echo $name ?>[" + select_index + "][options][]' style='width:200px' /> <a href='#' class='del-field-option button-secondary'><?php _e( 'Delete option', 'yith-plugin-fw' ) ?></a></p>";
437
+
438
+ $(option).appendTo( $(this).parents('#<?php echo $id ?>_addoptions') );
439
+ return false;
440
+ });
441
+
442
+ //toggle items
443
+ $(document).on('click', '.contactform_item h3, .contactform_item .handlediv', function () {
444
+ var p = $(this).parent('.contactform_item'), id = p.attr('id');
445
+ p.toggleClass('closed');
446
+
447
+ if (!p.hasClass('closed')) {
448
+ p.find('.inside').show();
449
+ } else {
450
+ p.find('.inside').hide();
451
+ }
452
+
453
+ });
454
+
455
+ //add item
456
+ $(".add-items").click(function () {
457
+
458
+
459
+ var a = $("#stamp_form").clone();
460
+ a.appendTo("#panel_form").attr("id", "").show();
461
+
462
+ a.find("input, select").each(function(){
463
+ $(this).prop('disabled', false);
464
+ var str = $(this).attr("name");
465
+
466
+ var nam = str.replace("[]","["+ index +"]");
467
+ $(this).attr("name", nam );
468
+ });
469
+
470
+ index++;
471
+
472
+ $('body').trigger('yit_contact_form_added_item');
473
+
474
+ return false;
475
+ });
476
+
477
+ //remove item
478
+ $(document).on('click', '.remove_item', function () {
479
+ if ($('.remove_item').length > 1) {
480
+ var str = $(this).parents('.contactform_item').find("input:first-child").attr("name").match( /(.*)\[(.*)\](.*)\[(.*)\]/ );
481
+
482
+ var i = parseInt(str[2]);
483
+
484
+ $('.contactform_item:gt('+ --i +')').find("input, select").each(function(){
485
+ var str = $(this).attr("name").match( /(.*)\[(.*)\](.*)\[(.*)\]/ );
486
+ var indice = parseInt(str[2]);
487
+ var nam = $(this).attr('name').replace("[" + indice + "]", "[" + --indice + "]");
488
+ $(this).attr("name", nam );
489
+ });
490
+
491
+ $(this).parents('.contactform_item').remove();
492
+
493
+ index--;
494
+
495
+ $('body').trigger('yit_contact_form_removed_item');
496
+ }
497
+
498
+ return false;
499
+ });
500
+
501
+ //sortable
502
+ $('.contactform_items').sortable({
503
+ items:'.contactform_item',
504
+ cursor:'move',
505
+ axis:'y',
506
+ handle: 'h3',
507
+ scrollSensitivity:60,
508
+ forcePlaceholderSize: tr