Discount Rules for WooCommerce - Version 1.7.19

Version Description

  • 26/08/19 =
  • Feature - Option to do strikeout on change quantity in product page.
  • Feature - Option to display strikeout on after a rule condition is matched in product page.
  • Fix - Validation issue in woocommerce v2.x on saving BOGO Rule.
  • Fix - Not applying discount for decimal values less than 1 in cart rules.
  • Fix - Wrong strikeout price for variable product on set option apply discount from regular price.
  • Fix - Not displaying price display suffix when disable strikeout option and enable sale option.
  • Improvement - Event apply_filters('woo_discount_rules_remove_event_woocommerce_cart_loaded_from_session', false).
  • Improvement - Update checker update to make compatible with PHP 7.x
Download this release

Release Info

Developer flycart
Plugin Icon 128x128 Discount Rules for WooCommerce
Version 1.7.19
Comparing to
See all releases

Code changes from version 1.7.18 to 1.7.19

Files changed (80) hide show
  1. assets/js/app.js +9 -7
  2. assets/js/woo_discount_rules.js +64 -0
  3. helper/general-helper.php +32 -0
  4. i18n/languages/woo-discount-rules.pot +87 -53
  5. includes/cart-rules.php +2 -2
  6. includes/discount-base.php +2 -2
  7. includes/pricing-rules.php +115 -27
  8. loader.php +60 -4
  9. readme.txt +11 -1
  10. vendor/composer/ClassLoader.php +9 -5
  11. vendor/composer/autoload_files.php +10 -0
  12. vendor/composer/autoload_real.php +18 -0
  13. vendor/composer/autoload_static.php +4 -0
  14. vendor/composer/installed.json +47 -42
  15. vendor/yahnis-elsts/plugin-update-checker/.editorconfig +15 -0
  16. vendor/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php +2 -261
  17. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Autoloader.php +49 -0
  18. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Extension.php +177 -0
  19. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Panel.php +165 -0
  20. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginExtension.php +33 -0
  21. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginPanel.php +38 -0
  22. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/ThemePanel.php +21 -0
  23. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Factory.php +297 -0
  24. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/InstalledPackage.php +103 -0
  25. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Metadata.php +132 -0
  26. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/OAuthSignature.php +100 -0
  27. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Info.php +134 -0
  28. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Package.php +184 -0
  29. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php +277 -0
  30. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Update.php +110 -0
  31. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/UpdateChecker.php +396 -0
  32. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Scheduler.php +231 -0
  33. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/StateStore.php +207 -0
  34. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Package.php +65 -0
  35. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Update.php +84 -0
  36. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/UpdateChecker.php +142 -0
  37. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Update.php +34 -0
  38. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpdateChecker.php +926 -0
  39. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpgraderStatus.php +199 -0
  40. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Utils.php +69 -0
  41. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Api.php +302 -0
  42. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BaseChecker.php +27 -0
  43. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BitBucketApi.php +265 -0
  44. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitHubApi.php +413 -0
  45. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitLabApi.php +297 -0
  46. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/PluginUpdateChecker.php +213 -0
  47. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Reference.php +49 -0
  48. vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/ThemeUpdateChecker.php +118 -0
  49. vendor/yahnis-elsts/plugin-update-checker/README.md +73 -4
  50. vendor/yahnis-elsts/plugin-update-checker/composer.json +22 -19
  51. vendor/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css +9 -1
  52. vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json +5 -0
  53. vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js +1 -1
  54. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo +0 -0
  55. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po +45 -0
  56. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.mo +0 -0
  57. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.po +42 -0
  58. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo +0 -0
  59. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.po +48 -0
  60. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo +0 -0
  61. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.po +21 -17
  62. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.mo +0 -0
  63. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.po +42 -0
  64. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo +0 -0
  65. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.po +48 -0
  66. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo +0 -0
  67. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.po +48 -0
  68. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo +0 -0
  69. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.po +48 -0
  70. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo +0 -0
  71. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.po +48 -0
  72. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo +0 -0
  73. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.po +42 -0
  74. vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot +22 -12
  75. vendor/yahnis-elsts/plugin-update-checker/license.txt +2 -2
  76. vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php +25 -12
  77. vendor/yahnis-elsts/plugin-update-checker/vendor/ParsedownLegacy.php +1 -2
  78. vendor/yahnis-elsts/plugin-update-checker/vendor/readme-parser.php +15 -8
  79. view/settings_price_rules.php +7 -1
  80. woo-discount-rules.php +2 -2
assets/js/app.js CHANGED
@@ -71,13 +71,15 @@ function validateWDRBOGOFields(){
71
  }
72
  }
73
  //discount_category_option_list_con
74
- if(jQuery.inArray(discount_product_option.val(), ['all', 'any_cheapest', 'more_than_one_cheapest']) !== -1){
75
- var product_field = jQuery(container).find('select.wc-product-search');
76
- if(product_field.val() == '' || product_field.val() == null){
77
- jQuery(container).find('.select2-selection').addClass('wdr_invalid');
78
- returnValue = false;
79
- } else {
80
- jQuery(container).find('.select2-selection').removeClass('wdr_invalid');
 
 
81
  }
82
  }
83
 
71
  }
72
  }
73
  //discount_category_option_list_con
74
+ if(parseInt(jQuery('#flycart_wdr_woocommerce_version').val()) > 2){
75
+ if(jQuery.inArray(discount_product_option.val(), ['all', 'any_cheapest', 'more_than_one_cheapest']) !== -1){
76
+ var product_field = jQuery(container).find('select.wc-product-search');
77
+ if(product_field.val() == '' || product_field.val() == null){
78
+ jQuery(container).find('.select2-selection').addClass('wdr_invalid');
79
+ returnValue = false;
80
+ } else {
81
+ jQuery(container).find('.select2-selection').removeClass('wdr_invalid');
82
+ }
83
  }
84
  }
85
 
assets/js/woo_discount_rules.js CHANGED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ jQuery( document ).ready( function() {
3
+ jQuery(document).on('change', 'input[name="quantity"]', function () {
4
+ if(woo_discount_rules.show_product_strikeout == undefined){
5
+ return false;
6
+ }
7
+ if(woo_discount_rules.show_product_strikeout !== 'show_on_qty_update'){
8
+ return false;
9
+ }
10
+ var form = jQuery(this).closest('form');
11
+ if(form.length){
12
+ var btn = form.find("button[name='add-to-cart']");
13
+ var product_id = null;
14
+ var current_object = jQuery(this);
15
+ var quantity = jQuery(this).val();
16
+ var target = jQuery(this).closest('.summary').find('.price');
17
+ if(btn.length && parseInt(btn.val()) > 0){
18
+ product_id = btn.val();
19
+ if(!target.length){
20
+ target = null;
21
+ }
22
+ } else {
23
+ var input_product_id = input_variation_id = null;
24
+ if(jQuery('input[name="product_id"]').length){
25
+ var input_product_id = form.find('input[name="product_id"]');
26
+ }
27
+ if(jQuery('input[name="variation_id"]').length){
28
+ var input_variation_id = form.find('input[name="variation_id"]');
29
+ }
30
+
31
+ if(input_product_id !== null){
32
+ product_id = input_product_id.val();
33
+ }
34
+ if(input_variation_id !== null){
35
+ product_id = input_variation_id.val();
36
+ target = form.find(".woocommerce-variation-price");
37
+ }
38
+ }
39
+ if(parseInt(product_id) > 0){
40
+ jQuery.ajax({
41
+ url: woo_discount_rules.ajax_url,
42
+ dataType: "json",
43
+ type: "POST",
44
+ data: {action: "loadWooDiscountStrikeoutPriceOfProduct", id: product_id, qty: quantity, price_html: ''},
45
+ beforeSend: function() {
46
+ },
47
+ complete: function() {
48
+ },
49
+ success: function (response) {
50
+ if(response.status == 1){
51
+ if(target !== null){
52
+ target.html(response.price_html);
53
+ }
54
+ }
55
+ current_object.trigger("woo_discount_rules_after_display_strikeout_price_on_quantity_update");
56
+ }
57
+ });
58
+ }
59
+ }
60
+ });
61
+ jQuery( ".single_variation_wrap" ).on( "show_variation, woo_discount_rules_after_variant_strikeout", function ( event, variation ) {
62
+ jQuery(this).closest('form').find('input[name="quantity"]').trigger('change');
63
+ });
64
+ });
helper/general-helper.php CHANGED
@@ -940,5 +940,37 @@ if ( ! class_exists( 'FlycartWooDiscountRulesGeneralHelper' ) ) {
940
 
941
  return $user_email;
942
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
943
  }
944
  }
940
 
941
  return $user_email;
942
  }
943
+
944
+ /**
945
+ * Add a quantity for product strikeout
946
+ *
947
+ * @return boolean
948
+ * */
949
+ public static function addAQuantityForProductStrikeOut(){
950
+ $config = FlycartWooDiscountBase::get_instance();
951
+ $show_price_discount = $config->getConfigData('show_price_discount_on_product_page', 'show');
952
+ $add = true;
953
+ if($show_price_discount == 'show_after_rule_matches'){
954
+ $add = false;
955
+ }
956
+
957
+ return $add;
958
+ }
959
+
960
+ /**
961
+ * Show discount on product page
962
+ *
963
+ * @return boolean
964
+ * */
965
+ public static function showDiscountOnProductPage(){
966
+ $config = FlycartWooDiscountBase::get_instance();
967
+ $show_price_discount = $config->getConfigData('show_price_discount_on_product_page', 'show');
968
+ $show = false;
969
+ if(in_array($show_price_discount, array('show', 'show_after_rule_matches', 'show_on_qty_update'))){
970
+ $show = true;
971
+ }
972
+
973
+ return $show;
974
+ }
975
  }
976
  }
i18n/languages/woo-discount-rules.pot CHANGED
@@ -150,7 +150,7 @@ msgstr ""
150
 
151
  #: includes/discount-base.php:196 view/cart-rules.php:149
152
  #: view/pricing-rules.php:179 view/settings_cart_rules.php:95
153
- #: view/settings_cart_rules.php:102 view/settings_price_rules.php:163
154
  #: view/settings_promotion.php:22 view/settings_promotion.php:62
155
  #: view/settings_promotion.php:97
156
  msgid "Disabled"
@@ -583,9 +583,9 @@ msgstr ""
583
  msgid "In each category"
584
  msgstr ""
585
 
586
- #: includes/discount-base.php:1086 view/settings_price_rules.php:128
587
- #: view/settings_price_rules.php:202 view/settings_price_rules.php:220
588
- #: view/settings_price_rules.php:238 view/settings_price_rules.php:256
589
  msgid "Show"
590
  msgstr ""
591
 
@@ -643,95 +643,117 @@ msgstr ""
643
  msgid "Settings"
644
  msgstr ""
645
 
646
- #: includes/pricing-rules.php:2836 view/view-pricing-rules.php:568
647
  msgid "Buy"
648
  msgstr ""
649
 
650
- #: includes/pricing-rules.php:2840
651
  msgid " less than or equal to "
652
  msgstr ""
653
 
654
- #: includes/pricing-rules.php:2840 includes/pricing-rules.php:2846
655
  msgid " Quantity"
656
  msgstr ""
657
 
658
- #: includes/pricing-rules.php:2843
659
  msgid " Quantity "
660
  msgstr ""
661
 
662
- #: includes/pricing-rules.php:2850
663
  msgid " or more Quantity"
664
  msgstr ""
665
 
666
- #: includes/pricing-rules.php:2859
667
  msgid " any "
668
  msgstr ""
669
 
670
- #: includes/pricing-rules.php:2859
671
  msgid " products from "
672
  msgstr ""
673
 
674
- #: includes/pricing-rules.php:2866
675
  msgid " in each products"
676
  msgstr ""
677
 
678
- #: includes/pricing-rules.php:2878
679
  msgid " and get discount in "
680
  msgstr ""
681
 
682
- #: includes/pricing-rules.php:2881
683
  msgid " first "
684
  msgstr ""
685
 
686
- #: includes/pricing-rules.php:2883 includes/pricing-rules.php:2887
687
  msgid " quantity of product(s) - "
688
  msgstr ""
689
 
690
- #: includes/pricing-rules.php:2885
691
  msgid " after first "
692
  msgstr ""
693
 
694
- #: includes/pricing-rules.php:2903
695
  msgid "Category(ies) "
696
  msgstr ""
697
 
698
- #: includes/pricing-rules.php:2971
699
  msgid "Get "
700
  msgstr ""
701
 
702
- #: includes/pricing-rules.php:2973
703
  #, php-format
704
  msgid "% discount in "
705
  msgstr ""
706
 
707
- #: includes/pricing-rules.php:2976
708
  msgid "same product"
709
  msgstr ""
710
 
711
- #: includes/pricing-rules.php:2978
712
  msgid "any cheapest one from cart"
713
  msgstr ""
714
 
715
- #: includes/pricing-rules.php:2981
716
  msgid "any cheapest one of "
717
  msgstr ""
718
 
719
- #: includes/pricing-rules.php:2986
720
  msgid " quantity of any "
721
  msgstr ""
722
 
723
- #: includes/pricing-rules.php:2988
724
  msgid " cheapest item "
725
  msgstr ""
726
 
727
- #: includes/pricing-rules.php:2991
728
  msgid " quantity of cheapest item "
729
  msgstr ""
730
 
731
- #: includes/pricing-rules.php:2995
732
  msgid "from the category "
733
  msgstr ""
734
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
735
  #: view/cart-rules.php:48
736
  msgid "Cart Rules"
737
  msgstr ""
@@ -1058,7 +1080,7 @@ msgstr ""
1058
  msgid "Enable free shipping option"
1059
  msgstr ""
1060
 
1061
- #: view/settings_cart_rules.php:92 view/settings_price_rules.php:307
1062
  #: view/view-pricing-rules.php:300 view/view-pricing-rules.php:357
1063
  #: view/view-pricing-rules.php:427 view/view-pricing-rules.php:475
1064
  #: view/view-pricing-rules.php:504
@@ -1116,14 +1138,14 @@ msgstr ""
1116
  #: view/settings_general.php:57 view/settings_general.php:74
1117
  #: view/settings_general.php:108 view/settings_performance.php:21
1118
  #: view/settings_price_rules.php:86 view/settings_price_rules.php:98
1119
- #: view/settings_price_rules.php:110 view/settings_price_rules.php:145
1120
  msgid "Yes"
1121
  msgstr ""
1122
 
1123
  #: view/settings_general.php:58 view/settings_general.php:75
1124
  #: view/settings_general.php:109 view/settings_performance.php:22
1125
  #: view/settings_price_rules.php:87 view/settings_price_rules.php:99
1126
- #: view/settings_price_rules.php:111 view/settings_price_rules.php:146
1127
  msgid "No"
1128
  msgstr ""
1129
 
@@ -1234,101 +1256,113 @@ msgstr ""
1234
  msgid "Show Price discount on product pages :"
1235
  msgstr ""
1236
 
1237
- #: view/settings_price_rules.php:131 view/settings_price_rules.php:205
1238
- #: view/settings_price_rules.php:223 view/settings_price_rules.php:241
1239
- #: view/settings_price_rules.php:259
 
 
 
 
 
 
 
 
 
 
 
 
1240
  msgid "Don't Show"
1241
  msgstr ""
1242
 
1243
- #: view/settings_price_rules.php:140
1244
  msgid ""
1245
  "Show a crossed-out original price along with discounted price at line items "
1246
  "in cart"
1247
  msgstr ""
1248
 
1249
- #: view/settings_price_rules.php:157
1250
  msgid "Discount Table :"
1251
  msgstr ""
1252
 
1253
- #: view/settings_price_rules.php:166
1254
  msgid "Default layout"
1255
  msgstr ""
1256
 
1257
- #: view/settings_price_rules.php:169
1258
  msgid "Advance layout"
1259
  msgstr ""
1260
 
1261
- #: view/settings_price_rules.php:178
1262
  msgid "Table placement:"
1263
  msgstr ""
1264
 
1265
- #: view/settings_price_rules.php:184
1266
  msgid "Before cart form"
1267
  msgstr ""
1268
 
1269
- #: view/settings_price_rules.php:187
1270
  msgid "After cart form"
1271
  msgstr ""
1272
 
1273
- #: view/settings_price_rules.php:196
1274
  msgid "Table header :"
1275
  msgstr ""
1276
 
1277
- #: view/settings_price_rules.php:214
1278
  msgid "Title column on table :"
1279
  msgstr ""
1280
 
1281
- #: view/settings_price_rules.php:232
1282
  msgid "Range column on table :"
1283
  msgstr ""
1284
 
1285
- #: view/settings_price_rules.php:250
1286
  msgid "Discount column on table :"
1287
  msgstr ""
1288
 
1289
- #: view/settings_price_rules.php:272
1290
  msgid "Show a Sale badge on product pages :"
1291
  msgstr ""
1292
 
1293
- #: view/settings_price_rules.php:278
1294
  msgid "Do not show"
1295
  msgstr ""
1296
 
1297
- #: view/settings_price_rules.php:281
1298
  msgid "Show only after a rule condition is matched exactly"
1299
  msgstr ""
1300
 
1301
- #: view/settings_price_rules.php:284
1302
  msgid ""
1303
  "Show on products that are covered under any price based discount rule in the "
1304
  "plugin"
1305
  msgstr ""
1306
 
1307
- #: view/settings_price_rules.php:295
1308
  msgid "Do you want to customize the sale badge?"
1309
  msgstr ""
1310
 
1311
- #: view/settings_price_rules.php:302
1312
  msgid "Yes, I would like to customize the sale badge"
1313
  msgstr ""
1314
 
1315
- #: view/settings_price_rules.php:304
1316
  msgid ""
1317
  "Force override the label for sale badge (useful when your theme has override "
1318
  "for sale badge)."
1319
  msgstr ""
1320
 
1321
- #: view/settings_price_rules.php:319
1322
  msgid "Sale badge content (TIP: You can use HTML inside)"
1323
  msgstr ""
1324
 
1325
- #: view/settings_price_rules.php:326
1326
  msgid ""
1327
  "IMPORTANT NOTE: This customized sale badge will be applicable only for "
1328
  "products that are part of the discount rules configured in this plugin"
1329
  msgstr ""
1330
 
1331
- #: view/settings_price_rules.php:330
1332
  msgid "Eg:"
1333
  msgstr ""
1334
 
150
 
151
  #: includes/discount-base.php:196 view/cart-rules.php:149
152
  #: view/pricing-rules.php:179 view/settings_cart_rules.php:95
153
+ #: view/settings_cart_rules.php:102 view/settings_price_rules.php:169
154
  #: view/settings_promotion.php:22 view/settings_promotion.php:62
155
  #: view/settings_promotion.php:97
156
  msgid "Disabled"
583
  msgid "In each category"
584
  msgstr ""
585
 
586
+ #: includes/discount-base.php:1086 view/settings_price_rules.php:208
587
+ #: view/settings_price_rules.php:226 view/settings_price_rules.php:244
588
+ #: view/settings_price_rules.php:262
589
  msgid "Show"
590
  msgstr ""
591
 
643
  msgid "Settings"
644
  msgstr ""
645
 
646
+ #: includes/pricing-rules.php:2859 view/view-pricing-rules.php:568
647
  msgid "Buy"
648
  msgstr ""
649
 
650
+ #: includes/pricing-rules.php:2863
651
  msgid " less than or equal to "
652
  msgstr ""
653
 
654
+ #: includes/pricing-rules.php:2863 includes/pricing-rules.php:2869
655
  msgid " Quantity"
656
  msgstr ""
657
 
658
+ #: includes/pricing-rules.php:2866
659
  msgid " Quantity "
660
  msgstr ""
661
 
662
+ #: includes/pricing-rules.php:2873
663
  msgid " or more Quantity"
664
  msgstr ""
665
 
666
+ #: includes/pricing-rules.php:2882
667
  msgid " any "
668
  msgstr ""
669
 
670
+ #: includes/pricing-rules.php:2882
671
  msgid " products from "
672
  msgstr ""
673
 
674
+ #: includes/pricing-rules.php:2889
675
  msgid " in each products"
676
  msgstr ""
677
 
678
+ #: includes/pricing-rules.php:2901
679
  msgid " and get discount in "
680
  msgstr ""
681
 
682
+ #: includes/pricing-rules.php:2904
683
  msgid " first "
684
  msgstr ""
685
 
686
+ #: includes/pricing-rules.php:2906 includes/pricing-rules.php:2910
687
  msgid " quantity of product(s) - "
688
  msgstr ""
689
 
690
+ #: includes/pricing-rules.php:2908
691
  msgid " after first "
692
  msgstr ""
693
 
694
+ #: includes/pricing-rules.php:2926
695
  msgid "Category(ies) "
696
  msgstr ""
697
 
698
+ #: includes/pricing-rules.php:2994
699
  msgid "Get "
700
  msgstr ""
701
 
702
+ #: includes/pricing-rules.php:2996
703
  #, php-format
704
  msgid "% discount in "
705
  msgstr ""
706
 
707
+ #: includes/pricing-rules.php:2999
708
  msgid "same product"
709
  msgstr ""
710
 
711
+ #: includes/pricing-rules.php:3001
712
  msgid "any cheapest one from cart"
713
  msgstr ""
714
 
715
+ #: includes/pricing-rules.php:3004
716
  msgid "any cheapest one of "
717
  msgstr ""
718
 
719
+ #: includes/pricing-rules.php:3009
720
  msgid " quantity of any "
721
  msgstr ""
722
 
723
+ #: includes/pricing-rules.php:3011
724
  msgid " cheapest item "
725
  msgstr ""
726
 
727
+ #: includes/pricing-rules.php:3014
728
  msgid " quantity of cheapest item "
729
  msgstr ""
730
 
731
+ #: includes/pricing-rules.php:3018
732
  msgid "from the category "
733
  msgstr ""
734
 
735
+ #: vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php:54
736
+ msgid "View details"
737
+ msgstr ""
738
+
739
+ #: vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php:77
740
+ #, php-format
741
+ msgid "More information about %s"
742
+ msgstr ""
743
+
744
+ #: vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php:128
745
+ msgid "Check for updates"
746
+ msgstr ""
747
+
748
+ #: vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php:223
749
+ #, php-format
750
+ msgid "Unknown update checker status \"%s\""
751
+ msgstr ""
752
+
753
+ #: vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/PluginUpdateChecker.php:98
754
+ msgid "There is no changelog available."
755
+ msgstr ""
756
+
757
  #: view/cart-rules.php:48
758
  msgid "Cart Rules"
759
  msgstr ""
1080
  msgid "Enable free shipping option"
1081
  msgstr ""
1082
 
1083
+ #: view/settings_cart_rules.php:92 view/settings_price_rules.php:313
1084
  #: view/view-pricing-rules.php:300 view/view-pricing-rules.php:357
1085
  #: view/view-pricing-rules.php:427 view/view-pricing-rules.php:475
1086
  #: view/view-pricing-rules.php:504
1138
  #: view/settings_general.php:57 view/settings_general.php:74
1139
  #: view/settings_general.php:108 view/settings_performance.php:21
1140
  #: view/settings_price_rules.php:86 view/settings_price_rules.php:98
1141
+ #: view/settings_price_rules.php:110 view/settings_price_rules.php:151
1142
  msgid "Yes"
1143
  msgstr ""
1144
 
1145
  #: view/settings_general.php:58 view/settings_general.php:75
1146
  #: view/settings_general.php:109 view/settings_performance.php:22
1147
  #: view/settings_price_rules.php:87 view/settings_price_rules.php:99
1148
+ #: view/settings_price_rules.php:111 view/settings_price_rules.php:152
1149
  msgid "No"
1150
  msgstr ""
1151
 
1256
  msgid "Show Price discount on product pages :"
1257
  msgstr ""
1258
 
1259
+ #: view/settings_price_rules.php:128
1260
+ msgid "Show when a rule condition is matched"
1261
+ msgstr ""
1262
+
1263
+ #: view/settings_price_rules.php:131
1264
+ msgid "Show after a rule condition is matched"
1265
+ msgstr ""
1266
+
1267
+ #: view/settings_price_rules.php:134
1268
+ msgid "Shown on quantity update (dynamic)"
1269
+ msgstr ""
1270
+
1271
+ #: view/settings_price_rules.php:137 view/settings_price_rules.php:211
1272
+ #: view/settings_price_rules.php:229 view/settings_price_rules.php:247
1273
+ #: view/settings_price_rules.php:265
1274
  msgid "Don't Show"
1275
  msgstr ""
1276
 
1277
+ #: view/settings_price_rules.php:146
1278
  msgid ""
1279
  "Show a crossed-out original price along with discounted price at line items "
1280
  "in cart"
1281
  msgstr ""
1282
 
1283
+ #: view/settings_price_rules.php:163
1284
  msgid "Discount Table :"
1285
  msgstr ""
1286
 
1287
+ #: view/settings_price_rules.php:172
1288
  msgid "Default layout"
1289
  msgstr ""
1290
 
1291
+ #: view/settings_price_rules.php:175
1292
  msgid "Advance layout"
1293
  msgstr ""
1294
 
1295
+ #: view/settings_price_rules.php:184
1296
  msgid "Table placement:"
1297
  msgstr ""
1298
 
1299
+ #: view/settings_price_rules.php:190
1300
  msgid "Before cart form"
1301
  msgstr ""
1302
 
1303
+ #: view/settings_price_rules.php:193
1304
  msgid "After cart form"
1305
  msgstr ""
1306
 
1307
+ #: view/settings_price_rules.php:202
1308
  msgid "Table header :"
1309
  msgstr ""
1310
 
1311
+ #: view/settings_price_rules.php:220
1312
  msgid "Title column on table :"
1313
  msgstr ""
1314
 
1315
+ #: view/settings_price_rules.php:238
1316
  msgid "Range column on table :"
1317
  msgstr ""
1318
 
1319
+ #: view/settings_price_rules.php:256
1320
  msgid "Discount column on table :"
1321
  msgstr ""
1322
 
1323
+ #: view/settings_price_rules.php:278
1324
  msgid "Show a Sale badge on product pages :"
1325
  msgstr ""
1326
 
1327
+ #: view/settings_price_rules.php:284
1328
  msgid "Do not show"
1329
  msgstr ""
1330
 
1331
+ #: view/settings_price_rules.php:287
1332
  msgid "Show only after a rule condition is matched exactly"
1333
  msgstr ""
1334
 
1335
+ #: view/settings_price_rules.php:290
1336
  msgid ""
1337
  "Show on products that are covered under any price based discount rule in the "
1338
  "plugin"
1339
  msgstr ""
1340
 
1341
+ #: view/settings_price_rules.php:301
1342
  msgid "Do you want to customize the sale badge?"
1343
  msgstr ""
1344
 
1345
+ #: view/settings_price_rules.php:308
1346
  msgid "Yes, I would like to customize the sale badge"
1347
  msgstr ""
1348
 
1349
+ #: view/settings_price_rules.php:310
1350
  msgid ""
1351
  "Force override the label for sale badge (useful when your theme has override "
1352
  "for sale badge)."
1353
  msgstr ""
1354
 
1355
+ #: view/settings_price_rules.php:325
1356
  msgid "Sale badge content (TIP: You can use HTML inside)"
1357
  msgstr ""
1358
 
1359
+ #: view/settings_price_rules.php:332
1360
  msgid ""
1361
  "IMPORTANT NOTE: This customized sale badge will be applicable only for "
1362
  "products that are part of the discount rules configured in this plugin"
1363
  msgstr ""
1364
 
1365
+ #: view/settings_price_rules.php:336
1366
  msgid "Eg:"
1367
  msgstr ""
1368
 
includes/cart-rules.php CHANGED
@@ -1668,11 +1668,11 @@ if (!class_exists('FlycartWooDiscountRulesCartRules')) {
1668
  $discount = 0;
1669
 
1670
  if ($adjustment['type'] == 'percentage') {
1671
- if(((int)$adjustment['value']) > 0){
1672
  $discount = $sub_total * ($adjustment['value'] / 100);
1673
  }
1674
  } else if ($adjustment['type'] == 'price') {
1675
- if(((int)$adjustment['value']) > 0){
1676
  $discount = $adjustment['value'];
1677
  }
1678
  }
1668
  $discount = 0;
1669
 
1670
  if ($adjustment['type'] == 'percentage') {
1671
+ if(((float)$adjustment['value']) > 0){
1672
  $discount = $sub_total * ($adjustment['value'] / 100);
1673
  }
1674
  } else if ($adjustment['type'] == 'price') {
1675
+ if(((float)$adjustment['value']) > 0){
1676
  $discount = $adjustment['value'];
1677
  }
1678
  }
includes/discount-base.php CHANGED
@@ -1170,10 +1170,10 @@ if (!class_exists('FlycartWooDiscountBase')) {
1170
  * @return array
1171
  * */
1172
  public static function addActionLinksInPluginPage($links){
1173
- $mewlinks = array(
1174
  '<a href="' . admin_url("admin.php?page=woo_discount_rules&tab=settings"). '">'.esc_html__('Settings', 'woo-discount-rules').'</a>',
1175
  );
1176
- return array_merge( $links, $mewlinks );
1177
  }
1178
 
1179
  /**
1170
  * @return array
1171
  * */
1172
  public static function addActionLinksInPluginPage($links){
1173
+ $new_links = array(
1174
  '<a href="' . admin_url("admin.php?page=woo_discount_rules&tab=settings"). '">'.esc_html__('Settings', 'woo-discount-rules').'</a>',
1175
  );
1176
+ return array_merge($new_links, $links);
1177
  }
1178
 
1179
  /**
includes/pricing-rules.php CHANGED
@@ -34,6 +34,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
34
  */
35
  public $rule_sets;
36
 
 
 
37
  /**
38
  * @var
39
  */
@@ -1294,7 +1296,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1294
  if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
1295
  $totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category'], $rule['product_to_exclude'], $rule['exclude_sale_items']);
1296
  if($product_page && !$bogo){
1297
- $quantity = 1+$totalQuantityInThisCategory;
 
 
 
 
1298
  } else {
1299
  $quantity = $totalQuantityInThisCategory;
1300
  }
@@ -1331,7 +1337,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1331
  if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
1332
  $totalQuantityInThisAttribute = $this->getProductQuantityInThisAttribute($rule['type']['specific_attribute'], $rule['product_to_exclude'], $rule['exclude_sale_items'], $id);
1333
  if($product_page && !$bogo){
1334
- $quantity = 1+$totalQuantityInThisAttribute;
 
 
 
 
1335
  } else {
1336
  $quantity = $totalQuantityInThisAttribute;
1337
  }
@@ -1697,7 +1707,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1697
  public function getProductQuantityForCumulativeSpecificProducts($item, $product_page, $rules, $specific_products){
1698
  global $woocommerce;
1699
  $quantity = 0;
1700
- if($product_page) $quantity++;
 
 
 
 
1701
  if(is_array($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents)){
1702
  foreach ($woocommerce->cart->cart_contents as $cartItem) {
1703
  if(empty($cartItem['data'])){
@@ -1724,7 +1738,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1724
  $exclude_sale_items = isset($rules['exclude_sale_items']) ? $rules['exclude_sale_items']: 0;
1725
  global $woocommerce;
1726
  $hasExcludeProduct = $quantity = 0;
1727
- if($product_page) $quantity++;
 
 
 
 
1728
  if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
1729
  if(is_array($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents)){
1730
  foreach ($woocommerce->cart->cart_contents as $cartItem) {
@@ -1782,6 +1800,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
1782
  {
1783
  $adjustment = array();
1784
  if(FlycartWooDiscountRulesGeneralHelper::is_countable($discount_ranges)){
 
 
 
 
 
1785
  foreach($discount_ranges as $discount_range) {
1786
  if (!is_array($discount_range) && !is_object($discount_range)) return false;
1787
  $range = is_array($discount_range) ? (object) $discount_range : $discount_range;
@@ -3531,8 +3554,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3531
  if(FlycartWoocommerceVersion::wcVersion('3.0')) return $data;
3532
  $item_price = $data['price_html'];
3533
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3534
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
3535
- if($show_price_discount_on_product_page == 'show' && $notAdmin){
3536
  $discountPrice = $this->getDiscountPriceForTheProduct($product, FlycartWoocommerceProduct::get_price($variations));
3537
  $product_id = FlycartWoocommerceProduct::get_id($variations);
3538
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
@@ -3568,8 +3590,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3568
  }
3569
 
3570
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3571
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
3572
- if($show_price_discount_on_product_page == 'show' && $notAdmin){
3573
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
3574
  $product_id = FlycartWoocommerceProduct::get_id($product);
3575
  self::$product_on_sale[$product_id] = 0;
@@ -3615,8 +3636,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3615
  public function replaceVisiblePricesForSalePriceAdjustment($item_price, $product)
3616
  {
3617
  $show_sale_tag_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
3618
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
3619
- if($show_sale_tag_on_product_page == 'show_on_any_rules_matches' || ($show_sale_tag_on_product_page == 'show' && $show_price_discount_on_product_page == 'dont')) {
3620
  $excluded_product_type = apply_filters('woo_discount_rules_exclude_product_type_for_sale_price_strikeout_adjustment', array('variable', 'subscription_variation', 'variable-subscription', 'grouped', 'composite'), $product);
3621
  if(is_array($excluded_product_type) && !empty($excluded_product_type)){
3622
  if (!$product->is_type($excluded_product_type)) {
@@ -3626,7 +3646,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3626
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
3627
  if($sale_price == $regular_price){
3628
  $item_price = '<span class="cart_price wdr_product_strikeout">';
3629
- $item_price .= FlycartWoocommerceProduct::wc_price($regular_price);
 
 
3630
  $item_price .= '</span>';
3631
  return $item_price;
3632
  }
@@ -3665,8 +3687,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3665
  }
3666
 
3667
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3668
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
3669
- if($show_price_discount_on_product_page == 'show' && ($notAdmin || $runTheRulesEvenInAjax)){
3670
  $product_id = FlycartWoocommerceProduct::get_id($product);
3671
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
3672
  return self::$product_strike_out_price[$product_id];
@@ -3722,9 +3743,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3722
  self::$woo_discount_product_on_sale_is_active[$product_id] = true;
3723
  }
3724
  } else {
3725
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_price_discount_on_product_page']))? $this->baseConfig['show_price_discount_on_product_page']: 'show';
3726
  $optimize_sale_and_price_strikeout = apply_filters('woo_discount_rules_do_sale_tag_through_strikeout_price', true, $product);
3727
- if($show_price_discount_on_product_page == 'show' && $optimize_sale_and_price_strikeout){
3728
  $this->replaceVisiblePrices('', $product);
3729
  if(isset(self::$product_on_sale[$product_id])){
3730
  if(self::$product_on_sale[$product_id]){
@@ -3759,6 +3779,68 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3759
  return $on_sale;
3760
  }
3761
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3762
  public function getWooDiscountedPriceForVariant(){
3763
  if (isset($_REQUEST['id']) && $_REQUEST['id'] && isset($_REQUEST['price_html']) && $_REQUEST['price_html'] != '') {
3764
  if (!defined('WOO_DISCOUNT_DOING_AJAX')) define('WOO_DISCOUNT_DOING_AJAX', 1);
@@ -3785,8 +3867,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3785
  if(is_array($children) && count($children)){
3786
  foreach ( $children as $child ) {
3787
  $is_visible = FlycartWoocommerceProduct::variation_is_visible_in_frontend($child);
3788
- if ( '' !== FlycartWoocommerceProduct::get_price($child) && $is_visible) {
3789
- $child_prices[FlycartWoocommerceProduct::get_id($child)] = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($child) : FlycartWoocommerceProduct::get_price_excluding_tax( $child );
 
3790
  }
3791
  }
3792
  }
@@ -3795,8 +3878,9 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3795
  if(is_array($children) && count($children)){
3796
  foreach ( $children as $child_id ) {
3797
  $child = FlycartWoocommerceProduct::wc_get_product($child_id);
3798
- if ( '' !== FlycartWoocommerceProduct::get_price($child) ) {
3799
- $child_prices[FlycartWoocommerceProduct::get_id($child)] = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($child) : FlycartWoocommerceProduct::get_price_excluding_tax( $child );
 
3800
  }
3801
  }
3802
  }
@@ -3822,7 +3906,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3822
  $leastPrice = FlycartWoocommerceProduct::wc_price($child_prices[$minProductId]);
3823
  } else {
3824
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
3825
- $leastPrice = FlycartWoocommerceProduct::get_price($minProduct);
3826
  $leastPrice = FlycartWoocommerceProduct::wc_price($leastPrice);
3827
  }
3828
  }
@@ -3831,7 +3915,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3831
  $greatestPrice = FlycartWoocommerceProduct::wc_price($child_prices[$maxProductId]);
3832
  } else {
3833
  $maxProduct = FlycartWoocommerceProduct::wc_get_product($maxProductId);
3834
- $greatestPrice = FlycartWoocommerceProduct::get_price($maxProduct);
3835
  $greatestPrice = FlycartWoocommerceProduct::wc_price($greatestPrice);
3836
  }
3837
  if(!empty($leastPrice)){
@@ -3839,7 +3923,7 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3839
  $leastPrice = FlycartWoocommerceProduct::wc_price($child_prices[$minProductId]);
3840
  } else {
3841
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
3842
- $leastPrice = FlycartWoocommerceProduct::get_price($minProduct);
3843
  $leastPrice = FlycartWoocommerceProduct::wc_price($leastPrice);
3844
  }
3845
  if($display_only_lowest_price){
@@ -3953,8 +4037,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
3953
  public function displayProductIsOnSaleTag($on_sale, $product){
3954
  $runTheRulesEvenInAjax = apply_filters('woo_discount_rules_run_sale_tag_for_ajax', false, $product);
3955
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3956
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
3957
- if($show_price_discount_on_product_page == 'show' && ($notAdmin || $runTheRulesEvenInAjax)){
3958
  $product_id = FlycartWoocommerceProduct::get_id($product);
3959
  self::$product_on_sale[$product_id] = 0;
3960
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
@@ -4038,8 +4122,8 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4038
  * */
4039
  public function displayProductIsOnSaleTagNew($on_sale, $product){
4040
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
4041
- $show_price_discount_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
4042
- if($show_price_discount_on_product_page == 'show' && $notAdmin){
4043
  global $product;
4044
  $rules = $this->generateDiscountTableData($product);
4045
  if(!empty($rules)){
@@ -4059,7 +4143,11 @@ if (!class_exists('FlycartWooDiscountRulesPricingRules')) {
4059
  $product_id = FlycartWoocommerceProduct::get_id($product);
4060
  $item['product_id'] = $product_id;
4061
  $item['data'] = $product;
4062
- $item['quantity'] = ($this->getQuantityOfProductInCart($product_id))+1;
 
 
 
 
4063
 
4064
  // To display the strike out price in product page for variant (specific attribute rule)
4065
  if($product->get_type() == 'variation'){
34
  */
35
  public $rule_sets;
36
 
37
+ protected $custom_qty = 0;
38
+
39
  /**
40
  * @var
41
  */
1296
  if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
1297
  $totalQuantityInThisCategory = $this->getProductQuantityInThisCategory($rule['type']['specific_category'], $rule['product_to_exclude'], $rule['exclude_sale_items']);
1298
  if($product_page && !$bogo){
1299
+ if(FlycartWooDiscountRulesGeneralHelper::addAQuantityForProductStrikeOut()){
1300
+ $quantity = 1+$totalQuantityInThisCategory;
1301
+ } else {
1302
+ $quantity = $totalQuantityInThisCategory;
1303
+ }
1304
  } else {
1305
  $quantity = $totalQuantityInThisCategory;
1306
  }
1337
  if(isset($rule['type']['is_cumulative']) && $rule['type']['is_cumulative']){
1338
  $totalQuantityInThisAttribute = $this->getProductQuantityInThisAttribute($rule['type']['specific_attribute'], $rule['product_to_exclude'], $rule['exclude_sale_items'], $id);
1339
  if($product_page && !$bogo){
1340
+ if(FlycartWooDiscountRulesGeneralHelper::addAQuantityForProductStrikeOut()){
1341
+ $quantity = 1+$totalQuantityInThisAttribute;
1342
+ } else {
1343
+ $quantity = $totalQuantityInThisAttribute;
1344
+ }
1345
  } else {
1346
  $quantity = $totalQuantityInThisAttribute;
1347
  }
1707
  public function getProductQuantityForCumulativeSpecificProducts($item, $product_page, $rules, $specific_products){
1708
  global $woocommerce;
1709
  $quantity = 0;
1710
+ if($product_page){
1711
+ if(FlycartWooDiscountRulesGeneralHelper::addAQuantityForProductStrikeOut()){
1712
+ $quantity++;
1713
+ }
1714
+ }
1715
  if(is_array($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents)){
1716
  foreach ($woocommerce->cart->cart_contents as $cartItem) {
1717
  if(empty($cartItem['data'])){
1738
  $exclude_sale_items = isset($rules['exclude_sale_items']) ? $rules['exclude_sale_items']: 0;
1739
  global $woocommerce;
1740
  $hasExcludeProduct = $quantity = 0;
1741
+ if($product_page){
1742
+ if(FlycartWooDiscountRulesGeneralHelper::addAQuantityForProductStrikeOut()){
1743
+ $quantity++;
1744
+ }
1745
+ }
1746
  if(!empty($product_to_exclude) && is_array($product_to_exclude) && count($product_to_exclude)) $hasExcludeProduct = 1;
1747
  if(is_array($woocommerce->cart->cart_contents) && count($woocommerce->cart->cart_contents)){
1748
  foreach ($woocommerce->cart->cart_contents as $cartItem) {
1800
  {
1801
  $adjustment = array();
1802
  if(FlycartWooDiscountRulesGeneralHelper::is_countable($discount_ranges)){
1803
+ if($product_page){
1804
+ if($this->custom_qty > 0){
1805
+ $quantity += ($this->custom_qty-1);
1806
+ }
1807
+ }
1808
  foreach($discount_ranges as $discount_range) {
1809
  if (!is_array($discount_range) && !is_object($discount_range)) return false;
1810
  $range = is_array($discount_range) ? (object) $discount_range : $discount_range;
3554
  if(FlycartWoocommerceVersion::wcVersion('3.0')) return $data;
3555
  $item_price = $data['price_html'];
3556
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3557
+ if(FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage() && $notAdmin){
 
3558
  $discountPrice = $this->getDiscountPriceForTheProduct($product, FlycartWoocommerceProduct::get_price($variations));
3559
  $product_id = FlycartWoocommerceProduct::get_id($variations);
3560
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
3590
  }
3591
 
3592
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3593
+ if(FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage() && $notAdmin){
 
3594
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
3595
  $product_id = FlycartWoocommerceProduct::get_id($product);
3596
  self::$product_on_sale[$product_id] = 0;
3636
  public function replaceVisiblePricesForSalePriceAdjustment($item_price, $product)
3637
  {
3638
  $show_sale_tag_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
3639
+ if($show_sale_tag_on_product_page == 'show_on_any_rules_matches' || ($show_sale_tag_on_product_page == 'show' && (!FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage()))) {
 
3640
  $excluded_product_type = apply_filters('woo_discount_rules_exclude_product_type_for_sale_price_strikeout_adjustment', array('variable', 'subscription_variation', 'variable-subscription', 'grouped', 'composite'), $product);
3641
  if(is_array($excluded_product_type) && !empty($excluded_product_type)){
3642
  if (!$product->is_type($excluded_product_type)) {
3646
  $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
3647
  if($sale_price == $regular_price){
3648
  $item_price = '<span class="cart_price wdr_product_strikeout">';
3649
+ $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
3650
+ $price_to_display = FlycartWoocommerceProduct::wc_price($regular_price);
3651
+ $item_price .= (($price_to_display).$product->get_price_suffix($regular_price));
3652
  $item_price .= '</span>';
3653
  return $item_price;
3654
  }
3687
  }
3688
 
3689
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
3690
+ if((FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage()) && ($notAdmin || $runTheRulesEvenInAjax)){
 
3691
  $product_id = FlycartWoocommerceProduct::get_id($product);
3692
  if(isset(self::$product_strike_out_price[$product_id]) && !empty(self::$product_strike_out_price[$product_id])){
3693
  return self::$product_strike_out_price[$product_id];
3743
  self::$woo_discount_product_on_sale_is_active[$product_id] = true;
3744
  }
3745
  } else {
 
3746
  $optimize_sale_and_price_strikeout = apply_filters('woo_discount_rules_do_sale_tag_through_strikeout_price', true, $product);
3747
+ if((FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage()) && $optimize_sale_and_price_strikeout){
3748
  $this->replaceVisiblePrices('', $product);
3749
  if(isset(self::$product_on_sale[$product_id])){
3750
  if(self::$product_on_sale[$product_id]){
3779
  return $on_sale;
3780
  }
3781
 
3782
+ /**
3783
+ * Get strikeout price of a product through ajax on change quantity
3784
+ * */
3785
+ public function getWooDiscountStrikeoutPriceOfProduct(){
3786
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
3787
+ $return['status'] = 0;
3788
+ $return['price_html'] = '';
3789
+ if (!defined('WOO_DISCOUNT_DOING_AJAX')) define('WOO_DISCOUNT_DOING_AJAX', 1);
3790
+ $product = FlycartWoocommerceProduct::wc_get_product(sanitize_text_field($_REQUEST['id']));
3791
+ if(!empty($product)){
3792
+ $price_html_request = $this->getOriginalStrikeoutPriceOfProduct($product);
3793
+ $this->custom_qty = sanitize_text_field($_REQUEST['qty']);
3794
+ $price_html = $this->replaceVisiblePrices($price_html_request, $product);
3795
+ $this->custom_qty = 0;
3796
+ $return['status'] = 1;
3797
+ $return['price_html'] = $price_html;
3798
+ $return['product_type'] = $product->get_type();
3799
+ }
3800
+ echo json_encode($return);
3801
+ exit;
3802
+ }
3803
+ }
3804
+
3805
+ /**
3806
+ * Get original price of a product
3807
+ *
3808
+ * @param $product object
3809
+ * @return string
3810
+ * */
3811
+ protected function getOriginalStrikeoutPriceOfProduct($product){
3812
+ $product_id = FlycartWoocommerceProduct::get_id($product);
3813
+ $product_type = $product->get_type();
3814
+ $sale_price = FlycartWoocommerceProduct::get_price($product);
3815
+ $regular_price = FlycartWoocommerceProduct::get_regular_price($product);
3816
+ if($sale_price == $regular_price){
3817
+ $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
3818
+ $html = '';
3819
+ if($product_type == 'variation'){
3820
+ $html = '<span class="price">';
3821
+ }
3822
+ $html .= FlycartWoocommerceProduct::wc_price($sale_price);
3823
+ if($product_type == 'variation'){
3824
+ $html .= '</span>';
3825
+ }
3826
+ } else {
3827
+ $html = '<span class="cart_price wdr_product_strikeout">';
3828
+ $regular_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $regular_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $regular_price);
3829
+ $sale_price = get_option('woocommerce_tax_display_shop') == 'excl' ? FlycartWoocommerceProduct::get_price_excluding_tax($product, 1, $sale_price) : FlycartWoocommerceProduct::get_price_including_tax($product, 1, $sale_price);
3830
+ if($product_type == 'variation'){
3831
+ $html .= '<span class="price">';
3832
+ }
3833
+ $html .= "<del>".FlycartWoocommerceProduct::wc_price($regular_price)."</del>";
3834
+ $html .= "<ins>".FlycartWoocommerceProduct::wc_price($sale_price)."</ins>";
3835
+ if($product_type == 'variation'){
3836
+ $html .= '</span>';
3837
+ }
3838
+ $html .= '</span>';
3839
+ }
3840
+
3841
+ return $html;
3842
+ }
3843
+
3844
  public function getWooDiscountedPriceForVariant(){
3845
  if (isset($_REQUEST['id']) && $_REQUEST['id'] && isset($_REQUEST['price_html']) && $_REQUEST['price_html'] != '') {
3846
  if (!defined('WOO_DISCOUNT_DOING_AJAX')) define('WOO_DISCOUNT_DOING_AJAX', 1);
3867
  if(is_array($children) && count($children)){
3868
  foreach ( $children as $child ) {
3869
  $is_visible = FlycartWoocommerceProduct::variation_is_visible_in_frontend($child);
3870
+ if ( '' !== FlycartWoocommerceProduct::get_regular_price($child) && $is_visible) {
3871
+ $regular_price = FlycartWoocommerceProduct::get_regular_price($child);
3872
+ $child_prices[FlycartWoocommerceProduct::get_id($child)] = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($child, 1, $regular_price) : FlycartWoocommerceProduct::get_price_excluding_tax( $child, 1, $regular_price );
3873
  }
3874
  }
3875
  }
3878
  if(is_array($children) && count($children)){
3879
  foreach ( $children as $child_id ) {
3880
  $child = FlycartWoocommerceProduct::wc_get_product($child_id);
3881
+ if ( '' !== FlycartWoocommerceProduct::get_regular_price($child) ) {
3882
+ $regular_price = FlycartWoocommerceProduct::get_regular_price($child);
3883
+ $child_prices[FlycartWoocommerceProduct::get_id($child)] = 'incl' === $tax_display_mode ? FlycartWoocommerceProduct::get_price_including_tax($child, 1, $regular_price) : FlycartWoocommerceProduct::get_price_excluding_tax( $child, 1, $regular_price );
3884
  }
3885
  }
3886
  }
3906
  $leastPrice = FlycartWoocommerceProduct::wc_price($child_prices[$minProductId]);
3907
  } else {
3908
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
3909
+ $leastPrice = FlycartWoocommerceProduct::get_regular_price($minProduct);
3910
  $leastPrice = FlycartWoocommerceProduct::wc_price($leastPrice);
3911
  }
3912
  }
3915
  $greatestPrice = FlycartWoocommerceProduct::wc_price($child_prices[$maxProductId]);
3916
  } else {
3917
  $maxProduct = FlycartWoocommerceProduct::wc_get_product($maxProductId);
3918
+ $greatestPrice = FlycartWoocommerceProduct::get_regular_price($maxProduct);
3919
  $greatestPrice = FlycartWoocommerceProduct::wc_price($greatestPrice);
3920
  }
3921
  if(!empty($leastPrice)){
3923
  $leastPrice = FlycartWoocommerceProduct::wc_price($child_prices[$minProductId]);
3924
  } else {
3925
  $minProduct = FlycartWoocommerceProduct::wc_get_product($minProductId);
3926
+ $leastPrice = FlycartWoocommerceProduct::get_regular_price($minProduct);
3927
  $leastPrice = FlycartWoocommerceProduct::wc_price($leastPrice);
3928
  }
3929
  if($display_only_lowest_price){
4037
  public function displayProductIsOnSaleTag($on_sale, $product){
4038
  $runTheRulesEvenInAjax = apply_filters('woo_discount_rules_run_sale_tag_for_ajax', false, $product);
4039
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
4040
+ $show_sale_tag_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
4041
+ if($show_sale_tag_on_product_page == 'show' && ($notAdmin || $runTheRulesEvenInAjax)){
4042
  $product_id = FlycartWoocommerceProduct::get_id($product);
4043
  self::$product_on_sale[$product_id] = 0;
4044
  $discountPrice = $this->getDiscountPriceForTheProduct($product);
4122
  * */
4123
  public function displayProductIsOnSaleTagNew($on_sale, $product){
4124
  $notAdmin = FlycartWooDiscountRulesGeneralHelper::doIHaveToRun();
4125
+ $show_sale_tag_on_product_page = (isset($this->baseConfig['show_sale_tag_on_product_page']))? $this->baseConfig['show_sale_tag_on_product_page']: 'show';
4126
+ if($show_sale_tag_on_product_page == 'show' && $notAdmin){
4127
  global $product;
4128
  $rules = $this->generateDiscountTableData($product);
4129
  if(!empty($rules)){
4143
  $product_id = FlycartWoocommerceProduct::get_id($product);
4144
  $item['product_id'] = $product_id;
4145
  $item['data'] = $product;
4146
+ if($this->custom_qty > 0){
4147
+ $item['quantity'] = ($this->getQuantityOfProductInCart($product_id))+$this->custom_qty;
4148
+ } else {
4149
+ $item['quantity'] = ($this->getQuantityOfProductInCart($product_id))+1;
4150
+ }
4151
 
4152
  // To display the strike out price in product page for variant (specific attribute rule)
4153
  if($product->get_type() == 'variation'){
loader.php CHANGED
@@ -88,6 +88,8 @@ if(!class_exists('FlycartWooDiscountRules')){
88
  * Run Plugin updater
89
  * */
90
  protected function runUpdater(){
 
 
91
  try{
92
  require plugin_dir_path( __FILE__ ).'/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php';
93
 
@@ -111,6 +113,54 @@ if(!class_exists('FlycartWooDiscountRules')){
111
  } catch (Exception $e){}
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  /**
115
  * Load Admin scripts
116
  * */
@@ -154,7 +204,10 @@ if(!class_exists('FlycartWooDiscountRules')){
154
  * Apply discount rules
155
  * */
156
  public function applyCartDiscountRules(){
157
- remove_action('woocommerce_cart_loaded_from_session', array($this, 'applyCartDiscountRules'), 97);
 
 
 
158
  $this->discountBase->handleCartDiscount();
159
  }
160
 
@@ -166,9 +219,8 @@ if(!class_exists('FlycartWooDiscountRules')){
166
  $script = '<script>';
167
  $script .= 'if(flycart_woo_discount_rules_strikeout_script_executed == undefined){';
168
  $script .= 'jQuery( document ).ready( function() {';
169
- $do_product_page_strikeout = $this->discountBase->getConfigData('show_price_discount_on_product_page', 'show');
170
  $enable_variable_product_cache = $this->discountBase->getConfigData('enable_variable_product_cache', 0);
171
- if($do_product_page_strikeout == 'show' && $runVariationStrikeoutAjax) {
172
  $script .= 'jQuery( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {';
173
  $script .= ' var container = jQuery(".single_variation .woocommerce-variation-price");';
174
  $script .= ' var current_object = jQuery(this);
@@ -384,6 +436,9 @@ if(!class_exists('FlycartWooDiscountRules')){
384
  }
385
  }
386
 
 
 
 
387
  add_action('wp_ajax_loadWooDiscountedPriceForVariant', array($this->pricingRules, 'getWooDiscountedPriceForVariant'));
388
  add_action('wp_ajax_nopriv_loadWooDiscountedPriceForVariant', array($this->pricingRules, 'getWooDiscountedPriceForVariant'));
389
  add_action('wp_ajax_loadWooDiscountedDiscountTable', array($this->pricingRules, 'getWooDiscountedPriceTableForVariant'));
@@ -475,7 +530,8 @@ if(!class_exists('FlycartWooDiscountRules')){
475
  wp_localize_script('woo_discount_rules_site', 'woo_discount_rules', array(
476
  'home_url' => get_home_url(),
477
  'admin_url' => admin_url(),
478
- 'ajax_url' => admin_url('admin-ajax.php')
 
479
  ));
480
  wp_enqueue_script( 'woo_discount_rules_site');
481
  }
88
  * Run Plugin updater
89
  * */
90
  protected function runUpdater(){
91
+ add_filter('puc_request_info_result-woo-discount-rules', array($this, 'loadWooDiscountRulesUpdateDetails'), 10, 2);
92
+
93
  try{
94
  require plugin_dir_path( __FILE__ ).'/vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php';
95
 
113
  } catch (Exception $e){}
114
  }
115
 
116
+ /**
117
+ * To load Woo discount rules update details
118
+ * */
119
+ public function loadWooDiscountRulesUpdateDetails($pluginInfo, $result){
120
+ try{
121
+ global $wp_version;
122
+ // include an unmodified $wp_version
123
+ include( ABSPATH . WPINC . '/version.php' );
124
+ $args = array('slug' => 'woo-discount-rules', 'fields' => array('active_installs'));
125
+ $response = wp_remote_post(
126
+ 'http://api.wordpress.org/plugins/info/1.0/',
127
+ array(
128
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . home_url( '/' ),
129
+ 'body' => array(
130
+ 'action' => 'plugin_information',
131
+ 'request'=>serialize((object)$args)
132
+ )
133
+ )
134
+ );
135
+
136
+ if(!empty($response)){
137
+ $returned_object = maybe_unserialize(wp_remote_retrieve_body($response));
138
+ if(!empty($returned_object)){
139
+ if(!empty($returned_object->name)) $pluginInfo->name = $returned_object->name;
140
+ if(!empty($returned_object->sections)) $pluginInfo->sections = $returned_object->sections;
141
+ if(!empty($returned_object->author)) $pluginInfo->author = $returned_object->author;
142
+ if(!empty($returned_object->author_profile)) $pluginInfo->author_profile = $returned_object->author_profile;
143
+ if(!empty($returned_object->requires)) $pluginInfo->requires = $returned_object->requires;
144
+ if(!empty($returned_object->tested)) $pluginInfo->tested = $returned_object->tested;
145
+ if(!empty($returned_object->rating)) $pluginInfo->rating = $returned_object->rating;
146
+ if(!empty($returned_object->ratings)) $pluginInfo->ratings = $returned_object->ratings;
147
+ if(!empty($returned_object->num_ratings)) $pluginInfo->num_ratings = $returned_object->num_ratings;
148
+ if(!empty($returned_object->support_threads)) $pluginInfo->support_threads = $returned_object->support_threads;
149
+ if(!empty($returned_object->support_threads_resolved)) $pluginInfo->support_threads_resolved = $returned_object->support_threads_resolved;
150
+ if(!empty($returned_object->downloaded)) $pluginInfo->downloaded = $returned_object->downloaded;
151
+ if(!empty($returned_object->last_updated)) $pluginInfo->last_updated = $returned_object->last_updated;
152
+ if(!empty($returned_object->added)) $pluginInfo->added = $returned_object->added;
153
+ if(!empty($returned_object->versions)) $pluginInfo->versions = $returned_object->versions;
154
+ if(!empty($returned_object->tags)) $pluginInfo->tags = $returned_object->tags;
155
+ if(!empty($returned_object->screenshots)) $pluginInfo->screenshots = $returned_object->screenshots;
156
+ if(!empty($returned_object->active_installs)) $pluginInfo->active_installs = $returned_object->active_installs;
157
+ }
158
+ }
159
+ } catch (Exception $e){}
160
+
161
+ return $pluginInfo;
162
+ }
163
+
164
  /**
165
  * Load Admin scripts
166
  * */
204
  * Apply discount rules
205
  * */
206
  public function applyCartDiscountRules(){
207
+ $removeTheEvent = apply_filters('woo_discount_rules_remove_event_woocommerce_cart_loaded_from_session', false);
208
+ if(!$removeTheEvent){
209
+ remove_action('woocommerce_cart_loaded_from_session', array($this, 'applyCartDiscountRules'), 97);
210
+ }
211
  $this->discountBase->handleCartDiscount();
212
  }
213
 
219
  $script = '<script>';
220
  $script .= 'if(flycart_woo_discount_rules_strikeout_script_executed == undefined){';
221
  $script .= 'jQuery( document ).ready( function() {';
 
222
  $enable_variable_product_cache = $this->discountBase->getConfigData('enable_variable_product_cache', 0);
223
+ if((FlycartWooDiscountRulesGeneralHelper::showDiscountOnProductPage()) && $runVariationStrikeoutAjax) {
224
  $script .= 'jQuery( ".single_variation_wrap" ).on( "show_variation", function ( event, variation, purchasable ) {';
225
  $script .= ' var container = jQuery(".single_variation .woocommerce-variation-price");';
226
  $script .= ' var current_object = jQuery(this);
436
  }
437
  }
438
 
439
+ add_action('wp_ajax_loadWooDiscountStrikeoutPriceOfProduct', array($this->pricingRules, 'getWooDiscountStrikeoutPriceOfProduct'));
440
+ add_action('wp_ajax_nopriv_loadWooDiscountStrikeoutPriceOfProduct', array($this->pricingRules, 'getWooDiscountStrikeoutPriceOfProduct'));
441
+
442
  add_action('wp_ajax_loadWooDiscountedPriceForVariant', array($this->pricingRules, 'getWooDiscountedPriceForVariant'));
443
  add_action('wp_ajax_nopriv_loadWooDiscountedPriceForVariant', array($this->pricingRules, 'getWooDiscountedPriceForVariant'));
444
  add_action('wp_ajax_loadWooDiscountedDiscountTable', array($this->pricingRules, 'getWooDiscountedPriceTableForVariant'));
530
  wp_localize_script('woo_discount_rules_site', 'woo_discount_rules', array(
531
  'home_url' => get_home_url(),
532
  'admin_url' => admin_url(),
533
+ 'ajax_url' => admin_url('admin-ajax.php'),
534
+ 'show_product_strikeout' => $this->discountBase->getConfigData('show_price_discount_on_product_page', 'show')
535
  ));
536
  wp_enqueue_script( 'woo_discount_rules_site');
537
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://flycart.org/
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.2
7
- Stable tag: 1.7.18
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
@@ -318,6 +318,16 @@ Discount - Enter minimum & Maximum quantity -> Adjustment Type -> Product Discou
318
 
319
  == Changelog ==
320
 
 
 
 
 
 
 
 
 
 
 
321
  = 1.7.18 - 30/07/19 =
322
  * Feature - Force override the label for sale badge option.
323
  * Fix - Include child variants while parent is chosen in product dependent rule.
4
  Tags: woocommerce, coupons, discounts, dynamic pricing, Buy One Get One Free, pricing deals, bulk discount, discount
5
  Requires at least: 4.4.1
6
  Tested up to: 5.2
7
+ Stable tag: 1.7.19
8
  License: GPLv3 or later
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
10
 
318
 
319
  == Changelog ==
320
 
321
+ = 1.7.19 - 26/08/19 =
322
+ * Feature - Option to do strikeout on change quantity in product page.
323
+ * Feature - Option to display strikeout on after a rule condition is matched in product page.
324
+ * Fix - Validation issue in woocommerce v2.x on saving BOGO Rule.
325
+ * Fix - Not applying discount for decimal values less than 1 in cart rules.
326
+ * Fix - Wrong strikeout price for variable product on set option apply discount from regular price.
327
+ * Fix - Not displaying price display suffix when disable strikeout option and enable sale option.
328
+ * Improvement - Event apply_filters('woo_discount_rules_remove_event_woocommerce_cart_loaded_from_session', false).
329
+ * Improvement - Update checker update to make compatible with PHP 7.x
330
+
331
  = 1.7.18 - 30/07/19 =
332
  * Feature - Force override the label for sale badge option.
333
  * Fix - Include child variants while parent is chosen in product dependent rule.
vendor/composer/ClassLoader.php CHANGED
@@ -279,7 +279,7 @@ class ClassLoader
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
- $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null;
283
  }
284
 
285
  /**
@@ -374,10 +374,14 @@ class ClassLoader
374
 
375
  $first = $class[0];
376
  if (isset($this->prefixLengthsPsr4[$first])) {
377
- foreach ($this->prefixLengthsPsr4[$first] as $prefix => $length) {
378
- if (0 === strpos($class, $prefix)) {
379
- foreach ($this->prefixDirsPsr4[$prefix] as $dir) {
380
- if (file_exists($file = $dir . DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $length))) {
 
 
 
 
381
  return $file;
382
  }
383
  }
279
  */
280
  public function setApcuPrefix($apcuPrefix)
281
  {
282
+ $this->apcuPrefix = function_exists('apcu_fetch') && filter_var(ini_get('apc.enabled'), FILTER_VALIDATE_BOOLEAN) ? $apcuPrefix : null;
283
  }
284
 
285
  /**
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
  }
vendor/composer/autoload_files.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // autoload_files.php @generated by Composer
4
+
5
+ $vendorDir = dirname(dirname(__FILE__));
6
+ $baseDir = dirname($vendorDir);
7
+
8
+ return array(
9
+ '89ff252b349d4d088742a09c25f5dd74' => $vendorDir . '/yahnis-elsts/plugin-update-checker/plugin-update-checker.php',
10
+ );
vendor/composer/autoload_real.php CHANGED
@@ -47,6 +47,24 @@ class ComposerAutoloaderInit99fb821a098de3bdad03e3323415706b
47
 
48
  $loader->register(true);
49
 
 
 
 
 
 
 
 
 
 
50
  return $loader;
51
  }
52
  }
 
 
 
 
 
 
 
 
 
47
 
48
  $loader->register(true);
49
 
50
+ if ($useStaticLoader) {
51
+ $includeFiles = Composer\Autoload\ComposerStaticInit99fb821a098de3bdad03e3323415706b::$files;
52
+ } else {
53
+ $includeFiles = require __DIR__ . '/autoload_files.php';
54
+ }
55
+ foreach ($includeFiles as $fileIdentifier => $file) {
56
+ composerRequire99fb821a098de3bdad03e3323415706b($fileIdentifier, $file);
57
+ }
58
+
59
  return $loader;
60
  }
61
  }
62
+
63
+ function composerRequire99fb821a098de3bdad03e3323415706b($fileIdentifier, $file)
64
+ {
65
+ if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
66
+ require $file;
67
+
68
+ $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
69
+ }
70
+ }
vendor/composer/autoload_static.php CHANGED
@@ -6,6 +6,10 @@ namespace Composer\Autoload;
6
 
7
  class ComposerStaticInit99fb821a098de3bdad03e3323415706b
8
  {
 
 
 
 
9
  public static $prefixLengthsPsr4 = array (
10
  'F' =>
11
  array (
6
 
7
  class ComposerStaticInit99fb821a098de3bdad03e3323415706b
8
  {
9
+ public static $files = array (
10
+ '89ff252b349d4d088742a09c25f5dd74' => __DIR__ . '/..' . '/yahnis-elsts/plugin-update-checker/plugin-update-checker.php',
11
+ );
12
+
13
  public static $prefixLengthsPsr4 = array (
14
  'F' =>
15
  array (
vendor/composer/installed.json CHANGED
@@ -1,4 +1,40 @@
1
  [
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
  {
3
  "name": "flycartinc/inputhelper",
4
  "version": "dev-master",
@@ -38,25 +74,30 @@
38
  },
39
  {
40
  "name": "yahnis-elsts/plugin-update-checker",
41
- "version": "v4.0.3",
42
- "version_normalized": "4.0.3.0",
43
  "source": {
44
  "type": "git",
45
  "url": "https://github.com/YahnisElsts/plugin-update-checker.git",
46
- "reference": "e4854cdb388153ce238044518c67888976d4a4ec"
47
  },
48
  "dist": {
49
  "type": "zip",
50
- "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/e4854cdb388153ce238044518c67888976d4a4ec",
51
- "reference": "e4854cdb388153ce238044518c67888976d4a4ec",
52
  "shasum": ""
53
  },
54
  "require": {
55
  "php": ">=5.2.0"
56
  },
57
- "time": "2017-01-24T10:18:34+00:00",
58
  "type": "library",
59
  "installation-source": "dist",
 
 
 
 
 
60
  "notification-url": "https://packagist.org/downloads/",
61
  "license": [
62
  "MIT"
@@ -77,41 +118,5 @@
77
  "theme updates",
78
  "wordpress"
79
  ]
80
- },
81
- {
82
- "name": "askupa-software/wp-admin-notification",
83
- "version": "dev-master",
84
- "version_normalized": "9999999-dev",
85
- "source": {
86
- "type": "git",
87
- "url": "https://github.com/askupasoftware/wp-admin-notification.git",
88
- "reference": "90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a"
89
- },
90
- "dist": {
91
- "type": "zip",
92
- "url": "https://api.github.com/repos/askupasoftware/wp-admin-notification/zipball/90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a",
93
- "reference": "90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a",
94
- "shasum": ""
95
- },
96
- "require": {
97
- "php": ">=5.3.0"
98
- },
99
- "time": "2017-03-20T21:01:42+00:00",
100
- "type": "wordpress",
101
- "installation-source": "source",
102
- "notification-url": "https://packagist.org/downloads/",
103
- "authors": [
104
- {
105
- "name": "Askupa Software",
106
- "email": "hello@askupasoftware.com"
107
- }
108
- ],
109
- "description": "Add static/dismissible admin notifications to WordPress",
110
- "homepage": "https://github.com/askupasoftware/wp-dismissible-notice",
111
- "keywords": [
112
- "framework",
113
- "notices",
114
- "wordpress"
115
- ]
116
  }
117
  ]
1
  [
2
+ {
3
+ "name": "askupa-software/wp-admin-notification",
4
+ "version": "dev-master",
5
+ "version_normalized": "9999999-dev",
6
+ "source": {
7
+ "type": "git",
8
+ "url": "https://github.com/askupasoftware/wp-admin-notification.git",
9
+ "reference": "90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a"
10
+ },
11
+ "dist": {
12
+ "type": "zip",
13
+ "url": "https://api.github.com/repos/askupasoftware/wp-admin-notification/zipball/90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a",
14
+ "reference": "90bc92aeb60ab3ffc3d581fafa16fb82a9b02f4a",
15
+ "shasum": ""
16
+ },
17
+ "require": {
18
+ "php": ">=5.3.0"
19
+ },
20
+ "time": "2017-03-20T21:01:42+00:00",
21
+ "type": "wordpress",
22
+ "installation-source": "source",
23
+ "notification-url": "https://packagist.org/downloads/",
24
+ "authors": [
25
+ {
26
+ "name": "Askupa Software",
27
+ "email": "hello@askupasoftware.com"
28
+ }
29
+ ],
30
+ "description": "Add static/dismissible admin notifications to WordPress",
31
+ "homepage": "https://github.com/askupasoftware/wp-dismissible-notice",
32
+ "keywords": [
33
+ "framework",
34
+ "notices",
35
+ "wordpress"
36
+ ]
37
+ },
38
  {
39
  "name": "flycartinc/inputhelper",
40
  "version": "dev-master",
74
  },
75
  {
76
  "name": "yahnis-elsts/plugin-update-checker",
77
+ "version": "v4.7",
78
+ "version_normalized": "4.7.0.0",
79
  "source": {
80
  "type": "git",
81
  "url": "https://github.com/YahnisElsts/plugin-update-checker.git",
82
+ "reference": "6da68b119277a400fad0ca6ec54f223b10bd8230"
83
  },
84
  "dist": {
85
  "type": "zip",
86
+ "url": "https://api.github.com/repos/YahnisElsts/plugin-update-checker/zipball/6da68b119277a400fad0ca6ec54f223b10bd8230",
87
+ "reference": "6da68b119277a400fad0ca6ec54f223b10bd8230",
88
  "shasum": ""
89
  },
90
  "require": {
91
  "php": ">=5.2.0"
92
  },
93
+ "time": "2019-07-05T18:39:53+00:00",
94
  "type": "library",
95
  "installation-source": "dist",
96
+ "autoload": {
97
+ "files": [
98
+ "plugin-update-checker.php"
99
+ ]
100
+ },
101
  "notification-url": "https://packagist.org/downloads/",
102
  "license": [
103
  "MIT"
118
  "theme updates",
119
  "wordpress"
120
  ]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  ]
vendor/yahnis-elsts/plugin-update-checker/.editorconfig ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [*]
2
+ charset=utf-8
3
+ end_of_line=lf
4
+ insert_final_newline=false
5
+ indent_style=tab
6
+ tab_width=4
7
+
8
+ [{phpunit.xml.dist,*.jhm,*.xslt,*.xul,*.rng,*.xsl,*.xsd,*.ant,*.tld,*.fxml,*.jrxml,*.xml,*.jnlp,*.wsdl}]
9
+ indent_style=space
10
+ indent_size=4
11
+
12
+ [*.svg]
13
+ indent_style=space
14
+ indent_size=4
15
+
vendor/yahnis-elsts/plugin-update-checker/Puc/v4/Factory.php CHANGED
@@ -1,265 +1,6 @@
1
  <?php
2
  if ( !class_exists('Puc_v4_Factory', false) ):
3
 
4
- /**
5
- * A factory that builds update checker instances.
6
- *
7
- * When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 4.0
8
- * and 4.1), this factory will always use the latest available minor version. Register class
9
- * versions by calling {@link PucFactory::addVersion()}.
10
- *
11
- * At the moment it can only build instances of the UpdateChecker class. Other classes are
12
- * intended mainly for internal use and refer directly to specific implementations.
13
- */
14
- class Puc_v4_Factory {
15
- protected static $classVersions = array();
16
- protected static $sorted = false;
17
 
18
- protected static $myMajorVersion = '';
19
- protected static $latestCompatibleVersion = '';
20
-
21
- /**
22
- * Create a new instance of the update checker.
23
- *
24
- * This method automatically detects if you're using it for a plugin or a theme and chooses
25
- * the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
26
- *
27
- * @see Puc_v4_UpdateChecker::__construct
28
- *
29
- * @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
30
- * @param string $fullPath Full path to the main plugin file or to the theme directory.
31
- * @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
32
- * @param int $checkPeriod How often to check for updates (in hours).
33
- * @param string $optionName Where to store book-keeping info about update checks.
34
- * @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
35
- * @return Puc_v4_Plugin_UpdateChecker|Puc_v4_Theme_UpdateChecker|Puc_v4_Vcs_BaseChecker
36
- */
37
- public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
38
- $fullPath = wp_normalize_path($fullPath);
39
- $id = null;
40
-
41
- //Plugin or theme?
42
- $themeDirectory = self::getThemeDirectoryName($fullPath);
43
- if ( $themeDirectory !== null ) {
44
- $type = 'Theme';
45
- $id = $themeDirectory;
46
- } else if ( self::isPluginFile($fullPath) ) {
47
- $type = 'Plugin';
48
- $id = $fullPath;
49
- } else {
50
- throw new RuntimeException(sprintf(
51
- 'The update checker cannot determine if "%s" is a plugin or a theme. ' .
52
- 'This is a bug. Please contact the PUC developer.',
53
- htmlentities($fullPath)
54
- ));
55
- }
56
-
57
- //Which hosting service does the URL point to?
58
- $service = self::getVcsService($metadataUrl);
59
-
60
- $apiClass = null;
61
- if ( empty($service) ) {
62
- //The default is to get update information from a remote JSON file.
63
- $checkerClass = $type . '_UpdateChecker';
64
- } else {
65
- //You can also use a VCS repository like GitHub.
66
- $checkerClass = 'Vcs_' . $type . 'UpdateChecker';
67
- $apiClass = $service . 'Api';
68
- }
69
-
70
- $checkerClass = self::getCompatibleClassVersion($checkerClass);
71
- if ( $checkerClass === null ) {
72
- trigger_error(
73
- sprintf(
74
- 'PUC %s does not support updates for %ss %s',
75
- htmlentities(self::$latestCompatibleVersion),
76
- strtolower($type),
77
- $service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata'
78
- ),
79
- E_USER_ERROR
80
- );
81
- return null;
82
- }
83
-
84
- if ( !isset($apiClass) ) {
85
- //Plain old update checker.
86
- return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile);
87
- } else {
88
- //VCS checker + an API client.
89
- $apiClass = self::getCompatibleClassVersion($apiClass);
90
- if ( $apiClass === null ) {
91
- trigger_error(sprintf(
92
- 'PUC %s does not support %s',
93
- htmlentities(self::$latestCompatibleVersion),
94
- htmlentities($service)
95
- ), E_USER_ERROR);
96
- return null;
97
- }
98
-
99
- return new $checkerClass(
100
- new $apiClass($metadataUrl),
101
- $id,
102
- $slug,
103
- $checkPeriod,
104
- $optionName,
105
- $muPluginFile
106
- );
107
- }
108
- }
109
-
110
- /**
111
- * Check if the path points to a plugin file.
112
- *
113
- * @param string $absolutePath Normalized path.
114
- * @return bool
115
- */
116
- protected static function isPluginFile($absolutePath) {
117
- //Is the file inside the "plugins" or "mu-plugins" directory?
118
- $pluginDir = wp_normalize_path(WP_PLUGIN_DIR);
119
- $muPluginDir = wp_normalize_path(WPMU_PLUGIN_DIR);
120
- if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
121
- return true;
122
- }
123
-
124
- //Does it have a valid plugin header?
125
- //This is a last-ditch check for plugins symlinked from outside the WP root.
126
- if ( function_exists('get_file_data') ) {
127
- $headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin');
128
- return !empty($headers['Name']);
129
- }
130
-
131
- return false;
132
- }
133
-
134
- /**
135
- * Get the name of the theme's directory from a full path to any theme file.
136
- * E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo".
137
- *
138
- * @param string $absolutePath Normalized path.
139
- * @return string|null Directory name, or NULL if the path doesn't point to a theme.
140
- */
141
- protected static function getThemeDirectoryName($absolutePath) {
142
- $themeRoot = wp_normalize_path(get_theme_root());
143
- if ( strpos($absolutePath, $themeRoot) !== 0 ) {
144
- return null;
145
- }
146
-
147
- $pathComponents = explode('/', substr($absolutePath, strlen($themeRoot) + 1));
148
- if ( !is_array($pathComponents) || !isset($pathComponents[0]) ) {
149
- return null;
150
- }
151
- return $pathComponents[0];
152
- }
153
-
154
- /**
155
- * Get the name of the hosting service that the URL points to.
156
- *
157
- * @param string $metadataUrl
158
- * @return string|null
159
- */
160
- private static function getVcsService($metadataUrl) {
161
- $service = null;
162
-
163
- //Which hosting service does the URL point to?
164
- $host = @parse_url($metadataUrl, PHP_URL_HOST);
165
- $path = @parse_url($metadataUrl, PHP_URL_PATH);
166
- //Check if the path looks like "/user-name/repository".
167
- $usernameRepoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@';
168
- if ( preg_match($usernameRepoRegex, $path) ) {
169
- $knownServices = array(
170
- 'github.com' => 'GitHub',
171
- 'bitbucket.org' => 'BitBucket',
172
- 'gitlab.com' => 'GitLab',
173
- );
174
- if ( isset($knownServices[$host]) ) {
175
- $service = $knownServices[$host];
176
- }
177
- }
178
-
179
- return $service;
180
- }
181
-
182
- /**
183
- * Get the latest version of the specified class that has the same major version number
184
- * as this factory class.
185
- *
186
- * @param string $class Partial class name.
187
- * @return string|null Full class name.
188
- */
189
- protected static function getCompatibleClassVersion($class) {
190
- if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) {
191
- return self::$classVersions[$class][self::$latestCompatibleVersion];
192
- }
193
- return null;
194
- }
195
-
196
- /**
197
- * Get the specific class name for the latest available version of a class.
198
- *
199
- * @param string $class
200
- * @return null|string
201
- */
202
- public static function getLatestClassVersion($class) {
203
- if ( !self::$sorted ) {
204
- self::sortVersions();
205
- }
206
-
207
- if ( isset(self::$classVersions[$class]) ) {
208
- return reset(self::$classVersions[$class]);
209
- } else {
210
- return null;
211
- }
212
- }
213
-
214
- /**
215
- * Sort available class versions in descending order (i.e. newest first).
216
- */
217
- protected static function sortVersions() {
218
- foreach ( self::$classVersions as $class => $versions ) {
219
- uksort($versions, array(__CLASS__, 'compareVersions'));
220
- self::$classVersions[$class] = $versions;
221
- }
222
- self::$sorted = true;
223
- }
224
-
225
- protected static function compareVersions($a, $b) {
226
- return -version_compare($a, $b);
227
- }
228
-
229
- /**
230
- * Register a version of a class.
231
- *
232
- * @access private This method is only for internal use by the library.
233
- *
234
- * @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'.
235
- * @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'.
236
- * @param string $version Version number, e.g. '1.2'.
237
- */
238
- public static function addVersion($generalClass, $versionedClass, $version) {
239
- if ( empty(self::$myMajorVersion) ) {
240
- $nameParts = explode('_', __CLASS__, 3);
241
- self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
242
- }
243
-
244
- //Store the greatest version number that matches our major version.
245
- $components = explode('.', $version);
246
- if ( $components[0] === self::$myMajorVersion ) {
247
-
248
- if (
249
- empty(self::$latestCompatibleVersion)
250
- || version_compare($version, self::$latestCompatibleVersion, '>')
251
- ) {
252
- self::$latestCompatibleVersion = $version;
253
- }
254
-
255
- }
256
-
257
- if ( !isset(self::$classVersions[$generalClass]) ) {
258
- self::$classVersions[$generalClass] = array();
259
- }
260
- self::$classVersions[$generalClass][$version] = $versionedClass;
261
- self::$sorted = false;
262
- }
263
- }
264
-
265
- endif;
1
  <?php
2
  if ( !class_exists('Puc_v4_Factory', false) ):
3
 
4
+ class Puc_v4_Factory extends Puc_v4p7_Factory { }
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ endif;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Autoloader.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Autoloader', false) ):
4
+
5
+ class Puc_v4p7_Autoloader {
6
+ private $prefix = '';
7
+ private $rootDir = '';
8
+ private $libraryDir = '';
9
+
10
+ private $staticMap;
11
+
12
+ public function __construct() {
13
+ $this->rootDir = dirname(__FILE__) . '/';
14
+ $nameParts = explode('_', __CLASS__, 3);
15
+ $this->prefix = $nameParts[0] . '_' . $nameParts[1] . '_';
16
+
17
+ $this->libraryDir = realpath($this->rootDir . '../..') . '/';
18
+ $this->staticMap = array(
19
+ 'PucReadmeParser' => 'vendor/readme-parser.php',
20
+ 'Parsedown' => 'vendor/ParsedownLegacy.php',
21
+ );
22
+ if ( version_compare(PHP_VERSION, '5.3.0', '>=') ) {
23
+ $this->staticMap['Parsedown'] = 'vendor/Parsedown.php';
24
+ }
25
+
26
+ spl_autoload_register(array($this, 'autoload'));
27
+ }
28
+
29
+ public function autoload($className) {
30
+ if ( isset($this->staticMap[$className]) && file_exists($this->libraryDir . $this->staticMap[$className]) ) {
31
+ /** @noinspection PhpIncludeInspection */
32
+ include ($this->libraryDir . $this->staticMap[$className]);
33
+ return;
34
+ }
35
+
36
+ if (strpos($className, $this->prefix) === 0) {
37
+ $path = substr($className, strlen($this->prefix));
38
+ $path = str_replace('_', '/', $path);
39
+ $path = $this->rootDir . $path . '.php';
40
+
41
+ if (file_exists($path)) {
42
+ /** @noinspection PhpIncludeInspection */
43
+ include $path;
44
+ }
45
+ }
46
+ }
47
+ }
48
+
49
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Extension.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_DebugBar_Extension', false) ):
3
+
4
+ class Puc_v4p7_DebugBar_Extension {
5
+ const RESPONSE_BODY_LENGTH_LIMIT = 4000;
6
+
7
+ /** @var Puc_v4p7_UpdateChecker */
8
+ protected $updateChecker;
9
+ protected $panelClass = 'Puc_v4p7_DebugBar_Panel';
10
+
11
+ public function __construct($updateChecker, $panelClass = null) {
12
+ $this->updateChecker = $updateChecker;
13
+ if ( isset($panelClass) ) {
14
+ $this->panelClass = $panelClass;
15
+ }
16
+
17
+ add_filter('debug_bar_panels', array($this, 'addDebugBarPanel'));
18
+ add_action('debug_bar_enqueue_scripts', array($this, 'enqueuePanelDependencies'));
19
+
20
+ add_action('wp_ajax_puc_v4_debug_check_now', array($this, 'ajaxCheckNow'));
21
+ }
22
+
23
+ /**
24
+ * Register the PUC Debug Bar panel.
25
+ *
26
+ * @param array $panels
27
+ * @return array
28
+ */
29
+ public function addDebugBarPanel($panels) {
30
+ if ( $this->updateChecker->userCanInstallUpdates() ) {
31
+ $panels[] = new $this->panelClass($this->updateChecker);
32
+ }
33
+ return $panels;
34
+ }
35
+
36
+ /**
37
+ * Enqueue our Debug Bar scripts and styles.
38
+ */
39
+ public function enqueuePanelDependencies() {
40
+ wp_enqueue_style(
41
+ 'puc-debug-bar-style-v4',
42
+ $this->getLibraryUrl("/css/puc-debug-bar.css"),
43
+ array('debug-bar'),
44
+ '20171124'
45
+ );
46
+
47
+ wp_enqueue_script(
48
+ 'puc-debug-bar-js-v4',
49
+ $this->getLibraryUrl("/js/debug-bar.js"),
50
+ array('jquery'),
51
+ '20170516'
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Run an update check and output the result. Useful for making sure that
57
+ * the update checking process works as expected.
58
+ */
59
+ public function ajaxCheckNow() {
60
+ if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
61
+ return;
62
+ }
63
+ $this->preAjaxRequest();
64
+ $update = $this->updateChecker->checkForUpdates();
65
+ if ( $update !== null ) {
66
+ echo "An update is available:";
67
+ echo '<pre>', htmlentities(print_r($update, true)), '</pre>';
68
+ } else {
69
+ echo 'No updates found.';
70
+ }
71
+
72
+ $errors = $this->updateChecker->getLastRequestApiErrors();
73
+ if ( !empty($errors) ) {
74
+ printf('<p>The update checker encountered %d API error%s.</p>', count($errors), (count($errors) > 1) ? 's' : '');
75
+
76
+ foreach (array_values($errors) as $num => $item) {
77
+ $wpError = $item['error'];
78
+ /** @var WP_Error $wpError */
79
+ printf('<h4>%d) %s</h4>', $num + 1, esc_html($wpError->get_error_message()));
80
+
81
+ echo '<dl>';
82
+ printf('<dt>Error code:</dt><dd><code>%s</code></dd>', esc_html($wpError->get_error_code()));
83
+
84
+ if ( isset($item['url']) ) {
85
+ printf('<dt>Requested URL:</dt><dd><code>%s</code></dd>', esc_html($item['url']));
86
+ }
87
+
88
+ if ( isset($item['httpResponse']) ) {
89
+ if ( is_wp_error($item['httpResponse']) ) {
90
+ $httpError = $item['httpResponse'];
91
+ /** @var WP_Error $httpError */
92
+ printf(
93
+ '<dt>WordPress HTTP API error:</dt><dd>%s (<code>%s</code>)</dd>',
94
+ esc_html($httpError->get_error_message()),
95
+ esc_html($httpError->get_error_code())
96
+ );
97
+ } else {
98
+ //Status code.
99
+ printf(
100
+ '<dt>HTTP status:</dt><dd><code>%d %s</code></dd>',
101
+ wp_remote_retrieve_response_code($item['httpResponse']),
102
+ wp_remote_retrieve_response_message($item['httpResponse'])
103
+ );
104
+
105
+ //Headers.
106
+ echo '<dt>Response headers:</dt><dd><pre>';
107
+ foreach (wp_remote_retrieve_headers($item['httpResponse']) as $name => $value) {
108
+ printf("%s: %s\n", esc_html($name), esc_html($value));
109
+ }
110
+ echo '</pre></dd>';
111
+
112
+ //Body.
113
+ $body = wp_remote_retrieve_body($item['httpResponse']);
114
+ if ( $body === '' ) {
115
+ $body = '(Empty response.)';
116
+ } else if ( strlen($body) > self::RESPONSE_BODY_LENGTH_LIMIT ) {
117
+ $length = strlen($body);
118
+ $body = substr($body, 0, self::RESPONSE_BODY_LENGTH_LIMIT)
119
+ . sprintf("\n(Long string truncated. Total length: %d bytes.)", $length);
120
+ }
121
+
122
+ printf('<dt>Response body:</dt><dd><pre>%s</pre></dd>', esc_html($body));
123
+ }
124
+ }
125
+ echo '<dl>';
126
+ }
127
+ }
128
+
129
+ exit;
130
+ }
131
+
132
+ /**
133
+ * Check access permissions and enable error display (for debugging).
134
+ */
135
+ protected function preAjaxRequest() {
136
+ if ( !$this->updateChecker->userCanInstallUpdates() ) {
137
+ die('Access denied');
138
+ }
139
+ check_ajax_referer('puc-ajax');
140
+
141
+ error_reporting(E_ALL);
142
+ @ini_set('display_errors', 'On');
143
+ }
144
+
145
+ /**
146
+ * @param string $filePath
147
+ * @return string
148
+ */
149
+ private function getLibraryUrl($filePath) {
150
+ $absolutePath = realpath(dirname(__FILE__) . '/../../../' . ltrim($filePath, '/'));
151
+
152
+ //Where is the library located inside the WordPress directory structure?
153
+ $absolutePath = Puc_v4p7_Factory::normalizePath($absolutePath);
154
+
155
+ $pluginDir = Puc_v4p7_Factory::normalizePath(WP_PLUGIN_DIR);
156
+ $muPluginDir = Puc_v4p7_Factory::normalizePath(WPMU_PLUGIN_DIR);
157
+ $themeDir = Puc_v4p7_Factory::normalizePath(get_theme_root());
158
+
159
+ if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
160
+ //It's part of a plugin.
161
+ return plugins_url(basename($absolutePath), $absolutePath);
162
+ } else if ( strpos($absolutePath, $themeDir) === 0 ) {
163
+ //It's part of a theme.
164
+ $relativePath = substr($absolutePath, strlen($themeDir) + 1);
165
+ $template = substr($relativePath, 0, strpos($relativePath, '/'));
166
+ $baseUrl = get_theme_root_uri($template);
167
+
168
+ if ( !empty($baseUrl) && $relativePath ) {
169
+ return $baseUrl . '/' . $relativePath;
170
+ }
171
+ }
172
+
173
+ return '';
174
+ }
175
+ }
176
+
177
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/Panel.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_DebugBar_Panel', false) && class_exists('Debug_Bar_Panel', false) ):
4
+
5
+ class Puc_v4p7_DebugBar_Panel extends Debug_Bar_Panel {
6
+ /** @var Puc_v4p7_UpdateChecker */
7
+ protected $updateChecker;
8
+
9
+ private $responseBox = '<div class="puc-ajax-response" style="display: none;"></div>';
10
+
11
+ public function __construct($updateChecker) {
12
+ $this->updateChecker = $updateChecker;
13
+ $title = sprintf(
14
+ '<span class="puc-debug-menu-link-%s">PUC (%s)</span>',
15
+ esc_attr($this->updateChecker->getUniqueName('uid')),
16
+ $this->updateChecker->slug
17
+ );
18
+ parent::__construct($title);
19
+ }
20
+
21
+ public function render() {
22
+ printf(
23
+ '<div class="puc-debug-bar-panel-v4" id="%1$s" data-slug="%2$s" data-uid="%3$s" data-nonce="%4$s">',
24
+ esc_attr($this->updateChecker->getUniqueName('debug-bar-panel')),
25
+ esc_attr($this->updateChecker->slug),
26
+ esc_attr($this->updateChecker->getUniqueName('uid')),
27
+ esc_attr(wp_create_nonce('puc-ajax'))
28
+ );
29
+
30
+ $this->displayConfiguration();
31
+ $this->displayStatus();
32
+ $this->displayCurrentUpdate();
33
+
34
+ echo '</div>';
35
+ }
36
+
37
+ private function displayConfiguration() {
38
+ echo '<h3>Configuration</h3>';
39
+ echo '<table class="puc-debug-data">';
40
+ $this->displayConfigHeader();
41
+ $this->row('Slug', htmlentities($this->updateChecker->slug));
42
+ $this->row('DB option', htmlentities($this->updateChecker->optionName));
43
+
44
+ $requestInfoButton = $this->getMetadataButton();
45
+ $this->row('Metadata URL', htmlentities($this->updateChecker->metadataUrl) . ' ' . $requestInfoButton . $this->responseBox);
46
+
47
+ $scheduler = $this->updateChecker->scheduler;
48
+ if ( $scheduler->checkPeriod > 0 ) {
49
+ $this->row('Automatic checks', 'Every ' . $scheduler->checkPeriod . ' hours');
50
+ } else {
51
+ $this->row('Automatic checks', 'Disabled');
52
+ }
53
+
54
+ if ( isset($scheduler->throttleRedundantChecks) ) {
55
+ if ( $scheduler->throttleRedundantChecks && ($scheduler->checkPeriod > 0) ) {
56
+ $this->row(
57
+ 'Throttling',
58
+ sprintf(
59
+ 'Enabled. If an update is already available, check for updates every %1$d hours instead of every %2$d hours.',
60
+ $scheduler->throttledCheckPeriod,
61
+ $scheduler->checkPeriod
62
+ )
63
+ );
64
+ } else {
65
+ $this->row('Throttling', 'Disabled');
66
+ }
67
+ }
68
+
69
+ $this->updateChecker->onDisplayConfiguration($this);
70
+
71
+ echo '</table>';
72
+ }
73
+
74
+ protected function displayConfigHeader() {
75
+ //Do nothing. This should be implemented in subclasses.
76
+ }
77
+
78
+ protected function getMetadataButton() {
79
+ return '';
80
+ }
81
+
82
+ private function displayStatus() {
83
+ echo '<h3>Status</h3>';
84
+ echo '<table class="puc-debug-data">';
85
+ $state = $this->updateChecker->getUpdateState();
86
+ $checkNowButton = '';
87
+ if ( function_exists('get_submit_button') ) {
88
+ $checkNowButton = get_submit_button(
89
+ 'Check Now',
90
+ 'secondary',
91
+ 'puc-check-now-button',
92
+ false,
93
+ array('id' => $this->updateChecker->getUniqueName('check-now-button'))
94
+ );
95
+ }
96
+
97
+ if ( $state->getLastCheck() > 0 ) {
98
+ $this->row('Last check', $this->formatTimeWithDelta($state->getLastCheck()) . ' ' . $checkNowButton . $this->responseBox);
99
+ } else {
100
+ $this->row('Last check', 'Never');
101
+ }
102
+
103
+ $nextCheck = wp_next_scheduled($this->updateChecker->scheduler->getCronHookName());
104
+ $this->row('Next automatic check', $this->formatTimeWithDelta($nextCheck));
105
+
106
+ if ( $state->getCheckedVersion() !== '' ) {
107
+ $this->row('Checked version', htmlentities($state->getCheckedVersion()));
108
+ $this->row('Cached update', $state->getUpdate());
109
+ }
110
+ $this->row('Update checker class', htmlentities(get_class($this->updateChecker)));
111
+ echo '</table>';
112
+ }
113
+
114
+ private function displayCurrentUpdate() {
115
+ $update = $this->updateChecker->getUpdate();
116
+ if ( $update !== null ) {
117
+ echo '<h3>An Update Is Available</h3>';
118
+ echo '<table class="puc-debug-data">';
119
+ $fields = $this->getUpdateFields();
120
+ foreach($fields as $field) {
121
+ if ( property_exists($update, $field) ) {
122
+ $this->row(ucwords(str_replace('_', ' ', $field)), htmlentities($update->$field));
123
+ }
124
+ }
125
+ echo '</table>';
126
+ } else {
127
+ echo '<h3>No updates currently available</h3>';
128
+ }
129
+ }
130
+
131
+ protected function getUpdateFields() {
132
+ return array('version', 'download_url', 'slug',);
133
+ }
134
+
135
+ private function formatTimeWithDelta($unixTime) {
136
+ if ( empty($unixTime) ) {
137
+ return 'Never';
138
+ }
139
+
140
+ $delta = time() - $unixTime;
141
+ $result = human_time_diff(time(), $unixTime);
142
+ if ( $delta < 0 ) {
143
+ $result = 'after ' . $result;
144
+ } else {
145
+ $result = $result . ' ago';
146
+ }
147
+ $result .= ' (' . $this->formatTimestamp($unixTime) . ')';
148
+ return $result;
149
+ }
150
+
151
+ private function formatTimestamp($unixTime) {
152
+ return gmdate('Y-m-d H:i:s', $unixTime + (get_option('gmt_offset') * 3600));
153
+ }
154
+
155
+ public function row($name, $value) {
156
+ if ( is_object($value) || is_array($value) ) {
157
+ $value = '<pre>' . htmlentities(print_r($value, true)) . '</pre>';
158
+ } else if ($value === null) {
159
+ $value = '<code>null</code>';
160
+ }
161
+ printf('<tr><th scope="row">%1$s</th> <td>%2$s</td></tr>', $name, $value);
162
+ }
163
+ }
164
+
165
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginExtension.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_DebugBar_PluginExtension', false) ):
3
+
4
+ class Puc_v4p7_DebugBar_PluginExtension extends Puc_v4p7_DebugBar_Extension {
5
+ /** @var Puc_v4p7_Plugin_UpdateChecker */
6
+ protected $updateChecker;
7
+
8
+ public function __construct($updateChecker) {
9
+ parent::__construct($updateChecker, 'Puc_v4p7_DebugBar_PluginPanel');
10
+
11
+ add_action('wp_ajax_puc_v4_debug_request_info', array($this, 'ajaxRequestInfo'));
12
+ }
13
+
14
+ /**
15
+ * Request plugin info and output it.
16
+ */
17
+ public function ajaxRequestInfo() {
18
+ if ( $_POST['uid'] !== $this->updateChecker->getUniqueName('uid') ) {
19
+ return;
20
+ }
21
+ $this->preAjaxRequest();
22
+ $info = $this->updateChecker->requestInfo();
23
+ if ( $info !== null ) {
24
+ echo 'Successfully retrieved plugin info from the metadata URL:';
25
+ echo '<pre>', htmlentities(print_r($info, true)), '</pre>';
26
+ } else {
27
+ echo 'Failed to retrieve plugin info from the metadata URL.';
28
+ }
29
+ exit;
30
+ }
31
+ }
32
+
33
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/PluginPanel.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_DebugBar_PluginPanel', false) ):
4
+
5
+ class Puc_v4p7_DebugBar_PluginPanel extends Puc_v4p7_DebugBar_Panel {
6
+ /**
7
+ * @var Puc_v4p7_Plugin_UpdateChecker
8
+ */
9
+ protected $updateChecker;
10
+
11
+ protected function displayConfigHeader() {
12
+ $this->row('Plugin file', htmlentities($this->updateChecker->pluginFile));
13
+ parent::displayConfigHeader();
14
+ }
15
+
16
+ protected function getMetadataButton() {
17
+ $requestInfoButton = '';
18
+ if ( function_exists('get_submit_button') ) {
19
+ $requestInfoButton = get_submit_button(
20
+ 'Request Info',
21
+ 'secondary',
22
+ 'puc-request-info-button',
23
+ false,
24
+ array('id' => $this->updateChecker->getUniqueName('request-info-button'))
25
+ );
26
+ }
27
+ return $requestInfoButton;
28
+ }
29
+
30
+ protected function getUpdateFields() {
31
+ return array_merge(
32
+ parent::getUpdateFields(),
33
+ array('homepage', 'upgrade_notice', 'tested',)
34
+ );
35
+ }
36
+ }
37
+
38
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/DebugBar/ThemePanel.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_DebugBar_ThemePanel', false) ):
4
+
5
+ class Puc_v4p7_DebugBar_ThemePanel extends Puc_v4p7_DebugBar_Panel {
6
+ /**
7
+ * @var Puc_v4p7_Theme_UpdateChecker
8
+ */
9
+ protected $updateChecker;
10
+
11
+ protected function displayConfigHeader() {
12
+ $this->row('Theme directory', htmlentities($this->updateChecker->directoryName));
13
+ parent::displayConfigHeader();
14
+ }
15
+
16
+ protected function getUpdateFields() {
17
+ return array_merge(parent::getUpdateFields(), array('details_url'));
18
+ }
19
+ }
20
+
21
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Factory.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Factory', false) ):
3
+
4
+ /**
5
+ * A factory that builds update checker instances.
6
+ *
7
+ * When multiple versions of the same class have been loaded (e.g. PluginUpdateChecker 4.0
8
+ * and 4.1), this factory will always use the latest available minor version. Register class
9
+ * versions by calling {@link PucFactory::addVersion()}.
10
+ *
11
+ * At the moment it can only build instances of the UpdateChecker class. Other classes are
12
+ * intended mainly for internal use and refer directly to specific implementations.
13
+ */
14
+ class Puc_v4p7_Factory {
15
+ protected static $classVersions = array();
16
+ protected static $sorted = false;
17
+
18
+ protected static $myMajorVersion = '';
19
+ protected static $latestCompatibleVersion = '';
20
+
21
+ /**
22
+ * Create a new instance of the update checker.
23
+ *
24
+ * This method automatically detects if you're using it for a plugin or a theme and chooses
25
+ * the appropriate implementation for your update source (JSON file, GitHub, BitBucket, etc).
26
+ *
27
+ * @see Puc_v4p7_UpdateChecker::__construct
28
+ *
29
+ * @param string $metadataUrl The URL of the metadata file, a GitHub repository, or another supported update source.
30
+ * @param string $fullPath Full path to the main plugin file or to the theme directory.
31
+ * @param string $slug Custom slug. Defaults to the name of the main plugin file or the theme directory.
32
+ * @param int $checkPeriod How often to check for updates (in hours).
33
+ * @param string $optionName Where to store book-keeping info about update checks.
34
+ * @param string $muPluginFile The plugin filename relative to the mu-plugins directory.
35
+ * @return Puc_v4p7_Plugin_UpdateChecker|Puc_v4p7_Theme_UpdateChecker|Puc_v4p7_Vcs_BaseChecker
36
+ */
37
+ public static function buildUpdateChecker($metadataUrl, $fullPath, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
38
+ $fullPath = self::normalizePath($fullPath);
39
+ $id = null;
40
+
41
+ //Plugin or theme?
42
+ $themeDirectory = self::getThemeDirectoryName($fullPath);
43
+ if ( self::isPluginFile($fullPath) ) {
44
+ $type = 'Plugin';
45
+ $id = $fullPath;
46
+ } else if ( $themeDirectory !== null ) {
47
+ $type = 'Theme';
48
+ $id = $themeDirectory;
49
+ } else {
50
+ throw new RuntimeException(sprintf(
51
+ 'The update checker cannot determine if "%s" is a plugin or a theme. ' .
52
+ 'This is a bug. Please contact the PUC developer.',
53
+ htmlentities($fullPath)
54
+ ));
55
+ }
56
+
57
+ //Which hosting service does the URL point to?
58
+ $service = self::getVcsService($metadataUrl);
59
+
60
+ $apiClass = null;
61
+ if ( empty($service) ) {
62
+ //The default is to get update information from a remote JSON file.
63
+ $checkerClass = $type . '_UpdateChecker';
64
+ } else {
65
+ //You can also use a VCS repository like GitHub.
66
+ $checkerClass = 'Vcs_' . $type . 'UpdateChecker';
67
+ $apiClass = $service . 'Api';
68
+ }
69
+
70
+ $checkerClass = self::getCompatibleClassVersion($checkerClass);
71
+ if ( $checkerClass === null ) {
72
+ trigger_error(
73
+ sprintf(
74
+ 'PUC %s does not support updates for %ss %s',
75
+ htmlentities(self::$latestCompatibleVersion),
76
+ strtolower($type),
77
+ $service ? ('hosted on ' . htmlentities($service)) : 'using JSON metadata'
78
+ ),
79
+ E_USER_ERROR
80
+ );
81
+ return null;
82
+ }
83
+
84
+ if ( !isset($apiClass) ) {
85
+ //Plain old update checker.
86
+ return new $checkerClass($metadataUrl, $id, $slug, $checkPeriod, $optionName, $muPluginFile);
87
+ } else {
88
+ //VCS checker + an API client.
89
+ $apiClass = self::getCompatibleClassVersion($apiClass);
90
+ if ( $apiClass === null ) {
91
+ trigger_error(sprintf(
92
+ 'PUC %s does not support %s',
93
+ htmlentities(self::$latestCompatibleVersion),
94
+ htmlentities($service)
95
+ ), E_USER_ERROR);
96
+ return null;
97
+ }
98
+
99
+ return new $checkerClass(
100
+ new $apiClass($metadataUrl),
101
+ $id,
102
+ $slug,
103
+ $checkPeriod,
104
+ $optionName,
105
+ $muPluginFile
106
+ );
107
+ }
108
+ }
109
+
110
+ /**
111
+ *
112
+ * Normalize a filesystem path. Introduced in WP 3.9.
113
+ * Copying here allows use of the class on earlier versions.
114
+ * This version adapted from WP 4.8.2 (unchanged since 4.5.0)
115
+ *
116
+ * @param string $path Path to normalize.
117
+ * @return string Normalized path.
118
+ */
119
+ public static function normalizePath($path) {
120
+ if ( function_exists('wp_normalize_path') ) {
121
+ return wp_normalize_path($path);
122
+ }
123
+ $path = str_replace('\\', '/', $path);
124
+ $path = preg_replace('|(?<=.)/+|', '/', $path);
125
+ if ( substr($path, 1, 1) === ':' ) {
126
+ $path = ucfirst($path);
127
+ }
128
+ return $path;
129
+ }
130
+
131
+ /**
132
+ * Check if the path points to a plugin file.
133
+ *
134
+ * @param string $absolutePath Normalized path.
135
+ * @return bool
136
+ */
137
+ protected static function isPluginFile($absolutePath) {
138
+ //Is the file inside the "plugins" or "mu-plugins" directory?
139
+ $pluginDir = self::normalizePath(WP_PLUGIN_DIR);
140
+ $muPluginDir = self::normalizePath(WPMU_PLUGIN_DIR);
141
+ if ( (strpos($absolutePath, $pluginDir) === 0) || (strpos($absolutePath, $muPluginDir) === 0) ) {
142
+ return true;
143
+ }
144
+
145
+ //Is it a file at all? Caution: is_file() can fail if the parent dir. doesn't have the +x permission set.
146
+ if ( !is_file($absolutePath) ) {
147
+ return false;
148
+ }
149
+
150
+ //Does it have a valid plugin header?
151
+ //This is a last-ditch check for plugins symlinked from outside the WP root.
152
+ if ( function_exists('get_file_data') ) {
153
+ $headers = get_file_data($absolutePath, array('Name' => 'Plugin Name'), 'plugin');
154
+ return !empty($headers['Name']);
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ /**
161
+ * Get the name of the theme's directory from a full path to a file inside that directory.
162
+ * E.g. "/abc/public_html/wp-content/themes/foo/whatever.php" => "foo".
163
+ *
164
+ * Note that subdirectories are currently not supported. For example,
165
+ * "/xyz/wp-content/themes/my-theme/includes/whatever.php" => NULL.
166
+ *
167
+ * @param string $absolutePath Normalized path.
168
+ * @return string|null Directory name, or NULL if the path doesn't point to a theme.
169
+ */
170
+ protected static function getThemeDirectoryName($absolutePath) {
171
+ if ( is_file($absolutePath) ) {
172
+ $absolutePath = dirname($absolutePath);
173
+ }
174
+
175
+ if ( file_exists($absolutePath . '/style.css') ) {
176
+ return basename($absolutePath);
177
+ }
178
+ return null;
179
+ }
180
+
181
+ /**
182
+ * Get the name of the hosting service that the URL points to.
183
+ *
184
+ * @param string $metadataUrl
185
+ * @return string|null
186
+ */
187
+ private static function getVcsService($metadataUrl) {
188
+ $service = null;
189
+
190
+ //Which hosting service does the URL point to?
191
+ $host = parse_url($metadataUrl, PHP_URL_HOST);
192
+ $path = parse_url($metadataUrl, PHP_URL_PATH);
193
+
194
+ //Check if the path looks like "/user-name/repository".
195
+ //For GitLab.com it can also be "/user/group1/group2/.../repository".
196
+ $repoRegex = '@^/?([^/]+?)/([^/#?&]+?)/?$@';
197
+ if ( $host === 'gitlab.com' ) {
198
+ $repoRegex = '@^/?(?:[^/#?&]++/){1,20}(?:[^/#?&]++)/?$@';
199
+ }
200
+ if ( preg_match($repoRegex, $path) ) {
201
+ $knownServices = array(
202
+ 'github.com' => 'GitHub',
203
+ 'bitbucket.org' => 'BitBucket',
204
+ 'gitlab.com' => 'GitLab',
205
+ );
206
+ if ( isset($knownServices[$host]) ) {
207
+ $service = $knownServices[$host];
208
+ }
209
+ }
210
+
211
+ return apply_filters('puc_get_vcs_service', $service, $host, $path, $metadataUrl);
212
+ }
213
+
214
+ /**
215
+ * Get the latest version of the specified class that has the same major version number
216
+ * as this factory class.
217
+ *
218
+ * @param string $class Partial class name.
219
+ * @return string|null Full class name.
220
+ */
221
+ protected static function getCompatibleClassVersion($class) {
222
+ if ( isset(self::$classVersions[$class][self::$latestCompatibleVersion]) ) {
223
+ return self::$classVersions[$class][self::$latestCompatibleVersion];
224
+ }
225
+ return null;
226
+ }
227
+
228
+ /**
229
+ * Get the specific class name for the latest available version of a class.
230
+ *
231
+ * @param string $class
232
+ * @return null|string
233
+ */
234
+ public static function getLatestClassVersion($class) {
235
+ if ( !self::$sorted ) {
236
+ self::sortVersions();
237
+ }
238
+
239
+ if ( isset(self::$classVersions[$class]) ) {
240
+ return reset(self::$classVersions[$class]);
241
+ } else {
242
+ return null;
243
+ }
244
+ }
245
+
246
+ /**
247
+ * Sort available class versions in descending order (i.e. newest first).
248
+ */
249
+ protected static function sortVersions() {
250
+ foreach ( self::$classVersions as $class => $versions ) {
251
+ uksort($versions, array(__CLASS__, 'compareVersions'));
252
+ self::$classVersions[$class] = $versions;
253
+ }
254
+ self::$sorted = true;
255
+ }
256
+
257
+ protected static function compareVersions($a, $b) {
258
+ return -version_compare($a, $b);
259
+ }
260
+
261
+ /**
262
+ * Register a version of a class.
263
+ *
264
+ * @access private This method is only for internal use by the library.
265
+ *
266
+ * @param string $generalClass Class name without version numbers, e.g. 'PluginUpdateChecker'.
267
+ * @param string $versionedClass Actual class name, e.g. 'PluginUpdateChecker_1_2'.
268
+ * @param string $version Version number, e.g. '1.2'.
269
+ */
270
+ public static function addVersion($generalClass, $versionedClass, $version) {
271
+ if ( empty(self::$myMajorVersion) ) {
272
+ $nameParts = explode('_', __CLASS__, 3);
273
+ self::$myMajorVersion = substr(ltrim($nameParts[1], 'v'), 0, 1);
274
+ }
275
+
276
+ //Store the greatest version number that matches our major version.
277
+ $components = explode('.', $version);
278
+ if ( $components[0] === self::$myMajorVersion ) {
279
+
280
+ if (
281
+ empty(self::$latestCompatibleVersion)
282
+ || version_compare($version, self::$latestCompatibleVersion, '>')
283
+ ) {
284
+ self::$latestCompatibleVersion = $version;
285
+ }
286
+
287
+ }
288
+
289
+ if ( !isset(self::$classVersions[$generalClass]) ) {
290
+ self::$classVersions[$generalClass] = array();
291
+ }
292
+ self::$classVersions[$generalClass][$version] = $versionedClass;
293
+ self::$sorted = false;
294
+ }
295
+ }
296
+
297
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/InstalledPackage.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_InstalledPackage', false) ):
3
+
4
+ /**
5
+ * This class represents a currently installed plugin or theme.
6
+ *
7
+ * Not to be confused with the "package" field in WP update API responses that contains
8
+ * the download URL of a the new version.
9
+ */
10
+ abstract class Puc_v4p7_InstalledPackage {
11
+ /**
12
+ * @var Puc_v4p7_UpdateChecker
13
+ */
14
+ protected $updateChecker;
15
+
16
+ public function __construct($updateChecker) {
17
+ $this->updateChecker = $updateChecker;
18
+ }
19
+
20
+ /**
21
+ * Get the currently installed version of the plugin or theme.
22
+ *
23
+ * @return string|null Version number.
24
+ */
25
+ abstract public function getInstalledVersion();
26
+
27
+ /**
28
+ * Get the full path of the plugin or theme directory (without a trailing slash).
29
+ *
30
+ * @return string
31
+ */
32
+ abstract public function getAbsoluteDirectoryPath();
33
+
34
+ /**
35
+ * Check whether a regular file exists in the package's directory.
36
+ *
37
+ * @param string $relativeFileName File name relative to the package directory.
38
+ * @return bool
39
+ */
40
+ public function fileExists($relativeFileName) {
41
+ return is_file(
42
+ $this->getAbsoluteDirectoryPath()
43
+ . DIRECTORY_SEPARATOR
44
+ . ltrim($relativeFileName, '/\\')
45
+ );
46
+ }
47
+
48
+ /* -------------------------------------------------------------------
49
+ * File header parsing
50
+ * -------------------------------------------------------------------
51
+ */
52
+
53
+ /**
54
+ * Parse plugin or theme metadata from the header comment.
55
+ *
56
+ * This is basically a simplified version of the get_file_data() function from /wp-includes/functions.php.
57
+ * It's intended as a utility for subclasses that detect updates by parsing files in a VCS.
58
+ *
59
+ * @param string|null $content File contents.
60
+ * @return string[]
61
+ */
62
+ public function getFileHeader($content) {
63
+ $content = (string)$content;
64
+
65
+ //WordPress only looks at the first 8 KiB of the file, so we do the same.
66
+ $content = substr($content, 0, 8192);
67
+ //Normalize line endings.
68
+ $content = str_replace("\r", "\n", $content);
69
+
70
+ $headers = $this->getHeaderNames();
71
+ $results = array();
72
+ foreach ($headers as $field => $name) {
73
+ $success = preg_match('/^[ \t\/*#@]*' . preg_quote($name, '/') . ':(.*)$/mi', $content, $matches);
74
+
75
+ if ( ($success === 1) && $matches[1] ) {
76
+ $value = $matches[1];
77
+ if ( function_exists('_cleanup_header_comment') ) {
78
+ $value = _cleanup_header_comment($value);
79
+ }
80
+ $results[$field] = $value;
81
+ } else {
82
+ $results[$field] = '';
83
+ }
84
+ }
85
+
86
+ return $results;
87
+ }
88
+
89
+ /**
90
+ * @return array Format: ['HeaderKey' => 'Header Name']
91
+ */
92
+ abstract protected function getHeaderNames();
93
+
94
+ /**
95
+ * Get the value of a specific plugin or theme header.
96
+ *
97
+ * @param string $headerName
98
+ * @return string Either the value of the header, or an empty string if the header doesn't exist.
99
+ */
100
+ abstract public function getHeaderValue($headerName);
101
+
102
+ }
103
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Metadata.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Metadata', false) ):
3
+
4
+ /**
5
+ * A base container for holding information about updates and plugin metadata.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ abstract class Puc_v4p7_Metadata {
12
+
13
+ /**
14
+ * Create an instance of this class from a JSON document.
15
+ *
16
+ * @abstract
17
+ * @param string $json
18
+ * @return self
19
+ */
20
+ public static function fromJson(/** @noinspection PhpUnusedParameterInspection */ $json) {
21
+ throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
22
+ }
23
+
24
+ /**
25
+ * @param string $json
26
+ * @param self $target
27
+ * @return bool
28
+ */
29
+ protected static function createFromJson($json, $target) {
30
+ /** @var StdClass $apiResponse */
31
+ $apiResponse = json_decode($json);
32
+ if ( empty($apiResponse) || !is_object($apiResponse) ){
33
+ $errorMessage = "Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/";
34
+ do_action('puc_api_error', new WP_Error('puc-invalid-json', $errorMessage));
35
+ trigger_error($errorMessage, E_USER_NOTICE);
36
+ return false;
37
+ }
38
+
39
+ $valid = $target->validateMetadata($apiResponse);
40
+ if ( is_wp_error($valid) ){
41
+ do_action('puc_api_error', $valid);
42
+ trigger_error($valid->get_error_message(), E_USER_NOTICE);
43
+ return false;
44
+ }
45
+
46
+ foreach(get_object_vars($apiResponse) as $key => $value){
47
+ $target->$key = $value;
48
+ }
49
+
50
+ return true;
51
+ }
52
+
53
+ /**
54
+ * No validation by default! Subclasses should check that the required fields are present.
55
+ *
56
+ * @param StdClass $apiResponse
57
+ * @return bool|WP_Error
58
+ */
59
+ protected function validateMetadata(/** @noinspection PhpUnusedParameterInspection */ $apiResponse) {
60
+ return true;
61
+ }
62
+
63
+ /**
64
+ * Create a new instance by copying the necessary fields from another object.
65
+ *
66
+ * @abstract
67
+ * @param StdClass|self $object The source object.
68
+ * @return self The new copy.
69
+ */
70
+ public static function fromObject(/** @noinspection PhpUnusedParameterInspection */ $object) {
71
+ throw new LogicException('The ' . __METHOD__ . ' method must be implemented by subclasses');
72
+ }
73
+
74
+ /**
75
+ * Create an instance of StdClass that can later be converted back to an
76
+ * update or info container. Useful for serialization and caching, as it
77
+ * avoids the "incomplete object" problem if the cached value is loaded
78
+ * before this class.
79
+ *
80
+ * @return StdClass
81
+ */
82
+ public function toStdClass() {
83
+ $object = new stdClass();
84
+ $this->copyFields($this, $object);
85
+ return $object;
86
+ }
87
+
88
+ /**
89
+ * Transform the metadata into the format used by WordPress core.
90
+ *
91
+ * @return object
92
+ */
93
+ abstract public function toWpFormat();
94
+
95
+ /**
96
+ * Copy known fields from one object to another.
97
+ *
98
+ * @param StdClass|self $from
99
+ * @param StdClass|self $to
100
+ */
101
+ protected function copyFields($from, $to) {
102
+ $fields = $this->getFieldNames();
103
+
104
+ if ( property_exists($from, 'slug') && !empty($from->slug) ) {
105
+ //Let plugins add extra fields without having to create subclasses.
106
+ $fields = apply_filters($this->getPrefixedFilter('retain_fields') . '-' . $from->slug, $fields);
107
+ }
108
+
109
+ foreach ($fields as $field) {
110
+ if ( property_exists($from, $field) ) {
111
+ $to->$field = $from->$field;
112
+ }
113
+ }
114
+ }
115
+
116
+ /**
117
+ * @return string[]
118
+ */
119
+ protected function getFieldNames() {
120
+ return array();
121
+ }
122
+
123
+ /**
124
+ * @param string $tag
125
+ * @return string
126
+ */
127
+ protected function getPrefixedFilter($tag) {
128
+ return 'puc_' . $tag;
129
+ }
130
+ }
131
+
132
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/OAuthSignature.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_OAuthSignature', false) ):
4
+
5
+ /**
6
+ * A basic signature generator for zero-legged OAuth 1.0.
7
+ */
8
+ class Puc_v4p7_OAuthSignature {
9
+ private $consumerKey = '';
10
+ private $consumerSecret = '';
11
+
12
+ public function __construct($consumerKey, $consumerSecret) {
13
+ $this->consumerKey = $consumerKey;
14
+ $this->consumerSecret = $consumerSecret;
15
+ }
16
+
17
+ /**
18
+ * Sign a URL using OAuth 1.0.
19
+ *
20
+ * @param string $url The URL to be signed. It may contain query parameters.
21
+ * @param string $method HTTP method such as "GET", "POST" and so on.
22
+ * @return string The signed URL.
23
+ */
24
+ public function sign($url, $method = 'GET') {
25
+ $parameters = array();
26
+
27
+ //Parse query parameters.
28
+ $query = parse_url($url, PHP_URL_QUERY);
29
+ if ( !empty($query) ) {
30
+ parse_str($query, $parsedParams);
31
+ if ( is_array($parameters) ) {
32
+ $parameters = $parsedParams;
33
+ }
34
+ //Remove the query string from the URL. We'll replace it later.
35
+ $url = substr($url, 0, strpos($url, '?'));
36
+ }
37
+
38
+ $parameters = array_merge(
39
+ $parameters,
40
+ array(
41
+ 'oauth_consumer_key' => $this->consumerKey,
42
+ 'oauth_nonce' => $this->nonce(),
43
+ 'oauth_signature_method' => 'HMAC-SHA1',
44
+ 'oauth_timestamp' => time(),
45
+ 'oauth_version' => '1.0',
46
+ )
47
+ );
48
+ unset($parameters['oauth_signature']);
49
+
50
+ //Parameters must be sorted alphabetically before signing.
51
+ ksort($parameters);
52
+
53
+ //The most complicated part of the request - generating the signature.
54
+ //The string to sign contains the HTTP method, the URL path, and all of
55
+ //our query parameters. Everything is URL encoded. Then we concatenate
56
+ //them with ampersands into a single string to hash.
57
+ $encodedVerb = urlencode($method);
58
+ $encodedUrl = urlencode($url);
59
+ $encodedParams = urlencode(http_build_query($parameters, '', '&'));
60
+
61
+ $stringToSign = $encodedVerb . '&' . $encodedUrl . '&' . $encodedParams;
62
+
63
+ //Since we only have one OAuth token (the consumer secret) we only have
64
+ //to use it as our HMAC key. However, we still have to append an & to it
65
+ //as if we were using it with additional tokens.
66
+ $secret = urlencode($this->consumerSecret) . '&';
67
+
68
+ //The signature is a hash of the consumer key and the base string. Note
69
+ //that we have to get the raw output from hash_hmac and base64 encode
70
+ //the binary data result.
71
+ $parameters['oauth_signature'] = base64_encode(hash_hmac('sha1', $stringToSign, $secret, true));
72
+
73
+ return ($url . '?' . http_build_query($parameters));
74
+ }
75
+
76
+ /**
77
+ * Generate a random nonce.
78
+ *
79
+ * @return string
80
+ */
81
+ private function nonce() {
82
+ $mt = microtime();
83
+
84
+ $rand = null;
85
+ if ( is_callable('random_bytes') ) {
86
+ try {
87
+ $rand = random_bytes(16);
88
+ } catch (Exception $ex) {
89
+ //Fall back to mt_rand (below).
90
+ }
91
+ }
92
+ if ( $rand === null ) {
93
+ $rand = mt_rand();
94
+ }
95
+
96
+ return md5($mt . '_' . $rand);
97
+ }
98
+ }
99
+
100
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Info.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Plugin_Info', false) ):
3
+
4
+ /**
5
+ * A container class for holding and transforming various plugin metadata.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ class Puc_v4p7_Plugin_Info extends Puc_v4p7_Metadata {
12
+ //Most fields map directly to the contents of the plugin's info.json file.
13
+ //See the relevant docs for a description of their meaning.
14
+ public $name;
15
+ public $slug;
16
+ public $version;
17
+ public $homepage;
18
+ public $sections = array();
19
+ public $download_url;
20
+
21
+ public $banners;
22
+ public $icons = array();
23
+ public $translations = array();
24
+
25
+ public $author;
26
+ public $author_homepage;
27
+
28
+ public $requires;
29
+ public $tested;
30
+ public $upgrade_notice;
31
+
32
+ public $rating;
33
+ public $num_ratings;
34
+ public $downloaded;
35
+ public $active_installs;
36
+ public $last_updated;
37
+
38
+ public $id = 0; //The native WP.org API returns numeric plugin IDs, but they're not used for anything.
39
+
40
+ public $filename; //Plugin filename relative to the plugins directory.
41
+
42
+ /**
43
+ * Create a new instance of Plugin Info from JSON-encoded plugin info
44
+ * returned by an external update API.
45
+ *
46
+ * @param string $json Valid JSON string representing plugin info.
47
+ * @return self|null New instance of Plugin Info, or NULL on error.
48
+ */
49
+ public static function fromJson($json){
50
+ $instance = new self();
51
+
52
+ if ( !parent::createFromJson($json, $instance) ) {
53
+ return null;
54
+ }
55
+
56
+ //json_decode decodes assoc. arrays as objects. We want them as arrays.
57
+ $instance->sections = (array)$instance->sections;
58
+ $instance->icons = (array)$instance->icons;
59
+
60
+ return $instance;
61
+ }
62
+
63
+ /**
64
+ * Very, very basic validation.
65
+ *
66
+ * @param StdClass $apiResponse
67
+ * @return bool|WP_Error
68
+ */
69
+ protected function validateMetadata($apiResponse) {
70
+ if (
71
+ !isset($apiResponse->name, $apiResponse->version)
72
+ || empty($apiResponse->name)
73
+ || empty($apiResponse->version)
74
+ ) {
75
+ /* Edited By Flycart starts here */
76
+ return false; //Added due to displaying error message while check update by Wordpress if name/version is not received in request response
77
+ /* Edited By Flycart Ends here */
78
+
79
+ return new WP_Error(
80
+ 'puc-invalid-metadata',
81
+ "The plugin metadata file does not contain the required 'name' and/or 'version' keys."
82
+ );
83
+ }
84
+ return true;
85
+ }
86
+
87
+
88
+ /**
89
+ * Transform plugin info into the format used by the native WordPress.org API
90
+ *
91
+ * @return object
92
+ */
93
+ public function toWpFormat(){
94
+ $info = new stdClass;
95
+
96
+ //The custom update API is built so that many fields have the same name and format
97
+ //as those returned by the native WordPress.org API. These can be assigned directly.
98
+ $sameFormat = array(
99
+ 'name', 'slug', 'version', 'requires', 'tested', 'rating', 'upgrade_notice',
100
+ 'num_ratings', 'downloaded', 'active_installs', 'homepage', 'last_updated',
101
+ );
102
+ foreach($sameFormat as $field){
103
+ if ( isset($this->$field) ) {
104
+ $info->$field = $this->$field;
105
+ } else {
106
+ $info->$field = null;
107
+ }
108
+ }
109
+
110
+ //Other fields need to be renamed and/or transformed.
111
+ $info->download_link = $this->download_url;
112
+ $info->author = $this->getFormattedAuthor();
113
+ $info->sections = array_merge(array('description' => ''), $this->sections);
114
+
115
+ if ( !empty($this->banners) ) {
116
+ //WP expects an array with two keys: "high" and "low". Both are optional.
117
+ //Docs: https://wordpress.org/plugins/about/faq/#banners
118
+ $info->banners = is_object($this->banners) ? get_object_vars($this->banners) : $this->banners;
119
+ $info->banners = array_intersect_key($info->banners, array('high' => true, 'low' => true));
120
+ }
121
+
122
+ return $info;
123
+ }
124
+
125
+ protected function getFormattedAuthor() {
126
+ if ( !empty($this->author_homepage) ){
127
+ /** @noinspection HtmlUnknownTarget */
128
+ return sprintf('<a href="%s">%s</a>', $this->author_homepage, $this->author);
129
+ }
130
+ return $this->author;
131
+ }
132
+ }
133
+
134
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Package.php ADDED
@@ -0,0 +1,184 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Plugin_Package', false) ):
3
+
4
+ class Puc_v4p7_Plugin_Package extends Puc_v4p7_InstalledPackage {
5
+ /**
6
+ * @var Puc_v4p7_Plugin_UpdateChecker
7
+ */
8
+ protected $updateChecker;
9
+
10
+ /**
11
+ * @var string Full path of the main plugin file.
12
+ */
13
+ protected $pluginAbsolutePath = '';
14
+
15
+ /**
16
+ * @var string Plugin basename.
17
+ */
18
+ private $pluginFile;
19
+
20
+ /**
21
+ * @var string|null
22
+ */
23
+ private $cachedInstalledVersion = null;
24
+
25
+ public function __construct($pluginAbsolutePath, $updateChecker) {
26
+ $this->pluginAbsolutePath = $pluginAbsolutePath;
27
+ $this->pluginFile = plugin_basename($this->pluginAbsolutePath);
28
+
29
+ parent::__construct($updateChecker);
30
+
31
+ //Clear the version number cache when something - anything - is upgraded or WP clears the update cache.
32
+ add_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
33
+ add_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
34
+ }
35
+
36
+ public function getInstalledVersion() {
37
+ if ( isset($this->cachedInstalledVersion) ) {
38
+ return $this->cachedInstalledVersion;
39
+ }
40
+
41
+ $pluginHeader = $this->getPluginHeader();
42
+ if ( isset($pluginHeader['Version']) ) {
43
+ $this->cachedInstalledVersion = $pluginHeader['Version'];
44
+ return $pluginHeader['Version'];
45
+ } else {
46
+ //This can happen if the filename points to something that is not a plugin.
47
+ $this->updateChecker->triggerError(
48
+ sprintf(
49
+ "Can't to read the Version header for '%s'. The filename is incorrect or is not a plugin.",
50
+ $this->updateChecker->pluginFile
51
+ ),
52
+ E_USER_WARNING
53
+ );
54
+ return null;
55
+ }
56
+ }
57
+
58
+ /**
59
+ * Clear the cached plugin version. This method can be set up as a filter (hook) and will
60
+ * return the filter argument unmodified.
61
+ *
62
+ * @param mixed $filterArgument
63
+ * @return mixed
64
+ */
65
+ public function clearCachedVersion($filterArgument = null) {
66
+ $this->cachedInstalledVersion = null;
67
+ return $filterArgument;
68
+ }
69
+
70
+ public function getAbsoluteDirectoryPath() {
71
+ return dirname($this->pluginAbsolutePath);
72
+ }
73
+
74
+ /**
75
+ * Get the value of a specific plugin or theme header.
76
+ *
77
+ * @param string $headerName
78
+ * @param string $defaultValue
79
+ * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
80
+ */
81
+ public function getHeaderValue($headerName, $defaultValue = '') {
82
+ $headers = $this->getPluginHeader();
83
+ if ( isset($headers[$headerName]) && ($headers[$headerName] !== '') ) {
84
+ return $headers[$headerName];
85
+ }
86
+ return $defaultValue;
87
+ }
88
+
89
+ protected function getHeaderNames() {
90
+ return array(
91
+ 'Name' => 'Plugin Name',
92
+ 'PluginURI' => 'Plugin URI',
93
+ 'Version' => 'Version',
94
+ 'Description' => 'Description',
95
+ 'Author' => 'Author',
96
+ 'AuthorURI' => 'Author URI',
97
+ 'TextDomain' => 'Text Domain',
98
+ 'DomainPath' => 'Domain Path',
99
+ 'Network' => 'Network',
100
+
101
+ //The newest WordPress version that this plugin requires or has been tested with.
102
+ //We support several different formats for compatibility with other libraries.
103
+ 'Tested WP' => 'Tested WP',
104
+ 'Requires WP' => 'Requires WP',
105
+ 'Tested up to' => 'Tested up to',
106
+ 'Requires at least' => 'Requires at least',
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Get the translated plugin title.
112
+ *
113
+ * @return string
114
+ */
115
+ public function getPluginTitle() {
116
+ $title = '';
117
+ $header = $this->getPluginHeader();
118
+ if ( $header && !empty($header['Name']) && isset($header['TextDomain']) ) {
119
+ $title = translate($header['Name'], $header['TextDomain']);
120
+ }
121
+ return $title;
122
+ }
123
+
124
+ /**
125
+ * Get plugin's metadata from its file header.
126
+ *
127
+ * @return array
128
+ */
129
+ public function getPluginHeader() {
130
+ if ( !is_file($this->pluginAbsolutePath) ) {
131
+ //This can happen if the plugin filename is wrong.
132
+ $this->updateChecker->triggerError(
133
+ sprintf(
134
+ "Can't to read the plugin header for '%s'. The file does not exist.",
135
+ $this->updateChecker->pluginFile
136
+ ),
137
+ E_USER_WARNING
138
+ );
139
+ return array();
140
+ }
141
+
142
+ if ( !function_exists('get_plugin_data') ) {
143
+ /** @noinspection PhpIncludeInspection */
144
+ require_once(ABSPATH . '/wp-admin/includes/plugin.php');
145
+ }
146
+ return get_plugin_data($this->pluginAbsolutePath, false, false);
147
+ }
148
+
149
+ public function removeHooks() {
150
+ remove_filter('upgrader_post_install', array($this, 'clearCachedVersion'));
151
+ remove_action('delete_site_transient_update_plugins', array($this, 'clearCachedVersion'));
152
+ }
153
+
154
+ /**
155
+ * Check if the plugin file is inside the mu-plugins directory.
156
+ *
157
+ * @return bool
158
+ */
159
+ public function isMuPlugin() {
160
+ static $cachedResult = null;
161
+
162
+ if ( $cachedResult === null ) {
163
+ if ( !defined('WPMU_PLUGIN_DIR') || !is_string(WPMU_PLUGIN_DIR) ) {
164
+ $cachedResult = false;
165
+ return $cachedResult;
166
+ }
167
+
168
+ //Convert both paths to the canonical form before comparison.
169
+ $muPluginDir = realpath(WPMU_PLUGIN_DIR);
170
+ $pluginPath = realpath($this->pluginAbsolutePath);
171
+ //If realpath() fails, just normalize the syntax instead.
172
+ if (($muPluginDir === false) || ($pluginPath === false)) {
173
+ $muPluginDir = Puc_v4p7_Factory::normalizePath(WPMU_PLUGIN_DIR);
174
+ $pluginPath = Puc_v4p7_Factory::normalizePath($this->pluginAbsolutePath);
175
+ }
176
+
177
+ $cachedResult = (strpos($pluginPath, $muPluginDir) === 0);
178
+ }
179
+
180
+ return $cachedResult;
181
+ }
182
+ }
183
+
184
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Ui.php ADDED
@@ -0,0 +1,277 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Plugin_Ui', false) ):
3
+ /**
4
+ * Additional UI elements for plugins.
5
+ */
6
+ class Puc_v4p7_Plugin_Ui {
7
+ private $updateChecker;
8
+ private $manualCheckErrorTransient = '';
9
+
10
+ /**
11
+ * @param Puc_v4p7_Plugin_UpdateChecker $updateChecker
12
+ */
13
+ public function __construct($updateChecker) {
14
+ $this->updateChecker = $updateChecker;
15
+ $this->manualCheckErrorTransient = $this->updateChecker->getUniqueName('manual_check_errors');
16
+
17
+ add_action('admin_init', array($this, 'onAdminInit'));
18
+ }
19
+
20
+ public function onAdminInit() {
21
+ if ( $this->updateChecker->userCanInstallUpdates() ) {
22
+ $this->handleManualCheck();
23
+
24
+ add_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10, 3);
25
+ add_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10, 2);
26
+ add_action('all_admin_notices', array($this, 'displayManualCheckResult'));
27
+ }
28
+ }
29
+
30
+ /**
31
+ * Add a "View Details" link to the plugin row in the "Plugins" page. By default,
32
+ * the new link will appear before the "Visit plugin site" link (if present).
33
+ *
34
+ * You can change the link text by using the "puc_view_details_link-$slug" filter.
35
+ * Returning an empty string from the filter will disable the link.
36
+ *
37
+ * You can change the position of the link using the
38
+ * "puc_view_details_link_position-$slug" filter.
39
+ * Returning 'before' or 'after' will place the link immediately before/after
40
+ * the "Visit plugin site" link.
41
+ * Returning 'append' places the link after any existing links at the time of the hook.
42
+ * Returning 'replace' replaces the "Visit plugin site" link.
43
+ * Returning anything else disables the link when there is a "Visit plugin site" link.
44
+ *
45
+ * If there is no "Visit plugin site" link 'append' is always used!
46
+ *
47
+ * @param array $pluginMeta Array of meta links.
48
+ * @param string $pluginFile
49
+ * @param array $pluginData Array of plugin header data.
50
+ * @return array
51
+ */
52
+ public function addViewDetailsLink($pluginMeta, $pluginFile, $pluginData = array()) {
53
+ if ( $this->isMyPluginFile($pluginFile) && !isset($pluginData['slug']) ) {
54
+ $linkText = apply_filters($this->updateChecker->getUniqueName('view_details_link'), __('View details'));
55
+ if ( !empty($linkText) ) {
56
+ $viewDetailsLinkPosition = 'append';
57
+
58
+ //Find the "Visit plugin site" link (if present).
59
+ $visitPluginSiteLinkIndex = count($pluginMeta) - 1;
60
+ if ( $pluginData['PluginURI'] ) {
61
+ $escapedPluginUri = esc_url($pluginData['PluginURI']);
62
+ foreach ($pluginMeta as $linkIndex => $existingLink) {
63
+ if ( strpos($existingLink, $escapedPluginUri) !== false ) {
64
+ $visitPluginSiteLinkIndex = $linkIndex;
65
+ $viewDetailsLinkPosition = apply_filters(
66
+ $this->updateChecker->getUniqueName('view_details_link_position'),
67
+ 'before'
68
+ );
69
+ break;
70
+ }
71
+ }
72
+ }
73
+
74
+ $viewDetailsLink = sprintf('<a href="%s" class="thickbox open-plugin-details-modal" aria-label="%s" data-title="%s">%s</a>',
75
+ esc_url(network_admin_url('plugin-install.php?tab=plugin-information&plugin=' . urlencode($this->updateChecker->slug) .
76
+ '&TB_iframe=true&width=600&height=550')),
77
+ esc_attr(sprintf(__('More information about %s'), $pluginData['Name'])),
78
+ esc_attr($pluginData['Name']),
79
+ $linkText
80
+ );
81
+ switch ($viewDetailsLinkPosition) {
82
+ case 'before':
83
+ array_splice($pluginMeta, $visitPluginSiteLinkIndex, 0, $viewDetailsLink);
84
+ break;
85
+ case 'after':
86
+ array_splice($pluginMeta, $visitPluginSiteLinkIndex + 1, 0, $viewDetailsLink);
87
+ break;
88
+ case 'replace':
89
+ $pluginMeta[$visitPluginSiteLinkIndex] = $viewDetailsLink;
90
+ break;
91
+ case 'append':
92
+ default:
93
+ $pluginMeta[] = $viewDetailsLink;
94
+ break;
95
+ }
96
+ }
97
+ }
98
+ return $pluginMeta;
99
+ }
100
+
101
+ /**
102
+ * Add a "Check for updates" link to the plugin row in the "Plugins" page. By default,
103
+ * the new link will appear after the "Visit plugin site" link if present, otherwise
104
+ * after the "View plugin details" link.
105
+ *
106
+ * You can change the link text by using the "puc_manual_check_link-$slug" filter.
107
+ * Returning an empty string from the filter will disable the link.
108
+ *
109
+ * @param array $pluginMeta Array of meta links.
110
+ * @param string $pluginFile
111
+ * @return array
112
+ */
113
+ public function addCheckForUpdatesLink($pluginMeta, $pluginFile) {
114
+ if ( $this->isMyPluginFile($pluginFile) ) {
115
+ $linkUrl = wp_nonce_url(
116
+ add_query_arg(
117
+ array(
118
+ 'puc_check_for_updates' => 1,
119
+ 'puc_slug' => $this->updateChecker->slug,
120
+ ),
121
+ self_admin_url('plugins.php')
122
+ ),
123
+ 'puc_check_for_updates'
124
+ );
125
+
126
+ $linkText = apply_filters(
127
+ $this->updateChecker->getUniqueName('manual_check_link'),
128
+ __('Check for updates', 'plugin-update-checker')
129
+ );
130
+ if ( !empty($linkText) ) {
131
+ /** @noinspection HtmlUnknownTarget */
132
+ $pluginMeta[] = sprintf('<a href="%s">%s</a>', esc_attr($linkUrl), $linkText);
133
+ }
134
+ }
135
+ return $pluginMeta;
136
+ }
137
+
138
+ protected function isMyPluginFile($pluginFile) {
139
+ return ($pluginFile == $this->updateChecker->pluginFile)
140
+ || (!empty($this->updateChecker->muPluginFile) && ($pluginFile == $this->updateChecker->muPluginFile));
141
+ }
142
+
143
+ /**
144
+ * Check for updates when the user clicks the "Check for updates" link.
145
+ *
146
+ * @see self::addCheckForUpdatesLink()
147
+ *
148
+ * @return void
149
+ */
150
+ public function handleManualCheck() {
151
+ $shouldCheck =
152
+ isset($_GET['puc_check_for_updates'], $_GET['puc_slug'])
153
+ && $_GET['puc_slug'] == $this->updateChecker->slug
154
+ && check_admin_referer('puc_check_for_updates');
155
+
156
+ if ( $shouldCheck ) {
157
+ $update = $this->updateChecker->checkForUpdates();
158
+ $status = ($update === null) ? 'no_update' : 'update_available';
159
+
160
+ if ( ($update === null) && !empty($this->lastRequestApiErrors) ) {
161
+ //Some errors are not critical. For example, if PUC tries to retrieve the readme.txt
162
+ //file from GitHub and gets a 404, that's an API error, but it doesn't prevent updates
163
+ //from working. Maybe the plugin simply doesn't have a readme.
164
+ //Let's only show important errors.
165
+ $foundCriticalErrors = false;
166
+ $questionableErrorCodes = array(
167
+ 'puc-github-http-error',
168
+ 'puc-gitlab-http-error',
169
+ 'puc-bitbucket-http-error',
170
+ );
171
+
172
+ foreach ($this->lastRequestApiErrors as $item) {
173
+ $wpError = $item['error'];
174
+ /** @var WP_Error $wpError */
175
+ if ( !in_array($wpError->get_error_code(), $questionableErrorCodes) ) {
176
+ $foundCriticalErrors = true;
177
+ break;
178
+ }
179
+ }
180
+
181
+ if ( $foundCriticalErrors ) {
182
+ $status = 'error';
183
+ set_site_transient($this->manualCheckErrorTransient, $this->lastRequestApiErrors, 60);
184
+ }
185
+ }
186
+
187
+ wp_redirect(add_query_arg(
188
+ array(
189
+ 'puc_update_check_result' => $status,
190
+ 'puc_slug' => $this->updateChecker->slug,
191
+ ),
192
+ self_admin_url('plugins.php')
193
+ ));
194
+ exit;
195
+ }
196
+ }
197
+
198
+ /**
199
+ * Display the results of a manual update check.
200
+ *
201
+ * @see self::handleManualCheck()
202
+ *
203
+ * You can change the result message by using the "puc_manual_check_message-$slug" filter.
204
+ */
205
+ public function displayManualCheckResult() {
206
+ if ( isset($_GET['puc_update_check_result'], $_GET['puc_slug']) && ($_GET['puc_slug'] == $this->updateChecker->slug) ) {
207
+ $status = strval($_GET['puc_update_check_result']);
208
+ $title = $this->updateChecker->getInstalledPackage()->getPluginTitle();
209
+ $noticeClass = 'updated notice-success';
210
+ $details = '';
211
+
212
+ if ( $status == 'no_update' ) {
213
+ $message = sprintf(_x('The %s plugin is up to date.', 'the plugin title', 'plugin-update-checker'), $title);
214
+ } else if ( $status == 'update_available' ) {
215
+ $message = sprintf(_x('A new version of the %s plugin is available.', 'the plugin title', 'plugin-update-checker'), $title);
216
+ } else if ( $status === 'error' ) {
217
+ $message = sprintf(_x('Could not determine if updates are available for %s.', 'the plugin title', 'plugin-update-checker'), $title);
218
+ $noticeClass = 'error notice-error';
219
+
220
+ $details = $this->formatManualCheckErrors(get_site_transient($this->manualCheckErrorTransient));
221
+ delete_site_transient($this->manualCheckErrorTransient);
222
+ } else {
223
+ $message = sprintf(__('Unknown update checker status "%s"', 'plugin-update-checker'), htmlentities($status));
224
+ $noticeClass = 'error notice-error';
225
+ }
226
+ printf(
227
+ '<div class="notice %s is-dismissible"><p>%s</p>%s</div>',
228
+ $noticeClass,
229
+ apply_filters($this->updateChecker->getUniqueName('manual_check_message'), $message, $status),
230
+ $details
231
+ );
232
+ }
233
+ }
234
+
235
+ /**
236
+ * Format the list of errors that were thrown during an update check.
237
+ *
238
+ * @param array $errors
239
+ * @return string
240
+ */
241
+ protected function formatManualCheckErrors($errors) {
242
+ if ( empty($errors) ) {
243
+ return '';
244
+ }
245
+ $output = '';
246
+
247
+ $showAsList = count($errors) > 1;
248
+ if ( $showAsList ) {
249
+ $output .= '<ol>';
250
+ $formatString = '<li>%1$s <code>%2$s</code></li>';
251
+ } else {
252
+ $formatString = '<p>%1$s <code>%2$s</code></p>';
253
+ }
254
+ foreach ($errors as $item) {
255
+ $wpError = $item['error'];
256
+ /** @var WP_Error $wpError */
257
+ $output .= sprintf(
258
+ $formatString,
259
+ $wpError->get_error_message(),
260
+ $wpError->get_error_code()
261
+ );
262
+ }
263
+ if ( $showAsList ) {
264
+ $output .= '</ol>';
265
+ }
266
+
267
+ return $output;
268
+ }
269
+
270
+ public function removeHooks() {
271
+ remove_action('admin_init', array($this, 'onAdminInit'));
272
+ remove_filter('plugin_row_meta', array($this, 'addViewDetailsLink'), 10);
273
+ remove_filter('plugin_row_meta', array($this, 'addCheckForUpdatesLink'), 10);
274
+ remove_action('all_admin_notices', array($this, 'displayManualCheckResult'));
275
+ }
276
+ }
277
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/Update.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Plugin_Update', false) ):
3
+
4
+ /**
5
+ * A simple container class for holding information about an available update.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2016
9
+ * @access public
10
+ */
11
+ class Puc_v4p7_Plugin_Update extends Puc_v4p7_Update {
12
+ public $id = 0;
13
+ public $homepage;
14
+ public $upgrade_notice;
15
+ public $tested;
16
+ public $icons = array();
17
+ public $filename; //Plugin filename relative to the plugins directory.
18
+
19
+ protected static $extraFields = array(
20
+ 'id', 'homepage', 'tested', 'upgrade_notice', 'icons', 'filename',
21
+ );
22
+
23
+ /**
24
+ * Create a new instance of PluginUpdate from its JSON-encoded representation.
25
+ *
26
+ * @param string $json
27
+ * @return Puc_v4p7_Plugin_Update|null
28
+ */
29
+ public static function fromJson($json){
30
+ //Since update-related information is simply a subset of the full plugin info,
31
+ //we can parse the update JSON as if it was a plugin info string, then copy over
32
+ //the parts that we care about.
33
+ $pluginInfo = Puc_v4p7_Plugin_Info::fromJson($json);
34
+ if ( $pluginInfo !== null ) {
35
+ return self::fromPluginInfo($pluginInfo);
36
+ } else {
37
+ return null;
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Create a new instance of PluginUpdate based on an instance of PluginInfo.
43
+ * Basically, this just copies a subset of fields from one object to another.
44
+ *
45
+ * @param Puc_v4p7_Plugin_Info $info
46
+ * @return Puc_v4p7_Plugin_Update
47
+ */
48
+ public static function fromPluginInfo($info){
49
+ return self::fromObject($info);
50
+ }
51
+
52
+ /**
53
+ * Create a new instance by copying the necessary fields from another object.
54
+ *
55
+ * @param StdClass|Puc_v4p7_Plugin_Info|Puc_v4p7_Plugin_Update $object The source object.
56
+ * @return Puc_v4p7_Plugin_Update The new copy.
57
+ */
58
+ public static function fromObject($object) {
59
+ $update = new self();
60
+ $update->copyFields($object, $update);
61
+ return $update;
62
+ }
63
+
64
+ /**
65
+ * @return string[]
66
+ */
67
+ protected function getFieldNames() {
68
+ return array_merge(parent::getFieldNames(), self::$extraFields);
69
+ }
70
+
71
+ /**
72
+ * Transform the update into the format used by WordPress native plugin API.
73
+ *
74
+ * @return object
75
+ */
76
+ public function toWpFormat() {
77
+ $update = parent::toWpFormat();
78
+
79
+ $update->id = $this->id;
80
+ $update->url = $this->homepage;
81
+ $update->tested = $this->tested;
82
+ $update->plugin = $this->filename;
83
+
84
+ if ( !empty($this->upgrade_notice) ) {
85
+ $update->upgrade_notice = $this->upgrade_notice;
86
+ }
87
+
88
+ if ( !empty($this->icons) && is_array($this->icons) ) {
89
+ //This should be an array with up to 4 keys: 'svg', '1x', '2x' and 'default'.
90
+ //Docs: https://developer.wordpress.org/plugins/wordpress-org/plugin-assets/#plugin-icons
91
+ $icons = array_intersect_key(
92
+ $this->icons,
93
+ array('svg' => true, '1x' => true, '2x' => true, 'default' => true)
94
+ );
95
+ if ( !empty($icons) ) {
96
+ $update->icons = $icons;
97
+
98
+ //It appears that the 'default' icon isn't used anywhere in WordPress 4.9,
99
+ //but lets set it just in case a future release needs it.
100
+ if ( !isset($update->icons['default']) ) {
101
+ $update->icons['default'] = current($update->icons);
102
+ }
103
+ }
104
+ }
105
+
106
+ return $update;
107
+ }
108
+ }
109
+
110
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Plugin/UpdateChecker.php ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Plugin_UpdateChecker', false) ):
3
+
4
+ /**
5
+ * A custom plugin update checker.
6
+ *
7
+ * @author Janis Elsts
8
+ * @copyright 2018
9
+ * @access public
10
+ */
11
+ class Puc_v4p7_Plugin_UpdateChecker extends Puc_v4p7_UpdateChecker {
12
+ protected $updateTransient = 'update_plugins';
13
+ protected $translationType = 'plugin';
14
+
15
+ public $pluginAbsolutePath = ''; //Full path of the main plugin file.
16
+ public $pluginFile = ''; //Plugin filename relative to the plugins directory. Many WP APIs use this to identify plugins.
17
+ public $muPluginFile = ''; //For MU plugins, the plugin filename relative to the mu-plugins directory.
18
+
19
+ /**
20
+ * @var Puc_v4p7_Plugin_Package
21
+ */
22
+ protected $package;
23
+
24
+ private $extraUi = null;
25
+
26
+ /**
27
+ * Class constructor.
28
+ *
29
+ * @param string $metadataUrl The URL of the plugin's metadata file.
30
+ * @param string $pluginFile Fully qualified path to the main plugin file.
31
+ * @param string $slug The plugin's 'slug'. If not specified, the filename part of $pluginFile sans '.php' will be used as the slug.
32
+ * @param integer $checkPeriod How often to check for updates (in hours). Defaults to checking every 12 hours. Set to 0 to disable automatic update checks.
33
+ * @param string $optionName Where to store book-keeping info about update checks. Defaults to 'external_updates-$slug'.
34
+ * @param string $muPluginFile Optional. The plugin filename relative to the mu-plugins directory.
35
+ */
36
+ public function __construct($metadataUrl, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = ''){
37
+ $this->pluginAbsolutePath = $pluginFile;
38
+ $this->pluginFile = plugin_basename($this->pluginAbsolutePath);
39
+ $this->muPluginFile = $muPluginFile;
40
+
41
+ //If no slug is specified, use the name of the main plugin file as the slug.
42
+ //For example, 'my-cool-plugin/cool-plugin.php' becomes 'cool-plugin'.
43
+ if ( empty($slug) ){
44
+ $slug = basename($this->pluginFile, '.php');
45
+ }
46
+
47
+ //Plugin slugs must be unique.
48
+ $slugCheckFilter = 'puc_is_slug_in_use-' . $slug;
49
+ $slugUsedBy = apply_filters($slugCheckFilter, false);
50
+ if ( $slugUsedBy ) {
51
+ $this->triggerError(sprintf(
52
+ 'Plugin slug "%s" is already in use by %s. Slugs must be unique.',
53
+ htmlentities($slug),
54
+ htmlentities($slugUsedBy)
55
+ ), E_USER_ERROR);
56
+ }
57
+ add_filter($slugCheckFilter, array($this, 'getAbsolutePath'));
58
+
59
+ //Backwards compatibility: If the plugin is a mu-plugin but no $muPluginFile is specified, assume
60
+ //it's the same as $pluginFile given that it's not in a subdirectory (WP only looks in the base dir).
61
+ if ( (strpbrk($this->pluginFile, '/\\') === false) && $this->isUnknownMuPlugin() ) {
62
+ $this->muPluginFile = $this->pluginFile;
63
+ }
64
+
65
+ //To prevent a crash during plugin uninstallation, remove updater hooks when the user removes the plugin.
66
+ //Details: https://github.com/YahnisElsts/plugin-update-checker/issues/138#issuecomment-335590964
67
+ add_action('uninstall_' . $this->pluginFile, array($this, 'removeHooks'));
68
+
69
+ parent::__construct($metadataUrl, dirname($this->pluginFile), $slug, $checkPeriod, $optionName);
70
+
71
+ $this->extraUi = new Puc_v4p7_Plugin_Ui($this);
72
+ }
73
+
74
+ /**
75
+ * Create an instance of the scheduler.
76
+ *
77
+ * @param int $checkPeriod
78
+ * @return Puc_v4p7_Scheduler
79
+ */
80
+ protected function createScheduler($checkPeriod) {
81
+ $scheduler = new Puc_v4p7_Scheduler($this, $checkPeriod, array('load-plugins.php'));
82
+ register_deactivation_hook($this->pluginFile, array($scheduler, 'removeUpdaterCron'));
83
+ return $scheduler;
84
+ }
85
+
86
+ /**
87
+ * Install the hooks required to run periodic update checks and inject update info
88
+ * into WP data structures.
89
+ *
90
+ * @return void
91
+ */
92
+ protected function installHooks(){
93
+ //Override requests for plugin information
94
+ add_filter('plugins_api', array($this, 'injectInfo'), 20, 3);
95
+
96
+ parent::installHooks();
97
+ }
98
+
99
+ /**
100
+ * Remove update checker hooks.
101
+ *
102
+ * The intent is to prevent a fatal error that can happen if the plugin has an uninstall
103
+ * hook. During uninstallation, WP includes the main plugin file (which creates a PUC instance),
104
+ * the uninstall hook runs, WP deletes the plugin files and then updates some transients.
105
+ * If PUC hooks are still around at this time, they could throw an error while trying to
106
+ * autoload classes from files that no longer exist.
107
+ *
108
+ * The "site_transient_{$transient}" filter is the main problem here, but let's also remove
109
+ * most other PUC hooks to be safe.
110
+ *
111
+ * @internal
112
+ */
113
+ public function removeHooks() {
114
+ parent::removeHooks();
115
+ $this->extraUi->removeHooks();
116
+ $this->package->removeHooks();
117
+
118
+ remove_filter('plugins_api', array($this, 'injectInfo'), 20);
119
+ }
120
+
121
+ /**
122
+ * Retrieve plugin info from the configured API endpoint.
123
+ *
124
+ * @uses wp_remote_get()
125
+ *
126
+ * @param array $queryArgs Additional query arguments to append to the request. Optional.
127
+ * @return Puc_v4p7_Plugin_Info
128
+ */
129
+ public function requestInfo($queryArgs = array()) {
130
+ list($pluginInfo, $result) = $this->requestMetadata('Puc_v4p7_Plugin_Info', 'request_info', $queryArgs);
131
+
132
+ if ( $pluginInfo !== null ) {
133
+ /** @var Puc_v4p7_Plugin_Info $pluginInfo */
134
+ $pluginInfo->filename = $this->pluginFile;
135
+ $pluginInfo->slug = $this->slug;
136
+ }
137
+
138
+ $pluginInfo = apply_filters($this->getUniqueName('request_info_result'), $pluginInfo, $result);
139
+ return $pluginInfo;
140
+ }
141
+
142
+ /**
143
+ * Retrieve the latest update (if any) from the configured API endpoint.
144
+ *
145
+ * @uses PluginUpdateChecker::requestInfo()
146
+ *
147
+ * @return Puc_v4p7_Update|null An instance of Plugin_Update, or NULL when no updates are available.
148
+ */
149
+ public function requestUpdate() {
150
+ //For the sake of simplicity, this function just calls requestInfo()
151
+ //and transforms the result accordingly.
152
+ $pluginInfo = $this->requestInfo(array('checking_for_updates' => '1'));
153
+ if ( $pluginInfo === null ){
154
+ return null;
155
+ }
156
+ $update = Puc_v4p7_Plugin_Update::fromPluginInfo($pluginInfo);
157
+
158
+ $update = $this->filterUpdateResult($update);
159
+
160
+ return $update;
161
+ }
162
+
163
+ /**
164
+ * Intercept plugins_api() calls that request information about our plugin and
165
+ * use the configured API endpoint to satisfy them.
166
+ *
167
+ * @see plugins_api()
168
+ *
169
+ * @param mixed $result
170
+ * @param string $action
171
+ * @param array|object $args
172
+ * @return mixed
173
+ */
174
+ public function injectInfo($result, $action = null, $args = null){
175
+ $relevant = ($action == 'plugin_information') && isset($args->slug) && (
176
+ ($args->slug == $this->slug) || ($args->slug == dirname($this->pluginFile))
177
+ );
178
+ if ( !$relevant ) {
179
+ return $result;
180
+ }
181
+
182
+ $pluginInfo = $this->requestInfo();
183
+ $pluginInfo = apply_filters($this->getUniqueName('pre_inject_info'), $pluginInfo);
184
+ if ( $pluginInfo ) {
185
+ return $pluginInfo->toWpFormat();
186
+ }
187
+
188
+ return $result;
189
+ }
190
+
191
+ protected function shouldShowUpdates() {
192
+ //No update notifications for mu-plugins unless explicitly enabled. The MU plugin file
193
+ //is usually different from the main plugin file so the update wouldn't show up properly anyway.
194
+ return !$this->isUnknownMuPlugin();
195
+ }
196
+
197
+ /**
198
+ * @param stdClass|null $updates
199
+ * @param stdClass $updateToAdd
200
+ * @return stdClass
201
+ */
202
+ protected function addUpdateToList($updates, $updateToAdd) {
203
+ if ( $this->package->isMuPlugin() ) {
204
+ //WP does not support automatic update installation for mu-plugins, but we can
205
+ //still display a notice.
206
+ $updateToAdd->package = null;
207
+ }
208
+ return parent::addUpdateToList($updates, $updateToAdd);
209
+ }
210
+
211
+ /**
212
+ * @param stdClass|null $updates
213
+ * @return stdClass|null
214
+ */
215
+ protected function removeUpdateFromList($updates) {
216
+ $updates = parent::removeUpdateFromList($updates);
217
+ if ( !empty($this->muPluginFile) && isset($updates, $updates->response) ) {
218
+ unset($updates->response[$this->muPluginFile]);
219
+ }
220
+ return $updates;
221
+ }
222
+
223
+ /**
224
+ * For plugins, the update array is indexed by the plugin filename relative to the "plugins"
225
+ * directory. Example: "plugin-name/plugin.php".
226
+ *
227
+ * @return string
228
+ */
229
+ protected function getUpdateListKey() {
230
+ if ( $this->package->isMuPlugin() ) {
231
+ return $this->muPluginFile;
232
+ }
233
+ return $this->pluginFile;
234
+ }
235
+
236
+ /**
237
+ * Alias for isBeingUpgraded().
238
+ *
239
+ * @deprecated
240
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
241
+ * @return bool
242
+ */
243
+ public function isPluginBeingUpgraded($upgrader = null) {
244
+ return $this->isBeingUpgraded($upgrader);
245
+ }
246
+
247
+ /**
248
+ * Is there an update being installed for this plugin, right now?
249
+ *
250
+ * @param WP_Upgrader|null $upgrader
251
+ * @return bool
252
+ */
253
+ public function isBeingUpgraded($upgrader = null) {
254
+ return $this->upgraderStatus->isPluginBeingUpgraded($this->pluginFile, $upgrader);
255
+ }
256
+
257
+ /**
258
+ * Get the details of the currently available update, if any.
259
+ *
260
+ * If no updates are available, or if the last known update version is below or equal
261
+ * to the currently installed version, this method will return NULL.
262
+ *
263
+ * Uses cached update data. To retrieve update information straight from
264
+ * the metadata URL, call requestUpdate() instead.
265
+ *
266
+ * @return Puc_v4p7_Plugin_Update|null
267
+ */
268
+ public function getUpdate() {
269
+ $update = parent::getUpdate();
270
+ if ( isset($update) ) {
271
+ /** @var Puc_v4p7_Plugin_Update $update */
272
+ $update->filename = $this->pluginFile;
273
+ }
274
+ return $update;
275
+ }
276
+
277
+ /**
278
+ * Get the translated plugin title.
279
+ *
280
+ * @deprecated
281
+ * @return string
282
+ */
283
+ public function getPluginTitle() {
284
+ return $this->package->getPluginTitle();
285
+ }
286
+
287
+ /**
288
+ * Check if the current user has the required permissions to install updates.
289
+ *
290
+ * @return bool
291
+ */
292
+ public function userCanInstallUpdates() {
293
+ return current_user_can('update_plugins');
294
+ }
295
+
296
+ /**
297
+ * Check if the plugin file is inside the mu-plugins directory.
298
+ *
299
+ * @deprecated
300
+ * @return bool
301
+ */
302
+ protected function isMuPlugin() {
303
+ return $this->package->isMuPlugin();
304
+ }
305
+
306
+ /**
307
+ * MU plugins are partially supported, but only when we know which file in mu-plugins
308
+ * corresponds to this plugin.
309
+ *
310
+ * @return bool
311
+ */
312
+ protected function isUnknownMuPlugin() {
313
+ return empty($this->muPluginFile) && $this->package->isMuPlugin();
314
+ }
315
+
316
+ /**
317
+ * Get absolute path to the main plugin file.
318
+ *
319
+ * @return string
320
+ */
321
+ public function getAbsolutePath() {
322
+ return $this->pluginAbsolutePath;
323
+ }
324
+
325
+ /**
326
+ * Register a callback for filtering query arguments.
327
+ *
328
+ * The callback function should take one argument - an associative array of query arguments.
329
+ * It should return a modified array of query arguments.
330
+ *
331
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
332
+ *
333
+ * @param callable $callback
334
+ * @return void
335
+ */
336
+ public function addQueryArgFilter($callback){
337
+ $this->addFilter('request_info_query_args', $callback);
338
+ }
339
+
340
+ /**
341
+ * Register a callback for filtering arguments passed to wp_remote_get().
342
+ *
343
+ * The callback function should take one argument - an associative array of arguments -
344
+ * and return a modified array or arguments. See the WP documentation on wp_remote_get()
345
+ * for details on what arguments are available and how they work.
346
+ *
347
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
348
+ *
349
+ * @param callable $callback
350
+ * @return void
351
+ */
352
+ public function addHttpRequestArgFilter($callback) {
353
+ $this->addFilter('request_info_options', $callback);
354
+ }
355
+
356
+ /**
357
+ * Register a callback for filtering the plugin info retrieved from the external API.
358
+ *
359
+ * The callback function should take two arguments. If the plugin info was retrieved
360
+ * successfully, the first argument passed will be an instance of PluginInfo. Otherwise,
361
+ * it will be NULL. The second argument will be the corresponding return value of
362
+ * wp_remote_get (see WP docs for details).
363
+ *
364
+ * The callback function should return a new or modified instance of PluginInfo or NULL.
365
+ *
366
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
367
+ *
368
+ * @param callable $callback
369
+ * @return void
370
+ */
371
+ public function addResultFilter($callback) {
372
+ $this->addFilter('request_info_result', $callback, 10, 2);
373
+ }
374
+
375
+ protected function createDebugBarExtension() {
376
+ return new Puc_v4p7_DebugBar_PluginExtension($this);
377
+ }
378
+
379
+ /**
380
+ * Create a package instance that represents this plugin or theme.
381
+ *
382
+ * @return Puc_v4p7_InstalledPackage
383
+ */
384
+ protected function createInstalledPackage() {
385
+ return new Puc_v4p7_Plugin_Package($this->pluginAbsolutePath, $this);
386
+ }
387
+
388
+ /**
389
+ * @return Puc_v4p7_Plugin_Package
390
+ */
391
+ public function getInstalledPackage() {
392
+ return $this->package;
393
+ }
394
+ }
395
+
396
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Scheduler.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Scheduler', false) ):
3
+
4
+ /**
5
+ * The scheduler decides when and how often to check for updates.
6
+ * It calls @see Puc_v4p7_UpdateChecker::checkForUpdates() to perform the actual checks.
7
+ */
8
+ class Puc_v4p7_Scheduler {
9
+ public $checkPeriod = 12; //How often to check for updates (in hours).
10
+ public $throttleRedundantChecks = false; //Check less often if we already know that an update is available.
11
+ public $throttledCheckPeriod = 72;
12
+
13
+ protected $hourlyCheckHooks = array('load-update.php');
14
+
15
+ /**
16
+ * @var Puc_v4p7_UpdateChecker
17
+ */
18
+ protected $updateChecker;
19
+
20
+ private $cronHook = null;
21
+
22
+ /**
23
+ * Scheduler constructor.
24
+ *
25
+ * @param Puc_v4p7_UpdateChecker $updateChecker
26
+ * @param int $checkPeriod How often to check for updates (in hours).
27
+ * @param array $hourlyHooks
28
+ */
29
+ public function __construct($updateChecker, $checkPeriod, $hourlyHooks = array('load-plugins.php')) {
30
+ $this->updateChecker = $updateChecker;
31
+ $this->checkPeriod = $checkPeriod;
32
+
33
+ //Set up the periodic update checks
34
+ $this->cronHook = $this->updateChecker->getUniqueName('cron_check_updates');
35
+ if ( $this->checkPeriod > 0 ){
36
+
37
+ //Trigger the check via Cron.
38
+ //Try to use one of the default schedules if possible as it's less likely to conflict
39
+ //with other plugins and their custom schedules.
40
+ $defaultSchedules = array(
41
+ 1 => 'hourly',
42
+ 12 => 'twicedaily',
43
+ 24 => 'daily',
44
+ );
45
+ if ( array_key_exists($this->checkPeriod, $defaultSchedules) ) {
46
+ $scheduleName = $defaultSchedules[$this->checkPeriod];
47
+ } else {
48
+ //Use a custom cron schedule.
49
+ $scheduleName = 'every' . $this->checkPeriod . 'hours';
50
+ add_filter('cron_schedules', array($this, '_addCustomSchedule'));
51
+ }
52
+
53
+ if ( !wp_next_scheduled($this->cronHook) && !defined('WP_INSTALLING') ) {
54
+ wp_schedule_event(time(), $scheduleName, $this->cronHook);
55
+ }
56
+ add_action($this->cronHook, array($this, 'maybeCheckForUpdates'));
57
+
58
+ //In case Cron is disabled or unreliable, we also manually trigger
59
+ //the periodic checks while the user is browsing the Dashboard.
60
+ add_action( 'admin_init', array($this, 'maybeCheckForUpdates') );
61
+
62
+ //Like WordPress itself, we check more often on certain pages.
63
+ /** @see wp_update_plugins */
64
+ add_action('load-update-core.php', array($this, 'maybeCheckForUpdates'));
65
+ //"load-update.php" and "load-plugins.php" or "load-themes.php".
66
+ $this->hourlyCheckHooks = array_merge($this->hourlyCheckHooks, $hourlyHooks);
67
+ foreach($this->hourlyCheckHooks as $hook) {
68
+ add_action($hook, array($this, 'maybeCheckForUpdates'));
69
+ }
70
+ //This hook fires after a bulk update is complete.
71
+ add_action('upgrader_process_complete', array($this, 'upgraderProcessComplete'), 11, 2);
72
+
73
+ } else {
74
+ //Periodic checks are disabled.
75
+ wp_clear_scheduled_hook($this->cronHook);
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Runs upon the WP action upgrader_process_complete.
81
+ *
82
+ * We look at the parameters to decide whether to call maybeCheckForUpdates() or not.
83
+ *
84
+ * @param WP_Upgrader $upgrader WP_Upgrader instance
85
+ * @param array $upgradeInfo extra information about the upgrade
86
+ */
87
+ public function upgraderProcessComplete(
88
+ /** @noinspection PhpUnusedParameterInspection */
89
+ $upgrader, $upgradeInfo
90
+ ) {
91
+
92
+ //Sanity check and limitation to relevant types.
93
+ if (
94
+ !is_array($upgradeInfo) || !isset($upgradeInfo['type'], $upgradeInfo['action'])
95
+ || 'update' !== $upgradeInfo['action'] || !in_array($upgradeInfo['type'], array('plugin', 'theme'))
96
+ ) {
97
+ return;
98
+ }
99
+
100
+ //Filter out notifications of upgrades that should have no bearing upon whether or not our
101
+ //current info is up-to-date.
102
+ if ( is_a($this->updateChecker, 'Puc_v4p7_Theme_UpdateChecker') ) {
103
+ if ( 'theme' !== $upgradeInfo['type'] || !isset($upgradeInfo['themes']) ) {
104
+ return;
105
+ }
106
+
107
+ //Letting too many things going through for checks is not a real problem, so we compare widely.
108
+ if ( !in_array(
109
+ strtolower($this->updateChecker->directoryName),
110
+ array_map('strtolower', $upgradeInfo['themes'])
111
+ ) ) {
112
+ return;
113
+ }
114
+ }
115
+
116
+ if ( is_a($this->updateChecker, 'Puc_v4p7_Plugin_UpdateChecker') ) {
117
+ if ( 'plugin' !== $upgradeInfo['type'] || !isset($upgradeInfo['plugins']) ) {
118
+ return;
119
+ }
120
+
121
+ //Themes pass in directory names in the information array, but plugins use the relative plugin path.
122
+ if ( !in_array(
123
+ strtolower($this->updateChecker->directoryName),
124
+ array_map('dirname', array_map('strtolower', $upgradeInfo['plugins']))
125
+ ) ) {
126
+ return;
127
+ }
128
+ }
129
+
130
+ $this->maybeCheckForUpdates();
131
+ }
132
+
133
+ /**
134
+ * Check for updates if the configured check interval has already elapsed.
135
+ * Will use a shorter check interval on certain admin pages like "Dashboard -> Updates" or when doing cron.
136
+ *
137
+ * You can override the default behaviour by using the "puc_check_now-$slug" filter.
138
+ * The filter callback will be passed three parameters:
139
+ * - Current decision. TRUE = check updates now, FALSE = don't check now.
140
+ * - Last check time as a Unix timestamp.
141
+ * - Configured check period in hours.
142
+ * Return TRUE to check for updates immediately, or FALSE to cancel.
143
+ *
144
+ * This method is declared public because it's a hook callback. Calling it directly is not recommended.
145
+ */
146
+ public function maybeCheckForUpdates() {
147
+ if ( empty($this->checkPeriod) ){
148
+ return;
149
+ }
150
+
151
+ $state = $this->updateChecker->getUpdateState();
152
+ $shouldCheck = ($state->timeSinceLastCheck() >= $this->getEffectiveCheckPeriod());
153
+
154
+ //Let plugin authors substitute their own algorithm.
155
+ $shouldCheck = apply_filters(
156
+ $this->updateChecker->getUniqueName('check_now'),
157
+ $shouldCheck,
158
+ $state->getLastCheck(),
159
+ $this->checkPeriod
160
+ );
161
+
162
+ if ( $shouldCheck ) {
163
+ $this->updateChecker->checkForUpdates();
164
+ }
165
+ }
166
+
167
+ /**
168
+ * Calculate the actual check period based on the current status and environment.
169
+ *
170
+ * @return int Check period in seconds.
171
+ */
172
+ protected function getEffectiveCheckPeriod() {
173
+ $currentFilter = current_filter();
174
+ if ( in_array($currentFilter, array('load-update-core.php', 'upgrader_process_complete')) ) {
175
+ //Check more often when the user visits "Dashboard -> Updates" or does a bulk update.
176
+ $period = 60;
177
+ } else if ( in_array($currentFilter, $this->hourlyCheckHooks) ) {
178
+ //Also check more often on /wp-admin/update.php and the "Plugins" or "Themes" page.
179
+ $period = 3600;
180
+ } else if ( $this->throttleRedundantChecks && ($this->updateChecker->getUpdate() !== null) ) {
181
+ //Check less frequently if it's already known that an update is available.
182
+ $period = $this->throttledCheckPeriod * 3600;
183
+ } else if ( defined('DOING_CRON') && constant('DOING_CRON') ) {
184
+ //WordPress cron schedules are not exact, so lets do an update check even
185
+ //if slightly less than $checkPeriod hours have elapsed since the last check.
186
+ $cronFuzziness = 20 * 60;
187
+ $period = $this->checkPeriod * 3600 - $cronFuzziness;
188
+ } else {
189
+ $period = $this->checkPeriod * 3600;
190
+ }
191
+
192
+ return $period;
193
+ }
194
+
195
+ /**
196
+ * Add our custom schedule to the array of Cron schedules used by WP.
197
+ *
198
+ * @param array $schedules
199
+ * @return array
200
+ */
201
+ public function _addCustomSchedule($schedules) {
202
+ if ( $this->checkPeriod && ($this->checkPeriod > 0) ){
203
+ $scheduleName = 'every' . $this->checkPeriod . 'hours';
204
+ $schedules[$scheduleName] = array(
205
+ 'interval' => $this->checkPeriod * 3600,
206
+ 'display' => sprintf('Every %d hours', $this->checkPeriod),
207
+ );
208
+ }
209
+ return $schedules;
210
+ }
211
+
212
+ /**
213
+ * Remove the scheduled cron event that the library uses to check for updates.
214
+ *
215
+ * @return void
216
+ */
217
+ public function removeUpdaterCron() {
218
+ wp_clear_scheduled_hook($this->cronHook);
219
+ }
220
+
221
+ /**
222
+ * Get the name of the update checker's WP-cron hook. Mostly useful for debugging.
223
+ *
224
+ * @return string
225
+ */
226
+ public function getCronHookName() {
227
+ return $this->cronHook;
228
+ }
229
+ }
230
+
231
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/StateStore.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_StateStore', false) ):
4
+
5
+ class Puc_v4p7_StateStore {
6
+ /**
7
+ * @var int Last update check timestamp.
8
+ */
9
+ protected $lastCheck = 0;
10
+
11
+ /**
12
+ * @var string Version number.
13
+ */
14
+ protected $checkedVersion = '';
15
+
16
+ /**
17
+ * @var Puc_v4p7_Update|null Cached update.
18
+ */
19
+ protected $update = null;
20
+
21
+ /**
22
+ * @var string Site option name.
23
+ */
24
+ private $optionName = '';
25
+
26
+ /**
27
+ * @var bool Whether we've already tried to load the state from the database.
28
+ */
29
+ private $isLoaded = false;
30
+
31
+ public function __construct($optionName) {
32
+ $this->optionName = $optionName;
33
+ }
34
+
35
+ /**
36
+ * Get time elapsed since the last update check.
37
+ *
38
+ * If there are no recorded update checks, this method returns a large arbitrary number
39
+ * (i.e. time since the Unix epoch).
40
+ *
41
+ * @return int Elapsed time in seconds.
42
+ */
43
+ public function timeSinceLastCheck() {
44
+ $this->lazyLoad();
45
+ return time() - $this->lastCheck;
46
+ }
47
+
48
+ /**
49
+ * @return int
50
+ */
51
+ public function getLastCheck() {
52
+ $this->lazyLoad();
53
+ return $this->lastCheck;
54
+ }
55
+
56
+ /**
57
+ * Set the time of the last update check to the current timestamp.
58
+ *
59
+ * @return $this
60
+ */
61
+ public function setLastCheckToNow() {
62
+ $this->lazyLoad();
63
+ $this->lastCheck = time();
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * @return null|Puc_v4p7_Update
69
+ */
70
+ public function getUpdate() {
71
+ $this->lazyLoad();
72
+ return $this->update;
73
+ }
74
+
75
+ /**
76
+ * @param Puc_v4p7_Update|null $update
77
+ * @return $this
78
+ */
79
+ public function setUpdate(Puc_v4p7_Update $update = null) {
80
+ $this->lazyLoad();
81
+ $this->update = $update;
82
+ return $this;
83
+ }
84
+
85
+ /**
86
+ * @return string
87
+ */
88
+ public function getCheckedVersion() {
89
+ $this->lazyLoad();
90
+ return $this->checkedVersion;
91
+ }
92
+
93
+ /**
94
+ * @param string $version
95
+ * @return $this
96
+ */
97
+ public function setCheckedVersion($version) {
98
+ $this->lazyLoad();
99
+ $this->checkedVersion = strval($version);
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Get translation updates.
105
+ *
106
+ * @return array
107
+ */
108
+ public function getTranslations() {
109
+ $this->lazyLoad();
110
+ if ( isset($this->update, $this->update->translations) ) {
111
+ return $this->update->translations;
112
+ }
113
+ return array();
114
+ }
115
+
116
+ /**
117
+ * Set translation updates.
118
+ *
119
+ * @param array $translationUpdates
120
+ */
121
+ public function setTranslations($translationUpdates) {
122
+ $this->lazyLoad();
123
+ if ( isset($this->update) ) {
124
+ $this->update->translations = $translationUpdates;
125
+ $this->save();
126
+ }
127
+ }
128
+
129
+ public function save() {
130
+ $state = new stdClass();
131
+
132
+ $state->lastCheck = $this->lastCheck;
133
+ $state->checkedVersion = $this->checkedVersion;
134
+
135
+ if ( isset($this->update)) {
136
+ $state->update = $this->update->toStdClass();
137
+
138
+ $updateClass = get_class($this->update);
139
+ $state->updateClass = $updateClass;
140
+ $prefix = $this->getLibPrefix();
141
+ if ( Puc_v4p7_Utils::startsWith($updateClass, $prefix) ) {
142
+ $state->updateBaseClass = substr($updateClass, strlen($prefix));
143
+ }
144
+ }
145
+
146
+ update_site_option($this->optionName, $state);
147
+ $this->isLoaded = true;
148
+ }
149
+
150
+ /**
151
+ * @return $this
152
+ */
153
+ public function lazyLoad() {
154
+ if ( !$this->isLoaded ) {
155
+ $this->load();
156
+ }
157
+ return $this;
158
+ }
159
+
160
+ protected function load() {
161
+ $this->isLoaded = true;
162
+
163
+ $state = get_site_option($this->optionName, null);
164
+
165
+ if ( !is_object($state) ) {
166
+ $this->lastCheck = 0;
167
+ $this->checkedVersion = '';
168
+ $this->update = null;
169
+ return;
170
+ }
171
+
172
+ $this->lastCheck = intval(Puc_v4p7_Utils::get($state, 'lastCheck', 0));
173
+ $this->checkedVersion = Puc_v4p7_Utils::get($state, 'checkedVersion', '');
174
+ $this->update = null;
175
+
176
+ if ( isset($state->update) ) {
177
+ //This mess is due to the fact that the want the update class from this version
178
+ //of the library, not the version that saved the update.
179
+
180
+ $updateClass = null;
181
+ if ( isset($state->updateBaseClass) ) {
182
+ $updateClass = $this->getLibPrefix() . $state->updateBaseClass;
183
+ } else if ( isset($state->updateClass) && class_exists($state->updateClass) ) {
184
+ $updateClass = $state->updateClass;
185
+ }
186
+
187
+ if ( $updateClass !== null ) {
188
+ $this->update = call_user_func(array($updateClass, 'fromObject'), $state->update);
189
+ }
190
+ }
191
+ }
192
+
193
+ public function delete() {
194
+ delete_site_option($this->optionName);
195
+
196
+ $this->lastCheck = 0;
197
+ $this->checkedVersion = '';
198
+ $this->update = null;
199
+ }
200
+
201
+ private function getLibPrefix() {
202
+ $parts = explode('_', __CLASS__, 3);
203
+ return $parts[0] . '_' . $parts[1] . '_';
204
+ }
205
+ }
206
+
207
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Package.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Theme_Package', false) ):
3
+
4
+ class Puc_v4p7_Theme_Package extends Puc_v4p7_InstalledPackage {
5
+ /**
6
+ * @var string Theme directory name.
7
+ */
8
+ protected $stylesheet;
9
+
10
+ /**
11
+ * @var WP_Theme Theme object.
12
+ */
13
+ protected $theme;
14
+
15
+ public function __construct($stylesheet, $updateChecker) {
16
+ $this->stylesheet = $stylesheet;
17
+ $this->theme = wp_get_theme($this->stylesheet);
18
+
19
+ parent::__construct($updateChecker);
20
+ }
21
+
22
+ public function getInstalledVersion() {
23
+ return $this->theme->get('Version');
24
+ }
25
+
26
+ public function getAbsoluteDirectoryPath() {
27
+ if ( method_exists($this->theme, 'get_stylesheet_directory') ) {
28
+ return $this->theme->get_stylesheet_directory(); //Available since WP 3.4.
29
+ }
30
+ return get_theme_root($this->stylesheet) . '/' . $this->stylesheet;
31
+ }
32
+
33
+ /**
34
+ * Get the value of a specific plugin or theme header.
35
+ *
36
+ * @param string $headerName
37
+ * @param string $defaultValue
38
+ * @return string Either the value of the header, or $defaultValue if the header doesn't exist or is empty.
39
+ */
40
+ public function getHeaderValue($headerName, $defaultValue = '') {
41
+ $value = $this->theme->get($headerName);
42
+ if ( ($headerName === false) || ($headerName === '') ) {
43
+ return $defaultValue;
44
+ }
45
+ return $value;
46
+ }
47
+
48
+ protected function getHeaderNames() {
49
+ return array(
50
+ 'Name' => 'Theme Name',
51
+ 'ThemeURI' => 'Theme URI',
52
+ 'Description' => 'Description',
53
+ 'Author' => 'Author',
54
+ 'AuthorURI' => 'Author URI',
55
+ 'Version' => 'Version',
56
+ 'Template' => 'Template',
57
+ 'Status' => 'Status',
58
+ 'Tags' => 'Tags',
59
+ 'TextDomain' => 'Text Domain',
60
+ 'DomainPath' => 'Domain Path',
61
+ );
62
+ }
63
+ }
64
+
65
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/Update.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Theme_Update', false) ):
4
+
5
+ class Puc_v4p7_Theme_Update extends Puc_v4p7_Update {
6
+ public $details_url = '';
7
+
8
+ protected static $extraFields = array('details_url');
9
+
10
+ /**
11
+ * Transform the metadata into the format used by WordPress core.
12
+ * Note the inconsistency: WP stores plugin updates as objects and theme updates as arrays.
13
+ *
14
+ * @return array
15
+ */
16
+ public function toWpFormat() {
17
+ $update = array(
18
+ 'theme' => $this->slug,
19
+ 'new_version' => $this->version,
20
+ 'url' => $this->details_url,
21
+ );
22
+
23
+ if ( !empty($this->download_url) ) {
24
+ $update['package'] = $this->download_url;
25
+ }
26
+
27
+ return $update;
28
+ }
29
+
30
+ /**
31
+ * Create a new instance of Theme_Update from its JSON-encoded representation.
32
+ *
33
+ * @param string $json Valid JSON string representing a theme information object.
34
+ * @return self New instance of ThemeUpdate, or NULL on error.
35
+ */
36
+ public static function fromJson($json) {
37
+ $instance = new self();
38
+ if ( !parent::createFromJson($json, $instance) ) {
39
+ return null;
40
+ }
41
+ return $instance;
42
+ }
43
+
44
+ /**
45
+ * Create a new instance by copying the necessary fields from another object.
46
+ *
47
+ * @param StdClass|Puc_v4p7_Theme_Update $object The source object.
48
+ * @return Puc_v4p7_Theme_Update The new copy.
49
+ */
50
+ public static function fromObject($object) {
51
+ $update = new self();
52
+ $update->copyFields($object, $update);
53
+ return $update;
54
+ }
55
+
56
+ /**
57
+ * Basic validation.
58
+ *
59
+ * @param StdClass $apiResponse
60
+ * @return bool|WP_Error
61
+ */
62
+ protected function validateMetadata($apiResponse) {
63
+ $required = array('version', 'details_url');
64
+ foreach($required as $key) {
65
+ if ( !isset($apiResponse->$key) || empty($apiResponse->$key) ) {
66
+ return new WP_Error(
67
+ 'tuc-invalid-metadata',
68
+ sprintf('The theme metadata is missing the required "%s" key.', $key)
69
+ );
70
+ }
71
+ }
72
+ return true;
73
+ }
74
+
75
+ protected function getFieldNames() {
76
+ return array_merge(parent::getFieldNames(), self::$extraFields);
77
+ }
78
+
79
+ protected function getPrefixedFilter($tag) {
80
+ return parent::getPrefixedFilter($tag) . '_theme';
81
+ }
82
+ }
83
+
84
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Theme/UpdateChecker.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Theme_UpdateChecker', false) ):
4
+
5
+ class Puc_v4p7_Theme_UpdateChecker extends Puc_v4p7_UpdateChecker {
6
+ protected $filterSuffix = 'theme';
7
+ protected $updateTransient = 'update_themes';
8
+ protected $translationType = 'theme';
9
+
10
+ /**
11
+ * @var string Theme directory name.
12
+ */
13
+ protected $stylesheet;
14
+
15
+ public function __construct($metadataUrl, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
16
+ if ( $stylesheet === null ) {
17
+ $stylesheet = get_stylesheet();
18
+ }
19
+ $this->stylesheet = $stylesheet;
20
+
21
+ parent::__construct(
22
+ $metadataUrl,
23
+ $stylesheet,
24
+ $customSlug ? $customSlug : $stylesheet,
25
+ $checkPeriod,
26
+ $optionName
27
+ );
28
+ }
29
+
30
+ /**
31
+ * For themes, the update array is indexed by theme directory name.
32
+ *
33
+ * @return string
34
+ */
35
+ protected function getUpdateListKey() {
36
+ return $this->directoryName;
37
+ }
38
+
39
+ /**
40
+ * Retrieve the latest update (if any) from the configured API endpoint.
41
+ *
42
+ * @return Puc_v4p7_Update|null An instance of Update, or NULL when no updates are available.
43
+ */
44
+ public function requestUpdate() {
45
+ list($themeUpdate, $result) = $this->requestMetadata('Puc_v4p7_Theme_Update', 'request_update');
46
+
47
+ if ( $themeUpdate !== null ) {
48
+ /** @var Puc_v4p7_Theme_Update $themeUpdate */
49
+ $themeUpdate->slug = $this->slug;
50
+ }
51
+
52
+ $themeUpdate = $this->filterUpdateResult($themeUpdate, $result);
53
+ return $themeUpdate;
54
+ }
55
+
56
+ public function userCanInstallUpdates() {
57
+ return current_user_can('update_themes');
58
+ }
59
+
60
+ /**
61
+ * Create an instance of the scheduler.
62
+ *
63
+ * @param int $checkPeriod
64
+ * @return Puc_v4p7_Scheduler
65
+ */
66
+ protected function createScheduler($checkPeriod) {
67
+ return new Puc_v4p7_Scheduler($this, $checkPeriod, array('load-themes.php'));
68
+ }
69
+
70
+ /**
71
+ * Is there an update being installed right now for this theme?
72
+ *
73
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
74
+ * @return bool
75
+ */
76
+ public function isBeingUpgraded($upgrader = null) {
77
+ return $this->upgraderStatus->isThemeBeingUpgraded($this->stylesheet, $upgrader);
78
+ }
79
+
80
+ protected function createDebugBarExtension() {
81
+ return new Puc_v4p7_DebugBar_Extension($this, 'Puc_v4p7_DebugBar_ThemePanel');
82
+ }
83
+
84
+ /**
85
+ * Register a callback for filtering query arguments.
86
+ *
87
+ * The callback function should take one argument - an associative array of query arguments.
88
+ * It should return a modified array of query arguments.
89
+ *
90
+ * @param callable $callback
91
+ * @return void
92
+ */
93
+ public function addQueryArgFilter($callback){
94
+ $this->addFilter('request_update_query_args', $callback);
95
+ }
96
+
97
+ /**
98
+ * Register a callback for filtering arguments passed to wp_remote_get().
99
+ *
100
+ * The callback function should take one argument - an associative array of arguments -
101
+ * and return a modified array or arguments. See the WP documentation on wp_remote_get()
102
+ * for details on what arguments are available and how they work.
103
+ *
104
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
105
+ *
106
+ * @param callable $callback
107
+ * @return void
108
+ */
109
+ public function addHttpRequestArgFilter($callback) {
110
+ $this->addFilter('request_update_options', $callback);
111
+ }
112
+
113
+ /**
114
+ * Register a callback for filtering theme updates retrieved from the external API.
115
+ *
116
+ * The callback function should take two arguments. If the theme update was retrieved
117
+ * successfully, the first argument passed will be an instance of Theme_Update. Otherwise,
118
+ * it will be NULL. The second argument will be the corresponding return value of
119
+ * wp_remote_get (see WP docs for details).
120
+ *
121
+ * The callback function should return a new or modified instance of Theme_Update or NULL.
122
+ *
123
+ * @uses add_filter() This method is a convenience wrapper for add_filter().
124
+ *
125
+ * @param callable $callback
126
+ * @return void
127
+ */
128
+ public function addResultFilter($callback) {
129
+ $this->addFilter('request_update_result', $callback, 10, 2);
130
+ }
131
+
132
+ /**
133
+ * Create a package instance that represents this plugin or theme.
134
+ *
135
+ * @return Puc_v4p7_InstalledPackage
136
+ */
137
+ protected function createInstalledPackage() {
138
+ return new Puc_v4p7_Theme_Package($this->stylesheet, $this);
139
+ }
140
+ }
141
+
142
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Update.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Update', false) ):
3
+
4
+ /**
5
+ * A simple container class for holding information about an available update.
6
+ *
7
+ * @author Janis Elsts
8
+ * @access public
9
+ */
10
+ abstract class Puc_v4p7_Update extends Puc_v4p7_Metadata {
11
+ public $slug;
12
+ public $version;
13
+ public $download_url;
14
+ public $translations = array();
15
+
16
+ /**
17
+ * @return string[]
18
+ */
19
+ protected function getFieldNames() {
20
+ return array('slug', 'version', 'download_url', 'translations');
21
+ }
22
+
23
+ public function toWpFormat() {
24
+ $update = new stdClass();
25
+
26
+ $update->slug = $this->slug;
27
+ $update->new_version = $this->version;
28
+ $update->package = $this->download_url;
29
+
30
+ return $update;
31
+ }
32
+ }
33
+
34
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpdateChecker.php ADDED
@@ -0,0 +1,926 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_UpdateChecker', false) ):
4
+
5
+ abstract class Puc_v4p7_UpdateChecker {
6
+ protected $filterSuffix = '';
7
+ protected $updateTransient = '';
8
+ protected $translationType = ''; //"plugin" or "theme".
9
+
10
+ /**
11
+ * Set to TRUE to enable error reporting. Errors are raised using trigger_error()
12
+ * and should be logged to the standard PHP error log.
13
+ * @var bool
14
+ */
15
+ public $debugMode = null;
16
+
17
+ /**
18
+ * @var string Where to store the update info.
19
+ */
20
+ public $optionName = '';
21
+
22
+ /**
23
+ * @var string The URL of the metadata file.
24
+ */
25
+ public $metadataUrl = '';
26
+
27
+ /**
28
+ * @var string Plugin or theme directory name.
29
+ */
30
+ public $directoryName = '';
31
+
32
+ /**
33
+ * @var string The slug that will be used in update checker hooks and remote API requests.
34
+ * Usually matches the directory name unless the plugin/theme directory has been renamed.
35
+ */
36
+ public $slug = '';
37
+
38
+ /**
39
+ * @var Puc_v4p7_InstalledPackage
40
+ */
41
+ protected $package;
42
+
43
+ /**
44
+ * @var Puc_v4p7_Scheduler
45
+ */
46
+ public $scheduler;
47
+
48
+ /**
49
+ * @var Puc_v4p7_UpgraderStatus
50
+ */
51
+ protected $upgraderStatus;
52
+
53
+ /**
54
+ * @var Puc_v4p7_StateStore
55
+ */
56
+ protected $updateState;
57
+
58
+ /**
59
+ * @var array List of API errors triggered during the last checkForUpdates() call.
60
+ */
61
+ protected $lastRequestApiErrors = array();
62
+
63
+ public function __construct($metadataUrl, $directoryName, $slug = null, $checkPeriod = 12, $optionName = '') {
64
+ $this->debugMode = (bool)(constant('WP_DEBUG'));
65
+ $this->metadataUrl = $metadataUrl;
66
+ $this->directoryName = $directoryName;
67
+ $this->slug = !empty($slug) ? $slug : $this->directoryName;
68
+
69
+ $this->optionName = $optionName;
70
+ if ( empty($this->optionName) ) {
71
+ //BC: Initially the library only supported plugin updates and didn't use type prefixes
72
+ //in the option name. Lets use the same prefix-less name when possible.
73
+ if ( $this->filterSuffix === '' ) {
74
+ $this->optionName = 'external_updates-' . $this->slug;
75
+ } else {
76
+ $this->optionName = $this->getUniqueName('external_updates');
77
+ }
78
+ }
79
+
80
+ $this->package = $this->createInstalledPackage();
81
+ $this->scheduler = $this->createScheduler($checkPeriod);
82
+ $this->upgraderStatus = new Puc_v4p7_UpgraderStatus();
83
+ $this->updateState = new Puc_v4p7_StateStore($this->optionName);
84
+
85
+ if ( did_action('init') ) {
86
+ $this->loadTextDomain();
87
+ } else {
88
+ add_action('init', array($this, 'loadTextDomain'));
89
+ }
90
+
91
+ $this->installHooks();
92
+ }
93
+
94
+ /**
95
+ * @internal
96
+ */
97
+ public function loadTextDomain() {
98
+ //We're not using load_plugin_textdomain() or its siblings because figuring out where
99
+ //the library is located (plugin, mu-plugin, theme, custom wp-content paths) is messy.
100
+ $domain = 'plugin-update-checker';
101
+ $locale = apply_filters(
102
+ 'plugin_locale',
103
+ (is_admin() && function_exists('get_user_locale')) ? get_user_locale() : get_locale(),
104
+ $domain
105
+ );
106
+
107
+ $moFile = $domain . '-' . $locale . '.mo';
108
+ $path = realpath(dirname(__FILE__) . '/../../languages');
109
+
110
+ if ($path && file_exists($path)) {
111
+ load_textdomain($domain, $path . '/' . $moFile);
112
+ }
113
+ }
114
+
115
+ protected function installHooks() {
116
+ //Insert our update info into the update array maintained by WP.
117
+ add_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
118
+
119
+ //Insert translation updates into the update list.
120
+ add_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
121
+
122
+ //Clear translation updates when WP clears the update cache.
123
+ //This needs to be done directly because the library doesn't actually remove obsolete plugin updates,
124
+ //it just hides them (see getUpdate()). We can't do that with translations - too much disk I/O.
125
+ add_action(
126
+ 'delete_site_transient_' . $this->updateTransient,
127
+ array($this, 'clearCachedTranslationUpdates')
128
+ );
129
+
130
+ //Rename the update directory to be the same as the existing directory.
131
+ if ( $this->directoryName !== '.' ) {
132
+ add_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10, 3);
133
+ }
134
+
135
+ //Allow HTTP requests to the metadata URL even if it's on a local host.
136
+ add_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10, 2);
137
+
138
+ //DebugBar integration.
139
+ if ( did_action('plugins_loaded') ) {
140
+ $this->maybeInitDebugBar();
141
+ } else {
142
+ add_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Remove hooks that were added by this update checker instance.
148
+ */
149
+ protected function removeHooks() {
150
+ remove_filter('site_transient_' . $this->updateTransient, array($this,'injectUpdate'));
151
+ remove_filter('site_transient_' . $this->updateTransient, array($this, 'injectTranslationUpdates'));
152
+ remove_action(
153
+ 'delete_site_transient_' . $this->updateTransient,
154
+ array($this, 'clearCachedTranslationUpdates')
155
+ );
156
+
157
+ remove_filter('upgrader_source_selection', array($this, 'fixDirectoryName'), 10);
158
+ remove_filter('http_request_host_is_external', array($this, 'allowMetadataHost'), 10);
159
+ remove_action('plugins_loaded', array($this, 'maybeInitDebugBar'));
160
+
161
+ remove_action('init', array($this, 'loadTextDomain'));
162
+ }
163
+
164
+ /**
165
+ * Check if the current user has the required permissions to install updates.
166
+ *
167
+ * @return bool
168
+ */
169
+ abstract public function userCanInstallUpdates();
170
+
171
+ /**
172
+ * Explicitly allow HTTP requests to the metadata URL.
173
+ *
174
+ * WordPress has a security feature where the HTTP API will reject all requests that are sent to
175
+ * another site hosted on the same server as the current site (IP match), a local host, or a local
176
+ * IP, unless the host exactly matches the current site.
177
+ *
178
+ * This feature is opt-in (at least in WP 4.4). Apparently some people enable it.
179
+ *
180
+ * That can be a problem when you're developing your plugin and you decide to host the update information
181
+ * on the same server as your test site. Update requests will mysteriously fail.
182
+ *
183
+ * We fix that by adding an exception for the metadata host.
184
+ *
185
+ * @param bool $allow
186
+ * @param string $host
187
+ * @return bool
188
+ */
189
+ public function allowMetadataHost($allow, $host) {
190
+ static $metadataHost = 0; //Using 0 instead of NULL because parse_url can return NULL.
191
+ if ( $metadataHost === 0 ) {
192
+ $metadataHost = parse_url($this->metadataUrl, PHP_URL_HOST);
193
+ }
194
+
195
+ if ( is_string($metadataHost) && (strtolower($host) === strtolower($metadataHost)) ) {
196
+ return true;
197
+ }
198
+ return $allow;
199
+ }
200
+
201
+ /**
202
+ * Create a package instance that represents this plugin or theme.
203
+ *
204
+ * @return Puc_v4p7_InstalledPackage
205
+ */
206
+ abstract protected function createInstalledPackage();
207
+
208
+ /**
209
+ * @return Puc_v4p7_InstalledPackage
210
+ */
211
+ public function getInstalledPackage() {
212
+ return $this->package;
213
+ }
214
+
215
+ /**
216
+ * Create an instance of the scheduler.
217
+ *
218
+ * This is implemented as a method to make it possible for plugins to subclass the update checker
219
+ * and substitute their own scheduler.
220
+ *
221
+ * @param int $checkPeriod
222
+ * @return Puc_v4p7_Scheduler
223
+ */
224
+ abstract protected function createScheduler($checkPeriod);
225
+
226
+ /**
227
+ * Check for updates. The results are stored in the DB option specified in $optionName.
228
+ *
229
+ * @return Puc_v4p7_Update|null
230
+ */
231
+ public function checkForUpdates() {
232
+ $installedVersion = $this->getInstalledVersion();
233
+ //Fail silently if we can't find the plugin/theme or read its header.
234
+ if ( $installedVersion === null ) {
235
+ $this->triggerError(
236
+ sprintf('Skipping update check for %s - installed version unknown.', $this->slug),
237
+ E_USER_WARNING
238
+ );
239
+ return null;
240
+ }
241
+
242
+ //Start collecting API errors.
243
+ $this->lastRequestApiErrors = array();
244
+ add_action('puc_api_error', array($this, 'collectApiErrors'), 10, 4);
245
+
246
+ $state = $this->updateState;
247
+ $state->setLastCheckToNow()
248
+ ->setCheckedVersion($installedVersion)
249
+ ->save(); //Save before checking in case something goes wrong
250
+
251
+ $state->setUpdate($this->requestUpdate());
252
+ $state->save();
253
+
254
+ //Stop collecting API errors.
255
+ remove_action('puc_api_error', array($this, 'collectApiErrors'), 10);
256
+
257
+ return $this->getUpdate();
258
+ }
259
+
260
+ /**
261
+ * Load the update checker state from the DB.
262
+ *
263
+ * @return Puc_v4p7_StateStore
264
+ */
265
+ public function getUpdateState() {
266
+ return $this->updateState->lazyLoad();
267
+ }
268
+
269
+ /**
270
+ * Reset update checker state - i.e. last check time, cached update data and so on.
271
+ *
272
+ * Call this when your plugin is being uninstalled, or if you want to
273
+ * clear the update cache.
274
+ */
275
+ public function resetUpdateState() {
276
+ $this->updateState->delete();
277
+ }
278
+
279
+ /**
280
+ * Get the details of the currently available update, if any.
281
+ *
282
+ * If no updates are available, or if the last known update version is below or equal
283
+ * to the currently installed version, this method will return NULL.
284
+ *
285
+ * Uses cached update data. To retrieve update information straight from
286
+ * the metadata URL, call requestUpdate() instead.
287
+ *
288
+ * @return Puc_v4p7_Update|null
289
+ */
290
+ public function getUpdate() {
291
+ $update = $this->updateState->getUpdate();
292
+
293
+ //Is there an update available?
294
+ if ( isset($update) ) {
295
+ //Check if the update is actually newer than the currently installed version.
296
+ $installedVersion = $this->getInstalledVersion();
297
+ if ( ($installedVersion !== null) && version_compare($update->version, $installedVersion, '>') ){
298
+ return $update;
299
+ }
300
+ }
301
+ return null;
302
+ }
303
+
304
+ /**
305
+ * Retrieve the latest update (if any) from the configured API endpoint.
306
+ *
307
+ * Subclasses should run the update through filterUpdateResult before returning it.
308
+ *
309
+ * @return Puc_v4p7_Update An instance of Update, or NULL when no updates are available.
310
+ */
311
+ abstract public function requestUpdate();
312
+
313
+ /**
314
+ * Filter the result of a requestUpdate() call.
315
+ *
316
+ * @param Puc_v4p7_Update|null $update
317
+ * @param array|WP_Error|null $httpResult The value returned by wp_remote_get(), if any.
318
+ * @return Puc_v4p7_Update
319
+ */
320
+ protected function filterUpdateResult($update, $httpResult = null) {
321
+ //Let plugins/themes modify the update.
322
+ $update = apply_filters($this->getUniqueName('request_update_result'), $update, $httpResult);
323
+
324
+ $this->fixSupportedWordpressVersion($update);
325
+
326
+ if ( isset($update, $update->translations) ) {
327
+ //Keep only those translation updates that apply to this site.
328
+ $update->translations = $this->filterApplicableTranslations($update->translations);
329
+ }
330
+
331
+ return $update;
332
+ }
333
+
334
+ /**
335
+ * The "Tested up to" field in the plugin metadata is supposed to be in the form of "major.minor",
336
+ * while WordPress core's list_plugin_updates() expects the $update->tested field to be an exact
337
+ * version, e.g. "major.minor.patch", to say it's compatible. In other case it shows
338
+ * "Compatibility: Unknown".
339
+ * The function mimics how wordpress.org API crafts the "tested" field out of "Tested up to".
340
+ *
341
+ * @param Puc_v4p7_Update|null $update
342
+ */
343
+ protected function fixSupportedWordpressVersion(Puc_v4p7_Update $update = null) {
344
+ if ( !isset($update->tested) || !preg_match('/^\d++\.\d++$/', $update->tested) ) {
345
+ return;
346
+ }
347
+
348
+ $actualWpVersions = array();
349
+
350
+ $wpVersion = $GLOBALS['wp_version'];
351
+
352
+ if ( function_exists('get_preferred_from_update_core') ) {
353
+ $coreUpdate = get_preferred_from_update_core();
354
+ if ( isset($coreUpdate->current) && version_compare($coreUpdate->current, $wpVersion, '>') ) {
355
+ $actualWpVersions[] = $coreUpdate->current;
356
+ }
357
+ }
358
+
359
+ $actualWpVersions[] = $wpVersion;
360
+
361
+ $actualWpPatchNumber = "999";
362
+ foreach ($actualWpVersions as $version) {
363
+ if ( preg_match('/^(?P<majorMinor>\d++\.\d++)\.(?P<patch>\d++)/', $version, $versionParts) ) {
364
+ if ( $versionParts['majorMinor'] === $update->tested ) {
365
+ $actualWpPatchNumber = $versionParts['patch'];
366
+ break;
367
+ }
368
+ }
369
+ }
370
+
371
+ $update->tested .= '.' . $actualWpPatchNumber;
372
+ }
373
+
374
+ /**
375
+ * Get the currently installed version of the plugin or theme.
376
+ *
377
+ * @return string|null Version number.
378
+ */
379
+ public function getInstalledVersion() {
380
+ return $this->package->getInstalledVersion();
381
+ }
382
+
383
+ /**
384
+ * Get the full path of the plugin or theme directory.
385
+ *
386
+ * @return string
387
+ */
388
+ public function getAbsoluteDirectoryPath() {
389
+ return $this->package->getAbsoluteDirectoryPath();
390
+ }
391
+
392
+ /**
393
+ * Trigger a PHP error, but only when $debugMode is enabled.
394
+ *
395
+ * @param string $message
396
+ * @param int $errorType
397
+ */
398
+ public function triggerError($message, $errorType) {
399
+ if ( $this->isDebugModeEnabled() ) {
400
+ trigger_error($message, $errorType);
401
+ }
402
+ }
403
+
404
+ /**
405
+ * @return bool
406
+ */
407
+ protected function isDebugModeEnabled() {
408
+ if ( $this->debugMode === null ) {
409
+ $this->debugMode = (bool)(constant('WP_DEBUG'));
410
+ }
411
+ return $this->debugMode;
412
+ }
413
+
414
+ /**
415
+ * Get the full name of an update checker filter, action or DB entry.
416
+ *
417
+ * This method adds the "puc_" prefix and the "-$slug" suffix to the filter name.
418
+ * For example, "pre_inject_update" becomes "puc_pre_inject_update-plugin-slug".
419
+ *
420
+ * @param string $baseTag
421
+ * @return string
422
+ */
423
+ public function getUniqueName($baseTag) {
424
+ $name = 'puc_' . $baseTag;
425
+ if ( $this->filterSuffix !== '' ) {
426
+ $name .= '_' . $this->filterSuffix;
427
+ }
428
+ return $name . '-' . $this->slug;
429
+ }
430
+
431
+ /**
432
+ * Store API errors that are generated when checking for updates.
433
+ *
434
+ * @internal
435
+ * @param WP_Error $error
436
+ * @param array|null $httpResponse
437
+ * @param string|null $url
438
+ * @param string|null $slug
439
+ */
440
+ public function collectApiErrors($error, $httpResponse = null, $url = null, $slug = null) {
441
+ if ( isset($slug) && ($slug !== $this->slug) ) {
442
+ return;
443
+ }
444
+
445
+ $this->lastRequestApiErrors[] = array(
446
+ 'error' => $error,
447
+ 'httpResponse' => $httpResponse,
448
+ 'url' => $url,
449
+ );
450
+ }
451
+
452
+ /**
453
+ * @return array
454
+ */
455
+ public function getLastRequestApiErrors() {
456
+ return $this->lastRequestApiErrors;
457
+ }
458
+
459
+ /* -------------------------------------------------------------------
460
+ * PUC filters and filter utilities
461
+ * -------------------------------------------------------------------
462
+ */
463
+
464
+ /**
465
+ * Register a callback for one of the update checker filters.
466
+ *
467
+ * Identical to add_filter(), except it automatically adds the "puc_" prefix
468
+ * and the "-$slug" suffix to the filter name. For example, "request_info_result"
469
+ * becomes "puc_request_info_result-your_plugin_slug".
470
+ *
471
+ * @param string $tag
472
+ * @param callable $callback
473
+ * @param int $priority
474
+ * @param int $acceptedArgs
475
+ */
476
+ public function addFilter($tag, $callback, $priority = 10, $acceptedArgs = 1) {
477
+ add_filter($this->getUniqueName($tag), $callback, $priority, $acceptedArgs);
478
+ }
479
+
480
+ /* -------------------------------------------------------------------
481
+ * Inject updates
482
+ * -------------------------------------------------------------------
483
+ */
484
+
485
+ /**
486
+ * Insert the latest update (if any) into the update list maintained by WP.
487
+ *
488
+ * @param stdClass $updates Update list.
489
+ * @return stdClass Modified update list.
490
+ */
491
+ public function injectUpdate($updates) {
492
+ //Is there an update to insert?
493
+ $update = $this->getUpdate();
494
+
495
+ if ( !$this->shouldShowUpdates() ) {
496
+ $update = null;
497
+ }
498
+
499
+ if ( !empty($update) ) {
500
+ //Let plugins filter the update info before it's passed on to WordPress.
501
+ $update = apply_filters($this->getUniqueName('pre_inject_update'), $update);
502
+ $updates = $this->addUpdateToList($updates, $update->toWpFormat());
503
+ } else {
504
+ //Clean up any stale update info.
505
+ $updates = $this->removeUpdateFromList($updates);
506
+ }
507
+
508
+ return $updates;
509
+ }
510
+
511
+ /**
512
+ * @param stdClass|null $updates
513
+ * @param stdClass|array $updateToAdd
514
+ * @return stdClass
515
+ */
516
+ protected function addUpdateToList($updates, $updateToAdd) {
517
+ if ( !is_object($updates) ) {
518
+ $updates = new stdClass();
519
+ $updates->response = array();
520
+ }
521
+
522
+ $updates->response[$this->getUpdateListKey()] = $updateToAdd;
523
+ return $updates;
524
+ }
525
+
526
+ /**
527
+ * @param stdClass|null $updates
528
+ * @return stdClass|null
529
+ */
530
+ protected function removeUpdateFromList($updates) {
531
+ if ( isset($updates, $updates->response) ) {
532
+ unset($updates->response[$this->getUpdateListKey()]);
533
+ }
534
+ return $updates;
535
+ }
536
+
537
+ /**
538
+ * Get the key that will be used when adding updates to the update list that's maintained
539
+ * by the WordPress core. The list is always an associative array, but the key is different
540
+ * for plugins and themes.
541
+ *
542
+ * @return string
543
+ */
544
+ abstract protected function getUpdateListKey();
545
+
546
+ /**
547
+ * Should we show available updates?
548
+ *
549
+ * Usually the answer is "yes", but there are exceptions. For example, WordPress doesn't
550
+ * support automatic updates installation for mu-plugins, so PUC usually won't show update
551
+ * notifications in that case. See the plugin-specific subclass for details.
552
+ *
553
+ * Note: This method only applies to updates that are displayed (or not) in the WordPress
554
+ * admin. It doesn't affect APIs like requestUpdate and getUpdate.
555
+ *
556
+ * @return bool
557
+ */
558
+ protected function shouldShowUpdates() {
559
+ return true;
560
+ }
561
+
562
+ /* -------------------------------------------------------------------
563
+ * JSON-based update API
564
+ * -------------------------------------------------------------------
565
+ */
566
+
567
+ /**
568
+ * Retrieve plugin or theme metadata from the JSON document at $this->metadataUrl.
569
+ *
570
+ * @param string $metaClass Parse the JSON as an instance of this class. It must have a static fromJson method.
571
+ * @param string $filterRoot
572
+ * @param array $queryArgs Additional query arguments.
573
+ * @return array [Puc_v4p7_Metadata|null, array|WP_Error] A metadata instance and the value returned by wp_remote_get().
574
+ */
575
+ protected function requestMetadata($metaClass, $filterRoot, $queryArgs = array()) {
576
+ //Query args to append to the URL. Plugins can add their own by using a filter callback (see addQueryArgFilter()).
577
+ $queryArgs = array_merge(
578
+ array(
579
+ 'installed_version' => strval($this->getInstalledVersion()),
580
+ 'php' => phpversion(),
581
+ 'locale' => get_locale(),
582
+ ),
583
+ $queryArgs
584
+ );
585
+ $queryArgs = apply_filters($this->getUniqueName($filterRoot . '_query_args'), $queryArgs);
586
+
587
+ //Various options for the wp_remote_get() call. Plugins can filter these, too.
588
+ $options = array(
589
+ 'timeout' => 10, //seconds
590
+ 'headers' => array(
591
+ 'Accept' => 'application/json',
592
+ ),
593
+ );
594
+ $options = apply_filters($this->getUniqueName($filterRoot . '_options'), $options);
595
+
596
+ //The metadata file should be at 'http://your-api.com/url/here/$slug/info.json'
597
+ $url = $this->metadataUrl;
598
+ if ( !empty($queryArgs) ){
599
+ $url = add_query_arg($queryArgs, $url);
600
+ }
601
+
602
+ $result = wp_remote_get($url, $options);
603
+
604
+ $result = apply_filters($this->getUniqueName('request_metadata_http_result'), $result, $url, $options);
605
+
606
+ //Try to parse the response
607
+ $status = $this->validateApiResponse($result);
608
+ $metadata = null;
609
+ if ( !is_wp_error($status) ){
610
+ $metadata = call_user_func(array($metaClass, 'fromJson'), $result['body']);
611
+ } else {
612
+ do_action('puc_api_error', $status, $result, $url, $this->slug);
613
+ $this->triggerError(
614
+ sprintf('The URL %s does not point to a valid metadata file. ', $url)
615
+ . $status->get_error_message(),
616
+ E_USER_WARNING
617
+ );
618
+ }
619
+
620
+ return array($metadata, $result);
621
+ }
622
+
623
+ /**
624
+ * Check if $result is a successful update API response.
625
+ *
626
+ * @param array|WP_Error $result
627
+ * @return true|WP_Error
628
+ */
629
+ protected function validateApiResponse($result) {
630
+ if ( is_wp_error($result) ) { /** @var WP_Error $result */
631
+ return new WP_Error($result->get_error_code(), 'WP HTTP Error: ' . $result->get_error_message());
632
+ }
633
+
634
+ if ( !isset($result['response']['code']) ) {
635
+ return new WP_Error(
636
+ 'puc_no_response_code',
637
+ 'wp_remote_get() returned an unexpected result.'
638
+ );
639
+ }
640
+
641
+ if ( $result['response']['code'] !== 200 ) {
642
+ return new WP_Error(
643
+ 'puc_unexpected_response_code',
644
+ 'HTTP response code is ' . $result['response']['code'] . ' (expected: 200)'
645
+ );
646
+ }
647
+
648
+ if ( empty($result['body']) ) {
649
+ return new WP_Error('puc_empty_response', 'The metadata file appears to be empty.');
650
+ }
651
+
652
+ return true;
653
+ }
654
+
655
+ /* -------------------------------------------------------------------
656
+ * Language packs / Translation updates
657
+ * -------------------------------------------------------------------
658
+ */
659
+
660
+ /**
661
+ * Filter a list of translation updates and return a new list that contains only updates
662
+ * that apply to the current site.
663
+ *
664
+ * @param array $translations
665
+ * @return array
666
+ */
667
+ protected function filterApplicableTranslations($translations) {
668
+ $languages = array_flip(array_values(get_available_languages()));
669
+ $installedTranslations = $this->getInstalledTranslations();
670
+
671
+ $applicableTranslations = array();
672
+ foreach ($translations as $translation) {
673
+ //Does it match one of the available core languages?
674
+ $isApplicable = array_key_exists($translation->language, $languages);
675
+ //Is it more recent than an already-installed translation?
676
+ if ( isset($installedTranslations[$translation->language]) ) {
677
+ $updateTimestamp = strtotime($translation->updated);
678
+ $installedTimestamp = strtotime($installedTranslations[$translation->language]['PO-Revision-Date']);
679
+ $isApplicable = $updateTimestamp > $installedTimestamp;
680
+ }
681
+
682
+ if ( $isApplicable ) {
683
+ $applicableTranslations[] = $translation;
684
+ }
685
+ }
686
+
687
+ return $applicableTranslations;
688
+ }
689
+
690
+ /**
691
+ * Get a list of installed translations for this plugin or theme.
692
+ *
693
+ * @return array
694
+ */
695
+ protected function getInstalledTranslations() {
696
+ if ( !function_exists('wp_get_installed_translations') ) {
697
+ return array();
698
+ }
699
+ $installedTranslations = wp_get_installed_translations($this->translationType . 's');
700
+ if ( isset($installedTranslations[$this->directoryName]) ) {
701
+ $installedTranslations = $installedTranslations[$this->directoryName];
702
+ } else {
703
+ $installedTranslations = array();
704
+ }
705
+ return $installedTranslations;
706
+ }
707
+
708
+ /**
709
+ * Insert translation updates into the list maintained by WordPress.
710
+ *
711
+ * @param stdClass $updates
712
+ * @return stdClass
713
+ */
714
+ public function injectTranslationUpdates($updates) {
715
+ $translationUpdates = $this->getTranslationUpdates();
716
+ if ( empty($translationUpdates) ) {
717
+ return $updates;
718
+ }
719
+
720
+ //Being defensive.
721
+ if ( !is_object($updates) ) {
722
+ $updates = new stdClass();
723
+ }
724
+ if ( !isset($updates->translations) ) {
725
+ $updates->translations = array();
726
+ }
727
+
728
+ //In case there's a name collision with a plugin or theme hosted on wordpress.org,
729
+ //remove any preexisting updates that match our thing.
730
+ $updates->translations = array_values(array_filter(
731
+ $updates->translations,
732
+ array($this, 'isNotMyTranslation')
733
+ ));
734
+
735
+ //Add our updates to the list.
736
+ foreach($translationUpdates as $update) {
737
+ $convertedUpdate = array_merge(
738
+ array(
739
+ 'type' => $this->translationType,
740
+ 'slug' => $this->directoryName,
741
+ 'autoupdate' => 0,
742
+ //AFAICT, WordPress doesn't actually use the "version" field for anything.
743
+ //But lets make sure it's there, just in case.
744
+ 'version' => isset($update->version) ? $update->version : ('1.' . strtotime($update->updated)),
745
+ ),
746
+ (array)$update
747
+ );
748
+
749
+ $updates->translations[] = $convertedUpdate;
750
+ }
751
+
752
+ return $updates;
753
+ }
754
+
755
+ /**
756
+ * Get a list of available translation updates.
757
+ *
758
+ * This method will return an empty array if there are no updates.
759
+ * Uses cached update data.
760
+ *
761
+ * @return array
762
+ */
763
+ public function getTranslationUpdates() {
764
+ return $this->updateState->getTranslations();
765
+ }
766
+
767
+ /**
768
+ * Remove all cached translation updates.
769
+ *
770
+ * @see wp_clean_update_cache
771
+ */
772
+ public function clearCachedTranslationUpdates() {
773
+ $this->updateState->setTranslations(array());
774
+ }
775
+
776
+ /**
777
+ * Filter callback. Keeps only translations that *don't* match this plugin or theme.
778
+ *
779
+ * @param array $translation
780
+ * @return bool
781
+ */
782
+ protected function isNotMyTranslation($translation) {
783
+ $isMatch = isset($translation['type'], $translation['slug'])
784
+ && ($translation['type'] === $this->translationType)
785
+ && ($translation['slug'] === $this->directoryName);
786
+
787
+ return !$isMatch;
788
+ }
789
+
790
+ /* -------------------------------------------------------------------
791
+ * Fix directory name when installing updates
792
+ * -------------------------------------------------------------------
793
+ */
794
+
795
+ /**
796
+ * Rename the update directory to match the existing plugin/theme directory.
797
+ *
798
+ * When WordPress installs a plugin or theme update, it assumes that the ZIP file will contain
799
+ * exactly one directory, and that the directory name will be the same as the directory where
800
+ * the plugin or theme is currently installed.
801
+ *
802
+ * GitHub and other repositories provide ZIP downloads, but they often use directory names like
803
+ * "project-branch" or "project-tag-hash". We need to change the name to the actual plugin folder.
804
+ *
805
+ * This is a hook callback. Don't call it from a plugin.
806
+ *
807
+ * @access protected
808
+ *
809
+ * @param string $source The directory to copy to /wp-content/plugins or /wp-content/themes. Usually a subdirectory of $remoteSource.
810
+ * @param string $remoteSource WordPress has extracted the update to this directory.
811
+ * @param WP_Upgrader $upgrader
812
+ * @return string|WP_Error
813
+ */
814
+ public function fixDirectoryName($source, $remoteSource, $upgrader) {
815
+ global $wp_filesystem;
816
+ /** @var WP_Filesystem_Base $wp_filesystem */
817
+
818
+ //Basic sanity checks.
819
+ if ( !isset($source, $remoteSource, $upgrader, $upgrader->skin, $wp_filesystem) ) {
820
+ return $source;
821
+ }
822
+
823
+ //If WordPress is upgrading anything other than our plugin/theme, leave the directory name unchanged.
824
+ if ( !$this->isBeingUpgraded($upgrader) ) {
825
+ return $source;
826
+ }
827
+
828
+ //Rename the source to match the existing directory.
829
+ $correctedSource = trailingslashit($remoteSource) . $this->directoryName . '/';
830
+ if ( $source !== $correctedSource ) {
831
+ //The update archive should contain a single directory that contains the rest of plugin/theme files.
832
+ //Otherwise, WordPress will try to copy the entire working directory ($source == $remoteSource).
833
+ //We can't rename $remoteSource because that would break WordPress code that cleans up temporary files
834
+ //after update.
835
+ if ( $this->isBadDirectoryStructure($remoteSource) ) {
836
+ return new WP_Error(
837
+ 'puc-incorrect-directory-structure',
838
+ sprintf(
839
+ 'The directory structure of the update is incorrect. All files should be inside ' .
840
+ 'a directory named <span class="code">%s</span>, not at the root of the ZIP archive.',
841
+ htmlentities($this->slug)
842
+ )
843
+ );
844
+ }
845
+
846
+ /** @var WP_Upgrader_Skin $upgrader ->skin */
847
+ $upgrader->skin->feedback(sprintf(
848
+ 'Renaming %s to %s&#8230;',
849
+ '<span class="code">' . basename($source) . '</span>',
850
+ '<span class="code">' . $this->directoryName . '</span>'
851
+ ));
852
+
853
+ if ( $wp_filesystem->move($source, $correctedSource, true) ) {
854
+ $upgrader->skin->feedback('Directory successfully renamed.');
855
+ return $correctedSource;
856
+ } else {
857
+ return new WP_Error(
858
+ 'puc-rename-failed',
859
+ 'Unable to rename the update to match the existing directory.'
860
+ );
861
+ }
862
+ }
863
+
864
+ return $source;
865
+ }
866
+
867
+ /**
868
+ * Is there an update being installed right now, for this plugin or theme?
869
+ *
870
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
871
+ * @return bool
872
+ */
873
+ abstract public function isBeingUpgraded($upgrader = null);
874
+
875
+ /**
876
+ * Check for incorrect update directory structure. An update must contain a single directory,
877
+ * all other files should be inside that directory.
878
+ *
879
+ * @param string $remoteSource Directory path.
880
+ * @return bool
881
+ */
882
+ protected function isBadDirectoryStructure($remoteSource) {
883
+ global $wp_filesystem;
884
+ /** @var WP_Filesystem_Base $wp_filesystem */
885
+
886
+ $sourceFiles = $wp_filesystem->dirlist($remoteSource);
887
+ if ( is_array($sourceFiles) ) {
888
+ $sourceFiles = array_keys($sourceFiles);
889
+ $firstFilePath = trailingslashit($remoteSource) . $sourceFiles[0];
890
+ return (count($sourceFiles) > 1) || (!$wp_filesystem->is_dir($firstFilePath));
891
+ }
892
+
893
+ //Assume it's fine.
894
+ return false;
895
+ }
896
+
897
+ /* -------------------------------------------------------------------
898
+ * DebugBar integration
899
+ * -------------------------------------------------------------------
900
+ */
901
+
902
+ /**
903
+ * Initialize the update checker Debug Bar plugin/add-on thingy.
904
+ */
905
+ public function maybeInitDebugBar() {
906
+ if ( class_exists('Debug_Bar', false) && file_exists(dirname(__FILE__) . '/DebugBar') ) {
907
+ $this->createDebugBarExtension();
908
+ }
909
+ }
910
+
911
+ protected function createDebugBarExtension() {
912
+ return new Puc_v4p7_DebugBar_Extension($this);
913
+ }
914
+
915
+ /**
916
+ * Display additional configuration details in the Debug Bar panel.
917
+ *
918
+ * @param Puc_v4p7_DebugBar_Panel $panel
919
+ */
920
+ public function onDisplayConfiguration($panel) {
921
+ //Do nothing. Subclasses can use this to add additional info to the panel.
922
+ }
923
+
924
+ }
925
+
926
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/UpgraderStatus.php ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_UpgraderStatus', false) ):
3
+
4
+ /**
5
+ * A utility class that helps figure out which plugin or theme WordPress is upgrading.
6
+ *
7
+ * It may seem strange to have a separate class just for that, but the task is surprisingly complicated.
8
+ * Core classes like Plugin_Upgrader don't expose the plugin file name during an in-progress update (AFAICT).
9
+ * This class uses a few workarounds and heuristics to get the file name.
10
+ */
11
+ class Puc_v4p7_UpgraderStatus {
12
+ private $currentType = null; //"plugin" or "theme".
13
+ private $currentId = null; //Plugin basename or theme directory name.
14
+
15
+ public function __construct() {
16
+ //Keep track of which plugin/theme WordPress is currently upgrading.
17
+ add_filter('upgrader_pre_install', array($this, 'setUpgradedThing'), 10, 2);
18
+ add_filter('upgrader_package_options', array($this, 'setUpgradedPluginFromOptions'), 10, 1);
19
+ add_filter('upgrader_post_install', array($this, 'clearUpgradedThing'), 10, 1);
20
+ add_action('upgrader_process_complete', array($this, 'clearUpgradedThing'), 10, 1);
21
+ }
22
+
23
+ /**
24
+ * Is there and update being installed RIGHT NOW, for a specific plugin?
25
+ *
26
+ * Caution: This method is unreliable. WordPress doesn't make it easy to figure out what it is upgrading,
27
+ * and upgrader implementations are liable to change without notice.
28
+ *
29
+ * @param string $pluginFile The plugin to check.
30
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
31
+ * @return bool True if the plugin identified by $pluginFile is being upgraded.
32
+ */
33
+ public function isPluginBeingUpgraded($pluginFile, $upgrader = null) {
34
+ return $this->isBeingUpgraded('plugin', $pluginFile, $upgrader);
35
+ }
36
+
37
+ /**
38
+ * Is there an update being installed for a specific theme?
39
+ *
40
+ * @param string $stylesheet Theme directory name.
41
+ * @param WP_Upgrader|null $upgrader The upgrader that's performing the current update.
42
+ * @return bool
43
+ */
44
+ public function isThemeBeingUpgraded($stylesheet, $upgrader = null) {
45
+ return $this->isBeingUpgraded('theme', $stylesheet, $upgrader);
46
+ }
47
+
48
+ /**
49
+ * Check if a specific theme or plugin is being upgraded.
50
+ *
51
+ * @param string $type
52
+ * @param string $id
53
+ * @param Plugin_Upgrader|WP_Upgrader|null $upgrader
54
+ * @return bool
55
+ */
56
+ protected function isBeingUpgraded($type, $id, $upgrader = null) {
57
+ if ( isset($upgrader) ) {
58
+ list($currentType, $currentId) = $this->getThingBeingUpgradedBy($upgrader);
59
+ if ( $currentType !== null ) {
60
+ $this->currentType = $currentType;
61
+ $this->currentId = $currentId;
62
+ }
63
+ }
64
+ return ($this->currentType === $type) && ($this->currentId === $id);
65
+ }
66
+
67
+ /**
68
+ * Figure out which theme or plugin is being upgraded by a WP_Upgrader instance.
69
+ *
70
+ * Returns an array with two items. The first item is the type of the thing that's being
71
+ * upgraded: "plugin" or "theme". The second item is either the plugin basename or
72
+ * the theme directory name. If we can't determine what the upgrader is doing, both items
73
+ * will be NULL.
74
+ *
75
+ * Examples:
76
+ * ['plugin', 'plugin-dir-name/plugin.php']
77
+ * ['theme', 'theme-dir-name']
78
+ *
79
+ * @param Plugin_Upgrader|WP_Upgrader $upgrader
80
+ * @return array
81
+ */
82
+ private function getThingBeingUpgradedBy($upgrader) {
83
+ if ( !isset($upgrader, $upgrader->skin) ) {
84
+ return array(null, null);
85
+ }
86
+
87
+ //Figure out which plugin or theme is being upgraded.
88
+ $pluginFile = null;
89
+ $themeDirectoryName = null;
90
+
91
+ $skin = $upgrader->skin;
92
+ if ( isset($skin->theme_info) && ($skin->theme_info instanceof WP_Theme) ) {
93
+ $themeDirectoryName = $skin->theme_info->get_stylesheet();
94
+ } elseif ( $skin instanceof Plugin_Upgrader_Skin ) {
95
+ if ( isset($skin->plugin) && is_string($skin->plugin) && ($skin->plugin !== '') ) {
96
+ $pluginFile = $skin->plugin;
97
+ }
98
+ } elseif ( $skin instanceof Theme_Upgrader_Skin ) {
99
+ if ( isset($skin->theme) && is_string($skin->theme) && ($skin->theme !== '') ) {
100
+ $themeDirectoryName = $skin->theme;
101
+ }
102
+ } elseif ( isset($skin->plugin_info) && is_array($skin->plugin_info) ) {
103
+ //This case is tricky because Bulk_Plugin_Upgrader_Skin (etc) doesn't actually store the plugin
104
+ //filename anywhere. Instead, it has the plugin headers in $plugin_info. So the best we can
105
+ //do is compare those headers to the headers of installed plugins.
106
+ $pluginFile = $this->identifyPluginByHeaders($skin->plugin_info);
107
+ }
108
+
109
+ if ( $pluginFile !== null ) {
110
+ return array('plugin', $pluginFile);
111
+ } elseif ( $themeDirectoryName !== null ) {
112
+ return array('theme', $themeDirectoryName);
113
+ }
114
+ return array(null, null);
115
+ }
116
+
117
+ /**
118
+ * Identify an installed plugin based on its headers.
119
+ *
120
+ * @param array $searchHeaders The plugin file header to look for.
121
+ * @return string|null Plugin basename ("foo/bar.php"), or NULL if we can't identify the plugin.
122
+ */
123
+ private function identifyPluginByHeaders($searchHeaders) {
124
+ if ( !function_exists('get_plugins') ){
125
+ /** @noinspection PhpIncludeInspection */
126
+ require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
127
+ }
128
+
129
+ $installedPlugins = get_plugins();
130
+ $matches = array();
131
+ foreach($installedPlugins as $pluginBasename => $headers) {
132
+ $diff1 = array_diff_assoc($headers, $searchHeaders);
133
+ $diff2 = array_diff_assoc($searchHeaders, $headers);
134
+ if ( empty($diff1) && empty($diff2) ) {
135
+ $matches[] = $pluginBasename;
136
+ }
137
+ }
138
+
139
+ //It's possible (though very unlikely) that there could be two plugins with identical
140
+ //headers. In that case, we can't unambiguously identify the plugin that's being upgraded.
141
+ if ( count($matches) !== 1 ) {
142
+ return null;
143
+ }
144
+
145
+ return reset($matches);
146
+ }
147
+
148
+ /**
149
+ * @access private
150
+ *
151
+ * @param mixed $input
152
+ * @param array $hookExtra
153
+ * @return mixed Returns $input unaltered.
154
+ */
155
+ public function setUpgradedThing($input, $hookExtra) {
156
+ if ( !empty($hookExtra['plugin']) && is_string($hookExtra['plugin']) ) {
157
+ $this->currentId = $hookExtra['plugin'];
158
+ $this->currentType = 'plugin';
159
+ } elseif ( !empty($hookExtra['theme']) && is_string($hookExtra['theme']) ) {
160
+ $this->currentId = $hookExtra['theme'];
161
+ $this->currentType = 'theme';
162
+ } else {
163
+ $this->currentType = null;
164
+ $this->currentId = null;
165
+ }
166
+ return $input;
167
+ }
168
+
169
+ /**
170
+ * @access private
171
+ *
172
+ * @param array $options
173
+ * @return array
174
+ */
175
+ public function setUpgradedPluginFromOptions($options) {
176
+ if ( isset($options['hook_extra']['plugin']) && is_string($options['hook_extra']['plugin']) ) {
177
+ $this->currentType = 'plugin';
178
+ $this->currentId = $options['hook_extra']['plugin'];
179
+ } else {
180
+ $this->currentType = null;
181
+ $this->currentId = null;
182
+ }
183
+ return $options;
184
+ }
185
+
186
+ /**
187
+ * @access private
188
+ *
189
+ * @param mixed $input
190
+ * @return mixed Returns $input unaltered.
191
+ */
192
+ public function clearUpgradedThing($input = null) {
193
+ $this->currentId = null;
194
+ $this->currentType = null;
195
+ return $input;
196
+ }
197
+ }
198
+
199
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Utils.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Utils', false) ):
4
+
5
+ class Puc_v4p7_Utils {
6
+ /**
7
+ * Get a value from a nested array or object based on a path.
8
+ *
9
+ * @param array|object|null $collection Get an entry from this array.
10
+ * @param array|string $path A list of array keys in hierarchy order, or a string path like "foo.bar.baz".
11
+ * @param mixed $default The value to return if the specified path is not found.
12
+ * @param string $separator Path element separator. Only applies to string paths.
13
+ * @return mixed
14
+ */
15
+ public static function get($collection, $path, $default = null, $separator = '.') {
16
+ if ( is_string($path) ) {
17
+ $path = explode($separator, $path);
18
+ }
19
+
20
+ //Follow the $path into $input as far as possible.
21
+ $currentValue = $collection;
22
+ foreach ($path as $node) {
23
+ if ( is_array($currentValue) && isset($currentValue[$node]) ) {
24
+ $currentValue = $currentValue[$node];
25
+ } else if ( is_object($currentValue) && isset($currentValue->$node) ) {
26
+ $currentValue = $currentValue->$node;
27
+ } else {
28
+ return $default;
29
+ }
30
+ }
31
+
32
+ return $currentValue;
33
+ }
34
+
35
+ /**
36
+ * Get the first array element that is not empty.
37
+ *
38
+ * @param array $values
39
+ * @param mixed|null $default Returns this value if there are no non-empty elements.
40
+ * @return mixed|null
41
+ */
42
+ public static function findNotEmpty($values, $default = null) {
43
+ if ( empty($values) ) {
44
+ return $default;
45
+ }
46
+
47
+ foreach ($values as $value) {
48
+ if ( !empty($value) ) {
49
+ return $value;
50
+ }
51
+ }
52
+
53
+ return $default;
54
+ }
55
+
56
+ /**
57
+ * Check if the input string starts with the specified prefix.
58
+ *
59
+ * @param string $input
60
+ * @param string $prefix
61
+ * @return bool
62
+ */
63
+ public static function startsWith($input, $prefix) {
64
+ $length = strlen($prefix);
65
+ return (substr($input, 0, $length) === $prefix);
66
+ }
67
+ }
68
+
69
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Api.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Vcs_Api') ):
3
+
4
+ abstract class Puc_v4p7_Vcs_Api {
5
+ protected $tagNameProperty = 'name';
6
+ protected $slug = '';
7
+
8
+ /**
9
+ * @var string
10
+ */
11
+ protected $repositoryUrl = '';
12
+
13
+ /**
14
+ * @var mixed Authentication details for private repositories. Format depends on service.
15
+ */
16
+ protected $credentials = null;
17
+
18
+ /**
19
+ * @var string The filter tag that's used to filter options passed to wp_remote_get.
20
+ * For example, "puc_request_info_options-slug" or "puc_request_update_options_theme-slug".
21
+ */
22
+ protected $httpFilterName = '';
23
+
24
+ /**
25
+ * @var string|null
26
+ */
27
+ protected $localDirectory = null;
28
+
29
+ /**
30
+ * Puc_v4p7_Vcs_Api constructor.
31
+ *
32
+ * @param string $repositoryUrl
33
+ * @param array|string|null $credentials
34
+ */
35
+ public function __construct($repositoryUrl, $credentials = null) {
36
+ $this->repositoryUrl = $repositoryUrl;
37
+ $this->setAuthentication($credentials);
38
+ }
39
+
40
+ /**
41
+ * @return string
42
+ */
43
+ public function getRepositoryUrl() {
44
+ return $this->repositoryUrl;
45
+ }
46
+
47
+ /**
48
+ * Figure out which reference (i.e tag or branch) contains the latest version.
49
+ *
50
+ * @param string $configBranch Start looking in this branch.
51
+ * @return null|Puc_v4p7_Vcs_Reference
52
+ */
53
+ abstract public function chooseReference($configBranch);
54
+
55
+ /**
56
+ * Get the readme.txt file from the remote repository and parse it
57
+ * according to the plugin readme standard.
58
+ *
59
+ * @param string $ref Tag or branch name.
60
+ * @return array Parsed readme.
61
+ */
62
+ public function getRemoteReadme($ref = 'master') {
63
+ $fileContents = $this->getRemoteFile($this->getLocalReadmeName(), $ref);
64
+ if ( empty($fileContents) ) {
65
+ return array();
66
+ }
67
+
68
+ $parser = new PucReadmeParser();
69
+ return $parser->parse_readme_contents($fileContents);
70
+ }
71
+
72
+ /**
73
+ * Get the case-sensitive name of the local readme.txt file.
74
+ *
75
+ * In most cases it should just be called "readme.txt", but some plugins call it "README.txt",
76
+ * "README.TXT", or even "Readme.txt". Most VCS are case-sensitive so we need to know the correct
77
+ * capitalization.
78
+ *
79
+ * Defaults to "readme.txt" (all lowercase).
80
+ *
81
+ * @return string
82
+ */
83
+ public function getLocalReadmeName() {
84
+ static $fileName = null;
85
+ if ( $fileName !== null ) {
86
+ return $fileName;
87
+ }
88
+
89
+ $fileName = 'readme.txt';
90
+ if ( isset($this->localDirectory) ) {
91
+ $files = scandir($this->localDirectory);
92
+ if ( !empty($files) ) {
93
+ foreach ($files as $possibleFileName) {
94
+ if ( strcasecmp($possibleFileName, 'readme.txt') === 0 ) {
95
+ $fileName = $possibleFileName;
96
+ break;
97
+ }
98
+ }
99
+ }
100
+ }
101
+ return $fileName;
102
+ }
103
+
104
+ /**
105
+ * Get a branch.
106
+ *
107
+ * @param string $branchName
108
+ * @return Puc_v4p7_Vcs_Reference|null
109
+ */
110
+ abstract public function getBranch($branchName);
111
+
112
+ /**
113
+ * Get a specific tag.
114
+ *
115
+ * @param string $tagName
116
+ * @return Puc_v4p7_Vcs_Reference|null
117
+ */
118
+ abstract public function getTag($tagName);
119
+
120
+ /**
121
+ * Get the tag that looks like the highest version number.
122
+ * (Implementations should skip pre-release versions if possible.)
123
+ *
124
+ * @return Puc_v4p7_Vcs_Reference|null
125
+ */
126
+ abstract public function getLatestTag();
127
+
128
+ /**
129
+ * Check if a tag name string looks like a version number.
130
+ *
131
+ * @param string $name
132
+ * @return bool
133
+ */
134
+ protected function looksLikeVersion($name) {
135
+ //Tag names may be prefixed with "v", e.g. "v1.2.3".
136
+ $name = ltrim($name, 'v');
137
+
138
+ //The version string must start with a number.
139
+ if ( !is_numeric(substr($name, 0, 1)) ) {
140
+ return false;
141
+ }
142
+
143
+ //The goal is to accept any SemVer-compatible or "PHP-standardized" version number.
144
+ return (preg_match('@^(\d{1,5}?)(\.\d{1,10}?){0,4}?($|[abrdp+_\-]|\s)@i', $name) === 1);
145
+ }
146
+
147
+ /**
148
+ * Check if a tag appears to be named like a version number.
149
+ *
150
+ * @param stdClass $tag
151
+ * @return bool
152
+ */
153
+ protected function isVersionTag($tag) {
154
+ $property = $this->tagNameProperty;
155
+ return isset($tag->$property) && $this->looksLikeVersion($tag->$property);
156
+ }
157
+
158
+ /**
159
+ * Sort a list of tags as if they were version numbers.
160
+ * Tags that don't look like version number will be removed.
161
+ *
162
+ * @param stdClass[] $tags Array of tag objects.
163
+ * @return stdClass[] Filtered array of tags sorted in descending order.
164
+ */
165
+ protected function sortTagsByVersion($tags) {
166
+ //Keep only those tags that look like version numbers.
167
+ $versionTags = array_filter($tags, array($this, 'isVersionTag'));
168
+ //Sort them in descending order.
169
+ usort($versionTags, array($this, 'compareTagNames'));
170
+
171
+ return $versionTags;
172
+ }
173
+
174
+ /**
175
+ * Compare two tags as if they were version number.
176
+ *
177
+ * @param stdClass $tag1 Tag object.
178
+ * @param stdClass $tag2 Another tag object.
179
+ * @return int
180
+ */
181
+ protected function compareTagNames($tag1, $tag2) {
182
+ $property = $this->tagNameProperty;
183
+ if ( !isset($tag1->$property) ) {
184
+ return 1;
185
+ }
186
+ if ( !isset($tag2->$property) ) {
187
+ return -1;
188
+ }
189
+ return -version_compare(ltrim($tag1->$property, 'v'), ltrim($tag2->$property, 'v'));
190
+ }
191
+
192
+ /**
193
+ * Get the contents of a file from a specific branch or tag.
194
+ *
195
+ * @param string $path File name.
196
+ * @param string $ref
197
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
198
+ */
199
+ abstract public function getRemoteFile($path, $ref = 'master');
200
+
201
+ /**
202
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
203
+ *
204
+ * @param string $ref Reference name (e.g. branch or tag).
205
+ * @return string|null
206
+ */
207
+ abstract public function getLatestCommitTime($ref);
208
+
209
+ /**
210
+ * Get the contents of the changelog file from the repository.
211
+ *
212
+ * @param string $ref
213
+ * @param string $localDirectory Full path to the local plugin or theme directory.
214
+ * @return null|string The HTML contents of the changelog.
215
+ */
216
+ public function getRemoteChangelog($ref, $localDirectory) {
217
+ $filename = $this->findChangelogName($localDirectory);
218
+ if ( empty($filename) ) {
219
+ return null;
220
+ }
221
+
222
+ $changelog = $this->getRemoteFile($filename, $ref);
223
+ if ( $changelog === null ) {
224
+ return null;
225
+ }
226
+
227
+ /** @noinspection PhpUndefinedClassInspection */
228
+ return Parsedown::instance()->text($changelog);
229
+ }
230
+
231
+ /**
232
+ * Guess the name of the changelog file.
233
+ *
234
+ * @param string $directory
235
+ * @return string|null
236
+ */
237
+ protected function findChangelogName($directory = null) {
238
+ if ( !isset($directory) ) {
239
+ $directory = $this->localDirectory;
240
+ }
241
+ if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
242
+ return null;
243
+ }
244
+
245
+ $possibleNames = array('CHANGES.md', 'CHANGELOG.md', 'changes.md', 'changelog.md');
246
+ $files = scandir($directory);
247
+ $foundNames = array_intersect($possibleNames, $files);
248
+
249
+ if ( !empty($foundNames) ) {
250
+ return reset($foundNames);
251
+ }
252
+ return null;
253
+ }
254
+
255
+ /**
256
+ * Set authentication credentials.
257
+ *
258
+ * @param $credentials
259
+ */
260
+ public function setAuthentication($credentials) {
261
+ $this->credentials = $credentials;
262
+ }
263
+
264
+ public function isAuthenticationEnabled() {
265
+ return !empty($this->credentials);
266
+ }
267
+
268
+ /**
269
+ * @param string $url
270
+ * @return string
271
+ */
272
+ public function signDownloadUrl($url) {
273
+ return $url;
274
+ }
275
+
276
+ /**
277
+ * @param string $filterName
278
+ */
279
+ public function setHttpFilterName($filterName) {
280
+ $this->httpFilterName = $filterName;
281
+ }
282
+
283
+ /**
284
+ * @param string $directory
285
+ */
286
+ public function setLocalDirectory($directory) {
287
+ if ( empty($directory) || !is_dir($directory) || ($directory === '.') ) {
288
+ $this->localDirectory = null;
289
+ } else {
290
+ $this->localDirectory = $directory;
291
+ }
292
+ }
293
+
294
+ /**
295
+ * @param string $slug
296
+ */
297
+ public function setSlug($slug) {
298
+ $this->slug = $slug;
299
+ }
300
+ }
301
+
302
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BaseChecker.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !interface_exists('Puc_v4p7_Vcs_BaseChecker', false) ):
3
+
4
+ interface Puc_v4p7_Vcs_BaseChecker {
5
+ /**
6
+ * Set the repository branch to use for updates. Defaults to 'master'.
7
+ *
8
+ * @param string $branch
9
+ * @return $this
10
+ */
11
+ public function setBranch($branch);
12
+
13
+ /**
14
+ * Set authentication credentials.
15
+ *
16
+ * @param array|string $credentials
17
+ * @return $this
18
+ */
19
+ public function setAuthentication($credentials);
20
+
21
+ /**
22
+ * @return Puc_v4p7_Vcs_Api
23
+ */
24
+ public function getVcsApi();
25
+ }
26
+
27
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/BitBucketApi.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Vcs_BitBucketApi', false) ):
3
+
4
+ class Puc_v4p7_Vcs_BitBucketApi extends Puc_v4p7_Vcs_Api {
5
+ /**
6
+ * @var Puc_v4p7_OAuthSignature
7
+ */
8
+ private $oauth = null;
9
+
10
+ /**
11
+ * @var string
12
+ */
13
+ private $username;
14
+
15
+ /**
16
+ * @var string
17
+ */
18
+ private $repository;
19
+
20
+ public function __construct($repositoryUrl, $credentials = array()) {
21
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
22
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
23
+ $this->username = $matches['username'];
24
+ $this->repository = $matches['repository'];
25
+ } else {
26
+ throw new InvalidArgumentException('Invalid BitBucket repository URL: "' . $repositoryUrl . '"');
27
+ }
28
+
29
+ parent::__construct($repositoryUrl, $credentials);
30
+ }
31
+
32
+ /**
33
+ * Figure out which reference (i.e tag or branch) contains the latest version.
34
+ *
35
+ * @param string $configBranch Start looking in this branch.
36
+ * @return null|Puc_v4p7_Vcs_Reference
37
+ */
38
+ public function chooseReference($configBranch) {
39
+ $updateSource = null;
40
+
41
+ //Check if there's a "Stable tag: 1.2.3" header that points to a valid tag.
42
+ $updateSource = $this->getStableTag($configBranch);
43
+
44
+ //Look for version-like tags.
45
+ if ( !$updateSource && ($configBranch === 'master') ) {
46
+ $updateSource = $this->getLatestTag();
47
+ }
48
+ //If all else fails, use the specified branch itself.
49
+ if ( !$updateSource ) {
50
+ $updateSource = $this->getBranch($configBranch);
51
+ }
52
+
53
+ return $updateSource;
54
+ }
55
+
56
+ public function getBranch($branchName) {
57
+ $branch = $this->api('/refs/branches/' . $branchName);
58
+ if ( is_wp_error($branch) || empty($branch) ) {
59
+ return null;
60
+ }
61
+
62
+ return new Puc_v4p7_Vcs_Reference(array(
63
+ 'name' => $branch->name,
64
+ 'updated' => $branch->target->date,
65
+ 'downloadUrl' => $this->getDownloadUrl($branch->name),
66
+ ));
67
+ }
68
+
69
+ /**
70
+ * Get a specific tag.
71
+ *
72
+ * @param string $tagName
73
+ * @return Puc_v4p7_Vcs_Reference|null
74
+ */
75
+ public function getTag($tagName) {
76
+ $tag = $this->api('/refs/tags/' . $tagName);
77
+ if ( is_wp_error($tag) || empty($tag) ) {
78
+ return null;
79
+ }
80
+
81
+ return new Puc_v4p7_Vcs_Reference(array(
82
+ 'name' => $tag->name,
83
+ 'version' => ltrim($tag->name, 'v'),
84
+ 'updated' => $tag->target->date,
85
+ 'downloadUrl' => $this->getDownloadUrl($tag->name),
86
+ ));
87
+ }
88
+
89
+ /**
90
+ * Get the tag that looks like the highest version number.
91
+ *
92
+ * @return Puc_v4p7_Vcs_Reference|null
93
+ */
94
+ public function getLatestTag() {
95
+ $tags = $this->api('/refs/tags?sort=-target.date');
96
+ if ( !isset($tags, $tags->values) || !is_array($tags->values) ) {
97
+ return null;
98
+ }
99
+
100
+ //Filter and sort the list of tags.
101
+ $versionTags = $this->sortTagsByVersion($tags->values);
102
+
103
+ //Return the first result.
104
+ if ( !empty($versionTags) ) {
105
+ $tag = $versionTags[0];
106
+ return new Puc_v4p7_Vcs_Reference(array(
107
+ 'name' => $tag->name,
108
+ 'version' => ltrim($tag->name, 'v'),
109
+ 'updated' => $tag->target->date,
110
+ 'downloadUrl' => $this->getDownloadUrl($tag->name),
111
+ ));
112
+ }
113
+ return null;
114
+ }
115
+
116
+ /**
117
+ * Get the tag/ref specified by the "Stable tag" header in the readme.txt of a given branch.
118
+ *
119
+ * @param string $branch
120
+ * @return null|Puc_v4p7_Vcs_Reference
121
+ */
122
+ protected function getStableTag($branch) {
123
+ $remoteReadme = $this->getRemoteReadme($branch);
124
+ if ( !empty($remoteReadme['stable_tag']) ) {
125
+ $tag = $remoteReadme['stable_tag'];
126
+
127
+ //You can explicitly opt out of using tags by setting "Stable tag" to
128
+ //"trunk" or the name of the current branch.
129
+ if ( ($tag === $branch) || ($tag === 'trunk') ) {
130
+ return $this->getBranch($branch);
131
+ }
132
+
133
+ return $this->getTag($tag);
134
+ }
135
+
136
+ return null;
137
+ }
138
+
139
+ /**
140
+ * @param string $ref
141
+ * @return string
142
+ */
143
+ protected function getDownloadUrl($ref) {
144
+ return sprintf(
145
+ 'https://bitbucket.org/%s/%s/get/%s.zip',
146
+ $this->username,
147
+ $this->repository,
148
+ $ref
149
+ );
150
+ }
151
+
152
+ /**
153
+ * Get the contents of a file from a specific branch or tag.
154
+ *
155
+ * @param string $path File name.
156
+ * @param string $ref
157
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
158
+ */
159
+ public function getRemoteFile($path, $ref = 'master') {
160
+ $response = $this->api('src/' . $ref . '/' . ltrim($path));
161
+ if ( is_wp_error($response) || !is_string($response) ) {
162
+ return null;
163
+ }
164
+ return $response;
165
+ }
166
+
167
+ /**
168
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
169
+ *
170
+ * @param string $ref Reference name (e.g. branch or tag).
171
+ * @return string|null
172
+ */
173
+ public function getLatestCommitTime($ref) {
174
+ $response = $this->api('commits/' . $ref);
175
+ if ( isset($response->values, $response->values[0], $response->values[0]->date) ) {
176
+ return $response->values[0]->date;
177
+ }
178
+ return null;
179
+ }
180
+
181
+ /**
182
+ * Perform a BitBucket API 2.0 request.
183
+ *
184
+ * @param string $url
185
+ * @param string $version
186
+ * @return mixed|WP_Error
187
+ */
188
+ public function api($url, $version = '2.0') {
189
+ $url = ltrim($url, '/');
190
+ $isSrcResource = Puc_v4p7_Utils::startsWith($url, 'src/');
191
+
192
+ $url = implode('/', array(
193
+ 'https://api.bitbucket.org',
194
+ $version,
195
+ 'repositories',
196
+ $this->username,
197
+ $this->repository,
198
+ $url
199
+ ));
200
+ $baseUrl = $url;
201
+
202
+ if ( $this->oauth ) {
203
+ $url = $this->oauth->sign($url,'GET');
204
+ }
205
+
206
+ $options = array('timeout' => 10);
207
+ if ( !empty($this->httpFilterName) ) {
208
+ $options = apply_filters($this->httpFilterName, $options);
209
+ }
210
+ $response = wp_remote_get($url, $options);
211
+ if ( is_wp_error($response) ) {
212
+ do_action('puc_api_error', $response, null, $url, $this->slug);
213
+ return $response;
214
+ }
215
+
216
+ $code = wp_remote_retrieve_response_code($response);
217
+ $body = wp_remote_retrieve_body($response);
218
+ if ( $code === 200 ) {
219
+ if ( $isSrcResource ) {
220
+ //Most responses are JSON-encoded, but src resources just
221
+ //return raw file contents.
222
+ $document = $body;
223
+ } else {
224
+ $document = json_decode($body);
225
+ }
226
+ return $document;
227
+ }
228
+
229
+ $error = new WP_Error(
230
+ 'puc-bitbucket-http-error',
231
+ sprintf('BitBucket API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
232
+ );
233
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
234
+
235
+ return $error;
236
+ }
237
+
238
+ /**
239
+ * @param array $credentials
240
+ */
241
+ public function setAuthentication($credentials) {
242
+ parent::setAuthentication($credentials);
243
+
244
+ if ( !empty($credentials) && !empty($credentials['consumer_key']) ) {
245
+ $this->oauth = new Puc_v4p7_OAuthSignature(
246
+ $credentials['consumer_key'],
247
+ $credentials['consumer_secret']
248
+ );
249
+ } else {
250
+ $this->oauth = null;
251
+ }
252
+ }
253
+
254
+ public function signDownloadUrl($url) {
255
+ //Add authentication data to download URLs. Since OAuth signatures incorporate
256
+ //timestamps, we have to do this immediately before inserting the update. Otherwise
257
+ //authentication could fail due to a stale timestamp.
258
+ if ( $this->oauth ) {
259
+ $url = $this->oauth->sign($url);
260
+ }
261
+ return $url;
262
+ }
263
+ }
264
+
265
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitHubApi.php ADDED
@@ -0,0 +1,413 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Vcs_GitHubApi', false) ):
4
+
5
+ class Puc_v4p7_Vcs_GitHubApi extends Puc_v4p7_Vcs_Api {
6
+ /**
7
+ * @var string GitHub username.
8
+ */
9
+ protected $userName;
10
+ /**
11
+ * @var string GitHub repository name.
12
+ */
13
+ protected $repositoryName;
14
+
15
+ /**
16
+ * @var string Either a fully qualified repository URL, or just "user/repo-name".
17
+ */
18
+ protected $repositoryUrl;
19
+
20
+ /**
21
+ * @var string GitHub authentication token. Optional.
22
+ */
23
+ protected $accessToken;
24
+
25
+ /**
26
+ * @var bool Whether to download release assets instead of the auto-generated source code archives.
27
+ */
28
+ protected $releaseAssetsEnabled = false;
29
+
30
+ /**
31
+ * @var string|null Regular expression that's used to filter release assets by name. Optional.
32
+ */
33
+ protected $assetFilterRegex = null;
34
+
35
+ /**
36
+ * @var string|null The unchanging part of a release asset URL. Used to identify download attempts.
37
+ */
38
+ protected $assetApiBaseUrl = null;
39
+
40
+ public function __construct($repositoryUrl, $accessToken = null) {
41
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
42
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
43
+ $this->userName = $matches['username'];
44
+ $this->repositoryName = $matches['repository'];
45
+ } else {
46
+ throw new InvalidArgumentException('Invalid GitHub repository URL: "' . $repositoryUrl . '"');
47
+ }
48
+
49
+ parent::__construct($repositoryUrl, $accessToken);
50
+ }
51
+
52
+ /**
53
+ * Get the latest release from GitHub.
54
+ *
55
+ * @return Puc_v4p7_Vcs_Reference|null
56
+ */
57
+ public function getLatestRelease() {
58
+ $release = $this->api('/repos/:user/:repo/releases/latest');
59
+ if ( is_wp_error($release) || !is_object($release) || !isset($release->tag_name) ) {
60
+ return null;
61
+ }
62
+
63
+ $reference = new Puc_v4p7_Vcs_Reference(array(
64
+ 'name' => $release->tag_name,
65
+ 'version' => ltrim($release->tag_name, 'v'), //Remove the "v" prefix from "v1.2.3".
66
+ 'downloadUrl' => $this->signDownloadUrl($release->zipball_url),
67
+ 'updated' => $release->created_at,
68
+ 'apiResponse' => $release,
69
+ ));
70
+
71
+ if ( isset($release->assets[0]) ) {
72
+ $reference->downloadCount = $release->assets[0]->download_count;
73
+ }
74
+
75
+ if ( $this->releaseAssetsEnabled && isset($release->assets, $release->assets[0]) ) {
76
+ //Use the first release asset that matches the specified regular expression.
77
+ $matchingAssets = array_filter($release->assets, array($this, 'matchesAssetFilter'));
78
+ if ( !empty($matchingAssets) ) {
79
+ if ( $this->isAuthenticationEnabled() ) {
80
+ /**
81
+ * Keep in mind that we'll need to add an "Accept" header to download this asset.
82
+ * @see setReleaseDownloadHeader()
83
+ */
84
+ $reference->downloadUrl = $this->signDownloadUrl($matchingAssets[0]->url);
85
+ } else {
86
+ //It seems that browser_download_url only works for public repositories.
87
+ //Using an access_token doesn't help. Maybe OAuth would work?
88
+ $reference->downloadUrl = $matchingAssets[0]->browser_download_url;
89
+ }
90
+
91
+ $reference->downloadCount = $matchingAssets[0]->download_count;
92
+ }
93
+ }
94
+
95
+ if ( !empty($release->body) ) {
96
+ /** @noinspection PhpUndefinedClassInspection */
97
+ $reference->changelog = Parsedown::instance()->text($release->body);
98
+ }
99
+
100
+ return $reference;
101
+ }
102
+
103
+ /**
104
+ * Get the tag that looks like the highest version number.
105
+ *
106
+ * @return Puc_v4p7_Vcs_Reference|null
107
+ */
108
+ public function getLatestTag() {
109
+ $tags = $this->api('/repos/:user/:repo/tags');
110
+
111
+ if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) {
112
+ return null;
113
+ }
114
+
115
+ $versionTags = $this->sortTagsByVersion($tags);
116
+ if ( empty($versionTags) ) {
117
+ return null;
118
+ }
119
+
120
+ $tag = $versionTags[0];
121
+ return new Puc_v4p7_Vcs_Reference(array(
122
+ 'name' => $tag->name,
123
+ 'version' => ltrim($tag->name, 'v'),
124
+ 'downloadUrl' => $this->signDownloadUrl($tag->zipball_url),
125
+ 'apiResponse' => $tag,
126
+ ));
127
+ }
128
+
129
+ /**
130
+ * Get a branch by name.
131
+ *
132
+ * @param string $branchName
133
+ * @return null|Puc_v4p7_Vcs_Reference
134
+ */
135
+ public function getBranch($branchName) {
136
+ $branch = $this->api('/repos/:user/:repo/branches/' . $branchName);
137
+ if ( is_wp_error($branch) || empty($branch) ) {
138
+ return null;
139
+ }
140
+
141
+ $reference = new Puc_v4p7_Vcs_Reference(array(
142
+ 'name' => $branch->name,
143
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
144
+ 'apiResponse' => $branch,
145
+ ));
146
+
147
+ if ( isset($branch->commit, $branch->commit->commit, $branch->commit->commit->author->date) ) {
148
+ $reference->updated = $branch->commit->commit->author->date;
149
+ }
150
+
151
+ return $reference;
152
+ }
153
+
154
+ /**
155
+ * Get the latest commit that changed the specified file.
156
+ *
157
+ * @param string $filename
158
+ * @param string $ref Reference name (e.g. branch or tag).
159
+ * @return StdClass|null
160
+ */
161
+ public function getLatestCommit($filename, $ref = 'master') {
162
+ $commits = $this->api(
163
+ '/repos/:user/:repo/commits',
164
+ array(
165
+ 'path' => $filename,
166
+ 'sha' => $ref,
167
+ )
168
+ );
169
+ if ( !is_wp_error($commits) && is_array($commits) && isset($commits[0]) ) {
170
+ return $commits[0];
171
+ }
172
+ return null;
173
+ }
174
+
175
+ /**
176
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
177
+ *
178
+ * @param string $ref Reference name (e.g. branch or tag).
179
+ * @return string|null
180
+ */
181
+ public function getLatestCommitTime($ref) {
182
+ $commits = $this->api('/repos/:user/:repo/commits', array('sha' => $ref));
183
+ if ( !is_wp_error($commits) && is_array($commits) && isset($commits[0]) ) {
184
+ return $commits[0]->commit->author->date;
185
+ }
186
+ return null;
187
+ }
188
+
189
+ /**
190
+ * Perform a GitHub API request.
191
+ *
192
+ * @param string $url
193
+ * @param array $queryParams
194
+ * @return mixed|WP_Error
195
+ */
196
+ protected function api($url, $queryParams = array()) {
197
+ $baseUrl = $url;
198
+ $url = $this->buildApiUrl($url, $queryParams);
199
+
200
+ $options = array('timeout' => 10);
201
+ if ( !empty($this->httpFilterName) ) {
202
+ $options = apply_filters($this->httpFilterName, $options);
203
+ }
204
+ $response = wp_remote_get($url, $options);
205
+ if ( is_wp_error($response) ) {
206
+ do_action('puc_api_error', $response, null, $url, $this->slug);
207
+ return $response;
208
+ }
209
+
210
+ $code = wp_remote_retrieve_response_code($response);
211
+ $body = wp_remote_retrieve_body($response);
212
+ if ( $code === 200 ) {
213
+ $document = json_decode($body);
214
+ return $document;
215
+ }
216
+
217
+ $error = new WP_Error(
218
+ 'puc-github-http-error',
219
+ sprintf('GitHub API error. Base URL: "%s", HTTP status code: %d.', $baseUrl, $code)
220
+ );
221
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
222
+
223
+ return $error;
224
+ }
225
+
226
+ /**
227
+ * Build a fully qualified URL for an API request.
228
+ *
229
+ * @param string $url
230
+ * @param array $queryParams
231
+ * @return string
232
+ */
233
+ protected function buildApiUrl($url, $queryParams) {
234
+ $variables = array(
235
+ 'user' => $this->userName,
236
+ 'repo' => $this->repositoryName,
237
+ );
238
+ foreach ($variables as $name => $value) {
239
+ $url = str_replace('/:' . $name, '/' . urlencode($value), $url);
240
+ }
241
+ $url = 'https://api.github.com' . $url;
242
+
243
+ if ( !empty($this->accessToken) ) {
244
+ $queryParams['access_token'] = $this->accessToken;
245
+ }
246
+ if ( !empty($queryParams) ) {
247
+ $url = add_query_arg($queryParams, $url);
248
+ }
249
+
250
+ return $url;
251
+ }
252
+
253
+ /**
254
+ * Get the contents of a file from a specific branch or tag.
255
+ *
256
+ * @param string $path File name.
257
+ * @param string $ref
258
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
259
+ */
260
+ public function getRemoteFile($path, $ref = 'master') {
261
+ $apiUrl = '/repos/:user/:repo/contents/' . $path;
262
+ $response = $this->api($apiUrl, array('ref' => $ref));
263
+
264
+ if ( is_wp_error($response) || !isset($response->content) || ($response->encoding !== 'base64') ) {
265
+ return null;
266
+ }
267
+ return base64_decode($response->content);
268
+ }
269
+
270
+ /**
271
+ * Generate a URL to download a ZIP archive of the specified branch/tag/etc.
272
+ *
273
+ * @param string $ref
274
+ * @return string
275
+ */
276
+ public function buildArchiveDownloadUrl($ref = 'master') {
277
+ $url = sprintf(
278
+ 'https://api.github.com/repos/%1$s/%2$s/zipball/%3$s',
279
+ urlencode($this->userName),
280
+ urlencode($this->repositoryName),
281
+ urlencode($ref)
282
+ );
283
+ if ( !empty($this->accessToken) ) {
284
+ $url = $this->signDownloadUrl($url);
285
+ }
286
+ return $url;
287
+ }
288
+
289
+ /**
290
+ * Get a specific tag.
291
+ *
292
+ * @param string $tagName
293
+ * @return void
294
+ */
295
+ public function getTag($tagName) {
296
+ //The current GitHub update checker doesn't use getTag, so I didn't bother to implement it.
297
+ throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
298
+ }
299
+
300
+ public function setAuthentication($credentials) {
301
+ parent::setAuthentication($credentials);
302
+ $this->accessToken = is_string($credentials) ? $credentials : null;
303
+ }
304
+
305
+ /**
306
+ * Figure out which reference (i.e tag or branch) contains the latest version.
307
+ *
308
+ * @param string $configBranch Start looking in this branch.
309
+ * @return null|Puc_v4p7_Vcs_Reference
310
+ */
311
+ public function chooseReference($configBranch) {
312
+ $updateSource = null;
313
+
314
+ if ( $configBranch === 'master' ) {
315
+ //Use the latest release.
316
+ $updateSource = $this->getLatestRelease();
317
+ if ( $updateSource === null ) {
318
+ //Failing that, use the tag with the highest version number.
319
+ $updateSource = $this->getLatestTag();
320
+ }
321
+ }
322
+ //Alternatively, just use the branch itself.
323
+ if ( empty($updateSource) ) {
324
+ $updateSource = $this->getBranch($configBranch);
325
+ }
326
+
327
+ return $updateSource;
328
+ }
329
+
330
+ /**
331
+ * @param string $url
332
+ * @return string
333
+ */
334
+ public function signDownloadUrl($url) {
335
+ if ( empty($this->credentials) ) {
336
+ return $url;
337
+ }
338
+ return add_query_arg('access_token', $this->credentials, $url);
339
+ }
340
+
341
+ /**
342
+ * Enable updating via release assets.
343
+ *
344
+ * If the latest release contains no usable assets, the update checker
345
+ * will fall back to using the automatically generated ZIP archive.
346
+ *
347
+ * Private repositories will only work with WordPress 3.7 or later.
348
+ *
349
+ * @param string|null $fileNameRegex Optional. Use only those assets where the file name matches this regex.
350
+ */
351
+ public function enableReleaseAssets($fileNameRegex = null) {
352
+ $this->releaseAssetsEnabled = true;
353
+ $this->assetFilterRegex = $fileNameRegex;
354
+ $this->assetApiBaseUrl = sprintf(
355
+ '//api.github.com/repos/%1$s/%2$s/releases/assets/',
356
+ $this->userName,
357
+ $this->repositoryName
358
+ );
359
+
360
+ //Optimization: Instead of filtering all HTTP requests, let's do it only when
361
+ //WordPress is about to download an update.
362
+ add_filter('upgrader_pre_download', array($this, 'addHttpRequestFilter'), 10, 1); //WP 3.7+
363
+ }
364
+
365
+ /**
366
+ * Does this asset match the file name regex?
367
+ *
368
+ * @param stdClass $releaseAsset
369
+ * @return bool
370
+ */
371
+ protected function matchesAssetFilter($releaseAsset) {
372
+ if ( $this->assetFilterRegex === null ) {
373
+ //The default is to accept all assets.
374
+ return true;
375
+ }
376
+ return isset($releaseAsset->name) && preg_match($this->assetFilterRegex, $releaseAsset->name);
377
+ }
378
+
379
+ /**
380
+ * @internal
381
+ * @param bool $result
382
+ * @return bool
383
+ */
384
+ public function addHttpRequestFilter($result) {
385
+ static $filterAdded = false;
386
+ if ( $this->releaseAssetsEnabled && !$filterAdded && $this->isAuthenticationEnabled() ) {
387
+ add_filter('http_request_args', array($this, 'setReleaseDownloadHeader'), 10, 2);
388
+ $filterAdded = true;
389
+ }
390
+ return $result;
391
+ }
392
+
393
+ /**
394
+ * Set the HTTP header that's necessary to download private release assets.
395
+ *
396
+ * See GitHub docs:
397
+ * @link https://developer.github.com/v3/repos/releases/#get-a-single-release-asset
398
+ *
399
+ * @internal
400
+ * @param array $requestArgs
401
+ * @param string $url
402
+ * @return array
403
+ */
404
+ public function setReleaseDownloadHeader($requestArgs, $url = '') {
405
+ //Is WordPress trying to download one of our assets?
406
+ if ( strpos($url, $this->assetApiBaseUrl) !== false ) {
407
+ $requestArgs['headers']['accept'] = 'application/octet-stream';
408
+ }
409
+ return $requestArgs;
410
+ }
411
+ }
412
+
413
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/GitLabApi.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Vcs_GitLabApi', false) ):
4
+
5
+ class Puc_v4p7_Vcs_GitLabApi extends Puc_v4p7_Vcs_Api {
6
+ /**
7
+ * @var string GitLab username.
8
+ */
9
+ protected $userName;
10
+
11
+ /**
12
+ * @var string GitLab server host.
13
+ */
14
+ protected $repositoryHost;
15
+
16
+ /**
17
+ * @var string Protocol used by this GitLab server: "http" or "https".
18
+ */
19
+ protected $repositoryProtocol = 'https';
20
+
21
+ /**
22
+ * @var string GitLab repository name.
23
+ */
24
+ protected $repositoryName;
25
+
26
+ /**
27
+ * @var string GitLab authentication token. Optional.
28
+ */
29
+ protected $accessToken;
30
+
31
+ public function __construct($repositoryUrl, $accessToken = null) {
32
+ //Parse the repository host to support custom hosts.
33
+ $port = parse_url($repositoryUrl, PHP_URL_PORT);
34
+ if ( !empty($port) ){
35
+ $port = ':' . $port;
36
+ }
37
+ $this->repositoryHost = parse_url($repositoryUrl, PHP_URL_HOST) . $port;
38
+
39
+ if ( $this->repositoryHost !== 'gitlab.com' ) {
40
+ $this->repositoryProtocol = parse_url($repositoryUrl, PHP_URL_SCHEME);
41
+ }
42
+
43
+ //Find the repository information
44
+ $path = parse_url($repositoryUrl, PHP_URL_PATH);
45
+ if ( preg_match('@^/?(?P<username>[^/]+?)/(?P<repository>[^/#?&]+?)/?$@', $path, $matches) ) {
46
+ $this->userName = $matches['username'];
47
+ $this->repositoryName = $matches['repository'];
48
+ } elseif ( ($this->repositoryHost === 'gitlab.com') ) {
49
+ //This is probably a repository in a subgroup, e.g. "/organization/category/repo".
50
+ $parts = explode('/', trim($path, '/'));
51
+ if ( count($parts) < 3 ) {
52
+ throw new InvalidArgumentException('Invalid GitLab.com repository URL: "' . $repositoryUrl . '"');
53
+ }
54
+ $lastPart = array_pop($parts);
55
+ $this->userName = implode('/', $parts);
56
+ $this->repositoryName = $lastPart;
57
+ } else {
58
+ //This is not a traditional url, it could be gitlab is in a deeper subdirectory.
59
+ //Get the path segments.
60
+ $segments = explode('/', untrailingslashit(ltrim($path, '/')));
61
+
62
+ //We need at least /user-name/repository-name/
63
+ if ( count($segments) < 2 ) {
64
+ throw new InvalidArgumentException('Invalid GitLab repository URL: "' . $repositoryUrl . '"');
65
+ }
66
+
67
+ //Get the username and repository name.
68
+ $usernameRepo = array_splice($segments, -2, 2);
69
+ $this->userName = $usernameRepo[0];
70
+ $this->repositoryName = $usernameRepo[1];
71
+
72
+ //Append the remaining segments to the host.
73
+ $this->repositoryHost = trailingslashit($this->repositoryHost) . implode('/', $segments);
74
+ }
75
+
76
+ parent::__construct($repositoryUrl, $accessToken);
77
+ }
78
+
79
+ /**
80
+ * Get the latest release from GitLab.
81
+ *
82
+ * @return Puc_v4p7_Vcs_Reference|null
83
+ */
84
+ public function getLatestRelease() {
85
+ return $this->getLatestTag();
86
+ }
87
+
88
+ /**
89
+ * Get the tag that looks like the highest version number.
90
+ *
91
+ * @return Puc_v4p7_Vcs_Reference|null
92
+ */
93
+ public function getLatestTag() {
94
+ $tags = $this->api('/:id/repository/tags');
95
+ if ( is_wp_error($tags) || empty($tags) || !is_array($tags) ) {
96
+ return null;
97
+ }
98
+
99
+ $versionTags = $this->sortTagsByVersion($tags);
100
+ if ( empty($versionTags) ) {
101
+ return null;
102
+ }
103
+
104
+ $tag = $versionTags[0];
105
+ return new Puc_v4p7_Vcs_Reference(array(
106
+ 'name' => $tag->name,
107
+ 'version' => ltrim($tag->name, 'v'),
108
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($tag->name),
109
+ 'apiResponse' => $tag
110
+ ));
111
+ }
112
+
113
+ /**
114
+ * Get a branch by name.
115
+ *
116
+ * @param string $branchName
117
+ * @return null|Puc_v4p7_Vcs_Reference
118
+ */
119
+ public function getBranch($branchName) {
120
+ $branch = $this->api('/:id/repository/branches/' . $branchName);
121
+ if ( is_wp_error($branch) || empty($branch) ) {
122
+ return null;
123
+ }
124
+
125
+ $reference = new Puc_v4p7_Vcs_Reference(array(
126
+ 'name' => $branch->name,
127
+ 'downloadUrl' => $this->buildArchiveDownloadUrl($branch->name),
128
+ 'apiResponse' => $branch,
129
+ ));
130
+
131
+ if ( isset($branch->commit, $branch->commit->committed_date) ) {
132
+ $reference->updated = $branch->commit->committed_date;
133
+ }
134
+
135
+ return $reference;
136
+ }
137
+
138
+ /**
139
+ * Get the timestamp of the latest commit that changed the specified branch or tag.
140
+ *
141
+ * @param string $ref Reference name (e.g. branch or tag).
142
+ * @return string|null
143
+ */
144
+ public function getLatestCommitTime($ref) {
145
+ $commits = $this->api('/:id/repository/commits/', array('ref_name' => $ref));
146
+ if ( is_wp_error($commits) || !is_array($commits) || !isset($commits[0]) ) {
147
+ return null;
148
+ }
149
+
150
+ return $commits[0]->committed_date;
151
+ }
152
+
153
+ /**
154
+ * Perform a GitLab API request.
155
+ *
156
+ * @param string $url
157
+ * @param array $queryParams
158
+ * @return mixed|WP_Error
159
+ */
160
+ protected function api($url, $queryParams = array()) {
161
+ $baseUrl = $url;
162
+ $url = $this->buildApiUrl($url, $queryParams);
163
+
164
+ $options = array('timeout' => 10);
165
+ if ( !empty($this->httpFilterName) ) {
166
+ $options = apply_filters($this->httpFilterName, $options);
167
+ }
168
+
169
+ $response = wp_remote_get($url, $options);
170
+ if ( is_wp_error($response) ) {
171
+ do_action('puc_api_error', $response, null, $url, $this->slug);
172
+ return $response;
173
+ }
174
+
175
+ $code = wp_remote_retrieve_response_code($response);
176
+ $body = wp_remote_retrieve_body($response);
177
+ if ( $code === 200 ) {
178
+ return json_decode($body);
179
+ }
180
+
181
+ $error = new WP_Error(
182
+ 'puc-gitlab-http-error',
183
+ sprintf('GitLab API error. URL: "%s", HTTP status code: %d.', $baseUrl, $code)
184
+ );
185
+ do_action('puc_api_error', $error, $response, $url, $this->slug);
186
+
187
+ return $error;
188
+ }
189
+
190
+ /**
191
+ * Build a fully qualified URL for an API request.
192
+ *
193
+ * @param string $url
194
+ * @param array $queryParams
195
+ * @return string
196
+ */
197
+ protected function buildApiUrl($url, $queryParams) {
198
+ $variables = array(
199
+ 'user' => $this->userName,
200
+ 'repo' => $this->repositoryName,
201
+ 'id' => $this->userName . '/' . $this->repositoryName,
202
+ );
203
+
204
+ foreach ($variables as $name => $value) {
205
+ $url = str_replace("/:{$name}", '/' . urlencode($value), $url);
206
+ }
207
+
208
+ $url = substr($url, 1);
209
+ $url = sprintf('%1$s://%2$s/api/v4/projects/%3$s', $this->repositoryProtocol, $this->repositoryHost, $url);
210
+
211
+ if ( !empty($this->accessToken) ) {
212
+ $queryParams['private_token'] = $this->accessToken;
213
+ }
214
+
215
+ if ( !empty($queryParams) ) {
216
+ $url = add_query_arg($queryParams, $url);
217
+ }
218
+
219
+ return $url;
220
+ }
221
+
222
+ /**
223
+ * Get the contents of a file from a specific branch or tag.
224
+ *
225
+ * @param string $path File name.
226
+ * @param string $ref
227
+ * @return null|string Either the contents of the file, or null if the file doesn't exist or there's an error.
228
+ */
229
+ public function getRemoteFile($path, $ref = 'master') {
230
+ $response = $this->api('/:id/repository/files/' . $path, array('ref' => $ref));
231
+ if ( is_wp_error($response) || !isset($response->content) || $response->encoding !== 'base64' ) {
232
+ return null;
233
+ }
234
+
235
+ return base64_decode($response->content);
236
+ }
237
+
238
+ /**
239
+ * Generate a URL to download a ZIP archive of the specified branch/tag/etc.
240
+ *
241
+ * @param string $ref
242
+ * @return string
243
+ */
244
+ public function buildArchiveDownloadUrl($ref = 'master') {
245
+ $url = sprintf(
246
+ '%1$s://%2$s/api/v4/projects/%3$s/repository/archive.zip',
247
+ $this->repositoryProtocol,
248
+ $this->repositoryHost,
249
+ urlencode($this->userName . '/' . $this->repositoryName)
250
+ );
251
+ $url = add_query_arg('sha', urlencode($ref), $url);
252
+
253
+ if ( !empty($this->accessToken) ) {
254
+ $url = add_query_arg('private_token', $this->accessToken, $url);
255
+ }
256
+
257
+ return $url;
258
+ }
259
+
260
+ /**
261
+ * Get a specific tag.
262
+ *
263
+ * @param string $tagName
264
+ * @return void
265
+ */
266
+ public function getTag($tagName) {
267
+ throw new LogicException('The ' . __METHOD__ . ' method is not implemented and should not be used.');
268
+ }
269
+
270
+ /**
271
+ * Figure out which reference (i.e tag or branch) contains the latest version.
272
+ *
273
+ * @param string $configBranch Start looking in this branch.
274
+ * @return null|Puc_v4p7_Vcs_Reference
275
+ */
276
+ public function chooseReference($configBranch) {
277
+ $updateSource = null;
278
+
279
+ // GitLab doesn't handle releases the same as GitHub so just use the latest tag
280
+ if ( $configBranch === 'master' ) {
281
+ $updateSource = $this->getLatestTag();
282
+ }
283
+
284
+ if ( empty($updateSource) ) {
285
+ $updateSource = $this->getBranch($configBranch);
286
+ }
287
+
288
+ return $updateSource;
289
+ }
290
+
291
+ public function setAuthentication($credentials) {
292
+ parent::setAuthentication($credentials);
293
+ $this->accessToken = is_string($credentials) ? $credentials : null;
294
+ }
295
+ }
296
+
297
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/PluginUpdateChecker.php ADDED
@@ -0,0 +1,213 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Vcs_PluginUpdateChecker') ):
3
+
4
+ class Puc_v4p7_Vcs_PluginUpdateChecker extends Puc_v4p7_Plugin_UpdateChecker implements Puc_v4p7_Vcs_BaseChecker {
5
+ /**
6
+ * @var string The branch where to look for updates. Defaults to "master".
7
+ */
8
+ protected $branch = 'master';
9
+
10
+ /**
11
+ * @var Puc_v4p7_Vcs_Api Repository API client.
12
+ */
13
+ protected $api = null;
14
+
15
+ /**
16
+ * Puc_v4p7_Vcs_PluginUpdateChecker constructor.
17
+ *
18
+ * @param Puc_v4p7_Vcs_Api $api
19
+ * @param string $pluginFile
20
+ * @param string $slug
21
+ * @param int $checkPeriod
22
+ * @param string $optionName
23
+ * @param string $muPluginFile
24
+ */
25
+ public function __construct($api, $pluginFile, $slug = '', $checkPeriod = 12, $optionName = '', $muPluginFile = '') {
26
+ $this->api = $api;
27
+ $this->api->setHttpFilterName($this->getUniqueName('request_info_options'));
28
+
29
+ parent::__construct($api->getRepositoryUrl(), $pluginFile, $slug, $checkPeriod, $optionName, $muPluginFile);
30
+
31
+ $this->api->setSlug($this->slug);
32
+ }
33
+
34
+ public function requestInfo($unusedParameter = null) {
35
+ //We have to make several remote API requests to gather all the necessary info
36
+ //which can take a while on slow networks.
37
+ if ( function_exists('set_time_limit') ) {
38
+ @set_time_limit(60);
39
+ }
40
+
41
+ $api = $this->api;
42
+ $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
43
+
44
+ $info = new Puc_v4p7_Plugin_Info();
45
+ $info->filename = $this->pluginFile;
46
+ $info->slug = $this->slug;
47
+
48
+ $this->setInfoFromHeader($this->package->getPluginHeader(), $info);
49
+
50
+ //Pick a branch or tag.
51
+ $updateSource = $api->chooseReference($this->branch);
52
+ if ( $updateSource ) {
53
+ $ref = $updateSource->name;
54
+ $info->version = $updateSource->version;
55
+ $info->last_updated = $updateSource->updated;
56
+ $info->download_url = $updateSource->downloadUrl;
57
+
58
+ if ( !empty($updateSource->changelog) ) {
59
+ $info->sections['changelog'] = $updateSource->changelog;
60
+ }
61
+ if ( isset($updateSource->downloadCount) ) {
62
+ $info->downloaded = $updateSource->downloadCount;
63
+ }
64
+ } else {
65
+ //There's probably a network problem or an authentication error.
66
+ do_action(
67
+ 'puc_api_error',
68
+ new WP_Error(
69
+ 'puc-no-update-source',
70
+ 'Could not retrieve version information from the repository. '
71
+ . 'This usually means that the update checker either can\'t connect '
72
+ . 'to the repository or it\'s configured incorrectly.'
73
+ ),
74
+ null, null, $this->slug
75
+ );
76
+ return null;
77
+ }
78
+
79
+ //Get headers from the main plugin file in this branch/tag. Its "Version" header and other metadata
80
+ //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
81
+ $mainPluginFile = basename($this->pluginFile);
82
+ $remotePlugin = $api->getRemoteFile($mainPluginFile, $ref);
83
+ if ( !empty($remotePlugin) ) {
84
+ $remoteHeader = $this->package->getFileHeader($remotePlugin);
85
+ $this->setInfoFromHeader($remoteHeader, $info);
86
+ }
87
+
88
+ //Try parsing readme.txt. If it's formatted according to WordPress.org standards, it will contain
89
+ //a lot of useful information like the required/tested WP version, changelog, and so on.
90
+ if ( $this->readmeTxtExistsLocally() ) {
91
+ $this->setInfoFromRemoteReadme($ref, $info);
92
+ }
93
+
94
+ //The changelog might be in a separate file.
95
+ if ( empty($info->sections['changelog']) ) {
96
+ $info->sections['changelog'] = $api->getRemoteChangelog($ref, $this->package->getAbsoluteDirectoryPath());
97
+ if ( empty($info->sections['changelog']) ) {
98
+ $info->sections['changelog'] = __('There is no changelog available.', 'plugin-update-checker');
99
+ }
100
+ }
101
+
102
+ if ( empty($info->last_updated) ) {
103
+ //Fetch the latest commit that changed the tag or branch and use it as the "last_updated" date.
104
+ $latestCommitTime = $api->getLatestCommitTime($ref);
105
+ if ( $latestCommitTime !== null ) {
106
+ $info->last_updated = $latestCommitTime;
107
+ }
108
+ }
109
+
110
+ $info = apply_filters($this->getUniqueName('request_info_result'), $info, null);
111
+ return $info;
112
+ }
113
+
114
+ /**
115
+ * Check if the currently installed version has a readme.txt file.
116
+ *
117
+ * @return bool
118
+ */
119
+ protected function readmeTxtExistsLocally() {
120
+ return $this->package->fileExists($this->api->getLocalReadmeName());
121
+ }
122
+
123
+ /**
124
+ * Copy plugin metadata from a file header to a Plugin Info object.
125
+ *
126
+ * @param array $fileHeader
127
+ * @param Puc_v4p7_Plugin_Info $pluginInfo
128
+ */
129
+ protected function setInfoFromHeader($fileHeader, $pluginInfo) {
130
+ $headerToPropertyMap = array(
131
+ 'Version' => 'version',
132
+ 'Name' => 'name',
133
+ 'PluginURI' => 'homepage',
134
+ 'Author' => 'author',
135
+ 'AuthorName' => 'author',
136
+ 'AuthorURI' => 'author_homepage',
137
+
138
+ 'Requires WP' => 'requires',
139
+ 'Tested WP' => 'tested',
140
+ 'Requires at least' => 'requires',
141
+ 'Tested up to' => 'tested',
142
+ );
143
+ foreach ($headerToPropertyMap as $headerName => $property) {
144
+ if ( isset($fileHeader[$headerName]) && !empty($fileHeader[$headerName]) ) {
145
+ $pluginInfo->$property = $fileHeader[$headerName];
146
+ }
147
+ }
148
+
149
+ if ( !empty($fileHeader['Description']) ) {
150
+ $pluginInfo->sections['description'] = $fileHeader['Description'];
151
+ }
152
+ }
153
+
154
+ /**
155
+ * Copy plugin metadata from the remote readme.txt file.
156
+ *
157
+ * @param string $ref GitHub tag or branch where to look for the readme.
158
+ * @param Puc_v4p7_Plugin_Info $pluginInfo
159
+ */
160
+ protected function setInfoFromRemoteReadme($ref, $pluginInfo) {
161
+ $readme = $this->api->getRemoteReadme($ref);
162
+ if ( empty($readme) ) {
163
+ return;
164
+ }
165
+
166
+ if ( isset($readme['sections']) ) {
167
+ $pluginInfo->sections = array_merge($pluginInfo->sections, $readme['sections']);
168
+ }
169
+ if ( !empty($readme['tested_up_to']) ) {
170
+ $pluginInfo->tested = $readme['tested_up_to'];
171
+ }
172
+ if ( !empty($readme['requires_at_least']) ) {
173
+ $pluginInfo->requires = $readme['requires_at_least'];
174
+ }
175
+
176
+ if ( isset($readme['upgrade_notice'], $readme['upgrade_notice'][$pluginInfo->version]) ) {
177
+ $pluginInfo->upgrade_notice = $readme['upgrade_notice'][$pluginInfo->version];
178
+ }
179
+ }
180
+
181
+ public function setBranch($branch) {
182
+ $this->branch = $branch;
183
+ return $this;
184
+ }
185
+
186
+ public function setAuthentication($credentials) {
187
+ $this->api->setAuthentication($credentials);
188
+ return $this;
189
+ }
190
+
191
+ public function getVcsApi() {
192
+ return $this->api;
193
+ }
194
+
195
+ public function getUpdate() {
196
+ $update = parent::getUpdate();
197
+
198
+ if ( isset($update) && !empty($update->download_url) ) {
199
+ $update->download_url = $this->api->signDownloadUrl($update->download_url);
200
+ }
201
+
202
+ return $update;
203
+ }
204
+
205
+ public function onDisplayConfiguration($panel) {
206
+ parent::onDisplayConfiguration($panel);
207
+ $panel->row('Branch', $this->branch);
208
+ $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
209
+ $panel->row('API client', get_class($this->api));
210
+ }
211
+ }
212
+
213
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/Reference.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( !class_exists('Puc_v4p7_Vcs_Reference', false) ):
3
+
4
+ /**
5
+ * This class represents a VCS branch or tag. It's intended as a read only, short-lived container
6
+ * that only exists to provide a limited degree of type checking.
7
+ *
8
+ * @property string $name
9
+ * @property string|null version
10
+ * @property string $downloadUrl
11
+ * @property string $updated
12
+ *
13
+ * @property string|null $changelog
14
+ * @property int|null $downloadCount
15
+ */
16
+ class Puc_v4p7_Vcs_Reference {
17
+ private $properties = array();
18
+
19
+ public function __construct($properties = array()) {
20
+ $this->properties = $properties;
21
+ }
22
+
23
+ /**
24
+ * @param string $name
25
+ * @return mixed|null
26
+ */
27
+ public function __get($name) {
28
+ return array_key_exists($name, $this->properties) ? $this->properties[$name] : null;
29
+ }
30
+
31
+ /**
32
+ * @param string $name
33
+ * @param mixed $value
34
+ */
35
+ public function __set($name, $value) {
36
+ $this->properties[$name] = $value;
37
+ }
38
+
39
+ /**
40
+ * @param string $name
41
+ * @return bool
42
+ */
43
+ public function __isset($name) {
44
+ return isset($this->properties[$name]);
45
+ }
46
+
47
+ }
48
+
49
+ endif;
vendor/yahnis-elsts/plugin-update-checker/Puc/v4p7/Vcs/ThemeUpdateChecker.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ if ( !class_exists('Puc_v4p7_Vcs_ThemeUpdateChecker', false) ):
4
+
5
+ class Puc_v4p7_Vcs_ThemeUpdateChecker extends Puc_v4p7_Theme_UpdateChecker implements Puc_v4p7_Vcs_BaseChecker {
6
+ /**
7
+ * @var string The branch where to look for updates. Defaults to "master".
8
+ */
9
+ protected $branch = 'master';
10
+
11
+ /**
12
+ * @var Puc_v4p7_Vcs_Api Repository API client.
13
+ */
14
+ protected $api = null;
15
+
16
+ /**
17
+ * Puc_v4p7_Vcs_ThemeUpdateChecker constructor.
18
+ *
19
+ * @param Puc_v4p7_Vcs_Api $api
20
+ * @param null $stylesheet
21
+ * @param null $customSlug
22
+ * @param int $checkPeriod
23
+ * @param string $optionName
24
+ */
25
+ public function __construct($api, $stylesheet = null, $customSlug = null, $checkPeriod = 12, $optionName = '') {
26
+ $this->api = $api;
27
+ $this->api->setHttpFilterName($this->getUniqueName('request_update_options'));
28
+
29
+ parent::__construct($api->getRepositoryUrl(), $stylesheet, $customSlug, $checkPeriod, $optionName);
30
+
31
+ $this->api->setSlug($this->slug);
32
+ }
33
+
34
+ public function requestUpdate() {
35
+ $api = $this->api;
36
+ $api->setLocalDirectory($this->package->getAbsoluteDirectoryPath());
37
+
38
+ $update = new Puc_v4p7_Theme_Update();
39
+ $update->slug = $this->slug;
40
+
41
+ //Figure out which reference (tag or branch) we'll use to get the latest version of the theme.
42
+ $updateSource = $api->chooseReference($this->branch);
43
+ if ( $updateSource ) {
44
+ $ref = $updateSource->name;
45
+ $update->download_url = $updateSource->downloadUrl;
46
+ } else {
47
+ do_action(
48
+ 'puc_api_error',
49
+ new WP_Error(
50
+ 'puc-no-update-source',
51
+ 'Could not retrieve version information from the repository. '
52
+ . 'This usually means that the update checker either can\'t connect '
53
+ . 'to the repository or it\'s configured incorrectly.'
54
+ ),
55
+ null, null, $this->slug
56
+ );
57
+ $ref = $this->branch;
58
+ }
59
+
60
+ //Get headers from the main stylesheet in this branch/tag. Its "Version" header and other metadata
61
+ //are what the WordPress install will actually see after upgrading, so they take precedence over releases/tags.
62
+ $remoteHeader = $this->package->getFileHeader($api->getRemoteFile('style.css', $ref));
63
+ $update->version = Puc_v4p7_Utils::findNotEmpty(array(
64
+ $remoteHeader['Version'],
65
+ Puc_v4p7_Utils::get($updateSource, 'version'),
66
+ ));
67
+
68
+ //The details URL defaults to the Theme URI header or the repository URL.
69
+ $update->details_url = Puc_v4p7_Utils::findNotEmpty(array(
70
+ $remoteHeader['ThemeURI'],
71
+ $this->package->getHeaderValue('ThemeURI'),
72
+ $this->metadataUrl,
73
+ ));
74
+
75
+ if ( empty($update->version) ) {
76
+ //It looks like we didn't find a valid update after all.
77
+ $update = null;
78
+ }
79
+
80
+ $update = $this->filterUpdateResult($update);
81
+ return $update;
82
+ }
83
+
84
+ //FIXME: This is duplicated code. Both theme and plugin subclasses that use VCS share these methods.
85
+
86
+ public function setBranch($branch) {
87
+ $this->branch = $branch;
88
+ return $this;
89
+ }
90
+
91
+ public function setAuthentication($credentials) {
92
+ $this->api->setAuthentication($credentials);
93
+ return $this;
94
+ }
95
+
96
+ public function getVcsApi() {
97
+ return $this->api;
98
+ }
99
+
100
+ public function getUpdate() {
101
+ $update = parent::getUpdate();
102
+
103
+ if ( isset($update) && !empty($update->download_url) ) {
104
+ $update->download_url = $this->api->signDownloadUrl($update->download_url);
105
+ }
106
+
107
+ return $update;
108
+ }
109
+
110
+ public function onDisplayConfiguration($panel) {
111
+ parent::onDisplayConfiguration($panel);
112
+ $panel->row('Branch', $this->branch);
113
+ $panel->row('Authentication enabled', $this->api->isAuthenticationEnabled() ? 'Yes' : 'No');
114
+ $panel->row('API client', get_class($this->api));
115
+ }
116
+ }
117
+
118
+ endif;
vendor/yahnis-elsts/plugin-update-checker/README.md CHANGED
@@ -18,6 +18,9 @@ From the users' perspective, it works just like with plugins and themes hosted o
18
  - [Notes](#notes-1)
19
  - [BitBucket Integration](#bitbucket-integration)
20
  - [How to Release an Update](#how-to-release-an-update-2)
 
 
 
21
  - [Resources](#resources)
22
 
23
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
@@ -42,7 +45,7 @@ Getting Started
42
  }
43
  ```
44
 
45
- This is a minimal example that leaves out optional fields. See [this table](https://spreadsheets.google.com/pub?key=0AqP80E74YcUWdEdETXZLcXhjd2w0cHMwX2U1eDlWTHc&authkey=CK7h9toK&hl=en&single=true&gid=0&output=html) for a full list of supported fields and their descriptions.
46
  - Theme example:
47
 
48
  ```json
@@ -61,16 +64,17 @@ Getting Started
61
  require 'path/to/plugin-update-checker/plugin-update-checker.php';
62
  $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
63
  'http://example.com/path/to/details.json',
64
- __FILE__,
65
  'unique-plugin-or-theme-slug'
66
  );
67
  ```
 
68
 
69
  #### How to Release an Update
70
 
71
  Change the `version` number in the JSON file and make sure that `download_url` points to the latest version. Update the other fields if necessary. Tip: You can use [wp-update-server](https://github.com/YahnisElsts/wp-update-server) to automate this process.
72
 
73
- By default, the library will check the specified URL for changes every 12 hours. You can force it to check immediately by clicking the "Check Now" link on the "Plugins" page (it's next to the "Visit plugin site" link). Themes don't get a "check now" link, but you can also trigger an update check like this:
74
 
75
  1. Install [Debug Bar](https://srd.wordpress.org/plugins/debug-bar/).
76
  2. Click the "Debug" menu in the Admin Bar (a.k.a Toolbar).
@@ -79,7 +83,7 @@ By default, the library will check the specified URL for changes every 12 hours.
79
 
80
  #### Notes
81
  - The second argument passed to `buildUpdateChecker` must be the absolute path to the main plugin file or any file in the theme directory. If you followed the "getting started" instructions, you can just use the `__FILE__` constant.
82
- - The third argument - i.e. the slug - is optional but recommended. If it's omitted, the update checker will use the name of the main plugin file as the slug (e.g. `my-cool-plugin.php` &rarr; `my-cool-plugin`). This can lead to conflicts if your plugin has a generic file name like `plugin.php`.
83
 
84
  This doesn't affect themes because PUC uses the theme directory name as the default slug. Still, if you're planning to use the slug in your own code - e.g. to filter updates or override update checker behaviour - it can be a good idea to set it explicitly.
85
 
@@ -112,6 +116,11 @@ This library supports a couple of different ways to release updates on GitHub. P
112
 
113
  Create a new release using the "Releases" feature on GitHub. The tag name and release title don't matter. The description is optional, but if you do provide one, it will be displayed when the user clicks the "View version x.y.z details" link on the "Plugins" page. Note that PUC ignores releases marked as "This is a pre-release".
114
 
 
 
 
 
 
115
  - **Tags**
116
 
117
  To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
@@ -172,6 +181,9 @@ The library will pull update details from the following parts of a release/tag/b
172
 
173
  //Optional: If you're using a private repository, create an OAuth consumer
174
  //and set the authentication credentials like this:
 
 
 
175
  $myUpdateChecker->setAuthentication(array(
176
  'consumer_key' => '...',
177
  'consumer_secret' => '...',
@@ -210,6 +222,63 @@ BitBucket doesn't have an equivalent to GitHub's releases, so the process is sli
210
  ```
211
  PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: If you set the branch to `master`, the update checker will still look for tags first.
212
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  Resources
214
  ---------
215
 
18
  - [Notes](#notes-1)
19
  - [BitBucket Integration](#bitbucket-integration)
20
  - [How to Release an Update](#how-to-release-an-update-2)
21
+ - [GitLab Integration](#gitlab-integration)
22
+ - [How to Release an Update](#how-to-release-an-update-3)
23
+ - [License Management](#license-management)
24
  - [Resources](#resources)
25
 
26
  <!-- END doctoc generated TOC please keep comment here to allow auto update -->
45
  }
46
  ```
47
 
48
+ This is a minimal example that leaves out optional fields. See [this table](https://docs.google.com/spreadsheets/d/1eOBbW7Go2qEQXReOOCdidMTf_tDYRq4JfegcO1CBPIs/edit?usp=sharing&authkey=CK7h9toK&output=html) for a full list of supported fields and their descriptions.
49
  - Theme example:
50
 
51
  ```json
64
  require 'path/to/plugin-update-checker/plugin-update-checker.php';
65
  $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
66
  'http://example.com/path/to/details.json',
67
+ __FILE__, //Full path to the main plugin file or functions.php.
68
  'unique-plugin-or-theme-slug'
69
  );
70
  ```
71
+ Note: If you're using the Composer autoloader, you don't need to explicitly `require` the library.
72
 
73
  #### How to Release an Update
74
 
75
  Change the `version` number in the JSON file and make sure that `download_url` points to the latest version. Update the other fields if necessary. Tip: You can use [wp-update-server](https://github.com/YahnisElsts/wp-update-server) to automate this process.
76
 
77
+ By default, the library will check the specified URL for changes every 12 hours. You can force it to check immediately by clicking the "Check for updates" link on the "Plugins" page (it's next to the "Visit plugin site" link). Themes don't have that link, but you can also trigger an update check like this:
78
 
79
  1. Install [Debug Bar](https://srd.wordpress.org/plugins/debug-bar/).
80
  2. Click the "Debug" menu in the Admin Bar (a.k.a Toolbar).
83
 
84
  #### Notes
85
  - The second argument passed to `buildUpdateChecker` must be the absolute path to the main plugin file or any file in the theme directory. If you followed the "getting started" instructions, you can just use the `__FILE__` constant.
86
+ - The third argument - i.e. the slug - is optional but recommended. In most cases, the slug should be the same as the name of your plugin directory. For example, if your plugin lives in `/wp-content/plugins/my-plugin`, set the slug to `my-plugin`. If the slug is omitted, the update checker will use the name of the main plugin file as the slug (e.g. `my-cool-plugin.php` &rarr; `my-cool-plugin`). This can lead to conflicts if your plugin has a generic file name like `plugin.php`.
87
 
88
  This doesn't affect themes because PUC uses the theme directory name as the default slug. Still, if you're planning to use the slug in your own code - e.g. to filter updates or override update checker behaviour - it can be a good idea to set it explicitly.
89
 
116
 
117
  Create a new release using the "Releases" feature on GitHub. The tag name and release title don't matter. The description is optional, but if you do provide one, it will be displayed when the user clicks the "View version x.y.z details" link on the "Plugins" page. Note that PUC ignores releases marked as "This is a pre-release".
118
 
119
+ If you want to use release assets, call the `enableReleaseAssets()` method after creating the update checker instance:
120
+ ```php
121
+ $myUpdateChecker->getVcsApi()->enableReleaseAssets();
122
+ ```
123
+
124
  - **Tags**
125
 
126
  To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
181
 
182
  //Optional: If you're using a private repository, create an OAuth consumer
183
  //and set the authentication credentials like this:
184
+ //Note: For now you need to check "This is a private consumer" when
185
+ //creating the consumer to work around #134:
186
+ // https://github.com/YahnisElsts/plugin-update-checker/issues/134
187
  $myUpdateChecker->setAuthentication(array(
188
  'consumer_key' => '...',
189
  'consumer_secret' => '...',
222
  ```
223
  PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version. Caveat: If you set the branch to `master`, the update checker will still look for tags first.
224
 
225
+ ### GitLab Integration
226
+
227
+ 1. Download [the latest release](https://github.com/YahnisElsts/plugin-update-checker/releases/latest) and copy the `plugin-update-checker` directory to your plugin or theme.
228
+ 2. Add the following code to the main plugin file or `functions.php`:
229
+
230
+ ```php
231
+ require 'plugin-update-checker/plugin-update-checker.php';
232
+ $myUpdateChecker = Puc_v4_Factory::buildUpdateChecker(
233
+ 'https://gitlab.com/user-name/repo-name/',
234
+ __FILE__,
235
+ 'unique-plugin-or-theme-slug'
236
+ );
237
+
238
+ //Optional: If you're using a private repository, specify the access token like this:
239
+ $myUpdateChecker->setAuthentication('your-token-here');
240
+
241
+ //Optional: Set the branch that contains the stable release.
242
+ $myUpdateChecker->setBranch('stable-branch-name');
243
+ ```
244
+
245
+ Alternatively, if you're using a self-hosted GitLab instance, initialize the update checker like this:
246
+ ```php
247
+ $myUpdateChecker = new Puc_v4p7_Vcs_PluginUpdateChecker(
248
+ new Puc_v4p7_Vcs_GitLabApi('https://myserver.com/user-name/repo-name/'),
249
+ __FILE__,
250
+ 'unique-plugin-or-theme-slug'
251
+ );
252
+ //Optional: Add setAuthentication(...) and setBranch(...) as shown above.
253
+ ```
254
+
255
+ 3. Plugins only: Add a `readme.txt` file formatted according to the [WordPress.org plugin readme standard](https://wordpress.org/plugins/about/readme.txt) to your repository. The contents of this file will be shown when the user clicks the "View version 1.2.3 details" link.
256
+
257
+ #### How to Release an Update
258
+
259
+ GitLab doesn't have an equivalent to GitHub's releases, so the process is slightly different. You can use any of the following approaches:
260
+
261
+ - **Tags**
262
+
263
+ To release version 1.2.3, create a new Git tag named `v1.2.3` or `1.2.3`. That's it.
264
+
265
+ PUC doesn't require strict adherence to [SemVer](http://semver.org/). These are all valid tag names: `v1.2.3`, `v1.2-foo`, `1.2.3_rc1-ABC`, `1.2.3.4.5`. However, be warned that it's not smart enough to filter out alpha/beta/RC versions. If that's a problem, you might want to use GitLab branches instead.
266
+
267
+ - **Stable branch**
268
+
269
+ Point the update checker at a stable, production-ready branch:
270
+ ```php
271
+ $updateChecker->setBranch('branch-name');
272
+ ```
273
+ PUC will periodically check the `Version` header in the main plugin file or `style.css` and display a notification if it's greater than the installed version.
274
+
275
+ Caveat: If you set the branch to `master` (the default), the update checker will look for recent releases and tags first. It'll only use the `master` branch if it doesn't find anything else suitable.
276
+
277
+ License Management
278
+ ------------------
279
+
280
+ Currently, the update checker doesn't have any built-in license management features. It only provides some hooks that you can use to, for example, append license keys to update requests (`$updateChecker->addQueryArgFilter()`). If you're looking for ways to manage and verify licenses, please post your feedback in [this issue](https://github.com/YahnisElsts/plugin-update-checker/issues/222).
281
+
282
  Resources
283
  ---------
284
 
vendor/yahnis-elsts/plugin-update-checker/composer.json CHANGED
@@ -1,19 +1,22 @@
1
- {
2
- "name": "yahnis-elsts/plugin-update-checker",
3
- "type": "library",
4
- "description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
5
- "keywords": ["wordpress", "plugin updates", "automatic updates", "theme updates"],
6
- "homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
7
- "license": "MIT",
8
- "authors": [
9
- {
10
- "name": "Yahnis Elsts",
11
- "email": "whiteshadow@w-shadow.com",
12
- "homepage": "http://w-shadow.com/",
13
- "role": "Developer"
14
- }
15
- ],
16
- "require": {
17
- "php": ">=5.2.0"
18
- }
19
- }
 
 
 
1
+ {
2
+ "name": "yahnis-elsts/plugin-update-checker",
3
+ "type": "library",
4
+ "description": "A custom update checker for WordPress plugins and themes. Useful if you can't host your plugin in the official WP repository but still want it to support automatic updates.",
5
+ "keywords": ["wordpress", "plugin updates", "automatic updates", "theme updates"],
6
+ "homepage": "https://github.com/YahnisElsts/plugin-update-checker/",
7
+ "license": "MIT",
8
+ "authors": [
9
+ {
10
+ "name": "Yahnis Elsts",
11
+ "email": "whiteshadow@w-shadow.com",
12
+ "homepage": "http://w-shadow.com/",
13
+ "role": "Developer"
14
+ }
15
+ ],
16
+ "require": {
17
+ "php": ">=5.2.0"
18
+ },
19
+ "autoload": {
20
+ "files": ["plugin-update-checker.php"]
21
+ }
22
+ }
vendor/yahnis-elsts/plugin-update-checker/css/puc-debug-bar.css CHANGED
@@ -59,4 +59,12 @@ table.puc-debug-data td {
59
 
60
  .puc-ajax-nonce {
61
  display: none;
62
- }
 
 
 
 
 
 
 
 
59
 
60
  .puc-ajax-nonce {
61
  display: none;
62
+ }
63
+
64
+ .puc-ajax-response dt {
65
+ margin: 0;
66
+ }
67
+
68
+ .puc-ajax-response dd {
69
+ margin: 0 0 1em;
70
+ }
vendor/yahnis-elsts/plugin-update-checker/examples/plugin.json CHANGED
@@ -18,6 +18,11 @@
18
  "changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
19
  "custom_section": "This is a custom section labeled 'Custom Section'."
20
  },
 
 
 
 
 
21
 
22
  "banners": {
23
  "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
18
  "changelog": "(Recommended) Changelog. <p>This section will be displayed by default when the user clicks 'View version x.y.z details'.</p>",
19
  "custom_section": "This is a custom section labeled 'Custom Section'."
20
  },
21
+
22
+ "icons" : {
23
+ "1x" : "http://w-shadow.com/files/external-update-example/assets/icon-128x128.png",
24
+ "2x" : "http://w-shadow.com/files/external-update-example/assets/icon-256x256.png"
25
+ },
26
 
27
  "banners": {
28
  "low": "http://w-shadow.com/files/external-update-example/assets/banner-772x250.png",
vendor/yahnis-elsts/plugin-update-checker/js/debug-bar.js CHANGED
@@ -44,7 +44,7 @@ jQuery(function($) {
44
  target.attr('id', 'debug-menu-target-puc-' + uid);
45
 
46
  //Change the menu link ID as well and point it at the new target ID.
47
- $('#puc-debug-menu-link-' + uid)
48
  .closest('.debug-menu-link')
49
  .attr('id', 'debug-menu-link-puc-' + uid)
50
  .attr('href', '#' + target.attr('id'));
44
  target.attr('id', 'debug-menu-target-puc-' + uid);
45
 
46
  //Change the menu link ID as well and point it at the new target ID.
47
+ $('#debug-bar-menu').find('.puc-debug-menu-link-' + uid)
48
  .closest('.debug-menu-link')
49
  .attr('id', 'debug-menu-link-puc-' + uid)
50
  .attr('href', '#' + target.attr('id'));
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-cs_CZ.po ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
6
+ "PO-Revision-Date: 2017-07-05 15:39+0000\n"
7
+ "Last-Translator: Vojtěch Sajdl <vojtech@sajdl.com>\n"
8
+ "Language-Team: Czech (Czech Republic)\n"
9
+ "Language: cs-CZ\n"
10
+ "Plural-Forms: nplurals=2; plural=(n != 1)\n"
11
+ "MIME-Version: 1.0\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "X-Loco-Source-Locale: cs_CZ\n"
15
+ "X-Generator: Loco - https://localise.biz/\n"
16
+ "X-Poedit-Basepath: ..\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+ "X-Loco-Parser: loco_parse_po"
21
+
22
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
23
+ msgid "Check for updates"
24
+ msgstr "Zkontrolovat aktualizace"
25
+
26
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
27
+ #, php-format
28
+ msgctxt "the plugin title"
29
+ msgid "The %s plugin is up to date."
30
+ msgstr "Plugin %s je aktuální."
31
+
32
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
33
+ #, php-format
34
+ msgctxt "the plugin title"
35
+ msgid "A new version of the %s plugin is available."
36
+ msgstr "Nová verze pluginu %s je dostupná."
37
+
38
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
39
+ #, php-format
40
+ msgid "Unknown update checker status \"%s\""
41
+ msgstr "Neznámý status kontroly aktualizací \"%s\""
42
+
43
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
44
+ msgid "There is no changelog available."
45
+ msgstr "Changelog není dostupný."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-da_DK.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
5
+ "PO-Revision-Date: 2017-10-17 11:07+0200\n"
6
+ "Last-Translator: Mikk3lRo\n"
7
+ "Language-Team: Mikk3lRo\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 2.0.4\n"
12
+ "X-Poedit-Basepath: ..\n"
13
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
14
+ "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
16
+ "Language: da_DK\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Undersøg for opdateringer"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Plugin'et %s er allerede opdateret."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "En ny version af plugin'et %s er tilgængelig."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Ukendt opdateringsstatus: \"%s\""
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Der er ingen ændringslog tilgængelig."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_CA.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2018-02-12 10:32-0500\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.0.4\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Eric Gagnon <eric.gagnon@banq.qc.ca>\n"
16
+ "Language: fr_CA\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Vérifier les mises à jour"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "L’extension %s est à jour."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Une nouvelle version de l’extension %s est disponible."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Impossible de déterminer si une mise à jour est disponible pour \"%s\""
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Un problème inconnu est survenu \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Il n’y a aucun journal de mise à jour disponible."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.mo CHANGED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-fr_FR.po CHANGED
@@ -1,38 +1,42 @@
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: plugin-update-checker\n"
4
- "POT-Creation-Date: 2016-02-17 14:21+0100\n"
5
- "PO-Revision-Date: 2016-08-04 21:08+0200\n"
6
- "Last-Translator: studio RVOLA <hello@rvola.com>\n"
7
  "Language-Team: studio RVOLA <http://www.rvola.com>\n"
8
  "Language: fr_FR\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.8.8\n"
13
  "X-Poedit-Basepath: ..\n"
14
  "Plural-Forms: nplurals=2; plural=(n > 1);\n"
15
  "X-Poedit-SourceCharset: UTF-8\n"
16
- "X-Poedit-KeywordsList: __;_e\n"
 
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
- #: github-checker.php:120
20
- msgid "There is no changelog available."
21
- msgstr "Il n’y a aucun journal de mise à jour disponible."
22
-
23
- #: plugin-update-checker.php:637
24
  msgid "Check for updates"
25
  msgstr "Vérifier les mises à jour"
26
 
27
- #: plugin-update-checker.php:681
28
- msgid "This plugin is up to date."
29
- msgstr "Cette extension est à jour."
 
 
30
 
31
- #: plugin-update-checker.php:683
32
- msgid "A new version of this plugin is available."
33
- msgstr "Une nouvelle version de cette extension est disponible."
 
 
34
 
35
- #: plugin-update-checker.php:685
36
  #, php-format
37
  msgid "Unknown update checker status \"%s\""
38
  msgstr "Un problème inconnu est survenu \"%s\""
 
 
 
 
1
  msgid ""
2
  msgstr ""
3
  "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-07-07 14:53+0200\n"
5
+ "PO-Revision-Date: 2017-07-07 14:54+0200\n"
 
6
  "Language-Team: studio RVOLA <http://www.rvola.com>\n"
7
  "Language: fr_FR\n"
8
  "MIME-Version: 1.0\n"
9
  "Content-Type: text/plain; charset=UTF-8\n"
10
  "Content-Transfer-Encoding: 8bit\n"
11
+ "X-Generator: Poedit 2.0.2\n"
12
  "X-Poedit-Basepath: ..\n"
13
  "Plural-Forms: nplurals=2; plural=(n > 1);\n"
14
  "X-Poedit-SourceCharset: UTF-8\n"
15
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
16
+ "Last-Translator: Nicolas GEHIN\n"
17
  "X-Poedit-SearchPath-0: .\n"
18
 
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
 
 
 
 
20
  msgid "Check for updates"
21
  msgstr "Vérifier les mises à jour"
22
 
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "L’extension %s est à jour."
28
 
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Une nouvelle version de l’extension %s est disponible."
34
 
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
  #, php-format
37
  msgid "Unknown update checker status \"%s\""
38
  msgstr "Un problème inconnu est survenu \"%s\""
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:85
41
+ msgid "There is no changelog available."
42
+ msgstr "Il n’y a aucun journal de mise à jour disponible."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-ja.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-06-02 18:31+0900\n"
5
+ "PO-Revision-Date: 2017-06-02 18:32+0900\n"
6
+ "Last-Translator: tak <tak7725@gmail.com>\n"
7
+ "Language-Team: \n"
8
+ "Language: ja_JP\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.2\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=1; plural=0;\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;_x;_x:1,2c\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:362
20
+ msgid "Check for updates"
21
+ msgstr "アップデートを確認"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "%s プラグインは、最新バージョンです。"
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:411
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "%s プラグインの最新バージョンがあります。"
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:413
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "バージョンアップの確認で想定外の状態になりました。ステータス:\"%s\""
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "更新履歴はありません。"
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_BE.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2018-03-25 18:15+0200\n"
5
+ "PO-Revision-Date: 2018-03-25 18:32+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.7.1\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Frank Goossens <frank@optimizingmatters.com>\n"
16
+ "Language: nl_BE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Controleer op nieuwe versies"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "De meest recente %s versie is geïnstalleerd."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Er is een nieuwe versie van %s beschikbaar."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Ongekende status bij controle op nieuwe versie: \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Er is geen changelog beschikbaar."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-nl_NL.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2018-03-25 18:15+0200\n"
5
+ "PO-Revision-Date: 2018-03-25 18:32+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 1.8.7.1\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Frank Goossens <frank@optimizingmatters.com>\n"
16
+ "Language: nl_NL\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Controleer op nieuwe versies"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "De meest recente %s versie is geïnstalleerd."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Er is een nieuwe versie van %s beschikbaar."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Kon niet bepalen of er nieuwe versie van %s beschikbaar is."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Ongekende status bij controle op nieuwe versie: \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Er is geen changelog beschikbaar."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-pt_BR.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-19 15:41-0300\n"
5
+ "PO-Revision-Date: 2017-05-19 15:42-0300\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: \n"
8
+ "Language: pt_BR\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.8.8\n"
13
+ "X-Poedit-Basepath: ..\n"
14
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
15
+ "X-Poedit-SourceCharset: UTF-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;_x;_x:1,2c\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Verificar Atualizações"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:401 Puc/v4p1/Plugin/UpdateChecker.php:406
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "O plugin %s já está na sua versão mais recente."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:408
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Há uma nova versão para o plugin %s disponível para download."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:410
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Status \"%s\" desconhecido."
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Não há um changelog disponível."
43
+
44
+ #~ msgid "The %s plugin is up to date."
45
+ #~ msgstr "O plugin %s já está na sua versão mais recente."
46
+
47
+ #~ msgid "A new version of the %s plugin is available."
48
+ #~ msgstr "Há uma nova versão para o plugin %s disponível para download."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sl_SI.po ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
5
+ "PO-Revision-Date: 2018-10-27 20:36+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.2\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=4; plural=(n%100==1 ? 0 : n%100==2 ? 1 : n%100>=3 && n%100<=4 ? 2 : 3);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: Igor Funa\n"
16
+ "Language: sl_SI\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
20
+ msgid "Check for updates"
21
+ msgstr "Preveri posodobitve"
22
+
23
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Vtičnik %s je že posodobljen."
28
+
29
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Nova različica vtičnika %s je na razpolago."
34
+
35
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
36
+ #, php-format
37
+ msgctxt "the plugin title"
38
+ msgid "Could not determine if updates are available for %s."
39
+ msgstr "Ne morem ugotoviti če se za vtičnik %s na razpolago posodobitve."
40
+
41
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
42
+ #, php-format
43
+ msgid "Unknown update checker status \"%s\""
44
+ msgstr "Neznan status preverjanja posodobitev za \"%s\""
45
+
46
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
47
+ msgid "There is no changelog available."
48
+ msgstr "Dnevnik sprememb ni na razpolago."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.mo ADDED
Binary file
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker-sv_SE.po ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: plugin-update-checker\n"
4
+ "POT-Creation-Date: 2017-05-20 10:53+0300\n"
5
+ "PO-Revision-Date: 2017-10-16 15:02+0200\n"
6
+ "Language-Team: \n"
7
+ "MIME-Version: 1.0\n"
8
+ "Content-Type: text/plain; charset=UTF-8\n"
9
+ "Content-Transfer-Encoding: 8bit\n"
10
+ "X-Generator: Poedit 2.0.4\n"
11
+ "X-Poedit-Basepath: ..\n"
12
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
13
+ "X-Poedit-SourceCharset: UTF-8\n"
14
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
15
+ "Last-Translator: \n"
16
+ "Language: sv_SE\n"
17
+ "X-Poedit-SearchPath-0: .\n"
18
+
19
+ #: Puc/v4p1/Plugin/UpdateChecker.php:358
20
+ msgid "Check for updates"
21
+ msgstr "Sök efter uppdateringar"
22
+
23
+ #: Puc/v4p1/Plugin/UpdateChecker.php:405
24
+ #, php-format
25
+ msgctxt "the plugin title"
26
+ msgid "The %s plugin is up to date."
27
+ msgstr "Tillägget %s är uppdaterat."
28
+
29
+ #: Puc/v4p1/Plugin/UpdateChecker.php:407
30
+ #, php-format
31
+ msgctxt "the plugin title"
32
+ msgid "A new version of the %s plugin is available."
33
+ msgstr "Det finns en ny version av tillägget %s."
34
+
35
+ #: Puc/v4p1/Plugin/UpdateChecker.php:409
36
+ #, php-format
37
+ msgid "Unknown update checker status \"%s\""
38
+ msgstr "Okänd status för kontroll av uppdatering “%s”"
39
+
40
+ #: Puc/v4p1/Vcs/PluginUpdateChecker.php:83
41
+ msgid "There is no changelog available."
42
+ msgstr "Det finns ingen ändringslogg tillgänglig."
vendor/yahnis-elsts/plugin-update-checker/languages/plugin-update-checker.pot CHANGED
@@ -2,7 +2,7 @@
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: plugin-update-checker\n"
5
- "POT-Creation-Date: 2016-01-11 21:22+0100\n"
6
  "PO-Revision-Date: 2016-01-10 20:59+0100\n"
7
  "Last-Translator: Tamás András Horváth <htomy92@gmail.com>\n"
8
  "Language-Team: \n"
@@ -10,30 +10,40 @@ msgstr ""
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.8.6\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
- "X-Poedit-KeywordsList: __;_e\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
 
20
- #: github-checker.php:137
21
- msgid "There is no changelog available."
22
  msgstr ""
23
 
24
- #: plugin-update-checker.php:852
25
- msgid "Check for updates"
 
 
26
  msgstr ""
27
 
28
- #: plugin-update-checker.php:896
29
- msgid "This plugin is up to date."
 
 
30
  msgstr ""
31
 
32
- #: plugin-update-checker.php:898
33
- msgid "A new version of this plugin is available."
 
 
34
  msgstr ""
35
 
36
- #: plugin-update-checker.php:900
37
  #, php-format
38
  msgid "Unknown update checker status \"%s\""
39
  msgstr ""
 
 
 
 
2
  msgid ""
3
  msgstr ""
4
  "Project-Id-Version: plugin-update-checker\n"
5
+ "POT-Creation-Date: 2017-11-24 17:02+0200\n"
6
  "PO-Revision-Date: 2016-01-10 20:59+0100\n"
7
  "Last-Translator: Tamás András Horváth <htomy92@gmail.com>\n"
8
  "Language-Team: \n"
10
  "MIME-Version: 1.0\n"
11
  "Content-Type: text/plain; charset=UTF-8\n"
12
  "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 2.0.4\n"
14
  "X-Poedit-Basepath: ..\n"
15
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
16
  "X-Poedit-SourceCharset: UTF-8\n"
17
+ "X-Poedit-KeywordsList: __;_e;_x:1,2c;_x\n"
18
  "X-Poedit-SearchPath-0: .\n"
19
 
20
+ #: Puc/v4p3/Plugin/UpdateChecker.php:395
21
+ msgid "Check for updates"
22
  msgstr ""
23
 
24
+ #: Puc/v4p3/Plugin/UpdateChecker.php:548
25
+ #, php-format
26
+ msgctxt "the plugin title"
27
+ msgid "The %s plugin is up to date."
28
  msgstr ""
29
 
30
+ #: Puc/v4p3/Plugin/UpdateChecker.php:550
31
+ #, php-format
32
+ msgctxt "the plugin title"
33
+ msgid "A new version of the %s plugin is available."
34
  msgstr ""
35
 
36
+ #: Puc/v4p3/Plugin/UpdateChecker.php:552
37
+ #, php-format
38
+ msgctxt "the plugin title"
39
+ msgid "Could not determine if updates are available for %s."
40
  msgstr ""
41
 
42
+ #: Puc/v4p3/Plugin/UpdateChecker.php:558
43
  #, php-format
44
  msgid "Unknown update checker status \"%s\""
45
  msgstr ""
46
+
47
+ #: Puc/v4p3/Vcs/PluginUpdateChecker.php:95
48
+ msgid "There is no changelog available."
49
+ msgstr ""
vendor/yahnis-elsts/plugin-update-checker/license.txt CHANGED
@@ -1,7 +1,7 @@
1
- Copyright (c) 2014 Jānis Elsts
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
 
5
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
 
7
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2017 Jānis Elsts
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
 
5
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
 
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
vendor/yahnis-elsts/plugin-update-checker/plugin-update-checker.php CHANGED
@@ -1,21 +1,34 @@
1
  <?php
2
  /**
3
- * Plugin Update Checker Library 4.0.2
4
  * http://w-shadow.com/
5
- *
6
- * Copyright 2017 Janis Elsts
7
  * Released under the MIT license. See license.txt for details.
8
  */
9
 
10
- require dirname(__FILE__) . '/Puc/v4/Autoloader.php';
11
- new Puc_v4_Autoloader();
 
 
12
 
13
- //Register classes defined in this file with the factory.
14
- Puc_v4_Factory::addVersion('Plugin_UpdateChecker', 'Puc_v4_Plugin_UpdateChecker', '4.0');
15
- Puc_v4_Factory::addVersion('Theme_UpdateChecker', 'Puc_v4_Theme_UpdateChecker', '4.0');
 
 
16
 
17
- Puc_v4_Factory::addVersion('Vcs_PluginUpdateChecker', 'Puc_v4_Vcs_PluginUpdateChecker', '4.0');
18
- Puc_v4_Factory::addVersion('Vcs_ThemeUpdateChecker', 'Puc_v4_Vcs_ThemeUpdateChecker', '4.0');
19
 
20
- Puc_v4_Factory::addVersion('GitHubApi', 'Puc_v4_Vcs_GitHubApi', '4.0');
21
- Puc_v4_Factory::addVersion('BitBucketApi', 'Puc_v4_Vcs_BitBucketApi', '4.0');
 
 
 
 
 
 
 
 
 
1
  <?php
2
  /**
3
+ * Plugin Update Checker Library 4.7
4
  * http://w-shadow.com/
5
+ *
6
+ * Copyright 2019 Janis Elsts
7
  * Released under the MIT license. See license.txt for details.
8
  */
9
 
10
+ require dirname(__FILE__) . '/Puc/v4p7/Factory.php';
11
+ require dirname(__FILE__) . '/Puc/v4/Factory.php';
12
+ require dirname(__FILE__) . '/Puc/v4p7/Autoloader.php';
13
+ new Puc_v4p7_Autoloader();
14
 
15
+ //Register classes defined in this version with the factory.
16
+ foreach (
17
+ array(
18
+ 'Plugin_UpdateChecker' => 'Puc_v4p7_Plugin_UpdateChecker',
19
+ 'Theme_UpdateChecker' => 'Puc_v4p7_Theme_UpdateChecker',
20
 
21
+ 'Vcs_PluginUpdateChecker' => 'Puc_v4p7_Vcs_PluginUpdateChecker',
22
+ 'Vcs_ThemeUpdateChecker' => 'Puc_v4p7_Vcs_ThemeUpdateChecker',
23
 
24
+ 'GitHubApi' => 'Puc_v4p7_Vcs_GitHubApi',
25
+ 'BitBucketApi' => 'Puc_v4p7_Vcs_BitBucketApi',
26
+ 'GitLabApi' => 'Puc_v4p7_Vcs_GitLabApi',
27
+ )
28
+ as $pucGeneralClass => $pucVersionedClass
29
+ ) {
30
+ Puc_v4_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.7');
31
+ //Also add it to the minor-version factory in case the major-version factory
32
+ //was already defined by another, older version of the update checker.
33
+ Puc_v4p7_Factory::addVersion($pucGeneralClass, $pucVersionedClass, '4.7');
34
+ }
vendor/yahnis-elsts/plugin-update-checker/vendor/ParsedownLegacy.php CHANGED
@@ -1409,8 +1409,7 @@ class Parsedown
1409
 
1410
  if (isset($Element['handler']))
1411
  {
1412
- $handler = $Element['handler'];
1413
- $markup .= $this->$handler($Element['text']);
1414
  }
1415
  else
1416
  {
1409
 
1410
  if (isset($Element['handler']))
1411
  {
1412
+ $markup .= $this->{$Element['handler']}($Element['text']);
 
1413
  }
1414
  else
1415
  {
vendor/yahnis-elsts/plugin-update-checker/vendor/readme-parser.php CHANGED
@@ -121,11 +121,15 @@ class PucReadmeParser {
121
  $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
122
 
123
  $sections = array();
124
- for ( $i=1; $i <= count($_sections); $i +=2 ) {
125
- $_sections[$i] = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i]);
126
- $_sections[$i] = $this->filter_text( $_sections[$i], true );
127
- $title = $this->sanitize_text( $_sections[$i-1] );
128
- $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]);
 
 
 
 
129
  }
130
 
131
 
@@ -157,8 +161,11 @@ class PucReadmeParser {
157
  $upgrade_notice = array();
158
  if ( isset($final_sections['upgrade_notice']) ) {
159
  $split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
160
- for ( $i = 0; $i < count( $split ); $i += 2 )
161
- $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
 
 
 
162
  unset( $final_sections['upgrade_notice'] );
163
  }
164
 
@@ -331,4 +338,4 @@ class PucReadmeParser {
331
 
332
  } // end class
333
 
334
- endif;
121
  $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);
122
 
123
  $sections = array();
124
+ for ( $i=0; $i < count($_sections); $i +=2 ) {
125
+ $title = $this->sanitize_text( $_sections[$i] );
126
+ if ( isset($_sections[$i+1]) ) {
127
+ $content = preg_replace('/(^[\s]*)=[\s]+(.+?)[\s]+=/m', '$1<h4>$2</h4>', $_sections[$i+1]);
128
+ $content = $this->filter_text( $content, true );
129
+ } else {
130
+ $content = '';
131
+ }
132
+ $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $content);
133
  }
134
 
135
 
161
  $upgrade_notice = array();
162
  if ( isset($final_sections['upgrade_notice']) ) {
163
  $split = preg_split( '#<h4>(.*?)</h4>#', $final_sections['upgrade_notice'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY );
164
+ if ( count($split) >= 2 ) {
165
+ for ( $i = 0; $i < count( $split ); $i += 2 ) {
166
+ $upgrade_notice[$this->sanitize_text( $split[$i] )] = substr( $this->sanitize_text( $split[$i + 1] ), 0, 300 );
167
+ }
168
+ }
169
  unset( $final_sections['upgrade_notice'] );
170
  }
171
 
338
 
339
  } // end class
340
 
341
+ endif;
view/settings_price_rules.php CHANGED
@@ -125,7 +125,13 @@ if (!defined('ABSPATH')) exit; // Exit if accessed directly
125
  <div class="col-md-6">
126
  <select class="selectpicker" name="show_price_discount_on_product_page" id="show_price_discount_on_product_page">
127
  <option <?php if ($data['show_price_discount_on_product_page'] == 'show') { ?> selected=selected <?php } ?>
128
- value="show"><?php esc_html_e('Show', 'woo-discount-rules'); ?>
 
 
 
 
 
 
129
  </option>
130
  <option <?php if ($data['show_price_discount_on_product_page'] == 'dont') { ?> selected=selected <?php } ?>
131
  value="dont"><?php esc_html_e("Don't Show", 'woo-discount-rules'); ?>
125
  <div class="col-md-6">
126
  <select class="selectpicker" name="show_price_discount_on_product_page" id="show_price_discount_on_product_page">
127
  <option <?php if ($data['show_price_discount_on_product_page'] == 'show') { ?> selected=selected <?php } ?>
128
+ value="show"><?php esc_html_e('Show when a rule condition is matched', 'woo-discount-rules'); ?>
129
+ </option>
130
+ <option <?php if ($data['show_price_discount_on_product_page'] == 'show_after_rule_matches') { ?> selected=selected <?php } ?>
131
+ value="show_after_rule_matches"><?php esc_html_e('Show after a rule condition is matched', 'woo-discount-rules'); ?>
132
+ </option>
133
+ <option <?php if ($data['show_price_discount_on_product_page'] == 'show_on_qty_update') { ?> selected=selected <?php } ?>
134
+ value="show_on_qty_update"><?php esc_html_e('Shown on quantity update (dynamic)', 'woo-discount-rules'); ?>
135
  </option>
136
  <option <?php if ($data['show_price_discount_on_product_page'] == 'dont') { ?> selected=selected <?php } ?>
137
  value="dont"><?php esc_html_e("Don't Show", 'woo-discount-rules'); ?>
woo-discount-rules.php CHANGED
@@ -5,13 +5,13 @@
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
- * Version: 1.7.18
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 2.4
14
- * WC tested up to: 3.6
15
  */
16
 
17
  if (!defined('ABSPATH')) exit; // Exit if accessed directly
5
  * Description: Simple Discount Rules for WooCommerce.
6
  * Author: Flycart Technologies LLP
7
  * Author URI: https://www.flycart.org
8
+ * Version: 1.7.19
9
  * Slug: woo-discount-rules
10
  * Text Domain: woo-discount-rules
11
  * Domain Path: /i18n/languages/
12
  * Requires at least: 4.6.1
13
  * WC requires at least: 2.4
14
+ * WC tested up to: 3.7
15
  */
16
 
17
  if (!defined('ABSPATH')) exit; // Exit if accessed directly