Google Maps Plugin by Intergeo - Version 1.0.5

Version Description

  • Added information for map new installs
  • Fix issue for non-admins in freemius
Download this release

Release Info

Developer codeinwp
Plugin Icon 128x128 Google Maps Plugin by Intergeo
Version 1.0.5
Comparing to
See all releases

Code changes from version 1.0.3 to 1.0.5

Files changed (102) hide show
  1. CHANGELOG.md +20 -0
  2. css/editor.css +69 -65
  3. freemius/.gitignore +3 -0
  4. freemius/LICENSE.txt +340 -0
  5. freemius/README.md +245 -0
  6. freemius/assets/css/admin/account.css +1 -0
  7. freemius/assets/css/admin/add-ons.css +2 -0
  8. freemius/assets/css/admin/common.css +1 -0
  9. freemius/assets/css/admin/connect.css +1 -0
  10. freemius/assets/css/admin/deactivation-feedback.css +1 -0
  11. freemius/assets/css/admin/debug.css +1 -0
  12. freemius/assets/css/common.css +1 -0
  13. freemius/assets/img/plugin-icon.png +0 -0
  14. freemius/assets/js/jquery.ba-postmessage.js +222 -0
  15. freemius/assets/js/jquery.ba-postmessage.min.js +9 -0
  16. freemius/assets/js/nojquery.ba-postmessage.js +140 -0
  17. freemius/assets/js/nojquery.ba-postmessage.min.js +12 -0
  18. freemius/assets/js/postmessage.js +110 -0
  19. freemius/assets/scss/_colors.scss +58 -0
  20. freemius/assets/scss/_functions.scss +0 -0
  21. freemius/assets/scss/_load.scss +4 -0
  22. freemius/assets/scss/_mixins.scss +224 -0
  23. freemius/assets/scss/_start.scss +4 -0
  24. freemius/assets/scss/_vars.scss +5 -0
  25. freemius/assets/scss/admin/account.scss +171 -0
  26. freemius/assets/scss/admin/add-ons.scss +333 -0
  27. freemius/assets/scss/admin/common.scss +134 -0
  28. freemius/assets/scss/admin/connect.scss +421 -0
  29. freemius/assets/scss/admin/deactivation-feedback.scss +120 -0
  30. freemius/assets/scss/admin/debug.scss +91 -0
  31. freemius/composer.json +10 -0
  32. freemius/config.php +219 -0
  33. freemius/includes/class-freemius-abstract.php +404 -0
  34. freemius/includes/class-freemius.php +8912 -0
  35. freemius/includes/class-fs-api.php +453 -0
  36. freemius/includes/class-fs-logger.php +179 -0
  37. freemius/includes/class-fs-plugin-updater.php +328 -0
  38. freemius/includes/class-fs-security.php +61 -0
  39. freemius/includes/debug/class-fs-debug-bar-panel.php +62 -0
  40. freemius/includes/debug/debug-bar-start.php +52 -0
  41. freemius/includes/entities/class-fs-entity.php +149 -0
  42. freemius/includes/entities/class-fs-plugin-info.php +34 -0
  43. freemius/includes/entities/class-fs-plugin-license.php +160 -0
  44. freemius/includes/entities/class-fs-plugin-plan.php +124 -0
  45. freemius/includes/entities/class-fs-plugin-tag.php +24 -0
  46. freemius/includes/entities/class-fs-plugin.php +90 -0
  47. freemius/includes/entities/class-fs-pricing.php +50 -0
  48. freemius/includes/entities/class-fs-scope-entity.php +29 -0
  49. freemius/includes/entities/class-fs-site.php +127 -0
  50. freemius/includes/entities/class-fs-subscription.php +125 -0
  51. freemius/includes/entities/class-fs-user.php +62 -0
  52. freemius/includes/fs-core-functions.php +441 -0
  53. freemius/includes/fs-essential-functions.php +412 -0
  54. freemius/includes/fs-plugin-info-dialog.php +806 -0
  55. freemius/includes/i18n.php +324 -0
  56. freemius/includes/managers/class-fs-admin-menu-manager.php +549 -0
  57. freemius/includes/managers/class-fs-admin-notice-manager.php +303 -0
  58. freemius/includes/managers/class-fs-cache-manager.php +237 -0
  59. freemius/includes/managers/class-fs-key-value-storage.php +295 -0
  60. freemius/includes/managers/class-fs-license-manager.php +101 -0
  61. freemius/includes/managers/class-fs-option-manager.php +297 -0
  62. freemius/includes/managers/class-fs-plan-manager.php +162 -0
  63. freemius/includes/managers/class-fs-plugin-manager.php +154 -0
  64. freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +6 -0
  65. freemius/includes/sdk/Exceptions/EmptyArgumentException.php +6 -0
  66. freemius/includes/sdk/Exceptions/Exception.php +75 -0
  67. freemius/includes/sdk/Exceptions/InvalidArgumentException.php +6 -0
  68. freemius/includes/sdk/Exceptions/OAuthException.php +12 -0
  69. freemius/includes/sdk/Freemius.php +574 -0
  70. freemius/includes/sdk/FreemiusBase.php +178 -0
  71. freemius/includes/sdk/LICENSE.txt +340 -0
  72. freemius/includes/supplements/fs-essential-functions-1.1.7.1.php +45 -0
  73. freemius/start.php +335 -0
  74. freemius/templates/account.php +618 -0
  75. freemius/templates/add-ons.php +125 -0
  76. freemius/templates/admin-notice.php +46 -0
  77. freemius/templates/all-admin-notice.php +35 -0
  78. freemius/templates/checkout.php +260 -0
  79. freemius/templates/connect.php +200 -0
  80. freemius/templates/contact.php +77 -0
  81. freemius/templates/deactivation-feedback-modal.php +201 -0
  82. freemius/templates/debug.php +250 -0
  83. freemius/templates/debug/api-calls.php +138 -0
  84. freemius/templates/debug/logger.php +60 -0
  85. freemius/templates/debug/scheduled-crons.php +100 -0
  86. freemius/templates/email.php +46 -0
  87. freemius/templates/firewall-issues-js.php +60 -0
  88. freemius/templates/plugin-icon.php +93 -0
  89. freemius/templates/plugin-info/description.php +75 -0
  90. freemius/templates/plugin-info/features.php +97 -0
  91. freemius/templates/plugin-info/screenshots.php +33 -0
  92. freemius/templates/powered-by.php +41 -0
  93. freemius/templates/pricing.php +100 -0
  94. freemius/templates/sticky-admin-notice-js.php +40 -0
  95. index.php +1012 -934
  96. js/editor.js +1122 -1122
  97. js/misc.js +11 -0
  98. js/rendering.js +448 -445
  99. languages/intergeo-en_US.mo +0 -0
  100. languages/intergeo-en_US.po +1264 -1016
  101. readme.txt +159 -135
  102. templates/iframe/adsense.php +129 -161
CHANGELOG.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ ### 1.0.4.1 - 05/04/2016
4
+
5
+ Changes:
6
+
7
+
8
+ * added freemius
9
+
10
+
11
+ ### 1.0.4 - 05/04/2016
12
+
13
+ Changes:
14
+
15
+
16
+ * fix readme
17
+ * added freemius support
18
+ added pro support
19
+ * added freemius support
20
+ added pro support
css/editor.css CHANGED
@@ -1,65 +1,69 @@
1
- @font-face{font-family:'Elsie Swash Caps';font-style:normal;font-weight:900;src:local('Elsie Swash Caps Blacks'),local('ElsieSwashCapsBlack-Regular'),url(http://themes.googleusercontent.com/static/fonts/elsieswashcaps/v1/iZnus9qif0tR5pGaDv5zdEd2CPfIv3tbBh_qUxvoikM.woff) format('woff')}#intergeo_canvas_wrapper{position:absolute;top:0;right:300px;bottom:60px;left:0;z-index:75}#intergeo_canvas{width:100%;height:100%}#intergeo_canvas_center{width:10px;height:10px;position:absolute;top:50%;left:50%;margin:-5px 0 0 -5px;border-radius:2px;background-image:url(../images/map_center.png);background-position:center center;background-repeat:no-repeat}#intergeo_footer{height:36px;padding:12px 16px;position:absolute;z-index:100;left:0;right:0;bottom:0;border-top:1px solid #dfdfdf;overflow:hidden;-webkit-box-shadow:0 -4px 4px -4px rgba(0,0,0,0.1);box-shadow:0 -4px 4px -4px rgba(0,0,0,0.1);text-align:right}#intergeo_tlbr{position:absolute;top:0;right:0;bottom:60px;width:299px;z-index:75;background:whitesmoke;border-left:1px solid #dfdfdf;overflow:auto;-webkit-overflow-scrolling:touch}#intergeo_tlbr_ttl{font-family:'Elsie Swash Caps',cursive;font-size:34px;padding:30px 20px 10px;display:block}#intergeo_tlbr_ul{border-top:1px solid #dfdfdf}.intergeo_tlbr_ul_li{margin:0}.intergeo_tlbr_ul_li.open{border-bottom:1px solid #dfdfdf}.intergeo_tlbr_ul_li_h3{border-top:1px solid white;border-bottom:1px solid #dfdfdf;position:relative;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin:0;padding:10px 20px;font-size:15px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-weight:normal;text-shadow:0 1px 0 white;background:whiteSmoke;background-image:-webkit-gradient(linear,left bottom,left top,from(#EEE),to(whiteSmoke));background-image:-webkit-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-moz-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-o-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-ms-linear-gradient(bottom,#EEE,whiteSmoke);background-image:linear-gradient(bottom,#EEE,whiteSmoke)}.intergeo_tlbr_ul_li_h3:hover,.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3{color:white;text-shadow:0 -1px 0 #333;background:gray;background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(gray));background-image:-webkit-linear-gradient(bottom,#6d6d6d,gray);background-image:-moz-linear-gradient(bottom,#6d6d6d,gray);background-image:-o-linear-gradient(bottom,#6d6d6d,gray);background-image:-ms-linear-gradient(bottom,#6d6d6d,gray);background-image:linear-gradient(bottom,#6d6d6d,gray)}.intergeo_tlbr_ul_li_h3::after{content:'';width:0;height:0;border-color:#CCC transparent;border-style:solid;border-width:6px 6px 0;position:absolute;top:15px;right:20px;z-index:1}.intergeo_tlbr_ul_li_h3:hover::after,.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3::after{border-color:#EEE transparent}.intergeo_tlbr_ul_li:hover .intergeo_tlbr_ul_li_h3{border-top-color:gray}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3{border-top-color:#6d6d6d}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3::after{border-width:0 6px 6px}.intergeo_tlbr_ul_li_ul{margin:0;display:none;background-color:#fdfdfd;padding:10px 0 20px 0;overflow:hidden}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_ul{display:block}.intergeo_tlbr_cntrl_ttl{display:block;font-weight:bold;line-height:22px;position:relative;cursor:pointer;padding:4px 20px;margin-bottom:5px;background-color:rgba(0,0,0,0.02);border-top:1px solid #eee;-webkit-box-shadow:0 4px 4px -4px rgba(0,0,0,0.1);box-shadow:0 4px 4px -4px rgba(0,0,0,0.1);border-bottom:1px solid #eee}.intergeo_tlbr_cntrl_ttl::after{content:'';width:0;height:0;border-color:#CCC transparent;border-style:solid;border-width:4px 4px 0;position:absolute;top:13px;right:20px;z-index:1}.intergeo_tlbr_cntrl_ttl.open::after{border-width:0 4px 4px}.intergeo_tlbr_cntrl_items{display:none;padding:5px 20px 10px 20px}.intergeo_tlbr_cntrl_more_info{text-decoration:none;color:#21759b;font-size:85%;font-weight:normal;float:right}.intergeo_tlbr_cntrl_dsc{display:none;padding:0}.intergeo_tlbr_cntrl_tbl{width:100%;margin-bottom:10px}.intergeo_tlbr_cntrl_tbl_clmn{width:50%;text-align:left;vertical-align:top;padding:0 1px}.intergeo_tlbr_cntrl_item{margin-bottom:10px}#intergeo_map_zoom_range{margin:10px 6px}.intergeo_tlbr_style_preview{display:block;width:220px;height:90px;padding:10px;background-image:url(../images/styles.jpg);background-repeat:no-repeat;background-position:top left;-webkit-box-shadow:0 0 5px rgba(0,0,0,0.5);box-shadow:0 0 5px rgba(0,0,0,0.5)}#intergeo_tlbr_style_red{background-position:0 -110px}#intergeo_tlbr_style_night{background-position:0 -220px}#intergeo_tlbr_style_blue{background-position:0 -330px}#intergeo_tlbr_style_grayscale{background-position:0 -440px}#intergeo_tlbr_style_no_roads{background-position:0 -550px}#intergeo_tlbr_style_mixed{background-position:0 -660px}#intergeo_tlbr_style_chilled{background-position:0 -770px}.intergeo_tlbr_overlay{border-bottom:1px dotted black;margin-bottom:5px;padding-bottom:5px}.intergeo_tlbr_actn{float:right;margin:4px 0 0 10px;background-repeat:no-repeat;display:block;height:16px;width:16px;background-image:url('../images/ui-icons.png')}.intergeo_tlbr_actn_delete{background-position:-176px -96px}.intergeo_tlbr_actn_edit{background-position:-64px -112px}.intergeo_tlbr_clr_prvw{float:right;margin:4px 0 0 10px;height:16px;width:16px;-webkit-box-shadow:0 0 2px #aaa;box-shadow:0 0 2px #aaa}.intergeo_tlbr_cntrl_slct{width:100%}.intergeo_tlbr_cntrl_txt{width:100%}.intergeo_tlbr_grp_dsc{padding:5px 20px 10px 20px;margin:0}.intergeo_ppp{position:absolute;top:0;right:0;left:0;bottom:0;z-index:150;background-image:url('../images/bg.png');background-repeat:repeat;display:none}.intergeo_ppp_frm{position:absolute;top:10%;left:50%;max-height:530px;-ms-overflow-y:auto;overflow-y:auto;margin-left:-222px;width:400px;border:2px solid #555;background-color:white;-webkit-box-shadow:0 0 15px #555;box-shadow:0 0 15px #555;padding:10px 20px 15px;border-radius:3px}.intergeo_ppp_ttl{font-weight:bold;font-size:115%;color:#333;border-bottom:1px solid whitesmoke;display:block;padding:5px 0;margin-bottom:10px}.intergeo_ppp_cls{float:right;background-image:url('../images/ui-icons.png');background-repeat:no-repeat;background-position:-80px -128px;display:block;width:16px;height:16px}.intergeo_ppp_tbl{width:100%}.intergeo_ppp_tbl td{padding-bottom:5px}.intergeo_ppp_txt{width:100%}#intergeo_tlbr_drctn_icon{margin-top:1px;margin-left:-5px;float:left;display:block;width:16px;height:16px;background-repeat:no-repeat;background-image:url('../images/ui-icons.png');background-position:-16px -128px}
2
-
3
- .computer-btn{
4
- color: #646464 !important;
5
- border: medium none rgb(100, 100, 100) !important;
6
- background: #E6E6E6 url("../images/computer.png") no-repeat scroll 7px 1px !important;
7
- padding-left: 27px !important;
8
- transition: all 0.3s ease 0s;
9
- font-family: "Open Sans",sans-serif;
10
- font-weight: 700;
11
- border: 1px solid #B0B0B0 !important;
12
- box-shadow: none !important;
13
-
14
- }
15
-
16
- .computer-btn:hover{
17
- color: white !important;
18
- background: #2f8cea url("../images/computer.png") no-repeat scroll 7px -36px !important;
19
- transition: all 0.3s ease 0s;
20
- padding-left: 27px !important;
21
- -webkit-transition: all .3s ease;
22
- -moz-transition: all .3s ease;
23
- -ms-transition: all .3s ease;
24
- -o-transition: all .3s ease;
25
- transition: all .3s ease;
26
- box-shadow: 0px 1px 0px rgba(171, 171, 171, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
27
- border: 1px solid #2f8cea !important;
28
- box-shadow: none !important;
29
-
30
-
31
- }
32
-
33
- .file-wrapper {
34
- position: relative;
35
- overflow: hidden;
36
- }
37
-
38
- .form-inline {
39
- display: inline-block;
40
- margin-bottom: 0;
41
- vertical-align: middle;
42
- }
43
-
44
- #thehole {
45
- position: absolute;
46
- left: 0;
47
- top: 0;
48
- width: 1px;
49
- height: 1px;
50
- border: 0;
51
- opacity: 0;
52
- -moz-opacity: 0;
53
- filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
54
- }
55
-
56
- .file {
57
- font-size: 200px;
58
- position: absolute;
59
- top: 0;
60
- right: 0;
61
- opacity: 0;
62
- -moz-opacity: 0;
63
- filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
64
- cursor: pointer;
65
- }
 
 
 
 
1
+ @font-face{font-family:'Elsie Swash Caps';font-style:normal;font-weight:900;src:local('Elsie Swash Caps Blacks'),local('ElsieSwashCapsBlack-Regular'),url(http://themes.googleusercontent.com/static/fonts/elsieswashcaps/v1/iZnus9qif0tR5pGaDv5zdEd2CPfIv3tbBh_qUxvoikM.woff) format('woff')}#intergeo_canvas_wrapper{position:absolute;top:0;right:300px;bottom:60px;left:0;z-index:75}#intergeo_canvas{width:100%;height:100%}#intergeo_canvas_center{width:10px;height:10px;position:absolute;top:50%;left:50%;margin:-5px 0 0 -5px;border-radius:2px;background-image:url(../images/map_center.png);background-position:center center;background-repeat:no-repeat}#intergeo_footer{height:36px;padding:12px 16px;position:absolute;z-index:100;left:0;right:0;bottom:0;border-top:1px solid #dfdfdf;overflow:hidden;-webkit-box-shadow:0 -4px 4px -4px rgba(0,0,0,0.1);box-shadow:0 -4px 4px -4px rgba(0,0,0,0.1);text-align:right}#intergeo_tlbr{position:absolute;top:0;right:0;bottom:60px;width:299px;z-index:75;background:whitesmoke;border-left:1px solid #dfdfdf;overflow:auto;-webkit-overflow-scrolling:touch}#intergeo_tlbr_ttl{font-family:'Elsie Swash Caps',cursive;font-size:34px;padding:30px 20px 10px;display:block}#intergeo_tlbr_ul{border-top:1px solid #dfdfdf}.intergeo_tlbr_ul_li{margin:0}.intergeo_tlbr_ul_li.open{border-bottom:1px solid #dfdfdf}.intergeo_tlbr_ul_li_h3{border-top:1px solid white;border-bottom:1px solid #dfdfdf;position:relative;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;margin:0;padding:10px 20px;font-size:15px;font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;font-weight:normal;text-shadow:0 1px 0 white;background:whiteSmoke;background-image:-webkit-gradient(linear,left bottom,left top,from(#EEE),to(whiteSmoke));background-image:-webkit-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-moz-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-o-linear-gradient(bottom,#EEE,whiteSmoke);background-image:-ms-linear-gradient(bottom,#EEE,whiteSmoke);background-image:linear-gradient(bottom,#EEE,whiteSmoke)}.intergeo_tlbr_ul_li_h3:hover,.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3{color:white;text-shadow:0 -1px 0 #333;background:gray;background-image:-webkit-gradient(linear,left bottom,left top,from(#6d6d6d),to(gray));background-image:-webkit-linear-gradient(bottom,#6d6d6d,gray);background-image:-moz-linear-gradient(bottom,#6d6d6d,gray);background-image:-o-linear-gradient(bottom,#6d6d6d,gray);background-image:-ms-linear-gradient(bottom,#6d6d6d,gray);background-image:linear-gradient(bottom,#6d6d6d,gray)}.intergeo_tlbr_ul_li_h3::after{content:'';width:0;height:0;border-color:#CCC transparent;border-style:solid;border-width:6px 6px 0;position:absolute;top:15px;right:20px;z-index:1}.intergeo_tlbr_ul_li_h3:hover::after,.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3::after{border-color:#EEE transparent}.intergeo_tlbr_ul_li:hover .intergeo_tlbr_ul_li_h3{border-top-color:gray}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3{border-top-color:#6d6d6d}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_h3::after{border-width:0 6px 6px}.intergeo_tlbr_ul_li_ul{margin:0;display:none;background-color:#fdfdfd;padding:10px 0 20px 0;overflow:hidden}.intergeo_tlbr_ul_li.open .intergeo_tlbr_ul_li_ul{display:block}.intergeo_tlbr_cntrl_ttl{display:block;font-weight:bold;line-height:22px;position:relative;cursor:pointer;padding:4px 20px;margin-bottom:5px;background-color:rgba(0,0,0,0.02);border-top:1px solid #eee;-webkit-box-shadow:0 4px 4px -4px rgba(0,0,0,0.1);box-shadow:0 4px 4px -4px rgba(0,0,0,0.1);border-bottom:1px solid #eee}.intergeo_tlbr_cntrl_ttl::after{content:'';width:0;height:0;border-color:#CCC transparent;border-style:solid;border-width:4px 4px 0;position:absolute;top:13px;right:20px;z-index:1}.intergeo_tlbr_cntrl_ttl.open::after{border-width:0 4px 4px}.intergeo_tlbr_cntrl_items{display:none;padding:5px 20px 10px 20px}.intergeo_tlbr_cntrl_more_info{text-decoration:none;color:#21759b;font-size:85%;font-weight:normal;float:right}.intergeo_tlbr_cntrl_dsc{display:none;padding:0}.intergeo_tlbr_cntrl_tbl{width:100%;margin-bottom:10px}.intergeo_tlbr_cntrl_tbl_clmn{width:50%;text-align:left;vertical-align:top;padding:0 1px}.intergeo_tlbr_cntrl_item{margin-bottom:10px}#intergeo_map_zoom_range{margin:10px 6px}.intergeo_tlbr_style_preview{display:block;width:220px;height:90px;padding:10px;background-image:url(../images/styles.jpg);background-repeat:no-repeat;background-position:top left;-webkit-box-shadow:0 0 5px rgba(0,0,0,0.5);box-shadow:0 0 5px rgba(0,0,0,0.5)}#intergeo_tlbr_style_red{background-position:0 -110px}#intergeo_tlbr_style_night{background-position:0 -220px}#intergeo_tlbr_style_blue{background-position:0 -330px}#intergeo_tlbr_style_grayscale{background-position:0 -440px}#intergeo_tlbr_style_no_roads{background-position:0 -550px}#intergeo_tlbr_style_mixed{background-position:0 -660px}#intergeo_tlbr_style_chilled{background-position:0 -770px}.intergeo_tlbr_overlay{border-bottom:1px dotted black;margin-bottom:5px;padding-bottom:5px}.intergeo_tlbr_actn{float:right;margin:4px 0 0 10px;background-repeat:no-repeat;display:block;height:16px;width:16px;background-image:url('../images/ui-icons.png')}.intergeo_tlbr_actn_delete{background-position:-176px -96px}.intergeo_tlbr_actn_edit{background-position:-64px -112px}.intergeo_tlbr_clr_prvw{float:right;margin:4px 0 0 10px;height:16px;width:16px;-webkit-box-shadow:0 0 2px #aaa;box-shadow:0 0 2px #aaa}.intergeo_tlbr_cntrl_slct{width:100%}.intergeo_tlbr_cntrl_txt{width:100%}.intergeo_tlbr_grp_dsc{text-align:center; padding:5px 20px 10px 20px;margin:0}.intergeo_ppp{position:absolute;top:0;right:0;left:0;bottom:0;z-index:150;background-image:url('../images/bg.png');background-repeat:repeat;display:none}.intergeo_ppp_frm{position:absolute;top:10%;left:50%;max-height:530px;-ms-overflow-y:auto;overflow-y:auto;margin-left:-222px;width:400px;border:2px solid #555;background-color:white;-webkit-box-shadow:0 0 15px #555;box-shadow:0 0 15px #555;padding:10px 20px 15px;border-radius:3px}.intergeo_ppp_ttl{font-weight:bold;font-size:115%;color:#333;border-bottom:1px solid whitesmoke;display:block;padding:5px 0;margin-bottom:10px}.intergeo_ppp_cls{float:right;background-image:url('../images/ui-icons.png');background-repeat:no-repeat;background-position:-80px -128px;display:block;width:16px;height:16px}.intergeo_ppp_tbl{width:100%}.intergeo_ppp_tbl td{padding-bottom:5px}.intergeo_ppp_txt{width:100%}#intergeo_tlbr_drctn_icon{margin-top:1px;margin-left:-5px;float:left;display:block;width:16px;height:16px;background-repeat:no-repeat;background-image:url('../images/ui-icons.png');background-position:-16px -128px}
2
+
3
+ .computer-btn{
4
+ color: #646464 !important;
5
+ border: medium none rgb(100, 100, 100) !important;
6
+ background: #E6E6E6 url("../images/computer.png") no-repeat scroll 7px 1px !important;
7
+ padding-left: 27px !important;
8
+ transition: all 0.3s ease 0s;
9
+ font-family: "Open Sans",sans-serif;
10
+ font-weight: 700;
11
+ border: 1px solid #B0B0B0 !important;
12
+ box-shadow: none !important;
13
+
14
+ }
15
+
16
+ .computer-btn:hover{
17
+ color: white !important;
18
+ background: #2f8cea url("../images/computer.png") no-repeat scroll 7px -36px !important;
19
+ transition: all 0.3s ease 0s;
20
+ padding-left: 27px !important;
21
+ -webkit-transition: all .3s ease;
22
+ -moz-transition: all .3s ease;
23
+ -ms-transition: all .3s ease;
24
+ -o-transition: all .3s ease;
25
+ transition: all .3s ease;
26
+ box-shadow: 0px 1px 0px rgba(171, 171, 171, 0.5) inset, 0px 1px 0px rgba(0, 0, 0, 0.15) !important;
27
+ border: 1px solid #2f8cea !important;
28
+ box-shadow: none !important;
29
+
30
+
31
+ }
32
+
33
+ .file-wrapper {
34
+ position: relative;
35
+ overflow: hidden;
36
+ }
37
+
38
+ .form-inline {
39
+ display: inline-block;
40
+ margin-bottom: 0;
41
+ vertical-align: middle;
42
+ }
43
+
44
+ #thehole {
45
+ position: absolute;
46
+ left: 0;
47
+ top: 0;
48
+ width: 1px;
49
+ height: 1px;
50
+ border: 0;
51
+ opacity: 0;
52
+ -moz-opacity: 0;
53
+ filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
54
+ }
55
+
56
+ .file {
57
+ font-size: 200px;
58
+ position: absolute;
59
+ top: 0;
60
+ right: 0;
61
+ opacity: 0;
62
+ -moz-opacity: 0;
63
+ filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);
64
+ cursor: pointer;
65
+ }
66
+
67
+ .computer-btn{
68
+ text-shadow: none !important;
69
+ }
freemius/.gitignore ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ output/
2
+ assets/img/icon.*
3
+
freemius/LICENSE.txt ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
freemius/README.md ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Freemius WordPress SDK
2
+ ======================
3
+
4
+ Freemius is an [analytics](https://freemius.com/wordpress/insights/) & [monetization](https://freemius.com/wordpress/) platform for plugin developers. Freemius empower developers with advanced real-time analytics and helps turning any plugin into a commercial product in less than 10 min.
5
+
6
+ The platform is fully functional and running in production. Having said that, the monetization platform is still in closed beta.
7
+ If you are a WordPress plugin developer and you are interested to monetize with Freemius [apply to our closed beta here](http://bit.ly/freemius-beta):
8
+
9
+ http://bit.ly/freemius-beta
10
+
11
+ **Below you'll find the integration instructions for our WordPress SDK.**
12
+
13
+ ## Initializing the SDK
14
+
15
+ Copy the code below and paste it into the top of your main plugin's PHP file, right after the plugin's header comment:
16
+
17
+ ```php
18
+ <?php
19
+ // Create a helper function for easy SDK access.
20
+ function my_prefix_fs() {
21
+ global $my_prefix_fs;
22
+ if ( ! isset( $my_prefix_fs ) ) {
23
+ // Include Freemius SDK.
24
+ require_once dirname(__FILE__) . '/freemius/start.php';
25
+
26
+ $my_prefix_fs = fs_dynamic_init( array(
27
+ 'id' => '1234',
28
+ 'slug' => 'my-plugin-slug',
29
+ 'menu_slug' => 'my_menu_slug', // You can also use __FILE__
30
+ 'public_key' => 'pk_MY_PUBLIC_KEY',
31
+ 'is_live' => true,
32
+ 'is_premium' => true,
33
+ 'has_addons' => false,
34
+ 'has_paid_plans' => false,
35
+ // Set the SDK to work in a sandbox mode (for development & testing).
36
+ // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
37
+ 'secret_key' => 'sk_MY_SECRET_KEY',
38
+ ) );
39
+ }
40
+
41
+ return $my_prefix_fs;
42
+ }
43
+
44
+ // Init Freemius.
45
+ my_prefix_fs();
46
+ ?>
47
+ ```
48
+
49
+ - **1234** - Replace with your plugin's ID.
50
+ - **pk_MY_PUBLIC_KEY** - Replace with your plugin's public key.
51
+ - **sk_MY_SECRET_KEY** - Replace with your plugin's secret key.
52
+ - **my-plugin-slug** - Replace with your plugin's WordPress.org slug.
53
+ - **my_menu_slug** - Replace with your admin dashboard settings menu slug.
54
+
55
+
56
+ ## Usage example
57
+
58
+ You can call the SDK by using the shortcode function:
59
+
60
+ ```php
61
+ <?php my_prefix_fs()->get_upgrade_url(); ?>
62
+ ```
63
+
64
+ Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
65
+
66
+ ```php
67
+ <?php
68
+ global $my_prefix_fs;
69
+ $my_prefix_fs->get_account_url();
70
+ ?>
71
+ ```
72
+
73
+ ## Adding license based logic examples
74
+
75
+ Add marketing content to encourage your users to upgrade for your paid version:
76
+
77
+ ```php
78
+ <?php
79
+ if ( my_prefix_fs()->is_not_paying() ) {
80
+ echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
81
+ echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
82
+ esc_html__('Upgrade Now!', 'my-plugin-slug') .
83
+ '</a>';
84
+ echo '</section>';
85
+ }
86
+ ?>
87
+ ```
88
+
89
+ Add logic which will only be available in your premium plugin version:
90
+
91
+ ```php
92
+ <?php
93
+ // This "if" block will be auto removed from the Free version.
94
+ if ( my_prefix_fs()->is__premium_only() ) {
95
+
96
+ // ... premium only logic ...
97
+
98
+ }
99
+ ?>
100
+ ```
101
+
102
+ To add a function which will only be available in your premium plugin version, simply add __premium_only as the suffix of the function name. Just make sure that all lines that call that method directly or by hooks, are also wrapped in premium only logic:
103
+
104
+ ```php
105
+ <?php
106
+ class My_Plugin {
107
+ function init() {
108
+ ...
109
+
110
+ // This "if" block will be auto removed from the free version.
111
+ if ( my_prefix_fs()->is__premium_only() ) {
112
+ // Init premium version.
113
+ $this->admin_init__premium_only();
114
+
115
+ add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
116
+ }
117
+
118
+ ...
119
+ }
120
+
121
+ // This method will be only included in the premium version.
122
+ function admin_init__premium_only() {
123
+ ...
124
+ }
125
+
126
+ // This method will be only included in the premium version.
127
+ function admin_init_hook__premium_only() {
128
+ ...
129
+ }
130
+ }
131
+ ?>
132
+ ```
133
+
134
+ Add logic which will only be executed for customers in your 'professional' plan:
135
+
136
+ ```php
137
+ <?php
138
+ if ( my_prefix_fs()->is_plan('professional', true) ) {
139
+ // .. logic related to Professional plan only ...
140
+ }
141
+ ?>
142
+ ```
143
+
144
+ Add logic which will only be executed for customers in your 'professional' plan or higher plans:
145
+
146
+ ```php
147
+ <?php
148
+ if ( my_prefix_fs()->is_plan('professional') ) {
149
+ // ... logic related to Professional plan and higher plans ...
150
+ }
151
+ ?>
152
+ ```
153
+
154
+ Add logic which will only be available in your premium plugin version AND will only be executed for customers in your 'professional' plan (and higher plans):
155
+
156
+ ```php
157
+ <?php
158
+ // This "if" block will be auto removed from the Free version.
159
+ if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
160
+ // ... logic related to Professional plan and higher plans ...
161
+ }
162
+ ?>
163
+ ```
164
+
165
+ Add logic only for users in trial:
166
+
167
+ ```php
168
+ <?php
169
+ if ( my_prefix_fs()->is_trial() ) {
170
+ // ... logic for users in trial ...
171
+ }
172
+ ?>
173
+ ```
174
+
175
+ Add logic for specified paid plan:
176
+
177
+ ```php
178
+ <?php
179
+ // This "if" block will be auto removed from the Free version.
180
+ if ( my_prefix_fs()->is__premium_only() ) {
181
+ if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
182
+
183
+ // ... logic related to Professional plan only ...
184
+
185
+ } else if ( my_prefix_fs()->is_plan( 'business' ) ) {
186
+
187
+ // ... logic related to Business plan and higher plans ...
188
+
189
+ }
190
+ }
191
+ ?>
192
+ ```
193
+
194
+ ## Excluding files and folders from the free plugin version
195
+ There are two ways to exclude files from your free version.
196
+
197
+ 1. Add `__premium_only` just before the file extension. For example, functions__premium_only.php will be only included in the premium plugin version. This works for all type of files, not only PHP.
198
+ 2. Add `@fs_premium_only` a sepcial meta tag to the plugin's main PHP file header. Example:
199
+ ```php
200
+ <?php
201
+ /**
202
+ * Plugin Name: My Very Awesome Plugin
203
+ * Plugin URI: http://my-awesome-plugin.com
204
+ * Description: Create and manage Awesomeness right in WordPress.
205
+ * Version: 1.0.0
206
+ * Author: Awesomattic
207
+ * Author URI: http://my-awesome-plugin.com/me/
208
+ * License: GPLv2
209
+ * Text Domain: myplugin
210
+ * Domain Path: /langs
211
+ *
212
+ * @fs_premium_only /lib/functions.php, /premium-files/
213
+ */
214
+
215
+ if ( ! defined( 'ABSPATH' ) ) {
216
+ exit;
217
+ }
218
+
219
+ // ... my code ...
220
+ ?>
221
+ ```
222
+ The file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
223
+
224
+ # WordPress.org Compliance
225
+ Based on [WordPress.org Guidelines](https://wordpress.org/plugins/about/guidelines/) you are not allowed to submit a plugin that has premium code in it:
226
+ > All code hosted by WordPress.org servers must be free and fully-functional. If you want to sell advanced features for a plugin (such as a "pro" version), then you must sell and serve that code from your own site, we will not host it on our servers.
227
+
228
+ Therefore, if you want to deploy your free plugin's version to WordPress.org, make sure you wrap all your premium code with `if ( my_prefix_fs()->{{ method }}__premium_only() )` or the other methods provided to exclude premium features & files from the free version.
229
+
230
+ ## Deployment
231
+ Zip your plugin's root folder and upload it in the Deployment section in the *Freemius Developer's Dashboard*.
232
+ The plugin will be scanned and processed by a custom developed *PHP Processor* which will auto-generate two versions of your plugin:
233
+
234
+ 1. **Premium version**: Identical to your uploaded version, including all code (except your `secret_key`). Will be enabled for download ONLY for your paying or in trial customers.
235
+ 2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
236
+
237
+ The free version is the one that you should give your users to download. Therefore, download the free generated version and upload to your site. Or, if your plugin was WordPress.org complaint and you made sure to exclude all your premium code with the different provided techniques, you can deploy the downloaded free version to the .org repo.
238
+
239
+ ## Reporting Bugs
240
+ Email dev [at] freemius [dot] com
241
+
242
+ ## FAQ
243
+
244
+ ## Copyright
245
+ Freemius, Inc.
freemius/assets/css/admin/account.css ADDED
@@ -0,0 +1 @@
 
1
+ #fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account h3{font-size:1.3em;padding:12px 15px;margin:0 0 12px 0;line-height:1.4;border-bottom:1px solid #F1F1F1}#fs_account i.dashicons{font-size:1.2em;height:1.2em;width:1.2em}#fs_account .button i.dashicons{vertical-align:middle}#fs_account .fs-header-actions{position:absolute;top:17px;right:15px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}.rtl #fs_account .fs-header-actions{left:15px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table var,.fs-key-value-table code{color:#0073AA;font-size:16px;background:none}label.fs-tag{background:#ffba00;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}label.fs-tag.fs-warn{background:#ffba00}label.fs-tag.fs-success{background:#46b450}label.fs-tag.fs-error{background:#dc3232}#fs_addons h3{border:none;margin-bottom:0;padding:4px 5px}#fs_addons td{vertical-align:middle}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}
freemius/assets/css/admin/add-ons.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ #fs_addons .fs-cards-list{list-style:none}#fs_addons .fs-cards-list .fs-card{float:left;height:152px;width:310px;padding:0;margin:0 0 30px 30px;font-size:14px;list-style:none;border:1px solid #ddd;cursor:pointer;position:relative}#fs_addons .fs-cards-list .fs-card .fs-overlay{position:absolute;left:0;right:0;bottom:0;top:0;z-index:9}#fs_addons .fs-cards-list .fs-card .fs-inner{background-color:#fff;overflow:hidden;height:100%;position:relative}#fs_addons .fs-cards-list .fs-card .fs-inner ul{-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s;left:0;right:0;top:0;position:absolute}#fs_addons .fs-cards-list .fs-card .fs-inner li{list-style:none;line-height:18px;padding:0 15px;width:100%;display:block;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-card-banner{padding:0;margin:0;line-height:0;display:block;height:100px;background-repeat:repeat-x;background-size:100% 100%;-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-title{margin:10px 0 0 0;height:18px;overflow:hidden;color:#000;white-space:nowrap;text-overflow:ellipsis;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-offer{font-size:0.9em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-description{background-color:#f9f9f9;padding:10px 15px 100px 15px;border-top:1px solid #eee;margin:0 0 10px 0;color:#777}@media screen and (min-width: 960px){#fs_addons .fs-cards-list .fs-card:hover .fs-overlay{border:2px solid #29abe1;margin-left:-1px;margin-top:-1px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner ul{top:-100px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-title,#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-offer{color:#29abe1}}
2
+ #TB_window,#TB_window iframe{width:772px !important}#plugin-information #section-description h2,#plugin-information #section-description h3,#plugin-information #section-description p,#plugin-information #section-description b,#plugin-information #section-description i,#plugin-information #section-description blockquote,#plugin-information #section-description li,#plugin-information #section-description ul,#plugin-information #section-description ol{clear:none}#plugin-information #section-description .fs-selling-points{padding-bottom:10px;border-bottom:1px solid #ddd}#plugin-information #section-description .fs-selling-points ul{margin:0}#plugin-information #section-description .fs-selling-points ul li{padding:0;list-style:none outside none}#plugin-information #section-description .fs-selling-points ul li i.dashicons{color:#71ae00;font-size:3em;vertical-align:middle;line-height:30px;float:left;margin:0 0 0 -15px}#plugin-information #section-description .fs-selling-points ul li h3{margin:1em 30px !important}#plugin-information #section-description .fs-screenshots:after{content:"";display:table;clear:both}#plugin-information #section-description .fs-screenshots ul{list-style:none;margin:0}#plugin-information #section-description .fs-screenshots ul li{width:225px;height:225px;float:left;margin-bottom:20px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#plugin-information #section-description .fs-screenshots ul li a{display:block;width:100%;height:100%;border:1px solid;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);background-size:cover}#plugin-information #section-description .fs-screenshots ul li.odd{margin-right:20px}#plugin-information .plugin-information-pricing{background:#FFFEEC;margin:-16px;padding:20px;border-bottom:1px solid #DDD}#plugin-information .plugin-information-pricing h3{margin-top:0}#plugin-information .plugin-information-pricing .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing label{white-space:nowrap}#plugin-information .plugin-information-pricing ul.fs-trial-terms{font-size:0.9em}#plugin-information .plugin-information-pricing ul.fs-trial-terms i{float:left;margin:0 0 0 -15px}#plugin-information .plugin-information-pricing ul.fs-trial-terms li{margin:10px 0 0 0}#plugin-information #section-features .fs-features{margin:-20px -26px}#plugin-information #section-features table{width:100%;border-spacing:0;border-collapse:separate}#plugin-information #section-features table thead th{padding:10px 0}#plugin-information #section-features table thead .fs-price{color:#71ae00;font-weight:normal;display:block;text-align:center}#plugin-information #section-features table tbody td{border-top:1px solid #ccc;padding:10px 0;text-align:center;width:100px;color:#71ae00}#plugin-information #section-features table tbody td:first-child{text-align:left;width:auto;color:inherit;padding-left:26px}#plugin-information #section-features table tbody tr.fs-odd td{background:#fefefe}#plugin-information #section-features .dashicons-yes{width:30px;height:30px;font-size:30px}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}
freemius/assets/css/admin/common.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-notice-body{margin:.5em 0;padding:2px}.fs-notice .fs-close{cursor:pointer;color:#aaa;float:right}.fs-notice .fs-close:hover{color:#666}.fs-notice .fs-close>*{margin-top:7px;display:inline-block}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;bottom:-22px;top:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}.rtl .fs-notice .fs-close{float:left}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;box-shadow:0px 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}
freemius/assets/css/admin/connect.css ADDED
@@ -0,0 +1 @@
 
1
+ #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-primary:after{content:' \279C'}#fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}.rtl #fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}.rtl #fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}.rtl #fs_connect .fs-actions .button.button-primary:after{content:' \000bb'}.rtl #fs_connect .fs-actions .button.button-primary.fs-loading:after{content:''}.rtl #fs_connect .fs-actions .button.button-secondary{float:left}.rtl #fs_connect .fs-permissions ul li div{margin-right:55px;margin-left:0}.rtl #fs_connect .fs-permissions ul li i.dashicons{float:right}.rtl #fs_connect .fs-visual .fs-site-icon{right:20px;left:auto}.rtl #fs_connect .fs-visual .fs-connect-logo{right:auto;left:20px}.wp-pointer-content #fs_connect{margin:0;-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none}.fs-opt-in-pointer .wp-pointer-content{padding:0}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow{border-bottom-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-top .wp-pointer-arrow-inner{border-bottom-color:#fafafa}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow{border-top-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-bottom .wp-pointer-arrow-inner{border-top-color:#fafafa}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow{border-right-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-left .wp-pointer-arrow-inner{border-right-color:#fafafa}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow{border-left-color:#dfdfdf}.fs-opt-in-pointer.wp-pointer-right .wp-pointer-arrow-inner{border-left-color:#fafafa}
freemius/assets/css/admin/deactivation-feedback.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}.fs-modal .fs-modal-dialog li.reason{margin-bottom:10px}.fs-modal .fs-modal-dialog li.reason .reason-input{margin-left:29px}.fs-modal .fs-modal-dialog li.reason label{display:table}.fs-modal .fs-modal-dialog li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body h2{font-size:20px}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel:not(.active){display:none}.fs-modal .reason-input{margin:3px 0 3px 22px}.fs-modal .reason-input input,.fs-modal .reason-input textarea{width:100%}body.has-fs-modal{overflow:hidden}#the-list .deactivate>.fs-slug{display:none}
freemius/assets/css/admin/debug.css ADDED
@@ -0,0 +1 @@
 
1
+ .switch{position:relative;display:inline-block;font-size:1.6em;font-weight:bold;color:#ccc;text-shadow:0px 1px 1px rgba(255,255,255,0.8);height:18px;padding:6px 6px 5px 6px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:4px;background:#ececec;box-shadow:0px 0px 4px rgba(0,0,0,0.1),inset 0px 1px 3px 0px rgba(0,0,0,0.1);cursor:pointer}.switch span{display:inline-block;width:35px;text-transform:uppercase}.switch span.on{color:#6bc406}.switch .toggle{position:absolute;top:1px;width:37px;height:25px;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.3);border-radius:4px;background:#fff;background:-moz-linear-gradient(top, #ececec 0%, #fff 100%);background:-webkit-gradient(linear, left top, left bottom, color-stop(0%, #ececec), color-stop(100%, #fff));background:-webkit-linear-gradient(top, #ececec 0%, #fff 100%);background:-o-linear-gradient(top, #ececec 0%, #fff 100%);background:-ms-linear-gradient(top, #ececec 0%, #fff 100%);background:linear-gradient(top, #ececec 0%, #fff 100%);box-shadow:inset 0px 1px 0px 0px rgba(255,255,255,0.5);z-index:999;-moz-transition:all 0.15s ease-in-out;-o-transition:all 0.15s ease-in-out;-ms-transition:all 0.15s ease-in-out;-webkit-transition:all 0.15s ease-in-out;transition:all 0.15s ease-in-out}.switch.on .toggle{left:2%}.switch.off .toggle{left:54%}.switch.round{padding:0px 20px;border-radius:40px}.switch.round .toggle{border-radius:40px;width:14px;height:14px}.switch.round.on .toggle{left:3%;background:#6bc406}.switch.round.off .toggle{left:58%}.switch-label{font-size:20px;line-height:31px;margin:0 5px}
freemius/assets/css/common.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice.success{color:green;font-weight:700}
freemius/assets/img/plugin-icon.png ADDED
Binary file
freemius/assets/js/jquery.ba-postmessage.js ADDED
@@ -0,0 +1,222 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery postMessage - v0.5 - 9/11/2009
3
+ * http://benalman.com/projects/jquery-postmessage-plugin/
4
+ *
5
+ * Copyright (c) 2009 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ */
9
+
10
+ // Script: jQuery postMessage: Cross-domain scripting goodness
11
+ //
12
+ // *Version: 0.5, Last updated: 9/11/2009*
13
+ //
14
+ // Project Home - http://benalman.com/projects/jquery-postmessage-plugin/
15
+ // GitHub - http://github.com/cowboy/jquery-postmessage/
16
+ // Source - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.js
17
+ // (Minified) - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.min.js (0.9kb)
18
+ //
19
+ // About: License
20
+ //
21
+ // Copyright (c) 2009 "Cowboy" Ben Alman,
22
+ // Dual licensed under the MIT and GPL licenses.
23
+ // http://benalman.com/about/license/
24
+ //
25
+ // About: Examples
26
+ //
27
+ // This working example, complete with fully commented code, illustrates one
28
+ // way in which this plugin can be used.
29
+ //
30
+ // Iframe resizing - http://benalman.com/code/projects/jquery-postmessage/examples/iframe/
31
+ //
32
+ // About: Support and Testing
33
+ //
34
+ // Information about what version or versions of jQuery this plugin has been
35
+ // tested with and what browsers it has been tested in.
36
+ //
37
+ // jQuery Versions - 1.3.2
38
+ // Browsers Tested - Internet Explorer 6-8, Firefox 3, Safari 3-4, Chrome, Opera 9.
39
+ //
40
+ // About: Release History
41
+ //
42
+ // 0.5 - (9/11/2009) Improved cache-busting
43
+ // 0.4 - (8/25/2009) Initial release
44
+
45
+ (function($){
46
+ '$:nomunge'; // Used by YUI compressor.
47
+
48
+ // A few vars used in non-awesome browsers.
49
+ var interval_id,
50
+ last_hash,
51
+ cache_bust = 1,
52
+
53
+ // A var used in awesome browsers.
54
+ rm_callback,
55
+
56
+ // A few convenient shortcuts.
57
+ window = this,
58
+ FALSE = !1,
59
+
60
+ // Reused internal strings.
61
+ postMessage = 'postMessage',
62
+ addEventListener = 'addEventListener',
63
+
64
+ p_receiveMessage,
65
+
66
+ // I couldn't get window.postMessage to actually work in Opera 9.64!
67
+ has_postMessage = window[postMessage] && !$.browser.opera;
68
+
69
+ // Method: jQuery.postMessage
70
+ //
71
+ // This method will call window.postMessage if available, setting the
72
+ // targetOrigin parameter to the base of the target_url parameter for maximum
73
+ // security in browsers that support it. If window.postMessage is not available,
74
+ // the target window's location.hash will be used to pass the message. If an
75
+ // object is passed as the message param, it will be serialized into a string
76
+ // using the jQuery.param method.
77
+ //
78
+ // Usage:
79
+ //
80
+ // > jQuery.postMessage( message, target_url [, target ] );
81
+ //
82
+ // Arguments:
83
+ //
84
+ // message - (String) A message to be passed to the other frame.
85
+ // message - (Object) An object to be serialized into a params string, using
86
+ // the jQuery.param method.
87
+ // target_url - (String) The URL of the other frame this window is
88
+ // attempting to communicate with. This must be the exact URL (including
89
+ // any query string) of the other window for this script to work in
90
+ // browsers that don't support window.postMessage.
91
+ // target - (Object) A reference to the other frame this window is
92
+ // attempting to communicate with. If omitted, defaults to `parent`.
93
+ //
94
+ // Returns:
95
+ //
96
+ // Nothing.
97
+
98
+ $[postMessage] = function( message, target_url, target ) {
99
+ if ( !target_url ) { return; }
100
+
101
+ // Serialize the message if not a string. Note that this is the only real
102
+ // jQuery dependency for this script. If removed, this script could be
103
+ // written as very basic JavaScript.
104
+ message = typeof message === 'string' ? message : $.param( message );
105
+
106
+ // Default to parent if unspecified.
107
+ target = target || parent;
108
+
109
+ if ( has_postMessage ) {
110
+ // The browser supports window.postMessage, so call it with a targetOrigin
111
+ // set appropriately, based on the target_url parameter.
112
+ target[postMessage]( message, target_url.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
113
+
114
+ } else if ( target_url ) {
115
+ // The browser does not support window.postMessage, so set the location
116
+ // of the target to target_url#message. A bit ugly, but it works! A cache
117
+ // bust parameter is added to ensure that repeat messages trigger the
118
+ // callback.
119
+ target.location = target_url.replace( /#.*$/, '' ) + '#' + (+new Date) + (cache_bust++) + '&' + message;
120
+ }
121
+ };
122
+
123
+ // Method: jQuery.receiveMessage
124
+ //
125
+ // Register a single callback for either a window.postMessage call, if
126
+ // supported, or if unsupported, for any change in the current window
127
+ // location.hash. If window.postMessage is supported and source_origin is
128
+ // specified, the source window will be checked against this for maximum
129
+ // security. If window.postMessage is unsupported, a polling loop will be
130
+ // started to watch for changes to the location.hash.
131
+ //
132
+ // Note that for simplicity's sake, only a single callback can be registered
133
+ // at one time. Passing no params will unbind this event (or stop the polling
134
+ // loop), and calling this method a second time with another callback will
135
+ // unbind the event (or stop the polling loop) first, before binding the new
136
+ // callback.
137
+ //
138
+ // Also note that if window.postMessage is available, the optional
139
+ // source_origin param will be used to test the event.origin property. From
140
+ // the MDC window.postMessage docs: This string is the concatenation of the
141
+ // protocol and "://", the host name if one exists, and ":" followed by a port
142
+ // number if a port is present and differs from the default port for the given
143
+ // protocol. Examples of typical origins are https://example.org (implying
144
+ // port 443), http://example.net (implying port 80), and http://example.com:8080.
145
+ //
146
+ // Usage:
147
+ //
148
+ // > jQuery.receiveMessage( callback [, source_origin ] [, delay ] );
149
+ //
150
+ // Arguments:
151
+ //
152
+ // callback - (Function) This callback will execute whenever a <jQuery.postMessage>
153
+ // message is received, provided the source_origin matches. If callback is
154
+ // omitted, any existing receiveMessage event bind or polling loop will be
155
+ // canceled.
156
+ // source_origin - (String) If window.postMessage is available and this value
157
+ // is not equal to the event.origin property, the callback will not be
158
+ // called.
159
+ // source_origin - (Function) If window.postMessage is available and this
160
+ // function returns false when passed the event.origin property, the
161
+ // callback will not be called.
162
+ // delay - (Number) An optional zero-or-greater delay in milliseconds at
163
+ // which the polling loop will execute (for browser that don't support
164
+ // window.postMessage). If omitted, defaults to 100.
165
+ //
166
+ // Returns:
167
+ //
168
+ // Nothing!
169
+
170
+ $.receiveMessage = p_receiveMessage = function( callback, source_origin, delay ) {
171
+ if ( has_postMessage ) {
172
+ // Since the browser supports window.postMessage, the callback will be
173
+ // bound to the actual event associated with window.postMessage.
174
+
175
+ if ( callback ) {
176
+ // Unbind an existing callback if it exists.
177
+ rm_callback && p_receiveMessage();
178
+
179
+ // Bind the callback. A reference to the callback is stored for ease of
180
+ // unbinding.
181
+ rm_callback = function(e) {
182
+ if ( ( typeof source_origin === 'string' && e.origin !== source_origin )
183
+ || ( $.isFunction( source_origin ) && source_origin( e.origin ) === FALSE ) ) {
184
+ return FALSE;
185
+ }
186
+ callback( e );
187
+ };
188
+ }
189
+
190
+ if ( window[addEventListener] ) {
191
+ window[ callback ? addEventListener : 'removeEventListener' ]( 'message', rm_callback, FALSE );
192
+ } else {
193
+ window[ callback ? 'attachEvent' : 'detachEvent' ]( 'onmessage', rm_callback );
194
+ }
195
+
196
+ } else {
197
+ // Since the browser sucks, a polling loop will be started, and the
198
+ // callback will be called whenever the location.hash changes.
199
+
200
+ interval_id && clearInterval( interval_id );
201
+ interval_id = null;
202
+
203
+ if ( callback ) {
204
+ delay = typeof source_origin === 'number'
205
+ ? source_origin
206
+ : typeof delay === 'number'
207
+ ? delay
208
+ : 100;
209
+
210
+ interval_id = setInterval(function(){
211
+ var hash = document.location.hash,
212
+ re = /^#?\d+&/;
213
+ if ( hash !== last_hash && re.test( hash ) ) {
214
+ last_hash = hash;
215
+ callback({ data: hash.replace( re, '' ) });
216
+ }
217
+ }, delay );
218
+ }
219
+ }
220
+ };
221
+
222
+ })(jQuery);
freemius/assets/js/jquery.ba-postmessage.min.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * jQuery postMessage - v0.5 - 9/11/2009
3
+ * http://benalman.com/projects/jquery-postmessage-plugin/
4
+ *
5
+ * Copyright (c) 2009 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ */
9
+ (function($){var g,d,j=1,a,b=this,f=!1,h="postMessage",e="addEventListener",c,i=b[h]&&!$.browser.opera;$[h]=function(k,l,m){if(!l){return}k=typeof k==="string"?k:$.param(k);m=m||parent;if(i){m[h](k,l.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))}else{if(l){m.location=l.replace(/#.*$/,"")+"#"+(+new Date)+(j++)+"&"+k}}};$.receiveMessage=c=function(l,m,k){if(i){if(l){a&&c();a=function(n){if((typeof m==="string"&&n.origin!==m)||($.isFunction(m)&&m(n.origin)===f)){return f}l(n)}}if(b[e]){b[l?e:"removeEventListener"]("message",a,f)}else{b[l?"attachEvent":"detachEvent"]("onmessage",a)}}else{g&&clearInterval(g);g=null;if(l){k=typeof m==="number"?m:typeof k==="number"?k:100;g=setInterval(function(){var o=document.location.hash,n=/^#?\d+&/;if(o!==d&&n.test(o)){d=o;l({data:o.replace(n,"")})}},k)}}}})(jQuery);
freemius/assets/js/nojquery.ba-postmessage.js ADDED
@@ -0,0 +1,140 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ * jQuery postMessage - v0.5 - 9/11/2009
3
+ * http://benalman.com/projects/jquery-postmessage-plugin/
4
+ *
5
+ * Copyright (c) 2009 "Cowboy" Ben Alman
6
+ * Dual licensed under the MIT and GPL licenses.
7
+ * http://benalman.com/about/license/
8
+ *
9
+ * Non-jQuery fork by Jeff Lee
10
+ *
11
+ * This fork consists of the following changes:
12
+ * 1. Basic code cleanup and restructuring, for legibility.
13
+ * 2. The `postMessage` and `receiveMessage` functions can be bound arbitrarily,
14
+ * in terms of both function names and object scope. Scope is specified by
15
+ * the the "this" context of NoJQueryPostMessageMixin();
16
+ * 3. I've removed the check for Opera 9.64, which used `$.browser`. There were
17
+ * at least three different GitHub users requesting the removal of this
18
+ * "Opera sniff" on the original project's Issues page, so I figured this
19
+ * would be a relatively safe change.
20
+ * 4. `postMessage` no longer uses `$.param` to serialize messages that are not
21
+ * strings. I actually prefer this structure anyway. `receiveMessage` does
22
+ * not implement a corresponding deserialization step, and as such it seems
23
+ * cleaner and more symmetric to leave both data serialization and
24
+ * deserialization to the client.
25
+ * 5. The use of `$.isFunction` is replaced by a functionally-identical check.
26
+ * 6. The `$:nomunge` YUI option is no longer necessary.
27
+ */
28
+
29
+ function NoJQueryPostMessageMixin(postBinding, receiveBinding) {
30
+
31
+ var setMessageCallback, unsetMessageCallback, currentMsgCallback,
32
+ intervalId, lastHash, cacheBust = 1;
33
+
34
+ if (window.postMessage) {
35
+
36
+ if (window.addEventListener) {
37
+ setMessageCallback = function(callback) {
38
+ window.addEventListener('message', callback, false);
39
+ }
40
+
41
+ unsetMessageCallback = function(callback) {
42
+ window.removeEventListener('message', callback, false);
43
+ }
44
+ } else {
45
+ setMessageCallback = function(callback) {
46
+ window.attachEvent('onmessage', callback);
47
+ }
48
+
49
+ unsetMessageCallback = function(callback) {
50
+ window.detachEvent('onmessage', callback);
51
+ }
52
+ }
53
+
54
+ this[postBinding] = function(message, targetUrl, target) {
55
+ if (!targetUrl) {
56
+ return;
57
+ }
58
+
59
+ // The browser supports window.postMessage, so call it with a targetOrigin
60
+ // set appropriately, based on the targetUrl parameter.
61
+ target.postMessage( message, targetUrl.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
62
+ }
63
+
64
+ // Since the browser supports window.postMessage, the callback will be
65
+ // bound to the actual event associated with window.postMessage.
66
+ this[receiveBinding] = function(callback, sourceOrigin, delay) {
67
+ // Unbind an existing callback if it exists.
68
+ if (currentMsgCallback) {
69
+ unsetMessageCallback(currentMsgCallback);
70
+ currentMsgCallback = null;
71
+ }
72
+
73
+ if (!callback) {
74
+ return false;
75
+ }
76
+
77
+ // Bind the callback. A reference to the callback is stored for ease of
78
+ // unbinding.
79
+ currentMsgCallback = setMessageCallback(function(e) {
80
+ switch(Object.prototype.toString.call(sourceOrigin)) {
81
+ case '[object String]':
82
+ if (sourceOrigin !== e.origin) {
83
+ return false;
84
+ }
85
+ break;
86
+ case '[object Function]':
87
+ if (sourceOrigin(e.origin)) {
88
+ return false;
89
+ }
90
+ break;
91
+ }
92
+
93
+ callback(e);
94
+ });
95
+ };
96
+
97
+ } else {
98
+
99
+ this[postBinding] = function(message, targetUrl, target) {
100
+ if (!targetUrl) {
101
+ return;
102
+ }
103
+
104
+ // The browser does not support window.postMessage, so set the location
105
+ // of the target to targetUrl#message. A bit ugly, but it works! A cache
106
+ // bust parameter is added to ensure that repeat messages trigger the
107
+ // callback.
108
+ target.location = targetUrl.replace( /#.*$/, '' ) + '#' + (+new Date) + (cacheBust++) + '&' + message;
109
+ }
110
+
111
+ // Since the browser sucks, a polling loop will be started, and the
112
+ // callback will be called whenever the location.hash changes.
113
+ this[receiveBinding] = function(callback, sourceOrigin, delay) {
114
+ if (intervalId) {
115
+ clearInterval(intervalId);
116
+ intervalId = null;
117
+ }
118
+
119
+ if (callback) {
120
+ delay = typeof sourceOrigin === 'number'
121
+ ? sourceOrigin
122
+ : typeof delay === 'number'
123
+ ? delay
124
+ : 100;
125
+
126
+ intervalId = setInterval(function(){
127
+ var hash = document.location.hash,
128
+ re = /^#?\d+&/;
129
+ if ( hash !== lastHash && re.test( hash ) ) {
130
+ lastHash = hash;
131
+ callback({ data: hash.replace( re, '' ) });
132
+ }
133
+ }, delay );
134
+ }
135
+ };
136
+
137
+ }
138
+
139
+ return this;
140
+ }
freemius/assets/js/nojquery.ba-postmessage.min.js ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * nojquery-postmessage by Jeff Lee
3
+ * a non-jQuery fork of:
4
+ *
5
+ * jQuery postMessage - v0.5 - 9/11/2009
6
+ * http://benalman.com/projects/jquery-postmessage-plugin/
7
+ *
8
+ * Copyright (c) 2009 "Cowboy" Ben Alman
9
+ * Dual licensed under the MIT and GPL licenses.
10
+ * http://benalman.com/about/license/
11
+ */
12
+ function NoJQueryPostMessageMixin(g,a){var b,h,e,d,f,c=1;if(window.postMessage){if(window.addEventListener){b=function(i){window.addEventListener("message",i,false)};h=function(i){window.removeEventListener("message",i,false)}}else{b=function(i){window.attachEvent("onmessage",i)};h=function(i){window.detachEvent("onmessage",i)}}this[g]=function(i,k,j){if(!k){return}j.postMessage(i,k.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))};this[a]=function(k,j,i){if(e){h(e);e=null}if(!k){return false}e=b(function(l){switch(Object.prototype.toString.call(j)){case"[object String]":if(j!==l.origin){return false}break;case"[object Function]":if(j(l.origin)){return false}break}k(l)})}}else{this[g]=function(i,k,j){if(!k){return}j.location=k.replace(/#.*$/,"")+"#"+(+new Date)+(c++)+"&"+i};this[a]=function(k,j,i){if(d){clearInterval(d);d=null}if(k){i=typeof j==="number"?j:typeof i==="number"?i:100;d=setInterval(function(){var m=document.location.hash,l=/^#?\d+&/;if(m!==f&&l.test(m)){f=m;k({data:m.replace(l,"")})}},i)}}}return this};
freemius/assets/js/postmessage.js ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function ($, undef) {
2
+ var global = this;
3
+
4
+ // Namespace.
5
+ global.FS = global.FS || {};
6
+
7
+ global.FS.PostMessage = function ()
8
+ {
9
+ var
10
+ _is_child = false,
11
+ _postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
12
+ _callbacks = {},
13
+ _base_url,
14
+ _parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
15
+ _parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
16
+ _init = function () {
17
+ _postman.receiveMessage(function (e) {
18
+ var data = JSON.parse(e.data);
19
+
20
+ if (_callbacks[data.type]) {
21
+ for (var i = 0; i < _callbacks[data.type].length; i++) {
22
+ // Execute type callbacks.
23
+ _callbacks[data.type][i](data.data);
24
+ }
25
+ }
26
+ }, _base_url);
27
+ };
28
+
29
+ return {
30
+ init : function (url)
31
+ {
32
+ _base_url = url;
33
+ _init();
34
+
35
+ // Automatically receive forward messages.
36
+ FS.PostMessage.receiveOnce('forward', function (data){
37
+ window.location = data.url;
38
+ });
39
+ },
40
+ init_child : function ()
41
+ {
42
+ this.init(_parent_subdomain);
43
+
44
+ _is_child = true;
45
+
46
+ // Post height of a child right after window is loaded.
47
+ $(window).bind('load', function () {
48
+ FS.PostMessage.postHeight();
49
+ });
50
+
51
+ },
52
+ postHeight : function (diff, wrapper) {
53
+ diff = diff || 0;
54
+ wrapper = wrapper || '#wrap_section';
55
+ this.post('height', {
56
+ height: diff + $(wrapper).outerHeight(true)
57
+ });
58
+ },
59
+ post : function (type, data, iframe)
60
+ {
61
+ console.debug('PostMessage.post', type);
62
+
63
+ if (iframe)
64
+ {
65
+ // Post to iframe.
66
+ _postman.postMessage(JSON.stringify({
67
+ type: type,
68
+ data: data
69
+ }), iframe.src, iframe.contentWindow);
70
+ }
71
+ else {
72
+ // Post to parent.
73
+ _postman.postMessage(JSON.stringify({
74
+ type: type,
75
+ data: data
76
+ }), _parent_url, window.parent);
77
+ }
78
+ },
79
+ receive: function (type, callback)
80
+ {
81
+ console.debug('PostMessage.receive', type);
82
+
83
+ if (undef === _callbacks[type])
84
+ _callbacks[type] = [];
85
+
86
+ _callbacks[type].push(callback);
87
+ },
88
+ receiveOnce: function (type, callback)
89
+ {
90
+ if (this.is_set(type))
91
+ return;
92
+
93
+ this.receive(type, callback);
94
+ },
95
+ // Check if any callbacks assigned to a specified message type.
96
+ is_set: function (type)
97
+ {
98
+ return (undef != _callbacks[type]);
99
+ },
100
+ parent_url: function ()
101
+ {
102
+ return _parent_url;
103
+ },
104
+ parent_subdomain: function ()
105
+ {
106
+ return _parent_subdomain;
107
+ }
108
+ };
109
+ }();
110
+ })(jQuery);
freemius/assets/scss/_colors.scss ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $menu-hover-color: #333;
2
+ $darkest-color: #000;
3
+ $fms-live-color: #71ae00;
4
+ $fms-test-color: #f7941d;
5
+ $fms-link-color: #29abe1;
6
+ $fms-link-hover-color: darken(#29abe1, 10%);
7
+ $body-bkg: #111;
8
+ $special-color: #d3135a;
9
+ $body-color: #f1f1f1;
10
+ $fms-white: #f1f1f1;
11
+ $container-bkg: #222;
12
+ $container-bkg-odd: #262626;
13
+ $container-border-color: #333;
14
+ $table-head-bkg: #333;
15
+ $table-head-color: #999;
16
+ $info-color: #999;
17
+ $error-color: #ff0000;
18
+
19
+ $fs-logo-blue-color: #29abe1;
20
+ $fs-logo-green-color: #71ae00;
21
+ $fs-logo-magenta-color: #d3135a;
22
+
23
+ $fs-notice-promotion-border-color: #00a0d2;
24
+ $fs-notice-promotion-bkg: #f2fcff;
25
+
26
+ // WordPress colors.
27
+ $page-header-bkg: #333;
28
+ $page-header-color: $fms-white;
29
+ $text-dark-color: #333;
30
+ $text-light-color: #666;
31
+ $text-lightest-color: #999;
32
+
33
+ // WP Buttons.
34
+ $button-primary-bkg: #6bc406;
35
+ $button-primary-color: $fms-white;
36
+ $button-secondary-bkg: #333;
37
+ $button-secondary-color: $fms-white;
38
+ $featured-color: #6bc406;
39
+ $wp-selected-color: #0074a3;
40
+
41
+ $wordpress_color: #01749A;
42
+ $blogger_color: #ff8100;
43
+ $wix_color: #fac102;
44
+ $shopify_color: #80d100;
45
+ $addthis_color: #fe6d4e;
46
+ $tumblr_color: #34506b;
47
+ $zepo_color: #00baf2;
48
+ $jquery_color: #000919;
49
+ $javascript_color: #00baf2;
50
+ $squarespace_color: #000;
51
+
52
+ $blog_color: #ff6600;
53
+ $facebook_color: #3b5998;
54
+ $twitter_color: #4099ff;
55
+ $linkedin_color: #4875b4;
56
+ $youtube_color: #ff3333;
57
+ $gplus_color: #c63d2d;
58
+
freemius/assets/scss/_functions.scss ADDED
File without changes
freemius/assets/scss/_load.scss ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ @import 'mixins';
2
+ @import "vars";
3
+ @import "functions";
4
+ @import "colors";
freemius/assets/scss/_mixins.scss ADDED
@@ -0,0 +1,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // ---- CSS3 SASS MIXINS ----
2
+ // https://github.com/madr/css3-sass-mixins
3
+ //
4
+ // Copyright (C) 2011 by Anders Ytterström
5
+ //
6
+ // Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ // of this software and associated documentation files (the "Software"), to deal
8
+ // in the Software without restriction, including without limitation the rights
9
+ // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ // copies of the Software, and to permit persons to whom the Software is
11
+ // furnished to do so, subject to the following conditions:
12
+ //
13
+ // The above copyright notice and this permission notice shall be included in
14
+ // all copies or substantial portions of the Software.
15
+ //
16
+ // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
+ // THE SOFTWARE.
23
+ //
24
+
25
+ // ---- LEGACY IE SUPPORT USING FILTERS ----
26
+ // Should IE filters be used or not?
27
+ // PROS: gradients, drop shadows etc will be handled by css.
28
+ // CONS: will harm the site performance badly,
29
+ // especially on sites with heavy rendering and scripting.
30
+ $useIEFilters: 0;
31
+ // might be 0 or 1. disabled by default.
32
+ // ---- /LEGACY IE SUPPORT USING FILTERS ----
33
+
34
+
35
+ @mixin background-size ($value) {
36
+ -webkit-background-size: $value;
37
+ background-size: $value;
38
+ }
39
+
40
+ @mixin border-image ($path, $offsets, $repeats) {
41
+ -moz-border-image: $path $offsets $repeats;
42
+ -o-border-image: $path $offsets $repeats;
43
+ -webkit-border-image: $path $offsets $repeats;
44
+ border-image: $path $offsets $repeats;
45
+ }
46
+
47
+ @mixin border-radius ($values...) {
48
+ -moz-border-radius: $values;
49
+ -webkit-border-radius: $values;
50
+ border-radius: $values;
51
+ /*-moz-background-clip: padding;
52
+ -webkit-background-clip: padding-box;
53
+ background-clip: padding-box;*/
54
+ }
55
+
56
+ @mixin box-shadow ($values...) {
57
+ -moz-box-shadow: $values;
58
+ -webkit-box-shadow: $values;
59
+ box-shadow: $values;
60
+ }
61
+
62
+ //@mixin box-shadow ($x, $y, $offset, $hex, $ie: $useIEFilters, $inset: null, $spread:null) {
63
+ // -moz-box-shadow: $x $y $offset $spread $hex $inset;
64
+ // -webkit-box-shadow: $x $y $offset $spread $hex $inset;
65
+ // box-shadow: $x $y $offset $spread $hex $inset;
66
+ //
67
+ // @if $ie == 1 {
68
+ // $iecolor: '#' + red($hex) + green($hex) + blue($hex);
69
+ // filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
70
+ // -ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
71
+ // }
72
+ //}
73
+
74
+ @mixin box-sizing($value) {
75
+ -moz-box-sizing: $value;
76
+ -webkit-box-sizing: $value;
77
+ box-sizing: $value;
78
+ }
79
+
80
+ // requires sass 3.2
81
+ //@mixin keyframes {
82
+ // @-moz-keyframes { @content; }
83
+ // @-ms-keyframes { @content; }
84
+ // @-o-keyframes { @content; }
85
+ // @-webkit-keyframes { @content; }
86
+ // @keyframes { @content; }
87
+ //}
88
+
89
+ @mixin linear-gradient($from, $to, $ie: $useIEFilters) {
90
+ @if $ie != 1 { background-color: $to; }
91
+
92
+ background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to));
93
+ background-image: -webkit-linear-gradient(top, $from, $to);
94
+ background-image: -moz-linear-gradient(top, $from, $to);
95
+ background-image: -ms-linear-gradient(top, $from, $to);
96
+ background-image: -o-linear-gradient(top, $from, $to);
97
+ background-image: linear-gradient(top, bottom, $from, $to);
98
+
99
+ @if $ie == 1 {
100
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
101
+ }
102
+ }
103
+
104
+ @mixin horizontal-gradient($startColor: #555, $endColor: #333, $ie: $useIEFilters) {
105
+ @if $ie != 1 { background-color: $endColor; }
106
+
107
+ background-color: $endColor;
108
+ background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
109
+ background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
110
+ background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
111
+ background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
112
+ background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
113
+ background-repeat: repeat-x;
114
+ @if $ie == 1 {
115
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1);
116
+ }
117
+ }
118
+
119
+ @mixin radial-gradient($from, $to, $ie: $useIEFilters) {
120
+ @if $ie != 1 { background-color: $to; }
121
+
122
+ background: -moz-radial-gradient(center, circle cover, $from 0%, $to 100%);
123
+ background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, $from), color-stop(100%, $to));
124
+ background: -webkit-radial-gradient(center, circle cover, $from 0%, $to 100%);
125
+ background: -o-radial-gradient(center, circle cover, $from 0%, $to 100%);
126
+ background: -ms-radial-gradient(center, circle cover, $from 0%, $to 100%);
127
+ background: radial-gradient(center, circle cover, $from 0%, $to 100%);
128
+ background-color: $from;
129
+
130
+ @if $ie == 1 {
131
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}', GradientType=1); /* IE6-9 fallback on horizontal gradient */
132
+ }
133
+ }
134
+
135
+ /*@mixin rgba-bg ($hex, $alpha, $ie: $useIEFilters) {
136
+ @if $ie == 1 {
137
+ background-color: none;
138
+ $hexopac: ie-hex-str(rgba($hex, $alpha));
139
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}}');
140
+ -ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}'));
141
+ }
142
+ @else {
143
+ background-color: $hex;
144
+ background-color: rgba($hex, $alpha);
145
+ }
146
+ }*/
147
+
148
+ @mixin perspective($perspective) {
149
+ -moz-perspective: $perspective;
150
+ -ms-perspective: $perspective;
151
+ -webkit-perspective: $perspective;
152
+ perspective: $perspective;
153
+ -moz-transform-style: preserve-3d;
154
+ -ms-transform-style: preserve-3d;
155
+ -webkit-transform-style: preserve-3d;
156
+ transform-style: preserve-3d;
157
+ }
158
+
159
+ @mixin transform ($transforms) {
160
+ -moz-transform: $transforms;
161
+ -o-transform: $transforms;
162
+ -ms-transform: $transforms;
163
+ -webkit-transform: $transforms;
164
+ transform: $transforms;
165
+ }
166
+
167
+ @mixin matrix ($a, $b, $c, $d, $e, $f) {
168
+ -moz-transform: matrix($a, $b, $c, $d, #{$e}px, #{$f}px);
169
+ -o-transform: matrix($a, $b, $c, $d, $e, $f);
170
+ -ms-transform: matrix($a, $b, $c, $d, $e, $f);
171
+ -webkit-transform: matrix($a, $b, $c, $d, $e, $f);
172
+ transform: matrix($a, $b, $c, $d, $e, $f);
173
+ }
174
+
175
+ @mixin rotate ($deg) {
176
+ @include transform(rotate(#{$deg}deg));
177
+ }
178
+
179
+ @mixin scale ($size) {
180
+ @include transform(scale(#{$size}));
181
+ }
182
+
183
+ @mixin translate ($x, $y) {
184
+ @include transform(translate($x, $y));
185
+ }
186
+
187
+ @mixin transition ($value...) {
188
+ -moz-transition: $value;
189
+ -o-transition: $value;
190
+ -ms-transition: $value;
191
+ -webkit-transition: $value;
192
+ transition: $value;
193
+ }
194
+
195
+ // ==== /CSS3 SASS MIXINS ====
196
+
197
+ @mixin opacity($opacity) {
198
+ opacity: $opacity;
199
+ $opacity-ie: $opacity * 100;
200
+ filter: alpha(opacity=$opacity-ie); //IE8
201
+ }
202
+
203
+ @mixin sprite($img, $width, $height: $width, $display: block)
204
+ {
205
+ display: $display;
206
+ background-image: url('#{$img}');
207
+
208
+ @include size($width, $height);
209
+ }
210
+
211
+ @mixin size($width, $height: $width)
212
+ {
213
+ width: $width;
214
+ height: $height;
215
+ }
216
+
217
+ @mixin clearfix
218
+ {
219
+ &:after {
220
+ content: "";
221
+ display: table;
222
+ clear: both;
223
+ }
224
+ }
freemius/assets/scss/_start.scss ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ @import "vars";
2
+ @import "colors";
3
+ @import "mixins";
4
+ @import "functions";
freemius/assets/scss/_vars.scss ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ $is_production: true;
2
+
3
+ $img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
4
+
5
+ $layout_width: 960px;
freemius/assets/scss/admin/account.scss ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #fs_account
2
+ {
3
+ .postbox,
4
+ .widefat
5
+ {
6
+ max-width: 700px;
7
+ }
8
+
9
+ h3
10
+ {
11
+ font-size: 1.3em;
12
+ padding: 12px 15px;
13
+ margin: 0 0 12px 0;
14
+ line-height: 1.4;
15
+ border-bottom: 1px solid #F1F1F1;
16
+ }
17
+
18
+ i.dashicons
19
+ {
20
+ font-size: 1.2em;
21
+ height: 1.2em;
22
+ width: 1.2em;
23
+ }
24
+
25
+ .button
26
+ {
27
+ i.dashicons
28
+ {
29
+ vertical-align: middle;
30
+ }
31
+ }
32
+
33
+ .fs-header-actions
34
+ {
35
+ position: absolute;
36
+ top: 17px;
37
+ right: 15px;
38
+ font-size: 0.9em;
39
+
40
+ ul
41
+ {
42
+ margin: 0;
43
+ }
44
+
45
+ li
46
+ {
47
+ form
48
+ {
49
+ display: inline-block;
50
+ }
51
+
52
+ float: left;
53
+ a
54
+ {
55
+ text-decoration: none;
56
+ }
57
+ }
58
+ }
59
+ }
60
+
61
+ .rtl #fs_account .fs-header-actions
62
+ {
63
+ left: 15px;
64
+ right: auto;
65
+ }
66
+
67
+ .fs-key-value-table
68
+ {
69
+ width: 100%;
70
+
71
+ form
72
+ {
73
+ display: inline-block;
74
+ }
75
+
76
+ tr
77
+ {
78
+ td:first-child
79
+ {
80
+ nobr
81
+ {
82
+ font-weight: bold;
83
+ }
84
+
85
+ text-align: right;
86
+
87
+ form
88
+ {
89
+ display: block;
90
+ }
91
+ }
92
+
93
+ td.fs-right
94
+ {
95
+ text-align: right;
96
+ }
97
+
98
+ &.fs-odd
99
+ {
100
+ background: #ebebeb;
101
+ }
102
+ }
103
+
104
+ td, th
105
+ {
106
+ padding: 10px;
107
+ }
108
+
109
+ var, code
110
+ {
111
+ color: #0073AA;
112
+ font-size: 16px;
113
+ background: none;
114
+ }
115
+ }
116
+
117
+ label.fs-tag
118
+ {
119
+ background: #ffba00;
120
+ color: #fff;
121
+ display: inline-block;
122
+ border-radius: 3px;
123
+ padding: 5px;
124
+ font-size: 11px;
125
+ line-height: 11px;
126
+ vertical-align: baseline;
127
+
128
+ &.fs-warn
129
+ {
130
+ background: #ffba00;
131
+ }
132
+ &.fs-success
133
+ {
134
+ background: #46b450;
135
+ }
136
+ &.fs-error
137
+ {
138
+ background: #dc3232;
139
+ }
140
+ }
141
+
142
+ #fs_addons
143
+ {
144
+ h3
145
+ {
146
+ border: none;
147
+ margin-bottom: 0;
148
+ padding: 4px 5px;
149
+ }
150
+
151
+ td
152
+ {
153
+ vertical-align: middle;
154
+ }
155
+
156
+ td:first-child,
157
+ th:first-child
158
+ {
159
+ text-align: left;
160
+ font-weight: bold;
161
+ }
162
+ td:last-child,
163
+ th:last-child
164
+ {
165
+ text-align: right;
166
+ }
167
+ th
168
+ {
169
+ font-weight: bold;
170
+ }
171
+ }
freemius/assets/scss/admin/add-ons.scss ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ #fs_addons
4
+ {
5
+ .fs-cards-list
6
+ {
7
+ list-style: none;
8
+
9
+ .fs-card
10
+ {
11
+ float: left;
12
+ // height: 185px; // With reviews/ratings
13
+ height: 152px;
14
+ width: 310px;
15
+ padding: 0;
16
+ margin: 0 0 30px 30px;
17
+ font-size: 14px;
18
+ list-style: none;
19
+ border: 1px solid #ddd;
20
+ cursor: pointer;
21
+ position: relative;
22
+
23
+ .fs-overlay
24
+ {
25
+ position: absolute;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ top: 0;
30
+ z-index: 9;
31
+ }
32
+
33
+ .fs-inner
34
+ {
35
+ background-color: #fff;
36
+ overflow: hidden;
37
+ height: 100%;
38
+ position: relative;
39
+
40
+ ul
41
+ {
42
+ @include transition(all, 0.15s);
43
+ left: 0;
44
+ right: 0;
45
+ top: 0;
46
+ position: absolute;
47
+
48
+ }
49
+
50
+ li
51
+ {
52
+ list-style: none;
53
+ line-height: 18px;
54
+ padding: 0 15px;
55
+ width: 100%;
56
+ display: block;
57
+ @include box-sizing(border-box);
58
+ }
59
+
60
+ .fs-card-banner
61
+ {
62
+ padding: 0;
63
+ margin: 0;
64
+ line-height: 0;
65
+ display: block;
66
+ height: 100px;
67
+ background-repeat: repeat-x;
68
+ background-size: 100% 100%;
69
+ @include transition(all, 0.15s);
70
+ }
71
+
72
+ .fs-title
73
+ {
74
+ margin: 10px 0 0 0;
75
+ height: 18px;
76
+ overflow: hidden;
77
+ color: #000;
78
+ white-space: nowrap;
79
+ text-overflow: ellipsis;
80
+ font-weight: bold;
81
+ }
82
+
83
+ .fs-offer
84
+ {
85
+ font-size: 0.9em;
86
+ }
87
+
88
+ .fs-description
89
+ {
90
+ background-color: #f9f9f9;
91
+ padding: 10px 15px 100px 15px;
92
+ border-top: 1px solid #eee;
93
+ margin: 0 0 10px 0;
94
+ color: #777;
95
+ }
96
+ }
97
+
98
+ @media screen and (min-width: 960px) {
99
+ &:hover
100
+ {
101
+ .fs-overlay
102
+ {
103
+ border: 2px solid $fms-link-color;
104
+ margin-left: -1px;
105
+ margin-top: -1px;
106
+ }
107
+
108
+ .fs-inner
109
+ {
110
+ ul
111
+ {
112
+ top: -100px;
113
+ }
114
+
115
+ .fs-card-banner
116
+ {
117
+ // background-position: 50% -100px;
118
+ }
119
+
120
+ .fs-title,
121
+ .fs-offer
122
+ {
123
+ color: $fms-link-color;
124
+ }
125
+ }
126
+ }
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ #TB_window
133
+ {
134
+ &, iframe
135
+ {
136
+ width: 772px !important;
137
+ }
138
+ }
139
+
140
+ #plugin-information
141
+ {
142
+ #section-description
143
+ {
144
+ h2, h3, p, b, i, blockquote, li, ul, ol
145
+ {
146
+ clear: none;
147
+ }
148
+
149
+ .fs-selling-points
150
+ {
151
+ padding-bottom: 10px;
152
+ border-bottom: 1px solid #ddd;
153
+
154
+ ul
155
+ {
156
+ margin: 0;
157
+
158
+ li
159
+ {
160
+ padding: 0;
161
+ list-style: none outside none;
162
+
163
+ i.dashicons
164
+ {
165
+ color: $fs-logo-green-color;
166
+ font-size: 3em;
167
+ vertical-align: middle;
168
+ line-height: 30px;
169
+ float: left;
170
+ margin: 0 0 0 -15px;
171
+ }
172
+
173
+ h3
174
+ {
175
+ margin: 1em 30px !important;
176
+ }
177
+ }
178
+ }
179
+ }
180
+
181
+ .fs-screenshots
182
+ {
183
+ @include clearfix();
184
+ ul
185
+ {
186
+ list-style: none;
187
+ margin: 0;
188
+
189
+ li
190
+ {
191
+ width: 225px;
192
+ height: 225px;
193
+ float: left;
194
+ margin-bottom: 20px;
195
+ @include box-sizing(content-box);
196
+
197
+ a
198
+ {
199
+ display: block;
200
+ width: 100%;
201
+ height: 100%;
202
+ border: 1px solid;
203
+ @include box-shadow(1px 1px 1px rgba(0,0,0,0.2));
204
+ background-size: cover;
205
+ }
206
+
207
+ &.odd
208
+ {
209
+ margin-right: 20px;
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+
216
+ .plugin-information-pricing
217
+ {
218
+ background: #FFFEEC;
219
+ margin: -16px;
220
+ padding: 20px;
221
+ border-bottom: 1px solid #DDD;
222
+
223
+ h3
224
+ {
225
+ margin-top: 0;
226
+ }
227
+
228
+ .button
229
+ {
230
+ width: 100%;
231
+ text-align: center;
232
+ font-weight: bold;
233
+ text-transform: uppercase;
234
+ font-size: 1.1em;
235
+ }
236
+
237
+ label
238
+ {
239
+ white-space: nowrap;
240
+ }
241
+
242
+ ul.fs-trial-terms
243
+ {
244
+ font-size: 0.9em;
245
+
246
+ i {
247
+ float: left;
248
+ margin: 0 0 0 -15px;
249
+ }
250
+
251
+ li {
252
+ margin: 10px 0 0 0;
253
+ }
254
+ }
255
+ }
256
+
257
+ #section-features
258
+ {
259
+ .fs-features
260
+ {
261
+ margin: -20px -26px;
262
+ }
263
+
264
+ table {
265
+ width: 100%;
266
+ border-spacing: 0;
267
+ border-collapse: separate;
268
+
269
+ thead {
270
+ th
271
+ {
272
+ padding: 10px 0;
273
+ }
274
+
275
+ .fs-price
276
+ {
277
+ color: $fs-logo-green-color;
278
+ font-weight: normal;
279
+ display: block;
280
+ text-align: center;
281
+ }
282
+ }
283
+
284
+ tbody
285
+ {
286
+ td
287
+ {
288
+ border-top: 1px solid #ccc;
289
+ padding: 10px 0;
290
+ text-align: center;
291
+ width: 100px;
292
+ color: $fs-logo-green-color;
293
+
294
+ &:first-child
295
+ {
296
+ text-align: left;
297
+ width: auto;
298
+ color: inherit;
299
+ padding-left: 26px;
300
+ }
301
+ }
302
+ tr.fs-odd
303
+ {
304
+ td
305
+ {
306
+ background: #fefefe;
307
+ }
308
+ }
309
+ }
310
+ }
311
+
312
+ .dashicons-yes
313
+ {
314
+ width: 30px;
315
+ height: 30px;
316
+ font-size: 30px;
317
+ }
318
+ }
319
+ }
320
+
321
+ @media screen and (max-width: 961px)
322
+ {
323
+ #fs_addons
324
+ {
325
+ .fs-cards-list
326
+ {
327
+ .fs-card
328
+ {
329
+ height: 265px;
330
+ }
331
+ }
332
+ }
333
+ }
freemius/assets/scss/admin/common.scss ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ .fs-notice
4
+ {
5
+ position: relative;
6
+
7
+ &.fs-has-title
8
+ {
9
+ margin-bottom: 30px !important;
10
+ }
11
+
12
+ &.success
13
+ {
14
+ color: green;
15
+ // font-weight: normal;
16
+ }
17
+
18
+ &.promotion
19
+ {
20
+ border-color: $fs-notice-promotion-border-color !important;
21
+ background-color: $fs-notice-promotion-bkg !important;
22
+ }
23
+
24
+ .fs-notice-body
25
+ {
26
+ margin: .5em 0;
27
+ padding: 2px;
28
+ }
29
+
30
+ .fs-close
31
+ {
32
+ // position: absolute;
33
+ // top: 2px;
34
+ // bottom: 2px;
35
+ // right: 2px;
36
+ // min-width: 100px;
37
+ // text-align: center;
38
+ // padding-right: 2px;
39
+ cursor: pointer;
40
+ color: #aaa;
41
+ float: right;
42
+
43
+ &:hover
44
+ {
45
+ color: #666;
46
+ // background: #A9A9A9;
47
+ }
48
+
49
+ > *
50
+ {
51
+ margin-top: 7px;
52
+ display: inline-block;
53
+ }
54
+ }
55
+
56
+ label.fs-plugin-title
57
+ {
58
+ background: rgba(0, 0, 0, 0.3);
59
+ color: #fff;
60
+ padding: 2px 10px;
61
+ position: absolute;
62
+ bottom: -22px;
63
+ top: auto;
64
+ right: auto;
65
+ @include border-radius(0 0 3px 3px);
66
+ left: 10px;
67
+ font-size: 12px;
68
+ font-weight: bold;
69
+ cursor: auto;
70
+ }
71
+ }
72
+
73
+ .rtl .fs-notice
74
+ {
75
+ .fs-close
76
+ {
77
+ // left: 2px;
78
+ // right: auto;
79
+ // padding-right: 0;
80
+ // padding-left: 2px;
81
+ float: left;
82
+ }
83
+ }
84
+
85
+ .fs-secure-notice
86
+ {
87
+ position: fixed;
88
+ top: 32px;
89
+ left: 160px;
90
+ right: 0;
91
+ background: rgb(235, 253, 235);
92
+ padding: 10px 20px;
93
+ color: green;
94
+ z-index: 9999;
95
+ box-shadow: 0px 2px 2px rgba(6, 113, 6, 0.3);
96
+ @include opacity(0.95);
97
+
98
+ &:hover
99
+ {
100
+ @include opacity(1);
101
+ }
102
+ }
103
+
104
+ @media screen and (max-width: 960px) {
105
+ .fs-secure-notice
106
+ {
107
+ left: 36px;
108
+ }
109
+ }
110
+
111
+ @media screen and (max-width: 782px) {
112
+ .fs-secure-notice
113
+ {
114
+ left: 0;
115
+ top: 46px;
116
+ text-align: center;
117
+ }
118
+ }
119
+
120
+ span.fs-submenu-item.fs-sub:before
121
+ {
122
+ // Add small arrow.
123
+ content: '\21B3';
124
+ padding: 0 5px;
125
+ }
126
+
127
+ .rtl
128
+ {
129
+ span.fs-submenu-item.fs-sub:before
130
+ {
131
+ // Add small RTL arrow.
132
+ content: '\21B2';
133
+ }
134
+ }
freemius/assets/scss/admin/connect.scss ADDED
@@ -0,0 +1,421 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ $form_width: 480px;
4
+
5
+ #fs_connect
6
+ {
7
+ width: $form_width;
8
+ @include box-shadow(0px 1px 2px rgba(0, 0, 0, 0.3));
9
+ margin: 20px 0;
10
+
11
+ @media screen and (max-width: ($form_width - 1)) {
12
+ @include box-shadow(none);
13
+ width: auto;
14
+ margin: 0 0 0 -10px;
15
+ }
16
+
17
+ .fs-content
18
+ {
19
+ background: #fff;
20
+ padding: 15px 20px;
21
+
22
+ p
23
+ {
24
+ margin: 0;
25
+ padding: 0;
26
+ font-size: 1.2em;
27
+ }
28
+ }
29
+
30
+ .fs-actions
31
+ {
32
+ padding: 10px 20px;
33
+ background: #C0C7CA;
34
+
35
+ .button
36
+ {
37
+ padding: 0 10px 1px;
38
+ line-height: 35px;
39
+ height: 37px;
40
+ font-size: 16px;
41
+ margin-bottom: 0;
42
+
43
+ .dashicons
44
+ {
45
+ font-size: 37px;
46
+ margin-left: -8px;
47
+ margin-right: 12px;
48
+ }
49
+
50
+ &.button-primary
51
+ {
52
+ padding-right: 15px;
53
+ padding-left: 15px;
54
+
55
+ &:after
56
+ {
57
+ content: ' \279C';
58
+ }
59
+
60
+ &.fs-loading
61
+ {
62
+ &:after
63
+ {
64
+ content: '';
65
+ }
66
+ }
67
+ }
68
+
69
+ &.button-secondary
70
+ {
71
+ float: right;
72
+ }
73
+ }
74
+
75
+ // .fs-skip
76
+ // {
77
+ // line-height: 38px;
78
+ // vertical-align: middle;
79
+ // text-decoration: none;
80
+ // margin-left: 10px;
81
+ // }
82
+ }
83
+
84
+ &.fs-anonymous-disabled
85
+ {
86
+ .fs-actions
87
+ {
88
+ .button.button-primary
89
+ {
90
+ width: 100%;
91
+ }
92
+ }
93
+ }
94
+
95
+ .fs-permissions
96
+ {
97
+ padding: 10px 20px;
98
+ background: #FEFEFE;
99
+ // background: #F1F1F1;
100
+ @include transition(background 0.5s ease);
101
+
102
+ .fs-trigger
103
+ {
104
+ font-size: 0.9em;
105
+ text-decoration: none;
106
+ text-align: center;
107
+ display: block;
108
+ }
109
+
110
+ ul
111
+ {
112
+ height: 0;
113
+ overflow: hidden;
114
+ margin: 0;
115
+
116
+ li
117
+ {
118
+ margin-bottom: 12px;
119
+
120
+ &:last-child
121
+ {
122
+ margin-bottom: 0;
123
+ }
124
+
125
+ i.dashicons
126
+ {
127
+ float: left;
128
+ font-size: 40px;
129
+ width: 40px;
130
+ height: 40px;
131
+ }
132
+
133
+ div
134
+ {
135
+ margin-left: 55px;
136
+
137
+ span
138
+ {
139
+ font-weight: bold;
140
+ text-transform: uppercase;
141
+ color: #23282d;
142
+ }
143
+
144
+ p
145
+ {
146
+ margin: 2px 0 0 0;
147
+ }
148
+ }
149
+ }
150
+ }
151
+
152
+ &.fs-open
153
+ {
154
+ background: #fff;
155
+
156
+ ul
157
+ {
158
+ height: auto;
159
+ margin: 20px 20px 10px 20px;
160
+ }
161
+ }
162
+
163
+ @media screen and (max-width: ($form_width - 1)) {
164
+ background: #fff;
165
+
166
+ .fs-trigger
167
+ {
168
+ display: none;
169
+ }
170
+
171
+ ul
172
+ {
173
+ height: auto;
174
+ margin: 20px;
175
+ }
176
+ }
177
+ }
178
+
179
+ $icon_size: 80px;
180
+ $wp_logo_padding: $icon_size / 10;
181
+ $icons_top: 10px;
182
+
183
+ .fs-visual
184
+ {
185
+ padding: 12px;
186
+ line-height: 0;
187
+ background: #fafafa;
188
+ height: $icon_size;
189
+ position: relative;
190
+
191
+ .fs-site-icon
192
+ {
193
+ position: absolute;
194
+ left: 20px;
195
+ top: $icons_top;
196
+ }
197
+
198
+ .fs-connect-logo
199
+ {
200
+ position: absolute;
201
+ right: 20px;
202
+ top: $icons_top;
203
+ }
204
+
205
+ .fs-plugin-icon
206
+ {
207
+ position: absolute;
208
+ top: $icons_top;
209
+ left: 50%;
210
+ margin-left: - ($icon_size / 2);
211
+ }
212
+
213
+ .fs-plugin-icon,
214
+ .fs-site-icon,
215
+ img,
216
+ object
217
+ {
218
+ width: $icon_size;
219
+ height: $icon_size;
220
+ }
221
+
222
+ .dashicons-wordpress
223
+ {
224
+ font-size: $icon_size - ($wp_logo_padding * 2);
225
+ background: $wordpress_color;
226
+ color: #fff;
227
+ width: $icon_size - ($wp_logo_padding * 2);
228
+ height: $icon_size - ($wp_logo_padding * 2);
229
+ padding: $wp_logo_padding;
230
+ }
231
+
232
+ .dashicons-plus
233
+ {
234
+ position: absolute;
235
+ top: 50%;
236
+ font-size: 30px;
237
+ margin-top: -10px;
238
+ color: #bbb;
239
+
240
+ &.fs-first
241
+ {
242
+ left: 28%;
243
+ }
244
+ &.fs-second
245
+ {
246
+ left: 65%;
247
+ }
248
+ }
249
+
250
+ .fs-plugin-icon,
251
+ .fs-connect-logo,
252
+ .fs-site-icon
253
+ {
254
+ border: 1px solid #ccc;
255
+ padding: 1px;
256
+ background: #fff;
257
+ }
258
+ }
259
+
260
+ .fs-terms
261
+ {
262
+ text-align: center;
263
+ font-size: 0.85em;
264
+ padding: 5px;
265
+ background: rgba(0, 0, 0, 0.05);
266
+
267
+ &, a
268
+ {
269
+ color: #999;
270
+ }
271
+
272
+ a
273
+ {
274
+ text-decoration: none;
275
+ }
276
+ }
277
+ }
278
+
279
+ .rtl
280
+ {
281
+ #fs_connect
282
+ {
283
+ .fs-actions
284
+ {
285
+ padding: 10px 20px;
286
+ background: #C0C7CA;
287
+
288
+ .button
289
+ {
290
+ .dashicons
291
+ {
292
+ font-size: 37px;
293
+ margin-left: -8px;
294
+ margin-right: 12px;
295
+ }
296
+
297
+ &.button-primary
298
+ {
299
+ &:after
300
+ {
301
+ content: ' \000bb';
302
+ }
303
+
304
+ &.fs-loading
305
+ {
306
+ &:after
307
+ {
308
+ content: '';
309
+ }
310
+ }
311
+ }
312
+
313
+ &.button-secondary
314
+ {
315
+ float: left;
316
+ }
317
+ }
318
+ }
319
+
320
+ .fs-permissions
321
+ {
322
+ ul
323
+ {
324
+ li
325
+ {
326
+ div
327
+ {
328
+ margin-right: 55px;
329
+ margin-left: 0;
330
+ }
331
+
332
+ i.dashicons
333
+ {
334
+ float: right;
335
+ }
336
+
337
+ }
338
+ }
339
+ }
340
+
341
+ .fs-visual
342
+ {
343
+ .fs-site-icon
344
+ {
345
+ right: 20px;
346
+ left: auto;
347
+ }
348
+
349
+ .fs-connect-logo
350
+ {
351
+ right: auto;
352
+ left: 20px;
353
+ }
354
+ }
355
+ }
356
+ }
357
+
358
+ .wp-pointer-content
359
+ {
360
+ #fs_connect
361
+ {
362
+ margin: 0;
363
+ @include box-shadow(none);
364
+ }
365
+ }
366
+
367
+ .fs-opt-in-pointer
368
+ {
369
+ .wp-pointer-content
370
+ {
371
+ padding: 0;
372
+ }
373
+
374
+ &.wp-pointer-top
375
+ {
376
+ .wp-pointer-arrow
377
+ {
378
+ border-bottom-color: #dfdfdf;
379
+ }
380
+ .wp-pointer-arrow-inner
381
+ {
382
+ border-bottom-color: #fafafa;
383
+ }
384
+ }
385
+
386
+ &.wp-pointer-bottom
387
+ {
388
+ .wp-pointer-arrow
389
+ {
390
+ border-top-color: #dfdfdf;
391
+ }
392
+ .wp-pointer-arrow-inner
393
+ {
394
+ border-top-color: #fafafa;
395
+ }
396
+ }
397
+
398
+ &.wp-pointer-left
399
+ {
400
+ .wp-pointer-arrow
401
+ {
402
+ border-right-color: #dfdfdf;
403
+ }
404
+ .wp-pointer-arrow-inner
405
+ {
406
+ border-right-color: #fafafa;
407
+ }
408
+ }
409
+
410
+ &.wp-pointer-right
411
+ {
412
+ .wp-pointer-arrow
413
+ {
414
+ border-left-color: #dfdfdf;
415
+ }
416
+ .wp-pointer-arrow-inner
417
+ {
418
+ border-left-color: #fafafa;
419
+ }
420
+ }
421
+ }
freemius/assets/scss/admin/deactivation-feedback.scss ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-modal {
2
+ position: fixed;
3
+ overflow: auto;
4
+ height: 100%;
5
+ width: 100%;
6
+ top: 0;
7
+ z-index: 100000;
8
+ display: none;
9
+ background: rgba(0, 0, 0, 0.6);
10
+
11
+ .fs-modal-dialog {
12
+ background: transparent;
13
+ position: absolute;
14
+ left: 50%;
15
+ margin-left: -298px;
16
+ padding-bottom: 30px;
17
+ top: -100%;
18
+ z-index: 100001;
19
+ width: 596px;
20
+
21
+ @media (max-width: 650px) {
22
+ margin-left: -50%;
23
+ box-sizing: border-box;
24
+ padding-left: 10px;
25
+ padding-right: 10px;
26
+ width: 100%;
27
+
28
+ .fs-modal-panel > h3 > strong {
29
+ font-size: 1.3em;
30
+ }
31
+
32
+ li.reason {
33
+ margin-bottom: 10px;
34
+
35
+ .reason-input {
36
+ margin-left: 29px;
37
+ }
38
+
39
+ label {
40
+ display: table;
41
+
42
+ > span {
43
+ display: table-cell;
44
+ font-size: 1.3em;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ }
50
+
51
+ &.active {
52
+ display: block;
53
+
54
+ &:before {
55
+ display: block;
56
+ }
57
+
58
+ .fs-modal-dialog {
59
+ top: 10%;
60
+ }
61
+ }
62
+
63
+ .fs-modal-body,
64
+ .fs-modal-footer {
65
+ border: 0;
66
+ background: #fefefe;
67
+ padding: 20px;
68
+ }
69
+
70
+ .fs-modal-body {
71
+ border-bottom: 0;
72
+
73
+ h2 {
74
+ font-size: 20px;
75
+ }
76
+
77
+ > div {
78
+ margin-top: 10px;
79
+
80
+ h2 {
81
+ font-weight: bold;
82
+ font-size: 20px;
83
+ margin-top: 0;
84
+ }
85
+ }
86
+ }
87
+
88
+ .fs-modal-footer {
89
+ border-top: #eeeeee solid 1px;
90
+ text-align: right;
91
+
92
+ > .button {
93
+ margin: 0 7px;
94
+
95
+ &:first-child {
96
+ margin: 0;
97
+ }
98
+ }
99
+ }
100
+
101
+ .fs-modal-panel:not(.active) {
102
+ display: none;
103
+ }
104
+
105
+ .reason-input {
106
+ margin: 3px 0 3px 22px;
107
+
108
+ input, textarea {
109
+ width: 100%;
110
+ }
111
+ }
112
+ }
113
+
114
+ body.has-fs-modal {
115
+ overflow: hidden;
116
+ }
117
+
118
+ #the-list .deactivate > .fs-slug {
119
+ display: none;
120
+ }
freemius/assets/scss/admin/debug.scss ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ .switch
4
+ {
5
+ position: relative;
6
+ display: inline-block;
7
+ font-size: 1.6em;
8
+ font-weight: bold;
9
+ color: #ccc;
10
+ text-shadow: 0px 1px 1px rgba(255, 255, 255, 0.8);
11
+ height: 18px;
12
+ padding: 6px 6px 5px 6px;
13
+ border: 1px solid #ccc;
14
+ border: 1px solid rgba(0, 0, 0, 0.2);
15
+ border-radius: 4px;
16
+ background: #ececec;
17
+ box-shadow: 0px 0px 4px rgba(0, 0, 0, 0.1), inset 0px 1px 3px 0px rgba(0, 0, 0, 0.1);
18
+ cursor: pointer;
19
+
20
+ span
21
+ {
22
+ display: inline-block; width: 35px;
23
+ text-transform: uppercase;
24
+
25
+ &.on
26
+ {
27
+ color: $button-primary-bkg;
28
+ }
29
+ }
30
+
31
+ .toggle
32
+ {
33
+ position: absolute;
34
+ top: 1px;
35
+ width: 37px;
36
+ height: 25px;
37
+ border: 1px solid #ccc;
38
+ border: 1px solid rgba(0, 0, 0, 0.3);
39
+ border-radius: 4px;
40
+ background: #fff;
41
+ background: -moz-linear-gradient(top, #ececec 0%, #fff 100%);
42
+ background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #ececec), color-stop(100%, #fff));
43
+ background: -webkit-linear-gradient(top, #ececec 0%, #fff 100%);
44
+ background: -o-linear-gradient(top, #ececec 0%, #fff 100%);
45
+ background: -ms-linear-gradient(top, #ececec 0%, #fff 100%);
46
+ background: linear-gradient(top, #ececec 0%, #fff 100%);
47
+ box-shadow: inset 0px 1px 0px 0px rgba(255, 255, 255, 0.5);
48
+ z-index: 999;
49
+ @include transition(all 0.15s ease-in-out);
50
+ }
51
+
52
+ &.on .toggle
53
+ {
54
+ left: 2%;
55
+ }
56
+ &.off .toggle
57
+ {
58
+ left: 54%;
59
+ }
60
+
61
+ /* Round switch */
62
+ &.round
63
+ {
64
+ padding: 0px 20px;
65
+ border-radius: 40px;
66
+
67
+ .toggle
68
+ {
69
+ border-radius: 40px;
70
+ width: 14px;
71
+ height: 14px;
72
+ }
73
+
74
+ &.on .toggle
75
+ {
76
+ left: 3%;
77
+ background: $button-primary-bkg;
78
+ }
79
+ &.off .toggle
80
+ {
81
+ left: 58%;
82
+ }
83
+ }
84
+ }
85
+
86
+ .switch-label
87
+ {
88
+ font-size: 20px;
89
+ line-height: 31px;
90
+ margin: 0 5px;
91
+ }
freemius/composer.json ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "freemius/wordpress-sdk",
3
+ "description": "Freemius WordPress SDK",
4
+ "keywords": ["freemius", "wordpress", "plugin", "sdk"],
5
+ "homepage": "https://freemius.com",
6
+ "license": "GPL-2.0+",
7
+ "require": {
8
+ "php": ">=5.2"
9
+ }
10
+ }
freemius/config.php ADDED
@@ -0,0 +1,219 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ define( 'WP_FS__SLUG', 'freemius' );
14
+ if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
15
+ define( 'WP_FS__DEV_MODE', false );
16
+ }
17
+
18
+ /**
19
+ * API Connectivity Simulation
20
+ */
21
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
22
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
23
+ }
24
+ if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
25
+ define( 'WP_FS__SIMULATE_NO_CURL', false );
26
+ }
27
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
28
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
29
+ }
30
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
31
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
32
+ }
33
+ if ( WP_FS__SIMULATE_NO_CURL ) {
34
+ define( 'FS_SDK__SIMULATE_NO_CURL', true );
35
+ }
36
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
37
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
38
+ }
39
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
40
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
41
+ }
42
+
43
+ if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
44
+ /**
45
+ * @since 1.1.7.3
46
+ * @author Vova Feldman (@svovaf)
47
+ *
48
+ * I'm not sure if shared servers periodically change IP, or the subdomain of the
49
+ * admin dashboard. Also, I've seen sites that have strange loop of switching
50
+ * between domains on a daily basis. Therefore, to eliminate the risk of
51
+ * multiple unwanted connectivity test pings, temporary ignore domain or
52
+ * server IP changes.
53
+ */
54
+ define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
55
+ }
56
+
57
+ /**
58
+ * If your dev environment supports custom public network IP setup
59
+ * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
60
+ * and uncomment it during dev.
61
+ */
62
+ if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
63
+ // VVV default public network IP.
64
+ define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
65
+
66
+ // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
67
+ }
68
+
69
+ /**
70
+ * If true and running with secret key, the opt-in process
71
+ * will skip the email activation process which is invoked
72
+ * when the email of the context user already exist in Freemius
73
+ * database (as a security precaution, to prevent sharing user
74
+ * secret with unauthorized entity).
75
+ *
76
+ * IMPORTANT:
77
+ * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
78
+ * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
79
+ * CLOCK IS SYNCED.
80
+ */
81
+ if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
82
+ define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
83
+ }
84
+
85
+
86
+ /**
87
+ * Directories
88
+ */
89
+ define( 'WP_FS__DIR', dirname( __FILE__ ) );
90
+ define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
91
+ define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
92
+ define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
93
+ define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
94
+ define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
95
+ define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
96
+ define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
97
+
98
+
99
+ /**
100
+ * Domain / URL / Address
101
+ */
102
+ define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
103
+ define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
104
+
105
+ if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
106
+ define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
107
+ }
108
+ if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
109
+ define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
110
+ }
111
+
112
+ if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
113
+ define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
114
+ }
115
+
116
+ if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
117
+ define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' );
118
+ }
119
+ if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
120
+ define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
121
+ }
122
+
123
+ define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
124
+ define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
125
+
126
+ if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
127
+ // By default, run with Freemius production servers.
128
+ define( 'WP_FS__IS_PRODUCTION_MODE', true );
129
+ }
130
+
131
+ define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
132
+
133
+ if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
134
+ define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
135
+ } else {
136
+ define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
137
+ is_string( WP_FS__REMOTE_ADDR ) &&
138
+ ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) == '127.' ||
139
+ WP_FS__REMOTE_ADDR == '::1' )
140
+ );
141
+ }
142
+
143
+ define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
144
+ false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
145
+
146
+ // Set API address for local testing.
147
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
148
+ define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
149
+ define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
150
+ }
151
+
152
+ define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
153
+
154
+ if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
155
+ define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
156
+ }
157
+ if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
158
+ define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
159
+ }
160
+ define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
161
+
162
+ define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
163
+ // Checks if CloudFlare's HTTPS (Flexible SSL support)
164
+ isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) ||
165
+ // Check if HTTPS request.
166
+ ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
167
+ ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
168
+ );
169
+
170
+ define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
171
+ strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
172
+
173
+ /**
174
+ * Billing Frequencies
175
+ */
176
+ define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
177
+ define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
178
+ define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
179
+
180
+ /**
181
+ * Plans
182
+ */
183
+ define( 'WP_FS__PLAN_DEFAULT_PAID', false );
184
+ define( 'WP_FS__PLAN_FREE', 'free' );
185
+ define( 'WP_FS__PLAN_TRIAL', 'trial' );
186
+
187
+ /**
188
+ * Times in seconds
189
+ */
190
+ define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
191
+ define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
192
+ // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
193
+ define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 );
194
+
195
+ /**
196
+ * Debugging
197
+ */
198
+ if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
199
+ $debug_mode = get_option( 'fs_debug_mode' );
200
+ define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
201
+ }
202
+
203
+ define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
204
+ define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-n-d H:i:s' );
205
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
206
+ define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
207
+ }
208
+
209
+ if ( WP_FS__ECHO_DEBUG_SDK ) {
210
+ error_reporting( E_ALL );
211
+ ini_set( 'error_reporting', E_ALL );
212
+ ini_set( 'display_errors', true );
213
+ ini_set( 'html_errors', true );
214
+ }
215
+
216
+
217
+ define( 'WP_FS__SCRIPT_START_TIME', time() );
218
+ define( 'WP_FS__DEFAULT_PRIORITY', 10 );
219
+ define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
freemius/includes/class-freemius-abstract.php ADDED
@@ -0,0 +1,404 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+
13
+ /**
14
+ * - Each instance of Freemius class represents a single plugin
15
+ * install by a single user (the installer of the plugin).
16
+ *
17
+ * - Each website can only have one install of the same plugin.
18
+ *
19
+ * - Install entity is only created after a user connects his account with Freemius.
20
+ *
21
+ * Class Freemius_Abstract
22
+ */
23
+ abstract class Freemius_Abstract {
24
+
25
+ #region Identity ------------------------------------------------------------------
26
+
27
+ /**
28
+ * Check if user registered with Freemius by connecting his account.
29
+ *
30
+ * @since 1.0.1
31
+ * @return bool
32
+ */
33
+ abstract function is_registered();
34
+
35
+ /**
36
+ * Check if the user skipped connecting the account with Freemius.
37
+ *
38
+ * @since 1.0.7
39
+ *
40
+ * @return bool
41
+ */
42
+ abstract function is_anonymous();
43
+
44
+ /**
45
+ * Check if the user currently in activation mode.
46
+ *
47
+ * @since 1.0.7
48
+ *
49
+ * @return bool
50
+ */
51
+ abstract function is_activation_mode();
52
+
53
+ #endregion Identity ------------------------------------------------------------------
54
+
55
+ #region Permissions ------------------------------------------------------------------
56
+
57
+ /**
58
+ * Check if plugin must be WordPress.org compliant.
59
+ *
60
+ * @since 1.0.7
61
+ *
62
+ * @return bool
63
+ */
64
+ abstract function is_org_repo_compliant();
65
+
66
+ /**
67
+ * Check if plugin is allowed to install executable files.
68
+ *
69
+ * @author Vova Feldman (@svovaf)
70
+ * @since 1.0.5
71
+ *
72
+ * @return bool
73
+ */
74
+ function is_allowed_to_install() {
75
+ return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
76
+ }
77
+
78
+ #endregion Permissions ------------------------------------------------------------------
79
+
80
+ /**
81
+ * Check if user in trial or in free plan (not paying).
82
+ *
83
+ * @author Vova Feldman (@svovaf)
84
+ * @since 1.0.4
85
+ *
86
+ * @return bool
87
+ */
88
+ function is_not_paying() {
89
+ return ( $this->is_trial() || $this->is_free_plan() );
90
+ }
91
+
92
+ /**
93
+ * Check if the user has an activated and valid paid license on current plugin's install.
94
+ *
95
+ * @since 1.0.9
96
+ *
97
+ * @return bool
98
+ */
99
+ abstract function is_paying();
100
+
101
+ /**
102
+ * Check if the user is paying or in trial.
103
+ *
104
+ * @since 1.0.9
105
+ *
106
+ * @return bool
107
+ */
108
+ function is_paying_or_trial() {
109
+ return ( $this->is_paying() || $this->is_trial() );
110
+ }
111
+
112
+ #region Premium Only ------------------------------------------------------------------
113
+
114
+ /**
115
+ * All logic wrapped in methods with "__premium_only()" suffix will be only
116
+ * included in the premium code.
117
+ *
118
+ * Example:
119
+ * if ( freemius()->is__premium_only() ) {
120
+ * ...
121
+ * }
122
+ */
123
+
124
+ /**
125
+ * Returns true when running premium plugin code.
126
+ *
127
+ * @since 1.0.9
128
+ *
129
+ * @return bool
130
+ */
131
+ function is__premium_only() {
132
+ return $this->is_premium();
133
+ }
134
+
135
+ /**
136
+ * Check if the user has an activated and valid paid license on current plugin's install.
137
+ *
138
+ * @since 1.0.9
139
+ *
140
+ * @return bool
141
+ *
142
+ */
143
+ function is_paying__premium_only() {
144
+ return ( $this->is__premium_only() && $this->is_paying() );
145
+ }
146
+
147
+ /**
148
+ * All code wrapped in this statement will be only included in the premium code.
149
+ *
150
+ * @since 1.0.9
151
+ *
152
+ * @param string $plan Plan name
153
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
154
+ *
155
+ * @return bool
156
+ */
157
+ function is_plan__premium_only( $plan, $exact = false ) {
158
+ return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
159
+ }
160
+
161
+ /**
162
+ * Check if plan matches active license' plan or active trial license' plan.
163
+ *
164
+ * All code wrapped in this statement will be only included in the premium code.
165
+ *
166
+ * @since 1.0.9
167
+ *
168
+ * @param string $plan Plan name
169
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
170
+ *
171
+ * @return bool
172
+ */
173
+ function is_plan_or_trial__premium_only( $plan, $exact = false ) {
174
+ return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
175
+ }
176
+
177
+ /**
178
+ * Check if the user is paying or in trial.
179
+ *
180
+ * All code wrapped in this statement will be only included in the premium code.
181
+ *
182
+ * @since 1.0.9
183
+ *
184
+ * @return bool
185
+ */
186
+ function is_paying_or_trial__premium_only() {
187
+ return $this->is_premium() && $this->is_paying_or_trial();
188
+ }
189
+
190
+ /**
191
+ * Check if the user has an activated and valid paid license on current plugin's install.
192
+ *
193
+ * @since 1.0.4
194
+ *
195
+ * @return bool
196
+ *
197
+ * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
198
+ * @using Alias to is_paying__premium_only()
199
+ */
200
+ function is_paying__fs__() {
201
+ return $this->is_paying__premium_only();
202
+ }
203
+
204
+ #endregion Premium Only ------------------------------------------------------------------
205
+
206
+ #region Trial ------------------------------------------------------------------
207
+
208
+ /**
209
+ * Check if the user in a trial.
210
+ *
211
+ * @since 1.0.3
212
+ *
213
+ * @return bool
214
+ */
215
+ abstract function is_trial();
216
+
217
+ /**
218
+ * Check if trial already utilized.
219
+ *
220
+ * @since 1.0.9
221
+ *
222
+ * @return bool
223
+ */
224
+ abstract function is_trial_utilized();
225
+
226
+ #endregion Trial ------------------------------------------------------------------
227
+
228
+ #region Plans ------------------------------------------------------------------
229
+
230
+ /**
231
+ * Check if plugin using the free plan.
232
+ *
233
+ * @since 1.0.4
234
+ *
235
+ * @return bool
236
+ */
237
+ abstract function is_free_plan();
238
+
239
+ /**
240
+ * @since 1.0.2
241
+ *
242
+ * @param string $plan Plan name
243
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
244
+ *
245
+ * @return bool
246
+ */
247
+ abstract function is_plan( $plan, $exact = false );
248
+
249
+ /**
250
+ * Check if plan based on trial. If not in trial mode, should return false.
251
+ *
252
+ * @since 1.0.9
253
+ *
254
+ * @param string $plan Plan name
255
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
256
+ *
257
+ * @return bool
258
+ */
259
+ abstract function is_trial_plan( $plan, $exact = false );
260
+
261
+ /**
262
+ * Check if plan matches active license' plan or active trial license' plan.
263
+ *
264
+ * @since 1.0.9
265
+ *
266
+ * @param string $plan Plan name
267
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
268
+ *
269
+ * @return bool
270
+ */
271
+ function is_plan_or_trial( $plan, $exact = false ) {
272
+ return $this->is_plan( $plan, $exact ) ||
273
+ $this->is_trial_plan( $plan, $exact );
274
+ }
275
+
276
+ /**
277
+ * Check if plugin has any paid plans.
278
+ *
279
+ * @author Vova Feldman (@svovaf)
280
+ * @since 1.0.7
281
+ *
282
+ * @return bool
283
+ */
284
+ abstract function has_paid_plan();
285
+
286
+ /**
287
+ * Check if plugin has any free plan, or is it premium only.
288
+ *
289
+ * Note: If no plans configured, assume plugin is free.
290
+ *
291
+ * @author Vova Feldman (@svovaf)
292
+ * @since 1.0.7
293
+ *
294
+ * @return bool
295
+ */
296
+ abstract function has_free_plan();
297
+
298
+ #endregion Plans ------------------------------------------------------------------
299
+
300
+ /**
301
+ * Check if running payments in sandbox mode.
302
+ *
303
+ * @since 1.0.4
304
+ *
305
+ * @return bool
306
+ */
307
+ abstract function is_payments_sandbox();
308
+
309
+ /**
310
+ * Check if running test vs. live plugin.
311
+ *
312
+ * @since 1.0.5
313
+ *
314
+ * @return bool
315
+ */
316
+ abstract function is_live();
317
+
318
+ /**
319
+ * Check if running premium plugin code.
320
+ *
321
+ * @since 1.0.5
322
+ *
323
+ * @return bool
324
+ */
325
+ abstract function is_premium();
326
+
327
+ /**
328
+ * Get upgrade URL.
329
+ *
330
+ * @author Vova Feldman (@svovaf)
331
+ * @since 1.0.2
332
+ *
333
+ * @param string $period Billing cycle
334
+ *
335
+ * @return string
336
+ */
337
+ abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
338
+
339
+ /**
340
+ * Check if Freemius was first added in a plugin update.
341
+ *
342
+ * @author Vova Feldman (@svovaf)
343
+ * @since 1.1.5
344
+ *
345
+ * @return bool
346
+ */
347
+ function is_plugin_update() {
348
+ return ! $this->is_plugin_new_install();
349
+ }
350
+
351
+ /**
352
+ * Check if Freemius was part of the plugin when the user installed it first.
353
+ *
354
+ * @author Vova Feldman (@svovaf)
355
+ * @since 1.1.5
356
+ *
357
+ * @return bool
358
+ */
359
+ abstract function is_plugin_new_install();
360
+
361
+ #region Marketing ------------------------------------------------------------------
362
+
363
+ /**
364
+ * Check if current user purchased any other plugins before.
365
+ *
366
+ * @author Vova Feldman (@svovaf)
367
+ * @since 1.0.9
368
+ *
369
+ * @return bool
370
+ */
371
+ abstract function has_purchased_before();
372
+
373
+ /**
374
+ * Check if current user classified as an agency.
375
+ *
376
+ * @author Vova Feldman (@svovaf)
377
+ * @since 1.0.9
378
+ *
379
+ * @return bool
380
+ */
381
+ abstract function is_agency();
382
+
383
+ /**
384
+ * Check if current user classified as a developer.
385
+ *
386
+ * @author Vova Feldman (@svovaf)
387
+ * @since 1.0.9
388
+ *
389
+ * @return bool
390
+ */
391
+ abstract function is_developer();
392
+
393
+ /**
394
+ * Check if current user classified as a business.
395
+ *
396
+ * @author Vova Feldman (@svovaf)
397
+ * @since 1.0.9
398
+ *
399
+ * @return bool
400
+ */
401
+ abstract function is_business();
402
+
403
+ #endregion ------------------------------------------------------------------
404
+ }
freemius/includes/class-freemius.php ADDED
@@ -0,0 +1,8912 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+ if ( ! defined( 'ABSPATH' ) ) {
9
+ exit;
10
+ }
11
+
12
+ // "final class"
13
+ class Freemius extends Freemius_Abstract {
14
+ /**
15
+ * SDK Version
16
+ *
17
+ * @var string
18
+ */
19
+ public $version = WP_FS__SDK_VERSION;
20
+
21
+ #region Plugin Info
22
+
23
+ /**
24
+ * @since 1.0.1
25
+ *
26
+ * @var string
27
+ */
28
+ private $_slug;
29
+
30
+ /**
31
+ * @since 1.0.0
32
+ *
33
+ * @var string
34
+ */
35
+ private $_plugin_basename;
36
+ /**
37
+ * @since 1.0.0
38
+ *
39
+ * @var string
40
+ */
41
+ private $_free_plugin_basename;
42
+ /**
43
+ * @since 1.0.0
44
+ *
45
+ * @var string
46
+ */
47
+ private $_plugin_dir_path;
48
+ /**
49
+ * @since 1.0.0
50
+ *
51
+ * @var string
52
+ */
53
+ private $_plugin_dir_name;
54
+ /**
55
+ * @since 1.0.0
56
+ *
57
+ * @var string
58
+ */
59
+ private $_plugin_main_file_path;
60
+ /**
61
+ * @var string[]
62
+ */
63
+ private $_plugin_data;
64
+ /**
65
+ * @since 1.0.9
66
+ *
67
+ * @var string
68
+ */
69
+ private $_plugin_name;
70
+
71
+ #endregion Plugin Info
72
+
73
+ /**
74
+ * @since 1.0.9
75
+ *
76
+ * @var bool If false, don't turn Freemius on.
77
+ */
78
+ private $_is_on;
79
+
80
+ /**
81
+ * @since 1.1.3
82
+ *
83
+ * @var bool If false, don't turn Freemius on.
84
+ */
85
+ private $_is_anonymous;
86
+
87
+ /**
88
+ * @since 1.0.9
89
+ * @var bool If false, issues with connectivity to Freemius API.
90
+ */
91
+ private $_has_api_connection;
92
+
93
+ /**
94
+ * @since 1.0.9
95
+ * @var bool Hints the SDK if plugin can support anonymous mode (if skip connect is visible).
96
+ */
97
+ private $_enable_anonymous;
98
+
99
+ /**
100
+ * @since 1.1.7.5
101
+ * @var bool Hints the SDK if plugin should run in anonymous mode (only adds feedback form).
102
+ */
103
+ private $_anonymous_mode;
104
+
105
+ /**
106
+ * @since 1.0.8
107
+ * @var bool Hints the SDK if the plugin has any paid plans.
108
+ */
109
+ private $_has_paid_plans;
110
+
111
+ /**
112
+ * @since 1.0.7
113
+ * @var bool Hints the SDK if the plugin is WordPress.org compliant.
114
+ */
115
+ private $_is_org_compliant;
116
+
117
+ /**
118
+ * @since 1.0.7
119
+ * @var bool Hints the SDK if the plugin is has add-ons.
120
+ */
121
+ private $_has_addons;
122
+
123
+ /**
124
+ * @since 1.1.6
125
+ * @var string[]bool.
126
+ */
127
+ private $_permissions;
128
+
129
+ /**
130
+ * @var FS_Key_Value_Storage
131
+ */
132
+ private $_storage;
133
+
134
+ /**
135
+ * @since 1.0.0
136
+ *
137
+ * @var FS_Logger
138
+ */
139
+ private $_logger;
140
+ /**
141
+ * @since 1.0.4
142
+ *
143
+ * @var FS_Plugin
144
+ */
145
+ private $_plugin = false;
146
+ /**
147
+ * @since 1.0.4
148
+ *
149
+ * @var FS_Plugin
150
+ */
151
+ private $_parent_plugin = false;
152
+ /**
153
+ * @since 1.1.1
154
+ *
155
+ * @var Freemius
156
+ */
157
+ private $_parent = false;
158
+ /**
159
+ * @since 1.0.1
160
+ *
161
+ * @var FS_User
162
+ */
163
+ private $_user = false;
164
+ /**
165
+ * @since 1.0.1
166
+ *
167
+ * @var FS_Site
168
+ */
169
+ private $_site = false;
170
+ /**
171
+ * @since 1.0.1
172
+ *
173
+ * @var FS_Plugin_License
174
+ */
175
+ private $_license;
176
+ /**
177
+ * @since 1.0.2
178
+ *
179
+ * @var FS_Plugin_Plan[]
180
+ */
181
+ private $_plans = false;
182
+ /**
183
+ * @var FS_Plugin_License[]
184
+ * @since 1.0.5
185
+ */
186
+ private $_licenses = false;
187
+
188
+ /**
189
+ * @since 1.0.1
190
+ *
191
+ * @var FS_Admin_Menu_Manager
192
+ */
193
+ private $_menu;
194
+
195
+ /**
196
+ * @var FS_Admin_Notice_Manager
197
+ */
198
+ private $_admin_notices;
199
+
200
+ /**
201
+ * @since 1.1.6
202
+ *
203
+ * @var FS_Admin_Notice_Manager
204
+ */
205
+ private static $_global_admin_notices;
206
+
207
+ /**
208
+ * @var FS_Logger
209
+ * @since 1.0.0
210
+ */
211
+ private static $_static_logger;
212
+
213
+ /**
214
+ * @var FS_Option_Manager
215
+ * @since 1.0.2
216
+ */
217
+ private static $_accounts;
218
+
219
+ /**
220
+ * @var Freemius[]
221
+ */
222
+ private static $_instances = array();
223
+
224
+
225
+ /* Ctor
226
+ ------------------------------------------------------------------------------------------------------------------*/
227
+
228
+ private function __construct( $slug ) {
229
+ $this->_slug = $slug;
230
+
231
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
232
+
233
+ $this->_storage = FS_Key_Value_Storage::instance( 'plugin_data', $this->_slug );
234
+
235
+ $this->_plugin_main_file_path = $this->_find_caller_plugin_file();
236
+ $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
237
+ $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
238
+ $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
239
+
240
+ $base_name_split = explode( '/', $this->_plugin_basename );
241
+ $this->_plugin_dir_name = $base_name_split[0];
242
+
243
+ if ( $this->_logger->is_on() ) {
244
+ $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
245
+ $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
246
+ $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
247
+ $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
248
+ $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
249
+ }
250
+
251
+ // Remember link between file to slug.
252
+ $this->store_file_slug_map();
253
+
254
+ // Store plugin's initial install timestamp.
255
+ if ( ! isset( $this->_storage->install_timestamp ) ) {
256
+ $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
257
+ }
258
+
259
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->get();
260
+
261
+ $this->_admin_notices = FS_Admin_Notice_Manager::instance(
262
+ $slug,
263
+ is_object( $this->_plugin ) ? $this->_plugin->title : ''
264
+ );
265
+
266
+ if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
267
+ 'true' === fs_request_is_action( 'restart_freemius' )
268
+ ) {
269
+ FS_Api::clear_cache();
270
+ }
271
+
272
+ $this->_register_hooks();
273
+
274
+ $this->_load_account();
275
+
276
+ $this->_version_updates_handler();
277
+ }
278
+
279
+ /**
280
+ * @author Vova Feldman (@svovaf)
281
+ * @since 1.0.9
282
+ */
283
+ private function _version_updates_handler() {
284
+ if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
285
+ // Freemius version upgrade mode.
286
+ $this->_storage->sdk_last_version = $this->_storage->sdk_version;
287
+ $this->_storage->sdk_version = $this->version;
288
+
289
+ if ( empty( $this->_storage->sdk_last_version ) ||
290
+ version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
291
+ ) {
292
+ $this->_storage->sdk_upgrade_mode = true;
293
+ $this->_storage->sdk_downgrade_mode = false;
294
+ } else {
295
+ $this->_storage->sdk_downgrade_mode = true;
296
+ $this->_storage->sdk_upgrade_mode = false;
297
+
298
+ }
299
+
300
+ $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
301
+ }
302
+
303
+ $plugin_version = $this->get_plugin_version();
304
+ if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
305
+ // Plugin version upgrade mode.
306
+ $this->_storage->plugin_last_version = $this->_storage->plugin_version;
307
+ $this->_storage->plugin_version = $plugin_version;
308
+
309
+ if ( empty( $this->_storage->plugin_last_version ) ||
310
+ version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
311
+ ) {
312
+ $this->_storage->plugin_upgrade_mode = true;
313
+ $this->_storage->plugin_downgrade_mode = false;
314
+ } else {
315
+ $this->_storage->plugin_downgrade_mode = true;
316
+ $this->_storage->plugin_upgrade_mode = false;
317
+ }
318
+
319
+ if ( ! empty( $this->_storage->plugin_last_version ) ) {
320
+ // Different version of the plugin was installed before, therefore it's an update.
321
+ $this->_storage->is_plugin_new_install = false;
322
+ }
323
+
324
+ $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
325
+ }
326
+ }
327
+
328
+ /**
329
+ * @author Vova Feldman (@svovaf)
330
+ * @since 1.1.5
331
+ *
332
+ * @param string $sdk_prev_version
333
+ * @param string $sdk_version
334
+ */
335
+ function _data_migration( $sdk_prev_version, $sdk_version ) {
336
+ /**
337
+ * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
338
+ */
339
+ if ( empty( $sdk_prev_version ) ) {
340
+ return;
341
+ }
342
+
343
+ if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
344
+ version_compare( $sdk_version, '1.1.5', '>=' )
345
+ ) {
346
+ // On version 1.1.5 merged connectivity and is_on data.
347
+ if ( isset( $this->_storage->connectivity_test ) ) {
348
+ if ( ! isset( $this->_storage->is_on ) ) {
349
+ unset( $this->_storage->connectivity_test );
350
+ } else {
351
+ $connectivity_data = $this->_storage->connectivity_test;
352
+ $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
353
+ $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
354
+
355
+ // Override.
356
+ $this->_storage->connectivity_test = $connectivity_data;
357
+
358
+ // Remove previous structure.
359
+ unset( $this->_storage->is_on );
360
+ }
361
+
362
+ }
363
+ }
364
+ }
365
+
366
+ /**
367
+ * @author Vova Feldman (@svovaf)
368
+ * @since 1.0.9
369
+ */
370
+ private function _register_hooks() {
371
+ if ( is_admin() ) {
372
+ // Hook to plugin activation
373
+ register_activation_hook( $this->_plugin_main_file_path, array(
374
+ &$this,
375
+ '_activate_plugin_event_hook'
376
+ ) );
377
+
378
+ // Hook to plugin uninstall.
379
+ register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
380
+
381
+ if ( ! $this->is_ajax() ) {
382
+ if ( ! $this->is_addon() ) {
383
+ add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
384
+ add_action( 'admin_menu', array( &$this, '_prepare_admin_menu' ), WP_FS__LOWEST_PRIORITY );
385
+ }
386
+ }
387
+ }
388
+
389
+ register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
390
+
391
+ add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
392
+
393
+ $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
394
+
395
+ $this->add_action( 'sdk_version_update', array( &$this, '_data_migration' ), WP_FS__DEFAULT_PRIORITY, 2 );
396
+ }
397
+
398
+ /**
399
+ * @author Vova Feldman (@svovaf)
400
+ * @since 1.0.9
401
+ */
402
+ private function _register_account_hooks() {
403
+ if ( is_admin() ) {
404
+ if ( ! $this->is_ajax() ) {
405
+ if ( $this->has_trial_plan() ) {
406
+ $last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
407
+ if ( ! $this->_site->is_trial_utilized() &&
408
+ (
409
+ // Show promotion if never shown it yet and 24 hours after initial activation.
410
+ ( false === $last_time_trial_promotion_shown && $this->_storage->activation_timestamp < ( time() - WP_FS__TIME_24_HOURS_IN_SEC ) ) ||
411
+ // Show promotion in every 30 days.
412
+ ( is_numeric( $last_time_trial_promotion_shown ) && 30 * WP_FS__TIME_24_HOURS_IN_SEC < time() - $last_time_trial_promotion_shown ) )
413
+ ) {
414
+ $this->add_action( 'after_init_plugin_registered', array( &$this, '_add_trial_notice' ) );
415
+ }
416
+ }
417
+ }
418
+
419
+ // If user is paying or in trial and have the free version installed,
420
+ // assume that the deactivation is for the upgrade process.
421
+ if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
422
+ add_action( 'wp_ajax_submit-uninstall-reason', array( &$this, '_submit_uninstall_reason_action' ) );
423
+
424
+ global $pagenow;
425
+ if ( 'plugins.php' === $pagenow ) {
426
+ add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
427
+ }
428
+ }
429
+ }
430
+ }
431
+
432
+ /**
433
+ * Leverage backtrace to find caller plugin file path.
434
+ *
435
+ * @author Vova Feldman (@svovaf)
436
+ * @since 1.0.6
437
+ *
438
+ * @return string
439
+ *
440
+ * @uses fs_find_caller_plugin_file
441
+ */
442
+ private function _find_caller_plugin_file() {
443
+ // Try to load the cached value of the file path.
444
+ if ( isset( $this->_storage->plugin_main_file ) ) {
445
+ if ( file_exists( $this->_storage->plugin_main_file->path ) ) {
446
+ return $this->_storage->plugin_main_file->path;
447
+ }
448
+ }
449
+
450
+ $plugin_file = fs_find_caller_plugin_file();
451
+
452
+ $this->_storage->plugin_main_file = (object) array(
453
+ 'path' => fs_normalize_path( $plugin_file ),
454
+ );
455
+
456
+ return $plugin_file;
457
+ }
458
+
459
+
460
+ #region Deactivation Feedback Form ------------------------------------------------------------------
461
+
462
+ /**
463
+ * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
464
+ * page.
465
+ *
466
+ * @author Vova Feldman (@svovaf)
467
+ * @author Leo Fajardo (@leorw)
468
+ * @since 1.1.2
469
+ */
470
+ function _add_deactivation_feedback_dialog_box() {
471
+ fs_enqueue_local_style( 'fs_deactivation_feedback', '/admin/deactivation-feedback.css' );
472
+
473
+ /* Check the type of user:
474
+ * 1. Long-term (long-term)
475
+ * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
476
+ * 3. Short-term (short-term)
477
+ */
478
+ $is_long_term_user = true;
479
+
480
+ // Check if the site is at least 2 days old.
481
+ $time_installed = $this->_storage->install_timestamp;
482
+
483
+ // Difference in seconds.
484
+ $date_diff = time() - $time_installed;
485
+
486
+ // Convert seconds to days.
487
+ $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
488
+
489
+ if ( $date_diff_days < 2 ) {
490
+ $is_long_term_user = false;
491
+ }
492
+
493
+ $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
494
+
495
+ if ( $is_long_term_user ) {
496
+ $user_type = 'long-term';
497
+ } else {
498
+ if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
499
+ $user_type = 'non-registered-and-non-anonymous-short-term';
500
+ } else {
501
+ $user_type = 'short-term';
502
+ }
503
+ }
504
+
505
+ $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
506
+
507
+ // Load the HTML template for the deactivation feedback dialog box.
508
+ $vars = array(
509
+ 'reasons' => $uninstall_reasons,
510
+ 'slug' => $this->_slug
511
+ );
512
+
513
+ /**
514
+ * @todo Deactivation form core functions should be loaded only once! Otherwise, when there are multiple Freemius powered plugins the same code is loaded multiple times. The only thing that should be loaded differently is the various deactivation reasons object based on the state of the plugin.
515
+ */
516
+ fs_require_template( 'deactivation-feedback-modal.php', $vars );
517
+ }
518
+
519
+ /**
520
+ * @author Leo Fajardo (leorw)
521
+ * @since 1.1.2
522
+ *
523
+ * @param string $user_type
524
+ *
525
+ * @return array The uninstall reasons for the specified user type.
526
+ */
527
+ function _get_uninstall_reasons( $user_type = 'long-term' ) {
528
+ $reason_found_better_plugin = array(
529
+ 'id' => 2,
530
+ 'text' => __fs( 'reason-found-a-better-plugin', $this->_slug ),
531
+ 'input_type' => 'textfield',
532
+ 'input_placeholder' => __fs( 'placeholder-plugin-name', $this->_slug )
533
+ );
534
+
535
+ $reason_other = array(
536
+ 'id' => 7,
537
+ 'text' => __fs( 'reason-other', $this->_slug ),
538
+ 'input_type' => 'textfield',
539
+ 'input_placeholder' => ''
540
+ );
541
+
542
+ $long_term_user_reasons = array(
543
+ array(
544
+ 'id' => 1,
545
+ 'text' => __fs( 'reason-no-longer-needed', $this->_slug ),
546
+ 'input_type' => '',
547
+ 'input_placeholder' => ''
548
+ ),
549
+ $reason_found_better_plugin,
550
+ array(
551
+ 'id' => 3,
552
+ 'text' => __fs( 'reason-needed-for-a-short-period', $this->_slug ),
553
+ 'input_type' => '',
554
+ 'input_placeholder' => ''
555
+ ),
556
+ array(
557
+ 'id' => 4,
558
+ 'text' => __fs( 'reason-broke-my-site', $this->_slug ),
559
+ 'input_type' => '',
560
+ 'input_placeholder' => ''
561
+ ),
562
+ array(
563
+ 'id' => 5,
564
+ 'text' => __fs( 'reason-suddenly-stopped-working', $this->_slug ),
565
+ 'input_type' => '',
566
+ 'input_placeholder' => ''
567
+ )
568
+ );
569
+
570
+ if ( $this->is_paying() ) {
571
+ $long_term_user_reasons[] = array(
572
+ 'id' => 6,
573
+ 'text' => __fs( 'reason-cant-pay-anymore', $this->_slug ),
574
+ 'input_type' => 'textfield',
575
+ 'input_placeholder' => __fs( 'placeholder-comfortable-price', $this->_slug )
576
+ );
577
+ }
578
+
579
+ $long_term_user_reasons[] = $reason_other;
580
+
581
+ $uninstall_reasons = array(
582
+ 'long-term' => $long_term_user_reasons,
583
+ 'non-registered-and-non-anonymous-short-term' => array(
584
+ array(
585
+ 'id' => 8,
586
+ 'text' => __fs( 'reason-didnt-work', $this->_slug ),
587
+ 'input_type' => '',
588
+ 'input_placeholder' => ''
589
+ ),
590
+ array(
591
+ 'id' => 9,
592
+ 'text' => __fs( 'reason-dont-like-to-share-my-information', $this->_slug ),
593
+ 'input_type' => '',
594
+ 'input_placeholder' => ''
595
+ ),
596
+ $reason_found_better_plugin,
597
+ $reason_other
598
+ ),
599
+ 'short-term' => array(
600
+ array(
601
+ 'id' => 10,
602
+ 'text' => __fs( 'reason-couldnt-make-it-work', $this->_slug ),
603
+ 'input_type' => '',
604
+ 'input_placeholder' => ''
605
+ ),
606
+ $reason_found_better_plugin,
607
+ array(
608
+ 'id' => 11,
609
+ 'text' => __fs( 'reason-great-but-need-specific-feature', $this->_slug ),
610
+ 'input_type' => 'textarea',
611
+ 'input_placeholder' => __fs( 'placeholder-feature', $this->_slug )
612
+ ),
613
+ array(
614
+ 'id' => 12,
615
+ 'text' => __fs( 'reason-not-working', $this->_slug ),
616
+ 'input_type' => 'textarea',
617
+ 'input_placeholder' => __fs( 'placeholder-share-what-didnt-work', $this->_slug )
618
+ ),
619
+ array(
620
+ 'id' => 13,
621
+ 'text' => __fs( 'reason-not-what-i-was-looking-for', $this->_slug ),
622
+ 'input_type' => 'textarea',
623
+ 'input_placeholder' => __fs( 'placeholder-what-youve-been-looking-for', $this->_slug )
624
+ ),
625
+ array(
626
+ 'id' => 14,
627
+ 'text' => __fs( 'reason-didnt-work-as-expected', $this->_slug ),
628
+ 'input_type' => 'textarea',
629
+ 'input_placeholder' => __fs( 'placeholder-what-did-you-expect', $this->_slug )
630
+ ),
631
+ $reason_other
632
+ )
633
+ );
634
+
635
+ $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
636
+
637
+ return $uninstall_reasons[ $user_type ];
638
+ }
639
+
640
+ /**
641
+ * Called after the user has submitted his reason for deactivating the plugin.
642
+ *
643
+ * @author Leo Fajardo (@leorw)
644
+ * @since 1.1.2
645
+ */
646
+ function _submit_uninstall_reason_action() {
647
+ if ( ! isset( $_POST['reason_id'] ) ) {
648
+ exit;
649
+ }
650
+
651
+ $reason_info = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( $_REQUEST['reason_info'] ) ) : '';
652
+
653
+ $reason = (object) array(
654
+ 'id' => $_POST['reason_id'],
655
+ 'info' => substr( $reason_info, 0, 128 )
656
+ );
657
+
658
+ $this->_storage->store( 'uninstall_reason', $reason );
659
+
660
+ // Print '1' for successful operation.
661
+ echo 1;
662
+ exit;
663
+ }
664
+
665
+ #endregion Deactivation Feedback Form ------------------------------------------------------------------
666
+
667
+ #region Instance ------------------------------------------------------------------
668
+
669
+ /**
670
+ * Main singleton instance.
671
+ *
672
+ * @author Vova Feldman (@svovaf)
673
+ * @since 1.0.0
674
+ *
675
+ * @param $slug
676
+ *
677
+ * @return Freemius
678
+ */
679
+ static function instance( $slug ) {
680
+ $slug = strtolower( $slug );
681
+
682
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
683
+ if ( 0 === count( self::$_instances ) ) {
684
+ self::_load_required_static();
685
+ }
686
+
687
+ self::$_instances[ $slug ] = new Freemius( $slug );
688
+ }
689
+
690
+ return self::$_instances[ $slug ];
691
+ }
692
+
693
+ /**
694
+ * @author Vova Feldman (@svovaf)
695
+ * @since 1.0.6
696
+ *
697
+ * @param string|number $slug_or_id
698
+ *
699
+ * @return bool
700
+ */
701
+ private static function has_instance( $slug_or_id ) {
702
+ return ! is_numeric( $slug_or_id ) ?
703
+ isset( self::$_instances[ strtolower( $slug_or_id ) ] ) :
704
+ ( false !== self::get_instance_by_id( $slug_or_id ) );
705
+ }
706
+
707
+ /**
708
+ * @author Vova Feldman (@svovaf)
709
+ * @since 1.0.6
710
+ *
711
+ * @param $id
712
+ *
713
+ * @return false|Freemius
714
+ */
715
+ static function get_instance_by_id( $id ) {
716
+ foreach ( self::$_instances as $slug => $instance ) {
717
+ if ( $id == $instance->get_id() ) {
718
+ return $instance;
719
+ }
720
+ }
721
+
722
+ return false;
723
+ }
724
+
725
+ /**
726
+ *
727
+ * @author Vova Feldman (@svovaf)
728
+ * @since 1.0.1
729
+ *
730
+ * @param $plugin_file
731
+ *
732
+ * @return false|Freemius
733
+ */
734
+ static function get_instance_by_file( $plugin_file ) {
735
+ $slug = self::find_slug_by_basename( $plugin_file );
736
+
737
+ return ( false !== $slug ) ?
738
+ self::instance( $slug ) :
739
+ false;
740
+ }
741
+
742
+ /**
743
+ * @author Vova Feldman (@svovaf)
744
+ * @since 1.0.6
745
+ *
746
+ * @return false|Freemius
747
+ */
748
+ function get_parent_instance() {
749
+ return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
750
+ }
751
+
752
+ /**
753
+ * @author Vova Feldman (@svovaf)
754
+ * @since 1.0.6
755
+ *
756
+ * @param $slug_or_id
757
+ *
758
+ * @return bool|Freemius
759
+ */
760
+ function get_addon_instance( $slug_or_id ) {
761
+ return ! is_numeric( $slug_or_id ) ?
762
+ self::instance( strtolower( $slug_or_id ) ) :
763
+ self::get_instance_by_id( $slug_or_id );
764
+ }
765
+
766
+ #endregion ------------------------------------------------------------------
767
+
768
+ /**
769
+ * @author Vova Feldman (@svovaf)
770
+ * @since 1.0.6
771
+ *
772
+ * @return bool
773
+ */
774
+ function is_parent_plugin_installed() {
775
+ return self::has_instance( $this->_plugin->parent_plugin_id );
776
+ }
777
+
778
+ /**
779
+ * Check if add-on parent plugin in activation mode.
780
+ *
781
+ * @author Vova Feldman (@svovaf)
782
+ * @since 1.0.7
783
+ *
784
+ * @return bool
785
+ */
786
+ function is_parent_in_activation() {
787
+ $parent_fs = $this->get_parent_instance();
788
+ if ( ! is_object( $parent_fs ) ) {
789
+ return false;
790
+ }
791
+
792
+ return ( $parent_fs->is_activation_mode() );
793
+ }
794
+
795
+ /**
796
+ * Is plugin in activation mode.
797
+ *
798
+ * @author Vova Feldman (@svovaf)
799
+ * @since 1.0.7
800
+ *
801
+ * @return bool
802
+ */
803
+ function is_activation_mode() {
804
+ return (
805
+ ! $this->is_registered() &&
806
+ ( ! $this->enable_anonymous() ||
807
+ ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
808
+ );
809
+ }
810
+
811
+ /**
812
+ * Get collection of all active plugins.
813
+ *
814
+ * @author Vova Feldman (@svovaf)
815
+ * @since 1.0.9
816
+ *
817
+ * @return array[string]array
818
+ */
819
+ private function get_active_plugins() {
820
+ self::require_plugin_essentials();
821
+
822
+ $active_plugin = array();
823
+ $all_plugins = get_plugins();
824
+ $active_plugins_basenames = get_option( 'active_plugins' );
825
+
826
+ foreach ( $active_plugins_basenames as $plugin_basename ) {
827
+ $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
828
+ }
829
+
830
+ return $active_plugin;
831
+ }
832
+
833
+ private static $_statics_loaded = false;
834
+
835
+ /**
836
+ * Load static resources.
837
+ *
838
+ * @author Vova Feldman (@svovaf)
839
+ * @since 1.0.1
840
+ */
841
+ private static function _load_required_static() {
842
+ if ( self::$_statics_loaded ) {
843
+ return;
844
+ }
845
+
846
+ self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
847
+
848
+ self::$_static_logger->entrance();
849
+
850
+ self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
851
+
852
+ self::$_global_admin_notices = FS_Admin_Notice_Manager::instance( 'global' );
853
+
854
+ // Configure which Freemius powered plugins should be auto updated.
855
+ // add_filter( 'auto_update_plugin', '_include_plugins_in_auto_update', 10, 2 );
856
+
857
+ add_action( 'admin_menu', array( 'Freemius', 'add_debug_page' ) );
858
+
859
+ add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
860
+
861
+ self::$_statics_loaded = true;
862
+ }
863
+
864
+ #region Debugging ------------------------------------------------------------------
865
+
866
+ /**
867
+ * @author Vova Feldman (@svovaf)
868
+ * @since 1.0.8
869
+ */
870
+ static function add_debug_page() {
871
+ if ( ! current_user_can( 'activate_plugins' ) ) {
872
+ return;
873
+ }
874
+
875
+ self::$_static_logger->entrance();
876
+
877
+ $title = sprintf( '%s [v.%s]', __fs( 'freemius-debug' ), WP_FS__SDK_VERSION );
878
+
879
+ if ( WP_FS__DEV_MODE ) {
880
+ // Add top-level debug menu item.
881
+ $hook = add_object_page(
882
+ $title,
883
+ $title,
884
+ 'manage_options',
885
+ 'freemius',
886
+ array( 'Freemius', '_debug_page_render' )
887
+ );
888
+ } else {
889
+ // Add hidden debug page.
890
+ $hook = add_submenu_page(
891
+ null,
892
+ $title,
893
+ $title,
894
+ 'manage_options',
895
+ 'freemius',
896
+ array( 'Freemius', '_debug_page_render' )
897
+ );
898
+ }
899
+
900
+ add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
901
+ }
902
+
903
+ /**
904
+ * @author Vova Feldman (@svovaf)
905
+ * @since 1.1.7.3
906
+ */
907
+ static function _toggle_debug_mode() {
908
+ if ( in_array( $_POST['is_on'], array( 0, 1 ) ) ) {
909
+ update_option( 'fs_debug_mode', $_POST['is_on'] );
910
+ }
911
+
912
+ exit;
913
+ }
914
+
915
+ /**
916
+ * @author Vova Feldman (@svovaf)
917
+ * @since 1.0.8
918
+ */
919
+ static function _debug_page_actions() {
920
+ self::_clean_admin_content_section();
921
+
922
+ if ( fs_request_is_action( 'restart_freemius' ) ) {
923
+ check_admin_referer( 'restart_freemius' );
924
+
925
+ self::$_accounts->clear( true );
926
+
927
+
928
+ return;
929
+ }
930
+ }
931
+
932
+ /**
933
+ * @author Vova Feldman (@svovaf)
934
+ * @since 1.0.8
935
+ */
936
+ static function _debug_page_render() {
937
+ self::$_static_logger->entrance();
938
+
939
+ $sites = self::get_all_sites();
940
+ $users = self::get_all_users();
941
+ $addons = self::get_all_addons();
942
+ $account_addons = self::get_all_account_addons();
943
+
944
+ // $plans = self::get_all_plans();
945
+ // $licenses = self::get_all_licenses();
946
+
947
+ $vars = array(
948
+ 'sites' => $sites,
949
+ 'users' => $users,
950
+ 'addons' => $addons,
951
+ 'account_addons' => $account_addons,
952
+ );
953
+
954
+ fs_enqueue_local_style( 'fs_account', '/admin/debug.css' );
955
+ fs_require_once_template( 'debug.php', $vars );
956
+ }
957
+
958
+ #endregion ------------------------------------------------------------------
959
+
960
+ #region Connectivity Issues ------------------------------------------------------------------
961
+
962
+ /**
963
+ * Check if Freemius should be turned on for the current plugin install.
964
+ *
965
+ * Note:
966
+ * $this->_is_on is updated in has_api_connectivity()
967
+ *
968
+ * @author Vova Feldman (@svovaf)
969
+ * @since 1.0.9
970
+ *
971
+ * @return bool
972
+ */
973
+ function is_on() {
974
+ self::$_static_logger->entrance();
975
+
976
+ if ( isset( $this->_is_on ) ) {
977
+ return $this->_is_on;
978
+ }
979
+
980
+ // If already installed or pending then sure it's on :)
981
+ if ( $this->is_registered() || $this->is_pending_activation() ) {
982
+ $this->_is_on = true;
983
+
984
+ return true;
985
+ }
986
+
987
+ return false;
988
+ }
989
+
990
+ /**
991
+ * @author Vova Feldman (@svovaf)
992
+ * @since 1.1.7.3
993
+ *
994
+ * @param bool $flush_if_no_connectivity
995
+ *
996
+ * @return bool
997
+ */
998
+ private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
999
+ if ( ! isset( $this->_storage->connectivity_test ) ) {
1000
+ // Connectivity test was never executed, or cache was cleared.
1001
+ return true;
1002
+ }
1003
+
1004
+ if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
1005
+ if ( WP_FS__IS_HTTP_REQUEST ) {
1006
+ if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
1007
+ // Domain changed.
1008
+ return true;
1009
+ }
1010
+
1011
+ if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
1012
+ // Server IP changed.
1013
+ return true;
1014
+ }
1015
+ }
1016
+ }
1017
+
1018
+ if ( $this->_storage->connectivity_test['is_connected'] &&
1019
+ $this->_storage->connectivity_test['is_active']
1020
+ ) {
1021
+ // API connected and Freemius is active - no need to run connectivity check.
1022
+ return false;
1023
+ }
1024
+
1025
+ if ( $flush_if_no_connectivity ) {
1026
+ /**
1027
+ * If explicitly asked to flush when no connectivity - do it only
1028
+ * if at least 10 sec passed from the last API connectivity test.
1029
+ */
1030
+ return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
1031
+ ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
1032
+ }
1033
+
1034
+ /**
1035
+ * @since 1.1.7 Don't check for connectivity on plugin downgrade.
1036
+ */
1037
+ $version = $this->get_plugin_version();
1038
+ if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
1039
+ // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
1040
+ return true;
1041
+ }
1042
+
1043
+ return false;
1044
+ }
1045
+
1046
+ /**
1047
+ * @author Vova Feldman (@svovaf)
1048
+ * @since 1.1.7.4
1049
+ *
1050
+ * @return object|false
1051
+ */
1052
+ private function ping() {
1053
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
1054
+ return false;
1055
+ }
1056
+
1057
+ $version = $this->get_plugin_version();
1058
+
1059
+ $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
1060
+
1061
+ return $this->get_api_plugin_scope()->ping(
1062
+ $this->get_anonymous_id(),
1063
+ array(
1064
+ 'is_update' => json_encode( $is_update ),
1065
+ 'version' => $version,
1066
+ 'sdk' => $this->version,
1067
+ 'is_admin' => json_encode( is_admin() ),
1068
+ 'is_ajax' => json_encode( $this->is_ajax() ),
1069
+ 'is_cron' => json_encode( $this->is_cron() ),
1070
+ 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
1071
+ )
1072
+ );
1073
+ }
1074
+
1075
+ /**
1076
+ * Check if there's any connectivity issue to Freemius API.
1077
+ *
1078
+ * @author Vova Feldman (@svovaf)
1079
+ * @since 1.0.9
1080
+ *
1081
+ * @param bool $flush_if_no_connectivity
1082
+ *
1083
+ * @return bool
1084
+ */
1085
+ function has_api_connectivity( $flush_if_no_connectivity = false ) {
1086
+ $this->_logger->entrance();
1087
+
1088
+ if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
1089
+ return $this->_has_api_connection;
1090
+ }
1091
+
1092
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
1093
+ isset( $this->_storage->connectivity_test ) &&
1094
+ true === $this->_storage->connectivity_test['is_connected']
1095
+ ) {
1096
+ unset( $this->_storage->connectivity_test );
1097
+ }
1098
+
1099
+ if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
1100
+ $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
1101
+ /**
1102
+ * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
1103
+ */
1104
+ $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
1105
+ ( WP_FS__DEV_MODE && $this->_has_api_connection );
1106
+
1107
+ return $this->_has_api_connection;
1108
+ }
1109
+
1110
+ $pong = $this->ping();
1111
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
1112
+
1113
+ if ( ! $is_connected ) {
1114
+ // API failure.
1115
+ $this->_add_connectivity_issue_message( $pong );
1116
+ }
1117
+
1118
+ $this->store_connectivity_info( $pong, $is_connected );
1119
+
1120
+ return $this->_has_api_connection;
1121
+ }
1122
+
1123
+ /**
1124
+ * @author Vova Feldman (@svovaf)
1125
+ * @since 1.1.7.4
1126
+ *
1127
+ * @param object $pong
1128
+ * @param bool $is_connected
1129
+ */
1130
+ private function store_connectivity_info( $pong, $is_connected ) {
1131
+ $this->_logger->entrance();
1132
+
1133
+ $version = $this->get_plugin_version();
1134
+
1135
+ $is_active = $this->apply_filters(
1136
+ 'is_on',
1137
+ ( ! $is_connected ) ? false :
1138
+ ( isset( $pong->is_active ) && true == $pong->is_active ),
1139
+ $this->is_plugin_update(),
1140
+ $version
1141
+ );
1142
+
1143
+ $this->_storage->connectivity_test = array(
1144
+ 'is_connected' => $is_connected,
1145
+ 'host' => $_SERVER['HTTP_HOST'],
1146
+ 'server_ip' => WP_FS__REMOTE_ADDR,
1147
+ 'is_active' => $is_active,
1148
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
1149
+ // Last version with connectivity attempt.
1150
+ 'version' => $version,
1151
+ );
1152
+
1153
+ $this->_has_api_connection = $is_connected;
1154
+ $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected );
1155
+ }
1156
+
1157
+ /**
1158
+ * Anonymous and unique site identifier (Hash).
1159
+ *
1160
+ * @author Vova Feldman (@svovaf)
1161
+ * @since 1.1.0
1162
+ *
1163
+ * @return string
1164
+ */
1165
+ function get_anonymous_id() {
1166
+ if ( ! self::$_accounts->has_option( 'unique_id' ) ) {
1167
+ $key = get_site_url();
1168
+
1169
+ // If localhost, assign microtime instead of domain.
1170
+ if ( WP_FS__IS_LOCALHOST || false !== strpos( $key, 'localhost' ) ) {
1171
+ $key = microtime();
1172
+ }
1173
+
1174
+ self::$_accounts->set_option( 'unique_id', md5( $key ), true );
1175
+ }
1176
+
1177
+ return self::$_accounts->get_option( 'unique_id' );
1178
+ }
1179
+
1180
+ /**
1181
+ * @author Vova Feldman (@svovaf)
1182
+ * @since 1.1.7.4
1183
+ *
1184
+ * @return \WP_User
1185
+ */
1186
+ static function _get_current_wp_user() {
1187
+ self::require_pluggable_essentials();
1188
+
1189
+ return wp_get_current_user();
1190
+ }
1191
+
1192
+ /**
1193
+ * Generate API connectivity issue message.
1194
+ *
1195
+ * @author Vova Feldman (@svovaf)
1196
+ * @since 1.0.9
1197
+ *
1198
+ * @param mixed $api_result
1199
+ * @param bool $is_first_failure
1200
+ */
1201
+ function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
1202
+ if ( $this->_enable_anonymous ) {
1203
+ // Don't add message if can run anonymously.
1204
+ return;
1205
+ }
1206
+
1207
+ if ( ! function_exists( 'wp_nonce_url' ) ) {
1208
+ require_once( ABSPATH . 'wp-includes/functions.php' );
1209
+ }
1210
+
1211
+ $current_user = self::_get_current_wp_user();
1212
+ // $admin_email = get_option( 'admin_email' );
1213
+ $admin_email = $current_user->user_email;
1214
+
1215
+ $message = false;
1216
+ if ( is_object( $api_result ) &&
1217
+ isset( $api_result->error ) &&
1218
+ isset( $api_result->error->code )
1219
+ ) {
1220
+ switch ( $api_result->error->code ) {
1221
+ case 'curl_missing':
1222
+ $message = sprintf(
1223
+ __fs( 'x-requires-access-to-api', $this->_slug ) . ' ' .
1224
+ __fs( 'curl-missing-message', $this->_slug ) . ' ' .
1225
+ ' %s',
1226
+ '<b>' . $this->get_plugin_name() . '</b>',
1227
+ sprintf(
1228
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1229
+ sprintf(
1230
+ '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
1231
+ __fs( 'curl-missing-no-clue-title', $this->_slug ),
1232
+ ' - ' . sprintf(
1233
+ __fs( 'curl-missing-no-clue-desc', $this->_slug ),
1234
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1235
+ )
1236
+ ),
1237
+ sprintf(
1238
+ '<b>%s</b> - %s',
1239
+ __fs( 'sysadmin-title', $this->_slug ),
1240
+ __fs( 'curl-missing-sysadmin-desc', $this->_slug )
1241
+ ),
1242
+ sprintf(
1243
+ '<a href="%s"><b>%s</b></a>%s',
1244
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=' . 'all' . '&amp;paged=' . '1' . '&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
1245
+ __fs( 'deactivate-plugin-title', $this->_slug ),
1246
+ ' - ' . __fs( 'deactivate-plugin-desc', 'freemius', $this->_slug )
1247
+ )
1248
+ )
1249
+ );
1250
+ break;
1251
+ case 'cloudflare_ddos_protection':
1252
+ $message = sprintf(
1253
+ __fs( 'x-requires-access-to-api', $this->_slug ) . ' ' .
1254
+ __fs( 'cloudflare-blocks-connection-message', $this->_slug ) . ' ' .
1255
+ __fs( 'happy-to-resolve-issue-asap', $this->_slug ) .
1256
+ ' %s',
1257
+ '<b>' . $this->get_plugin_name() . '</b>',
1258
+ sprintf(
1259
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1260
+ sprintf(
1261
+ '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
1262
+ __fs( 'fix-issue-title', $this->_slug ),
1263
+ ' - ' . sprintf(
1264
+ __fs( 'fix-issue-desc', $this->_slug ),
1265
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1266
+ )
1267
+ ),
1268
+ sprintf(
1269
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
1270
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1271
+ __fs( 'install-previous-title', $this->_slug ),
1272
+ ' - ' . __fs( 'install-previous-desc', $this->_slug )
1273
+ ),
1274
+ sprintf(
1275
+ '<a href="%s"><b>%s</b></a>%s',
1276
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=' . 'all' . '&amp;paged=' . '1' . '&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
1277
+ __fs( 'deactivate-plugin-title', $this->_slug ),
1278
+ ' - ' . __fs( 'deactivate-plugin-desc', $this->_slug )
1279
+ )
1280
+ )
1281
+ );
1282
+ break;
1283
+ case 'squid_cache_block':
1284
+ $message = sprintf(
1285
+ __fs( 'x-requires-access-to-api', $this->_slug ) . ' ' .
1286
+ __fs( 'squid-blocks-connection-message', $this->_slug ) .
1287
+ ' %s',
1288
+ '<b>' . $this->get_plugin_name() . '</b>',
1289
+ sprintf(
1290
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1291
+ sprintf(
1292
+ '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a>%s',
1293
+ __fs( 'squid-no-clue-title', $this->_slug ),
1294
+ ' - ' . sprintf(
1295
+ __fs( 'squid-no-clue-desc', $this->_slug ),
1296
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1297
+ )
1298
+ ),
1299
+ sprintf(
1300
+ '<b>%s</b> - %s',
1301
+ __fs( 'sysadmin-title', $this->_slug ),
1302
+ sprintf(
1303
+ __fs( 'squid-sysadmin-desc', $this->_slug ),
1304
+ // We use a filter since the plugin might require additional API connectivity.
1305
+ '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com' ) ) ) . '</b>' )
1306
+ ),
1307
+ sprintf(
1308
+ '<a href="%s"><b>%s</b></a>%s',
1309
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=' . 'all' . '&amp;paged=' . '1' . '&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
1310
+ __fs( 'deactivate-plugin-title', $this->_slug ),
1311
+ ' - ' . __fs( 'deactivate-plugin-desc', $this->_slug )
1312
+ )
1313
+ )
1314
+ );
1315
+ break;
1316
+ // default:
1317
+ // $message = __fs( 'connectivity-test-fails-message', $this->_slug );
1318
+ // break;
1319
+ }
1320
+ }
1321
+
1322
+ $message_id = 'failed_connect_api';
1323
+ $type = 'error';
1324
+
1325
+ if ( false === $message ) {
1326
+ if ( $is_first_failure ) {
1327
+ // First attempt failed.
1328
+ $message = sprintf(
1329
+ __fs( 'x-requires-access-to-api', $this->_slug ) . ' ' .
1330
+ __fs( 'connectivity-test-fails-message', $this->_slug ) . ' ' .
1331
+ __fs( 'connectivity-test-maybe-temporary', $this->_slug ) . '<br><br>' .
1332
+ '%s',
1333
+ '<b>' . $this->get_plugin_name() . '</b>',
1334
+ sprintf(
1335
+ '<div id="fs_firewall_issue_options">%s %s</div>',
1336
+ sprintf(
1337
+ '<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
1338
+ __fs( 'yes-do-your-thing', $this->_slug )
1339
+ ),
1340
+ sprintf(
1341
+ '<a href="%s" class="button">%s</a>',
1342
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=' . 'all' . '&amp;paged=' . '1' . '&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
1343
+ __fs( 'no-deactivate', $this->_slug )
1344
+ )
1345
+ )
1346
+ );
1347
+
1348
+ $message_id = 'failed_connect_api_first';
1349
+ $type = 'promotion';
1350
+ } else {
1351
+ // Second connectivity attempt failed.
1352
+ $message = sprintf(
1353
+ __fs( 'x-requires-access-to-api', $this->_slug ) . ' ' .
1354
+ __fs( 'connectivity-test-fails-message', $this->_slug ) . ' ' .
1355
+ __fs( 'happy-to-resolve-issue-asap', $this->_slug ) .
1356
+ ' %s',
1357
+ '<b>' . $this->get_plugin_name() . '</b>',
1358
+ sprintf(
1359
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1360
+ sprintf(
1361
+ '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
1362
+ __fs( 'fix-issue-title', $this->_slug ),
1363
+ ' - ' . sprintf(
1364
+ __fs( 'fix-issue-desc', $this->_slug ),
1365
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1366
+ )
1367
+ ),
1368
+ sprintf(
1369
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
1370
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1371
+ __fs( 'install-previous-title', $this->_slug ),
1372
+ ' - ' . __fs( 'install-previous-desc', $this->_slug )
1373
+ ),
1374
+ sprintf(
1375
+ '<a href="%s"><b>%s</b></a>%s',
1376
+ wp_nonce_url( 'plugins.php?action=deactivate&amp;plugin=' . $this->_plugin_basename . '&amp;plugin_status=' . 'all' . '&amp;paged=' . '1' . '&amp;s=' . '', 'deactivate-plugin_' . $this->_plugin_basename ),
1377
+ __fs( 'deactivate-plugin-title', $this->_slug ),
1378
+ ' - ' . __fs( 'deactivate-plugin-desc', $this->_slug )
1379
+ )
1380
+ )
1381
+ );
1382
+ }
1383
+ }
1384
+
1385
+ $this->_admin_notices->add_sticky(
1386
+ $message,
1387
+ $message_id,
1388
+ __fs( 'oops', $this->_slug ) . '...',
1389
+ $type
1390
+ );
1391
+ }
1392
+
1393
+ /**
1394
+ * Handle user request to resolve connectivity issue.
1395
+ * This method will send an email to Freemius API technical staff for resolution.
1396
+ * The email will contain server's info and installed plugins (might be caching issue).
1397
+ *
1398
+ * @author Vova Feldman (@svovaf)
1399
+ * @since 1.0.9
1400
+ */
1401
+ function _email_about_firewall_issue() {
1402
+ $this->_admin_notices->remove_sticky( 'failed_connect_api' );
1403
+
1404
+ $pong = $this->ping();
1405
+
1406
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
1407
+
1408
+ if ( $is_connected ) {
1409
+ $this->store_connectivity_info( $pong, $is_connected );
1410
+
1411
+ echo $this->get_after_plugin_activation_redirect_url();
1412
+ exit;
1413
+ }
1414
+
1415
+ $current_user = self::_get_current_wp_user();
1416
+ $admin_email = $current_user->user_email;
1417
+
1418
+ $error_type = fs_request_get( 'error_type', 'general' );
1419
+
1420
+ switch ( $error_type ) {
1421
+ case 'squid':
1422
+ $title = 'Squid ACL Blocking Issue';
1423
+ break;
1424
+ case 'cloudflare':
1425
+ $title = 'CloudFlare Blocking Issue';
1426
+ break;
1427
+ default:
1428
+ $title = 'API Connectivity Issue';
1429
+ break;
1430
+ }
1431
+
1432
+ $custom_email_sections = array();
1433
+
1434
+ if ( 'squid' === $error_type ) {
1435
+ // Override the 'Site' email section.
1436
+ $custom_email_sections['site'] = array(
1437
+ 'rows' => array(
1438
+ 'hosting_company' => array( 'Hosting Company', fs_request_get( 'hosting_company' ) )
1439
+ )
1440
+ );
1441
+ }
1442
+
1443
+ // Add 'API Error' custom email section.
1444
+ $custom_email_sections['api_error'] = array(
1445
+ 'title' => 'API Error',
1446
+ 'rows' => array(
1447
+ 'ping' => array( is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong ) )
1448
+ )
1449
+ );
1450
+
1451
+ // Send email with technical details to resolve CloudFlare's firewall unnecessary protection.
1452
+ $this->send_email(
1453
+ 'api@freemius.com', // recipient
1454
+ $title . ' [' . $this->get_plugin_name() . ']', // subject
1455
+ $custom_email_sections,
1456
+ array( "Reply-To: $admin_email <$admin_email>" ) // headers
1457
+ );
1458
+
1459
+ $this->_admin_notices->add_sticky(
1460
+ sprintf(
1461
+ __fs( 'fix-request-sent-message', $this->_slug ),
1462
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1463
+ ),
1464
+ 'server_details_sent'
1465
+ );
1466
+
1467
+ // Action was taken, tell that API connectivity troubleshooting should be off now.
1468
+
1469
+ echo "1";
1470
+ exit;
1471
+ }
1472
+
1473
+ /**
1474
+ * Handle connectivity test retry approved by the user.
1475
+ *
1476
+ * @author Vova Feldman (@svovaf)
1477
+ * @since 1.1.7.4
1478
+ */
1479
+ function _retry_connectivity_test() {
1480
+ $this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
1481
+
1482
+ $pong = $this->ping();
1483
+
1484
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
1485
+
1486
+ if ( $is_connected ) {
1487
+ $this->store_connectivity_info( $pong, $is_connected );
1488
+
1489
+ echo $this->get_after_plugin_activation_redirect_url();
1490
+ } else {
1491
+ // Add connectivity issue message after 2nd failed attempt.
1492
+ $this->_add_connectivity_issue_message( $pong, false );
1493
+
1494
+ echo "1";
1495
+ }
1496
+
1497
+ exit;
1498
+ }
1499
+
1500
+ static function _add_firewall_issues_javascript() {
1501
+ $params = array();
1502
+ fs_require_once_template( 'firewall-issues-js.php', $params );
1503
+ }
1504
+
1505
+ #endregion Connectivity Issues ------------------------------------------------------------------
1506
+
1507
+ #region Email ------------------------------------------------------------------
1508
+
1509
+ /**
1510
+ * Generates and sends an HTML email with customizable sections.
1511
+ *
1512
+ * @author Leo Fajardo (@leorw)
1513
+ * @since 1.1.2
1514
+ *
1515
+ * @param string $to_address
1516
+ * @param string $subject
1517
+ * @param array $sections
1518
+ * @param array $headers
1519
+ *
1520
+ * @return bool Whether the email contents were sent successfully.
1521
+ */
1522
+ private function send_email(
1523
+ $to_address,
1524
+ $subject,
1525
+ $sections = array(),
1526
+ $headers = array()
1527
+ ) {
1528
+ $default_sections = $this->get_email_sections();
1529
+
1530
+ // Insert new sections or replace the default email sections.
1531
+ if ( is_array( $sections ) && ! empty( $sections ) ) {
1532
+ foreach ( $sections as $section_id => $custom_section ) {
1533
+ if ( ! isset( $default_sections[ $section_id ] ) ) {
1534
+ // If the section does not exist, add it.
1535
+ $default_sections[ $section_id ] = $custom_section;
1536
+ } else {
1537
+ // If the section already exists, override it.
1538
+ $current_section = $default_sections[ $section_id ];
1539
+
1540
+ // Replace the current section's title if a custom section title exists.
1541
+ if ( isset( $custom_section['title'] ) ) {
1542
+ $current_section['title'] = $custom_section['title'];
1543
+ }
1544
+
1545
+ // Insert new rows under the current section or replace the default rows.
1546
+ if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
1547
+ foreach ( $custom_section['rows'] as $row_id => $row ) {
1548
+ $current_section['rows'][ $row_id ] = $row;
1549
+ }
1550
+ }
1551
+
1552
+ $default_sections[ $section_id ] = $current_section;
1553
+ }
1554
+ }
1555
+ }
1556
+
1557
+ $vars = array( 'sections' => $default_sections );
1558
+ $message = fs_get_template( 'email.php', $vars );
1559
+
1560
+ // Set the type of email to HTML.
1561
+ $headers[] = 'Content-type: text/html';
1562
+
1563
+ $header_string = implode( "\r\n", $headers );
1564
+
1565
+ return wp_mail(
1566
+ $to_address,
1567
+ $subject,
1568
+ $message,
1569
+ $header_string
1570
+ );
1571
+ }
1572
+
1573
+ /**
1574
+ * Generates the data for the sections of the email content.
1575
+ *
1576
+ * @author Leo Fajardo (@leorw)
1577
+ * @since 1.1.2
1578
+ *
1579
+ * @return array
1580
+ */
1581
+ private function get_email_sections() {
1582
+ // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
1583
+ $current_user = self::_get_current_wp_user();
1584
+
1585
+ // Retrieve the cURL version information so that we can get the version number below.
1586
+ $curl_version_information = curl_version();
1587
+
1588
+ $active_plugin = $this->get_active_plugins();
1589
+
1590
+ // Generate the list of active plugins separated by new line.
1591
+ $active_plugin_string = '';
1592
+ foreach ( $active_plugin as $plugin ) {
1593
+ $active_plugin_string .= sprintf(
1594
+ '<a href="%s">%s</a> [v%s]<br>',
1595
+ $plugin['PluginURI'],
1596
+ $plugin['Name'],
1597
+ $plugin['Version']
1598
+ );
1599
+ }
1600
+
1601
+ $server_ip = WP_FS__REMOTE_ADDR;
1602
+
1603
+ // Generate the default email sections.
1604
+ $sections = array(
1605
+ 'sdk' => array(
1606
+ 'title' => 'SDK',
1607
+ 'rows' => array(
1608
+ 'fs_version' => array( 'FS Version', $this->version ),
1609
+ 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
1610
+ )
1611
+ ),
1612
+ 'plugin' => array(
1613
+ 'title' => 'Plugin',
1614
+ 'rows' => array(
1615
+ 'name' => array( 'Name', $this->get_plugin_name() ),
1616
+ 'version' => array( 'Version', $this->get_plugin_version() )
1617
+ )
1618
+ ),
1619
+ 'site' => array(
1620
+ 'title' => 'Site',
1621
+ 'rows' => array(
1622
+ 'address' => array( 'Address', site_url() ),
1623
+ 'host' => array(
1624
+ 'HTTP_HOST',
1625
+ ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
1626
+ ),
1627
+ 'server_addr' => array(
1628
+ 'SERVER_ADDR',
1629
+ '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
1630
+ )
1631
+ )
1632
+ ),
1633
+ 'user' => array(
1634
+ 'title' => 'User',
1635
+ 'rows' => array(
1636
+ 'email' => array( 'Email', $current_user->user_email ),
1637
+ 'first' => array( 'First', $current_user->user_firstname ),
1638
+ 'last' => array( 'Last', $current_user->user_lastname )
1639
+ )
1640
+ ),
1641
+ 'plugins' => array(
1642
+ 'title' => 'Plugins',
1643
+ 'rows' => array(
1644
+ 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
1645
+ )
1646
+ ),
1647
+ );
1648
+
1649
+ // Allow the sections to be modified by other code.
1650
+ $sections = $this->apply_filters( 'email_template_sections', $sections );
1651
+
1652
+ return $sections;
1653
+ }
1654
+
1655
+ #endregion Email ------------------------------------------------------------------
1656
+
1657
+ #region Initialization ------------------------------------------------------------------
1658
+
1659
+ /**
1660
+ * Init plugin's Freemius instance.
1661
+ *
1662
+ * @author Vova Feldman (@svovaf)
1663
+ * @since 1.0.1
1664
+ *
1665
+ * @param number $id
1666
+ * @param string $public_key
1667
+ * @param bool $is_live
1668
+ * @param bool $is_premium
1669
+ */
1670
+ function init( $id, $public_key, $is_live = true, $is_premium = true ) {
1671
+ $this->_logger->entrance();
1672
+
1673
+ $this->dynamic_init( array(
1674
+ 'id' => $id,
1675
+ 'public_key' => $public_key,
1676
+ 'is_live' => $is_live,
1677
+ 'is_premium' => $is_premium,
1678
+ ) );
1679
+ }
1680
+
1681
+ /**
1682
+ * Dynamic initiator, originally created to support initiation
1683
+ * with parent_id for add-ons.
1684
+ *
1685
+ * @author Vova Feldman (@svovaf)
1686
+ * @since 1.0.6
1687
+ *
1688
+ * @param array $plugin_info
1689
+ *
1690
+ * @throws Freemius_Exception
1691
+ */
1692
+ function dynamic_init( array $plugin_info ) {
1693
+ $this->_logger->entrance();
1694
+
1695
+ $this->parse_settings( $plugin_info );
1696
+
1697
+ if ( $this->should_stop_execution() ) {
1698
+ return;
1699
+ }
1700
+
1701
+ if ( ! $this->is_registered() ) {
1702
+ if ( $this->is_anonymous() ) {
1703
+ // If user skipped, no need to test connectivity.
1704
+ $this->_has_api_connection = true;
1705
+ $this->_is_on = true;
1706
+ } else {
1707
+ if ( ! $this->has_api_connectivity() ) {
1708
+ if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
1709
+ $this->_admin_notices->has_sticky( 'failed_connect_api' )
1710
+ ) {
1711
+ if ( ! $this->_enable_anonymous ) {
1712
+ // If anonymous mode is disabled, add firewall admin-notice message.
1713
+ add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
1714
+
1715
+ add_action( "wp_ajax_{$this->_slug}_resolve_firewall_issues", array(
1716
+ &$this,
1717
+ '_email_about_firewall_issue'
1718
+ ) );
1719
+
1720
+ add_action( "wp_ajax_{$this->_slug}_retry_connectivity_test", array(
1721
+ &$this,
1722
+ '_retry_connectivity_test'
1723
+ ) );
1724
+ }
1725
+ }
1726
+
1727
+ return;
1728
+ } else {
1729
+ $this->_admin_notices->remove_sticky( array(
1730
+ 'failed_connect_api_first',
1731
+ 'failed_connect_api',
1732
+ ) );
1733
+
1734
+ if ( $this->_anonymous_mode ) {
1735
+ // Simulate anonymous mode.
1736
+ $this->_is_anonymous = true;
1737
+ }
1738
+ }
1739
+ }
1740
+
1741
+ // Check if Freemius is on for the current plugin.
1742
+ // This MUST be executed after all the plugin variables has been loaded.
1743
+ if ( ! $this->is_on() ) {
1744
+ return;
1745
+ }
1746
+ }
1747
+
1748
+ if ( $this->has_api_connectivity() && $this->is_user_in_admin() ) {
1749
+ /**
1750
+ * Schedule daily data sync cron if:
1751
+ *
1752
+ * 1. User opted-in (for tracking).
1753
+ * 2. If plugin has add-ons (update add-ons data).
1754
+ * 3. If skipped, but later upgraded (opted-in via upgrade).
1755
+ *
1756
+ * @author Vova Feldman (@svovaf)
1757
+ * @since 1.1.7.3
1758
+ *
1759
+ */
1760
+ if ( $this->is_registered() ||
1761
+ ( ! $this->is_activation_mode() && $this->_has_addons )
1762
+ ) {
1763
+
1764
+ $this->hook_callback_to_sync_cron();
1765
+
1766
+ if ( ! $this->is_sync_cron_on() ) {
1767
+ $this->schedule_sync_cron();
1768
+ }
1769
+ }
1770
+
1771
+ /**
1772
+ * Check if requested for manual blocking background sync.
1773
+ */
1774
+ if ( fs_request_has( 'background_sync' ) ) {
1775
+ $this->run_manual_sync();
1776
+ }
1777
+ }
1778
+
1779
+ if ( $this->is_registered() ) {
1780
+ $this->hook_callback_to_install_sync();
1781
+ }
1782
+
1783
+ if ( $this->is_addon() ) {
1784
+ if ( $this->is_parent_plugin_installed() ) {
1785
+ // Link to parent FS.
1786
+ $this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
1787
+
1788
+ // Get parent plugin reference.
1789
+ $this->_parent_plugin = $this->_parent->get_plugin();
1790
+ }
1791
+ }
1792
+
1793
+ if ( $this->is_user_in_admin() ) {
1794
+ global $pagenow;
1795
+ if ( 'plugins.php' === $pagenow ) {
1796
+ $this->hook_plugin_action_links();
1797
+ }
1798
+
1799
+ if ( $this->is_addon() ) {
1800
+ if ( ! $this->is_parent_plugin_installed() ) {
1801
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
1802
+
1803
+ if ( isset( $plugin_info['parent'] ) ) {
1804
+ $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
1805
+ }
1806
+
1807
+ $this->_admin_notices->add(
1808
+ ( ! empty( $parent_name ) ?
1809
+ sprintf( __fs( 'addon-x-cannot-run-without-y', $this->_slug ), $this->get_plugin_name(), $parent_name ) :
1810
+ sprintf( __fs( 'addon-x-cannot-run-without-parent', $this->_slug ), $this->get_plugin_name() )
1811
+ ),
1812
+ __fs( 'oops', $this->_slug ) . '...',
1813
+ 'error'
1814
+ );
1815
+
1816
+ return;
1817
+ } else {
1818
+ if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
1819
+ // If parent plugin activated, automatically install add-on for the user.
1820
+ $this->_activate_addon_account( $this->_parent );
1821
+ }
1822
+
1823
+ // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
1824
+ if ( $this->is_premium() ) {
1825
+ // Remove add-on download admin-notice.
1826
+ $this->_parent->_admin_notices->remove_sticky( 'addon_plan_upgraded_' . $this->_slug );
1827
+ }
1828
+
1829
+ $this->deactivate_premium_only_addon_without_license();
1830
+ }
1831
+ } else {
1832
+ add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
1833
+
1834
+ if ( $this->has_addons() &&
1835
+ 'plugin-information' === fs_request_get( 'tab', false ) &&
1836
+ $this->get_id() == fs_request_get( 'parent_plugin_id', false )
1837
+ ) {
1838
+ require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
1839
+
1840
+ new FS_Plugin_Info_Dialog( $this );
1841
+ }
1842
+ }
1843
+
1844
+ if ( $this->is_premium() ) {
1845
+ new FS_Plugin_Updater( $this );
1846
+ }
1847
+
1848
+ // if ( $this->is_registered() ||
1849
+ // $this->is_anonymous() ||
1850
+ // $this->is_pending_activation()
1851
+ // ) {
1852
+ // $this->_init_admin();
1853
+ // }
1854
+ }
1855
+
1856
+ $this->do_action( 'initiated' );
1857
+
1858
+ if ( ! $this->is_addon() ) {
1859
+ if ( $this->is_registered() ) {
1860
+ // Fix for upgrade from versions < 1.0.9.
1861
+ if ( ! isset( $this->_storage->activation_timestamp ) ) {
1862
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
1863
+ }
1864
+ if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
1865
+ if ( isset( $this->_storage->prev_is_premium ) ) {
1866
+ add_action( is_admin() ? 'admin_init' : 'init', array(
1867
+ &$this,
1868
+ '_plugin_code_type_changed'
1869
+ ) );
1870
+ } else {
1871
+ // Set for code type for the first time.
1872
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
1873
+ }
1874
+ }
1875
+
1876
+ $this->do_action( 'after_init_plugin_registered' );
1877
+ } else if ( $this->is_anonymous() ) {
1878
+ $this->do_action( 'after_init_plugin_anonymous' );
1879
+ } else if ( $this->is_pending_activation() ) {
1880
+ $this->do_action( 'after_init_plugin_pending_activations' );
1881
+ }
1882
+ } else {
1883
+ if ( $this->is_registered() ) {
1884
+ $this->do_action( 'after_init_addon_registered' );
1885
+ } else if ( $this->is_anonymous() ) {
1886
+ $this->do_action( 'after_init_addon_anonymous' );
1887
+ } else if ( $this->is_pending_activation() ) {
1888
+ $this->do_action( 'after_init_addon_pending_activations' );
1889
+ }
1890
+ }
1891
+ }
1892
+
1893
+ /**
1894
+ * Parse plugin's settings (as defined by the plugin dev).
1895
+ *
1896
+ * @author Vova Feldman (@svovaf)
1897
+ * @since 1.1.7.3
1898
+ *
1899
+ * @param array $plugin_info
1900
+ *
1901
+ * @throws \Freemius_Exception
1902
+ */
1903
+ private function parse_settings( &$plugin_info ) {
1904
+ $this->_logger->entrance();
1905
+
1906
+ $id = $this->get_numeric_option( $plugin_info, 'id', false );
1907
+ $public_key = $this->get_option( $plugin_info, 'public_key', false );
1908
+ $secret_key = $this->get_option( $plugin_info, 'secret_key', null );
1909
+ $parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
1910
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
1911
+
1912
+ if ( isset( $plugin_info['parent'] ) ) {
1913
+ $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
1914
+ // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
1915
+ // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
1916
+ $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
1917
+ }
1918
+
1919
+ if ( false === $id ) {
1920
+ throw new Freemius_Exception( 'Plugin id parameter is not set.' );
1921
+ }
1922
+ if ( false === $public_key ) {
1923
+ throw new Freemius_Exception( 'Plugin public_key parameter is not set.' );
1924
+ }
1925
+
1926
+ $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
1927
+ $this->_plugin :
1928
+ new FS_Plugin();
1929
+
1930
+ $plugin->update( array(
1931
+ 'id' => $id,
1932
+ 'public_key' => $public_key,
1933
+ 'slug' => $this->_slug,
1934
+ 'parent_plugin_id' => $parent_id,
1935
+ 'version' => $this->get_plugin_version(),
1936
+ 'title' => $this->get_plugin_name(),
1937
+ 'file' => $this->_plugin_basename,
1938
+ 'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
1939
+ 'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
1940
+ // 'secret_key' => $secret_key,
1941
+ ) );
1942
+
1943
+ if ( $plugin->is_updated() ) {
1944
+ // Update plugin details.
1945
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->store( $plugin );
1946
+ }
1947
+ // Set the secret key after storing the plugin, we don't want to store the key in the storage.
1948
+ $this->_plugin->secret_key = $secret_key;
1949
+
1950
+ if ( ! isset( $plugin_info['menu'] ) ) {
1951
+ // Back compatibility to 1.1.2
1952
+ $plugin_info['menu'] = array(
1953
+ 'slug' => isset( $plugin_info['menu_slug'] ) ?
1954
+ $plugin_info['menu_slug'] :
1955
+ $this->_slug
1956
+ );
1957
+ }
1958
+
1959
+ $this->_menu = FS_Admin_Menu_Manager::instance( $this->_slug );
1960
+ $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
1961
+
1962
+ $this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
1963
+ $this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
1964
+ $this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
1965
+ $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
1966
+ $this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
1967
+ $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
1968
+ }
1969
+
1970
+ /**
1971
+ * @param string[] $options
1972
+ * @param string $key
1973
+ * @param mixed $default
1974
+ *
1975
+ * @return bool
1976
+ */
1977
+ private function get_option( &$options, $key, $default = false ) {
1978
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
1979
+ }
1980
+
1981
+ private function get_bool_option( &$options, $key, $default = false ) {
1982
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
1983
+ }
1984
+
1985
+ private function get_numeric_option( &$options, $key, $default = false ) {
1986
+ return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
1987
+ }
1988
+
1989
+ /**
1990
+ * Gate keeper.
1991
+ *
1992
+ * @author Vova Feldman (@svovaf)
1993
+ * @since 1.1.7.3
1994
+ *
1995
+ * @return bool
1996
+ */
1997
+ private function should_stop_execution() {
1998
+ if ( $this->is_activation_mode() ) {
1999
+ if ( ! is_admin() ) {
2000
+ /**
2001
+ * If in activation mode, don't execute Freemius outside of the
2002
+ * admin dashboard.
2003
+ *
2004
+ * @author Vova Feldman (@svovaf)
2005
+ * @since 1.1.7.3
2006
+ */
2007
+ return true;
2008
+ }
2009
+
2010
+ if ( ! WP_FS__IS_HTTP_REQUEST ) {
2011
+ /**
2012
+ * If in activation and executed without HTTP context (e.g. CLI, Cronjob),
2013
+ * then don't start Freemius.
2014
+ *
2015
+ * @author Vova Feldman (@svovaf)
2016
+ * @since 1.1.6.3
2017
+ *
2018
+ * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
2019
+ */
2020
+ return true;
2021
+ }
2022
+
2023
+ if ( $this->is_cron() ) {
2024
+ /**
2025
+ * If in activation mode, don't execute Freemius during wp crons
2026
+ * (wp crons have HTTP context - called as HTTP request).
2027
+ *
2028
+ * @author Vova Feldman (@svovaf)
2029
+ * @since 1.1.7.3
2030
+ */
2031
+ return true;
2032
+ }
2033
+
2034
+ if ( $this->is_ajax() &&
2035
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
2036
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api' )
2037
+ ) {
2038
+ /**
2039
+ * During activation, if running in AJAX mode, unless there's a sticky
2040
+ * connectivity issue notice, don't run Freemius.
2041
+ *
2042
+ * @author Vova Feldman (@svovaf)
2043
+ * @since 1.1.7.3
2044
+ */
2045
+ return true;
2046
+ }
2047
+ }
2048
+
2049
+ return false;
2050
+ }
2051
+
2052
+ /**
2053
+ * Handles plugin's code type change (free <--> premium).
2054
+ *
2055
+ * @author Vova Feldman (@svovaf)
2056
+ * @since 1.0.9
2057
+ */
2058
+ function _plugin_code_type_changed() {
2059
+ // Schedule code type changes event.
2060
+ // $this->sync_install();
2061
+ $this->schedule_install_sync();
2062
+
2063
+ if ( $this->is_premium() ) {
2064
+ // Activated premium code.
2065
+ $this->do_action( 'after_premium_version_activation' );
2066
+
2067
+ // Remove all sticky messages related to download of the premium version.
2068
+ $this->_admin_notices->remove_sticky( array(
2069
+ 'trial_started',
2070
+ 'plan_upgraded',
2071
+ 'plan_changed',
2072
+ ) );
2073
+
2074
+ $this->_admin_notices->add_sticky(
2075
+ __fs( 'premium-activated-message', $this->_slug ),
2076
+ 'premium_activated',
2077
+ __fs( 'woot', $this->_slug ) . '!'
2078
+ );
2079
+ } else {
2080
+ // Activated free code (after had the premium before).
2081
+ $this->do_action( 'after_free_version_reactivation' );
2082
+
2083
+ if ( $this->is_paying() && ! $this->is_premium() ) {
2084
+ $this->_admin_notices->add_sticky(
2085
+ sprintf(
2086
+ __fs( 'you-have-x-license', $this->_slug ),
2087
+ $this->_site->plan->title
2088
+ ) . ' ' . $this->_get_latest_download_link( sprintf(
2089
+ __fs( 'download-x-version-now', $this->_slug ),
2090
+ $this->_site->plan->title
2091
+ ) ),
2092
+ 'plan_upgraded',
2093
+ __fs( 'yee-haw', $this->_slug ) . '!'
2094
+ );
2095
+ }
2096
+ }
2097
+
2098
+ // Update is_premium of latest version.
2099
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
2100
+ }
2101
+
2102
+ #endregion Initialization ------------------------------------------------------------------
2103
+
2104
+ #region Add-ons -------------------------------------------------------------------------
2105
+
2106
+ /**
2107
+ * Check if add-on installed and activated on site.
2108
+ *
2109
+ * @author Vova Feldman (@svovaf)
2110
+ * @since 1.0.6
2111
+ *
2112
+ * @param string|number $slug_or_id
2113
+ *
2114
+ * @return bool
2115
+ */
2116
+ function is_addon_activated( $slug_or_id ) {
2117
+ return self::has_instance( $slug_or_id );
2118
+ }
2119
+
2120
+ /**
2121
+ * Check if add-on was connected to install
2122
+ *
2123
+ * @author Vova Feldman (@svovaf)
2124
+ * @since 1.1.7
2125
+ *
2126
+ * @param string $slug
2127
+ *
2128
+ * @return bool
2129
+ */
2130
+ function is_addon_connected( $slug ) {
2131
+ $sites = self::get_all_sites();
2132
+
2133
+ if ( ! isset( $sites[ $slug ] ) ) {
2134
+ return false;
2135
+ }
2136
+
2137
+ $site = $sites[ $slug ];
2138
+
2139
+ $plugin = FS_Plugin_Manager::instance( $slug )->get();
2140
+
2141
+ if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
2142
+ // The given slug do NOT belong to any of the plugin's add-ons.
2143
+ return false;
2144
+ }
2145
+
2146
+ return ( is_object( $site ) &&
2147
+ is_numeric( $site->id ) &&
2148
+ is_numeric( $site->user_id ) &&
2149
+ is_object( $site->plan )
2150
+ );
2151
+ }
2152
+
2153
+ /**
2154
+ * Determines if add-on installed.
2155
+ *
2156
+ * NOTE: This is a heuristic and only works if the folder/file named as the slug.
2157
+ *
2158
+ * @author Vova Feldman (@svovaf)
2159
+ * @since 1.0.6
2160
+ *
2161
+ * @param string $slug
2162
+ *
2163
+ * @return bool
2164
+ */
2165
+ function is_addon_installed( $slug ) {
2166
+ return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $slug ) ) );
2167
+ }
2168
+
2169
+ /**
2170
+ * Get add-on basename.
2171
+ *
2172
+ * @author Vova Feldman (@svovaf)
2173
+ * @since 1.0.6
2174
+ *
2175
+ * @param string $slug
2176
+ *
2177
+ * @return string
2178
+ */
2179
+ function get_addon_basename( $slug ) {
2180
+ if ( $this->is_addon_activated( $slug ) ) {
2181
+ self::instance( $slug )->get_plugin_basename();
2182
+ }
2183
+
2184
+ $premium_basename = $slug . '-premium/' . $slug . '.php';
2185
+
2186
+ if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
2187
+ return $premium_basename;
2188
+ }
2189
+
2190
+ $free_basename = $slug . '/' . $slug . '.php';
2191
+
2192
+ return $free_basename;
2193
+ }
2194
+
2195
+ /**
2196
+ * Get installed add-ons instances.
2197
+ *
2198
+ * @author Vova Feldman (@svovaf)
2199
+ * @since 1.0.6
2200
+ *
2201
+ * @return Freemius[]
2202
+ */
2203
+ function get_installed_addons() {
2204
+ $installed_addons = array();
2205
+ foreach ( self::$_instances as $slug => $instance ) {
2206
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
2207
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
2208
+ $installed_addons[] = $instance;
2209
+ }
2210
+ }
2211
+ }
2212
+
2213
+ return $installed_addons;
2214
+ }
2215
+
2216
+ /**
2217
+ * Check if any add-ons of the plugin are installed.
2218
+ *
2219
+ * @author Leo Fajardo (@leorw)
2220
+ * @since 1.1.1
2221
+ *
2222
+ * @return bool
2223
+ */
2224
+ function has_installed_addons() {
2225
+ if ( ! $this->has_addons() ) {
2226
+ return false;
2227
+ }
2228
+
2229
+ foreach ( self::$_instances as $slug => $instance ) {
2230
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
2231
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
2232
+ return true;
2233
+ }
2234
+ }
2235
+ }
2236
+
2237
+ return false;
2238
+ }
2239
+
2240
+ /**
2241
+ * Tell Freemius that the current plugin is an add-on.
2242
+ *
2243
+ * @author Vova Feldman (@svovaf)
2244
+ * @since 1.0.6
2245
+ *
2246
+ * @param number $parent_plugin_id The parent plugin ID
2247
+ */
2248
+ function init_addon( $parent_plugin_id ) {
2249
+ $this->_plugin->parent_plugin_id = $parent_plugin_id;
2250
+ }
2251
+
2252
+ /**
2253
+ * @author Vova Feldman (@svovaf)
2254
+ * @since 1.0.6
2255
+ *
2256
+ * @return bool
2257
+ */
2258
+ function is_addon() {
2259
+ return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
2260
+ }
2261
+
2262
+ /**
2263
+ * Deactivate add-on if it's premium only and the user does't have a valid license.
2264
+ *
2265
+ * @param bool $is_after_trial_cancel
2266
+ *
2267
+ * @return bool If add-on was deactivated.
2268
+ */
2269
+ private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
2270
+ if ( ! $this->has_free_plan() &&
2271
+ ! $this->has_features_enabled_license() &&
2272
+ ! $this->_has_premium_license()
2273
+ ) {
2274
+ deactivate_plugins( array( $this->_plugin_basename ), true );
2275
+
2276
+ $this->_parent->_admin_notices->add_sticky(
2277
+ sprintf(
2278
+ __fs( ( $is_after_trial_cancel ?
2279
+ 'addon-trial-cancelled-message' :
2280
+ 'addon-no-license-message' ),
2281
+ $this->_parent->_slug
2282
+ ),
2283
+ '<b>' . $this->_plugin->title . '</b>'
2284
+ ) . ' ' . sprintf(
2285
+ '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
2286
+ $this->_parent->addon_url( $this->_slug ),
2287
+ esc_attr( sprintf( __fs( 'more-information-about-x', $this->_parent->_slug ), $this->_plugin->title ) ),
2288
+ __fs( 'purchase-license', $this->_parent->_slug )
2289
+ ),
2290
+ 'no_addon_license',
2291
+ ( $is_after_trial_cancel ? '' : __fs( 'oops', $this->_parent->_slug ) . '...' ),
2292
+ ( $is_after_trial_cancel ? 'success' : 'error' )
2293
+ );
2294
+
2295
+ return true;
2296
+ }
2297
+
2298
+ return false;
2299
+ }
2300
+
2301
+ #endregion ------------------------------------------------------------------
2302
+
2303
+ #region Sandbox ------------------------------------------------------------------
2304
+
2305
+ /**
2306
+ * Set Freemius into sandbox mode for debugging.
2307
+ *
2308
+ * @author Vova Feldman (@svovaf)
2309
+ * @since 1.0.4
2310
+ *
2311
+ * @param string $secret_key
2312
+ */
2313
+ function init_sandbox( $secret_key ) {
2314
+ $this->_plugin->secret_key = $secret_key;
2315
+
2316
+ // Update plugin details.
2317
+ FS_Plugin_Manager::instance( $this->_slug )->update( $this->_plugin, true );
2318
+ }
2319
+
2320
+ /**
2321
+ * Check if running payments in sandbox mode.
2322
+ *
2323
+ * @author Vova Feldman (@svovaf)
2324
+ * @since 1.0.4
2325
+ *
2326
+ * @return bool
2327
+ */
2328
+ function is_payments_sandbox() {
2329
+ return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
2330
+ }
2331
+
2332
+ #endregion Sandbox ------------------------------------------------------------------
2333
+
2334
+ /**
2335
+ * Check if running test vs. live plugin.
2336
+ *
2337
+ * @author Vova Feldman (@svovaf)
2338
+ * @since 1.0.5
2339
+ *
2340
+ * @return bool
2341
+ */
2342
+ function is_live() {
2343
+ return $this->_plugin->is_live;
2344
+ }
2345
+
2346
+ /**
2347
+ * Check if the user skipped connecting the account with Freemius.
2348
+ *
2349
+ * @author Vova Feldman (@svovaf)
2350
+ * @since 1.0.7
2351
+ *
2352
+ * @return bool
2353
+ */
2354
+ function is_anonymous() {
2355
+ if ( ! isset( $this->_is_anonymous ) ) {
2356
+ if ( ! isset( $this->_storage->is_anonymous ) ) {
2357
+ // Not skipped.
2358
+ $this->_is_anonymous = false;
2359
+ } else if ( is_bool( $this->_storage->is_anonymous ) ) {
2360
+ // For back compatibility, since the variable was boolean before.
2361
+ $this->_is_anonymous = $this->_storage->is_anonymous;
2362
+
2363
+ // Upgrade stored data format to 1.1.3 format.
2364
+ $this->set_anonymous_mode( $this->_storage->is_anonymous );
2365
+ } else {
2366
+ // Version 1.1.3 and later.
2367
+ $this->_is_anonymous = $this->_storage->is_anonymous['is'];
2368
+ }
2369
+ }
2370
+
2371
+ return $this->_is_anonymous;
2372
+ }
2373
+
2374
+ /**
2375
+ * Check if user connected his account and install pending email activation.
2376
+ *
2377
+ * @author Vova Feldman (@svovaf)
2378
+ * @since 1.0.7
2379
+ *
2380
+ * @return bool
2381
+ */
2382
+ function is_pending_activation() {
2383
+ return $this->_storage->get( 'is_pending_activation', false );
2384
+ }
2385
+
2386
+ /**
2387
+ * Check if plugin must be WordPress.org compliant.
2388
+ *
2389
+ * @since 1.0.7
2390
+ *
2391
+ * @return bool
2392
+ */
2393
+ function is_org_repo_compliant() {
2394
+ return $this->_is_org_compliant;
2395
+ }
2396
+
2397
+ #region Daily Sync Cron ------------------------------------------------------------------
2398
+
2399
+ /**
2400
+ * @author Vova Feldman (@svovaf)
2401
+ * @since 1.1.7.3
2402
+ */
2403
+ private function run_manual_sync() {
2404
+ $this->require_pluggable_essentials();
2405
+
2406
+ if ( ! current_user_can( 'activate_plugins' ) ) {
2407
+ return;
2408
+ }
2409
+
2410
+ // Run manual sync.
2411
+ $this->_sync_cron();
2412
+
2413
+ // Reschedule next cron to run 24 hours from now (performance optimization).
2414
+ $this->clear_sync_cron();
2415
+
2416
+ $this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
2417
+ }
2418
+
2419
+ /**
2420
+ * Data sync cron job. Replaces the background sync non blocking HTTP request
2421
+ * that doesn't halt page loading.
2422
+ *
2423
+ * @author Vova Feldman (@svovaf)
2424
+ * @since 1.1.7.3
2425
+ */
2426
+ function _sync_cron() {
2427
+ $this->_logger->entrance();
2428
+
2429
+ // Store the last time data sync was executed.
2430
+ $this->_storage->sync_timestamp = time();
2431
+
2432
+ // Check if API is temporary down.
2433
+ if ( FS_Api::is_temporary_down() ) {
2434
+ return;
2435
+ }
2436
+
2437
+ // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
2438
+
2439
+ if ( $this->is_registered() ) {
2440
+ if ( $this->has_paid_plan() ) {
2441
+ // Initiate background plan sync.
2442
+ $this->_sync_license( true );
2443
+
2444
+ if ( $this->is_paying() ) {
2445
+ // Check for premium plugin updates.
2446
+ $this->_check_updates( true );
2447
+ }
2448
+ } else {
2449
+ // Sync install (only if something changed locally).
2450
+ $this->sync_install();
2451
+ }
2452
+ }
2453
+
2454
+ if ( ! $this->is_addon() && $this->_has_addons ) {
2455
+ // Sync add-ons collection.
2456
+ $this->_sync_addons( true );
2457
+ }
2458
+ }
2459
+
2460
+ /**
2461
+ * Check if sync was executed in the last $period of seconds.
2462
+ *
2463
+ * @author Vova Feldman (@svovaf)
2464
+ * @since 1.1.7.3
2465
+ *
2466
+ * @param int $period In seconds
2467
+ *
2468
+ * @return bool
2469
+ */
2470
+ private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
2471
+ if ( ! isset( $this->_storage->sync_timestamp ) ) {
2472
+ return false;
2473
+ }
2474
+
2475
+ return ( $this->_storage->sync_timestamp > ( WP_FS__SCRIPT_START_TIME - $period ) );
2476
+ }
2477
+
2478
+ /**
2479
+ * @author Vova Feldman (@svovaf)
2480
+ * @since 1.1.7.3
2481
+ *
2482
+ * @return bool
2483
+ */
2484
+ private function is_sync_cron_on() {
2485
+ /**
2486
+ * @var object $sync_cron_data
2487
+ */
2488
+ $sync_cron_data = $this->_storage->get( 'sync_cron', null );
2489
+
2490
+ return ( ! is_null( $sync_cron_data ) && true === $sync_cron_data->on );
2491
+ }
2492
+
2493
+ /**
2494
+ * @author Vova Feldman (@svovaf)
2495
+ * @since 1.1.7.3
2496
+ *
2497
+ * @param int $start_at Defaults to now.
2498
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise,
2499
+ * schedule job to start right away.
2500
+ */
2501
+ private function schedule_sync_cron( $start_at = WP_FS__SCRIPT_START_TIME, $randomize_start = true ) {
2502
+ $this->_logger->entrance();
2503
+
2504
+ if ( $randomize_start ) {
2505
+ // Schedule first sync with a random 12 hour time range from now.
2506
+ $start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
2507
+ }
2508
+
2509
+ // Schedule daily WP cron.
2510
+ wp_schedule_event(
2511
+ $start_at,
2512
+ 'daily',
2513
+ $this->get_action_tag( 'data_sync' )
2514
+ );
2515
+
2516
+ $this->_storage->store( 'sync_cron', (object) array(
2517
+ 'version' => $this->get_plugin_version(),
2518
+ 'sdk_version' => $this->version,
2519
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
2520
+ 'on' => true,
2521
+ ) );
2522
+ }
2523
+
2524
+ /**
2525
+ * Add the actual sync function to the cron job hook.
2526
+ *
2527
+ * @author Vova Feldman (@svovaf)
2528
+ * @since 1.1.7.3
2529
+ */
2530
+ private function hook_callback_to_sync_cron() {
2531
+ $this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
2532
+ }
2533
+
2534
+ /**
2535
+ * @author Vova Feldman (@svovaf)
2536
+ * @since 1.1.7.3
2537
+ */
2538
+ private function clear_sync_cron() {
2539
+ $this->_logger->entrance();
2540
+
2541
+ if ( ! $this->is_sync_cron_on() ) {
2542
+ return;
2543
+ }
2544
+
2545
+ $this->_storage->remove( 'sync_cron' );
2546
+
2547
+ wp_clear_scheduled_hook( $this->get_action_tag( 'data_sync' ) );
2548
+ }
2549
+
2550
+ /**
2551
+ * Unix timestamp for next sync cron execution or false if not scheduled.
2552
+ *
2553
+ * @author Vova Feldman (@svovaf)
2554
+ * @since 1.1.7.3
2555
+ *
2556
+ * @return int|false
2557
+ */
2558
+ function next_sync_cron() {
2559
+ $this->_logger->entrance();
2560
+
2561
+ if ( ! $this->is_sync_cron_on() ) {
2562
+ return false;
2563
+ }
2564
+
2565
+ return wp_next_scheduled( $this->get_action_tag( 'data_sync' ) );
2566
+ }
2567
+
2568
+ /**
2569
+ * Unix timestamp for previous sync cron execution or false if never executed.
2570
+ *
2571
+ * @author Vova Feldman (@svovaf)
2572
+ * @since 1.1.7.3
2573
+ *
2574
+ * @return int|false
2575
+ */
2576
+ function last_sync_cron() {
2577
+ $this->_logger->entrance();
2578
+
2579
+ return $this->_storage->get( 'sync_timestamp' );
2580
+ }
2581
+
2582
+ #endregion Daily Sync Cron ------------------------------------------------------------------
2583
+
2584
+ #region Async Install Sync ------------------------------------------------------------------
2585
+
2586
+ /**
2587
+ * @author Vova Feldman (@svovaf)
2588
+ * @since 1.1.7.3
2589
+ *
2590
+ * @return bool
2591
+ */
2592
+ private function is_install_sync_scheduled() {
2593
+ /**
2594
+ * @var object $cron_data
2595
+ */
2596
+ $cron_data = $this->_storage->get( 'install_sync_cron', null );
2597
+
2598
+ return ( ! is_null( $cron_data ) && true === $cron_data->on );
2599
+ }
2600
+
2601
+ /**
2602
+ * Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
2603
+ *
2604
+ * @author Vova Feldman (@svovaf)
2605
+ * @since 1.1.7.3
2606
+ */
2607
+ private function schedule_install_sync() {
2608
+ $this->_logger->entrance();
2609
+
2610
+ $this->clear_install_sync_cron();
2611
+
2612
+ // Schedule immediate install sync.
2613
+ wp_schedule_single_event(
2614
+ WP_FS__SCRIPT_START_TIME,
2615
+ $this->get_action_tag( 'install_sync' )
2616
+ );
2617
+
2618
+ $this->_storage->store( 'install_sync_cron', (object) array(
2619
+ 'version' => $this->get_plugin_version(),
2620
+ 'sdk_version' => $this->version,
2621
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
2622
+ 'on' => true,
2623
+ ) );
2624
+ }
2625
+
2626
+ /**
2627
+ * Unix timestamp for previous install sync cron execution or false if never executed.
2628
+ *
2629
+ * @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being
2630
+ * updated. But for sure the sync event is working.
2631
+ *
2632
+ * @author Vova Feldman (@svovaf)
2633
+ * @since 1.1.7.3
2634
+ *
2635
+ * @return int|false
2636
+ */
2637
+ function last_install_sync() {
2638
+ $this->_logger->entrance();
2639
+
2640
+ return $this->_storage->get( 'install_sync_timestamp' );
2641
+ }
2642
+
2643
+ /**
2644
+ * Unix timestamp for next install sync cron execution or false if not scheduled.
2645
+ *
2646
+ * @author Vova Feldman (@svovaf)
2647
+ * @since 1.1.7.3
2648
+ *
2649
+ * @return int|false
2650
+ */
2651
+ function next_install_sync() {
2652
+ $this->_logger->entrance();
2653
+
2654
+ if ( ! $this->is_install_sync_scheduled() ) {
2655
+ return false;
2656
+ }
2657
+
2658
+ return wp_next_scheduled( $this->get_action_tag( 'install_sync' ) );
2659
+ }
2660
+
2661
+ /**
2662
+ * Add the actual install sync function to the cron job hook.
2663
+ *
2664
+ * @author Vova Feldman (@svovaf)
2665
+ * @since 1.1.7.3
2666
+ */
2667
+ private function hook_callback_to_install_sync() {
2668
+ $this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
2669
+ }
2670
+
2671
+ /**
2672
+ * @author Vova Feldman (@svovaf)
2673
+ * @since 1.1.7.3
2674
+ */
2675
+ private function clear_install_sync_cron() {
2676
+ $this->_logger->entrance();
2677
+
2678
+ if ( ! $this->is_install_sync_scheduled() ) {
2679
+ return;
2680
+ }
2681
+
2682
+ $this->_storage->remove( 'install_sync_cron' );
2683
+
2684
+ wp_clear_scheduled_hook( $this->get_action_tag( 'install_sync' ) );
2685
+ }
2686
+
2687
+ /**
2688
+ * @author Vova Feldman (@svovaf)
2689
+ * @since 1.1.7.3
2690
+ */
2691
+ public function _run_sync_install() {
2692
+ $this->_logger->entrance();
2693
+
2694
+ // Update last install sync timestamp.
2695
+ $this->_storage->install_sync_timestamp = time();
2696
+
2697
+ $this->sync_install( array(), true );
2698
+ }
2699
+
2700
+ #endregion Async Install Sync ------------------------------------------------------------------
2701
+
2702
+ /**
2703
+ * Show a notice that activation is currently pending.
2704
+ *
2705
+ * @author Vova Feldman (@svovaf)
2706
+ * @since 1.0.7
2707
+ *
2708
+ * @param bool|string $email
2709
+ */
2710
+ function _add_pending_activation_notice( $email = false ) {
2711
+ if ( ! is_string( $email ) ) {
2712
+ $current_user = self::_get_current_wp_user();
2713
+ $email = $current_user->user_email;
2714
+ }
2715
+
2716
+ $this->_admin_notices->add_sticky(
2717
+ sprintf(
2718
+ __fs( 'pending-activation-message', $this->_slug ),
2719
+ '<b>' . $this->get_plugin_name() . '</b>',
2720
+ '<b>' . $email . '</b>'
2721
+ ),
2722
+ 'activation_pending',
2723
+ 'Thanks!'
2724
+ );
2725
+ }
2726
+
2727
+ /**
2728
+ * Check if currently in plugin activation.
2729
+ *
2730
+ * @author Vova Feldman (@svovaf)
2731
+ * @since 1.1.4
2732
+ *
2733
+ * @return bool
2734
+ */
2735
+ function is_plugin_activation() {
2736
+ return get_option( "fs_{$this->_slug}_activated", false );
2737
+ }
2738
+
2739
+ /**
2740
+ *
2741
+ * NOTE: admin_menu action executed before admin_init.
2742
+ *
2743
+ * @author Vova Feldman (@svovaf)
2744
+ * @since 1.0.7
2745
+ */
2746
+ function _admin_init_action() {
2747
+ /**
2748
+ * Automatically redirect to connect/activation page after plugin activation.
2749
+ *
2750
+ * @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
2751
+ */
2752
+ if ( $this->is_plugin_activation() ) {
2753
+ delete_option( "fs_{$this->_slug}_activated" );
2754
+
2755
+ if ( ! function_exists( 'is_network_admin' ) || ! is_network_admin() ) {
2756
+ $this->_redirect_on_activation_hook();
2757
+
2758
+ return;
2759
+ }
2760
+ }
2761
+
2762
+ if ( fs_request_is_action( $this->_slug . '_skip_activation' ) ) {
2763
+ check_admin_referer( $this->_slug . '_skip_activation' );
2764
+
2765
+ $this->skip_connection();
2766
+
2767
+ if ( fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) ) ) {
2768
+ exit();
2769
+ }
2770
+ }
2771
+
2772
+ if ( ! $this->is_addon() && ! $this->is_registered() && ! $this->is_anonymous() ) {
2773
+ if ( ! $this->is_pending_activation() ) {
2774
+ if ( ! $this->_menu->is_activation_page() ) {
2775
+ if ( $this->is_plugin_new_install() ) {
2776
+ // Show notice for new plugin installations.
2777
+ $this->_admin_notices->add(
2778
+ sprintf(
2779
+ __fs( 'you-are-step-away', $this->_slug ),
2780
+ sprintf( '<b><a href="%s">%s</a></b>',
2781
+ $this->get_activation_url(),
2782
+ sprintf( __fs( 'activate-x-now', $this->_slug ), $this->get_plugin_name() )
2783
+ )
2784
+ ),
2785
+ '',
2786
+ 'update-nag'
2787
+ );
2788
+ } else {
2789
+ if ( ! isset( $this->_storage->sticky_optin_added ) ) {
2790
+ $this->_storage->sticky_optin_added = true;
2791
+
2792
+ // Show notice for new plugin installations.
2793
+ $this->_admin_notices->add_sticky(
2794
+ sprintf(
2795
+ __fs( 'few-plugin-tweaks', $this->_slug ),
2796
+ sprintf( '<b><a href="%s">%s</a></b>',
2797
+ $this->get_activation_url(),
2798
+ sprintf( __fs( 'optin-x-now', $this->_slug ), $this->get_plugin_name() )
2799
+ )
2800
+ ),
2801
+ 'connect_account',
2802
+ '',
2803
+ 'update-nag'
2804
+ );
2805
+ }
2806
+
2807
+ if ( $this->has_filter( 'optin_pointer_element' ) ) {
2808
+ // Don't show admin nag if plugin update.
2809
+ wp_enqueue_script( 'wp-pointer' );
2810
+ wp_enqueue_style( 'wp-pointer' );
2811
+
2812
+ $this->_enqueue_connect_essentials();
2813
+
2814
+ add_action( 'admin_print_footer_scripts', array(
2815
+ $this,
2816
+ '_add_connect_pointer_script'
2817
+ ) );
2818
+ }
2819
+
2820
+ }
2821
+ }
2822
+ }
2823
+ }
2824
+
2825
+ $this->_add_upgrade_action_link();
2826
+ }
2827
+
2828
+ /**
2829
+ * Enqueue connect requires scripts and styles.
2830
+ *
2831
+ * @author Vova Feldman (@svovaf)
2832
+ * @since 1.1.4
2833
+ */
2834
+ function _enqueue_connect_essentials() {
2835
+ wp_enqueue_script( 'jquery' );
2836
+ wp_enqueue_script( 'json2' );
2837
+
2838
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
2839
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
2840
+
2841
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
2842
+ }
2843
+
2844
+ /**
2845
+ * Add connect / opt-in pointer.
2846
+ *
2847
+ * @author Vova Feldman (@svovaf)
2848
+ * @since 1.1.4
2849
+ */
2850
+ function _add_connect_pointer_script() {
2851
+ $vars = array( 'slug' => $this->_slug );
2852
+ $pointer_content = fs_get_template( 'connect.php', $vars );
2853
+ ?>
2854
+ <script type="text/javascript">// <![CDATA[
2855
+ jQuery(document).ready(function ($) {
2856
+ if ('undefined' !== typeof(jQuery().pointer)) {
2857
+
2858
+ var element = <?php echo $this->apply_filters('optin_pointer_element', '$("#non_existing_element");') ?>;
2859
+
2860
+ if (element.length > 0) {
2861
+ var optin = $(element).pointer($.extend(true, {}, {
2862
+ content : <?php echo json_encode($pointer_content) ?>,
2863
+ position : {
2864
+ edge : 'left',
2865
+ align: 'center'
2866
+ },
2867
+ buttons : function () {
2868
+ // Don't show pointer buttons.
2869
+ return '';
2870
+ },
2871
+ pointerWidth: 482
2872
+ }, <?php echo $this->apply_filters('optin_pointer_options_json', '{}') ?>));
2873
+
2874
+ <?php
2875
+ echo $this->apply_filters('optin_pointer_execute', "
2876
+
2877
+ optin.pointer('open');
2878
+
2879
+ // Tag the opt-in pointer with custom class.
2880
+ $('.wp-pointer #fs_connect')
2881
+ .parents('.wp-pointer.wp-pointer-top')
2882
+ .addClass('fs-opt-in-pointer');
2883
+
2884
+ ", 'element', 'optin') ?>
2885
+ }
2886
+ }
2887
+ });
2888
+ // ]]></script>
2889
+ <?php
2890
+ }
2891
+
2892
+ /**
2893
+ * Return current page's URL.
2894
+ *
2895
+ * @author Vova Feldman (@svovaf)
2896
+ * @since 1.0.7
2897
+ *
2898
+ * @return string
2899
+ */
2900
+ function current_page_url() {
2901
+ $url = 'http';
2902
+
2903
+ if ( isset( $_SERVER["HTTPS"] ) ) {
2904
+ if ( $_SERVER["HTTPS"] == "on" ) {
2905
+ $url .= "s";
2906
+ }
2907
+ }
2908
+ $url .= "://";
2909
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
2910
+ $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
2911
+ } else {
2912
+ $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
2913
+ }
2914
+
2915
+ return esc_url( $url );
2916
+ }
2917
+
2918
+ /**
2919
+ * Check if the current page is the plugin's main admin settings page.
2920
+ *
2921
+ * @author Vova Feldman (@svovaf)
2922
+ * @since 1.0.7
2923
+ *
2924
+ * @return bool
2925
+ */
2926
+ function _is_plugin_page() {
2927
+ return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
2928
+ fs_is_plugin_page( $this->_slug );
2929
+ }
2930
+
2931
+ /* Events
2932
+ ------------------------------------------------------------------------------------------------------------------*/
2933
+ /**
2934
+ * Delete site install from Database.
2935
+ *
2936
+ * @author Vova Feldman (@svovaf)
2937
+ * @since 1.0.1
2938
+ *
2939
+ * @param bool $store
2940
+ */
2941
+ function _delete_site( $store = true ) {
2942
+ $sites = self::get_all_sites();
2943
+
2944
+ if ( isset( $sites[ $this->_slug ] ) ) {
2945
+ unset( $sites[ $this->_slug ] );
2946
+ }
2947
+
2948
+ self::$_accounts->set_option( 'sites', $sites, $store );
2949
+ }
2950
+
2951
+ /**
2952
+ * Delete plugin's plans information.
2953
+ *
2954
+ * @param bool $store Flush to Database if true.
2955
+ *
2956
+ * @author Vova Feldman (@svovaf)
2957
+ * @since 1.0.9
2958
+ */
2959
+ private function _delete_plans( $store = true ) {
2960
+ $this->_logger->entrance();
2961
+
2962
+ $plans = self::get_all_plans();
2963
+
2964
+ unset( $plans[ $this->_slug ] );
2965
+
2966
+ self::$_accounts->set_option( 'plans', $plans, $store );
2967
+ }
2968
+
2969
+ /**
2970
+ * Delete all plugin licenses.
2971
+ *
2972
+ * @author Vova Feldman (@svovaf)
2973
+ * @since 1.0.9
2974
+ *
2975
+ * @param bool $store
2976
+ * @param string|bool $plugin_slug
2977
+ */
2978
+ private function _delete_licenses( $store = true, $plugin_slug = false ) {
2979
+ $this->_logger->entrance();
2980
+
2981
+ $all_licenses = self::get_all_licenses();
2982
+
2983
+ if ( ! is_string( $plugin_slug ) ) {
2984
+ $plugin_slug = $this->_slug;
2985
+ }
2986
+
2987
+ unset( $all_licenses[ $plugin_slug ] );
2988
+
2989
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
2990
+ }
2991
+
2992
+ /**
2993
+ * Check if Freemius was added on new plugin installation.
2994
+ *
2995
+ * @author Vova Feldman (@svovaf)
2996
+ * @since 1.1.5
2997
+ *
2998
+ * @return bool
2999
+ */
3000
+ function is_plugin_new_install() {
3001
+ return isset( $this->_storage->is_plugin_new_install ) &&
3002
+ $this->_storage->is_plugin_new_install;
3003
+ }
3004
+
3005
+ /**
3006
+ * Plugin activated hook.
3007
+ *
3008
+ * @author Vova Feldman (@svovaf)
3009
+ * @since 1.0.1
3010
+ *
3011
+ * @uses FS_Api
3012
+ */
3013
+ function _activate_plugin_event_hook() {
3014
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
3015
+
3016
+ if ( ! current_user_can( 'activate_plugins' ) ) {
3017
+ return;
3018
+ }
3019
+
3020
+ // Clear API cache on activation.
3021
+ FS_Api::clear_cache();
3022
+
3023
+ if ( $this->is_registered() ) {
3024
+ // Schedule re-activation event and sync.
3025
+ // $this->sync_install( array(), true );
3026
+ $this->schedule_install_sync();
3027
+
3028
+ /**
3029
+ * @todo Work on automatic deactivation of the Free plugin version. It doesn't work since the slug of the free & premium versions is identical. Therefore, only one instance of Freemius is created and the activation hook of the premium version is not being added.
3030
+ */
3031
+ if ( $this->_plugin_basename !== $this->_free_plugin_basename ) {
3032
+ // Deactivate Free plugin version on premium plugin activation.
3033
+ deactivate_plugins( $this->_free_plugin_basename );
3034
+
3035
+ $this->_admin_notices->add(
3036
+ sprintf( __fs( 'successful-version-upgrade-message', $this->_slug ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
3037
+ __fs( 'woot', $this->_slug ) . '!'
3038
+ );
3039
+ }
3040
+ } else if ( $this->is_anonymous() ) {
3041
+ /**
3042
+ * Reset "skipped" click cache on the following:
3043
+ * 1. Development mode.
3044
+ * 2. If the user skipped the exact same version before.
3045
+ *
3046
+ * @todo 3. If explicitly asked to retry after every activation.
3047
+ */
3048
+ if ( WP_FS__DEV_MODE ||
3049
+ $this->get_plugin_version() == $this->_storage->is_anonymous['version']
3050
+ ) {
3051
+ $this->reset_anonymous_mode();
3052
+ }
3053
+ }
3054
+
3055
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
3056
+ /**
3057
+ * If no previous version of plugin's version exist, it means that it's either
3058
+ * the first time that the plugin installed on the site, or the plugin was installed
3059
+ * before but didn't have Freemius integrated.
3060
+ *
3061
+ * Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
3062
+ * on manual activation via the dashboard, is_plugin_activation() is TRUE
3063
+ * only after immediate activation.
3064
+ *
3065
+ * @since 1.1.4
3066
+ * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
3067
+ */
3068
+ $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
3069
+ }
3070
+
3071
+ if ( ! $this->_anonymous_mode && $this->has_api_connectivity( WP_FS__DEV_MODE ) ) {
3072
+ // Store hint that the plugin was just activated to enable auto-redirection to settings.
3073
+ add_option( "fs_{$this->_slug}_activated", true );
3074
+ }
3075
+ }
3076
+
3077
+ /**
3078
+ * Delete account.
3079
+ *
3080
+ * @author Vova Feldman (@svovaf)
3081
+ * @since 1.0.3
3082
+ *
3083
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
3084
+ */
3085
+ function delete_account_event( $check_user = true ) {
3086
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
3087
+
3088
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
3089
+ return;
3090
+ }
3091
+
3092
+ $this->do_action( 'before_account_delete' );
3093
+
3094
+ // Clear all admin notices.
3095
+ $this->_admin_notices->clear_all_sticky();
3096
+
3097
+ $this->_delete_site( false );
3098
+
3099
+ $this->_delete_plans( false );
3100
+
3101
+ $this->_delete_licenses( false );
3102
+
3103
+ // Delete add-ons related to plugin's account.
3104
+ $this->_delete_account_addons( false );
3105
+
3106
+ // @todo Delete plans and licenses of add-ons.
3107
+
3108
+ self::$_accounts->store();
3109
+
3110
+ /**
3111
+ * IMPORTANT:
3112
+ * Clear crons must be executed before clearing all storage.
3113
+ * Otherwise, the cron will not be cleared.
3114
+ */
3115
+ $this->clear_sync_cron();
3116
+ $this->clear_install_sync_cron();
3117
+
3118
+ // Clear all storage data.
3119
+ $this->_storage->clear_all( true, array(
3120
+ 'connectivity_test',
3121
+ 'is_on',
3122
+ ) );
3123
+
3124
+ // Send delete event.
3125
+ $this->get_api_site_scope()->call( '/', 'delete' );
3126
+
3127
+ $this->do_action( 'after_account_delete' );
3128
+ }
3129
+
3130
+ /**
3131
+ * Plugin deactivation hook.
3132
+ *
3133
+ * @author Vova Feldman (@svovaf)
3134
+ * @since 1.0.1
3135
+ */
3136
+ function _deactivate_plugin_hook() {
3137
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
3138
+
3139
+ if ( ! current_user_can( 'activate_plugins' ) ) {
3140
+ return;
3141
+ }
3142
+
3143
+ $this->_admin_notices->clear_all_sticky();
3144
+ if ( isset( $this->_storage->sticky_optin_added ) ) {
3145
+ unset( $this->_storage->sticky_optin_added );
3146
+ }
3147
+
3148
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
3149
+ // Remember that plugin was already installed.
3150
+ $this->_storage->is_plugin_new_install = false;
3151
+ }
3152
+
3153
+ $this->clear_sync_cron();
3154
+ $this->clear_install_sync_cron();
3155
+
3156
+ if ( $this->is_registered() ) {
3157
+ // Send deactivation event.
3158
+ $this->sync_install( array(
3159
+ 'is_active' => false,
3160
+ ) );
3161
+ } else {
3162
+ if ( ! $this->has_api_connectivity() ) {
3163
+ // Reset connectivity test cache.
3164
+ unset( $this->_storage->connectivity_test );
3165
+ }
3166
+ }
3167
+
3168
+ // Clear API cache on deactivation.
3169
+ FS_Api::clear_cache();
3170
+
3171
+ $this->remove_sdk_reference();
3172
+ }
3173
+
3174
+ /**
3175
+ * @author Vova Feldman (@svovaf)
3176
+ * @since 1.1.6
3177
+ */
3178
+ private function remove_sdk_reference() {
3179
+ global $fs_active_plugins;
3180
+
3181
+ foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) {
3182
+ if ( $this->_plugin_basename == $data->plugin_path ) {
3183
+ unset( $fs_active_plugins->plugins[ $sdk_path ] );
3184
+ break;
3185
+ }
3186
+ }
3187
+
3188
+ fs_fallback_to_newest_active_sdk();
3189
+ }
3190
+
3191
+ /**
3192
+ * @author Vova Feldman (@svovaf)
3193
+ * @since 1.1.3
3194
+ *
3195
+ * @param bool $is_anonymous
3196
+ */
3197
+ private function set_anonymous_mode( $is_anonymous = true ) {
3198
+ // Store information regarding skip to try and opt-in the user
3199
+ // again in the future.
3200
+ $this->_storage->is_anonymous = array(
3201
+ 'is' => $is_anonymous,
3202
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
3203
+ 'version' => $this->get_plugin_version(),
3204
+ );
3205
+
3206
+ // Update anonymous mode cache.
3207
+ $this->_is_anonymous = $is_anonymous;
3208
+ }
3209
+
3210
+ /**
3211
+ * @author Vova Feldman (@svovaf)
3212
+ * @since 1.1.3
3213
+ */
3214
+ private function reset_anonymous_mode() {
3215
+ unset( $this->_storage->is_anonymous );
3216
+ }
3217
+
3218
+ /**
3219
+ * Clears the anonymous mode and redirects to the opt-in screen.
3220
+ *
3221
+ * @author Vova Feldman (@svovaf)
3222
+ * @since 1.1.7
3223
+ */
3224
+ function connect_again() {
3225
+ if ( ! $this->is_anonymous() ) {
3226
+ return;
3227
+ }
3228
+
3229
+ $this->reset_anonymous_mode();
3230
+
3231
+ if ( fs_redirect( $this->get_activation_url() ) ) {
3232
+ exit();
3233
+ }
3234
+ }
3235
+
3236
+ /**
3237
+ * Skip account connect, and set anonymous mode.
3238
+ *
3239
+ * @author Vova Feldman (@svovaf)
3240
+ * @since 1.1.1
3241
+ */
3242
+ private function skip_connection() {
3243
+ $this->_logger->entrance();
3244
+
3245
+ $this->_admin_notices->remove_sticky( 'connect_account' );
3246
+
3247
+ $this->set_anonymous_mode();
3248
+
3249
+ // Send anonymous skip event.
3250
+ // No user identified info nor any tracking will be sent after the user skips the opt-in.
3251
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
3252
+ 'uid' => $this->get_anonymous_id(),
3253
+ ) );
3254
+ }
3255
+
3256
+ /**
3257
+ * Plugin version update hook.
3258
+ *
3259
+ * @author Vova Feldman (@svovaf)
3260
+ * @since 1.0.4
3261
+ */
3262
+ private function update_plugin_version_event() {
3263
+ $this->_logger->entrance();
3264
+
3265
+ if ( ! $this->is_registered() ) {
3266
+ return;
3267
+ }
3268
+
3269
+ $this->schedule_install_sync();
3270
+ // $this->sync_install( array(), true );
3271
+ }
3272
+
3273
+ /**
3274
+ * Update install details.
3275
+ *
3276
+ * @author Vova Feldman (@svovaf)
3277
+ * @since 1.1.2
3278
+ *
3279
+ * @param string[] string $override
3280
+ *
3281
+ * @return array
3282
+ */
3283
+ private function get_install_data_for_api( $override = array() ) {
3284
+ return array_merge( array(
3285
+ 'version' => $this->get_plugin_version(),
3286
+ 'is_premium' => $this->is_premium(),
3287
+ 'language' => get_bloginfo( 'language' ),
3288
+ 'charset' => get_bloginfo( 'charset' ),
3289
+ 'platform_version' => get_bloginfo( 'version' ),
3290
+ 'programming_language_version' => phpversion(),
3291
+ 'title' => get_bloginfo( 'name' ),
3292
+ 'url' => get_site_url(),
3293
+ // Special params.
3294
+ 'is_active' => true,
3295
+ 'is_uninstalled' => false,
3296
+ ), $override );
3297
+ }
3298
+
3299
+ /**
3300
+ * Update install only if changed.
3301
+ *
3302
+ * @author Vova Feldman (@svovaf)
3303
+ * @since 1.0.9
3304
+ *
3305
+ * @param string[] string $override
3306
+ * @param bool $flush
3307
+ *
3308
+ * @return false|object|string
3309
+ */
3310
+ private function send_install_update( $override = array(), $flush = false ) {
3311
+ $this->_logger->entrance();
3312
+
3313
+ $check_properties = $this->get_install_data_for_api( $override );
3314
+
3315
+ if ( $flush ) {
3316
+ $params = $check_properties;
3317
+ } else {
3318
+ $params = array();
3319
+ $special = array();
3320
+ $special_override = false;
3321
+
3322
+ foreach ( $check_properties as $p => $v ) {
3323
+ if ( property_exists( $this->_site, $p ) ) {
3324
+ if ( ! empty( $this->_site->{$p} ) &&
3325
+ $this->_site->{$p} != $v
3326
+ ) {
3327
+ $this->_site->{$p} = $v;
3328
+ $params[ $p ] = $v;
3329
+ }
3330
+ } else {
3331
+ $special[ $p ] = $v;
3332
+
3333
+ if ( isset( $override[ $p ] ) ) {
3334
+ $special_override = true;
3335
+ }
3336
+ }
3337
+ }
3338
+
3339
+ if ( $special_override || 0 < count( $params ) ) {
3340
+ // Add special params only if has at least one
3341
+ // standard param, or if explicitly requested to
3342
+ // override a special param or a pram which is not exist
3343
+ // in the install object.
3344
+ $params = array_merge( $params, $special );
3345
+ }
3346
+ }
3347
+
3348
+ if ( 0 < count( $params ) ) {
3349
+ // Update last install sync timestamp.
3350
+ $this->_storage->install_sync_timestamp = time();
3351
+
3352
+ // Send updated values to FS.
3353
+ $site = $this->get_api_site_scope()->call( '/', 'put', $params );
3354
+
3355
+ if ( ! $this->is_api_error( $site ) ) {
3356
+ // I successfully sent install update, clear scheduled sync if exist.
3357
+ $this->clear_install_sync_cron();
3358
+ }
3359
+
3360
+ return $site;
3361
+ }
3362
+
3363
+ return false;
3364
+ }
3365
+
3366
+ /**
3367
+ * Update install only if changed.
3368
+ *
3369
+ * @author Vova Feldman (@svovaf)
3370
+ * @since 1.0.9
3371
+ *
3372
+ * @param string[] string $override
3373
+ * @param bool $flush
3374
+ *
3375
+ * @return false|object|string
3376
+ */
3377
+ private function sync_install( $override = array(), $flush = false ) {
3378
+ $this->_logger->entrance();
3379
+
3380
+ $site = $this->send_install_update( $override, $flush );
3381
+
3382
+ if ( false === $site ) {
3383
+ // No sync required.
3384
+ return;
3385
+ }
3386
+
3387
+ if ( $this->is_api_error( $site ) ) {
3388
+ // Failed to sync, don't update locally.
3389
+ return;
3390
+ }
3391
+
3392
+ $plan = $this->get_plan();
3393
+ $this->_site = new FS_Site( $site );
3394
+ $this->_site->plan = $plan;
3395
+
3396
+ $this->_store_site( true );
3397
+ }
3398
+
3399
+ /**
3400
+ * Plugin uninstall hook.
3401
+ *
3402
+ * @author Vova Feldman (@svovaf)
3403
+ * @since 1.0.1
3404
+ *
3405
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
3406
+ */
3407
+ function _uninstall_plugin_event( $check_user = true ) {
3408
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
3409
+
3410
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
3411
+ return;
3412
+ }
3413
+
3414
+ $params = array();
3415
+ if ( isset( $this->_storage->uninstall_reason ) ) {
3416
+ $params['reason_id'] = $this->_storage->uninstall_reason->id;
3417
+ $params['reason_info'] = $this->_storage->uninstall_reason->info;
3418
+ }
3419
+
3420
+ if ( ! $this->is_registered() && isset( $this->_storage->uninstall_reason ) ) {
3421
+ // Send anonymous uninstall event only if user submitted a feedback.
3422
+ $params['uid'] = $this->get_anonymous_id();
3423
+ $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
3424
+ } else {
3425
+ // Send uninstall event.
3426
+ $this->send_install_update( array_merge( $params, array(
3427
+ 'is_active' => false,
3428
+ 'is_uninstalled' => true,
3429
+ ) ) );
3430
+ }
3431
+
3432
+ // @todo Decide if we want to delete plugin information from db.
3433
+ }
3434
+
3435
+ /**
3436
+ * @author Vova Feldman (@svovaf)
3437
+ * @since 1.1.1
3438
+ *
3439
+ * @return string
3440
+ */
3441
+ private function premium_plugin_basename() {
3442
+ return preg_replace( '/\//', '-premium/', $this->_free_plugin_basename, 1 );
3443
+ }
3444
+
3445
+ /**
3446
+ * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
3447
+ *
3448
+ * @author Vova Feldman (@svovaf)
3449
+ * @since 1.0.2
3450
+ */
3451
+ public static function _uninstall_plugin_hook() {
3452
+ self::_load_required_static();
3453
+
3454
+ self::$_static_logger->entrance();
3455
+
3456
+ if ( ! current_user_can( 'activate_plugins' ) ) {
3457
+ return;
3458
+ }
3459
+
3460
+ $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
3461
+
3462
+ self::$_static_logger->info( 'plugin = ' . $plugin_file );
3463
+
3464
+ define( 'WP_FS__UNINSTALL_MODE', true );
3465
+
3466
+ $fs = self::get_instance_by_file( $plugin_file );
3467
+
3468
+ if ( is_object( $fs ) ) {
3469
+ self::require_plugin_essentials();
3470
+
3471
+ if ( is_plugin_active( $fs->_free_plugin_basename ) ||
3472
+ is_plugin_active( $fs->premium_plugin_basename() )
3473
+ ) {
3474
+ // Deleting Free or Premium plugin version while the other version still installed.
3475
+ return;
3476
+ }
3477
+
3478
+ $fs->_uninstall_plugin_event();
3479
+
3480
+ $fs->do_action( 'after_uninstall' );
3481
+ }
3482
+ }
3483
+
3484
+ #region Plugin Information ------------------------------------------------------------------
3485
+
3486
+ /**
3487
+ * Load WordPress core plugin.php essential module.
3488
+ *
3489
+ * @author Vova Feldman (@svovaf)
3490
+ * @since 1.1.1
3491
+ */
3492
+ private static function require_plugin_essentials() {
3493
+ if ( ! function_exists( 'get_plugins' ) ) {
3494
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
3495
+ }
3496
+ }
3497
+
3498
+ /**
3499
+ * Load WordPress core pluggable.php module.
3500
+ *
3501
+ * @author Vova Feldman (@svovaf)
3502
+ * @since 1.1.2
3503
+ */
3504
+ private static function require_pluggable_essentials() {
3505
+ if ( ! function_exists( 'wp_get_current_user' ) ) {
3506
+ require_once( ABSPATH . 'wp-includes/pluggable.php' );
3507
+ }
3508
+ }
3509
+
3510
+ /**
3511
+ * Return plugin data.
3512
+ *
3513
+ * @author Vova Feldman (@svovaf)
3514
+ * @since 1.0.1
3515
+ *
3516
+ * @return array
3517
+ */
3518
+ function get_plugin_data() {
3519
+ if ( ! isset( $this->_plugin_data ) ) {
3520
+ self::require_plugin_essentials();
3521
+
3522
+ $this->_plugin_data = get_plugin_data( $this->_plugin_main_file_path );
3523
+ }
3524
+
3525
+ return $this->_plugin_data;
3526
+ }
3527
+
3528
+ /**
3529
+ * @author Vova Feldman (@svovaf)
3530
+ * @since 1.0.1
3531
+ *
3532
+ * @return string Plugin slug.
3533
+ */
3534
+ function get_slug() {
3535
+ return $this->_slug;
3536
+ }
3537
+
3538
+ /**
3539
+ * @author Vova Feldman (@svovaf)
3540
+ * @since 1.0.1
3541
+ *
3542
+ * @return number Plugin ID.
3543
+ */
3544
+ function get_id() {
3545
+ return $this->_plugin->id;
3546
+ }
3547
+
3548
+ /**
3549
+ * @author Vova Feldman (@svovaf)
3550
+ * @since 1.0.1
3551
+ *
3552
+ * @return string Plugin public key.
3553
+ */
3554
+ function get_public_key() {
3555
+ return $this->_plugin->public_key;
3556
+ }
3557
+
3558
+ /**
3559
+ * Will be available only on sandbox mode.
3560
+ *
3561
+ * @author Vova Feldman (@svovaf)
3562
+ * @since 1.0.4
3563
+ *
3564
+ * @return mixed Plugin secret key.
3565
+ */
3566
+ function get_secret_key() {
3567
+ return $this->_plugin->secret_key;
3568
+ }
3569
+
3570
+ /**
3571
+ * @author Vova Feldman (@svovaf)
3572
+ * @since 1.1.1
3573
+ *
3574
+ * @return bool
3575
+ */
3576
+ function has_secret_key() {
3577
+ return ! empty( $this->_plugin->secret_key );
3578
+ }
3579
+
3580
+ /**
3581
+ * @author Vova Feldman (@svovaf)
3582
+ * @since 1.0.9
3583
+ *
3584
+ * @return string
3585
+ */
3586
+ function get_plugin_name() {
3587
+ $this->_logger->entrance();
3588
+
3589
+ if ( ! isset( $this->_plugin_name ) ) {
3590
+ $plugin_data = $this->get_plugin_data();
3591
+
3592
+ // Get name.
3593
+ $this->_plugin_name = $plugin_data['Name'];
3594
+
3595
+ // Check if plugin name contains [Premium] suffix and remove it.
3596
+ $suffix = '[premium]';
3597
+ $suffix_len = strlen( $suffix );
3598
+
3599
+ if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
3600
+ $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
3601
+ ) {
3602
+ $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
3603
+ }
3604
+
3605
+ $this->_logger->departure( 'Name = ' . $this->_plugin_name );
3606
+ }
3607
+
3608
+ return $this->_plugin_name;
3609
+ }
3610
+
3611
+ /**
3612
+ * @author Vova Feldman (@svovaf)
3613
+ * @since 1.0.0
3614
+ *
3615
+ * @return string
3616
+ */
3617
+ function get_plugin_version() {
3618
+ $this->_logger->entrance();
3619
+
3620
+ $plugin_data = $this->get_plugin_data();
3621
+
3622
+ $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
3623
+
3624
+ return $this->apply_filters( 'plugin_version', $plugin_data['Version'] );
3625
+ }
3626
+
3627
+ /**
3628
+ * @author Vova Feldman (@svovaf)
3629
+ * @since 1.0.4
3630
+ *
3631
+ * @return string
3632
+ */
3633
+ function get_plugin_basename() {
3634
+ return $this->_plugin_basename;
3635
+ }
3636
+
3637
+ function get_plugin_folder_name() {
3638
+ $this->_logger->entrance();
3639
+
3640
+ $plugin_folder = $this->_plugin_basename;
3641
+
3642
+ while ( '.' !== dirname( $plugin_folder ) ) {
3643
+ $plugin_folder = dirname( $plugin_folder );
3644
+ }
3645
+
3646
+ $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
3647
+
3648
+ return $plugin_folder;
3649
+ }
3650
+
3651
+ #endregion ------------------------------------------------------------------
3652
+
3653
+ /* Account
3654
+ ------------------------------------------------------------------------------------------------------------------*/
3655
+
3656
+ /**
3657
+ * Find plugin's slug by plugin's basename.
3658
+ *
3659
+ * @author Vova Feldman (@svovaf)
3660
+ * @since 1.0.9
3661
+ *
3662
+ * @param string $plugin_base_name
3663
+ *
3664
+ * @return false|string
3665
+ */
3666
+ private static function find_slug_by_basename( $plugin_base_name ) {
3667
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
3668
+
3669
+ if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
3670
+ return false;
3671
+ }
3672
+
3673
+ return $file_slug_map[ $plugin_base_name ];
3674
+ }
3675
+
3676
+ /**
3677
+ * Store the map between the plugin's basename to the slug.
3678
+ *
3679
+ * @author Vova Feldman (@svovaf)
3680
+ * @since 1.0.9
3681
+ */
3682
+ private function store_file_slug_map() {
3683
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
3684
+
3685
+ if ( ! array( $file_slug_map ) ) {
3686
+ $file_slug_map = array();
3687
+ }
3688
+
3689
+ if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
3690
+ $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
3691
+ ) {
3692
+ $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
3693
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
3694
+ }
3695
+ }
3696
+
3697
+ /**
3698
+ * @return FS_User[]
3699
+ */
3700
+ static function get_all_users() {
3701
+ $users = self::$_accounts->get_option( 'users', array() );
3702
+
3703
+ if ( ! is_array( $users ) ) {
3704
+ $users = array();
3705
+ }
3706
+
3707
+ return $users;
3708
+ }
3709
+
3710
+ /**
3711
+ * @return FS_Site[]
3712
+ */
3713
+ private static function get_all_sites() {
3714
+ $sites = self::$_accounts->get_option( 'sites', array() );
3715
+
3716
+ if ( ! is_array( $sites ) ) {
3717
+ $sites = array();
3718
+ }
3719
+
3720
+ return $sites;
3721
+ }
3722
+
3723
+ /**
3724
+ * @author Vova Feldman (@svovaf)
3725
+ * @since 1.0.6
3726
+ *
3727
+ * @return FS_Plugin_License[]
3728
+ */
3729
+ private static function get_all_licenses() {
3730
+ $licenses = self::$_accounts->get_option( 'licenses', array() );
3731
+
3732
+ if ( ! is_array( $licenses ) ) {
3733
+ $licenses = array();
3734
+ }
3735
+
3736
+ return $licenses;
3737
+ }
3738
+
3739
+ /**
3740
+ * @return FS_Plugin_Plan[]
3741
+ */
3742
+ private static function get_all_plans() {
3743
+ $plans = self::$_accounts->get_option( 'plans', array() );
3744
+
3745
+ if ( ! is_array( $plans ) ) {
3746
+ $plans = array();
3747
+ }
3748
+
3749
+ return $plans;
3750
+ }
3751
+
3752
+ /**
3753
+ * @author Vova Feldman (@svovaf)
3754
+ * @since 1.0.4
3755
+ *
3756
+ * @return FS_Plugin_Tag[]
3757
+ */
3758
+ private static function get_all_updates() {
3759
+ $updates = self::$_accounts->get_option( 'updates', array() );
3760
+
3761
+ if ( ! is_array( $updates ) ) {
3762
+ $updates = array();
3763
+ }
3764
+
3765
+ return $updates;
3766
+ }
3767
+
3768
+ /**
3769
+ * @author Vova Feldman (@svovaf)
3770
+ * @since 1.0.6
3771
+ *
3772
+ * @return FS_Plugin[]|false
3773
+ */
3774
+ private static function get_all_addons() {
3775
+ $addons = self::$_accounts->get_option( 'addons', array() );
3776
+
3777
+ if ( ! is_array( $addons ) ) {
3778
+ $addons = array();
3779
+ }
3780
+
3781
+ return $addons;
3782
+ }
3783
+
3784
+ /**
3785
+ * @author Vova Feldman (@svovaf)
3786
+ * @since 1.0.6
3787
+ *
3788
+ * @return FS_Plugin[]|false
3789
+ */
3790
+ private static function get_all_account_addons() {
3791
+ $addons = self::$_accounts->get_option( 'account_addons', array() );
3792
+
3793
+ if ( ! is_array( $addons ) ) {
3794
+ $addons = array();
3795
+ }
3796
+
3797
+ return $addons;
3798
+ }
3799
+
3800
+ /**
3801
+ * Check if user is registered.
3802
+ *
3803
+ * @author Vova Feldman (@svovaf)
3804
+ * @since 1.0.1
3805
+ * @return bool
3806
+ */
3807
+ function is_registered() {
3808
+ return is_object( $this->_user );
3809
+ }
3810
+
3811
+ /**
3812
+ * @author Vova Feldman (@svovaf)
3813
+ * @since 1.0.4
3814
+ *
3815
+ * @return FS_Plugin
3816
+ */
3817
+ function get_plugin() {
3818
+ return $this->_plugin;
3819
+ }
3820
+
3821
+ /**
3822
+ * @author Vova Feldman (@svovaf)
3823
+ * @since 1.0.3
3824
+ *
3825
+ * @return FS_User
3826
+ */
3827
+ function get_user() {
3828
+ return $this->_user;
3829
+ }
3830
+
3831
+ /**
3832
+ * @author Vova Feldman (@svovaf)
3833
+ * @since 1.0.3
3834
+ *
3835
+ * @return FS_Site
3836
+ */
3837
+ function get_site() {
3838
+ return $this->_site;
3839
+ }
3840
+
3841
+ /**
3842
+ * Get plugin add-ons.
3843
+ *
3844
+ * @author Vova Feldman (@svovaf)
3845
+ * @since 1.0.6
3846
+ *
3847
+ * @since 1.1.7.3 If not yet loaded, fetch data from the API.
3848
+ *
3849
+ * @return FS_Plugin[]|false
3850
+ */
3851
+ function get_addons() {
3852
+ $this->_logger->entrance();
3853
+
3854
+ $all_addons = self::get_all_addons();
3855
+
3856
+ /**
3857
+ * @since 1.1.7.3 If not yet loaded, fetch data from the API.
3858
+ */
3859
+ if ( ! is_array( $all_addons ) ||
3860
+ ! isset( $all_addons[ $this->_plugin->id ] ) ||
3861
+ ! is_array( $all_addons[ $this->_plugin->id ] ) ||
3862
+ empty( $all_addons[ $this->_plugin->id ] )
3863
+ ) {
3864
+ if ( $this->_has_addons ) {
3865
+ $addons = $this->_sync_addons();
3866
+
3867
+ if ( ! empty( $addons ) ) {
3868
+ $all_addons = self::get_all_addons();
3869
+ }
3870
+ }
3871
+ }
3872
+
3873
+ if ( ! is_array( $all_addons ) ||
3874
+ ! isset( $all_addons[ $this->_plugin->id ] ) ||
3875
+ ! is_array( $all_addons[ $this->_plugin->id ] ) ||
3876
+ empty( $all_addons[ $this->_plugin->id ] )
3877
+ ) {
3878
+ return false;
3879
+ }
3880
+
3881
+ return $all_addons[ $this->_plugin->id ];
3882
+ }
3883
+
3884
+ /**
3885
+ * @author Vova Feldman (@svovaf)
3886
+ * @since 1.0.6
3887
+ *
3888
+ * @return FS_Plugin[]|false
3889
+ */
3890
+ function get_account_addons() {
3891
+ $this->_logger->entrance();
3892
+
3893
+ $addons = self::get_all_account_addons();
3894
+
3895
+ if ( ! is_array( $addons ) ||
3896
+ ! isset( $addons[ $this->_plugin->id ] ) ||
3897
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
3898
+ 0 === count( $addons[ $this->_plugin->id ] )
3899
+ ) {
3900
+ return false;
3901
+ }
3902
+
3903
+ return $addons[ $this->_plugin->id ];
3904
+ }
3905
+
3906
+ /**
3907
+ * Check if user has any
3908
+ *
3909
+ * @author Vova Feldman (@svovaf)
3910
+ * @since 1.1.6
3911
+ *
3912
+ * @return bool
3913
+ */
3914
+ function has_account_addons() {
3915
+ $addons = $this->get_account_addons();
3916
+
3917
+ return is_array( $addons ) && ( 0 < count( $addons ) );
3918
+ }
3919
+
3920
+
3921
+ /**
3922
+ * Get add-on by ID (from local data).
3923
+ *
3924
+ * @author Vova Feldman (@svovaf)
3925
+ * @since 1.0.6
3926
+ *
3927
+ * @param number $id
3928
+ *
3929
+ * @return FS_Plugin|false
3930
+ */
3931
+ function get_addon( $id ) {
3932
+ $this->_logger->entrance();
3933
+
3934
+ $addons = $this->get_addons();
3935
+
3936
+ if ( is_array( $addons ) ) {
3937
+ foreach ( $addons as $addon ) {
3938
+ if ( $id == $addon->id ) {
3939
+ return $addon;
3940
+ }
3941
+ }
3942
+ }
3943
+
3944
+ return false;
3945
+ }
3946
+
3947
+ /**
3948
+ * Get add-on by slug (from local data).
3949
+ *
3950
+ * @author Vova Feldman (@svovaf)
3951
+ * @since 1.0.6
3952
+ *
3953
+ * @param string $slug
3954
+ *
3955
+ * @return FS_Plugin|false
3956
+ */
3957
+ function get_addon_by_slug( $slug ) {
3958
+ $this->_logger->entrance();
3959
+
3960
+ $addons = $this->get_addons();
3961
+
3962
+ if ( is_array( $addons ) ) {
3963
+ foreach ( $addons as $addon ) {
3964
+ if ( $slug == $addon->slug ) {
3965
+ return $addon;
3966
+ }
3967
+ }
3968
+ }
3969
+
3970
+ return false;
3971
+ }
3972
+
3973
+ #region Plans & Licensing ------------------------------------------------------------------
3974
+
3975
+ /**
3976
+ * Check if running premium plugin code.
3977
+ *
3978
+ * @author Vova Feldman (@svovaf)
3979
+ * @since 1.0.5
3980
+ *
3981
+ * @return bool
3982
+ */
3983
+ function is_premium() {
3984
+ return $this->_plugin->is_premium;
3985
+ }
3986
+
3987
+ /**
3988
+ * Get site's plan ID.
3989
+ *
3990
+ * @author Vova Feldman (@svovaf)
3991
+ * @since 1.0.2
3992
+ *
3993
+ * @return number
3994
+ */
3995
+ function get_plan_id() {
3996
+ return $this->_site->plan->id;
3997
+ }
3998
+
3999
+ /**
4000
+ * Get site's plan title.
4001
+ *
4002
+ * @author Vova Feldman (@svovaf)
4003
+ * @since 1.0.2
4004
+ *
4005
+ * @return string
4006
+ */
4007
+ function get_plan_title() {
4008
+ return $this->_site->plan->title;
4009
+ }
4010
+
4011
+ /**
4012
+ * @author Vova Feldman (@svovaf)
4013
+ * @since 1.0.9
4014
+ *
4015
+ * @return FS_Plugin_Plan
4016
+ */
4017
+ function get_plan() {
4018
+ return is_object( $this->_site->plan ) ? $this->_site->plan : false;
4019
+ }
4020
+
4021
+ /**
4022
+ * @author Vova Feldman (@svovaf)
4023
+ * @since 1.0.3
4024
+ *
4025
+ * @return bool
4026
+ */
4027
+ function is_trial() {
4028
+ $this->_logger->entrance();
4029
+
4030
+ if ( ! $this->is_registered() ) {
4031
+ return false;
4032
+ }
4033
+
4034
+ return $this->_site->is_trial();
4035
+ }
4036
+
4037
+ /**
4038
+ * Check if currently in a trial with payment method (credit card or paypal).
4039
+ *
4040
+ * @author Vova Feldman (@svovaf)
4041
+ * @since 1.1.7
4042
+ *
4043
+ * @return bool
4044
+ */
4045
+ function is_paid_trial() {
4046
+ $this->_logger->entrance();
4047
+
4048
+ if ( ! $this->is_trial() ) {
4049
+ return false;
4050
+ }
4051
+
4052
+ return $this->has_active_license() && ( $this->_site->trial_plan_id == $this->_license->plan_id );
4053
+ }
4054
+
4055
+ /**
4056
+ * Check if trial already utilized.
4057
+ *
4058
+ * @since 1.0.9
4059
+ *
4060
+ * @return bool
4061
+ */
4062
+ function is_trial_utilized() {
4063
+ $this->_logger->entrance();
4064
+
4065
+ if ( ! $this->is_registered() ) {
4066
+ return false;
4067
+ }
4068
+
4069
+ return $this->_site->is_trial_utilized();
4070
+ }
4071
+
4072
+ /**
4073
+ * Get trial plan information (if in trial).
4074
+ *
4075
+ * @author Vova Feldman (@svovaf)
4076
+ * @since 1.0.9
4077
+ *
4078
+ * @return bool|FS_Plugin_Plan
4079
+ */
4080
+ function get_trial_plan() {
4081
+ $this->_logger->entrance();
4082
+
4083
+ if ( ! $this->is_trial() ) {
4084
+ return false;
4085
+ }
4086
+
4087
+ return $this->_storage->trial_plan;
4088
+ }
4089
+
4090
+ /**
4091
+ * Check if the user has an activated and valid paid license on current plugin's install.
4092
+ *
4093
+ * @since 1.0.9
4094
+ *
4095
+ * @return bool
4096
+ */
4097
+ function is_paying() {
4098
+ $this->_logger->entrance();
4099
+
4100
+ if ( ! $this->is_registered() ) {
4101
+ return false;
4102
+ }
4103
+
4104
+ if ( ! $this->has_paid_plan() ) {
4105
+ return false;
4106
+ }
4107
+
4108
+ return (
4109
+ ! $this->is_trial() &&
4110
+ 'free' !== $this->_site->plan->name &&
4111
+ $this->has_features_enabled_license()
4112
+ );
4113
+ }
4114
+
4115
+ /**
4116
+ * @author Vova Feldman (@svovaf)
4117
+ * @since 1.0.4
4118
+ *
4119
+ * @return bool
4120
+ */
4121
+ function is_free_plan() {
4122
+ if ( ! $this->is_registered() ) {
4123
+ return true;
4124
+ }
4125
+
4126
+ if ( ! $this->has_paid_plan() ) {
4127
+ return true;
4128
+ }
4129
+
4130
+ return (
4131
+ 'free' === $this->_site->plan->name ||
4132
+ ! $this->has_features_enabled_license()
4133
+ );
4134
+ }
4135
+
4136
+ /**
4137
+ * @author Vova Feldman (@svovaf)
4138
+ * @since 1.0.5
4139
+ *
4140
+ * @return bool
4141
+ */
4142
+ function _has_premium_license() {
4143
+ $this->_logger->entrance();
4144
+
4145
+ $premium_license = $this->_get_available_premium_license();
4146
+
4147
+ return ( false !== $premium_license );
4148
+ }
4149
+
4150
+ /**
4151
+ * Check if user has any licenses associated with the plugin (including expired or blocking).
4152
+ *
4153
+ * @author Vova Feldman (@svovaf)
4154
+ * @since 1.1.7.3
4155
+ *
4156
+ * @return bool
4157
+ */
4158
+ private function has_any_license() {
4159
+ return is_array( $this->_licenses ) && ( 0 < count( $this->_licenses ) );
4160
+ }
4161
+
4162
+ /**
4163
+ * @author Vova Feldman (@svovaf)
4164
+ * @since 1.0.5
4165
+ *
4166
+ * @return FS_Plugin_License
4167
+ */
4168
+ function _get_available_premium_license() {
4169
+ $this->_logger->entrance();
4170
+
4171
+ if ( ! $this->has_paid_plan() ) {
4172
+ return false;
4173
+ }
4174
+
4175
+ if ( is_array( $this->_licenses ) ) {
4176
+ foreach ( $this->_licenses as $license ) {
4177
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
4178
+ return $license;
4179
+ }
4180
+ }
4181
+ }
4182
+
4183
+ return false;
4184
+ }
4185
+
4186
+ /**
4187
+ * Sync local plugin plans with remote server.
4188
+ *
4189
+ * @author Vova Feldman (@svovaf)
4190
+ * @since 1.0.5
4191
+ *
4192
+ * @return FS_Plugin_Plan[]|object
4193
+ */
4194
+ function _sync_plans() {
4195
+ $plans = $this->_fetch_plugin_plans();
4196
+ if ( ! $this->is_api_error( $plans ) ) {
4197
+ $this->_plans = $plans;
4198
+ $this->_store_plans();
4199
+ }
4200
+
4201
+ $this->do_action( 'after_plans_sync', $plans );
4202
+
4203
+ return $this->_plans;
4204
+ }
4205
+
4206
+ /**
4207
+ * @author Vova Feldman (@svovaf)
4208
+ * @since 1.0.5
4209
+ *
4210
+ * @param number $id
4211
+ *
4212
+ * @return FS_Plugin_Plan
4213
+ */
4214
+ function _get_plan_by_id( $id ) {
4215
+ $this->_logger->entrance();
4216
+
4217
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
4218
+ $this->_sync_plans();
4219
+ }
4220
+
4221
+ foreach ( $this->_plans as $plan ) {
4222
+ if ( $id == $plan->id ) {
4223
+ return $plan;
4224
+ }
4225
+ }
4226
+
4227
+ return false;
4228
+ }
4229
+
4230
+ /**
4231
+ * Sync local plugin plans with remote server.
4232
+ *
4233
+ * @author Vova Feldman (@svovaf)
4234
+ * @since 1.0.6
4235
+ *
4236
+ * @return FS_Plugin_License[]|object
4237
+ */
4238
+ function _sync_licenses() {
4239
+ $licenses = $this->_fetch_licenses();
4240
+ if ( ! $this->is_api_error( $licenses ) ) {
4241
+ $this->_licenses = $licenses;
4242
+ $this->_store_licenses();
4243
+ }
4244
+
4245
+ // Update current license.
4246
+ if ( is_object( $this->_license ) ) {
4247
+ $this->_license = $this->_get_license_by_id( $this->_license->id );
4248
+ }
4249
+
4250
+ return $this->_licenses;
4251
+ }
4252
+
4253
+ /**
4254
+ * @author Vova Feldman (@svovaf)
4255
+ * @since 1.0.5
4256
+ *
4257
+ * @param number $id
4258
+ *
4259
+ * @return FS_Plugin_License
4260
+ */
4261
+ function _get_license_by_id( $id ) {
4262
+ $this->_logger->entrance();
4263
+
4264
+ if ( ! is_numeric( $id ) ) {
4265
+ return false;
4266
+ }
4267
+
4268
+ if ( ! is_array( $this->_licenses ) || 0 === count( $this->_licenses ) ) {
4269
+ $this->_sync_licenses();
4270
+ }
4271
+
4272
+ foreach ( $this->_licenses as $license ) {
4273
+ if ( $id == $license->id ) {
4274
+ return $license;
4275
+ }
4276
+ }
4277
+
4278
+ return false;
4279
+ }
4280
+
4281
+ /**
4282
+ * Sync site's license with user licenses.
4283
+ *
4284
+ * @author Vova Feldman (@svovaf)
4285
+ * @since 1.0.6
4286
+ *
4287
+ * @param FS_Plugin_License|null $new_license
4288
+ */
4289
+ function _update_site_license( $new_license ) {
4290
+ $this->_logger->entrance();
4291
+
4292
+ $this->_license = $new_license;
4293
+
4294
+ if ( ! is_object( $new_license ) ) {
4295
+ $this->_site->license_id = null;
4296
+ $this->_sync_site_subscription( null );
4297
+
4298
+ return;
4299
+ }
4300
+
4301
+ $this->_site->license_id = $this->_license->id;
4302
+
4303
+ if ( ! is_array( $this->_licenses ) ) {
4304
+ $this->_licenses = array();
4305
+ }
4306
+
4307
+ $is_license_found = false;
4308
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
4309
+ if ( $new_license->id == $this->_licenses[ $i ]->id ) {
4310
+ $this->_licenses[ $i ] = $new_license;
4311
+
4312
+ $is_license_found = true;
4313
+ break;
4314
+ }
4315
+ }
4316
+
4317
+ // If new license just append.
4318
+ if ( ! $is_license_found ) {
4319
+ $this->_licenses[] = $new_license;
4320
+ }
4321
+
4322
+ $this->_sync_site_subscription( $new_license );
4323
+ }
4324
+
4325
+ /**
4326
+ * Sync site's subscription.
4327
+ *
4328
+ * @author Vova Feldman (@svovaf)
4329
+ * @since 1.0.9
4330
+ *
4331
+ * @param FS_Plugin_License|null $license
4332
+ *
4333
+ * @return bool|\FS_Subscription
4334
+ */
4335
+ private function _sync_site_subscription( $license ) {
4336
+ if ( ! is_object( $license ) ) {
4337
+ unset( $this->_storage->subscription );
4338
+
4339
+ return false;
4340
+ }
4341
+
4342
+ // Load subscription details if not lifetime.
4343
+ $subscription = $license->is_lifetime() ?
4344
+ false :
4345
+ $this->_fetch_site_license_subscription();
4346
+
4347
+ if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
4348
+ $this->_storage->subscription = $subscription;
4349
+ } else {
4350
+ unset( $this->_storage->subscription );
4351
+ }
4352
+
4353
+ return $subscription;
4354
+ }
4355
+
4356
+ /**
4357
+ * @author Vova Feldman (@svovaf)
4358
+ * @since 1.0.6
4359
+ *
4360
+ * @return bool|\FS_Plugin_License
4361
+ */
4362
+ function _get_license() {
4363
+ return $this->_license;
4364
+ }
4365
+
4366
+ /**
4367
+ * @return bool|\FS_Subscription
4368
+ */
4369
+ function _get_subscription() {
4370
+ return isset( $this->_storage->subscription ) ?
4371
+ $this->_storage->subscription :
4372
+ false;
4373
+ }
4374
+
4375
+ /**
4376
+ * @author Vova Feldman (@svovaf)
4377
+ * @since 1.0.2
4378
+ *
4379
+ * @param string $plan Plan name
4380
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
4381
+ *
4382
+ * @return bool
4383
+ */
4384
+ function is_plan( $plan, $exact = false ) {
4385
+ $this->_logger->entrance();
4386
+
4387
+ if ( ! $this->is_registered() ) {
4388
+ return false;
4389
+ }
4390
+
4391
+ $plan = strtolower( $plan );
4392
+
4393
+ if ( $this->_site->plan->name === $plan ) // Exact plan.
4394
+ {
4395
+ return true;
4396
+ } else if ( $exact ) // Required exact, but plans are different.
4397
+ {
4398
+ return false;
4399
+ }
4400
+
4401
+ $current_plan_order = - 1;
4402
+ $required_plan_order = - 1;
4403
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
4404
+ if ( $plan === $this->_plans[ $i ]->name ) {
4405
+ $required_plan_order = $i;
4406
+ } else if ( $this->_site->plan->name === $this->_plans[ $i ]->name ) {
4407
+ $current_plan_order = $i;
4408
+ }
4409
+ }
4410
+
4411
+ return ( $current_plan_order > $required_plan_order );
4412
+ }
4413
+
4414
+ /**
4415
+ * Check if plan based on trial. If not in trial mode, should return false.
4416
+ *
4417
+ * @since 1.0.9
4418
+ *
4419
+ * @param string $plan Plan name
4420
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
4421
+ *
4422
+ * @return bool
4423
+ */
4424
+ function is_trial_plan( $plan, $exact = false ) {
4425
+ $this->_logger->entrance();
4426
+
4427
+ if ( ! $this->is_registered() ) {
4428
+ return false;
4429
+ }
4430
+
4431
+ if ( ! $this->is_trial() ) {
4432
+ return false;
4433
+ }
4434
+
4435
+ if ( ! isset( $this->_storage->trial_plan ) ) {
4436
+ // Store trial plan information.
4437
+ $this->_enrich_site_trial_plan( true );
4438
+ }
4439
+
4440
+ if ( $this->_storage->trial_plan->name === $plan ) // Exact plan.
4441
+ {
4442
+ return true;
4443
+ } else if ( $exact ) // Required exact, but plans are different.
4444
+ {
4445
+ return false;
4446
+ }
4447
+
4448
+ $current_plan_order = - 1;
4449
+ $required_plan_order = - 1;
4450
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
4451
+ if ( $plan === $this->_plans[ $i ]->name ) {
4452
+ $required_plan_order = $i;
4453
+ } else if ( $this->_storage->trial_plan->name === $this->_plans[ $i ]->name ) {
4454
+ $current_plan_order = $i;
4455
+ }
4456
+ }
4457
+
4458
+ return ( $current_plan_order > $required_plan_order );
4459
+ }
4460
+
4461
+ /**
4462
+ * Check if plugin has any paid plans.
4463
+ *
4464
+ * @author Vova Feldman (@svovaf)
4465
+ * @since 1.0.7
4466
+ *
4467
+ * @return bool
4468
+ */
4469
+ function has_paid_plan() {
4470
+ return $this->_has_paid_plans || FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
4471
+ }
4472
+
4473
+ /**
4474
+ * Check if plugin has any plan with a trail.
4475
+ *
4476
+ * @author Vova Feldman (@svovaf)
4477
+ * @since 1.0.9
4478
+ *
4479
+ * @return bool
4480
+ */
4481
+ function has_trial_plan() {
4482
+ if ( ! $this->is_registered() ) {
4483
+ return false;
4484
+ }
4485
+
4486
+ return $this->_storage->get( 'has_trial_plan', false );
4487
+ }
4488
+
4489
+ /**
4490
+ * Check if plugin has any free plan, or is it premium only.
4491
+ *
4492
+ * Note: If no plans configured, assume plugin is free.
4493
+ *
4494
+ * @author Vova Feldman (@svovaf)
4495
+ * @since 1.0.7
4496
+ *
4497
+ * @return bool
4498
+ */
4499
+ function has_free_plan() {
4500
+ return FS_Plan_Manager::instance()->has_free_plan( $this->_plans );
4501
+ }
4502
+
4503
+ #region URL Generators
4504
+
4505
+ /**
4506
+ * Alias to pricing_url().
4507
+ *
4508
+ * @author Vova Feldman (@svovaf)
4509
+ * @since 1.0.2
4510
+ *
4511
+ * @uses pricing_url()
4512
+ *
4513
+ * @param string $period Billing cycle
4514
+ * @param bool $is_trial
4515
+ *
4516
+ * @return string
4517
+ */
4518
+ function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
4519
+ return $this->pricing_url( $period, $is_trial );
4520
+ }
4521
+
4522
+ /**
4523
+ * @author Vova Feldman (@svovaf)
4524
+ * @since 1.0.9
4525
+ *
4526
+ * @uses get_upgrade_url()
4527
+ *
4528
+ * @return string
4529
+ */
4530
+ function get_trial_url() {
4531
+ return $this->get_upgrade_url( WP_FS__PERIOD_ANNUALLY, true );
4532
+ }
4533
+
4534
+ /**
4535
+ * Plugin's pricing URL.
4536
+ *
4537
+ * @author Vova Feldman (@svovaf)
4538
+ * @since 1.0.4
4539
+ *
4540
+ * @param string $billing_cycle Billing cycle
4541
+ *
4542
+ * @param bool $is_trial
4543
+ *
4544
+ * @return string
4545
+ */
4546
+ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
4547
+ $this->_logger->entrance();
4548
+
4549
+ $params = array(
4550
+ 'billing_cycle' => $billing_cycle
4551
+ );
4552
+
4553
+ if ( $is_trial ) {
4554
+ $params['trial'] = 'true';
4555
+ }
4556
+
4557
+ return $this->_get_admin_page_url( 'pricing', $params );
4558
+ }
4559
+
4560
+ /**
4561
+ * Checkout page URL.
4562
+ *
4563
+ * @author Vova Feldman (@svovaf)
4564
+ * @since 1.0.6
4565
+ *
4566
+ * @param string $billing_cycle Billing cycle
4567
+ * @param bool $is_trial
4568
+ * @param array $extra (optional) Extra parameters, override other query params.
4569
+ *
4570
+ * @return string
4571
+ */
4572
+ function checkout_url(
4573
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
4574
+ $is_trial = false,
4575
+ $extra = array()
4576
+ ) {
4577
+ $this->_logger->entrance();
4578
+
4579
+ $params = array(
4580
+ 'checkout' => 'true',
4581
+ 'billing_cycle' => $billing_cycle,
4582
+ );
4583
+
4584
+ if ( $is_trial ) {
4585
+ $params['trial'] = 'true';
4586
+ }
4587
+
4588
+ /**
4589
+ * Params in extra override other params.
4590
+ */
4591
+ $params = array_merge( $params, $extra );
4592
+
4593
+ return $this->_get_admin_page_url( 'pricing', $params );
4594
+ }
4595
+
4596
+ /**
4597
+ * Add-on checkout URL.
4598
+ *
4599
+ * @author Vova Feldman (@svovaf)
4600
+ * @since 1.1.7
4601
+ *
4602
+ * @param number $addon_id
4603
+ * @param number $pricing_id
4604
+ * @param string $billing_cycle
4605
+ * @param bool $is_trial
4606
+ *
4607
+ * @return string
4608
+ */
4609
+ function addon_checkout_url(
4610
+ $addon_id,
4611
+ $pricing_id,
4612
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
4613
+ $is_trial = false
4614
+ ) {
4615
+ return $this->checkout_url( $billing_cycle, $is_trial, array(
4616
+ 'plugin_id' => $addon_id,
4617
+ 'pricing_id' => $pricing_id,
4618
+ ) );
4619
+ }
4620
+
4621
+ #endregion
4622
+
4623
+ #endregion ------------------------------------------------------------------
4624
+
4625
+ /**
4626
+ * Check if plugin has any add-ons.
4627
+ *
4628
+ * @author Vova Feldman (@svovaf)
4629
+ * @since 1.0.5
4630
+ *
4631
+ * @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
4632
+ *
4633
+ * @return bool
4634
+ */
4635
+ function has_addons() {
4636
+ $this->_logger->entrance();
4637
+
4638
+ return $this->_has_addons;
4639
+ }
4640
+
4641
+ /**
4642
+ * Check if plugin can work in anonymous mode.
4643
+ *
4644
+ * @author Vova Feldman (@svovaf)
4645
+ * @since 1.0.9
4646
+ *
4647
+ * @return bool
4648
+ */
4649
+ function enable_anonymous() {
4650
+ return $this->_enable_anonymous;
4651
+ }
4652
+
4653
+ /**
4654
+ * Check if feature supported with current site's plan.
4655
+ *
4656
+ * @author Vova Feldman (@svovaf)
4657
+ * @since 1.0.1
4658
+ *
4659
+ * @todo IMPLEMENT
4660
+ *
4661
+ * @param number $feature_id
4662
+ *
4663
+ * @throws Exception
4664
+ */
4665
+ function is_feature_supported( $feature_id ) {
4666
+ throw new Exception( 'not implemented' );
4667
+ }
4668
+
4669
+ /**
4670
+ * @author Vova Feldman (@svovaf)
4671
+ * @since 1.0.1
4672
+ *
4673
+ * @return bool Is running in SSL/HTTPS
4674
+ */
4675
+ function is_ssl() {
4676
+ return WP_FS__IS_HTTPS;
4677
+ }
4678
+
4679
+ /**
4680
+ * @author Vova Feldman (@svovaf)
4681
+ * @since 1.0.9
4682
+ *
4683
+ * @return bool Is running in AJAX call.
4684
+ *
4685
+ * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
4686
+ */
4687
+ function is_ajax() {
4688
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
4689
+ }
4690
+
4691
+ /**
4692
+ * @author Vova Feldman (@svovaf)
4693
+ * @since 1.1.7
4694
+ *
4695
+ * @return bool
4696
+ */
4697
+ function is_cron() {
4698
+ return ( defined( 'DOING_CRON' ) && DOING_CRON );
4699
+ }
4700
+
4701
+ /**
4702
+ * Check if a real user is visiting the admin dashboard.
4703
+ *
4704
+ * @author Vova Feldman (@svovaf)
4705
+ * @since 1.1.7
4706
+ *
4707
+ * @return bool
4708
+ */
4709
+ function is_user_in_admin() {
4710
+ return is_admin() && ! $this->is_ajax() && ! $this->is_cron();
4711
+ }
4712
+
4713
+ /**
4714
+ * Check if running in HTTPS and if site's plan matching the specified plan.
4715
+ *
4716
+ * @param string $plan
4717
+ * @param bool $exact
4718
+ *
4719
+ * @return bool
4720
+ */
4721
+ function is_ssl_and_plan( $plan, $exact = false ) {
4722
+ return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
4723
+ }
4724
+
4725
+ /**
4726
+ * Construct plugin's settings page URL.
4727
+ *
4728
+ * @author Vova Feldman (@svovaf)
4729
+ * @since 1.0.4
4730
+ *
4731
+ * @param string $page
4732
+ * @param array $params
4733
+ *
4734
+ * @return string
4735
+ */
4736
+ function _get_admin_page_url( $page = '', $params = array() ) {
4737
+ if ( ! $this->_menu->is_top_level() ) {
4738
+ $parent_slug = $this->_menu->get_parent_slug();
4739
+ $menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
4740
+ $parent_slug :
4741
+ 'admin.php';
4742
+
4743
+ return add_query_arg( array_merge( $params, array(
4744
+ 'page' => $this->_menu->get_slug( $page ),
4745
+ ) ), admin_url( $menu_file, 'admin' ) );
4746
+ }
4747
+
4748
+ if ( $this->_menu->is_cpt() ) {
4749
+ if ( empty( $page ) && $this->is_activation_mode() ) {
4750
+ return add_query_arg( array_merge( $params, array(
4751
+ 'page' => $this->_menu->get_slug()
4752
+ ) ), admin_url( 'admin.php', 'admin' ) );
4753
+ } else {
4754
+ if ( ! empty( $page ) ) {
4755
+ $params['page'] = $this->_menu->get_slug( $page );
4756
+ }
4757
+
4758
+ return add_query_arg( $params, admin_url( $this->_menu->get_raw_slug(), 'admin' ) );
4759
+ }
4760
+ } else {
4761
+ return add_query_arg( array_merge( $params, array(
4762
+ 'page' => $this->_menu->get_slug( $page ),
4763
+ ) ), admin_url( 'admin.php', 'admin' ) );
4764
+ }
4765
+ }
4766
+
4767
+
4768
+ /**
4769
+ * Plugin's account URL.
4770
+ *
4771
+ * @author Vova Feldman (@svovaf)
4772
+ * @since 1.0.4
4773
+ *
4774
+ * @param bool|string $action
4775
+ * @param array $params
4776
+ *
4777
+ * @param bool $add_action_nonce
4778
+ *
4779
+ * @return string
4780
+ */
4781
+ function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
4782
+ if ( is_string( $action ) ) {
4783
+ $params['fs_action'] = $action;
4784
+ }
4785
+
4786
+ self::require_pluggable_essentials();
4787
+
4788
+ return ( $add_action_nonce && is_string( $action ) ) ?
4789
+ wp_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
4790
+ $this->_get_admin_page_url( 'account', $params );
4791
+ }
4792
+
4793
+ /**
4794
+ * Plugin's account URL.
4795
+ *
4796
+ * @author Vova Feldman (@svovaf)
4797
+ * @since 1.0.4
4798
+ *
4799
+ * @param bool|string $topic
4800
+ * @param bool|string $message
4801
+ *
4802
+ * @return string
4803
+ */
4804
+ function contact_url( $topic = false, $message = false ) {
4805
+ $params = array();
4806
+ if ( is_string( $topic ) ) {
4807
+ $params['topic'] = $topic;
4808
+ }
4809
+ if ( is_string( $message ) ) {
4810
+ $params['message'] = $message;
4811
+ }
4812
+
4813
+ if ( $this->is_addon() ) {
4814
+ $params['addon_id'] = $this->get_id();
4815
+
4816
+ return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
4817
+ } else {
4818
+ return $this->_get_admin_page_url( 'contact', $params );
4819
+ }
4820
+ }
4821
+
4822
+ /**
4823
+ * Add-on direct info URL.
4824
+ *
4825
+ * @author Vova Feldman (@svovaf)
4826
+ * @since 1.1.0
4827
+ *
4828
+ * @param string $slug
4829
+ *
4830
+ * @return string
4831
+ */
4832
+ function addon_url( $slug ) {
4833
+ return $this->_get_admin_page_url( 'addons', array(
4834
+ 'slug' => $slug
4835
+ ) );
4836
+ }
4837
+
4838
+ /* Logger
4839
+ ------------------------------------------------------------------------------------------------------------------*/
4840
+ /**
4841
+ * @param string $id
4842
+ * @param bool $prefix_slug
4843
+ *
4844
+ * @return FS_Logger
4845
+ */
4846
+ function get_logger( $id = '', $prefix_slug = true ) {
4847
+ return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
4848
+ }
4849
+
4850
+ /**
4851
+ * @param $id
4852
+ * @param bool $load_options
4853
+ * @param bool $prefix_slug
4854
+ *
4855
+ * @return FS_Option_Manager
4856
+ */
4857
+ function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
4858
+ return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
4859
+ }
4860
+
4861
+ /* Security
4862
+ ------------------------------------------------------------------------------------------------------------------*/
4863
+ private function _encrypt( $str ) {
4864
+ if ( is_null( $str ) ) {
4865
+ return null;
4866
+ }
4867
+
4868
+ return base64_encode( $str );
4869
+ }
4870
+
4871
+ private function _decrypt( $str ) {
4872
+ if ( is_null( $str ) ) {
4873
+ return null;
4874
+ }
4875
+
4876
+ return base64_decode( $str );
4877
+ }
4878
+
4879
+ /**
4880
+ * @author Vova Feldman (@svovaf)
4881
+ * @since 1.0.5
4882
+ *
4883
+ * @param FS_Entity $entity
4884
+ *
4885
+ * @return FS_Entity Return an encrypted clone entity.
4886
+ */
4887
+ private function _encrypt_entity( FS_Entity $entity ) {
4888
+ $clone = clone $entity;
4889
+ $props = get_object_vars( $entity );
4890
+
4891
+ foreach ( $props as $key => $val ) {
4892
+ $clone->{$key} = $this->_encrypt( $val );
4893
+ }
4894
+
4895
+ return $clone;
4896
+ }
4897
+
4898
+ /**
4899
+ * @author Vova Feldman (@svovaf)
4900
+ * @since 1.0.5
4901
+ *
4902
+ * @param FS_Entity $entity
4903
+ *
4904
+ * @return FS_Entity Return an decrypted clone entity.
4905
+ */
4906
+ private function _decrypt_entity( FS_Entity $entity ) {
4907
+ $clone = clone $entity;
4908
+ $props = get_object_vars( $entity );
4909
+
4910
+ foreach ( $props as $key => $val ) {
4911
+ $clone->{$key} = $this->_decrypt( $val );
4912
+ }
4913
+
4914
+ return $clone;
4915
+ }
4916
+
4917
+ /**
4918
+ * Tries to activate account based on POST params.
4919
+ *
4920
+ * @author Vova Feldman (@svovaf)
4921
+ * @since 1.0.2
4922
+ */
4923
+ function _activate_account() {
4924
+ if ( $this->is_registered() ) {
4925
+ // Already activated.
4926
+ return;
4927
+ }
4928
+
4929
+ self::_clean_admin_content_section();
4930
+
4931
+ if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
4932
+ // check_admin_referer( 'activate_' . $this->_plugin->public_key );
4933
+
4934
+ // Verify matching plugin details.
4935
+ if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
4936
+ return;
4937
+ }
4938
+
4939
+ $user = new FS_User();
4940
+ $user->id = fs_request_get( 'user_id' );
4941
+ $user->public_key = fs_request_get( 'user_public_key' );
4942
+ $user->secret_key = fs_request_get( 'user_secret_key' );
4943
+ $user->email = fs_request_get( 'user_email' );
4944
+ $user->first = fs_request_get( 'user_first' );
4945
+ $user->last = fs_request_get( 'user_last' );
4946
+ $user->is_verified = fs_request_get_bool( 'user_is_verified' );
4947
+
4948
+ $site = new FS_Site();
4949
+ $site->id = fs_request_get( 'install_id' );
4950
+ $site->public_key = fs_request_get( 'install_public_key' );
4951
+ $site->secret_key = fs_request_get( 'install_secret_key' );
4952
+ $site->plan->id = fs_request_get( 'plan_id' );
4953
+ $site->plan->title = fs_request_get( 'plan_title' );
4954
+ $site->plan->name = fs_request_get( 'plan_name' );
4955
+
4956
+ $plans = array();
4957
+ $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
4958
+ foreach ( $plans_data as $p ) {
4959
+ $plans[] = new FS_Plugin_Plan( $p );
4960
+ }
4961
+
4962
+ $this->_set_account( $user, $site, $plans );
4963
+
4964
+ // Reload the page with the keys.
4965
+ if ( fs_redirect( $this->_get_admin_page_url() ) ) {
4966
+ exit();
4967
+ }
4968
+ }
4969
+ }
4970
+
4971
+ /**
4972
+ * @author Vova Feldman (@svovaf)
4973
+ * @since 1.0.7
4974
+ *
4975
+ * @param string $email
4976
+ *
4977
+ * @return FS_User|bool
4978
+ */
4979
+ static function _get_user_by_email( $email ) {
4980
+ self::$_static_logger->entrance();
4981
+
4982
+ $email = trim( strtolower( $email ) );
4983
+ $users = self::get_all_users();
4984
+ if ( is_array( $users ) ) {
4985
+ foreach ( $users as $u ) {
4986
+ if ( $email === trim( strtolower( $u->email ) ) ) {
4987
+ return $u;
4988
+ }
4989
+ }
4990
+ }
4991
+
4992
+ return false;
4993
+ }
4994
+
4995
+ #region Account (Loading, Updates & Activation) ------------------------------------------------------------------
4996
+
4997
+ /***
4998
+ * Load account information (user + site).
4999
+ *
5000
+ * @author Vova Feldman (@svovaf)
5001
+ * @since 1.0.1
5002
+ */
5003
+ private function _load_account() {
5004
+ $this->_logger->entrance();
5005
+
5006
+ $this->do_action( 'before_account_load' );
5007
+
5008
+ $sites = self::get_all_sites();
5009
+ $users = self::get_all_users();
5010
+ $plans = self::get_all_plans();
5011
+ $licenses = self::get_all_licenses();
5012
+
5013
+ if ( $this->_logger->is_on() && is_admin() ) {
5014
+ $this->_logger->log( 'sites = ' . var_export( $sites, true ) );
5015
+ $this->_logger->log( 'users = ' . var_export( $users, true ) );
5016
+ $this->_logger->log( 'plans = ' . var_export( $plans, true ) );
5017
+ $this->_logger->log( 'licenses = ' . var_export( $licenses, true ) );
5018
+ }
5019
+
5020
+ $site = isset( $sites[ $this->_slug ] ) ? $sites[ $this->_slug ] : false;
5021
+
5022
+ if ( is_object( $site ) &&
5023
+ is_numeric( $site->id ) &&
5024
+ is_numeric( $site->user_id ) &&
5025
+ is_object( $site->plan )
5026
+ ) {
5027
+ // Load site.
5028
+ $this->_site = clone $site;
5029
+ $this->_site->plan = $this->_decrypt_entity( $this->_site->plan );
5030
+
5031
+ // Load relevant user.
5032
+ $this->_user = clone $users[ $this->_site->user_id ];
5033
+
5034
+ // Load plans.
5035
+ $this->_plans = $plans[ $this->_slug ];
5036
+ if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
5037
+ $this->_sync_plans( true );
5038
+ } else {
5039
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
5040
+ if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
5041
+ $this->_plans[ $i ] = $this->_decrypt_entity( $this->_plans[ $i ] );
5042
+ } else {
5043
+ unset( $this->_plans[ $i ] );
5044
+ }
5045
+ }
5046
+ }
5047
+
5048
+ // Load licenses.
5049
+ $this->_licenses = array();
5050
+ if ( is_array( $licenses ) &&
5051
+ isset( $licenses[ $this->_slug ] ) &&
5052
+ isset( $licenses[ $this->_slug ][ $this->_user->id ] )
5053
+ ) {
5054
+ $this->_licenses = $licenses[ $this->_slug ][ $this->_user->id ];
5055
+ }
5056
+
5057
+ $this->_license = $this->_get_license_by_id( $this->_site->license_id );
5058
+
5059
+ if ( $this->_site->version != $this->get_plugin_version() ) {
5060
+ // If stored install version is different than current installed plugin version,
5061
+ // then update plugin version event.
5062
+ $this->update_plugin_version_event();
5063
+ }
5064
+ }
5065
+
5066
+ $this->_register_account_hooks();
5067
+ }
5068
+
5069
+ /**
5070
+ * @author Vova Feldman (@svovaf)
5071
+ * @since 1.0.1
5072
+ *
5073
+ * @param FS_User $user
5074
+ * @param FS_Site $site
5075
+ * @param bool|array $plans
5076
+ */
5077
+ private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
5078
+ $site->slug = $this->_slug;
5079
+ $site->user_id = $user->id;
5080
+
5081
+ $this->_site = $site;
5082
+ $this->_user = $user;
5083
+ if ( false !== $plans ) {
5084
+ $this->_plans = $plans;
5085
+ }
5086
+
5087
+ $this->send_install_update();
5088
+
5089
+ $this->_store_account();
5090
+
5091
+ }
5092
+
5093
+ /**
5094
+ * @author Vova Feldman (@svovaf)
5095
+ * @since 1.1.7.4
5096
+ *
5097
+ * @param array $override_with
5098
+ *
5099
+ * @return array
5100
+ */
5101
+ function get_opt_in_params( $override_with = array() ) {
5102
+ $this->_logger->entrance();
5103
+
5104
+ $current_user = self::_get_current_wp_user();
5105
+
5106
+ $params = array(
5107
+ 'user_firstname' => $current_user->user_firstname,
5108
+ 'user_lastname' => $current_user->user_lastname,
5109
+ 'user_nickname' => $current_user->user_nicename,
5110
+ 'user_email' => $current_user->user_email,
5111
+ 'user_ip' => WP_FS__REMOTE_ADDR,
5112
+ 'plugin_slug' => $this->_slug,
5113
+ 'plugin_id' => $this->get_id(),
5114
+ 'plugin_public_key' => $this->get_public_key(),
5115
+ 'plugin_version' => $this->get_plugin_version(),
5116
+ 'return_url' => wp_nonce_url( $this->_get_admin_page_url(
5117
+ '',
5118
+ array( 'fs_action' => $this->_slug . '_activate_new' )
5119
+ ), $this->_slug . '_activate_new' ),
5120
+ 'account_url' => wp_nonce_url( $this->_get_admin_page_url(
5121
+ 'account',
5122
+ array( 'fs_action' => 'sync_user' )
5123
+ ), 'sync_user' ),
5124
+ 'site_uid' => $this->get_anonymous_id(),
5125
+ 'site_url' => get_site_url(),
5126
+ 'site_name' => get_bloginfo( 'name' ),
5127
+ 'platform_version' => get_bloginfo( 'version' ),
5128
+ 'php_version' => phpversion(),
5129
+ 'language' => get_bloginfo( 'language' ),
5130
+ 'charset' => get_bloginfo( 'charset' ),
5131
+ );
5132
+
5133
+ if ( WP_FS__SKIP_EMAIL_ACTIVATION && $this->has_secret_key() ) {
5134
+ // Even though rand() is known for its security issues,
5135
+ // the timestamp adds another layer of protection.
5136
+ // It would be very hard for an attacker to get the secret key form here.
5137
+ // Plus, this should never run in production since the secret should never
5138
+ // be included in the production version.
5139
+ $params['ts'] = WP_FS__SCRIPT_START_TIME;
5140
+ $params['salt'] = md5( uniqid( rand() ) );
5141
+ $params['secure'] = md5(
5142
+ $params['ts'] .
5143
+ $params['salt'] .
5144
+ $this->get_secret_key()
5145
+ );
5146
+ }
5147
+
5148
+ return array_merge( $params, $override_with );
5149
+ }
5150
+
5151
+ /**
5152
+ * @author Vova Feldman (@svovaf)
5153
+ * @since 1.1.7.4
5154
+ *
5155
+ * @param string|bool $email
5156
+ * @param string|bool $first
5157
+ * @param string|bool $last
5158
+ *
5159
+ * @return bool Is successful opt-in (or set to pending).
5160
+ */
5161
+ function opt_in( $email = false, $first = false, $last = false ) {
5162
+ $this->_logger->entrance();
5163
+
5164
+ if ( false === $email ) {
5165
+ $current_user = self::_get_current_wp_user();
5166
+ $email = $current_user->user_email;
5167
+ }
5168
+
5169
+ $fs_user = Freemius::_get_user_by_email( $email );
5170
+ if ( is_object( $fs_user ) && ! $this->is_pending_activation() ) {
5171
+ $this->install_with_current_user( false );
5172
+
5173
+ return true;
5174
+ }
5175
+
5176
+ $user_info = array();
5177
+ if ( ! empty( $email ) ) {
5178
+ $user_info['user_email'] = $email;
5179
+ }
5180
+ if ( ! empty( $first ) ) {
5181
+ $user_info['user_firstname'] = $first;
5182
+ }
5183
+ if ( ! empty( $last ) ) {
5184
+ $user_info['user_lastname'] = $last;
5185
+ }
5186
+
5187
+ $params = $this->get_opt_in_params( $user_info );
5188
+ $params['format'] = 'json';
5189
+
5190
+ $url = WP_FS__ADDRESS . '/action/service/user/install/';
5191
+ if ( isset( $_COOKIE['XDEBUG_SESSION'] ) ) {
5192
+ $url = add_query_arg( 'XDEBUG_SESSION', 'PHPSTORM', $url );
5193
+ }
5194
+
5195
+ $response = wp_remote_post( $url, array(
5196
+ 'method' => 'POST',
5197
+ 'body' => $params,
5198
+ 'timeout' => 15,
5199
+ ) );
5200
+
5201
+ if ( $response instanceof WP_Error ) {
5202
+ if ( 'https://' === substr( $url, 0, 8 ) &&
5203
+ isset( $response->errors ) &&
5204
+ isset( $response->errors['http_request_failed'] ) &&
5205
+ false !== strpos( $response->errors['http_request_failed'][0], 'sslv3 alert handshake' )
5206
+ ) {
5207
+ // Failed due to old version of cURL or Open SSL (SSLv3 is not supported by CloudFlare).
5208
+ $url = 'http://' . substr( $url, 8 );
5209
+
5210
+ $response = wp_remote_post( $url, array(
5211
+ 'method' => 'POST',
5212
+ 'body' => $params,
5213
+ 'timeout' => 15,
5214
+ ) );
5215
+ }
5216
+
5217
+ if ( $response instanceof WP_Error ) {
5218
+ return false;
5219
+ }
5220
+ }
5221
+
5222
+ if ( is_wp_error( $response ) ) {
5223
+ return false;
5224
+ }
5225
+
5226
+ $decoded = @json_decode( $response['body'] );
5227
+
5228
+ if ( empty( $decoded ) ) {
5229
+ return false;
5230
+ }
5231
+
5232
+ if ( isset( $decoded->error ) ) {
5233
+ return false;
5234
+ } else if ( isset( $decoded->pending_activation ) && $decoded->pending_activation ) {
5235
+ // Pending activation, add message.
5236
+ $this->set_pending_confirmation( false, false );
5237
+
5238
+ return true;
5239
+ } else if ( isset( $decoded->install_secret_key ) ) {
5240
+ $this->install_with_new_user(
5241
+ $decoded->user_id,
5242
+ $decoded->user_public_key,
5243
+ $decoded->user_secret_key,
5244
+ $decoded->install_id,
5245
+ $decoded->install_public_key,
5246
+ $decoded->install_secret_key,
5247
+ false
5248
+ );
5249
+
5250
+ return true;
5251
+ }
5252
+
5253
+ return false;
5254
+ }
5255
+
5256
+ /**
5257
+ * Set user and site identities.
5258
+ *
5259
+ * @author Vova Feldman (@svovaf)
5260
+ * @since 1.0.9
5261
+ *
5262
+ * @param FS_User $user
5263
+ * @param FS_Site $site
5264
+ * @param bool $redirect
5265
+ *
5266
+ * @return bool False if account already set.
5267
+ */
5268
+ function setup_account( FS_User $user, FS_Site $site, $redirect = true ) {
5269
+ $this->_user = $user;
5270
+ $this->_site = $site;
5271
+
5272
+ $this->_sync_plans();
5273
+
5274
+ $this->_enrich_site_plan( false );
5275
+
5276
+ $this->_set_account( $user, $site );
5277
+
5278
+ if ( $this->is_trial() ) {
5279
+ // Store trial plan information.
5280
+ $this->_enrich_site_trial_plan( true );
5281
+ }
5282
+
5283
+ $this->do_action( 'after_account_connection', $user, $site );
5284
+
5285
+ if ( is_numeric( $site->license_id ) ) {
5286
+ $this->_license = $this->_get_license_by_id( $site->license_id );
5287
+ }
5288
+
5289
+ if ( $this->is_pending_activation() ) {
5290
+ // Remove pending activation sticky notice (if still exist).
5291
+ $this->_admin_notices->remove_sticky( 'activation_pending' );
5292
+
5293
+ // Remove plugin from pending activation mode.
5294
+ unset( $this->_storage->is_pending_activation );
5295
+
5296
+ if ( ! $this->is_paying() ) {
5297
+ $this->_admin_notices->add_sticky(
5298
+ sprintf( __fs( 'plugin-x-activation-message', $this->_slug ), '<b>' . $this->get_plugin_name() . '</b>' ),
5299
+ 'activation_complete'
5300
+ );
5301
+ }
5302
+ }
5303
+
5304
+ if ( $this->is_paying() && ! $this->is_premium() ) {
5305
+ $this->_admin_notices->add_sticky(
5306
+ sprintf(
5307
+ __fs( 'activation-with-plan-x-message', $this->_slug ),
5308
+ $this->_site->plan->title
5309
+ ) . ' ' . $this->_get_latest_download_link( sprintf(
5310
+ __fs( 'download-latest-x-version', $this->_slug ),
5311
+ $this->_site->plan->title
5312
+ ) ),
5313
+ 'plan_upgraded',
5314
+ __fs( 'yee-haw', $this->_slug ) . '!'
5315
+ );
5316
+ }
5317
+
5318
+ $plugin_id = fs_request_get( 'plugin_id', false );
5319
+
5320
+ // Store activation time ONLY for plugins (not add-ons).
5321
+ if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
5322
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
5323
+ }
5324
+
5325
+ if ( is_numeric( $plugin_id ) ) {
5326
+ if ( $plugin_id != $this->_plugin->id ) {
5327
+ // Add-on was installed - sync license right after install.
5328
+ if ( $redirect && fs_redirect( fs_nonce_url( $this->_get_admin_page_url(
5329
+ 'account',
5330
+ array(
5331
+ 'fs_action' => $this->_slug . '_sync_license',
5332
+ 'plugin_id' => $plugin_id
5333
+ )
5334
+ ), $this->_slug . '_sync_license' ) )
5335
+ ) {
5336
+ exit();
5337
+ }
5338
+
5339
+ }
5340
+ } else {
5341
+ // Reload the page with the keys.
5342
+ if ( $redirect && fs_redirect( $this->get_after_activation_url( 'after_connect_url' ) ) ) {
5343
+ exit();
5344
+ }
5345
+ }
5346
+ }
5347
+
5348
+ /**
5349
+ * Install plugin with new user information after approval.
5350
+ *
5351
+ * @author Vova Feldman (@svovaf)
5352
+ * @since 1.0.7
5353
+ */
5354
+ function _install_with_new_user() {
5355
+ $this->_logger->entrance();
5356
+
5357
+ if ( $this->is_registered() ) {
5358
+ return;
5359
+ }
5360
+
5361
+ if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
5362
+ // check_admin_referer( $this->_slug . '_activate_new' );
5363
+
5364
+ $this->_admin_notices->remove_sticky( 'connect_account' );
5365
+
5366
+ if ( fs_request_has( 'user_secret_key' ) ) {
5367
+ $this->install_with_new_user(
5368
+ fs_request_get( 'user_id' ),
5369
+ fs_request_get( 'user_public_key' ),
5370
+ fs_request_get( 'user_secret_key' ),
5371
+ fs_request_get( 'install_id' ),
5372
+ fs_request_get( 'install_public_key' ),
5373
+ fs_request_get( 'install_secret_key' )
5374
+ );
5375
+ } else if ( fs_request_has( 'pending_activation' ) ) {
5376
+ $this->set_pending_confirmation( fs_request_get( 'user_email' ), true );
5377
+ }
5378
+ }
5379
+ }
5380
+
5381
+ /**
5382
+ * Install plugin with new user.
5383
+ *
5384
+ * @author Vova Feldman (@svovaf)
5385
+ * @since 1.1.7.4
5386
+ *
5387
+ * @param number $user_id
5388
+ * @param string $user_public_key
5389
+ * @param string $user_secret_key
5390
+ * @param number $install_id
5391
+ * @param string $install_public_key
5392
+ * @param string $install_secret_key
5393
+ * @param bool $redirect
5394
+ */
5395
+ private function install_with_new_user(
5396
+ $user_id,
5397
+ $user_public_key,
5398
+ $user_secret_key,
5399
+ $install_id,
5400
+ $install_public_key,
5401
+ $install_secret_key,
5402
+ $redirect = true
5403
+ ) {
5404
+ $user = new FS_User();
5405
+ $user->id = $user_id;
5406
+ $user->public_key = $user_public_key;
5407
+ $user->secret_key = $user_secret_key;
5408
+
5409
+ $this->_user = $user;
5410
+ $user_result = $this->get_api_user_scope()->get();
5411
+ $user = new FS_User( $user_result );
5412
+ $this->_user = $user;
5413
+
5414
+ $site = new FS_Site();
5415
+ $site->id = $install_id;
5416
+ $site->public_key = $install_public_key;
5417
+ $site->secret_key = $install_secret_key;
5418
+
5419
+ $this->_site = $site;
5420
+ $site_result = $this->get_api_site_scope()->get();
5421
+ $site = new FS_Site( $site_result );
5422
+ $this->_site = $site;
5423
+
5424
+ $this->setup_account( $this->_user, $this->_site, $redirect );
5425
+ }
5426
+
5427
+ /**
5428
+ * @author Vova Feldman (@svovaf)
5429
+ * @since 1.1.7.4
5430
+ *
5431
+ * @param bool $email
5432
+ * @param bool $redirect
5433
+ */
5434
+ private function set_pending_confirmation( $email = false, $redirect = true ) {
5435
+ // Install must be activated via email since
5436
+ // user with the same email already exist.
5437
+ $this->_storage->is_pending_activation = true;
5438
+ $this->_add_pending_activation_notice( $email );
5439
+
5440
+ // Reload the page with with pending activation message.
5441
+ if ( $redirect && fs_redirect( $this->get_after_activation_url( 'after_pending_connect_url' ) ) ) {
5442
+ exit();
5443
+ }
5444
+ }
5445
+
5446
+ /**
5447
+ * Install plugin with current logged WP user info.
5448
+ *
5449
+ * @author Vova Feldman (@svovaf)
5450
+ * @since 1.0.7
5451
+ */
5452
+ function _install_with_current_user() {
5453
+ $this->_logger->entrance();
5454
+
5455
+ if ( $this->is_registered() ) {
5456
+ return;
5457
+ }
5458
+
5459
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) && fs_request_is_post() ) {
5460
+ // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
5461
+
5462
+ $this->install_with_current_user();
5463
+ }
5464
+ }
5465
+
5466
+
5467
+ /**
5468
+ * @author Vova Feldman (@svovaf)
5469
+ * @since 1.1.7.4
5470
+ *
5471
+ * @param bool $redirect
5472
+ */
5473
+ private function install_with_current_user( $redirect = true ) {
5474
+ $this->_admin_notices->remove_sticky( 'connect_account' );
5475
+
5476
+ // Get current logged WP user.
5477
+ $current_user = self::_get_current_wp_user();
5478
+
5479
+ // Find the relevant FS user by the email.
5480
+ $user = self::_get_user_by_email( $current_user->user_email );
5481
+
5482
+ // We have to set the user before getting user scope API handler.
5483
+ $this->_user = $user;
5484
+
5485
+ // Install the plugin.
5486
+ $install = $this->get_api_user_scope()->call(
5487
+ "/plugins/{$this->get_id()}/installs.json",
5488
+ 'post',
5489
+ $this->get_install_data_for_api( array(
5490
+ 'uid' => $this->get_anonymous_id(),
5491
+ ) )
5492
+ );
5493
+
5494
+ if ( isset( $install->error ) ) {
5495
+ $this->_admin_notices->add(
5496
+ sprintf( __fs( 'could-not-activate-x', $this->_slug ), $this->get_plugin_name() ) . ' ' .
5497
+ __fs( 'contact-us-with-error-message', $this->_slug ) . ' ' . '<b>' . $install->error->message . '</b>',
5498
+ __fs( 'oops', $this->_slug ) . '...',
5499
+ 'error'
5500
+ );
5501
+
5502
+ return;
5503
+ }
5504
+
5505
+ $site = new FS_Site( $install );
5506
+ $this->_site = $site;
5507
+ // $this->_enrich_site_plan( false );
5508
+
5509
+ // $this->_set_account( $user, $site );
5510
+ // $this->_sync_plans();
5511
+
5512
+ $this->setup_account( $this->_user, $this->_site, $redirect );
5513
+ }
5514
+
5515
+ /**
5516
+ * Tries to activate add-on account based on parent plugin info.
5517
+ *
5518
+ * @author Vova Feldman (@svovaf)
5519
+ * @since 1.0.6
5520
+ *
5521
+ * @param Freemius $parent_fs
5522
+ */
5523
+ private function _activate_addon_account( Freemius $parent_fs ) {
5524
+ if ( $this->is_registered() ) {
5525
+ // Already activated.
5526
+ return;
5527
+ }
5528
+
5529
+ // Activate add-on with parent plugin credentials.
5530
+ $addon_install = $parent_fs->get_api_site_scope()->call(
5531
+ "/addons/{$this->_plugin->id}/installs.json",
5532
+ 'post',
5533
+ $this->get_install_data_for_api( array(
5534
+ 'uid' => $this->get_anonymous_id(),
5535
+ ) )
5536
+ );
5537
+
5538
+ if ( isset( $addon_install->error ) ) {
5539
+ $this->_admin_notices->add(
5540
+ sprintf( __fs( 'could-not-activate-x', $this->_slug ), $this->get_plugin_name() ) . ' ' .
5541
+ __fs( 'contact-us-with-error-message', $this->_slug ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
5542
+ __fs( 'oops', $this->_slug ) . '...',
5543
+ 'error'
5544
+ );
5545
+
5546
+ return;
5547
+ }
5548
+
5549
+ // First of all, set site info - otherwise we won't
5550
+ // be able to invoke API calls.
5551
+ $this->_site = new FS_Site( $addon_install );
5552
+
5553
+ // Sync add-on plans.
5554
+ $this->_sync_plans();
5555
+
5556
+ // Get site's current plan.
5557
+ $this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
5558
+
5559
+ // Get user information based on parent's plugin.
5560
+ $user = $parent_fs->get_user();
5561
+
5562
+ $this->_set_account( $user, $this->_site );
5563
+
5564
+ // Sync licenses.
5565
+ $this->_sync_licenses();
5566
+
5567
+ // Try to activate premium license.
5568
+ $this->_activate_license( true );
5569
+ }
5570
+
5571
+ #endregion ------------------------------------------------------------------
5572
+
5573
+ #region Admin Menu Items ------------------------------------------------------------------
5574
+
5575
+ private $_menu_items = array();
5576
+
5577
+ /**
5578
+ * @author Vova Feldman (@svovaf)
5579
+ * @since 1.0.7
5580
+ *
5581
+ * @return string
5582
+ */
5583
+ function get_menu_slug() {
5584
+ return $this->_menu->get_slug();
5585
+ }
5586
+
5587
+ /**
5588
+ * @author Vova Feldman (@svovaf)
5589
+ * @since 1.0.9
5590
+ */
5591
+ function _prepare_admin_menu() {
5592
+ if ( ! $this->is_on() ) {
5593
+ return;
5594
+ }
5595
+
5596
+ if ( ! $this->has_api_connectivity() && ! $this->enable_anonymous() ) {
5597
+ $this->_menu->remove_menu_item();
5598
+ } else {
5599
+ $this->add_submenu_items();
5600
+ $this->add_menu_action();
5601
+ }
5602
+ }
5603
+
5604
+ /**
5605
+ * Admin dashboard menu items modifications.
5606
+ *
5607
+ * NOTE: admin_menu action executed before admin_init.
5608
+ *
5609
+ * @author Vova Feldman (@svovaf)
5610
+ * @since 1.0.7
5611
+ *
5612
+ */
5613
+ private function add_menu_action() {
5614
+ if ( $this->is_activation_mode() ) {
5615
+ $this->override_plugin_menu_with_activation();
5616
+ } else {
5617
+ // If not registered try to install user.
5618
+ if ( ! $this->is_registered() &&
5619
+ fs_request_is_action( $this->_slug . '_activate_new' )
5620
+ ) {
5621
+ $this->_install_with_new_user();
5622
+ }
5623
+ }
5624
+ }
5625
+
5626
+ /**
5627
+ * @author Vova Feldman (@svovaf)
5628
+ * @since 1.0.1
5629
+ *
5630
+ * @return string
5631
+ */
5632
+ function _redirect_on_clicked_menu_link() {
5633
+ $this->_logger->entrance();
5634
+
5635
+ $page = strtolower( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
5636
+
5637
+ $this->_logger->log( 'page = ' . $page );
5638
+
5639
+ foreach ( $this->_menu_items as $priority => $items ) {
5640
+ foreach ( $items as $item ) {
5641
+ if ( isset( $item['url'] ) ) {
5642
+ if ( $page === $item['menu_slug'] ) {
5643
+ $this->_logger->log( 'Redirecting to ' . $item['url'] );
5644
+
5645
+ fs_redirect( $item['url'] );
5646
+ }
5647
+ }
5648
+ }
5649
+ }
5650
+ }
5651
+
5652
+ /**
5653
+ * Remove plugin's all admin menu items & pages, and replace with activation page.
5654
+ *
5655
+ * @author Vova Feldman (@svovaf)
5656
+ * @since 1.0.1
5657
+ */
5658
+ private function override_plugin_menu_with_activation() {
5659
+ $this->_logger->entrance();
5660
+
5661
+ $hook = false;
5662
+
5663
+ if ( $this->_menu->is_top_level() ) {
5664
+ $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) );
5665
+
5666
+ if ( false === $hook ) {
5667
+ // Create new menu item just for the opt-in.
5668
+ $hook = add_menu_page(
5669
+ $this->get_plugin_name(),
5670
+ $this->get_plugin_name(),
5671
+ 'manage_options',
5672
+ $this->_menu->get_slug(),
5673
+ array( &$this, '_connect_page_render' )
5674
+ );
5675
+ }
5676
+ } else {
5677
+ $menus = array( $this->_menu->get_parent_slug() );
5678
+
5679
+ if ( $this->_menu->is_override_exact() ) {
5680
+ // Make sure the current page is matching the activation page.
5681
+ $activation_url = strtolower( $this->get_activation_url() );
5682
+ $request_url = strtolower( $_SERVER['REQUEST_URI'] );
5683
+
5684
+ if ( parse_url( $activation_url, PHP_URL_PATH ) !== parse_url( $request_url, PHP_URL_PATH ) ) {
5685
+ // Different path - DO NOT OVERRIDE PAGE.
5686
+ return;
5687
+ }
5688
+
5689
+ $activation_url_params = array();
5690
+ parse_str( parse_url( $activation_url, PHP_URL_QUERY ), $activation_url_params );
5691
+
5692
+ $request_url_params = array();
5693
+ parse_str( parse_url( $request_url, PHP_URL_QUERY ), $request_url_params );
5694
+
5695
+
5696
+ foreach ( $activation_url_params as $key => $val ) {
5697
+ if ( ! isset( $request_url_params[ $key ] ) || $val != $request_url_params[ $key ] ) {
5698
+ // Not matching query string - DO NOT OVERRIDE PAGE.
5699
+ return;
5700
+ }
5701
+ }
5702
+ }
5703
+
5704
+ foreach ( $menus as $parent_slug ) {
5705
+ $hook = $this->_menu->override_submenu_action(
5706
+ $parent_slug,
5707
+ $this->_menu->get_raw_slug(),
5708
+ array( &$this, '_connect_page_render' )
5709
+ );
5710
+
5711
+ if ( false !== $hook ) {
5712
+ // Found plugin's submenu item.
5713
+ break;
5714
+ }
5715
+ }
5716
+ }
5717
+
5718
+ if ( $this->_menu->is_activation_page() ) {
5719
+ // Clean admin page from distracting content.
5720
+ self::_clean_admin_content_section();
5721
+ }
5722
+
5723
+ if ( false !== $hook ) {
5724
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) ) {
5725
+ add_action( "load-$hook", array( &$this, '_install_with_current_user' ) );
5726
+ } else if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
5727
+ add_action( "load-$hook", array( &$this, '_install_with_new_user' ) );
5728
+ }
5729
+ }
5730
+ }
5731
+
5732
+ /**
5733
+ * @author Vova Feldman (@svovaf)
5734
+ * @since 1.0.0
5735
+ *
5736
+ * @return string
5737
+ */
5738
+ private function get_top_level_menu_slug() {
5739
+ return ( $this->is_addon() ?
5740
+ $this->get_parent_instance()->_menu->get_top_level_menu_slug() :
5741
+ $this->_menu->get_top_level_menu_slug() );
5742
+ }
5743
+
5744
+ /**
5745
+ * Add default Freemius menu items.
5746
+ *
5747
+ * @author Vova Feldman (@svovaf)
5748
+ * @since 1.0.0
5749
+ */
5750
+ private function add_submenu_items() {
5751
+ $this->_logger->entrance();
5752
+
5753
+ $this->do_action( 'before_admin_menu_init' );
5754
+
5755
+ if ( ! $this->is_addon() ) {
5756
+ if ( ! $this->is_activation_mode() ) {
5757
+ if ( $this->is_registered() ) {
5758
+ // Add user account page.
5759
+ $this->add_submenu_item(
5760
+ __fs( 'account', $this->_slug ),
5761
+ array( &$this, '_account_page_render' ),
5762
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'account', $this->_slug ),
5763
+ 'manage_options',
5764
+ 'account',
5765
+ array( &$this, '_account_page_load' ),
5766
+ WP_FS__DEFAULT_PRIORITY,
5767
+ $this->_menu->is_submenu_item_visible( 'account' )
5768
+ );
5769
+ }
5770
+
5771
+ // Add contact page.
5772
+ $this->add_submenu_item(
5773
+ __fs( 'contact-us', $this->_slug ),
5774
+ array( &$this, '_contact_page_render' ),
5775
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'contact-us', $this->_slug ),
5776
+ 'manage_options',
5777
+ 'contact',
5778
+ 'Freemius::_clean_admin_content_section',
5779
+ WP_FS__DEFAULT_PRIORITY,
5780
+ $this->_menu->is_submenu_item_visible( 'contact' )
5781
+ );
5782
+
5783
+ if ( $this->has_addons() ) {
5784
+ $this->add_submenu_item(
5785
+ __fs( 'add-ons', $this->_slug ),
5786
+ array( &$this, '_addons_page_render' ),
5787
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'add-ons', $this->_slug ),
5788
+ 'manage_options',
5789
+ 'addons',
5790
+ array( &$this, '_addons_page_load' ),
5791
+ WP_FS__LOWEST_PRIORITY - 1,
5792
+ $this->_menu->is_submenu_item_visible( 'addons' )
5793
+ );
5794
+ }
5795
+
5796
+ $show_pricing = ( $this->has_paid_plan() && $this->_menu->is_submenu_item_visible( 'pricing' ) );
5797
+ // If user don't have paid plans, add pricing page
5798
+ // to support add-ons checkout but don't add the submenu item.
5799
+ // || (isset( $_GET['page'] ) && $this->_menu->get_slug( 'pricing' ) == $_GET['page']);
5800
+
5801
+ // Add upgrade/pricing page.
5802
+ $this->add_submenu_item(
5803
+ ( $this->is_paying() ? __fs( 'pricing', $this->_slug ) : __fs( 'upgrade', $this->_slug ) . '&nbsp;&nbsp;&#x27a4;' ),
5804
+ array( &$this, '_pricing_page_render' ),
5805
+ $this->get_plugin_name() . ' &ndash; ' . __fs( 'pricing', $this->_slug ),
5806
+ 'manage_options',
5807
+ 'pricing',
5808
+ 'Freemius::_clean_admin_content_section',
5809
+ WP_FS__LOWEST_PRIORITY,
5810
+ $show_pricing
5811
+ );
5812
+ }
5813
+ }
5814
+
5815
+
5816
+ if ( 0 < count( $this->_menu_items ) ) {
5817
+ if ( ! $this->_menu->is_top_level() ) {
5818
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
5819
+
5820
+ // Append submenu items right after the plugin's submenu item.
5821
+ $this->order_sub_submenu_items();
5822
+ } else {
5823
+ // Append submenu items.
5824
+ $this->embed_submenu_items();
5825
+ }
5826
+ }
5827
+ }
5828
+
5829
+ /**
5830
+ * Moved the actual submenu item additions to a separated function,
5831
+ * in order to support sub-submenu items when the plugin's settings
5832
+ * only have a submenu and not top-level menu item.
5833
+ *
5834
+ * @author Vova Feldman (@svovaf)
5835
+ * @since 1.1.4
5836
+ */
5837
+ private function embed_submenu_items() {
5838
+ $item_template = $this->_menu->is_top_level() ?
5839
+ '<span class="fs-submenu-item">%s</span>' :
5840
+ '<span class="fs-submenu-item fs-sub">%s</span>';
5841
+
5842
+ ksort( $this->_menu_items );
5843
+
5844
+ foreach ( $this->_menu_items as $priority => $items ) {
5845
+ foreach ( $items as $item ) {
5846
+ if ( ! isset( $item['url'] ) ) {
5847
+ $hook = add_submenu_page(
5848
+ $item['show_submenu'] ?
5849
+ $this->get_top_level_menu_slug() :
5850
+ null,
5851
+ $item['page_title'],
5852
+ sprintf( $item_template, $item['menu_title'] ),
5853
+ $item['capability'],
5854
+ $item['menu_slug'],
5855
+ $item['render_function']
5856
+ );
5857
+
5858
+ if ( false !== $item['before_render_function'] ) {
5859
+ add_action( "load-$hook", $item['before_render_function'] );
5860
+ }
5861
+ } else {
5862
+ add_submenu_page(
5863
+ $this->get_top_level_menu_slug(),
5864
+ $item['page_title'],
5865
+ sprintf( $item_template, $item['menu_title'] ),
5866
+ $item['capability'],
5867
+ $item['menu_slug'],
5868
+ array( $this, '' )
5869
+ );
5870
+ }
5871
+ }
5872
+ }
5873
+ }
5874
+
5875
+ /**
5876
+ * Re-order the submenu items so all Freemius added new submenu items
5877
+ * are added right after the plugin's settings submenu item.
5878
+ *
5879
+ * @author Vova Feldman (@svovaf)
5880
+ * @since 1.1.4
5881
+ */
5882
+ private function order_sub_submenu_items() {
5883
+ global $submenu;
5884
+
5885
+ $top_level_menu = &$submenu[ $this->_menu->get_top_level_menu_slug() ];
5886
+
5887
+ $all_submenu_items_after = array();
5888
+
5889
+ $found_submenu_item = false;
5890
+
5891
+ if (empty($top_level_menu)) return;
5892
+
5893
+ foreach ( $top_level_menu as $submenu_id => $meta ) {
5894
+ if ( $found_submenu_item ) {
5895
+ // Remove all submenu items after the plugin's submenu item.
5896
+ $all_submenu_items_after[] = $meta;
5897
+ unset( $top_level_menu[ $submenu_id ] );
5898
+ }
5899
+
5900
+ if ( $this->_menu->get_raw_slug() === $meta[2] ) {
5901
+ // Found the submenu item, put all below.
5902
+ $found_submenu_item = true;
5903
+ continue;
5904
+ }
5905
+ }
5906
+
5907
+ // Embed all plugin's new submenu items.
5908
+ $this->embed_submenu_items();
5909
+
5910
+ // Start with specially high number to make sure it's appended.
5911
+ $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
5912
+ foreach ( $all_submenu_items_after as $meta ) {
5913
+ $top_level_menu[ $i ] = $meta;
5914
+ $i ++;
5915
+ }
5916
+
5917
+ // Sort submenu items.
5918
+ ksort( $top_level_menu );
5919
+ }
5920
+
5921
+ /**
5922
+ * Displays the Support Forum link when enabled.
5923
+ *
5924
+ * Can be filtered like so:
5925
+ *
5926
+ * function _fs_show_support_menu( $is_visible, $menu_id ) {
5927
+ * if ( 'support' === $menu_id ) {
5928
+ * return _fs->is_registered();
5929
+ * }
5930
+ * return $is_visible;
5931
+ * }
5932
+ * _fs()->add_filter('is_submenu_visible', '_fs_show_support_menu', 10, 2);
5933
+ *
5934
+ */
5935
+ function _add_default_submenu_items() {
5936
+ if ( ! $this->is_on() ) {
5937
+ return;
5938
+ }
5939
+
5940
+ if ( $this->is_registered() || $this->is_anonymous() ) {
5941
+ if ( $this->_menu->is_submenu_item_visible( 'support' ) ) {
5942
+ $this->add_submenu_link_item(
5943
+ $this->apply_filters( 'support_forum_submenu', __fs( 'support-forum', $this->_slug ) ),
5944
+ $this->apply_filters( 'support_forum_url', 'https://wordpress.org/support/plugin/' . $this->_slug ),
5945
+ 'wp-support-forum',
5946
+ 'read',
5947
+ 50
5948
+ );
5949
+ }
5950
+ }
5951
+ }
5952
+
5953
+ /**
5954
+ * @author Vova Feldman (@svovaf)
5955
+ * @since 1.0.1
5956
+ *
5957
+ * @param string $menu_title
5958
+ * @param callable $render_function
5959
+ * @param bool|string $page_title
5960
+ * @param string $capability
5961
+ * @param bool|string $menu_slug
5962
+ * @param bool|callable $before_render_function
5963
+ * @param int $priority
5964
+ * @param bool $show_submenu
5965
+ */
5966
+ function add_submenu_item(
5967
+ $menu_title,
5968
+ $render_function,
5969
+ $page_title = false,
5970
+ $capability = 'manage_options',
5971
+ $menu_slug = false,
5972
+ $before_render_function = false,
5973
+ $priority = WP_FS__DEFAULT_PRIORITY,
5974
+ $show_submenu = true
5975
+ ) {
5976
+ $this->_logger->entrance( 'Title = ' . $menu_title );
5977
+
5978
+ if ( $this->is_addon() ) {
5979
+ $parent_fs = $this->get_parent_instance();
5980
+
5981
+ if ( is_object( $parent_fs ) ) {
5982
+ $parent_fs->add_submenu_item(
5983
+ $menu_title,
5984
+ $render_function,
5985
+ $page_title,
5986
+ $capability,
5987
+ $menu_slug,
5988
+ $before_render_function,
5989
+ $priority,
5990
+ $show_submenu
5991
+ );
5992
+
5993
+ return;
5994
+ }
5995
+ }
5996
+
5997
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
5998
+ $this->_menu_items[ $priority ] = array();
5999
+ }
6000
+
6001
+ $this->_menu_items[ $priority ][] = array(
6002
+ 'page_title' => is_string( $page_title ) ? $page_title : $menu_title,
6003
+ 'menu_title' => $menu_title,
6004
+ 'capability' => $capability,
6005
+ 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
6006
+ 'render_function' => $render_function,
6007
+ 'before_render_function' => $before_render_function,
6008
+ 'show_submenu' => $show_submenu,
6009
+ );
6010
+ }
6011
+
6012
+ /**
6013
+ * @author Vova Feldman (@svovaf)
6014
+ * @since 1.0.1
6015
+ *
6016
+ * @param string $menu_title
6017
+ * @param string $url
6018
+ * @param bool $menu_slug
6019
+ * @param string $capability
6020
+ * @param int $priority
6021
+ *
6022
+ */
6023
+ function add_submenu_link_item(
6024
+ $menu_title,
6025
+ $url,
6026
+ $menu_slug = false,
6027
+ $capability = 'read',
6028
+ $priority = WP_FS__DEFAULT_PRIORITY
6029
+ ) {
6030
+ $this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
6031
+
6032
+ if ( $this->is_addon() ) {
6033
+ $parent_fs = $this->get_parent_instance();
6034
+
6035
+ if ( is_object( $parent_fs ) ) {
6036
+ $parent_fs->add_submenu_link_item(
6037
+ $menu_title,
6038
+ $url,
6039
+ $menu_slug,
6040
+ $capability,
6041
+ $priority
6042
+ );
6043
+
6044
+ return;
6045
+ }
6046
+ }
6047
+
6048
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
6049
+ $this->_menu_items[ $priority ] = array();
6050
+ }
6051
+
6052
+ $this->_menu_items[ $priority ][] = array(
6053
+ 'menu_title' => $menu_title,
6054
+ 'capability' => $capability,
6055
+ 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
6056
+ 'url' => $url,
6057
+ 'page_title' => $menu_title,
6058
+ 'render_function' => 'fs_dummy',
6059
+ 'before_render_function' => '',
6060
+ );
6061
+ }
6062
+
6063
+ #endregion ------------------------------------------------------------------
6064
+
6065
+ /* Actions / Hooks / Filters
6066
+ ------------------------------------------------------------------------------------------------------------------*/
6067
+ /**
6068
+ * @author Vova Feldman (@svovaf)
6069
+ * @since 1.1.7
6070
+ *
6071
+ * @param string $tag
6072
+ *
6073
+ * @return string
6074
+ */
6075
+ private function get_action_tag( $tag ) {
6076
+ return 'fs_' . $tag . '_' . $this->_slug;
6077
+ }
6078
+
6079
+ /**
6080
+ * Do action, specific for the current context plugin.
6081
+ *
6082
+ * @author Vova Feldman (@svovaf)
6083
+ * @since 1.0.1
6084
+ *
6085
+ * @param string $tag The name of the action to be executed.
6086
+ * @param mixed $arg,... Optional. Additional arguments which are passed on to the
6087
+ * functions hooked to the action. Default empty.
6088
+ *
6089
+ * @uses do_action()
6090
+ */
6091
+ function do_action( $tag, $arg = '' ) {
6092
+ $this->_logger->entrance( $tag );
6093
+
6094
+ $args = func_get_args();
6095
+
6096
+ call_user_func_array( 'do_action', array_merge(
6097
+ array( $this->get_action_tag( $tag ) ),
6098
+ array_slice( $args, 1 ) )
6099
+ );
6100
+ }
6101
+
6102
+ /**
6103
+ * Add action, specific for the current context plugin.
6104
+ *
6105
+ * @author Vova Feldman (@svovaf)
6106
+ * @since 1.0.1
6107
+ *
6108
+ * @param string $tag
6109
+ * @param callable $function_to_add
6110
+ * @param int $priority
6111
+ * @param int $accepted_args
6112
+ *
6113
+ * @uses add_action()
6114
+ */
6115
+ function add_action( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
6116
+ $this->_logger->entrance( $tag );
6117
+
6118
+ add_action( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
6119
+ }
6120
+
6121
+ /**
6122
+ * Apply filter, specific for the current context plugin.
6123
+ *
6124
+ * @author Vova Feldman (@svovaf)
6125
+ * @since 1.0.9
6126
+ *
6127
+ * @param string $tag The name of the filter hook.
6128
+ * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
6129
+ *
6130
+ * @return mixed The filtered value after all hooked functions are applied to it.
6131
+ *
6132
+ * @uses apply_filters()
6133
+ */
6134
+ function apply_filters( $tag, $value ) {
6135
+ $this->_logger->entrance( $tag );
6136
+
6137
+ $args = func_get_args();
6138
+ array_unshift( $args, $this->_slug );
6139
+
6140
+ return call_user_func_array( 'fs_apply_filter', $args );
6141
+ }
6142
+
6143
+ /**
6144
+ * Add filter, specific for the current context plugin.
6145
+ *
6146
+ * @author Vova Feldman (@svovaf)
6147
+ * @since 1.0.9
6148
+ *
6149
+ * @param string $tag
6150
+ * @param callable $function_to_add
6151
+ * @param int $priority
6152
+ * @param int $accepted_args
6153
+ *
6154
+ * @uses add_filter()
6155
+ */
6156
+ function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
6157
+ $this->_logger->entrance( $tag );
6158
+
6159
+ add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
6160
+ }
6161
+
6162
+ /**
6163
+ * Check if has filter.
6164
+ *
6165
+ * @author Vova Feldman (@svovaf)
6166
+ * @since 1.1.4
6167
+ *
6168
+ * @param string $tag
6169
+ * @param callable|bool $function_to_check Optional. The callback to check for. Default false.
6170
+ *
6171
+ * @return false|int
6172
+ *
6173
+ * @uses has_filter()
6174
+ */
6175
+ function has_filter( $tag, $function_to_check = false ) {
6176
+ $this->_logger->entrance( $tag );
6177
+
6178
+ return has_filter( $this->get_action_tag( $tag ), $function_to_check );
6179
+ }
6180
+
6181
+ /**
6182
+ * Override default i18n text phrases.
6183
+ *
6184
+ * @author Vova Feldman (@svovaf)
6185
+ * @since 1.1.6
6186
+ *
6187
+ * @param string[] string $key_value
6188
+ *
6189
+ * @uses fs_override_i18n()
6190
+ */
6191
+ function override_i18n( $key_value ) {
6192
+ fs_override_i18n( $key_value, $this->_slug );
6193
+ }
6194
+
6195
+ /* Account Page
6196
+ ------------------------------------------------------------------------------------------------------------------*/
6197
+ /**
6198
+ * Update site information.
6199
+ *
6200
+ * @author Vova Feldman (@svovaf)
6201
+ * @since 1.0.1
6202
+ *
6203
+ * @param bool $store Flush to Database if true.
6204
+ */
6205
+ private function _store_site( $store = true ) {
6206
+ $this->_logger->entrance();
6207
+
6208
+ $encrypted_site = clone $this->_site;
6209
+ $encrypted_site->plan = $this->_encrypt_entity( $this->_site->plan );
6210
+
6211
+ $sites = self::get_all_sites();
6212
+ $sites[ $this->_slug ] = $encrypted_site;
6213
+ self::$_accounts->set_option( 'sites', $sites, $store );
6214
+ }
6215
+
6216
+ /**
6217
+ * Update plugin's plans information.
6218
+ *
6219
+ * @author Vova Feldman (@svovaf)
6220
+ * @since 1.0.2
6221
+ *
6222
+ * @param bool $store Flush to Database if true.
6223
+ */
6224
+ private function _store_plans( $store = true ) {
6225
+ $this->_logger->entrance();
6226
+
6227
+ $plans = self::get_all_plans();
6228
+
6229
+ // Copy plans.
6230
+ $encrypted_plans = array();
6231
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
6232
+ $encrypted_plans[] = $this->_encrypt_entity( $this->_plans[ $i ] );
6233
+ }
6234
+
6235
+ $plans[ $this->_slug ] = $encrypted_plans;
6236
+ self::$_accounts->set_option( 'plans', $plans, $store );
6237
+ }
6238
+
6239
+ /**
6240
+ * Update user's plugin licenses.
6241
+ *
6242
+ * @author Vova Feldman (@svovaf)
6243
+ * @since 1.0.5
6244
+ *
6245
+ * @param bool $store
6246
+ * @param string|bool $plugin_slug
6247
+ * @param FS_Plugin_License[] $licenses
6248
+ */
6249
+ private function _store_licenses( $store = true, $plugin_slug = false, $licenses = array() ) {
6250
+ $this->_logger->entrance();
6251
+
6252
+ $all_licenses = self::get_all_licenses();
6253
+
6254
+ if ( ! is_string( $plugin_slug ) ) {
6255
+ $plugin_slug = $this->_slug;
6256
+ $licenses = $this->_licenses;
6257
+ }
6258
+
6259
+ if ( ! isset( $all_licenses[ $plugin_slug ] ) ) {
6260
+ $all_licenses[ $plugin_slug ] = array();
6261
+ }
6262
+
6263
+ $all_licenses[ $plugin_slug ][ $this->_user->id ] = $licenses;
6264
+
6265
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
6266
+ }
6267
+
6268
+ /**
6269
+ * Update user information.
6270
+ *
6271
+ * @author Vova Feldman (@svovaf)
6272
+ * @since 1.0.1
6273
+ *
6274
+ * @param bool $store Flush to Database if true.
6275
+ */
6276
+ private function _store_user( $store = true ) {
6277
+ $this->_logger->entrance();
6278
+
6279
+ $users = self::get_all_users();
6280
+ $users[ $this->_user->id ] = $this->_user;
6281
+ self::$_accounts->set_option( 'users', $users, $store );
6282
+ }
6283
+
6284
+ /**
6285
+ * Update new updates information.
6286
+ *
6287
+ * @author Vova Feldman (@svovaf)
6288
+ * @since 1.0.4
6289
+ *
6290
+ * @param FS_Plugin_Tag|null $update
6291
+ * @param bool $store Flush to Database if true.
6292
+ * @param bool|number $plugin_id
6293
+ */
6294
+ private function _store_update( $update, $store = true, $plugin_id = false ) {
6295
+ $this->_logger->entrance();
6296
+
6297
+ if ( $update instanceof FS_Plugin_Tag ) {
6298
+ $update->updated = time();
6299
+ }
6300
+
6301
+ if ( ! is_numeric( $plugin_id ) ) {
6302
+ $plugin_id = $this->_plugin->id;
6303
+ }
6304
+
6305
+ $updates = self::get_all_updates();
6306
+ $updates[ $plugin_id ] = $update;
6307
+ self::$_accounts->set_option( 'updates', $updates, $store );
6308
+ }
6309
+
6310
+ /**
6311
+ * Update new updates information.
6312
+ *
6313
+ * @author Vova Feldman (@svovaf)
6314
+ * @since 1.0.6
6315
+ *
6316
+ * @param FS_Plugin[] $plugin_addons
6317
+ * @param bool $store Flush to Database if true.
6318
+ */
6319
+ private function _store_addons( $plugin_addons, $store = true ) {
6320
+ $this->_logger->entrance();
6321
+
6322
+ $addons = self::get_all_addons();
6323
+ $addons[ $this->_plugin->id ] = $plugin_addons;
6324
+ self::$_accounts->set_option( 'addons', $addons, $store );
6325
+ }
6326
+
6327
+ /**
6328
+ * Delete plugin's associated add-ons.
6329
+ *
6330
+ * @author Vova Feldman (@svovaf)
6331
+ * @since 1.0.8
6332
+ *
6333
+ * @param bool $store
6334
+ *
6335
+ * @return bool
6336
+ */
6337
+ private function _delete_account_addons( $store = true ) {
6338
+ $all_addons = self::get_all_account_addons();
6339
+
6340
+ if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) {
6341
+ return false;
6342
+ }
6343
+
6344
+ unset( $all_addons[ $this->_plugin->id ] );
6345
+
6346
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
6347
+
6348
+ return true;
6349
+ }
6350
+
6351
+ /**
6352
+ * Update account add-ons list.
6353
+ *
6354
+ * @author Vova Feldman (@svovaf)
6355
+ * @since 1.0.6
6356
+ *
6357
+ * @param FS_Plugin[] $addons
6358
+ * @param bool $store Flush to Database if true.
6359
+ */
6360
+ private function _store_account_addons( $addons, $store = true ) {
6361
+ $this->_logger->entrance();
6362
+
6363
+ $all_addons = self::get_all_account_addons();
6364
+ $all_addons[ $this->_plugin->id ] = $addons;
6365
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
6366
+ }
6367
+
6368
+ /**
6369
+ * Store account params in the Database.
6370
+ *
6371
+ * @author Vova Feldman (@svovaf)
6372
+ * @since 1.0.1
6373
+ */
6374
+ private function _store_account() {
6375
+ $this->_logger->entrance();
6376
+
6377
+ $this->_store_site( false );
6378
+ $this->_store_user( false );
6379
+ $this->_store_plans( false );
6380
+ $this->_store_licenses( false );
6381
+
6382
+ self::$_accounts->store();
6383
+ }
6384
+
6385
+ /**
6386
+ * Sync user's information.
6387
+ *
6388
+ * @author Vova Feldman (@svovaf)
6389
+ * @since 1.0.3
6390
+ * @uses FS_Api
6391
+ */
6392
+ private function _handle_account_user_sync() {
6393
+ $this->_logger->entrance();
6394
+
6395
+ $api = $this->get_api_user_scope();
6396
+
6397
+ // Get user's information.
6398
+ $user = $api->get( '/', true );
6399
+
6400
+ if ( isset( $user->id ) ) {
6401
+ $this->_user->first = $user->first;
6402
+ $this->_user->last = $user->last;
6403
+ $this->_user->email = $user->email;
6404
+
6405
+ $is_menu_item_account_visible = $this->_menu->is_submenu_item_visible( 'account' );
6406
+
6407
+ if ( $user->is_verified &&
6408
+ ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified )
6409
+ ) {
6410
+ $this->_user->is_verified = true;
6411
+
6412
+ $this->do_action( 'account_email_verified', $user->email );
6413
+
6414
+ $this->_admin_notices->add(
6415
+ __fs( 'email-verified-message', $this->_slug ),
6416
+ __fs( 'right-on', $this->_slug ) . '!',
6417
+ 'success',
6418
+ // Make admin sticky if account menu item is invisible,
6419
+ // since the page will be auto redirected to the plugin's
6420
+ // main settings page, and the non-sticky message
6421
+ // will disappear.
6422
+ ! $is_menu_item_account_visible,
6423
+ false,
6424
+ 'email_verified'
6425
+ );
6426
+ }
6427
+
6428
+ // Flush user details to DB.
6429
+ $this->_store_user();
6430
+
6431
+ $this->do_action( 'after_account_user_sync', $user );
6432
+
6433
+ /**
6434
+ * If account menu item is hidden, redirect to plugin's main settings page.
6435
+ *
6436
+ * @author Vova Feldman (@svovaf)
6437
+ * @since 1.1.6
6438
+ *
6439
+ * @link https://github.com/Freemius/wordpress-sdk/issues/6
6440
+ */
6441
+ if ( ! $is_menu_item_account_visible ) {
6442
+ if ( fs_redirect( $this->_get_admin_page_url() ) ) {
6443
+ exit();
6444
+ }
6445
+ }
6446
+ }
6447
+ }
6448
+
6449
+ /**
6450
+ * @author Vova Feldman (@svovaf)
6451
+ * @since 1.0.5
6452
+ * @uses FS_Api
6453
+ *
6454
+ * @param bool $flush
6455
+ *
6456
+ * @return object|\FS_Site
6457
+ */
6458
+ private function _fetch_site( $flush = false ) {
6459
+ $this->_logger->entrance();
6460
+ $api = $this->get_api_site_scope();
6461
+
6462
+ $site = $api->get( '/', $flush );
6463
+
6464
+ if ( ! isset( $site->error ) ) {
6465
+ $site = new FS_Site( $site );
6466
+ $site->slug = $this->_slug;
6467
+ $site->version = $this->get_plugin_version();
6468
+ }
6469
+
6470
+ return $site;
6471
+ }
6472
+
6473
+ /**
6474
+ * @param bool $store
6475
+ *
6476
+ * @return FS_Plugin_Plan|object|false
6477
+ */
6478
+ private function _enrich_site_plan( $store = true ) {
6479
+ // Try to load plan from local cache.
6480
+ $plan = $this->_get_plan_by_id( $this->_site->plan->id );
6481
+
6482
+ if ( false === $plan ) {
6483
+ $plan = $this->_fetch_site_plan();
6484
+ }
6485
+
6486
+ if ( $plan instanceof FS_Plugin_Plan ) {
6487
+ $this->_update_plan( $plan, $store );
6488
+ }
6489
+
6490
+ return $plan;
6491
+ }
6492
+
6493
+ /**
6494
+ * @author Vova Feldman (@svovaf)
6495
+ * @since 1.0.9
6496
+ * @uses FS_Api
6497
+ *
6498
+ * @param bool $store
6499
+ *
6500
+ * @return FS_Plugin_Plan|object|false
6501
+ */
6502
+ private function _enrich_site_trial_plan( $store = true ) {
6503
+ // Try to load plan from local cache.
6504
+ $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
6505
+
6506
+ if ( false === $trial_plan ) {
6507
+ $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
6508
+ }
6509
+
6510
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
6511
+ $this->_storage->store( 'trial_plan', $trial_plan, $store );
6512
+ }
6513
+
6514
+ return $trial_plan;
6515
+ }
6516
+
6517
+ /**
6518
+ * @author Vova Feldman (@svovaf)
6519
+ * @since 1.0.9
6520
+ * @uses FS_Api
6521
+ *
6522
+ * @param number|bool $license_id
6523
+ *
6524
+ * @return FS_Subscription|object|bool
6525
+ */
6526
+ private function _fetch_site_license_subscription( $license_id = false ) {
6527
+ $this->_logger->entrance();
6528
+ $api = $this->get_api_site_scope();
6529
+
6530
+ if ( ! is_numeric( $license_id ) ) {
6531
+ $license_id = $this->_license->id;
6532
+ }
6533
+
6534
+ $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );
6535
+
6536
+ return ! isset( $result->error ) ?
6537
+ ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
6538
+ new FS_Subscription( $result->subscriptions[0] ) :
6539
+ false
6540
+ ) :
6541
+ $result;
6542
+ }
6543
+
6544
+ /**
6545
+ * @author Vova Feldman (@svovaf)
6546
+ * @since 1.0.4
6547
+ * @uses FS_Api
6548
+ *
6549
+ * @param number|bool $plan_id
6550
+ *
6551
+ * @return FS_Plugin_Plan|object
6552
+ */
6553
+ private function _fetch_site_plan( $plan_id = false ) {
6554
+ $this->_logger->entrance();
6555
+ $api = $this->get_api_site_scope();
6556
+
6557
+ if ( ! is_numeric( $plan_id ) ) {
6558
+ $plan_id = $this->_site->plan->id;
6559
+ }
6560
+
6561
+ $plan = $api->get( "/plans/{$plan_id}.json", true );
6562
+
6563
+ return ! isset( $plan->error ) ? new FS_Plugin_Plan( $plan ) : $plan;
6564
+ }
6565
+
6566
+ /**
6567
+ * @author Vova Feldman (@svovaf)
6568
+ * @since 1.0.5
6569
+ * @uses FS_Api
6570
+ *
6571
+ * @return FS_Plugin_Plan[]|object
6572
+ */
6573
+ private function _fetch_plugin_plans() {
6574
+ $this->_logger->entrance();
6575
+ $api = $this->get_api_site_scope();
6576
+
6577
+ $result = $api->get( '/plans.json', true );
6578
+
6579
+ if ( ! $this->is_api_error( $result ) ) {
6580
+ for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
6581
+ $result->plans[ $i ] = new FS_Plugin_Plan( $result->plans[ $i ] );
6582
+ }
6583
+
6584
+ $result = $result->plans;
6585
+ }
6586
+
6587
+ return $result;
6588
+ }
6589
+
6590
+ /**
6591
+ * @author Vova Feldman (@svovaf)
6592
+ * @since 1.0.5
6593
+ * @uses FS_Api
6594
+ *
6595
+ * @param number|bool $plugin_id
6596
+ *
6597
+ * @return FS_Plugin_License[]|object
6598
+ */
6599
+ private function _fetch_licenses( $plugin_id = false ) {
6600
+ $this->_logger->entrance();
6601
+
6602
+ $api = $this->get_api_user_scope();
6603
+
6604
+ if ( ! is_numeric( $plugin_id ) ) {
6605
+ $plugin_id = $this->_plugin->id;
6606
+ }
6607
+
6608
+ $result = $api->get( "/plugins/{$plugin_id}/licenses.json", true );
6609
+
6610
+ if ( ! isset( $result->error ) ) {
6611
+ for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
6612
+ $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
6613
+ }
6614
+
6615
+ $result = $result->licenses;
6616
+ }
6617
+
6618
+ return $result;
6619
+ }
6620
+
6621
+ /**
6622
+ * @author Vova Feldman (@svovaf)
6623
+ * @since 1.0.4
6624
+ *
6625
+ * @param FS_Plugin_Plan $plan
6626
+ * @param bool $store
6627
+ */
6628
+ private function _update_plan( $plan, $store = false ) {
6629
+ $this->_logger->entrance();
6630
+
6631
+ $this->_site->plan = $plan;
6632
+ $this->_store_site( $store );
6633
+ }
6634
+
6635
+ /**
6636
+ * @author Vova Feldman (@svovaf)
6637
+ * @since 1.0.5
6638
+ *
6639
+ * @param FS_Plugin_License[] $licenses
6640
+ * @param string|bool $plugin_slug
6641
+ */
6642
+ private function _update_licenses( $licenses, $plugin_slug = false ) {
6643
+ $this->_logger->entrance();
6644
+
6645
+ if ( is_array( $licenses ) ) {
6646
+ for ( $i = 0, $len = count( $licenses ); $i < $len; $i ++ ) {
6647
+ $licenses[ $i ]->updated = time();
6648
+ }
6649
+ }
6650
+
6651
+ if ( ! is_string( $plugin_slug ) ) {
6652
+ $this->_licenses = $licenses;
6653
+ }
6654
+
6655
+ $this->_store_licenses( true, $plugin_slug, $licenses );
6656
+ }
6657
+
6658
+ /**
6659
+ * @author Vova Feldman (@svovaf)
6660
+ * @since 1.0.4
6661
+ *
6662
+ * @param bool|number $plugin_id
6663
+ * @param bool $flush Since 1.1.7.3
6664
+ *
6665
+ * @return object|false New plugin tag info if exist.
6666
+ */
6667
+ private function _fetch_newer_version( $plugin_id = false, $flush = true ) {
6668
+ $latest_tag = $this->_fetch_latest_version( $plugin_id, $flush );
6669
+
6670
+ if ( ! is_object( $latest_tag ) ) {
6671
+ return false;
6672
+ }
6673
+
6674
+ // Check if version is actually newer.
6675
+ $has_new_version =
6676
+ // If it's an non-installed add-on then always return latest.
6677
+ ( $this->_is_addon_id( $plugin_id ) && ! $this->is_addon_activated( $plugin_id ) ) ||
6678
+ // Compare versions.
6679
+ version_compare( $this->get_plugin_version(), $latest_tag->version, '<' );
6680
+
6681
+ $this->_logger->departure( $has_new_version ? 'Found newer plugin version ' . $latest_tag->version : 'No new version' );
6682
+
6683
+ return $has_new_version ? $latest_tag : false;
6684
+ }
6685
+
6686
+ /**
6687
+ * @author Vova Feldman (@svovaf)
6688
+ * @since 1.0.5
6689
+ *
6690
+ * @param bool|number $plugin_id
6691
+ * @param bool $flush Since 1.1.7.3
6692
+ *
6693
+ * @return bool|FS_Plugin_Tag
6694
+ */
6695
+ function get_update( $plugin_id = false, $flush = true ) {
6696
+ $this->_logger->entrance();
6697
+
6698
+ if ( ! is_numeric( $plugin_id ) ) {
6699
+ $plugin_id = $this->_plugin->id;
6700
+ }
6701
+
6702
+ $this->_check_updates( true, $plugin_id, $flush );
6703
+ $updates = $this->get_all_updates();
6704
+
6705
+ return isset( $updates[ $plugin_id ] ) && is_object( $updates[ $plugin_id ] ) ? $updates[ $plugin_id ] : false;
6706
+ }
6707
+
6708
+ /**
6709
+ * Check if site assigned with active license.
6710
+ *
6711
+ * @author Vova Feldman (@svovaf)
6712
+ * @since 1.0.6
6713
+ */
6714
+ function has_active_license() {
6715
+ return (
6716
+ is_object( $this->_license ) &&
6717
+ is_numeric( $this->_license->id ) &&
6718
+ ! $this->_license->is_expired()
6719
+ );
6720
+ }
6721
+
6722
+ /**
6723
+ * Check if site assigned with license with enabled features.
6724
+ *
6725
+ * @author Vova Feldman (@svovaf)
6726
+ * @since 1.0.6
6727
+ *
6728
+ * @return bool
6729
+ */
6730
+ function has_features_enabled_license() {
6731
+ return (
6732
+ is_object( $this->_license ) &&
6733
+ is_numeric( $this->_license->id ) &&
6734
+ $this->_license->is_features_enabled()
6735
+ );
6736
+ }
6737
+
6738
+ /**
6739
+ * Check if user is a trial or have feature enabled license.
6740
+ *
6741
+ * @author Vova Feldman (@svovaf)
6742
+ * @since 1.1.7
6743
+ *
6744
+ * @return bool
6745
+ */
6746
+ function can_use_premium_code() {
6747
+ return $this->is_trial() || $this->has_features_enabled_license();
6748
+ }
6749
+
6750
+ /**
6751
+ * Sync site's plan.
6752
+ *
6753
+ * @author Vova Feldman (@svovaf)
6754
+ * @since 1.0.3
6755
+ *
6756
+ * @uses FS_Api
6757
+ *
6758
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
6759
+ * the admin.
6760
+ */
6761
+ private function _sync_license( $background = false ) {
6762
+ $this->_logger->entrance();
6763
+
6764
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
6765
+
6766
+ $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() );
6767
+
6768
+ if ( $is_addon_sync ) {
6769
+ $this->_sync_addon_license( $plugin_id, $background );
6770
+ } else {
6771
+ $this->_sync_plugin_license( $background );
6772
+ }
6773
+
6774
+ $this->do_action( 'after_account_plan_sync', $this->_site->plan->name );
6775
+ }
6776
+
6777
+ /**
6778
+ * Sync plugin's add-on license.
6779
+ *
6780
+ * @author Vova Feldman (@svovaf)
6781
+ * @since 1.0.6
6782
+ * @uses FS_Api
6783
+ *
6784
+ * @param number $addon_id
6785
+ * @param bool $background
6786
+ */
6787
+ private function _sync_addon_license( $addon_id, $background ) {
6788
+ $this->_logger->entrance();
6789
+
6790
+ if ( $this->is_addon_activated( $addon_id ) ) {
6791
+ // If already installed, use add-on sync.
6792
+ $fs_addon = self::get_instance_by_id( $addon_id );
6793
+ $fs_addon->_sync_license( $background );
6794
+
6795
+ return;
6796
+ }
6797
+
6798
+ // Validate add-on exists.
6799
+ $addon = $this->get_addon( $addon_id );
6800
+
6801
+ if ( ! is_object( $addon ) ) {
6802
+ return;
6803
+ }
6804
+
6805
+ // Add add-on into account add-ons.
6806
+ $account_addons = $this->get_account_addons();
6807
+ if ( ! is_array( $account_addons ) ) {
6808
+ $account_addons = array();
6809
+ }
6810
+ $account_addons[] = $addon->id;
6811
+ $account_addons = array_unique( $account_addons );
6812
+ $this->_store_account_addons( $account_addons );
6813
+
6814
+ // Load add-on licenses.
6815
+ $licenses = $this->_fetch_licenses( $addon->id );
6816
+
6817
+ // Sync add-on licenses.
6818
+ if ( ! isset( $licenses->error ) ) {
6819
+ $this->_update_licenses( $licenses, $addon->slug );
6820
+
6821
+ if ( ! $this->is_addon_installed( $addon->slug ) && FS_License_Manager::has_premium_license( $licenses ) ) {
6822
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
6823
+
6824
+ if ( ! isset( $plans_result->error ) ) {
6825
+ $plans = array();
6826
+ foreach ( $plans_result->plans as $plan ) {
6827
+ $plans[] = new FS_Plugin_Plan( $plan );
6828
+ }
6829
+
6830
+ $this->_admin_notices->add_sticky(
6831
+ FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
6832
+ sprintf(
6833
+ __fs( 'addon-successfully-upgraded-message', $this->_slug ),
6834
+ $addon->title
6835
+ ) . ' ' . $this->_get_latest_download_link(
6836
+ __fs( 'download-latest-version', $this->_slug ),
6837
+ $addon_id
6838
+ )
6839
+ :
6840
+ sprintf(
6841
+ __fs( 'addon-successfully-purchased-message', $this->_slug ),
6842
+ $addon->title
6843
+ ) . ' ' . $this->_get_latest_download_link(
6844
+ __fs( 'download-latest-version', $this->_slug ),
6845
+ $addon_id
6846
+ ),
6847
+ 'addon_plan_upgraded_' . $addon->slug,
6848
+ __fs( 'yee-haw', $this->_slug ) . '!'
6849
+ );
6850
+ }
6851
+ }
6852
+ }
6853
+ }
6854
+
6855
+ /**
6856
+ * Sync site's plugin plan.
6857
+ *
6858
+ * @author Vova Feldman (@svovaf)
6859
+ * @since 1.0.6
6860
+ * @uses FS_Api
6861
+ *
6862
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
6863
+ * the admin.
6864
+ */
6865
+ private function _sync_plugin_license( $background = false ) {
6866
+ $this->_logger->entrance();
6867
+
6868
+ // Sync site info.
6869
+ $site = $this->send_install_update( array(), true );
6870
+
6871
+ $plan_change = 'none';
6872
+
6873
+ if ( $this->is_api_error( $site ) ) {
6874
+ // Show API messages only if not background sync or if paying customer.
6875
+ if ( ! $background || $this->is_paying() ) {
6876
+ // Try to ping API to see if not blocked.
6877
+ if ( ! FS_Api::test() ) {
6878
+ /**
6879
+ * Failed to ping API - blocked!
6880
+ *
6881
+ * @author Vova Feldman (@svovaf)
6882
+ * @since 1.1.6 Only show message related to one of the Freemius powered plugins. Once it will be resolved it will fix the issue for all plugins anyways. There's no point to scare users with multiple error messages.
6883
+ */
6884
+ $api = $this->get_api_site_scope();
6885
+
6886
+ if ( ! self::$_global_admin_notices->has_sticky( 'api_blocked' ) ) {
6887
+ self::$_global_admin_notices->add(
6888
+ sprintf(
6889
+ __fs( 'server-blocking-access', $this->_slug ),
6890
+ $this->get_plugin_name(),
6891
+ '<a href="' . $api->get_url() . '" target="_blank">' . $api->get_url() . '</a>'
6892
+ ) . '<br> ' . __fs( 'server-error-message', $this->_slug ) . var_export( $site->error, true ),
6893
+ __fs( 'oops', $this->_slug ) . '...',
6894
+ 'error',
6895
+ $background,
6896
+ false,
6897
+ 'api_blocked'
6898
+ );
6899
+ }
6900
+ } else {
6901
+ // Authentication params are broken.
6902
+ $this->_admin_notices->add(
6903
+ __fs( 'wrong-authentication-param-message', $this->_slug ),
6904
+ __fs( 'oops', $this->_slug ) . '...',
6905
+ 'error'
6906
+ );
6907
+ }
6908
+ }
6909
+
6910
+ // No reason to continue with license sync while there are API issues.
6911
+ return;
6912
+ }
6913
+
6914
+ // Remove sticky API connectivity message.
6915
+ self::$_global_admin_notices->remove_sticky( 'api_blocked' );
6916
+
6917
+ $site = new FS_Site( $site );
6918
+
6919
+ // Sync plans.
6920
+ $this->_sync_plans();
6921
+
6922
+ if ( ! $this->has_paid_plan() ) {
6923
+ $this->_site = $site;
6924
+ $this->_enrich_site_plan( true );
6925
+ $this->_store_site();
6926
+ } else {
6927
+ // Sync licenses.
6928
+ $this->_sync_licenses();
6929
+
6930
+ // Check if plan / license changed.
6931
+ if ( ! FS_Entity::equals( $site->plan, $this->_site->plan ) ||
6932
+ // Check if trial started.
6933
+ $site->trial_plan_id != $this->_site->trial_plan_id ||
6934
+ $site->trial_ends != $this->_site->trial_ends ||
6935
+ // Check if license changed.
6936
+ $site->license_id != $this->_site->license_id
6937
+ ) {
6938
+ if ( $site->is_trial() && ( ! $this->_site->is_trial() || $site->trial_ends != $this->_site->trial_ends ) ) {
6939
+ // New trial started.
6940
+ $this->_site = $site;
6941
+ $plan_change = 'trial_started';
6942
+
6943
+ // Store trial plan information.
6944
+ $this->_enrich_site_trial_plan( true );
6945
+
6946
+ // For trial with subscription use-case.
6947
+ $new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
6948
+
6949
+ if ( is_object( $new_license ) && ! $new_license->is_expired() ) {
6950
+ $this->_site = $site;
6951
+ $this->_update_site_license( $new_license );
6952
+ $this->_store_licenses();
6953
+ $this->_enrich_site_plan( true );
6954
+
6955
+ $this->_sync_site_subscription( $this->_license );
6956
+ }
6957
+ } else if ( $this->_site->is_trial() && ! $site->is_trial() && ! is_numeric( $site->license_id ) ) {
6958
+ // Was in trial, but now trial expired and no license ID.
6959
+ // New trial started.
6960
+ $this->_site = $site;
6961
+ $plan_change = 'trial_expired';
6962
+
6963
+ // Clear trial plan information.
6964
+ $this->_storage->trial_plan = null;
6965
+
6966
+ } else {
6967
+ $is_free = $this->is_free_plan();
6968
+
6969
+ // Make sure license exist and not expired.
6970
+ $new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
6971
+
6972
+ if ( $is_free && ( ( ! is_object( $new_license ) || $new_license->is_expired() ) ) ) {
6973
+ // The license is expired, so ignore upgrade method.
6974
+ } else {
6975
+ // License changed.
6976
+ $this->_site = $site;
6977
+ $this->_update_site_license( $new_license );
6978
+ $this->_store_licenses();
6979
+ $this->_enrich_site_plan( true );
6980
+
6981
+ $plan_change = $is_free ?
6982
+ 'upgraded' :
6983
+ ( is_object( $new_license ) ?
6984
+ 'changed' :
6985
+ 'downgraded' );
6986
+ }
6987
+ }
6988
+
6989
+ // Store updated site info.
6990
+ $this->_store_site();
6991
+ } else {
6992
+ if ( is_object( $this->_license ) && $this->_license->is_expired() ) {
6993
+ if ( ! $this->has_features_enabled_license() ) {
6994
+ $this->_deactivate_license();
6995
+ $plan_change = 'downgraded';
6996
+ } else {
6997
+ $plan_change = 'expired';
6998
+ }
6999
+ }
7000
+
7001
+ if ( is_numeric( $site->license_id ) && is_object( $this->_license ) ) {
7002
+ $this->_sync_site_subscription( $this->_license );
7003
+ }
7004
+ }
7005
+ }
7006
+
7007
+ if ( $this->has_paid_plan() ) {
7008
+ switch ( $plan_change ) {
7009
+ case 'none':
7010
+ if ( ! $background && is_admin() ) {
7011
+ $plan = $this->is_trial() ?
7012
+ $this->_storage->trial_plan :
7013
+ $this->_site->plan;
7014
+
7015
+ $this->_admin_notices->add(
7016
+ sprintf(
7017
+ __fs( 'plan-did-not-change-message', $this->_slug ) . ' ' .
7018
+ sprintf(
7019
+ '<a href="%s">%s</a>',
7020
+ $this->contact_url(
7021
+ 'bug',
7022
+ sprintf( __fs( 'plan-did-not-change-email-message', $this->_slug ),
7023
+ strtoupper( $plan->name )
7024
+ )
7025
+ ),
7026
+ __fs( 'contact-us-here', $this->_slug )
7027
+ ),
7028
+ '<i>' . $plan->title . ( $this->is_trial() ? ' ' . __fs( 'trial', $this->_slug ) : '' ) . '</i>'
7029
+ ),
7030
+ __fs( 'hmm', $this->_slug ) . '...',
7031
+ 'error'
7032
+ );
7033
+ }
7034
+ break;
7035
+ case 'upgraded':
7036
+ $this->_admin_notices->add_sticky(
7037
+ sprintf(
7038
+ __fs( 'plan-upgraded-message', $this->_slug ),
7039
+ '<i>' . $this->get_plugin_name() . '</i>'
7040
+ ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
7041
+ __fs( 'download-latest-x-version', $this->_slug ),
7042
+ $this->_site->plan->title
7043
+ ) )
7044
+ ),
7045
+ 'plan_upgraded',
7046
+ __fs( 'yee-haw', $this->_slug ) . '!'
7047
+ );
7048
+
7049
+ $this->_admin_notices->remove_sticky( array(
7050
+ 'trial_started',
7051
+ 'trial_promotion',
7052
+ 'trial_expired',
7053
+ 'activation_complete',
7054
+ ) );
7055
+ break;
7056
+ case 'changed':
7057
+ $this->_admin_notices->add_sticky(
7058
+ sprintf(
7059
+ __fs( 'plan-changed-to-x-message', $this->_slug ),
7060
+ $this->_site->plan->title
7061
+ ),
7062
+ 'plan_changed'
7063
+ );
7064
+
7065
+ $this->_admin_notices->remove_sticky( array(
7066
+ 'trial_started',
7067
+ 'trial_promotion',
7068
+ 'trial_expired',
7069
+ 'activation_complete',
7070
+ ) );
7071
+ break;
7072
+ case 'downgraded':
7073
+ $this->_admin_notices->add_sticky(
7074
+ sprintf( __fs( 'license-expired-blocking-message', $this->_slug ) ),
7075
+ 'license_expired',
7076
+ __fs( 'hmm', $this->_slug ) . '...'
7077
+ );
7078
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
7079
+ break;
7080
+ case 'expired':
7081
+ $this->_admin_notices->add_sticky(
7082
+ sprintf( __fs( 'license-expired-non-blocking-message', $this->_slug ), $this->_site->plan->title ),
7083
+ 'license_expired',
7084
+ __fs( 'hmm', $this->_slug ) . '...'
7085
+ );
7086
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
7087
+ break;
7088
+ case 'trial_started':
7089
+ $this->_admin_notices->add_sticky(
7090
+ sprintf(
7091
+ __fs( 'trial-started-message', $this->_slug ),
7092
+ '<i>' . $this->get_plugin_name() . '</i>'
7093
+ ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
7094
+ __fs( 'download-latest-x-version', $this->_slug ),
7095
+ $this->_storage->trial_plan->title
7096
+ ) ) ),
7097
+ 'trial_started',
7098
+ __fs( 'yee-haw', $this->_slug ) . '!'
7099
+ );
7100
+
7101
+ $this->_admin_notices->remove_sticky( array(
7102
+ 'trial_promotion',
7103
+ ) );
7104
+ break;
7105
+ case 'trial_expired':
7106
+ $this->_admin_notices->add_sticky(
7107
+ __fs( 'trial-expired-message', $this->_slug ),
7108
+ 'trial_expired',
7109
+ __fs( 'hmm', $this->_slug ) . '...'
7110
+ );
7111
+ $this->_admin_notices->remove_sticky( array(
7112
+ 'trial_started',
7113
+ 'trial_promotion',
7114
+ 'plan_upgraded',
7115
+ ) );
7116
+ break;
7117
+ }
7118
+ }
7119
+
7120
+ if ( 'none' !== $plan_change ) {
7121
+ $this->do_action( 'after_license_change', $plan_change, $this->_site->plan );
7122
+ }
7123
+ }
7124
+
7125
+ /**
7126
+ * @author Vova Feldman (@svovaf)
7127
+ * @since 1.0.5
7128
+ *
7129
+ * @param bool $background
7130
+ */
7131
+ protected function _activate_license( $background = false ) {
7132
+ $this->_logger->entrance();
7133
+
7134
+ $license_id = fs_request_get( 'license_id' );
7135
+
7136
+ if ( FS_Plugin_License::is_valid_id( $license_id ) && $license_id == $this->_site->license_id ) {
7137
+ // License is already activated.
7138
+ return;
7139
+ }
7140
+
7141
+ $premium_license = FS_Plugin_License::is_valid_id( $license_id ) ?
7142
+ $this->_get_license_by_id( $license_id ) :
7143
+ $this->_get_available_premium_license();
7144
+
7145
+ if ( ! is_object( $premium_license ) ) {
7146
+ return;
7147
+ }
7148
+
7149
+ $api = $this->get_api_site_scope();
7150
+ $license = $api->call( "/licenses/{$premium_license->id}.json", 'put' );
7151
+
7152
+ if ( $this->is_api_error( $license ) ) {
7153
+ if ( ! $background ) {
7154
+ $this->_admin_notices->add(
7155
+ __fs( 'license-activation-failed-message', $this->_slug ) . '<br> ' .
7156
+ __fs( 'server-error-message', $this->_slug ) . ' ' . var_export( $license, true ),
7157
+ __fs( 'hmm', $this->_slug ) . '...',
7158
+ 'error'
7159
+ );
7160
+ }
7161
+
7162
+ return;
7163
+ }
7164
+
7165
+ $premium_license = new FS_Plugin_License( $license );
7166
+
7167
+ // Updated site plan.
7168
+ $site = $this->get_api_site_scope()->get( '/', true );
7169
+ if ( ! $this->is_api_error( $site ) ) {
7170
+ $this->_site = new FS_Site( $site );
7171
+ }
7172
+ $this->_update_site_license( $premium_license );
7173
+ $this->_enrich_site_plan( false );
7174
+
7175
+ $this->_store_account();
7176
+
7177
+ if ( ! $background ) {
7178
+ $this->_admin_notices->add_sticky(
7179
+ __fs( 'license-activated-message', $this->_slug ) .
7180
+ ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
7181
+ __fs( 'download-latest-x-version', $this->_slug ),
7182
+ $this->_site->plan->title
7183
+ ) ) ),
7184
+ 'license_activated',
7185
+ __fs( 'yee-haw', $this->_slug ) . '!'
7186
+ );
7187
+ }
7188
+
7189
+ $this->_admin_notices->remove_sticky( array(
7190
+ 'trial_promotion',
7191
+ 'license_expired',
7192
+ ) );
7193
+ }
7194
+
7195
+ /**
7196
+ * @author Vova Feldman (@svovaf)
7197
+ * @since 1.0.5
7198
+ *
7199
+ * @param bool $show_notice
7200
+ */
7201
+ protected function _deactivate_license( $show_notice = true ) {
7202
+ $this->_logger->entrance();
7203
+
7204
+ if ( ! is_object( $this->_license ) ) {
7205
+ $this->_admin_notices->add(
7206
+ sprintf( __fs( 'no-active-license-message', $this->_slug ), $this->_site->plan->title ),
7207
+ __fs( 'hmm', $this->_slug ) . '...'
7208
+ );
7209
+
7210
+ return;
7211
+ }
7212
+
7213
+ $api = $this->get_api_site_scope();
7214
+ $license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
7215
+
7216
+ if ( isset( $license->error ) ) {
7217
+ $this->_admin_notices->add(
7218
+ __fs( 'license-deactivation-failed-message', $this->_slug ) . '<br> ' .
7219
+ __fs( 'server-error-message', $this->_slug ) . ' ' . var_export( $license->error, true ),
7220
+ __fs( 'hmm', $this->_slug ) . '...',
7221
+ 'error'
7222
+ );
7223
+
7224
+ return;
7225
+ }
7226
+
7227
+ // Update license cache.
7228
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
7229
+ if ( $license->id == $this->_licenses[ $i ]->id ) {
7230
+ $this->_licenses[ $i ] = new FS_Plugin_License( $license );
7231
+ }
7232
+ }
7233
+
7234
+ // Updated site plan to default.
7235
+ $this->_sync_plans();
7236
+ $this->_site->plan->id = $this->_plans[0]->id;
7237
+ // Unlink license from site.
7238
+ $this->_update_site_license( null );
7239
+ $this->_enrich_site_plan( false );
7240
+
7241
+ $this->_store_account();
7242
+
7243
+ if ( $show_notice ) {
7244
+ $this->_admin_notices->add(
7245
+ sprintf( __fs( 'license-deactivation-message', $this->_slug ), $this->_site->plan->title ),
7246
+ __fs( 'ok', $this->_slug )
7247
+ );
7248
+ }
7249
+
7250
+ $this->_admin_notices->remove_sticky( array(
7251
+ 'plan_upgraded',
7252
+ 'license_activated',
7253
+ ) );
7254
+ }
7255
+
7256
+ /**
7257
+ * Site plan downgrade.
7258
+ *
7259
+ * @author Vova Feldman (@svovaf)
7260
+ * @since 1.0.4
7261
+ *
7262
+ * @uses FS_Api
7263
+ */
7264
+ private function _downgrade_site() {
7265
+ $this->_logger->entrance();
7266
+
7267
+ $api = $this->get_api_site_scope();
7268
+ $site = $api->call( 'downgrade.json', 'put' );
7269
+
7270
+ $plan_downgraded = false;
7271
+ $plan = false;
7272
+ if ( ! isset( $site->error ) ) {
7273
+ $prev_plan_id = $this->_site->plan->id;
7274
+
7275
+ // Update new site plan id.
7276
+ $this->_site->plan->id = $site->plan_id;
7277
+
7278
+ $plan = $this->_enrich_site_plan();
7279
+ $subscription = $this->_sync_site_subscription( $this->_license );
7280
+
7281
+ // Plan downgraded if plan was changed or subscription was cancelled.
7282
+ $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
7283
+ ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
7284
+ } else {
7285
+ // handle different error cases.
7286
+
7287
+ }
7288
+
7289
+ if ( $plan_downgraded ) {
7290
+ // Remove previous sticky message about upgrade (if exist).
7291
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
7292
+
7293
+ $this->_admin_notices->add(
7294
+ sprintf( __fs( 'plan-x-downgraded-message', $this->_slug ),
7295
+ $plan->title,
7296
+ human_time_diff( time(), strtotime( $this->_license->expiration ) )
7297
+ )
7298
+ );
7299
+
7300
+ // Store site updates.
7301
+ $this->_store_site();
7302
+ } else {
7303
+ $this->_admin_notices->add(
7304
+ __fs( 'plan-downgraded-failure-message', $this->_slug ),
7305
+ __fs( 'oops', $this->_slug ) . '...',
7306
+ 'error'
7307
+ );
7308
+ }
7309
+ }
7310
+
7311
+ /**
7312
+ * Cancel site trial.
7313
+ *
7314
+ * @author Vova Feldman (@svovaf)
7315
+ * @since 1.0.9
7316
+ *
7317
+ * @uses FS_Api
7318
+ */
7319
+ private function _cancel_trial() {
7320
+ $this->_logger->entrance();
7321
+
7322
+ if ( ! $this->is_trial() ) {
7323
+ $this->_admin_notices->add(
7324
+ __fs( 'trial-cancel-no-trial-message', $this->_slug ),
7325
+ __fs( 'oops', $this->_slug ) . '...',
7326
+ 'error'
7327
+ );
7328
+
7329
+ return;
7330
+ }
7331
+
7332
+ $api = $this->get_api_site_scope();
7333
+ $site = $api->call( 'trials.json', 'delete' );
7334
+
7335
+ $trial_cancelled = false;
7336
+
7337
+ if ( ! $this->is_api_error( $site ) ) {
7338
+ $prev_trial_ends = $this->_site->trial_ends;
7339
+
7340
+ if ( $this->is_paid_trial() ) {
7341
+ $this->_license->expiration = $site->trial_ends;
7342
+ $this->_license->is_cancelled = true;
7343
+ $this->_update_site_license( $this->_license );
7344
+ $this->_store_licenses();
7345
+
7346
+ // Clear subscription reference.
7347
+ $this->_sync_site_subscription( null );
7348
+ }
7349
+
7350
+ // Update site info.
7351
+ $this->_site = new FS_Site( $site );
7352
+ $this->_enrich_site_plan();
7353
+
7354
+ $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
7355
+ } else {
7356
+ // handle different error cases.
7357
+
7358
+ }
7359
+
7360
+ if ( $trial_cancelled ) {
7361
+ // Remove previous sticky messages about upgrade or trial (if exist).
7362
+ $this->_admin_notices->remove_sticky( array(
7363
+ 'trial_started',
7364
+ 'trial_promotion',
7365
+ 'plan_upgraded',
7366
+ ) );
7367
+
7368
+ // Store site updates.
7369
+ $this->_store_site();
7370
+
7371
+ // Clear trial plan information.
7372
+ unset( $this->_storage->trial_plan );
7373
+
7374
+ if ( ! $this->is_addon() ||
7375
+ ! $this->deactivate_premium_only_addon_without_license( true )
7376
+ ) {
7377
+ $this->_admin_notices->add(
7378
+ sprintf( __fs( 'trial-cancel-message', $this->_slug ), $this->_storage->trial_plan->title )
7379
+ );
7380
+ }
7381
+ } else {
7382
+ $this->_admin_notices->add(
7383
+ __fs( 'trial-cancel-failure-message', $this->_slug ),
7384
+ __fs( 'oops', $this->_slug ) . '...',
7385
+ 'error'
7386
+ );
7387
+ }
7388
+ }
7389
+
7390
+ /**
7391
+ * @author Vova Feldman (@svovaf)
7392
+ * @since 1.0.6
7393
+ *
7394
+ * @param bool|number $plugin_id
7395
+ *
7396
+ * @return bool
7397
+ */
7398
+ private function _is_addon_id( $plugin_id ) {
7399
+ return is_numeric( $plugin_id ) && ( $this->get_id() != $plugin_id );
7400
+ }
7401
+
7402
+ /**
7403
+ * Check if user eligible to download premium version updates.
7404
+ *
7405
+ * @author Vova Feldman (@svovaf)
7406
+ * @since 1.0.6
7407
+ *
7408
+ * @return bool
7409
+ */
7410
+ private function _can_download_premium() {
7411
+ return $this->has_active_license() ||
7412
+ ( $this->is_trial() && ! $this->get_trial_plan()->is_free() );
7413
+ }
7414
+
7415
+ /**
7416
+ *
7417
+ * @author Vova Feldman (@svovaf)
7418
+ * @since 1.0.6
7419
+ *
7420
+ * @param bool|number $addon_id
7421
+ * @param string $type "json" or "zip"
7422
+ *
7423
+ * @return string
7424
+ */
7425
+ private function _get_latest_version_endpoint( $addon_id = false, $type = 'json' ) {
7426
+
7427
+ $is_addon = $this->_is_addon_id( $addon_id );
7428
+
7429
+ $is_premium = null;
7430
+ if ( ! $is_addon ) {
7431
+ $is_premium = $this->_can_download_premium();
7432
+ } else if ( $this->is_addon_activated( $addon_id ) ) {
7433
+ $is_premium = self::get_instance_by_id( $addon_id )->_can_download_premium();
7434
+ }
7435
+
7436
+ return // If add-on, then append add-on ID.
7437
+ ( $is_addon ? "/addons/$addon_id" : '' ) .
7438
+ '/updates/latest.' . $type .
7439
+ // If add-on and not yet activated, try to fetch based on server licensing.
7440
+ ( is_bool( $is_premium ) ? '?is_premium=' . json_encode( $is_premium ) : '' );
7441
+ }
7442
+
7443
+ /**
7444
+ * @author Vova Feldman (@svovaf)
7445
+ * @since 1.0.4
7446
+ *
7447
+ * @param bool|number $addon_id
7448
+ * @param bool $flush Since 1.1.7.3
7449
+ *
7450
+ * @return object|false Plugin latest tag info.
7451
+ */
7452
+ function _fetch_latest_version( $addon_id = false, $flush = true ) {
7453
+ $this->_logger->entrance();
7454
+
7455
+ /**
7456
+ * @since 1.1.7.3 Check for plugin updates from Freemius only if opted-in.
7457
+ * @since 1.1.7.4 Also check updates for add-ons.
7458
+ */
7459
+ if ( ! $this->is_registered() &&
7460
+ ! $this->_is_addon_id( $addon_id )
7461
+ ) {
7462
+ return false;
7463
+ }
7464
+
7465
+ $tag = $this->get_api_site_or_plugin_scope()->get(
7466
+ $this->_get_latest_version_endpoint( $addon_id, 'json' ),
7467
+ $flush
7468
+ );
7469
+
7470
+ $latest_version = ( is_object( $tag ) && isset( $tag->version ) ) ? $tag->version : 'couldn\'t get';
7471
+
7472
+ $this->_logger->departure( 'Latest version ' . $latest_version );
7473
+
7474
+ return ( is_object( $tag ) && isset( $tag->version ) ) ? $tag : false;
7475
+ }
7476
+
7477
+ #region Download Plugin ------------------------------------------------------------------
7478
+
7479
+ /**
7480
+ * Download latest plugin version, based on plan.
7481
+ * The download will be fetched via the API first.
7482
+ *
7483
+ * @author Vova Feldman (@svovaf)
7484
+ * @since 1.0.4
7485
+ *
7486
+ * @param bool|number $plugin_id
7487
+ *
7488
+ * @uses FS_Api
7489
+ *
7490
+ * @deprecated
7491
+ */
7492
+ private function _download_latest( $plugin_id = false ) {
7493
+ $this->_logger->entrance();
7494
+
7495
+ $is_addon = $this->_is_addon_id( $plugin_id );
7496
+
7497
+ $is_premium = $this->_can_download_premium();
7498
+
7499
+ $latest = $this->get_api_site_scope()->call(
7500
+ $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
7501
+ );
7502
+
7503
+ $slug = $this->_slug;
7504
+ if ( $is_addon ) {
7505
+ $addon = $this->get_addon( $plugin_id );
7506
+ $slug = is_object( $addon ) ? $addon->slug : 'addon';
7507
+ }
7508
+
7509
+ if ( ! is_object( $latest ) ) {
7510
+ header( "Content-Type: application/zip" );
7511
+ header( "Content-Disposition: attachment; filename={$slug}" . ( ! $is_addon && $is_premium ? '-premium' : '' ) . ".zip" );
7512
+ header( "Content-Length: " . strlen( $latest ) );
7513
+ echo $latest;
7514
+
7515
+ exit();
7516
+ }
7517
+ }
7518
+
7519
+ /**
7520
+ * Download latest plugin version, based on plan.
7521
+ *
7522
+ * Not like _download_latest(), this will redirect the page
7523
+ * to secure download url to prevent dual download (from FS to WP server,
7524
+ * and then from WP server to the client / browser).
7525
+ *
7526
+ * @author Vova Feldman (@svovaf)
7527
+ * @since 1.0.9
7528
+ *
7529
+ * @param bool|number $plugin_id
7530
+ *
7531
+ * @uses FS_Api
7532
+ * @uses wp_redirect()
7533
+ */
7534
+ private function _download_latest_directly( $plugin_id = false ) {
7535
+ $this->_logger->entrance();
7536
+
7537
+ wp_redirect( $this->_get_latest_download_api_url( $plugin_id ) );
7538
+ }
7539
+
7540
+ /**
7541
+ * Get latest plugin FS API download URL.
7542
+ *
7543
+ * @author Vova Feldman (@svovaf)
7544
+ * @since 1.0.9
7545
+ *
7546
+ * @param bool|number $plugin_id
7547
+ *
7548
+ * @return string
7549
+ */
7550
+ private function _get_latest_download_api_url( $plugin_id = false ) {
7551
+ $this->_logger->entrance();
7552
+
7553
+ return $this->get_api_site_scope()->get_signed_url(
7554
+ $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
7555
+ );
7556
+ }
7557
+
7558
+ /**
7559
+ * Get latest plugin download link.
7560
+ *
7561
+ * @author Vova Feldman (@svovaf)
7562
+ * @since 1.0.9
7563
+ *
7564
+ * @param string $label
7565
+ * @param bool|number $plugin_id
7566
+ *
7567
+ * @return string
7568
+ */
7569
+ private function _get_latest_download_link( $label, $plugin_id = false ) {
7570
+ return sprintf(
7571
+ '<a target="_blank" href="%s">%s</a>',
7572
+ $this->_get_latest_download_local_url( $plugin_id ),
7573
+ $label
7574
+ );
7575
+ }
7576
+
7577
+ /**
7578
+ * Get latest plugin download local URL.
7579
+ *
7580
+ * @author Vova Feldman (@svovaf)
7581
+ * @since 1.0.9
7582
+ *
7583
+ * @param bool|number $plugin_id
7584
+ *
7585
+ * @return string
7586
+ */
7587
+ function _get_latest_download_local_url( $plugin_id = false ) {
7588
+ // Add timestamp to protect from caching.
7589
+ $params = array( 'ts' => WP_FS__SCRIPT_START_TIME );
7590
+
7591
+ if ( ! empty( $plugin_id ) ) {
7592
+ $params['plugin_id'] = $plugin_id;
7593
+ }
7594
+
7595
+ return $this->get_account_url( 'download_latest', $params );
7596
+ }
7597
+
7598
+ #endregion Download Plugin ------------------------------------------------------------------
7599
+
7600
+ /**
7601
+ * @author Vova Feldman (@svovaf)
7602
+ * @since 1.0.4
7603
+ *
7604
+ * @uses FS_Api
7605
+ *
7606
+ * @param bool $background Hints the method if it's a background updates check. If false, it means that
7607
+ * was initiated by the admin.
7608
+ * @param bool|number $plugin_id
7609
+ * @param bool $flush Since 1.1.7.3
7610
+ */
7611
+ private function _check_updates( $background = false, $plugin_id = false, $flush = true ) {
7612
+ $this->_logger->entrance();
7613
+
7614
+ // Check if there's a newer version for download.
7615
+ $new_version = $this->_fetch_newer_version( $plugin_id, $flush );
7616
+
7617
+ $update = null;
7618
+ if ( is_object( $new_version ) ) {
7619
+ $update = new FS_Plugin_Tag( $new_version );
7620
+
7621
+ if ( ! $background ) {
7622
+ $this->_admin_notices->add(
7623
+ sprintf(
7624
+ __fs( 'version-x-released', $this->_slug ) . ' ' . __fs( 'please-download-x', $this->_slug ),
7625
+ $update->version,
7626
+ sprintf(
7627
+ '<a href="%s" target="_blank">%s</a>',
7628
+ $this->get_account_url( 'download_latest' ),
7629
+ sprintf( __fs( 'latest-x-version', $this->_slug ), $this->_site->plan->title )
7630
+ )
7631
+ ),
7632
+ __fs( 'new', $this->_slug ) . '!'
7633
+ );
7634
+ }
7635
+ } else if ( false === $new_version && ! $background ) {
7636
+ $this->_admin_notices->add(
7637
+ __fs( 'you-have-latest', $this->_slug ),
7638
+ __fs( 'you-are-good', $this->_slug )
7639
+ );
7640
+ }
7641
+
7642
+ $this->_store_update( $update, true, $plugin_id );
7643
+ }
7644
+
7645
+ /**
7646
+ * @author Vova Feldman (@svovaf)
7647
+ * @since 1.0.4
7648
+ *
7649
+ * @param bool $flush Since 1.1.7.3 by default add 24 hour cache.
7650
+ *
7651
+ * @return FS_Plugin[]
7652
+ *
7653
+ * @uses FS_Api
7654
+ */
7655
+ private function _sync_addons( $flush = false ) {
7656
+ $this->_logger->entrance();
7657
+
7658
+ $result = $this->get_api_site_or_plugin_scope()->get( '/addons.json?enriched=true', $flush );
7659
+
7660
+ $addons = array();
7661
+ if ( ! $this->is_api_error( $result ) ) {
7662
+ for ( $i = 0, $len = count( $result->plugins ); $i < $len; $i ++ ) {
7663
+ $addons[ $i ] = new FS_Plugin( $result->plugins[ $i ] );
7664
+ }
7665
+
7666
+ $this->_store_addons( $addons, true );
7667
+ }
7668
+
7669
+ return $addons;
7670
+ }
7671
+
7672
+ /**
7673
+ * Handle user email update.
7674
+ *
7675
+ * @author Vova Feldman (@svovaf)
7676
+ * @since 1.0.3
7677
+ * @uses FS_Api
7678
+ *
7679
+ * @param string $new_email
7680
+ *
7681
+ * @return object
7682
+ */
7683
+ private function _update_email( $new_email ) {
7684
+ $this->_logger->entrance();
7685
+
7686
+
7687
+ $api = $this->get_api_user_scope();
7688
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array(
7689
+ 'email' => $new_email,
7690
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
7691
+ 'account',
7692
+ array( 'fs_action' => 'sync_user' )
7693
+ ),
7694
+ ) );
7695
+
7696
+ if ( ! isset( $user->error ) ) {
7697
+ $this->_user->email = $user->email;
7698
+ $this->_user->is_verified = $user->is_verified;
7699
+ $this->_store_user();
7700
+ } else {
7701
+ // handle different error cases.
7702
+
7703
+ }
7704
+
7705
+ return $user;
7706
+ }
7707
+
7708
+ /**
7709
+ * @author Vova Feldman (@svovaf)
7710
+ * @since 1.1.1
7711
+ *
7712
+ * @param mixed $result
7713
+ *
7714
+ * @return bool Is API result contains an error.
7715
+ */
7716
+ private function is_api_error( $result ) {
7717
+ return ( is_object( $result ) && isset( $result->error ) ) ||
7718
+ is_string( $result );
7719
+ }
7720
+
7721
+ /**
7722
+ * Start install ownership change.
7723
+ *
7724
+ * @author Vova Feldman (@svovaf)
7725
+ * @since 1.1.1
7726
+ * @uses FS_Api
7727
+ *
7728
+ * @param string $candidate_email
7729
+ *
7730
+ * @return bool Is ownership change successfully initiated.
7731
+ */
7732
+ private function init_change_owner( $candidate_email ) {
7733
+ $this->_logger->entrance();
7734
+
7735
+ $api = $this->get_api_site_scope();
7736
+ $result = $api->call( "/users/{$this->_user->id}.json", 'put', array(
7737
+ 'email' => $candidate_email,
7738
+ 'after_confirm_url' => $this->_get_admin_page_url(
7739
+ 'account',
7740
+ array( 'fs_action' => 'change_owner' )
7741
+ ),
7742
+ ) );
7743
+
7744
+ return ! $this->is_api_error( $result );
7745
+ }
7746
+
7747
+ /**
7748
+ * Handle install ownership change.
7749
+ *
7750
+ * @author Vova Feldman (@svovaf)
7751
+ * @since 1.1.1
7752
+ * @uses FS_Api
7753
+ *
7754
+ * @return bool Was ownership change successfully complete.
7755
+ */
7756
+ private function complete_change_owner() {
7757
+ $this->_logger->entrance();
7758
+
7759
+ $site_result = $this->get_api_site_scope( true )->get();
7760
+ $site = new FS_Site( $site_result );
7761
+ $this->_site = $site;
7762
+
7763
+ $user = new FS_User();
7764
+ $user->id = fs_request_get( 'user_id' );
7765
+
7766
+ // Validate install's user and given user.
7767
+ if ( $user->id != $this->_site->user_id ) {
7768
+ return false;
7769
+ }
7770
+
7771
+ $user->public_key = fs_request_get( 'user_public_key' );
7772
+ $user->secret_key = fs_request_get( 'user_secret_key' );
7773
+
7774
+ // Fetch new user information.
7775
+ $this->_user = $user;
7776
+ $user_result = $this->get_api_user_scope( true )->get();
7777
+ $user = new FS_User( $user_result );
7778
+ $this->_user = $user;
7779
+
7780
+ $this->_set_account( $user, $site );
7781
+
7782
+ return true;
7783
+ }
7784
+
7785
+ /**
7786
+ * Handle user name update.
7787
+ *
7788
+ * @author Vova Feldman (@svovaf)
7789
+ * @since 1.0.9
7790
+ * @uses FS_Api
7791
+ *
7792
+ * @return object
7793
+ */
7794
+ private function update_user_name() {
7795
+ $this->_logger->entrance();
7796
+ $name = fs_request_get( 'fs_user_name_' . $this->_slug, '' );
7797
+
7798
+ $api = $this->get_api_user_scope();
7799
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
7800
+ 'name' => $name,
7801
+ ) );
7802
+
7803
+ if ( ! isset( $user->error ) ) {
7804
+ $this->_user->first = $user->first;
7805
+ $this->_user->last = $user->last;
7806
+ $this->_store_user();
7807
+ } else {
7808
+ // handle different error cases.
7809
+
7810
+ }
7811
+
7812
+ return $user;
7813
+ }
7814
+
7815
+ /**
7816
+ * Verify user email.
7817
+ *
7818
+ * @author Vova Feldman (@svovaf)
7819
+ * @since 1.0.3
7820
+ * @uses FS_Api
7821
+ */
7822
+ private function verify_email() {
7823
+ $this->_handle_account_user_sync();
7824
+
7825
+ if ( $this->_user->is_verified() ) {
7826
+ return;
7827
+ }
7828
+
7829
+ $api = $this->get_api_site_scope();
7830
+ $result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
7831
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
7832
+ 'account',
7833
+ array( 'fs_action' => 'sync_user' )
7834
+ )
7835
+ ) );
7836
+
7837
+ if ( ! isset( $result->error ) ) {
7838
+ $this->_admin_notices->add( sprintf(
7839
+ __fs( 'verification-email-sent-message', $this->_slug ),
7840
+ sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
7841
+ ) );
7842
+ } else {
7843
+ // handle different error cases.
7844
+
7845
+ }
7846
+ }
7847
+
7848
+ /**
7849
+ * @author Vova Feldman (@svovaf)
7850
+ * @since 1.1.2
7851
+ *
7852
+ * @return string
7853
+ */
7854
+ private function get_activation_url() {
7855
+ return $this->apply_filters( 'connect_url', $this->_get_admin_page_url() );
7856
+ }
7857
+
7858
+ /**
7859
+ * Get the URL of the page that should be loaded after the user connect or skip in the opt-in screen.
7860
+ *
7861
+ * @author Vova Feldman (@svovaf)
7862
+ * @since 1.1.3
7863
+ *
7864
+ * @param string $filter Filter name.
7865
+ *
7866
+ * @return string
7867
+ */
7868
+ private function get_after_activation_url( $filter ) {
7869
+ $first_time_path = $this->_menu->get_first_time_path();
7870
+
7871
+ return $this->apply_filters(
7872
+ $filter,
7873
+ empty( $first_time_path ) ?
7874
+ $this->_get_admin_page_url() :
7875
+ $first_time_path
7876
+ );
7877
+ }
7878
+
7879
+ /**
7880
+ * Handle account page updates / edits / actions.
7881
+ *
7882
+ * @author Vova Feldman (@svovaf)
7883
+ * @since 1.0.2
7884
+ *
7885
+ */
7886
+ private function _handle_account_edits() {
7887
+ if ( ! current_user_can( 'activate_plugins' ) ) {
7888
+ return;
7889
+ }
7890
+
7891
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
7892
+ $action = fs_get_action();
7893
+
7894
+ switch ( $action ) {
7895
+ case 'delete_account':
7896
+ check_admin_referer( $action );
7897
+
7898
+ if ( $plugin_id == $this->get_id() ) {
7899
+ $this->delete_account_event();
7900
+
7901
+ // Clear user and site.
7902
+ $this->_site = null;
7903
+ $this->_user = null;
7904
+
7905
+ if ( fs_redirect( $this->get_activation_url() ) ) {
7906
+ exit();
7907
+ }
7908
+ } else {
7909
+ if ( $this->is_addon_activated( $plugin_id ) ) {
7910
+ $fs_addon = self::get_instance_by_id( $plugin_id );
7911
+ $fs_addon->delete_account_event();
7912
+
7913
+ if ( fs_redirect( $this->_get_admin_page_url( 'account' ) ) ) {
7914
+ exit();
7915
+ }
7916
+ }
7917
+ }
7918
+
7919
+ return;
7920
+
7921
+ case 'downgrade_account':
7922
+ check_admin_referer( $action );
7923
+ $this->_downgrade_site();
7924
+
7925
+ return;
7926
+
7927
+ case 'activate_license':
7928
+ check_admin_referer( $action );
7929
+
7930
+ if ( $plugin_id == $this->get_id() ) {
7931
+ $this->_activate_license();
7932
+ } else {
7933
+ if ( $this->is_addon_activated( $plugin_id ) ) {
7934
+ $fs_addon = self::get_instance_by_id( $plugin_id );
7935
+ $fs_addon->_activate_license();
7936
+ }
7937
+ }
7938
+
7939
+ return;
7940
+
7941
+ case 'deactivate_license':
7942
+ check_admin_referer( $action );
7943
+
7944
+ if ( $plugin_id == $this->get_id() ) {
7945
+ $this->_deactivate_license();
7946
+ } else {
7947
+ if ( $this->is_addon_activated( $plugin_id ) ) {
7948
+ $fs_addon = self::get_instance_by_id( $plugin_id );
7949
+ $fs_addon->_deactivate_license();
7950
+ }
7951
+ }
7952
+
7953
+ return;
7954
+
7955
+ case 'check_updates':
7956
+ check_admin_referer( $action );
7957
+ $this->_check_updates();
7958
+
7959
+ return;
7960
+
7961
+ case 'change_owner':
7962
+ $state = fs_request_get( 'state', 'init' );
7963
+ switch ( $state ) {
7964
+ case 'init':
7965
+ $candidate_email = fs_request_get( 'candidate_email', '' );
7966
+
7967
+ if ( $this->init_change_owner( $candidate_email ) ) {
7968
+ $this->_admin_notices->add( sprintf( __fs( 'change-owner-request-sent-x', $this->_slug ), '<b>' . $this->_user->email . '</b>' ) );
7969
+ }
7970
+ break;
7971
+ case 'owner_confirmed':
7972
+ $candidate_email = fs_request_get( 'candidate_email', '' );
7973
+
7974
+ $this->_admin_notices->add( sprintf( __fs( 'change-owner-request_owner-confirmed', $this->_slug ), '<b>' . $candidate_email . '</b>' ) );
7975
+ break;
7976
+ case 'candidate_confirmed':
7977
+ if ( $this->complete_change_owner() ) {
7978
+ $this->_admin_notices->add_sticky(
7979
+ sprintf( __fs( 'change-owner-request_candidate-confirmed', $this->_slug ), '<b>' . $this->_user->email . '</b>' ),
7980
+ 'ownership_changed',
7981
+ __fs( 'congrats', $this->_slug ) . '!'
7982
+ );
7983
+ } else {
7984
+ // @todo Handle failed ownership change message.
7985
+ }
7986
+ break;
7987
+ }
7988
+
7989
+ return;
7990
+
7991
+ case 'update_email':
7992
+ check_admin_referer( 'update_email' );
7993
+
7994
+ $new_email = fs_request_get( 'fs_email_' . $this->_slug, '' );
7995
+ $result = $this->_update_email( $new_email );
7996
+
7997
+ if ( isset( $result->error ) ) {
7998
+ switch ( $result->error->code ) {
7999
+ case 'user_exist':
8000
+ $this->_admin_notices->add(
8001
+ __fs( 'user-exist-message', $this->_slug ) . ' ' .
8002
+ sprintf( __fs( 'user-exist-message_ownership', $this->_slug ), '<b>' . $new_email . '</b>' ) .
8003
+ sprintf(
8004
+ '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
8005
+ $this->get_account_url( 'change_owner', array(
8006
+ 'state' => 'init',
8007
+ 'candidate_email' => $new_email
8008
+ ) ),
8009
+ __fs( 'change-ownership', $this->_slug )
8010
+ ),
8011
+ __fs( 'oops', $this->_slug ) . '...',
8012
+ 'error'
8013
+ );
8014
+ break;
8015
+ }
8016
+ } else {
8017
+ $this->_admin_notices->add( __fs( 'email-updated-message', $this->_slug ) );
8018
+ }
8019
+
8020
+ return;
8021
+
8022
+ case 'update_user_name':
8023
+ check_admin_referer( 'update_user_name' );
8024
+
8025
+ $result = $this->update_user_name();
8026
+
8027
+ if ( isset( $result->error ) ) {
8028
+ $this->_admin_notices->add(
8029
+ __fs( 'name-update-failed-message', $this->_slug ),
8030
+ __fs( 'oops', $this->_slug ) . '...',
8031
+ 'error'
8032
+ );
8033
+ } else {
8034
+ $this->_admin_notices->add( __fs( 'name-updated-message', $this->_slug ) );
8035
+ }
8036
+
8037
+ return;
8038
+
8039
+ #region Actions that might be called from external links (e.g. email)
8040
+
8041
+ case 'cancel_trial':
8042
+ if ( $plugin_id == $this->get_id() ) {
8043
+ $this->_cancel_trial();
8044
+ } else {
8045
+ if ( $this->is_addon_activated( $plugin_id ) ) {
8046
+ $fs_addon = self::get_instance_by_id( $plugin_id );
8047
+ $fs_addon->_cancel_trial();
8048
+ }
8049
+ }
8050
+
8051
+ return;
8052
+
8053
+ case 'verify_email':
8054
+ $this->verify_email();
8055
+
8056
+ return;
8057
+
8058
+ case 'sync_user':
8059
+ $this->_handle_account_user_sync();
8060
+
8061
+ return;
8062
+
8063
+ case $this->_slug . '_sync_license':
8064
+ $this->_sync_license();
8065
+
8066
+ return;
8067
+
8068
+ case 'download_latest':
8069
+ $this->_download_latest_directly( $plugin_id );
8070
+
8071
+ return;
8072
+
8073
+ #endregion
8074
+ }
8075
+
8076
+ if ( WP_FS__IS_POST_REQUEST ) {
8077
+ $properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
8078
+ foreach ( $properties as $p ) {
8079
+ if ( 'update_' . $p === $action ) {
8080
+ check_admin_referer( $action );
8081
+
8082
+ $this->_logger->log( $action );
8083
+
8084
+ $site_property = substr( $p, strlen( 'site_' ) );
8085
+ $site_property_value = fs_request_get( 'fs_' . $p . '_' . $this->_slug, '' );
8086
+ $this->get_site()->{$site_property} = $site_property_value;
8087
+
8088
+ // Store account after modification.
8089
+ $this->_store_site();
8090
+
8091
+ $this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );
8092
+
8093
+ $this->_admin_notices->add( sprintf(
8094
+ __fs( 'x-updated', $this->_slug ),
8095
+ '<b>' . str_replace( '_', ' ', $p ) . '</b>' ) );
8096
+
8097
+ return;
8098
+ }
8099
+ }
8100
+ }
8101
+ }
8102
+
8103
+ /**
8104
+ * Account page resources load.
8105
+ *
8106
+ * @author Vova Feldman (@svovaf)
8107
+ * @since 1.0.6
8108
+ */
8109
+ function _account_page_load() {
8110
+ $this->_logger->entrance();
8111
+
8112
+ $this->_logger->info( var_export( $_REQUEST, true ) );
8113
+
8114
+ fs_enqueue_local_style( 'fs_account', '/admin/account.css' );
8115
+
8116
+ if ( $this->has_addons() ) {
8117
+ wp_enqueue_script( 'plugin-install' );
8118
+ add_thickbox();
8119
+
8120
+ function fs_addons_body_class( $classes ) {
8121
+ $classes .= ' plugins-php';
8122
+
8123
+ return $classes;
8124
+ }
8125
+
8126
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
8127
+ }
8128
+
8129
+ if ( $this->has_paid_plan() &&
8130
+ ! $this->has_any_license() &&
8131
+ ! $this->is_sync_executed()
8132
+ ) {
8133
+ /**
8134
+ * If no licenses found and no sync job was executed during the last 24 hours,
8135
+ * just execute the sync job right away (blocking execution).
8136
+ *
8137
+ * @since 1.1.7.3
8138
+ */
8139
+ $this->run_manual_sync();
8140
+ }
8141
+
8142
+ $this->_handle_account_edits();
8143
+
8144
+ $this->do_action( 'account_page_load_before_departure' );
8145
+ }
8146
+
8147
+ /**
8148
+ * Render account page.
8149
+ *
8150
+ * @author Vova Feldman (@svovaf)
8151
+ * @since 1.0.0
8152
+ */
8153
+ function _account_page_render() {
8154
+ $this->_logger->entrance();
8155
+
8156
+ $vars = array( 'slug' => $this->_slug );
8157
+ fs_require_once_template( 'account.php', $vars );
8158
+ }
8159
+
8160
+ /**
8161
+ * Render account connect page.
8162
+ *
8163
+ * @author Vova Feldman (@svovaf)
8164
+ * @since 1.0.7
8165
+ */
8166
+ function _connect_page_render() {
8167
+ $this->_logger->entrance();
8168
+
8169
+ $vars = array( 'slug' => $this->_slug );
8170
+ fs_require_once_template( 'connect.php', $vars );
8171
+ }
8172
+
8173
+ /**
8174
+ * Load required resources before add-ons page render.
8175
+ *
8176
+ * @author Vova Feldman (@svovaf)
8177
+ * @since 1.0.6
8178
+ */
8179
+ function _addons_page_load() {
8180
+ $this->_logger->entrance();
8181
+
8182
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
8183
+
8184
+ wp_enqueue_script( 'plugin-install' );
8185
+ add_thickbox();
8186
+
8187
+ function fs_addons_body_class( $classes ) {
8188
+ $classes .= ' plugins-php';
8189
+
8190
+ return $classes;
8191
+ }
8192
+
8193
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
8194
+
8195
+ if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) {
8196
+ $this->_admin_notices->add(
8197
+ sprintf( __fs( 'addons-info-external-message', $this->_slug ), '<b>' . $this->get_plugin_name() . '</b>' ),
8198
+ __fs( 'heads-up', $this->_slug ),
8199
+ 'update-nag'
8200
+ );
8201
+ }
8202
+ }
8203
+
8204
+ /**
8205
+ * Render add-ons page.
8206
+ *
8207
+ * @author Vova Feldman (@svovaf)
8208
+ * @since 1.0.6
8209
+ */
8210
+ function _addons_page_render() {
8211
+ $this->_logger->entrance();
8212
+
8213
+ $vars = array( 'slug' => $this->_slug );
8214
+ fs_require_once_template( 'add-ons.php', $vars );
8215
+ }
8216
+
8217
+ /* Pricing & Upgrade
8218
+ ------------------------------------------------------------------------------------------------------------------*/
8219
+ /**
8220
+ * Render pricing page.
8221
+ *
8222
+ * @author Vova Feldman (@svovaf)
8223
+ * @since 1.0.0
8224
+ */
8225
+ function _pricing_page_render() {
8226
+ $this->_logger->entrance();
8227
+
8228
+ $vars = array( 'slug' => $this->_slug );
8229
+
8230
+ if ( 'true' === fs_request_get( 'checkout', false ) ) {
8231
+ fs_require_once_template( 'checkout.php', $vars );
8232
+ } else {
8233
+ fs_require_once_template( 'pricing.php', $vars );
8234
+ }
8235
+ }
8236
+
8237
+ #region Contact Us ------------------------------------------------------------------
8238
+
8239
+ /**
8240
+ * Render contact-us page.
8241
+ *
8242
+ * @author Vova Feldman (@svovaf)
8243
+ * @since 1.0.3
8244
+ */
8245
+ function _contact_page_render() {
8246
+ $this->_logger->entrance();
8247
+
8248
+ $vars = array( 'slug' => $this->_slug );
8249
+ fs_require_once_template( 'contact.php', $vars );
8250
+ }
8251
+
8252
+ #endregion ------------------------------------------------------------------
8253
+
8254
+ /**
8255
+ * Hide all admin notices to prevent distractions.
8256
+ *
8257
+ * @author Vova Feldman (@svovaf)
8258
+ * @since 1.0.3
8259
+ *
8260
+ * @uses remove_all_actions()
8261
+ */
8262
+ private static function _hide_admin_notices() {
8263
+ remove_all_actions( 'admin_notices' );
8264
+ remove_all_actions( 'network_admin_notices' );
8265
+ remove_all_actions( 'all_admin_notices' );
8266
+ remove_all_actions( 'user_admin_notices' );
8267
+ }
8268
+
8269
+ static function _clean_admin_content_section_hook() {
8270
+ self::_hide_admin_notices();
8271
+
8272
+ // Hide footer.
8273
+ echo '<style>#wpfooter { display: none !important; }</style>';
8274
+ }
8275
+
8276
+ /**
8277
+ * Attach to admin_head hook to hide all admin notices.
8278
+ *
8279
+ * @author Vova Feldman (@svovaf)
8280
+ * @since 1.0.3
8281
+ */
8282
+ static function _clean_admin_content_section() {
8283
+ add_action( 'admin_head', 'Freemius::_clean_admin_content_section_hook' );
8284
+ }
8285
+
8286
+ /* CSS & JavaScript
8287
+ ------------------------------------------------------------------------------------------------------------------*/
8288
+ /* function _enqueue_script($handle, $src) {
8289
+ $url = plugins_url( substr( WP_FS__DIR_JS, strlen( $this->_plugin_dir_path ) ) . '/assets/js/' . $src );
8290
+
8291
+ $this->_logger->entrance( 'script = ' . $url );
8292
+
8293
+ wp_enqueue_script( $handle, $url );
8294
+ }*/
8295
+
8296
+ /* SDK
8297
+ ------------------------------------------------------------------------------------------------------------------*/
8298
+ private $_user_api;
8299
+
8300
+ /**
8301
+ *
8302
+ * @author Vova Feldman (@svovaf)
8303
+ * @since 1.0.2
8304
+ *
8305
+ * @param bool $flush
8306
+ *
8307
+ * @return FS_Api
8308
+ */
8309
+ function get_api_user_scope( $flush = false ) {
8310
+ if ( ! isset( $this->_user_api ) || $flush ) {
8311
+ $this->_user_api = FS_Api::instance(
8312
+ $this->_slug,
8313
+ 'user',
8314
+ $this->_user->id,
8315
+ $this->_user->public_key,
8316
+ ! $this->is_live(),
8317
+ $this->_user->secret_key
8318
+ );
8319
+ }
8320
+
8321
+ return $this->_user_api;
8322
+ }
8323
+
8324
+ private $_site_api;
8325
+
8326
+ /**
8327
+ *
8328
+ * @author Vova Feldman (@svovaf)
8329
+ * @since 1.0.2
8330
+ *
8331
+ * @param bool $flush
8332
+ *
8333
+ * @return FS_Api
8334
+ */
8335
+ function get_api_site_scope( $flush = false ) {
8336
+ if ( ! isset( $this->_site_api ) || $flush ) {
8337
+ $this->_site_api = FS_Api::instance(
8338
+ $this->_slug,
8339
+ 'install',
8340
+ $this->_site->id,
8341
+ $this->_site->public_key,
8342
+ ! $this->is_live(),
8343
+ $this->_site->secret_key
8344
+ );
8345
+ }
8346
+
8347
+ return $this->_site_api;
8348
+ }
8349
+
8350
+ private $_plugin_api;
8351
+
8352
+ /**
8353
+ * Get plugin public API scope.
8354
+ *
8355
+ * @author Vova Feldman (@svovaf)
8356
+ * @since 1.0.7
8357
+ *
8358
+ * @return FS_Api
8359
+ */
8360
+ function get_api_plugin_scope() {
8361
+ if ( ! isset( $this->_plugin_api ) ) {
8362
+ $this->_plugin_api = FS_Api::instance(
8363
+ $this->_slug,
8364
+ 'plugin',
8365
+ $this->_plugin->id,
8366
+ $this->_plugin->public_key,
8367
+ ! $this->is_live()
8368
+ );
8369
+ }
8370
+
8371
+ return $this->_plugin_api;
8372
+ }
8373
+
8374
+ /**
8375
+ * Get site API scope object (fallback to public plugin scope when not registered).
8376
+ *
8377
+ * @author Vova Feldman (@svovaf)
8378
+ * @since 1.0.7
8379
+ *
8380
+ * @return FS_Api
8381
+ */
8382
+ function get_api_site_or_plugin_scope() {
8383
+ return $this->is_registered() ?
8384
+ $this->get_api_site_scope() :
8385
+ $this->get_api_plugin_scope();
8386
+ }
8387
+
8388
+ /**
8389
+ * Show trial promotional notice (if any trial exist).
8390
+ *
8391
+ * @author Vova Feldman (@svovaf)
8392
+ * @since 1.0.9
8393
+ *
8394
+ * @param $plans
8395
+ */
8396
+ function _check_for_trial_plans( $plans ) {
8397
+ $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
8398
+ }
8399
+
8400
+ /**
8401
+ * Show trial promotional notice (if any trial exist).
8402
+ *
8403
+ * @author Vova Feldman (@svovaf)
8404
+ * @since 1.0.9
8405
+ */
8406
+ function _add_trial_notice() {
8407
+ // Check if trial already utilized.
8408
+ if ( $this->_site->is_trial_utilized() ) {
8409
+ return;
8410
+ }
8411
+
8412
+ // Check if already paying.
8413
+ if ( $this->is_paying() ) {
8414
+ return;
8415
+ }
8416
+
8417
+ // Check if trial message is already shown.
8418
+ if ( $this->_admin_notices->has_sticky( 'trial_promotion' ) ) {
8419
+ return;
8420
+ }
8421
+
8422
+ $trial_plans = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
8423
+ $trial_plans_count = count( $trial_plans );
8424
+
8425
+ // Check if any of the plans contains trial.
8426
+ if ( 0 === $trial_plans_count ) {
8427
+ return;
8428
+ }
8429
+
8430
+ /**
8431
+ * @var FS_Plugin_Plan $paid_plan
8432
+ */
8433
+ $paid_plan = $trial_plans[0];
8434
+ $require_subscription = $paid_plan->is_require_subscription;
8435
+ $upgrade_url = $this->get_trial_url();
8436
+ $cc_string = $require_subscription ?
8437
+ sprintf( __fs( 'no-commitment-for-x-days', $this->_slug ), $paid_plan->trial_period ) :
8438
+ __fs( 'no-cc-required', $this->_slug ) . '!';
8439
+
8440
+
8441
+ $total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );
8442
+
8443
+ if ( $total_paid_plans === $trial_plans_count ) {
8444
+ // All paid plans have trials.
8445
+ $message = sprintf(
8446
+ __fs( 'hey', $this->_slug ) . '! ' . __fs( 'trial-x-promotion-message', $this->_slug ),
8447
+ sprintf( '<b>%s</b>', $this->get_plugin_name() ),
8448
+ strtolower( __fs( 'awesome', $this->_slug ) ),
8449
+ $paid_plan->trial_period
8450
+ );
8451
+ } else {
8452
+ $plans_string = '';
8453
+ for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
8454
+ $plans_string .= sprintf( '<a href="%s">%s</a>', $upgrade_url, $trial_plans[ $i ]->title );
8455
+
8456
+ if ( $i < $trial_plans_count - 2 ) {
8457
+ $plans_string .= ', ';
8458
+ } else if ( $i == $trial_plans_count - 2 ) {
8459
+ $plans_string .= ' and ';
8460
+ }
8461
+ }
8462
+
8463
+ // Not all paid plans have trials.
8464
+ $message = sprintf(
8465
+ __fs( 'hey', $this->_slug ) . '! ' . __fs( 'trial-x-promotion-message', $this->_slug ),
8466
+ sprintf( '<b>%s</b>', $this->get_plugin_name() ),
8467
+ $plans_string,
8468
+ $paid_plan->trial_period
8469
+ );
8470
+ }
8471
+
8472
+ $message .= ' ' . $cc_string;
8473
+
8474
+ // Add start trial button.
8475
+ $message .= ' ' . sprintf(
8476
+ '<a style="margin-left: 10px; vertical-align: super;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
8477
+ $upgrade_url,
8478
+ __fs( 'start-free-trial', $this->_slug )
8479
+ );
8480
+
8481
+ $this->_admin_notices->add_sticky(
8482
+ $this->apply_filters( 'trial_promotion_message', $message ),
8483
+ 'trial_promotion',
8484
+ '',
8485
+ 'promotion'
8486
+ );
8487
+
8488
+ $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;
8489
+ }
8490
+
8491
+ /* Action Links
8492
+ ------------------------------------------------------------------------------------------------------------------*/
8493
+ private $_action_links_hooked = false;
8494
+ private $_action_links = array();
8495
+
8496
+ /**
8497
+ * @author Vova Feldman (@svovaf)
8498
+ * @since 1.0.0
8499
+ *
8500
+ * @return bool
8501
+ */
8502
+ private function is_plugin_action_links_hooked() {
8503
+ $this->_logger->entrance( json_encode( $this->_action_links_hooked ) );
8504
+
8505
+ return $this->_action_links_hooked;
8506
+ }
8507
+
8508
+ /**
8509
+ * Hook to plugin action links filter.
8510
+ *
8511
+ * @author Vova Feldman (@svovaf)
8512
+ * @since 1.0.0
8513
+ */
8514
+ private function hook_plugin_action_links() {
8515
+ $this->_logger->entrance();
8516
+
8517
+ $this->_action_links_hooked = true;
8518
+
8519
+ $this->_logger->log( 'Adding action links hooks.' );
8520
+
8521
+ // Add action link to settings page.
8522
+ add_filter( 'plugin_action_links_' . $this->_plugin_basename, array(
8523
+ &$this,
8524
+ '_modify_plugin_action_links_hook'
8525
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
8526
+ add_filter( 'network_admin_plugin_action_links_' . $this->_plugin_basename, array(
8527
+ &$this,
8528
+ '_modify_plugin_action_links_hook'
8529
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
8530
+ }
8531
+
8532
+ /**
8533
+ * Add plugin action link.
8534
+ *
8535
+ * @author Vova Feldman (@svovaf)
8536
+ * @since 1.0.0
8537
+ *
8538
+ * @param $label
8539
+ * @param $url
8540
+ * @param bool $external
8541
+ * @param int $priority
8542
+ * @param bool $key
8543
+ */
8544
+ function add_plugin_action_link( $label, $url, $external = false, $priority = WP_FS__DEFAULT_PRIORITY, $key = false ) {
8545
+ $this->_logger->entrance();
8546
+
8547
+ if ( ! isset( $this->_action_links[ $priority ] ) ) {
8548
+ $this->_action_links[ $priority ] = array();
8549
+ }
8550
+
8551
+ if ( false === $key ) {
8552
+ $key = preg_replace( "/[^A-Za-z0-9 ]/", '', strtolower( $label ) );
8553
+ }
8554
+
8555
+ $this->_action_links[ $priority ][] = array(
8556
+ 'label' => $label,
8557
+ 'href' => $url,
8558
+ 'key' => $key,
8559
+ 'external' => $external
8560
+ );
8561
+ }
8562
+
8563
+ /**
8564
+ * Adds Upgrade and Add-Ons links to the main Plugins page link actions collection.
8565
+ *
8566
+ * @author Vova Feldman (@svovaf)
8567
+ * @since 1.0.0
8568
+ */
8569
+ function _add_upgrade_action_link() {
8570
+ $this->_logger->entrance();
8571
+
8572
+ if ( $this->is_registered() ) {
8573
+ if ( ! $this->is_paying() && $this->has_paid_plan() ) {
8574
+ $this->add_plugin_action_link(
8575
+ __fs( 'upgrade', $this->_slug ),
8576
+ $this->get_upgrade_url(),
8577
+ false,
8578
+ 7,
8579
+ 'upgrade'
8580
+ );
8581
+ }
8582
+
8583
+ if ( $this->has_addons() ) {
8584
+ $this->add_plugin_action_link(
8585
+ __fs( 'add-ons', $this->_slug ),
8586
+ $this->_get_admin_page_url( 'addons' ),
8587
+ false,
8588
+ 9,
8589
+ 'addons'
8590
+ );
8591
+ }
8592
+ }
8593
+ }
8594
+
8595
+ /**
8596
+ * Get the URL of the page that should be loaded right after the plugin activation.
8597
+ *
8598
+ * @author Vova Feldman (@svovaf)
8599
+ * @since 1.1.7.4
8600
+ *
8601
+ * @return string
8602
+ */
8603
+ function get_after_plugin_activation_redirect_url() {
8604
+ $url = false;
8605
+ $plugin_fs = false;
8606
+
8607
+ if ( ! $this->is_addon() ) {
8608
+ $first_time_path = $this->_menu->get_first_time_path();
8609
+ $plugin_fs = $this;
8610
+ $url = $plugin_fs->is_activation_mode() ?
8611
+ $plugin_fs->get_activation_url() :
8612
+ ( empty( $first_time_path ) ?
8613
+ $this->_get_admin_page_url() :
8614
+ $first_time_path );
8615
+ } else {
8616
+ if ( $this->is_parent_plugin_installed() ) {
8617
+ $plugin_fs = self::get_parent_instance();
8618
+ }
8619
+
8620
+ if ( is_object( $plugin_fs ) ) {
8621
+ if ( ! $plugin_fs->is_registered() ) {
8622
+ // Forward to parent plugin connect when parent not registered.
8623
+ $url = $plugin_fs->get_activation_url();
8624
+ } else {
8625
+ // Forward to account page.
8626
+ $url = $plugin_fs->_get_admin_page_url( 'account' );
8627
+ }
8628
+ }
8629
+ }
8630
+
8631
+ return $url;
8632
+ }
8633
+
8634
+ /**
8635
+ * Forward page to activation page.
8636
+ *
8637
+ * @author Vova Feldman (@svovaf)
8638
+ * @since 1.0.3
8639
+ */
8640
+ function _redirect_on_activation_hook() {
8641
+ $url = $this->get_after_plugin_activation_redirect_url();
8642
+
8643
+ if ( is_string( $url ) ) {
8644
+ fs_redirect( $url );
8645
+ exit();
8646
+ }
8647
+ }
8648
+
8649
+ /**
8650
+ * Modify plugin's page action links collection.
8651
+ *
8652
+ * @author Vova Feldman (@svovaf)
8653
+ * @since 1.0.0
8654
+ *
8655
+ * @param array $links
8656
+ * @param $file
8657
+ *
8658
+ * @return array
8659
+ */
8660
+ function _modify_plugin_action_links_hook( $links, $file ) {
8661
+ $this->_logger->entrance();
8662
+
8663
+ $passed_deactivate = false;
8664
+ $deactivate_link = '';
8665
+ $before_deactivate = array();
8666
+ $after_deactivate = array();
8667
+ foreach ( $links as $key => $link ) {
8668
+ if ( 'deactivate' === $key ) {
8669
+ $deactivate_link = $link;
8670
+ $passed_deactivate = true;
8671
+ continue;
8672
+ }
8673
+
8674
+ if ( ! $passed_deactivate ) {
8675
+ $before_deactivate[ $key ] = $link;
8676
+ } else {
8677
+ $after_deactivate[ $key ] = $link;
8678
+ }
8679
+ }
8680
+
8681
+ ksort( $this->_action_links );
8682
+
8683
+ foreach ( $this->_action_links as $new_links ) {
8684
+ foreach ( $new_links as $link ) {
8685
+ $before_deactivate[ $link['key'] ] = '<a href="' . $link['href'] . '"' . ( $link['external'] ? ' target="_blank"' : '' ) . '>' . $link['label'] . '</a>';
8686
+ }
8687
+ }
8688
+
8689
+ if ( ! empty( $deactivate_link ) ) {
8690
+ if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
8691
+ /*
8692
+ * This HTML element is used to identify the correct plugin when attaching an event to its Deactivate link.
8693
+ *
8694
+ * If user is paying or in trial and have the free version installed,
8695
+ * assume that the deactivation is for the upgrade process, so this is not needed.
8696
+ */
8697
+ $deactivate_link .= '<i class="fs-slug" data-slug="' . $this->_slug . '"></i>';
8698
+ }
8699
+
8700
+ // Append deactivation link.
8701
+ $before_deactivate['deactivate'] = $deactivate_link;
8702
+ }
8703
+
8704
+ return array_merge( $before_deactivate, $after_deactivate );
8705
+ }
8706
+
8707
+ /**
8708
+ * Adds admin message.
8709
+ *
8710
+ * @author Vova Feldman (@svovaf)
8711
+ * @since 1.0.4
8712
+ *
8713
+ * @param string $message
8714
+ * @param string $title
8715
+ * @param string $type
8716
+ */
8717
+ function add_admin_message( $message, $title = '', $type = 'success' ) {
8718
+ $this->_admin_notices->add( $message, $title, $type );
8719
+ }
8720
+
8721
+ /**
8722
+ * Adds sticky admin message.
8723
+ *
8724
+ * @author Vova Feldman (@svovaf)
8725
+ * @since 1.1.0
8726
+ *
8727
+ * @param string $message
8728
+ * @param string $id
8729
+ * @param string $title
8730
+ * @param string $type
8731
+ */
8732
+ function add_sticky_admin_message( $message, $id, $title = '', $type = 'success' ) {
8733
+ $this->_admin_notices->add_sticky( $message, $id, $title, $type );
8734
+ }
8735
+
8736
+ /* Plugin Auto-Updates (@since 1.0.4)
8737
+ ------------------------------------------------------------------------------------------------------------------*/
8738
+ /**
8739
+ * @var string[]
8740
+ */
8741
+ private static $_auto_updated_plugins;
8742
+
8743
+ /**
8744
+ * @todo TEST IF IT WORKS!!!
8745
+ *
8746
+ * Include plugins for automatic updates based on stored settings.
8747
+ *
8748
+ * @see http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
8749
+ *
8750
+ * @author Vova Feldman (@svovaf)
8751
+ * @since 1.0.4
8752
+ *
8753
+ * @param bool $update Whether to update (not used for plugins)
8754
+ * @param object $item The plugin's info
8755
+ *
8756
+ * @return bool
8757
+ */
8758
+ static function _include_plugins_in_auto_update( $update, $item ) {
8759
+ // Before version 3.8.2 the $item was the file name of the plugin,
8760
+ // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
8761
+ $by_slug = ( (int) str_replace( '.', '', get_bloginfo( 'version' ) ) >= 382 );
8762
+
8763
+ if ( ! isset( self::$_auto_updated_plugins ) ) {
8764
+ $plugins = self::$_accounts->get_option( 'plugins', array() );
8765
+
8766
+ $identifiers = array();
8767
+ foreach ( $plugins as $p ) {
8768
+ /**
8769
+ * @var FS_Plugin $p
8770
+ */
8771
+ if ( isset( $p->auto_update ) && $p->auto_update ) {
8772
+ $identifiers[] = ( $by_slug ? $p->slug : plugin_basename( $p->file ) );
8773
+ }
8774
+ }
8775
+
8776
+ self::$_auto_updated_plugins = $identifiers;
8777
+ }
8778
+
8779
+ if ( in_array( $by_slug ? $item->slug : $item, self::$_auto_updated_plugins ) ) {
8780
+ return true;
8781
+ }
8782
+
8783
+ // Pass update decision to next filters
8784
+ return $update;
8785
+ }
8786
+
8787
+ #region Versioning ------------------------------------------------------------------
8788
+
8789
+ /**
8790
+ * Check if Freemius in SDK upgrade mode.
8791
+ *
8792
+ * @author Vova Feldman (@svovaf)
8793
+ * @since 1.0.9
8794
+ *
8795
+ * @return bool
8796
+ */
8797
+ function is_sdk_upgrade_mode() {
8798
+ return isset( $this->_storage->sdk_upgrade_mode ) ?
8799
+ $this->_storage->sdk_upgrade_mode :
8800
+ false;
8801
+ }
8802
+
8803
+ /**
8804
+ * Turn SDK upgrade mode off.
8805
+ *
8806
+ * @author Vova Feldman (@svovaf)
8807
+ * @since 1.0.9
8808
+ *
8809
+ * @return bool
8810
+ */
8811
+ function set_sdk_upgrade_complete() {
8812
+ $this->_storage->sdk_upgrade_mode = false;
8813
+ }
8814
+
8815
+ /**
8816
+ * Check if plugin upgrade mode.
8817
+ *
8818
+ * @author Vova Feldman (@svovaf)
8819
+ * @since 1.0.9
8820
+ *
8821
+ * @return bool
8822
+ */
8823
+ function is_plugin_upgrade_mode() {
8824
+ return isset( $this->_storage->plugin_upgrade_mode ) ?
8825
+ $this->_storage->plugin_upgrade_mode :
8826
+ false;
8827
+ }
8828
+
8829
+ /**
8830
+ * Turn plugin upgrade mode off.
8831
+ *
8832
+ * @author Vova Feldman (@svovaf)
8833
+ * @since 1.0.9
8834
+ *
8835
+ * @return bool
8836
+ */
8837
+ function set_plugin_upgrade_complete() {
8838
+ $this->_storage->plugin_upgrade_mode = false;
8839
+ }
8840
+
8841
+ #endregion ------------------------------------------------------------------
8842
+
8843
+ #region Permissions ------------------------------------------------------------------
8844
+
8845
+ /**
8846
+ * Check if specific permission requested.
8847
+ *
8848
+ * @author Vova Feldman (@svovaf)
8849
+ * @since 1.1.6
8850
+ *
8851
+ * @param string $permission
8852
+ *
8853
+ * @return bool
8854
+ */
8855
+ function is_permission_requested( $permission ) {
8856
+ return isset( $this->_permissions[ $permission ] ) && ( true === $this->_permissions[ $permission ] );
8857
+ }
8858
+
8859
+ #endregion Permissions ------------------------------------------------------------------
8860
+
8861
+ #region Marketing ------------------------------------------------------------------
8862
+
8863
+ /**
8864
+ * Check if current user purchased any other plugins before.
8865
+ *
8866
+ * @author Vova Feldman (@svovaf)
8867
+ * @since 1.0.9
8868
+ *
8869
+ * @return bool
8870
+ */
8871
+ function has_purchased_before() {
8872
+ // TODO: Implement has_purchased_before() method.
8873
+ }
8874
+
8875
+ /**
8876
+ * Check if current user classified as an agency.
8877
+ *
8878
+ * @author Vova Feldman (@svovaf)
8879
+ * @since 1.0.9
8880
+ *
8881
+ * @return bool
8882
+ */
8883
+ function is_agency() {
8884
+ // TODO: Implement is_agency() method.
8885
+ }
8886
+
8887
+ /**
8888
+ * Check if current user classified as a developer.
8889
+ *
8890
+ * @author Vova Feldman (@svovaf)
8891
+ * @since 1.0.9
8892
+ *
8893
+ * @return bool
8894
+ */
8895
+ function is_developer() {
8896
+ // TODO: Implement is_developer() method.
8897
+ }
8898
+
8899
+ /**
8900
+ * Check if current user classified as a business.
8901
+ *
8902
+ * @author Vova Feldman (@svovaf)
8903
+ * @since 1.0.9
8904
+ *
8905
+ * @return bool
8906
+ */
8907
+ function is_business() {
8908
+ // TODO: Implement is_business() method.
8909
+ }
8910
+
8911
+ #endregion ------------------------------------------------------------------
8912
+ }
freemius/includes/class-fs-api.php ADDED
@@ -0,0 +1,453 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Class FS_Api
15
+ *
16
+ * Wraps Freemius API SDK to handle:
17
+ * 1. Clock sync.
18
+ * 2. Fallback to HTTP when HTTPS fails.
19
+ * 3. Adds caching layer to GET requests.
20
+ * 4. Adds consistency for failed requests by using last cached version.
21
+ */
22
+ class FS_Api {
23
+ /**
24
+ * @var FS_Api[]
25
+ */
26
+ private static $_instances = array();
27
+
28
+ /**
29
+ * @var FS_Option_Manager Freemius options, options-manager.
30
+ */
31
+ private static $_options;
32
+
33
+ /**
34
+ * @var FS_Cache_Manager API Caching layer
35
+ */
36
+ private static $_cache;
37
+
38
+ /**
39
+ * @var int Clock diff in seconds between current server to API server.
40
+ */
41
+ private static $_clock_diff;
42
+
43
+ /**
44
+ * @var Freemius_Api
45
+ */
46
+ private $_api;
47
+
48
+ /**
49
+ * @var string
50
+ */
51
+ private $_slug;
52
+
53
+ /**
54
+ * @var FS_Logger
55
+ * @since 1.0.4
56
+ */
57
+ private $_logger;
58
+
59
+ /**
60
+ * @param string $slug
61
+ * @param string $scope 'app', 'developer', 'user' or 'install'.
62
+ * @param number $id Element's id.
63
+ * @param string $public_key Public key.
64
+ * @param bool $is_sandbox
65
+ * @param bool|string $secret_key Element's secret key.
66
+ *
67
+ * @return FS_Api
68
+ */
69
+ static function instance( $slug, $scope, $id, $public_key, $is_sandbox, $secret_key = false ) {
70
+ $identifier = md5( $slug . $scope . $id . $public_key . ( is_string( $secret_key ) ? $secret_key : '' ) . json_encode( $is_sandbox ) );
71
+
72
+ if ( ! isset( self::$_instances[ $identifier ] ) ) {
73
+ self::_init();
74
+
75
+ self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox );
76
+ }
77
+
78
+ return self::$_instances[ $identifier ];
79
+ }
80
+
81
+ private static function _init() {
82
+ if ( isset( self::$_options ) ) {
83
+ return;
84
+ }
85
+
86
+ if ( ! class_exists( 'Freemius_Api' ) ) {
87
+ require_once( WP_FS__DIR_SDK . '/Freemius.php' );
88
+ }
89
+
90
+ self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true );
91
+ self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
92
+
93
+ self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
94
+ Freemius_Api::SetClockDiff( self::$_clock_diff );
95
+
96
+ if ( self::$_options->get_option( 'api_force_http', false ) ) {
97
+ Freemius_Api::SetHttp();
98
+ }
99
+ }
100
+
101
+ /**
102
+ * @param string $slug
103
+ * @param string $scope 'app', 'developer', 'user' or 'install'.
104
+ * @param number $id Element's id.
105
+ * @param string $public_key Public key.
106
+ * @param bool|string $secret_key Element's secret key.
107
+ * @param bool $is_sandbox
108
+ */
109
+ private function __construct( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox ) {
110
+ $this->_api = new Freemius_Api( $scope, $id, $public_key, $secret_key, $is_sandbox );
111
+
112
+ $this->_slug = $slug;
113
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
114
+ }
115
+
116
+ /**
117
+ * Find clock diff between server and API server, and store the diff locally.
118
+ *
119
+ * @param bool|int $diff
120
+ *
121
+ * @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
122
+ */
123
+ private function _sync_clock_diff( $diff = false ) {
124
+ $this->_logger->entrance();
125
+
126
+ // Sync clock and store.
127
+ $new_clock_diff = ( false === $diff ) ?
128
+ Freemius_Api::FindClockDiff() :
129
+ $diff;
130
+
131
+ if ( $new_clock_diff === self::$_clock_diff ) {
132
+ return false;
133
+ }
134
+
135
+ self::$_clock_diff = $new_clock_diff;
136
+
137
+ // Update API clock's diff.
138
+ Freemius_Api::SetClockDiff( self::$_clock_diff );
139
+
140
+ // Store new clock diff in storage.
141
+ self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
142
+
143
+ return $new_clock_diff;
144
+ }
145
+
146
+ /**
147
+ * Override API call to enable retry with servers' clock auto sync method.
148
+ *
149
+ * @param string $path
150
+ * @param string $method
151
+ * @param array $params
152
+ * @param bool $retry Is in retry or first call attempt.
153
+ *
154
+ * @return array|mixed|string|void
155
+ */
156
+ private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
157
+ $this->_logger->entrance( $method . ':' . $path );
158
+
159
+ if ( self::is_temporary_down() ) {
160
+ $result = $this->get_temporary_unavailable_error();
161
+ } else {
162
+ $result = $this->_api->Api( $path, $method, $params );
163
+
164
+ if ( null !== $result &&
165
+ isset( $result->error ) &&
166
+ isset( $result->error->code ) &&
167
+ 'request_expired' === $result->error->code
168
+ ) {
169
+ if ( ! $retry ) {
170
+ $diff = isset( $result->error->timestamp ) ?
171
+ ( time() - strtotime( $result->error->timestamp ) ) :
172
+ false;
173
+
174
+ // Try to sync clock diff.
175
+ if ( false !== $this->_sync_clock_diff( $diff ) ) {
176
+ // Retry call with new synced clock.
177
+ return $this->_call( $path, $method, $params, true );
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ if ( null !== $result && isset( $result->error ) && isset( $result->error->message ) ) {
184
+ // Log API errors.
185
+ $this->_logger->error( $result->error->message );
186
+ }
187
+
188
+ return $result;
189
+ }
190
+
191
+ /**
192
+ * Override API call to wrap it in servers' clock sync method.
193
+ *
194
+ * @param string $path
195
+ * @param string $method
196
+ * @param array $params
197
+ *
198
+ * @return array|mixed|string|void
199
+ * @throws Freemius_Exception
200
+ */
201
+ function call( $path, $method = 'GET', $params = array() ) {
202
+ return $this->_call( $path, $method, $params );
203
+ }
204
+
205
+ /**
206
+ * Get API request URL signed via query string.
207
+ *
208
+ * @param string $path
209
+ *
210
+ * @return string
211
+ */
212
+ function get_signed_url( $path ) {
213
+ return $this->_api->GetSignedUrl( $path );
214
+ }
215
+
216
+ /**
217
+ * @param string $path
218
+ * @param bool $flush
219
+ * @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
220
+ *
221
+ * @return stdClass|mixed
222
+ */
223
+ function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
224
+ $this->_logger->entrance( $path );
225
+
226
+ $cache_key = $this->get_cache_key( $path );
227
+
228
+ // Always flush during development.
229
+ if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
230
+ $flush = true;
231
+ }
232
+
233
+ $cached_result = self::$_cache->get( $cache_key );
234
+
235
+ if ( $flush || ! self::$_cache->has_valid( $cache_key ) ) {
236
+ $result = $this->call( $path );
237
+
238
+ if ( ! is_object( $result ) || isset( $result->error ) ) {
239
+ // Api returned an error.
240
+ if ( is_object( $cached_result ) &&
241
+ ! isset( $cached_result )
242
+ ) {
243
+ // If there was an error during a newer data fetch,
244
+ // fallback to older data version.
245
+ $result = $cached_result;
246
+ } else {
247
+ // If no older data version, return result without
248
+ // caching the error.
249
+ return $result;
250
+ }
251
+ }
252
+
253
+ self::$_cache->set( $cache_key, $result, $expiration );
254
+
255
+ $cached_result = $result;
256
+ }
257
+
258
+ return $cached_result;
259
+ }
260
+
261
+ private function get_cache_key( $path, $method = 'GET', $params = array() ) {
262
+ $canonized = $this->_api->CanonizePath( $path );
263
+ // $exploded = explode('/', $canonized);
264
+ // return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
265
+ return $method . ':' . $canonized . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
266
+ }
267
+
268
+ /**
269
+ * Test API connectivity.
270
+ *
271
+ * @author Vova Feldman (@svovaf)
272
+ * @since 1.0.9 If fails, try to fallback to HTTP.
273
+ * @since 1.1.6 Added a 5-min caching mechanism, to prevent from overloading the server if the API if
274
+ * temporary down.
275
+ *
276
+ * @return bool True if successful connectivity to the API.
277
+ */
278
+ static function test() {
279
+ self::_init();
280
+
281
+ $cache_key = 'ping_test';
282
+
283
+ $test = self::$_cache->get_valid( $cache_key, null );
284
+
285
+ if ( is_null( $test ) ) {
286
+ $test = Freemius_Api::Test();
287
+
288
+ if ( false === $test && Freemius_Api::IsHttps() ) {
289
+ // Fallback to HTTP, since HTTPS fails.
290
+ Freemius_Api::SetHttp();
291
+
292
+ self::$_options->set_option( 'api_force_http', true, true );
293
+
294
+ $test = Freemius_Api::Test();
295
+
296
+ if ( false === $test ) {
297
+ /**
298
+ * API connectivity test fail also in HTTP request, therefore,
299
+ * fallback to HTTPS to keep connection secure.
300
+ *
301
+ * @since 1.1.6
302
+ */
303
+ self::$_options->set_option( 'api_force_http', false, true );
304
+ }
305
+ }
306
+
307
+ self::$_cache->set( $cache_key, $test, WP_FS__TIME_5_MIN_IN_SEC );
308
+ }
309
+
310
+ return $test;
311
+ }
312
+
313
+ /**
314
+ * Check if API is temporary down.
315
+ *
316
+ * @author Vova Feldman (@svovaf)
317
+ * @since 1.1.6
318
+ *
319
+ * @return bool
320
+ */
321
+ static function is_temporary_down() {
322
+ self::_init();
323
+
324
+ $test = self::$_cache->get_valid( 'ping_test', null );
325
+
326
+ return ( false === $test );
327
+ }
328
+
329
+ /**
330
+ * @author Vova Feldman (@svovaf)
331
+ * @since 1.1.6
332
+ *
333
+ * @return object
334
+ */
335
+ private function get_temporary_unavailable_error() {
336
+ return (object) array(
337
+ 'error' => array(
338
+ 'type' => 'TemporaryUnavailable',
339
+ 'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
340
+ 'code' => 'temporary_unavailable',
341
+ 'http' => 503
342
+ )
343
+ );
344
+ }
345
+
346
+ /**
347
+ * Ping API for connectivity test, and return result object.
348
+ *
349
+ * @author Vova Feldman (@svovaf)
350
+ * @since 1.0.9
351
+ *
352
+ * @param null|string $unique_anonymous_id
353
+ * @param array $params
354
+ *
355
+ * @return object
356
+ */
357
+ function ping( $unique_anonymous_id = null, $params = array() ) {
358
+ $this->_logger->entrance();
359
+
360
+ if ( self::is_temporary_down() ) {
361
+ return $this->get_temporary_unavailable_error();
362
+ }
363
+
364
+ $pong = is_null( $unique_anonymous_id ) ?
365
+ Freemius_Api::Ping() :
366
+ $this->_call( 'ping.json?' . http_build_query( array_merge( $params, array(
367
+ 'uid' => $unique_anonymous_id,
368
+ ) ) ) );
369
+
370
+ if ( $this->is_valid_ping( $pong ) ) {
371
+ return $pong;
372
+ }
373
+
374
+ if ( self::should_try_with_http( $pong ) ) {
375
+ // Fallback to HTTP, since HTTPS fails.
376
+ Freemius_Api::SetHttp();
377
+
378
+ self::$_options->set_option( 'api_force_http', true, true );
379
+
380
+ $pong = is_null( $unique_anonymous_id ) ?
381
+ Freemius_Api::Ping() :
382
+ $this->_call( 'ping.json?' . http_build_query( array_merge( $params, array(
383
+ 'uid' => $unique_anonymous_id,
384
+ ) ) ) );
385
+
386
+ if ( ! $this->is_valid_ping( $pong ) ) {
387
+ self::$_options->set_option( 'api_force_http', false, true );
388
+ }
389
+ }
390
+
391
+ return $pong;
392
+ }
393
+
394
+ /**
395
+ * Check if based on the API result we should try
396
+ * to re-run the same request with HTTP instead of HTTPS.
397
+ *
398
+ * @author Vova Feldman (@svovaf)
399
+ * @since 1.1.6
400
+ *
401
+ * @param $result
402
+ *
403
+ * @return bool
404
+ */
405
+ private static function should_try_with_http( $result ) {
406
+ if ( ! Freemius_Api::IsHttps() ) {
407
+ return false;
408
+ }
409
+
410
+ return ( ! is_object( $result ) ||
411
+ ! isset( $result->error ) ||
412
+ ! isset( $result->error->code ) ||
413
+ ! in_array( $result->error->code, array(
414
+ 'curl_missing',
415
+ 'cloudflare_ddos_protection',
416
+ 'maintenance_mode',
417
+ 'squid_cache_block',
418
+ 'too_many_requests',
419
+ ) ) );
420
+
421
+ }
422
+
423
+ /**
424
+ * Check if valid ping request result.
425
+ *
426
+ * @author Vova Feldman (@svovaf)
427
+ * @since 1.1.1
428
+ *
429
+ * @param mixed $pong
430
+ *
431
+ * @return bool
432
+ */
433
+ function is_valid_ping( $pong ) {
434
+ return Freemius_Api::Test( $pong );
435
+ }
436
+
437
+ function get_url( $path = '' ) {
438
+ return Freemius_Api::GetUrl( $path, $this->_api->IsSandbox() );
439
+ }
440
+
441
+ /**
442
+ * Clear API cache.
443
+ *
444
+ * @author Vova Feldman (@svovaf)
445
+ * @since 1.0.9
446
+ */
447
+ static function clear_cache() {
448
+ self::_init();
449
+
450
+ self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
451
+ self::$_cache->clear( true );
452
+ }
453
+ }
freemius/includes/class-fs-logger.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Logger {
14
+ private $_id;
15
+ private $_on = false;
16
+ private $_echo = false;
17
+ private $_file_start = 0;
18
+
19
+ private static $LOGGERS = array();
20
+ private static $LOG = array();
21
+ private static $CNT = 0;
22
+ private static $_HOOKED_FOOTER = false;
23
+
24
+ private function __construct( $id, $on = false, $echo = false ) {
25
+ $this->_id = $id;
26
+
27
+ $bt = debug_backtrace();
28
+ $caller = $bt[2];
29
+
30
+ $this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
31
+
32
+ if ( $on ) {
33
+ $this->on();
34
+ }
35
+ if ( $echo ) {
36
+ $this->echo_on();
37
+ }
38
+ }
39
+
40
+ /**
41
+ * @param string $id
42
+ * @param bool $on
43
+ * @param bool $echo
44
+ *
45
+ * @return FS_Logger
46
+ */
47
+ public static function get_logger( $id, $on = false, $echo = false ) {
48
+ $id = strtolower( $id );
49
+
50
+ if ( ! isset( self::$LOGGERS[ $id ] ) ) {
51
+ self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
52
+ }
53
+
54
+ return self::$LOGGERS[ $id ];
55
+ }
56
+
57
+ private static function _hook_footer() {
58
+ if ( self::$_HOOKED_FOOTER ) {
59
+ return;
60
+ }
61
+
62
+ if ( is_admin() ) {
63
+ add_action( 'admin_footer', 'FS_Logger::dump', 100 );
64
+ } else {
65
+ add_action( 'wp_footer', 'FS_Logger::dump', 100 );
66
+ }
67
+ }
68
+
69
+ function is_on() {
70
+ return $this->_on;
71
+ }
72
+
73
+ function on() {
74
+ $this->_on = true;
75
+
76
+ self::_hook_footer();
77
+ }
78
+
79
+ function echo_on() {
80
+ $this->on();
81
+
82
+ $this->_echo = true;
83
+ }
84
+
85
+ function is_echo_on() {
86
+ return $this->_echo;
87
+ }
88
+
89
+ function get_id() {
90
+ return $this->_id;
91
+ }
92
+
93
+ function get_file() {
94
+ return $this->_file_start;
95
+ }
96
+
97
+ private function _log( &$message, $type = 'log', $wrapper ) {
98
+ if ( ! $this->is_on() ) {
99
+ return;
100
+ }
101
+
102
+ $bt = debug_backtrace();
103
+ $depth = $wrapper ? 3 : 2;
104
+ while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
105
+ $depth ++;
106
+ }
107
+
108
+ $caller = $bt[ $depth ];
109
+
110
+ $log = array_merge( $caller, array(
111
+ 'cnt' => self::$CNT ++,
112
+ 'logger' => $this,
113
+ 'timestamp' => microtime(true),
114
+ 'type' => $type,
115
+ 'msg' => $message,
116
+ ) );
117
+
118
+ self::$LOG[] = $log;
119
+
120
+ if ( $this->is_echo_on() ) {
121
+ echo self::format_html( $log ) . "\n";
122
+ }
123
+ }
124
+
125
+ function log( $message, $wrapper = false ) {
126
+ $this->_log( $message, 'log', $wrapper );
127
+ }
128
+
129
+ function info( $message, $wrapper = false ) {
130
+ $this->_log( $message, 'info', $wrapper );
131
+ }
132
+
133
+ function warn( $message, $wrapper = false ) {
134
+ $this->_log( $message, 'warn', $wrapper );
135
+ }
136
+
137
+ function error( $message, $wrapper = false ) {
138
+ $this->_log( $message, 'error', $wrapper );
139
+ }
140
+
141
+ function entrance( $message = '', $wrapper = false ) {
142
+ $msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
143
+
144
+ $this->_log( $msg, 'log', $wrapper );
145
+ }
146
+
147
+ function departure( $message = '', $wrapper = false ) {
148
+ $msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
149
+
150
+ $this->_log( $msg, 'log', $wrapper );
151
+ }
152
+
153
+ private static function format( $log, $show_type = true ) {
154
+ return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['type'] . ']' : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
155
+ }
156
+
157
+ private static function format_html( $log ) {
158
+ return '<div style="font-size: 11px; padding: 3px; background: #ccc; margin-bottom: 3px;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['type'] . '] <b><code style="color: blue;">' . $log['function'] . '</code> >> <b style="color: darkorange;">' . $log['msg'] . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
159
+ }
160
+
161
+ static function dump() {
162
+ ?>
163
+ <!-- BEGIN: Freemius PHP Console Log -->
164
+ <script type="text/javascript">
165
+ <?php
166
+ foreach (self::$LOG as $log)
167
+ {
168
+ echo 'console.' . $log['type'] . '(' . json_encode(self::format($log, false)) . ')' . "\n";
169
+ }
170
+ ?>
171
+ </script>
172
+ <!-- END: Freemius PHP Console Log -->
173
+ <?php
174
+ }
175
+
176
+ static function get_log() {
177
+ return self::$LOG;
178
+ }
179
+ }
freemius/includes/class-fs-plugin-updater.php ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ *
8
+ * @link https://github.com/easydigitaldownloads/EDD-License-handler/blob/master/EDD_SL_Plugin_Updater.php
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ // Uncomment this line for testing.
16
+ // set_site_transient( 'update_plugins', null );
17
+
18
+ class FS_Plugin_Updater {
19
+
20
+ /**
21
+ * @var Freemius
22
+ * @since 1.0.4
23
+ */
24
+ private $_fs;
25
+ /**
26
+ * @var FS_Logger
27
+ * @since 1.0.4
28
+ */
29
+ private $_logger;
30
+ /**
31
+ * @var bool
32
+ * @since 1.1.7
33
+ */
34
+ private $_update_checked = false;
35
+
36
+ function __construct( Freemius $freemius ) {
37
+ $this->_fs = $freemius;
38
+
39
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $freemius->get_slug() . '_updater', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
40
+
41
+ $this->_filters();
42
+ }
43
+
44
+ /**
45
+ * Initiate required filters.
46
+ *
47
+ * @author Vova Feldman (@svovaf)
48
+ * @since 1.0.4
49
+ */
50
+ private function _filters() {
51
+ // Override request for plugin information
52
+ add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
53
+
54
+ // WP 3.0+
55
+ add_filter( 'pre_set_site_transient_update_plugins', array(
56
+ &$this,
57
+ 'pre_set_site_transient_update_plugins_filter'
58
+ ) );
59
+
60
+ if ( ! $this->_fs->has_active_license() ) {
61
+ /**
62
+ * If user has the premium plugin's code but do NOT have an active license,
63
+ * encourage him to upgrade by showing that there's a new release, but instead
64
+ * of showing an update link, show upgrade link to the pricing page.
65
+ *
66
+ * @since 1.1.6
67
+ *
68
+ */
69
+ // WP 2.9+
70
+ add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array(
71
+ &$this,
72
+ 'catch_plugin_update_row'
73
+ ), 9 );
74
+ add_action( "after_plugin_row_{$this->_fs->get_plugin_basename()}", array(
75
+ &$this,
76
+ 'edit_and_echo_plugin_update_row'
77
+ ), 11, 2 );
78
+ }
79
+
80
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
81
+ add_filter( 'http_request_host_is_external', array(
82
+ $this,
83
+ 'http_request_host_is_external_filter'
84
+ ), 10, 3 );
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Capture plugin update row by turning output buffering.
90
+ *
91
+ * @author Vova Feldman (@svovaf)
92
+ * @since 1.1.6
93
+ */
94
+ function catch_plugin_update_row() {
95
+ ob_start();
96
+ }
97
+
98
+ /**
99
+ * Overrides default update message format with "renew your license" message.
100
+ *
101
+ * @author Vova Feldman (@svovaf)
102
+ * @since 1.1.6
103
+ */
104
+ function edit_and_echo_plugin_update_row( $file, $plugin_data ) {
105
+ $plugin_update_row = ob_get_clean();
106
+
107
+ $current = get_site_transient( 'update_plugins' );
108
+ if ( ! isset( $current->response[ $file ] ) ) {
109
+ echo $plugin_update_row;
110
+
111
+ return false;
112
+ }
113
+
114
+ $r = $current->response[ $file ];
115
+
116
+ $plugin_update_row = preg_replace(
117
+ '/(\<div.+>)(.+)(\<a.+\<a.+)\<\/div\>/is',
118
+ '$1 $2 ' . sprintf(
119
+ __fs( 'renew-license-now' ),
120
+ '<a href="' . $this->_fs->pricing_url() . '">', '</a>',
121
+ $r->new_version ) .
122
+ '$4',
123
+ $plugin_update_row
124
+ );
125
+
126
+ echo $plugin_update_row;
127
+ }
128
+
129
+ /**
130
+ * Since WP version 3.6, a new security feature was added that denies access to repository with a local ip.
131
+ * During development mode we want to be able updating plugin versions via our localhost repository. This
132
+ * filter white-list all domains including "api.freemius".
133
+ *
134
+ * @link http://www.emanueletessore.com/wordpress-download-failed-valid-url-provided/
135
+ *
136
+ * @author Vova Feldman (@svovaf)
137
+ * @since 1.0.4
138
+ *
139
+ * @param bool $allow
140
+ * @param string $host
141
+ * @param string $url
142
+ *
143
+ * @return bool
144
+ */
145
+ function http_request_host_is_external_filter( $allow, $host, $url ) {
146
+ return ( false !== strpos( $host, 'freemius' ) ) ? true : $allow;
147
+ }
148
+
149
+ /**
150
+ * Check for Updates at the defined API endpoint and modify the update array.
151
+ *
152
+ * This function dives into the update api just when WordPress creates its update array,
153
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
154
+ * It is reassembled from parts of the native WordPress plugin update code.
155
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
156
+ *
157
+ * @author Vova Feldman (@svovaf)
158
+ * @since 1.0.4
159
+ *
160
+ * @uses FS_Api
161
+ *
162
+ * @param stdClass $transient_data Update array build by WordPress.
163
+ *
164
+ * @return array Modified update array with custom plugin data.
165
+ */
166
+ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
167
+ $this->_logger->entrance();
168
+
169
+ if ( empty( $transient_data ) ||
170
+ defined( 'WP_FS__UNINSTALL_MODE' ) ||
171
+ /**
172
+ * From some reason 'pre_set_site_transient_update_plugins' filter
173
+ * is called four times in a row.
174
+ *
175
+ * @since 1.1.7.3
176
+ */
177
+ $this->_update_checked
178
+ ) {
179
+ return $transient_data;
180
+ }
181
+
182
+ // Get plugin's newest update.
183
+ $new_version = $this->_fs->get_update(false, false);
184
+
185
+ $this->_update_checked = true;
186
+
187
+ if ( is_object( $new_version ) ) {
188
+ $this->_logger->log( 'Found newer plugin version ' . $new_version->version );
189
+
190
+ $plugin_details = new stdClass();
191
+ $plugin_details->slug = $this->_fs->get_slug();
192
+ $plugin_details->new_version = $new_version->version;
193
+ $plugin_details->url = WP_FS__ADDRESS;
194
+ $plugin_details->package = $new_version->url;
195
+ $plugin_details->plugin = $this->_fs->get_plugin_basename();
196
+
197
+ // Add plugin to transient data.
198
+ $transient_data->response[ $this->_fs->get_plugin_basename() ] = $plugin_details;
199
+ }
200
+
201
+ return $transient_data;
202
+ }
203
+
204
+ /**
205
+ * Try to fetch plugin's info from .org repository.
206
+ *
207
+ * @author Vova Feldman (@svovaf)
208
+ * @since 1.0.5
209
+ *
210
+ * @param string $action
211
+ * @param object $args
212
+ *
213
+ * @return bool|mixed
214
+ */
215
+ static function _fetch_plugin_info_from_repository( $action, $args ) {
216
+ $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
217
+ if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
218
+ $url = set_url_scheme( $url, 'https' );
219
+ }
220
+
221
+ $args = array(
222
+ 'timeout' => 15,
223
+ 'body' => array(
224
+ 'action' => $action,
225
+ 'request' => serialize( $args )
226
+ )
227
+ );
228
+
229
+ $request = wp_remote_post( $url, $args );
230
+
231
+ if ( is_wp_error( $request ) ) {
232
+ return false;
233
+ }
234
+
235
+ $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
236
+
237
+ if ( ! is_object( $res ) && ! is_array( $res ) ) {
238
+ return false;
239
+ }
240
+
241
+ return $res;
242
+ }
243
+
244
+ /**
245
+ * Updates information on the "View version x.x details" page with custom data.
246
+ *
247
+ * @author Vova Feldman (@svovaf)
248
+ * @since 1.0.4
249
+ *
250
+ * @uses FS_Api
251
+ *
252
+ * @param object $data
253
+ * @param string $action
254
+ * @param mixed $args
255
+ *
256
+ * @return object
257
+ */
258
+ function plugins_api_filter( $data, $action = '', $args = null ) {
259
+ $this->_logger->entrance();
260
+
261
+ if ( ( 'plugin_information' !== $action ) ||
262
+ ! isset( $args->slug )
263
+ ) {
264
+ return $data;
265
+ }
266
+
267
+ $addon = false;
268
+ $is_addon = false;
269
+
270
+ if ( $this->_fs->get_slug() !== $args->slug ) {
271
+ $addon = $this->_fs->get_addon_by_slug( $args->slug );
272
+
273
+ if ( ! is_object( $addon ) ) {
274
+ return $data;
275
+ }
276
+
277
+ $is_addon = true;
278
+ }
279
+
280
+ $plugin_in_repo = false;
281
+ if ( ! $is_addon ) {
282
+ // Try to fetch info from .org repository.
283
+ $data = self::_fetch_plugin_info_from_repository( $action, $args );
284
+
285
+ $plugin_in_repo = ( false !== $data );
286
+ }
287
+
288
+ if ( ! $plugin_in_repo ) {
289
+ $data = $args;
290
+
291
+ // Fetch as much as possible info from local files.
292
+ $plugin_local_data = $this->_fs->get_plugin_data();
293
+ $data->name = $plugin_local_data['Name'];
294
+ $data->author = $plugin_local_data['Author'];
295
+ $data->sections = array(
296
+ 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
297
+ );
298
+
299
+ // @todo Store extra plugin info on Freemius or parse readme.txt markup.
300
+ /*$info = $this->_fs->get_api_site_scope()->call('/information.json');
301
+
302
+ if ( !isset($info->error) ) {
303
+ $data = $info;
304
+ }*/
305
+ }
306
+
307
+ // Get plugin's newest update.
308
+ $new_version = $this->_fs->_fetch_latest_version( $is_addon ? $addon->id : false );
309
+
310
+ if ( $is_addon ) {
311
+ $data->name = $addon->title . ' ' . __fs( 'addon', $this->_fs->get_slug() );
312
+ $data->slug = $addon->slug;
313
+ $data->url = WP_FS__ADDRESS;
314
+ $data->package = $new_version->url;
315
+ }
316
+
317
+ if ( ! $plugin_in_repo ) {
318
+ $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
319
+ $data->requires = $new_version->requires_platform_version;
320
+ $data->tested = $new_version->tested_up_to_version;
321
+ }
322
+
323
+ $data->version = $new_version->version;
324
+ $data->download_link = $new_version->url;
325
+
326
+ return $data;
327
+ }
328
+ }
freemius/includes/class-fs-security.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' );
14
+
15
+ class FS_Security {
16
+ /**
17
+ * @var FS_Security
18
+ * @since 1.0.3
19
+ */
20
+ private static $_instance;
21
+ /**
22
+ * @var FS_Logger
23
+ * @since 1.0.3
24
+ */
25
+ private static $_logger;
26
+
27
+ public static function instance() {
28
+ if ( ! isset( self::$_instance ) ) {
29
+ self::$_instance = new FS_Security();
30
+ self::$_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
31
+ }
32
+
33
+ return self::$_instance;
34
+ }
35
+
36
+ private function __construct() {
37
+ }
38
+
39
+ function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
40
+ return md5(
41
+ $timestamp .
42
+ $entity->id .
43
+ $entity->secret_key .
44
+ $entity->public_key .
45
+ $action
46
+ );
47
+ }
48
+
49
+ function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
50
+ if ( false === $timestamp ) {
51
+ $timestamp = time();
52
+ }
53
+
54
+ return array(
55
+ 's_ctx_type' => $entity->get_type(),
56
+ 's_ctx_id' => $entity->id,
57
+ 's_ctx_ts' => $timestamp,
58
+ 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
59
+ );
60
+ }
61
+ }
freemius/includes/debug/class-fs-debug-bar-panel.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Extends Debug Bar plugin by adding a panel to show all Freemius API requests.
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.1.7.3
18
+ *
19
+ * Class Freemius_Debug_Bar_Panel
20
+ */
21
+ class Freemius_Debug_Bar_Panel extends Debug_Bar_Panel {
22
+ function init() {
23
+ $this->title( 'Freemius' );
24
+ }
25
+
26
+ static function requests_count() {
27
+ if ( class_exists( 'Freemius_Api' ) ) {
28
+ $logger = Freemius_Api::GetLogger();
29
+ } else {
30
+ $logger = array();
31
+ }
32
+
33
+ return number_format( count( $logger ) );
34
+ }
35
+
36
+ static function total_time() {
37
+ if ( class_exists( 'Freemius_Api' ) ) {
38
+ $logger = Freemius_Api::GetLogger();
39
+ } else {
40
+ $logger = array();
41
+ }
42
+
43
+ $total_time = .0;
44
+ foreach ( $logger as $l ) {
45
+ $total_time += $l['total'];
46
+ }
47
+
48
+ return number_format( 100 * $total_time, 2 ) . ' ' . __fs( 'ms' );
49
+ }
50
+
51
+ function render() {
52
+ ?>
53
+ <div id='debug-bar-php'>
54
+ <?php fs_require_template( '/debug/api-calls.php' ) ?>
55
+ <br>
56
+ <?php fs_require_template( '/debug/scheduled-crons.php' ) ?>
57
+ <br>
58
+ <?php fs_require_template( '/debug/logger.php' ) ?>
59
+ </div>
60
+ <?php
61
+ }
62
+ }
freemius/includes/debug/debug-bar-start.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( ! WP_FS__DEBUG_SDK ) {
14
+ return;
15
+ }
16
+
17
+ /**
18
+ * Initialize Freemius custom debug panels.
19
+ *
20
+ * @param array $panels Debug bar panels objects
21
+ *
22
+ * @return array Debug bar panels with your custom panels
23
+ */
24
+ function fs_custom_panels_init( $panels ) {
25
+ if ( class_exists( 'Debug_Bar_Panel' ) ) {
26
+ if ( FS_API__LOGGER_ON ) {
27
+ require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
28
+ $panels[] = new Freemius_Debug_Bar_Panel();
29
+ }
30
+ }
31
+
32
+ return $panels;
33
+ }
34
+
35
+ function fs_custom_status_init( $statuses ) {
36
+ if ( class_exists( 'Debug_Bar_Panel' ) ) {
37
+ if ( FS_API__LOGGER_ON ) {
38
+ require_once dirname( __FILE__ ) . '/class-fs-debug-bar-panel.php';
39
+ $statuses[] = array(
40
+ 'fs_api_requests',
41
+ __fs( 'Freemius API' ),
42
+ Freemius_Debug_Bar_Panel::requests_count() . ' ' . __fs( 'Requests' ) .
43
+ ' (' . Freemius_Debug_Bar_Panel::total_time() . ')'
44
+ );
45
+ }
46
+ }
47
+
48
+ return $statuses;
49
+ }
50
+
51
+ add_filter( 'debug_bar_panels', 'fs_custom_panels_init' );
52
+ add_filter( 'debug_bar_statuses', 'fs_custom_status_init' );
freemius/includes/entities/class-fs-entity.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Get object's public variables.
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.0.0
18
+ *
19
+ * @param object $object
20
+ *
21
+ * @return array
22
+ */
23
+ function fs_get_object_public_vars( $object ) {
24
+ return get_object_vars( $object );
25
+ }
26
+
27
+ class FS_Entity {
28
+ /**
29
+ * @var number
30
+ */
31
+ public $id;
32
+ /**
33
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
34
+ */
35
+ public $updated;
36
+ /**
37
+ * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
38
+ */
39
+ public $created;
40
+
41
+ /**
42
+ * @param bool|stdClass $entity
43
+ */
44
+ function __construct( $entity = false ) {
45
+ if ( ! ( $entity instanceof stdClass ) ) {
46
+ return;
47
+ }
48
+
49
+ $props = fs_get_object_public_vars( $this );
50
+
51
+ foreach ( $props as $key => $def_value ) {
52
+ $this->{$key} = isset( $entity->{$key} ) ?
53
+ $entity->{$key} :
54
+ $def_value;
55
+ }
56
+ }
57
+
58
+ static function get_type() {
59
+ return 'type';
60
+ }
61
+
62
+ /**
63
+ * @author Vova Feldman (@svovaf)
64
+ * @since 1.0.6
65
+ *
66
+ * @param FS_Entity $entity1
67
+ * @param FS_Entity $entity2
68
+ *
69
+ * @return bool
70
+ */
71
+ static function equals( $entity1, $entity2 ) {
72
+ if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
73
+ return true;
74
+ } else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
75
+ return ( $entity1->id == $entity2->id );
76
+ } else if ( is_object( $entity1 ) ) {
77
+ return is_null( $entity1->id );
78
+ } else {
79
+ return is_null( $entity2->id );
80
+ }
81
+ }
82
+
83
+ private $_is_updated = false;
84
+
85
+ /**
86
+ * Update object property.
87
+ *
88
+ * @author Vova Feldman (@svovaf)
89
+ * @since 1.0.9
90
+ *
91
+ * @param string|array[string]mixed $key
92
+ * @param string|bool $val
93
+ *
94
+ * @return bool
95
+ */
96
+ function update( $key, $val = false ) {
97
+ if ( ! is_array( $key ) ) {
98
+ $key = array( $key => $val );
99
+ }
100
+
101
+ $is_updated = false;
102
+
103
+ foreach ( $key as $k => $v ) {
104
+ if ( $this->{$k} === $v ) {
105
+ continue;
106
+ }
107
+
108
+ if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
109
+ ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
110
+ $this->{$k} == $v
111
+ ) {
112
+ continue;
113
+ }
114
+
115
+ // Update value.
116
+ $this->{$k} = $v;
117
+
118
+ $is_updated = true;
119
+ }
120
+
121
+ $this->_is_updated = $is_updated;
122
+
123
+ return $is_updated;
124
+ }
125
+
126
+ /**
127
+ * Checks if entity was updated.
128
+ *
129
+ * @author Vova Feldman (@svovaf)
130
+ * @since 1.0.9
131
+ *
132
+ * @return bool
133
+ */
134
+ function is_updated() {
135
+ return $this->_is_updated;
136
+ }
137
+
138
+ /**
139
+ * @param $id
140
+ *
141
+ * @author Vova Feldman (@svovaf)
142
+ * @since 1.1.2
143
+ *
144
+ * @return bool
145
+ */
146
+ static function is_valid_id($id){
147
+ return is_numeric($id);
148
+ }
149
+ }
freemius/includes/entities/class-fs-plugin-info.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Info extends FS_Entity {
14
+ public $plugin_id;
15
+ public $description;
16
+ public $short_description;
17
+ public $banner_url;
18
+ public $card_banner_url;
19
+ public $selling_point_0;
20
+ public $selling_point_1;
21
+ public $selling_point_2;
22
+ public $screenshots;
23
+
24
+ /**
25
+ * @param stdClass|bool $plugin_info
26
+ */
27
+ function __construct( $plugin_info = false ) {
28
+ parent::__construct( $plugin_info );
29
+ }
30
+
31
+ static function get_type() {
32
+ return 'plugin';
33
+ }
34
+ }
freemius/includes/entities/class-fs-plugin-license.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_License extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $plugin_id;
21
+ /**
22
+ * @var number
23
+ */
24
+ public $user_id;
25
+ /**
26
+ * @var number
27
+ */
28
+ public $plan_id;
29
+ /**
30
+ * @var number
31
+ */
32
+ public $pricing_id;
33
+ /**
34
+ * @var int
35
+ */
36
+ public $quota;
37
+ /**
38
+ * @var int
39
+ */
40
+ public $activated;
41
+ /**
42
+ * @var int
43
+ */
44
+ public $activated_local;
45
+ /**
46
+ * @var string
47
+ */
48
+ public $expiration;
49
+ /**
50
+ * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
51
+ * license.
52
+ */
53
+ public $is_free_localhost;
54
+ /**
55
+ * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
56
+ * block updates and support.
57
+ */
58
+ public $is_block_features;
59
+ /**
60
+ * @var bool
61
+ */
62
+ public $is_cancelled;
63
+
64
+ #endregion Properties
65
+
66
+ /**
67
+ * @param stdClass|bool $license
68
+ */
69
+ function __construct( $license = false ) {
70
+ parent::__construct( $license );
71
+ }
72
+
73
+ static function get_type() {
74
+ return 'license';
75
+ }
76
+
77
+ /**
78
+ * Check how many site activations left.
79
+ *
80
+ * @author Vova Feldman (@svovaf)
81
+ * @since 1.0.5
82
+ *
83
+ * @return int
84
+ */
85
+ function left() {
86
+ if ( $this->is_expired() ) {
87
+ return 0;
88
+ }
89
+
90
+ return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
91
+ }
92
+
93
+ /**
94
+ * @author Vova Feldman (@svovaf)
95
+ * @since 1.0.5
96
+ *
97
+ * @return bool
98
+ */
99
+ function is_expired() {
100
+ return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
101
+ }
102
+
103
+ /**
104
+ * @author Vova Feldman (@svovaf)
105
+ * @since 1.0.6
106
+ *
107
+ * @return bool
108
+ */
109
+ function is_lifetime() {
110
+ return is_null( $this->expiration );
111
+ }
112
+
113
+ /**
114
+ * Check if license is fully utilized.
115
+ *
116
+ * @author Vova Feldman (@svovaf)
117
+ * @since 1.0.6
118
+ *
119
+ * @param bool $is_localhost
120
+ *
121
+ * @return bool
122
+ */
123
+ function is_utilized( $is_localhost = null ) {
124
+ if ( is_null( $is_localhost ) ) {
125
+ $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
126
+ }
127
+
128
+ return ! ( $this->is_free_localhost && $is_localhost ) &&
129
+ ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
130
+ }
131
+
132
+ /**
133
+ * Check if license's plan features are enabled.
134
+ *
135
+ * - Either if plan not expired
136
+ * - If expired, based on the configuration to block features or not.
137
+ *
138
+ * @author Vova Feldman (@svovaf)
139
+ * @since 1.0.6
140
+ *
141
+ * @return bool
142
+ */
143
+ function is_features_enabled() {
144
+ return ( ! $this->is_block_features || ! $this->is_expired() );
145
+ }
146
+
147
+ /**
148
+ * Subscription considered to be new without any payments
149
+ * if the license expires in less than 24 hours
150
+ * from the license creation.
151
+ *
152
+ * @author Vova Feldman (@svovaf)
153
+ * @since 1.0.9
154
+ *
155
+ * @return bool
156
+ */
157
+ function is_first_payment_pending() {
158
+ return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
159
+ }
160
+ }
freemius/includes/entities/class-fs-plugin-plan.php ADDED
@@ -0,0 +1,124 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Plan extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $plugin_id;
21
+ /**
22
+ * @var string
23
+ */
24
+ public $name;
25
+ /**
26
+ * @var string
27
+ */
28
+ public $title;
29
+ /**
30
+ * @var string
31
+ */
32
+ public $description;
33
+ /**
34
+ * @var bool Defaults to true. If true, allow unlimited localhost installs with the same license.
35
+ */
36
+ public $is_free_localhost;
37
+ /**
38
+ * @var bool Defaults to true. If false, don't block features after license expiry - only block updates and
39
+ * support.
40
+ */
41
+ public $is_block_features;
42
+ /**
43
+ * @var int
44
+ */
45
+ public $license_type;
46
+ /**
47
+ * @var bool
48
+ */
49
+ public $is_https_support;
50
+ /**
51
+ * @var int Trial days.
52
+ */
53
+ public $trial_period;
54
+ /**
55
+ * @var string If true, require payment for trial.
56
+ */
57
+ public $is_require_subscription;
58
+ /**
59
+ * @var string Knowledge Base URL.
60
+ */
61
+ public $support_kb;
62
+ /**
63
+ * @var string Support Forum URL.
64
+ */
65
+ public $support_forum;
66
+ /**
67
+ * @var string Support email address.
68
+ */
69
+ public $support_email;
70
+ /**
71
+ * @var string Support phone.
72
+ */
73
+ public $support_phone;
74
+ /**
75
+ * @var string Support skype username.
76
+ */
77
+ public $support_skype;
78
+ /**
79
+ * @var bool Is personal success manager supported with the plan.
80
+ */
81
+ public $is_success_manager;
82
+ /**
83
+ * @var bool Is featured plan.
84
+ */
85
+ public $is_featured;
86
+
87
+ #endregion Properties
88
+
89
+ /**
90
+ * @param object|bool $plan
91
+ */
92
+ function __construct( $plan = false ) {
93
+ parent::__construct( $plan );
94
+
95
+ if ( is_object( $plan ) ) {
96
+ $this->name = strtolower( $plan->name );
97
+ }
98
+ }
99
+
100
+ static function get_type() {
101
+ return 'plan';
102
+ }
103
+
104
+ /**
105
+ * @author Vova Feldman (@svovaf)
106
+ * @since 1.0.9
107
+ *
108
+ * @return bool
109
+ */
110
+ function is_free() {
111
+ return ( 'free' === $this->name );
112
+ }
113
+
114
+ /**
115
+ * @author Vova Feldman (@svovaf)
116
+ * @since 1.0.9
117
+ *
118
+ * @return bool
119
+ */
120
+ function has_trial() {
121
+ return ! $this->is_free() &&
122
+ is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
123
+ }
124
+ }
freemius/includes/entities/class-fs-plugin-tag.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Tag extends FS_Entity {
14
+ public $version;
15
+ public $url;
16
+
17
+ function __construct( $tag = false ) {
18
+ parent::__construct( $tag );
19
+ }
20
+
21
+ static function get_type() {
22
+ return 'tag';
23
+ }
24
+ }
freemius/includes/entities/class-fs-plugin.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin extends FS_Scope_Entity {
14
+ /**
15
+ * @since 1.0.6
16
+ * @var null|number
17
+ */
18
+ public $parent_plugin_id;
19
+ /**
20
+ * @var string
21
+ */
22
+ public $title;
23
+ /**
24
+ * @var string
25
+ */
26
+ public $slug;
27
+
28
+ #region Install Specific Properties
29
+
30
+ /**
31
+ * @var string
32
+ */
33
+ public $file;
34
+ /**
35
+ * @var string
36
+ */
37
+ public $version;
38
+ /**
39
+ * @var bool
40
+ */
41
+ public $auto_update;
42
+ /**
43
+ * @var FS_Plugin_Info
44
+ */
45
+ public $info;
46
+ /**
47
+ * @since 1.0.9
48
+ *
49
+ * @var bool
50
+ */
51
+ public $is_premium;
52
+ /**
53
+ * @since 1.0.9
54
+ *
55
+ * @var bool
56
+ */
57
+ public $is_live;
58
+
59
+ #endregion Install Specific Properties
60
+
61
+ /**
62
+ * @param stdClass|bool $plugin
63
+ */
64
+ function __construct( $plugin = false ) {
65
+ parent::__construct( $plugin );
66
+
67
+ $this->is_premium = false;
68
+ $this->is_live = true;
69
+
70
+ if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
71
+ $this->info = new FS_Plugin_Info( $plugin->info );
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Check if plugin is an add-on (has parent).
77
+ *
78
+ * @author Vova Feldman (@svovaf)
79
+ * @since 1.0.6
80
+ *
81
+ * @return bool
82
+ */
83
+ function is_addon() {
84
+ return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
85
+ }
86
+
87
+ static function get_type() {
88
+ return 'plugin';
89
+ }
90
+ }
freemius/includes/entities/class-fs-pricing.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius for EDD Add-On
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.0
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Pricing extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $plan_id;
21
+ /**
22
+ * @var int
23
+ */
24
+ public $licenses;
25
+ /**
26
+ * @var null|float
27
+ */
28
+ public $monthly_price;
29
+ /**
30
+ * @var null|float
31
+ */
32
+ public $annual_price;
33
+ /**
34
+ * @var null|float
35
+ */
36
+ public $lifetime_price;
37
+
38
+ #endregion Properties
39
+
40
+ /**
41
+ * @param object|bool $pricing
42
+ */
43
+ function __construct( $pricing = false ) {
44
+ parent::__construct( $pricing );
45
+ }
46
+
47
+ static function get_type() {
48
+ return 'pricing';
49
+ }
50
+ }
freemius/includes/entities/class-fs-scope-entity.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Scope_Entity extends FS_Entity {
14
+ /**
15
+ * @var string
16
+ */
17
+ public $public_key;
18
+ /**
19
+ * @var string
20
+ */
21
+ public $secret_key;
22
+
23
+ /**
24
+ * @param bool|stdClass $scope_entity
25
+ */
26
+ function __construct( $scope_entity = false ) {
27
+ parent::__construct( $scope_entity );
28
+ }
29
+ }
freemius/includes/entities/class-fs-site.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Site extends FS_Scope_Entity {
14
+ /**
15
+ * @var string
16
+ */
17
+ public $slug;
18
+ /**
19
+ * @var number
20
+ */
21
+ public $site_id;
22
+ /**
23
+ * @var number
24
+ */
25
+ public $plugin_id;
26
+ /**
27
+ * @var number
28
+ */
29
+ public $user_id;
30
+ /**
31
+ * @var string
32
+ */
33
+ public $title;
34
+ /**
35
+ * @var string
36
+ */
37
+ public $url;
38
+ /**
39
+ * @var string
40
+ */
41
+ public $version;
42
+ /**
43
+ * @var string E.g. en-GB
44
+ */
45
+ public $language;
46
+ /**
47
+ * @var string E.g. UTF-8
48
+ */
49
+ public $charset;
50
+ /**
51
+ * @var string Platform version (e.g WordPress version).
52
+ */
53
+ public $platform_version;
54
+ /**
55
+ * @var string Programming language version (e.g PHP version).
56
+ */
57
+ public $programming_language_version;
58
+ /**
59
+ * @var FS_Plugin_Plan $plan
60
+ */
61
+ public $plan;
62
+ /**
63
+ * @var number|null
64
+ */
65
+ public $license_id;
66
+ /**
67
+ * @var number|null
68
+ */
69
+ public $trial_plan_id;
70
+ /**
71
+ * @var string|null
72
+ */
73
+ public $trial_ends;
74
+ /**
75
+ * @since 1.0.9
76
+ *
77
+ * @var bool
78
+ */
79
+ public $is_premium = false;
80
+
81
+ /**
82
+ * @param stdClass|bool $site
83
+ */
84
+ function __construct( $site = false ) {
85
+ $this->plan = new FS_Plugin_Plan();
86
+
87
+ parent::__construct( $site );
88
+
89
+ if ( is_object( $site ) ) {
90
+ $this->plan->id = $site->plan_id;
91
+ }
92
+ }
93
+
94
+ static function get_type() {
95
+ return 'install';
96
+ }
97
+
98
+ function is_localhost() {
99
+ // The server has no way to verify if localhost unless localhost appears in domain.
100
+ return WP_FS__IS_LOCALHOST_FOR_SERVER;
101
+ // return (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1');
102
+ }
103
+
104
+ /**
105
+ * Check if site in trial.
106
+ *
107
+ * @author Vova Feldman (@svovaf)
108
+ * @since 1.0.9
109
+ *
110
+ * @return bool
111
+ */
112
+ function is_trial() {
113
+ return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
114
+ }
115
+
116
+ /**
117
+ * Check if user already utilized the trial with the current install.
118
+ *
119
+ * @author Vova Feldman (@svovaf)
120
+ * @since 1.0.9
121
+ *
122
+ * @return bool
123
+ */
124
+ function is_trial_utilized() {
125
+ return is_numeric( $this->trial_plan_id );
126
+ }
127
+ }
freemius/includes/entities/class-fs-subscription.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.9
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Subscription extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var number
19
+ */
20
+ public $user_id;
21
+ /**
22
+ * @var number
23
+ */
24
+ public $install_id;
25
+ /**
26
+ * @var number
27
+ */
28
+ public $plan_id;
29
+ /**
30
+ * @var number
31
+ */
32
+ public $license_id;
33
+ /**
34
+ * @var float
35
+ */
36
+ public $total_gross;
37
+ /**
38
+ * @var float
39
+ */
40
+ public $amount_per_cycle;
41
+ /**
42
+ * @var int # of months
43
+ */
44
+ public $billing_cycle;
45
+ /**
46
+ * @var float
47
+ */
48
+ public $outstanding_balance;
49
+ /**
50
+ * @var int
51
+ */
52
+ public $failed_payments;
53
+ /**
54
+ * @var string
55
+ */
56
+ public $gateway;
57
+ /**
58
+ * @var string
59
+ */
60
+ public $external_id;
61
+ /**
62
+ * @var string|null
63
+ */
64
+ public $trial_ends;
65
+ /**
66
+ * @var string|null Datetime of the next payment, or null if cancelled
67
+ */
68
+ public $next_payment;
69
+ /**
70
+ * @var string|null
71
+ */
72
+ public $vat_id;
73
+ /**
74
+ * @var string Two characters country code
75
+ */
76
+ public $country_code;
77
+
78
+ #endregion Properties
79
+
80
+ /**
81
+ * @param object|bool $subscription
82
+ */
83
+ function __construct( $subscription = false ) {
84
+ parent::__construct( $subscription );
85
+ }
86
+
87
+ static function get_type() {
88
+ return 'subscription';
89
+ }
90
+
91
+ /**
92
+ * Check if subscription is active.
93
+ *
94
+ * @author Vova Feldman (@svovaf)
95
+ * @since 1.0.9
96
+ *
97
+ * @return bool
98
+ */
99
+ function is_active() {
100
+ return ! empty( $this->next_payment ) &&
101
+ ( strtotime( $this->next_payment ) > WP_FS__SCRIPT_START_TIME );
102
+ }
103
+
104
+ /**
105
+ * Subscription considered to be new without any payments
106
+ * if the next payment should be made within less than 24 hours
107
+ * from the subscription creation.
108
+ *
109
+ * @author Vova Feldman (@svovaf)
110
+ * @since 1.0.9
111
+ *
112
+ * @return bool
113
+ */
114
+ function is_first_payment_pending() {
115
+ return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->next_payment ) - strtotime( $this->created ) );
116
+ }
117
+
118
+ /**
119
+ * @author Vova Feldman (@svovaf)
120
+ * @since 1.1.7
121
+ */
122
+ function has_trial() {
123
+ return ! is_null( $this->trial_ends );
124
+ }
125
+ }
freemius/includes/entities/class-fs-user.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_User extends FS_Scope_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ public $email;
21
+ /**
22
+ * @var string
23
+ */
24
+ public $first;
25
+ /**
26
+ * @var string
27
+ */
28
+ public $last;
29
+ /**
30
+ * @var bool
31
+ */
32
+ public $is_verified;
33
+ /**
34
+ * @var string|null
35
+ */
36
+ public $customer_id;
37
+ /**
38
+ * @var float
39
+ */
40
+ public $gross;
41
+
42
+ #endregion Properties
43
+
44
+ /**
45
+ * @param object|bool $user
46
+ */
47
+ function __construct( $user = false ) {
48
+ parent::__construct( $user );
49
+ }
50
+
51
+ function get_name() {
52
+ return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
53
+ }
54
+
55
+ function is_verified() {
56
+ return ( isset( $this->is_verified ) && true === $this->is_verified );
57
+ }
58
+
59
+ static function get_type() {
60
+ return 'user';
61
+ }
62
+ }
freemius/includes/fs-core-functions.php ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ global $fs_core_logger;
14
+
15
+ $fs_core_logger = FS_Logger::get_logger( WP_FS__SLUG . '_core', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
16
+
17
+ if ( ! function_exists( 'fs_dummy' ) ) {
18
+ function fs_dummy() {
19
+ }
20
+ }
21
+
22
+ /* Url.
23
+ --------------------------------------------------------------------------------------------*/
24
+ function fs_get_url_daily_cache_killer() {
25
+ return date( '\YY\Mm\Dd' );
26
+ }
27
+
28
+ /* Templates / Views.
29
+ --------------------------------------------------------------------------------------------*/
30
+ if ( ! function_exists( 'fs_get_template_path' ) ) {
31
+ function fs_get_template_path( $path ) {
32
+ return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
33
+ }
34
+
35
+ function fs_include_template( $path, &$params = null ) {
36
+ $VARS = &$params;
37
+ include( fs_get_template_path( $path ) );
38
+ }
39
+
40
+ function fs_include_once_template( $path, &$params = null ) {
41
+ $VARS = &$params;
42
+ include_once( fs_get_template_path( $path ) );
43
+ }
44
+
45
+ function fs_require_template( $path, &$params = null ) {
46
+ $VARS = &$params;
47
+ require( fs_get_template_path( $path ) );
48
+ }
49
+
50
+ function fs_require_once_template( $path, &$params = null ) {
51
+ $VARS = &$params;
52
+ require_once( fs_get_template_path( $path ) );
53
+ }
54
+
55
+ function fs_get_template( $path, &$params = null ) {
56
+ ob_start();
57
+
58
+ $VARS = &$params;
59
+ require_once( fs_get_template_path( $path ) );
60
+
61
+ return ob_get_clean();
62
+ }
63
+ }
64
+
65
+ /* Scripts and styles including.
66
+ --------------------------------------------------------------------------------------------*/
67
+ function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
68
+ global $fs_core_logger;
69
+ if ( $fs_core_logger->is_on() ) {
70
+ $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
71
+ $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_CSS . trim( $path, '/' ) ) );
72
+ $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ) );
73
+ }
74
+
75
+ wp_enqueue_style( $handle, plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $media );
76
+ }
77
+
78
+ function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
79
+ global $fs_core_logger;
80
+ if ( $fs_core_logger->is_on() ) {
81
+ $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
82
+ $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_JS . trim( $path, '/' ) ) );
83
+ $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ) );
84
+ }
85
+
86
+ wp_enqueue_script( $handle, plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $in_footer );
87
+ }
88
+
89
+ function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) {
90
+ return plugins_url( plugin_basename( $img_dir . '/' . trim( $path, '/' ) ) );
91
+ }
92
+
93
+ /* Request handlers.
94
+ --------------------------------------------------------------------------------------------*/
95
+ /**
96
+ * @param string $key
97
+ * @param mixed $def
98
+ *
99
+ * @return mixed
100
+ */
101
+ function fs_request_get( $key, $def = false ) {
102
+ return isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
103
+ }
104
+
105
+ function fs_request_has( $key ) {
106
+ return isset( $_REQUEST[ $key ] );
107
+ }
108
+
109
+ function fs_request_get_bool( $key, $def = false ) {
110
+ return ( isset( $_REQUEST[ $key ] ) && ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) ) ? true : $def;
111
+ }
112
+
113
+ function fs_request_is_post() {
114
+ return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
115
+ }
116
+
117
+ function fs_request_is_get() {
118
+ return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
119
+ }
120
+
121
+ function fs_get_action( $action_key = 'action' ) {
122
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
123
+ return strtolower( $_REQUEST[ $action_key ] );
124
+ }
125
+
126
+ if ( 'action' == $action_key ) {
127
+ $action_key = 'fs_action';
128
+
129
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
130
+ return strtolower( $_REQUEST[ $action_key ] );
131
+ }
132
+ }
133
+
134
+ return false;
135
+ }
136
+
137
+ function fs_request_is_action( $action, $action_key = 'action' ) {
138
+ return ( strtolower( $action ) === fs_get_action( $action_key ) );
139
+ }
140
+
141
+ function fs_is_plugin_page( $menu_slug ) {
142
+ return ( is_admin() && $_REQUEST['page'] === $menu_slug );
143
+ }
144
+
145
+ /* Core UI.
146
+ --------------------------------------------------------------------------------------------*/
147
+ /**
148
+ * @param string $slug
149
+ * @param string $page
150
+ * @param string $action
151
+ * @param string $title
152
+ * @param array $params
153
+ * @param bool $is_primary
154
+ * @param string|bool $icon_class Optional class for an icon (since 1.1.7).
155
+ * @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7).
156
+ * @param string $method Since 1.1.7
157
+ *
158
+ * @uses fs_ui_get_action_button()
159
+ */
160
+ function fs_ui_action_button(
161
+ $slug,
162
+ $page,
163
+ $action,
164
+ $title,
165
+ $params = array(),
166
+ $is_primary = true,
167
+ $icon_class = false,
168
+ $confirmation = false,
169
+ $method = 'GET'
170
+ ) {
171
+ echo fs_ui_get_action_button(
172
+ $slug,
173
+ $page,
174
+ $action,
175
+ $title,
176
+ $params,
177
+ $is_primary,
178
+ $icon_class,
179
+ $confirmation,
180
+ $method
181
+ );
182
+ }
183
+
184
+ /**
185
+ * @author Vova Feldman (@svovaf)
186
+ * @since 1.1.7
187
+ *
188
+ * @param string $slug
189
+ * @param string $page
190
+ * @param string $action
191
+ * @param string $title
192
+ * @param array $params
193
+ * @param bool $is_primary
194
+ * @param string|bool $icon_class Optional class for an icon.
195
+ * @param string|bool $confirmation Optional confirmation message before submit.
196
+ * @param string $method
197
+ *
198
+ * @return string
199
+ */
200
+ function fs_ui_get_action_button(
201
+ $slug,
202
+ $page,
203
+ $action,
204
+ $title,
205
+ $params = array(),
206
+ $is_primary = true,
207
+ $icon_class = false,
208
+ $confirmation = false,
209
+ $method = 'GET'
210
+ ) {
211
+ // Prepend icon (if set).
212
+ $title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title;
213
+
214
+ if ( is_string( $confirmation ) ) {
215
+ return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="if (confirm(\'%s\')) this.parentNode.submit(); return false;">%s</a></form>',
216
+ freemius( $slug )->_get_admin_page_url( $page, $params ),
217
+ $method,
218
+ $action,
219
+ wp_nonce_field( $action, '_wpnonce', true, false ),
220
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
221
+ $confirmation,
222
+ $title
223
+ );
224
+ } else if ( 'GET' !== strtoupper( $method ) ) {
225
+ return sprintf( '<form action="%s" method="%s"><input type="hidden" name="fs_action" value="%s">%s<a href="#" class="%s" onclick="this.parentNode.submit(); return false;">%s</a></form>',
226
+ freemius( $slug )->_get_admin_page_url( $page, $params ),
227
+ $method,
228
+ $action,
229
+ wp_nonce_field( $action, '_wpnonce', true, false ),
230
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
231
+ $title
232
+ );
233
+ } else {
234
+ return sprintf( '<a href="%s" class="%s">%s</a></form>',
235
+ wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),
236
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
237
+ $title
238
+ );
239
+ }
240
+ }
241
+
242
+ function fs_ui_action_link( $slug, $page, $action, $title, $params = array() ) {
243
+ ?><a class=""
244
+ href="<?php echo wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ) ?>"><?php echo $title ?></a><?php
245
+ }
246
+
247
+ /*function fs_error_handler($errno, $errstr, $errfile, $errline)
248
+ {
249
+ if (false === strpos($errfile, 'freemius/'))
250
+ {
251
+ // @todo Dump Freemius errors to local log.
252
+ }
253
+
254
+ // switch ($errno) {
255
+ // case E_USER_ERROR:
256
+ // break;
257
+ // case E_WARNING:
258
+ // case E_USER_WARNING:
259
+ // break;
260
+ // case E_NOTICE:
261
+ // case E_USER_NOTICE:
262
+ // break;
263
+ // default:
264
+ // break;
265
+ // }
266
+ }
267
+
268
+ set_error_handler('fs_error_handler');*/
269
+
270
+ function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
271
+ // $actionurl = str_replace( '&amp;', '&', $actionurl );
272
+ return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
273
+ }
274
+
275
+ if ( ! function_exists( 'fs_starts_with' ) ) {
276
+ /**
277
+ * Check if string starts with.
278
+ *
279
+ * @author Vova Feldman (@svovaf)
280
+ * @since 1.1.3
281
+ *
282
+ * @param string $haystack
283
+ * @param string $needle
284
+ *
285
+ * @return bool
286
+ */
287
+ function fs_starts_with( $haystack, $needle ) {
288
+ $length = strlen( $needle );
289
+
290
+ return ( substr( $haystack, 0, $length ) === $needle );
291
+ }
292
+ }
293
+
294
+ #region Url Canonization ------------------------------------------------------------------
295
+
296
+ if ( ! function_exists( 'fs_canonize_url' ) ) {
297
+ /**
298
+ * @author Vova Feldman (@svovaf)
299
+ * @since 1.1.3
300
+ *
301
+ * @param string $url
302
+ * @param bool $omit_host
303
+ * @param array $ignore_params
304
+ *
305
+ * @return string
306
+ */
307
+ function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
308
+ $parsed_url = parse_url( strtolower( $url ) );
309
+
310
+ // if ( ! isset( $parsed_url['host'] ) ) {
311
+ // return $url;
312
+ // }
313
+
314
+ $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
315
+
316
+ if ( isset( $parsed_url['query'] ) ) {
317
+ parse_str( $parsed_url['query'], $queryString );
318
+ $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
319
+ }
320
+
321
+ return $canonical;
322
+ }
323
+ }
324
+
325
+ if ( ! function_exists( 'fs_canonize_query_string' ) ) {
326
+ /**
327
+ * @author Vova Feldman (@svovaf)
328
+ * @since 1.1.3
329
+ *
330
+ * @param array $params
331
+ * @param array $ignore_params
332
+ * @param bool $params_prefix
333
+ *
334
+ * @return string
335
+ */
336
+ function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
337
+ if ( ! is_array( $params ) || 0 === count( $params ) ) {
338
+ return '';
339
+ }
340
+
341
+ // Urlencode both keys and values
342
+ $keys = fs_urlencode_rfc3986( array_keys( $params ) );
343
+ $values = fs_urlencode_rfc3986( array_values( $params ) );
344
+ $params = array_combine( $keys, $values );
345
+
346
+ // Parameters are sorted by name, using lexicographical byte value ordering.
347
+ // Ref: Spec: 9.1.1 (1)
348
+ uksort( $params, 'strcmp' );
349
+
350
+ $pairs = array();
351
+ foreach ( $params as $parameter => $value ) {
352
+ $lower_param = strtolower( $parameter );
353
+
354
+ // Skip ignore params.
355
+ if ( in_array( $lower_param, $ignore_params ) || ( false !== $params_prefix && startsWith( $lower_param, $params_prefix ) ) ) {
356
+ continue;
357
+ }
358
+
359
+ if ( is_array( $value ) ) {
360
+ // If two or more parameters share the same name, they are sorted by their value
361
+ // Ref: Spec: 9.1.1 (1)
362
+ natsort( $value );
363
+ foreach ( $value as $duplicate_value ) {
364
+ $pairs[] = $lower_param . '=' . $duplicate_value;
365
+ }
366
+ } else {
367
+ $pairs[] = $lower_param . '=' . $value;
368
+ }
369
+ }
370
+
371
+ if ( 0 === count( $pairs ) ) {
372
+ return '';
373
+ }
374
+
375
+ return implode( "&", $pairs );
376
+ }
377
+ }
378
+
379
+ if ( ! function_exists( 'fs_urlencode_rfc3986' ) ) {
380
+ /**
381
+ * @author Vova Feldman (@svovaf)
382
+ * @since 1.1.3
383
+ *
384
+ * @param string|string[] $input
385
+ *
386
+ * @return array|mixed|string
387
+ */
388
+ function fs_urlencode_rfc3986( $input ) {
389
+ if ( is_array( $input ) ) {
390
+ return array_map( 'fs_urlencode_rfc3986', $input );
391
+ } else if ( is_scalar( $input ) ) {
392
+ return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
393
+ }
394
+
395
+ return '';
396
+ }
397
+ }
398
+
399
+ #endregion Url Canonization ------------------------------------------------------------------
400
+
401
+ function fs_download_image( $from, $to ) {
402
+ $ch = curl_init( $from );
403
+ $fp = fopen( fs_normalize_path( $to ), 'wb' );
404
+ curl_setopt( $ch, CURLOPT_FILE, $fp );
405
+ curl_setopt( $ch, CURLOPT_HEADER, 0 );
406
+ curl_exec( $ch );
407
+ curl_close( $ch );
408
+ fclose( $fp );
409
+ }
410
+
411
+ /* General Utilities
412
+ --------------------------------------------------------------------------------------------*/
413
+
414
+ /**
415
+ * Sorts an array by the value of the priority key.
416
+ *
417
+ * @author Daniel Iser (@danieliser)
418
+ * @since 1.1.7
419
+ *
420
+ * @param $a
421
+ * @param $b
422
+ *
423
+ * @return int
424
+ */
425
+ function fs_sort_by_priority( $a, $b ) {
426
+
427
+ // If b has a priority and a does not, b wins.
428
+ if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) {
429
+ return 1;
430
+ } // If b has a priority and a does not, b wins.
431
+ elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) {
432
+ return - 1;
433
+ } // If neither has a priority or both priorities are equal its a tie.
434
+ elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) {
435
+ return 0;
436
+ }
437
+
438
+ // If both have priority return the winner.
439
+ return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
440
+ }
441
+
freemius/includes/fs-essential-functions.php ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.5
7
+ */
8
+
9
+ if ( ! function_exists( 'fs_normalize_path' ) ) {
10
+ if ( function_exists( 'wp_normalize_path' ) ) {
11
+ /**
12
+ * Normalize a filesystem path.
13
+ *
14
+ * Replaces backslashes with forward slashes for Windows systems, and ensures
15
+ * no duplicate slashes exist.
16
+ *
17
+ * @param string $path Path to normalize.
18
+ *
19
+ * @return string Normalized path.
20
+ */
21
+ function fs_normalize_path( $path ) {
22
+ return wp_normalize_path( $path );
23
+ }
24
+ } else {
25
+ function fs_normalize_path( $path ) {
26
+ $path = str_replace( '\\', '/', $path );
27
+ $path = preg_replace( '|/+|', '/', $path );
28
+
29
+ return $path;
30
+ }
31
+ }
32
+ }
33
+
34
+ #region Core Redirect (copied from BuddyPress) -----------------------------------------
35
+
36
+ if ( ! function_exists( 'fs_redirect' ) ) {
37
+ /**
38
+ * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
39
+ *
40
+ * @link http://support.microsoft.com/kb/q176113/
41
+ * @since 1.5.1
42
+ * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
43
+ *
44
+ * @param string $location The path to redirect to
45
+ * @param int $status Status code to use
46
+ *
47
+ * @return bool False if $location is not set
48
+ */
49
+ function fs_redirect( $location, $status = 302 ) {
50
+ global $is_IIS;
51
+
52
+ if ( headers_sent() ) {
53
+ return false;
54
+ }
55
+
56
+ if ( ! $location ) // allows the wp_redirect filter to cancel a redirect
57
+ {
58
+ return false;
59
+ }
60
+
61
+ $location = fs_sanitize_redirect( $location );
62
+
63
+ if ( $is_IIS ) {
64
+ header( "Refresh: 0;url=$location" );
65
+ } else {
66
+ if ( php_sapi_name() != 'cgi-fcgi' ) {
67
+ status_header( $status );
68
+ } // This causes problems on IIS and some FastCGI setups
69
+ header( "Location: $location" );
70
+ }
71
+
72
+ return true;
73
+ }
74
+
75
+ if ( ! function_exists( 'fs_sanitize_redirect' ) ) {
76
+ /**
77
+ * Sanitizes a URL for use in a redirect.
78
+ *
79
+ * @since 2.3
80
+ *
81
+ * @param string $location
82
+ *
83
+ * @return string redirect-sanitized URL
84
+ */
85
+ function fs_sanitize_redirect( $location ) {
86
+ $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location );
87
+ $location = fs_kses_no_null( $location );
88
+
89
+ // remove %0d and %0a from location
90
+ $strip = array( '%0d', '%0a' );
91
+ $found = true;
92
+ while ( $found ) {
93
+ $found = false;
94
+ foreach ( (array) $strip as $val ) {
95
+ while ( strpos( $location, $val ) !== false ) {
96
+ $found = true;
97
+ $location = str_replace( $val, '', $location );
98
+ }
99
+ }
100
+ }
101
+
102
+ return $location;
103
+ }
104
+ }
105
+
106
+ if ( ! function_exists( 'fs_kses_no_null' ) ) {
107
+ /**
108
+ * Removes any NULL characters in $string.
109
+ *
110
+ * @since 1.0.0
111
+ *
112
+ * @param string $string
113
+ *
114
+ * @return string
115
+ */
116
+ function fs_kses_no_null( $string ) {
117
+ $string = preg_replace( '/\0+/', '', $string );
118
+ $string = preg_replace( '/(\\\\0)+/', '', $string );
119
+
120
+ return $string;
121
+ }
122
+ }
123
+ }
124
+
125
+ #endregion Core Redirect (copied from BuddyPress) -----------------------------------------
126
+
127
+ if ( ! function_exists( '__fs' ) ) {
128
+ global $fs_text_overrides;
129
+
130
+ if ( ! isset( $fs_text_overrides ) ) {
131
+ $fs_text_overrides = array();
132
+ }
133
+
134
+ /**
135
+ * Retrieve a translated text by key.
136
+ *
137
+ * @author Vova Feldman (@svovaf)
138
+ * @since 1.1.4
139
+ *
140
+ * @param string $key
141
+ * @param string $slug
142
+ *
143
+ * @return string
144
+ *
145
+ * @global $fs_text , $fs_text_overrides
146
+ */
147
+ function __fs( $key, $slug = 'freemius' ) {
148
+ global $fs_text, $fs_text_overrides;
149
+
150
+ if ( ! isset( $fs_text ) ) {
151
+ require_once( ( defined( 'WP_FS__DIR_INCLUDES' ) ? WP_FS__DIR_INCLUDES : dirname( __FILE__ ) ) . '/i18n.php' );
152
+ }
153
+
154
+ if ( isset( $fs_text_overrides[ $slug ] ) ) {
155
+ if ( isset( $fs_text_overrides[ $slug ][ $key ] ) ) {
156
+ return $fs_text_overrides[ $slug ][ $key ];
157
+ }
158
+
159
+ $lower_key = strtolower( $key );
160
+ if ( isset( $fs_text_overrides[ $slug ][ $lower_key ] ) ) {
161
+ return $fs_text_overrides[ $slug ][ $lower_key ];
162
+ }
163
+ }
164
+
165
+ return isset( $fs_text[ $key ] ) ?
166
+ $fs_text[ $key ] :
167
+ $key;
168
+ }
169
+
170
+ /**
171
+ * Display a translated text by key.
172
+ *
173
+ * @author Vova Feldman (@svovaf)
174
+ * @since 1.1.4
175
+ *
176
+ * @param string $key
177
+ * @param string $slug
178
+ */
179
+ function _efs( $key, $slug = 'freemius' ) {
180
+ echo __fs( $key, $slug );
181
+ }
182
+
183
+ /**
184
+ * Override default i18n text phrases.
185
+ *
186
+ * @author Vova Feldman (@svovaf)
187
+ * @since 1.1.6
188
+ *
189
+ * @param string[] $key_value
190
+ * @param string $slug
191
+ *
192
+ * @global $fs_text_overrides
193
+ */
194
+ function fs_override_i18n( array $key_value, $slug = 'freemius' ) {
195
+ global $fs_text_overrides;
196
+
197
+ if ( ! isset( $fs_text_overrides[ $slug ] ) ) {
198
+ $fs_text_overrides[ $slug ] = array();
199
+ }
200
+
201
+ foreach ( $key_value as $key => $value ) {
202
+ $fs_text_overrides[ $slug ][ $key ] = $value;
203
+ }
204
+ }
205
+ }
206
+
207
+ if ( ! function_exists( 'fs_get_ip' ) ) {
208
+ /**
209
+ * Get client IP.
210
+ *
211
+ * @author Vova Feldman (@svovaf)
212
+ * @since 1.1.2
213
+ *
214
+ * @return string|null
215
+ */
216
+ function fs_get_ip() {
217
+ $fields = array(
218
+ 'HTTP_CF_CONNECTING_IP',
219
+ 'HTTP_CLIENT_IP',
220
+ 'HTTP_X_FORWARDED_FOR',
221
+ 'HTTP_X_FORWARDED',
222
+ 'HTTP_FORWARDED_FOR',
223
+ 'HTTP_FORWARDED',
224
+ 'REMOTE_ADDR',
225
+ );
226
+
227
+ foreach ( $fields as $ip_field ) {
228
+ if ( ! empty( $_SERVER[ $ip_field ] ) ) {
229
+ return $_SERVER[ $ip_field ];
230
+ }
231
+ }
232
+
233
+ return null;
234
+ }
235
+ }
236
+
237
+ /**
238
+ * Leverage backtrace to find caller plugin main file path.
239
+ *
240
+ * @author Vova Feldman (@svovaf)
241
+ * @since 1.0.6
242
+ *
243
+ * @return string
244
+ */
245
+ function fs_find_caller_plugin_file() {
246
+ /**
247
+ * All the code below will be executed once on activation.
248
+ * If the user changes the main plugin's file name, the file_exists()
249
+ * will catch it.
250
+ */
251
+ if ( ! function_exists( 'get_plugins' ) ) {
252
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
253
+ }
254
+
255
+ $all_plugins = get_plugins();
256
+ $all_plugins_paths = array();
257
+
258
+ // Get active plugin's main files real full names (might be symlinks).
259
+ foreach ( $all_plugins as $relative_path => &$data ) {
260
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
261
+ }
262
+
263
+ $plugin_file = null;
264
+ for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
265
+ if ( in_array( fs_normalize_path( $bt[ $i ]['file'] ), $all_plugins_paths ) ) {
266
+ $plugin_file = $bt[ $i ]['file'];
267
+ break;
268
+ }
269
+ }
270
+
271
+ if ( is_null( $plugin_file ) ) {
272
+ // Throw an error to the developer in case of some edge case dev environment.
273
+ wp_die( __fs( 'failed-finding-main-path' ), __fs( 'error' ), array( 'back_link' => true ) );
274
+ }
275
+
276
+ return $plugin_file;
277
+ }
278
+
279
+ require_once dirname( __FILE__ ) . '/supplements/fs-essential-functions-1.1.7.1.php';
280
+
281
+ /**
282
+ * Update SDK newest version reference.
283
+ *
284
+ * @author Vova Feldman (@svovaf)
285
+ * @since 1.1.6
286
+ *
287
+ * @param string $sdk_relative_path
288
+ * @param string|bool $plugin_file
289
+ *
290
+ * @global $fs_active_plugins
291
+ */
292
+ function fs_update_sdk_newest_version( $sdk_relative_path, $plugin_file = false ) {
293
+ global $fs_active_plugins;
294
+
295
+ if ( ! is_string( $plugin_file ) ) {
296
+ $plugin_file = plugin_basename( fs_find_caller_plugin_file() );
297
+ }
298
+
299
+ $fs_active_plugins->newest = (object) array(
300
+ 'plugin_path' => $plugin_file,
301
+ 'sdk_path' => $sdk_relative_path,
302
+ 'version' => $fs_active_plugins->plugins[ $sdk_relative_path ]->version,
303
+ 'in_activation' => ! is_plugin_active( $plugin_file ),
304
+ 'timestamp' => time(),
305
+ );
306
+
307
+ // Update DB with latest SDK version and path.
308
+ update_option( 'fs_active_plugins', $fs_active_plugins );
309
+ }
310
+
311
+ /**
312
+ * Reorder the plugins load order so the plugin with the newest Freemius SDK is loaded first.
313
+ *
314
+ * @author Vova Feldman (@svovaf)
315
+ * @since 1.1.6
316
+ *
317
+ * @return bool Was plugin order changed. Return false if plugin was loaded first anyways.
318
+ *
319
+ * @global $fs_active_plugins
320
+ */
321
+ function fs_newest_sdk_plugin_first() {
322
+ global $fs_active_plugins;
323
+
324
+ /**
325
+ * @todo Multi-site network activated plugin are always loaded prior to site plugins so if there's a a plugin activated in the network mode that has an older version of the SDK of another plugin which is site activated that has new SDK version, the fs-essential-functions.php will be loaded from the older SDK. Same thing about MU plugins (loaded even before network activated plugins).
326
+ *
327
+ * @link https://github.com/Freemius/wordpress-sdk/issues/26
328
+ */
329
+ // $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
330
+
331
+ $active_plugins = get_option( 'active_plugins' );
332
+ $newest_sdk_plugin_key = array_search( $fs_active_plugins->newest->plugin_path, $active_plugins );
333
+ if ( 0 == $newest_sdk_plugin_key ) {
334
+ // if it's 0 it's the first plugin already, no need to continue
335
+ return false;
336
+ }
337
+
338
+ array_splice( $active_plugins, $newest_sdk_plugin_key, 1 );
339
+ array_unshift( $active_plugins, $fs_active_plugins->newest->plugin_path );
340
+ update_option( 'active_plugins', $active_plugins );
341
+
342
+ return true;
343
+ }
344
+
345
+ /**
346
+ * Go over all Freemius SDKs in the system and find and "remember"
347
+ * the newest SDK which is associated with an active plugin.
348
+ *
349
+ * @author Vova Feldman (@svovaf)
350
+ * @since 1.1.6
351
+ *
352
+ * @global $fs_active_plugins
353
+ */
354
+ function fs_fallback_to_newest_active_sdk() {
355
+ global $fs_active_plugins;
356
+
357
+ $newest_sdk_data = null;
358
+ $newest_sdk_path = null;
359
+
360
+ foreach ( $fs_active_plugins->plugins as $sdk_relative_path => $data ) {
361
+ if ( is_null( $newest_sdk_data ) || version_compare( $data->version, $newest_sdk_data->version, '>' )
362
+ ) {
363
+ // If plugin inactive or SDK starter file doesn't exist, remove SDK reference.
364
+ if ( ! is_plugin_active( $data->plugin_path ) ||
365
+ ! file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $sdk_relative_path . '/start.php' ) )
366
+ ) {
367
+ unset( $fs_active_plugins->plugins[ $sdk_relative_path ] );
368
+
369
+ // No need to store the data since it will be stored in fs_update_sdk_newest_version()
370
+ // or explicitly with update_option().
371
+ } else {
372
+ $newest_sdk_data = $data;
373
+ $newest_sdk_path = $sdk_relative_path;
374
+ }
375
+ }
376
+ }
377
+
378
+ if ( is_null( $newest_sdk_data ) ) {
379
+ // Couldn't find any SDK reference.
380
+ $fs_active_plugins = new stdClass();
381
+ update_option( 'fs_active_plugins', $fs_active_plugins );
382
+ } else {
383
+ fs_update_sdk_newest_version( $newest_sdk_path, $newest_sdk_data->plugin_path );
384
+ }
385
+ }
386
+
387
+ #region Actions / Filters -----------------------------------------
388
+
389
+ /**
390
+ * Apply filter for specific plugin.
391
+ *
392
+ * @author Vova Feldman (@svovaf)
393
+ * @since 1.0.9
394
+ *
395
+ * @param string $slug Plugin slug
396
+ * @param string $tag The name of the filter hook.
397
+ * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
398
+ *
399
+ * @return mixed The filtered value after all hooked functions are applied to it.
400
+ *
401
+ * @uses apply_filters()
402
+ */
403
+ function fs_apply_filter( $slug, $tag, $value ) {
404
+ $args = func_get_args();
405
+
406
+ return call_user_func_array( 'apply_filters', array_merge(
407
+ array( 'fs_' . $tag . '_' . $slug ),
408
+ array_slice( $args, 2 ) )
409
+ );
410
+ }
411
+
412
+ #endregion Actions / Filters -----------------------------------------
freemius/includes/fs-plugin-info-dialog.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Class FS_Plugin_Info_Dialog
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.1.7
18
+ */
19
+ class FS_Plugin_Info_Dialog {
20
+ /**
21
+ * @since 1.1.7
22
+ *
23
+ * @var FS_Logger
24
+ */
25
+ private $_logger;
26
+
27
+ /**
28
+ * @since 1.1.7
29
+ *
30
+ * @var Freemius
31
+ */
32
+ private $_fs;
33
+
34
+ function __construct( Freemius $fs ) {
35
+ $this->_fs = $fs;
36
+
37
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $fs->get_slug() . '_info', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
38
+
39
+ // Remove default plugin information action.
40
+ remove_all_actions( 'install_plugins_pre_plugin-information' );
41
+
42
+ // Override action with custom plugins function for add-ons.
43
+ add_action( 'install_plugins_pre_plugin-information', array( &$this, 'install_plugin_information' ) );
44
+
45
+ // Override request for plugin information for Add-ons.
46
+ add_filter(
47
+ 'fs_plugins_api',
48
+ array( &$this, '_get_addon_info_filter' ),
49
+ WP_FS__DEFAULT_PRIORITY, 3 );
50
+ }
51
+
52
+ /**
53
+ * Generate add-on plugin information.
54
+ *
55
+ * @author Vova Feldman (@svovaf)
56
+ * @since 1.0.6
57
+ *
58
+ * @param array $data
59
+ * @param string $action
60
+ * @param object|null $args
61
+ *
62
+ * @return array|null
63
+ */
64
+ function _get_addon_info_filter( $data, $action = '', $args = null ) {
65
+ $this->_logger->entrance();
66
+
67
+ $parent_plugin_id = fs_request_get( 'parent_plugin_id', false );
68
+
69
+ if ( $this->_fs->get_id() != $parent_plugin_id ||
70
+ ( 'plugin_information' !== $action ) ||
71
+ ! isset( $args->slug )
72
+ ) {
73
+ return $data;
74
+ }
75
+
76
+ // Find add-on by slug.
77
+ $addons = $this->_fs->get_addons();
78
+ $selected_addon = false;
79
+ foreach ( $addons as $addon ) {
80
+ if ( $addon->slug == $args->slug ) {
81
+ $selected_addon = $addon;
82
+ break;
83
+ }
84
+ }
85
+
86
+ if ( false === $selected_addon ) {
87
+ return $data;
88
+ }
89
+
90
+ if ( ! isset( $selected_addon->info ) ) {
91
+ // Setup some default info.
92
+ $selected_addon->info = new stdClass();
93
+ $selected_addon->info->selling_point_0 = 'Selling Point 1';
94
+ $selected_addon->info->selling_point_1 = 'Selling Point 2';
95
+ $selected_addon->info->selling_point_2 = 'Selling Point 3';
96
+ $selected_addon->info->description = '<p>Tell your users all about your add-on</p>';
97
+ }
98
+
99
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
100
+
101
+ $data = $args;
102
+
103
+ $is_free = true;
104
+
105
+ // Load add-on pricing.
106
+ $has_pricing = false;
107
+ $has_features = false;
108
+ $plans = false;
109
+ $plans_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans.json" );
110
+ if ( ! isset( $plans_result->error ) ) {
111
+ $plans = $plans_result->plans;
112
+ if ( is_array( $plans ) ) {
113
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
114
+ $plans[ $i ] = new FS_Plugin_Plan( $plans[ $i ] );
115
+ $plan = $plans[ $i ];
116
+
117
+ $pricing_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/pricing.json" );
118
+ if ( ! isset( $pricing_result->error ) ) {
119
+ // Update plan's pricing.
120
+ $plan->pricing = $pricing_result->pricing;
121
+
122
+ if ( is_array( $plan->pricing ) && ! empty( $plan->pricing ) ) {
123
+ $is_free = false;
124
+
125
+ foreach ( $plan->pricing as &$pricing ) {
126
+ $pricing = new FS_Pricing( $pricing );
127
+ }
128
+ }
129
+
130
+ $has_pricing = true;
131
+ }
132
+
133
+ $features_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/features.json" );
134
+ if ( ! isset( $features_result->error ) &&
135
+ is_array( $features_result->features ) &&
136
+ 0 < count( $features_result->features )
137
+ ) {
138
+ // Update plan's pricing.
139
+ $plan->features = $features_result->features;
140
+
141
+ $has_features = true;
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ // Fetch latest version from Freemius.
148
+ $latest = $this->_fs->_fetch_latest_version( $selected_addon->id );
149
+
150
+ if ( ! $is_free ) {
151
+ // If paid add-on, then it's not on wordpress.org
152
+ $is_wordpress_org = false;
153
+ } else {
154
+ // If no versions found, then assume it's a .org plugin.
155
+ $is_wordpress_org = ( false === $latest );
156
+ }
157
+
158
+ if ( $is_wordpress_org ) {
159
+ $repo_data = FS_Plugin_Updater::_fetch_plugin_info_from_repository(
160
+ 'plugin_information', (object) array(
161
+ 'slug' => $selected_addon->slug,
162
+ 'is_ssl' => is_ssl(),
163
+ 'fields' => array(
164
+ 'banners' => true,
165
+ 'reviews' => true,
166
+ 'downloaded' => false,
167
+ 'active_installs' => true
168
+ )
169
+ ) );
170
+
171
+ if ( ! empty( $repo_data ) ) {
172
+ $data = $repo_data;
173
+ $data->wp_org_missing = false;
174
+ } else {
175
+ // Couldn't find plugin on .org.
176
+ $is_wordpress_org = false;
177
+
178
+ // Plugin is missing, not on Freemius nor WP.org.
179
+ $data->wp_org_missing = true;
180
+ }
181
+ }
182
+
183
+ if ( ! $is_wordpress_org ) {
184
+ $data->checkout_link = $this->_fs->checkout_url();
185
+ $data->fs_missing = ( false === $latest );
186
+
187
+ if ( $is_free ) {
188
+ $data->download_link = $this->_fs->_get_latest_download_local_url( $selected_addon->id );
189
+ }
190
+ }
191
+
192
+ if ( ! $is_wordpress_org ) {
193
+ // Fetch as much as possible info from local files.
194
+ $plugin_local_data = $this->_fs->get_plugin_data();
195
+ $data->name = $selected_addon->title;
196
+ $data->author = $plugin_local_data['Author'];
197
+ $view_vars = array( 'plugin' => $selected_addon );
198
+ $data->sections = array(
199
+ 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
200
+ );
201
+
202
+ if ( ! empty( $selected_addon->info->banner_url ) ) {
203
+ $data->banners = array(
204
+ 'low' => $selected_addon->info->banner_url,
205
+ );
206
+ }
207
+
208
+ if ( ! empty( $selected_addon->info->screenshots ) ) {
209
+ $view_vars = array(
210
+ 'screenshots' => $selected_addon->info->screenshots,
211
+ 'plugin' => $selected_addon,
212
+ );
213
+ $data->sections['screenshots'] = fs_get_template( '/plugin-info/screenshots.php', $view_vars );
214
+ }
215
+
216
+ if ( is_object( $latest ) ) {
217
+ $data->version = $latest->version;
218
+ $data->last_updated = ! is_null( $latest->updated ) ? $latest->updated : $latest->created;
219
+ $data->requires = $latest->requires_platform_version;
220
+ $data->tested = $latest->tested_up_to_version;
221
+ } else {
222
+ // Add dummy version.
223
+ $data->version = '1.0.0';
224
+
225
+ // Add message to developer to deploy the plugin through Freemius.
226
+ }
227
+ }
228
+
229
+ if ( $has_pricing ) {
230
+ // Add plans to data.
231
+ $data->plans = $plans;
232
+
233
+ if ( $has_features ) {
234
+ $view_vars = array(
235
+ 'plans' => $plans,
236
+ 'plugin' => $selected_addon,
237
+ );
238
+ $data->sections['features'] = fs_get_template( '/plugin-info/features.php', $view_vars );
239
+ }
240
+ }
241
+
242
+ $data->is_paid = ! $is_free;
243
+ $data->external = ! $is_wordpress_org;
244
+
245
+ return $data;
246
+ }
247
+
248
+ /**
249
+ * @author Vova Feldman (@svovaf)
250
+ * @since 1.1.7
251
+ *
252
+ * @param FS_Plugin_Plan $plan
253
+ *
254
+ * @return string
255
+ */
256
+ private function get_billing_cycle( FS_Plugin_Plan $plan ) {
257
+ $billing_cycle = null;
258
+
259
+ if ( 1 === count( $plan->pricing ) && 1 == $plan->pricing[0]->licenses ) {
260
+ $pricing = $plan->pricing[0];
261
+ if ( isset( $pricing->annual_price ) ) {
262
+ $billing_cycle = 'annual';
263
+ } else if ( isset( $pricing->monthly_price ) ) {
264
+ $billing_cycle = 'monthly';
265
+ } else if ( isset( $pricing->lifetime_price ) ) {
266
+ $billing_cycle = 'lifetime';
267
+ }
268
+ } else {
269
+ foreach ( $plan->pricing as $pricing ) {
270
+ if ( isset( $pricing->annual_price ) ) {
271
+ $billing_cycle = 'annual';
272
+ } else if ( isset( $pricing->monthly_price ) ) {
273
+ $billing_cycle = 'monthly';
274
+ } else if ( isset( $pricing->lifetime_price ) ) {
275
+ $billing_cycle = 'lifetime';
276
+ }
277
+
278
+ if ( ! is_null( $billing_cycle ) ) {
279
+ break;
280
+ }
281
+ }
282
+ }
283
+
284
+ return $billing_cycle;
285
+ }
286
+
287
+ /**
288
+ * @author Vova Feldman (@svovaf)
289
+ * @since 1.1.7
290
+ *
291
+ * @param \FS_Plugin_Plan $plan
292
+ * @param \FS_Pricing $pricing
293
+ *
294
+ * @return float|null|string
295
+ */
296
+ private function get_price_tag( FS_Plugin_Plan $plan, FS_Pricing $pricing ) {
297
+ $price_tag = '';
298
+ if ( isset( $pricing->annual_price ) ) {
299
+ $price_tag = $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
300
+ } else if ( isset( $pricing->monthly_price ) ) {
301
+ $price_tag = $pricing->monthly_price . ' / mo';
302
+ } else if ( isset( $pricing->lifetime_price ) ) {
303
+ $price_tag = $pricing->lifetime_price;
304
+ }
305
+
306
+ return '$' . $price_tag;
307
+ }
308
+
309
+ /**
310
+ * @author Vova Feldman (@svovaf)
311
+ * @since 1.1.7
312
+ *
313
+ * @param object $api
314
+ * @param FS_Plugin_Plan|null $plan
315
+ *
316
+ * @return string
317
+ */
318
+ private function get_plugin_cta( $api, $plan = null ) {
319
+ if ( ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
320
+
321
+ if ( ! empty( $api->checkout_link ) && isset( $api->plans ) && 0 < is_array( $api->plans ) ) {
322
+ if ( is_null( $plan ) ) {
323
+ $plan = $api->plans[0];
324
+ }
325
+
326
+ return ' <a class="button button-primary right" href="' . $this->_fs->addon_checkout_url(
327
+ $plan->plugin_id,
328
+ $plan->pricing[0]->id,
329
+ $this->get_billing_cycle( $plan ),
330
+ $plan->has_trial()
331
+ ) . '" target="_parent">' .
332
+ ( ! $plan->has_trial() ?
333
+ __fs( 'purchase', $api->slug ) :
334
+ sprintf( __fs( 'start-free-x', $api->slug ), $this->get_trial_period( $plan ) )
335
+ ) .
336
+ '</a>';
337
+
338
+ // @todo Add Cart concept.
339
+ // echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
340
+
341
+ } else if ( ! empty( $api->download_link ) ) {
342
+ $status = install_plugin_install_status( $api );
343
+
344
+
345
+ // Hosted on WordPress.org.
346
+ switch ( $status['status'] ) {
347
+ case 'install':
348
+ if ( $api->external &&
349
+ $this->_fs->is_org_repo_compliant() ||
350
+ ! $this->_fs->is_premium()
351
+ ) {
352
+ /**
353
+ * Add-on hosted on Freemius, not yet installed, and core
354
+ * plugin is wordpress.org compliant. Therefore, require a download
355
+ * since installing external plugins is not allowed by the wp.org guidelines.
356
+ */
357
+ return ' <a class="button button-primary right" href="' . esc_url( $api->download_link ) . '" target="_blank">' . __fs( 'download-latest', $api->slug ) . '</a>';
358
+ } else {
359
+ if ( $status['url'] ) {
360
+ return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
361
+ }
362
+ }
363
+ break;
364
+ case 'update_available':
365
+ if ( $status['url'] ) {
366
+ return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
367
+ }
368
+ break;
369
+ case 'newer_installed':
370
+ return '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), $status['version'] ) . '</a>';
371
+ break;
372
+ case 'latest_installed':
373
+ return '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
374
+ break;
375
+ }
376
+
377
+ }
378
+ }
379
+ }
380
+
381
+ /**
382
+ * @author Vova Feldman (@svovaf)
383
+ * @since 1.1.7
384
+ *
385
+ * @param FS_Plugin_Plan $plan
386
+ *
387
+ * @return string
388
+ */
389
+ private function get_trial_period( $plan ) {
390
+ $trial_period = (int) $plan->trial_period;
391
+
392
+ switch ( $trial_period ) {
393
+ case 30:
394
+ return 'month';
395
+ case 60:
396
+ return '2 months';
397
+ default:
398
+ return "{$plan->trial_period} days";
399
+ }
400
+ }
401
+
402
+ /**
403
+ * Display plugin information in dialog box form.
404
+ *
405
+ * Based on core install_plugin_information() function.
406
+ *
407
+ * @author Vova Feldman (@svovaf)
408
+ * @since 1.0.6
409
+ */
410
+ function install_plugin_information() {
411
+ global $tab;
412
+
413
+ if ( empty( $_REQUEST['plugin'] ) ) {
414
+ return;
415
+ }
416
+
417
+ $args = array(
418
+ 'slug' => wp_unslash( $_REQUEST['plugin'] ),
419
+ 'is_ssl' => is_ssl(),
420
+ 'fields' => array(
421
+ 'banners' => true,
422
+ 'reviews' => true,
423
+ 'downloaded' => false,
424
+ 'active_installs' => true
425
+ )
426
+ );
427
+
428
+ if ( is_array( $args ) ) {
429
+ $args = (object) $args;
430
+ }
431
+
432
+ if ( ! isset( $args->per_page ) ) {
433
+ $args->per_page = 24;
434
+ }
435
+
436
+ if ( ! isset( $args->locale ) ) {
437
+ $args->locale = get_locale();
438
+ }
439
+
440
+ $api = apply_filters( 'fs_plugins_api', false, 'plugin_information', $args );
441
+
442
+ if ( is_wp_error( $api ) ) {
443
+ wp_die( $api );
444
+ }
445
+
446
+ $plugins_allowedtags = array(
447
+ 'a' => array(
448
+ 'href' => array(),
449
+ 'title' => array(),
450
+ 'target' => array(),
451
+ // Add image style for screenshots.
452
+ 'class' => array()
453
+ ),
454
+ 'style' => array(),
455
+ 'abbr' => array( 'title' => array() ),
456
+ 'acronym' => array( 'title' => array() ),
457
+ 'code' => array(),
458
+ 'pre' => array(),
459
+ 'em' => array(),
460
+ 'strong' => array(),
461
+ 'div' => array( 'class' => array() ),
462
+ 'span' => array( 'class' => array() ),
463
+ 'p' => array(),
464
+ 'ul' => array(),
465
+ 'ol' => array(),
466
+ 'li' => array( 'class' => array() ),
467
+ 'i' => array( 'class' => array() ),
468
+ 'h1' => array(),
469
+ 'h2' => array(),
470
+ 'h3' => array(),
471
+ 'h4' => array(),
472
+ 'h5' => array(),
473
+ 'h6' => array(),
474
+ 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
475
+ // 'table' => array(),
476
+ // 'td' => array(),
477
+ // 'tr' => array(),
478
+ // 'th' => array(),
479
+ // 'thead' => array(),
480
+ // 'tbody' => array(),
481
+ );
482
+
483
+ $plugins_section_titles = array(
484
+ 'description' => _x( 'Description', 'Plugin installer section title' ),
485
+ 'installation' => _x( 'Installation', 'Plugin installer section title' ),
486
+ 'faq' => _x( 'FAQ', 'Plugin installer section title' ),
487
+ 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ),
488
+ 'changelog' => _x( 'Changelog', 'Plugin installer section title' ),
489
+ 'reviews' => _x( 'Reviews', 'Plugin installer section title' ),
490
+ 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ),
491
+ );
492
+
493
+ // Sanitize HTML
494
+ // foreach ( (array) $api->sections as $section_name => $content ) {
495
+ // $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
496
+ // }
497
+
498
+ foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
499
+ if ( isset( $api->$key ) ) {
500
+ $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
501
+ }
502
+ }
503
+
504
+ // Add after $api->slug is ready.
505
+ $plugins_section_titles['features'] = __fs( 'features-and-pricing', $api->slug );
506
+
507
+ $_tab = esc_attr( $tab );
508
+
509
+ $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
510
+ if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
511
+ $section_titles = array_keys( (array) $api->sections );
512
+ $section = array_shift( $section_titles );
513
+ }
514
+
515
+ iframe_header( __( 'Plugin Install' ) );
516
+
517
+ $_with_banner = '';
518
+
519
+ // var_dump($api->banners);
520
+ if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
521
+ $_with_banner = 'with-banner';
522
+ $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
523
+ $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
524
+ ?>
525
+ <style type="text/css">
526
+ #plugin-information-title.with-banner
527
+ {
528
+ background-image: url( <?php echo esc_url( $low ); ?> );
529
+ }
530
+
531
+ @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 )
532
+ {
533
+ #plugin-information-title.with-banner
534
+ {
535
+ background-image: url( <?php echo esc_url( $high ); ?> );
536
+ }
537
+ }
538
+ </style>
539
+ <?php
540
+ }
541
+
542
+ echo '<div id="plugin-information-scrollable">';
543
+ echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
544
+ echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
545
+
546
+ foreach ( (array) $api->sections as $section_name => $content ) {
547
+ if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
548
+ continue;
549
+ }
550
+
551
+ if ( isset( $plugins_section_titles[ $section_name ] ) ) {
552
+ $title = $plugins_section_titles[ $section_name ];
553
+ } else {
554
+ $title = ucwords( str_replace( '_', ' ', $section_name ) );
555
+ }
556
+
557
+ $class = ( $section_name === $section ) ? ' class="current"' : '';
558
+ $href = add_query_arg( array( 'tab' => $tab, 'section' => $section_name ) );
559
+ $href = esc_url( $href );
560
+ $san_section = esc_attr( $section_name );
561
+ echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
562
+ }
563
+
564
+ echo "</div>\n";
565
+
566
+ ?>
567
+ <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
568
+ <div class="fyi">
569
+ <?php if ( isset( $api->plans ) ) : ?>
570
+ <div class="plugin-information-pricing">
571
+ <?php foreach ($api->plans as $plan) : ?>
572
+ <?php
573
+ /**
574
+ * @var FS_Plugin_Plan $plan
575
+ */
576
+ ?>
577
+ <h3 data-plan="<?php echo $plan->id ?>"><?php printf( __fs( 'x-plan', $api->slug ), $plan->title ) ?></h3>
578
+ <?php if ( $api->is_paid ) : ?>
579
+ <ul>
580
+ <?php if ( 1 === count( $plan->pricing ) && 1 == $plan->pricing[0]->licenses ) : ?>
581
+ <?php $pricing = $plan->pricing[0] ?>
582
+ <li><label><?php _efs( 'price', $api->slug ) ?>
583
+ : <?php echo $this->get_price_tag( $plan, $pricing ) ?></label></li>
584
+ <?php else : ?>
585
+ <?php $first = true;
586
+ foreach ( $plan->pricing as $pricing ) : ?>
587
+ <li><label><input name="pricing-<?php echo $plan->id ?>" type="radio"
588
+ value="<?php echo $pricing->id ?>"<?php checked( $first, true ) ?>><?php
589
+ switch ( $pricing->licenses ) {
590
+ case '1':
591
+ _efs( 'license-single-site', $api->slug );
592
+ break;
593
+ case null:
594
+ _efs( 'license-unlimited', $api->slug );
595
+ break;
596
+ default:
597
+ printf( __fs( 'license-x-sites', $api->slug ), $pricing->licenses );
598
+ break;
599
+ }
600
+ ?> - <?php echo $this->get_price_tag( $plan, $pricing ) ?></label></li>
601
+ <?php $first = false; endforeach ?>
602
+ <?php endif ?>
603
+ </ul>
604
+ <?php endif ?>
605
+ <?php echo $this->get_plugin_cta( $api, $plan ) ?>
606
+ <div style="clear:both"></div>
607
+ <?php if ( $api->is_paid ) : ?>
608
+ <?php if ( $plan->has_trial() ) : ?>
609
+ <?php $trial_period = $this->get_trial_period( $plan ) ?>
610
+ <ul class="fs-trial-terms">
611
+ <li>
612
+ <i class="dashicons dashicons-yes"></i><?php printf( __fs( 'no-commitment-x', $api->slug ), $trial_period ) ?>
613
+ </li>
614
+ <li>
615
+ <i class="dashicons dashicons-yes"></i><?php printf( __fs( 'after-x-pay-as-little-y', $api->slug ), $trial_period, $this->get_price_tag( $plan, $plan->pricing[0] ) ) ?>
616
+ </li>
617
+ </ul>
618
+ <?php endif ?>
619
+ <?php endif ?>
620
+ </div>
621
+ <?php endforeach ?>
622
+ <?php if ($api->is_paid) : ?>
623
+ <?php $plan = $api->plans[0] ?>
624
+ <?php $billing_cycle = $this->get_billing_cycle( $plan ) ?>
625
+
626
+ <?php wp_enqueue_script( 'jquery' ); ?>
627
+ <script type="text/javascript">
628
+ (function ($) {
629
+ $('.plugin-information-pricing input[type=radio]').click(function () {
630
+ var checkout_url = '<?php echo esc_url_raw(add_query_arg(array(
631
+ 'plugin_id' => $plan->plugin_id,
632
+ 'billing_cycle' => $billing_cycle,
633
+ ), $api->checkout_link)) ?>&plan_id=' +
634
+ $(this).parents('.plugin-information-pricing').find('h3').attr('data-plan') +
635
+ '&pricing_id=' + $(this).val();
636
+
637
+ $('.plugin-information-pricing .button, #plugin-information-footer .button').attr('href', checkout_url);
638
+ });
639
+ })(jQuery);
640
+ </script>
641
+ <?php endif ?>
642
+ <?php endif ?>
643
+ <div>
644
+ <h3><?php _efs( 'details', $api->slug ) ?></h3>
645
+ <ul>
646
+ <?php if ( ! empty( $api->version ) ) { ?>
647
+ <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
648
+ <?php
649
+ }
650
+ if ( ! empty( $api->author ) ) {
651
+ ?>
652
+ <li>
653
+ <strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?>
654
+ </li>
655
+ <?php
656
+ }
657
+ if ( ! empty( $api->last_updated ) ) {
658
+ ?>
659
+ <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span
660
+ title="<?php echo $api->last_updated; ?>">
661
+ <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
662
+ </span></li>
663
+ <?php
664
+ }
665
+ if ( ! empty( $api->requires ) ) {
666
+ ?>
667
+ <li>
668
+ <strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?>
669
+ </li>
670
+ <?php
671
+ }
672
+ if ( ! empty( $api->tested ) ) {
673
+ ?>
674
+ <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?>
675
+ </li>
676
+ <?php
677
+ }
678
+ if ( ! empty( $api->downloaded ) ) {
679
+ ?>
680
+ <li>
681
+ <strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?>
682
+ </li>
683
+ <?php
684
+ }
685
+ if ( ! empty( $api->slug ) && empty( $api->external ) ) {
686
+ ?>
687
+ <li><a target="_blank"
688
+ href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a>
689
+ </li>
690
+ <?php
691
+ }
692
+ if ( ! empty( $api->homepage ) ) {
693
+ ?>
694
+ <li><a target="_blank"
695
+ href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a>
696
+ </li>
697
+ <?php
698
+ }
699
+ if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) {
700
+ ?>
701
+ <li><a target="_blank"
702
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
703
+ </li>
704
+ <?php } ?>
705
+ </ul>
706
+ </div>
707
+ <?php if ( ! empty( $api->rating ) ) { ?>
708
+ <h3><?php _e( 'Average Rating' ); ?></h3>
709
+ <?php wp_star_rating( array(
710
+ 'rating' => $api->rating,
711
+ 'type' => 'percent',
712
+ 'number' => $api->num_ratings
713
+ ) ); ?>
714
+ <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small>
715
+ <?php
716
+ }
717
+
718
+ if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
719
+ foreach ( $api->ratings as $key => $ratecount ) {
720
+ // Avoid div-by-zero.
721
+ $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
722
+ ?>
723
+ <div class="counter-container">
724
+ <span class="counter-label"><a
725
+ href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
726
+ target="_blank"
727
+ title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
728
+ <span class="counter-back">
729
+ <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
730
+ </span>
731
+ <span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span>
732
+ </div>
733
+ <?php
734
+ }
735
+ }
736
+ if ( ! empty( $api->contributors ) ) {
737
+ ?>
738
+ <h3><?php _e( 'Contributors' ); ?></h3>
739
+ <ul class="contributors">
740
+ <?php
741
+ foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
742
+ if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
743
+ continue;
744
+ }
745
+ if ( empty( $contrib_username ) ) {
746
+ $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
747
+ }
748
+ $contrib_username = sanitize_user( $contrib_username );
749
+ if ( empty( $contrib_profile ) ) {
750
+ echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</li>";
751
+ } else {
752
+ echo "<li><a href='{$contrib_profile}' target='_blank'><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</a></li>";
753
+ }
754
+ }
755
+ ?>
756
+ </ul>
757
+ <?php if ( ! empty( $api->donate_link ) ) { ?>
758
+ <a target="_blank"
759
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
760
+ <?php } ?>
761
+ <?php } ?>
762
+ </div>
763
+ <div id="section-holder" class="wrap">
764
+ <?php
765
+ if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
766
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been tested with your current version of WordPress.' ) . '</p></div>';
767
+ } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
768
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been marked as compatible with your version of WordPress.' ) . '</p></div>';
769
+ }
770
+
771
+ foreach ( (array) $api->sections as $section_name => $content ) {
772
+ $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
773
+ $content = links_add_target( $content, '_blank' );
774
+
775
+ $san_section = esc_attr( $section_name );
776
+
777
+ $display = ( $section_name === $section ) ? 'block' : 'none';
778
+
779
+ if ( 'description' === $section_name &&
780
+ ( ( ! $api->external && $api->wp_org_missing ) ||
781
+ ( $api->external && $api->fs_missing ) )
782
+ ) {
783
+ $missing_notice = array(
784
+ 'type' => 'error',
785
+ 'id' => md5( microtime() ),
786
+ 'message' => __fs( ($api->is_paid ? 'paid-addon-not-deployed' : 'free-addon-not-deployed'), $api->slug ),
787
+ );
788
+ fs_require_template( 'admin-notice.php', $missing_notice );
789
+ }
790
+ echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
791
+ echo $content;
792
+ echo "\t</div>\n";
793
+ }
794
+ echo "</div>\n";
795
+ echo "</div>\n";
796
+ echo "</div>\n"; // #plugin-information-scrollable
797
+ echo "<div id='$tab-footer'>\n";
798
+
799
+ echo $this->get_plugin_cta( $api );
800
+
801
+ echo "</div>\n";
802
+
803
+ iframe_footer();
804
+ exit;
805
+ }
806
+ }
freemius/includes/i18n.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * All strings can now be overridden.
15
+ *
16
+ * For example, if we want to override:
17
+ * 'you-are-step-away' => 'You are just one step away - %s',
18
+ *
19
+ * We can use the filter:
20
+ * fs_override_i18n( array(
21
+ * 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
22
+ * 'skip' => __( 'Not today', '{your-text_domain}' ),
23
+ * ), '{plugin_slug}' );
24
+ *
25
+ * Or with the Freemius instance:
26
+ *
27
+ * my_freemius->override_i18n( array(
28
+ * 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
29
+ * 'skip' => __( 'Not today', '{your-text_domain}' ),
30
+ * );
31
+ */
32
+ global $fs_text;
33
+
34
+ $fs_text = array(
35
+ 'account' => __( 'Account', 'freemius' ),
36
+ 'addon' => __( 'Add On', 'freemius' ),
37
+ 'contact-us' => __( 'Contact Us', 'freemius' ),
38
+ 'change-ownership' => __( 'Change Ownership', 'freemius' ),
39
+ 'support' => __( 'Support', 'freemius' ),
40
+ 'support-forum' => __( 'Support Forum', 'freemius' ),
41
+ 'add-ons' => __( 'Add Ons', 'freemius' ),
42
+ 'upgrade' => _x( 'Upgrade', 'verb', 'freemius' ),
43
+ 'awesome' => __( 'Awesome', 'freemius' ),
44
+ 'pricing' => _x( 'Pricing', 'noun', 'freemius' ),
45
+ 'price' => _x( 'Price', 'noun', 'freemius' ),
46
+ 'unlimited-updates' => __( 'Unlimited Updates', 'freemius' ),
47
+ 'downgrade' => _x( 'Downgrade', 'verb', 'freemius' ),
48
+ 'cancel-trial' => __( 'Cancel Trial', 'freemius' ),
49
+ 'free-trial' => __( 'Free Trial', 'freemius' ),
50
+ 'start-free-x' => __( 'Start my free %s', 'freemius' ),
51
+ 'no-commitment-x' => __( 'No commitment for %s - cancel anytime', 'freemius' ),
52
+ 'after-x-pay-as-little-y' => __( 'After your free %s, pay as little as %s', 'freemius' ),
53
+ 'details' => __( 'Details', 'freemius' ),
54
+ 'account-details' => __( 'Account Details', 'freemius' ),
55
+ 'delete' => _x( 'Delete', 'verb', 'freemius' ),
56
+ 'delete-account' => __( 'Delete Account', 'freemius' ),
57
+ 'dismiss' => _x( 'Dismiss', 'as close a window', 'freemius' ),
58
+ 'plan' => _x( 'Plan', 'as product pricing plan', 'freemius' ),
59
+ 'change-plan' => __( 'Change Plan', 'freemius' ),
60
+ 'download-x-version' => _x( 'Download %s Version', 'as download professional version', 'freemius' ),
61
+ 'download-x-version-now' => _x( 'Download %s version now', 'as download professional version now', 'freemius' ),
62
+ 'download-latest' => _x( 'Download Latest', 'as download latest version', 'freemius' ),
63
+ 'you-have-x-license' => _x( 'You have a %s license.', 'E.g. you have a professional license.', 'freemius' ),
64
+ 'new' => __( 'New', 'freemius' ),
65
+ 'free' => __( 'Free', 'freemius' ),
66
+ 'trial' => _x( 'Trial', 'as trial plan', 'freemius' ),
67
+ 'purchase' => _x( 'Purchase', 'verb', 'freemius' ),
68
+ 'purchase-license' => __( 'Purchase License', 'freemius' ),
69
+ 'buy' => _x( 'Buy', 'verb', 'freemius' ),
70
+ 'buy-license' => __( 'Buy License', 'freemius' ),
71
+ 'license-single-site' => __( 'Single Site License', 'freemius' ),
72
+ 'license-unlimited' => __( 'Unlimited Licenses', 'freemius' ),
73
+ 'license-x-sites' => __( 'Up to %s Sites', 'freemius' ),
74
+ 'renew-license-now' => __( '%sRenew your license now%s to access version %s features and support.', 'freemius' ),
75
+ 'x-plan' => _x( '%s Plan', 'e.g. Professional Plan', 'freemius' ),
76
+ 'you-are-step-away' => __( 'You are just one step away - %s', 'freemius' ),
77
+ 'activate-x-now' => _x( 'Complete "%s" Activation Now', '%s - plugin name. As complete "Jetpack" activation now', 'freemius' ),
78
+ 'few-plugin-tweaks' => __( 'We made a few tweaks to the plugin, %s', 'freemius' ),
79
+ 'optin-x-now' => __( 'Opt-in to make "%s" Better!', 'freemius' ),
80
+ 'error' => __( 'Error', 'freemius' ),
81
+ 'failed-finding-main-path' => __( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'freemius' ),
82
+ #region Account
83
+
84
+ 'expiration' => _x( 'Expiration', 'as expiration date', 'freemius' ),
85
+ 'license' => _x( 'License', 'as software license', 'freemius' ),
86
+ 'not-verified' => __( 'not verified', 'freemius' ),
87
+ 'verify-email' => __( 'Verify Email', 'freemius' ),
88
+ 'expires-in' => _x( 'Expires in %s', 'e.g. expires in 2 months', 'freemius' ),
89
+ 'renews-in' => _x( 'Auto renews in %s', 'e.g. auto renews in 2 months', 'freemius' ),
90
+ 'no-expiration' => __( 'No expiration', 'freemius' ),
91
+ 'expired' => __( 'Expired', 'freemius' ),
92
+ 'cancelled' => __( 'Cancelled', 'freemius' ),
93
+ 'in-x' => _x( 'In %s', 'e.g. In 2 hours', 'freemius' ),
94
+ 'x-ago' => _x( '%s ago', 'e.g. 2 min ago', 'freemius' ),
95
+ 'version' => _x( 'Version', 'as plugin version', 'freemius' ),
96
+ 'name' => __( 'Name', 'freemius' ),
97
+ 'email' => __( 'Email', 'freemius' ),
98
+ 'verified' => __( 'Verified', 'freemius' ),
99
+ 'plugin' => __( 'Plugin', 'freemius' ),
100
+ 'plugins' => __( 'Plugins', 'freemius' ),
101
+ 'path' => _x( 'Path', 'as file/folder path', 'freemius' ),
102
+ 'title' => __( 'Title', 'freemius' ),
103
+ 'free-version' => __( 'Free version', 'freemius' ),
104
+ 'premium-version' => __( 'Premium version', 'freemius' ),
105
+ 'slug' => _x( 'Slug', 'as WP plugin slug', 'freemius' ),
106
+ 'id' => __( 'ID', 'freemius' ),
107
+ 'users' => __( 'Users', 'freemius' ),
108
+ 'plugin-installs' => __( 'Plugin Installs', 'freemius' ),
109
+ 'sites' => _x( 'Sites', 'like websites', 'freemius' ),
110
+ 'user-id' => __( 'User ID', 'freemius' ),
111
+ 'site-id' => __( 'Site ID', 'freemius' ),
112
+ 'public-key' => __( 'Public Key', 'freemius' ),
113
+ 'secret-key' => __( 'Secret Key', 'freemius' ),
114
+ 'no-secret' => _x( 'No Secret', 'as secret encryption key missing', 'freemius' ),
115
+ 'no-id' => __( 'No ID', 'freemius' ),
116
+ 'sync-license' => _x( 'Sync License', 'as synchronize license', 'freemius' ),
117
+ 'sync' => _x( 'Sync', 'as synchronize', 'freemius' ),
118
+ 'deactivate-license' => __( 'Deactivate License', 'freemius' ),
119
+ 'activate' => __( 'Activate', 'freemius' ),
120
+ 'deactivate' => __( 'Deactivate', 'freemius' ),
121
+ 'no-deactivate' => __( 'No - just deactivate', 'freemius' ),
122
+ 'yes-do-your-thing' => __( 'Yes - do your thing', 'freemius' ),
123
+ 'active' => _x( 'Active', 'active mode', 'freemius' ),
124
+ 'is-active' => _x( 'Is Active', 'is active mode?', 'freemius' ),
125
+ 'install-now' => __( 'Install Now', 'freemius' ),
126
+ 'install-update-now' => __( 'Install Update Now', 'freemius' ),
127
+ 'more-information-about-x' => __( 'More information about %s', 'freemius' ),
128
+ 'localhost' => __( 'Localhost', 'freemius' ),
129
+ 'activate-x-plan' => _x( 'Activate %s Plan', 'as activate Professional plan', 'freemius' ),
130
+ 'what-is-your-x' => __( 'What is your %s?', 'freemius' ),
131
+ 'activate-this-addon' => __( 'Activate this add-on', 'freemius' ),
132
+ 'deactivate-license-confirm' => __( 'Deactivating your license will block all premium features, but will enable you to activate the license on another site. Are you sure you want to proceed?', 'freemius' ),
133
+ 'delete-account-x-confirm' => __( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'freemius' ),
134
+ 'delete-account-confirm' => __( 'Deletion is not temporary. Only delete if you no longer want to use this plugin anymore. Are you sure you would like to continue with the deletion?', 'freemius' ),
135
+ 'downgrade-x-confirm' => __( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'freemius' ),
136
+ 'cancel-trial-confirm' => __( 'Cancelling the trial will immediately block access to all premium features. Are you sure?', 'freemius' ),
137
+ 'after-downgrade-non-blocking' => __( 'You can still enjoy all %s features but you will not have access to plugin updates and support.', 'freemius' ),
138
+ 'after-downgrade-blocking' => __( 'Once your license expire you can still use the Free version but you will NOT have access to the %s features.', 'freemius' ),
139
+ 'proceed-confirmation' => __( 'Are you sure you want to proceed?', 'freemius' ),
140
+ #endregion Account
141
+
142
+ 'add-ons-for-x' => __( 'Add Ons for %s', 'freemius' ),
143
+ 'add-ons-missing' => __( 'We could\'nt load the add-ons list. It\'s probably an issue on our side, please try to come back in few minutes.', 'freemius' ),
144
+ #region Plugin Deactivation
145
+ 'deactivation-share-reason' => __( 'If you have a moment, please let us know why you are deactivating', 'freemius' ),
146
+ 'deactivation-modal-button-confirm' => __( 'Yes - Deactivate', 'freemius' ),
147
+ 'deactivation-modal-button-submit' => __( 'Submit & Deactivate', 'freemius' ),
148
+ 'deactivation-modal-button-cancel' => _x( 'Cancel', 'the text of the cancel button of the plugin deactivation dialog box.', 'freemius' ),
149
+ 'reason-no-longer-needed' => __( 'I no longer need the plugin', 'freemius' ),
150
+ 'reason-found-a-better-plugin' => __( 'I found a better plugin', 'freemius' ),
151
+ 'reason-needed-for-a-short-period' => __( 'I only needed the plugin for a short period', 'freemius' ),
152
+ 'reason-broke-my-site' => __( 'The plugin broke my site', 'freemius' ),
153
+ 'reason-suddenly-stopped-working' => __( 'The plugin suddenly stopped working', 'freemius' ),
154
+ 'reason-cant-pay-anymore' => __( "I can't pay for it anymore", 'freemius' ),
155
+ 'reason-other' => _x( 'Other', 'the text of the "other" reason for deactivating the plugin that is shown in the modal box.', 'freemius' ),
156
+ 'placeholder-plugin-name' => __( "What's the plugin's name?", 'freemius' ),
157
+ 'placeholder-comfortable-price' => __( 'What price would you feel comfortable paying?', 'freemius' ),
158
+ 'reason-couldnt-make-it-work' => __( "I couldn't understand how to make it work", 'freemius' ),
159
+ 'reason-great-but-need-specific-feature' => __( "The plugin is great, but I need specific feature that you don't support", 'freemius' ),
160
+ 'reason-not-working' => __( 'The plugin is not working', 'freemius' ),
161
+ 'reason-not-what-i-was-looking-for' => __( "It's not what I was looking for", 'freemius' ),
162
+ 'reason-didnt-work-as-expected' => __( "The plugin didn't work as expected", 'freemius' ),
163
+ 'placeholder-feature' => __( 'What feature?', 'freemius' ),
164
+ 'placeholder-share-what-didnt-work' => __( "Kindly share what didn't work so we can fix it for future users...", 'freemius' ),
165
+ 'placeholder-what-youve-been-looking-for' => __( "What you've been looking for?", 'freemius' ),
166
+ 'placeholder-what-did-you-expect' => __( "What did you expect?", 'freemius' ),
167
+ 'reason-didnt-work' => __( "The plugin didn't work", 'freemius' ),
168
+ 'reason-dont-like-to-share-my-information' => __( "I don't like to share my information with you", 'freemius' ),
169
+ #endregion Plugin Deactivation
170
+
171
+ #region Connect
172
+ 'hey-x' => _x( 'Hey %s,', 'greeting', 'freemius' ),
173
+ 'thanks-x' => _x( 'Thanks %s!', 'a greeting. E.g. Thanks John!', 'freemius' ),
174
+ 'connect-message' => __( 'In order to enjoy all our features and functionality, %s needs to connect your user, %s at %s, to %s', 'freemius' ),
175
+ 'connect-message_on-update' => __( 'Please help us improve %2$s! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s okay! %2$s will still work just fine.', 'freemius' ),
176
+ 'pending-activation-message' => __( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to complete the install.', 'freemius' ),
177
+ 'what-permissions' => __( 'What permissions are being granted?', 'freemius' ),
178
+ 'permissions-profile' => __( 'Your Profile Overview', 'freemius' ),
179
+ 'permissions-profile_desc' => __( 'Name and email address', 'freemius' ),
180
+ 'permissions-site' => __( 'Your Site Overview', 'freemius' ),
181
+ 'permissions-site_desc' => __( 'Site address, WordPress version, PHP Version', 'freemius' ),
182
+ 'permissions-events' => __( 'Plugin Events', 'freemius' ),
183
+ 'permissions-events_desc' => __( 'Activation, deactivation and uninstall', 'freemius' ),
184
+ 'permissions-newsletter' => __( 'Newsletter', 'freemius' ),
185
+ 'permissions-newsletter_desc' => __( 'Updates, announcements, marketing, no spam', 'freemius' ),
186
+ 'privacy-policy' => __( 'Privacy Policy', 'freemius' ),
187
+ 'tos' => __( 'Terms of Service', 'freemius' ),
188
+ 'activating' => _x( 'Activating', 'as activating plugin', 'freemius' ),
189
+ 'sending-email' => _x( 'Sending email', 'as in the process of sending an email', 'freemius' ),
190
+ 'opt-in-connect' => _x( 'Allow & Continue', 'button label', 'freemius' ),
191
+ 'skip' => _x( 'Skip', 'verb', 'freemius' ),
192
+ 'resend-activation-email' => __( 'Re-send activation email', 'freemius' ),
193
+ #endregion Connect
194
+
195
+ #region Screenshots
196
+ 'screenshots' => __( 'Screenshots', 'freemius' ),
197
+ 'view-full-size-x' => __( 'Click to view full-size screenshot %d', 'freemius' ),
198
+ #endregion Screenshots
199
+
200
+ #region Debug
201
+ 'freemius-debug' => __( 'Freemius Debug', 'freemius' ),
202
+ 'on' => _x( 'On', 'as turned on', 'freemius' ),
203
+ 'off' => _x( 'Off', 'as turned off', 'freemius' ),
204
+ 'debugging' => _x( 'Debugging', 'as code debugging', 'freemius' ),
205
+ 'freemius-state' => __( 'Freemius State', 'freemius' ),
206
+ 'connected' => _x( 'Connected', 'as connection was successful', 'freemius' ),
207
+ 'blocked' => _x( 'Blocked', 'as connection blocked', 'freemius' ),
208
+ 'api' => _x( 'API', 'as application program interface', 'freemius' ),
209
+ 'sdk' => _x( 'SDK', 'as software development kit versions', 'freemius' ),
210
+ 'sdk-versions' => _x( 'SDK Versions', 'as software development kit versions', 'freemius' ),
211
+ 'plugin-path' => _x( 'Plugin Path', 'as plugin folder path', 'freemius' ),
212
+ 'sdk-path' => _x( 'SDK Path', 'as sdk path', 'freemius' ),
213
+ 'addons-of-x' => __( 'Add Ons of Plugin %s', 'freemius' ),
214
+ 'delete-all-confirm' => __( 'Are you sure you want to delete all Freemius data?', 'freemius' ),
215
+ 'actions' => __( 'Actions', 'freemius' ),
216
+ 'delete-all-accounts' => __( 'Delete All Accounts', 'freemius' ),
217
+ 'start-fresh' => __( 'Start Fresh', 'freemius' ),
218
+ 'clear-api-cache' => __( 'Clear API Cache', 'freemius' ),
219
+ 'sync-data-from-server' => __( 'Sync Data From Server', 'freemius' ),
220
+ 'scheduled-crons' => __( 'Scheduled Crons', 'freemius' ),
221
+ #endregion Debug
222
+
223
+ #region Expressions
224
+ 'congrats' => _x( 'Congrats', 'as congratulations', 'freemius' ),
225
+ 'oops' => _x( 'Oops', 'exclamation', 'freemius' ),
226
+ 'yee-haw' => _x( 'Yee-haw', 'interjection expressing joy or exuberance', 'freemius' ),
227
+ 'woot' => _x( 'W00t', '(especially in electronic communication) used to express elation, enthusiasm, or triumph.', 'freemius' ),
228
+ 'right-on' => _x( 'Right on', 'a positive response', 'freemius' ),
229
+ 'hmm' => _x( 'Hmm', 'something somebody says when they are thinking about what you have just said. ', 'freemius' ),
230
+ 'ok' => __( 'O.K', 'freemius' ),
231
+ 'hey' => _x( 'Hey', 'exclamation', 'freemius' ),
232
+ 'heads-up' => _x( 'Heads up', 'advance notice of something that will need attention.', 'freemius' ),
233
+ #endregion Expressions
234
+
235
+ #region Admin Notices
236
+ 'you-have-latest' => __( 'Seems like you got the latest release.', 'freemius' ),
237
+ 'you-are-good' => __( 'You are all good!', 'freemius' ),
238
+ 'user-exist-message' => __( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'freemius' ),
239
+ 'user-exist-message_ownership' => __( 'If you would like to give up the ownership of the plugin\'s account to %s click the Change Ownership button.', 'freemius' ),
240
+ 'email-updated-message' => __( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.', 'freemius' ),
241
+ 'name-updated-message' => __( 'Your name was successfully updated.', 'freemius' ),
242
+ 'x-updated' => __( 'You have successfully updated your %s.', 'freemius' ),
243
+ 'name-update-failed-message' => __( 'Please provide your full name.', 'freemius' ),
244
+ 'verification-email-sent-message' => __( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'freemius' ),
245
+ 'addons-info-external-message' => __( 'Just letting you know that the add-ons information of %s is being pulled from an external server.', 'freemius' ),
246
+ 'no-cc-required' => __( 'No credit card required', 'freemius' ),
247
+ 'premium-activated-message' => __( 'Premium plugin version was successfully activated.', 'freemius' ),
248
+ 'successful-version-upgrade-message' => __( 'The upgrade of %s was successfully completed.', 'freemius' ),
249
+ 'activation-with-plan-x-message' => __( 'Your account was successfully activated with the %s plan.', 'freemius' ),
250
+ 'download-latest-x-version' => __( 'Download the latest %s version now', 'freemius' ),
251
+ 'download-latest-version' => __( 'Download the latest version now', 'freemius' ),
252
+ 'addon-successfully-purchased-message' => _x( '%s Add-on was successfully purchased.', '%s - product name, e.g. Facebook add-on was successfully...', 'freemius' ),
253
+ 'addon-successfully-upgraded-message' => __( 'Your %s Add-on plan was successfully upgraded.', 'freemius' ),
254
+ 'email-verified-message' => __( 'Your email has been successfully verified - you are AWESOME!', 'freemius' ),
255
+ 'plan-upgraded-message' => __( 'Your plan was successfully upgraded.', 'freemius' ),
256
+ 'plan-changed-to-x-message' => __( 'Your plan was successfully changed to %s.', 'freemius' ),
257
+ 'license-expired-blocking-message' => __( 'Your license has expired. You can still continue using the free plugin forever.', 'freemius' ),
258
+ 'trial-started-message' => __( 'Your trial has been successfully started.', 'freemius' ),
259
+ 'license-activated-message' => __( 'Your license was successfully activated.', 'freemius' ),
260
+ 'no-active-license-message' => __( 'It looks like your site currently doesn\'t have an active license.', 'freemius' ),
261
+ 'license-deactivation-message' => __( 'Your license was successfully deactivated, you are back to the %s plan.', 'freemius' ),
262
+ 'license-deactivation-failed-message' => __( 'It looks like the license deactivation failed.', 'freemius' ),
263
+ 'license-activation-failed-message' => __( 'It looks like the license could not be activated.', 'freemius' ),
264
+ 'server-error-message' => __( 'Error received from the server:', 'freemius' ),
265
+ 'trial-expired-message' => __( 'Your trial has expired. You can still continue using all our free features.', 'freemius' ),
266
+ 'plan-x-downgraded-message' => __( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.', 'freemius' ),
267
+ 'plan-downgraded-failure-message' => __( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.', 'freemius' ),
268
+ 'trial-cancel-no-trial-message' => __( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'freemius' ),
269
+ 'trial-cancel-message' => __( 'Your %s free trial was successfully cancelled.', 'freemius' ),
270
+ 'version-x-released' => _x( 'Version %s was released.', '%s - numeric version number', 'freemius' ),
271
+ 'please-download-x' => __( 'Please download %s.', 'freemius' ),
272
+ 'latest-x-version' => _x( 'the latest %s version here', '%s - plan name, as the latest professional version here', 'freemius' ),
273
+ 'trial-x-promotion-message' => __( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.', 'freemius' ),
274
+ 'start-free-trial' => _x( 'Start free trial', 'call to action', 'freemius' ),
275
+ 'trial-cancel-failure-message' => __( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'freemius' ),
276
+ 'no-commitment-for-x-days' => __( 'No commitment for %s days - cancel anytime!', 'freemius' ),
277
+ 'license-expired-non-blocking-message' => __( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.', 'freemius' ),
278
+ 'could-not-activate-x' => __( 'Couldn\'t activate %s.', 'freemius' ),
279
+ 'contact-us-with-error-message' => __( 'Please contact us with the following message:', 'freemius' ),
280
+ 'plan-did-not-change-message' => __( 'It looks like you are still on the %s plan. If you did upgrade or change your plan, it\'s probably an issue on our side - sorry.', 'freemius' ),
281
+ 'contact-us-here' => __( 'Please contact us here', 'freemius' ),
282
+ 'plan-did-not-change-email-message' => __( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.', 'freemius' ),
283
+ #endregion Admin Notices
284
+ #region Connectivity Issues
285
+ 'connectivity-test-fails-message' => __( 'From unknown reason, the API connectivity test failed.', 'freemius' ),
286
+ 'connectivity-test-maybe-temporary' => __( 'It\'s probably a temporary issue on our end. Just to be sure, with your permission, would it be o.k to run another connectivity test?', 'freemius' ),
287
+ 'curl-missing-message' => __( 'We use PHP cURL library for the API calls, which is a very common library and usually installed out of the box. Unfortunately, cURL is not installed on your server.', 'freemius' ),
288
+ 'cloudflare-blocks-connection-message' => __( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'freemius' ),
289
+ 'x-requires-access-to-api' => _x( '%s requires an access to our API.', 'as pluginX requires an access to our API', 'freemius' ),
290
+ 'squid-blocks-connection-message' => __( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'freemius' ),
291
+ 'squid-no-clue-title' => __( 'I don\'t know what is Squid or ACL, help me!', 'freemius' ),
292
+ 'squid-no-clue-desc' => __( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'freemius' ),
293
+ 'sysadmin-title' => __( 'I\'m a system administrator', 'freemius' ),
294
+ 'squid-sysadmin-desc' => __( 'Great, please whitelist the following domains: %s. Once you done, deactivate the plugin and activate it again.', 'freemius' ),
295
+ 'curl-missing-no-clue-title' => __( 'I don\'t know what is cURL or how to install it, help me!', 'freemius' ),
296
+ 'curl-missing-no-clue-desc' => __( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.', 'freemius' ),
297
+ 'curl-missing-sysadmin-desc' => __( 'Great, please install cURL and enable it in your php.ini file. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the plugin and reactivate it back again.', 'freemius' ),
298
+ 'happy-to-resolve-issue-asap' => __( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'freemius' ),
299
+ 'fix-issue-title' => __( 'Yes - I\'m giving you a chance to fix it', 'freemius' ),
300
+ 'fix-issue-desc' => __( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'freemius' ),
301
+ 'install-previous-title' => __( 'Let\'s try your previous version', 'freemius' ),
302
+ 'install-previous-desc' => __( 'Uninstall this version and install the previous one.', 'freemius' ),
303
+ 'deactivate-plugin-title' => __( 'That\'s exhausting, please deactivate', 'freemius' ),
304
+ 'deactivate-plugin-desc' => __( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'freemius' ),
305
+ 'fix-request-sent-message' => __( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'freemius' ),
306
+ 'server-blocking-access' => _x( 'Your server is blocking the access to Freemius\' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s', '%1s - plugin title, %2s - API domain', 'freemius' ),
307
+ 'wrong-authentication-param-message' => __( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'freemius' ),
308
+ #endregion Connectivity Issues
309
+ #region Change Owner
310
+ 'change-owner-request-sent-x' => __( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.', 'freemius' ),
311
+ 'change-owner-request_owner-confirmed' => __( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'freemius' ),
312
+ 'change-owner-request_candidate-confirmed' => __( '%s is the new owner of the account.', 'freemius' ),
313
+ #endregion Change Owner
314
+ 'addon-x-cannot-run-without-y' => _x( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'freemius' ),
315
+ 'addon-x-cannot-run-without-parent' => _x( '%s cannot run without the plugin.', 'addonX cannot run...', 'freemius' ),
316
+ 'plugin-x-activation-message' => _x( '%s activation was successfully completed.', 'pluginX activation was successfully...', 'freemius' ),
317
+ 'features-and-pricing' => _x( 'Features & Pricing', 'Plugin installer section title', 'freemius' ),
318
+ 'free-addon-not-deployed' => __( 'Add-on must be deployed to WordPress.org or Freemius.', 'freemius' ),
319
+ 'paid-addon-not-deployed' => __( 'Paid add-on must be deployed to Freemius.', 'freemius' ),
320
+ #region Add-On Licensing
321
+ 'addon-no-license-message' => __( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.', 'freemius' ),
322
+ 'addon-trial-cancelled-message' => __( '%s free trial was successfully cancelled. Since the add-on is premium only it was automatically deactivated. If you like to use it in the future, you\'ll have to purchase a license.', 'freemius' ),
323
+ #endregion Add-On Licensing
324
+ );
freemius/includes/managers/class-fs-admin-menu-manager.php ADDED
@@ -0,0 +1,549 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Admin_Menu_Manager {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var string
19
+ */
20
+ protected $_plugin_slug;
21
+
22
+ /**
23
+ * @since 1.0.6
24
+ *
25
+ * @var string
26
+ */
27
+ private $_menu_slug;
28
+ /**
29
+ * @since 1.1.3
30
+ *
31
+ * @var string
32
+ */
33
+ private $_parent_slug;
34
+ /**
35
+ * @since 1.1.3
36
+ *
37
+ * @var string
38
+ */
39
+ private $_parent_type;
40
+ /**
41
+ * @since 1.1.3
42
+ *
43
+ * @var string
44
+ */
45
+ private $_type;
46
+ /**
47
+ * @since 1.1.3
48
+ *
49
+ * @var bool
50
+ */
51
+ private $_is_top_level;
52
+ /**
53
+ * @since 1.1.3
54
+ *
55
+ * @var bool
56
+ */
57
+ private $_is_override_exact;
58
+ /**
59
+ * @since 1.1.3
60
+ *
61
+ * @var string[]bool
62
+ */
63
+ private $_default_submenu_items;
64
+ /**
65
+ * @since 1.1.3
66
+ *
67
+ * @var string
68
+ */
69
+ private $_first_time_path;
70
+
71
+ #endregion Properties
72
+
73
+ /**
74
+ * @var FS_Logger
75
+ */
76
+ protected $_logger;
77
+
78
+ #region Singleton
79
+
80
+ /**
81
+ * @var FS_Admin_Menu_Manager[]
82
+ */
83
+ private static $_instances = array();
84
+
85
+ /**
86
+ * @param string $plugin_slug
87
+ *
88
+ * @return FS_Admin_Notice_Manager
89
+ */
90
+ static function instance( $plugin_slug ) {
91
+ if ( ! isset( self::$_instances[ $plugin_slug ] ) ) {
92
+ self::$_instances[ $plugin_slug ] = new FS_Admin_Menu_Manager( $plugin_slug );
93
+ }
94
+
95
+ return self::$_instances[ $plugin_slug ];
96
+ }
97
+
98
+ protected function __construct( $plugin_slug ) {
99
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $plugin_slug . '_admin_menu', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
100
+
101
+ $this->_plugin_slug = $plugin_slug;
102
+ }
103
+
104
+ #endregion Singleton
105
+
106
+ #region Helpers
107
+
108
+ private function get_option( &$options, $key, $default = false ) {
109
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
110
+ }
111
+
112
+ private function get_bool_option( &$options, $key, $default = false ) {
113
+ return isset( $options[ $key ] ) &&is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
114
+ }
115
+
116
+ #endregion Helpers
117
+
118
+ /**
119
+ * @param array $menu
120
+ * @param bool $is_addon
121
+ */
122
+ function init( $menu, $is_addon = false ) {
123
+ $this->_menu_slug = $menu['slug'];
124
+
125
+ $this->_default_submenu_items = array();
126
+ // @deprecated
127
+ $this->_type = 'page';
128
+ $this->_is_top_level = true;
129
+ $this->_is_override_exact = false;
130
+ $this->_parent_slug = false;
131
+ // @deprecated
132
+ $this->_parent_type = 'page';
133
+
134
+ if ( ! $is_addon && isset( $menu ) ) {
135
+ $this->_default_submenu_items = array(
136
+ 'contact' => $this->get_bool_option( $menu, 'contact', true ),
137
+ 'support' => $this->get_bool_option( $menu, 'support', true ),
138
+ 'account' => $this->get_bool_option( $menu, 'account', true ),
139
+ 'pricing' => $this->get_bool_option( $menu, 'pricing', true ),
140
+ 'addons' => $this->get_bool_option( $menu, 'addons', true ),
141
+ );
142
+
143
+ // @deprecated
144
+ $this->_type = $this->get_option( $menu, 'type', 'page' );
145
+ $this->_is_override_exact = $this->get_bool_option( $menu, 'override_exact' );
146
+
147
+ if ( isset( $menu['parent'] ) ) {
148
+ $this->_parent_slug = $this->get_option( $menu['parent'], 'slug' );
149
+ // @deprecated
150
+ $this->_parent_type = $this->get_option( $menu['parent'], 'type', 'page' );
151
+
152
+ // If parent's slug is different, then it's NOT a top level menu item.
153
+ $this->_is_top_level = ( $this->_parent_slug === $this->_menu_slug );
154
+ } else {
155
+ /**
156
+ * If no parent then top level if:
157
+ * - Has custom admin menu ('page')
158
+ * - CPT menu type ('cpt')
159
+ */
160
+ // $this->_is_top_level = in_array( $this->_type, array(
161
+ // 'cpt',
162
+ // 'page'
163
+ // ) );
164
+ }
165
+
166
+ $this->_first_time_path = $this->get_option( $menu, 'first-path', false );
167
+ if ( ! empty( $this->_first_time_path ) && is_string( $this->_first_time_path ) ) {
168
+ $this->_first_time_path = admin_url( $this->_first_time_path, 'admin' );
169
+ }
170
+ }
171
+ }
172
+
173
+ /**
174
+ * Check if top level menu.
175
+ *
176
+ * @author Vova Feldman (@svovaf)
177
+ * @since 1.1.3
178
+ *
179
+ * @return bool False if submenu item.
180
+ */
181
+ function is_top_level() {
182
+ return $this->_is_top_level;
183
+ }
184
+
185
+ /**
186
+ * Check if the page should be override on exact URL match.
187
+ *
188
+ * @author Vova Feldman (@svovaf)
189
+ * @since 1.1.3
190
+ *
191
+ * @return bool False if submenu item.
192
+ */
193
+ function is_override_exact() {
194
+ return $this->_is_override_exact;
195
+ }
196
+
197
+
198
+ /**
199
+ * Get the path of the page the user should be forwarded to after first activation.
200
+ *
201
+ * @author Vova Feldman (@svovaf)
202
+ * @since 1.1.3
203
+ *
204
+ * @return string
205
+ */
206
+ function get_first_time_path() {
207
+ return $this->_first_time_path;
208
+ }
209
+
210
+ /**
211
+ * Check if plugin's menu item is part of a custom top level menu.
212
+ *
213
+ * @author Vova Feldman (@svovaf)
214
+ * @since 1.1.3
215
+ *
216
+ * @return bool
217
+ */
218
+ function has_custom_parent() {
219
+ return ! $this->_is_top_level && is_string( $this->_parent_slug );
220
+ }
221
+
222
+ /**
223
+ * @author Vova Feldman (@svovaf)
224
+ * @since 1.1.3
225
+ *
226
+ * @return string
227
+ */
228
+ // function slug(){
229
+ // return $this->_menu_slug;
230
+ // }
231
+
232
+ /**
233
+ * @author Vova Feldman (@svovaf)
234
+ * @since 1.1.3
235
+ *
236
+ * @param string $id
237
+ * @param bool $default
238
+ *
239
+ * @return bool
240
+ */
241
+ function is_submenu_item_visible( $id, $default = true ) {
242
+ return fs_apply_filter(
243
+ $this->_plugin_slug,
244
+ 'is_submenu_visible',
245
+ $this->get_bool_option( $this->_default_submenu_items, $id, $default ),
246
+ $id
247
+ );
248
+ }
249
+
250
+ /**
251
+ * Calculates admin settings menu slug.
252
+ * If plugin's menu slug is a file (e.g. CPT), uses plugin's slug as the menu slug.
253
+ *
254
+ * @author Vova Feldman (@svovaf)
255
+ * @since 1.1.3
256
+ *
257
+ * @param string $page
258
+ *
259
+ * @return string
260
+ */
261
+ function get_slug( $page = '' ) {
262
+ return ( ( false === strpos( $this->_menu_slug, '.php?' ) ) ?
263
+ $this->_menu_slug :
264
+ $this->_plugin_slug ) . ( empty( $page ) ? '' : ( '-' . $page ) );
265
+ }
266
+
267
+ /**
268
+ * @author Vova Feldman (@svovaf)
269
+ * @since 1.1.3
270
+ *
271
+ * @return string
272
+ */
273
+ function get_parent_slug() {
274
+ return $this->_parent_slug;
275
+ }
276
+
277
+ /**
278
+ * @author Vova Feldman (@svovaf)
279
+ * @since 1.1.3
280
+ *
281
+ * @return string
282
+ */
283
+ function get_type() {
284
+ return $this->_type;
285
+ }
286
+
287
+ /**
288
+ * @author Vova Feldman (@svovaf)
289
+ * @since 1.1.3
290
+ *
291
+ * @return bool
292
+ */
293
+ function is_cpt() {
294
+ return ( 0 === strpos( $this->_menu_slug, 'edit.php?post_type=' ) ||
295
+ // Back compatibility.
296
+ 'cpt' === $this->_type
297
+ );
298
+ }
299
+
300
+ /**
301
+ * @author Vova Feldman (@svovaf)
302
+ * @since 1.1.3
303
+ *
304
+ * @return string
305
+ */
306
+ function get_parent_type() {
307
+ return $this->_parent_type;
308
+ }
309
+
310
+ /**
311
+ * @author Vova Feldman (@svovaf)
312
+ * @since 1.1.3
313
+ *
314
+ * @return string
315
+ */
316
+ function get_raw_slug() {
317
+ return $this->_menu_slug;
318
+ }
319
+
320
+ /**
321
+ * Get plugin's original menu slug.
322
+ *
323
+ * @author Vova Feldman (@svovaf)
324
+ * @since 1.1.3
325
+ *
326
+ * @return string
327
+ */
328
+ function get_original_menu_slug() {
329
+ if ( 'cpt' === $this->_type ) {
330
+ return add_query_arg( array(
331
+ 'post_type' => $this->_menu_slug
332
+ ), 'edit.php' );
333
+ }
334
+
335
+ if ( false === strpos( $this->_menu_slug, '.php?' ) ) {
336
+ return $this->_menu_slug;
337
+ } else {
338
+ return $this->_plugin_slug;
339
+ }
340
+ }
341
+
342
+ /**
343
+ * @author Vova Feldman (@svovaf)
344
+ * @since 1.1.3
345
+ *
346
+ * @return string
347
+ */
348
+ function get_top_level_menu_slug() {
349
+ return $this->has_custom_parent() ?
350
+ $this->get_parent_slug() :
351
+ $this->get_raw_slug();
352
+ }
353
+
354
+ /**
355
+ * Is user on plugin's admin activation page.
356
+ *
357
+ * @author Vova Feldman (@svovaf)
358
+ * @since 1.0.8
359
+ *
360
+ * @return bool
361
+ */
362
+ function is_activation_page() {
363
+ return isset( $_GET['page'] ) &&
364
+ ( ( strtolower( $this->_menu_slug ) === strtolower( $_GET['page'] ) ) ||
365
+ ( strtolower( $this->_plugin_slug ) === strtolower( $_GET['page'] ) ) );
366
+ }
367
+
368
+ #region Submenu Override
369
+
370
+ /**
371
+ * Override submenu's action.
372
+ *
373
+ * @author Vova Feldman (@svovaf)
374
+ * @since 1.1.0
375
+ *
376
+ * @param string $parent_slug
377
+ * @param string $menu_slug
378
+ * @param callable $function
379
+ *
380
+ * @return false|string If submenu exist, will return the hook name.
381
+ */
382
+ function override_submenu_action( $parent_slug, $menu_slug, $function ) {
383
+ global $submenu;
384
+
385
+ $menu_slug = plugin_basename( $menu_slug );
386
+ $parent_slug = plugin_basename( $parent_slug );
387
+
388
+ if ( ! isset( $submenu[ $parent_slug ] ) ) {
389
+ // Parent menu not exist.
390
+ return false;
391
+ }
392
+
393
+ $found_submenu_item = false;
394
+ foreach ( $submenu[ $parent_slug ] as $submenu_item ) {
395
+ if ( $menu_slug === $submenu_item[2] ) {
396
+ $found_submenu_item = $submenu_item;
397
+ break;
398
+ }
399
+ }
400
+
401
+ if ( false === $found_submenu_item ) {
402
+ // Submenu item not found.
403
+ return false;
404
+ }
405
+
406
+ // Remove current function.
407
+ $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
408
+ remove_all_actions( $hookname );
409
+
410
+ // Attach new action.
411
+ add_action( $hookname, $function );
412
+
413
+ return $hookname;
414
+ }
415
+
416
+ #endregion Submenu Override
417
+
418
+ #region Top level menu Override
419
+
420
+ /**
421
+ * Find plugin's admin dashboard main menu item.
422
+ *
423
+ * @author Vova Feldman (@svovaf)
424
+ * @since 1.0.2
425
+ *
426
+ * @return string[]|false
427
+ */
428
+ private function find_top_level_menu() {
429
+ global $menu;
430
+
431
+ $position = - 1;
432
+ $found_menu = false;
433
+
434
+ $menu_slug = $this->get_raw_slug();
435
+
436
+ $hook_name = get_plugin_page_hookname( $menu_slug, '' );
437
+ foreach ( $menu as $pos => $m ) {
438
+ if ( $menu_slug === $m[2] ) {
439
+ $position = $pos;
440
+ $found_menu = $m;
441
+ break;
442
+ }
443
+ }
444
+
445
+ if ( false === $found_menu ) {
446
+ return false;
447
+ }
448
+
449
+ return array(
450
+ 'menu' => $found_menu,
451
+ 'position' => $position,
452
+ 'hook_name' => $hook_name
453
+ );
454
+ }
455
+
456
+ /**
457
+ * Remove all sub-menu items.
458
+ *
459
+ * @author Vova Feldman (@svovaf)
460
+ * @since 1.0.7
461
+ *
462
+ * @return bool If submenu with plugin's menu slug was found.
463
+ */
464
+ private function remove_all_submenu_items() {
465
+ global $submenu;
466
+
467
+ $menu_slug = $this->get_raw_slug();
468
+
469
+ if ( ! isset( $submenu[ $menu_slug ] ) ) {
470
+ return false;
471
+ }
472
+
473
+ $submenu[ $menu_slug ] = array();
474
+
475
+ return true;
476
+ }
477
+
478
+ /**
479
+ *
480
+ * @author Vova Feldman (@svovaf)
481
+ * @since 1.0.9
482
+ *
483
+ * @return array[string]mixed
484
+ */
485
+ function remove_menu_item() {
486
+ $this->_logger->entrance();
487
+
488
+ // Find main menu item.
489
+ $menu = $this->find_top_level_menu();
490
+
491
+ if ( false === $menu ) {
492
+ return false;
493
+ }
494
+
495
+ // Remove it with its actions.
496
+ remove_all_actions( $menu['hook_name'] );
497
+
498
+ // Remove all submenu items.
499
+ $this->remove_all_submenu_items();
500
+
501
+ return $menu;
502
+ }
503
+
504
+ /**
505
+ *
506
+ * @author Vova Feldman (@svovaf)
507
+ * @since 1.1.4
508
+ *
509
+ * @param callable $function
510
+ *
511
+ * @return array[string]mixed
512
+ */
513
+ function override_menu_item( $function ) {
514
+ $found_menu = $this->remove_menu_item();
515
+
516
+ if ( false === $found_menu ) {
517
+ return false;
518
+ }
519
+
520
+ if ( ! $this->is_top_level() || ! $this->is_cpt() ) {
521
+ $menu_slug = plugin_basename( $this->get_slug() );
522
+
523
+ $hookname = get_plugin_page_hookname( $menu_slug, '' );
524
+
525
+ // Override menu action.
526
+ add_action( $hookname, $function );
527
+ } else {
528
+ global $menu;
529
+
530
+ // Create new top-level menu action.
531
+ $hookname = add_menu_page(
532
+ $found_menu['menu'][3],
533
+ $found_menu['menu'][0],
534
+ 'manage_options',
535
+ $this->get_slug(),
536
+ $function,
537
+ $found_menu['menu'][6],
538
+ $found_menu['position']
539
+ );
540
+
541
+ // Remove original CPT menu.
542
+ unset( $menu[ $found_menu['position'] ] );
543
+ }
544
+
545
+ return $hookname;
546
+ }
547
+
548
+ #endregion Top level menu Override
549
+ }
freemius/includes/managers/class-fs-admin-notice-manager.php ADDED
@@ -0,0 +1,303 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Admin_Notice_Manager {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_slug;
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_title;
22
+ /**
23
+ * @var array[]
24
+ */
25
+ private $_admin_messages = array();
26
+ /**
27
+ * @var FS_Key_Value_Storage
28
+ */
29
+ private $_sticky_storage;
30
+ /**
31
+ * @var FS_Plugin_Manager[]
32
+ */
33
+ private static $_instances = array();
34
+ /**
35
+ * @var FS_Logger
36
+ */
37
+ protected $_logger;
38
+
39
+ /**
40
+ * @param string $slug
41
+ * @param string $title
42
+ *
43
+ * @return FS_Admin_Notice_Manager
44
+ */
45
+ static function instance( $slug, $title = '' ) {
46
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
47
+ self::$_instances[ $slug ] = new FS_Admin_Notice_Manager( $slug, $title );
48
+ }
49
+
50
+ return self::$_instances[ $slug ];
51
+ }
52
+
53
+ protected function __construct( $slug, $title = '' ) {
54
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_data', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
55
+
56
+ $this->_slug = $slug;
57
+ $this->_title = ! empty( $title ) ? $title : '';
58
+ $this->_sticky_storage = FS_Key_Value_Storage::instance( 'admin_notices', $this->_slug );
59
+
60
+ if ( is_admin() ) {
61
+ if ( 0 < count( $this->_sticky_storage ) ) {
62
+ // If there are sticky notices for the current slug, add a callback
63
+ // to the AJAX action that handles message dismiss.
64
+ add_action( "wp_ajax_{$slug}_dismiss_notice_action", array(
65
+ &$this,
66
+ 'dismiss_notice_ajax_callback'
67
+ ) );
68
+
69
+ foreach ( $this->_sticky_storage as $id => $msg ) {
70
+ // Add admin notice.
71
+ $this->add(
72
+ $msg['message'],
73
+ $msg['title'],
74
+ $msg['type'],
75
+ true,
76
+ $msg['all'],
77
+ $msg['id'],
78
+ false
79
+ );
80
+ }
81
+ }
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Remove sticky message by ID.
87
+ *
88
+ * @author Vova Feldman (@svovaf)
89
+ * @since 1.0.7
90
+ *
91
+ */
92
+ function dismiss_notice_ajax_callback() {
93
+ $this->_sticky_storage->remove( $_POST['message_id'] );
94
+ wp_die();
95
+ }
96
+
97
+ /**
98
+ * Rendered sticky message dismiss JavaScript.
99
+ *
100
+ * @author Vova Feldman (@svovaf)
101
+ * @since 1.0.7
102
+ */
103
+ static function _add_sticky_dismiss_javascript() {
104
+ $params = array();
105
+ fs_require_once_template( 'sticky-admin-notice-js.php', $params );
106
+ }
107
+
108
+ private static $_added_sticky_javascript = false;
109
+
110
+ /**
111
+ * Hook to the admin_footer to add sticky message dismiss JavaScript handler.
112
+ *
113
+ * @author Vova Feldman (@svovaf)
114
+ * @since 1.0.7
115
+ */
116
+ private static function has_sticky_messages() {
117
+ if ( ! self::$_added_sticky_javascript ) {
118
+ add_action( 'admin_footer', array( 'FS_Admin_Notice_Manager', '_add_sticky_dismiss_javascript' ) );
119
+ }
120
+ }
121
+
122
+ /**
123
+ * Handle admin_notices by printing the admin messages stacked in the queue.
124
+ *
125
+ * @author Vova Feldman (@svovaf)
126
+ * @since 1.0.4
127
+ *
128
+ */
129
+ function _admin_notices_hook() {
130
+ $notice_type = 'admin_notices';
131
+
132
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
133
+ return;
134
+ }
135
+
136
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
137
+ fs_require_template( 'admin-notice.php', $msg );
138
+
139
+ if ( $msg['sticky'] ) {
140
+ self::has_sticky_messages();
141
+ }
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Handle all_admin_notices by printing the admin messages stacked in the queue.
147
+ *
148
+ * @author Vova Feldman (@svovaf)
149
+ * @since 1.0.4
150
+ *
151
+ */
152
+ function _all_admin_notices_hook() {
153
+ $notice_type = 'all_admin_notices';
154
+
155
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
156
+ return;
157
+ }
158
+
159
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
160
+ fs_require_template( 'all-admin-notice.php', $msg );
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Enqueue common stylesheet to style admin notice.
166
+ *
167
+ * @author Vova Feldman (@svovaf)
168
+ * @since 1.0.7
169
+ */
170
+ function _enqueue_styles() {
171
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
172
+ }
173
+
174
+ /**
175
+ * Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
176
+ *
177
+ * @author Vova Feldman (@svovaf)
178
+ * @since 1.0.4
179
+ *
180
+ * @param string $message
181
+ * @param string $title
182
+ * @param string $type
183
+ * @param bool $is_sticky
184
+ * @param bool $all_admin
185
+ * @param string $id Message ID
186
+ * @param bool $store_if_sticky
187
+ *
188
+ * @uses add_action()
189
+ */
190
+ function add( $message, $title = '', $type = 'success', $is_sticky = false, $all_admin = false, $id = '', $store_if_sticky = true ) {
191
+ $key = ( $all_admin ? 'all_admin_notices' : 'admin_notices' );
192
+
193
+ if ( ! isset( $this->_admin_messages[ $key ] ) ) {
194
+ $this->_admin_messages[ $key ] = array();
195
+
196
+ add_action( $key, array( &$this, "_{$key}_hook" ) );
197
+ add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_styles' ) );
198
+
199
+ }
200
+
201
+ if ( '' === $id ) {
202
+ $id = md5( $title . ' ' . $message . ' ' . $type );
203
+ }
204
+
205
+ $message_object = array(
206
+ 'message' => $message,
207
+ 'title' => $title,
208
+ 'type' => $type,
209
+ 'sticky' => $is_sticky,
210
+ 'id' => $id,
211
+ 'all' => $all_admin,
212
+ 'slug' => $this->_slug,
213
+ 'plugin' => $this->_title,
214
+ );
215
+
216
+ if ( $is_sticky && $store_if_sticky ) {
217
+ $this->_sticky_storage->{$id} = $message_object;
218
+ }
219
+
220
+ $this->_admin_messages[ $key ][ $id ] = $message_object;
221
+ }
222
+
223
+ /**
224
+ * @author Vova Feldman (@svovaf)
225
+ * @since 1.0.7
226
+ *
227
+ * @param string $ids
228
+ */
229
+ function remove_sticky( $ids ) {
230
+ if ( ! is_array( $ids ) ) {
231
+ $ids = array( $ids );
232
+ }
233
+
234
+ foreach ( $ids as $id ) {
235
+ // Remove from sticky storage.
236
+ $this->_sticky_storage->remove( $id );
237
+
238
+ // Remove from current admin messages.
239
+ if ( isset( $this->_admin_messages['all_admin_notices'] ) && isset( $this->_admin_messages['all_admin_notices'][ $id ] ) ) {
240
+ unset( $this->_admin_messages['all_admin_notices'][ $id ] );
241
+ }
242
+ if ( isset( $this->_admin_messages['admin_notices'] ) && isset( $this->_admin_messages['admin_notices'][ $id ] ) ) {
243
+ unset( $this->_admin_messages['admin_notices'][ $id ] );
244
+ }
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Check if sticky message exists by id.
250
+ *
251
+ * @author Vova Feldman (@svovaf)
252
+ * @since 1.0.9
253
+ *
254
+ * @param $id
255
+ *
256
+ * @return bool
257
+ */
258
+ function has_sticky( $id ) {
259
+ return isset( $this->_sticky_storage[ $id ] );
260
+ }
261
+
262
+ /**
263
+ * Adds sticky admin notification.
264
+ *
265
+ * @author Vova Feldman (@svovaf)
266
+ * @since 1.0.7
267
+ *
268
+ * @param string $message
269
+ * @param string $id Message ID
270
+ * @param string $title
271
+ * @param string $type
272
+ * @param bool $all_admin
273
+ */
274
+ function add_sticky( $message, $id, $title = '', $type = 'success', $all_admin = false ) {
275
+ $this->add( $message, $title, $type, true, $all_admin, $id );
276
+ }
277
+
278
+ /**
279
+ * Clear all sticky messages.
280
+ *
281
+ * @author Vova Feldman (@svovaf)
282
+ * @since 1.0.8
283
+ */
284
+ function clear_all_sticky() {
285
+ $this->_sticky_storage->clear_all();
286
+ }
287
+
288
+ /**
289
+ * Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
290
+ *
291
+ * @author Vova Feldman (@svovaf)
292
+ * @since 1.0.4
293
+ *
294
+ * @param string $message
295
+ * @param string $title
296
+ * @param string $type
297
+ * @param bool $is_sticky
298
+ * @param string $id Message ID
299
+ */
300
+ function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
301
+ $this->add( $message, $title, $type, $is_sticky, true, $id );
302
+ }
303
+ }
freemius/includes/managers/class-fs-cache-manager.php ADDED
@@ -0,0 +1,237 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Cache_Manager {
14
+ /**
15
+ * @var FS_Option_Manager
16
+ */
17
+ private $_options;
18
+ /**
19
+ * @var FS_Logger
20
+ */
21
+ private $_logger;
22
+
23
+ /**
24
+ * @var FS_Cache_Manager[]
25
+ */
26
+ private static $_MANAGERS = array();
27
+
28
+ /**
29
+ * @author Vova Feldman (@svovaf)
30
+ * @since 1.1.3
31
+ *
32
+ * @param string $id
33
+ */
34
+ private function __construct( $id ) {
35
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_cach_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
36
+
37
+ $this->_logger->entrance();
38
+ $this->_logger->log( 'id = ' . $id );
39
+
40
+ $this->_options = FS_Option_Manager::get_manager( $id, true );
41
+ }
42
+
43
+ /**
44
+ * @author Vova Feldman (@svovaf)
45
+ * @since 1.1.6
46
+ *
47
+ * @param $id
48
+ *
49
+ * @return FS_Cache_Manager
50
+ */
51
+ static function get_manager( $id ) {
52
+ $id = strtolower( $id );
53
+
54
+ if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
55
+ self::$_MANAGERS[ $id ] = new FS_Cache_Manager( $id );
56
+ }
57
+
58
+ return self::$_MANAGERS[ $id ];
59
+ }
60
+
61
+ /**
62
+ * @author Vova Feldman (@svovaf)
63
+ * @since 1.1.6
64
+ *
65
+ * @return bool
66
+ */
67
+ function is_empty() {
68
+ $this->_logger->entrance();
69
+
70
+ return $this->_options->is_empty();
71
+ }
72
+
73
+ /**
74
+ * @author Vova Feldman (@svovaf)
75
+ * @since 1.1.6
76
+ */
77
+ function clear() {
78
+ $this->_logger->entrance();
79
+
80
+ $this->_options->clear( true );
81
+ }
82
+
83
+ /**
84
+ * Delete cache manager from DB.
85
+ *
86
+ * @author Vova Feldman (@svovaf)
87
+ * @since 1.0.9
88
+ */
89
+ function delete() {
90
+ $this->_options->delete();
91
+ }
92
+
93
+ /**
94
+ * Check if there's a cached item.
95
+ *
96
+ * @author Vova Feldman (@svovaf)
97
+ * @since 1.1.6
98
+ *
99
+ * @param string $key
100
+ *
101
+ * @return bool
102
+ */
103
+ function has( $key ) {
104
+ $cache_entry = $this->_options->get_option( $key, false );
105
+
106
+ return ( is_object( $cache_entry ) &&
107
+ isset( $cache_entry->timestamp ) &&
108
+ is_numeric( $cache_entry->timestamp )
109
+ );
110
+ }
111
+
112
+ /**
113
+ * Check if there's a valid cached item.
114
+ *
115
+ * @author Vova Feldman (@svovaf)
116
+ * @since 1.1.6
117
+ *
118
+ * @param string $key
119
+ *
120
+ * @return bool
121
+ */
122
+ function has_valid( $key ) {
123
+ $cache_entry = $this->_options->get_option( $key, false );
124
+
125
+ return ( is_object( $cache_entry ) &&
126
+ isset( $cache_entry->timestamp ) &&
127
+ is_numeric( $cache_entry->timestamp ) &&
128
+ $cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
129
+ );
130
+ }
131
+
132
+ /**
133
+ * @author Vova Feldman (@svovaf)
134
+ * @since 1.1.6
135
+ *
136
+ * @param string $key
137
+ * @param mixed $default
138
+ *
139
+ * @return mixed
140
+ */
141
+ function get( $key, $default = null ) {
142
+ $this->_logger->entrance( 'key = ' . $key );
143
+
144
+ $cache_entry = $this->_options->get_option( $key, false );
145
+
146
+ if ( is_object( $cache_entry ) &&
147
+ isset( $cache_entry->timestamp ) &&
148
+ is_numeric( $cache_entry->timestamp )
149
+ ) {
150
+ return $cache_entry->result;
151
+ }
152
+
153
+ return $default;
154
+ }
155
+
156
+ /**
157
+ * @author Vova Feldman (@svovaf)
158
+ * @since 1.1.6
159
+ *
160
+ * @param string $key
161
+ * @param mixed $default
162
+ *
163
+ * @return mixed
164
+ */
165
+ function get_valid( $key, $default = null ) {
166
+ $this->_logger->entrance( 'key = ' . $key );
167
+
168
+ $cache_entry = $this->_options->get_option( $key, false );
169
+
170
+ if ( is_object( $cache_entry ) &&
171
+ isset( $cache_entry->timestamp ) &&
172
+ is_numeric( $cache_entry->timestamp ) &&
173
+ $cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
174
+ ) {
175
+ return $cache_entry->result;
176
+ }
177
+
178
+ return $default;
179
+ }
180
+
181
+ /**
182
+ * @author Vova Feldman (@svovaf)
183
+ * @since 1.1.6
184
+ *
185
+ * @param string $key
186
+ * @param mixed $value
187
+ * @param int $expiration
188
+ */
189
+ function set( $key, $value, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
190
+ $this->_logger->entrance( 'key = ' . $key );
191
+
192
+ $cache_entry = new stdClass();
193
+ $cache_entry->result = $value;
194
+ $cache_entry->timestamp = WP_FS__SCRIPT_START_TIME + $expiration;
195
+ $this->_options->set_option( $key, $cache_entry, true );
196
+ }
197
+
198
+ /**
199
+ * Get cached record expiration, or false if not cached or expired.
200
+ *
201
+ * @author Vova Feldman (@svovaf)
202
+ * @since 1.1.7.3
203
+ *
204
+ * @param string $key
205
+ *
206
+ * @return bool|int
207
+ */
208
+ function get_record_expiration( $key ) {
209
+ $this->_logger->entrance( 'key = ' . $key );
210
+
211
+ $cache_entry = $this->_options->get_option( $key, false );
212
+
213
+ if ( is_object( $cache_entry ) &&
214
+ isset( $cache_entry->timestamp ) &&
215
+ is_numeric( $cache_entry->timestamp ) &&
216
+ $cache_entry->timestamp > WP_FS__SCRIPT_START_TIME
217
+ ) {
218
+ return $cache_entry->timestamp;
219
+ }
220
+
221
+ return false;
222
+ }
223
+
224
+ /**
225
+ * Purge cached item.
226
+ *
227
+ * @author Vova Feldman (@svovaf)
228
+ * @since 1.1.6
229
+ *
230
+ * @param string $key
231
+ */
232
+ function purge( $key ) {
233
+ $this->_logger->entrance( 'key = ' . $key );
234
+
235
+ $this->_options->unset_option( $key, true );
236
+ }
237
+ }
freemius/includes/managers/class-fs-key-value-storage.php ADDED
@@ -0,0 +1,295 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Key_Value_Storage implements ArrayAccess, Iterator, Countable {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_id;
18
+ /**
19
+ * @var string
20
+ */
21
+ protected $_slug;
22
+ /**
23
+ * @var array
24
+ */
25
+ protected $_data;
26
+
27
+ /**
28
+ * @var FS_Plugin_Manager[]
29
+ */
30
+ private static $_instances = array();
31
+ /**
32
+ * @var FS_Logger
33
+ */
34
+ protected $_logger;
35
+
36
+ /**
37
+ * @param string $id
38
+ * @param string $slug
39
+ *
40
+ * @return FS_Key_Value_Storage
41
+ */
42
+ static function instance( $id, $slug ) {
43
+ $key = $id . ':' . $slug;
44
+ if ( ! isset( self::$_instances[ $key ] ) ) {
45
+ self::$_instances[ $key ] = new FS_Key_Value_Storage( $id, $slug );
46
+ }
47
+
48
+ return self::$_instances[ $key ];
49
+ }
50
+
51
+ protected function __construct( $id, $slug ) {
52
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
+
54
+ $this->_slug = $slug;
55
+ $this->_id = $id;
56
+ $this->load();
57
+ }
58
+
59
+ protected function get_option_manager() {
60
+ return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
61
+ }
62
+
63
+ protected function get_all_data() {
64
+ return $this->get_option_manager()->get_option( $this->_id, array() );
65
+ }
66
+
67
+ /**
68
+ * Load plugin data from local DB.
69
+ *
70
+ * @author Vova Feldman (@svovaf)
71
+ * @since 1.0.7
72
+ */
73
+ function load() {
74
+ $all_plugins_data = $this->get_all_data();
75
+ $this->_data = isset( $all_plugins_data[ $this->_slug ] ) ?
76
+ $all_plugins_data[ $this->_slug ] :
77
+ array();
78
+ }
79
+
80
+ /**
81
+ * @author Vova Feldman (@svovaf)
82
+ * @since 1.0.7
83
+ *
84
+ * @param string $key
85
+ * @param mixed $value
86
+ * @param bool $flush
87
+ */
88
+ function store( $key, $value, $flush = true ) {
89
+ if ( $this->_logger->is_on() ) {
90
+ $this->_logger->entrance( $key . ' = ' . var_export( $value, true ) );
91
+ }
92
+
93
+ if ( array_key_exists( $key, $this->_data ) && $value === $this->_data[ $key ] ) {
94
+ // No need to store data if the value wasn't changed.
95
+ return;
96
+ }
97
+
98
+ $all_data = $this->get_all_data();
99
+
100
+ $this->_data[ $key ] = $value;
101
+
102
+ $all_data[ $this->_slug ] = $this->_data;
103
+
104
+ $options_manager = $this->get_option_manager();
105
+ $options_manager->set_option( $this->_id, $all_data, $flush );
106
+ }
107
+
108
+ /**
109
+ * @author Vova Feldman (@svovaf)
110
+ * @since 1.0.7
111
+ *
112
+ * @param bool $store
113
+ * @param string[] $exceptions Set of keys to keep and not clear.
114
+ */
115
+ function clear_all( $store = true, $exceptions = array() ) {
116
+ $new_data = array();
117
+ foreach ( $exceptions as $key ) {
118
+ if ( isset( $this->_data[ $key ] ) ) {
119
+ $new_data[ $key ] = $this->_data[ $key ];
120
+ }
121
+ }
122
+
123
+ $this->_data = $new_data;
124
+
125
+ if ( $store ) {
126
+ $all_data = $this->get_all_data();
127
+ $all_data[ $this->_slug ] = $this->_data;
128
+ $options_manager = $this->get_option_manager();
129
+ $options_manager->set_option( $this->_id, $all_data, true );
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Delete key-value storage.
135
+ *
136
+ * @author Vova Feldman (@svovaf)
137
+ * @since 1.0.9
138
+ */
139
+ function delete() {
140
+ $this->_data = array();
141
+
142
+ $all_data = $this->get_all_data();
143
+ unset( $all_data[ $this->_slug ] );
144
+ $options_manager = $this->get_option_manager();
145
+ $options_manager->set_option( $this->_id, $all_data, true );
146
+ }
147
+
148
+ /**
149
+ * @author Vova Feldman (@svovaf)
150
+ * @since 1.0.7
151
+ *
152
+ * @param string $key
153
+ * @param bool $store
154
+ */
155
+ function remove( $key, $store = true ) {
156
+ if ( ! array_key_exists( $key, $this->_data ) ) {
157
+ return;
158
+ }
159
+
160
+ unset( $this->_data[ $key ] );
161
+
162
+ if ( $store ) {
163
+ $all_data = $this->get_all_data();
164
+ $all_data[ $this->_slug ] = $this->_data;
165
+ $options_manager = $this->get_option_manager();
166
+ $options_manager->set_option( $this->_id, $all_data, true );
167
+ }
168
+ }
169
+
170
+ /**
171
+ * @author Vova Feldman (@svovaf)
172
+ * @since 1.0.7
173
+ *
174
+ * @param string $key
175
+ * @param mixed $default
176
+ *
177
+ * @return bool|\FS_Plugin
178
+ */
179
+ function get( $key, $default = false ) {
180
+ return array_key_exists( $key, $this->_data ) ?
181
+ $this->_data[ $key ] :
182
+ $default;
183
+ }
184
+
185
+
186
+ /* ArrayAccess + Magic Access (better for refactoring)
187
+ -----------------------------------------------------------------------------------*/
188
+ function __set( $k, $v ) {
189
+ $this->store( $k, $v );
190
+ }
191
+
192
+ function __isset( $k ) {
193
+ return array_key_exists( $k, $this->_data );
194
+ }
195
+
196
+ function __unset( $k ) {
197
+ $this->remove( $k );
198
+ }
199
+
200
+ function __get( $k ) {
201
+ return $this->get( $k, null );
202
+ }
203
+
204
+ function offsetSet( $k, $v ) {
205
+ if ( is_null( $k ) ) {
206
+ throw new Exception( 'Can\'t append value to request params.' );
207
+ } else {
208
+ $this->{$k} = $v;
209
+ }
210
+ }
211
+
212
+ function offsetExists( $k ) {
213
+ return array_key_exists( $k, $this->_data );
214
+ }
215
+
216
+ function offsetUnset( $k ) {
217
+ unset( $this->$k );
218
+ }
219
+
220
+ function offsetGet( $k ) {
221
+ return $this->get( $k, null );
222
+ }
223
+
224
+ /**
225
+ * (PHP 5 &gt;= 5.0.0)<br/>
226
+ * Return the current element
227
+ *
228
+ * @link http://php.net/manual/en/iterator.current.php
229
+ * @return mixed Can return any type.
230
+ */
231
+ public function current() {
232
+ return current( $this->_data );
233
+ }
234
+
235
+ /**
236
+ * (PHP 5 &gt;= 5.0.0)<br/>
237
+ * Move forward to next element
238
+ *
239
+ * @link http://php.net/manual/en/iterator.next.php
240
+ * @return void Any returned value is ignored.
241
+ */
242
+ public function next() {
243
+ next( $this->_data );
244
+ }
245
+
246
+ /**
247
+ * (PHP 5 &gt;= 5.0.0)<br/>
248
+ * Return the key of the current element
249
+ *
250
+ * @link http://php.net/manual/en/iterator.key.php
251
+ * @return mixed scalar on success, or null on failure.
252
+ */
253
+ public function key() {
254
+ return key( $this->_data );
255
+ }
256
+
257
+ /**
258
+ * (PHP 5 &gt;= 5.0.0)<br/>
259
+ * Checks if current position is valid
260
+ *
261
+ * @link http://php.net/manual/en/iterator.valid.php
262
+ * @return boolean The return value will be casted to boolean and then evaluated.
263
+ * Returns true on success or false on failure.
264
+ */
265
+ public function valid() {
266
+ $key = key( $this->_data );
267
+
268
+ return ( $key !== null && $key !== false );
269
+ }
270
+
271
+ /**
272
+ * (PHP 5 &gt;= 5.0.0)<br/>
273
+ * Rewind the Iterator to the first element
274
+ *
275
+ * @link http://php.net/manual/en/iterator.rewind.php
276
+ * @return void Any returned value is ignored.
277
+ */
278
+ public function rewind() {
279
+ reset( $this->_data );
280
+ }
281
+
282
+ /**
283
+ * (PHP 5 &gt;= 5.1.0)<br/>
284
+ * Count elements of an object
285
+ *
286
+ * @link http://php.net/manual/en/countable.count.php
287
+ * @return int The custom count as an integer.
288
+ * </p>
289
+ * <p>
290
+ * The return value is cast to an integer.
291
+ */
292
+ public function count() {
293
+ return count( $this->_data );
294
+ }
295
+ }
freemius/includes/managers/class-fs-license-manager.php ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_License_Manager /*extends FS_Abstract_Manager*/
14
+ {
15
+ //
16
+ //
17
+ // /**
18
+ // * @var FS_License_Manager[]
19
+ // */
20
+ // private static $_instances = array();
21
+ //
22
+ // static function instance( Freemius $fs ) {
23
+ // $slug = strtolower( $fs->get_slug() );
24
+ //
25
+ // if ( ! isset( self::$_instances[ $slug ] ) ) {
26
+ // self::$_instances[ $slug ] = new FS_License_Manager( $slug, $fs );
27
+ // }
28
+ //
29
+ // return self::$_instances[ $slug ];
30
+ // }
31
+ //
32
+ //// private function __construct($slug) {
33
+ //// parent::__construct($slug);
34
+ //// }
35
+ //
36
+ // function entry_id() {
37
+ // return 'licenses';
38
+ // }
39
+ //
40
+ // function sync( $id ) {
41
+ //
42
+ // }
43
+ //
44
+ // /**
45
+ // * @author Vova Feldman (@svovaf)
46
+ // * @since 1.0.5
47
+ // * @uses FS_Api
48
+ // *
49
+ // * @param number|bool $plugin_id
50
+ // *
51
+ // * @return FS_Plugin_License[]|stdClass Licenses or API error.
52
+ // */
53
+ // function api_get_user_plugin_licenses( $plugin_id = false ) {
54
+ // $api = $this->_fs->get_api_user_scope();
55
+ //
56
+ // if ( ! is_numeric( $plugin_id ) ) {
57
+ // $plugin_id = $this->_fs->get_id();
58
+ // }
59
+ //
60
+ // $result = $api->call( "/plugins/{$plugin_id}/licenses.json" );
61
+ //
62
+ // if ( ! isset( $result->error ) ) {
63
+ // for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
64
+ // $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
65
+ // }
66
+ //
67
+ // $result = $result->licenses;
68
+ // }
69
+ //
70
+ // return $result;
71
+ // }
72
+ //
73
+ // function api_get_many() {
74
+ //
75
+ // }
76
+ //
77
+ // function api_activate( $id ) {
78
+ //
79
+ // }
80
+ //
81
+ // function api_deactivate( $id ) {
82
+ //
83
+ // }
84
+
85
+ /**
86
+ * @param FS_Plugin_License[] $licenses
87
+ *
88
+ * @return bool
89
+ */
90
+ static function has_premium_license( $licenses ) {
91
+ if ( is_array( $licenses ) ) {
92
+ foreach ( $licenses as $license ) {
93
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
94
+ return true;
95
+ }
96
+ }
97
+ }
98
+
99
+ return false;
100
+ }
101
+ }
freemius/includes/managers/class-fs-option-manager.php ADDED
@@ -0,0 +1,297 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * 3-layer lazy options manager.
15
+ * layer 3: Memory
16
+ * layer 2: Cache (if there's any caching plugin and if WP_FS__DEBUG_SDK is FALSE)
17
+ * layer 1: Database (options table). All options stored as one option record in the DB to reduce number of DB
18
+ * queries.
19
+ *
20
+ * If load() is not explicitly called, starts as empty manager. Same thing about saving the data - you have to
21
+ * explicitly call store().
22
+ *
23
+ * Class Freemius_Option_Manager
24
+ */
25
+ class FS_Option_Manager {
26
+ /**
27
+ * @var string
28
+ */
29
+ private $_id;
30
+ /**
31
+ * @var array
32
+ */
33
+ private $_options;
34
+ /**
35
+ * @var FS_Logger
36
+ */
37
+ private $_logger;
38
+
39
+ /**
40
+ * @var FS_Option_Manager[]
41
+ */
42
+ private static $_MANAGERS = array();
43
+
44
+ /**
45
+ * @author Vova Feldman (@svovaf)
46
+ * @since 1.0.3
47
+ *
48
+ * @param string $id
49
+ * @param bool $load
50
+ */
51
+ private function __construct( $id, $load = false ) {
52
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_opt_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
+
54
+ $this->_logger->entrance();
55
+ $this->_logger->log( 'id = ' . $id );
56
+
57
+ $this->_id = $id;
58
+
59
+ if ( $load ) {
60
+ $this->load();
61
+ }
62
+ }
63
+
64
+ /**
65
+ * @author Vova Feldman (@svovaf)
66
+ * @since 1.0.3
67
+ *
68
+ * @param $id
69
+ * @param $load
70
+ *
71
+ * @return FS_Option_Manager
72
+ */
73
+ static function get_manager( $id, $load = false ) {
74
+ $id = strtolower( $id );
75
+
76
+ if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
77
+ self::$_MANAGERS[ $id ] = new FS_Option_Manager( $id, $load );
78
+ } // If load required but not yet loaded, load.
79
+ else if ( $load && ! self::$_MANAGERS[ $id ]->is_loaded() ) {
80
+ self::$_MANAGERS[ $id ]->load();
81
+ }
82
+
83
+ return self::$_MANAGERS[ $id ];
84
+ }
85
+
86
+ private function _get_option_manager_name() {
87
+ // return WP_FS__SLUG . '_' . $this->_id;
88
+ return $this->_id;
89
+ }
90
+
91
+ /**
92
+ * @author Vova Feldman (@svovaf)
93
+ * @since 1.0.3
94
+ *
95
+ * @param bool $flush
96
+ */
97
+ function load( $flush = false ) {
98
+ $this->_logger->entrance();
99
+
100
+ $option_name = $this->_get_option_manager_name();
101
+
102
+ if ( $flush || ! isset( $this->_options ) ) {
103
+ if ( ! WP_FS__DEBUG_SDK ) {
104
+ $this->_options = wp_cache_get( $option_name, WP_FS__SLUG );
105
+ }
106
+
107
+ // $this->_logger->info('wp_cache_get = ' . var_export($this->_options, true));
108
+
109
+ // if ( is_array( $this->_options ) ) {
110
+ // $this->clear();
111
+ // }
112
+
113
+ $cached = true;
114
+
115
+ if ( empty( $this->_options ) ) {
116
+ $this->_options = get_option( $option_name );
117
+
118
+ if ( is_string( $this->_options ) ) {
119
+ $this->_options = json_decode( $this->_options );
120
+ }
121
+
122
+ // $this->_logger->info('get_option = ' . var_export($this->_options, true));
123
+
124
+ if ( false === $this->_options ) {
125
+ $this->clear();
126
+ }
127
+
128
+ $cached = false;
129
+ }
130
+
131
+ if ( ! WP_FS__DEBUG_SDK && ! $cached ) // Set non encoded cache.
132
+ {
133
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
134
+ }
135
+ }
136
+ }
137
+
138
+ /**
139
+ * @author Vova Feldman (@svovaf)
140
+ * @since 1.0.3
141
+ *
142
+ * @return bool
143
+ */
144
+ function is_loaded() {
145
+ return isset( $this->_options );
146
+ }
147
+
148
+ /**
149
+ * @author Vova Feldman (@svovaf)
150
+ * @since 1.0.3
151
+ *
152
+ * @return bool
153
+ */
154
+ function is_empty() {
155
+ return ( $this->is_loaded() && false === $this->_options );
156
+ }
157
+
158
+ /**
159
+ * @author Vova Feldman (@svovaf)
160
+ * @since 1.0.6
161
+ *
162
+ * @param bool $flush
163
+ */
164
+ function clear( $flush = false ) {
165
+ $this->_logger->entrance();
166
+
167
+ $this->_options = array();
168
+
169
+ if ( $flush ) {
170
+ $this->store();
171
+ }
172
+ }
173
+
174
+ /**
175
+ * Delete options manager from DB.
176
+ *
177
+ * @author Vova Feldman (@svovaf)
178
+ * @since 1.0.9
179
+ */
180
+ function delete() {
181
+ delete_option( $this->_get_option_manager_name() );
182
+ }
183
+
184
+ /**
185
+ * @author Vova Feldman (@svovaf)
186
+ * @since 1.0.6
187
+ *
188
+ * @param string $option
189
+ *
190
+ * @return bool
191
+ */
192
+ function has_option( $option ) {
193
+ return array_key_exists( $option, $this->_options );
194
+ }
195
+
196
+ /**
197
+ * @author Vova Feldman (@svovaf)
198
+ * @since 1.0.3
199
+ *
200
+ * @param string $option
201
+ * @param mixed $default
202
+ *
203
+ * @return mixed
204
+ */
205
+ function get_option( $option, $default = null ) {
206
+ $this->_logger->entrance( 'option = ' . $option );
207
+
208
+ if ( is_array( $this->_options ) ) {
209
+ return isset( $this->_options[ $option ] ) ? $this->_options[ $option ] : $default;
210
+ } else if ( is_object( $this->_options ) ) {
211
+ return isset( $this->_options->{$option} ) ? $this->_options->{$option} : $default;
212
+ }
213
+
214
+ return $default;
215
+ }
216
+
217
+ /**
218
+ * @author Vova Feldman (@svovaf)
219
+ * @since 1.0.3
220
+ *
221
+ * @param string $option
222
+ * @param mixed $value
223
+ * @param bool $flush
224
+ */
225
+ function set_option( $option, $value, $flush = false ) {
226
+ $this->_logger->entrance( 'option = ' . $option );
227
+
228
+ if ( ! $this->is_loaded() ) {
229
+ $this->clear();
230
+ }
231
+
232
+ if ( is_array( $this->_options ) ) {
233
+ $this->_options[ $option ] = $value;
234
+ } else if ( is_object( $this->_options ) ) {
235
+ $this->_options->{$option} = $value;
236
+ }
237
+
238
+ if ( $flush ) {
239
+ $this->store();
240
+ }
241
+ }
242
+
243
+ /**
244
+ * Unset option.
245
+ *
246
+ * @author Vova Feldman (@svovaf)
247
+ * @since 1.0.3
248
+ *
249
+ * @param string $option
250
+ * @param bool $flush
251
+ */
252
+ function unset_option( $option, $flush = false ) {
253
+ $this->_logger->entrance( 'option = ' . $option );
254
+
255
+ if ( is_array( $this->_options ) ) {
256
+ if ( ! isset( $this->_options[ $option ] ) ) {
257
+ return;
258
+ }
259
+
260
+ unset( $this->_options[ $option ] );
261
+
262
+ } else if ( is_object( $this->_options ) ) {
263
+ if ( ! isset( $this->_options->{$option} ) ) {
264
+ return;
265
+ }
266
+
267
+ unset( $this->_options->{$option} );
268
+ }
269
+
270
+ if ( $flush ) {
271
+ $this->store();
272
+ }
273
+ }
274
+
275
+ /**
276
+ * Dump options to database.
277
+ *
278
+ * @author Vova Feldman (@svovaf)
279
+ * @since 1.0.3
280
+ */
281
+ function store() {
282
+ $this->_logger->entrance();
283
+
284
+ $option_name = $this->_get_option_manager_name();
285
+
286
+ if ( $this->_logger->is_on() ) {
287
+ $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) );
288
+ }
289
+
290
+ // Update DB.
291
+ update_option( $option_name, $this->_options );
292
+
293
+ if ( ! WP_FS__DEBUG_SDK ) {
294
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
295
+ }
296
+ }
297
+ }
freemius/includes/managers/class-fs-plan-manager.php ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plan_Manager {
14
+ /**
15
+ * @var FS_Plan_Manager
16
+ */
17
+ private static $_instance;
18
+
19
+ /**
20
+ * @return FS_Plan_Manager
21
+ */
22
+ static function instance() {
23
+ if ( ! isset( self::$_instance ) ) {
24
+ self::$_instance = new FS_Plan_Manager();
25
+ }
26
+
27
+ return self::$_instance;
28
+ }
29
+
30
+ private function __construct() {
31
+ }
32
+
33
+ /**
34
+ * @param FS_Plugin_License[] $licenses
35
+ *
36
+ * @return bool
37
+ */
38
+ function has_premium_license( $licenses ) {
39
+ if ( is_array( $licenses ) ) {
40
+ /**
41
+ * @var FS_Plugin_License[] $licenses
42
+ */
43
+ foreach ( $licenses as $license ) {
44
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
45
+ return true;
46
+ }
47
+ }
48
+ }
49
+
50
+ return false;
51
+ }
52
+
53
+ /**
54
+ * Check if plugin has any paid plans.
55
+ *
56
+ * @author Vova Feldman (@svovaf)
57
+ * @since 1.0.7
58
+ *
59
+ * @param FS_Plugin_Plan[] $plans
60
+ *
61
+ * @return bool
62
+ */
63
+ function has_paid_plan( $plans ) {
64
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
65
+ return false;
66
+ }
67
+
68
+ /**
69
+ * @var FS_Plugin_Plan[] $plans
70
+ */
71
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
72
+ if ( ! $plans[ $i ]->is_free() ) {
73
+ return true;
74
+ }
75
+ }
76
+
77
+ return false;
78
+ }
79
+
80
+ /**
81
+ * Check if plugin has any free plan, or is it premium only.
82
+ *
83
+ * Note: If no plans configured, assume plugin is free.
84
+ *
85
+ * @author Vova Feldman (@svovaf)
86
+ * @since 1.0.7
87
+ *
88
+ * @param FS_Plugin_Plan[] $plans
89
+ *
90
+ * @return bool
91
+ */
92
+ function has_free_plan( $plans ) {
93
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
94
+ return true;
95
+ }
96
+
97
+ /**
98
+ * @var FS_Plugin_Plan[] $plans
99
+ */
100
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
101
+ if ( $plans[ $i ]->is_free() ) {
102
+ return true;
103
+ }
104
+ }
105
+
106
+ return false;
107
+ }
108
+
109
+ /**
110
+ * Find all plans that have trial.
111
+ *
112
+ * @author Vova Feldman (@svovaf)
113
+ * @since 1.0.9
114
+ *
115
+ * @param FS_Plugin_Plan[] $plans
116
+ *
117
+ * @return FS_Plugin_Plan[]
118
+ */
119
+ function get_trial_plans( $plans ) {
120
+ $trial_plans = array();
121
+
122
+ if ( is_array( $plans ) && 0 < count( $plans ) ) {
123
+ /**
124
+ * @var FS_Plugin_Plan[] $plans
125
+ */
126
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
127
+ if ( $plans[ $i ]->has_trial() ) {
128
+ $trial_plans[] = $plans[ $i ];
129
+ }
130
+ }
131
+ }
132
+
133
+ return $trial_plans;
134
+ }
135
+
136
+ /**
137
+ * Check if plugin has any trial plan.
138
+ *
139
+ * @author Vova Feldman (@svovaf)
140
+ * @since 1.0.9
141
+ *
142
+ * @param FS_Plugin_Plan[] $plans
143
+ *
144
+ * @return bool
145
+ */
146
+ function has_trial_plan( $plans ) {
147
+ if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
148
+ return true;
149
+ }
150
+
151
+ /**
152
+ * @var FS_Plugin_Plan[] $plans
153
+ */
154
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
155
+ if ( $plans[ $i ]->has_trial() ) {
156
+ return true;
157
+ }
158
+ }
159
+
160
+ return false;
161
+ }
162
+ }
freemius/includes/managers/class-fs-plugin-manager.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ class FS_Plugin_Manager {
14
+ /**
15
+ * @var string
16
+ */
17
+ protected $_slug;
18
+ /**
19
+ * @var FS_Plugin
20
+ */
21
+ protected $_plugin;
22
+
23
+ /**
24
+ * @var FS_Plugin_Manager[]
25
+ */
26
+ private static $_instances = array();
27
+ /**
28
+ * @var FS_Logger
29
+ */
30
+ protected $_logger;
31
+
32
+ /**
33
+ * @param string $slug
34
+ *
35
+ * @return FS_Plugin_Manager
36
+ */
37
+ static function instance( $slug ) {
38
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
39
+ self::$_instances[ $slug ] = new FS_Plugin_Manager( $slug );
40
+ }
41
+
42
+ return self::$_instances[ $slug ];
43
+ }
44
+
45
+ protected function __construct( $slug ) {
46
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . 'plugins', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
47
+
48
+ $this->_slug = $slug;
49
+ $this->load();
50
+ }
51
+
52
+ protected function get_option_manager() {
53
+ return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
54
+ }
55
+
56
+ protected function get_all_plugins() {
57
+ return $this->get_option_manager()->get_option( 'plugins', array() );
58
+ }
59
+
60
+ /**
61
+ * Load plugin data from local DB.
62
+ *
63
+ * @author Vova Feldman (@svovaf)
64
+ * @since 1.0.6
65
+ */
66
+ function load() {
67
+ $all_plugins = $this->get_all_plugins();
68
+ $this->_plugin = isset( $all_plugins[ $this->_slug ] ) ?
69
+ $all_plugins[ $this->_slug ] :
70
+ null;
71
+ }
72
+
73
+ /**
74
+ * Store plugin on local DB.
75
+ *
76
+ * @author Vova Feldman (@svovaf)
77
+ * @since 1.0.6
78
+ *
79
+ * @param bool|FS_Plugin $plugin
80
+ * @param bool $flush
81
+ *
82
+ * @return bool|\FS_Plugin
83
+ */
84
+ function store( $plugin = false, $flush = true ) {
85
+ $all_plugins = $this->get_all_plugins();
86
+
87
+ if ( false !== $plugin ) {
88
+ $this->_plugin = $plugin;
89
+ }
90
+
91
+ $all_plugins[ $this->_slug ] = $this->_plugin;
92
+
93
+ $options_manager = $this->get_option_manager();
94
+ $options_manager->set_option( 'plugins', $all_plugins, $flush );
95
+
96
+ return $this->_plugin;
97
+ }
98
+
99
+ /**
100
+ * Update local plugin data if different.
101
+ *
102
+ * @author Vova Feldman (@svovaf)
103
+ * @since 1.0.6
104
+ *
105
+ * @param \FS_Plugin $plugin
106
+ * @param bool $store
107
+ *
108
+ * @return bool True if plugin was updated.
109
+ */
110
+ function update( FS_Plugin $plugin, $store = true ) {
111
+ if ( ! ( $this->_plugin instanceof FS_Plugin ) ||
112
+ $this->_plugin->slug != $plugin->slug ||
113
+ $this->_plugin->public_key != $plugin->public_key ||
114
+ $this->_plugin->secret_key != $plugin->secret_key ||
115
+ $this->_plugin->parent_plugin_id != $plugin->parent_plugin_id ||
116
+ $this->_plugin->title != $plugin->title
117
+ ) {
118
+ $this->store( $plugin, $store );
119
+
120
+ return true;
121
+ }
122
+
123
+ return false;
124
+ }
125
+
126
+ /**
127
+ * @author Vova Feldman (@svovaf)
128
+ * @since 1.0.6
129
+ *
130
+ * @param FS_Plugin $plugin
131
+ * @param bool $store
132
+ */
133
+ function set( FS_Plugin $plugin, $store = false ) {
134
+ $this->_plugin = $plugin;
135
+
136
+ if ( $store ) {
137
+ $this->store();
138
+ }
139
+ }
140
+
141
+ /**
142
+ * @author Vova Feldman (@svovaf)
143
+ * @since 1.0.6
144
+ *
145
+ * @return bool|\FS_Plugin
146
+ */
147
+ function get() {
148
+ return isset( $this->_plugin ) ?
149
+ $this->_plugin :
150
+ false;
151
+ }
152
+
153
+
154
+ }
freemius/includes/sdk/Exceptions/ArgumentNotExistException.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class Freemius_ArgumentNotExistException extends Freemius_InvalidArgumentException { }
freemius/includes/sdk/Exceptions/EmptyArgumentException.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class Freemius_EmptyArgumentException extends Freemius_InvalidArgumentException { }
freemius/includes/sdk/Exceptions/Exception.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Thrown when an API call returns an exception.
4
+ *
5
+ */
6
+ class Freemius_Exception extends Exception
7
+ {
8
+ protected $_result;
9
+ protected $_type;
10
+ protected $_code;
11
+
12
+ /**
13
+ * Make a new API Exception with the given result.
14
+ *
15
+ * @param array $result The result from the API server.
16
+ */
17
+ public function __construct($result)
18
+ {
19
+ $this->_result = $result;
20
+
21
+ $code = 0;
22
+ $message = 'Unknown error, please check GetResult().';
23
+ $type = '';
24
+
25
+ if (isset($result['error']) && is_array($result['error']))
26
+ {
27
+ if (isset($result['error']['code']))
28
+ $code = $result['error']['code'];
29
+ if (isset($result['error']['message']))
30
+ $message = $result['error']['message'];
31
+ if (isset($result['error']['type']))
32
+ $type = $result['error']['type'];
33
+ }
34
+
35
+ $this->_type = $type;
36
+ $this->_code = $code;
37
+
38
+ parent::__construct($message, is_numeric($code) ? $code : 0);
39
+ }
40
+
41
+ /**
42
+ * Return the associated result object returned by the API server.
43
+ *
44
+ * @return array The result from the API server
45
+ */
46
+ public function getResult()
47
+ {
48
+ return $this->_result;
49
+ }
50
+
51
+ public function getStringCode()
52
+ {
53
+ return $this->_code;
54
+ }
55
+
56
+ public function getType()
57
+ {
58
+ return $this->_type;
59
+ }
60
+
61
+ /**
62
+ * To make debugging easier.
63
+ *
64
+ * @return string The string representation of the error
65
+ */
66
+ public function __toString()
67
+ {
68
+ $str = $this->getType() . ': ';
69
+
70
+ if ($this->code != 0)
71
+ $str .= $this->getStringCode() . ': ';
72
+
73
+ return $str . $this->getMessage();
74
+ }
75
+ }
freemius/includes/sdk/Exceptions/InvalidArgumentException.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_Exception' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class Freemius_InvalidArgumentException extends Freemius_Exception { }
freemius/includes/sdk/Exceptions/OAuthException.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_Exception' ) ) {
3
+ exit;
4
+ }
5
+
6
+ class Freemius_OAuthException extends Freemius_Exception
7
+ {
8
+ public function __construct($pResult)
9
+ {
10
+ parent::__construct($pResult);
11
+ }
12
+ }
freemius/includes/sdk/Freemius.php ADDED
@@ -0,0 +1,574 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2014 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ require_once( dirname( __FILE__ ) . '/FreemiusBase.php' );
19
+
20
+ define( 'FS_SDK__USER_AGENT', 'fs-php-' . Freemius_Api_Base::VERSION );
21
+
22
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_CURL' ) ) {
23
+ define( 'FS_SDK__SIMULATE_NO_CURL', false );
24
+ }
25
+
26
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
27
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
28
+ }
29
+
30
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
31
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
32
+ }
33
+
34
+ define( 'FS_SDK__HAS_CURL', ! FS_SDK__SIMULATE_NO_CURL && function_exists( 'curl_version' ) );
35
+
36
+ if ( ! FS_SDK__HAS_CURL ) {
37
+ $curl_version = array( 'version' => '7.0.0' );
38
+ } else {
39
+ $curl_version = curl_version();
40
+ }
41
+
42
+ define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
43
+
44
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
45
+ define( 'FS_API__LOGGER_ON', false );
46
+ }
47
+
48
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
49
+ define( 'FS_API__ADDRESS', '://api.freemius.com' );
50
+ }
51
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
52
+ define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
53
+ }
54
+
55
+ class Freemius_Api extends Freemius_Api_Base {
56
+ private static $_logger = array();
57
+
58
+ /**
59
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
60
+ * @param number $pID Element's id.
61
+ * @param string $pPublic Public key.
62
+ * @param string|bool $pSecret Element's secret key.
63
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
64
+ */
65
+ public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
66
+ // If secret key not provided, use public key encryption.
67
+ if ( is_bool( $pSecret ) ) {
68
+ $pSecret = $pPublic;
69
+ }
70
+
71
+ parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
72
+ }
73
+
74
+ public static function GetUrl( $pCanonizedPath = '', $pIsSandbox = false ) {
75
+ $address = ( $pIsSandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS );
76
+
77
+ if ( ':' === $address[0] ) {
78
+ $address = self::$_protocol . $address;
79
+ }
80
+
81
+ return $address . $pCanonizedPath;
82
+ }
83
+
84
+ #region Servers Clock Diff ------------------------------------------------------
85
+
86
+ /**
87
+ * @var int Clock diff in seconds between current server to API server.
88
+ */
89
+ private static $_clock_diff = 0;
90
+
91
+ /**
92
+ * Set clock diff for all API calls.
93
+ *
94
+ * @since 1.0.3
95
+ *
96
+ * @param $pSeconds
97
+ */
98
+ public static function SetClockDiff( $pSeconds ) {
99
+ self::$_clock_diff = $pSeconds;
100
+ }
101
+
102
+ /**
103
+ * Find clock diff between current server to API server.
104
+ *
105
+ * @since 1.0.2
106
+ * @return int Clock diff in seconds.
107
+ */
108
+ public static function FindClockDiff() {
109
+ $time = time();
110
+ $pong = self::Ping();
111
+
112
+ return ( $time - strtotime( $pong->timestamp ) );
113
+ }
114
+
115
+ #endregion Servers Clock Diff ------------------------------------------------------
116
+
117
+ /**
118
+ * @var string http or https
119
+ */
120
+ private static $_protocol = FS_API__PROTOCOL;
121
+
122
+ /**
123
+ * Set API connection protocol.
124
+ *
125
+ * @since 1.0.4
126
+ */
127
+ public static function SetHttp() {
128
+ self::$_protocol = 'http';
129
+ }
130
+
131
+ /**
132
+ * @since 1.0.4
133
+ *
134
+ * @return bool
135
+ */
136
+ public static function IsHttps() {
137
+ return ( 'https' === self::$_protocol );
138
+ }
139
+
140
+ /**
141
+ * Sign request with the following HTTP headers:
142
+ * Content-MD5: MD5(HTTP Request body)
143
+ * Date: Current date (i.e Sat, 14 Feb 2015 20:24:46 +0000)
144
+ * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
145
+ * {scope_entity_secret_key}))
146
+ *
147
+ * @param string $pResourceUrl
148
+ * @param array $pCurlOptions
149
+ *
150
+ * @return array
151
+ */
152
+ function SignRequest( $pResourceUrl, $pCurlOptions ) {
153
+ $eol = "\n";
154
+ $content_md5 = '';
155
+ $now = ( time() - self::$_clock_diff );
156
+ $date = date( 'r', $now );
157
+ $content_type = '';
158
+
159
+ if ( isset( $pCurlOptions[ CURLOPT_POST ] ) && 0 < $pCurlOptions[ CURLOPT_POST ] ) {
160
+ $content_md5 = md5( $pCurlOptions[ CURLOPT_POSTFIELDS ] );
161
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Content-MD5: ' . $content_md5;
162
+ $content_type = 'application/json';
163
+ }
164
+
165
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Date: ' . $date;
166
+
167
+ $string_to_sign = implode( $eol, array(
168
+ $pCurlOptions[ CURLOPT_CUSTOMREQUEST ],
169
+ $content_md5,
170
+ $content_type,
171
+ $date,
172
+ $pResourceUrl
173
+ ) );
174
+
175
+ // If secret and public keys are identical, it means that
176
+ // the signature uses public key hash encoding.
177
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
178
+
179
+ // Add authorization header.
180
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Authorization: ' .
181
+ $auth_type . ' ' .
182
+ $this->_id . ':' .
183
+ $this->_public . ':' .
184
+ self::Base64UrlEncode(
185
+ hash_hmac( 'sha256', $string_to_sign, $this->_secret )
186
+ );
187
+
188
+ return $pCurlOptions;
189
+ }
190
+
191
+ /**
192
+ * Get API request URL signed via query string.
193
+ *
194
+ * @param string $pPath
195
+ *
196
+ * @throws Freemius_Exception
197
+ *
198
+ * @return string
199
+ */
200
+ function GetSignedUrl( $pPath ) {
201
+ $resource = explode( '?', $this->CanonizePath( $pPath ) );
202
+ $pResourceUrl = $resource[0];
203
+
204
+ $eol = "\n";
205
+ $content_md5 = '';
206
+ $content_type = '';
207
+ $now = ( time() - self::$_clock_diff );
208
+ $date = date( 'r', $now );
209
+
210
+ $string_to_sign = implode( $eol, array(
211
+ 'GET',
212
+ $content_md5,
213
+ $content_type,
214
+ $date,
215
+ $pResourceUrl
216
+ ) );
217
+
218
+ // If secret and public keys are identical, it means that
219
+ // the signature uses public key hash encoding.
220
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
221
+
222
+ return Freemius_Api::GetUrl(
223
+ $pResourceUrl . '?' .
224
+ ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) .
225
+ http_build_query( array(
226
+ 'auth_date' => $date,
227
+ 'authorization' => $auth_type . ' ' . $this->_id . ':' .
228
+ $this->_public . ':' .
229
+ self::Base64UrlEncode( hash_hmac(
230
+ 'sha256', $string_to_sign, $this->_secret
231
+ ) )
232
+ ) ), $this->_isSandbox );
233
+ }
234
+
235
+ /**
236
+ * @param resource $pCurlHandler
237
+ * @param array $pCurlOptions
238
+ *
239
+ * @return mixed
240
+ */
241
+ private static function ExecuteRequest( &$pCurlHandler, &$pCurlOptions ) {
242
+ $start = microtime( true );
243
+
244
+ $result = curl_exec( $pCurlHandler );
245
+
246
+ if ( FS_API__LOGGER_ON ) {
247
+ $end = microtime( true );
248
+
249
+ $has_body = ( isset( $pCurlOptions[ CURLOPT_POST ] ) && 0 < $pCurlOptions[ CURLOPT_POST ] );
250
+
251
+ self::$_logger[] = array(
252
+ 'id' => count( self::$_logger ),
253
+ 'start' => $start,
254
+ 'end' => $end,
255
+ 'total' => ( $end - $start ),
256
+ 'method' => $pCurlOptions[ CURLOPT_CUSTOMREQUEST ],
257
+ 'path' => $pCurlOptions[ CURLOPT_URL ],
258
+ 'body' => $has_body ? $pCurlOptions[ CURLOPT_POSTFIELDS ] : null,
259
+ 'result' => $result,
260
+ 'code' => curl_getinfo( $pCurlHandler, CURLINFO_HTTP_CODE ),
261
+ 'backtrace' => debug_backtrace(),
262
+ );
263
+ }
264
+
265
+ return $result;
266
+ }
267
+
268
+ /**
269
+ * @return array
270
+ */
271
+ static function GetLogger() {
272
+ return self::$_logger;
273
+ }
274
+
275
+ /**
276
+ * @param string $pCanonizedPath
277
+ * @param string $pMethod
278
+ * @param array $pParams
279
+ * @param null|resource $pCurlHandler
280
+ * @param bool $pIsSandbox
281
+ * @param null|callable $pBeforeExecutionFunction
282
+ *
283
+ * @return object[]|object|null
284
+ *
285
+ * @throws \Freemius_Exception
286
+ */
287
+ private static function MakeStaticRequest(
288
+ $pCanonizedPath,
289
+ $pMethod = 'GET',
290
+ $pParams = array(),
291
+ $pCurlHandler = null,
292
+ $pIsSandbox = false,
293
+ $pBeforeExecutionFunction = null
294
+ ) {
295
+ if ( ! FS_SDK__HAS_CURL ) {
296
+ self::ThrowNoCurlException();
297
+ }
298
+
299
+ // Connectivity errors simulation.
300
+ if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
301
+ self::ThrowCloudFlareDDoSException();
302
+ } else if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
303
+ self::ThrowSquidAclException();
304
+ }
305
+
306
+ if ( ! $pCurlHandler ) {
307
+ $pCurlHandler = curl_init();
308
+ }
309
+
310
+ $opts = array(
311
+ CURLOPT_CONNECTTIMEOUT => 10,
312
+ CURLOPT_RETURNTRANSFER => true,
313
+ CURLOPT_TIMEOUT => 60,
314
+ CURLOPT_USERAGENT => FS_SDK__USER_AGENT,
315
+ );
316
+
317
+ if ( ! isset( $opts[ CURLOPT_HTTPHEADER ] ) || ! is_array( $opts[ CURLOPT_HTTPHEADER ] ) ) {
318
+ $opts[ CURLOPT_HTTPHEADER ] = array();
319
+ }
320
+
321
+ if ( 'POST' === $pMethod || 'PUT' === $pMethod ) {
322
+ if ( is_array( $pParams ) && 0 < count( $pParams ) ) {
323
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Content-Type: application/json';
324
+ $opts[ CURLOPT_POST ] = count( $pParams );
325
+ $opts[ CURLOPT_POSTFIELDS ] = json_encode( $pParams );
326
+ }
327
+
328
+ $opts[ CURLOPT_RETURNTRANSFER ] = true;
329
+ }
330
+
331
+ $opts[ CURLOPT_URL ] = Freemius_Api::GetUrl( $pCanonizedPath, $pIsSandbox );
332
+ $opts[ CURLOPT_CUSTOMREQUEST ] = $pMethod;
333
+
334
+ $resource = explode( '?', $pCanonizedPath );
335
+
336
+ // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
337
+ // for 2 seconds if the server does not support this header.
338
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Expect:';
339
+
340
+ if ( 'https' === substr( strtolower( $pCanonizedPath ), 0, 5 ) ) {
341
+ $opts[ CURLOPT_SSL_VERIFYHOST ] = false;
342
+ $opts[ CURLOPT_SSL_VERIFYPEER ] = false;
343
+ }
344
+
345
+ if ( false !== $pBeforeExecutionFunction &&
346
+ is_callable( $pBeforeExecutionFunction )
347
+ ) {
348
+ $opts = call_user_func( $pBeforeExecutionFunction, $resource[0], $opts );
349
+ }
350
+
351
+ curl_setopt_array( $pCurlHandler, $opts );
352
+ $result = self::ExecuteRequest( $pCurlHandler, $opts );
353
+
354
+ /*if (curl_errno($ch) == 60) // CURLE_SSL_CACERT
355
+ {
356
+ self::errorLog('Invalid or no certificate authority found, using bundled information');
357
+ curl_setopt($ch, CURLOPT_CAINFO,
358
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
359
+ $result = curl_exec($ch);
360
+ }*/
361
+
362
+ // With dual stacked DNS responses, it's possible for a server to
363
+ // have IPv6 enabled but not have IPv6 connectivity. If this is
364
+ // the case, curl will try IPv4 first and if that fails, then it will
365
+ // fall back to IPv6 and the error EHOSTUNREACH is returned by the
366
+ // operating system.
367
+ if ( false === $result && empty( $opts[ CURLOPT_IPRESOLVE ] ) ) {
368
+ $matches = array();
369
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
370
+ if ( preg_match( $regex, curl_error( $pCurlHandler ), $matches ) ) {
371
+ if ( strlen( @inet_pton( $matches[1] ) ) === 16 ) {
372
+ // self::errorLog('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
373
+ $opts[ CURLOPT_IPRESOLVE ] = CURL_IPRESOLVE_V4;
374
+ curl_setopt( $pCurlHandler, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
375
+ $result = self::ExecuteRequest( $pCurlHandler, $opts );
376
+ }
377
+ }
378
+ }
379
+
380
+ if ( $result === false ) {
381
+ self::ThrowCurlException( $pCurlHandler );
382
+ }
383
+
384
+ curl_close( $pCurlHandler );
385
+
386
+ if ( empty( $result ) ) {
387
+ return null;
388
+ }
389
+
390
+ $decoded = json_decode( $result );
391
+
392
+ if ( is_null( $decoded ) ) {
393
+ if ( preg_match( '/Please turn JavaScript on/i', $result ) &&
394
+ preg_match( '/text\/javascript/', $result )
395
+ ) {
396
+ self::ThrowCloudFlareDDoSException( $result );
397
+ } else if ( preg_match( '/Access control configuration prevents your request from being allowed at this time. Please contact your service provider if you feel this is incorrect./', $result ) &&
398
+ preg_match( '/squid/', $result )
399
+ ) {
400
+ self::ThrowSquidAclException( $result );
401
+ } else {
402
+ $decoded = (object) array(
403
+ 'error' => (object) array(
404
+ 'type' => 'Unknown',
405
+ 'message' => $result,
406
+ 'code' => 'unknown',
407
+ 'http' => 402
408
+ )
409
+ );
410
+ }
411
+ }
412
+
413
+ return $decoded;
414
+ }
415
+
416
+
417
+ /**
418
+ * Makes an HTTP request. This method can be overridden by subclasses if
419
+ * developers want to do fancier things or use something other than curl to
420
+ * make the request.
421
+ *
422
+ * @param string $pCanonizedPath The URL to make the request to
423
+ * @param string $pMethod HTTP method
424
+ * @param array $pParams The parameters to use for the POST body
425
+ * @param null|resource $pCurlHandler Initialized curl handle
426
+ *
427
+ * @return object[]|object|null
428
+ *
429
+ * @throws Freemius_Exception
430
+ */
431
+ public function MakeRequest(
432
+ $pCanonizedPath,
433
+ $pMethod = 'GET',
434
+ $pParams = array(),
435
+ $pCurlHandler = null
436
+ ) {
437
+ $resource = explode( '?', $pCanonizedPath );
438
+
439
+ // Only sign request if not ping.json connectivity test.
440
+ $sign_request = ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) );
441
+
442
+ return self::MakeStaticRequest(
443
+ $pCanonizedPath,
444
+ $pMethod,
445
+ $pParams,
446
+ $pCurlHandler,
447
+ $this->_isSandbox,
448
+ $sign_request ? array( &$this, 'SignRequest' ) : null
449
+ );
450
+ }
451
+
452
+ #region Connectivity Test ------------------------------------------------------
453
+
454
+ /**
455
+ * If successful connectivity to the API endpoint using ping.json endpoint.
456
+ *
457
+ * - OR -
458
+ *
459
+ * Validate if ping result object is valid.
460
+ *
461
+ * @param mixed $pPong
462
+ *
463
+ * @return bool
464
+ */
465
+ public static function Test( $pPong = null ) {
466
+ $pong = is_null( $pPong ) ?
467
+ self::Ping() :
468
+ $pPong;
469
+
470
+ return (
471
+ is_object( $pong ) &&
472
+ isset( $pong->api ) &&
473
+ 'pong' === $pong->api
474
+ );
475
+ }
476
+
477
+ /**
478
+ * Ping API to test connectivity.
479
+ *
480
+ * @return object
481
+ */
482
+ public static function Ping() {
483
+ try {
484
+ $result = self::MakeStaticRequest( '/v' . FS_API__VERSION . '/ping.json' );
485
+ } catch ( Freemius_Exception $e ) {
486
+ // Map to error object.
487
+ $result = (object) $e->getResult();
488
+ } catch ( Exception $e ) {
489
+ // Map to error object.
490
+ $result = (object) array(
491
+ 'error' => array(
492
+ 'type' => 'Unknown',
493
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
494
+ 'code' => 'unknown',
495
+ 'http' => 402
496
+ )
497
+ );
498
+ }
499
+
500
+ return $result;
501
+ }
502
+
503
+ #endregion Connectivity Test ------------------------------------------------------
504
+
505
+ #region Connectivity Exceptions ------------------------------------------------------
506
+
507
+ /**
508
+ * @param resource $pCurlHandler
509
+ *
510
+ * @throws Freemius_Exception
511
+ */
512
+ private static function ThrowCurlException( $pCurlHandler ) {
513
+ $e = new Freemius_Exception( array(
514
+ 'error' => array(
515
+ 'code' => curl_errno( $pCurlHandler ),
516
+ 'message' => curl_error( $pCurlHandler ),
517
+ 'type' => 'CurlException',
518
+ ),
519
+ ) );
520
+
521
+ curl_close( $pCurlHandler );
522
+ throw $e;
523
+ }
524
+
525
+ /**
526
+ * @param string $pResult
527
+ *
528
+ * @throws Freemius_Exception
529
+ */
530
+ private static function ThrowNoCurlException( $pResult = '' ) {
531
+ throw new Freemius_Exception( array(
532
+ 'error' => (object) array(
533
+ 'type' => 'cUrlMissing',
534
+ 'message' => $pResult,
535
+ 'code' => 'curl_missing',
536
+ 'http' => 402
537
+ )
538
+ ) );
539
+ }
540
+
541
+ /**
542
+ * @param string $pResult
543
+ *
544
+ * @throws Freemius_Exception
545
+ */
546
+ private static function ThrowCloudFlareDDoSException( $pResult = '' ) {
547
+ throw new Freemius_Exception( array(
548
+ 'error' => (object) array(
549
+ 'type' => 'CloudFlareDDoSProtection',
550
+ 'message' => $pResult,
551
+ 'code' => 'cloudflare_ddos_protection',
552
+ 'http' => 402
553
+ )
554
+ ) );
555
+ }
556
+
557
+ /**
558
+ * @param string $pResult
559
+ *
560
+ * @throws Freemius_Exception
561
+ */
562
+ private static function ThrowSquidAclException( $pResult = '' ) {
563
+ throw new Freemius_Exception( array(
564
+ 'error' => (object) array(
565
+ 'type' => 'SquidCacheBlock',
566
+ 'message' => $pResult,
567
+ 'code' => 'squid_cache_block',
568
+ 'http' => 402
569
+ )
570
+ ) );
571
+ }
572
+
573
+ #endregion Connectivity Exceptions ------------------------------------------------------
574
+ }
freemius/includes/sdk/FreemiusBase.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Copyright 2014 Freemius, Inc.
4
+ *
5
+ * Licensed under the GPL v2 (the "License"); you may
6
+ * not use this file except in compliance with the License. You may obtain
7
+ * a copy of the License at
8
+ *
9
+ * http://choosealicense.com/licenses/gpl-v2/
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
+ * License for the specific language governing permissions and limitations
15
+ * under the License.
16
+ */
17
+
18
+ define( 'FS_API__VERSION', '1' );
19
+ define( 'FS_SDK__PATH', dirname( __FILE__ ) );
20
+ define( 'FS_SDK__EXCEPTIONS_PATH', FS_SDK__PATH . '/Exceptions/' );
21
+
22
+ if ( ! function_exists( 'json_decode' ) ) {
23
+ throw new Exception( 'Freemius needs the JSON PHP extension.' );
24
+ }
25
+
26
+ // Include all exception files.
27
+ $exceptions = array(
28
+ 'Exception',
29
+ 'InvalidArgumentException',
30
+ 'ArgumentNotExistException',
31
+ 'EmptyArgumentException',
32
+ 'OAuthException'
33
+ );
34
+
35
+ foreach ( $exceptions as $e ) {
36
+ require FS_SDK__EXCEPTIONS_PATH . $e . '.php';
37
+ }
38
+
39
+ abstract class Freemius_Api_Base {
40
+ const VERSION = '1.0.4';
41
+ const FORMAT = 'json';
42
+
43
+ protected $_id;
44
+ protected $_public;
45
+ protected $_secret;
46
+ protected $_scope;
47
+ protected $_isSandbox;
48
+
49
+ /**
50
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
51
+ * @param number $pID Element's id.
52
+ * @param string $pPublic Public key.
53
+ * @param string $pSecret Element's secret key.
54
+ * @param bool $pIsSandbox Whether or not to run API in sandbox mode.
55
+ */
56
+ public function Init( $pScope, $pID, $pPublic, $pSecret, $pIsSandbox = false ) {
57
+ $this->_id = $pID;
58
+ $this->_public = $pPublic;
59
+ $this->_secret = $pSecret;
60
+ $this->_scope = $pScope;
61
+ $this->_isSandbox = $pIsSandbox;
62
+ }
63
+
64
+ public function IsSandbox() {
65
+ return $this->_isSandbox;
66
+ }
67
+
68
+ function CanonizePath( $pPath ) {
69
+ $pPath = trim( $pPath, '/' );
70
+ $query_pos = strpos( $pPath, '?' );
71
+ $query = '';
72
+
73
+ if ( false !== $query_pos ) {
74
+ $query = substr( $pPath, $query_pos );
75
+ $pPath = substr( $pPath, 0, $query_pos );
76
+ }
77
+
78
+ // Trim '.json' suffix.
79
+ $format_length = strlen( '.' . self::FORMAT );
80
+ $start = $format_length * ( - 1 ); //negative
81
+ if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
82
+ $pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
83
+ }
84
+
85
+ switch ( $this->_scope ) {
86
+ case 'app':
87
+ $base = '/apps/' . $this->_id;
88
+ break;
89
+ case 'developer':
90
+ $base = '/developers/' . $this->_id;
91
+ break;
92
+ case 'user':
93
+ $base = '/users/' . $this->_id;
94
+ break;
95
+ case 'plugin':
96
+ $base = '/plugins/' . $this->_id;
97
+ break;
98
+ case 'install':
99
+ $base = '/installs/' . $this->_id;
100
+ break;
101
+ default:
102
+ throw new Freemius_Exception( 'Scope not implemented.' );
103
+ }
104
+
105
+ return '/v' . FS_API__VERSION . $base .
106
+ ( ! empty( $pPath ) ? '/' : '' ) . $pPath .
107
+ ( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
108
+ }
109
+
110
+ abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array() );
111
+
112
+ /**
113
+ * @param string $pPath
114
+ * @param string $pMethod
115
+ * @param array $pParams
116
+ *
117
+ * @return object[]|object|null
118
+ */
119
+ private function _Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
120
+ $pMethod = strtoupper( $pMethod );
121
+
122
+ try {
123
+ $result = $this->MakeRequest( $pPath, $pMethod, $pParams );
124
+ } catch ( Freemius_Exception $e ) {
125
+ // Map to error object.
126
+ $result = (object) $e->getResult();
127
+ } catch ( Exception $e ) {
128
+ // Map to error object.
129
+ $result = (object) array(
130
+ 'error' => array(
131
+ 'type' => 'Unknown',
132
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
133
+ 'code' => 'unknown',
134
+ 'http' => 402
135
+ )
136
+ );
137
+ }
138
+
139
+ return $result;
140
+ }
141
+
142
+ public function Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
143
+ return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams );
144
+ }
145
+
146
+ /**
147
+ * Base64 encoding that does not need to be urlencode()ed.
148
+ * Exactly the same as base64_encode except it uses
149
+ * - instead of +
150
+ * _ instead of /
151
+ * No padded =
152
+ *
153
+ * @param string $input base64UrlEncoded string
154
+ *
155
+ * @return string
156
+ */
157
+ protected static function Base64UrlDecode( $input ) {
158
+ return base64_decode( strtr( $input, '-_', '+/' ) );
159
+ }
160
+
161
+ /**
162
+ * Base64 encoding that does not need to be urlencode()ed.
163
+ * Exactly the same as base64_encode except it uses
164
+ * - instead of +
165
+ * _ instead of /
166
+ *
167
+ * @param string $input string
168
+ *
169
+ * @return string base64Url encoded string
170
+ */
171
+ protected static function Base64UrlEncode( $input ) {
172
+ $str = strtr( base64_encode( $input ), '+/', '-_' );
173
+ $str = str_replace( '=', '', $str );
174
+
175
+ return $str;
176
+ }
177
+
178
+ }
freemius/includes/sdk/LICENSE.txt ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
freemius/includes/supplements/fs-essential-functions-1.1.7.1.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Find the plugin main file path based on any give file inside the plugin's folder.
15
+ *
16
+ * @author Vova Feldman (@svovaf)
17
+ * @since 1.1.7.1
18
+ *
19
+ * @param string $file Absolute path to a file inside a plugin's folder.
20
+ *
21
+ * @return string
22
+ */
23
+ function fs_find_direct_caller_plugin_file( $file ) {
24
+ /**
25
+ * All the code below will be executed once on activation.
26
+ * If the user changes the main plugin's file name, the file_exists()
27
+ * will catch it.
28
+ */
29
+ if ( ! function_exists( 'get_plugins' ) ) {
30
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
31
+ }
32
+
33
+ $all_plugins = get_plugins();
34
+
35
+ $file_real_path = fs_normalize_path( realpath( $file ) );
36
+
37
+ // Get active plugin's main files real full names (might be symlinks).
38
+ foreach ( $all_plugins as $relative_path => &$data ) {
39
+ if ( 0 === strpos( $file_real_path, fs_normalize_path( dirname( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) ) ) ) ) {
40
+ return $relative_path;
41
+ }
42
+ }
43
+
44
+ return null;
45
+ }
freemius/start.php ADDED
@@ -0,0 +1,335 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $this_sdk_version = '1.1.7.5';
14
+
15
+ #region SDK Selection Logic --------------------------------------------------------------------
16
+
17
+ /**
18
+ * Special logic added on 1.1.6 to make sure that every Freemius powered plugin
19
+ * will ALWAYS be loaded with the newest SDK from the active Freemius powered plugins.
20
+ *
21
+ * Since Freemius SDK is backward compatible, this will make sure that all Freemius powered
22
+ * plugins will run correctly.
23
+ *
24
+ * @since 1.1.6
25
+ */
26
+
27
+ global $fs_active_plugins;
28
+
29
+ $this_sdk_relative_path = plugin_basename( dirname( __FILE__ ) );
30
+
31
+ if ( ! isset( $fs_active_plugins ) ) {
32
+ // Require SDK essentials.
33
+ require_once dirname( __FILE__ ) . '/includes/fs-essential-functions.php';
34
+
35
+ // Load all Freemius powered active plugins.
36
+ $fs_active_plugins = get_option( 'fs_active_plugins', new stdClass() );
37
+
38
+ if ( ! isset( $fs_active_plugins->plugins ) ) {
39
+ $fs_active_plugins->plugins = array();
40
+ }
41
+ }
42
+
43
+ if ( ! function_exists( 'fs_find_direct_caller_plugin_file' ) ) {
44
+ require_once dirname( __FILE__ ) . '/includes/supplements/fs-essential-functions-1.1.7.1.php';
45
+ }
46
+
47
+ // Update current SDK info based on the SDK path.
48
+ if ( ! isset( $fs_active_plugins->plugins[ $this_sdk_relative_path ] ) ||
49
+ $this_sdk_version != $fs_active_plugins->plugins[ $this_sdk_relative_path ]->version
50
+ ) {
51
+ $fs_active_plugins->plugins[ $this_sdk_relative_path ] = (object) array(
52
+ 'version' => $this_sdk_version,
53
+ 'timestamp' => time(),
54
+ 'plugin_path' => plugin_basename( fs_find_direct_caller_plugin_file( __FILE__ ) ),
55
+ );
56
+ }
57
+
58
+ $is_current_sdk_newest = isset( $fs_active_plugins->newest ) && ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path );
59
+
60
+ if ( ! isset( $fs_active_plugins->newest ) ) {
61
+ /**
62
+ * This will be executed only once, for the first time a Freemius powered plugin is activated.
63
+ */
64
+ fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
65
+
66
+ $is_current_sdk_newest = true;
67
+ } else if ( version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '<' ) ) {
68
+ /**
69
+ * Current SDK is newer than the newest stored SDK.
70
+ */
71
+ fs_update_sdk_newest_version( $this_sdk_relative_path, $fs_active_plugins->plugins[ $this_sdk_relative_path ]->plugin_path );
72
+
73
+ if ( class_exists( 'Freemius' ) ) {
74
+ // Older SDK version was already loaded.
75
+
76
+ if ( ! $fs_active_plugins->newest->in_activation ) {
77
+ // Re-order plugins to load this plugin first.
78
+ fs_newest_sdk_plugin_first();
79
+ }
80
+
81
+ // Refresh page.
82
+ if ( fs_redirect( $_SERVER['REQUEST_URI'] ) ) {
83
+ exit();
84
+ }
85
+ }
86
+ } else {
87
+ if ( ! function_exists( 'get_plugins' ) ) {
88
+ require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
89
+ }
90
+
91
+ $is_newest_sdk_plugin_activate = is_plugin_active( $fs_active_plugins->newest->plugin_path );
92
+
93
+ if ( $is_current_sdk_newest &&
94
+ ! $is_newest_sdk_plugin_activate &&
95
+ ! $fs_active_plugins->newest->in_activation
96
+ ) {
97
+ // If current SDK is the newest and the plugin is NOT active, it means
98
+ // that the current plugin in activation mode.
99
+ $fs_active_plugins->newest->in_activation = true;
100
+ update_option( 'fs_active_plugins', $fs_active_plugins );
101
+ }
102
+
103
+ $is_newest_sdk_path_valid = ( $is_newest_sdk_plugin_activate || $fs_active_plugins->newest->in_activation ) && file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this_sdk_relative_path . '/start.php' ) );
104
+
105
+ if ( ! $is_newest_sdk_path_valid && ! $is_current_sdk_newest ) {
106
+ // Plugin with newest SDK is no longer active, or SDK was moved to a different location.
107
+ unset( $fs_active_plugins->plugins[ $fs_active_plugins->newest->sdk_path ] );
108
+ }
109
+
110
+ if ( ! ( $is_newest_sdk_plugin_activate || $fs_active_plugins->newest->in_activation ) ||
111
+ ! $is_newest_sdk_path_valid ||
112
+ // Is newest SDK downgraded.
113
+ ( $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
114
+ version_compare( $fs_active_plugins->newest->version, $this_sdk_version, '>' ) )
115
+ ) {
116
+ /**
117
+ * Plugin with newest SDK is no longer active.
118
+ * OR
119
+ * The newest SDK was in the current plugin. BUT, seems like the version of
120
+ * the SDK was downgraded to a lower SDK.
121
+ */
122
+ // Find the active plugin with the newest SDK version and update the newest reference.
123
+ fs_fallback_to_newest_active_sdk();
124
+ } else {
125
+ if ( $is_newest_sdk_plugin_activate &&
126
+ $this_sdk_relative_path == $fs_active_plugins->newest->sdk_path &&
127
+ ( $fs_active_plugins->newest->in_activation ||
128
+ ( class_exists( 'Freemius' ) && ( ! defined( 'WP_FS__SDK_VERSION' ) || version_compare( WP_FS__SDK_VERSION, $this_sdk_version, '<' ) ) )
129
+ )
130
+
131
+ ) {
132
+ if ( $fs_active_plugins->newest->in_activation ) {
133
+ // Plugin no more in activation.
134
+ $fs_active_plugins->newest->in_activation = false;
135
+ update_option( 'fs_active_plugins', $fs_active_plugins );
136
+ }
137
+
138
+ // Reorder plugins to load plugin with newest SDK first.
139
+ if ( fs_newest_sdk_plugin_first() ) {
140
+ // Refresh page after re-order to make sure activated plugin loads newest SDK.
141
+ if ( class_exists( 'Freemius' ) ) {
142
+ if ( fs_redirect( $_SERVER['REQUEST_URI'] ) ) {
143
+ exit();
144
+ }
145
+ }
146
+ }
147
+ }
148
+ }
149
+ }
150
+
151
+ if ( class_exists( 'Freemius' ) ) {
152
+ // SDK was already loaded.
153
+ return;
154
+ }
155
+
156
+ if ( version_compare( $this_sdk_version, $fs_active_plugins->newest->version, '<' ) ) {
157
+ $newest_sdk_starter = fs_normalize_path( WP_PLUGIN_DIR . '/' . $fs_active_plugins->newest->sdk_path . '/start.php' );
158
+
159
+ if ( file_exists( $newest_sdk_starter ) ) {
160
+ // Reorder plugins to load plugin with newest SDK first.
161
+ fs_newest_sdk_plugin_first();
162
+
163
+ // There's a newer SDK version, load it instead of the current one!
164
+ require_once $newest_sdk_starter;
165
+
166
+ return;
167
+ }
168
+ }
169
+
170
+ #endregion SDK Selection Logic --------------------------------------------------------------------
171
+
172
+ #region Hooks & Filters Collection --------------------------------------------------------------------
173
+
174
+ /**
175
+ * Freemius hooks (actions & filters) tags structure:
176
+ *
177
+ * fs_{filter/action_name}_{plugin_slug}
178
+ *
179
+ * --------------------------------------------------------
180
+ *
181
+ * Usage with WordPress' add_action() / add_filter():
182
+ *
183
+ * add_action('fs_{filter/action_name}_{plugin_slug}', $callable);
184
+ *
185
+ * --------------------------------------------------------
186
+ *
187
+ * Usage with Freemius' instance add_action() / add_filter():
188
+ *
189
+ * // No need to add 'fs_' prefix nor '_{plugin_slug}' suffix.
190
+ * my_freemius()->add_action('{action_name}', $callable);
191
+ *
192
+ * --------------------------------------------------------
193
+ *
194
+ * Freemius filters collection:
195
+ *
196
+ * fs_connect_url_{plugin_slug}
197
+ * fs_trial_promotion_message_{plugin_slug}
198
+ * fs_is_long_term_user_{plugin_slug}
199
+ * fs_uninstall_reasons_{plugin_slug}
200
+ * fs_is_plugin_update_{plugin_slug}
201
+ * fs_api_domains_{plugin_slug}
202
+ * fs_email_template_sections_{plugin_slug}
203
+ * fs_support_forum_submenu_{plugin_slug}
204
+ * fs_support_forum_url_{plugin_slug}
205
+ * fs_connect_message_{plugin_slug}
206
+ * fs_connect_message_on_update_{plugin_slug}
207
+ * fs_uninstall_confirmation_message_{plugin_slug}
208
+ * fs_pending_activation_message_{plugin_slug}
209
+ * fs_is_submenu_visible_{plugin_slug}
210
+ * fs_plugin_icon_{plugin_slug}
211
+ *
212
+ * --------------------------------------------------------
213
+ *
214
+ * Freemius actions collection:
215
+ *
216
+ * fs_after_license_loaded_{plugin_slug}
217
+ * fs_after_license_change_{plugin_slug}
218
+ * fs_after_plans_sync_{plugin_slug}
219
+ *
220
+ * fs_after_account_details_{plugin_slug}
221
+ * fs_after_account_user_sync_{plugin_slug}
222
+ * fs_after_account_plan_sync_{plugin_slug}
223
+ * fs_before_account_load_{plugin_slug}
224
+ * fs_after_account_connection_{plugin_slug}
225
+ * fs_account_property_edit_{plugin_slug}
226
+ * fs_account_email_verified_{plugin_slug}
227
+ * fs_account_page_load_before_departure_{plugin_slug}
228
+ * fs_before_account_delete_{plugin_slug}
229
+ * fs_after_account_delete_{plugin_slug}
230
+ *
231
+ * fs_sdk_version_update_{plugin_slug}
232
+ * fs_plugin_version_update_{plugin_slug}
233
+ *
234
+ * fs_initiated_{plugin_slug}
235
+ * fs_after_init_plugin_registered_{plugin_slug}
236
+ * fs_after_init_plugin_anonymous_{plugin_slug}
237
+ * fs_after_init_plugin_pending_activations_{plugin_slug}
238
+ * fs_after_init_addon_registered_{plugin_slug}
239
+ * fs_after_init_addon_anonymous_{plugin_slug}
240
+ * fs_after_init_addon_pending_activations_{plugin_slug}
241
+ *
242
+ * fs_after_premium_version_activation_{plugin_slug}
243
+ * fs_after_free_version_reactivation_{plugin_slug}
244
+ *
245
+ * fs_after_uninstall_{plugin_slug}
246
+ * fs_before_admin_menu_init_{plugin_slug}
247
+ */
248
+
249
+ #endregion Hooks & Filters Collection --------------------------------------------------------------------
250
+
251
+ if ( ! class_exists( 'Freemius' ) ) {
252
+
253
+ if ( ! defined( 'WP_FS__SDK_VERSION' ) ) {
254
+ define( 'WP_FS__SDK_VERSION', $this_sdk_version );
255
+ }
256
+
257
+ // Configuration should be loaded first.
258
+ require_once dirname( __FILE__ ) . '/config.php';
259
+
260
+ // Logger must be loaded before any other.
261
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-logger.php';
262
+ require_once WP_FS__DIR_INCLUDES . '/debug/debug-bar-start.php';
263
+
264
+ require_once WP_FS__DIR_INCLUDES . '/fs-core-functions.php';
265
+ // require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-abstract-manager.php';
266
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-option-manager.php';
267
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-cache-manager.php';
268
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-notice-manager.php';
269
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-menu-manager.php';
270
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-key-value-storage.php';
271
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-license-manager.php';
272
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plan-manager.php';
273
+ require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plugin-manager.php';
274
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-entity.php';
275
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-scope-entity.php';
276
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-user.php';
277
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-site.php';
278
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin.php';
279
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-info.php';
280
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-tag.php';
281
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-plan.php';
282
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-pricing.php';
283
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-license.php';
284
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-subscription.php';
285
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-api.php';
286
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-plugin-updater.php';
287
+ require_once WP_FS__DIR_INCLUDES . '/class-fs-security.php';
288
+ require_once WP_FS__DIR_INCLUDES . '/class-freemius-abstract.php';
289
+ require_once WP_FS__DIR_INCLUDES . '/class-freemius.php';
290
+
291
+ /**
292
+ * Quick shortcut to get Freemius for specified plugin.
293
+ * Used by various templates.
294
+ *
295
+ * @param string $slug
296
+ *
297
+ * @return Freemius
298
+ */
299
+ function freemius( $slug ) {
300
+ return Freemius::instance( $slug );
301
+ }
302
+
303
+ /**
304
+ * @param string $slug
305
+ * @param number $plugin_id
306
+ * @param string $public_key
307
+ * @param bool $is_live Is live or test plugin.
308
+ * @param bool $is_premium Hints freemius if running the premium plugin or not.
309
+ *
310
+ * @return Freemius
311
+ */
312
+ function fs_init( $slug, $plugin_id, $public_key, $is_live = true, $is_premium = true ) {
313
+ $fs = Freemius::instance( $slug );
314
+ $fs->init( $plugin_id, $public_key, $is_live, $is_premium );
315
+
316
+ return $fs;
317
+ }
318
+
319
+ /**
320
+ * @param array [string]string $plugin
321
+ *
322
+ * @return Freemius
323
+ * @throws Freemius_Exception
324
+ */
325
+ function fs_dynamic_init( $plugin ) {
326
+ $fs = Freemius::instance( $plugin['slug'] );
327
+ $fs->dynamic_init( $plugin );
328
+
329
+ return $fs;
330
+ }
331
+
332
+ function fs_dump_log() {
333
+ FS_Logger::dump();
334
+ }
335
+ }
freemius/templates/account.php ADDED
@@ -0,0 +1,618 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $slug = $VARS['slug'];
14
+ /**
15
+ * @var Freemius $fs
16
+ */
17
+ $fs = freemius( $slug );
18
+
19
+ /**
20
+ * @var FS_Plugin_Tag $update
21
+ */
22
+ $update = $fs->get_update( false, false );
23
+
24
+ $is_paying = $fs->is_paying();
25
+ $user = $fs->get_user();
26
+ $site = $fs->get_site();
27
+ $name = $user->get_name();
28
+ $license = $fs->_get_license();
29
+ $subscription = $fs->_get_subscription();
30
+ $plan = $fs->get_plan();
31
+ $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
32
+ $is_paid_trial = $fs->is_paid_trial();
33
+ $show_upgrade = ( ! $is_paying && ! $is_paid_trial );
34
+ ?>
35
+
36
+ <div class="wrap">
37
+ <h2 class="nav-tab-wrapper">
38
+ <a href="<?php $fs->get_account_url() ?>" class="nav-tab nav-tab-active"><?php _efs( 'account', $slug ) ?></a>
39
+ <?php if ( $fs->has_addons() ) : ?>
40
+ <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>"
41
+ class="nav-tab"><?php _efs( 'add-ons', $slug ) ?></a>
42
+ <?php endif ?>
43
+ <?php if ( $fs->is_not_paying() && $fs->has_paid_plan() ) : ?>
44
+ <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php _efs( 'upgrade', $slug ) ?></a>
45
+ <?php if ( ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
46
+ <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php _efs( 'free-trial', $slug ) ?></a>
47
+ <?php endif ?>
48
+ <?php endif ?>
49
+ </h2>
50
+
51
+ <div id="poststuff">
52
+ <div id="fs_account">
53
+ <div class="has-sidebar has-right-sidebar">
54
+ <div class="has-sidebar-content">
55
+ <div class="postbox">
56
+ <h3><?php _efs( 'account-details', $slug ) ?></h3>
57
+
58
+ <div class="fs-header-actions">
59
+ <ul>
60
+ <li>
61
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
62
+ <input type="hidden" name="fs_action" value="delete_account">
63
+ <?php wp_nonce_field( 'delete_account' ) ?>
64
+ <a href="#" onclick="if (confirm('<?php
65
+ if ( $is_active_subscription ) {
66
+ echo esc_attr( sprintf( __fs( 'delete-account-x-confirm', $slug ), $plan->title ) );
67
+ } else {
68
+ _efs( 'delete-account-confirm', $slug );
69
+ }
70
+ ?>')) this.parentNode.submit(); return false;"><i
71
+ class="dashicons dashicons-no"></i> <?php _efs( 'delete-account', $slug ) ?></a>
72
+ </form>
73
+ </li>
74
+ <?php if ( $is_paying ) : ?>
75
+ <li>
76
+ &nbsp;•&nbsp;
77
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
78
+ <input type="hidden" name="fs_action" value="deactivate_license">
79
+ <?php wp_nonce_field( 'deactivate_license' ) ?>
80
+ <a href="#"
81
+ onclick="if (confirm('<?php _efs( 'deactivate-license-confirm', $slug ) ?>')) this.parentNode.submit(); return false;"><i
82
+ class="dashicons dashicons-admin-network"></i> <?php _efs( 'deactivate-license', $slug ) ?>
83
+ </a>
84
+ </form>
85
+ </li>
86
+ <?php if ( ! $license->is_lifetime() &&
87
+ $is_active_subscription
88
+ ) : ?>
89
+ <li>
90
+ &nbsp;•&nbsp;
91
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
92
+ <input type="hidden" name="fs_action" value="downgrade_account">
93
+ <?php wp_nonce_field( 'downgrade_account' ) ?>
94
+ <a href="#"
95
+ onclick="if (confirm('<?php printf( __fs( 'downgrade-x-confirm', $slug ), $plan->title, human_time_diff( time(), strtotime( $license->expiration ) ) ) ?> <?php if ( ! $license->is_block_features ) {
96
+ printf( __fs( 'after-downgrade-non-blocking', $slug ), $plan->title );
97
+ } else {
98
+ printf( __fs( 'after-downgrade-blocking', $slug ), $plan->title );
99
+ }?> <?php _efs( 'proceed-confirmation', $slug ) ?>')) this.parentNode.submit(); return false;"><i
100
+ class="dashicons dashicons-download"></i> <?php _efs( 'downgrade', $slug ) ?></a>
101
+ </form>
102
+ </li>
103
+ <?php endif ?>
104
+ <li>
105
+ &nbsp;•&nbsp;
106
+ <a href="<?php echo $fs->get_upgrade_url() ?>"><i
107
+ class="dashicons dashicons-grid-view"></i> <?php _efs( 'change-plan', $slug ) ?></a>
108
+ </li>
109
+ <?php elseif ( $is_paid_trial ) : ?>
110
+ <li>
111
+ &nbsp;•&nbsp;
112
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
113
+ <input type="hidden" name="fs_action" value="cancel_trial">
114
+ <?php wp_nonce_field( 'cancel_trial' ) ?>
115
+ <a href="#"
116
+ onclick="if (confirm('<?php _efs( 'cancel-trial-confirm' ) ?>')) this.parentNode.submit(); return false;"><i
117
+ class="dashicons dashicons-download"></i> <?php _efs( 'cancel-trial', $slug ) ?></a>
118
+ </form>
119
+ </li>
120
+ <?php endif ?>
121
+ <li>
122
+ &nbsp;•&nbsp;
123
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
124
+ <input type="hidden" name="fs_action" value="<?php echo $slug ?>_sync_license">
125
+ <?php wp_nonce_field( $slug . '_sync_license' ) ?>
126
+ <a href="#" onclick="this.parentNode.submit(); return false;"><i
127
+ class="dashicons dashicons-image-rotate"></i> <?php _efs( 'sync', $slug ) ?></a>
128
+ </form>
129
+ </li>
130
+
131
+ </ul>
132
+ </div>
133
+ <div class="inside">
134
+ <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
135
+ <?php
136
+ $profile = array();
137
+ $profile[] = array(
138
+ 'id' => 'user_name',
139
+ 'title' => __fs( 'name', $slug ),
140
+ 'value' => $name
141
+ );
142
+ // if (isset($user->email) && false !== strpos($user->email, '@'))
143
+ $profile[] = array(
144
+ 'id' => 'email',
145
+ 'title' => __fs( 'email', $slug ),
146
+ 'value' => $user->email
147
+ );
148
+ if ( is_numeric( $user->id ) ) {
149
+ $profile[] = array(
150
+ 'id' => 'user_id',
151
+ 'title' => __fs( 'user-id', $slug ),
152
+ 'value' => $user->id
153
+ );
154
+ }
155
+
156
+ $profile[] = array(
157
+ 'id' => 'site_id',
158
+ 'title' => __fs( 'site-id', $slug ),
159
+ 'value' => is_string( $site->id ) ?
160
+ $site->id :
161
+ __fs( 'no-id', $slug )
162
+ );
163
+
164
+ $profile[] = array(
165
+ 'id' => 'site_public_key',
166
+ 'title' => __fs( 'public-key', $slug ),
167
+ 'value' => $site->public_key
168
+ );
169
+
170
+ $profile[] = array(
171
+ 'id' => 'site_secret_key',
172
+ 'title' => __fs( 'secret-key', $slug ),
173
+ 'value' => ( ( is_string( $site->secret_key ) ) ?
174
+ $site->secret_key :
175
+ __fs( 'no-secret', $slug )
176
+ )
177
+ );
178
+
179
+ if ( $fs->has_paid_plan() ) {
180
+ if ( $fs->is_trial() ) {
181
+ $trial_plan = $fs->get_trial_plan();
182
+
183
+ $profile[] = array(
184
+ 'id' => 'plan',
185
+ 'title' => __fs( 'plan', $slug ),
186
+ 'value' => ( is_string( $trial_plan->name ) ?
187
+ strtoupper( $trial_plan->title ) :
188
+ __fs( 'trial', $slug ) )
189
+ );
190
+ } else {
191
+ $profile[] = array(
192
+ 'id' => 'plan',
193
+ 'title' => __fs( 'plan', $slug ),
194
+ 'value' => is_string( $site->plan->name ) ?
195
+ strtoupper( $site->plan->title ) :
196
+ strtoupper( __fs( 'free', $slug ) )
197
+ );
198
+ }
199
+ }
200
+
201
+ $profile[] = array(
202
+ 'id' => 'version',
203
+ 'title' => __fs( 'version', $slug ),
204
+ 'value' => $fs->get_plugin_version()
205
+ );
206
+ ?>
207
+ <?php $odd = true;
208
+ foreach ( $profile as $p ) : ?>
209
+ <?php
210
+ if ( 'plan' === $p['id'] && ! $fs->has_paid_plan() ) {
211
+ // If plugin don't have any paid plans, there's no reason
212
+ // to show current plan.
213
+ continue;
214
+ }
215
+ ?>
216
+ <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
217
+ <td>
218
+ <nobr><?php echo $p['title'] ?>:</nobr>
219
+ </td>
220
+ <td>
221
+ <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
222
+ <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
223
+ <label class="fs-tag fs-warn"><?php _efs( 'not-verified', $slug ) ?></label>
224
+ <?php endif ?>
225
+ <?php if ( 'plan' === $p['id'] ) : ?>
226
+ <?php if ( $fs->is_trial() ) : ?>
227
+ <label class="fs-tag fs-success"><?php _efs( 'trial', $slug ) ?></label>
228
+ <?php endif ?>
229
+ <?php if ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
230
+ <?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?>
231
+ <label
232
+ class="fs-tag fs-warn"><?php printf( __fs( 'expires-in', $slug ), human_time_diff( time(), strtotime( $license->expiration ) ) ) ?></label>
233
+ <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
234
+ <label
235
+ class="fs-tag fs-success"><?php printf( __fs( 'renews-in', $slug ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ?></label>
236
+ <?php endif ?>
237
+ <?php elseif ( $fs->is_trial() ) : ?>
238
+ <label
239
+ class="fs-tag fs-warn"><?php printf( __fs( 'expires-in', $slug ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ?></label>
240
+ <?php endif ?>
241
+ <?php endif ?>
242
+ <?php if ( 'version' === $p['id'] && $fs->has_paid_plan() ) : ?>
243
+ <?php if ( $fs->is_premium() ) : ?>
244
+ <label
245
+ class="fs-tag fs-<?php echo $fs->can_use_premium_code() ? 'success' : 'warn' ?>"><?php _efs( 'premium-version' ) ?></label>
246
+ <?php elseif ( $fs->can_use_premium_code() ) : ?>
247
+ <label class="fs-tag fs-warn"><?php _efs( 'free-version' ) ?></label>
248
+ <?php endif ?>
249
+ <?php endif ?>
250
+ </td>
251
+ <td class="fs-right">
252
+ <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
253
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
254
+ <input type="hidden" name="fs_action" value="verify_email">
255
+ <?php wp_nonce_field( 'verify_email' ) ?>
256
+ <input type="submit" class="button button-small"
257
+ value="<?php _efs( 'verify-email', $slug ) ?>">
258
+ </form>
259
+ <?php endif ?>
260
+ <?php if ( 'plan' === $p['id'] ) : ?>
261
+ <div class="button-group">
262
+ <?php $license = $fs->is_free_plan() ? $fs->_get_available_premium_license() : false ?>
263
+ <?php if ( false !== $license && ( $license->left() > 0 || ( $site->is_localhost() && $license->is_free_localhost ) ) ) : ?>
264
+ <?php $premium_plan = $fs->_get_plan_by_id( $license->plan_id ) ?>
265
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
266
+ method="POST">
267
+ <input type="hidden" name="fs_action" value="activate_license">
268
+ <input type="hidden" name="license_id" value="<?php echo $license->id ?>">
269
+ <?php wp_nonce_field( 'activate_license' ) ?>
270
+ <input type="submit" class="button button-primary"
271
+ value="<?php printf(
272
+ __fs( 'activate-x-plan', $slug ),
273
+ $premium_plan->title,
274
+ ( $site->is_localhost() && $license->is_free_localhost ) ?
275
+ '[' . __fs( 'localhost', $slug ) . ']' :
276
+ ( 1 < $license->left() ? $license->left() . ' left' : '' )
277
+ ) ?> ">
278
+ </form>
279
+ <?php else : ?>
280
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
281
+ method="POST" class="button-group">
282
+ <input type="submit" class="button"
283
+ value="<?php _efs( 'sync-license', $slug ) ?>">
284
+ <input type="hidden" name="fs_action"
285
+ value="<?php echo $slug ?>_sync_license">
286
+ <?php wp_nonce_field( $slug . '_sync_license' ) ?>
287
+ <a href="<?php echo $fs->get_upgrade_url() ?>"
288
+ class="button<?php if ( $show_upgrade ) {
289
+ echo ' button-primary';
290
+ } ?> button-upgrade"><i
291
+ class="dashicons dashicons-cart"></i> <?php ( $show_upgrade ) ?
292
+ _efs( 'upgrade', $slug ) :
293
+ _efs( 'change-plan', $slug )
294
+ ?></a>
295
+ </form>
296
+ <?php endif ?>
297
+ </div>
298
+ <?php elseif ( 'version' === $p['id'] ) : ?>
299
+ <div class="button-group">
300
+ <?php if ( $is_paying || $fs->is_trial() ) : ?>
301
+ <?php if ( ! $fs->is_allowed_to_install() ) : ?>
302
+ <a target="_blank" class="button button-primary"
303
+ href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf( __fs( 'download-x-version', $slug ), $site->plan->title ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
304
+ <?php elseif ( is_object( $update ) ) : ?>
305
+ <a class="button button-primary"
306
+ href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $fs->get_plugin_basename() ), 'upgrade-plugin_' . $fs->get_plugin_basename() ) ?>"><?php echo __fs( 'install-update-now', $slug ) . ' [' . $update->version . ']' ?></a>
307
+ <?php endif ?>
308
+ <?php endif; ?>
309
+ </div>
310
+ <?php
311
+ elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
312
+ ( is_string( $user->secret_key ) && in_array( $p['id'], array(
313
+ 'email',
314
+ 'user_name'
315
+ ) ) )
316
+ ) : ?>
317
+ <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
318
+ onsubmit="var val = prompt('<?php printf( __fs( 'what-is-your-x', $slug ), $p['title'] ) ?>', '<?php echo $p['value'] ?>'); if (null == val || '' === val) return false; jQuery('input[name=fs_<?php echo $p['id'] ?>_<?php echo $slug ?>]').val(val); return true;">
319
+ <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
320
+ <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $slug ?>"
321
+ value="">
322
+ <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
323
+ <input type="submit" class="button button-small"
324
+ value="<?php _ex( 'Edit', 'verb', 'freemius' ) ?>">
325
+ </form>
326
+ <?php endif ?>
327
+ </td>
328
+ </tr>
329
+ <?php $odd = ! $odd; endforeach ?>
330
+ </table>
331
+ </div>
332
+ </div>
333
+ <?php
334
+ $account_addons = $fs->get_account_addons();
335
+ if ( ! is_array( $account_addons ) ) {
336
+ $account_addons = array();
337
+ }
338
+
339
+ $installed_addons = $fs->get_installed_addons();
340
+ $installed_addons_ids = array();
341
+ foreach ( $installed_addons as $fs_addon ) {
342
+ $installed_addons_ids[] = $fs_addon->get_id();
343
+ }
344
+
345
+ $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
346
+ ?>
347
+ <?php if ( 0 < count( $addons_to_show ) ) : ?>
348
+ <div class="postbox">
349
+ <div class="">
350
+ <!-- <div class="inside">-->
351
+ <table id="fs_addons" class="widefat">
352
+ <thead>
353
+ <tr>
354
+ <th><h3><?php _efs( 'add-ons', $slug ) ?></h3></th>
355
+ <th><?php _efs( 'id', $slug ) ?></th>
356
+ <th><?php _efs( 'version', $slug ) ?></th>
357
+ <th><?php _efs( 'plan', $slug ) ?></th>
358
+ <th><?php _efs( 'license', $slug ) ?></th>
359
+ <th></th>
360
+ <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
361
+ <th></th>
362
+ <?php endif ?>
363
+ </tr>
364
+ </thead>
365
+ <tbody>
366
+ <?php $odd = true;
367
+ foreach ( $addons_to_show as $addon_id ) : ?>
368
+ <?php
369
+ $addon = $fs->get_addon( $addon_id );
370
+ $is_addon_activated = $fs->is_addon_activated( $addon->slug );
371
+ $is_addon_connected = $fs->is_addon_connected( $addon->slug );
372
+
373
+ $fs_addon = $is_addon_connected ? freemius( $addon->slug ) : false;
374
+ if ( is_object( $fs_addon ) ) {
375
+ $is_paying = $fs_addon->is_paying();
376
+ $user = $fs_addon->get_user();
377
+ $site = $fs_addon->get_site();
378
+ $license = $fs_addon->_get_license();
379
+ $subscription = $fs_addon->_get_subscription();
380
+ $plan = $fs_addon->get_plan();
381
+ $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
382
+ $is_paid_trial = $fs_addon->is_paid_trial();
383
+ $show_upgrade = ( ! $is_paying && ! $is_paid_trial && ! $fs_addon->_has_premium_license() );
384
+ $is_current_license_expired = is_object( $license ) && $license->is_expired();
385
+ }
386
+
387
+ // var_dump( $is_paid_trial, $license, $site, $subscription );
388
+
389
+ ?>
390
+ <tr<?php if ( $odd ) {
391
+ echo ' class="alternate"';
392
+ } ?>>
393
+ <td>
394
+ <!-- Title -->
395
+ <?php echo $addon->title ?>
396
+ </td>
397
+ <?php if ( $is_addon_connected ) : ?>
398
+ <?php // Add-on Installed ?>
399
+ <?php $addon_site = $fs_addon->get_site(); ?>
400
+ <td>
401
+ <!-- ID -->
402
+ <?php echo $addon_site->id ?>
403
+ </td>
404
+ <td>
405
+ <!-- Version -->
406
+ <?php echo $fs_addon->get_plugin_version() ?>
407
+ </td>
408
+ <td>
409
+ <!-- Plan Title -->
410
+ <?php echo is_string( $addon_site->plan->name ) ? strtoupper( $addon_site->plan->title ) : 'FREE' ?>
411
+ </td>
412
+ <td>
413
+ <!-- Expiration -->
414
+ <?php
415
+ $tags = array();
416
+
417
+ if ( $fs_addon->is_trial() ) {
418
+ $tags[] = array( 'label' => __fs( 'trial', $slug ), 'type' => 'success' );
419
+
420
+ $tags[] = array(
421
+ 'label' => sprintf( __fs( ( $is_paid_trial ? 'renews-in' : 'expires-in' ), $slug ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ),
422
+ 'type' => ( $is_paid_trial ? 'success' : 'warn' )
423
+ );
424
+ } else {
425
+ if ( is_object( $license ) ) {
426
+ if ( $license->is_cancelled ) {
427
+ $tags[] = array(
428
+ 'label' => __fs( 'cancelled', $slug ),
429
+ 'type' => 'error'
430
+ );
431
+ } else if ( $license->is_expired() ) {
432
+ $tags[] = array(
433
+ 'label' => __fs( 'expired', $slug ),
434
+ 'type' => 'error'
435
+ );
436
+ } else if ( $license->is_lifetime() ) {
437
+ $tags[] = array(
438
+ 'label' => __fs( 'no-expiration', $slug ),
439
+ 'type' => 'success'
440
+ );
441
+ } else if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) {
442
+ $tags[] = array(
443
+ 'label' => sprintf( __fs( 'expires-in', $slug ), human_time_diff( time(), strtotime( $license->expiration ) ) ),
444
+ 'type' => 'warn'
445
+ );
446
+ } else if ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) {
447
+ $tags[] = array(
448
+ 'label' => sprintf( __fs( 'renews-in', $slug ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ),
449
+ 'type' => 'success'
450
+ );
451
+ }
452
+ }
453
+ }
454
+
455
+ foreach ( $tags as $t ) {
456
+ printf( '<label class="fs-tag fs-%s">%s</label>' . "\n", $t['type'], $t['label'] );
457
+ }
458
+ ?>
459
+ </td>
460
+ <?php
461
+ $buttons = array();
462
+ if ( $is_addon_activated ) {
463
+ if ( $is_paying ) {
464
+ $buttons[] = fs_ui_get_action_button(
465
+ $slug,
466
+ 'account',
467
+ 'deactivate_license',
468
+ __fs( 'deactivate-license', $slug ),
469
+ array( 'plugin_id' => $addon_id ),
470
+ false
471
+ );
472
+ } else if ( $is_paid_trial ) {
473
+ $buttons[] = fs_ui_get_action_button(
474
+ $slug,
475
+ 'account',
476
+ 'cancel_trial',
477
+ __fs( 'cancel-trial', $slug ),
478
+ array( 'plugin_id' => $addon_id ),
479
+ false,
480
+ 'dashicons dashicons-download',
481
+ __fs( 'cancel-trial-confirm', $slug ),
482
+ 'POST'
483
+ );
484
+ } else {
485
+ $premium_license = $fs_addon->_get_available_premium_license();
486
+
487
+ if ( is_object( $premium_license ) ) {
488
+ $site = $fs_addon->get_site();
489
+
490
+ $buttons[] = fs_ui_get_action_button(
491
+ $slug,
492
+ 'account',
493
+ 'activate_license',
494
+ sprintf( __fs( 'activate-x-plan', $slug ), $fs_addon->get_plan_title(), ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ),
495
+ array(
496
+ 'plugin_id' => $addon_id,
497
+ 'license_id' => $premium_license->id,
498
+ )
499
+ );
500
+ }
501
+ }
502
+
503
+ if ( 0 == count( $buttons ) ) {
504
+ // Add sync license only if non of the other CTAs are visible.
505
+ $buttons[] = fs_ui_get_action_button(
506
+ $slug,
507
+ 'account',
508
+ $slug . '_sync_license',
509
+ __fs( 'sync-license', $slug ),
510
+ array( 'plugin_id' => $addon_id ),
511
+ false
512
+ );
513
+
514
+ }
515
+ } else if ( ! $show_upgrade ) {
516
+ if ( $fs->is_addon_installed( $addon->slug ) ) {
517
+ $addon_file = $fs->get_addon_basename( $addon->slug );
518
+ $buttons[] = sprintf(
519
+ '<a class="button button-primary" href="%s" title="%s" class="edit">%s</a>',
520
+ wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ),
521
+ esc_attr( __fs( 'activate-this-addon', $slug ) ),
522
+ __fs( 'activate', $slug )
523
+ );
524
+ } else {
525
+ if ( $fs->is_allowed_to_install() ) {
526
+ $buttons[] = sprintf(
527
+ '<a class="button button-primary" href="%s" class="edit">%s</a>',
528
+ wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ),
529
+ __fs( 'install-now', $slug )
530
+ );
531
+ } else {
532
+ $buttons[] = sprintf(
533
+ '<a target="_blank" class="button button-primary" href="%s" class="edit">%s</a>',
534
+ $fs->_get_latest_download_local_url( $addon_id ),
535
+ __fs( 'download-latest', $slug )
536
+ );
537
+ }
538
+ }
539
+ }
540
+
541
+ if ( $show_upgrade ) {
542
+ $buttons[] = sprintf( '<a href="%s" class="thickbox button button-primary" aria-label="%s" data-title="%s"><i class="dashicons dashicons-cart"></i> %s</a>',
543
+ esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
544
+ '&TB_iframe=true&width=600&height=550' ) ),
545
+ esc_attr( sprintf( __fs( 'more-information-about-x', $slug ), $addon->title ) ),
546
+ esc_attr( $addon->title ),
547
+ __fs( ( $fs_addon->has_free_plan() ? 'upgrade' : 'purchase' ), $slug )
548
+ );
549
+ }
550
+
551
+ $buttons_count = count( $buttons );
552
+ ?>
553
+
554
+ <td>
555
+ <!-- Actions -->
556
+ <?php if ($buttons_count > 1) : ?>
557
+ <div class="button-group">
558
+ <?php endif ?>
559
+ <?php foreach ( $buttons as $button ) : ?>
560
+ <?php echo $button ?>
561
+ <?php endforeach ?>
562
+ <?php if ($buttons_count > 1) : ?>
563
+ </div>
564
+ <?php endif ?>
565
+ </td>
566
+ <?php else : ?>
567
+ <?php // Add-on NOT Installed or was never connected.
568
+ ?>
569
+ <td colspan="4">
570
+ <!-- Action -->
571
+ <?php if ( $fs->is_addon_installed( $addon->slug ) ) : ?>
572
+ <?php $addon_file = $fs->get_addon_basename( $addon->slug ) ?>
573
+ <a class="button button-primary"
574
+ href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
575
+ title="<?php esc_attr( __fs( 'activate-this-addon', $slug ) ) ?>"
576
+ class="edit"><?php _efs( 'activate', $slug ) ?></a>
577
+ <?php else : ?>
578
+ <?php if ( $fs->is_allowed_to_install() ) : ?>
579
+ <a class="button button-primary"
580
+ href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php _efs( 'install-now', $slug ) ?></a>
581
+ <?php else : ?>
582
+ <a target="_blank" class="button button-primary"
583
+ href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php _efs( 'download-latest', $slug ) ?></a>
584
+ <?php endif ?>
585
+ <?php endif ?>
586
+ </td>
587
+ <?php endif ?>
588
+ <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
589
+ <td>
590
+ <!-- Optional Delete Action -->
591
+ <?php
592
+ if ( $is_addon_activated ) {
593
+ fs_ui_action_button(
594
+ $slug, 'account',
595
+ 'delete_account',
596
+ __fs( 'delete', $slug ),
597
+ array( 'plugin_id' => $addon_id ),
598
+ false
599
+ );
600
+ }
601
+ ?>
602
+ </td>
603
+ <?php endif ?>
604
+ </tr>
605
+ <?php $odd = ! $odd; endforeach ?>
606
+ </tbody>
607
+ </table>
608
+ </div>
609
+ </div>
610
+ <?php endif ?>
611
+
612
+ <?php $fs->do_action( 'after_account_details' ) ?>
613
+ </div>
614
+ </div>
615
+ </div>
616
+ </div>
617
+ </div>
618
+ <?php fs_require_template( 'powered-by.php' ) ?>
freemius/templates/add-ons.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $slug = $VARS['slug'];
14
+ /**
15
+ * @var Freemius
16
+ */
17
+ $fs = freemius( $slug );
18
+
19
+ $open_addon_slug = fs_request_get( 'slug' );
20
+
21
+ $open_addon = false;
22
+
23
+ /**
24
+ * @var FS_Plugin[]
25
+ */
26
+ $addons = $fs->get_addons();
27
+ ?>
28
+ <div id="fs_addons" class="wrap">
29
+ <h2><?php printf( __fs( 'add-ons-for-x', $slug ), $fs->get_plugin_name() ) ?></h2>
30
+
31
+ <div id="poststuff">
32
+ <?php if ( ! is_array( $addons ) || 0 == count( $addons ) ) : ?>
33
+ <h3><?php printf(
34
+ '%s... %s',
35
+ __fs( 'oops', $slug ),
36
+ __fs( 'add-ons-missing', $slug )
37
+ ) ?></h3>
38
+ <?php else : ?>
39
+ <ul class="fs-cards-list">
40
+ <?php foreach ( $addons as $addon ) : ?>
41
+ <?php
42
+ $open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );
43
+
44
+ $price = 0;
45
+ $plans_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans.json" );
46
+ if ( ! isset( $plans_result->error ) ) {
47
+ $plans = $plans_result->plans;
48
+ if ( is_array( $plans ) && 0 < count( $plans ) ) {
49
+ $plan = $plans[0];
50
+ $pricing_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans/{$plan->id}/pricing.json" );
51
+ if ( ! isset( $pricing_result->error ) ) {
52
+ // Update plan's pricing.
53
+ $plan->pricing = $pricing_result->pricing;
54
+
55
+ if ( is_array( $plan->pricing ) && 0 < count( $plan->pricing ) ) {
56
+ $min_price = 999999;
57
+ foreach ( $plan->pricing as $pricing ) {
58
+ if ( ! is_null( $pricing->annual_price ) && $pricing->annual_price > 0 ) {
59
+ $min_price = min( $min_price, $pricing->annual_price );
60
+ } else if ( ! is_null( $pricing->monthly_price ) && $pricing->monthly_price > 0 ) {
61
+ $min_price = min( $min_price, 12 * $pricing->monthly_price );
62
+ }
63
+ }
64
+
65
+ if ( $min_price < 999999 ) {
66
+ $price = $min_price;
67
+ }
68
+ }
69
+ }
70
+ }
71
+ }
72
+ ?>
73
+ <li class="fs-card" data-slug="<?php echo $addon->slug ?>">
74
+ <?php
75
+ echo sprintf( '<a href="%s" class="thickbox fs-overlay" aria-label="%s" data-title="%s"></a>',
76
+ esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
77
+ '&TB_iframe=true&width=600&height=550' ) ),
78
+ esc_attr( sprintf( __fs( 'more-information-about-x', $slug ), $addon->title ) ),
79
+ esc_attr( $addon->title )
80
+ );
81
+ ?>
82
+ <?php
83
+ if ( is_null( $addon->info ) ) {
84
+ $addon->info = new stdClass();
85
+ }
86
+ if ( ! isset( $addon->info->card_banner_url ) ) {
87
+ $addon->info->card_banner_url = '//dashboard.freemius.com/assets/img/marketing/blueprint-300x100.jpg';
88
+ }
89
+ if ( ! isset( $addon->info->short_description ) ) {
90
+ $addon->info->short_description = 'What\'s the one thing your add-on does really, really well?';
91
+ }
92
+ ?>
93
+ <div class="fs-inner">
94
+ <ul>
95
+ <li class="fs-card-banner"
96
+ style="background-image: url('<?php echo $addon->info->card_banner_url ?>');"></li>
97
+ <li class="fs-title"><?php echo $addon->title ?></li>
98
+ <li class="fs-offer">
99
+ <span
100
+ class="fs-price"><?php echo ( 0 == $price ) ? __fs( 'free', $slug ) : '$' . number_format( $price, 2 ) ?></span>
101
+ </li>
102
+ <li class="fs-description"><?php echo ! empty( $addon->info->short_description ) ? $addon->info->short_description : 'SHORT DESCRIPTION' ?></li>
103
+ </ul>
104
+ </div>
105
+ </li>
106
+ <?php endforeach ?>
107
+ </ul>
108
+ <?php endif ?>
109
+ </div>
110
+ </div>
111
+ <?php if ( $open_addon ) : ?>
112
+ <script type="text/javascript">
113
+ (function ($) {
114
+ var interval = setInterval(function () {
115
+ // Open add-on information page.
116
+ $('.fs-card[data-slug=<?php echo $open_addon_slug ?>] a').click();
117
+ if ($('#TB_iframeContent').length > 0) {
118
+ clearInterval(interval);
119
+ interval = null;
120
+ }
121
+ }, 200);
122
+ })(jQuery);
123
+ </script>
124
+ <?php endif ?>
125
+ <?php fs_require_template( 'powered-by.php' ) ?>
freemius/templates/admin-notice.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+ ?>
13
+ <div<?php if ( ! empty( $VARS['id'] ) ) : ?> data-id="<?php echo $VARS['id'] ?>"<?php endif ?><?php if ( ! empty( $VARS['slug'] ) ) : ?> data-slug="<?php echo $VARS['slug'] ?>"<?php endif ?>
14
+ class="<?php
15
+ switch ( $VARS['type'] ) {
16
+ case 'error':
17
+ echo 'error form-invalid';
18
+ break;
19
+ case 'promotion':
20
+ echo 'updated promotion';
21
+ break;
22
+ case 'update':
23
+ // echo 'update-nag update';
24
+ // break;
25
+ case 'success':
26
+ default:
27
+ echo 'updated success';
28
+ break;
29
+ }
30
+ ?> fs-notice<?php if ( ! empty( $VARS['sticky'] ) ) {
31
+ echo ' fs-sticky';
32
+ } ?><?php if ( ! empty( $VARS['plugin'] ) ) {
33
+ echo ' fs-has-title';
34
+ } ?>"><?php if ( ! empty( $VARS['plugin'] ) ) : ?>
35
+ <label class="fs-plugin-title"><?php echo $VARS['plugin'] ?></label>
36
+ <?php endif ?>
37
+ <?php if ( ! empty( $VARS['sticky'] ) ) : ?>
38
+ <div class="fs-close"><i class="dashicons dashicons-no"
39
+ title="<?php _efs( 'dismiss' ) ?>"></i> <span><?php _efs( 'dismiss' ) ?></span>
40
+ </div>
41
+ <?php endif ?>
42
+ <div class="fs-notice-body">
43
+ <?php if ( ! empty( $VARS['title'] ) ) : ?><b><?php echo $VARS['title'] ?></b> <?php endif ?>
44
+ <?php echo $VARS['message'] ?>
45
+ </div>
46
+ </div>
freemius/templates/all-admin-notice.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+ ?>
13
+ <div class="<?php
14
+ switch ($VARS['type']) {
15
+ case 'error':
16
+ echo 'error form-invalid';
17
+ break;
18
+ case 'update-nag':
19
+ echo 'update-nag ';
20
+ break;
21
+ case 'update':
22
+ case 'success':
23
+ default:
24
+ echo 'updated success';
25
+ break;
26
+ }
27
+ ?> fs-notice">
28
+ <?php if ('update-nag' !== $VARS['type']) : ?><p><?php endif ?>
29
+ <?php if (!empty($VARS['title'])) : ?>
30
+ <b><?php echo $VARS['title'] ?></b>
31
+ <?php endif ?>
32
+ <?php echo $VARS['message'] ?>
33
+ <?php if ('update-nag' !== $VARS['type']) : ?></p><?php endif ?>
34
+ <?php if ($VARS['sticky']) : ?><i class="dashicons dashicons-no"></i><?php endif ?>
35
+ </div>
freemius/templates/checkout.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ wp_enqueue_script( 'jquery' );
14
+ wp_enqueue_script( 'json2' );
15
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
18
+
19
+ $slug = $VARS['slug'];
20
+ $fs = freemius( $slug );
21
+
22
+ $timestamp = time();
23
+
24
+ $context_params = array(
25
+ 'plugin_id' => $fs->get_id(),
26
+ 'plugin_public_key' => $fs->get_public_key(),
27
+ 'plugin_version' => $fs->get_plugin_version(),
28
+ );
29
+
30
+ // Get site context secure params.
31
+ if ( $fs->is_registered() ) {
32
+ $site = $fs->get_site();
33
+ $plugin_id = fs_request_get( 'plugin_id', $fs->get_id() );
34
+
35
+ if ($plugin_id != $fs->get_id()) {
36
+ if ( $fs->is_addon_activated( $plugin_id ) ) {
37
+ $fs_addon = Freemius::get_instance_by_id( $plugin_id );
38
+ $site = $fs_addon->get_site();
39
+ }
40
+ }
41
+
42
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
43
+ $site,
44
+ $timestamp,
45
+ 'checkout'
46
+ ) );
47
+ } else {
48
+ $current_user = Freemius::_get_current_wp_user();
49
+
50
+ // Add site and user info to the request, this information
51
+ // is NOT being stored unless the user complete the purchase
52
+ // and agrees to the TOS.
53
+ $context_params = array_merge( $context_params, array(
54
+ 'user_firstname' => $current_user->user_firstname,
55
+ 'user_lastname' => $current_user->user_lastname,
56
+ 'user_email' => $current_user->user_email,
57
+ // 'user_nickname' => $current_user->user_nicename,
58
+ // 'plugin_slug' => $slug,
59
+ // 'site_url' => get_site_url(),
60
+ // 'site_name' => get_bloginfo( 'name' ),
61
+ // 'platform_version' => get_bloginfo( 'version' ),
62
+ // 'language' => get_bloginfo( 'language' ),
63
+ // 'charset' => get_bloginfo( 'charset' ),
64
+ // 'account_url' => fs_nonce_url( $fs->_get_admin_page_url(
65
+ // 'account',
66
+ // array( 'fs_action' => 'sync_user' )
67
+ // ), 'sync_user' ),
68
+ ) );
69
+
70
+ $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
71
+
72
+ if ( is_object( $fs_user ) ) {
73
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
74
+ $fs_user,
75
+ $timestamp,
76
+ 'checkout'
77
+ ) );
78
+ }
79
+ }
80
+
81
+ if ( $fs->is_payments_sandbox() )
82
+ {
83
+ // Append plugin secure token for sandbox mode authentication.
84
+ $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
85
+ $fs->get_plugin(),
86
+ $timestamp,
87
+ 'checkout'
88
+ );
89
+
90
+ /**
91
+ * @since 1.1.7.3 Add security timestamp for sandbox even for anonymous user.
92
+ */
93
+ if ( empty( $context_params['s_ctx_ts'] ) ) {
94
+ $context_params['s_ctx_ts'] = $timestamp;
95
+ }
96
+ }
97
+
98
+ $return_url = fs_nonce_url( $fs->_get_admin_page_url(
99
+ 'account',
100
+ array(
101
+ 'fs_action' => $slug . '_sync_license',
102
+ 'plugin_id' => isset( $_GET['plugin_id'] ) ? $_GET['plugin_id'] : $fs->get_id()
103
+ )
104
+ ), $slug . '_sync_license' );
105
+
106
+ $query_params = array_merge( $context_params, $_GET, array(
107
+ // Current plugin version.
108
+ 'plugin_version' => $fs->get_plugin_version(),
109
+ 'return_url' => $return_url,
110
+ // Admin CSS URL for style/design competability.
111
+ // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
112
+ ) );
113
+ ?>
114
+ <div class="fs-secure-notice">
115
+ <i class="dashicons dashicons-lock"></i>
116
+ <span><b>Secure HTTPS Checkout</b> - PCI compliant, running via iframe from external domain</span>
117
+ </div>
118
+ <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
119
+ <div id="iframe"></div>
120
+ <script type="text/javascript">
121
+ // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
122
+ jQuery(function ($) {
123
+ $.extend({
124
+ form: function (url, data, method) {
125
+ if (method == null) method = 'POST';
126
+ if (data == null) data = {};
127
+
128
+ var form = $('<form>').attr({
129
+ method: method,
130
+ action: url
131
+ }).css({
132
+ display: 'none'
133
+ });
134
+
135
+ var addData = function (name, data) {
136
+ if ($.isArray(data)) {
137
+ for (var i = 0; i < data.length; i++) {
138
+ var value = data[i];
139
+ addData(name + '[]', value);
140
+ }
141
+ } else if (typeof data === 'object') {
142
+ for (var key in data) {
143
+ if (data.hasOwnProperty(key)) {
144
+ addData(name + '[' + key + ']', data[key]);
145
+ }
146
+ }
147
+ } else if (data != null) {
148
+ form.append($('<input>').attr({
149
+ type : 'hidden',
150
+ name : String(name),
151
+ value: String(data)
152
+ }));
153
+ }
154
+ };
155
+
156
+ for (var key in data) {
157
+ if (data.hasOwnProperty(key)) {
158
+ addData(key, data[key]);
159
+ }
160
+ }
161
+
162
+ return form.appendTo('body');
163
+ }
164
+ });
165
+ });
166
+
167
+ (function ($) {
168
+ $(function () {
169
+
170
+ var
171
+ // Keep track of the iframe height.
172
+ iframe_height = 800,
173
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
174
+ // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
175
+ // passed via query string or hard coded into the child page, it depends on your needs).
176
+ src = base_url + '/checkout/?<?php echo (isset($_REQUEST['XDEBUG_SESSION']) ? 'XDEBUG_SESSION=' . $_REQUEST['XDEBUG_SESSION'] . '&' : '') . http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
177
+
178
+ // Append the Iframe into the DOM.
179
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
180
+ .appendTo('#iframe');
181
+
182
+ FS.PostMessage.init(base_url);
183
+ FS.PostMessage.receiveOnce('height', function (data) {
184
+ var h = data.height;
185
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
186
+ iframe_height = h;
187
+ $("#iframe iframe").height(iframe_height + 'px');
188
+ }
189
+ });
190
+
191
+ FS.PostMessage.receiveOnce('install', function (data) {
192
+ // Post data to activation URL.
193
+ $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
194
+ 'fs_action' => $slug . '_activate_new',
195
+ 'plugin_id' => isset($_GET['plugin_id']) ? $_GET['plugin_id'] : $fs->get_id()
196
+ )), $slug . '_activate_new') ?>', {
197
+ user_id : data.user.id,
198
+ user_secret_key : data.user.secret_key,
199
+ user_public_key : data.user.public_key,
200
+ install_id : data.install.id,
201
+ install_secret_key: data.install.secret_key,
202
+ install_public_key: data.install.public_key
203
+ }).submit();
204
+ });
205
+
206
+ FS.PostMessage.receiveOnce('pending_activation', function (data) {
207
+ $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
208
+ 'fs_action' => $slug . '_activate_new',
209
+ 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
210
+ 'pending_activation' => true,
211
+ )), $slug . '_activate_new') ?>', {
212
+ user_email: data.user_email
213
+ }).submit();
214
+ });
215
+
216
+ FS.PostMessage.receiveOnce('get_context', function () {
217
+ console.debug('receiveOnce', 'get_context');
218
+
219
+ // If the user didn't connect his account with Freemius,
220
+ // once he accepts the Terms of Service and Privacy Policy,
221
+ // and then click the purchase button, the context information
222
+ // of the user will be shared with Freemius in order to complete the
223
+ // purchase workflow and activate the license for the right user.
224
+ FS.PostMessage.post('context', {
225
+ plugin_id : '<?php echo $fs->get_id() ?>',
226
+ plugin_public_key: '<?php echo $fs->get_public_key() ?>',
227
+ plugin_version : '<?php echo $fs->get_plugin_version() ?>',
228
+ plugin_slug : '<?php echo $slug ?>',
229
+ site_name : '<?php echo get_bloginfo('name') ?>',
230
+ platform_version : '<?php echo get_bloginfo('version') ?>',
231
+ language : '<?php echo get_bloginfo('language') ?>',
232
+ charset : '<?php echo get_bloginfo('charset') ?>',
233
+ return_url : '<?php echo $return_url ?>',
234
+ account_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url(
235
+ 'account',
236
+ array('fs_action' => 'sync_user')
237
+ ), 'sync_user') ?>',
238
+ activation_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('',
239
+ array(
240
+ 'fs_action' => $slug . '_activate_new',
241
+ 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
242
+
243
+ )),
244
+ $slug . '_activate_new') ?>'
245
+ }, iframe[0]);
246
+ });
247
+
248
+ FS.PostMessage.receiveOnce('get_dimensions', function (data) {
249
+ console.debug('receiveOnce', 'get_dimensions');
250
+
251
+ FS.PostMessage.post('dimensions', {
252
+ height : $(document.body).height(),
253
+ scrollTop: $(document).scrollTop()
254
+ }, iframe[0]);
255
+ });
256
+ });
257
+ })(jQuery);
258
+ </script>
259
+ </div>
260
+ <?php fs_require_template( 'powered-by.php' ) ?>
freemius/templates/connect.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.7
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $slug = $VARS['slug'];
14
+ $fs = freemius( $slug );
15
+ $is_pending_activation = $fs->is_pending_activation();
16
+
17
+ $fs->_enqueue_connect_essentials();
18
+
19
+ $current_user = Freemius::_get_current_wp_user();
20
+
21
+ $first_name = $current_user->user_firstname;
22
+ if ( empty( $first_name ) ) {
23
+ $first_name = $current_user->nickname;
24
+ }
25
+
26
+ $site_url = get_site_url();
27
+ $protocol_pos = strpos( $site_url, '://' );
28
+ if ( false !== $protocol_pos ) {
29
+ $site_url = substr( $site_url, $protocol_pos + 3 );
30
+ }
31
+
32
+ $freemius_site_url = $fs->has_paid_plan() ?
33
+ 'https://freemius.com/wordpress/' :
34
+ // Insights platform information.
35
+ 'https://freemius.com/wordpress/insights/';
36
+ ?>
37
+ <div id="fs_connect" class="wrap<?php if ( ! $fs->enable_anonymous() || $is_pending_activation ) {
38
+ echo ' fs-anonymous-disabled';
39
+ } ?>">
40
+ <div class="fs-visual">
41
+ <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
42
+ <i class="dashicons dashicons-plus fs-first"></i>
43
+ <?php
44
+ $vars = array( 'slug' => $slug );
45
+ fs_require_once_template( 'plugin-icon.php', $vars );
46
+ ?>
47
+ <i class="dashicons dashicons-plus fs-second"></i>
48
+ <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
49
+ </div>
50
+ <div class="fs-content">
51
+ <p><?php
52
+ if ( $is_pending_activation ) {
53
+ echo $fs->apply_filters( 'pending_activation_message', sprintf(
54
+ __fs( 'thanks-x', $slug ) . '<br>' .
55
+ __fs( 'pending-activation-message', $slug ),
56
+ $first_name,
57
+ '<b>' . $fs->get_plugin_name() . '</b>',
58
+ '<b>' . $current_user->user_email . '</b>'
59
+ ) );
60
+ } else {
61
+ $filter = 'connect_message';
62
+ $default_optin_message = 'connect-message';
63
+
64
+ if ( $fs->is_plugin_update() ) {
65
+ // If Freemius was added on a plugin update, set different
66
+ // opt-in message.
67
+ $default_optin_message = 'connect-message_on-update';
68
+
69
+ // If user customized the opt-in message on update, use
70
+ // that message. Otherwise, fallback to regular opt-in
71
+ // custom message if exist.
72
+ if ( $fs->has_filter( 'connect_message_on_update' ) ) {
73
+ $filter = 'connect_message_on_update';
74
+ }
75
+ }
76
+
77
+ echo $fs->apply_filters( $filter,
78
+ sprintf(
79
+ __fs( 'hey-x', $slug ) . '<br>' .
80
+ __fs( $default_optin_message, $slug ),
81
+ $first_name,
82
+ '<b>' . $fs->get_plugin_name() . '</b>',
83
+ '<b>' . $current_user->user_login . '</b>',
84
+ '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
85
+ '<a href="' . $freemius_site_url . '" target="_blank">freemius.com</a>'
86
+ ),
87
+ $first_name,
88
+ $fs->get_plugin_name(),
89
+ $current_user->user_login,
90
+ '<a href="' . $site_url . '" target="_blank">' . $site_url . '</a>',
91
+ '<a href="' . $freemius_site_url . '" target="_blank">freemius.com</a>'
92
+ );
93
+ }
94
+ ?></p>
95
+ </div>
96
+ <div class="fs-actions">
97
+ <?php if ( $fs->enable_anonymous() && ! $is_pending_activation ) : ?>
98
+ <a href="<?php echo wp_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $slug . '_skip_activation' ) ), $slug . '_skip_activation' ) ?>"
99
+ class="button button-secondary" tabindex="2"><?php _efs( 'skip', $slug ) ?></a>
100
+ <?php endif ?>
101
+
102
+ <?php $fs_user = Freemius::_get_user_by_email( $current_user->user_email ) ?>
103
+ <?php if ( is_object( $fs_user ) && ! $is_pending_activation ) : ?>
104
+ <form action="" method="POST">
105
+ <input type="hidden" name="fs_action" value="<?php echo $slug ?>_activate_existing">
106
+ <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
107
+ <button class="button button-primary" tabindex="1"
108
+ type="submit"><?php _efs( 'opt-in-connect', $slug ) ?></button>
109
+ </form>
110
+ <?php else : ?>
111
+ <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
112
+ <?php $params = $fs->get_opt_in_params() ?>
113
+ <?php foreach ( $params as $name => $value ) : ?>
114
+ <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
115
+ <?php endforeach ?>
116
+ <button class="button button-primary" tabindex="1"
117
+ type="submit"><?php _efs( $is_pending_activation ? 'resend-activation-email' : 'opt-in-connect', $slug ) ?></button>
118
+ </form>
119
+ <?php endif ?>
120
+ </div><?php
121
+
122
+ // Set core permission list items.
123
+ $permissions = array(
124
+ 'profile' => array(
125
+ 'icon-class' => 'dashicons dashicons-admin-users',
126
+ 'label' => __fs( 'permissions-profile' ),
127
+ 'desc' => __fs( 'permissions-profile_desc' ),
128
+ 'priority' => 5,
129
+ ),
130
+ 'site' => array(
131
+ 'icon-class' => 'dashicons dashicons-wordpress',
132
+ 'label' => __fs( 'permissions-site' ),
133
+ 'desc' => __fs( 'permissions-site_desc' ),
134
+ 'priority' => 10,
135
+ ),
136
+ 'events' => array(
137
+ 'icon-class' => 'dashicons dashicons-admin-plugins',
138
+ 'label' => __fs( 'permissions-events' ),
139
+ 'desc' => __fs( 'permissions-events_desc' ),
140
+ 'priority' => 20,
141
+ ),
142
+ );
143
+
144
+ // Add newsletter permissions if enabled.
145
+ if ( $fs->is_permission_requested( 'newsletter' ) ) {
146
+ $permissions['newsletter'] = array(
147
+ 'icon-class' => 'dashicons dashicons-email-alt',
148
+ 'label' => __fs( 'permissions-newsletter' ),
149
+ 'desc' => __fs( 'permissions-newsletter_desc' ),
150
+ 'priority' => 15,
151
+ );
152
+ }
153
+
154
+ // Allow filtering of the permissions list.
155
+ $permissions = $fs->apply_filters( 'permission_list', $permissions );
156
+
157
+ // Sort by priority.
158
+ uasort( $permissions, 'fs_sort_by_priority' );
159
+
160
+ if ( ! empty( $permissions ) ) : ?>
161
+ <div class="fs-permissions">
162
+ <a class="fs-trigger" href="#"><?php _efs( 'what-permissions', $slug ) ?></a>
163
+ <ul><?php
164
+ foreach ( $permissions as $id => $permission ) : ?>
165
+ <li id="fs-permission-<?php esc_attr_e( $id ); ?>"
166
+ class="fs-permission fs-<?php esc_attr_e( $id ); ?>">
167
+ <i class="<?php esc_attr_e( $permission['icon-class'] ); ?>"></i>
168
+
169
+ <div>
170
+ <span><?php esc_html_e( $permission['label'] ); ?></span>
171
+
172
+ <p><?php esc_html_e( $permission['desc'] ); ?></p>
173
+ </div>
174
+ </li>
175
+ <?php endforeach; ?>
176
+ </ul>
177
+ </div>
178
+ <?php endif; ?>
179
+
180
+ <div class="fs-terms">
181
+ <a href="https://freemius.com/privacy/" target="_blank"><?php _efs( 'privacy-policy', $slug ) ?></a>
182
+ &nbsp;&nbsp;-&nbsp;&nbsp;
183
+ <a href="https://freemius.com/terms/" target="_blank"><?php _efs( 'tos', $slug ) ?></a>
184
+ </div>
185
+ </div>
186
+ <script type="text/javascript">
187
+ (function ($) {
188
+ $('.button').on('click', function () {
189
+ // Set loading mode.
190
+ $(document.body).css({'cursor': 'wait'});
191
+ });
192
+ $('.button.button-primary').on('click', function () {
193
+ $(this).addClass('fs-loading');
194
+ $(this).html('<?php _efs( $is_pending_activation ? 'sending-email' : 'activating' , $slug ) ?>...').css({'cursor': 'wait'});
195
+ });
196
+ $('.fs-permissions .fs-trigger').on('click', function () {
197
+ $('.fs-permissions').toggleClass('fs-open');
198
+ });
199
+ })(jQuery);
200
+ </script>
freemius/templates/contact.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ wp_enqueue_script( 'jquery' );
14
+ wp_enqueue_script( 'json2' );
15
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17
+ fs_enqueue_local_style( 'fs_checkout', '/admin/common.css' );
18
+
19
+ $slug = $VARS['slug'];
20
+ $fs = freemius( $slug );
21
+
22
+ $context_params = array(
23
+ 'plugin_id' => $fs->get_id(),
24
+ 'plugin_public_key' => $fs->get_public_key(),
25
+ 'plugin_version' => $fs->get_plugin_version(),
26
+ );
27
+
28
+
29
+ // Get site context secure params.
30
+ if ( $fs->is_registered() ) {
31
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
32
+ $fs->get_site(),
33
+ time(),
34
+ 'contact'
35
+ ) );
36
+ }
37
+
38
+ $query_params = array_merge( $_GET, array_merge( $context_params, array(
39
+ 'plugin_version' => $fs->get_plugin_version(),
40
+ 'wp_login_url' => wp_login_url(),
41
+ 'site_url' => get_site_url(),
42
+ // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
43
+ ) ) );
44
+ ?>
45
+ <div class="fs-secure-notice">
46
+ <i class="dashicons dashicons-lock"></i>
47
+ <span><b>Secure HTTPS contact page</b>, running via iframe from external domain</span>
48
+ </div>
49
+ <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
50
+ <div id="iframe"></div>
51
+ <script type="text/javascript">
52
+ (function ($) {
53
+ $(function () {
54
+
55
+ var
56
+ // Keep track of the iframe height.
57
+ iframe_height = 800,
58
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
59
+ src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
60
+
61
+ // Append the Iframe into the DOM.
62
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
63
+ .appendTo('#iframe');
64
+
65
+ FS.PostMessage.init(base_url);
66
+ FS.PostMessage.receive('height', function (data) {
67
+ var h = data.height;
68
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
69
+ iframe_height = h;
70
+ $("#iframe iframe").height(iframe_height + 'px');
71
+ }
72
+ });
73
+ });
74
+ })(jQuery);
75
+ </script>
76
+ </div>
77
+ <?php fs_require_template( 'powered-by.php' ) ?>
freemius/templates/deactivation-feedback-modal.php ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.2
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $slug = $VARS['slug'];
14
+ $fs = freemius( $slug );
15
+
16
+ $confirmation_message = $fs->apply_filters( 'uninstall_confirmation_message', '' );
17
+
18
+ $reasons = $VARS['reasons'];
19
+
20
+ $reasons_list_items_html = '';
21
+
22
+ foreach ( $reasons as $reason ) {
23
+ $list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
24
+ $reasons_list_items_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $reason['input_type'] . '" data-input-placeholder="' . $reason['input_placeholder'] . '"><label><span><input type="radio" name="selected-reason" value="' . $reason['id'] . '"/></span><span>' . $reason['text'] . '</span></label></li>';
25
+ }
26
+ ?>
27
+ <script type="text/javascript">
28
+ (function ($) {
29
+ var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
30
+ modalHtml =
31
+ '<div class="fs-modal<?php echo empty( $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
32
+ + ' <div class="fs-modal-dialog">'
33
+ + ' <div class="fs-modal-body">'
34
+ + ' <div class="fs-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
35
+ + ' <div class="fs-modal-panel active" data-panel-id="reasons"><h3><strong><?php printf( __fs( 'deactivation-share-reason' , $slug ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
36
+ + ' </div>'
37
+ + ' <div class="fs-modal-footer">'
38
+ + ' <a href="#" class="button button-secondary button-deactivate"></a>'
39
+ + ' <a href="#" class="button button-primary button-close"><?php printf( __fs( 'deactivation-modal-button-cancel' , $slug ) ); ?></a>'
40
+ + ' </div>'
41
+ + ' </div>'
42
+ + '</div>',
43
+ $modal = $(modalHtml),
44
+ $deactivateLink = $('#the-list .deactivate > [data-slug=<?php echo $VARS['slug']; ?>].fs-slug').prev();
45
+
46
+ $modal.appendTo($('body'));
47
+
48
+ registerEventHandlers();
49
+
50
+ function registerEventHandlers() {
51
+ $deactivateLink.click(function (evt) {
52
+ evt.preventDefault();
53
+
54
+ showModal();
55
+ });
56
+
57
+ $modal.on('click', '.button', function (evt) {
58
+ evt.preventDefault();
59
+
60
+ if ($(this).hasClass('disabled')) {
61
+ return;
62
+ }
63
+
64
+ var _parent = $(this).parents('.fs-modal:first');
65
+ var _this = $(this);
66
+
67
+ if (_this.hasClass('allow-deactivate')) {
68
+ var $radio = $('input[type="radio"]:checked');
69
+
70
+ if (0 === $radio.length) {
71
+ // If no selected reason, just deactivate the plugin.
72
+ window.location.href = $deactivateLink.attr('href');
73
+ return;
74
+ }
75
+
76
+ var $selected_reason = $radio.parents('li:first'),
77
+ $input = $selected_reason.find('textarea, input[type="text"]');
78
+
79
+ $.ajax({
80
+ url : ajaxurl,
81
+ method : 'POST',
82
+ data : {
83
+ 'action' : 'submit-uninstall-reason',
84
+ 'reason_id' : $radio.val(),
85
+ 'reason_info': ( 0 !== $input.length ) ? $input.val().trim() : ''
86
+ },
87
+ beforeSend: function () {
88
+ _parent.find('.button').addClass('disabled');
89
+ _parent.find('.button-secondary').text('Processing...');
90
+ },
91
+ complete : function () {
92
+ // Do not show the dialog box, deactivate the plugin.
93
+ window.location.href = $deactivateLink.attr('href');
94
+ }
95
+ });
96
+ } else if (_this.hasClass('button-deactivate')) {
97
+ // Change the Deactivate button's text and show the reasons panel.
98
+ _parent.find('.button-deactivate').addClass('allow-deactivate');
99
+
100
+ showPanel('reasons');
101
+ }
102
+ });
103
+
104
+ $modal.on('click', 'input[type="radio"]', function () {
105
+ var _parent = $(this).parents('li:first');
106
+
107
+ $modal.find('.reason-input').remove();
108
+ $modal.find('.button-deactivate').text('<?php printf( __fs( 'deactivation-modal-button-submit' , $slug ) ); ?>');
109
+
110
+ if (_parent.hasClass('has-input')) {
111
+ var inputType = _parent.data('input-type'),
112
+ inputPlaceholder = _parent.data('input-placeholder'),
113
+ reasonInputHtml = '<div class="reason-input">' + ( ( 'textfield' === inputType ) ? '<input type="text" />' : '<textarea rows="5"></textarea>' ) + '</div>';
114
+
115
+ _parent.append($(reasonInputHtml));
116
+ _parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
117
+ }
118
+ });
119
+
120
+ // If the user has clicked outside the window, cancel it.
121
+ $modal.on('click', function (evt) {
122
+ var $target = $(evt.target);
123
+
124
+ // If the user has clicked anywhere in the modal dialog, just return.
125
+ if ($target.hasClass('fs-modal-body') || $target.hasClass('fs-modal-footer')) {
126
+ return;
127
+ }
128
+
129
+ // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
130
+ if (!$target.hasClass('button-close') && ( $target.parents('.fs-modal-body').length > 0 || $target.parents('.fs-modal-footer').length > 0 )) {
131
+ return;
132
+ }
133
+
134
+ closeModal();
135
+ });
136
+ }
137
+
138
+ function showModal() {
139
+ resetModal();
140
+
141
+ // Display the dialog box.
142
+ $modal.addClass('active');
143
+
144
+ $('body').addClass('has-fs-modal');
145
+ }
146
+
147
+ function closeModal() {
148
+ $modal.removeClass('active');
149
+
150
+ $('body').removeClass('has-fs-modal');
151
+ }
152
+
153
+ function resetModal() {
154
+ $modal.find('.button').removeClass('disabled');
155
+
156
+ // Uncheck all radio buttons.
157
+ $modal.find('input[type="radio"]').prop('checked', false);
158
+
159
+ // Remove all input fields ( textfield, textarea ).
160
+ $modal.find('.reason-input').remove();
161
+
162
+ var $deactivateButton = $modal.find('.button-deactivate');
163
+
164
+ /*
165
+ * If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
166
+ * that clicking the deactivate button will actually deactivate the plugin.
167
+ */
168
+ if ($modal.hasClass('no-confirmation-message')) {
169
+ $deactivateButton.addClass('allow-deactivate');
170
+
171
+ showPanel('reasons');
172
+ } else {
173
+ $deactivateButton.removeClass('allow-deactivate');
174
+
175
+ showPanel('confirm');
176
+ }
177
+ }
178
+
179
+ function showPanel(panelType) {
180
+ $modal.find('.fs-modal-panel').removeClass('active ');
181
+ $modal.find('[data-panel-id="' + panelType + '"]').addClass('active');
182
+
183
+ updateButtonLabels();
184
+ }
185
+
186
+ function updateButtonLabels() {
187
+ var $deactivateButton = $modal.find('.button-deactivate');
188
+
189
+ // Reset the deactivate button's text.
190
+ if ('confirm' === getCurrentPanel()) {
191
+ $deactivateButton.text('<?php printf( __fs( 'deactivation-modal-button-confirm' , $slug ) ); ?>');
192
+ } else {
193
+ $deactivateButton.text('<?php printf( __fs( 'deactivate' , $slug ) ); ?>');
194
+ }
195
+ }
196
+
197
+ function getCurrentPanel() {
198
+ return $modal.find('.fs-modal-panel.active').attr('data-panel-id');
199
+ }
200
+ })(jQuery);
201
+ </script>
freemius/templates/debug.php ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.1
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ global $fs_active_plugins;
14
+
15
+ $fs_options = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
16
+ ?>
17
+ <h1><?php echo __fs( 'Freemius Debug' ) . ' - ' . __fs( 'SDK' ) . ' v.' . $fs_active_plugins->newest->version ?></h1>
18
+ <div>
19
+ <!-- Debugging Switch -->
20
+ <?php //$debug_mode = get_option( 'fs_debug_mode', null ) ?>
21
+ <span class="switch-label"><?php _efs( 'debugging' ) ?></span>
22
+
23
+ <div class="switch <?php echo WP_FS__DEBUG_SDK ? 'off' : 'on' ?>">
24
+ <div class="toggle"></div>
25
+ <span class="on"><?php _efs( 'on' ) ?></span>
26
+ <span class="off"><?php _efs( 'off' ) ?></span>
27
+ </div>
28
+ <script type="text/javascript">
29
+ (function ($) {
30
+ $(document).ready(function () {
31
+ // Switch toggle
32
+ $('.switch').click(function () {
33
+ $(this)
34
+ .toggleClass('on')
35
+ .toggleClass('off');
36
+
37
+ $.post(ajaxurl, {
38
+ action: 'fs_toggle_debug_mode',
39
+ is_on : ($(this).hasClass('off') ? 1 : 0)
40
+ }, function (response) {
41
+ if (1 == response) {
42
+ // Refresh page on success.
43
+ location.reload();
44
+ }
45
+ });
46
+ });
47
+ });
48
+ }(jQuery));
49
+ </script>
50
+ </div>
51
+ <h2><?php _efs( 'actions' ) ?></h2>
52
+ <table>
53
+ <tbody>
54
+ <tr>
55
+ <td>
56
+ <!-- Delete All Accounts -->
57
+ <form action="" method="POST">
58
+ <input type="hidden" name="fs_action" value="restart_freemius">
59
+ <?php wp_nonce_field( 'restart_freemius' ) ?>
60
+ <button class="button button-primary"
61
+ onclick="if (confirm('<?php _efs( 'delete-all-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'delete-all-accounts' ) ?></button>
62
+ </form>
63
+ </td>
64
+ <td>
65
+ <!-- Clear API Cache -->
66
+ <form action="" method="POST">
67
+ <input type="hidden" name="fs_clear_api_cache" value="true">
68
+ <button class="button button-primary"><?php _efs( 'clear-api-cache' ) ?></button>
69
+ </form>
70
+ </td>
71
+ <td>
72
+ <!-- Sync Data with Server -->
73
+ <form action="" method="POST">
74
+ <input type="hidden" name="background_sync" value="true">
75
+ <button class="button button-primary"><?php _efs( 'sync-data-from-server' ) ?></button>
76
+ </form>
77
+ </td>
78
+ </tr>
79
+ </tbody>
80
+ </table>
81
+ <h2><?php _efs( 'sdk-versions' ) ?></h2>
82
+ <table id="fs_sdks" class="widefat">
83
+ <thead>
84
+ <tr>
85
+ <th><?php _efs( 'version' ) ?></th>
86
+ <th><?php _efs( 'sdk-path' ) ?></th>
87
+ <th><?php _efs( 'plugin-path' ) ?></th>
88
+ <th><?php _efs( 'is-active' ) ?></th>
89
+ </tr>
90
+ </thead>
91
+ <tbody>
92
+ <?php foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) : ?>
93
+ <?php $is_active = ( WP_FS__SDK_VERSION == $data->version ) ?>
94
+ <tr<?php if ( $is_active ) {
95
+ echo ' style="background: #E6FFE6; font-weight: bold"';
96
+ } ?>>
97
+ <td><?php echo $data->version ?></td>
98
+ <td><?php echo $sdk_path ?></td>
99
+ <td><?php echo $data->plugin_path ?></td>
100
+ <td><?php echo ( $is_active ) ? 'Active' : 'Inactive' ?></td>
101
+ </tr>
102
+ <?php endforeach ?>
103
+ </tbody>
104
+ </table>
105
+ <?php $plugins = $fs_options->get_option( 'plugins' ) ?>
106
+ <?php if ( is_array( $plugins ) && 0 < count( $plugins ) ) : ?>
107
+ <h2><?php _efs( 'plugins' ) ?></h2>
108
+ <table id="fs_plugins" class="widefat">
109
+ <thead>
110
+ <tr>
111
+ <th><?php _efs( 'id' ) ?></th>
112
+ <th><?php _efs( 'slug' ) ?></th>
113
+ <th><?php _efs( 'version' ) ?></th>
114
+ <th><?php _efs( 'title' ) ?></th>
115
+ <th><?php _efs( 'api' ) ?></th>
116
+ <th><?php _efs( 'freemius-state' ) ?></th>
117
+ <th><?php _efs( 'plugin-path' ) ?></th>
118
+ <th><?php _efs( 'public-key' ) ?></th>
119
+ </tr>
120
+ </thead>
121
+ <tbody>
122
+ <?php foreach ( $plugins as $slug => $data ) : ?>
123
+ <?php $is_active = is_plugin_active( $data->file ) ?>
124
+ <?php $fs = $is_active ? freemius( $slug ) : null ?>
125
+ <tr<?php if ( $is_active ) {
126
+ echo ' style="background: #E6FFE6; font-weight: bold"';
127
+ } ?>>
128
+ <td><?php echo $data->id ?></td>
129
+ <td><?php echo $slug ?></td>
130
+ <td><?php echo $data->version ?></td>
131
+ <td><?php echo $data->title ?></td>
132
+ <td><?php if ( $is_active ) {
133
+ echo $fs->has_api_connectivity() ?
134
+ __fs( 'connected' ) :
135
+ __fs( 'blocked' );
136
+ } ?></td>
137
+ <td><?php if ( $is_active ) {
138
+ echo $fs->is_on() ?
139
+ __fs( 'on' ) :
140
+ __fs( 'off' );
141
+ } ?></td>
142
+ <td><?php echo $data->file ?></td>
143
+ <td><?php echo $data->public_key ?></td>
144
+ </tr>
145
+ <?php endforeach ?>
146
+ </tbody>
147
+ </table>
148
+ <?php endif ?>
149
+ <?php
150
+ /**
151
+ * @var FS_Site[] $sites
152
+ */
153
+ $sites = $VARS['sites'];
154
+ ?>
155
+ <?php if ( is_array( $sites ) && 0 < count( $sites ) ) : ?>
156
+ <h2><?php _efs( 'plugin-installs' ) ?> / <?php _efs( 'sites' ) ?></h2>
157
+ <table id="fs_installs" class="widefat">
158
+ <thead>
159
+ <tr>
160
+ <th><?php _efs( 'id' ) ?></th>
161
+ <th><?php _efs( 'slug' ) ?></th>
162
+ <th><?php _efs( 'plan' ) ?></th>
163
+ <th><?php _efs( 'public-key' ) ?></th>
164
+ <th><?php _efs( 'secret-key' ) ?></th>
165
+ </tr>
166
+ </thead>
167
+ <tbody>
168
+ <?php foreach ( $sites as $slug => $site ) : ?>
169
+ <tr>
170
+ <td><?php echo $site->id ?></td>
171
+ <td><?php echo $slug ?></td>
172
+ <td><?php
173
+ echo is_object( $site->plan ) ?
174
+ base64_decode( $site->plan->name ) :
175
+ ''
176
+ ?></td>
177
+ <td><?php echo $site->public_key ?></td>
178
+ <td><?php echo $site->secret_key ?></td>
179
+ </tr>
180
+ <?php endforeach ?>
181
+ </tbody>
182
+ </table>
183
+ <?php endif ?>
184
+ <?php
185
+ $addons = $VARS['addons'];
186
+ ?>
187
+ <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?>
188
+ <h2><?php printf( __fs( 'addons-of-x' ), $plugin_id ) ?></h2>
189
+ <table id="fs_addons" class="widefat">
190
+ <thead>
191
+ <tr>
192
+ <th><?php _efs( 'id' ) ?></th>
193
+ <th><?php _efs( 'title' ) ?></th>
194
+ <th><?php _efs( 'slug' ) ?></th>
195
+ <th><?php _efs( 'version' ) ?></th>
196
+ <th><?php _efs( 'public-key' ) ?></th>
197
+ <th><?php _efs( 'secret-key' ) ?></th>
198
+ </tr>
199
+ </thead>
200
+ <tbody>
201
+ <?php
202
+ /**
203
+ * @var FS_Plugin[] $plugin_addons
204
+ */
205
+ foreach ( $plugin_addons as $addon ) : ?>
206
+ <tr>
207
+ <td><?php echo $addon->id ?></td>
208
+ <td><?php echo $addon->title ?></td>
209
+ <td><?php echo $addon->slug ?></td>
210
+ <td><?php echo $addon->version ?></td>
211
+ <td><?php echo $addon->public_key ?></td>
212
+ <td><?php echo $addon->secret_key ?></td>
213
+ </tr>
214
+ <?php endforeach ?>
215
+ </tbody>
216
+ </table>
217
+ <?php endforeach ?>
218
+ <?php
219
+ /**
220
+ * @var FS_User[] $users
221
+ */
222
+ $users = $VARS['users'];
223
+ ?>
224
+ <?php if ( is_array( $users ) && 0 < count( $users ) ) : ?>
225
+ <h2><?php _efs( 'users' ) ?></h2>
226
+ <table id="fs_users" class="widefat">
227
+ <thead>
228
+ <tr>
229
+ <th><?php _efs( 'id' ) ?></th>
230
+ <th><?php _efs( 'name' ) ?></th>
231
+ <th><?php _efs( 'email' ) ?></th>
232
+ <th><?php _efs( 'verified' ) ?></th>
233
+ <th><?php _efs( 'public-key' ) ?></th>
234
+ <th><?php _efs( 'secret-key' ) ?></th>
235
+ </tr>
236
+ </thead>
237
+ <tbody>
238
+ <?php foreach ( $users as $user_id => $user ) : ?>
239
+ <tr>
240
+ <td><?php echo $user->id ?></td>
241
+ <td><?php echo $user->get_name() ?></td>
242
+ <td><a href="mailto:<?php esc_attr_e($user->email) ?>"><?php echo $user->email ?></a></td>
243
+ <td><?php echo json_encode( $user->is_verified ) ?></td>
244
+ <td><?php echo $user->public_key ?></td>
245
+ <td><?php echo $user->secret_key ?></td>
246
+ </tr>
247
+ <?php endforeach ?>
248
+ </tbody>
249
+ </table>
250
+ <?php endif ?>
freemius/templates/debug/api-calls.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ if ( class_exists( 'Freemius_Api' ) ) {
14
+ $logger = Freemius_Api::GetLogger();
15
+ } else {
16
+ $logger = array();
17
+ }
18
+
19
+ $counters = array(
20
+ 'GET' => 0,
21
+ 'POST' => 0,
22
+ 'PUT' => 0,
23
+ 'DELETE' => 0
24
+ );
25
+
26
+ $show_body = false;
27
+ foreach ( $logger as $log ) {
28
+ $counters[ $log['method'] ] ++;
29
+
30
+ if ( ! is_null( $log['body'] ) ) {
31
+ $show_body = true;
32
+ }
33
+ }
34
+
35
+ $pretty_print = $show_body && defined( 'JSON_PRETTY_PRINT' ) && version_compare( phpversion(), '5.3', '>=' );
36
+
37
+ $root_path_len = strlen( ABSPATH );
38
+ ?>
39
+ <h1><?php _efs( 'API' ) ?></h1>
40
+
41
+ <h2><span>Total Time:</span><?php echo Freemius_Debug_Bar_Panel::total_time() ?></h2>
42
+
43
+ <h2><span>Total Requests:</span><?php echo Freemius_Debug_Bar_Panel::requests_count() ?></h2>
44
+ <?php foreach ( $counters as $method => $count ) : ?>
45
+ <h2><span><?php echo $method ?>:</span><?php echo number_format( $count ) ?></h2>
46
+ <?php endforeach ?>
47
+ <table class="widefat">
48
+ <thead>
49
+ <tr>
50
+ <th>#</th>
51
+ <th><?php _efs( 'Method' ) ?></th>
52
+ <th><?php _efs( 'Code' ) ?></th>
53
+ <th><?php _efs( 'Length' ) ?></th>
54
+ <th><?php _efs( 'Path' ) ?></th>
55
+ <?php if ( $show_body ) : ?>
56
+ <th><?php _efs( 'Body' ) ?></th>
57
+ <?php endif ?>
58
+ <th><?php _efs( 'Result' ) ?></th>
59
+ <th><?php _efs( 'Start' ) ?></th>
60
+ <th><?php _efs( 'End' ) ?></th>
61
+ </tr>
62
+ </thead>
63
+ <tbody>
64
+ <?php foreach ( $logger as $log ) : ?>
65
+ <tr>
66
+ <td><?php echo $log['id'] ?>.</td>
67
+ <td><?php echo $log['method'] ?></td>
68
+ <td><?php echo $log['code'] ?></td>
69
+ <td><?php echo number_format( 100 * $log['total'], 2 ) . ' ' . __fs( 'ms' ) ?></td>
70
+ <td>
71
+ <?php
72
+ printf( '<a href="#" onclick="jQuery(this).parent().find(\'table\').toggle(); return false;">%s</a>',
73
+ $log['path']
74
+ );
75
+ ?>
76
+ <table class="widefat" style="display: none">
77
+ <tbody>
78
+ <?php for ( $i = 0, $bt = $log['backtrace'], $len = count( $bt ); $i < $len; $i ++ ) : ?>
79
+ <tr>
80
+ <td><?php echo( $len - $i ) ?></td>
81
+ <td><?php if ( isset( $bt[ $i ]['function'] ) ) {
82
+ echo ( isset( $bt[ $i ]['class'] ) ? $bt[ $i ]['class'] . $bt[ $i ]['type'] : '' ) . $bt[ $i ]['function'];
83
+ } ?></td>
84
+ <td><?php if ( isset( $bt[ $i ]['file'] ) ) {
85
+ echo substr( $bt[ $i ]['file'], $root_path_len ) . ':' . $bt[ $i ]['line'];
86
+ } ?></td>
87
+ </tr>
88
+ <?php endfor ?>
89
+ </tbody>
90
+ </table>
91
+ </td>
92
+ <?php if ( $show_body ) : ?>
93
+ <td>
94
+ <?php if ( 'GET' !== $log['method'] ) : ?>
95
+ <?php
96
+ $body = $log['body'];
97
+ printf(
98
+ '<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
99
+ substr( $body, 0, 32 ) . ( 32 < strlen( $body ) ? '...' : '' )
100
+ );
101
+ if ( $pretty_print ) {
102
+ $body = json_encode( json_decode( $log['body'] ), JSON_PRETTY_PRINT );
103
+ }
104
+ ?>
105
+ <pre style="display: none"><code><?php echo esc_html( $body ) ?></code></pre>
106
+ <?php endif ?>
107
+ </td>
108
+ <?php endif ?>
109
+ <td>
110
+ <?php
111
+ $result = $log['result'];
112
+
113
+ $is_not_empty_result = ( is_string( $result ) && ! empty( $result ) );
114
+
115
+ if ( $is_not_empty_result ) {
116
+ printf(
117
+ '<a href="#" onclick="jQuery(this).parent().find(\'pre\').toggle(); return false;">%s</a>',
118
+ substr( $result, 0, 32 ) . ( 32 < strlen( $result ) ? '...' : '' )
119
+ );
120
+ }
121
+
122
+ if ( $is_not_empty_result && $pretty_print ) {
123
+ $decoded = json_decode( $result );
124
+ if ( ! is_null( $decoded ) ) {
125
+ $result = json_encode( $decoded, JSON_PRETTY_PRINT );
126
+ }
127
+ } else {
128
+ $result = is_string( $result ) ? $result : json_encode( $result );
129
+ }
130
+ ?>
131
+ <pre<?php if ( $is_not_empty_result ) : ?> style="display: none"<?php endif ?>><code><?php echo esc_html( $result ) ?></code></pre>
132
+ </td>
133
+ <td><?php echo number_format( 100 * ( $log['start'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . __fs( 'ms' ) ?></td>
134
+ <td><?php echo number_format( 100 * ( $log['end'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . __fs( 'ms' ) ?></td>
135
+ </tr>
136
+ <?php endforeach ?>
137
+ </tbody>
138
+ </table>
freemius/templates/debug/logger.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $log_book = FS_Logger::get_log();
14
+ ?>
15
+ <h1><?php _efs( 'Log' ) ?></h1>
16
+
17
+ <table class="widefat" style="font-size: 11px;">
18
+ <thead>
19
+ <tr>
20
+ <th>#</th>
21
+ <th><?php _efs( 'id' ) ?></th>
22
+ <th><?php _efs( 'type' ) ?></th>
23
+ <th><?php _efs( 'function' ) ?></th>
24
+ <th><?php _efs( 'message' ) ?></th>
25
+ <th><?php _efs( 'file' ) ?></th>
26
+ <th><?php _efs( 'timestamp' ) ?></th>
27
+ </tr>
28
+ </thead>
29
+ <tbody>
30
+
31
+ <?php $i = 0;
32
+ foreach ( $log_book as $log ) : ?>
33
+ <tr<?php if ( $i % 2 ) {
34
+ echo ' class="alternate"';
35
+ } ?>>
36
+ <td><?php echo $log['cnt'] ?>.</td>
37
+ <td><?php echo $log['logger']->get_id() ?></td>
38
+ <td><?php echo $log['type'] ?></td>
39
+ <td><b><code style="color: blue;"><?php echo $log['function'] ?></code></b></td>
40
+ <td>
41
+ <?php
42
+ printf(
43
+ '<a href="#" style="color: darkorange !important;" onclick="jQuery(this).parent().find(\'div\').toggle(); return false;"><nobr>%s</nobr></a>',
44
+ substr( $log['msg'], 0, 32 ) . ( 32 < strlen( $log['msg'] ) ? '...' : '' )
45
+ );
46
+ ?>
47
+ <div style="display: none;">
48
+ <b style="color: darkorange;"><?php echo $log['msg'] ?></b>
49
+ </div>
50
+ </td>
51
+ <td><?php
52
+ if ( isset( $log['file'] ) ) {
53
+ echo substr( $log['file'], $log['logger']->get_file() ) . ':' . $log['line'] . ')';
54
+ }
55
+ ?></td>
56
+ <td><?php echo number_format( 100 * ( $log['timestamp'] - WP_FS__SCRIPT_START_TIME ), 2 ) . ' ' . __fs( 'ms' ) ?></td>
57
+ </tr>
58
+ <?php $i ++; endforeach ?>
59
+ </tbody>
60
+ </table>
freemius/templates/debug/scheduled-crons.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.7.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $fs_options = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
14
+ $plugins = $fs_options->get_option( 'plugins' );
15
+ $scheduled_crons = array();
16
+ if ( is_array( $plugins ) && 0 < count( $plugins ) ) {
17
+ foreach ( $plugins as $slug => $data ) {
18
+ $fs = freemius( $slug );
19
+
20
+ $next_execution = $fs->next_sync_cron();
21
+ $last_execution = $fs->last_sync_cron();
22
+
23
+ if ( false !== $next_execution ) {
24
+ $scheduled_crons[ $slug ][] = array(
25
+ 'name' => $fs->get_plugin_name(),
26
+ 'slug' => $slug,
27
+ 'type' => 'sync_cron',
28
+ 'last' => $last_execution,
29
+ 'next' => $next_execution,
30
+ );
31
+ }
32
+
33
+ $next_install_execution = $fs->next_install_sync();
34
+ $last_install_execution = $fs->last_install_sync();
35
+
36
+ if ( false !== $next_install_execution || false !== $last_install_execution ) {
37
+ $scheduled_crons[ $slug ][] = array(
38
+ 'name' => $fs->get_plugin_name(),
39
+ 'slug' => $slug,
40
+ 'type' => 'install_sync',
41
+ 'last' => $last_install_execution,
42
+ 'next' => $next_install_execution,
43
+ );
44
+ }
45
+ }
46
+ }
47
+ ?>
48
+ <h1><?php _efs( 'scheduled-crons' ) ?></h1>
49
+ <table class="widefat">
50
+ <thead>
51
+ <tr>
52
+ <th><?php _efs( 'slug' ) ?></th>
53
+ <th><?php _efs( 'plugin' ) ?></th>
54
+ <th><?php _efs( 'type' ) ?></th>
55
+ <th><?php _efs( 'Last' ) ?></th>
56
+ <th><?php _efs( 'Next' ) ?></th>
57
+ </tr>
58
+ </thead>
59
+ <tbody>
60
+ <?php foreach ( $scheduled_crons as $slug => $crons ) : ?>
61
+ <?php foreach ( $crons as $cron ) : ?>
62
+ <tr>
63
+ <td><?php echo $slug ?></td>
64
+ <td><?php echo $cron['name'] ?></td>
65
+ <td><?php echo $cron['type'] ?></td>
66
+ <td><?php
67
+ if (is_numeric($cron['last'])) {
68
+ $diff = abs( WP_FS__SCRIPT_START_TIME - $cron['last'] );
69
+ $human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
70
+ $diff . ' ' . __fs( 'sec' ) :
71
+ human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['last'] );
72
+
73
+ if ( WP_FS__SCRIPT_START_TIME < $cron['last'] ) {
74
+ printf( __fs( 'in-x' ), $human_diff );
75
+ } else {
76
+ printf( __fs( 'x-ago' ), $human_diff );
77
+ }
78
+
79
+ // echo ' ' . $cron['last'];
80
+ }
81
+ ?></td>
82
+ <td><?php
83
+ if (is_numeric($cron['next'])) {
84
+ $diff = abs( WP_FS__SCRIPT_START_TIME - $cron['next'] );
85
+ $human_diff = ( $diff < MINUTE_IN_SECONDS ) ?
86
+ $diff . ' ' . __fs( 'sec' ) :
87
+ human_time_diff( WP_FS__SCRIPT_START_TIME, $cron['next'] );
88
+
89
+ if ( WP_FS__SCRIPT_START_TIME < $cron['next'] ) {
90
+ printf( __fs( 'in-x' ), $human_diff );
91
+ } else {
92
+ printf( __fs( 'x-ago' ), $human_diff );
93
+ }
94
+ }
95
+ ?></td>
96
+ </tr>
97
+ <?php endforeach ?>
98
+ <?php endforeach ?>
99
+ </tbody>
100
+ </table>
freemius/templates/email.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.1
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $sections = $VARS['sections'];
14
+ ?>
15
+ <table>
16
+ <?php
17
+ foreach ( $sections as $section_id => $section ) {
18
+ ?>
19
+ <thead>
20
+ <tr><th colspan="2" style="text-align: left; background: #333; color: #fff; padding: 5px;"><?php echo $section['title']; ?></th></tr>
21
+ </thead>
22
+ <tbody>
23
+ <?php
24
+ foreach ( $section['rows'] as $row_id => $row ) {
25
+ $col_count = count( $row );
26
+ ?>
27
+ <tr>
28
+ <?php
29
+ if ( 1 === $col_count ) { ?>
30
+ <td style="vertical-align: top;" colspan="2"><?php echo $row[0]; ?></td>
31
+ <?php
32
+ } else { ?>
33
+ <td style="vertical-align: top;"><b><?php echo $row[0]; ?>:</b></td>
34
+ <td><?php echo $row[1]; ?></td>
35
+ <?php
36
+ }
37
+ ?>
38
+ </tr>
39
+ <?php
40
+ }
41
+ ?>
42
+ </tbody>
43
+ <?php
44
+ }
45
+ ?>
46
+ </table>
freemius/templates/firewall-issues-js.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * API connectivity issues (CloudFlare's firewall) handler for handling different
4
+ * scenarios selected by the user after connectivity issue is detected, by sending
5
+ * AJAX call to the server in order to make the actual actions.
6
+ *
7
+ * @package Freemius
8
+ * @copyright Copyright (c) 2015, Freemius, Inc.
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.0.9
11
+ */
12
+
13
+ if ( ! defined( 'ABSPATH' ) ) {
14
+ exit;
15
+ }
16
+ ?>
17
+ <script type="text/javascript">
18
+ jQuery(document).ready(function ($) {
19
+ $('#fs_firewall_issue_options a.fs-resolve').click(function () {
20
+ var
21
+ error_type = $(this).attr('data-type'),
22
+ notice = $(this).parents('.fs-notice'),
23
+ slug = notice.attr('data-slug');
24
+
25
+ var data = {
26
+ action : slug + '_resolve_firewall_issues',
27
+ slug : slug,
28
+ error_type: error_type
29
+ };
30
+
31
+ if ('squid' === error_type) {
32
+ data.hosting_company = prompt('What is the name or URL of your hosting company?');
33
+ if (null == data.hosting_company)
34
+ return false;
35
+
36
+ if ('' === data.hosting_company) {
37
+ alert('We won\'t be able to help without knowing your hosting company.');
38
+ return false;
39
+ }
40
+ }
41
+
42
+ if ('retry_ping' === error_type) {
43
+ data.action = slug + '_retry_connectivity_test';
44
+ }
45
+
46
+ $(this).css({'cursor': 'wait'});
47
+
48
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
49
+ $.post(ajaxurl, data, function (response) {
50
+ if (1 == response) {
51
+ // Refresh page on success.
52
+ location.reload();
53
+ } else if ('http' === response.substr(0, 4)) {
54
+ // Ping actually worked, redirect.
55
+ window.location = response;
56
+ }
57
+ });
58
+ });
59
+ });
60
+ </script>
freemius/templates/plugin-icon.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.1.4
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ $slug = $VARS['slug'];
14
+ $fs = freemius( $slug );
15
+
16
+ /**
17
+ * @since 1.1.7.5
18
+ */
19
+ $local_path = $fs->apply_filters( 'plugin_icon', false );
20
+
21
+ if ( is_string( $local_path ) ) {
22
+ $icons = array( $local_path );
23
+ } else {
24
+ global $fs_active_plugins;
25
+
26
+ $img_dir = WP_FS__DIR_IMG;
27
+
28
+ if ( 1 < count( $fs_active_plugins->plugins ) ) {
29
+ foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) {
30
+ if ( $data->plugin_path == $fs->get_plugin_basename() ) {
31
+ $img_dir = WP_PLUGIN_DIR . '/' . $sdk_path . '/assets/img';
32
+ break;
33
+ }
34
+ }
35
+ }
36
+
37
+ $icons = glob( fs_normalize_path( $img_dir . '/icon.*' ) );
38
+ if ( ! is_array( $icons ) || 0 === count( $icons ) ) {
39
+ $icon_found = false;
40
+ $local_path = fs_normalize_path( $img_dir . '/icon.png' );
41
+ $have_write_permissions = is_writable( fs_normalize_path( $img_dir ) );
42
+
43
+ if ( WP_FS__IS_LOCALHOST && $fs->is_org_repo_compliant() && $have_write_permissions ) {
44
+ /**
45
+ * IMPORTANT: THIS CODE WILL NEVER RUN AFTER THE PLUGIN IS IN THE REPO.
46
+ *
47
+ * This code will only be executed once during the testing
48
+ * of the plugin in a local environment. The plugin icon file WILL
49
+ * already exist in the assets folder when the plugin is deployed to
50
+ * the repository.
51
+ */
52
+ $suffixes = array(
53
+ '-128x128.png',
54
+ '-128x128.jpg',
55
+ '-256x256.png',
56
+ '-256x256.jpg',
57
+ '.svg',
58
+ );
59
+
60
+ $base_url = 'https://plugins.svn.wordpress.org/' . $slug . '/assets/icon';
61
+
62
+ foreach ( $suffixes as $s ) {
63
+ $headers = get_headers( $base_url . $s );
64
+ if ( strpos( $headers[0], '200' ) ) {
65
+ $local_path = fs_normalize_path( $img_dir . '/icon.' . substr( $s, strpos( $s, '.' ) + 1 ) );
66
+ fs_download_image( $base_url . $s, $local_path );
67
+ $icon_found = true;
68
+ break;
69
+ }
70
+ }
71
+ }
72
+
73
+ if ( ! $icon_found ) {
74
+ // No icons found, fallback to default icon.
75
+ if ( $have_write_permissions ) {
76
+ // If have write permissions, copy default icon.
77
+ copy( fs_normalize_path( $img_dir . '/plugin-icon.png' ), $local_path );
78
+ } else {
79
+ // If doesn't have write permissions, use default icon path.
80
+ $local_path = fs_normalize_path( $img_dir . '/plugin-icon.png' );
81
+ }
82
+ }
83
+
84
+ $icons = array( $local_path );
85
+ }
86
+ }
87
+
88
+ $icon_dir = dirname( $icons[0] );
89
+ $relative_url = fs_img_url( substr( $icons[0], strlen( $icon_dir ) ), $icon_dir );
90
+ ?>
91
+ <div class="fs-plugin-icon">
92
+ <img src="<?php echo $relative_url ?>"/>
93
+ </div>
freemius/templates/plugin-info/description.php ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @var FS_Plugin $plugin
15
+ */
16
+ $plugin = $VARS['plugin'];
17
+
18
+ if ( ! empty( $plugin->info->selling_point_0 ) ||
19
+ ! empty( $plugin->info->selling_point_1 ) ||
20
+ ! empty( $plugin->info->selling_point_2 )
21
+ ) : ?>
22
+ <div class="fs-selling-points">
23
+ <ul>
24
+ <?php for ( $i = 0; $i < 3; $i ++ ) : ?>
25
+ <?php if ( ! empty( $plugin->info->{'selling_point_' . $i} ) ) : ?>
26
+ <li><i class="dashicons dashicons-yes"></i>
27
+
28
+ <h3><?php echo $plugin->info->{'selling_point_' . $i} ?></h3></li>
29
+ <?php endif ?>
30
+ <?php endfor ?>
31
+ </ul>
32
+ </div>
33
+ <?php endif ?>
34
+ <div>
35
+ <?php
36
+ echo wp_kses( $plugin->info->description, array(
37
+ 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
38
+ 'b' => array(),
39
+ 'i' => array(),
40
+ 'p' => array(),
41
+ 'blockquote' => array(),
42
+ 'h2' => array(),
43
+ 'h3' => array(),
44
+ 'ul' => array(),
45
+ 'ol' => array(),
46
+ 'li' => array()
47
+ ) );
48
+ ?>
49
+ </div>
50
+ <?php if ( ! empty( $plugin->info->screenshots ) ) : ?>
51
+ <?php $screenshots = $plugin->info->screenshots ?>
52
+ <div class="fs-screenshots clearfix">
53
+ <h2><?php _efs( 'screenshots', $plugin->slug ) ?></h2>
54
+ <ul>
55
+ <?php $i = 0;
56
+ foreach ( $screenshots as $s => $url ) : ?>
57
+ <?php
58
+ // Relative URLs are replaced with WordPress.org base URL
59
+ // therefore we need to set absolute URLs.
60
+ $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
61
+ <li class="<?php echo ( 0 === $i % 2 ) ? 'odd' : 'even' ?>">
62
+ <style>
63
+ #section-description .fs-screenshots <?php echo ".fs-screenshot-{$i}" ?>
64
+ {
65
+ background-image: url('<?php echo $url ?>');
66
+ }
67
+ </style>
68
+ <a href="<?php echo $url ?>"
69
+ title="<?php printf( __fs( 'view-full-size-x', $plugin->slug ), $i ) ?>"
70
+ class="fs-screenshot-<?php echo $i ?>"></a>
71
+ </li>
72
+ <?php $i ++; endforeach ?>
73
+ </ul>
74
+ </div>
75
+ <?php endif ?>
freemius/templates/plugin-info/features.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @var FS_Plugin $plugin
15
+ */
16
+ $plugin = $VARS['plugin'];
17
+
18
+ $plans = $VARS['plans'];
19
+
20
+ $features_plan_map = array();
21
+ foreach ( $plans as $plan ) {
22
+ foreach ( $plan->features as $feature ) {
23
+ if ( ! isset( $features_plan_map[ $feature->id ] ) ) {
24
+ $features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() );
25
+ }
26
+
27
+ $features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature;
28
+ }
29
+
30
+ // Add support as a feature.
31
+ if ( ! empty( $plan->support_email ) ||
32
+ ! empty( $plan->support_skype ) ||
33
+ ! empty( $plan->support_phone ) ||
34
+ true === $plan->is_success_manager
35
+ ) {
36
+ if ( ! isset( $features_plan_map['support'] ) ) {
37
+ $support_feature = new stdClass();
38
+ $support_feature->id = 'support';
39
+ $support_feature->title = __fs( 'Support', $plugin->slug );
40
+ $features_plan_map[ $support_feature->id ] = array( 'feature' => $support_feature, 'plans' => array() );
41
+ } else {
42
+ $support_feature = $features_plan_map['support'];
43
+ }
44
+
45
+ $features_plan_map[ $support_feature->id ]['plans'][ $plan->id ] = $support_feature;
46
+ }
47
+ }
48
+
49
+ // Add updates as a feature for all plans.
50
+ $updates_feature = new stdClass();
51
+ $updates_feature->id = 'updates';
52
+ $updates_feature->title = __fs( 'unlimited-updates', $plugin->slug );
53
+ $features_plan_map[ $updates_feature->id ] = array( 'feature' => $updates_feature, 'plans' => array() );
54
+ foreach ( $plans as $plan ) {
55
+ $features_plan_map[ $updates_feature->id ]['plans'][ $plan->id ] = $updates_feature;
56
+ }
57
+ ?>
58
+ <div class="fs-features">
59
+ <table>
60
+ <thead>
61
+ <tr>
62
+ <th></th>
63
+ <?php foreach ( $plans as $plan ) : ?>
64
+ <th>
65
+ <?php echo $plan->title ?>
66
+ <span class="fs-price">
67
+ <?php foreach ( $plan->pricing as $pricing ) : ?>
68
+ <?php if ( 1 == $pricing->licenses ) : ?>
69
+ $<?php echo $pricing->annual_price ?> / year
70
+ <?php endif ?>
71
+ <?php endforeach ?>
72
+ </span>
73
+ </th>
74
+ <?php endforeach ?>
75
+ </tr>
76
+ </thead>
77
+ <tbody>
78
+ <?php $odd = true;
79
+ foreach ( $features_plan_map as $feature_id => $data ) : ?>
80
+ <tr class="fs-<?php echo $odd ? 'odd' : 'even' ?>">
81
+ <td><?php echo ucfirst( $data['feature']->title ) ?></td>
82
+ <?php foreach ( $plans as $plan ) : ?>
83
+ <td>
84
+ <?php if ( isset( $data['plans'][ $plan->id ] ) ) : ?>
85
+ <?php if ( ! empty( $data['plans'][ $plan->id ]->value ) ) : ?>
86
+ <b><?php echo $data['plans'][ $plan->id ]->value ?></b>
87
+ <?php else : ?>
88
+ <i class="dashicons dashicons-yes"></i>
89
+ <?php endif ?>
90
+ <?php endif ?>
91
+ </td>
92
+ <?php endforeach ?>
93
+ </tr>
94
+ <?php $odd = ! $odd; endforeach ?>
95
+ </tbody>
96
+ </table>
97
+ </div>
freemius/templates/plugin-info/screenshots.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * @var FS_Plugin $plugin
15
+ */
16
+ $plugin = $VARS['plugin'];
17
+
18
+ $screenshots = $VARS['screenshots'];
19
+ ?>
20
+ <ol>
21
+ <?php $i = 0;
22
+ foreach ( $screenshots as $s => $url ) : ?>
23
+ <?php
24
+ // Relative URLs are replaced with WordPress.org base URL
25
+ // therefore we need to set absolute URLs.
26
+ $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
27
+ <li>
28
+ <a href="<?php echo $url ?>"
29
+ title="<?php printf( __fs( 'view-full-size-x', $plugin->slug ), $i ) ?>"><img
30
+ src="<?php echo $url ?>"></a>
31
+ </li>
32
+ <?php $i ++; endforeach ?>
33
+ </ol>
freemius/templates/powered-by.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.5
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * KEEP THE POWERED BY TAB AND GET ADDITIONAL - 1% - OFF THE COMMISSION
15
+ */
16
+
17
+ wp_enqueue_script( 'jquery' );
18
+ wp_enqueue_script( 'json2' );
19
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
20
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
21
+ ?>
22
+
23
+ <div id="piframe"></div>
24
+ <script type="text/javascript">
25
+ (function ($) {
26
+ $(function () {
27
+ var
28
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
29
+ piframe = $('<iframe id="fs_promo_tab" src="' + base_url + '/promotional-tab/?page=contact#' + encodeURIComponent(document.location.href) + '" height="350" width="60" frameborder="0" style=" background: transparent; position: fixed; top: 20%; right: 0;" scrolling="no"></iframe>')
30
+ .appendTo('#piframe');
31
+
32
+ FS.PostMessage.init(base_url);
33
+ FS.PostMessage.receive('state', function (state) {
34
+ if ('closed' === state)
35
+ $('#fs_promo_tab').css('width', '60px');
36
+ else
37
+ $('#fs_promo_tab').css('width', '345px');
38
+ });
39
+ });
40
+ })(jQuery);
41
+ </script>
freemius/templates/pricing.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2015, Freemius, Inc.
5
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
+ * @since 1.0.3
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ wp_enqueue_script( 'jquery' );
14
+ wp_enqueue_script( 'json2' );
15
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17
+
18
+ $slug = $VARS['slug'];
19
+ $fs = freemius( $slug );
20
+ $timestamp = time();
21
+
22
+ $context_params = array(
23
+ 'plugin_id' => $fs->get_id(),
24
+ 'plugin_public_key' => $fs->get_public_key(),
25
+ 'plugin_version' => $fs->get_plugin_version(),
26
+ );
27
+
28
+ // Get site context secure params.
29
+ if ( $fs->is_registered() ) {
30
+ $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
31
+ $fs->get_site(),
32
+ $timestamp,
33
+ 'upgrade'
34
+ ) );
35
+ }
36
+
37
+ if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
38
+ {
39
+ $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
40
+ $fs->get_plugin(),
41
+ $timestamp,
42
+ 'checkout'
43
+ );
44
+ }
45
+
46
+ $query_params = array_merge( $context_params, $_GET, array(
47
+ 'next' => $fs->_get_admin_page_url( 'account', array( 'fs_action' => $slug . '_sync_license' ) ),
48
+ 'plugin_version' => $fs->get_plugin_version(),
49
+ // Billing cycle.
50
+ 'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ),
51
+ ) );
52
+ ?>
53
+
54
+ <div id="fs_pricing" class="wrap" style="margin: 0 0 -65px -20px;">
55
+ <div id="iframe"></div>
56
+ <form action="" method="POST">
57
+ <input type="hidden" name="user_id"/>
58
+ <input type="hidden" name="user_email"/>
59
+ <input type="hidden" name="site_id"/>
60
+ <input type="hidden" name="public_key"/>
61
+ <input type="hidden" name="secret_key"/>
62
+ <input type="hidden" name="action" value="account"/>
63
+ </form>
64
+
65
+ <script type="text/javascript">
66
+ (function ($, undef) {
67
+ $(function () {
68
+ var
69
+ // Keep track of the iframe height.
70
+ iframe_height = 800,
71
+ base_url = '<?php echo WP_FS__ADDRESS ?>',
72
+ // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
73
+ // passed via query string or hard coded into the child page, it depends on your needs).
74
+ src = base_url + '/pricing/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
75
+
76
+ // Append the Iframe into the DOM.
77
+ iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
78
+ .appendTo('#iframe');
79
+
80
+ FS.PostMessage.init(base_url);
81
+
82
+ FS.PostMessage.receive('height', function (data) {
83
+ var h = data.height;
84
+ if (!isNaN(h) && h > 0 && h != iframe_height) {
85
+ iframe_height = h;
86
+ $("#iframe iframe").height(iframe_height + 'px');
87
+ }
88
+ });
89
+
90
+ FS.PostMessage.receive('get_dimensions', function (data) {
91
+ FS.PostMessage.post('dimensions', {
92
+ height : $(document.body).height(),
93
+ scrollTop: $(document).scrollTop()
94
+ }, iframe[0]);
95
+ });
96
+ });
97
+ })(jQuery);
98
+ </script>
99
+ </div>
100
+ <?php fs_require_template( 'powered-by.php' ) ?>
freemius/templates/sticky-admin-notice-js.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sticky admin notices JavaScript handler for dismissing notice messages
4
+ * by sending AJAX call to the server in order to remove the message from the Database.
5
+ *
6
+ * @package Freemius
7
+ * @copyright Copyright (c) 2015, Freemius, Inc.
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0.7
10
+ */
11
+
12
+ if ( ! defined( 'ABSPATH' ) ) {
13
+ exit;
14
+ }
15
+ ?>
16
+ <script type="text/javascript" >
17
+ jQuery(document).ready(function($) {
18
+ $('.fs-notice.fs-sticky .fs-close').click(function(){
19
+ var
20
+ notice = $(this).parents('.fs-notice'),
21
+ id = notice.attr('data-id'),
22
+ slug = notice.attr('data-slug');
23
+
24
+ notice.fadeOut('fast', function(){
25
+ var data = {
26
+ action: slug + '_dismiss_notice_action',
27
+ slug: slug,
28
+ message_id: id
29
+ };
30
+
31
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
32
+ $.post(ajaxurl, data, function(response) {
33
+
34
+ });
35
+
36
+ notice.remove();
37
+ });
38
+ });
39
+ });
40
+ </script>
index.php CHANGED
@@ -1,934 +1,1012 @@
1
- <?php
2
- /*
3
- Plugin Name: Intergeo Maps - Google Maps Plugin
4
- Plugin URI: http://plugins.svn.wordpress.org/intergeo-maps/
5
- Description: A simple, easy and quite powerful Google Map tool to create, manage and embed custom Google Maps into your WordPress posts and pages. The plugin allows you to deeply customize look and feel of a map, add overlays like markers, rectangles, circles, polylines and polygons to your map. It could even be integraded with your Google Adsense account and show ad on your maps.
6
- Version: 1.0.3
7
- Author: Themeisle
8
- Author URI: http://themeisle.com
9
- License: GPL v2.0 or later
10
- License URI: http://www.opensource.org/licenses/gpl-license.php
11
- */
12
-
13
- // <editor-fold defaultstate="collapsed" desc="constants">
14
-
15
- define( 'INTERGEO_PLUGIN_NAME', 'intergeo' ); // don't change it whatever
16
- define( 'INTERGEO_VERSION', '1.0.3' );
17
- define( 'INTERGEO_ABSPATH', dirname( __FILE__ ) );
18
- define( 'INTERGEO_ABSURL', plugins_url( '/', __FILE__ ) );
19
- // Added by Ash/Upwork
20
- defined('WPLANG') || define( 'WPLANG', '' );
21
- // Added by Ash/Upwork
22
-
23
- // Added by Ash/Upwork
24
- if ( class_exists( 'IntergeoMaps_Pro', false ) ){
25
- define( 'IntergeoMaps_Pro', true);
26
- }
27
- // Added by Ash/Upwork
28
-
29
- // </editor-fold>
30
-
31
- // <editor-fold defaultstate="collapsed" desc="plugin init">
32
-
33
- add_filter( 'plugin_action_links', 'intergeo_action_links', 10, 2 );
34
- function intergeo_action_links( $links, $file ) {
35
- if ( $file == plugin_basename( __FILE__ ) ) {
36
- array_unshift(
37
- $links,
38
- sprintf( '<a href="%s">%s</a>', add_query_arg( 'page', INTERGEO_PLUGIN_NAME, admin_url( 'upload.php' ) ), __( "Maps", INTERGEO_PLUGIN_NAME ) ),
39
- sprintf( '<a href="%s">%s</a>', admin_url( 'options-media.php' ), __( "Settings", INTERGEO_PLUGIN_NAME ) )
40
- );
41
- }
42
- return $links;
43
- }
44
-
45
- add_action( 'admin_init', 'intergeo_admin_init' );
46
- function intergeo_admin_init() {
47
- load_plugin_textdomain( INTERGEO_PLUGIN_NAME, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
48
- register_post_type( INTERGEO_PLUGIN_NAME );
49
- }
50
-
51
- add_action( 'wp_enqueue_scripts', 'intergeo_frontend_enqueue_scripts' );
52
- function intergeo_frontend_enqueue_scripts() {
53
- wp_register_style( 'intergeo-frontend', INTERGEO_ABSURL . 'css/frontend.css', array(), INTERGEO_VERSION );
54
- }
55
-
56
- // </editor-fold>
57
-
58
- // <editor-fold defaultstate="collapsed" desc="settings">
59
-
60
- add_filter( 'whitelist_options', 'intergeo_whitelist_options' );
61
- function intergeo_whitelist_options( $whitelist ) {
62
- $whitelist['media'][] = 'intergeo_map_api_key';
63
- $whitelist['media'][] = 'intergeo_adsense_publisher_id';
64
- return $whitelist;
65
- }
66
-
67
- add_action( 'admin_init', 'intergeo_settings_init' );
68
- function intergeo_settings_init() {
69
- register_setting( 'media', 'intergeo-settings-map-api-key', 'trim' );
70
- add_settings_section( 'intergeo-settings-maps', 'Intergeo Google Maps', 'intergeo_settings_init_map', 'media' );
71
- add_settings_field( 'intergeo_map_api_key', 'Maps API Key', 'intergeo_settings_print_field', 'media', 'intergeo-settings-maps', array(
72
- '<input type="text" name="%s" value="%s" class="regular-text">',
73
- 'intergeo_map_api_key',
74
- esc_attr( get_option( 'intergeo_map_api_key' ) ),
75
- ) );
76
-
77
- register_setting( 'media', 'intergeo_adsense_publisher_id', 'trim' );
78
- add_settings_section( 'intergeo-settings-adsense', 'Intergeo Google Maps AdSense Integration', 'intergeo_settings_init_adsense', 'media' );
79
- add_settings_field( 'intergeo_adsense_publisher_id', 'AdSense Publisher Id', 'intergeo_settings_print_field', 'media', 'intergeo-settings-adsense', array(
80
- '<input type="text" name="%s" value="%s" class="regular-text">',
81
- 'intergeo_adsense_publisher_id',
82
- esc_attr( get_option( 'intergeo_adsense_publisher_id' ) ),
83
- ) );
84
- }
85
-
86
- function intergeo_settings_init_map() {
87
- ?><p><?php
88
- printf( esc_html__( "All Maps API applications should load the Maps API using an API key (however it is still possible to use maps without API key). Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API using an API key in order to purchase additional quota. To create your API key:", INTERGEO_PLUGIN_NAME ), '<a href="https://developers.google.com/maps/documentation/javascript/usage#usage_limits" target="_blank">', '</a>' );
89
- ?></p>
90
- <ol>
91
- <li><?php printf( esc_html__( "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log in with your Google Account.", INTERGEO_PLUGIN_NAME ), '<a href="https://code.google.com/apis/console" target="_blank">', '</a>' ) ?></li>
92
- <li><?php printf( esc_html__( 'Click the %sServices%s link from the left-hand menu.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
93
- <li><?php printf( esc_html__( 'Activate the %sGoogle Maps API v3%s service.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
94
- <li><?php printf( esc_html__( 'Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s section. Maps API applications use the %1$sKey for browser apps%2$s.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
95
- </ol>
96
- <?php
97
- }
98
-
99
- function intergeo_settings_init_adsense() {
100
- ?><p><?php
101
- printf( esc_html__( "Adding display ads to your map requires that you have an AdSense account enabled for AdSense for Content. If you don't yet have an AdSense account, %1\$ssign up%3\$s for one. Once you have done so (or if you already have an account) make sure you've also enabled the account with %2\$sAdSense for Content%3\$s.", INTERGEO_PLUGIN_NAME ), '<a href="https://www.google.com/adsense/support/bin/answer.py?answer=10162" target="_blank">', '<a href="https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=17470" target="_blank">', '</a>' )
102
- ?></p><p><?php
103
- esc_html_e( 'Once you have an Adsense for Content account, you will have received an AdSense for Content (AFC) publisher ID. This publisher ID is used to link any advertising shown to your AdSense account, allowing you to share in advertising revenue when a user clicks on one of the ads shown on your maps.', INTERGEO_PLUGIN_NAME )
104
- ?></p><?php
105
- }
106
-
107
- function intergeo_settings_print_field( array $args ) {
108
- vprintf( array_shift( $args ), $args );
109
- }
110
-
111
- // </editor-fold>
112
-
113
- // <editor-fold defaultstate="collapsed" desc="common">
114
-
115
- function intergeo_enqueue_google_maps_script( $libraries = false ) {
116
- global $wp_scripts;
117
-
118
- if ( is_array( $libraries ) ) {
119
- $libraries = implode( ',', $libraries );
120
- }
121
-
122
- if ( wp_script_is( 'google-maps-v3' ) ) {
123
-
124
- $params = array();
125
- parse_str( end( explode( '?', $wp_scripts->registered['google-maps-v3']->src ) ), $params );
126
- $params['libraries'] = implode( ',', array_unique( array_merge( isset( $params['libraries'] ) ? explode( ',', $params['libraries'] ) : array(), explode( ',', $libraries ) ) ) );
127
- $wp_scripts->registered['google-maps-v3']->src = '//maps.googleapis.com/maps/api/js?' . http_build_query( $params );
128
-
129
- } else {
130
-
131
- $lang = explode( '_', WPLANG ? WPLANG : 'en_US' );
132
- $params = array(
133
- 'v' => '3.10',
134
- 'sensor' => 'false',
135
- 'region' => isset( $lang[1] ) ? $lang[1] : 'US',
136
- 'language' => $lang[0],
137
- );
138
-
139
- if ( !empty( $libraries ) ) {
140
- $params['libraries'] = $libraries;
141
- }
142
-
143
- $api_key = get_option( 'intergeo_map_api_key' );
144
- if ( !empty( $api_key ) ) {
145
- $params['key'] = $api_key;
146
- }
147
-
148
- wp_enqueue_script( 'google-maps-v3', '//maps.googleapis.com/maps/api/js?' . http_build_query( $params ), array(), null );
149
-
150
- }
151
- }
152
-
153
- function intergeo_check_libraries( $json, $libraries = array() ) {
154
- if ( isset( $json['layer']['adsense'] ) && $json['layer']['adsense'] && !in_array( 'adsense', $libraries ) ) {
155
- $libraries[] = 'adsense';
156
- }
157
-
158
- if ( isset( $json['layer']['panoramio'] ) && $json['layer']['panoramio'] && !in_array( 'panoramio', $libraries ) ) {
159
- $libraries[] = 'panoramio';
160
- }
161
-
162
- if ( ( isset( $json['layer']['weather'] ) && $json['layer']['weather'] ) || ( isset( $json['layer']['cloud'] ) && $json['layer']['cloud'] ) ) {
163
- if ( !in_array( 'weather', $libraries ) ) {
164
- $libraries[] = 'weather';
165
- }
166
- }
167
-
168
- return $libraries;
169
- }
170
-
171
- function intergeo_encode( $id ) {
172
- return strrev( rtrim( call_user_func( 'base64_' . 'encode', $id ), '=' ) );
173
- }
174
-
175
- function intergeo_decode( $code ) {
176
- return intval( call_user_func( 'base64' . '_decode', strrev( $code ) ) );
177
- }
178
-
179
- // </editor-fold>
180
-
181
- // <editor-fold defaultstate="collapsed" desc="iframe">
182
-
183
- // <editor-fold defaultstate="collapsed" desc="rendering">
184
-
185
- add_filter( 'media_upload_tabs', 'intergeo_media_upload_tabs' );
186
- function intergeo_media_upload_tabs( $tabs ) {
187
- $tabs['intergeo_map'] = __( 'Intergeo Maps', INTERGEO_PLUGIN_NAME );
188
- return $tabs;
189
- }
190
-
191
- add_action( 'media_upload_intergeo_map', 'intergeo_map_popup_init' );
192
- function intergeo_map_popup_init() {
193
- $post_id = filter_input( INPUT_GET, 'post_id', FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1 ) ) );
194
- $map_id = filter_input( INPUT_GET, 'map' );
195
-
196
- $send_to_editor = false;
197
- if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
198
- $shortcode = intergeo_save_map( $map_id, $post_id );
199
- if ( $post_id ) {
200
- $send_to_editor = $shortcode;
201
- } else {
202
- $args = array(
203
- 'page' => INTERGEO_PLUGIN_NAME,
204
- 'updated' => date( 'YmdHis' ),
205
- );
206
- wp_redirect( add_query_arg( $args, admin_url( 'upload.php' ) ) );
207
- exit;
208
- }
209
- }
210
-
211
- intergeo_enqueue_google_maps_script( 'adsense,panoramio,weather,drawing' );
212
-
213
- wp_enqueue_script( 'intergeo-editor', INTERGEO_ABSURL . 'js/editor.js', array( 'wp-color-picker', 'google-maps-v3', 'jquery' ), INTERGEO_VERSION );
214
- wp_localize_script( 'intergeo-editor', 'intergeo_options', array(
215
- 'send_to_editor' => $send_to_editor,
216
- 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) ),
217
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
218
- 'nonce' => wp_create_nonce( 'editor_popup' . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ),
219
- 'l10n' => array(
220
- 'marker' => __( 'marker', INTERGEO_PLUGIN_NAME ),
221
- 'error' => array(
222
- 'style' => __( 'Styles are broken. Please, fix it and try again.', INTERGEO_PLUGIN_NAME ),
223
- 'directions' => __( 'Direction was not found.', INTERGEO_PLUGIN_NAME ),
224
- ),
225
- ),
226
- ) );
227
-
228
- wp_enqueue_style( 'wp-color-picker' );
229
- wp_enqueue_style( 'intergeo-editor', INTERGEO_ABSURL . 'css/editor.css', array(), INTERGEO_VERSION );
230
-
231
- // Added by Ash/Upwork
232
- if( defined( 'IntergeoMaps_Pro' ) ){
233
- global $IntergeoMaps_Pro;
234
- $IntergeoMaps_Pro->enqueueScriptsAndStyles(array('intergeo-editor'), array("mapID" => $map_id));
235
- }
236
- // Added by Ash/Upwork
237
-
238
- wp_iframe( 'intergeo_iframe', $post_id, $map_id );
239
- }
240
-
241
- function intergeo_iframe( $post_id = false, $map_id = false ) {
242
- $publisher_id = trim( get_option( 'intergeo_adsense_publisher_id' ) );
243
- $show_map_center = get_option( 'intergeo_show_map_center', true );
244
-
245
- $submit_text = __( 'Insert into post', INTERGEO_PLUGIN_NAME );
246
-
247
- if ( !$post_id ) {
248
- $submit_text = __( 'Create the map', INTERGEO_PLUGIN_NAME );
249
- }
250
-
251
- $copy = false;
252
- if ( !$map_id ) {
253
- $copy = true;
254
- $map_id = filter_input( INPUT_GET, 'copy' );
255
- }
256
-
257
- $json = array();
258
- if ( $map_id ) {
259
- $map = get_post( intergeo_decode( $map_id ) );
260
- if ( $map->post_type == INTERGEO_PLUGIN_NAME ) {
261
- $json = json_decode( $map->post_content, true );
262
- if ( !$copy ) {
263
- $submit_text = __( 'Update the map', INTERGEO_PLUGIN_NAME );
264
- }
265
- }
266
- }
267
-
268
- require INTERGEO_ABSPATH . '/templates/iframe/form.php';
269
- }
270
-
271
- // </editor-fold>
272
-
273
- // <editor-fold defaultstate="collapsed" desc="filtering">
274
-
275
- function intergeo_filter_value( $value, $array ) {
276
- $value = strtoupper( $value );
277
- return !in_array( $value, $array ) ? null : $value;
278
- }
279
-
280
- function intergeo_filter_position( $position ) {
281
- return intergeo_filter_value( $position, array(
282
- 'TOP_LEFT', 'TOP_CENTER', 'TOP_RIGHT',
283
- 'RIGHT_TOP', 'RIGHT_CENTER', 'RIGHT_BOTTOM',
284
- 'BOTTOM_RIGHT', 'BOTTOM_CENTER', 'BOTTOM_LEFT',
285
- 'LEFT_BOTTOM', 'LEFT_CENTER', 'LEFT_TOP'
286
- ) );
287
- }
288
-
289
- function intergeo_filter_map_type( $type ) {
290
- return intergeo_filter_value( $type, array( 'ROADMAP', 'TERRAIN', 'SATELLITE', 'HYBRID' ) );
291
- }
292
-
293
- function intergeo_filter_map_type_style( $style ) {
294
- return intergeo_filter_value( $style, array( 'DEFAULT', 'DROPDOWN_MENU', 'HORIZONTAL_BAR' ) );
295
- }
296
-
297
- function intergeo_filter_zoom_style( $style ) {
298
- return intergeo_filter_value( $style, array( 'DEFAULT', 'SMALL', 'LARGE' ) );
299
- }
300
-
301
- function intergeo_filter_wind_speed_units( $unit ) {
302
- return intergeo_filter_value( $unit, array( 'KILOMETERS_PER_HOUR', 'METERS_PER_SECOND', 'MILES_PER_HOUR' ) );
303
- }
304
-
305
- function intergeo_filter_temperature_units( $unit ) {
306
- return intergeo_filter_value( $unit, array( 'CELSIUS', 'FAHRENHEIT' ) );
307
- }
308
-
309
- function intergeo_filter_adsense_format( $format ) {
310
- return intergeo_filter_value( $format, array(
311
- 'BANNER',
312
- 'BUTTON',
313
- 'HALF_BANNER',
314
- 'LARGE_HORIZONTAL_LINK_UNIT',
315
- 'LARGE_RECTANGLE',
316
- 'LARGE_VERTICAL_LINK_UNIT',
317
- 'LEADERBOARD',
318
- 'MEDIUM_RECTANGLE',
319
- 'MEDIUM_VERTICAL_LINK_UNIT',
320
- 'SKYSCRAPER',
321
- 'SMALL_HORIZONTAL_LINK_UNIT',
322
- 'SMALL_RECTANGLE',
323
- 'SMALL_SQUARE',
324
- 'SMALL_VERTICAL_LINK_UNIT',
325
- 'SQUARE',
326
- 'VERTICAL_BANNER',
327
- 'WIDE_SKYSCRAPER',
328
- 'X_LARGE_VERTICAL_LINK_UNIT',
329
- ) );
330
- }
331
-
332
- function intergeo_filter_custom_style( $style ) {
333
- $style = trim( $style );
334
- $json = @json_decode( $style, true );
335
-
336
- return empty( $json ) ? null : $json;
337
- }
338
-
339
- function intergeo_filter_overlays_marker( $marker ) {
340
- if ( !isset( $marker['position'] ) || !preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $marker['position'] ) ) {
341
- return false;
342
- }
343
-
344
- return array(
345
- 'position' => explode( ',', $marker['position'] ),
346
- 'icon' => isset( $marker['icon'] ) ? filter_var( $marker['icon'], FILTER_VALIDATE_URL ) : '',
347
- 'info' => isset( $marker['info'] ) ? trim( preg_replace( '/\<\/?script.*?\>/is', '', $marker['info'] ) ) : '',
348
- 'title' => isset( $marker['title'] ) ? strip_tags( trim( $marker['title'] ) ) : '',
349
- );
350
- }
351
-
352
- function intergeo_filter_overlays_polyline( $polyline ) {
353
- if ( !isset( $polyline['path'] ) ) {
354
- return false;
355
- }
356
-
357
- $path = array();
358
- foreach( explode( ';', $polyline['path'] ) as $point ) {
359
- if ( preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $point ) ) {
360
- $path[] = explode( ',', $point );
361
- }
362
- }
363
-
364
- if ( count( $path ) < 2 ) {
365
- return false;
366
- }
367
-
368
- return array(
369
- 'path' => $path,
370
- 'weight' => isset( $polyline['weight'] )
371
- ? filter_var( $polyline['weight'], FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'default' => '' ) ) )
372
- : '',
373
- 'opacity' => isset( $polyline['opacity'] )
374
- ? filter_var( $polyline['opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) )
375
- : '',
376
- 'color' => isset( $polyline['color'] )
377
- ? filter_var( $polyline['color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) )
378
- : '#000000',
379
- );
380
- }
381
-
382
- function intergeo_filter_overlays_polyoverlay( $polygon ) {
383
- if ( !isset( $polygon['path'] ) ) {
384
- return false;
385
- }
386
-
387
- $path = array();
388
- foreach( explode( ';', $polygon['path'] ) as $point ) {
389
- if ( preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $point ) ) {
390
- $path[] = explode( ',', $point );
391
- }
392
- }
393
-
394
- if ( count( $path ) < 2 ) {
395
- return false;
396
- }
397
-
398
- $position = isset( $polygon['position'] ) ? strtoupper( trim( $polygon['position'] ) ) : 'CENTER';
399
-
400
- return array(
401
- 'path' => $path,
402
- 'position' => in_array( $position, array( 'CENTER', 'INSIDE', 'OUTSIDE' ) ) ? $position : 'CENTER',
403
- 'weight' => isset( $polygon['weight'] ) ? filter_var( $polygon['weight'], FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'default' => '' ) ) ) : '',
404
- 'stroke_opacity' => isset( $polygon['stroke_opacity'] ) ? filter_var( $polygon['stroke_opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) ) : '',
405
- 'stroke_color' => isset( $polygon['stroke_color'] ) ? filter_var( $polygon['stroke_color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) ) : '#000000',
406
- 'fill_opacity' => isset( $polygon['fill_opacity'] ) ? filter_var( $polygon['fill_opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) ) : '',
407
- 'fill_color' => isset( $polygon['fill_color'] ) ? filter_var( $polygon['fill_color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) ) : '#000000',
408
- );
409
- }
410
-
411
- function intergeo_filter_directions( $direction ) {
412
- $to = isset( $direction['to'] ) ? trim( $direction['to'] ) : '';
413
- $from = isset( $direction['from'] ) ? trim( $direction['from'] ) : '';
414
-
415
- if ( empty( $to ) || empty( $from ) ) {
416
- return false;
417
- }
418
-
419
- $mode = isset( $direction['mode'] ) ? strtoupper( trim( $direction['mode'] ) ) : 'DRIVING';
420
-
421
- return array(
422
- 'mode' => in_array( $mode, array( 'BICYCLING', 'DRIVING', 'TRANSIT', 'WALKING' ) ) ? $mode : 'DRIVING',
423
- 'from' => $from,
424
- 'to' => $to,
425
- );
426
- }
427
-
428
- function intergeo_filter_input() {
429
- $color_regexp = '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/';
430
- $postion_filter = array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_position' );
431
-
432
- $validationArray = array (
433
- 'lat' => array( 'filter' => FILTER_VALIDATE_FLOAT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => -90, 'max_range' => 90, 'default' => 48.1366069 ) ),
434
- 'lng' => array( 'filter' => FILTER_VALIDATE_FLOAT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => -180, 'max_range' => 180, 'default' => 11.577085099999977 ) ),
435
- 'zoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 5 ) ),
436
- 'address' => FILTER_SANITIZE_STRING,
437
- 'map_mapTypeId' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_map_type' ),
438
- 'map_draggable' => FILTER_VALIDATE_BOOLEAN,
439
- 'map_minZoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 0 ) ),
440
- 'map_maxZoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 19 ) ),
441
- 'map_scrollwheel' => FILTER_VALIDATE_BOOLEAN,
442
- 'map_zoomControl' => FILTER_VALIDATE_BOOLEAN,
443
- 'map_zoomControlOptions_position' => $postion_filter,
444
- 'map_zoomControlOptions_style' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_zoom_style' ),
445
- 'map_panControl' => FILTER_VALIDATE_BOOLEAN,
446
- 'map_panControlOptions_position' => $postion_filter,
447
- 'map_scaleControl' => FILTER_VALIDATE_BOOLEAN,
448
- 'map_scaleControlOptions_position' => $postion_filter,
449
- 'map_mapTypeControl' => FILTER_VALIDATE_BOOLEAN,
450
- 'map_mapTypeControlOptions_position' => $postion_filter,
451
- 'map_mapTypeControlOptions_style' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_map_type_style' ),
452
- 'map_mapTypeControlOptions_mapTypeIds' => array( 'filter' => FILTER_CALLBACK, 'flags' => FILTER_REQUIRE_ARRAY, 'options' => 'intergeo_filter_map_type' ),
453
- 'map_streetViewControl' => FILTER_VALIDATE_BOOLEAN,
454
- 'map_streetViewControlOptions_position' => $postion_filter,
455
- 'map_rotateControl' => FILTER_VALIDATE_BOOLEAN,
456
- 'map_rotateControlOptions_position' => $postion_filter,
457
- 'map_overviewMapControl' => FILTER_VALIDATE_BOOLEAN,
458
- 'map_overviewMapControlOptions_opened' => FILTER_VALIDATE_BOOLEAN,
459
- 'layer_traffic' => FILTER_VALIDATE_BOOLEAN,
460
- 'layer_bicycling' => FILTER_VALIDATE_BOOLEAN,
461
- 'layer_cloud' => FILTER_VALIDATE_BOOLEAN,
462
- 'layer_weather' => FILTER_VALIDATE_BOOLEAN,
463
- 'weather_temperatureUnits' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_temperature_units' ),
464
- 'weather_windSpeedUnits' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_wind_speed_units' ),
465
- 'layer_panoramio' => FILTER_VALIDATE_BOOLEAN,
466
- 'panoramio_tag' => FILTER_SANITIZE_STRING,
467
- 'panoramio_userId' => FILTER_SANITIZE_STRING,
468
- 'layer_adsense' => FILTER_VALIDATE_BOOLEAN,
469
- 'adsense_format' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_adsense_format' ),
470
- 'adsense_position' => $postion_filter,
471
- 'adsense_backgroundColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#c4d4f3' ) ),
472
- 'adsense_borderColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#e5ecf9' ) ),
473
- 'adsense_titleColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#0000cc' ) ),
474
- 'adsense_textColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#000000' ) ),
475
- 'adsense_urlColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#009900' ) ),
476
- 'container_width' => FILTER_SANITIZE_STRING,
477
- 'container_height' => FILTER_SANITIZE_STRING,
478
- 'container_styles' => FILTER_SANITIZE_STRING,
479
- 'styles_type' => FILTER_SANITIZE_STRING,
480
- 'styles_custom' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_custom_style' ),
481
- 'overlays_marker' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
482
- 'overlays_polyline' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
483
- 'overlays_polygon' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
484
- 'overlays_rectangle' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
485
- 'overlays_circle' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
486
- 'directions' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
487
- );
488
-
489
- $defaults = array (
490
- 'lat' => 48.1366069,
491
- 'lng' => 11.577085099999977,
492
- 'zoom' => 5,
493
- 'address' => '',
494
- 'map_mapTypeId' => 'ROADMAP',
495
- 'map_draggable' => true,
496
- 'map_minZoom' => 0,
497
- 'map_maxZoom' => 19,
498
- 'map_scrollwheel' => true,
499
- 'map_zoomControl' => true,
500
- 'map_zoomControlOptions_position' => null,
501
- 'map_zoomControlOptions_style' => 'DEFAULT',
502
- 'map_panControl' => true,
503
- 'map_panControlOptions_position' => null,
504
- 'map_scaleControl' => false,
505
- 'map_scaleControlOptions_position' => null,
506
- 'map_mapTypeControl' => true,
507
- 'map_mapTypeControlOptions_position' => null,
508
- 'map_mapTypeControlOptions_style' => 'DEFAULT',
509
- 'map_mapTypeControlOptions_mapTypeIds' => array( 'ROADMAP', 'TERRAIN', 'SATELLITE', 'HYBRID' ),
510
- 'map_streetViewControl' => true,
511
- 'map_streetViewControlOptions_position' => null,
512
- 'map_rotateControl' => true,
513
- 'map_rotateControlOptions_position' => null,
514
- 'map_overviewMapControl' => false,
515
- 'map_overviewMapControlOptions_opened' => false,
516
- 'layer_traffic' => false,
517
- 'layer_bicycling' => false,
518
- 'layer_cloud' => false,
519
- 'layer_weather' => false,
520
- 'weather_temperatureUnits' => null,
521
- 'weather_windSpeedUnits' => null,
522
- 'layer_panoramio' => false,
523
- 'panoramio_tag' => '',
524
- 'panoramio_userId' => '',
525
- 'layer_adsense' => false,
526
- 'adsense_format' => null,
527
- 'adsense_position' => null,
528
- 'adsense_backgroundColor' => '#c4d4f3',
529
- 'adsense_borderColor' => '#e5ecf9',
530
- 'adsense_titleColor' => '#0000cc',
531
- 'adsense_textColor' => '#000000',
532
- 'adsense_urlColor' => '#009900',
533
- 'container_width' => '',
534
- 'container_height' => '',
535
- 'container_styles' => '',
536
- 'styles_type' => 'DEFAULT',
537
- 'styles_custom' => null,
538
- 'overlays_marker' => array(),
539
- 'overlays_polyline' => array(),
540
- 'overlays_polygon' => array(),
541
- 'overlays_rectangle' => array(),
542
- 'overlays_circle' => array(),
543
- 'directions' => array(),
544
- );
545
-
546
- // Added by Ash/Upwork
547
- if( defined( 'IntergeoMaps_Pro' ) ){
548
- global $IntergeoMaps_Pro;
549
- $IntergeoMaps_Pro->addValidations($validationArray, $defaults);
550
- }
551
- // Added by Ash/Upwork
552
-
553
- $options = filter_input_array( INPUT_POST, $validationArray );
554
-
555
- $results = array();
556
- foreach ( $options as $key => $value ) {
557
- if ( array_key_exists( $key, $defaults ) ) {
558
- $equals = $defaults[$key] == $value;
559
- if ( is_array( $value ) ) {
560
- $equals = ( count( $value ) == count( $defaults[$key] ) ) && ( count( array_diff( (array)$defaults[$key], $value ) ) == 0 );
561
- }
562
-
563
- if ( !$equals ) {
564
- $results[$key] = $value;
565
- }
566
- }
567
- }
568
-
569
- if ( !empty( $results['overlays_marker'] ) ) {
570
- $results['overlays_marker'] = array_filter( array_map( 'intergeo_filter_overlays_marker', $results['overlays_marker'] ) );
571
- }
572
-
573
- if ( !empty( $results['overlays_polyline'] ) ) {
574
- $results['overlays_polyline'] = array_filter( array_map( 'intergeo_filter_overlays_polyline', $results['overlays_polyline'] ) );
575
- }
576
-
577
- if ( !empty( $results['directions'] ) ) {
578
- $results['directions'] = array_filter( array_map( 'intergeo_filter_directions', $results['directions'] ) );
579
- }
580
-
581
- foreach ( array( 'polygon', 'rectangle', 'circle' ) as $overlay ) {
582
- $overlay = 'overlays_' . $overlay;
583
- if ( !empty( $results[$overlay] ) ) {
584
- $results[$overlay] = array_filter( array_map( 'intergeo_filter_overlays_polyoverlay', $results[$overlay] ) );
585
- }
586
- }
587
-
588
- // Added by Ash/Upwork
589
- if( defined( 'IntergeoMaps_Pro' ) ){
590
- global $IntergeoMaps_Pro;
591
- $IntergeoMaps_Pro->processResults($results);
592
- }
593
- // Added by Ash/Upwork
594
-
595
- return $results;
596
- }
597
-
598
- // </editor-fold>
599
-
600
- // <editor-fold defaultstate="collapsed" desc="saving">
601
-
602
- function intergeo_save_map( $map_id = false, $post_id = false ) {
603
- $options = array();
604
- $array_ptr = &$options;
605
- foreach ( intergeo_filter_input() as $key => $value ) {
606
- if ( !is_null( $value ) ) {
607
- $keys = explode( '_', $key );
608
- $last_key = array_pop( $keys );
609
-
610
- while ( $arr_key = array_shift( $keys ) ) {
611
- if ( !array_key_exists( $arr_key, $array_ptr ) ) {
612
- $array_ptr[$arr_key] = array( );
613
- }
614
- $array_ptr = &$array_ptr[$arr_key];
615
- }
616
-
617
- $array_ptr[$last_key] = $value;
618
- $array_ptr = &$options;
619
- }
620
- }
621
-
622
- $address = '';
623
- if ( !empty( $options['address'] ) ) {
624
- $address = $options['address'] = trim( $options['address'] );
625
- }
626
-
627
- $args = array(
628
- 'post_type' => INTERGEO_PLUGIN_NAME,
629
- 'post_content' => addcslashes( json_encode( $options ), '\\' ),
630
- 'post_status' => 'private',
631
- );
632
-
633
- $update = false;
634
- if ( $map_id ) {
635
- $post = get_post( intergeo_decode( $map_id ) );
636
- if ( $post && $post->post_type == INTERGEO_PLUGIN_NAME ) {
637
- $update = true;
638
- $args['ID'] = $post->ID;
639
- }
640
- }
641
-
642
- $id = wp_insert_post( $args );
643
-
644
- if ( !empty( $id ) && !is_wp_error( $id ) ) {
645
- if ( !$post_id ) {
646
- intergeo_set_info( $update
647
- ? __( 'The map has been updated successfully.', INTERGEO_PLUGIN_NAME )
648
- : __( 'The map has been created successfully.', INTERGEO_PLUGIN_NAME )
649
- );
650
- }
651
- return sprintf( '[intergeo id="%s"]%s[/intergeo]', intergeo_encode( $id ), $address );
652
- }
653
-
654
- if ( !$post_id ) {
655
- intergeo_set_error( $update
656
- ? __( 'The map updating failed.', INTERGEO_PLUGIN_NAME )
657
- : __( 'The map creation failed.', INTERGEO_PLUGIN_NAME )
658
- );
659
- }
660
-
661
- return false;
662
- }
663
-
664
- // </editor-fold>
665
-
666
- // <editor-fold defaultstate="collapsed" desc="ajax stuff">
667
-
668
- add_action( 'wp_ajax_intergeo_show_map_center', 'intergeo_show_map_center_changed' );
669
- function intergeo_show_map_center_changed() {
670
- $nonce = filter_input( INPUT_POST, 'nonce' );
671
- if ( wp_verify_nonce( $nonce, 'editor_popup' . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ) ) {
672
- update_option( 'intergeo_show_map_center', (int)filter_input( INPUT_POST, 'status', FILTER_VALIDATE_BOOLEAN ) );
673
- }
674
- }
675
-
676
- // </editor-fold>
677
-
678
- // </editor-fold>
679
-
680
- // <editor-fold defaultstate="collapsed" desc="shortcode">
681
-
682
- add_filter( 'widget_text', 'do_shortcode' );
683
- add_filter( 'term_description', 'do_shortcode' );
684
-
685
- add_shortcode( INTERGEO_PLUGIN_NAME, 'intergeo_shortcode' );
686
- function intergeo_shortcode( $attrs, $address = '' ) {
687
- $args = shortcode_atts( array(
688
- 'id' => false,
689
- 'hook' => false,
690
- 'width' => false,
691
- 'height' => false,
692
- 'style' => false,
693
- 'zoom' => false,
694
- ), $attrs );
695
-
696
- $address = trim( $address );
697
- if ( empty( $args['id'] ) && empty( $address ) ) {
698
- return '';
699
- }
700
-
701
- $json = array();
702
- if ( !empty( $args['id'] ) ) {
703
- $post = get_post( intergeo_decode( $args['id'] ) );
704
- if ( !$post || $post->post_type != INTERGEO_PLUGIN_NAME ) {
705
- return '';
706
- }
707
-
708
- $json = json_decode( $post->post_content, true );
709
- } else {
710
- $args['id'] = intergeo_encode( rand( 0, 100 ) . rand( 0, 10000 ) );
711
- $json['zoom'] = intval( $args['zoom'] ) ? intval( $args['zoom'] ) : 15;
712
- }
713
-
714
- if ( !empty( $address ) ) {
715
- $json['address'] = $address;
716
- }
717
-
718
- if ( trim( $args['hook'] ) != '' ) {
719
- $json = apply_filters( $args['hook'], $json );
720
- }
721
-
722
- wp_enqueue_style( 'intergeo-frontend' );
723
- intergeo_enqueue_google_maps_script( intergeo_check_libraries( $json ) );
724
- if ( !wp_script_is( 'intergeo-rendering' ) ) {
725
- wp_enqueue_script( 'intergeo-rendering', INTERGEO_ABSURL . 'js/rendering.js', array( 'jquery', 'google-maps-v3' ), INTERGEO_VERSION );
726
- wp_localize_script( 'intergeo-rendering', 'intergeo_options', array(
727
- 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) )
728
- ) );
729
- }
730
-
731
- $container = array();
732
- if ( isset( $json['container'] ) ) {
733
- $container = $json['container'];
734
- unset( $json['container'] );
735
- }
736
-
737
- $width = !empty( $container['width'] ) ? esc_attr( $container['width'] ) : '100%';
738
- if ( trim( $args['width'] ) != '' ) {
739
- $width = $args['width'];
740
- }
741
- if ( is_numeric( $width ) ) {
742
- $width .= 'px';
743
- }
744
-
745
- $height = !empty( $container['height'] ) ? esc_attr( $container['height'] ) : '300px';
746
- if ( trim( $args['height'] ) != '' ) {
747
- $height = $args['height'];
748
- }
749
- if ( is_numeric( $height ) ) {
750
- $height .= 'px';
751
- }
752
-
753
- $styles = !empty( $container['styles'] ) ? esc_attr( $container['styles'] ) : '';
754
- if ( trim( $args['style'] ) != '' ) {
755
- $styles = $args['style'];
756
- }
757
-
758
- return sprintf( '
759
- <div id="intergeo_map%1$s" class="intergeo_map_canvas" style="width:100%%;height:300px;width:%2$s;height:%3$s;%4$s"></div>
760
- <script type="text/javascript">
761
- /* <![CDATA[ */
762
- if (!window.intergeo_maps) window.intergeo_maps = [];
763
- window.intergeo_maps.push( { container: \'intergeo_map%1$s\', options: %5$s } );
764
- if (!window.intergeo_maps_current) window.intergeo_maps_current = null;
765
- /* ]]> */
766
- </script>
767
- ',
768
- $args['id'],
769
- $width,
770
- $height,
771
- $styles,
772
- json_encode( $json )
773
- );
774
- }
775
-
776
- // </editor-fold>
777
-
778
- // <editor-fold defaultstate="collapsed" desc="library">
779
-
780
- add_action( 'admin_menu', 'intergeo_admin_menu' );
781
- function intergeo_admin_menu() {
782
- $page = add_submenu_page( 'upload.php', 'Intergeo Maps Library', 'Intergeo Maps', 'edit_posts', INTERGEO_PLUGIN_NAME, 'intergeo_library' );
783
- if ( $page ) {
784
- add_action( "load-{$page}", 'intergeo_library_init' );
785
- }
786
- }
787
-
788
- function intergeo_library_init() {
789
- wp_enqueue_style( 'intergeo_library', INTERGEO_ABSURL . 'css/library.css', array(), INTERGEO_VERSION );
790
- wp_enqueue_media();
791
-
792
- $screen = get_current_screen();
793
-
794
- $screen->add_help_tab( array(
795
- 'title' => esc_html__( 'Overview', INTERGEO_PLUGIN_NAME ),
796
- 'id' => 'overview',
797
- 'content' => sprintf( '<p>%s</p>', implode( '</p><p>', array(
798
- esc_html__( "The library is a list to view all maps you have created in your system. The library is showing you 3x3 grid of maps' previews. You will see the same maps embedded into your posts at front end, as you see here. The library is paginated and if you have more than 9 maps, you will see pagination links under maps grid.", INTERGEO_PLUGIN_NAME ),
799
- esc_html__( 'To create a new map, click on "Add New" button next to the page title and map editor popup will appear. In case you want to edit a map, you can click on pencil icon in the right bottom corner of map preview box and edit popup window will appear.', INTERGEO_PLUGIN_NAME ),
800
- esc_html__( "If you want to delete a map, click on the trash icon in the right bottom corner of a map and confirm your action. Pay attention that whole information about the map will be removed from the system, but all shortcodes will be left where you embed it. However these deprecated shortcodes won't be rendered anymore, so you don't have to worry about it while the plugin is enabled.", INTERGEO_PLUGIN_NAME ),
801
- ) ) ),
802
- ) );
803
-
804
- $screen->add_help_tab( array(
805
- 'title' => esc_html__( 'Shortcodes', INTERGEO_PLUGIN_NAME ),
806
- 'id' => 'shortcodes',
807
- 'content' => sprintf( '<p>%s</p>', implode( '</p><p>', array(
808
- esc_html__( 'You can easily embed a map into your posts, pages, categories or tags descriptions and text widgets by copying shortcode which you can find in the input field of a map preview box.', INTERGEO_PLUGIN_NAME ),
809
- esc_html__( 'To specify a certain address just type it inside a shortcode, and a map will be automatically centered at this place. Also each shortcode could be extended with custom attributes like width, height, style, zoom and hook. Use standard CSS values for such attributes as width, height and style. Type an integer between 0 and 19 for zoom attribute. You can use hook attribute to set up a filter hook which you can use in your custom plugin or theme to configure all options of a map.', INTERGEO_PLUGIN_NAME ),
810
- ) ) ),
811
- ) );
812
- }
813
-
814
- function intergeo_library() {
815
- if ( filter_input( INPUT_GET, 'do' ) == 'delete' ) {
816
- intergeo_library_delete();
817
- }
818
-
819
- $query = new WP_Query( array(
820
- 'orderby' => 'ID',
821
- 'order' => 'DESC',
822
- 'post_type' => INTERGEO_PLUGIN_NAME,
823
- 'posts_per_page' => 9,
824
- 'paged' => filter_input( INPUT_GET, 'pagenum', FILTER_VALIDATE_INT, array( 'options' => array(
825
- 'min_range' => 1,
826
- 'default' => 1,
827
- ) ) ),
828
- ) );
829
-
830
- $libraries = array();
831
- $pagination = paginate_links( array(
832
- 'base' => add_query_arg( array(
833
- 'pagenum' => '%#%',
834
- 'updated' => false,
835
- ) ),
836
- 'format' => '',
837
- 'current' => max( 1, $query->get( 'paged' ) ),
838
- 'total' => $query->max_num_pages,
839
- 'type' => 'array',
840
- ) );
841
-
842
- require INTERGEO_ABSPATH . '/templates/library/list.php';
843
-
844
- intergeo_enqueue_google_maps_script( $libraries );
845
-
846
- wp_enqueue_script( 'intergeo-rendering', INTERGEO_ABSURL . 'js/rendering.js', array( 'jquery', 'google-maps-v3' ), INTERGEO_VERSION );
847
- wp_enqueue_script( 'intergeo-library', INTERGEO_ABSURL . 'js/library.js', array( 'intergeo-rendering', 'media-views' ), INTERGEO_VERSION );
848
-
849
- wp_localize_script( 'intergeo-rendering', 'intergeo_options', array(
850
- 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) )
851
- ) );
852
-
853
- // Added by Ash/Upwork
854
- if( defined( 'IntergeoMaps_Pro' ) ){
855
- global $IntergeoMaps_Pro;
856
- $IntergeoMaps_Pro->enqueueScriptsAndStyles(array('intergeo-rendering'));
857
- }
858
- // Added by Ash/Upwork
859
-
860
- }
861
-
862
- function intergeo_library_delete() {
863
- if ( !current_user_can( 'delete_posts' ) ) {
864
- return;
865
- }
866
-
867
- $id = intergeo_decode( trim( filter_input( INPUT_GET, 'map' ) ) );
868
- if ( !$id ) {
869
- return;
870
- }
871
-
872
- $post = get_post( $id );
873
- if ( wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ), $id . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ) && $post->post_type == INTERGEO_PLUGIN_NAME ) {
874
- if ( wp_delete_post( $id, true ) ) {
875
- intergeo_set_info( __( 'The map was deleted successfully.', INTERGEO_PLUGIN_NAME ) );
876
- }
877
- }
878
-
879
- if ( filter_input( INPUT_GET, 'noheader', FILTER_VALIDATE_BOOLEAN ) ) {
880
- wp_redirect( add_query_arg( 'page', INTERGEO_PLUGIN_NAME, admin_url( 'upload.php' ) ) );
881
- exit;
882
- }
883
- }
884
-
885
- // </editor-fold>
886
-
887
- // <editor-fold defaultstate="collapsed" desc="messaging functions">
888
-
889
- function intergeo_set_message( $message, $is_normal, $user_id = false ) {
890
- $messages = get_option( 'intergeo_messages', array() );
891
- if ( $user_id === false ) {
892
- $user_id = get_current_user_id();
893
- }
894
-
895
- if ( !isset( $messages[$user_id] ) ) {
896
- $messages[$user_id] = array();
897
- }
898
-
899
- $messages[$user_id][] = array( $message, $is_normal );
900
- update_option( 'intergeo_messages', $messages );
901
- }
902
-
903
- function intergeo_set_info( $message, $user_id = false ) {
904
- intergeo_set_message( $message, 1, $user_id );
905
- }
906
-
907
- function intergeo_set_error( $message, $user_id = false ) {
908
- intergeo_set_message( $message, 0, $user_id );
909
- }
910
-
911
- add_action( 'admin_notices', 'intergeo_print_messages' );
912
- function intergeo_print_messages() {
913
- global $pagenow;
914
-
915
- if ( $pagenow != 'upload.php' ) {
916
- return;
917
- }
918
-
919
- $messages = get_option( 'intergeo_messages', array() );
920
- $user_id = get_current_user_id();
921
-
922
- if ( !isset( $messages[$user_id] ) ) {
923
- return;
924
- }
925
-
926
- foreach ( $messages[$user_id] as $message ) {
927
- printf( $message[1] ? '<div class="updated"><p>%s</p></div>' : '<div class="error"><p>%s</p></div>', $message[0] );
928
- }
929
-
930
- $messages[$user_id] = array();
931
- update_option( 'intergeo_messages', $messages );
932
- }
933
-
934
- // </editor-fold>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Intergeo Maps - Google Maps Plugin
4
+ Plugin URI: http://themeisle.com/plugins/intergeo-maps-lite/
5
+ Description: A simple, easy and quite powerful Google Map tool to create, manage and embed custom Google Maps into your WordPress posts and pages. The plugin allows you to deeply customize look and feel of a map, add overlays like markers, rectangles, circles, polylines and polygons to your map. It could even be integraded with your Google Adsense account and show ad on your maps.
6
+ Version: 1.0.5
7
+ Author: Themeisle
8
+ Author URI: http://themeisle.com
9
+ License: GPL v2.0 or later
10
+ License URI: http://www.opensource.org/licenses/gpl-license.php
11
+ Text Domain: intergeo
12
+ Domain Path: /languages
13
+ */
14
+
15
+ // <editor-fold defaultstate="collapsed" desc="constants">
16
+
17
+ define( 'INTERGEO_PLUGIN_NAME', 'intergeo' ); // don't change it whatever
18
+ define( 'INTERGEO_VERSION', '1.0.5' );
19
+ define( 'INTERGEO_ABSPATH', dirname( __FILE__ ) );
20
+ define( 'INTERGEO_ABSURL', plugins_url( '/', __FILE__ ) );
21
+ define( 'INTERGEO_PRO_URL', "http://themeisle.com/plugins/intergeo-maps-pro/" );
22
+ // Added by Ash/Upwork
23
+ defined('WPLANG') || define( 'WPLANG', '' );
24
+ // Added by Ash/Upwork
25
+
26
+ // Added by Ash/Upwork
27
+ if ( class_exists( 'IntergeoMaps_Pro', false ) ){
28
+ define( 'IntergeoMaps_Pro', true);
29
+ }
30
+ // Added by Ash/Upwork
31
+
32
+ // </editor-fold>
33
+
34
+ // <editor-fold defaultstate="collapsed" desc="plugin init">
35
+
36
+ function im_fs() {
37
+ global $im_fs;
38
+
39
+ if ( ! isset( $im_fs ) ) {
40
+ // Include Freemius SDK.
41
+ require_once dirname(__FILE__) . '/freemius/start.php';
42
+
43
+ $im_fs = fs_dynamic_init( array(
44
+ 'id' => '239',
45
+ 'slug' => 'intergeo-maps',
46
+ 'public_key' => 'pk_35c86b731f06c8d4ba25b490af632',
47
+ 'is_premium' => false,
48
+ 'has_addons' => false,
49
+ 'has_paid_plans' => false,
50
+ 'anonymous_mode' => true,
51
+ 'menu' => array(
52
+ 'slug' => 'intergeo',
53
+ 'account' => false,
54
+ 'support' => false,
55
+ 'parent' => array(
56
+ 'slug' => 'upload.php',
57
+ ),
58
+ ),
59
+ ) );
60
+ }
61
+
62
+ return $im_fs;
63
+ }
64
+ // Init Freemius.
65
+ im_fs();
66
+
67
+ add_filter( 'plugin_action_links', 'intergeo_action_links', 10, 2 );
68
+ function intergeo_action_links( $links, $file ) {
69
+ if ( $file == plugin_basename( __FILE__ ) ) {
70
+ array_unshift(
71
+ $links,
72
+ sprintf( '<a href="%s">%s</a>', add_query_arg( 'page', INTERGEO_PLUGIN_NAME, admin_url( 'upload.php' ) ), __( "Maps", INTERGEO_PLUGIN_NAME ) ),
73
+ sprintf( '<a href="%s">%s</a>', admin_url( 'options-media.php' ), __( "Settings", INTERGEO_PLUGIN_NAME ) )
74
+ );
75
+ }
76
+ return $links;
77
+ }
78
+
79
+ add_action( 'admin_init', 'intergeo_admin_init' );
80
+ function intergeo_admin_init() {
81
+ load_plugin_textdomain( INTERGEO_PLUGIN_NAME, false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
82
+ register_post_type( INTERGEO_PLUGIN_NAME );
83
+ }
84
+
85
+ add_action( 'wp_enqueue_scripts', 'intergeo_frontend_enqueue_scripts' );
86
+ function intergeo_frontend_enqueue_scripts() {
87
+ wp_register_style( 'intergeo-frontend', INTERGEO_ABSURL . 'css/frontend.css', array(), INTERGEO_VERSION );
88
+ }
89
+
90
+ add_action("plugins_loaded", 'intergeo_i18n');
91
+ function intergeo_i18n(){
92
+ $pluginDirName = dirname(plugin_basename(__FILE__));
93
+ $domain = INTERGEO_PLUGIN_NAME;
94
+ $locale = apply_filters("plugin_locale", get_locale(), $domain);
95
+ load_textdomain($domain, WP_LANG_DIR . "/" . $pluginDirName . "/" . $domain . "-" . $locale . ".mo");
96
+ load_plugin_textdomain($domain, "", $pluginDirName . "/languages/");
97
+ }
98
+
99
+ // </editor-fold>
100
+
101
+ // <editor-fold defaultstate="collapsed" desc="settings">
102
+
103
+ add_filter( 'whitelist_options', 'intergeo_whitelist_options' );
104
+ function intergeo_whitelist_options( $whitelist ) {
105
+ $whitelist['media'][] = 'intergeo_map_api_key';
106
+ $whitelist['media'][] = 'intergeo_adsense_publisher_id';
107
+ return $whitelist;
108
+ }
109
+
110
+ add_action( 'admin_init', 'intergeo_settings_init' );
111
+ function intergeo_settings_init() {
112
+ register_setting( 'media', 'intergeo-settings-map-api-key', 'trim' );
113
+ add_settings_section( 'intergeo-settings-maps', 'Intergeo Google Maps', 'intergeo_settings_init_map', 'media' );
114
+ add_settings_field( 'intergeo_map_api_key', __('Maps API Key', INTERGEO_PLUGIN_NAME), 'intergeo_settings_print_field', 'media', 'intergeo-settings-maps', array(
115
+ '<input type="text" name="%s" value="%s" class="regular-text">',
116
+ 'intergeo_map_api_key',
117
+ esc_attr( get_option( 'intergeo_map_api_key' ) ),
118
+ ) );
119
+
120
+ register_setting( 'media', 'intergeo_adsense_publisher_id', 'trim' );
121
+ add_settings_section( 'intergeo-settings-adsense', __('Intergeo Google Maps AdSense Integration', INTERGEO_PLUGIN_NAME), 'intergeo_settings_init_adsense', 'media' );
122
+ add_settings_field( 'intergeo_adsense_publisher_id', __('AdSense Publisher Id', INTERGEO_PLUGIN_NAME), 'intergeo_settings_print_field', 'media', 'intergeo-settings-adsense', array(
123
+ '<input type="text" name="%s" value="%s" class="regular-text">',
124
+ 'intergeo_adsense_publisher_id',
125
+ esc_attr( get_option( 'intergeo_adsense_publisher_id' ) ),
126
+ ) );
127
+ }
128
+
129
+ function intergeo_settings_init_map() {
130
+ ?><p><?php
131
+ printf( esc_html__( "All Maps API applications should load the Maps API using an API key (however it is still possible to use maps without API key). Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API using an API key in order to purchase additional quota. To create your API key:", INTERGEO_PLUGIN_NAME ), '<a href="https://developers.google.com/maps/documentation/javascript/usage#usage_limits" target="_blank">', '</a>' );
132
+ ?></p>
133
+ <ol>
134
+ <li><?php printf( esc_html__( "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log in with your Google Account.", INTERGEO_PLUGIN_NAME ), '<a href="https://code.google.com/apis/console" target="_blank">', '</a>' ) ?></li>
135
+ <li><?php printf( esc_html__( 'Click the %sServices%s link from the left-hand menu.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
136
+ <li><?php printf( esc_html__( 'Activate the %sGoogle Maps API v3%s service.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
137
+ <li><?php printf( esc_html__( 'Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s section. Maps API applications use the %1$sKey for browser apps%2$s.', INTERGEO_PLUGIN_NAME ), '<b>', '</b>' ) ?></li>
138
+ </ol>
139
+ <?php
140
+ }
141
+
142
+ function intergeo_settings_init_adsense() {
143
+ ?><p><?php
144
+ printf( esc_html__( "Adding display ads to your map requires that you have an AdSense account enabled for AdSense for Content. If you don't yet have an AdSense account, %1\$ssign up%3\$s for one. Once you have done so (or if you already have an account) make sure you've also enabled the account with %2\$sAdSense for Content%3\$s.", INTERGEO_PLUGIN_NAME ), '<a href="https://www.google.com/adsense/support/bin/answer.py?answer=10162" target="_blank">', '<a href="https://www.google.com/adsense/support/bin/answer.py?hl=en&answer=17470" target="_blank">', '</a>' )
145
+ ?></p><p><?php
146
+ esc_html_e( 'Once you have an Adsense for Content account, you will have received an AdSense for Content (AFC) publisher ID. This publisher ID is used to link any advertising shown to your AdSense account, allowing you to share in advertising revenue when a user clicks on one of the ads shown on your maps.', INTERGEO_PLUGIN_NAME )
147
+ ?></p><?php
148
+ }
149
+
150
+ function intergeo_settings_print_field( array $args ) {
151
+ vprintf( array_shift( $args ), $args );
152
+ }
153
+
154
+ // </editor-fold>
155
+
156
+ // <editor-fold defaultstate="collapsed" desc="common">
157
+
158
+ function intergeo_enqueue_google_maps_script( $libraries = false ) {
159
+ global $wp_scripts;
160
+
161
+ if ( is_array( $libraries ) ) {
162
+ $libraries = implode( ',', $libraries );
163
+ }
164
+
165
+ if ( wp_script_is( 'google-maps-v3' ) ) {
166
+
167
+ $params = array();
168
+ parse_str( end( explode( '?', $wp_scripts->registered['google-maps-v3']->src ) ), $params );
169
+ $params['libraries'] = implode( ',', array_unique( array_merge( isset( $params['libraries'] ) ? explode( ',', $params['libraries'] ) : array(), explode( ',', $libraries ) ) ) );
170
+ $wp_scripts->registered['google-maps-v3']->src = '//maps.googleapis.com/maps/api/js?' . http_build_query( $params );
171
+
172
+ } else {
173
+
174
+ $lang = explode( '_', WPLANG ? WPLANG : 'en_US' );
175
+ $params = array(
176
+ 'v' => '3.10',
177
+ 'sensor' => 'false',
178
+ 'region' => isset( $lang[1] ) ? $lang[1] : 'US',
179
+ 'language' => $lang[0],
180
+ );
181
+
182
+ if ( !empty( $libraries ) ) {
183
+ $params['libraries'] = $libraries;
184
+ }
185
+
186
+ $api_key = get_option( 'intergeo_map_api_key' );
187
+ if ( !empty( $api_key ) ) {
188
+ $params['key'] = $api_key;
189
+ }
190
+
191
+ wp_enqueue_script( 'google-maps-v3', '//maps.googleapis.com/maps/api/js?' . http_build_query( $params ), array(), null );
192
+
193
+ }
194
+ }
195
+
196
+ function intergeo_check_libraries( $json, $libraries = array() ) {
197
+ if ( isset( $json['layer']['adsense'] ) && $json['layer']['adsense'] && !in_array( 'adsense', $libraries ) ) {
198
+ $libraries[] = 'adsense';
199
+ }
200
+
201
+ if ( isset( $json['layer']['panoramio'] ) && $json['layer']['panoramio'] && !in_array( 'panoramio', $libraries ) ) {
202
+ $libraries[] = 'panoramio';
203
+ }
204
+
205
+ if ( ( isset( $json['layer']['weather'] ) && $json['layer']['weather'] ) || ( isset( $json['layer']['cloud'] ) && $json['layer']['cloud'] ) ) {
206
+ if ( !in_array( 'weather', $libraries ) ) {
207
+ $libraries[] = 'weather';
208
+ }
209
+ }
210
+
211
+ return $libraries;
212
+ }
213
+
214
+ function intergeo_encode( $id ) {
215
+ return strrev( rtrim( call_user_func( 'base64_' . 'encode', $id ), '=' ) );
216
+ }
217
+
218
+ function intergeo_decode( $code ) {
219
+ return intval( call_user_func( 'base64' . '_decode', strrev( $code ) ) );
220
+ }
221
+
222
+ // </editor-fold>
223
+
224
+ // <editor-fold defaultstate="collapsed" desc="iframe">
225
+
226
+ // <editor-fold defaultstate="collapsed" desc="rendering">
227
+
228
+ add_filter( 'media_upload_tabs', 'intergeo_media_upload_tabs' );
229
+ function intergeo_media_upload_tabs( $tabs ) {
230
+ $tabs['intergeo_map'] = __( 'Intergeo Maps', INTERGEO_PLUGIN_NAME );
231
+ return $tabs;
232
+ }
233
+
234
+ add_action( 'media_upload_intergeo_map', 'intergeo_map_popup_init' );
235
+ function intergeo_map_popup_init() {
236
+ $post_id = filter_input( INPUT_GET, 'post_id', FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1 ) ) );
237
+ $map_id = filter_input( INPUT_GET, 'map' );
238
+
239
+ $send_to_editor = false;
240
+ if ( $_SERVER['REQUEST_METHOD'] == 'POST' ) {
241
+ $shortcode = intergeo_save_map( $map_id, $post_id );
242
+ if ( $post_id ) {
243
+ $send_to_editor = $shortcode;
244
+ } else {
245
+ $args = array(
246
+ 'page' => INTERGEO_PLUGIN_NAME,
247
+ 'updated' => date( 'YmdHis' ),
248
+ );
249
+ wp_redirect( add_query_arg( $args, admin_url( 'upload.php' ) ) );
250
+ exit;
251
+ }
252
+ }
253
+
254
+ intergeo_enqueue_google_maps_script( 'adsense,panoramio,weather,drawing' );
255
+
256
+ wp_enqueue_script( 'intergeo-editor', INTERGEO_ABSURL . 'js/editor.js', array( 'wp-color-picker', 'google-maps-v3', 'jquery' ), INTERGEO_VERSION );
257
+ wp_localize_script( 'intergeo-editor', 'intergeo_options', array(
258
+ 'send_to_editor' => $send_to_editor,
259
+ 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) ),
260
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
261
+ 'nonce' => wp_create_nonce( 'editor_popup' . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ),
262
+ 'l10n' => array(
263
+ 'marker' => __( 'marker', INTERGEO_PLUGIN_NAME ),
264
+ 'error' => array(
265
+ 'style' => __( 'Styles are broken. Please, fix it and try again.', INTERGEO_PLUGIN_NAME ),
266
+ 'directions' => __( 'Direction was not found.', INTERGEO_PLUGIN_NAME ),
267
+ ),
268
+ ),
269
+ ) );
270
+
271
+ wp_enqueue_style( 'wp-color-picker' );
272
+ wp_enqueue_style( 'intergeo-editor', INTERGEO_ABSURL . 'css/editor.css', array(), INTERGEO_VERSION );
273
+
274
+ // Added by Ash/Upwork
275
+ if( defined( 'IntergeoMaps_Pro' ) ){
276
+ global $IntergeoMaps_Pro;
277
+ $IntergeoMaps_Pro->enqueueScriptsAndStyles(array('intergeo-editor'), array("mapID" => $map_id));
278
+ }
279
+ // Added by Ash/Upwork
280
+
281
+ wp_iframe( 'intergeo_iframe', $post_id, $map_id );
282
+ }
283
+
284
+ function intergeo_iframe( $post_id = false, $map_id = false ) {
285
+ $publisher_id = trim( get_option( 'intergeo_adsense_publisher_id' ) );
286
+ $show_map_center = get_option( 'intergeo_show_map_center', true );
287
+
288
+ $submit_text = __( 'Insert into post', INTERGEO_PLUGIN_NAME );
289
+
290
+ if ( !$post_id ) {
291
+ $submit_text = __( 'Create the map', INTERGEO_PLUGIN_NAME );
292
+ }
293
+
294
+ $copy = false;
295
+ if ( !$map_id ) {
296
+ $copy = true;
297
+ $map_id = filter_input( INPUT_GET, 'copy' );
298
+ }
299
+
300
+ $json = array();
301
+ if ( $map_id ) {
302
+ $map = get_post( intergeo_decode( $map_id ) );
303
+ if ( $map->post_type == INTERGEO_PLUGIN_NAME ) {
304
+ $json = json_decode( $map->post_content, true );
305
+ if ( !$copy ) {
306
+ $submit_text = __( 'Update the map', INTERGEO_PLUGIN_NAME );
307
+ }
308
+ }
309
+ }
310
+
311
+ require INTERGEO_ABSPATH . '/templates/iframe/form.php';
312
+ }
313
+
314
+ // </editor-fold>
315
+
316
+ // <editor-fold defaultstate="collapsed" desc="filtering">
317
+
318
+ function intergeo_filter_value( $value, $array ) {
319
+ $value = strtoupper( $value );
320
+ return !in_array( $value, $array ) ? null : $value;
321
+ }
322
+
323
+ function intergeo_filter_position( $position ) {
324
+ return intergeo_filter_value( $position, array(
325
+ 'TOP_LEFT', 'TOP_CENTER', 'TOP_RIGHT',
326
+ 'RIGHT_TOP', 'RIGHT_CENTER', 'RIGHT_BOTTOM',
327
+ 'BOTTOM_RIGHT', 'BOTTOM_CENTER', 'BOTTOM_LEFT',
328
+ 'LEFT_BOTTOM', 'LEFT_CENTER', 'LEFT_TOP'
329
+ ) );
330
+ }
331
+
332
+ function intergeo_filter_map_type( $type ) {
333
+ return intergeo_filter_value( $type, array( 'ROADMAP', 'TERRAIN', 'SATELLITE', 'HYBRID' ) );
334
+ }
335
+
336
+ function intergeo_filter_map_type_style( $style ) {
337
+ return intergeo_filter_value( $style, array( 'DEFAULT', 'DROPDOWN_MENU', 'HORIZONTAL_BAR' ) );
338
+ }
339
+
340
+ function intergeo_filter_zoom_style( $style ) {
341
+ return intergeo_filter_value( $style, array( 'DEFAULT', 'SMALL', 'LARGE' ) );
342
+ }
343
+
344
+ function intergeo_filter_wind_speed_units( $unit ) {
345
+ return intergeo_filter_value( $unit, array( 'KILOMETERS_PER_HOUR', 'METERS_PER_SECOND', 'MILES_PER_HOUR' ) );
346
+ }
347
+
348
+ function intergeo_filter_temperature_units( $unit ) {
349
+ return intergeo_filter_value( $unit, array( 'CELSIUS', 'FAHRENHEIT' ) );
350
+ }
351
+
352
+ function intergeo_filter_adsense_format( $format ) {
353
+ return intergeo_filter_value( $format, array(
354
+ 'BANNER',
355
+ 'BUTTON',
356
+ 'HALF_BANNER',
357
+ 'LARGE_HORIZONTAL_LINK_UNIT',
358
+ 'LARGE_RECTANGLE',
359
+ 'LARGE_VERTICAL_LINK_UNIT',
360
+ 'LEADERBOARD',
361
+ 'MEDIUM_RECTANGLE',
362
+ 'MEDIUM_VERTICAL_LINK_UNIT',
363
+ 'SKYSCRAPER',
364
+ 'SMALL_HORIZONTAL_LINK_UNIT',
365
+ 'SMALL_RECTANGLE',
366
+ 'SMALL_SQUARE',
367
+ 'SMALL_VERTICAL_LINK_UNIT',
368
+ 'SQUARE',
369
+ 'VERTICAL_BANNER',
370
+ 'WIDE_SKYSCRAPER',
371
+ 'X_LARGE_VERTICAL_LINK_UNIT',
372
+ ) );
373
+ }
374
+
375
+ function intergeo_filter_custom_style( $style ) {
376
+ $style = trim( $style );
377
+ $json = @json_decode( $style, true );
378
+
379
+ return empty( $json ) ? null : $json;
380
+ }
381
+
382
+ function intergeo_filter_overlays_marker( $marker ) {
383
+ if ( !isset( $marker['position'] ) || !preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $marker['position'] ) ) {
384
+ return false;
385
+ }
386
+
387
+ return array(
388
+ 'position' => explode( ',', $marker['position'] ),
389
+ 'icon' => isset( $marker['icon'] ) ? filter_var( $marker['icon'], FILTER_VALIDATE_URL ) : '',
390
+ 'info' => isset( $marker['info'] ) ? trim( preg_replace( '/\<\/?script.*?\>/is', '', $marker['info'] ) ) : '',
391
+ 'title' => isset( $marker['title'] ) ? strip_tags( trim( $marker['title'] ) ) : '',
392
+ );
393
+ }
394
+
395
+ function intergeo_filter_overlays_polyline( $polyline ) {
396
+ if ( !isset( $polyline['path'] ) ) {
397
+ return false;
398
+ }
399
+
400
+ $path = array();
401
+ foreach( explode( ';', $polyline['path'] ) as $point ) {
402
+ if ( preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $point ) ) {
403
+ $path[] = explode( ',', $point );
404
+ }
405
+ }
406
+
407
+ if ( count( $path ) < 2 ) {
408
+ return false;
409
+ }
410
+
411
+ return array(
412
+ 'path' => $path,
413
+ 'weight' => isset( $polyline['weight'] )
414
+ ? filter_var( $polyline['weight'], FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'default' => '' ) ) )
415
+ : '',
416
+ 'opacity' => isset( $polyline['opacity'] )
417
+ ? filter_var( $polyline['opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) )
418
+ : '',
419
+ 'color' => isset( $polyline['color'] )
420
+ ? filter_var( $polyline['color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) )
421
+ : '#000000',
422
+ );
423
+ }
424
+
425
+ function intergeo_filter_overlays_polyoverlay( $polygon ) {
426
+ if ( !isset( $polygon['path'] ) ) {
427
+ return false;
428
+ }
429
+
430
+ $path = array();
431
+ foreach( explode( ';', $polygon['path'] ) as $point ) {
432
+ if ( preg_match( '/^-?\d+\.?\d*,-?\d+\.?\d*$/', $point ) ) {
433
+ $path[] = explode( ',', $point );
434
+ }
435
+ }
436
+
437
+ if ( count( $path ) < 2 ) {
438
+ return false;
439
+ }
440
+
441
+ $position = isset( $polygon['position'] ) ? strtoupper( trim( $polygon['position'] ) ) : 'CENTER';
442
+
443
+ return array(
444
+ 'path' => $path,
445
+ 'position' => in_array( $position, array( 'CENTER', 'INSIDE', 'OUTSIDE' ) ) ? $position : 'CENTER',
446
+ 'weight' => isset( $polygon['weight'] ) ? filter_var( $polygon['weight'], FILTER_VALIDATE_INT, array( 'options' => array( 'min_range' => 1, 'default' => '' ) ) ) : '',
447
+ 'stroke_opacity' => isset( $polygon['stroke_opacity'] ) ? filter_var( $polygon['stroke_opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) ) : '',
448
+ 'stroke_color' => isset( $polygon['stroke_color'] ) ? filter_var( $polygon['stroke_color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) ) : '#000000',
449
+ 'fill_opacity' => isset( $polygon['fill_opacity'] ) ? filter_var( $polygon['fill_opacity'], FILTER_VALIDATE_FLOAT, array( 'options' => array( 'min_range' => 0, 'max_range' => 1, 'default' => '' ) ) ) : '',
450
+ 'fill_color' => isset( $polygon['fill_color'] ) ? filter_var( $polygon['fill_color'], FILTER_VALIDATE_REGEXP, array( 'options' => array( 'regexp' => '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/', 'default' => '#000000' ) ) ) : '#000000',
451
+ );
452
+ }
453
+
454
+ function intergeo_filter_directions( $direction ) {
455
+ $to = isset( $direction['to'] ) ? trim( $direction['to'] ) : '';
456
+ $from = isset( $direction['from'] ) ? trim( $direction['from'] ) : '';
457
+
458
+ if ( empty( $to ) || empty( $from ) ) {
459
+ return false;
460
+ }
461
+
462
+ $mode = isset( $direction['mode'] ) ? strtoupper( trim( $direction['mode'] ) ) : 'DRIVING';
463
+
464
+ return array(
465
+ 'mode' => in_array( $mode, array( 'BICYCLING', 'DRIVING', 'TRANSIT', 'WALKING' ) ) ? $mode : 'DRIVING',
466
+ 'from' => $from,
467
+ 'to' => $to,
468
+ );
469
+ }
470
+
471
+ function intergeo_filter_input() {
472
+ $color_regexp = '/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/';
473
+ $postion_filter = array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_position' );
474
+
475
+ $validationArray = array (
476
+ 'lat' => array( 'filter' => FILTER_VALIDATE_FLOAT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => -90, 'max_range' => 90, 'default' => 48.1366069 ) ),
477
+ 'lng' => array( 'filter' => FILTER_VALIDATE_FLOAT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => -180, 'max_range' => 180, 'default' => 11.577085099999977 ) ),
478
+ 'zoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 5 ) ),
479
+ 'address' => FILTER_SANITIZE_STRING,
480
+ 'map_mapTypeId' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_map_type' ),
481
+ 'map_draggable' => FILTER_VALIDATE_BOOLEAN,
482
+ 'map_minZoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 0 ) ),
483
+ 'map_maxZoom' => array( 'filter' => FILTER_VALIDATE_INT, 'flags' => FILTER_REQUIRE_SCALAR, 'options' => array( 'min_range' => 0, 'max_range' => 19, 'default' => 19 ) ),
484
+ 'map_scrollwheel' => FILTER_VALIDATE_BOOLEAN,
485
+ 'map_zoomControl' => FILTER_VALIDATE_BOOLEAN,
486
+ 'map_zoomControlOptions_position' => $postion_filter,
487
+ 'map_zoomControlOptions_style' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_zoom_style' ),
488
+ 'map_panControl' => FILTER_VALIDATE_BOOLEAN,
489
+ 'map_panControlOptions_position' => $postion_filter,
490
+ 'map_scaleControl' => FILTER_VALIDATE_BOOLEAN,
491
+ 'map_scaleControlOptions_position' => $postion_filter,
492
+ 'map_mapTypeControl' => FILTER_VALIDATE_BOOLEAN,
493
+ 'map_mapTypeControlOptions_position' => $postion_filter,
494
+ 'map_mapTypeControlOptions_style' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_map_type_style' ),
495
+ 'map_mapTypeControlOptions_mapTypeIds' => array( 'filter' => FILTER_CALLBACK, 'flags' => FILTER_REQUIRE_ARRAY, 'options' => 'intergeo_filter_map_type' ),
496
+ 'map_streetViewControl' => FILTER_VALIDATE_BOOLEAN,
497
+ 'map_streetViewControlOptions_position' => $postion_filter,
498
+ 'map_rotateControl' => FILTER_VALIDATE_BOOLEAN,
499
+ 'map_rotateControlOptions_position' => $postion_filter,
500
+ 'map_overviewMapControl' => FILTER_VALIDATE_BOOLEAN,
501
+ 'map_overviewMapControlOptions_opened' => FILTER_VALIDATE_BOOLEAN,
502
+ 'layer_traffic' => FILTER_VALIDATE_BOOLEAN,
503
+ 'layer_bicycling' => FILTER_VALIDATE_BOOLEAN,
504
+ 'layer_cloud' => FILTER_VALIDATE_BOOLEAN,
505
+ 'layer_weather' => FILTER_VALIDATE_BOOLEAN,
506
+ 'weather_temperatureUnits' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_temperature_units' ),
507
+ 'weather_windSpeedUnits' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_wind_speed_units' ),
508
+ 'layer_panoramio' => FILTER_VALIDATE_BOOLEAN,
509
+ 'panoramio_tag' => FILTER_SANITIZE_STRING,
510
+ 'panoramio_userId' => FILTER_SANITIZE_STRING,
511
+ 'layer_adsense' => FILTER_VALIDATE_BOOLEAN,
512
+ 'adsense_format' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_adsense_format' ),
513
+ 'adsense_position' => $postion_filter,
514
+ 'adsense_backgroundColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#c4d4f3' ) ),
515
+ 'adsense_borderColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#e5ecf9' ) ),
516
+ 'adsense_titleColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#0000cc' ) ),
517
+ 'adsense_textColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#000000' ) ),
518
+ 'adsense_urlColor' => array( 'filter' => FILTER_VALIDATE_REGEXP, 'options' => array( 'regexp' => $color_regexp, 'default' => '#009900' ) ),
519
+ 'container_width' => FILTER_SANITIZE_STRING,
520
+ 'container_height' => FILTER_SANITIZE_STRING,
521
+ 'container_styles' => FILTER_SANITIZE_STRING,
522
+ 'styles_type' => FILTER_SANITIZE_STRING,
523
+ 'styles_custom' => array( 'filter' => FILTER_CALLBACK, 'options' => 'intergeo_filter_custom_style' ),
524
+ 'overlays_marker' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
525
+ 'overlays_polyline' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
526
+ 'overlays_polygon' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
527
+ 'overlays_rectangle' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
528
+ 'overlays_circle' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
529
+ 'directions' => array( 'filter' => FILTER_DEFAULT, 'flags' => FILTER_REQUIRE_ARRAY ),
530
+ );
531
+
532
+ $defaults = array (
533
+ 'lat' => 48.1366069,
534
+ 'lng' => 11.577085099999977,
535
+ 'zoom' => 5,
536
+ 'address' => '',
537
+ 'map_mapTypeId' => 'ROADMAP',
538
+ 'map_draggable' => true,
539
+ 'map_minZoom' => 0,
540
+ 'map_maxZoom' => 19,
541
+ 'map_scrollwheel' => true,
542
+ 'map_zoomControl' => true,
543
+ 'map_zoomControlOptions_position' => null,
544
+ 'map_zoomControlOptions_style' => 'DEFAULT',
545
+ 'map_panControl' => true,
546
+ 'map_panControlOptions_position' => null,
547
+ 'map_scaleControl' => false,
548
+ 'map_scaleControlOptions_position' => null,
549
+ 'map_mapTypeControl' => true,
550
+ 'map_mapTypeControlOptions_position' => null,
551
+ 'map_mapTypeControlOptions_style' => 'DEFAULT',
552
+ 'map_mapTypeControlOptions_mapTypeIds' => array( 'ROADMAP', 'TERRAIN', 'SATELLITE', 'HYBRID' ),
553
+ 'map_streetViewControl' => true,
554
+ 'map_streetViewControlOptions_position' => null,
555
+ 'map_rotateControl' => true,
556
+ 'map_rotateControlOptions_position' => null,
557
+ 'map_overviewMapControl' => false,
558
+ 'map_overviewMapControlOptions_opened' => false,
559
+ 'layer_traffic' => false,
560
+ 'layer_bicycling' => false,
561
+ 'layer_cloud' => false,
562
+ 'layer_weather' => false,
563
+ 'weather_temperatureUnits' => null,
564
+ 'weather_windSpeedUnits' => null,
565
+ 'layer_panoramio' => false,
566
+ 'panoramio_tag' => '',
567
+ 'panoramio_userId' => '',
568
+ 'layer_adsense' => false,
569
+ 'adsense_format' => null,
570
+ 'adsense_position' => null,
571
+ 'adsense_backgroundColor' => '#c4d4f3',
572
+ 'adsense_borderColor' => '#e5ecf9',
573
+ 'adsense_titleColor' => '#0000cc',
574
+ 'adsense_textColor' => '#000000',
575
+ 'adsense_urlColor' => '#009900',
576
+ 'container_width' => '',
577
+ 'container_height' => '',
578
+ 'container_styles' => '',
579
+ 'styles_type' => 'DEFAULT',
580
+ 'styles_custom' => null,
581
+ 'overlays_marker' => array(),
582
+ 'overlays_polyline' => array(),
583
+ 'overlays_polygon' => array(),
584
+ 'overlays_rectangle' => array(),
585
+ 'overlays_circle' => array(),
586
+ 'directions' => array(),
587
+ );
588
+
589
+ // Added by Ash/Upwork
590
+ if( defined( 'IntergeoMaps_Pro' ) ){
591
+ global $IntergeoMaps_Pro;
592
+ $IntergeoMaps_Pro->addValidations($validationArray, $defaults);
593
+ }
594
+ // Added by Ash/Upwork
595
+
596
+ $options = filter_input_array( INPUT_POST, $validationArray );
597
+
598
+ $results = array();
599
+ foreach ( $options as $key => $value ) {
600
+ if ( array_key_exists( $key, $defaults ) ) {
601
+ $equals = $defaults[$key] == $value;
602
+ if ( is_array( $value ) ) {
603
+ $equals = ( count( $value ) == count( $defaults[$key] ) ) && ( count( array_diff( (array)$defaults[$key], $value ) ) == 0 );
604
+ }
605
+
606
+ if ( !$equals ) {
607
+ $results[$key] = $value;
608
+ }
609
+ }
610
+ }
611
+
612
+ if ( !empty( $results['overlays_marker'] ) ) {
613
+ $results['overlays_marker'] = array_filter( array_map( 'intergeo_filter_overlays_marker', $results['overlays_marker'] ) );
614
+ }
615
+
616
+ if ( !empty( $results['overlays_polyline'] ) ) {
617
+ $results['overlays_polyline'] = array_filter( array_map( 'intergeo_filter_overlays_polyline', $results['overlays_polyline'] ) );
618
+ }
619
+
620
+ if ( !empty( $results['directions'] ) ) {
621
+ $results['directions'] = array_filter( array_map( 'intergeo_filter_directions', $results['directions'] ) );
622
+ }
623
+
624
+ foreach ( array( 'polygon', 'rectangle', 'circle' ) as $overlay ) {
625
+ $overlay = 'overlays_' . $overlay;
626
+ if ( !empty( $results[$overlay] ) ) {
627
+ $results[$overlay] = array_filter( array_map( 'intergeo_filter_overlays_polyoverlay', $results[$overlay] ) );
628
+ }
629
+ }
630
+
631
+ // Added by Ash/Upwork
632
+ if( defined( 'IntergeoMaps_Pro' ) ){
633
+ global $IntergeoMaps_Pro;
634
+ $IntergeoMaps_Pro->processResults($results);
635
+ }
636
+ // Added by Ash/Upwork
637
+
638
+ return $results;
639
+ }
640
+
641
+ // </editor-fold>
642
+
643
+ // <editor-fold defaultstate="collapsed" desc="saving">
644
+
645
+ function intergeo_save_map( $map_id = false, $post_id = false ) {
646
+ $options = array();
647
+ $array_ptr = &$options;
648
+ foreach ( intergeo_filter_input() as $key => $value ) {
649
+ if ( !is_null( $value ) ) {
650
+ $keys = explode( '_', $key );
651
+ $last_key = array_pop( $keys );
652
+
653
+ while ( $arr_key = array_shift( $keys ) ) {
654
+ if ( !array_key_exists( $arr_key, $array_ptr ) ) {
655
+ $array_ptr[$arr_key] = array( );
656
+ }
657
+ $array_ptr = &$array_ptr[$arr_key];
658
+ }
659
+
660
+ $array_ptr[$last_key] = $value;
661
+ $array_ptr = &$options;
662
+ }
663
+ }
664
+
665
+ $address = '';
666
+ if ( !empty( $options['address'] ) ) {
667
+ $address = $options['address'] = trim( $options['address'] );
668
+ }
669
+
670
+ $args = array(
671
+ 'post_type' => INTERGEO_PLUGIN_NAME,
672
+ 'post_content' => addcslashes( json_encode( $options ), '\\' ),
673
+ 'post_status' => 'private',
674
+ );
675
+
676
+ $update = false;
677
+ if ( $map_id ) {
678
+ $post = get_post( intergeo_decode( $map_id ) );
679
+ if ( $post && $post->post_type == INTERGEO_PLUGIN_NAME ) {
680
+ $update = true;
681
+ $args['ID'] = $post->ID;
682
+ }
683
+ }
684
+
685
+ $id = wp_insert_post( $args );
686
+
687
+ if ( !empty( $id ) && !is_wp_error( $id ) ) {
688
+ if ( !$post_id ) {
689
+ intergeo_set_info( $update
690
+ ? __( 'The map has been updated successfully.', INTERGEO_PLUGIN_NAME )
691
+ : __( 'The map has been created successfully.', INTERGEO_PLUGIN_NAME )
692
+ );
693
+ }
694
+ return sprintf( '[intergeo id="%s"]%s[/intergeo]', intergeo_encode( $id ), $address );
695
+ }
696
+
697
+ if ( !$post_id ) {
698
+ intergeo_set_error( $update
699
+ ? __( 'The map updating failed.', INTERGEO_PLUGIN_NAME )
700
+ : __( 'The map creation failed.', INTERGEO_PLUGIN_NAME )
701
+ );
702
+ }
703
+
704
+ return false;
705
+ }
706
+
707
+ // </editor-fold>
708
+
709
+ // <editor-fold defaultstate="collapsed" desc="ajax stuff">
710
+
711
+ add_action( 'wp_ajax_intergeo_show_map_center', 'intergeo_show_map_center_changed' );
712
+ function intergeo_show_map_center_changed() {
713
+ $nonce = filter_input( INPUT_POST, 'nonce' );
714
+ if ( wp_verify_nonce( $nonce, 'editor_popup' . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ) ) {
715
+ update_option( 'intergeo_show_map_center', (int)filter_input( INPUT_POST, 'status', FILTER_VALIDATE_BOOLEAN ) );
716
+ }
717
+ }
718
+
719
+ // </editor-fold>
720
+
721
+ // </editor-fold>
722
+
723
+ // <editor-fold defaultstate="collapsed" desc="shortcode">
724
+
725
+ add_filter( 'widget_text', 'do_shortcode' );
726
+ add_filter( 'term_description', 'do_shortcode' );
727
+
728
+ add_shortcode( INTERGEO_PLUGIN_NAME, 'intergeo_shortcode' );
729
+ function intergeo_shortcode( $attrs, $address = '' ) {
730
+ $args = shortcode_atts( array(
731
+ 'id' => false,
732
+ 'hook' => false,
733
+ 'width' => false,
734
+ 'height' => false,
735
+ 'style' => false,
736
+ 'zoom' => false,
737
+ ), $attrs );
738
+
739
+ $address = trim( $address );
740
+ if ( empty( $args['id'] ) && empty( $address ) ) {
741
+ return '';
742
+ }
743
+
744
+ $json = array();
745
+ if ( !empty( $args['id'] ) ) {
746
+ $post = get_post( intergeo_decode( $args['id'] ) );
747
+ if ( !$post || $post->post_type != INTERGEO_PLUGIN_NAME ) {
748
+ return '';
749
+ }
750
+
751
+ $json = json_decode( $post->post_content, true );
752
+ } else {
753
+ $args['id'] = intergeo_encode( rand( 0, 100 ) . rand( 0, 10000 ) );
754
+ $json['zoom'] = intval( $args['zoom'] ) ? intval( $args['zoom'] ) : 15;
755
+ }
756
+
757
+ if ( !empty( $address ) ) {
758
+ $json['address'] = $address;
759
+ }
760
+
761
+ if ( trim( $args['hook'] ) != '' ) {
762
+ $json = apply_filters( $args['hook'], $json );
763
+ }
764
+
765
+ wp_enqueue_style( 'intergeo-frontend' );
766
+ intergeo_enqueue_google_maps_script( intergeo_check_libraries( $json ) );
767
+ if ( !wp_script_is( 'intergeo-rendering' ) ) {
768
+ wp_enqueue_script( 'intergeo-rendering', INTERGEO_ABSURL . 'js/rendering.js', array( 'jquery', 'google-maps-v3' ), INTERGEO_VERSION );
769
+ wp_localize_script( 'intergeo-rendering', 'intergeo_options', array(
770
+ 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) )
771
+ ) );
772
+ }
773
+
774
+ $container = array();
775
+ if ( isset( $json['container'] ) ) {
776
+ $container = $json['container'];
777
+ unset( $json['container'] );
778
+ }
779
+
780
+ $width = !empty( $container['width'] ) ? esc_attr( $container['width'] ) : '100%';
781
+ if ( trim( $args['width'] ) != '' ) {
782
+ $width = $args['width'];
783
+ }
784
+ if ( is_numeric( $width ) ) {
785
+ $width .= 'px';
786
+ }
787
+
788
+ $height = !empty( $container['height'] ) ? esc_attr( $container['height'] ) : '300px';
789
+ if ( trim( $args['height'] ) != '' ) {
790
+ $height = $args['height'];
791
+ }
792
+ if ( is_numeric( $height ) ) {
793
+ $height .= 'px';
794
+ }
795
+
796
+ $styles = !empty( $container['styles'] ) ? esc_attr( $container['styles'] ) : '';
797
+ if ( trim( $args['style'] ) != '' ) {
798
+ $styles = $args['style'];
799
+ }
800
+
801
+ return sprintf( '
802
+ <div id="intergeo_map%1$s" class="intergeo_map_canvas" style="width:100%%;height:300px;width:%2$s;height:%3$s;%4$s"></div>
803
+ <script type="text/javascript">
804
+ /* <![CDATA[ */
805
+ if (!window.intergeo_maps) window.intergeo_maps = [];
806
+ window.intergeo_maps.push( { container: \'intergeo_map%1$s\', options: %5$s } );
807
+ if (!window.intergeo_maps_current) window.intergeo_maps_current = null;
808
+ /* ]]> */
809
+ </script>
810
+ ',
811
+ $args['id'],
812
+ $width,
813
+ $height,
814
+ $styles,
815
+ json_encode( $json )
816
+ );
817
+ }
818
+
819
+ // </editor-fold>
820
+
821
+ // <editor-fold defaultstate="collapsed" desc="library">
822
+
823
+ add_action( 'admin_menu', 'intergeo_admin_menu' );
824
+ function intergeo_admin_menu() {
825
+ $page = add_submenu_page( 'upload.php', 'Intergeo Maps Library', 'Intergeo Maps', 'edit_posts', INTERGEO_PLUGIN_NAME, 'intergeo_library' );
826
+ if ( $page ) {
827
+ add_action( "load-{$page}", 'intergeo_library_init' );
828
+ }
829
+ }
830
+
831
+ function intergeo_library_init() {
832
+ wp_enqueue_style( 'intergeo_library', INTERGEO_ABSURL . 'css/library.css', array(), INTERGEO_VERSION );
833
+ wp_enqueue_media();
834
+
835
+ $screen = get_current_screen();
836
+
837
+ $screen->add_help_tab( array(
838
+ 'title' => esc_html__( 'Overview', INTERGEO_PLUGIN_NAME ),
839
+ 'id' => 'overview',
840
+ 'content' => sprintf( '<p>%s</p>', implode( '</p><p>', array(
841
+ esc_html__( "The library is a list to view all maps you have created in your system. The library is showing you 3x3 grid of maps' previews. You will see the same maps embedded into your posts at front end, as you see here. The library is paginated and if you have more than 9 maps, you will see pagination links under maps grid.", INTERGEO_PLUGIN_NAME ),
842
+ esc_html__( 'To create a new map, click on "Add New" button next to the page title and map editor popup will appear. In case you want to edit a map, you can click on pencil icon in the right bottom corner of map preview box and edit popup window will appear.', INTERGEO_PLUGIN_NAME ),
843
+ esc_html__( "If you want to delete a map, click on the trash icon in the right bottom corner of a map and confirm your action. Pay attention that whole information about the map will be removed from the system, but all shortcodes will be left where you embed it. However these deprecated shortcodes won't be rendered anymore, so you don't have to worry about it while the plugin is enabled.", INTERGEO_PLUGIN_NAME ),
844
+ ) ) ),
845
+ ) );
846
+
847
+ $screen->add_help_tab( array(
848
+ 'title' => esc_html__( 'Shortcodes', INTERGEO_PLUGIN_NAME ),
849
+ 'id' => 'shortcodes',
850
+ 'content' => sprintf( '<p>%s</p>', implode( '</p><p>', array(
851
+ esc_html__( 'You can easily embed a map into your posts, pages, categories or tags descriptions and text widgets by copying shortcode which you can find in the input field of a map preview box.', INTERGEO_PLUGIN_NAME ),
852
+ esc_html__( 'To specify a certain address just type it inside a shortcode, and a map will be automatically centered at this place. Also each shortcode could be extended with custom attributes like width, height, style, zoom and hook. Use standard CSS values for such attributes as width, height and style. Type an integer between 0 and 19 for zoom attribute. You can use hook attribute to set up a filter hook which you can use in your custom plugin or theme to configure all options of a map.', INTERGEO_PLUGIN_NAME ),
853
+ ) ) ),
854
+ ) );
855
+ }
856
+
857
+ function intergeo_library() {
858
+ if ( filter_input( INPUT_GET, 'do' ) == 'delete' ) {
859
+ intergeo_library_delete();
860
+ }
861
+
862
+ $query = new WP_Query( array(
863
+ 'orderby' => 'ID',
864
+ 'order' => 'DESC',
865
+ 'post_type' => INTERGEO_PLUGIN_NAME,
866
+ 'posts_per_page' => 9,
867
+ 'paged' => filter_input( INPUT_GET, 'pagenum', FILTER_VALIDATE_INT, array( 'options' => array(
868
+ 'min_range' => 1,
869
+ 'default' => 1,
870
+ ) ) ),
871
+ ) );
872
+
873
+ $libraries = array();
874
+ $pagination = paginate_links( array(
875
+ 'base' => add_query_arg( array(
876
+ 'pagenum' => '%#%',
877
+ 'updated' => false,
878
+ ) ),
879
+ 'format' => '',
880
+ 'current' => max( 1, $query->get( 'paged' ) ),
881
+ 'total' => $query->max_num_pages,
882
+ 'type' => 'array',
883
+ ) );
884
+
885
+ require INTERGEO_ABSPATH . '/templates/library/list.php';
886
+
887
+ intergeo_enqueue_google_maps_script( $libraries );
888
+
889
+ wp_enqueue_script( 'intergeo-rendering', INTERGEO_ABSURL . 'js/rendering.js', array( 'jquery', 'google-maps-v3' ), INTERGEO_VERSION );
890
+ wp_enqueue_script( 'intergeo-library', INTERGEO_ABSURL . 'js/library.js', array( 'intergeo-rendering', 'media-views' ), INTERGEO_VERSION );
891
+
892
+ wp_localize_script( 'intergeo-rendering', 'intergeo_options', array(
893
+ 'adsense' => array( 'publisher_id' => get_option( 'intergeo_adsense_publisher_id' ) )
894
+ ) );
895
+
896
+ // Added by Ash/Upwork
897
+ if( defined( 'IntergeoMaps_Pro' ) ){
898
+ global $IntergeoMaps_Pro;
899
+ $IntergeoMaps_Pro->enqueueScriptsAndStyles(array('intergeo-rendering'));
900
+ }
901
+ // Added by Ash/Upwork
902
+
903
+ }
904
+
905
+ function intergeo_library_delete() {
906
+ if ( !current_user_can( 'delete_posts' ) ) {
907
+ return;
908
+ }
909
+
910
+ $id = intergeo_decode( trim( filter_input( INPUT_GET, 'map' ) ) );
911
+ if ( !$id ) {
912
+ return;
913
+ }
914
+
915
+ $post = get_post( $id );
916
+ if ( wp_verify_nonce( filter_input( INPUT_GET, 'nonce' ), $id . filter_input( INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP ) ) && $post->post_type == INTERGEO_PLUGIN_NAME ) {
917
+ if ( wp_delete_post( $id, true ) ) {
918
+ intergeo_set_info( __( 'The map was deleted successfully.', INTERGEO_PLUGIN_NAME ) );
919
+ }
920
+ }
921
+
922
+ if ( filter_input( INPUT_GET, 'noheader', FILTER_VALIDATE_BOOLEAN ) ) {
923
+ wp_redirect( add_query_arg( 'page', INTERGEO_PLUGIN_NAME, admin_url( 'upload.php' ) ) );
924
+ exit;
925
+ }
926
+ }
927
+
928
+ // </editor-fold>
929
+
930
+ // <editor-fold defaultstate="collapsed" desc="messaging functions">
931
+
932
+ function intergeo_set_message( $message, $is_normal, $user_id = false ) {
933
+ $messages = get_option( 'intergeo_messages', array() );
934
+ if ( $user_id === false ) {
935
+ $user_id = get_current_user_id();
936
+ }
937
+
938
+ if ( !isset( $messages[$user_id] ) ) {
939
+ $messages[$user_id] = array();
940
+ }
941
+
942
+ $messages[$user_id][] = array( $message, $is_normal );
943
+ update_option( 'intergeo_messages', $messages );
944
+ }
945
+
946
+ function intergeo_set_info( $message, $user_id = false ) {
947
+ intergeo_set_message( $message, 1, $user_id );
948
+ }
949
+
950
+ function intergeo_set_error( $message, $user_id = false ) {
951
+ intergeo_set_message( $message, 0, $user_id );
952
+ }
953
+
954
+ add_action( 'admin_notices', 'intergeo_print_messages' );
955
+ function intergeo_print_messages() {
956
+ global $pagenow;
957
+
958
+ // Added by Ash/Upwork
959
+ intergeo_show_nag();
960
+ // Added by Ash/Upwork
961
+
962
+ if ( $pagenow != 'upload.php' ) {
963
+ return;
964
+ }
965
+
966
+ $messages = get_option( 'intergeo_messages', array() );
967
+ $user_id = get_current_user_id();
968
+
969
+ if ( !isset( $messages[$user_id] ) ) {
970
+ return;
971
+ }
972
+
973
+ foreach ( $messages[$user_id] as $message ) {
974
+ printf( $message[1] ? '<div class="updated"><p>%s</p></div>' : '<div class="error"><p>%s</p></div>', __($message[0], INTERGEO_PLUGIN_NAME) );
975
+ }
976
+
977
+ $messages[$user_id] = array();
978
+ update_option( 'intergeo_messages', $messages );
979
+ }
980
+
981
+ // Added by Ash/Upwork
982
+ add_action( 'admin_enqueue_scripts', 'intergeo_enqueue_scripts' );
983
+ function intergeo_enqueue_scripts()
984
+ {
985
+ wp_enqueue_script( 'intergeo-misc', INTERGEO_ABSURL . 'js/misc.js', array( 'jquery' ), INTERGEO_VERSION );
986
+ wp_localize_script( 'intergeo-misc', 'intergeo_misc', array(
987
+ "ajax" => array(
988
+ "action" => "intergeo_dismiss_nag",
989
+ "nonce" => wp_create_nonce(INTERGEO_PLUGIN_NAME . INTERGEO_VERSION),
990
+ )
991
+ ));
992
+ }
993
+
994
+ add_action( 'wp_ajax_intergeo_dismiss_nag', 'intergeo_dismiss_nag' );
995
+ function intergeo_dismiss_nag() {
996
+ check_ajax_referer(INTERGEO_PLUGIN_NAME . INTERGEO_VERSION, "security");
997
+
998
+ update_option("intergeo_nag_dismissed", true);
999
+ wp_die();
1000
+ }
1001
+
1002
+ function intergeo_show_nag()
1003
+ {
1004
+ global $pagenow;
1005
+
1006
+ if ( $pagenow == 'plugins.php' && !get_option("intergeo_nag_dismissed", false)) {
1007
+ include_once INTERGEO_ABSPATH . '/templates/nag.php';
1008
+ }
1009
+ }
1010
+ // Added by Ash/Upwork
1011
+
1012
+ // </editor-fold>
js/editor.js CHANGED
@@ -1,1123 +1,1123 @@
1
- (function() {
2
- var a = window.dialogArguments || opener || parent || top;
3
- if (intergeo_options.send_to_editor && a.send_to_editor) {
4
- a.send_to_editor(intergeo_options.send_to_editor)
5
- }
6
- })();
7
- (function(a, b) {
8
- if (typeof define == "function") {
9
- define(b)
10
- } else {
11
- if (typeof module != "undefined") {
12
- module.exports = b()
13
- } else {
14
- this[a] = b()
15
- }
16
- }
17
- })("klass", function() {
18
- var c = this,
19
- d = c.klass,
20
- h = "function",
21
- k = /xyz/.test(function() {
22
- xyz
23
- }) ? /\bsupr\b/ : /.*/,
24
- e = "prototype";
25
-
26
- function i(f) {
27
- return j.call(g(f) ? f : function() {}, f, 1)
28
- }
29
-
30
- function g(f) {
31
- return typeof f === h
32
- }
33
-
34
- function b(l, m, f) {
35
- return function() {
36
- var o = this.supr;
37
- this.supr = f[e][l];
38
- var p = {}.fabricatedUndefined;
39
- var n = p;
40
- try {
41
- n = m.apply(this, arguments)
42
- } finally {
43
- this.supr = o
44
- }
45
- return n
46
- }
47
- }
48
-
49
- function a(m, n, f) {
50
- for (var l in n) {
51
- if (n.hasOwnProperty(l)) {
52
- m[l] = g(n[l]) && g(f[e][l]) && k.test(n[l]) ? b(l, n[l], f) : n[l]
53
- }
54
- }
55
- }
56
-
57
- function j(m, p) {
58
- function t() {}
59
- t[e] = this[e];
60
- var q = this,
61
- s = new t(),
62
- n = g(m),
63
- f = n ? m : this,
64
- l = n ? {} : m;
65
-
66
- function r() {
67
- if (this.initialize) {
68
- this.initialize.apply(this, arguments)
69
- } else {
70
- p || n && q.apply(this, arguments);
71
- f.apply(this, arguments)
72
- }
73
- }
74
- r.methods = function(u) {
75
- a(s, u, q);
76
- r[e] = s;
77
- return this
78
- };
79
- r.methods.call(r, l).prototype.constructor = r;
80
- r.extend = arguments.callee;
81
- r[e].implement = r.statics = function(v, u) {
82
- v = typeof v == "string" ? (function() {
83
- var o = {};
84
- o[v] = u;
85
- return o
86
- }()) : v;
87
- a(this, v, q);
88
- return this
89
- };
90
- return r
91
- }
92
- i.noConflict = function() {
93
- c.klass = d;
94
- return this
95
- };
96
- c.klass = i;
97
- return i
98
- });
99
- if (!window.intergeo) {
100
- window.intergeo = {
101
- maps: {}
102
- }
103
- }
104
- if (!window.intergeo.maps) {
105
- window.intergeo.maps = {}
106
- }(function(c, b, a) {
107
- a.Overlay = klass({
108
- initialize: function(h, f, g, d, i) {
109
- var e = this;
110
- e.map = h;
111
- e.overlay = f;
112
- e.html = g;
113
- e.position = d;
114
- e.array = i;
115
- e.timeout = null;
116
- e.bindRemoveEvent(i)
117
- },
118
- bindRemoveEvent: function(e) {
119
- var d = this;
120
- d.html.find(".intergeo_tlbr_actn_delete").click(function() {
121
- if (showNotice.warn()) {
122
- d.overlay.setMap(null);
123
- d.map[e][d.position] = null;
124
- d.html.remove()
125
- }
126
- })
127
- }
128
- });
129
- a.Marker = a.Overlay.extend({
130
- initialize: function(i, f, g, d) {
131
- var e = this,
132
- h = new b.InfoWindow();
133
- e.supr(i, f, g, d, "markers");
134
- g.hover(function() {
135
- if (i.markers[d]) {
136
- f.setAnimation(b.Animation.BOUNCE)
137
- }
138
- }, function() {
139
- if (i.markers[d]) {
140
- f.setAnimation(null)
141
- }
142
- });
143
- e.html.find(".intergeo_tlbr_actn_edit").click(function() {
144
- var j = c("#intergeo_marker_ppp");
145
- j.find(".intergeo_ppp_frm").attr("data-position", d);
146
- j.find(".intergeo_tlbr_marker_title").val(g.find(".intergeo_tlbr_marker_title").val());
147
- j.find(".intergeo_tlbr_marker_icon").val(g.find(".intergeo_tlbr_marker_icon").val());
148
- j.find(".intergeo_tlbr_marker_info").val(g.find(".intergeo_tlbr_marker_info").val());
149
- j.fadeIn(150)
150
- });
151
- b.event.addListener(f, "dragend", function(j) {
152
- g.find(".intergeo_tlbr_marker_location").val(j.latLng.toUrlValue())
153
- });
154
- b.event.addListener(f, "click", function() {
155
- var j = c.trim(g.find(".intergeo_tlbr_marker_info").val());
156
- if (j.length) {
157
- if (i.infowindow) {
158
- i.infowindow.close()
159
- }
160
- h.setContent(j);
161
- h.open(i.map, f);
162
- i.infowindow = h
163
- }
164
- })
165
- },
166
- update: function(g) {
167
- var d = this,
168
- e = {},
169
- i = c.trim(g.find(".intergeo_tlbr_marker_title").val()),
170
- f = c.trim(g.find(".intergeo_tlbr_marker_icon").val()),
171
- h = c.trim(g.find(".intergeo_tlbr_marker_info").val()),
172
- j = d.html.find(".intergeo_tlbr_marker_title_td");
173
- e.title = i;
174
- if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(f)) {
175
- e.icon = f
176
- } else {
177
- e.icon = null
178
- }
179
- d.html.find(".intergeo_tlbr_marker_title").val(i);
180
- d.html.find(".intergeo_tlbr_marker_icon").val(f);
181
- d.html.find(".intergeo_tlbr_marker_info").val(h);
182
- d.overlay.setOptions(e);
183
- if (i != "") {
184
- j.text(i)
185
- } else {
186
- j.text("#" + (d.position + 1) + " " + intergeo_options.l10n.marker)
187
- }
188
- }
189
- });
190
- a.PolyOverlay = a.Overlay.extend({
191
- initialize: function(h, f, g, d, i) {
192
- var e = this;
193
- e.supr(h, f, g, d, i);
194
- e.html.find(".intergeo_tlbr_actn_edit").click(function() {
195
- e.edit();
196
- return false
197
- })
198
- },
199
- pathToString: function() {
200
- var d = [];
201
- this.overlay.getPath().forEach(function(e) {
202
- d.push(e.toUrlValue())
203
- });
204
- return d.join(";")
205
- },
206
- bindChangeEvent: function(e) {
207
- var d = this;
208
- b.event.addListener(d.overlay, e, function() {
209
- d.html.find(".intergeo_tlbr_" + d.array + "_path").val(d.pathToString())
210
- })
211
- },
212
- edit: function() {
213
- var d = this,
214
- e = c("#intergeo_polyoverlay_ppp"),
215
- g = c.trim(d.html.find(".intergeo_tlbr_" + d.array + "_fill_color").val()),
216
- f = c.trim(d.html.find(".intergeo_tlbr_" + d.array + "_stroke_color").val());
217
- e.find(".intergeo_ppp_frm").attr("data-position", d.position).attr("data-target", d.array);
218
- if (!g) {
219
- g = "#000000"
220
- }
221
- e.find(".intergeo_tlbr_polyoverlay_fill_color").val(g).wpColorPicker("color", g);
222
- e.find(".intergeo_tlbr_polyoverlay_fill_opacity").val(d.html.find(".intergeo_tlbr_" + d.array + "_fill_opacity").val());
223
- if (!f) {
224
- f = "#000000"
225
- }
226
- e.find(".intergeo_tlbr_polyoverlay_stroke_color").val(f).wpColorPicker("color", f);
227
- e.find(".intergeo_tlbr_polyoverlay_weight").val(d.html.find(".intergeo_tlbr_" + d.array + "_weight").val());
228
- e.find(".intergeo_tlbr_polyoverlay_stroke_opacity").val(d.html.find(".intergeo_tlbr_" + d.array + "_stroke_opacity").val());
229
- e.find(".intergeo_tlbr_polyoverlay_position").val(d.html.find(".intergeo_tlbr_" + d.array + "_position").val());
230
- e.fadeIn(150)
231
- },
232
- update: function(e) {
233
- var n = this,
234
- o = {},
235
- k = e.find(".intergeo_tlbr_polyoverlay_position").val(),
236
- j = parseInt(e.find(".intergeo_tlbr_polyoverlay_weight").val()),
237
- i = !isNaN(j) && 0 <= j,
238
- f = parseFloat(e.find(".intergeo_tlbr_polyoverlay_stroke_opacity").val()),
239
- d = !isNaN(f) && 0 <= f && f <= 1,
240
- h = c.trim(e.find(".intergeo_tlbr_polyoverlay_stroke_color").val()),
241
- g = parseFloat(e.find(".intergeo_tlbr_polyoverlay_fill_opacity").val()),
242
- l = !isNaN(g) && 0 <= g && g <= 1,
243
- m = c.trim(e.find(".intergeo_tlbr_polyoverlay_fill_color").val());
244
- o.strokePosition = b.StrokePosition[k] || b.StrokePosition.CENTER;
245
- o.strokeWeight = i ? j : 3;
246
- o.strokeOpacity = d ? f : 1;
247
- o.strokeColor = h;
248
- o.fillOpacity = l ? g : 0.3;
249
- o.fillColor = m;
250
- n.html.find(".intergeo_tlbr_" + n.array + "_position").val(k);
251
- n.html.find(".intergeo_tlbr_" + n.array + "_weight").val(i ? j : "");
252
- n.html.find(".intergeo_tlbr_" + n.array + "_stroke_opacity").val(d ? f : "");
253
- n.html.find(".intergeo_tlbr_" + n.array + "_stroke_color").val(h);
254
- n.html.find(".intergeo_tlbr_" + n.array + "_fill_opacity").val(l ? g : "");
255
- n.html.find(".intergeo_tlbr_" + n.array + "_fill_color").val(m);
256
- n.html.find(".intergeo_tlbr_clr_prvw:last").css("background-color", h).fadeTo(0, d ? f : 1);
257
- n.html.find(".intergeo_tlbr_clr_prvw:first").css("background-color", m).fadeTo(0, l ? g : 0.3);
258
- n.overlay.setOptions(o)
259
- }
260
- });
261
- a.PolyOverlay.stringToPath = function(e, d) {
262
- var f = [];
263
- c.each(e.find(d).val().split(";"), function(h, i) {
264
- var g = i.split(",");
265
- if (g.length == 2) {
266
- f.push(new b.LatLng(g[0], g[1]))
267
- }
268
- });
269
- return f
270
- };
271
- a.PolyOverlay.stringToBounds = function(e, d) {
272
- var f = a.PolyOverlay.stringToPath(e, d);
273
- return new b.LatLngBounds(f[0], f[1])
274
- };
275
- a.Polyline = a.PolyOverlay.extend({
276
- initialize: function(g, e, f, d) {
277
- this.supr(g, e, f, d, "polyline");
278
- this.bindChangeEvent("mouseup")
279
- },
280
- edit: function() {
281
- var e = this,
282
- f = c("#intergeo_polyline_ppp"),
283
- d = c.trim(e.html.find(".intergeo_tlbr_polyline_color").val());
284
- f.find(".intergeo_ppp_frm").attr("data-position", e.position).attr("data-target", "polyline");
285
- f.find(".intergeo_tlbr_polyline_weight").val(e.html.find(".intergeo_tlbr_polyline_weight").val());
286
- f.find(".intergeo_tlbr_polyline_opacity").val(e.html.find(".intergeo_tlbr_polyline_opacity").val());
287
- if (!d) {
288
- d = "#000000"
289
- }
290
- f.find(".intergeo_tlbr_polyline_color").val(d).wpColorPicker("color", d);
291
- f.fadeIn(150)
292
- },
293
- update: function(i) {
294
- var e = this,
295
- g = {},
296
- j = parseInt(i.find(".intergeo_tlbr_polyline_weight").val()),
297
- k = !isNaN(j) && 0 <= j,
298
- f = parseFloat(i.find(".intergeo_tlbr_polyline_opacity").val()),
299
- h = !isNaN(f) && 0 <= f && f <= 1,
300
- d = c.trim(i.find(".intergeo_tlbr_polyline_color").val());
301
- g.strokeOpacity = h ? f : 1;
302
- g.strokeWeight = k ? j : 3;
303
- g.strokeColor = d;
304
- e.html.find(".intergeo_tlbr_polyline_weight").val(k ? j : "");
305
- e.html.find(".intergeo_tlbr_polyline_opacity").val(h ? f : "");
306
- e.html.find(".intergeo_tlbr_polyline_color").val(d);
307
- e.html.find(".intergeo_tlbr_clr_prvw").css("background-color", d).fadeTo(0, h ? f : 1);
308
- e.overlay.setOptions(g)
309
- }
310
- });
311
- a.Polygon = a.PolyOverlay.extend({
312
- initialize: function(g, e, f, d) {
313
- this.supr(g, e, f, d, "polygon");
314
- this.bindChangeEvent("mouseup")
315
- }
316
- });
317
- a.Rectangle = a.PolyOverlay.extend({
318
- initialize: function(g, e, f, d) {
319
- this.supr(g, e, f, d, "rectangle");
320
- this.bindChangeEvent("bounds_changed")
321
- },
322
- pathToString: function() {
323
- var d = this.overlay.getBounds();
324
- return [d.getSouthWest().toUrlValue(), d.getNorthEast().toUrlValue()].join(";")
325
- }
326
- });
327
- a.Circle = a.PolyOverlay.extend({
328
- initialize: function(g, e, f, d) {
329
- this.supr(g, e, f, d, "circle");
330
- this.bindChangeEvent("center_changed");
331
- this.bindChangeEvent("radius_changed")
332
- },
333
- pathToString: function() {
334
- var d = this.overlay;
335
- return d.getCenter().toUrlValue() + ";" + d.getRadius() + ",0"
336
- }
337
- });
338
- a.Direction = a.PolyOverlay.extend({
339
- initialize: function(g, e, f, d) {
340
- this.supr(g, e, f, d, "direction")
341
- },
342
- edit: function() {
343
- var d = this,
344
- e = c("#intergeo_drctn_ppp");
345
- e.find(".intergeo_ppp_frm").attr("data-position", d.position).attr("data-target", d.array);
346
- e.find("#intergeo_ppp_drctn_from").val(d.html.find(".intergeo_tlbr_drctn_from").val());
347
- e.find("#intergeo_ppp_drctn_to").val(d.html.find(".intergeo_tlbr_drctn_to").val());
348
- e.find("#intergeo_ppp_drctn_mode").val(d.html.find(".intergeo_tlbr_drctn_mode").val());
349
- e.fadeIn(150)
350
- },
351
- update: function(f) {
352
- var d = this,
353
- i = f.find("#intergeo_ppp_drctn_from").val(),
354
- h = f.find("#intergeo_ppp_drctn_to").val(),
355
- g = f.find("#intergeo_ppp_drctn_mode").val(),
356
- e = {
357
- origin: i,
358
- destination: h,
359
- travelMode: b.TravelMode[g] || b.TravelMode.DRIVING
360
- };
361
- d.map.directions.route(e, function(k, j) {
362
- if (j == b.DirectionsStatus.OK) {
363
- d.overlay.setDirections(k);
364
- d.html.find(".intergeo_tlbr_direction_title_td").text(c("#intergeo_tlbr_drctn_ttl_tmpl").text().replaceByHash({
365
- "%num%": d.position + 1,
366
- "%from%": i,
367
- "%to%": h,
368
- "%mode%": f.find("#intergeo_ppp_drctn_mode > :selected").text()
369
- }))
370
- } else {
371
- alert(intergeo_options.l10n.error.directions)
372
- }
373
- });
374
- d.html.find(".intergeo_tlbr_drctn_from").val(i);
375
- d.html.find(".intergeo_tlbr_drctn_to").val(h);
376
- d.html.find(".intergeo_tlbr_drctn_mode").val(g)
377
- }
378
- })
379
- })(jQuery, google.maps, intergeo.maps);
380
- (function(d, c, b) {
381
- var a;
382
- String.prototype.replaceByHash = function(e) {
383
- var f = this;
384
- d.each(e, function(g, h) {
385
- f = f.split(g).join(h)
386
- });
387
- return f
388
- };
389
- a = function(e, g) {
390
- var f = this;
391
- f.map = new c.Map(document.getElementById(e), g);
392
- f.drawing = new c.drawing.DrawingManager({
393
- drawingControl: false,
394
- map: f.map,
395
- circleOptions: {
396
- editable: true
397
- },
398
- markerOptions: {
399
- draggable: true
400
- },
401
- polygonOptions: {
402
- editable: true
403
- },
404
- polylineOptions: {
405
- editable: true
406
- },
407
- rectangleOptions: {
408
- editable: true
409
- }
410
- });
411
- f.directions = new c.DirectionsService();
412
- f.geocoder = null;
413
- f.traffic = null;
414
- f.bicycling = null;
415
- f.weather = null;
416
- f.cloud = null;
417
- f.panoramio = null;
418
- f.adunit = null;
419
- f.markers = [];
420
- f.polyline = [];
421
- f.polygon = [];
422
- f.rectangle = [];
423
- f.circle = [];
424
- f.direction = [];
425
- f.infowindow = null;
426
- c.event.addListener(f.map, "center_changed", function() {
427
- var h = f.map.getCenter();
428
- d("#intergeo_map_lat").val(h.lat());
429
- d("#intergeo_map_lng").val(h.lng())
430
- });
431
- c.event.addListener(f.map, "zoom_changed", function() {
432
- d("#intergeo_map_zoom").val(f.map.getZoom())
433
- });
434
- c.event.addListener(f.drawing, "overlaycomplete", function(h) {
435
- switch (h.type) {
436
- case c.drawing.OverlayType.MARKER:
437
- f._markerComplete(h);
438
- break;
439
- case c.drawing.OverlayType.CIRCLE:
440
- f._polyComplete(h, "circle", b.Circle);
441
- break;
442
- case c.drawing.OverlayType.POLYGON:
443
- f._polyComplete(h, "polygon", b.Polygon);
444
- break;
445
- case c.drawing.OverlayType.POLYLINE:
446
- f._polyComplete(h, "polyline", b.Polyline);
447
- break;
448
- case c.drawing.OverlayType.RECTANGLE:
449
- f._polyComplete(h, "rectangle", b.Rectangle);
450
- break
451
- }
452
- });
453
- f._initOverlays()
454
- };
455
- a.Styles = {
456
- DEFAULT: [],
457
- RED: [{
458
- featureType: "all",
459
- stylers: [{
460
- hue: "#ff0000"
461
- }]
462
- }],
463
- NIGHT: [{
464
- featureType: "all",
465
- stylers: [{
466
- invert_lightness: "true"
467
- }]
468
- }],
469
- BLUE: [{
470
- featureType: "all",
471
- stylers: [{
472
- hue: "#0000b0"
473
- }, {
474
- invert_lightness: "true"
475
- }, {
476
- saturation: -30
477
- }]
478
- }],
479
- GREYSCALE: [{
480
- featureType: "all",
481
- stylers: [{
482
- saturation: -100
483
- }, {
484
- gamma: 0.5
485
- }]
486
- }],
487
- NO_ROADS: [{
488
- featureType: "road",
489
- stylers: [{
490
- visibility: "off"
491
- }]
492
- }],
493
- MIXED: [{
494
- featureType: "landscape",
495
- stylers: [{
496
- hue: "#00dd00"
497
- }]
498
- }, {
499
- featureType: "road",
500
- stylers: [{
501
- hue: "#dd0000"
502
- }]
503
- }, {
504
- featureType: "water",
505
- stylers: [{
506
- hue: "#000040"
507
- }]
508
- }, {
509
- featureType: "poi.park",
510
- stylers: [{
511
- visibility: "off"
512
- }]
513
- }, {
514
- featureType: "road.arterial",
515
- stylers: [{
516
- hue: "#ffff00"
517
- }]
518
- }, {
519
- featureType: "road.local",
520
- stylers: [{
521
- visibility: "off"
522
- }]
523
- }],
524
- CHILLED: [{
525
- featureType: "road",
526
- elementType: "geometry",
527
- stylers: [{
528
- visibility: "simplified"
529
- }]
530
- }, {
531
- featureType: "road.arterial",
532
- stylers: [{
533
- hue: 149
534
- }, {
535
- saturation: -78
536
- }, {
537
- lightness: 0
538
- }]
539
- }, {
540
- featureType: "road.highway",
541
- stylers: [{
542
- hue: -31
543
- }, {
544
- saturation: -40
545
- }, {
546
- lightness: 2.8
547
- }]
548
- }, {
549
- featureType: "poi",
550
- elementType: "label",
551
- stylers: [{
552
- visibility: "off"
553
- }]
554
- }, {
555
- featureType: "landscape",
556
- stylers: [{
557
- hue: 163
558
- }, {
559
- saturation: -26
560
- }, {
561
- lightness: -1.1
562
- }]
563
- }, {
564
- featureType: "transit",
565
- stylers: [{
566
- visibility: "off"
567
- }]
568
- }, {
569
- featureType: "water",
570
- stylers: [{
571
- hue: 3
572
- }, {
573
- saturation: -24.24
574
- }, {
575
- lightness: -38.57
576
- }]
577
- }]
578
- };
579
- a.prototype = {
580
- _initOverlays: function() {
581
- var e = this;
582
- d(".intergeo_tlbr_marker").each(function(f, i) {
583
- var h = d(i),
584
- g = h.find(".intergeo_tlbr_marker_location").val().split(",");
585
- e.markers.push(new b.Marker(e, new c.Marker({
586
- position: new c.LatLng(parseFloat(g[0]), parseFloat(g[1])),
587
- map: e.map,
588
- title: h.find(".intergeo_tlbr_marker_title").val(),
589
- icon: h.find(".intergeo_tlbr_marker_icon").val(),
590
- draggable: true
591
- }), h, f))
592
- });
593
- d(".intergeo_tlbr_polyline").each(function(f, j) {
594
- var i = d(j),
595
- g = d.trim(i.find(".intergeo_tlbr_polyline_color").val()),
596
- h = parseFloat(i.find(".intergeo_tlbr_polyline_opacity").val()),
597
- k = parseInt(i.find(".intergeo_tlbr_polyline_weight").val());
598
- e.polyline.push(new b.Polyline(e, new c.Polyline({
599
- map: e.map,
600
- path: b.PolyOverlay.stringToPath(i, ".intergeo_tlbr_polyline_path"),
601
- editable: true,
602
- strokeColor: g.length == 0 ? "#000000" : g,
603
- strokeOpacity: isNaN(h) ? 1 : h,
604
- strokeWeight: isNaN(k) ? 3 : k
605
- }), i, f))
606
- });
607
- d(".intergeo_tlbr_polygon").each(function(f, i) {
608
- var h = d(i),
609
- l = d.trim(h.find(".intergeo_tlbr_polygon_fill_color").val()),
610
- g = parseFloat(h.find(".intergeo_tlbr_polygon_fill_opacity").val()),
611
- k = d.trim(h.find(".intergeo_tlbr_polygon_stroke_color").val()),
612
- m = parseFloat(h.find(".intergeo_tlbr_polygon_stroke_opacity").val()),
613
- f = d.trim(h.find(".intergeo_tlbr_plygon_position").val()),
614
- j = parseInt(h.find(".intergeo_tlbr_polygon_weight").val());
615
- e.polygon.push(new b.Polygon(e, new c.Polygon({
616
- map: e.map,
617
- path: b.PolyOverlay.stringToPath(h, ".intergeo_tlbr_polygon_path"),
618
- editable: true,
619
- fillColor: l.length == 0 ? "#000000" : l,
620
- fillOpacity: isNaN(g) ? 0.3 : g,
621
- strokeColor: k.length == 0 ? "#000000" : k,
622
- strokeOpacity: isNaN(m) ? 1 : m,
623
- strokePosition: c.StrokePosition[f] || c.StrokePosition.CENTER,
624
- strokeWeight: isNaN(j) ? 3 : j
625
- }), h, f))
626
- });
627
- d(".intergeo_tlbr_rectangle").each(function(f, i) {
628
- var h = d(i),
629
- l = d.trim(h.find(".intergeo_tlbr_rectangle_fill_color").val()),
630
- g = parseFloat(h.find(".intergeo_tlbr_rectangle_fill_opacity").val()),
631
- k = d.trim(h.find(".intergeo_tlbr_rectangle_stroke_color").val()),
632
- m = parseFloat(h.find(".intergeo_tlbr_rectangle_stroke_opacity").val()),
633
- f = d.trim(h.find(".intergeo_tlbr_rectangle_position").val()),
634
- j = parseInt(h.find(".intergeo_tlbr_rectangle_weight").val());
635
- e.rectangle.push(new b.Rectangle(e, new c.Rectangle({
636
- map: e.map,
637
- bounds: b.PolyOverlay.stringToBounds(h, ".intergeo_tlbr_rectangle_path"),
638
- editable: true,
639
- fillColor: l.length == 0 ? "#000000" : l,
640
- fillOpacity: isNaN(g) ? 0.3 : g,
641
- strokeColor: k.length == 0 ? "#000000" : k,
642
- strokeOpacity: isNaN(m) ? 1 : m,
643
- strokePosition: c.StrokePosition[f] || c.StrokePosition.CENTER,
644
- strokeWeight: isNaN(j) ? 3 : j
645
- }), h, f))
646
- });
647
- d(".intergeo_tlbr_circle").each(function(m, j) {
648
- var l = d(j),
649
- p = d.trim(l.find(".intergeo_tlbr_circle_fill_color").val()),
650
- i = parseFloat(l.find(".intergeo_tlbr_circle_fill_opacity").val()),
651
- h = d.trim(l.find(".intergeo_tlbr_circle_stroke_color").val()),
652
- g = parseFloat(l.find(".intergeo_tlbr_circle_stroke_opacity").val()),
653
- o = d.trim(l.find(".intergeo_tlbr_circle_position").val()),
654
- k = parseInt(l.find(".intergeo_tlbr_circle_weight").val()),
655
- q = d.trim(l.find(".intergeo_tlbr_circle_path").val()).split(";"),
656
- f = q[0].split(","),
657
- n = q[1].split(",");
658
- e.circle.push(new b.Circle(e, new c.Circle({
659
- map: e.map,
660
- center: new c.LatLng(f[0], f[1]),
661
- radius: parseFloat(n[0]),
662
- editable: true,
663
- fillColor: p.length == 0 ? "#000000" : p,
664
- fillOpacity: isNaN(i) ? 0.3 : i,
665
- strokeColor: h.length == 0 ? "#000000" : h,
666
- strokeOpacity: isNaN(g) ? 1 : g,
667
- strokePosition: c.StrokePosition[o] || c.StrokePosition.CENTER,
668
- strokeWeight: isNaN(k) ? 3 : k
669
- }), l, m))
670
- });
671
- d(".intergeo_tlbr_drctn").each(function(f, h) {
672
- var g = d(h),
673
- l = d.trim(g.find(".intergeo_tlbr_drctn_from").val()),
674
- k = d.trim(g.find(".intergeo_tlbr_drctn_to").val()),
675
- j = d.trim(g.find(".intergeo_tlbr_drctn_mode").val()),
676
- i = {
677
- origin: l,
678
- destination: k,
679
- travelMode: c.TravelMode[j] || c.TravelMode.DRIVING
680
- };
681
- e.directions.route(i, function(n, m) {
682
- if (m == c.DirectionsStatus.OK) {
683
- var o = new b.Direction(e, new c.DirectionsRenderer({
684
- map: e.map,
685
- directions: n
686
- }), g, f);
687
- e.direction.push(o)
688
- } else {
689
- g.remove();
690
- e.direction.push(null)
691
- }
692
- })
693
- })
694
- },
695
- _markerComplete: function(i) {
696
- var g = this,
697
- e = g.markers.length,
698
- h = d(d("#intergeo_tlbr_marker_tmpl").html().replaceByHash({
699
- "%pos%": e,
700
- "%num%": e + 1
701
- })),
702
- f = new b.Marker(g, i.overlay, h, e);
703
- h.find(".intergeo_tlbr_marker_location").val(i.overlay.getPosition().toUrlValue());
704
- d("#intergeo_tlbr_markers").append(h);
705
- g.markers.push(f);
706
- i.overlay.setDraggable(true)
707
- },
708
- _polyComplete: function(j, i, h) {
709
- var f = this,
710
- e = f[i].length,
711
- g = d(d("#intergeo_tlbr_" + i + "_tmpl").html().replaceByHash({
712
- "%pos%": e,
713
- "%num%": e + 1
714
- })),
715
- k = new h(f, j.overlay, g, e);
716
- f[i].push(k);
717
- g.find(".intergeo_tlbr_" + i + "_path").val(k.pathToString());
718
- d("#intergeo_tlbr_" + i + "s").append(g)
719
- },
720
- _normalize: function(h) {
721
- var g = function(j) {
722
- return j === "1"
723
- },
724
- f = function(j, k, l) {
725
- return k[j] || l
726
- },
727
- e = function(j) {
728
- return f(j, c.ControlPosition, 0)
729
- },
730
- i = {
731
- minZoom: parseInt,
732
- maxZoom: parseInt,
733
- scrollwheel: g,
734
- draggable: g,
735
- mapTypeId: function(j) {
736
- return c.MapTypeId[j] || c.MapTypeId.ROADMAP
737
- },
738
- mapTypeControl: g,
739
- mapTypeControlOptions: {
740
- position: e,
741
- mapTypeIds: function(j) {
742
- var k = [];
743
- d.each(j, function(l, m) {
744
- if (c.MapTypeId[m] !== undefined) {
745
- k.push(c.MapTypeId[m])
746
- }
747
- });
748
- return k
749
- },
750
- style: function(j) {
751
- return f(j, c.MapTypeControlStyle, c.MapTypeControlStyle.DEFAULT)
752
- }
753
- },
754
- overviewMapControl: g,
755
- overviewMapControlOptions: {
756
- opened: g
757
- },
758
- panControl: g,
759
- panControlOptions: {
760
- position: e
761
- },
762
- rotateControl: g,
763
- rotateControlOptions: {
764
- position: e
765
- },
766
- scaleControl: g,
767
- scaleControlOptions: {
768
- position: e
769
- },
770
- streetViewControl: g,
771
- streetViewControlOptions: {
772
- position: e
773
- },
774
- zoomControl: g,
775
- zoomControlOptions: {
776
- position: e,
777
- style: function(j) {
778
- return f(j, c.ZoomControlStyle, c.ZoomControlStyle.DEFAULT)
779
- }
780
- }
781
- };
782
- return d.each(h, function(j, k) {
783
- if (i[j] === undefined) {
784
- delete h[j]
785
- } else {
786
- if (typeof k === "string") {
787
- h[j] = i[j](k)
788
- } else {
789
- d.each(k, function(m, l) {
790
- if (i[j][m] === undefined) {
791
- delete h[j][m]
792
- } else {
793
- h[j][m] = i[j][m](l)
794
- }
795
- })
796
- }
797
- }
798
- })
799
- },
800
- _traffic: function(f) {
801
- var e = this;
802
- if (f.layer.traffic == 1) {
803
- if (!e.traffic) {
804
- e.traffic = new c.TrafficLayer()
805
- }
806
- e.traffic.setMap(e.map)
807
- } else {
808
- if (e.traffic) {
809
- e.traffic.setMap(null)
810
- }
811
- }
812
- },
813
- _bicycling: function(f) {
814
- var e = this;
815
- if (f.layer.bicycling == 1) {
816
- if (!e.bicycling) {
817
- e.bicycling = new c.BicyclingLayer()
818
- }
819
- e.bicycling.setMap(e.map)
820
- } else {
821
- if (e.bicycling) {
822
- e.bicycling.setMap(null)
823
- }
824
- }
825
- },
826
- _weather: function(f) {
827
- var e = this;
828
- if (f.layer.weather == 1) {
829
- if (!e.weather) {
830
- e.weather = new c.weather.WeatherLayer({})
831
- }
832
- e.weather.setMap(e.map);
833
- e.weather.setOptions({
834
- temperatureUnits: c.weather.TemperatureUnit[f.weather.temperatureUnits] || c.weather.TemperatureUnit.CELSIUS,
835
- windSpeedUnits: c.weather.WindSpeedUnit[f.weather.windSpeedUnits] || c.weather.WindSpeedUnit.METERS_PER_SECOND
836
- })
837
- } else {
838
- if (e.weather) {
839
- e.weather.setMap(null)
840
- }
841
- }
842
- },
843
- _cloud: function(f) {
844
- var e = this;
845
- if (f.layer.cloud == 1) {
846
- if (!e.cloud) {
847
- e.cloud = new c.weather.CloudLayer()
848
- }
849
- e.cloud.setMap(e.map)
850
- } else {
851
- if (e.cloud) {
852
- e.cloud.setMap(null)
853
- }
854
- }
855
- },
856
- _panoramio: function(f) {
857
- var e = this;
858
- if (f.layer.panoramio == 1) {
859
- if (!e.panoramio) {
860
- e.panoramio = new c.panoramio.PanoramioLayer({})
861
- }
862
- e.panoramio.setMap(e.map);
863
- e.panoramio.setTag(f.panoramio.tag);
864
- e.panoramio.setUserId(f.panoramio.userId)
865
- } else {
866
- if (e.panoramio) {
867
- e.panoramio.setMap(null)
868
- }
869
- }
870
- },
871
- _adsense: function(f) {
872
- var e = this;
873
- if (f.layer.adsense == 1 && intergeo_options.adsense.publisher_id && d.trim(intergeo_options.adsense.publisher_id) != "") {
874
- if (!e.adunit) {
875
- e.adunit = new c.adsense.AdUnit(document.createElement("div"), {
876
- visible: true,
877
- publisherId: intergeo_options.adsense.publisher_id
878
- })
879
- }
880
- e.adunit.setMap(this.map);
881
- e.adunit.setBackgroundColor(f.adsense.backgroundColor);
882
- e.adunit.setBorderColor(f.adsense.borderColor);
883
- e.adunit.setUrlColor(f.adsense.urlColor);
884
- e.adunit.setTitleColor(f.adsense.titleColor);
885
- e.adunit.setTextColor(f.adsense.textColor);
886
- if (c.ControlPosition[f.adsense.position] !== undefined) {
887
- e.adunit.setPosition(c.ControlPosition[f.adsense.position])
888
- }
889
- if (c.adsense.AdFormat[f.adsense.format]) {
890
- e.adunit.setFormat(c.adsense.AdFormat[f.adsense.format])
891
- }
892
- } else {
893
- if (e.adunit) {
894
- e.adunit.setMap(null)
895
- }
896
- }
897
- },
898
- _pro: function(f){
899
- var e = this;
900
- if(window._proFeatures){
901
- _proFeatures(f, e);
902
- }
903
- },
904
- createDirection: function() {
905
- var f = this,
906
- e = d("#intergeo_drctn_ppp"),
907
- g = e.find(".intergeo_ppp_frm");
908
- g.bind("submit.firsttime", function() {
909
- var h, i, j, l, k;
910
- if (g.attr("data-position") != "") {
911
- return false
912
- }
913
- h = f.direction.length;
914
- l = d.trim(g.find("#intergeo_ppp_drctn_from").val());
915
- k = d.trim(g.find("#intergeo_ppp_drctn_to").val());
916
- if (l == "" || k == "") {
917
- return false
918
- }
919
- j = d(d("#intergeo_tlbr_drctn_tmpl").html().replaceByHash({
920
- "%pos%": h,
921
- "%num%": h + 1,
922
- "%from%": l,
923
- "%to%": k,
924
- "%mode%": d.trim(g.find("#intergeo_ppp_drctn_mode option:selected").text())
925
- }));
926
- i = new b.Direction(f, new c.DirectionsRenderer({
927
- map: f.map
928
- }), j, h);
929
- d("#intergeo_tlbr_drctns").append(j);
930
- f.direction.push(i);
931
- i.update(g);
932
- g.unbind("submit.firsttime");
933
- return false
934
- });
935
- g.find('select,input[type!="submit"]').val("");
936
- g.attr("data-position", "");
937
- e.fadeIn(150)
938
- },
939
- updateOverlays: function() {
940
- var e = this;
941
- d.each(e.polyline, function(g, f) {
942
- if (f) {
943
- d('.intergeo_tlbr_polyline_path[data-position="' + g + '"]').val(f.pathToString())
944
- }
945
- });
946
- d.each(e.polygon, function(g, f) {
947
- if (f) {
948
- d('.intergeo_tlbr_polygon_path[data-position="' + g + '"]').val(f.pathToString())
949
- }
950
- })
951
- },
952
- preview: function() {
953
- var f = this,
954
- g = {};
955
- d.each(d("#intergeo_frm").serializeArray(), function() {
956
- var l = /\[\]$/,
957
- m = g,
958
- j = this.name.replace(l, "").split("_"),
959
- e = j.pop(),
960
- k = this.value || "",
961
- i = l.test(this.name);
962
- d.each(j, function(n, o) {
963
- if (m[o] === undefined) {
964
- m[o] = {}
965
- }
966
- m = m[o]
967
- });
968
- if (m[e] !== undefined) {
969
- if (i) {
970
- m[e].push(k)
971
- } else {
972
- m[e] = k
973
- }
974
- } else {
975
- m[e] = i ? [k] : k
976
- }
977
- });
978
- f._normalize(g.map);
979
- if (d("#intergeo_map_lock_preview").is(":checked")) {
980
- g.map.draggable = false;
981
- g.map.scrollwheel = false
982
- }
983
- f.map.setOptions(g.map);
984
- if (g.styles && g.styles.type) {
985
- if (g.styles.type == -1) {
986
- try {
987
- f.map.setOptions({
988
- styles: d.parseJSON(g.styles.custom || "[]")
989
- })
990
- } catch (h) {
991
- alert(intergeo_options.l10n.error.style)
992
- }
993
- } else {
994
- if (a.Styles[g.styles.type] !== undefined) {
995
- f.map.setOptions({
996
- styles: a.Styles[g.styles.type]
997
- })
998
- }
999
- }
1000
- }
1001
- f._traffic(g);
1002
- f._bicycling(g);
1003
- f._weather(g);
1004
- f._cloud(g);
1005
- f._panoramio(g);
1006
- f._adsense(g);
1007
- f._pro(g);
1008
- }
1009
- };
1010
- d(document).ready(function() {
1011
- var g, f, e;
1012
- f = new a("intergeo_canvas", {
1013
- center: new c.LatLng(parseFloat(d("#intergeo_map_lat").val()), parseFloat(d("#intergeo_map_lng").val())),
1014
- zoom: parseInt(d("#intergeo_map_zoom").val()),
1015
- minZoom: 0,
1016
- maxZoom: 19,
1017
- mapTypeId: c.MapTypeId.ROADMAP
1018
- });
1019
- var xxxx = window.dialogArguments || opener || parent || top;
1020
- xxxx.intergeo_maps_current = f;
1021
- e = d("#intergeo_frm");
1022
- e.find("input[name], select[name], textarea[name]").not("input[type='file']").change(function() {
1023
- f.preview()
1024
- });
1025
- e.find(".intergeo_tlbr_cntrl_onkeyup").keyup(function() {
1026
- f.preview()
1027
- });
1028
- e.submit(function() {
1029
- f.updateOverlays();
1030
- return true
1031
- });
1032
- f.preview();
1033
- d("#intergeo_map_lock_preview").change(function() {
1034
- var h = d(this).is(":checked");
1035
- f.map.setOptions({
1036
- draggable: !h,
1037
- scrollwheel: !h
1038
- })
1039
- });
1040
- d(".intergeo_tlbr_ul_li_h3").click(function() {
1041
- var h = d(this).parent();
1042
- if (h.hasClass("open")) {
1043
- h.removeClass("open")
1044
- } else {
1045
- d(".intergeo_tlbr_ul_li.open").removeClass("open");
1046
- h.addClass("open")
1047
- }
1048
- });
1049
- d(".intergeo_tlbr_cntrl_more_info").click(function() {
1050
- d(this).parent().nextAll(".intergeo_tlbr_cntrl_dsc:first").toggle();
1051
- return false
1052
- });
1053
- d(".intergeo_tlbr_cntrl_ttl").click(function() {
1054
- d(this).toggleClass("open").parent().find(".intergeo_tlbr_cntrl_items").toggle();
1055
- return false
1056
- });
1057
- d(".color-picker-hex").wpColorPicker({
1058
- change: function() {
1059
- clearTimeout(g);
1060
- g = setTimeout(function() {
1061
- f.preview()
1062
- }, 500)
1063
- }
1064
- });
1065
- d(".intergeo_tlbr_clr").wpColorPicker();
1066
- d("#intergeo_show_map_center").change(function() {
1067
- d("#intergeo_canvas_center").toggle();
1068
- d.post(intergeo_options.ajaxurl, {
1069
- action: "intergeo_show_map_center",
1070
- nonce: intergeo_options.nonce || "",
1071
- status: d(this).is(":checked") ? 1 : 0
1072
- })
1073
- });
1074
- d("#intergeo_tlbr_drawing_tools").change(function() {
1075
- f.drawing.setDrawingMode(null);
1076
- f.drawing.setOptions({
1077
- drawingControl: d(this).is(":checked")
1078
- })
1079
- });
1080
- d(".intergeo_ppp_cls").click(function() {
1081
- d(this).parents(".intergeo_ppp").fadeOut(150);
1082
- return false
1083
- });
1084
- d("#intergeo_go_to_address").click(function() {
1085
- d("#intergeo_address_ppp").fadeIn(150);
1086
- return false
1087
- });
1088
- d("#intergeo_address_ppp .intergeo_ppp_frm").submit(function() {
1089
- var h = d(this),
1090
- j = h.find(".intergeo_ppp_txt"),
1091
- i = d.trim(j.val());
1092
- if (i != "") {
1093
- if (!f.geocoder) {
1094
- f.geocoder = new c.Geocoder()
1095
- }
1096
- f.geocoder.geocode({
1097
- address: i
1098
- }, function(l, k) {
1099
- if (k == c.GeocoderStatus.OK) {
1100
- f.map.setCenter(l[0].geometry.location)
1101
- }
1102
- })
1103
- }
1104
- j.val("");
1105
- h.parents(".intergeo_ppp").fadeOut(150);
1106
- return false
1107
- });
1108
- d(".intregeo_ppp_frm_overlay").submit(function() {
1109
- var j = d(this),
1110
- h = parseInt(j.attr("data-position")),
1111
- i = j.attr("data-target");
1112
- j.parents(".intergeo_ppp").fadeOut(150);
1113
- if (f[i] && f[i][h]) {
1114
- f[i][h].update(j)
1115
- }
1116
- return false
1117
- });
1118
- d("#intergeo_tlbr_new_drctn").click(function() {
1119
- f.createDirection();
1120
- return false
1121
- })
1122
- })
1123
  })(jQuery, google.maps, intergeo.maps);
1
+ (function() {
2
+ var a = window.dialogArguments || opener || parent || top;
3
+ if (intergeo_options.send_to_editor && a.send_to_editor) {
4
+ a.send_to_editor(intergeo_options.send_to_editor)
5
+ }
6
+ })();
7
+ (function(a, b) {
8
+ if (typeof define == "function") {
9
+ define(b)
10
+ } else {
11
+ if (typeof module != "undefined") {
12
+ module.exports = b()
13
+ } else {
14
+ this[a] = b()
15
+ }
16
+ }
17
+ })("klass", function() {
18
+ var c = this,
19
+ d = c.klass,
20
+ h = "function",
21
+ k = /xyz/.test(function() {
22
+ xyz
23
+ }) ? /\bsupr\b/ : /.*/,
24
+ e = "prototype";
25
+
26
+ function i(f) {
27
+ return j.call(g(f) ? f : function() {}, f, 1)
28
+ }
29
+
30
+ function g(f) {
31
+ return typeof f === h
32
+ }
33
+
34
+ function b(l, m, f) {
35
+ return function() {
36
+ var o = this.supr;
37
+ this.supr = f[e][l];
38
+ var p = {}.fabricatedUndefined;
39
+ var n = p;
40
+ try {
41
+ n = m.apply(this, arguments)
42
+ } finally {
43
+ this.supr = o
44
+ }
45
+ return n
46
+ }
47
+ }
48
+
49
+ function a(m, n, f) {
50
+ for (var l in n) {
51
+ if (n.hasOwnProperty(l)) {
52
+ m[l] = g(n[l]) && g(f[e][l]) && k.test(n[l]) ? b(l, n[l], f) : n[l]
53
+ }
54
+ }
55
+ }
56
+
57
+ function j(m, p) {
58
+ function t() {}
59
+ t[e] = this[e];
60
+ var q = this,
61
+ s = new t(),
62
+ n = g(m),
63
+ f = n ? m : this,
64
+ l = n ? {} : m;
65
+
66
+ function r() {
67
+ if (this.initialize) {
68
+ this.initialize.apply(this, arguments)
69
+ } else {
70
+ p || n && q.apply(this, arguments);
71
+ f.apply(this, arguments)
72
+ }
73
+ }
74
+ r.methods = function(u) {
75
+ a(s, u, q);
76
+ r[e] = s;
77
+ return this
78
+ };
79
+ r.methods.call(r, l).prototype.constructor = r;
80
+ r.extend = arguments.callee;
81
+ r[e].implement = r.statics = function(v, u) {
82
+ v = typeof v == "string" ? (function() {
83
+ var o = {};
84
+ o[v] = u;
85
+ return o
86
+ }()) : v;
87
+ a(this, v, q);
88
+ return this
89
+ };
90
+ return r
91
+ }
92
+ i.noConflict = function() {
93
+ c.klass = d;
94
+ return this
95
+ };
96
+ c.klass = i;
97
+ return i
98
+ });
99
+ if (!window.intergeo) {
100
+ window.intergeo = {
101
+ maps: {}
102
+ }
103
+ }
104
+ if (!window.intergeo.maps) {
105
+ window.intergeo.maps = {}
106
+ }(function(c, b, a) {
107
+ a.Overlay = klass({
108
+ initialize: function(h, f, g, d, i) {
109
+ var e = this;
110
+ e.map = h;
111
+ e.overlay = f;
112
+ e.html = g;
113
+ e.position = d;
114
+ e.array = i;
115
+ e.timeout = null;
116
+ e.bindRemoveEvent(i)
117
+ },
118
+ bindRemoveEvent: function(e) {
119
+ var d = this;
120
+ d.html.find(".intergeo_tlbr_actn_delete").click(function() {
121
+ if (showNotice.warn()) {
122
+ d.overlay.setMap(null);
123
+ d.map[e][d.position] = null;
124
+ d.html.remove()
125
+ }
126
+ })
127
+ }
128
+ });
129
+ a.Marker = a.Overlay.extend({
130
+ initialize: function(i, f, g, d) {
131
+ var e = this,
132
+ h = new b.InfoWindow();
133
+ e.supr(i, f, g, d, "markers");
134
+ g.hover(function() {
135
+ if (i.markers[d]) {
136
+ f.setAnimation(b.Animation.BOUNCE)
137
+ }
138
+ }, function() {
139
+ if (i.markers[d]) {
140
+ f.setAnimation(null)
141
+ }
142
+ });
143
+ e.html.find(".intergeo_tlbr_actn_edit").click(function() {
144
+ var j = c("#intergeo_marker_ppp");
145
+ j.find(".intergeo_ppp_frm").attr("data-position", d);
146
+ j.find(".intergeo_tlbr_marker_title").val(g.find(".intergeo_tlbr_marker_title").val());
147
+ j.find(".intergeo_tlbr_marker_icon").val(g.find(".intergeo_tlbr_marker_icon").val());
148
+ j.find(".intergeo_tlbr_marker_info").val(g.find(".intergeo_tlbr_marker_info").val());
149
+ j.fadeIn(150)
150
+ });
151
+ b.event.addListener(f, "dragend", function(j) {
152
+ g.find(".intergeo_tlbr_marker_location").val(j.latLng.toUrlValue())
153
+ });
154
+ b.event.addListener(f, "click", function() {
155
+ var j = c.trim(g.find(".intergeo_tlbr_marker_info").val());
156
+ if (j.length) {
157
+ if (i.infowindow) {
158
+ i.infowindow.close()
159
+ }
160
+ h.setContent(j);
161
+ h.open(i.map, f);
162
+ i.infowindow = h
163
+ }
164
+ })
165
+ },
166
+ update: function(g) {
167
+ var d = this,
168
+ e = {},
169
+ i = c.trim(g.find(".intergeo_tlbr_marker_title").val()),
170
+ f = c.trim(g.find(".intergeo_tlbr_marker_icon").val()),
171
+ h = c.trim(g.find(".intergeo_tlbr_marker_info").val()),
172
+ j = d.html.find(".intergeo_tlbr_marker_title_td");
173
+ e.title = i;
174
+ if (/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(f)) {
175
+ e.icon = f
176
+ } else {
177
+ e.icon = null
178
+ }
179
+ d.html.find(".intergeo_tlbr_marker_title").val(i);
180
+ d.html.find(".intergeo_tlbr_marker_icon").val(f);
181
+ d.html.find(".intergeo_tlbr_marker_info").val(h);
182
+ d.overlay.setOptions(e);
183
+ if (i != "") {
184
+ j.text(i)
185
+ } else {
186
+ j.text("#" + (d.position + 1) + " " + intergeo_options.l10n.marker)
187
+ }
188
+ }
189
+ });
190
+ a.PolyOverlay = a.Overlay.extend({
191
+ initialize: function(h, f, g, d, i) {
192
+ var e = this;
193
+ e.supr(h, f, g, d, i);
194
+ e.html.find(".intergeo_tlbr_actn_edit").click(function() {
195
+ e.edit();
196
+ return false
197
+ })
198
+ },
199
+ pathToString: function() {
200
+ var d = [];
201
+ this.overlay.getPath().forEach(function(e) {
202
+ d.push(e.toUrlValue())
203
+ });
204
+ return d.join(";")
205
+ },
206
+ bindChangeEvent: function(e) {
207
+ var d = this;
208
+ b.event.addListener(d.overlay, e, function() {
209
+ d.html.find(".intergeo_tlbr_" + d.array + "_path").val(d.pathToString())
210
+ })
211
+ },
212
+ edit: function() {
213
+ var d = this,
214
+ e = c("#intergeo_polyoverlay_ppp"),
215
+ g = c.trim(d.html.find(".intergeo_tlbr_" + d.array + "_fill_color").val()),
216
+ f = c.trim(d.html.find(".intergeo_tlbr_" + d.array + "_stroke_color").val());
217
+ e.find(".intergeo_ppp_frm").attr("data-position", d.position).attr("data-target", d.array);
218
+ if (!g) {
219
+ g = "#000000"
220
+ }
221
+ e.find(".intergeo_tlbr_polyoverlay_fill_color").val(g).wpColorPicker("color", g);
222
+ e.find(".intergeo_tlbr_polyoverlay_fill_opacity").val(d.html.find(".intergeo_tlbr_" + d.array + "_fill_opacity").val());
223
+ if (!f) {
224
+ f = "#000000"
225
+ }
226
+ e.find(".intergeo_tlbr_polyoverlay_stroke_color").val(f).wpColorPicker("color", f);
227
+ e.find(".intergeo_tlbr_polyoverlay_weight").val(d.html.find(".intergeo_tlbr_" + d.array + "_weight").val());
228
+ e.find(".intergeo_tlbr_polyoverlay_stroke_opacity").val(d.html.find(".intergeo_tlbr_" + d.array + "_stroke_opacity").val());
229
+ e.find(".intergeo_tlbr_polyoverlay_position").val(d.html.find(".intergeo_tlbr_" + d.array + "_position").val());
230
+ e.fadeIn(150)
231
+ },
232
+ update: function(e) {
233
+ var n = this,
234
+ o = {},
235
+ k = e.find(".intergeo_tlbr_polyoverlay_position").val(),
236
+ j = parseInt(e.find(".intergeo_tlbr_polyoverlay_weight").val()),
237
+ i = !isNaN(j) && 0 <= j,
238
+ f = parseFloat(e.find(".intergeo_tlbr_polyoverlay_stroke_opacity").val()),
239
+ d = !isNaN(f) && 0 <= f && f <= 1,
240
+ h = c.trim(e.find(".intergeo_tlbr_polyoverlay_stroke_color").val()),
241
+ g = parseFloat(e.find(".intergeo_tlbr_polyoverlay_fill_opacity").val()),
242
+ l = !isNaN(g) && 0 <= g && g <= 1,
243
+ m = c.trim(e.find(".intergeo_tlbr_polyoverlay_fill_color").val());
244
+ o.strokePosition = b.StrokePosition[k] || b.StrokePosition.CENTER;
245
+ o.strokeWeight = i ? j : 3;
246
+ o.strokeOpacity = d ? f : 1;
247
+ o.strokeColor = h;
248
+ o.fillOpacity = l ? g : 0.3;
249
+ o.fillColor = m;
250
+ n.html.find(".intergeo_tlbr_" + n.array + "_position").val(k);
251
+ n.html.find(".intergeo_tlbr_" + n.array + "_weight").val(i ? j : "");
252
+ n.html.find(".intergeo_tlbr_" + n.array + "_stroke_opacity").val(d ? f : "");
253
+ n.html.find(".intergeo_tlbr_" + n.array + "_stroke_color").val(h);
254
+ n.html.find(".intergeo_tlbr_" + n.array + "_fill_opacity").val(l ? g : "");
255
+ n.html.find(".intergeo_tlbr_" + n.array + "_fill_color").val(m);
256
+ n.html.find(".intergeo_tlbr_clr_prvw:last").css("background-color", h).fadeTo(0, d ? f : 1);
257
+ n.html.find(".intergeo_tlbr_clr_prvw:first").css("background-color", m).fadeTo(0, l ? g : 0.3);
258
+ n.overlay.setOptions(o)
259
+ }
260
+ });
261
+ a.PolyOverlay.stringToPath = function(e, d) {
262
+ var f = [];
263
+ c.each(e.find(d).val().split(";"), function(h, i) {
264
+ var g = i.split(",");
265
+ if (g.length == 2) {
266
+ f.push(new b.LatLng(g[0], g[1]))
267
+ }
268
+ });
269
+ return f
270
+ };
271
+ a.PolyOverlay.stringToBounds = function(e, d) {
272
+ var f = a.PolyOverlay.stringToPath(e, d);
273
+ return new b.LatLngBounds(f[0], f[1])
274
+ };
275
+ a.Polyline = a.PolyOverlay.extend({
276
+ initialize: function(g, e, f, d) {
277
+ this.supr(g, e, f, d, "polyline");
278
+ this.bindChangeEvent("mouseup")
279
+ },
280
+ edit: function() {
281
+ var e = this,
282
+ f = c("#intergeo_polyline_ppp"),
283
+ d = c.trim(e.html.find(".intergeo_tlbr_polyline_color").val());
284
+ f.find(".intergeo_ppp_frm").attr("data-position", e.position).attr("data-target", "polyline");
285
+ f.find(".intergeo_tlbr_polyline_weight").val(e.html.find(".intergeo_tlbr_polyline_weight").val());
286
+ f.find(".intergeo_tlbr_polyline_opacity").val(e.html.find(".intergeo_tlbr_polyline_opacity").val());
287
+ if (!d) {
288
+ d = "#000000"
289
+ }
290
+ f.find(".intergeo_tlbr_polyline_color").val(d).wpColorPicker("color", d);
291
+ f.fadeIn(150)
292
+ },
293
+ update: function(i) {
294
+ var e = this,
295
+ g = {},
296
+ j = parseInt(i.find(".intergeo_tlbr_polyline_weight").val()),
297
+ k = !isNaN(j) && 0 <= j,
298
+ f = parseFloat(i.find(".intergeo_tlbr_polyline_opacity").val()),
299
+ h = !isNaN(f) && 0 <= f && f <= 1,
300
+ d = c.trim(i.find(".intergeo_tlbr_polyline_color").val());
301
+ g.strokeOpacity = h ? f : 1;
302
+ g.strokeWeight = k ? j : 3;
303
+ g.strokeColor = d;
304
+ e.html.find(".intergeo_tlbr_polyline_weight").val(k ? j : "");
305
+ e.html.find(".intergeo_tlbr_polyline_opacity").val(h ? f : "");
306
+ e.html.find(".intergeo_tlbr_polyline_color").val(d);
307
+ e.html.find(".intergeo_tlbr_clr_prvw").css("background-color", d).fadeTo(0, h ? f : 1);
308
+ e.overlay.setOptions(g)
309
+ }
310
+ });
311
+ a.Polygon = a.PolyOverlay.extend({
312
+ initialize: function(g, e, f, d) {
313
+ this.supr(g, e, f, d, "polygon");
314
+ this.bindChangeEvent("mouseup")
315
+ }
316
+ });
317
+ a.Rectangle = a.PolyOverlay.extend({
318
+ initialize: function(g, e, f, d) {
319
+ this.supr(g, e, f, d, "rectangle");
320
+ this.bindChangeEvent("bounds_changed")
321
+ },
322
+ pathToString: function() {
323
+ var d = this.overlay.getBounds();
324
+ return [d.getSouthWest().toUrlValue(), d.getNorthEast().toUrlValue()].join(";")
325
+ }
326
+ });
327
+ a.Circle = a.PolyOverlay.extend({
328
+ initialize: function(g, e, f, d) {
329
+ this.supr(g, e, f, d, "circle");
330
+ this.bindChangeEvent("center_changed");
331
+ this.bindChangeEvent("radius_changed")
332
+ },
333
+ pathToString: function() {
334
+ var d = this.overlay;
335
+ return d.getCenter().toUrlValue() + ";" + d.getRadius() + ",0"
336
+ }
337
+ });
338
+ a.Direction = a.PolyOverlay.extend({
339
+ initialize: function(g, e, f, d) {
340
+ this.supr(g, e, f, d, "direction")
341
+ },
342
+ edit: function() {
343
+ var d = this,
344
+ e = c("#intergeo_drctn_ppp");
345
+ e.find(".intergeo_ppp_frm").attr("data-position", d.position).attr("data-target", d.array);
346
+ e.find("#intergeo_ppp_drctn_from").val(d.html.find(".intergeo_tlbr_drctn_from").val());
347
+ e.find("#intergeo_ppp_drctn_to").val(d.html.find(".intergeo_tlbr_drctn_to").val());
348
+ e.find("#intergeo_ppp_drctn_mode").val(d.html.find(".intergeo_tlbr_drctn_mode").val());
349
+ e.fadeIn(150)
350
+ },
351
+ update: function(f) {
352
+ var d = this,
353
+ i = f.find("#intergeo_ppp_drctn_from").val(),
354
+ h = f.find("#intergeo_ppp_drctn_to").val(),
355
+ g = f.find("#intergeo_ppp_drctn_mode").val(),
356
+ e = {
357
+ origin: i,
358
+ destination: h,
359
+ travelMode: b.TravelMode[g] || b.TravelMode.DRIVING
360
+ };
361
+ d.map.directions.route(e, function(k, j) {
362
+ if (j == b.DirectionsStatus.OK) {
363
+ d.overlay.setDirections(k);
364
+ d.html.find(".intergeo_tlbr_direction_title_td").text(c("#intergeo_tlbr_drctn_ttl_tmpl").text().replaceByHash({
365
+ "%num%": d.position + 1,
366
+ "%from%": i,
367
+ "%to%": h,
368
+ "%mode%": f.find("#intergeo_ppp_drctn_mode > :selected").text()
369
+ }))
370
+ } else {
371
+ alert(intergeo_options.l10n.error.directions)
372
+ }
373
+ });
374
+ d.html.find(".intergeo_tlbr_drctn_from").val(i);
375
+ d.html.find(".intergeo_tlbr_drctn_to").val(h);
376
+ d.html.find(".intergeo_tlbr_drctn_mode").val(g)
377
+ }
378
+ })
379
+ })(jQuery, google.maps, intergeo.maps);
380
+ (function(d, c, b) {
381
+ var a;
382
+ String.prototype.replaceByHash = function(e) {
383
+ var f = this;
384
+ d.each(e, function(g, h) {
385
+ f = f.split(g).join(h)
386
+ });
387
+ return f
388
+ };
389
+ a = function(e, g) {
390
+ var f = this;
391
+ f.map = new c.Map(document.getElementById(e), g);
392
+ f.drawing = new c.drawing.DrawingManager({
393
+ drawingControl: false,
394
+ map: f.map,
395
+ circleOptions: {
396
+ editable: true
397
+ },
398
+ markerOptions: {
399
+ draggable: true
400
+ },
401
+ polygonOptions: {
402
+ editable: true
403
+ },
404
+ polylineOptions: {
405
+ editable: true
406
+ },
407
+ rectangleOptions: {
408
+ editable: true
409
+ }
410
+ });
411
+ f.directions = new c.DirectionsService();
412
+ f.geocoder = null;
413
+ f.traffic = null;
414
+ f.bicycling = null;
415
+ f.weather = null;
416
+ f.cloud = null;
417
+ f.panoramio = null;
418
+ f.adunit = null;
419
+ f.markers = [];
420
+ f.polyline = [];
421
+ f.polygon = [];
422
+ f.rectangle = [];
423
+ f.circle = [];
424
+ f.direction = [];
425
+ f.infowindow = null;
426
+ c.event.addListener(f.map, "center_changed", function() {
427
+ var h = f.map.getCenter();
428
+ d("#intergeo_map_lat").val(h.lat());
429
+ d("#intergeo_map_lng").val(h.lng())
430
+ });
431
+ c.event.addListener(f.map, "zoom_changed", function() {
432
+ d("#intergeo_map_zoom").val(f.map.getZoom())
433
+ });
434
+ c.event.addListener(f.drawing, "overlaycomplete", function(h) {
435
+ switch (h.type) {
436
+ case c.drawing.OverlayType.MARKER:
437
+ f._markerComplete(h);
438
+ break;
439
+ case c.drawing.OverlayType.CIRCLE:
440
+ f._polyComplete(h, "circle", b.Circle);
441
+ break;
442
+ case c.drawing.OverlayType.POLYGON:
443
+ f._polyComplete(h, "polygon", b.Polygon);
444
+ break;
445
+ case c.drawing.OverlayType.POLYLINE:
446
+ f._polyComplete(h, "polyline", b.Polyline);
447
+ break;
448
+ case c.drawing.OverlayType.RECTANGLE:
449
+ f._polyComplete(h, "rectangle", b.Rectangle);
450
+ break
451
+ }
452
+ });
453
+ f._initOverlays()
454
+ };
455
+ a.Styles = {
456
+ DEFAULT: [],
457
+ RED: [{
458
+ featureType: "all",
459
+ stylers: [{
460
+ hue: "#ff0000"
461
+ }]
462
+ }],
463
+ NIGHT: [{
464
+ featureType: "all",
465
+ stylers: [{
466
+ invert_lightness: "true"
467
+ }]
468
+ }],
469
+ BLUE: [{
470
+ featureType: "all",
471
+ stylers: [{
472
+ hue: "#0000b0"
473
+ }, {
474
+ invert_lightness: "true"
475
+ }, {
476
+ saturation: -30
477
+ }]
478
+ }],
479
+ GREYSCALE: [{
480
+ featureType: "all",
481
+ stylers: [{
482
+ saturation: -100
483
+ }, {
484
+ gamma: 0.5
485
+ }]
486
+ }],
487
+ NO_ROADS: [{
488
+ featureType: "road",
489
+ stylers: [{
490
+ visibility: "off"
491
+ }]
492
+ }],
493
+ MIXED: [{
494
+ featureType: "landscape",
495
+ stylers: [{
496
+ hue: "#00dd00"
497
+ }]
498
+ }, {
499
+ featureType: "road",
500
+ stylers: [{
501
+ hue: "#dd0000"
502
+ }]
503
+ }, {
504
+ featureType: "water",
505
+ stylers: [{
506
+ hue: "#000040"
507
+ }]
508
+ }, {
509
+ featureType: "poi.park",
510
+ stylers: [{
511
+ visibility: "off"
512
+ }]
513
+ }, {
514
+ featureType: "road.arterial",
515
+ stylers: [{
516
+ hue: "#ffff00"
517
+ }]
518
+ }, {
519
+ featureType: "road.local",
520
+ stylers: [{
521
+ visibility: "off"
522
+ }]
523
+ }],
524
+ CHILLED: [{
525
+ featureType: "road",
526
+ elementType: "geometry",
527
+ stylers: [{
528
+ visibility: "simplified"
529
+ }]
530
+ }, {
531
+ featureType: "road.arterial",
532
+ stylers: [{
533
+ hue: 149
534
+ }, {
535
+ saturation: -78
536
+ }, {
537
+ lightness: 0
538
+ }]
539
+ }, {
540
+ featureType: "road.highway",
541
+ stylers: [{
542
+ hue: -31
543
+ }, {
544
+ saturation: -40
545
+ }, {
546
+ lightness: 2.8
547
+ }]
548
+ }, {
549
+ featureType: "poi",
550
+ elementType: "label",
551
+ stylers: [{
552
+ visibility: "off"
553
+ }]
554
+ }, {
555
+ featureType: "landscape",
556
+ stylers: [{
557
+ hue: 163
558
+ }, {
559
+ saturation: -26
560
+ }, {
561
+ lightness: -1.1
562
+ }]
563
+ }, {
564
+ featureType: "transit",
565
+ stylers: [{
566
+ visibility: "off"
567
+ }]
568
+ }, {
569
+ featureType: "water",
570
+ stylers: [{
571
+ hue: 3
572
+ }, {
573
+ saturation: -24.24
574
+ }, {
575
+ lightness: -38.57
576
+ }]
577
+ }]
578
+ };
579
+ a.prototype = {
580
+ _initOverlays: function() {
581
+ var e = this;
582
+ d(".intergeo_tlbr_marker").each(function(f, i) {
583
+ var h = d(i),
584
+ g = h.find(".intergeo_tlbr_marker_location").val().split(",");
585
+ e.markers.push(new b.Marker(e, new c.Marker({
586
+ position: new c.LatLng(parseFloat(g[0]), parseFloat(g[1])),
587
+ map: e.map,
588
+ title: h.find(".intergeo_tlbr_marker_title").val(),
589
+ icon: h.find(".intergeo_tlbr_marker_icon").val(),
590
+ draggable: true
591
+ }), h, f))
592
+ });
593
+ d(".intergeo_tlbr_polyline").each(function(f, j) {
594
+ var i = d(j),
595
+ g = d.trim(i.find(".intergeo_tlbr_polyline_color").val()),
596
+ h = parseFloat(i.find(".intergeo_tlbr_polyline_opacity").val()),
597
+ k = parseInt(i.find(".intergeo_tlbr_polyline_weight").val());
598
+ e.polyline.push(new b.Polyline(e, new c.Polyline({
599
+ map: e.map,
600
+ path: b.PolyOverlay.stringToPath(i, ".intergeo_tlbr_polyline_path"),
601
+ editable: true,
602
+ strokeColor: g.length == 0 ? "#000000" : g,
603
+ strokeOpacity: isNaN(h) ? 1 : h,
604
+ strokeWeight: isNaN(k) ? 3 : k
605
+ }), i, f))
606
+ });
607
+ d(".intergeo_tlbr_polygon").each(function(f, i) {
608
+ var h = d(i),
609
+ l = d.trim(h.find(".intergeo_tlbr_polygon_fill_color").val()),
610
+ g = parseFloat(h.find(".intergeo_tlbr_polygon_fill_opacity").val()),
611
+ k = d.trim(h.find(".intergeo_tlbr_polygon_stroke_color").val()),
612
+ m = parseFloat(h.find(".intergeo_tlbr_polygon_stroke_opacity").val()),
613
+ f = d.trim(h.find(".intergeo_tlbr_plygon_position").val()),
614
+ j = parseInt(h.find(".intergeo_tlbr_polygon_weight").val());
615
+ e.polygon.push(new b.Polygon(e, new c.Polygon({
616
+ map: e.map,
617
+ path: b.PolyOverlay.stringToPath(h, ".intergeo_tlbr_polygon_path"),
618
+ editable: true,
619
+ fillColor: l.length == 0 ? "#000000" : l,
620
+ fillOpacity: isNaN(g) ? 0.3 : g,
621
+ strokeColor: k.length == 0 ? "#000000" : k,
622
+ strokeOpacity: isNaN(m) ? 1 : m,
623
+ strokePosition: c.StrokePosition[f] || c.StrokePosition.CENTER,
624
+ strokeWeight: isNaN(j) ? 3 : j
625
+ }), h, f))
626
+ });
627
+ d(".intergeo_tlbr_rectangle").each(function(f, i) {
628
+ var h = d(i),
629
+ l = d.trim(h.find(".intergeo_tlbr_rectangle_fill_color").val()),
630
+ g = parseFloat(h.find(".intergeo_tlbr_rectangle_fill_opacity").val()),
631
+ k = d.trim(h.find(".intergeo_tlbr_rectangle_stroke_color").val()),
632
+ m = parseFloat(h.find(".intergeo_tlbr_rectangle_stroke_opacity").val()),
633
+ f = d.trim(h.find(".intergeo_tlbr_rectangle_position").val()),
634
+ j = parseInt(h.find(".intergeo_tlbr_rectangle_weight").val());
635
+ e.rectangle.push(new b.Rectangle(e, new c.Rectangle({
636
+ map: e.map,
637
+ bounds: b.PolyOverlay.stringToBounds(h, ".intergeo_tlbr_rectangle_path"),
638
+ editable: true,
639
+ fillColor: l.length == 0 ? "#000000" : l,
640
+ fillOpacity: isNaN(g) ? 0.3 : g,
641
+ strokeColor: k.length == 0 ? "#000000" : k,
642
+ strokeOpacity: isNaN(m) ? 1 : m,
643
+ strokePosition: c.StrokePosition[f] || c.StrokePosition.CENTER,
644
+ strokeWeight: isNaN(j) ? 3 : j
645
+ }), h, f))
646
+ });
647
+ d(".intergeo_tlbr_circle").each(function(m, j) {
648
+ var l = d(j),
649
+ p = d.trim(l.find(".intergeo_tlbr_circle_fill_color").val()),
650
+ i = parseFloat(l.find(".intergeo_tlbr_circle_fill_opacity").val()),
651
+ h = d.trim(l.find(".intergeo_tlbr_circle_stroke_color").val()),
652
+ g = parseFloat(l.find(".intergeo_tlbr_circle_stroke_opacity").val()),
653
+ o = d.trim(l.find(".intergeo_tlbr_circle_position").val()),
654
+ k = parseInt(l.find(".intergeo_tlbr_circle_weight").val()),
655
+ q = d.trim(l.find(".intergeo_tlbr_circle_path").val()).split(";"),
656
+ f = q[0].split(","),
657
+ n = q[1].split(",");
658
+ e.circle.push(new b.Circle(e, new c.Circle({
659
+ map: e.map,
660
+ center: new c.LatLng(f[0], f[1]),
661
+ radius: parseFloat(n[0]),
662
+ editable: true,
663
+ fillColor: p.length == 0 ? "#000000" : p,
664
+ fillOpacity: isNaN(i) ? 0.3 : i,
665
+ strokeColor: h.length == 0 ? "#000000" : h,
666
+ strokeOpacity: isNaN(g) ? 1 : g,
667
+ strokePosition: c.StrokePosition[o] || c.StrokePosition.CENTER,
668
+ strokeWeight: isNaN(k) ? 3 : k
669
+ }), l, m))
670
+ });
671
+ d(".intergeo_tlbr_drctn").each(function(f, h) {
672
+ var g = d(h),
673
+ l = d.trim(g.find(".intergeo_tlbr_drctn_from").val()),
674
+ k = d.trim(g.find(".intergeo_tlbr_drctn_to").val()),
675
+ j = d.trim(g.find(".intergeo_tlbr_drctn_mode").val()),
676
+ i = {
677
+ origin: l,
678
+ destination: k,
679
+ travelMode: c.TravelMode[j] || c.TravelMode.DRIVING
680
+ };
681
+ e.directions.route(i, function(n, m) {
682
+ if (m == c.DirectionsStatus.OK) {
683
+ var o = new b.Direction(e, new c.DirectionsRenderer({
684
+ map: e.map,
685
+ directions: n
686
+ }), g, f);
687
+ e.direction.push(o)
688
+ } else {
689
+ g.remove();
690
+ e.direction.push(null)
691
+ }
692
+ })
693
+ })
694
+ },
695
+ _markerComplete: function(i) {
696
+ var g = this,
697
+ e = g.markers.length,
698
+ h = d(d("#intergeo_tlbr_marker_tmpl").html().replaceByHash({
699
+ "%pos%": e,
700
+ "%num%": e + 1
701
+ })),
702
+ f = new b.Marker(g, i.overlay, h, e);
703
+ h.find(".intergeo_tlbr_marker_location").val(i.overlay.getPosition().toUrlValue());
704
+ d("#intergeo_tlbr_markers").append(h);
705
+ g.markers.push(f);
706
+ i.overlay.setDraggable(true)
707
+ },
708
+ _polyComplete: function(j, i, h) {
709
+ var f = this,
710
+ e = f[i].length,
711
+ g = d(d("#intergeo_tlbr_" + i + "_tmpl").html().replaceByHash({
712
+ "%pos%": e,
713
+ "%num%": e + 1
714
+ })),
715
+ k = new h(f, j.overlay, g, e);
716
+ f[i].push(k);
717
+ g.find(".intergeo_tlbr_" + i + "_path").val(k.pathToString());
718
+ d("#intergeo_tlbr_" + i + "s").append(g)
719
+ },
720
+ _normalize: function(h) {
721
+ var g = function(j) {
722
+ return j === "1"
723
+ },
724
+ f = function(j, k, l) {
725
+ return k[j] || l
726
+ },
727
+ e = function(j) {
728
+ return f(j, c.ControlPosition, 0)
729
+ },
730
+ i = {
731
+ minZoom: parseInt,
732
+ maxZoom: parseInt,
733
+ scrollwheel: g,
734
+ draggable: g,
735
+ mapTypeId: function(j) {
736
+ return c.MapTypeId[j] || c.MapTypeId.ROADMAP
737
+ },
738
+ mapTypeControl: g,
739
+ mapTypeControlOptions: {
740
+ position: e,
741
+ mapTypeIds: function(j) {
742
+ var k = [];
743
+ d.each(j, function(l, m) {
744
+ if (c.MapTypeId[m] !== undefined) {
745
+ k.push(c.MapTypeId[m])
746
+ }
747
+ });
748
+ return k
749
+ },
750
+ style: function(j) {
751
+ return f(j, c.MapTypeControlStyle, c.MapTypeControlStyle.DEFAULT)
752
+ }
753
+ },
754
+ overviewMapControl: g,
755
+ overviewMapControlOptions: {
756
+ opened: g
757
+ },
758
+ panControl: g,
759
+ panControlOptions: {
760
+ position: e
761
+ },
762
+ rotateControl: g,
763
+ rotateControlOptions: {
764
+ position: e
765
+ },
766
+ scaleControl: g,
767
+ scaleControlOptions: {
768
+ position: e
769
+ },
770
+ streetViewControl: g,
771
+ streetViewControlOptions: {
772
+ position: e
773
+ },
774
+ zoomControl: g,
775
+ zoomControlOptions: {
776
+ position: e,
777
+ style: function(j) {
778
+ return f(j, c.ZoomControlStyle, c.ZoomControlStyle.DEFAULT)
779
+ }
780
+ }
781
+ };
782
+ return d.each(h, function(j, k) {
783
+ if (i[j] === undefined) {
784
+ delete h[j]
785
+ } else {
786
+ if (typeof k === "string") {
787
+ h[j] = i[j](k)
788
+ } else {
789
+ d.each(k, function(m, l) {
790
+ if (i[j][m] === undefined) {
791
+ delete h[j][m]
792
+ } else {
793
+ h[j][m] = i[j][m](l)
794
+ }
795
+ })
796
+ }
797
+ }
798
+ })
799
+ },
800
+ _traffic: function(f) {
801
+ var e = this;
802
+ if (f.layer.traffic == 1) {
803
+ if (!e.traffic) {
804
+ e.traffic = new c.TrafficLayer()
805
+ }
806
+ e.traffic.setMap(e.map)
807
+ } else {
808
+ if (e.traffic) {
809
+ e.traffic.setMap(null)
810
+ }
811
+ }
812
+ },
813
+ _bicycling: function(f) {
814
+ var e = this;
815
+ if (f.layer.bicycling == 1) {
816
+ if (!e.bicycling) {
817
+ e.bicycling = new c.BicyclingLayer()
818
+ }
819
+ e.bicycling.setMap(e.map)
820
+ } else {
821
+ if (e.bicycling) {
822
+ e.bicycling.setMap(null)
823
+ }
824
+ }
825
+ },
826
+ _weather: function(f) {
827
+ var e = this;
828
+ if (f.layer.weather == 1) {
829
+ if (!e.weather) {
830
+ e.weather = new c.weather.WeatherLayer({})
831
+ }
832
+ e.weather.setMap(e.map);
833
+ e.weather.setOptions({
834
+ temperatureUnits: c.weather.TemperatureUnit[f.weather.temperatureUnits] || c.weather.TemperatureUnit.CELSIUS,
835
+ windSpeedUnits: c.weather.WindSpeedUnit[f.weather.windSpeedUnits] || c.weather.WindSpeedUnit.METERS_PER_SECOND
836
+ })
837
+ } else {
838
+ if (e.weather) {
839
+ e.weather.setMap(null)
840
+ }
841
+ }
842
+ },
843
+ _cloud: function(f) {
844
+ var e = this;
845
+ if (f.layer.cloud == 1) {
846
+ if (!e.cloud) {
847
+ e.cloud = new c.weather.CloudLayer()
848
+ }
849
+ e.cloud.setMap(e.map)
850
+ } else {
851
+ if (e.cloud) {
852
+ e.cloud.setMap(null)
853
+ }
854
+ }
855
+ },
856
+ _panoramio: function(f) {
857
+ var e = this;
858
+ if (f.layer.panoramio == 1) {
859
+ if (!e.panoramio) {
860
+ e.panoramio = new c.panoramio.PanoramioLayer({})
861
+ }
862
+ e.panoramio.setMap(e.map);
863
+ e.panoramio.setTag(f.panoramio.tag);
864
+ e.panoramio.setUserId(f.panoramio.userId)
865
+ } else {
866
+ if (e.panoramio) {
867
+ e.panoramio.setMap(null)
868
+ }
869
+ }
870
+ },
871
+ _adsense: function(f) {
872
+ var e = this;
873
+ if (f.layer.adsense == 1 && intergeo_options.adsense.publisher_id && d.trim(intergeo_options.adsense.publisher_id) != "") {
874
+ if (!e.adunit) {
875
+ e.adunit = new c.adsense.AdUnit(document.createElement("div"), {
876
+ visible: true,
877
+ publisherId: intergeo_options.adsense.publisher_id
878
+ })
879
+ }
880
+ e.adunit.setMap(this.map);
881
+ e.adunit.setBackgroundColor(f.adsense.backgroundColor);
882
+ e.adunit.setBorderColor(f.adsense.borderColor);
883
+ e.adunit.setUrlColor(f.adsense.urlColor);
884
+ e.adunit.setTitleColor(f.adsense.titleColor);
885
+ e.adunit.setTextColor(f.adsense.textColor);
886
+ if (c.ControlPosition[f.adsense.position] !== undefined) {
887
+ e.adunit.setPosition(c.ControlPosition[f.adsense.position])
888
+ }
889
+ if (c.adsense.AdFormat[f.adsense.format]) {
890
+ e.adunit.setFormat(c.adsense.AdFormat[f.adsense.format])
891
+ }
892
+ } else {
893
+ if (e.adunit) {
894
+ e.adunit.setMap(null)
895
+ }
896
+ }
897
+ },
898
+ _pro: function(f){
899
+ var e = this;
900
+ if(window._proFeatures){
901
+ _proFeatures(f, e);
902
+ }
903
+ },
904
+ createDirection: function() {
905
+ var f = this,
906
+ e = d("#intergeo_drctn_ppp"),
907
+ g = e.find(".intergeo_ppp_frm");
908
+ g.bind("submit.firsttime", function() {
909
+ var h, i, j, l, k;
910
+ if (g.attr("data-position") != "") {
911
+ return false
912
+ }
913
+ h = f.direction.length;
914
+ l = d.trim(g.find("#intergeo_ppp_drctn_from").val());
915
+ k = d.trim(g.find("#intergeo_ppp_drctn_to").val());
916
+ if (l == "" || k == "") {
917
+ return false
918
+ }
919
+ j = d(d("#intergeo_tlbr_drctn_tmpl").html().replaceByHash({
920
+ "%pos%": h,
921
+ "%num%": h + 1,
922
+ "%from%": l,
923
+ "%to%": k,
924
+ "%mode%": d.trim(g.find("#intergeo_ppp_drctn_mode option:selected").text())
925
+ }));
926
+ i = new b.Direction(f, new c.DirectionsRenderer({
927
+ map: f.map
928
+ }), j, h);
929
+ d("#intergeo_tlbr_drctns").append(j);
930
+ f.direction.push(i);
931
+ i.update(g);
932
+ g.unbind("submit.firsttime");
933
+ return false
934
+ });
935
+ g.find('select,input[type!="submit"]').val("");
936
+ g.attr("data-position", "");
937
+ e.fadeIn(150)
938
+ },
939
+ updateOverlays: function() {
940
+ var e = this;
941
+ d.each(e.polyline, function(g, f) {
942
+ if (f) {
943
+ d('.intergeo_tlbr_polyline_path[data-position="' + g + '"]').val(f.pathToString())
944
+ }
945
+ });
946
+ d.each(e.polygon, function(g, f) {
947
+ if (f) {
948
+ d('.intergeo_tlbr_polygon_path[data-position="' + g + '"]').val(f.pathToString())
949
+ }
950
+ })
951
+ },
952
+ preview: function() {
953
+ var f = this,
954
+ g = {};
955
+ d.each(d("#intergeo_frm").serializeArray(), function() {
956
+ var l = /\[\]$/,
957
+ m = g,
958
+ j = this.name.replace(l, "").split("_"),
959
+ e = j.pop(),
960
+ k = this.value || "",
961
+ i = l.test(this.name);
962
+ d.each(j, function(n, o) {
963
+ if (m[o] === undefined) {
964
+ m[o] = {}
965
+ }
966
+ m = m[o]
967
+ });
968
+ if (m[e] !== undefined) {
969
+ if (i) {
970
+ m[e].push(k)
971
+ } else {
972
+ m[e] = k
973
+ }
974
+ } else {
975
+ m[e] = i ? [k] : k
976
+ }
977
+ });
978
+ f._normalize(g.map);
979
+ if (d("#intergeo_map_lock_preview").is(":checked")) {
980
+ g.map.draggable = false;
981
+ g.map.scrollwheel = false
982
+ }
983
+ f.map.setOptions(g.map);
984
+ if (g.styles && g.styles.type) {
985
+ if (g.styles.type == -1) {
986
+ try {
987
+ f.map.setOptions({
988
+ styles: d.parseJSON(g.styles.custom || "[]")
989
+ })
990
+ } catch (h) {
991
+ alert(intergeo_options.l10n.error.style)
992
+ }
993
+ } else {
994
+ if (a.Styles[g.styles.type] !== undefined) {
995
+ f.map.setOptions({
996
+ styles: a.Styles[g.styles.type]
997
+ })
998
+ }
999
+ }
1000
+ }
1001
+ f._traffic(g);
1002
+ f._bicycling(g);
1003
+ f._weather(g);
1004
+ f._cloud(g);
1005
+ f._panoramio(g);
1006
+ f._adsense(g);
1007
+ f._pro(g);
1008
+ }
1009
+ };
1010
+ d(document).ready(function() {
1011
+ var g, f, e;
1012
+ f = new a("intergeo_canvas", {
1013
+ center: new c.LatLng(parseFloat(d("#intergeo_map_lat").val()), parseFloat(d("#intergeo_map_lng").val())),
1014
+ zoom: parseInt(d("#intergeo_map_zoom").val()),
1015
+ minZoom: 0,
1016
+ maxZoom: 19,
1017
+ mapTypeId: c.MapTypeId.ROADMAP
1018
+ });
1019
+ var xxxx = window.dialogArguments || opener || parent || top;
1020
+ xxxx.intergeo_maps_current = f;
1021
+ e = d("#intergeo_frm");
1022
+ e.find("input[name], select[name], textarea[name]").not("input[type='file']").change(function() {
1023
+ f.preview()
1024
+ });
1025
+ e.find(".intergeo_tlbr_cntrl_onkeyup").keyup(function() {
1026
+ f.preview()
1027
+ });
1028
+ e.submit(function() {
1029
+ f.updateOverlays();
1030
+ return true
1031
+ });
1032
+ f.preview();
1033
+ d("#intergeo_map_lock_preview").change(function() {
1034
+ var h = d(this).is(":checked");
1035
+ f.map.setOptions({
1036
+ draggable: !h,
1037
+ scrollwheel: !h
1038
+ })
1039
+ });
1040
+ d(".intergeo_tlbr_ul_li_h3").click(function() {
1041
+ var h = d(this).parent();
1042
+ if (h.hasClass("open")) {
1043
+ h.removeClass("open")
1044
+ } else {
1045
+ d(".intergeo_tlbr_ul_li.open").removeClass("open");
1046
+ h.addClass("open")
1047
+ }
1048
+ });
1049
+ d(".intergeo_tlbr_cntrl_more_info").click(function() {
1050
+ d(this).parent().nextAll(".intergeo_tlbr_cntrl_dsc:first").toggle();
1051
+ return false
1052
+ });
1053
+ d(".intergeo_tlbr_cntrl_ttl").click(function() {
1054
+ d(this).toggleClass("open").parent().find(".intergeo_tlbr_cntrl_items").toggle();
1055
+ return false
1056
+ });
1057
+ d(".color-picker-hex").wpColorPicker({
1058
+ change: function() {
1059
+ clearTimeout(g);
1060
+ g = setTimeout(function() {
1061
+ f.preview()
1062
+ }, 500)
1063
+ }
1064
+ });
1065
+ d(".intergeo_tlbr_clr").wpColorPicker();
1066
+ d("#intergeo_show_map_center").change(function() {
1067
+ d("#intergeo_canvas_center").toggle();
1068
+ d.post(intergeo_options.ajaxurl, {
1069
+ action: "intergeo_show_map_center",
1070
+ nonce: intergeo_options.nonce || "",
1071
+ status: d(this).is(":checked") ? 1 : 0
1072
+ })
1073
+ });
1074
+ d("#intergeo_tlbr_drawing_tools").change(function() {
1075
+ f.drawing.setDrawingMode(null);
1076
+ f.drawing.setOptions({
1077
+ drawingControl: d(this).is(":checked")
1078
+ })
1079
+ });
1080
+ d(".intergeo_ppp_cls").click(function() {
1081
+ d(this).parents(".intergeo_ppp").fadeOut(150);
1082
+ return false
1083
+ });
1084
+ d("#intergeo_go_to_address").click(function() {
1085
+ d("#intergeo_address_ppp").fadeIn(150);
1086
+ return false
1087
+ });
1088
+ d("#intergeo_address_ppp .intergeo_ppp_frm").submit(function() {
1089
+ var h = d(this),
1090
+ j = h.find(".intergeo_ppp_txt"),
1091
+ i = d.trim(j.val());
1092
+ if (i != "") {
1093
+ if (!f.geocoder) {
1094
+ f.geocoder = new c.Geocoder()
1095
+ }
1096
+ f.geocoder.geocode({
1097
+ address: i
1098
+ }, function(l, k) {
1099
+ if (k == c.GeocoderStatus.OK) {
1100
+ f.map.setCenter(l[0].geometry.location)
1101
+ }
1102
+ })
1103
+ }
1104
+ j.val("");
1105
+ h.parents(".intergeo_ppp").fadeOut(150);
1106
+ return false
1107
+ });
1108
+ d(".intregeo_ppp_frm_overlay").submit(function() {
1109
+ var j = d(this),
1110
+ h = parseInt(j.attr("data-position")),
1111
+ i = j.attr("data-target");
1112
+ j.parents(".intergeo_ppp").fadeOut(150);
1113
+ if (f[i] && f[i][h]) {
1114
+ f[i][h].update(j)
1115
+ }
1116
+ return false
1117
+ });
1118
+ d("#intergeo_tlbr_new_drctn").click(function() {
1119
+ f.createDirection();
1120
+ return false
1121
+ })
1122
+ })
1123
  })(jQuery, google.maps, intergeo.maps);
js/misc.js ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ (function($, im){
2
+ $(document).on('click', '.intergeo_nag .notice-dismiss', function(e){
3
+ $.ajax({
4
+ url: ajaxurl,
5
+ data: {
6
+ 'action' : im.ajax["action"],
7
+ 'security' : im.ajax["nonce"]
8
+ }
9
+ });
10
+ });
11
+ })(jQuery, intergeo_misc)
js/rendering.js CHANGED
@@ -1,446 +1,449 @@
1
- (function(c, b) {
2
- var a = function(d, f) {
3
- var e = this;
4
- e.map = null;
5
- e.container = document.getElementById(d);
6
- e.options = f;
7
- e.infowindow = null;
8
- e._normalizeOptions()
9
- };
10
- a.styles = {
11
- DEFAULT: [],
12
- RED: [{
13
- featureType: "all",
14
- stylers: [{
15
- hue: "#ff0000"
16
- }]
17
- }],
18
- NIGHT: [{
19
- featureType: "all",
20
- stylers: [{
21
- invert_lightness: "true"
22
- }]
23
- }],
24
- BLUE: [{
25
- featureType: "all",
26
- stylers: [{
27
- hue: "#0000b0"
28
- }, {
29
- invert_lightness: "true"
30
- }, {
31
- saturation: -30
32
- }]
33
- }],
34
- GREYSCALE: [{
35
- featureType: "all",
36
- stylers: [{
37
- saturation: -100
38
- }, {
39
- gamma: 0.5
40
- }]
41
- }],
42
- NO_ROADS: [{
43
- featureType: "road",
44
- stylers: [{
45
- visibility: "off"
46
- }]
47
- }],
48
- MIXED: [{
49
- featureType: "landscape",
50
- stylers: [{
51
- hue: "#00dd00"
52
- }]
53
- }, {
54
- featureType: "road",
55
- stylers: [{
56
- hue: "#dd0000"
57
- }]
58
- }, {
59
- featureType: "water",
60
- stylers: [{
61
- hue: "#000040"
62
- }]
63
- }, {
64
- featureType: "poi.park",
65
- stylers: [{
66
- visibility: "off"
67
- }]
68
- }, {
69
- featureType: "road.arterial",
70
- stylers: [{
71
- hue: "#ffff00"
72
- }]
73
- }, {
74
- featureType: "road.local",
75
- stylers: [{
76
- visibility: "off"
77
- }]
78
- }],
79
- CHILLED: [{
80
- featureType: "road",
81
- elementType: "geometry",
82
- stylers: [{
83
- visibility: "simplified"
84
- }]
85
- }, {
86
- featureType: "road.arterial",
87
- stylers: [{
88
- hue: 149
89
- }, {
90
- saturation: -78
91
- }, {
92
- lightness: 0
93
- }]
94
- }, {
95
- featureType: "road.highway",
96
- stylers: [{
97
- hue: -31
98
- }, {
99
- saturation: -40
100
- }, {
101
- lightness: 2.8
102
- }]
103
- }, {
104
- featureType: "poi",
105
- elementType: "label",
106
- stylers: [{
107
- visibility: "off"
108
- }]
109
- }, {
110
- featureType: "landscape",
111
- stylers: [{
112
- hue: 163
113
- }, {
114
- saturation: -26
115
- }, {
116
- lightness: -1.1
117
- }]
118
- }, {
119
- featureType: "transit",
120
- stylers: [{
121
- visibility: "off"
122
- }]
123
- }, {
124
- featureType: "water",
125
- stylers: [{
126
- hue: 3
127
- }, {
128
- saturation: -24.24
129
- }, {
130
- lightness: -38.57
131
- }]
132
- }]
133
- };
134
- a.prototype = {};
135
- a.prototype._normalizeOptions = function() {
136
- var g = this.options.map || {},
137
- f = function(i) {
138
- return i === "1"
139
- },
140
- e = function(i, j, k) {
141
- return j[i] || k
142
- },
143
- d = function(i) {
144
- return e(i, b.ControlPosition, 0)
145
- },
146
- h = {
147
- minZoom: parseInt,
148
- maxZoom: parseInt,
149
- scrollwheel: f,
150
- draggable: f,
151
- mapTypeId: function(i) {
152
- return b.MapTypeId[i] || b.MapTypeId.ROADMAP
153
- },
154
- mapTypeControl: f,
155
- mapTypeControlOptions: {
156
- position: d,
157
- mapTypeIds: function(i) {
158
- var j = [];
159
- c.each(i, function(k, l) {
160
- if (b.MapTypeId[l] !== undefined) {
161
- j.push(b.MapTypeId[l])
162
- }
163
- });
164
- return j
165
- },
166
- style: function(i) {
167
- return e(i, b.MapTypeControlStyle, b.MapTypeControlStyle.DEFAULT)
168
- }
169
- },
170
- overviewMapControl: f,
171
- overviewMapControlOptions: {
172
- opened: f
173
- },
174
- panControl: f,
175
- panControlOptions: {
176
- position: d
177
- },
178
- rotateControl: f,
179
- rotateControlOptions: {
180
- position: d
181
- },
182
- scaleControl: f,
183
- scaleControlOptions: {
184
- position: d
185
- },
186
- streetViewControl: f,
187
- streetViewControlOptions: {
188
- position: d
189
- },
190
- zoomControl: f,
191
- zoomControlOptions: {
192
- position: d,
193
- style: function(i) {
194
- return e(i, b.ZoomControlStyle, b.ZoomControlStyle.DEFAULT)
195
- }
196
- }
197
- };
198
- return c.each(g, function(i, j) {
199
- if (h[i] === undefined) {
200
- delete g[i]
201
- } else {
202
- if (typeof j === "boolean") {
203
- j = j ? "1" : "0";
204
- }
205
- if (typeof j === "string") {
206
- g[i] = h[i](j)
207
- } else {
208
- c.each(j, function(l, k) {
209
- if (h[i][l] === undefined) {
210
- delete g[i][l]
211
- } else {
212
- g[i][l] = h[i][l](k)
213
- }
214
- })
215
- }
216
- }
217
- })
218
- };
219
- a.prototype._getGeocoder = function() {
220
- if (!a._geocoder) {
221
- a._geocoder = new b.Geocoder()
222
- }
223
- return a._geocoder
224
- };
225
- a.prototype._renderOverlays = function() {
226
- var d = this;
227
- c.each(d.options.overlays.marker || [], function(h, g) {
228
- var f;
229
- try {
230
- f = new b.Marker({
231
- position: new b.LatLng(g.position[0], g.position[1]),
232
- map: d.map,
233
- title: g.title || "",
234
- icon: g.icon || null
235
- });
236
- b.event.addListener(f, "click", function() {
237
- var i, e = c.trim(g.info || "");
238
- if (e.length) {
239
- if (d.infowindow) {
240
- d.infowindow.close()
241
- }
242
- i = new b.InfoWindow();
243
- i.setContent(e);
244
- i.open(d.map, f);
245
- d.infowindow = i
246
- }
247
- })
248
- } catch (j) {}
249
- });
250
- c.each(d.options.overlays.polyline || [], function(g, f) {
251
- var j = [];
252
- c.each(f.path || [], function(i, e) {
253
- if (e.length == 2) {
254
- j.push(new b.LatLng(e[0], e[1]))
255
- }
256
- });
257
- if (j.length >= 2) {
258
- try {
259
- new b.Polyline({
260
- map: d.map,
261
- path: j,
262
- strokeColor: f.color || "#000000",
263
- strokeOpacity: f.opacity || 1,
264
- strokeWeight: f.weight || 3
265
- })
266
- } catch (h) {}
267
- }
268
- });
269
- c.each(d.options.overlays.polygon || [], function(g, f) {
270
- var j = [];
271
- c.each(f.path || [], function(i, e) {
272
- if (e.length == 2) {
273
- j.push(new b.LatLng(e[0], e[1]))
274
- }
275
- });
276
- if (j.length >= 2) {
277
- try {
278
- new b.Polygon({
279
- map: d.map,
280
- path: j,
281
- strokeColor: f.stroke_color || "#000000",
282
- strokeOpacity: f.stroke_opacity || 1,
283
- strokeWeight: f.weight || 3,
284
- strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
285
- fillColor: f.fill_color || "#000000",
286
- fillOpacity: f.fill_opacity || 0.3
287
- })
288
- } catch (h) {}
289
- }
290
- });
291
- c.each(d.options.overlays.rectangle || [], function(g, f) {
292
- var j = [];
293
- c.each(f.path || [], function(i, e) {
294
- if (e.length == 2) {
295
- j.push(new b.LatLng(e[0], e[1]))
296
- }
297
- });
298
- if (j.length == 2) {
299
- try {
300
- new b.Rectangle({
301
- map: d.map,
302
- bounds: new b.LatLngBounds(j[0], j[1]),
303
- strokeColor: f.stroke_color || "#000000",
304
- strokeOpacity: f.stroke_opacity || 1,
305
- strokeWeight: f.weight || 3,
306
- strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
307
- fillColor: f.fill_color || "#000000",
308
- fillOpacity: f.fill_opacity || 0.3
309
- })
310
- } catch (h) {}
311
- }
312
- });
313
- c.each(d.options.overlays.circle || [], function(g, f) {
314
- try {
315
- new b.Circle({
316
- map: d.map,
317
- center: new b.LatLng(f.path[0][0], f.path[0][1]),
318
- radius: parseFloat(f.path[1][0]),
319
- strokeColor: f.stroke_color || "#000000",
320
- strokeOpacity: f.stroke_opacity || 1,
321
- strokeWeight: f.weight || 3,
322
- strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
323
- fillColor: f.fill_color || "#000000",
324
- fillOpacity: f.fill_opacity || 0.3
325
- })
326
- } catch (h) {}
327
- })
328
- };
329
- a.prototype._renderDirections = function() {
330
- var e = this,
331
- d = new b.DirectionsService();
332
- c.each(e.options.directions || [], function(g, f) {
333
- d.route({
334
- origin: f.from,
335
- destination: f.to,
336
- travelMode: b.TravelMode[f.mode] || b.TravelMode.DRIVING
337
- }, function(i, h) {
338
- if (h == b.DirectionsStatus.OK) {
339
- new b.DirectionsRenderer({
340
- map: e.map,
341
- directions: i
342
- })
343
- }
344
- })
345
- })
346
- };
347
- a.prototype.render = function() {
348
- var d = this,
349
- j = d.options.layer || {},
350
- i = d.options.weather || {},
351
- g = d.options.panoramio || {},
352
- k = null,
353
- f = d.options.adsense || {};
354
- if (!d.container) {
355
- return false
356
- }
357
- d.map = new b.Map(d.container, c.extend({
358
- center: new b.LatLng(d.options.lat || 48.1366069, d.options.lng || 11.577085099999977),
359
- zoom: d.options.zoom || 5,
360
- mapTypeId: b.MapTypeId.ROADMAP
361
- }, d.options.map || {}));
362
- if (d.options.styles && d.options.styles.type) {
363
- if (d.options.styles.type == -1) {
364
- try {
365
- d.map.setOptions({
366
- styles: d.options.styles.custom || []
367
- })
368
- } catch (h) {}
369
- } else {
370
- if (a.styles[d.options.styles.type] !== undefined) {
371
- d.map.setOptions({
372
- styles: a.styles[d.options.styles.type]
373
- })
374
- }
375
- }
376
- }
377
- if (d.options.address) {
378
- d._getGeocoder().geocode({
379
- address: d.options.address
380
- }, function(l, e) {
381
- if (e == b.GeocoderStatus.OK) {
382
- d.map.setCenter(l[0].geometry.location)
383
- }
384
- })
385
- }
386
- if (d.options.overlays) {
387
- d._renderOverlays()
388
- }
389
- if (d.options.directions) {
390
- d._renderDirections()
391
- }
392
- if (j.traffic) {
393
- (new b.TrafficLayer()).setMap(d.map)
394
- }
395
- if (j.bicycling) {
396
- (new b.BicyclingLayer()).setMap(d.map)
397
- }
398
- if (j.weather) {
399
- new b.weather.WeatherLayer({
400
- map: d.map,
401
- temperatureUnits: b.weather.TemperatureUnit[i.temperatureUnits || "CELSIUS"],
402
- windSpeedUnits: b.weather.WindSpeedUnit[i.windSpeedUnits || "METERS_PER_SECOND"]
403
- })
404
- }
405
- if (j.cloud) {
406
- (new b.weather.CloudLayer()).setMap(d.map)
407
- }
408
- if (j.panoramio) {
409
- new b.panoramio.PanoramioLayer({
410
- map: d.map,
411
- tag: g.tag || "",
412
- userId: g.userId || ""
413
- })
414
- }
415
- if (j.adsense && intergeo_options.adsense.publisher_id && c.trim(intergeo_options.adsense.publisher_id) != "") {
416
- k = new b.adsense.AdUnit(document.createElement("div"), {
417
- map: d.map,
418
- visible: true,
419
- publisherId: intergeo_options.adsense.publisher_id,
420
- backgroundColor: f.backgroundColor || "",
421
- borderColor: f.borderColor || "",
422
- textColor: f.urlColor || "",
423
- titleColor: f.titleColor || "",
424
- urlColor: f.textColor || ""
425
- });
426
- if (f.position && b.ControlPosition[f.position]) {
427
- k.setPosition(b.ControlPosition[f.position])
428
- }
429
- if (f.format && b.adsense.AdFormat[f.format]) {
430
- k.setFormat(b.adsense.AdFormat[f.format])
431
- }
432
- }
433
- var containerID = c(this.container).attr("id");
434
- var __map = window.intergeo_maps_maps || [];
435
- __map[containerID] = d.map;
436
- return true
437
- };
438
- c(document).ready(function() {
439
- var d, e, f = window.intergeo_maps || [];
440
- for (d = 0; d < f.length; d++) {
441
- e = new a(f[d].container, f[d].options);
442
- e.render()
443
- }
444
- })
445
-
 
 
 
446
  })(jQuery, google.maps);
1
+ (function(c, b) {
2
+ var a = function(d, f) {
3
+ var e = this;
4
+ e.map = null;
5
+ e.container = document.getElementById(d);
6
+ e.options = f;
7
+ e.infowindow = null;
8
+ e._normalizeOptions()
9
+ };
10
+ a.styles = {
11
+ DEFAULT: [],
12
+ RED: [{
13
+ featureType: "all",
14
+ stylers: [{
15
+ hue: "#ff0000"
16
+ }]
17
+ }],
18
+ NIGHT: [{
19
+ featureType: "all",
20
+ stylers: [{
21
+ invert_lightness: "true"
22
+ }]
23
+ }],
24
+ BLUE: [{
25
+ featureType: "all",
26
+ stylers: [{
27
+ hue: "#0000b0"
28
+ }, {
29
+ invert_lightness: "true"
30
+ }, {
31
+ saturation: -30
32
+ }]
33
+ }],
34
+ GREYSCALE: [{
35
+ featureType: "all",
36
+ stylers: [{
37
+ saturation: -100
38
+ }, {
39
+ gamma: 0.5
40
+ }]
41
+ }],
42
+ NO_ROADS: [{
43
+ featureType: "road",
44
+ stylers: [{
45
+ visibility: "off"
46
+ }]
47
+ }],
48
+ MIXED: [{
49
+ featureType: "landscape",
50
+ stylers: [{
51
+ hue: "#00dd00"
52
+ }]
53
+ }, {
54
+ featureType: "road",
55
+ stylers: [{
56
+ hue: "#dd0000"
57
+ }]
58
+ }, {
59
+ featureType: "water",
60
+ stylers: [{
61
+ hue: "#000040"
62
+ }]
63
+ }, {
64
+ featureType: "poi.park",
65
+ stylers: [{
66
+ visibility: "off"
67
+ }]
68
+ }, {
69
+ featureType: "road.arterial",
70
+ stylers: [{
71
+ hue: "#ffff00"
72
+ }]
73
+ }, {
74
+ featureType: "road.local",
75
+ stylers: [{
76
+ visibility: "off"
77
+ }]
78
+ }],
79
+ CHILLED: [{
80
+ featureType: "road",
81
+ elementType: "geometry",
82
+ stylers: [{
83
+ visibility: "simplified"
84
+ }]
85
+ }, {
86
+ featureType: "road.arterial",
87
+ stylers: [{
88
+ hue: 149
89
+ }, {
90
+ saturation: -78
91
+ }, {
92
+ lightness: 0
93
+ }]
94
+ }, {
95
+ featureType: "road.highway",
96
+ stylers: [{
97
+ hue: -31
98
+ }, {
99
+ saturation: -40
100
+ }, {
101
+ lightness: 2.8
102
+ }]
103
+ }, {
104
+ featureType: "poi",
105
+ elementType: "label",
106
+ stylers: [{
107
+ visibility: "off"
108
+ }]
109
+ }, {
110
+ featureType: "landscape",
111
+ stylers: [{
112
+ hue: 163
113
+ }, {
114
+ saturation: -26
115
+ }, {
116
+ lightness: -1.1
117
+ }]
118
+ }, {
119
+ featureType: "transit",
120
+ stylers: [{
121
+ visibility: "off"
122
+ }]
123
+ }, {
124
+ featureType: "water",
125
+ stylers: [{
126
+ hue: 3
127
+ }, {
128
+ saturation: -24.24
129
+ }, {
130
+ lightness: -38.57
131
+ }]
132
+ }]
133
+ };
134
+ a.prototype = {};
135
+ a.prototype._normalizeOptions = function() {
136
+ var g = this.options.map || {},
137
+ f = function(i) {
138
+ return i === "1"
139
+ },
140
+ e = function(i, j, k) {
141
+ return j[i] || k
142
+ },
143
+ d = function(i) {
144
+ return e(i, b.ControlPosition, 0)
145
+ },
146
+ h = {
147
+ minZoom: parseInt,
148
+ maxZoom: parseInt,
149
+ scrollwheel: f,
150
+ draggable: f,
151
+ mapTypeId: function(i) {
152
+ return b.MapTypeId[i] || b.MapTypeId.ROADMAP
153
+ },
154
+ mapTypeControl: f,
155
+ mapTypeControlOptions: {
156
+ position: d,
157
+ mapTypeIds: function(i) {
158
+ var j = [];
159
+ c.each(i, function(k, l) {
160
+ if (b.MapTypeId[l] !== undefined) {
161
+ j.push(b.MapTypeId[l])
162
+ }
163
+ });
164
+ return j
165
+ },
166
+ style: function(i) {
167
+ return e(i, b.MapTypeControlStyle, b.MapTypeControlStyle.DEFAULT)
168
+ }
169
+ },
170
+ overviewMapControl: f,
171
+ overviewMapControlOptions: {
172
+ opened: f
173
+ },
174
+ panControl: f,
175
+ panControlOptions: {
176
+ position: d
177
+ },
178
+ rotateControl: f,
179
+ rotateControlOptions: {
180
+ position: d
181
+ },
182
+ scaleControl: f,
183
+ scaleControlOptions: {
184
+ position: d
185
+ },
186
+ streetViewControl: f,
187
+ streetViewControlOptions: {
188
+ position: d
189
+ },
190
+ zoomControl: f,
191
+ zoomControlOptions: {
192
+ position: d,
193
+ style: function(i) {
194
+ return e(i, b.ZoomControlStyle, b.ZoomControlStyle.DEFAULT)
195
+ }
196
+ }
197
+ };
198
+ return c.each(g, function(i, j) {
199
+ if (h[i] === undefined) {
200
+ delete g[i]
201
+ } else {
202
+ if (typeof j === "boolean") {
203
+ j = j ? "1" : "0";
204
+ }
205
+ if(typeof j === "number") {
206
+ j = j.toString();
207
+ }
208
+ if (typeof j === "string") {
209
+ g[i] = h[i](j)
210
+ } else {
211
+ c.each(j, function(l, k) {
212
+ if (h[i][l] === undefined) {
213
+ delete g[i][l]
214
+ } else {
215
+ g[i][l] = h[i][l](k)
216
+ }
217
+ })
218
+ }
219
+ }
220
+ })
221
+ };
222
+ a.prototype._getGeocoder = function() {
223
+ if (!a._geocoder) {
224
+ a._geocoder = new b.Geocoder()
225
+ }
226
+ return a._geocoder
227
+ };
228
+ a.prototype._renderOverlays = function() {
229
+ var d = this;
230
+ c.each(d.options.overlays.marker || [], function(h, g) {
231
+ var f;
232
+ try {
233
+ f = new b.Marker({
234
+ position: new b.LatLng(g.position[0], g.position[1]),
235
+ map: d.map,
236
+ title: g.title || "",
237
+ icon: g.icon || null
238
+ });
239
+ b.event.addListener(f, "click", function() {
240
+ var i, e = c.trim(g.info || "");
241
+ if (e.length) {
242
+ if (d.infowindow) {
243
+ d.infowindow.close()
244
+ }
245
+ i = new b.InfoWindow();
246
+ i.setContent(e);
247
+ i.open(d.map, f);
248
+ d.infowindow = i
249
+ }
250
+ })
251
+ } catch (j) {}
252
+ });
253
+ c.each(d.options.overlays.polyline || [], function(g, f) {
254
+ var j = [];
255
+ c.each(f.path || [], function(i, e) {
256
+ if (e.length == 2) {
257
+ j.push(new b.LatLng(e[0], e[1]))
258
+ }
259
+ });
260
+ if (j.length >= 2) {
261
+ try {
262
+ new b.Polyline({
263
+ map: d.map,
264
+ path: j,
265
+ strokeColor: f.color || "#000000",
266
+ strokeOpacity: f.opacity || 1,
267
+ strokeWeight: f.weight || 3
268
+ })
269
+ } catch (h) {}
270
+ }
271
+ });
272
+ c.each(d.options.overlays.polygon || [], function(g, f) {
273
+ var j = [];
274
+ c.each(f.path || [], function(i, e) {
275
+ if (e.length == 2) {
276
+ j.push(new b.LatLng(e[0], e[1]))
277
+ }
278
+ });
279
+ if (j.length >= 2) {
280
+ try {
281
+ new b.Polygon({
282
+ map: d.map,
283
+ path: j,
284
+ strokeColor: f.stroke_color || "#000000",
285
+ strokeOpacity: f.stroke_opacity || 1,
286
+ strokeWeight: f.weight || 3,
287
+ strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
288
+ fillColor: f.fill_color || "#000000",
289
+ fillOpacity: f.fill_opacity || 0.3
290
+ })
291
+ } catch (h) {}
292
+ }
293
+ });
294
+ c.each(d.options.overlays.rectangle || [], function(g, f) {
295
+ var j = [];
296
+ c.each(f.path || [], function(i, e) {
297
+ if (e.length == 2) {
298
+ j.push(new b.LatLng(e[0], e[1]))
299
+ }
300
+ });
301
+ if (j.length == 2) {
302
+ try {
303
+ new b.Rectangle({
304
+ map: d.map,
305
+ bounds: new b.LatLngBounds(j[0], j[1]),
306
+ strokeColor: f.stroke_color || "#000000",
307
+ strokeOpacity: f.stroke_opacity || 1,
308
+ strokeWeight: f.weight || 3,
309
+ strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
310
+ fillColor: f.fill_color || "#000000",
311
+ fillOpacity: f.fill_opacity || 0.3
312
+ })
313
+ } catch (h) {}
314
+ }
315
+ });
316
+ c.each(d.options.overlays.circle || [], function(g, f) {
317
+ try {
318
+ new b.Circle({
319
+ map: d.map,
320
+ center: new b.LatLng(f.path[0][0], f.path[0][1]),
321
+ radius: parseFloat(f.path[1][0]),
322
+ strokeColor: f.stroke_color || "#000000",
323
+ strokeOpacity: f.stroke_opacity || 1,
324
+ strokeWeight: f.weight || 3,
325
+ strokePosition: b.StrokePosition[f.position] || b.StrokePosition.CENTER,
326
+ fillColor: f.fill_color || "#000000",
327
+ fillOpacity: f.fill_opacity || 0.3
328
+ })
329
+ } catch (h) {}
330
+ })
331
+ };
332
+ a.prototype._renderDirections = function() {
333
+ var e = this,
334
+ d = new b.DirectionsService();
335
+ c.each(e.options.directions || [], function(g, f) {
336
+ d.route({
337
+ origin: f.from,
338
+ destination: f.to,
339
+ travelMode: b.TravelMode[f.mode] || b.TravelMode.DRIVING
340
+ }, function(i, h) {
341
+ if (h == b.DirectionsStatus.OK) {
342
+ new b.DirectionsRenderer({
343
+ map: e.map,
344
+ directions: i
345
+ })
346
+ }
347
+ })
348
+ })
349
+ };
350
+ a.prototype.render = function() {
351
+ var d = this,
352
+ j = d.options.layer || {},
353
+ i = d.options.weather || {},
354
+ g = d.options.panoramio || {},
355
+ k = null,
356
+ f = d.options.adsense || {};
357
+ if (!d.container) {
358
+ return false
359
+ }
360
+ d.map = new b.Map(d.container, c.extend({
361
+ center: new b.LatLng(d.options.lat || 48.1366069, d.options.lng || 11.577085099999977),
362
+ zoom: d.options.zoom || 5,
363
+ mapTypeId: b.MapTypeId.ROADMAP
364
+ }, d.options.map || {}));
365
+ if (d.options.styles && d.options.styles.type) {
366
+ if (d.options.styles.type == -1) {
367
+ try {
368
+ d.map.setOptions({
369
+ styles: d.options.styles.custom || []
370
+ })
371
+ } catch (h) {}
372
+ } else {
373
+ if (a.styles[d.options.styles.type] !== undefined) {
374
+ d.map.setOptions({
375
+ styles: a.styles[d.options.styles.type]
376
+ })
377
+ }
378
+ }
379
+ }
380
+ if (d.options.address) {
381
+ d._getGeocoder().geocode({
382
+ address: d.options.address
383
+ }, function(l, e) {
384
+ if (e == b.GeocoderStatus.OK) {
385
+ d.map.setCenter(l[0].geometry.location)
386
+ }
387
+ })
388
+ }
389
+ if (d.options.overlays) {
390
+ d._renderOverlays()
391
+ }
392
+ if (d.options.directions) {
393
+ d._renderDirections()
394
+ }
395
+ if (j.traffic) {
396
+ (new b.TrafficLayer()).setMap(d.map)
397
+ }
398
+ if (j.bicycling) {
399
+ (new b.BicyclingLayer()).setMap(d.map)
400
+ }
401
+ if (j.weather) {
402
+ new b.weather.WeatherLayer({
403
+ map: d.map,
404
+ temperatureUnits: b.weather.TemperatureUnit[i.temperatureUnits || "CELSIUS"],
405
+ windSpeedUnits: b.weather.WindSpeedUnit[i.windSpeedUnits || "METERS_PER_SECOND"]
406
+ })
407
+ }
408
+ if (j.cloud) {
409
+ (new b.weather.CloudLayer()).setMap(d.map)
410
+ }
411
+ if (j.panoramio) {
412
+ new b.panoramio.PanoramioLayer({
413
+ map: d.map,
414
+ tag: g.tag || "",
415
+ userId: g.userId || ""
416
+ })
417
+ }
418
+ if (j.adsense && intergeo_options.adsense.publisher_id && c.trim(intergeo_options.adsense.publisher_id) != "") {
419
+ k = new b.adsense.AdUnit(document.createElement("div"), {
420
+ map: d.map,
421
+ visible: true,
422
+ publisherId: intergeo_options.adsense.publisher_id,
423
+ backgroundColor: f.backgroundColor || "",
424
+ borderColor: f.borderColor || "",
425
+ textColor: f.urlColor || "",
426
+ titleColor: f.titleColor || "",
427
+ urlColor: f.textColor || ""
428
+ });
429
+ if (f.position && b.ControlPosition[f.position]) {
430
+ k.setPosition(b.ControlPosition[f.position])
431
+ }
432
+ if (f.format && b.adsense.AdFormat[f.format]) {
433
+ k.setFormat(b.adsense.AdFormat[f.format])
434
+ }
435
+ }
436
+ var containerID = c(this.container).attr("id");
437
+ var __map = window.intergeo_maps_maps || [];
438
+ __map[containerID] = d.map;
439
+ return true
440
+ };
441
+ c(document).ready(function() {
442
+ var d, e, f = window.intergeo_maps || [];
443
+ for (d = 0; d < f.length; d++) {
444
+ e = new a(f[d].container, f[d].options);
445
+ e.render()
446
+ }
447
+ })
448
+
449
  })(jQuery, google.maps);
languages/intergeo-en_US.mo CHANGED
Binary file
languages/intergeo-en_US.po CHANGED
@@ -1,1016 +1,1264 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Intergeo 1.0\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2013-02-01 21:40+0300\n"
6
- "PO-Revision-Date: 2013-02-01 21:40+0300\n"
7
- "Last-Translator: Eugene Manuilov <eugene@manuilov.org>\n"
8
- "Language-Team: Intergeo <eugene@manuilov.org>\n"
9
- "Language: \n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "X-Poedit-Basepath: ./../../\n"
14
- "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html__;esc_attr_e;esc_attr__\n"
15
- "X-Poedit-SourceCharset: utf-8\n"
16
- "X-Poedit-Language: English\n"
17
- "X-Poedit-Country: UNITED STATES\n"
18
- "X-Poedit-SearchPath-0: intergeo\n"
19
-
20
- #: intergeo/index.php:31
21
- #: intergeo/templates/library/list.php:3
22
- #: intergeo/templates/iframe/form.php:7
23
- msgid "Maps"
24
- msgstr "Maps"
25
-
26
- #: intergeo/index.php:32
27
- msgid "Settings"
28
- msgstr "Settings"
29
-
30
- #: intergeo/index.php:81
31
- #, php-format
32
- msgid "All Maps API applications should load the Maps API using an API key (however it is still possible to use maps without API key). Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API using an API key in order to purchase additional quota. To create your API key:"
33
- msgstr "All Maps API applications should load the Maps API using an API key (however it is still possible to use maps without API key). Using an API key enables you to monitor your application's Maps API usage, and ensures that Google can contact you about your application if necessary. If your application's Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API using an API key in order to purchase additional quota. To create your API key:"
34
-
35
- #: intergeo/index.php:84
36
- #, php-format
37
- msgid "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log in with your Google Account."
38
- msgstr "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log in with your Google Account."
39
-
40
- #: intergeo/index.php:85
41
- #, php-format
42
- msgid "Click the %sServices%s link from the left-hand menu."
43
- msgstr "Click the %sServices%s link from the left-hand menu."
44
-
45
- #: intergeo/index.php:86
46
- #, php-format
47
- msgid "Activate the %sGoogle Maps API v3%s service."
48
- msgstr "Activate the %sGoogle Maps API v3%s service."
49
-
50
- #: intergeo/index.php:87
51
- msgid "Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s section. Maps API applications use the %1$sKey for browser apps%2$s."
52
- msgstr "Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s section. Maps API applications use the %1$sKey for browser apps%2$s."
53
-
54
- #: intergeo/index.php:94
55
- #, php-format
56
- msgid "Adding display ads to your map requires that you have an AdSense account enabled for AdSense for Content. If you don't yet have an AdSense account, %1$ssign up%3$s for one. Once you have done so (or if you already have an account) make sure you've also enabled the account with %2$sAdSense for Content%3$s."
57
- msgstr "Adding display ads to your map requires that you have an AdSense account enabled for AdSense for Content. If you don't yet have an AdSense account, %1$ssign up%3$s for one. Once you have done so (or if you already have an account) make sure you've also enabled the account with %2$sAdSense for Content%3$s."
58
-
59
- #: intergeo/index.php:96
60
- msgid "Once you have an Adsense for Content account, you will have received an AdSense for Content (AFC) publisher ID. This publisher ID is used to link any advertising shown to your AdSense account, allowing you to share in advertising revenue when a user clicks on one of the ads shown on your maps."
61
- msgstr "Once you have an Adsense for Content account, you will have received an AdSense for Content (AFC) publisher ID. This publisher ID is used to link any advertising shown to your AdSense account, allowing you to share in advertising revenue when a user clicks on one of the ads shown on your maps."
62
-
63
- #: intergeo/index.php:180
64
- msgid "Intergeo Maps"
65
- msgstr "Intergeo Maps"
66
-
67
- #: intergeo/index.php:217
68
- #: intergeo/templates/iframe/overlays.php:26
69
- #: intergeo/templates/iframe/overlays.php:49
70
- msgid "marker"
71
- msgstr "marker"
72
-
73
- #: intergeo/index.php:219
74
- msgid "Styles are broken. Please, fix it and try again."
75
- msgstr "Styles are broken. Please, fix it and try again."
76
-
77
- #: intergeo/index.php:220
78
- msgid "Direction was not found."
79
- msgstr "Maps"
80
-
81
- #: intergeo/index.php:235
82
- msgid "Insert into post"
83
- msgstr "Insert into post"
84
-
85
- #: intergeo/index.php:238
86
- msgid "Create the map"
87
- msgstr "Create the map"
88
-
89
- #: intergeo/index.php:253
90
- msgid "Update the map"
91
- msgstr "Update the map"
92
-
93
- #: intergeo/index.php:621
94
- msgid "The map has been updated successfully."
95
- msgstr "The map has been updated successfully."
96
-
97
- #: intergeo/index.php:622
98
- msgid "The map has been created successfully."
99
- msgstr "The map has been created successfully."
100
-
101
- #: intergeo/index.php:630
102
- msgid "The map updating failed."
103
- msgstr "The map updating failed."
104
-
105
- #: intergeo/index.php:631
106
- msgid "The map creation failed."
107
- msgstr "The map creation failed."
108
-
109
- #: intergeo/index.php:768
110
- msgid "Overview"
111
- msgstr "Overview"
112
-
113
- #: intergeo/index.php:771
114
- msgid "The library is a list to view all maps you have created in your system. The library is showing you 3x3 grid of maps' previews. You will see the same maps embedded into your posts at front end, as you see here. The library is paginated and if you have more than 9 maps, you will see pagination links under maps grid."
115
- msgstr "The library is a list to view all maps you have created in your system. The library is showing you 3x3 grid of maps' previews. You will see the same maps embedded into your posts at front end, as you see here. The library is paginated and if you have more than 9 maps, you will see pagination links under maps grid."
116
-
117
- #: intergeo/index.php:772
118
- msgid "To create a new map, click on \"Add New\" button next to the page title and map editor popup will appear. In case you want to edit a map, you can click on pencil icon in the right bottom corner of map preview box and edit popup window will appear."
119
- msgstr "To create a new map, click on \"Add New\" button next to the page title and map editor popup will appear. In case you want to edit a map, you can click on pencil icon in the right bottom corner of map preview box and edit popup window will appear."
120
-
121
- #: intergeo/index.php:773
122
- msgid "If you want to delete a map, click on the trash icon in the right bottom corner of a map and confirm your action. Pay attention that whole information about the map will be removed from the system, but all shortcodes will be left where you embed it. However these deprecated shortcodes won't be rendered anymore, so you don't have to worry about it while the plugin is enabled."
123
- msgstr "If you want to delete a map, click on the trash icon in the right bottom corner of a map and confirm your action. Pay attention that whole information about the map will be removed from the system, but all shortcodes will be left where you embed it. However these deprecated shortcodes won't be rendered anymore, so you don't have to worry about it while the plugin is enabled."
124
-
125
- #: intergeo/index.php:778
126
- msgid "Shortcodes"
127
- msgstr "Shortcodes"
128
-
129
- #: intergeo/index.php:781
130
- msgid "You can easily embed a map into your posts, pages, categories or tags descriptions and text widgets by copying shortcode which you can find in the input field of a map preview box."
131
- msgstr "You can easily embed a map into your posts, pages, categories or tags descriptions and text widgets by copying shortcode which you can find in the input field of a map preview box."
132
-
133
- #: intergeo/index.php:782
134
- msgid "To specify a certain address just type it inside a shortcode, and a map will be automatically centered at this place. Also each shortcode could be extended with custom attributes like width, height, style, zoom and hook. Use standard CSS values for such attributes as width, height and style. Type an integer between 0 and 19 for zoom attribute. You can use hook attribute to set up a filter hook which you can use in your custom plugin or theme to configure all options of a map."
135
- msgstr "To specify a certain address just type it inside a shortcode, and a map will be automatically centered at this place. Also each shortcode could be extended with custom attributes like width, height, style, zoom and hook. Use standard CSS values for such attributes as width, height and style. Type an integer between 0 and 19 for zoom attribute. You can use hook attribute to set up a filter hook which you can use in your custom plugin or theme to configure all options of a map."
136
-
137
- #: intergeo/index.php:841
138
- msgid "The map was deleted successfully."
139
- msgstr "The map was deleted successfully."
140
-
141
- #: intergeo/templates/library/list.php:4
142
- msgid "Add New"
143
- msgstr "Add New"
144
-
145
- #: intergeo/templates/library/list.php:45
146
- msgid "Edit"
147
- msgstr "Edit"
148
-
149
- #: intergeo/templates/library/list.php:46
150
- msgid "Copy"
151
- msgstr "Copy"
152
-
153
- #: intergeo/templates/library/list.php:47
154
- msgid "Delete"
155
- msgstr "Delete"
156
-
157
- #: intergeo/templates/library/list.php:81
158
- msgid "You do not have created maps. Start adding it by clicking \"Add New\" button."
159
- msgstr "You do not have created maps. Start adding it by clicking \"Add New\" button."
160
-
161
- #: intergeo/templates/iframe/layers.php:1
162
- msgid "Layers"
163
- msgstr "Layers"
164
-
165
- #: intergeo/templates/iframe/layers.php:4
166
- msgid "Traffic layer"
167
- msgstr "Traffic layer"
168
-
169
- #: intergeo/templates/iframe/layers.php:11
170
- #: intergeo/templates/iframe/layers.php:27
171
- #: intergeo/templates/iframe/layers.php:103
172
- #: intergeo/templates/iframe/controls.php:12
173
- #: intergeo/templates/iframe/controls.php:86
174
- #: intergeo/templates/iframe/controls.php:148
175
- #: intergeo/templates/iframe/controls.php:210
176
- #: intergeo/templates/iframe/controls.php:311
177
- #: intergeo/templates/iframe/controls.php:373
178
- #: intergeo/templates/iframe/controls.php:435
179
- msgid "Enabled"
180
- msgstr "Enabled"
181
-
182
- #: intergeo/templates/iframe/layers.php:15
183
- #, php-format
184
- msgid "Allows you to add real-time traffic information (where supported) to your map. Traffic information is provided for the time at which the request is made. Consult %s this spreadsheet %s to determine traffic coverage support."
185
- msgstr "Allows you to add real-time traffic information (where supported) to your map. Traffic information is provided for the time at which the request is made. Consult %s this spreadsheet %s to determine traffic coverage support."
186
-
187
- #: intergeo/templates/iframe/layers.php:20
188
- msgid "Bicycling layer"
189
- msgstr "Bicycling layer"
190
-
191
- #: intergeo/templates/iframe/layers.php:31
192
- msgid "Allows you to add bicycle information to your map. It renders a layer of bike paths, suggested bike routes and other overlays specific to bicycling usage on top of the given map. Additionally, the layer alters the style of the base map itself to emphasize streets supporting bicycle routes and de-emphasize streets inappropriate for bicycles."
193
- msgstr "Allows you to add bicycle information to your map. It renders a layer of bike paths, suggested bike routes and other overlays specific to bicycling usage on top of the given map. Additionally, the layer alters the style of the base map itself to emphasize streets supporting bicycle routes and de-emphasize streets inappropriate for bicycles."
194
-
195
- #: intergeo/templates/iframe/layers.php:36
196
- msgid "Weather & Cloud layers"
197
- msgstr "Weather & Cloud layers"
198
-
199
- #: intergeo/templates/iframe/layers.php:43
200
- msgid "Enabled cloud"
201
- msgstr "Enabled cloud"
202
-
203
- #: intergeo/templates/iframe/layers.php:47
204
- msgid "Allows you to add the display of cloud imagery on your map. Enabling the cloud layer will add cloud coverage imagery to your map, visible at low zoom levels."
205
- msgstr "Allows you to add the display of cloud imagery on your map. Enabling the cloud layer will add cloud coverage imagery to your map, visible at low zoom levels."
206
-
207
- #: intergeo/templates/iframe/layers.php:54
208
- msgid "Enabled weather"
209
- msgstr "Enabled weather"
210
-
211
- #: intergeo/templates/iframe/layers.php:58
212
- msgid "Allows you to add the display of weather data on your map. Enabling the weather layer will show current weather conditions from weather.com on your map, including icons that denote sun, clouds, rain and so on."
213
- msgstr "Allows you to add the display of weather data on your map. Enabling the weather layer will show current weather conditions from weather.com on your map, including icons that denote sun, clouds, rain and so on."
214
-
215
- #: intergeo/templates/iframe/layers.php:65
216
- msgid "temperature units"
217
- msgstr "temperature units"
218
-
219
- #: intergeo/templates/iframe/layers.php:68
220
- msgid "Celsius"
221
- msgstr "Celsius"
222
-
223
- #: intergeo/templates/iframe/layers.php:71
224
- msgid "Fahrenheit"
225
- msgstr "Fahrenheit"
226
-
227
- #: intergeo/templates/iframe/layers.php:78
228
- msgid "wind speed units"
229
- msgstr "wind speed units"
230
-
231
- #: intergeo/templates/iframe/layers.php:81
232
- msgid "kilometers per hour"
233
- msgstr "kilometers per hour"
234
-
235
- #: intergeo/templates/iframe/layers.php:84
236
- msgid "meters per second"
237
- msgstr "meters per second"
238
-
239
- #: intergeo/templates/iframe/layers.php:87
240
- msgid "miles per hour"
241
- msgstr "miles per hour"
242
-
243
- #: intergeo/templates/iframe/layers.php:96
244
- msgid "Panoramio layer"
245
- msgstr "Panoramio layer"
246
-
247
- #: intergeo/templates/iframe/layers.php:107
248
- msgid "Allows you to add photos from Panoramio as a layer to your map. It renders a layer of geotagged photo icons from Panoramio on the map as a series of large and small photo icons."
249
- msgstr "Allows you to add photos from Panoramio as a layer to your map. It renders a layer of geotagged photo icons from Panoramio on the map as a series of large and small photo icons."
250
-
251
- #: intergeo/templates/iframe/layers.php:111
252
- msgid "Restricting photos by tag"
253
- msgstr "Restricting photos by tag"
254
-
255
- #: intergeo/templates/iframe/layers.php:115
256
- msgid "Allows you to restrict the set of photos to display on the map to those matching a certain textual tag."
257
- msgstr "Allows you to restrict the set of photos to display on the map to those matching a certain textual tag."
258
-
259
- #: intergeo/templates/iframe/layers.php:119
260
- msgid "Restricting photos by user id"
261
- msgstr "Restricting photos by user id"
262
-
263
- #: intergeo/templates/iframe/layers.php:123
264
- msgid "Allows you to restrict the set of photos to display on the map to those matching a particular user."
265
- msgstr "Allows you to restrict the set of photos to display on the map to those matching a particular user."
266
-
267
- #: intergeo/templates/iframe/form.php:34
268
- msgid "The center of the map"
269
- msgstr "The center of the map"
270
-
271
- #: intergeo/templates/iframe/form.php:37
272
- msgid "Go to address"
273
- msgstr "Go to address"
274
-
275
- #: intergeo/templates/iframe/overlays.php:1
276
- msgid "Overlays"
277
- msgstr "Overlays"
278
-
279
- #: intergeo/templates/iframe/overlays.php:5
280
- msgid "Drawing tools allows you to add overlays over the map. You can add markers, polylines, polygons, circles and rectangles. To enable drawing tools just put a tick in the checkbox below."
281
- msgstr "Drawing tools allows you to add overlays over the map. You can add markers, polylines, polygons, circles and rectangles. To enable drawing tools just put a tick in the checkbox below."
282
-
283
- #: intergeo/templates/iframe/overlays.php:8
284
- msgid "To delete a marker, just double click on it and an item will be removed."
285
- msgstr "To delete a marker, just double click on it and an item will be removed."
286
-
287
- #: intergeo/templates/iframe/overlays.php:16
288
- msgid "Enable drawing tools"
289
- msgstr "Enable drawing tools"
290
-
291
- #: intergeo/templates/iframe/overlays.php:34
292
- #: intergeo/templates/iframe/overlays.php:60
293
- msgid "Delete marker"
294
- msgstr "Delete marker"
295
-
296
- #: intergeo/templates/iframe/overlays.php:35
297
- #: intergeo/templates/iframe/overlays.php:61
298
- msgid "Edit marker"
299
- msgstr "Edit marker"
300
-
301
- #: intergeo/templates/iframe/overlays.php:41
302
- msgid "Markers"
303
- msgstr "Markers"
304
-
305
- #: intergeo/templates/iframe/overlays.php:74
306
- #: intergeo/templates/iframe/overlays.php:102
307
- msgid "polyline"
308
- msgstr "polyline"
309
-
310
- #: intergeo/templates/iframe/overlays.php:82
311
- #: intergeo/templates/iframe/overlays.php:110
312
- msgid "Delete polyline"
313
- msgstr "Delete polyline"
314
-
315
- #: intergeo/templates/iframe/overlays.php:83
316
- #: intergeo/templates/iframe/overlays.php:111
317
- msgid "Edit polyline"
318
- msgstr "Edit polyline"
319
-
320
- #: intergeo/templates/iframe/overlays.php:90
321
- msgid "Polylines"
322
- msgstr "Polylines"
323
-
324
- #: intergeo/templates/iframe/overlays.php:126
325
- #: intergeo/templates/iframe/overlays.php:171
326
- msgid "rectangle"
327
- msgstr "Maps"
328
-
329
- #: intergeo/templates/iframe/overlays.php:137
330
- #: intergeo/templates/iframe/overlays.php:182
331
- #: intergeo/templates/iframe/overlays.php:210
332
- msgid "Delete rectangle"
333
- msgstr "Delete rectangle"
334
-
335
- #: intergeo/templates/iframe/overlays.php:138
336
- #: intergeo/templates/iframe/overlays.php:183
337
- #: intergeo/templates/iframe/overlays.php:211
338
- msgid "Edit rectangle"
339
- msgstr "Edit rectangle"
340
-
341
- #: intergeo/templates/iframe/overlays.php:146
342
- msgid "Rectangles"
343
- msgstr "Rectangles"
344
-
345
- #: intergeo/templates/iframe/overlays.php:199
346
- #: intergeo/templates/iframe/overlays.php:244
347
- msgid "circle"
348
- msgstr "circle"
349
-
350
- #: intergeo/templates/iframe/overlays.php:219
351
- msgid "Circles"
352
- msgstr "Circles"
353
-
354
- #: intergeo/templates/iframe/overlays.php:255
355
- msgid "Delete circle"
356
- msgstr "Delete circle"
357
-
358
- #: intergeo/templates/iframe/overlays.php:256
359
- msgid "Edit circle"
360
- msgstr "Edit circle"
361
-
362
- #: intergeo/templates/iframe/overlays.php:272
363
- #: intergeo/templates/iframe/overlays.php:317
364
- msgid "polygon"
365
- msgstr "polygon"
366
-
367
- #: intergeo/templates/iframe/overlays.php:283
368
- #: intergeo/templates/iframe/overlays.php:328
369
- msgid "Delete polygon"
370
- msgstr "Delete polygon"
371
-
372
- #: intergeo/templates/iframe/overlays.php:284
373
- #: intergeo/templates/iframe/overlays.php:329
374
- msgid "Edit polygon"
375
- msgstr "Edit polygon"
376
-
377
- #: intergeo/templates/iframe/overlays.php:292
378
- msgid "Polygons"
379
- msgstr "Polygons"
380
-
381
- #: intergeo/templates/iframe/positioning.php:1
382
- msgid "Positioning & Zooming"
383
- msgstr "Positioning & Zooming"
384
-
385
- #: intergeo/templates/iframe/positioning.php:5
386
- msgid "If you want to set specific map position and certain level of zooming, just set it up on preview map and these settings will be remembered at published map."
387
- msgstr "If you want to set specific map position and certain level of zooming, just set it up on preview map and these settings will be remembered at published map."
388
-
389
- #: intergeo/templates/iframe/positioning.php:9
390
- msgid "Positioning"
391
- msgstr "Positioning"
392
-
393
- #: intergeo/templates/iframe/positioning.php:12
394
- msgid "The initial map type"
395
- msgstr "The initial map type"
396
-
397
- #: intergeo/templates/iframe/positioning.php:15
398
- #: intergeo/templates/iframe/controls.php:280
399
- msgid "Road map"
400
- msgstr "Road map"
401
-
402
- #: intergeo/templates/iframe/positioning.php:18
403
- #: intergeo/templates/iframe/controls.php:286
404
- msgid "Terrain"
405
- msgstr "Terrain"
406
-
407
- #: intergeo/templates/iframe/positioning.php:21
408
- #: intergeo/templates/iframe/controls.php:292
409
- msgid "Satellite"
410
- msgstr "Satellite"
411
-
412
- #: intergeo/templates/iframe/positioning.php:24
413
- #: intergeo/templates/iframe/controls.php:298
414
- msgid "Hybrid"
415
- msgstr "Hybrid"
416
-
417
- #: intergeo/templates/iframe/positioning.php:33
418
- msgid "Draggable map"
419
- msgstr "Draggable map"
420
-
421
- #: intergeo/templates/iframe/positioning.php:37
422
- msgid "If unchecked prevents the map from being dragged. Dragging is enabled by default."
423
- msgstr "If unchecked prevents the map from being dragged. Dragging is enabled by default."
424
-
425
- #: intergeo/templates/iframe/positioning.php:42
426
- msgid "Zooming"
427
- msgstr "Zooming"
428
-
429
- #: intergeo/templates/iframe/positioning.php:46
430
- msgid "Zoom range values"
431
- msgstr "Zoom range values"
432
-
433
- #: intergeo/templates/iframe/positioning.php:59
434
- msgid "The maximum (19) and minimum (0) zoom levels which could be displayed on the map."
435
- msgstr "The maximum (19) and minimum (0) zoom levels which could be displayed on the map."
436
-
437
- #: intergeo/templates/iframe/positioning.php:66
438
- msgid "Scrollwheel zooming"
439
- msgstr "Scrollwheel zooming"
440
-
441
- #: intergeo/templates/iframe/positioning.php:70
442
- msgid "Determines if scrollwheel zooming is enabled on the map."
443
- msgstr "Determines if scrollwheel zooming is enabled on the map."
444
-
445
- #: intergeo/templates/iframe/positioning.php:75
446
- msgid "Preview settings"
447
- msgstr "Preview settings"
448
-
449
- #: intergeo/templates/iframe/positioning.php:81
450
- msgid "Lock preview"
451
- msgstr "Lock preview"
452
-
453
- #: intergeo/templates/iframe/positioning.php:85
454
- msgid "Lock preview map to preserve changing of the viewport bounds and zoom level. Locking affects only on preview map and won't lock embedded map."
455
- msgstr "Lock preview map to preserve changing of the viewport bounds and zoom level. Locking affects only on preview map and won't lock embedded map."
456
-
457
- #: intergeo/templates/iframe/positioning.php:91
458
- msgid "Show map center"
459
- msgstr "Show map center"
460
-
461
- #: intergeo/templates/iframe/positioning.php:95
462
- msgid "Show small red circle at the center of the map. It helps you to centralize the map bounds. Note that this option won't be displayed at frontend."
463
- msgstr "Show small red circle at the center of the map. It helps you to centralize the map bounds. Note that this option won't be displayed at frontend."
464
-
465
- #: intergeo/templates/iframe/styles.php:1
466
- #: intergeo/templates/iframe/adsense.php:128
467
- msgid "Styles"
468
- msgstr "Styles"
469
-
470
- #: intergeo/templates/iframe/styles.php:4
471
- msgid "Container's Styles"
472
- msgstr "Container's Styles"
473
-
474
- #: intergeo/templates/iframe/styles.php:7
475
- msgid "Width"
476
- msgstr "Width"
477
-
478
- #: intergeo/templates/iframe/styles.php:11
479
- msgid "Height"
480
- msgstr "Height"
481
-
482
- #: intergeo/templates/iframe/styles.php:15
483
- msgid "Extra Styles"
484
- msgstr "Extra Styles"
485
-
486
- #: intergeo/templates/iframe/styles.php:21
487
- msgid "Predefined Map Styles"
488
- msgstr "Predefined Map Styles"
489
-
490
- #: intergeo/templates/iframe/styles.php:66
491
- msgid "Custom Map Styles"
492
- msgstr "Custom Map Styles"
493
-
494
- #: intergeo/templates/iframe/styles.php:72
495
- msgid "Use custom styles"
496
- msgstr "Use custom styles"
497
-
498
- #: intergeo/templates/iframe/styles.php:79
499
- #, php-format
500
- msgid "Creating styles by hand and testing your code to see how they look is potentially time-consuming. Instead, you can use the %sStyled Map Wizard%s to set up the JSON for your map's styles."
501
- msgstr "Creating styles by hand and testing your code to see how they look is potentially time-consuming. Instead, you can use the %sStyled Map Wizard%s to set up the JSON for your map's styles."
502
-
503
- #: intergeo/templates/iframe/controls.php:2
504
- msgid "Controls"
505
- msgstr "Controls"
506
-
507
- #: intergeo/templates/iframe/controls.php:5
508
- msgid "Zoom control"
509
- msgstr "Zoom control"
510
-
511
- #: intergeo/templates/iframe/controls.php:16
512
- msgid "The Zoom control displays a slider (for large maps) or small \"+/-\" buttons (for small maps) to control the zoom level of the map. This control appears by default in the top left corner of the map on non-touch devices or in the bottom left corner on touch devices."
513
- msgstr "The Zoom control displays a slider (for large maps) or small \"+/-\" buttons (for small maps) to control the zoom level of the map. This control appears by default in the top left corner of the map on non-touch devices or in the bottom left corner on touch devices."
514
-
515
- #: intergeo/templates/iframe/controls.php:22
516
- #: intergeo/templates/iframe/controls.php:96
517
- #: intergeo/templates/iframe/controls.php:158
518
- #: intergeo/templates/iframe/controls.php:220
519
- #: intergeo/templates/iframe/controls.php:321
520
- #: intergeo/templates/iframe/controls.php:383
521
- #: intergeo/templates/iframe/adsense.php:84
522
- msgid "default position"
523
- msgstr "default position"
524
-
525
- #: intergeo/templates/iframe/controls.php:24
526
- #: intergeo/templates/iframe/controls.php:98
527
- #: intergeo/templates/iframe/controls.php:160
528
- #: intergeo/templates/iframe/controls.php:222
529
- #: intergeo/templates/iframe/controls.php:323
530
- #: intergeo/templates/iframe/controls.php:385
531
- #: intergeo/templates/iframe/adsense.php:86
532
- msgid "Top Left"
533
- msgstr "Top Left"
534
-
535
- #: intergeo/templates/iframe/controls.php:27
536
- #: intergeo/templates/iframe/controls.php:101
537
- #: intergeo/templates/iframe/controls.php:163
538
- #: intergeo/templates/iframe/controls.php:225
539
- #: intergeo/templates/iframe/controls.php:326
540
- #: intergeo/templates/iframe/controls.php:388
541
- #: intergeo/templates/iframe/adsense.php:89
542
- msgid "Top Center"
543
- msgstr "Top Center"
544
-
545
- #: intergeo/templates/iframe/controls.php:30
546
- #: intergeo/templates/iframe/controls.php:104
547
- #: intergeo/templates/iframe/controls.php:166
548
- #: intergeo/templates/iframe/controls.php:228
549
- #: intergeo/templates/iframe/controls.php:329
550
- #: intergeo/templates/iframe/controls.php:391
551
- #: intergeo/templates/iframe/adsense.php:92
552
- msgid "Top Right"
553
- msgstr "Top Right"
554
-
555
- #: intergeo/templates/iframe/controls.php:33
556
- #: intergeo/templates/iframe/controls.php:107
557
- #: intergeo/templates/iframe/controls.php:169
558
- #: intergeo/templates/iframe/controls.php:231
559
- #: intergeo/templates/iframe/controls.php:332
560
- #: intergeo/templates/iframe/controls.php:394
561
- #: intergeo/templates/iframe/adsense.php:95
562
- msgid "Right Top"
563
- msgstr "Right Top"
564
-
565
- #: intergeo/templates/iframe/controls.php:36
566
- #: intergeo/templates/iframe/controls.php:110
567
- #: intergeo/templates/iframe/controls.php:172
568
- #: intergeo/templates/iframe/controls.php:234
569
- #: intergeo/templates/iframe/controls.php:335
570
- #: intergeo/templates/iframe/controls.php:397
571
- #: intergeo/templates/iframe/adsense.php:98
572
- msgid "Right Center"
573
- msgstr "Right Center"
574
-
575
- #: intergeo/templates/iframe/controls.php:39
576
- #: intergeo/templates/iframe/controls.php:113
577
- #: intergeo/templates/iframe/controls.php:175
578
- #: intergeo/templates/iframe/controls.php:237
579
- #: intergeo/templates/iframe/controls.php:338
580
- #: intergeo/templates/iframe/controls.php:400
581
- #: intergeo/templates/iframe/adsense.php:101
582
- msgid "Right Bottom"
583
- msgstr "Right Bottom"
584
-
585
- #: intergeo/templates/iframe/controls.php:42
586
- #: intergeo/templates/iframe/controls.php:116
587
- #: intergeo/templates/iframe/controls.php:178
588
- #: intergeo/templates/iframe/controls.php:240
589
- #: intergeo/templates/iframe/controls.php:341
590
- #: intergeo/templates/iframe/controls.php:403
591
- #: intergeo/templates/iframe/adsense.php:104
592
- msgid "Bottom Right"
593
- msgstr "Bottom Right"
594
-
595
- #: intergeo/templates/iframe/controls.php:45
596
- #: intergeo/templates/iframe/controls.php:119
597
- #: intergeo/templates/iframe/controls.php:181
598
- #: intergeo/templates/iframe/controls.php:243
599
- #: intergeo/templates/iframe/controls.php:344
600
- #: intergeo/templates/iframe/controls.php:406
601
- #: intergeo/templates/iframe/adsense.php:107
602
- msgid "Bottom Center"
603
- msgstr "Bottom Center"
604
-
605
- #: intergeo/templates/iframe/controls.php:48
606
- #: intergeo/templates/iframe/controls.php:122
607
- #: intergeo/templates/iframe/controls.php:184
608
- #: intergeo/templates/iframe/controls.php:246
609
- #: intergeo/templates/iframe/controls.php:347
610
- #: intergeo/templates/iframe/controls.php:409
611
- #: intergeo/templates/iframe/adsense.php:110
612
- msgid "Bottom Left"
613
- msgstr "Bottom Left"
614
-
615
- #: intergeo/templates/iframe/controls.php:51
616
- #: intergeo/templates/iframe/controls.php:125
617
- #: intergeo/templates/iframe/controls.php:187
618
- #: intergeo/templates/iframe/controls.php:249
619
- #: intergeo/templates/iframe/controls.php:350
620
- #: intergeo/templates/iframe/controls.php:412
621
- #: intergeo/templates/iframe/adsense.php:113
622
- msgid "Left Bottom"
623
- msgstr "Left Bottom"
624
-
625
- #: intergeo/templates/iframe/controls.php:54
626
- #: intergeo/templates/iframe/controls.php:128
627
- #: intergeo/templates/iframe/controls.php:190
628
- #: intergeo/templates/iframe/controls.php:252
629
- #: intergeo/templates/iframe/controls.php:353
630
- #: intergeo/templates/iframe/controls.php:415
631
- #: intergeo/templates/iframe/adsense.php:116
632
- msgid "Left Center"
633
- msgstr "Left Center"
634
-
635
- #: intergeo/templates/iframe/controls.php:57
636
- #: intergeo/templates/iframe/controls.php:131
637
- #: intergeo/templates/iframe/controls.php:193
638
- #: intergeo/templates/iframe/controls.php:255
639
- #: intergeo/templates/iframe/controls.php:356
640
- #: intergeo/templates/iframe/controls.php:418
641
- #: intergeo/templates/iframe/adsense.php:119
642
- msgid "Left Top"
643
- msgstr "Left Top"
644
-
645
- #: intergeo/templates/iframe/controls.php:64
646
- #: intergeo/templates/iframe/controls.php:262
647
- msgid "default style"
648
- msgstr "default style"
649
-
650
- #: intergeo/templates/iframe/controls.php:67
651
- msgid "small"
652
- msgstr "small"
653
-
654
- #: intergeo/templates/iframe/controls.php:70
655
- msgid "large"
656
- msgstr "large"
657
-
658
- #: intergeo/templates/iframe/controls.php:79
659
- msgid "Pan control"
660
- msgstr "Pan control"
661
-
662
- #: intergeo/templates/iframe/controls.php:90
663
- msgid "The Pan control displays buttons for panning the map. This control appears by default in the top left corner of the map on non-touch devices. The Pan control also allows you to rotate 45° imagery, if available."
664
- msgstr "The Pan control displays buttons for panning the map. This control appears by default in the top left corner of the map on non-touch devices. The Pan control also allows you to rotate 45° imagery, if available."
665
-
666
- #: intergeo/templates/iframe/controls.php:141
667
- msgid "Scale control"
668
- msgstr "Scale control"
669
-
670
- #: intergeo/templates/iframe/controls.php:152
671
- msgid "The Scale control displays a map scale element. This control is not enabled by default."
672
- msgstr "The Scale control displays a map scale element. This control is not enabled by default."
673
-
674
- #: intergeo/templates/iframe/controls.php:203
675
- msgid "MapType control"
676
- msgstr "MapType control"
677
-
678
- #: intergeo/templates/iframe/controls.php:214
679
- msgid "The MapType control lets the user toggle between map types (such as roadmap and satellite). This control appears by default in the top right corner of the map."
680
- msgstr "The MapType control lets the user toggle between map types (such as roadmap and satellite). This control appears by default in the top right corner of the map."
681
-
682
- #: intergeo/templates/iframe/controls.php:265
683
- msgid "dropdown menu"
684
- msgstr "dropdown menu"
685
-
686
- #: intergeo/templates/iframe/controls.php:268
687
- msgid "horizontal bar"
688
- msgstr "horizontal bar"
689
-
690
- #: intergeo/templates/iframe/controls.php:275
691
- msgid "Map types:"
692
- msgstr "Map types:"
693
-
694
- #: intergeo/templates/iframe/controls.php:278
695
- msgid "This map type displays a normal street map."
696
- msgstr "This map type displays a normal street map."
697
-
698
- #: intergeo/templates/iframe/controls.php:284
699
- msgid "This map type displays maps with physical features such as terrain and vegetation."
700
- msgstr "This map type displays maps with physical features such as terrain and vegetation."
701
-
702
- #: intergeo/templates/iframe/controls.php:290
703
- msgid "This map type displays satellite images."
704
- msgstr "This map type displays satellite images."
705
-
706
- #: intergeo/templates/iframe/controls.php:296
707
- msgid "This map type displays a transparent layer of major streets on satellite images."
708
- msgstr "This map type displays a transparent layer of major streets on satellite images."
709
-
710
- #: intergeo/templates/iframe/controls.php:304
711
- msgid "Street View control"
712
- msgstr "Street View control"
713
-
714
- #: intergeo/templates/iframe/controls.php:315
715
- msgid "The Street View control contains a Pegman icon which can be dragged onto the map to enable Street View. This control appears by default in the top left corner of the map."
716
- msgstr "The Street View control contains a Pegman icon which can be dragged onto the map to enable Street View. This control appears by default in the top left corner of the map."
717
-
718
- #: intergeo/templates/iframe/controls.php:366
719
- msgid "Rotate control"
720
- msgstr "Rotate control"
721
-
722
- #: intergeo/templates/iframe/controls.php:377
723
- msgid "The Rotate control contains a small circular icon which allows you to rotate maps containing oblique imagery. This control appears by default in the top left corner of the map."
724
- msgstr "The Rotate control contains a small circular icon which allows you to rotate maps containing oblique imagery. This control appears by default in the top left corner of the map."
725
-
726
- #: intergeo/templates/iframe/controls.php:428
727
- msgid "Overview Map control"
728
- msgstr "Overview Map control"
729
-
730
- #: intergeo/templates/iframe/controls.php:439
731
- msgid "The Overview Map control displays a thumbnail overview map reflecting the current map viewport within a wider area. This control appears by default in the bottom right corner of the map, and is by default shown in its collapsed state."
732
- msgstr "The Overview Map control displays a thumbnail overview map reflecting the current map viewport within a wider area. This control appears by default in the bottom right corner of the map, and is by default shown in its collapsed state."
733
-
734
- #: intergeo/templates/iframe/controls.php:445
735
- msgid "Opened"
736
- msgstr "Opened"
737
-
738
- #: intergeo/templates/iframe/popups.php:5
739
- msgid "Go To Address"
740
- msgstr "Go To Address"
741
-
742
- #: intergeo/templates/iframe/popups.php:10
743
- msgid "Type an address you want to go to"
744
- msgstr "Type an address you want to go to"
745
-
746
- #: intergeo/templates/iframe/popups.php:13
747
- msgid "Go"
748
- msgstr "Go"
749
-
750
- #: intergeo/templates/iframe/popups.php:24
751
- msgid "Marker Options"
752
- msgstr "Marker Options"
753
-
754
- #: intergeo/templates/iframe/popups.php:31
755
- #: intergeo/templates/iframe/popups.php:32
756
- msgid "Enter title"
757
- msgstr "Enter title"
758
-
759
- #: intergeo/templates/iframe/popups.php:39
760
- #: intergeo/templates/iframe/popups.php:40
761
- msgid "Enter icon URL"
762
- msgstr "Enter icon URL"
763
-
764
- #: intergeo/templates/iframe/popups.php:47
765
- #: intergeo/templates/iframe/popups.php:48
766
- msgid "Enter html for info window"
767
- msgstr "Enter html for info window"
768
-
769
- #: intergeo/templates/iframe/popups.php:54
770
- #: intergeo/templates/iframe/popups.php:89
771
- #: intergeo/templates/iframe/popups.php:157
772
- msgid "Update"
773
- msgstr "Update"
774
-
775
- #: intergeo/templates/iframe/popups.php:65
776
- msgid "Polyline Options"
777
- msgstr "Polyline Options"
778
-
779
- #: intergeo/templates/iframe/popups.php:72
780
- #: intergeo/templates/iframe/popups.php:73
781
- #: intergeo/templates/iframe/popups.php:112
782
- #: intergeo/templates/iframe/popups.php:113
783
- msgid "Stroke weight in pixel"
784
- msgstr "Stroke weight in pixel"
785
-
786
- #: intergeo/templates/iframe/popups.php:78
787
- #: intergeo/templates/iframe/popups.php:79
788
- #: intergeo/templates/iframe/popups.php:118
789
- #: intergeo/templates/iframe/popups.php:119
790
- msgid "Stroke opacity from 0.0 to 1.0"
791
- msgstr "Stroke opacity from 0.0 to 1.0"
792
-
793
- #: intergeo/templates/iframe/popups.php:100
794
- msgid "Polygon Options"
795
- msgstr "Polygon Options"
796
-
797
- #: intergeo/templates/iframe/popups.php:105
798
- msgid "Stroke options"
799
- msgstr "Stroke options"
800
-
801
- #: intergeo/templates/iframe/popups.php:125
802
- msgid "stroke position"
803
- msgstr "stroke position"
804
-
805
- #: intergeo/templates/iframe/popups.php:126
806
- msgid "center"
807
- msgstr "center"
808
-
809
- #: intergeo/templates/iframe/popups.php:127
810
- msgid "inside the object"
811
- msgstr "inside the object"
812
-
813
- #: intergeo/templates/iframe/popups.php:128
814
- msgid "outside the object"
815
- msgstr "outside the object"
816
-
817
- #: intergeo/templates/iframe/popups.php:139
818
- msgid "Fill options"
819
- msgstr "Fill options"
820
-
821
- #: intergeo/templates/iframe/popups.php:146
822
- #: intergeo/templates/iframe/popups.php:147
823
- msgid "Fill opacity from 0.0 to 1.0"
824
- msgstr "Fill opacity from 0.0 to 1.0"
825
-
826
- #: intergeo/templates/iframe/popups.php:168
827
- msgid "Direction Options"
828
- msgstr "Direction Options"
829
-
830
- #: intergeo/templates/iframe/popups.php:175
831
- #: intergeo/templates/iframe/popups.php:176
832
- msgid "The start location from which to calculate directions"
833
- msgstr "The start location from which to calculate directions"
834
-
835
- #: intergeo/templates/iframe/popups.php:183
836
- #: intergeo/templates/iframe/popups.php:184
837
- msgid "The end location to which to calculate directions"
838
- msgstr "The end location to which to calculate directions"
839
-
840
- #: intergeo/templates/iframe/popups.php:190
841
- #: intergeo/templates/iframe/directions.php:60
842
- msgid "via standard driving directions"
843
- msgstr "via standard driving directions"
844
-
845
- #: intergeo/templates/iframe/popups.php:191
846
- #: intergeo/templates/iframe/directions.php:50
847
- msgid "via bicycle paths & preferred streets"
848
- msgstr "via bicycle paths & preferred streets"
849
-
850
- #: intergeo/templates/iframe/popups.php:192
851
- #: intergeo/templates/iframe/directions.php:53
852
- msgid "via public transit routes"
853
- msgstr "via public transit routes"
854
-
855
- #: intergeo/templates/iframe/popups.php:193
856
- #: intergeo/templates/iframe/directions.php:56
857
- msgid "via pedestrian paths & sidewalks"
858
- msgstr "via pedestrian paths & sidewalks"
859
-
860
- #: intergeo/templates/iframe/popups.php:199
861
- msgid "Save"
862
- msgstr "Save"
863
-
864
- #: intergeo/templates/iframe/adsense.php:1
865
- msgid "AdSense Integration"
866
- msgstr "AdSense Integration"
867
-
868
- #: intergeo/templates/iframe/adsense.php:6
869
- #, php-format
870
- msgid "To make AdSense working on your maps, you have to setup your publisher ID. You can do it at the %ssettings page%s."
871
- msgstr "To make AdSense working on your maps, you have to setup your publisher ID. You can do it at the %ssettings page%s."
872
-
873
- #: intergeo/templates/iframe/adsense.php:24
874
- msgid "default format"
875
- msgstr "default format"
876
-
877
- #: intergeo/templates/iframe/adsense.php:27
878
- msgid "Leaderboard"
879
- msgstr "Leaderboard"
880
-
881
- #: intergeo/templates/iframe/adsense.php:30
882
- msgid "Banner"
883
- msgstr "Banner"
884
-
885
- #: intergeo/templates/iframe/adsense.php:33
886
- msgid "Half Banner"
887
- msgstr "Half Banner"
888
-
889
- #: intergeo/templates/iframe/adsense.php:36
890
- msgid "Skyscraper"
891
- msgstr "Skyscraper"
892
-
893
- #: intergeo/templates/iframe/adsense.php:39
894
- msgid "Wide Skyscraper"
895
- msgstr "Wide Skyscraper"
896
-
897
- #: intergeo/templates/iframe/adsense.php:42
898
- msgid "Vertical Banner"
899
- msgstr "Vertical Banner"
900
-
901
- #: intergeo/templates/iframe/adsense.php:45
902
- msgid "Button"
903
- msgstr "Button"
904
-
905
- #: intergeo/templates/iframe/adsense.php:48
906
- msgid "Small Square"
907
- msgstr "Small Square"
908
-
909
- #: intergeo/templates/iframe/adsense.php:51
910
- msgid "Square"
911
- msgstr "Square"
912
-
913
- #: intergeo/templates/iframe/adsense.php:54
914
- msgid "Small Rectangle"
915
- msgstr "Small Rectangle"
916
-
917
- #: intergeo/templates/iframe/adsense.php:57
918
- msgid "Medium Rectangle"
919
- msgstr "Medium Rectangle"
920
-
921
- #: intergeo/templates/iframe/adsense.php:60
922
- msgid "Large Rectangle"
923
- msgstr "Large Rectangle"
924
-
925
- #: intergeo/templates/iframe/adsense.php:63
926
- msgid "Small Vertical Link Unit"
927
- msgstr "Small Vertical Link Unit"
928
-
929
- #: intergeo/templates/iframe/adsense.php:66
930
- msgid "Medium Vertical Link Unit"
931
- msgstr "Medium Vertical Link Unit"
932
-
933
- #: intergeo/templates/iframe/adsense.php:69
934
- msgid "Large Vertical Link Unit"
935
- msgstr "Large Vertical Link Unit"
936
-
937
- #: intergeo/templates/iframe/adsense.php:72
938
- msgid "Extra Large Vertical Link Unit"
939
- msgstr "Extra Large Vertical Link Unit"
940
-
941
- #: intergeo/templates/iframe/adsense.php:75
942
- msgid "Small Horizontal Link Unit"
943
- msgstr "Small Horizontal Link Unit"
944
-
945
- #: intergeo/templates/iframe/adsense.php:78
946
- msgid "Large Horizontal Link Unit"
947
- msgstr "Large Horizontal Link Unit"
948
-
949
- #: intergeo/templates/iframe/adsense.php:131
950
- msgid "Background color"
951
- msgstr "Background color"
952
-
953
- #: intergeo/templates/iframe/adsense.php:134
954
- #: intergeo/templates/iframe/adsense.php:140
955
- #: intergeo/templates/iframe/adsense.php:146
956
- #: intergeo/templates/iframe/adsense.php:152
957
- #: intergeo/templates/iframe/adsense.php:158
958
- msgid "Hex Value"
959
- msgstr "Hex Value"
960
-
961
- #: intergeo/templates/iframe/adsense.php:137
962
- msgid "Border color"
963
- msgstr "Border color"
964
-
965
- #: intergeo/templates/iframe/adsense.php:143
966
- msgid "Title color"
967
- msgstr "Title color"
968
-
969
- #: intergeo/templates/iframe/adsense.php:149
970
- msgid "Text color"
971
- msgstr "Text color"
972
-
973
- #: intergeo/templates/iframe/adsense.php:155
974
- msgid "URL color"
975
- msgstr "URL color"
976
-
977
- #: intergeo/templates/iframe/directions.php:1
978
- msgid "Directions"
979
- msgstr "Directions"
980
-
981
- #: intergeo/templates/iframe/directions.php:5
982
- msgid "To add a new direction just click the button below:"
983
- msgstr "To add a new direction just click the button below:"
984
-
985
- #: intergeo/templates/iframe/directions.php:10
986
- msgid "Add Direction"
987
- msgstr "Add Direction"
988
-
989
- #: intergeo/templates/iframe/directions.php:16
990
- #: intergeo/templates/iframe/directions.php:22
991
- #: intergeo/templates/iframe/directions.php:43
992
- msgid "from"
993
- msgstr "from"
994
-
995
- #: intergeo/templates/iframe/directions.php:16
996
- #: intergeo/templates/iframe/directions.php:22
997
- #: intergeo/templates/iframe/directions.php:45
998
- msgid "to"
999
- msgstr "to"
1000
-
1001
- #: intergeo/templates/iframe/directions.php:29
1002
- #: intergeo/templates/iframe/directions.php:70
1003
- msgid "Delete direction"
1004
- msgstr "Delete direction"
1005
-
1006
- #: intergeo/templates/iframe/directions.php:30
1007
- #: intergeo/templates/iframe/directions.php:71
1008
- msgid "Edit direction"
1009
- msgstr "Edit direction"
1010
-
1011
- #: intergeo/templates/iframe/directions.php:35
1012
- msgid "Created directions"
1013
- msgstr "Created directions"
1014
-
1015
- #~ msgid "Direction calculation process failed."
1016
- #~ msgstr "Direction calculation process failed."
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Intergeo 1.0\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: 2013-02-01 21:40+0300\n"
6
+ "PO-Revision-Date: Thu Apr 07 2016 13:49:48 GMT+0530 (India Standard Time)\n"
7
+ "Last-Translator: Eugene Manuilov <eugene@manuilov.org>\n"
8
+ "Language-Team: Intergeo <eugene@manuilov.org>\n"
9
+ "Language: Intergeo\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-Poedit-SourceCharset: utf-8\n"
15
+ "X-Loco-Source-Locale: en_IN\n"
16
+ "X-Poedit-Basepath: ./../../\n"
17
+ "X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html__;esc_attr_e;esc_attr__\n"
18
+ "X-Poedit-Language: English\n"
19
+ "X-Poedit-Country: UNITED STATES\n"
20
+ "X-Poedit-SearchPath-0: intergeo\n"
21
+ "X-Loco-Parser: loco_parse_po\n"
22
+ "X-Loco-Target-Locale: en_US\n"
23
+ "X-Generator: Loco - https://localise.biz/"
24
+
25
+ #: intergeo/index.php:31
26
+ #: intergeo/templates/library/list.php:3
27
+ #: intergeo/templates/iframe/form.php:7
28
+ msgid "Maps"
29
+ msgstr "Maps"
30
+
31
+ #: intergeo/index.php:32
32
+ msgid "Settings"
33
+ msgstr "Settings"
34
+
35
+ #: intergeo/index.php:81
36
+ #, php-format
37
+ msgid ""
38
+ "All Maps API applications should load the Maps API using an API key (however "
39
+ "it is still possible to use maps without API key). Using an API key enables "
40
+ "you to monitor your application's Maps API usage, and ensures that Google "
41
+ "can contact you about your application if necessary. If your application's "
42
+ "Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API "
43
+ "using an API key in order to purchase additional quota. To create your API "
44
+ "key:"
45
+ msgstr ""
46
+ "All Maps API applications should load the Maps API using an API key (however "
47
+ "it is still possible to use maps without API key). Using an API key enables "
48
+ "you to monitor your application's Maps API usage, and ensures that Google "
49
+ "can contact you about your application if necessary. If your application's "
50
+ "Maps API usage exceeds the %sUsage Limits%s, you must load the Maps API "
51
+ "using an API key in order to purchase additional quota. To create your API "
52
+ "key:"
53
+
54
+ #: intergeo/index.php:84
55
+ #, php-format
56
+ msgid ""
57
+ "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log "
58
+ "in with your Google Account."
59
+ msgstr ""
60
+ "Visit the APIs Console at %shttps://code.google.com/apis/console%s and log "
61
+ "in with your Google Account."
62
+
63
+ #: intergeo/index.php:85
64
+ #, php-format
65
+ msgid "Click the %sServices%s link from the left-hand menu."
66
+ msgstr "Click the %sServices%s link from the left-hand menu."
67
+
68
+ #: intergeo/index.php:86
69
+ #, php-format
70
+ msgid "Activate the %sGoogle Maps API v3%s service."
71
+ msgstr "Activate the %sGoogle Maps API v3%s service."
72
+
73
+ #: intergeo/index.php:87
74
+ #, c-format
75
+ msgid ""
76
+ "Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is "
77
+ "available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s "
78
+ "section. Maps API applications use the %1$sKey for browser apps%2$s."
79
+ msgstr ""
80
+ "Click the %1$sAPI Access%2$s link from the left-hand menu. Your API key is "
81
+ "available from the %1$sAPI Access%2$s page, in the %1$Simple API Access%2$s "
82
+ "section. Maps API applications use the %1$sKey for browser apps%2$s."
83
+
84
+ #: intergeo/index.php:94
85
+ #, php-format
86
+ msgid ""
87
+ "Adding display ads to your map requires that you have an AdSense account "
88
+ "enabled for AdSense for Content. If you don't yet have an AdSense account, "
89
+ "%1$ssign up%3$s for one. Once you have done so (or if you already have an "
90
+ "account) make sure you've also enabled the account with %2$sAdSense for "
91
+ "Content%3$s."
92
+ msgstr ""
93
+ "Adding display ads to your map requires that you have an AdSense account "
94
+ "enabled for AdSense for Content. If you don't yet have an AdSense account, "
95
+ "%1$ssign up%3$s for one. Once you have done so (or if you already have an "
96
+ "account) make sure you've also enabled the account with %2$sAdSense for "
97
+ "Content%3$s."
98
+
99
+ #: intergeo/index.php:96
100
+ msgid ""
101
+ "Once you have an Adsense for Content account, you will have received an "
102
+ "AdSense for Content (AFC) publisher ID. This publisher ID is used to link "
103
+ "any advertising shown to your AdSense account, allowing you to share in "
104
+ "advertising revenue when a user clicks on one of the ads shown on your maps."
105
+ msgstr ""
106
+ "Once you have an Adsense for Content account, you will have received an "
107
+ "AdSense for Content (AFC) publisher ID. This publisher ID is used to link "
108
+ "any advertising shown to your AdSense account, allowing you to share in "
109
+ "advertising revenue when a user clicks on one of the ads shown on your maps."
110
+
111
+ #: intergeo/index.php:180
112
+ msgid "Intergeo Maps"
113
+ msgstr "Intergeo Maps"
114
+
115
+ #: intergeo/index.php:217
116
+ #: intergeo/templates/iframe/overlays.php:26
117
+ #: intergeo/templates/iframe/overlays.php:49
118
+ msgid "marker"
119
+ msgstr "marker"
120
+
121
+ #: intergeo/index.php:219
122
+ msgid "Styles are broken. Please, fix it and try again."
123
+ msgstr "Styles are broken. Please, fix it and try again."
124
+
125
+ #: intergeo/index.php:220
126
+ msgid "Direction was not found."
127
+ msgstr "Maps"
128
+
129
+ #: intergeo/index.php:235
130
+ msgid "Insert into post"
131
+ msgstr "Insert into post"
132
+
133
+ #: intergeo/index.php:238
134
+ msgid "Create the map"
135
+ msgstr "Create the map"
136
+
137
+ #: intergeo/index.php:253
138
+ msgid "Update the map"
139
+ msgstr "Update the map"
140
+
141
+ #: intergeo/index.php:621
142
+ msgid "The map has been updated successfully."
143
+ msgstr "The map has been updated successfully."
144
+
145
+ #: intergeo/index.php:622
146
+ msgid "The map has been created successfully."
147
+ msgstr "The map has been created successfully."
148
+
149
+ #: intergeo/index.php:630
150
+ msgid "The map updating failed."
151
+ msgstr "The map updating failed."
152
+
153
+ #: intergeo/index.php:631
154
+ msgid "The map creation failed."
155
+ msgstr "The map creation failed."
156
+
157
+ #: intergeo/index.php:768
158
+ msgid "Overview"
159
+ msgstr "Overview"
160
+
161
+ #: intergeo/index.php:771
162
+ msgid ""
163
+ "The library is a list to view all maps you have created in your system. The "
164
+ "library is showing you 3x3 grid of maps' previews. You will see the same "
165
+ "maps embedded into your posts at front end, as you see here. The library is "
166
+ "paginated and if you have more than 9 maps, you will see pagination links "
167
+ "under maps grid."
168
+ msgstr ""
169
+ "The library is a list to view all maps you have created in your system. The "
170
+ "library is showing you 3x3 grid of maps' previews. You will see the same "
171
+ "maps embedded into your posts at front end, as you see here. The library is "
172
+ "paginated and if you have more than 9 maps, you will see pagination links "
173
+ "under maps grid."
174
+
175
+ #: intergeo/index.php:772
176
+ msgid ""
177
+ "To create a new map, click on \"Add New\" button next to the page title and "
178
+ "map editor popup will appear. In case you want to edit a map, you can click "
179
+ "on pencil icon in the right bottom corner of map preview box and edit popup "
180
+ "window will appear."
181
+ msgstr ""
182
+ "To create a new map, click on \"Add New\" button next to the page title and "
183
+ "map editor popup will appear. In case you want to edit a map, you can click "
184
+ "on pencil icon in the right bottom corner of map preview box and edit popup "
185
+ "window will appear."
186
+
187
+ #: intergeo/index.php:773
188
+ msgid ""
189
+ "If you want to delete a map, click on the trash icon in the right bottom "
190
+ "corner of a map and confirm your action. Pay attention that whole "
191
+ "information about the map will be removed from the system, but all "
192
+ "shortcodes will be left where you embed it. However these deprecated "
193
+ "shortcodes won't be rendered anymore, so you don't have to worry about it "
194
+ "while the plugin is enabled."
195
+ msgstr ""
196
+ "If you want to delete a map, click on the trash icon in the right bottom "
197
+ "corner of a map and confirm your action. Pay attention that whole "
198
+ "information about the map will be removed from the system, but all "
199
+ "shortcodes will be left where you embed it. However these deprecated "
200
+ "shortcodes won't be rendered anymore, so you don't have to worry about it "
201
+ "while the plugin is enabled."
202
+
203
+ #: intergeo/index.php:778
204
+ msgid "Shortcodes"
205
+ msgstr "Shortcodes"
206
+
207
+ #: intergeo/index.php:781
208
+ msgid ""
209
+ "You can easily embed a map into your posts, pages, categories or tags "
210
+ "descriptions and text widgets by copying shortcode which you can find in the "
211
+ "input field of a map preview box."
212
+ msgstr ""
213
+ "You can easily embed a map into your posts, pages, categories or tags "
214
+ "descriptions and text widgets by copying shortcode which you can find in the "
215
+ "input field of a map preview box."
216
+
217
+ #: intergeo/index.php:782
218
+ msgid ""
219
+ "To specify a certain address just type it inside a shortcode, and a map will "
220
+ "be automatically centered at this place. Also each shortcode could be "
221
+ "extended with custom attributes like width, height, style, zoom and hook. "
222
+ "Use standard CSS values for such attributes as width, height and style. Type "
223
+ "an integer between 0 and 19 for zoom attribute. You can use hook attribute "
224
+ "to set up a filter hook which you can use in your custom plugin or theme to "
225
+ "configure all options of a map."
226
+ msgstr ""
227
+ "To specify a certain address just type it inside a shortcode, and a map will "
228
+ "be automatically centered at this place. Also each shortcode could be "
229
+ "extended with custom attributes like width, height, style, zoom and hook. "
230
+ "Use standard CSS values for such attributes as width, height and style. Type "
231
+ "an integer between 0 and 19 for zoom attribute. You can use hook attribute "
232
+ "to set up a filter hook which you can use in your custom plugin or theme to "
233
+ "configure all options of a map."
234
+
235
+ #: intergeo/index.php:841
236
+ msgid "The map was deleted successfully."
237
+ msgstr "The map was deleted successfully."
238
+
239
+ #: intergeo/templates/library/list.php:4
240
+ msgid "Add New"
241
+ msgstr "Add New"
242
+
243
+ #: intergeo/templates/library/list.php:45
244
+ msgid "Edit"
245
+ msgstr "Edit"
246
+
247
+ #: intergeo/templates/library/list.php:46
248
+ msgid "Copy"
249
+ msgstr "Copy"
250
+
251
+ #: intergeo/templates/library/list.php:47
252
+ msgid "Delete"
253
+ msgstr "Delete"
254
+
255
+ #: intergeo/templates/library/list.php:81
256
+ msgid "You do not have created maps. Start adding it by clicking \"Add New\" button."
257
+ msgstr "You do not have created maps. Start adding it by clicking \"Add New\" button."
258
+
259
+ #: intergeo/templates/iframe/layers.php:1
260
+ msgid "Layers"
261
+ msgstr "Layers"
262
+
263
+ #: intergeo/templates/iframe/layers.php:4
264
+ msgid "Traffic layer"
265
+ msgstr "Traffic layer"
266
+
267
+ #: intergeo/templates/iframe/layers.php:11
268
+ #: intergeo/templates/iframe/layers.php:27
269
+ #: intergeo/templates/iframe/layers.php:103
270
+ #: intergeo/templates/iframe/controls.php:12
271
+ #: intergeo/templates/iframe/controls.php:86
272
+ #: intergeo/templates/iframe/controls.php:148
273
+ #: intergeo/templates/iframe/controls.php:210
274
+ #: intergeo/templates/iframe/controls.php:311
275
+ #: intergeo/templates/iframe/controls.php:373
276
+ #: intergeo/templates/iframe/controls.php:435
277
+ msgid "Enabled"
278
+ msgstr "Enabled"
279
+
280
+ #: intergeo/templates/iframe/layers.php:15
281
+ #, php-format
282
+ msgid ""
283
+ "Allows you to add real-time traffic information (where supported) to your "
284
+ "map. Traffic information is provided for the time at which the request is "
285
+ "made. Consult %s this spreadsheet %s to determine traffic coverage support."
286
+ msgstr ""
287
+ "Allows you to add real-time traffic information (where supported) to your "
288
+ "map. Traffic information is provided for the time at which the request is "
289
+ "made. Consult %s this spreadsheet %s to determine traffic coverage support."
290
+
291
+ #: intergeo/templates/iframe/layers.php:20
292
+ msgid "Bicycling layer"
293
+ msgstr "Bicycling layer"
294
+
295
+ #: intergeo/templates/iframe/layers.php:31
296
+ msgid ""
297
+ "Allows you to add bicycle information to your map. It renders a layer of "
298
+ "bike paths, suggested bike routes and other overlays specific to bicycling "
299
+ "usage on top of the given map. Additionally, the layer alters the style of "
300
+ "the base map itself to emphasize streets supporting bicycle routes and de-"
301
+ "emphasize streets inappropriate for bicycles."
302
+ msgstr ""
303
+ "Allows you to add bicycle information to your map. It renders a layer of "
304
+ "bike paths, suggested bike routes and other overlays specific to bicycling "
305
+ "usage on top of the given map. Additionally, the layer alters the style of "
306
+ "the base map itself to emphasize streets supporting bicycle routes and de-"
307
+ "emphasize streets inappropriate for bicycles."
308
+
309
+ #: intergeo/templates/iframe/layers.php:36
310
+ msgid "Weather & Cloud layers"
311
+ msgstr "Weather & Cloud layers"
312
+
313
+ #: intergeo/templates/iframe/layers.php:43
314
+ msgid "Enabled cloud"
315
+ msgstr "Enabled cloud"
316
+
317
+ #: intergeo/templates/iframe/layers.php:47
318
+ msgid ""
319
+ "Allows you to add the display of cloud imagery on your map. Enabling the "
320
+ "cloud layer will add cloud coverage imagery to your map, visible at low zoom "
321
+ "levels."
322
+ msgstr ""
323
+ "Allows you to add the display of cloud imagery on your map. Enabling the "
324
+ "cloud layer will add cloud coverage imagery to your map, visible at low zoom "
325
+ "levels."
326
+
327
+ #: intergeo/templates/iframe/layers.php:54
328
+ msgid "Enabled weather"
329
+ msgstr "Enabled weather"
330
+
331
+ #: intergeo/templates/iframe/layers.php:58
332
+ msgid ""
333
+ "Allows you to add the display of weather data on your map. Enabling the "
334
+ "weather layer will show current weather conditions from weather.com on your "
335
+ "map, including icons that denote sun, clouds, rain and so on."
336
+ msgstr ""
337
+ "Allows you to add the display of weather data on your map. Enabling the "
338
+ "weather layer will show current weather conditions from weather.com on your "
339
+ "map, including icons that denote sun, clouds, rain and so on."
340
+
341
+ #: intergeo/templates/iframe/layers.php:65
342
+ msgid "temperature units"
343
+ msgstr "temperature units"
344
+
345
+ #: intergeo/templates/iframe/layers.php:68
346
+ msgid "Celsius"
347
+ msgstr "Celsius"
348
+
349
+ #: intergeo/templates/iframe/layers.php:71
350
+ msgid "Fahrenheit"
351
+ msgstr "Fahrenheit"
352
+
353
+ #: intergeo/templates/iframe/layers.php:78
354
+ msgid "wind speed units"
355
+ msgstr "wind speed units"
356
+
357
+ #: intergeo/templates/iframe/layers.php:81
358
+ msgid "kilometers per hour"
359
+ msgstr "kilometers per hour"
360
+
361
+ #: intergeo/templates/iframe/layers.php:84
362
+ msgid "meters per second"
363
+ msgstr "meters per second"
364
+
365
+ #: intergeo/templates/iframe/layers.php:87
366
+ msgid "miles per hour"
367
+ msgstr "miles per hour"
368
+
369
+ #: intergeo/templates/iframe/layers.php:96
370
+ msgid "Panoramio layer"
371
+ msgstr "Panoramio layer"
372
+
373
+ #: intergeo/templates/iframe/layers.php:107
374
+ msgid ""
375
+ "Allows you to add photos from Panoramio as a layer to your map. It renders a "
376
+ "layer of geotagged photo icons from Panoramio on the map as a series of "
377
+ "large and small photo icons."
378
+ msgstr ""
379
+ "Allows you to add photos from Panoramio as a layer to your map. It renders a "
380
+ "layer of geotagged photo icons from Panoramio on the map as a series of "
381
+ "large and small photo icons."
382
+
383
+ #: intergeo/templates/iframe/layers.php:111
384
+ msgid "Restricting photos by tag"
385
+ msgstr "Restricting photos by tag"
386
+
387
+ #: intergeo/templates/iframe/layers.php:115
388
+ msgid ""
389
+ "Allows you to restrict the set of photos to display on the map to those "
390
+ "matching a certain textual tag."
391
+ msgstr ""
392
+ "Allows you to restrict the set of photos to display on the map to those "
393
+ "matching a certain textual tag."
394
+
395
+ #: intergeo/templates/iframe/layers.php:119
396
+ msgid "Restricting photos by user id"
397
+ msgstr "Restricting photos by user id"
398
+
399
+ #: intergeo/templates/iframe/layers.php:123
400
+ msgid ""
401
+ "Allows you to restrict the set of photos to display on the map to those "
402
+ "matching a particular user."
403
+ msgstr ""
404
+ "Allows you to restrict the set of photos to display on the map to those "
405
+ "matching a particular user."
406
+
407
+ #: intergeo/templates/iframe/form.php:34
408
+ msgid "The center of the map"
409
+ msgstr "The center of the map"
410
+
411
+ #: intergeo/templates/iframe/form.php:37
412
+ msgid "Go to address"
413
+ msgstr "Go to address"
414
+
415
+ #: intergeo/templates/iframe/overlays.php:1
416
+ msgid "Overlays"
417
+ msgstr "Overlays"
418
+
419
+ #: intergeo/templates/iframe/overlays.php:5
420
+ msgid ""
421
+ "Drawing tools allows you to add overlays over the map. You can add markers, "
422
+ "polylines, polygons, circles and rectangles. To enable drawing tools just "
423
+ "put a tick in the checkbox below."
424
+ msgstr ""
425
+ "Drawing tools allows you to add overlays over the map. You can add markers, "
426
+ "polylines, polygons, circles and rectangles. To enable drawing tools just "
427
+ "put a tick in the checkbox below."
428
+
429
+ #: intergeo/templates/iframe/overlays.php:8
430
+ msgid "To delete a marker, just double click on it and an item will be removed."
431
+ msgstr "To delete a marker, just double click on it and an item will be removed."
432
+
433
+ #: intergeo/templates/iframe/overlays.php:16
434
+ msgid "Enable drawing tools"
435
+ msgstr "Enable drawing tools"
436
+
437
+ #: intergeo/templates/iframe/overlays.php:34
438
+ #: intergeo/templates/iframe/overlays.php:60
439
+ msgid "Delete marker"
440
+ msgstr "Delete marker"
441
+
442
+ #: intergeo/templates/iframe/overlays.php:35
443
+ #: intergeo/templates/iframe/overlays.php:61
444
+ msgid "Edit marker"
445
+ msgstr "Edit marker"
446
+
447
+ #: intergeo/templates/iframe/overlays.php:41
448
+ msgid "Markers"
449
+ msgstr "Markers"
450
+
451
+ #: intergeo/templates/iframe/overlays.php:74
452
+ #: intergeo/templates/iframe/overlays.php:102
453
+ msgid "polyline"
454
+ msgstr "polyline"
455
+
456
+ #: intergeo/templates/iframe/overlays.php:82
457
+ #: intergeo/templates/iframe/overlays.php:110
458
+ msgid "Delete polyline"
459
+ msgstr "Delete polyline"
460
+
461
+ #: intergeo/templates/iframe/overlays.php:83
462
+ #: intergeo/templates/iframe/overlays.php:111
463
+ msgid "Edit polyline"
464
+ msgstr "Edit polyline"
465
+
466
+ #: intergeo/templates/iframe/overlays.php:90
467
+ msgid "Polylines"
468
+ msgstr "Polylines"
469
+
470
+ #: intergeo/templates/iframe/overlays.php:126
471
+ #: intergeo/templates/iframe/overlays.php:171
472
+ msgid "rectangle"
473
+ msgstr "Maps"
474
+
475
+ #: intergeo/templates/iframe/overlays.php:137
476
+ #: intergeo/templates/iframe/overlays.php:182
477
+ #: intergeo/templates/iframe/overlays.php:210
478
+ msgid "Delete rectangle"
479
+ msgstr "Delete rectangle"
480
+
481
+ #: intergeo/templates/iframe/overlays.php:138
482
+ #: intergeo/templates/iframe/overlays.php:183
483
+ #: intergeo/templates/iframe/overlays.php:211
484
+ msgid "Edit rectangle"
485
+ msgstr "Edit rectangle"
486
+
487
+ #: intergeo/templates/iframe/overlays.php:146
488
+ msgid "Rectangles"
489
+ msgstr "Rectangles"
490
+
491
+ #: intergeo/templates/iframe/overlays.php:199
492
+ #: intergeo/templates/iframe/overlays.php:244
493
+ msgid "circle"
494
+ msgstr "circle"
495
+
496
+ #: intergeo/templates/iframe/overlays.php:219
497
+ msgid "Circles"
498
+ msgstr "Circles"
499
+
500
+ #: intergeo/templates/iframe/overlays.php:255
501
+ msgid "Delete circle"
502
+ msgstr "Delete circle"
503
+
504
+ #: intergeo/templates/iframe/overlays.php:256
505
+ msgid "Edit circle"
506
+ msgstr "Edit circle"
507
+
508
+ #: intergeo/templates/iframe/overlays.php:272
509
+ #: intergeo/templates/iframe/overlays.php:317
510
+ msgid "polygon"
511
+ msgstr "polygon"
512
+
513
+ #: intergeo/templates/iframe/overlays.php:283
514
+ #: intergeo/templates/iframe/overlays.php:328
515
+ msgid "Delete polygon"
516
+ msgstr "Delete polygon"
517
+
518
+ #: intergeo/templates/iframe/overlays.php:284
519
+ #: intergeo/templates/iframe/overlays.php:329
520
+ msgid "Edit polygon"
521
+ msgstr "Edit polygon"
522
+
523
+ #: intergeo/templates/iframe/overlays.php:292
524
+ msgid "Polygons"
525
+ msgstr "Polygons"
526
+
527
+ #: intergeo/templates/iframe/positioning.php:1
528
+ msgid "Positioning & Zooming"
529
+ msgstr "Positioning & Zooming"
530
+
531
+ #: intergeo/templates/iframe/positioning.php:5
532
+ msgid ""
533
+ "If you want to set specific map position and certain level of zooming, just "
534
+ "set it up on preview map and these settings will be remembered at published "
535
+ "map."
536
+ msgstr ""
537
+ "If you want to set specific map position and certain level of zooming, just "
538
+ "set it up on preview map and these settings will be remembered at published "
539
+ "map."
540
+
541
+ #: intergeo/templates/iframe/positioning.php:9
542
+ msgid "Positioning"
543
+ msgstr "Positioning"
544
+
545
+ #: intergeo/templates/iframe/positioning.php:12
546
+ msgid "The initial map type"
547
+ msgstr "The initial map type"
548
+
549
+ #: intergeo/templates/iframe/positioning.php:15
550
+ #: intergeo/templates/iframe/controls.php:280
551
+ msgid "Road map"
552
+ msgstr "Road map"
553
+
554
+ #: intergeo/templates/iframe/positioning.php:18
555
+ #: intergeo/templates/iframe/controls.php:286
556
+ msgid "Terrain"
557
+ msgstr "Terrain"
558
+
559
+ #: intergeo/templates/iframe/positioning.php:21
560
+ #: intergeo/templates/iframe/controls.php:292
561
+ msgid "Satellite"
562
+ msgstr "Satellite"
563
+
564
+ #: intergeo/templates/iframe/positioning.php:24
565
+ #: intergeo/templates/iframe/controls.php:298
566
+ msgid "Hybrid"
567
+ msgstr "Hybrid"
568
+
569
+ #: intergeo/templates/iframe/positioning.php:33
570
+ msgid "Draggable map"
571
+ msgstr "Draggable map"
572
+
573
+ #: intergeo/templates/iframe/positioning.php:37
574
+ msgid ""
575
+ "If unchecked prevents the map from being dragged. Dragging is enabled by "
576
+ "default."
577
+ msgstr ""
578
+ "If unchecked prevents the map from being dragged. Dragging is enabled by "
579
+ "default."
580
+
581
+ #: intergeo/templates/iframe/positioning.php:42
582
+ msgid "Zooming"
583
+ msgstr "Zooming"
584
+
585
+ #: intergeo/templates/iframe/positioning.php:46
586
+ msgid "Zoom range values"
587
+ msgstr "Zoom range values"
588
+
589
+ #: intergeo/templates/iframe/positioning.php:59
590
+ msgid ""
591
+ "The maximum (19) and minimum (0) zoom levels which could be displayed on the "
592
+ "map."
593
+ msgstr ""
594
+ "The maximum (19) and minimum (0) zoom levels which could be displayed on the "
595
+ "map."
596
+
597
+ #: intergeo/templates/iframe/positioning.php:66
598
+ msgid "Scrollwheel zooming"
599
+ msgstr "Scrollwheel zooming"
600
+
601
+ #: intergeo/templates/iframe/positioning.php:70
602
+ msgid "Determines if scrollwheel zooming is enabled on the map."
603
+ msgstr "Determines if scrollwheel zooming is enabled on the map."
604
+
605
+ #: intergeo/templates/iframe/positioning.php:75
606
+ msgid "Preview settings"
607
+ msgstr "Preview settings"
608
+
609
+ #: intergeo/templates/iframe/positioning.php:81
610
+ msgid "Lock preview"
611
+ msgstr "Lock preview"
612
+
613
+ #: intergeo/templates/iframe/positioning.php:85
614
+ msgid ""
615
+ "Lock preview map to preserve changing of the viewport bounds and zoom level. "
616
+ "Locking affects only on preview map and won't lock embedded map."
617
+ msgstr ""
618
+ "Lock preview map to preserve changing of the viewport bounds and zoom level. "
619
+ "Locking affects only on preview map and won't lock embedded map."
620
+
621
+ #: intergeo/templates/iframe/positioning.php:91
622
+ msgid "Show map center"
623
+ msgstr "Show map center"
624
+
625
+ #: intergeo/templates/iframe/positioning.php:95
626
+ msgid ""
627
+ "Show small red circle at the center of the map. It helps you to centralize "
628
+ "the map bounds. Note that this option won't be displayed at frontend."
629
+ msgstr ""
630
+ "Show small red circle at the center of the map. It helps you to centralize "
631
+ "the map bounds. Note that this option won't be displayed at frontend."
632
+
633
+ #: intergeo/templates/iframe/styles.php:1
634
+ #: intergeo/templates/iframe/adsense.php:128
635
+ msgid "Styles"
636
+ msgstr "Styles"
637
+
638
+ #: intergeo/templates/iframe/styles.php:4
639
+ msgid "Container's Styles"
640
+ msgstr "Container's Styles"
641
+
642
+ #: intergeo/templates/iframe/styles.php:7
643
+ msgid "Width"
644
+ msgstr "Width"
645
+
646
+ #: intergeo/templates/iframe/styles.php:11
647
+ msgid "Height"
648
+ msgstr "Height"
649
+
650
+ #: intergeo/templates/iframe/styles.php:15
651
+ msgid "Extra Styles"
652
+ msgstr "Extra Styles"
653
+
654
+ #: intergeo/templates/iframe/styles.php:21
655
+ msgid "Predefined Map Styles"
656
+ msgstr "Predefined Map Styles"
657
+
658
+ #: intergeo/templates/iframe/styles.php:66
659
+ msgid "Custom Map Styles"
660
+ msgstr "Custom Map Styles"
661
+
662
+ #: intergeo/templates/iframe/styles.php:72
663
+ msgid "Use custom styles"
664
+ msgstr "Use custom styles"
665
+
666
+ #: intergeo/templates/iframe/styles.php:79
667
+ #, php-format
668
+ msgid ""
669
+ "Creating styles by hand and testing your code to see how they look is "
670
+ "potentially time-consuming. Instead, you can use the %sStyled Map Wizard%s "
671
+ "to set up the JSON for your map's styles."
672
+ msgstr ""
673
+ "Creating styles by hand and testing your code to see how they look is "
674
+ "potentially time-consuming. Instead, you can use the %sStyled Map Wizard%s "
675
+ "to set up the JSON for your map's styles."
676
+
677
+ #: intergeo/templates/iframe/controls.php:2
678
+ msgid "Controls"
679
+ msgstr "Controls"
680
+
681
+ #: intergeo/templates/iframe/controls.php:5
682
+ msgid "Zoom control"
683
+ msgstr "Zoom control"
684
+
685
+ #: intergeo/templates/iframe/controls.php:16
686
+ msgid ""
687
+ "The Zoom control displays a slider (for large maps) or small \"+/-\" buttons "
688
+ "(for small maps) to control the zoom level of the map. This control appears "
689
+ "by default in the top left corner of the map on non-touch devices or in the "
690
+ "bottom left corner on touch devices."
691
+ msgstr ""
692
+ "The Zoom control displays a slider (for large maps) or small \"+/-\" buttons "
693
+ "(for small maps) to control the zoom level of the map. This control appears "
694
+ "by default in the top left corner of the map on non-touch devices or in the "
695
+ "bottom left corner on touch devices."
696
+
697
+ #: intergeo/templates/iframe/controls.php:22
698
+ #: intergeo/templates/iframe/controls.php:96
699
+ #: intergeo/templates/iframe/controls.php:158
700
+ #: intergeo/templates/iframe/controls.php:220
701
+ #: intergeo/templates/iframe/controls.php:321
702
+ #: intergeo/templates/iframe/controls.php:383
703
+ #: intergeo/templates/iframe/adsense.php:84
704
+ msgid "default position"
705
+ msgstr "default position"
706
+
707
+ #: intergeo/templates/iframe/controls.php:24
708
+ #: intergeo/templates/iframe/controls.php:98
709
+ #: intergeo/templates/iframe/controls.php:160
710
+ #: intergeo/templates/iframe/controls.php:222
711
+ #: intergeo/templates/iframe/controls.php:323
712
+ #: intergeo/templates/iframe/controls.php:385
713
+ #: intergeo/templates/iframe/adsense.php:86
714
+ msgid "Top Left"
715
+ msgstr "Top Left"
716
+
717
+ #: intergeo/templates/iframe/controls.php:27
718
+ #: intergeo/templates/iframe/controls.php:101
719
+ #: intergeo/templates/iframe/controls.php:163
720
+ #: intergeo/templates/iframe/controls.php:225
721
+ #: intergeo/templates/iframe/controls.php:326
722
+ #: intergeo/templates/iframe/controls.php:388
723
+ #: intergeo/templates/iframe/adsense.php:89
724
+ msgid "Top Center"
725
+ msgstr "Top Center"
726
+
727
+ #: intergeo/templates/iframe/controls.php:30
728
+ #: intergeo/templates/iframe/controls.php:104
729
+ #: intergeo/templates/iframe/controls.php:166
730
+ #: intergeo/templates/iframe/controls.php:228
731
+ #: intergeo/templates/iframe/controls.php:329
732
+ #: intergeo/templates/iframe/controls.php:391
733
+ #: intergeo/templates/iframe/adsense.php:92
734
+ msgid "Top Right"
735
+ msgstr "Top Right"
736
+
737
+ #: intergeo/templates/iframe/controls.php:33
738
+ #: intergeo/templates/iframe/controls.php:107
739
+ #: intergeo/templates/iframe/controls.php:169
740
+ #: intergeo/templates/iframe/controls.php:231
741
+ #: intergeo/templates/iframe/controls.php:332
742
+ #: intergeo/templates/iframe/controls.php:394
743
+ #: intergeo/templates/iframe/adsense.php:95
744
+ msgid "Right Top"
745
+ msgstr "Right Top"
746
+
747
+ #: intergeo/templates/iframe/controls.php:36
748
+ #: intergeo/templates/iframe/controls.php:110
749
+ #: intergeo/templates/iframe/controls.php:172
750
+ #: intergeo/templates/iframe/controls.php:234
751
+ #: intergeo/templates/iframe/controls.php:335
752
+ #: intergeo/templates/iframe/controls.php:397
753
+ #: intergeo/templates/iframe/adsense.php:98
754
+ msgid "Right Center"
755
+ msgstr "Right Center"
756
+
757
+ #: intergeo/templates/iframe/controls.php:39
758
+ #: intergeo/templates/iframe/controls.php:113
759
+ #: intergeo/templates/iframe/controls.php:175
760
+ #: intergeo/templates/iframe/controls.php:237
761
+ #: intergeo/templates/iframe/controls.php:338
762
+ #: intergeo/templates/iframe/controls.php:400
763
+ #: intergeo/templates/iframe/adsense.php:101
764
+ msgid "Right Bottom"
765
+ msgstr "Right Bottom"
766
+
767
+ #: intergeo/templates/iframe/controls.php:42
768
+ #: intergeo/templates/iframe/controls.php:116
769
+ #: intergeo/templates/iframe/controls.php:178
770
+ #: intergeo/templates/iframe/controls.php:240
771
+ #: intergeo/templates/iframe/controls.php:341
772
+ #: intergeo/templates/iframe/controls.php:403
773
+ #: intergeo/templates/iframe/adsense.php:104
774
+ msgid "Bottom Right"
775
+ msgstr "Bottom Right"
776
+
777
+ #: intergeo/templates/iframe/controls.php:45
778
+ #: intergeo/templates/iframe/controls.php:119
779
+ #: intergeo/templates/iframe/controls.php:181
780
+ #: intergeo/templates/iframe/controls.php:243
781
+ #: intergeo/templates/iframe/controls.php:344
782
+ #: intergeo/templates/iframe/controls.php:406
783
+ #: intergeo/templates/iframe/adsense.php:107
784
+ msgid "Bottom Center"
785
+ msgstr "Bottom Center"
786
+
787
+ #: intergeo/templates/iframe/controls.php:48
788
+ #: intergeo/templates/iframe/controls.php:122
789
+ #: intergeo/templates/iframe/controls.php:184
790
+ #: intergeo/templates/iframe/controls.php:246
791
+ #: intergeo/templates/iframe/controls.php:347
792
+ #: intergeo/templates/iframe/controls.php:409
793
+ #: intergeo/templates/iframe/adsense.php:110
794
+ msgid "Bottom Left"
795
+ msgstr "Bottom Left"
796
+
797
+ #: intergeo/templates/iframe/controls.php:51
798
+ #: intergeo/templates/iframe/controls.php:125
799
+ #: intergeo/templates/iframe/controls.php:187
800
+ #: intergeo/templates/iframe/controls.php:249
801
+ #: intergeo/templates/iframe/controls.php:350
802
+ #: intergeo/templates/iframe/controls.php:412
803
+ #: intergeo/templates/iframe/adsense.php:113
804
+ msgid "Left Bottom"
805
+ msgstr "Left Bottom"
806
+
807
+ #: intergeo/templates/iframe/controls.php:54
808
+ #: intergeo/templates/iframe/controls.php:128
809
+ #: intergeo/templates/iframe/controls.php:190
810
+ #: intergeo/templates/iframe/controls.php:252
811
+ #: intergeo/templates/iframe/controls.php:353
812
+ #: intergeo/templates/iframe/controls.php:415
813
+ #: intergeo/templates/iframe/adsense.php:116
814
+ msgid "Left Center"
815
+ msgstr "Left Center"
816
+
817
+ #: intergeo/templates/iframe/controls.php:57
818
+ #: intergeo/templates/iframe/controls.php:131
819
+ #: intergeo/templates/iframe/controls.php:193
820
+ #: intergeo/templates/iframe/controls.php:255
821
+ #: intergeo/templates/iframe/controls.php:356
822
+ #: intergeo/templates/iframe/controls.php:418
823
+ #: intergeo/templates/iframe/adsense.php:119
824
+ msgid "Left Top"
825
+ msgstr "Left Top"
826
+
827
+ #: intergeo/templates/iframe/controls.php:64
828
+ #: intergeo/templates/iframe/controls.php:262
829
+ msgid "default style"
830
+ msgstr "default style"
831
+
832
+ #: intergeo/templates/iframe/controls.php:67
833
+ msgid "small"
834
+ msgstr "small"
835
+
836
+ #: intergeo/templates/iframe/controls.php:70
837
+ msgid "large"
838
+ msgstr "large"
839
+
840
+ #: intergeo/templates/iframe/controls.php:79
841
+ msgid "Pan control"
842
+ msgstr "Pan control"
843
+
844
+ #: intergeo/templates/iframe/controls.php:90
845
+ msgid ""
846
+ "The Pan control displays buttons for panning the map. This control appears "
847
+ "by default in the top left corner of the map on non-touch devices. The Pan "
848
+ "control also allows you to rotate 45° imagery, if available."
849
+ msgstr ""
850
+ "The Pan control displays buttons for panning the map. This control appears "
851
+ "by default in the top left corner of the map on non-touch devices. The Pan "
852
+ "control also allows you to rotate 45° imagery, if available."
853
+
854
+ #: intergeo/templates/iframe/controls.php:141
855
+ msgid "Scale control"
856
+ msgstr "Scale control"
857
+
858
+ #: intergeo/templates/iframe/controls.php:152
859
+ msgid ""
860
+ "The Scale control displays a map scale element. This control is not enabled "
861
+ "by default."
862
+ msgstr ""
863
+ "The Scale control displays a map scale element. This control is not enabled "
864
+ "by default."
865
+
866
+ #: intergeo/templates/iframe/controls.php:203
867
+ msgid "MapType control"
868
+ msgstr "MapType control"
869
+
870
+ #: intergeo/templates/iframe/controls.php:214
871
+ msgid ""
872
+ "The MapType control lets the user toggle between map types (such as roadmap "
873
+ "and satellite). This control appears by default in the top right corner of "
874
+ "the map."
875
+ msgstr ""
876
+ "The MapType control lets the user toggle between map types (such as roadmap "
877
+ "and satellite). This control appears by default in the top right corner of "
878
+ "the map."
879
+
880
+ #: intergeo/templates/iframe/controls.php:265
881
+ msgid "dropdown menu"
882
+ msgstr "dropdown menu"
883
+
884
+ #: intergeo/templates/iframe/controls.php:268
885
+ msgid "horizontal bar"
886
+ msgstr "horizontal bar"
887
+
888
+ #: intergeo/templates/iframe/controls.php:275
889
+ msgid "Map types:"
890
+ msgstr "Map types:"
891
+
892
+ #: intergeo/templates/iframe/controls.php:278
893
+ msgid "This map type displays a normal street map."
894
+ msgstr "This map type displays a normal street map."
895
+
896
+ #: intergeo/templates/iframe/controls.php:284
897
+ msgid ""
898
+ "This map type displays maps with physical features such as terrain and "
899
+ "vegetation."
900
+ msgstr ""
901
+ "This map type displays maps with physical features such as terrain and "
902
+ "vegetation."
903
+
904
+ #: intergeo/templates/iframe/controls.php:290
905
+ msgid "This map type displays satellite images."
906
+ msgstr "This map type displays satellite images."
907
+
908
+ #: intergeo/templates/iframe/controls.php:296
909
+ msgid ""
910
+ "This map type displays a transparent layer of major streets on satellite "
911
+ "images."
912
+ msgstr ""
913
+ "This map type displays a transparent layer of major streets on satellite "
914
+ "images."
915
+
916
+ #: intergeo/templates/iframe/controls.php:304
917
+ msgid "Street View control"
918
+ msgstr "Street View control"
919
+
920
+ #: intergeo/templates/iframe/controls.php:315
921
+ msgid ""
922
+ "The Street View control contains a Pegman icon which can be dragged onto the "
923
+ "map to enable Street View. This control appears by default in the top left "
924
+ "corner of the map."
925
+ msgstr ""
926
+ "The Street View control contains a Pegman icon which can be dragged onto the "
927
+ "map to enable Street View. This control appears by default in the top left "
928
+ "corner of the map."
929
+
930
+ #: intergeo/templates/iframe/controls.php:366
931
+ msgid "Rotate control"
932
+ msgstr "Rotate control"
933
+
934
+ #: intergeo/templates/iframe/controls.php:377
935
+ msgid ""
936
+ "The Rotate control contains a small circular icon which allows you to rotate "
937
+ "maps containing oblique imagery. This control appears by default in the top "
938
+ "left corner of the map."
939
+ msgstr ""
940
+ "The Rotate control contains a small circular icon which allows you to rotate "
941
+ "maps containing oblique imagery. This control appears by default in the top "
942
+ "left corner of the map."
943
+
944
+ #: intergeo/templates/iframe/controls.php:428
945
+ msgid "Overview Map control"
946
+ msgstr "Overview Map control"
947
+
948
+ #: intergeo/templates/iframe/controls.php:439
949
+ msgid ""
950
+ "The Overview Map control displays a thumbnail overview map reflecting the "
951
+ "current map viewport within a wider area. This control appears by default in "
952
+ "the bottom right corner of the map, and is by default shown in its collapsed "
953
+ "state."
954
+ msgstr ""
955
+ "The Overview Map control displays a thumbnail overview map reflecting the "
956
+ "current map viewport within a wider area. This control appears by default in "
957
+ "the bottom right corner of the map, and is by default shown in its collapsed "
958
+ "state."
959
+
960
+ #: intergeo/templates/iframe/controls.php:445
961
+ msgid "Opened"
962
+ msgstr "Opened"
963
+
964
+ #: intergeo/templates/iframe/popups.php:5
965
+ msgid "Go To Address"
966
+ msgstr "Go To Address"
967
+
968
+ #: intergeo/templates/iframe/popups.php:10
969
+ msgid "Type an address you want to go to"
970
+ msgstr "Type an address you want to go to"
971
+
972
+ #: intergeo/templates/iframe/popups.php:13
973
+ msgid "Go"
974
+ msgstr "Go"
975
+
976
+ #: intergeo/templates/iframe/popups.php:24
977
+ msgid "Marker Options"
978
+ msgstr "Marker Options"
979
+
980
+ #: intergeo/templates/iframe/popups.php:31
981
+ #: intergeo/templates/iframe/popups.php:32
982
+ msgid "Enter title"
983
+ msgstr "Enter title"
984
+
985
+ #: intergeo/templates/iframe/popups.php:39
986
+ #: intergeo/templates/iframe/popups.php:40
987
+ msgid "Enter icon URL"
988
+ msgstr "Enter icon URL"
989
+
990
+ #: intergeo/templates/iframe/popups.php:47
991
+ #: intergeo/templates/iframe/popups.php:48
992
+ msgid "Enter html for info window"
993
+ msgstr "Enter html for info window"
994
+
995
+ #: intergeo/templates/iframe/popups.php:54
996
+ #: intergeo/templates/iframe/popups.php:89
997
+ #: intergeo/templates/iframe/popups.php:157
998
+ msgid "Update"
999
+ msgstr "Update"
1000
+
1001
+ #: intergeo/templates/iframe/popups.php:65
1002
+ msgid "Polyline Options"
1003
+ msgstr "Polyline Options"
1004
+
1005
+ #: intergeo/templates/iframe/popups.php:72
1006
+ #: intergeo/templates/iframe/popups.php:73
1007
+ #: intergeo/templates/iframe/popups.php:112
1008
+ #: intergeo/templates/iframe/popups.php:113
1009
+ msgid "Stroke weight in pixel"
1010
+ msgstr "Stroke weight in pixel"
1011
+
1012
+ #: intergeo/templates/iframe/popups.php:78
1013
+ #: intergeo/templates/iframe/popups.php:79
1014
+ #: intergeo/templates/iframe/popups.php:118
1015
+ #: intergeo/templates/iframe/popups.php:119
1016
+ msgid "Stroke opacity from 0.0 to 1.0"
1017
+ msgstr "Stroke opacity from 0.0 to 1.0"
1018
+
1019
+ #: intergeo/templates/iframe/popups.php:100
1020
+ msgid "Polygon Options"
1021
+ msgstr "Polygon Options"
1022
+
1023
+ #: intergeo/templates/iframe/popups.php:105
1024
+ msgid "Stroke options"
1025
+ msgstr "Stroke options"
1026
+
1027
+ #: intergeo/templates/iframe/popups.php:125
1028
+ msgid "stroke position"
1029
+ msgstr "stroke position"
1030
+
1031
+ #: intergeo/templates/iframe/popups.php:126
1032
+ msgid "center"
1033
+ msgstr "center"
1034
+
1035
+ #: intergeo/templates/iframe/popups.php:127
1036
+ msgid "inside the object"
1037
+ msgstr "inside the object"
1038
+
1039
+ #: intergeo/templates/iframe/popups.php:128
1040
+ msgid "outside the object"
1041
+ msgstr "outside the object"
1042
+
1043
+ #: intergeo/templates/iframe/popups.php:139
1044
+ msgid "Fill options"
1045
+ msgstr "Fill options"
1046
+
1047
+ #: intergeo/templates/iframe/popups.php:146
1048
+ #: intergeo/templates/iframe/popups.php:147
1049
+ msgid "Fill opacity from 0.0 to 1.0"
1050
+ msgstr "Fill opacity from 0.0 to 1.0"
1051
+
1052
+ #: intergeo/templates/iframe/popups.php:168
1053
+ msgid "Direction Options"
1054
+ msgstr "Direction Options"
1055
+
1056
+ #: intergeo/templates/iframe/popups.php:175
1057
+ #: intergeo/templates/iframe/popups.php:176
1058
+ msgid "The start location from which to calculate directions"
1059
+ msgstr "The start location from which to calculate directions"
1060
+
1061
+ #: intergeo/templates/iframe/popups.php:183
1062
+ #: intergeo/templates/iframe/popups.php:184
1063
+ msgid "The end location to which to calculate directions"
1064
+ msgstr "The end location to which to calculate directions"
1065
+
1066
+ #: intergeo/templates/iframe/popups.php:190
1067
+ #: intergeo/templates/iframe/directions.php:60
1068
+ msgid "via standard driving directions"
1069
+ msgstr "via standard driving directions"
1070
+
1071
+ #: intergeo/templates/iframe/popups.php:191
1072
+ #: intergeo/templates/iframe/directions.php:50
1073
+ msgid "via bicycle paths & preferred streets"
1074
+ msgstr "via bicycle paths & preferred streets"
1075
+
1076
+ #: intergeo/templates/iframe/popups.php:192
1077
+ #: intergeo/templates/iframe/directions.php:53
1078
+ msgid "via public transit routes"
1079
+ msgstr "via public transit routes"
1080
+
1081
+ #: intergeo/templates/iframe/popups.php:193
1082
+ #: intergeo/templates/iframe/directions.php:56
1083
+ msgid "via pedestrian paths & sidewalks"
1084
+ msgstr "via pedestrian paths & sidewalks"
1085
+
1086
+ #: intergeo/templates/iframe/popups.php:199
1087
+ msgid "Save"
1088
+ msgstr "Save"
1089
+
1090
+ #: intergeo/templates/iframe/adsense.php:1
1091
+ msgid "AdSense Integration"
1092
+ msgstr "AdSense Integration"
1093
+
1094
+ #: intergeo/templates/iframe/adsense.php:6
1095
+ #, php-format
1096
+ msgid ""
1097
+ "To make AdSense working on your maps, you have to setup your publisher ID. "
1098
+ "You can do it at the %ssettings page%s."
1099
+ msgstr ""
1100
+ "To make AdSense working on your maps, you have to setup your publisher ID. "
1101
+ "You can do it at the %ssettings page%s."
1102
+
1103
+ #: intergeo/templates/iframe/adsense.php:24
1104
+ msgid "default format"
1105
+ msgstr "default format"
1106
+
1107
+ #: intergeo/templates/iframe/adsense.php:27
1108
+ msgid "Leaderboard"
1109
+ msgstr "Leaderboard"
1110
+
1111
+ #: intergeo/templates/iframe/adsense.php:30
1112
+ msgid "Banner"
1113
+ msgstr "Banner"
1114
+
1115
+ #: intergeo/templates/iframe/adsense.php:33
1116
+ msgid "Half Banner"
1117
+ msgstr "Half Banner"
1118
+
1119
+ #: intergeo/templates/iframe/adsense.php:36
1120
+ msgid "Skyscraper"
1121
+ msgstr "Skyscraper"
1122
+
1123
+ #: intergeo/templates/iframe/adsense.php:39
1124
+ msgid "Wide Skyscraper"
1125
+ msgstr "Wide Skyscraper"
1126
+
1127
+ #: intergeo/templates/iframe/adsense.php:42
1128
+ msgid "Vertical Banner"
1129
+ msgstr "Vertical Banner"
1130
+
1131
+ #: intergeo/templates/iframe/adsense.php:45
1132
+ msgid "Button"
1133
+ msgstr "Button"
1134
+
1135
+ #: intergeo/templates/iframe/adsense.php:48
1136
+ msgid "Small Square"
1137
+ msgstr "Small Square"
1138
+
1139
+ #: intergeo/templates/iframe/adsense.php:51
1140
+ msgid "Square"
1141
+ msgstr "Square"
1142
+
1143
+ #: intergeo/templates/iframe/adsense.php:54
1144
+ msgid "Small Rectangle"
1145
+ msgstr "Small Rectangle"
1146
+
1147
+ #: intergeo/templates/iframe/adsense.php:57
1148
+ msgid "Medium Rectangle"
1149
+ msgstr "Medium Rectangle"
1150
+
1151
+ #: intergeo/templates/iframe/adsense.php:60
1152
+ msgid "Large Rectangle"
1153
+ msgstr "Large Rectangle"
1154
+
1155
+ #: intergeo/templates/iframe/adsense.php:63
1156
+ msgid "Small Vertical Link Unit"
1157
+ msgstr "Small Vertical Link Unit"
1158
+
1159
+ #: intergeo/templates/iframe/adsense.php:66
1160
+ msgid "Medium Vertical Link Unit"
1161
+ msgstr "Medium Vertical Link Unit"
1162
+
1163
+ #: intergeo/templates/iframe/adsense.php:69
1164
+ msgid "Large Vertical Link Unit"
1165
+ msgstr "Large Vertical Link Unit"
1166
+
1167
+ #: intergeo/templates/iframe/adsense.php:72
1168
+ msgid "Extra Large Vertical Link Unit"
1169
+ msgstr "Extra Large Vertical Link Unit"
1170
+
1171
+ #: intergeo/templates/iframe/adsense.php:75
1172
+ msgid "Small Horizontal Link Unit"
1173
+ msgstr "Small Horizontal Link Unit"
1174
+
1175
+ #: intergeo/templates/iframe/adsense.php:78
1176
+ msgid "Large Horizontal Link Unit"
1177
+ msgstr "Large Horizontal Link Unit"
1178
+
1179
+ #: intergeo/templates/iframe/adsense.php:131
1180
+ msgid "Background color"
1181
+ msgstr "Background color"
1182
+
1183
+ #: intergeo/templates/iframe/adsense.php:134
1184
+ #: intergeo/templates/iframe/adsense.php:140
1185
+ #: intergeo/templates/iframe/adsense.php:146
1186
+ #: intergeo/templates/iframe/adsense.php:152
1187
+ #: intergeo/templates/iframe/adsense.php:158
1188
+ msgid "Hex Value"
1189
+ msgstr "Hex Value"
1190
+
1191
+ #: intergeo/templates/iframe/adsense.php:137
1192
+ msgid "Border color"
1193
+ msgstr "Border color"
1194
+
1195
+ #: intergeo/templates/iframe/adsense.php:143
1196
+ msgid "Title color"
1197
+ msgstr "Title color"
1198
+
1199
+ #: intergeo/templates/iframe/adsense.php:149
1200
+ msgid "Text color"
1201
+ msgstr "Text color"
1202
+
1203
+ #: intergeo/templates/iframe/adsense.php:155
1204
+ msgid "URL color"
1205
+ msgstr "URL color"
1206
+
1207
+ #: intergeo/templates/iframe/directions.php:1
1208
+ msgid "Directions"
1209
+ msgstr "Directions"
1210
+
1211
+ #: intergeo/templates/iframe/directions.php:5
1212
+ msgid "To add a new direction just click the button below:"
1213
+ msgstr "To add a new direction just click the button below:"
1214
+
1215
+ #: intergeo/templates/iframe/directions.php:10
1216
+ msgid "Add Direction"
1217
+ msgstr "Add Direction"
1218
+
1219
+ #: intergeo/templates/iframe/directions.php:16
1220
+ #: intergeo/templates/iframe/directions.php:22
1221
+ #: intergeo/templates/iframe/directions.php:43
1222
+ msgid "from"
1223
+ msgstr "from"
1224
+
1225
+ #: intergeo/templates/iframe/directions.php:16
1226
+ #: intergeo/templates/iframe/directions.php:22
1227
+ #: intergeo/templates/iframe/directions.php:45
1228
+ msgid "to"
1229
+ msgstr "to"
1230
+
1231
+ #: intergeo/templates/iframe/directions.php:29
1232
+ #: intergeo/templates/iframe/directions.php:70
1233
+ msgid "Delete direction"
1234
+ msgstr "Delete direction"
1235
+
1236
+ #: intergeo/templates/iframe/directions.php:30
1237
+ #: intergeo/templates/iframe/directions.php:71
1238
+ msgid "Edit direction"
1239
+ msgstr "Edit direction"
1240
+
1241
+ #: intergeo/templates/iframe/directions.php:35
1242
+ msgid "Created directions"
1243
+ msgstr "Created directions"
1244
+
1245
+ msgid "AdSense Publisher Id"
1246
+ msgstr "AdSense Publisher Id"
1247
+
1248
+ msgid "Maps API Key"
1249
+ msgstr "Maps API Key"
1250
+
1251
+ msgid "To add a new direction just click the button below"
1252
+ msgstr "To add a new direction just click the button below"
1253
+
1254
+ msgid "Custom Layers are available in the PRO version"
1255
+ msgstr "Custom Layers are available in the PRO version"
1256
+
1257
+ msgid "Import Markers"
1258
+ msgstr "Import Markers"
1259
+
1260
+ msgid "Enabled ( Available in PRO )"
1261
+ msgstr "Enabled ( Available in PRO )"
1262
+
1263
+ msgid "Allows you to upload marker data to your map."
1264
+ msgstr "Allows you to upload marker data to your map."
readme.txt CHANGED
@@ -1,135 +1,159 @@
1
- === WordPress Google Maps Plugin ===
2
- Contributors: codeinwp,marius2012,marius_codeinwp,hardeepasrani,themeisle,Madalin_ThemeIsle
3
- Tags: directions, easy map, google, google map, google map plugin, google maps, latitude, location, longitude, map, map directions, map markers, map plugin, map widget, maps, marker, polygons, polylines, routes, store locator, streetview, wp google map, wp google maps, wp maps,plugin,admin,widget,shortcode,google maps, maps, map, map markers, google, google map, maps api, wp maps, wp google maps, easy map, embed, marker, placemark, icon, geocode, shortcode, custom post type, multisite, marker clustering
4
- Requires at least: 3.5
5
- Tested up to: 4.4.2
6
- Stable tag: trunk
7
- License: GPL v2.0 or later
8
- License URI: http://www.opensource.org/licenses/gpl-license.php
9
-
10
- A simple, easy and quite powerful Google Maps tool to create, manage and embed custom Google Maps into your WordPress posts and pages.
11
-
12
- == Description ==
13
-
14
- The Intergeo Google Maps WordPress plugin is a simple, easy and in the same time quite powerful tool for handling Google Maps in your website. This simple WordPress map plugin allow users to create new maps by using powerful UI builder. Created maps could be easily edited and saved with new settings. To increase the speed of creation process the plugin has ability to clone a map with all it's settings. Finally the plugin has attractive library which allows users to browse all maps in the system and delete unnecessary maps.
15
-
16
- The powerful UI builder allows users to:
17
-
18
- * Setup initial position and zooming level of a map;
19
- * Adjust controls settings and positioning;
20
- * Setup map color styles by using predefined color schemes or by using custom color settings;
21
- * Add overlays like markers, rectangles, circles, polylines and polygons;
22
- * Create directions routes from A address to B address;
23
- * Integrate AdSense service into your maps and earn money by displaying ads on maps.
24
-
25
- ### Create Google maps with shortcode ###
26
-
27
- To create new WordPress maps you just can input simple shortcode into your post, page, text widget or taxonomy description:
28
-
29
- `[intergeo]Your address[/intergeo]`
30
-
31
- This shortcode will be displayed as Google Maps centered at specific address. The shortcode could be extended with custom attributes like height, width, zoom, etc. These attributes will setup special settings for a map.
32
-
33
- > **Time-saving features available in the Pro version:**
34
- >
35
- > * Custom layers for maps
36
- > * Import markers in bulk
37
- > * Priority email support from the developer of the plugin
38
- > * Support and updates for 1 year
39
- >
40
- > **[Learn more about Intergeo Maps Pro](http://themeisle.com/plugins/intergeo-maps-pro/)**
41
-
42
- The following table describes all possible attributes, which users can use with shortcodes:
43
-
44
- **Width**
45
- Sets width of the map container. Accepts all valid CSS values as css width property accepts. For example, the value could be set in pixels like 500px, or in percentage like 75%. Default value is 100%.
46
-
47
- **Height**
48
- Sets width of the map container. Accepts all valid CSS values as css height property accepts. For example, the value could be set in pixels like 700px. Default value is 300px.
49
-
50
- **Style**
51
- This attribute allows users to set extra styles for Google map's container element. It accepts all valid css properties and will echo it in the style attribute of the container element. Default value is empty.
52
-
53
- **Zoom**
54
- Sets the initial zoom level of the map. This attribute accepts integer value from 0 to 19, where 0 is the biggest distance and 19 is the lowest distance to the ground. The default value is 5.
55
-
56
- **Hook**
57
- This attribute allows users to setup their own filter, which will be used to filter settings of a map before using it to render a map. Hooks for the filter will receive one parameter which will be array of options and they have to return it modified or not.
58
-
59
- So your shortcode could looks like this one:
60
-
61
- `[intergeo zoom=”12” width=”50%” heigth=”400px” style=”border: 3px solid red; margin: 0 auto;”]Central Park, NY[/intergeo]`
62
-
63
- Check-out the <a href="http://themeisle.com/plugins/intergeo-maps-lite/" rel="frield">#1 free Google Maps plugin</a>
64
-
65
- ### Create map with UI builder ###
66
-
67
- Another way to create map is to use UI builder. This is more recommended way to build a Google map as this way provides much more features and wide range of settings to customize. To create a map with UI builder, pass following steps:
68
-
69
- 1. Create a new post or a page, or just edit existing one;
70
- 1. Place the mouse cursor into the content editor, at the place you want to embed a map and click on **Add Media** button above editor toolbar;
71
- 1. When media popup appears, find **Intergeo Maps** link in the left sidebar of popup window, click on the link;
72
- 1. Now you have to see Intergeo UI builder which allows you to customize your map;
73
- 1. Use all tools from right sidebar of the builder to create a map you need;
74
- 1. After finishing maps configuration click on **Insert into post** button at the footer of the builder;
75
- 1. After doing it a map has to be saved in background, popup has to be closed and new appropriate shortcode has to be inserted into the place, where your cursor was.
76
-
77
- ### Using maps library ###
78
-
79
- All maps which have been created with UI builder are stored in WordPress database. The plugin allows to browse and manage these Google maps in the maps library. To see it go to the **Media** » **Intergeo Maps** page to see all maps which have been created in your website.
80
-
81
- The library shows you maps preview as you will see it at front end pages. Here users can copy shortcode of a Google map, edit or clone maps, and delete unnecessary or deprecated maps.
82
-
83
- Also users can create a Google map from library page. To do it just click on **Add New** button next to the page title and UI builder popup immediately appears. The builder interacts in the same way as it does at edit posts page, except that popup doesn't insert shortcode into somewhere, popup just save a map into database for future reuse.
84
-
85
- Check-out the <a href="http://www.codeinwp.com/blog/intergeo-maps-plugin-review/" target="_blank" rel="friend">Intergeo review</a> and find out some of the <a href="http://www.codeinwp.com/blog/top-non-obvious-wordpress-plugins/" target="_blank" rel="friend">best WordPress plugins</a>.
86
-
87
- == Installation ==
88
-
89
- 1. Upload the files to the `/wp-content/plugins/intergeo/` directory.
90
- 1. Activate the plugin through the 'Plugins' menu in WordPress.
91
-
92
-
93
- == Frequently Asked Questions ==
94
-
95
- = How to override Google map settings =
96
-
97
- To override Google map settings you can use your own hook. Just add **hook** attribute to your shortcode like this:
98
-
99
- `[intergeo hook="my_custom_intergeo_hook" ...]...[/intergeo]`
100
-
101
- And add a function to hook that filter:
102
-
103
- `add_filter( 'my_custom_intergeo_hook', 'filter_intergeo_map_settings' ) {
104
- function filter_intergeo_map_settings( $options ) {
105
- // update options
106
- $options[...] = ...;
107
- ...
108
-
109
- // return updated options
110
- return $options;
111
- }`
112
-
113
- == Screenshots ==
114
-
115
- 1. Directions Google Maps layer
116
- 2. Wather and cloud Google Maps layers
117
- 3. Panaramio layer and styles settings
118
- 4. Bicycling layer and gray styles
119
- 5. Overlay settings
120
- 6. Markers settings
121
-
122
- == Changelog ==
123
-
124
- = 1.0.3 =
125
-
126
- * Fixed issue with warning error when including some templates
127
-
128
- = 1.0.2 =
129
-
130
- * Fixed minZoom and maxZoom settings.
131
-
132
- = 1.0.1 =
133
-
134
- * Fixed compatibility with Wordpress 4.3 versions
135
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === WordPress Google Maps Plugin ===
2
+ Contributors: codeinwp,marius2012,marius_codeinwp,hardeepasrani,themeisle,Madalin_ThemeIsle
3
+ Tags: directions, easy map, google, google map, google map plugin, google maps, latitude, location, longitude, map, map directions, map markers, map plugin, map widget, maps, marker, polygons, polylines, routes, store locator, streetview, wp google map, wp google maps, wp maps,plugin,admin,widget,shortcode,google maps, maps, map, map markers, google, google map, maps api, wp maps, wp google maps, easy map, embed, marker, placemark, icon, geocode, shortcode, custom post type, multisite, marker clustering
4
+ Requires at least: 3.5
5
+ Tested up to: 4.5.2
6
+ Stable tag: trunk
7
+ License: GPL v2.0 or later
8
+ License URI: http://www.opensource.org/licenses/gpl-license.php
9
+
10
+ A simple, easy and quite powerful Google Maps tool to create, manage and embed custom Google Maps into your WordPress posts and pages.
11
+
12
+ == Description ==
13
+
14
+ The Intergeo Google Maps WordPress plugin is a simple, easy and in the same time quite powerful tool for handling Google Maps in your website. This simple WordPress map plugin allow users to create new maps by using powerful UI builder. Created maps could be easily edited and saved with new settings. To increase the speed of creation process the plugin has ability to clone a map with all it's settings. Finally the plugin has attractive library which allows users to browse all maps in the system and delete unnecessary maps.
15
+ We've also built some fantastic <a href="http://themeisle.com/wordpress-themes/business/" rel="friend" target="_blank">business themes</a> that integrate with Intergeo Google Maps perfectly, check them out.
16
+
17
+ The powerful UI builder allows users to:
18
+
19
+ * Setup initial position and zooming level of a map;
20
+ * Adjust controls settings and positioning;
21
+ * Setup map color styles by using predefined color schemes or by using custom color settings;
22
+ * Add overlays like markers, rectangles, circles, polylines and polygons;
23
+ * Create directions routes from A address to B address;
24
+ * Integrate AdSense service into your maps and earn money by displaying ads on maps.
25
+
26
+ ### Create Google maps with shortcode ###
27
+
28
+ To create new WordPress maps you just can input simple shortcode into your post, page, text widget or taxonomy description:
29
+
30
+ `[intergeo]Your address[/intergeo]`
31
+
32
+ This shortcode will be displayed as Google Maps centered at specific address. The shortcode could be extended with custom attributes like height, width, zoom, etc. These attributes will setup special settings for a map.
33
+
34
+ > **Time-saving features available in the Pro version:**
35
+ >
36
+ > * Custom layers for maps
37
+ > * Import markers in bulk
38
+ > * Priority email support from the developer of the plugin
39
+ > * Support and updates for 1 year
40
+ >
41
+ > **[Learn more about Intergeo Maps Pro](http://themeisle.com/plugins/intergeo-maps-pro/)**
42
+
43
+ The following table describes all possible attributes, which users can use with shortcodes:
44
+
45
+ **Width**
46
+ Sets width of the map container. Accepts all valid CSS values as css width property accepts. For example, the value could be set in pixels like 500px, or in percentage like 75%. Default value is 100%.
47
+
48
+ **Height**
49
+ Sets width of the map container. Accepts all valid CSS values as css height property accepts. For example, the value could be set in pixels like 700px. Default value is 300px.
50
+
51
+ **Style**
52
+ This attribute allows users to set extra styles for Google map's container element. It accepts all valid css properties and will echo it in the style attribute of the container element. Default value is empty.
53
+
54
+ **Zoom**
55
+ Sets the initial zoom level of the map. This attribute accepts integer value from 0 to 19, where 0 is the biggest distance and 19 is the lowest distance to the ground. The default value is 5.
56
+
57
+ **Hook**
58
+ This attribute allows users to setup their own filter, which will be used to filter settings of a map before using it to render a map. Hooks for the filter will receive one parameter which will be array of options and they have to return it modified or not.
59
+
60
+ So your shortcode could looks like this one:
61
+
62
+ `[intergeo zoom=”12” width=”50%” heigth=”400px” style=”border: 3px solid red; margin: 0 auto;”]Central Park, NY[/intergeo]`
63
+
64
+ Check-out the <a href="http://themeisle.com/plugins/intergeo-maps-lite/" rel="frield">#1 free Google Maps plugin</a>
65
+
66
+ ### Create map with UI builder ###
67
+
68
+ Another way to create map is to use UI builder. This is more recommended way to build a Google map as this way provides much more features and wide range of settings to customize. To create a map with UI builder, pass following steps:
69
+
70
+ 1. Create a new post or a page, or just edit existing one;
71
+ 1. Place the mouse cursor into the content editor, at the place you want to embed a map and click on **Add Media** button above editor toolbar;
72
+ 1. When media popup appears, find **Intergeo Maps** link in the left sidebar of popup window, click on the link;
73
+ 1. Now you have to see Intergeo UI builder which allows you to customize your map;
74
+ 1. Use all tools from right sidebar of the builder to create a map you need;
75
+ 1. After finishing maps configuration click on **Insert into post** button at the footer of the builder;
76
+ 1. After doing it a map has to be saved in background, popup has to be closed and new appropriate shortcode has to be inserted into the place, where your cursor was.
77
+
78
+ ### Using maps library ###
79
+
80
+ All maps which have been created with UI builder are stored in WordPress database. The plugin allows to browse and manage these Google maps in the maps library. To see it go to the **Media** » **Intergeo Maps** page to see all maps which have been created in your website.
81
+
82
+ The library shows you maps preview as you will see it at front end pages. Here users can copy shortcode of a Google map, edit or clone maps, and delete unnecessary or deprecated maps.
83
+
84
+ Also users can create a Google map from library page. To do it just click on **Add New** button next to the page title and UI builder popup immediately appears. The builder interacts in the same way as it does at edit posts page, except that popup doesn't insert shortcode into somewhere, popup just save a map into database for future reuse.
85
+
86
+ **About us:**
87
+
88
+ We are a young team of WordPress enthusiasts who enjoy developing <a href="http://themeisle.com/wordpress-plugins/" rel="friend" target="_blank">free WordPress plugins</a> and <a href="http://themeisle.com/wordpress-themes/" rel="friend" target="_blank">themes</a> for small businesses and startups. Check them out and let us know what you think, our goal is to build fully fledged products that will solve your needs.
89
+
90
+ We also love to blog at CodeinWP and help our users finding the <a href="http://www.codeinwp.com/blog/best-wordpress-shared-hosting-providers/" rel="friend">best hosting</a> or <a href="http://justfreethemes.com/" rel="friend">themes</a>.
91
+
92
+ **More from us**
93
+
94
+ - <a href="http://justfreethemes.com/" rel="friend" target="_blank">JustFreeThemes</a> - Find the best free WordPress Themes
95
+ - <a href="http://www.codeinwp.com/" rel="friend" target="_blank">CodeinWP</a> - Turn your PSD file into a WordPress Theme
96
+ - <a href="http://revive.social/" rel="friend" target="_blank">Revive.Social</a> - WordPress plugins for Social Media marketers
97
+
98
+ Check-out the <a href="http://www.codeinwp.com/blog/intergeo-maps-plugin-review/" target="_blank" rel="friend">Intergeo review</a> and find out some of the <a href="http://www.codeinwp.com/blog/top-non-obvious-wordpress-plugins/" target="_blank" rel="friend">best WordPress plugins</a>.
99
+
100
+ == Installation ==
101
+
102
+ 1. Upload the files to the `/wp-content/plugins/intergeo/` directory.
103
+ 1. Activate the plugin through the 'Plugins' menu in WordPress.
104
+
105
+
106
+ == Frequently Asked Questions ==
107
+
108
+ = How to override Google map settings =
109
+
110
+ To override Google map settings you can use your own hook. Just add **hook** attribute to your shortcode like this:
111
+
112
+ `[intergeo hook="my_custom_intergeo_hook" ...]...[/intergeo]`
113
+
114
+ And add a function to hook that filter:
115
+
116
+ `add_filter( 'my_custom_intergeo_hook', 'filter_intergeo_map_settings' ) {
117
+ function filter_intergeo_map_settings( $options ) {
118
+ // update options
119
+ $options[...] = ...;
120
+ ...
121
+
122
+ // return updated options
123
+ return $options;
124
+ }`
125
+
126
+ == Screenshots ==
127
+
128
+ 1. Directions Google Maps layer
129
+ 2. Wather and cloud Google Maps layers
130
+ 3. Panaramio layer and styles settings
131
+ 4. Bicycling layer and gray styles
132
+ 5. Overlay settings
133
+ 6. Markers settings
134
+
135
+ == Changelog ==
136
+
137
+ = 1.0.5 =
138
+
139
+ * Added information for map new installs
140
+ * Fix issue for non-admins in freemius
141
+
142
+
143
+ = 1.0.4 =
144
+
145
+ * Added uninstall feedback
146
+ * Added support for pro version
147
+
148
+ = 1.0.3 =
149
+
150
+ * Fixed issue with warning error when including some templates
151
+
152
+ = 1.0.2 =
153
+
154
+ * Fixed minZoom and maxZoom settings.
155
+
156
+ = 1.0.1 =
157
+
158
+ * Fixed compatibility with Wordpress 4.3 versions
159
+
templates/iframe/adsense.php CHANGED
@@ -1,162 +1,162 @@
1
- <h3 class="intergeo_tlbr_ul_li_h3"><?php esc_html_e( 'AdSense Integration', INTERGEO_PLUGIN_NAME ) ?></h3>
2
- <ul class="intergeo_tlbr_ul_li_ul"><?php
3
- if ( empty( $publisher_id ) ) :
4
- ?><li class="intergeo_tlbr_ul_li_ul_li">
5
- <p class="intergeo_tlbr_grp_dsc"><?php
6
- printf( esc_html__( 'To make AdSense working on your maps, you have to setup your publisher ID. You can do it at the %ssettings page%s.', INTERGEO_PLUGIN_NAME ), '<a href="' . admin_url( 'options-media.php' ) . '" target="_blank">', '</a>' )
7
- ?></p>
8
- </li><?php
9
- endif;
10
- ?><li class="intergeo_tlbr_ul_li_ul_li">
11
- <div class="intergeo_tlbr_cntrl_items" style="display:block">
12
- <div class="intergeo_tlbr_cntrl_item">
13
- <label>
14
- <input type="hidden" name="layer_adsense" value="0">
15
- <input type="checkbox" name="layer_adsense" value="1" <?php checked( isset( $json['layer']['adsense'] ) ? $json['layer']['adsense'] == '1' : false ) ?>>
16
- Enabled
17
- </label>
18
- </div>
19
- <table class="intergeo_tlbr_cntrl_tbl" cellpadding="0" cellspacing="0" border="0">
20
- <tr>
21
- <td class="intergeo_tlbr_cntrl_tbl_clmn">
22
- <select name="adsense_format" class="intergeo_tlbr_cntrl_slct">
23
- <option value="">
24
- <?php esc_html_e( 'default format', INTERGEO_PLUGIN_NAME ) ?>
25
- </option>
26
- <option value="LEADERBOARD" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LEADERBOARD' : false ) ?>>
27
- <?php esc_html_e( 'Leaderboard', INTERGEO_PLUGIN_NAME ) ?>
28
- </option>
29
- <option value="BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'BANNER' : false ) ?>>
30
- <?php esc_html_e( 'Banner', INTERGEO_PLUGIN_NAME ) ?>
31
- </option>
32
- <option value="HALF_BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'HALF_BANNER' : false ) ?>>
33
- <?php esc_html_e( 'Half Banner', INTERGEO_PLUGIN_NAME ) ?>
34
- </option>
35
- <option value="SKYSCRAPER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SKYSCRAPER' : false ) ?>>
36
- <?php esc_html_e( 'Skyscraper', INTERGEO_PLUGIN_NAME ) ?>
37
- </option>
38
- <option value="WIDE_SKYSCRAPER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'WIDE_SKYSCRAPER' : false ) ?>>
39
- <?php esc_html_e( 'Wide Skyscraper', INTERGEO_PLUGIN_NAME ) ?>
40
- </option>
41
- <option value="VERTICAL_BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'VERTICAL_BANNER' : false ) ?>>
42
- <?php esc_html_e( 'Vertical Banner', INTERGEO_PLUGIN_NAME ) ?>
43
- </option>
44
- <option value="BUTTON" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'BUTTON' : false ) ?>>
45
- <?php esc_html_e( 'Button', INTERGEO_PLUGIN_NAME ) ?>
46
- </option>
47
- <option value="SMALL_SQUARE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_SQUARE' : false ) ?>>
48
- <?php esc_html_e( 'Small Square', INTERGEO_PLUGIN_NAME ) ?>
49
- </option>
50
- <option value="SQUARE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SQUARE' : false ) ?>>
51
- <?php esc_html_e( 'Square', INTERGEO_PLUGIN_NAME ) ?>
52
- </option>
53
- <option value="SMALL_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_RECTANGLE' : false ) ?>>
54
- <?php esc_html_e( 'Small Rectangle', INTERGEO_PLUGIN_NAME ) ?>
55
- </option>
56
- <option value="MEDIUM_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'MEDIUM_RECTANGLE' : false ) ?>>
57
- <?php esc_html_e( 'Medium Rectangle', INTERGEO_PLUGIN_NAME ) ?>
58
- </option>
59
- <option value="LARGE_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_RECTANGLE' : false ) ?>>
60
- <?php esc_html_e( 'Large Rectangle', INTERGEO_PLUGIN_NAME ) ?>
61
- </option>
62
- <option value="SMALL_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_VERTICAL_LINK_UNIT' : false ) ?>>
63
- <?php esc_html_e( 'Small Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
64
- </option>
65
- <option value="MEDIUM_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'MEDIUM_VERTICAL_LINK_UNIT' : false ) ?>>
66
- <?php esc_html_e( 'Medium Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
67
- </option>
68
- <option value="LARGE_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_VERTICAL_LINK_UNIT' : false ) ?>>
69
- <?php esc_html_e( 'Large Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
70
- </option>
71
- <option value="X_LARGE_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'X_LARGE_VERTICAL_LINK_UNIT' : false ) ?>>
72
- <?php esc_html_e( 'Extra Large Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
73
- </option>
74
- <option value="SMALL_HORIZONTAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_HORIZONTAL_LINK_UNIT' : false ) ?>>
75
- <?php esc_html_e( 'Small Horizontal Link Unit', INTERGEO_PLUGIN_NAME ) ?>
76
- </option>
77
- <option value="LARGE_HORIZONTAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_HORIZONTAL_LINK_UNIT' : false ) ?>>
78
- <?php esc_html_e( 'Large Horizontal Link Unit', INTERGEO_PLUGIN_NAME ) ?>
79
- </option>
80
- </select>
81
- </td>
82
- <td class="intergeo_tlbr_cntrl_tbl_clmn">
83
- <select class="intergeo_tlbr_cntrl_slct" name="adsense_position">
84
- <option value=""><?php esc_html_e( 'default position', INTERGEO_PLUGIN_NAME ) ?></option>
85
- <option value="TOP_LEFT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_LEFT' : false ) ?>>
86
- <?php esc_html_e( 'Top Left', INTERGEO_PLUGIN_NAME ) ?>
87
- </option>
88
- <option value="TOP_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_CENTER' : false ) ?>>
89
- <?php esc_html_e( 'Top Center', INTERGEO_PLUGIN_NAME ) ?>
90
- </option>
91
- <option value="TOP_RIGHT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_RIGHT' : false ) ?>>
92
- <?php esc_html_e( 'Top Right', INTERGEO_PLUGIN_NAME ) ?>
93
- </option>
94
- <option value="RIGHT_TOP" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_TOP' : false ) ?>>
95
- <?php esc_html_e( 'Right Top', INTERGEO_PLUGIN_NAME ) ?>
96
- </option>
97
- <option value="RIGHT_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_CENTER' : false ) ?>>
98
- <?php esc_html_e( 'Right Center', INTERGEO_PLUGIN_NAME ) ?>
99
- </option>
100
- <option value="RIGHT_BOTTOM" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_BOTTOM' : false ) ?>>
101
- <?php esc_html_e( 'Right Bottom', INTERGEO_PLUGIN_NAME ) ?>
102
- </option>
103
- <option value="BOTTOM_RIGHT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_RIGHT' : false ) ?>>
104
- <?php esc_html_e( 'Bottom Right', INTERGEO_PLUGIN_NAME ) ?>
105
- </option>
106
- <option value="BOTTOM_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_CENTER' : false ) ?>>
107
- <?php esc_html_e( 'Bottom Center', INTERGEO_PLUGIN_NAME ) ?>
108
- </option>
109
- <option value="BOTTOM_LEFT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_LEFT' : false ) ?>>
110
- <?php esc_html_e( 'Bottom Left', INTERGEO_PLUGIN_NAME ) ?>
111
- </option>
112
- <option value="LEFT_BOTTOM" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_BOTTOM' : false ) ?>>
113
- <?php esc_html_e( 'Left Bottom', INTERGEO_PLUGIN_NAME ) ?>
114
- </option>
115
- <option value="LEFT_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_CENTER' : false ) ?>>
116
- <?php esc_html_e( 'Left Center', INTERGEO_PLUGIN_NAME ) ?>
117
- </option>
118
- <option value="LEFT_TOP" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_TOP' : false ) ?>>
119
- <?php esc_html_e( 'Left Top', INTERGEO_PLUGIN_NAME ) ?>
120
- </option>
121
- </select>
122
- </td>
123
- </tr>
124
- </table>
125
- </div>
126
- </li>
127
- <li class="intergeo_tlbr_ul_li_ul_li">
128
- <span class="intergeo_tlbr_cntrl_ttl"><?php esc_html_e( 'Styles', INTERGEO_PLUGIN_NAME ) ?></span>
129
- <div class="intergeo_tlbr_cntrl_items">
130
- <div class="intergeo_tlbr_cntrl_item">
131
- <b><?php esc_html_e( 'Background color', INTERGEO_PLUGIN_NAME ) ?></b>
132
- </div>
133
- <div class="intergeo_tlbr_cntrl_item">
134
- <input class="color-picker-hex" type="text" name="adsense_backgroundColor" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ) ?>" value="<?php echo isset( $json['adsense']['backgroundColor'] ) ? esc_attr( $json['adsense']['backgroundColor'] ) : '#c4d4f3' ?>" data-default-color="#c4d4f3">
135
- </div>
136
- <div class="intergeo_tlbr_cntrl_item">
137
- <b><?php esc_html_e( 'Border color', INTERGEO_PLUGIN_NAME ) ?></b>
138
- </div>
139
- <div class="intergeo_tlbr_cntrl_item">
140
- <input class="color-picker-hex" type="text" name="adsense_borderColor" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ) ?>" value="<?php echo isset( $json['adsense']['borderColor'] ) ? esc_attr( $json['adsense']['borderColor'] ) : '#e5ecf9' ?>" data-default-color="#e5ecf9">
141
- </div>
142
- <div class="intergeo_tlbr_cntrl_item">
143
- <b><?php esc_html_e( 'Title color', INTERGEO_PLUGIN_NAME ) ?></b>
144
- </div>
145
- <div class="intergeo_tlbr_cntrl_item">
146
- <input class="color-picker-hex" type="text" name="adsense_titleColor" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ) ?>" value="<?php echo isset( $json['adsense']['titleColor'] ) ? esc_attr( $json['adsense']['titleColor'] ) : '#0000cc' ?>" data-default-color="#0000cc">
147
- </div>
148
- <div class="intergeo_tlbr_cntrl_item">
149
- <b><?php esc_html_e( 'Text color', INTERGEO_PLUGIN_NAME ) ?></b>
150
- </div>
151
- <div class="intergeo_tlbr_cntrl_item">
152
- <input class="color-picker-hex" type="text" name="adsense_textColor" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ) ?>" value="<?php echo isset( $json['adsense']['textColor'] ) ? esc_attr( $json['adsense']['textColor'] ) : '#000000' ?>" data-default-color="#000000">
153
- </div>
154
- <div class="intergeo_tlbr_cntrl_item">
155
- <b><?php esc_html_e( 'URL color', INTERGEO_PLUGIN_NAME ) ?></b>
156
- </div>
157
- <div class="intergeo_tlbr_cntrl_item">
158
- <input class="color-picker-hex" type="text" name="adsense_urlColor" maxlength="7" placeholder="<?php esc_attr_e( 'Hex Value' ) ?>" value="<?php echo isset( $json['adsense']['urlColor'] ) ? esc_attr( $json['adsense']['urlColor'] ) : '#009900' ?>" data-default-color="#009900">
159
- </div>
160
- </div>
161
- </li>
1
+ <h3 class="intergeo_tlbr_ul_li_h3"><?php esc_html_e( 'AdSense Integration', INTERGEO_PLUGIN_NAME ) ?></h3>
2
+ <ul class="intergeo_tlbr_ul_li_ul"><?php
3
+ if ( empty( $publisher_id ) ) :
4
+ ?><li class="intergeo_tlbr_ul_li_ul_li">
5
+ <p class="intergeo_tlbr_grp_dsc"><?php
6
+ printf( esc_html__( 'To make AdSense working on your maps, you have to setup your publisher ID. You can do it at the %ssettings page%s.', INTERGEO_PLUGIN_NAME ), '<a href="' . admin_url( 'options-media.php' ) . '" target="_blank">', '</a>' )
7
+ ?></p>
8
+ </li><?php
9
+ endif;
10
+ ?><li class="intergeo_tlbr_ul_li_ul_li">
11
+ <div class="intergeo_tlbr_cntrl_items" style="display:block">
12
+ <div class="intergeo_tlbr_cntrl_item">
13
+ <label>
14
+ <input type="hidden" name="layer_adsense" value="0">
15
+ <input type="checkbox" name="layer_adsense" value="1" <?php checked( isset( $json['layer']['adsense'] ) ? $json['layer']['adsense'] == '1' : false ) ?>>
16
+ Enabled
17
+ </label>
18
+ </div>
19
+ <table class="intergeo_tlbr_cntrl_tbl" cellpadding="0" cellspacing="0" border="0">
20
+ <tr>
21
+ <td class="intergeo_tlbr_cntrl_tbl_clmn">
22
+ <select name="adsense_format" class="intergeo_tlbr_cntrl_slct">
23
+ <option value="">
24
+ <?php esc_html_e( 'default format', INTERGEO_PLUGIN_NAME ) ?>
25
+ </option>
26
+ <option value="LEADERBOARD" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LEADERBOARD' : false ) ?>>
27
+ <?php esc_html_e( 'Leaderboard', INTERGEO_PLUGIN_NAME ) ?>
28
+ </option>
29
+ <option value="BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'BANNER' : false ) ?>>
30
+ <?php esc_html_e( 'Banner', INTERGEO_PLUGIN_NAME ) ?>
31
+ </option>
32
+ <option value="HALF_BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'HALF_BANNER' : false ) ?>>
33
+ <?php esc_html_e( 'Half Banner', INTERGEO_PLUGIN_NAME ) ?>
34
+ </option>
35
+ <option value="SKYSCRAPER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SKYSCRAPER' : false ) ?>>
36
+ <?php esc_html_e( 'Skyscraper', INTERGEO_PLUGIN_NAME ) ?>
37
+ </option>
38
+ <option value="WIDE_SKYSCRAPER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'WIDE_SKYSCRAPER' : false ) ?>>
39
+ <?php esc_html_e( 'Wide Skyscraper', INTERGEO_PLUGIN_NAME ) ?>
40
+ </option>
41
+ <option value="VERTICAL_BANNER" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'VERTICAL_BANNER' : false ) ?>>
42
+ <?php esc_html_e( 'Vertical Banner', INTERGEO_PLUGIN_NAME ) ?>
43
+ </option>
44
+ <option value="BUTTON" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'BUTTON' : false ) ?>>
45
+ <?php esc_html_e( 'Button', INTERGEO_PLUGIN_NAME ) ?>
46
+ </option>
47
+ <option value="SMALL_SQUARE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_SQUARE' : false ) ?>>
48
+ <?php esc_html_e( 'Small Square', INTERGEO_PLUGIN_NAME ) ?>
49
+ </option>
50
+ <option value="SQUARE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SQUARE' : false ) ?>>
51
+ <?php esc_html_e( 'Square', INTERGEO_PLUGIN_NAME ) ?>
52
+ </option>
53
+ <option value="SMALL_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_RECTANGLE' : false ) ?>>
54
+ <?php esc_html_e( 'Small Rectangle', INTERGEO_PLUGIN_NAME ) ?>
55
+ </option>
56
+ <option value="MEDIUM_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'MEDIUM_RECTANGLE' : false ) ?>>
57
+ <?php esc_html_e( 'Medium Rectangle', INTERGEO_PLUGIN_NAME ) ?>
58
+ </option>
59
+ <option value="LARGE_RECTANGLE" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_RECTANGLE' : false ) ?>>
60
+ <?php esc_html_e( 'Large Rectangle', INTERGEO_PLUGIN_NAME ) ?>
61
+ </option>
62
+ <option value="SMALL_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_VERTICAL_LINK_UNIT' : false ) ?>>
63
+ <?php esc_html_e( 'Small Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
64
+ </option>
65
+ <option value="MEDIUM_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'MEDIUM_VERTICAL_LINK_UNIT' : false ) ?>>
66
+ <?php esc_html_e( 'Medium Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
67
+ </option>
68
+ <option value="LARGE_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_VERTICAL_LINK_UNIT' : false ) ?>>
69
+ <?php esc_html_e( 'Large Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
70
+ </option>
71
+ <option value="X_LARGE_VERTICAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'X_LARGE_VERTICAL_LINK_UNIT' : false ) ?>>
72
+ <?php esc_html_e( 'Extra Large Vertical Link Unit', INTERGEO_PLUGIN_NAME ) ?>
73
+ </option>
74
+ <option value="SMALL_HORIZONTAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'SMALL_HORIZONTAL_LINK_UNIT' : false ) ?>>
75
+ <?php esc_html_e( 'Small Horizontal Link Unit', INTERGEO_PLUGIN_NAME ) ?>
76
+ </option>
77
+ <option value="LARGE_HORIZONTAL_LINK_UNIT" <?php selected( isset( $json['adsense']['format'] ) ? $json['adsense']['format'] == 'LARGE_HORIZONTAL_LINK_UNIT' : false ) ?>>
78
+ <?php esc_html_e( 'Large Horizontal Link Unit', INTERGEO_PLUGIN_NAME ) ?>
79
+ </option>
80
+ </select>
81
+ </td>
82
+ <td class="intergeo_tlbr_cntrl_tbl_clmn">
83
+ <select class="intergeo_tlbr_cntrl_slct" name="adsense_position">
84
+ <option value=""><?php esc_html_e( 'default position', INTERGEO_PLUGIN_NAME ) ?></option>
85
+ <option value="TOP_LEFT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_LEFT' : false ) ?>>
86
+ <?php esc_html_e( 'Top Left', INTERGEO_PLUGIN_NAME ) ?>
87
+ </option>
88
+ <option value="TOP_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_CENTER' : false ) ?>>
89
+ <?php esc_html_e( 'Top Center', INTERGEO_PLUGIN_NAME ) ?>
90
+ </option>
91
+ <option value="TOP_RIGHT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'TOP_RIGHT' : false ) ?>>
92
+ <?php esc_html_e( 'Top Right', INTERGEO_PLUGIN_NAME ) ?>
93
+ </option>
94
+ <option value="RIGHT_TOP" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_TOP' : false ) ?>>
95
+ <?php esc_html_e( 'Right Top', INTERGEO_PLUGIN_NAME ) ?>
96
+ </option>
97
+ <option value="RIGHT_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_CENTER' : false ) ?>>
98
+ <?php esc_html_e( 'Right Center', INTERGEO_PLUGIN_NAME ) ?>
99
+ </option>
100
+ <option value="RIGHT_BOTTOM" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'RIGHT_BOTTOM' : false ) ?>>
101
+ <?php esc_html_e( 'Right Bottom', INTERGEO_PLUGIN_NAME ) ?>
102
+ </option>
103
+ <option value="BOTTOM_RIGHT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_RIGHT' : false ) ?>>
104
+ <?php esc_html_e( 'Bottom Right', INTERGEO_PLUGIN_NAME ) ?>
105
+ </option>
106
+ <option value="BOTTOM_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_CENTER' : false ) ?>>
107
+ <?php esc_html_e( 'Bottom Center', INTERGEO_PLUGIN_NAME ) ?>
108
+ </option>
109
+ <option value="BOTTOM_LEFT" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'BOTTOM_LEFT' : false ) ?>>
110
+ <?php esc_html_e( 'Bottom Left', INTERGEO_PLUGIN_NAME ) ?>
111
+ </option>
112
+ <option value="LEFT_BOTTOM" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_BOTTOM' : false ) ?>>
113
+ <?php esc_html_e( 'Left Bottom', INTERGEO_PLUGIN_NAME ) ?>
114
+ </option>
115
+ <option value="LEFT_CENTER" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_CENTER' : false ) ?>>
116
+ <?php esc_html_e( 'Left Center', INTERGEO_PLUGIN_NAME ) ?>
117
+ </option>
118
+ <option value="LEFT_TOP" <?php selected( isset( $json['adsense']['position'] ) ? $json['adsense']['position'] == 'LEFT_TOP' : false ) ?>>
119
+ <?php esc_html_e( 'Left Top', INTERGEO_PLUGIN_NAME ) ?>
120
+ </option>
121
+ </select>
122
+ </td>
123
+ </tr>
124
+ </table>
125
+ </div>
126
+ </li>
127
+ <li class="intergeo_tlbr_ul_li_ul_li">
128
+ <span class="intergeo_tlbr_cntrl_ttl"><?php esc_html_e( 'Styles', INTERGEO_PLUGIN_NAME ) ?></span>
129
+ <di