Flexible Shipping for WooCommerce - Version 2.1

Version Description

  • 2018-05-07 =
  • Added Flexible Shipping tab on WooCommerce Shipping
  • Tweaked calculation method for shipping rules - based on WooCommerce tax display
  • Fixed display printer name on order edit
  • Fixed notice after all rules delete
Download this release

Release Info

Developer jablonowski
Plugin Icon 128x128 Flexible Shipping for WooCommerce
Version 2.1
Comparing to
See all releases

Code changes from version 2.0.1 to 2.1

Files changed (62) hide show
  1. assets/css/admin.css +41 -2
  2. assets/css/admin.min.css +1 -1
  3. assets/js/admin.js +15 -1
  4. assets/js/admin.min.js +1 -1
  5. bootstrap.php +12 -0
  6. classes/admin-notices.php +237 -0
  7. classes/flexible-shipping-export.php +226 -0
  8. classes/flexible-shipping-factory.php +43 -0
  9. classes/flexible-shipping-plugin.php +302 -0
  10. classes/inspire/index.php +0 -3
  11. classes/inspire/plugin4.php +0 -421
  12. classes/manifest/cpt-shipping-manifest.php +1 -1
  13. classes/multicurrency.php +108 -0
  14. classes/multilingual.php +81 -0
  15. classes/{settings-flexible-shipping.php → settings/flexible-shipping.php} +0 -0
  16. classes/{settings-shipping-method-form.php → settings/shipping-method-form.php} +0 -0
  17. classes/shipment/ajax.php +1 -1
  18. classes/shipment/cpt-shipment.php +1 -1
  19. classes/shipping-method-info.php +47 -0
  20. classes/{shipping_method.php → shipping-method.php} +87 -31
  21. classes/views/html-ads.php +2 -3
  22. classes/views/html-shipping-method-info-description.php +62 -0
  23. classes/views/html-shipping-method-rules.php +2 -2
  24. classes/wpdesk/assets/css/admin-settings.css +82 -0
  25. classes/wpdesk/assets/css/admin-settings.min.css +1 -0
  26. classes/wpdesk/assets/js/admin-settings.js +104 -0
  27. classes/wpdesk/assets/js/admin-settings.min.js +1 -0
  28. classes/wpdesk/class-helper.php +75 -0
  29. classes/wpdesk/class-plugin.php +277 -0
  30. classes/wpdesk/class-requirement-checker.php +356 -0
  31. classes/wpdesk/class-settings.php +352 -0
  32. classes/wpdesk/functions.php +17 -0
  33. classes/wpdesk/interface-plugin-factory.php +15 -0
  34. classes/wpdesk/lang/wpdesk-plugin-pl_PL.mo +0 -0
  35. classes/wpdesk/lang/wpdesk-plugin-pl_PL.po +145 -0
  36. classes/wpdesk/settings-api/assets/css/admin.css +35 -0
  37. classes/wpdesk/settings-api/assets/css/admin.min.css +1 -0
  38. classes/wpdesk/settings-api/assets/css/jquery-ui-classic.min.css +1 -0
  39. classes/wpdesk/settings-api/assets/css/jquery-ui-fresh.min.css +1 -0
  40. classes/wpdesk/settings-api/assets/js/admin.js +104 -0
  41. classes/wpdesk/settings-api/assets/js/admin.min.js +1 -0
  42. classes/wpdesk/settings-api/class.s214-settings.php +1253 -0
  43. classes/wpdesk/settings-api/modules/sysinfo/browser.php +1103 -0
  44. classes/wpdesk/settings-api/modules/sysinfo/class.s214-sysinfo.php +442 -0
  45. composer.json +26 -0
  46. flexible-shipping.php +24 -677
  47. inc/functions.php +99 -0
  48. inc/wpdesk-tracker/lang/wpdesk-tracker-pl_PL.mo +0 -0
  49. inc/wpdesk-tracker/lang/wpdesk-tracker-pl_PL.po +12 -5
  50. languages/flexible-shipping-pl_PL.mo +0 -0
  51. languages/flexible-shipping-pl_PL.po +286 -131
  52. readme.md +2 -0
  53. readme.txt +15 -3
  54. vendor/autoload.php +7 -0
  55. vendor/composer/ClassLoader.php +445 -0
  56. vendor/composer/LICENSE +21 -0
  57. vendor/composer/autoload_classmap.php +9 -0
  58. vendor/composer/autoload_namespaces.php +9 -0
  59. vendor/composer/autoload_psr4.php +9 -0
  60. vendor/composer/autoload_real.php +52 -0
  61. vendor/composer/autoload_static.php +15 -0
  62. vendor/composer/installed.json +1 -0
assets/css/admin.css CHANGED
@@ -129,7 +129,7 @@ table.flexible_shipping_method_rules tfoot th {
129
  min-width: 180px;
130
  right: 0;
131
  position: absolute;
132
- top: 155px;
133
  }
134
 
135
  @media screen and (max-width: 1199px) {
@@ -210,4 +210,43 @@ table.flexible_shipping_method_rules tfoot th {
210
  /** select */
211
  .wp-admin select {
212
  height: 100%;
213
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  min-width: 180px;
130
  right: 0;
131
  position: absolute;
132
+ top: 135px;
133
  }
134
 
135
  @media screen and (max-width: 1199px) {
210
  /** select */
211
  .wp-admin select {
212
  height: 100%;
213
+ }
214
+
215
+ /** flexible printing integration */
216
+ .button.flexible-printing-button-print {
217
+ height: auto !important;
218
+ white-space: normal !important;;
219
+ word-wrap: break-word !important;;
220
+ }
221
+
222
+ /* Info Page */
223
+ .inspire-settings {
224
+ display: table;
225
+ width: 100%;
226
+ }
227
+
228
+ .inspire-settings .inspire-main-content,
229
+ .inspire-settings .inspire-sidebar {
230
+ display: table-cell;
231
+ height: 500px;
232
+ margin: 0;
233
+ padding: 0;
234
+ vertical-align: top;
235
+ }
236
+
237
+ .inspire-settings .inspire-main-content {
238
+ min-width: 800px;
239
+ }
240
+
241
+ .inspire-settings .inspire-sidebar {
242
+ padding-left: 30px;
243
+ width: 250px;
244
+ }
245
+
246
+ .flexible-shipping-info ol {
247
+ margin-top: 0;
248
+ }
249
+
250
+ #wpbody-content .flexible-shipping-info .metabox-holder {
251
+ padding-top: 0;
252
+ }
assets/css/admin.min.css CHANGED
@@ -1 +1 @@
1
- table.flexible_shipping_methods th.select,table.flexible_shipping_methods td.select{text-align:center;width:40px;margin-top:-7px;margin-left:-6px;padding:2px}table.flexible_shipping_methods .checkbox-select-all{margin:0 12px 0 8px}table.flexible_shipping_methods th.integration,table.flexible_shipping_methods td.integration{text-align:center;width:130px}table.flexible_shipping_methods tr.highlight td{background-color:#e4f2fd}table.flexible_shipping_methods.wc_shipping th{font-weight:400;width:auto}table.flexible_shipping_method_rules th,table.flexible_shipping_method_rules th{padding:5px 10px 5px 0}table.flexible_shipping_method_rules td p,table.flexible_shipping_method_rules td p input,table.flexible_shipping_method_rules td p select{margin:0;width:100%;box-shadow:none;padding:0 !important}table.flexible_shipping_method_rules td p input[type=text]{text-align:right;padding:0 5px 0 5px !important;width:100% !important}table.flexible_shipping_method_rules td p select{margin:0;width:100% !important;box-shadow:none;line-height:28px;height:37px;vertical-align:middle}table.flexible_shipping_method_rules td p input[type=checkbox]{margin:0;width:auto}table.flexible_shipping_method_rules th,table.flexible_shipping_method_rules td{text-align:center}table.flexible_shipping_method_rules th.shipping_class,table.flexible_shipping_method_rules td.shipping_class{text-align:center;width:200px}table.flexible_shipping_method_rules td.shipping_class span{border:0}table.flexible_shipping_method_rules th.stop,table.flexible_shipping_method_rules td.stop{text-align:center;width:30px}table.flexible_shipping_method_rules th.cancel,table.flexible_shipping_method_rules td.cancel{text-align:center;width:60px}.woocommerce table.form-table .flexible_shipping_method_rules th span.woocommerce-help-tip{float:none;margin:0}.woocommerce table.form-table .flexible_shipping_method_rules .select2-container{margin:0}.woocommerce table.form-table .fs-locations-table .select2-container{max-width:none}.woocommerce table.form-table .fs-locations-table th .woocommerce-help-tip{float:none}div.flexilble_shipping_export_import{float:right}table.flexible_shipping_method_rules tfoot th{padding:10px}.woocommerce_page_wc-settings #mainform{position:relative}.flexible-shipping-pro-box{max-width:280px;min-width:180px;right:0;position:absolute;top:155px}@media screen and (max-width:1199px){.flexible-shipping-pro-box{display:none}}.column-flexible_shipping{width:130px}.column-flexible_shipping .shipping-status{float:left;margin-right:8px;margin-top:4px;text-align:left;width:18px}.column-flexible_shipping .shipping-status .created:after{color:#d0c21f !important}.column-flexible_shipping .shipping-actions a.button{float:left;margin:0 4px 2px 0;display:block;height:2em !important;padding:0 !important;position:relative;text-indent:-9999px;width:2em}.column-flexible_shipping .shipping-actions a.button:after{font-family:WooCommerce;font-variant:normal;font-weight:400;height:100%;left:0;line-height:1.85;margin:0;position:absolute;text-align:center;text-indent:0;text-transform:none;top:0;width:100%}.column-flexible_shipping .shipping-actions a.button.get-label:after{content:"\e01e"}.column-flexible_shipping .shipping-actions a.button.track:after{content:"\e01b"}.column-flexible_shipping mark.failed:after{color:#a00 !important}.column-flexible_shipping mark.manifest:after{color:#2ea2cc !important}.flexible_shipping_shipment_message{color:green}.flexible_shipping_shipment_message_error{color:red}.wp-admin select{height:100%}
1
+ table.flexible_shipping_methods th.select,table.flexible_shipping_methods td.select{text-align:center;width:40px;margin-top:-7px;margin-left:-6px;padding:2px}table.flexible_shipping_methods .checkbox-select-all{margin:0 12px 0 8px}table.flexible_shipping_methods th.integration,table.flexible_shipping_methods td.integration{text-align:center;width:130px}table.flexible_shipping_methods tr.highlight td{background-color:#e4f2fd}table.flexible_shipping_methods.wc_shipping th{font-weight:400;width:auto}table.flexible_shipping_method_rules th,table.flexible_shipping_method_rules th{padding:5px 10px 5px 0px}table.flexible_shipping_method_rules td p,table.flexible_shipping_method_rules td p input,table.flexible_shipping_method_rules td p select{margin:0;width:100%;box-shadow:none;padding:0px !important}table.flexible_shipping_method_rules td p input[type=text]{text-align:right;padding:0px 5px 0px 5px !important;width:100% !important}table.flexible_shipping_method_rules td p select{margin:0;width:100% !important;box-shadow:none;line-height:28px;height:37px;vertical-align:middle}table.flexible_shipping_method_rules td p input[type=checkbox]{margin:0;width:auto}table.flexible_shipping_method_rules th,table.flexible_shipping_method_rules td{text-align:center}table.flexible_shipping_method_rules th.shipping_class,table.flexible_shipping_method_rules td.shipping_class{text-align:center;width:200px}table.flexible_shipping_method_rules td.shipping_class span{border:none}table.flexible_shipping_method_rules th.stop,table.flexible_shipping_method_rules td.stop{text-align:center;width:30px}table.flexible_shipping_method_rules th.cancel,table.flexible_shipping_method_rules td.cancel{text-align:center;width:60px}.woocommerce table.form-table .flexible_shipping_method_rules th span.woocommerce-help-tip{float:none;margin:0px}.woocommerce table.form-table .flexible_shipping_method_rules .select2-container{margin:0}.woocommerce table.form-table .fs-locations-table .select2-container{max-width:none}.woocommerce table.form-table .fs-locations-table th .woocommerce-help-tip{float:none}div.flexilble_shipping_export_import{float:right}table.flexible_shipping_method_rules tfoot th{padding:10px}.woocommerce_page_wc-settings #mainform{position:relative}.flexible-shipping-pro-box{max-width:280px;min-width:180px;right:0;position:absolute;top:135px}@media screen and (max-width: 1199px){.flexible-shipping-pro-box{display:none}}.column-flexible_shipping{width:130px}.column-flexible_shipping .shipping-status{float:left;margin-right:8px;margin-top:4px;text-align:left;width:18px}.column-flexible_shipping .shipping-status .created:after{color:#d0c21f !important}.column-flexible_shipping .shipping-actions a.button{float:left;margin:0 4px 2px 0;display:block;height:2em !important;padding:0 !important;position:relative;text-indent:-9999px;width:2em}.column-flexible_shipping .shipping-actions a.button:after{font-family:WooCommerce;font-variant:normal;font-weight:400;height:100%;left:0;line-height:1.85;margin:0;position:absolute;text-align:center;text-indent:0;text-transform:none;top:0;width:100%}.column-flexible_shipping .shipping-actions a.button.get-label:after{content:"\e01e"}.column-flexible_shipping .shipping-actions a.button.track:after{content:"\e01b"}.column-flexible_shipping mark.failed:after{color:#a00 !important}.column-flexible_shipping mark.manifest:after{color:#2ea2cc !important}.flexible_shipping_shipment_message{color:green}.flexible_shipping_shipment_message_error{color:red}.wp-admin select{height:100%}.button.flexible-printing-button-print{height:auto !important;white-space:normal !important;word-wrap:break-word !important}.inspire-settings{display:table;width:100%}.inspire-settings .inspire-main-content,.inspire-settings .inspire-sidebar{display:table-cell;height:500px;margin:0;padding:0;vertical-align:top}.inspire-settings .inspire-main-content{min-width:800px}.inspire-settings .inspire-sidebar{padding-left:30px;width:250px}.flexible-shipping-info ol{margin-top:0}#wpbody-content .flexible-shipping-info .metabox-holder{padding-top:0}
assets/js/admin.js CHANGED
@@ -157,4 +157,18 @@ function fs_ajax(button, id, fs_action) {
157
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').show();
158
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').html("Request failed: " + textStatus + " " + jqXHR.status);
159
  })
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').show();
158
  jQuery('#flexible_shipping_shipment_' + id + ' .flexible_shipping_shipment_message').html("Request failed: " + textStatus + " " + jqXHR.status);
159
  })
160
+ }
161
+
162
+ /* Notice */
163
+
164
+ jQuery(function($) {
165
+ $( document ).on( 'click', '.flexible-shipping-taxes-notice .notice-dismiss', function () {
166
+ $.ajax( ajaxurl,
167
+ {
168
+ type: 'POST',
169
+ data: {
170
+ action: 'flexible_shipping_taxes_notice',
171
+ }
172
+ } );
173
+ } );
174
+ });
assets/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){if(jQuery("#flexible_shipping_labels_url").length){window.location.href=jQuery("#flexible_shipping_labels_url").attr("href")}if(jQuery("a.shipping_manifest_download").length==1){window.location.href=jQuery("a.shipping_manifest_download").attr("href")}if(typeof window.history.pushState=="function"){var a=document.location.href;var b=document.location.href;a=fs_removeParam("bulk_flexible_shipping_labels",a);a=fs_removeParam("bulk_flexible_shipping_send",a);a=fs_removeParam("bulk_flexible_shipping_manifests",a);a=fs_removeParam("bulk_flexible_shipping_no_labels_created",a);a=fs_trimChar(a,"?");if(a!=b){window.history.pushState({},"",a)}}});function fs_removeParam(b,d){var e=d.split("?")[0],f,c=[],g=(d.indexOf("?")!==-1)?d.split("?")[1]:"";if(g!==""){c=g.split("&");for(var a=c.length-1;a>=0;a-=1){f=c[a].split("=")[0];if(f===b){c.splice(a,1)}}e=e+"?"+c.join("&")}return e}function fs_trimChar(b,a){while(b.charAt(0)==a){b=b.substring(1)}while(b.charAt(b.length-1)==a){b=b.substring(0,b.length-1)}return b}function fs_id(a){return jQuery(a).closest(".flexible_shipping_shipment").attr("data-id")}function fs_data_set_val(c,a,f){if(typeof a=="undefined"){return c}if(a.indexOf("[")==-1){c[a]=f}else{var d=a.split("[");var g=c;var e=c;var b="";jQuery.each(d,function(i,h){b=h.replace("]","");if(typeof g[b]=="undefined"){g[b]={}}e=g;g=g[b]});e[b]=f}return c}function fs_ajax(a,e,d){jQuery(".button-shipping").attr("disabled",true);jQuery(a).parent().find(".spinner").css({visibility:"visible"});var c={};jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content input, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content select, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content textarea").each(function(){if(jQuery(this).attr("type")=="radio"){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery("#flexible_shipping_shipment_"+e+" input[name="+jQuery(this).attr("name")+"]:checked").val())}else{if(jQuery(this).attr("type")=="checkbox"){if(jQuery(this).is(":checked")){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}else{c=fs_data_set_val(c,jQuery(this).attr("name"),"")}}else{c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}}});var b=jQuery("#flexible_shipping_shipment_nonce_"+e).val();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").removeClass("flexible_shipping_shipment_message_error");jQuery.ajax({url:fs_admin.ajax_url,type:"POST",data:{fs_action:d,action:"flexible_shipping",nonce:b,shipment_id:e,data:c},dataType:"json"}).done(function(f){if(f){if(f=="0"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Invalid response: 0")}else{if(f.status=="success"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content);jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();if(typeof f.message!="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: invalid method?")}}).always(function(){jQuery(".button-shipping").attr("disabled",false);jQuery(".shipping-spinner").parent().find(".spinner").css({visibility:"hidden"})}).fail(function(f,g){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: "+g+" "+f.status)})};
1
+ jQuery(document).ready(function(){if(jQuery("#flexible_shipping_labels_url").length){window.location.href=jQuery("#flexible_shipping_labels_url").attr("href")}if(jQuery("a.shipping_manifest_download").length==1){window.location.href=jQuery("a.shipping_manifest_download").attr("href")}if(typeof window.history.pushState=="function"){var a=document.location.href;var b=document.location.href;a=fs_removeParam("bulk_flexible_shipping_labels",a);a=fs_removeParam("bulk_flexible_shipping_send",a);a=fs_removeParam("bulk_flexible_shipping_manifests",a);a=fs_removeParam("bulk_flexible_shipping_no_labels_created",a);a=fs_trimChar(a,"?");if(a!=b){window.history.pushState({},"",a)}}});function fs_removeParam(b,d){var e=d.split("?")[0],f,c=[],g=(d.indexOf("?")!==-1)?d.split("?")[1]:"";if(g!==""){c=g.split("&");for(var a=c.length-1;a>=0;a-=1){f=c[a].split("=")[0];if(f===b){c.splice(a,1)}}e=e+"?"+c.join("&")}return e}function fs_trimChar(b,a){while(b.charAt(0)==a){b=b.substring(1)}while(b.charAt(b.length-1)==a){b=b.substring(0,b.length-1)}return b}function fs_id(a){return jQuery(a).closest(".flexible_shipping_shipment").attr("data-id")}function fs_data_set_val(c,a,f){if(typeof a=="undefined"){return c}if(a.indexOf("[")==-1){c[a]=f}else{var d=a.split("[");var g=c;var e=c;var b="";jQuery.each(d,function(i,h){b=h.replace("]","");if(typeof g[b]=="undefined"){g[b]={}}e=g;g=g[b]});e[b]=f}return c}function fs_ajax(a,e,d){jQuery(".button-shipping").attr("disabled",true);jQuery(a).parent().find(".spinner").css({visibility:"visible"});var c={};jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content input, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content select, #flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content textarea").each(function(){if(jQuery(this).attr("type")=="radio"){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery("#flexible_shipping_shipment_"+e+" input[name="+jQuery(this).attr("name")+"]:checked").val())}else{if(jQuery(this).attr("type")=="checkbox"){if(jQuery(this).is(":checked")){c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}else{c=fs_data_set_val(c,jQuery(this).attr("name"),"")}}else{c=fs_data_set_val(c,jQuery(this).attr("name"),jQuery(this).val())}}});var b=jQuery("#flexible_shipping_shipment_nonce_"+e).val();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").removeClass("flexible_shipping_shipment_message_error");jQuery.ajax({url:fs_admin.ajax_url,type:"POST",data:{fs_action:d,action:"flexible_shipping",nonce:b,shipment_id:e,data:c},dataType:"json"}).done(function(f){if(f){if(f=="0"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Invalid response: 0")}else{if(f.status=="success"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_content").html(f.content);jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").hide();if(typeof f.message!="undefined"){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html(f.message)}}}else{jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").addClass("flexible_shipping_shipment_message_error");jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: invalid method?")}}).always(function(){jQuery(".button-shipping").attr("disabled",false);jQuery(".shipping-spinner").parent().find(".spinner").css({visibility:"hidden"})}).fail(function(f,g){jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").show();jQuery("#flexible_shipping_shipment_"+e+" .flexible_shipping_shipment_message").html("Request failed: "+g+" "+f.status)})}jQuery(function(a){a(document).on("click",".flexible-shipping-taxes-notice .notice-dismiss",function(){a.ajax(ajaxurl,{type:"POST",data:{action:"flexible_shipping_taxes_notice"}})})});
bootstrap.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ //require_once __DIR__ . '/vendor/autoload.php';
8
+ require_once( 'classes/wpdesk/class-plugin.php' );
9
+ require_once( 'classes/flexible-shipping-factory.php' );
10
+ require_once( 'inc/functions.php' );
11
+
12
+ WPDesk_Flexible_Shipping_Factory::get_plugin_instance();
classes/admin-notices.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Admin_Notices' ) ) {
8
+
9
+ class WPDesk_Flexible_Shipping_Admin_Notices {
10
+
11
+ /**
12
+ *
13
+ */
14
+ const SETTINGS_CHECKED_OPTION_NAME = 'flexible_shipping_smsc';
15
+
16
+ /**
17
+ *
18
+ */
19
+ const SETTINGS_CHECKED_OPTION_NAME_DISMISS = 'flexible_shipping_smsc_dismiss';
20
+
21
+ /**
22
+ *
23
+ */
24
+ const SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE = '1';
25
+
26
+ /**
27
+ *
28
+ */
29
+ const SETTINGS_CHECKED_OPTION_VALUE_DO_NOT_SHOW_MESSAGE = '2';
30
+
31
+ /**
32
+ *
33
+ */
34
+ const BASED_ON_VALUE = 'value';
35
+
36
+ /**
37
+ * @var WPDesk_Flexible_Shipping_Plugin
38
+ */
39
+ private $plugin;
40
+
41
+ /**
42
+ * WPDesk_Flexible_Shipping_Export constructor.
43
+ *
44
+ * @param WPDesk_Flexible_Shipping_Plugin $plugin
45
+ */
46
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
47
+ $this->plugin = $plugin;
48
+ $this->hooks();
49
+ }
50
+
51
+ /**
52
+ *
53
+ */
54
+ private function hooks() {
55
+ //add_action( 'admin_notices', array( $this, 'admin_notices_plugin_versions' ) );
56
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_activepayments' ) );
57
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_enadawca' ) );
58
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_pwr' ) );
59
+ add_action( 'admin_notices', array( $this, 'admin_notices_plugin_woo_fs' ) );
60
+
61
+ add_action( 'admin_notices', array( $this, 'admin_notices_taxes' ) );
62
+
63
+ add_action( 'wp_ajax_flexible_shipping_taxes_notice', array( $this, 'wp_ajax_flexible_shipping_taxes_notice' ) );
64
+ }
65
+
66
+ /**
67
+ *
68
+ */
69
+ public function wp_ajax_flexible_shipping_taxes_notice() {
70
+ update_option( self::SETTINGS_CHECKED_OPTION_NAME_DISMISS, 1 );
71
+ }
72
+
73
+
74
+ /**
75
+ * @param WC_Shipping_Method $shipping_method
76
+ *
77
+ * @return bool
78
+ */
79
+ private function has_value_based_rule( $shipping_method ) {
80
+ $methods = get_option( 'flexible_shipping_methods_' . $shipping_method->instance_id, array() );
81
+ if ( is_array( $methods ) ) {
82
+ foreach ( $methods as $method_settings ) {
83
+ if ( isset( $method_settings['method_rules'] ) && is_array( $method_settings['method_rules'] ) ) {
84
+ foreach ( $method_settings['method_rules'] as $rule ) {
85
+ if ( isset( $rule['based_on'] ) && $rule['based_on'] == self::BASED_ON_VALUE ) {
86
+ return true;
87
+ }
88
+ }
89
+ }
90
+ }
91
+ }
92
+ return false;
93
+ }
94
+
95
+ /**
96
+ *
97
+ */
98
+ private function update_show_admin_notice_taxes_option() {
99
+ $has_value_based_rule = false;
100
+ $shipping_zones = WC_Shipping_Zones::get_zones();
101
+ $shipping_zones[0] = WC_Shipping_Zones::get_zone_by( 'zone_id', 0 );
102
+ foreach ( $shipping_zones as $zone_id => $shipping_zone_array ) {
103
+ $shipping_zone = WC_Shipping_Zones::get_zone( $zone_id );
104
+ /** @var WC_Shipping_Zone $shipping_zone */
105
+ $shipping_methods = $shipping_zone->get_shipping_methods();
106
+ foreach ( $shipping_methods as $shipping_method ) {
107
+ /** @var WC_Shipping_Method $shipping_method */
108
+ if ( $shipping_method->id == 'flexible_shipping' ) {
109
+ $has_value_based_rule = $has_value_based_rule || $this->has_value_based_rule( $shipping_method );
110
+ }
111
+ }
112
+ }
113
+ if ( $has_value_based_rule ) {
114
+ $shipping_methods_settings_checked = self::SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE;
115
+ }
116
+ else {
117
+ $shipping_methods_settings_checked = self::SETTINGS_CHECKED_OPTION_VALUE_DO_NOT_SHOW_MESSAGE;
118
+ }
119
+ update_option( self::SETTINGS_CHECKED_OPTION_NAME, $shipping_methods_settings_checked );
120
+ }
121
+
122
+ /**
123
+ * @return bool
124
+ */
125
+ public function is_show_admin_notice_taxes() {
126
+ $shipping_methods_settings_checked = get_option( self::SETTINGS_CHECKED_OPTION_NAME, '0' );
127
+ if ( $shipping_methods_settings_checked == '0' ) {
128
+ $this->update_show_admin_notice_taxes_option();
129
+ $shipping_methods_settings_checked = get_option( self::SETTINGS_CHECKED_OPTION_NAME, '0' );
130
+ }
131
+ return $shipping_methods_settings_checked == self::SETTINGS_CHECKED_OPTION_VALUE_SHOW_MESSAGE;
132
+ }
133
+
134
+ /**
135
+ * @return bool
136
+ */
137
+ public function is_in_zones() {
138
+ if ( isset( $_GET['page'] ) && $_GET['page'] == 'wc-settings'
139
+ && isset( $_GET['tab'] ) && $_GET['tab'] == 'shipping'
140
+ && ( !isset( $_GET['section'] ) || $_GET['section'] == '' )
141
+ ) {
142
+ return true;
143
+ }
144
+ return false;
145
+ }
146
+
147
+ /**
148
+ * @return bool
149
+ */
150
+ public function is_admin_notice_taxes_dismissed() {
151
+ if ( get_option( self::SETTINGS_CHECKED_OPTION_NAME_DISMISS, '0' ) == '1' ) {
152
+ return true;
153
+ }
154
+ return false;
155
+ }
156
+
157
+ /**
158
+ *
159
+ */
160
+ public function admin_notices_taxes() {
161
+ if ( !$this->is_admin_notice_taxes_dismissed() && $this->is_show_admin_notice_taxes() ) {
162
+ $class = 'notice notice-error is-dismissible flexible-shipping-taxes-notice';
163
+ $message = sprintf(
164
+ __( 'Flexible Shipping has changed the calculation method for shipping rules. Currently, the cart value for rules based on price is determined by WooCommerce tax option "Display prices during cart and checkout". You should check the %ssettings%s.', 'flexible-shipping' ),
165
+ '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=tax' ) . '">',
166
+ '</a>'
167
+ );
168
+ $this->print_notice( $class, $message );
169
+ }
170
+ }
171
+
172
+ /*
173
+ *
174
+ */
175
+ public function admin_notices_plugin_activepayments() {
176
+ if ( is_plugin_active( 'woocommerce-active-payments/activepayments.php' ) ) {
177
+ $plugin_activepayments = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-active-payments/activepayments.php' );
178
+ $version_compare = version_compare( $plugin_activepayments['Version'], '2.7' );
179
+ if ( $version_compare < 0 ) {
180
+ $class = 'notice notice-error';
181
+ $message = __( 'Flexible Shipping requires at least version 2.7 of Active Payments plugin.', 'flexible-shipping' );
182
+ $this->print_notice( $class, $message );
183
+ }
184
+ }
185
+ }
186
+
187
+ /**
188
+ *
189
+ */
190
+ public function admin_notices_plugin_enadawca() {
191
+ if ( is_plugin_active( 'woocommerce-enadawca/woocommerce-enadawca.php' ) ) {
192
+ $plugin_enadawca = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-enadawca/woocommerce-enadawca.php' );
193
+ $version_compare = version_compare( $plugin_enadawca['Version'], '1.2' );
194
+ if ( $version_compare < 0 ) {
195
+ $class = 'notice notice-error';
196
+ $message = __( 'Flexible Shipping requires at least version 1.2 of eNadawca plugin.', 'flexible-shipping' );
197
+ $this->print_notice( $class, $message );
198
+ }
199
+ }
200
+ }
201
+
202
+ /**
203
+ *
204
+ */
205
+ public function admin_notices_plugin_pwr() {
206
+ if ( is_plugin_active( 'woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' ) ) {
207
+ $plugin_pwr = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' );
208
+ $version_compare = version_compare( $plugin_pwr['Version'], '1.1' );
209
+ if ( $version_compare < 0 ) {
210
+ $class = 'notice notice-error';
211
+ $message = __( 'Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin.', 'flexible-shipping' );
212
+ $this->print_notice( $class, $message );
213
+ }
214
+ }
215
+ }
216
+
217
+ /*
218
+ *
219
+ */
220
+ public function admin_notices_plugin_woo_fs() {
221
+ if ( is_plugin_active( 'woo-flexible-shipping/flexible-shipping.php' ) ) {
222
+ $class = 'notice notice-error';
223
+ $message = sprintf( __( 'You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it on %splugins page%s. Read about big changes in Flexible Shipping on %sour blog →%s', 'flexible-shipping' ), '<a href="' . admin_url('plugins.php') . '">', '</a>', '<a href="https://www.wpdesk.pl/blog/nowy-flexible-shipping/">', '</a>' );
224
+ $this->print_notice( $class, $message );
225
+ }
226
+ }
227
+
228
+ /**
229
+ * @param string $class
230
+ * @param string $message
231
+ */
232
+ private function print_notice( $class, $message ) {
233
+ printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
234
+ }
235
+
236
+ }
237
+ }
classes/flexible-shipping-export.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Export' ) ) {
8
+
9
+ class WPDesk_Flexible_Shipping_Export {
10
+
11
+ /**
12
+ * @var WPDesk_Flexible_Shipping_Plugin
13
+ */
14
+ private $plugin;
15
+
16
+ /**
17
+ * WPDesk_Flexible_Shipping_Export constructor.
18
+ *
19
+ * @param WPDesk_Flexible_Shipping_Plugin $plugin
20
+ */
21
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
22
+ $this->plugin = $plugin;
23
+ $this->hooks();
24
+ }
25
+
26
+ /**
27
+ *
28
+ */
29
+ private function hooks() {
30
+ add_action( 'wp_ajax_flexible_shipping_export', array( $this, 'wp_ajax_flexible_shipping_export' ) );
31
+ }
32
+
33
+ /**
34
+ *
35
+ */
36
+ public function wp_ajax_flexible_shipping_export() {
37
+ check_ajax_referer( 'flexible_shipping', 'flexible_shipping_nonce' );
38
+ $ret = array( 'status' => 'ok' );
39
+ $flexible_shipping_action = '';
40
+ if ( isset( $_REQUEST['flexible_shipping_action'] ) ) {
41
+ $flexible_shipping_action = $_REQUEST['flexible_shipping_action'];
42
+ }
43
+ if ( $flexible_shipping_action == 'export' ) {
44
+ $instance_id = '';
45
+ if ( isset( $_REQUEST['instance_id'] ) ) {
46
+ $instance_id = $_REQUEST['instance_id'];
47
+ }
48
+ $ret['instance_id'] = $instance_id;
49
+ $methods = '';
50
+ if ( isset( $_REQUEST['methods'] ) ) {
51
+ $methods = $_REQUEST['methods'];
52
+ }
53
+ $methods_array = explode( ',', $methods );
54
+ $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
55
+ $wc_shipping_classes = WC()->shipping->get_shipping_classes();
56
+ $ret['shipping_method'] = $shipping_method;
57
+
58
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
59
+
60
+ /** @var WPDesk_Flexible_Shipping $flexible_shipping */
61
+ $flexible_shipping = $all_shipping_methods['flexible_shipping'];
62
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
63
+
64
+ $filename = 'fs_' . str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ) . '-' . $instance_id;
65
+
66
+ $ret['all_rates'] = $flexible_shipping_rates;
67
+ $ret['methods'] = $methods;
68
+ $csv_array = array();
69
+ $csv_header = array(
70
+ 'Method Title',
71
+ 'Method Description',
72
+ 'Free Shipping',
73
+ 'Maximum Cost',
74
+ 'Calculation Method',
75
+ 'Visibility',
76
+ 'Default',
77
+ 'Based on',
78
+ 'Min',
79
+ 'Max',
80
+ 'Cost per order',
81
+ 'Additional cost',
82
+ 'Value',
83
+ 'Shipping Class',
84
+ 'Stop',
85
+ 'Cancel',
86
+ );
87
+ $csv_array[] = $csv_header;
88
+ foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
89
+ if ( ! in_array( $flexible_shipping_rate['id'], $methods_array ) ) {
90
+ continue;
91
+ }
92
+ $filename .= '_' . $flexible_shipping_rate['id'];
93
+ if ( ! isset( $flexible_shipping_rate['method_description'] ) ) {
94
+ $flexible_shipping_rate['method_description'] = '';
95
+ }
96
+ if ( ! isset( $flexible_shipping_rate['method_free_shipping'] ) ) {
97
+ $flexible_shipping_rate['method_free_shipping'] = '';
98
+ }
99
+ if ( ! isset( $flexible_shipping_rate['method_max_cost'] ) ) {
100
+ $flexible_shipping_rate['method_max_cost'] = '';
101
+ }
102
+ if ( ! isset( $flexible_shipping_rate['method_calculation_method'] ) ) {
103
+ $flexible_shipping_rate['method_calculation_method'] = '';
104
+ }
105
+ if ( ! isset( $flexible_shipping_rate['method_visibility'] ) ) {
106
+ $flexible_shipping_rate['method_visibility'] = '';
107
+ }
108
+ if ( $flexible_shipping_rate['method_visibility'] != 'yes' ) {
109
+ $flexible_shipping_rate['method_visibility'] = '';
110
+ }
111
+ if ( ! isset( $flexible_shipping_rate['method_default'] ) ) {
112
+ $flexible_shipping_rate['method_default'] = '';
113
+ }
114
+ if ( $flexible_shipping_rate['method_default'] != 'yes' ) {
115
+ $flexible_shipping_rate['method_default'] = '';
116
+ }
117
+ $csv_array[] = array(
118
+ $flexible_shipping_rate['method_title'],
119
+ $flexible_shipping_rate['method_description'],
120
+ $flexible_shipping_rate['method_free_shipping'],
121
+ $flexible_shipping_rate['method_max_cost'],
122
+ $flexible_shipping_rate['method_calculation_method'],
123
+ $flexible_shipping_rate['method_visibility'],
124
+ $flexible_shipping_rate['method_default'],
125
+ '',
126
+ '',
127
+ '',
128
+ '',
129
+ '',
130
+ '',
131
+ '',
132
+ '',
133
+ '',
134
+ );
135
+ foreach ( $flexible_shipping_rate['method_rules'] as $method_rule ) {
136
+ if ( ! isset( $method_rule['based_on'] ) ) {
137
+ $method_rule['based_on'] = '';
138
+ }
139
+ if ( ! isset( $method_rule['min'] ) ) {
140
+ $method_rule['min'] = '';
141
+ }
142
+ if ( ! isset( $method_rule['max'] ) ) {
143
+ $method_rule['max'] = '';
144
+ }
145
+ if ( ! isset( $method_rule['cost_per_order'] ) ) {
146
+ $method_rule['cost_per_order'] = '';
147
+ }
148
+ if ( ! isset( $method_rule['cost_additional'] ) ) {
149
+ $method_rule['cost_additional'] = '';
150
+ }
151
+ if ( ! isset( $method_rule['per_value'] ) ) {
152
+ $method_rule['per_value'] = '';
153
+ }
154
+ if ( ! isset( $method_rule['shipping_class'] ) ) {
155
+ $method_rule['shipping_class'] = '';
156
+ } else {
157
+ $method_shipping_class = $method_rule['shipping_class'];
158
+ if ( ! is_array( $method_shipping_class ) ) {
159
+ $method_shipping_class = array( $method_shipping_class );
160
+ }
161
+ $method_rule['shipping_class'] = '';
162
+ foreach ( $method_shipping_class as $shipping_class ) {
163
+ if ( in_array( $shipping_class, array( 'none', 'any', 'all' ) ) ) {
164
+ $method_rule['shipping_class'] .= $shipping_class;
165
+ $method_rule['shipping_class'] .= ',';
166
+ }
167
+ }
168
+ foreach ( $wc_shipping_classes as $shipping_class ) {
169
+ if ( in_array( $shipping_class->term_id, $method_shipping_class ) ) {
170
+ $method_rule['shipping_class'] .= $shipping_class->name;
171
+ $method_rule['shipping_class'] .= ',';
172
+ }
173
+ }
174
+ $method_rule['shipping_class'] = trim( $method_rule['shipping_class'], ',' );
175
+ }
176
+ if ( ! isset( $method_rule['stop'] ) ) {
177
+ $method_rule['stop'] = '';
178
+ }
179
+ if ( $method_rule['stop'] == '1' ) {
180
+ $method_rule['stop'] = 'yes';
181
+ } else {
182
+ $method_rule['stop'] = '';
183
+ }
184
+ if ( ! isset( $method_rule['cancel'] ) ) {
185
+ $method_rule['cancel'] = '';
186
+ }
187
+ if ( $method_rule['cancel'] == '1' ) {
188
+ $method_rule['cancel'] = 'yes';
189
+ } else {
190
+ $method_rule['cancel'] = '';
191
+ }
192
+ $csv_array[] = array(
193
+ $flexible_shipping_rate['method_title'],
194
+ '',
195
+ '',
196
+ '',
197
+ '',
198
+ '',
199
+ '',
200
+ $method_rule['based_on'],
201
+ $method_rule['min'],
202
+ $method_rule['max'],
203
+ $method_rule['cost_per_order'],
204
+ $method_rule['cost_additional'],
205
+ $method_rule['per_value'],
206
+ $method_rule['shipping_class'],
207
+ $method_rule['stop'],
208
+ $method_rule['cancel'],
209
+ );
210
+ }
211
+ }
212
+ $ret['csv_array'] = $csv_array;
213
+ header( 'Content-Type: text/csv; charset=utf-8' );
214
+ header( 'Content-Disposition: attachment; filename=' . $filename . '.csv' );
215
+ $out = fopen( 'php://output', 'w' );
216
+ foreach ( $csv_array as $fields ) {
217
+ fputcsv( $out, $fields, ';' );
218
+ }
219
+ fclose( $out );
220
+ wp_die();
221
+ }
222
+ echo json_encode( $ret, JSON_PRETTY_PRINT );
223
+ wp_die();
224
+ }
225
+ }
226
+ }
classes/flexible-shipping-factory.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once( 'wpdesk/class-plugin.php' );
3
+ require_once( 'wpdesk/interface-plugin-factory.php' );
4
+ require_once( 'flexible-shipping-plugin.php' );
5
+
6
+
7
+ final class WPDesk_Flexible_Shipping_Factory implements WPDesk_Plugin_Factory_1_10 {
8
+
9
+ const PHP_EXTENSION = '.php';
10
+ /**
11
+ * @var WPDesk_Flexible_Shipping_Plugin
12
+ */
13
+ private static $instance = null;
14
+
15
+ /**
16
+ * Builds instance of plugin. If called more than once then more than one instance is created.
17
+ *
18
+ * @return WPDesk_Flexible_Shipping_Plugin
19
+ */
20
+ public static function build_plugin() {
21
+ $wpdesk_flexible_shipping_plugin_data = array();
22
+
23
+ $class_name = apply_filters( self::WPDESK_FILTER_PLUGIN_CLASS, WPDesk_Flexible_Shipping_Plugin::class );
24
+
25
+ $plugin_dir = dirname( dirname( __FILE__ ) );
26
+ $plugin_file = trailingslashit( $plugin_dir ) . basename( $plugin_dir ) . self::PHP_EXTENSION;
27
+
28
+ return new $class_name( $plugin_file, $wpdesk_flexible_shipping_plugin_data );
29
+ }
30
+
31
+ /**
32
+ * Builds instance if needed and ensures there is only one instance.
33
+ *
34
+ * @return WPDesk_Flexible_Shipping_Plugin
35
+ */
36
+ public static function get_plugin_instance() {
37
+ if ( empty( self::$instance ) ) {
38
+ self::$instance = self::build_plugin();
39
+ }
40
+
41
+ return self::$instance;
42
+ }
43
+ }
classes/flexible-shipping-plugin.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once( 'wpdesk/class-plugin.php' );
3
+
4
+ class WPDesk_Flexible_Shipping_Plugin extends WPDesk_Plugin_1_10 {
5
+
6
+ /**
7
+ * @var string
8
+ */
9
+ private $scripts_version = '60';
10
+
11
+ /**
12
+ * @var WPDesk_Flexible_Shipping_Admin_Notices
13
+ */
14
+ public $admin_notices;
15
+
16
+ /**
17
+ * WPDesk_Flexible_Shipping_Plugin constructor.
18
+ *
19
+ * @param $base_file
20
+ * @param $plugin_data
21
+ */
22
+ public function __construct( $base_file, $plugin_data ) {
23
+ $this->plugin_namespace = 'flexible-shipping';
24
+ $this->plugin_text_domain = 'flexible-shipping';
25
+
26
+ $this->plugin_has_settings = false;
27
+ $this->default_settings_tab = 'welcome';
28
+
29
+ parent::__construct( $base_file, $plugin_data );
30
+
31
+ if ( $this->plugin_is_active() ) {
32
+ $this->init();
33
+ $this->hooks();
34
+ }
35
+ }
36
+
37
+ /**
38
+ *
39
+ */
40
+ private function load_dependencies() {
41
+ require_once('shipment/cpt-shipment.php');
42
+ new WPDesk_Flexible_Shipping_Shipment_CPT( $this );
43
+
44
+ require_once('manifest/cpt-shipping-manifest.php');
45
+ new WPDesk_Flexible_Shipping_Shipping_Manifest_CPT( $this );
46
+
47
+ require_once('shipment/ajax.php');
48
+ new WPDesk_Flexible_Shipping_Shipment_Ajax( $this );
49
+
50
+ require_once('shipment/class-shipment.php');
51
+ require_once('shipment/interface-shipment.php');
52
+ require_once('shipment/functions.php');
53
+
54
+ require_once('manifest/class-manifest.php');
55
+ require_once('manifest/interface-manifest.php');
56
+ require_once('manifest/functions.php');
57
+ require_once('manifest/class-manifest-fs.php');
58
+
59
+ require_once('bulk-actions.php');
60
+ new WPDesk_Flexible_Shipping_Bulk_Actions();
61
+
62
+ require_once('order-add-shipping.php');
63
+ new WPDesk_Flexible_Shipping_Add_Shipping();
64
+
65
+ require_once( 'shipping-method.php' );
66
+ require_once( 'shipping-method-info.php' );
67
+
68
+ require_once( 'flexible-shipping-export.php' );
69
+ new WPDesk_Flexible_Shipping_Export( $this );
70
+
71
+ require_once( 'multilingual.php' );
72
+ new WPDesk_Flexible_Shipping_Multilingual( $this );
73
+
74
+ require_once( 'multicurrency.php' );
75
+ new WPDesk_Flexible_Shipping_Multicurrency( $this );
76
+
77
+ require_once( 'admin-notices.php' );
78
+ $this->admin_notices = new WPDesk_Flexible_Shipping_Admin_Notices( $this );
79
+ }
80
+
81
+ /**
82
+ *
83
+ */
84
+ public function init() {
85
+ $this->load_dependencies();
86
+ }
87
+
88
+ /**
89
+ *
90
+ */
91
+ public function hooks() {
92
+ parent::hooks();
93
+
94
+ add_filter( 'woocommerce_shipping_methods', array( $this, 'woocommerce_shipping_methods_filter' ), 10, 1 );
95
+
96
+ add_action( 'admin_init', array( $this, 'session_init') );
97
+
98
+ add_action( 'woocommerce_after_shipping_rate', array( $this, 'woocommerce_after_shipping_rate' ), 10, 2 );
99
+
100
+ add_action( 'flexible_shipping_method_rate_id', array( $this, 'flexible_shipping_method_rate_id' ), 9999999, 2 );
101
+
102
+ add_filter( 'woocommerce_shipping_chosen_method', array( $this, 'woocommerce_shipping_chosen_method' ), 10, 2);
103
+
104
+ add_action( 'woocommerce_checkout_update_order_meta', array(
105
+ $this,
106
+ 'woocommerce_checkout_update_order_meta'
107
+ ) );
108
+
109
+ add_action( 'woocommerce_checkout_create_order', array(
110
+ $this,
111
+ 'woocommerce_checkout_create_order'
112
+ ) );
113
+
114
+ add_filter( 'option_woocommerce_cod_settings', array( $this, 'option_woocommerce_cod_settings' ) );
115
+
116
+ }
117
+
118
+ /**
119
+ * @param $methods
120
+ *
121
+ * @return mixed
122
+ */
123
+ public function woocommerce_shipping_methods_filter( $methods ) {
124
+ $methods['flexible_shipping'] = 'WPDesk_Flexible_Shipping';
125
+ $methods['flexible_shipping_info'] = 'WPDesk_Flexible_Shipping_Info';
126
+ return $methods;
127
+ }
128
+
129
+
130
+ /**
131
+ * @param array $value
132
+ *
133
+ * @return array
134
+ */
135
+ public function option_woocommerce_cod_settings( $value ) {
136
+ if ( is_checkout() ) {
137
+ if (
138
+ !empty( $value )
139
+ && is_array( $value )
140
+ && $value['enabled'] == 'yes'
141
+ && !empty( $value['enable_for_methods'] )
142
+ && is_array( $value['enable_for_methods'] )
143
+ ) {
144
+ foreach ( $value['enable_for_methods'] as $method ) {
145
+ if ( $method == 'flexible_shipping' ) {
146
+ $all_fs_methods = flexible_shipping_get_all_shipping_methods();
147
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
148
+ $flexible_shipping = $all_shipping_methods['flexible_shipping'];
149
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
150
+ foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
151
+ $value['enable_for_methods'][] = $flexible_shipping_rate['id_for_shipping'];
152
+ }
153
+ break;
154
+ }
155
+ }
156
+ }
157
+ }
158
+ return $value;
159
+ }
160
+
161
+ /**
162
+ *
163
+ */
164
+ public function session_init() {
165
+ if ( ! session_id() ) {
166
+ session_start();
167
+ }
168
+ }
169
+
170
+ /**
171
+ * @param WC_Order $order
172
+ */
173
+ public function woocommerce_checkout_create_order( WC_Order $order ) {
174
+ $order_shipping_methods = $order->get_shipping_methods();
175
+ foreach ( $order_shipping_methods as $shipping_id => $shipping_method ) {
176
+ if ( isset( $shipping_method['item_meta'] )
177
+ && isset( $shipping_method['item_meta']['_fs_method'] )
178
+ ) {
179
+ $fs_method = $shipping_method['item_meta']['_fs_method'];
180
+ if ( !empty( $fs_method['method_integration'] ) ) {
181
+ $order->add_meta_data( '_flexible_shipping_integration', $fs_method['method_integration'] );
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+ /**
188
+ * @param in $order_id
189
+ */
190
+ public function woocommerce_checkout_update_order_meta( $order_id ) {
191
+ $order = wc_get_order( $order_id );
192
+ $order_shipping_methods = $order->get_shipping_methods();
193
+ foreach ( $order_shipping_methods as $shipping_id => $shipping_method ) {
194
+ if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
195
+ if (isset($shipping_method['item_meta'])
196
+ && isset($shipping_method['item_meta']['_fs_method'])
197
+ && isset($shipping_method['item_meta']['_fs_method'][0])
198
+ ) {
199
+ $fs_method = unserialize($shipping_method['item_meta']['_fs_method'][0]);
200
+ if ( !empty( $fs_method['method_integration'] ) ) {
201
+ add_post_meta($order->id, '_flexible_shipping_integration', $fs_method['method_integration']);
202
+ }
203
+ }
204
+ }
205
+ }
206
+ }
207
+
208
+ /**
209
+ * @param $method
210
+ * @param $available_methods
211
+ *
212
+ * @return mixed
213
+ */
214
+ function woocommerce_shipping_chosen_method( $method, $available_methods ) {
215
+ $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
216
+ if ( isset( $chosen_shipping_methods[0] ) ) {
217
+ foreach ($available_methods as $available_method ) {
218
+ if ( $available_method->id ==
219
+ $chosen_shipping_methods[0] ) {
220
+ $method = $available_method->id;
221
+ break;
222
+ }
223
+ }
224
+ }
225
+ return $method;
226
+ }
227
+
228
+ /**
229
+ * @param $hooq
230
+ */
231
+ public function admin_enqueue_scripts( $hooq ) {
232
+ $current_screen = get_current_screen();
233
+ if ( $current_screen->id === 'woocommerce_page_wc-settings' || $current_screen->id === 'edit-shop_order' || $current_screen->id === 'shop_order' ) {
234
+ $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
235
+ wp_register_script( 'fs_admin', trailingslashit( $this->get_plugin_assets_url() ) . 'js/admin' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
236
+ wp_localize_script( 'fs_admin', 'fs_admin', array(
237
+ 'ajax_url' => admin_url( 'admin-ajax.php' ),
238
+ ));
239
+ wp_enqueue_script( 'fs_admin' );
240
+ wp_enqueue_style( 'fs_admin', trailingslashit( $this->get_plugin_assets_url() ) . 'css/admin' . $suffix . '.css', array(), $this->scripts_version );
241
+ wp_enqueue_style( 'fs_font', trailingslashit( $this->get_plugin_assets_url() ) . 'css/font' . $suffix . '.css', array(), $this->scripts_version );
242
+ }
243
+ }
244
+
245
+ /**
246
+ * @param array $links
247
+ *
248
+ * @return array
249
+ */
250
+ public function links_filter( $links ) {
251
+ $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/';
252
+ $support_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/support/' : 'https://www.wpdesk.net/support';
253
+
254
+ $docs_link .= '?utm_source=wp-admin-plugins&utm_medium=quick-link&utm_campaign=flexible-shipping-docs-link';
255
+
256
+ $plugin_links = array(
257
+ '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&section=flexible_shipping_info') . '">' . __( 'Settings', 'flexible-shipping' ) . '</a>',
258
+ '<a href="' . $docs_link . '">' . __( 'Docs', 'flexible-shipping' ) . '</a>',
259
+ '<a href="' . $support_link . '">' . __( 'Support', 'flexible-shipping' ) . '</a>',
260
+ );
261
+ $pro_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/sklep/flexible-shipping-pro-woocommerce/' : 'https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/';
262
+ $utm = '?utm_source=wp-admin-plugins&utm_medium=link&utm_campaign=flexible-shipping-plugins-upgrade-link';
263
+
264
+ if ( ! wpdesk_is_plugin_active( 'flexible-shipping-pro/flexible-shipping-pro.php' ) )
265
+ $plugin_links[] = '<a href="' . $pro_link . $utm . '" target="_blank" style="color:#d64e07;font-weight:bold;">' . __( 'Upgrade', 'flexible-shipping' ) . '</a>';
266
+ return array_merge( $plugin_links, $links );
267
+ }
268
+
269
+
270
+ /**
271
+ * @param WC_Shipping_Rate $method
272
+ * @param int $index
273
+ */
274
+ public function woocommerce_after_shipping_rate( $method, $index ) {
275
+ if ( $method->method_id == 'flexible_shipping' ) {
276
+ $description = WC()->session->get('flexible_shipping_description_' . $method->id, false );
277
+ if ( $description && $description != '' ) {
278
+ echo $this->load_template(
279
+ 'flexible-shipping/after-shipping-rate',
280
+ 'cart/',
281
+ array(
282
+ 'method_description' => $description,
283
+ )
284
+ );
285
+ }
286
+ }
287
+ }
288
+
289
+ /**
290
+ * @param string $method_id
291
+ * @param array $shipping_method
292
+ *
293
+ * @return string
294
+ */
295
+ public function flexible_shipping_method_rate_id( $method_id, array $shipping_method ) {
296
+ if ( isset( $shipping_method['id_for_shipping'] ) && $shipping_method['id_for_shipping'] != '' ) {
297
+ $method_id = $shipping_method['id_for_shipping'];
298
+ }
299
+ return $method_id;
300
+ }
301
+
302
+ }
classes/inspire/index.php DELETED
@@ -1,3 +0,0 @@
1
- <?php
2
- // Silence is golden.
3
- ?>
 
 
 
classes/inspire/plugin4.php DELETED
@@ -1,421 +0,0 @@
1
- <?php
2
- if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
-
4
- //set_site_transient('update_plugins', null);
5
-
6
- if (!class_exists('inspire_Plugin4'))
7
- {
8
-
9
- /**
10
- * Base plugin class for Inspire Labs plugins
11
- *
12
- * @author Krzysiek
13
- *
14
- */
15
- abstract class inspire_Plugin4
16
- {
17
- const VERSION = '4.0';
18
- const DEFAULT_TOKEN = '350299001f1cbf2c8f3af7ca3296f0a3';
19
-
20
- protected $_pluginNamespace = "";
21
- protected $__wpdeskUpdateUrl = 'http://wpdesk.pl/wp-content/';
22
-
23
- protected $_pluginPath;
24
- protected $_templatePath;
25
- protected $_pluginFilePath;
26
- protected $_pluginUrl;
27
-
28
- protected $_defaultViewArgs; // default args given to template
29
-
30
- public function __construct()
31
- {
32
- $this->initBaseVariables();
33
- }
34
-
35
- /**
36
- *
37
- * @return inspire_Plugin4
38
- */
39
- public function getPlugin()
40
- {
41
- return $this;
42
- }
43
-
44
- public function loadPluginTextDomain()
45
- {
46
- load_plugin_textdomain( 'inspire-plugin', FALSE, basename( dirname( __FILE__ ) ) . '/lang/' );
47
- }
48
-
49
- /**
50
- *
51
- */
52
- public function initBaseVariables()
53
- {
54
- $reflection = new ReflectionClass($this);
55
-
56
- // Set Plugin Path
57
- $this->_pluginPath = dirname($reflection->getFileName());
58
-
59
- // Set Plugin URL
60
- $this->_pluginUrl = plugin_dir_url($reflection->getFileName());
61
-
62
- $this->_pluginFilePath = $reflection->getFileName();
63
-
64
- $this->_templatePath = '/' . $this->_pluginNamespace . '_templates';
65
-
66
- $this->_defaultViewArgs = array(
67
- 'pluginUrl' => $this->getPluginUrl()
68
- );
69
-
70
- register_activation_hook( $this->_pluginFilePath, array( $this, 'activation' ) );
71
- register_deactivation_hook( $this->_pluginFilePath, array( $this, 'deactivation' ) );
72
- register_uninstall_hook( $this->_pluginFilePath, 'inspire_Plugin4::uninstall' );
73
-
74
- add_action( 'plugins_loaded', array($this, 'loadPluginTextDomain') );
75
- add_filter( 'plugin_action_links_' . plugin_basename( $this->getPluginFilePath() ), array( $this, 'linksFilter' ) );
76
- /*$this->_initPluginUpdates();
77
- echo '<pre style="margin-left: 170px;">';
78
- var_dump($this->_pluginPath);
79
- var_dump($this->_pluginUrl);
80
- var_dump($this->_pluginFilePath);
81
- var_dump($this->getTemplatePath());
82
- var_dump($this->getPluginAssetsUrl());
83
-
84
- echo '</pre>';*/
85
-
86
- }
87
-
88
- /**
89
- * Plugin activation hook
90
- */
91
- public function activation()
92
- {
93
-
94
- }
95
-
96
- /**
97
- * Plugin deactivation hook
98
- */
99
- public function deactivation()
100
- {
101
-
102
- }
103
-
104
- /**
105
- * Plugin uninstall hook
106
- */
107
- public static function uninstall()
108
- {
109
-
110
- }
111
-
112
- /**
113
- *
114
- * @return string
115
- */
116
- public function getPluginUrl()
117
- {
118
- return esc_url(trailingslashit($this->_pluginUrl));
119
- }
120
-
121
- public function getPluginAssetsUrl()
122
- {
123
- return esc_url(trailingslashit($this->getPluginUrl() . 'assets'));
124
- }
125
-
126
- /**
127
- * @return string
128
- */
129
- public function getTemplatePath()
130
- {
131
- return trailingslashit($this->_templatePath);
132
- }
133
-
134
- public function getPluginFilePath()
135
- {
136
- return $this->_pluginFilePath;
137
- }
138
-
139
- public function getNamespace()
140
- {
141
- return $this->_pluginNamespace;
142
- }
143
-
144
- protected function _initPluginUpdates()
145
- {
146
- add_filter('pre_set_site_transient_update_plugins', array($this, 'checkForPluginUpdate'));
147
- //add_filter('plugins_api', array($this, 'pluginApiCall'), 10, 3);
148
- }
149
-
150
- protected function getPluginUpdateName()
151
- {
152
- return $this->getNamespace() . '/' . str_replace('woocommerce-', '', $this->getNamespace()) .'.php';
153
- }
154
-
155
- public function checkForPluginUpdate($checked_data)
156
- {
157
- global $wp_version;
158
-
159
- var_dump('y');
160
-
161
- if (empty($checked_data->checked))
162
- return $checked_data;
163
-
164
- var_dump($checked_data);
165
-
166
- $args = array(
167
- 'slug' => $this->getNamespace(),
168
- 'version' => $checked_data->checked[$this->getPluginUpdateName()],
169
- );
170
- $request_string = array(
171
- 'body' => array(
172
- 'action' => 'basic_check',
173
- 'request' => serialize($args),
174
- 'site' => get_bloginfo('url'),
175
- 'token' => self::DEFAULT_TOKEN
176
- ),
177
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
178
- );
179
-
180
- var_dump($request_string); die();
181
-
182
- // Start checking for an update
183
- $raw_response = wp_remote_post($this->_wpdeskUpdateUrl, $request_string);
184
-
185
- if (!is_wp_error($raw_response) && ($raw_response['response']['code'] == 200))
186
- $response = unserialize($raw_response['body']);
187
-
188
- if (is_object($response) && !empty($response)) // Feed the update data into WP updater
189
- $checked_data->response[$this->getNamespace() .'/'. $this->getNamespace() .'.php'] = $response;
190
-
191
- return $checked_data;
192
- }
193
-
194
- function pluginApiCall($def, $action, $args) {
195
- global $wp_version;
196
-
197
- if (!isset($args->slug) || ($args->slug != $plugin_slug))
198
- return false;
199
-
200
- // Get the current version
201
- $plugin_info = get_site_transient('update_plugins');
202
- $current_version = $plugin_info->checked[$this->getPluginUpdateName()];
203
- $args->version = $current_version;
204
-
205
- $request_string = array(
206
- 'body' => array(
207
- 'action' => $action,
208
- 'request' => serialize($args),
209
- 'api-key' => md5(get_bloginfo('url'))
210
- ),
211
- 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo('url')
212
- );
213
-
214
- $request = wp_remote_post($this->wpdeskServer, $request_string);
215
-
216
- if (is_wp_error($request)) {
217
- $res = new WP_Error('plugins_api_failed', __('An Unexpected HTTP Error occurred during the API request. <a href="?" onclick="document.location.reload(); return false;">Try again</a>', 'inspire-plugin'), $request->get_error_message());
218
- } else {
219
- $res = unserialize($request['body']);
220
-
221
- if ($res === false)
222
- $res = new WP_Error('plugins_api_failed', __('An unknown error occurred', 'inspire-plugin'), $request['body']);
223
- }
224
-
225
- return $res;
226
- }
227
-
228
- /**
229
- *
230
- * @param string $message
231
- * @param string $class
232
- */
233
- public function addAdminMessage($message, $class = 'updated')
234
- {
235
- $messages = $this->_getAdminMessages();
236
- if (!is_array($messages))
237
- {
238
- $messages = array();
239
- }
240
- $messages[$class][] = $message;
241
- $this->_setAdminMessages($messages);
242
- }
243
-
244
- protected function _getAdminMessages()
245
- {
246
- return get_option($this->getNamespace() . '_messages');
247
- }
248
-
249
- protected function _setAdminMessages($messages)
250
- {
251
- update_option($this->getNamespace() . '_messages', $messages);
252
- }
253
-
254
- /**
255
- *
256
- * @param boolean $clean
257
- */
258
- public function getAdminMessagesHtml($clean = true)
259
- {
260
- $messages = $this->_getAdminMessages();
261
- $str = '';
262
-
263
- if (is_array($messages) && !empty($messages))
264
- {
265
- foreach ($messages as $class => $messagesArray)
266
- {
267
- $str .= '<div class="' . $class . '" id="message">';
268
-
269
- foreach ($messagesArray as $message)
270
- {
271
- $str .= '<p>' . $message . '</p>';
272
- }
273
- $str .= '</div>';
274
- }
275
- }
276
-
277
- if ($clean)
278
- {
279
- $this->_setAdminMessages('');
280
- }
281
- return $str;
282
- }
283
-
284
- public function addFrontMessage($message, $class = 'message')
285
- {
286
- $messages = $this->_getFrontMessages();
287
- if (!is_array($messages))
288
- {
289
- $messages = array();
290
- }
291
- $messages[$class][] = $message;
292
- $this->_setFrontMessages($messages);
293
- }
294
-
295
- protected function _getFrontMessages()
296
- {
297
- return $_SESSION['i-messages'];
298
- }
299
-
300
- protected function _setFrontMessages($messages)
301
- {
302
- $_SESSION['i-messages'] = $messages;
303
- }
304
-
305
- public function getFrontMessagesHtml($clean = true)
306
- {
307
- $messages = $this->_getFrontMessages();
308
- $str = '';
309
-
310
- if (is_array($messages) && !empty($messages))
311
- {
312
- foreach ($messages as $class => $messagesArray)
313
- {
314
- foreach ($messagesArray as $message)
315
- {
316
- $str .= '<p class="woocommerce-' . $class . '"><strong>' . $message . '</strong></p>';
317
- }
318
- }
319
- }
320
-
321
- if ($clean)
322
- {
323
- $this->_setFrontMessages('');
324
- }
325
- return $str;
326
- }
327
-
328
- /**
329
- * Renders end returns selected template
330
- *
331
- * @param string $name name of the template
332
- * @param string $path additional inner path to the template
333
- * @param array $args args accesible from template
334
- * @return string
335
- */
336
- public function loadTemplate($name, $path = '', $args = array())
337
- {
338
- //$args = array_merge($this->_defaultViewArgs, array('textDomain', $this->_textDomain), $args);
339
- $path = trim($path, '/');
340
-
341
- if (file_exists($templateName = implode('/', array(get_template_directory(), $this->getTemplatePath(), $path, $name . '.php'))))
342
- {
343
- } else {
344
- $templateName = implode('/', array($this->_pluginPath, $this->getTemplatePath(), $path, $name . '.php'));
345
- }
346
-
347
- ob_start();
348
- include($templateName);
349
- return ob_get_clean();
350
- }
351
-
352
- /**
353
- * Gets setting value
354
- *
355
- * @param string $name
356
- * @param string $default
357
- * @return Ambigous <mixed, boolean>
358
- */
359
- public function getSettingValue($name, $default = null)
360
- {
361
- return get_option($this->getNamespace() . '_' . $name, $default);
362
- }
363
-
364
- public function setSettingValue($name, $value)
365
- {
366
- return update_option($this->getNamespace() . '_' . $name, $value);
367
- }
368
-
369
- public function isSettingValue($name)
370
- {
371
- $option = get_option($this->getNamespace() . '_' . $name);
372
- return !empty($option);
373
- }
374
-
375
- /**
376
- * action_links function.
377
- *
378
- * @access public
379
- * @param mixed $links
380
- * @return void
381
- */
382
- public function linksFilter( $links )
383
- {
384
-
385
- $plugin_links = array(
386
- '<a href="' . admin_url( 'admin.php?page=' . $this->getNamespace() ) . '">' . __( 'Settings', 'inspire-plugin' ) . '</a>',
387
- '<a href="http://www.wpdesk.pl/docs/' . str_replace('_', '-', $this->getNamespace()) . '_docs/">' . __( 'Docs', 'inspire-plugin' ) . '</a>',
388
- '<a href="http://www.wpdesk.pl/support/">' . __( 'Support', $this->getTextDomain() ) . '</a>',
389
- );
390
-
391
- return array_merge( $plugin_links, $links );
392
- }
393
-
394
- /**
395
- *
396
- * @param string $name
397
- */
398
- protected function _convertCamelCaseToPath($name)
399
- {
400
- return strtolower(preg_replace('/([a-z0-9])([A-Z])/', '$1_$2', $name));
401
- }
402
-
403
- public function createHelperClass($name)
404
- {
405
- require_once('pluginHelper4.php');
406
- $file = $this->_convertCamelCaseToPath($name); ;
407
- require_once( plugin_dir_path($this->getPluginFilePath()) . '/classes/' . $file . '.php' );
408
-
409
- return new $name($this);
410
- }
411
-
412
- public function createDependant($name)
413
- {
414
- require_once('pluginDependant4.php');
415
- $file = $this->_convertCamelCaseToPath($name); ;
416
- require_once( plugin_dir_path($this->getPluginFilePath()) . '/classes/' . $file . '.php' );
417
-
418
- return new $name($this);
419
- }
420
- }
421
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
classes/manifest/cpt-shipping-manifest.php CHANGED
@@ -6,7 +6,7 @@ class WPDesk_Flexible_Shipping_Shipping_Manifest_CPT {
6
 
7
  private $plugin = null;
8
 
9
- public function __construct( WPDesk_Flexible_Shipping_Free_Plugin $plugin ) {
10
  $this->plugin = $plugin;
11
  $this->hooks();
12
  }
6
 
7
  private $plugin = null;
8
 
9
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
10
  $this->plugin = $plugin;
11
  $this->hooks();
12
  }
classes/multicurrency.php ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Multicurrency' ) ) {
8
+
9
+ class WPDesk_Flexible_Shipping_Multicurrency {
10
+
11
+ /**
12
+ * @var WPDesk_Flexible_Shipping_Plugin
13
+ */
14
+ private $plugin;
15
+
16
+ /**
17
+ * WPDesk_Flexible_Shipping_Export constructor.
18
+ *
19
+ * @param WPDesk_Flexible_Shipping_Plugin $plugin
20
+ */
21
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
22
+ $this->plugin = $plugin;
23
+ $this->hooks();
24
+ }
25
+
26
+ /**
27
+ *
28
+ */
29
+ private function hooks() {
30
+ add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_wpml' ), 1 );
31
+
32
+ if ( class_exists( 'WC_Aelia_CurrencySwitcher' ) ) {
33
+ add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_aelia' ), 1 );
34
+ }
35
+
36
+ if ( class_exists( 'Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher' ) ) {
37
+ add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_aelia_namespaces' ), 1 );
38
+ }
39
+
40
+ if ( function_exists( 'wmcs_convert_price' ) ) {
41
+ add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_wmcs' ), 1 );
42
+ }
43
+
44
+ if ( isset( $GLOBALS['WOOCS'] ) ) {
45
+ add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_woocs' ), 1 );
46
+ }
47
+ }
48
+
49
+ /**
50
+ * @param float $value
51
+ *
52
+ * @return float
53
+ */
54
+ public function flexible_shipping_value_in_currency_aelia( $value ) {
55
+ $aelia = WC_Aelia_CurrencySwitcher::instance();
56
+ $aelia_settings = WC_Aelia_CurrencySwitcher::settings();
57
+ $from_currency = $aelia_settings->base_currency();
58
+ $to_currency = $aelia->get_selected_currency();
59
+ $value = $aelia->convert( $value, $from_currency, $to_currency );
60
+ return $value;
61
+ }
62
+
63
+ /**
64
+ * @param float $value
65
+ *
66
+ * @return float
67
+ */
68
+ public function flexible_shipping_value_in_currency_aelia_namespaces( $value ) {
69
+ $aelia = Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher::instance();
70
+ $aelia_settings = Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher::settings();
71
+ $from_currency = $aelia_settings->base_currency();
72
+ $to_currency = $aelia->get_selected_currency();
73
+ $value = $aelia->convert( $value, $from_currency, $to_currency );
74
+ return $value;
75
+ }
76
+
77
+ /**
78
+ * @param float $value
79
+ *
80
+ * @return float
81
+ */
82
+ public function flexible_shipping_value_in_currency_wmcs( $value ) {
83
+ $value = wmcs_convert_price( $value );
84
+ return $value;
85
+ }
86
+
87
+ /**
88
+ * @param float $value
89
+ *
90
+ * @return float
91
+ */
92
+ public function flexible_shipping_value_in_currency_wpml( $value ) {
93
+ return apply_filters( 'wcml_raw_price_amount', $value );
94
+ }
95
+
96
+ /**
97
+ * @param float $value
98
+ *
99
+ * @return float
100
+ */
101
+ public function flexible_shipping_value_in_currency_woocs( $value ) {
102
+ return $GLOBALS['WOOCS']->woocs_exchange_value( $value );
103
+ }
104
+
105
+
106
+ }
107
+
108
+ }
classes/multilingual.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Multilingual' ) ) {
8
+
9
+ class WPDesk_Flexible_Shipping_Multilingual {
10
+
11
+ /**
12
+ * @var WPDesk_Flexible_Shipping_Plugin
13
+ */
14
+ private $plugin;
15
+
16
+ /**
17
+ * WPDesk_Flexible_Shipping_Export constructor.
18
+ *
19
+ * @param WPDesk_Flexible_Shipping_Plugin $plugin
20
+ */
21
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
22
+ $this->plugin = $plugin;
23
+ $this->hooks();
24
+ }
25
+
26
+ /**
27
+ *
28
+ */
29
+ private function hooks() {
30
+ add_action( 'init', array( $this, 'init_polylang') );
31
+ add_action( 'admin_init', array( $this, 'init_wpml') );
32
+ }
33
+
34
+ /**
35
+ *
36
+ */
37
+ public function init_polylang() {
38
+ if ( function_exists( 'pll_register_string' ) ) {
39
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
40
+ $flexible_shipping = $all_shipping_methods['flexible_shipping'];
41
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
42
+ foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
43
+ if ( isset( $flexible_shipping_rate['method_title'] ) ) {
44
+ pll_register_string( $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], __( 'Flexible Shipping', 'flexible-shipping' ) );
45
+ }
46
+ if ( isset( $flexible_shipping_rate['method_description'] ) ) {
47
+ pll_register_string( $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], __( 'Flexible Shipping', 'flexible-shipping' ) );
48
+ }
49
+ if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) {
50
+ pll_register_string( $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], __( 'Flexible Shipping', 'flexible-shipping' ) );
51
+ }
52
+ }
53
+ }
54
+ }
55
+
56
+ /**
57
+ *
58
+ */
59
+ public function init_wpml() {
60
+ if ( function_exists( 'icl_register_string' ) ) {
61
+ $icl_language_code = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : get_bloginfo('language');
62
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
63
+ $flexible_shipping = $all_shipping_methods['flexible_shipping'];
64
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
65
+ foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
66
+ if ( isset( $flexible_shipping_rate['method_title'] ) ) {
67
+ icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], false, $icl_language_code );
68
+ }
69
+ if ( isset( $flexible_shipping_rate['method_description'] ) ) {
70
+ icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], false, $icl_language_code );
71
+ }
72
+ if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) {
73
+ icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], false, $icl_language_code );
74
+ }
75
+ }
76
+ }
77
+ }
78
+
79
+ }
80
+
81
+ }
classes/{settings-flexible-shipping.php → settings/flexible-shipping.php} RENAMED
File without changes
classes/{settings-shipping-method-form.php → settings/shipping-method-form.php} RENAMED
File without changes
classes/shipment/ajax.php CHANGED
@@ -8,7 +8,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Shipment_Ajax' ) ) {
8
 
9
  private $plugin = null;
10
 
11
- public function __construct( WPDesk_Flexible_Shipping_Free_Plugin $plugin ) {
12
  $this->plugin = $plugin;
13
  $this->hooks();
14
  }
8
 
9
  private $plugin = null;
10
 
11
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
12
  $this->plugin = $plugin;
13
  $this->hooks();
14
  }
classes/shipment/cpt-shipment.php CHANGED
@@ -6,7 +6,7 @@ class WPDesk_Flexible_Shipping_Shipment_CPT {
6
 
7
  private $plugin = null;
8
 
9
- public function __construct( WPDesk_Flexible_Shipping_Free_Plugin $plugin ) {
10
  $this->plugin = $plugin;
11
  $this->hooks();
12
  }
6
 
7
  private $plugin = null;
8
 
9
+ public function __construct( WPDesk_Flexible_Shipping_Plugin $plugin ) {
10
  $this->plugin = $plugin;
11
  $this->hooks();
12
  }
classes/shipping-method-info.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Flexible_Shipping_Info' ) ) {
8
+
9
+ class WPDesk_Flexible_Shipping_Info extends WC_Shipping_Method {
10
+
11
+ /**
12
+ * WPDesk_Flexible_Shipping_Fake_Method constructor.
13
+ *
14
+ * @param int $instance_id
15
+ */
16
+ public function __construct( $instance_id = 0 ) {
17
+ parent::__construct( $instance_id );
18
+ $this->id = 'flexible_shipping_info';
19
+ $this->enabled = 'no';
20
+ $this->method_title = __( 'Flexible Shipping', 'flexible-shipping' );
21
+
22
+ $this->supports = array(
23
+ 'settings',
24
+ );
25
+
26
+ }
27
+
28
+ /**
29
+ * @param array $form_fields
30
+ * @param bool $echo
31
+ *
32
+ * @return string
33
+ */
34
+ public function generate_settings_html( $form_fields = array(), $echo = true ) {
35
+ ob_start();
36
+ include( 'views/html-shipping-method-info-description.php' );
37
+ $html = ob_get_clean();
38
+ if ( $echo ) {
39
+ echo $html;
40
+ } else {
41
+ return $html;
42
+ }
43
+ }
44
+
45
+ }
46
+
47
+ }
classes/{shipping_method.php → shipping-method.php} RENAMED
@@ -68,7 +68,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
68
  * @return void
69
  */
70
  function init() {
71
- $this->instance_form_fields = include( 'settings-flexible-shipping.php' );
72
  // Load the settings API
73
  $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
74
  $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
@@ -169,7 +169,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
169
  if ( file_exists( $wc_template_functions ) ) {
170
  include_once( $wc_template_functions );
171
  }
172
- }
173
  ob_start();
174
  include ( 'views/html-shipping-method-rules.php' );
175
  return ob_get_clean();
@@ -180,7 +180,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
180
  * Initialise Settings Form Fields
181
  */
182
  public function init_form_fields() {
183
- $this->form_fields = include( 'settings-flexible-shipping.php' );
184
  }
185
 
186
  public function update_rates( $shipping_methods ) {
@@ -273,7 +273,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
273
  //
274
  $count = 0;
275
  $shipping_method['method_rules'] = array();
276
- if ( $_POST['method_rules'] ) {
277
  foreach ( $_POST['method_rules'] as $rule ) {
278
  $count++;
279
  $method_rule = array();
@@ -506,7 +506,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
506
  }
507
 
508
  public function get_shipping_method_form( $shipping_method ) {
509
- $this->form_fields = include( 'settings-shipping-method-form.php' );
510
  }
511
 
512
 
@@ -658,7 +658,7 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
658
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
659
  add_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
660
  }
661
- $cart_weight = WC()->cart->cart_contents_weight;
662
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
663
  remove_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
664
  }
@@ -668,9 +668,10 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
668
  /* Fix for Woocommerce 2.6 weight calculation */
669
  /* PHP Warning: A non-numeric value encountered in /wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 359 */
670
  public function woocommerce_product_weight( $weight ) {
671
- if ( $weight == '' ) {
672
  return 0;
673
  }
 
674
  }
675
 
676
  public function package_item_count( $items ) {
@@ -704,6 +705,79 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
704
  return $cost;
705
  }
706
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
707
  public function calculate_shipping( $package = array() ) {
708
  $processed = apply_filters( 'flexible_shipping_calculate_shipping', false, $this, $package, 0 );
709
 
@@ -725,29 +799,19 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
725
  }
726
 
727
  foreach ( $shipping_method['method_rules'] as $rule_key => $method_rule ) {
728
-
729
  $rule_triggered = false;
730
 
731
  if ( $method_rule['based_on'] == 'none' ) {
732
  $rule_triggered = true;
733
  }
734
 
735
- $contents_cost = 0;
736
- if ( WC()->cart->prices_include_tax ) {
737
- $taxes = array();
738
- if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
739
- $taxes = WC()->cart->taxes;
740
- $contents_cost = WC()->cart->cart_contents_total + array_sum( $taxes );
741
- }
742
- else {
743
- $taxes = WC()->cart->get_cart_contents_taxes();
744
- $contents_cost = WC()->cart->get_cart_contents_total() + array_sum( $taxes );
745
- }
746
  }
747
  else {
748
- $contents_cost = WC()->cart->cart_contents_total;
749
  }
750
-
751
  $cart_contents_cost = $contents_cost;
752
 
753
  if ( $method_rule['based_on'] == 'value' ) {
@@ -755,15 +819,14 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
755
  $min = 0;
756
  }
757
  else {
758
- $min = apply_filters( 'flexible_shipping_value_in_currency', floatval( $method_rule['min'] ) );
759
  }
760
  if ( trim( $method_rule['max'] ) == '' ) {
761
  $max = INF;
762
  }
763
  else {
764
- $max = apply_filters( 'flexible_shipping_value_in_currency', floatval( $method_rule['max'] ) );
765
  }
766
-
767
  if ( $contents_cost >= $min && $contents_cost <= $max ) {
768
  $rule_triggered = true;
769
  }
@@ -800,7 +863,6 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
800
  }
801
 
802
  $cost = $this->calculate_method_cost( $shipping_method, $rule_costs );
803
-
804
  $add_method = apply_filters( 'flexible_shipping_add_method' , $add_method, $shipping_method, $package );
805
 
806
  if ( $add_method === true ) {
@@ -899,10 +961,4 @@ if ( ! class_exists( 'WPDesk_Flexible_Shipping' ) ) {
899
 
900
  }
901
 
902
- function wpdesk_add_flexible_shipping( $methods ) {
903
- $methods['flexible_shipping'] = 'WPDesk_Flexible_Shipping';
904
- return $methods;
905
- }
906
- add_filter( 'woocommerce_shipping_methods', 'wpdesk_add_flexible_shipping', 10, 1 );
907
-
908
  }
68
  * @return void
69
  */
70
  function init() {
71
+ $this->instance_form_fields = include( 'settings/flexible-shipping.php' );
72
  // Load the settings API
73
  $this->init_form_fields(); // This is part of the settings API. Override the method to add your own settings
74
  $this->init_settings(); // This is part of the settings API. Loads settings you previously init.
169
  if ( file_exists( $wc_template_functions ) ) {
170
  include_once( $wc_template_functions );
171
  }
172
+ }
173
  ob_start();
174
  include ( 'views/html-shipping-method-rules.php' );
175
  return ob_get_clean();
180
  * Initialise Settings Form Fields
181
  */
182
  public function init_form_fields() {
183
+ $this->form_fields = include( 'settings/flexible-shipping.php' );
184
  }
185
 
186
  public function update_rates( $shipping_methods ) {
273
  //
274
  $count = 0;
275
  $shipping_method['method_rules'] = array();
276
+ if ( isset( $_POST['method_rules'] ) ) {
277
  foreach ( $_POST['method_rules'] as $rule ) {
278
  $count++;
279
  $method_rule = array();
506
  }
507
 
508
  public function get_shipping_method_form( $shipping_method ) {
509
+ $this->form_fields = include( 'settings/shipping-method-form.php' );
510
  }
511
 
512
 
658
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
659
  add_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
660
  }
661
+ $cart_weight = WC()->cart->get_cart_contents_weight();
662
  if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
663
  remove_filter( 'woocommerce_product_weight', array( $this, 'woocommerce_product_weight' ) );
664
  }
668
  /* Fix for Woocommerce 2.6 weight calculation */
669
  /* PHP Warning: A non-numeric value encountered in /wp-content/plugins/woocommerce/includes/class-wc-cart.php on line 359 */
670
  public function woocommerce_product_weight( $weight ) {
671
+ if ( $weight === '' ) {
672
  return 0;
673
  }
674
+ return $weight;
675
  }
676
 
677
  public function package_item_count( $items ) {
705
  return $cost;
706
  }
707
 
708
+ public function cart_display_prices_including_tax() {
709
+ if ( version_compare( WC_VERSION, '3.3', '<' ) ) {
710
+ $display_prices_including_tax = 'incl' === WC()->cart->tax_display_cart;
711
+ }
712
+ else {
713
+ $display_prices_including_tax = WC()->cart->display_prices_including_tax();
714
+ }
715
+ return $display_prices_including_tax;
716
+ }
717
+
718
+ /**
719
+ * @return int
720
+ */
721
+ public function contents_cost_with_tax() {
722
+ $display_prices_including_tax = $this->cart_display_prices_including_tax();
723
+ if ( $display_prices_including_tax ) {
724
+ $total = WC()->cart->get_displayed_subtotal();
725
+ }
726
+ else {
727
+ if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
728
+ $total = WC()->cart->subtotal;
729
+ }
730
+ else {
731
+ $total = WC()->cart->get_displayed_subtotal() + WC()->cart->get_subtotal_tax();
732
+ }
733
+ }
734
+ if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
735
+ $total_discount = WC()->cart->discount_cart + WC()->cart->discount_cart_tax;
736
+ }
737
+ else {
738
+ $total_discount = WC()->cart->get_cart_discount_total() + WC()->cart->get_cart_discount_tax_total();
739
+ }
740
+ $total = round( $total - $total_discount, wc_get_price_decimals() );
741
+ return $total;
742
+ }
743
+
744
+ /**
745
+ * @return int
746
+ */
747
+ public function contents_cost_without_tax() {
748
+ $display_prices_including_tax = $this->cart_display_prices_including_tax();
749
+ $total = WC()->cart->get_displayed_subtotal();
750
+ if ( $display_prices_including_tax ) {
751
+ if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
752
+ $total = WC()->cart->subtotal_ex_tax;
753
+ }
754
+ else {
755
+ $total = $total - WC()->cart->get_subtotal_tax();
756
+ }
757
+ }
758
+ if ( version_compare( WC_VERSION, '3.2', '<' ) ) {
759
+ $discount_without_tax = WC()->cart->discount_cart;
760
+ }
761
+ else {
762
+ $discount_without_tax = WC()->cart->get_cart_discount_total();
763
+ }
764
+ $total = round( $total - $discount_without_tax, wc_get_price_decimals() );
765
+ return $total;
766
+ }
767
+
768
+ public function prices_include_tax() {
769
+ if ( version_compare( WC_VERSION, '3.3', '<' ) ) {
770
+ $prices_include_tax = 'incl' === WC()->cart->tax_display_cart;
771
+ }
772
+ else {
773
+ $prices_include_tax = WC()->cart->display_prices_including_tax();
774
+ }
775
+ return apply_filters( 'flexible_shipping_prices_include_tax', $prices_include_tax );
776
+ }
777
+
778
+ /**
779
+ * @param array $package
780
+ */
781
  public function calculate_shipping( $package = array() ) {
782
  $processed = apply_filters( 'flexible_shipping_calculate_shipping', false, $this, $package, 0 );
783
 
799
  }
800
 
801
  foreach ( $shipping_method['method_rules'] as $rule_key => $method_rule ) {
 
802
  $rule_triggered = false;
803
 
804
  if ( $method_rule['based_on'] == 'none' ) {
805
  $rule_triggered = true;
806
  }
807
 
808
+ $prices_include_tax = $this->prices_include_tax();
809
+ if ( $prices_include_tax ) {
810
+ $contents_cost = $this->contents_cost_with_tax();
 
 
 
 
 
 
 
 
811
  }
812
  else {
813
+ $contents_cost = $this->contents_cost_without_tax();
814
  }
 
815
  $cart_contents_cost = $contents_cost;
816
 
817
  if ( $method_rule['based_on'] == 'value' ) {
819
  $min = 0;
820
  }
821
  else {
822
+ $min = floatval( apply_filters( 'flexible_shipping_value_in_currency', floatval( $method_rule['min'] ) ) );
823
  }
824
  if ( trim( $method_rule['max'] ) == '' ) {
825
  $max = INF;
826
  }
827
  else {
828
+ $max = floatval( apply_filters( 'flexible_shipping_value_in_currency', floatval( $method_rule['max'] ) ) );
829
  }
 
830
  if ( $contents_cost >= $min && $contents_cost <= $max ) {
831
  $rule_triggered = true;
832
  }
863
  }
864
 
865
  $cost = $this->calculate_method_cost( $shipping_method, $rule_costs );
 
866
  $add_method = apply_filters( 'flexible_shipping_add_method' , $add_method, $shipping_method, $package );
867
 
868
  if ( $add_method === true ) {
961
 
962
  }
963
 
 
 
 
 
 
 
964
  }
classes/views/html-ads.php CHANGED
@@ -12,9 +12,8 @@
12
  <ul>
13
  <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Shipping Classes support', 'flexible-shipping' ); ?></li>
14
  <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Product count based costs', 'flexible-shipping' ); ?></li>
15
- <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Stopping a rule', 'flexible-shipping' ); ?></li>
16
- <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Cancelling a rule', 'flexible-shipping' ); ?></li>
17
- <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Additional calculation methods (sum, lowest cost, highest cost)', 'flexible-shipping' ); ?></li>
18
  </ul>
19
 
20
  <a class="button button-primary" href="<?php echo $fs_link; ?>?utm_source=flexible-shipping-settings&utm_medium=button&utm_campaign=flexible-shipping-pro-plugin" target="_blank"><?php _e( 'Upgrade Now &rarr;', 'flexible-shipping' ); ?></a>
12
  <ul>
13
  <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Shipping Classes support', 'flexible-shipping' ); ?></li>
14
  <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Product count based costs', 'flexible-shipping' ); ?></li>
15
+ <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Stopping, Cancelling a rule', 'flexible-shipping' ); ?></li>
16
+ <li><span class="dashicons dashicons-yes"></span> <?php _e( 'Additional calculation methods', 'flexible-shipping' ); ?></li>
 
17
  </ul>
18
 
19
  <a class="button button-primary" href="<?php echo $fs_link; ?>?utm_source=flexible-shipping-settings&utm_medium=button&utm_campaign=flexible-shipping-pro-plugin" target="_blank"><?php _e( 'Upgrade Now &rarr;', 'flexible-shipping' ); ?></a>
classes/views/html-shipping-method-info-description.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $pl = get_locale() === 'pl_PL';
3
+ $youtube_url = 'https://www.youtube.com/embed/qsFvYoiNDgU';
4
+ $general_settings_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=general-settings#Ustawienia_glowne' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=general-settings#General_Settings';
5
+ $adding_a_shipping_method_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=adding-a-shipping-method#Metody_wysylki' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=adding-a-shipping-method#Shipping_Methods';
6
+ $currency_support_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=currency-support#Waluty' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=currency-support#Currency_Support';
7
+ $weight_based_shipping_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=weight-based-shipping#Koszt_na_wage' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=weight-based-shipping#Weight_Based_Shipping';
8
+ $shipping_insurance_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=shipping-insurance#Ubezpieczenie_przesylki' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=shipping-insurance#Shipping_Insurance';
9
+ $conditional_cash_on_delivery_url = $pl ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=conditional-cash-on-delivery#Przesylka_za_pobraniem' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/?utm_source=flexible-shipping-info&utm_medium=link&utm_campaign=flexible-shipping-resources-box&utm_content=conditional-cash-on-delivery#Conditional_Cash_on_Delivery';
10
+ ?>
11
+ </table>
12
+
13
+ <div class="inspire-settings flexible-shipping-info">
14
+ <div class="inspire-main-content">
15
+ <ol>
16
+ <li>
17
+ <?php
18
+ echo sprintf(
19
+ __( 'To add first Flexible Shipping method go to %sShipping zones%s and add Flexible Shipping to a shipping zone.', 'flexible-shipping' ),
20
+ '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping&section' ) . '">',
21
+ '</a>'
22
+ );
23
+ ?>
24
+ </li>
25
+
26
+ <li><?php _e( 'You can start the configuration by clicking the Flexible Shipping link in the Shipping methods table.', 'flexible-shipping' ); ?></li>
27
+ </ol>
28
+
29
+ <h4><?php _e( 'Quick Video Overview', 'flexible-shipping' ); ?></h4>
30
+
31
+ <div class="flexible-shipping-video">
32
+ <?php /* <iframe src="<?php echo $youtube_url?>" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen class="flexible-shipping-video"></iframe> */ ?>
33
+ <iframe width="720" height="405" src="<?php echo $youtube_url?>?rel=0&amp;showinfo=0" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="inspire-sidebar">
38
+ <div class="metabox-holder">
39
+ <div class="stuffbox">
40
+ <h3 class="hndle"><?php _e( 'More resources', 'flexible-shipping' ); ?></h3>
41
+
42
+ <div class="inside">
43
+ <ul>
44
+ <li><a href="<?php echo $general_settings_url; ?>"><?php _e( 'General Settings', 'flexible-shipping' ); ?></a></li>
45
+ <li><a href="<?php echo $adding_a_shipping_method_url; ?>"><?php _e( 'Adding a shipping method', 'flexible-shipping' ); ?></a></li>
46
+ <li><a href="<?php echo $currency_support_url; ?>"><?php _e( 'Currency Support', 'flexible-shipping' ); ?></a></li>
47
+ <li><a href="<?php echo $weight_based_shipping_url; ?>"><?php _e( 'Weight Based Shipping', 'flexible-shipping' ); ?></a></li>
48
+ <li><a href="<?php echo $shipping_insurance_url; ?>"><?php _e( 'Shipping Insurance', 'flexible-shipping' ); ?></a></li>
49
+ <li><a href="<?php echo $conditional_cash_on_delivery_url; ?>"><?php _e( 'Conditional Cash on Delivery', 'flexible-shipping' ); ?></a></li>
50
+ </ul>
51
+ </div>
52
+ </div>
53
+ </div>
54
+ </div>
55
+ </div>
56
+
57
+ <script type="text/javascript">
58
+ jQuery(document).ready(function() {
59
+ jQuery('.woocommerce-save-button').hide();
60
+ })
61
+ </script>
62
+ <table>
classes/views/html-shipping-method-rules.php CHANGED
@@ -75,11 +75,11 @@
75
  </th>
76
  <th class="min">
77
  <?php _e( 'Min', 'flexible-shipping' ); ?>
78
- <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter minimum value for the &quot;Based on&quot; parameter.', 'flexible-shipping' ); ?>"></span>
79
  </th>
80
  <th class="max">
81
  <?php _e( 'Max', 'flexible-shipping' ); ?>
82
- <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter maximum value for the &quot;Based on&quot; parameter.', 'flexible-shipping' ); ?>"></span>
83
  </th>
84
  <th class="cost_per_order">
85
  <?php _e( 'Cost per<br/>order', 'flexible-shipping' ); ?>
75
  </th>
76
  <th class="min">
77
  <?php _e( 'Min', 'flexible-shipping' ); ?>
78
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter minimum value for the &quot;Based on&quot; parameter. Value based on the price will be calculated by WooCommerce tax settings &quot;Display prices during cart and checkout&quot;', 'flexible-shipping' ); ?>"></span>
79
  </th>
80
  <th class="max">
81
  <?php _e( 'Max', 'flexible-shipping' ); ?>
82
+ <span class="woocommerce-help-tip" data-tip="<?php _e( 'Enter maximum value for the &quot;Based on&quot; parameter. Value based on the price will be calculated by WooCommerce tax settings &quot;Display prices during cart and checkout&quot;', 'flexible-shipping' ); ?>"></span>
83
  </th>
84
  <th class="cost_per_order">
85
  <?php _e( 'Cost per<br/>order', 'flexible-shipping' ); ?>
classes/wpdesk/assets/css/admin-settings.css ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Added by WP Desk - Reset some default WP styles
2
+ -------------------------------------------------------------- */
3
+ .select2-container li {
4
+ margin-bottom: 0;
5
+ }
6
+
7
+ /* Added by WP Desk - Select2 Columns Draggable/Sortable
8
+ -------------------------------------------------------------- */
9
+ .select-2-columns .available-column,
10
+ .select-2-columns .selected-column {
11
+ background-color: #fff;
12
+ border: 1px solid #e5e5e5;
13
+ float: left;
14
+ margin-right: 20px;
15
+ padding: 12px 14px;
16
+ max-width: 450px;
17
+ }
18
+
19
+ .select-2-columns > div > strong {
20
+ display: block;
21
+ margin-bottom: 10px;
22
+ }
23
+
24
+ .select-2-columns ul {
25
+ margin: 0;
26
+ min-height: 50px;
27
+ min-width: 200px;
28
+ }
29
+
30
+ .select-2-columns li {
31
+ background-color: #fafafa;
32
+ border: 1px solid #e5e5e5;
33
+ cursor: move;
34
+ padding: 5px 10px;
35
+ }
36
+
37
+ .select-2-columns li:hover {
38
+ border-color: #999;
39
+ }
40
+
41
+ .select-2-columns .ui-sortable-placeholder {
42
+ background-color: transparent;
43
+ border:1px dashed #b4b9be;
44
+ visibility: visible !important;
45
+ }
46
+
47
+
48
+ /* Fix color picker label alignment
49
+ -------------------------------------------------------------- */
50
+ .s214-color-picker-label {
51
+ position: absolute;
52
+ display: inline-block;
53
+ padding-top: 4px;
54
+ }
55
+
56
+ /* System info styles
57
+ -------------------------------------------------------------- */
58
+ #system-info-textarea {
59
+ width: 800px;
60
+ height: 400px;
61
+ font-family: Menlo, Monaco, monospace;
62
+ background: none;
63
+ white-space: pre;
64
+ overflow: auto;
65
+ display: block;
66
+ }
67
+
68
+ /* Tooltips
69
+ -------------------------------------------------------------- */
70
+ .s214-help-tip {
71
+ cursor: help;
72
+ }
73
+
74
+ .ui-tooltip {
75
+ background: #333 !important;
76
+ border-radius: 3px !important;
77
+ box-shadow: 1px 1px 2px 1px rgba(214,214,214,0.5);
78
+ color: #dedede !important;
79
+ max-width: 300px;
80
+ padding: 7px;
81
+ text-rendering: optimizeLegibility;
82
+ }
classes/wpdesk/assets/css/admin-settings.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .select2-container li{margin-bottom:0}.select-2-columns .available-column,.select-2-columns .selected-column{background-color:#fff;border:1px solid #e5e5e5;float:left;margin-right:20px;padding:12px 14px;max-width:450px}.select-2-columns>div>strong{display:block;margin-bottom:10px}.select-2-columns ul{margin:0;min-height:50px;min-width:200px}.select-2-columns li{background-color:#fafafa;border:1px solid #e5e5e5;cursor:move;padding:5px 10px}.select-2-columns li:hover{border-color:#999}.select-2-columns .ui-sortable-placeholder{background-color:transparent;border:1px dashed #b4b9be;visibility:visible !important}.s214-color-picker-label{position:absolute;display:inline-block;padding-top:4px}#system-info-textarea{width:800px;height:400px;font-family:Menlo,Monaco,monospace;background:0;white-space:pre;overflow:auto;display:block}.s214-help-tip{cursor:help}.ui-tooltip{background:#333 !important;border-radius:3px !important;box-shadow:1px 1px 2px 1px rgba(214,214,214,0.5);color:#dedede !important;max-width:300px;padding:7px;text-rendering:optimizeLegibility}
classes/wpdesk/assets/js/admin-settings.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global jQuery, document, window, wp, CodeMirror, s214_settings_vars*/
2
+ jQuery(document).ready(function ($) {
3
+ 'use strict';
4
+
5
+ // Setup color picker
6
+ if ($('.s214-color-picker').length) {
7
+ $('.s214-color-picker').wpColorPicker();
8
+ }
9
+
10
+ // Setup select2
11
+ if ($('.s214-select2').length) {
12
+ $('.s214-select2').select2();
13
+ }
14
+
15
+ // Setup CodeMirror
16
+ if ($('.s214-html').length) {
17
+ $('.s214-html').each(function (index, elem) {
18
+ CodeMirror.fromTextArea(elem, {
19
+ lineNumbers: true,
20
+ mode: 'text/html',
21
+ showCursorWhenSelecting: true
22
+ });
23
+ });
24
+ }
25
+
26
+ // Setup tooltips
27
+ $('.s214-help-tip').tooltip({
28
+ content: function () {
29
+ return $(this).prop('title');
30
+ },
31
+ position: {
32
+ my: 'center top',
33
+ at: 'center bottom+10',
34
+ collision: 'flipfit'
35
+ },
36
+ hide: {
37
+ duration: 200
38
+ },
39
+ show: {
40
+ duration: 200
41
+ }
42
+ });
43
+
44
+ // Setup uploaders
45
+ if ($('.' + s214_settings_vars.func + '_settings_upload_button').length) {
46
+ var file_frame;
47
+
48
+ $('body').on('click', '.' + s214_settings_vars.func + '_settings_upload_button', function (e) {
49
+ e.preventDefault();
50
+
51
+ var button = $(this);
52
+
53
+ window.formfield = $(this).parent().prev();
54
+
55
+ // If the media frame already exists, reopen it
56
+ if (file_frame) {
57
+ file_frame.open();
58
+ return;
59
+ }
60
+
61
+ // Create the media frame
62
+ wp.media.frames.file_frame = wp.media({
63
+ frame: 'post',
64
+ state: 'insert',
65
+ title: button.data('uploader_title'),
66
+ button: {
67
+ text: button.data('uploader_button_text')
68
+ },
69
+ multiple: false
70
+ });
71
+
72
+ file_frame = wp.media.frames.file_frame;
73
+
74
+ file_frame.on('menu:render:default', function (view) {
75
+ // Store our views in an object
76
+ var views = {};
77
+
78
+ // Unset default menu items
79
+ view.unset('library-separator');
80
+ view.unset('gallery');
81
+ view.unset('featured-image');
82
+ view.unset('embed');
83
+
84
+ // Initialize the views in our object
85
+ view.set(views);
86
+ });
87
+
88
+ // Run a callback on select
89
+ file_frame.on('insert', function () {
90
+ var selection = file_frame.state().get('selection');
91
+
92
+ selection.each(function (attachment) {
93
+ attachment = attachment.toJSON();
94
+ window.formfield.val(attachment.url);
95
+ });
96
+ });
97
+
98
+ // Open the modal
99
+ file_frame.open();
100
+ });
101
+
102
+ window.formfield = '';
103
+ }
104
+ });
classes/wpdesk/assets/js/admin-settings.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(b){if(b(".s214-color-picker").length){b(".s214-color-picker").wpColorPicker()}if(b(".s214-select2").length){b(".s214-select2").select2()}if(b(".s214-html").length){b(".s214-html").each(function(c,d){CodeMirror.fromTextArea(d,{lineNumbers:true,mode:"text/html",showCursorWhenSelecting:true})})}b(".s214-help-tip").tooltip({content:function(){return b(this).prop("title")},position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}});if(b("."+s214_settings_vars.func+"_settings_upload_button").length){var a;b("body").on("click","."+s214_settings_vars.func+"_settings_upload_button",function(d){d.preventDefault();var c=b(this);window.formfield=b(this).parent().prev();if(a){a.open();return}wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:c.data("uploader_title"),button:{text:c.data("uploader_button_text")},multiple:false});a=wp.media.frames.file_frame;a.on("menu:render:default",function(f){var e={};f.unset("library-separator");f.unset("gallery");f.unset("featured-image");f.unset("embed");f.set(e)});a.on("insert",function(){var e=a.state().get("selection");e.each(function(f){f=f.toJSON();window.formfield.val(f.url)})});a.open()});window.formfield=""}});
classes/wpdesk/class-helper.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Helper_Plugin' ) ) {
8
+
9
+ class WPDesk_Helper_Plugin {
10
+
11
+ /** @var array */
12
+ protected $plugin_data;
13
+
14
+ /** @var string */
15
+ protected $text_domain;
16
+
17
+ /** @var string */
18
+ protected $ame_activated_key;
19
+
20
+ /** @var string */
21
+ protected $ame_activation_tab_key;
22
+
23
+ /**
24
+ * @param array $plugin_data
25
+ */
26
+ function __construct( $plugin_data ) {
27
+ global $wpdesk_helper_plugins;
28
+
29
+ $this->plugin_data = $plugin_data;
30
+ if ( ! isset( $wpdesk_helper_plugins ) ) {
31
+ $wpdesk_helper_plugins = array();
32
+ }
33
+ $plugin_data['helper_plugin'] = $this;
34
+ $wpdesk_helper_plugins[] = $plugin_data;
35
+
36
+ $this->ame_activated_key = 'api_' . dirname( $plugin_data['plugin'] ) . '_activated';
37
+ $this->ame_activation_tab_key = 'api_' . dirname( $plugin_data['plugin'] ) . '_dashboard';
38
+
39
+ }
40
+
41
+ /**
42
+ * @return void
43
+ */
44
+ public function inactive_notice() { ?>
45
+ <?php if ( ! current_user_can( 'manage_options' ) ) {
46
+ return;
47
+ } ?>
48
+ <?php if ( 1 == 1 && isset( $_GET['page'] ) && $this->ame_activation_tab_key == $_GET['page'] ) {
49
+ return;
50
+ } ?>
51
+ <div class="update-nag">
52
+ <?php printf( __( 'The %s%s%s License Key has not been activated, so the plugin is inactive! %sClick here%s to activate the license key and the plugin.', 'wpdesk-plugin' ), '<strong>', $this->plugin_data['product_id'], '</strong>', '<a href="' . esc_url( admin_url( 'admin.php?page=' . $this->ame_activation_tab_key ) ) . '">', '</a>' ); ?>
53
+ </div>
54
+ <?php
55
+ }
56
+
57
+ /**
58
+ * @param bool $add_notice
59
+ *
60
+ * @return bool
61
+ */
62
+ function is_active( $add_notice = false ) {
63
+ if ( get_option( $this->ame_activated_key, '0' ) != 'Activated' ) {
64
+ if ( $add_notice ) {
65
+ add_action( 'admin_notices', array( $this, 'inactive_notice' ) );
66
+ }
67
+
68
+ return false;
69
+ } else {
70
+ return true;
71
+ }
72
+ }
73
+
74
+ }
75
+ }
classes/wpdesk/class-plugin.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ require_once 'functions.php';
8
+
9
+ if ( ! class_exists( 'WPDesk_Plugin_1_10' ) ) {
10
+
11
+ require_once 'class-settings.php';
12
+
13
+ /**
14
+ * Base plugin class for WP Desk plugins
15
+ *
16
+ * @author Grzegorz
17
+ *
18
+ */
19
+ class WPDesk_Plugin_1_10 {
20
+
21
+ const VERSION = '1.10';
22
+
23
+ /** @var bool */
24
+ protected $plugin_is_active = true;
25
+
26
+ /** @var array */
27
+ protected $default_view_args;
28
+
29
+ /** @var string */
30
+ public $plugin_namespace = 'wpdesk_plugin';
31
+
32
+ /** @var string */
33
+ public $plugin_text_domain = 'wpdesk-plugin';
34
+
35
+ /** @var bool */
36
+ public $plugin_has_settings = false;
37
+
38
+ /** @var string */
39
+ public $plugin_path;
40
+
41
+ /** @var string */
42
+ public $template_path;
43
+
44
+ /** @var string */
45
+ public $plugin_file_path;
46
+
47
+ /** @var string */
48
+ public $plugin_url;
49
+
50
+ /** @var bool */
51
+ public $settings_url = false;
52
+
53
+ /** @var bool */
54
+ public $docs_url = false;
55
+
56
+ /** @var string */
57
+ public $default_settings_tab = 'general';
58
+
59
+ public $settings_hooks = null;
60
+
61
+ /** @var WPDesk_Settings_1_10 */
62
+ public $settings = null;
63
+
64
+ /** @var array */
65
+ public $options = null;
66
+
67
+ protected function __construct( $base_file, $plugin_data = false ) {
68
+ $this->init_base_variables( $base_file );
69
+ if ( $this->plugin_is_active ) {
70
+ if ( $this->plugin_has_settings ) {
71
+ $this->settings = new WPDesk_Settings_1_10( $this, $this->get_namespace(), $this->default_settings_tab );
72
+ $this->options = $this->settings->get_settings();
73
+ }
74
+ }
75
+ $this->hooks();
76
+ }
77
+
78
+ /**
79
+ * @return bool
80
+ */
81
+ public function plugin_is_active() {
82
+ return $this->plugin_is_active;
83
+ }
84
+
85
+ /**
86
+ * @return WPDesk_Settings_1_10
87
+ */
88
+ public function get_settings() {
89
+ return $this->settings;
90
+ }
91
+
92
+ /**
93
+ * @param $key
94
+ * @param $default
95
+ *
96
+ * @return mixed
97
+ */
98
+ public function get_option( $key, $default ) {
99
+ return $this->settings->get_option( $key, $default );
100
+ }
101
+
102
+ /**
103
+ * @return $this
104
+ */
105
+ public function get_plugin() {
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * @return string
111
+ */
112
+ public function get_text_domain() {
113
+ return $this->plugin_text_domain;
114
+ }
115
+
116
+ /**
117
+ * @return void
118
+ */
119
+ public function load_plugin_text_domain() {
120
+ $wpdesk_translation = load_plugin_textdomain( 'wpdesk-plugin', false, $this->get_namespace() . '/classes/wpdesk/lang/' );
121
+ $plugin_translation = load_plugin_textdomain( $this->get_text_domain(), false, $this->get_namespace() . '/lang/' );
122
+ }
123
+
124
+ /**
125
+ * @param string $base_file
126
+ */
127
+ public function init_base_variables( $base_file ) {
128
+ // Set Plugin Path
129
+ $this->plugin_path = dirname( $base_file );
130
+
131
+ // Set Plugin URL
132
+ $this->plugin_url = plugin_dir_url( $base_file );
133
+
134
+ $this->plugin_file_path = $base_file;
135
+
136
+ $this->template_path = $this->get_namespace();
137
+
138
+ $this->default_view_args = array(
139
+ 'plugin_url' => $this->get_plugin_url()
140
+ );
141
+
142
+ }
143
+
144
+ /**
145
+ * @return void
146
+ */
147
+ public function hooks() {
148
+
149
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
150
+
151
+ add_action( 'wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ) );
152
+
153
+ add_action( 'plugins_loaded', array( $this, 'load_plugin_text_domain' ) );
154
+
155
+ add_filter( 'plugin_action_links_' . plugin_basename( $this->get_plugin_file_path() ), array(
156
+ $this,
157
+ 'links_filter'
158
+ ) );
159
+
160
+ }
161
+
162
+ /**
163
+ *
164
+ * @return string
165
+ */
166
+ public function get_plugin_url() {
167
+ return esc_url( trailingslashit( $this->plugin_url ) );
168
+ }
169
+
170
+ public function get_plugin_assets_url() {
171
+ return esc_url( trailingslashit( $this->get_plugin_url() . 'assets' ) );
172
+ }
173
+
174
+ /**
175
+ * @return string
176
+ */
177
+ public function get_template_path() {
178
+ return trailingslashit( $this->template_path );
179
+ }
180
+
181
+ /**
182
+ * @return string
183
+ */
184
+ public function get_plugin_file_path() {
185
+ return $this->plugin_file_path;
186
+ }
187
+
188
+ /**
189
+ * @return string
190
+ */
191
+ public function get_namespace() {
192
+ return $this->plugin_namespace;
193
+ }
194
+
195
+ /**
196
+ * @return null
197
+ */
198
+ public function get_settings_hooks() {
199
+ return $this->settings_hooks;
200
+ }
201
+
202
+
203
+ /**
204
+ * Renders end returns selected template
205
+ *
206
+ * @param string $name name of the template
207
+ * @param string $path additional inner path to the template
208
+ * @param array $args args accesible from template
209
+ *
210
+ * @return string
211
+ */
212
+ public function load_template( $name, $path = '', $args = array() ) {
213
+ $plugin_template_path = trailingslashit( $this->plugin_path ) . 'templates/';
214
+
215
+ // Look within passed path within the theme - this is priority.
216
+ $template = locate_template(
217
+ array(
218
+ trailingslashit( $this->get_template_path() ) . trailingslashit( $path ) . $name . '.php',
219
+ )
220
+ );
221
+
222
+ if ( ! $template ) {
223
+ $template = $plugin_template_path . trailingslashit( $path ) . $name . '.php';
224
+ }
225
+
226
+ extract( $args );
227
+ ob_start();
228
+ include( $template );
229
+
230
+ return ob_get_clean();
231
+ }
232
+
233
+
234
+ public function admin_enqueue_scripts( $hooq ) {
235
+ }
236
+
237
+ public function wp_enqueue_scripts() {
238
+ }
239
+
240
+ /**
241
+ * action_links function.
242
+ *
243
+ * @access public
244
+ *
245
+ * @param mixed $links
246
+ *
247
+ * @return array
248
+ */
249
+ public function links_filter( $links ) {
250
+
251
+ $support_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/support/' : 'https://www.wpdesk.net/support';
252
+
253
+ $plugin_links = array(
254
+ '<a href="' . $support_link . '">' . __( 'Support', 'wpdesk-plugin' ) . '</a>',
255
+ );
256
+ $links = array_merge( $plugin_links, $links );
257
+
258
+ if ( $this->docs_url ) {
259
+ $plugin_links = array(
260
+ '<a href="' . $this->docs_url . '">' . __( 'Docs', 'wpdesk-plugin' ) . '</a>',
261
+ );
262
+ $links = array_merge( $plugin_links, $links );
263
+ }
264
+
265
+ if ( $this->settings_url ) {
266
+ $plugin_links = array(
267
+ '<a href="' . $this->settings_url . '">' . __( 'Settings', 'wpdesk-plugin' ) . '</a>',
268
+ );
269
+ $links = array_merge( $plugin_links, $links );
270
+ }
271
+
272
+ return $links;
273
+ }
274
+
275
+ }
276
+
277
+ }
classes/wpdesk/class-requirement-checker.php ADDED
@@ -0,0 +1,356 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Requirement_Checker_1_10' ) ) {
8
+ /**
9
+ * Checks requirements for plugin
10
+ * have to be compatible with PHP 5.2.x
11
+ */
12
+ class WPDesk_Requirement_Checker_1_10 {
13
+
14
+ const HOOK_PRIORITY_LOAD_AS_FIRST = -10;
15
+
16
+ /** @var string */
17
+ private $plugin_name = '';
18
+
19
+ /** @var string */
20
+ private $plugin_file = '';
21
+
22
+ /** @var string */
23
+ private $min_php_version;
24
+
25
+ /** @var string */
26
+ private $min_wp_version;
27
+
28
+ /** @var string */
29
+ private $min_wc_version;
30
+
31
+ /** @var array */
32
+ private $plugin_require;
33
+
34
+ /** @var array */
35
+ private $module_require;
36
+
37
+ /** @var array */
38
+ private $setting_require;
39
+
40
+ /** @var array */
41
+ private $notices;
42
+
43
+ /**
44
+ * @param $plugin_file
45
+ * @param $php_version
46
+ * @param $wp_version
47
+ * @param string|null $wc_version
48
+ */
49
+ public function __construct( $plugin_file, $php_version, $wp_version, $wc_version = null ) {
50
+ $this->plugin_file = $plugin_file;
51
+ $this->plugin_name = $this->extract_plugin_title_from_header( $plugin_file );
52
+ $this->set_min_php_require( $php_version );
53
+ $this->set_min_wp_require( $wp_version );
54
+ $this->set_min_wc_require( $wc_version );
55
+
56
+ $this->plugin_require = array();
57
+ $this->module_require = array();
58
+ $this->setting_require = array();
59
+ $this->notices = array();
60
+ }
61
+
62
+ /**
63
+ * Should be used when you want to check if others plugin are loaded (WC for example)
64
+ */
65
+ public function check_requirements_and_load_plugin_deferred() {
66
+ add_action( "plugins_loaded", array( $this, "check_requirements_and_load_plugin" ), self::HOOK_PRIORITY_LOAD_AS_FIRST );
67
+ }
68
+
69
+ /**
70
+ * Checks if requirements are met and loads bootstrap
71
+ */
72
+ public function check_requirements_and_load_plugin() {
73
+ if ( $this->is_requirements_met() ) {
74
+ require_once plugin_dir_path( $this->plugin_file ) . DIRECTORY_SEPARATOR . 'bootstrap.php';
75
+ } else {
76
+ $this->disable_plugin_render_notice();
77
+ }
78
+ }
79
+
80
+ /**
81
+ * @param string $version
82
+ *
83
+ * @return $this
84
+ */
85
+ public function set_min_php_require( $version ) {
86
+ $this->min_php_version = $version;
87
+
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * @param string $version
93
+ *
94
+ * @return $this
95
+ */
96
+ public function set_min_wp_require( $version ) {
97
+ $this->min_wp_version = $version;
98
+
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * @param string $version
104
+ *
105
+ * @return $this
106
+ */
107
+ public function set_min_wc_require( $version ) {
108
+ $this->min_wc_version = $version;
109
+
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * @param string $plugin_name
115
+ * @param string $nice_plugin_name Nice plugin name for better looks in notice
116
+ *
117
+ * @return $this
118
+ */
119
+ public function add_plugin_require( $plugin_name, $nice_plugin_name = null ) {
120
+ if ( is_null( $nice_plugin_name ) ) {
121
+ $this->plugin_require[ $plugin_name ] = $plugin_name;
122
+ } else {
123
+ $this->plugin_require[ $plugin_name ] = $nice_plugin_name;
124
+ }
125
+
126
+ return $this;
127
+ }
128
+
129
+ /**
130
+ * @param string $module_name
131
+ * @param string $nice_name Nice module name for better looks in notice
132
+ *
133
+ * @return $this
134
+ */
135
+ public function add_php_module_require( $module_name, $nice_name = null ) {
136
+ if ( is_null( $nice_name ) ) {
137
+ $this->module_require[ $module_name ] = $module_name;
138
+ } else {
139
+ $this->module_require[ $module_name ] = $nice_name;
140
+ }
141
+
142
+ return $this;
143
+ }
144
+
145
+ /**
146
+ * @param string $setting
147
+ * @param mixed $value
148
+ *
149
+ * @return $this
150
+ */
151
+ public function add_php_setting_require( $setting, $value ) {
152
+ $this->setting_require[ $setting ] = $value;
153
+
154
+ return $this;
155
+ }
156
+
157
+ /**
158
+ * @param string $file
159
+ *
160
+ * @return string mixed
161
+ */
162
+ private function extract_plugin_title_from_header( $file ) {
163
+ $plugin_data = get_file_data( $file, array(
164
+ 'title' => 'Plugin Name'
165
+ ) );
166
+
167
+ return $plugin_data['title'];
168
+ }
169
+
170
+ /**
171
+ * @return bool
172
+ */
173
+ public function is_requirements_met() {
174
+ $this->notices = $this->prepare_requirement_notices();
175
+
176
+ return count( $this->notices ) === 0;
177
+ }
178
+
179
+ /**
180
+ * @return array
181
+ */
182
+ private function prepare_requirement_notices() {
183
+ $notices = array();
184
+ if ( ! $this->is_php_at_least( $this->min_php_version ) ) {
185
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run on PHP versions older than %s. Please contact your host and ask them to upgrade.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), $this->min_php_version ) );
186
+ }
187
+ if ( ! $this->is_wp_at_least( $this->min_wp_version ) ) {
188
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run on WordPress versions older than %s. Please update WordPress.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), $this->min_wp_version ) );
189
+ }
190
+ if ( ! is_null( $this->min_wc_version ) && ! $this->is_wc_at_least( $this->min_wc_version ) ) {
191
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run on WooCommerce versions older than %s. Please update WooCommerce.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), $this->min_wc_version ) );
192
+ }
193
+ $notices = $this->append_plugin_require_notices( $notices );
194
+ $notices = $this->append_module_require_notices( $notices );
195
+ $notices = $this->append_settings_require_notices( $notices );
196
+
197
+ return $notices;
198
+ }
199
+
200
+ /**
201
+ * @param array $notices
202
+ *
203
+ * @return array
204
+ */
205
+ private function append_module_require_notices( $notices ) {
206
+ if ( count( $this->module_require ) > 0 ) {
207
+ foreach ( $this->module_require as $module_name => $nice_module_name ) {
208
+ if ( ! $this->is_module_active( $module_name ) ) {
209
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run without %s php module installed. Please contact your host and ask them to install %s.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), esc_html( basename( $nice_module_name ) ), esc_html( basename( $nice_module_name ) ) ) );
210
+ }
211
+ }
212
+ }
213
+
214
+ return $notices;
215
+ }
216
+
217
+ /**
218
+ * @param array $notices
219
+ *
220
+ * @return array
221
+ */
222
+ private function append_settings_require_notices( $notices ) {
223
+ if ( count( $this->setting_require ) > 0 ) {
224
+ foreach ( $this->setting_require as $setting => $value ) {
225
+ if ( ! $this->is_setting_set( $setting, $value ) ) {
226
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run without %s php setting set to %s. Please contact your host and ask them to set %s.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), esc_html( basename( $setting ) ), esc_html( basename( $value ) ), esc_html( basename( $setting ) ) ) );
227
+ }
228
+ }
229
+ }
230
+
231
+ return $notices;
232
+ }
233
+
234
+ /**
235
+ * @param array $notices
236
+ *
237
+ * @return array
238
+ */
239
+ private function append_plugin_require_notices( $notices ) {
240
+ if ( count( $this->plugin_require ) > 0 ) {
241
+ foreach ( $this->plugin_require as $plugin_name => $nice_plugin_name ) {
242
+ if ( ! $this->is_wp_plugin_active( $plugin_name ) ) {
243
+ $notices[] = $this->prepare_notice_message( sprintf( __( 'The &#8220;%s&#8221; plugin cannot run without %s active. Please install and activate %s plugin.', 'wpdesk-plugin' ), esc_html( $this->plugin_name ), esc_html( basename( $nice_plugin_name ) ), esc_html( basename( $nice_plugin_name ) ) ) );
244
+ }
245
+ }
246
+ }
247
+
248
+ return $notices;
249
+ }
250
+
251
+ /**
252
+ * @param string $name
253
+ * @param mixed $value
254
+ *
255
+ * @return bool
256
+ */
257
+ public static function is_setting_set( $name, $value ) {
258
+ return ini_get( $name ) === strval( $value );
259
+ }
260
+
261
+ /**
262
+ * @param string $name
263
+ *
264
+ * @return bool
265
+ */
266
+ public static function is_module_active( $name ) {
267
+ return extension_loaded( $name );
268
+ }
269
+
270
+ /**
271
+ * @return void
272
+ */
273
+ public function disable_plugin_render_notice() {
274
+ add_action( 'admin_notices', array( $this, 'deactivate_action' ) );
275
+ add_action( 'admin_notices', array( $this, 'render_notices_action' ) );
276
+ }
277
+
278
+ /**
279
+ * Shoud be called as WordPress action
280
+ *
281
+ * @return void
282
+ */
283
+ public function render_notices_action() {
284
+ foreach ( $this->notices as $notice ) {
285
+ echo $notice;
286
+ }
287
+ }
288
+
289
+ /**
290
+ * Prepares message in html format
291
+ *
292
+ * @param string $message
293
+ *
294
+ * @return string
295
+ */
296
+ private function prepare_notice_message( $message ) {
297
+ return '<div class="error"><p>' . $message . '</p></div>';
298
+ }
299
+
300
+ /**
301
+ * @return void
302
+ */
303
+ public function deactivate_action() {
304
+ if ( isset( $this->plugin_file ) ) {
305
+ deactivate_plugins( plugin_basename( $this->plugin_file ) );
306
+ }
307
+ }
308
+
309
+ /**
310
+ * @param $min_version
311
+ *
312
+ * @return mixed
313
+ */
314
+ public static function is_php_at_least( $min_version ) {
315
+ return version_compare( phpversion(), $min_version, '>=' );
316
+ }
317
+
318
+ /**
319
+ * @param string $min_version
320
+ *
321
+ * @return bool
322
+ */
323
+ public static function is_wp_at_least( $min_version ) {
324
+ return version_compare( get_bloginfo( 'version' ), $min_version, '>=' );
325
+ }
326
+
327
+ /**
328
+ * Checks if plugin is active. Needs to be enabled in deferred way.
329
+ *
330
+ * @param string $plugin_file
331
+ *
332
+ * @return bool
333
+ */
334
+ public static function is_wp_plugin_active( $plugin_file ) {
335
+ $active_plugins = (array) get_option( 'active_plugins', array() );
336
+
337
+ if ( is_multisite() ) {
338
+ $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
339
+ }
340
+
341
+ return in_array( $plugin_file, $active_plugins ) || array_key_exists( $plugin_file, $active_plugins );
342
+ }
343
+
344
+ /**
345
+ * Checks if plugin is active and have designated version. Needs to be enabled in deferred way.
346
+ *
347
+ * @param string $min_version
348
+ *
349
+ * @return bool
350
+ */
351
+ public static function is_wc_at_least( $min_version ) {
352
+ return defined('WC_VERSION') &&
353
+ version_compare( WC_VERSION, $min_version, '>=' );
354
+ }
355
+ }
356
+ }
classes/wpdesk/class-settings.php ADDED
@@ -0,0 +1,352 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! class_exists( 'WPDesk_Settings_1_10' ) ) {
8
+
9
+ if ( ! class_exists( 'WPDesk_S214_Settings_1_10' ) ) {
10
+ require_once 'settings-api/class.s214-settings.php';
11
+ }
12
+
13
+ /**
14
+ * Base plugin class for WP Desk plugins settings
15
+ *
16
+ * @author Grzegorz
17
+ *
18
+ */
19
+ class WPDesk_Settings_1_10 extends WPDesk_S214_Settings_1_10 {
20
+
21
+ private $slug;
22
+
23
+ protected $version = '1.0';
24
+
25
+ protected $plugin_text_domain = 'wpdesk-plugin';
26
+
27
+ protected $plugin = null;
28
+
29
+ protected $func = 'wpdesk_plugin';
30
+
31
+ public function __construct( WPDesk_Plugin_1_10 $plugin, $slug = 'wpdesk-settings', $default_tab = 'general' ) {
32
+ parent::__construct( $slug, $default_tab );
33
+ $this->slug = $slug;
34
+ $this->plugin = $plugin;
35
+ $this->func = str_replace( '-', '_', $slug );
36
+ global ${$this->func . '_options'};
37
+ ${$this->func . '_options'} = $this->get_settings();
38
+ $this->hooks();
39
+ }
40
+
41
+ public function hooks() {
42
+ }
43
+
44
+ public function render_settings_page() {
45
+ parent::render_settings_page();
46
+ }
47
+
48
+ public function enqueue_scripts( $hook ) {
49
+ if ( ! apply_filters( $this->func . '_load_admin_scripts', $this->load_scripts( $hook ), $hook ) ) {
50
+ return;
51
+ }
52
+
53
+ global $wp_scripts;
54
+
55
+ // Use minified libraries if SCRIPT_DEBUG is turned off
56
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
57
+ //$url_path = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname( __FILE__ ) );
58
+ $url_path = $this->plugin->get_plugin_url() . 'classes/wpdesk';
59
+ $select2_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/';
60
+ $cm_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.14.2/';
61
+ $jquery_version = isset( $wp_scripts->registered['jquery-ui-core']->ver ) ? $wp_scripts->registered['jquery-ui-core']->ver : '1.11.4';
62
+
63
+ wp_enqueue_style( 'wp-color-picker' );
64
+ wp_enqueue_script( 'wp-color-picker' );
65
+ wp_enqueue_script( 'jquery-ui-tooltip' );
66
+ wp_enqueue_media();
67
+ wp_enqueue_style( 'jquery-ui-style', '//code.jquery.com/ui/' . $jquery_version . '/themes/smoothness/jquery-ui' . $suffix . '.css', array(), $jquery_version );
68
+
69
+ wp_enqueue_script( 'media-upload' );
70
+ wp_enqueue_style( 'thickbox' );
71
+ wp_enqueue_script( 'thickbox' );
72
+ wp_enqueue_style( 's14-select2', $select2_cdn . 'css/select2' . $suffix . '.css', array(), '4.0.3' );
73
+ wp_enqueue_script( 's14-select2', $select2_cdn . 'js/select2' . $suffix . '.js', array( 'jquery' ), '4.0.3' );
74
+
75
+ wp_enqueue_style( $this->slug . '-cm', $cm_cdn . 'codemirror.css', array(), '5.10' );
76
+ wp_enqueue_script( $this->slug . '-cm', $cm_cdn . 'codemirror.js', array( 'jquery' ), '5.14.2' );
77
+ wp_enqueue_script( $this->slug . '-cm-html', $cm_cdn . 'mode/htmlmixed/htmlmixed.js', array(
78
+ 'jquery',
79
+ $this->slug . '-cm'
80
+ ), '5.14.2' );
81
+ wp_enqueue_script( $this->slug . '-cm-xml', $cm_cdn . 'mode/xml/xml.js', array(
82
+ 'jquery',
83
+ $this->slug . '-cm'
84
+ ), '5.14.2' );
85
+ wp_enqueue_script( $this->slug . '-cm-js', $cm_cdn . 'mode/javascript/javascript.js', array(
86
+ 'jquery',
87
+ $this->slug . '-cm'
88
+ ), '5.14.2' );
89
+ wp_enqueue_script( $this->slug . '-cm-css', $cm_cdn . 'mode/css/css.js', array(
90
+ 'jquery',
91
+ $this->slug . '-cm'
92
+ ), '5.14.2' );
93
+ wp_enqueue_script( $this->slug . '-cm-php', $cm_cdn . 'mode/php/php.js', array(
94
+ 'jquery',
95
+ $this->slug . '-cm'
96
+ ), '5.14.2' );
97
+ wp_enqueue_script( $this->slug . '-cm-clike', $cm_cdn . 'mode/clike/clike.js', array(
98
+ 'jquery',
99
+ $this->slug . '-cm'
100
+ ), '5.14.2' );
101
+
102
+ wp_enqueue_style( $this->slug, $url_path . '/assets/css/admin-settings' . $suffix . '.css', array(), $this->version );
103
+ wp_enqueue_script( $this->slug . '-js', $url_path . '/assets/js/admin-settings' . $suffix . '.js', array( 'jquery' ), $this->version );
104
+ wp_localize_script( $this->slug . '-js', 's214_settings_vars', apply_filters( $this->func . 'localize_script', array(
105
+ 'func' => $this->func,
106
+ 'image_media_button' => __( 'Insert Image', 'wpdesk-plugin' ),
107
+ 'image_media_title' => __( 'Select Image', 'wpdesk-plugin' ),
108
+ ) ) );
109
+ }
110
+
111
+ /**
112
+ * Add settings sections and fields
113
+ *
114
+ * @access public
115
+ * @since 1.0.0
116
+ * @return void
117
+ */
118
+ function register_settings() {
119
+ if ( get_option( $this->func . '_settings' ) == false ) {
120
+ add_option( $this->func . '_settings' );
121
+ }
122
+
123
+ foreach ( $this->get_registered_settings() as $tab => $sections ) {
124
+ foreach ( $sections as $section => $settings ) {
125
+ // Check for backwards compatibility
126
+ $section_tabs = $this->get_settings_tab_sections( $tab );
127
+
128
+ if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
129
+ $section = 'main';
130
+ $settings = $sections;
131
+ }
132
+
133
+ add_settings_section(
134
+ $this->func . '_settings_' . $tab . '_' . $section,
135
+ __return_null(),
136
+ '__return_false',
137
+ $this->func . '_settings_' . $tab . '_' . $section
138
+ );
139
+
140
+ foreach ( $settings as $option ) {
141
+ // For backwards compatibility
142
+ if ( empty( $option['id'] ) ) {
143
+ continue;
144
+ }
145
+
146
+ $name = isset( $option['name'] ) ? $option['name'] : '';
147
+
148
+ add_settings_field(
149
+ $this->func . '_settings[' . $option['id'] . ']',
150
+ $name,
151
+ function_exists( $this->func . '_' . $option['type'] . '_callback' ) ? $this->func . '_' . $option['type'] . '_callback' : ( method_exists( $this, $option['type'] . '_callback' ) ? array(
152
+ $this,
153
+ $option['type'] . '_callback'
154
+ ) : array( $this, 'missing_callback' ) ),
155
+ $this->func . '_settings_' . $tab . '_' . $section,
156
+ $this->func . '_settings_' . $tab . '_' . $section,
157
+ array(
158
+ 'section' => $section,
159
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
160
+ 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
161
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
162
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
163
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
164
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
165
+ 'min' => isset( $option['min'] ) ? $option['min'] : null,
166
+ 'max' => isset( $option['max'] ) ? $option['max'] : null,
167
+ 'step' => isset( $option['step'] ) ? $option['step'] : null,
168
+ 'select2' => isset( $option['select2'] ) ? $option['select2'] : null,
169
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
170
+ 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : null,
171
+ 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
172
+ 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
173
+ 'buttons' => isset( $option['buttons'] ) ? $option['buttons'] : null,
174
+ 'wpautop' => isset( $option['wpautop'] ) ? $option['wpautop'] : null,
175
+ 'teeny' => isset( $option['teeny'] ) ? $option['teeny'] : null,
176
+ 'tab' => isset( $option['tab'] ) ? $option['tab'] : null,
177
+ 'tooltip_title' => isset( $option['tooltip_title'] ) ? $option['tooltip_title'] : false,
178
+ 'tooltip_desc' => isset( $option['tooltip_desc'] ) ? $option['tooltip_desc'] : false,
179
+
180
+ 'available_header' => isset( $option['available_header'] ) ? $option['available_header'] : null,
181
+ 'selected_header' => isset( $option['selected_header'] ) ? $option['selected_header'] : null,
182
+
183
+ 'class' => isset( $option['class'] ) ? $option['class'] : '',
184
+
185
+ )
186
+ );
187
+ }
188
+ }
189
+ }
190
+
191
+ register_setting( $this->func . '_settings', $this->func . '_settings', array(
192
+ $this,
193
+ 'settings_sanitize'
194
+ ) );
195
+ }
196
+
197
+ /**
198
+ * Checkbox callback
199
+ *
200
+ * @access public
201
+ * @since 1.0.0
202
+ *
203
+ * @param array $args Arguments passed by the setting
204
+ *
205
+ * @global array ${$this->func . '_options'} The plugin options
206
+ * @return void
207
+ */
208
+ public function checkbox_callback( $args ) {
209
+ global ${$this->func . '_options'};
210
+
211
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
212
+
213
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
214
+ $value = ${$this->func . '_options'}[ $args['id'] ];
215
+ } else {
216
+ $value = isset( $args['std'] ) ? $args['std'] : '';
217
+ }
218
+
219
+ $checked = checked( 1, $value, false );
220
+
221
+ $html = '<input type="hidden"' . $name . ' value="0" />';
222
+ $html .= '<input type="checkbox" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="1" ' . $checked . '/>&nbsp;';
223
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
224
+
225
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
226
+ }
227
+
228
+
229
+ /**
230
+ * Date callback
231
+ *
232
+ * @access public
233
+ * @since 1.0.0
234
+ *
235
+ * @param array $args Arguments passed by the setting
236
+ *
237
+ * @global array ${$this->func . '_options'} The Beacon options
238
+ * @return void
239
+ */
240
+ public function date_callback( $args ) {
241
+ global ${$this->func . '_options'};
242
+
243
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
244
+ $value = ${$this->func . '_options'}[ $args['id'] ];
245
+ } else {
246
+ $value = isset( $args['std'] ) ? $args['std'] : '';
247
+ }
248
+
249
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
250
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'date';
251
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
252
+
253
+ $html = '<input type="date" ' . '" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
254
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
255
+
256
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
257
+ }
258
+
259
+
260
+ /**
261
+ * select 2 columns
262
+ *
263
+ * @access public
264
+ * @since 1.0.0
265
+ *
266
+ * @param array $args Arguments passed by the setting
267
+ *
268
+ * @global array ${$this->func . '_options'} The Beacon options
269
+ * @return void
270
+ */
271
+ public function select_2_columns_callback( $args ) {
272
+ global ${$this->func . '_options'};
273
+
274
+ if ( isset( ${$this->func . '_options'}[ $args['id'] ] ) ) {
275
+ $value = ${$this->func . '_options'}[ $args['id'] ];
276
+ } else {
277
+ $value = isset( $args['std'] ) ? $args['std'] : '';
278
+ }
279
+
280
+ $value_array = explode( ',', $value );
281
+
282
+ $available_header = isset( $args['available_header'] ) ? $args['available_header'] : '';
283
+
284
+ $selected_header = isset( $args['selected_header'] ) ? $args['selected_header'] : '';
285
+
286
+ $html = '<input type="hidden" value="' . esc_attr( $value ) . '" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']"' . ' />';
287
+
288
+ $html_list_available = '<div class="available-column">';
289
+ $html_list_available .= '<strong>' . $available_header . '</strong>';
290
+ $html_list_available .= '<ul id="' . $this->func . '_settings[' . $args['id'] . '][available]" class="available connectedSortable">';
291
+
292
+ $html_list_selected = '<div class="selected-column">';
293
+ $html_list_selected .= '<strong>' . $selected_header . '</strong>';
294
+ $html_list_selected .= '<ul id="' . $this->func . '_settings[' . $args['id'] . '][selected]" class="selected connectedSortable">';
295
+
296
+ foreach ( $args['options'] as $option => $name ) {
297
+ if ( is_array( $value_array ) && in_array( $option, $value_array ) ) {
298
+ $html_list_selected .= '<li data-value="' . esc_attr( $option ) . '">' . $name . '</li>';
299
+ } else {
300
+ $html_list_available .= '<li data-value="' . esc_attr( $option ) . '">' . $name . '</li>';
301
+ }
302
+ }
303
+
304
+ $html_list_available .= '</ul></div>';
305
+ $html_list_selected .= '</ul></div>';
306
+
307
+ $html .= '<div class="select-2-columns">';
308
+ $html .= $html_list_available;
309
+ $html .= $html_list_selected;
310
+
311
+ $html .= '<div style="clear:both;">';
312
+
313
+ $html .= '<script type="text/javascript">';
314
+ $html .= "\n";
315
+ $html .= '
316
+ jQuery( function() {
317
+ jQuery( "#' . $this->func . '_settings\\\\[' . $args['id'] . '\\\\]\\\\[available\\\\], #' . $this->func . '_settings\\\\[' . $args['id'] . '\\\\]\\\\[selected\\\\]" ).sortable({
318
+ connectWith: ".connectedSortable",
319
+ deactivate: function( event, ui ) {
320
+ jQuery("#' . $this->func . '_settings\\\\[' . $args['id'] . '\\\\]").val("");
321
+ var val = "";
322
+ jQuery("#' . $this->func . '_settings\\\\[' . $args['id'] . '\\\\]\\\\[selected\\\\] > li").each( function () {
323
+ if ( val != "" ) {
324
+ val = val + ",";
325
+ }
326
+ val = val + jQuery(this).attr("data-value");
327
+ });
328
+ jQuery("#' . $this->func . '_settings\\\\[' . $args['id'] . '\\\\]").val(val);
329
+ }
330
+ }).disableSelection();
331
+ } );
332
+ ';
333
+ $html .= "\n";
334
+ $html .= '</script>';
335
+
336
+ $html .= '</div>';
337
+
338
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
339
+
340
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
341
+ }
342
+
343
+ public function set_text_domain( $plugin_text_domain ) {
344
+ $this->plugin_text_domain = $plugin_text_domain;
345
+ }
346
+
347
+ public function get_text_domain() {
348
+ return $this->plugin_text_domain;
349
+ }
350
+
351
+ }
352
+ }
classes/wpdesk/functions.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( ! function_exists( 'wpdesk_is_plugin_active' ) ) {
8
+ /**
9
+ * @param $plugin_file
10
+ *
11
+ * @return bool
12
+ * @deprecated 1.10 Use requirement class
13
+ */
14
+ function wpdesk_is_plugin_active( $plugin_file ) {
15
+ return WPDesk_Requirement_Checker_1_10::is_wp_plugin_active($plugin_file);
16
+ }
17
+ }
classes/wpdesk/interface-plugin-factory.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( ! defined( 'ABSPATH' ) ) {
4
+ exit;
5
+ } // Exit if accessed directly
6
+
7
+ if ( !interface_exists( 'WPDesk_Plugin_Factory_1_10' ) ) {
8
+ interface WPDesk_Plugin_Factory_1_10 {
9
+ const WPDESK_FILTER_PLUGIN_CLASS = 'wpdesk_plugin_class';
10
+
11
+ static function build_plugin();
12
+
13
+ static function get_plugin_instance();
14
+ }
15
+ }
classes/wpdesk/lang/wpdesk-plugin-pl_PL.mo ADDED
Binary file
classes/wpdesk/lang/wpdesk-plugin-pl_PL.po ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: WP Desk Class\n"
4
+ "POT-Creation-Date: 2016-10-27 14:04+0100\n"
5
+ "PO-Revision-Date: 2016-10-27 14:05+0100\n"
6
+ "Last-Translator: wp-kat <admin@wp-kat.net>\n"
7
+ "Language-Team: \n"
8
+ "Language: pl_PL\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.7\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
15
+ "|| n%100>=20) ? 1 : 2);\n"
16
+ "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
18
+ "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
19
+ "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
20
+ "X-Poedit-SearchPathExcluded-0: settings-api\n"
21
+ "X-Poedit-SearchPath-0: .\n"
22
+
23
+ #: class-helper.php:34
24
+ #, php-format
25
+ msgid ""
26
+ "The %s%s%s License Key has not been activated, so the plugin is inactive! "
27
+ "%sClick here%s to activate the license key and the plugin."
28
+ msgstr ""
29
+ "Klucz licencyjny wtyczki %s%s%s nie został aktywowany, więc wtyczka jest "
30
+ "nieaktywna! %sKliknij tutaj%s, aby aktywować klucz licencyjny wtyczki."
31
+
32
+ #: class-plugin.php:217
33
+ msgid "Docs"
34
+ msgstr "Docs"
35
+
36
+ #: class-plugin.php:218
37
+ msgid "Support"
38
+ msgstr "Wsparcie"
39
+
40
+ #: class-plugin.php:224
41
+ msgid "Settings"
42
+ msgstr "Ustawienia"
43
+
44
+ #: class-plugin.php:270
45
+ #, php-format
46
+ msgid ""
47
+ "<a href=\"%s\">Install the WP Desk Helper plugin</a> to activate and get "
48
+ "updates for your WP Desk plugins."
49
+ msgstr ""
50
+ "<a href=\"%s\">Zainstaluj wtyczkę WP Desk Helper</a>, aby aktywować i "
51
+ "otrzymywać aktualizacje wtyczek WP Desk."
52
+
53
+ #: class-plugin.php:276
54
+ #, php-format
55
+ msgid ""
56
+ "<a href=\"%s\">Activate the WP Desk Helper plugin</a> to activate and get "
57
+ "updates for your WP Desk plugins."
58
+ msgstr ""
59
+ "<a href=\"%s\">Włącz wtyczkę WP Desk Helper</a>, aby aktywować i otrzymywać "
60
+ "aktualizacje wtyczek WP Desk."
61
+
62
+ #: class-settings.php:85 settings-api/class.s214-settings.php:1211
63
+ msgid "Insert Image"
64
+ msgstr "Wstaw obrazek"
65
+
66
+ #: class-settings.php:86 settings-api/class.s214-settings.php:1212
67
+ msgid "Select Image"
68
+ msgstr "Wybierz obrazek"
69
+
70
+ #: settings-api/class.s214-settings.php:144
71
+ #: settings-api/class.s214-settings.php:146
72
+ msgid "Section214 Settings"
73
+ msgstr "Ustawienia Section214"
74
+
75
+ #: settings-api/class.s214-settings.php:592
76
+ msgid "Settings updated."
77
+ msgstr "Ustawienia zostały zaktualizowane."
78
+
79
+ #: settings-api/class.s214-settings.php:977
80
+ msgid ""
81
+ "To copy the system info, click below then press Ctrl + C (PC) or Cmd + C "
82
+ "(Mac)."
83
+ msgstr ""
84
+ "Aby skopiować informacje systemowe kliknij poniżej a następnie wciśnij Ctrl"
85
+ "+C lub Cmd+C."
86
+
87
+ #: settings-api/class.s214-settings.php:980
88
+ msgid "Download System Info File"
89
+ msgstr "Pobierz plik z informacjami systemowymi"
90
+
91
+ #: settings-api/class.s214-settings.php:1060
92
+ msgid "Upload File"
93
+ msgstr "Załaduj plik"
94
+
95
+ #: settings-api/class.s214-settings.php:1090
96
+ msgid "Deactivate License"
97
+ msgstr "Deaktywacja licencji"
98
+
99
+ #: settings-api/class.s214-settings.php:1121
100
+ #, php-format
101
+ msgid ""
102
+ "The callback function used for the <strong>%s</strong> setting is missing."
103
+ msgstr "Funkcja callback dla <strong>%s</strong> nie istnieje"
104
+
105
+ #~ msgid "Licensing"
106
+ #~ msgstr "Licencjonowanie"
107
+
108
+ #~ msgid "%1$s License Key"
109
+ #~ msgstr "Klucz licencji %1$s"
110
+
111
+ #~ msgid ""
112
+ #~ "Please enter your license key to enable automatic updates and support."
113
+ #~ msgstr ""
114
+ #~ "Wprowadz klucz licencji aby aktywować automatyczne aktualizacje i support."
115
+
116
+ #~ msgid "Nonce verification failed"
117
+ #~ msgstr "Błąd weryfikacji nonce"
118
+
119
+ #~ msgid "Error"
120
+ #~ msgstr "Błąd"
121
+
122
+ #~ msgid "This license does not belong to the product you have entered it for."
123
+ #~ msgstr "Licencja dotyczy innego produktu."
124
+
125
+ #~ msgid "This license does not have any activations left"
126
+ #~ msgstr "Licencja nie posiada wolnych aktywacji."
127
+
128
+ #~ msgid "This license key is expired. Please renew it."
129
+ #~ msgstr "Klucz licencyjny wygasł. Proszę go odnowić."
130
+
131
+ #~ msgid ""
132
+ #~ "There was a problem activating your license key, please try again or "
133
+ #~ "contact support. Error code: %s"
134
+ #~ msgstr ""
135
+ #~ "Wystąpił problem przy aktywacji klucza licencji, proszę spróbować "
136
+ #~ "ponownie lub skontaktować się z supportem. Kod błędu: %s"
137
+
138
+ #~ msgid ""
139
+ #~ "There is a new version of %1$s available. %2$sView version %3$s details"
140
+ #~ "%4$s."
141
+ #~ msgstr ""
142
+ #~ "Jest dostępna nowa wersja %1$s . %2$sZobacz szczegóły %3$s wersji %4$s."
143
+
144
+ #~ msgid "You do not have permission to install plugin updates"
145
+ #~ msgstr "Brak uprawnień do instalacji aktualizacji"
classes/wpdesk/settings-api/assets/css/admin.css ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Fix color picker label alignment
2
+ -------------------------------------------------------------- */
3
+ .s214-color-picker-label {
4
+ position: absolute;
5
+ display: inline-block;
6
+ padding-top: 4px;
7
+ }
8
+
9
+ /* System info styles
10
+ -------------------------------------------------------------- */
11
+ #system-info-textarea {
12
+ width: 800px;
13
+ height: 400px;
14
+ font-family: Menlo, Monaco, monospace;
15
+ background: none;
16
+ white-space: pre;
17
+ overflow: auto;
18
+ display: block;
19
+ }
20
+
21
+ /* Tooltips
22
+ -------------------------------------------------------------- */
23
+ .s214-help-tip {
24
+ cursor: help;
25
+ }
26
+
27
+ .ui-tooltip {
28
+ background: #333 !important;
29
+ border-radius: 3px !important;
30
+ box-shadow: 1px 1px 2px 1px rgba(214,214,214,0.5);
31
+ color: #dedede !important;
32
+ max-width: 300px;
33
+ padding: 7px;
34
+ text-rendering: optimizeLegibility;
35
+ }
classes/wpdesk/settings-api/assets/css/admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .s214-color-picker-label{position:absolute;display:inline-block;padding-top:4px}#system-info-textarea{width:800px;height:400px;font-family:Menlo,Monaco,monospace;background:0;white-space:pre;overflow:auto;display:block}.s214-help-tip{cursor:help}.ui-tooltip{background:#333 !important;border-radius:3px !important;box-shadow:1px 1px 2px 1px rgba(214,214,214,0.5);color:#dedede !important;max-width:300px;padding:7px;text-rendering:optimizeLegibility}
classes/wpdesk/settings-api/assets/css/jquery-ui-classic.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.ui-helper-clearfix{display:inline-block}/*\*/* html .ui-helper-clearfix{height:1%}.ui-helper-clearfix{display:block}/**/.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-widget{font-family:sans-serif;font-size:12px}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:sans-serif;font-size:1em}.ui-widget-content{border:1px solid #d1e5ee;background:#fff;color:#333}.ui-widget-header{border:1px solid #d1e5ee;background-color:#f5fafd;background-image:-ms-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-moz-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-o-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-webkit-gradient(linear,left top,left bottom,from(#f7fcfe),to(#eff8ff));background-image:-webkit-linear-gradient(top,#f7fcfe,#eff8ff);background-image:linear-gradient(top,#f7fcfe,#eff8ff);color:#333;font-weight:bold}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #d1e5ee;background-color:#f5fafd;background-image:-ms-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-moz-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-o-linear-gradient(top,#f7fcfe,#eff8ff);background-image:-webkit-gradient(linear,left top,left bottom,from(#f7fcfe),to(#eff8ff));background-image:-webkit-linear-gradient(top,#f7fcfe,#eff8ff);background-image:linear-gradient(top,#f7fcfe,#eff8ff);font-weight:normal;color:#333}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#333;text-decoration:none}.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:1px solid #b8d7e5;background-color:#f7fcfe;background-image:-ms-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-moz-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-o-linear-gradient(top,#eff8ff,#f7fcfe);background-image:-webkit-gradient(linear,left top,left bottom,from(#eff8ff),to(#f7fcfe));background-image:-webkit-linear-gradient(top,#eff8ff,#f7fcfe);background-image:linear-gradient(top,#eff8ff,#f7fcfe);font-weight:normal;color:#000}.ui-state-hover a,.ui-state-hover a:hover{color:#000;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #d1e5ee;background:#fff;font-weight:normal;color:#333}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#333;text-decoration:none}.ui-widget :active{outline:0}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #e6db55;background:#ffffe0;color:#333}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#333}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #c00;background:#ffebe8;color:#c00}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#c00}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#c00}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-icon{width:16px;height:16px;background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-header .ui-icon{background-image:url(../images/ui-icons_999999_256x240.png)}.ui-state-default .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-active .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_21759b_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(../images/ui-icons_cc0000_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-off{background-position:-96px -144px}.ui-icon-radio-on{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;-khtml-border-top-left-radius:3px;border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;-khtml-border-top-right-radius:3px;border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;-khtml-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;-khtml-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ui-widget-overlay{background:#000;opacity:.6;filter:Alpha(Opacity=60)}.ui-widget-shadow{box-shadow:0 0 16px rgba(0,0,0,0.3)}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion{width:100%}.ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.ui-accordion .ui-accordion-li-fix{display:inline}.ui-accordion .ui-accordion-header-active{border-bottom:0!important}.ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.ui-accordion .ui-accordion-content-active{display:block}.ui-autocomplete{position:absolute;cursor:default}* html .ui-autocomplete{width:1px}.ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.ui-menu .ui-menu{margin-top:-3px}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.ui-menu .ui-menu-item a.ui-state-hover,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none!important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:absolute;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0!important;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:0}.ui-tabs .ui-tabs-hide{display:none!important}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.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}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{display:none;display:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-progressbar{height:2em;text-align:left}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-widget-header{background-color:#83b4d8;background-image:linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-o-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-moz-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-webkit-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-ms-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%)}
classes/wpdesk/settings-api/assets/css/jquery-ui-fresh.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{position:absolute!important;clip:rect(1px 1px 1px 1px);clip:rect(1px,1px,1px,1px)}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.ui-helper-clearfix{display:inline-block}/*\*/* html .ui-helper-clearfix{height:1%}.ui-helper-clearfix{display:block}/**/.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:absolute;top:0;left:0;width:100%;height:100%}.ui-widget{font-family:sans-serif;font-size:12px}.ui-widget .ui-widget{font-size:1em}.ui-widget input,.ui-widget select,.ui-widget textarea,.ui-widget button{font-family:sans-serif;font-size:1em}.ui-widget-content{border:1px solid #dfdfdf;background:#fff;color:#333}.ui-widget-header{border:1px solid #dfdfdf;color:#333;font-weight:bold;background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#ececec);background-image:-moz-linear-gradient(top,#f9f9f9,#ececec);background-image:-o-linear-gradient(top,#f9f9f9,#ececec);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));background-image:-webkit-linear-gradient(top,#f9f9f9,#ececec);background-image:linear-gradient(top,#f9f9f9,#ececec)}.ui-widget-header a{color:#333}.ui-state-default,.ui-widget-content .ui-state-default,.ui-widget-header .ui-state-default{border:1px solid #dfdfdf;background-color:#f1f1f1;background-image:-ms-linear-gradient(top,#f9f9f9,#ececec);background-image:-moz-linear-gradient(top,#f9f9f9,#ececec);background-image:-o-linear-gradient(top,#f9f9f9,#ececec);background-image:-webkit-gradient(linear,left top,left bottom,from(#f9f9f9),to(#ececec));background-image:-webkit-linear-gradient(top,#f9f9f9,#ececec);background-image:linear-gradient(top,#f9f9f9,#ececec);font-weight:normal;color:#333}.ui-state-default a,.ui-state-default a:link,.ui-state-default a:visited{color:#333;text-decoration:none}.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:1px solid #ccc;background-color:#ececec;background-image:-ms-linear-gradient(top,#ececec,#f9f9f9);background-image:-moz-linear-gradient(top,#ececec,#f9f9f9);background-image:-o-linear-gradient(top,#ececec,#f9f9f9);background-image:-webkit-gradient(linear,left top,left bottom,from(#ececec),to(#f9f9f9));background-image:-webkit-linear-gradient(top,#ececec,#f9f9f9);background-image:linear-gradient(top,#ececec,#f9f9f9);font-weight:normal;color:#000}.ui-state-hover a,.ui-state-hover a:hover{color:#000;text-decoration:none}.ui-state-active,.ui-widget-content .ui-state-active,.ui-widget-header .ui-state-active{border:1px solid #dfdfdf;background:#fff;font-weight:normal;color:#333}.ui-state-active a,.ui-state-active a:link,.ui-state-active a:visited{color:#333;text-decoration:none}.ui-widget :active{outline:0}.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight{border:1px solid #e6db55;background:#ffffe0;color:#333}.ui-state-highlight a,.ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a{color:#333}.ui-state-error,.ui-widget-content .ui-state-error,.ui-widget-header .ui-state-error{border:1px solid #c00;background:#ffebe8;color:#c00}.ui-state-error a,.ui-widget-content .ui-state-error a,.ui-widget-header .ui-state-error a{color:#c00}.ui-state-error-text,.ui-widget-content .ui-state-error-text,.ui-widget-header .ui-state-error-text{color:#c00}.ui-priority-primary,.ui-widget-content .ui-priority-primary,.ui-widget-header .ui-priority-primary{font-weight:bold}.ui-priority-secondary,.ui-widget-content .ui-priority-secondary,.ui-widget-header .ui-priority-secondary{opacity:.7;filter:Alpha(Opacity=70);font-weight:normal}.ui-state-disabled,.ui-widget-content .ui-state-disabled,.ui-widget-header .ui-state-disabled{opacity:.35;filter:Alpha(Opacity=35);background-image:none}.ui-icon{width:16px;height:16px;background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-content .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-widget-header .ui-icon{background-image:url(../images/ui-icons_999999_256x240.png)}.ui-state-default .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-hover .ui-icon,.ui-state-focus .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-active .ui-icon{background-image:url(../images/ui-icons_333333_256x240.png)}.ui-state-highlight .ui-icon{background-image:url(../images/ui-icons_21759b_256x240.png)}.ui-state-error .ui-icon,.ui-state-error-text .ui-icon{background-image:url(../images/ui-icons_cc0000_256x240.png)}.ui-icon-carat-1-n{background-position:0 0}.ui-icon-carat-1-ne{background-position:-16px 0}.ui-icon-carat-1-e{background-position:-32px 0}.ui-icon-carat-1-se{background-position:-48px 0}.ui-icon-carat-1-s{background-position:-64px 0}.ui-icon-carat-1-sw{background-position:-80px 0}.ui-icon-carat-1-w{background-position:-96px 0}.ui-icon-carat-1-nw{background-position:-112px 0}.ui-icon-carat-2-n-s{background-position:-128px 0}.ui-icon-carat-2-e-w{background-position:-144px 0}.ui-icon-triangle-1-n{background-position:0 -16px}.ui-icon-triangle-1-ne{background-position:-16px -16px}.ui-icon-triangle-1-e{background-position:-32px -16px}.ui-icon-triangle-1-se{background-position:-48px -16px}.ui-icon-triangle-1-s{background-position:-64px -16px}.ui-icon-triangle-1-sw{background-position:-80px -16px}.ui-icon-triangle-1-w{background-position:-96px -16px}.ui-icon-triangle-1-nw{background-position:-112px -16px}.ui-icon-triangle-2-n-s{background-position:-128px -16px}.ui-icon-triangle-2-e-w{background-position:-144px -16px}.ui-icon-arrow-1-n{background-position:0 -32px}.ui-icon-arrow-1-ne{background-position:-16px -32px}.ui-icon-arrow-1-e{background-position:-32px -32px}.ui-icon-arrow-1-se{background-position:-48px -32px}.ui-icon-arrow-1-s{background-position:-64px -32px}.ui-icon-arrow-1-sw{background-position:-80px -32px}.ui-icon-arrow-1-w{background-position:-96px -32px}.ui-icon-arrow-1-nw{background-position:-112px -32px}.ui-icon-arrow-2-n-s{background-position:-128px -32px}.ui-icon-arrow-2-ne-sw{background-position:-144px -32px}.ui-icon-arrow-2-e-w{background-position:-160px -32px}.ui-icon-arrow-2-se-nw{background-position:-176px -32px}.ui-icon-arrowstop-1-n{background-position:-192px -32px}.ui-icon-arrowstop-1-e{background-position:-208px -32px}.ui-icon-arrowstop-1-s{background-position:-224px -32px}.ui-icon-arrowstop-1-w{background-position:-240px -32px}.ui-icon-arrowthick-1-n{background-position:0 -48px}.ui-icon-arrowthick-1-ne{background-position:-16px -48px}.ui-icon-arrowthick-1-e{background-position:-32px -48px}.ui-icon-arrowthick-1-se{background-position:-48px -48px}.ui-icon-arrowthick-1-s{background-position:-64px -48px}.ui-icon-arrowthick-1-sw{background-position:-80px -48px}.ui-icon-arrowthick-1-w{background-position:-96px -48px}.ui-icon-arrowthick-1-nw{background-position:-112px -48px}.ui-icon-arrowthick-2-n-s{background-position:-128px -48px}.ui-icon-arrowthick-2-ne-sw{background-position:-144px -48px}.ui-icon-arrowthick-2-e-w{background-position:-160px -48px}.ui-icon-arrowthick-2-se-nw{background-position:-176px -48px}.ui-icon-arrowthickstop-1-n{background-position:-192px -48px}.ui-icon-arrowthickstop-1-e{background-position:-208px -48px}.ui-icon-arrowthickstop-1-s{background-position:-224px -48px}.ui-icon-arrowthickstop-1-w{background-position:-240px -48px}.ui-icon-arrowreturnthick-1-w{background-position:0 -64px}.ui-icon-arrowreturnthick-1-n{background-position:-16px -64px}.ui-icon-arrowreturnthick-1-e{background-position:-32px -64px}.ui-icon-arrowreturnthick-1-s{background-position:-48px -64px}.ui-icon-arrowreturn-1-w{background-position:-64px -64px}.ui-icon-arrowreturn-1-n{background-position:-80px -64px}.ui-icon-arrowreturn-1-e{background-position:-96px -64px}.ui-icon-arrowreturn-1-s{background-position:-112px -64px}.ui-icon-arrowrefresh-1-w{background-position:-128px -64px}.ui-icon-arrowrefresh-1-n{background-position:-144px -64px}.ui-icon-arrowrefresh-1-e{background-position:-160px -64px}.ui-icon-arrowrefresh-1-s{background-position:-176px -64px}.ui-icon-arrow-4{background-position:0 -80px}.ui-icon-arrow-4-diag{background-position:-16px -80px}.ui-icon-extlink{background-position:-32px -80px}.ui-icon-newwin{background-position:-48px -80px}.ui-icon-refresh{background-position:-64px -80px}.ui-icon-shuffle{background-position:-80px -80px}.ui-icon-transfer-e-w{background-position:-96px -80px}.ui-icon-transferthick-e-w{background-position:-112px -80px}.ui-icon-folder-collapsed{background-position:0 -96px}.ui-icon-folder-open{background-position:-16px -96px}.ui-icon-document{background-position:-32px -96px}.ui-icon-document-b{background-position:-48px -96px}.ui-icon-note{background-position:-64px -96px}.ui-icon-mail-closed{background-position:-80px -96px}.ui-icon-mail-open{background-position:-96px -96px}.ui-icon-suitcase{background-position:-112px -96px}.ui-icon-comment{background-position:-128px -96px}.ui-icon-person{background-position:-144px -96px}.ui-icon-print{background-position:-160px -96px}.ui-icon-trash{background-position:-176px -96px}.ui-icon-locked{background-position:-192px -96px}.ui-icon-unlocked{background-position:-208px -96px}.ui-icon-bookmark{background-position:-224px -96px}.ui-icon-tag{background-position:-240px -96px}.ui-icon-home{background-position:0 -112px}.ui-icon-flag{background-position:-16px -112px}.ui-icon-calendar{background-position:-32px -112px}.ui-icon-cart{background-position:-48px -112px}.ui-icon-pencil{background-position:-64px -112px}.ui-icon-clock{background-position:-80px -112px}.ui-icon-disk{background-position:-96px -112px}.ui-icon-calculator{background-position:-112px -112px}.ui-icon-zoomin{background-position:-128px -112px}.ui-icon-zoomout{background-position:-144px -112px}.ui-icon-search{background-position:-160px -112px}.ui-icon-wrench{background-position:-176px -112px}.ui-icon-gear{background-position:-192px -112px}.ui-icon-heart{background-position:-208px -112px}.ui-icon-star{background-position:-224px -112px}.ui-icon-link{background-position:-240px -112px}.ui-icon-cancel{background-position:0 -128px}.ui-icon-plus{background-position:-16px -128px}.ui-icon-plusthick{background-position:-32px -128px}.ui-icon-minus{background-position:-48px -128px}.ui-icon-minusthick{background-position:-64px -128px}.ui-icon-close{background-position:-80px -128px}.ui-icon-closethick{background-position:-96px -128px}.ui-icon-key{background-position:-112px -128px}.ui-icon-lightbulb{background-position:-128px -128px}.ui-icon-scissors{background-position:-144px -128px}.ui-icon-clipboard{background-position:-160px -128px}.ui-icon-copy{background-position:-176px -128px}.ui-icon-contact{background-position:-192px -128px}.ui-icon-image{background-position:-208px -128px}.ui-icon-video{background-position:-224px -128px}.ui-icon-script{background-position:-240px -128px}.ui-icon-alert{background-position:0 -144px}.ui-icon-info{background-position:-16px -144px}.ui-icon-notice{background-position:-32px -144px}.ui-icon-help{background-position:-48px -144px}.ui-icon-check{background-position:-64px -144px}.ui-icon-bullet{background-position:-80px -144px}.ui-icon-radio-off{background-position:-96px -144px}.ui-icon-radio-on{background-position:-112px -144px}.ui-icon-pin-w{background-position:-128px -144px}.ui-icon-pin-s{background-position:-144px -144px}.ui-icon-play{background-position:0 -160px}.ui-icon-pause{background-position:-16px -160px}.ui-icon-seek-next{background-position:-32px -160px}.ui-icon-seek-prev{background-position:-48px -160px}.ui-icon-seek-end{background-position:-64px -160px}.ui-icon-seek-start{background-position:-80px -160px}.ui-icon-seek-first{background-position:-80px -160px}.ui-icon-stop{background-position:-96px -160px}.ui-icon-eject{background-position:-112px -160px}.ui-icon-volume-off{background-position:-128px -160px}.ui-icon-volume-on{background-position:-144px -160px}.ui-icon-power{background-position:0 -176px}.ui-icon-signal-diag{background-position:-16px -176px}.ui-icon-signal{background-position:-32px -176px}.ui-icon-battery-0{background-position:-48px -176px}.ui-icon-battery-1{background-position:-64px -176px}.ui-icon-battery-2{background-position:-80px -176px}.ui-icon-battery-3{background-position:-96px -176px}.ui-icon-circle-plus{background-position:0 -192px}.ui-icon-circle-minus{background-position:-16px -192px}.ui-icon-circle-close{background-position:-32px -192px}.ui-icon-circle-triangle-e{background-position:-48px -192px}.ui-icon-circle-triangle-s{background-position:-64px -192px}.ui-icon-circle-triangle-w{background-position:-80px -192px}.ui-icon-circle-triangle-n{background-position:-96px -192px}.ui-icon-circle-arrow-e{background-position:-112px -192px}.ui-icon-circle-arrow-s{background-position:-128px -192px}.ui-icon-circle-arrow-w{background-position:-144px -192px}.ui-icon-circle-arrow-n{background-position:-160px -192px}.ui-icon-circle-zoomin{background-position:-176px -192px}.ui-icon-circle-zoomout{background-position:-192px -192px}.ui-icon-circle-check{background-position:-208px -192px}.ui-icon-circlesmall-plus{background-position:0 -208px}.ui-icon-circlesmall-minus{background-position:-16px -208px}.ui-icon-circlesmall-close{background-position:-32px -208px}.ui-icon-squaresmall-plus{background-position:-48px -208px}.ui-icon-squaresmall-minus{background-position:-64px -208px}.ui-icon-squaresmall-close{background-position:-80px -208px}.ui-icon-grip-dotted-vertical{background-position:0 -224px}.ui-icon-grip-dotted-horizontal{background-position:-16px -224px}.ui-icon-grip-solid-vertical{background-position:-32px -224px}.ui-icon-grip-solid-horizontal{background-position:-48px -224px}.ui-icon-gripsmall-diagonal-se{background-position:-64px -224px}.ui-icon-grip-diagonal-se{background-position:-80px -224px}.ui-corner-all,.ui-corner-top,.ui-corner-left,.ui-corner-tl{-moz-border-radius-topleft:3px;-webkit-border-top-left-radius:3px;border-top-left-radius:3px}.ui-corner-all,.ui-corner-top,.ui-corner-right,.ui-corner-tr{-moz-border-radius-topright:3px;-webkit-border-top-right-radius:3px;border-top-right-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-left,.ui-corner-bl{-moz-border-radius-bottomleft:3px;-webkit-border-bottom-left-radius:3px;border-bottom-left-radius:3px}.ui-corner-all,.ui-corner-bottom,.ui-corner-right,.ui-corner-br{-moz-border-radius-bottomright:3px;-webkit-border-bottom-right-radius:3px;border-bottom-right-radius:3px}.ui-widget-overlay{background:#000;opacity:.6;filter:Alpha(Opacity=60)}.ui-widget-shadow{box-shadow:0 0 16px rgba(0,0,0,0.3)}.ui-resizable{position:relative}.ui-resizable-handle{position:absolute;font-size:.1px;z-index:99999;display:block}.ui-resizable-disabled .ui-resizable-handle,.ui-resizable-autohide .ui-resizable-handle{display:none}.ui-resizable-n{cursor:n-resize;height:7px;width:100%;top:-5px;left:0}.ui-resizable-s{cursor:s-resize;height:7px;width:100%;bottom:-5px;left:0}.ui-resizable-e{cursor:e-resize;width:7px;right:-5px;top:0;height:100%}.ui-resizable-w{cursor:w-resize;width:7px;left:-5px;top:0;height:100%}.ui-resizable-se{cursor:se-resize;width:12px;height:12px;right:1px;bottom:1px}.ui-resizable-sw{cursor:sw-resize;width:9px;height:9px;left:-5px;bottom:-5px}.ui-resizable-nw{cursor:nw-resize;width:9px;height:9px;left:-5px;top:-5px}.ui-resizable-ne{cursor:ne-resize;width:9px;height:9px;right:-5px;top:-5px}.ui-selectable-helper{position:absolute;z-index:100;border:1px dotted black}.ui-accordion{width:100%}.ui-accordion .ui-accordion-header{cursor:pointer;position:relative;margin-top:1px;zoom:1}.ui-accordion .ui-accordion-li-fix{display:inline}.ui-accordion .ui-accordion-header-active{border-bottom:0!important}.ui-accordion .ui-accordion-header a{display:block;font-size:1em;padding:.5em .5em .5em .7em}.ui-accordion-icons .ui-accordion-header a{padding-left:2.2em}.ui-accordion .ui-accordion-header .ui-icon{position:absolute;left:.5em;top:50%;margin-top:-8px}.ui-accordion .ui-accordion-content{padding:1em 2.2em;border-top:0;margin-top:-2px;position:relative;top:1px;margin-bottom:2px;overflow:auto;display:none;zoom:1}.ui-accordion .ui-accordion-content-active{display:block}.ui-autocomplete{position:absolute;cursor:default}* html .ui-autocomplete{width:1px}.ui-menu{list-style:none;padding:2px;margin:0;display:block;float:left}.ui-menu .ui-menu{margin-top:-3px}.ui-menu .ui-menu-item{margin:0;padding:0;zoom:1;float:left;clear:left;width:100%}.ui-menu .ui-menu-item a{text-decoration:none;display:block;padding:.2em .4em;line-height:1.5;zoom:1}.ui-menu .ui-menu-item a.ui-state-hover,.ui-menu .ui-menu-item a.ui-state-active{font-weight:normal;margin:-1px}.ui-button{display:inline-block;position:relative;padding:0;margin-right:.1em;text-decoration:none!important;cursor:pointer;text-align:center;zoom:1;overflow:visible}.ui-button-icon-only{width:2.2em}button.ui-button-icon-only{width:2.4em}.ui-button-icons-only{width:3.4em}button.ui-button-icons-only{width:3.7em}.ui-button .ui-button-text{display:block;line-height:1.4}.ui-button-text-only .ui-button-text{padding:.4em 1em}.ui-button-icon-only .ui-button-text,.ui-button-icons-only .ui-button-text{padding:.4em;text-indent:-9999999px}.ui-button-text-icon-primary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 1em .4em 2.1em}.ui-button-text-icon-secondary .ui-button-text,.ui-button-text-icons .ui-button-text{padding:.4em 2.1em .4em 1em}.ui-button-text-icons .ui-button-text{padding-left:2.1em;padding-right:2.1em}input.ui-button{padding:.4em 1em}.ui-button-icon-only .ui-icon,.ui-button-text-icon-primary .ui-icon,.ui-button-text-icon-secondary .ui-icon,.ui-button-text-icons .ui-icon,.ui-button-icons-only .ui-icon{position:absolute;top:50%;margin-top:-8px}.ui-button-icon-only .ui-icon{left:50%;margin-left:-8px}.ui-button-text-icon-primary .ui-button-icon-primary,.ui-button-text-icons .ui-button-icon-primary,.ui-button-icons-only .ui-button-icon-primary{left:.5em}.ui-button-text-icon-secondary .ui-button-icon-secondary,.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-button-text-icons .ui-button-icon-secondary,.ui-button-icons-only .ui-button-icon-secondary{right:.5em}.ui-buttonset{margin-right:7px}.ui-buttonset .ui-button{margin-left:0;margin-right:-.3em}button.ui-button::-moz-focus-inner{border:0;padding:0}.ui-dialog{position:fixed;padding:.2em;width:300px;overflow:hidden}.ui-dialog .ui-dialog-titlebar{padding:.4em 1em;position:relative}.ui-dialog .ui-dialog-title{float:left;margin:.1em 16px .1em 0}.ui-dialog .ui-dialog-titlebar-close{position:absolute;right:.3em;top:50%;width:19px;margin:-10px 0 0 0;padding:1px;height:18px}.ui-dialog .ui-dialog-titlebar-close span{display:block;margin:1px}.ui-dialog .ui-dialog-titlebar-close:hover,.ui-dialog .ui-dialog-titlebar-close:focus{padding:0}.ui-dialog .ui-dialog-content{position:relative;border:0;padding:.5em 1em;background:0;overflow:auto;zoom:1}.ui-dialog .ui-dialog-buttonpane{text-align:left;border-width:1px 0 0 0;background-image:none;margin:.5em 0 0 0;padding:.3em 1em .5em .4em}.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset{float:right}.ui-dialog .ui-dialog-buttonpane button{margin:.5em .4em .5em 0;cursor:pointer}.ui-dialog .ui-resizable-se{width:14px;height:14px;right:3px;bottom:3px}.ui-draggable .ui-dialog-titlebar{cursor:move}.ui-slider{position:relative;text-align:left}.ui-slider .ui-slider-handle{position:absolute;z-index:2;width:1.2em;height:1.2em;cursor:default}.ui-slider .ui-slider-range{position:absolute;z-index:1;font-size:.7em;display:block;border:0;background-position:0 0}.ui-slider-horizontal{height:.8em}.ui-slider-horizontal .ui-slider-handle{top:-.3em;margin-left:-.6em}.ui-slider-horizontal .ui-slider-range{top:0;height:100%}.ui-slider-horizontal .ui-slider-range-min{left:0}.ui-slider-horizontal .ui-slider-range-max{right:0}.ui-slider-vertical{width:.8em;height:100px}.ui-slider-vertical .ui-slider-handle{left:-.3em;margin-left:0;margin-bottom:-.6em}.ui-slider-vertical .ui-slider-range{left:0;width:100%}.ui-slider-vertical .ui-slider-range-min{bottom:0}.ui-slider-vertical .ui-slider-range-max{top:0}.ui-tabs{position:relative;padding:.2em;zoom:1}.ui-tabs .ui-tabs-nav{margin:0;padding:.2em .2em 0}.ui-tabs .ui-tabs-nav li{list-style:none;float:left;position:relative;top:1px;margin:0 .2em 1px 0;border-bottom:0!important;padding:0;white-space:nowrap}.ui-tabs .ui-tabs-nav li a{float:left;padding:.5em 1em;text-decoration:none}.ui-tabs .ui-tabs-nav li.ui-tabs-selected{margin-bottom:0;padding-bottom:1px}.ui-tabs .ui-tabs-nav li.ui-tabs-selected a,.ui-tabs .ui-tabs-nav li.ui-state-disabled a,.ui-tabs .ui-tabs-nav li.ui-state-processing a{cursor:text}.ui-tabs .ui-tabs-nav li a,.ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a{cursor:pointer}.ui-tabs .ui-tabs-panel{display:block;border-width:0;padding:1em 1.4em;background:0}.ui-tabs .ui-tabs-hide{display:none!important}.ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.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}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:bold;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em .6em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current{float:right}.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}.ui-datepicker-cover{display:none;display:block;position:absolute;z-index:-1;filter:mask();top:-4px;left:-4px;width:200px;height:200px}.ui-progressbar{height:2em;text-align:left}.ui-progressbar .ui-progressbar-value{margin:-1px;height:100%}.ui-progressbar .ui-widget-header{background-color:#83b4d8;background-image:linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-o-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-moz-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-webkit-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%);background-image:-ms-linear-gradient(bottom,#72a7cf 0,#90c5ee 100%)}
classes/wpdesk/settings-api/assets/js/admin.js ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*global jQuery, document, window, wp, CodeMirror, s214_settings_vars*/
2
+ jQuery(document).ready(function ($) {
3
+ 'use strict';
4
+
5
+ // Setup color picker
6
+ if ($('.s214-color-picker').length) {
7
+ $('.s214-color-picker').wpColorPicker();
8
+ }
9
+
10
+ // Setup select2
11
+ if ($('.s214-select2').length) {
12
+ $('.s214-select2').select2();
13
+ }
14
+
15
+ // Setup CodeMirror
16
+ if ($('.s214-html').length) {
17
+ $('.s214-html').each(function (index, elem) {
18
+ CodeMirror.fromTextArea(elem, {
19
+ lineNumbers: true,
20
+ mode: 'text/html',
21
+ showCursorWhenSelecting: true
22
+ });
23
+ });
24
+ }
25
+
26
+ // Setup tooltips
27
+ $('.s214-help-tip').tooltip({
28
+ content: function () {
29
+ return $(this).prop('title');
30
+ },
31
+ position: {
32
+ my: 'center top',
33
+ at: 'center bottom+10',
34
+ collision: 'flipfit'
35
+ },
36
+ hide: {
37
+ duration: 200
38
+ },
39
+ show: {
40
+ duration: 200
41
+ }
42
+ });
43
+
44
+ // Setup uploaders
45
+ if ($('.' + s214_settings_vars.func + '_settings_upload_button').length) {
46
+ var file_frame;
47
+
48
+ $('body').on('click', '.' + s214_settings_vars.func + '_settings_upload_button', function (e) {
49
+ e.preventDefault();
50
+
51
+ var button = $(this);
52
+
53
+ window.formfield = $(this).parent().prev();
54
+
55
+ // If the media frame already exists, reopen it
56
+ if (file_frame) {
57
+ file_frame.open();
58
+ return;
59
+ }
60
+
61
+ // Create the media frame
62
+ wp.media.frames.file_frame = wp.media({
63
+ frame: 'post',
64
+ state: 'insert',
65
+ title: button.data('uploader_title'),
66
+ button: {
67
+ text: button.data('uploader_button_text')
68
+ },
69
+ multiple: false
70
+ });
71
+
72
+ file_frame = wp.media.frames.file_frame;
73
+
74
+ file_frame.on('menu:render:default', function (view) {
75
+ // Store our views in an object
76
+ var views = {};
77
+
78
+ // Unset default menu items
79
+ view.unset('library-separator');
80
+ view.unset('gallery');
81
+ view.unset('featured-image');
82
+ view.unset('embed');
83
+
84
+ // Initialize the views in our object
85
+ view.set(views);
86
+ });
87
+
88
+ // Run a callback on select
89
+ file_frame.on('insert', function () {
90
+ var selection = file_frame.state().get('selection');
91
+
92
+ selection.each(function (attachment) {
93
+ attachment = attachment.toJSON();
94
+ window.formfield.val(attachment.url);
95
+ });
96
+ });
97
+
98
+ // Open the modal
99
+ file_frame.open();
100
+ });
101
+
102
+ window.formfield = '';
103
+ }
104
+ });
classes/wpdesk/settings-api/assets/js/admin.min.js ADDED
@@ -0,0 +1 @@
 
1
+ jQuery(document).ready(function(b){if(b(".s214-color-picker").length){b(".s214-color-picker").wpColorPicker()}if(b(".s214-select2").length){b(".s214-select2").select2()}if(b(".s214-html").length){b(".s214-html").each(function(c,d){CodeMirror.fromTextArea(d,{lineNumbers:true,mode:"text/html",showCursorWhenSelecting:true})})}b(".s214-help-tip").tooltip({content:function(){return b(this).prop("title")},position:{my:"center top",at:"center bottom+10",collision:"flipfit"},hide:{duration:200},show:{duration:200}});if(b("."+s214_settings_vars.func+"_settings_upload_button").length){var a;b("body").on("click","."+s214_settings_vars.func+"_settings_upload_button",function(d){d.preventDefault();var c=b(this);window.formfield=b(this).parent().prev();if(a){a.open();return}wp.media.frames.file_frame=wp.media({frame:"post",state:"insert",title:c.data("uploader_title"),button:{text:c.data("uploader_button_text")},multiple:false});a=wp.media.frames.file_frame;a.on("menu:render:default",function(f){var e={};f.unset("library-separator");f.unset("gallery");f.unset("featured-image");f.unset("embed");f.set(e)});a.on("insert",function(){var e=a.state().get("selection");e.each(function(f){f=f.toJSON();window.formfield.val(f.url)})});a.open()});window.formfield=""}});
classes/wpdesk/settings-api/class.s214-settings.php ADDED
@@ -0,0 +1,1253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Section214 Settings Class
4
+ *
5
+ * @package S214\Settings
6
+ * @since 1.0.0
7
+ */
8
+
9
+
10
+ // Exit if accessed directly
11
+ if( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+
16
+ /**
17
+ * Section214 settings handler class
18
+ *
19
+ * @since 1.0.0
20
+ */
21
+ class WPDesk_S214_Settings_1_10 {
22
+
23
+
24
+ /**
25
+ * @var string $version The settings class version
26
+ * @since 1.0.0
27
+ */
28
+ private $version = '1.2.2';
29
+
30
+
31
+ /**
32
+ * @var string $slug The plugin slug
33
+ * @since 1.0.0
34
+ */
35
+ private $slug;
36
+
37
+
38
+ /**
39
+ * @var string $func The plugin slug for names
40
+ * @since 1.0.0
41
+ */
42
+ private $func;
43
+
44
+
45
+ /**
46
+ * @var string $default_tab The default tab to display
47
+ * @since 1.0.0
48
+ */
49
+ private $default_tab;
50
+
51
+
52
+ /**
53
+ * @var bool $show_title Whether or not to display the page title
54
+ * @since 1.0.3
55
+ */
56
+ private $show_title;
57
+
58
+
59
+ /**
60
+ * @var bool page_title The page title
61
+ * @since 1.2.1
62
+ */
63
+ private $page_title;
64
+
65
+
66
+ /**
67
+ * @var object $sysinfo The sysinfo object
68
+ * @since 1.1.0
69
+ */
70
+ private $sysinfo;
71
+
72
+
73
+ /**
74
+ * Get things started
75
+ *
76
+ * @access public
77
+ * @since 1.0.1
78
+ * @param string $slug The plugin slug
79
+ * @param string $default_tab The default settings tab to display
80
+ * @return void
81
+ */
82
+ public function __construct( $slug = false, $default_tab = 'general' ) {
83
+ // Bail if no slug is specified
84
+ if( ! $slug ) {
85
+ return;
86
+ }
87
+
88
+ // Setup plugin variables
89
+ $this->slug = $slug;
90
+ $this->func = str_replace( '-', '_', $slug );
91
+ $this->default_tab = $default_tab;
92
+
93
+ // Run action and filter hooks
94
+ $this->hooks();
95
+
96
+ // Setup the Sysinfo class
97
+ if( ! class_exists( 'S214_Sysinfo' ) ) {
98
+ require_once 'modules/sysinfo/class.s214-sysinfo.php';
99
+ }
100
+ $this->sysinfo = new S214_Sysinfo( $this->slug, $this->func, $this->version );
101
+ }
102
+
103
+
104
+ /**
105
+ * Run action and filter hooks
106
+ *
107
+ * @access private
108
+ * @since 1.0.0
109
+ * @return void
110
+ */
111
+ private function hooks() {
112
+ // Add the plugin setting page
113
+ add_action( 'admin_menu', array( $this, 'add_settings_page' ), 10 );
114
+
115
+ // Register the plugin settings
116
+ add_action( 'admin_init', array( $this, 'register_settings' ) );
117
+ add_filter( $this->func . '_settings_sanitize_text', array( $this, 'sanitize_text_field' ) );
118
+
119
+ // Add styles and scripts
120
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 100 );
121
+
122
+ // Process actions
123
+ add_action( 'admin_init', array( $this, 'process_actions' ) );
124
+
125
+ // Handle tooltips
126
+ add_filter( $this->func . '_after_setting_output', array( $this, 'add_setting_tooltip' ), 10, 2 );
127
+ }
128
+
129
+
130
+ /**
131
+ * Add settings pages
132
+ *
133
+ * @access public
134
+ * @since 1.0.0
135
+ * @global string ${this->func . '_settings_page'} The settings page slug
136
+ * @return void
137
+ */
138
+ public function add_settings_page() {
139
+ global ${$this->func . '_settings_page'};
140
+
141
+ $menu = apply_filters( $this->func . '_menu', array(
142
+ 'type' => 'menu',
143
+ 'parent' => 'options-general.php',
144
+ 'page_title' => __( 'Section214 Settings', 'wpdesk-plugin' ),
145
+ 'show_title' => false,
146
+ 'menu_title' => __( 'Section214 Settings', 'wpdesk-plugin' ),
147
+ 'capability' => 'manage_options',
148
+ 'icon' => '',
149
+ 'position' => null
150
+ ) );
151
+
152
+ $this->show_title = $menu['show_title'];
153
+ $this->page_title = $menu['page_title'];
154
+
155
+ if( $menu['type'] == 'submenu' ) {
156
+ ${$this->func . '_settings_page'} = add_submenu_page( $menu['parent'], $menu['page_title'], $menu['menu_title'], $menu['capability'], $this->slug . '-settings', array( $this, 'render_settings_page' ) );
157
+ } else {
158
+ ${$this->func . '_settings_page'} = add_menu_page( $menu['page_title'], $menu['menu_title'], $menu['capability'], $this->slug . '-settings', array( $this, 'render_settings_page' ), $menu['icon'], $menu['position'] );
159
+ }
160
+ }
161
+
162
+
163
+ /**
164
+ * Render settings page
165
+ *
166
+ * @access public
167
+ * @since 1.0.0
168
+ * @return void
169
+ */
170
+ public function render_settings_page() {
171
+ $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $this->get_settings_tabs() ) ? $_GET['tab'] : $this->default_tab;
172
+ $sections = $registered_sections = $this->get_settings_tab_sections( $active_tab );
173
+ $key = 'main';
174
+
175
+ if( is_array( $sections ) ) {
176
+ $key = key( $sections );
177
+ }
178
+
179
+ $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key;
180
+
181
+ ob_start();
182
+ ?>
183
+ <div class="wrap">
184
+ <?php if( $this->show_title ) { ?>
185
+ <h2><?php echo $this->page_title; ?></h2>
186
+ <?php } ?>
187
+ <h2 class="nav-tab-wrapper">
188
+ <?php
189
+ foreach( $this->get_settings_tabs() as $tab_id => $tab_name ) {
190
+ $tab_url = add_query_arg( array(
191
+ 'settings-updated' => false,
192
+ 'tab' => $tab_id
193
+ ) );
194
+
195
+ // Remove the section from the tabs so we always end up at the main section
196
+ $tab_url = remove_query_arg( 'section', $tab_url );
197
+
198
+ $tab_url = apply_filters( $this->func . '_settings_tab_url_' . $tab_id, $tab_url );
199
+ $tab_url = apply_filters( $this->func . '_settings_tab_url', $tab_url );
200
+
201
+ $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
202
+
203
+ echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">' . esc_html( $tab_name ) . '</a>';
204
+ }
205
+ ?>
206
+ </h2>
207
+ <?php
208
+
209
+ $number_of_sections = count( $sections );
210
+ $number = 0;
211
+
212
+ if( $number_of_sections > 1 ) {
213
+ echo '<div><ul class="subsubsub">';
214
+
215
+ foreach( $sections as $section_id => $section_name ) {
216
+ echo '<li>';
217
+
218
+ $number++;
219
+ $tab_url = add_query_arg( array(
220
+ 'settings-updated' => false,
221
+ 'tab' => $active_tab,
222
+ 'section' => $section_id
223
+ ) );
224
+ $class = '';
225
+
226
+ if( $section == $section_id ) {
227
+ $class = 'current';
228
+ }
229
+
230
+ $tab_url = apply_filters( $this->func . '_settings_section_url_' . $section_id, $tab_url );
231
+ $tab_url = apply_filters( $this->func . '_settings_section_url', $tab_url );
232
+
233
+ echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>';
234
+
235
+ if( $number != $number_of_sections ) {
236
+ echo ' | ';
237
+ }
238
+
239
+ echo '</li>';
240
+ }
241
+
242
+ echo '</ul></div>';
243
+ }
244
+ ?>
245
+ <div id="tab_container">
246
+ <form method="post" action="options.php">
247
+ <table class="form-table">
248
+ <?php
249
+ settings_fields( $this->func . '_settings' );
250
+
251
+ do_action( $this->func . '_settings_tab_top_' . $active_tab, $section );
252
+
253
+ do_action( $this->func . '_settings_tab_top_' . $active_tab . '_' . $section );
254
+
255
+ do_settings_sections( $this->func . '_settings_' . $active_tab . '_' . $section );
256
+
257
+ do_action( $this->func . '_settings_tab_bottom_' . $active_tab, $section );
258
+
259
+ do_action( $this->func . '_settings_tab_bottom_' . $active_tab . '_' . $section );
260
+ ?>
261
+ </table>
262
+ <?php
263
+ if( ! in_array( $active_tab, apply_filters( $this->func . '_unsavable_tabs', array() ) ) ) {
264
+ submit_button();
265
+ }
266
+ ?>
267
+ </form>
268
+ </div>
269
+ </div>
270
+ <?php
271
+ echo ob_get_clean();
272
+ }
273
+
274
+
275
+ /**
276
+ * Retrieve the settings tabs
277
+ *
278
+ * @access private
279
+ * @since 1.0.0
280
+ * @return array $tabs The registered tabs for this plugin
281
+ */
282
+ private function get_settings_tabs() {
283
+ return apply_filters( $this->func . '_settings_tabs', array() );
284
+ }
285
+
286
+
287
+ /**
288
+ * Retrieve settings tab sections
289
+ *
290
+ * @access public
291
+ * @since 1.0.1
292
+ * @param string $tab The current tab
293
+ * @return array $section The section items
294
+ */
295
+ public function get_settings_tab_sections( $tab = false ) {
296
+ $tabs = false;
297
+ $sections = $this->get_registered_settings_sections();
298
+
299
+ if( $tab && ! empty( $sections[$tab] ) ) {
300
+ $tabs = $sections[$tab];
301
+ } elseif( $tab ) {
302
+ $tabs = false;
303
+ }
304
+
305
+ return $tabs;
306
+ }
307
+
308
+
309
+ /**
310
+ * Retrieve the plugin settings
311
+ *
312
+ * @access public
313
+ * @since 1.0.0
314
+ * @return array $settings The plugin settings
315
+ */
316
+ public function get_registered_settings() {
317
+ return apply_filters( $this->func . '_registered_settings', array() );
318
+ }
319
+
320
+
321
+ /**
322
+ * Retrieve the plugin settings sections
323
+ *
324
+ * @access private
325
+ * @since 1.0.1
326
+ * @return array $sections The registered sections
327
+ */
328
+ private function get_registered_settings_sections() {
329
+ global ${$this->func . '_sections'};
330
+
331
+ if ( !empty( ${$this->func . '_sections'} ) ) {
332
+ return ${$this->func . '_sections'};
333
+ }
334
+
335
+ ${$this->func . '_sections'} = apply_filters( $this->func . '_registered_settings_sections', array() );
336
+
337
+ return ${$this->func . '_sections'};
338
+ }
339
+
340
+
341
+ /**
342
+ * Retrieve an option
343
+ *
344
+ * @access public
345
+ * @since 1.0.0
346
+ * @param string $key The key to retrieve
347
+ * @param mixed $default The default value if key doesn't exist
348
+ * @global array ${$this->func . '_options'} The options array
349
+ * @return mixed $value The value to return
350
+ */
351
+ public function get_option( $key = '', $default = false ) {
352
+ global ${$this->func . '_options'};
353
+
354
+ $value = ! empty( ${$this->func . '_options'}[$key] ) ? ${$this->func . '_options'}[$key] : $default;
355
+ $value = apply_filters( $this->func . '_get_option', $value, $key, $default );
356
+
357
+ return apply_filters( $this->func . '_get_option_' . $key, $value, $key, $default );
358
+ }
359
+
360
+
361
+ /**
362
+ * Update an option
363
+ *
364
+ * @access public
365
+ * @since 1.0.0
366
+ * @param string $key The key to update
367
+ * @param mixed $value The value to set key to
368
+ * @return bool true if updated, false otherwise
369
+ */
370
+ public function update_option( $key = '', $value = false ) {
371
+ // Bail if no key is set
372
+ if( empty( $key ) ) {
373
+ return false;
374
+ }
375
+
376
+ if( empty( $value ) ) {
377
+ $remove_option = $this->delete_option( $key );
378
+ return $remove_option;
379
+ }
380
+
381
+ // Fetch a clean copy of the options array
382
+ $options = get_option( $this->func . '_settings' );
383
+
384
+ // Allow devs to modify the value
385
+ $value = apply_filters( $this->func . '_update_option', $value, $key );
386
+
387
+ // Try to update the option
388
+ $options[$key] = $value;
389
+ $did_update = update_option( $this->func . '_settings', $options );
390
+
391
+ // Update the global
392
+ if( $did_update ) {
393
+ global ${$this->func . '_options'};
394
+ ${$this->func . '_options'}[$key] = $value;
395
+ }
396
+
397
+ return $did_update;
398
+ }
399
+
400
+
401
+ /**
402
+ * Delete an option
403
+ *
404
+ * @access public
405
+ * @since 1.0.0
406
+ * @param string $key The key to delete
407
+ * @return bool true if deleted, false otherwise
408
+ */
409
+ public function delete_option( $key = '' ) {
410
+ // Bail if no key is set
411
+ if( empty( $key ) ) {
412
+ return false;
413
+ }
414
+
415
+ // Fetch a clean copy of the options array
416
+ $options = get_option( $this->func . '_settings' );
417
+
418
+ // Try to unset the option
419
+ if( isset( $options[$key] ) ) {
420
+ unset( $options[$key] );
421
+ }
422
+
423
+ $did_update = update_option( $this->func . '_settings', $options );
424
+
425
+ // Update the global
426
+ if( $did_update ) {
427
+ global ${$this->func . '_options'};
428
+ ${$this->func . '_options'} = $options;
429
+ }
430
+
431
+ return $did_update;
432
+ }
433
+
434
+
435
+ /**
436
+ * Retrieve all options
437
+ *
438
+ * @access public
439
+ * @since 1.0.0
440
+ * @return array $settings The options array
441
+ */
442
+ public function get_settings() {
443
+ $settings = get_option( $this->func . '_settings' );
444
+
445
+ if( empty( $settings ) ) {
446
+ $settings = array();
447
+
448
+ update_option( $this->func . '_settings', $settings );
449
+ }
450
+
451
+ return apply_filters( $this->func . '_get_settings', $settings );
452
+ }
453
+
454
+
455
+ /**
456
+ * Add settings sections and fields
457
+ *
458
+ * @access public
459
+ * @since 1.0.0
460
+ * @return void
461
+ */
462
+ function register_settings() {
463
+ if( get_option( $this->func . '_settings' ) == false ) {
464
+ add_option( $this->func . '_settings' );
465
+ }
466
+
467
+ foreach( $this->get_registered_settings() as $tab => $sections ) {
468
+ foreach( $sections as $section => $settings ) {
469
+ // Check for backwards compatibility
470
+ $section_tabs = $this->get_settings_tab_sections( $tab );
471
+
472
+ if( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
473
+ $section = 'main';
474
+ $settings = $sections;
475
+ }
476
+
477
+ add_settings_section(
478
+ $this->func . '_settings_' . $tab . '_' . $section,
479
+ __return_null(),
480
+ '__return_false',
481
+ $this->func . '_settings_' . $tab . '_' . $section
482
+ );
483
+
484
+ foreach( $settings as $option ) {
485
+ // For backwards compatibility
486
+ if( empty( $option['id'] ) ) {
487
+ continue;
488
+ }
489
+
490
+ $name = isset( $option['name'] ) ? $option['name'] : '';
491
+
492
+ add_settings_field(
493
+ $this->func . '_settings[' . $option['id'] . ']',
494
+ $name,
495
+ function_exists(
496
+ $this->func . '_' . $option['type'] . '_callback' )
497
+ ? $this->func . '_' . $option['type'] . '_callback'
498
+ : ( method_exists( $this, $option['type'] . '_callback' )
499
+ ? array( $this, $option['type'] . '_callback' )
500
+ : array( $this, 'missing_callback' )
501
+ ),
502
+ $this->func . '_settings_' . $tab . '_' . $section,
503
+ $this->func . '_settings_' . $tab . '_' . $section,
504
+ array(
505
+ 'section' => $section,
506
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
507
+ 'desc' => ! empty( $option['desc'] ) ? $option['desc'] : '',
508
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
509
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
510
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
511
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
512
+ 'min' => isset( $option['min'] ) ? $option['min'] : null,
513
+ 'max' => isset( $option['max'] ) ? $option['max'] : null,
514
+ 'step' => isset( $option['step'] ) ? $option['step'] : null,
515
+ 'select2' => isset( $option['select2'] ) ? $option['select2'] : null,
516
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
517
+ 'multiple' => isset( $option['multiple'] ) ? $option['multiple'] : null,
518
+ 'allow_blank' => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
519
+ 'readonly' => isset( $option['readonly'] ) ? $option['readonly'] : false,
520
+ 'buttons' => isset( $option['buttons'] ) ? $option['buttons'] : null,
521
+ 'wpautop' => isset( $option['wpautop'] ) ? $option['wpautop'] : null,
522
+ 'teeny' => isset( $option['teeny'] ) ? $option['teeny'] : null,
523
+ 'tab' => isset( $option['tab'] ) ? $option['tab'] : null,
524
+ 'tooltip_title' => isset( $option['tooltip_title'] ) ? $option['tooltip_title'] : false,
525
+ 'tooltip_desc' => isset( $option['tooltip_desc'] ) ? $option['tooltip_desc'] : false,
526
+ 'class' => isset( $option['class'] ) ? $option['class'] : '',
527
+ )
528
+ );
529
+ }
530
+ }
531
+ }
532
+
533
+ register_setting( $this->func . '_settings', $this->func . '_settings', array( $this, 'settings_sanitize' ) );
534
+ }
535
+
536
+
537
+ /**
538
+ * Settings sanitization
539
+ *
540
+ * @access public
541
+ * @since 1.0.0
542
+ * @param array $input The value entered in the field
543
+ * @global array ${$this->func . '_options'} The options array
544
+ * @return string $input The sanitized value
545
+ */
546
+ public function settings_sanitize( $input = array() ) {
547
+ global ${$this->func . '_options'};
548
+
549
+ $doing_section = false;
550
+
551
+ if( ! empty( $_POST['_wp_http_referer'] ) ) {
552
+ $doing_section = true;
553
+ }
554
+
555
+ $setting_types = $this->get_registered_settings_types();
556
+ $input = $input ? $input : array();
557
+
558
+ if( $doing_section ) {
559
+ parse_str( $_POST['_wp_http_referer'], $referrer );
560
+
561
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : $this->default_tab;
562
+ $section = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
563
+ $input = apply_filters( $this->func . '_settings_' . $tab . '_sanitize', $input );
564
+ $input = apply_filters( $this->func . '_settings_' . $tab . '-' . $section . '_sanitize', $input );
565
+ }
566
+
567
+ $output = array_merge( ${$this->func . '_options'}, $input );
568
+
569
+ foreach( $setting_types as $key => $type ) {
570
+ if( empty( $type ) ) {
571
+ continue;
572
+ }
573
+
574
+ // Bypass non-setting settings
575
+ $non_setting_types = apply_filters( $this->func . '_non_setting_types', array(
576
+ 'header', 'descriptive_text', 'hook'
577
+ ) );
578
+
579
+ if( in_array( $type, $non_setting_types ) ) {
580
+ continue;
581
+ }
582
+
583
+ if( array_key_exists( $key, $output ) ) {
584
+ $output[$key] = apply_filters( $this->func . '_settings_sanitize_' . $type, $output[$key], $key );
585
+ $output[$key] = apply_filters( $this->func . '_settings_sanitize', $output[$key], $key );
586
+ }
587
+
588
+ if( $doing_section ) {
589
+ switch( $type ) {
590
+ case 'checkbox':
591
+ if( array_key_exists( $key, $input ) && $output[$key] === '-1' ) {
592
+ unset( $output[$key] );
593
+ }
594
+ break;
595
+ default:
596
+ if( array_key_exists( $key, $input ) && empty( $input[$key] ) ) {
597
+ unset( $output[$key] );
598
+ }
599
+ break;
600
+ }
601
+ } else {
602
+ if( empty( $input[$key] ) ) {
603
+ unset( $output[$key] );
604
+ }
605
+ }
606
+ }
607
+
608
+ if( $doing_section ) {
609
+ add_settings_error( $this->slug . '-notices', '', __( 'Settings updated.', 'wpdesk-plugin' ), 'updated' );
610
+ }
611
+
612
+ return $output;
613
+ }
614
+
615
+
616
+ /**
617
+ * Flattens the set of registered settings and their type so we can easily sanitize all settings
618
+ *
619
+ * @since 1.2.0
620
+ * @return array Key is the setting ID, value is the type of setting it is registered as
621
+ */
622
+ function get_registered_settings_types() {
623
+ $settings = $this->get_registered_settings();
624
+ $setting_types = array();
625
+
626
+ foreach( $settings as $tab ) {
627
+ foreach( $tab as $section_or_setting ) {
628
+ // See if we have a setting registered at the tab level for backwards compatibility
629
+ if( is_array( $section_or_setting ) && array_key_exists( 'type', $section_or_setting ) ) {
630
+ $setting_types[$section_or_setting['id']] = $section_or_setting['type'];
631
+ continue;
632
+ }
633
+
634
+ foreach( $section_or_setting as $section => $section_settings ) {
635
+ $setting_types[$section_settings['id']] = $section_settings['type'];
636
+ }
637
+ }
638
+ }
639
+
640
+ return $setting_types;
641
+ }
642
+
643
+
644
+ /**
645
+ * Sanitize text fields
646
+ *
647
+ * @access public
648
+ * @since 1.0.0
649
+ * @param array $input The value entered in the field
650
+ * @return string $input The sanitized value
651
+ */
652
+ public function sanitize_text_field( $input ) {
653
+ return trim( wp_strip_all_tags( $input, true ) );
654
+ }
655
+
656
+
657
+ /**
658
+ * Header callback
659
+ *
660
+ * @access public
661
+ * @since 1.0.0
662
+ * @param array $args Arguments passed by the setting
663
+ * @return void
664
+ */
665
+ public function header_callback( $args ) {
666
+ echo '<hr />';
667
+ }
668
+
669
+
670
+ /**
671
+ * Checkbox callback
672
+ *
673
+ * @access public
674
+ * @since 1.0.0
675
+ * @param array $args Arguments passed by the setting
676
+ * @global array ${$this->func . '_options'} The plugin options
677
+ * @return void
678
+ */
679
+ public function checkbox_callback( $args ) {
680
+ global ${$this->func . '_options'};
681
+
682
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
683
+ $checked = isset( ${$this->func . '_options'}[$args['id']] ) ? checked( 1, ${$this->func . '_options'}[$args['id']], false ) : '';
684
+
685
+ $html = '<input type="hidden"' . $name . ' value="-1" />';
686
+ $html .= '<input type="checkbox" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="1" ' . $checked . '/>&nbsp;';
687
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
688
+
689
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
690
+ }
691
+
692
+
693
+ /**
694
+ * Color callback
695
+ *
696
+ * @access public
697
+ * @since 1.0.0
698
+ * @param array $args Arguments passed by the settings
699
+ * @global array ${$this->func . '_options'} The Beacon options
700
+ * @return void
701
+ */
702
+ public function color_callback( $args ) {
703
+ global ${$this->func . '_options'};
704
+
705
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
706
+ $value = ${$this->func . '_options'}[$args['id']];
707
+ } else {
708
+ $value = isset( $args['std'] ) ? $args['std'] : '';
709
+ }
710
+
711
+ $default = isset( $args['std'] ) ? $args['std'] : '';
712
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
713
+
714
+ $html = '<input type="text" class="s214-color-picker" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />&nbsp;';
715
+ $html .= '<span class="s214-color-picker-label description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
716
+
717
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
718
+ }
719
+
720
+
721
+ /**
722
+ * Descriptive text callback
723
+ *
724
+ * @access public
725
+ * @since 1.0.0
726
+ * @param array $args Arguments passed by the setting
727
+ * @return void
728
+ */
729
+ public function descriptive_text_callback( $args ) {
730
+ $html = wp_kses_post( $args['desc'] );
731
+
732
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
733
+ }
734
+
735
+
736
+ /**
737
+ * Editor callback
738
+ *
739
+ * @access public
740
+ * @since 1.0.0
741
+ * @param array $args Arguments passed by the setting
742
+ * @global array ${$this->func . '_options'} The Beacon options
743
+ * @return void
744
+ */
745
+ public function editor_callback( $args ) {
746
+ global ${$this->func . '_options'};
747
+
748
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
749
+ $value = ${$this->func . '_options'}[$args['id']];
750
+
751
+ if( empty( $args['allow_blank'] ) && empty( $value ) ) {
752
+ $value = isset( $args['std'] ) ? $args['std'] : '';
753
+ }
754
+ } else {
755
+ $value = isset( $args['std'] ) ? $args['std'] : '';
756
+ }
757
+
758
+ $rows = isset( $args['size'] ) ? $args['size'] : '10';
759
+ $wpautop = isset( $args['wpautop'] ) ? $args['wpautop'] : true;
760
+ $buttons = isset( $args['buttons'] ) ? $args['buttons'] : true;
761
+ $teeny = isset( $args['teeny'] ) ? $args['teeny'] : false;
762
+
763
+ wp_editor(
764
+ $value,
765
+ $this->func . '_settings_' . $args['id'],
766
+ array(
767
+ 'wpautop' => $wpautop,
768
+ 'media_buttons' => $buttons,
769
+ 'textarea_name' => $this->func . '_settings[' . $args['id'] . ']',
770
+ 'textarea_rows' => $rows,
771
+ 'teeny' => $teeny
772
+ )
773
+ );
774
+ $html = '<br /><span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
775
+
776
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
777
+ }
778
+
779
+
780
+ /**
781
+ * HTML callback
782
+ *
783
+ * @since 1.0.0
784
+ * @param array $args Arguments passed by the setting
785
+ * @global array ${$this->func . '_options'} The Beacon options
786
+ * @return void
787
+ */
788
+ public function html_callback( $args ) {
789
+ global ${$this->func . '_options'};
790
+
791
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
792
+ $value = ${$this->func . '_options'}[$args['id']];
793
+ } else {
794
+ $value = isset( $args['std'] ) ? $args['std'] : '';
795
+ }
796
+
797
+ $html = '<textarea class="large-text s214-html" cols="50" rows="5" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>&nbsp;';
798
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
799
+
800
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
801
+ }
802
+
803
+
804
+ /**
805
+ * Multicheck callback
806
+ *
807
+ * @access public
808
+ * @since 1.0.0
809
+ * @param array $args Arguments passed by the setting
810
+ * @global array ${$this->func . '_options'} The Beacon options
811
+ * @return void
812
+ */
813
+ public function multicheck_callback( $args ) {
814
+ global ${$this->func . '_options'};
815
+
816
+ if( ! empty( $args['options'] ) ) {
817
+ $html = '';
818
+
819
+ foreach( $args['options'] as $key => $option ) {
820
+ if( isset( ${$this->func . '_options'}[$args['id']][$key] ) ) {
821
+ $enabled = $option;
822
+ } else {
823
+ $enabled = isset( $args['std'][$key] ) ? $args['std'][$key] : NULL;
824
+ }
825
+
826
+ $html .= '<input name="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" id="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . ' />&nbsp;';
827
+ $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
828
+ }
829
+ $html .= '<p class="description">' . $args['desc'] . '</p>';
830
+
831
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
832
+ }
833
+ }
834
+
835
+
836
+ /**
837
+ * Number callback
838
+ *
839
+ * @access public
840
+ * @since 1.0.0
841
+ * @param array $args Arguments passed by the setting
842
+ * @global array ${$this->func . '_options'} The Beacon options
843
+ * @return void
844
+ */
845
+ public function number_callback( $args ) {
846
+ global ${$this->func . '_options'};
847
+
848
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
849
+ $value = ${$this->func . '_options'}[$args['id']];
850
+ } else {
851
+ $value = isset( $args['std'] ) ? $args['std'] : '';
852
+ }
853
+
854
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
855
+ $max = isset( $args['max'] ) ? $args['max'] : 999999;
856
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
857
+ $step = isset( $args['step'] ) ? $args['step'] : 1;
858
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
860
+
861
+ $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
862
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
863
+
864
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
865
+ }
866
+
867
+
868
+ /**
869
+ * Password callback
870
+ *
871
+ * @access public
872
+ * @since 1.0.0
873
+ * @param array $args Arguments passed by the settings
874
+ * @global array ${$this->func . '_options'} The Beacon options
875
+ * @return void
876
+ */
877
+ public function password_callback( $args ) {
878
+ global ${$this->func . '_options'};
879
+
880
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
881
+ $value = ${$this->func . '_options'}[$args['id']];
882
+ } else {
883
+ $value = isset( $args['std'] ) ? $args['std'] : '';
884
+ }
885
+
886
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
887
+
888
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
889
+
890
+ $html = '<input type="password" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"' . $readonly . ' />&nbsp;';
891
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
892
+
893
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
894
+ }
895
+
896
+
897
+ /**
898
+ * Radio callback
899
+ *
900
+ * @access public
901
+ * @since 1.0.0
902
+ * @param array $args Arguments passed by the setting
903
+ * @global array ${$this->func . '_options'} The Beacon options
904
+ * @return void
905
+ */
906
+ public function radio_callback( $args ) {
907
+ global ${$this->func . '_options'};
908
+
909
+ if( ! empty( $args['options'] ) ) {
910
+ $html = '';
911
+
912
+ foreach( $args['options'] as $key => $option ) {
913
+ $checked = false;
914
+
915
+ if( isset( ${$this->func . '_options'}[$args['id']] ) && ${$this->func . '_options'}[$args['id']] == $key ) {
916
+ $checked = true;
917
+ } elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( ${$this->func . '_options'}[$args['id']] ) ) {
918
+ $checked = true;
919
+ }
920
+
921
+ $html .= '<input name="' . $this->func . '_settings[' . $args['id'] . ']" id="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
922
+ $html .= '<label for="' . $this->func . '_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br />';
923
+ }
924
+
925
+ $html .= '<p class="description">' . $args['desc'] . '</p>';
926
+
927
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
928
+ }
929
+ }
930
+
931
+
932
+ /**
933
+ * Select callback
934
+ *
935
+ * @access public
936
+ * @since 1.0.0
937
+ * @param array $args Arguments passed by the setting
938
+ * @global array ${$this->func . '_options'} The Beacon options
939
+ * @return void
940
+ */
941
+ public function select_callback( $args ) {
942
+ global ${$this->func . '_options'};
943
+
944
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
945
+ $value = ${$this->func . '_options'}[$args['id']];
946
+ } else {
947
+ $value = isset( $args['std'] ) ? $args['std'] : '';
948
+ }
949
+
950
+ $placeholder = isset( $args['placeholder'] ) ? $args['placeholder'] : '';
951
+ $select2 = isset( $args['select2'] ) ? ' class="s214-select2"' : '';
952
+ $width = isset( $args['size'] ) ? ' style="width: ' . $args['size'] . '"' : '';
953
+
954
+ if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
955
+ $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . '][]"' . $select2 . ' data-placeholder="' . $placeholder . '" multiple="multiple"' . $width . ' />';
956
+ } else {
957
+ $html = '<select id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']"' . $select2 . ' data-placeholder="' . $placeholder . '"' . $width . ' />';
958
+ }
959
+
960
+ foreach( $args['options'] as $option => $name ) {
961
+ if( isset( $args['multiple'] ) && $args['multiple'] === true ) {
962
+ if( is_array( $value ) ) {
963
+ $selected = ( in_array( $option, $value ) ? 'selected="selected"' : '' );
964
+ } else {
965
+ $selected = '';
966
+ }
967
+ } else {
968
+ if( is_string( $value ) ) {
969
+ $selected = selected( $option, $value, false );
970
+ } else {
971
+ $selected = '';
972
+ }
973
+ }
974
+
975
+ $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
976
+ }
977
+
978
+ $html .= '</select>&nbsp;';
979
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
980
+
981
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
982
+ }
983
+
984
+
985
+ /**
986
+ * Sysinfo callback
987
+ *
988
+ * @since 1.1.0
989
+ * @param array $args Arguements passed by the settings
990
+ * @return void
991
+ */
992
+ public function sysinfo_callback( $args ) {
993
+ global ${$this->func . '_options'};
994
+
995
+ if( ! isset( ${$this->func . '_options'}[$args['tab']] ) || ( isset( ${$this->func . '_options'}[$args['tab']] ) && isset( $_GET['tab'] ) && $_GET['tab'] == ${$this->func . '_options'}[$args['tab']] ) ) {
996
+ $html = '<textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="' . $this->func . '-system-info" title="' . __( 'To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac).', 'wpdesk-plugin' ) . '">' . $this->sysinfo->get_system_info() . '</textarea>';
997
+ $html .= '<p class="submit">';
998
+ $html .= '<input type="hidden" name="' . $this->slug . '-settings-action" value="download_system_info" />';
999
+ $html .= '<a class="button button-primary" href="' . add_query_arg( $this->slug . '-settings-action', 'download_system_info' ) . '">' . __( 'Download System Info File', 'wpdesk-plugin' ) . '</a>';
1000
+ $html .= '</p>';
1001
+
1002
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1003
+ }
1004
+ }
1005
+
1006
+
1007
+ /**
1008
+ * Text callback
1009
+ *
1010
+ * @since 1.0.0
1011
+ * @param array $args Arguments passed by the setting
1012
+ * @global array ${$this->func . '_options'} The Beacon options
1013
+ * @return void
1014
+ */
1015
+ public function text_callback( $args ) {
1016
+ global ${$this->func . '_options'};
1017
+
1018
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1019
+ $value = ${$this->func . '_options'}[$args['id']];
1020
+ } else {
1021
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1022
+ }
1023
+
1024
+ $name = ' name="' . $this->func . '_settings[' . $args['id'] . ']"';
1025
+ $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
1026
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1027
+
1028
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']"' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>&nbsp;';
1029
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1030
+
1031
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1032
+ }
1033
+
1034
+
1035
+ /**
1036
+ * Textarea callback
1037
+ *
1038
+ * @since 1.0.0
1039
+ * @param array $args Arguments passed by the setting
1040
+ * @global array ${$this->func . '_options'} The Beacon options
1041
+ * @return void
1042
+ */
1043
+ public function textarea_callback( $args ) {
1044
+ global ${$this->func . '_options'};
1045
+
1046
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1047
+ $value = ${$this->func . '_options'}[$args['id']];
1048
+ } else {
1049
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1050
+ }
1051
+
1052
+ $html = '<textarea class="large-text" cols="50" rows="5" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>&nbsp;';
1053
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1054
+
1055
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1056
+ }
1057
+
1058
+
1059
+ /**
1060
+ * Upload callback
1061
+ *
1062
+ * @since 1.0.0
1063
+ * @param array $args Arguments passed by the setting
1064
+ * @global array ${$this->func . '_options'} The Beacon options
1065
+ * @return void
1066
+ */
1067
+ public function upload_callback( $args ) {
1068
+ global ${$this->func . '_options'};
1069
+
1070
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1071
+ $value = ${$this->func . '_options'}[$args['id']];
1072
+ } else {
1073
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1074
+ }
1075
+
1076
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1077
+
1078
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '" />&nbsp;';
1079
+ $html .= '<span><input type="button" class="' . $this->func . '_settings_upload_button button-secondary" value="' . __( 'Upload File', 'wpdesk-plugin' ) . '" /></span>&nbsp;';
1080
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']">' . $args['desc'] . '</label></span>';
1081
+
1082
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1083
+ }
1084
+
1085
+
1086
+ /**
1087
+ * License field callback
1088
+ *
1089
+ * @access public
1090
+ * @since 1.0.0
1091
+ * @param array $args Arguments passed by the setting
1092
+ * @global array ${$this->func . '_options'} The Beacon options
1093
+ * @return void
1094
+ */
1095
+ public function license_key_callback( $args ) {
1096
+ global ${$this->func . '_options'};
1097
+
1098
+ if( isset( ${$this->func . '_options'}[$args['id']] ) ) {
1099
+ $value = ${$this->func . '_options'}[$args['id']];
1100
+ } else {
1101
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1102
+ }
1103
+
1104
+ $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1105
+
1106
+ $html = '<input type="text" class="' . $size . '-text" id="' . $this->func . '_settings[' . $args['id'] . ']" name="' . $this->func . '_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" />&nbsp;';
1107
+
1108
+ if( get_option( $args['options']['is_valid_license_option'] ) ) {
1109
+ $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'wpdesk-plugin' ) . '"/>';
1110
+ }
1111
+ $html .= '<span class="description"><label for="' . $this->func . '_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label></span>';
1112
+
1113
+ wp_nonce_field( $args['id'] . '-nonce', $args['id'] . '-nonce' );
1114
+
1115
+ echo apply_filters( $this->func . '_after_setting_output', $html, $args );
1116
+ }
1117
+
1118
+
1119
+ /**
1120
+ * Hook callback
1121
+ *
1122
+ * @since 1.0.0
1123
+ * @param array $args Arguments passed by the setting
1124
+ * @return void
1125
+ */
1126
+ public function hook_callback( $args ) {
1127
+ do_action( $this->func . '_' . $args['id'] );
1128
+ }
1129
+
1130
+
1131
+ /**
1132
+ * Missing callback
1133
+ *
1134
+ * @access public
1135
+ * @since 1.0.0
1136
+ * @param array $args Arguments passed by the setting
1137
+ * @return void
1138
+ */
1139
+ public function missing_callback( $args ) {
1140
+ printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'wpdesk-plugin' ), $args['id'] );
1141
+ }
1142
+
1143
+
1144
+ /**
1145
+ * Check if we should load admin scripts
1146
+ *
1147
+ * @access public
1148
+ * @since 1.0.0
1149
+ * @param string $hook The hook for the current page
1150
+ * @return bool true if we should load scripts, false otherwise
1151
+ */
1152
+ public function load_scripts( $hook ) {
1153
+ global $typenow, $pagenow, ${$this->func . '_settings_page'};
1154
+
1155
+ $ret = false;
1156
+ $pages = apply_filters( $this->func . '_admin_pages', array( ${$this->func . '_settings_page'} ) );
1157
+
1158
+ if( in_array( $hook, $pages ) ) {
1159
+ $ret = true;
1160
+ }
1161
+
1162
+ return (bool) apply_filters( $this->func . 'load_scripts', $ret );
1163
+ }
1164
+
1165
+
1166
+ /**
1167
+ * Processes all actions sent via POST and GET by looking for the '$func-settings-action'
1168
+ * request and running do_action() to call the function
1169
+ *
1170
+ * @since 1.1.0
1171
+ * @return void
1172
+ */
1173
+ function process_actions() {
1174
+ if( ! isset( $_POST['submit'] ) ) {
1175
+ if( isset( $_POST[$this->slug . '-settings-action'] ) ) {
1176
+ do_action( $this->func . '_settings_' . $_POST[$this->slug . '-settings-action'], $_POST );
1177
+ }
1178
+
1179
+ if( isset( $_GET[$this->slug . '-settings-action'] ) ) {
1180
+ do_action( $this->func . '_settings_' . $_GET[$this->slug . '-settings-action'], $_GET );
1181
+ }
1182
+ }
1183
+ }
1184
+
1185
+
1186
+ /**
1187
+ * Enqueue scripts
1188
+ *
1189
+ * @access public
1190
+ * @since 1.0.0
1191
+ * @param string $hook The current page hook
1192
+ * @return void
1193
+ */
1194
+ public function enqueue_scripts( $hook ) {
1195
+ if( ! apply_filters( $this->func . '_load_admin_scripts', $this->load_scripts( $hook ), $hook ) ) {
1196
+ return;
1197
+ }
1198
+
1199
+ // Use minified libraries if SCRIPT_DEBUG is turned off
1200
+ $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) ? '' : '.min';
1201
+ $ui_style = ( get_user_option( 'admin_color' ) == 'classic' ) ? 'classic' : 'fresh';
1202
+ $url_path = str_replace( WP_CONTENT_DIR, WP_CONTENT_URL, dirname( __FILE__ ) );
1203
+ $select2_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.2/';
1204
+ $cm_cdn = 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.14.2/';
1205
+
1206
+ wp_enqueue_style( 'wp-color-picker' );
1207
+ wp_enqueue_script( 'wp-color-picker' );
1208
+ wp_enqueue_script( 'jquery-ui-tooltip' );
1209
+ wp_enqueue_media();
1210
+ wp_enqueue_style( 'jquery-ui-css', $url_path . '/assets/css/jquery-ui-' . $ui_style . '.min.css' );
1211
+ wp_enqueue_script( 'media-upload' );
1212
+ wp_enqueue_style( 'thickbox' );
1213
+ wp_enqueue_script( 'thickbox' );
1214
+ wp_enqueue_style( 'select2', $select2_cdn . 'css/select2.min.css', array(), '4.0.2' );
1215
+ wp_enqueue_script( 'select2', $select2_cdn . 'js/select2.min.js', array( 'jquery' ), '4.0.2' );
1216
+
1217
+ wp_enqueue_style( $this->slug . '-cm', $cm_cdn . 'codemirror.css', array(), '5.10' );
1218
+ wp_enqueue_script( $this->slug . '-cm', $cm_cdn . 'codemirror.js', array( 'jquery' ), '5.14.2' );
1219
+ wp_enqueue_script( $this->slug . '-cm-html', $cm_cdn . 'mode/htmlmixed/htmlmixed.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1220
+ wp_enqueue_script( $this->slug . '-cm-xml', $cm_cdn . 'mode/xml/xml.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1221
+ wp_enqueue_script( $this->slug . '-cm-js', $cm_cdn . 'mode/javascript/javascript.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1222
+ wp_enqueue_script( $this->slug . '-cm-css', $cm_cdn . 'mode/css/css.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1223
+ wp_enqueue_script( $this->slug . '-cm-php', $cm_cdn . 'mode/php/php.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1224
+ wp_enqueue_script( $this->slug . '-cm-clike', $cm_cdn . 'mode/clike/clike.js', array( 'jquery', $this->slug . '-cm' ), '5.14.2' );
1225
+
1226
+ wp_enqueue_style( $this->slug, $url_path . '/assets/css/admin' . $suffix . '.css', array(), $this->version );
1227
+ wp_enqueue_script( $this->slug, $url_path . '/assets/js/admin' . $suffix . '.js', array( 'jquery' ), $this->version );
1228
+ wp_localize_script( $this->slug, 's214_settings_vars', apply_filters( $this->func . 'localize_script', array(
1229
+ 'func' => $this->func,
1230
+ 'image_media_button' => __( 'Insert Image', 'wpdesk-plugin' ),
1231
+ 'image_media_title' => __( 'Select Image', 'wpdesk-plugin' ),
1232
+ ) ) );
1233
+ }
1234
+
1235
+
1236
+ /**
1237
+ * Add tooltips
1238
+ *
1239
+ * @access public
1240
+ * @since 1.2.0
1241
+ * @param string $html The current field HTML
1242
+ * @param array $args Arguments passed to the field
1243
+ * @return string $html The updated field HTML
1244
+ */
1245
+ function add_setting_tooltip( $html, $args ) {
1246
+ if( ! empty( $args['tooltip_title'] ) && ! empty( $args['tooltip_desc'] ) ) {
1247
+ $tooltip = '<span alt="f223" class="s214-help-tip dashicons dashicons-editor-help" title="<strong>' . $args['tooltip_title'] . '</strong>: ' . $args['tooltip_desc'] . '"></span>';
1248
+ $html .= $tooltip;
1249
+ }
1250
+
1251
+ return $html;
1252
+ }
1253
+ }
classes/wpdesk/settings-api/modules/sysinfo/browser.php ADDED
@@ -0,0 +1,1103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Exit if accessed directly
4
+ if ( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ /**
7
+ * Modified to remove var
8
+ * Chris Christoff on 12/26/2012
9
+ * Changes: Changes vars to publics
10
+ *
11
+ * Modified to work for EDD by
12
+ * Chris Christoff on 12/23/2012
13
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
14
+ *
15
+ * Modified to add formatted User Agent string for EDD System Info by
16
+ * Chris Christoff on 12/23/2012
17
+ * Changes: Split user string and add formatting so we can print a nicely
18
+ * formatted user agent string on the EDD System Info
19
+ *
20
+ * File: Browser.php
21
+ * Author: Chris Schuld (http://chrisschuld.com/)
22
+ * Last Modified: August 20th, 2010
23
+ *
24
+ * @version 1.9
25
+ * @package PegasusPHP
26
+ *
27
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
28
+ *
29
+ * This program is free software; you can redistribute it and/or
30
+ * modify it under the terms of the GNU General Public License as
31
+ * published by the Free Software Foundation; either version 2 of
32
+ * the License, or (at your option) any later version.
33
+ *
34
+ * This program is distributed in the hope that it will be useful,
35
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
36
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
37
+ * GNU General Public License for more details at:
38
+ * http://www.gnu.org/copyleft/gpl.html
39
+ *
40
+ *
41
+ * Typical Usage:
42
+ *
43
+ * $browser = new Browser();
44
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
45
+ * echo 'You have FireFox version 2 or greater';
46
+ * }
47
+ *
48
+ * User Agents Sampled from: http://www.useragentstring.com/
49
+ *
50
+ * This implementation is based on the original work from Gary White
51
+ * http://apptools.com/phptools/browser/
52
+ *
53
+ * UPDATES:
54
+ *
55
+ * 2010-08-20 (v1.9):
56
+ * + Added MSN Explorer Browser (legacy)
57
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
58
+ * + Added the Android Platform (PLATFORM_ANDROID)
59
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
60
+ *
61
+ * 2010-04-27 (v1.8):
62
+ * + Added iPad Support
63
+ *
64
+ * 2010-03-07 (v1.7):
65
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
66
+ * + Almost allof Gary's original code has been replaced
67
+ * + Large PHPUNIT testing environment created to validate new releases and additions
68
+ * + Added FreeBSD Platform
69
+ * + Added OpenBSD Platform
70
+ * + Added NetBSD Platform
71
+ * + Added SunOS Platform
72
+ * + Added OpenSolaris Platform
73
+ * + Added support of the Iceweazel Browser
74
+ * + Added isChromeFrame() call to check if chromeframe is in use
75
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
76
+ * + Added the __toString() method (Thanks Deano)
77
+ *
78
+ * 2009-11-15:
79
+ * + Updated the checkes for Firefox
80
+ * + Added the NOKIA platform
81
+ * + Added Checks for the NOKIA brower(s)
82
+ *
83
+ * 2009-11-08:
84
+ * + PHP 5.3 Support
85
+ * + Added support for BlackBerry OS and BlackBerry browser
86
+ * + Added support for the Opera Mini browser
87
+ * + Added additional documenation
88
+ * + Added support for isRobot() and isMobile()
89
+ * + Added support for Opera version 10
90
+ * + Added support for deprecated Netscape Navigator version 9
91
+ * + Added support for IceCat
92
+ * + Added support for Shiretoko
93
+ *
94
+ * 2010-04-27 (v1.8):
95
+ * + Added iPad Support
96
+ *
97
+ * 2009-08-18:
98
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
99
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
100
+ *
101
+ * 2009-04-27:
102
+ * + Updated the IE check to remove a typo and bug (thanks John)
103
+ *
104
+ * 2009-04-22:
105
+ * + Added detection for GoogleBot
106
+ * + Added detection for the W3C Validator.
107
+ * + Added detection for Yahoo! Slurp
108
+ *
109
+ * 2009-03-14:
110
+ * + Added detection for iPods.
111
+ * + Added Platform detection for iPhones
112
+ * + Added Platform detection for iPods
113
+ *
114
+ * 2009-02-16: (Rick Hale)
115
+ * + Added version detection for Android phones.
116
+ *
117
+ * 2008-12-09:
118
+ * + Removed unused constant
119
+ *
120
+ * 2008-11-07:
121
+ * + Added Google's Chrome to the detection list
122
+ * + Added isBrowser(string) to the list of functions special thanks to
123
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
124
+ *
125
+ *
126
+ * Gary White noted: "Since browser detection is so unreliable, I am
127
+ * no longer maintaining this script. You are free to use and or
128
+ * modify/update it as you want, however the author assumes no
129
+ * responsibility for the accuracy of the detected values."
130
+ *
131
+ * Anyone experienced with Gary's script might be interested in these notes:
132
+ *
133
+ * Added class constants
134
+ * Added detection and version detection for Google's Chrome
135
+ * Updated the version detection for Amaya
136
+ * Updated the version detection for Firefox
137
+ * Updated the version detection for Lynx
138
+ * Updated the version detection for WebTV
139
+ * Updated the version detection for NetPositive
140
+ * Updated the version detection for IE
141
+ * Updated the version detection for OmniWeb
142
+ * Updated the version detection for iCab
143
+ * Updated the version detection for Safari
144
+ * Updated Safari to remove mobile devices (iPhone)
145
+ * Added detection for iPhone
146
+ * Added detection for robots
147
+ * Added detection for mobile devices
148
+ * Added detection for BlackBerry
149
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
150
+ *
151
+ */
152
+
153
+ class Browser {
154
+ public $_agent = '';
155
+ public $_browser_name = '';
156
+ public $_version = '';
157
+ public $_platform = '';
158
+ public $_os = '';
159
+ public $_is_aol = false;
160
+ public $_is_mobile = false;
161
+ public $_is_robot = false;
162
+ public $_aol_version = '';
163
+
164
+ public $BROWSER_UNKNOWN = 'unknown';
165
+ public $VERSION_UNKNOWN = 'unknown';
166
+
167
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
168
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
169
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
170
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
171
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
172
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
173
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
174
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
175
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
176
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
177
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
178
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
179
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
180
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
181
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
182
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
183
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
184
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
185
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
186
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
187
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
188
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
189
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
190
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
191
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
192
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
193
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
194
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
195
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
196
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
197
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
198
+
199
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
200
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
201
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
202
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
203
+
204
+ public $PLATFORM_UNKNOWN = 'unknown';
205
+ public $PLATFORM_WINDOWS = 'Windows';
206
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
207
+ public $PLATFORM_APPLE = 'Apple';
208
+ public $PLATFORM_LINUX = 'Linux';
209
+ public $PLATFORM_OS2 = 'OS/2';
210
+ public $PLATFORM_BEOS = 'BeOS';
211
+ public $PLATFORM_IPHONE = 'iPhone';
212
+ public $PLATFORM_IPOD = 'iPod';
213
+ public $PLATFORM_IPAD = 'iPad';
214
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
215
+ public $PLATFORM_NOKIA = 'Nokia';
216
+ public $PLATFORM_FREEBSD = 'FreeBSD';
217
+ public $PLATFORM_OPENBSD = 'OpenBSD';
218
+ public $PLATFORM_NETBSD = 'NetBSD';
219
+ public $PLATFORM_SUNOS = 'SunOS';
220
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
221
+ public $PLATFORM_ANDROID = 'Android';
222
+
223
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
224
+
225
+ function __construct( $useragent="" ) {
226
+ $this->reset();
227
+ if ( $useragent != "" ) {
228
+ $this->setUserAgent( $useragent );
229
+ } else {
230
+ $this->determine();
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Reset all properties
236
+ */
237
+ function reset() {
238
+ $this->_agent = isset( $_SERVER['HTTP_USER_AGENT'] ) ? $_SERVER['HTTP_USER_AGENT'] : "";
239
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
240
+ $this->_version = $this->VERSION_UNKNOWN;
241
+ $this->_platform = $this->PLATFORM_UNKNOWN;
242
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
243
+ $this->_is_aol = false;
244
+ $this->_is_mobile = false;
245
+ $this->_is_robot = false;
246
+ $this->_aol_version = $this->VERSION_UNKNOWN;
247
+ }
248
+
249
+ /**
250
+ * Check to see if the specific browser is valid
251
+ *
252
+ * @param string $browserName
253
+ * @return True if the browser is the specified browser
254
+ */
255
+ function isBrowser( $browserName ) { return 0 == strcasecmp( $this->_browser_name, trim( $browserName ) ); }
256
+
257
+ /**
258
+ * The name of the browser. All return types are from the class contants
259
+ *
260
+ * @return string Name of the browser
261
+ */
262
+ function getBrowser() { return $this->_browser_name; }
263
+ /**
264
+ * Set the name of the browser
265
+ *
266
+ * @param unknown $browser The name of the Browser
267
+ */
268
+ function setBrowser( $browser ) { return $this->_browser_name = $browser; }
269
+ /**
270
+ * The name of the platform. All return types are from the class contants
271
+ *
272
+ * @return string Name of the browser
273
+ */
274
+ function getPlatform() { return $this->_platform; }
275
+ /**
276
+ * Set the name of the platform
277
+ *
278
+ * @param unknown $platform The name of the Platform
279
+ */
280
+ function setPlatform( $platform ) { return $this->_platform = $platform; }
281
+ /**
282
+ * The version of the browser.
283
+ *
284
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
285
+ */
286
+ function getVersion() { return $this->_version; }
287
+ /**
288
+ * Set the version of the browser
289
+ *
290
+ * @param unknown $version The version of the Browser
291
+ */
292
+ function setVersion( $version ) { $this->_version = preg_replace( '/[^0-9,.,a-z,A-Z-]/', '', $version ); }
293
+ /**
294
+ * The version of AOL.
295
+ *
296
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
297
+ */
298
+ function getAolVersion() { return $this->_aol_version; }
299
+ /**
300
+ * Set the version of AOL
301
+ *
302
+ * @param unknown $version The version of AOL
303
+ */
304
+ function setAolVersion( $version ) { $this->_aol_version = preg_replace( '/[^0-9,.,a-z,A-Z]/', '', $version ); }
305
+ /**
306
+ * Is the browser from AOL?
307
+ *
308
+ * @return boolean True if the browser is from AOL otherwise false
309
+ */
310
+ function isAol() { return $this->_is_aol; }
311
+ /**
312
+ * Is the browser from a mobile device?
313
+ *
314
+ * @return boolean True if the browser is from a mobile device otherwise false
315
+ */
316
+ function isMobile() { return $this->_is_mobile; }
317
+ /**
318
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
319
+ *
320
+ * @return boolean True if the browser is from a robot otherwise false
321
+ */
322
+ function isRobot() { return $this->_is_robot; }
323
+ /**
324
+ * Set the browser to be from AOL
325
+ *
326
+ * @param unknown $isAol
327
+ */
328
+ function setAol( $isAol ) { $this->_is_aol = $isAol; }
329
+ /**
330
+ * Set the Browser to be mobile
331
+ *
332
+ * @param boolean $value is the browser a mobile brower or not
333
+ */
334
+ function setMobile( $value=true ) { $this->_is_mobile = $value; }
335
+ /**
336
+ * Set the Browser to be a robot
337
+ *
338
+ * @param boolean $value is the browser a robot or not
339
+ */
340
+ function setRobot( $value=true ) { $this->_is_robot = $value; }
341
+ /**
342
+ * Get the user agent value in use to determine the browser
343
+ *
344
+ * @return string The user agent from the HTTP header
345
+ */
346
+ function getUserAgent() { return $this->_agent; }
347
+ /**
348
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
349
+ *
350
+ * @param unknown $agent_string The value for the User Agent
351
+ */
352
+ function setUserAgent( $agent_string ) {
353
+ $this->reset();
354
+ $this->_agent = $agent_string;
355
+ $this->determine();
356
+ }
357
+ /**
358
+ * Used to determine if the browser is actually "chromeframe"
359
+ *
360
+ * @since 1.7
361
+ * @return boolean True if the browser is using chromeframe
362
+ */
363
+ function isChromeFrame() {
364
+ return strpos( $this->_agent, "chromeframe" ) !== false;
365
+ }
366
+ /**
367
+ * Returns a formatted string with a summary of the details of the browser.
368
+ *
369
+ * @return string formatted string with a summary of the browser
370
+ */
371
+ function __toString() {
372
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
373
+ $UAline1 = substr( $text1, 0, 32 ); //the first line we print should only be the first 32 characters of the UA string
374
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
375
+ $towrapUA = str_replace( $UAline1, '', $text2 );//the rest of the printoff (other than first line) is equivolent
376
+ // To the whole string minus the part we printed off. IE
377
+ // User Agent: thefirst32charactersfromUAline1
378
+ // the rest of it is now stored in
379
+ // $text2 to be printed off
380
+ // But we need to add spaces before each line that is split other than line 1
381
+ $space = '';
382
+ for ( $i = 0; $i < 25; $i++ ) {
383
+ $space .= ' ';
384
+ }
385
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
386
+ $wordwrapped = chunk_split( $towrapUA, 32, "\n $space" );
387
+ return "Platform: {$this->getPlatform()} \n".
388
+ "Browser Name: {$this->getBrowser()} \n" .
389
+ "Browser Version: {$this->getVersion()} \n" .
390
+ "User Agent String: $UAline1 \n\t\t\t " .
391
+ "$wordwrapped";
392
+ }
393
+ /**
394
+ * Protected routine to calculate and determine what the browser is in use (including platform)
395
+ */
396
+ function determine() {
397
+ $this->checkPlatform();
398
+ $this->checkBrowsers();
399
+ $this->checkForAol();
400
+ }
401
+ /**
402
+ * Protected routine to determine the browser type
403
+ *
404
+ * @return boolean True if the browser was detected otherwise false
405
+ */
406
+ function checkBrowsers() {
407
+ return (
408
+ // Well-known, well-used
409
+ // Special Notes:
410
+ // (1) Opera must be checked before FireFox due to the odd
411
+ // user agents used in some older versions of Opera
412
+ // (2) WebTV is strapped onto Internet Explorer so we must
413
+ // check for WebTV before IE
414
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
415
+ // tested before Firefox is tested
416
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
417
+ // before Safari
418
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
419
+ // before FireFox are necessary
420
+ $this->checkBrowserWebTv() ||
421
+ $this->checkBrowserInternetExplorer() ||
422
+ $this->checkBrowserOpera() ||
423
+ $this->checkBrowserGaleon() ||
424
+ $this->checkBrowserNetscapeNavigator9Plus() ||
425
+ $this->checkBrowserFirefox() ||
426
+ $this->checkBrowserChrome() ||
427
+ $this->checkBrowserOmniWeb() ||
428
+
429
+ // Common mobile
430
+ $this->checkBrowserAndroid() ||
431
+ $this->checkBrowseriPad() ||
432
+ $this->checkBrowseriPod() ||
433
+ $this->checkBrowseriPhone() ||
434
+ $this->checkBrowserBlackBerry() ||
435
+ $this->checkBrowserNokia() ||
436
+
437
+ // Common bots
438
+ $this->checkBrowserGoogleBot() ||
439
+ $this->checkBrowserMSNBot() ||
440
+ $this->checkBrowserSlurp() ||
441
+
442
+ // WebKit base check (post mobile and others)
443
+ $this->checkBrowserSafari() ||
444
+
445
+ // Everyone else
446
+ $this->checkBrowserNetPositive() ||
447
+ $this->checkBrowserFirebird() ||
448
+ $this->checkBrowserKonqueror() ||
449
+ $this->checkBrowserIcab() ||
450
+ $this->checkBrowserPhoenix() ||
451
+ $this->checkBrowserAmaya() ||
452
+ $this->checkBrowserLynx() ||
453
+
454
+ $this->checkBrowserShiretoko() ||
455
+ $this->checkBrowserIceCat() ||
456
+ $this->checkBrowserW3CValidator() ||
457
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
458
+ );
459
+ }
460
+
461
+ /**
462
+ * Determine if the user is using a BlackBerry (last updated 1.7)
463
+ *
464
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
465
+ */
466
+ function checkBrowserBlackBerry() {
467
+ if ( stripos( $this->_agent, 'blackberry' ) !== false ) {
468
+ $aresult = explode( "/", stristr( $this->_agent, "BlackBerry" ) );
469
+ $aversion = explode( ' ', $aresult[1] );
470
+ $this->setVersion( $aversion[0] );
471
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
472
+ $this->setMobile( true );
473
+ return true;
474
+ }
475
+ return false;
476
+ }
477
+
478
+ /**
479
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
480
+ *
481
+ * @return boolean True if the browser is from AOL otherwise false
482
+ */
483
+ function checkForAol() {
484
+ $this->setAol( false );
485
+ $this->setAolVersion( $this->VERSION_UNKNOWN );
486
+
487
+ if ( stripos( $this->_agent, 'aol' ) !== false ) {
488
+ $aversion = explode( ' ', stristr( $this->_agent, 'AOL' ) );
489
+ $this->setAol( true );
490
+ $this->setAolVersion( preg_replace( '/[^0-9\.a-z]/i', '', $aversion[1] ) );
491
+ return true;
492
+ }
493
+ return false;
494
+ }
495
+
496
+ /**
497
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
498
+ *
499
+ * @return boolean True if the browser is the GoogletBot otherwise false
500
+ */
501
+ function checkBrowserGoogleBot() {
502
+ if ( stripos( $this->_agent, 'googlebot' ) !== false ) {
503
+ $aresult = explode( '/', stristr( $this->_agent, 'googlebot' ) );
504
+ $aversion = explode( ' ', $aresult[1] );
505
+ $this->setVersion( str_replace( ';', '', $aversion[0] ) );
506
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
507
+ $this->setRobot( true );
508
+ return true;
509
+ }
510
+ return false;
511
+ }
512
+
513
+ /**
514
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
515
+ *
516
+ * @return boolean True if the browser is the MSNBot otherwise false
517
+ */
518
+ function checkBrowserMSNBot() {
519
+ if ( stripos( $this->_agent, "msnbot" ) !== false ) {
520
+ $aresult = explode( "/", stristr( $this->_agent, "msnbot" ) );
521
+ $aversion = explode( " ", $aresult[1] );
522
+ $this->setVersion( str_replace( ";", "", $aversion[0] ) );
523
+ $this->_browser_name = $this->BROWSER_MSNBOT;
524
+ $this->setRobot( true );
525
+ return true;
526
+ }
527
+ return false;
528
+ }
529
+
530
+ /**
531
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
532
+ *
533
+ * @return boolean True if the browser is the W3C Validator otherwise false
534
+ */
535
+ function checkBrowserW3CValidator() {
536
+ if ( stripos( $this->_agent, 'W3C-checklink' ) !== false ) {
537
+ $aresult = explode( '/', stristr( $this->_agent, 'W3C-checklink' ) );
538
+ $aversion = explode( ' ', $aresult[1] );
539
+ $this->setVersion( $aversion[0] );
540
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
541
+ return true;
542
+ } else if ( stripos( $this->_agent, 'W3C_Validator' ) !== false ) {
543
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
544
+ $ua = str_replace( "W3C_Validator ", "W3C_Validator/", $this->_agent );
545
+ $aresult = explode( '/', stristr( $ua, 'W3C_Validator' ) );
546
+ $aversion = explode( ' ', $aresult[1] );
547
+ $this->setVersion( $aversion[0] );
548
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
549
+ return true;
550
+ }
551
+ return false;
552
+ }
553
+
554
+ /**
555
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
556
+ *
557
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
558
+ */
559
+ function checkBrowserSlurp() {
560
+ if ( stripos( $this->_agent, 'slurp' ) !== false ) {
561
+ $aresult = explode( '/', stristr( $this->_agent, 'Slurp' ) );
562
+ $aversion = explode( ' ', $aresult[1] );
563
+ $this->setVersion( $aversion[0] );
564
+ $this->_browser_name = $this->BROWSER_SLURP;
565
+ $this->setRobot( true );
566
+ $this->setMobile( false );
567
+ return true;
568
+ }
569
+ return false;
570
+ }
571
+
572
+ /**
573
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
574
+ *
575
+ * @return boolean True if the browser is Internet Explorer otherwise false
576
+ */
577
+ function checkBrowserInternetExplorer() {
578
+
579
+ // Test for v1 - v1.5 IE
580
+ if ( stripos( $this->_agent, 'microsoft internet explorer' ) !== false ) {
581
+ $this->setBrowser( $this->BROWSER_IE );
582
+ $this->setVersion( '1.0' );
583
+ $aresult = stristr( $this->_agent, '/' );
584
+ if ( preg_match( '/308|425|426|474|0b1/i', $aresult ) ) {
585
+ $this->setVersion( '1.5' );
586
+ }
587
+ return true;
588
+ }
589
+ // Test for versions > 1.5
590
+ else if ( stripos( $this->_agent, 'msie' ) !== false && stripos( $this->_agent, 'opera' ) === false ) {
591
+ // See if the browser is the odd MSN Explorer
592
+ if ( stripos( $this->_agent, 'msnb' ) !== false ) {
593
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'MSN' ) );
594
+ $this->setBrowser( $this->BROWSER_MSN );
595
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
596
+ return true;
597
+ }
598
+ $aresult = explode( ' ', stristr( str_replace( ';', '; ', $this->_agent ), 'msie' ) );
599
+ $this->setBrowser( $this->BROWSER_IE );
600
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aresult[1] ) );
601
+ return true;
602
+ }
603
+ // Test for Pocket IE
604
+ else if ( stripos( $this->_agent, 'mspie' ) !== false || stripos( $this->_agent, 'pocket' ) !== false ) {
605
+ $aresult = explode( ' ', stristr( $this->_agent, 'mspie' ) );
606
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
607
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
608
+ $this->setMobile( true );
609
+
610
+ if ( stripos( $this->_agent, 'mspie' ) !== false ) {
611
+ $this->setVersion( $aresult[1] );
612
+ } else {
613
+ $aversion = explode( '/', $this->_agent );
614
+ $this->setVersion( $aversion[1] );
615
+ }
616
+ return true;
617
+ }
618
+ return false;
619
+ }
620
+
621
+ /**
622
+ * Determine if the browser is Opera or not (last updated 1.7)
623
+ *
624
+ * @return boolean True if the browser is Opera otherwise false
625
+ */
626
+ function checkBrowserOpera() {
627
+ if ( stripos( $this->_agent, 'opera mini' ) !== false ) {
628
+ $resultant = stristr( $this->_agent, 'opera mini' );
629
+ if ( preg_match( '/\//', $resultant ) ) {
630
+ $aresult = explode( '/', $resultant );
631
+ $aversion = explode( ' ', $aresult[1] );
632
+ $this->setVersion( $aversion[0] );
633
+ } else {
634
+ $aversion = explode( ' ', stristr( $resultant, 'opera mini' ) );
635
+ $this->setVersion( $aversion[1] );
636
+ }
637
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
638
+ $this->setMobile( true );
639
+ return true;
640
+ } else if ( stripos( $this->_agent, 'opera' ) !== false ) {
641
+ $resultant = stristr( $this->_agent, 'opera' );
642
+ if ( preg_match( '/Version\/(10.*)$/', $resultant, $matches ) ) {
643
+ $this->setVersion( $matches[1] );
644
+ } else if ( preg_match( '/\//', $resultant ) ) {
645
+ $aresult = explode( '/', str_replace( "(", " ", $resultant ) );
646
+ $aversion = explode( ' ', $aresult[1] );
647
+ $this->setVersion( $aversion[0] );
648
+ } else {
649
+ $aversion = explode( ' ', stristr( $resultant, 'opera' ) );
650
+ $this->setVersion( isset( $aversion[1] )?$aversion[1]:"" );
651
+ }
652
+ $this->_browser_name = $this->BROWSER_OPERA;
653
+ return true;
654
+ }
655
+ return false;
656
+ }
657
+
658
+ /**
659
+ * Determine if the browser is Chrome or not (last updated 1.7)
660
+ *
661
+ * @return boolean True if the browser is Chrome otherwise false
662
+ */
663
+ function checkBrowserChrome() {
664
+ if ( stripos( $this->_agent, 'Chrome' ) !== false ) {
665
+ $aresult = explode( '/', stristr( $this->_agent, 'Chrome' ) );
666
+ $aversion = explode( ' ', $aresult[1] );
667
+ $this->setVersion( $aversion[0] );
668
+ $this->setBrowser( $this->BROWSER_CHROME );
669
+ return true;
670
+ }
671
+ return false;
672
+ }
673
+
674
+
675
+ /**
676
+ * Determine if the browser is WebTv or not (last updated 1.7)
677
+ *
678
+ * @return boolean True if the browser is WebTv otherwise false
679
+ */
680
+ function checkBrowserWebTv() {
681
+ if ( stripos( $this->_agent, 'webtv' ) !== false ) {
682
+ $aresult = explode( '/', stristr( $this->_agent, 'webtv' ) );
683
+ $aversion = explode( ' ', $aresult[1] );
684
+ $this->setVersion( $aversion[0] );
685
+ $this->setBrowser( $this->BROWSER_WEBTV );
686
+ return true;
687
+ }
688
+ return false;
689
+ }
690
+
691
+ /**
692
+ * Determine if the browser is NetPositive or not (last updated 1.7)
693
+ *
694
+ * @return boolean True if the browser is NetPositive otherwise false
695
+ */
696
+ function checkBrowserNetPositive() {
697
+ if ( stripos( $this->_agent, 'NetPositive' ) !== false ) {
698
+ $aresult = explode( '/', stristr( $this->_agent, 'NetPositive' ) );
699
+ $aversion = explode( ' ', $aresult[1] );
700
+ $this->setVersion( str_replace( array( '(', ')', ';' ), '', $aversion[0] ) );
701
+ $this->setBrowser( $this->BROWSER_NETPOSITIVE );
702
+ return true;
703
+ }
704
+ return false;
705
+ }
706
+
707
+ /**
708
+ * Determine if the browser is Galeon or not (last updated 1.7)
709
+ *
710
+ * @return boolean True if the browser is Galeon otherwise false
711
+ */
712
+ function checkBrowserGaleon() {
713
+ if ( stripos( $this->_agent, 'galeon' ) !== false ) {
714
+ $aresult = explode( ' ', stristr( $this->_agent, 'galeon' ) );
715
+ $aversion = explode( '/', $aresult[0] );
716
+ $this->setVersion( $aversion[1] );
717
+ $this->setBrowser( $this->BROWSER_GALEON );
718
+ return true;
719
+ }
720
+ return false;
721
+ }
722
+
723
+ /**
724
+ * Determine if the browser is Konqueror or not (last updated 1.7)
725
+ *
726
+ * @return boolean True if the browser is Konqueror otherwise false
727
+ */
728
+ function checkBrowserKonqueror() {
729
+ if ( stripos( $this->_agent, 'Konqueror' ) !== false ) {
730
+ $aresult = explode( ' ', stristr( $this->_agent, 'Konqueror' ) );
731
+ $aversion = explode( '/', $aresult[0] );
732
+ $this->setVersion( $aversion[1] );
733
+ $this->setBrowser( $this->BROWSER_KONQUEROR );
734
+ return true;
735
+ }
736
+ return false;
737
+ }
738
+
739
+ /**
740
+ * Determine if the browser is iCab or not (last updated 1.7)
741
+ *
742
+ * @return boolean True if the browser is iCab otherwise false
743
+ */
744
+ function checkBrowserIcab() {
745
+ if ( stripos( $this->_agent, 'icab' ) !== false ) {
746
+ $aversion = explode( ' ', stristr( str_replace( '/', ' ', $this->_agent ), 'icab' ) );
747
+ $this->setVersion( $aversion[1] );
748
+ $this->setBrowser( $this->BROWSER_ICAB );
749
+ return true;
750
+ }
751
+ return false;
752
+ }
753
+
754
+ /**
755
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
756
+ *
757
+ * @return boolean True if the browser is OmniWeb otherwise false
758
+ */
759
+ function checkBrowserOmniWeb() {
760
+ if ( stripos( $this->_agent, 'omniweb' ) !== false ) {
761
+ $aresult = explode( '/', stristr( $this->_agent, 'omniweb' ) );
762
+ $aversion = explode( ' ', isset( $aresult[1] )?$aresult[1]:"" );
763
+ $this->setVersion( $aversion[0] );
764
+ $this->setBrowser( $this->BROWSER_OMNIWEB );
765
+ return true;
766
+ }
767
+ return false;
768
+ }
769
+
770
+ /**
771
+ * Determine if the browser is Phoenix or not (last updated 1.7)
772
+ *
773
+ * @return boolean True if the browser is Phoenix otherwise false
774
+ */
775
+ function checkBrowserPhoenix() {
776
+ if ( stripos( $this->_agent, 'Phoenix' ) !== false ) {
777
+ $aversion = explode( '/', stristr( $this->_agent, 'Phoenix' ) );
778
+ $this->setVersion( $aversion[1] );
779
+ $this->setBrowser( $this->BROWSER_PHOENIX );
780
+ return true;
781
+ }
782
+ return false;
783
+ }
784
+
785
+ /**
786
+ * Determine if the browser is Firebird or not (last updated 1.7)
787
+ *
788
+ * @return boolean True if the browser is Firebird otherwise false
789
+ */
790
+ function checkBrowserFirebird() {
791
+ if ( stripos( $this->_agent, 'Firebird' ) !== false ) {
792
+ $aversion = explode( '/', stristr( $this->_agent, 'Firebird' ) );
793
+ $this->setVersion( $aversion[1] );
794
+ $this->setBrowser( $this->BROWSER_FIREBIRD );
795
+ return true;
796
+ }
797
+ return false;
798
+ }
799
+
800
+ /**
801
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
802
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
803
+ *
804
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
805
+ */
806
+ function checkBrowserNetscapeNavigator9Plus() {
807
+ if ( stripos( $this->_agent, 'Firefox' ) !== false && preg_match( '/Navigator\/([^ ]*)/i', $this->_agent, $matches ) ) {
808
+ $this->setVersion( $matches[1] );
809
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
810
+ return true;
811
+ } else if ( stripos( $this->_agent, 'Firefox' ) === false && preg_match( '/Netscape6?\/([^ ]*)/i', $this->_agent, $matches ) ) {
812
+ $this->setVersion( $matches[1] );
813
+ $this->setBrowser( $this->BROWSER_NETSCAPE_NAVIGATOR );
814
+ return true;
815
+ }
816
+ return false;
817
+ }
818
+
819
+ /**
820
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
821
+ *
822
+ * @return boolean True if the browser is Shiretoko otherwise false
823
+ */
824
+ function checkBrowserShiretoko() {
825
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/Shiretoko\/([^ ]*)/i', $this->_agent, $matches ) ) {
826
+ $this->setVersion( $matches[1] );
827
+ $this->setBrowser( $this->BROWSER_SHIRETOKO );
828
+ return true;
829
+ }
830
+ return false;
831
+ }
832
+
833
+ /**
834
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
835
+ *
836
+ * @return boolean True if the browser is Ice Cat otherwise false
837
+ */
838
+ function checkBrowserIceCat() {
839
+ if ( stripos( $this->_agent, 'Mozilla' ) !== false && preg_match( '/IceCat\/([^ ]*)/i', $this->_agent, $matches ) ) {
840
+ $this->setVersion( $matches[1] );
841
+ $this->setBrowser( $this->BROWSER_ICECAT );
842
+ return true;
843
+ }
844
+ return false;
845
+ }
846
+
847
+ /**
848
+ * Determine if the browser is Nokia or not (last updated 1.7)
849
+ *
850
+ * @return boolean True if the browser is Nokia otherwise false
851
+ */
852
+ function checkBrowserNokia() {
853
+ if ( preg_match( "/Nokia([^\/]+)\/([^ SP]+)/i", $this->_agent, $matches ) ) {
854
+ $this->setVersion( $matches[2] );
855
+ if ( stripos( $this->_agent, 'Series60' ) !== false || strpos( $this->_agent, 'S60' ) !== false ) {
856
+ $this->setBrowser( $this->BROWSER_NOKIA_S60 );
857
+ } else {
858
+ $this->setBrowser( $this->BROWSER_NOKIA );
859
+ }
860
+ $this->setMobile( true );
861
+ return true;
862
+ }
863
+ return false;
864
+ }
865
+
866
+ /**
867
+ * Determine if the browser is Firefox or not (last updated 1.7)
868
+ *
869
+ * @return boolean True if the browser is Firefox otherwise false
870
+ */
871
+ function checkBrowserFirefox() {
872
+ if ( stripos( $this->_agent, 'safari' ) === false ) {
873
+ if ( preg_match( "/Firefox[\/ \(]([^ ;\)]+)/i", $this->_agent, $matches ) ) {
874
+ $this->setVersion( $matches[1] );
875
+ $this->setBrowser( $this->BROWSER_FIREFOX );
876
+ return true;
877
+ } else if ( preg_match( "/Firefox$/i", $this->_agent, $matches ) ) {
878
+ $this->setVersion( "" );
879
+ $this->setBrowser( $this->BROWSER_FIREFOX );
880
+ return true;
881
+ }
882
+ }
883
+ return false;
884
+ }
885
+
886
+ /**
887
+ * Determine if the browser is Firefox or not (last updated 1.7)
888
+ *
889
+ * @return boolean True if the browser is Firefox otherwise false
890
+ */
891
+ function checkBrowserIceweasel() {
892
+ if ( stripos( $this->_agent, 'Iceweasel' ) !== false ) {
893
+ $aresult = explode( '/', stristr( $this->_agent, 'Iceweasel' ) );
894
+ $aversion = explode( ' ', $aresult[1] );
895
+ $this->setVersion( $aversion[0] );
896
+ $this->setBrowser( $this->BROWSER_ICEWEASEL );
897
+ return true;
898
+ }
899
+ return false;
900
+ }
901
+ /**
902
+ * Determine if the browser is Mozilla or not (last updated 1.7)
903
+ *
904
+ * @return boolean True if the browser is Mozilla otherwise false
905
+ */
906
+ function checkBrowserMozilla() {
907
+ if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
908
+ $aversion = explode( ' ', stristr( $this->_agent, 'rv:' ) );
909
+ preg_match( '/rv:[0-9].[0-9][a-b]?/i', $this->_agent, $aversion );
910
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
911
+ $this->setBrowser( $this->BROWSER_MOZILLA );
912
+ return true;
913
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/rv:[0-9]\.[0-9]/i', $this->_agent ) && stripos( $this->_agent, 'netscape' ) === false ) {
914
+ $aversion = explode( '', stristr( $this->_agent, 'rv:' ) );
915
+ $this->setVersion( str_replace( 'rv:', '', $aversion[0] ) );
916
+ $this->setBrowser( $this->BROWSER_MOZILLA );
917
+ return true;
918
+ } else if ( stripos( $this->_agent, 'mozilla' ) !== false && preg_match( '/mozilla\/([^ ]*)/i', $this->_agent, $matches ) && stripos( $this->_agent, 'netscape' ) === false ) {
919
+ $this->setVersion( $matches[1] );
920
+ $this->setBrowser( $this->BROWSER_MOZILLA );
921
+ return true;
922
+ }
923
+ return false;
924
+ }
925
+
926
+ /**
927
+ * Determine if the browser is Lynx or not (last updated 1.7)
928
+ *
929
+ * @return boolean True if the browser is Lynx otherwise false
930
+ */
931
+ function checkBrowserLynx() {
932
+ if ( stripos( $this->_agent, 'lynx' ) !== false ) {
933
+ $aresult = explode( '/', stristr( $this->_agent, 'Lynx' ) );
934
+ $aversion = explode( ' ', ( isset( $aresult[1] )?$aresult[1]:"" ) );
935
+ $this->setVersion( $aversion[0] );
936
+ $this->setBrowser( $this->BROWSER_LYNX );
937
+ return true;
938
+ }
939
+ return false;
940
+ }
941
+
942
+ /**
943
+ * Determine if the browser is Amaya or not (last updated 1.7)
944
+ *
945
+ * @return boolean True if the browser is Amaya otherwise false
946
+ */
947
+ function checkBrowserAmaya() {
948
+ if ( stripos( $this->_agent, 'amaya' ) !== false ) {
949
+ $aresult = explode( '/', stristr( $this->_agent, 'Amaya' ) );
950
+ $aversion = explode( ' ', $aresult[1] );
951
+ $this->setVersion( $aversion[0] );
952
+ $this->setBrowser( $this->BROWSER_AMAYA );
953
+ return true;
954
+ }
955
+ return false;
956
+ }
957
+
958
+ /**
959
+ * Determine if the browser is Safari or not (last updated 1.7)
960
+ *
961
+ * @return boolean True if the browser is Safari otherwise false
962
+ */
963
+ function checkBrowserSafari() {
964
+ if ( stripos( $this->_agent, 'Safari' ) !== false && stripos( $this->_agent, 'iPhone' ) === false && stripos( $this->_agent, 'iPod' ) === false ) {
965
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
966
+ if ( isset( $aresult[1] ) ) {
967
+ $aversion = explode( ' ', $aresult[1] );
968
+ $this->setVersion( $aversion[0] );
969
+ } else {
970
+ $this->setVersion( $this->VERSION_UNKNOWN );
971
+ }
972
+ $this->setBrowser( $this->BROWSER_SAFARI );
973
+ return true;
974
+ }
975
+ return false;
976
+ }
977
+
978
+ /**
979
+ * Determine if the browser is iPhone or not (last updated 1.7)
980
+ *
981
+ * @return boolean True if the browser is iPhone otherwise false
982
+ */
983
+ function checkBrowseriPhone() {
984
+ if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
985
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
986
+ if ( isset( $aresult[1] ) ) {
987
+ $aversion = explode( ' ', $aresult[1] );
988
+ $this->setVersion( $aversion[0] );
989
+ } else {
990
+ $this->setVersion( $this->VERSION_UNKNOWN );
991
+ }
992
+ $this->setMobile( true );
993
+ $this->setBrowser( $this->BROWSER_IPHONE );
994
+ return true;
995
+ }
996
+ return false;
997
+ }
998
+
999
+ /**
1000
+ * Determine if the browser is iPod or not (last updated 1.7)
1001
+ *
1002
+ * @return boolean True if the browser is iPod otherwise false
1003
+ */
1004
+ function checkBrowseriPad() {
1005
+ if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1006
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1007
+ if ( isset( $aresult[1] ) ) {
1008
+ $aversion = explode( ' ', $aresult[1] );
1009
+ $this->setVersion( $aversion[0] );
1010
+ } else {
1011
+ $this->setVersion( $this->VERSION_UNKNOWN );
1012
+ }
1013
+ $this->setMobile( true );
1014
+ $this->setBrowser( $this->BROWSER_IPAD );
1015
+ return true;
1016
+ }
1017
+ return false;
1018
+ }
1019
+
1020
+ /**
1021
+ * Determine if the browser is iPod or not (last updated 1.7)
1022
+ *
1023
+ * @return boolean True if the browser is iPod otherwise false
1024
+ */
1025
+ function checkBrowseriPod() {
1026
+ if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1027
+ $aresult = explode( '/', stristr( $this->_agent, 'Version' ) );
1028
+ if ( isset( $aresult[1] ) ) {
1029
+ $aversion = explode( ' ', $aresult[1] );
1030
+ $this->setVersion( $aversion[0] );
1031
+ } else {
1032
+ $this->setVersion( $this->VERSION_UNKNOWN );
1033
+ }
1034
+ $this->setMobile( true );
1035
+ $this->setBrowser( $this->BROWSER_IPOD );
1036
+ return true;
1037
+ }
1038
+ return false;
1039
+ }
1040
+
1041
+ /**
1042
+ * Determine if the browser is Android or not (last updated 1.7)
1043
+ *
1044
+ * @return boolean True if the browser is Android otherwise false
1045
+ */
1046
+ function checkBrowserAndroid() {
1047
+ if ( stripos( $this->_agent, 'Android' ) !== false ) {
1048
+ $aresult = explode( ' ', stristr( $this->_agent, 'Android' ) );
1049
+ if ( isset( $aresult[1] ) ) {
1050
+ $aversion = explode( ' ', $aresult[1] );
1051
+ $this->setVersion( $aversion[0] );
1052
+ } else {
1053
+ $this->setVersion( $this->VERSION_UNKNOWN );
1054
+ }
1055
+ $this->setMobile( true );
1056
+ $this->setBrowser( $this->BROWSER_ANDROID );
1057
+ return true;
1058
+ }
1059
+ return false;
1060
+ }
1061
+
1062
+ /**
1063
+ * Determine the user's platform (last updated 1.7)
1064
+ */
1065
+ function checkPlatform() {
1066
+ if ( stripos( $this->_agent, 'windows' ) !== false ) {
1067
+ $this->_platform = $this->PLATFORM_WINDOWS;
1068
+ } else if ( stripos( $this->_agent, 'iPad' ) !== false ) {
1069
+ $this->_platform = $this->PLATFORM_IPAD;
1070
+ } else if ( stripos( $this->_agent, 'iPod' ) !== false ) {
1071
+ $this->_platform = $this->PLATFORM_IPOD;
1072
+ } else if ( stripos( $this->_agent, 'iPhone' ) !== false ) {
1073
+ $this->_platform = $this->PLATFORM_IPHONE;
1074
+ } elseif ( stripos( $this->_agent, 'mac' ) !== false ) {
1075
+ $this->_platform = $this->PLATFORM_APPLE;
1076
+ } elseif ( stripos( $this->_agent, 'android' ) !== false ) {
1077
+ $this->_platform = $this->PLATFORM_ANDROID;
1078
+ } elseif ( stripos( $this->_agent, 'linux' ) !== false ) {
1079
+ $this->_platform = $this->PLATFORM_LINUX;
1080
+ } else if ( stripos( $this->_agent, 'Nokia' ) !== false ) {
1081
+ $this->_platform = $this->PLATFORM_NOKIA;
1082
+ } else if ( stripos( $this->_agent, 'BlackBerry' ) !== false ) {
1083
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1084
+ } elseif ( stripos( $this->_agent, 'FreeBSD' ) !== false ) {
1085
+ $this->_platform = $this->PLATFORM_FREEBSD;
1086
+ } elseif ( stripos( $this->_agent, 'OpenBSD' ) !== false ) {
1087
+ $this->_platform = $this->PLATFORM_OPENBSD;
1088
+ } elseif ( stripos( $this->_agent, 'NetBSD' ) !== false ) {
1089
+ $this->_platform = $this->PLATFORM_NETBSD;
1090
+ } elseif ( stripos( $this->_agent, 'OpenSolaris' ) !== false ) {
1091
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1092
+ } elseif ( stripos( $this->_agent, 'SunOS' ) !== false ) {
1093
+ $this->_platform = $this->PLATFORM_SUNOS;
1094
+ } elseif ( stripos( $this->_agent, 'OS\/2' ) !== false ) {
1095
+ $this->_platform = $this->PLATFORM_OS2;
1096
+ } elseif ( stripos( $this->_agent, 'BeOS' ) !== false ) {
1097
+ $this->_platform = $this->PLATFORM_BEOS;
1098
+ } elseif ( stripos( $this->_agent, 'win' ) !== false ) {
1099
+ $this->_platform = $this->PLATFORM_WINDOWS;
1100
+ }
1101
+
1102
+ }
1103
+ }
classes/wpdesk/settings-api/modules/sysinfo/class.s214-sysinfo.php ADDED
@@ -0,0 +1,442 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * System Info handler for Section214
4
+ *
5
+ * @package S214\Sysinfo
6
+ * @since 1.1.0
7
+ */
8
+
9
+ // Exit if accessed directly
10
+ if( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+
15
+ /**
16
+ * Section214 system info handler class
17
+ *
18
+ * @since 1.1.0
19
+ */
20
+ class S214_Sysinfo {
21
+
22
+
23
+ /**
24
+ * @var string $slug The plugin slug
25
+ * @since 1.1.0
26
+ */
27
+ private $slug;
28
+
29
+
30
+ /**
31
+ * @var string $func The plugin slug for names
32
+ * @since 1.1.0
33
+ */
34
+ private $func;
35
+
36
+
37
+ /**
38
+ * @var string $ver The library version
39
+ * @since 1.1.0
40
+ */
41
+ private $version;
42
+
43
+
44
+ /**
45
+ * Class constructor
46
+ *
47
+ * @access public
48
+ * @since 1.1.0
49
+ * @param string $_slug
50
+ * @param string $_func
51
+ * @return void
52
+ */
53
+ public function __construct( $_slug, $_func, $_version ) {
54
+ $this->slug = $_slug;
55
+ $this->func = $_func;
56
+ $this->version = $_version;
57
+
58
+ // Run action and filter hooks
59
+ $this->hooks();
60
+ }
61
+
62
+
63
+ /**
64
+ * Run action and filter hooks
65
+ *
66
+ * @access private
67
+ * @since 1.1.0
68
+ * @return void
69
+ */
70
+ private function hooks() {
71
+ // Process sysinfo download
72
+ add_action( $this->func . '_settings_download_system_info', array( $this, 'download_system_info' ) );
73
+ }
74
+
75
+
76
+ /**
77
+ * Get system info
78
+ *
79
+ * @access public
80
+ * @since 1.1.0
81
+ * @global object $wpdb The WordPress database object
82
+ * @return string $return The system info to display
83
+ */
84
+ public function get_system_info() {
85
+ global $wpdb;
86
+
87
+ if( ! class_exists( 'Browser' ) ) {
88
+ require_once 'browser.php';
89
+ }
90
+
91
+ $browser = new Browser();
92
+
93
+ // Get theme info
94
+ if( get_bloginfo( 'version' ) < '3.4' ) {
95
+ $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
96
+ $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
97
+ } else {
98
+ $theme_data = wp_get_theme();
99
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
100
+ }
101
+
102
+ // Try to identify the hosting provider
103
+ $host = $this->get_host();
104
+
105
+ $return = '### Begin System Info ###' . "\n\n";
106
+
107
+ // Start with the basics...
108
+ $return .= '-- Site Info' . "\n\n";
109
+ $return .= 'Site URL: ' . site_url() . "\n";
110
+ $return .= 'Home URL: ' . home_url() . "\n";
111
+ $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
112
+
113
+ $return = apply_filters( $this->func . '_sysinfo_after_site_info', $return );
114
+
115
+ // Can we determine the site's host?
116
+ if( $host ) {
117
+ $return .= "\n" . '-- Hosting Provider' . "\n\n";
118
+ $return .= 'Host: ' . $host . "\n";
119
+
120
+ $return = apply_filters( $this->func . '_sysinfo_after_host_info', $return );
121
+ }
122
+
123
+ // The local users' browser information, handled by the Browser class
124
+ $return .= "\n" . '-- User Browser' . "\n\n";
125
+ $return .= $browser;
126
+
127
+ $return = apply_filters( $this->func . '_sysinfo_after_user_browser', $return );
128
+
129
+ // WordPress configuration
130
+ $return .= "\n" . '-- WordPress Configuration' . "\n\n";
131
+ $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
132
+ $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
133
+ $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
134
+ $return .= 'Active Theme: ' . $theme . "\n";
135
+ $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
136
+
137
+ // Only show page specs if frontpage is set to 'page'
138
+ if( get_option( 'show_on_front' ) == 'page' ) {
139
+ $front_page_id = get_option( 'page_on_front' );
140
+ $blog_page_id = get_option( 'page_for_posts' );
141
+
142
+ $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
143
+ $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
144
+ }
145
+
146
+ // Make sure wp_remote_post() is working
147
+ $request['cmd'] = '_notify-validate';
148
+
149
+ $params = array(
150
+ 'sslverify' => false,
151
+ 'timeout' => 60,
152
+ 'user-agent' => 'S214-Settings/' . $this->version,
153
+ 'body' => $request
154
+ );
155
+
156
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
157
+
158
+ if( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
159
+ $WP_REMOTE_POST = 'wp_remote_post() works';
160
+ } else {
161
+ $WP_REMOTE_POST = 'wp_remote_post() does not work';
162
+ }
163
+
164
+ $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
165
+ $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
166
+ $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
167
+ $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
168
+ $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
169
+
170
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_config', $return );
171
+
172
+ // Get plugins that have an update
173
+ $updates = get_plugin_updates();
174
+
175
+ // Must-use plugins
176
+ // NOTE: MU plugins can't show updates!
177
+ $muplugins = get_mu_plugins();
178
+ if( count( $muplugins > 0 ) ) {
179
+ $return .= "\n" . '-- Must-Use Plugins' . "\n\n";
180
+
181
+ foreach( $muplugins as $plugin => $plugin_data ) {
182
+ $return .= $plugin_data['Name'] . ': ' . $plugin_data['Version'] . "\n";
183
+ }
184
+
185
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_mu_plugins', $return );
186
+ }
187
+
188
+ // WordPress active plugins
189
+ $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
190
+
191
+ $plugins = get_plugins();
192
+ $active_plugins = get_option( 'active_plugins', array() );
193
+
194
+ foreach( $plugins as $plugin_path => $plugin ) {
195
+ if( ! in_array( $plugin_path, $active_plugins ) ) {
196
+ continue;
197
+ }
198
+
199
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
200
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
201
+ }
202
+
203
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins', $return );
204
+
205
+ // WordPress inactive plugins
206
+ $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
207
+
208
+ foreach( $plugins as $plugin_path => $plugin ) {
209
+ if( in_array( $plugin_path, $active_plugins ) ) {
210
+ continue;
211
+ }
212
+
213
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
214
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
215
+ }
216
+
217
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_plugins_inactive', $return );
218
+
219
+ if( is_multisite() ) {
220
+ // WordPress Multisite active plugins
221
+ $return .= "\n" . '-- Network Active Plugins' . "\n\n";
222
+
223
+ $plugins = wp_get_active_network_plugins();
224
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
225
+
226
+ foreach( $plugins as $plugin_path ) {
227
+ $plugin_base = plugin_basename( $plugin_path );
228
+
229
+ if( ! array_key_exists( $plugin_base, $active_plugins ) ) {
230
+ continue;
231
+ }
232
+
233
+ $update = ( array_key_exists( $plugin_path, $updates ) ) ? ' (needs update - ' . $updates[$plugin_path]->update->new_version . ')' : '';
234
+ $plugin = get_plugin_data( $plugin_path );
235
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . $update . "\n";
236
+ }
237
+
238
+ $return = apply_filters( $this->func . '_sysinfo_after_wordpress_ms_plugins', $return );
239
+ }
240
+
241
+ // Server configuration (really just versioning)
242
+ $return .= "\n" . '-- Webserver Configuration' . "\n\n";
243
+ $return .= 'PHP Version: ' . PHP_VERSION . "\n";
244
+ $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
245
+ $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
246
+
247
+ $return = apply_filters( $this->func . '_sysinfo_after_webserver_config', $return );
248
+
249
+ // PHP configs... now we're getting to the important stuff
250
+ $return .= "\n" . '-- PHP Configuration' . "\n\n";
251
+ $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
252
+ $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
253
+ $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
254
+ $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
255
+ $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
256
+ $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
257
+ $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
258
+ $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
259
+
260
+ $return = apply_filters( $this->func . '_sysinfo_after_php_config', $return );
261
+
262
+ // PHP extensions and such
263
+ $return .= "\n" . '-- PHP Extensions' . "\n\n";
264
+ $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
265
+ $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
266
+ $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
267
+ $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
268
+
269
+ $return = apply_filters( $this->func . '_sysinfo_after_php_ext', $return );
270
+
271
+ $return .= "\n" . '### End System Info ###';
272
+
273
+ return $return;
274
+ }
275
+
276
+
277
+ /**
278
+ * Generates a System Info download file
279
+ *
280
+ * @param public
281
+ * @since 1.1.0
282
+ * @return void
283
+ */
284
+ public function download_system_info() {
285
+ nocache_headers();
286
+
287
+ header( 'Content-Type: text/plain' );
288
+ header( 'Content-Disposition: attachment; filename="' . $this->slug . '-system-info.txt"' );
289
+
290
+ echo wp_strip_all_tags( $this->get_system_info() );
291
+ die();
292
+ }
293
+
294
+
295
+ /**
296
+ * Get AJAX URL
297
+ *
298
+ * @access public
299
+ * @since 1.1.0
300
+ * @return string URL to the AJAX file to call during AJAX requests.
301
+ */
302
+ function get_ajax_url() {
303
+ $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
304
+
305
+ $current_url = $this->get_current_page_url();
306
+ $ajax_url = admin_url( 'admin-ajax.php', $scheme );
307
+
308
+ if( preg_match( '/^https/', $current_url ) && ! preg_match( '/^https/', $ajax_url ) ) {
309
+ $ajax_url = preg_replace( '/^http/', 'https', $ajax_url );
310
+ }
311
+
312
+ return apply_filters( $this->func . '_ajax_url', $ajax_url );
313
+ }
314
+
315
+
316
+ /**
317
+ * Get the current page URL
318
+ *
319
+ * @access public
320
+ * @since 1.1.0
321
+ * @param bool $nocache If we should bust cache on the returned URL
322
+ * @return string $page_url Current page URL
323
+ */
324
+ function get_current_page_url( $nocache = false ) {
325
+ global $wp;
326
+
327
+ if( get_option( 'permalink_structure' ) ) {
328
+ $base = trailingslashit( home_url( $wp->request ) );
329
+ } else {
330
+ $base = add_query_arg( $wp->query_string, '', trailingslashit( home_url( $wp->request ) ) );
331
+ $base = remove_query_arg( array( 'post_type', 'name' ), $base );
332
+ }
333
+
334
+ $scheme = is_ssl() ? 'https' : 'http';
335
+ $uri = set_url_scheme( $base, $scheme );
336
+
337
+ if( is_front_page() ) {
338
+ $uri = home_url( '/' );
339
+ }
340
+
341
+ $uri = apply_filters( $this->func . '_get_current_page_url', $uri );
342
+
343
+ if ( $nocache ) {
344
+ $uri = $this->add_cache_busting( $uri );
345
+ }
346
+
347
+ return $uri;
348
+ }
349
+
350
+
351
+ /**
352
+ * Adds the 'nocache' parameter to the provided URL
353
+ *
354
+ * @access public
355
+ * @since 1.1.0
356
+ * @param string $url The URL being requested
357
+ * @return string The URL with cache busting added or not
358
+ */
359
+ function add_cache_busting( $url = '' ) {
360
+ if( $this->is_caching_plugin_active() ) {
361
+ $url = add_query_arg( 'nocache', 'true', $url );
362
+ }
363
+
364
+ return $url;
365
+ }
366
+
367
+
368
+ /**
369
+ * Checks if a caching plugin is active
370
+ *
371
+ * @access public
372
+ * @since 1.1.0
373
+ * @return bool $caching True if caching plugin is enabled, false otherwise
374
+ */
375
+ function is_caching_plugin_active() {
376
+ $caching = ( function_exists( 'wpsupercache_site_admin' ) || defined( 'W3TC' ) || function_exists( 'rocket_init' ) );
377
+ return apply_filters( $this->func . '_is_caching_plugin_active', $caching );
378
+ }
379
+
380
+
381
+ /**
382
+ * Get user host
383
+ *
384
+ * @access public
385
+ * @since 1.1.0
386
+ * @return mixed string $host if detected, fallback data otherwise
387
+ */
388
+ function get_host() {
389
+ if( defined( 'WPE_APIKEY' ) ) {
390
+ $host = 'WP Engine';
391
+ } elseif( defined( 'PAGELYBIN' ) ) {
392
+ $host = 'Pagely';
393
+ } elseif( DB_HOST == 'localhost:/tmp/mysql5.sock' ) {
394
+ $host = 'ICDSoft';
395
+ } elseif( DB_HOST == 'mysqlv5' ) {
396
+ $host = 'NetworkSolutions';
397
+ } elseif( strpos( DB_HOST, 'ipagemysql.com' ) !== false ) {
398
+ $host = 'iPage';
399
+ } elseif( strpos( DB_HOST, 'ipowermysql.com' ) !== false ) {
400
+ $host = 'IPower';
401
+ } elseif( strpos( DB_HOST, '.gridserver.com' ) !== false ) {
402
+ $host = 'MediaTemple Grid';
403
+ } elseif( strpos( DB_HOST, '.pair.com' ) !== false ) {
404
+ $host = 'pair Networks';
405
+ } elseif( strpos( DB_HOST, '.stabletransit.com' ) !== false ) {
406
+ $host = 'Rackspace Cloud';
407
+ } elseif( strpos( DB_HOST, '.sysfix.eu' ) !== false ) {
408
+ $host = 'SysFix.eu Power Hosting';
409
+ } elseif( strpos( $_SERVER['SERVER_NAME'], 'Flywheel' ) !== false ) {
410
+ $host = 'Flywheel';
411
+ } else {
412
+ // Adding a general fallback for data gathering
413
+ $host = 'DBH: ' . DB_HOST . ', SRV: ' . $_SERVER['SERVER_NAME'];
414
+ }
415
+
416
+ return $host;
417
+ }
418
+
419
+
420
+ /**
421
+ * Get user IP
422
+ *
423
+ * @access public
424
+ * @since 1.1.0
425
+ * @return string $ip User's IP address
426
+ */
427
+ function get_ip() {
428
+ $ip = '127.0.0.1';
429
+
430
+ if( ! empty( $_SERVER['HTTP_CLIENT_IP'] ) ) {
431
+ // Check if IP is from share internet
432
+ $ip = $_SERVER['HTTP_CLIENT_IP'];
433
+ } elseif( ! empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ) {
434
+ // Check if IP is passed from proxy
435
+ $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
436
+ } elseif( ! empty( $_SERVER['REMOTE_ADDR'] ) ) {
437
+ $ip = $_SERVER['REMOTE_ADDR'];
438
+ }
439
+
440
+ return apply_filters( $this->func . '_get_ip', $ip );
441
+ }
442
+ }
composer.json ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "wpdesk/flexible-shipping",
3
+ "authors": [
4
+ {
5
+ "name": "Krzysiek",
6
+ "email": "krzysiek@wpdesk.pl"
7
+ }
8
+ ],
9
+ "require-dev": {
10
+ "phpunit/phpunit": "<7",
11
+ "wp-coding-standards/wpcs": "^0.14.1",
12
+ "squizlabs/php_codesniffer": "^3.0.2",
13
+ "mockery/mockery": "*",
14
+ "10up/wp_mock": "*",
15
+ "wimg/php-compatibility": "^8"
16
+ },
17
+ "autoload-dev": {
18
+ },
19
+ "scripts": {
20
+ "test": "echo composer is alive",
21
+ "phpcs": "phpcs",
22
+ "phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
23
+ "phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
24
+ "docs": "apigen generate"
25
+ }
26
+ }
flexible-shipping.php CHANGED
@@ -3,15 +3,15 @@
3
  Plugin Name: Flexible Shipping
4
  Plugin URI: https://wordpress.org/plugins/flexible-shipping/
5
  Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
6
- Version: 2.0.1
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-shipping
10
  Domain Path: /languages/
11
  Requires at least: 4.5
12
- Tested up to: 4.9.4
13
  WC requires at least: 2.6.14
14
- WC tested up to: 3.3.3
15
 
16
  Copyright 2017 WP Desk Ltd.
17
 
@@ -32,687 +32,34 @@
32
  */
33
 
34
 
35
- if (!defined('ABSPATH')) exit; // Exit if accessed directly
 
 
36
 
37
- if (!class_exists('inspire_Plugin4')) {
38
- require_once('classes/inspire/plugin4.php');
39
- }
40
-
41
- require_once('classes/tracker.php');
42
-
43
- if ( !function_exists( 'wpdesk_is_plugin_active' ) ) {
44
- function wpdesk_is_plugin_active( $plugin_file ) {
45
-
46
- $active_plugins = (array) get_option( 'active_plugins', array() );
47
-
48
- if ( is_multisite() ) {
49
- $active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
50
- }
51
-
52
- return in_array( $plugin_file, $active_plugins ) || array_key_exists( $plugin_file, $active_plugins );
53
- }
54
- }
55
-
56
- if ( wpdesk_is_plugin_active( 'woocommerce/woocommerce.php' ) && !class_exists( 'WPDesk_Flexible_Shipping_Free_Plugin' ) ) {
57
-
58
- class WPDesk_Flexible_Shipping_Free_Plugin extends inspire_Plugin4 {
59
-
60
- private $scripts_version = '58';
61
-
62
- protected $_pluginNamespace = "flexible-shipping";
63
-
64
- public function __construct() {
65
- parent::__construct();
66
- add_action( 'plugins_loaded', array($this, 'init_flexible_shipping'), 1 );
67
- }
68
-
69
- public function init_flexible_shipping() {
70
-
71
- require_once('classes/shipment/cpt-shipment.php');
72
- new WPDesk_Flexible_Shipping_Shipment_CPT( $this );
73
-
74
- require_once('classes/manifest/cpt-shipping-manifest.php');
75
- new WPDesk_Flexible_Shipping_Shipping_Manifest_CPT( $this );
76
-
77
- require_once('classes/shipment/ajax.php');
78
- new WPDesk_Flexible_Shipping_Shipment_Ajax( $this );
79
-
80
- require_once('classes/shipment/class-shipment.php');
81
- require_once('classes/shipment/interface-shipment.php');
82
- require_once('classes/shipment/functions.php');
83
-
84
- require_once('classes/manifest/class-manifest.php');
85
- require_once('classes/manifest/interface-manifest.php');
86
- require_once('classes/manifest/functions.php');
87
- require_once('classes/manifest/class-manifest-fs.php');
88
-
89
- require_once('classes/bulk-actions.php');
90
- new WPDesk_Flexible_Shipping_Bulk_Actions();
91
-
92
- require_once('classes/order-add-shipping.php');
93
- new WPDesk_Flexible_Shipping_Add_Shipping();
94
-
95
- require_once('classes/shipping_method.php');
96
-
97
- add_action( 'admin_init', array( $this, 'session_init') );
98
-
99
- add_action( 'admin_enqueue_scripts', array($this, 'enqueue_admin_scripts'), 75 );
100
- add_action( 'admin_notices', array( $this, 'admin_notices' ) );
101
-
102
- add_action( 'woocommerce_after_shipping_rate', array( $this, 'woocommerce_after_shipping_rate' ), 10, 2 );
103
-
104
- add_action( 'flexible_shipping_method_rate_id', array( $this, 'flexible_shipping_method_rate_id' ), 9999999, 2 );
105
-
106
- add_action( 'wp_ajax_flexible_shipping_export', array( $this, 'wp_ajax_flexible_shipping_export' ) );
107
-
108
- add_filter( 'woocommerce_shipping_chosen_method', array( $this, 'woocommerce_shipping_chosen_method' ), 10, 2);
109
-
110
- add_action( 'woocommerce_checkout_update_order_meta', array(
111
- $this,
112
- 'woocommerce_checkout_update_order_meta'
113
- ) );
114
-
115
- add_action( 'woocommerce_checkout_create_order', array(
116
- $this,
117
- 'woocommerce_checkout_create_order'
118
- ) );
119
-
120
-
121
- add_action( 'init', array( $this, 'init_polylang') );
122
- add_action( 'admin_init', array( $this, 'init_wpml') );
123
-
124
- add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_wpml' ), 1 );
125
-
126
- if ( class_exists( 'WC_Aelia_CurrencySwitcher' ) ) {
127
- add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_aelia' ), 1 );
128
- }
129
-
130
- if ( class_exists( 'Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher' ) ) {
131
- add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_aelia_namespaces' ), 1 );
132
- }
133
-
134
- if ( function_exists( 'wmcs_convert_price' ) ) {
135
- add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_wmcs' ), 1 );
136
- }
137
-
138
- if ( isset( $GLOBALS['WOOCS'] ) ) {
139
- add_filter( 'flexible_shipping_value_in_currency', array( $this, 'flexible_shipping_value_in_currency_woocs' ), 1 );
140
- }
141
- add_filter( 'option_woocommerce_cod_settings', array( $this, 'option_woocommerce_cod_settings' ) );
142
-
143
- }
144
-
145
- public function option_woocommerce_cod_settings( $value ) {
146
- if ( is_checkout() ) {
147
- if (
148
- !empty( $value )
149
- && is_array( $value )
150
- && $value['enabled'] == 'yes'
151
- && !empty( $value['enable_for_methods'] )
152
- && is_array( $value['enable_for_methods'] )
153
- ) {
154
- foreach ( $value['enable_for_methods'] as $method ) {
155
- if ( $method == 'flexible_shipping' ) {
156
- $all_fs_methods = flexible_shipping_get_all_shipping_methods();
157
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
158
- $flexible_shipping = $all_shipping_methods['flexible_shipping'];
159
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
160
- foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
161
- $value['enable_for_methods'][] = $flexible_shipping_rate['id_for_shipping'];
162
- }
163
- break;
164
- }
165
- }
166
- }
167
- }
168
- return $value;
169
- }
170
-
171
- public function session_init() {
172
- if ( ! session_id() ) {
173
- session_start();
174
- }
175
- }
176
-
177
- public function woocommerce_checkout_create_order( WC_Order $order ) {
178
- $order_shipping_methods = $order->get_shipping_methods();
179
- foreach ( $order_shipping_methods as $shipping_id => $shipping_method ) {
180
- if ( isset( $shipping_method['item_meta'] )
181
- && isset( $shipping_method['item_meta']['_fs_method'] )
182
- ) {
183
- $fs_method = $shipping_method['item_meta']['_fs_method'];
184
- if ( !empty( $fs_method['method_integration'] ) ) {
185
- $order->add_meta_data( '_flexible_shipping_integration', $fs_method['method_integration'] );
186
- }
187
- }
188
- }
189
- }
190
-
191
-
192
- public function woocommerce_checkout_update_order_meta( $order_id ) {
193
- $order = wc_get_order( $order_id );
194
- $order_shipping_methods = $order->get_shipping_methods();
195
- foreach ( $order_shipping_methods as $shipping_id => $shipping_method ) {
196
- if ( version_compare( WC_VERSION, '2.7', '<' ) ) {
197
- if (isset($shipping_method['item_meta'])
198
- && isset($shipping_method['item_meta']['_fs_method'])
199
- && isset($shipping_method['item_meta']['_fs_method'][0])
200
- ) {
201
- $fs_method = unserialize($shipping_method['item_meta']['_fs_method'][0]);
202
- if ( !empty( $fs_method['method_integration'] ) ) {
203
- add_post_meta($order->id, '_flexible_shipping_integration', $fs_method['method_integration']);
204
- }
205
- }
206
- }
207
- }
208
- }
209
-
210
- function woocommerce_shipping_chosen_method( $method, $available_methods ) {
211
- $chosen_shipping_methods = WC()->session->get( 'chosen_shipping_methods', array() );
212
- if ( isset( $chosen_shipping_methods[0] ) ) {
213
- foreach ($available_methods as $available_method ) {
214
- if ( $available_method->id ==
215
- $chosen_shipping_methods[0] ) {
216
- $method = $available_method->id;
217
- break;
218
- }
219
- }
220
- }
221
- return $method;
222
- }
223
-
224
- function wp_ajax_flexible_shipping_export() {
225
- check_ajax_referer( 'flexible_shipping', 'flexible_shipping_nonce' );
226
- $ret = array( 'status' => 'ok' );
227
- $flexible_shipping_action = '';
228
- if ( isset( $_REQUEST['flexible_shipping_action'] ) ) {
229
- $flexible_shipping_action = $_REQUEST['flexible_shipping_action'];
230
- }
231
- if ( $flexible_shipping_action == 'export' ) {
232
- $instance_id = '';
233
- if ( isset( $_REQUEST['instance_id'] ) ) {
234
- $instance_id = $_REQUEST['instance_id'];
235
- }
236
- $ret['instance_id'] = $instance_id;
237
- $methods = '';
238
- if ( isset( $_REQUEST['methods'] ) ) {
239
- $methods = $_REQUEST['methods'];
240
- }
241
- $methods_array = explode( ',', $methods );
242
- $shipping_method = WC_Shipping_Zones::get_shipping_method( $instance_id );
243
- $wc_shipping_classes = WC()->shipping->get_shipping_classes();
244
- $ret['shipping_method'] = $shipping_method;
245
-
246
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
247
-
248
- $flexible_shipping = $all_shipping_methods['flexible_shipping'];
249
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
250
-
251
- $filename = 'fs_' . str_replace( 'http://', '', str_replace( 'https://', '', site_url() ) ) . '-' . $instance_id;
252
-
253
- $ret['all_rates'] = $flexible_shipping_rates;
254
- $ret['methods'] = $methods;
255
- $csv_array = array();
256
- $csv_header = array(
257
- 'Method Title',
258
- 'Method Description',
259
- 'Free Shipping',
260
- 'Maximum Cost',
261
- 'Calculation Method',
262
- 'Visibility',
263
- 'Default',
264
- 'Based on',
265
- 'Min',
266
- 'Max',
267
- 'Cost per order',
268
- 'Additional cost',
269
- 'Value',
270
- 'Shipping Class',
271
- 'Stop',
272
- 'Cancel',
273
- );
274
- $csv_array[] = $csv_header;
275
- foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
276
- if ( !in_array( $flexible_shipping_rate['id'], $methods_array ) ) {
277
- continue;
278
- }
279
- $filename .= '_' . $flexible_shipping_rate['id'];
280
- if ( !isset( $flexible_shipping_rate['method_description'] ) ) {
281
- $flexible_shipping_rate['method_description'] = '';
282
- }
283
- if ( !isset( $flexible_shipping_rate['method_free_shipping'] ) ) {
284
- $flexible_shipping_rate['method_free_shipping'] = '';
285
- }
286
- if ( !isset( $flexible_shipping_rate['method_max_cost'] ) ) {
287
- $flexible_shipping_rate['method_max_cost'] = '';
288
- }
289
- if ( !isset( $flexible_shipping_rate['method_calculation_method'] ) ) {
290
- $flexible_shipping_rate['method_calculation_method'] = '';
291
- }
292
- if ( !isset( $flexible_shipping_rate['method_visibility'] ) ) {
293
- $flexible_shipping_rate['method_visibility'] = '';
294
- }
295
- if ( $flexible_shipping_rate['method_visibility'] != 'yes' ) {
296
- $flexible_shipping_rate['method_visibility'] = '';
297
- }
298
- if ( !isset( $flexible_shipping_rate['method_default'] ) ) {
299
- $flexible_shipping_rate['method_default'] = '';
300
- }
301
- if ( $flexible_shipping_rate['method_default'] != 'yes' ) {
302
- $flexible_shipping_rate['method_default'] = '';
303
- }
304
- $csv_array[] = array(
305
- $flexible_shipping_rate['method_title'],
306
- $flexible_shipping_rate['method_description'],
307
- $flexible_shipping_rate['method_free_shipping'],
308
- $flexible_shipping_rate['method_max_cost'],
309
- $flexible_shipping_rate['method_calculation_method'],
310
- $flexible_shipping_rate['method_visibility'],
311
- $flexible_shipping_rate['method_default'],
312
- '',
313
- '',
314
- '',
315
- '',
316
- '',
317
- '',
318
- '',
319
- '',
320
- '',
321
- );
322
- foreach ( $flexible_shipping_rate['method_rules'] as $method_rule ) {
323
- if ( !isset( $method_rule['based_on'] ) ) {
324
- $method_rule['based_on'] = '';
325
- }
326
- if ( !isset( $method_rule['min'] ) ) {
327
- $method_rule['min'] = '';
328
- }
329
- if ( !isset( $method_rule['max'] ) ) {
330
- $method_rule['max'] = '';
331
- }
332
- if ( !isset( $method_rule['cost_per_order'] ) ) {
333
- $method_rule['cost_per_order'] = '';
334
- }
335
- if ( !isset( $method_rule['cost_additional'] ) ) {
336
- $method_rule['cost_additional'] = '';
337
- }
338
- if ( !isset( $method_rule['per_value'] ) ) {
339
- $method_rule['per_value'] = '';
340
- }
341
- if ( !isset( $method_rule['shipping_class'] ) ) {
342
- $method_rule['shipping_class'] = '';
343
- }
344
- else {
345
- $method_shipping_class = $method_rule['shipping_class'];
346
- if ( !is_array( $method_shipping_class ) ) {
347
- $method_shipping_class = array( $method_shipping_class );
348
- }
349
- $method_rule['shipping_class'] = '';
350
- foreach ( $method_shipping_class as $shipping_class ) {
351
- if ( in_array( $shipping_class, array( 'none', 'any', 'all' ) ) ) {
352
- $method_rule['shipping_class'] .= $shipping_class;
353
- $method_rule['shipping_class'] .= ',';
354
- }
355
- }
356
- foreach ( $wc_shipping_classes as $shipping_class ) {
357
- if ( in_array($shipping_class->term_id, $method_shipping_class ) ) {
358
- $method_rule['shipping_class'] .= $shipping_class->name;
359
- $method_rule['shipping_class'] .= ',';
360
- }
361
- }
362
- $method_rule['shipping_class'] = trim( $method_rule['shipping_class'], ',' );
363
- }
364
- if ( !isset( $method_rule['stop'] ) ) {
365
- $method_rule['stop'] = '';
366
- }
367
- if ( $method_rule['stop'] == '1' ) {
368
- $method_rule['stop'] = 'yes';
369
- }
370
- else {
371
- $method_rule['stop'] = '';
372
- }
373
- if ( !isset( $method_rule['cancel'] ) ) {
374
- $method_rule['cancel'] = '';
375
- }
376
- if ( $method_rule['cancel'] == '1' ) {
377
- $method_rule['cancel'] = 'yes';
378
- }
379
- else {
380
- $method_rule['cancel'] = '';
381
- }
382
- $csv_array[] = array(
383
- $flexible_shipping_rate['method_title'],
384
- '',
385
- '',
386
- '',
387
- '',
388
- '',
389
- '',
390
- $method_rule['based_on'],
391
- $method_rule['min'],
392
- $method_rule['max'],
393
- $method_rule['cost_per_order'],
394
- $method_rule['cost_additional'],
395
- $method_rule['per_value'],
396
- $method_rule['shipping_class'],
397
- $method_rule['stop'],
398
- $method_rule['cancel'],
399
- );
400
- }
401
- }
402
- $ret['csv_array'] = $csv_array;
403
- header('Content-Type: text/csv; charset=utf-8');
404
- header('Content-Disposition: attachment; filename=' . $filename . '.csv');
405
- $out = fopen('php://output', 'w');
406
- foreach ( $csv_array as $fields ) {
407
- fputcsv( $out, $fields, ';' );
408
- }
409
- fclose($out);
410
- wp_die();
411
- }
412
- echo json_encode($ret,JSON_PRETTY_PRINT);
413
- wp_die();
414
- }
415
-
416
- function init_polylang() {
417
- if ( function_exists( 'pll_register_string' ) ) {
418
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
419
- $flexible_shipping = $all_shipping_methods['flexible_shipping'];
420
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
421
- foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
422
- if ( isset( $flexible_shipping_rate['method_title'] ) ) {
423
- pll_register_string( $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], __( 'Flexible Shipping', 'flexible-shipping' ) );
424
- }
425
- if ( isset( $flexible_shipping_rate['method_description'] ) ) {
426
- pll_register_string( $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], __( 'Flexible Shipping', 'flexible-shipping' ) );
427
- }
428
- if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) {
429
- pll_register_string( $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], __( 'Flexible Shipping', 'flexible-shipping' ) );
430
- }
431
- }
432
- }
433
- }
434
-
435
- function init_wpml() {
436
- if ( function_exists( 'icl_register_string' ) ) {
437
- $icl_language_code = defined('ICL_LANGUAGE_CODE') ? ICL_LANGUAGE_CODE : get_bloginfo('language');
438
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
439
- $flexible_shipping = $all_shipping_methods['flexible_shipping'];
440
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
441
- foreach ( $flexible_shipping_rates as $flexible_shipping_rate ) {
442
- if ( isset( $flexible_shipping_rate['method_title'] ) ) {
443
- icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_title'], $flexible_shipping_rate['method_title'], false, $icl_language_code );
444
- }
445
- if ( isset( $flexible_shipping_rate['method_description'] ) ) {
446
- icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_description'], $flexible_shipping_rate['method_description'], false, $icl_language_code );
447
- }
448
- if ( isset( $flexible_shipping_rate['method_free_shipping_label'] ) ) {
449
- icl_register_string( 'flexible-shipping', $flexible_shipping_rate['method_free_shipping_label'], $flexible_shipping_rate['method_free_shipping_label'], false, $icl_language_code );
450
- }
451
- }
452
- }
453
- }
454
-
455
-
456
- public function admin_notices() {
457
- if ( is_plugin_active( 'woocommerce-active-payments/activepayments.php' ) ) {
458
- $plugin_activepayments = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-active-payments/activepayments.php' );
459
-
460
- $version_compare = version_compare( $plugin_activepayments['Version'], '2.7' );
461
- if ( $version_compare < 0 ) {
462
- $class = 'notice notice-error';
463
- $message = __( 'Flexible Shipping requires at least version 2.7 of Active Payments plugin.', 'flexible-shipping' );
464
-
465
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
466
- }
467
- }
468
- if ( is_plugin_active( 'woocommerce-enadawca/woocommerce-enadawca.php' ) ) {
469
- $plugin_enadawca = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-enadawca/woocommerce-enadawca.php' );
470
-
471
- $version_compare = version_compare( $plugin_enadawca['Version'], '1.2' );
472
- if ( $version_compare < 0 ) {
473
- $class = 'notice notice-error';
474
- $message = __( 'Flexible Shipping requires at least version 1.2 of eNadawca plugin.', 'flexible-shipping' );
475
-
476
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
477
- }
478
- }
479
- if ( is_plugin_active( 'woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' ) ) {
480
- $plugin_pwr = get_plugin_data( WP_PLUGIN_DIR . '/woocommerce-paczka-w-ruchu/woocommerce-paczka-w-ruchu.php' );
481
-
482
- $version_compare = version_compare( $plugin_pwr['Version'], '1.1' );
483
- if ( $version_compare < 0 ) {
484
- $class = 'notice notice-error';
485
- $message = __( 'Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin.', 'flexible-shipping' );
486
-
487
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
488
- }
489
- }
490
- if ( is_plugin_active( 'woo-flexible-shipping/flexible-shipping.php' ) ) {
491
-
492
- $class = 'notice notice-error';
493
- $message = sprintf( __( 'You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it on %splugins page%s. Read about big changes in Flexible Shipping on %sour blog →%s', 'flexible-shipping' ), '<a href="' . admin_url('plugins.php') . '">', '</a>', '<a href="https://www.wpdesk.pl/blog/nowy-flexible-shipping/">', '</a>' );
494
-
495
- printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
496
- }
497
- }
498
-
499
- public function loadPluginTextDomain() {
500
- parent::loadPluginTextDomain();
501
- $ret = load_plugin_textdomain( 'flexible-shipping', FALSE, basename( dirname( __FILE__ ) ) . '/languages' );
502
- }
503
-
504
- public static function getTextDomain() {
505
- return 'flexible-shipping';
506
- }
507
-
508
- function enqueue_admin_scripts() {
509
- $current_screen = get_current_screen();
510
- if ( $current_screen->id === 'woocommerce_page_wc-settings' || $current_screen->id === 'edit-shop_order' || $current_screen->id === 'shop_order' ) {
511
- $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
512
- wp_register_script( 'fs_admin', $this->getPluginUrl() . 'assets/js/admin' . $suffix . '.js', array( 'jquery' ), $this->scripts_version );
513
- wp_localize_script( 'fs_admin', 'fs_admin', array(
514
- 'ajax_url' => admin_url( 'admin-ajax.php' ),
515
- ));
516
- wp_enqueue_script( 'fs_admin' );
517
- wp_enqueue_style( 'fs_admin', $this->getPluginUrl() . 'assets/css/admin' . $suffix . '.css', array(), $this->scripts_version );
518
- wp_enqueue_style( 'fs_font', $this->getPluginUrl() . 'assets/css/font' . $suffix . '.css', array(), $this->scripts_version );
519
- }
520
- }
521
-
522
- function enqueue_scripts() {
523
- }
524
-
525
- function admin_footer() {
526
- }
527
-
528
- /**
529
- * action_links function.
530
- *
531
- * @access public
532
- * @param mixed $links
533
- * @return void
534
- */
535
- public function linksFilter( $links ) {
536
- $docs_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/docs/flexible-shipping-pro-woocommerce-docs/' : 'https://www.wpdesk.net/docs/flexible-shipping-pro-woocommerce-docs/';
537
- $support_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/support/' : 'https://www.wpdesk.net/support';
538
 
539
- $docs_link .= '?utm_source=wp-admin-plugins&utm_medium=quick-link&utm_campaign=flexible-shipping-docs-link';
540
 
541
- $plugin_links = array(
542
- '<a href="' . admin_url( 'admin.php?page=wc-settings&tab=shipping') . '">' . __( 'Settings', 'flexible-shipping' ) . '</a>',
543
- '<a href="' . $docs_link . '">' . __( 'Docs', 'flexible-shipping' ) . '</a>',
544
- '<a href="' . $support_link . '">' . __( 'Support', 'flexible-shipping' ) . '</a>',
545
- );
546
- $pro_link = get_locale() === 'pl_PL' ? 'https://www.wpdesk.pl/sklep/flexible-shipping-pro-woocommerce/' : 'https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/';
547
- $utm = '?utm_source=wp-admin-plugins&utm_medium=link&utm_campaign=flexible-shipping-plugins-upgrade-link';
548
 
549
- if ( ! wpdesk_is_plugin_active( 'flexible-shipping-pro/flexible-shipping-pro.php' ) )
550
- $plugin_links[] = '<a href="' . $pro_link . $utm . '" target="_blank" style="color:#d64e07;font-weight:bold;">' . __( 'Upgrade', 'flexible-shipping' ) . '</a>';
551
- return array_merge( $plugin_links, $links );
552
- }
553
-
554
-
555
- public function woocommerce_after_shipping_rate( $method, $index ) {
556
- if ( $method->method_id == 'flexible_shipping' ) {
557
- $description = WC()->session->get('flexible_shipping_description_' . $method->id, false );
558
- if ( $description && $description != '' ) {
559
- wc_get_template(
560
- 'cart/flexible-shipping/after-shipping-rate.php',
561
- array(
562
- 'method_description' => $description,
563
- )
564
- , ''
565
- , trailingslashit( plugin_dir_path( __FILE__ ) ) . 'templates/'
566
- );
567
- }
568
- }
569
- }
570
-
571
- public function flexible_shipping_method_rate_id( $method_id, array $shipping_method ) {
572
- if ( isset( $shipping_method['id_for_shipping'] ) && $shipping_method['id_for_shipping'] != '' ) {
573
- $method_id = $shipping_method['id_for_shipping'];
574
- }
575
- return $method_id;
576
- }
577
-
578
- public function flexible_shipping_value_in_currency_aelia( $value ) {
579
- $aelia = WC_Aelia_CurrencySwitcher::instance();
580
- $aelia_settings = WC_Aelia_CurrencySwitcher::settings();
581
- $from_currency = $aelia_settings->base_currency();
582
- $to_currency = $aelia->get_selected_currency();
583
- $value = $aelia->convert( $value, $from_currency, $to_currency );
584
- return $value;
585
- }
586
-
587
- public function flexible_shipping_value_in_currency_aelia_namespaces( $value ) {
588
- $aelia = Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher::instance();
589
- $aelia_settings = Aelia\WC\CurrencySwitcher\WC_Aelia_CurrencySwitcher::settings();
590
- $from_currency = $aelia_settings->base_currency();
591
- $to_currency = $aelia->get_selected_currency();
592
- $value = $aelia->convert( $value, $from_currency, $to_currency );
593
- return $value;
594
- }
595
 
596
- public function flexible_shipping_value_in_currency_wmcs( $value ) {
597
- $value = wmcs_convert_price( $value );
598
- return $value;
599
- }
600
 
601
- public function flexible_shipping_value_in_currency_wpml( $value ) {
602
- return apply_filters( 'wcml_raw_price_amount', $value );
603
- }
604
-
605
- public function flexible_shipping_value_in_currency_woocs( $value ) {
606
- return $GLOBALS['WOOCS']->woocs_exchange_value( $value );
607
- }
608
-
609
- }
610
-
611
- function flexible_shipping_get_all_shipping_methods() {
612
- /*
613
- $all_shipping_methods = WC()->shipping()->get_shipping_methods();
614
- if ( empty( $all_shipping_methods ) ) {
615
- $all_shipping_methods = WC()->shipping()->load_shipping_methods();
616
- }
617
- */
618
- $all_shipping_methods = WC()->shipping()->load_shipping_methods();
619
- return $all_shipping_methods;
620
- }
621
-
622
-
623
- function flexible_shipping_method_selected_in_cart( $shipping_method_integration ) {
624
- global $woocommerce;
625
- $shippings = $woocommerce->session->get('chosen_shipping_methods');
626
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
627
- $flexible_shipping = $all_shipping_methods['flexible_shipping'];
628
- $flexible_shipping_rates = $flexible_shipping->get_all_rates();
629
- foreach ( $shippings as $id => $shipping ) {
630
- if ( isset( $flexible_shipping_rates[$shipping] ) ) {
631
- $shipping_method = $flexible_shipping_rates[$shipping];
632
- if ( $shipping_method['method_integration'] == $shipping_method_integration ) {
633
- return $shipping_method;
634
- }
635
- }
636
- }
637
- return false;
638
- }
639
-
640
- function flexible_shipping_method_selected( $order, $shipping_method_integration ) {
641
- if ( is_numeric( $order ) ) {
642
- $order = wc_get_order( $order );
643
- }
644
- $shippings = $order->get_shipping_methods();
645
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
646
- if ( isset( $all_shipping_methods['flexible_shipping'] ) ) {
647
- $flexible_shipping_rates = $all_shipping_methods['flexible_shipping']->get_all_rates();
648
- foreach ( $shippings as $id => $shipping ) {
649
- if ( isset( $flexible_shipping_rates[ $shipping['method_id'] ] ) ) {
650
- $shipping_method = $flexible_shipping_rates[ $shipping['method_id'] ];
651
- if ( $shipping_method['method_integration'] == $shipping_method_integration ) {
652
- return $shipping_method;
653
- }
654
- }
655
- }
656
- }
657
- return false;
658
- }
659
-
660
- function flexible_shipping_get_integration_for_method( $method_id ) {
661
- $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
662
- if ( isset( $all_shipping_methods['flexible_shipping'] ) ) {
663
- $flexible_shipping_rates = $all_shipping_methods['flexible_shipping']->get_all_rates();
664
- if ( isset( $flexible_shipping_rates[$method_id] ) ) {
665
- return $flexible_shipping_rates[$method_id]['method_integration'];
666
- }
667
- }
668
- return false;
669
- }
670
-
671
- if ( !function_exists('wpdesk_redirect') ) {
672
- function wpdesk_redirect( $redirect ) {
673
- if ( 1==1 && headers_sent() ) {
674
- ?>
675
- <span><?php printf( __( 'Redirecting. If page not redirects click %s here %s.', 'flexible-shipping'), '<a href="' . $redirect . '" >', '</a>' ); ?></span>
676
-
677
- <script>
678
- parent.location.replace('<?php echo $redirect; ?>');
679
- </script>
680
- <?php
681
- }
682
- else {
683
- wp_safe_redirect($redirect);
684
- }
685
- exit;
686
- }
687
- }
688
-
689
- if ( !function_exists( 'wpdesk__' ) ) {
690
- function wpdesk__( $text, $domain ) {
691
- if ( function_exists( 'icl_sw_filters_gettext' ) ) {
692
- return icl_sw_filters_gettext( $text, $text, $domain, $text );
693
- }
694
- if ( function_exists( 'pll__' ) ) {
695
- return pll__( $text );
696
- }
697
- return __( $text, $domain );
698
- }
699
- }
700
-
701
- if ( !function_exists( 'wpdesk__e' ) ) {
702
- function wpdesk__e( $text, $domain ) {
703
- echo wpdesk__( $text, $domain );
704
- }
705
- }
706
-
707
- $_GLOBALS['woocommerce_flexible_shipping'] = new WPDesk_Flexible_Shipping_Free_Plugin();
708
-
709
- }
710
 
711
  add_action( 'plugins_loaded', 'flexible_shipping_plugins_loaded', 9 );
712
- function flexible_shipping_plugins_loaded() {
713
- if ( !class_exists( 'WPDesk_Tracker' ) ) {
714
- include( 'inc/wpdesk-tracker/class-wpdesk-tracker.php' );
715
- WPDesk_Tracker::init( basename( dirname( __FILE__ ) ) );
 
 
716
  }
717
  }
718
-
3
  Plugin Name: Flexible Shipping
4
  Plugin URI: https://wordpress.org/plugins/flexible-shipping/
5
  Description: Create additional shipment methods in WooCommerce and enable pricing based on cart weight or total.
6
+ Version: 2.1
7
  Author: WP Desk
8
  Author URI: https://www.wpdesk.net/
9
  Text Domain: flexible-shipping
10
  Domain Path: /languages/
11
  Requires at least: 4.5
12
+ Tested up to: 4.9.5
13
  WC requires at least: 2.6.14
14
+ WC tested up to: 3.3.5
15
 
16
  Copyright 2017 WP Desk Ltd.
17
 
32
  */
33
 
34
 
35
+ if ( ! defined( 'ABSPATH' ) ) {
36
+ exit;
37
+ } // Exit if accessed directly
38
 
39
+ $plugin_version = '2.1';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ define( 'FLEXIBLE_SHIPPING_VERSION', $plugin_version );
42
 
43
+ require_once( dirname( __FILE__ ) . '/classes/wpdesk/class-requirement-checker.php' );
 
 
 
 
 
 
44
 
45
+ $requirements_checker = new WPDesk_Requirement_Checker_1_10(
46
+ __FILE__,
47
+ '5.5',
48
+ '4.5',
49
+ '2.6.14'
50
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
+ $requirements_checker
53
+ ->add_plugin_require('woocommerce/woocommerce.php', 'WooCommerce' );
 
 
54
 
55
+ $requirements_checker->check_requirements_and_load_plugin_deferred();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  add_action( 'plugins_loaded', 'flexible_shipping_plugins_loaded', 9 );
58
+ if ( !function_exists( 'flexible_shipping_plugins_loaded' ) ) {
59
+ function flexible_shipping_plugins_loaded() {
60
+ if ( ! class_exists( 'WPDesk_Tracker' ) ) {
61
+ include( 'inc/wpdesk-tracker/class-wpdesk-tracker.php' );
62
+ WPDesk_Tracker::init( basename( dirname( __FILE__ ) ) );
63
+ }
64
  }
65
  }
 
inc/functions.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function flexible_shipping_get_all_shipping_methods() {
4
+ /*
5
+ $all_shipping_methods = WC()->shipping()->get_shipping_methods();
6
+ if ( empty( $all_shipping_methods ) ) {
7
+ $all_shipping_methods = WC()->shipping()->load_shipping_methods();
8
+ }
9
+ */
10
+ $all_shipping_methods = WC()->shipping()->load_shipping_methods();
11
+ return $all_shipping_methods;
12
+ }
13
+
14
+
15
+ function flexible_shipping_method_selected_in_cart( $shipping_method_integration ) {
16
+ global $woocommerce;
17
+ $shippings = $woocommerce->session->get('chosen_shipping_methods');
18
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
19
+ $flexible_shipping = $all_shipping_methods['flexible_shipping'];
20
+ $flexible_shipping_rates = $flexible_shipping->get_all_rates();
21
+ foreach ( $shippings as $id => $shipping ) {
22
+ if ( isset( $flexible_shipping_rates[$shipping] ) ) {
23
+ $shipping_method = $flexible_shipping_rates[$shipping];
24
+ if ( $shipping_method['method_integration'] == $shipping_method_integration ) {
25
+ return $shipping_method;
26
+ }
27
+ }
28
+ }
29
+ return false;
30
+ }
31
+
32
+ function flexible_shipping_method_selected( $order, $shipping_method_integration ) {
33
+ if ( is_numeric( $order ) ) {
34
+ $order = wc_get_order( $order );
35
+ }
36
+ $shippings = $order->get_shipping_methods();
37
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
38
+ if ( isset( $all_shipping_methods['flexible_shipping'] ) ) {
39
+ $flexible_shipping_rates = $all_shipping_methods['flexible_shipping']->get_all_rates();
40
+ foreach ( $shippings as $id => $shipping ) {
41
+ if ( isset( $flexible_shipping_rates[ $shipping['method_id'] ] ) ) {
42
+ $shipping_method = $flexible_shipping_rates[ $shipping['method_id'] ];
43
+ if ( $shipping_method['method_integration'] == $shipping_method_integration ) {
44
+ return $shipping_method;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return false;
50
+ }
51
+
52
+ function flexible_shipping_get_integration_for_method( $method_id ) {
53
+ $all_shipping_methods = flexible_shipping_get_all_shipping_methods();
54
+ if ( isset( $all_shipping_methods['flexible_shipping'] ) ) {
55
+ $flexible_shipping_rates = $all_shipping_methods['flexible_shipping']->get_all_rates();
56
+ if ( isset( $flexible_shipping_rates[$method_id] ) ) {
57
+ return $flexible_shipping_rates[$method_id]['method_integration'];
58
+ }
59
+ }
60
+ return false;
61
+ }
62
+
63
+ if ( !function_exists('wpdesk_redirect') ) {
64
+ function wpdesk_redirect( $redirect ) {
65
+ if ( 1==1 && headers_sent() ) {
66
+ ?>
67
+ <span><?php printf( __( 'Redirecting. If page not redirects click %s here %s.', 'flexible-shipping'), '<a href="' . $redirect . '" >', '</a>' ); ?></span>
68
+
69
+ <script>
70
+ parent.location.replace('<?php echo $redirect; ?>');
71
+ </script>
72
+ <?php
73
+ }
74
+ else {
75
+ wp_safe_redirect($redirect);
76
+ }
77
+ exit;
78
+ }
79
+ }
80
+
81
+ if ( !function_exists( 'wpdesk__' ) ) {
82
+ function wpdesk__( $text, $domain ) {
83
+ if ( function_exists( 'icl_sw_filters_gettext' ) ) {
84
+ return icl_sw_filters_gettext( $text, $text, $domain, $text );
85
+ }
86
+ if ( function_exists( 'pll__' ) ) {
87
+ return pll__( $text );
88
+ }
89
+ return __( $text, $domain );
90
+ }
91
+ }
92
+
93
+ if ( !function_exists( 'wpdesk__e' ) ) {
94
+ function wpdesk__e( $text, $domain ) {
95
+ echo wpdesk__( $text, $domain );
96
+ }
97
+ }
98
+
99
+
inc/wpdesk-tracker/lang/wpdesk-tracker-pl_PL.mo CHANGED
Binary file
inc/wpdesk-tracker/lang/wpdesk-tracker-pl_PL.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP Desk Tracker\n"
4
- "POT-Creation-Date: 2017-10-04 17:34+0200\n"
5
- "PO-Revision-Date: 2017-10-04 17:36+0200\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: \n"
8
  "Language: pl_PL\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 2.0.3\n"
13
  "X-Poedit-Basepath: ../..\n"
14
  "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
15
  "|| n%100>=20) ? 1 : 2);\n"
@@ -20,6 +20,13 @@ msgstr ""
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: wpdesk-logger.php\n"
22
 
 
 
 
 
 
 
 
23
  #: wpdesk-tracker/views/tracker-connect.php:7
24
  #: wpdesk-tracker/views/tracker-notice.php:5
25
  #: wpdesk-tracker/views/tracker-notice.php:22
@@ -99,7 +106,7 @@ msgid ""
99
  " If you have a moment, please let us know why you are deactivating plugin "
100
  "(anonymous feedback):"
101
  msgstr ""
102
- "Jeśli masz chwilę, prosimy daj nam znać dlaczego dezaktywowałeś wtyczkę "
103
  "(anonimowa opinia):"
104
 
105
  #: wpdesk-tracker/views/tracker-deactivate.php:16
@@ -128,7 +135,7 @@ msgstr "Nie potrzebuję już wtyczki"
128
 
129
  #: wpdesk-tracker/views/tracker-deactivate.php:59
130
  msgid "It's a temporary deactivation. I'm just debugging an issue."
131
- msgstr "Jest to tymczasowa dezaktywacja, debaguję problem"
132
 
133
  #: wpdesk-tracker/views/tracker-deactivate.php:67
134
  msgid "Other"
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: WP Desk Tracker\n"
4
+ "POT-Creation-Date: 2018-04-19 22:51+0200\n"
5
+ "PO-Revision-Date: 2018-04-19 22:53+0200\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: \n"
8
  "Language: pl_PL\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.0.6\n"
13
  "X-Poedit-Basepath: ../..\n"
14
  "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
15
  "|| n%100>=20) ? 1 : 2);\n"
20
  "X-Poedit-SearchPath-0: .\n"
21
  "X-Poedit-SearchPathExcluded-0: wpdesk-logger.php\n"
22
 
23
+ #: functions.php:67
24
+ #, php-format
25
+ msgid "Redirecting. If page not redirects click %s here %s."
26
+ msgstr ""
27
+ "Przekierowywanie. Jeśli strona nie przekierowuje cię automatycznie, kliknij "
28
+ "%s tu %s."
29
+
30
  #: wpdesk-tracker/views/tracker-connect.php:7
31
  #: wpdesk-tracker/views/tracker-notice.php:5
32
  #: wpdesk-tracker/views/tracker-notice.php:22
106
  " If you have a moment, please let us know why you are deactivating plugin "
107
  "(anonymous feedback):"
108
  msgstr ""
109
+ " Jeśli masz chwilę, prosimy daj nam znać dlaczego dezaktywowałeś wtyczkę "
110
  "(anonimowa opinia):"
111
 
112
  #: wpdesk-tracker/views/tracker-deactivate.php:16
135
 
136
  #: wpdesk-tracker/views/tracker-deactivate.php:59
137
  msgid "It's a temporary deactivation. I'm just debugging an issue."
138
+ msgstr "Jest to tymczasowa dezaktywacja, debaguję problem."
139
 
140
  #: wpdesk-tracker/views/tracker-deactivate.php:67
141
  msgid "Other"
languages/flexible-shipping-pl_PL.mo CHANGED
Binary file
languages/flexible-shipping-pl_PL.po CHANGED
@@ -1,15 +1,15 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Flexible Shipping\n"
4
- "POT-Creation-Date: 2017-12-22 12:55+0100\n"
5
- "PO-Revision-Date: 2017-12-22 12:57+0100\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
8
  "Language: pl_PL\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 2.0.4\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: flexible-shipping.php\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
@@ -20,6 +20,47 @@ msgstr ""
20
  "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  #: classes/bulk-actions.php:46
25
  msgid "New"
@@ -134,30 +175,22 @@ msgstr ""
134
  msgid "Bulk shipping manifest - processed orders: %d"
135
  msgstr "Zbiorcze tworzenie protokołów nadania - przetworzone zamówienia: %d"
136
 
137
- #: classes/inspire/plugin4.php:217
138
- msgid ""
139
- "An Unexpected HTTP Error occurred during the API request. <a href=\"?\" "
140
- "onclick=\"document.location.reload(); return false;\">Try again</a>"
141
- msgstr ""
142
- "Wystąpił nieoczekiwany błąd HTTP podczas zapytania API.</p> <p><a href=„?” "
143
- "onclick=„document.location.reload(); return false;”>Spróbuj ponownie</a>"
144
-
145
- #: classes/inspire/plugin4.php:222
146
- msgid "An unknown error occurred"
147
- msgstr "Wystąpił nieznany błąd"
148
-
149
- #: classes/inspire/plugin4.php:386 flexible-shipping.php:541
150
  msgid "Settings"
151
  msgstr "Ustawienia"
152
 
153
- #: classes/inspire/plugin4.php:387 flexible-shipping.php:542
154
  msgid "Docs"
155
  msgstr "Docs"
156
 
157
- #: classes/inspire/plugin4.php:388 flexible-shipping.php:543
158
  msgid "Support"
159
  msgstr "Wsparcie"
160
 
 
 
 
 
161
  #: classes/manifest/cpt-shipping-manifest.php:60
162
  #: classes/manifest/cpt-shipping-manifest.php:62
163
  #: classes/manifest/cpt-shipping-manifest.php:64
@@ -217,7 +250,7 @@ msgstr "Data"
217
 
218
  #: classes/manifest/cpt-shipping-manifest.php:161
219
  #: classes/manifest/views/filter-form.php:5
220
- #: classes/settings-shipping-method-form.php:115
221
  #: classes/views/html-orders-filter-form.php:5
222
  #: classes/views/html-shipping-method-settings.php:15
223
  msgid "Integration"
@@ -270,6 +303,16 @@ msgstr "Przesyłka"
270
  msgid "Order"
271
  msgstr "Zamówienie"
272
 
 
 
 
 
 
 
 
 
 
 
273
  #: classes/order-add-shipping.php:30 classes/shipment/functions.php:23
274
  #, php-format
275
  msgid "Shipment for order %s, %s"
@@ -288,108 +331,98 @@ msgstr "Wybierz integrację"
288
  msgid "Add shipping"
289
  msgstr "Dodaj przesyłkę"
290
 
291
- #. Plugin Name of the plugin/theme
292
- #: classes/settings-flexible-shipping.php:16
293
- #: classes/settings-flexible-shipping.php:30
294
- #: classes/settings-shipping-method-form.php:57 classes/shipping_method.php:24
295
- #: classes/shipping_method.php:25 classes/shipping_method.php:43
296
- #: flexible-shipping.php:423 flexible-shipping.php:426
297
- #: flexible-shipping.php:429
298
- msgid "Flexible Shipping"
299
- msgstr "Flexible Shipping"
300
-
301
- #: classes/settings-flexible-shipping.php:18
302
  #, php-format
303
  msgid "See how to %sconfigure Flexible Shipping%s."
304
  msgstr "Zobacz jak %sskonfigurować Flexible Shipping%s."
305
 
306
- #: classes/settings-flexible-shipping.php:21
307
- #: classes/settings-shipping-method-form.php:48 classes/shipping_method.php:34
308
  msgid "Enable/Disable"
309
  msgstr "Włącz/Wyłącz"
310
 
311
- #: classes/settings-flexible-shipping.php:23
312
  msgid "Enable Flexible Shipping"
313
  msgstr "Włącz Flexible Shipping"
314
 
315
- #: classes/settings-flexible-shipping.php:27
316
  msgid "Shipping title"
317
  msgstr "Tytuł"
318
 
319
- #: classes/settings-flexible-shipping.php:29
320
  msgid "Visible only to admin in WooCommerce settings."
321
  msgstr "Widoczny tylko dla admina w ustawieniach WooCommerce."
322
 
323
- #: classes/settings-flexible-shipping.php:34
324
  msgid "Tax Status"
325
  msgstr "Status podatku"
326
 
327
- #: classes/settings-flexible-shipping.php:39
328
  msgid "Taxable"
329
  msgstr "Opodatkowany"
330
 
331
- #: classes/settings-flexible-shipping.php:40
332
  msgctxt "Tax status"
333
  msgid "None"
334
  msgstr "Brak"
335
 
336
- #: classes/settings-flexible-shipping.php:44
337
- #: classes/settings-flexible-shipping.php:49
338
  msgid "Shipping Methods"
339
  msgstr "Metody wysyłki"
340
 
341
- #: classes/settings-shipping-method-form.php:10
342
  msgid "Select shipment class"
343
  msgstr "Wybierz klasę wysyłkową"
344
 
345
- #: classes/settings-shipping-method-form.php:19
346
  msgid ""
347
  "Integrate with DPD, DHL, InPost, eNadawca Poczta Polska, Paczka w Ruchu."
348
  msgstr "Zintegruj z DPD, DHL, InPost, eNadawca Poczta Polska, Paczka w Ruchu."
349
 
350
- #: classes/settings-shipping-method-form.php:19
351
  #, php-format
352
  msgid "%sAdd integrations%s"
353
  msgstr "%sDodaj integracje%s"
354
 
355
- #: classes/settings-shipping-method-form.php:22
356
  msgid "Integrate with DPD."
357
  msgstr "Zintegruj z DPD."
358
 
359
- #: classes/settings-shipping-method-form.php:22
360
  #, php-format
361
  msgid "%sAdd integration%s"
362
  msgstr "%sDodaj integrację%s"
363
 
364
- #: classes/settings-shipping-method-form.php:32 classes/shipping_method.php:816
365
  msgid "Free"
366
  msgstr "Bezpłatnie"
367
 
368
- #: classes/settings-shipping-method-form.php:51 classes/shipping_method.php:36
369
  msgid "Enable this shipment method"
370
  msgstr "Włącz tę metodę wysyłki"
371
 
372
- #: classes/settings-shipping-method-form.php:54
373
  msgid "Method Title"
374
  msgstr "Tytuł metody"
375
 
376
- #: classes/settings-shipping-method-form.php:56 classes/shipping_method.php:42
377
  msgid "This controls the title which the user sees during checkout."
378
  msgstr "Tytuł, który widzi użytkownik podczas składania zamówienia."
379
 
380
- #: classes/settings-shipping-method-form.php:63
381
  msgid "Method Description"
382
  msgstr "Opis"
383
 
384
- #: classes/settings-shipping-method-form.php:65
385
  msgid "This controls method description which the user sees during checkout."
386
  msgstr "Opis, który widzi użytkownik podczas składania zamówienia."
387
 
388
- #: classes/settings-shipping-method-form.php:76
389
  msgid "Free Shipping"
390
  msgstr "Darmowa wysyłka"
391
 
392
- #: classes/settings-shipping-method-form.php:79
393
  msgid ""
394
  "Enter a minimum order amount for free shipment. This will override the costs "
395
  "configured below."
@@ -397,46 +430,46 @@ msgstr ""
397
  "Wpisz minimalną kwotę zamówienia dla bezpłatnej wysyłki. Spowoduje to "
398
  "zastąpienie reguł skonfigurowanych poniżej."
399
 
400
- #: classes/settings-shipping-method-form.php:83
401
  msgid "Free Shipping Label"
402
  msgstr "Etykieta darmowej wysyłki"
403
 
404
- #: classes/settings-shipping-method-form.php:86
405
  msgid "Enter additional label for shipment when free shipment available."
406
  msgstr ""
407
  "Wpisz dodatkową etykietę, która zostanie wyświetlona dla darmowej wysyłki."
408
 
409
- #: classes/settings-shipping-method-form.php:95
410
  msgid "Calculation Method"
411
  msgstr "Metoda obliczania"
412
 
413
- #: classes/settings-shipping-method-form.php:97
414
  msgid ""
415
  "Select how rules will be calculated. If you choose \"sum\" the rules order "
416
  "is important."
417
  msgstr ""
418
  "Wybierz jak będą obliczane reguły. Dla sumy, kolejność reguł ma znaczenie."
419
 
420
- #: classes/settings-shipping-method-form.php:100
421
  msgid "Sum"
422
  msgstr "Suma"
423
 
424
- #: classes/settings-shipping-method-form.php:103
425
  #: classes/views/html-shipping-method-settings.php:13
426
  msgid "Visibility"
427
  msgstr "Wyświetlanie"
428
 
429
- #: classes/settings-shipping-method-form.php:106
430
  #: classes/views/html-shipping-method-settings.php:46
431
  msgid "Show only for logged in users"
432
  msgstr "Pokaż tylko dla zalogowanych użytkowników"
433
 
434
- #: classes/settings-shipping-method-form.php:109
435
  #: classes/views/html-shipping-method-settings.php:14
436
  msgid "Default"
437
  msgstr "Domyślnie"
438
 
439
- #: classes/settings-shipping-method-form.php:112
440
  msgid ""
441
  "Check the box to set this option as the default selected choice on the cart "
442
  "page."
@@ -444,24 +477,24 @@ msgstr ""
444
  "Zaznacz, aby ustawić tę metodę wysyłki jako domyślną przy składaniu "
445
  "zamówienia."
446
 
447
- #: classes/settings-shipping-method-form.php:117
448
  msgid "Select integration. "
449
  msgstr "Wybierz integrację. "
450
 
451
- #: classes/settings-shipping-method-form.php:120
452
  #: classes/views/html-shipping-method-rules.php:7
453
  msgid "None"
454
  msgstr "Brak"
455
 
456
- #: classes/settings-shipping-method-form.php:131
457
  msgid "Rules"
458
  msgstr "Reguły"
459
 
460
- #: classes/settings-shipping-method-form.php:152
461
  msgid "Shipping Zone"
462
  msgstr "Strefa wysyłki"
463
 
464
- #: classes/settings-shipping-method-form.php:166
465
  #, php-format
466
  msgid "See how to %sconfigure shipment methods%s."
467
  msgstr "Zobacz jak %sskonfigurować metody wysyłki %s."
@@ -583,108 +616,108 @@ msgstr[2] "Błąd <span class=\"count\">(%s)</span>"
583
  msgid "Shipment data"
584
  msgstr "Dane przesyłki"
585
 
586
- #: classes/shipping_method.php:40
587
  msgid "Shipping Title"
588
  msgstr "Tytuł"
589
 
590
- #: classes/shipping_method.php:112
591
  #: classes/views/html-shipping-method-rules.php:241
592
  msgid "Add New"
593
  msgstr "Dodaj nową"
594
 
595
- #: classes/shipping_method.php:347
596
  msgid ""
597
  "Sorry, there has been an error. The CSV is invalid or incorrect file type."
598
  msgstr ""
599
  "Przepraszamy, wystąpił błąd. Plik CSV jest niepoprawny lub typ pliku jest "
600
  "nieprawidłowy."
601
 
602
- #: classes/shipping_method.php:357 classes/shipping_method.php:360
603
  msgid "import"
604
  msgstr "import"
605
 
606
- #: classes/shipping_method.php:369
607
  #, php-format
608
  msgid "Free Shipping value %s is not valid number. Row number %d."
609
  msgstr "Wartość darmowej wysyłki %s jest niepoprawna. Numer wiersza %d."
610
 
611
- #: classes/shipping_method.php:375
612
  #, php-format
613
  msgid "Maximum Cost value %s is not valid number. Row number %d."
614
  msgstr "Maksymalny koszt %s jest niepoprawny. Numer wiersza %d."
615
 
616
- #: classes/shipping_method.php:386
617
  #, php-format
618
  msgid "Invalid value for Calculation Method in row number %d."
619
  msgstr "Nieprawidłowa wartość dla Metody obliczania w wierszu %d."
620
 
621
- #: classes/shipping_method.php:410
622
  #, php-format
623
  msgid "Invalid value for Based On in row number %d."
624
  msgstr "Nieprawidłowa wartość dla Oparte na w wierszu %d."
625
 
626
- #: classes/shipping_method.php:415
627
  #, php-format
628
  msgid "Min value %s is not valid number. Row number %d."
629
  msgstr "Wartość Min %s jest niepoprawna. Numer wiersza %d."
630
 
631
- #: classes/shipping_method.php:421
632
  #, php-format
633
  msgid "Max value %s is not valid number. Row number %d."
634
  msgstr "Wartość Maks %s jest niepoprawna. Numer wiersza %d."
635
 
636
- #: classes/shipping_method.php:427
637
  #, php-format
638
  msgid "Cost per order value %s is not valid number. Row number %d."
639
  msgstr "Wartość Koszt na zamówienie %s jest niepoprawna. Numer wiersza %d."
640
 
641
- #: classes/shipping_method.php:433
642
  #, php-format
643
  msgid "Additional cost value %s is not valid number. Row number %d."
644
  msgstr "Wartość Dodatkowy koszt %s jest niepoprawna. Numer wiersza %d."
645
 
646
- #: classes/shipping_method.php:439
647
  #, php-format
648
  msgid "Value value %s is not valid number. Row number %d."
649
  msgstr "Wartość w polu Wartość %s jest niepoprawna. Numer wiersza %d."
650
 
651
- #: classes/shipping_method.php:491
652
  #, php-format
653
  msgid "Shipping method %s imported as %s."
654
  msgstr "Metoda wysyłki %s została zaimportowana jako %s."
655
 
656
- #: classes/shipping_method.php:551
657
  msgid "New Shipping Method"
658
  msgstr "Nowa metoda wysyłki"
659
 
660
- #: classes/shipping_method.php:554
661
  msgid "Edit Shipping Method"
662
  msgstr "Edytuj metodę wysyłki"
663
 
664
- #: classes/shipping_method.php:564 classes/shipping_method.php:606
665
  #, php-format
666
  msgid "Shipping method %s added."
667
  msgstr "Metoda wysyłki dodana: %s."
668
 
669
- #: classes/shipping_method.php:589
670
  #, php-format
671
  msgid "Shipping method %s deleted."
672
  msgstr "Metoda wysyłki usunięta: %s."
673
 
674
- #: classes/shipping_method.php:592
675
  msgid "Shipping method not found."
676
  msgstr "Metoda wysyłki nie znaleziona."
677
 
678
- #: classes/shipping_method.php:618
679
  #, php-format
680
  msgid "Shipping method %s updated."
681
  msgstr "Metoda wysyłki zaktualizowana: %s."
682
 
683
- #: classes/tracker.php:178
684
  msgid "Opt-in"
685
  msgstr "Opt-in"
686
 
687
- #: classes/tracker.php:182
688
  msgid "Opt-out"
689
  msgstr "Opt-out"
690
 
@@ -701,28 +734,22 @@ msgid "Product count based costs"
701
  msgstr "Koszty oparte o liczbę produktów w koszyku"
702
 
703
  #: classes/views/html-ads.php:15
704
- msgid "Stopping a rule"
705
- msgstr "Zatrzymywanie reguł"
706
 
707
  #: classes/views/html-ads.php:16
708
- msgid "Cancelling a rule"
709
- msgstr "Anulowanie reguł"
710
-
711
- #: classes/views/html-ads.php:17
712
- msgid "Additional calculation methods (sum, lowest cost, highest cost)"
713
- msgstr ""
714
- "Dodatkowe rodzaje obliczania kosztów (suma, najniższy, najwyższy koszt reguł "
715
- "spełniających warunki)"
716
 
717
- #: classes/views/html-ads.php:20
718
  msgid "Upgrade Now &rarr;"
719
  msgstr "Zaktualizuj do wersji PRO &rarr;"
720
 
721
- #: classes/views/html-column-shipping-shipping.php:11
722
  msgid "Get label for: "
723
  msgstr "Pobierz etykietę dla "
724
 
725
- #: classes/views/html-column-shipping-shipping.php:14
726
  msgid "Track shipment for: "
727
  msgstr "Śledź przesyłkę "
728
 
@@ -739,6 +766,55 @@ msgstr "Wszystkie przesyłki"
739
  msgid "Shipment status"
740
  msgstr "Status przesyłki"
741
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
742
  #: classes/views/html-shipping-method-rules.php:8
743
  msgid "Price"
744
  msgstr "Cena"
@@ -770,16 +846,28 @@ msgid "Min"
770
  msgstr "Min"
771
 
772
  #: classes/views/html-shipping-method-rules.php:78
773
- msgid "Enter minimum value for the &quot;Based on&quot; parameter."
774
- msgstr "Wpisz minimalną wartość dla parametru &quot;Oparte na&quot;."
 
 
 
 
 
 
775
 
776
  #: classes/views/html-shipping-method-rules.php:81
777
  msgid "Max"
778
  msgstr "Max"
779
 
780
  #: classes/views/html-shipping-method-rules.php:82
781
- msgid "Enter maximum value for the &quot;Based on&quot; parameter."
782
- msgstr "Wpisz maksymalną wartość dla parametru &quot;Oparte na&quot;."
 
 
 
 
 
 
783
 
784
  #: classes/views/html-shipping-method-rules.php:85
785
  msgid "Cost per<br/>order"
@@ -861,38 +949,78 @@ msgstr "Proszę wybrać metody wysyłki do usunięcia"
861
  msgid "Select file to import"
862
  msgstr "Wybierz plik do importu"
863
 
864
- #: flexible-shipping.php:463
 
865
  msgid ""
866
- "Flexible Shipping requires at least version 2.7 of Active Payments plugin."
 
867
  msgstr ""
868
- "Flexible Shipping wymaga wtyczki Aktywne płatności w wersji co najmniej 2.7."
 
869
 
870
- #: flexible-shipping.php:474
871
- msgid "Flexible Shipping requires at least version 1.2 of eNadawca plugin."
872
- msgstr "Flexible Shipping wymaga wtyczki eNadawca w wersji co najmniej 1.2."
 
 
 
 
 
873
 
874
- #: flexible-shipping.php:485
 
875
  msgid ""
876
- "Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin."
 
877
  msgstr ""
878
- "Flexible Shipping wymaga wtyczki Paczka w Ruchu w wersji co najmniej 1.1."
 
879
 
880
- #: flexible-shipping.php:493
881
  #, php-format
882
  msgid ""
883
- "You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it "
884
- "on %splugins page%s. Read about big changes in Flexible Shipping on %sour "
885
- "blog →%s"
886
  msgstr ""
887
- "Masz włączony WooCommerce Flexible Shipping w wersji starszej niż 1.4. "
888
- "Wyłącz go na %sstronie wtyczek%s. Przeczytaj o dużej zmianie we Flexible "
889
- "Shipping na %snaszym blogu →%s"
890
 
891
- #: flexible-shipping.php:549
892
- msgid "Upgrade"
893
- msgstr "Kup PRO"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
894
 
895
- #: flexible-shipping.php:674
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
896
  #, php-format
897
  msgid "Redirecting. If page not redirects click %s here %s."
898
  msgstr ""
@@ -978,7 +1106,7 @@ msgid ""
978
  " If you have a moment, please let us know why you are deactivating plugin "
979
  "(anonymous feedback):"
980
  msgstr ""
981
- "Jeśli masz chwilę, prosimy daj nam znać dlaczego dezaktywowałeś wtyczkę "
982
  "(anonimowa opinia):"
983
 
984
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:16
@@ -1007,7 +1135,7 @@ msgstr "Nie potrzebuję już wtyczki"
1007
 
1008
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:59
1009
  msgid "It's a temporary deactivation. I'm just debugging an issue."
1010
- msgstr "Jest to tymczasowa dezaktywacja, debaguję problem"
1011
 
1012
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:67
1013
  msgid "Other"
@@ -1079,6 +1207,36 @@ msgstr "WP Desk"
1079
  msgid "https://www.wpdesk.net/"
1080
  msgstr "https://www.wpdesk.pl/"
1081
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1082
  #~ msgid ""
1083
  #~ "Please help us improve our plugins and get a <strong>20&#37; discount "
1084
  #~ "coupon</strong> for <strong>WP Desk</strong> plugins."
@@ -1106,9 +1264,6 @@ msgstr "https://www.wpdesk.pl/"
1106
  #~ msgid "Free shipment label"
1107
  #~ msgstr "Etykieta darmowej wysyłki"
1108
 
1109
- #~ msgid "Calculation method"
1110
- #~ msgstr "Metoda obliczania"
1111
-
1112
  #~ msgid "Free shipment"
1113
  #~ msgstr "Darmowa wysyłka"
1114
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Flexible Shipping\n"
4
+ "POT-Creation-Date: 2018-04-25 09:36+0200\n"
5
+ "PO-Revision-Date: 2018-04-25 09:37+0200\n"
6
  "Last-Translator: Piotr Jabłonowski <piotr.jablonowski@wpdesk.net>\n"
7
  "Language-Team: Maciej Swoboda <maciej.swoboda@gmail.com>\n"
8
  "Language: pl_PL\n"
9
  "MIME-Version: 1.0\n"
10
  "Content-Type: text/plain; charset=UTF-8\n"
11
  "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 2.0.6\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "X-Poedit-WPHeader: flexible-shipping.php\n"
15
  "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 "
20
  "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
21
  "X-Poedit-SearchPath-0: .\n"
22
  "X-Poedit-SearchPathExcluded-0: *.js\n"
23
+ "X-Poedit-SearchPathExcluded-1: classes/wpdesk/settings-api\n"
24
+
25
+ #: classes/admin-notices.php:164
26
+ #, php-format
27
+ msgid ""
28
+ "Flexible Shipping has changed the calculation method for shipping rules. "
29
+ "Currently, the cart value for rules based on price is determined by "
30
+ "WooCommerce tax option \"Display prices during cart and checkout\". You "
31
+ "should check the %ssettings%s."
32
+ msgstr ""
33
+ "Flexible Shipping: zaktualizowane zostały metody obliczania reguł wysyłki. "
34
+ "Aktualnie dla reguł opartych na cenie wartość koszyka zostanie obliczona na "
35
+ "podstawie ustawienia podatków WooCommerce ”Wyświetlanie cen w sklepie”. "
36
+ "Sprawdź %sstawienia podatków%s."
37
+
38
+ #: classes/admin-notices.php:181
39
+ msgid ""
40
+ "Flexible Shipping requires at least version 2.7 of Active Payments plugin."
41
+ msgstr ""
42
+ "Flexible Shipping wymaga wtyczki Aktywne płatności w wersji co najmniej 2.7."
43
+
44
+ #: classes/admin-notices.php:196
45
+ msgid "Flexible Shipping requires at least version 1.2 of eNadawca plugin."
46
+ msgstr "Flexible Shipping wymaga wtyczki eNadawca w wersji co najmniej 1.2."
47
+
48
+ #: classes/admin-notices.php:211
49
+ msgid ""
50
+ "Flexible Shipping requires at least version 1.1 of Paczka w Ruchu plugin."
51
+ msgstr ""
52
+ "Flexible Shipping wymaga wtyczki Paczka w Ruchu w wersji co najmniej 1.1."
53
+
54
+ #: classes/admin-notices.php:223
55
+ #, php-format
56
+ msgid ""
57
+ "You are using WooCommerce Flexible Shipping below 1.4. Please deactivate it "
58
+ "on %splugins page%s. Read about big changes in Flexible Shipping on %sour "
59
+ "blog →%s"
60
+ msgstr ""
61
+ "Masz włączony WooCommerce Flexible Shipping w wersji starszej niż 1.4. "
62
+ "Wyłącz go na %sstronie wtyczek%s. Przeczytaj o dużej zmianie we Flexible "
63
+ "Shipping na %snaszym blogu →%s"
64
 
65
  #: classes/bulk-actions.php:46
66
  msgid "New"
175
  msgid "Bulk shipping manifest - processed orders: %d"
176
  msgstr "Zbiorcze tworzenie protokołów nadania - przetworzone zamówienia: %d"
177
 
178
+ #: classes/flexible-shipping-plugin.php:257 classes/wpdesk/class-plugin.php:267
 
 
 
 
 
 
 
 
 
 
 
 
179
  msgid "Settings"
180
  msgstr "Ustawienia"
181
 
182
+ #: classes/flexible-shipping-plugin.php:258 classes/wpdesk/class-plugin.php:260
183
  msgid "Docs"
184
  msgstr "Docs"
185
 
186
+ #: classes/flexible-shipping-plugin.php:259 classes/wpdesk/class-plugin.php:254
187
  msgid "Support"
188
  msgstr "Wsparcie"
189
 
190
+ #: classes/flexible-shipping-plugin.php:265
191
+ msgid "Upgrade"
192
+ msgstr "Kup PRO"
193
+
194
  #: classes/manifest/cpt-shipping-manifest.php:60
195
  #: classes/manifest/cpt-shipping-manifest.php:62
196
  #: classes/manifest/cpt-shipping-manifest.php:64
250
 
251
  #: classes/manifest/cpt-shipping-manifest.php:161
252
  #: classes/manifest/views/filter-form.php:5
253
+ #: classes/settings/shipping-method-form.php:115
254
  #: classes/views/html-orders-filter-form.php:5
255
  #: classes/views/html-shipping-method-settings.php:15
256
  msgid "Integration"
303
  msgid "Order"
304
  msgstr "Zamówienie"
305
 
306
+ #. Plugin Name of the plugin/theme
307
+ #: classes/multilingual.php:44 classes/multilingual.php:47
308
+ #: classes/multilingual.php:50 classes/settings/flexible-shipping.php:16
309
+ #: classes/settings/flexible-shipping.php:30
310
+ #: classes/settings/shipping-method-form.php:57
311
+ #: classes/shipping-method-info.php:20 classes/shipping-method.php:24
312
+ #: classes/shipping-method.php:25 classes/shipping-method.php:43
313
+ msgid "Flexible Shipping"
314
+ msgstr "Flexible Shipping"
315
+
316
  #: classes/order-add-shipping.php:30 classes/shipment/functions.php:23
317
  #, php-format
318
  msgid "Shipment for order %s, %s"
331
  msgid "Add shipping"
332
  msgstr "Dodaj przesyłkę"
333
 
334
+ #: classes/settings/flexible-shipping.php:18
 
 
 
 
 
 
 
 
 
 
335
  #, php-format
336
  msgid "See how to %sconfigure Flexible Shipping%s."
337
  msgstr "Zobacz jak %sskonfigurować Flexible Shipping%s."
338
 
339
+ #: classes/settings/flexible-shipping.php:21
340
+ #: classes/settings/shipping-method-form.php:48 classes/shipping-method.php:34
341
  msgid "Enable/Disable"
342
  msgstr "Włącz/Wyłącz"
343
 
344
+ #: classes/settings/flexible-shipping.php:23
345
  msgid "Enable Flexible Shipping"
346
  msgstr "Włącz Flexible Shipping"
347
 
348
+ #: classes/settings/flexible-shipping.php:27
349
  msgid "Shipping title"
350
  msgstr "Tytuł"
351
 
352
+ #: classes/settings/flexible-shipping.php:29
353
  msgid "Visible only to admin in WooCommerce settings."
354
  msgstr "Widoczny tylko dla admina w ustawieniach WooCommerce."
355
 
356
+ #: classes/settings/flexible-shipping.php:34
357
  msgid "Tax Status"
358
  msgstr "Status podatku"
359
 
360
+ #: classes/settings/flexible-shipping.php:39
361
  msgid "Taxable"
362
  msgstr "Opodatkowany"
363
 
364
+ #: classes/settings/flexible-shipping.php:40
365
  msgctxt "Tax status"
366
  msgid "None"
367
  msgstr "Brak"
368
 
369
+ #: classes/settings/flexible-shipping.php:44
370
+ #: classes/settings/flexible-shipping.php:49
371
  msgid "Shipping Methods"
372
  msgstr "Metody wysyłki"
373
 
374
+ #: classes/settings/shipping-method-form.php:10
375
  msgid "Select shipment class"
376
  msgstr "Wybierz klasę wysyłkową"
377
 
378
+ #: classes/settings/shipping-method-form.php:19
379
  msgid ""
380
  "Integrate with DPD, DHL, InPost, eNadawca Poczta Polska, Paczka w Ruchu."
381
  msgstr "Zintegruj z DPD, DHL, InPost, eNadawca Poczta Polska, Paczka w Ruchu."
382
 
383
+ #: classes/settings/shipping-method-form.php:19
384
  #, php-format
385
  msgid "%sAdd integrations%s"
386
  msgstr "%sDodaj integracje%s"
387
 
388
+ #: classes/settings/shipping-method-form.php:22
389
  msgid "Integrate with DPD."
390
  msgstr "Zintegruj z DPD."
391
 
392
+ #: classes/settings/shipping-method-form.php:22
393
  #, php-format
394
  msgid "%sAdd integration%s"
395
  msgstr "%sDodaj integrację%s"
396
 
397
+ #: classes/settings/shipping-method-form.php:32 classes/shipping-method.php:879
398
  msgid "Free"
399
  msgstr "Bezpłatnie"
400
 
401
+ #: classes/settings/shipping-method-form.php:51 classes/shipping-method.php:36
402
  msgid "Enable this shipment method"
403
  msgstr "Włącz tę metodę wysyłki"
404
 
405
+ #: classes/settings/shipping-method-form.php:54
406
  msgid "Method Title"
407
  msgstr "Tytuł metody"
408
 
409
+ #: classes/settings/shipping-method-form.php:56 classes/shipping-method.php:42
410
  msgid "This controls the title which the user sees during checkout."
411
  msgstr "Tytuł, który widzi użytkownik podczas składania zamówienia."
412
 
413
+ #: classes/settings/shipping-method-form.php:63
414
  msgid "Method Description"
415
  msgstr "Opis"
416
 
417
+ #: classes/settings/shipping-method-form.php:65
418
  msgid "This controls method description which the user sees during checkout."
419
  msgstr "Opis, który widzi użytkownik podczas składania zamówienia."
420
 
421
+ #: classes/settings/shipping-method-form.php:76
422
  msgid "Free Shipping"
423
  msgstr "Darmowa wysyłka"
424
 
425
+ #: classes/settings/shipping-method-form.php:79
426
  msgid ""
427
  "Enter a minimum order amount for free shipment. This will override the costs "
428
  "configured below."
430
  "Wpisz minimalną kwotę zamówienia dla bezpłatnej wysyłki. Spowoduje to "
431
  "zastąpienie reguł skonfigurowanych poniżej."
432
 
433
+ #: classes/settings/shipping-method-form.php:83
434
  msgid "Free Shipping Label"
435
  msgstr "Etykieta darmowej wysyłki"
436
 
437
+ #: classes/settings/shipping-method-form.php:86
438
  msgid "Enter additional label for shipment when free shipment available."
439
  msgstr ""
440
  "Wpisz dodatkową etykietę, która zostanie wyświetlona dla darmowej wysyłki."
441
 
442
+ #: classes/settings/shipping-method-form.php:95
443
  msgid "Calculation Method"
444
  msgstr "Metoda obliczania"
445
 
446
+ #: classes/settings/shipping-method-form.php:97
447
  msgid ""
448
  "Select how rules will be calculated. If you choose \"sum\" the rules order "
449
  "is important."
450
  msgstr ""
451
  "Wybierz jak będą obliczane reguły. Dla sumy, kolejność reguł ma znaczenie."
452
 
453
+ #: classes/settings/shipping-method-form.php:100
454
  msgid "Sum"
455
  msgstr "Suma"
456
 
457
+ #: classes/settings/shipping-method-form.php:103
458
  #: classes/views/html-shipping-method-settings.php:13
459
  msgid "Visibility"
460
  msgstr "Wyświetlanie"
461
 
462
+ #: classes/settings/shipping-method-form.php:106
463
  #: classes/views/html-shipping-method-settings.php:46
464
  msgid "Show only for logged in users"
465
  msgstr "Pokaż tylko dla zalogowanych użytkowników"
466
 
467
+ #: classes/settings/shipping-method-form.php:109
468
  #: classes/views/html-shipping-method-settings.php:14
469
  msgid "Default"
470
  msgstr "Domyślnie"
471
 
472
+ #: classes/settings/shipping-method-form.php:112
473
  msgid ""
474
  "Check the box to set this option as the default selected choice on the cart "
475
  "page."
477
  "Zaznacz, aby ustawić tę metodę wysyłki jako domyślną przy składaniu "
478
  "zamówienia."
479
 
480
+ #: classes/settings/shipping-method-form.php:117
481
  msgid "Select integration. "
482
  msgstr "Wybierz integrację. "
483
 
484
+ #: classes/settings/shipping-method-form.php:120
485
  #: classes/views/html-shipping-method-rules.php:7
486
  msgid "None"
487
  msgstr "Brak"
488
 
489
+ #: classes/settings/shipping-method-form.php:131
490
  msgid "Rules"
491
  msgstr "Reguły"
492
 
493
+ #: classes/settings/shipping-method-form.php:152
494
  msgid "Shipping Zone"
495
  msgstr "Strefa wysyłki"
496
 
497
+ #: classes/settings/shipping-method-form.php:166
498
  #, php-format
499
  msgid "See how to %sconfigure shipment methods%s."
500
  msgstr "Zobacz jak %sskonfigurować metody wysyłki %s."
616
  msgid "Shipment data"
617
  msgstr "Dane przesyłki"
618
 
619
+ #: classes/shipping-method.php:40
620
  msgid "Shipping Title"
621
  msgstr "Tytuł"
622
 
623
+ #: classes/shipping-method.php:112
624
  #: classes/views/html-shipping-method-rules.php:241
625
  msgid "Add New"
626
  msgstr "Dodaj nową"
627
 
628
+ #: classes/shipping-method.php:347
629
  msgid ""
630
  "Sorry, there has been an error. The CSV is invalid or incorrect file type."
631
  msgstr ""
632
  "Przepraszamy, wystąpił błąd. Plik CSV jest niepoprawny lub typ pliku jest "
633
  "nieprawidłowy."
634
 
635
+ #: classes/shipping-method.php:357 classes/shipping-method.php:360
636
  msgid "import"
637
  msgstr "import"
638
 
639
+ #: classes/shipping-method.php:369
640
  #, php-format
641
  msgid "Free Shipping value %s is not valid number. Row number %d."
642
  msgstr "Wartość darmowej wysyłki %s jest niepoprawna. Numer wiersza %d."
643
 
644
+ #: classes/shipping-method.php:375
645
  #, php-format
646
  msgid "Maximum Cost value %s is not valid number. Row number %d."
647
  msgstr "Maksymalny koszt %s jest niepoprawny. Numer wiersza %d."
648
 
649
+ #: classes/shipping-method.php:386
650
  #, php-format
651
  msgid "Invalid value for Calculation Method in row number %d."
652
  msgstr "Nieprawidłowa wartość dla Metody obliczania w wierszu %d."
653
 
654
+ #: classes/shipping-method.php:410
655
  #, php-format
656
  msgid "Invalid value for Based On in row number %d."
657
  msgstr "Nieprawidłowa wartość dla Oparte na w wierszu %d."
658
 
659
+ #: classes/shipping-method.php:415
660
  #, php-format
661
  msgid "Min value %s is not valid number. Row number %d."
662
  msgstr "Wartość Min %s jest niepoprawna. Numer wiersza %d."
663
 
664
+ #: classes/shipping-method.php:421
665
  #, php-format
666
  msgid "Max value %s is not valid number. Row number %d."
667
  msgstr "Wartość Maks %s jest niepoprawna. Numer wiersza %d."
668
 
669
+ #: classes/shipping-method.php:427
670
  #, php-format
671
  msgid "Cost per order value %s is not valid number. Row number %d."
672
  msgstr "Wartość Koszt na zamówienie %s jest niepoprawna. Numer wiersza %d."
673
 
674
+ #: classes/shipping-method.php:433
675
  #, php-format
676
  msgid "Additional cost value %s is not valid number. Row number %d."
677
  msgstr "Wartość Dodatkowy koszt %s jest niepoprawna. Numer wiersza %d."
678
 
679
+ #: classes/shipping-method.php:439
680
  #, php-format
681
  msgid "Value value %s is not valid number. Row number %d."
682
  msgstr "Wartość w polu Wartość %s jest niepoprawna. Numer wiersza %d."
683
 
684
+ #: classes/shipping-method.php:491
685
  #, php-format
686
  msgid "Shipping method %s imported as %s."
687
  msgstr "Metoda wysyłki %s została zaimportowana jako %s."
688
 
689
+ #: classes/shipping-method.php:551
690
  msgid "New Shipping Method"
691
  msgstr "Nowa metoda wysyłki"
692
 
693
+ #: classes/shipping-method.php:554
694
  msgid "Edit Shipping Method"
695
  msgstr "Edytuj metodę wysyłki"
696
 
697
+ #: classes/shipping-method.php:564 classes/shipping-method.php:606
698
  #, php-format
699
  msgid "Shipping method %s added."
700
  msgstr "Metoda wysyłki dodana: %s."
701
 
702
+ #: classes/shipping-method.php:589
703
  #, php-format
704
  msgid "Shipping method %s deleted."
705
  msgstr "Metoda wysyłki usunięta: %s."
706
 
707
+ #: classes/shipping-method.php:592
708
  msgid "Shipping method not found."
709
  msgstr "Metoda wysyłki nie znaleziona."
710
 
711
+ #: classes/shipping-method.php:618
712
  #, php-format
713
  msgid "Shipping method %s updated."
714
  msgstr "Metoda wysyłki zaktualizowana: %s."
715
 
716
+ #: classes/tracker.php:181
717
  msgid "Opt-in"
718
  msgstr "Opt-in"
719
 
720
+ #: classes/tracker.php:185
721
  msgid "Opt-out"
722
  msgstr "Opt-out"
723
 
734
  msgstr "Koszty oparte o liczbę produktów w koszyku"
735
 
736
  #: classes/views/html-ads.php:15
737
+ msgid "Stopping, Cancelling a rule"
738
+ msgstr "Zatrzymywanie, anulowanie reguł"
739
 
740
  #: classes/views/html-ads.php:16
741
+ msgid "Additional calculation methods"
742
+ msgstr "Dodatkowe rodzaje obliczania kosztów"
 
 
 
 
 
 
743
 
744
+ #: classes/views/html-ads.php:19
745
  msgid "Upgrade Now &rarr;"
746
  msgstr "Zaktualizuj do wersji PRO &rarr;"
747
 
748
+ #: classes/views/html-column-shipping-shipping.php:14
749
  msgid "Get label for: "
750
  msgstr "Pobierz etykietę dla "
751
 
752
+ #: classes/views/html-column-shipping-shipping.php:17
753
  msgid "Track shipment for: "
754
  msgstr "Śledź przesyłkę "
755
 
766
  msgid "Shipment status"
767
  msgstr "Status przesyłki"
768
 
769
+ #: classes/views/html-shipping-method-info-description.php:19
770
+ #, php-format
771
+ msgid ""
772
+ "To add first Flexible Shipping method go to %sShipping zones%s and add "
773
+ "Flexible Shipping to a shipping zone."
774
+ msgstr ""
775
+ "Aby dodać pierwszą metodę Flexible Shipping przejdź do zakładki %sStrefy "
776
+ "wysyłki%s i dodaj Flexible Shipping do strefy wysyłki."
777
+
778
+ #: classes/views/html-shipping-method-info-description.php:26
779
+ msgid ""
780
+ "You can start the configuration by clicking the Flexible Shipping link in "
781
+ "the Shipping methods table."
782
+ msgstr ""
783
+ "Możesz rozpocząć konfigurację klikając na link Flexible Shipping w tabeli "
784
+ "”Metody wysyłki”."
785
+
786
+ #: classes/views/html-shipping-method-info-description.php:29
787
+ msgid "Quick Video Overview"
788
+ msgstr "Krótki przewodnik video"
789
+
790
+ #: classes/views/html-shipping-method-info-description.php:40
791
+ msgid "More resources"
792
+ msgstr "Więcej informacji"
793
+
794
+ #: classes/views/html-shipping-method-info-description.php:44
795
+ msgid "General Settings"
796
+ msgstr "Ustawienia główne"
797
+
798
+ #: classes/views/html-shipping-method-info-description.php:45
799
+ msgid "Adding a shipping method"
800
+ msgstr "Dodawanie metody wysyłki"
801
+
802
+ #: classes/views/html-shipping-method-info-description.php:46
803
+ msgid "Currency Support"
804
+ msgstr "Waluty"
805
+
806
+ #: classes/views/html-shipping-method-info-description.php:47
807
+ msgid "Weight Based Shipping"
808
+ msgstr "Koszt na wagę"
809
+
810
+ #: classes/views/html-shipping-method-info-description.php:48
811
+ msgid "Shipping Insurance"
812
+ msgstr "Ubezpieczenie przesyłki"
813
+
814
+ #: classes/views/html-shipping-method-info-description.php:49
815
+ msgid "Conditional Cash on Delivery"
816
+ msgstr "Przesyłka za pobraniem"
817
+
818
  #: classes/views/html-shipping-method-rules.php:8
819
  msgid "Price"
820
  msgstr "Cena"
846
  msgstr "Min"
847
 
848
  #: classes/views/html-shipping-method-rules.php:78
849
+ msgid ""
850
+ "Enter minimum value for the &quot;Based on&quot; parameter. Value based on "
851
+ "the price will be calculated by WooCommerce tax settings &quot;Display "
852
+ "prices during cart and checkout&quot;"
853
+ msgstr ""
854
+ "Wpisz minimalną wartość dla parametru &quot;Oparte na&quot;. Wartość oparta "
855
+ "na cenie zostanie obliczona wg. ustawienia podatków WooCommerce &quot;"
856
+ "Wyświetlanie cen w koszyku i zamówieniu&quot;"
857
 
858
  #: classes/views/html-shipping-method-rules.php:81
859
  msgid "Max"
860
  msgstr "Max"
861
 
862
  #: classes/views/html-shipping-method-rules.php:82
863
+ msgid ""
864
+ "Enter maximum value for the &quot;Based on&quot; parameter. Value based on "
865
+ "the price will be calculated by WooCommerce tax settings &quot;Display "
866
+ "prices during cart and checkout&quot;"
867
+ msgstr ""
868
+ "Wpisz maksymalną wartość dla parametru &quot;Oparte na&quot;. Wartość oparta "
869
+ "na cenie zostanie obliczona wg. ustawienia podatków WooCommerce &quot;"
870
+ "Wyświetlanie cen w koszyku i zamówieniu&quot;"
871
 
872
  #: classes/views/html-shipping-method-rules.php:85
873
  msgid "Cost per<br/>order"
949
  msgid "Select file to import"
950
  msgstr "Wybierz plik do importu"
951
 
952
+ #: classes/wpdesk/class-helper.php:52
953
+ #, php-format
954
  msgid ""
955
+ "The %s%s%s License Key has not been activated, so the plugin is inactive! "
956
+ "%sClick here%s to activate the license key and the plugin."
957
  msgstr ""
958
+ "Klucz licencyjny wtyczki %s%s%s nie został aktywowany, więc wtyczka jest "
959
+ "nieaktywna! %sKliknij tutaj%s, aby aktywować klucz licencyjny wtyczki."
960
 
961
+ #: classes/wpdesk/class-requirement-checker.php:185
962
+ #, php-format
963
+ msgid ""
964
+ "The &#8220;%s&#8221; plugin cannot run on PHP versions older than %s. Please "
965
+ "contact your host and ask them to upgrade."
966
+ msgstr ""
967
+ "Wtyczka &#8220;%s&#8221; nie może działać w wersjach PHP starszych niż %s. "
968
+ "Skontaktuj się z administratorem hostingu i poproś o aktualizację."
969
 
970
+ #: classes/wpdesk/class-requirement-checker.php:188
971
+ #, php-format
972
  msgid ""
973
+ "The &#8220;%s&#8221; plugin cannot run on WordPress versions older than %s. "
974
+ "Please update WordPress."
975
  msgstr ""
976
+ "Wtyczka &#8220;%s&#8221; nie może działać w wersjach WordPress starszych niż "
977
+ "%s. Prosimy o aktualizację WordPress."
978
 
979
+ #: classes/wpdesk/class-requirement-checker.php:191
980
  #, php-format
981
  msgid ""
982
+ "The &#8220;%s&#8221; plugin cannot run on WooCommerce versions older than "
983
+ "%s. Please update WooCommerce."
 
984
  msgstr ""
985
+ "Wtyczka &#8220;%s&#8221; nie może działać w wersjach WooCommerce starszych "
986
+ "niż %s. Prosimy o aktualizację WooCommerce."
 
987
 
988
+ #: classes/wpdesk/class-requirement-checker.php:209
989
+ #, php-format
990
+ msgid ""
991
+ "The &#8220;%s&#8221; plugin cannot run without %s php module installed. "
992
+ "Please contact your host and ask them to install %s."
993
+ msgstr ""
994
+ "Wtyczka &#8220;%s&#8221; nie może działać bez modułu php: %s. Skontaktuj się "
995
+ "z administratorem hostingu i poproś o instalację %s."
996
+
997
+ #: classes/wpdesk/class-requirement-checker.php:226
998
+ #, php-format
999
+ msgid ""
1000
+ "The &#8220;%s&#8221; plugin cannot run without %s php setting set to %s. "
1001
+ "Please contact your host and ask them to set %s."
1002
+ msgstr ""
1003
+ "Wtyczka &#8220;%s&#8221; nie może działać bez ustawienia php %s ustawionego "
1004
+ "na %s. Skontaktuj się z administratorem hostingu i poproś o ustawienie %s."
1005
 
1006
+ #: classes/wpdesk/class-requirement-checker.php:243
1007
+ #, php-format
1008
+ msgid ""
1009
+ "The &#8220;%s&#8221; plugin cannot run without %s active. Please install and "
1010
+ "activate %s plugin."
1011
+ msgstr ""
1012
+ "Wtyczka &#8220;%s&#8221; nie może działać bez aktywacji %s. Zainstaluj i "
1013
+ "aktywuj wtyczkę %s."
1014
+
1015
+ #: classes/wpdesk/class-settings.php:106
1016
+ msgid "Insert Image"
1017
+ msgstr "Wstaw obrazek"
1018
+
1019
+ #: classes/wpdesk/class-settings.php:107
1020
+ msgid "Select Image"
1021
+ msgstr "Wybierz obrazek"
1022
+
1023
+ #: inc/functions.php:67
1024
  #, php-format
1025
  msgid "Redirecting. If page not redirects click %s here %s."
1026
  msgstr ""
1106
  " If you have a moment, please let us know why you are deactivating plugin "
1107
  "(anonymous feedback):"
1108
  msgstr ""
1109
+ " Jeśli masz chwilę, prosimy daj nam znać dlaczego dezaktywowałeś wtyczkę "
1110
  "(anonimowa opinia):"
1111
 
1112
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:16
1135
 
1136
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:59
1137
  msgid "It's a temporary deactivation. I'm just debugging an issue."
1138
+ msgstr "Jest to tymczasowa dezaktywacja, debaguję problem."
1139
 
1140
  #: inc/wpdesk-tracker/views/tracker-deactivate.php:67
1141
  msgid "Other"
1207
  msgid "https://www.wpdesk.net/"
1208
  msgstr "https://www.wpdesk.pl/"
1209
 
1210
+ #~ msgid "Stopping a rule"
1211
+ #~ msgstr "Zatrzymywanie reguł"
1212
+
1213
+ #~ msgid "Additional calculation methods (sum, lowest cost, highest cost)"
1214
+ #~ msgstr ""
1215
+ #~ "Dodatkowe rodzaje obliczania kosztów (suma, najniższy, najwyższy koszt "
1216
+ #~ "reguł spełniających warunki)"
1217
+
1218
+ #~ msgid "Enter minimum value for the &quot;Based on&quot; parameter."
1219
+ #~ msgstr "Wpisz minimalną wartość dla parametru &quot;Oparte na&quot;."
1220
+
1221
+ #~ msgid "Enter maximum value for the &quot;Based on&quot; parameter."
1222
+ #~ msgstr "Wpisz maksymalną wartość dla parametru &quot;Oparte na&quot;."
1223
+
1224
+ #, fuzzy
1225
+ #~| msgid "Settings"
1226
+ #~ msgid "Settings updated."
1227
+ #~ msgstr "Ustawienia"
1228
+
1229
+ #~ msgid ""
1230
+ #~ "An Unexpected HTTP Error occurred during the API request. <a href=\"?\" "
1231
+ #~ "onclick=\"document.location.reload(); return false;\">Try again</a>"
1232
+ #~ msgstr ""
1233
+ #~ "Wystąpił nieoczekiwany błąd HTTP podczas zapytania API.</p> <p><a "
1234
+ #~ "href=„?” onclick=„document.location.reload(); return false;”>Spróbuj "
1235
+ #~ "ponownie</a>"
1236
+
1237
+ #~ msgid "An unknown error occurred"
1238
+ #~ msgstr "Wystąpił nieznany błąd"
1239
+
1240
  #~ msgid ""
1241
  #~ "Please help us improve our plugins and get a <strong>20&#37; discount "
1242
  #~ "coupon</strong> for <strong>WP Desk</strong> plugins."
1264
  #~ msgid "Free shipment label"
1265
  #~ msgstr "Etykieta darmowej wysyłki"
1266
 
 
 
 
1267
  #~ msgid "Free shipment"
1268
  #~ msgstr "Darmowa wysyłka"
1269
 
readme.md ADDED
@@ -0,0 +1,2 @@
 
 
1
+ [![pipeline status](https://gitlab.com/wpdesk/flexible-shipping/badges/master/pipeline.svg)](https://gitlab.com/wpdesk/flexible-shipping/commits/master)
2
+
readme.txt CHANGED
@@ -3,9 +3,9 @@ Contributors: wpdesk, swoboda
3
  Donate link: https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/
4
  Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
5
  Requires at least: 4.5
6
- Tested up to: 4.9.4
7
- Stable tag: 2.0.1
8
- Requires PHP: 5.3
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
@@ -113,6 +113,12 @@ There are several integrations that we provide for Flexible Shipping in Poland:
113
  * WooCommerce Currency Switcher
114
  * WPML
115
 
 
 
 
 
 
 
116
  = Flexible Shipping in a nutshell =
117
 
118
  Key features:
@@ -165,6 +171,12 @@ If you are upgrading from the old Flexible Shipping version (1.3.2, woo-flexible
165
 
166
  == Changelog ==
167
 
 
 
 
 
 
 
168
  = 2.0.1 - 2018-03-01 =
169
  * Fixed problems with deactivation plugin on multisite
170
  * Fixed WP Desk Tracker warning after enabling the plugin
3
  Donate link: https://www.wpdesk.net/products/flexible-shipping-pro-woocommerce/
4
  Tags: table rate, table rate shipping, woocommerce shipping, flexible shipping, woocommerce table rate shipping, cart based shipping, weight shipping, weight based shipping, totals based shipping, order based shipping, shipping zones, shipping classes
5
  Requires at least: 4.5
6
+ Tested up to: 4.9.5
7
+ Stable tag: 2.1
8
+ Requires PHP: 5.5
9
  License: GPLv3 or later
10
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
11
 
113
  * WooCommerce Currency Switcher
114
  * WPML
115
 
116
+ = Translations =
117
+
118
+ * English - default, always included
119
+ * Polish
120
+ * German by [jensratzel](https://profiles.wordpress.org/jensratzel/)
121
+
122
  = Flexible Shipping in a nutshell =
123
 
124
  Key features:
171
 
172
  == Changelog ==
173
 
174
+ = 2.1 - 2018-05-07 =
175
+ * Added Flexible Shipping tab on WooCommerce Shipping
176
+ * Tweaked calculation method for shipping rules - based on WooCommerce tax display
177
+ * Fixed display printer name on order edit
178
+ * Fixed notice after all rules delete
179
+
180
  = 2.0.1 - 2018-03-01 =
181
  * Fixed problems with deactivation plugin on multisite
182
  * Fixed WP Desk Tracker warning after enabling the plugin
vendor/autoload.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload.php @generated by Composer
4
+
5
+ require_once __DIR__ . '/composer/autoload_real.php';
6
+
7
+ return ComposerAutoloaderInit23647a3460d57690a4c19a9b5812d13b::getLoader();
vendor/composer/ClassLoader.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * This file is part of Composer.
5
+ *
6
+ * (c) Nils Adermann <naderman@naderman.de>
7
+ * Jordi Boggiano <j.boggiano@seld.be>
8
+ *
9
+ * For the full copyright and license information, please view the LICENSE
10
+ * file that was distributed with this source code.
11
+ */
12
+
13
+ namespace Composer\Autoload;
14
+
15
+ /**
16
+ * ClassLoader implements a PSR-0, PSR-4 and classmap class loader.
17
+ *
18
+ * $loader = new \Composer\Autoload\ClassLoader();
19
+ *
20
+ * // register classes with namespaces
21
+ * $loader->add('Symfony\Component', __DIR__.'/component');
22
+ * $loader->add('Symfony', __DIR__.'/framework');
23
+ *
24
+ * // activate the autoloader
25
+ * $loader->register();
26
+ *
27
+ * // to enable searching the include path (eg. for PEAR packages)
28
+ * $loader->setUseIncludePath(true);
29
+ *
30
+ * In this example, if you try to use a class in the Symfony\Component
31
+ * namespace or one of its children (Symfony\Component\Console for instance),
32
+ * the autoloader will first look for the class under the component/
33
+ * directory, and it will then fallback to the framework/ directory if not
34
+ * found before giving up.
35
+ *
36
+ * This class is loosely based on the Symfony UniversalClassLoader.
37
+ *
38
+ * @author Fabien Potencier <fabien@symfony.com>
39
+ * @author Jordi Boggiano <j.boggiano@seld.be>
40
+ * @see http://www.php-fig.org/psr/psr-0/
41
+ * @see http://www.php-fig.org/psr/psr-4/
42
+ */
43
+ class ClassLoader
44
+ {
45
+ // PSR-4
46
+ private $prefixLengthsPsr4 = array();
47
+ private $prefixDirsPsr4 = array();
48
+ private $fallbackDirsPsr4 = array();
49
+
50
+ // PSR-0
51
+ private $prefixesPsr0 = array();
52
+ private $fallbackDirsPsr0 = array();
53
+
54
+ private $useIncludePath = false;
55
+ private $classMap = array();
56
+ private $classMapAuthoritative = false;
57
+ private $missingClasses = array();
58
+ private $apcuPrefix;
59
+
60
+ public function getPrefixes()
61
+ {
62
+ if (!empty($this->prefixesPsr0)) {
63
+ return call_user_func_array('array_merge', $this->prefixesPsr0);
64
+ }
65
+
66
+ return array();
67
+ }
68
+
69
+ public function getPrefixesPsr4()
70
+ {
71
+ return $this->prefixDirsPsr4;
72
+ }
73
+
74
+ public function getFallbackDirs()
75
+ {
76
+ return $this->fallbackDirsPsr0;
77
+ }
78
+
79
+ public function getFallbackDirsPsr4()
80
+ {
81
+ return $this->fallbackDirsPsr4;
82
+ }
83
+
84
+ public function getClassMap()
85
+ {
86
+ return $this->classMap;
87
+ }
88
+
89
+ /**
90
+ * @param array $classMap Class to filename map
91
+ */
92
+ public function addClassMap(array $classMap)
93
+ {
94
+ if ($this->classMap) {
95
+ $this->classMap = array_merge($this->classMap, $classMap);
96
+ } else {
97
+ $this->classMap = $classMap;
98
+ }
99
+ }
100
+
101
+ /**
102
+ * Registers a set of PSR-0 directories for a given prefix, either
103
+ * appending or prepending to the ones previously set for this prefix.
104
+ *
105
+ * @param string $prefix The prefix
106
+ * @param array|string $paths The PSR-0 root directories
107
+ * @param bool $prepend Whether to prepend the directories
108
+ */
109
+ public function add($prefix, $paths, $prepend = false)
110
+ {
111
+ if (!$prefix) {
112
+ if ($prepend) {
113
+ $this->fallbackDirsPsr0 = array_merge(
114
+ (array) $paths,
115
+ $this->fallbackDirsPsr0
116
+ );
117
+ } else {
118
+ $this->fallbackDirsPsr0 = array_merge(
119
+ $this->fallbackDirsPsr0,
120
+ (array) $paths
121
+ );
122
+ }
123
+
124
+ return;
125
+ }
126
+
127
+ $first = $prefix[0];
128
+ if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
+ $this->prefixesPsr0[$first][$prefix] = (array) $paths;
130
+
131
+ return;
132
+ }
133
+ if ($prepend) {
134
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
135
+ (array) $paths,
136
+ $this->prefixesPsr0[$first][$prefix]
137
+ );
138
+ } else {
139
+ $this->prefixesPsr0[$first][$prefix] = array_merge(
140
+ $this->prefixesPsr0[$first][$prefix],
141
+ (array) $paths
142
+ );
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Registers a set of PSR-4 directories for a given namespace, either
148
+ * appending or prepending to the ones previously set for this namespace.
149
+ *
150
+ * @param string $prefix The prefix/namespace, with trailing '\\'
151
+ * @param array|string $paths The PSR-4 base directories
152
+ * @param bool $prepend Whether to prepend the directories
153
+ *
154
+ * @throws \InvalidArgumentException
155
+ */
156
+ public function addPsr4($prefix, $paths, $prepend = false)
157
+ {
158
+ if (!$prefix) {
159
+ // Register directories for the root namespace.
160
+ if ($prepend) {
161
+ $this->fallbackDirsPsr4 = array_merge(
162
+ (array) $paths,
163
+ $this->fallbackDirsPsr4
164
+ );
165
+ } else {
166
+ $this->fallbackDirsPsr4 = array_merge(
167
+ $this->fallbackDirsPsr4,
168
+ (array) $paths
169
+ );
170
+ }
171
+ } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
172
+ // Register directories for a new namespace.
173
+ $length = strlen($prefix);
174
+ if ('\\' !== $prefix[$length - 1]) {
175
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176
+ }
177
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
179
+ } elseif ($prepend) {
180
+ // Prepend directories for an already registered namespace.
181
+ $this->prefixDirsPsr4[$prefix] = array_merge(
182
+ (array) $paths,
183
+ $this->prefixDirsPsr4[$prefix]
184
+ );
185
+ } else {
186
+ // Append directories for an already registered namespace.
187
+ $this->prefixDirsPsr4[$prefix] = array_merge(
188
+ $this->prefixDirsPsr4[$prefix],
189
+ (array) $paths
190
+ );
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Registers a set of PSR-0 directories for a given prefix,
196
+ * replacing any others previously set for this prefix.
197
+ *
198
+ * @param string $prefix The prefix
199
+ * @param array|string $paths The PSR-0 base directories
200
+ */
201
+ public function set($prefix, $paths)
202
+ {
203
+ if (!$prefix) {
204
+ $this->fallbackDirsPsr0 = (array) $paths;
205
+ } else {
206
+ $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * Registers a set of PSR-4 directories for a given namespace,
212
+ * replacing any others previously set for this namespace.
213
+ *
214
+ * @param string $prefix The prefix/namespace, with trailing '\\'
215
+ * @param array|string $paths The PSR-4 base directories
216
+ *
217
+ * @throws \InvalidArgumentException
218
+ */
219
+ public function setPsr4($prefix, $paths)
220
+ {
221
+ if (!$prefix) {
222
+ $this->fallbackDirsPsr4 = (array) $paths;
223
+ } else {
224
+ $length = strlen($prefix);
225
+ if ('\\' !== $prefix[$length - 1]) {
226
+ throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227
+ }
228
+ $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
+ $this->prefixDirsPsr4[$prefix] = (array) $paths;
230
+ }
231
+ }
232
+
233
+ /**
234
+ * Turns on searching the include path for class files.
235
+ *
236
+ * @param bool $useIncludePath
237
+ */
238
+ public function setUseIncludePath($useIncludePath)
239
+ {
240
+ $this->useIncludePath = $useIncludePath;
241
+ }
242
+
243
+ /**
244
+ * Can be used to check if the autoloader uses the include path to check
245
+ * for classes.
246
+ *
247
+ * @return bool
248
+ */
249
+ public function getUseIncludePath()
250
+ {
251
+ return $this->useIncludePath;
252
+ }
253
+
254
+ /**
255
+ * Turns off searching the prefix and fallback directories for classes
256
+ * that have not been registered with the class map.
257
+ *
258
+ * @param bool $classMapAuthoritative
259
+ */
260
+ public function setClassMapAuthoritative($classMapAuthoritative)
261
+ {
262
+ $this->classMapAuthoritative = $classMapAuthoritative;
263
+ }
264
+
265
+ /**
266
+ * Should class lookup fail if not found in the current class map?
267
+ *
268
+ * @return bool
269
+ */
270
+ public function isClassMapAuthoritative()
271
+ {
272
+ return $this->classMapAuthoritative;
273
+ }
274
+
275
+ /**
276
+ * APCu prefix to use to cache found/not-found classes, if the extension is enabled.
277
+ *
278
+ * @param string|null $apcuPrefix
279
+ */
280
+ public function setApcuPrefix($apcuPrefix)
281
+ {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
+ }
284
+
285
+ /**
286
+ * The APCu prefix in use, or null if APCu caching is not enabled.
287
+ *
288
+ * @return string|null
289
+ */
290
+ public function getApcuPrefix()
291
+ {
292
+ return $this->apcuPrefix;
293
+ }
294
+
295
+ /**
296
+ * Registers this instance as an autoloader.
297
+ *
298
+ * @param bool $prepend Whether to prepend the autoloader or not
299
+ */
300
+ public function register($prepend = false)
301
+ {
302
+ spl_autoload_register(array($this, 'loadClass'), true, $prepend);
303
+ }
304
+
305
+ /**
306
+ * Unregisters this instance as an autoloader.
307
+ */
308
+ public function unregister()
309
+ {
310
+ spl_autoload_unregister(array($this, 'loadClass'));
311
+ }
312
+
313
+ /**
314
+ * Loads the given class or interface.
315
+ *
316
+ * @param string $class The name of the class
317
+ * @return bool|null True if loaded, null otherwise
318
+ */
319
+ public function loadClass($class)
320
+ {
321
+ if ($file = $this->findFile($class)) {
322
+ includeFile($file);
323
+
324
+ return true;
325
+ }
326
+ }
327
+
328
+ /**
329
+ * Finds the path to the file where the class is defined.
330
+ *
331
+ * @param string $class The name of the class
332
+ *
333
+ * @return string|false The path if found, false otherwise
334
+ */
335
+ public function findFile($class)
336
+ {
337
+ // class map lookup
338
+ if (isset($this->classMap[$class])) {
339
+ return $this->classMap[$class];
340
+ }
341
+ if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) {
342
+ return false;
343
+ }
344
+ if (null !== $this->apcuPrefix) {
345
+ $file = apcu_fetch($this->apcuPrefix.$class, $hit);
346
+ if ($hit) {
347
+ return $file;
348
+ }
349
+ }
350
+
351
+ $file = $this->findFileWithExtension($class, '.php');
352
+
353
+ // Search for Hack files if we are running on HHVM
354
+ if (false === $file && defined('HHVM_VERSION')) {
355
+ $file = $this->findFileWithExtension($class, '.hh');
356
+ }
357
+
358
+ if (null !== $this->apcuPrefix) {
359
+ apcu_add($this->apcuPrefix.$class, $file);
360
+ }
361
+
362
+ if (false === $file) {
363
+ // Remember that this class does not exist.
364
+ $this->missingClasses[$class] = true;
365
+ }
366
+
367
+ return $file;
368
+ }
369
+
370
+ private function findFileWithExtension($class, $ext)
371
+ {
372
+ // PSR-4 lookup
373
+ $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext;
374
+
375
+ $first = $class[0];
376
+ if (isset($this->prefixLengthsPsr4[$first])) {
377
+ $subPath = $class;
378
+ while (false !== $lastPos = strrpos($subPath, '\\')) {
379
+ $subPath = substr($subPath, 0, $lastPos);
380
+ $search = $subPath.'\\';
381
+ if (isset($this->prefixDirsPsr4[$search])) {
382
+ $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1);
383
+ foreach ($this->prefixDirsPsr4[$search] as $dir) {
384
+ if (file_exists($file = $dir . $pathEnd)) {
385
+ return $file;
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+
392
+ // PSR-4 fallback dirs
393
+ foreach ($this->fallbackDirsPsr4 as $dir) {
394
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) {
395
+ return $file;
396
+ }
397
+ }
398
+
399
+ // PSR-0 lookup
400
+ if (false !== $pos = strrpos($class, '\\')) {
401
+ // namespaced class name
402
+ $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1)
403
+ . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR);
404
+ } else {
405
+ // PEAR-like class name
406
+ $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext;
407
+ }
408
+
409
+ if (isset($this->prefixesPsr0[$first])) {
410
+ foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) {
411
+ if (0 === strpos($class, $prefix)) {
412
+ foreach ($dirs as $dir) {
413
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
414
+ return $file;
415
+ }
416
+ }
417
+ }
418
+ }
419
+ }
420
+
421
+ // PSR-0 fallback dirs
422
+ foreach ($this->fallbackDirsPsr0 as $dir) {
423
+ if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) {
424
+ return $file;
425
+ }
426
+ }
427
+
428
+ // PSR-0 include paths.
429
+ if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) {
430
+ return $file;
431
+ }
432
+
433
+ return false;
434
+ }
435
+ }
436
+
437
+ /**
438
+ * Scope isolated include.
439
+ *
440
+ * Prevents access to $this/self from included files.
441
+ */
442
+ function includeFile($file)
443
+ {
444
+ include $file;
445
+ }
vendor/composer/LICENSE ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Copyright (c) Nils Adermann, Jordi Boggiano
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is furnished
9
+ to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
21
+
vendor/composer/autoload_classmap.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_classmap.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_namespaces.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_namespaces.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_psr4.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_psr4.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ );
vendor/composer/autoload_real.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_real.php @generated by Composer
4
+
5
+ class ComposerAutoloaderInit23647a3460d57690a4c19a9b5812d13b
6
+ {
7
+ private static $loader;
8
+
9
+ public static function loadClassLoader($class)
10
+ {
11
+ if ('Composer\Autoload\ClassLoader' === $class) {
12
+ require __DIR__ . '/ClassLoader.php';
13
+ }
14
+ }
15
+
16
+ public static function getLoader()
17
+ {
18
+ if (null !== self::$loader) {
19
+ return self::$loader;
20
+ }
21
+
22
+ spl_autoload_register(array('ComposerAutoloaderInit23647a3460d57690a4c19a9b5812d13b', 'loadClassLoader'), true, true);
23
+ self::$loader = $loader = new \Composer\Autoload\ClassLoader();
24
+ spl_autoload_unregister(array('ComposerAutoloaderInit23647a3460d57690a4c19a9b5812d13b', 'loadClassLoader'));
25
+
26
+ $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
27
+ if ($useStaticLoader) {
28
+ require_once __DIR__ . '/autoload_static.php';
29
+
30
+ call_user_func(\Composer\Autoload\ComposerStaticInit23647a3460d57690a4c19a9b5812d13b::getInitializer($loader));
31
+ } else {
32
+ $map = require __DIR__ . '/autoload_namespaces.php';
33
+ foreach ($map as $namespace => $path) {
34
+ $loader->set($namespace, $path);
35
+ }
36
+
37
+ $map = require __DIR__ . '/autoload_psr4.php';
38
+ foreach ($map as $namespace => $path) {
39
+ $loader->setPsr4($namespace, $path);
40
+ }
41
+
42
+ $classMap = require __DIR__ . '/autoload_classmap.php';
43
+ if ($classMap) {
44
+ $loader->addClassMap($classMap);
45
+ }
46
+ }
47
+
48
+ $loader->register(true);
49
+
50
+ return $loader;
51
+ }
52
+ }
vendor/composer/autoload_static.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_static.php @generated by Composer
4
+
5
+ namespace Composer\Autoload;
6
+
7
+ class ComposerStaticInit23647a3460d57690a4c19a9b5812d13b
8
+ {
9
+ public static function getInitializer(ClassLoader $loader)
10
+ {
11
+ return \Closure::bind(function () use ($loader) {
12
+
13
+ }, null, ClassLoader::class);
14
+ }
15
+ }
vendor/composer/installed.json ADDED
@@ -0,0 +1 @@
 
1
+ []