Smart Floating / Sticky Buttons – Call, Sharing, Chat Widgets & More – Buttonizer - Version 1.0.2

Version Description

Download this release

Release Info

Developer buttonizer
Plugin Icon wp plugin Smart Floating / Sticky Buttons – Call, Sharing, Chat Widgets & More – Buttonizer
Version 1.0.2
Comparing to
See all releases

Version 1.0.2

Files changed (123) hide show
  1. assets/banner-772x250.png +0 -0
  2. assets/buttonizer.png +0 -0
  3. assets/icon-128x128.png +0 -0
  4. assets/img/buttonizer-floating-action-button.png +0 -0
  5. assets/img/buttonizer.png +0 -0
  6. assets/img/plugin-icon.png +0 -0
  7. assets/logo.png +0 -0
  8. assets/no-buttons.jpg +0 -0
  9. assets/plugin-icon.png +0 -0
  10. assets/screenshot-1.png +0 -0
  11. assets/screenshot-2.png +0 -0
  12. assets/screenshot-3.jpg +0 -0
  13. assets/screenshot-4.jpg +0 -0
  14. assets/screenshot-5.jpg +0 -0
  15. assets/wp-icon.png +0 -0
  16. buttonizer.php +147 -0
  17. classes/_README.php +17 -0
  18. classes/admin/Buttons.php +344 -0
  19. classes/admin/CompanyOpened.php +116 -0
  20. classes/admin/General.php +279 -0
  21. classes/admin/InitializeAdmin.php +300 -0
  22. classes/admin/PageCategories.php +72 -0
  23. classes/admin/ResetButtonizer.php +73 -0
  24. classes/default/license.php +69 -0
  25. classes/default/main.php +314 -0
  26. classes/default/maintain.php +151 -0
  27. css/buttonizer.css +239 -0
  28. css/style.css +552 -0
  29. favicon.ico +0 -0
  30. freemius/LICENSE.txt +340 -0
  31. freemius/README.md +253 -0
  32. freemius/assets/css/admin/account.css +1 -0
  33. freemius/assets/css/admin/add-ons.css +2 -0
  34. freemius/assets/css/admin/checkout.css +1 -0
  35. freemius/assets/css/admin/common.css +2 -0
  36. freemius/assets/css/admin/connect.css +1 -0
  37. freemius/assets/css/admin/deactivation-feedback.css +1 -0
  38. freemius/assets/css/admin/debug.css +1 -0
  39. freemius/assets/css/admin/dialog-boxes.css +2 -0
  40. freemius/assets/css/admin/license-activation.css +1 -0
  41. freemius/assets/css/common.css +1 -0
  42. freemius/assets/img/buttonizer-floating-action-button.png +0 -0
  43. freemius/assets/img/buttonizer.png +0 -0
  44. freemius/assets/img/icon.png +0 -0
  45. freemius/assets/index.php +3 -0
  46. freemius/assets/js/nojquery.ba-postmessage.js +140 -0
  47. freemius/assets/js/nojquery.ba-postmessage.min.js +12 -0
  48. freemius/assets/js/postmessage.js +135 -0
  49. freemius/assets/scss/_colors.scss +65 -0
  50. freemius/assets/scss/_functions.scss +0 -0
  51. freemius/assets/scss/_load.scss +4 -0
  52. freemius/assets/scss/_mixins.scss +283 -0
  53. freemius/assets/scss/_start.scss +4 -0
  54. freemius/assets/scss/_vars.scss +6 -0
  55. freemius/assets/scss/admin/_ajax-loader.scss +49 -0
  56. freemius/assets/scss/admin/_auto-install.scss +33 -0
  57. freemius/assets/scss/admin/_deactivation-feedback.scss +55 -0
  58. freemius/assets/scss/admin/_license-activation.scss +7 -0
  59. freemius/assets/scss/admin/_license-key-resend.scss +68 -0
  60. freemius/assets/scss/admin/_modal-common.scss +186 -0
  61. freemius/assets/scss/admin/account.scss +250 -0
  62. freemius/assets/scss/admin/add-ons.scss +449 -0
  63. freemius/assets/scss/admin/checkout.scss +5 -0
  64. freemius/assets/scss/admin/common.scss +173 -0
  65. freemius/assets/scss/admin/connect.scss +471 -0
  66. freemius/assets/scss/admin/debug.scss +135 -0
  67. freemius/assets/scss/admin/dialog-boxes.scss +7 -0
  68. freemius/config.php +327 -0
  69. freemius/includes/class-freemius-abstract.php +597 -0
  70. freemius/includes/class-freemius.php +12315 -0
  71. freemius/includes/class-fs-api.php +558 -0
  72. freemius/includes/class-fs-logger.php +688 -0
  73. freemius/includes/class-fs-plugin-updater.php +683 -0
  74. freemius/includes/class-fs-security.php +85 -0
  75. freemius/includes/debug/class-fs-debug-bar-panel.php +64 -0
  76. freemius/includes/debug/debug-bar-start.php +52 -0
  77. freemius/includes/debug/index.php +3 -0
  78. freemius/includes/entities/class-fs-billing.php +95 -0
  79. freemius/includes/entities/class-fs-entity.php +149 -0
  80. freemius/includes/entities/class-fs-payment.php +94 -0
  81. freemius/includes/entities/class-fs-plugin-info.php +34 -0
  82. freemius/includes/entities/class-fs-plugin-license.php +224 -0
  83. freemius/includes/entities/class-fs-plugin-plan.php +145 -0
  84. freemius/includes/entities/class-fs-plugin-tag.php +24 -0
  85. freemius/includes/entities/class-fs-plugin.php +94 -0
  86. freemius/includes/entities/class-fs-pricing.php +141 -0
  87. freemius/includes/entities/class-fs-scope-entity.php +29 -0
  88. freemius/includes/entities/class-fs-site.php +148 -0
  89. freemius/includes/entities/class-fs-subscription.php +125 -0
  90. freemius/includes/entities/class-fs-user.php +62 -0
  91. freemius/includes/entities/index.php +3 -0
  92. freemius/includes/fs-core-functions.php +629 -0
  93. freemius/includes/fs-essential-functions.php +459 -0
  94. freemius/includes/fs-plugin-info-dialog.php +942 -0
  95. freemius/includes/i18n.php +538 -0
  96. freemius/includes/index.php +3 -0
  97. freemius/includes/l10n.php +250 -0
  98. freemius/includes/managers/class-fs-admin-menu-manager.php +782 -0
  99. freemius/includes/managers/class-fs-admin-notice-manager.php +313 -0
  100. freemius/includes/managers/class-fs-cache-manager.php +237 -0
  101. freemius/includes/managers/class-fs-key-value-storage.php +326 -0
  102. freemius/includes/managers/class-fs-license-manager.php +104 -0
  103. freemius/includes/managers/class-fs-option-manager.php +302 -0
  104. freemius/includes/managers/class-fs-plan-manager.php +162 -0
  105. freemius/includes/managers/class-fs-plugin-manager.php +154 -0
  106. freemius/includes/managers/index.php +3 -0
  107. freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +9 -0
  108. freemius/includes/sdk/Exceptions/EmptyArgumentException.php +9 -0
  109. freemius/includes/sdk/Exceptions/Exception.php +74 -0
  110. freemius/includes/sdk/Exceptions/InvalidArgumentException.php +8 -0
  111. freemius/includes/sdk/Exceptions/OAuthException.php +12 -0
  112. freemius/includes/sdk/Exceptions/index.php +3 -0
  113. freemius/includes/sdk/Freemius.php +627 -0
  114. freemius/includes/sdk/FreemiusBase.php +188 -0
  115. freemius/includes/sdk/LICENSE.txt +340 -0
  116. freemius/includes/sdk/index.php +3 -0
  117. freemius/includes/supplements/fs-essential-functions-1.1.7.1.php +47 -0
  118. freemius/includes/supplements/index.php +3 -0
  119. freemius/index.php +3 -0
  120. freemius/languages/freemius-da_DK.mo +0 -0
  121. freemius/languages/freemius-da_DK.po +1790 -0
  122. freemius/languages/freemius-en.mo +0 -0
  123. freemius/languages/freemius-en.po +1699 -0
assets/banner-772x250.png ADDED
Binary file
assets/buttonizer.png ADDED
Binary file
assets/icon-128x128.png ADDED
Binary file
assets/img/buttonizer-floating-action-button.png ADDED
Binary file
assets/img/buttonizer.png ADDED
Binary file
assets/img/plugin-icon.png ADDED
Binary file
assets/logo.png ADDED
Binary file
assets/no-buttons.jpg ADDED
Binary file
assets/plugin-icon.png ADDED
Binary file
assets/screenshot-1.png ADDED
Binary file
assets/screenshot-2.png ADDED
Binary file
assets/screenshot-3.jpg ADDED
Binary file
assets/screenshot-4.jpg ADDED
Binary file
assets/screenshot-5.jpg ADDED
Binary file
assets/wp-icon.png ADDED
Binary file
buttonizer.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ Plugin Name: Buttonizer - Smart Floating Action Button
4
+ Plugin URI: https://buttonizer.pro
5
+ Description: The Buttonizer is a new way to give a boost to your number of interactions, actions and conversions from your website visitor by adding one or multiple Customizable Smart Floating Button in the corner of your website.
6
+ Version: 1.0.2
7
+ Author: Buttonizer
8
+ Author URI: https://buttonizer.pro
9
+ License: GPL2
10
+ License URI: https://www.gnu.org/licenses/gpl-2.0.html
11
+ Text Domain: wporg
12
+ */
13
+ /*
14
+ This program is free software; you can redistribute it and/or
15
+ modify it under the terms of the GNU General Public License
16
+ as published by the Free Software Foundation; either version 2
17
+ of the License, or (at your option) any later version.
18
+
19
+ This program is distributed in the hope that it will be useful,
20
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ GNU General Public License for more details.
23
+
24
+ You should have received a copy of the GNU General Public License
25
+ along with this program; if not, write to the Free Software
26
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27
+
28
+ Copyright 2017 Buttonizer
29
+ */
30
+
31
+ define('BUTTONIZER_NAME', 'buttonizer');
32
+ define('BUTTONIZER_DIR', dirname(__FILE__));
33
+ define('BUTTONIZER_PLUGIN_DIR', __FILE__ );
34
+ define('BUTTONIZER_VERSION','1.0.2');
35
+
36
+ # No script kiddies
37
+ defined( 'ABSPATH' ) or die('No script kiddies please!');
38
+
39
+ /* ================================================
40
+ * WELCOME TO THE BUTTONIZER SOURCE CODE!
41
+ *
42
+ * We like to see that you are courious
43
+ * how the code is written. When you
44
+ * are here to try to resolve problems
45
+ * you must be carefully, anything
46
+ * can get broken you know...
47
+ *
48
+ * -- KNOWLEDGE BASE --
49
+ * Did you know you can use our
50
+ * knowledge base?
51
+ * That's free!
52
+ *
53
+ * VISIT:
54
+ * https://knowledge.buttonizer.pro
55
+ *
56
+ * -- BUGS FOUND? --
57
+ * Are you here to look for a bug?
58
+ * Cool! If you found something
59
+ * you can report it to us!
60
+ *
61
+ * Maybe you get a FREE license
62
+ * for 1 website ;)
63
+ *
64
+ * ================================================
65
+ */
66
+
67
+ if(!class_exists("\\Buttonizer\\Maintain")) {
68
+ /* Install, deactivate and remove Buttonizer */
69
+ require BUTTONIZER_DIR . '/classes/default/maintain.php';
70
+
71
+ // Main stuff
72
+ require BUTTONIZER_DIR . '/classes/default/main.php';
73
+
74
+ // License stuff
75
+ require BUTTONIZER_DIR . '/classes/default/license.php';
76
+
77
+ // Admin stuff
78
+ require BUTTONIZER_DIR . '/classes/admin/InitializeAdmin.php';
79
+ }
80
+
81
+ /*
82
+ * License setup
83
+ */
84
+ $oButtonizer = new Buttonizer\License();
85
+ $oButtonizer->init();
86
+
87
+ if(!function_exists("ButtonizerLicense")) {
88
+ function ButtonizerLicense() {
89
+ global $oButtonizer;
90
+
91
+ return $oButtonizer->get();
92
+ }
93
+ }
94
+
95
+ /*
96
+ * Installation, removing and initiallization
97
+ */
98
+ $oButtonizerMaintain = new Buttonizer\Maintain(true, 'init');
99
+
100
+ /*
101
+ * Buttonizer admin stuff or button
102
+ */
103
+ if(is_admin()) {
104
+ // Load admin page
105
+ new Buttonizer\Admin\InitializeAdmin();
106
+ }
107
+ else
108
+ {
109
+ // Buttonizer button
110
+ new Buttonizer\Button($oButtonizerMaintain->isMobile());
111
+ }
112
+
113
+ /* LAST FEW FUNCTIONS */
114
+ if(!function_exists("buttonizer_custom_connect_message_on_update")) {
115
+ function buttonizer_custom_connect_message_on_update(
116
+ $message,
117
+ $user_first_name,
118
+ $plugin_title,
119
+ $user_login,
120
+ $site_link,
121
+ $freemius_link
122
+ ) {
123
+ return sprintf(
124
+ __fs( 'hey-x' ) . '<br>' .
125
+ __( 'Hey %2$s! We want to ask you to help us to improve Buttonizer! If you opt-in, some data about your usage of %2$s will be sent to %5$s. If you skip this, that\'s no problem! %2$s will still be improved!', 'buttonizer' ),
126
+ $user_first_name,
127
+ '<b>' . $plugin_title . '</b>',
128
+ '<b>' . $user_login . '</b>',
129
+ $site_link,
130
+ $freemius_link
131
+ );
132
+ }
133
+ }
134
+
135
+ $oButtonizer->get()->add_action('after_uninstall', 'buttonizer_uninstall_cleanup');
136
+
137
+ // System, buttonizer is loaded
138
+ do_action('buttonizer_loaded');
139
+
140
+ if(defined("BUTTONIZER_DEFINED")) {
141
+ echo "<div style='clear: both;'></div><img src='". plugins_url('/assets/buttonizer.png', BUTTONIZER_PLUGIN_DIR) ."' style='height: 40px; margin-right: 10px; float: left; vertical-align: top;'> Hey, looks like you try to install me (Buttonizer), while you already have an older version (or the free version) installed and activated? Deactivate all older Buttonizer plugins before trying again.<div style='clear: both; height: 20px'></div>";
142
+ trigger_error("Error", E_USER_ERROR);
143
+ exit;
144
+ }
145
+
146
+ // Ok, define
147
+ define('BUTTONIZER_DEFINED','1.0');
classes/_README.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ ===========================================================================
4
+
5
+ Dear reader,
6
+
7
+ When you are here, it means you are searching something. Right?
8
+
9
+ Something wrong? Error? Or just curious?
10
+
11
+ If you want to get a free license, you are here on the wrong place. Please
12
+ buy your license here:
13
+ /wp-admin/admin.php?page=Buttonizer-pricing
14
+
15
+ Questons? www.buttonizer.pro
16
+
17
+ ===========================================================================*/
classes/admin/Buttons.php ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This program is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU General Public License
5
+ as published by the Free Software Foundation; either version 2
6
+ of the License, or (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program; if not, write to the Free Software
15
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
+
17
+ Copyright 2017 Buttonizer
18
+ */
19
+
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die('No script kiddies please!');
24
+
25
+ class Buttons {
26
+ private $aSavedData = [];
27
+ private $aPageCategories = [];
28
+ private $aFontAwesome = [];
29
+
30
+ public function __construct($aFontAwesome) {
31
+ $this->aFontAwesome = $aFontAwesome;
32
+ $this->loadData();
33
+ $this->loadButtons();
34
+ }
35
+
36
+ private function loadData() {
37
+ $this->aSavedData = (array) get_option('buttonizer_buttons');
38
+ $this->aPageCategories = (array) get_option('buttonizer_page_categories');
39
+ }
40
+
41
+ private function loadButtons() {
42
+ // Get buttons
43
+ $aButtons = (isset($this->aSavedData['buttonorder']) && is_array($this->aSavedData['buttonorder']) ? $this->aSavedData['buttonorder'] : [0 => -1]);
44
+
45
+ if($aButtons[0] != '-1') {
46
+ $aButtons[-1] = '-1';
47
+ }
48
+
49
+ echo '<div id="button-rows">';
50
+ $iButtonCount = 0;
51
+ foreach($aButtons as $sButtonKey => $iButtonId) {
52
+ $this->loadIndividialButtonRow($sButtonKey, $iButtonId, (isset($bDisabled) ? true : false));
53
+ $iButtonCount++;
54
+ }
55
+
56
+ echo '<img src="'. plugins_url('/assets/no-buttons.jpg', BUTTONIZER_PLUGIN_DIR) .'" style="'. (0 == ($iButtonCount - 1) ? 'display: block;' : 'display: none;') .'" class="buttonizer-no-buttons" />';
57
+
58
+ echo '</div>';
59
+ }
60
+
61
+ private function loadIndividialButtonRow($sButtonKey, $iButtonId, $bDisabled) {
62
+ $sButtonTitle = (isset($this->aSavedData['button_' . $iButtonId . '_title']) ? ( $this->aSavedData['button_' . $iButtonId . '_title'] ):'Button ' . ($iButtonId + 1));
63
+
64
+ $onMobile = (isset($this->aSavedData['button_' . $iButtonId . '_show_on_phone'])?( $this->aSavedData['button_' . $iButtonId . '_show_on_phone'] ):'');
65
+ $onDesktop = (isset($this->aSavedData['button_' . $iButtonId . '_show_on_desktop'])?( $this->aSavedData['button_' . $iButtonId . '_show_on_desktop'] ):'');
66
+
67
+ ?>
68
+ <div class="button-row" id="btn_row_<?=$iButtonId?>" button-id="<?=$iButtonId?>"<?php if($iButtonId == -1) { echo ' style="display: none"'; } ?>>
69
+ <input type="checkbox" name="buttonizer_buttons[buttonorder][]" value="<?=$iButtonId?>" checked="checked" style="display: none;" />
70
+
71
+ <div class="row-info">
72
+ <span><i class="fa <?=$this->buttonOutputIcon($iButtonId);?> button-icon"></i> <span class="row-title"><?=($iButtonId == -1 ? 'New button' : $sButtonTitle)?></span> <i class="fa fa-pencil pencil-edit"></i></span>
73
+
74
+ <a href="javascript:buttonizer.removeRow(<?=$iButtonId?>)" class="delete-button">Delete <i class="fa fa-trash-o"></i></a>
75
+
76
+ <a href="javascript:buttonizer.toggleMobile(<?=$iButtonId?>)" class="mobiledesktop mobile-button <?=($onMobile == "" ? 'selected' : '');?>"><i class="fa fa-mobile"></i></a>
77
+ <a href="javascript:buttonizer.toggleDesktop(<?=$iButtonId?>)" class="mobiledesktop desktop-button <?=($onDesktop == "" ? 'selected' : '');?>"><i class="fa fa-desktop"></i></a>
78
+ </div>
79
+
80
+ <div class="button-data">
81
+ <table>
82
+ <tr style="display: none;">
83
+ <td width="20%"></td>
84
+ <td width="20%"></td>
85
+ <td></td>
86
+ </tr>
87
+ <tr>
88
+ <td>
89
+ <label for="button_text" class="label-top">
90
+ <span class="info-class"><i class="fa fa-info-circle"></i> <span>This is for internal use only.<br /><br />When using Google Analytics, this will be the title of the event when clicking this button.</span></span>
91
+ Button name:
92
+ </label>
93
+ <input type="text" name="buttonizer_buttons[button_<?=$iButtonId?>_title]" value="<?=$sButtonTitle?>" class="button_title" />
94
+ </td>
95
+ <td class="button-pdr" colspan="2">
96
+ <label for="button_icon" class="label-top">
97
+ <span class="info-class"><i class="fa fa-info-circle"></i> <span>This will be the icon of the button. You can choose from the build-in Font Awesome icons.<br /><br />When you want to use your own icon or image, you can click the 'or upload an image' link to use your own icon.</span></span>
98
+ Button icon:
99
+ </label>
100
+ <?=$this->buttonGetIcon($iButtonId); ?>
101
+ </td>
102
+ </tr>
103
+
104
+ <tr>
105
+ <td>&nbsp;</td>
106
+ <td></td>
107
+ <td></td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td>
112
+ <label for="button_text" class="label-top">
113
+ <span class="info-class"><i class="fa fa-info-circle"></i> <span>This is the label what the guest on your website will see. Something like 'Contact me!', or 'Like us on Facebook'</span></span>
114
+ Button label:
115
+ </label>
116
+ <?=$this->buttonGetText($iButtonId); ?>
117
+ </td>
118
+ <td colspan="2">
119
+ <label for="button_category" class="label-top">
120
+ <span class="info-class"><i class="fa fa-info-circle"></i> <span>Select a page category. You can add more page rules at the 'Page categories' tab.</span></span>
121
+ Button page category:
122
+ </label>
123
+ <?=$this->buttonGetShowOnPages($iButtonId); ?>
124
+ </td>
125
+ </tr>
126
+
127
+ <tr>
128
+ <td>&nbsp;</td>
129
+ <td></td>
130
+ <td></td>
131
+ </tr>
132
+
133
+ <tr class="settings-row">
134
+ <td>
135
+ <i class="fa fa-globe setting-icon"></i> URL or phone-number
136
+ <span class="info-class"><i class="fa fa-info-circle"></i> <span>This is the click-action of your button. You can input a full url (http://myawesomewebsite.com), a URI (/contact), an anchor-link (#anchor) or a phone number. Note that if you input a phone number that you select the option ‘Is phone number’. This will be a direct click-to-call action. Please don’t add a full url without the http:// (like: www.myawesomewebsite.com). </span></span>
137
+ </td>
138
+ <td colspan="2"><?=$this->buttonGetUrl($iButtonId)?></td>
139
+ </tr>
140
+
141
+ <tr class="settings-row">
142
+ <td>
143
+ <i class="fa fa-phone setting-icon"></i> Is phone number
144
+ </td>
145
+ <td><?=$this->buttonGetIsPhoneNumber($iButtonId)?><label for="button_<?=$iButtonId?>_is_phonenumber"> Yes</label></td>
146
+ <td></td>
147
+ </tr>
148
+
149
+ <tr class="settings-row setting-new-tab">
150
+ <td>
151
+ <i class="fa fa-external-link setting-icon"></i> Open in new tab
152
+ </td>
153
+ <td><?=$this->buttonGetNewTab($iButtonId)?><label for="button_<?=$iButtonId?>_url_newtab"> Yes</label></td>
154
+ <td></td>
155
+ </tr>
156
+
157
+ <tr>
158
+ <td>&nbsp;</td>
159
+ <td></td>
160
+ <td></td>
161
+ </tr>
162
+
163
+ <tr class="settings-row">
164
+ <td>
165
+ <i class="fa fa-mobile setting-icon"></i> Show on mobile
166
+ </td>
167
+ <td><?=$this->buttonGetShowPhone($iButtonId)?><label for="button_<?=$iButtonId?>_show_on_phone"> Yes</label></td>
168
+ <td></td>
169
+ </tr>
170
+
171
+ <tr class="settings-row">
172
+ <td>
173
+ <i class="fa fa-desktop setting-icon"></i> Show on desktop
174
+ </td>
175
+ <td><?=$this->buttonGetShowDesktop($iButtonId)?><label for="button_<?=$iButtonId?>_show_on_desktop"> Yes</label></td>
176
+ <td></td>
177
+ </tr>
178
+
179
+ <tr class="settings-row">
180
+ <td>
181
+ <i class="fa fa-tag setting-icon"></i> Hide label
182
+
183
+ <span class="info-class">
184
+ <i class="fa fa-info-circle"></i>
185
+ <span>
186
+ This is the label what the guest on your website will see. Something like 'Contact me!', or 'Like us on Facebook'
187
+ </span>
188
+ </span>
189
+ </td>
190
+ <td><?=$this->buttonGetHideLabel($iButtonId)?><label for="button_<?=$iButtonId?>_hide_label"> Yes</label></td>
191
+ <td></td>
192
+ </tr>
193
+
194
+ <tr>
195
+ <td>&nbsp;</td>
196
+ <td></td>
197
+ <td></td>
198
+ </tr>
199
+
200
+ <tr class="settings-row">
201
+ <td>
202
+ <i class="fa fa-clock-o setting-icon"></i> Show <b>only</b> on opening hours
203
+ </td>
204
+ <td><?=$this->buttonGetShowWenOpen($iButtonId)?><label for="button_<?=$iButtonId?>_show_when_opened"> Yes</label></td>
205
+ <td></td>
206
+ </tr>
207
+
208
+ <tr class="settings-row">
209
+ <td>
210
+ <i class="fa fa-times-circle-o setting-icon"></i> Show <b>only outside</b> opening hours
211
+ </td>
212
+ <td><?=$this->buttonGetShowNotWenOpen($iButtonId)?><label for="button_<?=$iButtonId?>_show_not_when_opened"> Yes</label></td>
213
+ <td></td>
214
+ </tr>
215
+ </table>
216
+ </div>
217
+ </div>
218
+ <?php
219
+ }
220
+
221
+ /*
222
+ * Form functions
223
+ */
224
+ // Get the text of the button
225
+ function buttonGetText($iButtonId = 0) {
226
+ $fieldName = 'button_' . $iButtonId . '_text';
227
+
228
+ $fieldValue = (isset($this->aSavedData[$fieldName]) ? ($this->aSavedData[$fieldName]) : 'New button');
229
+
230
+ return '<input type="text" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="'. $fieldValue .'" class="button_textfield" placeholder="Button text" />';
231
+ }
232
+
233
+ // Get button icon
234
+ function buttonGetIcon($iButtonId = 0) {
235
+ $fieldName = 'button_' . $iButtonId . '_icon';
236
+
237
+ $fab_icon_image = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
238
+
239
+ $p = '<select name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" style="font-family: \'FontAwesome\', \'Helvetica\';" class="button_iconfield fa-chooser">';
240
+
241
+ foreach($this->aFontAwesome as $key=>$row) {
242
+ $p .= '<option value="'. $key . '" '. ($fab_icon_image == $key ? 'selected="selected"' : '') . '>'. $row ." ".$key .'</option>';
243
+ }
244
+
245
+ return $p;
246
+ }
247
+
248
+ // Get button icon
249
+ function buttonOutputIcon($iButtonId = 0) {
250
+ $fieldName = 'button_' . $iButtonId . '_icon';
251
+
252
+ return (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'fa-info');
253
+ }
254
+
255
+ // Only show this button on phone?
256
+ function buttonGetShowPhone($iButtonId = 0) {
257
+ $fieldName = 'button_' . $iButtonId . '_show_on_phone';
258
+
259
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
260
+
261
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_showonphone" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
262
+ }
263
+
264
+ // buttonGetShowOnPages
265
+ function buttonGetShowOnPages($iButtonId = 0) {
266
+ $fieldName = 'button_' . $iButtonId . '_show_on_pages';
267
+
268
+ $is_selected = (isset($this->aSavedData[$fieldName]) ? ($this->aSavedData[$fieldName]) : '');
269
+
270
+ $pageOrders = (isset($this->aPageCategories['categorieOrder']) ? $this->aPageCategories['categorieOrder'] : []);
271
+
272
+ /*
273
+ * Generate <select>
274
+ */
275
+ $html = '<select name="buttonizer_buttons['. $fieldName .']" id="button_category"><option value="-5">Show on every page</option><option value="-4">Hide everywhere</option>';
276
+ foreach($pageOrders as $arrayKey => $pageKey) {
277
+ if($pageKey == -1) { continue; }
278
+
279
+ $html .= '<option value="'. $pageKey .'"'. ($pageKey == $is_selected ? 'selected="selected"' : '') .'>'. $this->aPageCategories['category_' . $pageKey . '_title'] .'</option>';
280
+ }
281
+ return $html . '</select>';
282
+ }
283
+
284
+ // Only show this button on desktop?
285
+ function buttonGetShowDesktop($iButtonId = 0) {
286
+ $fieldName = 'button_' . $iButtonId . '_show_on_desktop';
287
+
288
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
289
+
290
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_showondesktop" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
291
+ }
292
+
293
+ // Only show when company is open?
294
+ function buttonGetShowWenOpen($iButtonId = 0) {
295
+ $fieldName = 'button_' . $iButtonId . '_show_when_opened';
296
+
297
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
298
+
299
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_showwhenopened" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
300
+ }
301
+
302
+ // Only show when company is open?
303
+ function buttonGetShowNotWenOpen($iButtonId = 0) {
304
+ $fieldName = 'button_' . $iButtonId . '_show_not_when_opened';
305
+
306
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
307
+
308
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_showwhenopened" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
309
+ }
310
+
311
+ function buttonGetHideLabel($iButtonId = 0) {
312
+ $fieldName = 'button_' . $iButtonId . '_hide_label';
313
+
314
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
315
+
316
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_hidelabel" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
317
+ }
318
+
319
+ // Is this a phone number?
320
+ function buttonGetIsPhoneNumber($iButtonId = 0) {
321
+ $fieldName = 'button_' . $iButtonId . '_is_phonenumber';
322
+
323
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
324
+
325
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_isphonenumber" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
326
+ }
327
+
328
+ function buttonGetUrl($iButtonId = 0) {
329
+ $fieldName = 'button_' . $iButtonId . '_url';
330
+
331
+ $fieldValue = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
332
+
333
+ return '<input type="text" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="'. $fieldValue .'" class="button_isurl" placeholder="URL/Phone number" />';
334
+ }
335
+
336
+ // Only show this button on phone?
337
+ function buttonGetNewTab($iButtonId = 0) {
338
+ $fieldName = 'button_' . $iButtonId . '_url_newtab';
339
+
340
+ $is_selected = (isset($this->aSavedData[$fieldName])?( $this->aSavedData[$fieldName] ):'');
341
+
342
+ return '<input type="checkbox" name="buttonizer_buttons['. $fieldName .']" id="'. $fieldName .'" value="1" class="button_isnewtab" '. ($is_selected == '1' ? 'checked="checked"' : '') .' />';
343
+ }
344
+ }
classes/admin/CompanyOpened.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ Copyright 2017 Buttonizer
19
+ */
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24
+ class CompanyOpened
25
+ {
26
+ private $aSavedData = array() ;
27
+ public function __construct()
28
+ {
29
+ $this->loadData();
30
+ $this->createTable();
31
+ }
32
+
33
+ private function loadData()
34
+ {
35
+ $this->aSavedData = (array) get_option( 'buttonizer_opening_settings' );
36
+ }
37
+
38
+ public function createTable()
39
+ {
40
+ echo '<table class="opening_hours">' ;
41
+ echo '<thead><td></td><td>Monday</td><td>Tuesday</td><td>Wednesday</td><td>Thursday</td><td>Friday</td><td>Saturday</td><td>Sunday</td></thead>' ;
42
+ echo '<tbody>' ;
43
+ // Opened
44
+ echo '<tr>
45
+ <td><b>Opened from ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
46
+ <td>' . $this->fieldOpeningTimeSelector( 'monday', false ) . '</td>
47
+ <td>' . $this->fieldOpeningTimeSelector( 'tuesday', false ) . '</td>
48
+ <td>' . $this->fieldOpeningTimeSelector( 'wednesday', false ) . '</td>
49
+ <td>' . $this->fieldOpeningTimeSelector( 'thursday', false ) . '</td>
50
+ <td>' . $this->fieldOpeningTimeSelector( 'friday', false ) . '</td>
51
+ <td>' . $this->fieldOpeningTimeSelector( 'saturday', false ) . '</td>
52
+ <td>' . $this->fieldOpeningTimeSelector( 'sunday', false ) . '</td>
53
+ </tr>' ;
54
+ // Opened
55
+ echo '<tr>
56
+ <td><b>Closing at ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
57
+ <td>' . $this->fieldOpeningTimeSelector( 'monday', true ) . '</td>
58
+ <td>' . $this->fieldOpeningTimeSelector( 'tuesday', true ) . '</td>
59
+ <td>' . $this->fieldOpeningTimeSelector( 'wednesday', true ) . '</td>
60
+ <td>' . $this->fieldOpeningTimeSelector( 'thursday', true ) . '</td>
61
+ <td>' . $this->fieldOpeningTimeSelector( 'friday', true ) . '</td>
62
+ <td>' . $this->fieldOpeningTimeSelector( 'saturday', true ) . '</td>
63
+ <td>' . $this->fieldOpeningTimeSelector( 'sunday', true ) . '</td>
64
+ </tr>' ;
65
+ // Closed today
66
+ echo '<tr>
67
+ <td><b>Is it closed today? ' . (( ButtonizerLicense()->is__premium_only() ? ( !ButtonizerLicense()->is_plan( 'premium' ) ? '<span class="buttonizer-pro-feature">PRO</span>' : '' ) : '<span class="buttonizer-pro-feature">PRO</span>' )) . '</b></td>
68
+ <td>' . $this->fieldClosedToday( 'monday' ) . '</td>
69
+ <td>' . $this->fieldClosedToday( 'tuesday' ) . '</td>
70
+ <td>' . $this->fieldClosedToday( 'wednesday' ) . '</td>
71
+ <td>' . $this->fieldClosedToday( 'thursday' ) . '</td>
72
+ <td>' . $this->fieldClosedToday( 'friday' ) . '</td>
73
+ <td>' . $this->fieldClosedToday( 'saturday' ) . '</td>
74
+ <td>' . $this->fieldClosedToday( 'sunday' ) . '</td>
75
+ </tr>' ;
76
+ echo '</tbody>' ;
77
+ echo '</table>' ;
78
+ echo '<div class="buttonizer-pro-text"><i class="fa fa-lock"></i> You are missing the fun! When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will unlock opening hours.</div>' ;
79
+ }
80
+
81
+ public function fieldOpeningTimeManager( $value )
82
+ {
83
+ $sSelectBuilder = '';
84
+ // Get all 24-hours from a day
85
+ for ( $i = 0 ; $i < 24 ; $i++ ) {
86
+ // Set a zero before the hours less than 10 hours. (00, 01, 02 ...)
87
+ if ( $i < 10 ) {
88
+ $i = '0' . $i;
89
+ }
90
+ // Get all minutes in this hour
91
+ for ( $j = 0 ; $j < 60 ; $j++ ) {
92
+ // Set a zero before the minutes less than 10 minutes. (00, 01, 02 ...)
93
+ if ( $j < 10 ) {
94
+ $j = '0' . $j;
95
+ }
96
+ // Make a readable string. 00:00, 12:43, 16:16, ...
97
+ $sTime = $i . ':' . $j;
98
+ // Make a query
99
+ $sSelectBuilder .= '<option value=\'' . $sTime . '\'' . (( $value == $sTime ? 'selected="selected"' : '' )) . '>' . $sTime . '</option>';
100
+ }
101
+ }
102
+ return $sSelectBuilder;
103
+ }
104
+
105
+ public function fieldOpeningTimeSelector( $sDay, $bIsClosedSelector = false )
106
+ {
107
+ $sName = 'buttonizer_' . $sDay . '_' . (( $bIsClosedSelector == false ? 'opened_from' : 'closing_on' ));
108
+ return '<select class="buttonizer-click-to-pro" readonly><option disabled selected>' . (( $bIsClosedSelector == false ? '10:00' : '17:00' )) . '</option></select>';
109
+ }
110
+
111
+ public function fieldClosedToday( $sDay = 'monday' )
112
+ {
113
+ return '<input type="checkbox" class="buttonizer-click-to-pro" readonly />';
114
+ }
115
+
116
+ }
classes/admin/General.php ADDED
@@ -0,0 +1,279 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ Copyright 2017 Buttonizer
19
+ */
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24
+ class General
25
+ {
26
+ private $aSavedData = array() ;
27
+ private $aSubCatagories = array() ;
28
+ private $aSubPages = array() ;
29
+ private $aFontAwesome = array() ;
30
+ private $bHasProFeature = false ;
31
+ public function __construct( $aFontAwesome )
32
+ {
33
+ $this->aFontAwesome = $aFontAwesome;
34
+ $this->loadData();
35
+ $this->registerStylingSettings();
36
+ $this->registerAdvancedSettings();
37
+ $this->registerSocialSettings();
38
+ $this->registerOther();
39
+ $this->generatePage();
40
+ }
41
+
42
+ private function loadData()
43
+ {
44
+ $this->aSavedData = (array) get_option( 'buttonizer_general_settings' );
45
+ }
46
+
47
+ private function generatePage()
48
+ {
49
+ $sTabs = '';
50
+ $sTabsContent = '';
51
+ $bFirstTab = true;
52
+ // Get tabs
53
+ foreach ( $this->aSubCatagories as $sKey => $sTitle ) {
54
+ $sTabs .= '<a href="#tab_' . $sKey . '" onclick="javascript:buttonizer.tabNavigate(\'' . $sKey . '\')" id="tab_container_' . $sKey . '" class="nav-tab ' . (( $bFirstTab ? 'first nav-tab-active' : '' )) . '">' . $sTitle . '</a>';
55
+ $sTabsContent .= '<div id="tab_container_' . $sKey . '" ' . (( !$bFirstTab ? 'style="display: none;"' : '' )) . ' class="tab-container">' . $this->aSubPages[$sKey] . '</div>';
56
+ $bFirstTab = false;
57
+ }
58
+ echo '<table class="vertical-tabs">
59
+ <tr>
60
+ <td class="tabs">' . $sTabs . '</td>
61
+ <td class="tabsholder">' . $sTabsContent . '</td>
62
+ </tr>
63
+ </table>' ;
64
+ }
65
+
66
+ /*
67
+ * Register settings
68
+ */
69
+ public function registerStylingSettings()
70
+ {
71
+ $this->aSubCatagories['styling'] = 'Styling settings';
72
+ $this->aSubPages['styling'] = '<table class="form-table"><tbody>';
73
+ $this->aSubPages['styling'] .= $this->createFormField( 'Right', array( &$this, 'field_position_right' ) );
74
+ $this->aSubPages['styling'] .= $this->createFormField( 'Bottom', array( &$this, 'field_position_bottom' ) );
75
+ $this->aSubPages['styling'] .= $this->createFormField( 'Color button unpushed', array( &$this, 'field_button_unpushed' ) );
76
+ $this->aSubPages['styling'] .= $this->createFormField( 'Color button pushed', array( &$this, 'field_button_pushed' ) );
77
+ $this->aSubPages['styling'] .= $this->createFormField( 'Icon color', array( &$this, 'field_icon_color' ) );
78
+ $this->aSubPages['styling'] .= $this->createFormField( 'Main icon<br /><br /><small>Used only when more then one button and there is a menu.</small>', array( &$this, 'field_icon_icon' ) );
79
+ $this->aSubPages['styling'] .= '</tbody></table>';
80
+ }
81
+
82
+ public function registerAdvancedSettings()
83
+ {
84
+ $this->aSubCatagories['advanced'] = 'Advanced settings';
85
+ $this->aSubPages['advanced'] = '<table class="form-table"><tbody>';
86
+ $this->aSubPages['advanced'] .= $this->createFormField( '
87
+ <span class="info-class">
88
+ <i class="fa fa-info-circle"></i>
89
+ <span>If you have your Google Analytics tracking code already installed you can ignore this setting. If you want to be sure that your buttons are tracked in your Google Analytics account? Then go to your Google Analytics account > Click on Real Time > Events and open your website in another tab. Click on a Buttonizer button and check if you see that the click gets tracked in Google Analytics. If this doesn\'t happen than go to your google Analytics settings page > Click on tracking code and copy your tracking-ID. It should look like this (UA-00000000-0)
90
+ </span>
91
+ </span>
92
+ Google Analytics', array( &$this, 'field_analytics_code' ) );
93
+ // Show on scroll
94
+ $this->aSubPages['advanced'] .= $this->createFormField( '
95
+ <span class="info-class">
96
+ <i class="fa fa-info-circle"></i>
97
+ <span>
98
+ When selected, the buttons will be shown after the user has scrolled a percentage of the page.
99
+ </span>
100
+ </span>
101
+ Show on scroll?', array( &$this, 'field_show_on_scroll' ) );
102
+ $this->aSubPages['advanced'] .= $this->createFormField( '
103
+ <span class="info-class">
104
+ <i class="fa fa-info-circle"></i>
105
+ <span>
106
+ Enter a percentage, starting from 0, up to 100.
107
+ </span>
108
+ </span>
109
+ % from top to show:', array( &$this, 'field_procent_to_scroll' ) );
110
+ // Show after timeout
111
+ $this->aSubPages['advanced'] .= $this->createFormField( '
112
+ <span class="info-class">
113
+ <i class="fa fa-info-circle"></i>
114
+ <span>
115
+ When selected, the buttons will be shown when the user browsers more than the given seconds. So when you say: Show after 20<i>000</i>ms, the button shows after the user browsed on the website for 20 seconds.
116
+ </span>
117
+ </span>
118
+ Show after timeout?', array( &$this, 'field_show_on_timeout' ) );
119
+ $this->aSubPages['advanced'] .= $this->createFormField( '
120
+ <span class="info-class">
121
+ <i class="fa fa-info-circle"></i>
122
+ <span>
123
+ Enter the miliseconds from when the buttons must get shown to the user.<br />
124
+ <br />
125
+ 1 second = 1000 miliseconds<br />
126
+ 10 seconds = 10000 miliseconds<br />
127
+ 1 minute = 60000 miliseconds<br />
128
+ </span>
129
+ </span>
130
+ Milliseconds: ', array( &$this, 'field_time_to_timeout' ) );
131
+ $this->aSubPages['advanced'] .= '</tbody></table>';
132
+ if ( !ButtonizerLicense()->is_not_paying() ) {
133
+ $this->aSubPages['advanced'] .= '<div class="buttonizer-pro-text"><i class="fa fa-lock"></i> You are missing the fun! When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will get these features.</div>';
134
+ }
135
+ }
136
+
137
+ public function registerSocialSettings()
138
+ {
139
+ $this->aSubCatagories['social'] = 'Social share settings';
140
+ $this->aSubPages['social'] = '<table class="form-table"><tbody>';
141
+ // Facebook share button
142
+ $this->aSubPages['social'] .= $this->createFormField( 'Share on Facebook', array( &$this, 'field_share_facebook' ) );
143
+ // Twitter share button
144
+ $this->aSubPages['social'] .= $this->createFormField( 'Share on Twitter', array( &$this, 'field_share_twitter' ) );
145
+ // LinkedIn share button
146
+ $this->aSubPages['social'] .= $this->createFormField( 'Share on LinkedIn', array( &$this, 'field_share_linkedin' ) );
147
+ $this->aSubPages['social'] .= '</tbody></table>';
148
+ }
149
+
150
+ public function registerOther()
151
+ {
152
+ $this->aSubCatagories['other'] = 'Other';
153
+ $this->aSubPages['other'] = '<table class="form-table"><tbody>';
154
+ $this->aSubPages['other'] .= '<tr><th scope="row">Reset Buttonizer</th><td><a href="?page=Buttonizer&tab=buttonizer_page_reset">More info</a></td></tr>';
155
+ $this->aSubPages['other'] .= '</tbody></table>';
156
+ }
157
+
158
+ private function createFormField( $sLabel, $aFunction )
159
+ {
160
+ return '<tr><th scope="row">' . $sLabel . '</th><td>' . $aFunction() . '</td></tr>';
161
+ }
162
+
163
+ /*
164
+ * Form
165
+ */
166
+ public function field_button_unpushed()
167
+ {
168
+ $button_unpushed = ( isset( $this->aSavedData['button_unpushed'] ) ? $this->aSavedData['button_unpushed'] : '#48A4DC' );
169
+ return '<input type="text" name="buttonizer_general_settings[button_unpushed]" value="' . $button_unpushed . '" id="button_unpushed" data-default-color="#fffff" />';
170
+ }
171
+
172
+ public function field_button_pushed()
173
+ {
174
+ $button_pushed = ( isset( $this->aSavedData['button_pushed'] ) ? $this->aSavedData['button_pushed'] : '#1D9BDB' );
175
+ return '<input type="text" name="buttonizer_general_settings[button_pushed]" value="' . $button_pushed . '" id="button_pushed" data-default-color="#fffff" />';
176
+ }
177
+
178
+ public function field_icon_color()
179
+ {
180
+ $icon_color = ( isset( $this->aSavedData['icon_color'] ) ? $this->aSavedData['icon_color'] : '#fffff' );
181
+ return '<input type="text" name="buttonizer_general_settings[icon_color]" value="' . $icon_color . '" id="icon_color" data-default-color="#fffff" />';
182
+ }
183
+
184
+ public function field_icon_icon()
185
+ {
186
+ $fieldName = 'icon_icon';
187
+ $icon_image = ( isset( $this->aSavedData[$fieldName] ) ? $this->aSavedData[$fieldName] : '' );
188
+ $sValueImage = ( isset( $this->aSavedData['custom_icon'] ) ? $this->aSavedData['custom_icon'] : '' );
189
+ if ( $sValueImage != '' ) {
190
+ $this->bHasProFeature = true;
191
+ }
192
+ $p = '<div class="icon-or-image" data-type="' . (( $sValueImage != '' ? 'image' : 'icon' )) . '">
193
+ <div class="icon-placeholder" ' . (( $sValueImage != '' ? 'style="display: none;"' : '' )) . '>
194
+ <div class="placeholder-choose">
195
+ or <a href="javascript:void(0)">upload image</a>
196
+ </div>';
197
+ $p .= '<select name="buttonizer_general_settings[' . $fieldName . ']" id="' . $fieldName . '" style="font-family: \'FontAwesome\', \'Helvetica\';" class="fa-chooser">';
198
+ $p .= '<option value="+">+</option>';
199
+ foreach ( $this->aFontAwesome as $key => $row ) {
200
+ $p .= '<option value="' . $key . '" ' . (( $icon_image == $key ? 'selected="selected"' : '' )) . '>' . $row . ' ' . $key . '</option>';
201
+ }
202
+ $p .= '</select>';
203
+ $p .= '</div><div class="image-placeholder" ' . (( $sValueImage == '' ? 'style="display: none;"' : '' )) . '>';
204
+ $p .= '
205
+ <div class="placeholder-choose">
206
+ or <a href="javascript:void(0)">use an icon</a>
207
+ </div>
208
+
209
+ <div class="form-group smartcat-uploader" data-image="' . $sValueImage . '">
210
+ <input type="hidden" name="buttonizer_general_settings[custom_icon]" value="' . $sValueImage . '">
211
+ </div>
212
+ </div>';
213
+ return $p;
214
+ }
215
+
216
+ public function field_position_right()
217
+ {
218
+ $position_right = ( isset( $this->aSavedData['position_right'] ) ? $this->aSavedData['position_right'] : '95' );
219
+ return '<input type="text" name="buttonizer_general_settings[position_right]" value="' . $position_right . '"/><small><i>%</i></small>';
220
+ }
221
+
222
+ public function field_position_bottom()
223
+ {
224
+ $position_bottom = ( isset( $this->aSavedData['position_bottom'] ) ? $this->aSavedData['position_bottom'] : '95' );
225
+ return '<input type="text" name="buttonizer_general_settings[position_bottom]" value="' . $position_bottom . '"/><small><i>%</i></small>';
226
+ }
227
+
228
+ /*
229
+ * Advanced
230
+ */
231
+ public function field_analytics_code()
232
+ {
233
+ $google_analytics = ( isset( $this->aSavedData['google_analytics'] ) ? $this->aSavedData['google_analytics'] : '' );
234
+ return '<input type="text" name="buttonizer_general_settings[google_analytics]" value="' . $google_analytics . '" placeholder="Only when not inserted yet" style="width: 250px;"/>';
235
+ }
236
+
237
+ public function field_show_on_scroll()
238
+ {
239
+ return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
240
+ }
241
+
242
+ public function field_procent_to_scroll()
243
+ {
244
+ return '<input type="text" value="0" class="buttonizer-click-to-pro" readonly /><small><i>%</i></small> <span class="buttonizer-pro-feature">PRO</span>';
245
+ }
246
+
247
+ public function field_show_on_timeout()
248
+ {
249
+ return '<input type="checkbox" class="buttonizer-click-to-pro" readonly /> <span class="buttonizer-pro-feature">PRO</span>';
250
+ }
251
+
252
+ public function field_time_to_timeout()
253
+ {
254
+ return '<input type="text" class="buttonizer-click-to-pro" readonly value="0" /><span class="buttonizer-pro-feature">PRO</span>';
255
+ }
256
+
257
+ // Share page
258
+ public function field_share_facebook()
259
+ {
260
+ $share_facebook = ( isset( $this->aSavedData['share_facebook'] ) ? $this->aSavedData['share_facebook'] : '' );
261
+ $share_facebook_text = ( isset( $this->aSavedData['share_facebook_text'] ) ? $this->aSavedData['share_facebook_text'] : 'Share this on Facebook' );
262
+ return '<input type="checkbox" name="buttonizer_general_settings[share_facebook]" value="1" ' . (( $share_facebook == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_facebook_text]" value="' . $share_facebook_text . '" placeholder="Share this on Facebook" style="vertical-align: middle; margin-left: 10px;" />';
263
+ }
264
+
265
+ public function field_share_linkedin()
266
+ {
267
+ $share_linkedin = ( isset( $this->aSavedData['share_linkedin'] ) ? $this->aSavedData['share_linkedin'] : '' );
268
+ $share_linkedin_text = ( isset( $this->aSavedData['share_linkedin_text'] ) ? $this->aSavedData['share_linkedin_text'] : 'Share this on LinkedIn' );
269
+ return '<input type="checkbox" name="buttonizer_general_settings[share_linkedin]" value="1" ' . (( $share_linkedin == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_linkedin_text]" value="' . $share_linkedin_text . '" placeholder="Share this on LinkedIn" style="vertical-align: middle; margin-left: 10px;" />';
270
+ }
271
+
272
+ public function field_share_twitter()
273
+ {
274
+ $share_twitter = ( isset( $this->aSavedData['share_twitter'] ) ? $this->aSavedData['share_twitter'] : '' );
275
+ $share_twitter_text = ( isset( $this->aSavedData['share_twitter_text'] ) ? $this->aSavedData['share_twitter_text'] : 'Share this on Twitter' );
276
+ return '<input type="checkbox" name="buttonizer_general_settings[share_twitter]" value="1" ' . (( $share_twitter == '1' ? 'checked="checked"' : '' )) . ' /> <input type="text" name="buttonizer_general_settings[share_twitter_text]" value="' . $share_twitter_text . '" placeholder="Share this on Twitter" style="vertical-align: middle; margin-left: 10px;" />';
277
+ }
278
+
279
+ }
classes/admin/InitializeAdmin.php ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This program is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU General Public License
5
+ as published by the Free Software Foundation; either version 2
6
+ of the License, or (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program; if not, write to the Free Software
15
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
+
17
+ Copyright 2017 Buttonizer
18
+ */
19
+
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die('No script kiddies please!');
24
+
25
+ class InitializeAdmin {
26
+ // Define some data
27
+ private $aButtonizerPageButtons;
28
+ private $aPluginTabs = array();
29
+ private $aFontAwesome = null;
30
+
31
+ // Construct
32
+ public function __construct() {
33
+ if(!function_exists('wp_get_current_user')) {
34
+ include(ABSPATH . "wp-includes/pluggable.php");
35
+ }
36
+
37
+ $this->createButtonizerAdminMenu();
38
+ $this->getFontAwesome();
39
+
40
+ // Insert scripts
41
+ if (is_admin()) {
42
+ add_action('admin_enqueue_scripts', array(&$this, 'getPluginScripts'));
43
+ }else{
44
+ add_action('wp_print_scripts', array(&$this, 'getPluginScripts'));
45
+ }
46
+
47
+ add_action( 'admin_init', array( &$this, 'register_allSettings') );
48
+ }
49
+
50
+ /*
51
+ * Create menus
52
+ */
53
+ private function createButtonizerAdminMenu() {
54
+ add_menu_page(
55
+ 'Buttonizer Settings',
56
+ 'Buttonizer',
57
+ 'manage_options',
58
+ 'Buttonizer',
59
+ array(&$this, 'plugin_options_page'),
60
+ plugins_url('/assets/wp-icon.png', BUTTONIZER_PLUGIN_DIR),
61
+ 81
62
+ );
63
+ }
64
+
65
+ /* Get media */
66
+ public function getPluginScripts() {
67
+ wp_enqueue_media();
68
+ wp_enqueue_style( 'wp-color-picker' );
69
+ wp_enqueue_script( /*'fab-script', plugins_url( 'js/fab-script.js', __FILE__ ),*/
70
+ array( 'jquery','wp-color-picker' ),
71
+ false,
72
+ true
73
+ );
74
+
75
+ wp_enqueue_script('media-uploader', plugins_url('/js/wp_media_uploader.js?v=' . md5(BUTTONIZER_VERSION), BUTTONIZER_PLUGIN_DIR));
76
+ wp_enqueue_script('dashboard-script', plugins_url('/js/dashboard.js?v=' . md5(BUTTONIZER_VERSION), BUTTONIZER_PLUGIN_DIR));
77
+ wp_enqueue_script('opening-script', plugins_url('/js/company-openingtimes.js?v=' . md5(BUTTONIZER_VERSION), BUTTONIZER_PLUGIN_DIR));
78
+ wp_enqueue_script('advanced-settings-script', plugins_url('/js/advanced-settings.js?v=' . md5(BUTTONIZER_VERSION), BUTTONIZER_PLUGIN_DIR));
79
+
80
+ wp_enqueue_style('font-awesome','//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css');
81
+
82
+ wp_enqueue_style('dialog-boxes', plugins_url('/freemius/assets/css/admin/dialog-boxes.css', BUTTONIZER_PLUGIN_DIR));
83
+
84
+ }
85
+
86
+ /* Register tabs */
87
+ public function register_allSettings() {
88
+ $this->register_buttonizer_buttons();
89
+ $this->register_buttonizer_general_settings();
90
+ $this->register_buttonizer_page_categories();
91
+ $this->register_buttonizer_opening_settings();
92
+ $this->register_buttonizer_reset_everything();
93
+ }
94
+
95
+ /*
96
+ * Tabs and things
97
+ */
98
+ function plugin_options_page() {
99
+ $tab = isset($_GET['tab']) ? $_GET['tab'] : 'buttonizer_buttons';
100
+
101
+ ?>
102
+ <link rel="stylesheet" href="<?php echo plugins_url('/css/style.css', BUTTONIZER_PLUGIN_DIR); ?>?v=<?=md5(BUTTONIZER_VERSION)?>" type="text/css" media="all" />
103
+ <script>
104
+ var fontAwesome = <?php echo json_encode($this->aFontAwesome); ?>;
105
+ var faviconUrl = '<?php echo plugins_url('/favicon.ico', BUTTONIZER_PLUGIN_DIR); ?>?v=<?=md5(BUTTONIZER_VERSION)?>'
106
+ </script>
107
+
108
+ <!-- Icon autocompleter -->
109
+ <div class="fontawesome-searcher" style="display: none;">
110
+ <div class="fontawesome-searcher-searchbar">
111
+ <input type="text" placeholder="Search..." />
112
+ </div>
113
+ <div class="fontawesome-searcher-icons"></div>
114
+
115
+ <div class="no-matches-found" style="display: none;">
116
+ There is nothing found.
117
+ </div>
118
+ </div>
119
+
120
+ <a href="admin.php?page=Buttonizer&tab=buttonizer_buttons" class="buttonizer-logo"><img src="<?php echo plugins_url('/assets/logo.png', BUTTONIZER_PLUGIN_DIR); ?>" /></a>
121
+ <div class="clear"></div>
122
+
123
+ <!-- Page wrapper -->
124
+ <div class="wrap">
125
+ <?php $this->plugin_options_tabs(); ?>
126
+ <form method="post" action="options.php" id="buttonizer">
127
+ <?php wp_nonce_field( 'update-options' ); ?>
128
+ <?php settings_fields( $tab ); ?>
129
+
130
+ <?php do_settings_sections( $tab ); ?>
131
+
132
+
133
+ <?php
134
+ if($tab != 'buttonizer_page_reset'){
135
+ // submit_button();
136
+ ?>
137
+ <p class="submit">
138
+ <button type="submit" class="button button-primary savebutton"><i class="fa fa-floppy-o"></i> <span>Save</span></button>
139
+ </p>
140
+ <?php
141
+ }
142
+
143
+ if(!ButtonizerLicense()->is_plan('premium')) {
144
+ ?><div class="buttonizer-pro-text"><b class="color-buttonizer">You <span><i class="fa fa-heart"></i></span> Buttonizer?</b> When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will get more cool &amp; handy features.</div><?php
145
+ }
146
+ ?>
147
+ </form>
148
+ </div>
149
+ <?php
150
+ }
151
+
152
+ // Button
153
+ public function plugin_options_tabs() {
154
+ $current_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'buttonizer_buttons';
155
+
156
+ screen_icon();
157
+
158
+ echo '<div id="wordpress-plugin-message-spam" style="display: none; visibility: hidden;"><h2 class="nav-tab-wrapper">Sorry, I don\'t want all those plugin-spam from others on my page. This is a fake div where they will be spawned in. Happy life :)</h2></div>';
159
+
160
+
161
+ echo '<h1 class="nav-tab-wrapper">';
162
+
163
+ // Load tabs
164
+ foreach ( $this->aPluginTabs as $tab_key => $tab_caption ) {
165
+ $active = $current_tab == $tab_key ? 'nav-tab-active' : '';
166
+ echo '<a class="nav-tab ' . $active . '" href="?page=Buttonizer&tab=' . $tab_key . '">' . $tab_caption . '</a>';
167
+ }
168
+
169
+ // Show Buttonizer version number
170
+ echo '<a href="javascript:void(0)" class="nav-tab" style="cursor: default; float: right; border: 0; background: none; outline: none !important;">Buttonizer: v'. BUTTONIZER_VERSION .'</a>';
171
+
172
+ // Show buttonizer upgrade notification
173
+ if (!ButtonizerLicense()->is_plan('btn_pro')) {
174
+ echo '<a href="'. ButtonizerLicense()->get_upgrade_url() .'" id="upgrade-to-pro-url" class="nav-tab" style="float: right; border: 0; background: none; outline: none !important;">Upgrade to Pro!</a>';
175
+
176
+ if (ButtonizerLicense()->is_trial()) {
177
+ echo '<a href="" style="display: none;" id="upgrade-has-trail"></a>';
178
+ }
179
+ }else{
180
+ echo '<a href="'. ButtonizerLicense()->get_account_url() .'" class="nav-tab" style="float: right; border: 0; background: none; outline: none !important;">My Account</a>';
181
+ }
182
+
183
+ echo '</h1>';
184
+ }
185
+
186
+ /* =============================
187
+ * Add the tabs
188
+ * =============================
189
+ */
190
+
191
+ /* Add buttons tab */
192
+ function register_buttonizer_buttons() {
193
+ $this->aPluginTabs['buttonizer_buttons'] = __('Buttons', 'buttonizer');
194
+
195
+ register_setting('buttonizer_buttons', 'buttonizer_buttons');
196
+
197
+ // FAB Button Settings
198
+ add_settings_section(
199
+ 'buttonizer_buttons', // ID
200
+ 'Floating Action Buttons <button type="submit" class="button button-primary savebutton savebutton_margin"><i class="fa fa-floppy-o"></i> <span>Save</span></button> <a href="javascript:buttonizer.addRow()" id="new-button" class="button button-primary"><i class="fa fa-plus"></i> New button</a>', // Title
201
+ array( $this, 'getPageButtons' ), // Callback
202
+ 'buttonizer_buttons' // Page
203
+ );
204
+ }
205
+
206
+ public function getPageButtons() {
207
+ require BUTTONIZER_DIR . '/classes/admin/Buttons.php';
208
+
209
+ new Buttons($this->aFontAwesome);
210
+ }
211
+
212
+ /* Add general settings */
213
+ function register_buttonizer_general_settings() {
214
+ $this->aPluginTabs['buttonizer_general_settings'] = __('General settings', 'buttonizer');
215
+
216
+ register_setting('buttonizer_general_settings', 'buttonizer_general_settings');
217
+
218
+ // FAB Button Settings
219
+ add_settings_section(
220
+ 'buttonizer_general_settings', // ID
221
+ 'General settings <button type="submit" class="button button-primary savebutton savebutton_margin"><i class="fa fa-floppy-o"></i> <span>Save</span></button>', // Title
222
+ array( $this, 'getPageGeneralSettings' ), // Callback
223
+ 'buttonizer_general_settings' // Page
224
+ );
225
+ }
226
+
227
+ public function getPageGeneralSettings() {
228
+ require BUTTONIZER_DIR . '/classes/admin/General.php';
229
+
230
+ new General($this->aFontAwesome);
231
+ }
232
+
233
+ /* Buttonizer opening times */
234
+ private function register_buttonizer_opening_settings() {
235
+ $this->aPluginTabs['buttonizer_opening_settings'] = __('Opening hours', 'buttonizer');
236
+
237
+ register_setting( 'buttonizer_opening_settings', 'buttonizer_opening_settings');
238
+
239
+ // FAB Button Settings
240
+ add_settings_section(
241
+ 'buttonizer_opening_settings', // ID
242
+ 'Opening settings <button type="submit" class="button button-primary savebutton savebutton_margin"><i class="fa fa-floppy-o"></i> <span>Save</span></button>', // Title
243
+ array( $this, 'getPageOpeningTimes' ), // Callback
244
+ 'buttonizer_opening_settings' // Page
245
+ );
246
+ }
247
+
248
+ public function getPageOpeningTimes() {
249
+ require BUTTONIZER_DIR . '/classes/admin/CompanyOpened.php';
250
+
251
+ new CompanyOpened();
252
+ }
253
+
254
+ /* Buttonizer Page Categories */
255
+ private function register_buttonizer_page_categories() {
256
+ $this->aPluginTabs['buttonizer_page_categories'] = __('Page categories', 'buttonizer');
257
+
258
+ register_setting( 'buttonizer_page_categories', 'buttonizer_page_categories');
259
+
260
+ // FAB Button Settings
261
+ add_settings_section(
262
+ 'buttonizer_page_categories', // ID
263
+ 'Page categories <button type="submit" class="button button-primary savebutton savebutton_margin"><i class="fa fa-floppy-o"></i> <span>Save</span></button> <a href="javascript:buttonizer.addRow()" id="new-button" class="button button-primary"><i class="fa fa-plus"></i> New category</a>', // Title
264
+ array( $this, 'getPagePageCategories' ), // Callback
265
+ 'buttonizer_page_categories' // Page
266
+ );
267
+ }
268
+
269
+ public function getPagePageCategories() {
270
+ require BUTTONIZER_DIR . '/classes/admin/PageCategories.php';
271
+
272
+ new PageCategories();
273
+ }
274
+
275
+ /* Buttonizer Page Categories */
276
+ private function register_buttonizer_reset_everything() {
277
+ register_setting( 'buttonizer_page_reset', 'buttonizer_page_categories');
278
+
279
+ // FAB Button Settings
280
+ add_settings_section(
281
+ 'buttonizer_page_reset', // ID
282
+ 'Reset Buttonizer <a href="?page=Buttonizer&tab=buttonizer_page_reset&realReset='. md5(BUTTONIZER_DIR) .'" class="button button-red"><i class="fa fa-refresh"></i> Reset Buttonizer</a>',
283
+ array( $this, 'getPageResetButtonizer' ), // Callback
284
+ 'buttonizer_page_reset' // Page
285
+ );
286
+ }
287
+
288
+ public function getPageResetButtonizer() {
289
+ require BUTTONIZER_DIR . '/classes/admin/ResetButtonizer.php';
290
+
291
+ new ResetButtonizer();
292
+ }
293
+
294
+ /*
295
+ * Load Font Awesome Icons
296
+ */
297
+ private function getFontAwesome() {
298
+ $this->aFontAwesome = array ( 'fa-adjust' => '&#xf042;', 'fa-adn' => '&#xf170;', 'fa-align-center' => '&#xf037;', 'fa-align-justify' => '&#xf039;', 'fa-align-left' => '&#xf036;', 'fa-align-right' => '&#xf038;', 'fa-ambulance' => '&#xf0f9;', 'fa-anchor' => '&#xf13d;', 'fa-android' => '&#xf17b;', 'fa-angellist' => '&#xf209;', 'fa-angle-double-down' => '&#xf103;', 'fa-angle-double-left' => '&#xf100;', 'fa-angle-double-right' => '&#xf101;', 'fa-angle-double-up' => '&#xf102;', 'fa-angle-down' => '&#xf107;', 'fa-angle-left' => '&#xf104;', 'fa-angle-right' => '&#xf105;', 'fa-angle-up' => '&#xf106;', 'fa-apple' => '&#xf179;', 'fa-archive' => '&#xf187;', 'fa-area-chart' => '&#xf1fe;', 'fa-arrow-circle-down' => '&#xf0ab;', 'fa-arrow-circle-left' => '&#xf0a8;', 'fa-arrow-circle-o-down' => '&#xf01a;', 'fa-arrow-circle-o-left' => '&#xf190;', 'fa-arrow-circle-o-right' => '&#xf18e;', 'fa-arrow-circle-o-up' => '&#xf01b;', 'fa-arrow-circle-right' => '&#xf0a9;', 'fa-arrow-circle-up' => '&#xf0aa;', 'fa-arrow-down' => '&#xf063;', 'fa-arrow-left' => '&#xf060;', 'fa-arrow-right' => '&#xf061;', 'fa-arrow-up' => '&#xf062;', 'fa-arrows' => '&#xf047;', 'fa-arrows-alt' => '&#xf0b2;', 'fa-arrows-h' => '&#xf07e;', 'fa-arrows-v' => '&#xf07d;', 'fa-asterisk' => '&#xf069;', 'fa-at' => '&#xf1fa;', 'fa-automobile' => '&#xf1b9;', 'fa-backward' => '&#xf04a;', 'fa-ban' => '&#xf05e;', 'fa-bank' => '&#xf19c;', 'fa-bar-chart' => '&#xf080;', 'fa-bar-chart-o' => '&#xf080;', 'fa-barcode' => '&#xf02a;', 'fa-bars' => '&#xf0c9;', 'fa-bed' => '&#xf236;', 'fa-beer' => '&#xf0fc;', 'fa-behance' => '&#xf1b4;', 'fa-behance-square' => '&#xf1b5;', 'fa-bell' => '&#xf0f3;', 'fa-bell-o' => '&#xf0a2;', 'fa-bell-slash' => '&#xf1f6;', 'fa-bell-slash-o' => '&#xf1f7;', 'fa-bicycle' => '&#xf206;', 'fa-binoculars' => '&#xf1e5;', 'fa-birthday-cake' => '&#xf1fd;', 'fa-bitbucket' => '&#xf171;', 'fa-bitbucket-square' => '&#xf172;', 'fa-bitcoin' => '&#xf15a;', 'fa-bold' => '&#xf032;', 'fa-bolt' => '&#xf0e7;', 'fa-bomb' => '&#xf1e2;', 'fa-book' => '&#xf02d;', 'fa-bookmark' => '&#xf02e;', 'fa-bookmark-o' => '&#xf097;', 'fa-briefcase' => '&#xf0b1;', 'fa-btc' => '&#xf15a;', 'fa-bug' => '&#xf188;', 'fa-building' => '&#xf1ad;', 'fa-building-o' => '&#xf0f7;', 'fa-bullhorn' => '&#xf0a1;', 'fa-bullseye' => '&#xf140;', 'fa-bus' => '&#xf207;', 'fa-buysellads' => '&#xf20d;', 'fa-cab' => '&#xf1ba;', 'fa-calculator' => '&#xf1ec;', 'fa-calendar' => '&#xf073;', 'fa-calendar-o' => '&#xf133;', 'fa-camera' => '&#xf030;', 'fa-camera-retro' => '&#xf083;', 'fa-car' => '&#xf1b9;', 'fa-caret-down' => '&#xf0d7;', 'fa-caret-left' => '&#xf0d9;', 'fa-caret-right' => '&#xf0da;', 'fa-caret-square-o-down' => '&#xf150;', 'fa-caret-square-o-left' => '&#xf191;', 'fa-caret-square-o-right' => '&#xf152;', 'fa-caret-square-o-up' => '&#xf151;', 'fa-caret-up' => '&#xf0d8;', 'fa-cart-arrow-down' => '&#xf218;', 'fa-cart-plus' => '&#xf217;', 'fa-cc' => '&#xf20a;', 'fa-cc-amex' => '&#xf1f3;', 'fa-cc-discover' => '&#xf1f2;', 'fa-cc-mastercard' => '&#xf1f1;', 'fa-cc-paypal' => '&#xf1f4;', 'fa-cc-stripe' => '&#xf1f5;', 'fa-cc-visa' => '&#xf1f0;', 'fa-certificate' => '&#xf0a3;', 'fa-chain' => '&#xf0c1;', 'fa-chain-broken' => '&#xf127;', 'fa-check' => '&#xf00c;', 'fa-check-circle' => '&#xf058;', 'fa-check-circle-o' => '&#xf05d;', 'fa-check-square' => '&#xf14a;', 'fa-check-square-o' => '&#xf046;', 'fa-chevron-circle-down' => '&#xf13a;', 'fa-chevron-circle-left' => '&#xf137;', 'fa-chevron-circle-right' => '&#xf138;', 'fa-chevron-circle-up' => '&#xf139;', 'fa-chevron-down' => '&#xf078;', 'fa-chevron-left' => '&#xf053;', 'fa-chevron-right' => '&#xf054;', 'fa-chevron-up' => '&#xf077;', 'fa-child' => '&#xf1ae;', 'fa-circle' => '&#xf111;', 'fa-circle-o' => '&#xf10c;', 'fa-circle-o-notch' => '&#xf1ce;', 'fa-circle-thin' => '&#xf1db;', 'fa-clipboard' => '&#xf0ea;', 'fa-clock-o' => '&#xf017;', 'fa-close' => '&#xf00d;', 'fa-cloud' => '&#xf0c2;', 'fa-cloud-download' => '&#xf0ed;', 'fa-cloud-upload' => '&#xf0ee;', 'fa-cny' => '&#xf157;', 'fa-code' => '&#xf121;', 'fa-code-fork' => '&#xf126;', 'fa-codepen' => '&#xf1cb;', 'fa-coffee' => '&#xf0f4;', 'fa-cog' => '&#xf013;', 'fa-cogs' => '&#xf085;', 'fa-columns' => '&#xf0db;', 'fa-comment' => '&#xf075;', 'fa-comment-o' => '&#xf0e5;', 'fa-comments' => '&#xf086;', 'fa-comments-o' => '&#xf0e6;', 'fa-compass' => '&#xf14e;', 'fa-compress' => '&#xf066;', 'fa-connectdevelop' => '&#xf20e;', 'fa-copy' => '&#xf0c5;', 'fa-copyright' => '&#xf1f9;', 'fa-credit-card' => '&#xf09d;', 'fa-crop' => '&#xf125;', 'fa-crosshairs' => '&#xf05b;', 'fa-css3' => '&#xf13c;', 'fa-cube' => '&#xf1b2;', 'fa-cubes' => '&#xf1b3;', 'fa-cut' => '&#xf0c4;', 'fa-cutlery' => '&#xf0f5;', 'fa-dashboard' => '&#xf0e4;', 'fa-dashcube' => '&#xf210;', 'fa-database' => '&#xf1c0;', 'fa-dedent' => '&#xf03b;', 'fa-delicious' => '&#xf1a5;', 'fa-desktop' => '&#xf108;', 'fa-deviantart' => '&#xf1bd;', 'fa-diamond' => '&#xf219;', 'fa-digg' => '&#xf1a6;', 'fa-dollar' => '&#xf155;', 'fa-dot-circle-o' => '&#xf192;', 'fa-download' => '&#xf019;', 'fa-dribbble' => '&#xf17d;', 'fa-dropbox' => '&#xf16b;', 'fa-drupal' => '&#xf1a9;', 'fa-edit' => '&#xf044;', 'fa-eject' => '&#xf052;', 'fa-ellipsis-h' => '&#xf141;', 'fa-ellipsis-v' => '&#xf142;', 'fa-empire' => '&#xf1d1;', 'fa-envelope' => '&#xf0e0;', 'fa-envelope-o' => '&#xf003;', 'fa-envelope-square' => '&#xf199;', 'fa-eraser' => '&#xf12d;', 'fa-eur' => '&#xf153;', 'fa-euro' => '&#xf153;', 'fa-exchange' => '&#xf0ec;', 'fa-exclamation' => '&#xf12a;', 'fa-exclamation-circle' => '&#xf06a;', 'fa-exclamation-triangle' => '&#xf071;', 'fa-expand' => '&#xf065;', 'fa-external-link' => '&#xf08e;', 'fa-external-link-square' => '&#xf14c;', 'fa-eye' => '&#xf06e;', 'fa-eye-slash' => '&#xf070;', 'fa-eyedropper' => '&#xf1fb;', 'fa-facebook' => '&#xf09a;', 'fa-facebook-f' => '&#xf09a;', 'fa-facebook-official' => '&#xf230;', 'fa-facebook-square' => '&#xf082;', 'fa-fast-backward' => '&#xf049;', 'fa-fast-forward' => '&#xf050;', 'fa-fax' => '&#xf1ac;', 'fa-female' => '&#xf182;', 'fa-fighter-jet' => '&#xf0fb;', 'fa-file' => '&#xf15b;', 'fa-file-archive-o' => '&#xf1c6;', 'fa-file-audio-o' => '&#xf1c7;', 'fa-file-code-o' => '&#xf1c9;', 'fa-file-excel-o' => '&#xf1c3;', 'fa-file-image-o' => '&#xf1c5;', 'fa-file-movie-o' => '&#xf1c8;', 'fa-file-o' => '&#xf016;', 'fa-file-pdf-o' => '&#xf1c1;', 'fa-file-photo-o' => '&#xf1c5;', 'fa-file-picture-o' => '&#xf1c5;', 'fa-file-powerpoint-o' => '&#xf1c4;', 'fa-file-sound-o' => '&#xf1c7;', 'fa-file-text' => '&#xf15c;', 'fa-file-text-o' => '&#xf0f6;', 'fa-file-video-o' => '&#xf1c8;', 'fa-file-word-o' => '&#xf1c2;', 'fa-file-zip-o' => '&#xf1c6;', 'fa-files-o' => '&#xf0c5;', 'fa-film' => '&#xf008;', 'fa-filter' => '&#xf0b0;', 'fa-fire' => '&#xf06d;', 'fa-fire-extinguisher' => '&#xf134;', 'fa-flag' => '&#xf024;', 'fa-flag-checkered' => '&#xf11e;', 'fa-flag-o' => '&#xf11d;', 'fa-flash' => '&#xf0e7;', 'fa-flask' => '&#xf0c3;', 'fa-flickr' => '&#xf16e;', 'fa-floppy-o' => '&#xf0c7;', 'fa-folder' => '&#xf07b;', 'fa-folder-o' => '&#xf114;', 'fa-folder-open' => '&#xf07c;', 'fa-folder-open-o' => '&#xf115;', 'fa-font' => '&#xf031;', 'fa-forumbee' => '&#xf211;', 'fa-forward' => '&#xf04e;', 'fa-foursquare' => '&#xf180;', 'fa-frown-o' => '&#xf119;', 'fa-futbol-o' => '&#xf1e3;', 'fa-gamepad' => '&#xf11b;', 'fa-gavel' => '&#xf0e3;', 'fa-gbp' => '&#xf154;', 'fa-ge' => '&#xf1d1;', 'fa-gear' => '&#xf013;', 'fa-gears' => '&#xf085;', 'fa-genderless' => '&#xf1db;', 'fa-gift' => '&#xf06b;', 'fa-git' => '&#xf1d3;', 'fa-git-square' => '&#xf1d2;', 'fa-github' => '&#xf09b;', 'fa-github-alt' => '&#xf113;', 'fa-github-square' => '&#xf092;', 'fa-gittip' => '&#xf184;', 'fa-glass' => '&#xf000;', 'fa-globe' => '&#xf0ac;', 'fa-google' => '&#xf1a0;', 'fa-google-plus' => '&#xf0d5;', 'fa-google-plus-square' => '&#xf0d4;', 'fa-google-wallet' => '&#xf1ee;', 'fa-graduation-cap' => '&#xf19d;', 'fa-gratipay' => '&#xf184;', 'fa-group' => '&#xf0c0;', 'fa-h-square' => '&#xf0fd;', 'fa-hacker-news' => '&#xf1d4;', 'fa-hand-o-down' => '&#xf0a7;', 'fa-hand-o-left' => '&#xf0a5;', 'fa-hand-o-right' => '&#xf0a4;', 'fa-hand-o-up' => '&#xf0a6;', 'fa-hdd-o' => '&#xf0a0;', 'fa-header' => '&#xf1dc;', 'fa-headphones' => '&#xf025;', 'fa-heart' => '&#xf004;', 'fa-heart-o' => '&#xf08a;', 'fa-heartbeat' => '&#xf21e;', 'fa-history' => '&#xf1da;', 'fa-home' => '&#xf015;', 'fa-hospital-o' => '&#xf0f8;', 'fa-hotel' => '&#xf236;', 'fa-html5' => '&#xf13b;', 'fa-ils' => '&#xf20b;', 'fa-image' => '&#xf03e;', 'fa-inbox' => '&#xf01c;', 'fa-indent' => '&#xf03c;', 'fa-info' => '&#xf129;', 'fa-info-circle' => '&#xf05a;', 'fa-inr' => '&#xf156;', 'fa-instagram' => '&#xf16d;', 'fa-institution' => '&#xf19c;', 'fa-ioxhost' => '&#xf208;', 'fa-italic' => '&#xf033;', 'fa-joomla' => '&#xf1aa;', 'fa-jpy' => '&#xf157;', 'fa-jsfiddle' => '&#xf1cc;', 'fa-key' => '&#xf084;', 'fa-keyboard-o' => '&#xf11c;', 'fa-krw' => '&#xf159;', 'fa-language' => '&#xf1ab;', 'fa-laptop' => '&#xf109;', 'fa-lastfm' => '&#xf202;', 'fa-lastfm-square' => '&#xf203;', 'fa-leaf' => '&#xf06c;', 'fa-leanpub' => '&#xf212;', 'fa-legal' => '&#xf0e3;', 'fa-lemon-o' => '&#xf094;', 'fa-level-down' => '&#xf149;', 'fa-level-up' => '&#xf148;', 'fa-life-bouy' => '&#xf1cd;', 'fa-life-buoy' => '&#xf1cd;', 'fa-life-ring' => '&#xf1cd;', 'fa-life-saver' => '&#xf1cd;', 'fa-lightbulb-o' => '&#xf0eb;', 'fa-line-chart' => '&#xf201;', 'fa-link' => '&#xf0c1;', 'fa-linkedin' => '&#xf0e1;', 'fa-linkedin-square' => '&#xf08c;', 'fa-linux' => '&#xf17c;', 'fa-list' => '&#xf03a;', 'fa-list-alt' => '&#xf022;', 'fa-list-ol' => '&#xf0cb;', 'fa-list-ul' => '&#xf0ca;', 'fa-location-arrow' => '&#xf124;', 'fa-lock' => '&#xf023;', 'fa-long-arrow-down' => '&#xf175;', 'fa-long-arrow-left' => '&#xf177;', 'fa-long-arrow-right' => '&#xf178;', 'fa-long-arrow-up' => '&#xf176;', 'fa-magic' => '&#xf0d0;', 'fa-magnet' => '&#xf076;', 'fa-mail-forward' => '&#xf064;', 'fa-mail-reply' => '&#xf112;', 'fa-mail-reply-all' => '&#xf122;', 'fa-male' => '&#xf183;', 'fa-map-marker' => '&#xf041;', 'fa-mars' => '&#xf222;', 'fa-mars-double' => '&#xf227;', 'fa-mars-stroke' => '&#xf229;', 'fa-mars-stroke-h' => '&#xf22b;', 'fa-mars-stroke-v' => '&#xf22a;', 'fa-maxcdn' => '&#xf136;', 'fa-meanpath' => '&#xf20c;', 'fa-medium' => '&#xf23a;', 'fa-medkit' => '&#xf0fa;', 'fa-meh-o' => '&#xf11a;', 'fa-mercury' => '&#xf223;', 'fa-microphone' => '&#xf130;', 'fa-microphone-slash' => '&#xf131;', 'fa-minus' => '&#xf068;', 'fa-minus-circle' => '&#xf056;', 'fa-minus-square' => '&#xf146;', 'fa-minus-square-o' => '&#xf147;', 'fa-mobile' => '&#xf10b;', 'fa-mobile-phone' => '&#xf10b;', 'fa-money' => '&#xf0d6;', 'fa-moon-o' => '&#xf186;', 'fa-mortar-board' => '&#xf19d;', 'fa-motorcycle' => '&#xf21c;', 'fa-music' => '&#xf001;', 'fa-navicon' => '&#xf0c9;', 'fa-neuter' => '&#xf22c;', 'fa-newspaper-o' => '&#xf1ea;', 'fa-openid' => '&#xf19b;', 'fa-outdent' => '&#xf03b;', 'fa-pagelines' => '&#xf18c;', 'fa-paint-brush' => '&#xf1fc;', 'fa-paper-plane' => '&#xf1d8;', 'fa-paper-plane-o' => '&#xf1d9;', 'fa-paperclip' => '&#xf0c6;', 'fa-paragraph' => '&#xf1dd;', 'fa-paste' => '&#xf0ea;', 'fa-pause' => '&#xf04c;', 'fa-paw' => '&#xf1b0;', 'fa-paypal' => '&#xf1ed;', 'fa-pencil' => '&#xf040;', 'fa-pencil-square' => '&#xf14b;', 'fa-pencil-square-o' => '&#xf044;', 'fa-phone' => '&#xf095;', 'fa-phone-square' => '&#xf098;', 'fa-photo' => '&#xf03e;', 'fa-picture-o' => '&#xf03e;', 'fa-pie-chart' => '&#xf200;', 'fa-pied-piper' => '&#xf1a7;', 'fa-pied-piper-alt' => '&#xf1a8;', 'fa-pinterest' => '&#xf0d2;', 'fa-pinterest-p' => '&#xf231;', 'fa-pinterest-square' => '&#xf0d3;', 'fa-plane' => '&#xf072;', 'fa-play' => '&#xf04b;', 'fa-play-circle' => '&#xf144;', 'fa-play-circle-o' => '&#xf01d;', 'fa-plug' => '&#xf1e6;', 'fa-plus' => '&#xf067;', 'fa-plus-circle' => '&#xf055;', 'fa-plus-square' => '&#xf0fe;', 'fa-plus-square-o' => '&#xf196;', 'fa-power-off' => '&#xf011;', 'fa-print' => '&#xf02f;', 'fa-puzzle-piece' => '&#xf12e;', 'fa-qq' => '&#xf1d6;', 'fa-qrcode' => '&#xf029;', 'fa-question' => '&#xf128;', 'fa-question-circle' => '&#xf059;', 'fa-quote-left' => '&#xf10d;', 'fa-quote-right' => '&#xf10e;', 'fa-ra' => '&#xf1d0;', 'fa-random' => '&#xf074;', 'fa-rebel' => '&#xf1d0;', 'fa-recycle' => '&#xf1b8;', 'fa-reddit' => '&#xf1a1;', 'fa-reddit-square' => '&#xf1a2;', 'fa-refresh' => '&#xf021;', 'fa-remove' => '&#xf00d;', 'fa-renren' => '&#xf18b;', 'fa-reorder' => '&#xf0c9;', 'fa-repeat' => '&#xf01e;', 'fa-reply' => '&#xf112;', 'fa-reply-all' => '&#xf122;', 'fa-retweet' => '&#xf079;', 'fa-rmb' => '&#xf157;', 'fa-road' => '&#xf018;', 'fa-rocket' => '&#xf135;', 'fa-rotate-left' => '&#xf0e2;', 'fa-rotate-right' => '&#xf01e;', 'fa-rouble' => '&#xf158;', 'fa-rss' => '&#xf09e;', 'fa-rss-square' => '&#xf143;', 'fa-rub' => '&#xf158;', 'fa-ruble' => '&#xf158;', 'fa-rupee' => '&#xf156;', 'fa-save' => '&#xf0c7;', 'fa-scissors' => '&#xf0c4;', 'fa-search' => '&#xf002;', 'fa-search-minus' => '&#xf010;', 'fa-search-plus' => '&#xf00e;', 'fa-sellsy' => '&#xf213;', 'fa-send' => '&#xf1d8;', 'fa-send-o' => '&#xf1d9;', 'fa-server' => '&#xf233;', 'fa-share' => '&#xf064;', 'fa-share-alt' => '&#xf1e0;', 'fa-share-alt-square' => '&#xf1e1;', 'fa-share-square' => '&#xf14d;', 'fa-share-square-o' => '&#xf045;', 'fa-shekel' => '&#xf20b;', 'fa-sheqel' => '&#xf20b;', 'fa-shield' => '&#xf132;', 'fa-ship' => '&#xf21a;', 'fa-shirtsinbulk' => '&#xf214;', 'fa-shopping-cart' => '&#xf07a;', 'fa-sign-in' => '&#xf090;', 'fa-sign-out' => '&#xf08b;', 'fa-signal' => '&#xf012;', 'fa-simplybuilt' => '&#xf215;', 'fa-sitemap' => '&#xf0e8;', 'fa-skyatlas' => '&#xf216;', 'fa-skype' => '&#xf17e;', 'fa-slack' => '&#xf198;', 'fa-sliders' => '&#xf1de;', 'fa-slideshare' => '&#xf1e7;', 'fa-smile-o' => '&#xf118;', 'fa-soccer-ball-o' => '&#xf1e3;', 'fa-sort' => '&#xf0dc;', 'fa-sort-alpha-asc' => '&#xf15d;', 'fa-sort-alpha-desc' => '&#xf15e;', 'fa-sort-amount-asc' => '&#xf160;', 'fa-sort-amount-desc' => '&#xf161;', 'fa-sort-asc' => '&#xf0de;', 'fa-sort-desc' => '&#xf0dd;', 'fa-sort-down' => '&#xf0dd;', 'fa-sort-numeric-asc' => '&#xf162;', 'fa-sort-numeric-desc' => '&#xf163;', 'fa-sort-up' => '&#xf0de;', 'fa-soundcloud' => '&#xf1be;', 'fa-space-shuttle' => '&#xf197;', 'fa-spinner' => '&#xf110;', 'fa-spoon' => '&#xf1b1;', 'fa-spotify' => '&#xf1bc;', 'fa-square' => '&#xf0c8;', 'fa-square-o' => '&#xf096;', 'fa-stack-exchange' => '&#xf18d;', 'fa-stack-overflow' => '&#xf16c;', 'fa-star' => '&#xf005;', 'fa-star-half' => '&#xf089;', 'fa-star-half-empty' => '&#xf123;', 'fa-star-half-full' => '&#xf123;', 'fa-star-half-o' => '&#xf123;', 'fa-star-o' => '&#xf006;', 'fa-steam' => '&#xf1b6;', 'fa-steam-square' => '&#xf1b7;', 'fa-step-backward' => '&#xf048;', 'fa-step-forward' => '&#xf051;', 'fa-stethoscope' => '&#xf0f1;', 'fa-stop' => '&#xf04d;', 'fa-street-view' => '&#xf21d;', 'fa-strikethrough' => '&#xf0cc;', 'fa-stumbleupon' => '&#xf1a4;', 'fa-stumbleupon-circle' => '&#xf1a3;', 'fa-subscript' => '&#xf12c;', 'fa-subway' => '&#xf239;', 'fa-suitcase' => '&#xf0f2;', 'fa-sun-o' => '&#xf185;', 'fa-superscript' => '&#xf12b;', 'fa-support' => '&#xf1cd;', 'fa-table' => '&#xf0ce;', 'fa-tablet' => '&#xf10a;', 'fa-tachometer' => '&#xf0e4;', 'fa-tag' => '&#xf02b;', 'fa-tags' => '&#xf02c;', 'fa-tasks' => '&#xf0ae;', 'fa-taxi' => '&#xf1ba;', 'fa-tencent-weibo' => '&#xf1d5;', 'fa-terminal' => '&#xf120;', 'fa-text-height' => '&#xf034;', 'fa-text-width' => '&#xf035;', 'fa-th' => '&#xf00a;', 'fa-th-large' => '&#xf009;', 'fa-th-list' => '&#xf00b;', 'fa-thumb-tack' => '&#xf08d;', 'fa-thumbs-down' => '&#xf165;', 'fa-thumbs-o-down' => '&#xf088;', 'fa-thumbs-o-up' => '&#xf087;', 'fa-thumbs-up' => '&#xf164;', 'fa-ticket' => '&#xf145;', 'fa-times' => '&#xf00d;', 'fa-times-circle' => '&#xf057;', 'fa-times-circle-o' => '&#xf05c;', 'fa-tint' => '&#xf043;', 'fa-toggle-down' => '&#xf150;', 'fa-toggle-left' => '&#xf191;', 'fa-toggle-off' => '&#xf204;', 'fa-toggle-on' => '&#xf205;', 'fa-toggle-right' => '&#xf152;', 'fa-toggle-up' => '&#xf151;', 'fa-train' => '&#xf238;', 'fa-transgender' => '&#xf224;', 'fa-transgender-alt' => '&#xf225;', 'fa-trash' => '&#xf1f8;', 'fa-trash-o' => '&#xf014;', 'fa-tree' => '&#xf1bb;', 'fa-trello' => '&#xf181;', 'fa-trophy' => '&#xf091;', 'fa-truck' => '&#xf0d1;', 'fa-try' => '&#xf195;', 'fa-tty' => '&#xf1e4;', 'fa-tumblr' => '&#xf173;', 'fa-tumblr-square' => '&#xf174;', 'fa-turkish-lira' => '&#xf195;', 'fa-twitch' => '&#xf1e8;', 'fa-twitter' => '&#xf099;', 'fa-twitter-square' => '&#xf081;', 'fa-umbrella' => '&#xf0e9;', 'fa-underline' => '&#xf0cd;', 'fa-undo' => '&#xf0e2;', 'fa-university' => '&#xf19c;', 'fa-unlink' => '&#xf127;', 'fa-unlock' => '&#xf09c;', 'fa-unlock-alt' => '&#xf13e;', 'fa-unsorted' => '&#xf0dc;', 'fa-upload' => '&#xf093;', 'fa-usd' => '&#xf155;', 'fa-user' => '&#xf007;', 'fa-user-md' => '&#xf0f0;', 'fa-user-plus' => '&#xf234;', 'fa-user-secret' => '&#xf21b;', 'fa-user-times' => '&#xf235;', 'fa-users' => '&#xf0c0;', 'fa-venus' => '&#xf221;', 'fa-venus-double' => '&#xf226;', 'fa-venus-mars' => '&#xf228;', 'fa-viacoin' => '&#xf237;', 'fa-video-camera' => '&#xf03d;', 'fa-vimeo-square' => '&#xf194;', 'fa-vine' => '&#xf1ca;', 'fa-vk' => '&#xf189;', 'fa-volume-down' => '&#xf027;', 'fa-volume-off' => '&#xf026;', 'fa-volume-up' => '&#xf028;', 'fa-warning' => '&#xf071;', 'fa-wechat' => '&#xf1d7;', 'fa-weibo' => '&#xf18a;', 'fa-weixin' => '&#xf1d7;', 'fa-whatsapp' => '&#xf232;', 'fa-wheelchair' => '&#xf193;', 'fa-wifi' => '&#xf1eb;', 'fa-windows' => '&#xf17a;', 'fa-won' => '&#xf159;', 'fa-wordpress' => '&#xf19a;', 'fa-wrench' => '&#xf0ad;', 'fa-xing' => '&#xf168;', 'fa-xing-square' => '&#xf169;', 'fa-yahoo' => '&#xf19e;', 'fa-yelp' => '&#xf1e9;', 'fa-yen' => '&#xf157;', 'fa-youtube' => '&#xf167;', 'fa-youtube-play' => '&#xf16a;', 'fa-youtube-square' => '&#xf166;', );
299
+ }
300
+ }
classes/admin/PageCategories.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ Copyright 2017 Buttonizer
19
+ */
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24
+ class PageCategories
25
+ {
26
+ private $aSavedData = array() ;
27
+ private $aAllPages = array() ;
28
+ private $iButtonCount ;
29
+ public function __construct()
30
+ {
31
+ $this->loadData();
32
+ $this->loadCategories();
33
+ }
34
+
35
+ private function loadData()
36
+ {
37
+ $this->aSavedData = (array) get_option( 'buttonizer_page_categories' );
38
+ $this->aAllPages = get_pages();
39
+ }
40
+
41
+ private function loadCategories()
42
+ {
43
+ // Get buttons
44
+ $aCategories = ( isset( $this->aSavedData['categorieOrder'] ) && is_array( $this->aSavedData['categorieOrder'] ) ? $this->aSavedData['categorieOrder'] : array(
45
+ 0 => '-1',
46
+ ) );
47
+ if ( $aCategories[0] != '-1' ) {
48
+ $aCategories[-1] = '-1';
49
+ }
50
+ echo '<div id="page-categories">' ;
51
+ // Not removable button row
52
+ echo '<div class="button-row">
53
+ <div class="row-info">
54
+ <span><i class="fa fa-file-text-o"></i> All pages</span>
55
+ <a href="javascript:void(0)" class="delete-button" style="opacity: 0.5">Delete <i class="fa fa-trash-o"></i></a>
56
+ </div>
57
+
58
+ <div class="button-data">
59
+ When a button is set on \'All pages\', the button will shown on all pages. <br />
60
+ <br />
61
+ You cannot edit the \'All pages\' item.
62
+ </div>
63
+ </div>' ;
64
+ echo '<script>jQuery("h2 #new-button").click(buttonizer.proInfoWindow);</script><div class="buttonizer-pro-text"><i class="fa fa-lock"></i> You are missing the fun! When upgrading to <a href="admin.php?page=Buttonizer-pricing">Buttonizer Pro</a> you will unlock page categories.</div>' ;
65
+ echo '</div>' ;
66
+ }
67
+
68
+ private function loadIndividialCategoryRow( $sCategoryKey, $iCategoryId, $bDisabled )
69
+ {
70
+ }
71
+
72
+ }
classes/admin/ResetButtonizer.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This program is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU General Public License
5
+ as published by the Free Software Foundation; either version 2
6
+ of the License, or (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program; if not, write to the Free Software
15
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
+
17
+ Copyright 2017 Buttonizer
18
+ */
19
+
20
+ namespace Buttonizer\Admin;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die('No script kiddies please!');
24
+
25
+ class ResetButtonizer {
26
+
27
+ public function __construct() {
28
+
29
+ if(isset($_GET['realReset']) && $_GET['realReset'] == md5(BUTTONIZER_DIR)) {
30
+ $this->reset();
31
+
32
+ echo '<h1>Bibbidi Bobbidi Boo!</h1>';
33
+
34
+ echo '<h2>The magic happened! Have fun with a clean Buttonizer :)</h2>';
35
+ }else{
36
+ echo '<p><b>What happens when I click the cool red button at the right side?</b><br />
37
+ What will happen is that the plugin will get a \'reset\'. All changes to Buttonizer will get reversed. From then you can start all-over again.</p>';
38
+
39
+ echo '<p>&nbsp;</p>';
40
+
41
+ echo '<p><b>Why would I do that?</b><br />
42
+ There can be many reasons to use the <b>red button</b>. One could be, you ruined the Buttonizer buttons, the settings, categories and you almost blew up your computer. Then you can use it. Or if you want to try it.</p>';
43
+
44
+ echo '<p>&nbsp;</p>';
45
+
46
+ echo '<p><b>What about my license?</b><br />
47
+ The license will not be touched. This button does only reset & remove: <ul>
48
+ <li>- the Buttonizer buttons</li>
49
+ <li>- the opening hours</li>
50
+ <li>- general settings</li>
51
+ <li>- page categories</li>
52
+ </ul></p>';
53
+
54
+ echo '<p>&nbsp;</p>';
55
+
56
+ echo '<p><b>Okay, and then?</b><br />
57
+ Then Buttonizer will get to the default values again. Like you just installed Buttonizer. Nothing more, nothing less. Everything back to normal.</p>';
58
+
59
+ }
60
+ }
61
+
62
+ // Reset
63
+ private function reset() {
64
+ global $oButtonizerMaintain;
65
+
66
+ update_option('buttonizer_buttons', '');
67
+ update_option('buttonizer_opening_settings', '');
68
+ update_option('buttonizer_general_settings', '');
69
+ update_option('buttonizer_page_categories', '');
70
+
71
+ $oButtonizerMaintain->pluginActivate();
72
+ }
73
+ }
classes/default/license.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ Copyright 2017 Buttonizer
19
+ */
20
+ namespace Buttonizer;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24
+ class License
25
+ {
26
+ private $oButtonizer = 'null' ;
27
+ public function init()
28
+ {
29
+
30
+ if ( $this->oButtonizer == 'null' ) {
31
+ require_once BUTTONIZER_DIR . '/freemius/start.php';
32
+ // Some data for Buttonizer to be freemium and paid.
33
+ // We are paid so we can maintain the plugin
34
+ // If you don't want to pay for the plugin, you can allways use the
35
+ $this->oButtonizer = fs_dynamic_init( array(
36
+ 'id' => '1219',
37
+ 'slug' => 'buttonizer-floating-action-button',
38
+ 'type' => 'plugin',
39
+ 'public_key' => 'pk_fcd360d9c82b90a5e874e651ad733',
40
+ 'is_premium' => false,
41
+ 'has_addons' => false,
42
+ 'has_paid_plans' => true,
43
+ 'menu' => array(
44
+ 'slug' => 'Buttonizer',
45
+ 'support' => false,
46
+ ),
47
+ 'is_live' => true,
48
+ ) );
49
+ }
50
+
51
+ return;
52
+ }
53
+
54
+ public function get()
55
+ {
56
+ return $this->oButtonizer;
57
+ }
58
+
59
+ private function getDaysLeft()
60
+ {
61
+ return round( 2000 / 8 - 243 );
62
+ }
63
+
64
+ // Default data
65
+ private function initButtonizerData()
66
+ {
67
+ }
68
+
69
+ }
classes/default/main.php ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ This program is free software; you can redistribute it and/or
5
+ modify it under the terms of the GNU General Public License
6
+ as published by the Free Software Foundation; either version 2
7
+ of the License, or (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU General Public License for more details.
13
+
14
+ You should have received a copy of the GNU General Public License
15
+ along with this program; if not, write to the Free Software
16
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
+
18
+ Copyright 2017 Buttonizer
19
+ */
20
+ namespace Buttonizer;
21
+
22
+ # No script kiddies
23
+ defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
24
+ class Button
25
+ {
26
+ // Saved settings
27
+ private $aButtons ;
28
+ private $aPageSettings ;
29
+ private $aSettings ;
30
+ private $aOpeningData ;
31
+ // Default settings
32
+ private $bIsMobile = false ;
33
+ private $bIsOpened = true ;
34
+ // Current page
35
+ private $sCurrentPageId = 0 ;
36
+ private $sCurrentPageUrl = '' ;
37
+ private $sCurrentPageTitle = '' ;
38
+ private $sCurrentPageDescription = '' ;
39
+ // Output string
40
+ private $iAmountOfButtons = 0 ;
41
+ private $iAmountOfShareButtons = 0 ;
42
+ private $sOutput = '' ;
43
+ public function __construct( $bIsMobile )
44
+ {
45
+ // Set some data
46
+ $this->bIsMobile = (bool) $bIsMobile;
47
+ add_action( 'wp_footer', function () {
48
+ // Setup
49
+ $this->setup();
50
+ // Generate
51
+ $this->generate();
52
+ // Share buttons
53
+ $this->share_btns();
54
+ // Output
55
+ $this->output();
56
+ } );
57
+ add_action( 'wp_print_styles', array( &$this, 'siteLoadStyles' ) );
58
+ add_action( 'wp_print_scripts', array( &$this, 'siteLoadScripts' ) );
59
+ }
60
+
61
+ private function setup()
62
+ {
63
+ // Timezone
64
+ date_default_timezone_set( ( get_option( 'timezone_string' ) != '' ? get_option( 'timezone_string' ) : 'Europe/Amsterdam' ) );
65
+ // Get options
66
+ $this->aButtons = (array) get_option( 'buttonizer_buttons' );
67
+ $this->aPageSettings = (array) get_option( 'buttonizer_page_categories' );
68
+ $this->aOpeningData = (array) get_option( 'buttonizer_opening_settings' );
69
+ $this->aSettings = (array) get_option( 'buttonizer_general_settings' );
70
+ // Current page data
71
+ $this->sCurrentPageId = get_the_ID();
72
+ $this->sCurrentPageUrl = urlencode( get_permalink() );
73
+ $this->sCurrentPageTitle = get_the_title();
74
+ $this->sCurrentPageDescription = str_replace( ' ', '+', get_the_content( 'Read more' ) );
75
+ // Is store opened
76
+ $this->bIsOpened = $this->isOpened();
77
+ }
78
+
79
+ public function siteLoadStyles()
80
+ {
81
+ wp_enqueue_style( 'buttonizer', plugins_url( '/css/buttonizer.css?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) );
82
+ wp_enqueue_style( 'font-awesome', '//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css' );
83
+ }
84
+
85
+ public function siteLoadScripts()
86
+ {
87
+ wp_enqueue_script( 'buttonizer-js', plugins_url( '/js/buttonizer.js?v=' . md5( BUTTONIZER_VERSION ), BUTTONIZER_PLUGIN_DIR ) );
88
+ }
89
+
90
+ // Generate
91
+ private function generate()
92
+ {
93
+ $aButtons = ( isset( $this->aButtons['buttonorder'] ) && is_array( $this->aButtons['buttonorder'] ) ? $this->aButtons['buttonorder'] : array() );
94
+ foreach ( $aButtons as $sKey => $iId ) {
95
+ if ( '-1' == $iId ) {
96
+ continue;
97
+ }
98
+ $sButton = $this->generateB( $iId );
99
+
100
+ if ( 'continue' == $sButton ) {
101
+ continue;
102
+ } else {
103
+ $this->sOutput .= $sButton;
104
+ }
105
+
106
+ $this->iAmountOfButtons++;
107
+ }
108
+ }
109
+
110
+ private function generateB( $bNmbr )
111
+ {
112
+ // Check if this one must be showed when the company is open:
113
+ if ( isset( $this->aButtons['button_' . $bNmbr . '_show_when_opened'] ) && !$this->bIsOpened ) {
114
+ return 'continue';
115
+ }
116
+ // Check if this one must be showed when the company is open:
117
+ if ( isset( $this->aButtons['button_' . $bNmbr . '_show_not_when_opened'] ) && $this->bIsOpened ) {
118
+ return 'continue';
119
+ }
120
+ // Do we need to show the button?
121
+
122
+ if ( !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
123
+ // Skipping because not showing on desktop AND phone
124
+ return 'continue';
125
+ } else {
126
+ // Is the button visble on mobile phones?:
127
+ if ( $this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_phone'] ) ) {
128
+ // Skipping because this is a mobile
129
+ return 'continue';
130
+ }
131
+ // Is the button visible on desktop?:
132
+ if ( !$this->bIsMobile && !isset( $this->aButtons['button_' . $bNmbr . '_show_on_desktop'] ) ) {
133
+ // Skipping because this is desktop and it musn't get shown here
134
+ return 'continue';
135
+ }
136
+ }
137
+
138
+ /*
139
+ * Page categories selected or not
140
+ * Check on what pages the button must be shown
141
+ */
142
+ $buttonShowOnPages = ( isset( $this->aButtons['button_' . $bNmbr . '_show_on_pages'] ) ? $this->aButtons['button_' . $bNmbr . '_show_on_pages'] : 'all' );
143
+ $buttonPagesData = ( isset( $this->aPageSettings['category_' . $buttonShowOnPages] ) ? $this->aPageSettings['category_' . $buttonShowOnPages] : 'all' );
144
+ $sCategoryType = ( isset( $this->aPageSettings['category_' . $buttonShowOnPages . '_type'] ) ? $this->aPageSettings['category_' . $buttonShowOnPages . '_type'] : 'include' );
145
+ if ( $buttonShowOnPages != 'all' && $buttonShowOnPages != -5 && $buttonPagesData != 'all' && ($sCategoryType == 'include' && !in_array( $this->sCurrentPageId, $buttonPagesData ) || $sCategoryType == 'exclude' && in_array( $this->sCurrentPageId, $buttonPagesData )) ) {
146
+ return 'continue';
147
+ }
148
+ /*
149
+ * All button info
150
+ */
151
+ $buttonText = ( isset( $this->aButtons['button_' . $bNmbr . '_text'] ) ? $this->aButtons['button_' . $bNmbr . '_text'] : 'Button ' . $bNmbr );
152
+ $buttonTitle = ( isset( $this->aButtons['button_' . $bNmbr . '_title'] ) ? $this->aButtons['button_' . $bNmbr . '_title'] : 'Button ' . $bNmbr );
153
+ $buttonIcon = ( isset( $this->aButtons['button_' . $bNmbr . '_icon'] ) ? $this->aButtons['button_' . $bNmbr . '_icon'] : 'plus' );
154
+ $buttonIsPhone = ( isset( $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] ) ? $this->aButtons['button_' . $bNmbr . '_is_phonenumber'] : '' );
155
+ $link = ( isset( $this->aButtons['button_' . $bNmbr . '_url'] ) ? $this->aButtons['button_' . $bNmbr . '_url'] : '' );
156
+ $linkNewTab = ( isset( $this->aButtons['button_' . $bNmbr . '_url_newtab'] ) ? 'target="_blank"' : '' );
157
+ $hideLabel = ( isset( $this->aButtons['button_' . $bNmbr . '_hide_label'] ) ? $this->aButtons['button_' . $bNmbr . '_hide_label'] : '' );
158
+
159
+ if ( $link != '#' && strpos( 'javascript:', $link ) !== false ) {
160
+ $linkInfo = parse_url( $link );
161
+ if ( !$buttonIsPhone && empty($linkInfo['scheme']) && substr( $link, 0, 1 ) != '/' ) {
162
+ $link = 'http://' . $link;
163
+ }
164
+ }
165
+
166
+ $sButtonClasses = 'is_extra bt_' . $this->iAmountOfButtons;
167
+ return '<a href="' . (( $buttonIsPhone ? 'tel:' . $link : $link )) . '" class="' . $sButtonClasses . '" ' . $linkNewTab . ' onclick="onButtonizerClickEvent(\'' . $buttonText . '\')">' . (( $buttonText != '' ? '<div class="text"' . (( $hideLabel == '1' ? 'style="display: none;"' : '' )) . '><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa ' . $buttonIcon . '"></i></a>';
168
+ }
169
+
170
+ // Show on timeout
171
+ private function showOnTimeout()
172
+ {
173
+ return '0';
174
+ }
175
+
176
+ // Show on scroll
177
+ private function showOnScroll()
178
+ {
179
+ return '0';
180
+ }
181
+
182
+ // Is the store opened right now?
183
+ private function isOpened()
184
+ {
185
+ $sDayOfWeek = $this->getDay( date( 'N' ) );
186
+ $bIsOpened = true;
187
+ // Result
188
+ $bTodayClosed = ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closed'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closed'] : '' );
189
+ // If result == 1 => Closed
190
+
191
+ if ( $bTodayClosed == '1' ) {
192
+ $bIsOpened = false;
193
+ } else {
194
+ // Get the time right now
195
+ $sCurentHour = date( 'G' );
196
+ $sCurrentMinute = date( 'i' );
197
+ // Get the opening and closing time from today.
198
+ $hourOpening = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_opened_from'] : '10:00' ) );
199
+ $hourClosing = explode( ':', ( isset( $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] ) ? $this->aOpeningData['buttonizer_' . $sDayOfWeek . '_closing_on'] : '17:00' ) );
200
+ // Check if the company is opened/closed
201
+
202
+ if ( $sCurentHour < $hourOpening[0] || $sCurentHour == $hourOpening[0] && $sCurrentMinute < $hourOpening[1] || $sCurentHour > $hourClosing[0] || $sCurentHour == $hourClosing[0] && $sCurrentMinute > $hourClosing[1] - 1 ) {
203
+ $bIsOpened = false;
204
+ } else {
205
+ $bIsOpened = true;
206
+ }
207
+
208
+ }
209
+
210
+ return $bIsOpened;
211
+ }
212
+
213
+ // Day-number to text
214
+ private function getDay( $sDay )
215
+ {
216
+ switch ( $sDay ) {
217
+ case '1':
218
+ return 'monday';
219
+ break;
220
+ case '2':
221
+ return 'tuesday';
222
+ break;
223
+ case '3':
224
+ return 'wednesday';
225
+ break;
226
+ case '4':
227
+ return 'thursday';
228
+ break;
229
+ case '5':
230
+ return 'friday';
231
+ break;
232
+ case '6':
233
+ return 'saturday';
234
+ break;
235
+ case '7':
236
+ return 'monday';
237
+ break;
238
+ default:
239
+ return 'sunday';
240
+ break;
241
+ }
242
+ }
243
+
244
+ // Share buttons
245
+ private function share_btns()
246
+ {
247
+
248
+ if ( isset( $this->aSettings['share_facebook'] ) && '1' == $this->aSettings['share_facebook'] ) {
249
+ $buttonText = ( isset( $this->aSettings['share_facebook_text'] ) && $this->aSettings['share_facebook_text'] != '' ? $this->aSettings['share_facebook_text'] : 'Share this on Facebok' );
250
+ $this->sOutput .= '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Facebook share click\'); onButtonizerButtonFacebook();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != '' ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-facebook"></i></a>';
251
+ $this->iAmountOfShareButtons++;
252
+ }
253
+
254
+
255
+ if ( isset( $this->aSettings['share_twitter'] ) && '1' == $this->aSettings['share_twitter'] ) {
256
+ $buttonText = ( isset( $this->aSettings['share_twitter_text'] ) && $this->aSettings['share_twitter_text'] != '' ? $this->aSettings['share_twitter_text'] : 'Share this on Twitter' );
257
+ $this->sOutput .= '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Twitter share click\'); onButtonizerButtonTwitter();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != '' ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-twitter"></i></a>';
258
+ $this->iAmountOfShareButtons++;
259
+ }
260
+
261
+
262
+ if ( isset( $this->aSettings['share_linkedin'] ) && '1' == $this->aSettings['share_linkedin'] ) {
263
+ $buttonText = ( isset( $this->aSettings['share_linkedin_text'] ) && $this->aSettings['share_linkedin_text'] != '' ? $this->aSettings['share_linkedin_text'] : 'Share this on LinkedIn' );
264
+ $this->sOutput .= '<a href="javascript:void(0)" onclick="onButtonizerClickEvent(\'Linkedin share click\'); onButtonizerButtonLinkedin();" class="is_extra share share_' . ($this->iAmountOfShareButtons + 1) . '">' . (( $buttonText != '' ? '<div class="text"><div>' . $buttonText . '</div></div>' : '' )) . '<i class="fa fa-linkedin"></i></a>';
265
+ $this->iAmountOfShareButtons++;
266
+ }
267
+
268
+ }
269
+
270
+ // Output
271
+ public function output()
272
+ {
273
+ $bShowOnScroll = ( isset( $this->aSettings['show_on_scroll'] ) ? true : false );
274
+ $bShowOnProcent = ( isset( $this->aSettings['procent_to_scroll'] ) ? $this->aSettings['procent_to_scroll'] : '0' );
275
+ $sGoogleAnalyticsCode = ( isset( $this->aSettings['google_analytics'] ) ? $this->aSettings['google_analytics'] : false );
276
+ $showAfterTimeout = $this->showOnTimeout();
277
+ $showOnScroll = $this->showOnScroll();
278
+ // Main button image or icon
279
+ $sImage = ( isset( $this->aSettings['custom_icon'] ) ? $this->aSettings['custom_icon'] : '' );
280
+
281
+ if ( $sImage != '' ) {
282
+ $sIcon = '<img src="' . $sImage . '" style="width: 32px; vertical-align: middle;" />';
283
+ } else {
284
+ $sIcon = ( !empty($this->aSettings['icon_icon']) && $this->aSettings['icon_icon'] != '+' ? '<i class="isicon-fa fa ' . $this->aSettings['icon_icon'] . '"></i>' : '<i>+</i>' );
285
+ }
286
+
287
+
288
+ if ( $this->iAmountOfButtons == 1 && $this->iAmountOfShareButtons == 0 ) {
289
+ $output = str_replace( 'is_extra bt_0', 'buttonizer_head onlyone', $this->sOutput );
290
+ } else {
291
+
292
+ if ( $this->iAmountOfButtons > 1 || $this->iAmountOfShareButtons > 0 ) {
293
+ $output = '<a href="javascript:void(0)" class="buttonizer_head" id="buttonizer-sys" onclick="onButtonizerClickEvent(\'Open/Close Buttonizer button\')">' . $sIcon . '</a>' . $this->sOutput;
294
+ } else {
295
+ $output = '';
296
+ }
297
+
298
+ }
299
+
300
+ // Google analytics toevoegen
301
+ if ( isset( $this->aSettings['google_analytics'] ) && $this->aSettings['google_analytics'] != '' ) {
302
+ $output .= '<script>(function(i,s,o,g,r,a,m){i[\'GoogleAnalyticsObject\']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,\'script\',\'https://www.google-analytics.com/analytics.js\',\'ga\');ga(\'create\', \'' . $this->aSettings['google_analytics'] . '\', \'auto\');</script>';
303
+ }
304
+ echo '<div class="buttonizer-button ' . (( $showOnScroll > 0 || $showAfterTimeout > 0 ? 'hide' : '' )) . '" id="buttonizer-button"><div class="buttonizer_inner" id="buttonizer-sys">' . $output . '</div></div>
305
+ <script type="text/javascript">
306
+ buttonizer.init({
307
+ scrollBarTop: ' . $showOnScroll . ',
308
+ showAfter: ' . $showAfterTimeout . ',
309
+ });
310
+ </script>
311
+ <style>.buttonizer-button { right: ' . $this->aSettings['position_right'] . '%; bottom: ' . $this->aSettings['position_bottom'] . '%; } .buttonizer-button a:hover, .buttonizer-button a:focus{ background:' . $this->aSettings['button_pushed'] . '; } .buttonizer-button a { background:' . $this->aSettings['button_unpushed'] . '; } .buttonizer-button a i { color: ' . $this->aSettings['icon_color'] . '; }</style>' ;
312
+ }
313
+
314
+ }
classes/default/maintain.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ This program is free software; you can redistribute it and/or
4
+ modify it under the terms of the GNU General Public License
5
+ as published by the Free Software Foundation; either version 2
6
+ of the License, or (at your option) any later version.
7
+
8
+ This program is distributed in the hope that it will be useful,
9
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
10
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
+ GNU General Public License for more details.
12
+
13
+ You should have received a copy of the GNU General Public License
14
+ along with this program; if not, write to the Free Software
15
+ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16
+
17
+ Copyright 2017 Buttonizer
18
+ */
19
+ namespace Buttonizer;
20
+
21
+ # No script kiddies
22
+ defined( 'ABSPATH' ) or die('No script kiddies please!');
23
+
24
+ class Maintain {
25
+
26
+ // Construct
27
+ public function __construct($sReady = false) {
28
+ if(!$sReady) return;
29
+
30
+ if (!session_id())
31
+ session_start();
32
+
33
+ register_activation_hook('buttonizer', array(&$this, 'pluginActivate'));
34
+ register_deactivation_hook('buttonizer', array(&$this, 'pluginDeactivate'));
35
+ }
36
+
37
+ /**
38
+ * Activate Buttonizer, AWESOMAAH!
39
+ */
40
+ public function pluginActivate() {
41
+ /*
42
+ * General settings
43
+ */
44
+ $aGeneralSettings = get_option('buttonizer_general_settings');
45
+
46
+ // Check stored old data
47
+ if($aGeneralSettings == ''){
48
+ $aGeneralSettings = array(
49
+ 'button_unpushed' => '#48A4DC',
50
+ 'button_pushed' => '#1D9BDB',
51
+ 'icon_color' => '#FFFFFF',
52
+ 'icon_icon' => 'fa-plus',
53
+ 'position_right' => '5',
54
+ 'position_bottom' => '5',
55
+ 'google_analytics' => ''
56
+ );
57
+
58
+ // Update and save general default settings
59
+ update_option('buttonizer_general_settings', $aGeneralSettings);
60
+ }
61
+
62
+ /*
63
+ * Add default buttons
64
+ */
65
+ $aButtonizerDefaultButtons = get_option('buttonizer_buttons');
66
+
67
+ // Check stored old data
68
+ if($aButtonizerDefaultButtons == ''){
69
+ $aButtonizerDefaultButtons = [];
70
+
71
+ // Update and save general default settings
72
+ update_option('buttonizer_buttons', $aButtonizerDefaultButtons);
73
+ }
74
+
75
+ /*
76
+ * Opening settings
77
+ */
78
+ $aDefaultOpeningSettings = get_option('buttonizer_opening_settings');
79
+
80
+ // Do we have old opening data?
81
+ if($aDefaultOpeningSettings == '') {
82
+ $aDefaultOpeningSettings =
83
+ array(
84
+ // Monday
85
+ 'monday_opened_from' => '10:00',
86
+ 'monday_closing_on' => '17:00',
87
+ 'monday_closed' => false,
88
+
89
+ // Tuesday
90
+ 'tuesday_opened_from' => '10:00',
91
+ 'tuesday_closing_on' => '17:00',
92
+ 'tuesday_closed' => false,
93
+
94
+ // Wednesday
95
+ 'wednesday_opened_from' => '10:00',
96
+ 'wednesday_closing_on' => '17:00',
97
+ 'wednesday_closed' => false,
98
+
99
+ // Thursday
100
+ 'thursday_opened_from' => '10:00',
101
+ 'thursday_closing_on' => '17:00',
102
+ 'thursday_closed' => false,
103
+
104
+ // Friday
105
+ 'friday_opened_from' => '10:00',
106
+ 'friday_closing_on' => '17:00',
107
+ 'friday_closed' => false,
108
+
109
+ // Saturday
110
+ 'saturday_opened_from' => '10:00',
111
+ 'saturday_closing_on' => '17:00',
112
+ 'saturday_closed' => true,
113
+
114
+ // Sunday
115
+ 'sunday_opened_from' => '10:00',
116
+ 'sunday_closing_on' => '17:00',
117
+ 'sunday_closed' => true,
118
+ );
119
+
120
+ // Update and save default opening settings
121
+ update_option('buttonizer_opening_settings', $aDefaultOpeningSettings);
122
+ }
123
+ }
124
+
125
+ /**
126
+ * Deactivate plugin, SEE YOU SOON!
127
+ */
128
+ public function pluginDeactivate(){
129
+ // Nothing to handle right now. Maybe later
130
+ }
131
+
132
+ /*
133
+ * Mobile or desktop check
134
+ */
135
+ public function isMobile() {
136
+ if (strpos($_SERVER['HTTP_USER_AGENT'], 'Mobile') !== false ||
137
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Android') !== false ||
138
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Silk/') !== false ||
139
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Kindle') !== false ||
140
+ strpos($_SERVER['HTTP_USER_AGENT'], 'BlackBerry') !== false ||
141
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mini') !== false ||
142
+ strpos($_SERVER['HTTP_USER_AGENT'], 'Opera Mobi') !== false )
143
+ {
144
+ // Is mobile
145
+ return true;
146
+ } else {
147
+ // Is desktop
148
+ return false;
149
+ }
150
+ }
151
+ }
css/buttonizer.css ADDED
@@ -0,0 +1,239 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .buttonizer-button{
2
+ position:fixed;
3
+ right: 40px;
4
+ bottom: 40px;
5
+ z-index: 9999;
6
+ transition: all 0.2s ease-in-out;
7
+ -moz-transition: all 0.2s ease-in-out;
8
+ -webkit-transition: all 0.2s ease-in-out;
9
+ -o-transition: all 0.2s ease-in-out;
10
+ }
11
+
12
+ .buttonizer-button .buttonizer_inner {
13
+ position: relative;
14
+ }
15
+
16
+ .buttonizer-button:hover .c5 {
17
+ opacity: 1;
18
+ }
19
+
20
+ .buttonizer-button a, .buttonizer-button a:hover, .buttonizer-button a:active, .buttonizer-button a:focus{
21
+ text-decoration: none;
22
+ color: #fff;
23
+ box-shadow: 0 5px 11px 0 rgba(0,0,0,0.18),0 4px 15px 0 rgba(0,0,0,0.15);
24
+ }
25
+
26
+ .c5 {
27
+ font-family: Arial, \'Helvetica Neue\', Helvetica, sans-serif;
28
+ position: absolute !important;
29
+ opacity: 0;
30
+ bottom: -23px;
31
+ height: 15px !important;
32
+ line-height: 15px !important;
33
+ right: 0;
34
+ font-size: 8px;
35
+ background-color: rgba(0, 0, 0, 0.4) !important;
36
+ color: #FFFFFF;
37
+ text-align: center;
38
+ border-radius: 2px !important;
39
+ -moz-border-radius: 2px !important;
40
+ -webkit-border-radius: 2px !important;
41
+ }
42
+
43
+ .buttonizer-button a:hover,
44
+ .buttonizer-button a:focus{
45
+ background: #1D9BDB;
46
+ }
47
+
48
+ .buttonizer-button a{
49
+ background: #48A4DC;
50
+ border-radius:50%;
51
+ width:56px;
52
+ height:56px;
53
+ display: block;
54
+ vertical-align: middle;
55
+ text-align:center;
56
+ color: #FFFFFF;
57
+ box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16),0 2px 10px 0 rgba(0,0,0,0.12);
58
+ cursor:pointer;
59
+ outline:none;
60
+ position: relative;
61
+ transition: all 0.2s ease-out;
62
+ -moz-transition: all 0.2s ease-out;
63
+ -webkit-transition: all 0.2s ease-out;
64
+ -o-transition: all 0.2s ease-out;
65
+ margin-top: 5px;
66
+ line-height: 56px;
67
+ }
68
+
69
+ .buttonizer-button a.buttonizer_head {
70
+ position: absolute;
71
+ z-index: 999;
72
+ bottom: 0;
73
+ right: 0;
74
+ }
75
+
76
+ .buttonizer-button .buttonizer_inner a.buttonizer_head i {
77
+ font-size: 40px;
78
+ font-style: normal;
79
+ width: 56px;
80
+ height: 56px;
81
+ line-height: 56px;
82
+ display: block;
83
+ text-align: center;
84
+ }
85
+
86
+ .buttonizer-button a.buttonizer_head .text {
87
+ top: 15px;
88
+ right: 70px;
89
+ opacity: 0;
90
+ visibility: hidden;
91
+ }
92
+
93
+ .buttonizer-button a.buttonizer_head.onlyone:hover .text {
94
+ opacity: 1;
95
+ visibility: visible;
96
+ }
97
+
98
+ .buttonizer-button a.buttonizer_head.onlyone i {
99
+ font-size: 26px !important;
100
+ }
101
+
102
+ .buttonizer-button .buttonizer_inner a.buttonizer_head i, .buttonizer-button .buttonizer_inner a.buttonizer_head img {
103
+ transition: all 0.2s ease-in-out;
104
+ -moz-transition: all 0.2s ease-in-out;
105
+ -webkit-transition: all 0.2s ease-in-out;
106
+ -o-transition: all 0.2s ease-in-out;
107
+ }
108
+
109
+ .buttonizer-button .buttonizer_inner.opened a.buttonizer_head i, .buttonizer-button .buttonizer_inner.opened a.buttonizer_head img {
110
+ -webkit-transform: rotate(45deg);
111
+ -moz-transform: rotate(45deg);
112
+ -o-transform: rotate(45deg);
113
+ -ms-transform: rotate(45deg);
114
+ transform: rotate(45deg);
115
+ }
116
+
117
+ .buttonizer-button i.isicon-fa {
118
+ font-size: 30px !important;
119
+ }
120
+
121
+ .buttonizer-button .buttonizer_inner a.is_extra {
122
+ position: absolute;
123
+ top: 0;
124
+ z-index: 1;
125
+ opacity: 0;
126
+ right: 9px;
127
+ width: 40px;
128
+ height: 40px;
129
+ line-height: 40px;
130
+ }
131
+
132
+ .buttonizer-button .buttonizer_inner a.is_extra i {
133
+ font-size: 18px;
134
+ }
135
+
136
+ .buttonizer-button.hide .buttonizer_inner a.buttonizer_head,
137
+ .buttonizer-button.hide .buttonizer_inner a.is_extra {
138
+ width:0;
139
+ height: 0;
140
+ bottom: 20px;
141
+ right: 20px;
142
+ opacity: 0;
143
+ }
144
+
145
+ .buttonizer-button.hide #buttonizer-sys {
146
+ width:0;
147
+ height: 0;
148
+ bottom: 20px;
149
+ right: 20px;
150
+ opacity: 0;
151
+ }
152
+
153
+ .buttonizer-button .buttonizer_inner.opened .bt_0 {
154
+ opacity: 1;
155
+ top: -110px;
156
+ }
157
+
158
+ .buttonizer-button .buttonizer_inner.opened .bt_1 {
159
+ opacity: 1;
160
+ top: -160px;
161
+ }
162
+
163
+ .buttonizer-button .buttonizer_inner.opened .bt_2 {
164
+ opacity: 1;
165
+ top: -210px;
166
+ }
167
+
168
+ .buttonizer-button .buttonizer_inner.opened .bt_3 {
169
+ opacity: 1;
170
+ top: -260px;
171
+ }
172
+
173
+ .buttonizer-button .buttonizer_inner.opened .bt_4 {
174
+ opacity: 1;
175
+ top: -310px;
176
+ }
177
+
178
+ .buttonizer-button .buttonizer_inner.opened .share_1 {
179
+ opacity: 1;
180
+ left: -105px;
181
+ top: -53px;
182
+ }
183
+
184
+ .buttonizer-button .buttonizer_inner.opened .share_2 {
185
+ opacity: 1;
186
+ left: -154px;
187
+ top: -53px;
188
+ }
189
+
190
+ .buttonizer-button .buttonizer_inner.opened .share_3 {
191
+ opacity: 1;
192
+ left: -202px;
193
+ top: -53px;
194
+ }
195
+
196
+ .buttonizer-button .buttonizer_inner.opened .share_1 .text,
197
+ .buttonizer-button .buttonizer_inner.opened .share_2 .text,
198
+ .buttonizer-button .buttonizer_inner.opened .share_3 .text {
199
+ top: -35px;
200
+ right: -53px;
201
+ }
202
+
203
+ .buttonizer-button a .text {
204
+ position: absolute;
205
+ top: 7px;
206
+ right: 55px;
207
+ text-align: right;
208
+ color: #ffffff;
209
+ height: 26px;
210
+ line-height: 26px;
211
+ font-size: 12px;
212
+ padding: 0 10px;
213
+ transition: all 0.1s ease-out;
214
+ -moz-transition: all 0.1s ease-out;
215
+ -webkit-transition: all 0.1s ease-out;
216
+ -o-transition: all 0.1s ease-out;
217
+ display: block;
218
+ white-space: nowrap;
219
+ background: #4e4c4c;
220
+ border-radius: 3px;
221
+ -moz-border-radius: 3px;
222
+ -webkit-border-radius: 3px;
223
+ }
224
+
225
+ .buttonizer-button .share .text {
226
+ opacity: 0;
227
+ visibility: hidden;
228
+ }
229
+
230
+ .buttonizer-button a.share:hover .text {
231
+ visibility: visible;
232
+ opacity: 1;
233
+ }
234
+
235
+ .buttonizer-button a i {
236
+ font-size:24px;
237
+ width:24px;
238
+ height:24px;
239
+ }
css/style.css ADDED
@@ -0,0 +1,552 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ * Buttonizer
3
+ */
4
+ .opening_hours {
5
+ width: 100%;
6
+ }
7
+
8
+ .opening_hours td {
9
+ padding: 5px;
10
+ }
11
+
12
+ h2 .button {
13
+ float: right;
14
+ }
15
+
16
+ .buttonizer-logo {
17
+ display: inline-block;
18
+ margin-top: 20px;
19
+ margin-right: 20px;
20
+ padding-left: 10px;
21
+ float: left;
22
+ }
23
+
24
+ .buttonizer-logo img {
25
+ max-width: 200px;
26
+ }
27
+
28
+ .buttonizer-no-buttons {
29
+ width: 100%;
30
+ }
31
+
32
+ .clear {
33
+ clear: both;
34
+ }
35
+
36
+ .fs-modal .fs-modal-header .fs-close {
37
+ text-decoration: none;
38
+ }
39
+
40
+ .info-class {
41
+ position: relative;
42
+ display: inline-block;
43
+ }
44
+
45
+ .info-class >i {
46
+ color: #9d8a7e;
47
+ padding: 3px 5px;
48
+ margin-right: 4px;
49
+ }
50
+
51
+ .info-class >span {
52
+ opacity: 0;
53
+ position: absolute;
54
+ visibility: hidden;
55
+ z-index: 100;
56
+ top: 19px;
57
+ left: 0px;
58
+ border-radius: 3px;
59
+ -moz-border-radius: 3px;
60
+ -webkit-border-radius: 3px;
61
+ -edge-border-radius: 3px;
62
+
63
+ border-top-left-radius: 0;
64
+ -moz-border-top-left-radius: 0;
65
+ -webkit-border-top-left-radius: 0;
66
+ min-width: 200px;
67
+ padding: 10px;
68
+ background-color: rgba(0, 0, 0, 0.56);
69
+ color: #FFFFFF;
70
+ font-weight: 200;
71
+ }
72
+
73
+ .info-class:hover >i {
74
+ background-color: rgba(0, 0, 0, 0.56);
75
+ color: rgba(255, 255, 255, 0.5);
76
+
77
+ border-top-left-radius: 3px;
78
+ -moz-border-top-left-radius: 3px;
79
+ -webkit-border-top-left-radius: 3px;
80
+
81
+ border-top-right-radius: 3px;
82
+ -moz-border-top-right-radius: 3px;
83
+ -webkit-border-top-right-radius: 3px;
84
+
85
+ }
86
+
87
+ .info-class:hover >span {
88
+ opacity: 1;
89
+ visibility: visible;
90
+ }
91
+
92
+ #buttonizer h2 {
93
+ margin-bottom: 20px !important;
94
+ }
95
+
96
+ .savebutton_margin {
97
+ margin-left: 10px !important;
98
+ }
99
+
100
+ .savebutton span {
101
+ margin-left: 5px;
102
+ }
103
+
104
+ .button-row {
105
+ border: 1px solid #c4c4c4;
106
+ margin-bottom: 10px;
107
+ }
108
+
109
+ .button-row.opened .button-data {
110
+ display: block;
111
+ }
112
+
113
+ .button-row.button-row-disabled .row-info {
114
+ position: relative;
115
+ }
116
+
117
+ .button-row.button-row-disabled .row-info .button-locked {
118
+ position: absolute;
119
+ left: 0;
120
+ right: 0;
121
+ top: 0;
122
+ bottom: 0;
123
+ background: rgba(238, 238, 238, 0.74);
124
+ color: #6b6b6b;
125
+ text-align: center;
126
+ padding: 12px;
127
+ font-size: 16px;
128
+ }
129
+
130
+ .button-row.button-row-disabled.opened .button-data {
131
+ display: none !important;
132
+ }
133
+
134
+ .button-row .row-info {
135
+ padding: 12px 15px;
136
+ background-color: #e6e6e6;
137
+ cursor: pointer;
138
+ font-size: 18px;
139
+ }
140
+
141
+ .button-row .row-info i {
142
+ font-size: 18px;
143
+ margin-left: 10px;
144
+ margin-right: 20px;
145
+ }
146
+
147
+ .button-row .row-info .pencil-edit {
148
+ font-size: 15px;
149
+ color: #7d7d7d;
150
+ }
151
+
152
+ .button-row .row-info .pencil-edit:hover {
153
+ color: #333333;
154
+ }
155
+
156
+ .button-row .row-info .mobiledesktop {
157
+ font-size: 15px;
158
+ color: #4876ff;
159
+ float: right;
160
+ text-decoration: none;
161
+ outline: none;
162
+ box-shadow: none;
163
+ -webkit-box-shadow: none;
164
+ }
165
+
166
+ .button-row .row-info .mobiledesktop i {
167
+ margin: 0 10px !important;
168
+ }
169
+
170
+ .button-row .row-info .mobiledesktop.selected {
171
+ color: #7d7d7d;
172
+ }
173
+
174
+ .button-row .row-info .delete-button {
175
+ color: #c31414;
176
+ float: right;
177
+ font-size: 13px;
178
+ text-decoration: none;
179
+ margin-left: 15px;
180
+ }
181
+
182
+ .button-row .row-info .delete-button i {
183
+ font-size: 14px;
184
+ margin-right: 5px;
185
+ }
186
+
187
+ .button-row .row-info .delete-button:hover {
188
+ text-decoration: underline;
189
+ }
190
+
191
+ .button-row.button-row-disabled .row-info >.delete-button {
192
+ opacity: 0.2;
193
+ }
194
+
195
+ .button-row:hover .row-info, .button-row.opened .row-info {
196
+ background-color: #dbdbdb;
197
+ }
198
+
199
+ .button-row .button-data {
200
+ padding: 20px;
201
+ display: none;
202
+ }
203
+
204
+ .button-row .button-data table {
205
+ width: 100%;
206
+ }
207
+
208
+ .button-row .button-data .label-top {
209
+ font-weight: bold;
210
+ margin-bottom: 5px;
211
+ display: block;
212
+ }
213
+
214
+ .button-row .button-data input[type=text],
215
+ .button-row .button-data select {
216
+ width: 100%;
217
+ height: auto;
218
+ padding: 8px 10px;
219
+ }
220
+
221
+ .button-row .button-data .fontawesome-searcher-clicker {
222
+ display: block !important;
223
+ }
224
+
225
+ .button-row .button-data table .button-pdr {
226
+ padding-right: 15px;
227
+ }
228
+
229
+ .button-row .button-data table .settings-row td {
230
+ padding: 5px 0;
231
+ }
232
+
233
+ .button-row .button-data .setting-icon {
234
+ width: 23px;
235
+ text-align: center;
236
+ margin-right: 4px;
237
+ }
238
+
239
+ .button-preview {
240
+ border-radius: 50%;
241
+ width: 56px;
242
+ height: 56px;
243
+ display: block;
244
+ vertical-align: middle;
245
+ text-align: center;
246
+ color: #FFFFFF;
247
+ box-shadow: 0 2px 5px 0 rgba(0,0,0,0.16), 0 2px 10px 0 rgba(0,0,0,0.12);
248
+ cursor: pointer;
249
+ outline: none;
250
+ position: relative;
251
+ transition: all 0.2s ease-out;
252
+ -moz-transition: all 0.2s ease-out;
253
+ -webkit-transition: all 0.2s ease-out;
254
+ -o-transition: all 0.2s ease-out;
255
+ margin-top: 5px;
256
+ line-height: 56px;
257
+ }
258
+
259
+ /* General settings tabs */
260
+ .vertical-tabs {
261
+ display: block;
262
+ width: 100%;
263
+ border-spacing: 0;
264
+ }
265
+
266
+ .vertical-tabs tr td {
267
+ vertical-align: top;
268
+ padding: 0;
269
+ }
270
+
271
+ .vertical-tabs .tabs {
272
+ width: 200px;
273
+ }
274
+
275
+ .vertical-tabs .tabs a {
276
+ display: block;
277
+ float: none !important;
278
+ margin: 0px;
279
+ padding: 10px 20px;
280
+ border: 1px solid #cccccc;
281
+ border-top: 0;
282
+ box-shadow: none !important;
283
+ }
284
+
285
+ .vertical-tabs .tabs a.first {
286
+ border-top: 1px solid #cccccc;
287
+ }
288
+
289
+ .vertical-tabs .tabs a.nav-tab-active {
290
+ border-right: 0;
291
+ }
292
+
293
+ .vertical-tabs .tabsholder {
294
+ width: 85%;
295
+ }
296
+
297
+ .vertical-tabs .tab-container {
298
+ display: block;
299
+ border: 1px solid #cccccc;
300
+ margin-left: -1px;
301
+ min-height: 200px;
302
+ padding: 0 20px 20px 40px;
303
+ border-left: 0;
304
+ border-bottom: 0;
305
+ }
306
+
307
+ .form-table td {
308
+ vertical-align: middle !important;
309
+ }
310
+
311
+ /* Categories */
312
+ .categories-load-more {
313
+ display: block;
314
+
315
+ background-color: #e6e6e6;
316
+ border: 1px solid #c4c4c4;
317
+
318
+ padding: 10px 15px;
319
+ margin-top: 20px;
320
+
321
+ font-size: 15px;
322
+ text-align: center;
323
+ cursor: pointer;
324
+
325
+ color: #444444;
326
+
327
+ text-decoration: none;
328
+ }
329
+
330
+ .categories-load-more:hover {
331
+ color: #888888;
332
+ }
333
+
334
+ .page-categorie-styling {
335
+ background: #FFFFFF;
336
+ border-radius: 5px;
337
+ margin-top: 20px;
338
+ border: 1px solid #c4c4c4;
339
+ border-spacing: 0;
340
+ overflow: hidden;
341
+ }
342
+
343
+ .page-categorie-styling thead {
344
+ background-color: #f1f1f1;
345
+ }
346
+
347
+ .page-categorie-styling thead td {
348
+ border-bottom: 2px solid #dcdcdc;
349
+ padding: 8px 11px !important;
350
+ }
351
+
352
+ .page-categorie-styling tr {
353
+ border-bottom: 1px solid #333333;
354
+ }
355
+
356
+ .page-categorie-styling tr td {
357
+ padding: 14px 11px;
358
+ border-bottom: 1px solid #dcdcdc;
359
+ }
360
+
361
+ .page-categorie-styling .text-centered {
362
+ text-align: center;
363
+ }
364
+
365
+ .page-categorie-styling .is-clickable {
366
+ cursor: pointer;
367
+ }
368
+
369
+ /* FontAwesome searcher */
370
+ .fontawesome-searcher-clicker {
371
+ display: inline-block;
372
+ background-color: #ffffff;
373
+ border: 1px solid #cccccc;
374
+ color: #333333;
375
+ padding: 6px 16px;
376
+ text-decoration: none;
377
+ }
378
+
379
+ .fontawesome-searcher {
380
+ position: absolute;
381
+ left: 0;
382
+ top: 0;
383
+ background: #FFFFFF;
384
+ box-shadow: 0px 0px 10px rgba(183, 183, 183, 0.18);
385
+ min-width: 250px;
386
+ border: 1px solid #e7e7e7;
387
+ z-index: 999;
388
+ }
389
+
390
+ .fontawesome-searcher .fontawesome-searcher-searchbar {
391
+ padding: 20px;
392
+ text-align: center;
393
+ }
394
+
395
+ .fontawesome-searcher .fontawesome-searcher-searchbar input {
396
+ border-radius: 50px;
397
+ -moz-border-radius: 50px;
398
+ -webkit-border-radius: 50px;
399
+ padding: 7px 20px;
400
+ font-weight: 200;
401
+ outline: none;
402
+ }
403
+
404
+ .fontawesome-searcher .fontawesome-searcher-icons {
405
+ background-color: #f5f5f5;
406
+
407
+ border-top: 1px solid #e7e7e7;
408
+
409
+ overflow: auto;
410
+ max-height: 150px;
411
+ }
412
+
413
+ .fontawesome-searcher .fontawesome-searcher-icons table {
414
+ width: 100%;
415
+ }
416
+
417
+ .fontawesome-searcher .fontawesome-searcher-icons table table td {
418
+ border-bottom: 1px solid #e7e7e7;
419
+ border-right: 1px solid #e7e7e7;
420
+ border-left: 1px solid #ffffff;
421
+ }
422
+
423
+ .fontawesome-searcher .fontawesome-searcher-icons a {
424
+ background-color: #f5f5f5;
425
+ color: #464646;
426
+ font-size: 16px;
427
+ padding: 12px 0;
428
+ text-decoration: none;
429
+ display: block;
430
+ text-align: center;
431
+ outline: none;
432
+ }
433
+
434
+ .fontawesome-searcher .fontawesome-searcher-icons a:hover {
435
+ background-color: #e7e7e7;
436
+ }
437
+
438
+ .fontawesome-searcher .no-matches-found {
439
+ padding: 0 0 15px;
440
+ text-align: center;
441
+ font-style: italic;
442
+ color: #8b8b8b;
443
+ }
444
+
445
+ /* Pro */
446
+ .color-buttonizer {
447
+ color: #2a7688;
448
+ text-transform: uppercase;
449
+ }
450
+
451
+ .color-buttonizer span {
452
+ color: #ef8419;
453
+ }
454
+
455
+ .color-buttonizer-blue {
456
+ color: #2a7688;
457
+ }
458
+
459
+ .color-buttonizer-orange {
460
+ color: #ef8419;
461
+ }
462
+
463
+ .buttonizer-pro-checklist {
464
+ font-size: 16px;
465
+ line-height: 25px;
466
+ font-weight: 400;
467
+ }
468
+
469
+ .buttonizer-pro-checklist .fa-check {
470
+ margin-right: 10px;
471
+ font-size: 17px;
472
+ }
473
+
474
+ .buttonizer-pro-feature {
475
+ background: #2d7688;
476
+ background: -moz-linear-gradient(-45deg, #2d7688 0%, #187287 50%, #187287 50%, #f0841a 51%, #e8832c 98%);
477
+ background: -webkit-linear-gradient(-45deg, #2d7688 0%,#187287 50%,#187287 50%,#f0841a 51%,#e8832c 98%);
478
+ background: linear-gradient(135deg, #2d7688 0%,#187287 50%,#187287 50%,#f0841a 51%,#e8832c 98%);
479
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d7688', endColorstr='#e8832c',GradientType=1 );
480
+ color: #FFFFFF;
481
+ font-weight: 500;
482
+ font-size: 13px;
483
+ padding: 4px 20px;
484
+ display: inline-block;
485
+ border-radius: 4px;
486
+ -moz-border-radius: 4px;
487
+ -webkit-border-radius: 4px;
488
+ margin-left: 10px;
489
+ }
490
+
491
+ .buttonizer-pro-text {
492
+ border: 1px solid #eeeeee;
493
+ color: #999999;
494
+ padding: 20px 0;
495
+ font-size: 16px;
496
+ }
497
+
498
+ .buttonizer-pro-text a {
499
+ color: #999999;
500
+ }
501
+
502
+ .buttonizer-pro-text .fa-lock {
503
+ margin-right: 10px;
504
+ }
505
+
506
+ /* */
507
+ .icon-or-image {
508
+
509
+ }
510
+
511
+ .icon-or-image .placeholder-choose {
512
+ padding: 5px 5px 10px 5px;
513
+ display: block;
514
+ }
515
+
516
+ .icon-or-image .placeholder-choose a {
517
+ color: #147aae;
518
+ text-decoration: none;
519
+
520
+ }
521
+
522
+ .icon-or-image .placeholder-choose a:hover {
523
+ text-decoration: underline;
524
+ }
525
+
526
+ /*
527
+ * Red button
528
+ */
529
+ .wp-core-ui .button-red {
530
+ background: #ba0000;
531
+ border-color: #aa0000 #990000 #990000;
532
+ -webkit-box-shadow: 0 1px 0 #990000;
533
+ box-shadow: 0 1px 0 #990000;
534
+ color: #fff;
535
+ text-decoration: none;
536
+ text-shadow: 0 -1px 1px #990000, 1px 0 1px #990000, 0 1px 1px #990000, -1px 0 1px #990000;
537
+ }
538
+
539
+ .wp-core-ui .button-red:hover {
540
+ background: #c20000 !important;
541
+ border-color: #990000 !important;
542
+ color: #fff;
543
+ }
544
+
545
+ .wp-core-ui .button-red:active, .wp-core-ui .button-red:focus {
546
+ background: #aa0000 !important;
547
+ border-color: #990000 !important;
548
+ -webkit-box-shadow: inset 0 2px 0 #990000;
549
+ box-shadow: inset 0 2px 0 #990000;
550
+ vertical-align: top;
551
+ color: #FFFFFF;
552
+ }
favicon.ico ADDED
Binary file
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,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Freemius WordPress SDK
2
+ ======================
3
+
4
+ [Monetization](https://freemius.com/wordpress/), [analytics](https://freemius.com/wordpress/insights/), and marketing automation platform for plugin & theme developers. Freemius empower developers to create prosperous subscription based businesses.
5
+
6
+ You can see some of the WordPress.org plugins & themes that are utilizing the power of Freemius here:
7
+
8
+ https://includewp.com/freemius/#focus
9
+
10
+ If you are a WordPress plugin or theme developer and you are interested to monetize with Freemius you can [sign-up here for free](https://dashboard.freemius.com/register/):
11
+
12
+ https://dashboard.freemius.com/register/
13
+
14
+ **Below you'll find the integration instructions for our WordPress SDK.**
15
+
16
+ ## Code Documentation
17
+
18
+ You can find the SDK's PHP-Doc documentation here:
19
+ https://codedoc.pub/freemius/wordpress-sdk/master/
20
+
21
+ ## Initializing the SDK
22
+
23
+ Copy the code below and paste it into the top of your main plugin's PHP file, right after the plugin's header comment:
24
+
25
+ ```php
26
+ <?php
27
+ // Create a helper function for easy SDK access.
28
+ function my_prefix_fs() {
29
+ global $my_prefix_fs;
30
+ if ( ! isset( $my_prefix_fs ) ) {
31
+ // Include Freemius SDK.
32
+ require_once dirname(__FILE__) . '/freemius/start.php';
33
+
34
+ $my_prefix_fs = fs_dynamic_init( array(
35
+ 'id' => '1234',
36
+ 'slug' => 'my-plugin-slug',
37
+ 'menu_slug' => 'my_menu_slug', // You can also use __FILE__
38
+ 'public_key' => 'pk_MY_PUBLIC_KEY',
39
+ 'is_live' => true,
40
+ 'is_premium' => true,
41
+ 'has_addons' => false,
42
+ 'has_paid_plans' => false,
43
+ // Set the SDK to work in a sandbox mode (for development & testing).
44
+ // IMPORTANT: MAKE SURE TO REMOVE SECRET KEY BEFORE DEPLOYMENT.
45
+ 'secret_key' => 'sk_MY_SECRET_KEY',
46
+ ) );
47
+ }
48
+
49
+ return $my_prefix_fs;
50
+ }
51
+
52
+ // Init Freemius.
53
+ my_prefix_fs();
54
+ ?>
55
+ ```
56
+
57
+ - **1234** - Replace with your plugin's ID.
58
+ - **pk_MY_PUBLIC_KEY** - Replace with your plugin's public key.
59
+ - **sk_MY_SECRET_KEY** - Replace with your plugin's secret key.
60
+ - **my-plugin-slug** - Replace with your plugin's WordPress.org slug.
61
+ - **my_menu_slug** - Replace with your admin dashboard settings menu slug.
62
+
63
+
64
+ ## Usage example
65
+
66
+ You can call the SDK by using the shortcode function:
67
+
68
+ ```php
69
+ <?php my_prefix_fs()->get_upgrade_url(); ?>
70
+ ```
71
+
72
+ Or when calling Freemius multiple times in a scope, it's recommended to use it with the global variable:
73
+
74
+ ```php
75
+ <?php
76
+ global $my_prefix_fs;
77
+ $my_prefix_fs->get_account_url();
78
+ ?>
79
+ ```
80
+
81
+ ## Adding license based logic examples
82
+
83
+ Add marketing content to encourage your users to upgrade for your paid version:
84
+
85
+ ```php
86
+ <?php
87
+ if ( my_prefix_fs()->is_not_paying() ) {
88
+ echo '<section><h1>' . esc_html__('Awesome Premium Features', 'my-plugin-slug') . '</h1>';
89
+ echo '<a href="' . my_prefix_fs()->get_upgrade_url() . '">' .
90
+ esc_html__('Upgrade Now!', 'my-plugin-slug') .
91
+ '</a>';
92
+ echo '</section>';
93
+ }
94
+ ?>
95
+ ```
96
+
97
+ Add logic which will only be available in your premium plugin version:
98
+
99
+ ```php
100
+ <?php
101
+ // This "if" block will be auto removed from the Free version.
102
+ if ( my_prefix_fs()->is__premium_only() ) {
103
+
104
+ // ... premium only logic ...
105
+
106
+ }
107
+ ?>
108
+ ```
109
+
110
+ 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:
111
+
112
+ ```php
113
+ <?php
114
+ class My_Plugin {
115
+ function init() {
116
+ ...
117
+
118
+ // This "if" block will be auto removed from the free version.
119
+ if ( my_prefix_fs()->is__premium_only() ) {
120
+ // Init premium version.
121
+ $this->admin_init__premium_only();
122
+
123
+ add_action( 'admin_init', array( &$this, 'admin_init_hook__premium_only' );
124
+ }
125
+
126
+ ...
127
+ }
128
+
129
+ // This method will be only included in the premium version.
130
+ function admin_init__premium_only() {
131
+ ...
132
+ }
133
+
134
+ // This method will be only included in the premium version.
135
+ function admin_init_hook__premium_only() {
136
+ ...
137
+ }
138
+ }
139
+ ?>
140
+ ```
141
+
142
+ Add logic which will only be executed for customers in your 'professional' plan:
143
+
144
+ ```php
145
+ <?php
146
+ if ( my_prefix_fs()->is_plan('professional', true) ) {
147
+ // .. logic related to Professional plan only ...
148
+ }
149
+ ?>
150
+ ```
151
+
152
+ Add logic which will only be executed for customers in your 'professional' plan or higher plans:
153
+
154
+ ```php
155
+ <?php
156
+ if ( my_prefix_fs()->is_plan('professional') ) {
157
+ // ... logic related to Professional plan and higher plans ...
158
+ }
159
+ ?>
160
+ ```
161
+
162
+ 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):
163
+
164
+ ```php
165
+ <?php
166
+ // This "if" block will be auto removed from the Free version.
167
+ if ( my_prefix_fs()->is_plan__premium_only('professional') ) {
168
+ // ... logic related to Professional plan and higher plans ...
169
+ }
170
+ ?>
171
+ ```
172
+
173
+ Add logic only for users in trial:
174
+
175
+ ```php
176
+ <?php
177
+ if ( my_prefix_fs()->is_trial() ) {
178
+ // ... logic for users in trial ...
179
+ }
180
+ ?>
181
+ ```
182
+
183
+ Add logic for specified paid plan:
184
+
185
+ ```php
186
+ <?php
187
+ // This "if" block will be auto removed from the Free version.
188
+ if ( my_prefix_fs()->is__premium_only() ) {
189
+ if ( my_prefix_fs()->is_plan( 'professional', true ) ) {
190
+
191
+ // ... logic related to Professional plan only ...
192
+
193
+ } else if ( my_prefix_fs()->is_plan( 'business' ) ) {
194
+
195
+ // ... logic related to Business plan and higher plans ...
196
+
197
+ }
198
+ }
199
+ ?>
200
+ ```
201
+
202
+ ## Excluding files and folders from the free plugin version
203
+ There are two ways to exclude files from your free version.
204
+
205
+ 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.
206
+ 2. Add `@fs_premium_only` a sepcial meta tag to the plugin's main PHP file header. Example:
207
+ ```php
208
+ <?php
209
+ /**
210
+ * Plugin Name: My Very Awesome Plugin
211
+ * Plugin URI: http://my-awesome-plugin.com
212
+ * Description: Create and manage Awesomeness right in WordPress.
213
+ * Version: 1.0.0
214
+ * Author: Awesomattic
215
+ * Author URI: http://my-awesome-plugin.com/me/
216
+ * License: GPLv2
217
+ * Text Domain: myplugin
218
+ * Domain Path: /langs
219
+ *
220
+ * @fs_premium_only /lib/functions.php, /premium-files/
221
+ */
222
+
223
+ if ( ! defined( 'ABSPATH' ) ) {
224
+ exit;
225
+ }
226
+
227
+ // ... my code ...
228
+ ?>
229
+ ```
230
+ The file `/lib/functions.php` and the directory `/premium-files/` will be removed from the free plugin version.
231
+
232
+ # WordPress.org Compliance
233
+ 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:
234
+ > 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.
235
+
236
+ 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.
237
+
238
+ ## Deployment
239
+ Zip your plugin's root folder and upload it in the Deployment section in the *Freemius Developer's Dashboard*.
240
+ The plugin will be scanned and processed by a custom developed *PHP Processor* which will auto-generate two versions of your plugin:
241
+
242
+ 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.
243
+ 2. **Free version**: The code stripped from all your paid features (based on the logic added wrapped in `{ method }__premium_only()`).
244
+
245
+ 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.
246
+
247
+ ## Reporting Bugs
248
+ Email dev [at] freemius [dot] com
249
+
250
+ ## FAQ
251
+
252
+ ## Copyright
253
+ 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}#fs_account_details .button-group{float:right}.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 code{line-height:28px}.fs-key-value-table var,.fs-key-value-table code,.fs-key-value-table input[type="text"]{color:#0073AA;font-size:16px;background:none}.fs-key-value-table input[type="text"]{width:100%;font-weight:bold}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 thead{white-space:nowrap}#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}#fs_billing_address{width:100%}#fs_billing_address tr td{width:50%;padding:5px}#fs_billing_address tr:first-of-type td{padding-top:0}#fs_billing_address span{font-weight:bold}#fs_billing_address input,#fs_billing_address select{display:block;width:100%;margin-top:5px}#fs_billing_address input::-moz-placeholder,#fs_billing_address select::-moz-placeholder{color:transparent;opacity:1}#fs_billing_address input:-ms-input-placeholder,#fs_billing_address select:-ms-input-placeholder{color:transparent}#fs_billing_address input::-webkit-input-placeholder,#fs_billing_address select::-webkit-input-placeholder{color:transparent}#fs_billing_address input.fs-read-mode,#fs_billing_address select.fs-read-mode{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode td span{display:none}#fs_billing_address.fs-read-mode input,#fs_billing_address.fs-read-mode select{border-color:transparent;color:#777;border-bottom:1px dashed #ccc;padding-left:0;background:none}#fs_billing_address.fs-read-mode input::-moz-placeholder,#fs_billing_address.fs-read-mode select::-moz-placeholder{color:#ccc;opacity:1}#fs_billing_address.fs-read-mode input:-ms-input-placeholder,#fs_billing_address.fs-read-mode select:-ms-input-placeholder{color:#ccc}#fs_billing_address.fs-read-mode input::-webkit-input-placeholder,#fs_billing_address.fs-read-mode select::-webkit-input-placeholder{color:#ccc}#fs_billing_address button{display:block;width:100%}
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}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-tag{position:absolute;top:10px;right:0px;background:greenyellow;display:block;padding:2px 10px;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.3);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.3);box-shadow:1px 1px 1px rgba(0,0,0,0.3);text-transform:uppercase;font-size:0.9em;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-cta .button{position:absolute;top:112px;right:10px}@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{margin:-16px;border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan h3{margin-top:0;padding:20px;font-size:16px}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper{border-bottom:1px solid #ddd}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab{cursor:pointer;position:relative;padding:0 10px;font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab label{text-transform:uppercase;color:green;background:greenyellow;position:absolute;left:-1px;right:-1px;bottom:100%;border:1px solid darkgreen;padding:2px;text-align:center;font-size:0.9em;line-height:1em}#plugin-information .plugin-information-pricing .fs-plan .nav-tab-wrapper .nav-tab.nav-tab-active{cursor:default;background:#fffeec;border-bottom-color:#fffeec}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle h3{background:#fffeec;margin:0;padding-bottom:0;color:#0073aa}#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .nav-tab-wrapper,#plugin-information .plugin-information-pricing .fs-plan.fs-single-cycle .fs-billing-frequency{display:none}#plugin-information .plugin-information-pricing .fs-plan .fs-pricing-body{background:#fffeec;padding:20px}#plugin-information .plugin-information-pricing .fs-plan .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing .fs-plan label{white-space:nowrap}#plugin-information .plugin-information-pricing .fs-plan var{font-style:normal}#plugin-information .plugin-information-pricing .fs-plan .fs-billing-frequency,#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-align:center;display:block;font-weight:bold;margin-bottom:10px;text-transform:uppercase;background:#F3F3F3;padding:2px;border:1px solid #ccc}#plugin-information .plugin-information-pricing .fs-plan .fs-annual-discount{text-transform:none;color:green;background:greenyellow}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms{font-size:0.9em}#plugin-information .plugin-information-pricing .fs-plan ul.fs-trial-terms i{float:left;margin:0 0 0 -15px}#plugin-information .plugin-information-pricing .fs-plan 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/checkout.css ADDED
@@ -0,0 +1 @@
 
1
+ @media screen and (max-width: 782px){#wpbody-content{padding-bottom:0 !important}}
freemius/assets/css/admin/common.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ #iframe{line-height:0;font-size:0}.fs-full-size-wrapper{margin:0 0 -65px -20px}@media (max-width: 782px){.fs-full-size-wrapper{margin:0 0 -65px -10px}}
2
+ .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;top:100%;bottom: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: 500px){#fs_promo_tab{display:none}}@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'}.fs-submenu-item.pricing.upgrade-mode{color:greenyellow}.fs-submenu-item.pricing.trial-mode{color:#83e2ff}#adminmenu .update-plugins.fs-trial{background-color:#00b9eb}
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 .fs-error{background:snow;color:#d3135a;border:1px solid #d3135a;-moz-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);box-shadow:0 1px 1px 0 rgba(0,0,0,0.1);text-align:center;padding:5px;margin-bottom:10px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-license-key-container{position:relative;width:280px;margin:10px auto 0 auto}#fs_connect .fs-license-key-container input{width:100%}#fs_connect .fs-license-key-container .dashicons{position:absolute;top:5px;right:5px}#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-license-sync-disclaimer{text-align:center;margin-top:0}#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-freemium-licensing{padding:8px;background:#777;color:#fff}#fs_connect .fs-freemium-licensing p{text-align:center;display:block;margin:0;padding:0}#fs_connect .fs-freemium-licensing a{color:#C2EEFF;text-decoration:underline}#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,.fs-modal .fs-modal-dialog li.reason .internal-message{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,.fs-modal .internal-message{margin:3px 0 3px 22px}.fs-modal .reason-input input,.fs-modal .reason-input textarea,.fs-modal .internal-message input,.fs-modal .internal-message textarea{width:100%}.fs-modal li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}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}#fs_log_book table{font-family:Consolas,Monaco,monospace;font-size:12px}#fs_log_book table th{color:#ccc}#fs_log_book table tr{background:#232525}#fs_log_book table tr.alternate{background:#2b2b2b}#fs_log_book table tr td.fs-col--logger{color:#5a7435}#fs_log_book table tr td.fs-col--type{color:#ffc861}#fs_log_book table tr td.fs-col--function{color:#a7b7b1;font-weight:bold}#fs_log_book table tr td.fs-col--message,#fs_log_book table tr td.fs-col--message a{color:#9a73ac !important}#fs_log_book table tr td.fs-col--file{color:#d07922}#fs_log_book table tr td.fs-col--timestamp{color:#6596be}
freemius/assets/css/admin/dialog-boxes.css ADDED
@@ -0,0 +1,2 @@
 
 
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.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal.fs-success .fs-modal-header{border-bottom-color:#46b450}.fs-modal.fs-success .fs-modal-body{background-color:#f7fff7}.fs-modal.fs-warn .fs-modal-header{border-bottom-color:#ffb900}.fs-modal.fs-warn .fs-modal-body{background-color:#fff8e5}.fs-modal.fs-error .fs-modal-header{border-bottom-color:#dc3232}.fs-modal.fs-error .fs-modal-body{background-color:#ffeaea}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-header{border-bottom:#eeeeee solid 1px;background:#fbfbfb;padding:15px 20px;position:relative;margin-bottom:-10px}.fs-modal .fs-modal-header h4{margin:0;padding:0;text-transform:uppercase;font-size:1.2em;font-weight:bold;color:#cacaca;text-shadow:1px 1px 1px #fff;letter-spacing:0.6px;-webkit-font-smoothing:antialiased}.fs-modal .fs-modal-header .fs-close{position:absolute;right:10px;top:12px;cursor:pointer;color:#bbb;-moz-border-radius:20px;-webkit-border-radius:20px;border-radius:20px;padding:3px;-moz-transition:all 0.2s ease-in-out;-o-transition:all 0.2s ease-in-out;-ms-transition:all 0.2s ease-in-out;-webkit-transition:all 0.2s ease-in-out;transition:all 0.2s ease-in-out}.fs-modal .fs-modal-header .fs-close:hover{color:#fff;background:#aaa}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body p{font-size:14px}.fs-modal .fs-modal-body h2{font-size:20px;line-height:1.5em}.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>.notice.inline{margin:0;display:none}.fs-modal .fs-modal-panel:not(.active){display:none}.rtl .fs-modal .fs-modal-header .fs-close{right:auto;left:20px}body.has-fs-modal{overflow:hidden}.fs-modal.fs-modal-deactivation-feedback .reason-input,.fs-modal.fs-modal-deactivation-feedback .internal-message{margin:3px 0 3px 22px}.fs-modal.fs-modal-deactivation-feedback .reason-input input,.fs-modal.fs-modal-deactivation-feedback .reason-input textarea,.fs-modal.fs-modal-deactivation-feedback .internal-message input,.fs-modal.fs-modal-deactivation-feedback .internal-message textarea{width:100%}.fs-modal.fs-modal-deactivation-feedback li.reason.has-internal-message .internal-message{border:1px solid #ccc;padding:7px;display:none}@media (max-width: 650px){.fs-modal.fs-modal-deactivation-feedback li.reason li.reason{margin-bottom:10px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .reason-input,.fs-modal.fs-modal-deactivation-feedback li.reason li.reason .internal-message{margin-left:29px}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label{display:table}.fs-modal.fs-modal-deactivation-feedback li.reason li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.fs-modal-deactivation-feedback .anonymous-feedback-label{float:left}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel{margin-top:0 !important}.fs-modal.fs-modal-deactivation-feedback .fs-modal-panel h3{margin-top:0;line-height:1.5em}#the-list .deactivate>.fs-slug{display:none}.fs-modal.fs-modal-license-activation .fs-modal-body input.license_key{width:100%}.fs-modal.fs-modal-license-key-resend .email-address-container{overflow:hidden;padding-right:2px}.fs-modal.fs-modal-license-key-resend.fs-freemium input.email-address{width:300px}.fs-modal.fs-modal-license-key-resend.fs-freemium label{display:block;margin-bottom:10px}.fs-modal.fs-modal-license-key-resend.fs-premium input.email-address{width:100%}.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{float:right;margin-left:7px}@media (max-width: 650px){.fs-modal.fs-modal-license-key-resend.fs-premium .button-container{margin-top:2px}}
2
+ .rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .input-container>.email-address-container{padding-left:2px;padding-right:0}.rtl .fs-modal.fs-modal-license-key-resend .fs-modal-body .button-container{float:left;margin-right:7px;margin-left:0}a.show-license-resend-modal{margin-top:4px;display:inline-block}.fs-ajax-loader{position:relative;width:170px;height:20px;margin:auto}.fs-ajax-loader .fs-ajax-loader-bar{position:absolute;top:0;background-color:#0074a3;width:20px;height:20px;-webkit-animation-name:bounce_ajaxLoader;-moz-animation-name:bounce_ajaxLoader;-ms-animation-name:bounce_ajaxLoader;-o-animation-name:bounce_ajaxLoader;animation-name:bounce_ajaxLoader;-webkit-animation-duration:1.5s;-moz-animation-duration:1.5s;-ms-animation-duration:1.5s;-o-animation-duration:1.5s;animation-duration:1.5s;animation-iteration-count:infinite;-o-animation-iteration-count:infinite;-ms-animation-iteration-count:infinite;-webkit-animation-iteration-count:infinite;-moz-animation-iteration-count:infinite;-webkit-animation-direction:normal;-moz-animation-direction:normal;-ms-animation-direction:normal;-o-animation-direction:normal;animation-direction:normal;-moz-transform:0.3;-o-transform:0.3;-ms-transform:0.3;-webkit-transform:0.3;transform:0.3}.fs-ajax-loader .fs-ajax-loader-bar-1{left:0px;animation-delay:0.6s;-o-animation-delay:0.6s;-ms-animation-delay:0.6s;-webkit-animation-delay:0.6s;-moz-animation-delay:0.6s}.fs-ajax-loader .fs-ajax-loader-bar-2{left:19px;animation-delay:0.75s;-o-animation-delay:0.75s;-ms-animation-delay:0.75s;-webkit-animation-delay:0.75s;-moz-animation-delay:0.75s}.fs-ajax-loader .fs-ajax-loader-bar-3{left:38px;animation-delay:0.9s;-o-animation-delay:0.9s;-ms-animation-delay:0.9s;-webkit-animation-delay:0.9s;-moz-animation-delay:0.9s}.fs-ajax-loader .fs-ajax-loader-bar-4{left:57px;animation-delay:1.05s;-o-animation-delay:1.05s;-ms-animation-delay:1.05s;-webkit-animation-delay:1.05s;-moz-animation-delay:1.05s}.fs-ajax-loader .fs-ajax-loader-bar-5{left:76px;animation-delay:1.2s;-o-animation-delay:1.2s;-ms-animation-delay:1.2s;-webkit-animation-delay:1.2s;-moz-animation-delay:1.2s}.fs-ajax-loader .fs-ajax-loader-bar-6{left:95px;animation-delay:1.35s;-o-animation-delay:1.35s;-ms-animation-delay:1.35s;-webkit-animation-delay:1.35s;-moz-animation-delay:1.35s}.fs-ajax-loader .fs-ajax-loader-bar-7{left:114px;animation-delay:1.5s;-o-animation-delay:1.5s;-ms-animation-delay:1.5s;-webkit-animation-delay:1.5s;-moz-animation-delay:1.5s}.fs-ajax-loader .fs-ajax-loader-bar-8{left:133px;animation-delay:1.65s;-o-animation-delay:1.65s;-ms-animation-delay:1.65s;-webkit-animation-delay:1.65s;-moz-animation-delay:1.65s}@-moz-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-ms-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-o-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@-webkit-keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}@keyframes bounce_ajaxLoader{0%{-moz-transform:scale(1);-o-transform:scale(1);-ms-transform:scale(1);-webkit-transform:scale(1);transform:scale(1);background-color:#0074a3}100%{-moz-transform:scale(0.3);-o-transform:scale(0.3);-ms-transform:scale(0.3);-webkit-transform:scale(0.3);transform:scale(0.3);background-color:#fff}}.fs-modal-auto-install #request-filesystem-credentials-form h2,.fs-modal-auto-install #request-filesystem-credentials-form .request-filesystem-credentials-action-buttons{display:none}.fs-modal-auto-install #request-filesystem-credentials-form input[type=password],.fs-modal-auto-install #request-filesystem-credentials-form input[type=email],.fs-modal-auto-install #request-filesystem-credentials-form input[type=text]{-webkit-appearance:none;padding:10px 10px 5px 10px;width:300px;max-width:100%}.fs-modal-auto-install #request-filesystem-credentials-form>div,.fs-modal-auto-install #request-filesystem-credentials-form label,.fs-modal-auto-install #request-filesystem-credentials-form fieldset{width:300px;max-width:100%;margin:0 auto;display:block}
freemius/assets/css/admin/license-activation.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.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 .license-activation-message{margin:0;display:none}.fs-modal .fs-modal-body input.license_key{width:100%}.fs-modal .fs-modal-body p{font-size:14px}.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}body.has-fs-modal{overflow:hidden}
freemius/assets/css/common.css ADDED
@@ -0,0 +1 @@
 
1
+ .fs-notice.success{color:green;font-weight:700}
freemius/assets/img/buttonizer-floating-action-button.png ADDED
Binary file
freemius/assets/img/buttonizer.png ADDED
Binary file
freemius/assets/img/icon.png ADDED
Binary file
freemius/assets/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
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,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ _hasParent = ('' !== _parent_url),
29
+ $window = $(window),
30
+ $html = $('html');
31
+
32
+ return {
33
+ init : function (url, iframes)
34
+ {
35
+ _base_url = url;
36
+ _init();
37
+
38
+ // Automatically receive forward messages.
39
+ FS.PostMessage.receiveOnce('forward', function (data){
40
+ window.location = data.url;
41
+ });
42
+
43
+ iframes = iframes || [];
44
+
45
+ if (iframes.length > 0) {
46
+ $window.on('scroll', function () {
47
+ for (var i = 0; i < iframes.length; i++) {
48
+ FS.PostMessage.postScroll(iframes[i]);
49
+ }
50
+ });
51
+ }
52
+ },
53
+ init_child : function ()
54
+ {
55
+ this.init(_parent_subdomain);
56
+
57
+ _is_child = true;
58
+
59
+ // Post height of a child right after window is loaded.
60
+ $(window).bind('load', function () {
61
+ FS.PostMessage.postHeight();
62
+
63
+ // Post message that window was loaded.
64
+ FS.PostMessage.post('loaded');
65
+ });
66
+ },
67
+ hasParent : function ()
68
+ {
69
+ return _hasParent;
70
+ },
71
+ postHeight : function (diff, wrapper) {
72
+ diff = diff || 0;
73
+ wrapper = wrapper || '#wrap_section';
74
+ this.post('height', {
75
+ height: diff + $(wrapper).outerHeight(true)
76
+ });
77
+ },
78
+ postScroll : function (iframe) {
79
+ this.post('scroll', {
80
+ top: $window.scrollTop(),
81
+ height: ($window.height() - parseFloat($html.css('paddingTop')) - parseFloat($html.css('marginTop')))
82
+ }, iframe);
83
+ },
84
+ post : function (type, data, iframe)
85
+ {
86
+ console.debug('PostMessage.post', type);
87
+
88
+ if (iframe)
89
+ {
90
+ // Post to iframe.
91
+ _postman.postMessage(JSON.stringify({
92
+ type: type,
93
+ data: data
94
+ }), iframe.src, iframe.contentWindow);
95
+ }
96
+ else {
97
+ // Post to parent.
98
+ _postman.postMessage(JSON.stringify({
99
+ type: type,
100
+ data: data
101
+ }), _parent_url, window.parent);
102
+ }
103
+ },
104
+ receive: function (type, callback)
105
+ {
106
+ console.debug('PostMessage.receive', type);
107
+
108
+ if (undef === _callbacks[type])
109
+ _callbacks[type] = [];
110
+
111
+ _callbacks[type].push(callback);
112
+ },
113
+ receiveOnce: function (type, callback)
114
+ {
115
+ if (this.is_set(type))
116
+ return;
117
+
118
+ this.receive(type, callback);
119
+ },
120
+ // Check if any callbacks assigned to a specified message type.
121
+ is_set: function (type)
122
+ {
123
+ return (undef != _callbacks[type]);
124
+ },
125
+ parent_url: function ()
126
+ {
127
+ return _parent_url;
128
+ },
129
+ parent_subdomain: function ()
130
+ {
131
+ return _parent_subdomain;
132
+ }
133
+ };
134
+ }();
135
+ })(jQuery);
freemius/assets/scss/_colors.scss ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ // WordPress colors.
24
+ $page-header-bkg: #333;
25
+ $page-header-color: $fms-white;
26
+ $text-dark-color: #333;
27
+ $text-light-color: #666;
28
+ $text-lightest-color: #999;
29
+
30
+ // Notices.
31
+ $wp-notice-success-color: #f7fff7;
32
+ $wp-notice-success-dark-color: #46b450;
33
+ $wp-notice-error-color: #ffeaea;
34
+ $wp-notice-error-dark-color: #dc3232;
35
+ $wp-notice-warn-color: #fff8e5;
36
+ $wp-notice-warn-dark-color: #ffb900;
37
+ $fs-notice-promotion-border-color: #00a0d2;
38
+ $fs-notice-promotion-bkg: #f2fcff;
39
+
40
+ // WP Buttons.
41
+ $button-primary-bkg: #6bc406;
42
+ $button-primary-color: $fms-white;
43
+ $button-secondary-bkg: #333;
44
+ $button-secondary-color: $fms-white;
45
+ $featured-color: #6bc406;
46
+ $wp-selected-color: #0074a3;
47
+
48
+ $wordpress_color: #01749A;
49
+ $blogger_color: #ff8100;
50
+ $wix_color: #fac102;
51
+ $shopify_color: #80d100;
52
+ $addthis_color: #fe6d4e;
53
+ $tumblr_color: #34506b;
54
+ $zepo_color: #00baf2;
55
+ $jquery_color: #000919;
56
+ $javascript_color: #00baf2;
57
+ $squarespace_color: #000;
58
+
59
+ $blog_color: #ff6600;
60
+ $facebook_color: #3b5998;
61
+ $twitter_color: #4099ff;
62
+ $linkedin_color: #4875b4;
63
+ $youtube_color: #ff3333;
64
+ $gplus_color: #c63d2d;
65
+
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,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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($name){
82
+ @-moz-keyframes #{$name} { @content; }
83
+ @-ms-keyframes #{$name} { @content; }
84
+ @-o-keyframes #{$name} { @content; }
85
+ @-webkit-keyframes #{$name} { @content; }
86
+ @keyframes #{$name} { @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
+ @mixin animation($str) {
196
+ -webkit-animation: #{$str};
197
+ -moz-animation: #{$str};
198
+ -ms-animation: #{$str};
199
+ -o-animation: #{$str};
200
+ animation: #{$str};
201
+ }
202
+
203
+ @mixin animation-name($str) {
204
+ -webkit-animation-name: #{$str};
205
+ -moz-animation-name: #{$str};
206
+ -ms-animation-name: #{$str};
207
+ -o-animation-name: #{$str};
208
+ animation-name: #{$str};
209
+ }
210
+
211
+ @mixin animation-duration($str) {
212
+ -webkit-animation-duration: #{$str};
213
+ -moz-animation-duration: #{$str};
214
+ -ms-animation-duration: #{$str};
215
+ -o-animation-duration: #{$str};
216
+ animation-duration: #{$str};
217
+ }
218
+
219
+ @mixin animation-direction($str) {
220
+ -webkit-animation-direction: #{$str};
221
+ -moz-animation-direction: #{$str};
222
+ -ms-animation-direction: #{$str};
223
+ -o-animation-direction: #{$str};
224
+ animation-direction: #{$str};
225
+ }
226
+
227
+ @mixin animation-delay($str) {
228
+ animation-delay:#{$str};
229
+ -o-animation-delay:#{$str};
230
+ -ms-animation-delay:#{$str};
231
+ -webkit-animation-delay:#{$str};
232
+ -moz-animation-delay:#{$str};
233
+ }
234
+
235
+ @mixin animation-iteration-count($str) {
236
+ animation-iteration-count:#{$str};
237
+ -o-animation-iteration-count:#{$str};
238
+ -ms-animation-iteration-count:#{$str};
239
+ -webkit-animation-iteration-count:#{$str};
240
+ -moz-animation-iteration-count:#{$str};
241
+ }
242
+
243
+ @mixin animation-timing-function($str) {
244
+ -webkit-animation-timing-function: #{$str};
245
+ -moz-animation-timing-function: #{$str};
246
+ -ms-animation-timing-function: #{$str};
247
+ -o-animation-timing-function: #{$str};
248
+ animation-timing-function: #{$str};
249
+ }
250
+
251
+ // ==== /CSS3 SASS MIXINS ====
252
+
253
+ @mixin opacity($opacity) {
254
+ opacity: $opacity;
255
+ $opacity-ie: $opacity * 100;
256
+ filter: alpha(opacity=$opacity-ie); //IE8
257
+ }
258
+
259
+ @mixin size($width, $height: $width)
260
+ {
261
+ width: $width;
262
+ height: $height;
263
+ }
264
+
265
+ @mixin clearfix
266
+ {
267
+ &:after {
268
+ content: "";
269
+ display: table;
270
+ clear: both;
271
+ }
272
+ }
273
+
274
+ // Placeholder text
275
+ @mixin placeholder($color: $input-color-placeholder) {
276
+ // Firefox
277
+ &::-moz-placeholder {
278
+ color: $color;
279
+ opacity: 1; // Override Firefox's unusual default opacity; see https://github.com/twbs/bootstrap/pull/11526
280
+ }
281
+ &:-ms-input-placeholder { color: $color; } // Internet Explorer 10+
282
+ &::-webkit-input-placeholder { color: $color; } // Safari and Chrome
283
+ }
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,6 @@
 
 
 
 
 
 
1
+ $is_production: true;
2
+
3
+ $img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
4
+
5
+ $layout_width: 960px;
6
+ $admin_mobile_max_width: 782px;
freemius/assets/scss/admin/_ajax-loader.scss ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ $color: $wp-selected-color;
2
+ $bkg-color: #fff;
3
+ $size: 20;
4
+
5
+ .fs-ajax-loader
6
+ {
7
+ position: relative;
8
+ width: #{8*$size + 10}px;
9
+ height: #{$size}px;
10
+ margin: auto;
11
+
12
+ .fs-ajax-loader-bar
13
+ {
14
+ position: absolute;
15
+ top: 0;
16
+ background-color: $color;
17
+ width: #{$size}px;
18
+ height: #{$size}px;
19
+ @include animation-name(bounce_ajaxLoader);
20
+ @include animation-duration(1.5s);
21
+ @include animation-iteration-count(infinite);
22
+ @include animation-direction(normal);
23
+ @include transform(.3);
24
+ }
25
+
26
+ @for $i from 0 through 7
27
+ {
28
+ .fs-ajax-loader-bar-#{$i + 1}
29
+ {
30
+ left: #{$i*($size - 1)}px;
31
+ @include animation-delay(#{0.6 + $i*0.15}s);
32
+ }
33
+ }
34
+ }
35
+
36
+ @include keyframes(bounce_ajaxLoader)
37
+ {
38
+ 0%
39
+ {
40
+ @include transform(scale(1));
41
+ background-color: $color;
42
+ }
43
+
44
+ 100%
45
+ {
46
+ @include transform(scale(.3));
47
+ background-color: $bkg-color;
48
+ }
49
+ }
freemius/assets/scss/admin/_auto-install.scss ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-modal-auto-install
2
+ {
3
+ $max-width: 300px;
4
+
5
+ #request-filesystem-credentials-form
6
+ {
7
+ h2,
8
+ .request-filesystem-credentials-action-buttons
9
+ {
10
+ display: none;
11
+ }
12
+
13
+ input[type=password],
14
+ input[type=email],
15
+ input[type=text]
16
+ {
17
+ -webkit-appearance: none;
18
+ padding: 10px 10px 5px 10px;
19
+ width: $max-width;
20
+ max-width: 100%;
21
+ }
22
+
23
+ > div,
24
+ label,
25
+ fieldset
26
+ {
27
+ width: $max-width;
28
+ max-width: 100%;
29
+ margin: 0 auto;
30
+ display: block;
31
+ }
32
+ }
33
+ }
freemius/assets/scss/admin/_deactivation-feedback.scss ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../colors";
2
+
3
+ .fs-modal.fs-modal-deactivation-feedback {
4
+ .reason-input, .internal-message {
5
+ margin: 3px 0 3px 22px;
6
+
7
+ input, textarea {
8
+ width: 100%;
9
+ }
10
+ }
11
+
12
+ li.reason {
13
+ &.has-internal-message .internal-message {
14
+ border: 1px solid lighten($darkest-color, 80%);
15
+ padding: 7px;
16
+ display: none;
17
+ }
18
+
19
+ @media (max-width: 650px) {
20
+ li.reason {
21
+ margin-bottom: 10px;
22
+
23
+ .reason-input, .internal-message {
24
+ margin-left: 29px;
25
+ }
26
+
27
+ label {
28
+ display: table;
29
+
30
+ > span {
31
+ display: table-cell;
32
+ font-size: 1.3em;
33
+ }
34
+ }
35
+ }
36
+ }
37
+ }
38
+
39
+ .anonymous-feedback-label {
40
+ float: left;
41
+ }
42
+
43
+ .fs-modal-panel {
44
+ margin-top: 0 !important;
45
+
46
+ h3 {
47
+ margin-top: 0;
48
+ line-height: 1.5em;
49
+ }
50
+ }
51
+ }
52
+
53
+ #the-list .deactivate > .fs-slug {
54
+ display: none;
55
+ }
freemius/assets/scss/admin/_license-activation.scss ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ .fs-modal.fs-modal-license-activation {
2
+ .fs-modal-body {
3
+ input.license_key {
4
+ width: 100%;
5
+ }
6
+ }
7
+ }
freemius/assets/scss/admin/_license-key-resend.scss ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .fs-modal.fs-modal-license-key-resend
2
+ {
3
+ .email-address-container
4
+ {
5
+ overflow: hidden;
6
+ padding-right: 2px;
7
+ }
8
+
9
+ &.fs-freemium
10
+ {
11
+ input.email-address
12
+ {
13
+ width: 300px;
14
+ }
15
+
16
+ label
17
+ {
18
+ display: block;
19
+ margin-bottom: 10px;
20
+ }
21
+ }
22
+
23
+ &.fs-premium
24
+ {
25
+ input.email-address
26
+ {
27
+ width: 100%;
28
+ }
29
+
30
+ .button-container
31
+ {
32
+ float: right;
33
+ margin-left: 7px;
34
+
35
+ @media (max-width: 650px) {
36
+ margin-top: 2px;
37
+ }
38
+ }
39
+ }
40
+ }
41
+
42
+ .rtl
43
+ {
44
+ .fs-modal.fs-modal-license-key-resend
45
+ {
46
+ .fs-modal-body
47
+ {
48
+ .input-container > .email-address-container
49
+ {
50
+ padding-left: 2px;
51
+ padding-right: 0;
52
+ }
53
+
54
+ .button-container
55
+ {
56
+ float: left;
57
+ margin-right: 7px;
58
+ margin-left: 0;
59
+ }
60
+ }
61
+ }
62
+ }
63
+
64
+ a.show-license-resend-modal
65
+ {
66
+ margin-top: 4px;
67
+ display: inline-block;
68
+ }
freemius/assets/scss/admin/_modal-common.scss ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../colors";
2
+ @import "../mixins";
3
+
4
+ .fs-modal {
5
+ position: fixed;
6
+ overflow: auto;
7
+ height: 100%;
8
+ width: 100%;
9
+ top: 0;
10
+ z-index: 100000;
11
+ display: none;
12
+ background: rgba(0, 0, 0, 0.6);
13
+
14
+ .fs-modal-dialog {
15
+ background: transparent;
16
+ position: absolute;
17
+ left: 50%;
18
+ margin-left: -298px;
19
+ padding-bottom: 30px;
20
+ top: -100%;
21
+ z-index: 100001;
22
+ width: 596px;
23
+
24
+ @media (max-width: 650px) {
25
+ margin-left: -50%;
26
+ box-sizing: border-box;
27
+ padding-left: 10px;
28
+ padding-right: 10px;
29
+ width: 100%;
30
+
31
+ .fs-modal-panel > h3 > strong {
32
+ font-size: 1.3em;
33
+ }
34
+ }
35
+ }
36
+
37
+ &.active {
38
+ display: block;
39
+
40
+ &:before {
41
+ display: block;
42
+ }
43
+
44
+ .fs-modal-dialog {
45
+ top: 10%;
46
+ }
47
+ }
48
+
49
+ &.fs-success {
50
+ .fs-modal-header {
51
+ border-bottom-color: $wp-notice-success-dark-color;
52
+ }
53
+
54
+ .fs-modal-body {
55
+ background-color: $wp-notice-success-color;
56
+ }
57
+ }
58
+
59
+ &.fs-warn {
60
+ .fs-modal-header {
61
+ border-bottom-color: $wp-notice-warn-dark-color;
62
+ }
63
+
64
+ .fs-modal-body {
65
+ background-color: $wp-notice-warn-color;
66
+ }
67
+ }
68
+
69
+ &.fs-error {
70
+ .fs-modal-header {
71
+ border-bottom-color: $wp-notice-error-dark-color;
72
+ }
73
+
74
+ .fs-modal-body {
75
+ background-color: $wp-notice-error-color;
76
+ }
77
+ }
78
+
79
+
80
+ .fs-modal-body,
81
+ .fs-modal-footer {
82
+ border: 0;
83
+ background: #fefefe;
84
+ padding: 20px;
85
+ }
86
+
87
+ .fs-modal-header {
88
+ border-bottom: #eeeeee solid 1px;
89
+ background: #fbfbfb;
90
+ padding: 15px 20px;
91
+ position: relative;
92
+ margin-bottom: -10px;
93
+ // z-index: 2;
94
+
95
+ h4 {
96
+ margin: 0;
97
+ padding: 0;
98
+ text-transform: uppercase;
99
+ font-size: 1.2em;
100
+ font-weight: bold;
101
+ color: #cacaca;
102
+ text-shadow: 1px 1px 1px #fff;
103
+ letter-spacing: 0.6px;
104
+ -webkit-font-smoothing: antialiased;
105
+ }
106
+
107
+ .fs-close {
108
+ position: absolute;
109
+ right: 10px;
110
+ top: 12px;
111
+ cursor: pointer;
112
+ color: #bbb;
113
+ @include border-radius(20px);
114
+ padding: 3px;
115
+ @include transition(all 0.2s ease-in-out);
116
+
117
+ &:hover {
118
+ color: #fff;
119
+ background: #aaa;
120
+ }
121
+ }
122
+ }
123
+
124
+ .fs-modal-body {
125
+ border-bottom: 0;
126
+
127
+ p {
128
+ font-size: 14px;
129
+ }
130
+
131
+ h2 {
132
+ font-size: 20px;
133
+ line-height: 1.5em;
134
+ }
135
+
136
+ > div {
137
+ margin-top: 10px;
138
+
139
+ h2 {
140
+ font-weight: bold;
141
+ font-size: 20px;
142
+ margin-top: 0;
143
+ }
144
+ }
145
+ }
146
+
147
+ .fs-modal-footer {
148
+ border-top: #eeeeee solid 1px;
149
+ text-align: right;
150
+
151
+ > .button {
152
+ margin: 0 7px;
153
+
154
+ &:first-child {
155
+ margin: 0;
156
+ }
157
+ }
158
+ }
159
+
160
+ .fs-modal-panel {
161
+ > .notice.inline {
162
+ margin: 0;
163
+ display: none;
164
+ }
165
+
166
+ &:not(.active) {
167
+ display: none;
168
+ }
169
+ }
170
+ }
171
+
172
+ .rtl
173
+ {
174
+ .fs-modal {
175
+ .fs-modal-header {
176
+ .fs-close {
177
+ right: auto;
178
+ left: 20px;
179
+ }
180
+ }
181
+ }
182
+ }
183
+
184
+ body.has-fs-modal {
185
+ overflow: hidden;
186
+ }
freemius/assets/scss/admin/account.scss ADDED
@@ -0,0 +1,250 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ #fs_account
4
+ {
5
+ .postbox,
6
+ .widefat
7
+ {
8
+ max-width: 700px;
9
+ }
10
+
11
+ h3
12
+ {
13
+ font-size: 1.3em;
14
+ padding: 12px 15px;
15
+ margin: 0 0 12px 0;
16
+ line-height: 1.4;
17
+ border-bottom: 1px solid #F1F1F1;
18
+ }
19
+
20
+ i.dashicons
21
+ {
22
+ font-size: 1.2em;
23
+ height: 1.2em;
24
+ width: 1.2em;
25
+ }
26
+
27
+ .button
28
+ {
29
+ i.dashicons
30
+ {
31
+ vertical-align: middle;
32
+ }
33
+ }
34
+
35
+ .fs-header-actions
36
+ {
37
+ position: absolute;
38
+ top: 17px;
39
+ right: 15px;
40
+ font-size: 0.9em;
41
+
42
+ ul
43
+ {
44
+ margin: 0;
45
+ }
46
+
47
+ li
48
+ {
49
+ form
50
+ {
51
+ display: inline-block;
52
+ }
53
+
54
+ float: left;
55
+ a
56
+ {
57
+ text-decoration: none;
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ #fs_account_details .button-group {
64
+ float: right;
65
+ }
66
+
67
+ .rtl #fs_account .fs-header-actions
68
+ {
69
+ left: 15px;
70
+ right: auto;
71
+ }
72
+
73
+ .fs-key-value-table
74
+ {
75
+ width: 100%;
76
+
77
+ form
78
+ {
79
+ display: inline-block;
80
+ }
81
+
82
+ tr
83
+ {
84
+ td:first-child
85
+ {
86
+ nobr
87
+ {
88
+ font-weight: bold;
89
+ }
90
+
91
+ text-align: right;
92
+
93
+ form
94
+ {
95
+ display: block;
96
+ }
97
+ }
98
+
99
+ td.fs-right
100
+ {
101
+ text-align: right;
102
+ }
103
+
104
+ &.fs-odd
105
+ {
106
+ background: #ebebeb;
107
+ }
108
+ }
109
+
110
+ td, th
111
+ {
112
+ padding: 10px;
113
+ }
114
+
115
+ code {
116
+ line-height: 28px;
117
+ }
118
+
119
+ var, code, input[type="text"]
120
+ {
121
+ color: #0073AA;
122
+ font-size: 16px;
123
+ background: none;
124
+ }
125
+
126
+ input[type="text"] {
127
+ width: 100%;
128
+ font-weight: bold;
129
+ }
130
+ }
131
+
132
+ label.fs-tag
133
+ {
134
+ background: #ffba00;
135
+ color: #fff;
136
+ display: inline-block;
137
+ border-radius: 3px;
138
+ padding: 5px;
139
+ font-size: 11px;
140
+ line-height: 11px;
141
+ vertical-align: baseline;
142
+
143
+ &.fs-warn
144
+ {
145
+ background: #ffba00;
146
+ }
147
+ &.fs-success
148
+ {
149
+ background: #46b450;
150
+ }
151
+ &.fs-error
152
+ {
153
+ background: #dc3232;
154
+ }
155
+ }
156
+
157
+ #fs_addons
158
+ {
159
+ h3
160
+ {
161
+ border: none;
162
+ margin-bottom: 0;
163
+ padding: 4px 5px;
164
+ }
165
+
166
+ td
167
+ {
168
+ vertical-align: middle;
169
+ }
170
+
171
+ thead {
172
+ white-space: nowrap;
173
+ }
174
+
175
+ td:first-child,
176
+ th:first-child
177
+ {
178
+ text-align: left;
179
+ font-weight: bold;
180
+ }
181
+ td:last-child,
182
+ th:last-child
183
+ {
184
+ text-align: right;
185
+ }
186
+ th
187
+ {
188
+ font-weight: bold;
189
+ }
190
+ }
191
+
192
+ #fs_billing_address {
193
+ width: 100%;
194
+
195
+ tr {
196
+ td {
197
+ width: 50%;
198
+ padding: 5px;
199
+ }
200
+
201
+ &:first-of-type {
202
+ td {
203
+ padding-top: 0;
204
+ }
205
+ }
206
+ }
207
+
208
+ @mixin read-mode {
209
+ border-color: transparent;
210
+ color: #777;
211
+ border-bottom: 1px dashed #ccc;
212
+ padding-left: 0;
213
+ background: none;
214
+ }
215
+
216
+ span {
217
+ font-weight: bold;
218
+ }
219
+
220
+ input, select {
221
+ @include placeholder(transparent);
222
+
223
+ display: block;
224
+ width: 100%;
225
+ margin-top: 5px;
226
+
227
+ &.fs-read-mode {
228
+ @include read-mode();
229
+ }
230
+ }
231
+
232
+
233
+ &.fs-read-mode {
234
+ td span {
235
+ display: none;
236
+ }
237
+
238
+ input, select
239
+ {
240
+ @include read-mode();
241
+ @include placeholder(#ccc);
242
+ }
243
+ }
244
+
245
+
246
+ button {
247
+ display: block;
248
+ width: 100%;
249
+ }
250
+ }
freemius/assets/scss/admin/add-ons.scss ADDED
@@ -0,0 +1,449 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ li
50
+ {
51
+ list-style: none;
52
+ line-height: 18px;
53
+ padding: 0 15px;
54
+ width: 100%;
55
+ display: block;
56
+ @include box-sizing(border-box);
57
+ }
58
+
59
+ .fs-card-banner
60
+ {
61
+ padding: 0;
62
+ margin: 0;
63
+ line-height: 0;
64
+ display: block;
65
+ height: 100px;
66
+ background-repeat: repeat-x;
67
+ background-size: 100% 100%;
68
+ @include transition(all, 0.15s);
69
+ }
70
+
71
+ .fs-title
72
+ {
73
+ margin: 10px 0 0 0;
74
+ height: 18px;
75
+ overflow: hidden;
76
+ color: #000;
77
+ white-space: nowrap;
78
+ text-overflow: ellipsis;
79
+ font-weight: bold;
80
+ }
81
+
82
+ .fs-offer
83
+ {
84
+ font-size: 0.9em;
85
+ }
86
+
87
+ .fs-description
88
+ {
89
+ background-color: #f9f9f9;
90
+ padding: 10px 15px 100px 15px;
91
+ border-top: 1px solid #eee;
92
+ margin: 0 0 10px 0;
93
+ color: #777;
94
+ }
95
+
96
+ .fs-tag
97
+ {
98
+ position: absolute;
99
+ top: 10px;
100
+ right: 0px;
101
+ background: greenyellow;
102
+ display: block;
103
+ padding: 2px 10px;
104
+ @include box-shadow(1px 1px 1px rgba(0,0,0,0.3));
105
+ text-transform: uppercase;
106
+ font-size: 0.9em;
107
+ font-weight: bold;
108
+ }
109
+
110
+ .fs-cta
111
+ {
112
+ .button
113
+ {
114
+ position: absolute;
115
+ top: 112px;
116
+ right: 10px;
117
+ }
118
+ }
119
+ }
120
+
121
+ @media screen and (min-width: 960px) {
122
+ &:hover
123
+ {
124
+ .fs-overlay
125
+ {
126
+ border: 2px solid $fms-link-color;
127
+ margin-left: -1px;
128
+ margin-top: -1px;
129
+ }
130
+
131
+ .fs-inner
132
+ {
133
+ ul
134
+ {
135
+ top: -100px;
136
+ }
137
+
138
+ .fs-card-banner
139
+ {
140
+ // background-position: 50% -100px;
141
+ }
142
+
143
+ .fs-title,
144
+ .fs-offer
145
+ {
146
+ color: $fms-link-color;
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ }
153
+ }
154
+
155
+ #TB_window
156
+ {
157
+ &, iframe
158
+ {
159
+ width: 772px !important;
160
+ }
161
+ }
162
+
163
+ #plugin-information
164
+ {
165
+ #section-description
166
+ {
167
+ h2, h3, p, b, i, blockquote, li, ul, ol
168
+ {
169
+ clear: none;
170
+ }
171
+
172
+ .fs-selling-points
173
+ {
174
+ padding-bottom: 10px;
175
+ border-bottom: 1px solid #ddd;
176
+
177
+ ul
178
+ {
179
+ margin: 0;
180
+
181
+ li
182
+ {
183
+ padding: 0;
184
+ list-style: none outside none;
185
+
186
+ i.dashicons
187
+ {
188
+ color: $fs-logo-green-color;
189
+ font-size: 3em;
190
+ vertical-align: middle;
191
+ line-height: 30px;
192
+ float: left;
193
+ margin: 0 0 0 -15px;
194
+ }
195
+
196
+ h3
197
+ {
198
+ margin: 1em 30px !important;
199
+ }
200
+ }
201
+ }
202
+ }
203
+
204
+ .fs-screenshots
205
+ {
206
+ @include clearfix();
207
+ ul
208
+ {
209
+ list-style: none;
210
+ margin: 0;
211
+
212
+ li
213
+ {
214
+ width: 225px;
215
+ height: 225px;
216
+ float: left;
217
+ margin-bottom: 20px;
218
+ @include box-sizing(content-box);
219
+
220
+ a
221
+ {
222
+ display: block;
223
+ width: 100%;
224
+ height: 100%;
225
+ border: 1px solid;
226
+ @include box-shadow(1px 1px 1px rgba(0, 0, 0, 0.2));
227
+ background-size: cover;
228
+ }
229
+
230
+ &.odd
231
+ {
232
+ margin-right: 20px;
233
+ }
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ .plugin-information-pricing
240
+ {
241
+ $pricing_color: #FFFEEC;
242
+ $borders_color: #DDD;
243
+ margin: -16px;
244
+ // padding: 20px;
245
+ border-bottom: 1px solid $borders_color;
246
+
247
+ .fs-plan
248
+ {
249
+
250
+ h3
251
+ {
252
+ margin-top: 0;
253
+ padding: 20px;
254
+ font-size: 16px;
255
+ }
256
+
257
+ .nav-tab-wrapper
258
+ {
259
+ border-bottom: 1px solid $borders_color;
260
+
261
+ .nav-tab
262
+ {
263
+ cursor: pointer;
264
+ position: relative;
265
+ padding: 0 10px;
266
+ font-size: 0.9em;
267
+
268
+ label
269
+ {
270
+ text-transform: uppercase;
271
+ color: green;
272
+ background: greenyellow;
273
+ position: absolute;
274
+ left: -1px;
275
+ right: -1px;
276
+ bottom: 100%;
277
+ border: 1px solid darkgreen;
278
+ padding: 2px;
279
+ text-align: center;
280
+ font-size: 0.9em;
281
+ line-height: 1em;
282
+ }
283
+
284
+ &.nav-tab-active
285
+ {
286
+ cursor: default;
287
+ background: $pricing_color;
288
+ border-bottom-color: $pricing_color;
289
+ }
290
+ }
291
+ }
292
+
293
+ &.fs-single-cycle
294
+ {
295
+ h3
296
+ {
297
+ background: $pricing_color;
298
+ margin: 0;
299
+ padding-bottom: 0;
300
+ color: #0073aa;
301
+ }
302
+
303
+ .nav-tab-wrapper,
304
+ .fs-billing-frequency
305
+ {
306
+ display: none;
307
+ }
308
+ }
309
+
310
+ .fs-pricing-body
311
+ {
312
+ background: $pricing_color;
313
+ padding: 20px;
314
+ }
315
+
316
+ .button
317
+ {
318
+ width: 100%;
319
+ text-align: center;
320
+ font-weight: bold;
321
+ text-transform: uppercase;
322
+ font-size: 1.1em;
323
+ }
324
+
325
+ label
326
+ {
327
+ white-space: nowrap;
328
+ }
329
+
330
+ var {
331
+ font-style: normal;
332
+ }
333
+
334
+ .fs-billing-frequency,
335
+ .fs-annual-discount
336
+ {
337
+ text-align: center;
338
+ display: block;
339
+ font-weight: bold;
340
+ margin-bottom: 10px;
341
+ text-transform: uppercase;
342
+ background: #F3F3F3;
343
+ padding: 2px;
344
+ border: 1px solid #ccc;
345
+ }
346
+
347
+ .fs-annual-discount
348
+ {
349
+ text-transform: none;
350
+ color: green;
351
+ background: greenyellow;
352
+ }
353
+
354
+ ul.fs-trial-terms
355
+ {
356
+ font-size: 0.9em;
357
+
358
+ i
359
+ {
360
+ float: left;
361
+ margin: 0 0 0 -15px;
362
+ }
363
+
364
+ li
365
+ {
366
+ margin: 10px 0 0 0;
367
+ }
368
+ }
369
+ }
370
+ }
371
+
372
+ #section-features
373
+ {
374
+ .fs-features
375
+ {
376
+ margin: -20px -26px;
377
+ }
378
+
379
+ table
380
+ {
381
+ width: 100%;
382
+ border-spacing: 0;
383
+ border-collapse: separate;
384
+
385
+ thead
386
+ {
387
+ th
388
+ {
389
+ padding: 10px 0;
390
+ }
391
+
392
+ .fs-price
393
+ {
394
+ color: $fs-logo-green-color;
395
+ font-weight: normal;
396
+ display: block;
397
+ text-align: center;
398
+ }
399
+ }
400
+
401
+ tbody
402
+ {
403
+ td
404
+ {
405
+ border-top: 1px solid #ccc;
406
+ padding: 10px 0;
407
+ text-align: center;
408
+ width: 100px;
409
+ color: $fs-logo-green-color;
410
+
411
+ &:first-child
412
+ {
413
+ text-align: left;
414
+ width: auto;
415
+ color: inherit;
416
+ padding-left: 26px;
417
+ }
418
+ }
419
+ tr.fs-odd
420
+ {
421
+ td
422
+ {
423
+ background: #fefefe;
424
+ }
425
+ }
426
+ }
427
+ }
428
+
429
+ .dashicons-yes
430
+ {
431
+ width: 30px;
432
+ height: 30px;
433
+ font-size: 30px;
434
+ }
435
+ }
436
+ }
437
+
438
+ @media screen and (max-width: 961px) {
439
+ #fs_addons
440
+ {
441
+ .fs-cards-list
442
+ {
443
+ .fs-card
444
+ {
445
+ height: 265px;
446
+ }
447
+ }
448
+ }
449
+ }
freemius/assets/scss/admin/checkout.scss ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ @media screen and (max-width: 782px) {
2
+ #wpbody-content {
3
+ padding-bottom: 0 !important;
4
+ }
5
+ }
freemius/assets/scss/admin/common.scss ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ @import "../start";
2
+
3
+ #iframe {
4
+ line-height: 0;
5
+ font-size: 0;
6
+ }
7
+
8
+ .fs-full-size-wrapper {
9
+ margin: 0 0 -65px -20px;
10
+
11
+ @media (max-width: $admin_mobile_max_width) {
12
+ margin: 0 0 -65px -10px;
13
+ }
14
+ }
15
+
16
+ .fs-notice
17
+ {
18
+ position: relative;
19
+
20
+ &.fs-has-title
21
+ {
22
+ margin-bottom: 30px !important;
23
+ }
24
+
25
+ &.success
26
+ {
27
+ color: green;
28
+ // font-weight: normal;
29
+ }
30
+
31
+ &.promotion
32
+ {
33
+ border-color: $fs-notice-promotion-border-color !important;
34
+ background-color: $fs-notice-promotion-bkg !important;
35
+ }
36
+
37
+ .fs-notice-body
38
+ {
39
+ margin: .5em 0;
40
+ padding: 2px;
41
+ }
42
+
43
+ .fs-close
44
+ {
45
+ // position: absolute;
46
+ // top: 2px;
47
+ // bottom: 2px;
48
+ // right: 2px;
49
+ // min-width: 100px;
50
+ // text-align: center;
51
+ // padding-right: 2px;
52
+ cursor: pointer;
53
+ color: #aaa;
54
+ float: right;
55
+
56
+ &:hover
57
+ {
58
+ color: #666;
59
+ // background: #A9A9A9;
60
+ }
61
+
62
+ > *
63
+ {
64
+ margin-top: 7px;
65
+ display: inline-block;
66
+ }
67
+ }
68
+
69
+ label.fs-plugin-title
70
+ {
71
+ background: rgba(0, 0, 0, 0.3);
72
+ color: #fff;
73
+ padding: 2px 10px;
74
+ position: absolute;
75
+ top: 100%;
76
+ bottom: auto;
77
+ right: auto;
78
+ @include border-radius(0 0 3px 3px);
79
+ left: 10px;
80
+ font-size: 12px;
81
+ font-weight: bold;
82
+ cursor: auto;
83
+ }
84
+ }
85
+
86
+ .rtl .fs-notice
87
+ {
88
+ .fs-close
89
+ {
90
+ // left: 2px;
91
+ // right: auto;
92
+ // padding-right: 0;
93
+ // padding-left: 2px;
94
+ float: left;
95
+ }
96
+ }
97
+
98
+ .fs-secure-notice
99
+ {
100
+ position: fixed;
101
+ top: 32px;
102
+ left: 160px;
103
+ right: 0;
104
+ background: rgb(235, 253, 235);
105
+ padding: 10px 20px;
106
+ color: green;
107
+ z-index: 9999;
108
+ box-shadow: 0px 2px 2px rgba(6, 113, 6, 0.3);
109
+ @include opacity(0.95);
110
+
111
+ &:hover
112
+ {
113
+ @include opacity(1);
114
+ }
115
+ }
116
+
117
+ @media screen and (max-width: 960px) {
118
+ .fs-secure-notice
119
+ {
120
+ left: 36px;
121
+ }
122
+ }
123
+
124
+ @media screen and (max-width:500px) {
125
+ #fs_promo_tab {
126
+ display: none;
127
+ }
128
+ }
129
+
130
+ @media screen and (max-width: 782px) {
131
+ .fs-secure-notice
132
+ {
133
+ left: 0;
134
+ top: 46px;
135
+ text-align: center;
136
+ }
137
+ }
138
+
139
+ span.fs-submenu-item.fs-sub:before
140
+ {
141
+ // Add small arrow.
142
+ content: '\21B3';
143
+ padding: 0 5px;
144
+ }
145
+
146
+ .rtl
147
+ {
148
+ span.fs-submenu-item.fs-sub:before
149
+ {
150
+ // Add small RTL arrow.
151
+ content: '\21B2';
152
+ }
153
+ }
154
+
155
+ .fs-submenu-item
156
+ {
157
+ &.pricing
158
+ {
159
+ &.upgrade-mode
160
+ {
161
+ color: greenyellow;
162
+ }
163
+
164
+ &.trial-mode
165
+ {
166
+ color: #83e2ff;
167
+ }
168
+ }
169
+ }
170
+
171
+ #adminmenu .update-plugins.fs-trial {
172
+ background-color: #00b9eb;
173
+ }
freemius/assets/scss/admin/connect.scss ADDED
@@ -0,0 +1,471 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ .fs-error {
23
+ background: snow;
24
+ color: $fs-logo-magenta-color;
25
+ border: 1px solid $fs-logo-magenta-color;
26
+ @include box-shadow(0 1px 1px 0 rgba(0,0,0,.1));
27
+ text-align: center;
28
+ padding: 5px;
29
+ margin-bottom: 10px;
30
+ }
31
+
32
+ p
33
+ {
34
+ margin: 0;
35
+ padding: 0;
36
+ font-size: 1.2em;
37
+ }
38
+ }
39
+
40
+ .fs-license-key-container {
41
+ position: relative;
42
+ width: 280px;
43
+ margin: 10px auto 0 auto;
44
+
45
+ input {
46
+ width: 100%;
47
+ }
48
+
49
+ .dashicons {
50
+ position: absolute;
51
+ top: 5px;
52
+ right: 5px;
53
+ }
54
+ }
55
+
56
+ .fs-actions
57
+ {
58
+ padding: 10px 20px;
59
+ background: #C0C7CA;
60
+
61
+ .button
62
+ {
63
+ padding: 0 10px 1px;
64
+ line-height: 35px;
65
+ height: 37px;
66
+ font-size: 16px;
67
+ margin-bottom: 0;
68
+
69
+ .dashicons
70
+ {
71
+ font-size: 37px;
72
+ margin-left: -8px;
73
+ margin-right: 12px;
74
+ }
75
+
76
+ &.button-primary
77
+ {
78
+ padding-right: 15px;
79
+ padding-left: 15px;
80
+
81
+ &:after
82
+ {
83
+ content: ' \279C';
84
+ }
85
+
86
+ &.fs-loading
87
+ {
88
+ &:after
89
+ {
90
+ content: '';
91
+ }
92
+ }
93
+ }
94
+
95
+ &.button-secondary
96
+ {
97
+ float: right;
98
+ }
99
+ }
100
+
101
+ // .fs-skip
102
+ // {
103
+ // line-height: 38px;
104
+ // vertical-align: middle;
105
+ // text-decoration: none;
106
+ // margin-left: 10px;
107
+ // }
108
+ }
109
+
110
+ &.fs-anonymous-disabled
111
+ {
112
+ .fs-actions
113
+ {
114
+ .button.button-primary
115
+ {
116
+ width: 100%;
117
+ }
118
+ }
119
+ }
120
+
121
+ .fs-permissions
122
+ {
123
+ padding: 10px 20px;
124
+ background: #FEFEFE;
125
+ // background: #F1F1F1;
126
+ @include transition(background 0.5s ease);
127
+
128
+ .fs-license-sync-disclaimer {
129
+ text-align: center;
130
+ margin-top: 0;
131
+ }
132
+
133
+ .fs-trigger
134
+ {
135
+ font-size: 0.9em;
136
+ text-decoration: none;
137
+ text-align: center;
138
+ display: block;
139
+ }
140
+
141
+ ul
142
+ {
143
+ height: 0;
144
+ overflow: hidden;
145
+ margin: 0;
146
+
147
+ li
148
+ {
149
+ margin-bottom: 12px;
150
+
151
+ &:last-child
152
+ {
153
+ margin-bottom: 0;
154
+ }
155
+
156
+ i.dashicons
157
+ {
158
+ float: left;
159
+ font-size: 40px;
160
+ width: 40px;
161
+ height: 40px;
162
+ }
163
+
164
+ div
165
+ {
166
+ margin-left: 55px;
167
+
168
+ span
169
+ {
170
+ font-weight: bold;
171
+ text-transform: uppercase;
172
+ color: #23282d;
173
+ }
174
+
175
+ p
176
+ {
177
+ margin: 2px 0 0 0;
178
+ }
179
+ }
180
+ }
181
+ }
182
+
183
+ &.fs-open
184
+ {
185
+ background: #fff;
186
+
187
+ ul
188
+ {
189
+ height: auto;
190
+ margin: 20px 20px 10px 20px;
191
+ }
192
+ }
193
+
194
+ @media screen and (max-width: ($form_width - 1)) {
195
+ background: #fff;
196
+
197
+ .fs-trigger
198
+ {
199
+ display: none;
200
+ }
201
+
202
+ ul
203
+ {
204
+ height: auto;
205
+ margin: 20px;
206
+ }
207
+ }
208
+ }
209
+
210
+ .fs-freemium-licensing {
211
+ padding: 8px;
212
+ // background: #0085BA;
213
+ background: #777;
214
+ color: #fff;
215
+
216
+ p {
217
+ text-align: center;
218
+ display: block;
219
+ margin: 0;
220
+ padding: 0;
221
+ }
222
+
223
+ a {
224
+ color: #C2EEFF;
225
+ text-decoration: underline;
226
+ }
227
+ }
228
+
229
+ $icon_size: 80px;
230
+ $wp_logo_padding: $icon_size / 10;
231
+ $icons_top: 10px;
232
+
233
+ .fs-visual
234
+ {
235
+ padding: 12px;
236
+ line-height: 0;
237
+ background: #fafafa;
238
+ height: $icon_size;
239
+ position: relative;
240
+
241
+ .fs-site-icon
242
+ {
243
+ position: absolute;
244
+ left: 20px;
245
+ top: $icons_top;
246
+ }
247
+
248
+ .fs-connect-logo
249
+ {
250
+ position: absolute;
251
+ right: 20px;
252
+ top: $icons_top;
253
+ }
254
+
255
+ .fs-plugin-icon
256
+ {
257
+ position: absolute;
258
+ top: $icons_top;
259
+ left: 50%;
260
+ margin-left: - ($icon_size / 2);
261
+ }
262
+
263
+ .fs-plugin-icon,
264
+ .fs-site-icon,
265
+ img,
266
+ object
267
+ {
268
+ width: $icon_size;
269
+ height: $icon_size;
270
+ }
271
+
272
+ .dashicons-wordpress
273
+ {
274
+ font-size: $icon_size - ($wp_logo_padding * 2);
275
+ background: $wordpress_color;
276
+ color: #fff;
277
+ width: $icon_size - ($wp_logo_padding * 2);
278
+ height: $icon_size - ($wp_logo_padding * 2);
279
+ padding: $wp_logo_padding;
280
+ }
281
+
282
+ .dashicons-plus
283
+ {
284
+ position: absolute;
285
+ top: 50%;
286
+ font-size: 30px;
287
+ margin-top: -10px;
288
+ color: #bbb;
289
+
290
+ &.fs-first
291
+ {
292
+ left: 28%;
293
+ }
294
+ &.fs-second
295
+ {
296
+ left: 65%;
297
+ }
298
+ }
299
+
300
+ .fs-plugin-icon,
301
+ .fs-connect-logo,
302
+ .fs-site-icon
303
+ {
304
+ border: 1px solid #ccc;
305
+ padding: 1px;
306
+ background: #fff;
307
+ }
308
+ }
309
+
310
+ .fs-terms
311
+ {
312
+ text-align: center;
313
+ font-size: 0.85em;
314
+ padding: 5px;
315
+ background: rgba(0, 0, 0, 0.05);
316
+
317
+ &, a
318
+ {
319
+ color: #999;
320
+ }
321
+
322
+ a
323
+ {
324
+ text-decoration: none;
325
+ }
326
+ }
327
+ }
328
+
329
+ .rtl
330
+ {
331
+ #fs_connect
332
+ {
333
+ .fs-actions
334
+ {
335
+ padding: 10px 20px;
336
+ background: #C0C7CA;
337
+
338
+ .button
339
+ {
340
+ .dashicons
341
+ {
342
+ font-size: 37px;
343
+ margin-left: -8px;
344
+ margin-right: 12px;
345
+ }
346
+
347
+ &.button-primary
348
+ {
349
+ &:after
350
+ {
351
+ content: ' \000bb';
352
+ }
353
+
354
+ &.fs-loading
355
+ {
356
+ &:after
357
+ {
358
+ content: '';
359
+ }
360
+ }
361
+ }
362
+
363
+ &.button-secondary
364
+ {
365
+ float: left;
366
+ }
367
+ }
368
+ }
369
+
370
+ .fs-permissions
371
+ {
372
+ ul
373
+ {
374
+ li
375
+ {
376
+ div
377
+ {
378
+ margin-right: 55px;
379
+ margin-left: 0;
380
+ }
381
+
382
+ i.dashicons
383
+ {
384
+ float: right;
385
+ }
386
+
387
+ }
388
+ }
389
+ }
390
+
391
+ .fs-visual
392
+ {
393
+ .fs-site-icon
394
+ {
395
+ right: 20px;
396
+ left: auto;
397
+ }
398
+
399
+ .fs-connect-logo
400
+ {
401
+ right: auto;
402
+ left: 20px;
403
+ }
404
+ }
405
+ }
406
+ }
407
+
408
+ .wp-pointer-content
409
+ {
410
+ #fs_connect
411
+ {
412
+ margin: 0;
413
+ @include box-shadow(none);
414
+ }
415
+ }
416
+
417
+ .fs-opt-in-pointer
418
+ {
419
+ .wp-pointer-content
420
+ {
421
+ padding: 0;
422
+ }
423
+
424
+ &.wp-pointer-top
425
+ {
426
+ .wp-pointer-arrow
427
+ {
428
+ border-bottom-color: #dfdfdf;
429
+ }
430
+ .wp-pointer-arrow-inner
431
+ {
432
+ border-bottom-color: #fafafa;
433
+ }
434
+ }
435
+
436
+ &.wp-pointer-bottom
437
+ {
438
+ .wp-pointer-arrow
439
+ {
440
+ border-top-color: #dfdfdf;
441
+ }
442
+ .wp-pointer-arrow-inner
443
+ {
444
+ border-top-color: #fafafa;
445
+ }
446
+ }
447
+
448
+ &.wp-pointer-left
449
+ {
450
+ .wp-pointer-arrow
451
+ {
452
+ border-right-color: #dfdfdf;
453
+ }
454
+ .wp-pointer-arrow-inner
455
+ {
456
+ border-right-color: #fafafa;
457
+ }
458
+ }
459
+
460
+ &.wp-pointer-right
461
+ {
462
+ .wp-pointer-arrow
463
+ {
464
+ border-left-color: #dfdfdf;
465
+ }
466
+ .wp-pointer-arrow-inner
467
+ {
468
+ border-left-color: #fafafa;
469
+ }
470
+ }
471
+ }
freemius/assets/scss/admin/debug.scss ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ }
92
+
93
+ #fs_log_book {
94
+ table {
95
+ font-family: Consolas,Monaco,monospace;
96
+ font-size: 12px;
97
+
98
+ th {
99
+ color: #ccc;
100
+ }
101
+
102
+ tr {
103
+ background: #232525;
104
+
105
+ &.alternate {
106
+ background: #2b2b2b;
107
+ }
108
+
109
+ td {
110
+ &.fs-col--logger {
111
+ color: #5a7435;
112
+ }
113
+ &.fs-col--type {
114
+ color: #ffc861;
115
+ }
116
+ &.fs-col--function {
117
+ color: #a7b7b1;
118
+ font-weight: bold;
119
+ }
120
+ &.fs-col--message {
121
+ &, a
122
+ {
123
+ color: #9a73ac !important;
124
+ }
125
+ }
126
+ &.fs-col--file {
127
+ color: #d07922;
128
+ }
129
+ &.fs-col--timestamp {
130
+ color: #6596be;
131
+ }
132
+ }
133
+ }
134
+ }
135
+ }
freemius/assets/scss/admin/dialog-boxes.scss ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ @import "../start";
2
+ @import "modal-common";
3
+ @import "deactivation-feedback";
4
+ @import "license-activation";
5
+ @import "license-key-resend";
6
+ @import "ajax-loader";
7
+ @import "auto-install";
freemius/config.php ADDED
@@ -0,0 +1,327 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if ( ! defined( 'WP_FS__SLUG' ) ) {
14
+ define( 'WP_FS__SLUG', 'freemius' );
15
+ }
16
+ if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
17
+ define( 'WP_FS__DEV_MODE', false );
18
+ }
19
+
20
+ #--------------------------------------------------------------------------------
21
+ #region API Connectivity Issues Simulation
22
+ #--------------------------------------------------------------------------------
23
+
24
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY' ) ) {
25
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false );
26
+ }
27
+ if ( ! defined( 'WP_FS__SIMULATE_NO_CURL' ) ) {
28
+ define( 'WP_FS__SIMULATE_NO_CURL', false );
29
+ }
30
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
31
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
32
+ }
33
+ if ( ! defined( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
34
+ define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
35
+ }
36
+ if ( WP_FS__SIMULATE_NO_CURL ) {
37
+ define( 'FS_SDK__SIMULATE_NO_CURL', true );
38
+ }
39
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
40
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
41
+ }
42
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
43
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
44
+ }
45
+
46
+ #endregion
47
+
48
+ if ( ! defined( 'WP_FS__SIMULATE_FREEMIUS_OFF' ) ) {
49
+ define( 'WP_FS__SIMULATE_FREEMIUS_OFF', false );
50
+ }
51
+
52
+ if ( ! defined( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES' ) ) {
53
+ /**
54
+ * @since 1.1.7.3
55
+ * @author Vova Feldman (@svovaf)
56
+ *
57
+ * I'm not sure if shared servers periodically change IP, or the subdomain of the
58
+ * admin dashboard. Also, I've seen sites that have strange loop of switching
59
+ * between domains on a daily basis. Therefore, to eliminate the risk of
60
+ * multiple unwanted connectivity test pings, temporary ignore domain or
61
+ * server IP changes.
62
+ */
63
+ define( 'WP_FS__PING_API_ON_IP_OR_HOST_CHANGES', false );
64
+ }
65
+
66
+ /**
67
+ * If your dev environment supports custom public network IP setup
68
+ * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
69
+ * and uncomment it during dev.
70
+ */
71
+ if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
72
+ // VVV default public network IP.
73
+ define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
74
+
75
+ // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
76
+ }
77
+
78
+ /**
79
+ * If true and running with secret key, the opt-in process
80
+ * will skip the email activation process which is invoked
81
+ * when the email of the context user already exist in Freemius
82
+ * database (as a security precaution, to prevent sharing user
83
+ * secret with unauthorized entity).
84
+ *
85
+ * IMPORTANT:
86
+ * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
87
+ * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
88
+ * CLOCK IS SYNCED.
89
+ */
90
+ if ( ! defined( 'WP_FS__SKIP_EMAIL_ACTIVATION' ) ) {
91
+ define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
92
+ }
93
+
94
+
95
+ #--------------------------------------------------------------------------------
96
+ #region Directories
97
+ #--------------------------------------------------------------------------------
98
+
99
+ if ( ! defined( 'WP_FS__DIR' ) ) {
100
+ define( 'WP_FS__DIR', dirname( __FILE__ ) );
101
+ }
102
+ if ( ! defined( 'WP_FS__DIR_INCLUDES' ) ) {
103
+ define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
104
+ }
105
+ if ( ! defined( 'WP_FS__DIR_TEMPLATES' ) ) {
106
+ define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
107
+ }
108
+ if ( ! defined( 'WP_FS__DIR_ASSETS' ) ) {
109
+ define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
110
+ }
111
+ if ( ! defined( 'WP_FS__DIR_CSS' ) ) {
112
+ define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
113
+ }
114
+ if ( ! defined( 'WP_FS__DIR_JS' ) ) {
115
+ define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
116
+ }
117
+ if ( ! defined( 'WP_FS__DIR_IMG' ) ) {
118
+ define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
119
+ }
120
+ if ( ! defined( 'WP_FS__DIR_SDK' ) ) {
121
+ define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
122
+ }
123
+
124
+ #endregion
125
+
126
+ /**
127
+ * Domain / URL / Address
128
+ */
129
+ define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
130
+ define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
131
+
132
+ if ( ! defined( 'WP_FS__DOMAIN_LOCALHOST' ) ) {
133
+ define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
134
+ }
135
+ if ( ! defined( 'WP_FS__ADDRESS_LOCALHOST' ) ) {
136
+ define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
137
+ }
138
+
139
+ if ( ! defined( 'WP_FS__TESTING_DOMAIN' ) ) {
140
+ define( 'WP_FS__TESTING_DOMAIN', 'fswp' );
141
+ }
142
+
143
+ #--------------------------------------------------------------------------------
144
+ #region HTTP
145
+ #--------------------------------------------------------------------------------
146
+
147
+ if ( ! defined( 'WP_FS__IS_HTTP_REQUEST' ) ) {
148
+ define( 'WP_FS__IS_HTTP_REQUEST', isset( $_SERVER['HTTP_HOST'] ) );
149
+ }
150
+
151
+ if ( ! defined( 'WP_FS__IS_HTTPS' ) ) {
152
+ define( 'WP_FS__IS_HTTPS', ( WP_FS__IS_HTTP_REQUEST &&
153
+ // Checks if CloudFlare's HTTPS (Flexible SSL support).
154
+ isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) &&
155
+ 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] )
156
+ ) ||
157
+ // Check if HTTPS request.
158
+ ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
159
+ ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
160
+ );
161
+ }
162
+
163
+ if ( ! defined( 'WP_FS__IS_POST_REQUEST' ) ) {
164
+ define( 'WP_FS__IS_POST_REQUEST', ( WP_FS__IS_HTTP_REQUEST &&
165
+ strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
166
+ }
167
+
168
+ if ( ! defined( 'WP_FS__REMOTE_ADDR' ) ) {
169
+ define( 'WP_FS__REMOTE_ADDR', fs_get_ip() );
170
+ }
171
+
172
+ if ( ! defined( 'WP_FS__IS_LOCALHOST' ) ) {
173
+ if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
174
+ define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP === WP_FS__REMOTE_ADDR ) );
175
+ } else {
176
+ define( 'WP_FS__IS_LOCALHOST', WP_FS__IS_HTTP_REQUEST &&
177
+ is_string( WP_FS__REMOTE_ADDR ) &&
178
+ ( substr( WP_FS__REMOTE_ADDR, 0, 4 ) === '127.' ||
179
+ WP_FS__REMOTE_ADDR === '::1' )
180
+ );
181
+ }
182
+ }
183
+
184
+ if ( ! defined( 'WP_FS__IS_LOCALHOST_FOR_SERVER' ) ) {
185
+ define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( ! WP_FS__IS_HTTP_REQUEST ||
186
+ false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
187
+ }
188
+
189
+ #endregion
190
+
191
+ if ( ! defined( 'WP_FS__IS_PRODUCTION_MODE' ) ) {
192
+ // By default, run with Freemius production servers.
193
+ define( 'WP_FS__IS_PRODUCTION_MODE', true );
194
+ }
195
+
196
+ if ( ! defined( 'WP_FS__ADDRESS' ) ) {
197
+ define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
198
+ }
199
+
200
+
201
+ #--------------------------------------------------------------------------------
202
+ #region API
203
+ #--------------------------------------------------------------------------------
204
+
205
+ if ( ! defined( 'WP_FS__API_ADDRESS_LOCALHOST' ) ) {
206
+ define( 'WP_FS__API_ADDRESS_LOCALHOST', 'http://api.freemius:8080' );
207
+ }
208
+ if ( ! defined( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST' ) ) {
209
+ define( 'WP_FS__API_SANDBOX_ADDRESS_LOCALHOST', 'http://sandbox-api.freemius:8080' );
210
+ }
211
+
212
+ // Set API address for local testing.
213
+ if ( ! WP_FS__IS_PRODUCTION_MODE ) {
214
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
215
+ define( 'FS_API__ADDRESS', WP_FS__API_ADDRESS_LOCALHOST );
216
+ }
217
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
218
+ define( 'FS_API__SANDBOX_ADDRESS', WP_FS__API_SANDBOX_ADDRESS_LOCALHOST );
219
+ }
220
+ }
221
+
222
+ #endregion
223
+
224
+ #--------------------------------------------------------------------------------
225
+ #region Checkout
226
+ #--------------------------------------------------------------------------------
227
+
228
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_PRODUCTION' ) ) {
229
+ define( 'FS_CHECKOUT__ADDRESS_PRODUCTION', 'https://checkout.freemius.com' );
230
+ }
231
+
232
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS_LOCALHOST' ) ) {
233
+ define( 'FS_CHECKOUT__ADDRESS_LOCALHOST', 'http://checkout.freemius:8080' );
234
+ }
235
+
236
+ if ( ! defined( 'FS_CHECKOUT__ADDRESS' ) ) {
237
+ define( 'FS_CHECKOUT__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? FS_CHECKOUT__ADDRESS_PRODUCTION : FS_CHECKOUT__ADDRESS_LOCALHOST ) );
238
+ }
239
+
240
+ #endregion
241
+
242
+ define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
243
+
244
+ if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
245
+ define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
246
+ }
247
+ if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
248
+ define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
249
+ }
250
+ define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
251
+
252
+ /**
253
+ * Module types
254
+ *
255
+ * @since 1.2.2
256
+ */
257
+ define( 'WP_FS__MODULE_TYPE_PLUGIN', 'plugin' );
258
+ define( 'WP_FS__MODULE_TYPE_THEME', 'theme' );
259
+
260
+ /**
261
+ * Billing Frequencies
262
+ */
263
+ define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
264
+ define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
265
+ define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
266
+
267
+ /**
268
+ * Plans
269
+ */
270
+ define( 'WP_FS__PLAN_DEFAULT_PAID', false );
271
+ define( 'WP_FS__PLAN_FREE', 'free' );
272
+ define( 'WP_FS__PLAN_TRIAL', 'trial' );
273
+
274
+ /**
275
+ * Times in seconds
276
+ */
277
+ if ( ! defined( 'WP_FS__TIME_5_MIN_IN_SEC' ) ) {
278
+ define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
279
+ }
280
+ if ( ! defined( 'WP_FS__TIME_10_MIN_IN_SEC' ) ) {
281
+ define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
282
+ }
283
+ // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
284
+ if ( ! defined( 'WP_FS__TIME_24_HOURS_IN_SEC' ) ) {
285
+ define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 );
286
+ }
287
+
288
+ #--------------------------------------------------------------------------------
289
+ #region Debugging
290
+ #--------------------------------------------------------------------------------
291
+
292
+ if ( ! defined( 'WP_FS__DEBUG_SDK' ) ) {
293
+ $debug_mode = get_option( 'fs_debug_mode', null );
294
+
295
+ if ( $debug_mode === null ) {
296
+ $debug_mode = false;
297
+ add_option( 'fs_debug_mode', $debug_mode );
298
+ }
299
+
300
+ define( 'WP_FS__DEBUG_SDK', is_numeric( $debug_mode ) ? ( 0 < $debug_mode ) : WP_FS__DEV_MODE );
301
+ }
302
+
303
+ if ( ! defined( 'WP_FS__ECHO_DEBUG_SDK' ) ) {
304
+ define( 'WP_FS__ECHO_DEBUG_SDK', WP_FS__DEV_MODE && ! empty( $_GET['fs_dbg_echo'] ) );
305
+ }
306
+ if ( ! defined( 'WP_FS__LOG_DATETIME_FORMAT' ) ) {
307
+ define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-m-d H:i:s' );
308
+ }
309
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
310
+ define( 'FS_API__LOGGER_ON', WP_FS__DEBUG_SDK );
311
+ }
312
+
313
+ if ( WP_FS__ECHO_DEBUG_SDK ) {
314
+ error_reporting( E_ALL );
315
+ }
316
+
317
+ #endregion
318
+
319
+ if ( ! defined( 'WP_FS__SCRIPT_START_TIME' ) ) {
320
+ define( 'WP_FS__SCRIPT_START_TIME', time() );
321
+ }
322
+ if ( ! defined( 'WP_FS__DEFAULT_PRIORITY' ) ) {
323
+ define( 'WP_FS__DEFAULT_PRIORITY', 10 );
324
+ }
325
+ if ( ! defined( 'WP_FS__LOWEST_PRIORITY' ) ) {
326
+ define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
327
+ }
freemius/includes/class-freemius-abstract.php ADDED
@@ -0,0 +1,597 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
14
+ /**
15
+ * - Each instance of Freemius class represents a single plugin
16
+ * install by a single user (the installer of the plugin).
17
+ *
18
+ * - Each website can only have one install of the same plugin.
19
+ *
20
+ * - Install entity is only created after a user connects his account with Freemius.
21
+ *
22
+ * Class Freemius_Abstract
23
+ */
24
+ abstract class Freemius_Abstract {
25
+
26
+ #----------------------------------------------------------------------------------
27
+ #region Identity
28
+ #----------------------------------------------------------------------------------
29
+
30
+ /**
31
+ * Check if user has connected his account (opted-in).
32
+ *
33
+ * Note:
34
+ * If the user opted-in and opted-out on a later stage,
35
+ * this will still return true. If you want to check if the
36
+ * user is currently opted-in, use:
37
+ * `$fs->is_registered() && $fs->is_tracking_allowed()`
38
+ *
39
+ * @since 1.0.1
40
+ * @return bool
41
+ */
42
+ abstract function is_registered();
43
+
44
+ /**
45
+ * Check if the user skipped connecting the account with Freemius.
46
+ *
47
+ * @since 1.0.7
48
+ *
49
+ * @return bool
50
+ */
51
+ abstract function is_anonymous();
52
+
53
+ /**
54
+ * Check if the user currently in activation mode.
55
+ *
56
+ * @since 1.0.7
57
+ *
58
+ * @return bool
59
+ */
60
+ abstract function is_activation_mode();
61
+
62
+ #endregion
63
+
64
+ #----------------------------------------------------------------------------------
65
+ #region Usage Tracking
66
+ #----------------------------------------------------------------------------------
67
+
68
+ /**
69
+ * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
70
+ *
71
+ * @author Leo Fajardo (@leorw)
72
+ * @since 1.2.1.5
73
+ *
74
+ * @return bool
75
+ */
76
+ abstract function is_tracking_allowed();
77
+
78
+ /**
79
+ * Returns TRUE if the user never opted-in or manually opted-out.
80
+ *
81
+ * @author Vova Feldman (@svovaf)
82
+ * @since 1.2.1.5
83
+ *
84
+ * @return bool
85
+ */
86
+ function is_tracking_prohibited() {
87
+ return ! $this->is_registered() || ! $this->is_tracking_allowed();
88
+ }
89
+
90
+ /**
91
+ * Opt-out from usage tracking.
92
+ *
93
+ * Note: This will not delete the account information but will stop all tracking.
94
+ *
95
+ * Returns:
96
+ * 1. FALSE - If the user never opted-in.
97
+ * 2. TRUE - If successfully opted-out.
98
+ * 3. object - API Result on failure.
99
+ *
100
+ * @author Leo Fajardo (@leorw)
101
+ * @since 1.2.1.5
102
+ *
103
+ * @return bool|object
104
+ */
105
+ abstract function stop_tracking();
106
+
107
+ /**
108
+ * Opt-in back into usage tracking.
109
+ *
110
+ * Note: This will only work if the user opted-in previously.
111
+ *
112
+ * Returns:
113
+ * 1. FALSE - If the user never opted-in.
114
+ * 2. TRUE - If successfully opted-in back to usage tracking.
115
+ * 3. object - API result on failure.
116
+ *
117
+ * @author Leo Fajardo (@leorw)
118
+ * @since 1.2.1.5
119
+ *
120
+ * @return bool|object
121
+ */
122
+ abstract function allow_tracking();
123
+
124
+ #endregion
125
+
126
+ #----------------------------------------------------------------------------------
127
+ #region Module Type
128
+ #----------------------------------------------------------------------------------
129
+
130
+ /**
131
+ * Checks if the plugin's type is "plugin". The other type is "theme".
132
+ *
133
+ * @author Leo Fajardo (@leorw)
134
+ * @since 1.2.2
135
+ *
136
+ * @return bool
137
+ */
138
+ abstract function is_plugin();
139
+
140
+ /**
141
+ * Checks if the module type is "theme". The other type is "plugin".
142
+ *
143
+ * @author Leo Fajardo (@leorw)
144
+ * @since 1.2.2
145
+ *
146
+ * @return bool
147
+ */
148
+ function is_theme() {
149
+ return ( ! $this->is_plugin() );
150
+ }
151
+
152
+ #endregion
153
+
154
+ #----------------------------------------------------------------------------------
155
+ #region Permissions
156
+ #----------------------------------------------------------------------------------
157
+
158
+ /**
159
+ * Check if plugin must be WordPress.org compliant.
160
+ *
161
+ * @since 1.0.7
162
+ *
163
+ * @return bool
164
+ */
165
+ abstract function is_org_repo_compliant();
166
+
167
+ /**
168
+ * Check if plugin is allowed to install executable files.
169
+ *
170
+ * @author Vova Feldman (@svovaf)
171
+ * @since 1.0.5
172
+ *
173
+ * @return bool
174
+ */
175
+ function is_allowed_to_install() {
176
+ return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
177
+ }
178
+
179
+ #endregion
180
+
181
+ /**
182
+ * Check if user in trial or in free plan (not paying).
183
+ *
184
+ * @author Vova Feldman (@svovaf)
185
+ * @since 1.0.4
186
+ *
187
+ * @return bool
188
+ */
189
+ function is_not_paying() {
190
+ return ( $this->is_trial() || $this->is_free_plan() );
191
+ }
192
+
193
+ /**
194
+ * Check if the user has an activated and valid paid license on current plugin's install.
195
+ *
196
+ * @since 1.0.9
197
+ *
198
+ * @return bool
199
+ */
200
+ abstract function is_paying();
201
+
202
+ /**
203
+ * Check if the user is paying or in trial.
204
+ *
205
+ * @since 1.0.9
206
+ *
207
+ * @return bool
208
+ */
209
+ function is_paying_or_trial() {
210
+ return ( $this->is_paying() || $this->is_trial() );
211
+ }
212
+
213
+ /**
214
+ * Check if user in a trial or have feature enabled license.
215
+ *
216
+ * @author Vova Feldman (@svovaf)
217
+ * @since 1.1.7
218
+ *
219
+ * @return bool
220
+ */
221
+ abstract function can_use_premium_code();
222
+
223
+ #----------------------------------------------------------------------------------
224
+ #region Premium Only
225
+ #----------------------------------------------------------------------------------
226
+
227
+ /**
228
+ * All logic wrapped in methods with "__premium_only()" suffix will be only
229
+ * included in the premium code.
230
+ *
231
+ * Example:
232
+ * if ( freemius()->is__premium_only() ) {
233
+ * ...
234
+ * }
235
+ */
236
+
237
+ /**
238
+ * Returns true when running premium plugin code.
239
+ *
240
+ * @since 1.0.9
241
+ *
242
+ * @return bool
243
+ */
244
+ function is__premium_only() {
245
+ return $this->is_premium();
246
+ }
247
+
248
+ /**
249
+ * Check if the user has an activated and valid paid license on current plugin's install.
250
+ *
251
+ * @since 1.0.9
252
+ *
253
+ * @return bool
254
+ *
255
+ */
256
+ function is_paying__premium_only() {
257
+ return ( $this->is__premium_only() && $this->is_paying() );
258
+ }
259
+
260
+ /**
261
+ * All code wrapped in this statement will be only included in the premium code.
262
+ *
263
+ * @since 1.0.9
264
+ *
265
+ * @param string $plan Plan name.
266
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
267
+ *
268
+ * @return bool
269
+ */
270
+ function is_plan__premium_only( $plan, $exact = false ) {
271
+ return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
272
+ }
273
+
274
+ /**
275
+ * Check if plan matches active license' plan or active trial license' plan.
276
+ *
277
+ * All code wrapped in this statement will be only included in the premium code.
278
+ *
279
+ * @since 1.0.9
280
+ *
281
+ * @param string $plan Plan name.
282
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
283
+ *
284
+ * @return bool
285
+ */
286
+ function is_plan_or_trial__premium_only( $plan, $exact = false ) {
287
+ return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
288
+ }
289
+
290
+ /**
291
+ * Check if the user is paying or in trial.
292
+ *
293
+ * All code wrapped in this statement will be only included in the premium code.
294
+ *
295
+ * @since 1.0.9
296
+ *
297
+ * @return bool
298
+ */
299
+ function is_paying_or_trial__premium_only() {
300
+ return $this->is_premium() && $this->is_paying_or_trial();
301
+ }
302
+
303
+ /**
304
+ * Check if the user has an activated and valid paid license on current plugin's install.
305
+ *
306
+ * @since 1.0.4
307
+ *
308
+ * @return bool
309
+ *
310
+ * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
311
+ * @using Alias to is_paying__premium_only()
312
+ */
313
+ function is_paying__fs__() {
314
+ return $this->is_paying__premium_only();
315
+ }
316
+
317
+ /**
318
+ * Check if user in a trial or have feature enabled license.
319
+ *
320
+ * All code wrapped in this statement will be only included in the premium code.
321
+ *
322
+ * @author Vova Feldman (@svovaf)
323
+ * @since 1.1.9
324
+ *
325
+ * @return bool
326
+ */
327
+ function can_use_premium_code__premium_only() {
328
+ return $this->is_premium() && $this->can_use_premium_code();
329
+ }
330
+
331
+ #endregion
332
+
333
+ #----------------------------------------------------------------------------------
334
+ #region Trial
335
+ #----------------------------------------------------------------------------------
336
+
337
+ /**
338
+ * Check if the user in a trial.
339
+ *
340
+ * @since 1.0.3
341
+ *
342
+ * @return bool
343
+ */
344
+ abstract function is_trial();
345
+
346
+ /**
347
+ * Check if trial already utilized.
348
+ *
349
+ * @since 1.0.9
350
+ *
351
+ * @return bool
352
+ */
353
+ abstract function is_trial_utilized();
354
+
355
+ #endregion
356
+
357
+ #----------------------------------------------------------------------------------
358
+ #region Plans
359
+ #----------------------------------------------------------------------------------
360
+
361
+ /**
362
+ * Check if plugin using the free plan.
363
+ *
364
+ * @since 1.0.4
365
+ *
366
+ * @return bool
367
+ */
368
+ abstract function is_free_plan();
369
+
370
+ /**
371
+ * @since 1.0.2
372
+ *
373
+ * @param string $plan Plan name.
374
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
375
+ *
376
+ * @return bool
377
+ */
378
+ abstract function is_plan( $plan, $exact = false );
379
+
380
+ /**
381
+ * Check if plan based on trial. If not in trial mode, should return false.
382
+ *
383
+ * @since 1.0.9
384
+ *
385
+ * @param string $plan Plan name.
386
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
387
+ *
388
+ * @return bool
389
+ */
390
+ abstract function is_trial_plan( $plan, $exact = false );
391
+
392
+ /**
393
+ * Check if plan matches active license' plan or active trial license' plan.
394
+ *
395
+ * @since 1.0.9
396
+ *
397
+ * @param string $plan Plan name.
398
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
399
+ *
400
+ * @return bool
401
+ */
402
+ function is_plan_or_trial( $plan, $exact = false ) {
403
+ return $this->is_plan( $plan, $exact ) ||
404
+ $this->is_trial_plan( $plan, $exact );
405
+ }
406
+
407
+ /**
408
+ * Check if plugin has any paid plans.
409
+ *
410
+ * @author Vova Feldman (@svovaf)
411
+ * @since 1.0.7
412
+ *
413
+ * @return bool
414
+ */
415
+ abstract function has_paid_plan();
416
+
417
+ /**
418
+ * Check if plugin has any free plan, or is it premium only.
419
+ *
420
+ * Note: If no plans configured, assume plugin is free.
421
+ *
422
+ * @author Vova Feldman (@svovaf)
423
+ * @since 1.0.7
424
+ *
425
+ * @return bool
426
+ */
427
+ abstract function has_free_plan();
428
+
429
+ /**
430
+ * Check if plugin is premium only (no free plans).
431
+ *
432
+ * NOTE: is__premium_only() is very different method, don't get confused.
433
+ *
434
+ * @author Vova Feldman (@svovaf)
435
+ * @since 1.1.9
436
+ *
437
+ * @return bool
438
+ */
439
+ abstract function is_only_premium();
440
+
441
+ /**
442
+ * Check if module has a premium code version.
443
+ *
444
+ * Serviceware module might be freemium without any
445
+ * premium code version, where the paid features
446
+ * are all part of the service.
447
+ *
448
+ * @author Vova Feldman (@svovaf)
449
+ * @since 1.2.1.6
450
+ *
451
+ * @return bool
452
+ */
453
+ abstract function has_premium_version();
454
+
455
+ /**
456
+ * Check if module has any release on Freemius,
457
+ * or all plugin's code is on WordPress.org (Serviceware).
458
+ *
459
+ * @return bool
460
+ */
461
+ function has_release_on_freemius() {
462
+ return ! $this->is_org_repo_compliant() ||
463
+ $this->has_premium_version();
464
+ }
465
+
466
+ /**
467
+ * Checks if it's a freemium plugin.
468
+ *
469
+ * @author Vova Feldman (@svovaf)
470
+ * @since 1.1.9
471
+ *
472
+ * @return bool
473
+ */
474
+ function is_freemium() {
475
+ return $this->has_paid_plan() &&
476
+ $this->has_free_plan();
477
+ }
478
+
479
+ /**
480
+ * Check if module has only one plan.
481
+ *
482
+ * @author Vova Feldman (@svovaf)
483
+ * @since 1.2.1.7
484
+ *
485
+ * @return bool
486
+ */
487
+ abstract function is_single_plan();
488
+
489
+ #endregion
490
+
491
+ /**
492
+ * Check if running payments in sandbox mode.
493
+ *
494
+ * @since 1.0.4
495
+ *
496
+ * @return bool
497
+ */
498
+ abstract function is_payments_sandbox();
499
+
500
+ /**
501
+ * Check if running test vs. live plugin.
502
+ *
503
+ * @since 1.0.5
504
+ *
505
+ * @return bool
506
+ */
507
+ abstract function is_live();
508
+
509
+ /**
510
+ * Check if running premium plugin code.
511
+ *
512
+ * @since 1.0.5
513
+ *
514
+ * @return bool
515
+ */
516
+ abstract function is_premium();
517
+
518
+ /**
519
+ * Get upgrade URL.
520
+ *
521
+ * @author Vova Feldman (@svovaf)
522
+ * @since 1.0.2
523
+ *
524
+ * @param string $period Billing cycle.
525
+ *
526
+ * @return string
527
+ */
528
+ abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
529
+
530
+ /**
531
+ * Check if Freemius was first added in a plugin update.
532
+ *
533
+ * @author Vova Feldman (@svovaf)
534
+ * @since 1.1.5
535
+ *
536
+ * @return bool
537
+ */
538
+ function is_plugin_update() {
539
+ return ! $this->is_plugin_new_install();
540
+ }
541
+
542
+ /**
543
+ * Check if Freemius was part of the plugin when the user installed it first.
544
+ *
545
+ * @author Vova Feldman (@svovaf)
546
+ * @since 1.1.5
547
+ *
548
+ * @return bool
549
+ */
550
+ abstract function is_plugin_new_install();
551
+
552
+ #----------------------------------------------------------------------------------
553
+ #region Marketing
554
+ #----------------------------------------------------------------------------------
555
+
556
+ /**
557
+ * Check if current user purchased any other plugins before.
558
+ *
559
+ * @author Vova Feldman (@svovaf)
560
+ * @since 1.0.9
561
+ *
562
+ * @return bool
563
+ */
564
+ abstract function has_purchased_before();
565
+
566
+ /**
567
+ * Check if current user classified as an agency.
568
+ *
569
+ * @author Vova Feldman (@svovaf)
570
+ * @since 1.0.9
571
+ *
572
+ * @return bool
573
+ */
574
+ abstract function is_agency();
575
+
576
+ /**
577
+ * Check if current user classified as a developer.
578
+ *
579
+ * @author Vova Feldman (@svovaf)
580
+ * @since 1.0.9
581
+ *
582
+ * @return bool
583
+ */
584
+ abstract function is_developer();
585
+
586
+ /**
587
+ * Check if current user classified as a business.
588
+ *
589
+ * @author Vova Feldman (@svovaf)
590
+ * @since 1.0.9
591
+ *
592
+ * @return bool
593
+ */
594
+ abstract function is_business();
595
+
596
+ #endregion
597
+ }
freemius/includes/class-freemius.php ADDED
@@ -0,0 +1,12315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.1.9
107
+ * @var bool Hints the SDK if plugin have any free plans.
108
+ */
109
+ private $_is_premium_only;
110
+
111
+ /**
112
+ * @since 1.2.1.6
113
+ * @var bool Hints the SDK if plugin have premium code version at all.
114
+ */
115
+ private $_has_premium_version;
116
+
117
+ /**
118
+ * @since 1.2.1.6
119
+ * @var bool Hints the SDK if plugin should ignore pending mode by simulating a skip.
120
+ */
121
+ private $_ignore_pending_mode;
122
+
123
+ /**
124
+ * @since 1.0.8
125
+ * @var bool Hints the SDK if the plugin has any paid plans.
126
+ */
127
+ private $_has_paid_plans;
128
+
129
+ /**
130
+ * @since 1.2.1.5
131
+ * @var int Hints the SDK if the plugin offers a trial period. If negative, no trial, if zero - has a trial but
132
+ * without a specified period, if positive - the number of trial days.
133
+ */
134
+ private $_trial_days = - 1;
135
+
136
+ /**
137
+ * @since 1.2.1.5
138
+ * @var bool Hints the SDK if the trial requires a payment method or not.
139
+ */
140
+ private $_is_trial_require_payment = false;
141
+
142
+ /**
143
+ * @since 1.0.7
144
+ * @var bool Hints the SDK if the plugin is WordPress.org compliant.
145
+ */
146
+ private $_is_org_compliant;
147
+
148
+ /**
149
+ * @since 1.0.7
150
+ * @var bool Hints the SDK if the plugin is has add-ons.
151
+ */
152
+ private $_has_addons;
153
+
154
+ /**
155
+ * @since 1.1.6
156
+ * @var string[]bool.
157
+ */
158
+ private $_permissions;
159
+
160
+ /**
161
+ * @var FS_Key_Value_Storage
162
+ */
163
+ private $_storage;
164
+
165
+ /**
166
+ * @since 1.0.0
167
+ *
168
+ * @var FS_Logger
169
+ */
170
+ private $_logger;
171
+ /**
172
+ * @since 1.0.4
173
+ *
174
+ * @var FS_Plugin
175
+ */
176
+ private $_plugin = false;
177
+ /**
178
+ * @since 1.0.4
179
+ *
180
+ * @var FS_Plugin|false
181
+ */
182
+ private $_parent_plugin = false;
183
+ /**
184
+ * @since 1.1.1
185
+ *
186
+ * @var Freemius
187
+ */
188
+ private $_parent = false;
189
+ /**
190
+ * @since 1.0.1
191
+ *
192
+ * @var FS_User
193
+ */
194
+ private $_user = false;
195
+ /**
196
+ * @since 1.0.1
197
+ *
198
+ * @var FS_Site
199
+ */
200
+ private $_site = false;
201
+ /**
202
+ * @since 1.0.1
203
+ *
204
+ * @var FS_Plugin_License
205
+ */
206
+ private $_license;
207
+ /**
208
+ * @since 1.0.2
209
+ *
210
+ * @var FS_Plugin_Plan[]
211
+ */
212
+ private $_plans = false;
213
+ /**
214
+ * @var FS_Plugin_License[]
215
+ * @since 1.0.5
216
+ */
217
+ private $_licenses = false;
218
+
219
+ /**
220
+ * @since 1.0.1
221
+ *
222
+ * @var FS_Admin_Menu_Manager
223
+ */
224
+ private $_menu;
225
+
226
+ /**
227
+ * @var FS_Admin_Notice_Manager
228
+ */
229
+ private $_admin_notices;
230
+
231
+ /**
232
+ * @since 1.1.6
233
+ *
234
+ * @var FS_Admin_Notice_Manager
235
+ */
236
+ private static $_global_admin_notices;
237
+
238
+ /**
239
+ * @var FS_Logger
240
+ * @since 1.0.0
241
+ */
242
+ private static $_static_logger;
243
+
244
+ /**
245
+ * @var FS_Option_Manager
246
+ * @since 1.0.2
247
+ */
248
+ private static $_accounts;
249
+
250
+ /**
251
+ * @var Freemius[]
252
+ */
253
+ private static $_instances = array();
254
+
255
+ #region Uninstall Reasons IDs
256
+
257
+ const REASON_NO_LONGER_NEEDED = 1;
258
+ const REASON_FOUND_A_BETTER_PLUGIN = 2;
259
+ const REASON_NEEDED_FOR_A_SHORT_PERIOD = 3;
260
+ const REASON_BROKE_MY_SITE = 4;
261
+ const REASON_SUDDENLY_STOPPED_WORKING = 5;
262
+ const REASON_CANT_PAY_ANYMORE = 6;
263
+ const REASON_OTHER = 7;
264
+ const REASON_DIDNT_WORK = 8;
265
+ const REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION = 9;
266
+ const REASON_COULDNT_MAKE_IT_WORK = 10;
267
+ const REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE = 11;
268
+ const REASON_NOT_WORKING = 12;
269
+ const REASON_NOT_WHAT_I_WAS_LOOKING_FOR = 13;
270
+ const REASON_DIDNT_WORK_AS_EXPECTED = 14;
271
+ const REASON_TEMPORARY_DEACTIVATION = 15;
272
+
273
+ #endregion
274
+
275
+ /* Ctor
276
+ ------------------------------------------------------------------------------------------------------------------*/
277
+
278
+ /**
279
+ * Main singleton instance.
280
+ *
281
+ * @author Vova Feldman (@svovaf)
282
+ * @since 1.0.0
283
+ *
284
+ * @param string $slug
285
+ * @param bool $is_init Since 1.2.1 Is initiation sequence.
286
+ */
287
+ private function __construct( $slug, $is_init = false ) {
288
+ $this->_slug = $slug;
289
+
290
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
291
+
292
+ $this->_storage = FS_Key_Value_Storage::instance( 'plugin_data', $this->_slug );
293
+
294
+ $this->_plugin_main_file_path = $this->_find_caller_plugin_file( $is_init );
295
+ $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
296
+ $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
297
+ $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
298
+
299
+ $base_name_split = explode( '/', $this->_plugin_basename );
300
+ $this->_plugin_dir_name = $base_name_split[0];
301
+
302
+ if ( $this->_logger->is_on() ) {
303
+ $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
304
+ $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
305
+ $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
306
+ $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
307
+ $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
308
+ }
309
+
310
+ // Remember link between file to slug.
311
+ $this->store_file_slug_map();
312
+
313
+ // Store plugin's initial install timestamp.
314
+ if ( ! isset( $this->_storage->install_timestamp ) ) {
315
+ $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
316
+ }
317
+
318
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->get();
319
+
320
+ $this->_admin_notices = FS_Admin_Notice_Manager::instance(
321
+ $slug,
322
+ is_object( $this->_plugin ) ? $this->_plugin->title : ''
323
+ );
324
+
325
+ if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ||
326
+ 'true' === fs_request_is_action( 'restart_freemius' )
327
+ ) {
328
+ FS_Api::clear_cache();
329
+ }
330
+
331
+ $this->_register_hooks();
332
+
333
+ $this->_load_account();
334
+
335
+ $this->_version_updates_handler();
336
+ }
337
+
338
+ /**
339
+ * Checks whether this plugin or theme has settings menu.
340
+ *
341
+ * @author Leo Fajardo (@leorw)
342
+ * @since 1.2.2
343
+ *
344
+ * @return bool
345
+ */
346
+ function has_settings_menu() {
347
+ /**
348
+ * At the moment the wp.org require to show the opt-in in
349
+ * the themes page. Therefore, if the theme is .org compliant,
350
+ * treat it as if it doesn't have a menu item.
351
+ */
352
+ if ( $this->is_theme() && $this->is_org_repo_compliant() ) {
353
+ return false;
354
+ }
355
+
356
+ return $this->_menu->has_menu();
357
+ }
358
+
359
+ /**
360
+ * Checks whether this a submenu item is visible.
361
+ *
362
+ * @author Vova Feldman (@svovaf)
363
+ * @since 1.2.2.6
364
+ *
365
+ * @param string $slug
366
+ *
367
+ * @return bool
368
+ */
369
+ function is_submenu_item_visible( $slug ) {
370
+ if ( ! $this->has_settings_menu() ) {
371
+ return false;
372
+ }
373
+
374
+ return $this->_menu->is_submenu_item_visible( $slug );
375
+ }
376
+
377
+ /**
378
+ * @author Vova Feldman (@svovaf)
379
+ * @since 1.0.9
380
+ */
381
+ private function _version_updates_handler() {
382
+ if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
383
+ // Freemius version upgrade mode.
384
+ $this->_storage->sdk_last_version = $this->_storage->sdk_version;
385
+ $this->_storage->sdk_version = $this->version;
386
+
387
+ if ( empty( $this->_storage->sdk_last_version ) ||
388
+ version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
389
+ ) {
390
+ $this->_storage->sdk_upgrade_mode = true;
391
+ $this->_storage->sdk_downgrade_mode = false;
392
+ } else {
393
+ $this->_storage->sdk_downgrade_mode = true;
394
+ $this->_storage->sdk_upgrade_mode = false;
395
+
396
+ }
397
+
398
+ $this->do_action( 'sdk_version_update', $this->_storage->sdk_last_version, $this->version );
399
+ }
400
+
401
+ $plugin_version = $this->get_plugin_version();
402
+ if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
403
+ // Plugin version upgrade mode.
404
+ $this->_storage->plugin_last_version = $this->_storage->plugin_version;
405
+ $this->_storage->plugin_version = $plugin_version;
406
+
407
+ if ( empty( $this->_storage->plugin_last_version ) ||
408
+ version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
409
+ ) {
410
+ $this->_storage->plugin_upgrade_mode = true;
411
+ $this->_storage->plugin_downgrade_mode = false;
412
+ } else {
413
+ $this->_storage->plugin_downgrade_mode = true;
414
+ $this->_storage->plugin_upgrade_mode = false;
415
+ }
416
+
417
+ if ( ! empty( $this->_storage->plugin_last_version ) ) {
418
+ // Different version of the plugin was installed before, therefore it's an update.
419
+ $this->_storage->is_plugin_new_install = false;
420
+ }
421
+
422
+ $this->do_action( 'plugin_version_update', $this->_storage->plugin_last_version, $plugin_version );
423
+ }
424
+ }
425
+
426
+ /**
427
+ * @author Vova Feldman (@svovaf)
428
+ * @since 1.1.5
429
+ *
430
+ * @param string $sdk_prev_version
431
+ * @param string $sdk_version
432
+ */
433
+ function _data_migration( $sdk_prev_version, $sdk_version ) {
434
+ /**
435
+ * @since 1.1.7.3 Fixed unwanted connectivity test cleanup.
436
+ */
437
+ if ( empty( $sdk_prev_version ) ) {
438
+ return;
439
+ }
440
+
441
+ if ( version_compare( $sdk_prev_version, '1.1.5', '<' ) &&
442
+ version_compare( $sdk_version, '1.1.5', '>=' )
443
+ ) {
444
+ // On version 1.1.5 merged connectivity and is_on data.
445
+ if ( isset( $this->_storage->connectivity_test ) ) {
446
+ if ( ! isset( $this->_storage->is_on ) ) {
447
+ unset( $this->_storage->connectivity_test );
448
+ } else {
449
+ $connectivity_data = $this->_storage->connectivity_test;
450
+ $connectivity_data['is_active'] = $this->_storage->is_on['is_active'];
451
+ $connectivity_data['timestamp'] = $this->_storage->is_on['timestamp'];
452
+
453
+ // Override.
454
+ $this->_storage->connectivity_test = $connectivity_data;
455
+
456
+ // Remove previous structure.
457
+ unset( $this->_storage->is_on );
458
+ }
459
+
460
+ }
461
+ }
462
+ }
463
+
464
+ /**
465
+ * This action is connected to the 'plugins_loaded' hook and helps to determine
466
+ * if this is a new plugin installation or a plugin update.
467
+ *
468
+ * There are 3 different use-cases:
469
+ * 1) New plugin installation right with Freemius:
470
+ * 1.1 _activate_plugin_event_hook() will be executed first
471
+ * 1.2 Since $this->_storage->is_plugin_new_install is not set,
472
+ * and $this->_storage->plugin_last_version is not set,
473
+ * $this->_storage->is_plugin_new_install will be set to TRUE.
474
+ * 1.3 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
475
+ * be already set to TRUE.
476
+ *
477
+ * 2) Plugin update, didn't have Freemius before, and now have the SDK:
478
+ * 2.1 _activate_plugin_event_hook() will not be executed, because
479
+ * the activation hook do NOT fires on updates since WP 3.1.
480
+ * 2.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install will
481
+ * be empty, therefore, it will be set to FALSE.
482
+ *
483
+ * 3) Plugin update, had Freemius in prev version as well:
484
+ * 3.1 _version_updates_handler() will be executed 1st, since FS was installed
485
+ * before, $this->_storage->plugin_last_version will NOT be empty,
486
+ * therefore, $this->_storage->is_plugin_new_install will be set to FALSE.
487
+ * 3.2 When _plugins_loaded() will be executed, $this->_storage->is_plugin_new_install is
488
+ * already set, therefore, it will not be modified.
489
+ *
490
+ * Use-case #3 is backward compatible, #3.1 will be executed since 1.0.9.
491
+ *
492
+ * NOTE:
493
+ * The only fallback of this mechanism is if an admin updates a plugin based on use-case #2,
494
+ * and then, the next immediate PageView is the plugin's main settings page, it will not
495
+ * show the opt-in right away. The reason it will happen is because Freemius execution
496
+ * will be turned off till the plugin is fully loaded at least once
497
+ * (till $this->_storage->was_plugin_loaded is TRUE).
498
+ *
499
+ * @author Vova Feldman (@svovaf)
500
+ * @since 1.1.9
501
+ *
502
+ */
503
+ function _plugins_loaded() {
504
+ // Update flag that plugin was loaded with Freemius at least once.
505
+ $this->_storage->was_plugin_loaded = true;
506
+
507
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
508
+ $this->_storage->is_plugin_new_install = false;
509
+ }
510
+ }
511
+
512
+ /**
513
+ * @author Vova Feldman (@svovaf)
514
+ * @since 1.0.9
515
+ */
516
+ private function _register_hooks() {
517
+ $this->_logger->entrance();
518
+
519
+ if ( is_admin() ) {
520
+ $plugin_dir = dirname( $this->_plugin_dir_path ) . '/';
521
+
522
+ /**
523
+ * @since 1.2.2
524
+ *
525
+ * Hook to both free and premium version activations to support
526
+ * auto deactivation on the other version activation.
527
+ */
528
+ register_activation_hook(
529
+ $plugin_dir . $this->_free_plugin_basename,
530
+ array( &$this, '_activate_plugin_event_hook' )
531
+ );
532
+ register_activation_hook(
533
+ $plugin_dir . $this->premium_plugin_basename(),
534
+ array( &$this, '_activate_plugin_event_hook' )
535
+ );
536
+
537
+ /**
538
+ * Part of the mechanism to identify new plugin install vs. plugin update.
539
+ *
540
+ * @author Vova Feldman (@svovaf)
541
+ * @since 1.1.9
542
+ */
543
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
544
+ if ( $this->is_activation_mode( false ) ) {
545
+ add_action( 'plugins_loaded', array( &$this, '_plugins_loaded' ) );
546
+ } else {
547
+ // If was activated before, then it was already loaded before.
548
+ $this->_plugins_loaded();
549
+ }
550
+ }
551
+
552
+ if ( ! self::is_ajax() ) {
553
+ if ( ! $this->is_addon() ) {
554
+ add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
555
+ add_action( 'admin_menu', array( &$this, '_prepare_admin_menu' ), WP_FS__LOWEST_PRIORITY );
556
+ }
557
+ }
558
+ }
559
+
560
+ register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
561
+
562
+ add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
563
+
564
+ add_action( 'admin_init', array( &$this, '_add_tracking_links' ) );
565
+ add_action( 'admin_init', array( &$this, '_add_license_activation' ) );
566
+ $this->add_ajax_action( 'update_billing', array( &$this, '_update_billing_ajax_action' ) );
567
+ $this->add_ajax_action( 'start_trial', array( &$this, '_start_trial_ajax_action' ) );
568
+
569
+ $this->add_ajax_action( 'install_premium_version', array(
570
+ &$this,
571
+ '_install_premium_version_ajax_action'
572
+ ) );
573
+
574
+ $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
575
+
576
+ $this->add_action( 'sdk_version_update', array( &$this, '_data_migration' ), WP_FS__DEFAULT_PRIORITY, 2 );
577
+
578
+ add_action( 'admin_init', array( &$this, '_add_trial_notice' ) );
579
+ add_action( 'admin_init', array( &$this, '_enqueue_common_css' ) );
580
+
581
+ /**
582
+ * Handle request to reset anonymous mode for `get_reconnect_url()`.
583
+ *
584
+ * @author Vova Feldman (@svovaf)
585
+ * @since 1.2.1.5
586
+ */
587
+ if ( fs_request_is_action( 'reset_anonymous_mode' ) &&
588
+ $this->_slug === fs_request_get( 'fs_slug' )
589
+ ) {
590
+ add_action( 'admin_init', array( &$this, 'connect_again' ) );
591
+ }
592
+ }
593
+
594
+ /**
595
+ * Keeping the uninstall hook registered for free or premium plugin version may result to a fatal error that
596
+ * could happen when a user tries to uninstall either version while one of them is still active. Uninstalling a
597
+ * plugin will trigger inclusion of the free or premium version and if one of them is active during the
598
+ * uninstallation, a fatal error may occur in case the plugin's class or functions are already defined.
599
+ *
600
+ * @author Leo Fajardo (leorw)
601
+ *
602
+ * @since 1.2.0
603
+ */
604
+ private function unregister_uninstall_hook() {
605
+ $uninstallable_plugins = (array) get_option( 'uninstall_plugins' );
606
+ unset( $uninstallable_plugins[ $this->_free_plugin_basename ] );
607
+ unset( $uninstallable_plugins[ $this->premium_plugin_basename() ] );
608
+
609
+ update_option( 'uninstall_plugins', $uninstallable_plugins );
610
+ }
611
+
612
+ /**
613
+ * @since 1.2.0 Invalidate module's main file cache, otherwise, FS_Plugin_Updater will not fetch updates.
614
+ */
615
+ private function clear_module_main_file_cache() {
616
+ if ( ! isset( $this->_storage->plugin_main_file ) ||
617
+ empty( $this->_storage->plugin_main_file->path )
618
+ ) {
619
+ return;
620
+ }
621
+
622
+ $plugin_main_file = clone $this->_storage->plugin_main_file;
623
+
624
+ // Store cached path (2nd layer cache).
625
+ $plugin_main_file->prev_path = $plugin_main_file->path;
626
+
627
+ // Clear cached path.
628
+ unset( $plugin_main_file->path );
629
+
630
+ $this->_storage->plugin_main_file = $plugin_main_file;
631
+ }
632
+
633
+ /**
634
+ * @author Vova Feldman (@svovaf)
635
+ * @since 1.0.9
636
+ */
637
+ private function _register_account_hooks() {
638
+ if ( ! is_admin() ) {
639
+ return;
640
+ }
641
+
642
+ /**
643
+ * Always show the deactivation feedback form since we added
644
+ * automatic free version deactivation upon premium code activation.
645
+ *
646
+ * @since 1.2.1.6
647
+ */
648
+ $this->add_ajax_action(
649
+ 'submit_uninstall_reason',
650
+ array( &$this, '_submit_uninstall_reason_action' )
651
+ );
652
+
653
+ if ( $this->is_plugins_page() ) {
654
+ add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
655
+ }
656
+
657
+ if ( ! $this->is_addon() ) {
658
+ if ( $this->is_registered() ) {
659
+ $this->add_filter( 'after_code_type_change', array( &$this, '_after_code_type_change' ) );
660
+ }
661
+ }
662
+ }
663
+
664
+ /**
665
+ * Leverage backtrace to find caller plugin file path.
666
+ *
667
+ * @author Vova Feldman (@svovaf)
668
+ * @since 1.0.6
669
+ *
670
+ * @param bool $is_init Is initiation sequence.
671
+ *
672
+ * @return string
673
+ *
674
+ * @uses fs_find_caller_plugin_file
675
+ */
676
+ private function _find_caller_plugin_file( $is_init = false ) {
677
+ // Try to load the cached value of the file path.
678
+ if ( isset( $this->_storage->plugin_main_file ) ) {
679
+ $plugin_main_file = $this->_storage->plugin_main_file;
680
+ if ( isset( $plugin_main_file->path ) && file_exists( $plugin_main_file->path ) ) {
681
+ return $plugin_main_file->path;
682
+ }
683
+ }
684
+
685
+ /**
686
+ * @since 1.2.1
687
+ *
688
+ * `clear_module_main_file_cache()` is clearing the plugin's cached path on
689
+ * deactivation. Therefore, if any plugin/theme was initiating `Freemius`
690
+ * with that plugin's slug, it was overriding the empty plugin path with a wrong path.
691
+ *
692
+ * So, we've added a special mechanism with a 2nd layer of cache that uses `prev_path`
693
+ * when the class instantiator isn't the module.
694
+ */
695
+ if ( ! $is_init ) {
696
+ // Fetch prev path cache.
697
+ if ( isset( $this->_storage->plugin_main_file ) &&
698
+ isset( $this->_storage->plugin_main_file->prev_path )
699
+ ) {
700
+ if ( file_exists( $this->_storage->plugin_main_file->prev_path ) ) {
701
+ return $this->_storage->plugin_main_file->prev_path;
702
+ }
703
+ }
704
+
705
+ wp_die(
706
+ $this->get_text( 'failed-finding-main-path' ) .
707
+ " Module: {$this->_slug}; SDK: " . WP_FS__SDK_VERSION . ";",
708
+ $this->get_text( 'error' ),
709
+ array( 'back_link' => true )
710
+ );
711
+ }
712
+
713
+ /**
714
+ * @since 1.2.1
715
+ *
716
+ * Only the original instantiator that calls dynamic_init can modify the module's path.
717
+ */
718
+ // Find caller module.
719
+ $file_and_type = $this->get_caller_main_file_and_type();
720
+ $plugin_file = $file_and_type->path;
721
+
722
+ $this->_storage->plugin_main_file = (object) array(
723
+ 'path' => fs_normalize_path( $plugin_file ),
724
+ );
725
+
726
+ return $plugin_file;
727
+ }
728
+
729
+ /**
730
+ * Identifies the caller path.
731
+ *
732
+ * @todo (Vova) When merging this branch with the theme's one, use the theme's one instead of this one.
733
+ *
734
+ * @author Leo Fajardo (@leorw)
735
+ * @since 1.2.2
736
+ *
737
+ * @author Vova Feldman (@svovaf)
738
+ * @since 1.2.2.3 Find the earliest module in the call stack that calls to the SDK. This fix is for cases
739
+ * when add-ons are relying on loading the SDK from the parent module, and also allows themes
740
+ * including the SDK an internal file instead of directly from functions.php.
741
+ * @since 1.2.1.7 Knows how to handle cases when an add-on includes the parent module logic.
742
+ */
743
+ private function get_caller_main_file_and_type() {
744
+ self::require_plugin_essentials();
745
+
746
+ $all_plugins = get_plugins();
747
+ $all_plugins_paths = array();
748
+
749
+ // Get active plugin's main files real full names (might be symlinks).
750
+ foreach ( $all_plugins as $relative_path => &$data ) {
751
+ if ( false === strpos( fs_normalize_path( $relative_path ), '/' ) ) {
752
+ /**
753
+ * Ignore plugins that don't have a folder (e.g. Hello Dolly) since they
754
+ * can't really include the SDK.
755
+ *
756
+ * @author Vova Feldman
757
+ * @since 1.2.1.7
758
+ */
759
+ continue;
760
+ }
761
+
762
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
763
+ }
764
+
765
+ $caller_file_candidate = false;
766
+ $caller_map = array();
767
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
768
+
769
+ for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
770
+ if ( empty( $bt[ $i ]['file'] ) ) {
771
+ continue;
772
+ }
773
+
774
+ if ( $i > 1 && ! empty( $bt[ $i - 1 ]['file'] ) && $bt[ $i ]['file'] === $bt[ $i - 1 ]['file'] ) {
775
+ // If file same as the prev file in the stack, skip it.
776
+ continue;
777
+ }
778
+
779
+ if ( ! empty( $bt[ $i ]['function'] ) && in_array( $bt[ $i ]['function'], array(
780
+ 'do_action',
781
+ 'apply_filter',
782
+ 'require_once',
783
+ 'require',
784
+ 'include_once',
785
+ 'include'
786
+ ) )
787
+ ) {
788
+ // Ignore call stack hooks and files inclusion.
789
+ continue;
790
+ }
791
+
792
+ $caller_file_path = fs_normalize_path( $bt[ $i ]['file'] );
793
+ $caller_file_hash = md5( $caller_file_path );
794
+
795
+ if ( ! isset( $caller_map[ $caller_file_hash ] ) ) {
796
+ foreach ( $all_plugins_paths as $plugin_path ) {
797
+ if ( false !== strpos( $caller_file_path, fs_normalize_path( dirname( $plugin_path ) . '/' ) ) ) {
798
+ $caller_map[ $caller_file_hash ] = fs_normalize_path( $plugin_path );
799
+ break;
800
+ }
801
+ }
802
+ }
803
+
804
+ if ( isset( $caller_map[ $caller_file_hash ] ) ) {
805
+ $module_type = WP_FS__MODULE_TYPE_PLUGIN;
806
+ $caller_file_candidate = $caller_map[ $caller_file_hash ];
807
+ }
808
+ }
809
+
810
+ if ( empty( $caller_file_candidate ) ) {
811
+ // Throw an error to the developer in case of some edge case dev environment.
812
+ wp_die( $this->get_text( 'failed-finding-main-path' ), $this->get_text( 'error' ), array( 'back_link' => true ) );
813
+ }
814
+
815
+ return (object) array(
816
+ 'module_type' => $module_type,
817
+ 'path' => $caller_file_candidate
818
+ );
819
+ }
820
+
821
+ #----------------------------------------------------------------------------------
822
+ #region Deactivation Feedback Form
823
+ #----------------------------------------------------------------------------------
824
+
825
+ /**
826
+ * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
827
+ * page.
828
+ *
829
+ * @author Vova Feldman (@svovaf)
830
+ * @author Leo Fajardo (@leorw)
831
+ * @since 1.1.2
832
+ */
833
+ function _add_deactivation_feedback_dialog_box() {
834
+ /* Check the type of user:
835
+ * 1. Long-term (long-term)
836
+ * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
837
+ * 3. Short-term (short-term)
838
+ */
839
+ $is_long_term_user = true;
840
+
841
+ // Check if the site is at least 2 days old.
842
+ $time_installed = $this->_storage->install_timestamp;
843
+
844
+ // Difference in seconds.
845
+ $date_diff = time() - $time_installed;
846
+
847
+ // Convert seconds to days.
848
+ $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
849
+
850
+ if ( $date_diff_days < 2 ) {
851
+ $is_long_term_user = false;
852
+ }
853
+
854
+ $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
855
+
856
+ if ( $is_long_term_user ) {
857
+ $user_type = 'long-term';
858
+ } else {
859
+ if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
860
+ $user_type = 'non-registered-and-non-anonymous-short-term';
861
+ } else {
862
+ $user_type = 'short-term';
863
+ }
864
+ }
865
+
866
+ $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
867
+
868
+ // Load the HTML template for the deactivation feedback dialog box.
869
+ $vars = array(
870
+ 'reasons' => $uninstall_reasons,
871
+ 'slug' => $this->_slug
872
+ );
873
+
874
+ /**
875
+ * @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.
876
+ */
877
+ fs_require_template( 'forms/deactivation/form.php', $vars );
878
+ }
879
+
880
+ /**
881
+ * @author Leo Fajardo (leorw)
882
+ * @since 1.1.2
883
+ *
884
+ * @param string $user_type
885
+ *
886
+ * @return array The uninstall reasons for the specified user type.
887
+ */
888
+ function _get_uninstall_reasons( $user_type = 'long-term' ) {
889
+ $internal_message_template_var = array(
890
+ 'slug' => $this->_slug
891
+ );
892
+
893
+ if ( $this->is_registered() && false !== $this->get_plan() && $this->get_plan()->has_technical_support() ) {
894
+ $contact_support_template = fs_get_template( 'forms/deactivation/contact.php', $internal_message_template_var );
895
+ } else {
896
+ $contact_support_template = '';
897
+ }
898
+
899
+ $reason_found_better_plugin = array(
900
+ 'id' => self::REASON_FOUND_A_BETTER_PLUGIN,
901
+ 'text' => $this->get_text( 'reason-found-a-better-plugin' ),
902
+ 'input_type' => 'textfield',
903
+ 'input_placeholder' => $this->get_text( 'placeholder-plugin-name' )
904
+ );
905
+
906
+ $reason_temporary_deactivation = array(
907
+ 'id' => self::REASON_TEMPORARY_DEACTIVATION,
908
+ 'text' => $this->get_text( 'reason-temporary-deactivation' ),
909
+ 'input_type' => '',
910
+ 'input_placeholder' => ''
911
+ );
912
+
913
+ $reason_other = array(
914
+ 'id' => self::REASON_OTHER,
915
+ 'text' => $this->get_text( 'reason-other' ),
916
+ 'input_type' => 'textfield',
917
+ 'input_placeholder' => ''
918
+ );
919
+
920
+ $long_term_user_reasons = array(
921
+ array(
922
+ 'id' => self::REASON_NO_LONGER_NEEDED,
923
+ 'text' => $this->get_text( 'reason-no-longer-needed' ),
924
+ 'input_type' => '',
925
+ 'input_placeholder' => ''
926
+ ),
927
+ $reason_found_better_plugin,
928
+ array(
929
+ 'id' => self::REASON_NEEDED_FOR_A_SHORT_PERIOD,
930
+ 'text' => $this->get_text( 'reason-needed-for-a-short-period' ),
931
+ 'input_type' => '',
932
+ 'input_placeholder' => ''
933
+ ),
934
+ array(
935
+ 'id' => self::REASON_BROKE_MY_SITE,
936
+ 'text' => $this->get_text( 'reason-broke-my-site' ),
937
+ 'input_type' => '',
938
+ 'input_placeholder' => '',
939
+ 'internal_message' => $contact_support_template
940
+ ),
941
+ array(
942
+ 'id' => self::REASON_SUDDENLY_STOPPED_WORKING,
943
+ 'text' => $this->get_text( 'reason-suddenly-stopped-working' ),
944
+ 'input_type' => '',
945
+ 'input_placeholder' => '',
946
+ 'internal_message' => $contact_support_template
947
+ )
948
+ );
949
+
950
+ if ( $this->is_paying() ) {
951
+ $long_term_user_reasons[] = array(
952
+ 'id' => self::REASON_CANT_PAY_ANYMORE,
953
+ 'text' => $this->get_text( 'reason-cant-pay-anymore' ),
954
+ 'input_type' => 'textfield',
955
+ 'input_placeholder' => $this->get_text( 'placeholder-comfortable-price' )
956
+ );
957
+ }
958
+
959
+ $reason_dont_share_info = array(
960
+ 'id' => self::REASON_DONT_LIKE_TO_SHARE_MY_INFORMATION,
961
+ 'text' => $this->get_text( 'reason-dont-like-to-share-my-information' ),
962
+ 'input_type' => '',
963
+ 'input_placeholder' => ''
964
+ );
965
+
966
+ /**
967
+ * If the current user has selected the "don't share data" reason in the deactivation feedback modal, inform the
968
+ * user by showing additional message that he doesn't have to share data and can just choose to skip the opt-in
969
+ * (the Skip button is included in the message to show). This message will only be shown if anonymous mode is
970
+ * enabled and the user's account is currently not in pending activation state (similar to the way the Skip
971
+ * button in the opt-in form is shown/hidden).
972
+ */
973
+ if ( $this->is_enable_anonymous() && ! $this->is_pending_activation() ) {
974
+ $reason_dont_share_info['internal_message'] = fs_get_template( 'forms/deactivation/retry-skip.php', $internal_message_template_var );
975
+ }
976
+
977
+ $uninstall_reasons = array(
978
+ 'long-term' => $long_term_user_reasons,
979
+ 'non-registered-and-non-anonymous-short-term' => array(
980
+ array(
981
+ 'id' => self::REASON_DIDNT_WORK,
982
+ 'text' => $this->get_text( 'reason-didnt-work' ),
983
+ 'input_type' => '',
984
+ 'input_placeholder' => ''
985
+ ),
986
+ $reason_dont_share_info,
987
+ $reason_found_better_plugin
988
+ ),
989
+ 'short-term' => array(
990
+ array(
991
+ 'id' => self::REASON_COULDNT_MAKE_IT_WORK,
992
+ 'text' => $this->get_text( 'reason-couldnt-make-it-work' ),
993
+ 'input_type' => '',
994
+ 'input_placeholder' => '',
995
+ 'internal_message' => $contact_support_template
996
+ ),
997
+ $reason_found_better_plugin,
998
+ array(
999
+ 'id' => self::REASON_GREAT_BUT_NEED_SPECIFIC_FEATURE,
1000
+ 'text' => $this->get_text( 'reason-great-but-need-specific-feature' ),
1001
+ 'input_type' => 'textarea',
1002
+ 'input_placeholder' => $this->get_text( 'placeholder-feature' )
1003
+ ),
1004
+ array(
1005
+ 'id' => self::REASON_NOT_WORKING,
1006
+ 'text' => $this->get_text( 'reason-not-working' ),
1007
+ 'input_type' => 'textarea',
1008
+ 'input_placeholder' => $this->get_text( 'placeholder-share-what-didnt-work' )
1009
+ ),
1010
+ array(
1011
+ 'id' => self::REASON_NOT_WHAT_I_WAS_LOOKING_FOR,
1012
+ 'text' => $this->get_text( 'reason-not-what-i-was-looking-for' ),
1013
+ 'input_type' => 'textarea',
1014
+ 'input_placeholder' => $this->get_text( 'placeholder-what-youve-been-looking-for' )
1015
+ ),
1016
+ array(
1017
+ 'id' => self::REASON_DIDNT_WORK_AS_EXPECTED,
1018
+ 'text' => $this->get_text( 'reason-didnt-work-as-expected' ),
1019
+ 'input_type' => 'textarea',
1020
+ 'input_placeholder' => $this->get_text( 'placeholder-what-did-you-expect' )
1021
+ )
1022
+ )
1023
+ );
1024
+
1025
+ // Randomize the reasons for the current user type.
1026
+ shuffle( $uninstall_reasons[ $user_type ] );
1027
+
1028
+ // Keep the following reasons as the last items in the list.
1029
+ $uninstall_reasons[ $user_type ][] = $reason_temporary_deactivation;
1030
+ $uninstall_reasons[ $user_type ][] = $reason_other;
1031
+
1032
+ $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
1033
+
1034
+ return $uninstall_reasons[ $user_type ];
1035
+ }
1036
+
1037
+ /**
1038
+ * Called after the user has submitted his reason for deactivating the plugin.
1039
+ *
1040
+ * @author Leo Fajardo (@leorw)
1041
+ * @since 1.1.2
1042
+ */
1043
+ function _submit_uninstall_reason_action() {
1044
+ $this->_logger->entrance();
1045
+
1046
+ $this->check_ajax_referer( 'submit_uninstall_reason' );
1047
+
1048
+ $reason_id = fs_request_get( 'reason_id' );
1049
+
1050
+ // Check if the given reason ID is an unsigned integer.
1051
+ if ( ! ctype_digit( $reason_id ) ) {
1052
+ exit;
1053
+ }
1054
+
1055
+ $reason_info = trim( fs_request_get( 'reason_info', '' ) );
1056
+ if ( ! empty( $reason_info ) ) {
1057
+ $reason_info = substr( $reason_info, 0, 128 );
1058
+ }
1059
+
1060
+ $reason = (object) array(
1061
+ 'id' => $reason_id,
1062
+ 'info' => $reason_info,
1063
+ 'is_anonymous' => fs_request_get_bool( 'is_anonymous' )
1064
+ );
1065
+
1066
+ $this->_storage->store( 'uninstall_reason', $reason );
1067
+
1068
+ // Print '1' for successful operation.
1069
+ echo 1;
1070
+ exit;
1071
+ }
1072
+
1073
+ #endregion
1074
+
1075
+ #----------------------------------------------------------------------------------
1076
+ #region Instance
1077
+ #----------------------------------------------------------------------------------
1078
+
1079
+ /**
1080
+ * Main singleton instance.
1081
+ *
1082
+ * @author Vova Feldman (@svovaf)
1083
+ * @since 1.0.0
1084
+ *
1085
+ * @param string $slug
1086
+ * @param bool $is_init Is initiation sequence.
1087
+ *
1088
+ * @return Freemius|false
1089
+ */
1090
+ static function instance( $slug, $is_init = false ) {
1091
+ if ( empty( $slug ) ) {
1092
+ return false;
1093
+ }
1094
+
1095
+ $slug = strtolower( $slug );
1096
+
1097
+ if ( ! isset( self::$_instances[ $slug ] ) ) {
1098
+ if ( 0 === count( self::$_instances ) ) {
1099
+ self::_load_required_static();
1100
+ }
1101
+
1102
+ self::$_instances[ $slug ] = new Freemius( $slug, $is_init );
1103
+ }
1104
+
1105
+ return self::$_instances[ $slug ];
1106
+ }
1107
+
1108
+ /**
1109
+ * @author Vova Feldman (@svovaf)
1110
+ * @since 1.0.6
1111
+ *
1112
+ * @param string|number $slug_or_id
1113
+ *
1114
+ * @return bool
1115
+ */
1116
+ private static function has_instance( $slug_or_id ) {
1117
+ return ! is_numeric( $slug_or_id ) ?
1118
+ isset( self::$_instances[ strtolower( $slug_or_id ) ] ) :
1119
+ ( false !== self::get_instance_by_id( $slug_or_id ) );
1120
+ }
1121
+
1122
+ /**
1123
+ * @author Vova Feldman (@svovaf)
1124
+ * @since 1.0.6
1125
+ *
1126
+ * @param number $id
1127
+ *
1128
+ * @return false|Freemius
1129
+ */
1130
+ static function get_instance_by_id( $id ) {
1131
+ foreach ( self::$_instances as $slug => $instance ) {
1132
+ if ( $id == $instance->get_id() ) {
1133
+ return $instance;
1134
+ }
1135
+ }
1136
+
1137
+ return false;
1138
+ }
1139
+
1140
+ /**
1141
+ *
1142
+ * @author Vova Feldman (@svovaf)
1143
+ * @since 1.0.1
1144
+ *
1145
+ * @param $plugin_file
1146
+ *
1147
+ * @return false|Freemius
1148
+ */
1149
+ static function get_instance_by_file( $plugin_file ) {
1150
+ $slug = self::find_slug_by_basename( $plugin_file );
1151
+
1152
+ return ( false !== $slug ) ?
1153
+ self::instance( $slug ) :
1154
+ false;
1155
+ }
1156
+
1157
+ /**
1158
+ * @author Vova Feldman (@svovaf)
1159
+ * @since 1.0.6
1160
+ *
1161
+ * @return false|Freemius
1162
+ */
1163
+ function get_parent_instance() {
1164
+ return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
1165
+ }
1166
+
1167
+ /**
1168
+ * @author Vova Feldman (@svovaf)
1169
+ * @since 1.0.6
1170
+ *
1171
+ * @param string|number $slug_or_id
1172
+ *
1173
+ * @return bool|Freemius
1174
+ */
1175
+ function get_addon_instance( $slug_or_id ) {
1176
+ return ! is_numeric( $slug_or_id ) ?
1177
+ self::instance( strtolower( $slug_or_id ) ) :
1178
+ self::get_instance_by_id( $slug_or_id );
1179
+ }
1180
+
1181
+ #endregion ------------------------------------------------------------------
1182
+
1183
+ /**
1184
+ * @author Vova Feldman (@svovaf)
1185
+ * @since 1.0.6
1186
+ *
1187
+ * @return bool
1188
+ */
1189
+ function is_parent_plugin_installed() {
1190
+ return self::has_instance( $this->_plugin->parent_plugin_id );
1191
+ }
1192
+
1193
+ /**
1194
+ * Check if add-on parent plugin in activation mode.
1195
+ *
1196
+ * @author Vova Feldman (@svovaf)
1197
+ * @since 1.0.7
1198
+ *
1199
+ * @return bool
1200
+ */
1201
+ function is_parent_in_activation() {
1202
+ $parent_fs = $this->get_parent_instance();
1203
+ if ( ! is_object( $parent_fs ) ) {
1204
+ return false;
1205
+ }
1206
+
1207
+ return ( $parent_fs->is_activation_mode() );
1208
+ }
1209
+
1210
+ /**
1211
+ * Is plugin in activation mode.
1212
+ *
1213
+ * @author Vova Feldman (@svovaf)
1214
+ * @since 1.0.7
1215
+ *
1216
+ * @param bool $and_on
1217
+ *
1218
+ * @return bool
1219
+ */
1220
+ function is_activation_mode( $and_on = true ) {
1221
+ return (
1222
+ ( $this->is_on() || ! $and_on ) &&
1223
+ ! $this->is_registered() &&
1224
+ ( ! $this->is_enable_anonymous() ||
1225
+ ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
1226
+ );
1227
+ }
1228
+
1229
+ /**
1230
+ * Check if current page is the opt-in/pending-activation page.
1231
+ *
1232
+ * @author Vova Feldman (@svovaf)
1233
+ * @since 1.2.1.7
1234
+ *
1235
+ * @return bool
1236
+ */
1237
+ function is_activation_page() {
1238
+ if ( $this->_menu->is_main_settings_page() ) {
1239
+ return true;
1240
+ }
1241
+
1242
+ if ( ! $this->is_activation_mode() ) {
1243
+ return false;
1244
+ }
1245
+
1246
+ // Check if current page is matching the activation page.
1247
+ return $this->is_matching_url( $_SERVER['REQUEST_URI'], $this->get_activation_url() );
1248
+ }
1249
+
1250
+ /**
1251
+ * Check if URL path's are matching and that all querystring
1252
+ * arguments of the $sub_url exist in the $url with the same values.
1253
+ *
1254
+ * WARNING:
1255
+ * 1. This method doesn't check if the sub/domain are matching.
1256
+ * 2. Ignore case sensitivity.
1257
+ *
1258
+ * @author Vova Feldman (@svovaf)
1259
+ * @since 1.2.1.7
1260
+ *
1261
+ * @param string $url
1262
+ * @param string $sub_url
1263
+ *
1264
+ * @return bool
1265
+ */
1266
+ private function is_matching_url( $url, $sub_url ) {
1267
+ $url = strtolower( $url );
1268
+ $sub_url = strtolower( $sub_url );
1269
+
1270
+ if ( parse_url( $sub_url, PHP_URL_PATH ) !== parse_url( $url, PHP_URL_PATH ) ) {
1271
+ // Different path - DO NOT OVERRIDE PAGE.
1272
+ return false;
1273
+ }
1274
+
1275
+ $url_params = array();
1276
+ parse_str( parse_url( $url, PHP_URL_QUERY ), $url_params );
1277
+
1278
+ $sub_url_params = array();
1279
+ parse_str( parse_url( $sub_url, PHP_URL_QUERY ), $sub_url_params );
1280
+
1281
+ foreach ( $sub_url_params as $key => $val ) {
1282
+ if ( ! isset( $url_params[ $key ] ) || $val != $url_params[ $key ] ) {
1283
+ // Not matching query string - DO NOT OVERRIDE PAGE.
1284
+ return false;
1285
+ }
1286
+ }
1287
+
1288
+ return true;
1289
+ }
1290
+
1291
+ /**
1292
+ * Get collection of all active plugins.
1293
+ *
1294
+ * @author Vova Feldman (@svovaf)
1295
+ * @since 1.0.9
1296
+ *
1297
+ * @return array[string]array
1298
+ */
1299
+ private static function get_active_plugins() {
1300
+ self::require_plugin_essentials();
1301
+
1302
+ $active_plugin = array();
1303
+ $all_plugins = get_plugins();
1304
+ $active_plugins_basenames = get_option( 'active_plugins' );
1305
+
1306
+ foreach ( $active_plugins_basenames as $plugin_basename ) {
1307
+ $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
1308
+ }
1309
+
1310
+ return $active_plugin;
1311
+ }
1312
+
1313
+ /**
1314
+ * Get collection of all plugins.
1315
+ *
1316
+ * @author Vova Feldman (@svovaf)
1317
+ * @since 1.1.8
1318
+ *
1319
+ * @return array Key is the plugin file path and the value is an array of the plugin data.
1320
+ */
1321
+ private static function get_all_plugins() {
1322
+ self::require_plugin_essentials();
1323
+
1324
+ $all_plugins = get_plugins();
1325
+ $active_plugins_basenames = get_option( 'active_plugins' );
1326
+
1327
+ foreach ( $all_plugins as $basename => &$data ) {
1328
+ // By default set to inactive (next foreach update the active plugins).
1329
+ $data['is_active'] = false;
1330
+ // Enrich with plugin slug.
1331
+ $data['slug'] = self::get_plugin_slug( $basename );
1332
+ }
1333
+
1334
+ // Flag active plugins.
1335
+ foreach ( $active_plugins_basenames as $basename ) {
1336
+ if ( isset( $all_plugins[ $basename ] ) ) {
1337
+ $all_plugins[ $basename ]['is_active'] = true;
1338
+ }
1339
+ }
1340
+
1341
+ return $all_plugins;
1342
+ }
1343
+
1344
+
1345
+ /**
1346
+ * Cached result of get_site_transient( 'update_plugins' )
1347
+ *
1348
+ * @author Vova Feldman (@svovaf)
1349
+ * @since 1.1.8
1350
+ *
1351
+ * @var object
1352
+ */
1353
+ private static $_plugins_info;
1354
+
1355
+ /**
1356
+ * Helper function to get specified plugin's slug.
1357
+ *
1358
+ * @author Vova Feldman (@svovaf)
1359
+ * @since 1.1.8
1360
+ *
1361
+ * @param $basename
1362
+ *
1363
+ * @return string
1364
+ */
1365
+ private static function get_plugin_slug( $basename ) {
1366
+ if ( ! isset( self::$_plugins_info ) ) {
1367
+ self::$_plugins_info = get_site_transient( 'update_plugins' );
1368
+ }
1369
+
1370
+ $slug = '';
1371
+
1372
+ if ( is_object( self::$_plugins_info ) ) {
1373
+ if ( isset( self::$_plugins_info->no_update ) &&
1374
+ isset( self::$_plugins_info->no_update[ $basename ] ) &&
1375
+ ! empty( self::$_plugins_info->no_update[ $basename ]->slug )
1376
+ ) {
1377
+ $slug = self::$_plugins_info->no_update[ $basename ]->slug;
1378
+ } else if ( isset( self::$_plugins_info->response ) &&
1379
+ isset( self::$_plugins_info->response[ $basename ] ) &&
1380
+ ! empty( self::$_plugins_info->response[ $basename ]->slug )
1381
+ ) {
1382
+ $slug = self::$_plugins_info->response[ $basename ]->slug;
1383
+ }
1384
+ }
1385
+
1386
+ if ( empty( $slug ) ) {
1387
+ // Try to find slug from FS data.
1388
+ $slug = self::find_slug_by_basename( $basename );
1389
+ }
1390
+
1391
+ if ( empty( $slug ) ) {
1392
+ // Fallback to plugin's folder name.
1393
+ $slug = dirname( $basename );
1394
+ }
1395
+
1396
+ return $slug;
1397
+ }
1398
+
1399
+ private static $_statics_loaded = false;
1400
+
1401
+ /**
1402
+ * Load static resources.
1403
+ *
1404
+ * @author Vova Feldman (@svovaf)
1405
+ * @since 1.0.1
1406
+ */
1407
+ private static function _load_required_static() {
1408
+ if ( self::$_statics_loaded ) {
1409
+ return;
1410
+ }
1411
+
1412
+ self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
1413
+
1414
+ self::$_static_logger->entrance();
1415
+
1416
+ self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
1417
+
1418
+ self::$_global_admin_notices = FS_Admin_Notice_Manager::instance( 'global' );
1419
+
1420
+ // Configure which Freemius powered plugins should be auto updated.
1421
+ // add_filter( 'auto_update_plugin', '_include_plugins_in_auto_update', 10, 2 );
1422
+
1423
+ add_action( 'admin_menu', array( 'Freemius', '_add_debug_section' ) );
1424
+
1425
+ add_action( "wp_ajax_fs_toggle_debug_mode", array( 'Freemius', '_toggle_debug_mode' ) );
1426
+
1427
+ self::add_ajax_action_static( 'get_debug_log', array( 'Freemius', '_get_debug_log' ) );
1428
+
1429
+ self::add_ajax_action_static( 'get_db_option', array( 'Freemius', '_get_db_option' ) );
1430
+
1431
+ self::add_ajax_action_static( 'set_db_option', array( 'Freemius', '_set_db_option' ) );
1432
+
1433
+ add_action( 'plugins_loaded', array( 'Freemius', '_load_textdomain' ), 1 );
1434
+
1435
+ self::$_statics_loaded = true;
1436
+ }
1437
+
1438
+ #----------------------------------------------------------------------------------
1439
+ #region Localization
1440
+ #----------------------------------------------------------------------------------
1441
+
1442
+ /**
1443
+ * Load framework's text domain.
1444
+ *
1445
+ * @author Vova Feldman (@svovaf)
1446
+ * @since 1.2.1
1447
+ */
1448
+ static function _load_textdomain() {
1449
+ if ( ! is_admin() ) {
1450
+ return;
1451
+ }
1452
+
1453
+ global $fs_active_plugins;
1454
+
1455
+ // Works both for plugins and themes.
1456
+ load_plugin_textdomain(
1457
+ 'freemius',
1458
+ false,
1459
+ $fs_active_plugins->newest->sdk_path . '/languages/'
1460
+ );
1461
+ }
1462
+
1463
+ #endregion
1464
+
1465
+ #----------------------------------------------------------------------------------
1466
+ #region Debugging
1467
+ #----------------------------------------------------------------------------------
1468
+
1469
+ /**
1470
+ * @author Vova Feldman (@svovaf)
1471
+ * @since 1.0.8
1472
+ */
1473
+ static function _add_debug_section() {
1474
+ if ( ! current_user_can( 'activate_plugins' ) ) {
1475
+ return;
1476
+ }
1477
+
1478
+ self::$_static_logger->entrance();
1479
+
1480
+ $title = sprintf( '%s [v.%s]', fs_text( 'freemius-debug' ), WP_FS__SDK_VERSION );
1481
+
1482
+ $hook = null;
1483
+
1484
+ if ( WP_FS__DEV_MODE ) {
1485
+ // Add top-level debug menu item.
1486
+ $hook = FS_Admin_Menu_Manager::add_page(
1487
+ $title,
1488
+ $title,
1489
+ 'manage_options',
1490
+ 'freemius',
1491
+ array( 'Freemius', '_debug_page_render' )
1492
+ );
1493
+ } else {
1494
+ if ( 'freemius' === fs_request_get( 'page' ) ) {
1495
+ // Add hidden debug page.
1496
+ $hook = FS_Admin_Menu_Manager::add_subpage(
1497
+ null,
1498
+ $title,
1499
+ $title,
1500
+ 'manage_options',
1501
+ 'freemius',
1502
+ array( 'Freemius', '_debug_page_render' )
1503
+ );
1504
+ }
1505
+ }
1506
+
1507
+ if ( ! empty( $hook ) ) {
1508
+ add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
1509
+ }
1510
+ }
1511
+
1512
+ /**
1513
+ * @author Vova Feldman (@svovaf)
1514
+ * @since 1.1.7.3
1515
+ */
1516
+ static function _toggle_debug_mode() {
1517
+ $is_on = fs_request_get( 'is_on', false, 'post' );
1518
+
1519
+ if ( fs_request_is_post() && in_array( $is_on, array( 0, 1 ) ) ) {
1520
+ update_option( 'fs_debug_mode', $is_on );
1521
+
1522
+ // Turn on/off storage logging.
1523
+ FS_Logger::_set_storage_logging( ( 1 == $is_on ) );
1524
+ }
1525
+
1526
+ exit;
1527
+ }
1528
+
1529
+ /**
1530
+ * @author Vova Feldman (@svovaf)
1531
+ * @since 1.2.1.6
1532
+ */
1533
+ static function _get_debug_log() {
1534
+ $logs = FS_Logger::load_db_logs(
1535
+ fs_request_get( 'filters', false, 'post' ),
1536
+ ! empty( $_POST['limit'] ) && is_numeric( $_POST['limit'] ) ? $_POST['limit'] : 200,
1537
+ ! empty( $_POST['offset'] ) && is_numeric( $_POST['offset'] ) ? $_POST['offset'] : 0
1538
+ );
1539
+
1540
+ self::shoot_ajax_success( $logs );
1541
+ }
1542
+
1543
+ /**
1544
+ * @author Vova Feldman (@svovaf)
1545
+ * @since 1.2.1.7
1546
+ */
1547
+ static function _get_db_option() {
1548
+ $option_name = fs_request_get( 'option_name' );
1549
+
1550
+ $value = get_option( $option_name );
1551
+
1552
+ $result = array(
1553
+ 'name' => $option_name,
1554
+ );
1555
+
1556
+ if ( false !== $value ) {
1557
+ if ( ! is_string( $value ) ) {
1558
+ $value = json_encode( $value );
1559
+ }
1560
+
1561
+ $result['value'] = $value;
1562
+ }
1563
+
1564
+ self::shoot_ajax_success( $result );
1565
+ }
1566
+
1567
+ /**
1568
+ * @author Vova Feldman (@svovaf)
1569
+ * @since 1.2.1.7
1570
+ */
1571
+ static function _set_db_option() {
1572
+ $option_name = fs_request_get( 'option_name' );
1573
+ $option_value = fs_request_get( 'option_value' );
1574
+
1575
+ if ( ! empty( $option_value ) ) {
1576
+ update_option( $option_name, $option_value );
1577
+ }
1578
+
1579
+ self::shoot_ajax_success();
1580
+ }
1581
+
1582
+
1583
+ /**
1584
+ * @author Vova Feldman (@svovaf)
1585
+ * @since 1.0.8
1586
+ */
1587
+ static function _debug_page_actions() {
1588
+ self::_clean_admin_content_section();
1589
+
1590
+ if ( fs_request_is_action( 'restart_freemius' ) ) {
1591
+ check_admin_referer( 'restart_freemius' );
1592
+
1593
+ // Clear accounts data.
1594
+ self::$_accounts->clear( true );
1595
+
1596
+ // Clear SDK reference cache.
1597
+ delete_option( 'fs_active_plugins' );
1598
+ } else if ( fs_request_is_action( 'simulate_trial' ) ) {
1599
+ check_admin_referer( 'simulate_trial' );
1600
+
1601
+ $slug = fs_request_get( 'slug' );
1602
+
1603
+ $fs = freemius( $slug );
1604
+
1605
+ // Update SDK install to at least 24 hours before.
1606
+ $fs->_storage->install_timestamp = ( time() - WP_FS__TIME_24_HOURS_IN_SEC );
1607
+ // Unset the trial shown timestamp.
1608
+ unset( $fs->_storage->trial_promotion_shown );
1609
+ } else if ( fs_request_is_action( 'download_logs' ) ) {
1610
+ check_admin_referer( 'download_logs' );
1611
+
1612
+ $download_url = FS_Logger::download_db_logs(
1613
+ fs_request_get( 'filters', false, 'post' )
1614
+ );
1615
+
1616
+ if ( false === $download_url ) {
1617
+ wp_die( 'Oops... there was an error while generating the logs download file. Please try again and if it doesn\'t work contact support@freemius.com.' );
1618
+ }
1619
+
1620
+ fs_redirect( $download_url );
1621
+ }
1622
+ }
1623
+
1624
+ /**
1625
+ * @author Vova Feldman (@svovaf)
1626
+ * @since 1.0.8
1627
+ */
1628
+ static function _debug_page_render() {
1629
+ self::$_static_logger->entrance();
1630
+
1631
+ $vars = array(
1632
+ 'sites' => self::get_all_sites(),
1633
+ 'users' => self::get_all_users(),
1634
+ 'addons' => self::get_all_addons(),
1635
+ 'account_addons' => self::get_all_account_addons(),
1636
+ 'licenses' => self::get_all_licenses(),
1637
+ );
1638
+
1639
+ fs_enqueue_local_style( 'fs_debug', '/admin/debug.css' );
1640
+ fs_require_once_template( 'debug.php', $vars );
1641
+ }
1642
+
1643
+ #endregion
1644
+
1645
+ #----------------------------------------------------------------------------------
1646
+ #region Connectivity Issues
1647
+ #----------------------------------------------------------------------------------
1648
+
1649
+ /**
1650
+ * Check if Freemius should be turned on for the current plugin install.
1651
+ *
1652
+ * Note:
1653
+ * $this->_is_on is updated in has_api_connectivity()
1654
+ *
1655
+ * @author Vova Feldman (@svovaf)
1656
+ * @since 1.0.9
1657
+ *
1658
+ * @return bool
1659
+ */
1660
+ function is_on() {
1661
+ self::$_static_logger->entrance();
1662
+
1663
+ if ( isset( $this->_is_on ) ) {
1664
+ return $this->_is_on;
1665
+ }
1666
+
1667
+ // If already installed or pending then sure it's on :)
1668
+ if ( $this->is_registered() || $this->is_pending_activation() ) {
1669
+ $this->_is_on = true;
1670
+
1671
+ return true;
1672
+ }
1673
+
1674
+ return false;
1675
+ }
1676
+
1677
+ /**
1678
+ * @author Vova Feldman (@svovaf)
1679
+ * @since 1.1.7.3
1680
+ *
1681
+ * @param bool $flush_if_no_connectivity
1682
+ *
1683
+ * @return bool
1684
+ */
1685
+ private function should_run_connectivity_test( $flush_if_no_connectivity = false ) {
1686
+ if ( ! isset( $this->_storage->connectivity_test ) ) {
1687
+ // Connectivity test was never executed, or cache was cleared.
1688
+ return true;
1689
+ }
1690
+
1691
+ if ( WP_FS__PING_API_ON_IP_OR_HOST_CHANGES ) {
1692
+ if ( WP_FS__IS_HTTP_REQUEST ) {
1693
+ if ( $_SERVER['HTTP_HOST'] != $this->_storage->connectivity_test['host'] ) {
1694
+ // Domain changed.
1695
+ return true;
1696
+ }
1697
+
1698
+ if ( WP_FS__REMOTE_ADDR != $this->_storage->connectivity_test['server_ip'] ) {
1699
+ // Server IP changed.
1700
+ return true;
1701
+ }
1702
+ }
1703
+ }
1704
+
1705
+ if ( $this->_storage->connectivity_test['is_connected'] &&
1706
+ $this->_storage->connectivity_test['is_active']
1707
+ ) {
1708
+ // API connected and Freemius is active - no need to run connectivity check.
1709
+ return false;
1710
+ }
1711
+
1712
+ if ( $flush_if_no_connectivity ) {
1713
+ /**
1714
+ * If explicitly asked to flush when no connectivity - do it only
1715
+ * if at least 10 sec passed from the last API connectivity test.
1716
+ */
1717
+ return ( isset( $this->_storage->connectivity_test['timestamp'] ) &&
1718
+ ( WP_FS__SCRIPT_START_TIME - $this->_storage->connectivity_test['timestamp'] ) > 10 );
1719
+ }
1720
+
1721
+ /**
1722
+ * @since 1.1.7 Don't check for connectivity on plugin downgrade.
1723
+ */
1724
+ $version = $this->get_plugin_version();
1725
+ if ( version_compare( $version, $this->_storage->connectivity_test['version'], '>' ) ) {
1726
+ // If it's a plugin version upgrade and Freemius is off or no connectivity, run connectivity test.
1727
+ return true;
1728
+ }
1729
+
1730
+ return false;
1731
+ }
1732
+
1733
+ /**
1734
+ * @author Vova Feldman (@svovaf)
1735
+ * @since 1.1.7.4
1736
+ *
1737
+ * @return object|false
1738
+ */
1739
+ private function ping() {
1740
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY ) {
1741
+ return false;
1742
+ }
1743
+
1744
+ $version = $this->get_plugin_version();
1745
+
1746
+ $is_update = $this->apply_filters( 'is_plugin_update', $this->is_plugin_update() );
1747
+
1748
+ return $this->get_api_plugin_scope()->ping(
1749
+ $this->get_anonymous_id(),
1750
+ array(
1751
+ 'is_update' => json_encode( $is_update ),
1752
+ 'version' => $version,
1753
+ 'sdk' => $this->version,
1754
+ 'is_admin' => json_encode( is_admin() ),
1755
+ 'is_ajax' => json_encode( self::is_ajax() ),
1756
+ 'is_cron' => json_encode( $this->is_cron() ),
1757
+ 'is_http' => json_encode( WP_FS__IS_HTTP_REQUEST ),
1758
+ )
1759
+ );
1760
+ }
1761
+
1762
+ /**
1763
+ * Check if there's any connectivity issue to Freemius API.
1764
+ *
1765
+ * @author Vova Feldman (@svovaf)
1766
+ * @since 1.0.9
1767
+ *
1768
+ * @param bool $flush_if_no_connectivity
1769
+ *
1770
+ * @return bool
1771
+ */
1772
+ function has_api_connectivity( $flush_if_no_connectivity = false ) {
1773
+ $this->_logger->entrance();
1774
+
1775
+ if ( isset( $this->_has_api_connection ) && ( $this->_has_api_connection || ! $flush_if_no_connectivity ) ) {
1776
+ return $this->_has_api_connection;
1777
+ }
1778
+
1779
+ if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
1780
+ isset( $this->_storage->connectivity_test ) &&
1781
+ true === $this->_storage->connectivity_test['is_connected']
1782
+ ) {
1783
+ unset( $this->_storage->connectivity_test );
1784
+ }
1785
+
1786
+ if ( ! $this->should_run_connectivity_test( $flush_if_no_connectivity ) ) {
1787
+ $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
1788
+ /**
1789
+ * @since 1.1.6 During dev mode, if there's connectivity - turn Freemius on regardless the configuration.
1790
+ *
1791
+ * @since 1.2.1.5 If the user running the premium version then ignore the 'is_active' flag and turn Freemius on to enable license key activation.
1792
+ */
1793
+ $this->_is_on = $this->_storage->connectivity_test['is_active'] ||
1794
+ $this->is_premium() ||
1795
+ ( WP_FS__DEV_MODE && $this->_has_api_connection && ! WP_FS__SIMULATE_FREEMIUS_OFF );
1796
+
1797
+ return $this->_has_api_connection;
1798
+ }
1799
+
1800
+ $pong = $this->ping();
1801
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
1802
+
1803
+ if ( ! $is_connected ) {
1804
+ // API failure.
1805
+ $this->_add_connectivity_issue_message( $pong );
1806
+ }
1807
+
1808
+ $this->store_connectivity_info( $pong, $is_connected );
1809
+
1810
+ return $this->_has_api_connection;
1811
+ }
1812
+
1813
+ /**
1814
+ * @author Vova Feldman (@svovaf)
1815
+ * @since 1.1.7.4
1816
+ *
1817
+ * @param object $pong
1818
+ * @param bool $is_connected
1819
+ */
1820
+ private function store_connectivity_info( $pong, $is_connected ) {
1821
+ $this->_logger->entrance();
1822
+
1823
+ $version = $this->get_plugin_version();
1824
+
1825
+ if ( ! $is_connected || WP_FS__SIMULATE_FREEMIUS_OFF ) {
1826
+ $is_active = false;
1827
+ } else {
1828
+ $is_active = ( isset( $pong->is_active ) && true == $pong->is_active );
1829
+ }
1830
+
1831
+ $is_active = $this->apply_filters(
1832
+ 'is_on',
1833
+ $is_active,
1834
+ $this->is_plugin_update(),
1835
+ $version
1836
+ );
1837
+
1838
+ $this->_storage->connectivity_test = array(
1839
+ 'is_connected' => $is_connected,
1840
+ 'host' => $_SERVER['HTTP_HOST'],
1841
+ 'server_ip' => WP_FS__REMOTE_ADDR,
1842
+ 'is_active' => $is_active,
1843
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
1844
+ // Last version with connectivity attempt.
1845
+ 'version' => $version,
1846
+ );
1847
+
1848
+ $this->_has_api_connection = $is_connected;
1849
+ $this->_is_on = $is_active || ( WP_FS__DEV_MODE && $is_connected && ! WP_FS__SIMULATE_FREEMIUS_OFF );
1850
+ }
1851
+
1852
+ /**
1853
+ * Force turning Freemius on.
1854
+ *
1855
+ * @author Vova Feldman (@svovaf)
1856
+ * @since 1.1.8.1
1857
+ *
1858
+ * @return bool TRUE if successfully turned on.
1859
+ */
1860
+ private function turn_on() {
1861
+ $this->_logger->entrance();
1862
+
1863
+ if ( $this->is_on() || ! isset( $this->_storage->connectivity_test['is_active'] ) ) {
1864
+ return false;
1865
+ }
1866
+
1867
+ $updated_connectivity = $this->_storage->connectivity_test;
1868
+ $updated_connectivity['is_active'] = true;
1869
+ $updated_connectivity['timestamp'] = WP_FS__SCRIPT_START_TIME;
1870
+ $this->_storage->connectivity_test = $updated_connectivity;
1871
+
1872
+ $this->_is_on = true;
1873
+
1874
+ return true;
1875
+ }
1876
+
1877
+ /**
1878
+ * Anonymous and unique site identifier (Hash).
1879
+ *
1880
+ * @author Vova Feldman (@svovaf)
1881
+ * @since 1.1.0
1882
+ *
1883
+ * @return string
1884
+ */
1885
+ function get_anonymous_id() {
1886
+ $unique_id = self::$_accounts->get_option( 'unique_id' );
1887
+
1888
+ if ( empty( $unique_id ) || ! is_string( $unique_id ) ) {
1889
+ $key = get_site_url();
1890
+
1891
+ // If localhost, assign microtime instead of domain.
1892
+ if ( WP_FS__IS_LOCALHOST ||
1893
+ false !== strpos( $key, 'localhost' ) ||
1894
+ false === strpos( $key, '.' )
1895
+ ) {
1896
+ $key = microtime();
1897
+ }
1898
+
1899
+ $unique_id = md5( $key );
1900
+
1901
+ self::$_accounts->set_option( 'unique_id', $unique_id, true );
1902
+ }
1903
+
1904
+ $this->_logger->departure( $unique_id );
1905
+
1906
+ return $unique_id;
1907
+ }
1908
+
1909
+ /**
1910
+ * @author Vova Feldman (@svovaf)
1911
+ * @since 1.1.7.4
1912
+ *
1913
+ * @return \WP_User
1914
+ */
1915
+ static function _get_current_wp_user() {
1916
+ self::require_pluggable_essentials();
1917
+
1918
+ return wp_get_current_user();
1919
+ }
1920
+
1921
+ /**
1922
+ * Generate API connectivity issue message.
1923
+ *
1924
+ * @author Vova Feldman (@svovaf)
1925
+ * @since 1.0.9
1926
+ *
1927
+ * @param mixed $api_result
1928
+ * @param bool $is_first_failure
1929
+ */
1930
+ function _add_connectivity_issue_message( $api_result, $is_first_failure = true ) {
1931
+ if ( ! $this->is_premium() && $this->_enable_anonymous ) {
1932
+ // Don't add message if it's the free version and can run anonymously.
1933
+ return;
1934
+ }
1935
+
1936
+ if ( ! function_exists( 'wp_nonce_url' ) ) {
1937
+ require_once ABSPATH . 'wp-includes/functions.php';
1938
+ }
1939
+
1940
+ $current_user = self::_get_current_wp_user();
1941
+ // $admin_email = get_option( 'admin_email' );
1942
+ $admin_email = $current_user->user_email;
1943
+
1944
+ $message = false;
1945
+ if ( is_object( $api_result ) &&
1946
+ isset( $api_result->error ) &&
1947
+ isset( $api_result->error->code )
1948
+ ) {
1949
+ switch ( $api_result->error->code ) {
1950
+ case 'curl_missing':
1951
+ $missing_methods = '';
1952
+ if ( is_array( $api_result->missing_methods ) &&
1953
+ ! empty( $api_result->missing_methods )
1954
+ ) {
1955
+ foreach ( $api_result->missing_methods as $m ) {
1956
+ if ( 'curl_version' === $m ) {
1957
+ continue;
1958
+ }
1959
+
1960
+ if ( ! empty( $missing_methods ) ) {
1961
+ $missing_methods .= ', ';
1962
+ }
1963
+
1964
+ $missing_methods .= sprintf( '<code>%s</code>', $m );
1965
+ }
1966
+
1967
+ if ( ! empty( $missing_methods ) ) {
1968
+ $missing_methods = sprintf(
1969
+ '<br><br><b>%s</b> %s',
1970
+ $this->get_text( 'curl-disabled-methods' ),
1971
+ $missing_methods
1972
+ );
1973
+ }
1974
+ }
1975
+
1976
+ $message = sprintf(
1977
+ $this->get_text( 'x-requires-access-to-api' ) . ' ' .
1978
+ $this->get_text( 'curl-missing-message' ) . ' ' .
1979
+ $missing_methods .
1980
+ ' %s',
1981
+ '<b>' . $this->get_plugin_name() . '</b>',
1982
+ sprintf(
1983
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1984
+ sprintf(
1985
+ '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
1986
+ $this->get_text( 'curl-missing-no-clue-title' ),
1987
+ ' - ' . sprintf(
1988
+ $this->get_text( 'curl-missing-no-clue-desc' ),
1989
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1990
+ )
1991
+ ),
1992
+ sprintf(
1993
+ '<b>%s</b> - %s',
1994
+ $this->get_text( 'sysadmin-title' ),
1995
+ $this->get_text( 'curl-missing-sysadmin-desc' )
1996
+ ),
1997
+ sprintf(
1998
+ '<a href="%s"><b>%s</b></a>%s',
1999
+ 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 ),
2000
+ $this->get_text( 'deactivate-plugin-title' ),
2001
+ ' - ' . $this->get_text( 'deactivate-plugin-desc' )
2002
+ )
2003
+ )
2004
+ );
2005
+ break;
2006
+ case 'cloudflare_ddos_protection':
2007
+ $message = sprintf(
2008
+ $this->get_text( 'x-requires-access-to-api' ) . ' ' .
2009
+ $this->get_text( 'cloudflare-blocks-connection-message' ) . ' ' .
2010
+ $this->get_text( 'happy-to-resolve-issue-asap' ) .
2011
+ ' %s',
2012
+ '<b>' . $this->get_plugin_name() . '</b>',
2013
+ sprintf(
2014
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2015
+ sprintf(
2016
+ '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
2017
+ $this->get_text( 'fix-issue-title' ),
2018
+ ' - ' . sprintf(
2019
+ $this->get_text( 'fix-issue-desc' ),
2020
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2021
+ )
2022
+ ),
2023
+ sprintf(
2024
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
2025
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
2026
+ $this->get_text( 'install-previous-title' ),
2027
+ ' - ' . $this->get_text( 'install-previous-desc' )
2028
+ ),
2029
+ sprintf(
2030
+ '<a href="%s"><b>%s</b></a>%s',
2031
+ 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 ),
2032
+ $this->get_text( 'deactivate-plugin-title' ),
2033
+ ' - ' . $this->get_text( 'deactivate-plugin-desc' )
2034
+ )
2035
+ )
2036
+ );
2037
+ break;
2038
+ case 'squid_cache_block':
2039
+ $message = sprintf(
2040
+ $this->get_text( 'x-requires-access-to-api' ) . ' ' .
2041
+ $this->get_text( 'squid-blocks-connection-message' ) .
2042
+ ' %s',
2043
+ '<b>' . $this->get_plugin_name() . '</b>',
2044
+ sprintf(
2045
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2046
+ sprintf(
2047
+ '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a>%s',
2048
+ $this->get_text( 'squid-no-clue-title' ),
2049
+ ' - ' . sprintf(
2050
+ $this->get_text( 'squid-no-clue-desc' ),
2051
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2052
+ )
2053
+ ),
2054
+ sprintf(
2055
+ '<b>%s</b> - %s',
2056
+ $this->get_text( 'sysadmin-title' ),
2057
+ sprintf(
2058
+ $this->get_text( 'squid-sysadmin-desc' ),
2059
+ // We use a filter since the plugin might require additional API connectivity.
2060
+ '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com' ) ) ) . '</b>' )
2061
+ ),
2062
+ sprintf(
2063
+ '<a href="%s"><b>%s</b></a>%s',
2064
+ 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 ),
2065
+ $this->get_text( 'deactivate-plugin-title' ),
2066
+ ' - ' . $this->get_text( 'deactivate-plugin-desc' )
2067
+ )
2068
+ )
2069
+ );
2070
+ break;
2071
+ // default:
2072
+ // $message = $this->get_text( 'connectivity-test-fails-message' );
2073
+ // break;
2074
+ }
2075
+ }
2076
+
2077
+ $message_id = 'failed_connect_api';
2078
+ $type = 'error';
2079
+
2080
+ if ( false === $message ) {
2081
+ if ( $is_first_failure ) {
2082
+ // First attempt failed.
2083
+ $message = sprintf(
2084
+ $this->get_text( 'x-requires-access-to-api' ) . ' ' .
2085
+ $this->get_text( 'connectivity-test-fails-message' ) . ' ' .
2086
+ $this->get_text( 'connectivity-test-maybe-temporary' ) . '<br><br>' .
2087
+ '%s',
2088
+ '<b>' . $this->get_plugin_name() . '</b>',
2089
+ sprintf(
2090
+ '<div id="fs_firewall_issue_options">%s %s</div>',
2091
+ sprintf(
2092
+ '<a class="button button-primary fs-resolve" data-type="retry_ping" href="#">%s</a>',
2093
+ $this->get_text( 'yes-do-your-thing' )
2094
+ ),
2095
+ sprintf(
2096
+ '<a href="%s" class="button">%s</a>',
2097
+ 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 ),
2098
+ $this->get_text( 'no-deactivate' )
2099
+ )
2100
+ )
2101
+ );
2102
+
2103
+ $message_id = 'failed_connect_api_first';
2104
+ $type = 'promotion';
2105
+ } else {
2106
+ // Second connectivity attempt failed.
2107
+ $message = sprintf(
2108
+ $this->get_text( 'x-requires-access-to-api' ) . ' ' .
2109
+ $this->get_text( 'connectivity-test-fails-message' ) . ' ' .
2110
+ $this->get_text( 'happy-to-resolve-issue-asap' ) .
2111
+ ' %s',
2112
+ '<b>' . $this->get_plugin_name() . '</b>',
2113
+ sprintf(
2114
+ '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
2115
+ sprintf(
2116
+ '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
2117
+ $this->get_text( 'fix-issue-title' ),
2118
+ ' - ' . sprintf(
2119
+ $this->get_text( 'fix-issue-desc' ),
2120
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2121
+ )
2122
+ ),
2123
+ sprintf(
2124
+ '<a href="%s" target="_blank"><b>%s</b></a>%s',
2125
+ sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
2126
+ $this->get_text( 'install-previous-title' ),
2127
+ ' - ' . $this->get_text( 'install-previous-desc' )
2128
+ ),
2129
+ sprintf(
2130
+ '<a href="%s"><b>%s</b></a>%s',
2131
+ 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 ),
2132
+ $this->get_text( 'deactivate-plugin-title' ),
2133
+ ' - ' . $this->get_text( 'deactivate-plugin-desc' )
2134
+ )
2135
+ )
2136
+ );
2137
+ }
2138
+ }
2139
+
2140
+ $this->_admin_notices->add_sticky(
2141
+ $message,
2142
+ $message_id,
2143
+ $this->get_text( 'oops' ) . '...',
2144
+ $type
2145
+ );
2146
+ }
2147
+
2148
+ /**
2149
+ * Handle user request to resolve connectivity issue.
2150
+ * This method will send an email to Freemius API technical staff for resolution.
2151
+ * The email will contain server's info and installed plugins (might be caching issue).
2152
+ *
2153
+ * @author Vova Feldman (@svovaf)
2154
+ * @since 1.0.9
2155
+ */
2156
+ function _email_about_firewall_issue() {
2157
+ $this->_admin_notices->remove_sticky( 'failed_connect_api' );
2158
+
2159
+ $pong = $this->ping();
2160
+
2161
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
2162
+
2163
+ if ( $is_connected ) {
2164
+ $this->store_connectivity_info( $pong, $is_connected );
2165
+
2166
+ echo $this->get_after_plugin_activation_redirect_url();
2167
+ exit;
2168
+ }
2169
+
2170
+ $current_user = self::_get_current_wp_user();
2171
+ $admin_email = $current_user->user_email;
2172
+
2173
+ $error_type = fs_request_get( 'error_type', 'general' );
2174
+
2175
+ switch ( $error_type ) {
2176
+ case 'squid':
2177
+ $title = 'Squid ACL Blocking Issue';
2178
+ break;
2179
+ case 'cloudflare':
2180
+ $title = 'CloudFlare Blocking Issue';
2181
+ break;
2182
+ default:
2183
+ $title = 'API Connectivity Issue';
2184
+ break;
2185
+ }
2186
+
2187
+ $custom_email_sections = array();
2188
+
2189
+ // Add 'API Error' custom email section.
2190
+ $custom_email_sections['api_error'] = array(
2191
+ 'title' => 'API Error',
2192
+ 'rows' => array(
2193
+ 'ping' => array(
2194
+ 'API Error',
2195
+ is_string( $pong ) ? htmlentities( $pong ) : json_encode( $pong )
2196
+ ),
2197
+ )
2198
+ );
2199
+
2200
+ // Send email with technical details to resolve API connectivity issues.
2201
+ $this->send_email(
2202
+ 'api@freemius.com', // recipient
2203
+ $title . ' [' . $this->get_plugin_name() . ']', // subject
2204
+ $custom_email_sections,
2205
+ array( "Reply-To: $admin_email <$admin_email>" ) // headers
2206
+ );
2207
+
2208
+ $this->_admin_notices->add_sticky(
2209
+ sprintf(
2210
+ $this->get_text( 'fix-request-sent-message' ),
2211
+ '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
2212
+ ),
2213
+ 'server_details_sent'
2214
+ );
2215
+
2216
+ // Action was taken, tell that API connectivity troubleshooting should be off now.
2217
+
2218
+ echo "1";
2219
+ exit;
2220
+ }
2221
+
2222
+ /**
2223
+ * Handle connectivity test retry approved by the user.
2224
+ *
2225
+ * @author Vova Feldman (@svovaf)
2226
+ * @since 1.1.7.4
2227
+ */
2228
+ function _retry_connectivity_test() {
2229
+ $this->_admin_notices->remove_sticky( 'failed_connect_api_first' );
2230
+
2231
+ $pong = $this->ping();
2232
+
2233
+ $is_connected = $this->get_api_plugin_scope()->is_valid_ping( $pong );
2234
+
2235
+ if ( $is_connected ) {
2236
+ $this->store_connectivity_info( $pong, $is_connected );
2237
+
2238
+ echo $this->get_after_plugin_activation_redirect_url();
2239
+ } else {
2240
+ // Add connectivity issue message after 2nd failed attempt.
2241
+ $this->_add_connectivity_issue_message( $pong, false );
2242
+
2243
+ echo "1";
2244
+ }
2245
+
2246
+ exit;
2247
+ }
2248
+
2249
+ static function _add_firewall_issues_javascript() {
2250
+ $params = array();
2251
+ fs_require_once_template( 'firewall-issues-js.php', $params );
2252
+ }
2253
+
2254
+ #endregion
2255
+
2256
+ #----------------------------------------------------------------------------------
2257
+ #region Email
2258
+ #----------------------------------------------------------------------------------
2259
+
2260
+ /**
2261
+ * Generates and sends an HTML email with customizable sections.
2262
+ *
2263
+ * @author Leo Fajardo (@leorw)
2264
+ * @since 1.1.2
2265
+ *
2266
+ * @param string $to_address
2267
+ * @param string $subject
2268
+ * @param array $sections
2269
+ * @param array $headers
2270
+ *
2271
+ * @return bool Whether the email contents were sent successfully.
2272
+ */
2273
+ private function send_email(
2274
+ $to_address,
2275
+ $subject,
2276
+ $sections = array(),
2277
+ $headers = array()
2278
+ ) {
2279
+ $default_sections = $this->get_email_sections();
2280
+
2281
+ // Insert new sections or replace the default email sections.
2282
+ if ( is_array( $sections ) && ! empty( $sections ) ) {
2283
+ foreach ( $sections as $section_id => $custom_section ) {
2284
+ if ( ! isset( $default_sections[ $section_id ] ) ) {
2285
+ // If the section does not exist, add it.
2286
+ $default_sections[ $section_id ] = $custom_section;
2287
+ } else {
2288
+ // If the section already exists, override it.
2289
+ $current_section = $default_sections[ $section_id ];
2290
+
2291
+ // Replace the current section's title if a custom section title exists.
2292
+ if ( isset( $custom_section['title'] ) ) {
2293
+ $current_section['title'] = $custom_section['title'];
2294
+ }
2295
+
2296
+ // Insert new rows under the current section or replace the default rows.
2297
+ if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
2298
+ foreach ( $custom_section['rows'] as $row_id => $row ) {
2299
+ $current_section['rows'][ $row_id ] = $row;
2300
+ }
2301
+ }
2302
+
2303
+ $default_sections[ $section_id ] = $current_section;
2304
+ }
2305
+ }
2306
+ }
2307
+
2308
+ $vars = array( 'sections' => $default_sections );
2309
+ $message = fs_get_template( 'email.php', $vars );
2310
+
2311
+ // Set the type of email to HTML.
2312
+ $headers[] = 'Content-type: text/html; charset=UTF-8';
2313
+
2314
+ $header_string = implode( "\r\n", $headers );
2315
+
2316
+ return wp_mail(
2317
+ $to_address,
2318
+ $subject,
2319
+ $message,
2320
+ $header_string
2321
+ );
2322
+ }
2323
+
2324
+ /**
2325
+ * Generates the data for the sections of the email content.
2326
+ *
2327
+ * @author Leo Fajardo (@leorw)
2328
+ * @since 1.1.2
2329
+ *
2330
+ * @return array
2331
+ */
2332
+ private function get_email_sections() {
2333
+ // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
2334
+ $current_user = self::_get_current_wp_user();
2335
+
2336
+ // Retrieve the cURL version information so that we can get the version number below.
2337
+ $curl_version_information = curl_version();
2338
+
2339
+ $active_plugin = self::get_active_plugins();
2340
+
2341
+ // Generate the list of active plugins separated by new line.
2342
+ $active_plugin_string = '';
2343
+ foreach ( $active_plugin as $plugin ) {
2344
+ $active_plugin_string .= sprintf(
2345
+ '<a href="%s">%s</a> [v%s]<br>',
2346
+ $plugin['PluginURI'],
2347
+ $plugin['Name'],
2348
+ $plugin['Version']
2349
+ );
2350
+ }
2351
+
2352
+ $server_ip = WP_FS__REMOTE_ADDR;
2353
+
2354
+ // Add PHP info for deeper investigation.
2355
+ ob_start();
2356
+ phpinfo();
2357
+ $php_info = ob_get_clean();
2358
+
2359
+ $api_domain = substr( FS_API__ADDRESS, strpos( FS_API__ADDRESS, ':' ) + 3 );
2360
+
2361
+ // Generate the default email sections.
2362
+ $sections = array(
2363
+ 'sdk' => array(
2364
+ 'title' => 'SDK',
2365
+ 'rows' => array(
2366
+ 'fs_version' => array( 'FS Version', $this->version ),
2367
+ 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
2368
+ )
2369
+ ),
2370
+ 'plugin' => array(
2371
+ 'title' => 'Plugin',
2372
+ 'rows' => array(
2373
+ 'name' => array( 'Name', $this->get_plugin_name() ),
2374
+ 'version' => array( 'Version', $this->get_plugin_version() )
2375
+ )
2376
+ ),
2377
+ 'api' => array(
2378
+ 'title' => 'API Subdomain',
2379
+ 'rows' => array(
2380
+ 'dns' => array( 'DNS_CNAME', var_export( @dns_get_record( $api_domain, DNS_CNAME ), true ) ),
2381
+ 'ip' => array( 'IP', @gethostbyname( $api_domain ) ),
2382
+ ),
2383
+ ),
2384
+ 'site' => array(
2385
+ 'title' => 'Site',
2386
+ 'rows' => array(
2387
+ 'unique_id' => array( 'Unique ID', $this->get_anonymous_id() ),
2388
+ 'address' => array( 'Address', site_url() ),
2389
+ 'host' => array(
2390
+ 'HTTP_HOST',
2391
+ ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
2392
+ ),
2393
+ 'hosting' => array(
2394
+ 'Hosting Company' => fs_request_has( 'hosting_company' ) ?
2395
+ fs_request_get( 'hosting_company' ) :
2396
+ 'Unknown',
2397
+ ),
2398
+ 'server_addr' => array(
2399
+ 'SERVER_ADDR',
2400
+ '<a href="http://www.projecthoneypot.org/ip_' . $server_ip . '">' . $server_ip . '</a>'
2401
+ )
2402
+ )
2403
+ ),
2404
+ 'user' => array(
2405
+ 'title' => 'User',
2406
+ 'rows' => array(
2407
+ 'email' => array( 'Email', $current_user->user_email ),
2408
+ 'first' => array( 'First', $current_user->user_firstname ),
2409
+ 'last' => array( 'Last', $current_user->user_lastname )
2410
+ )
2411
+ ),
2412
+ 'plugins' => array(
2413
+ 'title' => 'Plugins',
2414
+ 'rows' => array(
2415
+ 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
2416
+ )
2417
+ ),
2418
+ 'php_info' => array(
2419
+ 'title' => 'PHP Info',
2420
+ 'rows' => array(
2421
+ 'info' => array( $php_info )
2422
+ ),
2423
+ )
2424
+ );
2425
+
2426
+ // Allow the sections to be modified by other code.
2427
+ $sections = $this->apply_filters( 'email_template_sections', $sections );
2428
+
2429
+ return $sections;
2430
+ }
2431
+
2432
+ #endregion
2433
+
2434
+ #----------------------------------------------------------------------------------
2435
+ #region Initialization
2436
+ #----------------------------------------------------------------------------------
2437
+
2438
+ /**
2439
+ * Init plugin's Freemius instance.
2440
+ *
2441
+ * @author Vova Feldman (@svovaf)
2442
+ * @since 1.0.1
2443
+ *
2444
+ * @param number $id
2445
+ * @param string $public_key
2446
+ * @param bool $is_live
2447
+ * @param bool $is_premium
2448
+ */
2449
+ function init( $id, $public_key, $is_live = true, $is_premium = true ) {
2450
+ $this->_logger->entrance();
2451
+
2452
+ $this->dynamic_init( array(
2453
+ 'id' => $id,
2454
+ 'public_key' => $public_key,
2455
+ 'is_live' => $is_live,
2456
+ 'is_premium' => $is_premium,
2457
+ ) );
2458
+ }
2459
+
2460
+ /**
2461
+ * Dynamic initiator, originally created to support initiation
2462
+ * with parent_id for add-ons.
2463
+ *
2464
+ * @author Vova Feldman (@svovaf)
2465
+ * @since 1.0.6
2466
+ *
2467
+ * @param array $plugin_info
2468
+ *
2469
+ * @throws Freemius_Exception
2470
+ */
2471
+ function dynamic_init( array $plugin_info ) {
2472
+ $this->_logger->entrance();
2473
+
2474
+ $this->parse_settings( $plugin_info );
2475
+
2476
+ if ( $this->should_stop_execution() ) {
2477
+ return;
2478
+ }
2479
+
2480
+ if ( ! $this->is_registered() ) {
2481
+ if ( $this->is_anonymous() ) {
2482
+ // If user skipped, no need to test connectivity.
2483
+ $this->_has_api_connection = true;
2484
+ $this->_is_on = true;
2485
+ } else {
2486
+ if ( ! $this->has_api_connectivity() ) {
2487
+ if ( $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) ||
2488
+ $this->_admin_notices->has_sticky( 'failed_connect_api' )
2489
+ ) {
2490
+ if ( ! $this->_enable_anonymous || $this->is_premium() ) {
2491
+ // If anonymous mode is disabled, add firewall admin-notice message.
2492
+ add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
2493
+
2494
+ $this->add_ajax_action( 'resolve_firewall_issues', array(
2495
+ &$this,
2496
+ '_email_about_firewall_issue'
2497
+ ) );
2498
+
2499
+ $this->add_ajax_action( 'retry_connectivity_test', array(
2500
+ &$this,
2501
+ '_retry_connectivity_test'
2502
+ ) );
2503
+ }
2504
+ }
2505
+
2506
+ return;
2507
+ } else {
2508
+ $this->_admin_notices->remove_sticky( array(
2509
+ 'failed_connect_api_first',
2510
+ 'failed_connect_api',
2511
+ ) );
2512
+
2513
+ if ( $this->_anonymous_mode ) {
2514
+ // Simulate anonymous mode.
2515
+ $this->_is_anonymous = true;
2516
+ }
2517
+ }
2518
+ }
2519
+
2520
+ // Check if Freemius is on for the current plugin.
2521
+ // This MUST be executed after all the plugin variables has been loaded.
2522
+ if ( ! $this->is_on() ) {
2523
+ return;
2524
+ }
2525
+ }
2526
+
2527
+ if ( $this->has_api_connectivity() ) {
2528
+ if ( $this->is_cron() ) {
2529
+ $this->hook_callback_to_sync_cron();
2530
+ } else if ( $this->is_user_in_admin() ) {
2531
+ /**
2532
+ * Schedule daily data sync cron if:
2533
+ *
2534
+ * 1. User opted-in (for tracking).
2535
+ * 2. If skipped, but later upgraded (opted-in via upgrade).
2536
+ *
2537
+ * @author Vova Feldman (@svovaf)
2538
+ * @since 1.1.7.3
2539
+ *
2540
+ */
2541
+ if ( $this->is_registered() ) {
2542
+ if ( ! $this->is_sync_cron_on() && $this->is_tracking_allowed() ) {
2543
+ $this->schedule_sync_cron();
2544
+ }
2545
+ }
2546
+
2547
+ /**
2548
+ * Check if requested for manual blocking background sync.
2549
+ */
2550
+ if ( fs_request_has( 'background_sync' ) ) {
2551
+ $this->run_manual_sync();
2552
+ }
2553
+ }
2554
+ }
2555
+
2556
+ if ( $this->is_registered() ) {
2557
+ $this->hook_callback_to_install_sync();
2558
+ }
2559
+
2560
+ if ( $this->is_addon() ) {
2561
+ if ( $this->is_parent_plugin_installed() ) {
2562
+ // Link to parent FS.
2563
+ $this->_parent = self::get_instance_by_id( $this->_plugin->parent_plugin_id );
2564
+
2565
+ // Get parent plugin reference.
2566
+ $this->_parent_plugin = $this->_parent->get_plugin();
2567
+ }
2568
+ }
2569
+
2570
+ if ( $this->is_user_in_admin() ) {
2571
+ if ( $this->is_plugins_page() ) {
2572
+ $this->hook_plugin_action_links();
2573
+ }
2574
+
2575
+ if ( $this->is_addon() ) {
2576
+ if ( ! $this->is_parent_plugin_installed() ) {
2577
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
2578
+
2579
+ if ( isset( $plugin_info['parent'] ) ) {
2580
+ $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
2581
+ }
2582
+
2583
+ $this->_admin_notices->add(
2584
+ ( ! empty( $parent_name ) ?
2585
+ sprintf( $this->get_text( 'addon-x-cannot-run-without-y' ), $this->get_plugin_name(), $parent_name ) :
2586
+ sprintf( $this->get_text( 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
2587
+ ),
2588
+ $this->get_text( 'oops' ) . '...',
2589
+ 'error'
2590
+ );
2591
+
2592
+ return;
2593
+ } else {
2594
+ if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
2595
+ // If parent plugin activated, automatically install add-on for the user.
2596
+ $this->_activate_addon_account( $this->_parent );
2597
+ }
2598
+
2599
+ // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
2600
+ if ( $this->is_premium() ) {
2601
+ // Remove add-on download admin-notice.
2602
+ $this->_parent->_admin_notices->remove_sticky( array(
2603
+ 'addon_plan_upgraded_' . $this->_slug,
2604
+ 'no_addon_license_' . $this->_slug,
2605
+ ) );
2606
+ }
2607
+
2608
+ $this->deactivate_premium_only_addon_without_license();
2609
+ }
2610
+ } else {
2611
+ if ( $this->has_addons() &&
2612
+ 'plugin-information' === fs_request_get( 'tab', false ) &&
2613
+ $this->get_id() == fs_request_get( 'parent_plugin_id', false )
2614
+ ) {
2615
+ require_once WP_FS__DIR_INCLUDES . '/fs-plugin-info-dialog.php';
2616
+
2617
+ new FS_Plugin_Info_Dialog( $this );
2618
+ }
2619
+ }
2620
+
2621
+ add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
2622
+
2623
+ // if ( $this->is_registered() ||
2624
+ // $this->is_anonymous() ||
2625
+ // $this->is_pending_activation()
2626
+ // ) {
2627
+ // $this->_init_admin();
2628
+ // }
2629
+ }
2630
+
2631
+ /**
2632
+ * Should be called outside `$this->is_user_in_admin()` scope
2633
+ * because the updater has some logic that needs to be executed
2634
+ * during AJAX calls.
2635
+ *
2636
+ * Currently we need to hook to the `http_request_host_is_external` filter.
2637
+ * In the future, there might be additional logic added.
2638
+ *
2639
+ * @author Vova Feldman
2640
+ * @since 1.2.1.6
2641
+ */
2642
+ if ( $this->is_premium() && $this->has_release_on_freemius() ) {
2643
+ new FS_Plugin_Updater( $this );
2644
+ }
2645
+
2646
+ $this->do_action( 'initiated' );
2647
+
2648
+ if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
2649
+ if ( isset( $this->_storage->prev_is_premium ) ) {
2650
+ $this->apply_filters(
2651
+ 'after_code_type_change',
2652
+ // New code type.
2653
+ $this->_plugin->is_premium
2654
+ );
2655
+ } else {
2656
+ // Set for code type for the first time.
2657
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
2658
+ }
2659
+ }
2660
+
2661
+ if ( ! $this->is_addon() ) {
2662
+ if ( $this->is_registered() ) {
2663
+ // Fix for upgrade from versions < 1.0.9.
2664
+ if ( ! isset( $this->_storage->activation_timestamp ) ) {
2665
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
2666
+ }
2667
+
2668
+ $this->do_action( 'after_init_plugin_registered' );
2669
+ } else if ( $this->is_anonymous() ) {
2670
+ $this->do_action( 'after_init_plugin_anonymous' );
2671
+ } else if ( $this->is_pending_activation() ) {
2672
+ $this->do_action( 'after_init_plugin_pending_activations' );
2673
+ }
2674
+ } else {
2675
+ if ( $this->is_registered() ) {
2676
+ $this->do_action( 'after_init_addon_registered' );
2677
+ } else if ( $this->is_anonymous() ) {
2678
+ $this->do_action( 'after_init_addon_anonymous' );
2679
+ } else if ( $this->is_pending_activation() ) {
2680
+ $this->do_action( 'after_init_addon_pending_activations' );
2681
+ }
2682
+ }
2683
+ }
2684
+
2685
+ /**
2686
+ * @author Leo Fajardo (@leorw)
2687
+ *
2688
+ * @since 1.2.1.5
2689
+ */
2690
+ function _stop_tracking_callback() {
2691
+ $this->_logger->entrance();
2692
+
2693
+ $this->check_ajax_referer( 'stop_tracking' );
2694
+
2695
+ $result = $this->stop_tracking();
2696
+
2697
+ if ( true === $result ) {
2698
+ self::shoot_ajax_success();
2699
+ }
2700
+
2701
+ $this->_logger->api_error( $result );
2702
+
2703
+ self::shoot_ajax_failure(
2704
+ $this->get_text( 'unexpected-api-error' ) .
2705
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
2706
+ $result->error->message :
2707
+ var_export( $result, true ) )
2708
+ );
2709
+ }
2710
+
2711
+ /**
2712
+ * @author Leo Fajardo (@leorw)
2713
+ * @since 1.2.1.5
2714
+ */
2715
+ function _allow_tracking_callback() {
2716
+ $this->_logger->entrance();
2717
+
2718
+ $this->check_ajax_referer( 'allow_tracking' );
2719
+
2720
+ $result = $this->allow_tracking();
2721
+
2722
+ if ( true === $result ) {
2723
+ self::shoot_ajax_success();
2724
+ }
2725
+
2726
+ $this->_logger->api_error( $result );
2727
+
2728
+ self::shoot_ajax_failure(
2729
+ $this->get_text( 'unexpected-api-error' ) .
2730
+ ( $this->is_api_error( $result ) && isset( $result->error ) ?
2731
+ $result->error->message :
2732
+ var_export( $result, true ) )
2733
+ );
2734
+ }
2735
+
2736
+ /**
2737
+ * Opt-out from usage tracking.
2738
+ *
2739
+ * Note: This will not delete the account information but will stop all tracking.
2740
+ *
2741
+ * Returns:
2742
+ * 1. FALSE - If the user never opted-in.
2743
+ * 2. TRUE - If successfully opted-out.
2744
+ * 3. object - API result on failure.
2745
+ *
2746
+ * @author Leo Fajardo (@leorw)
2747
+ * @since 1.2.1.5
2748
+ *
2749
+ * @return bool|object
2750
+ */
2751
+ function stop_tracking() {
2752
+ $this->_logger->entrance();
2753
+
2754
+ if ( ! $this->is_registered() ) {
2755
+ // User never opted-in.
2756
+ return false;
2757
+ }
2758
+
2759
+ if ( $this->is_tracking_prohibited() ) {
2760
+ // Already disconnected.
2761
+ return true;
2762
+ }
2763
+
2764
+ // Send update to FS.
2765
+ $result = $this->get_api_site_scope()->call( '/?fields=is_disconnected', 'put', array(
2766
+ 'is_disconnected' => true
2767
+ ) );
2768
+
2769
+ if ( ! $this->is_api_result_entity( $result ) ||
2770
+ ! isset( $result->is_disconnected ) ||
2771
+ ! $result->is_disconnected
2772
+ ) {
2773
+ $this->_logger->api_error( $result );
2774
+
2775
+ return $result;
2776
+ }
2777
+
2778
+ $this->_site->is_disconnected = $result->is_disconnected;
2779
+ $this->_store_site();
2780
+
2781
+ $this->clear_sync_cron();
2782
+
2783
+ // Successfully disconnected.
2784
+ return true;
2785
+ }
2786
+
2787
+ /**
2788
+ * Opt-in back into usage tracking.
2789
+ *
2790
+ * Note: This will only work if the user opted-in previously.
2791
+ *
2792
+ * Returns:
2793
+ * 1. FALSE - If the user never opted-in.
2794
+ * 2. TRUE - If successfully opted-in back to usage tracking.
2795
+ * 3. object - API result on failure.
2796
+ *
2797
+ * @author Leo Fajardo (@leorw)
2798
+ * @since 1.2.1.5
2799
+ *
2800
+ * @return bool|object
2801
+ */
2802
+ function allow_tracking() {
2803
+ $this->_logger->entrance();
2804
+
2805
+ if ( ! $this->is_registered() ) {
2806
+ // User never opted-in.
2807
+ return false;
2808
+ }
2809
+
2810
+ if ( $this->is_tracking_allowed() ) {
2811
+ // Tracking already allowed.
2812
+ return true;
2813
+ }
2814
+
2815
+ $result = $this->get_api_site_scope()->call( '/?is_disconnected', 'put', array(
2816
+ 'is_disconnected' => false
2817
+ ) );
2818
+
2819
+ if ( ! $this->is_api_result_entity( $result ) ||
2820
+ ! isset( $result->is_disconnected ) ||
2821
+ $result->is_disconnected
2822
+ ) {
2823
+ $this->_logger->api_error( $result );
2824
+
2825
+ return $result;
2826
+ }
2827
+
2828
+ $this->_site->is_disconnected = $result->is_disconnected;
2829
+ $this->_store_site();
2830
+
2831
+ $this->schedule_sync_cron();
2832
+
2833
+ // Successfully reconnected.
2834
+ return true;
2835
+ }
2836
+
2837
+ /**
2838
+ * If user opted-in and later disabled usage-tracking,
2839
+ * re-allow tracking for licensing and updates.
2840
+ *
2841
+ * @author Leo Fajardo (@leorw)
2842
+ *
2843
+ * @since 1.2.1.5
2844
+ */
2845
+ private function reconnect_locally() {
2846
+ $this->_logger->entrance();
2847
+
2848
+ if ( $this->is_tracking_prohibited() &&
2849
+ $this->is_registered()
2850
+ ) {
2851
+ $this->_site->is_disconnected = false;
2852
+ $this->_store_site();
2853
+ }
2854
+ }
2855
+
2856
+ /**
2857
+ * Parse plugin's settings (as defined by the plugin dev).
2858
+ *
2859
+ * @author Vova Feldman (@svovaf)
2860
+ * @since 1.1.7.3
2861
+ *
2862
+ * @param array $plugin_info
2863
+ *
2864
+ * @throws \Freemius_Exception
2865
+ */
2866
+ private function parse_settings( &$plugin_info ) {
2867
+ $this->_logger->entrance();
2868
+
2869
+ $id = $this->get_numeric_option( $plugin_info, 'id', false );
2870
+ $public_key = $this->get_option( $plugin_info, 'public_key', false );
2871
+ $secret_key = $this->get_option( $plugin_info, 'secret_key', null );
2872
+ $parent_id = $this->get_numeric_option( $plugin_info, 'parent_id', null );
2873
+ $parent_name = $this->get_option( $plugin_info, 'parent_name', null );
2874
+
2875
+ /**
2876
+ * @author Vova Feldman (@svovaf)
2877
+ * @since 1.1.9 Try to pull secret key from external config.
2878
+ */
2879
+ if ( is_null( $secret_key ) && defined( "WP_FS__{$this->_slug}_SECRET_KEY" ) ) {
2880
+ $secret_key = constant( "WP_FS__{$this->_slug}_SECRET_KEY" );
2881
+ }
2882
+
2883
+ if ( isset( $plugin_info['parent'] ) ) {
2884
+ $parent_id = $this->get_numeric_option( $plugin_info['parent'], 'id', null );
2885
+ // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
2886
+ // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
2887
+ // $parent_name = $this->get_option( $plugin_info['parent'], 'name', null );
2888
+ }
2889
+
2890
+ if ( false === $id ) {
2891
+ throw new Freemius_Exception( 'Plugin id parameter is not set.' );
2892
+ }
2893
+ if ( false === $public_key ) {
2894
+ throw new Freemius_Exception( 'Plugin public_key parameter is not set.' );
2895
+ }
2896
+
2897
+ $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
2898
+ $this->_plugin :
2899
+ new FS_Plugin();
2900
+
2901
+ $plugin->update( array(
2902
+ 'id' => $id,
2903
+ 'public_key' => $public_key,
2904
+ 'slug' => $this->_slug,
2905
+ 'parent_plugin_id' => $parent_id,
2906
+ 'version' => $this->get_plugin_version(),
2907
+ 'title' => $this->get_plugin_name(),
2908
+ 'file' => $this->_plugin_basename,
2909
+ 'is_premium' => $this->get_bool_option( $plugin_info, 'is_premium', true ),
2910
+ 'is_live' => $this->get_bool_option( $plugin_info, 'is_live', true ),
2911
+ // 'secret_key' => $secret_key,
2912
+ ) );
2913
+
2914
+ if ( $plugin->is_updated() ) {
2915
+ // Update plugin details.
2916
+ $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->store( $plugin );
2917
+ }
2918
+ // Set the secret key after storing the plugin, we don't want to store the key in the storage.
2919
+ $this->_plugin->secret_key = $secret_key;
2920
+
2921
+ if ( ! isset( $plugin_info['menu'] ) ) {
2922
+ $plugin_info['menu'] = array();
2923
+
2924
+ if ( ! empty( $this->_storage->sdk_last_version ) &&
2925
+ version_compare( $this->_storage->sdk_last_version, '1.1.2', '<=' )
2926
+ ) {
2927
+ // Backward compatibility to 1.1.2
2928
+ $plugin_info['menu']['slug'] = isset( $plugin_info['menu_slug'] ) ?
2929
+ $plugin_info['menu_slug'] :
2930
+ $this->_slug;
2931
+ }
2932
+ }
2933
+
2934
+ $this->_menu = FS_Admin_Menu_Manager::instance( $this->_slug );
2935
+ $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
2936
+
2937
+ $this->_has_addons = $this->get_bool_option( $plugin_info, 'has_addons', false );
2938
+ $this->_has_paid_plans = $this->get_bool_option( $plugin_info, 'has_paid_plans', true );
2939
+ $this->_has_premium_version = $this->get_bool_option( $plugin_info, 'has_premium_version', $this->_has_paid_plans );
2940
+ $this->_ignore_pending_mode = $this->get_bool_option( $plugin_info, 'ignore_pending_mode', false );
2941
+ $this->_is_org_compliant = $this->get_bool_option( $plugin_info, 'is_org_compliant', true );
2942
+ $this->_is_premium_only = $this->get_bool_option( $plugin_info, 'is_premium_only', false );
2943
+ if ( $this->_is_premium_only ) {
2944
+ // If premium only plugin, disable anonymous mode.
2945
+ $this->_enable_anonymous = false;
2946
+ $this->_anonymous_mode = false;
2947
+ } else {
2948
+ $this->_enable_anonymous = $this->get_bool_option( $plugin_info, 'enable_anonymous', true );
2949
+ $this->_anonymous_mode = $this->get_bool_option( $plugin_info, 'anonymous_mode', false );
2950
+ }
2951
+ $this->_permissions = $this->get_option( $plugin_info, 'permissions', array() );
2952
+
2953
+ if ( ! empty( $plugin_info['trial'] ) ) {
2954
+ $this->_trial_days = $this->get_numeric_option(
2955
+ $plugin_info['trial'],
2956
+ 'days',
2957
+ // Default to 0 - trial without days specification.
2958
+ 0
2959
+ );
2960
+
2961
+ $this->_is_trial_require_payment = $this->get_bool_option( $plugin_info['trial'], 'is_require_payment', false );
2962
+ }
2963
+ }
2964
+
2965
+ /**
2966
+ * @param string[] $options
2967
+ * @param string $key
2968
+ * @param mixed $default
2969
+ *
2970
+ * @return bool
2971
+ */
2972
+ private function get_option( &$options, $key, $default = false ) {
2973
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
2974
+ }
2975
+
2976
+ private function get_bool_option( &$options, $key, $default = false ) {
2977
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
2978
+ }
2979
+
2980
+ private function get_numeric_option( &$options, $key, $default = false ) {
2981
+ return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
2982
+ }
2983
+
2984
+ /**
2985
+ * Gate keeper.
2986
+ *
2987
+ * @author Vova Feldman (@svovaf)
2988
+ * @since 1.1.7.3
2989
+ *
2990
+ * @return bool
2991
+ */
2992
+ private function should_stop_execution() {
2993
+ if ( empty( $this->_storage->was_plugin_loaded ) ) {
2994
+ /**
2995
+ * Don't execute Freemius until plugin was fully loaded at least once,
2996
+ * to give the opportunity for the activation hook to run before pinging
2997
+ * the API for connectivity test. This logic is relevant for the
2998
+ * identification of new plugin install vs. plugin update.
2999
+ *
3000
+ * @author Vova Feldman (@svovaf)
3001
+ * @since 1.1.9
3002
+ */
3003
+ return true;
3004
+ }
3005
+
3006
+ if ( $this->is_activation_mode() ) {
3007
+ if ( ! is_admin() ) {
3008
+ /**
3009
+ * If in activation mode, don't execute Freemius outside of the
3010
+ * admin dashboard.
3011
+ *
3012
+ * @author Vova Feldman (@svovaf)
3013
+ * @since 1.1.7.3
3014
+ */
3015
+ return true;
3016
+ }
3017
+
3018
+ if ( ! WP_FS__IS_HTTP_REQUEST ) {
3019
+ /**
3020
+ * If in activation and executed without HTTP context (e.g. CLI, Cronjob),
3021
+ * then don't start Freemius.
3022
+ *
3023
+ * @author Vova Feldman (@svovaf)
3024
+ * @since 1.1.6.3
3025
+ *
3026
+ * @link https://wordpress.org/support/topic/errors-in-the-freemius-class-when-running-in-wordpress-in-cli
3027
+ */
3028
+ return true;
3029
+ }
3030
+
3031
+ if ( $this->is_cron() ) {
3032
+ /**
3033
+ * If in activation mode, don't execute Freemius during wp crons
3034
+ * (wp crons have HTTP context - called as HTTP request).
3035
+ *
3036
+ * @author Vova Feldman (@svovaf)
3037
+ * @since 1.1.7.3
3038
+ */
3039
+ return true;
3040
+ }
3041
+
3042
+ if ( self::is_ajax() &&
3043
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api_first' ) &&
3044
+ ! $this->_admin_notices->has_sticky( 'failed_connect_api' )
3045
+ ) {
3046
+ /**
3047
+ * During activation, if running in AJAX mode, unless there's a sticky
3048
+ * connectivity issue notice, don't run Freemius.
3049
+ *
3050
+ * @author Vova Feldman (@svovaf)
3051
+ * @since 1.1.7.3
3052
+ */
3053
+ return true;
3054
+ }
3055
+ }
3056
+
3057
+ return false;
3058
+ }
3059
+
3060
+ /**
3061
+ * Triggered after code type has changed.
3062
+ *
3063
+ * @author Vova Feldman (@svovaf)
3064
+ * @since 1.1.9.1
3065
+ */
3066
+ function _after_code_type_change() {
3067
+ $this->_logger->entrance();
3068
+
3069
+ add_action( is_admin() ? 'admin_init' : 'init', array(
3070
+ &$this,
3071
+ '_plugin_code_type_changed'
3072
+ ) );
3073
+ }
3074
+
3075
+ /**
3076
+ * Handles plugin's code type change (free <--> premium).
3077
+ *
3078
+ * @author Vova Feldman (@svovaf)
3079
+ * @since 1.0.9
3080
+ */
3081
+ function _plugin_code_type_changed() {
3082
+ $this->_logger->entrance();
3083
+
3084
+ if ( $this->is_premium() ) {
3085
+ $this->reconnect_locally();
3086
+
3087
+ // Activated premium code.
3088
+ $this->do_action( 'after_premium_version_activation' );
3089
+
3090
+ // Remove all sticky messages related to download of the premium version.
3091
+ $this->_admin_notices->remove_sticky( array(
3092
+ 'trial_started',
3093
+ 'plan_upgraded',
3094
+ 'plan_changed',
3095
+ 'license_activated',
3096
+ ) );
3097
+
3098
+ $this->_admin_notices->add_sticky(
3099
+ $this->get_text( 'premium-activated-message' ),
3100
+ 'premium_activated',
3101
+ $this->get_text( 'woot' ) . '!'
3102
+ );
3103
+ } else {
3104
+ // Remove sticky message related to premium code activation.
3105
+ $this->_admin_notices->remove_sticky( 'premium_activated' );
3106
+
3107
+ // Activated free code (after had the premium before).
3108
+ $this->do_action( 'after_free_version_reactivation' );
3109
+
3110
+ if ( $this->is_paying() && ! $this->is_premium() ) {
3111
+ $this->_admin_notices->add_sticky(
3112
+ sprintf(
3113
+ $this->get_text( 'you-have-x-license' ),
3114
+ $this->_site->plan->title
3115
+ ) . $this->get_complete_upgrade_instructions(),
3116
+ 'plan_upgraded',
3117
+ $this->get_text( 'yee-haw' ) . '!'
3118
+ );
3119
+ }
3120
+ }
3121
+
3122
+ // Schedule code type changes event.
3123
+ $this->schedule_install_sync();
3124
+
3125
+ /**
3126
+ * Unregister the uninstall hook for the other version of the plugin (with different code type) to avoid
3127
+ * triggering a fatal error when uninstalling that plugin. For example, after deactivating the "free" version
3128
+ * of a specific plugin, its uninstall hook should be unregistered after the "premium" version has been
3129
+ * activated. If we don't do that, a fatal error will occur when we try to uninstall the "free" version since
3130
+ * the main file of the "free" version will be loaded first before calling the hooked callback. Since the
3131
+ * free and premium versions are almost identical (same class or have same functions), a fatal error like
3132
+ * "Cannot redeclare class MyClass" or "Cannot redeclare my_function()" will occur.
3133
+ */
3134
+ $this->unregister_uninstall_hook();
3135
+
3136
+ $this->clear_module_main_file_cache();
3137
+
3138
+ // Update is_premium of latest version.
3139
+ $this->_storage->prev_is_premium = $this->_plugin->is_premium;
3140
+ }
3141
+
3142
+ #endregion
3143
+
3144
+ #----------------------------------------------------------------------------------
3145
+ #region Add-ons
3146
+ #----------------------------------------------------------------------------------
3147
+
3148
+ /**
3149
+ * Check if add-on installed and activated on site.
3150
+ *
3151
+ * @author Vova Feldman (@svovaf)
3152
+ * @since 1.0.6
3153
+ *
3154
+ * @param string|number $slug_or_id
3155
+ * @param bool|null $is_premium Since 1.2.1.7 can check for specified add-on version.
3156
+ *
3157
+ * @return bool
3158
+ */
3159
+ function is_addon_activated( $slug_or_id, $is_premium = null ) {
3160
+ $this->_logger->entrance();
3161
+
3162
+ $is_activated = self::has_instance( $slug_or_id );
3163
+
3164
+ if ( ! $is_activated ) {
3165
+ return false;
3166
+ }
3167
+
3168
+ if ( is_bool( $is_premium ) ) {
3169
+ // Check if the specified code version is activate.
3170
+ $addon = $this->get_addon_instance( $slug_or_id );
3171
+ $is_activated = ( $is_premium === $addon->is_premium() );
3172
+ }
3173
+
3174
+ return $is_activated;
3175
+ }
3176
+
3177
+ /**
3178
+ * Check if add-on was connected to install
3179
+ *
3180
+ * @author Vova Feldman (@svovaf)
3181
+ * @since 1.1.7
3182
+ *
3183
+ * @param string $slug
3184
+ *
3185
+ * @return bool
3186
+ */
3187
+ function is_addon_connected( $slug ) {
3188
+ $this->_logger->entrance();
3189
+
3190
+ $sites = self::get_all_sites();
3191
+
3192
+ if ( ! isset( $sites[ $slug ] ) ) {
3193
+ return false;
3194
+ }
3195
+
3196
+ $site = $sites[ $slug ];
3197
+
3198
+ $plugin = FS_Plugin_Manager::instance( $slug )->get();
3199
+
3200
+ if ( $plugin->parent_plugin_id != $this->_plugin->id ) {
3201
+ // The given slug do NOT belong to any of the plugin's add-ons.
3202
+ return false;
3203
+ }
3204
+
3205
+ return ( is_object( $site ) &&
3206
+ is_numeric( $site->id ) &&
3207
+ is_numeric( $site->user_id ) &&
3208
+ is_object( $site->plan )
3209
+ );
3210
+ }
3211
+
3212
+ /**
3213
+ * Determines if add-on installed.
3214
+ *
3215
+ * NOTE: This is a heuristic and only works if the folder/file named as the slug.
3216
+ *
3217
+ * @author Vova Feldman (@svovaf)
3218
+ * @since 1.0.6
3219
+ *
3220
+ * @param string $slug
3221
+ *
3222
+ * @return bool
3223
+ */
3224
+ function is_addon_installed( $slug ) {
3225
+ $this->_logger->entrance();
3226
+
3227
+ return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $slug ) ) );
3228
+ }
3229
+
3230
+ /**
3231
+ * Get add-on basename.
3232
+ *
3233
+ * @author Vova Feldman (@svovaf)
3234
+ * @since 1.0.6
3235
+ *
3236
+ * @param string $slug
3237
+ *
3238
+ * @return string
3239
+ */
3240
+ function get_addon_basename( $slug ) {
3241
+ if ( $this->is_addon_activated( $slug ) ) {
3242
+ self::instance( $slug )->get_plugin_basename();
3243
+ }
3244
+
3245
+ $premium_basename = "{$slug}-premium/{$slug}.php";
3246
+
3247
+ if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $premium_basename ) ) ) {
3248
+ return $premium_basename;
3249
+ }
3250
+
3251
+ $free_basename = "{$slug}/{$slug}.php";
3252
+
3253
+ return $free_basename;
3254
+ }
3255
+
3256
+ /**
3257
+ * Get installed add-ons instances.
3258
+ *
3259
+ * @author Vova Feldman (@svovaf)
3260
+ * @since 1.0.6
3261
+ *
3262
+ * @return Freemius[]
3263
+ */
3264
+ function get_installed_addons() {
3265
+ $installed_addons = array();
3266
+ foreach ( self::$_instances as $slug => $instance ) {
3267
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
3268
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
3269
+ $installed_addons[] = $instance;
3270
+ }
3271
+ }
3272
+ }
3273
+
3274
+ return $installed_addons;
3275
+ }
3276
+
3277
+ /**
3278
+ * Check if any add-ons of the plugin are installed.
3279
+ *
3280
+ * @author Leo Fajardo (@leorw)
3281
+ * @since 1.1.1
3282
+ *
3283
+ * @return bool
3284
+ */
3285
+ function has_installed_addons() {
3286
+ if ( ! $this->has_addons() ) {
3287
+ return false;
3288
+ }
3289
+
3290
+ foreach ( self::$_instances as $slug => $instance ) {
3291
+ if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
3292
+ if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
3293
+ return true;
3294
+ }
3295
+ }
3296
+ }
3297
+
3298
+ return false;
3299
+ }
3300
+
3301
+ /**
3302
+ * Tell Freemius that the current plugin is an add-on.
3303
+ *
3304
+ * @author Vova Feldman (@svovaf)
3305
+ * @since 1.0.6
3306
+ *
3307
+ * @param number $parent_plugin_id The parent plugin ID
3308
+ */
3309
+ function init_addon( $parent_plugin_id ) {
3310
+ $this->_plugin->parent_plugin_id = $parent_plugin_id;
3311
+ }
3312
+
3313
+ /**
3314
+ * @author Vova Feldman (@svovaf)
3315
+ * @since 1.0.6
3316
+ *
3317
+ * @return bool
3318
+ */
3319
+ function is_addon() {
3320
+ return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
3321
+ }
3322
+
3323
+ /**
3324
+ * Deactivate add-on if it's premium only and the user does't have a valid license.
3325
+ *
3326
+ * @param bool $is_after_trial_cancel
3327
+ *
3328
+ * @return bool If add-on was deactivated.
3329
+ */
3330
+ private function deactivate_premium_only_addon_without_license( $is_after_trial_cancel = false ) {
3331
+ if ( ! $this->has_free_plan() &&
3332
+ ! $this->has_features_enabled_license() &&
3333
+ ! $this->_has_premium_license()
3334
+ ) {
3335
+ // IF wrapper is turned off because activation_timestamp is currently only stored for plugins (not addons).
3336
+ // if (empty($this->_storage->activation_timestamp) ||
3337
+ // (WP_FS__SCRIPT_START_TIME - $this->_storage->activation_timestamp) > 30
3338
+ // ) {
3339
+ /**
3340
+ * @todo When it's first fail, there's no reason to try and re-sync because the licenses were just synced after initial activation.
3341
+ *
3342
+ * Retry syncing the user add-on licenses.
3343
+ */
3344
+ // Sync licenses.
3345
+ $this->_sync_licenses();
3346
+ // }
3347
+
3348
+ // Try to activate premium license.
3349
+ $this->_activate_license( true );
3350
+
3351
+ if ( ! $this->has_free_plan() &&
3352
+ ! $this->has_features_enabled_license() &&
3353
+ ! $this->_has_premium_license()
3354
+ ) {
3355
+ // @todo Check if deactivate plugins also call the deactivation hook.
3356
+
3357
+ deactivate_plugins( array( $this->_plugin_basename ), true );
3358
+
3359
+ $this->_parent->_admin_notices->add_sticky(
3360
+ sprintf(
3361
+ $this->_parent->get_text( $is_after_trial_cancel ?
3362
+ 'addon-trial-cancelled-message' :
3363
+ 'addon-no-license-message'
3364
+ ),
3365
+ '<b>' . $this->_plugin->title . '</b>'
3366
+ ) . ' ' . sprintf(
3367
+ '<a href="%s" aria-label="%s" class="button button-primary" style="margin-left: 10px; vertical-align: middle;">%s &nbsp;&#10140;</a>',
3368
+ $this->_parent->addon_url( $this->_slug ),
3369
+ esc_attr( sprintf( $this->_parent->get_text( 'more-information-about-x' ), $this->_plugin->title ) ),
3370
+ $this->_parent->get_text( 'purchase-license' )
3371
+ ),
3372
+ 'no_addon_license_' . $this->_slug,
3373
+ ( $is_after_trial_cancel ? '' : $this->_parent->get_text( 'oops' ) . '...' ),
3374
+ ( $is_after_trial_cancel ? 'success' : 'error' )
3375
+ );
3376
+
3377
+ return true;
3378
+ }
3379
+ }
3380
+
3381
+ return false;
3382
+ }
3383
+
3384
+ #endregion
3385
+
3386
+ #----------------------------------------------------------------------------------
3387
+ #region Sandbox
3388
+ #----------------------------------------------------------------------------------
3389
+
3390
+ /**
3391
+ * Set Freemius into sandbox mode for debugging.
3392
+ *
3393
+ * @author Vova Feldman (@svovaf)
3394
+ * @since 1.0.4
3395
+ *
3396
+ * @param string $secret_key
3397
+ */
3398
+ function init_sandbox( $secret_key ) {
3399
+ $this->_plugin->secret_key = $secret_key;
3400
+
3401
+ // Update plugin details.
3402
+ FS_Plugin_Manager::instance( $this->_slug )->update( $this->_plugin, true );
3403
+ }
3404
+
3405
+ /**
3406
+ * Check if running payments in sandbox mode.
3407
+ *
3408
+ * @author Vova Feldman (@svovaf)
3409
+ * @since 1.0.4
3410
+ *
3411
+ * @return bool
3412
+ */
3413
+ function is_payments_sandbox() {
3414
+ return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
3415
+ }
3416
+
3417
+ #endregion
3418
+
3419
+ /**
3420
+ * Check if running test vs. live plugin.
3421
+ *
3422
+ * @author Vova Feldman (@svovaf)
3423
+ * @since 1.0.5
3424
+ *
3425
+ * @return bool
3426
+ */
3427
+ function is_live() {
3428
+ return $this->_plugin->is_live;
3429
+ }
3430
+
3431
+ /**
3432
+ * Check if the user skipped connecting the account with Freemius.
3433
+ *
3434
+ * @author Vova Feldman (@svovaf)
3435
+ * @since 1.0.7
3436
+ *
3437
+ * @return bool
3438
+ */
3439
+ function is_anonymous() {
3440
+ if ( ! isset( $this->_is_anonymous ) ) {
3441
+ if ( ! isset( $this->_storage->is_anonymous ) ) {
3442
+ // Not skipped.
3443
+ $this->_is_anonymous = false;
3444
+ } else if ( is_bool( $this->_storage->is_anonymous ) ) {
3445
+ // For back compatibility, since the variable was boolean before.
3446
+ $this->_is_anonymous = $this->_storage->is_anonymous;
3447
+
3448
+ // Upgrade stored data format to 1.1.3 format.
3449
+ $this->set_anonymous_mode( $this->_storage->is_anonymous );
3450
+ } else {
3451
+ // Version 1.1.3 and later.
3452
+ $this->_is_anonymous = $this->_storage->is_anonymous['is'];
3453
+ }
3454
+ }
3455
+
3456
+ return $this->_is_anonymous;
3457
+ }
3458
+
3459
+ /**
3460
+ * Check if user connected his account and install pending email activation.
3461
+ *
3462
+ * @author Vova Feldman (@svovaf)
3463
+ * @since 1.0.7
3464
+ *
3465
+ * @return bool
3466
+ */
3467
+ function is_pending_activation() {
3468
+ return $this->_storage->get( 'is_pending_activation', false );
3469
+ }
3470
+
3471
+ /**
3472
+ * Check if plugin must be WordPress.org compliant.
3473
+ *
3474
+ * @since 1.0.7
3475
+ *
3476
+ * @return bool
3477
+ */
3478
+ function is_org_repo_compliant() {
3479
+ return $this->_is_org_compliant;
3480
+ }
3481
+
3482
+ #----------------------------------------------------------------------------------
3483
+ #region Daily Sync Cron
3484
+ #----------------------------------------------------------------------------------
3485
+
3486
+ /**
3487
+ * @author Vova Feldman (@svovaf)
3488
+ * @since 1.1.7.3
3489
+ */
3490
+ private function run_manual_sync() {
3491
+ $this->require_pluggable_essentials();
3492
+
3493
+ if ( ! $this->is_user_admin() ) {
3494
+ return;
3495
+ }
3496
+
3497
+ // Run manual sync.
3498
+ $this->_sync_cron();
3499
+
3500
+ // Reschedule next cron to run 24 hours from now (performance optimization).
3501
+ $this->clear_sync_cron();
3502
+
3503
+ $this->schedule_sync_cron( time() + WP_FS__TIME_24_HOURS_IN_SEC, false );
3504
+ }
3505
+
3506
+ /**
3507
+ * Data sync cron job. Replaces the background sync non blocking HTTP request
3508
+ * that doesn't halt page loading.
3509
+ *
3510
+ * @author Vova Feldman (@svovaf)
3511
+ * @since 1.1.7.3
3512
+ */
3513
+ function _sync_cron() {
3514
+ $this->_logger->entrance();
3515
+
3516
+ // Store the last time data sync was executed.
3517
+ $this->_storage->sync_timestamp = time();
3518
+
3519
+ // Check if API is temporary down.
3520
+ if ( FS_Api::is_temporary_down() ) {
3521
+ return;
3522
+ }
3523
+
3524
+ // @todo Add logic that identifies API latency, and reschedule the next background sync randomly between 8-16 hours.
3525
+
3526
+ if ( $this->is_registered() ) {
3527
+ if ( $this->has_paid_plan() ) {
3528
+ // Initiate background plan sync.
3529
+ $this->_sync_license( true );
3530
+
3531
+ if ( $this->is_paying() ) {
3532
+ // Check for premium plugin updates.
3533
+ $this->check_updates( true );
3534
+ }
3535
+ } else {
3536
+ // Sync install (only if something changed locally).
3537
+ $this->sync_install();
3538
+ }
3539
+ }
3540
+
3541
+ $this->do_action( 'after_sync_cron' );
3542
+ }
3543
+
3544
+ /**
3545
+ * Check if sync was executed in the last $period of seconds.
3546
+ *
3547
+ * @author Vova Feldman (@svovaf)
3548
+ * @since 1.1.7.3
3549
+ *
3550
+ * @param int $period In seconds
3551
+ *
3552
+ * @return bool
3553
+ */
3554
+ private function is_sync_executed( $period = WP_FS__TIME_24_HOURS_IN_SEC ) {
3555
+ if ( ! isset( $this->_storage->sync_timestamp ) ) {
3556
+ return false;
3557
+ }
3558
+
3559
+ return ( $this->_storage->sync_timestamp > ( WP_FS__SCRIPT_START_TIME - $period ) );
3560
+ }
3561
+
3562
+ /**
3563
+ * @author Vova Feldman (@svovaf)
3564
+ * @since 1.1.7.3
3565
+ *
3566
+ * @return bool
3567
+ */
3568
+ private function is_sync_cron_on() {
3569
+ /**
3570
+ * @var object $sync_cron_data
3571
+ */
3572
+ $sync_cron_data = $this->_storage->get( 'sync_cron', null );
3573
+
3574
+ return ( ! is_null( $sync_cron_data ) && true === $sync_cron_data->on );
3575
+ }
3576
+
3577
+ /**
3578
+ * @author Vova Feldman (@svovaf)
3579
+ * @since 1.1.7.3
3580
+ *
3581
+ * @param int $start_at Defaults to now.
3582
+ * @param bool $randomize_start If true, schedule first job randomly during the next 12 hours. Otherwise,
3583
+ * schedule job to start right away.
3584
+ */
3585
+ private function schedule_sync_cron( $start_at = WP_FS__SCRIPT_START_TIME, $randomize_start = true ) {
3586
+ $this->_logger->entrance();
3587
+
3588
+ if ( $randomize_start ) {
3589
+ // Schedule first sync with a random 12 hour time range from now.
3590
+ $start_at += rand( 0, ( WP_FS__TIME_24_HOURS_IN_SEC / 2 ) );
3591
+ }
3592
+
3593
+ // Schedule daily WP cron.
3594
+ wp_schedule_event(
3595
+ $start_at,
3596
+ 'daily',
3597
+ $this->get_action_tag( 'data_sync' )
3598
+ );
3599
+
3600
+ $this->_storage->store( 'sync_cron', (object) array(
3601
+ 'version' => $this->get_plugin_version(),
3602
+ 'sdk_version' => $this->version,
3603
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
3604
+ 'on' => true,
3605
+ ) );
3606
+ }
3607
+
3608
+ /**
3609
+ * Add the actual sync function to the cron job hook.
3610
+ *
3611
+ * @author Vova Feldman (@svovaf)
3612
+ * @since 1.1.7.3
3613
+ */
3614
+ private function hook_callback_to_sync_cron() {
3615
+ $this->add_action( 'data_sync', array( &$this, '_sync_cron' ) );
3616
+ }
3617
+
3618
+ /**
3619
+ * @author Vova Feldman (@svovaf)
3620
+ * @since 1.1.7.3
3621
+ */
3622
+ private function clear_sync_cron() {
3623
+ $this->_logger->entrance();
3624
+
3625
+ if ( ! $this->is_sync_cron_on() ) {
3626
+ return;
3627
+ }
3628
+
3629
+ $this->_storage->remove( 'sync_cron' );
3630
+
3631
+ wp_clear_scheduled_hook( $this->get_action_tag( 'data_sync' ) );
3632
+ }
3633
+
3634
+ /**
3635
+ * Unix timestamp for next sync cron execution or false if not scheduled.
3636
+ *
3637
+ * @author Vova Feldman (@svovaf)
3638
+ * @since 1.1.7.3
3639
+ *
3640
+ * @return int|false
3641
+ */
3642
+ function next_sync_cron() {
3643
+ $this->_logger->entrance();
3644
+
3645
+ if ( ! $this->is_sync_cron_on() ) {
3646
+ return false;
3647
+ }
3648
+
3649
+ return wp_next_scheduled( $this->get_action_tag( 'data_sync' ) );
3650
+ }
3651
+
3652
+ /**
3653
+ * Unix timestamp for previous sync cron execution or false if never executed.
3654
+ *
3655
+ * @author Vova Feldman (@svovaf)
3656
+ * @since 1.1.7.3
3657
+ *
3658
+ * @return int|false
3659
+ */
3660
+ function last_sync_cron() {
3661
+ $this->_logger->entrance();
3662
+
3663
+ return $this->_storage->get( 'sync_timestamp' );
3664
+ }
3665
+
3666
+ #endregion Daily Sync Cron ------------------------------------------------------------------
3667
+
3668
+ #----------------------------------------------------------------------------------
3669
+ #region Async Install Sync
3670
+ #----------------------------------------------------------------------------------
3671
+
3672
+ /**
3673
+ * @author Vova Feldman (@svovaf)
3674
+ * @since 1.1.7.3
3675
+ *
3676
+ * @return bool
3677
+ */
3678
+ private function is_install_sync_scheduled() {
3679
+ /**
3680
+ * @var object $cron_data
3681
+ */
3682
+ $cron_data = $this->_storage->get( 'install_sync_cron', null );
3683
+
3684
+ return ( ! is_null( $cron_data ) && true === $cron_data->on );
3685
+ }
3686
+
3687
+ /**
3688
+ * Instead of running blocking install sync event, execute non blocking scheduled wp-cron.
3689
+ *
3690
+ * @author Vova Feldman (@svovaf)
3691
+ * @since 1.1.7.3
3692
+ */
3693
+ private function schedule_install_sync() {
3694
+ $this->_logger->entrance();
3695
+
3696
+ $this->clear_install_sync_cron();
3697
+
3698
+ // Schedule immediate install sync.
3699
+ wp_schedule_single_event(
3700
+ WP_FS__SCRIPT_START_TIME,
3701
+ $this->get_action_tag( 'install_sync' )
3702
+ );
3703
+
3704
+ $this->_storage->store( 'install_sync_cron', (object) array(
3705
+ 'version' => $this->get_plugin_version(),
3706
+ 'sdk_version' => $this->version,
3707
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
3708
+ 'on' => true,
3709
+ ) );
3710
+ }
3711
+
3712
+ /**
3713
+ * Unix timestamp for previous install sync cron execution or false if never executed.
3714
+ *
3715
+ * @todo There's some very strange bug that $this->_storage->install_sync_timestamp value is not being
3716
+ * updated. But for sure the sync event is working.
3717
+ *
3718
+ * @author Vova Feldman (@svovaf)
3719
+ * @since 1.1.7.3
3720
+ *
3721
+ * @return int|false
3722
+ */
3723
+ function last_install_sync() {
3724
+ $this->_logger->entrance();
3725
+
3726
+ return $this->_storage->get( 'install_sync_timestamp' );
3727
+ }
3728
+
3729
+ /**
3730
+ * Unix timestamp for next install sync cron execution or false if not scheduled.
3731
+ *
3732
+ * @author Vova Feldman (@svovaf)
3733
+ * @since 1.1.7.3
3734
+ *
3735
+ * @return int|false
3736
+ */
3737
+ function next_install_sync() {
3738
+ $this->_logger->entrance();
3739
+
3740
+ if ( ! $this->is_install_sync_scheduled() ) {
3741
+ return false;
3742
+ }
3743
+
3744
+ return wp_next_scheduled( $this->get_action_tag( 'install_sync' ) );
3745
+ }
3746
+
3747
+ /**
3748
+ * Add the actual install sync function to the cron job hook.
3749
+ *
3750
+ * @author Vova Feldman (@svovaf)
3751
+ * @since 1.1.7.3
3752
+ */
3753
+ private function hook_callback_to_install_sync() {
3754
+ $this->add_action( 'install_sync', array( &$this, '_run_sync_install' ) );
3755
+ }
3756
+
3757
+ /**
3758
+ * @author Vova Feldman (@svovaf)
3759
+ * @since 1.1.7.3
3760
+ */
3761
+ private function clear_install_sync_cron() {
3762
+ $this->_logger->entrance();
3763
+
3764
+ if ( ! $this->is_install_sync_scheduled() ) {
3765
+ return;
3766
+ }
3767
+
3768
+ $this->_storage->remove( 'install_sync_cron' );
3769
+
3770
+ wp_clear_scheduled_hook( $this->get_action_tag( 'install_sync' ) );
3771
+ }
3772
+
3773
+ /**
3774
+ * @author Vova Feldman (@svovaf)
3775
+ * @since 1.1.7.3
3776
+ */
3777
+ public function _run_sync_install() {
3778
+ $this->_logger->entrance();
3779
+
3780
+ // Update last install sync timestamp.
3781
+ $this->_storage->install_sync_timestamp = time();
3782
+
3783
+ $this->sync_install( array(), true );
3784
+ }
3785
+
3786
+ #endregion Async Install Sync ------------------------------------------------------------------
3787
+
3788
+ /**
3789
+ * Show a notice that activation is currently pending.
3790
+ *
3791
+ * @author Vova Feldman (@svovaf)
3792
+ * @since 1.0.7
3793
+ *
3794
+ * @param bool|string $email
3795
+ * @param bool $is_pending_trial Since 1.2.1.5
3796
+ */
3797
+ function _add_pending_activation_notice( $email = false, $is_pending_trial = false ) {
3798
+ if ( ! is_string( $email ) ) {
3799
+ $current_user = self::_get_current_wp_user();
3800
+ $email = $current_user->user_email;
3801
+ }
3802
+
3803
+ $this->_admin_notices->add_sticky(
3804
+ sprintf(
3805
+ $this->get_text( 'pending-activation-message' ),
3806
+ '<b>' . $this->get_plugin_name() . '</b>',
3807
+ '<b>' . $email . '</b>',
3808
+ $this->get_text( $is_pending_trial ? 'start-the-trial' : 'complete-the-install' )
3809
+ ),
3810
+ 'activation_pending',
3811
+ 'Thanks!'
3812
+ );
3813
+ }
3814
+
3815
+ /**
3816
+ * Check if currently in plugin activation.
3817
+ *
3818
+ * @author Vova Feldman (@svovaf)
3819
+ * @since 1.1.4
3820
+ *
3821
+ * @return bool
3822
+ */
3823
+ function is_plugin_activation() {
3824
+ return get_option( "fs_{$this->_slug}_activated", false );
3825
+ }
3826
+
3827
+ /**
3828
+ *
3829
+ * NOTE: admin_menu action executed before admin_init.
3830
+ *
3831
+ * @author Vova Feldman (@svovaf)
3832
+ * @since 1.0.7
3833
+ */
3834
+ function _admin_init_action() {
3835
+ /**
3836
+ * Automatically redirect to connect/activation page after plugin activation.
3837
+ *
3838
+ * @since 1.1.7 Do NOT redirect to opt-in when running in network admin mode.
3839
+ */
3840
+ if ( $this->is_plugin_activation() ) {
3841
+ delete_option( "fs_{$this->_slug}_activated" );
3842
+
3843
+ if ( ! function_exists( 'is_network_admin' ) || ! is_network_admin() ) {
3844
+ $this->_redirect_on_activation_hook();
3845
+
3846
+ return;
3847
+ }
3848
+ }
3849
+
3850
+ if ( fs_request_is_action( $this->_slug . '_skip_activation' ) ) {
3851
+ check_admin_referer( $this->_slug . '_skip_activation' );
3852
+
3853
+ $this->skip_connection();
3854
+
3855
+ fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) );
3856
+ }
3857
+
3858
+ if ( ! $this->is_addon() && ! $this->is_registered() && ! $this->is_anonymous() ) {
3859
+ if ( ! $this->is_pending_activation() ) {
3860
+ if ( ! $this->_menu->is_main_settings_page() ) {
3861
+ if ( $this->is_plugin_new_install() || $this->is_only_premium() ) {
3862
+ // Show notice for new plugin installations.
3863
+ $this->_admin_notices->add(
3864
+ sprintf(
3865
+ $this->get_text( 'you-are-step-away' ),
3866
+ sprintf( '<b><a href="%s">%s</a></b>',
3867
+ $this->get_activation_url(),
3868
+ sprintf( $this->get_text( 'activate-x-now' ), $this->get_plugin_name() )
3869
+ )
3870
+ ),
3871
+ '',
3872
+ 'update-nag'
3873
+ );
3874
+ } else {
3875
+ if ( ! isset( $this->_storage->sticky_optin_added ) ) {
3876
+ $this->_storage->sticky_optin_added = true;
3877
+
3878
+ // Show notice for new plugin installations.
3879
+ $this->_admin_notices->add_sticky(
3880
+ sprintf(
3881
+ $this->get_text( 'few-plugin-tweaks' ),
3882
+ sprintf( '<b><a href="%s">%s</a></b>',
3883
+ $this->get_activation_url(),
3884
+ sprintf( $this->get_text( 'optin-x-now' ), $this->get_plugin_name() )
3885
+ )
3886
+ ),
3887
+ 'connect_account',
3888
+ '',
3889
+ 'update-nag'
3890
+ );
3891
+ }
3892
+
3893
+ if ( $this->has_filter( 'optin_pointer_element' ) ) {
3894
+ // Don't show admin nag if plugin update.
3895
+ wp_enqueue_script( 'wp-pointer' );
3896
+ wp_enqueue_style( 'wp-pointer' );
3897
+
3898
+ $this->_enqueue_connect_essentials();
3899
+
3900
+ add_action( 'admin_print_footer_scripts', array(
3901
+ $this,
3902
+ '_add_connect_pointer_script'
3903
+ ) );
3904
+ }
3905
+
3906
+ }
3907
+ }
3908
+ }
3909
+ }
3910
+
3911
+ $this->_add_upgrade_action_link();
3912
+ }
3913
+
3914
+ /**
3915
+ * Enqueue connect requires scripts and styles.
3916
+ *
3917
+ * @author Vova Feldman (@svovaf)
3918
+ * @since 1.1.4
3919
+ */
3920
+ function _enqueue_connect_essentials() {
3921
+ wp_enqueue_script( 'jquery' );
3922
+ wp_enqueue_script( 'json2' );
3923
+
3924
+ fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
3925
+ fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
3926
+
3927
+ fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
3928
+ }
3929
+
3930
+ /**
3931
+ * Add connect / opt-in pointer.
3932
+ *
3933
+ * @author Vova Feldman (@svovaf)
3934
+ * @since 1.1.4
3935
+ */
3936
+ function _add_connect_pointer_script() {
3937
+ $vars = array( 'slug' => $this->_slug );
3938
+ $pointer_content = fs_get_template( 'connect.php', $vars );
3939
+ ?>
3940
+ <script type="text/javascript">// <![CDATA[
3941
+ jQuery(document).ready(function ($) {
3942
+ if ('undefined' !== typeof(jQuery().pointer)) {
3943
+
3944
+ var element = <?php echo $this->apply_filters( 'optin_pointer_element', '$("#non_existing_element");' ) ?>;
3945
+
3946
+ if (element.length > 0) {
3947
+ var optin = $(element).pointer($.extend(true, {}, {
3948
+ content : <?php echo json_encode( $pointer_content ) ?>,
3949
+ position : {
3950
+ edge : 'left',
3951
+ align: 'center'
3952
+ },
3953
+ buttons : function () {
3954
+ // Don't show pointer buttons.
3955
+ return '';
3956
+ },
3957
+ pointerWidth: 482
3958
+ }, <?php echo $this->apply_filters( 'optin_pointer_options_json', '{}' ) ?>));
3959
+
3960
+ <?php
3961
+ echo $this->apply_filters( 'optin_pointer_execute', "
3962
+
3963
+ optin.pointer('open');
3964
+
3965
+ // Tag the opt-in pointer with custom class.
3966
+ $('.wp-pointer #fs_connect')
3967
+ .parents('.wp-pointer.wp-pointer-top')
3968
+ .addClass('fs-opt-in-pointer');
3969
+
3970
+ ", 'element', 'optin' ) ?>
3971
+ }
3972
+ }
3973
+ });
3974
+ // ]]></script>
3975
+ <?php
3976
+ }
3977
+
3978
+ /**
3979
+ * Return current page's URL.
3980
+ *
3981
+ * @author Vova Feldman (@svovaf)
3982
+ * @since 1.0.7
3983
+ *
3984
+ * @return string
3985
+ */
3986
+ function current_page_url() {
3987
+ $url = 'http';
3988
+
3989
+ if ( isset( $_SERVER["HTTPS"] ) ) {
3990
+ if ( $_SERVER["HTTPS"] == "on" ) {
3991
+ $url .= "s";
3992
+ }
3993
+ }
3994
+ $url .= "://";
3995
+ if ( $_SERVER["SERVER_PORT"] != "80" ) {
3996
+ $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
3997
+ } else {
3998
+ $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
3999
+ }
4000
+
4001
+ return esc_url( $url );
4002
+ }
4003
+
4004
+ /**
4005
+ * Check if the current page is the plugin's main admin settings page.
4006
+ *
4007
+ * @author Vova Feldman (@svovaf)
4008
+ * @since 1.0.7
4009
+ *
4010
+ * @return bool
4011
+ */
4012
+ function _is_plugin_page() {
4013
+ return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
4014
+ fs_is_plugin_page( $this->_slug );
4015
+ }
4016
+
4017
+ /* Events
4018
+ ------------------------------------------------------------------------------------------------------------------*/
4019
+ /**
4020
+ * Delete site install from Database.
4021
+ *
4022
+ * @author Vova Feldman (@svovaf)
4023
+ * @since 1.0.1
4024
+ *
4025
+ * @param bool $store
4026
+ */
4027
+ function _delete_site( $store = true ) {
4028
+ $sites = self::get_all_sites();
4029
+
4030
+ if ( isset( $sites[ $this->_slug ] ) ) {
4031
+ unset( $sites[ $this->_slug ] );
4032
+ }
4033
+
4034
+ self::$_accounts->set_option( 'sites', $sites, $store );
4035
+ }
4036
+
4037
+ /**
4038
+ * Delete plugin's plans information.
4039
+ *
4040
+ * @param bool $store Flush to Database if true.
4041
+ *
4042
+ * @author Vova Feldman (@svovaf)
4043
+ * @since 1.0.9
4044
+ */
4045
+ private function _delete_plans( $store = true ) {
4046
+ $this->_logger->entrance();
4047
+
4048
+ $plans = self::get_all_plans();
4049
+
4050
+ unset( $plans[ $this->_slug ] );
4051
+
4052
+ self::$_accounts->set_option( 'plans', $plans, $store );
4053
+ }
4054
+
4055
+ /**
4056
+ * Delete all plugin licenses.
4057
+ *
4058
+ * @author Vova Feldman (@svovaf)
4059
+ * @since 1.0.9
4060
+ *
4061
+ * @param bool $store
4062
+ * @param string|bool $plugin_slug
4063
+ */
4064
+ private function _delete_licenses( $store = true, $plugin_slug = false ) {
4065
+ $this->_logger->entrance();
4066
+
4067
+ $all_licenses = self::get_all_licenses();
4068
+
4069
+ if ( ! is_string( $plugin_slug ) ) {
4070
+ $plugin_slug = $this->_slug;
4071
+ }
4072
+
4073
+ unset( $all_licenses[ $plugin_slug ] );
4074
+
4075
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
4076
+ }
4077
+
4078
+ /**
4079
+ * Check if Freemius was added on new plugin installation.
4080
+ *
4081
+ * @author Vova Feldman (@svovaf)
4082
+ * @since 1.1.5
4083
+ *
4084
+ * @return bool
4085
+ */
4086
+ function is_plugin_new_install() {
4087
+ return isset( $this->_storage->is_plugin_new_install ) &&
4088
+ $this->_storage->is_plugin_new_install;
4089
+ }
4090
+
4091
+ /**
4092
+ * Check if it's the first plugin release that is running Freemius.
4093
+ *
4094
+ * @author Vova Feldman (@svovaf)
4095
+ * @since 1.2.1.5
4096
+ *
4097
+ * @return bool
4098
+ */
4099
+ function is_first_freemius_powered_version() {
4100
+ return empty( $this->_storage->plugin_last_version );
4101
+ }
4102
+
4103
+ /**
4104
+ * Plugin activated hook.
4105
+ *
4106
+ * @author Vova Feldman (@svovaf)
4107
+ * @since 1.0.1
4108
+ *
4109
+ * @uses FS_Api
4110
+ */
4111
+ function _activate_plugin_event_hook() {
4112
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
4113
+
4114
+ if ( ! $this->is_user_admin() ) {
4115
+ return;
4116
+ }
4117
+
4118
+ $this->unregister_uninstall_hook();
4119
+
4120
+ // Clear API cache on activation.
4121
+ FS_Api::clear_cache();
4122
+
4123
+ if ( $this->is_registered() ) {
4124
+ $is_premium_version_activation = ( current_filter() !== ( 'activate_' . $this->_free_plugin_basename ) );
4125
+
4126
+ if ( $is_premium_version_activation ) {
4127
+ $this->reconnect_locally();
4128
+ }
4129
+
4130
+ $this->_logger->info( 'Activating ' . ( $is_premium_version_activation ? 'premium' : 'free' ) . ' plugin version.' );
4131
+
4132
+ // Schedule re-activation event and sync.
4133
+ // $this->sync_install( array(), true );
4134
+ $this->schedule_install_sync();
4135
+
4136
+ // 1. If running in the activation of the FREE module, get the basename of the PREMIUM.
4137
+ // 2. If running in the activation of the PREMIUM module, get the basename of the FREE.
4138
+ $other_version_basename = $is_premium_version_activation ?
4139
+ $this->_free_plugin_basename :
4140
+ $this->premium_plugin_basename();
4141
+
4142
+ /**
4143
+ * If the other module version is activate, deactivate it.
4144
+ *
4145
+ * @author Leo Fajardo (@leorw)
4146
+ * @since 1.2.2
4147
+ */
4148
+ if ( is_plugin_active( $other_version_basename ) ) {
4149
+ deactivate_plugins( $other_version_basename );
4150
+ }
4151
+
4152
+ // If activating the premium module version, add an admin notice to congratulate for an upgrade completion.
4153
+ if ( $is_premium_version_activation ) {
4154
+ $this->_admin_notices->add(
4155
+ sprintf( $this->get_text( 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
4156
+ $this->get_text( 'woot' ) . '!'
4157
+ );
4158
+ }
4159
+ } else if ( $this->is_anonymous() ) {
4160
+ /**
4161
+ * Reset "skipped" click cache on the following:
4162
+ * 1. Development mode.
4163
+ * 2. If the user skipped the exact same version before.
4164
+ *
4165
+ * @todo 3. If explicitly asked to retry after every activation.
4166
+ */
4167
+ if ( WP_FS__DEV_MODE ||
4168
+ $this->get_plugin_version() == $this->_storage->is_anonymous['version']
4169
+ ) {
4170
+ $this->reset_anonymous_mode();
4171
+ }
4172
+ }
4173
+
4174
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
4175
+ /**
4176
+ * If no previous version of plugin's version exist, it means that it's either
4177
+ * the first time that the plugin installed on the site, or the plugin was installed
4178
+ * before but didn't have Freemius integrated.
4179
+ *
4180
+ * Since register_activation_hook() do NOT fires on updates since 3.1, and only fires
4181
+ * on manual activation via the dashboard, is_plugin_activation() is TRUE
4182
+ * only after immediate activation.
4183
+ *
4184
+ * @since 1.1.4
4185
+ * @link https://make.wordpress.org/core/2010/10/27/plugin-activation-hooks-no-longer-fire-for-updates/
4186
+ */
4187
+ $this->_storage->is_plugin_new_install = empty( $this->_storage->plugin_last_version );
4188
+ }
4189
+
4190
+ if ( ! $this->_anonymous_mode &&
4191
+ $this->has_api_connectivity( WP_FS__DEV_MODE ) &&
4192
+ ! $this->_isAutoInstall
4193
+ ) {
4194
+ // Store hint that the plugin was just activated to enable auto-redirection to settings.
4195
+ add_option( "fs_{$this->_slug}_activated", true );
4196
+ }
4197
+
4198
+ /**
4199
+ * Activation hook is executed after the plugin's main file is loaded, therefore,
4200
+ * after the plugin was loaded. The logic is located at activate_plugin()
4201
+ * ./wp-admin/includes/plugin.php.
4202
+ *
4203
+ * @author Vova Feldman (@svovaf)
4204
+ * @since 1.1.9
4205
+ */
4206
+ $this->_storage->was_plugin_loaded = true;
4207
+ }
4208
+
4209
+ /**
4210
+ * Delete account.
4211
+ *
4212
+ * @author Vova Feldman (@svovaf)
4213
+ * @since 1.0.3
4214
+ *
4215
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
4216
+ */
4217
+ function delete_account_event( $check_user = true ) {
4218
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
4219
+
4220
+ if ( $check_user && ! $this->is_user_admin() ) {
4221
+ return;
4222
+ }
4223
+
4224
+ $this->do_action( 'before_account_delete' );
4225
+
4226
+ // Clear all admin notices.
4227
+ $this->_admin_notices->clear_all_sticky();
4228
+
4229
+ $this->_delete_site( false );
4230
+
4231
+ $this->_delete_plans( false );
4232
+
4233
+ $this->_delete_licenses( false );
4234
+
4235
+ // Delete add-ons related to plugin's account.
4236
+ $this->_delete_account_addons( false );
4237
+
4238
+ // @todo Delete plans and licenses of add-ons.
4239
+
4240
+ self::$_accounts->store();
4241
+
4242
+ /**
4243
+ * IMPORTANT:
4244
+ * Clear crons must be executed before clearing all storage.
4245
+ * Otherwise, the cron will not be cleared.
4246
+ */
4247
+ $this->clear_sync_cron();
4248
+ $this->clear_install_sync_cron();
4249
+
4250
+ // Clear all storage data.
4251
+ $this->_storage->clear_all( true, array(
4252
+ 'connectivity_test',
4253
+ 'is_on',
4254
+ ) );
4255
+
4256
+ // Send delete event.
4257
+ $this->get_api_site_scope()->call( '/', 'delete' );
4258
+
4259
+ $this->do_action( 'after_account_delete' );
4260
+ }
4261
+
4262
+ /**
4263
+ * Plugin deactivation hook.
4264
+ *
4265
+ * @author Vova Feldman (@svovaf)
4266
+ * @since 1.0.1
4267
+ */
4268
+ function _deactivate_plugin_hook() {
4269
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
4270
+
4271
+ if ( ! current_user_can( 'activate_plugins' ) ) {
4272
+ return;
4273
+ }
4274
+
4275
+ $this->_admin_notices->clear_all_sticky();
4276
+ if ( isset( $this->_storage->sticky_optin_added ) ) {
4277
+ unset( $this->_storage->sticky_optin_added );
4278
+ }
4279
+
4280
+ if ( ! isset( $this->_storage->is_plugin_new_install ) ) {
4281
+ // Remember that plugin was already installed.
4282
+ $this->_storage->is_plugin_new_install = false;
4283
+ }
4284
+
4285
+ // Hook to plugin uninstall.
4286
+ register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
4287
+
4288
+ $this->clear_module_main_file_cache();
4289
+ $this->clear_sync_cron();
4290
+ $this->clear_install_sync_cron();
4291
+
4292
+ if ( $this->is_registered() ) {
4293
+ // Send deactivation event.
4294
+ $this->sync_install( array(
4295
+ 'is_active' => false,
4296
+ ) );
4297
+ } else {
4298
+ if ( ! $this->has_api_connectivity() ) {
4299
+ // Reset connectivity test cache.
4300
+ unset( $this->_storage->connectivity_test );
4301
+ }
4302
+ }
4303
+
4304
+ // Clear API cache on deactivation.
4305
+ FS_Api::clear_cache();
4306
+
4307
+ $this->remove_sdk_reference();
4308
+ }
4309
+
4310
+ /**
4311
+ * @author Vova Feldman (@svovaf)
4312
+ * @since 1.1.6
4313
+ */
4314
+ private function remove_sdk_reference() {
4315
+ global $fs_active_plugins;
4316
+
4317
+ foreach ( $fs_active_plugins->plugins as $sdk_path => &$data ) {
4318
+ if ( $this->_plugin_basename == $data->plugin_path ) {
4319
+ unset( $fs_active_plugins->plugins[ $sdk_path ] );
4320
+ break;
4321
+ }
4322
+ }
4323
+
4324
+ fs_fallback_to_newest_active_sdk();
4325
+ }
4326
+
4327
+ /**
4328
+ * @author Vova Feldman (@svovaf)
4329
+ * @since 1.1.3
4330
+ *
4331
+ * @param bool $is_anonymous
4332
+ */
4333
+ private function set_anonymous_mode( $is_anonymous = true ) {
4334
+ // Store information regarding skip to try and opt-in the user
4335
+ // again in the future.
4336
+ $this->_storage->is_anonymous = array(
4337
+ 'is' => $is_anonymous,
4338
+ 'timestamp' => WP_FS__SCRIPT_START_TIME,
4339
+ 'version' => $this->get_plugin_version(),
4340
+ );
4341
+
4342
+ // Update anonymous mode cache.
4343
+ $this->_is_anonymous = $is_anonymous;
4344
+ }
4345
+
4346
+ /**
4347
+ * @author Vova Feldman (@svovaf)
4348
+ * @since 1.1.3
4349
+ */
4350
+ private function reset_anonymous_mode() {
4351
+ unset( $this->_storage->is_anonymous );
4352
+ }
4353
+
4354
+ /**
4355
+ * Clears the anonymous mode and redirects to the opt-in screen.
4356
+ *
4357
+ * @author Vova Feldman (@svovaf)
4358
+ * @since 1.1.7
4359
+ */
4360
+ function connect_again() {
4361
+ if ( ! $this->is_anonymous() ) {
4362
+ return;
4363
+ }
4364
+
4365
+ $this->reset_anonymous_mode();
4366
+
4367
+ fs_redirect( $this->get_activation_url() );
4368
+ }
4369
+
4370
+ /**
4371
+ * Skip account connect, and set anonymous mode.
4372
+ *
4373
+ * @author Vova Feldman (@svovaf)
4374
+ * @since 1.1.1
4375
+ */
4376
+ private function skip_connection() {
4377
+ $this->_logger->entrance();
4378
+
4379
+ $this->_admin_notices->remove_sticky( 'connect_account' );
4380
+
4381
+ $this->set_anonymous_mode();
4382
+
4383
+ // Send anonymous skip event.
4384
+ // No user identified info nor any tracking will be sent after the user skips the opt-in.
4385
+ $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
4386
+ 'uid' => $this->get_anonymous_id(),
4387
+ ) );
4388
+ }
4389
+
4390
+ /**
4391
+ * Plugin version update hook.
4392
+ *
4393
+ * @author Vova Feldman (@svovaf)
4394
+ * @since 1.0.4
4395
+ */
4396
+ private function update_plugin_version_event() {
4397
+ $this->_logger->entrance();
4398
+
4399
+ if ( ! $this->is_registered() ) {
4400
+ return;
4401
+ }
4402
+
4403
+ $this->schedule_install_sync();
4404
+ // $this->sync_install( array(), true );
4405
+ }
4406
+
4407
+ /**
4408
+ * Return a list of modified plugins since the last sync.
4409
+ *
4410
+ * Note:
4411
+ * There's no point to store a plugins counter since even if the number of
4412
+ * plugins didn't change, we still need to check if the versions are all the
4413
+ * same and the activity state is similar.
4414
+ *
4415
+ * @author Vova Feldman (@svovaf)
4416
+ * @since 1.1.8
4417
+ *
4418
+ * @return array|false
4419
+ */
4420
+ private function get_plugins_data_for_api() {
4421
+ // Alias.
4422
+ $option_name = 'all_plugins';
4423
+
4424
+ $all_cached_plugins = self::$_accounts->get_option( $option_name );
4425
+
4426
+ if ( ! is_object( $all_cached_plugins ) ) {
4427
+ $all_cached_plugins = (object) array(
4428
+ 'timestamp' => '',
4429
+ 'md5' => '',
4430
+ 'plugins' => array(),
4431
+ );
4432
+ }
4433
+
4434
+ $time = time();
4435
+
4436
+ if ( ! empty( $all_cached_plugins->timestamp ) &&
4437
+ ( $time - $all_cached_plugins->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
4438
+ ) {
4439
+ // Don't send plugin updates if last update was in the past 5 min.
4440
+ return false;
4441
+ }
4442
+
4443
+ // Write timestamp to lock the logic.
4444
+ $all_cached_plugins->timestamp = $time;
4445
+ self::$_accounts->set_option( $option_name, $all_cached_plugins, true );
4446
+
4447
+ // Reload options from DB.
4448
+ self::$_accounts->load( true );
4449
+ $all_cached_plugins = self::$_accounts->get_option( $option_name );
4450
+
4451
+ if ( $time != $all_cached_plugins->timestamp ) {
4452
+ // If timestamp is different, then another thread captured the lock.
4453
+ return false;
4454
+ }
4455
+
4456
+ // Check if there's a change in plugins.
4457
+ $all_plugins = self::get_all_plugins();
4458
+
4459
+ // Check if plugins changed.
4460
+ ksort( $all_plugins );
4461
+
4462
+ $plugins_signature = '';
4463
+ foreach ( $all_plugins as $basename => $data ) {
4464
+ $plugins_signature .= $data['slug'] . ',' .
4465
+ $data['Version'] . ',' .
4466
+ ( $data['is_active'] ? '1' : '0' ) . ';';
4467
+ }
4468
+
4469
+ // Check if plugins status changed (version or active/inactive).
4470
+ $plugins_changed = ( $all_cached_plugins->md5 !== md5( $plugins_signature ) );
4471
+
4472
+ $plugins_update_data = array();
4473
+
4474
+ if ( $plugins_changed ) {
4475
+ // Change in plugins, report changes.
4476
+
4477
+ // Update existing plugins info.
4478
+ foreach ( $all_cached_plugins->plugins as $basename => $data ) {
4479
+ if ( ! isset( $all_plugins[ $basename ] ) ) {
4480
+ // Plugin uninstalled.
4481
+ $uninstalled_plugin_data = $data;
4482
+ $uninstalled_plugin_data['is_active'] = false;
4483
+ $uninstalled_plugin_data['is_uninstalled'] = true;
4484
+ $plugins_update_data[] = $uninstalled_plugin_data;
4485
+
4486
+ unset( $all_plugins[ $basename ] );
4487
+ unset( $all_cached_plugins->plugins[ $basename ] );
4488
+ } else if ( $data['is_active'] !== $all_plugins[ $basename ]['is_active'] ||
4489
+ $data['version'] !== $all_plugins[ $basename ]['Version']
4490
+ ) {
4491
+ // Plugin activated or deactivated, or version changed.
4492
+ $all_cached_plugins->plugins[ $basename ]['is_active'] = $all_plugins[ $basename ]['is_active'];
4493
+ $all_cached_plugins->plugins[ $basename ]['version'] = $all_plugins[ $basename ]['Version'];
4494
+
4495
+ $plugins_update_data[] = $all_cached_plugins->plugins[ $basename ];
4496
+ }
4497
+ }
4498
+
4499
+ // Find new plugins that weren't yet seen before.
4500
+ foreach ( $all_plugins as $basename => $data ) {
4501
+ if ( ! isset( $all_cached_plugins->plugins[ $basename ] ) ) {
4502
+ // New plugin.
4503
+ $new_plugin = array(
4504
+ 'slug' => $data['slug'],
4505
+ 'version' => $data['Version'],
4506
+ 'title' => $data['Name'],
4507
+ 'is_active' => $data['is_active'],
4508
+ 'is_uninstalled' => false,
4509
+ );
4510
+
4511
+ $plugins_update_data[] = $new_plugin;
4512
+ $all_cached_plugins->plugins[ $basename ] = $new_plugin;
4513
+ }
4514
+ }
4515
+
4516
+ $all_cached_plugins->md5 = md5( $plugins_signature );
4517
+ $all_cached_plugins->timestamp = $time;
4518
+ self::$_accounts->set_option( $option_name, $all_cached_plugins, true );
4519
+ }
4520
+
4521
+ return $plugins_update_data;
4522
+ }
4523
+
4524
+ /**
4525
+ * Return a list of modified themes since the last sync.
4526
+ *
4527
+ * Note:
4528
+ * There's no point to store a themes counter since even if the number of
4529
+ * themes didn't change, we still need to check if the versions are all the
4530
+ * same and the activity state is similar.
4531
+ *
4532
+ * @author Vova Feldman (@svovaf)
4533
+ * @since 1.1.8
4534
+ *
4535
+ * @return array|false
4536
+ */
4537
+ private function get_themes_data_for_api() {
4538
+ // Alias.
4539
+ $option_name = 'all_themes';
4540
+
4541
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
4542
+
4543
+ if ( ! is_object( $all_cached_themes ) ) {
4544
+ $all_cached_themes = (object) array(
4545
+ 'timestamp' => '',
4546
+ 'md5' => '',
4547
+ 'themes' => array(),
4548
+ );
4549
+ }
4550
+
4551
+ $time = time();
4552
+
4553
+ if ( ! empty( $all_cached_themes->timestamp ) &&
4554
+ ( $time - $all_cached_themes->timestamp ) < WP_FS__TIME_5_MIN_IN_SEC
4555
+ ) {
4556
+ // Don't send theme updates if last update was in the past 5 min.
4557
+ return false;
4558
+ }
4559
+
4560
+ // Write timestamp to lock the logic.
4561
+ $all_cached_themes->timestamp = $time;
4562
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
4563
+
4564
+ // Reload options from DB.
4565
+ self::$_accounts->load( true );
4566
+ $all_cached_themes = self::$_accounts->get_option( $option_name );
4567
+
4568
+ if ( $time != $all_cached_themes->timestamp ) {
4569
+ // If timestamp is different, then another thread captured the lock.
4570
+ return false;
4571
+ }
4572
+
4573
+ // Get active theme.
4574
+ $active_theme = wp_get_theme();
4575
+ $active_theme_stylesheet = $active_theme->get_stylesheet();
4576
+
4577
+ // Check if there's a change in themes.
4578
+ $all_themes = wp_get_themes();
4579
+
4580
+ // Check if themes changed.
4581
+ ksort( $all_themes );
4582
+
4583
+ $themes_signature = '';
4584
+ foreach ( $all_themes as $slug => $data ) {
4585
+ $is_active = ( $slug === $active_theme_stylesheet );
4586
+ $themes_signature .= $slug . ',' .
4587
+ $data->version . ',' .
4588
+ ( $is_active ? '1' : '0' ) . ';';
4589
+ }
4590
+
4591
+ // Check if themes status changed (version or active/inactive).
4592
+ $themes_changed = ( $all_cached_themes->md5 !== md5( $themes_signature ) );
4593
+
4594
+ $themes_update_data = array();
4595
+
4596
+ if ( $themes_changed ) {
4597
+ // Change in themes, report changes.
4598
+
4599
+ // Update existing themes info.
4600
+ foreach ( $all_cached_themes->themes as $slug => $data ) {
4601
+ $is_active = ( $slug === $active_theme_stylesheet );
4602
+
4603
+ if ( ! isset( $all_themes[ $slug ] ) ) {
4604
+ // Plugin uninstalled.
4605
+ $uninstalled_theme_data = $data;
4606
+ $uninstalled_theme_data['is_active'] = false;
4607
+ $uninstalled_theme_data['is_uninstalled'] = true;
4608
+ $themes_update_data[] = $uninstalled_theme_data;
4609
+
4610
+ unset( $all_themes[ $slug ] );
4611
+ unset( $all_cached_themes->themes[ $slug ] );
4612
+ } else if ( $data['is_active'] !== $is_active ||
4613
+ $data['version'] !== $all_themes[ $slug ]->version
4614
+ ) {
4615
+ // Plugin activated or deactivated, or version changed.
4616
+
4617
+ $all_cached_themes->themes[ $slug ]['is_active'] = $is_active;
4618
+ $all_cached_themes->themes[ $slug ]['version'] = $all_themes[ $slug ]->version;
4619
+
4620
+ $themes_update_data[] = $all_cached_themes->themes[ $slug ];
4621
+ }
4622
+ }
4623
+
4624
+ // Find new themes that weren't yet seen before.
4625
+ foreach ( $all_themes as $slug => $data ) {
4626
+ if ( ! isset( $all_cached_themes->themes[ $slug ] ) ) {
4627
+ $is_active = ( $slug === $active_theme_stylesheet );
4628
+
4629
+ // New plugin.
4630
+ $new_plugin = array(
4631
+ 'slug' => $slug,
4632
+ 'version' => $data->version,
4633
+ 'title' => $data->name,
4634
+ 'is_active' => $is_active,
4635
+ 'is_uninstalled' => false,
4636
+ );
4637
+
4638
+ $themes_update_data[] = $new_plugin;
4639
+ $all_cached_themes->themes[ $slug ] = $new_plugin;
4640
+ }
4641
+ }
4642
+
4643
+ $all_cached_themes->md5 = md5( $themes_signature );
4644
+ $all_cached_themes->timestamp = time();
4645
+ self::$_accounts->set_option( $option_name, $all_cached_themes, true );
4646
+ }
4647
+
4648
+ return $themes_update_data;
4649
+ }
4650
+
4651
+ /**
4652
+ * Update install details.
4653
+ *
4654
+ * @author Vova Feldman (@svovaf)
4655
+ * @since 1.1.2
4656
+ *
4657
+ * @param string[] string $override
4658
+ * @param bool $include_plugins Since 1.1.8 by default include plugin changes.
4659
+ * @param bool $include_themes Since 1.1.8 by default include plugin changes.
4660
+ *
4661
+ * @return array
4662
+ */
4663
+ private function get_install_data_for_api(
4664
+ array $override,
4665
+ $include_plugins = true,
4666
+ $include_themes = true
4667
+ ) {
4668
+ /**
4669
+ * @since 1.1.8 Also send plugin updates.
4670
+ */
4671
+ if ( $include_plugins && ! isset( $override['plugins'] ) ) {
4672
+ $plugins = $this->get_plugins_data_for_api();
4673
+ if ( ! empty( $plugins ) ) {
4674
+ $override['plugins'] = $plugins;
4675
+ }
4676
+ }
4677
+ /**
4678
+ * @since 1.1.8 Also send themes updates.
4679
+ */
4680
+ if ( $include_themes && ! isset( $override['themes'] ) ) {
4681
+ $themes = $this->get_themes_data_for_api();
4682
+ if ( ! empty( $themes ) ) {
4683
+ $override['themes'] = $themes;
4684
+ }
4685
+ }
4686
+
4687
+ return array_merge( array(
4688
+ 'version' => $this->get_plugin_version(),
4689
+ 'is_premium' => $this->is_premium(),
4690
+ 'language' => get_bloginfo( 'language' ),
4691
+ 'charset' => get_bloginfo( 'charset' ),
4692
+ 'platform_version' => get_bloginfo( 'version' ),
4693
+ 'sdk_version' => $this->version,
4694
+ 'programming_language_version' => phpversion(),
4695
+ 'title' => get_bloginfo( 'name' ),
4696
+ 'url' => get_site_url(),
4697
+ // Special params.
4698
+ 'is_active' => true,
4699
+ 'is_disconnected' => $this->is_tracking_prohibited(),
4700
+ 'is_uninstalled' => false,
4701
+ ), $override );
4702
+ }
4703
+
4704
+ /**
4705
+ * Update install only if changed.
4706
+ *
4707
+ * @author Vova Feldman (@svovaf)
4708
+ * @since 1.0.9
4709
+ *
4710
+ * @param string[] string $override
4711
+ * @param bool $flush
4712
+ *
4713
+ * @return false|object|string
4714
+ */
4715
+ private function send_install_update( $override = array(), $flush = false ) {
4716
+ $this->_logger->entrance();
4717
+
4718
+ $check_properties = $this->get_install_data_for_api( $override );
4719
+
4720
+ if ( $flush ) {
4721
+ $params = $check_properties;
4722
+ } else {
4723
+ $params = array();
4724
+ $special = array();
4725
+ $special_override = false;
4726
+
4727
+ foreach ( $check_properties as $p => $v ) {
4728
+ if ( property_exists( $this->_site, $p ) ) {
4729
+ if ( ( is_bool( $this->_site->{$p} ) || ! empty( $this->_site->{$p} ) ) &&
4730
+ $this->_site->{$p} != $v
4731
+ ) {
4732
+ $this->_site->{$p} = $v;
4733
+ $params[ $p ] = $v;
4734
+ }
4735
+ } else {
4736
+ $special[ $p ] = $v;
4737
+
4738
+ if ( isset( $override[ $p ] ) ||
4739
+ 'plugins' === $p ||
4740
+ 'themes' === $p
4741
+ ) {
4742
+ $special_override = true;
4743
+ }
4744
+ }
4745
+ }
4746
+
4747
+ if ( $special_override || 0 < count( $params ) ) {
4748
+ // Add special params only if has at least one
4749
+ // standard param, or if explicitly requested to
4750
+ // override a special param or a param which is not exist
4751
+ // in the install object.
4752
+ $params = array_merge( $params, $special );
4753
+ }
4754
+ }
4755
+
4756
+ if ( 0 < count( $params ) ) {
4757
+ // Update last install sync timestamp.
4758
+ $this->_storage->install_sync_timestamp = time();
4759
+
4760
+ $params['uid'] = $this->get_anonymous_id();
4761
+
4762
+ // Send updated values to FS.
4763
+ $site = $this->get_api_site_scope()->call( '/', 'put', $params );
4764
+
4765
+ if ( $this->is_api_result_entity( $site ) ) {
4766
+ // I successfully sent install update, clear scheduled sync if exist.
4767
+ $this->clear_install_sync_cron();
4768
+ }
4769
+
4770
+ return $site;
4771
+ }
4772
+
4773
+ return false;
4774
+ }
4775
+
4776
+ /**
4777
+ * Update install only if changed.
4778
+ *
4779
+ * @author Vova Feldman (@svovaf)
4780
+ * @since 1.0.9
4781
+ *
4782
+ * @param string[] string $override
4783
+ * @param bool $flush
4784
+ */
4785
+ private function sync_install( $override = array(), $flush = false ) {
4786
+ $this->_logger->entrance();
4787
+
4788
+ $site = $this->send_install_update( $override, $flush );
4789
+
4790
+ if ( false === $site ) {
4791
+ // No sync required.
4792
+ return;
4793
+ }
4794
+
4795
+ if ( ! $this->is_api_result_entity( $site ) ) {
4796
+ // Failed to sync, don't update locally.
4797
+ return;
4798
+ }
4799
+
4800
+ $plan = $this->get_plan();
4801
+ $this->_site = new FS_Site( $site );
4802
+ $this->_site->plan = $plan;
4803
+
4804
+ $this->_store_site( true );
4805
+ }
4806
+
4807
+ /**
4808
+ * Track install's custom event.
4809
+ *
4810
+ * IMPORTANT:
4811
+ * Custom event tracking is currently only supported for specific clients.
4812
+ * If you are not one of them, please don't use this method. If you will,
4813
+ * the API will simply ignore your request based on the plugin ID.
4814
+ *
4815
+ * Need custom tracking for your plugin or theme?
4816
+ * If you are interested in custom event tracking please contact yo@freemius.com
4817
+ * for further details.
4818
+ *
4819
+ * @author Vova Feldman (@svovaf)
4820
+ * @since 1.2.1
4821
+ *
4822
+ * @param string $name Event name.
4823
+ * @param array $properties Associative key/value array with primitive values only
4824
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
4825
+ * @param bool $once If true, event will be tracked only once. IMPORTANT: Still trigger the API call.
4826
+ *
4827
+ * @return object|false Event data or FALSE on failure.
4828
+ *
4829
+ * @throws \Freemius_InvalidArgumentException
4830
+ */
4831
+ public function track_event( $name, $properties = array(), $process_at = false, $once = false ) {
4832
+ $this->_logger->entrance( http_build_query( array( 'name' => $name, 'once' => $once ) ) );
4833
+
4834
+ if ( ! $this->is_registered() ) {
4835
+ return false;
4836
+ }
4837
+
4838
+ $event = array( 'type' => $name );
4839
+
4840
+ if ( is_numeric( $process_at ) && $process_at > time() ) {
4841
+ $event['process_at'] = $process_at;
4842
+ }
4843
+
4844
+ if ( $once ) {
4845
+ $event['once'] = true;
4846
+ }
4847
+
4848
+ if ( ! empty( $properties ) ) {
4849
+ // Verify associative array values are primitive.
4850
+ foreach ( $properties as $k => $v ) {
4851
+ if ( ! is_scalar( $v ) ) {
4852
+ throw new Freemius_InvalidArgumentException( 'The $properties argument must be an associative key/value array with primitive values only.' );
4853
+ }
4854
+ }
4855
+
4856
+ $event['properties'] = $properties;
4857
+ }
4858
+
4859
+ $result = $this->get_api_site_scope()->call( 'events.json', 'post', $event );
4860
+
4861
+ return $this->is_api_error( $result ) ?
4862
+ false :
4863
+ $result;
4864
+ }
4865
+
4866
+ /**
4867
+ * Track install's custom event only once, but it still triggers the API call.
4868
+ *
4869
+ * IMPORTANT:
4870
+ * Custom event tracking is currently only supported for specific clients.
4871
+ * If you are not one of them, please don't use this method. If you will,
4872
+ * the API will simply ignore your request based on the plugin ID.
4873
+ *
4874
+ * Need custom tracking for your plugin or theme?
4875
+ * If you are interested in custom event tracking please contact yo@freemius.com
4876
+ * for further details.
4877
+ *
4878
+ * @author Vova Feldman (@svovaf)
4879
+ * @since 1.2.1
4880
+ *
4881
+ * @param string $name Event name.
4882
+ * @param array $properties Associative key/value array with primitive values only
4883
+ * @param bool $process_at A valid future date-time in the following format Y-m-d H:i:s.
4884
+ *
4885
+ * @return object|false Event data or FALSE on failure.
4886
+ *
4887
+ * @throws \Freemius_InvalidArgumentException
4888
+ *
4889
+ * @user Freemius::track_event()
4890
+ */
4891
+ public function track_event_once( $name, $properties = array(), $process_at = false ) {
4892
+ return $this->track_event( $name, $properties, $process_at, true );
4893
+ }
4894
+
4895
+ /**
4896
+ * Plugin uninstall hook.
4897
+ *
4898
+ * @author Vova Feldman (@svovaf)
4899
+ * @since 1.0.1
4900
+ *
4901
+ * @param bool $check_user Enforce checking if user have plugins activation privileges.
4902
+ */
4903
+ function _uninstall_plugin_event( $check_user = true ) {
4904
+ $this->_logger->entrance( 'slug = ' . $this->_slug );
4905
+
4906
+ if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
4907
+ return;
4908
+ }
4909
+
4910
+ $params = array();
4911
+ $uninstall_reason = null;
4912
+ if ( isset( $this->_storage->uninstall_reason ) ) {
4913
+ $uninstall_reason = $this->_storage->uninstall_reason;
4914
+ $params['reason_id'] = $uninstall_reason->id;
4915
+ $params['reason_info'] = $uninstall_reason->info;
4916
+ }
4917
+
4918
+ if ( ! $this->is_registered() ) {
4919
+ // Send anonymous uninstall event only if user submitted a feedback.
4920
+ if ( isset( $uninstall_reason ) ) {
4921
+ if ( isset( $uninstall_reason->is_anonymous ) && ! $uninstall_reason->is_anonymous ) {
4922
+ $this->opt_in( false, false, false, false, true );
4923
+ } else {
4924
+ $params['uid'] = $this->get_anonymous_id();
4925
+ $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
4926
+ }
4927
+ }
4928
+ } else {
4929
+ // Send uninstall event.
4930
+ $this->send_install_update( array_merge( $params, array(
4931
+ 'is_active' => false,
4932
+ 'is_uninstalled' => true,
4933
+ ) ) );
4934
+ }
4935
+
4936
+ // @todo Decide if we want to delete plugin information from db.
4937
+ }
4938
+
4939
+ /**
4940
+ * @author Vova Feldman (@svovaf)
4941
+ * @since 1.1.1
4942
+ *
4943
+ * @return string
4944
+ */
4945
+ function premium_plugin_basename() {
4946
+ return "{$this->_slug}-premium/" . basename( $this->_free_plugin_basename );
4947
+ }
4948
+
4949
+ /**
4950
+ * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
4951
+ *
4952
+ * @author Vova Feldman (@svovaf)
4953
+ * @since 1.0.2
4954
+ */
4955
+ public static function _uninstall_plugin_hook() {
4956
+ self::_load_required_static();
4957
+
4958
+ self::$_static_logger->entrance();
4959
+
4960
+ if ( ! current_user_can( 'activate_plugins' ) ) {
4961
+ return;
4962
+ }
4963
+
4964
+ $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
4965
+
4966
+ self::$_static_logger->info( 'plugin = ' . $plugin_file );
4967
+
4968
+ define( 'WP_FS__UNINSTALL_MODE', true );
4969
+
4970
+ $fs = self::get_instance_by_file( $plugin_file );
4971
+
4972
+ if ( is_object( $fs ) ) {
4973
+ self::require_plugin_essentials();
4974
+
4975
+ if ( is_plugin_active( $fs->_free_plugin_basename ) ||
4976
+ is_plugin_active( $fs->premium_plugin_basename() )
4977
+ ) {
4978
+ // Deleting Free or Premium plugin version while the other version still installed.
4979
+ return;
4980
+ }
4981
+
4982
+ $fs->_uninstall_plugin_event();
4983
+
4984
+ $fs->do_action( 'after_uninstall' );
4985
+ }
4986
+ }
4987
+
4988
+ #----------------------------------------------------------------------------------
4989
+ #region Plugin Information
4990
+ #----------------------------------------------------------------------------------
4991
+
4992
+ /**
4993
+ * Load WordPress core plugin.php essential module.
4994
+ *
4995
+ * @author Vova Feldman (@svovaf)
4996
+ * @since 1.1.1
4997
+ */
4998
+ private static function require_plugin_essentials() {
4999
+ if ( ! function_exists( 'get_plugins' ) ) {
5000
+ self::$_static_logger->log( 'Including wp-admin/includes/plugin.php...' );
5001
+
5002
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
5003
+ }
5004
+ }
5005
+
5006
+ /**
5007
+ * Load WordPress core pluggable.php module.
5008
+ *
5009
+ * @author Vova Feldman (@svovaf)
5010
+ * @since 1.1.2
5011
+ */
5012
+ private static function require_pluggable_essentials() {
5013
+ if ( ! function_exists( 'wp_get_current_user' ) ) {
5014
+ require_once ABSPATH . 'wp-includes/pluggable.php';
5015
+ }
5016
+ }
5017
+
5018
+ /**
5019
+ * Return plugin data.
5020
+ *
5021
+ * @author Vova Feldman (@svovaf)
5022
+ * @since 1.0.1
5023
+ *
5024
+ * @return array
5025
+ */
5026
+ function get_plugin_data() {
5027
+ if ( ! isset( $this->_plugin_data ) ) {
5028
+ self::require_plugin_essentials();
5029
+
5030
+ /**
5031
+ * @author Vova Feldman (@svovaf)
5032
+ * @since 1.2.0 When using get_plugin_data() do NOT translate plugin data.
5033
+ *
5034
+ * @link https://github.com/Freemius/wordpress-sdk/issues/77
5035
+ */
5036
+ $this->_plugin_data = get_plugin_data(
5037
+ $this->_plugin_main_file_path,
5038
+ false,
5039
+ false
5040
+ );
5041
+ }
5042
+
5043
+ return $this->_plugin_data;
5044
+ }
5045
+
5046
+ /**
5047
+ * @author Vova Feldman (@svovaf)
5048
+ * @since 1.0.1
5049
+ *
5050
+ * @return string Plugin slug.
5051
+ */
5052
+ function get_slug() {
5053
+ return $this->_slug;
5054
+ }
5055
+
5056
+ /**
5057
+ * @author Vova Feldman (@svovaf)
5058
+ * @since 1.2.1.7
5059
+ *
5060
+ * @return string Plugin slug.
5061
+ */
5062
+ function get_target_folder_name() {
5063
+ return $this->_slug . ( $this->can_use_premium_code() ? '-premium' : '' );
5064
+ }
5065
+
5066
+ /**
5067
+ * @author Vova Feldman (@svovaf)
5068
+ * @since 1.0.1
5069
+ *
5070
+ * @return number Plugin ID.
5071
+ */
5072
+ function get_id() {
5073
+ return $this->_plugin->id;
5074
+ }
5075
+
5076
+ /**
5077
+ * @author Vova Feldman (@svovaf)
5078
+ * @since 1.2.1.5
5079
+ *
5080
+ * @return string Freemius SDK version
5081
+ */
5082
+ function get_sdk_version() {
5083
+ return $this->version;
5084
+ }
5085
+
5086
+ /**
5087
+ * @author Vova Feldman (@svovaf)
5088
+ * @since 1.2.1.5
5089
+ *
5090
+ * @return number Parent plugin ID (if parent exist).
5091
+ */
5092
+ function get_parent_id() {
5093
+ return $this->is_addon() ?
5094
+ $this->get_parent_instance()->get_id() :
5095
+ $this->_plugin->id;
5096
+ }
5097
+
5098
+ /**
5099
+ * @author Vova Feldman (@svovaf)
5100
+ * @since 1.0.1
5101
+ *
5102
+ * @return string Plugin public key.
5103
+ */
5104
+ function get_public_key() {
5105
+ return $this->_plugin->public_key;
5106
+ }
5107
+
5108
+ /**
5109
+ * Will be available only on sandbox mode.
5110
+ *
5111
+ * @author Vova Feldman (@svovaf)
5112
+ * @since 1.0.4
5113
+ *
5114
+ * @return mixed Plugin secret key.
5115
+ */
5116
+ function get_secret_key() {
5117
+ return $this->_plugin->secret_key;
5118
+ }
5119
+
5120
+ /**
5121
+ * @author Vova Feldman (@svovaf)
5122
+ * @since 1.1.1
5123
+ *
5124
+ * @return bool
5125
+ */
5126
+ function has_secret_key() {
5127
+ return ! empty( $this->_plugin->secret_key );
5128
+ }
5129
+
5130
+ /**
5131
+ * @author Vova Feldman (@svovaf)
5132
+ * @since 1.0.9
5133
+ *
5134
+ * @return string
5135
+ */
5136
+ function get_plugin_name() {
5137
+ $this->_logger->entrance();
5138
+
5139
+ if ( ! isset( $this->_plugin_name ) ) {
5140
+ $plugin_data = $this->get_plugin_data();
5141
+
5142
+ // Get name.
5143
+ $this->_plugin_name = $plugin_data['Name'];
5144
+
5145
+ // Check if plugin name contains [Premium] suffix and remove it.
5146
+ $suffix = '[premium]';
5147
+ $suffix_len = strlen( $suffix );
5148
+
5149
+ if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
5150
+ $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
5151
+ ) {
5152
+ $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
5153
+ }
5154
+
5155
+ $this->_logger->departure( 'Name = ' . $this->_plugin_name );
5156
+ }
5157
+
5158
+ return $this->_plugin_name;
5159
+ }
5160
+
5161
+ /**
5162
+ * @author Vova Feldman (@svovaf)
5163
+ * @since 1.0.0
5164
+ *
5165
+ * @return string
5166
+ */
5167
+ function get_plugin_version() {
5168
+ $this->_logger->entrance();
5169
+
5170
+ $plugin_data = $this->get_plugin_data();
5171
+
5172
+ $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
5173
+
5174
+ return $this->apply_filters( 'plugin_version', $plugin_data['Version'] );
5175
+ }
5176
+
5177
+ /**
5178
+ * @author Vova Feldman (@svovaf)
5179
+ * @since 1.2.1.7
5180
+ *
5181
+ * @return string
5182
+ */
5183
+ function get_plugin_title() {
5184
+ $this->_logger->entrance();
5185
+
5186
+ $title = $this->_plugin->title;
5187
+
5188
+ return $this->apply_filters( 'plugin_title', $title );
5189
+ }
5190
+
5191
+ /**
5192
+ * @author Vova Feldman (@svovaf)
5193
+ * @since 1.0.4
5194
+ *
5195
+ * @return string
5196
+ */
5197
+ function get_plugin_basename() {
5198
+ return $this->_plugin_basename;
5199
+ }
5200
+
5201
+ function get_plugin_folder_name() {
5202
+ $this->_logger->entrance();
5203
+
5204
+ $plugin_folder = $this->_plugin_basename;
5205
+
5206
+ while ( '.' !== dirname( $plugin_folder ) ) {
5207
+ $plugin_folder = dirname( $plugin_folder );
5208
+ }
5209
+
5210
+ $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
5211
+
5212
+ return $plugin_folder;
5213
+ }
5214
+
5215
+ #endregion ------------------------------------------------------------------
5216
+
5217
+ /* Account
5218
+ ------------------------------------------------------------------------------------------------------------------*/
5219
+
5220
+ /**
5221
+ * Find plugin's slug by plugin's basename.
5222
+ *
5223
+ * @author Vova Feldman (@svovaf)
5224
+ * @since 1.0.9
5225
+ *
5226
+ * @param string $plugin_base_name
5227
+ *
5228
+ * @return false|string
5229
+ */
5230
+ private static function find_slug_by_basename( $plugin_base_name ) {
5231
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
5232
+
5233
+ if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
5234
+ return false;
5235
+ }
5236
+
5237
+ return $file_slug_map[ $plugin_base_name ];
5238
+ }
5239
+
5240
+ /**
5241
+ * Store the map between the plugin's basename to the slug.
5242
+ *
5243
+ * @author Vova Feldman (@svovaf)
5244
+ * @since 1.0.9
5245
+ */
5246
+ private function store_file_slug_map() {
5247
+ $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
5248
+
5249
+ if ( ! array( $file_slug_map ) ) {
5250
+ $file_slug_map = array();
5251
+ }
5252
+
5253
+ if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
5254
+ $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
5255
+ ) {
5256
+ $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
5257
+ self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
5258
+ }
5259
+ }
5260
+
5261
+ /**
5262
+ * @return FS_User[]
5263
+ */
5264
+ static function get_all_users() {
5265
+ $users = self::$_accounts->get_option( 'users', array() );
5266
+
5267
+ if ( ! is_array( $users ) ) {
5268
+ $users = array();
5269
+ }
5270
+
5271
+ return $users;
5272
+ }
5273
+
5274
+ /**
5275
+ * @return FS_Site[]
5276
+ */
5277
+ private static function get_all_sites() {
5278
+ $sites = self::$_accounts->get_option( 'sites', array() );
5279
+
5280
+ if ( ! is_array( $sites ) ) {
5281
+ $sites = array();
5282
+ }
5283
+
5284
+ return $sites;
5285
+ }
5286
+
5287
+ /**
5288
+ * @author Vova Feldman (@svovaf)
5289
+ * @since 1.0.6
5290
+ *
5291
+ * @return FS_Plugin_License[]
5292
+ */
5293
+ private static function get_all_licenses() {
5294
+ $licenses = self::$_accounts->get_option( 'licenses', array() );
5295
+
5296
+ if ( ! is_array( $licenses ) ) {
5297
+ $licenses = array();
5298
+ }
5299
+
5300
+ return $licenses;
5301
+ }
5302
+
5303
+ /**
5304
+ * @return FS_Plugin_Plan[]
5305
+ */
5306
+ private static function get_all_plans() {
5307
+ $plans = self::$_accounts->get_option( 'plans', array() );
5308
+
5309
+ if ( ! is_array( $plans ) ) {
5310
+ $plans = array();
5311
+ }
5312
+
5313
+ return $plans;
5314
+ }
5315
+
5316
+ /**
5317
+ * @author Vova Feldman (@svovaf)
5318
+ * @since 1.0.4
5319
+ *
5320
+ * @return FS_Plugin_Tag[]
5321
+ */
5322
+ private static function get_all_updates() {
5323
+ $updates = self::$_accounts->get_option( 'updates', array() );
5324
+
5325
+ if ( ! is_array( $updates ) ) {
5326
+ $updates = array();
5327
+ }
5328
+
5329
+ return $updates;
5330
+ }
5331
+
5332
+ /**
5333
+ * @author Vova Feldman (@svovaf)
5334
+ * @since 1.0.6
5335
+ *
5336
+ * @return array<number,FS_Plugin[]>|false
5337
+ */
5338
+ private static function get_all_addons() {
5339
+ $addons = self::$_accounts->get_option( 'addons', array() );
5340
+
5341
+ if ( ! is_array( $addons ) ) {
5342
+ $addons = array();
5343
+ }
5344
+
5345
+ return $addons;
5346
+ }
5347
+
5348
+ /**
5349
+ * @author Vova Feldman (@svovaf)
5350
+ * @since 1.0.6
5351
+ *
5352
+ * @return FS_Plugin[]|false
5353
+ */
5354
+ private static function get_all_account_addons() {
5355
+ $addons = self::$_accounts->get_option( 'account_addons', array() );
5356
+
5357
+ if ( ! is_array( $addons ) ) {
5358
+ $addons = array();
5359
+ }
5360
+
5361
+ return $addons;
5362
+ }
5363
+
5364
+ /**
5365
+ * Check if user has connected his account (opted-in).
5366
+ *
5367
+ * Note:
5368
+ * If the user opted-in and opted-out on a later stage,
5369
+ * this will still return true. If you want to check if the
5370
+ * user is currently opted-in, use:
5371
+ * `$fs->is_registered() && $fs->is_tracking_allowed()`
5372
+ *
5373
+ * @author Vova Feldman (@svovaf)
5374
+ * @since 1.0.1
5375
+ * @return bool
5376
+ */
5377
+ function is_registered() {
5378
+ return is_object( $this->_user );
5379
+ }
5380
+
5381
+ /**
5382
+ * Returns TRUE if the user opted-in and didn't disconnect (opt-out).
5383
+ *
5384
+ * @author Leo Fajardo (@leorw)
5385
+ * @since 1.2.1.5
5386
+ *
5387
+ * @return bool
5388
+ */
5389
+ function is_tracking_allowed() {
5390
+ return ( is_object( $this->_site ) && true !== $this->_site->is_disconnected );
5391
+ }
5392
+
5393
+ /**
5394
+ * @author Vova Feldman (@svovaf)
5395
+ * @since 1.0.4
5396
+ *
5397
+ * @return FS_Plugin
5398
+ */
5399
+ function get_plugin() {
5400
+ return $this->_plugin;
5401
+ }
5402
+
5403
+ /**
5404
+ * @author Vova Feldman (@svovaf)
5405
+ * @since 1.0.3
5406
+ *
5407
+ * @return FS_User
5408
+ */
5409
+ function get_user() {
5410
+ return $this->_user;
5411
+ }
5412
+
5413
+ /**
5414
+ * @author Vova Feldman (@svovaf)
5415
+ * @since 1.0.3
5416
+ *
5417
+ * @return FS_Site
5418
+ */
5419
+ function get_site() {
5420
+ return $this->_site;
5421
+ }
5422
+
5423
+ /**
5424
+ * Get plugin add-ons.
5425
+ *
5426
+ * @author Vova Feldman (@svovaf)
5427
+ * @since 1.0.6
5428
+ *
5429
+ * @since 1.1.7.3 If not yet loaded, fetch data from the API.
5430
+ *
5431
+ * @param bool $flush
5432
+ *
5433
+ * @return FS_Plugin[]|false
5434
+ */
5435
+ function get_addons( $flush = false ) {
5436
+ $this->_logger->entrance();
5437
+
5438
+ if ( ! $this->_has_addons ) {
5439
+ return false;
5440
+ }
5441
+
5442
+ $addons = $this->sync_addons( $flush );
5443
+
5444
+ return ( ! is_array( $addons ) || empty( $addons ) ) ?
5445
+ false :
5446
+ $addons;
5447
+ }
5448
+
5449
+ /**
5450
+ * @author Vova Feldman (@svovaf)
5451
+ * @since 1.0.6
5452
+ *
5453
+ * @return FS_Plugin[]|false
5454
+ */
5455
+ function get_account_addons() {
5456
+ $this->_logger->entrance();
5457
+
5458
+ $addons = self::get_all_account_addons();
5459
+
5460
+ if ( ! is_array( $addons ) ||
5461
+ ! isset( $addons[ $this->_plugin->id ] ) ||
5462
+ ! is_array( $addons[ $this->_plugin->id ] ) ||
5463
+ 0 === count( $addons[ $this->_plugin->id ] )
5464
+ ) {
5465
+ return false;
5466
+ }
5467
+
5468
+ return $addons[ $this->_plugin->id ];
5469
+ }
5470
+
5471
+ /**
5472
+ * Check if user has any
5473
+ *
5474
+ * @author Vova Feldman (@svovaf)
5475
+ * @since 1.1.6
5476
+ *
5477
+ * @return bool
5478
+ */
5479
+ function has_account_addons() {
5480
+ $addons = $this->get_account_addons();
5481
+
5482
+ return is_array( $addons ) && ( 0 < count( $addons ) );
5483
+ }
5484
+
5485
+
5486
+ /**
5487
+ * Get add-on by ID (from local data).
5488
+ *
5489
+ * @author Vova Feldman (@svovaf)
5490
+ * @since 1.0.6
5491
+ *
5492
+ * @param number $id
5493
+ *
5494
+ * @return FS_Plugin|false
5495
+ */
5496
+ function get_addon( $id ) {
5497
+ $this->_logger->entrance();
5498
+
5499
+ $addons = $this->get_addons();
5500
+
5501
+ if ( is_array( $addons ) ) {
5502
+ foreach ( $addons as $addon ) {
5503
+ if ( $id == $addon->id ) {
5504
+ return $addon;
5505
+ }
5506
+ }
5507
+ }
5508
+
5509
+ return false;
5510
+ }
5511
+
5512
+ /**
5513
+ * Get add-on by slug (from local data).
5514
+ *
5515
+ * @author Vova Feldman (@svovaf)
5516
+ * @since 1.0.6
5517
+ *
5518
+ * @param string $slug
5519
+ *
5520
+ * @param bool $flush
5521
+ *
5522
+ * @return FS_Plugin|false
5523
+ */
5524
+ function get_addon_by_slug( $slug, $flush = false ) {
5525
+ $this->_logger->entrance();
5526
+
5527
+ $addons = $this->get_addons( $flush );
5528
+
5529
+ if ( is_array( $addons ) ) {
5530
+ foreach ( $addons as $addon ) {
5531
+ if ( $slug === $addon->slug ) {
5532
+ return $addon;
5533
+ }
5534
+ }
5535
+ }
5536
+
5537
+ return false;
5538
+ }
5539
+
5540
+ #----------------------------------------------------------------------------------
5541
+ #region Plans & Licensing
5542
+ #----------------------------------------------------------------------------------
5543
+
5544
+ /**
5545
+ * Check if running premium plugin code.
5546
+ *
5547
+ * @author Vova Feldman (@svovaf)
5548
+ * @since 1.0.5
5549
+ *
5550
+ * @return bool
5551
+ */
5552
+ function is_premium() {
5553
+ return $this->_plugin->is_premium;
5554
+ }
5555
+
5556
+ /**
5557
+ * Get site's plan ID.
5558
+ *
5559
+ * @author Vova Feldman (@svovaf)
5560
+ * @since 1.0.2
5561
+ *
5562
+ * @return number
5563
+ */
5564
+ function get_plan_id() {
5565
+ return $this->_site->plan->id;
5566
+ }
5567
+
5568
+ /**
5569
+ * Get site's plan title.
5570
+ *
5571
+ * @author Vova Feldman (@svovaf)
5572
+ * @since 1.0.2
5573
+ *
5574
+ * @return string
5575
+ */
5576
+ function get_plan_title() {
5577
+ return $this->_site->plan->title;
5578
+ }
5579
+
5580
+ /**
5581
+ * @author Vova Feldman (@svovaf)
5582
+ * @since 1.0.9
5583
+ *
5584
+ * @return FS_Plugin_Plan|false
5585
+ */
5586
+ function get_plan() {
5587
+ return is_object( $this->_site->plan ) ?
5588
+ $this->_site->plan :
5589
+ false;
5590
+ }
5591
+
5592
+ /**
5593
+ * @author Vova Feldman (@svovaf)
5594
+ * @since 1.0.3
5595
+ *
5596
+ * @return bool
5597
+ */
5598
+ function is_trial() {
5599
+ $this->_logger->entrance();
5600
+
5601
+ if ( ! $this->is_registered() ) {
5602
+ return false;
5603
+ }
5604
+
5605
+ return $this->_site->is_trial();
5606
+ }
5607
+
5608
+ /**
5609
+ * Check if currently in a trial with payment method (credit card or paypal).
5610
+ *
5611
+ * @author Vova Feldman (@svovaf)
5612
+ * @since 1.1.7
5613
+ *
5614
+ * @return bool
5615
+ */
5616
+ function is_paid_trial() {
5617
+ $this->_logger->entrance();
5618
+
5619
+ if ( ! $this->is_trial() ) {
5620
+ return false;
5621
+ }
5622
+
5623
+ return $this->has_active_valid_license() && ( $this->_site->trial_plan_id == $this->_license->plan_id );
5624
+ }
5625
+
5626
+ /**
5627
+ * Check if trial already utilized.
5628
+ *
5629
+ * @since 1.0.9
5630
+ *
5631
+ * @return bool
5632
+ */
5633
+ function is_trial_utilized() {
5634
+ $this->_logger->entrance();
5635
+
5636
+ if ( ! $this->is_registered() ) {
5637
+ return false;
5638
+ }
5639
+
5640
+ return $this->_site->is_trial_utilized();
5641
+ }
5642
+
5643
+ /**
5644
+ * Get trial plan information (if in trial).
5645
+ *
5646
+ * @author Vova Feldman (@svovaf)
5647
+ * @since 1.0.9
5648
+ *
5649
+ * @return bool|FS_Plugin_Plan
5650
+ */
5651
+ function get_trial_plan() {
5652
+ $this->_logger->entrance();
5653
+
5654
+ if ( ! $this->is_trial() ) {
5655
+ return false;
5656
+ }
5657
+
5658
+ return $this->_storage->trial_plan;
5659
+ }
5660
+
5661
+ /**
5662
+ * Check if the user has an activate, non-expired license on current plugin's install.
5663
+ *
5664
+ * @since 1.0.9
5665
+ *
5666
+ * @return bool
5667
+ */
5668
+ function is_paying() {
5669
+ $this->_logger->entrance();
5670
+
5671
+ if ( ! $this->is_registered() ) {
5672
+ return false;
5673
+ }
5674
+
5675
+ if ( ! $this->has_paid_plan() ) {
5676
+ return false;
5677
+ }
5678
+
5679
+ return (
5680
+ ! $this->is_trial() &&
5681
+ 'free' !== $this->_site->plan->name &&
5682
+ $this->has_active_valid_license()
5683
+ );
5684
+ }
5685
+
5686
+ /**
5687
+ * @author Vova Feldman (@svovaf)
5688
+ * @since 1.0.4
5689
+ *
5690
+ * @return bool
5691
+ */
5692
+ function is_free_plan() {
5693
+ if ( ! $this->is_registered() ) {
5694
+ return true;
5695
+ }
5696
+
5697
+ if ( ! $this->has_paid_plan() ) {
5698
+ return true;
5699
+ }
5700
+
5701
+ return (
5702
+ 'free' === $this->_site->plan->name ||
5703
+ ! $this->has_features_enabled_license()
5704
+ );
5705
+ }
5706
+
5707
+ /**
5708
+ * @author Vova Feldman (@svovaf)
5709
+ * @since 1.0.5
5710
+ *
5711
+ * @return bool
5712
+ */
5713
+ function _has_premium_license() {
5714
+ $this->_logger->entrance();
5715
+
5716
+ $premium_license = $this->_get_available_premium_license();
5717
+
5718
+ return ( false !== $premium_license );
5719
+ }
5720
+
5721
+ /**
5722
+ * Check if user has any licenses associated with the plugin (including expired or blocking).
5723
+ *
5724
+ * @author Vova Feldman (@svovaf)
5725
+ * @since 1.1.7.3
5726
+ *
5727
+ * @return bool
5728
+ */
5729
+ private function has_any_license() {
5730
+ return is_array( $this->_licenses ) && ( 0 < count( $this->_licenses ) );
5731
+ }
5732
+
5733
+ /**
5734
+ * @author Vova Feldman (@svovaf)
5735
+ * @since 1.0.5
5736
+ *
5737
+ * @return FS_Plugin_License|false
5738
+ */
5739
+ function _get_available_premium_license() {
5740
+ $this->_logger->entrance();
5741
+
5742
+ if ( ! $this->has_paid_plan() ) {
5743
+ return false;
5744
+ }
5745
+
5746
+ if ( is_array( $this->_licenses ) ) {
5747
+ foreach ( $this->_licenses as $license ) {
5748
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
5749
+ return $license;
5750
+ }
5751
+ }
5752
+ }
5753
+
5754
+ return false;
5755
+ }
5756
+
5757
+ /**
5758
+ * Sync local plugin plans with remote server.
5759
+ *
5760
+ * @author Vova Feldman (@svovaf)
5761
+ * @since 1.0.5
5762
+ *
5763
+ * @return FS_Plugin_Plan[]|object
5764
+ */
5765
+ function _sync_plans() {
5766
+ $plans = $this->_fetch_plugin_plans();
5767
+
5768
+ if ( $this->is_array_instanceof( $plans, 'FS_Plugin_Plan' ) ) {
5769
+ $this->_plans = $plans;
5770
+ $this->_store_plans();
5771
+ }
5772
+
5773
+ $this->do_action( 'after_plans_sync', $plans );
5774
+
5775
+ return $this->_plans;
5776
+ }
5777
+
5778
+ /**
5779
+ * @author Vova Feldman (@svovaf)
5780
+ * @since 1.0.5
5781
+ *
5782
+ * @param number $id
5783
+ *
5784
+ * @return FS_Plugin_Plan|false
5785
+ */
5786
+ function _get_plan_by_id( $id ) {
5787
+ $this->_logger->entrance();
5788
+
5789
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
5790
+ $this->_sync_plans();
5791
+ }
5792
+
5793
+ foreach ( $this->_plans as $plan ) {
5794
+ if ( $id == $plan->id ) {
5795
+ return $plan;
5796
+ }
5797
+ }
5798
+
5799
+ return false;
5800
+ }
5801
+
5802
+ /**
5803
+ * @author Vova Feldman (@svovaf)
5804
+ * @since 1.1.8.1
5805
+ *
5806
+ * @param string $name
5807
+ *
5808
+ * @return FS_Plugin_Plan|false
5809
+ */
5810
+ private function get_plan_by_name( $name ) {
5811
+ $this->_logger->entrance();
5812
+
5813
+ if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
5814
+ $this->_sync_plans();
5815
+ }
5816
+
5817
+ foreach ( $this->_plans as $plan ) {
5818
+ if ( $name == $plan->name ) {
5819
+ return $plan;
5820
+ }
5821
+ }
5822
+
5823
+ return false;
5824
+ }
5825
+
5826
+ /**
5827
+ * Sync local plugin plans with remote server.
5828
+ *
5829
+ * @author Vova Feldman (@svovaf)
5830
+ * @since 1.0.6
5831
+ *
5832
+ * @param number|bool $site_license_id
5833
+ *
5834
+ * @return FS_Plugin_License[]|object
5835
+ */
5836
+ function _sync_licenses( $site_license_id = false ) {
5837
+ $licenses = $this->_fetch_licenses( false, $site_license_id );
5838
+
5839
+ if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
5840
+ $this->_licenses = $licenses;
5841
+ $this->_store_licenses();
5842
+ }
5843
+
5844
+ // Update current license.
5845
+ if ( is_object( $this->_license ) ) {
5846
+ $this->_license = $this->_get_license_by_id( $this->_license->id );
5847
+ }
5848
+
5849
+ return $this->_licenses;
5850
+ }
5851
+
5852
+ /**
5853
+ * @author Vova Feldman (@svovaf)
5854
+ * @since 1.0.5
5855
+ *
5856
+ * @param number $id
5857
+ *
5858
+ * @return FS_Plugin_License|false
5859
+ */
5860
+ function _get_license_by_id( $id ) {
5861
+ $this->_logger->entrance();
5862
+
5863
+ if ( ! is_numeric( $id ) ) {
5864
+ return false;
5865
+ }
5866
+
5867
+ if ( ! $this->has_any_license() ) {
5868
+ $this->_sync_licenses();
5869
+ }
5870
+
5871
+ foreach ( $this->_licenses as $license ) {
5872
+ if ( $id == $license->id ) {
5873
+ return $license;
5874
+ }
5875
+ }
5876
+
5877
+ return false;
5878
+ }
5879
+
5880
+ /**
5881
+ * Sync site's license with user licenses.
5882
+ *
5883
+ * @author Vova Feldman (@svovaf)
5884
+ * @since 1.0.6
5885
+ *
5886
+ * @param FS_Plugin_License|null $new_license
5887
+ */
5888
+ function _update_site_license( $new_license ) {
5889
+ $this->_logger->entrance();
5890
+
5891
+ $this->_license = $new_license;
5892
+
5893
+ if ( ! is_object( $new_license ) ) {
5894
+ $this->_site->license_id = null;
5895
+ $this->_sync_site_subscription( null );
5896
+
5897
+ return;
5898
+ }
5899
+
5900
+ $this->_site->license_id = $this->_license->id;
5901
+
5902
+ if ( ! is_array( $this->_licenses ) ) {
5903
+ $this->_licenses = array();
5904
+ }
5905
+
5906
+ $is_license_found = false;
5907
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
5908
+ if ( $new_license->id == $this->_licenses[ $i ]->id ) {
5909
+ $this->_licenses[ $i ] = $new_license;
5910
+
5911
+ $is_license_found = true;
5912
+ break;
5913
+ }
5914
+ }
5915
+
5916
+ // If new license just append.
5917
+ if ( ! $is_license_found ) {
5918
+ $this->_licenses[] = $new_license;
5919
+ }
5920
+
5921
+ $this->_sync_site_subscription( $new_license );
5922
+ }
5923
+
5924
+ /**
5925
+ * Sync site's subscription.
5926
+ *
5927
+ * @author Vova Feldman (@svovaf)
5928
+ * @since 1.0.9
5929
+ *
5930
+ * @param FS_Plugin_License|null $license
5931
+ *
5932
+ * @return bool|\FS_Subscription
5933
+ */
5934
+ private function _sync_site_subscription( $license ) {
5935
+ if ( ! is_object( $license ) ) {
5936
+ unset( $this->_storage->subscription );
5937
+
5938
+ return false;
5939
+ }
5940
+
5941
+ // Load subscription details if not lifetime.
5942
+ $subscription = $license->is_lifetime() ?
5943
+ false :
5944
+ $this->_fetch_site_license_subscription();
5945
+
5946
+ if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
5947
+ $this->_storage->subscription = $subscription;
5948
+ } else {
5949
+ unset( $this->_storage->subscription );
5950
+ }
5951
+
5952
+ return $subscription;
5953
+ }
5954
+
5955
+ /**
5956
+ * @author Vova Feldman (@svovaf)
5957
+ * @since 1.0.6
5958
+ *
5959
+ * @return bool|\FS_Plugin_License
5960
+ */
5961
+ function _get_license() {
5962
+ return $this->_license;
5963
+ }
5964
+
5965
+ /**
5966
+ * @return bool|\FS_Subscription
5967
+ */
5968
+ function _get_subscription() {
5969
+ return isset( $this->_storage->subscription ) ?
5970
+ $this->_storage->subscription :
5971
+ false;
5972
+ }
5973
+
5974
+ /**
5975
+ * @author Vova Feldman (@svovaf)
5976
+ * @since 1.0.2
5977
+ *
5978
+ * @param string $plan Plan name
5979
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
5980
+ *
5981
+ * @return bool
5982
+ */
5983
+ function is_plan( $plan, $exact = false ) {
5984
+ $this->_logger->entrance();
5985
+
5986
+ if ( ! $this->is_registered() ) {
5987
+ return false;
5988
+ }
5989
+
5990
+ $plan = strtolower( $plan );
5991
+
5992
+ if ( $this->_site->plan->name === $plan ) // Exact plan.
5993
+ {
5994
+ return true;
5995
+ } else if ( $exact ) // Required exact, but plans are different.
5996
+ {
5997
+ return false;
5998
+ }
5999
+
6000
+ $current_plan_order = - 1;
6001
+ $required_plan_order = - 1;
6002
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
6003
+ if ( $plan === $this->_plans[ $i ]->name ) {
6004
+ $required_plan_order = $i;
6005
+ } else if ( $this->_site->plan->name === $this->_plans[ $i ]->name ) {
6006
+ $current_plan_order = $i;
6007
+ }
6008
+ }
6009
+
6010
+ return ( $current_plan_order > $required_plan_order );
6011
+ }
6012
+
6013
+ /**
6014
+ * Check if module has only one plan.
6015
+ *
6016
+ * @author Vova Feldman (@svovaf)
6017
+ * @since 1.2.1.7
6018
+ *
6019
+ * @return bool
6020
+ */
6021
+ function is_single_plan() {
6022
+ $this->_logger->entrance();
6023
+
6024
+ if ( ! $this->is_registered() ||
6025
+ ! is_array( $this->_plans ) ||
6026
+ 0 === count( $this->_plans )
6027
+ ) {
6028
+ return true;
6029
+ }
6030
+
6031
+ return ( 1 === count( $this->_plans ) );
6032
+ }
6033
+
6034
+ /**
6035
+ * Check if plan based on trial. If not in trial mode, should return false.
6036
+ *
6037
+ * @since 1.0.9
6038
+ *
6039
+ * @param string $plan Plan name
6040
+ * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
6041
+ *
6042
+ * @return bool
6043
+ */
6044
+ function is_trial_plan( $plan, $exact = false ) {
6045
+ $this->_logger->entrance();
6046
+
6047
+ if ( ! $this->is_registered() ) {
6048
+ return false;
6049
+ }
6050
+
6051
+ if ( ! $this->is_trial() ) {
6052
+ return false;
6053
+ }
6054
+
6055
+ if ( ! isset( $this->_storage->trial_plan ) ) {
6056
+ // Store trial plan information.
6057
+ $this->_enrich_site_trial_plan( true );
6058
+ }
6059
+
6060
+ if ( $this->_storage->trial_plan->name === $plan ) // Exact plan.
6061
+ {
6062
+ return true;
6063
+ } else if ( $exact ) // Required exact, but plans are different.
6064
+ {
6065
+ return false;
6066
+ }
6067
+
6068
+ $current_plan_order = - 1;
6069
+ $required_plan_order = - 1;
6070
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
6071
+ if ( $plan === $this->_plans[ $i ]->name ) {
6072
+ $required_plan_order = $i;
6073
+ } else if ( $this->_storage->trial_plan->name === $this->_plans[ $i ]->name ) {
6074
+ $current_plan_order = $i;
6075
+ }
6076
+ }
6077
+
6078
+ return ( $current_plan_order > $required_plan_order );
6079
+ }
6080
+
6081
+ /**
6082
+ * Check if plugin has any paid plans.
6083
+ *
6084
+ * @author Vova Feldman (@svovaf)
6085
+ * @since 1.0.7
6086
+ *
6087
+ * @return bool
6088
+ */
6089
+ function has_paid_plan() {
6090
+ return $this->_has_paid_plans ||
6091
+ FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
6092
+ }
6093
+
6094
+ /**
6095
+ * Check if plugin has any plan with a trail.
6096
+ *
6097
+ * @author Vova Feldman (@svovaf)
6098
+ * @since 1.0.9
6099
+ *
6100
+ * @return bool
6101
+ */
6102
+ function has_trial_plan() {
6103
+ if ( ! $this->is_registered() ) {
6104
+ /**
6105
+ * @author Vova Feldman(@svovaf)
6106
+ * @since 1.2.1.5
6107
+ *
6108
+ * Allow setting a trial from the SDK without calling the API.
6109
+ * But, if the user did opt-in, continue using the real data from the API.
6110
+ */
6111
+ if ( $this->_trial_days >= 0 ) {
6112
+ return true;
6113
+ }
6114
+
6115
+ return false;
6116
+ }
6117
+
6118
+ return $this->_storage->get( 'has_trial_plan', false );
6119
+ }
6120
+
6121
+ /**
6122
+ * Check if plugin has any free plan, or is it premium only.
6123
+ *
6124
+ * Note: If no plans configured, assume plugin is free.
6125
+ *
6126
+ * @author Vova Feldman (@svovaf)
6127
+ * @since 1.0.7
6128
+ *
6129
+ * @return bool
6130
+ */
6131
+ function has_free_plan() {
6132
+ return ! $this->is_only_premium();
6133
+ }
6134
+
6135
+ /**
6136
+ * Displays a license activation dialog box when the user clicks on the "Activate License"
6137
+ * or "Change License" link on the plugins
6138
+ * page.
6139
+ *
6140
+ * @author Leo Fajardo (@leorw)
6141
+ * @since 1.1.9
6142
+ */
6143
+ function _add_license_activation_dialog_box() {
6144
+ $vars = array(
6145
+ 'slug' => $this->_slug,
6146
+ );
6147
+
6148
+ fs_require_template( 'forms/license-activation.php', $vars );
6149
+ fs_require_template( 'forms/resend-key.php', $vars );
6150
+ }
6151
+
6152
+ /**
6153
+ * Displays the opt-out dialog box when the user clicks on the "Opt Out" link on the "Plugins"
6154
+ * page.
6155
+ *
6156
+ * @author Leo Fajardo (@leorw)
6157
+ * @since 1.2.1.5
6158
+ */
6159
+ function _add_optout_dialog() {
6160
+ $vars = array(
6161
+ 'slug' => $this->_slug,
6162
+ );
6163
+
6164
+ fs_require_template( 'forms/optout.php', $vars );
6165
+ }
6166
+
6167
+ /**
6168
+ * Prepare page to include all required UI and logic for the license activation dialog.
6169
+ *
6170
+ * @author Vova Feldman (@svovaf)
6171
+ * @since 1.2.0
6172
+ */
6173
+ function _add_license_activation() {
6174
+ if ( ! $this->is_user_admin() ) {
6175
+ // Only admins can activate a license.
6176
+ return;
6177
+ }
6178
+
6179
+ if ( ! $this->has_paid_plan() ) {
6180
+ // Module doesn't have any paid plans.
6181
+ return;
6182
+ }
6183
+
6184
+ if ( ! $this->is_premium() ) {
6185
+ // Only add license activation logic to the premium version.
6186
+ return;
6187
+ }
6188
+
6189
+ // Add license activation link and AJAX request handler.
6190
+ if ( $this->is_plugins_page() ) {
6191
+ /**
6192
+ * @since 1.2.0 Add license action link only on plugins page.
6193
+ */
6194
+ $this->_add_license_action_link();
6195
+ }
6196
+
6197
+ // Add license activation AJAX callback.
6198
+ $this->add_ajax_action( 'activate_license', array( &$this, '_activate_license_ajax_action' ) );
6199
+
6200
+ // Add resend license AJAX callback.
6201
+ $this->add_ajax_action( 'resend_license_key', array( &$this, '_resend_license_key_ajax_action' ) );
6202
+ }
6203
+
6204
+ /**
6205
+ * @author Leo Fajardo (@leorw)
6206
+ * @since 1.1.9
6207
+ */
6208
+ function _activate_license_ajax_action() {
6209
+ $this->_logger->entrance();
6210
+
6211
+ $this->check_ajax_referer( 'activate_license' );
6212
+
6213
+ $license_key = trim( fs_request_get( 'license_key' ) );
6214
+
6215
+ if ( empty( $license_key ) ) {
6216
+ exit;
6217
+ }
6218
+
6219
+ $slug = fs_request_get( 'slug', '', 'post' );
6220
+ $fs = ( $slug === $this->_slug ) ?
6221
+ $this :
6222
+ $this->get_addon_instance( $slug );
6223
+
6224
+ $error = false;
6225
+ $next_page = false;
6226
+
6227
+ if ( $fs->is_registered() ) {
6228
+ $api = $fs->get_api_site_scope();
6229
+ $install = $api->call( '/', 'put', array(
6230
+ 'license_key' => $fs->apply_filters( 'license_key', $license_key )
6231
+ ) );
6232
+
6233
+ if ( isset( $install->error ) ) {
6234
+ $error = $install->error->message;
6235
+ } else {
6236
+ $parent_fs = $fs->is_addon() ?
6237
+ $fs->get_parent_instance() :
6238
+ $fs;
6239
+
6240
+ $next_page = $parent_fs->_get_sync_license_url( $fs->get_id(), true );
6241
+
6242
+ $fs->reconnect_locally();
6243
+ }
6244
+ } else {
6245
+ $next_page = $fs->opt_in( false, false, false, $license_key );
6246
+
6247
+ if ( isset( $next_page->error ) ) {
6248
+ $error = $next_page->error;
6249
+ }
6250
+ }
6251
+
6252
+ $result = array(
6253
+ 'success' => ( false === $error )
6254
+ );
6255
+
6256
+ if ( false !== $error ) {
6257
+ $result['error'] = $error;
6258
+ } else {
6259
+ $result['next_page'] = $next_page;
6260
+ }
6261
+
6262
+ echo json_encode( $result );
6263
+
6264
+ exit;
6265
+ }
6266
+
6267
+ /**
6268
+ * Billing update AJAX callback.
6269
+ *
6270
+ * @author Vova Feldman (@svovaf)
6271
+ * @since 1.2.1.5
6272
+ */
6273
+ function _update_billing_ajax_action() {
6274
+ $this->_logger->entrance();
6275
+
6276
+ $this->check_ajax_referer( 'update_billing' );
6277
+
6278
+ if ( ! $this->is_user_admin() ) {
6279
+ // Only for admins.
6280
+ self::shoot_ajax_failure();
6281
+ }
6282
+
6283
+ $billing = fs_request_get( 'billing' );
6284
+
6285
+ $api = $this->get_api_user_scope();
6286
+ $result = $api->call( '/billing.json', 'put', array_merge( $billing, array(
6287
+ 'plugin_id' => $this->get_parent_id(),
6288
+ ) ) );
6289
+
6290
+ if ( ! $this->is_api_result_entity( $result ) ) {
6291
+ self::shoot_ajax_failure();
6292
+ }
6293
+
6294
+ // Purge cached billing.
6295
+ $this->get_api_user_scope()->purge_cache( 'billing.json' );
6296
+
6297
+ self::shoot_ajax_success();
6298
+ }
6299
+
6300
+ /**
6301
+ * Trial start for anonymous users (AJAX callback).
6302
+ *
6303
+ * @author Vova Feldman (@svovaf)
6304
+ * @since 1.2.1.5
6305
+ */
6306
+ function _start_trial_ajax_action() {
6307
+ $this->_logger->entrance();
6308
+
6309
+ $this->check_ajax_referer( 'start_trial' );
6310
+
6311
+ if ( ! $this->is_user_admin() ) {
6312
+ // Only for admins.
6313
+ self::shoot_ajax_failure();
6314
+ }
6315
+
6316
+ $trial_data = fs_request_get( 'trial' );
6317
+
6318
+ $next_page = $this->opt_in(
6319
+ false,
6320
+ false,
6321
+ false,
6322
+ false,
6323
+ false,
6324
+ $trial_data['plan_id']
6325
+ );
6326
+
6327
+ if ( is_object( $next_page ) && $this->is_api_error( $next_page ) ) {
6328
+ self::shoot_ajax_failure(
6329
+ isset( $next_page->error ) ?
6330
+ $next_page->error->message :
6331
+ var_export( $next_page, true )
6332
+ );
6333
+ }
6334
+
6335
+ self::shoot_ajax_success( array(
6336
+ 'next_page' => $next_page,
6337
+ ) );
6338
+ }
6339
+
6340
+ /**
6341
+ * @author Leo Fajardo (@leorw)
6342
+ * @since 1.2.0
6343
+ */
6344
+ function _resend_license_key_ajax_action() {
6345
+ $this->_logger->entrance();
6346
+
6347
+ $this->check_ajax_referer( 'resend_license_key' );
6348
+
6349
+ $email_address = sanitize_email( trim( fs_request_get( 'email', '', 'post' ) ) );
6350
+
6351
+ if ( empty( $email_address ) ) {
6352
+ exit;
6353
+ }
6354
+
6355
+ $error = false;
6356
+
6357
+ $api = $this->get_api_plugin_scope();
6358
+ $result = $api->call( '/licenses/resend.json', 'post',
6359
+ array(
6360
+ 'email' => $email_address,
6361
+ 'url' => home_url(),
6362
+ )
6363
+ );
6364
+
6365
+ if ( is_object( $result ) && isset( $result->error ) ) {
6366
+ $error = $result->error;
6367
+
6368
+ if ( in_array( $error->code, array( 'invalid_email', 'no_user' ) ) ) {
6369
+ $error = $this->get_text( 'email-not-found' );
6370
+ } else if ( 'no_license' === $error->code ) {
6371
+ $error = $this->get_text( 'no-active-licenses' );
6372
+ } else {
6373
+ $error = $error->message;
6374
+ }
6375
+ }
6376
+
6377
+ $licenses = array(
6378
+ 'success' => ( false === $error )
6379
+ );
6380
+
6381
+ if ( false !== $error ) {
6382
+ $licenses['error'] = sprintf( '%s... %s', $this->get_text( 'oops' ), strtolower( $error ) );
6383
+ }
6384
+
6385
+ echo json_encode( $licenses );
6386
+
6387
+ exit;
6388
+ }
6389
+
6390
+ /**
6391
+ * Helper method to check if user in the plugins page.
6392
+ *
6393
+ * @author Vova Feldman (@svovaf)
6394
+ * @since 1.2.1.5
6395
+ *
6396
+ * @return bool
6397
+ */
6398
+ function is_plugins_page() {
6399
+ global $pagenow;
6400
+
6401
+ return ( 'plugins.php' === $pagenow );
6402
+ }
6403
+
6404
+ /**
6405
+ * Helper method to check if user in the themes page.
6406
+ *
6407
+ * @author Vova Feldman (@svovaf)
6408
+ * @since 1.2.2.6
6409
+ *
6410
+ * @return bool
6411
+ */
6412
+ function is_themes_page() {
6413
+ global $pagenow;
6414
+
6415
+ return ( 'themes.php' === $pagenow );
6416
+ }
6417
+
6418
+ #----------------------------------------------------------------------------------
6419
+ #region URL Generators
6420
+ #----------------------------------------------------------------------------------
6421
+
6422
+ /**
6423
+ * Alias to pricing_url().
6424
+ *
6425
+ * @author Vova Feldman (@svovaf)
6426
+ * @since 1.0.2
6427
+ *
6428
+ * @uses pricing_url()
6429
+ *
6430
+ * @param string $period Billing cycle
6431
+ * @param bool $is_trial
6432
+ *
6433
+ * @return string
6434
+ */
6435
+ function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
6436
+ return $this->pricing_url( $period, $is_trial );
6437
+ }
6438
+
6439
+ /**
6440
+ * @author Vova Feldman (@svovaf)
6441
+ * @since 1.0.9
6442
+ *
6443
+ * @uses get_upgrade_url()
6444
+ *
6445
+ * @return string
6446
+ */
6447
+ function get_trial_url() {
6448
+ return $this->get_upgrade_url( WP_FS__PERIOD_ANNUALLY, true );
6449
+ }
6450
+
6451
+ /**
6452
+ * Plugin's pricing URL.
6453
+ *
6454
+ * @author Vova Feldman (@svovaf)
6455
+ * @since 1.0.4
6456
+ *
6457
+ * @param string $billing_cycle Billing cycle
6458
+ *
6459
+ * @param bool $is_trial
6460
+ *
6461
+ * @return string
6462
+ */
6463
+ function pricing_url( $billing_cycle = WP_FS__PERIOD_ANNUALLY, $is_trial = false ) {
6464
+ $this->_logger->entrance();
6465
+
6466
+ $params = array(
6467
+ 'billing_cycle' => $billing_cycle
6468
+ );
6469
+
6470
+ if ( $is_trial ) {
6471
+ $params['trial'] = 'true';
6472
+ }
6473
+
6474
+ return $this->_get_admin_page_url( 'pricing', $params );
6475
+ }
6476
+
6477
+ /**
6478
+ * Checkout page URL.
6479
+ *
6480
+ * @author Vova Feldman (@svovaf)
6481
+ * @since 1.0.6
6482
+ *
6483
+ * @param string $billing_cycle Billing cycle
6484
+ * @param bool $is_trial
6485
+ * @param array $extra (optional) Extra parameters, override other query params.
6486
+ *
6487
+ * @return string
6488
+ */
6489
+ function checkout_url(
6490
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
6491
+ $is_trial = false,
6492
+ $extra = array()
6493
+ ) {
6494
+ $this->_logger->entrance();
6495
+
6496
+ $params = array(
6497
+ 'checkout' => 'true',
6498
+ 'billing_cycle' => $billing_cycle,
6499
+ );
6500
+
6501
+ if ( $is_trial ) {
6502
+ $params['trial'] = 'true';
6503
+ }
6504
+
6505
+ /**
6506
+ * Params in extra override other params.
6507
+ */
6508
+ $params = array_merge( $params, $extra );
6509
+
6510
+ return $this->_get_admin_page_url( 'pricing', $params );
6511
+ }
6512
+
6513
+ /**
6514
+ * Add-on checkout URL.
6515
+ *
6516
+ * @author Vova Feldman (@svovaf)
6517
+ * @since 1.1.7
6518
+ *
6519
+ * @param number $addon_id
6520
+ * @param number $pricing_id
6521
+ * @param string $billing_cycle
6522
+ * @param bool $is_trial
6523
+ *
6524
+ * @return string
6525
+ */
6526
+ function addon_checkout_url(
6527
+ $addon_id,
6528
+ $pricing_id,
6529
+ $billing_cycle = WP_FS__PERIOD_ANNUALLY,
6530
+ $is_trial = false
6531
+ ) {
6532
+ return $this->checkout_url( $billing_cycle, $is_trial, array(
6533
+ 'plugin_id' => $addon_id,
6534
+ 'pricing_id' => $pricing_id,
6535
+ ) );
6536
+ }
6537
+
6538
+ #endregion
6539
+
6540
+ #endregion ------------------------------------------------------------------
6541
+
6542
+ /**
6543
+ * Check if plugin has any add-ons.
6544
+ *
6545
+ * @author Vova Feldman (@svovaf)
6546
+ * @since 1.0.5
6547
+ *
6548
+ * @since 1.1.7.3 Base logic only on the parameter provided by the developer in the init function.
6549
+ *
6550
+ * @return bool
6551
+ */
6552
+ function has_addons() {
6553
+ $this->_logger->entrance();
6554
+
6555
+ return $this->_has_addons;
6556
+ }
6557
+
6558
+ /**
6559
+ * Check if plugin can work in anonymous mode.
6560
+ *
6561
+ * @author Vova Feldman (@svovaf)
6562
+ * @since 1.0.9
6563
+ *
6564
+ * @return bool
6565
+ *
6566
+ * @deprecated Please use is_enable_anonymous() instead
6567
+ */
6568
+ function enable_anonymous() {
6569
+ return $this->_enable_anonymous;
6570
+ }
6571
+
6572
+ /**
6573
+ * Check if plugin can work in anonymous mode.
6574
+ *
6575
+ * @author Vova Feldman (@svovaf)
6576
+ * @since 1.1.9
6577
+ *
6578
+ * @return bool
6579
+ */
6580
+ function is_enable_anonymous() {
6581
+ return $this->_enable_anonymous;
6582
+ }
6583
+
6584
+ /**
6585
+ * Check if plugin is premium only (no free plans).
6586
+ *
6587
+ * @author Vova Feldman (@svovaf)
6588
+ * @since 1.1.9
6589
+ *
6590
+ * @return bool
6591
+ */
6592
+ function is_only_premium() {
6593
+ return $this->_is_premium_only;
6594
+ }
6595
+
6596
+ /**
6597
+ * Checks if the plugin's type is "plugin". The other type is "theme".
6598
+ *
6599
+ * @author Leo Fajardo (@leorw)
6600
+ * @since 1.2.2
6601
+ *
6602
+ * @return bool
6603
+ */
6604
+ function is_plugin() {
6605
+ return true;
6606
+ }
6607
+
6608
+ /**
6609
+ * Check if module has a premium code version.
6610
+ *
6611
+ * Serviceware module might be freemium without any
6612
+ * premium code version, where the paid features
6613
+ * are all part of the service.
6614
+ *
6615
+ * @author Vova Feldman (@svovaf)
6616
+ * @since 1.2.1.6
6617
+ *
6618
+ * @return bool
6619
+ */
6620
+ function has_premium_version() {
6621
+ return $this->_has_premium_version;
6622
+ }
6623
+
6624
+ /**
6625
+ * Check if feature supported with current site's plan.
6626
+ *
6627
+ * @author Vova Feldman (@svovaf)
6628
+ * @since 1.0.1
6629
+ *
6630
+ * @todo IMPLEMENT
6631
+ *
6632
+ * @param number $feature_id
6633
+ *
6634
+ * @throws Exception
6635
+ */
6636
+ function is_feature_supported( $feature_id ) {
6637
+ throw new Exception( 'not implemented' );
6638
+ }
6639
+
6640
+ /**
6641
+ * @author Vova Feldman (@svovaf)
6642
+ * @since 1.0.1
6643
+ *
6644
+ * @return bool Is running in SSL/HTTPS
6645
+ */
6646
+ function is_ssl() {
6647
+ return WP_FS__IS_HTTPS;
6648
+ }
6649
+
6650
+ /**
6651
+ * @author Vova Feldman (@svovaf)
6652
+ * @since 1.0.9
6653
+ *
6654
+ * @return bool Is running in AJAX call.
6655
+ *
6656
+ * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
6657
+ */
6658
+ static function is_ajax() {
6659
+ return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
6660
+ }
6661
+
6662
+ /**
6663
+ * Check if it's an AJAX call targeted for the current module.
6664
+ *
6665
+ * @author Vova Feldman (@svovaf)
6666
+ * @since 1.2.0
6667
+ *
6668
+ * @param array|string $actions Collection of AJAX actions.
6669
+ *
6670
+ * @return bool
6671
+ */
6672
+ function is_ajax_action( $actions ) {
6673
+ // Verify it's an ajax call.
6674
+ if ( ! self::is_ajax() ) {
6675
+ return false;
6676
+ }
6677
+
6678
+ // Verify the call is relevant for the plugin.
6679
+ if ( $this->_slug !== fs_request_get( 'slug' ) ) {
6680
+ return false;
6681
+ }
6682
+
6683
+ // Verify it's one of the specified actions.
6684
+ if ( is_string( $actions ) ) {
6685
+ $actions = explode( ',', $actions );
6686
+ }
6687
+
6688
+ if ( is_array( $actions ) && 0 < count( $actions ) ) {
6689
+ $ajax_action = fs_request_get( 'action' );
6690
+
6691
+ foreach ( $actions as $action ) {
6692
+ if ( $ajax_action === $this->get_action_tag( $action ) ) {
6693
+ return true;
6694
+ }
6695
+ }
6696
+ }
6697
+
6698
+ return false;
6699
+ }
6700
+
6701
+ /**
6702
+ * Check if it's an AJAX call targeted for current request.
6703
+ *
6704
+ * @author Vova Feldman (@svovaf)
6705
+ * @since 1.2.0
6706
+ *
6707
+ * @param array|string $actions Collection of AJAX actions.
6708
+ * @param string $slug
6709
+ *
6710
+ * @return bool
6711
+ */
6712
+ static function is_ajax_action_static( $actions, $slug = '' ) {
6713
+ // Verify it's an ajax call.
6714
+ if ( ! self::is_ajax() ) {
6715
+ return false;
6716
+ }
6717
+
6718
+ if ( ! empty( $slug ) ) {
6719
+ // Verify the call is relevant for the plugin.
6720
+ if ( $slug !== fs_request_get( 'slug' ) ) {
6721
+ return false;
6722
+ }
6723
+ }
6724
+
6725
+ // Verify it's one of the specified actions.
6726
+ if ( is_string( $actions ) ) {
6727
+ $actions = explode( ',', $actions );
6728
+ }
6729
+
6730
+ if ( is_array( $actions ) && 0 < count( $actions ) ) {
6731
+ $ajax_action = fs_request_get( 'action' );
6732
+
6733
+ foreach ( $actions as $action ) {
6734
+ if ( $ajax_action === self::get_ajax_action_static( $action, $slug ) ) {
6735
+ return true;
6736
+ }
6737
+ }
6738
+ }
6739
+
6740
+ return false;
6741
+ }
6742
+
6743
+ /**
6744
+ * @author Vova Feldman (@svovaf)
6745
+ * @since 1.1.7
6746
+ *
6747
+ * @return bool
6748
+ */
6749
+ function is_cron() {
6750
+ return ( defined( 'DOING_CRON' ) && DOING_CRON );
6751
+ }
6752
+
6753
+ /**
6754
+ * Check if a real user is visiting the admin dashboard.
6755
+ *
6756
+ * @author Vova Feldman (@svovaf)
6757
+ * @since 1.1.7
6758
+ *
6759
+ * @return bool
6760
+ */
6761
+ function is_user_in_admin() {
6762
+ return is_admin() && ! self::is_ajax() && ! $this->is_cron();
6763
+ }
6764
+
6765
+ /**
6766
+ * Check if running in HTTPS and if site's plan matching the specified plan.
6767
+ *
6768
+ * @param string $plan
6769
+ * @param bool $exact
6770
+ *
6771
+ * @return bool
6772
+ */
6773
+ function is_ssl_and_plan( $plan, $exact = false ) {
6774
+ return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
6775
+ }
6776
+
6777
+ /**
6778
+ * Construct plugin's settings page URL.
6779
+ *
6780
+ * @author Vova Feldman (@svovaf)
6781
+ * @since 1.0.4
6782
+ *
6783
+ * @param string $page
6784
+ * @param array $params
6785
+ *
6786
+ * @return string
6787
+ */
6788
+ function _get_admin_page_url( $page = '', $params = array() ) {
6789
+ if ( 0 < count( $params ) ) {
6790
+ foreach ( $params as $k => $v ) {
6791
+ $params[ $k ] = urlencode( $v );
6792
+ }
6793
+ }
6794
+
6795
+ $page_param = $this->_menu->get_slug( $page );
6796
+
6797
+ if ( ! $this->has_settings_menu() ) {
6798
+ if ( ! empty( $page ) ) {
6799
+ // Module doesn't have a setting page, but since the request is for
6800
+ // a specific Freemius page, use the admin.php path.
6801
+ return add_query_arg( array_merge( $params, array(
6802
+ 'page' => $page_param,
6803
+ ) ), admin_url( 'admin.php', 'admin' ) );
6804
+ } else {
6805
+ if ( $this->is_activation_mode() ) {
6806
+ /**
6807
+ * @author Vova Feldman
6808
+ * @since 1.2.1.6
6809
+ *
6810
+ * If plugin doesn't have a settings page, create one for the opt-in screen.
6811
+ */
6812
+ return add_query_arg( array_merge( $params, array(
6813
+ 'page' => $this->_slug,
6814
+ ) ), admin_url( 'admin.php', 'admin' ) );
6815
+ } else {
6816
+ // Plugin without a settings page.
6817
+ return admin_url( 'plugins.php' );
6818
+ }
6819
+ }
6820
+ }
6821
+
6822
+ // Module has a submenu settings page.
6823
+ if ( ! $this->_menu->is_top_level() ) {
6824
+ $parent_slug = $this->_menu->get_parent_slug();
6825
+ $menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
6826
+ $parent_slug :
6827
+ 'admin.php';
6828
+
6829
+ return add_query_arg( array_merge( $params, array(
6830
+ 'page' => $page_param,
6831
+ ) ), admin_url( $menu_file, 'admin' ) );
6832
+ }
6833
+
6834
+ // Module has a top level CPT settings page.
6835
+ if ( $this->_menu->is_cpt() ) {
6836
+ if ( empty( $page ) && $this->is_activation_mode() ) {
6837
+ return add_query_arg( array_merge( $params, array(
6838
+ 'page' => $page_param
6839
+ ) ), admin_url( 'admin.php', 'admin' ) );
6840
+ } else {
6841
+ if ( ! empty( $page ) ) {
6842
+ $params['page'] = $page_param;
6843
+ }
6844
+
6845
+ return add_query_arg(
6846
+ $params,
6847
+ admin_url( $this->_menu->get_raw_slug(), 'admin' )
6848
+ );
6849
+ }
6850
+ }
6851
+
6852
+ // Module has a custom top level settings page.
6853
+ return add_query_arg( array_merge( $params, array(
6854
+ 'page' => $page_param,
6855
+ ) ), admin_url( 'admin.php', 'admin' ) );
6856
+ }
6857
+
6858
+ /**
6859
+ * Plugin's account page + sync license URL.
6860
+ *
6861
+ * @author Vova Feldman (@svovaf)
6862
+ * @since 1.1.9.1
6863
+ *
6864
+ * @param bool|number $plugin_id
6865
+ * @param bool $add_action_nonce
6866
+ * @param array $params
6867
+ *
6868
+ * @return string
6869
+ */
6870
+ function _get_sync_license_url( $plugin_id = false, $add_action_nonce = true, $params = array() ) {
6871
+ if ( is_numeric( $plugin_id ) ) {
6872
+ $params['plugin_id'] = $plugin_id;
6873
+ }
6874
+
6875
+ return $this->get_account_url(
6876
+ $this->_slug . '_sync_license',
6877
+ $params,
6878
+ $add_action_nonce
6879
+ );
6880
+ }
6881
+
6882
+ /**
6883
+ * Plugin's account URL.
6884
+ *
6885
+ * @author Vova Feldman (@svovaf)
6886
+ * @since 1.0.4
6887
+ *
6888
+ * @param bool|string $action
6889
+ * @param array $params
6890
+ *
6891
+ * @param bool $add_action_nonce
6892
+ *
6893
+ * @return string
6894
+ */
6895
+ function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
6896
+ if ( is_string( $action ) ) {
6897
+ $params['fs_action'] = $action;
6898
+ }
6899
+
6900
+ self::require_pluggable_essentials();
6901
+
6902
+ return ( $add_action_nonce && is_string( $action ) ) ?
6903
+ fs_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
6904
+ $this->_get_admin_page_url( 'account', $params );
6905
+ }
6906
+
6907
+ /**
6908
+ * @author Vova Feldman (@svovaf)
6909
+ * @since 1.2.0
6910
+ *
6911
+ * @param string $tab
6912
+ * @param bool $action
6913
+ * @param array $params
6914
+ * @param bool $add_action_nonce
6915
+ *
6916
+ * @return string
6917
+ *
6918
+ * @uses get_account_url()
6919
+ */
6920
+ function get_account_tab_url( $tab, $action = false, $params = array(), $add_action_nonce = true ) {
6921
+ $params['tab'] = $tab;
6922
+
6923
+ return $this->get_account_url( $action, $params, $add_action_nonce );
6924
+ }
6925
+
6926
+ /**
6927
+ * Plugin's account URL.
6928
+ *
6929
+ * @author Vova Feldman (@svovaf)
6930
+ * @since 1.0.4
6931
+ *
6932
+ * @param bool|string $topic
6933
+ * @param bool|string $message
6934
+ *
6935
+ * @return string
6936
+ */
6937
+ function contact_url( $topic = false, $message = false ) {
6938
+ $params = array();
6939
+ if ( is_string( $topic ) ) {
6940
+ $params['topic'] = $topic;
6941
+ }
6942
+ if ( is_string( $message ) ) {
6943
+ $params['message'] = $message;
6944
+ }
6945
+
6946
+ if ( $this->is_addon() ) {
6947
+ $params['addon_id'] = $this->get_id();
6948
+
6949
+ return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
6950
+ } else {
6951
+ return $this->_get_admin_page_url( 'contact', $params );
6952
+ }
6953
+ }
6954
+
6955
+ /**
6956
+ * Add-on direct info URL.
6957
+ *
6958
+ * @author Vova Feldman (@svovaf)
6959
+ * @since 1.1.0
6960
+ *
6961
+ * @param string $slug
6962
+ *
6963
+ * @return string
6964
+ */
6965
+ function addon_url( $slug ) {
6966
+ return $this->_get_admin_page_url( 'addons', array(
6967
+ 'slug' => $slug
6968
+ ) );
6969
+ }
6970
+
6971
+ /* Logger
6972
+ ------------------------------------------------------------------------------------------------------------------*/
6973
+ /**
6974
+ * @param string $id
6975
+ * @param bool $prefix_slug
6976
+ *
6977
+ * @return FS_Logger
6978
+ */
6979
+ function get_logger( $id = '', $prefix_slug = true ) {
6980
+ return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
6981
+ }
6982
+
6983
+ /**
6984
+ * @param $id
6985
+ * @param bool $load_options
6986
+ * @param bool $prefix_slug
6987
+ *
6988
+ * @return FS_Option_Manager
6989
+ */
6990
+ function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
6991
+ return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
6992
+ }
6993
+
6994
+ /* Security
6995
+ ------------------------------------------------------------------------------------------------------------------*/
6996
+ private static function _encrypt( $str ) {
6997
+ if ( is_null( $str ) ) {
6998
+ return null;
6999
+ }
7000
+
7001
+ /**
7002
+ * The encrypt/decrypt functions are used to protect
7003
+ * the user from messing up with some of the sensitive
7004
+ * data stored for the module as a JSON in the database.
7005
+ *
7006
+ * I used the same suggested hack by the theme review team.
7007
+ * For more details, look at the function `Base64UrlDecode()`
7008
+ * in `./sdk/FreemiusBase.php`.
7009
+ *
7010
+ * @todo Remove this hack once the base64 error is removed from the Theme Check.
7011
+ *
7012
+ * @author Vova Feldman (@svovaf)
7013
+ * @since 1.2.2
7014
+ */
7015
+ $fn = 'base64' . '_encode';
7016
+
7017
+ return $fn( $str );
7018
+ }
7019
+
7020
+ static function _decrypt( $str ) {
7021
+ if ( is_null( $str ) ) {
7022
+ return null;
7023
+ }
7024
+
7025
+ /**
7026
+ * The encrypt/decrypt functions are used to protect
7027
+ * the user from messing up with some of the sensitive
7028
+ * data stored for the module as a JSON in the database.
7029
+ *
7030
+ * I used the same suggested hack by the theme review team.
7031
+ * For more details, look at the function `Base64UrlDecode()`
7032
+ * in `./sdk/FreemiusBase.php`.
7033
+ *
7034
+ * @todo Remove this hack once the base64 error is removed from the Theme Check.
7035
+ *
7036
+ * @author Vova Feldman (@svovaf)
7037
+ * @since 1.2.2
7038
+ */
7039
+ $fn = 'base64' . '_decode';
7040
+
7041
+ return $fn( $str );
7042
+ }
7043
+
7044
+ /**
7045
+ * @author Vova Feldman (@svovaf)
7046
+ * @since 1.0.5
7047
+ *
7048
+ * @param FS_Entity $entity
7049
+ *
7050
+ * @return FS_Entity Return an encrypted clone entity.
7051
+ */
7052
+ private static function _encrypt_entity( FS_Entity $entity ) {
7053
+ $clone = clone $entity;
7054
+ $props = get_object_vars( $entity );
7055
+
7056
+ foreach ( $props as $key => $val ) {
7057
+ $clone->{$key} = self::_encrypt( $val );
7058
+ }
7059
+
7060
+ return $clone;
7061
+ }
7062
+
7063
+ /**
7064
+ * @author Vova Feldman (@svovaf)
7065
+ * @since 1.0.5
7066
+ *
7067
+ * @param FS_Entity $entity
7068
+ *
7069
+ * @return FS_Entity Return an decrypted clone entity.
7070
+ */
7071
+ private static function _decrypt_entity( FS_Entity $entity ) {
7072
+ $clone = clone $entity;
7073
+ $props = get_object_vars( $entity );
7074
+
7075
+ foreach ( $props as $key => $val ) {
7076
+ $clone->{$key} = self::_decrypt( $val );
7077
+ }
7078
+
7079
+ return $clone;
7080
+ }
7081
+
7082
+ /**
7083
+ * Tries to activate account based on POST params.
7084
+ *
7085
+ * @author Vova Feldman (@svovaf)
7086
+ * @since 1.0.2
7087
+ */
7088
+ function _activate_account() {
7089
+ if ( $this->is_registered() ) {
7090
+ // Already activated.
7091
+ return;
7092
+ }
7093
+
7094
+ self::_clean_admin_content_section();
7095
+
7096
+ if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
7097
+ // check_admin_referer( 'activate_' . $this->_plugin->public_key );
7098
+
7099
+ // Verify matching plugin details.
7100
+ if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
7101
+ return;
7102
+ }
7103
+
7104
+ $user = new FS_User();
7105
+ $user->id = fs_request_get( 'user_id' );
7106
+ $user->public_key = fs_request_get( 'user_public_key' );
7107
+ $user->secret_key = fs_request_get( 'user_secret_key' );
7108
+ $user->email = fs_request_get( 'user_email' );
7109
+ $user->first = fs_request_get( 'user_first' );
7110
+ $user->last = fs_request_get( 'user_last' );
7111
+ $user->is_verified = fs_request_get_bool( 'user_is_verified' );
7112
+
7113
+ $site = new FS_Site();
7114
+ $site->id = fs_request_get( 'install_id' );
7115
+ $site->public_key = fs_request_get( 'install_public_key' );
7116
+ $site->secret_key = fs_request_get( 'install_secret_key' );
7117
+ $site->plan->id = fs_request_get( 'plan_id' );
7118
+ $site->plan->title = fs_request_get( 'plan_title' );
7119
+ $site->plan->name = fs_request_get( 'plan_name' );
7120
+
7121
+ $plans = array();
7122
+ $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
7123
+ foreach ( $plans_data as $p ) {
7124
+ $plans[] = new FS_Plugin_Plan( $p );
7125
+ }
7126
+
7127
+ $this->_set_account( $user, $site, $plans );
7128
+
7129
+ // Reload the page with the keys.
7130
+ fs_redirect( $this->_get_admin_page_url() );
7131
+ }
7132
+ }
7133
+
7134
+ /**
7135
+ * @author Vova Feldman (@svovaf)
7136
+ * @since 1.0.7
7137
+ *
7138
+ * @param string $email
7139
+ *
7140
+ * @return FS_User|bool
7141
+ */
7142
+ static function _get_user_by_email( $email ) {
7143
+ self::$_static_logger->entrance();
7144
+
7145
+ $email = trim( strtolower( $email ) );
7146
+ $users = self::get_all_users();
7147
+ if ( is_array( $users ) ) {
7148
+ foreach ( $users as $u ) {
7149
+ if ( $email === trim( strtolower( $u->email ) ) ) {
7150
+ return $u;
7151
+ }
7152
+ }
7153
+ }
7154
+
7155
+ return false;
7156
+ }
7157
+
7158
+ #----------------------------------------------------------------------------------
7159
+ #region Account (Loading, Updates & Activation)
7160
+ #----------------------------------------------------------------------------------
7161
+
7162
+ /***
7163
+ * Load account information (user + site).
7164
+ *
7165
+ * @author Vova Feldman (@svovaf)
7166
+ * @since 1.0.1
7167
+ */
7168
+ private function _load_account() {
7169
+ $this->_logger->entrance();
7170
+
7171
+ $this->do_action( 'before_account_load' );
7172
+
7173
+ $sites = self::get_all_sites();
7174
+ $users = self::get_all_users();
7175
+ $plans = self::get_all_plans();
7176
+ $licenses = self::get_all_licenses();
7177
+
7178
+ if ( $this->_logger->is_on() && is_admin() ) {
7179
+ $this->_logger->log( 'sites = ' . var_export( $sites, true ) );
7180
+ $this->_logger->log( 'users = ' . var_export( $users, true ) );
7181
+ $this->_logger->log( 'plans = ' . var_export( $plans, true ) );
7182
+ $this->_logger->log( 'licenses = ' . var_export( $licenses, true ) );
7183
+ }
7184
+
7185
+ $site = isset( $sites[ $this->_slug ] ) ? $sites[ $this->_slug ] : false;
7186
+
7187
+ if ( is_object( $site ) &&
7188
+ is_numeric( $site->id ) &&
7189
+ is_numeric( $site->user_id ) &&
7190
+ is_object( $site->plan )
7191
+ ) {
7192
+ // Load site.
7193
+ $this->_site = clone $site;
7194
+ $this->_site->plan = self::_decrypt_entity( $this->_site->plan );
7195
+
7196
+ // Load relevant user.
7197
+ $this->_user = clone $users[ $this->_site->user_id ];
7198
+
7199
+ // Load plans.
7200
+ $this->_plans = $plans[ $this->_slug ];
7201
+ if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
7202
+ $this->_sync_plans();
7203
+ } else {
7204
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
7205
+ if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
7206
+ $this->_plans[ $i ] = self::_decrypt_entity( $this->_plans[ $i ] );
7207
+ } else {
7208
+ unset( $this->_plans[ $i ] );
7209
+ }
7210
+ }
7211
+ }
7212
+
7213
+ // Load licenses.
7214
+ $this->_licenses = array();
7215
+ if ( is_array( $licenses ) &&
7216
+ isset( $licenses[ $this->_slug ] ) &&
7217
+ isset( $licenses[ $this->_slug ][ $this->_user->id ] )
7218
+ ) {
7219
+ $this->_licenses = $licenses[ $this->_slug ][ $this->_user->id ];
7220
+ }
7221
+
7222
+ $this->_license = $this->_get_license_by_id( $this->_site->license_id );
7223
+
7224
+ if ( $this->_site->version != $this->get_plugin_version() ) {
7225
+ // If stored install version is different than current installed plugin version,
7226
+ // then update plugin version event.
7227
+ $this->update_plugin_version_event();
7228
+ }
7229
+ }
7230
+
7231
+ $this->_register_account_hooks();
7232
+ }
7233
+
7234
+ /**
7235
+ * @author Vova Feldman (@svovaf)
7236
+ * @since 1.0.1
7237
+ *
7238
+ * @param FS_User $user
7239
+ * @param FS_Site $site
7240
+ * @param bool|array $plans
7241
+ */
7242
+ private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
7243
+ $site->slug = $this->_slug;
7244
+ $site->user_id = $user->id;
7245
+
7246
+ $this->_site = $site;
7247
+ $this->_user = $user;
7248
+ if ( false !== $plans ) {
7249
+ $this->_plans = $plans;
7250
+ }
7251
+
7252
+ $this->send_install_update();
7253
+
7254
+ $this->_store_account();
7255
+
7256
+ }
7257
+
7258
+ /**
7259
+ * @author Vova Feldman (@svovaf)
7260
+ * @since 1.1.7.4
7261
+ *
7262
+ * @param array $override_with
7263
+ *
7264
+ * @return array
7265
+ */
7266
+ function get_opt_in_params( $override_with = array() ) {
7267
+ $this->_logger->entrance();
7268
+
7269
+ $current_user = self::_get_current_wp_user();
7270
+
7271
+ $activation_action = $this->_slug . '_activate_new';
7272
+ $return_url = $this->is_anonymous() ?
7273
+ // If skipped already, then return to the account page.
7274
+ $this->get_account_url( $activation_action, array(), false ) :
7275
+ // Return to the module's main page.
7276
+ $this->_get_admin_page_url(
7277
+ '',
7278
+ array( 'fs_action' => $activation_action )
7279
+ );
7280
+
7281
+ $params = array(
7282
+ 'user_firstname' => $current_user->user_firstname,
7283
+ 'user_lastname' => $current_user->user_lastname,
7284
+ 'user_nickname' => $current_user->user_nicename,
7285
+ 'user_email' => $current_user->user_email,
7286
+ 'user_ip' => WP_FS__REMOTE_ADDR,
7287
+ 'plugin_slug' => $this->_slug,
7288
+ 'plugin_id' => $this->get_id(),
7289
+ 'plugin_public_key' => $this->get_public_key(),
7290
+ 'plugin_version' => $this->get_plugin_version(),
7291
+ 'return_url' => fs_nonce_url( $return_url, $activation_action ),
7292
+ 'account_url' => fs_nonce_url( $this->_get_admin_page_url(
7293
+ 'account',
7294
+ array( 'fs_action' => 'sync_user' )
7295
+ ), 'sync_user' ),
7296
+ 'site_uid' => $this->get_anonymous_id(),
7297
+ 'site_url' => get_site_url(),
7298
+ 'site_name' => get_bloginfo( 'name' ),
7299
+ 'platform_version' => get_bloginfo( 'version' ),
7300
+ 'sdk_version' => $this->version,
7301
+ 'programming_language_version' => phpversion(),
7302
+ 'language' => get_bloginfo( 'language' ),
7303
+ 'charset' => get_bloginfo( 'charset' ),
7304
+ 'is_premium' => $this->is_premium(),
7305
+ 'is_active' => true,
7306
+ 'is_uninstalled' => false,
7307
+ );
7308
+
7309
+ if ( $this->is_pending_activation() &&
7310
+ ! empty( $this->_storage->pending_license_key )
7311
+ ) {
7312
+ $params['license_key'] = $this->_storage->pending_license_key;
7313
+ }
7314
+
7315
+ if ( WP_FS__SKIP_EMAIL_ACTIVATION && $this->has_secret_key() ) {
7316
+ // Even though rand() is known for its security issues,
7317
+ // the timestamp adds another layer of protection.
7318
+ // It would be very hard for an attacker to get the secret key form here.
7319
+ // Plus, this should never run in production since the secret should never
7320
+ // be included in the production version.
7321
+ $params['ts'] = WP_FS__SCRIPT_START_TIME;
7322
+ $params['salt'] = md5( uniqid( rand() ) );
7323
+ $params['secure'] = md5(
7324
+ $params['ts'] .
7325
+ $params['salt'] .
7326
+ $this->get_secret_key()
7327
+ );
7328
+ }
7329
+
7330
+ return array_merge( $params, $override_with );
7331
+ }
7332
+
7333
+ /**
7334
+ * 1. If successful opt-in or pending activation returns the next page that the user should be redirected to.
7335
+ * 2. If there was an API error, return the API result.
7336
+ *
7337
+ * @author Vova Feldman (@svovaf)
7338
+ * @since 1.1.7.4
7339
+ *
7340
+ * @param string|bool $email
7341
+ * @param string|bool $first
7342
+ * @param string|bool $last
7343
+ * @param string|bool $license_key
7344
+ * @param bool $is_uninstall If "true", this means that the module is currently being uninstalled.
7345
+ * In this case, the user and site info will be sent to the server but no
7346
+ * data will be saved to the WP installation's database.
7347
+ * @param number|bool $trial_plan_id
7348
+ *
7349
+ * @return string|object
7350
+ * @use WP_Error
7351
+ */
7352
+ function opt_in(
7353
+ $email = false,
7354
+ $first = false,
7355
+ $last = false,
7356
+ $license_key = false,
7357
+ $is_uninstall = false,
7358
+ $trial_plan_id = false
7359
+ ) {
7360
+ $this->_logger->entrance();
7361
+
7362
+ if ( false === $email ) {
7363
+ $current_user = self::_get_current_wp_user();
7364
+ $email = $current_user->user_email;
7365
+ }
7366
+
7367
+ /**
7368
+ * @since 1.2.1 If activating with license key, ignore the context-user
7369
+ * since the user will be automatically loaded from the license.
7370
+ */
7371
+ if ( empty( $license_key ) ) {
7372
+ // Clean up pending license if opt-ing in again.
7373
+ $this->_storage->remove( 'pending_license_key' );
7374
+
7375
+ if ( ! $is_uninstall ) {
7376
+ $fs_user = Freemius::_get_user_by_email( $email );
7377
+ if ( is_object( $fs_user ) && ! $this->is_pending_activation() ) {
7378
+ return $this->install_with_current_user( false, $trial_plan_id );
7379
+ }
7380
+ }
7381
+ }
7382
+
7383
+ $user_info = array();
7384
+ if ( ! empty( $email ) ) {
7385
+ $user_info['user_email'] = $email;
7386
+ }
7387
+ if ( ! empty( $first ) ) {
7388
+ $user_info['user_firstname'] = $first;
7389
+ }
7390
+ if ( ! empty( $last ) ) {
7391
+ $user_info['user_lastname'] = $last;
7392
+ }
7393
+
7394
+ $params = $this->get_opt_in_params( $user_info );
7395
+
7396
+ $filtered_license_key = false;
7397
+ if ( is_string( $license_key ) ) {
7398
+ $filtered_license_key = $this->apply_filters( 'license_key', $license_key );
7399
+ $params['license_key'] = $filtered_license_key;
7400
+ } else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) {
7401
+ $params['trial_plan_id'] = $trial_plan_id;
7402
+ }
7403
+
7404
+ if ( $is_uninstall ) {
7405
+ $params['uninstall_params'] = array(
7406
+ 'reason_id' => $this->_storage->uninstall_reason->id,
7407
+ 'reason_info' => $this->_storage->uninstall_reason->info
7408
+ );
7409
+ }
7410
+
7411
+ $params['format'] = 'json';
7412
+
7413
+ $url = WP_FS__ADDRESS . '/action/service/user/install/';
7414
+ if ( isset( $_COOKIE['XDEBUG_SESSION'] ) ) {
7415
+ $url = add_query_arg( 'XDEBUG_SESSION', 'PHPSTORM', $url );
7416
+ }
7417
+
7418
+ $response = wp_remote_post( $url, array(
7419
+ 'method' => 'POST',
7420
+ 'body' => $params,
7421
+ 'timeout' => 15,
7422
+ ) );
7423
+
7424
+ if ( $response instanceof WP_Error ) {
7425
+ if ( 'https://' === substr( $url, 0, 8 ) &&
7426
+ isset( $response->errors ) &&
7427
+ isset( $response->errors['http_request_failed'] )
7428
+ ) {
7429
+ $http_error = strtolower( $response->errors['http_request_failed'][0] );
7430
+
7431
+ if ( false !== strpos( $http_error, 'ssl' ) ) {
7432
+ // Failed due to old version of cURL or Open SSL (SSLv3 is not supported by CloudFlare).
7433
+ $url = 'http://' . substr( $url, 8 );
7434
+
7435
+ $response = wp_remote_post( $url, array(
7436
+ 'method' => 'POST',
7437
+ 'body' => $params,
7438
+ 'timeout' => 15,
7439
+ ) );
7440
+ }
7441
+ }
7442
+ }
7443
+
7444
+ if ( is_wp_error( $response ) ) {
7445
+ /**
7446
+ * @var WP_Error $response
7447
+ */
7448
+ $result = new stdClass();
7449
+
7450
+ $error_code = $response->get_error_code();
7451
+ $error_type = str_replace( ' ', '', ucwords( str_replace( '_', ' ', $error_code ) ) );
7452
+
7453
+ $result->error = (object) array(
7454
+ 'type' => $error_type,
7455
+ 'message' => $response->get_error_message(),
7456
+ 'code' => $error_code,
7457
+ 'http' => 402
7458
+ );
7459
+
7460
+ return $result;
7461
+ }
7462
+
7463
+ // Module is being uninstalled, don't handle the returned data.
7464
+ if ( $is_uninstall ) {
7465
+ return true;
7466
+ }
7467
+
7468
+ $decoded = @json_decode( $response['body'] );
7469
+
7470
+ if ( empty( $decoded ) ) {
7471
+ return false;
7472
+ }
7473
+
7474
+ if ( ! $this->is_api_result_object( $decoded ) ) {
7475
+ if ( ! empty( $params['license_key'] ) ) {
7476
+ // Pass the fully entered license key to the failure handler.
7477
+ $params['license_key'] = $license_key;
7478
+ }
7479
+
7480
+ return $is_uninstall ?
7481
+ $decoded :
7482
+ $this->apply_filters( 'after_install_failure', $decoded, $params );
7483
+ } else if ( isset( $decoded->pending_activation ) && $decoded->pending_activation ) {
7484
+ // Pending activation, add message.
7485
+ return $this->set_pending_confirmation(
7486
+ true,
7487
+ false,
7488
+ $filtered_license_key,
7489
+ ! empty( $params['trial_plan_id'] )
7490
+ );
7491
+ } else if ( isset( $decoded->install_secret_key ) ) {
7492
+ return $this->install_with_new_user(
7493
+ $decoded->user_id,
7494
+ $decoded->user_public_key,
7495
+ $decoded->user_secret_key,
7496
+ $decoded->install_id,
7497
+ $decoded->install_public_key,
7498
+ $decoded->install_secret_key,
7499
+ false
7500
+ );
7501
+ }
7502
+
7503
+ return $decoded;
7504
+ }
7505
+
7506
+ /**
7507
+ * Set user and site identities.
7508
+ *
7509
+ * @author Vova Feldman (@svovaf)
7510
+ * @since 1.0.9
7511
+ *
7512
+ * @param FS_User $user
7513
+ * @param FS_Site $site
7514
+ * @param bool $redirect
7515
+ * @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
7516
+ * redirect (or return a URL) to the account page with a special parameter to
7517
+ * trigger the auto installation processes.
7518
+ *
7519
+ * @return string If redirect is `false`, returns the next page the user should be redirected to.
7520
+ */
7521
+ function setup_account(
7522
+ FS_User $user,
7523
+ FS_Site $site,
7524
+ $redirect = true,
7525
+ $auto_install = false
7526
+ ) {
7527
+ $this->_user = $user;
7528
+ $this->_site = $site;
7529
+
7530
+ $this->_sync_plans();
7531
+
7532
+ $this->_enrich_site_plan( false );
7533
+
7534
+ $this->_set_account( $user, $site );
7535
+
7536
+ if ( $this->is_trial() ) {
7537
+ // Store trial plan information.
7538
+ $this->_enrich_site_trial_plan( true );
7539
+ }
7540
+
7541
+ // If Freemius was OFF before, turn it on.
7542
+ $this->turn_on();
7543
+
7544
+ $this->do_action( 'after_account_connection', $user, $site );
7545
+
7546
+ if ( is_numeric( $site->license_id ) ) {
7547
+ $this->_license = $this->_get_license_by_id( $site->license_id );
7548
+ }
7549
+
7550
+ $this->_admin_notices->remove_sticky( 'connect_account' );
7551
+
7552
+ if ( $this->is_pending_activation() ) {
7553
+ // Remove pending activation sticky notice (if still exist).
7554
+ $this->_admin_notices->remove_sticky( 'activation_pending' );
7555
+
7556
+ // Remove plugin from pending activation mode.
7557
+ unset( $this->_storage->is_pending_activation );
7558
+
7559
+ if ( ! $this->is_paying_or_trial() ) {
7560
+ $this->_admin_notices->add_sticky(
7561
+ sprintf( $this->get_text( 'plugin-x-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
7562
+ 'activation_complete'
7563
+ );
7564
+ }
7565
+ }
7566
+
7567
+ if ( $this->is_paying_or_trial() ) {
7568
+ if ( ! $this->is_premium() || ! $this->has_premium_version() ) {
7569
+ if ( $this->is_paying() ) {
7570
+ $this->_admin_notices->add_sticky(
7571
+ sprintf(
7572
+ $this->get_text( 'activation-with-plan-x-message' ),
7573
+ $this->_site->plan->title
7574
+ ) . $this->get_complete_upgrade_instructions(),
7575
+ 'plan_upgraded',
7576
+ $this->get_text( 'yee-haw' ) . '!'
7577
+ );
7578
+ } else {
7579
+ $this->_admin_notices->add_sticky(
7580
+ sprintf(
7581
+ $this->get_text( 'trial-started-message' ),
7582
+ '<i>' . $this->get_plugin_name() . '</i>'
7583
+ ) . $this->get_complete_upgrade_instructions( $this->_storage->trial_plan->title ),
7584
+ 'trial_started',
7585
+ $this->get_text( 'yee-haw' ) . '!'
7586
+ );
7587
+ }
7588
+ }
7589
+
7590
+ $this->_admin_notices->remove_sticky( array(
7591
+ 'trial_promotion',
7592
+ ) );
7593
+ }
7594
+
7595
+ $plugin_id = fs_request_get( 'plugin_id', false );
7596
+
7597
+ // Store activation time ONLY for plugins (not add-ons).
7598
+ if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
7599
+ $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
7600
+ }
7601
+
7602
+ $next_page = '';
7603
+
7604
+ $extra = array();
7605
+ if ( $auto_install ) {
7606
+ $extra['auto_install'] = 'true';
7607
+ }
7608
+
7609
+ if ( is_numeric( $plugin_id ) ) {
7610
+ /**
7611
+ * @author Leo Fajardo
7612
+ * @since 1.2.1.6
7613
+ *
7614
+ * Also sync the license after an anonymous user subscribes.
7615
+ */
7616
+ if ( $this->is_anonymous() || $plugin_id != $this->_plugin->id ) {
7617
+ // Add-on was installed - sync license right after install.
7618
+ $next_page = $this->_get_sync_license_url( $plugin_id, true, $extra );
7619
+ }
7620
+ } else {
7621
+ /**
7622
+ * @author Vova Feldman (@svovaf)
7623
+ * @since 1.1.9 If site installed with a valid license, sync license.
7624
+ */
7625
+ if ( $this->is_paying() ) {
7626
+ $this->_sync_plugin_license( true );
7627
+ }
7628
+
7629
+ // Reload the page with the keys.
7630
+ $next_page = $this->is_anonymous() ?
7631
+ // If user previously skipped, redirect to account page.
7632
+ $this->get_account_url( false, $extra ) :
7633
+ $this->get_after_activation_url( 'after_connect_url' );
7634
+ }
7635
+
7636
+ if ( ! empty( $next_page ) && $redirect ) {
7637
+ fs_redirect( $next_page );
7638
+ }
7639
+
7640
+ return $next_page;
7641
+ }
7642
+
7643
+ /**
7644
+ * Install plugin with new user information after approval.
7645
+ *
7646
+ * @author Vova Feldman (@svovaf)
7647
+ * @since 1.0.7
7648
+ */
7649
+ function _install_with_new_user() {
7650
+ $this->_logger->entrance();
7651
+
7652
+ if ( $this->is_registered() ) {
7653
+ return;
7654
+ }
7655
+
7656
+ if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
7657
+ // check_admin_referer( $this->_slug . '_activate_new' );
7658
+
7659
+ if ( fs_request_has( 'user_secret_key' ) ) {
7660
+ $this->install_with_new_user(
7661
+ fs_request_get( 'user_id' ),
7662
+ fs_request_get( 'user_public_key' ),
7663
+ fs_request_get( 'user_secret_key' ),
7664
+ fs_request_get( 'install_id' ),
7665
+ fs_request_get( 'install_public_key' ),
7666
+ fs_request_get( 'install_secret_key' ),
7667
+ true,
7668
+ fs_request_get_bool( 'auto_install' )
7669
+ );
7670
+ } else if ( fs_request_has( 'pending_activation' ) ) {
7671
+ $this->set_pending_confirmation( fs_request_get( 'user_email' ), true );
7672
+ }
7673
+ }
7674
+ }
7675
+
7676
+ /**
7677
+ * Install plugin with new user.
7678
+ *
7679
+ * @author Vova Feldman (@svovaf)
7680
+ * @since 1.1.7.4
7681
+ *
7682
+ * @param number $user_id
7683
+ * @param string $user_public_key
7684
+ * @param string $user_secret_key
7685
+ * @param number $install_id
7686
+ * @param string $install_public_key
7687
+ * @param string $install_secret_key
7688
+ * @param bool $redirect
7689
+ * @param bool $auto_install Since 1.2.1.7 If `true` and setting up an account with a valid license, will
7690
+ * redirect (or return a URL) to the account page with a special parameter to
7691
+ * trigger the auto installation processes.
7692
+ *
7693
+ * @return string If redirect is `false`, returns the next page the user should be redirected to.
7694
+ */
7695
+ private function install_with_new_user(
7696
+ $user_id,
7697
+ $user_public_key,
7698
+ $user_secret_key,
7699
+ $install_id,
7700
+ $install_public_key,
7701
+ $install_secret_key,
7702
+ $redirect = true,
7703
+ $auto_install = false
7704
+ ) {
7705
+ $user = new FS_User();
7706
+ $user->id = $user_id;
7707
+ $user->public_key = $user_public_key;
7708
+ $user->secret_key = $user_secret_key;
7709
+
7710
+ $this->_user = $user;
7711
+ $user_result = $this->get_api_user_scope()->get();
7712
+ $user = new FS_User( $user_result );
7713
+ $this->_user = $user;
7714
+
7715
+ $site = new FS_Site();
7716
+ $site->id = $install_id;
7717
+ $site->public_key = $install_public_key;
7718
+ $site->secret_key = $install_secret_key;
7719
+
7720
+ $this->_site = $site;
7721
+ $site_result = $this->get_api_site_scope()->get();
7722
+ $site = new FS_Site( $site_result );
7723
+ $this->_site = $site;
7724
+
7725
+ return $this->setup_account(
7726
+ $this->_user,
7727
+ $this->_site,
7728
+ $redirect,
7729
+ $auto_install
7730
+ );
7731
+ }
7732
+
7733
+ /**
7734
+ * @author Vova Feldman (@svovaf)
7735
+ * @since 1.1.7.4
7736
+ *
7737
+ * @param string|bool $email
7738
+ * @param bool $redirect
7739
+ * @param string|bool $license_key Since 1.2.1.5
7740
+ * @param bool $is_pending_trial Since 1.2.1.5
7741
+ *
7742
+ * @return string Since 1.2.1.5 if $redirect is `false`, return the pending activation page.
7743
+ */
7744
+ private function set_pending_confirmation(
7745
+ $email = false,
7746
+ $redirect = true,
7747
+ $license_key = false,
7748
+ $is_pending_trial = false
7749
+ ) {
7750
+ if ( $this->_ignore_pending_mode ) {
7751
+ /**
7752
+ * If explicitly asked to ignore pending mode, set to anonymous mode
7753
+ * if require confirmation before finalizing the opt-in.
7754
+ *
7755
+ * @author Vova Feldman
7756
+ * @since 1.2.1.6
7757
+ */
7758
+ $this->skip_connection();
7759
+ } else {
7760
+ // Install must be activated via email since
7761
+ // user with the same email already exist.
7762
+ $this->_storage->is_pending_activation = true;
7763
+ $this->_add_pending_activation_notice( $email, $is_pending_trial );
7764
+ }
7765
+
7766
+ if ( ! empty( $license_key ) ) {
7767
+ $this->_storage->pending_license_key = $license_key;
7768
+ }
7769
+
7770
+ // Remove the opt-in sticky notice.
7771
+ $this->_admin_notices->remove_sticky( array(
7772
+ 'connect_account',
7773
+ 'trial_promotion',
7774
+ ) );
7775
+
7776
+ $next_page = $this->get_after_activation_url( 'after_pending_connect_url' );
7777
+
7778
+ // Reload the page with with pending activation message.
7779
+ if ( $redirect ) {
7780
+ fs_redirect( $next_page );
7781
+ }
7782
+
7783
+ return $next_page;
7784
+ }
7785
+
7786
+ /**
7787
+ * Install plugin with current logged WP user info.
7788
+ *
7789
+ * @author Vova Feldman (@svovaf)
7790
+ * @since 1.0.7
7791
+ */
7792
+ function _install_with_current_user() {
7793
+ $this->_logger->entrance();
7794
+
7795
+ if ( $this->is_registered() ) {
7796
+ return;
7797
+ }
7798
+
7799
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) && fs_request_is_post() ) {
7800
+ // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
7801
+
7802
+ /**
7803
+ * @author Vova Feldman (@svovaf)
7804
+ * @since 1.1.9 Add license key if given.
7805
+ */
7806
+ $license_key = fs_request_get( 'license_secret_key' );
7807
+
7808
+ $this->install_with_current_user( $license_key );
7809
+ }
7810
+ }
7811
+
7812
+
7813
+ /**
7814
+ * @author Vova Feldman (@svovaf)
7815
+ * @since 1.1.7.4
7816
+ *
7817
+ * @param string|bool $license_key
7818
+ * @param number|bool $trial_plan_id
7819
+ * @param bool $redirect
7820
+ *
7821
+ * @return string|object If redirect is `false`, returns the next page the user should be redirected to, or the
7822
+ * API error object if failed to install.
7823
+ */
7824
+ private function install_with_current_user(
7825
+ $license_key = false,
7826
+ $trial_plan_id = false,
7827
+ $redirect = true
7828
+ ) {
7829
+ // Get current logged WP user.
7830
+ $current_user = self::_get_current_wp_user();
7831
+
7832
+ // Find the relevant FS user by the email.
7833
+ $user = self::_get_user_by_email( $current_user->user_email );
7834
+
7835
+ // We have to set the user before getting user scope API handler.
7836
+ $this->_user = $user;
7837
+
7838
+ $extra_install_params = array(
7839
+ 'uid' => $this->get_anonymous_id(),
7840
+ );
7841
+
7842
+ if ( ! empty( $license_key ) ) {
7843
+ $filtered_license_key = $this->apply_filters( 'license_key', $license_key );
7844
+ $extra_install_params['license_key'] = $filtered_license_key;
7845
+ } else if ( FS_Plugin_Plan::is_valid_id( $trial_plan_id ) ) {
7846
+ $extra_install_params['trial_plan_id'] = $trial_plan_id;
7847
+ }
7848
+
7849
+ $args = $this->get_install_data_for_api( $extra_install_params, false, false );
7850
+
7851
+ // Install the plugin.
7852
+ $install = $this->get_api_user_scope()->call(
7853
+ "/plugins/{$this->get_id()}/installs.json",
7854
+ 'post',
7855
+ $args
7856
+ );
7857
+
7858
+ if ( ! $this->is_api_result_entity( $install ) ) {
7859
+ if ( ! empty( $args['license_key'] ) ) {
7860
+ // Pass full the fully entered license key to the failure handler.
7861
+ $args['license_key'] = $license_key;
7862
+ }
7863
+
7864
+ $install = $this->apply_filters( 'after_install_failure', $install, $args );
7865
+
7866
+ $this->_admin_notices->add(
7867
+ sprintf( $this->get_text( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
7868
+ $this->get_text( 'contact-us-with-error-message' ) . ' ' . '<b>' . $install->error->message . '</b>',
7869
+ $this->get_text( 'oops' ) . '...',
7870
+ 'error'
7871
+ );
7872
+
7873
+ if ( $redirect ) {
7874
+ fs_redirect( $this->get_activation_url( array( 'error' => $install->error->message ) ) );
7875
+ }
7876
+
7877
+ return $install;
7878
+ }
7879
+
7880
+ $site = new FS_Site( $install );
7881
+ $this->_site = $site;
7882
+
7883
+ return $this->setup_account( $this->_user, $this->_site, $redirect );
7884
+ }
7885
+
7886
+ /**
7887
+ * Tries to activate add-on account based on parent plugin info.
7888
+ *
7889
+ * @author Vova Feldman (@svovaf)
7890
+ * @since 1.0.6
7891
+ *
7892
+ * @param Freemius $parent_fs
7893
+ */
7894
+ private function _activate_addon_account( Freemius $parent_fs ) {
7895
+ if ( $this->is_registered() ) {
7896
+ // Already activated.
7897
+ return;
7898
+ }
7899
+
7900
+ // Activate add-on with parent plugin credentials.
7901
+ $addon_install = $parent_fs->get_api_site_scope()->call(
7902
+ "/addons/{$this->_plugin->id}/installs.json",
7903
+ 'post',
7904
+ $this->get_install_data_for_api( array(
7905
+ 'uid' => $this->get_anonymous_id(),
7906
+ ), false, false )
7907
+ );
7908
+
7909
+ if ( isset( $addon_install->error ) ) {
7910
+ $this->_admin_notices->add(
7911
+ sprintf( $this->get_text( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
7912
+ $this->get_text( 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
7913
+ $this->get_text( 'oops' ) . '...',
7914
+ 'error'
7915
+ );
7916
+
7917
+ return;
7918
+ }
7919
+
7920
+ // First of all, set site info - otherwise we won't
7921
+ // be able to invoke API calls.
7922
+ $this->_site = new FS_Site( $addon_install );
7923
+
7924
+ // Sync add-on plans.
7925
+ $this->_sync_plans();
7926
+
7927
+ // Get site's current plan.
7928
+ $this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
7929
+
7930
+ // Get user information based on parent's plugin.
7931
+ $user = $parent_fs->get_user();
7932
+
7933
+ $this->_set_account( $user, $this->_site );
7934
+
7935
+ // Sync licenses.
7936
+ $this->_sync_licenses();
7937
+
7938
+ // Try to activate premium license.
7939
+ $this->_activate_license( true );
7940
+ }
7941
+
7942
+ #endregion
7943
+
7944
+ #----------------------------------------------------------------------------------
7945
+ #region Admin Menu Items
7946
+ #----------------------------------------------------------------------------------
7947
+
7948
+ private $_menu_items = array();
7949
+
7950
+ /**
7951
+ * @author Vova Feldman (@svovaf)
7952
+ * @since 1.0.7
7953
+ *
7954
+ * @return string
7955
+ */
7956
+ function get_menu_slug() {
7957
+ return $this->_menu->get_slug();
7958
+ }
7959
+
7960
+ /**
7961
+ * @author Vova Feldman (@svovaf)
7962
+ * @since 1.0.9
7963
+ */
7964
+ function _prepare_admin_menu() {
7965
+ // if ( ! $this->is_on() ) {
7966
+ // return;
7967
+ // }
7968
+
7969
+ if ( ! $this->has_api_connectivity() && ! $this->is_enable_anonymous() ) {
7970
+ $this->_menu->remove_menu_item();
7971
+ } else {
7972
+ $this->do_action( 'before_admin_menu_init' );
7973
+
7974
+ $this->add_menu_action();
7975
+ $this->add_submenu_items();
7976
+ }
7977
+ }
7978
+
7979
+ /**
7980
+ * Admin dashboard menu items modifications.
7981
+ *
7982
+ * NOTE: admin_menu action executed before admin_init.
7983
+ *
7984
+ * @author Vova Feldman (@svovaf)
7985
+ * @since 1.0.7
7986
+ *
7987
+ */
7988
+ private function add_menu_action() {
7989
+ if ( $this->is_activation_mode() ) {
7990
+ $this->override_plugin_menu_with_activation();
7991
+ } else {
7992
+ // If not registered try to install user.
7993
+ if ( ! $this->is_registered() &&
7994
+ fs_request_is_action( $this->_slug . '_activate_new' )
7995
+ ) {
7996
+ $this->_install_with_new_user();
7997
+ } else if ( fs_request_is_action( 'sync_user' ) && ! $this->has_settings_menu() ) {
7998
+ $this->_handle_account_user_sync();
7999
+ }
8000
+ }
8001
+ }
8002
+
8003
+ /**
8004
+ * @author Vova Feldman (@svovaf)
8005
+ * @since 1.0.1
8006
+ */
8007
+ function _redirect_on_clicked_menu_link() {
8008
+ $this->_logger->entrance();
8009
+
8010
+ $page = strtolower( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
8011
+
8012
+ $this->_logger->log( 'page = ' . $page );
8013
+
8014
+ foreach ( $this->_menu_items as $priority => $items ) {
8015
+ foreach ( $items as $item ) {
8016
+ if ( isset( $item['url'] ) ) {
8017
+ if ( $page === $this->_menu->get_slug( strtolower( $item['menu_slug'] ) ) ) {
8018
+ $this->_logger->log( 'Redirecting to ' . $item['url'] );
8019
+
8020
+ fs_redirect( $item['url'] );
8021
+ }
8022
+ }
8023
+ }
8024
+ }
8025
+ }
8026
+
8027
+ /**
8028
+ * Remove plugin's all admin menu items & pages, and replace with activation page.
8029
+ *
8030
+ * @author Vova Feldman (@svovaf)
8031
+ * @since 1.0.1
8032
+ */
8033
+ private function override_plugin_menu_with_activation() {
8034
+ $this->_logger->entrance();
8035
+
8036
+ $hook = false;
8037
+
8038
+ if ( ! $this->_menu->has_menu() ) {
8039
+ // Add the opt-in page without a menu item.
8040
+ $hook = FS_Admin_Menu_Manager::add_subpage(
8041
+ null,
8042
+ $this->get_plugin_name(),
8043
+ $this->get_plugin_name(),
8044
+ 'manage_options',
8045
+ $this->_slug,
8046
+ array( &$this, '_connect_page_render' )
8047
+ );
8048
+ } else if ( $this->_menu->is_top_level() ) {
8049
+ $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) );
8050
+
8051
+ if ( false === $hook ) {
8052
+ // Create new menu item just for the opt-in.
8053
+ $hook = FS_Admin_Menu_Manager::add_page(
8054
+ $this->get_plugin_name(),
8055
+ $this->get_plugin_name(),
8056
+ 'manage_options',
8057
+ $this->_menu->get_slug(),
8058
+ array( &$this, '_connect_page_render' )
8059
+ );
8060
+ }
8061
+ } else {
8062
+ $menus = array( $this->_menu->get_parent_slug() );
8063
+
8064
+ if ( $this->_menu->is_override_exact() ) {
8065
+ if ( ! $this->is_matching_url( $_SERVER['REQUEST_URI'], $this->get_activation_url() ) ) {
8066
+ return;
8067
+ }
8068
+ }
8069
+
8070
+ foreach ( $menus as $parent_slug ) {
8071
+ $hook = $this->_menu->override_submenu_action(
8072
+ $parent_slug,
8073
+ $this->_menu->get_raw_slug(),
8074
+ array( &$this, '_connect_page_render' )
8075
+ );
8076
+
8077
+ if ( false !== $hook ) {
8078
+ // Found plugin's submenu item.
8079
+ break;
8080
+ }
8081
+ }
8082
+ }
8083
+
8084
+ if ( $this->is_activation_page() ) {
8085
+ // Clean admin page from distracting content.
8086
+ self::_clean_admin_content_section();
8087
+ }
8088
+
8089
+ if ( false !== $hook ) {
8090
+ if ( fs_request_is_action( $this->_slug . '_activate_existing' ) ) {
8091
+ add_action( "load-$hook", array( &$this, '_install_with_current_user' ) );
8092
+ } else if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
8093
+ add_action( "load-$hook", array( &$this, '_install_with_new_user' ) );
8094
+ }
8095
+ }
8096
+ }
8097
+
8098
+ /**
8099
+ * @author Leo Fajardo (leorw)
8100
+ * @since 1.2.1
8101
+ *
8102
+ * return string
8103
+ */
8104
+ function get_top_level_menu_capability() {
8105
+ global $menu;
8106
+
8107
+ $top_level_menu_slug = $this->get_top_level_menu_slug();
8108
+
8109
+ foreach ( $menu as $menu_info ) {
8110
+ /**
8111
+ * The second element in the menu info array is the capability/role that has access to the menu and the
8112
+ * third element is the menu slug.
8113
+ */
8114
+ if ( $menu_info[2] === $top_level_menu_slug ) {
8115
+ return $menu_info[1];
8116
+ }
8117
+ }
8118
+
8119
+ return 'read';
8120
+ }
8121
+
8122
+ /**
8123
+ * @author Vova Feldman (@svovaf)
8124
+ * @since 1.0.0
8125
+ *
8126
+ * @return string
8127
+ */
8128
+ private function get_top_level_menu_slug() {
8129
+ return ( $this->is_addon() ?
8130
+ $this->get_parent_instance()->_menu->get_top_level_menu_slug() :
8131
+ $this->_menu->get_top_level_menu_slug() );
8132
+ }
8133
+
8134
+ /**
8135
+ * Add default Freemius menu items.
8136
+ *
8137
+ * @author Vova Feldman (@svovaf)
8138
+ * @since 1.0.0
8139
+ */
8140
+ private function add_submenu_items() {
8141
+ $this->_logger->entrance();
8142
+
8143
+ if ( ! $this->is_addon() ) {
8144
+ if ( ! $this->is_activation_mode() ) {
8145
+ if ( $this->is_registered() ) {
8146
+ // Add user account page.
8147
+ $this->add_submenu_item(
8148
+ $this->get_text( 'account' ),
8149
+ array( &$this, '_account_page_render' ),
8150
+ $this->get_plugin_name() . ' &ndash; ' . $this->get_text( 'account' ),
8151
+ 'manage_options',
8152
+ 'account',
8153
+ array( &$this, '_account_page_load' ),
8154
+ WP_FS__DEFAULT_PRIORITY,
8155
+ $this->is_submenu_item_visible( 'account' )
8156
+ );
8157
+ }
8158
+
8159
+ // Add contact page.
8160
+ $this->add_submenu_item(
8161
+ $this->get_text( 'contact-us' ),
8162
+ array( &$this, '_contact_page_render' ),
8163
+ $this->get_plugin_name() . ' &ndash; ' . $this->get_text( 'contact-us' ),
8164
+ 'manage_options',
8165
+ 'contact',
8166
+ 'Freemius::_clean_admin_content_section',
8167
+ WP_FS__DEFAULT_PRIORITY,
8168
+ $this->is_submenu_item_visible( 'contact' )
8169
+ );
8170
+
8171
+ if ( $this->has_addons() ) {
8172
+ $this->add_submenu_item(
8173
+ $this->get_text( 'add-ons' ),
8174
+ array( &$this, '_addons_page_render' ),
8175
+ $this->get_plugin_name() . ' &ndash; ' . $this->get_text( 'add-ons' ),
8176
+ 'manage_options',
8177
+ 'addons',
8178
+ array( &$this, '_addons_page_load' ),
8179
+ WP_FS__LOWEST_PRIORITY - 1,
8180
+ $this->is_submenu_item_visible( 'addons' )
8181
+ );
8182
+ }
8183
+
8184
+ $show_pricing = (
8185
+ // Has at least one paid plan.
8186
+ $this->has_paid_plan() &&
8187
+ // Didn't ask to hide the pricing page.
8188
+ $this->is_submenu_item_visible( 'pricing' ) &&
8189
+ // Don't have a valid active license or has more than one plan.
8190
+ ( ! $this->is_paying() || ! $this->is_single_plan() )
8191
+ );
8192
+ // If user don't have paid plans, add pricing page
8193
+ // to support add-ons checkout but don't add the submenu item.
8194
+ // || (isset( $_GET['page'] ) && $this->_menu->get_slug( 'pricing' ) == $_GET['page']);
8195
+
8196
+ $pricing_cta_slug = 'upgrade';
8197
+ $pricing_class = 'upgrade-mode';
8198
+ if ( $show_pricing ) {
8199
+ if ( $this->_admin_notices->has_sticky( 'trial_promotion' ) &&
8200
+ ! $this->is_paying_or_trial()
8201
+ ) {
8202
+ // If running a trial promotion, modify the pricing to load the trial.
8203
+ $pricing_cta_slug = 'start-trial';
8204
+ $pricing_class = 'trial-mode';
8205
+ } else if ( $this->is_paying() ) {
8206
+ $pricing_cta_slug = 'pricing';
8207
+ $pricing_class = '';
8208
+ }
8209
+ }
8210
+
8211
+ // Add upgrade/pricing page.
8212
+ $this->add_submenu_item(
8213
+ $this->get_text( $pricing_cta_slug ) . '&nbsp;&nbsp;' . ( is_rtl() ? '&#x2190;' : '&#x27a4;' ),
8214
+ array( &$this, '_pricing_page_render' ),
8215
+ $this->get_plugin_name() . ' &ndash; ' . $this->get_text( 'pricing' ),
8216
+ 'manage_options',
8217
+ 'pricing',
8218
+ 'Freemius::_clean_admin_content_section',
8219
+ WP_FS__LOWEST_PRIORITY,
8220
+ $show_pricing,
8221
+ $pricing_class
8222
+ );
8223
+ }
8224
+ }
8225
+
8226
+
8227
+ if ( 0 < count( $this->_menu_items ) ) {
8228
+ if ( ! $this->_menu->is_top_level() ) {
8229
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
8230
+
8231
+ // Append submenu items right after the plugin's submenu item.
8232
+ $this->order_sub_submenu_items();
8233
+ } else {
8234
+ // Append submenu items.
8235
+ $this->embed_submenu_items();
8236
+ }
8237
+ }
8238
+ }
8239
+
8240
+ /**
8241
+ * Moved the actual submenu item additions to a separated function,
8242
+ * in order to support sub-submenu items when the plugin's settings
8243
+ * only have a submenu and not top-level menu item.
8244
+ *
8245
+ * @author Vova Feldman (@svovaf)
8246
+ * @since 1.1.4
8247
+ */
8248
+ private function embed_submenu_items() {
8249
+ $item_template = $this->_menu->is_top_level() ?
8250
+ '<span class="fs-submenu-item %s %s %s">%s</span>' :
8251
+ '<span class="fs-submenu-item fs-sub %s %s %s">%s</span>';
8252
+
8253
+ $top_level_menu_capability = $this->get_top_level_menu_capability();
8254
+
8255
+ ksort( $this->_menu_items );
8256
+
8257
+ foreach ( $this->_menu_items as $priority => $items ) {
8258
+ foreach ( $items as $item ) {
8259
+ $capability = ( ! empty( $item['capability'] ) ? $item['capability'] : $top_level_menu_capability );
8260
+
8261
+ $menu_item = sprintf(
8262
+ $item_template,
8263
+ $this->_slug,
8264
+ $item['menu_slug'],
8265
+ ! empty( $item['class'] ) ? $item['class'] : '',
8266
+ $item['menu_title']
8267
+ );
8268
+
8269
+ $menu_slug = $this->_menu->get_slug( $item['menu_slug'] );
8270
+
8271
+ if ( ! isset( $item['url'] ) ) {
8272
+ $hook = FS_Admin_Menu_Manager::add_subpage(
8273
+ $item['show_submenu'] ?
8274
+ $this->get_top_level_menu_slug() :
8275
+ null,
8276
+ $item['page_title'],
8277
+ $menu_item,
8278
+ $capability,
8279
+ $menu_slug,
8280
+ $item['render_function']
8281
+ );
8282
+
8283
+ if ( false !== $item['before_render_function'] ) {
8284
+ add_action( "load-$hook", $item['before_render_function'] );
8285
+ }
8286
+ } else {
8287
+ FS_Admin_Menu_Manager::add_subpage(
8288
+ $this->get_top_level_menu_slug(),
8289
+ $item['page_title'],
8290
+ $menu_item,
8291
+ $capability,
8292
+ $menu_slug,
8293
+ array( $this, '' )
8294
+ );
8295
+ }
8296
+ }
8297
+ }
8298
+ }
8299
+
8300
+ /**
8301
+ * Re-order the submenu items so all Freemius added new submenu items
8302
+ * are added right after the plugin's settings submenu item.
8303
+ *
8304
+ * @author Vova Feldman (@svovaf)
8305
+ * @since 1.1.4
8306
+ */
8307
+ private function order_sub_submenu_items() {
8308
+ global $submenu;
8309
+
8310
+ $menu_slug = $this->_menu->get_top_level_menu_slug();
8311
+
8312
+ /**
8313
+ * Before "admin_menu" fires, WordPress will loop over the default submenus and remove pages for which the user
8314
+ * does not have permissions. So in case a plugin does not have top-level menu but does have submenus under any
8315
+ * of the default menus, only users that have the right role can access its sub-submenus (Account, Contact Us,
8316
+ * Support Forum, etc.) since $submenu[ $menu_slug ] will be empty if the user doesn't have permission.
8317
+ *
8318
+ * In case a plugin does not have submenus under any of the default menus but does have submenus under the menu
8319
+ * of another plugin, only users that have the right role can access its sub-submenus since we will use the
8320
+ * capability needed to access the parent menu as the capability for the submenus that we will add.
8321
+ */
8322
+ if ( empty( $submenu[ $menu_slug ] ) ) {
8323
+ return;
8324
+ }
8325
+
8326
+ $top_level_menu = &$submenu[ $menu_slug ];
8327
+
8328
+ $all_submenu_items_after = array();
8329
+
8330
+ $found_submenu_item = false;
8331
+
8332
+ foreach ( $top_level_menu as $submenu_id => $meta ) {
8333
+ if ( $found_submenu_item ) {
8334
+ // Remove all submenu items after the plugin's submenu item.
8335
+ $all_submenu_items_after[] = $meta;
8336
+ unset( $top_level_menu[ $submenu_id ] );
8337
+ }
8338
+
8339
+ if ( $this->_menu->get_raw_slug() === $meta[2] ) {
8340
+ // Found the submenu item, put all below.
8341
+ $found_submenu_item = true;
8342
+ continue;
8343
+ }
8344
+ }
8345
+
8346
+ // Embed all plugin's new submenu items.
8347
+ $this->embed_submenu_items();
8348
+
8349
+ // Start with specially high number to make sure it's appended.
8350
+ $i = max( 10000, max( array_keys( $top_level_menu ) ) + 1 );
8351
+ foreach ( $all_submenu_items_after as $meta ) {
8352
+ $top_level_menu[ $i ] = $meta;
8353
+ $i ++;
8354
+ }
8355
+
8356
+ // Sort submenu items.
8357
+ ksort( $top_level_menu );
8358
+ }
8359
+
8360
+ /**
8361
+ * Displays the Support Forum link when enabled.
8362
+ *
8363
+ * Can be filtered like so:
8364
+ *
8365
+ * function _fs_show_support_menu( $is_visible, $menu_id ) {
8366
+ * if ( 'support' === $menu_id ) {
8367
+ * return _fs->is_registered();
8368
+ * }
8369
+ * return $is_visible;
8370
+ * }
8371
+ * _fs()->add_filter('is_submenu_visible', '_fs_show_support_menu', 10, 2);
8372
+ *
8373
+ */
8374
+ function _add_default_submenu_items() {
8375
+ if ( ! $this->is_on() ) {
8376
+ return;
8377
+ }
8378
+
8379
+ if ( ! $this->is_activation_mode() ) {
8380
+ if ( $this->is_submenu_item_visible( 'support' ) ) {
8381
+ $this->add_submenu_link_item(
8382
+ $this->apply_filters( 'support_forum_submenu', $this->get_text( 'support-forum' ) ),
8383
+ $this->apply_filters( 'support_forum_url', 'https://wordpress.org/support/plugin/' . $this->_slug ),
8384
+ 'wp-support-forum',
8385
+ null,
8386
+ 50
8387
+ );
8388
+ }
8389
+ }
8390
+ }
8391
+
8392
+ /**
8393
+ * @author Vova Feldman (@svovaf)
8394
+ * @since 1.0.1
8395
+ *
8396
+ * @param string $menu_title
8397
+ * @param callable $render_function
8398
+ * @param bool|string $page_title
8399
+ * @param string $capability
8400
+ * @param bool|string $menu_slug
8401
+ * @param bool|callable $before_render_function
8402
+ * @param int $priority
8403
+ * @param bool $show_submenu
8404
+ * @param string $class Since 1.2.1.5 can add custom classes to menu items.
8405
+ */
8406
+ function add_submenu_item(
8407
+ $menu_title,
8408
+ $render_function,
8409
+ $page_title = false,
8410
+ $capability = 'manage_options',
8411
+ $menu_slug = false,
8412
+ $before_render_function = false,
8413
+ $priority = WP_FS__DEFAULT_PRIORITY,
8414
+ $show_submenu = true,
8415
+ $class = ''
8416
+ ) {
8417
+ $this->_logger->entrance( 'Title = ' . $menu_title );
8418
+
8419
+ if ( $this->is_addon() ) {
8420
+ $parent_fs = $this->get_parent_instance();
8421
+
8422
+ if ( is_object( $parent_fs ) ) {
8423
+ $parent_fs->add_submenu_item(
8424
+ $menu_title,
8425
+ $render_function,
8426
+ $page_title,
8427
+ $capability,
8428
+ $menu_slug,
8429
+ $before_render_function,
8430
+ $priority,
8431
+ $show_submenu,
8432
+ $class
8433
+ );
8434
+
8435
+ return;
8436
+ }
8437
+ }
8438
+
8439
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
8440
+ $this->_menu_items[ $priority ] = array();
8441
+ }
8442
+
8443
+ $this->_menu_items[ $priority ][] = array(
8444
+ 'page_title' => is_string( $page_title ) ? $page_title : $menu_title,
8445
+ 'menu_title' => $menu_title,
8446
+ 'capability' => $capability,
8447
+ 'menu_slug' => is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ),
8448
+ 'render_function' => $render_function,
8449
+ 'before_render_function' => $before_render_function,
8450
+ 'show_submenu' => $show_submenu,
8451
+ 'class' => $class,
8452
+ );
8453
+ }
8454
+
8455
+ /**
8456
+ * @author Vova Feldman (@svovaf)
8457
+ * @since 1.0.1
8458
+ *
8459
+ * @param string $menu_title
8460
+ * @param string $url
8461
+ * @param bool $menu_slug
8462
+ * @param string $capability
8463
+ * @param int $priority
8464
+ *
8465
+ */
8466
+ function add_submenu_link_item(
8467
+ $menu_title,
8468
+ $url,
8469
+ $menu_slug = false,
8470
+ $capability = 'read',
8471
+ $priority = WP_FS__DEFAULT_PRIORITY
8472
+ ) {
8473
+ $this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
8474
+
8475
+ if ( $this->is_addon() ) {
8476
+ $parent_fs = $this->get_parent_instance();
8477
+
8478
+ if ( is_object( $parent_fs ) ) {
8479
+ $parent_fs->add_submenu_link_item(
8480
+ $menu_title,
8481
+ $url,
8482
+ $menu_slug,
8483
+ $capability,
8484
+ $priority
8485
+ );
8486
+
8487
+ return;
8488
+ }
8489
+ }
8490
+
8491
+ if ( ! isset( $this->_menu_items[ $priority ] ) ) {
8492
+ $this->_menu_items[ $priority ] = array();
8493
+ }
8494
+
8495
+ $this->_menu_items[ $priority ][] = array(
8496
+ 'menu_title' => $menu_title,
8497
+ 'capability' => $capability,
8498
+ 'menu_slug' => is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ),
8499
+ 'url' => $url,
8500
+ 'page_title' => $menu_title,
8501
+ 'render_function' => 'fs_dummy',
8502
+ 'before_render_function' => '',
8503
+ );
8504
+ }
8505
+
8506
+ #endregion ------------------------------------------------------------------
8507
+
8508
+ #--------------------------------------------------------------------------------
8509
+ #region Actions / Hooks / Filters
8510
+ #--------------------------------------------------------------------------------
8511
+
8512
+ /**
8513
+ * @author Vova Feldman (@svovaf)
8514
+ * @since 1.1.7
8515
+ *
8516
+ * @param string $tag
8517
+ *
8518
+ * @return string
8519
+ */
8520
+ public function get_action_tag( $tag ) {
8521
+ return self::get_action_tag_static( $tag, $this->_slug );
8522
+ }
8523
+
8524
+ /**
8525
+ * @author Vova Feldman (@svovaf)
8526
+ * @since 1.2.1.6
8527
+ *
8528
+ * @param string $tag
8529
+ * @param string $slug
8530
+ *
8531
+ * @return string
8532
+ */
8533
+ static function get_action_tag_static( $tag, $slug = '' ) {
8534
+ return "fs_{$tag}" . ( empty( $slug ) ? '' : "_{$slug}" );
8535
+ }
8536
+
8537
+ /**
8538
+ * @author Vova Feldman (@svovaf)
8539
+ * @since 1.2.1
8540
+ *
8541
+ * @param string $tag
8542
+ *
8543
+ * @return string
8544
+ */
8545
+ function get_ajax_action( $tag ) {
8546
+ return self::get_ajax_action_static( $tag, $this->_slug );
8547
+ }
8548
+
8549
+ /**
8550
+ * @author Vova Feldman (@svovaf)
8551
+ * @since 1.2.1.7
8552
+ *
8553
+ * @param string $tag
8554
+ *
8555
+ * @return string
8556
+ */
8557
+ function get_ajax_security( $tag ) {
8558
+ return wp_create_nonce( $this->get_ajax_action( $tag ) );
8559
+ }
8560
+
8561
+ /**
8562
+ * @author Vova Feldman (@svovaf)
8563
+ * @since 1.2.1.7
8564
+ *
8565
+ * @param string $tag
8566
+ */
8567
+ function check_ajax_referer( $tag ) {
8568
+ check_ajax_referer( $this->get_ajax_action( $tag ), 'security' );
8569
+ }
8570
+
8571
+ /**
8572
+ * @author Vova Feldman (@svovaf)
8573
+ * @since 1.2.1.6
8574
+ *
8575
+ * @param string $tag
8576
+ * @param string $slug
8577
+ *
8578
+ * @return string
8579
+ */
8580
+ private static function get_ajax_action_static( $tag, $slug = '' ) {
8581
+ $action = "fs_{$tag}";
8582
+
8583
+ if ( ! empty( $slug ) ) {
8584
+ $action .= "_{$slug}";
8585
+ }
8586
+
8587
+ return $action;
8588
+ }
8589
+
8590
+ /**
8591
+ * Do action, specific for the current context plugin.
8592
+ *
8593
+ * @author Vova Feldman (@svovaf)
8594
+ * @since 1.0.1
8595
+ *
8596
+ * @param string $tag The name of the action to be executed.
8597
+ * @param mixed $arg,... Optional. Additional arguments which are passed on to the
8598
+ * functions hooked to the action. Default empty.
8599
+ *
8600
+ * @uses do_action()
8601
+ */
8602
+ function do_action( $tag, $arg = '' ) {
8603
+ $this->_logger->entrance( $tag );
8604
+
8605
+ $args = func_get_args();
8606
+
8607
+ call_user_func_array( 'do_action', array_merge(
8608
+ array( $this->get_action_tag( $tag ) ),
8609
+ array_slice( $args, 1 ) )
8610
+ );
8611
+ }
8612
+
8613
+ /**
8614
+ * Add action, specific for the current context plugin.
8615
+ *
8616
+ * @author Vova Feldman (@svovaf)
8617
+ * @since 1.0.1
8618
+ *
8619
+ * @param string $tag
8620
+ * @param callable $function_to_add
8621
+ * @param int $priority
8622
+ * @param int $accepted_args
8623
+ *
8624
+ * @uses add_action()
8625
+ */
8626
+ function add_action(
8627
+ $tag,
8628
+ $function_to_add,
8629
+ $priority = WP_FS__DEFAULT_PRIORITY,
8630
+ $accepted_args = 1
8631
+ ) {
8632
+ $this->_logger->entrance( $tag );
8633
+
8634
+ add_action( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
8635
+ }
8636
+
8637
+ /**
8638
+ * Add AJAX action, specific for the current context plugin.
8639
+ *
8640
+ * @author Vova Feldman (@svovaf)
8641
+ * @since 1.2.1
8642
+ *
8643
+ * @param string $tag
8644
+ * @param callable $function_to_add
8645
+ * @param int $priority
8646
+ *
8647
+ * @uses add_action()
8648
+ *
8649
+ * @return bool True if action added, false if no need to add the action since the AJAX call isn't matching.
8650
+ */
8651
+ function add_ajax_action(
8652
+ $tag,
8653
+ $function_to_add,
8654
+ $priority = WP_FS__DEFAULT_PRIORITY
8655
+ ) {
8656
+ $this->_logger->entrance( $tag );
8657
+
8658
+ return self::add_ajax_action_static(
8659
+ $tag,
8660
+ $function_to_add,
8661
+ $priority,
8662
+ $this->_slug
8663
+ );
8664
+ }
8665
+
8666
+ /**
8667
+ * Add AJAX action.
8668
+ *
8669
+ * @author Vova Feldman (@svovaf)
8670
+ * @since 1.2.1.6
8671
+ *
8672
+ * @param string $tag
8673
+ * @param callable $function_to_add
8674
+ * @param int $priority
8675
+ * @param string $slug
8676
+ *
8677
+ * @return bool True if action added, false if no need to add the action since the AJAX call isn't matching.
8678
+ * @uses add_action()
8679
+ *
8680
+ */
8681
+ static function add_ajax_action_static(
8682
+ $tag,
8683
+ $function_to_add,
8684
+ $priority = WP_FS__DEFAULT_PRIORITY,
8685
+ $slug = ''
8686
+ ) {
8687
+ self::$_static_logger->entrance( $tag );
8688
+
8689
+ if ( ! self::is_ajax_action_static( $tag, $slug ) ) {
8690
+ return false;
8691
+ }
8692
+
8693
+ add_action(
8694
+ 'wp_ajax_' . self::get_ajax_action_static( $tag, $slug ),
8695
+ $function_to_add,
8696
+ $priority,
8697
+ 0
8698
+ );
8699
+
8700
+ self::$_static_logger->info( "$tag AJAX callback action added." );
8701
+
8702
+ return true;
8703
+ }
8704
+
8705
+ /**
8706
+ * Send a JSON response back to an Ajax request.
8707
+ *
8708
+ * @author Vova Feldman (@svovaf)
8709
+ * @since 1.2.1.5
8710
+ *
8711
+ * @param mixed $response
8712
+ */
8713
+ static function shoot_ajax_response( $response ) {
8714
+ wp_send_json( $response );
8715
+ }
8716
+
8717
+ /**
8718
+ * Send a JSON response back to an Ajax request, indicating success.
8719
+ *
8720
+ * @author Vova Feldman (@svovaf)
8721
+ * @since 1.2.1.5
8722
+ *
8723
+ * @param mixed $data Data to encode as JSON, then print and exit.
8724
+ */
8725
+ static function shoot_ajax_success( $data = null ) {
8726
+ wp_send_json_success( $data );
8727
+ }
8728
+
8729
+ /**
8730
+ * Send a JSON response back to an Ajax request, indicating failure.
8731
+ *
8732
+ * @author Vova Feldman (@svovaf)
8733
+ * @since 1.2.1.5
8734
+ *
8735
+ * @param mixed $error Optional error message.
8736
+ */
8737
+ static function shoot_ajax_failure( $error = '' ) {
8738
+ $result = array( 'success' => false );
8739
+ if ( ! empty( $error ) ) {
8740
+ $result['error'] = $error;
8741
+ }
8742
+
8743
+ wp_send_json( $result );
8744
+ }
8745
+
8746
+ /**
8747
+ * Apply filter, specific for the current context plugin.
8748
+ *
8749
+ * @author Vova Feldman (@svovaf)
8750
+ * @since 1.0.9
8751
+ *
8752
+ * @param string $tag The name of the filter hook.
8753
+ * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
8754
+ *
8755
+ * @return mixed The filtered value after all hooked functions are applied to it.
8756
+ *
8757
+ * @uses apply_filters()
8758
+ */
8759
+ function apply_filters( $tag, $value ) {
8760
+ $this->_logger->entrance( $tag );
8761
+
8762
+ $args = func_get_args();
8763
+ array_unshift( $args, $this->_slug );
8764
+
8765
+ return call_user_func_array( 'fs_apply_filter', $args );
8766
+ }
8767
+
8768
+ /**
8769
+ * Add filter, specific for the current context plugin.
8770
+ *
8771
+ * @author Vova Feldman (@svovaf)
8772
+ * @since 1.0.9
8773
+ *
8774
+ * @param string $tag
8775
+ * @param callable $function_to_add
8776
+ * @param int $priority
8777
+ * @param int $accepted_args
8778
+ *
8779
+ * @uses add_filter()
8780
+ */
8781
+ function add_filter( $tag, $function_to_add, $priority = WP_FS__DEFAULT_PRIORITY, $accepted_args = 1 ) {
8782
+ $this->_logger->entrance( $tag );
8783
+
8784
+ add_filter( $this->get_action_tag( $tag ), $function_to_add, $priority, $accepted_args );
8785
+ }
8786
+
8787
+ /**
8788
+ * Check if has filter.
8789
+ *
8790
+ * @author Vova Feldman (@svovaf)
8791
+ * @since 1.1.4
8792
+ *
8793
+ * @param string $tag
8794
+ * @param callable|bool $function_to_check Optional. The callback to check for. Default false.
8795
+ *
8796
+ * @return false|int
8797
+ *
8798
+ * @uses has_filter()
8799
+ */
8800
+ function has_filter( $tag, $function_to_check = false ) {
8801
+ $this->_logger->entrance( $tag );
8802
+
8803
+ return has_filter( $this->get_action_tag( $tag ), $function_to_check );
8804
+ }
8805
+
8806
+ #endregion
8807
+
8808
+ /**
8809
+ * Override default i18n text phrases.
8810
+ *
8811
+ * @author Vova Feldman (@svovaf)
8812
+ * @since 1.1.6
8813
+ *
8814
+ * @param string[] string $key_value
8815
+ *
8816
+ * @uses fs_override_i18n()
8817
+ */
8818
+ function override_i18n( $key_value ) {
8819
+ fs_override_i18n( $key_value, $this->_slug );
8820
+ }
8821
+
8822
+ /* Account Page
8823
+ ------------------------------------------------------------------------------------------------------------------*/
8824
+ /**
8825
+ * Update site information.
8826
+ *
8827
+ * @author Vova Feldman (@svovaf)
8828
+ * @since 1.0.1
8829
+ *
8830
+ * @param bool $store Flush to Database if true.
8831
+ */
8832
+ private function _store_site( $store = true ) {
8833
+ $this->_logger->entrance();
8834
+
8835
+ if ( empty( $this->_site->id ) ) {
8836
+ $this->_logger->error( "Empty install ID, can't store site." );
8837
+
8838
+ return;
8839
+ }
8840
+
8841
+ $encrypted_site = clone $this->_site;
8842
+ $encrypted_site->plan = self::_encrypt_entity( $this->_site->plan );
8843
+
8844
+ $sites = self::get_all_sites();
8845
+ $sites[ $this->_slug ] = $encrypted_site;
8846
+ self::$_accounts->set_option( 'sites', $sites, $store );
8847
+ }
8848
+
8849
+ /**
8850
+ * Update plugin's plans information.
8851
+ *
8852
+ * @author Vova Feldman (@svovaf)
8853
+ * @since 1.0.2
8854
+ *
8855
+ * @param bool $store Flush to Database if true.
8856
+ */
8857
+ private function _store_plans( $store = true ) {
8858
+ $this->_logger->entrance();
8859
+
8860
+ $plans = self::get_all_plans();
8861
+
8862
+ // Copy plans.
8863
+ $encrypted_plans = array();
8864
+ for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
8865
+ $encrypted_plans[] = self::_encrypt_entity( $this->_plans[ $i ] );
8866
+ }
8867
+
8868
+ $plans[ $this->_slug ] = $encrypted_plans;
8869
+ self::$_accounts->set_option( 'plans', $plans, $store );
8870
+ }
8871
+
8872
+ /**
8873
+ * Update user's plugin licenses.
8874
+ *
8875
+ * @author Vova Feldman (@svovaf)
8876
+ * @since 1.0.5
8877
+ *
8878
+ * @param bool $store
8879
+ * @param string|bool $plugin_slug
8880
+ * @param FS_Plugin_License[] $licenses
8881
+ */
8882
+ private function _store_licenses( $store = true, $plugin_slug = false, $licenses = array() ) {
8883
+ $this->_logger->entrance();
8884
+
8885
+ $all_licenses = self::get_all_licenses();
8886
+
8887
+ if ( ! is_string( $plugin_slug ) ) {
8888
+ $plugin_slug = $this->_slug;
8889
+ $licenses = $this->_licenses;
8890
+ }
8891
+
8892
+ if ( ! isset( $all_licenses[ $plugin_slug ] ) ) {
8893
+ $all_licenses[ $plugin_slug ] = array();
8894
+ }
8895
+
8896
+ $all_licenses[ $plugin_slug ][ $this->_user->id ] = $licenses;
8897
+
8898
+ self::$_accounts->set_option( 'licenses', $all_licenses, $store );
8899
+ }
8900
+
8901
+ /**
8902
+ * Update user information.
8903
+ *
8904
+ * @author Vova Feldman (@svovaf)
8905
+ * @since 1.0.1
8906
+ *
8907
+ * @param bool $store Flush to Database if true.
8908
+ */
8909
+ private function _store_user( $store = true ) {
8910
+ $this->_logger->entrance();
8911
+
8912
+ if ( empty( $this->_user->id ) ) {
8913
+ $this->_logger->error( "Empty user ID, can't store user." );
8914
+
8915
+ return;
8916
+ }
8917
+
8918
+ $users = self::get_all_users();
8919
+ $users[ $this->_user->id ] = $this->_user;
8920
+ self::$_accounts->set_option( 'users', $users, $store );
8921
+ }
8922
+
8923
+ /**
8924
+ * Update new updates information.
8925
+ *
8926
+ * @author Vova Feldman (@svovaf)
8927
+ * @since 1.0.4
8928
+ *
8929
+ * @param FS_Plugin_Tag|null $update
8930
+ * @param bool $store Flush to Database if true.
8931
+ * @param bool|number $plugin_id
8932
+ */
8933
+ private function _store_update( $update, $store = true, $plugin_id = false ) {
8934
+ $this->_logger->entrance();
8935
+
8936
+ if ( $update instanceof FS_Plugin_Tag ) {
8937
+ $update->updated = time();
8938
+ }
8939
+
8940
+ if ( ! is_numeric( $plugin_id ) ) {
8941
+ $plugin_id = $this->_plugin->id;
8942
+ }
8943
+
8944
+ $updates = self::get_all_updates();
8945
+ $updates[ $plugin_id ] = $update;
8946
+ self::$_accounts->set_option( 'updates', $updates, $store );
8947
+ }
8948
+
8949
+ /**
8950
+ * Update new updates information.
8951
+ *
8952
+ * @author Vova Feldman (@svovaf)
8953
+ * @since 1.0.6
8954
+ *
8955
+ * @param FS_Plugin[] $plugin_addons
8956
+ * @param bool $store Flush to Database if true.
8957
+ */
8958
+ private function _store_addons( $plugin_addons, $store = true ) {
8959
+ $this->_logger->entrance();
8960
+
8961
+ $addons = self::get_all_addons();
8962
+ $addons[ $this->_plugin->id ] = $plugin_addons;
8963
+ self::$_accounts->set_option( 'addons', $addons, $store );
8964
+ }
8965
+
8966
+ /**
8967
+ * Delete plugin's associated add-ons.
8968
+ *
8969
+ * @author Vova Feldman (@svovaf)
8970
+ * @since 1.0.8
8971
+ *
8972
+ * @param bool $store
8973
+ *
8974
+ * @return bool
8975
+ */
8976
+ private function _delete_account_addons( $store = true ) {
8977
+ $all_addons = self::get_all_account_addons();
8978
+
8979
+ if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) {
8980
+ return false;
8981
+ }
8982
+
8983
+ unset( $all_addons[ $this->_plugin->id ] );
8984
+
8985
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
8986
+
8987
+ return true;
8988
+ }
8989
+
8990
+ /**
8991
+ * Update account add-ons list.
8992
+ *
8993
+ * @author Vova Feldman (@svovaf)
8994
+ * @since 1.0.6
8995
+ *
8996
+ * @param FS_Plugin[] $addons
8997
+ * @param bool $store Flush to Database if true.
8998
+ */
8999
+ private function _store_account_addons( $addons, $store = true ) {
9000
+ $this->_logger->entrance();
9001
+
9002
+ $all_addons = self::get_all_account_addons();
9003
+ $all_addons[ $this->_plugin->id ] = $addons;
9004
+ self::$_accounts->set_option( 'account_addons', $all_addons, $store );
9005
+ }
9006
+
9007
+ /**
9008
+ * Store account params in the Database.
9009
+ *
9010
+ * @author Vova Feldman (@svovaf)
9011
+ * @since 1.0.1
9012
+ */
9013
+ private function _store_account() {
9014
+ $this->_logger->entrance();
9015
+
9016
+ $this->_store_site( false );
9017
+ $this->_store_user( false );
9018
+ $this->_store_plans( false );
9019
+ $this->_store_licenses( false );
9020
+
9021
+ self::$_accounts->store();
9022
+ }
9023
+
9024
+ /**
9025
+ * Sync user's information.
9026
+ *
9027
+ * @author Vova Feldman (@svovaf)
9028
+ * @since 1.0.3
9029
+ * @uses FS_Api
9030
+ */
9031
+ private function _handle_account_user_sync() {
9032
+ $this->_logger->entrance();
9033
+
9034
+ $api = $this->get_api_user_scope();
9035
+
9036
+ // Get user's information.
9037
+ $user = $api->get( '/', true );
9038
+
9039
+ if ( isset( $user->id ) ) {
9040
+ $this->_user->first = $user->first;
9041
+ $this->_user->last = $user->last;
9042
+ $this->_user->email = $user->email;
9043
+
9044
+ $is_menu_item_account_visible = $this->is_submenu_item_visible( 'account' );
9045
+
9046
+ if ( $user->is_verified &&
9047
+ ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified )
9048
+ ) {
9049
+ $this->_user->is_verified = true;
9050
+
9051
+ $this->do_action( 'account_email_verified', $user->email );
9052
+
9053
+ $this->_admin_notices->add(
9054
+ $this->get_text( 'email-verified-message' ),
9055
+ $this->get_text( 'right-on' ) . '!',
9056
+ 'success',
9057
+ // Make admin sticky if account menu item is invisible,
9058
+ // since the page will be auto redirected to the plugin's
9059
+ // main settings page, and the non-sticky message
9060
+ // will disappear.
9061
+ ! $is_menu_item_account_visible,
9062
+ false,
9063
+ 'email_verified'
9064
+ );
9065
+ }
9066
+
9067
+ // Flush user details to DB.
9068
+ $this->_store_user();
9069
+
9070
+ $this->do_action( 'after_account_user_sync', $user );
9071
+
9072
+ /**
9073
+ * If account menu item is hidden, redirect to plugin's main settings page.
9074
+ *
9075
+ * @author Vova Feldman (@svovaf)
9076
+ * @since 1.1.6
9077
+ *
9078
+ * @link https://github.com/Freemius/wordpress-sdk/issues/6
9079
+ */
9080
+ if ( ! $is_menu_item_account_visible ) {
9081
+ fs_redirect( $this->_get_admin_page_url() );
9082
+ }
9083
+ }
9084
+ }
9085
+
9086
+ /**
9087
+ * @param bool $store
9088
+ *
9089
+ * @return FS_Plugin_Plan|object|false
9090
+ */
9091
+ private function _enrich_site_plan( $store = true ) {
9092
+ // Try to load plan from local cache.
9093
+ $plan = $this->_get_plan_by_id( $this->_site->plan->id );
9094
+
9095
+ if ( false === $plan ) {
9096
+ $plan = $this->_fetch_site_plan();
9097
+ }
9098
+
9099
+ if ( $plan instanceof FS_Plugin_Plan ) {
9100
+ $this->_update_plan( $plan, $store );
9101
+ }
9102
+
9103
+ return $plan;
9104
+ }
9105
+
9106
+ /**
9107
+ * @author Vova Feldman (@svovaf)
9108
+ * @since 1.0.9
9109
+ * @uses FS_Api
9110
+ *
9111
+ * @param bool $store
9112
+ *
9113
+ * @return FS_Plugin_Plan|object|false
9114
+ */
9115
+ private function _enrich_site_trial_plan( $store = true ) {
9116
+ // Try to load plan from local cache.
9117
+ $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
9118
+
9119
+ if ( false === $trial_plan ) {
9120
+ $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
9121
+ }
9122
+
9123
+ if ( $trial_plan instanceof FS_Plugin_Plan ) {
9124
+ $this->_storage->store( 'trial_plan', $trial_plan, $store );
9125
+ }
9126
+
9127
+ return $trial_plan;
9128
+ }
9129
+
9130
+ /**
9131
+ * @author Vova Feldman (@svovaf)
9132
+ * @since 1.0.9
9133
+ * @uses FS_Api
9134
+ *
9135
+ * @param number|bool $license_id
9136
+ *
9137
+ * @return FS_Subscription|object|bool
9138
+ */
9139
+ private function _fetch_site_license_subscription( $license_id = false ) {
9140
+ $this->_logger->entrance();
9141
+ $api = $this->get_api_site_scope();
9142
+
9143
+ if ( ! is_numeric( $license_id ) ) {
9144
+ $license_id = $this->_license->id;
9145
+ }
9146
+
9147
+ $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );
9148
+
9149
+ return ! isset( $result->error ) ?
9150
+ ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
9151
+ new FS_Subscription( $result->subscriptions[0] ) :
9152
+ false
9153
+ ) :
9154
+ $result;
9155
+ }
9156
+
9157
+ /**
9158
+ * @author Vova Feldman (@svovaf)
9159
+ * @since 1.0.4
9160
+ * @uses FS_Api
9161
+ *
9162
+ * @param number|bool $plan_id
9163
+ *
9164
+ * @return FS_Plugin_Plan|object
9165
+ */
9166
+ private function _fetch_site_plan( $plan_id = false ) {
9167
+ $this->_logger->entrance();
9168
+ $api = $this->get_api_site_scope();
9169
+
9170
+ if ( ! is_numeric( $plan_id ) ) {
9171
+ $plan_id = $this->_site->plan->id;
9172
+ }
9173
+
9174
+ $plan = $api->get( "/plans/{$plan_id}.json", true );
9175
+
9176
+ return ! isset( $plan->error ) ? new FS_Plugin_Plan( $plan ) : $plan;
9177
+ }
9178
+
9179
+ /**
9180
+ * @author Vova Feldman (@svovaf)
9181
+ * @since 1.0.5
9182
+ * @uses FS_Api
9183
+ *
9184
+ * @return FS_Plugin_Plan[]|object
9185
+ */
9186
+ private function _fetch_plugin_plans() {
9187
+ $this->_logger->entrance();
9188
+ $api = $this->get_api_site_scope();
9189
+
9190
+ $result = $api->get( '/plans.json', true );
9191
+
9192
+ if ( $this->is_api_result_object( $result, 'plans' ) && is_array( $result->plans ) ) {
9193
+ for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
9194
+ $result->plans[ $i ] = new FS_Plugin_Plan( $result->plans[ $i ] );
9195
+ }
9196
+
9197
+ $result = $result->plans;
9198
+ }
9199
+
9200
+ return $result;
9201
+ }
9202
+
9203
+ /**
9204
+ * @author Vova Feldman (@svovaf)
9205
+ * @since 1.0.5
9206
+ * @uses FS_Api
9207
+ *
9208
+ * @param number|bool $plugin_id
9209
+ * @param number|bool $site_license_id
9210
+ *
9211
+ * @return FS_Plugin_License[]|object
9212
+ */
9213
+ private function _fetch_licenses( $plugin_id = false, $site_license_id = false ) {
9214
+ $this->_logger->entrance();
9215
+
9216
+ $api = $this->get_api_user_scope();
9217
+
9218
+ if ( ! is_numeric( $plugin_id ) ) {
9219
+ $plugin_id = $this->_plugin->id;
9220
+ }
9221
+
9222
+ $result = $api->get( "/plugins/{$plugin_id}/licenses.json", true );
9223
+
9224
+ $is_site_license_synced = false;
9225
+
9226
+ $api_errors = array();
9227
+
9228
+ if ( $this->is_api_result_object( $result, 'licenses' ) &&
9229
+ is_array( $result->licenses )
9230
+ ) {
9231
+ for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
9232
+ $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
9233
+
9234
+ if ( ( ! $is_site_license_synced ) && is_numeric( $site_license_id ) ) {
9235
+ $is_site_license_synced = ( $site_license_id == $result->licenses[ $i ]->id );
9236
+ }
9237
+ }
9238
+
9239
+ $result = $result->licenses;
9240
+ } else {
9241
+ $api_errors[] = $result;
9242
+ $result = array();
9243
+ }
9244
+
9245
+ if ( ! $is_site_license_synced ) {
9246
+ $api = $this->get_api_site_scope();
9247
+
9248
+ if ( is_numeric( $site_license_id ) ) {
9249
+ // Try to retrieve a foreign license that is linked to the install.
9250
+ $api_result = $api->call( '/licenses.json' );
9251
+
9252
+ if ( $this->is_api_result_object( $api_result, 'licenses' ) &&
9253
+ is_array( $api_result->licenses )
9254
+ ) {
9255
+ $licenses = $api_result->licenses;
9256
+
9257
+ if ( ! empty( $licenses ) ) {
9258
+ $result[] = new FS_Plugin_License( $licenses[0] );
9259
+ }
9260
+ } else {
9261
+ $api_errors[] = $api_result;
9262
+ }
9263
+ } else if ( is_object( $this->_license ) ) {
9264
+ // Fetch foreign license by ID and license key.
9265
+ $license = $api->get( "/licenses/{$this->_license->id}.json?license_key=" .
9266
+ urlencode( $this->_license->secret_key ) );
9267
+
9268
+ if ( $this->is_api_result_entity( $license ) ) {
9269
+ $result[] = new FS_Plugin_License( $license );
9270
+ } else {
9271
+ $api_errors[] = $license;
9272
+ }
9273
+ }
9274
+ }
9275
+
9276
+ if ( is_array( $result ) && 0 < count( $result ) ) {
9277
+ // If found at least one license, return license collection even if there are errors.
9278
+ return $result;
9279
+ }
9280
+
9281
+ if ( ! empty( $api_errors ) ) {
9282
+ // If found any errors and no licenses, return first error.
9283
+ return $api_errors[0];
9284
+ }
9285
+
9286
+ // Fallback to empty licenses list.
9287
+ return $result;
9288
+ }
9289
+
9290
+ /**
9291
+ * @author Vova Feldman (@svovaf)
9292
+ * @since 1.2.0
9293
+ * @uses FS_Api
9294
+ *
9295
+ * @param number|bool $plugin_id
9296
+ *
9297
+ * @return FS_Payment[]|object
9298
+ */
9299
+ function _fetch_payments( $plugin_id = false ) {
9300
+ $this->_logger->entrance();
9301
+
9302
+ $api = $this->get_api_user_scope();
9303
+
9304
+ if ( ! is_numeric( $plugin_id ) ) {
9305
+ $plugin_id = $this->_plugin->id;
9306
+ }
9307
+
9308
+ $result = $api->get( "/plugins/{$plugin_id}/payments.json?include_addons=true", true );
9309
+
9310
+ if ( ! isset( $result->error ) ) {
9311
+ for ( $i = 0, $len = count( $result->payments ); $i < $len; $i ++ ) {
9312
+ $result->payments[ $i ] = new FS_Payment( $result->payments[ $i ] );
9313
+ }
9314
+ $result = $result->payments;
9315
+ }
9316
+
9317
+ return $result;
9318
+ }
9319
+
9320
+ /**
9321
+ * @author Vova Feldman (@svovaf)
9322
+ * @since 1.2.1.5
9323
+ * @uses FS_Api
9324
+ *
9325
+ * @return \FS_Billing|mixed
9326
+ */
9327
+ function _fetch_billing() {
9328
+ require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-billing.php';
9329
+
9330
+ $billing = $this->get_api_user_scope()->call( 'billing.json' );
9331
+
9332
+ if ( $this->is_api_result_entity( $billing ) ) {
9333
+ $billing = new FS_Billing( $billing );
9334
+ }
9335
+
9336
+ return $billing;
9337
+ }
9338
+
9339
+ /**
9340
+ * @author Vova Feldman (@svovaf)
9341
+ * @since 1.0.4
9342
+ *
9343
+ * @param FS_Plugin_Plan $plan
9344
+ * @param bool $store
9345
+ */
9346
+ private function _update_plan( $plan, $store = false ) {
9347
+ $this->_logger->entrance();
9348
+
9349
+ $this->_site->plan = $plan;
9350
+ $this->_store_site( $store );
9351
+ }
9352
+
9353
+ /**
9354
+ * @author Vova Feldman (@svovaf)
9355
+ * @since 1.0.5
9356
+ *
9357
+ * @param FS_Plugin_License[] $licenses
9358
+ * @param string|bool $plugin_slug
9359
+ */
9360
+ private function _update_licenses( $licenses, $plugin_slug = false ) {
9361
+ $this->_logger->entrance();
9362
+
9363
+ if ( is_array( $licenses ) ) {
9364
+ for ( $i = 0, $len = count( $licenses ); $i < $len; $i ++ ) {
9365
+ $licenses[ $i ]->updated = time();
9366
+ }
9367
+ }
9368
+
9369
+ if ( ! is_string( $plugin_slug ) ) {
9370
+ $this->_licenses = $licenses;
9371
+ }
9372
+
9373
+ $this->_store_licenses( true, $plugin_slug, $licenses );
9374
+ }
9375
+
9376
+ /**
9377
+ * @author Vova Feldman (@svovaf)
9378
+ * @since 1.0.4
9379
+ *
9380
+ * @param bool|number $plugin_id
9381
+ * @param bool $flush Since 1.1.7.3
9382
+ *
9383
+ * @return object|false New plugin tag info if exist.
9384
+ */
9385
+ private function _fetch_newer_version( $plugin_id = false, $flush = true ) {
9386
+ $latest_tag = $this->_fetch_latest_version( $plugin_id, $flush );
9387
+
9388
+ if ( ! is_object( $latest_tag ) ) {
9389
+ return false;
9390
+ }
9391
+
9392
+ // Check if version is actually newer.
9393
+ $has_new_version =
9394
+ // If it's an non-installed add-on then always return latest.
9395
+ ( $this->_is_addon_id( $plugin_id ) && ! $this->is_addon_activated( $plugin_id ) ) ||
9396
+ // Compare versions.
9397
+ version_compare( $this->get_plugin_version(), $latest_tag->version, '<' );
9398
+
9399
+ $this->_logger->departure( $has_new_version ? 'Found newer plugin version ' . $latest_tag->version : 'No new version' );
9400
+
9401
+ return $has_new_version ? $latest_tag : false;
9402
+ }
9403
+
9404
+ /**
9405
+ * @author Vova Feldman (@svovaf)
9406
+ * @since 1.0.5
9407
+ *
9408
+ * @param bool|number $plugin_id
9409
+ * @param bool $flush Since 1.1.7.3
9410
+ *
9411
+ * @return bool|FS_Plugin_Tag
9412
+ */
9413
+ function get_update( $plugin_id = false, $flush = true ) {
9414
+ $this->_logger->entrance();
9415
+
9416
+ if ( ! is_numeric( $plugin_id ) ) {
9417
+ $plugin_id = $this->_plugin->id;
9418
+ }
9419
+
9420
+ $this->check_updates( true, $plugin_id, $flush );
9421
+ $updates = $this->get_all_updates();
9422
+
9423
+ return isset( $updates[ $plugin_id ] ) && is_object( $updates[ $plugin_id ] ) ? $updates[ $plugin_id ] : false;
9424
+ }
9425
+
9426
+ /**
9427
+ * Check if site assigned with active license.
9428
+ *
9429
+ * @author Vova Feldman (@svovaf)
9430
+ * @since 1.0.6
9431
+ *
9432
+ * @deprecated Please use has_active_valid_license() instead because license can be cancelled.
9433
+ */
9434
+ function has_active_license() {
9435
+ return (
9436
+ is_object( $this->_license ) &&
9437
+ is_numeric( $this->_license->id ) &&
9438
+ ! $this->_license->is_expired()
9439
+ );
9440
+ }
9441
+
9442
+ /**
9443
+ * Check if site assigned with active & valid (not expired) license.
9444
+ *
9445
+ * @author Vova Feldman (@svovaf)
9446
+ * @since 1.2.1
9447
+ */
9448
+ function has_active_valid_license() {
9449
+ return (
9450
+ is_object( $this->_license ) &&
9451
+ is_numeric( $this->_license->id ) &&
9452
+ $this->_license->is_active() &&
9453
+ $this->_license->is_valid()
9454
+ );
9455
+ }
9456
+
9457
+ /**
9458
+ * Check if site assigned with license with enabled features.
9459
+ *
9460
+ * @author Vova Feldman (@svovaf)
9461
+ * @since 1.0.6
9462
+ *
9463
+ * @return bool
9464
+ */
9465
+ function has_features_enabled_license() {
9466
+ return (
9467
+ is_object( $this->_license ) &&
9468
+ is_numeric( $this->_license->id ) &&
9469
+ $this->_license->is_features_enabled()
9470
+ );
9471
+ }
9472
+
9473
+ /**
9474
+ * Check if user is a trial or have feature enabled license.
9475
+ *
9476
+ * @author Vova Feldman (@svovaf)
9477
+ * @since 1.1.7
9478
+ *
9479
+ * @return bool
9480
+ */
9481
+ function can_use_premium_code() {
9482
+ return $this->is_trial() || $this->has_features_enabled_license();
9483
+ }
9484
+
9485
+ /**
9486
+ * Checks if the current user can activate plugins or switch themes. Note that this method should only be used
9487
+ * after the `init` action is triggered because it is using `current_user_can()` which is only functional after
9488
+ * the context user is authenticated.
9489
+ *
9490
+ * @author Leo Fajardo (@leorw)
9491
+ * @since 1.2.2
9492
+ *
9493
+ * @return bool
9494
+ */
9495
+ function is_user_admin() {
9496
+ return current_user_can( 'activate_plugins' );
9497
+ }
9498
+
9499
+ /**
9500
+ * Sync site's plan.
9501
+ *
9502
+ * @author Vova Feldman (@svovaf)
9503
+ * @since 1.0.3
9504
+ *
9505
+ * @uses FS_Api
9506
+ *
9507
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
9508
+ * the admin.
9509
+ */
9510
+ private function _sync_license( $background = false ) {
9511
+ $this->_logger->entrance();
9512
+
9513
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
9514
+
9515
+ $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() );
9516
+
9517
+ if ( $is_addon_sync ) {
9518
+ $this->_sync_addon_license( $plugin_id, $background );
9519
+ } else {
9520
+ $this->_sync_plugin_license( $background );
9521
+ }
9522
+
9523
+ $this->do_action( 'after_account_plan_sync', $this->_site->plan->name );
9524
+ }
9525
+
9526
+ /**
9527
+ * Sync plugin's add-on license.
9528
+ *
9529
+ * @author Vova Feldman (@svovaf)
9530
+ * @since 1.0.6
9531
+ * @uses FS_Api
9532
+ *
9533
+ * @param number $addon_id
9534
+ * @param bool $background
9535
+ */
9536
+ private function _sync_addon_license( $addon_id, $background ) {
9537
+ $this->_logger->entrance();
9538
+
9539
+ if ( $this->is_addon_activated( $addon_id ) ) {
9540
+ // If already installed, use add-on sync.
9541
+ $fs_addon = self::get_instance_by_id( $addon_id );
9542
+ $fs_addon->_sync_license( $background );
9543
+
9544
+ return;
9545
+ }
9546
+
9547
+ // Validate add-on exists.
9548
+ $addon = $this->get_addon( $addon_id );
9549
+
9550
+ if ( ! is_object( $addon ) ) {
9551
+ return;
9552
+ }
9553
+
9554
+ // Add add-on into account add-ons.
9555
+ $account_addons = $this->get_account_addons();
9556
+ if ( ! is_array( $account_addons ) ) {
9557
+ $account_addons = array();
9558
+ }
9559
+ $account_addons[] = $addon->id;
9560
+ $account_addons = array_unique( $account_addons );
9561
+ $this->_store_account_addons( $account_addons );
9562
+
9563
+ // Load add-on licenses.
9564
+ $licenses = $this->_fetch_licenses( $addon->id );
9565
+
9566
+ // Sync add-on licenses.
9567
+ if ( $this->is_array_instanceof( $licenses, 'FS_Plugin_License' ) ) {
9568
+ $this->_update_licenses( $licenses, $addon->slug );
9569
+
9570
+ if ( ! $this->is_addon_installed( $addon->slug ) && FS_License_Manager::has_premium_license( $licenses ) ) {
9571
+ $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
9572
+
9573
+ if ( ! isset( $plans_result->error ) ) {
9574
+ $plans = array();
9575
+ foreach ( $plans_result->plans as $plan ) {
9576
+ $plans[] = new FS_Plugin_Plan( $plan );
9577
+ }
9578
+
9579
+ $this->_admin_notices->add_sticky(
9580
+ FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
9581
+ sprintf(
9582
+ $this->get_text( 'addon-successfully-upgraded-message' ),
9583
+ $addon->title
9584
+ ) . ' ' . $this->get_latest_download_link(
9585
+ $this->get_text( 'download-latest-version' ),
9586
+ $addon_id
9587
+ )
9588
+ :
9589
+ sprintf(
9590
+ $this->get_text( 'addon-successfully-purchased-message' ),
9591
+ $addon->title
9592
+ ) . ' ' . $this->get_latest_download_link(
9593
+ $this->get_text( 'download-latest-version' ),
9594
+ $addon_id
9595
+ ),
9596
+ 'addon_plan_upgraded_' . $addon->slug,
9597
+ $this->get_text( 'yee-haw' ) . '!'
9598
+ );
9599
+ }
9600
+ }
9601
+ }
9602
+ }
9603
+
9604
+ /**
9605
+ * Sync site's plugin plan.
9606
+ *
9607
+ * @author Vova Feldman (@svovaf)
9608
+ * @since 1.0.6
9609
+ * @uses FS_Api
9610
+ *
9611
+ * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
9612
+ * the admin.
9613
+ */
9614
+ private function _sync_plugin_license( $background = false ) {
9615
+ $this->_logger->entrance();
9616
+
9617
+ /**
9618
+ * Sync site info.
9619
+ *
9620
+ * @todo This line will execute install sync on a daily basis, even if running the free version (for opted-in users). The reason we want to keep it that way is for cases when the user was a paying customer, then there was a failure in subscription payment, and then after some time the payment was successful. This could be heavily optimized. For example, we can skip the $flush if the current install was never associated with a paid version.
9621
+ */
9622
+ $site = $this->send_install_update( array(), true );
9623
+
9624
+ $plan_change = 'none';
9625
+
9626
+ if ( ! $this->is_api_result_entity( $site ) ) {
9627
+ // Show API messages only if not background sync or if paying customer.
9628
+ if ( ! $background || $this->is_paying() ) {
9629
+ // Try to ping API to see if not blocked.
9630
+ if ( ! FS_Api::test() ) {
9631
+ /**
9632
+ * Failed to ping API - blocked!
9633
+ *
9634
+ * @author Vova Feldman (@svovaf)
9635
+ * @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.
9636
+ */
9637
+ $api = $this->get_api_site_scope();
9638
+
9639
+ if ( ! self::$_global_admin_notices->has_sticky( 'api_blocked' ) ) {
9640
+ self::$_global_admin_notices->add(
9641
+ sprintf(
9642
+ $this->get_text( 'server-blocking-access' ),
9643
+ $this->get_plugin_name(),
9644
+ '<a href="' . $api->get_url() . '" target="_blank">' . $api->get_url() . '</a>'
9645
+ ) . '<br> ' . $this->get_text( 'server-error-message' ) . var_export( $site->error, true ),
9646
+ $this->get_text( 'oops' ) . '...',
9647
+ 'error',
9648
+ $background,
9649
+ false,
9650
+ 'api_blocked'
9651
+ );
9652
+ }
9653
+ } else {
9654
+ // Authentication params are broken.
9655
+ $this->_admin_notices->add(
9656
+ $this->get_text( 'wrong-authentication-param-message' ),
9657
+ $this->get_text( 'oops' ) . '...',
9658
+ 'error'
9659
+ );
9660
+ }
9661
+ }
9662
+
9663
+ // No reason to continue with license sync while there are API issues.
9664
+ return;
9665
+ }
9666
+
9667
+ // Remove sticky API connectivity message.
9668
+ self::$_global_admin_notices->remove_sticky( 'api_blocked' );
9669
+
9670
+ $site = new FS_Site( $site );
9671
+
9672
+ // Sync plans.
9673
+ $this->_sync_plans();
9674
+
9675
+ if ( ! $this->has_paid_plan() ) {
9676
+ $this->_site = $site;
9677
+ $this->_enrich_site_plan( true );
9678
+ $this->_store_site();
9679
+ } else {
9680
+ /**
9681
+ * Sync licenses. Pass the site's license ID so that the foreign licenses will be fetched if the license
9682
+ * associated with that ID is not included in the user's licenses collection.
9683
+ */
9684
+ $this->_sync_licenses( $site->license_id );
9685
+
9686
+ // Check if plan / license changed.
9687
+ if ( ! FS_Entity::equals( $site->plan, $this->_site->plan ) ||
9688
+ // Check if trial started.
9689
+ $site->trial_plan_id != $this->_site->trial_plan_id ||
9690
+ $site->trial_ends != $this->_site->trial_ends ||
9691
+ // Check if license changed.
9692
+ $site->license_id != $this->_site->license_id
9693
+ ) {
9694
+ if ( $site->is_trial() && ( ! $this->_site->is_trial() || $site->trial_ends != $this->_site->trial_ends ) ) {
9695
+ // New trial started.
9696
+ $this->_site = $site;
9697
+ $plan_change = 'trial_started';
9698
+
9699
+ // Store trial plan information.
9700
+ $this->_enrich_site_trial_plan( true );
9701
+
9702
+ // For trial with subscription use-case.
9703
+ $new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
9704
+
9705
+ if ( is_object( $new_license ) && $new_license->is_valid() ) {
9706
+ $this->_site = $site;
9707
+ $this->_update_site_license( $new_license );
9708
+ $this->_store_licenses();
9709
+ $this->_enrich_site_plan( true );
9710
+
9711
+ $this->_sync_site_subscription( $this->_license );
9712
+ }
9713
+ } else if ( $this->_site->is_trial() && ! $site->is_trial() && ! is_numeric( $site->license_id ) ) {
9714
+ // Was in trial, but now trial expired and no license ID.
9715
+ // New trial started.
9716
+ $this->_site = $site;
9717
+ $plan_change = 'trial_expired';
9718
+
9719
+ // Clear trial plan information.
9720
+ $this->_storage->trial_plan = null;
9721
+
9722
+ } else {
9723
+ $is_free = $this->is_free_plan();
9724
+
9725
+ // Make sure license exist and not expired.
9726
+ $new_license = is_null( $site->license_id ) ?
9727
+ null :
9728
+ $this->_get_license_by_id( $site->license_id );
9729
+
9730
+ if ( $is_free && is_null( $new_license ) && $this->has_any_license() && $this->_license->is_cancelled ) {
9731
+ // License cancelled.
9732
+ $this->_site = $site;
9733
+ $this->_update_site_license( $new_license );
9734
+ $this->_store_licenses();
9735
+ $this->_enrich_site_plan( true );
9736
+
9737
+ $plan_change = 'cancelled';
9738
+ } else if ( $is_free && ( ( ! is_object( $new_license ) || $new_license->is_expired() ) ) ) {
9739
+ // The license is expired, so ignore upgrade method.
9740
+ } else {
9741
+ // License changed.
9742
+ $this->_site = $site;
9743
+ $this->_update_site_license( $new_license );
9744
+ $this->_store_licenses();
9745
+ $this->_enrich_site_plan( true );
9746
+
9747
+ $plan_change = $is_free ?
9748
+ 'upgraded' :
9749
+ ( is_object( $new_license ) ?
9750
+ 'changed' :
9751
+ 'downgraded' );
9752
+ }
9753
+ }
9754
+
9755
+ // Store updated site info.
9756
+ $this->_store_site();
9757
+ } else {
9758
+ if ( is_object( $this->_license ) && $this->_license->is_expired() ) {
9759
+ if ( ! $this->has_features_enabled_license() ) {
9760
+ $this->_deactivate_license();
9761
+ $plan_change = 'downgraded';
9762
+ } else {
9763
+ $plan_change = 'expired';
9764
+ }
9765
+ }
9766
+
9767
+ if ( is_numeric( $site->license_id ) && is_object( $this->_license ) ) {
9768
+ $this->_sync_site_subscription( $this->_license );
9769
+ }
9770
+ }
9771
+ }
9772
+
9773
+ if ( $this->has_paid_plan() ) {
9774
+ switch ( $plan_change ) {
9775
+ case 'none':
9776
+ if ( ! $background && is_admin() ) {
9777
+ $plan = $this->is_trial() ?
9778
+ $this->_storage->trial_plan :
9779
+ $this->_site->plan;
9780
+
9781
+ if ( $plan->is_free() ) {
9782
+ $this->_admin_notices->add(
9783
+ sprintf(
9784
+ $this->get_text( 'plan-did-not-change-message' ),
9785
+ '<i><b>' . $plan->title . ( $this->is_trial() ? ' ' . $this->get_text( 'trial' ) : '' ) . '</b></i>'
9786
+ ) . ' ' . sprintf(
9787
+ '<a href="%s">%s</a>',
9788
+ $this->contact_url(
9789
+ 'bug',
9790
+ sprintf( $this->get_text( 'plan-did-not-change-email-message' ),
9791
+ strtoupper( $plan->name )
9792
+ )
9793
+ ),
9794
+ $this->get_text( 'contact-us-here' )
9795
+ ),
9796
+ $this->get_text( 'hmm' ) . '...'
9797
+ );
9798
+ }
9799
+ }
9800
+ break;
9801
+ case 'upgraded':
9802
+ $this->_admin_notices->add_sticky(
9803
+ sprintf(
9804
+ $this->get_text( 'plan-upgraded-message' ),
9805
+ '<i>' . $this->get_plugin_name() . '</i>'
9806
+ ) . $this->get_complete_upgrade_instructions(),
9807
+ 'plan_upgraded',
9808
+ $this->get_text( 'yee-haw' ) . '!'
9809
+ );
9810
+
9811
+ $this->_admin_notices->remove_sticky( array(
9812
+ 'trial_started',
9813
+ 'trial_promotion',
9814
+ 'trial_expired',
9815
+ 'activation_complete',
9816
+ ) );
9817
+ break;
9818
+ case 'changed':
9819
+ $this->_admin_notices->add_sticky(
9820
+ sprintf(
9821
+ $this->get_text( 'plan-changed-to-x-message' ),
9822
+ $this->_site->plan->title
9823
+ ),
9824
+ 'plan_changed'
9825
+ );
9826
+
9827
+ $this->_admin_notices->remove_sticky( array(
9828
+ 'trial_started',
9829
+ 'trial_promotion',
9830
+ 'trial_expired',
9831
+ 'activation_complete',
9832
+ ) );
9833
+ break;
9834
+ case 'downgraded':
9835
+ $this->_admin_notices->add_sticky(
9836
+ sprintf( $this->get_text( 'license-expired-blocking-message' ) ),
9837
+ 'license_expired',
9838
+ $this->get_text( 'hmm' ) . '...'
9839
+ );
9840
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
9841
+ break;
9842
+ case 'cancelled':
9843
+ $this->_admin_notices->add(
9844
+ $this->get_text( 'license-cancelled' ) . ' ' .
9845
+ sprintf(
9846
+ '<a href="%s">%s</a>',
9847
+ $this->contact_url( 'bug' ),
9848
+ $this->get_text( 'contact-us-here' )
9849
+ ),
9850
+ $this->get_text( 'hmm' ) . '...',
9851
+ 'error'
9852
+ );
9853
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
9854
+ break;
9855
+ case 'expired':
9856
+ $this->_admin_notices->add_sticky(
9857
+ sprintf( $this->get_text( 'license-expired-non-blocking-message' ), $this->_site->plan->title ),
9858
+ 'license_expired',
9859
+ $this->get_text( 'hmm' ) . '...'
9860
+ );
9861
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
9862
+ break;
9863
+ case 'trial_started':
9864
+ $this->_admin_notices->add_sticky(
9865
+ sprintf(
9866
+ $this->get_text( 'trial-started-message' ),
9867
+ '<i>' . $this->get_plugin_name() . '</i>'
9868
+ ) . $this->get_complete_upgrade_instructions( $this->_storage->trial_plan->title ),
9869
+ 'trial_started',
9870
+ $this->get_text( 'yee-haw' ) . '!'
9871
+ );
9872
+
9873
+ $this->_admin_notices->remove_sticky( array(
9874
+ 'trial_promotion',
9875
+ ) );
9876
+ break;
9877
+ case 'trial_expired':
9878
+ $this->_admin_notices->add_sticky(
9879
+ $this->get_text( 'trial-expired-message' ),
9880
+ 'trial_expired',
9881
+ $this->get_text( 'hmm' ) . '...'
9882
+ );
9883
+ $this->_admin_notices->remove_sticky( array(
9884
+ 'trial_started',
9885
+ 'trial_promotion',
9886
+ 'plan_upgraded',
9887
+ ) );
9888
+ break;
9889
+ }
9890
+ }
9891
+
9892
+ if ( 'none' !== $plan_change ) {
9893
+ $this->do_action( 'after_license_change', $plan_change, $this->_site->plan );
9894
+ }
9895
+ }
9896
+
9897
+ /**
9898
+ * @author Vova Feldman (@svovaf)
9899
+ * @since 1.0.5
9900
+ *
9901
+ * @param bool $background
9902
+ */
9903
+ protected function _activate_license( $background = false ) {
9904
+ $this->_logger->entrance();
9905
+
9906
+ $license_id = fs_request_get( 'license_id' );
9907
+
9908
+ if ( FS_Plugin_License::is_valid_id( $license_id ) && $license_id == $this->_site->license_id ) {
9909
+ // License is already activated.
9910
+ return;
9911
+ }
9912
+
9913
+ $premium_license = FS_Plugin_License::is_valid_id( $license_id ) ?
9914
+ $this->_get_license_by_id( $license_id ) :
9915
+ $this->_get_available_premium_license();
9916
+
9917
+ if ( ! is_object( $premium_license ) ) {
9918
+ return;
9919
+ }
9920
+
9921
+ /**
9922
+ * If the premium license is already associated with the install, just
9923
+ * update the license reference (activation is not required).
9924
+ *
9925
+ * @since 1.1.9
9926
+ */
9927
+ if ( $premium_license->id == $this->_site->license_id ) {
9928
+ // License is already activated.
9929
+ $this->_update_site_license( $premium_license );
9930
+ $this->_enrich_site_plan( false );
9931
+ $this->_store_account();
9932
+
9933
+ return;
9934
+ }
9935
+
9936
+ if ( $this->_site->user_id != $premium_license->user_id ) {
9937
+ $api_request_params = array( 'license_key' => $premium_license->secret_key );
9938
+ } else {
9939
+ $api_request_params = array();
9940
+ }
9941
+
9942
+ $api = $this->get_api_site_scope();
9943
+ $license = $api->call( "/licenses/{$premium_license->id}.json", 'put', $api_request_params );
9944
+
9945
+ if ( ! $this->is_api_result_entity( $license ) ) {
9946
+ if ( ! $background ) {
9947
+ $this->_admin_notices->add( sprintf(
9948
+ '%s %s',
9949
+ $this->get_text( 'license-activation-failed-message' ),
9950
+ ( is_object( $license ) && isset( $license->error ) ?
9951
+ $license->error->message :
9952
+ sprintf( '%s<br><code>%s</code>',
9953
+ $this->get_text( 'server-error-message' ),
9954
+ var_export( $license, true )
9955
+ )
9956
+ )
9957
+ ),
9958
+ $this->get_text( 'hmm' ) . '...',
9959
+ 'error'
9960
+ );
9961
+ }
9962
+
9963
+ return;
9964
+ }
9965
+
9966
+ $premium_license = new FS_Plugin_License( $license );
9967
+
9968
+ // Updated site plan.
9969
+ $site = $this->get_api_site_scope()->get( '/', true );
9970
+ if ( $this->is_api_result_entity( $site ) ) {
9971
+ $this->_site = new FS_Site( $site );
9972
+ }
9973
+ $this->_update_site_license( $premium_license );
9974
+ $this->_enrich_site_plan( false );
9975
+
9976
+ $this->_store_account();
9977
+
9978
+ if ( ! $background ) {
9979
+ $this->_admin_notices->add_sticky(
9980
+ $this->get_text( 'license-activated-message' ) .
9981
+ $this->get_complete_upgrade_instructions(),
9982
+ 'license_activated',
9983
+ $this->get_text( 'yee-haw' ) . '!'
9984
+ );
9985
+ }
9986
+
9987
+ $this->_admin_notices->remove_sticky( array(
9988
+ 'trial_promotion',
9989
+ 'license_expired',
9990
+ ) );
9991
+ }
9992
+
9993
+ /**
9994
+ * @author Vova Feldman (@svovaf)
9995
+ * @since 1.0.5
9996
+ *
9997
+ * @param bool $show_notice
9998
+ */
9999
+ protected function _deactivate_license( $show_notice = true ) {
10000
+ $this->_logger->entrance();
10001
+
10002
+ if ( ! is_object( $this->_license ) ) {
10003
+ $this->_admin_notices->add(
10004
+ sprintf( $this->get_text( 'no-active-license-message' ), $this->_site->plan->title ),
10005
+ $this->get_text( 'hmm' ) . '...'
10006
+ );
10007
+
10008
+ return;
10009
+ }
10010
+
10011
+ $api = $this->get_api_site_scope();
10012
+ $license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
10013
+
10014
+ if ( isset( $license->error ) ) {
10015
+ $this->_admin_notices->add(
10016
+ $this->get_text( 'license-deactivation-failed-message' ) . '<br> ' .
10017
+ $this->get_text( 'server-error-message' ) . ' ' . var_export( $license->error, true ),
10018
+ $this->get_text( 'hmm' ) . '...',
10019
+ 'error'
10020
+ );
10021
+
10022
+ return;
10023
+ }
10024
+
10025
+ // Update license cache.
10026
+ for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
10027
+ if ( $license->id == $this->_licenses[ $i ]->id ) {
10028
+ $this->_licenses[ $i ] = new FS_Plugin_License( $license );
10029
+ }
10030
+ }
10031
+
10032
+ // Updated site plan to default.
10033
+ $this->_sync_plans();
10034
+ $this->_site->plan->id = $this->_plans[0]->id;
10035
+ // Unlink license from site.
10036
+ $this->_update_site_license( null );
10037
+ $this->_enrich_site_plan( false );
10038
+
10039
+ $this->_store_account();
10040
+
10041
+ if ( $show_notice ) {
10042
+ $this->_admin_notices->add(
10043
+ sprintf( $this->get_text( 'license-deactivation-message' ), $this->_site->plan->title ),
10044
+ $this->get_text( 'ok' )
10045
+ );
10046
+ }
10047
+
10048
+ $this->_admin_notices->remove_sticky( array(
10049
+ 'plan_upgraded',
10050
+ 'license_activated',
10051
+ ) );
10052
+ }
10053
+
10054
+ /**
10055
+ * Site plan downgrade.
10056
+ *
10057
+ * @author Vova Feldman (@svovaf)
10058
+ * @since 1.0.4
10059
+ *
10060
+ * @uses FS_Api
10061
+ */
10062
+ private function _downgrade_site() {
10063
+ $this->_logger->entrance();
10064
+
10065
+ $api = $this->get_api_site_scope();
10066
+ $site = $api->call( 'downgrade.json', 'put' );
10067
+
10068
+ $plan_downgraded = false;
10069
+ $plan = false;
10070
+ if ( $this->is_api_result_entity( $site ) ) {
10071
+ $prev_plan_id = $this->_site->plan->id;
10072
+
10073
+ // Update new site plan id.
10074
+ $this->_site->plan->id = $site->plan_id;
10075
+
10076
+ $plan = $this->_enrich_site_plan();
10077
+ $subscription = $this->_sync_site_subscription( $this->_license );
10078
+
10079
+ // Plan downgraded if plan was changed or subscription was cancelled.
10080
+ $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
10081
+ ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
10082
+ } else {
10083
+ // handle different error cases.
10084
+
10085
+ }
10086
+
10087
+ if ( $plan_downgraded ) {
10088
+ // Remove previous sticky message about upgrade (if exist).
10089
+ $this->_admin_notices->remove_sticky( 'plan_upgraded' );
10090
+
10091
+ $this->_admin_notices->add(
10092
+ sprintf( $this->get_text( 'plan-x-downgraded-message' ),
10093
+ $plan->title,
10094
+ human_time_diff( time(), strtotime( $this->_license->expiration ) )
10095
+ )
10096
+ );
10097
+
10098
+ // Store site updates.
10099
+ $this->_store_site();
10100
+ } else {
10101
+ $this->_admin_notices->add(
10102
+ $this->get_text( 'plan-downgraded-failure-message' ),
10103
+ $this->get_text( 'oops' ) . '...',
10104
+ 'error'
10105
+ );
10106
+ }
10107
+ }
10108
+
10109
+ /**
10110
+ * @author Vova Feldman (@svovaf)
10111
+ * @since 1.1.8.1
10112
+ *
10113
+ * @param bool|string $plan_name
10114
+ *
10115
+ * @return bool If trial was successfully started.
10116
+ */
10117
+ function start_trial( $plan_name = false ) {
10118
+ $this->_logger->entrance();
10119
+
10120
+ if ( $this->is_trial() ) {
10121
+ // Already in trial mode.
10122
+ $this->_admin_notices->add(
10123
+ $this->get_text( 'in-trial-mode' ),
10124
+ $this->get_text( 'oops' ) . '...',
10125
+ 'error'
10126
+ );
10127
+
10128
+ return false;
10129
+ }
10130
+
10131
+ if ( $this->_site->is_trial_utilized() ) {
10132
+ // Trial was already utilized.
10133
+ $this->_admin_notices->add(
10134
+ $this->get_text( 'trial-utilized' ),
10135
+ $this->get_text( 'oops' ) . '...',
10136
+ 'error'
10137
+ );
10138
+
10139
+ return false;
10140
+ }
10141
+
10142
+ if ( false !== $plan_name ) {
10143
+ $plan = $this->get_plan_by_name( $plan_name );
10144
+
10145
+ if ( false === $plan ) {
10146
+ // Plan doesn't exist.
10147
+ $this->_admin_notices->add(
10148
+ sprintf( $this->get_text( 'trial-plan-x-not-exist' ), $plan_name ),
10149
+ $this->get_text( 'oops' ) . '...',
10150
+ 'error'
10151
+ );
10152
+
10153
+ return false;
10154
+ }
10155
+
10156
+ if ( ! $plan->has_trial() ) {
10157
+ // Plan doesn't exist.
10158
+ $this->_admin_notices->add(
10159
+ sprintf( $this->get_text( 'plan-x-no-trial' ), $plan_name ),
10160
+ $this->get_text( 'oops' ) . '...',
10161
+ 'error'
10162
+ );
10163
+
10164
+ return false;
10165
+ }
10166
+ } else {
10167
+ if ( ! $this->has_trial_plan() ) {
10168
+ // None of the plans have a trial.
10169
+ $this->_admin_notices->add(
10170
+ $this->get_text( 'no-trials' ),
10171
+ $this->get_text( 'oops' ) . '...',
10172
+ 'error'
10173
+ );
10174
+
10175
+ return false;
10176
+ }
10177
+
10178
+ $plans_with_trial = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
10179
+
10180
+ $plan = $plans_with_trial[0];
10181
+ }
10182
+
10183
+ $api = $this->get_api_site_scope();
10184
+ $plan = $api->call( "plans/{$plan->id}/trials.json", 'post' );
10185
+
10186
+ if ( ! $this->is_api_result_entity( $plan ) ) {
10187
+ // Some API error while trying to start the trial.
10188
+ $this->_admin_notices->add(
10189
+ $this->get_text( 'unexpected-api-error' ) . ' ' . var_export( $plan, true ),
10190
+ $this->get_text( 'oops' ) . '...',
10191
+ 'error'
10192
+ );
10193
+
10194
+ return false;
10195
+ }
10196
+
10197
+ // Sync license.
10198
+ $this->_sync_license();
10199
+
10200
+ return $this->is_trial();
10201
+ }
10202
+
10203
+ /**
10204
+ * Cancel site trial.
10205
+ *
10206
+ * @author Vova Feldman (@svovaf)
10207
+ * @since 1.0.9
10208
+ *
10209
+ * @uses FS_Api
10210
+ */
10211
+ private function _cancel_trial() {
10212
+ $this->_logger->entrance();
10213
+
10214
+ if ( ! $this->is_trial() ) {
10215
+ $this->_admin_notices->add(
10216
+ $this->get_text( 'trial-cancel-no-trial-message' ),
10217
+ $this->get_text( 'oops' ) . '...',
10218
+ 'error'
10219
+ );
10220
+
10221
+ return;
10222
+ }
10223
+
10224
+ $api = $this->get_api_site_scope();
10225
+ $site = $api->call( 'trials.json', 'delete' );
10226
+
10227
+ $trial_cancelled = false;
10228
+
10229
+ if ( $this->is_api_result_entity( $site ) ) {
10230
+ $prev_trial_ends = $this->_site->trial_ends;
10231
+
10232
+ if ( $this->is_paid_trial() ) {
10233
+ $this->_license->expiration = $site->trial_ends;
10234
+ $this->_license->is_cancelled = true;
10235
+ $this->_update_site_license( $this->_license );
10236
+ $this->_store_licenses();
10237
+
10238
+ // Clear subscription reference.
10239
+ $this->_sync_site_subscription( null );
10240
+ }
10241
+
10242
+ // Update site info.
10243
+ $this->_site = new FS_Site( $site );
10244
+ $this->_enrich_site_plan();
10245
+
10246
+ $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
10247
+ } else {
10248
+ // handle different error cases.
10249
+
10250
+ }
10251
+
10252
+ if ( $trial_cancelled ) {
10253
+ // Remove previous sticky messages about upgrade or trial (if exist).
10254
+ $this->_admin_notices->remove_sticky( array(
10255
+ 'trial_started',
10256
+ 'trial_promotion',
10257
+ 'plan_upgraded',
10258
+ ) );
10259
+
10260
+ // Store site updates.
10261
+ $this->_store_site();
10262
+
10263
+ if ( ! $this->is_addon() ||
10264
+ ! $this->deactivate_premium_only_addon_without_license( true )
10265
+ ) {
10266
+ $this->_admin_notices->add(
10267
+ sprintf( $this->get_text( 'trial-cancel-message' ), $this->_storage->trial_plan->title )
10268
+ );
10269
+ }
10270
+
10271
+ // Clear trial plan information.
10272
+ unset( $this->_storage->trial_plan );
10273
+ } else {
10274
+ $this->_admin_notices->add(
10275
+ $this->get_text( 'trial-cancel-failure-message' ),
10276
+ $this->get_text( 'oops' ) . '...',
10277
+ 'error'
10278
+ );
10279
+ }
10280
+ }
10281
+
10282
+ /**
10283
+ * @author Vova Feldman (@svovaf)
10284
+ * @since 1.0.6
10285
+ *
10286
+ * @param bool|number $plugin_id
10287
+ *
10288
+ * @return bool
10289
+ */
10290
+ private function _is_addon_id( $plugin_id ) {
10291
+ return is_numeric( $plugin_id ) && ( $this->get_id() != $plugin_id );
10292
+ }
10293
+
10294
+ /**
10295
+ * Check if user eligible to download premium version updates.
10296
+ *
10297
+ * @author Vova Feldman (@svovaf)
10298
+ * @since 1.0.6
10299
+ *
10300
+ * @return bool
10301
+ */
10302
+ private function _can_download_premium() {
10303
+ return $this->has_active_valid_license() ||
10304
+ ( $this->is_trial() && ! $this->get_trial_plan()->is_free() );
10305
+ }
10306
+
10307
+ /**
10308
+ *
10309
+ * @author Vova Feldman (@svovaf)
10310
+ * @since 1.0.6
10311
+ *
10312
+ * @param bool|number $addon_id
10313
+ * @param string $type "json" or "zip"
10314
+ *
10315
+ * @return string
10316
+ */
10317
+ private function _get_latest_version_endpoint( $addon_id = false, $type = 'json' ) {
10318
+
10319
+ $is_addon = $this->_is_addon_id( $addon_id );
10320
+
10321
+ $is_premium = null;
10322
+ if ( ! $is_addon ) {
10323
+ $is_premium = $this->_can_download_premium();
10324
+ } else if ( $this->is_addon_activated( $addon_id ) ) {
10325
+ $is_premium = self::get_instance_by_id( $addon_id )->_can_download_premium();
10326
+ }
10327
+
10328
+ // If add-on, then append add-on ID.
10329
+ $endpoint = ( $is_addon ? "/addons/$addon_id" : '' ) .
10330
+ '/updates/latest.' . $type;
10331
+
10332
+ // If add-on and not yet activated, try to fetch based on server licensing.
10333
+ if ( is_bool( $is_premium ) ) {
10334
+ $endpoint = add_query_arg( 'is_premium', json_encode( $is_premium ), $endpoint );
10335
+ }
10336
+
10337
+ if ( $this->has_secret_key() ) {
10338
+ $endpoint = add_query_arg( 'type', 'all', $endpoint );
10339
+ }
10340
+
10341
+ return $endpoint;
10342
+ }
10343
+
10344
+ /**
10345
+ * @author Vova Feldman (@svovaf)
10346
+ * @since 1.0.4
10347
+ *
10348
+ * @param bool|number $addon_id
10349
+ * @param bool $flush Since 1.1.7.3
10350
+ *
10351
+ * @return object|false Plugin latest tag info.
10352
+ */
10353
+ function _fetch_latest_version( $addon_id = false, $flush = true ) {
10354
+ $this->_logger->entrance();
10355
+
10356
+ /**
10357
+ * @since 1.1.7.3 Check for plugin updates from Freemius only if opted-in.
10358
+ * @since 1.1.7.4 Also check updates for add-ons.
10359
+ */
10360
+ if ( ! $this->is_registered() &&
10361
+ ! $this->_is_addon_id( $addon_id )
10362
+ ) {
10363
+ return false;
10364
+ }
10365
+
10366
+ $tag = $this->get_api_site_or_plugin_scope()->get(
10367
+ $this->_get_latest_version_endpoint( $addon_id, 'json' ),
10368
+ $flush
10369
+ );
10370
+
10371
+ $latest_version = ( is_object( $tag ) && isset( $tag->version ) ) ? $tag->version : 'couldn\'t get';
10372
+
10373
+ $this->_logger->departure( 'Latest version ' . $latest_version );
10374
+
10375
+ return ( is_object( $tag ) && isset( $tag->version ) ) ? $tag : false;
10376
+ }
10377
+
10378
+ #----------------------------------------------------------------------------------
10379
+ #region Download Plugin
10380
+ #----------------------------------------------------------------------------------
10381
+
10382
+ /**
10383
+ * Download latest plugin version, based on plan.
10384
+ *
10385
+ * Not like _download_latest(), this will redirect the page
10386
+ * to secure download url to prevent dual download (from FS to WP server,
10387
+ * and then from WP server to the client / browser).
10388
+ *
10389
+ * @author Vova Feldman (@svovaf)
10390
+ * @since 1.0.9
10391
+ *
10392
+ * @param bool|number $plugin_id
10393
+ *
10394
+ * @uses FS_Api
10395
+ * @uses wp_redirect()
10396
+ */
10397
+ private function download_latest_directly( $plugin_id = false ) {
10398
+ $this->_logger->entrance();
10399
+
10400
+ wp_redirect( $this->get_latest_download_api_url( $plugin_id ) );
10401
+ }
10402
+
10403
+ /**
10404
+ * Get latest plugin FS API download URL.
10405
+ *
10406
+ * @author Vova Feldman (@svovaf)
10407
+ * @since 1.0.9
10408
+ *
10409
+ * @param bool|number $plugin_id
10410
+ *
10411
+ * @return string
10412
+ */
10413
+ private function get_latest_download_api_url( $plugin_id = false ) {
10414
+ $this->_logger->entrance();
10415
+
10416
+ return $this->get_api_site_scope()->get_signed_url(
10417
+ $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
10418
+ );
10419
+ }
10420
+
10421
+ /**
10422
+ * Get payment invoice URL.
10423
+ *
10424
+ * @author Vova Feldman (@svovaf)
10425
+ * @since 1.2.0
10426
+ *
10427
+ * @param bool|number $payment_id
10428
+ *
10429
+ * @return string
10430
+ */
10431
+ function _get_invoice_api_url( $payment_id = false ) {
10432
+ $this->_logger->entrance();
10433
+
10434
+ return $this->get_api_user_scope()->get_signed_url(
10435
+ "/payments/{$payment_id}/invoice.pdf"
10436
+ );
10437
+ }
10438
+
10439
+ /**
10440
+ * Get latest plugin download link.
10441
+ *
10442
+ * @author Vova Feldman (@svovaf)
10443
+ * @since 1.0.9
10444
+ *
10445
+ * @param string $label
10446
+ * @param bool|number $plugin_id
10447
+ *
10448
+ * @return string
10449
+ */
10450
+ private function get_latest_download_link( $label, $plugin_id = false ) {
10451
+ return sprintf(
10452
+ '<a target="_blank" href="%s">%s</a>',
10453
+ $this->_get_latest_download_local_url( $plugin_id ),
10454
+ $label
10455
+ );
10456
+ }
10457
+
10458
+ /**
10459
+ * Get latest plugin download local URL.
10460
+ *
10461
+ * @author Vova Feldman (@svovaf)
10462
+ * @since 1.0.9
10463
+ *
10464
+ * @param bool|number $plugin_id
10465
+ *
10466
+ * @return string
10467
+ */
10468
+ function _get_latest_download_local_url( $plugin_id = false ) {
10469
+ // Add timestamp to protect from caching.
10470
+ $params = array( 'ts' => WP_FS__SCRIPT_START_TIME );
10471
+
10472
+ if ( ! empty( $plugin_id ) ) {
10473
+ $params['plugin_id'] = $plugin_id;
10474
+ }
10475
+
10476
+ return $this->get_account_url( 'download_latest', $params );
10477
+ }
10478
+
10479
+ #endregion Download Plugin ------------------------------------------------------------------
10480
+
10481
+ /**
10482
+ * @author Vova Feldman (@svovaf)
10483
+ * @since 1.0.4
10484
+ *
10485
+ * @uses FS_Api
10486
+ *
10487
+ * @param bool $background Hints the method if it's a background updates check. If false, it means that
10488
+ * was initiated by the admin.
10489
+ * @param bool|number $plugin_id
10490
+ * @param bool $flush Since 1.1.7.3
10491
+ */
10492
+ private function check_updates( $background = false, $plugin_id = false, $flush = true ) {
10493
+ $this->_logger->entrance();
10494
+
10495
+ // Check if there's a newer version for download.
10496
+ $new_version = $this->_fetch_newer_version( $plugin_id, $flush );
10497
+
10498
+ $update = null;
10499
+ if ( is_object( $new_version ) ) {
10500
+ $update = new FS_Plugin_Tag( $new_version );
10501
+
10502
+ if ( ! $background ) {
10503
+ $this->_admin_notices->add(
10504
+ sprintf(
10505
+ $this->get_text( 'version-x-released' ) . ' ' . $this->get_text( 'please-download-x' ),
10506
+ $update->version,
10507
+ sprintf(
10508
+ '<a href="%s" target="_blank">%s</a>',
10509
+ $this->get_account_url( 'download_latest' ),
10510
+ sprintf( $this->get_text( 'latest-x-version' ), $this->_site->plan->title )
10511
+ )
10512
+ ),
10513
+ $this->get_text( 'new' ) . '!'
10514
+ );
10515
+ }
10516
+ } else if ( false === $new_version && ! $background ) {
10517
+ $this->_admin_notices->add(
10518
+ $this->get_text( 'you-have-latest' ),
10519
+ $this->get_text( 'you-are-good' )
10520
+ );
10521
+ }
10522
+
10523
+ $this->_store_update( $update, true, $plugin_id );
10524
+ }
10525
+
10526
+ /**
10527
+ * @author Vova Feldman (@svovaf)
10528
+ * @since 1.0.4
10529
+ *
10530
+ * @param bool $flush Since 1.1.7.3 add 24 hour cache by default.
10531
+ *
10532
+ * @return FS_Plugin[]
10533
+ *
10534
+ * @uses FS_Api
10535
+ */
10536
+ private function sync_addons( $flush = false ) {
10537
+ $this->_logger->entrance();
10538
+
10539
+ $api = $this->get_api_site_or_plugin_scope();
10540
+
10541
+ /**
10542
+ * @since 1.2.1
10543
+ *
10544
+ * If there's a cached version of the add-ons and not asking
10545
+ * for a flush, just use the currently stored add-ons.
10546
+ */
10547
+ if ( ! $flush && $api->is_cached( '/addons.json?enriched=true' ) ) {
10548
+ $addons = self::get_all_addons();
10549
+
10550
+ return $addons[ $this->_plugin->id ];
10551
+ }
10552
+
10553
+ $result = $api->get( '/addons.json?enriched=true', $flush );
10554
+
10555
+ $addons = array();
10556
+ if ( $this->is_api_result_object( $result, 'plugins' ) &&
10557
+ is_array( $result->plugins )
10558
+ ) {
10559
+ for ( $i = 0, $len = count( $result->plugins ); $i < $len; $i ++ ) {
10560
+ $addons[ $i ] = new FS_Plugin( $result->plugins[ $i ] );
10561
+ }
10562
+
10563
+ $this->_store_addons( $addons, true );
10564
+ }
10565
+
10566
+ return $addons;
10567
+ }
10568
+
10569
+ /**
10570
+ * Handle user email update.
10571
+ *
10572
+ * @author Vova Feldman (@svovaf)
10573
+ * @since 1.0.3
10574
+ * @uses FS_Api
10575
+ *
10576
+ * @param string $new_email
10577
+ *
10578
+ * @return object
10579
+ */
10580
+ private function update_email( $new_email ) {
10581
+ $this->_logger->entrance();
10582
+
10583
+
10584
+ $api = $this->get_api_user_scope();
10585
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array(
10586
+ 'email' => $new_email,
10587
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
10588
+ 'account',
10589
+ array( 'fs_action' => 'sync_user' )
10590
+ ),
10591
+ ) );
10592
+
10593
+ if ( ! isset( $user->error ) ) {
10594
+ $this->_user->email = $user->email;
10595
+ $this->_user->is_verified = $user->is_verified;
10596
+ $this->_store_user();
10597
+ } else {
10598
+ // handle different error cases.
10599
+
10600
+ }
10601
+
10602
+ return $user;
10603
+ }
10604
+
10605
+ #----------------------------------------------------------------------------------
10606
+ #region API Error Handling
10607
+ #----------------------------------------------------------------------------------
10608
+
10609
+ /**
10610
+ * @author Vova Feldman (@svovaf)
10611
+ * @since 1.1.1
10612
+ *
10613
+ * @param mixed $result
10614
+ *
10615
+ * @return bool Is API result contains an error.
10616
+ */
10617
+ private function is_api_error( $result ) {
10618
+ return FS_Api::is_api_error( $result );
10619
+ }
10620
+
10621
+ /**
10622
+ * Checks if given API result is a non-empty and not an error object.
10623
+ *
10624
+ * @author Vova Feldman (@svovaf)
10625
+ * @since 1.2.1.5
10626
+ *
10627
+ * @param mixed $result
10628
+ * @param string|null $required_property Optional property we want to verify that is set.
10629
+ *
10630
+ * @return bool
10631
+ */
10632
+ function is_api_result_object( $result, $required_property = null ) {
10633
+ return FS_Api::is_api_result_object( $result, $required_property );
10634
+ }
10635
+
10636
+ /**
10637
+ * Checks if given API result is a non-empty entity object with non-empty ID.
10638
+ *
10639
+ * @author Vova Feldman (@svovaf)
10640
+ * @since 1.2.1.5
10641
+ *
10642
+ * @param mixed $result
10643
+ *
10644
+ * @return bool
10645
+ */
10646
+ private function is_api_result_entity( $result ) {
10647
+ return FS_Api::is_api_result_entity( $result );
10648
+ }
10649
+
10650
+ #endregion
10651
+
10652
+ /**
10653
+ * Make sure a given argument is an array of a specific type.
10654
+ *
10655
+ * @author Vova Feldman (@svovaf)
10656
+ * @since 1.2.1.5
10657
+ *
10658
+ * @param mixed $array
10659
+ * @param string $class
10660
+ *
10661
+ * @return bool
10662
+ */
10663
+ private function is_array_instanceof( $array, $class ) {
10664
+ return ( is_array( $array ) && ( empty( $array ) || $array[0] instanceof $class ) );
10665
+ }
10666
+
10667
+ /**
10668
+ * Start install ownership change.
10669
+ *
10670
+ * @author Vova Feldman (@svovaf)
10671
+ * @since 1.1.1
10672
+ * @uses FS_Api
10673
+ *
10674
+ * @param string $candidate_email
10675
+ *
10676
+ * @return bool Is ownership change successfully initiated.
10677
+ */
10678
+ private function init_change_owner( $candidate_email ) {
10679
+ $this->_logger->entrance();
10680
+
10681
+ $api = $this->get_api_site_scope();
10682
+ $result = $api->call( "/users/{$this->_user->id}.json", 'put', array(
10683
+ 'email' => $candidate_email,
10684
+ 'after_confirm_url' => $this->_get_admin_page_url(
10685
+ 'account',
10686
+ array( 'fs_action' => 'change_owner' )
10687
+ ),
10688
+ ) );
10689
+
10690
+ return ! $this->is_api_error( $result );
10691
+ }
10692
+
10693
+ /**
10694
+ * Handle install ownership change.
10695
+ *
10696
+ * @author Vova Feldman (@svovaf)
10697
+ * @since 1.1.1
10698
+ * @uses FS_Api
10699
+ *
10700
+ * @return bool Was ownership change successfully complete.
10701
+ */
10702
+ private function complete_change_owner() {
10703
+ $this->_logger->entrance();
10704
+
10705
+ $site_result = $this->get_api_site_scope( true )->get();
10706
+ $site = new FS_Site( $site_result );
10707
+ $this->_site = $site;
10708
+
10709
+ $user = new FS_User();
10710
+ $user->id = fs_request_get( 'user_id' );
10711
+
10712
+ // Validate install's user and given user.
10713
+ if ( $user->id != $this->_site->user_id ) {
10714
+ return false;
10715
+ }
10716
+
10717
+ $user->public_key = fs_request_get( 'user_public_key' );
10718
+ $user->secret_key = fs_request_get( 'user_secret_key' );
10719
+
10720
+ // Fetch new user information.
10721
+ $this->_user = $user;
10722
+ $user_result = $this->get_api_user_scope( true )->get();
10723
+ $user = new FS_User( $user_result );
10724
+ $this->_user = $user;
10725
+
10726
+ $this->_set_account( $user, $site );
10727
+
10728
+ return true;
10729
+ }
10730
+
10731
+ /**
10732
+ * Handle user name update.
10733
+ *
10734
+ * @author Vova Feldman (@svovaf)
10735
+ * @since 1.0.9
10736
+ * @uses FS_Api
10737
+ *
10738
+ * @return object
10739
+ */
10740
+ private function update_user_name() {
10741
+ $this->_logger->entrance();
10742
+ $name = fs_request_get( 'fs_user_name_' . $this->_slug, '' );
10743
+
10744
+ $api = $this->get_api_user_scope();
10745
+ $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
10746
+ 'name' => $name,
10747
+ ) );
10748
+
10749
+ if ( ! isset( $user->error ) ) {
10750
+ $this->_user->first = $user->first;
10751
+ $this->_user->last = $user->last;
10752
+ $this->_store_user();
10753
+ } else {
10754
+ // handle different error cases.
10755
+
10756
+ }
10757
+
10758
+ return $user;
10759
+ }
10760
+
10761
+ /**
10762
+ * Verify user email.
10763
+ *
10764
+ * @author Vova Feldman (@svovaf)
10765
+ * @since 1.0.3
10766
+ * @uses FS_Api
10767
+ */
10768
+ private function verify_email() {
10769
+ $this->_handle_account_user_sync();
10770
+
10771
+ if ( $this->_user->is_verified() ) {
10772
+ return;
10773
+ }
10774
+
10775
+ $api = $this->get_api_site_scope();
10776
+ $result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
10777
+ 'after_email_confirm_url' => $this->_get_admin_page_url(
10778
+ 'account',
10779
+ array( 'fs_action' => 'sync_user' )
10780
+ )
10781
+ ) );
10782
+
10783
+ if ( ! isset( $result->error ) ) {
10784
+ $this->_admin_notices->add( sprintf(
10785
+ $this->get_text( 'verification-email-sent-message' ),
10786
+ sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
10787
+ ) );
10788
+ } else {
10789
+ // handle different error cases.
10790
+
10791
+ }
10792
+ }
10793
+
10794
+ /**
10795
+ * @author Vova Feldman (@svovaf)
10796
+ * @since 1.1.2
10797
+ *
10798
+ * @param array $params
10799
+ *
10800
+ * @return string
10801
+ */
10802
+ private function get_activation_url( $params = array() ) {
10803
+ if ( $this->is_addon() ) {
10804
+ /**
10805
+ * @author Vova Feldman (@svovaf)
10806
+ * @since 1.2.1.7 Add-on's activation is the parent's module activation.
10807
+ */
10808
+ return $this->get_parent_instance()->get_activation_url( $params );
10809
+ }
10810
+
10811
+ return $this->apply_filters( 'connect_url', $this->_get_admin_page_url( '', $params ) );
10812
+ }
10813
+
10814
+ /**
10815
+ * @author Vova Feldman (@svovaf)
10816
+ * @since 1.2.1.5
10817
+ *
10818
+ * @param array $params
10819
+ *
10820
+ * @return string
10821
+ */
10822
+ function get_reconnect_url( $params = array() ) {
10823
+ $params['fs_action'] = 'reset_anonymous_mode';
10824
+ $params['fs_slug'] = $this->_slug;
10825
+
10826
+ return $this->apply_filters( 'connect_url', $this->_get_admin_page_url( '', $params ) );
10827
+ }
10828
+
10829
+ /**
10830
+ * Get the URL of the page that should be loaded after the user connect or skip in the opt-in screen.
10831
+ *
10832
+ * @author Vova Feldman (@svovaf)
10833
+ * @since 1.1.3
10834
+ *
10835
+ * @param string $filter Filter name.
10836
+ *
10837
+ * @return string
10838
+ */
10839
+ function get_after_activation_url( $filter ) {
10840
+ $first_time_path = $this->_menu->get_first_time_path();
10841
+
10842
+ return $this->apply_filters(
10843
+ $filter,
10844
+ empty( $first_time_path ) ?
10845
+ $this->_get_admin_page_url() :
10846
+ $first_time_path
10847
+ );
10848
+ }
10849
+
10850
+ /**
10851
+ * Handle account page updates / edits / actions.
10852
+ *
10853
+ * @author Vova Feldman (@svovaf)
10854
+ * @since 1.0.2
10855
+ *
10856
+ */
10857
+ private function _handle_account_edits() {
10858
+ if ( ! $this->is_user_admin() ) {
10859
+ return;
10860
+ }
10861
+
10862
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
10863
+ $action = fs_get_action();
10864
+
10865
+ switch ( $action ) {
10866
+ case 'delete_account':
10867
+ check_admin_referer( $action );
10868
+
10869
+ if ( $plugin_id == $this->get_id() ) {
10870
+ $this->delete_account_event();
10871
+
10872
+ // Clear user and site.
10873
+ $this->_site = null;
10874
+ $this->_user = null;
10875
+
10876
+ fs_redirect( $this->get_activation_url() );
10877
+ } else {
10878
+ if ( $this->is_addon_activated( $plugin_id ) ) {
10879
+ $fs_addon = self::get_instance_by_id( $plugin_id );
10880
+ $fs_addon->delete_account_event();
10881
+
10882
+ fs_redirect( $this->_get_admin_page_url( 'account' ) );
10883
+ }
10884
+ }
10885
+
10886
+ return;
10887
+
10888
+ case 'downgrade_account':
10889
+ check_admin_referer( $action );
10890
+
10891
+ if ( $plugin_id == $this->get_id() ) {
10892
+ $this->_downgrade_site();
10893
+ } else if ( $this->is_addon_activated( $plugin_id ) ) {
10894
+ $fs_addon = self::get_instance_by_id( $plugin_id );
10895
+ $fs_addon->_downgrade_site();
10896
+ }
10897
+
10898
+ return;
10899
+
10900
+ case 'activate_license':
10901
+ check_admin_referer( $action );
10902
+
10903
+ if ( $plugin_id == $this->get_id() ) {
10904
+ $this->_activate_license();
10905
+ } else {
10906
+ if ( $this->is_addon_activated( $plugin_id ) ) {
10907
+ $fs_addon = self::get_instance_by_id( $plugin_id );
10908
+ $fs_addon->_activate_license();
10909
+ }
10910
+ }
10911
+
10912
+ return;
10913
+
10914
+ case 'deactivate_license':
10915
+ check_admin_referer( $action );
10916
+
10917
+ if ( $plugin_id == $this->get_id() ) {
10918
+ $this->_deactivate_license();
10919
+ } else {
10920
+ if ( $this->is_addon_activated( $plugin_id ) ) {
10921
+ $fs_addon = self::get_instance_by_id( $plugin_id );
10922
+ $fs_addon->_deactivate_license();
10923
+ }
10924
+ }
10925
+
10926
+ return;
10927
+
10928
+ case 'check_updates':
10929
+ check_admin_referer( $action );
10930
+ $this->check_updates();
10931
+
10932
+ return;
10933
+
10934
+ case 'change_owner':
10935
+ $state = fs_request_get( 'state', 'init' );
10936
+ switch ( $state ) {
10937
+ case 'init':
10938
+ $candidate_email = fs_request_get( 'candidate_email', '' );
10939
+
10940
+ if ( $this->init_change_owner( $candidate_email ) ) {
10941
+ $this->_admin_notices->add( sprintf( $this->get_text( 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
10942
+ }
10943
+ break;
10944
+ case 'owner_confirmed':
10945
+ $candidate_email = fs_request_get( 'candidate_email', '' );
10946
+
10947
+ $this->_admin_notices->add( sprintf( $this->get_text( 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
10948
+ break;
10949
+ case 'candidate_confirmed':
10950
+ if ( $this->complete_change_owner() ) {
10951
+ $this->_admin_notices->add_sticky(
10952
+ sprintf( $this->get_text( 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
10953
+ 'ownership_changed',
10954
+ $this->get_text( 'congrats' ) . '!'
10955
+ );
10956
+ } else {
10957
+ // @todo Handle failed ownership change message.
10958
+ }
10959
+ break;
10960
+ }
10961
+
10962
+ return;
10963
+
10964
+ case 'update_email':
10965
+ check_admin_referer( 'update_email' );
10966
+
10967
+ $new_email = fs_request_get( 'fs_email_' . $this->_slug, '' );
10968
+ $result = $this->update_email( $new_email );
10969
+
10970
+ if ( isset( $result->error ) ) {
10971
+ switch ( $result->error->code ) {
10972
+ case 'user_exist':
10973
+ $this->_admin_notices->add(
10974
+ $this->get_text( 'user-exist-message' ) . ' ' .
10975
+ sprintf( $this->get_text( 'user-exist-message_ownership' ), '<b>' . $new_email . '</b>' ) .
10976
+ sprintf(
10977
+ '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
10978
+ $this->get_account_url( 'change_owner', array(
10979
+ 'state' => 'init',
10980
+ 'candidate_email' => $new_email
10981
+ ) ),
10982
+ $this->get_text( 'change-ownership' )
10983
+ ),
10984
+ $this->get_text( 'oops' ) . '...',
10985
+ 'error'
10986
+ );
10987
+ break;
10988
+ }
10989
+ } else {
10990
+ $this->_admin_notices->add( $this->get_text( 'email-updated-message' ) );
10991
+ }
10992
+
10993
+ return;
10994
+
10995
+ case 'update_user_name':
10996
+ check_admin_referer( 'update_user_name' );
10997
+
10998
+ $result = $this->update_user_name();
10999
+
11000
+ if ( isset( $result->error ) ) {
11001
+ $this->_admin_notices->add(
11002
+ $this->get_text( 'name-update-failed-message' ),
11003
+ $this->get_text( 'oops' ) . '...',
11004
+ 'error'
11005
+ );
11006
+ } else {
11007
+ $this->_admin_notices->add( $this->get_text( 'name-updated-message' ) );
11008
+ }
11009
+
11010
+ return;
11011
+
11012
+ #region Actions that might be called from external links (e.g. email)
11013
+
11014
+ case 'cancel_trial':
11015
+ if ( $plugin_id == $this->get_id() ) {
11016
+ $this->_cancel_trial();
11017
+ } else {
11018
+ if ( $this->is_addon_activated( $plugin_id ) ) {
11019
+ $fs_addon = self::get_instance_by_id( $plugin_id );
11020
+ $fs_addon->_cancel_trial();
11021
+ }
11022
+ }
11023
+
11024
+ return;
11025
+
11026
+ case 'verify_email':
11027
+ $this->verify_email();
11028
+
11029
+ return;
11030
+
11031
+ case 'sync_user':
11032
+ $this->_handle_account_user_sync();
11033
+
11034
+ return;
11035
+
11036
+ case $this->_slug . '_sync_license':
11037
+ $this->_sync_license();
11038
+
11039
+ return;
11040
+
11041
+ case 'download_latest':
11042
+ $this->download_latest_directly( $plugin_id );
11043
+
11044
+ return;
11045
+
11046
+ #endregion
11047
+ }
11048
+
11049
+ if ( WP_FS__IS_POST_REQUEST ) {
11050
+ $properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
11051
+ foreach ( $properties as $p ) {
11052
+ if ( 'update_' . $p === $action ) {
11053
+ check_admin_referer( $action );
11054
+
11055
+ $this->_logger->log( $action );
11056
+
11057
+ $site_property = substr( $p, strlen( 'site_' ) );
11058
+ $site_property_value = fs_request_get( 'fs_' . $p . '_' . $this->_slug, '' );
11059
+ $this->get_site()->{$site_property} = $site_property_value;
11060
+
11061
+ // Store account after modification.
11062
+ $this->_store_site();
11063
+
11064
+ $this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );
11065
+
11066
+ $this->_admin_notices->add( sprintf(
11067
+ $this->get_text( 'x-updated' ),
11068
+ '<b>' . str_replace( '_', ' ', $p ) . '</b>' ) );
11069
+
11070
+ return;
11071
+ }
11072
+ }
11073
+ }
11074
+ }
11075
+
11076
+ /**
11077
+ * Account page resources load.
11078
+ *
11079
+ * @author Vova Feldman (@svovaf)
11080
+ * @since 1.0.6
11081
+ */
11082
+ function _account_page_load() {
11083
+ $this->_logger->entrance();
11084
+
11085
+ $this->_logger->info( var_export( $_REQUEST, true ) );
11086
+
11087
+ fs_enqueue_local_style( 'fs_account', '/admin/account.css' );
11088
+
11089
+ if ( $this->has_addons() ) {
11090
+ wp_enqueue_script( 'plugin-install' );
11091
+ add_thickbox();
11092
+
11093
+ function fs_addons_body_class( $classes ) {
11094
+ $classes .= ' plugins-php';
11095
+
11096
+ return $classes;
11097
+ }
11098
+
11099
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
11100
+ }
11101
+
11102
+ if ( $this->has_paid_plan() &&
11103
+ ! $this->has_any_license() &&
11104
+ ! $this->is_sync_executed() &&
11105
+ $this->is_tracking_allowed()
11106
+ ) {
11107
+ /**
11108
+ * If no licenses found and no sync job was executed during the last 24 hours,
11109
+ * just execute the sync job right away (blocking execution).
11110
+ *
11111
+ * @since 1.1.7.3
11112
+ */
11113
+ $this->run_manual_sync();
11114
+ }
11115
+
11116
+ $this->_handle_account_edits();
11117
+
11118
+ $this->do_action( 'account_page_load_before_departure' );
11119
+ }
11120
+
11121
+ /**
11122
+ * Render account page.
11123
+ *
11124
+ * @author Vova Feldman (@svovaf)
11125
+ * @since 1.0.0
11126
+ */
11127
+ function _account_page_render() {
11128
+ $this->_logger->entrance();
11129
+
11130
+ $template = 'account.php';
11131
+ if ( 'billing' === fs_request_get( 'tab' ) ) {
11132
+ $template = 'billing.php';
11133
+ }
11134
+
11135
+ $vars = array( 'slug' => $this->_slug );
11136
+
11137
+ /**
11138
+ * Added filter to the template to allow developers wrapping the template
11139
+ * in custom HTML (e.g. within a wizard/tabs).
11140
+ *
11141
+ * @author Vova Feldman (@svovaf)
11142
+ * @since 1.2.1.6
11143
+ */
11144
+ echo $this->apply_filters( "templates/{$template}", fs_get_template( $template, $vars ) );
11145
+ }
11146
+
11147
+ /**
11148
+ * Render account connect page.
11149
+ *
11150
+ * @author Vova Feldman (@svovaf)
11151
+ * @since 1.0.7
11152
+ */
11153
+ function _connect_page_render() {
11154
+ $this->_logger->entrance();
11155
+
11156
+ $vars = array( 'slug' => $this->_slug );
11157
+
11158
+ /**
11159
+ * Added filter to the template to allow developers wrapping the template
11160
+ * in custom HTML (e.g. within a wizard/tabs).
11161
+ *
11162
+ * @author Vova Feldman (@svovaf)
11163
+ * @since 1.2.1.6
11164
+ */
11165
+ echo $this->apply_filters( 'templates/connect.php', fs_get_template( 'connect.php', $vars ) );
11166
+ }
11167
+
11168
+ /**
11169
+ * Load required resources before add-ons page render.
11170
+ *
11171
+ * @author Vova Feldman (@svovaf)
11172
+ * @since 1.0.6
11173
+ */
11174
+ function _addons_page_load() {
11175
+ $this->_logger->entrance();
11176
+
11177
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
11178
+
11179
+ wp_enqueue_script( 'plugin-install' );
11180
+ add_thickbox();
11181
+
11182
+ function fs_addons_body_class( $classes ) {
11183
+ $classes .= ' plugins-php';
11184
+
11185
+ return $classes;
11186
+ }
11187
+
11188
+ add_filter( 'admin_body_class', 'fs_addons_body_class' );
11189
+
11190
+ if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) {
11191
+ $this->_admin_notices->add(
11192
+ sprintf( $this->get_text( 'addons-info-external-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
11193
+ $this->get_text( 'heads-up' ),
11194
+ 'update-nag'
11195
+ );
11196
+ }
11197
+ }
11198
+
11199
+ /**
11200
+ * Render add-ons page.
11201
+ *
11202
+ * @author Vova Feldman (@svovaf)
11203
+ * @since 1.0.6
11204
+ */
11205
+ function _addons_page_render() {
11206
+ $this->_logger->entrance();
11207
+
11208
+ $vars = array( 'slug' => $this->_slug );
11209
+
11210
+ /**
11211
+ * Added filter to the template to allow developers wrapping the template
11212
+ * in custom HTML (e.g. within a wizard/tabs).
11213
+ *
11214
+ * @author Vova Feldman (@svovaf)
11215
+ * @since 1.2.1.6
11216
+ */
11217
+ echo $this->apply_filters( 'templates/add-ons.php', fs_get_template( 'add-ons.php', $vars ) );
11218
+ }
11219
+
11220
+ /* Pricing & Upgrade
11221
+ ------------------------------------------------------------------------------------------------------------------*/
11222
+ /**
11223
+ * Render pricing page.
11224
+ *
11225
+ * @author Vova Feldman (@svovaf)
11226
+ * @since 1.0.0
11227
+ */
11228
+ function _pricing_page_render() {
11229
+ $this->_logger->entrance();
11230
+
11231
+ $vars = array( 'slug' => $this->_slug );
11232
+
11233
+ if ( 'true' === fs_request_get( 'checkout', false ) ) {
11234
+ fs_require_once_template( 'checkout.php', $vars );
11235
+ } else {
11236
+ fs_require_once_template( 'pricing.php', $vars );
11237
+ }
11238
+ }
11239
+
11240
+ #----------------------------------------------------------------------------------
11241
+ #region Contact Us
11242
+ #----------------------------------------------------------------------------------
11243
+
11244
+ /**
11245
+ * Render contact-us page.
11246
+ *
11247
+ * @author Vova Feldman (@svovaf)
11248
+ * @since 1.0.3
11249
+ */
11250
+ function _contact_page_render() {
11251
+ $this->_logger->entrance();
11252
+
11253
+ $vars = array( 'slug' => $this->_slug );
11254
+ fs_require_once_template( 'contact.php', $vars );
11255
+ }
11256
+
11257
+ #endregion ------------------------------------------------------------------------
11258
+
11259
+ /**
11260
+ * Hide all admin notices to prevent distractions.
11261
+ *
11262
+ * @author Vova Feldman (@svovaf)
11263
+ * @since 1.0.3
11264
+ *
11265
+ * @uses remove_all_actions()
11266
+ */
11267
+ private static function _hide_admin_notices() {
11268
+ remove_all_actions( 'admin_notices' );
11269
+ remove_all_actions( 'network_admin_notices' );
11270
+ remove_all_actions( 'all_admin_notices' );
11271
+ remove_all_actions( 'user_admin_notices' );
11272
+ }
11273
+
11274
+ static function _clean_admin_content_section_hook() {
11275
+ self::_hide_admin_notices();
11276
+
11277
+ // Hide footer.
11278
+ echo '<style>#wpfooter { display: none !important; }</style>';
11279
+ }
11280
+
11281
+ /**
11282
+ * Attach to admin_head hook to hide all admin notices.
11283
+ *
11284
+ * @author Vova Feldman (@svovaf)
11285
+ * @since 1.0.3
11286
+ */
11287
+ static function _clean_admin_content_section() {
11288
+ add_action( 'admin_head', 'Freemius::_clean_admin_content_section_hook' );
11289
+ }
11290
+
11291
+ /* CSS & JavaScript
11292
+ ------------------------------------------------------------------------------------------------------------------*/
11293
+ /* function _enqueue_script($handle, $src) {
11294
+ $url = plugins_url( substr( WP_FS__DIR_JS, strlen( $this->_plugin_dir_path ) ) . '/assets/js/' . $src );
11295
+
11296
+ $this->_logger->entrance( 'script = ' . $url );
11297
+
11298
+ wp_enqueue_script( $handle, $url );
11299
+ }*/
11300
+
11301
+ /* SDK
11302
+ ------------------------------------------------------------------------------------------------------------------*/
11303
+ private $_user_api;
11304
+
11305
+ /**
11306
+ *
11307
+ * @author Vova Feldman (@svovaf)
11308
+ * @since 1.0.2
11309
+ *
11310
+ * @param bool $flush
11311
+ *
11312
+ * @return FS_Api
11313
+ */
11314
+ function get_api_user_scope( $flush = false ) {
11315
+ if ( ! isset( $this->_user_api ) || $flush ) {
11316
+ $this->_user_api = FS_Api::instance(
11317
+ $this->_slug,
11318
+ 'user',
11319
+ $this->_user->id,
11320
+ $this->_user->public_key,
11321
+ ! $this->is_live(),
11322
+ $this->_user->secret_key
11323
+ );
11324
+ }
11325
+
11326
+ return $this->_user_api;
11327
+ }
11328
+
11329
+ private $_site_api;
11330
+
11331
+ /**
11332
+ *
11333
+ * @author Vova Feldman (@svovaf)
11334
+ * @since 1.0.2
11335
+ *
11336
+ * @param bool $flush
11337
+ *
11338
+ * @return FS_Api
11339
+ */
11340
+ function get_api_site_scope( $flush = false ) {
11341
+ if ( ! isset( $this->_site_api ) || $flush ) {
11342
+ $this->_site_api = FS_Api::instance(
11343
+ $this->_slug,
11344
+ 'install',
11345
+ $this->_site->id,
11346
+ $this->_site->public_key,
11347
+ ! $this->is_live(),
11348
+ $this->_site->secret_key
11349
+ );
11350
+ }
11351
+
11352
+ return $this->_site_api;
11353
+ }
11354
+
11355
+ private $_plugin_api;
11356
+
11357
+ /**
11358
+ * Get plugin public API scope.
11359
+ *
11360
+ * @author Vova Feldman (@svovaf)
11361
+ * @since 1.0.7
11362
+ *
11363
+ * @return FS_Api
11364
+ */
11365
+ function get_api_plugin_scope() {
11366
+ if ( ! isset( $this->_plugin_api ) ) {
11367
+ $this->_plugin_api = FS_Api::instance(
11368
+ $this->_slug,
11369
+ 'plugin',
11370
+ $this->_plugin->id,
11371
+ $this->_plugin->public_key,
11372
+ ! $this->is_live()
11373
+ );
11374
+ }
11375
+
11376
+ return $this->_plugin_api;
11377
+ }
11378
+
11379
+ /**
11380
+ * Get site API scope object (fallback to public plugin scope when not registered).
11381
+ *
11382
+ * @author Vova Feldman (@svovaf)
11383
+ * @since 1.0.7
11384
+ *
11385
+ * @return FS_Api
11386
+ */
11387
+ function get_api_site_or_plugin_scope() {
11388
+ return $this->is_registered() ?
11389
+ $this->get_api_site_scope() :
11390
+ $this->get_api_plugin_scope();
11391
+ }
11392
+
11393
+ /**
11394
+ * Show trial promotional notice (if any trial exist).
11395
+ *
11396
+ * @author Vova Feldman (@svovaf)
11397
+ * @since 1.0.9
11398
+ *
11399
+ * @param $plans
11400
+ */
11401
+ function _check_for_trial_plans( $plans ) {
11402
+ $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
11403
+ }
11404
+
11405
+ /**
11406
+ * During trial promotion the "upgrade" submenu item turns to
11407
+ * "start trial" to encourage the trial. Since we want to keep
11408
+ * the same menu item handler and there's no robust way to
11409
+ * add new arguments to the menu item link's querystring,
11410
+ * use JavaScript to find the menu item and update the href of
11411
+ * the link.
11412
+ *
11413
+ * @author Vova Feldman (@svovaf)
11414
+ * @since 1.2.1.5
11415
+ */
11416
+ function _fix_start_trial_menu_item_url() {
11417
+ $template_args = array( 'slug' => $this->_slug );
11418
+ fs_require_template( 'add-trial-to-pricing.php', $template_args );
11419
+ }
11420
+
11421
+ /**
11422
+ * Show trial promotional notice (if any trial exist).
11423
+ *
11424
+ * @author Vova Feldman (@svovaf)
11425
+ * @since 1.0.9
11426
+ *
11427
+ * @return bool If trial notice added.
11428
+ */
11429
+ function _add_trial_notice() {
11430
+ if ( ! $this->is_user_admin() ) {
11431
+ return false;
11432
+ }
11433
+
11434
+ if ( ! $this->is_user_in_admin() ) {
11435
+ return false;
11436
+ }
11437
+
11438
+ // Check if trial message is already shown.
11439
+ if ( $this->_admin_notices->has_sticky( 'trial_promotion' ) ) {
11440
+ add_action( 'admin_footer', array( &$this, '_fix_start_trial_menu_item_url' ) );
11441
+
11442
+ $this->_menu->add_counter_to_menu_item( 1, 'fs-trial' );
11443
+
11444
+ return false;
11445
+ }
11446
+
11447
+ if ( $this->is_premium() && ! WP_FS__DEV_MODE ) {
11448
+ // Don't show trial if running the premium code, unless running in DEV mode.
11449
+ return false;
11450
+ }
11451
+
11452
+ if ( ! $this->has_trial_plan() ) {
11453
+ // No plans with trial.
11454
+ return false;
11455
+ }
11456
+
11457
+ if ( ! $this->apply_filters( 'show_trial', true ) ) {
11458
+ // Developer explicitly asked not to show the trial promo.
11459
+ return false;
11460
+ }
11461
+
11462
+ if ( $this->is_registered() ) {
11463
+ // Check if trial already utilized.
11464
+ if ( $this->_site->is_trial_utilized() ) {
11465
+ return false;
11466
+ }
11467
+
11468
+ if ( $this->is_paying_or_trial() ) {
11469
+ // Don't show trial if paying or already in trial.
11470
+ return false;
11471
+ }
11472
+ }
11473
+
11474
+ if ( $this->is_activation_mode() || $this->is_pending_activation() ) {
11475
+ // If not yet opted-in/skipped, or pending activation, don't show trial.
11476
+ return false;
11477
+ }
11478
+
11479
+ $last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
11480
+ $was_promotion_shown_before = ( false !== $last_time_trial_promotion_shown );
11481
+
11482
+ // Show promotion if never shown before and 24 hours after initial activation with FS.
11483
+ if ( ! $was_promotion_shown_before &&
11484
+ $this->_storage->install_timestamp > ( time() - WP_FS__TIME_24_HOURS_IN_SEC )
11485
+ ) {
11486
+ return false;
11487
+ }
11488
+
11489
+ // OR if promotion was shown before, try showing it every 30 days.
11490
+ if ( $was_promotion_shown_before &&
11491
+ 30 * WP_FS__TIME_24_HOURS_IN_SEC > time() - $last_time_trial_promotion_shown
11492
+ ) {
11493
+ return false;
11494
+ }
11495
+
11496
+ $trial_period = $this->_trial_days;
11497
+ $require_payment = $this->_is_trial_require_payment;
11498
+ $trial_url = $this->get_trial_url();
11499
+ $plans_string = strtolower( $this->get_text( 'awesome' ) );
11500
+
11501
+ if ( $this->is_registered() ) {
11502
+ // If opted-in, override trial with up to date data from API.
11503
+ $trial_plans = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
11504
+ $trial_plans_count = count( $trial_plans );
11505
+
11506
+ if ( 0 === $trial_plans_count ) {
11507
+ // If there's no plans with a trial just exit.
11508
+ return false;
11509
+ }
11510
+
11511
+ /**
11512
+ * @var FS_Plugin_Plan $paid_plan
11513
+ */
11514
+ $paid_plan = $trial_plans[0];
11515
+ $require_payment = $paid_plan->is_require_subscription;
11516
+ $trial_period = $paid_plan->trial_period;
11517
+
11518
+ $total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );
11519
+
11520
+ if ( $total_paid_plans !== $trial_plans_count ) {
11521
+ // Not all paid plans have a trial - generate a string of those that have it.
11522
+ for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
11523
+ $plans_string .= sprintf(
11524
+ '<a href="%s">%s</a>',
11525
+ $trial_url,
11526
+ $trial_plans[ $i ]->title
11527
+ );
11528
+
11529
+ if ( $i < $trial_plans_count - 2 ) {
11530
+ $plans_string .= ', ';
11531
+ } else if ( $i == $trial_plans_count - 2 ) {
11532
+ $plans_string .= ' and ';
11533
+ }
11534
+ }
11535
+ }
11536
+ }
11537
+
11538
+ $message = sprintf(
11539
+ $this->get_text( 'hey' ) . '! ' . $this->get_text( 'trial-x-promotion-message' ),
11540
+ sprintf( '<b>%s</b>', $this->get_plugin_name() ),
11541
+ $plans_string,
11542
+ $trial_period
11543
+ );
11544
+
11545
+ // "No Credit-Card Required" or "No Commitment for N Days".
11546
+ $cc_string = $require_payment ?
11547
+ sprintf( $this->get_text( 'no-commitment-for-x-days' ), $trial_period ) :
11548
+ $this->get_text( 'no-cc-required' ) . '!';
11549
+
11550
+
11551
+ // Start trial button.
11552
+ $button = ' ' . sprintf(
11553
+ '<a style="margin-left: 10px; vertical-align: super;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
11554
+ $trial_url,
11555
+ $this->get_text( 'start-free-trial' )
11556
+ );
11557
+
11558
+ $this->_admin_notices->add_sticky(
11559
+ $this->apply_filters( 'trial_promotion_message', "{$message} {$cc_string} {$button}" ),
11560
+ 'trial_promotion',
11561
+ '',
11562
+ 'promotion'
11563
+ );
11564
+
11565
+ $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;
11566
+
11567
+ return true;
11568
+ }
11569
+
11570
+ /**
11571
+ * @author Vova Feldman (@svovaf)
11572
+ * @since 1.2.1.5
11573
+ */
11574
+ function _enqueue_common_css() {
11575
+ if ( $this->has_paid_plan() && ! $this->is_paying() ) {
11576
+ // Add basic CSS for admin-notices and menu-item colors.
11577
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
11578
+ }
11579
+ }
11580
+
11581
+ /* Action Links
11582
+ ------------------------------------------------------------------------------------------------------------------*/
11583
+ private $_action_links_hooked = false;
11584
+ private $_action_links = array();
11585
+
11586
+ /**
11587
+ * Hook to plugin action links filter.
11588
+ *
11589
+ * @author Vova Feldman (@svovaf)
11590
+ * @since 1.0.0
11591
+ */
11592
+ private function hook_plugin_action_links() {
11593
+ $this->_logger->entrance();
11594
+
11595
+ $this->_action_links_hooked = true;
11596
+
11597
+ $this->_logger->log( 'Adding action links hooks.' );
11598
+
11599
+ // Add action link to settings page.
11600
+ add_filter( 'plugin_action_links_' . $this->_plugin_basename, array(
11601
+ &$this,
11602
+ '_modify_plugin_action_links_hook'
11603
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
11604
+ add_filter( 'network_admin_plugin_action_links_' . $this->_plugin_basename, array(
11605
+ &$this,
11606
+ '_modify_plugin_action_links_hook'
11607
+ ), WP_FS__DEFAULT_PRIORITY, 2 );
11608
+ }
11609
+
11610
+ /**
11611
+ * Add plugin action link.
11612
+ *
11613
+ * @author Vova Feldman (@svovaf)
11614
+ * @since 1.0.0
11615
+ *
11616
+ * @param $label
11617
+ * @param $url
11618
+ * @param bool $external
11619
+ * @param int $priority
11620
+ * @param bool $key
11621
+ */
11622
+ function add_plugin_action_link( $label, $url, $external = false, $priority = WP_FS__DEFAULT_PRIORITY, $key = false ) {
11623
+ $this->_logger->entrance();
11624
+
11625
+ if ( ! isset( $this->_action_links[ $priority ] ) ) {
11626
+ $this->_action_links[ $priority ] = array();
11627
+ }
11628
+
11629
+ if ( false === $key ) {
11630
+ $key = preg_replace( "/[^A-Za-z0-9 ]/", '', strtolower( $label ) );
11631
+ }
11632
+
11633
+ $this->_action_links[ $priority ][] = array(
11634
+ 'label' => $label,
11635
+ 'href' => $url,
11636
+ 'key' => $key,
11637
+ 'external' => $external
11638
+ );
11639
+ }
11640
+
11641
+ /**
11642
+ * Adds Upgrade and Add-Ons links to the main Plugins page link actions collection.
11643
+ *
11644
+ * @author Vova Feldman (@svovaf)
11645
+ * @since 1.0.0
11646
+ */
11647
+ function _add_upgrade_action_link() {
11648
+ $this->_logger->entrance();
11649
+
11650
+ if ( $this->is_registered() ) {
11651
+ if ( ! $this->is_paying() && $this->has_paid_plan() ) {
11652
+ $this->add_plugin_action_link(
11653
+ $this->get_text( 'upgrade' ),
11654
+ $this->get_upgrade_url(),
11655
+ false,
11656
+ 7,
11657
+ 'upgrade'
11658
+ );
11659
+ }
11660
+
11661
+ if ( $this->has_addons() ) {
11662
+ $this->add_plugin_action_link(
11663
+ $this->get_text( 'add-ons' ),
11664
+ $this->_get_admin_page_url( 'addons' ),
11665
+ false,
11666
+ 9,
11667
+ 'addons'
11668
+ );
11669
+ }
11670
+ }
11671
+ }
11672
+
11673
+ /**
11674
+ * Adds "Activate License" or "Change License" link to the main Plugins page link actions collection.
11675
+ *
11676
+ * @author Leo Fajardo (@leorw)
11677
+ * @since 1.1.9
11678
+ */
11679
+ function _add_license_action_link() {
11680
+ $this->_logger->entrance();
11681
+
11682
+ if ( $this->is_free_plan() && $this->is_addon() ) {
11683
+ return;
11684
+ }
11685
+
11686
+ if ( ! self::is_ajax() ) {
11687
+ // Inject license activation dialog UI and client side code.
11688
+ add_action( 'admin_footer', array( &$this, '_add_license_activation_dialog_box' ) );
11689
+ }
11690
+
11691
+ $link_text = $this->get_text(
11692
+ $this->is_free_plan() ?
11693
+ 'activate-license' :
11694
+ 'change-license'
11695
+ );
11696
+
11697
+ $this->add_plugin_action_link(
11698
+ $link_text,
11699
+ '#',
11700
+ false,
11701
+ 11,
11702
+ ( 'activate-license ' . $this->_slug )
11703
+ );
11704
+ }
11705
+
11706
+ /**
11707
+ * Adds "Opt in" or "Opt out" link to the main "Plugins" page link actions collection.
11708
+ *
11709
+ * @author Leo Fajardo (@leorw)
11710
+ * @since 1.2.1.5
11711
+ */
11712
+ function _add_tracking_links() {
11713
+ if ( ! current_user_can( 'activate_plugins' ) ) {
11714
+ return;
11715
+ }
11716
+
11717
+ $this->_logger->entrance();
11718
+
11719
+ if ( ! $this->is_plugins_page() ) {
11720
+ // Only show tracking links on the plugin's page.
11721
+ return;
11722
+ }
11723
+
11724
+ if ( ! $this->is_enable_anonymous() ) {
11725
+ // Don't allow to opt-out if anonymous mode is disabled.
11726
+ return;
11727
+ }
11728
+
11729
+ if ( ! $this->is_free_plan() ) {
11730
+ // Don't allow to opt-out if running in paid plan.
11731
+ return;
11732
+ }
11733
+
11734
+ if ( $this->add_ajax_action( 'stop_tracking', array( &$this, '_stop_tracking_callback' ) ) ) {
11735
+ return;
11736
+ }
11737
+
11738
+ if ( $this->add_ajax_action( 'allow_tracking', array( &$this, '_allow_tracking_callback' ) ) ) {
11739
+ return;
11740
+ }
11741
+
11742
+ if ( fs_request_is_action_secure( $this->_slug . '_reconnect' ) ) {
11743
+ if ( ! $this->is_registered() && $this->is_anonymous() ) {
11744
+ $this->connect_again();
11745
+
11746
+ return;
11747
+ }
11748
+ }
11749
+
11750
+ $url = '#';
11751
+
11752
+ if ( $this->is_registered() ) {
11753
+ if ( $this->is_tracking_allowed() ) {
11754
+ $link_text_id = 'opt-out';
11755
+ } else {
11756
+ $link_text_id = 'opt-in';
11757
+ }
11758
+
11759
+ add_action( 'admin_footer', array( &$this, '_add_optout_dialog' ) );
11760
+ } else {
11761
+ $link_text_id = 'opt-in';
11762
+
11763
+ $params = ! $this->is_anonymous() ?
11764
+ array() :
11765
+ array(
11766
+ 'nonce' => wp_create_nonce( $this->_slug . '_reconnect' ),
11767
+ 'fs_action' => ( $this->_slug . '_reconnect' ),
11768
+ );
11769
+
11770
+ $url = $this->get_activation_url( $params );
11771
+ }
11772
+
11773
+ $this->add_plugin_action_link(
11774
+ $this->get_text( $link_text_id ),
11775
+ $url,
11776
+ false,
11777
+ 13,
11778
+ "opt-in-or-opt-out {$this->_slug}"
11779
+ );
11780
+ }
11781
+
11782
+ /**
11783
+ * Get the URL of the page that should be loaded right after the plugin activation.
11784
+ *
11785
+ * @author Vova Feldman (@svovaf)
11786
+ * @since 1.1.7.4
11787
+ *
11788
+ * @return string
11789
+ */
11790
+ function get_after_plugin_activation_redirect_url() {
11791
+ $url = false;
11792
+ $plugin_fs = false;
11793
+
11794
+ if ( ! $this->is_addon() ) {
11795
+ $first_time_path = $this->_menu->get_first_time_path();
11796
+ $plugin_fs = $this;
11797
+ $url = $plugin_fs->is_activation_mode() ?
11798
+ $plugin_fs->get_activation_url() :
11799
+ ( empty( $first_time_path ) ?
11800
+ $this->_get_admin_page_url() :
11801
+ $first_time_path );
11802
+ } else {
11803
+ if ( $this->is_parent_plugin_installed() ) {
11804
+ $plugin_fs = self::get_parent_instance();
11805
+ }
11806
+
11807
+ if ( is_object( $plugin_fs ) ) {
11808
+ if ( ! $plugin_fs->is_registered() ) {
11809
+ // Forward to parent plugin connect when parent not registered.
11810
+ $url = $plugin_fs->get_activation_url();
11811
+ } else {
11812
+ // Forward to account page.
11813
+ $url = $plugin_fs->_get_admin_page_url( 'account' );
11814
+ }
11815
+ }
11816
+ }
11817
+
11818
+ return $url;
11819
+ }
11820
+
11821
+ /**
11822
+ * Forward page to activation page.
11823
+ *
11824
+ * @author Vova Feldman (@svovaf)
11825
+ * @since 1.0.3
11826
+ */
11827
+ function _redirect_on_activation_hook() {
11828
+ $url = $this->get_after_plugin_activation_redirect_url();
11829
+
11830
+ if ( is_string( $url ) ) {
11831
+ fs_redirect( $url );
11832
+ }
11833
+ }
11834
+
11835
+ /**
11836
+ * Modify plugin's page action links collection.
11837
+ *
11838
+ * @author Vova Feldman (@svovaf)
11839
+ * @since 1.0.0
11840
+ *
11841
+ * @param array $links
11842
+ * @param $file
11843
+ *
11844
+ * @return array
11845
+ */
11846
+ function _modify_plugin_action_links_hook( $links, $file ) {
11847
+ $this->_logger->entrance();
11848
+
11849
+ $passed_deactivate = false;
11850
+ $deactivate_link = '';
11851
+ $before_deactivate = array();
11852
+ $after_deactivate = array();
11853
+ foreach ( $links as $key => $link ) {
11854
+ if ( 'deactivate' === $key ) {
11855
+ $deactivate_link = $link;
11856
+ $passed_deactivate = true;
11857
+ continue;
11858
+ }
11859
+
11860
+ if ( ! $passed_deactivate ) {
11861
+ $before_deactivate[ $key ] = $link;
11862
+ } else {
11863
+ $after_deactivate[ $key ] = $link;
11864
+ }
11865
+ }
11866
+
11867
+ ksort( $this->_action_links );
11868
+
11869
+ foreach ( $this->_action_links as $new_links ) {
11870
+ foreach ( $new_links as $link ) {
11871
+ $before_deactivate[ $link['key'] ] = '<a href="' . $link['href'] . '"' . ( $link['external'] ? ' target="_blank"' : '' ) . '>' . $link['label'] . '</a>';
11872
+ }
11873
+ }
11874
+
11875
+ if ( ! empty( $deactivate_link ) ) {
11876
+ /**
11877
+ * This HTML element is used to identify the correct plugin when attaching an event to its Deactivate link.
11878
+ *
11879
+ * @since 1.2.1.6 Always show the deactivation feedback form since we added automatic free version deactivation upon premium code activation.
11880
+ */
11881
+ $deactivate_link .= '<i class="fs-slug" data-slug="' . $this->_slug . '"></i>';
11882
+
11883
+ // Append deactivation link.
11884
+ $before_deactivate['deactivate'] = $deactivate_link;
11885
+ }
11886
+
11887
+ return array_merge( $before_deactivate, $after_deactivate );
11888
+ }
11889
+
11890
+ /**
11891
+ * Adds admin message.
11892
+ *
11893
+ * @author Vova Feldman (@svovaf)
11894
+ * @since 1.0.4
11895
+ *
11896
+ * @param string $message
11897
+ * @param string $title
11898
+ * @param string $type
11899
+ */
11900
+ function add_admin_message( $message, $title = '', $type = 'success' ) {
11901
+ $this->_admin_notices->add( $message, $title, $type );
11902
+ }
11903
+
11904
+ /**
11905
+ * Adds sticky admin message.
11906
+ *
11907
+ * @author Vova Feldman (@svovaf)
11908
+ * @since 1.1.0
11909
+ *
11910
+ * @param string $message
11911
+ * @param string $id
11912
+ * @param string $title
11913
+ * @param string $type
11914
+ */
11915
+ function add_sticky_admin_message( $message, $id, $title = '', $type = 'success' ) {
11916
+ $this->_admin_notices->add_sticky( $message, $id, $title, $type );
11917
+ }
11918
+
11919
+ /**
11920
+ * Helper function that returns the final steps for the upgrade completion.
11921
+ *
11922
+ * If the module is already running the premium code, returns an empty string.
11923
+ *
11924
+ * @author Vova Feldman (@svovaf)
11925
+ * @since 1.2.1
11926
+ *
11927
+ * @param string $plan_title
11928
+ *
11929
+ * @return string
11930
+ */
11931
+ private function get_complete_upgrade_instructions( $plan_title = '' ) {
11932
+ if ( ! $this->has_premium_version() || $this->is_premium() ) {
11933
+ return '';
11934
+ }
11935
+
11936
+ if ( empty( $plan_title ) ) {
11937
+ $plan_title = $this->_site->plan->title;
11938
+ }
11939
+
11940
+ // @since 1.2.1.5 The free version is auto deactivated.
11941
+ $deactivation_step = version_compare( $this->version, '1.2.1.5', '<' ) ?
11942
+ ( '<li>' . $this->get_text( 'deactivate-free-version' ) . '.</li>' ) :
11943
+ '';
11944
+
11945
+ return sprintf(
11946
+ ' %s: <ol><li>%s.</li>%s<li>%s (<a href="%s" target="_blank">%s</a>).</li></ol>',
11947
+ $this->get_text( 'follow-steps-to-complete-upgrade' ),
11948
+ $this->get_latest_download_link( sprintf(
11949
+ $this->get_text( 'download-latest-x-version' ),
11950
+ $plan_title
11951
+ ) ),
11952
+ $deactivation_step,
11953
+ $this->get_text( 'upload-and-activate' ),
11954
+ '//bit.ly/upload-wp-plugin',
11955
+ $this->get_text( 'howto-upload-activate' )
11956
+ );
11957
+ }
11958
+
11959
+ /* Plugin Auto-Updates (@since 1.0.4)
11960
+ ------------------------------------------------------------------------------------------------------------------*/
11961
+ /**
11962
+ * @var string[]
11963
+ */
11964
+ private static $_auto_updated_plugins;
11965
+
11966
+ /**
11967
+ * @todo TEST IF IT WORKS!!!
11968
+ *
11969
+ * Include plugins for automatic updates based on stored settings.
11970
+ *
11971
+ * @see http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
11972
+ *
11973
+ * @author Vova Feldman (@svovaf)
11974
+ * @since 1.0.4
11975
+ *
11976
+ * @param bool $update Whether to update (not used for plugins)
11977
+ * @param object $item The plugin's info
11978
+ *
11979
+ * @return bool
11980
+ */
11981
+ static function _include_plugins_in_auto_update( $update, $item ) {
11982
+ // Before version 3.8.2 the $item was the file name of the plugin,
11983
+ // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
11984
+ $by_slug = ( (int) str_replace( '.', '', get_bloginfo( 'version' ) ) >= 382 );
11985
+
11986
+ if ( ! isset( self::$_auto_updated_plugins ) ) {
11987
+ $plugins = self::$_accounts->get_option( 'plugins', array() );
11988
+
11989
+ $identifiers = array();
11990
+ foreach ( $plugins as $p ) {
11991
+ /**
11992
+ * @var FS_Plugin $p
11993
+ */
11994
+ if ( isset( $p->auto_update ) && $p->auto_update ) {
11995
+ $identifiers[] = ( $by_slug ? $p->slug : plugin_basename( $p->file ) );
11996
+ }
11997
+ }
11998
+
11999
+ self::$_auto_updated_plugins = $identifiers;
12000
+ }
12001
+
12002
+ if ( in_array( $by_slug ? $item->slug : $item, self::$_auto_updated_plugins ) ) {
12003
+ return true;
12004
+ }
12005
+
12006
+ // Pass update decision to next filters
12007
+ return $update;
12008
+ }
12009
+
12010
+ /**
12011
+ * @author Vova Feldman (@svovaf)
12012
+ * @since 1.2.1.7
12013
+ *
12014
+ * @param string $key
12015
+ *
12016
+ * @return string
12017
+ */
12018
+ function get_text( $key ) {
12019
+ return fs_text( $key, $this->_slug );
12020
+ }
12021
+
12022
+ #----------------------------------------------------------------------------------
12023
+ #region Versioning
12024
+ #----------------------------------------------------------------------------------
12025
+
12026
+ /**
12027
+ * Check if Freemius in SDK upgrade mode.
12028
+ *
12029
+ * @author Vova Feldman (@svovaf)
12030
+ * @since 1.0.9
12031
+ *
12032
+ * @return bool
12033
+ */
12034
+ function is_sdk_upgrade_mode() {
12035
+ return isset( $this->_storage->sdk_upgrade_mode ) ?
12036
+ $this->_storage->sdk_upgrade_mode :
12037
+ false;
12038
+ }
12039
+
12040
+ /**
12041
+ * Turn SDK upgrade mode off.
12042
+ *
12043
+ * @author Vova Feldman (@svovaf)
12044
+ * @since 1.0.9
12045
+ */
12046
+ function set_sdk_upgrade_complete() {
12047
+ $this->_storage->sdk_upgrade_mode = false;
12048
+ }
12049
+
12050
+ /**
12051
+ * Check if plugin upgrade mode.
12052
+ *
12053
+ * @author Vova Feldman (@svovaf)
12054
+ * @since 1.0.9
12055
+ *
12056
+ * @return bool
12057
+ */
12058
+ function is_plugin_upgrade_mode() {
12059
+ return isset( $this->_storage->plugin_upgrade_mode ) ?
12060
+ $this->_storage->plugin_upgrade_mode :
12061
+ false;
12062
+ }
12063
+
12064
+ /**
12065
+ * Turn plugin upgrade mode off.
12066
+ *
12067
+ * @author Vova Feldman (@svovaf)
12068
+ * @since 1.0.9
12069
+ */
12070
+ function set_plugin_upgrade_complete() {
12071
+ $this->_storage->plugin_upgrade_mode = false;
12072
+ }
12073
+
12074
+ #endregion
12075
+
12076
+ #----------------------------------------------------------------------------------
12077
+ #region Permissions
12078
+ #----------------------------------------------------------------------------------
12079
+
12080
+ /**
12081
+ * Check if specific permission requested.
12082
+ *
12083
+ * @author Vova Feldman (@svovaf)
12084
+ * @since 1.1.6
12085
+ *
12086
+ * @param string $permission
12087
+ *
12088
+ * @return bool
12089
+ */
12090
+ function is_permission_requested( $permission ) {
12091
+ return isset( $this->_permissions[ $permission ] ) && ( true === $this->_permissions[ $permission ] );
12092
+ }
12093
+
12094
+ #endregion
12095
+
12096
+ #----------------------------------------------------------------------------------
12097
+ #region Auto Activation
12098
+ #----------------------------------------------------------------------------------
12099
+
12100
+ /**
12101
+ * Hints the SDK if running an auto-installation.
12102
+ *
12103
+ * @var bool
12104
+ */
12105
+ private $_isAutoInstall = false;
12106
+
12107
+ /**
12108
+ * After upgrade callback to install and auto activate a plugin.
12109
+ * This code will only be executed on explicit request from the user,
12110
+ * following the practice Jetpack are using with their theme installations.
12111
+ *
12112
+ * @link https://make.wordpress.org/plugins/2017/03/16/clarification-of-guideline-8-executable-code-and-installs/
12113
+ *
12114
+ * @author Vova Feldman (@svovaf)
12115
+ * @since 1.2.1.7
12116
+ */
12117
+ function _install_premium_version_ajax_action() {
12118
+ $this->_logger->entrance();
12119
+
12120
+ $this->check_ajax_referer( 'install_premium_version' );
12121
+
12122
+ if ( ! $this->is_registered() ) {
12123
+ // Not registered.
12124
+ self::shoot_ajax_failure( array(
12125
+ 'message' => $this->get_text( 'auto-install-error-not-opted-in' ),
12126
+ 'code' => 'premium_installed',
12127
+ ) );
12128
+ }
12129
+
12130
+ $plugin_id = fs_request_get( 'module_id', $this->get_id() );
12131
+
12132
+ if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
12133
+ // Invalid ID.
12134
+ self::shoot_ajax_failure( array(
12135
+ 'message' => $this->get_text( 'auto-install-error-invalid-id' ),
12136
+ 'code' => 'invalid_module_id',
12137
+ ) );
12138
+ }
12139
+
12140
+ if ( $plugin_id == $this->get_id() ) {
12141
+ if ( $this->is_premium() ) {
12142
+ // Already using the premium code version.
12143
+ self::shoot_ajax_failure( array(
12144
+ 'message' => $this->get_text( 'auto-install-error-premium-activated' ),
12145
+ 'code' => 'premium_installed',
12146
+ ) );
12147
+ }
12148
+ if ( ! $this->can_use_premium_code() ) {
12149
+ // Don't have access to the premium code.
12150
+ self::shoot_ajax_failure( array(
12151
+ 'message' => $this->get_text( 'auto-install-error-invalid-license' ),
12152
+ 'code' => 'invalid_license',
12153
+ ) );
12154
+ }
12155
+ if ( ! $this->has_release_on_freemius() ) {
12156
+ // Plugin is a serviceware, no premium code version.
12157
+ self::shoot_ajax_failure( array(
12158
+ 'message' => $this->get_text( 'auto-install-error-serviceware' ),
12159
+ 'code' => 'premium_version_missing',
12160
+ ) );
12161
+ }
12162
+ } else {
12163
+ $addon = $this->get_addon( $plugin_id );
12164
+
12165
+ if ( ! is_object( $addon ) ) {
12166
+ // Invalid add-on ID.
12167
+ self::shoot_ajax_failure( array(
12168
+ 'message' => $this->get_text( 'auto-install-error-invalid-id' ),
12169
+ 'code' => 'invalid_module_id',
12170
+ ) );
12171
+ }
12172
+
12173
+ if ( $this->is_addon_activated( $plugin_id, true ) ) {
12174
+ // Premium add-on version is already activated.
12175
+ self::shoot_ajax_failure( array(
12176
+ 'message' => $this->get_text( 'auto-install-error-premium-addon-activated' ),
12177
+ 'code' => 'premium_installed',
12178
+ ) );
12179
+ }
12180
+ }
12181
+
12182
+ $this->_isAutoInstall = true;
12183
+
12184
+ // Try to install and activate.
12185
+ $updater = new FS_Plugin_Updater( $this );
12186
+ $result = $updater->install_and_activate_plugin( $plugin_id );
12187
+
12188
+ if ( is_array( $result ) && ! empty( $result['message'] ) ) {
12189
+ self::shoot_ajax_failure( array(
12190
+ 'message' => $result['message'],
12191
+ 'code' => $result['code'],
12192
+ ) );
12193
+ }
12194
+
12195
+ self::shoot_ajax_success( $result );
12196
+ }
12197
+
12198
+ /**
12199
+ * Displays module activation dialog box after a successful upgrade
12200
+ * where the user explicitly requested to auto download and install
12201
+ * the premium version.
12202
+ *
12203
+ * @author Vova Feldman (@svovaf)
12204
+ * @since 1.2.1.7
12205
+ */
12206
+ function _add_auto_installation_dialog_box() {
12207
+ $this->_logger->entrance();
12208
+
12209
+ if ( ! $this->is_registered() ) {
12210
+ // Not registered.
12211
+ return;
12212
+ }
12213
+
12214
+ $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
12215
+
12216
+ if ( ! FS_Plugin::is_valid_id( $plugin_id ) ) {
12217
+ // Invalid module ID.
12218
+ return;
12219
+ }
12220
+
12221
+ if ( $plugin_id == $this->get_id() ) {
12222
+ if ( $this->is_premium() ) {
12223
+ // Already using the premium code version.
12224
+ return;
12225
+ }
12226
+ if ( ! $this->can_use_premium_code() ) {
12227
+ // Don't have access to the premium code.
12228
+ return;
12229
+ }
12230
+ if ( ! $this->has_release_on_freemius() ) {
12231
+ // Plugin is a serviceware, no premium code version.
12232
+ return;
12233
+ }
12234
+ } else {
12235
+ $addon = $this->get_addon( $plugin_id );
12236
+
12237
+ if ( ! is_object( $addon ) ) {
12238
+ // Invalid add-on ID.
12239
+ return;
12240
+ }
12241
+
12242
+ if ( $this->is_addon_activated( $plugin_id, true ) ) {
12243
+ // Premium add-on version is already activated.
12244
+ return;
12245
+ }
12246
+ }
12247
+
12248
+ $vars = array(
12249
+ 'id' => $plugin_id,
12250
+ 'slug' => $this->_slug,
12251
+ );
12252
+
12253
+ fs_require_template( 'auto-installation.php', $vars );
12254
+ }
12255
+
12256
+ #endregion
12257
+
12258
+ #----------------------------------------------------------------------------------
12259
+ #region Marketing
12260
+ #----------------------------------------------------------------------------------
12261
+
12262
+ /**
12263
+ * Check if current user purchased any other plugins before.
12264
+ *
12265
+ * @author Vova Feldman (@svovaf)
12266
+ * @since 1.0.9
12267
+ *
12268
+ * @return bool
12269
+ */
12270
+ function has_purchased_before() {
12271
+ // TODO: Implement has_purchased_before() method.
12272
+ throw new Exception( 'not implemented' );
12273
+ }
12274
+
12275
+ /**
12276
+ * Check if current user classified as an agency.
12277
+ *
12278
+ * @author Vova Feldman (@svovaf)
12279
+ * @since 1.0.9
12280
+ *
12281
+ * @return bool
12282
+ */
12283
+ function is_agency() {
12284
+ // TODO: Implement is_agency() method.
12285
+ throw new Exception( 'not implemented' );
12286
+ }
12287
+
12288
+ /**
12289
+ * Check if current user classified as a developer.
12290
+ *
12291
+ * @author Vova Feldman (@svovaf)
12292
+ * @since 1.0.9
12293
+ *
12294
+ * @return bool
12295
+ */
12296
+ function is_developer() {
12297
+ // TODO: Implement is_developer() method.
12298
+ throw new Exception( 'not implemented' );
12299
+ }
12300
+
12301
+ /**
12302
+ * Check if current user classified as a business.
12303
+ *
12304
+ * @author Vova Feldman (@svovaf)
12305
+ * @since 1.0.9
12306
+ *
12307
+ * @return bool
12308
+ */
12309
+ function is_business() {
12310
+ // TODO: Implement is_business() method.
12311
+ throw new Exception( 'not implemented' );
12312
+ }
12313
+
12314
+ #endregion
12315
+ }
freemius/includes/class-fs-api.php ADDED
@@ -0,0 +1,558 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ( $this->_logger->is_on() && self::is_api_error( $result ) ) {
184
+ // Log API errors.
185
+ $this->_logger->api_error( $result );
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
+
247
+ if ( $this->_logger->is_on() ) {
248
+ $this->_logger->warn( 'Fallback to cached API result: ' . var_export( $cached_result, true ) );
249
+ }
250
+ } else {
251
+ // If no older data version, return result without
252
+ // caching the error.
253
+ return $result;
254
+ }
255
+ }
256
+
257
+ self::$_cache->set( $cache_key, $result, $expiration );
258
+
259
+ $cached_result = $result;
260
+ } else {
261
+ $this->_logger->log( 'Using cached API result.' );
262
+ }
263
+
264
+ return $cached_result;
265
+ }
266
+
267
+ /**
268
+ * Check if there's a cached version of the API request.
269
+ *
270
+ * @author Vova Feldman (@svovaf)
271
+ * @since 1.2.1
272
+ *
273
+ * @param string $path
274
+ * @param string $method
275
+ * @param array $params
276
+ *
277
+ * @return bool
278
+ */
279
+ function is_cached( $path, $method = 'GET', $params = array() ) {
280
+ $cache_key = $this->get_cache_key( $path, $method, $params );
281
+
282
+ return self::$_cache->has_valid( $cache_key );
283
+ }
284
+
285
+ /**
286
+ * Invalidate a cached version of the API request.
287
+ *
288
+ * @author Vova Feldman (@svovaf)
289
+ * @since 1.2.1.5
290
+ *
291
+ * @param string $path
292
+ * @param string $method
293
+ * @param array $params
294
+ */
295
+ function purge_cache( $path, $method = 'GET', $params = array() ) {
296
+ $this->_logger->entrance( "{$method}:{$path}" );
297
+
298
+ $cache_key = $this->get_cache_key( $path, $method, $params );
299
+
300
+ self::$_cache->purge( $cache_key );
301
+ }
302
+
303
+ /**
304
+ * @param string $path
305
+ * @param string $method
306
+ * @param array $params
307
+ *
308
+ * @return string
309
+ * @throws \Freemius_Exception
310
+ */
311
+ private function get_cache_key( $path, $method = 'GET', $params = array() ) {
312
+ $canonized = $this->_api->CanonizePath( $path );
313
+ // $exploded = explode('/', $canonized);
314
+ // return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
315
+ return strtolower( $method . ':' . $canonized ) . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
316
+ }
317
+
318
+ /**
319
+ * Test API connectivity.
320
+ *
321
+ * @author Vova Feldman (@svovaf)
322
+ * @since 1.0.9 If fails, try to fallback to HTTP.
323
+ * @since 1.1.6 Added a 5-min caching mechanism, to prevent from overloading the server if the API if
324
+ * temporary down.
325
+ *
326
+ * @return bool True if successful connectivity to the API.
327
+ */
328
+ static function test() {
329
+ self::_init();
330
+
331
+ $cache_key = 'ping_test';
332
+
333
+ $test = self::$_cache->get_valid( $cache_key, null );
334
+
335
+ if ( is_null( $test ) ) {
336
+ $test = Freemius_Api::Test();
337
+
338
+ if ( false === $test && Freemius_Api::IsHttps() ) {
339
+ // Fallback to HTTP, since HTTPS fails.
340
+ Freemius_Api::SetHttp();
341
+
342
+ self::$_options->set_option( 'api_force_http', true, true );
343
+
344
+ $test = Freemius_Api::Test();
345
+
346
+ if ( false === $test ) {
347
+ /**
348
+ * API connectivity test fail also in HTTP request, therefore,
349
+ * fallback to HTTPS to keep connection secure.
350
+ *
351
+ * @since 1.1.6
352
+ */
353
+ self::$_options->set_option( 'api_force_http', false, true );
354
+ }
355
+ }
356
+
357
+ self::$_cache->set( $cache_key, $test, WP_FS__TIME_5_MIN_IN_SEC );
358
+ }
359
+
360
+ return $test;
361
+ }
362
+
363
+ /**
364
+ * Check if API is temporary down.
365
+ *
366
+ * @author Vova Feldman (@svovaf)
367
+ * @since 1.1.6
368
+ *
369
+ * @return bool
370
+ */
371
+ static function is_temporary_down() {
372
+ self::_init();
373
+
374
+ $test = self::$_cache->get_valid( 'ping_test', null );
375
+
376
+ return ( false === $test );
377
+ }
378
+
379
+ /**
380
+ * @author Vova Feldman (@svovaf)
381
+ * @since 1.1.6
382
+ *
383
+ * @return object
384
+ */
385
+ private function get_temporary_unavailable_error() {
386
+ return (object) array(
387
+ 'error' => (object) array(
388
+ 'type' => 'TemporaryUnavailable',
389
+ 'message' => 'API is temporary unavailable, please retry in ' . ( self::$_cache->get_record_expiration( 'ping_test' ) - WP_FS__SCRIPT_START_TIME ) . ' sec.',
390
+ 'code' => 'temporary_unavailable',
391
+ 'http' => 503
392
+ )
393
+ );
394
+ }
395
+
396
+ /**
397
+ * Ping API for connectivity test, and return result object.
398
+ *
399
+ * @author Vova Feldman (@svovaf)
400
+ * @since 1.0.9
401
+ *
402
+ * @param null|string $unique_anonymous_id
403
+ * @param array $params
404
+ *
405
+ * @return object
406
+ */
407
+ function ping( $unique_anonymous_id = null, $params = array() ) {
408
+ $this->_logger->entrance();
409
+
410
+ if ( self::is_temporary_down() ) {
411
+ return $this->get_temporary_unavailable_error();
412
+ }
413
+
414
+ $pong = is_null( $unique_anonymous_id ) ?
415
+ Freemius_Api::Ping() :
416
+ $this->_call( 'ping.json?' . http_build_query( array_merge(
417
+ array( 'uid' => $unique_anonymous_id ),
418
+ $params
419
+ ) ) );
420
+
421
+ if ( $this->is_valid_ping( $pong ) ) {
422
+ return $pong;
423
+ }
424
+
425
+ if ( self::should_try_with_http( $pong ) ) {
426
+ // Fallback to HTTP, since HTTPS fails.
427
+ Freemius_Api::SetHttp();
428
+
429
+ self::$_options->set_option( 'api_force_http', true, true );
430
+
431
+ $pong = is_null( $unique_anonymous_id ) ?
432
+ Freemius_Api::Ping() :
433
+ $this->_call( 'ping.json?' . http_build_query( array_merge(
434
+ array( 'uid' => $unique_anonymous_id ),
435
+ $params
436
+ ) ) );
437
+
438
+ if ( ! $this->is_valid_ping( $pong ) ) {
439
+ self::$_options->set_option( 'api_force_http', false, true );
440
+ }
441
+ }
442
+
443
+ return $pong;
444
+ }
445
+
446
+ /**
447
+ * Check if based on the API result we should try
448
+ * to re-run the same request with HTTP instead of HTTPS.
449
+ *
450
+ * @author Vova Feldman (@svovaf)
451
+ * @since 1.1.6
452
+ *
453
+ * @param $result
454
+ *
455
+ * @return bool
456
+ */
457
+ private static function should_try_with_http( $result ) {
458
+ if ( ! Freemius_Api::IsHttps() ) {
459
+ return false;
460
+ }
461
+
462
+ return ( ! is_object( $result ) ||
463
+ ! isset( $result->error ) ||
464
+ ! isset( $result->error->code ) ||
465
+ ! in_array( $result->error->code, array(
466
+ 'curl_missing',
467
+ 'cloudflare_ddos_protection',
468
+ 'maintenance_mode',
469
+ 'squid_cache_block',
470
+ 'too_many_requests',
471
+ ) ) );
472
+
473
+ }
474
+
475
+ /**
476
+ * Check if valid ping request result.
477
+ *
478
+ * @author Vova Feldman (@svovaf)
479
+ * @since 1.1.1
480
+ *
481
+ * @param mixed $pong
482
+ *
483
+ * @return bool
484
+ */
485
+ function is_valid_ping( $pong ) {
486
+ return Freemius_Api::Test( $pong );
487
+ }
488
+
489
+ function get_url( $path = '' ) {
490
+ return Freemius_Api::GetUrl( $path, $this->_api->IsSandbox() );
491
+ }
492
+
493
+ /**
494
+ * Clear API cache.
495
+ *
496
+ * @author Vova Feldman (@svovaf)
497
+ * @since 1.0.9
498
+ */
499
+ static function clear_cache() {
500
+ self::_init();
501
+
502
+ self::$_cache = FS_Cache_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME );
503
+ self::$_cache->clear();
504
+ }
505
+
506
+ #----------------------------------------------------------------------------------
507
+ #region Error Handling
508
+ #----------------------------------------------------------------------------------
509
+
510
+ /**
511
+ * @author Vova Feldman (@svovaf)
512
+ * @since 1.2.1.5
513
+ *
514
+ * @param mixed $result
515
+ *
516
+ * @return bool Is API result contains an error.
517
+ */
518
+ static function is_api_error( $result ) {
519
+ return ( is_object( $result ) && isset( $result->error ) ) ||
520
+ is_string( $result );
521
+ }
522
+
523
+ /**
524
+ * Checks if given API result is a non-empty and not an error object.
525
+ *
526
+ * @author Vova Feldman (@svovaf)
527
+ * @since 1.2.1.5
528
+ *
529
+ * @param mixed $result
530
+ * @param string|null $required_property Optional property we want to verify that is set.
531
+ *
532
+ * @return bool
533
+ */
534
+ static function is_api_result_object( $result, $required_property = null ) {
535
+ return (
536
+ is_object( $result ) &&
537
+ ! isset( $result->error ) &&
538
+ ( empty( $required_property ) || isset( $result->{$required_property} ) )
539
+ );
540
+ }
541
+
542
+ /**
543
+ * Checks if given API result is a non-empty entity object with non-empty ID.
544
+ *
545
+ * @author Vova Feldman (@svovaf)
546
+ * @since 1.2.1.5
547
+ *
548
+ * @param mixed $result
549
+ *
550
+ * @return bool
551
+ */
552
+ static function is_api_result_entity( $result ) {
553
+ return self::is_api_result_object( $result, 'id' ) &&
554
+ FS_Entity::is_valid_id( $result->id );
555
+ }
556
+
557
+ #endregion
558
+ }
freemius/includes/class-fs-logger.php ADDED
@@ -0,0 +1,688 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var int PHP Process ID.
20
+ */
21
+ private static $_processID;
22
+ /**
23
+ * @var string PHP Script user name.
24
+ */
25
+ private static $_ownerName;
26
+ /**
27
+ * @var bool Is storage logging turned on.
28
+ */
29
+ private static $_isStorageLoggingOn;
30
+ /**
31
+ * @var int ABSPATH length.
32
+ */
33
+ private static $_abspathLength;
34
+
35
+ private static $LOGGERS = array();
36
+ private static $LOG = array();
37
+ private static $CNT = 0;
38
+ private static $_HOOKED_FOOTER = false;
39
+
40
+ private function __construct( $id, $on = false, $echo = false ) {
41
+ $this->_id = $id;
42
+
43
+ $bt = debug_backtrace();
44
+ $caller = $bt[2];
45
+
46
+ if ( false !== strpos( $caller['file'], 'plugins' ) ) {
47
+ $this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
48
+ } else {
49
+ $this->_file_start = strpos( $caller['file'], 'themes' ) + strlen( 'themes/' );
50
+ }
51
+
52
+ if ( $on ) {
53
+ $this->on();
54
+ }
55
+ if ( $echo ) {
56
+ $this->echo_on();
57
+ }
58
+ }
59
+
60
+ /**
61
+ * @param string $id
62
+ * @param bool $on
63
+ * @param bool $echo
64
+ *
65
+ * @return FS_Logger
66
+ */
67
+ public static function get_logger( $id, $on = false, $echo = false ) {
68
+ $id = strtolower( $id );
69
+
70
+ if ( ! isset( self::$_processID ) ) {
71
+ self::init();
72
+ }
73
+
74
+ if ( ! isset( self::$LOGGERS[ $id ] ) ) {
75
+ self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
76
+ }
77
+
78
+ return self::$LOGGERS[ $id ];
79
+ }
80
+
81
+ /**
82
+ * Initialize logging global info.
83
+ *
84
+ * @author Vova Feldman (@svovaf)
85
+ * @since 1.2.1.6
86
+ */
87
+ private static function init() {
88
+ self::$_ownerName = function_exists( 'get_current_user' ) ?
89
+ get_current_user() :
90
+ 'unknown';
91
+ self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
92
+ self::$_abspathLength = strlen( ABSPATH );
93
+ self::$_processID = mt_rand( 0, 32000 );
94
+
95
+ // Process ID may be `false` on errors.
96
+ if ( ! is_numeric( self::$_processID ) ) {
97
+ self::$_processID = 0;
98
+ }
99
+ }
100
+
101
+ private static function hook_footer() {
102
+ if ( self::$_HOOKED_FOOTER ) {
103
+ return;
104
+ }
105
+
106
+ if ( is_admin() ) {
107
+ add_action( 'admin_footer', 'FS_Logger::dump', 100 );
108
+ } else {
109
+ add_action( 'wp_footer', 'FS_Logger::dump', 100 );
110
+ }
111
+ }
112
+
113
+ function is_on() {
114
+ return $this->_on;
115
+ }
116
+
117
+ function on() {
118
+ $this->_on = true;
119
+
120
+ if ( ! function_exists( 'dbDelta' ) ) {
121
+ require_once ABSPATH . 'wp-admin/includes/upgrade.php';
122
+ }
123
+
124
+ self::hook_footer();
125
+ }
126
+
127
+ function echo_on() {
128
+ $this->on();
129
+
130
+ $this->_echo = true;
131
+ }
132
+
133
+ function is_echo_on() {
134
+ return $this->_echo;
135
+ }
136
+
137
+ function get_id() {
138
+ return $this->_id;
139
+ }
140
+
141
+ function get_file() {
142
+ return $this->_file_start;
143
+ }
144
+
145
+ private function _log( &$message, $type = 'log', $wrapper ) {
146
+ if ( ! $this->is_on() ) {
147
+ return;
148
+ }
149
+
150
+ $bt = debug_backtrace();
151
+ $depth = $wrapper ? 3 : 2;
152
+ while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
153
+ $depth ++;
154
+ }
155
+
156
+ $caller = $bt[ $depth ];
157
+
158
+ /**
159
+ * Retrieve the correct call file & line number from backtrace
160
+ * when logging from a wrapper method.
161
+ *
162
+ * @author Vova Feldman
163
+ * @since 1.2.1.6
164
+ */
165
+ if ( empty( $caller['line'] ) ) {
166
+ $depth --;
167
+
168
+ while ( $depth >= 0 ) {
169
+ if ( ! empty( $bt[ $depth ]['line'] ) ) {
170
+ $caller['line'] = $bt[ $depth ]['line'];
171
+ $caller['file'] = $bt[ $depth ]['file'];
172
+ break;
173
+ }
174
+ }
175
+ }
176
+
177
+ $log = array_merge( $caller, array(
178
+ 'cnt' => self::$CNT ++,
179
+ 'logger' => $this,
180
+ 'timestamp' => microtime( true ),
181
+ 'log_type' => $type,
182
+ 'msg' => $message,
183
+ ) );
184
+
185
+ if ( self::$_isStorageLoggingOn ) {
186
+ $this->db_log( $type, $message, self::$CNT, $caller );
187
+ }
188
+
189
+ self::$LOG[] = $log;
190
+
191
+ if ( $this->is_echo_on() && ! Freemius::is_ajax() ) {
192
+ echo self::format_html( $log ) . "\n";
193
+ }
194
+ }
195
+
196
+ function log( $message, $wrapper = false ) {
197
+ $this->_log( $message, 'log', $wrapper );
198
+ }
199
+
200
+ function info( $message, $wrapper = false ) {
201
+ $this->_log( $message, 'info', $wrapper );
202
+ }
203
+
204
+ function warn( $message, $wrapper = false ) {
205
+ $this->_log( $message, 'warn', $wrapper );
206
+ }
207
+
208
+ function error( $message, $wrapper = false ) {
209
+ $this->_log( $message, 'error', $wrapper );
210
+ }
211
+
212
+ /**
213
+ * Log API error.
214
+ *
215
+ * @author Vova Feldman (@svovaf)
216
+ * @since 1.2.1.5
217
+ *
218
+ * @param mixed $api_result
219
+ * @param bool $wrapper
220
+ */
221
+ function api_error( $api_result, $wrapper = false ) {
222
+ $message = '';
223
+ if ( is_object( $api_result ) && isset( $api_result->error ) ) {
224
+ $message = $api_result->error->message;
225
+ } else if ( is_object( $api_result ) ) {
226
+ $message = var_export( $api_result, true );
227
+ } else if ( is_string( $api_result ) ) {
228
+ $message = $api_result;
229
+ } else if ( empty( $api_result ) ) {
230
+ $message = 'Empty API result.';
231
+ }
232
+
233
+ $message = 'API Error: ' . $message;
234
+
235
+ $this->_log( $message, 'error', $wrapper );
236
+ }
237
+
238
+ function entrance( $message = '', $wrapper = false ) {
239
+ $msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
240
+
241
+ $this->_log( $msg, 'log', $wrapper );
242
+ }
243
+
244
+ function departure( $message = '', $wrapper = false ) {
245
+ $msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
246
+
247
+ $this->_log( $msg, 'log', $wrapper );
248
+ }
249
+
250
+ #--------------------------------------------------------------------------------
251
+ #region Log Formatting
252
+ #--------------------------------------------------------------------------------
253
+
254
+ private static function format( $log, $show_type = true ) {
255
+ return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['log_type'] . ']' : '' ) . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
256
+ }
257
+
258
+ private static function format_html( $log ) {
259
+ return '<div style="font-size: 13px; font-family: monospace; color: #7da767; padding: 8px 3px; background: #000; border-bottom: 1px solid #555;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['log_type'] . '] <b><code style="color: #c4b1e0;">' . ( ! empty( $log['class'] ) ? $log['class'] . $log['type'] : '' ) . $log['function'] . '</code> >> <b style="color: #f59330;">' . esc_html( $log['msg'] ) . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
260
+ }
261
+
262
+ #endregion
263
+
264
+ static function dump() {
265
+ ?>
266
+ <!-- BEGIN: Freemius PHP Console Log -->
267
+ <script type="text/javascript">
268
+ <?php
269
+ foreach ( self::$LOG as $log ) {
270
+ echo 'console.' . $log['log_type'] . '(' . json_encode( self::format( $log, false ) ) . ')' . "\n";
271
+ }
272
+ ?>
273
+ </script>
274
+ <!-- END: Freemius PHP Console Log -->
275
+ <?php
276
+ }
277
+
278
+ static function get_log() {
279
+ return self::$LOG;
280
+ }
281
+
282
+ #--------------------------------------------------------------------------------
283
+ #region Database Logging
284
+ #--------------------------------------------------------------------------------
285
+
286
+ /**
287
+ * @author Vova Feldman (@svovaf)
288
+ * @since 1.2.1.6
289
+ *
290
+ * @return bool
291
+ */
292
+ public static function is_storage_logging_on() {
293
+ if ( ! isset( self::$_isStorageLoggingOn ) ) {
294
+ self::$_isStorageLoggingOn = ( 1 == get_option( 'fs_storage_logger', 0 ) );
295
+ }
296
+
297
+ return self::$_isStorageLoggingOn;
298
+ }
299
+
300
+ /**
301
+ * Turns on/off database persistent debugging to capture
302
+ * multi-session logs to debug complex flows like
303
+ * plugin auto-deactivate on premium version activation.
304
+ *
305
+ * @todo Check if Theme Check has issues with DB tables for themes.
306
+ *
307
+ * @author Vova Feldman (@svovaf)
308
+ * @since 1.2.1.6
309
+ *
310
+ * @param bool $is_on
311
+ *
312
+ * @return bool
313
+ */
314
+ public static function _set_storage_logging( $is_on = true ) {
315
+ global $wpdb;
316
+
317
+ $table = "{$wpdb->prefix}fs_logger";
318
+
319
+ if ( $is_on ) {
320
+ /**
321
+ * Create logging table.
322
+ *
323
+ * NOTE:
324
+ * dbDelta must use KEY and not INDEX for indexes.
325
+ *
326
+ * @link https://core.trac.wordpress.org/ticket/2695
327
+ */
328
+ $result = $wpdb->query( "CREATE TABLE {$table} (
329
+ `id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
330
+ `process_id` INT UNSIGNED NOT NULL,
331
+ `user_name` VARCHAR(64) NOT NULL,
332
+ `logger` VARCHAR(128) NOT NULL,
333
+ `log_order` INT UNSIGNED NOT NULL,
334
+ `type` ENUM('log','info','warn','error') NOT NULL DEFAULT 'log',
335
+ `message` TEXT NOT NULL,
336
+ `file` VARCHAR(256) NOT NULL,
337
+ `line` INT UNSIGNED NOT NULL,
338
+ `function` VARCHAR(256) NOT NULL,
339
+ `request_type` ENUM('call','ajax','cron') NOT NULL DEFAULT 'call',
340
+ `request_url` VARCHAR(1024) NOT NULL,
341
+ `created` DECIMAL(16, 6) NOT NULL,
342
+ PRIMARY KEY (`id`),
343
+ KEY `process_id` (`process_id` ASC),
344
+ KEY `process_logger` (`process_id` ASC, `logger` ASC),
345
+ KEY `function` (`function` ASC),
346
+ KEY `type` (`type` ASC))" );
347
+ } else {
348
+ /**
349
+ * Drop logging table.
350
+ */
351
+ $result = $wpdb->query( "DROP TABLE IF EXISTS $table;" );
352
+ }
353
+
354
+ if ( false !== $result ) {
355
+ update_option( 'fs_storage_logger', ( $is_on ? 1 : 0 ) );
356
+ }
357
+
358
+ return ( false !== $result );
359
+ }
360
+
361
+ /**
362
+ * @author Vova Feldman (@svovaf)
363
+ * @since 1.2.1.6
364
+ *
365
+ * @param string $type
366
+ * @param string $message
367
+ * @param int $log_order
368
+ * @param array $caller
369
+ *
370
+ * @return false|int
371
+ */
372
+ private function db_log(
373
+ &$type,
374
+ &$message,
375
+ &$log_order,
376
+ &$caller
377
+ ) {
378
+ global $wpdb;
379
+
380
+ $request_type = 'call';
381
+ if ( defined( 'DOING_CRON' ) && DOING_CRON ) {
382
+ $request_type = 'cron';
383
+ } else if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
384
+ $request_type = 'ajax';
385
+ }
386
+
387
+ $request_url = WP_FS__IS_HTTP_REQUEST ?
388
+ $_SERVER['REQUEST_URI'] :
389
+ '';
390
+
391
+ return $wpdb->insert(
392
+ "{$wpdb->prefix}fs_logger",
393
+ array(
394
+ 'process_id' => self::$_processID,
395
+ 'user_name' => self::$_ownerName,
396
+ 'logger' => $this->_id,
397
+ 'log_order' => $log_order,
398
+ 'type' => $type,
399
+ 'request_type' => $request_type,
400
+ 'request_url' => $request_url,
401
+ 'message' => $message,
402
+ 'file' => isset( $caller['file'] ) ?
403
+ substr( $caller['file'], self::$_abspathLength ) :
404
+ '',
405
+ 'line' => $caller['line'],
406
+ 'function' => ( ! empty( $caller['class'] ) ? $caller['class'] . $caller['type'] : '' ) . $caller['function'],
407
+ 'created' => microtime( true ),
408
+ )
409
+ );
410
+ }
411
+
412
+ /**
413
+ * Persistent DB logger columns.
414
+ *
415
+ * @var array
416
+ */
417
+ private static $_log_columns = array(
418
+ 'id',
419
+ 'process_id',
420
+ 'user_name',
421
+ 'logger',
422
+ 'log_order',
423
+ 'type',
424
+ 'message',
425
+ 'file',
426
+ 'line',
427
+ 'function',
428
+ 'request_type',
429
+ 'request_url',
430
+ 'created',
431
+ );
432
+
433
+ /**
434
+ * Create DB logs query.
435
+ *
436
+ * @author Vova Feldman (@svovaf)
437
+ * @since 1.2.1.6
438
+ *
439
+ * @param bool $filters
440
+ * @param int $limit
441
+ * @param int $offset
442
+ * @param bool $order
443
+ * @param bool $escape_eol
444
+ *
445
+ * @return string
446
+ */
447
+ private static function build_db_logs_query(
448
+ $filters = false,
449
+ $limit = 200,
450
+ $offset = 0,
451
+ $order = false,
452
+ $escape_eol = false
453
+ ) {
454
+ global $wpdb;
455
+
456
+ $select = '*';
457
+
458
+ if ( $escape_eol ) {
459
+ $select = '';
460
+ for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
461
+ if ( $i > 0 ) {
462
+ $select .= ', ';
463
+ }
464
+
465
+ if ( 'message' !== self::$_log_columns[ $i ] ) {
466
+ $select .= self::$_log_columns[ $i ];
467
+ } else {
468
+ $select .= 'REPLACE(message , \'\n\', \' \') AS message';
469
+ }
470
+ }
471
+ }
472
+
473
+ $query = "SELECT {$select} FROM {$wpdb->prefix}fs_logger";
474
+ if ( is_array( $filters ) ) {
475
+ $criteria = array();
476
+
477
+ if ( ! empty( $filters['type'] ) && 'all' !== $filters['type'] ) {
478
+ $filters['type'] = strtolower( $filters['type'] );
479
+
480
+ switch ( $filters['type'] ) {
481
+ case 'warn_error':
482
+ $criteria[] = array( 'col' => 'type', 'val' => array( 'warn', 'error' ) );
483
+ break;
484
+ case 'error':
485
+ case 'warn':
486
+ $criteria[] = array( 'col' => 'type', 'val' => $filters['type'] );
487
+ break;
488
+ case 'info':
489
+ default:
490
+ $criteria[] = array( 'col' => 'type', 'val' => array( 'info', 'log' ) );
491
+ break;
492
+ }
493
+ }
494
+
495
+ if ( ! empty( $filters['request_type'] ) ) {
496
+ $filters['request_type'] = strtolower( $filters['request_type'] );
497
+
498
+ if ( in_array( $filters['request_type'], array( 'call', 'ajax', 'cron' ) ) ) {
499
+ $criteria[] = array( 'col' => 'request_type', 'val' => $filters['request_type'] );
500
+ }
501
+ }
502
+
503
+ if ( ! empty( $filters['file'] ) ) {
504
+ $criteria[] = array(
505
+ 'col' => 'file',
506
+ 'op' => 'LIKE',
507
+ 'val' => '%' . esc_sql( $filters['file'] ),
508
+ );
509
+ }
510
+
511
+ if ( ! empty( $filters['function'] ) ) {
512
+ $criteria[] = array(
513
+ 'col' => 'function',
514
+ 'op' => 'LIKE',
515
+ 'val' => '%' . esc_sql( $filters['function'] ),
516
+ );
517
+ }
518
+
519
+ if ( ! empty( $filters['process_id'] ) && is_numeric( $filters['process_id'] ) ) {
520
+ $criteria[] = array( 'col' => 'process_id', 'val' => $filters['process_id'] );
521
+ }
522
+
523
+ if ( ! empty( $filters['logger'] ) ) {
524
+ $criteria[] = array(
525
+ 'col' => 'logger',
526
+ 'op' => 'LIKE',
527
+ 'val' => '%' . esc_sql( $filters['logger'] ) . '%',
528
+ );
529
+ }
530
+
531
+ if ( ! empty( $filters['message'] ) ) {
532
+ $criteria[] = array(
533
+ 'col' => 'message',
534
+ 'op' => 'LIKE',
535
+ 'val' => '%' . esc_sql( $filters['message'] ) . '%',
536
+ );
537
+ }
538
+
539
+ if ( 0 < count( $criteria ) ) {
540
+ $query .= "\nWHERE\n";
541
+
542
+ $first = true;
543
+ foreach ( $criteria as $c ) {
544
+ if ( ! $first ) {
545
+ $query .= "AND\n";
546
+ }
547
+
548
+ if ( is_array( $c['val'] ) ) {
549
+ $operator = 'IN';
550
+
551
+ for ( $i = 0, $len = count( $c['val'] ); $i < $len; $i ++ ) {
552
+ $c['val'][ $i ] = "'" . esc_sql( $c['val'][ $i ] ) . "'";
553
+ }
554
+
555
+ $val = '(' . implode( ',', $c['val'] ) . ')';
556
+ } else {
557
+ $operator = ! empty( $c['op'] ) ? $c['op'] : '=';
558
+ $val = "'" . esc_sql( $c['val'] ) . "'";
559
+ }
560
+
561
+ $query .= "`{$c['col']}` {$operator} {$val}\n";
562
+
563
+ $first = false;
564
+ }
565
+ }
566
+ }
567
+
568
+ if ( ! is_array( $order ) ) {
569
+ $order = array(
570
+ 'col' => 'id',
571
+ 'order' => 'desc'
572
+ );
573
+ }
574
+
575
+ $query .= " ORDER BY {$order['col']} {$order['order']} LIMIT {$offset},{$limit}";
576
+
577
+ return $query;
578
+ }
579
+
580
+ /**
581
+ * Load logs from DB.
582
+ *
583
+ * @author Vova Feldman (@svovaf)
584
+ * @since 1.2.1.6
585
+ *
586
+ * @param bool $filters
587
+ * @param int $limit
588
+ * @param int $offset
589
+ * @param bool $order
590
+ *
591
+ * @return object[]|null
592
+ */
593
+ public static function load_db_logs(
594
+ $filters = false,
595
+ $limit = 200,
596
+ $offset = 0,
597
+ $order = false
598
+ ) {
599
+ global $wpdb;
600
+
601
+ $query = self::build_db_logs_query(
602
+ $filters,
603
+ $limit,
604
+ $offset,
605
+ $order
606
+ );
607
+
608
+ return $wpdb->get_results( $query );
609
+ }
610
+
611
+ /**
612
+ * Load logs from DB.
613
+ *
614
+ * @author Vova Feldman (@svovaf)
615
+ * @since 1.2.1.6
616
+ *
617
+ * @param bool $filters
618
+ * @param string $filename
619
+ * @param int $limit
620
+ * @param int $offset
621
+ * @param bool $order
622
+ *
623
+ * @return false|string File download URL or false on failure.
624
+ */
625
+ public static function download_db_logs(
626
+ $filters = false,
627
+ $filename = '',
628
+ $limit = 10000,
629
+ $offset = 0,
630
+ $order = false
631
+ ) {
632
+ global $wpdb;
633
+
634
+ $query = self::build_db_logs_query(
635
+ $filters,
636
+ $limit,
637
+ $offset,
638
+ $order,
639
+ true
640
+ );
641
+
642
+ $upload_dir = wp_upload_dir();
643
+ if ( empty( $filename ) ) {
644
+ $filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
645
+ }
646
+ $filepath = rtrim( $upload_dir['path'], '/' ) . "/{$filename}";
647
+
648
+ $query .= " INTO OUTFILE '{$filepath}' FIELDS TERMINATED BY '\t' ESCAPED BY '\\\\' OPTIONALLY ENCLOSED BY '\"' LINES TERMINATED BY '\\n'";
649
+
650
+ $columns = '';
651
+ for ( $i = 0, $len = count( self::$_log_columns ); $i < $len; $i ++ ) {
652
+ if ( $i > 0 ) {
653
+ $columns .= ', ';
654
+ }
655
+
656
+ $columns .= "'" . self::$_log_columns[ $i ] . "'";
657
+ }
658
+
659
+ $query = "SELECT {$columns} UNION ALL " . $query;
660
+
661
+ $result = $wpdb->query( $query );
662
+
663
+ if ( false === $result ) {
664
+ return false;
665
+ }
666
+
667
+ return rtrim( $upload_dir['url'], '/' ) . '/' . $filename;
668
+ }
669
+
670
+ /**
671
+ * @author Vova Feldman (@svovaf)
672
+ * @since 1.2.1.6
673
+ *
674
+ * @param string $filename
675
+ *
676
+ * @return string
677
+ */
678
+ public static function get_logs_download_url( $filename = '' ) {
679
+ $upload_dir = wp_upload_dir();
680
+ if ( empty( $filename ) ) {
681
+ $filename = 'fs-logs-' . date( 'Y-m-d_H-i-s', WP_FS__SCRIPT_START_TIME ) . '.csv';
682
+ }
683
+
684
+ return rtrim( $upload_dir['url'], '/' ) . $filename;
685
+ }
686
+
687
+ #endregion
688
+ }
freemius/includes/class-fs-plugin-updater.php ADDED
@@ -0,0 +1,683 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 object
32
+ * @since 1.1.8.1
33
+ */
34
+ private $_update_details;
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_valid_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
+ if ( $this->_fs->is_premium() && $this->is_correct_folder_name() ) {
88
+ add_filter( 'upgrader_post_install', array( &$this, '_maybe_update_folder_name' ), 10, 3 );
89
+ }
90
+ }
91
+
92
+ /**
93
+ * Capture plugin update row by turning output buffering.
94
+ *
95
+ * @author Vova Feldman (@svovaf)
96
+ * @since 1.1.6
97
+ */
98
+ function catch_plugin_update_row() {
99
+ ob_start();
100
+ }
101
+
102
+ /**
103
+ * Overrides default update message format with "renew your license" message.
104
+ *
105
+ * @author Vova Feldman (@svovaf)
106
+ * @since 1.1.6
107
+ *
108
+ * @param string $file
109
+ * @param array $plugin_data
110
+ */
111
+ function edit_and_echo_plugin_update_row( $file, $plugin_data ) {
112
+ $plugin_update_row = ob_get_clean();
113
+
114
+ $current = get_site_transient( 'update_plugins' );
115
+ if ( ! isset( $current->response[ $file ] ) ) {
116
+ echo $plugin_update_row;
117
+
118
+ return;
119
+ }
120
+
121
+ $r = $current->response[ $file ];
122
+
123
+ $plugin_update_row = preg_replace(
124
+ '/(\<div.+>)(.+)(\<a.+\<a.+)\<\/div\>/is',
125
+ '$1 $2 ' . sprintf(
126
+ $this->_fs->get_text( 'renew-license-now' ),
127
+ '<a href="' . $this->_fs->pricing_url() . '">', '</a>',
128
+ $r->new_version ) .
129
+ '$4',
130
+ $plugin_update_row
131
+ );
132
+
133
+ echo $plugin_update_row;
134
+ }
135
+
136
+ /**
137
+ * Since WP version 3.6, a new security feature was added that denies access to repository with a local ip.
138
+ * During development mode we want to be able updating plugin versions via our localhost repository. This
139
+ * filter white-list all domains including "api.freemius".
140
+ *
141
+ * @link http://www.emanueletessore.com/wordpress-download-failed-valid-url-provided/
142
+ *
143
+ * @author Vova Feldman (@svovaf)
144
+ * @since 1.0.4
145
+ *
146
+ * @param bool $allow
147
+ * @param string $host
148
+ * @param string $url
149
+ *
150
+ * @return bool
151
+ */
152
+ function http_request_host_is_external_filter( $allow, $host, $url ) {
153
+ return ( false !== strpos( $host, 'freemius' ) ) ? true : $allow;
154
+ }
155
+
156
+ /**
157
+ * Check for Updates at the defined API endpoint and modify the update array.
158
+ *
159
+ * This function dives into the update api just when WordPress creates its update array,
160
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
161
+ * It is reassembled from parts of the native WordPress plugin update code.
162
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
163
+ *
164
+ * @author Vova Feldman (@svovaf)
165
+ * @since 1.0.4
166
+ *
167
+ * @uses FS_Api
168
+ *
169
+ * @param object $transient_data Update array build by WordPress.
170
+ *
171
+ * @return object Modified update array with custom plugin data.
172
+ */
173
+ function pre_set_site_transient_update_plugins_filter( $transient_data ) {
174
+ $this->_logger->entrance();
175
+
176
+ if ( empty( $transient_data ) ||
177
+ defined( 'WP_FS__UNINSTALL_MODE' )
178
+ ) {
179
+ return $transient_data;
180
+ }
181
+
182
+ if ( ! isset( $this->_update_details ) ) {
183
+ // Get plugin's newest update.
184
+ $new_version = $this->_fs->get_update( false, false );
185
+
186
+ $this->_update_details = false;
187
+
188
+ if ( is_object( $new_version ) ) {
189
+ $this->_logger->log( 'Found newer plugin version ' . $new_version->version );
190
+
191
+ $plugin_details = new stdClass();
192
+ $plugin_details->slug = $this->_fs->get_slug();
193
+ $plugin_details->new_version = $new_version->version;
194
+ $plugin_details->url = WP_FS__ADDRESS;
195
+ $plugin_details->package = $new_version->url;
196
+ $plugin_details->plugin = $this->_fs->get_plugin_basename();
197
+
198
+ /**
199
+ * Cache plugin details locally since set_site_transient( 'update_plugins' )
200
+ * called multiple times and the non wp.org plugins are filtered after the
201
+ * call to .org.
202
+ *
203
+ * @since 1.1.8.1
204
+ */
205
+ $this->_update_details = $plugin_details;
206
+ }
207
+ }
208
+
209
+ if ( is_object( $this->_update_details ) ) {
210
+ // Add plugin to transient data.
211
+ $transient_data->response[ $this->_fs->get_plugin_basename() ] = $this->_update_details;
212
+ }
213
+
214
+ return $transient_data;
215
+ }
216
+
217
+ /**
218
+ * Try to fetch plugin's info from .org repository.
219
+ *
220
+ * @author Vova Feldman (@svovaf)
221
+ * @since 1.0.5
222
+ *
223
+ * @param string $action
224
+ * @param object $args
225
+ *
226
+ * @return bool|mixed
227
+ */
228
+ static function _fetch_plugin_info_from_repository( $action, $args ) {
229
+ $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
230
+ if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
231
+ $url = set_url_scheme( $url, 'https' );
232
+ }
233
+
234
+ $args = array(
235
+ 'timeout' => 15,
236
+ 'body' => array(
237
+ 'action' => $action,
238
+ 'request' => serialize( $args )
239
+ )
240
+ );
241
+
242
+ $request = wp_remote_post( $url, $args );
243
+
244
+ if ( is_wp_error( $request ) ) {
245
+ return false;
246
+ }
247
+
248
+ $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
249
+
250
+ if ( ! is_object( $res ) && ! is_array( $res ) ) {
251
+ return false;
252
+ }
253
+
254
+ return $res;
255
+ }
256
+
257
+ /**
258
+ * Updates information on the "View version x.x details" page with custom data.
259
+ *
260
+ * @author Vova Feldman (@svovaf)
261
+ * @since 1.0.4
262
+ *
263
+ * @uses FS_Api
264
+ *
265
+ * @param object $data
266
+ * @param string $action
267
+ * @param mixed $args
268
+ *
269
+ * @return object
270
+ */
271
+ function plugins_api_filter( $data, $action = '', $args = null ) {
272
+ $this->_logger->entrance();
273
+
274
+ if ( ( 'plugin_information' !== $action ) ||
275
+ ! isset( $args->slug )
276
+ ) {
277
+ return $data;
278
+ }
279
+
280
+ $addon = false;
281
+ $is_addon = false;
282
+
283
+ if ( $this->_fs->get_slug() !== $args->slug ) {
284
+ $addon = $this->_fs->get_addon_by_slug( $args->slug );
285
+
286
+ if ( ! is_object( $addon ) ) {
287
+ return $data;
288
+ }
289
+
290
+ $is_addon = true;
291
+ }
292
+
293
+ $plugin_in_repo = false;
294
+ if ( ! $is_addon ) {
295
+ // Try to fetch info from .org repository.
296
+ $data = self::_fetch_plugin_info_from_repository( $action, $args );
297
+
298
+ $plugin_in_repo = ( false !== $data );
299
+ }
300
+
301
+ if ( ! $plugin_in_repo ) {
302
+ $data = $args;
303
+
304
+ // Fetch as much as possible info from local files.
305
+ $plugin_local_data = $this->_fs->get_plugin_data();
306
+ $data->name = $plugin_local_data['Name'];
307
+ $data->author = $plugin_local_data['Author'];
308
+ $data->sections = array(
309
+ 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
310
+ );
311
+
312
+ // @todo Store extra plugin info on Freemius or parse readme.txt markup.
313
+ /*$info = $this->_fs->get_api_site_scope()->call('/information.json');
314
+
315
+ if ( !isset($info->error) ) {
316
+ $data = $info;
317
+ }*/
318
+ }
319
+
320
+ // Get plugin's newest update.
321
+ $new_version = $this->get_latest_download_details( $is_addon ? $addon->id : false );
322
+
323
+ if ( ! is_object( $new_version ) || empty( $new_version->version ) ) {
324
+ $data->version = $this->_fs->get_plugin_version();
325
+ } else {
326
+ if ( $is_addon ) {
327
+ $data->name = $addon->title . ' ' . $this->_fs->get_text( 'addon' );
328
+ $data->slug = $addon->slug;
329
+ $data->url = WP_FS__ADDRESS;
330
+ $data->package = $new_version->url;
331
+ }
332
+
333
+ if ( ! $plugin_in_repo ) {
334
+ $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
335
+ $data->requires = $new_version->requires_platform_version;
336
+ $data->tested = $new_version->tested_up_to_version;
337
+ }
338
+
339
+ $data->version = $new_version->version;
340
+ $data->download_link = $new_version->url;
341
+ }
342
+
343
+ return $data;
344
+ }
345
+
346
+ /**
347
+ * @author Vova Feldman (@svovaf)
348
+ * @since 1.2.1.7
349
+ *
350
+ * @param number|bool $addon_id
351
+ *
352
+ * @return object
353
+ */
354
+ private function get_latest_download_details( $addon_id = false ) {
355
+ return $this->_fs->_fetch_latest_version( $addon_id );
356
+ }
357
+
358
+ /**
359
+ * Checks if a given basename has a matching folder name
360
+ * with the current context plugin.
361
+ *
362
+ * @author Vova Feldman (@svovaf)
363
+ * @since 1.2.1.6
364
+ *
365
+ * @param string $basename Current plugin's basename.
366
+ *
367
+ * @return bool
368
+ */
369
+ private function is_correct_folder_name( $basename = '' ) {
370
+ if ( empty( $basename ) ) {
371
+ $basename = $this->_fs->get_plugin_basename();
372
+ }
373
+
374
+ return ( $this->_fs->get_target_folder_name() != trim( dirname( $basename ), '/\\' ) );
375
+ }
376
+
377
+ /**
378
+ * This is a special after upgrade handler for migrating modules
379
+ * that didn't use the '-premium' suffix folder structure before
380
+ * the migration.
381
+ *
382
+ * @author Vova Feldman (@svovaf)
383
+ * @since 1.2.1.6
384
+ *
385
+ * @param bool $response Install response.
386
+ * @param array $hook_extra Extra arguments passed to hooked filters.
387
+ * @param array $result Installation result data.
388
+ *
389
+ * @return bool
390
+ */
391
+ function _maybe_update_folder_name( $response, $hook_extra, $result ) {
392
+ $basename = $this->_fs->get_plugin_basename();
393
+
394
+ if ( true !== $response ||
395
+ empty( $hook_extra ) ||
396
+ empty( $hook_extra['plugin'] ) ||
397
+ $basename !== $hook_extra['plugin']
398
+ ) {
399
+ return $response;
400
+ }
401
+
402
+ $active_plugins_basenames = get_option( 'active_plugins' );
403
+
404
+ for ( $i = 0, $len = count( $active_plugins_basenames ); $i < $len; $i ++ ) {
405
+ if ( $basename === $active_plugins_basenames[ $i ] ) {
406
+ // Get filename including extension.
407
+ $filename = basename( $basename );
408
+
409
+ $new_basename = plugin_basename(
410
+ trailingslashit( $this->_fs->get_slug() . ( $this->_fs->is_premium() ? '-premium' : '' ) ) .
411
+ $filename
412
+ );
413
+
414
+ // Verify that the expected correct path exists.
415
+ if ( file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $new_basename ) ) ) {
416
+ // Override active plugin name.
417
+ $active_plugins_basenames[ $i ] = $new_basename;
418
+ update_option( 'active_plugins', $active_plugins_basenames );
419
+ }
420
+
421
+ break;
422
+ }
423
+ }
424
+
425
+ return $response;
426
+ }
427
+
428
+ #----------------------------------------------------------------------------------
429
+ #region Auto Activation
430
+ #----------------------------------------------------------------------------------
431
+
432
+ /**
433
+ * Installs and active a plugin when explicitly requested that from a 3rd party service.
434
+ *
435
+ * This logic was inspired by the TGMPA GPL licensed library by Thomas Griffin.
436
+ *
437
+ * @link http://tgmpluginactivation.com/
438
+ *
439
+ * @author Vova Feldman
440
+ * @since 1.2.1.7
441
+ *
442
+ * @link https://make.wordpress.org/plugins/2017/03/16/clarification-of-guideline-8-executable-code-and-installs/
443
+ *
444
+ * @uses WP_Filesystem
445
+ * @uses WP_Error
446
+ * @uses WP_Upgrader
447
+ * @uses Plugin_Upgrader
448
+ * @uses Plugin_Installer_Skin
449
+ * @uses Plugin_Upgrader_Skin
450
+ *
451
+ * @param number|bool $plugin_id
452
+ *
453
+ * @return array
454
+ */
455
+ function install_and_activate_plugin( $plugin_id = false ) {
456
+ if ( ! empty( $plugin_id ) && ! FS_Plugin::is_valid_id( $plugin_id ) ) {
457
+ // Invalid plugin ID.
458
+ return array(
459
+ 'message' => $this->_fs->get_text( 'auto-install-error-invalid-id' ),
460
+ 'code' => 'invalid_module_id',
461
+ );
462
+ }
463
+
464
+ $is_addon = false;
465
+ if ( FS_Plugin::is_valid_id( $plugin_id ) &&
466
+ $plugin_id != $this->_fs->get_id()
467
+ ) {
468
+ $addon = $this->_fs->get_addon( $plugin_id );
469
+
470
+ if ( ! is_object( $addon ) ) {
471
+ // Invalid add-on ID.
472
+ return array(
473
+ 'message' => $this->_fs->get_text( 'auto-install-error-invalid-id' ),
474
+ 'code' => 'invalid_module_id',
475
+ );
476
+ }
477
+
478
+ $slug = $addon->slug;
479
+ $title = $addon->title . ' ' . $this->_fs->get_text( 'addon' );
480
+
481
+ $is_addon = true;
482
+ } else {
483
+ $slug = $this->_fs->get_slug();
484
+ $title = $this->_fs->get_plugin_title() .
485
+ ( $this->_fs->is_addon() ? ' ' . $this->_fs->get_text( 'addon' ) : '' );
486
+ }
487
+
488
+ if ( $this->is_premium_plugin_active( $plugin_id ) ) {
489
+ // Premium version already activated.
490
+ return array(
491
+ 'message' => $this->_fs->get_text(
492
+ $is_addon ?
493
+ 'auto-install-error-premium-addon-activated' :
494
+ 'auto-install-error-premium-activated'
495
+ ),
496
+ 'code' => 'premium_installed',
497
+ );
498
+ }
499
+
500
+ $latest_version = $this->get_latest_download_details( $plugin_id );
501
+ $target_folder = "{$slug}-premium";
502
+
503
+ // Prep variables for Plugin_Installer_Skin class.
504
+ $extra = array();
505
+ $extra['slug'] = $target_folder;
506
+ $source = $latest_version->url;
507
+ $api = null;
508
+
509
+ $install_url = add_query_arg(
510
+ array(
511
+ 'action' => 'install-plugin',
512
+ 'plugin' => urlencode( $slug ),
513
+ ),
514
+ 'update.php'
515
+ );
516
+
517
+ if ( ! class_exists( 'Plugin_Upgrader', false ) ) {
518
+ // Include required resources for the installation.
519
+ require_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
520
+ }
521
+
522
+ $skin_args = array(
523
+ 'type' => 'web',
524
+ 'title' => sprintf( fs_text( 'installing-plugin-x', $slug ), $title ),
525
+ 'url' => esc_url_raw( $install_url ),
526
+ 'nonce' => 'install-plugin_' . $slug,
527
+ 'plugin' => '',
528
+ 'api' => $api,
529
+ 'extra' => $extra,
530
+ );
531
+
532
+ // $skin = new Automatic_Upgrader_Skin( $skin_args );
533
+ // $skin = new Plugin_Installer_Skin( $skin_args );
534
+ $skin = new WP_Ajax_Upgrader_Skin( $skin_args );
535
+
536
+ // Create a new instance of Plugin_Upgrader.
537
+ $upgrader = new Plugin_Upgrader( $skin );
538
+
539
+ // Perform the action and install the plugin from the $source urldecode().
540
+ add_filter( 'upgrader_source_selection', array( &$this, '_maybe_adjust_source_dir' ), 1, 3 );
541
+
542
+ $install_result = $upgrader->install( $source );
543
+
544
+ remove_filter( 'upgrader_source_selection', array( &$this, '_maybe_adjust_source_dir' ), 1 );
545
+
546
+ if ( is_wp_error( $install_result ) ) {
547
+ return array(
548
+ 'message' => $install_result->get_error_message(),
549
+ 'code' => $install_result->get_error_code(),
550
+ );
551
+ } elseif ( is_wp_error( $skin->result ) ) {
552
+ return array(
553
+ 'message' => $skin->result->get_error_message(),
554
+ 'code' => $skin->result->get_error_code(),
555
+ );
556
+ } elseif ( $skin->get_errors()->get_error_code() ) {
557
+ return array(
558
+ 'message' => $skin->get_error_messages(),
559
+ 'code' => 'unknown',
560
+ );
561
+ } elseif ( is_null( $install_result ) ) {
562
+ global $wp_filesystem;
563
+
564
+ $error_code = 'unable_to_connect_to_filesystem';
565
+ $error_message = __( 'Unable to connect to the filesystem. Please confirm your credentials.' );
566
+
567
+ // Pass through the error from WP_Filesystem if one was raised.
568
+ if ( $wp_filesystem instanceof WP_Filesystem_Base &&
569
+ is_wp_error( $wp_filesystem->errors ) &&
570
+ $wp_filesystem->errors->get_error_code()
571
+ ) {
572
+ $error_message = $wp_filesystem->errors->get_error_message();
573
+ }
574
+
575
+ return array(
576
+ 'message' => $error_message,
577
+ 'code' => $error_code,
578
+ );
579
+ }
580
+
581
+ // Grab the full path to the main plugin's file.
582
+ $plugin_activate = $upgrader->plugin_info();
583
+
584
+ // Try to activate the plugin.
585
+ $activation_result = $this->try_activate_plugin( $plugin_activate );
586
+
587
+ if ( is_wp_error( $activation_result ) ) {
588
+ return array(
589
+ 'message' => $activation_result->get_error_message(),
590
+ 'code' => $activation_result->get_error_code(),
591
+ );
592
+ }
593
+
594
+ return $skin->get_upgrade_messages();
595
+ }
596
+
597
+ /**
598
+ * Tries to activate a plugin. If fails, returns the error.
599
+ *
600
+ * @author Vova Feldman
601
+ * @since 1.2.1.7
602
+ *
603
+ * @param string $file_path Path within wp-plugins/ to main plugin file.
604
+ * This determines the styling of the output messages.
605
+ *
606
+ * @return bool|WP_Error
607
+ */
608
+ protected function try_activate_plugin( $file_path ) {
609
+ $activate = activate_plugin( $file_path );
610
+
611
+ return is_wp_error( $activate ) ?
612
+ $activate :
613
+ true;
614
+ }
615
+
616
+ /**
617
+ * Check if a premium module version is already active.
618
+ *
619
+ * @author Vova Feldman
620
+ * @since 1.2.1.7
621
+ *
622
+ * @param number|bool $plugin_id
623
+ *
624
+ * @return bool
625
+ */
626
+ private function is_premium_plugin_active( $plugin_id = false ) {
627
+ if ( $plugin_id != $this->_fs->get_id() ) {
628
+ return $this->_fs->is_addon_activated( $plugin_id, true );
629
+ }
630
+
631
+ return is_plugin_active( $this->_fs->premium_plugin_basename() );
632
+ }
633
+
634
+ /**
635
+ * Adjust the plugin directory name if necessary.
636
+ * Assumes plugin has a folder (not a single file plugin).
637
+ *
638
+ * The final destination directory of a plugin is based on the subdirectory name found in the
639
+ * (un)zipped source. In some cases this subdirectory name is not the same as the expected
640
+ * slug and the plugin will not be recognized as installed. This is fixed by adjusting
641
+ * the temporary unzipped source subdirectory name to the expected plugin slug.
642
+ *
643
+ * @author Vova Feldman
644
+ * @since 1.2.1.7
645
+ *
646
+ * @param string $source Path to upgrade/zip-file-name.tmp/subdirectory/.
647
+ * @param string $remote_source Path to upgrade/zip-file-name.tmp.
648
+ * @param \WP_Upgrader $upgrader Instance of the upgrader which installs the plugin.
649
+ *
650
+ * @return string|WP_Error
651
+ */
652
+ function _maybe_adjust_source_dir( $source, $remote_source, $upgrader ) {
653
+ if ( ! is_object( $GLOBALS['wp_filesystem'] ) ) {
654
+ return $source;
655
+ }
656
+
657
+ // Figure out what the slug is supposed to be.
658
+ $desired_slug = $upgrader->skin->options['extra']['slug'];
659
+
660
+ $subdir_name = untrailingslashit( str_replace( trailingslashit( $remote_source ), '', $source ) );
661
+
662
+ if ( ! empty( $subdir_name ) && $subdir_name !== $desired_slug ) {
663
+ $from_path = untrailingslashit( $source );
664
+ $to_path = trailingslashit( $remote_source ) . $desired_slug;
665
+
666
+ if ( true === $GLOBALS['wp_filesystem']->move( $from_path, $to_path ) ) {
667
+ return trailingslashit( $to_path );
668
+ } else {
669
+ return new WP_Error(
670
+ 'rename_failed',
671
+ $this->_fs->get_text( 'module-package-rename-failure' ),
672
+ array(
673
+ 'found' => $subdir_name,
674
+ 'expected' => $desired_slug
675
+ ) );
676
+ }
677
+ }
678
+
679
+ return $source;
680
+ }
681
+
682
+ #endregion
683
+ }
freemius/includes/class-fs-security.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
16
+ * Class FS_Security
17
+ */
18
+ class FS_Security {
19
+ /**
20
+ * @var FS_Security
21
+ * @since 1.0.3
22
+ */
23
+ private static $_instance;
24
+ /**
25
+ * @var FS_Logger
26
+ * @since 1.0.3
27
+ */
28
+ private static $_logger;
29
+
30
+ /**
31
+ * @return \FS_Security
32
+ */
33
+ public static function instance() {
34
+ if ( ! isset( self::$_instance ) ) {
35
+ self::$_instance = new FS_Security();
36
+ self::$_logger = FS_Logger::get_logger(
37
+ WP_FS__SLUG,
38
+ WP_FS__DEBUG_SDK,
39
+ WP_FS__ECHO_DEBUG_SDK
40
+ );
41
+ }
42
+
43
+ return self::$_instance;
44
+ }
45
+
46
+ private function __construct() {
47
+ }
48
+
49
+ /**
50
+ * @param \FS_Scope_Entity $entity
51
+ * @param int $timestamp
52
+ * @param string $action
53
+ *
54
+ * @return string
55
+ */
56
+ function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
57
+ return md5(
58
+ $timestamp .
59
+ $entity->id .
60
+ $entity->secret_key .
61
+ $entity->public_key .
62
+ $action
63
+ );
64
+ }
65
+
66
+ /**
67
+ * @param \FS_Scope_Entity $entity
68
+ * @param int|bool $timestamp
69
+ * @param string $action
70
+ *
71
+ * @return array
72
+ */
73
+ function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
74
+ if ( false === $timestamp ) {
75
+ $timestamp = time();
76
+ }
77
+
78
+ return array(
79
+ 's_ctx_type' => $entity->get_type(),
80
+ 's_ctx_id' => $entity->id,
81
+ 's_ctx_ts' => $timestamp,
82
+ 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
83
+ );
84
+ }
85
+ }
freemius/includes/debug/class-fs-debug-bar-panel.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_text( '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/plugins-themes-sync.php' ) ?>
59
+ <br>
60
+ <?php fs_require_template( '/debug/logger.php' ) ?>
61
+ </div>
62
+ <?php
63
+ }
64
+ }
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_text( 'Freemius API' ),
42
+ Freemius_Debug_Bar_Panel::requests_count() . ' ' . fs_text( '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/debug/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/entities/class-fs-billing.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius for EDD Add-On
4
+ * @copyright Copyright (c) 2016, 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_Billing extends FS_Entity {
14
+
15
+ #region Properties
16
+
17
+ /**
18
+ * @var int
19
+ */
20
+ public $entity_id;
21
+ /**
22
+ * @var string (Enum) Linked entity type. One of: developer, plugin, user, install
23
+ */
24
+ public $entity_type;
25
+ /**
26
+ * @var string
27
+ */
28
+ public $business_name;
29
+ /**
30
+ * @var string
31
+ */
32
+ public $first;
33
+ /**
34
+ * @var string
35
+ */
36
+ public $last;
37
+ /**
38
+ * @var string
39
+ */
40
+ public $email;
41
+ /**
42
+ * @var string
43
+ */
44
+ public $phone;
45
+ /**
46
+ * @var string
47
+ */
48
+ public $website;
49
+ /**
50
+ * @var string Tax or VAT ID.
51
+ */
52
+ public $tax_id;
53
+ /**
54
+ * @var string
55
+ */
56
+ public $address_street;
57
+ /**
58
+ * @var string
59
+ */
60
+ public $address_apt;
61
+ /**
62
+ * @var string
63
+ */
64
+ public $address_city;
65
+ /**
66
+ * @var string
67
+ */
68
+ public $address_country;
69
+ /**
70
+ * @var string Two chars country code.
71
+ */
72
+ public $address_country_code;
73
+ /**
74
+ * @var string
75
+ */
76
+ public $address_state;
77
+ /**
78
+ * @var number Numeric ZIP code (cab be with leading zeros).
79
+ */
80
+ public $address_zip;
81
+
82
+ #endregion Properties
83
+
84
+
85
+ /**
86
+ * @param object|bool $event
87
+ */
88
+ function __construct( $event = false ) {
89
+ parent::__construct( $event );
90
+ }
91
+
92
+ static function get_type() {
93
+ return 'billing';
94
+ }
95
+ }
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|object $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-payment.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @package Freemius
4
+ * @copyright Copyright (c) 2016, 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_Payment 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 $install_id;
29
+ /**
30
+ * @var number
31
+ */
32
+ public $subscription_id;
33
+ /**
34
+ * @var number
35
+ */
36
+ public $plan_id;
37
+ /**
38
+ * @var number
39
+ */
40
+ public $license_id;
41
+ /**
42
+ * @var float
43
+ */
44
+ public $gross;
45
+ /**
46
+ * @var number
47
+ */
48
+ public $bound_payment_id;
49
+ /**
50
+ * @var string
51
+ */
52
+ public $external_id;
53
+ /**
54
+ * @var string
55
+ */
56
+ public $gateway;
57
+ /**
58
+ * @var string ISO 3166-1 alpha-2 - two-letter country code.
59
+ *
60
+ * @link http://www.wikiwand.com/en/ISO_3166-1_alpha-2
61
+ */
62
+ public $country_code;
63
+ /**
64
+ * @var string
65
+ */
66
+ public $vat_id;
67
+ /**
68
+ * @var float Actual Tax / VAT in $$$
69
+ */
70
+ public $vat;
71
+
72
+ #endregion Properties
73
+
74
+ /**
75
+ * @param object|bool $payment
76
+ */
77
+ function __construct( $payment = false ) {
78
+ parent::__construct( $payment );
79
+ }
80
+
81
+ static function get_type() {
82
+ return 'payment';
83
+ }
84
+
85
+ /**
86
+ * @author Vova Feldman (@svovaf)
87
+ * @since 1.0.0
88
+ *
89
+ * @return bool
90
+ */
91
+ function is_refund() {
92
+ return ( parent::is_valid_id( $this->bound_payment_id ) && 0 > $this->gross );
93
+ }
94
+ }
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,224 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Class FS_Plugin_License
15
+ */
16
+ class FS_Plugin_License extends FS_Entity {
17
+
18
+ #region Properties
19
+
20
+ /**
21
+ * @var number
22
+ */
23
+ public $plugin_id;
24
+ /**
25
+ * @var number
26
+ */
27
+ public $user_id;
28
+ /**
29
+ * @var number
30
+ */
31
+ public $plan_id;
32
+ /**
33
+ * @var number
34
+ */
35
+ public $pricing_id;
36
+ /**
37
+ * @var int|null
38
+ */
39
+ public $quota;
40
+ /**
41
+ * @var int
42
+ */
43
+ public $activated;
44
+ /**
45
+ * @var int
46
+ */
47
+ public $activated_local;
48
+ /**
49
+ * @var string
50
+ */
51
+ public $expiration;
52
+ /**
53
+ * @var string
54
+ */
55
+ public $secret_key;
56
+ /**
57
+ * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
58
+ * license.
59
+ */
60
+ public $is_free_localhost;
61
+ /**
62
+ * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
63
+ * block updates and support.
64
+ */
65
+ public $is_block_features;
66
+ /**
67
+ * @var bool
68
+ */
69
+ public $is_cancelled;
70
+
71
+ #endregion Properties
72
+
73
+ /**
74
+ * @param stdClass|bool $license
75
+ */
76
+ function __construct( $license = false ) {
77
+ parent::__construct( $license );
78
+ }
79
+
80
+ /**
81
+ * Get entity type.
82
+ *
83
+ * @return string
84
+ */
85
+ static function get_type() {
86
+ return 'license';
87
+ }
88
+
89
+ /**
90
+ * Check how many site activations left.
91
+ *
92
+ * @author Vova Feldman (@svovaf)
93
+ * @since 1.0.5
94
+ *
95
+ * @return int
96
+ */
97
+ function left() {
98
+ if ( ! $this->is_active() || $this->is_expired() ) {
99
+ return 0;
100
+ }
101
+
102
+ if ( $this->is_unlimited() ) {
103
+ return 999;
104
+ }
105
+
106
+ return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
107
+ }
108
+
109
+ /**
110
+ * Check if single site license.
111
+ *
112
+ * @author Vova Feldman (@svovaf)
113
+ * @since 1.1.8.1
114
+ *
115
+ * @return bool
116
+ */
117
+ function is_single_site() {
118
+ return ( is_numeric( $this->quota ) && 1 == $this->quota );
119
+ }
120
+
121
+ /**
122
+ * @author Vova Feldman (@svovaf)
123
+ * @since 1.0.5
124
+ *
125
+ * @return bool
126
+ */
127
+ function is_expired() {
128
+ return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
129
+ }
130
+
131
+ /**
132
+ * Check if license is not expired.
133
+ *
134
+ * @author Vova Feldman (@svovaf)
135
+ * @since 1.2.1
136
+ *
137
+ * @return bool
138
+ */
139
+ function is_valid() {
140
+ return ! $this->is_expired();
141
+ }
142
+
143
+ /**
144
+ * @author Vova Feldman (@svovaf)
145
+ * @since 1.0.6
146
+ *
147
+ * @return bool
148
+ */
149
+ function is_lifetime() {
150
+ return is_null( $this->expiration );
151
+ }
152
+
153
+ /**
154
+ * @author Vova Feldman (@svovaf)
155
+ * @since 1.2.0
156
+ *
157
+ * @return bool
158
+ */
159
+ function is_unlimited() {
160
+ return is_null( $this->quota );
161
+ }
162
+
163
+ /**
164
+ * Check if license is fully utilized.
165
+ *
166
+ * @author Vova Feldman (@svovaf)
167
+ * @since 1.0.6
168
+ *
169
+ * @param bool $is_localhost
170
+ *
171
+ * @return bool
172
+ */
173
+ function is_utilized( $is_localhost = null ) {
174
+ if ( is_null( $is_localhost ) ) {
175
+ $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
176
+ }
177
+
178
+ if ( $this->is_unlimited() ) {
179
+ return false;
180
+ }
181
+
182
+ return ! ( $this->is_free_localhost && $is_localhost ) &&
183
+ ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
184
+ }
185
+
186
+ /**
187
+ * @author Vova Feldman (@svovaf)
188
+ * @since 1.2.1
189
+ *
190
+ * @return bool
191
+ */
192
+ function is_active() {
193
+ return ( ! $this->is_cancelled );
194
+ }
195
+
196
+ /**
197
+ * Check if license's plan features are enabled.
198
+ *
199
+ * - Either if plan not expired
200
+ * - If expired, based on the configuration to block features or not.
201
+ *
202
+ * @author Vova Feldman (@svovaf)
203
+ * @since 1.0.6
204
+ *
205
+ * @return bool
206
+ */
207
+ function is_features_enabled() {
208
+ return $this->is_active() && ( ! $this->is_block_features || ! $this->is_expired() );
209
+ }
210
+
211
+ /**
212
+ * Subscription considered to be new without any payments
213
+ * if the license expires in less than 24 hours
214
+ * from the license creation.
215
+ *
216
+ * @author Vova Feldman (@svovaf)
217
+ * @since 1.0.9
218
+ *
219
+ * @return bool
220
+ */
221
+ function is_first_payment_pending() {
222
+ return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
223
+ }
224
+ }
freemius/includes/entities/class-fs-plugin-plan.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Class FS_Plugin_Plan
15
+ *
16
+ * @property FS_Pricing[] $pricing
17
+ */
18
+ class FS_Plugin_Plan extends FS_Entity {
19
+
20
+ #region Properties
21
+
22
+ /**
23
+ * @var number
24
+ */
25
+ public $plugin_id;
26
+ /**
27
+ * @var string
28
+ */
29
+ public $name;
30
+ /**
31
+ * @var string
32
+ */
33
+ public $title;
34
+ /**
35
+ * @var string
36
+ */
37
+ public $description;
38
+ /**
39
+ * @var bool Defaults to true. If true, allow unlimited localhost installs with the same license.
40
+ */
41
+ public $is_free_localhost;
42
+ /**
43
+ * @var bool Defaults to true. If false, don't block features after license expiry - only block updates and
44
+ * support.
45
+ */
46
+ public $is_block_features;
47
+ /**
48
+ * @var int
49
+ */
50
+ public $license_type;
51
+ /**
52
+ * @var bool
53
+ */
54
+ public $is_https_support;
55
+ /**
56
+ * @var int Trial days.
57
+ */
58
+ public $trial_period;
59
+ /**
60
+ * @var string If true, require payment for trial.
61
+ */
62
+ public $is_require_subscription;
63
+ /**
64
+ * @var string Knowledge Base URL.
65
+ */
66
+ public $support_kb;
67
+ /**
68
+ * @var string Support Forum URL.
69
+ */
70
+ public $support_forum;
71
+ /**
72
+ * @var string Support email address.
73
+ */
74
+ public $support_email;
75
+ /**
76
+ * @var string Support phone.
77
+ */
78
+ public $support_phone;
79
+ /**
80
+ * @var string Support skype username.
81
+ */
82
+ public $support_skype;
83
+ /**
84
+ * @var bool Is personal success manager supported with the plan.
85
+ */
86
+ public $is_success_manager;
87
+ /**
88
+ * @var bool Is featured plan.
89
+ */
90
+ public $is_featured;
91
+
92
+ #endregion Properties
93
+
94
+ /**
95
+ * @param object|bool $plan
96
+ */
97
+ function __construct( $plan = false ) {
98
+ parent::__construct( $plan );
99
+
100
+ if ( is_object( $plan ) ) {
101
+ $this->name = strtolower( $plan->name );
102
+ }
103
+ }
104
+
105
+ static function get_type() {
106
+ return 'plan';
107
+ }
108
+
109
+ /**
110
+ * @author Vova Feldman (@svovaf)
111
+ * @since 1.0.9
112
+ *
113
+ * @return bool
114
+ */
115
+ function is_free() {
116
+ return ( 'free' === $this->name );
117
+ }
118
+
119
+ /**
120
+ * Checks if this plan supports "Technical Support".
121
+ *
122
+ * @author Leo Fajardo (leorw)
123
+ * @since 1.2.0
124
+ *
125
+ * @return bool
126
+ */
127
+ function has_technical_support() {
128
+ return ( ! empty( $this->support_email ) ||
129
+ ! empty( $this->support_skype ) ||
130
+ ! empty( $this->support_phone ) ||
131
+ ! empty( $this->is_success_manager )
132
+ );
133
+ }
134
+
135
+ /**
136
+ * @author Vova Feldman (@svovaf)
137
+ * @since 1.0.9
138
+ *
139
+ * @return bool
140
+ */
141
+ function has_trial() {
142
+ return ! $this->is_free() &&
143
+ is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
144
+ }
145
+ }
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,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @var string 'plugin' or 'theme'
29
+ */
30
+ public $type;
31
+
32
+ #region Install Specific Properties
33
+
34
+ /**
35
+ * @var string
36
+ */
37
+ public $file;
38
+ /**
39
+ * @var string
40
+ */
41
+ public $version;
42
+ /**
43
+ * @var bool
44
+ */
45
+ public $auto_update;
46
+ /**
47
+ * @var FS_Plugin_Info
48
+ */
49
+ public $info;
50
+ /**
51
+ * @since 1.0.9
52
+ *
53
+ * @var bool
54
+ */
55
+ public $is_premium;
56
+ /**
57
+ * @since 1.0.9
58
+ *
59
+ * @var bool
60
+ */
61
+ public $is_live;
62
+
63
+ #endregion Install Specific Properties
64
+
65
+ /**
66
+ * @param stdClass|bool $plugin
67
+ */
68
+ function __construct( $plugin = false ) {
69
+ parent::__construct( $plugin );
70
+
71
+ $this->is_premium = false;
72
+ $this->is_live = true;
73
+
74
+ if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
75
+ $this->info = new FS_Plugin_Info( $plugin->info );
76
+ }
77
+ }
78
+
79
+ /**
80
+ * Check if plugin is an add-on (has parent).
81
+ *
82
+ * @author Vova Feldman (@svovaf)
83
+ * @since 1.0.6
84
+ *
85
+ * @return bool
86
+ */
87
+ function is_addon() {
88
+ return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
89
+ }
90
+
91
+ static function get_type() {
92
+ return 'plugin';
93
+ }
94
+ }
freemius/includes/entities/class-fs-pricing.php ADDED
@@ -0,0 +1,141 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
51
+ /**
52
+ * @author Vova Feldman (@svovaf)
53
+ * @since 1.1.8
54
+ *
55
+ * @return bool
56
+ */
57
+ function has_monthly() {
58
+ return ( is_numeric( $this->monthly_price ) && $this->monthly_price > 0 );
59
+ }
60
+
61
+ /**
62
+ * @author Vova Feldman (@svovaf)
63
+ * @since 1.1.8
64
+ *
65
+ * @return bool
66
+ */
67
+ function has_annual() {
68
+ return ( is_numeric( $this->annual_price ) && $this->annual_price > 0 );
69
+ }
70
+
71
+ /**
72
+ * @author Vova Feldman (@svovaf)
73
+ * @since 1.1.8
74
+ *
75
+ * @return bool
76
+ */
77
+ function has_lifetime() {
78
+ return ( is_numeric( $this->lifetime_price ) && $this->lifetime_price > 0 );
79
+ }
80
+
81
+ /**
82
+ * Check if unlimited licenses pricing.
83
+ *
84
+ * @author Vova Feldman (@svovaf)
85
+ * @since 1.1.8
86
+ *
87
+ * @return bool
88
+ */
89
+ function is_unlimited() {
90
+ return is_null( $this->licenses );
91
+ }
92
+
93
+
94
+ /**
95
+ * Check if pricing has more than one billing cycle.
96
+ *
97
+ * @author Vova Feldman (@svovaf)
98
+ * @since 1.1.8
99
+ *
100
+ * @return bool
101
+ */
102
+ function is_multi_cycle() {
103
+ $cycles = 0;
104
+ if ( $this->has_monthly() ) {
105
+ $cycles ++;
106
+ }
107
+ if ( $this->has_annual() ) {
108
+ $cycles ++;
109
+ }
110
+ if ( $this->has_lifetime() ) {
111
+ $cycles ++;
112
+ }
113
+
114
+ return $cycles > 1;
115
+ }
116
+
117
+ /**
118
+ * Get annual over monthly discount.
119
+ *
120
+ * @author Vova Feldman (@svovaf)
121
+ * @since 1.1.8
122
+ *
123
+ * @return int
124
+ */
125
+ function annual_discount_percentage() {
126
+ return floor( $this->annual_savings() / ( $this->monthly_price * 12 * ( $this->is_unlimited() ? 1 : $this->licenses ) ) * 100 );
127
+ }
128
+
129
+ /**
130
+ * Get annual over monthly savings.
131
+ *
132
+ * @author Vova Feldman (@svovaf)
133
+ * @since 1.1.8
134
+ *
135
+ * @return float
136
+ */
137
+ function annual_savings() {
138
+ return ( $this->monthly_price * 12 - $this->annual_price ) * ( $this->is_unlimited() ? 1 : $this->licenses );
139
+ }
140
+
141
+ }
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,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * Freemius SDK version
56
+ *
57
+ * @author Leo Fajardo (@leorw)
58
+ * @since 1.2.2
59
+ *
60
+ * @var string SDK version (e.g.: 1.2.2)
61
+ */
62
+ public $sdk_version;
63
+ /**
64
+ * @var string Programming language version (e.g PHP version).
65
+ */
66
+ public $programming_language_version;
67
+ /**
68
+ * @var FS_Plugin_Plan $plan
69
+ */
70
+ public $plan;
71
+ /**
72
+ * @var number|null
73
+ */
74
+ public $license_id;
75
+ /**
76
+ * @var number|null
77
+ */
78
+ public $trial_plan_id;
79
+ /**
80
+ * @var string|null
81
+ */
82
+ public $trial_ends;
83
+ /**
84
+ * @since 1.0.9
85
+ *
86
+ * @var bool
87
+ */
88
+ public $is_premium = false;
89
+ /**
90
+ * @author Leo Fajardo (@leorw)
91
+ *
92
+ * @since 1.2.1.5
93
+ *
94
+ * @var bool
95
+ */
96
+ public $is_disconnected = false;
97
+
98
+ /**
99
+ * @param stdClass|bool $site
100
+ */
101
+ function __construct( $site = false ) {
102
+ $this->plan = new FS_Plugin_Plan();
103
+
104
+ parent::__construct( $site );
105
+
106
+ if ( is_object( $site ) ) {
107
+ $this->plan->id = $site->plan_id;
108
+ }
109
+
110
+ if ( ! is_bool( $this->is_disconnected ) ) {
111
+ $this->is_disconnected = false;
112
+ }
113
+ }
114
+
115
+ static function get_type() {
116
+ return 'install';
117
+ }
118
+
119
+ function is_localhost() {
120
+ // The server has no way to verify if localhost unless localhost appears in domain.
121
+ return WP_FS__IS_LOCALHOST_FOR_SERVER;
122
+ // return (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1');
123
+ }
124
+
125
+ /**
126
+ * Check if site in trial.
127
+ *
128
+ * @author Vova Feldman (@svovaf)
129
+ * @since 1.0.9
130
+ *
131
+ * @return bool
132
+ */
133
+ function is_trial() {
134
+ return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
135
+ }
136
+
137
+ /**
138
+ * Check if user already utilized the trial with the current install.
139
+ *
140
+ * @author Vova Feldman (@svovaf)
141
+ * @since 1.0.9
142
+ *
143
+ * @return bool
144
+ */
145
+ function is_trial_utilized() {
146
+ return is_numeric( $this->trial_plan_id );
147
+ }
148
+ }
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/entities/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/fs-core-functions.php ADDED
@@ -0,0 +1,629 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if ( ! function_exists( 'fs_dummy' ) ) {
14
+ function fs_dummy() {
15
+ }
16
+ }
17
+
18
+ /* Url.
19
+ --------------------------------------------------------------------------------------------*/
20
+ function fs_get_url_daily_cache_killer() {
21
+ return date( '\YY\Mm\Dd' );
22
+ }
23
+
24
+ /* Templates / Views.
25
+ --------------------------------------------------------------------------------------------*/
26
+ if ( ! function_exists( 'fs_get_template_path' ) ) {
27
+ function fs_get_template_path( $path ) {
28
+ return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
29
+ }
30
+
31
+ function fs_include_template( $path, &$params = null ) {
32
+ $VARS = &$params;
33
+ include fs_get_template_path( $path );
34
+ }
35
+
36
+ function fs_include_once_template( $path, &$params = null ) {
37
+ $VARS = &$params;
38
+ include_once fs_get_template_path( $path );
39
+ }
40
+
41
+ function fs_require_template( $path, &$params = null ) {
42
+ $VARS = &$params;
43
+ require fs_get_template_path( $path );
44
+ }
45
+
46
+ function fs_require_once_template( $path, &$params = null ) {
47
+ $VARS = &$params;
48
+ require_once fs_get_template_path( $path );
49
+ }
50
+
51
+ function fs_get_template( $path, &$params = null ) {
52
+ ob_start();
53
+
54
+ $VARS = &$params;
55
+ require fs_get_template_path( $path );
56
+
57
+ return ob_get_clean();
58
+ }
59
+ }
60
+
61
+ /* Scripts and styles including.
62
+ --------------------------------------------------------------------------------------------*/
63
+ function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
64
+ wp_enqueue_style( $handle, plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $media );
65
+ }
66
+
67
+ function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
68
+ wp_enqueue_script( $handle, plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $in_footer );
69
+ }
70
+
71
+ function fs_img_url( $path, $img_dir = WP_FS__DIR_IMG ) {
72
+ return plugins_url( plugin_basename( $img_dir . '/' . trim( $path, '/' ) ) );
73
+ }
74
+
75
+ /* Request handlers.
76
+ --------------------------------------------------------------------------------------------*/
77
+ /**
78
+ * @param string $key
79
+ * @param mixed $def
80
+ * @param string|bool $type Since 1.2.1.7 - when set to 'get' will look for the value passed via querystring, when
81
+ * set to 'post' will look for the value passed via the POST request's body, otherwise,
82
+ * will check if the parameter was passed in any of the two.
83
+ *
84
+ * @return mixed
85
+ */
86
+ function fs_request_get( $key, $def = false, $type = false ) {
87
+ if ( is_string( $type ) ) {
88
+ $type = strtolower( $type );
89
+ }
90
+
91
+ switch ( $type ) {
92
+ case 'post':
93
+ $value = isset( $_POST[ $key ] ) ? $_POST[ $key ] : $def;
94
+ break;
95
+ case 'get':
96
+ $value = isset( $_GET[ $key ] ) ? $_GET[ $key ] : $def;
97
+ break;
98
+ default:
99
+ $value = isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
100
+ break;
101
+ }
102
+
103
+ return $value;
104
+ }
105
+
106
+ function fs_request_has( $key ) {
107
+ return isset( $_REQUEST[ $key ] );
108
+ }
109
+
110
+ function fs_request_get_bool( $key, $def = false ) {
111
+ if ( ! isset( $_REQUEST[ $key ] ) ) {
112
+ return $def;
113
+ }
114
+
115
+ if ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) {
116
+ return true;
117
+ }
118
+
119
+ if ( 0 == $_REQUEST[ $key ] || 'false' === strtolower( $_REQUEST[ $key ] ) ) {
120
+ return false;
121
+ }
122
+
123
+ return $def;
124
+ }
125
+
126
+ function fs_request_is_post() {
127
+ return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
128
+ }
129
+
130
+ function fs_request_is_get() {
131
+ return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
132
+ }
133
+
134
+ function fs_get_action( $action_key = 'action' ) {
135
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
136
+ return strtolower( $_REQUEST[ $action_key ] );
137
+ }
138
+
139
+ if ( 'action' == $action_key ) {
140
+ $action_key = 'fs_action';
141
+
142
+ if ( ! empty( $_REQUEST[ $action_key ] ) ) {
143
+ return strtolower( $_REQUEST[ $action_key ] );
144
+ }
145
+ }
146
+
147
+ return false;
148
+ }
149
+
150
+ function fs_request_is_action( $action, $action_key = 'action' ) {
151
+ return ( strtolower( $action ) === fs_get_action( $action_key ) );
152
+ }
153
+
154
+ /**
155
+ * @author Vova Feldman (@svovaf)
156
+ * @since 1.0.0
157
+ *
158
+ * @since 1.2.1.5 Allow nonce verification.
159
+ *
160
+ * @param string $action
161
+ * @param string $action_key
162
+ * @param string $nonce_key
163
+ *
164
+ * @return bool
165
+ */
166
+ function fs_request_is_action_secure(
167
+ $action,
168
+ $action_key = 'action',
169
+ $nonce_key = 'nonce'
170
+ ) {
171
+ if ( strtolower( $action ) !== fs_get_action( $action_key ) ) {
172
+ return false;
173
+ }
174
+
175
+ $nonce = ! empty( $_REQUEST[ $nonce_key ] ) ?
176
+ $_REQUEST[ $nonce_key ] :
177
+ '';
178
+
179
+ if ( empty( $nonce ) ||
180
+ ( false === wp_verify_nonce( $nonce, $action ) )
181
+ ) {
182
+ return false;
183
+ }
184
+
185
+ return true;
186
+ }
187
+
188
+ function fs_is_plugin_page( $page_slug ) {
189
+ return ( is_admin() && $page_slug === fs_request_get('page') );
190
+ }
191
+
192
+ /* Core UI.
193
+ --------------------------------------------------------------------------------------------*/
194
+ /**
195
+ * @param string $slug
196
+ * @param string $page
197
+ * @param string $action
198
+ * @param string $title
199
+ * @param array $params
200
+ * @param bool $is_primary
201
+ * @param string|bool $icon_class Optional class for an icon (since 1.1.7).
202
+ * @param string|bool $confirmation Optional confirmation message before submit (since 1.1.7).
203
+ * @param string $method Since 1.1.7
204
+ *
205
+ * @uses fs_ui_get_action_button()
206
+ */
207
+ function fs_ui_action_button(
208
+ $slug,
209
+ $page,
210
+ $action,
211
+ $title,
212
+ $params = array(),
213
+ $is_primary = true,
214
+ $icon_class = false,
215
+ $confirmation = false,
216
+ $method = 'GET'
217
+ ) {
218
+ echo fs_ui_get_action_button(
219
+ $slug,
220
+ $page,
221
+ $action,
222
+ $title,
223
+ $params,
224
+ $is_primary,
225
+ $icon_class,
226
+ $confirmation,
227
+ $method
228
+ );
229
+ }
230
+
231
+ /**
232
+ * @author Vova Feldman (@svovaf)
233
+ * @since 1.1.7
234
+ *
235
+ * @param string $slug
236
+ * @param string $page
237
+ * @param string $action
238
+ * @param string $title
239
+ * @param array $params
240
+ * @param bool $is_primary
241
+ * @param string|bool $icon_class Optional class for an icon.
242
+ * @param string|bool $confirmation Optional confirmation message before submit.
243
+ * @param string $method
244
+ *
245
+ * @return string
246
+ */
247
+ function fs_ui_get_action_button(
248
+ $slug,
249
+ $page,
250
+ $action,
251
+ $title,
252
+ $params = array(),
253
+ $is_primary = true,
254
+ $icon_class = false,
255
+ $confirmation = false,
256
+ $method = 'GET'
257
+ ) {
258
+ // Prepend icon (if set).
259
+ $title = ( is_string( $icon_class ) ? '<i class="' . $icon_class . '"></i> ' : '' ) . $title;
260
+
261
+ if ( is_string( $confirmation ) ) {
262
+ 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>',
263
+ freemius( $slug )->_get_admin_page_url( $page, $params ),
264
+ $method,
265
+ $action,
266
+ wp_nonce_field( $action, '_wpnonce', true, false ),
267
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
268
+ $confirmation,
269
+ $title
270
+ );
271
+ } else if ( 'GET' !== strtoupper( $method ) ) {
272
+ 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>',
273
+ freemius( $slug )->_get_admin_page_url( $page, $params ),
274
+ $method,
275
+ $action,
276
+ wp_nonce_field( $action, '_wpnonce', true, false ),
277
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
278
+ $title
279
+ );
280
+ } else {
281
+ return sprintf( '<a href="%s" class="%s">%s</a></form>',
282
+ wp_nonce_url( freemius( $slug )->_get_admin_page_url( $page, array_merge( $params, array( 'fs_action' => $action ) ) ), $action ),
283
+ 'button' . ( $is_primary ? ' button-primary' : '' ),
284
+ $title
285
+ );
286
+ }
287
+ }
288
+
289
+ function fs_ui_action_link( $slug, $page, $action, $title, $params = array() ) {
290
+ ?><a class=""
291
+ 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
292
+ }
293
+
294
+ /*function fs_error_handler($errno, $errstr, $errfile, $errline)
295
+ {
296
+ if (false === strpos($errfile, 'freemius/'))
297
+ {
298
+ // @todo Dump Freemius errors to local log.
299
+ }
300
+
301
+ // switch ($errno) {
302
+ // case E_USER_ERROR:
303
+ // break;
304
+ // case E_WARNING:
305
+ // case E_USER_WARNING:
306
+ // break;
307
+ // case E_NOTICE:
308
+ // case E_USER_NOTICE:
309
+ // break;
310
+ // default:
311
+ // break;
312
+ // }
313
+ }
314
+
315
+ set_error_handler('fs_error_handler');*/
316
+
317
+ if ( ! function_exists( 'fs_nonce_url' ) ) {
318
+ /**
319
+ * Retrieve URL with nonce added to URL query.
320
+ *
321
+ * Originally was using `wp_nonce_url()` but the new version
322
+ * changed the return value to escaped URL, that's not the expected
323
+ * behaviour.
324
+ *
325
+ * @author Vova Feldman (@svovaf)
326
+ * @since ~1.1.3
327
+ *
328
+ * @param string $actionurl URL to add nonce action.
329
+ * @param int|string $action Optional. Nonce action name. Default -1.
330
+ * @param string $name Optional. Nonce name. Default '_wpnonce'.
331
+ *
332
+ * @return string Escaped URL with nonce action added.
333
+ */
334
+ function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
335
+ return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
336
+ }
337
+ }
338
+
339
+ if ( ! function_exists( 'fs_starts_with' ) ) {
340
+ /**
341
+ * Check if string starts with.
342
+ *
343
+ * @author Vova Feldman (@svovaf)
344
+ * @since 1.1.3
345
+ *
346
+ * @param string $haystack
347
+ * @param string $needle
348
+ *
349
+ * @return bool
350
+ */
351
+ function fs_starts_with( $haystack, $needle ) {
352
+ $length = strlen( $needle );
353
+
354
+ return ( substr( $haystack, 0, $length ) === $needle );
355
+ }
356
+ }
357
+
358
+ #region Url Canonization ------------------------------------------------------------------
359
+
360
+ if ( ! function_exists( 'fs_canonize_url' ) ) {
361
+ /**
362
+ * @author Vova Feldman (@svovaf)
363
+ * @since 1.1.3
364
+ *
365
+ * @param string $url
366
+ * @param bool $omit_host
367
+ * @param array $ignore_params
368
+ *
369
+ * @return string
370
+ */
371
+ function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
372
+ $parsed_url = parse_url( strtolower( $url ) );
373
+
374
+ // if ( ! isset( $parsed_url['host'] ) ) {
375
+ // return $url;
376
+ // }
377
+
378
+ $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
379
+
380
+ if ( isset( $parsed_url['query'] ) ) {
381
+ parse_str( $parsed_url['query'], $queryString );
382
+ $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
383
+ }
384
+
385
+ return $canonical;
386
+ }
387
+ }
388
+
389
+ if ( ! function_exists( 'fs_canonize_query_string' ) ) {
390
+ /**
391
+ * @author Vova Feldman (@svovaf)
392
+ * @since 1.1.3
393
+ *
394
+ * @param array $params
395
+ * @param array $ignore_params
396
+ * @param bool $params_prefix
397
+ *
398
+ * @return string
399
+ */
400
+ function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
401
+ if ( ! is_array( $params ) || 0 === count( $params ) ) {
402
+ return '';
403
+ }
404
+
405
+ // Url encode both keys and values
406
+ $keys = fs_urlencode_rfc3986( array_keys( $params ) );
407
+ $values = fs_urlencode_rfc3986( array_values( $params ) );
408
+ $params = array_combine( $keys, $values );
409
+
410
+ // Parameters are sorted by name, using lexicographical byte value ordering.
411
+ // Ref: Spec: 9.1.1 (1)
412
+ uksort( $params, 'strcmp' );
413
+
414
+ $pairs = array();
415
+ foreach ( $params as $parameter => $value ) {
416
+ $lower_param = strtolower( $parameter );
417
+
418
+ // Skip ignore params.
419
+ if ( in_array( $lower_param, $ignore_params ) ||
420
+ ( false !== $params_prefix && fs_starts_with( $lower_param, $params_prefix ) )
421
+ ) {
422
+ continue;
423
+ }
424
+
425
+ if ( is_array( $value ) ) {
426
+ // If two or more parameters share the same name, they are sorted by their value
427
+ // Ref: Spec: 9.1.1 (1)
428
+ natsort( $value );
429
+ foreach ( $value as $duplicate_value ) {
430
+ $pairs[] = $lower_param . '=' . $duplicate_value;
431
+ }
432
+ } else {
433
+ $pairs[] = $lower_param . '=' . $value;
434
+ }
435
+ }
436
+
437
+ if ( 0 === count( $pairs ) ) {
438
+ return '';
439
+ }
440
+
441
+ return implode( "&", $pairs );
442
+ }
443
+ }
444
+
445
+ if ( ! function_exists( 'fs_urlencode_rfc3986' ) ) {
446
+ /**
447
+ * @author Vova Feldman (@svovaf)
448
+ * @since 1.1.3
449
+ *
450
+ * @param string|string[] $input
451
+ *
452
+ * @return array|mixed|string
453
+ */
454
+ function fs_urlencode_rfc3986( $input ) {
455
+ if ( is_array( $input ) ) {
456
+ return array_map( 'fs_urlencode_rfc3986', $input );
457
+ } else if ( is_scalar( $input ) ) {
458
+ return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
459
+ }
460
+
461
+ return '';
462
+ }
463
+ }
464
+
465
+ #endregion Url Canonization ------------------------------------------------------------------
466
+
467
+ function fs_download_image( $from, $to ) {
468
+ $ch = curl_init( $from );
469
+ $fp = fopen( fs_normalize_path( $to ), 'wb' );
470
+ curl_setopt( $ch, CURLOPT_FILE, $fp );
471
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
472
+ curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
473
+ curl_setopt( $ch, CURLOPT_HEADER, 0 );
474
+ curl_exec( $ch );
475
+ curl_close( $ch );
476
+ fclose( $fp );
477
+ }
478
+
479
+ /* General Utilities
480
+ --------------------------------------------------------------------------------------------*/
481
+
482
+ /**
483
+ * Sorts an array by the value of the priority key.
484
+ *
485
+ * @author Daniel Iser (@danieliser)
486
+ * @since 1.1.7
487
+ *
488
+ * @param $a
489
+ * @param $b
490
+ *
491
+ * @return int
492
+ */
493
+ function fs_sort_by_priority( $a, $b ) {
494
+
495
+ // If b has a priority and a does not, b wins.
496
+ if ( ! isset( $a['priority'] ) && isset( $b['priority'] ) ) {
497
+ return 1;
498
+ } // If b has a priority and a does not, b wins.
499
+ elseif ( isset( $a['priority'] ) && ! isset( $b['priority'] ) ) {
500
+ return - 1;
501
+ } // If neither has a priority or both priorities are equal its a tie.
502
+ elseif ( ( ! isset( $a['priority'] ) && ! isset( $b['priority'] ) ) || $a['priority'] === $b['priority'] ) {
503
+ return 0;
504
+ }
505
+
506
+ // If both have priority return the winner.
507
+ return ( $a['priority'] < $b['priority'] ) ? - 1 : 1;
508
+ }
509
+
510
+ #--------------------------------------------------------------------------------
511
+ #region Localization
512
+ #--------------------------------------------------------------------------------
513
+
514
+ if ( ! function_exists( 'fs_text' ) ) {
515
+ /**
516
+ * Retrieve a translated text by key.
517
+ *
518
+ * @author Vova Feldman (@svovaf)
519
+ * @since 1.2.1.7
520
+ *
521
+ * @param string $key
522
+ * @param string $slug
523
+ *
524
+ * @return string
525
+ *
526
+ * @global $fs_text, $fs_text_overrides
527
+ */
528
+ function fs_text( $key, $slug = 'freemius' ) {
529
+ return __fs( $key, $slug );
530
+ }
531
+
532
+ /**
533
+ * Output a translated text by key.
534
+ *
535
+ * @author Vova Feldman (@svovaf)
536
+ * @since 1.2.1.7
537
+ *
538
+ * @param string $key
539
+ * @param string $slug
540
+ */
541
+ function fs_echo( $key, $slug = 'freemius' ) {
542
+ echo fs_text( $key, $slug );
543
+ }
544
+ }
545
+
546
+ /**
547
+ * @author Vova Feldman
548
+ * @since 1.2.1.6
549
+ *
550
+ * @param string $key
551
+ * @param string $slug
552
+ *
553
+ * @return string
554
+ */
555
+ function fs_esc_attr( $key, $slug ) {
556
+ return esc_attr( fs_text( $key, $slug ) );
557
+ }
558
+
559
+ /**
560
+ * @author Vova Feldman
561
+ * @since 1.2.1.6
562
+ *
563
+ * @param string $key
564
+ * @param string $slug
565
+ */
566
+ function fs_esc_attr_echo( $key, $slug ) {
567
+ echo esc_attr( fs_text( $key, $slug ) );
568
+ }
569
+
570
+ /**
571
+ * @author Vova Feldman
572
+ * @since 1.2.1.6
573
+ *
574
+ * @param string $key
575
+ * @param string $slug
576
+ *
577
+ * @return string
578
+ */
579
+ function fs_esc_js( $key, $slug ) {
580
+ return esc_js( fs_text( $key, $slug ) );
581
+ }
582
+
583
+ /**
584
+ * @author Vova Feldman
585
+ * @since 1.2.1.6
586
+ *
587
+ * @param string $key
588
+ * @param string $slug
589
+ */
590
+ function fs_esc_js_echo( $key, $slug ) {
591
+ echo esc_js( fs_text( $key, $slug ) );
592
+ }
593
+
594
+ /**
595
+ * @author Vova Feldman
596
+ * @since 1.2.1.6
597
+ *
598
+ * @param string $key
599
+ * @param string $slug
600
+ */
601
+ function fs_json_encode_echo( $key, $slug ) {
602
+ echo json_encode( fs_text( $key, $slug ) );
603
+ }
604
+
605
+ /**
606
+ * @author Vova Feldman
607
+ * @since 1.2.1.6
608
+ *
609
+ * @param string $key
610
+ * @param string $slug
611
+ *
612
+ * @return string
613
+ */
614
+ function fs_esc_html( $key, $slug ) {
615
+ return esc_html( fs_text( $key, $slug ) );
616
+ }
617
+
618
+ /**
619
+ * @author Vova Feldman
620
+ * @since 1.2.1.6
621
+ *
622
+ * @param string $key
623
+ * @param string $slug
624
+ */
625
+ function fs_esc_html_echo( $key, $slug ) {
626
+ echo esc_html( fs_text( $key, $slug ) );
627
+ }
628
+
629
+ #endregion
freemius/includes/fs-essential-functions.php ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 bool $exit If true, exit after redirect (Since 1.2.1.5).
46
+ * @param int $status Status code to use.
47
+ *
48
+ * @return bool False if $location is not set
49
+ */
50
+ function fs_redirect( $location, $exit = true, $status = 302 ) {
51
+ global $is_IIS;
52
+
53
+ $file = '';
54
+ $line = '';
55
+ if ( headers_sent( $file, $line ) ) {
56
+ if ( WP_FS__DEBUG_SDK && class_exists( 'FS_Admin_Notice_Manager' ) ) {
57
+ $notices = FS_Admin_Notice_Manager::instance( 'global' );
58
+
59
+ $notices->add( "Freemius failed to redirect the page because the headers have been already sent from line <b><code>{$line}</code></b> in file <b><code>{$file}</code></b>. If it's unexpected, it usually happens due to invalid space and/or EOL character(s).", 'Oops...', 'error' );
60
+ }
61
+
62
+ return false;
63
+ }
64
+
65
+ if ( defined( 'DOING_AJAX' ) ) {
66
+ // Don't redirect on AJAX calls.
67
+ return false;
68
+ }
69
+
70
+ if ( ! $location ) // allows the wp_redirect filter to cancel a redirect
71
+ {
72
+ return false;
73
+ }
74
+
75
+ $location = fs_sanitize_redirect( $location );
76
+
77
+ if ( $is_IIS ) {
78
+ header( "Refresh: 0;url=$location" );
79
+ } else {
80
+ if ( php_sapi_name() != 'cgi-fcgi' ) {
81
+ status_header( $status );
82
+ } // This causes problems on IIS and some FastCGI setups
83
+ header( "Location: $location" );
84
+ }
85
+
86
+ if ( $exit ) {
87
+ exit();
88
+ }
89
+
90
+ return true;
91
+ }
92
+
93
+ if ( ! function_exists( 'fs_sanitize_redirect' ) ) {
94
+ /**
95
+ * Sanitizes a URL for use in a redirect.
96
+ *
97
+ * @since 2.3
98
+ *
99
+ * @param string $location
100
+ *
101
+ * @return string redirect-sanitized URL
102
+ */
103
+ function fs_sanitize_redirect( $location ) {
104
+ $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location );
105
+ $location = fs_kses_no_null( $location );
106
+
107
+ // remove %0d and %0a from location
108
+ $strip = array( '%0d', '%0a' );
109
+ $found = true;
110
+ while ( $found ) {
111
+ $found = false;
112
+ foreach ( (array) $strip as $val ) {
113
+ while ( strpos( $location, $val ) !== false ) {
114
+ $found = true;
115
+ $location = str_replace( $val, '', $location );
116
+ }
117
+ }
118
+ }
119
+
120
+ return $location;
121
+ }
122
+ }
123
+
124
+ if ( ! function_exists( 'fs_kses_no_null' ) ) {
125
+ /**
126
+ * Removes any NULL characters in $string.
127
+ *
128
+ * @since 1.0.0
129
+ *
130
+ * @param string $string
131
+ *
132
+ * @return string
133
+ */
134
+ function fs_kses_no_null( $string ) {
135
+ $string = preg_replace( '/\0+/', '', $string );
136
+ $string = preg_replace( '/(\\\\0)+/', '', $string );
137
+
138
+ return $string;
139
+ }
140
+ }
141
+ }
142
+
143
+ #endregion Core Redirect (copied from BuddyPress) -----------------------------------------
144
+
145
+ if ( ! function_exists( '__fs' ) ) {
146
+ global $fs_text_overrides;
147
+
148
+ if ( ! isset( $fs_text_overrides ) ) {
149
+ $fs_text_overrides = array();
150
+ }
151
+
152
+ /**
153
+ * Retrieve a translated text by key.
154
+ *
155
+ * @deprecated Use `fs_text()` instead since methods starting with `__` trigger warnings in Php 7.
156
+ *
157
+ * @author Vova Feldman (@svovaf)
158
+ * @since 1.1.4
159
+ *
160
+ * @param string $key
161
+ * @param string $slug
162
+ *
163
+ * @return string
164
+ *
165
+ * @global $fs_text, $fs_text_overrides
166
+ */
167
+ function __fs( $key, $slug = 'freemius' ) {
168
+ global $fs_text,
169
+ $fs_module_info_text,
170
+ $fs_text_overrides;
171
+
172
+ if ( isset( $fs_text_overrides[ $slug ] ) ) {
173
+ if ( isset( $fs_text_overrides[ $slug ][ $key ] ) ) {
174
+ return $fs_text_overrides[ $slug ][ $key ];
175
+ }
176
+
177
+ $lower_key = strtolower( $key );
178
+ if ( isset( $fs_text_overrides[ $slug ][ $lower_key ] ) ) {
179
+ return $fs_text_overrides[ $slug ][ $lower_key ];
180
+ }
181
+ }
182
+
183
+ if ( ! isset( $fs_text ) ) {
184
+ $dir = defined( 'WP_FS__DIR_INCLUDES' ) ?
185
+ WP_FS__DIR_INCLUDES :
186
+ dirname( __FILE__ );
187
+
188
+ require_once $dir . '/i18n.php';
189
+ }
190
+
191
+ if ( isset( $fs_text[ $key ] ) ) {
192
+ return $fs_text[ $key ];
193
+ }
194
+
195
+ if ( isset( $fs_module_info_text[ $key ] ) ) {
196
+ return $fs_module_info_text[ $key ];
197
+ }
198
+
199
+ return $key;
200
+ }
201
+
202
+ /**
203
+ * Output a translated text by key.
204
+ *
205
+ * @deprecated Use `fs_echo()` instead for consistency with `fs_text()`.
206
+ *
207
+ * @author Vova Feldman (@svovaf)
208
+ * @since 1.1.4
209
+ *
210
+ * @param string $key
211
+ * @param string $slug
212
+ */
213
+ function _efs( $key, $slug = 'freemius' ) {
214
+ fs_echo( $key, $slug );
215
+ }
216
+ }
217
+
218
+ if ( ! function_exists( 'fs_override_i18n' ) ) {
219
+ /**
220
+ * Override default i18n text phrases.
221
+ *
222
+ * @author Vova Feldman (@svovaf)
223
+ * @since 1.1.6
224
+ *
225
+ * @param string[] $key_value
226
+ * @param string $slug
227
+ *
228
+ * @global $fs_text_overrides
229
+ */
230
+ function fs_override_i18n( array $key_value, $slug = 'freemius' ) {
231
+ global $fs_text_overrides;
232
+
233
+ if ( ! isset( $fs_text_overrides[ $slug ] ) ) {
234
+ $fs_text_overrides[ $slug ] = array();
235
+ }
236
+
237
+ foreach ( $key_value as $key => $value ) {
238
+ $fs_text_overrides[ $slug ][ $key ] = $value;
239
+ }
240
+ }
241
+ }
242
+
243
+ if ( ! function_exists( 'fs_get_ip' ) ) {
244
+ /**
245
+ * Get client IP.
246
+ *
247
+ * @author Vova Feldman (@svovaf)
248
+ * @since 1.1.2
249
+ *
250
+ * @return string|null
251
+ */
252
+ function fs_get_ip() {
253
+ $fields = array(
254
+ 'HTTP_CF_CONNECTING_IP',
255
+ 'HTTP_CLIENT_IP',
256
+ 'HTTP_X_FORWARDED_FOR',
257
+ 'HTTP_X_FORWARDED',
258
+ 'HTTP_FORWARDED_FOR',
259
+ 'HTTP_FORWARDED',
260
+ 'REMOTE_ADDR',
261
+ );
262
+
263
+ foreach ( $fields as $ip_field ) {
264
+ if ( ! empty( $_SERVER[ $ip_field ] ) ) {
265
+ return $_SERVER[ $ip_field ];
266
+ }
267
+ }
268
+
269
+ return null;
270
+ }
271
+ }
272
+
273
+ /**
274
+ * Leverage backtrace to find caller plugin main file path.
275
+ *
276
+ * @author Vova Feldman (@svovaf)
277
+ * @since 1.0.6
278
+ *
279
+ * @return string
280
+ */
281
+ function fs_find_caller_plugin_file() {
282
+ /**
283
+ * All the code below will be executed once on activation.
284
+ * If the user changes the main plugin's file name, the file_exists()
285
+ * will catch it.
286
+ */
287
+ if ( ! function_exists( 'get_plugins' ) ) {
288
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
289
+ }
290
+
291
+ $all_plugins = get_plugins();
292
+ $all_plugins_paths = array();
293
+
294
+ // Get active plugin's main files real full names (might be symlinks).
295
+ foreach ( $all_plugins as $relative_path => &$data ) {
296
+ $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
297
+ }
298
+
299
+ $plugin_file = null;
300
+ for ( $i = 1, $bt = debug_backtrace(), $len = count( $bt ); $i < $len; $i ++ ) {
301
+ if ( empty( $bt[ $i ]['file'] ) ) {
302
+ continue;
303
+ }
304
+
305
+ if ( in_array( fs_normalize_path( $bt[ $i ]['file'] ), $all_plugins_paths ) ) {
306
+ $plugin_file = $bt[ $i ]['file'];
307
+ break;
308
+ }
309
+ }
310
+
311
+ if ( is_null( $plugin_file ) ) {
312
+ // Throw an error to the developer in case of some edge case dev environment.
313
+ wp_die(
314
+ "Freemius SDK couldn't find the plugin's main file. Please contact sdk@freemius.com with the current error.",
315
+ 'Error',
316
+ array( 'back_link' => true )
317
+ );
318
+ }
319
+
320
+ return $plugin_file;
321
+ }
322
+
323
+ require_once dirname( __FILE__ ) . '/supplements/fs-essential-functions-1.1.7.1.php';
324
+
325
+ /**
326
+ * Update SDK newest version reference.
327
+ *
328
+ * @author Vova Feldman (@svovaf)
329
+ * @since 1.1.6
330
+ *
331
+ * @param string $sdk_relative_path
332
+ * @param string|bool $plugin_file
333
+ *
334
+ * @global $fs_active_plugins
335
+ */
336
+ function fs_update_sdk_newest_version( $sdk_relative_path, $plugin_file = false ) {
337
+ global $fs_active_plugins;
338
+
339
+ if ( ! is_string( $plugin_file ) ) {
340
+ $plugin_file = plugin_basename( fs_find_caller_plugin_file() );
341
+ }
342
+
343
+ $fs_active_plugins->newest = (object) array(
344
+ 'plugin_path' => $plugin_file,
345
+ 'sdk_path' => $sdk_relative_path,
346
+ 'version' => $fs_active_plugins->plugins[ $sdk_relative_path ]->version,
347
+ 'in_activation' => ! is_plugin_active( $plugin_file ),
348
+ 'timestamp' => time(),
349
+ );
350
+
351
+ // Update DB with latest SDK version and path.
352
+ update_option( 'fs_active_plugins', $fs_active_plugins );
353
+ }
354
+
355
+ /**
356
+ * Reorder the plugins load order so the plugin with the newest Freemius SDK is loaded first.
357
+ *
358
+ * @author Vova Feldman (@svovaf)
359
+ * @since 1.1.6
360
+ *
361
+ * @return bool Was plugin order changed. Return false if plugin was loaded first anyways.
362
+ *
363
+ * @global $fs_active_plugins
364
+ */
365
+ function fs_newest_sdk_plugin_first() {
366
+ global $fs_active_plugins;
367
+
368
+ /**
369
+ * @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).
370
+ *
371
+ * @link https://github.com/Freemius/wordpress-sdk/issues/26
372
+ */
373
+ // $active_sitewide_plugins = get_site_option( 'active_sitewide_plugins' );
374
+
375
+ $active_plugins = get_option( 'active_plugins' );
376
+ $newest_sdk_plugin_key = array_search( $fs_active_plugins->newest->plugin_path, $active_plugins );
377
+ if ( 0 == $newest_sdk_plugin_key ) {
378
+ // if it's 0 it's the first plugin already, no need to continue
379
+ return false;
380
+ }
381
+
382
+ array_splice( $active_plugins, $newest_sdk_plugin_key, 1 );
383
+ array_unshift( $active_plugins, $fs_active_plugins->newest->plugin_path );
384
+ update_option( 'active_plugins', $active_plugins );
385
+
386
+ return true;
387
+ }
388
+
389
+ /**
390
+ * Go over all Freemius SDKs in the system and find and "remember"
391
+ * the newest SDK which is associated with an active plugin.
392
+ *
393
+ * @author Vova Feldman (@svovaf)
394
+ * @since 1.1.6
395
+ *
396
+ * @global $fs_active_plugins
397
+ */
398
+ function fs_fallback_to_newest_active_sdk() {
399
+ global $fs_active_plugins;
400
+
401
+ /**
402
+ * @var object $newest_sdk_data
403
+ */
404
+ $newest_sdk_data = null;
405
+ $newest_sdk_path = null;
406
+
407
+ foreach ( $fs_active_plugins->plugins as $sdk_relative_path => $data ) {
408
+ if ( is_null( $newest_sdk_data ) || version_compare( $data->version, $newest_sdk_data->version, '>' )
409
+ ) {
410
+ // If plugin inactive or SDK starter file doesn't exist, remove SDK reference.
411
+ if ( ! is_plugin_active( $data->plugin_path ) ||
412
+ ! file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $sdk_relative_path . '/start.php' ) )
413
+ ) {
414
+ unset( $fs_active_plugins->plugins[ $sdk_relative_path ] );
415
+
416
+ // No need to store the data since it will be stored in fs_update_sdk_newest_version()
417
+ // or explicitly with update_option().
418
+ } else {
419
+ $newest_sdk_data = $data;
420
+ $newest_sdk_path = $sdk_relative_path;
421
+ }
422
+ }
423
+ }
424
+
425
+ if ( is_null( $newest_sdk_data ) ) {
426
+ // Couldn't find any SDK reference.
427
+ $fs_active_plugins = new stdClass();
428
+ update_option( 'fs_active_plugins', $fs_active_plugins );
429
+ } else {
430
+ fs_update_sdk_newest_version( $newest_sdk_path, $newest_sdk_data->plugin_path );
431
+ }
432
+ }
433
+
434
+ #region Actions / Filters -----------------------------------------
435
+
436
+ /**
437
+ * Apply filter for specific plugin.
438
+ *
439
+ * @author Vova Feldman (@svovaf)
440
+ * @since 1.0.9
441
+ *
442
+ * @param string $slug Plugin slug
443
+ * @param string $tag The name of the filter hook.
444
+ * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
445
+ *
446
+ * @return mixed The filtered value after all hooked functions are applied to it.
447
+ *
448
+ * @uses apply_filters()
449
+ */
450
+ function fs_apply_filter( $slug, $tag, $value ) {
451
+ $args = func_get_args();
452
+
453
+ return call_user_func_array( 'apply_filters', array_merge(
454
+ array( "fs_{$tag}_{$slug}" ),
455
+ array_slice( $args, 2 ) )
456
+ );
457
+ }
458
+
459
+ #endregion Actions / Filters -----------------------------------------
freemius/includes/fs-plugin-info-dialog.php ADDED
@@ -0,0 +1,942 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ $selected_addon = $this->_fs->get_addon_by_slug($args->slug, WP_FS__DEV_MODE);
78
+
79
+ if ( false === $selected_addon ) {
80
+ return $data;
81
+ }
82
+
83
+ if ( ! isset( $selected_addon->info ) ) {
84
+ // Setup some default info.
85
+ $selected_addon->info = new stdClass();
86
+ $selected_addon->info->selling_point_0 = 'Selling Point 1';
87
+ $selected_addon->info->selling_point_1 = 'Selling Point 2';
88
+ $selected_addon->info->selling_point_2 = 'Selling Point 3';
89
+ $selected_addon->info->description = '<p>Tell your users all about your add-on</p>';
90
+ }
91
+
92
+ fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
93
+
94
+ $data = $args;
95
+
96
+ $is_free = true;
97
+
98
+ // Load add-on pricing.
99
+ $has_pricing = false;
100
+ $has_features = false;
101
+ $plans = false;
102
+ $plans_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans.json?type=visible" );
103
+ if ( ! isset( $plans_result->error ) ) {
104
+ $plans = $plans_result->plans;
105
+ if ( is_array( $plans ) ) {
106
+ for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
107
+ $plans[ $i ] = new FS_Plugin_Plan( $plans[ $i ] );
108
+ $plan = $plans[ $i ];
109
+
110
+ $pricing_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/pricing.json" );
111
+ if ( ! isset( $pricing_result->error ) ) {
112
+ // Update plan's pricing.
113
+ $plan->pricing = $pricing_result->pricing;
114
+
115
+ if ( is_array( $plan->pricing ) && ! empty( $plan->pricing ) ) {
116
+ $is_free = false;
117
+
118
+ foreach ( $plan->pricing as &$pricing ) {
119
+ $pricing = new FS_Pricing( $pricing );
120
+ }
121
+ }
122
+
123
+ $has_pricing = true;
124
+ }
125
+
126
+ $features_result = $this->_fs->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/features.json" );
127
+ if ( ! isset( $features_result->error ) &&
128
+ is_array( $features_result->features ) &&
129
+ 0 < count( $features_result->features )
130
+ ) {
131
+ // Update plan's pricing.
132
+ $plan->features = $features_result->features;
133
+
134
+ $has_features = true;
135
+ }
136
+ }
137
+ }
138
+ }
139
+
140
+ // Fetch latest version from Freemius.
141
+ $latest = $this->_fs->_fetch_latest_version( $selected_addon->id );
142
+
143
+ if ( ! $is_free ) {
144
+ // If paid add-on, then it's not on wordpress.org
145
+ $is_wordpress_org = false;
146
+ } else {
147
+ // If no versions found, then assume it's a .org plugin.
148
+ $is_wordpress_org = ( false === $latest );
149
+ }
150
+
151
+ if ( $is_wordpress_org ) {
152
+ $repo_data = FS_Plugin_Updater::_fetch_plugin_info_from_repository(
153
+ 'plugin_information', (object) array(
154
+ 'slug' => $selected_addon->slug,
155
+ 'is_ssl' => is_ssl(),
156
+ 'fields' => array(
157
+ 'banners' => true,
158
+ 'reviews' => true,
159
+ 'downloaded' => false,
160
+ 'active_installs' => true
161
+ )
162
+ ) );
163
+
164
+ if ( ! empty( $repo_data ) ) {
165
+ $data = $repo_data;
166
+ $data->wp_org_missing = false;
167
+ } else {
168
+ // Couldn't find plugin on .org.
169
+ $is_wordpress_org = false;
170
+
171
+ // Plugin is missing, not on Freemius nor WP.org.
172
+ $data->wp_org_missing = true;
173
+ }
174
+ }
175
+
176
+ if ( ! $is_wordpress_org ) {
177
+ $data->checkout_link = $this->_fs->checkout_url();
178
+ $data->fs_missing = ( false === $latest );
179
+
180
+ if ( $is_free ) {
181
+ $data->download_link = $this->_fs->_get_latest_download_local_url( $selected_addon->id );
182
+ }
183
+ }
184
+
185
+ if ( ! $is_wordpress_org ) {
186
+ // Fetch as much as possible info from local files.
187
+ $plugin_local_data = $this->_fs->get_plugin_data();
188
+ $data->name = $selected_addon->title;
189
+ $data->author = $plugin_local_data['Author'];
190
+ $view_vars = array( 'plugin' => $selected_addon );
191
+ $data->sections = array(
192
+ 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
193
+ );
194
+
195
+ if ( ! empty( $selected_addon->info->banner_url ) ) {
196
+ $data->banners = array(
197
+ 'low' => $selected_addon->info->banner_url,
198
+ );
199
+ }
200
+
201
+ if ( ! empty( $selected_addon->info->screenshots ) ) {
202
+ $view_vars = array(
203
+ 'screenshots' => $selected_addon->info->screenshots,
204
+ 'plugin' => $selected_addon,
205
+ );
206
+ $data->sections['screenshots'] = fs_get_template( '/plugin-info/screenshots.php', $view_vars );
207
+ }
208
+
209
+ if ( is_object( $latest ) ) {
210
+ $data->version = $latest->version;
211
+ $data->last_updated = ! is_null( $latest->updated ) ? $latest->updated : $latest->created;
212
+ $data->requires = $latest->requires_platform_version;
213
+ $data->tested = $latest->tested_up_to_version;
214
+ } else {
215
+ // Add dummy version.
216
+ $data->version = '1.0.0';
217
+
218
+ // Add message to developer to deploy the plugin through Freemius.
219
+ }
220
+ }
221
+
222
+ if ( $has_pricing ) {
223
+ // Add plans to data.
224
+ $data->plans = $plans;
225
+
226
+ if ( $has_features ) {
227
+ $view_vars = array(
228
+ 'plans' => $plans,
229
+ 'plugin' => $selected_addon,
230
+ );
231
+ $data->sections['features'] = fs_get_template( '/plugin-info/features.php', $view_vars );
232
+ }
233
+ }
234
+
235
+ $data->is_paid = ! $is_free;
236
+ $data->external = ! $is_wordpress_org;
237
+
238
+ return $data;
239
+ }
240
+
241
+ /**
242
+ * @author Vova Feldman (@svovaf)
243
+ * @since 1.1.7
244
+ *
245
+ * @param FS_Plugin_Plan $plan
246
+ *
247
+ * @return string
248
+ */
249
+ private function get_billing_cycle( FS_Plugin_Plan $plan ) {
250
+ $billing_cycle = null;
251
+
252
+ if ( 1 === count( $plan->pricing ) && 1 == $plan->pricing[0]->licenses ) {
253
+ $pricing = $plan->pricing[0];
254
+ if ( isset( $pricing->annual_price ) ) {
255
+ $billing_cycle = 'annual';
256
+ } else if ( isset( $pricing->monthly_price ) ) {
257
+ $billing_cycle = 'monthly';
258
+ } else if ( isset( $pricing->lifetime_price ) ) {
259
+ $billing_cycle = 'lifetime';
260
+ }
261
+ } else {
262
+ foreach ( $plan->pricing as $pricing ) {
263
+ if ( isset( $pricing->annual_price ) ) {
264
+ $billing_cycle = 'annual';
265
+ } else if ( isset( $pricing->monthly_price ) ) {
266
+ $billing_cycle = 'monthly';
267
+ } else if ( isset( $pricing->lifetime_price ) ) {
268
+ $billing_cycle = 'lifetime';
269
+ }
270
+
271
+ if ( ! is_null( $billing_cycle ) ) {
272
+ break;
273
+ }
274
+ }
275
+ }
276
+
277
+ return $billing_cycle;
278
+ }
279
+
280
+ /**
281
+ * @author Vova Feldman (@svovaf)
282
+ * @since 1.1.7
283
+ *
284
+ * @param FS_Plugin_Plan $plan
285
+ * @param FS_Pricing $pricing
286
+ *
287
+ * @return float|null|string
288
+ */
289
+ private function get_price_tag( FS_Plugin_Plan $plan, FS_Pricing $pricing ) {
290
+ $price_tag = '';
291
+ if ( isset( $pricing->annual_price ) ) {
292
+ $price_tag = $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
293
+ } else if ( isset( $pricing->monthly_price ) ) {
294
+ $price_tag = $pricing->monthly_price . ' / mo';
295
+ } else if ( isset( $pricing->lifetime_price ) ) {
296
+ $price_tag = $pricing->lifetime_price;
297
+ }
298
+
299
+ return '$' . $price_tag;
300
+ }
301
+
302
+ /**
303
+ * @author Vova Feldman (@svovaf)
304
+ * @since 1.1.7
305
+ *
306
+ * @param object $api
307
+ * @param FS_Plugin_Plan|null $plan
308
+ *
309
+ * @return string
310
+ */
311
+ private function get_plugin_cta( $api, $plan = null ) {
312
+ if ( ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
313
+
314
+ if ( ! empty( $api->checkout_link ) && isset( $api->plans ) && 0 < is_array( $api->plans ) ) {
315
+ if ( is_null( $plan ) ) {
316
+ $plan = $api->plans[0];
317
+ }
318
+
319
+ return ' <a class="button button-primary right" href="' . $this->_fs->addon_checkout_url(
320
+ $plan->plugin_id,
321
+ $plan->pricing[0]->id,
322
+ $this->get_billing_cycle( $plan ),
323
+ $plan->has_trial()
324
+ ) . '" target="_parent">' .
325
+ ( ! $plan->has_trial() ?
326
+ fs_text( 'purchase', $api->slug ) :
327
+ sprintf( fs_text( 'start-free-x', $api->slug ), $this->get_trial_period( $plan ) )
328
+ ) .
329
+ '</a>';
330
+
331
+ // @todo Add Cart concept.
332
+ // echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
333
+
334
+ } else if ( ! empty( $api->download_link ) ) {
335
+ $status = install_plugin_install_status( $api );
336
+
337
+ // Hosted on WordPress.org.
338
+ switch ( $status['status'] ) {
339
+ case 'install':
340
+ if ( $api->external &&
341
+ $this->_fs->is_org_repo_compliant() ||
342
+ ! $this->_fs->is_premium()
343
+ ) {
344
+ /**
345
+ * Add-on hosted on Freemius, not yet installed, and core
346
+ * plugin is wordpress.org compliant. Therefore, require a download
347
+ * since installing external plugins is not allowed by the wp.org guidelines.
348
+ */
349
+ return ' <a class="button button-primary right" href="' . esc_url( $api->download_link ) . '" target="_blank">' . fs_text( 'download-latest', $api->slug ) . '</a>';
350
+ } else {
351
+ if ( $status['url'] ) {
352
+ return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . fs_text( 'install-now', $api->slug ) . '</a>';
353
+ }
354
+ }
355
+ break;
356
+ case 'update_available':
357
+ if ( $status['url'] ) {
358
+ return '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . fs_text( 'install-update-now', $api->slug ) . '</a>';
359
+ }
360
+ break;
361
+ case 'newer_installed':
362
+ return '<a class="button button-primary right disabled">' . sprintf( fs_text( 'newer-installed', $api->slug ), $status['version'] ) . '</a>';
363
+ break;
364
+ case 'latest_installed':
365
+ return '<a class="button button-primary right disabled">' . fs_text( 'latest-installed', $api->slug ) . '</a>';
366
+ break;
367
+ }
368
+
369
+ }
370
+ }
371
+
372
+ return '';
373
+ }
374
+
375
+ /**
376
+ * @author Vova Feldman (@svovaf)
377
+ * @since 1.1.7
378
+ *
379
+ * @param FS_Plugin_Plan $plan
380
+ *
381
+ * @return string
382
+ */
383
+ private function get_trial_period( $plan ) {
384
+ $trial_period = (int) $plan->trial_period;
385
+
386
+ switch ( $trial_period ) {
387
+ case 30:
388
+ return 'month';
389
+ case 60:
390
+ return '2 months';
391
+ default:
392
+ return "{$plan->trial_period} days";
393
+ }
394
+ }
395
+
396
+ /**
397
+ * Display plugin information in dialog box form.
398
+ *
399
+ * Based on core install_plugin_information() function.
400
+ *
401
+ * @author Vova Feldman (@svovaf)
402
+ * @since 1.0.6
403
+ */
404
+ function install_plugin_information() {
405
+ global $tab;
406
+
407
+ if ( empty( $_REQUEST['plugin'] ) ) {
408
+ return;
409
+ }
410
+
411
+ $args = array(
412
+ 'slug' => wp_unslash( $_REQUEST['plugin'] ),
413
+ 'is_ssl' => is_ssl(),
414
+ 'fields' => array(
415
+ 'banners' => true,
416
+ 'reviews' => true,
417
+ 'downloaded' => false,
418
+ 'active_installs' => true
419
+ )
420
+ );
421
+
422
+ if ( is_array( $args ) ) {
423
+ $args = (object) $args;
424
+ }
425
+
426
+ if ( ! isset( $args->per_page ) ) {
427
+ $args->per_page = 24;
428
+ }
429
+
430
+ if ( ! isset( $args->locale ) ) {
431
+ $args->locale = get_locale();
432
+ }
433
+
434
+ $api = apply_filters( 'fs_plugins_api', false, 'plugin_information', $args );
435
+
436
+ if ( is_wp_error( $api ) ) {
437
+ wp_die( $api );
438
+ }
439
+
440
+ $plugins_allowedtags = array(
441
+ 'a' => array(
442
+ 'href' => array(),
443
+ 'title' => array(),
444
+ 'target' => array(),
445
+ // Add image style for screenshots.
446
+ 'class' => array()
447
+ ),
448
+ 'style' => array(),
449
+ 'abbr' => array( 'title' => array() ),
450
+ 'acronym' => array( 'title' => array() ),
451
+ 'code' => array(),
452
+ 'pre' => array(),
453
+ 'em' => array(),
454
+ 'strong' => array(),
455
+ 'div' => array( 'class' => array() ),
456
+ 'span' => array( 'class' => array() ),
457
+ 'p' => array(),
458
+ 'ul' => array(),
459
+ 'ol' => array(),
460
+ 'li' => array( 'class' => array() ),
461
+ 'i' => array( 'class' => array() ),
462
+ 'h1' => array(),
463
+ 'h2' => array(),
464
+ 'h3' => array(),
465
+ 'h4' => array(),
466
+ 'h5' => array(),
467
+ 'h6' => array(),
468
+ 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
469
+ // 'table' => array(),
470
+ // 'td' => array(),
471
+ // 'tr' => array(),
472
+ // 'th' => array(),
473
+ // 'thead' => array(),
474
+ // 'tbody' => array(),
475
+ );
476
+
477
+ $plugins_section_titles = array(
478
+ 'description' => fs_text( 'description', $api->slug ),
479
+ 'installation' => fs_text( 'installation', $api->slug ),
480
+ 'faq' => fs_text( 'faq', $api->slug ),
481
+ 'screenshots' => fs_text( 'screenshots', $api->slug ),
482
+ 'changelog' => fs_text( 'changelog', $api->slug ),
483
+ 'reviews' => fs_text( 'reviews', $api->slug ),
484
+ 'other_notes' => fs_text( 'other_notes', $api->slug ),
485
+ );
486
+
487
+ // Sanitize HTML
488
+ // foreach ( (array) $api->sections as $section_name => $content ) {
489
+ // $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
490
+ // }
491
+
492
+ foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
493
+ if ( isset( $api->$key ) ) {
494
+ $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
495
+ }
496
+ }
497
+
498
+ // Add after $api->slug is ready.
499
+ $plugins_section_titles['features'] = fs_text( 'features-and-pricing', $api->slug );
500
+
501
+ $_tab = esc_attr( $tab );
502
+
503
+ $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
504
+ if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
505
+ $section_titles = array_keys( (array) $api->sections );
506
+ $section = array_shift( $section_titles );
507
+ }
508
+
509
+ iframe_header( fs_text( 'plugin-install', $api->slug ) );
510
+
511
+ $_with_banner = '';
512
+
513
+ // var_dump($api->banners);
514
+ if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
515
+ $_with_banner = 'with-banner';
516
+ $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
517
+ $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
518
+ ?>
519
+ <style type="text/css">
520
+ #plugin-information-title.with-banner
521
+ {
522
+ background-image: url( <?php echo esc_url( $low ); ?> );
523
+ }
524
+
525
+ @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 )
526
+ {
527
+ #plugin-information-title.with-banner
528
+ {
529
+ background-image: url( <?php echo esc_url( $high ); ?> );
530
+ }
531
+ }
532
+ </style>
533
+ <?php
534
+ }
535
+
536
+ echo '<div id="plugin-information-scrollable">';
537
+ echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
538
+ echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
539
+
540
+ foreach ( (array) $api->sections as $section_name => $content ) {
541
+ if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
542
+ continue;
543
+ }
544
+
545
+ if ( isset( $plugins_section_titles[ $section_name ] ) ) {
546
+ $title = $plugins_section_titles[ $section_name ];
547
+ } else {
548
+ $title = ucwords( str_replace( '_', ' ', $section_name ) );
549
+ }
550
+
551
+ $class = ( $section_name === $section ) ? ' class="current"' : '';
552
+ $href = add_query_arg( array( 'tab' => $tab, 'section' => $section_name ) );
553
+ $href = esc_url( $href );
554
+ $san_section = esc_attr( $section_name );
555
+ echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
556
+ }
557
+
558
+ echo "</div>\n";
559
+
560
+ ?>
561
+ <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
562
+ <div class="fyi">
563
+ <?php if ( $api->is_paid ) : ?>
564
+ <?php if ( isset( $api->plans ) ) : ?>
565
+ <div class="plugin-information-pricing">
566
+ <?php foreach ( $api->plans as $plan ) : ?>
567
+ <?php
568
+ /**
569
+ * @var FS_Plugin_Plan $plan
570
+ */
571
+ ?>
572
+ <?php $first_pricing = $plan->pricing[0] ?>
573
+ <?php $is_multi_cycle = $first_pricing->is_multi_cycle() ?>
574
+ <div class="fs-plan<?php if ( ! $is_multi_cycle ) {
575
+ echo ' fs-single-cycle';
576
+ } ?>" data-plan-id="<?php echo $plan->id ?>">
577
+ <h3 data-plan="<?php echo $plan->id ?>"><?php printf( fs_text( 'x-plan', $api->slug ), $plan->title ) ?></h3>
578
+ <?php $has_annual = $first_pricing->has_annual() ?>
579
+ <?php $has_monthly = $first_pricing->has_monthly() ?>
580
+ <div class="nav-tab-wrapper">
581
+ <?php $billing_cycles = array( 'monthly', 'annual', 'lifetime' ) ?>
582
+ <?php $i = 0;
583
+ foreach ( $billing_cycles as $cycle ) : ?>
584
+ <?php $prop = "{$cycle}_price";
585
+ if ( isset( $first_pricing->{$prop} ) ) : ?>
586
+ <?php $is_featured = ( 'annual' === $cycle && $is_multi_cycle ) ?>
587
+ <?php
588
+ $prices = array();
589
+ foreach ( $plan->pricing as $pricing ) {
590
+ if ( isset( $pricing->{$prop} ) ) {
591
+ $prices[] = array(
592
+ 'id' => $pricing->id,
593
+ 'licenses' => $pricing->licenses,
594
+ 'price' => $pricing->{$prop}
595
+ );
596
+ }
597
+ }
598
+ ?>
599
+ <a class="nav-tab" data-billing-cycle="<?php echo $cycle ?>"
600
+ data-pricing="<?php echo esc_attr( json_encode( $prices ) ) ?>">
601
+ <?php if ( $is_featured ) : ?>
602
+ <label>&#9733; <?php fs_echo( 'best', $api->slug ) ?> &#9733;</label>
603
+ <?php endif ?>
604
+ <?php fs_echo( $cycle, $api->slug ) ?>
605
+ </a>
606
+ <?php endif ?>
607
+ <?php $i ++; endforeach ?>
608
+ <?php wp_enqueue_script( 'jquery' ) ?>
609
+ <script type="text/javascript">
610
+ (function ($, undef) {
611
+ var
612
+ _formatBillingFrequency = function (cycle) {
613
+ switch (cycle) {
614
+ case 'monthly':
615
+ return '<?php printf(fs_text('billed-x', $api->slug), fs_text('monthly', $api->slug)) ?>';
616
+ case 'annual':
617
+ return '<?php printf(fs_text('billed-x', $api->slug), fs_text('annually', $api->slug)) ?>';
618
+ case 'lifetime':
619
+ return '<?php printf(fs_text('billed-x', $api->slug), fs_text('once', $api->slug)) ?>';
620
+ }
621
+ },
622
+ _formatLicensesTitle = function (pricing) {
623
+ switch (pricing.licenses) {
624
+ case 1:
625
+ return '<?php fs_echo( 'license-single-site', $api->slug ) ?>';
626
+ case null:
627
+ return '<?php fs_echo( 'license-unlimited', $api->slug ) ?>';
628
+ default:
629
+ return '<?php fs_echo( 'license-x-sites', $api->slug ) ?>'.replace('%s', pricing.licenses);
630
+ }
631
+ },
632
+ _formatPrice = function (pricing, cycle, multipleLicenses) {
633
+ if (undef === multipleLicenses)
634
+ multipleLicenses = true;
635
+
636
+ var priceCycle;
637
+ switch (cycle) {
638
+ case 'monthly':
639
+ priceCycle = ' / <?php fs_echo('mo', $api->slug) ?>';
640
+ break;
641
+ case 'lifetime':
642
+ priceCycle = '';
643
+ break;
644
+ case 'annual':
645
+ default:
646
+ priceCycle = ' / <?php fs_echo('year', $api->slug) ?>';
647
+ break;
648
+ }
649
+
650
+ if (!multipleLicenses && 1 == pricing.licenses) {
651
+ return '$' + pricing.price + priceCycle;
652
+ }
653
+
654
+ return _formatLicensesTitle(pricing) + ' - <var class="fs-price">$' + pricing.price + priceCycle + '</var>';
655
+ },
656
+ _checkoutUrl = function (plan, pricing, cycle) {
657
+ return '<?php echo esc_url_raw(remove_query_arg('billing_cycle', add_query_arg(array('plugin_id' => $plan->plugin_id), $api->checkout_link))) ?>' +
658
+ '&plan_id=' + plan +
659
+ '&pricing_id=' + pricing +
660
+ '&billing_cycle=' + cycle<?php if ($plan->has_trial()) { echo " + '&trial=true'"; }?>;
661
+ },
662
+ _updateCtaUrl = function (plan, pricing, cycle) {
663
+ $('.plugin-information-pricing .button, #plugin-information-footer .button').attr('href', _checkoutUrl(plan, pricing, cycle));
664
+ };
665
+
666
+ $(document).ready(function () {
667
+ var $plan = $('.plugin-information-pricing .fs-plan[data-plan-id=<?php echo $plan->id ?>]');
668
+ $plan.find('input[type=radio]').live('click', function () {
669
+ _updateCtaUrl(
670
+ $plan.attr('data-plan-id'),
671
+ $(this).val(),
672
+ $plan.find('.nav-tab-active').attr('data-billing-cycle')
673
+ );
674
+
675
+ $plan.find('.fs-trial-terms .fs-price').html(
676
+ $(this).parents('label').find('.fs-price').html()
677
+ );
678
+ });
679
+
680
+ $plan.find('.nav-tab').click(function () {
681
+ if ($(this).hasClass('nav-tab-active'))
682
+ return;
683
+
684
+ var $this = $(this),
685
+ billingCycle = $this.attr('data-billing-cycle'),
686
+ pricing = JSON.parse($this.attr('data-pricing')),
687
+ $pricesList = $this.parents('.fs-plan').find('.fs-pricing-body .fs-licenses'),
688
+ html = '';
689
+
690
+ // Un-select previously selected tab.
691
+ $plan.find('.nav-tab').removeClass('nav-tab-active');
692
+
693
+ // Select current tab.
694
+ $this.addClass('nav-tab-active');
695
+
696
+ // Render licenses prices.
697
+ if (1 == pricing.length) {
698
+ html = '<li><label><?php fs_echo( 'price', $api->slug ) ?>: ' + _formatPrice(pricing[0], billingCycle, false) + '</label></li>';
699
+ } else {
700
+ for (var i = 0; i < pricing.length; i++) {
701
+ html += '<li><label><input name="pricing-<?php echo $plan->id ?>" type="radio" value="' + pricing[i].id + '">' + _formatPrice(pricing[i], billingCycle) + '</label></li>';
702
+ }
703
+ }
704
+ $pricesList.html(html);
705
+
706
+ if (1 < pricing.length) {
707
+ // Select first license option.
708
+ $pricesList.find('li:first input').click();
709
+ }
710
+ else {
711
+ _updateCtaUrl(
712
+ $plan.attr('data-plan-id'),
713
+ pricing[0].id,
714
+ billingCycle
715
+ );
716
+ }
717
+
718
+ // Update billing frequency.
719
+ $plan.find('.fs-billing-frequency').html(_formatBillingFrequency(billingCycle));
720
+
721
+ if ('annual' === billingCycle) {
722
+ $plan.find('.fs-annual-discount').show();
723
+ } else {
724
+ $plan.find('.fs-annual-discount').hide();
725
+ }
726
+ });
727
+
728
+ <?php if ( $has_annual ) : ?>
729
+ // Select annual by default.
730
+ $plan.find('.nav-tab[data-billing-cycle=annual]').click();
731
+ <?php else : ?>
732
+ // Select first tab.
733
+ $plan.find('.nav-tab:first').click();
734
+ <?php endif ?>
735
+ });
736
+ }(jQuery));
737
+ </script>
738
+ </div>
739
+ <div class="fs-pricing-body">
740
+ <span class="fs-billing-frequency"></span>
741
+ <?php $annual_discount = ( $has_annual && $has_monthly ) ? $plan->pricing[0]->annual_discount_percentage() : 0 ?>
742
+ <?php if ( $annual_discount > 0 ) : ?>
743
+ <span
744
+ class="fs-annual-discount"><?php printf( fs_text( 'save-x', $api->slug ), $annual_discount . '%' ) ?></span>
745
+ <?php endif ?>
746
+ <ul class="fs-licenses">
747
+ </ul>
748
+ <?php echo $this->get_plugin_cta( $api, $plan ) ?>
749
+ <div style="clear:both"></div>
750
+ <?php if ( $plan->has_trial() ) : ?>
751
+ <?php $trial_period = $this->get_trial_period( $plan ) ?>
752
+ <ul class="fs-trial-terms">
753
+ <li>
754
+ <i class="dashicons dashicons-yes"></i><?php printf( fs_text( 'no-commitment-x', $api->slug ), $trial_period ) ?>
755
+ </li>
756
+ <li>
757
+ <i class="dashicons dashicons-yes"></i><?php printf( fs_text( 'after-x-pay-as-little-y', $api->slug ), $trial_period, '<var class="fs-price">' . $this->get_price_tag( $plan, $plan->pricing[0] ) . '</var>' ) ?>
758
+ </li>
759
+ </ul>
760
+ <?php endif ?>
761
+ </div>
762
+ </div>
763
+ </div>
764
+ <?php endforeach ?>
765
+ <?php endif ?>
766
+ <?php endif ?>
767
+ <div>
768
+ <h3><?php fs_echo( 'details', $api->slug ) ?></h3>
769
+ <ul>
770
+ <?php if ( ! empty( $api->version ) ) { ?>
771
+ <li><strong><?php fs_echo( 'version', $api->slug ); ?>:</strong> <?php echo $api->version; ?></li>
772
+ <?php
773
+ }
774
+ if ( ! empty( $api->author ) ) {
775
+ ?>
776
+ <li>
777
+ <strong><?php fs_echo( 'author:', $api->slug ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?>
778
+ </li>
779
+ <?php
780
+ }
781
+ if ( ! empty( $api->last_updated ) ) {
782
+ ?>
783
+ <li><strong><?php fs_echo( 'last-updated:', $api->slug ); ?></strong> <span
784
+ title="<?php echo $api->last_updated; ?>">
785
+ <?php printf( fs_text( 'x-ago', $api->slug ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
786
+ </span></li>
787
+ <?php
788
+ }
789
+ if ( ! empty( $api->requires ) ) {
790
+ ?>
791
+ <li>
792
+ <strong><?php fs_echo( 'requires-wordpress-version:', $api->slug ); ?></strong> <?php printf( fs_text( 'x-or-higher', $api->slug ), $api->requires ); ?>
793
+ </li>
794
+ <?php
795
+ }
796
+ if ( ! empty( $api->tested ) ) {
797
+ ?>
798
+ <li><strong><?php fs_echo( 'compatible-up-to:', $api->slug ); ?></strong> <?php echo $api->tested; ?>
799
+ </li>
800
+ <?php
801
+ }
802
+ if ( ! empty( $api->downloaded ) ) {
803
+ ?>
804
+ <li>
805
+ <strong><?php fs_echo( 'downloaded:', $api->slug ); ?></strong> <?php printf(
806
+ fs_text( ( 1 == $api->downloaded ) ? 'x-time' : 'x-times', $api->slug ),
807
+ number_format_i18n( $api->downloaded )
808
+ ); ?>
809
+ </li>
810
+ <?php
811
+ }
812
+ if ( ! empty( $api->slug ) && empty( $api->external ) ) {
813
+ ?>
814
+ <li><a target="_blank"
815
+ href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php fs_echo( 'wp-org-plugin-page', $api->slug ); ?> &#187;</a>
816
+ </li>
817
+ <?php
818
+ }
819
+ if ( ! empty( $api->homepage ) ) {
820
+ ?>
821
+ <li><a target="_blank"
822
+ href="<?php echo esc_url( $api->homepage ); ?>"><?php fs_echo( 'plugin-homepage', $api->slug ); ?> &#187;</a>
823
+ </li>
824
+ <?php
825
+ }
826
+ if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) {
827
+ ?>
828
+ <li><a target="_blank"
829
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php fs_echo( 'donate-to-plugin', $api->slug ); ?> &#187;</a>
830
+ </li>
831
+ <?php } ?>
832
+ </ul>
833
+ </div>
834
+ <?php if ( ! empty( $api->rating ) ) { ?>
835
+ <h3><?php fs_echo( 'average-rating', $api->slug ); ?></h3>
836
+ <?php wp_star_rating( array(
837
+ 'rating' => $api->rating,
838
+ 'type' => 'percent',
839
+ 'number' => $api->num_ratings
840
+ ) ); ?>
841
+ <small>(<?php printf(
842
+ fs_text( 'based-on-x', $api->slug ),
843
+ sprintf(
844
+ fs_text( ( 1 == $api->num_ratings ) ? 'x-rating' : 'x-ratings', $api->slug ),
845
+ number_format_i18n( $api->num_ratings )
846
+ ) ); ?>)</small>
847
+ <?php
848
+ }
849
+
850
+ if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
851
+ foreach ( $api->ratings as $key => $ratecount ) {
852
+ // Avoid div-by-zero.
853
+ $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
854
+ $stars_label = sprintf(
855
+ fs_text( ( 1 == $key ) ? 'x-star' : 'x-stars', $api->slug ),
856
+ number_format_i18n( $key )
857
+ );
858
+ ?>
859
+ <div class="counter-container">
860
+ <span class="counter-label"><a
861
+ href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
862
+ target="_blank"
863
+ title="<?php echo esc_attr( sprintf( fs_text('click-to-reviews', $api->slug), $stars_label) ) ?>"><?php echo $stars_label ?></a></span>
864
+ <span class="counter-back">
865
+ <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
866
+ </span>
867
+ <span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span>
868
+ </div>
869
+ <?php
870
+ }
871
+ }
872
+ if ( ! empty( $api->contributors ) ) {
873
+ ?>
874
+ <h3><?php fs_echo( 'contributors', $api->slug ); ?></h3>
875
+ <ul class="contributors">
876
+ <?php
877
+ foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
878
+ if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
879
+ continue;
880
+ }
881
+ if ( empty( $contrib_username ) ) {
882
+ $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
883
+ }
884
+ $contrib_username = sanitize_user( $contrib_username );
885
+ if ( empty( $contrib_profile ) ) {
886
+ echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</li>";
887
+ } else {
888
+ 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>";
889
+ }
890
+ }
891
+ ?>
892
+ </ul>
893
+ <?php if ( ! empty( $api->donate_link ) ) { ?>
894
+ <a target="_blank"
895
+ href="<?php echo esc_url( $api->donate_link ); ?>"><?php fs_echo( 'donate-to-plugin', $api->slug ) ?> &#187;</a>
896
+ <?php } ?>
897
+ <?php } ?>
898
+ </div>
899
+ <div id="section-holder" class="wrap">
900
+ <?php
901
+ if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
902
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . fs_text( 'warning:', $api->slug ) . '</strong> ' . fs_text( 'not-tested-warning', $api->slug ) . '</p></div>';
903
+ } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
904
+ echo '<div class="notice notice-warning"><p>' . '<strong>' . fs_text( 'warning:', $api->slug ) . '</strong> ' . fs_text( 'not-compatible-warning', $api->slug ) . '</p></div>';
905
+ }
906
+
907
+ foreach ( (array) $api->sections as $section_name => $content ) {
908
+ $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
909
+ $content = links_add_target( $content, '_blank' );
910
+
911
+ $san_section = esc_attr( $section_name );
912
+
913
+ $display = ( $section_name === $section ) ? 'block' : 'none';
914
+
915
+ if ( 'description' === $section_name &&
916
+ ( ( ! $api->external && $api->wp_org_missing ) ||
917
+ ( $api->external && $api->fs_missing ) )
918
+ ) {
919
+ $missing_notice = array(
920
+ 'type' => 'error',
921
+ 'id' => md5( microtime() ),
922
+ 'message' => fs_text( ( $api->is_paid ? 'paid-addon-not-deployed' : 'free-addon-not-deployed' ), $api->slug ),
923
+ );
924
+ fs_require_template( 'admin-notice.php', $missing_notice );
925
+ }
926
+ echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
927
+ echo $content;
928
+ echo "\t</div>\n";
929
+ }
930
+ echo "</div>\n";
931
+ echo "</div>\n";
932
+ echo "</div>\n"; // #plugin-information-scrollable
933
+ echo "<div id='$tab-footer'>\n";
934
+
935
+ echo $this->get_plugin_cta( $api );
936
+
937
+ echo "</div>\n";
938
+
939
+ iframe_footer();
940
+ exit;
941
+ }
942
+ }
freemius/includes/i18n.php ADDED
@@ -0,0 +1,538 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ require_once dirname( __FILE__ ) . '/l10n.php';
14
+
15
+ /**
16
+ * All strings can now be overridden.
17
+ *
18
+ * For example, if we want to override:
19
+ * 'you-are-step-away' => 'You are just one step away - %s',
20
+ *
21
+ * We can use the filter:
22
+ * fs_override_i18n( array(
23
+ * 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
24
+ * 'skip' => __( 'Not today', '{your-text_domain}' ),
25
+ * ), '{plugin_slug}' );
26
+ *
27
+ * Or with the Freemius instance:
28
+ *
29
+ * my_freemius->override_i18n( array(
30
+ * 'opt-in-connect' => __( "Yes - I'm in!", '{your-text_domain}' ),
31
+ * 'skip' => __( 'Not today', '{your-text_domain}' ),
32
+ * );
33
+ */
34
+ global $fs_text;
35
+
36
+ $fs_text = array(
37
+ 'account' => _fs_text( 'Account' ),
38
+ 'addon' => _fs_text( 'Add On' ),
39
+ 'contact-us' => _fs_text( 'Contact Us' ),
40
+ 'contact-support' => _fs_text( 'Contact Support' ),
41
+ 'change-ownership' => _fs_text( 'Change Ownership' ),
42
+ 'support' => _fs_text( 'Support' ),
43
+ 'support-forum' => _fs_text( 'Support Forum' ),
44
+ 'add-ons' => _fs_text( 'Add Ons' ),
45
+ 'upgrade' => _fs_x( 'Upgrade', 'verb' ),
46
+ 'awesome' => _fs_text( 'Awesome' ),
47
+ 'pricing' => _fs_x( 'Pricing', 'noun' ),
48
+ 'price' => _fs_x( 'Price', 'noun' ),
49
+ 'unlimited-updates' => _fs_text( 'Unlimited Updates' ),
50
+ 'downgrade' => _fs_x( 'Downgrade', 'verb' ),
51
+ 'cancel-subscription' => _fs_x( 'Cancel Subscription', 'verb' ),
52
+ 'cancel-trial' => _fs_text( 'Cancel Trial' ),
53
+ 'free-trial' => _fs_text( 'Free Trial' ),
54
+ 'start-free-x' => _fs_text( 'Start my free %s' ),
55
+ 'no-commitment-x' => _fs_text( 'No commitment for %s - cancel anytime' ),
56
+ 'after-x-pay-as-little-y' => _fs_text( 'After your free %s, pay as little as %s' ),
57
+ 'details' => _fs_text( 'Details' ),
58
+ 'account-details' => _fs_text( 'Account Details' ),
59
+ 'delete' => _fs_x( 'Delete', 'verb' ),
60
+ 'show' => _fs_x( 'Show', 'verb' ),
61
+ 'hide' => _fs_x( 'Hide', 'verb' ),
62
+ 'edit' => _fs_x( 'Edit', 'verb' ),
63
+ 'update' => _fs_x( 'Update', 'verb' ),
64
+ 'date' => _fs_text( 'Date' ),
65
+ 'amount' => _fs_text( 'Amount' ),
66
+ 'invoice' => _fs_text( 'Invoice' ),
67
+ 'billing' => _fs_text( 'Billing' ),
68
+ 'payments' => _fs_text( 'Payments' ),
69
+ 'delete-account' => _fs_text( 'Delete Account' ),
70
+ 'dismiss' => _fs_x( 'Dismiss', 'as close a window' ),
71
+ 'plan' => _fs_x( 'Plan', 'as product pricing plan' ),
72
+ 'change-plan' => _fs_text( 'Change Plan' ),
73
+ 'download-x-version' => _fs_x( 'Download %s Version', 'as download professional version' ),
74
+ 'download-x-version-now' => _fs_x( 'Download %s version now', 'as download professional version now' ),
75
+ 'download-latest' => _fs_x( 'Download Latest', 'as download latest version' ),
76
+ 'you-have-x-license' => _fs_x( 'You have a %s license.', 'E.g. you have a professional license.' ),
77
+ 'new' => _fs_text( 'New' ),
78
+ 'free' => _fs_text( 'Free' ),
79
+ 'trial' => _fs_x( 'Trial', 'as trial plan' ),
80
+ 'start-trial' => _fs_x( 'Start Trial', 'as starting a trial plan' ),
81
+ 'purchase' => _fs_x( 'Purchase', 'verb' ),
82
+ 'purchase-license' => _fs_text( 'Purchase License' ),
83
+ 'buy' => _fs_x( 'Buy', 'verb' ),
84
+ 'buy-license' => _fs_text( 'Buy License' ),
85
+ 'license-single-site' => _fs_text( 'Single Site License' ),
86
+ 'license-unlimited' => _fs_text( 'Unlimited Licenses' ),
87
+ 'license-x-sites' => _fs_text( 'Up to %s Sites' ),
88
+ 'renew-license-now' => _fs_text( '%sRenew your license now%s to access version %s features and support.' ),
89
+ 'ask-for-upgrade-email-address' => _fs_text( "Enter the email address you've used for the upgrade below and we will resend you the license key." ),
90
+ 'x-plan' => _fs_x( '%s Plan', 'e.g. Professional Plan' ),
91
+ 'you-are-step-away' => _fs_text( 'You are just one step away - %s' ),
92
+ 'activate-x-now' => _fs_x( 'Complete "%s" Activation Now',
93
+ '%s - plugin name. As complete "Jetpack" activation now' ),
94
+ 'few-plugin-tweaks' => _fs_text( 'We made a few tweaks to the plugin, %s' ),
95
+ 'optin-x-now' => _fs_text( 'Opt-in to make "%s" Better!' ),
96
+ 'error' => _fs_text( 'Error' ),
97
+ 'failed-finding-main-path' => _fs_text( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.' ),
98
+ #region Account
99
+
100
+ 'expiration' => _fs_x( 'Expiration', 'as expiration date' ),
101
+ 'license' => _fs_x( 'License', 'as software license' ),
102
+ 'not-verified' => _fs_text( 'not verified' ),
103
+ 'verify-email' => _fs_text( 'Verify Email' ),
104
+ 'expires-in' => _fs_x( 'Expires in %s', 'e.g. expires in 2 months' ),
105
+ 'renews-in' => _fs_x( 'Auto renews in %s', 'e.g. auto renews in 2 months' ),
106
+ 'no-expiration' => _fs_text( 'No expiration' ),
107
+ 'expired' => _fs_text( 'Expired' ),
108
+ 'cancelled' => _fs_text( 'Cancelled' ),
109
+ 'in-x' => _fs_x( 'In %s', 'e.g. In 2 hours' ),
110
+ 'x-ago' => _fs_x( '%s ago', 'e.g. 2 min ago' ),
111
+ /* translators: %s: Version number (e.g. 4.6 or higher) */
112
+ 'x-or-higher' => _fs_text( '%s or higher' ),
113
+ 'version' => _fs_x( 'Version', 'as plugin version' ),
114
+ 'name' => _fs_text( 'Name' ),
115
+ 'email' => _fs_text( 'Email' ),
116
+ 'email-address' => _fs_text( 'Email address' ),
117
+ 'verified' => _fs_text( 'Verified' ),
118
+ 'module' => _fs_text( 'Module' ),
119
+ 'module-type' => _fs_text( 'Module Type' ),
120
+ 'plugin' => _fs_text( 'Plugin' ),
121
+ 'plugins' => _fs_text( 'Plugins' ),
122
+ 'theme' => _fs_text( 'Theme' ),
123
+ 'themes' => _fs_text( 'Themes' ),
124
+ 'path' => _fs_x( 'Path', 'as file/folder path' ),
125
+ 'title' => _fs_text( 'Title' ),
126
+ 'free-version' => _fs_text( 'Free version' ),
127
+ 'premium-version' => _fs_text( 'Premium version' ),
128
+ 'slug' => _fs_x( 'Slug', 'as WP plugin slug' ),
129
+ 'id' => _fs_text( 'ID' ),
130
+ 'users' => _fs_text( 'Users' ),
131
+ 'plugin-installs' => _fs_text( 'Plugin Installs' ),
132
+ 'module-installs' => _fs_text( '%s Installs' ),
133
+ 'sites' => _fs_x( 'Sites', 'like websites' ),
134
+ 'user-id' => _fs_text( 'User ID' ),
135
+ 'site-id' => _fs_text( 'Site ID' ),
136
+ 'public-key' => _fs_text( 'Public Key' ),
137
+ 'secret-key' => _fs_text( 'Secret Key' ),
138
+ 'no-secret' => _fs_x( 'No Secret', 'as secret encryption key missing' ),
139
+ 'no-id' => _fs_text( 'No ID' ),
140
+ 'sync-license' => _fs_x( 'Sync License', 'as synchronize license' ),
141
+ 'sync' => _fs_x( 'Sync', 'as synchronize' ),
142
+ 'activate-license' => _fs_text( 'Activate License' ),
143
+ 'activate-free-version' => _fs_text( 'Activate Free Version' ),
144
+ 'activate-license-message' => _fs_text( 'Please enter the license key that you received in the email right after the purchase:' ),
145
+ 'activating-license' => _fs_text( 'Activating license...' ),
146
+ 'change-license' => _fs_text( 'Change License' ),
147
+ 'update-license' => _fs_text( 'Update License' ),
148
+ 'deactivate-license' => _fs_text( 'Deactivate License' ),
149
+ 'activate' => _fs_text( 'Activate' ),
150
+ 'deactivate' => _fs_text( 'Deactivate' ),
151
+ 'skip-deactivate' => _fs_text( 'Skip & Deactivate' ),
152
+ 'skip-and-x' => _fs_text( 'Skip & %s' ),
153
+ 'no-deactivate' => _fs_text( 'No - just deactivate' ),
154
+ 'yes-do-your-thing' => _fs_text( 'Yes - do your thing' ),
155
+ 'active' => _fs_x( 'Active', 'active mode' ),
156
+ 'is-active' => _fs_x( 'Is Active', 'is active mode?' ),
157
+ 'install-now' => _fs_text( 'Install Now' ),
158
+ 'install-update-now' => _fs_text( 'Install Update Now' ),
159
+ 'more-information-about-x' => _fs_text( 'More information about %s' ),
160
+ 'localhost' => _fs_text( 'Localhost' ),
161
+ 'activate-x-plan' => _fs_x( 'Activate %s Plan', 'as activate Professional plan' ),
162
+ 'x-left' => _fs_x( '%s left', 'as 5 licenses left' ),
163
+ 'last-license' => _fs_text( 'Last license' ),
164
+ 'what-is-your-x' => _fs_text( 'What is your %s?' ),
165
+ 'activate-this-addon' => _fs_text( 'Activate this add-on' ),
166
+ 'deactivate-license-confirm' => _fs_text( '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?' ),
167
+ 'delete-account-x-confirm' => _fs_text( '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?' ),
168
+ 'delete-account-confirm' => _fs_text( '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?' ),
169
+ 'downgrade-x-confirm' => _fs_text( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.' ),
170
+ 'cancel-trial-confirm' => _fs_text( 'Cancelling the trial will immediately block access to all premium features. Are you sure?' ),
171
+ 'after-downgrade-non-blocking' => _fs_text( 'You can still enjoy all %s features but you will not have access to plugin updates and support.' ),
172
+ 'after-downgrade-blocking' => _fs_text( 'Once your license expires you can still use the Free version but you will NOT have access to the %s features.' ),
173
+ 'proceed-confirmation' => _fs_text( 'Are you sure you want to proceed?' ),
174
+ #endregion Account
175
+
176
+ 'add-ons-for-x' => _fs_text( 'Add Ons for %s' ),
177
+ 'add-ons-missing' => _fs_text( 'We could\'nt load the add-ons list. It\'s probably an issue on our side, please try to come back in few minutes.' ),
178
+ #region Plugin Deactivation
179
+ 'anonymous-feedback' => _fs_text( 'Anonymous feedback' ),
180
+ 'quick-feedback' => _fs_text( 'Quick feedback' ),
181
+ 'deactivation-share-reason' => _fs_text( 'If you have a moment, please let us know why you are deactivating' ),
182
+ 'deactivation-modal-button-confirm' => _fs_text( 'Yes - Deactivate' ),
183
+ 'deactivation-modal-button-submit' => _fs_text( 'Submit & Deactivate' ),
184
+ 'cancel' => _fs_text( 'Cancel' ),
185
+ 'reason-no-longer-needed' => _fs_text( 'I no longer need the plugin' ),
186
+ 'reason-found-a-better-plugin' => _fs_text( 'I found a better plugin' ),
187
+ 'reason-needed-for-a-short-period' => _fs_text( 'I only needed the plugin for a short period' ),
188
+ 'reason-broke-my-site' => _fs_text( 'The plugin broke my site' ),
189
+ 'reason-suddenly-stopped-working' => _fs_text( 'The plugin suddenly stopped working' ),
190
+ 'reason-cant-pay-anymore' => _fs_text( "I can't pay for it anymore" ),
191
+ 'reason-temporary-deactivation' => _fs_text( "It's a temporary deactivation. I'm just debugging an issue." ),
192
+ 'reason-other' => _fs_x( 'Other',
193
+ 'the text of the "other" reason for deactivating the plugin that is shown in the modal box.' ),
194
+ 'ask-for-reason-message' => _fs_text( 'Kindly tell us the reason so we can improve.' ),
195
+ 'placeholder-plugin-name' => _fs_text( "What's the plugin's name?" ),
196
+ 'placeholder-comfortable-price' => _fs_text( 'What price would you feel comfortable paying?' ),
197
+ 'reason-couldnt-make-it-work' => _fs_text( "I couldn't understand how to make it work" ),
198
+ 'reason-great-but-need-specific-feature' => _fs_text( "The plugin is great, but I need specific feature that you don't support" ),
199
+ 'reason-not-working' => _fs_text( 'The plugin is not working' ),
200
+ 'reason-not-what-i-was-looking-for' => _fs_text( "It's not what I was looking for" ),
201
+ 'reason-didnt-work-as-expected' => _fs_text( "The plugin didn't work as expected" ),
202
+ 'placeholder-feature' => _fs_text( 'What feature?' ),
203
+ 'placeholder-share-what-didnt-work' => _fs_text( "Kindly share what didn't work so we can fix it for future users..." ),
204
+ 'placeholder-what-youve-been-looking-for' => _fs_text( "What you've been looking for?" ),
205
+ 'placeholder-what-did-you-expect' => _fs_text( "What did you expect?" ),
206
+ 'reason-didnt-work' => _fs_text( "The plugin didn't work" ),
207
+ 'reason-dont-like-to-share-my-information' => _fs_text( "I don't like to share my information with you" ),
208
+ 'dont-have-to-share-any-data' => _fs_text( "You might have missed it, but you don't have to share any data and can just %s the opt-in." ),
209
+ #endregion Plugin Deactivation
210
+
211
+ #region Connect
212
+ 'hey-x' => _fs_x( 'Hey %s,', 'greeting' ),
213
+ 'thanks-x' => _fs_x( 'Thanks %s!', 'a greeting. E.g. Thanks John!' ),
214
+ 'connect-message' => _fs_text( 'Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s.' ),
215
+ 'connect-message_on-update' => _fs_text( 'Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that\'s okay! %1$s will still work just fine.' ),
216
+ 'pending-activation-message' => _fs_text( '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 %s.' ),
217
+ 'complete-the-install' => _fs_text( 'complete the install' ),
218
+ 'start-the-trial' => _fs_text( 'start the trial' ),
219
+ 'thanks-for-purchasing' => _fs_text( 'Thanks for purchasing %s! To get started, please enter your license key:' ),
220
+ 'license-sync-disclaimer' => _fs_text( 'The plugin will be periodically sending data to %s to check for plugin updates and verify the validity of your license.' ),
221
+ 'what-permissions' => _fs_text( 'What permissions are being granted?' ),
222
+ 'permissions-profile' => _fs_text( 'Your Profile Overview' ),
223
+ 'permissions-profile_desc' => _fs_text( 'Name and email address' ),
224
+ 'permissions-site' => _fs_text( 'Your Site Overview' ),
225
+ 'permissions-site_desc' => _fs_text( 'Site URL, WP version, PHP info, plugins & themes' ),
226
+ 'permissions-events' => _fs_text( 'Current Plugin Events' ),
227
+ 'permissions-events_desc' => _fs_text( 'Activation, deactivation and uninstall' ),
228
+ 'permissions-plugins_themes' => _fs_text( 'Plugins & Themes' ),
229
+ 'permissions-plugins_themes_desc' => _fs_text( 'Titles, versions and state.' ),
230
+ 'permissions-admin-notices' => _fs_text( 'Admin Notices' ),
231
+ 'permissions-newsletter' => _fs_text( 'Newsletter' ),
232
+ 'permissions-newsletter_desc' => _fs_text( 'Updates, announcements, marketing, no spam' ),
233
+ 'privacy-policy' => _fs_text( 'Privacy Policy' ),
234
+ 'tos' => _fs_text( 'Terms of Service' ),
235
+ 'activating' => _fs_x( 'Activating', 'as activating plugin' ),
236
+ 'sending-email' => _fs_x( 'Sending email', 'as in the process of sending an email' ),
237
+ 'opt-in-connect' => _fs_x( 'Allow & Continue', 'button label' ),
238
+ 'agree-activate-license' => _fs_x( 'Agree & Activate License', 'button label' ),
239
+ 'skip' => _fs_x( 'Skip', 'verb' ),
240
+ 'click-here-to-use-plugin-anonymously' => _fs_text( 'Click here to use the plugin anonymously' ),
241
+ 'resend-activation-email' => _fs_text( 'Re-send activation email' ),
242
+ 'license-key' => _fs_text( 'License key' ),
243
+ 'send-license-key' => _fs_text( 'Send License Key' ),
244
+ 'sending-license-key' => _fs_text( 'Sending license key' ),
245
+ 'have-license-key' => _fs_text( 'Have a license key?' ),
246
+ 'dont-have-license-key' => _fs_text( 'Don\'t have a license key?' ),
247
+ 'cant-find-license-key' => _fs_text( "Can't find your license key?" ),
248
+ 'email-not-found' => _fs_text( "We couldn't find your email address in the system, are you sure it's the right address?" ),
249
+ 'no-active-licenses' => _fs_text( "We can't see any active licenses associated with that email address, are you sure it's the right address?" ),
250
+ 'opt-in' => _fs_text( 'Opt In' ),
251
+ 'opt-out' => _fs_text( 'Opt Out' ),
252
+ 'opt-out-cancel' => _fs_text( 'On second thought - I want to continue helping' ),
253
+ 'opting-out' => _fs_text( 'Opting out...' ),
254
+ 'opting-in' => _fs_text( 'Opting in...' ),
255
+ 'opt-out-message-appreciation' => _fs_text( 'We appreciate your help in making the %s better by letting us track some usage data.' ),
256
+ 'opt-out-message-usage-tracking' => _fs_text( "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking." ),
257
+ 'opt-out-message-clicking-opt-out' => _fs_text( 'By clicking "Opt Out", we will no longer be sending any data from %s to %s.' ),
258
+ #endregion Connect
259
+
260
+ #region Screenshots
261
+ 'screenshots' => _fs_text( 'Screenshots' ),
262
+ 'view-full-size-x' => _fs_text( 'Click to view full-size screenshot %d' ),
263
+ #endregion Screenshots
264
+
265
+ #region Debug
266
+ 'freemius-debug' => _fs_text( 'Freemius Debug' ),
267
+ 'on' => _fs_x( 'On', 'as turned on' ),
268
+ 'off' => _fs_x( 'Off', 'as turned off' ),
269
+ 'debugging' => _fs_x( 'Debugging', 'as code debugging' ),
270
+ 'freemius-state' => _fs_text( 'Freemius State' ),
271
+ 'connected' => _fs_x( 'Connected', 'as connection was successful' ),
272
+ 'blocked' => _fs_x( 'Blocked', 'as connection blocked' ),
273
+ 'api' => _fs_x( 'API', 'as application program interface' ),
274
+ 'sdk' => _fs_x( 'SDK', 'as software development kit versions' ),
275
+ 'sdk-versions' => _fs_x( 'SDK Versions', 'as software development kit versions' ),
276
+ 'plugin-path' => _fs_x( 'Plugin Path', 'as plugin folder path' ),
277
+ 'sdk-path' => _fs_x( 'SDK Path', 'as sdk path' ),
278
+ 'addons-of-x' => _fs_text( 'Add Ons of Plugin %s' ),
279
+ 'delete-all-confirm' => _fs_text( 'Are you sure you want to delete all Freemius data?' ),
280
+ 'actions' => _fs_text( 'Actions' ),
281
+ 'delete-all-accounts' => _fs_text( 'Delete All Accounts' ),
282
+ 'start-fresh' => _fs_text( 'Start Fresh' ),
283
+ 'clear-api-cache' => _fs_text( 'Clear API Cache' ),
284
+ 'sync-data-from-server' => _fs_text( 'Sync Data From Server' ),
285
+ 'scheduled-crons' => _fs_text( 'Scheduled Crons' ),
286
+ 'cron-type' => _fs_text( 'Cron Type' ),
287
+ 'plugins-themes-sync' => _fs_text( 'Plugins & Themes Sync' ),
288
+ 'licenses' => _fs_text( 'Licenses' ),
289
+ 'debug-log' => _fs_text( 'Debug Log' ),
290
+ 'all' => _fs_text( 'All' ),
291
+ 'file' => _fs_text( 'File' ),
292
+ 'function' => _fs_text( 'Function' ),
293
+ 'process-id' => _fs_text( 'Process ID' ),
294
+ 'logger' => _fs_text( 'Logger' ),
295
+ 'message' => _fs_text( 'Message' ),
296
+ 'download' => _fs_text( 'Download' ),
297
+ 'filter' => _fs_text( 'Filter' ),
298
+ 'type' => _fs_text( 'Type' ),
299
+ 'all-types' => _fs_text( 'All Types' ),
300
+ 'all-requests' => _fs_text( 'All Requests' ),
301
+ #endregion Debug
302
+
303
+ #region Expressions
304
+ 'congrats' => _fs_x( 'Congrats', 'as congratulations' ),
305
+ 'oops' => _fs_x( 'Oops', 'exclamation' ),
306
+ 'yee-haw' => _fs_x( 'Yee-haw', 'interjection expressing joy or exuberance' ),
307
+ 'woot' => _fs_x( 'W00t',
308
+ '(especially in electronic communication) used to express elation, enthusiasm, or triumph.' ),
309
+ 'right-on' => _fs_x( 'Right on', 'a positive response' ),
310
+ 'hmm' => _fs_x( 'Hmm',
311
+ 'something somebody says when they are thinking about what you have just said. ' ),
312
+ 'ok' => _fs_text( 'O.K' ),
313
+ 'hey' => _fs_x( 'Hey', 'exclamation' ),
314
+ 'heads-up' => _fs_x( 'Heads up',
315
+ 'advance notice of something that will need attention.' ),
316
+ #endregion Expressions
317
+
318
+ #region Admin Notices
319
+ 'you-have-latest' => _fs_text( 'Seems like you got the latest release.' ),
320
+ 'you-are-good' => _fs_text( 'You are all good!' ),
321
+ 'user-exist-message' => _fs_text( 'Sorry, we could not complete the email update. Another user with the same email is already registered.' ),
322
+ 'user-exist-message_ownership' => _fs_text( 'If you would like to give up the ownership of the plugin\'s account to %s click the Change Ownership button.' ),
323
+ 'email-updated-message' => _fs_text( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.' ),
324
+ 'name-updated-message' => _fs_text( 'Your name was successfully updated.' ),
325
+ 'x-updated' => _fs_text( 'You have successfully updated your %s.' ),
326
+ 'name-update-failed-message' => _fs_text( 'Please provide your full name.' ),
327
+ 'verification-email-sent-message' => _fs_text( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.' ),
328
+ 'addons-info-external-message' => _fs_text( 'Just letting you know that the add-ons information of %s is being pulled from an external server.' ),
329
+ 'no-cc-required' => _fs_text( 'No credit card required' ),
330
+ 'premium-activated-message' => _fs_text( 'Premium plugin version was successfully activated.' ),
331
+ 'successful-version-upgrade-message' => _fs_text( 'The upgrade of %s was successfully completed.' ),
332
+ 'activation-with-plan-x-message' => _fs_text( 'Your account was successfully activated with the %s plan.' ),
333
+ 'download-latest-x-version-now' => _fs_text( 'Download the latest %s version now' ),
334
+ 'follow-steps-to-complete-upgrade' => _fs_text( 'Please follow these steps to complete the upgrade' ),
335
+ 'download-latest-x-version' => _fs_text( 'Download the latest %s version' ),
336
+ 'download-latest-version' => _fs_text( 'Download the latest version' ),
337
+ 'deactivate-free-version' => _fs_text( 'Deactivate the free version' ),
338
+ 'upload-and-activate' => _fs_text( 'Upload and activate the downloaded version' ),
339
+ 'howto-upload-activate' => _fs_text( 'How to upload and activate?' ),
340
+ 'addon-successfully-purchased-message' => _fs_x( '%s Add-on was successfully purchased.',
341
+ '%s - product name, e.g. Facebook add-on was successfully...' ),
342
+ 'addon-successfully-upgraded-message' => _fs_text( 'Your %s Add-on plan was successfully upgraded.' ),
343
+ 'email-verified-message' => _fs_text( 'Your email has been successfully verified - you are AWESOME!' ),
344
+ 'plan-upgraded-message' => _fs_text( 'Your plan was successfully upgraded.' ),
345
+ 'plan-changed-to-x-message' => _fs_text( 'Your plan was successfully changed to %s.' ),
346
+ 'license-expired-blocking-message' => _fs_text( 'Your license has expired. You can still continue using the free plugin forever.' ),
347
+ 'license-cancelled' => _fs_text( 'Your license has been cancelled. If you think it\'s a mistake, please contact support.' ),
348
+ 'trial-started-message' => _fs_text( 'Your trial has been successfully started.' ),
349
+ 'license-activated-message' => _fs_text( 'Your license was successfully activated.' ),
350
+ 'no-active-license-message' => _fs_text( 'It looks like your site currently doesn\'t have an active license.' ),
351
+ 'license-deactivation-message' => _fs_text( 'Your license was successfully deactivated, you are back to the %s plan.' ),
352
+ 'license-deactivation-failed-message' => _fs_text( 'It looks like the license deactivation failed.' ),
353
+ 'license-activation-failed-message' => _fs_text( 'It looks like the license could not be activated.' ),
354
+ 'server-error-message' => _fs_text( 'Error received from the server:' ),
355
+ 'trial-expired-message' => _fs_text( 'Your trial has expired. You can still continue using all our free features.' ),
356
+ 'plan-x-downgraded-message' => _fs_text( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.' ),
357
+ 'plan-downgraded-failure-message' => _fs_text( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.' ),
358
+ 'trial-cancel-no-trial-message' => _fs_text( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)' ),
359
+ 'trial-cancel-message' => _fs_text( 'Your %s free trial was successfully cancelled.' ),
360
+ 'version-x-released' => _fs_x( 'Version %s was released.', '%s - numeric version number' ),
361
+ 'please-download-x' => _fs_text( 'Please download %s.' ),
362
+ 'latest-x-version' => _fs_x( 'the latest %s version here',
363
+ '%s - plan name, as the latest professional version here' ),
364
+ 'trial-x-promotion-message' => _fs_text( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.' ),
365
+ 'start-free-trial' => _fs_x( 'Start free trial', 'call to action' ),
366
+ 'starting-trial' => _fs_text( 'Starting trial' ),
367
+ 'please-wait' => _fs_text( 'Please wait' ),
368
+ 'trial-cancel-failure-message' => _fs_text( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.' ),
369
+ 'trial-utilized' => _fs_text( 'You already utilized a trial before.' ),
370
+ 'in-trial-mode' => _fs_text( 'You are already running the plugin in a trial mode.' ),
371
+ 'trial-plan-x-not-exist' => _fs_text( 'Plan %s do not exist, therefore, can\'t start a trial.' ),
372
+ 'plan-x-no-trial' => _fs_text( 'Plan %s does not support a trial period.' ),
373
+ 'no-trials' => _fs_text( 'None of the plugin\'s plans supports a trial period.' ),
374
+ 'unexpected-api-error' => _fs_text( 'Unexpected API error. Please contact the plugin\'s author with the following error.' ),
375
+ 'no-commitment-for-x-days' => _fs_text( 'No commitment for %s days - cancel anytime!' ),
376
+ 'license-expired-non-blocking-message' => _fs_text( '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.' ),
377
+ 'could-not-activate-x' => _fs_text( 'Couldn\'t activate %s.' ),
378
+ 'contact-us-with-error-message' => _fs_text( 'Please contact us with the following message:' ),
379
+ 'plan-did-not-change-message' => _fs_text( '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.' ),
380
+ 'contact-us-here' => _fs_text( 'Please contact us here' ),
381
+ 'plan-did-not-change-email-message' => _fs_text( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.' ),
382
+ #endregion Admin Notices
383
+ #region Connectivity Issues
384
+ 'connectivity-test-fails-message' => _fs_text( 'From unknown reason, the API connectivity test failed.' ),
385
+ 'connectivity-test-maybe-temporary' => _fs_text( '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?' ),
386
+ 'curl-missing-message' => _fs_text( 'We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server.' ),
387
+ 'curl-disabled-methods' => _fs_text( 'Disabled method(s):' ),
388
+ 'cloudflare-blocks-connection-message' => _fs_text( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.' ),
389
+ 'x-requires-access-to-api' => _fs_x( '%s requires an access to our API.',
390
+ 'as pluginX requires an access to our API' ),
391
+ 'squid-blocks-connection-message' => _fs_text( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.' ),
392
+ 'squid-no-clue-title' => _fs_text( 'I don\'t know what is Squid or ACL, help me!' ),
393
+ 'squid-no-clue-desc' => _fs_text( '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.' ),
394
+ 'sysadmin-title' => _fs_text( 'I\'m a system administrator' ),
395
+ 'squid-sysadmin-desc' => _fs_text( 'Great, please whitelist the following domains: %s. Once you are done, deactivate the plugin and activate it again.' ),
396
+ 'curl-missing-no-clue-title' => _fs_text( 'I don\'t know what is cURL or how to install it, help me!' ),
397
+ 'curl-missing-no-clue-desc' => _fs_text( '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.' ),
398
+ 'curl-missing-sysadmin-desc' => _fs_text( 'Great, please install cURL and enable it in your php.ini file. In addition, search for the \'disable_functions\' directive in your php.ini file and remove any disabled methods starting with \'curl_\'. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the plugin and reactivate it back again.' ),
399
+ 'happy-to-resolve-issue-asap' => _fs_text( '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.' ),
400
+ 'contact-support-before-deactivation' => _fs_text( 'Sorry for the inconvenience and we are here to help if you give us a chance.' ),
401
+ 'fix-issue-title' => _fs_text( 'Yes - I\'m giving you a chance to fix it' ),
402
+ 'fix-issue-desc' => _fs_text( '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.' ),
403
+ 'install-previous-title' => _fs_text( 'Let\'s try your previous version' ),
404
+ 'install-previous-desc' => _fs_text( 'Uninstall this version and install the previous one.' ),
405
+ 'deactivate-plugin-title' => _fs_text( 'That\'s exhausting, please deactivate' ),
406
+ 'deactivate-plugin-desc' => _fs_text( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.' ),
407
+ 'fix-request-sent-message' => _fs_text( '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.' ),
408
+ 'server-blocking-access' => _fs_x( 'Your server is blocking the access to Freemius\' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s',
409
+ '%1s - plugin title, %2s - API domain' ),
410
+ 'wrong-authentication-param-message' => _fs_text( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.' ),
411
+ #endregion Connectivity Issues
412
+ #region Change Owner
413
+ 'change-owner-request-sent-x' => _fs_text( '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.' ),
414
+ 'change-owner-request_owner-confirmed' => _fs_text( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.' ),
415
+ 'change-owner-request_candidate-confirmed' => _fs_text( '%s is the new owner of the account.' ),
416
+ #endregion Change Owner
417
+ 'addon-x-cannot-run-without-y' => _fs_x( '%s cannot run without %s.',
418
+ 'addonX cannot run without pluginY' ),
419
+ 'addon-x-cannot-run-without-parent' => _fs_x( '%s cannot run without the plugin.', 'addonX cannot run...' ),
420
+ 'plugin-x-activation-message' => _fs_x( '%s activation was successfully completed.',
421
+ 'pluginX activation was successfully...' ),
422
+ 'features-and-pricing' => _fs_x( 'Features & Pricing', 'Plugin installer section title' ),
423
+ 'free-addon-not-deployed' => _fs_text( 'Add-on must be deployed to WordPress.org or Freemius.' ),
424
+ 'paid-addon-not-deployed' => _fs_text( 'Paid add-on must be deployed to Freemius.' ),
425
+ #--------------------------------------------------------------------------------
426
+ #region Add-On Licensing
427
+ #--------------------------------------------------------------------------------
428
+ 'addon-no-license-message' => _fs_text( '%s is a premium only add-on. You have to purchase a license first before activating the plugin.' ),
429
+ 'addon-trial-cancelled-message' => _fs_text( '%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.' ),
430
+ #endregion
431
+ #--------------------------------------------------------------------------------
432
+ #region Billing Cycles
433
+ #--------------------------------------------------------------------------------
434
+ 'monthly' => _fs_x( 'Monthly', 'as every month' ),
435
+ 'mo' => _fs_x( 'mo', 'as monthly period' ),
436
+ 'annual' => _fs_x( 'Annual', 'as once a year' ),
437
+ 'annually' => _fs_x( 'Annually', 'as once a year' ),
438
+ 'once' => _fs_x( 'Once', 'as once a year' ),
439
+ 'year' => _fs_x( 'year', 'as annual period' ),
440
+ 'lifetime' => _fs_text( 'Lifetime' ),
441
+ 'best' => _fs_x( 'Best', 'e.g. the best product' ),
442
+ 'billed-x' => _fs_x( 'Billed %s', 'e.g. billed monthly' ),
443
+ 'save-x' => _fs_x( 'Save %s', 'as a discount of $5 or 10%' ),
444
+ #endregion Billing Cycles
445
+ 'view-details' => _fs_text( 'View details' ),
446
+ #--------------------------------------------------------------------------------
447
+ #region Trial
448
+ #--------------------------------------------------------------------------------
449
+ 'approve-start-trial' => _fs_x( 'Approve & Start Trial', 'button label' ),
450
+ /* translators: %1$s: Number of trial days; %2$s: Plan name; */
451
+ 'start-trial-prompt-header' => _fs_text( 'You are 1-click away from starting your %1$s-day free trial of the %2$s plan.' ),
452
+ /* translators: %s: Link to freemius.com */
453
+ 'start-trial-prompt-message' => _fs_text( 'For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt-in with your user and non-sensitive site information, allowing the plugin to periodically send data to %s to check for version updates and to validate your trial.' ),
454
+
455
+ #endregion
456
+ #--------------------------------------------------------------------------------
457
+ #region Billing Details
458
+ #--------------------------------------------------------------------------------
459
+ 'business-name' => _fs_text( 'Business name' ),
460
+ 'tax-vat-id' => _fs_text( 'Tax / VAT ID' ),
461
+ 'address-line-n' => _fs_text( 'Address Line %d' ),
462
+ 'country' => _fs_text( 'Country' ),
463
+ 'select-country' => _fs_text( 'Select Country' ),
464
+ 'city' => _fs_text( 'City' ),
465
+ 'town' => _fs_text( 'Town' ),
466
+ 'state' => _fs_text( 'State' ),
467
+ 'province' => _fs_text( 'Province' ),
468
+ 'zip-postal-code' => _fs_text( 'ZIP / Postal Code' ),
469
+ #endregion
470
+ #--------------------------------------------------------------------------------
471
+ #region Module Installation
472
+ #--------------------------------------------------------------------------------
473
+ 'installing-plugin-x' => _fs_text( 'Installing plugin: %s' ),
474
+ 'auto-installation' => _fs_text( 'Automatic Installation' ),
475
+ /* translators: %s: Number of seconds */
476
+ 'x-sec' => _fs_text( '%s sec' ),
477
+ 'installing-in-n' => _fs_text( 'An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now.' ),
478
+ 'installing-module-x' => _fs_text( 'The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page.' ),
479
+ 'cancel-installation' => _fs_text( 'Cancel Installation' ),
480
+ 'module-package-rename-failure' => _fs_text( 'The remote plugin package does not contain a folder with the desired slug and renaming did not work.' ),
481
+ 'auto-install-error-invalid-id' => _fs_text( 'Invalid module ID.' ),
482
+ 'auto-install-error-not-opted-in' => _fs_text( 'Auto installation only works for opted-in users.' ),
483
+ 'auto-install-error-premium-activated' => _fs_text( 'Premium version already active.' ),
484
+ 'auto-install-error-premium-addon-activated' => _fs_text( 'Premium add-on version already installed.' ),
485
+ 'auto-install-error-invalid-license' => _fs_text( 'You do not have a valid license to access the premium version.' ),
486
+ 'auto-install-error-serviceware' => _fs_text( 'Plugin is a "Serviceware" which means it does not have a premium code version.' ),
487
+ #endregion
488
+ );
489
+
490
+ /**
491
+ * Localization of the strings in the plugin/theme info dialog box.
492
+ *
493
+ * $fs_module_info_text should ONLY include strings that are not located in $fs_text.
494
+ *
495
+ * @author Vova Feldman (@svovaf)
496
+ * @since 1.2.2
497
+ */
498
+ global $fs_module_info_text;
499
+
500
+ $fs_module_info_text = array(
501
+ 'description' => _fs_x( 'Description', 'Plugin installer section title' ),
502
+ 'installation' => _fs_x( 'Installation', 'Plugin installer section title' ),
503
+ 'faq' => _fs_x( 'FAQ', 'Plugin installer section title' ),
504
+ 'changelog' => _fs_x( 'Changelog', 'Plugin installer section title' ),
505
+ 'reviews' => _fs_x( 'Reviews', 'Plugin installer section title' ),
506
+ 'other_notes' => _fs_x( 'Other Notes', 'Plugin installer section title' ),
507
+ /* translators: %s: 1 or One */
508
+ 'x-star' => _fs_text( '%s star' ),
509
+ /* translators: %s: Number larger than 1 */
510
+ 'x-stars' => _fs_text( '%s stars' ),
511
+ /* translators: %s: 1 or One */
512
+ 'x-rating' => _fs_text( '%s rating' ),
513
+ /* translators: %s: Number larger than 1 */
514
+ 'x-ratings' => _fs_text( '%s ratings' ),
515
+ /* translators: %s: 1 or One (Number of times downloaded) */
516
+ 'x-time' => _fs_text( '%s time' ),
517
+ /* translators: %s: Number of times downloaded */
518
+ 'x-times' => _fs_text( '%s times' ),
519
+ /* translators: %s: # of stars (e.g. 5 stars) */
520
+ 'click-to-reviews' => _fs_text( 'Click to see reviews that provided a rating of %s' ),
521
+ 'last-updated:' => _fs_text( 'Last Updated' ),
522
+ 'requires-wordpress-version:' => _fs_text( 'Requires WordPress Version:' ),
523
+ 'author:' => _fs_x( 'Author:', 'as the plugin author' ),
524
+ 'compatible-up-to:' => _fs_text( 'Compatible up to:' ),
525
+ 'downloaded:' => _fs_text( 'Downloaded:' ),
526
+ 'wp-org-plugin-page' => _fs_text( 'WordPress.org Plugin Page' ),
527
+ 'plugin-homepage' => _fs_text( 'Plugin Homepage' ),
528
+ 'donate-to-plugin' => _fs_text( 'Donate to this plugin' ),
529
+ 'average-rating' => _fs_text( 'Average Rating' ),
530
+ 'based-on-x' => _fs_text( 'based on %s' ),
531
+ 'warning:' => _fs_text( 'Warning:' ),
532
+ 'contributors' => _fs_text( 'Contributors' ),
533
+ 'plugin-install' => _fs_text( 'Plugin Install' ),
534
+ 'not-tested-warning' => _fs_text( 'This plugin has not been tested with your current version of WordPress.' ),
535
+ 'not-compatible-warning' => _fs_text( 'This plugin has not been marked as compatible with your version of WordPress.' ),
536
+ 'newer-installed' => _fs_text( 'Newer Version (%s) Installed' ),
537
+ 'latest-installed' => _fs_text( 'Latest Version Installed' ),
538
+ );
freemius/includes/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/l10n.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.2.1.6
7
+ */
8
+
9
+ if ( ! defined( 'ABSPATH' ) ) {
10
+ exit;
11
+ }
12
+
13
+ /**
14
+ * Retrieve the translation of $text.
15
+ *
16
+ * @since 1.2.1.6
17
+ *
18
+ * @param string $text
19
+ *
20
+ * @return string
21
+ */
22
+ function _fs_text( $text ) {
23
+ return translate( $text, 'freemius' );
24
+ }
25
+
26
+ /**
27
+ * Retrieve the translation of $text and escapes it for safe use in an attribute.
28
+ *
29
+ * @since 1.2.1.6
30
+ *
31
+ * @param string $text
32
+ *
33
+ * @return string
34
+ */
35
+ function _fs_esc_attr( $text ) {
36
+ return esc_attr( translate( $text, 'freemius' ) );
37
+ }
38
+
39
+ /**
40
+ * Retrieve the translation of $text and escapes it for safe use in HTML output.
41
+ *
42
+ * @since 1.2.1.6
43
+ *
44
+ * @param string $text
45
+ *
46
+ * @return string
47
+ */
48
+ function _fs_esc_html( $text ) {
49
+ return esc_html( translate( $text, 'freemius' ) );
50
+ }
51
+
52
+ /**
53
+ * Display translated text.
54
+ *
55
+ * @since 1.2.0
56
+ *
57
+ * @param string $text
58
+ */
59
+ function _fs_echo( $text ) {
60
+ echo translate( $text, 'freemius' );
61
+ }
62
+
63
+ /**
64
+ * Display translated text that has been escaped for safe use in an attribute.
65
+ *
66
+ * @since 1.2.1.6
67
+ *
68
+ * @param string $text
69
+ */
70
+ function _fs_esc_attr_echo( $text ) {
71
+ echo esc_attr( translate( $text, 'freemius' ) );
72
+ }
73
+
74
+ /**
75
+ * Display translated text that has been escaped for safe use in HTML output.
76
+ *
77
+ * @since 1.2.1.6
78
+ *
79
+ * @param string $text
80
+ */
81
+ function _fs_esc_html_echo( $text ) {
82
+ echo esc_html( translate( $text, 'freemius' ) );
83
+ }
84
+
85
+ /**
86
+ * Retrieve translated string with gettext context.
87
+ *
88
+ * Quite a few times, there will be collisions with similar translatable text
89
+ * found in more than two places, but with different translated context.
90
+ *
91
+ * By including the context in the pot file, translators can translate the two
92
+ * strings differently.
93
+ *
94
+ * @since 1.2.1.6
95
+ *
96
+ * @param string $text
97
+ * @param string $context
98
+ *
99
+ * @return string
100
+ */
101
+ function _fs_x( $text, $context ) {
102
+ return translate_with_gettext_context( $text, $context, 'freemius' );
103
+ }
104
+
105
+ /**
106
+ * Display translated string with gettext context.
107
+ *
108
+ * @since 1.2.1.6
109
+ *
110
+ * @param string $text
111
+ * @param string $context
112
+ */
113
+ function _fs_ex( $text, $context ) {
114
+ // Avoid misleading Theme Check warning.
115
+ $fn = '_x';
116
+ echo $fn( $text, $context, 'freemius' );
117
+ }
118
+
119
+ /**
120
+ * Translate string with gettext context, and escapes it for safe use in an attribute.
121
+ *
122
+ * @since 1.2.1.6
123
+ *
124
+ * @param string $text
125
+ * @param string $context
126
+ *
127
+ * @return string
128
+ */
129
+ function _fs_esc_attr_x( $text, $context ) {
130
+ return esc_attr( translate_with_gettext_context( $text, $context, 'freemius' ) );
131
+ }
132
+
133
+ /**
134
+ * Translate string with gettext context, and escapes it for safe use in HTML output.
135
+ *
136
+ * @since 2.9.0
137
+ *
138
+ * @param string $text
139
+ * @param string $context
140
+ *
141
+ * @return string
142
+ */
143
+ function _fs_esc_html_x( $text, $context ) {
144
+ return esc_html( translate_with_gettext_context( $text, $context, 'freemius' ) );
145
+ }
146
+
147
+ /**
148
+ * Translates and retrieves the singular or plural form based on the supplied number.
149
+ *
150
+ * @since 1.2.1.6
151
+ *
152
+ * @param string $single
153
+ * @param string $plural
154
+ * @param int $number
155
+ *
156
+ * @return string
157
+ */
158
+ function _fs_n( $single, $plural, $number ) {
159
+ $translations = get_translations_for_domain( 'freemius' );
160
+ $translation = $translations->translate_plural( $single, $plural, $number );
161
+
162
+ /**
163
+ * Filters the singular or plural form of a string.
164
+ *
165
+ * @since WP 2.2.0
166
+ *
167
+ * @param string $translation
168
+ * @param string $single
169
+ * @param string $plural
170
+ * @param string $number
171
+ * @param string $domain
172
+ */
173
+ return apply_filters( 'ngettext', $translation, $single, $plural, $number, 'freemius' );
174
+ }
175
+
176
+ /**
177
+ * Translates and retrieves the singular or plural form based on the supplied number, with gettext context.
178
+ *
179
+ * @since 1.2.1.6
180
+ *
181
+ * @param string $single
182
+ * @param string $plural
183
+ * @param int $number
184
+ * @param string $context
185
+ *
186
+ * @return string
187
+ */
188
+ function _fs_nx($single, $plural, $number, $context ) {
189
+ $translations = get_translations_for_domain( 'freemius' );
190
+ $translation = $translations->translate_plural( $single, $plural, $number, $context );
191
+
192
+ /**
193
+ * Filters the singular or plural form of a string with gettext context.
194
+ *
195
+ * @since WP 3.0
196
+ *
197
+ * @param string $translation
198
+ * @param string $single
199
+ * @param string $plural
200
+ * @param string $number
201
+ * @param string $context
202
+ * @param string $domain
203
+ */
204
+ return apply_filters( 'ngettext_with_context', $translation, $single, $plural, $number, $context, 'freemius' );
205
+ }
206
+
207
+ /**
208
+ * Registers plural strings in POT file, but does not translate them.
209
+ *
210
+ * Used when you want to keep structures with translatable plural
211
+ * strings and use them later when the number is known.
212
+ *
213
+ * @since 1.2.1.6
214
+ *
215
+ * @param string $singular
216
+ * @param string $plural
217
+ *
218
+ * @return array
219
+ */
220
+ function _fs_n_noop( $singular, $plural ) {
221
+ return array(
222
+ 'singular' => $singular,
223
+ 'plural' => $plural,
224
+ 'context' => null,
225
+ 'domain' => 'freemius'
226
+ );
227
+ }
228
+
229
+ /**
230
+ * Registers plural strings with gettext context in POT file, but does not translate them.
231
+ *
232
+ * Used when you want to keep structures with translatable plural
233
+ * strings and use them later when the number is known.
234
+ *
235
+ * @since 1.2.1.6
236
+ *
237
+ * @param string $singular
238
+ * @param string $plural
239
+ * @param string $context
240
+ *
241
+ * @return array
242
+ */
243
+ function _fs_nx_noop( $singular, $plural, $context ) {
244
+ return array(
245
+ 'singular' => $singular,
246
+ 'plural' => $plural,
247
+ 'context' => $context,
248
+ 'domain' => 'freemius'
249
+ );
250
+ }
freemius/includes/managers/class-fs-admin-menu-manager.php ADDED
@@ -0,0 +1,782 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 array<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
+ * @since 1.2.2
72
+ *
73
+ * @var bool
74
+ */
75
+ private $_menu_exists;
76
+
77
+ #endregion Properties
78
+
79
+ /**
80
+ * @var FS_Logger
81
+ */
82
+ protected $_logger;
83
+
84
+ #region Singleton
85
+
86
+ /**
87
+ * @var FS_Admin_Menu_Manager[]
88
+ */
89
+ private static $_instances = array();
90
+
91
+ /**
92
+ * @param string $plugin_slug
93
+ *
94
+ * @return FS_Admin_Menu_Manager
95
+ */
96
+ static function instance( $plugin_slug ) {
97
+ if ( ! isset( self::$_instances[ $plugin_slug ] ) ) {
98
+ self::$_instances[ $plugin_slug ] = new FS_Admin_Menu_Manager( $plugin_slug );
99
+ }
100
+
101
+ return self::$_instances[ $plugin_slug ];
102
+ }
103
+
104
+ protected function __construct( $plugin_slug ) {
105
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $plugin_slug . '_admin_menu', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
106
+
107
+ $this->_plugin_slug = $plugin_slug;
108
+ }
109
+
110
+ #endregion Singleton
111
+
112
+ #region Helpers
113
+
114
+ private function get_option( &$options, $key, $default = false ) {
115
+ return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
116
+ }
117
+
118
+ private function get_bool_option( &$options, $key, $default = false ) {
119
+ return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
120
+ }
121
+
122
+ #endregion Helpers
123
+
124
+ /**
125
+ * @param array $menu
126
+ * @param bool $is_addon
127
+ */
128
+ function init( $menu, $is_addon = false ) {
129
+ $this->_menu_exists = ( isset( $menu['slug'] ) && ! empty( $menu['slug'] ) );
130
+
131
+ $this->_menu_slug = ! empty( $menu['slug'] ) ? $menu['slug'] : null;
132
+
133
+ $this->_default_submenu_items = array();
134
+ // @deprecated
135
+ $this->_type = 'page';
136
+ $this->_is_top_level = true;
137
+ $this->_is_override_exact = false;
138
+ $this->_parent_slug = false;
139
+ // @deprecated
140
+ $this->_parent_type = 'page';
141
+
142
+ if ( ! $is_addon && isset( $menu ) ) {
143
+ $this->_default_submenu_items = array(
144
+ 'contact' => $this->get_bool_option( $menu, 'contact', true ),
145
+ 'support' => $this->get_bool_option( $menu, 'support', true ),
146
+ 'account' => $this->get_bool_option( $menu, 'account', true ),
147
+ 'pricing' => $this->get_bool_option( $menu, 'pricing', true ),
148
+ 'addons' => $this->get_bool_option( $menu, 'addons', true ),
149
+ );
150
+
151
+ // @deprecated
152
+ $this->_type = $this->get_option( $menu, 'type', 'page' );
153
+ $this->_is_override_exact = $this->get_bool_option( $menu, 'override_exact' );
154
+
155
+ if ( isset( $menu['parent'] ) ) {
156
+ $this->_parent_slug = $this->get_option( $menu['parent'], 'slug' );
157
+ // @deprecated
158
+ $this->_parent_type = $this->get_option( $menu['parent'], 'type', 'page' );
159
+
160
+ // If parent's slug is different, then it's NOT a top level menu item.
161
+ $this->_is_top_level = ( $this->_parent_slug === $this->_menu_slug );
162
+ } else {
163
+ /**
164
+ * If no parent then top level if:
165
+ * - Has custom admin menu ('page')
166
+ * - CPT menu type ('cpt')
167
+ */
168
+ // $this->_is_top_level = in_array( $this->_type, array(
169
+ // 'cpt',
170
+ // 'page'
171
+ // ) );
172
+ }
173
+
174
+ $this->_first_time_path = $this->get_option( $menu, 'first-path', false );
175
+ if ( ! empty( $this->_first_time_path ) && is_string( $this->_first_time_path ) ) {
176
+ $this->_first_time_path = admin_url( $this->_first_time_path, 'admin' );
177
+ }
178
+ }
179
+ }
180
+
181
+ /**
182
+ * Check if top level menu.
183
+ *
184
+ * @author Vova Feldman (@svovaf)
185
+ * @since 1.1.3
186
+ *
187
+ * @return bool False if submenu item.
188
+ */
189
+ function is_top_level() {
190
+ return $this->_is_top_level;
191
+ }
192
+
193
+ /**
194
+ * Check if the page should be override on exact URL match.
195
+ *
196
+ * @author Vova Feldman (@svovaf)
197
+ * @since 1.1.3
198
+ *
199
+ * @return bool False if submenu item.
200
+ */
201
+ function is_override_exact() {
202
+ return $this->_is_override_exact;
203
+ }
204
+
205
+
206
+ /**
207
+ * Get the path of the page the user should be forwarded to after first activation.
208
+ *
209
+ * @author Vova Feldman (@svovaf)
210
+ * @since 1.1.3
211
+ *
212
+ * @return string
213
+ */
214
+ function get_first_time_path() {
215
+ return $this->_first_time_path;
216
+ }
217
+
218
+ /**
219
+ * Check if plugin's menu item is part of a custom top level menu.
220
+ *
221
+ * @author Vova Feldman (@svovaf)
222
+ * @since 1.1.3
223
+ *
224
+ * @return bool
225
+ */
226
+ function has_custom_parent() {
227
+ return ! $this->_is_top_level && is_string( $this->_parent_slug );
228
+ }
229
+
230
+ /**
231
+ * @author Leo Fajardo (@leorw)
232
+ * @since 1.2.2
233
+ *
234
+ * @return bool
235
+ */
236
+ function has_menu() {
237
+ return $this->_menu_exists;
238
+ }
239
+
240
+ /**
241
+ * @author Vova Feldman (@svovaf)
242
+ * @since 1.1.3
243
+ *
244
+ * @param string $id
245
+ * @param bool $default
246
+ *
247
+ * @return bool
248
+ */
249
+ function is_submenu_item_visible( $id, $default = true ) {
250
+ if ( ! $this->has_menu() ) {
251
+ return false;
252
+ }
253
+
254
+ return fs_apply_filter(
255
+ $this->_plugin_slug,
256
+ 'is_submenu_visible',
257
+ $this->get_bool_option( $this->_default_submenu_items, $id, $default ),
258
+ $id
259
+ );
260
+ }
261
+
262
+ /**
263
+ * Calculates admin settings menu slug.
264
+ * If plugin's menu slug is a file (e.g. CPT), uses plugin's slug as the menu slug.
265
+ *
266
+ * @author Vova Feldman (@svovaf)
267
+ * @since 1.1.3
268
+ *
269
+ * @param string $page
270
+ *
271
+ * @return string
272
+ */
273
+ function get_slug( $page = '' ) {
274
+ return ( ( false === strpos( $this->_menu_slug, '.php?' ) ) ?
275
+ $this->_menu_slug :
276
+ $this->_plugin_slug ) . ( empty( $page ) ? '' : ( '-' . $page ) );
277
+ }
278
+
279
+ /**
280
+ * Check if module has a menu slug set.
281
+ *
282
+ * @author Vova Feldman (@svovaf)
283
+ * @since 1.2.1.6
284
+ *
285
+ * @return bool
286
+ */
287
+ function has_menu_slug() {
288
+ return $this->has_menu();
289
+ }
290
+
291
+ /**
292
+ * @author Vova Feldman (@svovaf)
293
+ * @since 1.1.3
294
+ *
295
+ * @return string
296
+ */
297
+ function get_parent_slug() {
298
+ return $this->_parent_slug;
299
+ }
300
+
301
+ /**
302
+ * @author Vova Feldman (@svovaf)
303
+ * @since 1.1.3
304
+ *
305
+ * @return string
306
+ */
307
+ function get_type() {
308
+ return $this->_type;
309
+ }
310
+
311
+ /**
312
+ * @author Vova Feldman (@svovaf)
313
+ * @since 1.1.3
314
+ *
315
+ * @return bool
316
+ */
317
+ function is_cpt() {
318
+ return ( 0 === strpos( $this->_menu_slug, 'edit.php?post_type=' ) ||
319
+ // Back compatibility.
320
+ 'cpt' === $this->_type
321
+ );
322
+ }
323
+
324
+ /**
325
+ * @author Vova Feldman (@svovaf)
326
+ * @since 1.1.3
327
+ *
328
+ * @return string
329
+ */
330
+ function get_parent_type() {
331
+ return $this->_parent_type;
332
+ }
333
+
334
+ /**
335
+ * @author Vova Feldman (@svovaf)
336
+ * @since 1.1.3
337
+ *
338
+ * @return string
339
+ */
340
+ function get_raw_slug() {
341
+ return $this->_menu_slug;
342
+ }
343
+
344
+ /**
345
+ * Get plugin's original menu slug.
346
+ *
347
+ * @author Vova Feldman (@svovaf)
348
+ * @since 1.1.3
349
+ *
350
+ * @return string
351
+ */
352
+ function get_original_menu_slug() {
353
+ if ( 'cpt' === $this->_type ) {
354
+ return add_query_arg( array(
355
+ 'post_type' => $this->_menu_slug
356
+ ), 'edit.php' );
357
+ }
358
+
359
+ if ( false === strpos( $this->_menu_slug, '.php?' ) ) {
360
+ return $this->_menu_slug;
361
+ } else {
362
+ return $this->_plugin_slug;
363
+ }
364
+ }
365
+
366
+ /**
367
+ * @author Vova Feldman (@svovaf)
368
+ * @since 1.1.3
369
+ *
370
+ * @return string
371
+ */
372
+ function get_top_level_menu_slug() {
373
+ return $this->has_custom_parent() ?
374
+ $this->get_parent_slug() :
375
+ $this->get_raw_slug();
376
+ }
377
+
378
+ /**
379
+ * Is user on plugin's admin activation page.
380
+ *
381
+ * @author Vova Feldman (@svovaf)
382
+ * @since 1.0.8
383
+ *
384
+ * @return bool
385
+ */
386
+ function is_main_settings_page() {
387
+ if ( $this->_menu_exists &&
388
+ ( fs_is_plugin_page( $this->_menu_slug ) || fs_is_plugin_page( $this->_plugin_slug ) )
389
+ ) {
390
+ /**
391
+ * Module has a settings menu and the context page is the main settings page, so assume it's in
392
+ * activation (doesn't really check if already opted-in/skipped or not).
393
+ *
394
+ * @since 1.2.2
395
+ */
396
+ return true;
397
+ }
398
+
399
+ return false;
400
+ }
401
+
402
+ #region Submenu Override
403
+
404
+ /**
405
+ * Override submenu's action.
406
+ *
407
+ * @author Vova Feldman (@svovaf)
408
+ * @since 1.1.0
409
+ *
410
+ * @param string $parent_slug
411
+ * @param string $menu_slug
412
+ * @param callable $function
413
+ *
414
+ * @return false|string If submenu exist, will return the hook name.
415
+ */
416
+ function override_submenu_action( $parent_slug, $menu_slug, $function ) {
417
+ global $submenu;
418
+
419
+ $menu_slug = plugin_basename( $menu_slug );
420
+ $parent_slug = plugin_basename( $parent_slug );
421
+
422
+ if ( ! isset( $submenu[ $parent_slug ] ) ) {
423
+ // Parent menu not exist.
424
+ return false;
425
+ }
426
+
427
+ $found_submenu_item = false;
428
+ foreach ( $submenu[ $parent_slug ] as $submenu_item ) {
429
+ if ( $menu_slug === $submenu_item[2] ) {
430
+ $found_submenu_item = $submenu_item;
431
+ break;
432
+ }
433
+ }
434
+
435
+ if ( false === $found_submenu_item ) {
436
+ // Submenu item not found.
437
+ return false;
438
+ }
439
+
440
+ // Remove current function.
441
+ $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
442
+ remove_all_actions( $hookname );
443
+
444
+ // Attach new action.
445
+ add_action( $hookname, $function );
446
+
447
+ return $hookname;
448
+ }
449
+
450
+ #endregion Submenu Override
451
+
452
+ #region Top level menu Override
453
+
454
+ /**
455
+ * Find plugin's admin dashboard main menu item.
456
+ *
457
+ * @author Vova Feldman (@svovaf)
458
+ * @since 1.0.2
459
+ *
460
+ * @return string[]|false
461
+ */
462
+ private function find_top_level_menu() {
463
+ global $menu;
464
+
465
+ $position = - 1;
466
+ $found_menu = false;
467
+
468
+ $menu_slug = $this->get_raw_slug();
469
+
470
+ $hook_name = get_plugin_page_hookname( $menu_slug, '' );
471
+ foreach ( $menu as $pos => $m ) {
472
+ if ( $menu_slug === $m[2] ) {
473
+ $position = $pos;
474
+ $found_menu = $m;
475
+ break;
476
+ }
477
+ }
478
+
479
+ if ( false === $found_menu ) {
480
+ return false;
481
+ }
482
+
483
+ return array(
484
+ 'menu' => $found_menu,
485
+ 'position' => $position,
486
+ 'hook_name' => $hook_name
487
+ );
488
+ }
489
+
490
+ /**
491
+ * Find plugin's admin dashboard main submenu item.
492
+ *
493
+ * @author Vova Feldman (@svovaf)
494
+ * @since 1.2.1.6
495
+ *
496
+ * @return array|false
497
+ */
498
+ private function find_main_submenu() {
499
+ global $submenu;
500
+
501
+ $top_level_menu_slug = $this->get_top_level_menu_slug();
502
+
503
+ if ( ! isset( $submenu[ $top_level_menu_slug ] ) ) {
504
+ return false;
505
+ }
506
+
507
+ $submenu_slug = $this->get_raw_slug();
508
+
509
+ $position = - 1;
510
+ $found_submenu = false;
511
+
512
+ $hook_name = get_plugin_page_hookname( $submenu_slug, '' );
513
+
514
+ foreach ( $submenu[ $top_level_menu_slug ] as $pos => $sub ) {
515
+ if ( $submenu_slug === $sub[2] ) {
516
+ $position = $pos;
517
+ $found_submenu = $sub;
518
+ }
519
+ }
520
+
521
+ if ( false === $found_submenu ) {
522
+ return false;
523
+ }
524
+
525
+ return array(
526
+ 'menu' => $found_submenu,
527
+ 'parent_slug' => $top_level_menu_slug,
528
+ 'position' => $position,
529
+ 'hook_name' => $hook_name
530
+ );
531
+ }
532
+
533
+ /**
534
+ * Remove all sub-menu items.
535
+ *
536
+ * @author Vova Feldman (@svovaf)
537
+ * @since 1.0.7
538
+ *
539
+ * @return bool If submenu with plugin's menu slug was found.
540
+ */
541
+ private function remove_all_submenu_items() {
542
+ global $submenu;
543
+
544
+ $menu_slug = $this->get_raw_slug();
545
+
546
+ if ( ! isset( $submenu[ $menu_slug ] ) ) {
547
+ return false;
548
+ }
549
+
550
+ $submenu[ $menu_slug ] = array();
551
+
552
+ return true;
553
+ }
554
+
555
+ /**
556
+ *
557
+ * @author Vova Feldman (@svovaf)
558
+ * @since 1.0.9
559
+ *
560
+ * @return false|array[string]mixed
561
+ */
562
+ function remove_menu_item() {
563
+ $this->_logger->entrance();
564
+
565
+ // Find main menu item.
566
+ $menu = $this->find_top_level_menu();
567
+
568
+ if ( false === $menu ) {
569
+ return false;
570
+ }
571
+
572
+ // Remove it with its actions.
573
+ remove_all_actions( $menu['hook_name'] );
574
+
575
+ // Remove all submenu items.
576
+ $this->remove_all_submenu_items();
577
+
578
+ return $menu;
579
+ }
580
+
581
+ /**
582
+ * @author Vova Feldman (@svovaf)
583
+ * @since 1.1.4
584
+ *
585
+ * @param callable $function
586
+ *
587
+ * @return false|array[string]mixed
588
+ */
589
+ function override_menu_item( $function ) {
590
+ $found_menu = $this->remove_menu_item();
591
+
592
+ if ( false === $found_menu ) {
593
+ return false;
594
+ }
595
+
596
+ if ( ! $this->is_top_level() || ! $this->is_cpt() ) {
597
+ $menu_slug = plugin_basename( $this->get_slug() );
598
+
599
+ $hookname = get_plugin_page_hookname( $menu_slug, '' );
600
+
601
+ // Override menu action.
602
+ add_action( $hookname, $function );
603
+ } else {
604
+ global $menu;
605
+
606
+ // Remove original CPT menu.
607
+ unset( $menu[ $found_menu['position'] ] );
608
+
609
+ // Create new top-level menu action.
610
+ $hookname = self::add_page(
611
+ $found_menu['menu'][3],
612
+ $found_menu['menu'][0],
613
+ 'manage_options',
614
+ $this->get_slug(),
615
+ $function,
616
+ $found_menu['menu'][6],
617
+ $found_menu['position']
618
+ );
619
+ }
620
+
621
+ return $hookname;
622
+ }
623
+
624
+ /**
625
+ * Adds a counter to the module's top level menu item.
626
+ *
627
+ * @author Vova Feldman (@svovaf)
628
+ * @since 1.2.1.5
629
+ *
630
+ * @param int $counter
631
+ * @param string $class
632
+ */
633
+ function add_counter_to_menu_item( $counter = 1, $class = '' ) {
634
+ global $menu, $submenu;
635
+
636
+ $mask = '%s <span class="update-plugins %s count-%3$s" aria-hidden="true"><span>%3$s<span class="screen-reader-text">%3$s notifications</span></span></span>';
637
+
638
+ if ( $this->_is_top_level ) {
639
+ // Find main menu item.
640
+ $found_menu = $this->find_top_level_menu();
641
+
642
+ if ( false !== $found_menu ) {
643
+ // Override menu label.
644
+ $menu[ $found_menu['position'] ][0] = sprintf(
645
+ $mask,
646
+ $found_menu['menu'][0],
647
+ $class,
648
+ $counter
649
+ );
650
+ }
651
+ } else {
652
+ $found_submenu = $this->find_main_submenu();
653
+
654
+ if ( false !== $found_submenu ) {
655
+ // Override menu label.
656
+ $submenu[ $found_submenu['parent_slug'] ][ $found_submenu['position'] ][0] = sprintf(
657
+ $mask,
658
+ $found_submenu['menu'][0],
659
+ $class,
660
+ $counter
661
+ );
662
+ }
663
+ }
664
+ }
665
+
666
+ #endregion Top level menu Override
667
+
668
+ /**
669
+ * Add a top-level menu page.
670
+ *
671
+ * Note for WordPress.org Theme/Plugin reviewer:
672
+ *
673
+ * This is a replication of `add_menu_page()` to avoid Theme Check warning.
674
+ *
675
+ * Why?
676
+ * ====
677
+ * Freemius is an SDK for plugin and theme developers. Since the core
678
+ * of the SDK is relevant both for plugins and themes, for obvious reasons,
679
+ * we only develop and maintain one code base.
680
+ *
681
+ * This method will not run for wp.org themes (only plugins) since theme
682
+ * admin settings/options are now only allowed in the customizer.
683
+ *
684
+ * If you have any questions or need clarifications, please don't hesitate
685
+ * pinging me on slack, my username is @svovaf.
686
+ *
687
+ * @author Vova Feldman (@svovaf)
688
+ * @since 1.2.2
689
+ *
690
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is
691
+ * selected.
692
+ * @param string $menu_title The text to be used for the menu.
693
+ * @param string $capability The capability required for this menu to be displayed to the user.
694
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
695
+ * @param callable|string $function The function to be called to output the content for this page.
696
+ * @param string $icon_url The URL to the icon to be used for this menu.
697
+ * * Pass a base64-encoded SVG using a data URI, which will be colored to
698
+ * match the color scheme. This should begin with
699
+ * 'data:image/svg+xml;base64,'.
700
+ * * Pass the name of a Dashicons helper class to use a font icon,
701
+ * e.g. 'dashicons-chart-pie'.
702
+ * * Pass 'none' to leave div.wp-menu-image empty so an icon can be added
703
+ * via CSS.
704
+ * @param int $position The position in the menu order this one should appear.
705
+ *
706
+ * @return string The resulting page's hook_suffix.
707
+ */
708
+ static function add_page(
709
+ $page_title,
710
+ $menu_title,
711
+ $capability,
712
+ $menu_slug,
713
+ $function = '',
714
+ $icon_url = '',
715
+ $position = null
716
+ ) {
717
+ $fn = 'add_menu' . '_page';
718
+
719
+ return $fn(
720
+ $page_title,
721
+ $menu_title,
722
+ $capability,
723
+ $menu_slug,
724
+ $function,
725
+ $icon_url,
726
+ $position
727
+ );
728
+ }
729
+
730
+ /**
731
+ * Add a submenu page.
732
+ *
733
+ * Note for WordPress.org Theme/Plugin reviewer:
734
+ *
735
+ * This is a replication of `add_submenu_page()` to avoid Theme Check warning.
736
+ *
737
+ * Why?
738
+ * ====
739
+ * Freemius is an SDK for plugin and theme developers. Since the core
740
+ * of the SDK is relevant both for plugins and themes, for obvious reasons,
741
+ * we only develop and maintain one code base.
742
+ *
743
+ * This method will not run for wp.org themes (only plugins) since theme
744
+ * admin settings/options are now only allowed in the customizer.
745
+ *
746
+ * If you have any questions or need clarifications, please don't hesitate
747
+ * pinging me on slack, my username is @svovaf.
748
+ *
749
+ * @author Vova Feldman (@svovaf)
750
+ * @since 1.2.2
751
+ *
752
+ * @param string $parent_slug The slug name for the parent menu (or the file name of a standard
753
+ * WordPress admin page).
754
+ * @param string $page_title The text to be displayed in the title tags of the page when the menu is
755
+ * selected.
756
+ * @param string $menu_title The text to be used for the menu.
757
+ * @param string $capability The capability required for this menu to be displayed to the user.
758
+ * @param string $menu_slug The slug name to refer to this menu by (should be unique for this menu).
759
+ * @param callable|string $function The function to be called to output the content for this page.
760
+ *
761
+ * @return false|string The resulting page's hook_suffix, or false if the user does not have the capability
762
+ * required.
763
+ */
764
+ static function add_subpage(
765
+ $parent_slug,
766
+ $page_title,
767
+ $menu_title,
768
+ $capability,
769
+ $menu_slug,
770
+ $function = ''
771
+ ) {
772
+ $fn = 'add_submenu' . '_page';
773
+
774
+ return $fn( $parent_slug,
775
+ $page_title,
776
+ $menu_title,
777
+ $capability,
778
+ $menu_slug,
779
+ $function
780
+ );
781
+ }
782
+ }
freemius/includes/managers/class-fs-admin-notice-manager.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_fs_dismiss_notice_action_{$slug}", 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 ( function_exists( 'current_user_can' ) &&
133
+ ! current_user_can( 'manage_options' )
134
+ ) {
135
+ // Only show messages to admins.
136
+ return;
137
+ }
138
+
139
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
140
+ return;
141
+ }
142
+
143
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
144
+ fs_require_template( 'admin-notice.php', $msg );
145
+
146
+ if ( $msg['sticky'] ) {
147
+ self::has_sticky_messages();
148
+ }
149
+ }
150
+ }
151
+
152
+ /**
153
+ * Handle all_admin_notices by printing the admin messages stacked in the queue.
154
+ *
155
+ * @author Vova Feldman (@svovaf)
156
+ * @since 1.0.4
157
+ *
158
+ */
159
+ function _all_admin_notices_hook() {
160
+ $notice_type = 'all_admin_notices';
161
+
162
+ if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
163
+ return;
164
+ }
165
+
166
+ foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
167
+ fs_require_template( 'all-admin-notice.php', $msg );
168
+ }
169
+ }
170
+
171
+ /**
172
+ * Enqueue common stylesheet to style admin notice.
173
+ *
174
+ * @author Vova Feldman (@svovaf)
175
+ * @since 1.0.7
176
+ */
177
+ function _enqueue_styles() {
178
+ fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
179
+ }
180
+
181
+ /**
182
+ * Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
183
+ *
184
+ * @author Vova Feldman (@svovaf)
185
+ * @since 1.0.4
186
+ *
187
+ * @param string $message
188
+ * @param string $title
189
+ * @param string $type
190
+ * @param bool $is_sticky
191
+ * @param bool $all_admin
192
+ * @param string $id Message ID
193
+ * @param bool $store_if_sticky
194
+ *
195
+ * @uses add_action()
196
+ */
197
+ function add( $message, $title = '', $type = 'success', $is_sticky = false, $all_admin = false, $id = '', $store_if_sticky = true ) {
198
+ $key = ( $all_admin ? 'all_admin_notices' : 'admin_notices' );
199
+
200
+ if ( ! isset( $this->_admin_messages[ $key ] ) ) {
201
+ $this->_admin_messages[ $key ] = array();
202
+
203
+ add_action( $key, array( &$this, "_{$key}_hook" ) );
204
+ add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_styles' ) );
205
+
206
+ }
207
+
208
+ if ( '' === $id ) {
209
+ $id = md5( $title . ' ' . $message . ' ' . $type );
210
+ }
211
+
212
+ $message_object = array(
213
+ 'message' => $message,
214
+ 'title' => $title,
215
+ 'type' => $type,
216
+ 'sticky' => $is_sticky,
217
+ 'id' => $id,
218
+ 'all' => $all_admin,
219
+ 'slug' => $this->_slug,
220
+ 'plugin' => $this->_title,
221
+ );
222
+
223
+ if ( $is_sticky && $store_if_sticky ) {
224
+ $this->_sticky_storage->{$id} = $message_object;
225
+ }
226
+
227
+ $this->_admin_messages[ $key ][ $id ] = $message_object;
228
+ }
229
+
230
+ /**
231
+ * @author Vova Feldman (@svovaf)
232
+ * @since 1.0.7
233
+ *
234
+ * @param string|string[] $ids
235
+ */
236
+ function remove_sticky( $ids ) {
237
+ if ( ! is_array( $ids ) ) {
238
+ $ids = array( $ids );
239
+ }
240
+
241
+ foreach ( $ids as $id ) {
242
+ // Remove from sticky storage.
243
+ $this->_sticky_storage->remove( $id );
244
+
245
+ // Remove from current admin messages.
246
+ if ( isset( $this->_admin_messages['all_admin_notices'] ) && isset( $this->_admin_messages['all_admin_notices'][ $id ] ) ) {
247
+ unset( $this->_admin_messages['all_admin_notices'][ $id ] );
248
+ }
249
+ if ( isset( $this->_admin_messages['admin_notices'] ) && isset( $this->_admin_messages['admin_notices'][ $id ] ) ) {
250
+ unset( $this->_admin_messages['admin_notices'][ $id ] );
251
+ }
252
+ }
253
+ }
254
+
255
+ /**
256
+ * Check if sticky message exists by id.
257
+ *
258
+ * @author Vova Feldman (@svovaf)
259
+ * @since 1.0.9
260
+ *
261
+ * @param $id
262
+ *
263
+ * @return bool
264
+ */
265
+ function has_sticky( $id ) {
266
+ return isset( $this->_sticky_storage[ $id ] );
267
+ }
268
+
269
+ /**
270
+ * Adds sticky admin notification.
271
+ *
272
+ * @author Vova Feldman (@svovaf)
273
+ * @since 1.0.7
274
+ *
275
+ * @param string $message
276
+ * @param string $id Message ID
277
+ * @param string $title
278
+ * @param string $type
279
+ * @param bool $all_admin
280
+ */
281
+ function add_sticky( $message, $id, $title = '', $type = 'success', $all_admin = false ) {
282
+ $message = fs_apply_filter( $this->_slug, "sticky_message_{$id}", $message );
283
+ $title = fs_apply_filter( $this->_slug, "sticky_title_{$id}", $title );
284
+
285
+ $this->add( $message, $title, $type, true, $all_admin, $id );
286
+ }
287
+
288
+ /**
289
+ * Clear all sticky messages.
290
+ *
291
+ * @author Vova Feldman (@svovaf)
292
+ * @since 1.0.8
293
+ */
294
+ function clear_all_sticky() {
295
+ $this->_sticky_storage->clear_all();
296
+ }
297
+
298
+ /**
299
+ * Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
300
+ *
301
+ * @author Vova Feldman (@svovaf)
302
+ * @since 1.0.4
303
+ *
304
+ * @param string $message
305
+ * @param string $title
306
+ * @param string $type
307
+ * @param bool $is_sticky
308
+ * @param string $id Message ID
309
+ */
310
+ function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
311
+ $this->add( $message, $title, $type, $is_sticky, true, $id );
312
+ }
313
+ }
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,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
14
+ * Class FS_Key_Value_Storage
15
+ *
16
+ * @property int $install_timestamp
17
+ * @property int $activation_timestamp
18
+ * @property int $sync_timestamp
19
+ * @property object $sync_cron
20
+ * @property int $install_sync_timestamp
21
+ * @property array $connectivity_test
22
+ * @property array $is_on
23
+ * @property object $trial_plan
24
+ * @property bool $has_trial_plan
25
+ * @property bool $trial_promotion_shown
26
+ * @property string $sdk_version
27
+ * @property string $sdk_last_version
28
+ * @property bool $sdk_upgrade_mode
29
+ * @property bool $sdk_downgrade_mode
30
+ * @property bool $plugin_upgrade_mode
31
+ * @property bool $plugin_downgrade_mode
32
+ * @property string $plugin_version
33
+ * @property string $plugin_last_version
34
+ * @property bool $is_plugin_new_install
35
+ * @property bool $was_plugin_loaded
36
+ * @property object $plugin_main_file
37
+ * @property bool $prev_is_premium
38
+ * @property array $is_anonymous
39
+ * @property bool $is_pending_activation
40
+ * @property bool $sticky_optin_added
41
+ * @property object $uninstall_reason
42
+ * @property object $subscription
43
+ */
44
+ class FS_Key_Value_Storage implements ArrayAccess, Iterator, Countable {
45
+ /**
46
+ * @var string
47
+ */
48
+ protected $_id;
49
+ /**
50
+ * @var string
51
+ */
52
+ protected $_slug;
53
+ /**
54
+ * @var array
55
+ */
56
+ protected $_data;
57
+
58
+ /**
59
+ * @var FS_Plugin_Manager[]
60
+ */
61
+ private static $_instances = array();
62
+ /**
63
+ * @var FS_Logger
64
+ */
65
+ protected $_logger;
66
+
67
+ /**
68
+ * @param string $id
69
+ * @param string $slug
70
+ *
71
+ * @return FS_Key_Value_Storage
72
+ */
73
+ static function instance( $id, $slug ) {
74
+ $key = $id . ':' . $slug;
75
+ if ( ! isset( self::$_instances[ $key ] ) ) {
76
+ self::$_instances[ $key ] = new FS_Key_Value_Storage( $id, $slug );
77
+ }
78
+
79
+ return self::$_instances[ $key ];
80
+ }
81
+
82
+ protected function __construct( $id, $slug ) {
83
+ $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
84
+
85
+ $this->_slug = $slug;
86
+ $this->_id = $id;
87
+ $this->load();
88
+ }
89
+
90
+ protected function get_option_manager() {
91
+ return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
92
+ }
93
+
94
+ protected function get_all_data() {
95
+ return $this->get_option_manager()->get_option( $this->_id, array() );
96
+ }
97
+
98
+ /**
99
+ * Load plugin data from local DB.
100
+ *
101
+ * @author Vova Feldman (@svovaf)
102
+ * @since 1.0.7
103
+ */
104
+ function load() {
105
+ $all_plugins_data = $this->get_all_data();
106
+ $this->_data = isset( $all_plugins_data[ $this->_slug ] ) ?
107
+ $all_plugins_data[ $this->_slug ] :
108
+ array();
109
+ }
110
+
111
+ /**
112
+ * @author Vova Feldman (@svovaf)
113
+ * @since 1.0.7
114
+ *
115
+ * @param string $key
116
+ * @param mixed $value
117
+ * @param bool $flush
118
+ */
119
+ function store( $key, $value, $flush = true ) {
120
+ if ( $this->_logger->is_on() ) {
121
+ $this->_logger->entrance( $key . ' = ' . var_export( $value, true ) );
122
+ }
123
+
124
+ if ( array_key_exists( $key, $this->_data ) && $value === $this->_data[ $key ] ) {
125
+ // No need to store data if the value wasn't changed.
126
+ return;
127
+ }
128
+
129
+ $all_data = $this->get_all_data();
130
+
131
+ $this->_data[ $key ] = $value;
132
+
133
+ $all_data[ $this->_slug ] = $this->_data;
134
+
135
+ $options_manager = $this->get_option_manager();
136
+ $options_manager->set_option( $this->_id, $all_data, $flush );
137
+ }
138
+
139
+ /**
140
+ * @author Vova Feldman (@svovaf)
141
+ * @since 1.0.7
142
+ *
143
+ * @param bool $store
144
+ * @param string[] $exceptions Set of keys to keep and not clear.
145
+ */
146
+ function clear_all( $store = true, $exceptions = array() ) {
147
+ $new_data = array();
148
+ foreach ( $exceptions as $key ) {
149
+ if ( isset( $this->_data[ $key ] ) ) {
150
+ $new_data[ $key ] = $this->_data[ $key ];
151
+ }
152
+ }
153
+
154
+ $this->_data = $new_data;
155
+
156
+ if ( $store ) {
157
+ $all_data = $this->get_all_data();
158
+ $all_data[ $this->_slug ] = $this->_data;
159
+ $options_manager = $this->get_option_manager();
160
+ $options_manager->set_option( $this->_id, $all_data, true );
161
+ }
162
+ }
163
+
164
+ /**
165
+ * Delete key-value storage.
166
+ *
167
+ * @author Vova Feldman (@svovaf)
168
+ * @since 1.0.9
169
+ */
170
+ function delete() {
171
+ $this->_data = array();
172
+
173
+ $all_data = $this->get_all_data();
174
+ unset( $all_data[ $this->_slug ] );
175
+ $options_manager = $this->get_option_manager();
176
+ $options_manager->set_option( $this->_id, $all_data, true );
177
+ }
178
+
179
+ /**
180
+ * @author Vova Feldman (@svovaf)
181
+ * @since 1.0.7
182
+ *
183
+ * @param string $key
184
+ * @param bool $store
185
+ */
186
+ function remove( $key, $store = true ) {
187
+ if ( ! array_key_exists( $key, $this->_data ) ) {
188
+ return;
189
+ }
190
+
191
+ unset( $this->_data[ $key ] );
192
+
193
+ if ( $store ) {
194
+ $all_data = $this->get_all_data();
195
+ $all_data[ $this->_slug ] = $this->_data;
196
+ $options_manager = $this->get_option_manager();
197
+ $options_manager->set_option( $this->_id, $all_data, true );
198
+ }
199
+ }
200
+
201
+ /**
202
+ * @author Vova Feldman (@svovaf)
203
+ * @since 1.0.7
204
+ *
205
+ * @param string $key
206
+ * @param mixed $default
207
+ *
208
+ * @return bool|\FS_Plugin
209
+ */
210
+ function get( $key, $default = false ) {
211
+ return array_key_exists( $key, $this->_data ) ?
212
+ $this->_data[ $key ] :
213
+ $default;
214
+ }
215
+
216
+
217
+ /* ArrayAccess + Magic Access (better for refactoring)
218
+ -----------------------------------------------------------------------------------*/
219
+ function __set( $k, $v ) {
220
+ $this->store( $k, $v );
221
+ }
222
+
223
+ function __isset( $k ) {
224
+ return array_key_exists( $k, $this->_data );
225
+ }
226
+
227
+ function __unset( $k ) {
228
+ $this->remove( $k );
229
+ }
230
+
231
+ function __get( $k ) {
232
+ return $this->get( $k, null );
233
+ }
234
+
235
+ function offsetSet( $k, $v ) {
236
+ if ( is_null( $k ) ) {
237
+ throw new Exception( 'Can\'t append value to request params.' );
238
+ } else {
239
+ $this->{$k} = $v;
240
+ }
241
+ }
242
+
243
+ function offsetExists( $k ) {
244
+ return array_key_exists( $k, $this->_data );
245
+ }
246
+
247
+ function offsetUnset( $k ) {
248
+ unset( $this->$k );
249
+ }
250
+
251
+ function offsetGet( $k ) {
252
+ return $this->get( $k, null );
253
+ }
254
+
255
+ /**
256
+ * (PHP 5 &gt;= 5.0.0)<br/>
257
+ * Return the current element
258
+ *
259
+ * @link http://php.net/manual/en/iterator.current.php
260
+ * @return mixed Can return any type.
261
+ */
262
+ public function current() {
263
+ return current( $this->_data );
264
+ }
265
+
266
+ /**
267
+ * (PHP 5 &gt;= 5.0.0)<br/>
268
+ * Move forward to next element
269
+ *
270
+ * @link http://php.net/manual/en/iterator.next.php
271
+ * @return void Any returned value is ignored.
272
+ */
273
+ public function next() {
274
+ next( $this->_data );
275
+ }
276
+
277
+ /**
278
+ * (PHP 5 &gt;= 5.0.0)<br/>
279
+ * Return the key of the current element
280
+ *
281
+ * @link http://php.net/manual/en/iterator.key.php
282
+ * @return mixed scalar on success, or null on failure.
283
+ */
284
+ public function key() {
285
+ return key( $this->_data );
286
+ }
287
+
288
+ /**
289
+ * (PHP 5 &gt;= 5.0.0)<br/>
290
+ * Checks if current position is valid
291
+ *
292
+ * @link http://php.net/manual/en/iterator.valid.php
293
+ * @return boolean The return value will be casted to boolean and then evaluated.
294
+ * Returns true on success or false on failure.
295
+ */
296
+ public function valid() {
297
+ $key = key( $this->_data );
298
+
299
+ return ( $key !== null && $key !== false );
300
+ }
301
+
302
+ /**
303
+ * (PHP 5 &gt;= 5.0.0)<br/>
304
+ * Rewind the Iterator to the first element
305
+ *
306
+ * @link http://php.net/manual/en/iterator.rewind.php
307
+ * @return void Any returned value is ignored.
308
+ */
309
+ public function rewind() {
310
+ reset( $this->_data );
311
+ }
312
+
313
+ /**
314
+ * (PHP 5 &gt;= 5.1.0)<br/>
315
+ * Count elements of an object
316
+ *
317
+ * @link http://php.net/manual/en/countable.count.php
318
+ * @return int The custom count as an integer.
319
+ * </p>
320
+ * <p>
321
+ * The return value is cast to an integer.
322
+ */
323
+ public function count() {
324
+ return count( $this->_data );
325
+ }
326
+ }
freemius/includes/managers/class-fs-license-manager.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
94
+ * @var FS_Plugin_License $license
95
+ */
96
+ if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
97
+ return true;
98
+ }
99
+ }
100
+ }
101
+
102
+ return false;
103
+ }
104
+ }
freemius/includes/managers/class-fs-option-manager.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ( isset( $this->_options ) ) {
104
+ // Clear prev options.
105
+ $this->clear();
106
+ }
107
+
108
+ if ( ! WP_FS__DEBUG_SDK ) {
109
+ $this->_options = wp_cache_get( $option_name, WP_FS__SLUG );
110
+ }
111
+
112
+ // $this->_logger->info('wp_cache_get = ' . var_export($this->_options, true));
113
+
114
+ // if ( is_array( $this->_options ) ) {
115
+ // $this->clear();
116
+ // }
117
+
118
+ $cached = true;
119
+
120
+ if ( empty( $this->_options ) ) {
121
+ $this->_options = get_option( $option_name );
122
+
123
+ if ( is_string( $this->_options ) ) {
124
+ $this->_options = json_decode( $this->_options );
125
+ }
126
+
127
+ // $this->_logger->info('get_option = ' . var_export($this->_options, true));
128
+
129
+ if ( false === $this->_options ) {
130
+ $this->clear();
131
+ }
132
+
133
+ $cached = false;
134
+ }
135
+
136
+ if ( ! WP_FS__DEBUG_SDK && ! $cached ) // Set non encoded cache.
137
+ {
138
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
139
+ }
140
+ }
141
+ }
142
+
143
+ /**
144
+ * @author Vova Feldman (@svovaf)
145
+ * @since 1.0.3
146
+ *
147
+ * @return bool
148
+ */
149
+ function is_loaded() {
150
+ return isset( $this->_options );
151
+ }
152
+
153
+ /**
154
+ * @author Vova Feldman (@svovaf)
155
+ * @since 1.0.3
156
+ *
157
+ * @return bool
158
+ */
159
+ function is_empty() {
160
+ return ( $this->is_loaded() && false === $this->_options );
161
+ }
162
+
163
+ /**
164
+ * @author Vova Feldman (@svovaf)
165
+ * @since 1.0.6
166
+ *
167
+ * @param bool $flush
168
+ */
169
+ function clear( $flush = false ) {
170
+ $this->_logger->entrance();
171
+
172
+ $this->_options = array();
173
+
174
+ if ( $flush ) {
175
+ $this->store();
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Delete options manager from DB.
181
+ *
182
+ * @author Vova Feldman (@svovaf)
183
+ * @since 1.0.9
184
+ */
185
+ function delete() {
186
+ delete_option( $this->_get_option_manager_name() );
187
+ }
188
+
189
+ /**
190
+ * @author Vova Feldman (@svovaf)
191
+ * @since 1.0.6
192
+ *
193
+ * @param string $option
194
+ *
195
+ * @return bool
196
+ */
197
+ function has_option( $option ) {
198
+ return array_key_exists( $option, $this->_options );
199
+ }
200
+
201
+ /**
202
+ * @author Vova Feldman (@svovaf)
203
+ * @since 1.0.3
204
+ *
205
+ * @param string $option
206
+ * @param mixed $default
207
+ *
208
+ * @return mixed
209
+ */
210
+ function get_option( $option, $default = null ) {
211
+ $this->_logger->entrance( 'option = ' . $option );
212
+
213
+ if ( is_array( $this->_options ) ) {
214
+ return isset( $this->_options[ $option ] ) ? $this->_options[ $option ] : $default;
215
+ } else if ( is_object( $this->_options ) ) {
216
+ return isset( $this->_options->{$option} ) ? $this->_options->{$option} : $default;
217
+ }
218
+
219
+ return $default;
220
+ }
221
+
222
+ /**
223
+ * @author Vova Feldman (@svovaf)
224
+ * @since 1.0.3
225
+ *
226
+ * @param string $option
227
+ * @param mixed $value
228
+ * @param bool $flush
229
+ */
230
+ function set_option( $option, $value, $flush = false ) {
231
+ $this->_logger->entrance( 'option = ' . $option );
232
+
233
+ if ( ! $this->is_loaded() ) {
234
+ $this->clear();
235
+ }
236
+
237
+ if ( is_array( $this->_options ) ) {
238
+ $this->_options[ $option ] = $value;
239
+ } else if ( is_object( $this->_options ) ) {
240
+ $this->_options->{$option} = $value;
241
+ }
242
+
243
+ if ( $flush ) {
244
+ $this->store();
245
+ }
246
+ }
247
+
248
+ /**
249
+ * Unset option.
250
+ *
251
+ * @author Vova Feldman (@svovaf)
252
+ * @since 1.0.3
253
+ *
254
+ * @param string $option
255
+ * @param bool $flush
256
+ */
257
+ function unset_option( $option, $flush = false ) {
258
+ $this->_logger->entrance( 'option = ' . $option );
259
+
260
+ if ( is_array( $this->_options ) ) {
261
+ if ( ! isset( $this->_options[ $option ] ) ) {
262
+ return;
263
+ }
264
+
265
+ unset( $this->_options[ $option ] );
266
+
267
+ } else if ( is_object( $this->_options ) ) {
268
+ if ( ! isset( $this->_options->{$option} ) ) {
269
+ return;
270
+ }
271
+
272
+ unset( $this->_options->{$option} );
273
+ }
274
+
275
+ if ( $flush ) {
276
+ $this->store();
277
+ }
278
+ }
279
+
280
+ /**
281
+ * Dump options to database.
282
+ *
283
+ * @author Vova Feldman (@svovaf)
284
+ * @since 1.0.3
285
+ */
286
+ function store() {
287
+ $this->_logger->entrance();
288
+
289
+ $option_name = $this->_get_option_manager_name();
290
+
291
+ if ( $this->_logger->is_on() ) {
292
+ $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) );
293
+ }
294
+
295
+ // Update DB.
296
+ update_option( $option_name, $this->_options );
297
+
298
+ if ( ! WP_FS__DEBUG_SDK ) {
299
+ wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
300
+ }
301
+ }
302
+ }
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/managers/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/sdk/Exceptions/ArgumentNotExistException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
3
+ exit;
4
+ }
5
+
6
+ if ( ! class_exists( 'Freemius_ArgumentNotExistException' ) ) {
7
+ class Freemius_ArgumentNotExistException extends Freemius_InvalidArgumentException {
8
+ }
9
+ }
freemius/includes/sdk/Exceptions/EmptyArgumentException.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
3
+ exit;
4
+ }
5
+
6
+ if ( ! class_exists( 'Freemius_EmptyArgumentException' ) ) {
7
+ class Freemius_EmptyArgumentException extends Freemius_InvalidArgumentException {
8
+ }
9
+ }
freemius/includes/sdk/Exceptions/Exception.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_Exception' ) ) {
3
+ /**
4
+ * Thrown when an API call returns an exception.
5
+ *
6
+ */
7
+ class Freemius_Exception extends Exception {
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
+ $this->_result = $result;
19
+
20
+ $code = 0;
21
+ $message = 'Unknown error, please check GetResult().';
22
+ $type = '';
23
+
24
+ if ( isset( $result['error'] ) && is_array( $result['error'] ) ) {
25
+ if ( isset( $result['error']['code'] ) ) {
26
+ $code = $result['error']['code'];
27
+ }
28
+ if ( isset( $result['error']['message'] ) ) {
29
+ $message = $result['error']['message'];
30
+ }
31
+ if ( isset( $result['error']['type'] ) ) {
32
+ $type = $result['error']['type'];
33
+ }
34
+ }
35
+
36
+ $this->_type = $type;
37
+ $this->_code = $code;
38
+
39
+ parent::__construct( $message, is_numeric( $code ) ? $code : 0 );
40
+ }
41
+
42
+ /**
43
+ * Return the associated result object returned by the API server.
44
+ *
45
+ * @return array The result from the API server
46
+ */
47
+ public function getResult() {
48
+ return $this->_result;
49
+ }
50
+
51
+ public function getStringCode() {
52
+ return $this->_code;
53
+ }
54
+
55
+ public function getType() {
56
+ return $this->_type;
57
+ }
58
+
59
+ /**
60
+ * To make debugging easier.
61
+ *
62
+ * @return string The string representation of the error
63
+ */
64
+ public function __toString() {
65
+ $str = $this->getType() . ': ';
66
+
67
+ if ( $this->code != 0 ) {
68
+ $str .= $this->getStringCode() . ': ';
69
+ }
70
+
71
+ return $str . $this->getMessage();
72
+ }
73
+ }
74
+ }
freemius/includes/sdk/Exceptions/InvalidArgumentException.php ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_Exception' ) ) {
3
+ exit;
4
+ }
5
+
6
+ if ( ! class_exists( 'Freemius_InvalidArgumentException' ) ) {
7
+ class Freemius_InvalidArgumentException extends Freemius_Exception { }
8
+ }
freemius/includes/sdk/Exceptions/OAuthException.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! class_exists( 'Freemius_Exception' ) ) {
3
+ exit;
4
+ }
5
+
6
+ if ( ! class_exists( 'Freemius_OAuthException' ) ) {
7
+ class Freemius_OAuthException extends Freemius_Exception {
8
+ public function __construct( $pResult ) {
9
+ parent::__construct( $pResult );
10
+ }
11
+ }
12
+ }
freemius/includes/sdk/Exceptions/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/sdk/Freemius.php ADDED
@@ -0,0 +1,627 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if ( ! defined( 'FS_SDK__USER_AGENT' ) ) {
21
+ define( 'FS_SDK__USER_AGENT', 'fs-php-' . Freemius_Api_Base::VERSION );
22
+ }
23
+
24
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_CURL' ) ) {
25
+ define( 'FS_SDK__SIMULATE_NO_CURL', false );
26
+ }
27
+
28
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
29
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
30
+ }
31
+
32
+ if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
33
+ define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
34
+ }
35
+
36
+ if ( ! defined( 'FS_SDK__HAS_CURL' ) ) {
37
+ if ( FS_SDK__SIMULATE_NO_CURL ) {
38
+ define( 'FS_SDK__HAS_CURL', false );
39
+ } else {
40
+ $curl_required_methods = array(
41
+ 'curl_version',
42
+ 'curl_exec',
43
+ 'curl_init',
44
+ 'curl_close',
45
+ 'curl_setopt',
46
+ 'curl_setopt_array',
47
+ 'curl_error',
48
+ );
49
+
50
+ $has_curl = true;
51
+ foreach ( $curl_required_methods as $m ) {
52
+ if ( ! function_exists( $m ) ) {
53
+ $has_curl = false;
54
+ break;
55
+ }
56
+ }
57
+
58
+ define( 'FS_SDK__HAS_CURL', $has_curl );
59
+ }
60
+ }
61
+
62
+ $curl_version = FS_SDK__HAS_CURL ?
63
+ curl_version() :
64
+ array( 'version' => '7.37' );
65
+
66
+ if ( ! defined( 'FS_API__PROTOCOL' ) ) {
67
+ define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
68
+ }
69
+
70
+ if ( ! defined( 'FS_API__LOGGER_ON' ) ) {
71
+ define( 'FS_API__LOGGER_ON', false );
72
+ }
73
+
74
+ if ( ! defined( 'FS_API__ADDRESS' ) ) {
75
+ define( 'FS_API__ADDRESS', '://api.freemius.com' );
76
+ }
77
+ if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
78
+ define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
79
+ }
80
+
81
+ if ( class_exists( 'Freemius_Api' ) ) {
82
+ return;
83
+ }
84
+
85
+ class Freemius_Api extends Freemius_Api_Base {
86
+ private static $_logger = array();
87
+
88
+ /**
89
+ * @param string $pScope 'app', 'developer', 'user' or 'install'.
90
+ * @param number $pID Element's id.
91
+ * @param string $pPublic Public key.
92
+ * @param string|bool $pSecret Element's secret key.
93
+ * @param bool $pSandbox Whether or not to run API in sandbox mode.
94
+ */
95
+ public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
96
+ // If secret key not provided, use public key encryption.
97
+ if ( is_bool( $pSecret ) ) {
98
+ $pSecret = $pPublic;
99
+ }
100
+
101
+ parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
102
+ }
103
+
104
+ public static function GetUrl( $pCanonizedPath = '', $pIsSandbox = false ) {
105
+ $address = ( $pIsSandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS );
106
+
107
+ if ( ':' === $address[0] ) {
108
+ $address = self::$_protocol . $address;
109
+ }
110
+
111
+ return $address . $pCanonizedPath;
112
+ }
113
+
114
+ #----------------------------------------------------------------------------------
115
+ #region Servers Clock Diff
116
+ #----------------------------------------------------------------------------------
117
+
118
+ /**
119
+ * @var int Clock diff in seconds between current server to API server.
120
+ */
121
+ private static $_clock_diff = 0;
122
+
123
+ /**
124
+ * Set clock diff for all API calls.
125
+ *
126
+ * @since 1.0.3
127
+ *
128
+ * @param $pSeconds
129
+ */
130
+ public static function SetClockDiff( $pSeconds ) {
131
+ self::$_clock_diff = $pSeconds;
132
+ }
133
+
134
+ /**
135
+ * Find clock diff between current server to API server.
136
+ *
137
+ * @since 1.0.2
138
+ * @return int Clock diff in seconds.
139
+ */
140
+ public static function FindClockDiff() {
141
+ $time = time();
142
+ $pong = self::Ping();
143
+
144
+ return ( $time - strtotime( $pong->timestamp ) );
145
+ }
146
+
147
+ #endregion
148
+
149
+ /**
150
+ * @var string http or https
151
+ */
152
+ private static $_protocol = FS_API__PROTOCOL;
153
+
154
+ /**
155
+ * Set API connection protocol.
156
+ *
157
+ * @since 1.0.4
158
+ */
159
+ public static function SetHttp() {
160
+ self::$_protocol = 'http';
161
+ }
162
+
163
+ /**
164
+ * @since 1.0.4
165
+ *
166
+ * @return bool
167
+ */
168
+ public static function IsHttps() {
169
+ return ( 'https' === self::$_protocol );
170
+ }
171
+
172
+ /**
173
+ * Sign request with the following HTTP headers:
174
+ * Content-MD5: MD5(HTTP Request body)
175
+ * Date: Current date (i.e Sat, 14 Feb 2015 20:24:46 +0000)
176
+ * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
177
+ * {scope_entity_secret_key}))
178
+ *
179
+ * @param string $pResourceUrl
180
+ * @param array $pCurlOptions
181
+ *
182
+ * @return array
183
+ */
184
+ function SignRequest( $pResourceUrl, $pCurlOptions ) {
185
+ $eol = "\n";
186
+ $content_md5 = '';
187
+ $now = ( time() - self::$_clock_diff );
188
+ $date = date( 'r', $now );
189
+ $content_type = '';
190
+
191
+ if ( isset( $pCurlOptions[ CURLOPT_POST ] ) && 0 < $pCurlOptions[ CURLOPT_POST ] ) {
192
+ $content_md5 = md5( $pCurlOptions[ CURLOPT_POSTFIELDS ] );
193
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Content-MD5: ' . $content_md5;
194
+ $content_type = 'application/json';
195
+ }
196
+
197
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Date: ' . $date;
198
+
199
+ $string_to_sign = implode( $eol, array(
200
+ $pCurlOptions[ CURLOPT_CUSTOMREQUEST ],
201
+ $content_md5,
202
+ $content_type,
203
+ $date,
204
+ $pResourceUrl
205
+ ) );
206
+
207
+ // If secret and public keys are identical, it means that
208
+ // the signature uses public key hash encoding.
209
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
210
+
211
+ // Add authorization header.
212
+ $pCurlOptions[ CURLOPT_HTTPHEADER ][] = 'Authorization: ' .
213
+ $auth_type . ' ' .
214
+ $this->_id . ':' .
215
+ $this->_public . ':' .
216
+ self::Base64UrlEncode(
217
+ hash_hmac( 'sha256', $string_to_sign, $this->_secret )
218
+ );
219
+
220
+ return $pCurlOptions;
221
+ }
222
+
223
+ /**
224
+ * Get API request URL signed via query string.
225
+ *
226
+ * @param string $pPath
227
+ *
228
+ * @throws Freemius_Exception
229
+ *
230
+ * @return string
231
+ */
232
+ function GetSignedUrl( $pPath ) {
233
+ $resource = explode( '?', $this->CanonizePath( $pPath ) );
234
+ $pResourceUrl = $resource[0];
235
+
236
+ $eol = "\n";
237
+ $content_md5 = '';
238
+ $content_type = '';
239
+ $now = ( time() - self::$_clock_diff );
240
+ $date = date( 'r', $now );
241
+
242
+ $string_to_sign = implode( $eol, array(
243
+ 'GET',
244
+ $content_md5,
245
+ $content_type,
246
+ $date,
247
+ $pResourceUrl
248
+ ) );
249
+
250
+ // If secret and public keys are identical, it means that
251
+ // the signature uses public key hash encoding.
252
+ $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
253
+
254
+ return Freemius_Api::GetUrl(
255
+ $pResourceUrl . '?' .
256
+ ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) .
257
+ http_build_query( array(
258
+ 'auth_date' => $date,
259
+ 'authorization' => $auth_type . ' ' . $this->_id . ':' .
260
+ $this->_public . ':' .
261
+ self::Base64UrlEncode( hash_hmac(
262
+ 'sha256', $string_to_sign, $this->_secret
263
+ ) )
264
+ ) ), $this->_isSandbox );
265
+ }
266
+
267
+ /**
268
+ * @param resource $pCurlHandler
269
+ * @param array $pCurlOptions
270
+ *
271
+ * @return mixed
272
+ */
273
+ private static function ExecuteRequest( &$pCurlHandler, &$pCurlOptions ) {
274
+ $start = microtime( true );
275
+
276
+ $result = curl_exec( $pCurlHandler );
277
+
278
+ if ( FS_API__LOGGER_ON ) {
279
+ $end = microtime( true );
280
+
281
+ $has_body = ( isset( $pCurlOptions[ CURLOPT_POST ] ) && 0 < $pCurlOptions[ CURLOPT_POST ] );
282
+
283
+ self::$_logger[] = array(
284
+ 'id' => count( self::$_logger ),
285
+ 'start' => $start,
286
+ 'end' => $end,
287
+ 'total' => ( $end - $start ),
288
+ 'method' => $pCurlOptions[ CURLOPT_CUSTOMREQUEST ],
289
+ 'path' => $pCurlOptions[ CURLOPT_URL ],
290
+ 'body' => $has_body ? $pCurlOptions[ CURLOPT_POSTFIELDS ] : null,
291
+ 'result' => $result,
292
+ 'code' => curl_getinfo( $pCurlHandler, CURLINFO_HTTP_CODE ),
293
+ 'backtrace' => debug_backtrace(),
294
+ );
295
+ }
296
+
297
+ return $result;
298
+ }
299
+
300
+ /**
301
+ * @return array
302
+ */
303
+ static function GetLogger() {
304
+ return self::$_logger;
305
+ }
306
+
307
+ /**
308
+ * @param string $pCanonizedPath
309
+ * @param string $pMethod
310
+ * @param array $pParams
311
+ * @param null|resource $pCurlHandler
312
+ * @param bool $pIsSandbox
313
+ * @param null|callable $pBeforeExecutionFunction
314
+ *
315
+ * @return object[]|object|null
316
+ *
317
+ * @throws \Freemius_Exception
318
+ */
319
+ private static function MakeStaticRequest(
320
+ $pCanonizedPath,
321
+ $pMethod = 'GET',
322
+ $pParams = array(),
323
+ $pCurlHandler = null,
324
+ $pIsSandbox = false,
325
+ $pBeforeExecutionFunction = null
326
+ ) {
327
+ if ( ! FS_SDK__HAS_CURL ) {
328
+ self::ThrowNoCurlException();
329
+ }
330
+
331
+ // Connectivity errors simulation.
332
+ if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
333
+ self::ThrowCloudFlareDDoSException();
334
+ } else if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
335
+ self::ThrowSquidAclException();
336
+ }
337
+
338
+ if ( ! $pCurlHandler ) {
339
+ $pCurlHandler = curl_init();
340
+ }
341
+
342
+ $opts = array(
343
+ CURLOPT_CONNECTTIMEOUT => 10,
344
+ CURLOPT_RETURNTRANSFER => true,
345
+ CURLOPT_TIMEOUT => 60,
346
+ CURLOPT_USERAGENT => FS_SDK__USER_AGENT,
347
+ CURLOPT_HTTPHEADER => array(),
348
+ );
349
+
350
+ if ( 'POST' === $pMethod || 'PUT' === $pMethod ) {
351
+ if ( is_array( $pParams ) && 0 < count( $pParams ) ) {
352
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Content-Type: application/json';
353
+ $opts[ CURLOPT_POST ] = count( $pParams );
354
+ $opts[ CURLOPT_POSTFIELDS ] = json_encode( $pParams );
355
+ }
356
+
357
+ $opts[ CURLOPT_RETURNTRANSFER ] = true;
358
+ }
359
+
360
+ $request_url = self::GetUrl( $pCanonizedPath, $pIsSandbox );
361
+
362
+ $opts[ CURLOPT_URL ] = $request_url;
363
+ $opts[ CURLOPT_CUSTOMREQUEST ] = $pMethod;
364
+
365
+ $resource = explode( '?', $pCanonizedPath );
366
+
367
+ // Disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
368
+ // for 2 seconds if the server does not support this header.
369
+ $opts[ CURLOPT_HTTPHEADER ][] = 'Expect:';
370
+
371
+ if ( 'https' === substr( strtolower( $request_url ), 0, 5 ) ) {
372
+ $opts[ CURLOPT_SSL_VERIFYHOST ] = false;
373
+ $opts[ CURLOPT_SSL_VERIFYPEER ] = false;
374
+ }
375
+
376
+ if ( false !== $pBeforeExecutionFunction &&
377
+ is_callable( $pBeforeExecutionFunction )
378
+ ) {
379
+ $opts = call_user_func( $pBeforeExecutionFunction, $resource[0], $opts );
380
+ }
381
+
382
+ curl_setopt_array( $pCurlHandler, $opts );
383
+ $result = self::ExecuteRequest( $pCurlHandler, $opts );
384
+
385
+ /*if (curl_errno($ch) == 60) // CURLE_SSL_CACERT
386
+ {
387
+ self::errorLog('Invalid or no certificate authority found, using bundled information');
388
+ curl_setopt($ch, CURLOPT_CAINFO,
389
+ dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
390
+ $result = curl_exec($ch);
391
+ }*/
392
+
393
+ // With dual stacked DNS responses, it's possible for a server to
394
+ // have IPv6 enabled but not have IPv6 connectivity. If this is
395
+ // the case, curl will try IPv4 first and if that fails, then it will
396
+ // fall back to IPv6 and the error EHOSTUNREACH is returned by the
397
+ // operating system.
398
+ if ( false === $result && empty( $opts[ CURLOPT_IPRESOLVE ] ) ) {
399
+ $matches = array();
400
+ $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
401
+ if ( preg_match( $regex, curl_error( $pCurlHandler ), $matches ) ) {
402
+ if ( strlen( @inet_pton( $matches[1] ) ) === 16 ) {
403
+ // self::errorLog('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
404
+ $opts[ CURLOPT_IPRESOLVE ] = CURL_IPRESOLVE_V4;
405
+ curl_setopt( $pCurlHandler, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
406
+ $result = self::ExecuteRequest( $pCurlHandler, $opts );
407
+ }
408
+ }
409
+ }
410
+
411
+ if ( $result === false ) {
412
+ self::ThrowCurlException( $pCurlHandler );
413
+ }
414
+
415
+ curl_close( $pCurlHandler );
416
+
417
+ if ( empty( $result ) ) {
418
+ return null;
419
+ }
420
+
421
+ $decoded = json_decode( $result );
422
+
423
+ if ( is_null( $decoded ) ) {
424
+ if ( preg_match( '/Please turn JavaScript on/i', $result ) &&
425
+ preg_match( '/text\/javascript/', $result )
426
+ ) {
427
+ self::ThrowCloudFlareDDoSException( $result );
428
+ } 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 ) &&
429
+ preg_match( '/squid/', $result )
430
+ ) {
431
+ self::ThrowSquidAclException( $result );
432
+ } else {
433
+ $decoded = (object) array(
434
+ 'error' => (object) array(
435
+ 'type' => 'Unknown',
436
+ 'message' => $result,
437
+ 'code' => 'unknown',
438
+ 'http' => 402
439
+ )
440
+ );
441
+ }
442
+ }
443
+
444
+ return $decoded;
445
+ }
446
+
447
+
448
+ /**
449
+ * Makes an HTTP request. This method can be overridden by subclasses if
450
+ * developers want to do fancier things or use something other than curl to
451
+ * make the request.
452
+ *
453
+ * @param string $pCanonizedPath The URL to make the request to
454
+ * @param string $pMethod HTTP method
455
+ * @param array $pParams The parameters to use for the POST body
456
+ * @param null|resource $pCurlHandler Initialized curl handle
457
+ *
458
+ * @return object[]|object|null
459
+ *
460
+ * @throws Freemius_Exception
461
+ */
462
+ public function MakeRequest(
463
+ $pCanonizedPath,
464
+ $pMethod = 'GET',
465
+ $pParams = array(),
466
+ $pCurlHandler = null
467
+ ) {
468
+ $resource = explode( '?', $pCanonizedPath );
469
+
470
+ // Only sign request if not ping.json connectivity test.
471
+ $sign_request = ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) );
472
+
473
+ return self::MakeStaticRequest(
474
+ $pCanonizedPath,
475
+ $pMethod,
476
+ $pParams,
477
+ $pCurlHandler,
478
+ $this->_isSandbox,
479
+ $sign_request ? array( &$this, 'SignRequest' ) : null
480
+ );
481
+ }
482
+
483
+ #----------------------------------------------------------------------------------
484
+ #region Connectivity Test
485
+ #----------------------------------------------------------------------------------
486
+ /**
487
+ * If successful connectivity to the API endpoint using ping.json endpoint.
488
+ *
489
+ * - OR -
490
+ *
491
+ * Validate if ping result object is valid.
492
+ *
493
+ * @param mixed $pPong
494
+ *
495
+ * @return bool
496
+ */
497
+ public static function Test( $pPong = null ) {
498
+ $pong = is_null( $pPong ) ?
499
+ self::Ping() :
500
+ $pPong;
501
+
502
+ return (
503
+ is_object( $pong ) &&
504
+ isset( $pong->api ) &&
505
+ 'pong' === $pong->api
506
+ );
507
+ }
508
+
509
+ /**
510
+ * Ping API to test connectivity.
511
+ *
512
+ * @return object
513
+ */
514
+ public static function Ping() {
515
+ try {
516
+ $result = self::MakeStaticRequest( '/v' . FS_API__VERSION . '/ping.json' );
517
+ } catch ( Freemius_Exception $e ) {
518
+ // Map to error object.
519
+ $result = (object) $e->getResult();
520
+ } catch ( Exception $e ) {
521
+ // Map to error object.
522
+ $result = (object) array(
523
+ 'error' => array(
524
+ 'type' => 'Unknown',
525
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
526
+ 'code' => 'unknown',
527
+ 'http' => 402
528
+ )
529
+ );
530
+ }
531
+
532
+ return $result;
533
+ }
534
+
535
+ #endregion
536
+
537
+ #----------------------------------------------------------------------------------
538
+ #region Connectivity Exceptions
539
+ #----------------------------------------------------------------------------------
540
+
541
+ /**
542
+ * @param resource $pCurlHandler
543
+ *
544
+ * @throws Freemius_Exception
545
+ */
546
+ private static function ThrowCurlException( $pCurlHandler ) {
547
+ $e = new Freemius_Exception( array(
548
+ 'error' => array(
549
+ 'code' => curl_errno( $pCurlHandler ),
550
+ 'message' => curl_error( $pCurlHandler ),
551
+ 'type' => 'CurlException',
552
+ ),
553
+ ) );
554
+
555
+ curl_close( $pCurlHandler );
556
+ throw $e;
557
+ }
558
+
559
+ /**
560
+ * @param string $pResult
561
+ *
562
+ * @throws Freemius_Exception
563
+ */
564
+ private static function ThrowNoCurlException( $pResult = '' ) {
565
+ $curl_required_methods = array(
566
+ 'curl_version',
567
+ 'curl_exec',
568
+ 'curl_init',
569
+ 'curl_close',
570
+ 'curl_setopt',
571
+ 'curl_setopt_array',
572
+ 'curl_error',
573
+ );
574
+
575
+ // Find all missing methods.
576
+ $missing_methods = array();
577
+ foreach ( $curl_required_methods as $m ) {
578
+ if ( ! function_exists( $m ) ) {
579
+ $missing_methods[] = $m;
580
+ }
581
+ }
582
+
583
+ throw new Freemius_Exception( array(
584
+ 'error' => (object) array(
585
+ 'type' => 'cUrlMissing',
586
+ 'message' => $pResult,
587
+ 'code' => 'curl_missing',
588
+ 'http' => 402
589
+ ),
590
+ 'missing_methods' => $missing_methods,
591
+ ) );
592
+ }
593
+
594
+ /**
595
+ * @param string $pResult
596
+ *
597
+ * @throws Freemius_Exception
598
+ */
599
+ private static function ThrowCloudFlareDDoSException( $pResult = '' ) {
600
+ throw new Freemius_Exception( array(
601
+ 'error' => (object) array(
602
+ 'type' => 'CloudFlareDDoSProtection',
603
+ 'message' => $pResult,
604
+ 'code' => 'cloudflare_ddos_protection',
605
+ 'http' => 402
606
+ )
607
+ ) );
608
+ }
609
+
610
+ /**
611
+ * @param string $pResult
612
+ *
613
+ * @throws Freemius_Exception
614
+ */
615
+ private static function ThrowSquidAclException( $pResult = '' ) {
616
+ throw new Freemius_Exception( array(
617
+ 'error' => (object) array(
618
+ 'type' => 'SquidCacheBlock',
619
+ 'message' => $pResult,
620
+ 'code' => 'squid_cache_block',
621
+ 'http' => 402
622
+ )
623
+ ) );
624
+ }
625
+
626
+ #endregion
627
+ }
freemius/includes/sdk/FreemiusBase.php ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if ( ! defined( 'FS_API__VERSION' ) ) {
19
+ define( 'FS_API__VERSION', '1' );
20
+ }
21
+ if ( ! defined( 'FS_SDK__PATH' ) ) {
22
+ define( 'FS_SDK__PATH', dirname( __FILE__ ) );
23
+ }
24
+ if ( ! defined( 'FS_SDK__EXCEPTIONS_PATH' ) ) {
25
+ define( 'FS_SDK__EXCEPTIONS_PATH', FS_SDK__PATH . '/Exceptions/' );
26
+ }
27
+
28
+ if ( ! function_exists( 'json_decode' ) ) {
29
+ throw new Exception( 'Freemius needs the JSON PHP extension.' );
30
+ }
31
+
32
+ // Include all exception files.
33
+ $exceptions = array(
34
+ 'Exception',
35
+ 'InvalidArgumentException',
36
+ 'ArgumentNotExistException',
37
+ 'EmptyArgumentException',
38
+ 'OAuthException'
39
+ );
40
+
41
+ foreach ( $exceptions as $e ) {
42
+ require_once FS_SDK__EXCEPTIONS_PATH . $e . '.php';
43
+ }
44
+
45
+ if ( class_exists( 'Freemius_Api_Base' ) ) {
46
+ return;
47
+ }
48
+
49
+ abstract class Freemius_Api_Base {
50
+ const VERSION = '1.0.4';
51
+ const FORMAT = 'json';
52
+
53
+ protected $_id;
54
+ protected $_public;
55
+ protected $_secret;
56
+ protected $_scope;
57
+ protected $_isSandbox;
58
+
59
+ /**
60
+ * @param string $pScope 'app', 'developer', 'plugin', 'user' or 'install'.
61
+ * @param number $pID Element's id.
62
+ * @param string $pPublic Public key.
63
+ * @param string $pSecret Element's secret key.
64
+ * @param bool $pIsSandbox Whether or not to run API in sandbox mode.
65
+ */
66
+ public function Init( $pScope, $pID, $pPublic, $pSecret, $pIsSandbox = false ) {
67
+ $this->_id = $pID;
68
+ $this->_public = $pPublic;
69
+ $this->_secret = $pSecret;
70
+ $this->_scope = $pScope;
71
+ $this->_isSandbox = $pIsSandbox;
72
+ }
73
+
74
+ public function IsSandbox() {
75
+ return $this->_isSandbox;
76
+ }
77
+
78
+ function CanonizePath( $pPath ) {
79
+ $pPath = trim( $pPath, '/' );
80
+ $query_pos = strpos( $pPath, '?' );
81
+ $query = '';
82
+
83
+ if ( false !== $query_pos ) {
84
+ $query = substr( $pPath, $query_pos );
85
+ $pPath = substr( $pPath, 0, $query_pos );
86
+ }
87
+
88
+ // Trim '.json' suffix.
89
+ $format_length = strlen( '.' . self::FORMAT );
90
+ $start = $format_length * ( - 1 ); //negative
91
+ if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
92
+ $pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
93
+ }
94
+
95
+ switch ( $this->_scope ) {
96
+ case 'app':
97
+ $base = '/apps/' . $this->_id;
98
+ break;
99
+ case 'developer':
100
+ $base = '/developers/' . $this->_id;
101
+ break;
102
+ case 'user':
103
+ $base = '/users/' . $this->_id;
104
+ break;
105
+ case 'plugin':
106
+ $base = '/plugins/' . $this->_id;
107
+ break;
108
+ case 'install':
109
+ $base = '/installs/' . $this->_id;
110
+ break;
111
+ default:
112
+ throw new Freemius_Exception( 'Scope not implemented.' );
113
+ }
114
+
115
+ return '/v' . FS_API__VERSION . $base .
116
+ ( ! empty( $pPath ) ? '/' : '' ) . $pPath .
117
+ ( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
118
+ }
119
+
120
+ abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array() );
121
+
122
+ /**
123
+ * @param string $pPath
124
+ * @param string $pMethod
125
+ * @param array $pParams
126
+ *
127
+ * @return object[]|object|null
128
+ */
129
+ private function _Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
130
+ $pMethod = strtoupper( $pMethod );
131
+
132
+ try {
133
+ $result = $this->MakeRequest( $pPath, $pMethod, $pParams );
134
+ } catch ( Freemius_Exception $e ) {
135
+ // Map to error object.
136
+ $result = (object) $e->getResult();
137
+ } catch ( Exception $e ) {
138
+ // Map to error object.
139
+ $result = (object) array(
140
+ 'error' => array(
141
+ 'type' => 'Unknown',
142
+ 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
143
+ 'code' => 'unknown',
144
+ 'http' => 402
145
+ )
146
+ );
147
+ }
148
+
149
+ return $result;
150
+ }
151
+
152
+ public function Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
153
+ return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams );
154
+ }
155
+
156
+ /**
157
+ * Base64 encoding that does not need to be urlencode()ed.
158
+ * Exactly the same as base64_encode except it uses
159
+ * - instead of +
160
+ * _ instead of /
161
+ * No padded =
162
+ *
163
+ * @param string $input base64UrlEncoded string
164
+ *
165
+ * @return string
166
+ */
167
+ protected static function Base64UrlDecode( $input ) {
168
+ return base64_decode( strtr( $input, '-_', '+/' ) );
169
+ }
170
+
171
+ /**
172
+ * Base64 encoding that does not need to be urlencode()ed.
173
+ * Exactly the same as base64_encode except it uses
174
+ * - instead of +
175
+ * _ instead of /
176
+ *
177
+ * @param string $input string
178
+ *
179
+ * @return string base64Url encoded string
180
+ */
181
+ protected static function Base64UrlEncode( $input ) {
182
+ $str = strtr( base64_encode( $input ), '+/', '-_' );
183
+ $str = str_replace( '=', '', $str );
184
+
185
+ return $str;
186
+ }
187
+
188
+ }
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/sdk/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/includes/supplements/fs-essential-functions-1.1.7.1.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ if ( '.' !== dirname( trailingslashit( $relative_path ) ) ) {
41
+ return $relative_path;
42
+ }
43
+ }
44
+ }
45
+
46
+ return null;
47
+ }
freemius/includes/supplements/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/index.php ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php
2
+ // Silence is golden.
3
+ // Hide file structure from users on unprotected servers.
freemius/languages/freemius-da_DK.mo ADDED
Binary file
freemius/languages/freemius-da_DK.po ADDED
@@ -0,0 +1,1790 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2017 freemius
2
+ # This file is distributed under the same license as the freemius package.
3
+ # Translators:
4
+ # Joachim Jensen <jv@intox.dk>, 2016-2017
5
+ msgid ""
6
+ msgstr ""
7
+ "Project-Id-Version: WordPress SDK\n"
8
+ "Report-Msgid-Bugs-To: https://github.com/Freemius/wordpress-sdk/issues\n"
9
+ "POT-Creation-Date: \n"
10
+ "PO-Revision-Date: 2017-05-12 17:32+0000\n"
11
+ "Last-Translator: Vova Feldman <vova@freemius.com>\n"
12
+ "Language: da_DK\n"
13
+ "Language-Team: Danish (Denmark) (http://www.transifex.com/freemius/wordpress-sdk/language/da_DK/)\n"
14
+ "Content-Type: text/plain; charset=UTF-8\n"
15
+ "Content-Transfer-Encoding: 8bit\n"
16
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
17
+ "MIME-Version: 1.0\n"
18
+ "X-Poedit-Basepath: ..\n"
19
+ "X-Poedit-KeywordsList: _fs_text;_fs_echo;_fs_esc_attr;_fs_esc_attr_echo;_fs_esc_html;_fs_esc_html_echo;_fs_x:1,2c;_fs_ex:1,2c;_fs_esc_attr_x:1,2c;_fs_esc_html_x:1,2c;_fs_n:1,2;_fs_n_noop:1,2;_fs_nx:1,2,4c;_fs_nx_noop:1,2,3c\n"
20
+ "X-Poedit-SearchPath-0: .\n"
21
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
22
+ "X-Poedit-SourceCharset: UTF-8\n"
23
+
24
+ #: includes/i18n.php:37
25
+ msgid "Account"
26
+ msgstr "Konto"
27
+
28
+ #: includes/i18n.php:38
29
+ msgid "Add On"
30
+ msgstr "Tilføjelse"
31
+
32
+ #: includes/i18n.php:39
33
+ msgid "Contact Us"
34
+ msgstr "Kontakt os"
35
+
36
+ #: includes/i18n.php:40
37
+ msgid "Contact Support"
38
+ msgstr "Kontakt support"
39
+
40
+ #: includes/i18n.php:41
41
+ msgid "Change Ownership"
42
+ msgstr "Skift ejerskab"
43
+
44
+ #: includes/i18n.php:42
45
+ msgid "Support"
46
+ msgstr "Support"
47
+
48
+ #: includes/i18n.php:43
49
+ msgid "Support Forum"
50
+ msgstr "Supportforum"
51
+
52
+ #: includes/i18n.php:44
53
+ msgid "Add Ons"
54
+ msgstr "Tilføjelser"
55
+
56
+ #: includes/i18n.php:45
57
+ msgctxt "verb"
58
+ msgid "Upgrade"
59
+ msgstr "Opgrader"
60
+
61
+ #: includes/i18n.php:46
62
+ msgid "Awesome"
63
+ msgstr "Sejt"
64
+
65
+ #: includes/i18n.php:47
66
+ msgctxt "noun"
67
+ msgid "Pricing"
68
+ msgstr "Priser"
69
+
70
+ #: includes/i18n.php:48
71
+ msgctxt "noun"
72
+ msgid "Price"
73
+ msgstr "Pris"
74
+
75
+ #: includes/i18n.php:49
76
+ msgid "Unlimited Updates"
77
+ msgstr "Ubegrænsede opdateringer"
78
+
79
+ #: includes/i18n.php:50
80
+ msgctxt "verb"
81
+ msgid "Downgrade"
82
+ msgstr "Nedgrader"
83
+
84
+ #: includes/i18n.php:51
85
+ msgctxt "verb"
86
+ msgid "Cancel Subscription"
87
+ msgstr "Cancel Subscription"
88
+
89
+ #: includes/i18n.php:52
90
+ msgid "Cancel Trial"
91
+ msgstr "Annuller prøveperiode"
92
+
93
+ #: includes/i18n.php:53
94
+ msgid "Free Trial"
95
+ msgstr "Gratis prøveperiode"
96
+
97
+ #: includes/i18n.php:54
98
+ msgid "Start my free %s"
99
+ msgstr "Start min gratis %s"
100
+
101
+ #: includes/i18n.php:55
102
+ msgid "No commitment for %s - cancel anytime"
103
+ msgstr "Ingen bindinger ved %s - annuller når som helst"
104
+
105
+ #: includes/i18n.php:56
106
+ msgid "After your free %s, pay as little as %s"
107
+ msgstr "Efter din gratis %s er prisen kun %s"
108
+
109
+ #: includes/i18n.php:57
110
+ msgid "Details"
111
+ msgstr "Detaljer"
112
+
113
+ #: includes/i18n.php:58
114
+ msgid "Account Details"
115
+ msgstr "Kontodetaljer"
116
+
117
+ #: includes/i18n.php:59
118
+ msgctxt "verb"
119
+ msgid "Delete"
120
+ msgstr "Slet"
121
+
122
+ #: includes/i18n.php:60
123
+ msgctxt "verb"
124
+ msgid "Show"
125
+ msgstr "Vis"
126
+
127
+ #: includes/i18n.php:61
128
+ msgctxt "verb"
129
+ msgid "Hide"
130
+ msgstr "Skjul"
131
+
132
+ #: includes/i18n.php:62
133
+ msgctxt "verb"
134
+ msgid "Edit"
135
+ msgstr "Rediger"
136
+
137
+ #: includes/i18n.php:63
138
+ msgctxt "verb"
139
+ msgid "Update"
140
+ msgstr "Opdater"
141
+
142
+ #: includes/i18n.php:64
143
+ msgid "Date"
144
+ msgstr "Dato"
145
+
146
+ #: includes/i18n.php:65
147
+ msgid "Amount"
148
+ msgstr "Beløb"
149
+
150
+ #: includes/i18n.php:66
151
+ msgid "Invoice"
152
+ msgstr "Faktura"
153
+
154
+ #: includes/i18n.php:67
155
+ msgid "Billing"
156
+ msgstr "Betaling"
157
+
158
+ #: includes/i18n.php:68
159
+ msgid "Payments"
160
+ msgstr "Betalinger"
161
+
162
+ #: includes/i18n.php:69
163
+ msgid "Delete Account"
164
+ msgstr "Slet konto"
165
+
166
+ #: includes/i18n.php:70
167
+ msgctxt "as close a window"
168
+ msgid "Dismiss"
169
+ msgstr "Fjern"
170
+
171
+ #: includes/i18n.php:71
172
+ msgctxt "as product pricing plan"
173
+ msgid "Plan"
174
+ msgstr "Plan"
175
+
176
+ #: includes/i18n.php:72
177
+ msgid "Change Plan"
178
+ msgstr "Skift plan"
179
+
180
+ #: includes/i18n.php:73
181
+ msgctxt "as download professional version"
182
+ msgid "Download %s Version"
183
+ msgstr "Download %s Version"
184
+
185
+ #: includes/i18n.php:74
186
+ msgctxt "as download professional version now"
187
+ msgid "Download %s version now"
188
+ msgstr "Download %s version now"
189
+
190
+ #: includes/i18n.php:75
191
+ msgctxt "as download latest version"
192
+ msgid "Download Latest"
193
+ msgstr "Download seneste"
194
+
195
+ #: includes/i18n.php:76
196
+ msgctxt "E.g. you have a professional license."
197
+ msgid "You have a %s license."
198
+ msgstr "Du har en %s licens."
199
+
200
+ #: includes/i18n.php:77
201
+ msgid "New"
202
+ msgstr "Ny"
203
+
204
+ #: includes/i18n.php:78
205
+ msgid "Free"
206
+ msgstr "Gratis"
207
+
208
+ #: includes/i18n.php:79
209
+ msgctxt "as trial plan"
210
+ msgid "Trial"
211
+ msgstr "Prøveperiode"
212
+
213
+ #: includes/i18n.php:80
214
+ msgctxt "as starting a trial plan"
215
+ msgid "Start Trial"
216
+ msgstr "Start prøveperiode"
217
+
218
+ #: includes/i18n.php:81
219
+ msgctxt "verb"
220
+ msgid "Purchase"
221
+ msgstr "Køb"
222
+
223
+ #: includes/i18n.php:82
224
+ msgid "Purchase License"
225
+ msgstr "Køb licens"
226
+
227
+ #: includes/i18n.php:83
228
+ msgctxt "verb"
229
+ msgid "Buy"
230
+ msgstr "Køb"
231
+
232
+ #: includes/i18n.php:84
233
+ msgid "Buy License"
234
+ msgstr "Køb licens"
235
+
236
+ #: includes/i18n.php:85
237
+ msgid "Single Site License"
238
+ msgstr "Single Site License"
239
+
240
+ #: includes/i18n.php:86
241
+ msgid "Unlimited Licenses"
242
+ msgstr "Ubegrænsede licenser"
243
+
244
+ #: includes/i18n.php:87
245
+ msgid "Up to %s Sites"
246
+ msgstr "Op til %s websteder"
247
+
248
+ #: includes/i18n.php:88
249
+ msgid "%sRenew your license now%s to access version %s features and support."
250
+ msgstr "%sRenew your license now%s to access version %s features and support."
251
+
252
+ #: includes/i18n.php:89
253
+ msgid "Enter the email address you've used for the upgrade below and we will resend you the license key."
254
+ msgstr "Enter the email address you've used for the upgrade below and we will resend you the license key."
255
+
256
+ #: includes/i18n.php:90
257
+ msgctxt "e.g. Professional Plan"
258
+ msgid "%s Plan"
259
+ msgstr "%s Plan"
260
+
261
+ #: includes/i18n.php:91
262
+ msgid "You are just one step away - %s"
263
+ msgstr "Du mangler kun ét skridt - %s"
264
+
265
+ #: includes/i18n.php:92
266
+ msgctxt "%s - plugin name. As complete \"Jetpack\" activation now"
267
+ msgid "Complete \"%s\" Activation Now"
268
+ msgstr "Færdiggør aktivering af \"%s\" nu"
269
+
270
+ #: includes/i18n.php:94
271
+ msgid "We made a few tweaks to the plugin, %s"
272
+ msgstr "Vi har lavet nogle få rettelser til pluginnet, %s"
273
+
274
+ #: includes/i18n.php:95
275
+ msgid "Opt-in to make \"%s\" Better!"
276
+ msgstr "Tilmeld for at gøre \"%s\" bedre!"
277
+
278
+ #: includes/i18n.php:96
279
+ msgid "Error"
280
+ msgstr "Fejl"
281
+
282
+ #: includes/i18n.php:97
283
+ msgid "Freemius SDK couldn't find the plugin's main file. Please contact sdk@freemius.com with the current error."
284
+ msgstr "Freemius SDK couldn't find the plugin's main file. Please contact sdk@freemius.com with the current error."
285
+
286
+ #: includes/i18n.php:100
287
+ msgctxt "as expiration date"
288
+ msgid "Expiration"
289
+ msgstr "Expiration"
290
+
291
+ #: includes/i18n.php:101
292
+ msgctxt "as software license"
293
+ msgid "License"
294
+ msgstr "Licens"
295
+
296
+ #: includes/i18n.php:102
297
+ msgid "not verified"
298
+ msgstr "ikke verificeret"
299
+
300
+ #: includes/i18n.php:103
301
+ msgid "Verify Email"
302
+ msgstr "Verificer e-mail"
303
+
304
+ #: includes/i18n.php:104
305
+ msgctxt "e.g. expires in 2 months"
306
+ msgid "Expires in %s"
307
+ msgstr "Udløber om %s"
308
+
309
+ #: includes/i18n.php:105
310
+ msgctxt "e.g. auto renews in 2 months"
311
+ msgid "Auto renews in %s"
312
+ msgstr "Auto-fornyer om %s"
313
+
314
+ #: includes/i18n.php:106
315
+ msgid "No expiration"
316
+ msgstr "Udløber ikke"
317
+
318
+ #: includes/i18n.php:107
319
+ msgid "Expired"
320
+ msgstr "Udløbet"
321
+
322
+ #: includes/i18n.php:108
323
+ msgid "Cancelled"
324
+ msgstr "Annulleret"
325
+
326
+ #: includes/i18n.php:109
327
+ msgctxt "e.g. In 2 hours"
328
+ msgid "In %s"
329
+ msgstr "Om %s"
330
+
331
+ #: includes/i18n.php:110
332
+ msgctxt "e.g. 2 min ago"
333
+ msgid "%s ago"
334
+ msgstr "%s siden"
335
+
336
+ #: includes/i18n.php:112
337
+ msgid "%s or higher"
338
+ msgstr "%s eller højere"
339
+
340
+ #: includes/i18n.php:113
341
+ msgctxt "as plugin version"
342
+ msgid "Version"
343
+ msgstr "Version"
344
+
345
+ #: includes/i18n.php:114
346
+ msgid "Name"
347
+ msgstr "Navn"
348
+
349
+ #: includes/i18n.php:115
350
+ msgid "Email"
351
+ msgstr "E-mail"
352
+
353
+ #: includes/i18n.php:116
354
+ msgid "Email address"
355
+ msgstr "E-mailadresse"
356
+
357
+ #: includes/i18n.php:117
358
+ msgid "Verified"
359
+ msgstr "Verificeret"
360
+
361
+ #: includes/i18n.php:118
362
+ msgid "Module"
363
+ msgstr "Modul"
364
+
365
+ #: includes/i18n.php:119
366
+ msgid "Module Type"
367
+ msgstr "Modultype"
368
+
369
+ #: includes/i18n.php:120
370
+ msgid "Plugin"
371
+ msgstr "Plugin"
372
+
373
+ #: includes/i18n.php:121
374
+ msgid "Plugins"
375
+ msgstr "Plugins"
376
+
377
+ #: includes/i18n.php:122
378
+ msgid "Theme"
379
+ msgstr "Tema"
380
+
381
+ #: includes/i18n.php:123
382
+ msgid "Themes"
383
+ msgstr "Temaer"
384
+
385
+ #: includes/i18n.php:124
386
+ msgctxt "as file/folder path"
387
+ msgid "Path"
388
+ msgstr "Sti"
389
+
390
+ #: includes/i18n.php:125
391
+ msgid "Title"
392
+ msgstr "Titel"
393
+
394
+ #: includes/i18n.php:126
395
+ msgid "Free version"
396
+ msgstr "Gratis version"
397
+
398
+ #: includes/i18n.php:127
399
+ msgid "Premium version"
400
+ msgstr "Premium version"
401
+
402
+ #: includes/i18n.php:128
403
+ msgctxt "as WP plugin slug"
404
+ msgid "Slug"
405
+ msgstr "Kortnavn"
406
+
407
+ #: includes/i18n.php:129
408
+ msgid "ID"
409
+ msgstr "ID"
410
+
411
+ #: includes/i18n.php:130
412
+ msgid "Users"
413
+ msgstr "Brugere"
414
+
415
+ #: includes/i18n.php:131
416
+ msgid "Plugin Installs"
417
+ msgstr "Plugin-installationer"
418
+
419
+ #: includes/i18n.php:132
420
+ msgid "%s Installs"
421
+ msgstr "%s installeringer"
422
+
423
+ #: includes/i18n.php:133
424
+ msgctxt "like websites"
425
+ msgid "Sites"
426
+ msgstr "Websteder"
427
+
428
+ #: includes/i18n.php:134
429
+ msgid "User ID"
430
+ msgstr "Bruger-ID"
431
+
432
+ #: includes/i18n.php:135
433
+ msgid "Site ID"
434
+ msgstr "Websteds-ID"
435
+
436
+ #: includes/i18n.php:136
437
+ msgid "Public Key"
438
+ msgstr "Offentlig nøgle"
439
+
440
+ #: includes/i18n.php:137
441
+ msgid "Secret Key"
442
+ msgstr "Privat nøgle"
443
+
444
+ #: includes/i18n.php:138
445
+ msgctxt "as secret encryption key missing"
446
+ msgid "No Secret"
447
+ msgstr "Ingen privat nøgle"
448
+
449
+ #: includes/i18n.php:139
450
+ msgid "No ID"
451
+ msgstr "Intet ID"
452
+
453
+ #: includes/i18n.php:140
454
+ msgctxt "as synchronize license"
455
+ msgid "Sync License"
456
+ msgstr "Synkroniser licens"
457
+
458
+ #: includes/i18n.php:141
459
+ msgctxt "as synchronize"
460
+ msgid "Sync"
461
+ msgstr "Synkroniser"
462
+
463
+ #: includes/i18n.php:142
464
+ msgid "Activate License"
465
+ msgstr "Aktiver licens"
466
+
467
+ #: includes/i18n.php:143
468
+ msgid "Activate Free Version"
469
+ msgstr "Aktiver gratis version"
470
+
471
+ #: includes/i18n.php:144
472
+ msgid "Please enter the license key that you received in the email right after the purchase:"
473
+ msgstr "Please enter the license key that you received in the email right after the purchase:"
474
+
475
+ #: includes/i18n.php:145
476
+ msgid "Activating license..."
477
+ msgstr "Aktiverer licens..."
478
+
479
+ #: includes/i18n.php:146
480
+ msgid "Change License"
481
+ msgstr "Skift licens"
482
+
483
+ #: includes/i18n.php:147
484
+ msgid "Update License"
485
+ msgstr "Opdater licens"
486
+
487
+ #: includes/i18n.php:148
488
+ msgid "Deactivate License"
489
+ msgstr "Deaktiver licens"
490
+
491
+ #: includes/i18n.php:149
492
+ msgid "Activate"
493
+ msgstr "Aktiver"
494
+
495
+ #: includes/i18n.php:150
496
+ msgid "Deactivate"
497
+ msgstr "Deaktiver"
498
+
499
+ #: includes/i18n.php:151
500
+ msgid "Skip & Deactivate"
501
+ msgstr "Spring over & deaktiver"
502
+
503
+ #: includes/i18n.php:152
504
+ msgid "Skip & %s"
505
+ msgstr "Spring over & %s"
506
+
507
+ #: includes/i18n.php:153
508
+ msgid "No - just deactivate"
509
+ msgstr "Nej - bare deaktiver"
510
+
511
+ #: includes/i18n.php:154
512
+ msgid "Yes - do your thing"
513
+ msgstr "Yes - do your thing"
514
+
515
+ #: includes/i18n.php:155
516
+ msgctxt "active mode"
517
+ msgid "Active"
518
+ msgstr "Aktiv"
519
+
520
+ #: includes/i18n.php:156
521
+ msgctxt "is active mode?"
522
+ msgid "Is Active"
523
+ msgstr "Er aktiv"
524
+
525
+ #: includes/i18n.php:157
526
+ msgid "Install Now"
527
+ msgstr "Installer nu"
528
+
529
+ #: includes/i18n.php:158
530
+ msgid "Install Update Now"
531
+ msgstr "Installer opdatering nu"
532
+
533
+ #: includes/i18n.php:159
534
+ msgid "More information about %s"
535
+ msgstr "Mere information om %s"
536
+
537
+ #: includes/i18n.php:160
538
+ msgid "Localhost"
539
+ msgstr "Localhost"
540
+
541
+ #: includes/i18n.php:161
542
+ msgctxt "as activate Professional plan"
543
+ msgid "Activate %s Plan"
544
+ msgstr "Aktiver plan %s"
545
+
546
+ #: includes/i18n.php:162
547
+ msgctxt "as 5 licenses left"
548
+ msgid "%s left"
549
+ msgstr "%s tilbage"
550
+
551
+ #: includes/i18n.php:163
552
+ msgid "Last license"
553
+ msgstr "Seneste license"
554
+
555
+ #: includes/i18n.php:164
556
+ msgid "What is your %s?"
557
+ msgstr "What is your %s?"
558
+
559
+ #: includes/i18n.php:165
560
+ msgid "Activate this add-on"
561
+ msgstr "Aktiver denne tilføjelse"
562
+
563
+ #: includes/i18n.php:166
564
+ msgid "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?"
565
+ msgstr "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?"
566
+
567
+ #: includes/i18n.php:167
568
+ msgid "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?"
569
+ msgstr "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?"
570
+
571
+ #: includes/i18n.php:168
572
+ msgid "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?"
573
+ msgstr "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?"
574
+
575
+ #: includes/i18n.php:169
576
+ msgid "Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s."
577
+ msgstr "Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s."
578
+
579
+ #: includes/i18n.php:170
580
+ msgid "Cancelling the trial will immediately block access to all premium features. Are you sure?"
581
+ msgstr "Cancelling the trial will immediately block access to all premium features. Are you sure?"
582
+
583
+ #: includes/i18n.php:171
584
+ msgid "You can still enjoy all %s features but you will not have access to plugin updates and support."
585
+ msgstr "You can still enjoy all %s features but you will not have access to plugin updates and support."
586
+
587
+ #: includes/i18n.php:172
588
+ msgid "Once your license expires you can still use the Free version but you will NOT have access to the %s features."
589
+ msgstr "Once your license expires you can still use the Free version but you will NOT have access to the %s features."
590
+
591
+ #: includes/i18n.php:173
592
+ msgid "Are you sure you want to proceed?"
593
+ msgstr "Er du sikker på, du vil fortsætte?"
594
+
595
+ #: includes/i18n.php:176
596
+ msgid "Add Ons for %s"
597
+ msgstr "Tilføjelser til %s"
598
+
599
+ #: includes/i18n.php:177
600
+ msgid "We could'nt load the add-ons list. It's probably an issue on our side, please try to come back in few minutes."
601
+ msgstr "We could'nt load the add-ons list. It's probably an issue on our side, please try to come back in few minutes."
602
+
603
+ #: includes/i18n.php:179
604
+ msgid "Anonymous feedback"
605
+ msgstr "Anonym feedback"
606
+
607
+ #: includes/i18n.php:180
608
+ msgid "Quick feedback"
609
+ msgstr "Hurtig feedback"
610
+
611
+ #: includes/i18n.php:181
612
+ msgid "If you have a moment, please let us know why you are deactivating"
613
+ msgstr "Hvis du har et øjeblik, så lad os venligst vide, hvorfor du deaktiverer"
614
+
615
+ #: includes/i18n.php:182
616
+ msgid "Yes - Deactivate"
617
+ msgstr "Ja - deaktiver"
618
+
619
+ #: includes/i18n.php:183
620
+ msgid "Submit & Deactivate"
621
+ msgstr "Send & deaktiver"
622
+
623
+ #: includes/i18n.php:184
624
+ msgid "Cancel"
625
+ msgstr "Annuller"
626
+
627
+ #: includes/i18n.php:185
628
+ msgid "I no longer need the plugin"
629
+ msgstr "Jeg har ikke længere brug for dette plugin"
630
+
631
+ #: includes/i18n.php:186
632
+ msgid "I found a better plugin"
633
+ msgstr "Jeg har fundet et bedre plugin"
634
+
635
+ #: includes/i18n.php:187
636
+ msgid "I only needed the plugin for a short period"
637
+ msgstr "Jeg skulle kun bruge pluginnet i en kort periode"
638
+
639
+ #: includes/i18n.php:188
640
+ msgid "The plugin broke my site"
641
+ msgstr "Pluginnet ødelagde mit websted"
642
+
643
+ #: includes/i18n.php:189
644
+ msgid "The plugin suddenly stopped working"
645
+ msgstr "Pluginnet virker ikke længere"
646
+
647
+ #: includes/i18n.php:190
648
+ msgid "I can't pay for it anymore"
649
+ msgstr "Jeg kan ikke længere betale for det"
650
+
651
+ #: includes/i18n.php:191
652
+ msgid "It's a temporary deactivation. I'm just debugging an issue."
653
+ msgstr "Det er en midlertidig deaktivering. Jeg prøver at fejlfinde et problem."
654
+
655
+ #: includes/i18n.php:192
656
+ msgctxt ""
657
+ msgid "Other"
658
+ msgstr "Andet"
659
+
660
+ #: includes/i18n.php:194
661
+ msgid "Kindly tell us the reason so we can improve."
662
+ msgstr "Fortæl os venligst årsagen, så vi kan forbedre det."
663
+
664
+ #: includes/i18n.php:195
665
+ msgid "What's the plugin's name?"
666
+ msgstr "Hvad er pluginnets navn?"
667
+
668
+ #: includes/i18n.php:196
669
+ msgid "What price would you feel comfortable paying?"
670
+ msgstr "What price would you feel comfortable paying?"
671
+
672
+ #: includes/i18n.php:197
673
+ msgid "I couldn't understand how to make it work"
674
+ msgstr "Jeg forstod ikke, hvordan jeg skulle få det til at fungere."
675
+
676
+ #: includes/i18n.php:198
677
+ msgid "The plugin is great, but I need specific feature that you don't support"
678
+ msgstr "Pluginnet er godt, men jeg har brug for en specifik funktionalitet, som det ikke understøtter."
679
+
680
+ #: includes/i18n.php:199
681
+ msgid "The plugin is not working"
682
+ msgstr "Pluginnet virker ikke"
683
+
684
+ #: includes/i18n.php:200
685
+ msgid "It's not what I was looking for"
686
+ msgstr "Det er ikke, hvad jeg søgte"
687
+
688
+ #: includes/i18n.php:201
689
+ msgid "The plugin didn't work as expected"
690
+ msgstr "Plugin virkede ikke som forventet"
691
+
692
+ #: includes/i18n.php:202
693
+ msgid "What feature?"
694
+ msgstr "Hvilken feature?"
695
+
696
+ #: includes/i18n.php:203
697
+ msgid "Kindly share what didn't work so we can fix it for future users..."
698
+ msgstr "Kindly share what didn't work so we can fix it for future users..."
699
+
700
+ #: includes/i18n.php:204
701
+ msgid "What you've been looking for?"
702
+ msgstr "What you've been looking for?"
703
+
704
+ #: includes/i18n.php:205
705
+ msgid "What did you expect?"
706
+ msgstr "Hvad forventede du?"
707
+
708
+ #: includes/i18n.php:206
709
+ msgid "The plugin didn't work"
710
+ msgstr "Pluginnet virkede ikke"
711
+
712
+ #: includes/i18n.php:207
713
+ msgid "I don't like to share my information with you"
714
+ msgstr "I don't like to share my information with you"
715
+
716
+ #: includes/i18n.php:208
717
+ msgid "You might have missed it, but you don't have to share any data and can just %s the opt-in."
718
+ msgstr "You might have missed it, but you don't have to share any data and can just %s the opt-in."
719
+
720
+ #: includes/i18n.php:212
721
+ msgctxt "greeting"
722
+ msgid "Hey %s,"
723
+ msgstr "Hey %s,"
724
+
725
+ #: includes/i18n.php:213
726
+ msgctxt "a greeting. E.g. Thanks John!"
727
+ msgid "Thanks %s!"
728
+ msgstr "Tak %s!"
729
+
730
+ #: includes/i18n.php:214
731
+ msgid "Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s."
732
+ msgstr "Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s."
733
+
734
+ #: includes/i18n.php:215
735
+ msgid "Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that's okay! %1$s will still work just fine."
736
+ msgstr "Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that's okay! %1$s will still work just fine."
737
+
738
+ #: includes/i18n.php:216
739
+ msgid "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 %s."
740
+ msgstr "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 %s."
741
+
742
+ #: includes/i18n.php:217
743
+ msgid "complete the install"
744
+ msgstr "færdiggør installeringen"
745
+
746
+ #: includes/i18n.php:218
747
+ msgid "start the trial"
748
+ msgstr "start prøveperioden"
749
+
750
+ #: includes/i18n.php:219
751
+ msgid "Thanks for purchasing %s! To get started, please enter your license key:"
752
+ msgstr "Thanks for purchasing %s! To get started, please enter your license key:"
753
+
754
+ #: includes/i18n.php:220
755
+ msgid "The plugin will be periodically sending data to %s to check for plugin updates and verify the validity of your license."
756
+ msgstr "The plugin will be periodically sending data to %s to check for plugin updates and verify the validity of your license."
757
+
758
+ #: includes/i18n.php:221
759
+ msgid "What permissions are being granted?"
760
+ msgstr "Hvilke tilladelser bliver givet?"
761
+
762
+ #: includes/i18n.php:222
763
+ msgid "Your Profile Overview"
764
+ msgstr "Overblik af din profil"
765
+
766
+ #: includes/i18n.php:223
767
+ msgid "Name and email address"
768
+ msgstr "Navn og e-mailadresse"
769
+
770
+ #: includes/i18n.php:224
771
+ msgid "Your Site Overview"
772
+ msgstr "Overblik af dit websted"
773
+
774
+ #: includes/i18n.php:225
775
+ msgid "Site URL, WP version, PHP info, plugins & themes"
776
+ msgstr "Websteds-URL, WP version, PHP info, plugins og temaer"
777
+
778
+ #: includes/i18n.php:226
779
+ msgid "Current Plugin Events"
780
+ msgstr "Nuværende plugin-begivenheder"
781
+
782
+ #: includes/i18n.php:227
783
+ msgid "Activation, deactivation and uninstall"
784
+ msgstr "Aktivering, deaktivering og afinstallering"
785
+
786
+ #: includes/i18n.php:228
787
+ msgid "Plugins & Themes"
788
+ msgstr "Plugins & Temaer"
789
+
790
+ #: includes/i18n.php:229
791
+ msgid "Titles, versions and state."
792
+ msgstr "Titler, versioner og tilstand."
793
+
794
+ #: includes/i18n.php:230
795
+ msgid "Admin Notices"
796
+ msgstr "Admin Notices"
797
+
798
+ #: includes/i18n.php:231
799
+ msgid "Newsletter"
800
+ msgstr "Nyhedsbrev"
801
+
802
+ #: includes/i18n.php:232
803
+ msgid "Updates, announcements, marketing, no spam"
804
+ msgstr "Updates, announcements, marketing, no spam"
805
+
806
+ #: includes/i18n.php:233
807
+ msgid "Privacy Policy"
808
+ msgstr "Privatlivspolitik"
809
+
810
+ #: includes/i18n.php:234
811
+ msgid "Terms of Service"
812
+ msgstr "Servicevilkår"
813
+
814
+ #: includes/i18n.php:235
815
+ msgctxt "as activating plugin"
816
+ msgid "Activating"
817
+ msgstr "Aktiverer"
818
+
819
+ #: includes/i18n.php:236
820
+ msgctxt "as in the process of sending an email"
821
+ msgid "Sending email"
822
+ msgstr "Sender e-mail"
823
+
824
+ #: includes/i18n.php:237
825
+ msgctxt "button label"
826
+ msgid "Allow & Continue"
827
+ msgstr "Tillad & Fortsæt"
828
+
829
+ #: includes/i18n.php:238
830
+ msgctxt "button label"
831
+ msgid "Agree & Activate License"
832
+ msgstr "Accepter & aktiver licens"
833
+
834
+ #: includes/i18n.php:239
835
+ msgctxt "verb"
836
+ msgid "Skip"
837
+ msgstr "Spring over"
838
+
839
+ #: includes/i18n.php:240
840
+ msgid "Click here to use the plugin anonymously"
841
+ msgstr "Klik her for at benytte pluginnet anonymt"
842
+
843
+ #: includes/i18n.php:241
844
+ msgid "Re-send activation email"
845
+ msgstr "Gensend e-mail om aktivering"
846
+
847
+ #: includes/i18n.php:242
848
+ msgid "License key"
849
+ msgstr "Licensnøgle"
850
+
851
+ #: includes/i18n.php:243
852
+ msgid "Send License Key"
853
+ msgstr "Send licensnøgle"
854
+
855
+ #: includes/i18n.php:244
856
+ msgid "Sending license key"
857
+ msgstr "Sender licensnøgle"
858
+
859
+ #: includes/i18n.php:245
860
+ msgid "Have a license key?"
861
+ msgstr "Har du en licensnøgle?"
862
+
863
+ #: includes/i18n.php:246
864
+ msgid "Don't have a license key?"
865
+ msgstr "Har du ikke en licensnøgle?"
866
+
867
+ #: includes/i18n.php:247
868
+ msgid "Can't find your license key?"
869
+ msgstr "Kan du ikke finde din licensnøgle?"
870
+
871
+ #: includes/i18n.php:248
872
+ msgid "We couldn't find your email address in the system, are you sure it's the right address?"
873
+ msgstr "We couldn't find your email address in the system, are you sure it's the right address?"
874
+
875
+ #: includes/i18n.php:249
876
+ msgid "We can't see any active licenses associated with that email address, are you sure it's the right address?"
877
+ msgstr "We can't see any active licenses associated with that email address, are you sure it's the right address?"
878
+
879
+ #: includes/i18n.php:250
880
+ msgid "Opt In"
881
+ msgstr "Tilmeld"
882
+
883
+ #: includes/i18n.php:251
884
+ msgid "Opt Out"
885
+ msgstr "Frameld"
886
+
887
+ #: includes/i18n.php:252
888
+ msgid "On second thought - I want to continue helping"
889
+ msgstr "Ved nærmere eftertanke - Jeg vil fortsætte med at hjælpe"
890
+
891
+ #: includes/i18n.php:253
892
+ msgid "Opting out..."
893
+ msgstr "Framelder..."
894
+
895
+ #: includes/i18n.php:254
896
+ msgid "Opting in..."
897
+ msgstr "Tilmelder..."
898
+
899
+ #: includes/i18n.php:255
900
+ msgid "We appreciate your help in making the %s better by letting us track some usage data."
901
+ msgstr "We appreciate your help in making the %s better by letting us track some usage data."
902
+
903
+ #: includes/i18n.php:256
904
+ msgid "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking."
905
+ msgstr "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking."
906
+
907
+ #: includes/i18n.php:257
908
+ msgid "By clicking \"Opt Out\", we will no longer be sending any data from %s to %s."
909
+ msgstr "Ved at klikke \"Frameld\" vil vi ikke længere sende data fra %s til %s."
910
+
911
+ #: includes/i18n.php:261
912
+ msgid "Screenshots"
913
+ msgstr "Skærmbilleder"
914
+
915
+ #: includes/i18n.php:262
916
+ msgid "Click to view full-size screenshot %d"
917
+ msgstr "Click to view full-size screenshot %d"
918
+
919
+ #: includes/i18n.php:266
920
+ msgid "Freemius Debug"
921
+ msgstr "Freemius Debug"
922
+
923
+ #: includes/i18n.php:267
924
+ msgctxt "as turned on"
925
+ msgid "On"
926
+ msgstr "Til"
927
+
928
+ #: includes/i18n.php:268
929
+ msgctxt "as turned off"
930
+ msgid "Off"
931
+ msgstr "Fra"
932
+
933
+ #: includes/i18n.php:269
934
+ msgctxt "as code debugging"
935
+ msgid "Debugging"
936
+ msgstr "Fejlfinding"
937
+
938
+ #: includes/i18n.php:270
939
+ msgid "Freemius State"
940
+ msgstr "Freemius tilstand"
941
+
942
+ #: includes/i18n.php:271
943
+ msgctxt "as connection was successful"
944
+ msgid "Connected"
945
+ msgstr "Forbundet"
946
+
947
+ #: includes/i18n.php:272
948
+ msgctxt "as connection blocked"
949
+ msgid "Blocked"
950
+ msgstr "Blokeret"
951
+
952
+ #: includes/i18n.php:273
953
+ msgctxt "as application program interface"
954
+ msgid "API"
955
+ msgstr "API"
956
+
957
+ #: includes/i18n.php:274
958
+ msgctxt "as software development kit versions"
959
+ msgid "SDK"
960
+ msgstr "SDK"
961
+
962
+ #: includes/i18n.php:275
963
+ msgctxt "as software development kit versions"
964
+ msgid "SDK Versions"
965
+ msgstr "SDK-versioner"
966
+
967
+ #: includes/i18n.php:276
968
+ msgctxt "as plugin folder path"
969
+ msgid "Plugin Path"
970
+ msgstr "Plugin-sti"
971
+
972
+ #: includes/i18n.php:277
973
+ msgctxt "as sdk path"
974
+ msgid "SDK Path"
975
+ msgstr "SDK-sti"
976
+
977
+ #: includes/i18n.php:278
978
+ msgid "Add Ons of Plugin %s"
979
+ msgstr "Tilføjelser til plugin %s"
980
+
981
+ #: includes/i18n.php:279
982
+ msgid "Are you sure you want to delete all Freemius data?"
983
+ msgstr "Er du sikker på, du vil slette al Freemius data?"
984
+
985
+ #: includes/i18n.php:280
986
+ msgid "Actions"
987
+ msgstr "Handlinger"
988
+
989
+ #: includes/i18n.php:281
990
+ msgid "Delete All Accounts"
991
+ msgstr "Slet alle konti"
992
+
993
+ #: includes/i18n.php:282
994
+ msgid "Start Fresh"
995
+ msgstr "Start forfra"
996
+
997
+ #: includes/i18n.php:283
998
+ msgid "Clear API Cache"
999
+ msgstr "Ryd API-cache"
1000
+
1001
+ #: includes/i18n.php:284
1002
+ msgid "Sync Data From Server"
1003
+ msgstr "Synkroniser data fra server"
1004
+
1005
+ #: includes/i18n.php:285
1006
+ msgid "Scheduled Crons"
1007
+ msgstr "Planlagte cron jobs"
1008
+
1009
+ #: includes/i18n.php:286
1010
+ msgid "Cron Type"
1011
+ msgstr "Cron Type"
1012
+
1013
+ #: includes/i18n.php:287
1014
+ msgid "Plugins & Themes Sync"
1015
+ msgstr "Synkronisering af plugins og temaer"
1016
+
1017
+ #: includes/i18n.php:288
1018
+ msgid "Licenses"
1019
+ msgstr "Licenser"
1020
+
1021
+ #: includes/i18n.php:289
1022
+ msgid "Debug Log"
1023
+ msgstr "Fejlfindingslog"
1024
+
1025
+ #: includes/i18n.php:290
1026
+ msgid "All"
1027
+ msgstr "Alle"
1028
+
1029
+ #: includes/i18n.php:291
1030
+ msgid "File"
1031
+ msgstr "Fil"
1032
+
1033
+ #: includes/i18n.php:292
1034
+ msgid "Function"
1035
+ msgstr "Funktion"
1036
+
1037
+ #: includes/i18n.php:293
1038
+ msgid "Process ID"
1039
+ msgstr "Proces-ID"
1040
+
1041
+ #: includes/i18n.php:294
1042
+ msgid "Logger"
1043
+ msgstr "Logger"
1044
+
1045
+ #: includes/i18n.php:295
1046
+ msgid "Message"
1047
+ msgstr "Besked"
1048
+
1049
+ #: includes/i18n.php:296
1050
+ msgid "Download"
1051
+ msgstr "Download"
1052
+
1053
+ #: includes/i18n.php:297
1054
+ msgid "Filter"
1055
+ msgstr "Filter"
1056
+
1057
+ #: includes/i18n.php:298
1058
+ msgid "Type"
1059
+ msgstr "Type"
1060
+
1061
+ #: includes/i18n.php:299
1062
+ msgid "All Types"
1063
+ msgstr "Alle typer"
1064
+
1065
+ #: includes/i18n.php:300
1066
+ msgid "All Requests"
1067
+ msgstr "Alle forespørgsler"
1068
+
1069
+ #: includes/i18n.php:304
1070
+ msgctxt "as congratulations"
1071
+ msgid "Congrats"
1072
+ msgstr "Tillykke"
1073
+
1074
+ #: includes/i18n.php:305
1075
+ msgctxt "exclamation"
1076
+ msgid "Oops"
1077
+ msgstr "Ups"
1078
+
1079
+ #: includes/i18n.php:306
1080
+ msgctxt "interjection expressing joy or exuberance"
1081
+ msgid "Yee-haw"
1082
+ msgstr "Yee-haw"
1083
+
1084
+ #: includes/i18n.php:307
1085
+ msgctxt ""
1086
+ msgid "W00t"
1087
+ msgstr "W00t"
1088
+
1089
+ #: includes/i18n.php:309
1090
+ msgctxt "a positive response"
1091
+ msgid "Right on"
1092
+ msgstr "Sådan"
1093
+
1094
+ #: includes/i18n.php:310
1095
+ msgctxt ""
1096
+ msgid "Hmm"
1097
+ msgstr "Hmm"
1098
+
1099
+ #: includes/i18n.php:312
1100
+ msgid "O.K"
1101
+ msgstr "O.K"
1102
+
1103
+ #: includes/i18n.php:313
1104
+ msgctxt "exclamation"
1105
+ msgid "Hey"
1106
+ msgstr "Hey"
1107
+
1108
+ #: includes/i18n.php:314
1109
+ msgctxt "advance notice of something that will need attention."
1110
+ msgid "Heads up"
1111
+ msgstr "Se her"
1112
+
1113
+ #: includes/i18n.php:319
1114
+ msgid "Seems like you got the latest release."
1115
+ msgstr "Det ser ud til, at du har den seneste udgivelse."
1116
+
1117
+ #: includes/i18n.php:320
1118
+ msgid "You are all good!"
1119
+ msgstr "Det var det!"
1120
+
1121
+ #: includes/i18n.php:321
1122
+ msgid "Sorry, we could not complete the email update. Another user with the same email is already registered."
1123
+ msgstr "Sorry, we could not complete the email update. Another user with the same email is already registered."
1124
+
1125
+ #: includes/i18n.php:322
1126
+ msgid "If you would like to give up the ownership of the plugin's account to %s click the Change Ownership button."
1127
+ msgstr "If you would like to give up the ownership of the plugin's account to %s click the Change Ownership button."
1128
+
1129
+ #: includes/i18n.php:323
1130
+ msgid "Your email was successfully updated. You should receive an email with confirmation instructions in few moments."
1131
+ msgstr "Your email was successfully updated. You should receive an email with confirmation instructions in few moments."
1132
+
1133
+ #: includes/i18n.php:324
1134
+ msgid "Your name was successfully updated."
1135
+ msgstr "Dit navn er blevet opdateret."
1136
+
1137
+ #: includes/i18n.php:325
1138
+ msgid "You have successfully updated your %s."
1139
+ msgstr "Opdatering af %s blev gennemført."
1140
+
1141
+ #: includes/i18n.php:326
1142
+ msgid "Please provide your full name."
1143
+ msgstr "Indtast venligst dit fulde navn."
1144
+
1145
+ #: includes/i18n.php:327
1146
+ msgid "Verification mail was just sent to %s. If you can't find it after 5 min, please check your spam box."
1147
+ msgstr "Verification mail was just sent to %s. If you can't find it after 5 min, please check your spam box."
1148
+
1149
+ #: includes/i18n.php:328
1150
+ msgid "Just letting you know that the add-ons information of %s is being pulled from an external server."
1151
+ msgstr "Just letting you know that the add-ons information of %s is being pulled from an external server."
1152
+
1153
+ #: includes/i18n.php:329
1154
+ msgid "No credit card required"
1155
+ msgstr "Betalingskort ikke påkrævet"
1156
+
1157
+ #: includes/i18n.php:330
1158
+ msgid "Premium plugin version was successfully activated."
1159
+ msgstr "Premium-versionen af pluginnet blev aktiveret."
1160
+
1161
+ #: includes/i18n.php:331
1162
+ msgid "The upgrade of %s was successfully completed."
1163
+ msgstr "Opgraderingen af %s blev fuldendt."
1164
+
1165
+ #: includes/i18n.php:332
1166
+ msgid "Your account was successfully activated with the %s plan."
1167
+ msgstr "Din konto blev aktiveret med planen %s."
1168
+
1169
+ #: includes/i18n.php:333
1170
+ msgid "Download the latest %s version now"
1171
+ msgstr "Download den seneste version af %s nu"
1172
+
1173
+ #: includes/i18n.php:334
1174
+ msgid "Please follow these steps to complete the upgrade"
1175
+ msgstr "Følg venligst disse trin for at færdiggøre opgraderingen"
1176
+
1177
+ #: includes/i18n.php:335
1178
+ msgid "Download the latest %s version"
1179
+ msgstr "Download den seneste version af %s"
1180
+
1181
+ #: includes/i18n.php:336
1182
+ msgid "Download the latest version"
1183
+ msgstr "Download den seneste version"
1184
+
1185
+ #: includes/i18n.php:337
1186
+ msgid "Deactivate the free version"
1187
+ msgstr "Deaktiver den gratis version"
1188
+
1189
+ #: includes/i18n.php:338
1190
+ msgid "Upload and activate the downloaded version"
1191
+ msgstr "Upload og aktiver den downloadede version"
1192
+
1193
+ #: includes/i18n.php:339
1194
+ msgid "How to upload and activate?"
1195
+ msgstr "Upload og aktivering, hvordan?"
1196
+
1197
+ #: includes/i18n.php:340
1198
+ msgctxt "%s - product name, e.g. Facebook add-on was successfully..."
1199
+ msgid "%s Add-on was successfully purchased."
1200
+ msgstr "Betalingen for tilføjelsen %s blev gennemført."
1201
+
1202
+ #: includes/i18n.php:342
1203
+ msgid "Your %s Add-on plan was successfully upgraded."
1204
+ msgstr "Your %s Add-on plan was successfully upgraded."
1205
+
1206
+ #: includes/i18n.php:343
1207
+ msgid "Your email has been successfully verified - you are AWESOME!"
1208
+ msgstr "Your email has been successfully verified - you are AWESOME!"
1209
+
1210
+ #: includes/i18n.php:344
1211
+ msgid "Your plan was successfully upgraded."
1212
+ msgstr "Din plan er blevet opgraderet."
1213
+
1214
+ #: includes/i18n.php:345
1215
+ msgid "Your plan was successfully changed to %s."
1216
+ msgstr "Din plan er blevet ændret til %s."
1217
+
1218
+ #: includes/i18n.php:346
1219
+ msgid "Your license has expired. You can still continue using the free plugin forever."
1220
+ msgstr "Din licens er udløbet. Du kan stadig fortsætte med at benytte det gratis plugin for evigt."
1221
+
1222
+ #: includes/i18n.php:347
1223
+ msgid "Your license has been cancelled. If you think it's a mistake, please contact support."
1224
+ msgstr "Din licens er blevet annulleret. Hvis du mener, dette er en fejl, så kontakt venligst support."
1225
+
1226
+ #: includes/i18n.php:348
1227
+ msgid "Your trial has been successfully started."
1228
+ msgstr "Din prøveperiode er begyndt."
1229
+
1230
+ #: includes/i18n.php:349
1231
+ msgid "Your license was successfully activated."
1232
+ msgstr "Din licens er blevet aktiveret."
1233
+
1234
+ #: includes/i18n.php:350
1235
+ msgid "It looks like your site currently doesn't have an active license."
1236
+ msgstr "Det ser ud til, at dit websted endnu ikke har en aktiv licens."
1237
+
1238
+ #: includes/i18n.php:351
1239
+ msgid "Your license was successfully deactivated, you are back to the %s plan."
1240
+ msgstr "Din licens blev deaktiveret, du er tilbage på planen %s."
1241
+
1242
+ #: includes/i18n.php:352
1243
+ msgid "It looks like the license deactivation failed."
1244
+ msgstr "Det ser ud til, at licens-deaktiveringen mislykkedes."
1245
+
1246
+ #: includes/i18n.php:353
1247
+ msgid "It looks like the license could not be activated."
1248
+ msgstr "Det ser ud til, at licensen ikke kunne aktiveres."
1249
+
1250
+ #: includes/i18n.php:354
1251
+ msgid "Error received from the server:"
1252
+ msgstr "Fejl modtager fra serveren:"
1253
+
1254
+ #: includes/i18n.php:355
1255
+ msgid "Your trial has expired. You can still continue using all our free features."
1256
+ msgstr "Din prøveperiode er udløbet. Du kan fortsat bruge alle vores gratis funktioner."
1257
+
1258
+ #: includes/i18n.php:356
1259
+ msgid "Your plan was successfully downgraded. Your %s plan license will expire in %s."
1260
+ msgstr "Din plan blev nedgraderet. Licensen til din %s plan vil udløbe om %s."
1261
+
1262
+ #: includes/i18n.php:357
1263
+ msgid "Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes."
1264
+ msgstr "Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes."
1265
+
1266
+ #: includes/i18n.php:358
1267
+ msgid "It looks like you are not in trial mode anymore so there's nothing to cancel :)"
1268
+ msgstr "It looks like you are not in trial mode anymore so there's nothing to cancel :)"
1269
+
1270
+ #: includes/i18n.php:359
1271
+ msgid "Your %s free trial was successfully cancelled."
1272
+ msgstr "Din gratis prøveperiode for %s er blevet annulleret."
1273
+
1274
+ #: includes/i18n.php:360
1275
+ msgctxt "%s - numeric version number"
1276
+ msgid "Version %s was released."
1277
+ msgstr "Version %s er blevet udgivet."
1278
+
1279
+ #: includes/i18n.php:361
1280
+ msgid "Please download %s."
1281
+ msgstr "Download venligst %s."
1282
+
1283
+ #: includes/i18n.php:362
1284
+ msgctxt "%s - plan name, as the latest professional version here"
1285
+ msgid "the latest %s version here"
1286
+ msgstr "den seneste version af %s her"
1287
+
1288
+ #: includes/i18n.php:364
1289
+ msgid "How do you like %s so far? Test all our %s premium features with a %d-day free trial."
1290
+ msgstr "How do you like %s so far? Test all our %s premium features with a %d-day free trial."
1291
+
1292
+ #: includes/i18n.php:365
1293
+ msgctxt "call to action"
1294
+ msgid "Start free trial"
1295
+ msgstr "Start gratis prøveperiode"
1296
+
1297
+ #: includes/i18n.php:366
1298
+ msgid "Starting trial"
1299
+ msgstr "Starter prøveperiode"
1300
+
1301
+ #: includes/i18n.php:367
1302
+ msgid "Please wait"
1303
+ msgstr "Vent venligst"
1304
+
1305
+ #: includes/i18n.php:368
1306
+ msgid "Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes."
1307
+ msgstr "Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes."
1308
+
1309
+ #: includes/i18n.php:369
1310
+ msgid "You already utilized a trial before."
1311
+ msgstr "Du har allerede brugt din prøveperiode."
1312
+
1313
+ #: includes/i18n.php:370
1314
+ msgid "You are already running the plugin in a trial mode."
1315
+ msgstr "Du benytter allerede dette plugin under en prøveperiode."
1316
+
1317
+ #: includes/i18n.php:371
1318
+ msgid "Plan %s do not exist, therefore, can't start a trial."
1319
+ msgstr "Plan %s eksisterer ikke og kan derfor ikke starte prøveperiode."
1320
+
1321
+ #: includes/i18n.php:372
1322
+ msgid "Plan %s does not support a trial period."
1323
+ msgstr "Plan %s understøtter ikke en prøveperiode."
1324
+
1325
+ #: includes/i18n.php:373
1326
+ msgid "None of the plugin's plans supports a trial period."
1327
+ msgstr "Ingen af dette plugins planer understøtter prøveperiode."
1328
+
1329
+ #: includes/i18n.php:374
1330
+ msgid "Unexpected API error. Please contact the plugin's author with the following error."
1331
+ msgstr "Unexpected API error. Please contact the plugin's author with the following error."
1332
+
1333
+ #: includes/i18n.php:375
1334
+ msgid "No commitment for %s days - cancel anytime!"
1335
+ msgstr "Ingen bindinger i %s dage - annuller når som helst!"
1336
+
1337
+ #: includes/i18n.php:376
1338
+ msgid "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."
1339
+ msgstr "Din licens er udløbet. Du kan stadig benytte alle funktionerne i %s, men du bliver nødt til at fornye din licens for at få opdateringer og support."
1340
+
1341
+ #: includes/i18n.php:377
1342
+ msgid "Couldn't activate %s."
1343
+ msgstr "Kunne ikke aktivere %s."
1344
+
1345
+ #: includes/i18n.php:378
1346
+ msgid "Please contact us with the following message:"
1347
+ msgstr "Kontakt os venligst med følgende besked:"
1348
+
1349
+ #: includes/i18n.php:379
1350
+ msgid "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."
1351
+ msgstr "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."
1352
+
1353
+ #: includes/i18n.php:380
1354
+ msgid "Please contact us here"
1355
+ msgstr "Kontakt os her"
1356
+
1357
+ #: includes/i18n.php:381
1358
+ msgid "I have upgraded my account but when I try to Sync the License, the plan remains %s."
1359
+ msgstr "I have upgraded my account but when I try to Sync the License, the plan remains %s."
1360
+
1361
+ #: includes/i18n.php:384
1362
+ msgid "From unknown reason, the API connectivity test failed."
1363
+ msgstr "From unknown reason, the API connectivity test failed."
1364
+
1365
+ #: includes/i18n.php:385
1366
+ msgid "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?"
1367
+ msgstr "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?"
1368
+
1369
+ #: includes/i18n.php:386
1370
+ msgid "We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server."
1371
+ msgstr "We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server."
1372
+
1373
+ #: includes/i18n.php:387
1374
+ msgid "Disabled method(s):"
1375
+ msgstr "Disabled method(s):"
1376
+
1377
+ #: includes/i18n.php:388
1378
+ msgid "From unknown reason, CloudFlare, the firewall we use, blocks the connection."
1379
+ msgstr "Af en ukendt årsag blokerer CloudFlare, vores firewall, forbindelsen."
1380
+
1381
+ #: includes/i18n.php:389
1382
+ msgctxt "as pluginX requires an access to our API"
1383
+ msgid "%s requires an access to our API."
1384
+ msgstr "%s påkræver adgang til vores API."
1385
+
1386
+ #: includes/i18n.php:391
1387
+ msgid "It looks like your server is using Squid ACL (access control lists), which blocks the connection."
1388
+ msgstr "Det ser ud til, at din server benytter Squid ACL (access control lists), som blokerer forbindelsen."
1389
+
1390
+ #: includes/i18n.php:392
1391
+ msgid "I don't know what is Squid or ACL, help me!"
1392
+ msgstr "Jeg ved ikke hvad Squid eller ACL er. Hjælp mig!"
1393
+
1394
+ #: includes/i18n.php393, includes/i18n.php:397
1395
+ msgid "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."
1396
+ msgstr "Vi vil kontakte din udbyder og løse problemet. Når vi har opdatinger i sagen, vil vi følge op med en email til dig på %s."
1397
+
1398
+ #: includes/i18n.php:394
1399
+ msgid "I'm a system administrator"
1400
+ msgstr "Jeg er en system-administrator"
1401
+
1402
+ #: includes/i18n.php:395
1403
+ msgid "Great, please whitelist the following domains: %s. Once you are done, deactivate the plugin and activate it again."
1404
+ msgstr "Sådan, venligst whitelist følgende domæner: %s. Når du er færdig, skal du deaktivere pluginnet og aktivere det igen."
1405
+
1406
+ #: includes/i18n.php:396
1407
+ msgid "I don't know what is cURL or how to install it, help me!"
1408
+ msgstr "Jeg ved ikke hvad cURL er, eller hvordan jeg installerer det. Hjælp mig!"
1409
+
1410
+ #: includes/i18n.php:398
1411
+ msgid "Great, please install cURL and enable it in your php.ini file. In addition, search for the 'disable_functions' directive in your php.ini file and remove any disabled methods starting with 'curl_'. To make sure it was successfully activated, use 'phpinfo()'. Once activated, deactivate the plugin and reactivate it back again."
1412
+ msgstr "Great, please install cURL and enable it in your php.ini file. In addition, search for the 'disable_functions' directive in your php.ini file and remove any disabled methods starting with 'curl_'. To make sure it was successfully activated, use 'phpinfo()'. Once activated, deactivate the plugin and reactivate it back again."
1413
+
1414
+ #: includes/i18n.php:399
1415
+ msgid "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."
1416
+ msgstr "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."
1417
+
1418
+ #: includes/i18n.php:400
1419
+ msgid "Sorry for the inconvenience and we are here to help if you give us a chance."
1420
+ msgstr "Vi beklager ulejligheden, og vi er her for at hjælpe, hvis du giver os chancen."
1421
+
1422
+ #: includes/i18n.php:401
1423
+ msgid "Yes - I'm giving you a chance to fix it"
1424
+ msgstr "Ja - jeg giver jer en chance for at rette det"
1425
+
1426
+ #: includes/i18n.php:402
1427
+ msgid "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."
1428
+ msgstr "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."
1429
+
1430
+ #: includes/i18n.php:403
1431
+ msgid "Let's try your previous version"
1432
+ msgstr "Lad os prøve din forrige version"
1433
+
1434
+ #: includes/i18n.php:404
1435
+ msgid "Uninstall this version and install the previous one."
1436
+ msgstr "Afinstaller denne version og installer den forrige."
1437
+
1438
+ #: includes/i18n.php:405
1439
+ msgid "That's exhausting, please deactivate"
1440
+ msgstr "Det er udmattende, deaktiver venligst"
1441
+
1442
+ #: includes/i18n.php:406
1443
+ msgid "We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future."
1444
+ msgstr "We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future."
1445
+
1446
+ #: includes/i18n.php:407
1447
+ msgid "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."
1448
+ msgstr "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."
1449
+
1450
+ #: includes/i18n.php:408
1451
+ msgctxt "%1s - plugin title, %2s - API domain"
1452
+ msgid "Your server is blocking the access to Freemius' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s"
1453
+ msgstr "Your server is blocking the access to Freemius' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s"
1454
+
1455
+ #: includes/i18n.php:410
1456
+ msgid "It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again."
1457
+ msgstr "It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again."
1458
+
1459
+ #: includes/i18n.php:413
1460
+ msgid "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."
1461
+ msgstr "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."
1462
+
1463
+ #: includes/i18n.php:414
1464
+ msgid "Thanks for confirming the ownership change. An email was just sent to %s for final approval."
1465
+ msgstr "Thanks for confirming the ownership change. An email was just sent to %s for final approval."
1466
+
1467
+ #: includes/i18n.php:415
1468
+ msgid "%s is the new owner of the account."
1469
+ msgstr "%s er den nye ejer af kontoen."
1470
+
1471
+ #: includes/i18n.php:417
1472
+ msgctxt "addonX cannot run without pluginY"
1473
+ msgid "%s cannot run without %s."
1474
+ msgstr "%s virker ikke uden %s."
1475
+
1476
+ #: includes/i18n.php:419
1477
+ msgctxt "addonX cannot run..."
1478
+ msgid "%s cannot run without the plugin."
1479
+ msgstr "%s virker ikke uden pluginnet."
1480
+
1481
+ #: includes/i18n.php:420
1482
+ msgctxt "pluginX activation was successfully..."
1483
+ msgid "%s activation was successfully completed."
1484
+ msgstr "Aktivering af %s blev gennemført."
1485
+
1486
+ #: includes/i18n.php:422
1487
+ msgctxt "Plugin installer section title"
1488
+ msgid "Features & Pricing"
1489
+ msgstr "Funktioner og priser"
1490
+
1491
+ #: includes/i18n.php:423
1492
+ msgid "Add-on must be deployed to WordPress.org or Freemius."
1493
+ msgstr "Add-on must be deployed to WordPress.org or Freemius."
1494
+
1495
+ #: includes/i18n.php:424
1496
+ msgid "Paid add-on must be deployed to Freemius."
1497
+ msgstr "Paid add-on must be deployed to Freemius."
1498
+
1499
+ #: includes/i18n.php:428
1500
+ msgid "%s is a premium only add-on. You have to purchase a license first before activating the plugin."
1501
+ msgstr "%s is a premium only add-on. You have to purchase a license first before activating the plugin."
1502
+
1503
+ #: includes/i18n.php:429
1504
+ msgid "%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."
1505
+ msgstr "%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."
1506
+
1507
+ #: includes/i18n.php:434
1508
+ msgctxt "as every month"
1509
+ msgid "Monthly"
1510
+ msgstr "Månedligt"
1511
+
1512
+ #: includes/i18n.php:435
1513
+ msgctxt "as monthly period"
1514
+ msgid "mo"
1515
+ msgstr "md"
1516
+
1517
+ #: includes/i18n.php:436
1518
+ msgctxt "as once a year"
1519
+ msgid "Annual"
1520
+ msgstr "Årligt"
1521
+
1522
+ #: includes/i18n.php:437
1523
+ msgctxt "as once a year"
1524
+ msgid "Annually"
1525
+ msgstr "Årligt"
1526
+
1527
+ #: includes/i18n.php:438
1528
+ msgctxt "as once a year"
1529
+ msgid "Once"
1530
+ msgstr "Engangsbeløb"
1531
+
1532
+ #: includes/i18n.php:439
1533
+ msgctxt "as annual period"
1534
+ msgid "year"
1535
+ msgstr "år"
1536
+
1537
+ #: includes/i18n.php:440
1538
+ msgid "Lifetime"
1539
+ msgstr "Livstid"
1540
+
1541
+ #: includes/i18n.php:441
1542
+ msgctxt "e.g. the best product"
1543
+ msgid "Best"
1544
+ msgstr "Bedste"
1545
+
1546
+ #: includes/i18n.php:442
1547
+ msgctxt "e.g. billed monthly"
1548
+ msgid "Billed %s"
1549
+ msgstr "Faktureret %s"
1550
+
1551
+ #: includes/i18n.php:443
1552
+ msgctxt "as a discount of $5 or 10%"
1553
+ msgid "Save %s"
1554
+ msgstr "Spar %s"
1555
+
1556
+ #: includes/i18n.php:445
1557
+ msgid "View details"
1558
+ msgstr "Vis detaljer"
1559
+
1560
+ #: includes/i18n.php:449
1561
+ msgctxt "button label"
1562
+ msgid "Approve & Start Trial"
1563
+ msgstr "Godkend & start prøveperiode"
1564
+
1565
+ #: includes/i18n.php:451
1566
+ msgid "You are 1-click away from starting your %1$s-day free trial of the %2$s plan."
1567
+ msgstr "Du er 1 klik fra at begynde din %1$s dages gratis prøveperiode af planen %2$s."
1568
+
1569
+ #: includes/i18n.php:453
1570
+ msgid "For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt-in with your user and non-sensitive site information, allowing the plugin to periodically send data to %s to check for version updates and to validate your trial."
1571
+ msgstr "For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt-in with your user and non-sensitive site information, allowing the plugin to periodically send data to %s to check for version updates and to validate your trial."
1572
+
1573
+ #: includes/i18n.php:459
1574
+ msgid "Business name"
1575
+ msgstr "Firmanavn"
1576
+
1577
+ #: includes/i18n.php:460
1578
+ msgid "Tax / VAT ID"
1579
+ msgstr "Moms / VAT ID"
1580
+
1581
+ #: includes/i18n.php:461
1582
+ msgid "Address Line %d"
1583
+ msgstr "Adresselinje %d"
1584
+
1585
+ #: includes/i18n.php:462
1586
+ msgid "Country"
1587
+ msgstr "Land"
1588
+
1589
+ #: includes/i18n.php:463
1590
+ msgid "Select Country"
1591
+ msgstr "Vælg land"
1592
+
1593
+ #: includes/i18n.php:464
1594
+ msgid "City"
1595
+ msgstr "By"
1596
+
1597
+ #: includes/i18n.php:465
1598
+ msgid "Town"
1599
+ msgstr "By"
1600
+
1601
+ #: includes/i18n.php:466
1602
+ msgid "State"
1603
+ msgstr "Stat"
1604
+
1605
+ #: includes/i18n.php:467
1606
+ msgid "Province"
1607
+ msgstr "Provins"
1608
+
1609
+ #: includes/i18n.php:468
1610
+ msgid "ZIP / Postal Code"
1611
+ msgstr "ZIP / Postnummer"
1612
+
1613
+ #: includes/i18n.php:473
1614
+ msgid "Installing plugin: %s"
1615
+ msgstr "Installing plugin: %s"
1616
+
1617
+ #: includes/i18n.php:474
1618
+ msgid "Automatic Installation"
1619
+ msgstr "Automatic Installation"
1620
+
1621
+ #: includes/i18n.php:476
1622
+ msgid "%s sec"
1623
+ msgstr "%s sec"
1624
+
1625
+ #: includes/i18n.php:477
1626
+ msgid "An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now."
1627
+ msgstr "An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now."
1628
+
1629
+ #: includes/i18n.php:478
1630
+ msgid "The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page."
1631
+ msgstr "The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page."
1632
+
1633
+ #: includes/i18n.php:479
1634
+ msgid "Cancel Installation"
1635
+ msgstr "Cancel Installation"
1636
+
1637
+ #: includes/i18n.php:480
1638
+ msgid "The remote plugin package does not contain a folder with the desired slug and renaming did not work."
1639
+ msgstr "The remote plugin package does not contain a folder with the desired slug and renaming did not work."
1640
+
1641
+ #: includes/i18n.php:481
1642
+ msgid "Invalid module ID."
1643
+ msgstr "Invalid module ID."
1644
+
1645
+ #: includes/i18n.php:482
1646
+ msgid "Auto installation only works for opted-in users."
1647
+ msgstr "Auto installation only works for opted-in users."
1648
+
1649
+ #: includes/i18n.php:483
1650
+ msgid "Premium version already active."
1651
+ msgstr "Premium version already active."
1652
+
1653
+ #: includes/i18n.php:484
1654
+ msgid "Premium add-on version already installed."
1655
+ msgstr "Premium add-on version already installed."
1656
+
1657
+ #: includes/i18n.php:485
1658
+ msgid "You do not have a valid license to access the premium version."
1659
+ msgstr "You do not have a valid license to access the premium version."
1660
+
1661
+ #: includes/i18n.php:486
1662
+ msgid "Plugin is a \"Serviceware\" which means it does not have a premium code version."
1663
+ msgstr "Plugin is a \"Serviceware\" which means it does not have a premium code version."
1664
+
1665
+ #: includes/i18n.php:501
1666
+ msgctxt "Plugin installer section title"
1667
+ msgid "Description"
1668
+ msgstr "Beskrivelse"
1669
+
1670
+ #: includes/i18n.php:502
1671
+ msgctxt "Plugin installer section title"
1672
+ msgid "Installation"
1673
+ msgstr "Installering"
1674
+
1675
+ #: includes/i18n.php:503
1676
+ msgctxt "Plugin installer section title"
1677
+ msgid "FAQ"
1678
+ msgstr "FAQ"
1679
+
1680
+ #: includes/i18n.php:504
1681
+ msgctxt "Plugin installer section title"
1682
+ msgid "Changelog"
1683
+ msgstr "Ændringslog"
1684
+
1685
+ #: includes/i18n.php:505
1686
+ msgctxt "Plugin installer section title"
1687
+ msgid "Reviews"
1688
+ msgstr "Anmeldelser"
1689
+
1690
+ #: includes/i18n.php:506
1691
+ msgctxt "Plugin installer section title"
1692
+ msgid "Other Notes"
1693
+ msgstr "Andre noter"
1694
+
1695
+ #: includes/i18n.php:508
1696
+ msgid "%s star"
1697
+ msgstr "%s stjerne"
1698
+
1699
+ #: includes/i18n.php:510
1700
+ msgid "%s stars"
1701
+ msgstr "%s stjerner"
1702
+
1703
+ #: includes/i18n.php:512
1704
+ msgid "%s rating"
1705
+ msgstr "%s vurdering"
1706
+
1707
+ #: includes/i18n.php:514
1708
+ msgid "%s ratings"
1709
+ msgstr "%s vurderinger"
1710
+
1711
+ #: includes/i18n.php:516
1712
+ msgid "%s time"
1713
+ msgstr "%s gang"
1714
+
1715
+ #: includes/i18n.php:518
1716
+ msgid "%s times"
1717
+ msgstr "%s gange"
1718
+
1719
+ #: includes/i18n.php:520
1720
+ msgid "Click to see reviews that provided a rating of %s"
1721
+ msgstr "Click to see reviews that provided a rating of %s"
1722
+
1723
+ #: includes/i18n.php:521
1724
+ msgid "Last Updated"
1725
+ msgstr "Senest opdateret"
1726
+
1727
+ #: includes/i18n.php:522
1728
+ msgid "Requires WordPress Version:"
1729
+ msgstr "Kræver WordPress-version:"
1730
+
1731
+ #: includes/i18n.php:523
1732
+ msgctxt "as the plugin author"
1733
+ msgid "Author:"
1734
+ msgstr "Forfatter:"
1735
+
1736
+ #: includes/i18n.php:524
1737
+ msgid "Compatible up to:"
1738
+ msgstr "Kompatibel op til:"
1739
+
1740
+ #: includes/i18n.php:525
1741
+ msgid "Downloaded:"
1742
+ msgstr "Hentet:"
1743
+
1744
+ #: includes/i18n.php:526
1745
+ msgid "WordPress.org Plugin Page"
1746
+ msgstr "WordPress.org Plugin-side"
1747
+
1748
+ #: includes/i18n.php:527
1749
+ msgid "Plugin Homepage"
1750
+ msgstr "Plugin-websted"
1751
+
1752
+ #: includes/i18n.php:528
1753
+ msgid "Donate to this plugin"
1754
+ msgstr "Donér til dette plugin"
1755
+
1756
+ #: includes/i18n.php:529
1757
+ msgid "Average Rating"
1758
+ msgstr "Gennemsnitlig vurdering"
1759
+
1760
+ #: includes/i18n.php:530
1761
+ msgid "based on %s"
1762
+ msgstr "baseret på %s"
1763
+
1764
+ #: includes/i18n.php:531
1765
+ msgid "Warning:"
1766
+ msgstr "Advarsel:"
1767
+
1768
+ #: includes/i18n.php:532
1769
+ msgid "Contributors"
1770
+ msgstr "Bidragsydere"
1771
+
1772
+ #: includes/i18n.php:533
1773
+ msgid "Plugin Install"
1774
+ msgstr "Plugin Install"
1775
+
1776
+ #: includes/i18n.php:534
1777
+ msgid "This plugin has not been tested with your current version of WordPress."
1778
+ msgstr "This plugin has not been tested with your current version of WordPress."
1779
+
1780
+ #: includes/i18n.php:535
1781
+ msgid "This plugin has not been marked as compatible with your version of WordPress."
1782
+ msgstr "This plugin has not been marked as compatible with your version of WordPress."
1783
+
1784
+ #: includes/i18n.php:536
1785
+ msgid "Newer Version (%s) Installed"
1786
+ msgstr "Nyere version (%s) installeret"
1787
+
1788
+ #: includes/i18n.php:537
1789
+ msgid "Latest Version Installed"
1790
+ msgstr "Seneste version installeret"
freemius/languages/freemius-en.mo ADDED
Binary file
freemius/languages/freemius-en.po ADDED
@@ -0,0 +1,1788 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2017 freemius
2
+ # This file is distributed under the same license as the freemius package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: freemius\n"
6
+ "Report-Msgid-Bugs-To: https://github.com/Freemius/wordpress-sdk/issues\n"
7
+ "POT-Creation-Date: \n"
8
+ "PO-Revision-Date: \n"
9
+ "Last-Translator: Vova Feldman <vova@freemius.com>\n"
10
+ "Language: \n"
11
+ "Language-Team: Freemius Team <admin@freemius.com>\n"
12
+ "Content-Type: text/plain; charset=UTF-8\n"
13
+ "Content-Transfer-Encoding: 8bit\n"
14
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
15
+ "MIME-Version: 1.0\n"
16
+ "X-Poedit-Basepath: ..\n"
17
+ "X-Poedit-KeywordsList: _fs_text;_fs_echo;_fs_esc_attr;_fs_esc_attr_echo;_fs_esc_html;_fs_esc_html_echo;_fs_x:1,2c;_fs_ex:1,2c;_fs_esc_attr_x:1,2c;_fs_esc_html_x:1,2c;_fs_n:1,2;_fs_n_noop:1,2;_fs_nx:1,2,4c;_fs_nx_noop:1,2,3c\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+ "X-Poedit-SearchPathExcluded-0: *.js\n"
20
+ "X-Poedit-SourceCharset: UTF-8\n"
21
+
22
+ #: includes/i18n.php:37
23
+ msgid "Account"
24
+ msgstr "Account"
25
+
26
+ #: includes/i18n.php:38
27
+ msgid "Add On"
28
+ msgstr "Add On"
29
+
30
+ #: includes/i18n.php:39
31
+ msgid "Contact Us"
32
+ msgstr "Contact Us"
33
+
34
+ #: includes/i18n.php:40
35
+ msgid "Contact Support"
36
+ msgstr "Contact Support"
37
+
38
+ #: includes/i18n.php:41
39
+ msgid "Change Ownership"
40
+ msgstr "Change Ownership"
41
+
42
+ #: includes/i18n.php:42
43
+ msgid "Support"
44
+ msgstr "Support"
45
+
46
+ #: includes/i18n.php:43
47
+ msgid "Support Forum"
48
+ msgstr "Support Forum"
49
+
50
+ #: includes/i18n.php:44
51
+ msgid "Add Ons"
52
+ msgstr "Add Ons"
53
+
54
+ #: includes/i18n.php:45
55
+ msgctxt "verb"
56
+ msgid "Upgrade"
57
+ msgstr "Upgrade"
58
+
59
+ #: includes/i18n.php:46
60
+ msgid "Awesome"
61
+ msgstr "Awesome"
62
+
63
+ #: includes/i18n.php:47
64
+ msgctxt "noun"
65
+ msgid "Pricing"
66
+ msgstr "Pricing"
67
+
68
+ #: includes/i18n.php:48
69
+ msgctxt "noun"
70
+ msgid "Price"
71
+ msgstr "Price"
72
+
73
+ #: includes/i18n.php:49
74
+ msgid "Unlimited Updates"
75
+ msgstr "Unlimited Updates"
76
+
77
+ #: includes/i18n.php:50
78
+ msgctxt "verb"
79
+ msgid "Downgrade"
80
+ msgstr "Downgrade"
81
+
82
+ #: includes/i18n.php:51
83
+ msgctxt "verb"
84
+ msgid "Cancel Subscription"
85
+ msgstr "Cancel Subscription"
86
+
87
+ #: includes/i18n.php:52
88
+ msgid "Cancel Trial"
89
+ msgstr "Cancel Trial"
90
+
91
+ #: includes/i18n.php:53
92
+ msgid "Free Trial"
93
+ msgstr "Free Trial"
94
+
95
+ #: includes/i18n.php:54
96
+ msgid "Start my free %s"
97
+ msgstr "Start my free %s"
98
+
99
+ #: includes/i18n.php:55
100
+ msgid "No commitment for %s - cancel anytime"
101
+ msgstr "No commitment for %s - cancel anytime"
102
+
103
+ #: includes/i18n.php:56
104
+ msgid "After your free %s, pay as little as %s"
105
+ msgstr "After your free %s, pay as little as %s"
106
+
107
+ #: includes/i18n.php:57
108
+ msgid "Details"
109
+ msgstr "Details"
110
+
111
+ #: includes/i18n.php:58
112
+ msgid "Account Details"
113
+ msgstr "Account Details"
114
+
115
+ #: includes/i18n.php:59
116
+ msgctxt "verb"
117
+ msgid "Delete"
118
+ msgstr "Delete"
119
+
120
+ #: includes/i18n.php:60
121
+ msgctxt "verb"
122
+ msgid "Show"
123
+ msgstr "Show"
124
+
125
+ #: includes/i18n.php:61
126
+ msgctxt "verb"
127
+ msgid "Hide"
128
+ msgstr "Hide"
129
+
130
+ #: includes/i18n.php:62
131
+ msgctxt "verb"
132
+ msgid "Edit"
133
+ msgstr "Edit"
134
+
135
+ #: includes/i18n.php:63
136
+ msgctxt "verb"
137
+ msgid "Update"
138
+ msgstr "Update"
139
+
140
+ #: includes/i18n.php:64
141
+ msgid "Date"
142
+ msgstr "Date"
143
+
144
+ #: includes/i18n.php:65
145
+ msgid "Amount"
146
+ msgstr "Amount"
147
+
148
+ #: includes/i18n.php:66
149
+ msgid "Invoice"
150
+ msgstr "Invoice"
151
+
152
+ #: includes/i18n.php:67
153
+ msgid "Billing"
154
+ msgstr "Billing"
155
+
156
+ #: includes/i18n.php:68
157
+ msgid "Payments"
158
+ msgstr "Payments"
159
+
160
+ #: includes/i18n.php:69
161
+ msgid "Delete Account"
162
+ msgstr "Delete Account"
163
+
164
+ #: includes/i18n.php:70
165
+ msgctxt "as close a window"
166
+ msgid "Dismiss"
167
+ msgstr "Dismiss"
168
+
169
+ #: includes/i18n.php:71
170
+ msgctxt "as product pricing plan"
171
+ msgid "Plan"
172
+ msgstr "Plan"
173
+
174
+ #: includes/i18n.php:72
175
+ msgid "Change Plan"
176
+ msgstr "Change Plan"
177
+
178
+ #: includes/i18n.php:73
179
+ msgctxt "as download professional version"
180
+ msgid "Download %s Version"
181
+ msgstr "Download %s Version"
182
+
183
+ #: includes/i18n.php:74
184
+ msgctxt "as download professional version now"
185
+ msgid "Download %s version now"
186
+ msgstr "Download %s version now"
187
+
188
+ #: includes/i18n.php:75
189
+ msgctxt "as download latest version"
190
+ msgid "Download Latest"
191
+ msgstr "Download Latest"
192
+
193
+ #: includes/i18n.php:76
194
+ msgctxt "E.g. you have a professional license."
195
+ msgid "You have a %s license."
196
+ msgstr "You have a %s license."
197
+
198
+ #: includes/i18n.php:77
199
+ msgid "New"
200
+ msgstr "New"
201
+
202
+ #: includes/i18n.php:78
203
+ msgid "Free"
204
+ msgstr "Free"
205
+
206
+ #: includes/i18n.php:79
207
+ msgctxt "as trial plan"
208
+ msgid "Trial"
209
+ msgstr "Trial"
210
+
211
+ #: includes/i18n.php:80
212
+ msgctxt "as starting a trial plan"
213
+ msgid "Start Trial"
214
+ msgstr "Start Trial"
215
+
216
+ #: includes/i18n.php:81
217
+ msgctxt "verb"
218
+ msgid "Purchase"
219
+ msgstr "Purchase"
220
+
221
+ #: includes/i18n.php:82
222
+ msgid "Purchase License"
223
+ msgstr "Purchase License"
224
+
225
+ #: includes/i18n.php:83
226
+ msgctxt "verb"
227
+ msgid "Buy"
228
+ msgstr "Buy"
229
+
230
+ #: includes/i18n.php:84
231
+ msgid "Buy License"
232
+ msgstr "Buy License"
233
+
234
+ #: includes/i18n.php:85
235
+ msgid "Single Site License"
236
+ msgstr "Single Site License"
237
+
238
+ #: includes/i18n.php:86
239
+ msgid "Unlimited Licenses"
240
+ msgstr "Unlimited Licenses"
241
+
242
+ #: includes/i18n.php:87
243
+ msgid "Up to %s Sites"
244
+ msgstr "Up to %s Sites"
245
+
246
+ #: includes/i18n.php:88
247
+ msgid "%sRenew your license now%s to access version %s features and support."
248
+ msgstr "%sRenew your license now%s to access version %s features and support."
249
+
250
+ #: includes/i18n.php:89
251
+ msgid "Enter the email address you've used for the upgrade below and we will resend you the license key."
252
+ msgstr "Enter the email address you've used for the upgrade below and we will resend you the license key."
253
+
254
+ #: includes/i18n.php:90
255
+ msgctxt "e.g. Professional Plan"
256
+ msgid "%s Plan"
257
+ msgstr "%s Plan"
258
+
259
+ #: includes/i18n.php:91
260
+ msgid "You are just one step away - %s"
261
+ msgstr "You are just one step away - %s"
262
+
263
+ #: includes/i18n.php:92
264
+ msgctxt "%s - plugin name. As complete \"Jetpack\" activation now"
265
+ msgid "Complete \"%s\" Activation Now"
266
+ msgstr "Complete \"%s\" Activation Now"
267
+
268
+ #: includes/i18n.php:94
269
+ msgid "We made a few tweaks to the plugin, %s"
270
+ msgstr "We made a few tweaks to the plugin, %s"
271
+
272
+ #: includes/i18n.php:95
273
+ msgid "Opt-in to make \"%s\" Better!"
274
+ msgstr "Opt-in to make \"%s\" Better!"
275
+
276
+ #: includes/i18n.php:96
277
+ msgid "Error"
278
+ msgstr "Error"
279
+
280
+ #: includes/i18n.php:97
281
+ msgid "Freemius SDK couldn't find the plugin's main file. Please contact sdk@freemius.com with the current error."
282
+ msgstr "Freemius SDK couldn't find the plugin's main file. Please contact sdk@freemius.com with the current error."
283
+
284
+ #: includes/i18n.php:100
285
+ msgctxt "as expiration date"
286
+ msgid "Expiration"
287
+ msgstr "Expiration"
288
+
289
+ #: includes/i18n.php:101
290
+ msgctxt "as software license"
291
+ msgid "License"
292
+ msgstr "License"
293
+
294
+ #: includes/i18n.php:102
295
+ msgid "not verified"
296
+ msgstr "not verified"
297
+
298
+ #: includes/i18n.php:103
299
+ msgid "Verify Email"
300
+ msgstr "Verify Email"
301
+
302
+ #: includes/i18n.php:104
303
+ msgctxt "e.g. expires in 2 months"
304
+ msgid "Expires in %s"
305
+ msgstr "Expires in %s"
306
+
307
+ #: includes/i18n.php:105
308
+ msgctxt "e.g. auto renews in 2 months"
309
+ msgid "Auto renews in %s"
310
+ msgstr "Auto renews in %s"
311
+
312
+ #: includes/i18n.php:106
313
+ msgid "No expiration"
314
+ msgstr "No expiration"
315
+
316
+ #: includes/i18n.php:107
317
+ msgid "Expired"
318
+ msgstr "Expired"
319
+
320
+ #: includes/i18n.php:108
321
+ msgid "Cancelled"
322
+ msgstr "Cancelled"
323
+
324
+ #: includes/i18n.php:109
325
+ msgctxt "e.g. In 2 hours"
326
+ msgid "In %s"
327
+ msgstr "In %s"
328
+
329
+ #: includes/i18n.php:110
330
+ msgctxt "e.g. 2 min ago"
331
+ msgid "%s ago"
332
+ msgstr "%s ago"
333
+
334
+ #: includes/i18n.php:112
335
+ msgid "%s or higher"
336
+ msgstr "%s or higher"
337
+
338
+ #: includes/i18n.php:113
339
+ msgctxt "as plugin version"
340
+ msgid "Version"
341
+ msgstr "Version"
342
+
343
+ #: includes/i18n.php:114
344
+ msgid "Name"
345
+ msgstr "Name"
346
+
347
+ #: includes/i18n.php:115
348
+ msgid "Email"
349
+ msgstr "Email"
350
+
351
+ #: includes/i18n.php:116
352
+ msgid "Email address"
353
+ msgstr "Email address"
354
+
355
+ #: includes/i18n.php:117
356
+ msgid "Verified"
357
+ msgstr "Verified"
358
+
359
+ #: includes/i18n.php:118
360
+ msgid "Module"
361
+ msgstr "Module"
362
+
363
+ #: includes/i18n.php:119
364
+ msgid "Module Type"
365
+ msgstr "Module Type"
366
+
367
+ #: includes/i18n.php:120
368
+ msgid "Plugin"
369
+ msgstr "Plugin"
370
+
371
+ #: includes/i18n.php:121
372
+ msgid "Plugins"
373
+ msgstr "Plugins"
374
+
375
+ #: includes/i18n.php:122
376
+ msgid "Theme"
377
+ msgstr "Theme"
378
+
379
+ #: includes/i18n.php:123
380
+ msgid "Themes"
381
+ msgstr "Themes"
382
+
383
+ #: includes/i18n.php:124
384
+ msgctxt "as file/folder path"
385
+ msgid "Path"
386
+ msgstr "Path"
387
+
388
+ #: includes/i18n.php:125
389
+ msgid "Title"
390
+ msgstr "Title"
391
+
392
+ #: includes/i18n.php:126
393
+ msgid "Free version"
394
+ msgstr "Free version"
395
+
396
+ #: includes/i18n.php:127
397
+ msgid "Premium version"
398
+ msgstr "Premium version"
399
+
400
+ #: includes/i18n.php:128
401
+ msgctxt "as WP plugin slug"
402
+ msgid "Slug"
403
+ msgstr "Slug"
404
+
405
+ #: includes/i18n.php:129
406
+ msgid "ID"
407
+ msgstr "ID"
408
+
409
+ #: includes/i18n.php:130
410
+ msgid "Users"
411
+ msgstr "Users"
412
+
413
+ #: includes/i18n.php:131
414
+ msgid "Plugin Installs"
415
+ msgstr "Plugin Installs"
416
+
417
+ #: includes/i18n.php:132
418
+ msgid "%s Installs"
419
+ msgstr "%s Installs"
420
+
421
+ #: includes/i18n.php:133
422
+ msgctxt "like websites"
423
+ msgid "Sites"
424
+ msgstr "Sites"
425
+
426
+ #: includes/i18n.php:134
427
+ msgid "User ID"
428
+ msgstr "User ID"
429
+
430
+ #: includes/i18n.php:135
431
+ msgid "Site ID"
432
+ msgstr "Site ID"
433
+
434
+ #: includes/i18n.php:136
435
+ msgid "Public Key"
436
+ msgstr "Public Key"
437
+
438
+ #: includes/i18n.php:137
439
+ msgid "Secret Key"
440
+ msgstr "Secret Key"
441
+
442
+ #: includes/i18n.php:138
443
+ msgctxt "as secret encryption key missing"
444
+ msgid "No Secret"
445
+ msgstr "No Secret"
446
+
447
+ #: includes/i18n.php:139
448
+ msgid "No ID"
449
+ msgstr "No ID"
450
+
451
+ #: includes/i18n.php:140
452
+ msgctxt "as synchronize license"
453
+ msgid "Sync License"
454
+ msgstr "Sync License"
455
+
456
+ #: includes/i18n.php:141
457
+ msgctxt "as synchronize"
458
+ msgid "Sync"
459
+ msgstr "Sync"
460
+
461
+ #: includes/i18n.php:142
462
+ msgid "Activate License"
463
+ msgstr "Activate License"
464
+
465
+ #: includes/i18n.php:143
466
+ msgid "Activate Free Version"
467
+ msgstr "Activate Free Version"
468
+
469
+ #: includes/i18n.php:144
470
+ msgid "Please enter the license key that you received in the email right after the purchase:"
471
+ msgstr "Please enter the license key that you received in the email right after the purchase:"
472
+
473
+ #: includes/i18n.php:145
474
+ msgid "Activating license..."
475
+ msgstr "Activating license..."
476
+
477
+ #: includes/i18n.php:146
478
+ msgid "Change License"
479
+ msgstr "Change License"
480
+
481
+ #: includes/i18n.php:147
482
+ msgid "Update License"
483
+ msgstr "Update License"
484
+
485
+ #: includes/i18n.php:148
486
+ msgid "Deactivate License"
487
+ msgstr "Deactivate License"
488
+
489
+ #: includes/i18n.php:149
490
+ msgid "Activate"
491
+ msgstr "Activate"
492
+
493
+ #: includes/i18n.php:150
494
+ msgid "Deactivate"
495
+ msgstr "Deactivate"
496
+
497
+ #: includes/i18n.php:151
498
+ msgid "Skip & Deactivate"
499
+ msgstr "Skip & Deactivate"
500
+
501
+ #: includes/i18n.php:152
502
+ msgid "Skip & %s"
503
+ msgstr "Skip & %s"
504
+
505
+ #: includes/i18n.php:153
506
+ msgid "No - just deactivate"
507
+ msgstr "No - just deactivate"
508
+
509
+ #: includes/i18n.php:154
510
+ msgid "Yes - do your thing"
511
+ msgstr "Yes - do your thing"
512
+
513
+ #: includes/i18n.php:155
514
+ msgctxt "active mode"
515
+ msgid "Active"
516
+ msgstr "Active"
517
+
518
+ #: includes/i18n.php:156
519
+ msgctxt "is active mode?"
520
+ msgid "Is Active"
521
+ msgstr "Is Active"
522
+
523
+ #: includes/i18n.php:157
524
+ msgid "Install Now"
525
+ msgstr "Install Now"
526
+
527
+ #: includes/i18n.php:158
528
+ msgid "Install Update Now"
529
+ msgstr "Install Update Now"
530
+
531
+ #: includes/i18n.php:159
532
+ msgid "More information about %s"
533
+ msgstr "More information about %s"
534
+
535
+ #: includes/i18n.php:160
536
+ msgid "Localhost"
537
+ msgstr "Localhost"
538
+
539
+ #: includes/i18n.php:161
540
+ msgctxt "as activate Professional plan"
541
+ msgid "Activate %s Plan"
542
+ msgstr "Activate %s Plan"
543
+
544
+ #: includes/i18n.php:162
545
+ msgctxt "as 5 licenses left"
546
+ msgid "%s left"
547
+ msgstr "%s left"
548
+
549
+ #: includes/i18n.php:163
550
+ msgid "Last license"
551
+ msgstr "Last license"
552
+
553
+ #: includes/i18n.php:164
554
+ msgid "What is your %s?"
555
+ msgstr "What is your %s?"
556
+
557
+ #: includes/i18n.php:165
558
+ msgid "Activate this add-on"
559
+ msgstr "Activate this add-on"
560
+
561
+ #: includes/i18n.php:166
562
+ msgid "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?"
563
+ msgstr "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?"
564
+
565
+ #: includes/i18n.php:167
566
+ msgid "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?"
567
+ msgstr "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?"
568
+
569
+ #: includes/i18n.php:168
570
+ msgid "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?"
571
+ msgstr "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?"
572
+
573
+ #: includes/i18n.php:169
574
+ msgid "Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s."
575
+ msgstr "Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s."
576
+
577
+ #: includes/i18n.php:170
578
+ msgid "Cancelling the trial will immediately block access to all premium features. Are you sure?"
579
+ msgstr "Cancelling the trial will immediately block access to all premium features. Are you sure?"
580
+
581
+ #: includes/i18n.php:171
582
+ msgid "You can still enjoy all %s features but you will not have access to plugin updates and support."
583
+ msgstr "You can still enjoy all %s features but you will not have access to plugin updates and support."
584
+
585
+ #: includes/i18n.php:172
586
+ msgid "Once your license expires you can still use the Free version but you will NOT have access to the %s features."
587
+ msgstr "Once your license expires you can still use the Free version but you will NOT have access to the %s features."
588
+
589
+ #: includes/i18n.php:173
590
+ msgid "Are you sure you want to proceed?"
591
+ msgstr "Are you sure you want to proceed?"
592
+
593
+ #: includes/i18n.php:176
594
+ msgid "Add Ons for %s"
595
+ msgstr "Add Ons for %s"
596
+
597
+ #: includes/i18n.php:177
598
+ msgid "We could'nt load the add-ons list. It's probably an issue on our side, please try to come back in few minutes."
599
+ msgstr "We could'nt load the add-ons list. It's probably an issue on our side, please try to come back in few minutes."
600
+
601
+ #: includes/i18n.php:179
602
+ msgid "Anonymous feedback"
603
+ msgstr "Anonymous feedback"
604
+
605
+ #: includes/i18n.php:180
606
+ msgid "Quick feedback"
607
+ msgstr "Quick feedback"
608
+
609
+ #: includes/i18n.php:181
610
+ msgid "If you have a moment, please let us know why you are deactivating"
611
+ msgstr "If you have a moment, please let us know why you are deactivating"
612
+
613
+ #: includes/i18n.php:182
614
+ msgid "Yes - Deactivate"
615
+ msgstr "Yes - Deactivate"
616
+
617
+ #: includes/i18n.php:183
618
+ msgid "Submit & Deactivate"
619
+ msgstr "Submit & Deactivate"
620
+
621
+ #: includes/i18n.php:184
622
+ msgid "Cancel"
623
+ msgstr "Cancel"
624
+
625
+ #: includes/i18n.php:185
626
+ msgid "I no longer need the plugin"
627
+ msgstr "I no longer need the plugin"
628
+
629
+ #: includes/i18n.php:186
630
+ msgid "I found a better plugin"
631
+ msgstr "I found a better plugin"
632
+
633
+ #: includes/i18n.php:187
634
+ msgid "I only needed the plugin for a short period"
635
+ msgstr "I only needed the plugin for a short period"
636
+
637
+ #: includes/i18n.php:188
638
+ msgid "The plugin broke my site"
639
+ msgstr "The plugin broke my site"
640
+
641
+ #: includes/i18n.php:189
642
+ msgid "The plugin suddenly stopped working"
643
+ msgstr "The plugin suddenly stopped working"
644
+
645
+ #: includes/i18n.php:190
646
+ msgid "I can't pay for it anymore"
647
+ msgstr "I can't pay for it anymore"
648
+
649
+ #: includes/i18n.php:191
650
+ msgid "It's a temporary deactivation. I'm just debugging an issue."
651
+ msgstr "It's a temporary deactivation. I'm just debugging an issue."
652
+
653
+ #: includes/i18n.php:192
654
+ msgctxt "the text of the \"other\" reason for deactivating the plugin that is shown in the modal box."
655
+ msgid "Other"
656
+ msgstr "Other"
657
+
658
+ #: includes/i18n.php:194
659
+ msgid "Kindly tell us the reason so we can improve."
660
+ msgstr "Kindly tell us the reason so we can improve."
661
+
662
+ #: includes/i18n.php:195
663
+ msgid "What's the plugin's name?"
664
+ msgstr "What's the plugin's name?"
665
+
666
+ #: includes/i18n.php:196
667
+ msgid "What price would you feel comfortable paying?"
668
+ msgstr "What price would you feel comfortable paying?"
669
+
670
+ #: includes/i18n.php:197
671
+ msgid "I couldn't understand how to make it work"
672
+ msgstr "I couldn't understand how to make it work"
673
+
674
+ #: includes/i18n.php:198
675
+ msgid "The plugin is great, but I need specific feature that you don't support"
676
+ msgstr "The plugin is great, but I need specific feature that you don't support"
677
+
678
+ #: includes/i18n.php:199
679
+ msgid "The plugin is not working"
680
+ msgstr "The plugin is not working"
681
+
682
+ #: includes/i18n.php:200
683
+ msgid "It's not what I was looking for"
684
+ msgstr "It's not what I was looking for"
685
+
686
+ #: includes/i18n.php:201
687
+ msgid "The plugin didn't work as expected"
688
+ msgstr "The plugin didn't work as expected"
689
+
690
+ #: includes/i18n.php:202
691
+ msgid "What feature?"
692
+ msgstr "What feature?"
693
+
694
+ #: includes/i18n.php:203
695
+ msgid "Kindly share what didn't work so we can fix it for future users..."
696
+ msgstr "Kindly share what didn't work so we can fix it for future users..."
697
+
698
+ #: includes/i18n.php:204
699
+ msgid "What you've been looking for?"
700
+ msgstr "What you've been looking for?"
701
+
702
+ #: includes/i18n.php:205
703
+ msgid "What did you expect?"
704
+ msgstr "What did you expect?"
705
+
706
+ #: includes/i18n.php:206
707
+ msgid "The plugin didn't work"
708
+ msgstr "The plugin didn't work"
709
+
710
+ #: includes/i18n.php:207
711
+ msgid "I don't like to share my information with you"
712
+ msgstr "I don't like to share my information with you"
713
+
714
+ #: includes/i18n.php:208
715
+ msgid "You might have missed it, but you don't have to share any data and can just %s the opt-in."
716
+ msgstr "You might have missed it, but you don't have to share any data and can just %s the opt-in."
717
+
718
+ #: includes/i18n.php:212
719
+ msgctxt "greeting"
720
+ msgid "Hey %s,"
721
+ msgstr "Hey %s,"
722
+
723
+ #: includes/i18n.php:213
724
+ msgctxt "a greeting. E.g. Thanks John!"
725
+ msgid "Thanks %s!"
726
+ msgstr "Thanks %s!"
727
+
728
+ #: includes/i18n.php:214
729
+ msgid "Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s."
730
+ msgstr "Never miss an important update - opt-in to our security and feature updates notifications, and non-sensitive diagnostic tracking with %4$s."
731
+
732
+ #: includes/i18n.php:215
733
+ msgid "Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that's okay! %1$s will still work just fine."
734
+ msgstr "Please help us improve %1$s! If you opt-in, some data about your usage of %1$s will be sent to %4$s. If you skip this, that's okay! %1$s will still work just fine."
735
+
736
+ #: includes/i18n.php:216
737
+ msgid "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 %s."
738
+ msgstr "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 %s."
739
+
740
+ #: includes/i18n.php:217
741
+ msgid "complete the install"
742
+ msgstr "complete the install"
743
+
744
+ #: includes/i18n.php:218
745
+ msgid "start the trial"
746
+ msgstr "start the trial"
747
+
748
+ #: includes/i18n.php:219
749
+ msgid "Thanks for purchasing %s! To get started, please enter your license key:"
750
+ msgstr "Thanks for purchasing %s! To get started, please enter your license key:"
751
+
752
+ #: includes/i18n.php:220
753
+ msgid "The plugin will be periodically sending data to %s to check for plugin updates and verify the validity of your license."
754
+ msgstr "The plugin will be periodically sending data to %s to check for plugin updates and verify the validity of your license."
755
+
756
+ #: includes/i18n.php:221
757
+ msgid "What permissions are being granted?"
758
+ msgstr "What permissions are being granted?"
759
+
760
+ #: includes/i18n.php:222
761
+ msgid "Your Profile Overview"
762
+ msgstr "Your Profile Overview"
763
+
764
+ #: includes/i18n.php:223
765
+ msgid "Name and email address"
766
+ msgstr "Name and email address"
767
+
768
+ #: includes/i18n.php:224
769
+ msgid "Your Site Overview"
770
+ msgstr "Your Site Overview"
771
+
772
+ #: includes/i18n.php:225
773
+ msgid "Site URL, WP version, PHP info, plugins & themes"
774
+ msgstr "Site URL, WP version, PHP info, plugins & themes"
775
+
776
+ #: includes/i18n.php:226
777
+ msgid "Current Plugin Events"
778
+ msgstr "Current Plugin Events"
779
+
780
+ #: includes/i18n.php:227
781
+ msgid "Activation, deactivation and uninstall"
782
+ msgstr "Activation, deactivation and uninstall"
783
+
784
+ #: includes/i18n.php:228
785
+ msgid "Plugins & Themes"
786
+ msgstr "Plugins & Themes"
787
+
788
+ #: includes/i18n.php:229
789
+ msgid "Titles, versions and state."
790
+ msgstr "Titles, versions and state."
791
+
792
+ #: includes/i18n.php:230
793
+ msgid "Admin Notices"
794
+ msgstr "Admin Notices"
795
+
796
+ #: includes/i18n.php:231
797
+ msgid "Newsletter"
798
+ msgstr "Newsletter"
799
+
800
+ #: includes/i18n.php:232
801
+ msgid "Updates, announcements, marketing, no spam"
802
+ msgstr "Updates, announcements, marketing, no spam"
803
+
804
+ #: includes/i18n.php:233
805
+ msgid "Privacy Policy"
806
+ msgstr "Privacy Policy"
807
+
808
+ #: includes/i18n.php:234
809
+ msgid "Terms of Service"
810
+ msgstr "Terms of Service"
811
+
812
+ #: includes/i18n.php:235
813
+ msgctxt "as activating plugin"
814
+ msgid "Activating"
815
+ msgstr "Activating"
816
+
817
+ #: includes/i18n.php:236
818
+ msgctxt "as in the process of sending an email"
819
+ msgid "Sending email"
820
+ msgstr "Sending email"
821
+
822
+ #: includes/i18n.php:237
823
+ msgctxt "button label"
824
+ msgid "Allow & Continue"
825
+ msgstr "Allow & Continue"
826
+
827
+ #: includes/i18n.php:238
828
+ msgctxt "button label"
829
+ msgid "Agree & Activate License"
830
+ msgstr "Agree & Activate License"
831
+
832
+ #: includes/i18n.php:239
833
+ msgctxt "verb"
834
+ msgid "Skip"
835
+ msgstr "Skip"
836
+
837
+ #: includes/i18n.php:240
838
+ msgid "Click here to use the plugin anonymously"
839
+ msgstr "Click here to use the plugin anonymously"
840
+
841
+ #: includes/i18n.php:241
842
+ msgid "Re-send activation email"
843
+ msgstr "Re-send activation email"
844
+
845
+ #: includes/i18n.php:242
846
+ msgid "License key"
847
+ msgstr "License key"
848
+
849
+ #: includes/i18n.php:243
850
+ msgid "Send License Key"
851
+ msgstr "Send License Key"
852
+
853
+ #: includes/i18n.php:244
854
+ msgid "Sending license key"
855
+ msgstr "Sending license key"
856
+
857
+ #: includes/i18n.php:245
858
+ msgid "Have a license key?"
859
+ msgstr "Have a license key?"
860
+
861
+ #: includes/i18n.php:246
862
+ msgid "Don't have a license key?"
863
+ msgstr "Don't have a license key?"
864
+
865
+ #: includes/i18n.php:247
866
+ msgid "Can't find your license key?"
867
+ msgstr "Can't find your license key?"
868
+
869
+ #: includes/i18n.php:248
870
+ msgid "We couldn't find your email address in the system, are you sure it's the right address?"
871
+ msgstr "We couldn't find your email address in the system, are you sure it's the right address?"
872
+
873
+ #: includes/i18n.php:249
874
+ msgid "We can't see any active licenses associated with that email address, are you sure it's the right address?"
875
+ msgstr "We can't see any active licenses associated with that email address, are you sure it's the right address?"
876
+
877
+ #: includes/i18n.php:250
878
+ msgid "Opt In"
879
+ msgstr "Opt In"
880
+
881
+ #: includes/i18n.php:251
882
+ msgid "Opt Out"
883
+ msgstr "Opt Out"
884
+
885
+ #: includes/i18n.php:252
886
+ msgid "On second thought - I want to continue helping"
887
+ msgstr "On second thought - I want to continue helping"
888
+
889
+ #: includes/i18n.php:253
890
+ msgid "Opting out..."
891
+ msgstr "Opting out..."
892
+
893
+ #: includes/i18n.php:254
894
+ msgid "Opting in..."
895
+ msgstr "Opting in..."
896
+
897
+ #: includes/i18n.php:255
898
+ msgid "We appreciate your help in making the %s better by letting us track some usage data."
899
+ msgstr "We appreciate your help in making the %s better by letting us track some usage data."
900
+
901
+ #: includes/i18n.php:256
902
+ msgid "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking."
903
+ msgstr "Usage tracking is done in the name of making %s better. Making a better user experience, prioritizing new features, and more good things. We'd really appreciate if you'll reconsider letting us continue with the tracking."
904
+
905
+ #: includes/i18n.php:257
906
+ msgid "By clicking \"Opt Out\", we will no longer be sending any data from %s to %s."
907
+ msgstr "By clicking \"Opt Out\", we will no longer be sending any data from %s to %s."
908
+
909
+ #: includes/i18n.php:261
910
+ msgid "Screenshots"
911
+ msgstr "Screenshots"
912
+
913
+ #: includes/i18n.php:262
914
+ msgid "Click to view full-size screenshot %d"
915
+ msgstr "Click to view full-size screenshot %d"
916
+
917
+ #: includes/i18n.php:266
918
+ msgid "Freemius Debug"
919
+ msgstr "Freemius Debug"
920
+
921
+ #: includes/i18n.php:267
922
+ msgctxt "as turned on"
923
+ msgid "On"
924
+ msgstr "On"
925
+
926
+ #: includes/i18n.php:268
927
+ msgctxt "as turned off"
928
+ msgid "Off"
929
+ msgstr "Off"
930
+
931
+ #: includes/i18n.php:269
932
+ msgctxt "as code debugging"
933
+ msgid "Debugging"
934
+ msgstr "Debugging"
935
+
936
+ #: includes/i18n.php:270
937
+ msgid "Freemius State"
938
+ msgstr "Freemius State"
939
+
940
+ #: includes/i18n.php:271
941
+ msgctxt "as connection was successful"
942
+ msgid "Connected"
943
+ msgstr "Connected"
944
+
945
+ #: includes/i18n.php:272
946
+ msgctxt "as connection blocked"
947
+ msgid "Blocked"
948
+ msgstr "Blocked"
949
+
950
+ #: includes/i18n.php:273
951
+ msgctxt "as application program interface"
952
+ msgid "API"
953
+ msgstr "API"
954
+
955
+ #: includes/i18n.php:274
956
+ msgctxt "as software development kit versions"
957
+ msgid "SDK"
958
+ msgstr "SDK"
959
+
960
+ #: includes/i18n.php:275
961
+ msgctxt "as software development kit versions"
962
+ msgid "SDK Versions"
963
+ msgstr "SDK Versions"
964
+
965
+ #: includes/i18n.php:276
966
+ msgctxt "as plugin folder path"
967
+ msgid "Plugin Path"
968
+ msgstr "Plugin Path"
969
+
970
+ #: includes/i18n.php:277
971
+ msgctxt "as sdk path"
972
+ msgid "SDK Path"
973
+ msgstr "SDK Path"
974
+
975
+ #: includes/i18n.php:278
976
+ msgid "Add Ons of Plugin %s"
977
+ msgstr "Add Ons of Plugin %s"
978
+
979
+ #: includes/i18n.php:279
980
+ msgid "Are you sure you want to delete all Freemius data?"
981
+ msgstr "Are you sure you want to delete all Freemius data?"
982
+
983
+ #: includes/i18n.php:280
984
+ msgid "Actions"
985
+ msgstr "Actions"
986
+
987
+ #: includes/i18n.php:281
988
+ msgid "Delete All Accounts"
989
+ msgstr "Delete All Accounts"
990
+
991
+ #: includes/i18n.php:282
992
+ msgid "Start Fresh"
993
+ msgstr "Start Fresh"
994
+
995
+ #: includes/i18n.php:283
996
+ msgid "Clear API Cache"
997
+ msgstr "Clear API Cache"
998
+
999
+ #: includes/i18n.php:284
1000
+ msgid "Sync Data From Server"
1001
+ msgstr "Sync Data From Server"
1002
+
1003
+ #: includes/i18n.php:285
1004
+ msgid "Scheduled Crons"
1005
+ msgstr "Scheduled Crons"
1006
+
1007
+ #: includes/i18n.php:286
1008
+ msgid "Cron Type"
1009
+ msgstr "Cron Type"
1010
+
1011
+ #: includes/i18n.php:287
1012
+ msgid "Plugins & Themes Sync"
1013
+ msgstr "Plugins & Themes Sync"
1014
+
1015
+ #: includes/i18n.php:288
1016
+ msgid "Licenses"
1017
+ msgstr "Licenses"
1018
+
1019
+ #: includes/i18n.php:289
1020
+ msgid "Debug Log"
1021
+ msgstr "Debug Log"
1022
+
1023
+ #: includes/i18n.php:290
1024
+ msgid "All"
1025
+ msgstr "All"
1026
+
1027
+ #: includes/i18n.php:291
1028
+ msgid "File"
1029
+ msgstr "File"
1030
+
1031
+ #: includes/i18n.php:292
1032
+ msgid "Function"
1033
+ msgstr "Function"
1034
+
1035
+ #: includes/i18n.php:293
1036
+ msgid "Process ID"
1037
+ msgstr "Process ID"
1038
+
1039
+ #: includes/i18n.php:294
1040
+ msgid "Logger"
1041
+ msgstr "Logger"
1042
+
1043
+ #: includes/i18n.php:295
1044
+ msgid "Message"
1045
+ msgstr "Message"
1046
+
1047
+ #: includes/i18n.php:296
1048
+ msgid "Download"
1049
+ msgstr "Download"
1050
+
1051
+ #: includes/i18n.php:297
1052
+ msgid "Filter"
1053
+ msgstr "Filter"
1054
+
1055
+ #: includes/i18n.php:298
1056
+ msgid "Type"
1057
+ msgstr "Type"
1058
+
1059
+ #: includes/i18n.php:299
1060
+ msgid "All Types"
1061
+ msgstr "All Types"
1062
+
1063
+ #: includes/i18n.php:300
1064
+ msgid "All Requests"
1065
+ msgstr "All Requests"
1066
+
1067
+ #: includes/i18n.php:304
1068
+ msgctxt "as congratulations"
1069
+ msgid "Congrats"
1070
+ msgstr "Congrats"
1071
+
1072
+ #: includes/i18n.php:305
1073
+ msgctxt "exclamation"
1074
+ msgid "Oops"
1075
+ msgstr "Oops"
1076
+
1077
+ #: includes/i18n.php:306
1078
+ msgctxt "interjection expressing joy or exuberance"
1079
+ msgid "Yee-haw"
1080
+ msgstr "Yee-haw"
1081
+
1082
+ #: includes/i18n.php:307
1083
+ msgctxt "(especially in electronic communication) used to express elation, enthusiasm, or triumph."
1084
+ msgid "W00t"
1085
+ msgstr "W00t"
1086
+
1087
+ #: includes/i18n.php:309
1088
+ msgctxt "a positive response"
1089
+ msgid "Right on"
1090
+ msgstr "Right on"
1091
+
1092
+ #: includes/i18n.php:310
1093
+ msgctxt "something somebody says when they are thinking about what you have just said. "
1094
+ msgid "Hmm"
1095
+ msgstr "Hmm"
1096
+
1097
+ #: includes/i18n.php:312
1098
+ msgid "O.K"
1099
+ msgstr "O.K"
1100
+
1101
+ #: includes/i18n.php:313
1102
+ msgctxt "exclamation"
1103
+ msgid "Hey"
1104
+ msgstr "Hey"
1105
+
1106
+ #: includes/i18n.php:314
1107
+ msgctxt "advance notice of something that will need attention."
1108
+ msgid "Heads up"
1109
+ msgstr "Heads up"
1110
+
1111
+ #: includes/i18n.php:319
1112
+ msgid "Seems like you got the latest release."
1113
+ msgstr "Seems like you got the latest release."
1114
+
1115
+ #: includes/i18n.php:320
1116
+ msgid "You are all good!"
1117
+ msgstr "You are all good!"
1118
+
1119
+ #: includes/i18n.php:321
1120
+ msgid "Sorry, we could not complete the email update. Another user with the same email is already registered."
1121
+ msgstr "Sorry, we could not complete the email update. Another user with the same email is already registered."
1122
+
1123
+ #: includes/i18n.php:322
1124
+ msgid "If you would like to give up the ownership of the plugin's account to %s click the Change Ownership button."
1125
+ msgstr "If you would like to give up the ownership of the plugin's account to %s click the Change Ownership button."
1126
+
1127
+ #: includes/i18n.php:323
1128
+ msgid "Your email was successfully updated. You should receive an email with confirmation instructions in few moments."
1129
+ msgstr "Your email was successfully updated. You should receive an email with confirmation instructions in few moments."
1130
+
1131
+ #: includes/i18n.php:324
1132
+ msgid "Your name was successfully updated."
1133
+ msgstr "Your name was successfully updated."
1134
+
1135
+ #: includes/i18n.php:325
1136
+ msgid "You have successfully updated your %s."
1137
+ msgstr "You have successfully updated your %s."
1138
+
1139
+ #: includes/i18n.php:326
1140
+ msgid "Please provide your full name."
1141
+ msgstr "Please provide your full name."
1142
+
1143
+ #: includes/i18n.php:327
1144
+ msgid "Verification mail was just sent to %s. If you can't find it after 5 min, please check your spam box."
1145
+ msgstr "Verification mail was just sent to %s. If you can't find it after 5 min, please check your spam box."
1146
+
1147
+ #: includes/i18n.php:328
1148
+ msgid "Just letting you know that the add-ons information of %s is being pulled from an external server."
1149
+ msgstr "Just letting you know that the add-ons information of %s is being pulled from an external server."
1150
+
1151
+ #: includes/i18n.php:329
1152
+ msgid "No credit card required"
1153
+ msgstr "No credit card required"
1154
+
1155
+ #: includes/i18n.php:330
1156
+ msgid "Premium plugin version was successfully activated."
1157
+ msgstr "Premium plugin version was successfully activated."
1158
+
1159
+ #: includes/i18n.php:331
1160
+ msgid "The upgrade of %s was successfully completed."
1161
+ msgstr "The upgrade of %s was successfully completed."
1162
+
1163
+ #: includes/i18n.php:332
1164
+ msgid "Your account was successfully activated with the %s plan."
1165
+ msgstr "Your account was successfully activated with the %s plan."
1166
+
1167
+ #: includes/i18n.php:333
1168
+ msgid "Download the latest %s version now"
1169
+ msgstr "Download the latest %s version now"
1170
+
1171
+ #: includes/i18n.php:334
1172
+ msgid "Please follow these steps to complete the upgrade"
1173
+ msgstr "Please follow these steps to complete the upgrade"
1174
+
1175
+ #: includes/i18n.php:335
1176
+ msgid "Download the latest %s version"
1177
+ msgstr "Download the latest %s version"
1178
+
1179
+ #: includes/i18n.php:336
1180
+ msgid "Download the latest version"
1181
+ msgstr "Download the latest version"
1182
+
1183
+ #: includes/i18n.php:337
1184
+ msgid "Deactivate the free version"
1185
+ msgstr "Deactivate the free version"
1186
+
1187
+ #: includes/i18n.php:338
1188
+ msgid "Upload and activate the downloaded version"
1189
+ msgstr "Upload and activate the downloaded version"
1190
+
1191
+ #: includes/i18n.php:339
1192
+ msgid "How to upload and activate?"
1193
+ msgstr "How to upload and activate?"
1194
+
1195
+ #: includes/i18n.php:340
1196
+ msgctxt "%s - product name, e.g. Facebook add-on was successfully..."
1197
+ msgid "%s Add-on was successfully purchased."
1198
+ msgstr "%s Add-on was successfully purchased."
1199
+
1200
+ #: includes/i18n.php:342
1201
+ msgid "Your %s Add-on plan was successfully upgraded."
1202
+ msgstr "Your %s Add-on plan was successfully upgraded."
1203
+
1204
+ #: includes/i18n.php:343
1205
+ msgid "Your email has been successfully verified - you are AWESOME!"
1206
+ msgstr "Your email has been successfully verified - you are AWESOME!"
1207
+
1208
+ #: includes/i18n.php:344
1209
+ msgid "Your plan was successfully upgraded."
1210
+ msgstr "Your plan was successfully upgraded."
1211
+
1212
+ #: includes/i18n.php:345
1213
+ msgid "Your plan was successfully changed to %s."
1214
+ msgstr "Your plan was successfully changed to %s."
1215
+
1216
+ #: includes/i18n.php:346
1217
+ msgid "Your license has expired. You can still continue using the free plugin forever."
1218
+ msgstr "Your license has expired. You can still continue using the free plugin forever."
1219
+
1220
+ #: includes/i18n.php:347
1221
+ msgid "Your license has been cancelled. If you think it's a mistake, please contact support."
1222
+ msgstr "Your license has been cancelled. If you think it's a mistake, please contact support."
1223
+
1224
+ #: includes/i18n.php:348
1225
+ msgid "Your trial has been successfully started."
1226
+ msgstr "Your trial has been successfully started."
1227
+
1228
+ #: includes/i18n.php:349
1229
+ msgid "Your license was successfully activated."
1230
+ msgstr "Your license was successfully activated."
1231
+
1232
+ #: includes/i18n.php:350
1233
+ msgid "It looks like your site currently doesn't have an active license."
1234
+ msgstr "It looks like your site currently doesn't have an active license."
1235
+
1236
+ #: includes/i18n.php:351
1237
+ msgid "Your license was successfully deactivated, you are back to the %s plan."
1238
+ msgstr "Your license was successfully deactivated, you are back to the %s plan."
1239
+
1240
+ #: includes/i18n.php:352
1241
+ msgid "It looks like the license deactivation failed."
1242
+ msgstr "It looks like the license deactivation failed."
1243
+
1244
+ #: includes/i18n.php:353
1245
+ msgid "It looks like the license could not be activated."
1246
+ msgstr "It looks like the license could not be activated."
1247
+
1248
+ #: includes/i18n.php:354
1249
+ msgid "Error received from the server:"
1250
+ msgstr "Error received from the server:"
1251
+
1252
+ #: includes/i18n.php:355
1253
+ msgid "Your trial has expired. You can still continue using all our free features."
1254
+ msgstr "Your trial has expired. You can still continue using all our free features."
1255
+
1256
+ #: includes/i18n.php:356
1257
+ msgid "Your plan was successfully downgraded. Your %s plan license will expire in %s."
1258
+ msgstr "Your plan was successfully downgraded. Your %s plan license will expire in %s."
1259
+
1260
+ #: includes/i18n.php:357
1261
+ msgid "Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes."
1262
+ msgstr "Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes."
1263
+
1264
+ #: includes/i18n.php:358
1265
+ msgid "It looks like you are not in trial mode anymore so there's nothing to cancel :)"
1266
+ msgstr "It looks like you are not in trial mode anymore so there's nothing to cancel :)"
1267
+
1268
+ #: includes/i18n.php:359
1269
+ msgid "Your %s free trial was successfully cancelled."
1270
+ msgstr "Your %s free trial was successfully cancelled."
1271
+
1272
+ #: includes/i18n.php:360
1273
+ msgctxt "%s - numeric version number"
1274
+ msgid "Version %s was released."
1275
+ msgstr "Version %s was released."
1276
+
1277
+ #: includes/i18n.php:361
1278
+ msgid "Please download %s."
1279
+ msgstr "Please download %s."
1280
+
1281
+ #: includes/i18n.php:362
1282
+ msgctxt "%s - plan name, as the latest professional version here"
1283
+ msgid "the latest %s version here"
1284
+ msgstr "the latest %s version here"
1285
+
1286
+ #: includes/i18n.php:364
1287
+ msgid "How do you like %s so far? Test all our %s premium features with a %d-day free trial."
1288
+ msgstr "How do you like %s so far? Test all our %s premium features with a %d-day free trial."
1289
+
1290
+ #: includes/i18n.php:365
1291
+ msgctxt "call to action"
1292
+ msgid "Start free trial"
1293
+ msgstr "Start free trial"
1294
+
1295
+ #: includes/i18n.php:366
1296
+ msgid "Starting trial"
1297
+ msgstr "Starting trial"
1298
+
1299
+ #: includes/i18n.php:367
1300
+ msgid "Please wait"
1301
+ msgstr "Please wait"
1302
+
1303
+ #: includes/i18n.php:368
1304
+ msgid "Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes."
1305
+ msgstr "Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes."
1306
+
1307
+ #: includes/i18n.php:369
1308
+ msgid "You already utilized a trial before."
1309
+ msgstr "You already utilized a trial before."
1310
+
1311
+ #: includes/i18n.php:370
1312
+ msgid "You are already running the plugin in a trial mode."
1313
+ msgstr "You are already running the plugin in a trial mode."
1314
+
1315
+ #: includes/i18n.php:371
1316
+ msgid "Plan %s do not exist, therefore, can't start a trial."
1317
+ msgstr "Plan %s do not exist, therefore, can't start a trial."
1318
+
1319
+ #: includes/i18n.php:372
1320
+ msgid "Plan %s does not support a trial period."
1321
+ msgstr "Plan %s does not support a trial period."
1322
+
1323
+ #: includes/i18n.php:373
1324
+ msgid "None of the plugin's plans supports a trial period."
1325
+ msgstr "None of the plugin's plans supports a trial period."
1326
+
1327
+ #: includes/i18n.php:374
1328
+ msgid "Unexpected API error. Please contact the plugin's author with the following error."
1329
+ msgstr "Unexpected API error. Please contact the plugin's author with the following error."
1330
+
1331
+ #: includes/i18n.php:375
1332
+ msgid "No commitment for %s days - cancel anytime!"
1333
+ msgstr "No commitment for %s days - cancel anytime!"
1334
+
1335
+ #: includes/i18n.php:376
1336
+ msgid "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."
1337
+ msgstr "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."
1338
+
1339
+ #: includes/i18n.php:377
1340
+ msgid "Couldn't activate %s."
1341
+ msgstr "Couldn't activate %s."
1342
+
1343
+ #: includes/i18n.php:378
1344
+ msgid "Please contact us with the following message:"
1345
+ msgstr "Please contact us with the following message:"
1346
+
1347
+ #: includes/i18n.php:379
1348
+ msgid "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."
1349
+ msgstr "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."
1350
+
1351
+ #: includes/i18n.php:380
1352
+ msgid "Please contact us here"
1353
+ msgstr "Please contact us here"
1354
+
1355
+ #: includes/i18n.php:381
1356
+ msgid "I have upgraded my account but when I try to Sync the License, the plan remains %s."
1357
+ msgstr "I have upgraded my account but when I try to Sync the License, the plan remains %s."
1358
+
1359
+ #: includes/i18n.php:384
1360
+ msgid "From unknown reason, the API connectivity test failed."
1361
+ msgstr "From unknown reason, the API connectivity test failed."
1362
+
1363
+ #: includes/i18n.php:385
1364
+ msgid "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?"
1365
+ msgstr "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?"
1366
+
1367
+ #: includes/i18n.php:386
1368
+ msgid "We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server."
1369
+ msgstr "We use PHP cURL library for the API calls, which is a very common library and usually installed and activated out of the box. Unfortunately, cURL is not activated (or disabled) on your server."
1370
+
1371
+ #: includes/i18n.php:387
1372
+ msgid "Disabled method(s):"
1373
+ msgstr "Disabled method(s):"
1374
+
1375
+ #: includes/i18n.php:388
1376
+ msgid "From unknown reason, CloudFlare, the firewall we use, blocks the connection."
1377
+ msgstr "From unknown reason, CloudFlare, the firewall we use, blocks the connection."
1378
+
1379
+ #: includes/i18n.php:389
1380
+ msgctxt "as pluginX requires an access to our API"
1381
+ msgid "%s requires an access to our API."
1382
+ msgstr "%s requires an access to our API."
1383
+
1384
+ #: includes/i18n.php:391
1385
+ msgid "It looks like your server is using Squid ACL (access control lists), which blocks the connection."
1386
+ msgstr "It looks like your server is using Squid ACL (access control lists), which blocks the connection."
1387
+
1388
+ #: includes/i18n.php:392
1389
+ msgid "I don't know what is Squid or ACL, help me!"
1390
+ msgstr "I don't know what is Squid or ACL, help me!"
1391
+
1392
+ #: includes/i18n.php:393, includes/i18n.php:397
1393
+ msgid "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."
1394
+ msgstr "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."
1395
+
1396
+ #: includes/i18n.php:394
1397
+ msgid "I'm a system administrator"
1398
+ msgstr "I'm a system administrator"
1399
+
1400
+ #: includes/i18n.php:395
1401
+ msgid "Great, please whitelist the following domains: %s. Once you are done, deactivate the plugin and activate it again."
1402
+ msgstr "Great, please whitelist the following domains: %s. Once you are done, deactivate the plugin and activate it again."
1403
+
1404
+ #: includes/i18n.php:396
1405
+ msgid "I don't know what is cURL or how to install it, help me!"
1406
+ msgstr "I don't know what is cURL or how to install it, help me!"
1407
+
1408
+ #: includes/i18n.php:398
1409
+ msgid "Great, please install cURL and enable it in your php.ini file. In addition, search for the 'disable_functions' directive in your php.ini file and remove any disabled methods starting with 'curl_'. To make sure it was successfully activated, use 'phpinfo()'. Once activated, deactivate the plugin and reactivate it back again."
1410
+ msgstr "Great, please install cURL and enable it in your php.ini file. In addition, search for the 'disable_functions' directive in your php.ini file and remove any disabled methods starting with 'curl_'. To make sure it was successfully activated, use 'phpinfo()'. Once activated, deactivate the plugin and reactivate it back again."
1411
+
1412
+ #: includes/i18n.php:399
1413
+ msgid "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."
1414
+ msgstr "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."
1415
+
1416
+ #: includes/i18n.php:400
1417
+ msgid "Sorry for the inconvenience and we are here to help if you give us a chance."
1418
+ msgstr "Sorry for the inconvenience and we are here to help if you give us a chance."
1419
+
1420
+ #: includes/i18n.php:401
1421
+ msgid "Yes - I'm giving you a chance to fix it"
1422
+ msgstr "Yes - I'm giving you a chance to fix it"
1423
+
1424
+ #: includes/i18n.php:402
1425
+ msgid "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."
1426
+ msgstr "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."
1427
+
1428
+ #: includes/i18n.php:403
1429
+ msgid "Let's try your previous version"
1430
+ msgstr "Let's try your previous version"
1431
+
1432
+ #: includes/i18n.php:404
1433
+ msgid "Uninstall this version and install the previous one."
1434
+ msgstr "Uninstall this version and install the previous one."
1435
+
1436
+ #: includes/i18n.php:405
1437
+ msgid "That's exhausting, please deactivate"
1438
+ msgstr "That's exhausting, please deactivate"
1439
+
1440
+ #: includes/i18n.php:406
1441
+ msgid "We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future."
1442
+ msgstr "We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future."
1443
+
1444
+ #: includes/i18n.php:407
1445
+ msgid "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."
1446
+ msgstr "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."
1447
+
1448
+ #: includes/i18n.php:408
1449
+ msgctxt "%1s - plugin title, %2s - API domain"
1450
+ msgid "Your server is blocking the access to Freemius' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s"
1451
+ msgstr "Your server is blocking the access to Freemius' API, which is crucial for %1s synchronization. Please contact your host to whitelist %2s"
1452
+
1453
+ #: includes/i18n.php:410
1454
+ msgid "It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again."
1455
+ msgstr "It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again."
1456
+
1457
+ #: includes/i18n.php:413
1458
+ msgid "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."
1459
+ msgstr "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."
1460
+
1461
+ #: includes/i18n.php:414
1462
+ msgid "Thanks for confirming the ownership change. An email was just sent to %s for final approval."
1463
+ msgstr "Thanks for confirming the ownership change. An email was just sent to %s for final approval."
1464
+
1465
+ #: includes/i18n.php:415
1466
+ msgid "%s is the new owner of the account."
1467
+ msgstr "%s is the new owner of the account."
1468
+
1469
+ #: includes/i18n.php:417
1470
+ msgctxt "addonX cannot run without pluginY"
1471
+ msgid "%s cannot run without %s."
1472
+ msgstr "%s cannot run without %s."
1473
+
1474
+ #: includes/i18n.php:419
1475
+ msgctxt "addonX cannot run..."
1476
+ msgid "%s cannot run without the plugin."
1477
+ msgstr "%s cannot run without the plugin."
1478
+
1479
+ #: includes/i18n.php:420
1480
+ msgctxt "pluginX activation was successfully..."
1481
+ msgid "%s activation was successfully completed."
1482
+ msgstr "%s activation was successfully completed."
1483
+
1484
+ #: includes/i18n.php:422
1485
+ msgctxt "Plugin installer section title"
1486
+ msgid "Features & Pricing"
1487
+ msgstr "Features & Pricing"
1488
+
1489
+ #: includes/i18n.php:423
1490
+ msgid "Add-on must be deployed to WordPress.org or Freemius."
1491
+ msgstr "Add-on must be deployed to WordPress.org or Freemius."
1492
+
1493
+ #: includes/i18n.php:424
1494
+ msgid "Paid add-on must be deployed to Freemius."
1495
+ msgstr "Paid add-on must be deployed to Freemius."
1496
+
1497
+ #: includes/i18n.php:428
1498
+ msgid "%s is a premium only add-on. You have to purchase a license first before activating the plugin."
1499
+ msgstr "%s is a premium only add-on. You have to purchase a license first before activating the plugin."
1500
+
1501
+ #: includes/i18n.php:429
1502
+ msgid "%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."
1503
+ msgstr "%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."
1504
+
1505
+ #: includes/i18n.php:434
1506
+ msgctxt "as every month"
1507
+ msgid "Monthly"
1508
+ msgstr "Monthly"
1509
+
1510
+ #: includes/i18n.php:435
1511
+ msgctxt "as monthly period"
1512
+ msgid "mo"
1513
+ msgstr "mo"
1514
+
1515
+ #: includes/i18n.php:436
1516
+ msgctxt "as once a year"
1517
+ msgid "Annual"
1518
+ msgstr "Annual"
1519
+
1520
+ #: includes/i18n.php:437
1521
+ msgctxt "as once a year"
1522
+ msgid "Annually"
1523
+ msgstr "Annually"
1524
+
1525
+ #: includes/i18n.php:438
1526
+ msgctxt "as once a year"
1527
+ msgid "Once"
1528
+ msgstr "Once"
1529
+
1530
+ #: includes/i18n.php:439
1531
+ msgctxt "as annual period"
1532
+ msgid "year"
1533
+ msgstr "year"
1534
+
1535
+ #: includes/i18n.php:440
1536
+ msgid "Lifetime"
1537
+ msgstr "Lifetime"
1538
+
1539
+ #: includes/i18n.php:441
1540
+ msgctxt "e.g. the best product"
1541
+ msgid "Best"
1542
+ msgstr "Best"
1543
+
1544
+ #: includes/i18n.php:442
1545
+ msgctxt "e.g. billed monthly"
1546
+ msgid "Billed %s"
1547
+ msgstr "Billed %s"
1548
+
1549
+ #: includes/i18n.php:443
1550
+ msgctxt "as a discount of $5 or 10%"
1551
+ msgid "Save %s"
1552
+ msgstr "Save %s"
1553
+
1554
+ #: includes/i18n.php:445
1555
+ msgid "View details"
1556
+ msgstr "View details"
1557
+
1558
+ #: includes/i18n.php:449
1559
+ msgctxt "button label"
1560
+ msgid "Approve & Start Trial"
1561
+ msgstr "Approve & Start Trial"
1562
+
1563
+ #: includes/i18n.php:451
1564
+ msgid "You are 1-click away from starting your %1$s-day free trial of the %2$s plan."
1565
+ msgstr "You are 1-click away from starting your %1$s-day free trial of the %2$s plan."
1566
+
1567
+ #: includes/i18n.php:453
1568
+ msgid "For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt-in with your user and non-sensitive site information, allowing the plugin to periodically send data to %s to check for version updates and to validate your trial."
1569
+ msgstr "For compliance with the WordPress.org guidelines, before we start the trial we ask that you opt-in with your user and non-sensitive site information, allowing the plugin to periodically send data to %s to check for version updates and to validate your trial."
1570
+
1571
+ #: includes/i18n.php:459
1572
+ msgid "Business name"
1573
+ msgstr "Business name"
1574
+
1575
+ #: includes/i18n.php:460
1576
+ msgid "Tax / VAT ID"
1577
+ msgstr "Tax / VAT ID"
1578
+
1579
+ #: includes/i18n.php:461
1580
+ msgid "Address Line %d"
1581
+ msgstr "Address Line %d"
1582
+
1583
+ #: includes/i18n.php:462
1584
+ msgid "Country"
1585
+ msgstr "Country"
1586
+
1587
+ #: includes/i18n.php:463
1588
+ msgid "Select Country"
1589
+ msgstr "Select Country"
1590
+
1591
+ #: includes/i18n.php:464
1592
+ msgid "City"
1593
+ msgstr "City"
1594
+
1595
+ #: includes/i18n.php:465
1596
+ msgid "Town"
1597
+ msgstr "Town"
1598
+
1599
+ #: includes/i18n.php:466
1600
+ msgid "State"
1601
+ msgstr "State"
1602
+
1603
+ #: includes/i18n.php:467
1604
+ msgid "Province"
1605
+ msgstr "Province"
1606
+
1607
+ #: includes/i18n.php:468
1608
+ msgid "ZIP / Postal Code"
1609
+ msgstr "ZIP / Postal Code"
1610
+
1611
+ #: includes/i18n.php:473
1612
+ msgid "Installing plugin: %s"
1613
+ msgstr "Installing plugin: %s"
1614
+
1615
+ #: includes/i18n.php:474
1616
+ msgid "Automatic Installation"
1617
+ msgstr "Automatic Installation"
1618
+
1619
+ #: includes/i18n.php:476
1620
+ msgid "%s sec"
1621
+ msgstr "%s sec"
1622
+
1623
+ #: includes/i18n.php:477
1624
+ msgid "An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now."
1625
+ msgstr "An automated download and installation of %s (paid version) from %s will start in %s. If you would like to do it manually - click the cancellation button now."
1626
+
1627
+ #: includes/i18n.php:478
1628
+ msgid "The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page."
1629
+ msgstr "The installation process has started and may take a few minutes to complete. Please wait until it is done - do not refresh this page."
1630
+
1631
+ #: includes/i18n.php:479
1632
+ msgid "Cancel Installation"
1633
+ msgstr "Cancel Installation"
1634
+
1635
+ #: includes/i18n.php:480
1636
+ msgid "The remote plugin package does not contain a folder with the desired slug and renaming did not work."
1637
+ msgstr "The remote plugin package does not contain a folder with the desired slug and renaming did not work."
1638
+
1639
+ #: includes/i18n.php:481
1640
+ msgid "Invalid module ID."
1641
+ msgstr "Invalid module ID."
1642
+
1643
+ #: includes/i18n.php:482
1644
+ msgid "Auto installation only works for opted-in users."
1645
+ msgstr "Auto installation only works for opted-in users."
1646
+
1647
+ #: includes/i18n.php:483
1648
+ msgid "Premium version already active."
1649
+ msgstr "Premium version already active."
1650
+
1651
+ #: includes/i18n.php:484
1652
+ msgid "Premium add-on version already installed."
1653
+ msgstr "Premium add-on version already installed."
1654
+
1655
+ #: includes/i18n.php:485
1656
+ msgid "You do not have a valid license to access the premium version."
1657
+ msgstr "You do not have a valid license to access the premium version."
1658
+
1659
+ #: includes/i18n.php:486
1660
+ msgid "Plugin is a \"Serviceware\" which means it does not have a premium code version."
1661
+ msgstr "Plugin is a \"Serviceware\" which means it does not have a premium code version."
1662
+
1663
+ #: includes/i18n.php:501
1664
+ msgctxt "Plugin installer section title"
1665
+ msgid "Description"
1666
+ msgstr "Description"
1667
+
1668
+ #: includes/i18n.php:502
1669
+ msgctxt "Plugin installer section title"
1670
+ msgid "Installation"
1671
+ msgstr "Installation"
1672
+
1673
+ #: includes/i18n.php:503
1674
+ msgctxt "Plugin installer section title"
1675
+ msgid "FAQ"
1676
+ msgstr "FAQ"
1677
+
1678
+ #: includes/i18n.php:504
1679
+ msgctxt "Plugin installer section title"
1680
+ msgid "Changelog"
1681
+ msgstr "Changelog"
1682
+
1683
+ #: includes/i18n.php:505
1684
+ msgctxt "Plugin installer section title"
1685
+ msgid "Reviews"
1686
+ msgstr "Reviews"
1687
+
1688
+ #: includes/i18n.php:506
1689
+ msgctxt "Plugin installer section title"
1690
+ msgid "Other Notes"
1691
+ msgstr "Other Notes"
1692
+
1693
+ #: includes/i18n.php:508
1694
+ msgid "%s star"
1695
+ msgstr "%s star"
1696
+
1697
+ #: includes/i18n.php:510
1698
+ msgid "%s stars"
1699
+ msgstr "%s