Image Widget - Version 4.2.1

Version Description

  • Feature - Removing Freemius. Interesting experiment, but ultimately, not our cup of tea. Thanks for sticking with us!
Download this release

Release Info

Developer zbtirrell
Plugin Icon 128x128 Image Widget
Version 4.2.1
Comparing to
See all releases

Code changes from version 4.2 to 4.2.1

Files changed (89) hide show
  1. freemius/LICENSE.txt +0 -340
  2. freemius/assets/css/admin/account.css +0 -1
  3. freemius/assets/css/admin/add-ons.css +0 -2
  4. freemius/assets/css/admin/common.css +0 -1
  5. freemius/assets/css/admin/connect.css +0 -1
  6. freemius/assets/css/admin/deactivation-feedback.css +0 -1
  7. freemius/assets/css/common.css +0 -1
  8. freemius/assets/img/icon.jpg +0 -0
  9. freemius/assets/img/plugin-icon.png +0 -0
  10. freemius/assets/js/jquery.ba-postmessage.js +0 -222
  11. freemius/assets/js/jquery.ba-postmessage.min.js +0 -9
  12. freemius/assets/js/nojquery.ba-postmessage.js +0 -140
  13. freemius/assets/js/nojquery.ba-postmessage.min.js +0 -12
  14. freemius/assets/js/postmessage.js +0 -110
  15. freemius/assets/scss/_colors.scss +0 -58
  16. freemius/assets/scss/_functions.scss +0 -0
  17. freemius/assets/scss/_load.scss +0 -4
  18. freemius/assets/scss/_mixins.scss +0 -224
  19. freemius/assets/scss/_start.scss +0 -4
  20. freemius/assets/scss/_vars.scss +0 -5
  21. freemius/assets/scss/admin/account.scss +0 -122
  22. freemius/assets/scss/admin/add-ons.scss +0 -319
  23. freemius/assets/scss/admin/common.scss +0 -109
  24. freemius/assets/scss/admin/connect.scss +0 -263
  25. freemius/assets/scss/admin/deactivation-feedback.scss +0 -120
  26. freemius/config.php +0 -160
  27. freemius/includes/class-freemius-abstract.php +0 -382
  28. freemius/includes/class-freemius.php +0 -7527
  29. freemius/includes/class-fs-api.php +0 -350
  30. freemius/includes/class-fs-logger.php +0 -168
  31. freemius/includes/class-fs-plugin-updater.php +0 -253
  32. freemius/includes/class-fs-security.php +0 -61
  33. freemius/includes/entities/class-fs-entity.php +0 -149
  34. freemius/includes/entities/class-fs-plugin-info.php +0 -34
  35. freemius/includes/entities/class-fs-plugin-license.php +0 -160
  36. freemius/includes/entities/class-fs-plugin-plan.php +0 -71
  37. freemius/includes/entities/class-fs-plugin-tag.php +0 -24
  38. freemius/includes/entities/class-fs-plugin.php +0 -90
  39. freemius/includes/entities/class-fs-scope-entity.php +0 -29
  40. freemius/includes/entities/class-fs-site.php +0 -119
  41. freemius/includes/entities/class-fs-subscription.php +0 -117
  42. freemius/includes/entities/class-fs-user.php +0 -62
  43. freemius/includes/fs-core-functions.php +0 -461
  44. freemius/includes/fs-plugin-functions.php +0 -411
  45. freemius/includes/i18n.php +0 -245
  46. freemius/includes/managers/class-fs-admin-menu-manager.php +0 -531
  47. freemius/includes/managers/class-fs-admin-notice-manager.php +0 -303
  48. freemius/includes/managers/class-fs-key-value-storage.php +0 -289
  49. freemius/includes/managers/class-fs-license-manager.php +0 -101
  50. freemius/includes/managers/class-fs-option-manager.php +0 -297
  51. freemius/includes/managers/class-fs-plan-manager.php +0 -147
  52. freemius/includes/managers/class-fs-plugin-manager.php +0 -154
  53. freemius/includes/sdk/Exceptions/ArgumentNotExistException.php +0 -2
  54. freemius/includes/sdk/Exceptions/EmptyArgumentException.php +0 -2
  55. freemius/includes/sdk/Exceptions/Exception.php +0 -75
  56. freemius/includes/sdk/Exceptions/InvalidArgumentException.php +0 -2
  57. freemius/includes/sdk/Exceptions/OAuthException.php +0 -8
  58. freemius/includes/sdk/Freemius.php +0 -403
  59. freemius/includes/sdk/FreemiusBase.php +0 -217
  60. freemius/includes/sdk/LICENSE.txt +0 -340
  61. freemius/start.php +0 -95
  62. freemius/templates/account.php +0 -442
  63. freemius/templates/add-ons.php +0 -113
  64. freemius/templates/admin-notice.php +0 -34
  65. freemius/templates/all-admin-notice.php +0 -31
  66. freemius/templates/checkout.php +0 -242
  67. freemius/templates/connect.php +0 -176
  68. freemius/templates/contact.php +0 -72
  69. freemius/templates/deactivation-feedback-modal.php +0 -196
  70. freemius/templates/debug.php +0 -103
  71. freemius/templates/email.php +0 -42
  72. freemius/templates/firewall-issues-js.php +0 -49
  73. freemius/templates/pending-activation.php +0 -146
  74. freemius/templates/plugin-icon.php +0 -58
  75. freemius/templates/plugin-info/description.php +0 -63
  76. freemius/templates/plugin-info/features.php +0 -81
  77. freemius/templates/plugin-info/screenshots.php +0 -19
  78. freemius/templates/powered-by.php +0 -37
  79. freemius/templates/pricing.php +0 -96
  80. freemius/templates/sticky-admin-notice-js.php +0 -36
  81. image-widget.php +2 -33
  82. index.php +0 -0
  83. lang/image_widget-da_DK.mo +0 -0
  84. lang/image_widget-da_DK.po +0 -146
  85. lib/index.php +0 -0
  86. readme.txt +5 -1
  87. resources/index.php +0 -0
  88. resources/js/index.php +0 -0
  89. views/index.php +0 -0
freemius/LICENSE.txt DELETED
@@ -1,340 +0,0 @@
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/assets/css/admin/account.css DELETED
@@ -1 +0,0 @@
1
- #fs_account .postbox,#fs_account .widefat{max-width:700px}#fs_account .fs-header-actions{position:absolute;top:10px;right:10px;font-size:0.9em}#fs_account .fs-header-actions ul{margin:0}#fs_account .fs-header-actions li{float:left}#fs_account .fs-header-actions li form{display:inline-block}#fs_account .fs-header-actions li a{text-decoration:none}.rtl #fs_account .fs-header-actions{left:10px;right:auto}.fs-key-value-table{width:100%}.fs-key-value-table form{display:inline-block}.fs-key-value-table td label{background:orange;color:#fff;display:inline-block;border-radius:3px;padding:5px;font-size:11px;line-height:11px;vertical-align:baseline}.fs-key-value-table tr td:first-child{text-align:right}.fs-key-value-table tr td:first-child nobr{font-weight:bold}.fs-key-value-table tr td:first-child form{display:block}.fs-key-value-table tr td.fs-right{text-align:right}.fs-key-value-table tr.fs-odd{background:#ebebeb}.fs-key-value-table td,.fs-key-value-table th{padding:10px}.fs-key-value-table var,.fs-key-value-table code{color:#0073AA;font-size:16px;background:none}#fs_addons td:first-child,#fs_addons th:first-child{text-align:left;font-weight:bold}#fs_addons td:last-child,#fs_addons th:last-child{text-align:right}#fs_addons th{font-weight:bold}
 
freemius/assets/css/admin/add-ons.css DELETED
@@ -1,2 +0,0 @@
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;-moz-transition:all,0.15s;-o-transition:all,0.15s;-ms-transition:all,0.15s;-webkit-transition:all,0.15s;transition:all,0.15s}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-title{margin:10px 0 0 0;height:18px;overflow:hidden;color:#000;white-space:nowrap;text-overflow:ellipsis;font-weight:bold}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-offer{font-size:0.9em}#fs_addons .fs-cards-list .fs-card .fs-inner .fs-description{background-color:#f9f9f9;padding:10px 15px 100px 15px;border-top:1px solid #eee;margin:0 0 10px 0;color:#777}@media screen and (min-width: 960px){#fs_addons .fs-cards-list .fs-card:hover .fs-overlay{border:2px solid #29abe1;margin-left:-1px;margin-top:-1px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner ul{top:-100px}#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-title,#fs_addons .fs-cards-list .fs-card:hover .fs-inner .fs-offer{color:#29abe1}}
2
- #TB_window,#TB_window iframe{width:772px !important}#plugin-information #section-description h2,#plugin-information #section-description h3,#plugin-information #section-description p,#plugin-information #section-description b,#plugin-information #section-description i,#plugin-information #section-description blockquote,#plugin-information #section-description li,#plugin-information #section-description ul,#plugin-information #section-description ol{clear:none}#plugin-information #section-description .fs-selling-points{padding-bottom:10px;border-bottom:1px solid #ddd}#plugin-information #section-description .fs-selling-points ul{margin:0}#plugin-information #section-description .fs-selling-points ul li{padding:0;list-style:none outside none}#plugin-information #section-description .fs-selling-points ul li i.dashicons{color:#71ae00;font-size:3em;vertical-align:middle;line-height:30px;float:left;margin:0 0 0 -15px}#plugin-information #section-description .fs-selling-points ul li h3{margin-left:30px}#plugin-information #section-description .fs-screenshots:after{content:"";display:table;clear:both}#plugin-information #section-description .fs-screenshots ul{list-style:none;margin:0}#plugin-information #section-description .fs-screenshots ul li{width:225px;height:225px;float:left;margin-bottom:20px;-moz-box-sizing:content-box;-webkit-box-sizing:content-box;box-sizing:content-box}#plugin-information #section-description .fs-screenshots ul li a{display:block;width:100%;height:100%;border:1px solid;-moz-box-shadow:1px 1px 1px rgba(0,0,0,0.2);-webkit-box-shadow:1px 1px 1px rgba(0,0,0,0.2);box-shadow:1px 1px 1px rgba(0,0,0,0.2);background-size:cover}#plugin-information #section-description .fs-screenshots ul li.odd{margin-right:20px}#plugin-information .plugin-information-pricing{background:#FFFEEC;margin:-16px;padding:20px 20px 50px 20px;border-bottom:1px solid #DDD}#plugin-information .plugin-information-pricing h3{margin-top:0}#plugin-information .plugin-information-pricing .button{width:100%;text-align:center;font-weight:bold;text-transform:uppercase;font-size:1.1em}#plugin-information .plugin-information-pricing label{white-space:nowrap}#plugin-information #section-features .fs-features{margin:-20px -26px}#plugin-information #section-features table{width:100%;border-spacing:0;border-collapse:separate}#plugin-information #section-features table thead th{padding:10px 0}#plugin-information #section-features table thead .fs-price{color:#71ae00;font-weight:normal;display:block;text-align:center}#plugin-information #section-features table tbody td{border-top:1px solid #ccc;padding:10px 0;text-align:center;width:100px;color:#71ae00}#plugin-information #section-features table tbody td:first-child{text-align:left;width:auto;color:inherit;padding-left:26px}#plugin-information #section-features table tbody tr.fs-odd td{background:#fefefe}#plugin-information #section-features .dashicons-yes{width:30px;height:30px;font-size:30px}@media screen and (max-width: 961px){#fs_addons .fs-cards-list .fs-card{height:265px}}
 
 
freemius/assets/css/admin/common.css DELETED
@@ -1 +0,0 @@
1
- .fs-notice{position:relative}.fs-notice.fs-has-title{margin-bottom:30px !important}.fs-notice.success{color:green}.fs-notice.promotion{border-color:#00a0d2 !important;background-color:#f2fcff !important}.fs-notice .fs-close{position:absolute;top:10px;right:10px;cursor:pointer;color:#ccc}.fs-notice .fs-close:hover{color:#aaa}.fs-notice label.fs-plugin-title{background:rgba(0,0,0,0.3);color:#fff;padding:2px 10px;position:absolute;bottom:-22px;top:auto;right:auto;-moz-border-radius:0 0 3px 3px;-webkit-border-radius:0 0 3px 3px;border-radius:0 0 3px 3px;left:10px;font-size:12px;font-weight:bold;cursor:auto}.rtl .fs-notice .fs-close{left:10px;right:auto}.fs-secure-notice{position:fixed;top:32px;left:160px;right:0;background:#ebfdeb;padding:10px 20px;color:green;z-index:9999;box-shadow:0px 2px 2px rgba(6,113,6,0.3);opacity:0.95;filter:alpha(opacity=95)}.fs-secure-notice:hover{opacity:1;filter:alpha(opacity=100)}@media screen and (max-width: 960px){.fs-secure-notice{left:36px}}@media screen and (max-width: 782px){.fs-secure-notice{left:0;top:46px;text-align:center}}span.fs-submenu-item.fs-sub:before{content:'\21B3';padding:0 5px}.rtl span.fs-submenu-item.fs-sub:before{content:'\21B2'}
 
freemius/assets/css/admin/connect.css DELETED
@@ -1 +0,0 @@
1
- #fs_connect{width:480px;-moz-box-shadow:0px 1px 2px rgba(0,0,0,0.3);-webkit-box-shadow:0px 1px 2px rgba(0,0,0,0.3);box-shadow:0px 1px 2px rgba(0,0,0,0.3);margin:20px 0}@media screen and (max-width: 479px){#fs_connect{-moz-box-shadow:none;-webkit-box-shadow:none;box-shadow:none;width:auto;margin:0 0 0 -10px}}#fs_connect .fs-content{background:#fff;padding:15px 20px}#fs_connect .fs-content p{margin:0;padding:0;font-size:1.2em}#fs_connect .fs-actions{padding:10px 20px;background:#C0C7CA}#fs_connect .fs-actions .button{padding:0 10px 1px;line-height:35px;height:37px;font-size:16px;margin-bottom:0}#fs_connect .fs-actions .button .dashicons{font-size:37px;margin-left:-8px;margin-right:12px}#fs_connect .fs-actions .button.button-primary{padding-right:15px;padding-left:15px}#fs_connect .fs-actions .button.button-secondary{float:right}#fs_connect.fs-anonymous-disabled .fs-actions .button.button-primary{width:100%}#fs_connect .fs-permissions{padding:10px 20px;background:#FEFEFE;-moz-transition:background 0.5s ease;-o-transition:background 0.5s ease;-ms-transition:background 0.5s ease;-webkit-transition:background 0.5s ease;transition:background 0.5s ease}#fs_connect .fs-permissions .fs-trigger{font-size:0.9em;text-decoration:none;text-align:center;display:block}#fs_connect .fs-permissions ul{height:0;overflow:hidden;margin:0}#fs_connect .fs-permissions ul li{margin-bottom:12px}#fs_connect .fs-permissions ul li:last-child{margin-bottom:0}#fs_connect .fs-permissions ul li i.dashicons{float:left;font-size:40px;width:40px;height:40px}#fs_connect .fs-permissions ul li div{margin-left:55px}#fs_connect .fs-permissions ul li div span{font-weight:bold;text-transform:uppercase;color:#23282d}#fs_connect .fs-permissions ul li div p{margin:2px 0 0 0}#fs_connect .fs-permissions.fs-open{background:#fff}#fs_connect .fs-permissions.fs-open ul{height:auto;margin:20px 20px 10px 20px}@media screen and (max-width: 479px){#fs_connect .fs-permissions{background:#fff}#fs_connect .fs-permissions .fs-trigger{display:none}#fs_connect .fs-permissions ul{height:auto;margin:20px}}#fs_connect .fs-visual{padding:12px;line-height:0;background:#fafafa;height:80px;position:relative}#fs_connect .fs-visual .fs-site-icon{position:absolute;left:20px;top:10px}#fs_connect .fs-visual .fs-connect-logo{position:absolute;right:20px;top:10px}#fs_connect .fs-visual .fs-plugin-icon{position:absolute;top:10px;left:50%;margin-left:-40px}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-site-icon,#fs_connect .fs-visual img,#fs_connect .fs-visual object{width:80px;height:80px}#fs_connect .fs-visual .dashicons-wordpress{font-size:64px;background:#01749a;color:#fff;width:64px;height:64px;padding:8px}#fs_connect .fs-visual .dashicons-plus{position:absolute;top:50%;font-size:30px;margin-top:-10px;color:#bbb}#fs_connect .fs-visual .dashicons-plus.fs-first{left:28%}#fs_connect .fs-visual .dashicons-plus.fs-second{left:65%}#fs_connect .fs-visual .fs-plugin-icon,#fs_connect .fs-visual .fs-connect-logo,#fs_connect .fs-visual .fs-site-icon{border:1px solid #ccc;padding:1px;background:#fff}#fs_connect .fs-terms{text-align:center;font-size:0.85em;padding:5px;background:rgba(0,0,0,0.05)}#fs_connect .fs-terms,#fs_connect .fs-terms a{color:#999}#fs_connect .fs-terms a{text-decoration:none}
 
freemius/assets/css/admin/deactivation-feedback.css DELETED
@@ -1 +0,0 @@
1
- .fs-modal{position:fixed;overflow:auto;height:100%;width:100%;top:0;z-index:100000;display:none;background:rgba(0,0,0,0.6)}.fs-modal .fs-modal-dialog{background:transparent;position:absolute;left:50%;margin-left:-298px;padding-bottom:30px;top:-100%;z-index:100001;width:596px}@media (max-width: 650px){.fs-modal .fs-modal-dialog{margin-left:-50%;box-sizing:border-box;padding-left:10px;padding-right:10px;width:100%}.fs-modal .fs-modal-dialog .fs-modal-panel>h3>strong{font-size:1.3em}.fs-modal .fs-modal-dialog li.reason{margin-bottom:10px}.fs-modal .fs-modal-dialog li.reason .reason-input{margin-left:29px}.fs-modal .fs-modal-dialog li.reason label{display:table}.fs-modal .fs-modal-dialog li.reason label>span{display:table-cell;font-size:1.3em}}.fs-modal.active{display:block}.fs-modal.active:before{display:block}.fs-modal.active .fs-modal-dialog{top:10%}.fs-modal .fs-modal-body,.fs-modal .fs-modal-footer{border:0;background:#fefefe;padding:20px}.fs-modal .fs-modal-body{border-bottom:0}.fs-modal .fs-modal-body h2{font-size:20px}.fs-modal .fs-modal-body>div{margin-top:10px}.fs-modal .fs-modal-body>div h2{font-weight:bold;font-size:20px;margin-top:0}.fs-modal .fs-modal-footer{border-top:#eeeeee solid 1px;text-align:right}.fs-modal .fs-modal-footer>.button{margin:0 7px}.fs-modal .fs-modal-footer>.button:first-child{margin:0}.fs-modal .fs-modal-panel:not(.active){display:none}.fs-modal .reason-input{margin:3px 0 3px 22px}.fs-modal .reason-input input,.fs-modal .reason-input textarea{width:100%}body.has-fs-modal{overflow:hidden}#the-list .deactivate>.fs-slug{display:none}
 
freemius/assets/css/common.css DELETED
@@ -1 +0,0 @@
1
- .fs-notice.success{color:green;font-weight:700}
 
freemius/assets/img/icon.jpg DELETED
Binary file
freemius/assets/img/plugin-icon.png DELETED
Binary file
freemius/assets/js/jquery.ba-postmessage.js DELETED
@@ -1,222 +0,0 @@
1
- /*!
2
- * jQuery postMessage - v0.5 - 9/11/2009
3
- * http://benalman.com/projects/jquery-postmessage-plugin/
4
- *
5
- * Copyright (c) 2009 "Cowboy" Ben Alman
6
- * Dual licensed under the MIT and GPL licenses.
7
- * http://benalman.com/about/license/
8
- */
9
-
10
- // Script: jQuery postMessage: Cross-domain scripting goodness
11
- //
12
- // *Version: 0.5, Last updated: 9/11/2009*
13
- //
14
- // Project Home - http://benalman.com/projects/jquery-postmessage-plugin/
15
- // GitHub - http://github.com/cowboy/jquery-postmessage/
16
- // Source - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.js
17
- // (Minified) - http://github.com/cowboy/jquery-postmessage/raw/master/jquery.ba-postmessage.min.js (0.9kb)
18
- //
19
- // About: License
20
- //
21
- // Copyright (c) 2009 "Cowboy" Ben Alman,
22
- // Dual licensed under the MIT and GPL licenses.
23
- // http://benalman.com/about/license/
24
- //
25
- // About: Examples
26
- //
27
- // This working example, complete with fully commented code, illustrates one
28
- // way in which this plugin can be used.
29
- //
30
- // Iframe resizing - http://benalman.com/code/projects/jquery-postmessage/examples/iframe/
31
- //
32
- // About: Support and Testing
33
- //
34
- // Information about what version or versions of jQuery this plugin has been
35
- // tested with and what browsers it has been tested in.
36
- //
37
- // jQuery Versions - 1.3.2
38
- // Browsers Tested - Internet Explorer 6-8, Firefox 3, Safari 3-4, Chrome, Opera 9.
39
- //
40
- // About: Release History
41
- //
42
- // 0.5 - (9/11/2009) Improved cache-busting
43
- // 0.4 - (8/25/2009) Initial release
44
-
45
- (function($){
46
- '$:nomunge'; // Used by YUI compressor.
47
-
48
- // A few vars used in non-awesome browsers.
49
- var interval_id,
50
- last_hash,
51
- cache_bust = 1,
52
-
53
- // A var used in awesome browsers.
54
- rm_callback,
55
-
56
- // A few convenient shortcuts.
57
- window = this,
58
- FALSE = !1,
59
-
60
- // Reused internal strings.
61
- postMessage = 'postMessage',
62
- addEventListener = 'addEventListener',
63
-
64
- p_receiveMessage,
65
-
66
- // I couldn't get window.postMessage to actually work in Opera 9.64!
67
- has_postMessage = window[postMessage] && !$.browser.opera;
68
-
69
- // Method: jQuery.postMessage
70
- //
71
- // This method will call window.postMessage if available, setting the
72
- // targetOrigin parameter to the base of the target_url parameter for maximum
73
- // security in browsers that support it. If window.postMessage is not available,
74
- // the target window's location.hash will be used to pass the message. If an
75
- // object is passed as the message param, it will be serialized into a string
76
- // using the jQuery.param method.
77
- //
78
- // Usage:
79
- //
80
- // > jQuery.postMessage( message, target_url [, target ] );
81
- //
82
- // Arguments:
83
- //
84
- // message - (String) A message to be passed to the other frame.
85
- // message - (Object) An object to be serialized into a params string, using
86
- // the jQuery.param method.
87
- // target_url - (String) The URL of the other frame this window is
88
- // attempting to communicate with. This must be the exact URL (including
89
- // any query string) of the other window for this script to work in
90
- // browsers that don't support window.postMessage.
91
- // target - (Object) A reference to the other frame this window is
92
- // attempting to communicate with. If omitted, defaults to `parent`.
93
- //
94
- // Returns:
95
- //
96
- // Nothing.
97
-
98
- $[postMessage] = function( message, target_url, target ) {
99
- if ( !target_url ) { return; }
100
-
101
- // Serialize the message if not a string. Note that this is the only real
102
- // jQuery dependency for this script. If removed, this script could be
103
- // written as very basic JavaScript.
104
- message = typeof message === 'string' ? message : $.param( message );
105
-
106
- // Default to parent if unspecified.
107
- target = target || parent;
108
-
109
- if ( has_postMessage ) {
110
- // The browser supports window.postMessage, so call it with a targetOrigin
111
- // set appropriately, based on the target_url parameter.
112
- target[postMessage]( message, target_url.replace( /([^:]+:\/\/[^\/]+).*/, '$1' ) );
113
-
114
- } else if ( target_url ) {
115
- // The browser does not support window.postMessage, so set the location
116
- // of the target to target_url#message. A bit ugly, but it works! A cache
117
- // bust parameter is added to ensure that repeat messages trigger the
118
- // callback.
119
- target.location = target_url.replace( /#.*$/, '' ) + '#' + (+new Date) + (cache_bust++) + '&' + message;
120
- }
121
- };
122
-
123
- // Method: jQuery.receiveMessage
124
- //
125
- // Register a single callback for either a window.postMessage call, if
126
- // supported, or if unsupported, for any change in the current window
127
- // location.hash. If window.postMessage is supported and source_origin is
128
- // specified, the source window will be checked against this for maximum
129
- // security. If window.postMessage is unsupported, a polling loop will be
130
- // started to watch for changes to the location.hash.
131
- //
132
- // Note that for simplicity's sake, only a single callback can be registered
133
- // at one time. Passing no params will unbind this event (or stop the polling
134
- // loop), and calling this method a second time with another callback will
135
- // unbind the event (or stop the polling loop) first, before binding the new
136
- // callback.
137
- //
138
- // Also note that if window.postMessage is available, the optional
139
- // source_origin param will be used to test the event.origin property. From
140
- // the MDC window.postMessage docs: This string is the concatenation of the
141
- // protocol and "://", the host name if one exists, and ":" followed by a port
142
- // number if a port is present and differs from the default port for the given
143
- // protocol. Examples of typical origins are https://example.org (implying
144
- // port 443), http://example.net (implying port 80), and http://example.com:8080.
145
- //
146
- // Usage:
147
- //
148
- // > jQuery.receiveMessage( callback [, source_origin ] [, delay ] );
149
- //
150
- // Arguments:
151
- //
152
- // callback - (Function) This callback will execute whenever a <jQuery.postMessage>
153
- // message is received, provided the source_origin matches. If callback is
154
- // omitted, any existing receiveMessage event bind or polling loop will be
155
- // canceled.
156
- // source_origin - (String) If window.postMessage is available and this value
157
- // is not equal to the event.origin property, the callback will not be
158
- // called.
159
- // source_origin - (Function) If window.postMessage is available and this
160
- // function returns false when passed the event.origin property, the
161
- // callback will not be called.
162
- // delay - (Number) An optional zero-or-greater delay in milliseconds at
163
- // which the polling loop will execute (for browser that don't support
164
- // window.postMessage). If omitted, defaults to 100.
165
- //
166
- // Returns:
167
- //
168
- // Nothing!
169
-
170
- $.receiveMessage = p_receiveMessage = function( callback, source_origin, delay ) {
171
- if ( has_postMessage ) {
172
- // Since the browser supports window.postMessage, the callback will be
173
- // bound to the actual event associated with window.postMessage.
174
-
175
- if ( callback ) {
176
- // Unbind an existing callback if it exists.
177
- rm_callback && p_receiveMessage();
178
-
179
- // Bind the callback. A reference to the callback is stored for ease of
180
- // unbinding.
181
- rm_callback = function(e) {
182
- if ( ( typeof source_origin === 'string' && e.origin !== source_origin )
183
- || ( $.isFunction( source_origin ) && source_origin( e.origin ) === FALSE ) ) {
184
- return FALSE;
185
- }
186
- callback( e );
187
- };
188
- }
189
-
190
- if ( window[addEventListener] ) {
191
- window[ callback ? addEventListener : 'removeEventListener' ]( 'message', rm_callback, FALSE );
192
- } else {
193
- window[ callback ? 'attachEvent' : 'detachEvent' ]( 'onmessage', rm_callback );
194
- }
195
-
196
- } else {
197
- // Since the browser sucks, a polling loop will be started, and the
198
- // callback will be called whenever the location.hash changes.
199
-
200
- interval_id && clearInterval( interval_id );
201
- interval_id = null;
202
-
203
- if ( callback ) {
204
- delay = typeof source_origin === 'number'
205
- ? source_origin
206
- : typeof delay === 'number'
207
- ? delay
208
- : 100;
209
-
210
- interval_id = setInterval(function(){
211
- var hash = document.location.hash,
212
- re = /^#?\d+&/;
213
- if ( hash !== last_hash && re.test( hash ) ) {
214
- last_hash = hash;
215
- callback({ data: hash.replace( re, '' ) });
216
- }
217
- }, delay );
218
- }
219
- }
220
- };
221
-
222
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/js/jquery.ba-postmessage.min.js DELETED
@@ -1,9 +0,0 @@
1
- /*
2
- * jQuery postMessage - v0.5 - 9/11/2009
3
- * http://benalman.com/projects/jquery-postmessage-plugin/
4
- *
5
- * Copyright (c) 2009 "Cowboy" Ben Alman
6
- * Dual licensed under the MIT and GPL licenses.
7
- * http://benalman.com/about/license/
8
- */
9
- (function($){var g,d,j=1,a,b=this,f=!1,h="postMessage",e="addEventListener",c,i=b[h]&&!$.browser.opera;$[h]=function(k,l,m){if(!l){return}k=typeof k==="string"?k:$.param(k);m=m||parent;if(i){m[h](k,l.replace(/([^:]+:\/\/[^\/]+).*/,"$1"))}else{if(l){m.location=l.replace(/#.*$/,"")+"#"+(+new Date)+(j++)+"&"+k}}};$.receiveMessage=c=function(l,m,k){if(i){if(l){a&&c();a=function(n){if((typeof m==="string"&&n.origin!==m)||($.isFunction(m)&&m(n.origin)===f)){return f}l(n)}}if(b[e]){b[l?e:"removeEventListener"]("message",a,f)}else{b[l?"attachEvent":"detachEvent"]("onmessage",a)}}else{g&&clearInterval(g);g=null;if(l){k=typeof m==="number"?m:typeof k==="number"?k:100;g=setInterval(function(){var o=document.location.hash,n=/^#?\d+&/;if(o!==d&&n.test(o)){d=o;l({data:o.replace(n,"")})}},k)}}}})(jQuery);
 
 
 
 
 
 
 
 
 
freemius/assets/js/nojquery.ba-postmessage.js DELETED
@@ -1,140 +0,0 @@
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 DELETED
@@ -1,12 +0,0 @@
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 DELETED
@@ -1,110 +0,0 @@
1
- (function ($, undef) {
2
- var global = this;
3
-
4
- // Namespace.
5
- global.FS = global.FS || {};
6
-
7
- global.FS.PostMessage = function ()
8
- {
9
- var
10
- _is_child = false,
11
- _postman = new NoJQueryPostMessageMixin('postMessage', 'receiveMessage'),
12
- _callbacks = {},
13
- _base_url,
14
- _parent_url = decodeURIComponent(document.location.hash.replace(/^#/, '')),
15
- _parent_subdomain = _parent_url.substring(0, _parent_url.indexOf('/', ('https://' === _parent_url.substring(0, ('https://').length)) ? 8 : 7)),
16
- _init = function () {
17
- _postman.receiveMessage(function (e) {
18
- var data = JSON.parse(e.data);
19
-
20
- if (_callbacks[data.type]) {
21
- for (var i = 0; i < _callbacks[data.type].length; i++) {
22
- // Execute type callbacks.
23
- _callbacks[data.type][i](data.data);
24
- }
25
- }
26
- }, _base_url);
27
- };
28
-
29
- return {
30
- init : function (url)
31
- {
32
- _base_url = url;
33
- _init();
34
-
35
- // Automatically receive forward messages.
36
- FS.PostMessage.receiveOnce('forward', function (data){
37
- window.location = data.url;
38
- });
39
- },
40
- init_child : function ()
41
- {
42
- this.init(_parent_subdomain);
43
-
44
- _is_child = true;
45
-
46
- // Post height of a child right after window is loaded.
47
- $(window).bind('load', function () {
48
- FS.PostMessage.postHeight();
49
- });
50
-
51
- },
52
- postHeight : function (diff, wrapper) {
53
- diff = diff || 0;
54
- wrapper = wrapper || '#wrap_section';
55
- this.post('height', {
56
- height: diff + $(wrapper).outerHeight(true)
57
- });
58
- },
59
- post : function (type, data, iframe)
60
- {
61
- console.debug('PostMessage.post', type);
62
-
63
- if (iframe)
64
- {
65
- // Post to iframe.
66
- _postman.postMessage(JSON.stringify({
67
- type: type,
68
- data: data
69
- }), iframe.src, iframe.contentWindow);
70
- }
71
- else {
72
- // Post to parent.
73
- _postman.postMessage(JSON.stringify({
74
- type: type,
75
- data: data
76
- }), _parent_url, window.parent);
77
- }
78
- },
79
- receive: function (type, callback)
80
- {
81
- console.debug('PostMessage.receive', type);
82
-
83
- if (undef === _callbacks[type])
84
- _callbacks[type] = [];
85
-
86
- _callbacks[type].push(callback);
87
- },
88
- receiveOnce: function (type, callback)
89
- {
90
- if (this.is_set(type))
91
- return;
92
-
93
- this.receive(type, callback);
94
- },
95
- // Check if any callbacks assigned to a specified message type.
96
- is_set: function (type)
97
- {
98
- return (undef != _callbacks[type]);
99
- },
100
- parent_url: function ()
101
- {
102
- return _parent_url;
103
- },
104
- parent_subdomain: function ()
105
- {
106
- return _parent_subdomain;
107
- }
108
- };
109
- }();
110
- })(jQuery);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/_colors.scss DELETED
@@ -1,58 +0,0 @@
1
- $menu-hover-color: #333;
2
- $darkest-color: #000;
3
- $fms-live-color: #71ae00;
4
- $fms-test-color: #f7941d;
5
- $fms-link-color: #29abe1;
6
- $fms-link-hover-color: darken(#29abe1, 10%);
7
- $body-bkg: #111;
8
- $special-color: #d3135a;
9
- $body-color: #f1f1f1;
10
- $fms-white: #f1f1f1;
11
- $container-bkg: #222;
12
- $container-bkg-odd: #262626;
13
- $container-border-color: #333;
14
- $table-head-bkg: #333;
15
- $table-head-color: #999;
16
- $info-color: #999;
17
- $error-color: #ff0000;
18
-
19
- $fs-logo-blue-color: #29abe1;
20
- $fs-logo-green-color: #71ae00;
21
- $fs-logo-magenta-color: #d3135a;
22
-
23
- $fs-notice-promotion-border-color: #00a0d2;
24
- $fs-notice-promotion-bkg: #f2fcff;
25
-
26
- // WordPress colors.
27
- $page-header-bkg: #333;
28
- $page-header-color: $fms-white;
29
- $text-dark-color: #333;
30
- $text-light-color: #666;
31
- $text-lightest-color: #999;
32
-
33
- // WP Buttons.
34
- $button-primary-bkg: #6bc406;
35
- $button-primary-color: $fms-white;
36
- $button-secondary-bkg: #333;
37
- $button-secondary-color: $fms-white;
38
- $featured-color: #6bc406;
39
- $wp-selected-color: #0074a3;
40
-
41
- $wordpress_color: #01749A;
42
- $blogger_color: #ff8100;
43
- $wix_color: #fac102;
44
- $shopify_color: #80d100;
45
- $addthis_color: #fe6d4e;
46
- $tumblr_color: #34506b;
47
- $zepo_color: #00baf2;
48
- $jquery_color: #000919;
49
- $javascript_color: #00baf2;
50
- $squarespace_color: #000;
51
-
52
- $blog_color: #ff6600;
53
- $facebook_color: #3b5998;
54
- $twitter_color: #4099ff;
55
- $linkedin_color: #4875b4;
56
- $youtube_color: #ff3333;
57
- $gplus_color: #c63d2d;
58
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/_functions.scss DELETED
File without changes
freemius/assets/scss/_load.scss DELETED
@@ -1,4 +0,0 @@
1
- @import 'mixins';
2
- @import "vars";
3
- @import "functions";
4
- @import "colors";
 
 
 
 
freemius/assets/scss/_mixins.scss DELETED
@@ -1,224 +0,0 @@
1
- // ---- CSS3 SASS MIXINS ----
2
- // https://github.com/madr/css3-sass-mixins
3
- //
4
- // Copyright (C) 2011 by Anders Ytterström
5
- //
6
- // Permission is hereby granted, free of charge, to any person obtaining a copy
7
- // of this software and associated documentation files (the "Software"), to deal
8
- // in the Software without restriction, including without limitation the rights
9
- // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- // copies of the Software, and to permit persons to whom the Software is
11
- // furnished to do so, subject to the following conditions:
12
- //
13
- // The above copyright notice and this permission notice shall be included in
14
- // all copies or substantial portions of the Software.
15
- //
16
- // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
- // THE SOFTWARE.
23
- //
24
-
25
- // ---- LEGACY IE SUPPORT USING FILTERS ----
26
- // Should IE filters be used or not?
27
- // PROS: gradients, drop shadows etc will be handled by css.
28
- // CONS: will harm the site performance badly,
29
- // especially on sites with heavy rendering and scripting.
30
- $useIEFilters: 0;
31
- // might be 0 or 1. disabled by default.
32
- // ---- /LEGACY IE SUPPORT USING FILTERS ----
33
-
34
-
35
- @mixin background-size ($value) {
36
- -webkit-background-size: $value;
37
- background-size: $value;
38
- }
39
-
40
- @mixin border-image ($path, $offsets, $repeats) {
41
- -moz-border-image: $path $offsets $repeats;
42
- -o-border-image: $path $offsets $repeats;
43
- -webkit-border-image: $path $offsets $repeats;
44
- border-image: $path $offsets $repeats;
45
- }
46
-
47
- @mixin border-radius ($values...) {
48
- -moz-border-radius: $values;
49
- -webkit-border-radius: $values;
50
- border-radius: $values;
51
- /*-moz-background-clip: padding;
52
- -webkit-background-clip: padding-box;
53
- background-clip: padding-box;*/
54
- }
55
-
56
- @mixin box-shadow ($values...) {
57
- -moz-box-shadow: $values;
58
- -webkit-box-shadow: $values;
59
- box-shadow: $values;
60
- }
61
-
62
- //@mixin box-shadow ($x, $y, $offset, $hex, $ie: $useIEFilters, $inset: null, $spread:null) {
63
- // -moz-box-shadow: $x $y $offset $spread $hex $inset;
64
- // -webkit-box-shadow: $x $y $offset $spread $hex $inset;
65
- // box-shadow: $x $y $offset $spread $hex $inset;
66
- //
67
- // @if $ie == 1 {
68
- // $iecolor: '#' + red($hex) + green($hex) + blue($hex);
69
- // filter: progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}');
70
- // -ms-filter: quote(progid:DXImageTransform.Microsoft.dropshadow(OffX=#{$x}, OffY=#{$y}, Color='#{$iecolor}'));
71
- // }
72
- //}
73
-
74
- @mixin box-sizing($value) {
75
- -moz-box-sizing: $value;
76
- -webkit-box-sizing: $value;
77
- box-sizing: $value;
78
- }
79
-
80
- // requires sass 3.2
81
- //@mixin keyframes {
82
- // @-moz-keyframes { @content; }
83
- // @-ms-keyframes { @content; }
84
- // @-o-keyframes { @content; }
85
- // @-webkit-keyframes { @content; }
86
- // @keyframes { @content; }
87
- //}
88
-
89
- @mixin linear-gradient($from, $to, $ie: $useIEFilters) {
90
- @if $ie != 1 { background-color: $to; }
91
-
92
- background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, $from),color-stop(1, $to));
93
- background-image: -webkit-linear-gradient(top, $from, $to);
94
- background-image: -moz-linear-gradient(top, $from, $to);
95
- background-image: -ms-linear-gradient(top, $from, $to);
96
- background-image: -o-linear-gradient(top, $from, $to);
97
- background-image: linear-gradient(top, bottom, $from, $to);
98
-
99
- @if $ie == 1 {
100
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}');
101
- }
102
- }
103
-
104
- @mixin horizontal-gradient($startColor: #555, $endColor: #333, $ie: $useIEFilters) {
105
- @if $ie != 1 { background-color: $endColor; }
106
-
107
- background-color: $endColor;
108
- background-image: -webkit-gradient(linear, 0 0, 100% 0, from($startColor), to($endColor)); // Safari 4+, Chrome 2+
109
- background-image: -webkit-linear-gradient(left, $startColor, $endColor); // Safari 5.1+, Chrome 10+
110
- background-image: -moz-linear-gradient(left, $startColor, $endColor); // FF 3.6+
111
- background-image: -o-linear-gradient(left, $startColor, $endColor); // Opera 11.10
112
- background-image: linear-gradient(to right, $startColor, $endColor); // Standard, IE10
113
- background-repeat: repeat-x;
114
- @if $ie == 1 {
115
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$startColor}', endColorstr='#{$endColor}', GradientType=1);
116
- }
117
- }
118
-
119
- @mixin radial-gradient($from, $to, $ie: $useIEFilters) {
120
- @if $ie != 1 { background-color: $to; }
121
-
122
- background: -moz-radial-gradient(center, circle cover, $from 0%, $to 100%);
123
- background: -webkit-gradient(radial, center center, 0px, center center, 100%, color-stop(0%, $from), color-stop(100%, $to));
124
- background: -webkit-radial-gradient(center, circle cover, $from 0%, $to 100%);
125
- background: -o-radial-gradient(center, circle cover, $from 0%, $to 100%);
126
- background: -ms-radial-gradient(center, circle cover, $from 0%, $to 100%);
127
- background: radial-gradient(center, circle cover, $from 0%, $to 100%);
128
- background-color: $from;
129
-
130
- @if $ie == 1 {
131
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#{$from}', endColorstr='#{$to}', GradientType=1); /* IE6-9 fallback on horizontal gradient */
132
- }
133
- }
134
-
135
- /*@mixin rgba-bg ($hex, $alpha, $ie: $useIEFilters) {
136
- @if $ie == 1 {
137
- background-color: none;
138
- $hexopac: ie-hex-str(rgba($hex, $alpha));
139
- filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}}');
140
- -ms-filter: quote(progid:DXImageTransform.Microsoft.gradient(startColorStr='#{$hexopac}',EndColorStr='#{$hexopac}'));
141
- }
142
- @else {
143
- background-color: $hex;
144
- background-color: rgba($hex, $alpha);
145
- }
146
- }*/
147
-
148
- @mixin perspective($perspective) {
149
- -moz-perspective: $perspective;
150
- -ms-perspective: $perspective;
151
- -webkit-perspective: $perspective;
152
- perspective: $perspective;
153
- -moz-transform-style: preserve-3d;
154
- -ms-transform-style: preserve-3d;
155
- -webkit-transform-style: preserve-3d;
156
- transform-style: preserve-3d;
157
- }
158
-
159
- @mixin transform ($transforms) {
160
- -moz-transform: $transforms;
161
- -o-transform: $transforms;
162
- -ms-transform: $transforms;
163
- -webkit-transform: $transforms;
164
- transform: $transforms;
165
- }
166
-
167
- @mixin matrix ($a, $b, $c, $d, $e, $f) {
168
- -moz-transform: matrix($a, $b, $c, $d, #{$e}px, #{$f}px);
169
- -o-transform: matrix($a, $b, $c, $d, $e, $f);
170
- -ms-transform: matrix($a, $b, $c, $d, $e, $f);
171
- -webkit-transform: matrix($a, $b, $c, $d, $e, $f);
172
- transform: matrix($a, $b, $c, $d, $e, $f);
173
- }
174
-
175
- @mixin rotate ($deg) {
176
- @include transform(rotate(#{$deg}deg));
177
- }
178
-
179
- @mixin scale ($size) {
180
- @include transform(scale(#{$size}));
181
- }
182
-
183
- @mixin translate ($x, $y) {
184
- @include transform(translate($x, $y));
185
- }
186
-
187
- @mixin transition ($value...) {
188
- -moz-transition: $value;
189
- -o-transition: $value;
190
- -ms-transition: $value;
191
- -webkit-transition: $value;
192
- transition: $value;
193
- }
194
-
195
- // ==== /CSS3 SASS MIXINS ====
196
-
197
- @mixin opacity($opacity) {
198
- opacity: $opacity;
199
- $opacity-ie: $opacity * 100;
200
- filter: alpha(opacity=$opacity-ie); //IE8
201
- }
202
-
203
- @mixin sprite($img, $width, $height: $width, $display: block)
204
- {
205
- display: $display;
206
- background-image: url('#{$img}');
207
-
208
- @include size($width, $height);
209
- }
210
-
211
- @mixin size($width, $height: $width)
212
- {
213
- width: $width;
214
- height: $height;
215
- }
216
-
217
- @mixin clearfix
218
- {
219
- &:after {
220
- content: "";
221
- display: table;
222
- clear: both;
223
- }
224
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/_start.scss DELETED
@@ -1,4 +0,0 @@
1
- @import "vars";
2
- @import "colors";
3
- @import "mixins";
4
- @import "functions";
 
 
 
 
freemius/assets/scss/_vars.scss DELETED
@@ -1,5 +0,0 @@
1
- $is_production: true;
2
-
3
- $img_common: if($is_production == true, '//img.freemius.com', 'http://img.freemius:8080');
4
-
5
- $layout_width: 960px;
 
 
 
 
 
freemius/assets/scss/admin/account.scss DELETED
@@ -1,122 +0,0 @@
1
- #fs_account
2
- {
3
- .postbox,
4
- .widefat
5
- {
6
- max-width: 700px;
7
- }
8
-
9
- .fs-header-actions
10
- {
11
- position: absolute;
12
- top: 10px;
13
- right: 10px;
14
- font-size: 0.9em;
15
-
16
- ul
17
- {
18
- margin: 0;
19
- }
20
-
21
- li
22
- {
23
- form
24
- {
25
- display: inline-block;
26
- }
27
-
28
- float: left;
29
- a
30
- {
31
- text-decoration: none;
32
- }
33
- }
34
- }
35
- }
36
-
37
- .rtl #fs_account .fs-header-actions
38
- {
39
- left: 10px;
40
- right: auto;
41
- }
42
-
43
- .fs-key-value-table
44
- {
45
- width: 100%;
46
-
47
- form
48
- {
49
- display: inline-block;
50
- }
51
-
52
- td label
53
- {
54
- background: orange;
55
- color: #fff;
56
- display: inline-block;
57
- border-radius: 3px;
58
- padding: 5px;
59
- font-size: 11px;
60
- line-height: 11px;
61
- vertical-align: baseline;
62
- }
63
-
64
- tr
65
- {
66
- td:first-child
67
- {
68
- nobr
69
- {
70
- font-weight: bold;
71
- }
72
-
73
- text-align: right;
74
-
75
- form
76
- {
77
- display: block;
78
- }
79
- }
80
-
81
- td.fs-right
82
- {
83
- text-align: right;
84
- }
85
-
86
- &.fs-odd
87
- {
88
- background: #ebebeb;
89
- }
90
- }
91
-
92
- td, th
93
- {
94
- padding: 10px;
95
- }
96
-
97
- var, code
98
- {
99
- color: #0073AA;
100
- font-size: 16px;
101
- background: none;
102
- }
103
- }
104
-
105
- #fs_addons
106
- {
107
- td:first-child,
108
- th:first-child
109
- {
110
- text-align: left;
111
- font-weight: bold;
112
- }
113
- td:last-child,
114
- th:last-child
115
- {
116
- text-align: right;
117
- }
118
- th
119
- {
120
- font-weight: bold;
121
- }
122
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/admin/add-ons.scss DELETED
@@ -1,319 +0,0 @@
1
- @import "../start";
2
-
3
- #fs_addons
4
- {
5
- .fs-cards-list
6
- {
7
- list-style: none;
8
-
9
- .fs-card
10
- {
11
- float: left;
12
- // height: 185px; // With reviews/ratings
13
- height: 152px;
14
- width: 310px;
15
- padding: 0;
16
- margin: 0 0 30px 30px;
17
- font-size: 14px;
18
- list-style: none;
19
- border: 1px solid #ddd;
20
- cursor: pointer;
21
- position: relative;
22
-
23
- .fs-overlay
24
- {
25
- position: absolute;
26
- left: 0;
27
- right: 0;
28
- bottom: 0;
29
- top: 0;
30
- z-index: 9;
31
- }
32
-
33
- .fs-inner
34
- {
35
- background-color: #fff;
36
- overflow: hidden;
37
- height: 100%;
38
- position: relative;
39
-
40
- ul
41
- {
42
- @include transition(all, 0.15s);
43
- left: 0;
44
- right: 0;
45
- top: 0;
46
- position: absolute;
47
-
48
- }
49
-
50
- li
51
- {
52
- list-style: none;
53
- line-height: 18px;
54
- padding: 0 15px;
55
- width: 100%;
56
- display: block;
57
- @include box-sizing(border-box);
58
- }
59
-
60
- .fs-card-banner
61
- {
62
- padding: 0;
63
- margin: 0;
64
- line-height: 0;
65
- display: block;
66
- height: 100px;
67
- background-repeat: repeat-x;
68
- background-size: 100% 100%;
69
- @include transition(all, 0.15s);
70
- }
71
-
72
- .fs-title
73
- {
74
- margin: 10px 0 0 0;
75
- height: 18px;
76
- overflow: hidden;
77
- color: #000;
78
- white-space: nowrap;
79
- text-overflow: ellipsis;
80
- font-weight: bold;
81
- }
82
-
83
- .fs-offer
84
- {
85
- font-size: 0.9em;
86
- }
87
-
88
- .fs-description
89
- {
90
- background-color: #f9f9f9;
91
- padding: 10px 15px 100px 15px;
92
- border-top: 1px solid #eee;
93
- margin: 0 0 10px 0;
94
- color: #777;
95
- }
96
- }
97
-
98
- @media screen and (min-width: 960px) {
99
- &:hover
100
- {
101
- .fs-overlay
102
- {
103
- border: 2px solid $fms-link-color;
104
- margin-left: -1px;
105
- margin-top: -1px;
106
- }
107
-
108
- .fs-inner
109
- {
110
- ul
111
- {
112
- top: -100px;
113
- }
114
-
115
- .fs-card-banner
116
- {
117
- // background-position: 50% -100px;
118
- }
119
-
120
- .fs-title,
121
- .fs-offer
122
- {
123
- color: $fms-link-color;
124
- }
125
- }
126
- }
127
- }
128
- }
129
- }
130
- }
131
-
132
- #TB_window
133
- {
134
- &, iframe
135
- {
136
- width: 772px !important;
137
- }
138
- }
139
-
140
- #plugin-information
141
- {
142
- #section-description
143
- {
144
- h2, h3, p, b, i, blockquote, li, ul, ol
145
- {
146
- clear: none;
147
- }
148
-
149
- .fs-selling-points
150
- {
151
- padding-bottom: 10px;
152
- border-bottom: 1px solid #ddd;
153
-
154
- ul
155
- {
156
- margin: 0;
157
-
158
- li
159
- {
160
- padding: 0;
161
- list-style: none outside none;
162
-
163
- i.dashicons
164
- {
165
- color: $fs-logo-green-color;
166
- font-size: 3em;
167
- vertical-align: middle;
168
- line-height: 30px;
169
- float: left;
170
- margin: 0 0 0 -15px;
171
- }
172
-
173
- h3
174
- {
175
- margin-left: 30px;
176
- }
177
- }
178
- }
179
- }
180
-
181
- .fs-screenshots
182
- {
183
- @include clearfix();
184
- ul
185
- {
186
- list-style: none;
187
- margin: 0;
188
-
189
- li
190
- {
191
- width: 225px;
192
- height: 225px;
193
- float: left;
194
- margin-bottom: 20px;
195
- @include box-sizing(content-box);
196
-
197
- a
198
- {
199
- display: block;
200
- width: 100%;
201
- height: 100%;
202
- border: 1px solid;
203
- @include box-shadow(1px 1px 1px rgba(0,0,0,0.2));
204
- background-size: cover;
205
- }
206
-
207
- &.odd
208
- {
209
- margin-right: 20px;
210
- }
211
- }
212
- }
213
- }
214
- }
215
-
216
- .plugin-information-pricing
217
- {
218
- background: #FFFEEC;
219
- margin: -16px;
220
- padding: 20px 20px 50px 20px;
221
- border-bottom: 1px solid #DDD;
222
-
223
- h3
224
- {
225
- margin-top: 0;
226
- }
227
-
228
- .button
229
- {
230
- width: 100%;
231
- text-align: center;
232
- font-weight: bold;
233
- text-transform: uppercase;
234
- font-size: 1.1em;
235
- }
236
-
237
- label
238
- {
239
- white-space: nowrap;
240
- }
241
- }
242
-
243
- #section-features
244
- {
245
- .fs-features
246
- {
247
- margin: -20px -26px;
248
- }
249
-
250
- table {
251
- width: 100%;
252
- border-spacing: 0;
253
- border-collapse: separate;
254
-
255
- thead {
256
- th
257
- {
258
- padding: 10px 0;
259
- }
260
-
261
- .fs-price
262
- {
263
- color: $fs-logo-green-color;
264
- font-weight: normal;
265
- display: block;
266
- text-align: center;
267
- }
268
- }
269
-
270
- tbody
271
- {
272
- td
273
- {
274
- border-top: 1px solid #ccc;
275
- padding: 10px 0;
276
- text-align: center;
277
- width: 100px;
278
- color: $fs-logo-green-color;
279
-
280
- &:first-child
281
- {
282
- text-align: left;
283
- width: auto;
284
- color: inherit;
285
- padding-left: 26px;
286
- }
287
- }
288
- tr.fs-odd
289
- {
290
- td
291
- {
292
- background: #fefefe;
293
- }
294
- }
295
- }
296
- }
297
-
298
- .dashicons-yes
299
- {
300
- width: 30px;
301
- height: 30px;
302
- font-size: 30px;
303
- }
304
- }
305
- }
306
-
307
- @media screen and (max-width: 961px)
308
- {
309
- #fs_addons
310
- {
311
- .fs-cards-list
312
- {
313
- .fs-card
314
- {
315
- height: 265px;
316
- }
317
- }
318
- }
319
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/admin/common.scss DELETED
@@ -1,109 +0,0 @@
1
- @import "../start";
2
-
3
- .fs-notice
4
- {
5
- position: relative;
6
-
7
- &.fs-has-title
8
- {
9
- margin-bottom: 30px !important;
10
- }
11
-
12
- &.success
13
- {
14
- color: green;
15
- // font-weight: normal;
16
- }
17
-
18
- &.promotion
19
- {
20
- border-color: $fs-notice-promotion-border-color !important;
21
- background-color: $fs-notice-promotion-bkg !important;
22
- }
23
-
24
- .fs-close
25
- {
26
- position: absolute;
27
- top: 10px;
28
- right: 10px;
29
- cursor: pointer;
30
- color: #ccc;
31
-
32
- &:hover
33
- {
34
- color: #aaa;
35
- }
36
- }
37
-
38
- label.fs-plugin-title
39
- {
40
- background: rgba(0, 0, 0, 0.3);
41
- color: #fff;
42
- padding: 2px 10px;
43
- position: absolute;
44
- bottom: -22px;
45
- top: auto;
46
- right: auto;
47
- @include border-radius(0 0 3px 3px);
48
- left: 10px;
49
- font-size: 12px;
50
- font-weight: bold;
51
- cursor: auto;
52
- }
53
- }
54
-
55
- .rtl .fs-notice .fs-close
56
- {
57
- left: 10px;
58
- right: auto;
59
- }
60
-
61
- .fs-secure-notice
62
- {
63
- position: fixed;
64
- top: 32px;
65
- left: 160px;
66
- right: 0;
67
- background: rgb(235, 253, 235);
68
- padding: 10px 20px;
69
- color: green;
70
- z-index: 9999;
71
- box-shadow: 0px 2px 2px rgba(6, 113, 6, 0.3);
72
- @include opacity(0.95);
73
-
74
- &:hover
75
- {
76
- @include opacity(1);
77
- }
78
- }
79
-
80
- @media screen and (max-width: 960px)
81
- {
82
- .fs-secure-notice
83
- {
84
- left: 36px;
85
- }
86
- }
87
-
88
- @media screen and (max-width: 782px)
89
- {
90
- .fs-secure-notice
91
- {
92
- left: 0;
93
- top: 46px;
94
- text-align: center;
95
- }
96
- }
97
-
98
- span.fs-submenu-item.fs-sub:before {
99
- // Add small arrow.
100
- content: '\21B3';
101
- padding: 0 5px;
102
- }
103
-
104
- .rtl {
105
- span.fs-submenu-item.fs-sub:before {
106
- // Add small RTL arrow.
107
- content: '\21B2';
108
- }
109
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/admin/connect.scss DELETED
@@ -1,263 +0,0 @@
1
- @import "../start";
2
-
3
- $form_width: 480px;
4
-
5
- #fs_connect
6
- {
7
- width: $form_width;
8
- @include box-shadow(0px 1px 2px rgba(0,0,0,0.3));
9
- margin: 20px 0;
10
-
11
- @media screen and (max-width: ($form_width - 1)) {
12
- @include box-shadow(none);
13
- width: auto;
14
- margin: 0 0 0 -10px;
15
- }
16
-
17
- .fs-content
18
- {
19
- background: #fff;
20
- padding: 15px 20px;
21
-
22
- p
23
- {
24
- margin: 0;
25
- padding: 0;
26
- font-size: 1.2em;
27
- }
28
- }
29
-
30
- .fs-actions
31
- {
32
- padding: 10px 20px;
33
- background: #C0C7CA;
34
-
35
- .button
36
- {
37
- padding: 0 10px 1px;
38
- line-height: 35px;
39
- height: 37px;
40
- font-size: 16px;
41
- margin-bottom: 0;
42
-
43
- .dashicons
44
- {
45
- font-size: 37px;
46
- margin-left: -8px;
47
- margin-right: 12px;
48
- }
49
-
50
- &.button-primary
51
- {
52
- padding-right: 15px;
53
- padding-left: 15px;
54
- }
55
-
56
- &.button-secondary
57
- {
58
- float: right;
59
- }
60
- }
61
-
62
- // .fs-skip
63
- // {
64
- // line-height: 38px;
65
- // vertical-align: middle;
66
- // text-decoration: none;
67
- // margin-left: 10px;
68
- // }
69
- }
70
-
71
- &.fs-anonymous-disabled
72
- {
73
- .fs-actions
74
- {
75
- .button.button-primary
76
- {
77
- width: 100%;
78
- }
79
- }
80
- }
81
-
82
- .fs-permissions
83
- {
84
- padding: 10px 20px;
85
- background: #FEFEFE;
86
- // background: #F1F1F1;
87
- @include transition(background 0.5s ease);
88
-
89
- .fs-trigger
90
- {
91
- font-size: 0.9em;
92
- text-decoration: none;
93
- text-align: center;
94
- display: block;
95
- }
96
-
97
- ul
98
- {
99
- height: 0;
100
- overflow: hidden;
101
- margin: 0;
102
-
103
- li
104
- {
105
- margin-bottom: 12px;
106
-
107
- &:last-child
108
- {
109
- margin-bottom: 0;
110
- }
111
-
112
- i.dashicons
113
- {
114
- float: left;
115
- font-size: 40px;
116
- width: 40px;
117
- height: 40px;
118
- }
119
-
120
- div
121
- {
122
- margin-left: 55px;
123
-
124
- span
125
- {
126
- font-weight: bold;
127
- text-transform: uppercase;
128
- color: #23282d;
129
- }
130
-
131
- p
132
- {
133
- margin: 2px 0 0 0;
134
- }
135
- }
136
- }
137
- }
138
-
139
- &.fs-open
140
- {
141
- background: #fff;
142
-
143
- ul
144
- {
145
- height: auto;
146
- margin: 20px 20px 10px 20px;
147
- }
148
- }
149
-
150
- @media screen and (max-width: ($form_width - 1)) {
151
- background: #fff;
152
-
153
- .fs-trigger
154
- {
155
- display: none;
156
- }
157
-
158
- ul
159
- {
160
- height: auto;
161
- margin: 20px;
162
- }
163
- }
164
- }
165
-
166
- $icon_size: 80px;
167
- $wp_logo_padding: $icon_size / 10;
168
- $icons_top: 10px;
169
-
170
- .fs-visual
171
- {
172
- padding: 12px;
173
- line-height: 0;
174
- background: #fafafa;
175
- height: $icon_size;
176
- position: relative;
177
-
178
- .fs-site-icon
179
- {
180
- position: absolute;
181
- left: 20px;
182
- top: $icons_top;
183
- }
184
-
185
- .fs-connect-logo
186
- {
187
- position: absolute;
188
- right: 20px;
189
- top: $icons_top;
190
- }
191
-
192
- .fs-plugin-icon
193
- {
194
- position: absolute;
195
- top: $icons_top;
196
- left: 50%;
197
- margin-left: - ($icon_size / 2);
198
- }
199
-
200
- .fs-plugin-icon,
201
- .fs-site-icon,
202
- img,
203
- object
204
- {
205
- width: $icon_size;
206
- height: $icon_size;
207
- }
208
-
209
- .dashicons-wordpress
210
- {
211
- font-size: $icon_size - ($wp_logo_padding * 2);
212
- background: $wordpress_color;
213
- color: #fff;
214
- width: $icon_size - ($wp_logo_padding * 2);
215
- height: $icon_size - ($wp_logo_padding * 2);
216
- padding: $wp_logo_padding;
217
- }
218
-
219
- .dashicons-plus
220
- {
221
- position: absolute;
222
- top: 50%;
223
- font-size: 30px;
224
- margin-top: -10px;
225
- color: #bbb;
226
-
227
- &.fs-first
228
- {
229
- left: 28%;
230
- }
231
- &.fs-second
232
- {
233
- left: 65%;
234
- }
235
- }
236
-
237
- .fs-plugin-icon,
238
- .fs-connect-logo,
239
- .fs-site-icon
240
- {
241
- border: 1px solid #ccc;
242
- padding: 1px;
243
- background: #fff;
244
- }
245
- }
246
-
247
- .fs-terms
248
- {
249
- text-align: center;
250
- font-size: 0.85em;
251
- padding: 5px;
252
- background: rgba(0,0,0,0.05);
253
-
254
- &, a
255
- {
256
- color: #999;
257
- }
258
-
259
- a {
260
- text-decoration: none;
261
- }
262
- }
263
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/assets/scss/admin/deactivation-feedback.scss DELETED
@@ -1,120 +0,0 @@
1
- .fs-modal {
2
- position: fixed;
3
- overflow: auto;
4
- height: 100%;
5
- width: 100%;
6
- top: 0;
7
- z-index: 100000;
8
- display: none;
9
- background: rgba(0, 0, 0, 0.6);
10
-
11
- .fs-modal-dialog {
12
- background: transparent;
13
- position: absolute;
14
- left: 50%;
15
- margin-left: -298px;
16
- padding-bottom: 30px;
17
- top: -100%;
18
- z-index: 100001;
19
- width: 596px;
20
-
21
- @media (max-width: 650px) {
22
- margin-left: -50%;
23
- box-sizing: border-box;
24
- padding-left: 10px;
25
- padding-right: 10px;
26
- width: 100%;
27
-
28
- .fs-modal-panel > h3 > strong {
29
- font-size: 1.3em;
30
- }
31
-
32
- li.reason {
33
- margin-bottom: 10px;
34
-
35
- .reason-input {
36
- margin-left: 29px;
37
- }
38
-
39
- label {
40
- display: table;
41
-
42
- > span {
43
- display: table-cell;
44
- font-size: 1.3em;
45
- }
46
- }
47
- }
48
- }
49
- }
50
-
51
- &.active {
52
- display: block;
53
-
54
- &:before {
55
- display: block;
56
- }
57
-
58
- .fs-modal-dialog {
59
- top: 10%;
60
- }
61
- }
62
-
63
- .fs-modal-body,
64
- .fs-modal-footer {
65
- border: 0;
66
- background: #fefefe;
67
- padding: 20px;
68
- }
69
-
70
- .fs-modal-body {
71
- border-bottom: 0;
72
-
73
- h2 {
74
- font-size: 20px;
75
- }
76
-
77
- > div {
78
- margin-top: 10px;
79
-
80
- h2 {
81
- font-weight: bold;
82
- font-size: 20px;
83
- margin-top: 0;
84
- }
85
- }
86
- }
87
-
88
- .fs-modal-footer {
89
- border-top: #eeeeee solid 1px;
90
- text-align: right;
91
-
92
- > .button {
93
- margin: 0 7px;
94
-
95
- &:first-child {
96
- margin: 0;
97
- }
98
- }
99
- }
100
-
101
- .fs-modal-panel:not(.active) {
102
- display: none;
103
- }
104
-
105
- .reason-input {
106
- margin: 3px 0 3px 22px;
107
-
108
- input, textarea {
109
- width: 100%;
110
- }
111
- }
112
- }
113
-
114
- body.has-fs-modal {
115
- overflow: hidden;
116
- }
117
-
118
- #the-list .deactivate > .fs-slug {
119
- display: none;
120
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/config.php DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.4
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- define( 'WP_FS__SLUG', 'freemius' );
14
- if ( ! defined( 'WP_FS__DEV_MODE' ) ) {
15
- define( 'WP_FS__DEV_MODE', false );
16
- }
17
-
18
- /**
19
- * API Connectivity Simulation
20
- */
21
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY', false && WP_FS__DEV_MODE );
22
- define( 'WP_FS__SIMULATE_NO_CURL', false && WP_FS__DEV_MODE );
23
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false && WP_FS__DEV_MODE );
24
- define( 'WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false && WP_FS__DEV_MODE );
25
- if ( WP_FS__SIMULATE_NO_CURL ) {
26
- define( 'FS_SDK__SIMULATE_NO_CURL', true );
27
- }
28
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
29
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', true );
30
- }
31
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
32
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', true );
33
- }
34
-
35
- /**
36
- * If your dev environment supports custom public network IP setup
37
- * like VVV, please update WP_FS__LOCALHOST_IP with your public IP
38
- * and uncomment it during dev.
39
- */
40
- if ( ! defined( 'WP_FS__LOCALHOST_IP' ) ) {
41
- // VVV default public network IP.
42
- define( 'WP_FS__VVV_DEFAULT_PUBLIC_IP', '192.168.50.4' );
43
-
44
- // define( 'WP_FS__LOCALHOST_IP', WP_FS__VVV_DEFAULT_PUBLIC_IP );
45
- }
46
-
47
- /**
48
- * If true and running with secret key, the opt-in process
49
- * will skip the email activation process which is invoked
50
- * when the email of the context user already exist in Freemius
51
- * database (as a security precaution, to prevent sharing user
52
- * secret with unauthorized entity).
53
- *
54
- * IMPORTANT:
55
- * AS A SECURITY PRECAUTION, WE VALIDATE THE TIMESTAMP OF THE OPT-IN REQUEST.
56
- * THEREFORE, MAKE SURE THAT WHEN USING THIS PARAMETER,YOUR TESTING ENVIRONMENT'S
57
- * CLOCK IS SYNCED.
58
- */
59
- define( 'WP_FS__SKIP_EMAIL_ACTIVATION', false );
60
-
61
-
62
- /**
63
- * Directories
64
- */
65
- define( 'WP_FS__DIR', dirname( __FILE__ ) );
66
- define( 'WP_FS__DIR_INCLUDES', WP_FS__DIR . '/includes' );
67
- define( 'WP_FS__DIR_TEMPLATES', WP_FS__DIR . '/templates' );
68
- define( 'WP_FS__DIR_ASSETS', WP_FS__DIR . '/assets' );
69
- define( 'WP_FS__DIR_CSS', WP_FS__DIR_ASSETS . '/css' );
70
- define( 'WP_FS__DIR_JS', WP_FS__DIR_ASSETS . '/js' );
71
- define( 'WP_FS__DIR_IMG', WP_FS__DIR_ASSETS . '/img' );
72
- define( 'WP_FS__DIR_SDK', WP_FS__DIR_INCLUDES . '/sdk' );
73
-
74
-
75
- /**
76
- * Domain / URL / Address
77
- */
78
- define( 'WP_FS__TESTING_DOMAIN', 'fswp:8080' );
79
- define( 'WP_FS__DOMAIN_PRODUCTION', 'wp.freemius.com' );
80
- define( 'WP_FS__DOMAIN_LOCALHOST', 'wp.freemius' );
81
- define( 'WP_FS__ADDRESS_LOCALHOST', 'http://' . WP_FS__DOMAIN_LOCALHOST . ':8080' );
82
- define( 'WP_FS__ADDRESS_PRODUCTION', 'https://' . WP_FS__DOMAIN_PRODUCTION );
83
-
84
- define( 'WP_FS__IS_PRODUCTION_MODE', ! defined( 'WP_FS__DEV_MODE' ) || ! WP_FS__DEV_MODE || ( WP_FS__TESTING_DOMAIN !== $_SERVER['HTTP_HOST'] ) );
85
-
86
- define( 'WP_FS__ADDRESS', ( WP_FS__IS_PRODUCTION_MODE ? WP_FS__ADDRESS_PRODUCTION : WP_FS__ADDRESS_LOCALHOST ) );
87
-
88
- if ( defined( 'WP_FS__LOCALHOST_IP' ) ) {
89
- define( 'WP_FS__IS_LOCALHOST', ( WP_FS__LOCALHOST_IP == $_SERVER['REMOTE_ADDR'] ) );
90
- } else {
91
- define( 'WP_FS__IS_LOCALHOST', ( substr( $_SERVER['REMOTE_ADDR'], 0, 4 ) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1' ) );
92
- }
93
-
94
- define( 'WP_FS__IS_LOCALHOST_FOR_SERVER', ( false !== strpos( $_SERVER['HTTP_HOST'], 'localhost' ) ) );
95
-
96
- // Set API address for local testing.
97
- if ( ! WP_FS__IS_PRODUCTION_MODE ) {
98
- define( 'FS_API__ADDRESS', 'http://api.freemius:8080' );
99
- define( 'FS_API__SANDBOX_ADDRESS', 'http://sandbox-api.freemius:8080' );
100
- }
101
-
102
- define( 'WP_FS___OPTION_PREFIX', 'fs' . ( WP_FS__IS_PRODUCTION_MODE ? '' : '_dbg' ) . '_' );
103
-
104
- if ( ! defined( 'WP_FS__ACCOUNTS_OPTION_NAME' ) ) {
105
- define( 'WP_FS__ACCOUNTS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'accounts' );
106
- }
107
- if ( ! defined( 'WP_FS__API_CACHE_OPTION_NAME' ) ) {
108
- define( 'WP_FS__API_CACHE_OPTION_NAME', WP_FS___OPTION_PREFIX . 'api_cache' );
109
- }
110
- define( 'WP_FS__OPTIONS_OPTION_NAME', WP_FS___OPTION_PREFIX . 'options' );
111
-
112
- define( 'WP_FS__IS_HTTPS', (
113
- // Checks if CloudFlare's HTTPS (Flexible SSL support)
114
- isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' === strtolower( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) ) ||
115
- // Check if HTTPS request.
116
- ( isset( $_SERVER['HTTPS'] ) && 'on' == $_SERVER['HTTPS'] ) ||
117
- ( isset( $_SERVER['SERVER_PORT'] ) && 443 == $_SERVER['SERVER_PORT'] )
118
- );
119
-
120
- define( 'WP_FS__IS_POST_REQUEST', ( strtoupper( $_SERVER['REQUEST_METHOD'] ) == 'POST' ) );
121
-
122
- /**
123
- * Billing Frequencies
124
- */
125
- define( 'WP_FS__PERIOD_ANNUALLY', 'annual' );
126
- define( 'WP_FS__PERIOD_MONTHLY', 'monthly' );
127
- define( 'WP_FS__PERIOD_LIFETIME', 'lifetime' );
128
-
129
- /**
130
- * Plans
131
- */
132
- define( 'WP_FS__PLAN_DEFAULT_PAID', false );
133
- define( 'WP_FS__PLAN_FREE', 'free' );
134
- define( 'WP_FS__PLAN_TRIAL', 'trial' );
135
-
136
- /**
137
- * Times in seconds
138
- */
139
- // define( 'WP_FS__TIME_5_MIN_IN_SEC', 300 );
140
- define( 'WP_FS__TIME_10_MIN_IN_SEC', 600 );
141
- // define( 'WP_FS__TIME_15_MIN_IN_SEC', 900 );
142
- define( 'WP_FS__TIME_24_HOURS_IN_SEC', 86400 );
143
-
144
- /**
145
- * Debugging
146
- */
147
- define( 'WP_FS__DEBUG_SDK', ! empty( $_GET['fs_dbg'] ) );
148
- define( 'WP_FS__ECHO_DEBUG_SDK', ! empty( $_GET['fs_dbg_echo'] ) );
149
- define( 'WP_FS__LOG_DATETIME_FORMAT', 'Y-n-d H:i:s' );
150
-
151
- if ( WP_FS__ECHO_DEBUG_SDK ) {
152
- error_reporting( E_ALL );
153
- ini_set( 'error_reporting', E_ALL );
154
- ini_set( 'display_errors', true );
155
- ini_set( 'html_errors', true );
156
- }
157
-
158
-
159
- define( 'WP_FS__SCRIPT_START_TIME', time() );
160
- define( 'WP_FS__LOWEST_PRIORITY', 999999999 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-freemius-abstract.php DELETED
@@ -1,382 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.7
7
- */
8
- if ( ! defined( 'ABSPATH' ) ) {
9
- exit;
10
- }
11
-
12
-
13
- /**
14
- * - Each instance of Freemius class represents a single plugin
15
- * install by a single user (the installer of the plugin).
16
- *
17
- * - Each website can only have one install of the same plugin.
18
- *
19
- * - Install entity is only created after a user connects his account with Freemius.
20
- *
21
- * Class Freemius_Abstract
22
- */
23
- abstract class Freemius_Abstract {
24
-
25
- #region Identity ------------------------------------------------------------------
26
-
27
- /**
28
- * Check if user registered with Freemius by connecting his account.
29
- *
30
- * @since 1.0.1
31
- * @return bool
32
- */
33
- abstract function is_registered();
34
-
35
- /**
36
- * Check if the user skipped connecting the account with Freemius.
37
- *
38
- * @since 1.0.7
39
- *
40
- * @return bool
41
- */
42
- abstract function is_anonymous();
43
-
44
- /**
45
- * Check if the user currently in activation mode.
46
- *
47
- * @since 1.0.7
48
- *
49
- * @return bool
50
- */
51
- abstract function is_activation_mode();
52
-
53
- #endregion Identity ------------------------------------------------------------------
54
-
55
- #region Permissions ------------------------------------------------------------------
56
-
57
- /**
58
- * Check if plugin must be WordPress.org compliant.
59
- *
60
- * @since 1.0.7
61
- *
62
- * @return bool
63
- */
64
- abstract function is_org_repo_compliant();
65
-
66
- /**
67
- * Check if plugin is allowed to install executable files.
68
- *
69
- * @author Vova Feldman (@svovaf)
70
- * @since 1.0.5
71
- *
72
- * @return bool
73
- */
74
- function is_allowed_to_install() {
75
- return ( $this->is_premium() || ! $this->is_org_repo_compliant() );
76
- }
77
-
78
- #endregion Permissions ------------------------------------------------------------------
79
-
80
- /**
81
- * Check if user in trial or in free plan (not paying).
82
- *
83
- * @author Vova Feldman (@svovaf)
84
- * @since 1.0.4
85
- *
86
- * @return bool
87
- */
88
- function is_not_paying() {
89
- return ( $this->is_trial() || $this->is_free_plan() );
90
- }
91
-
92
- /**
93
- * Check if the user has an activated and valid paid license on current plugin's install.
94
- *
95
- * @since 1.0.9
96
- *
97
- * @return bool
98
- */
99
- abstract function is_paying();
100
-
101
- /**
102
- * Check if the user is paying or in trial.
103
- *
104
- * @since 1.0.9
105
- *
106
- * @return bool
107
- */
108
- function is_paying_or_trial() {
109
- return ( $this->is_paying() || $this->is_trial() );
110
- }
111
-
112
- #region Premium Only ------------------------------------------------------------------
113
-
114
- /**
115
- * All logic wrapped in methods with "__premium_only()" suffix will be only
116
- * included in the premium code.
117
- *
118
- * Example:
119
- * if ( freemius()->is__premium_only() ) {
120
- * ...
121
- * }
122
- */
123
-
124
- /**
125
- * Returns true when running premium plugin code.
126
- *
127
- * @since 1.0.9
128
- *
129
- * @return bool
130
- */
131
- function is__premium_only() {
132
- return $this->is_premium();
133
- }
134
-
135
- /**
136
- * Check if the user has an activated and valid paid license on current plugin's install.
137
- *
138
- * @since 1.0.9
139
- *
140
- * @return bool
141
- *
142
- */
143
- function is_paying__premium_only() {
144
- return ( $this->is__premium_only() && $this->is_paying() );
145
- }
146
-
147
- /**
148
- * All code wrapped in this statement will be only included in the premium code.
149
- *
150
- * @since 1.0.9
151
- *
152
- * @param string $plan Plan name
153
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
154
- *
155
- * @return bool
156
- */
157
- function is_plan__premium_only( $plan, $exact = false ) {
158
- return ( $this->is_premium() && $this->is_plan( $plan, $exact ) );
159
- }
160
-
161
- /**
162
- * Check if plan matches active license' plan or active trial license' plan.
163
- *
164
- * All code wrapped in this statement will be only included in the premium code.
165
- *
166
- * @since 1.0.9
167
- *
168
- * @param string $plan Plan name
169
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
170
- *
171
- * @return bool
172
- */
173
- function is_plan_or_trial__premium_only( $plan, $exact = false ) {
174
- return ( $this->is_premium() && $this->is_plan_or_trial( $plan, $exact ) );
175
- }
176
-
177
- /**
178
- * Check if the user is paying or in trial.
179
- *
180
- * All code wrapped in this statement will be only included in the premium code.
181
- *
182
- * @since 1.0.9
183
- *
184
- * @return bool
185
- */
186
- function is_paying_or_trial__premium_only() {
187
- return $this->is_premium() && $this->is_paying_or_trial();
188
- }
189
-
190
- /**
191
- * Check if the user has an activated and valid paid license on current plugin's install.
192
- *
193
- * @since 1.0.4
194
- *
195
- * @return bool
196
- *
197
- * @deprecated Method name is confusing since it's not clear from the name the code will be removed.
198
- * @using Alias to is_paying__premium_only()
199
- */
200
- function is_paying__fs__() {
201
- return $this->is_paying__premium_only();
202
- }
203
-
204
- #endregion Premium Only ------------------------------------------------------------------
205
-
206
- #region Trial ------------------------------------------------------------------
207
-
208
- /**
209
- * Check if the user in a trial.
210
- *
211
- * @since 1.0.3
212
- *
213
- * @return bool
214
- */
215
- abstract function is_trial();
216
-
217
- /**
218
- * Check if trial already utilized.
219
- *
220
- * @since 1.0.9
221
- *
222
- * @return bool
223
- */
224
- abstract function is_trial_utilized();
225
-
226
- #endregion Trial ------------------------------------------------------------------
227
-
228
- #region Plans ------------------------------------------------------------------
229
-
230
- /**
231
- * Check if plugin using the free plan.
232
- *
233
- * @since 1.0.4
234
- *
235
- * @return bool
236
- */
237
- abstract function is_free_plan();
238
-
239
- /**
240
- * @since 1.0.2
241
- *
242
- * @param string $plan Plan name
243
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
244
- *
245
- * @return bool
246
- */
247
- abstract function is_plan( $plan, $exact = false );
248
-
249
- /**
250
- * Check if plan based on trial. If not in trial mode, should return false.
251
- *
252
- * @since 1.0.9
253
- *
254
- * @param string $plan Plan name
255
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
256
- *
257
- * @return bool
258
- */
259
- abstract function is_trial_plan( $plan, $exact = false );
260
-
261
- /**
262
- * Check if plan matches active license' plan or active trial license' plan.
263
- *
264
- * @since 1.0.9
265
- *
266
- * @param string $plan Plan name
267
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
268
- *
269
- * @return bool
270
- */
271
- function is_plan_or_trial( $plan, $exact = false ) {
272
- return $this->is_plan( $plan, $exact ) ||
273
- $this->is_trial_plan( $plan, $exact );
274
- }
275
-
276
- /**
277
- * Check if plugin has any paid plans.
278
- *
279
- * @author Vova Feldman (@svovaf)
280
- * @since 1.0.7
281
- *
282
- * @return bool
283
- */
284
- abstract function has_paid_plan();
285
-
286
- /**
287
- * Check if plugin has any free plan, or is it premium only.
288
- *
289
- * Note: If no plans configured, assume plugin is free.
290
- *
291
- * @author Vova Feldman (@svovaf)
292
- * @since 1.0.7
293
- *
294
- * @return bool
295
- */
296
- abstract function has_free_plan();
297
-
298
- #endregion Plans ------------------------------------------------------------------
299
-
300
- /**
301
- * Check if running payments in sandbox mode.
302
- *
303
- * @since 1.0.4
304
- *
305
- * @return bool
306
- */
307
- abstract function is_payments_sandbox();
308
-
309
- /**
310
- * Check if running test vs. live plugin.
311
- *
312
- * @since 1.0.5
313
- *
314
- * @return bool
315
- */
316
- abstract function is_live();
317
-
318
- /**
319
- * Check if running premium plugin code.
320
- *
321
- * @since 1.0.5
322
- *
323
- * @return bool
324
- */
325
- abstract function is_premium();
326
-
327
- /**
328
- * Get upgrade URL.
329
- *
330
- * @author Vova Feldman (@svovaf)
331
- * @since 1.0.2
332
- *
333
- * @param string $period Billing cycle
334
- *
335
- * @return string
336
- */
337
- abstract function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY );
338
-
339
- #region Marketing ------------------------------------------------------------------
340
-
341
- /**
342
- * Check if current user purchased any other plugins before.
343
- *
344
- * @author Vova Feldman (@svovaf)
345
- * @since 1.0.9
346
- *
347
- * @return bool
348
- */
349
- abstract function has_purchased_before();
350
-
351
- /**
352
- * Check if current user classified as an agency.
353
- *
354
- * @author Vova Feldman (@svovaf)
355
- * @since 1.0.9
356
- *
357
- * @return bool
358
- */
359
- abstract function is_agency();
360
-
361
- /**
362
- * Check if current user classified as a developer.
363
- *
364
- * @author Vova Feldman (@svovaf)
365
- * @since 1.0.9
366
- *
367
- * @return bool
368
- */
369
- abstract function is_developer();
370
-
371
- /**
372
- * Check if current user classified as a business.
373
- *
374
- * @author Vova Feldman (@svovaf)
375
- * @since 1.0.9
376
- *
377
- * @return bool
378
- */
379
- abstract function is_business();
380
-
381
- #endregion ------------------------------------------------------------------
382
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-freemius.php DELETED
@@ -1,7527 +0,0 @@
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" only supported since PHP 5.
13
- class Freemius extends Freemius_Abstract {
14
- /**
15
- * SDK Version
16
- *
17
- * @var string
18
- */
19
- public $version = '1.1.4';
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.0.8
101
- * @var bool Hints the SDK if the plugin has any paid plans.
102
- */
103
- private $_has_paid_plans;
104
-
105
- /**
106
- * @since 1.0.7
107
- * @var bool Hints the SDK if the plugin is WordPress.org compliant.
108
- */
109
- private $_is_org_compliant;
110
-
111
- /**
112
- * @since 1.0.7
113
- * @var bool Hints the SDK if the plugin is has add-ons.
114
- */
115
- private $_has_addons;
116
-
117
- /**
118
- * @var FS_Key_Value_Storage
119
- */
120
- private $_storage;
121
-
122
- /**
123
- * @since 1.0.0
124
- *
125
- * @var FS_Logger
126
- */
127
- private $_logger;
128
- /**
129
- * @since 1.0.4
130
- *
131
- * @var FS_Plugin
132
- */
133
- private $_plugin = false;
134
- /**
135
- * @since 1.0.4
136
- *
137
- * @var FS_Plugin
138
- */
139
- private $_parent_plugin = false;
140
- /**
141
- * @since 1.1.1
142
- *
143
- * @var Freemius
144
- */
145
- private $_parent = false;
146
- /**
147
- * @since 1.0.1
148
- *
149
- * @var FS_User
150
- */
151
- private $_user = false;
152
- /**
153
- * @since 1.0.1
154
- *
155
- * @var FS_Site
156
- */
157
- private $_site = false;
158
- /**
159
- * @since 1.0.1
160
- *
161
- * @var FS_Plugin_License
162
- */
163
- private $_license;
164
- /**
165
- * @since 1.0.2
166
- *
167
- * @var FS_Plugin_Plan[]
168
- */
169
- private $_plans = false;
170
- /**
171
- * @var FS_Plugin_License[]
172
- * @since 1.0.5
173
- */
174
- private $_licenses = false;
175
-
176
- /**
177
- * @since 1.0.1
178
- *
179
- * @var FS_Admin_Menu_Manager
180
- */
181
- private $_menu;
182
-
183
- /**
184
- * @var FS_Admin_Notice_Manager
185
- */
186
- private $_admin_notices;
187
-
188
- /**
189
- * @var FS_Logger
190
- * @since 1.0.0
191
- */
192
- private static $_static_logger;
193
-
194
- /**
195
- * @var FS_Option_Manager
196
- * @since 1.0.2
197
- */
198
- private static $_accounts;
199
-
200
- /**
201
- * @var Freemius[]
202
- */
203
- private static $_instances = array();
204
-
205
-
206
- /* Ctor
207
- ------------------------------------------------------------------------------------------------------------------*/
208
-
209
- private function __construct( $slug ) {
210
- $this->_slug = $slug;
211
-
212
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
213
-
214
- $this->_storage = FS_Key_Value_Storage::instance( 'plugin_data', $this->_slug );
215
-
216
- $this->_plugin_main_file_path = $this->_find_caller_plugin_file();
217
- $this->_plugin_dir_path = plugin_dir_path( $this->_plugin_main_file_path );
218
- $this->_plugin_basename = plugin_basename( $this->_plugin_main_file_path );
219
- $this->_free_plugin_basename = str_replace( '-premium/', '/', $this->_plugin_basename );
220
-
221
- $base_name_split = explode( '/', $this->_plugin_basename );
222
- $this->_plugin_dir_name = $base_name_split[0];
223
-
224
- if ( $this->_logger->is_on() ) {
225
- $this->_logger->info( 'plugin_main_file_path = ' . $this->_plugin_main_file_path );
226
- $this->_logger->info( 'plugin_dir_path = ' . $this->_plugin_dir_path );
227
- $this->_logger->info( 'plugin_basename = ' . $this->_plugin_basename );
228
- $this->_logger->info( 'free_plugin_basename = ' . $this->_free_plugin_basename );
229
- $this->_logger->info( 'plugin_dir_name = ' . $this->_plugin_dir_name );
230
- }
231
-
232
- // Remember link between file to slug.
233
- $this->store_file_slug_map();
234
-
235
- // Store plugin's initial install timestamp.
236
- if ( ! isset( $this->_storage->install_timestamp ) ) {
237
- $this->_storage->install_timestamp = WP_FS__SCRIPT_START_TIME;
238
- }
239
-
240
- $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->get();
241
-
242
- $this->_admin_notices = FS_Admin_Notice_Manager::instance(
243
- $slug,
244
- is_object( $this->_plugin ) ? $this->_plugin->title : ''
245
- );
246
-
247
- if ( 'true' === fs_request_get( 'fs_clear_api_cache' ) ) {
248
- FS_Api::clear_cache();
249
- }
250
-
251
- $this->_register_hooks();
252
-
253
- $this->_load_account();
254
-
255
- $this->_version_updates_handler();
256
- }
257
-
258
- /**
259
- * @author Vova Feldman (@svovaf)
260
- * @since 1.0.9
261
- */
262
- private function _version_updates_handler() {
263
- if ( ! isset( $this->_storage->sdk_version ) || $this->_storage->sdk_version != $this->version ) {
264
- // Freemius version upgrade mode.
265
- $this->_storage->sdk_last_version = $this->_storage->sdk_version;
266
- $this->_storage->sdk_version = $this->version;
267
-
268
- if ( empty( $this->_storage->sdk_last_version ) ||
269
- version_compare( $this->_storage->sdk_last_version, $this->version, '<' )
270
- ) {
271
- $this->_storage->sdk_upgrade_mode = true;
272
- $this->_storage->sdk_downgrade_mode = false;
273
- } else {
274
- $this->_storage->sdk_downgrade_mode = true;
275
- $this->_storage->sdk_upgrade_mode = false;
276
-
277
- }
278
-
279
- $this->do_action( 'sdk_version_update' );
280
- }
281
-
282
- $plugin_version = $this->get_plugin_version();
283
- if ( ! isset( $this->_storage->plugin_version ) || $this->_storage->plugin_version != $plugin_version ) {
284
- // Plugin version upgrade mode.
285
- $this->_storage->plugin_last_version = $this->_storage->plugin_version;
286
- $this->_storage->plugin_version = $plugin_version;
287
-
288
- if ( empty( $this->_storage->plugin_last_version ) ||
289
- version_compare( $this->_storage->plugin_last_version, $plugin_version, '<' )
290
- ) {
291
- $this->_storage->plugin_upgrade_mode = true;
292
- $this->_storage->plugin_downgrade_mode = false;
293
- } else {
294
- $this->_storage->plugin_downgrade_mode = true;
295
- $this->_storage->plugin_upgrade_mode = false;
296
- }
297
-
298
- $this->do_action( 'plugin_version_update' );
299
- }
300
- }
301
-
302
- /**
303
- * @author Vova Feldman (@svovaf)
304
- * @since 1.0.9
305
- */
306
- private function _register_hooks() {
307
- if ( is_admin() ) {
308
- // Hook to plugin activation
309
- register_activation_hook( $this->_plugin_main_file_path, array(
310
- &$this,
311
- '_activate_plugin_event_hook'
312
- ) );
313
-
314
- // Hook to plugin uninstall.
315
- register_uninstall_hook( $this->_plugin_main_file_path, array( 'Freemius', '_uninstall_plugin_hook' ) );
316
-
317
- if ( ! $this->is_ajax() ) {
318
- if ( ! $this->is_addon() ) {
319
- add_action( 'init', array( &$this, '_add_default_submenu_items' ), WP_FS__LOWEST_PRIORITY );
320
- add_action( 'admin_menu', array( &$this, '_prepare_admin_menu' ), WP_FS__LOWEST_PRIORITY );
321
- }
322
- }
323
- }
324
-
325
- register_deactivation_hook( $this->_plugin_main_file_path, array( &$this, '_deactivate_plugin_hook' ) );
326
-
327
- add_action( 'init', array( &$this, '_redirect_on_clicked_menu_link' ), WP_FS__LOWEST_PRIORITY );
328
-
329
- $this->add_action( 'after_plans_sync', array( &$this, '_check_for_trial_plans' ) );
330
- }
331
-
332
- /**
333
- * @author Vova Feldman (@svovaf)
334
- * @since 1.0.9
335
- */
336
- private function _register_account_hooks() {
337
- if ( is_admin() ) {
338
- if ( ! $this->is_ajax() ) {
339
- if ( $this->has_trial_plan() ) {
340
- $last_time_trial_promotion_shown = $this->_storage->get( 'trial_promotion_shown', false );
341
- if ( ! $this->_site->is_trial_utilized() &&
342
- (
343
- // Show promotion if never shown it yet and 24 hours after initial activation.
344
- ( false === $last_time_trial_promotion_shown && $this->_storage->activation_timestamp < ( time() - WP_FS__TIME_24_HOURS_IN_SEC ) ) ||
345
- // Show promotion in every 30 days.
346
- ( is_numeric( $last_time_trial_promotion_shown ) && 30 * WP_FS__TIME_24_HOURS_IN_SEC < time() - $last_time_trial_promotion_shown ) )
347
- ) {
348
- $this->add_action( 'after_init_plugin_registered', array( &$this, '_add_trial_notice' ) );
349
- }
350
- }
351
- }
352
-
353
- // If user is paying or in trial and have the free version installed,
354
- // assume that the deactivation is for the upgrade process.
355
- if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
356
- add_action( 'wp_ajax_submit-uninstall-reason', array( &$this, '_submit_uninstall_reason_action' ) );
357
-
358
- global $pagenow;
359
- if ( 'plugins.php' === $pagenow ) {
360
- add_action( 'admin_footer', array( &$this, '_add_deactivation_feedback_dialog_box' ) );
361
- }
362
- }
363
- }
364
- }
365
-
366
- /**
367
- * Displays a confirmation and feedback dialog box when the user clicks on the "Deactivate" link on the plugins
368
- * page.
369
- *
370
- * @author Vova Feldman (@svovaf)
371
- * @author Leo Fajardo (@leorw)
372
- * @since 1.1.2
373
- */
374
- function _add_deactivation_feedback_dialog_box() {
375
- fs_enqueue_local_style( 'fs_deactivation_feedback', '/admin/deactivation-feedback.css' );
376
-
377
- /* Check the type of user:
378
- * 1. Long-term (long-term)
379
- * 2. Non-registered and non-anonymous short-term (non-registered-and-non-anonymous-short-term).
380
- * 3. Short-term (short-term)
381
- */
382
- $is_long_term_user = true;
383
-
384
- // Check if the site is at least 2 days old.
385
- $time_installed = $this->_storage->install_timestamp;
386
-
387
- // Difference in seconds.
388
- $date_diff = time() - $time_installed;
389
-
390
- // Convert seconds to days.
391
- $date_diff_days = floor( $date_diff / ( 60 * 60 * 24 ) );
392
-
393
- if ( $date_diff_days < 2 ) {
394
- $is_long_term_user = false;
395
- }
396
-
397
- $is_long_term_user = $this->apply_filters( 'is_long_term_user', $is_long_term_user );
398
-
399
- if ( $is_long_term_user ) {
400
- $user_type = 'long-term';
401
- } else {
402
- if ( ! $this->is_registered() && ! $this->is_anonymous() ) {
403
- $user_type = 'non-registered-and-non-anonymous-short-term';
404
- } else {
405
- $user_type = 'short-term';
406
- }
407
- }
408
-
409
- $uninstall_reasons = $this->_get_uninstall_reasons( $user_type );
410
-
411
- // Load the HTML template for the deactivation feedback dialog box.
412
- $vars = array(
413
- 'reasons' => $uninstall_reasons,
414
- 'slug' => $this->_slug
415
- );
416
-
417
- fs_require_once_template( 'deactivation-feedback-modal.php', $vars );
418
- }
419
-
420
- /**
421
- * @author Leo Fajardo (leorw)
422
- * @since 1.1.2
423
- *
424
- * @param string $user_type
425
- *
426
- * @return array The uninstall reasons for the specified user type.
427
- */
428
- function _get_uninstall_reasons( $user_type = 'long-term' ) {
429
- $reason_found_better_plugin = array(
430
- 'id' => 2,
431
- 'text' => __fs( 'reason-found-a-better-plugin' ),
432
- 'input_type' => 'textfield',
433
- 'input_placeholder' => __fs( 'placeholder-plugin-name' )
434
- );
435
-
436
- $reason_other = array(
437
- 'id' => 7,
438
- 'text' => __fs( 'reason-other' ),
439
- 'input_type' => 'textfield',
440
- 'input_placeholder' => ''
441
- );
442
-
443
- $long_term_user_reasons = array(
444
- array(
445
- 'id' => 1,
446
- 'text' => __fs( 'reason-no-longer-needed' ),
447
- 'input_type' => '',
448
- 'input_placeholder' => ''
449
- ),
450
- $reason_found_better_plugin,
451
- array(
452
- 'id' => 3,
453
- 'text' => __fs( 'reason-needed-for-a-short-period' ),
454
- 'input_type' => '',
455
- 'input_placeholder' => ''
456
- ),
457
- array(
458
- 'id' => 4,
459
- 'text' => __fs( 'reason-broke-my-site' ),
460
- 'input_type' => '',
461
- 'input_placeholder' => ''
462
- ),
463
- array(
464
- 'id' => 5,
465
- 'text' => __fs( 'reason-suddenly-stopped-working' ),
466
- 'input_type' => '',
467
- 'input_placeholder' => ''
468
- )
469
- );
470
-
471
- if ( $this->is_paying() ) {
472
- $long_term_user_reasons[] = array(
473
- 'id' => 6,
474
- 'text' => __fs( 'reason-cant-pay-anymore' ),
475
- 'input_type' => 'textfield',
476
- 'input_placeholder' => __fs( 'placeholder-comfortable-price' )
477
- );
478
- }
479
-
480
- $long_term_user_reasons[] = $reason_other;
481
-
482
- $uninstall_reasons = array(
483
- 'long-term' => $long_term_user_reasons,
484
- 'non-registered-and-non-anonymous-short-term' => array(
485
- array(
486
- 'id' => 8,
487
- 'text' => __fs( 'reason-didnt-work' ),
488
- 'input_type' => '',
489
- 'input_placeholder' => ''
490
- ),
491
- array(
492
- 'id' => 9,
493
- 'text' => __fs( 'reason-dont-like-to-share-my-information' ),
494
- 'input_type' => '',
495
- 'input_placeholder' => ''
496
- ),
497
- $reason_found_better_plugin,
498
- $reason_other
499
- ),
500
- 'short-term' => array(
501
- array(
502
- 'id' => 10,
503
- 'text' => __fs( 'reason-couldnt-make-it-work' ),
504
- 'input_type' => '',
505
- 'input_placeholder' => ''
506
- ),
507
- $reason_found_better_plugin,
508
- array(
509
- 'id' => 11,
510
- 'text' => __fs( 'reason-great-but-need-specific-feature' ),
511
- 'input_type' => 'textarea',
512
- 'input_placeholder' => __fs( 'placeholder-feature' )
513
- ),
514
- array(
515
- 'id' => 12,
516
- 'text' => __fs( 'reason-not-working' ),
517
- 'input_type' => 'textarea',
518
- 'input_placeholder' => __fs( 'placeholder-share-what-didnt-work' )
519
- ),
520
- array(
521
- 'id' => 13,
522
- 'text' => __fs( 'reason-not-what-i-was-looking-for' ),
523
- 'input_type' => 'textarea',
524
- 'input_placeholder' => __fs( 'placeholder-what-youve-been-looking-for' )
525
- ),
526
- array(
527
- 'id' => 14,
528
- 'text' => __fs( 'reason-didnt-work-as-expected' ),
529
- 'input_type' => 'textarea',
530
- 'input_placeholder' => __fs( 'placeholder-what-did-you-expect' )
531
- ),
532
- $reason_other
533
- )
534
- );
535
-
536
- $uninstall_reasons = $this->apply_filters( 'uninstall_reasons', $uninstall_reasons );
537
-
538
- return $uninstall_reasons[ $user_type ];
539
- }
540
-
541
- /**
542
- * Called after the user has submitted his reason for deactivating the plugin.
543
- *
544
- * @author Leo Fajardo (@leorw)
545
- * @since 1.1.2
546
- */
547
- function _submit_uninstall_reason_action() {
548
- if ( ! isset( $_POST['reason_id'] ) ) {
549
- exit;
550
- }
551
-
552
- $reason_info = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( $_REQUEST['reason_info'] ) ) : '';
553
-
554
- $reason = (object) array(
555
- 'id' => $_POST['reason_id'],
556
- 'info' => substr( $reason_info, 0, 128 )
557
- );
558
-
559
- $this->_storage->store( 'uninstall_reason', $reason );
560
-
561
- // Print '1' for successful operation.
562
- echo 1;
563
- exit;
564
- }
565
-
566
- /**
567
- * Leverage backtrace to find caller plugin file path.
568
- *
569
- * @author Vova Feldman (@svovaf)
570
- * @since 1.0.6
571
- *
572
- * @return string
573
- */
574
- private function _find_caller_plugin_file() {
575
- $bt = debug_backtrace();
576
- $backtrace_entries_count = count( $bt );
577
-
578
- // Try to load the cached value of the file path.
579
- if ( isset( $this->_storage->plugin_main_file ) ) {
580
- if ( file_exists( $this->_storage->plugin_main_file->path ) ) {
581
- return $this->_storage->plugin_main_file->path;
582
- }
583
- }
584
-
585
- /**
586
- * All the code below will be executed once on activation.
587
- * If the user changes the main plugin's file name, the file_exists()
588
- * will catch it.
589
- */
590
- self::require_plugin_essentials();
591
-
592
- $all_plugins = get_plugins();
593
- $all_plugins_paths = array();
594
-
595
- // Get active plugin's main files real full names (might be symlinks).
596
- foreach ( $all_plugins as $relative_path => &$data ) {
597
- $all_plugins_paths[] = fs_normalize_path( realpath( WP_PLUGIN_DIR . '/' . $relative_path ) );
598
- }
599
-
600
- $plugin_file = null;
601
- for ( $i = 1; $i < $backtrace_entries_count; $i ++ ) {
602
- if ( in_array( fs_normalize_path( $bt[ $i ]['file'] ), $all_plugins_paths ) ) {
603
- $plugin_file = $bt[ $i ]['file'];
604
- break;
605
- }
606
- }
607
-
608
- if ( is_null( $plugin_file ) ) {
609
- // Throw an error to the developer in case of some edge case dev environment.
610
- wp_die( __fs( 'failed-finding-main-path' ), __fs( 'error' ), array( 'back_link' => true ) );
611
- }
612
-
613
- $this->_storage->plugin_main_file = (object) array(
614
- 'path' => fs_normalize_path( $plugin_file ),
615
- );
616
-
617
- return $plugin_file;
618
- }
619
-
620
- #region Instance ------------------------------------------------------------------
621
-
622
- /**
623
- * Main singleton instance.
624
- *
625
- * @author Vova Feldman (@svovaf)
626
- * @since 1.0.0
627
- *
628
- * @param $slug
629
- *
630
- * @return Freemius
631
- */
632
- static function instance( $slug ) {
633
- $slug = strtolower( $slug );
634
-
635
- if ( ! isset( self::$_instances[ $slug ] ) ) {
636
- if ( 0 === count( self::$_instances ) ) {
637
- self::_load_required_static();
638
- }
639
-
640
- self::$_instances[ $slug ] = new Freemius( $slug );
641
- }
642
-
643
- return self::$_instances[ $slug ];
644
- }
645
-
646
- /**
647
- * @author Vova Feldman (@svovaf)
648
- * @since 1.0.6
649
- *
650
- * @param string|number $slug_or_id
651
- *
652
- * @return bool
653
- */
654
- private static function has_instance( $slug_or_id ) {
655
- return ! is_numeric( $slug_or_id ) ?
656
- isset( self::$_instances[ strtolower( $slug_or_id ) ] ) :
657
- ( false !== self::get_instance_by_id( $slug_or_id ) );
658
- }
659
-
660
- /**
661
- * @author Vova Feldman (@svovaf)
662
- * @since 1.0.6
663
- *
664
- * @param $id
665
- *
666
- * @return false|Freemius
667
- */
668
- static function get_instance_by_id( $id ) {
669
- foreach ( self::$_instances as $slug => $instance ) {
670
- if ( $id == $instance->get_id() ) {
671
- return $instance;
672
- }
673
- }
674
-
675
- return false;
676
- }
677
-
678
- /**
679
- *
680
- * @author Vova Feldman (@svovaf)
681
- * @since 1.0.1
682
- *
683
- * @param $plugin_file
684
- *
685
- * @return false|Freemius
686
- */
687
- static function get_instance_by_file( $plugin_file ) {
688
- $slug = self::find_slug_by_basename( $plugin_file );
689
-
690
- return ( false !== $slug ) ?
691
- self::instance( $slug ) :
692
- false;
693
- }
694
-
695
- /**
696
- * @author Vova Feldman (@svovaf)
697
- * @since 1.0.6
698
- *
699
- * @return false|Freemius
700
- */
701
- function get_parent_instance() {
702
- return self::get_instance_by_id( $this->_plugin->parent_plugin_id );
703
- }
704
-
705
- /**
706
- * @author Vova Feldman (@svovaf)
707
- * @since 1.0.6
708
- *
709
- * @param $slug_or_id
710
- *
711
- * @return bool|Freemius
712
- */
713
- function get_addon_instance( $slug_or_id ) {
714
- return ! is_numeric( $slug_or_id ) ?
715
- self::instance( strtolower( $slug_or_id ) ) :
716
- self::get_instance_by_id( $slug_or_id );
717
- }
718
-
719
- #endregion ------------------------------------------------------------------
720
-
721
- /**
722
- * @author Vova Feldman (@svovaf)
723
- * @since 1.0.6
724
- *
725
- * @return bool
726
- */
727
- function is_parent_plugin_installed() {
728
- return self::has_instance( $this->_plugin->parent_plugin_id );
729
- }
730
-
731
- /**
732
- * Check if add-on parent plugin in activation mode.
733
- *
734
- * @author Vova Feldman (@svovaf)
735
- * @since 1.0.7
736
- *
737
- * @return bool
738
- */
739
- function is_parent_in_activation() {
740
- $parent_fs = $this->get_parent_instance();
741
- if ( ! is_object( $parent_fs ) ) {
742
- return false;
743
- }
744
-
745
- return ( $parent_fs->is_activation_mode() );
746
- }
747
-
748
- /**
749
- * Is plugin in activation mode.
750
- *
751
- * @author Vova Feldman (@svovaf)
752
- * @since 1.0.7
753
- *
754
- * @return bool
755
- */
756
- function is_activation_mode() {
757
- return (
758
- ! $this->is_registered() &&
759
- ( ! $this->enable_anonymous() ||
760
- ( ! $this->is_anonymous() && ! $this->is_pending_activation() ) )
761
- );
762
- }
763
-
764
- private static $_statics_loaded = false;
765
-
766
- /**
767
- * Load static resources.
768
- *
769
- * @author Vova Feldman (@svovaf)
770
- * @since 1.0.1
771
- */
772
- private static function _load_required_static() {
773
- if ( self::$_statics_loaded ) {
774
- return;
775
- }
776
-
777
- self::$_static_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
778
-
779
- self::$_static_logger->entrance();
780
-
781
- self::$_accounts = FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
782
-
783
- // Configure which Freemius powered plugins should be auto updated.
784
- // add_filter( 'auto_update_plugin', '_include_plugins_in_auto_update', 10, 2 );
785
-
786
- if ( WP_FS__DEV_MODE ) {
787
- add_action( 'admin_menu', array( 'Freemius', 'add_debug_page' ) );
788
- }
789
-
790
- self::$_statics_loaded = true;
791
- }
792
-
793
- #region Debugging ------------------------------------------------------------------
794
-
795
- /**
796
- * @author Vova Feldman (@svovaf)
797
- * @since 1.0.8
798
- */
799
- static function add_debug_page() {
800
- self::$_static_logger->entrance();
801
-
802
- $hook = add_object_page(
803
- __fs( 'freemius-debug' ),
804
- __fs( 'freemius-debug' ),
805
- 'manage_options',
806
- 'freemius',
807
- array( 'Freemius', '_debug_page_render' )
808
- );
809
-
810
- add_action( "load-$hook", array( 'Freemius', '_debug_page_actions' ) );
811
- }
812
-
813
- /**
814
- * @author Vova Feldman (@svovaf)
815
- * @since 1.0.8
816
- */
817
- static function _debug_page_actions() {
818
- if ( fs_request_is_action( 'delete_all_accounts' ) ) {
819
- check_admin_referer( 'delete_all_accounts' );
820
-
821
- self::$_accounts->clear( true );
822
-
823
- return;
824
- }
825
- }
826
-
827
- /**
828
- * @author Vova Feldman (@svovaf)
829
- * @since 1.0.8
830
- */
831
- static function _debug_page_render() {
832
- self::$_static_logger->entrance();
833
-
834
- $sites = self::get_all_sites();
835
- $users = self::get_all_users();
836
- $addons = self::get_all_addons();
837
- $account_addons = self::get_all_account_addons();
838
-
839
- // $plans = self::get_all_plans();
840
- // $licenses = self::get_all_licenses();
841
-
842
- $vars = array(
843
- 'sites' => $sites,
844
- 'users' => $users,
845
- 'addons' => $addons,
846
- 'account_addons' => $account_addons,
847
- );
848
- fs_require_once_template( 'debug.php', $vars );
849
- }
850
-
851
- #endregion ------------------------------------------------------------------
852
-
853
- #region Connectivity Issues ------------------------------------------------------------------
854
-
855
- /**
856
- * Check if Freemius should be turned on for the current plugin install + version combination. The API query
857
- * will be only invoked once per plugin version (cached locally).
858
- *
859
- * @author Vova Feldman (@svovaf)
860
- * @since 1.0.9
861
- *
862
- * @return bool
863
- */
864
- private function is_on() {
865
- self::$_static_logger->entrance();
866
-
867
- if ( isset( $this->_is_on ) ) {
868
- return $this->_is_on;
869
- }
870
-
871
- // If already installed then sure it's on :)
872
- if ( $this->is_registered() ) {
873
- $this->_is_on = true;
874
-
875
- return $this->_is_on;
876
- }
877
-
878
- $version = $this->get_plugin_version();
879
-
880
- if ( isset( $this->_storage->is_on ) ) {
881
- if ( $version == $this->_storage->is_on['version'] ) {
882
- $this->_is_on = $this->_storage->is_on['is_active'];
883
-
884
- return $this->_is_on;
885
- }
886
- }
887
-
888
- // Defaults to new install.
889
- $is_update = false;
890
- $is_update = $this->apply_filters( 'is_plugin_update', $is_update );
891
-
892
- /**
893
- * Check anonymously if the SDK should be currently activated.
894
- * The logic is based on whether the developer turned Freemius off,
895
- * or set a limit to the number of activations. It's not related to
896
- * any private information of the current WordPress instance.
897
- *
898
- * Note:
899
- * Only the plugin's public key is being shared with the endpoint.
900
- * NO private nor sensitive information is being shared.
901
- */
902
- $result = $this->get_api_plugin_scope()->get(
903
- 'is_active.json?is_update=' . json_encode( $is_update )
904
- );
905
-
906
- $is_active = ! isset( $result->error ) &&
907
- isset( $result->is_active ) &&
908
- is_bool( $result->is_active ) ?
909
- $result->is_active :
910
- false;
911
-
912
- $this->_storage->is_on = array(
913
- 'is_active' => $is_active,
914
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
915
- 'version' => $version,
916
- );
917
-
918
- $this->_is_on = $is_active;
919
-
920
- return $this->_is_on;
921
- }
922
-
923
- /**
924
- * Check if there's any connectivity issue to Freemius API.
925
- *
926
- * @author Vova Feldman (@svovaf)
927
- * @since 1.0.9
928
- *
929
- * @return bool
930
- */
931
- private function has_api_connectivity() {
932
- if ( isset( $this->_has_api_connection ) ) {
933
- return $this->_has_api_connection;
934
- }
935
-
936
- $version = $this->get_plugin_version();
937
-
938
- if ( WP_FS__SIMULATE_NO_API_CONNECTIVITY &&
939
- isset( $this->_storage->connectivity_test ) &&
940
- true === $this->_storage->connectivity_test['is_connected']
941
- ) {
942
- unset( $this->_storage->connectivity_test );
943
- }
944
-
945
- if ( isset( $this->_storage->connectivity_test ) ) {
946
- if ( $version == $this->_storage->connectivity_test['version'] &&
947
- $_SERVER['HTTP_HOST'] == $this->_storage->connectivity_test['host'] &&
948
- $_SERVER['SERVER_ADDR'] == $this->_storage->connectivity_test['server_ip']
949
- ) {
950
- $this->_has_api_connection = $this->_storage->connectivity_test['is_connected'];
951
-
952
- return $this->_has_api_connection;
953
- }
954
- }
955
-
956
- $is_connected = WP_FS__SIMULATE_NO_API_CONNECTIVITY ?
957
- false :
958
- $this->get_api_plugin_scope()->test( $this->get_anonymous_id() );
959
-
960
- if ( ! $is_connected ) {
961
- // 2nd try of connectivity.
962
- $pong = $this->get_api_plugin_scope()->ping( $this->get_anonymous_id() );
963
-
964
- if ( $this->get_api_plugin_scope()->is_valid_ping( $pong ) ) {
965
- $is_connected = true;
966
- } else {
967
- // Another API failure.
968
- $this->_add_connectivity_issue_message( $pong );
969
- }
970
- }
971
-
972
- $this->_storage->connectivity_test = array(
973
- 'is_connected' => $is_connected,
974
- 'host' => $_SERVER['HTTP_HOST'],
975
- 'server_ip' => $_SERVER['SERVER_ADDR'],
976
- 'version' => $version,
977
- );
978
-
979
- $this->_has_api_connection = $is_connected;
980
-
981
- return $this->_has_api_connection;
982
- }
983
-
984
- /**
985
- * Anonymous and unique site identifier (Hash).
986
- *
987
- * @author Vova Feldman (@svovaf)
988
- * @since 1.1.0
989
- *
990
- * @return string
991
- */
992
- function get_anonymous_id() {
993
- if ( ! self::$_accounts->has_option( 'unique_id' ) ) {
994
- $key = get_site_url();
995
-
996
- // If localhost, assign microtime instead of domain.
997
- if ( WP_FS__IS_LOCALHOST || false !== strpos( $key, 'localhost' ) ) {
998
- $key = microtime();
999
- }
1000
-
1001
- self::$_accounts->set_option( 'unique_id', md5( $key ), true );
1002
- }
1003
-
1004
- return self::$_accounts->get_option( 'unique_id' );
1005
- }
1006
-
1007
- /**
1008
- * Generate API connectivity issue message.
1009
- *
1010
- * @author Vova Feldman (@svovaf)
1011
- * @since 1.0.9
1012
- *
1013
- * @param mixed $api_result
1014
- */
1015
- function _add_connectivity_issue_message( $api_result ) {
1016
- if ( $this->_enable_anonymous ) {
1017
- // Don't add message if can run anonymously.
1018
- return;
1019
- }
1020
-
1021
- if ( ! function_exists( 'wp_nonce_url' ) ) {
1022
- require_once( ABSPATH . 'wp-includes/functions.php' );
1023
- }
1024
-
1025
- self::require_pluggable_essentials();
1026
-
1027
- $current_user = wp_get_current_user();
1028
- // $admin_email = get_option( 'admin_email' );
1029
- $admin_email = $current_user->user_email;
1030
-
1031
- $message = false;
1032
- if ( is_object( $api_result ) &&
1033
- isset( $api_result->error )
1034
- ) {
1035
- switch ( $api_result->error->code ) {
1036
- case 'curl_missing':
1037
- $message = sprintf(
1038
- __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1039
- __fs( 'curl-missing-message' ) . ' ' .
1040
- ' %s',
1041
- '<b>' . $this->get_plugin_name() . '</b>',
1042
- sprintf(
1043
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1044
- sprintf(
1045
- '<a class="fs-resolve" data-type="curl" href="#"><b>%s</b></a>%s',
1046
- __fs( 'curl-missing-no-clue-title' ),
1047
- ' - ' . sprintf(
1048
- __fs( 'curl-missing-no-clue-desc' ),
1049
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1050
- )
1051
- ),
1052
- sprintf(
1053
- '<b>%s</b> - %s',
1054
- __fs( 'sysadmin-title' ),
1055
- __fs( 'curl-missing-sysadmin-desc' )
1056
- ),
1057
- sprintf(
1058
- '<a href="%s"><b>%s</b></a>%s',
1059
- 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 ),
1060
- __fs( 'deactivate-plugin-title' ),
1061
- ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1062
- )
1063
- )
1064
- );
1065
- break;
1066
- case 'cloudflare_ddos_protection':
1067
- $message = sprintf(
1068
- __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1069
- __fs( 'cloudflare-blocks-connection-message' ) . ' ' .
1070
- __fs( 'happy-to-resolve-issue-asap' ) .
1071
- ' %s',
1072
- '<b>' . $this->get_plugin_name() . '</b>',
1073
- sprintf(
1074
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1075
- sprintf(
1076
- '<a class="fs-resolve" data-type="cloudflare" href="#"><b>%s</b></a>%s',
1077
- __fs( 'fix-issue-title' ),
1078
- ' - ' . sprintf(
1079
- __fs( 'fix-issue-desc' ),
1080
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1081
- )
1082
- ),
1083
- sprintf(
1084
- '<a href="%s" target="_blank"><b>%s</b></a>%s',
1085
- sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1086
- __fs( 'install-previous-title' ),
1087
- ' - ' . __fs( 'install-previous-desc' )
1088
- ),
1089
- sprintf(
1090
- '<a href="%s"><b>%s</b></a>%s',
1091
- 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 ),
1092
- __fs( 'deactivate-plugin-title' ),
1093
- ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1094
- )
1095
- )
1096
- );
1097
- break;
1098
- case 'squid_cache_block':
1099
- $message = sprintf(
1100
- __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1101
- __fs( 'squid-blocks-connection-message' ) .
1102
- ' %s',
1103
- '<b>' . $this->get_plugin_name() . '</b>',
1104
- sprintf(
1105
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1106
- sprintf(
1107
- '<a class="fs-resolve" data-type="squid" href="#"><b>%s</b></a>%s',
1108
- __fs( 'squid-no-clue-title' ),
1109
- ' - ' . sprintf(
1110
- __fs( 'squid-no-clue-desc' ),
1111
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1112
- )
1113
- ),
1114
- sprintf(
1115
- '<b>%s</b> - %s',
1116
- __fs( 'sysadmin-title' ),
1117
- sprintf(
1118
- __fs( 'squid-sysadmin-desc' ),
1119
- // We use a filter since the plugin might require additional API connectivity.
1120
- '<b>' . implode( ', ', $this->apply_filters( 'api_domains', array( 'api.freemius.com' ) ) ) . '</b>' )
1121
- ),
1122
- sprintf(
1123
- '<a href="%s"><b>%s</b></a>%s',
1124
- 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 ),
1125
- __fs( 'deactivate-plugin-title' ),
1126
- ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1127
- )
1128
- )
1129
- );
1130
- break;
1131
- default:
1132
- $message = __fs( 'connectivity-test-fails-message' );
1133
- break;
1134
- }
1135
- }
1136
-
1137
- if ( false === $message ) {
1138
- $message = sprintf(
1139
- __fs( 'x-requires-access-to-api', 'freemius' ) . ' ' .
1140
- __fs( 'connectivity-test-fails-message' ) . ' ' .
1141
- __fs( 'happy-to-resolve-issue-asap' ) .
1142
- ' %s',
1143
- '<b>' . $this->get_plugin_name() . '</b>',
1144
- sprintf(
1145
- '<ol id="fs_firewall_issue_options"><li>%s</li><li>%s</li><li>%s</li></ol>',
1146
- sprintf(
1147
- '<a class="fs-resolve" data-type="general" href="#"><b>%s</b></a>%s',
1148
- __fs( 'fix-issue-title' ),
1149
- ' - ' . sprintf(
1150
- __fs( 'fix-issue-desc' ),
1151
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1152
- )
1153
- ),
1154
- sprintf(
1155
- '<a href="%s" target="_blank"><b>%s</b></a>%s',
1156
- sprintf( 'https://wordpress.org/plugins/%s/download/', $this->_slug ),
1157
- __fs( 'install-previous-title' ),
1158
- ' - ' . __fs( 'install-previous-desc' )
1159
- ),
1160
- sprintf(
1161
- '<a href="%s"><b>%s</b></a>%s',
1162
- 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 ),
1163
- __fs( 'deactivate-plugin-title' ),
1164
- ' - ' . __fs( 'deactivate-plugin-desc', 'freemius' )
1165
- )
1166
- )
1167
- );
1168
- }
1169
-
1170
- $this->_admin_notices->add_sticky(
1171
- $message,
1172
- 'failed_connect_api',
1173
- __fs( 'oops' ) . '...',
1174
- 'error'
1175
- );
1176
- }
1177
-
1178
- /**
1179
- * Get collection of all active plugins.
1180
- *
1181
- * @author Vova Feldman (@svovaf)
1182
- * @since 1.0.9
1183
- *
1184
- * @return array[string]array
1185
- */
1186
- private function get_active_plugins() {
1187
- self::require_plugin_essentials();
1188
-
1189
- $active_plugin = array();
1190
- $all_plugins = get_plugins();
1191
- $active_plugins_basenames = get_option( 'active_plugins' );
1192
-
1193
- foreach ( $active_plugins_basenames as $plugin_basename ) {
1194
- $active_plugin[ $plugin_basename ] = $all_plugins[ $plugin_basename ];
1195
- }
1196
-
1197
- return $active_plugin;
1198
- }
1199
-
1200
- /**
1201
- * Handle user request to resolve connectivity issue.
1202
- * This method will send an email to Freemius API technical staff for resolution.
1203
- * The email will contain server's info and installed plugins (might be caching issue).
1204
- *
1205
- * @author Vova Feldman (@svovaf)
1206
- * @since 1.0.9
1207
- */
1208
- function _email_about_firewall_issue() {
1209
- $this->_admin_notices->remove_sticky( 'failed_connect_api' );
1210
-
1211
- self::require_pluggable_essentials();
1212
-
1213
- $current_user = wp_get_current_user();
1214
- $admin_email = $current_user->user_email;
1215
-
1216
- $ping = $this->get_api_plugin_scope()->ping();
1217
-
1218
- $error_type = fs_request_get( 'error_type', 'general' );
1219
-
1220
- switch ( $error_type ) {
1221
- case 'squid':
1222
- $title = 'Squid ACL Blocking Issue';
1223
- break;
1224
- case 'cloudflare':
1225
- $title = 'CloudFlare Blocking Issue';
1226
- break;
1227
- default:
1228
- $title = 'API Connectivity Issue';
1229
- break;
1230
- }
1231
-
1232
- $custom_email_sections = array();
1233
-
1234
- if ( 'squid' === $error_type ) {
1235
- // Override the 'Site' email section.
1236
- $custom_email_sections['site'] = array(
1237
- 'rows' => array(
1238
- 'hosting_company' => array( 'Hosting Company', fs_request_get( 'hosting_company' ) )
1239
- )
1240
- );
1241
- }
1242
-
1243
- // Add 'API Error' custom email section.
1244
- $custom_email_sections['api_error'] = array(
1245
- 'title' => 'API Error',
1246
- 'rows' => array(
1247
- 'ping' => array( is_string( $ping ) ? htmlentities( $ping ) : json_encode( $ping ) )
1248
- )
1249
- );
1250
-
1251
- // Send email with technical details to resolve CloudFlare's firewall unnecessary protection.
1252
- $this->send_email(
1253
- 'api@freemius.com', // recipient
1254
- $title . ' [' . $this->get_plugin_name() . ']', // subject
1255
- $custom_email_sections,
1256
- array( "Reply-To: $admin_email <$admin_email>" ) // headers
1257
- );
1258
-
1259
- $this->_admin_notices->add_sticky(
1260
- sprintf(
1261
- __fs( 'fix-request-sent-message' ),
1262
- '<a href="mailto:' . $admin_email . '">' . $admin_email . '</a>'
1263
- ),
1264
- 'server_details_sent'
1265
- );
1266
-
1267
- // Action was taken, tell that API connectivity troubleshooting should be off now.
1268
-
1269
- echo "1";
1270
- exit;
1271
- }
1272
-
1273
- static function _add_firewall_issues_javascript() {
1274
- $params = array();
1275
- fs_require_once_template( 'firewall-issues-js.php', $params );
1276
- }
1277
-
1278
- #endregion Connectivity Issues ------------------------------------------------------------------
1279
-
1280
- #region Email ------------------------------------------------------------------
1281
-
1282
- /**
1283
- * Generates and sends an HTML email with customizable sections.
1284
- *
1285
- * @author Leo Fajardo (@leorw)
1286
- * @since 1.1.2
1287
- *
1288
- * @param string $to_address
1289
- * @param string $subject
1290
- * @param array $sections
1291
- * @param array $headers
1292
- *
1293
- * @return bool Whether the email contents were sent successfully.
1294
- */
1295
- private function send_email(
1296
- $to_address,
1297
- $subject,
1298
- $sections = array(),
1299
- $headers = array()
1300
- ) {
1301
- $default_sections = $this->get_email_sections();
1302
-
1303
- // Insert new sections or replace the default email sections.
1304
- if ( is_array( $sections ) && ! empty( $sections ) ) {
1305
- foreach ( $sections as $section_id => $custom_section ) {
1306
- if ( ! isset( $default_sections[ $section_id ] ) ) {
1307
- // If the section does not exist, add it.
1308
- $default_sections[ $section_id ] = $custom_section;
1309
- } else {
1310
- // If the section already exists, override it.
1311
- $current_section = $default_sections[ $section_id ];
1312
-
1313
- // Replace the current section's title if a custom section title exists.
1314
- if ( isset( $custom_section['title'] ) ) {
1315
- $current_section['title'] = $custom_section['title'];
1316
- }
1317
-
1318
- // Insert new rows under the current section or replace the default rows.
1319
- if ( isset( $custom_section['rows'] ) && is_array( $custom_section['rows'] ) && ! empty( $custom_section['rows'] ) ) {
1320
- foreach ( $custom_section['rows'] as $row_id => $row ) {
1321
- $current_section['rows'][ $row_id ] = $row;
1322
- }
1323
- }
1324
-
1325
- $default_sections[ $section_id ] = $current_section;
1326
- }
1327
- }
1328
- }
1329
-
1330
- $vars = array( 'sections' => $default_sections );
1331
- $message = fs_get_template( 'email.php', $vars );
1332
-
1333
- // Set the type of email to HTML.
1334
- $headers[] = 'Content-type: text/html';
1335
-
1336
- $header_string = implode( "\r\n", $headers );
1337
-
1338
- return wp_mail(
1339
- $to_address,
1340
- $subject,
1341
- $message,
1342
- $header_string
1343
- );
1344
- }
1345
-
1346
- /**
1347
- * Generates the data for the sections of the email content.
1348
- *
1349
- * @author Leo Fajardo (@leorw)
1350
- * @since 1.1.2
1351
- *
1352
- * @return array
1353
- */
1354
- private function get_email_sections() {
1355
- self::require_pluggable_essentials();
1356
-
1357
- // Retrieve the current user's information so that we can get the user's email, first name, and last name below.
1358
- $current_user = wp_get_current_user();
1359
-
1360
- // Retrieve the cURL version information so that we can get the version number below.
1361
- $curl_version_information = curl_version();
1362
-
1363
- $active_plugin = $this->get_active_plugins();
1364
-
1365
- // Generate the list of active plugins separated by new line.
1366
- $active_plugin_string = '';
1367
- foreach ( $active_plugin as $plugin ) {
1368
- $active_plugin_string .= sprintf(
1369
- '<a href="%s">%s</a> [v%s]<br>',
1370
- $plugin['PluginURI'],
1371
- $plugin['Name'],
1372
- $plugin['Version']
1373
- );
1374
- }
1375
-
1376
- // Generate the default email sections.
1377
- $sections = array(
1378
- 'sdk' => array(
1379
- 'title' => 'SDK',
1380
- 'rows' => array(
1381
- 'fs_version' => array( 'FS Version', $this->version ),
1382
- 'curl_version' => array( 'cURL Version', $curl_version_information['version'] )
1383
- )
1384
- ),
1385
- 'plugin' => array(
1386
- 'title' => 'Plugin',
1387
- 'rows' => array(
1388
- 'name' => array( 'Name', $this->get_plugin_name() ),
1389
- 'version' => array( 'Version', $this->get_plugin_version() )
1390
- )
1391
- ),
1392
- 'site' => array(
1393
- 'title' => 'Site',
1394
- 'rows' => array(
1395
- 'address' => array( 'Address', site_url() ),
1396
- 'host' => array(
1397
- 'HTTP_HOST',
1398
- ( ! empty( $_SERVER['HTTP_HOST'] ) ? $_SERVER['HTTP_HOST'] : '' )
1399
- ),
1400
- 'server_addr' => array(
1401
- 'SERVER_ADDR',
1402
- ( ! empty( $_SERVER['SERVER_ADDR'] ) ? '<a href="http://www.projecthoneypot.org/ip_' . $_SERVER['SERVER_ADDR'] . '">' . $_SERVER['SERVER_ADDR'] . '</a>' : '' )
1403
- )
1404
- )
1405
- ),
1406
- 'user' => array(
1407
- 'title' => 'User',
1408
- 'rows' => array(
1409
- 'email' => array( 'Email', $current_user->user_email ),
1410
- 'first' => array( 'First', $current_user->user_firstname ),
1411
- 'last' => array( 'Last', $current_user->user_lastname )
1412
- )
1413
- ),
1414
- 'plugins' => array(
1415
- 'title' => 'Plugins',
1416
- 'rows' => array(
1417
- 'active_plugins' => array( 'Active Plugins', $active_plugin_string )
1418
- )
1419
- ),
1420
- );
1421
-
1422
- // Allow the sections to be modified by other code.
1423
- $sections = $this->apply_filters( 'email_template_sections', $sections );
1424
-
1425
- return $sections;
1426
- }
1427
-
1428
- #endregion Email ------------------------------------------------------------------
1429
-
1430
- #region Initialization ------------------------------------------------------------------
1431
-
1432
- /**
1433
- * Init plugin's Freemius instance.
1434
- *
1435
- * @author Vova Feldman (@svovaf)
1436
- * @since 1.0.1
1437
- *
1438
- * @param number $id
1439
- * @param string $public_key
1440
- * @param bool $is_live
1441
- * @param bool $is_premium
1442
- */
1443
- function init( $id, $public_key, $is_live = true, $is_premium = true ) {
1444
- $this->_logger->entrance();
1445
-
1446
- $this->dynamic_init( array(
1447
- 'id' => $id,
1448
- 'public_key' => $public_key,
1449
- 'is_live' => $is_live,
1450
- 'is_premium' => $is_premium,
1451
- ) );
1452
- }
1453
-
1454
- private function _get_option( &$options, $key, $default = false ) {
1455
- return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
1456
- }
1457
-
1458
- private function _get_bool_option( &$options, $key, $default = false ) {
1459
- return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
1460
- }
1461
-
1462
- private function _get_numeric_option( &$options, $key, $default = false ) {
1463
- return isset( $options[ $key ] ) && is_numeric( $options[ $key ] ) ? $options[ $key ] : $default;
1464
- }
1465
-
1466
- /**
1467
- * Dynamic initiator, originally created to support initiation
1468
- * with parent_id for add-ons.
1469
- *
1470
- * @author Vova Feldman (@svovaf)
1471
- * @since 1.0.6
1472
- *
1473
- * @param array $plugin_info
1474
- *
1475
- * @throws Freemius_Exception
1476
- */
1477
- function dynamic_init( array $plugin_info ) {
1478
- $this->_logger->entrance();
1479
-
1480
- $id = $this->_get_numeric_option( $plugin_info, 'id', false );
1481
- $public_key = $this->_get_option( $plugin_info, 'public_key', false );
1482
- $secret_key = $this->_get_option( $plugin_info, 'secret_key', null );
1483
- $parent_id = $this->_get_numeric_option( $plugin_info, 'parent_id', null );
1484
- $parent_name = $this->_get_option( $plugin_info, 'parent_name', null );
1485
-
1486
- if ( isset( $plugin_info['parent'] ) ) {
1487
- $parent_id = $this->_get_numeric_option( $plugin_info['parent'], 'id', null );
1488
- // $parent_slug = $this->get_option( $plugin_info['parent'], 'slug', null );
1489
- // $parent_public_key = $this->get_option( $plugin_info['parent'], 'public_key', null );
1490
- $parent_name = $this->_get_option( $plugin_info['parent'], 'name', null );
1491
- }
1492
-
1493
- if ( false === $id ) {
1494
- throw new Freemius_Exception( 'Plugin id parameter is not set.' );
1495
- }
1496
- if ( false === $public_key ) {
1497
- throw new Freemius_Exception( 'Plugin public_key parameter is not set.' );
1498
- }
1499
-
1500
- $plugin = ( $this->_plugin instanceof FS_Plugin ) ?
1501
- $this->_plugin :
1502
- new FS_Plugin();
1503
-
1504
- $plugin->update( array(
1505
- 'id' => $id,
1506
- 'public_key' => $public_key,
1507
- 'slug' => $this->_slug,
1508
- 'parent_plugin_id' => $parent_id,
1509
- 'version' => $this->get_plugin_version(),
1510
- 'title' => $this->get_plugin_name(),
1511
- 'file' => $this->_free_plugin_basename,
1512
- 'is_premium' => $this->_get_bool_option( $plugin_info, 'is_premium', true ),
1513
- 'is_live' => $this->_get_bool_option( $plugin_info, 'is_live', true ),
1514
- // 'secret_key' => $secret_key,
1515
- ) );
1516
-
1517
- if ( $plugin->is_updated() ) {
1518
- // Update plugin details.
1519
- $this->_plugin = FS_Plugin_Manager::instance( $this->_slug )->store( $plugin );
1520
- }
1521
- $this->_plugin->secret_key = $secret_key;
1522
-
1523
- if ( ! isset( $plugin_info['menu'] ) ) {
1524
- // Back compatibility to 1.1.2
1525
- $plugin_info['menu'] = array(
1526
- 'slug' => isset( $plugin_info['menu_slug'] ) ?
1527
- $plugin_info['menu_slug'] :
1528
- $this->_slug
1529
- );
1530
- }
1531
-
1532
- $this->_menu = FS_Admin_Menu_Manager::instance( $this->_slug );
1533
- $this->_menu->init( $plugin_info['menu'], $this->is_addon() );
1534
-
1535
- $this->_has_addons = $this->_get_bool_option( $plugin_info, 'has_addons', false );
1536
- $this->_has_paid_plans = $this->_get_bool_option( $plugin_info, 'has_paid_plans', true );
1537
- $this->_is_org_compliant = $this->_get_bool_option( $plugin_info, 'is_org_compliant', true );
1538
- $this->_enable_anonymous = $this->_get_bool_option( $plugin_info, 'enable_anonymous', true );
1539
-
1540
- if ( ! $this->is_registered() ) {
1541
- if ( ! $this->has_api_connectivity() ) {
1542
- if ( is_admin() && $this->_admin_notices->has_sticky( 'failed_connect_api' ) ) {
1543
- if ( ! $this->_enable_anonymous ) {
1544
- // If anonymous mode is disabled, add firewall admin-notice message.
1545
- add_action( 'admin_footer', array( 'Freemius', '_add_firewall_issues_javascript' ) );
1546
-
1547
- add_action( "wp_ajax_{$this->_slug}_resolve_firewall_issues", array(
1548
- &$this,
1549
- '_email_about_firewall_issue'
1550
- ) );
1551
- }
1552
- }
1553
-
1554
- // Turn Freemius off.
1555
- $this->_is_on = false;
1556
-
1557
- return;
1558
- }
1559
-
1560
- // Check if Freemius is on for the current plugin.
1561
- // This MUST be executed after all the plugin variables has been loaded.
1562
- if ( ! $this->is_on() ) {
1563
- return;
1564
- }
1565
- }
1566
-
1567
- if ( false === $this->_background_sync() ) {
1568
- // If background sync wasn't executed,
1569
- // and if the plugin declared it has add-ons but
1570
- // no add-ons found in the local data, then try to sync add-ons.
1571
- if ( $this->_has_addons &&
1572
- ! $this->is_addon() &&
1573
- ( false === $this->get_addons() )
1574
- ) {
1575
- $this->_sync_addons();
1576
- }
1577
- }
1578
-
1579
- if ( $this->is_addon() ) {
1580
- if ( $this->is_parent_plugin_installed() ) {
1581
- // Link to parent FS.
1582
- $this->_parent = self::get_instance_by_id( $parent_id );
1583
-
1584
- // Get parent plugin reference.
1585
- $this->_parent_plugin = $this->_parent->get_plugin();
1586
- }
1587
- }
1588
-
1589
- if ( is_admin() ) {
1590
- global $pagenow;
1591
- if ( 'plugins.php' === $pagenow ) {
1592
- $this->hook_plugin_action_links();
1593
- }
1594
-
1595
- if ( $this->is_addon() ) {
1596
- if ( ! $this->is_parent_plugin_installed() ) {
1597
- $this->_admin_notices->add(
1598
- ( is_string( $parent_name ) ?
1599
- sprintf( __fs( 'addon-cannot-run-without-x' ), $this->get_plugin_name(), $parent_name ) :
1600
- sprintf( __fs( 'addon-x-cannot-run-without-parent' ), $this->get_plugin_name() )
1601
- ),
1602
- __fs( 'oops' ) . '...',
1603
- 'error'
1604
- );
1605
-
1606
- return;
1607
- } else {
1608
- if ( $this->_parent->is_registered() && ! $this->is_registered() ) {
1609
- // If parent plugin activated, automatically install add-on for the user.
1610
- $this->_activate_addon_account( $this->_parent );
1611
- }
1612
-
1613
- // @todo This should be only executed on activation. It should be migrated to register_activation_hook() together with other activation related logic.
1614
- if ( $this->is_premium() ) {
1615
- // Remove add-on download admin-notice.
1616
- $this->_parent->_admin_notices->remove_sticky( 'addon_plan_upgraded_' . $this->_slug );
1617
- }
1618
- }
1619
- } else {
1620
- add_action( 'admin_init', array( &$this, '_admin_init_action' ) );
1621
-
1622
- if ( $this->_has_addons() &&
1623
- 'plugin-information' === fs_request_get( 'tab', false ) &&
1624
- $this->get_id() == fs_request_get( 'parent_plugin_id', false )
1625
- ) {
1626
- // Remove default plugin information action.
1627
- remove_all_actions( 'install_plugins_pre_plugin-information' );
1628
-
1629
- require_once WP_FS__DIR_INCLUDES . '/fs-plugin-functions.php';
1630
-
1631
- // Override action with custom plugins function for add-ons.
1632
- add_action( 'install_plugins_pre_plugin-information', 'fs_install_plugin_information' );
1633
-
1634
- // Override request for plugin information for Add-ons.
1635
- add_filter( 'fs_plugins_api', array( &$this, '_get_addon_info_filter' ), 10, 3 );
1636
- } else {
1637
- if ( $this->is_paying() || $this->_has_addons() ) {
1638
- new FS_Plugin_Updater( $this );
1639
- }
1640
- }
1641
- }
1642
-
1643
- // if ( $this->is_registered() ||
1644
- // $this->is_anonymous() ||
1645
- // $this->is_pending_activation()
1646
- // ) {
1647
- // $this->_init_admin();
1648
- // }
1649
- }
1650
-
1651
- $this->do_action( 'initiated' );
1652
-
1653
- if ( ! $this->is_addon() ) {
1654
- if ( $this->is_registered() ) {
1655
- // Fix for upgrade from versions < 1.0.9.
1656
- if ( ! isset( $this->_storage->activation_timestamp ) ) {
1657
- $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
1658
- }
1659
- if ( $this->_storage->prev_is_premium !== $this->_plugin->is_premium ) {
1660
- if ( isset( $this->_storage->prev_is_premium ) ) {
1661
- add_action( is_admin() ? 'admin_init' : 'init', array(
1662
- &$this,
1663
- '_plugin_code_type_changed'
1664
- ) );
1665
- } else {
1666
- // Set for code type for the first time.
1667
- $this->_storage->prev_is_premium = $this->_plugin->is_premium;
1668
- }
1669
- }
1670
-
1671
- $this->do_action( 'after_init_plugin_registered' );
1672
- } else if ( $this->is_anonymous() ) {
1673
- $this->do_action( 'after_init_plugin_anonymous' );
1674
- } else if ( $this->is_pending_activation() ) {
1675
- $this->do_action( 'after_init_plugin_pending_activations' );
1676
- }
1677
- } else {
1678
- if ( $this->is_registered() ) {
1679
- $this->do_action( 'after_init_addon_registered' );
1680
- } else if ( $this->is_anonymous() ) {
1681
- $this->do_action( 'after_init_addon_anonymous' );
1682
- } else if ( $this->is_pending_activation() ) {
1683
- $this->do_action( 'after_init_addon_pending_activations' );
1684
- }
1685
- }
1686
- }
1687
-
1688
- /**
1689
- * Handles plugin's code type change (free <--> premium).
1690
- *
1691
- * @author Vova Feldman (@svovaf)
1692
- * @since 1.0.9
1693
- */
1694
- function _plugin_code_type_changed() {
1695
- // Send code type changes event.
1696
- $this->sync_install();
1697
-
1698
- if ( $this->is_premium() ) {
1699
- // Activated premium code.
1700
- $this->do_action( 'after_premium_version_activation' );
1701
-
1702
- // Remove all sticky messages related to download of the premium version.
1703
- $this->_admin_notices->remove_sticky( array(
1704
- 'trial_started',
1705
- 'plan_upgraded',
1706
- 'plan_changed',
1707
- ) );
1708
-
1709
- $this->_admin_notices->add_sticky(
1710
- __fs( 'premium-activated-message' ),
1711
- 'premium_activated',
1712
- __fs( 'woot' ) . '!'
1713
- );
1714
- } else {
1715
- // Activated free code (after had the premium before).
1716
- $this->do_action( 'after_free_version_reactivation' );
1717
-
1718
- if ( $this->is_paying() && ! $this->is_premium() ) {
1719
- $this->_admin_notices->add_sticky(
1720
- sprintf(
1721
- __fs( 'you-have-x-license' ),
1722
- $this->_site->plan->title
1723
- ) . ' ' . $this->_get_latest_download_link( sprintf(
1724
- __fs( 'download-x-version-now' ),
1725
- $this->_site->plan->title
1726
- ) ),
1727
- 'plan_upgraded',
1728
- __fs( 'yee-haw' ) . '!'
1729
- );
1730
- }
1731
- }
1732
-
1733
- // Update is_premium of latest version.
1734
- $this->_storage->prev_is_premium = $this->_plugin->is_premium;
1735
- }
1736
-
1737
- #endregion Initialization ------------------------------------------------------------------
1738
-
1739
- #region Add-ons -------------------------------------------------------------------------
1740
-
1741
- /**
1742
- * Generate add-on plugin information.
1743
- *
1744
- * @author Vova Feldman (@svovaf)
1745
- * @since 1.0.6
1746
- *
1747
- * @param array $data
1748
- * @param string $action
1749
- * @param object|null $args
1750
- *
1751
- * @return array|null
1752
- */
1753
- function _get_addon_info_filter( $data, $action = '', $args = null ) {
1754
- $this->_logger->entrance();
1755
-
1756
- $parent_plugin_id = fs_request_get( 'parent_plugin_id', false );
1757
-
1758
- if ( $this->get_id() != $parent_plugin_id ||
1759
- ( 'plugin_information' !== $action ) ||
1760
- ! isset( $args->slug )
1761
- ) {
1762
- return $data;
1763
- }
1764
-
1765
- // Find add-on by slug.
1766
- $addons = $this->get_addons();
1767
- $selected_addon = false;
1768
- foreach ( $addons as $addon ) {
1769
- if ( $addon->slug == $args->slug ) {
1770
- $selected_addon = $addon;
1771
- break;
1772
- }
1773
- }
1774
-
1775
- if ( false === $selected_addon ) {
1776
- return $data;
1777
- }
1778
-
1779
- if ( ! isset( $selected_addon->info ) ) {
1780
- // Setup some default info.
1781
- $selected_addon->info = new stdClass();
1782
- $selected_addon->info->selling_point_0 = 'Selling Point 1';
1783
- $selected_addon->info->selling_point_1 = 'Selling Point 2';
1784
- $selected_addon->info->selling_point_2 = 'Selling Point 3';
1785
- $selected_addon->info->description = '<p>Tell your users all about your add-on</p>';
1786
- }
1787
-
1788
- fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
1789
-
1790
- $data = $args;
1791
-
1792
- // Fetch as much as possible info from local files.
1793
- $plugin_local_data = $this->get_plugin_data();
1794
- $data->name = $selected_addon->title;
1795
- $data->author = $plugin_local_data['Author'];
1796
- $view_vars = array( 'plugin' => $selected_addon );
1797
- $data->sections = array(
1798
- 'description' => fs_get_template( '/plugin-info/description.php', $view_vars ),
1799
- );
1800
-
1801
- if ( ! empty( $selected_addon->info->banner_url ) ) {
1802
- $data->banners = array(
1803
- 'low' => $selected_addon->info->banner_url,
1804
- );
1805
- }
1806
-
1807
- if ( ! empty( $selected_addon->info->screenshots ) ) {
1808
- $view_vars = array( 'screenshots' => $selected_addon->info->screenshots );
1809
- $data->sections['screenshots'] = fs_get_template( '/plugin-info/screenshots.php', $view_vars );
1810
- }
1811
-
1812
- // Load add-on pricing.
1813
- $has_pricing = false;
1814
- $has_features = false;
1815
- $plans = false;
1816
- $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans.json" );
1817
- if ( ! isset( $plans_result->error ) ) {
1818
- $plans = $plans_result->plans;
1819
- if ( is_array( $plans ) ) {
1820
- foreach ( $plans as &$plan ) {
1821
- $pricing_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/pricing.json" );
1822
- if ( ! isset( $pricing_result->error ) ) {
1823
- // Update plan's pricing.
1824
- $plan->pricing = $pricing_result->pricing;
1825
-
1826
- $has_pricing = true;
1827
- }
1828
-
1829
- $features_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$selected_addon->id}/plans/{$plan->id}/features.json" );
1830
- if ( ! isset( $features_result->error ) &&
1831
- is_array( $features_result->features ) &&
1832
- 0 < count( $features_result->features )
1833
- ) {
1834
- // Update plan's pricing.
1835
- $plan->features = $features_result->features;
1836
-
1837
- $has_features = true;
1838
- }
1839
- }
1840
- }
1841
- }
1842
-
1843
- // Get latest add-on version.
1844
- $latest = $this->_fetch_latest_version( $selected_addon->id );
1845
-
1846
- if ( is_object( $latest ) ) {
1847
- $data->version = $latest->version;
1848
- $data->last_updated = ! is_null( $latest->updated ) ? $latest->updated : $latest->created;
1849
- $data->requires = $latest->requires_platform_version;
1850
- $data->tested = $latest->tested_up_to_version;
1851
- } else {
1852
- // Add dummy version.
1853
- $data->version = '1.0.0';
1854
-
1855
- // Add message to developer to deploy the plugin through Freemius.
1856
- }
1857
-
1858
- $data->checkout_link = $this->checkout_url();
1859
- $data->download_link = 'https://dummy.com';
1860
-
1861
- if ( $has_pricing ) {
1862
- // Add plans to data.
1863
- $data->plans = $plans;
1864
-
1865
- if ( $has_features ) {
1866
- $view_vars = array( 'plans' => $plans );
1867
- $data->sections['features'] = fs_get_template( '/plugin-info/features.php', $view_vars );
1868
- }
1869
- }
1870
-
1871
- return $data;
1872
- }
1873
-
1874
- /**
1875
- * Check if add-on installed and activated on site.
1876
- *
1877
- * @author Vova Feldman (@svovaf)
1878
- * @since 1.0.6
1879
- *
1880
- * @param string|number $slug_or_id
1881
- *
1882
- * @return bool
1883
- */
1884
- function is_addon_activated( $slug_or_id ) {
1885
- return self::has_instance( $slug_or_id );
1886
- }
1887
-
1888
- /**
1889
- * Determines if add-on installed.
1890
- *
1891
- * NOTE: This is a heuristic and only works if the folder/file named as the slug.
1892
- *
1893
- * @author Vova Feldman (@svovaf)
1894
- * @since 1.0.6
1895
- *
1896
- * @param string $slug
1897
- *
1898
- * @return bool
1899
- */
1900
- function is_addon_installed( $slug ) {
1901
- return file_exists( fs_normalize_path( WP_PLUGIN_DIR . '/' . $this->get_addon_basename( $slug ) ) );
1902
- }
1903
-
1904
- /**
1905
- * Get add-on basename.
1906
- *
1907
- * @author Vova Feldman (@svovaf)
1908
- * @since 1.0.6
1909
- *
1910
- * @param string $slug
1911
- *
1912
- * @return string
1913
- */
1914
- function get_addon_basename( $slug ) {
1915
- if ( $this->is_addon_activated( $slug ) ) {
1916
- self::instance( $slug )->get_plugin_basename();
1917
- }
1918
-
1919
- return $slug . '/' . $slug . '.php';
1920
- }
1921
-
1922
- /**
1923
- * Get installed add-ons instances.
1924
- *
1925
- * @author Vova Feldman (@svovaf)
1926
- * @since 1.0.6
1927
- *
1928
- * @return Freemius[]
1929
- */
1930
- function get_installed_addons() {
1931
- $installed_addons = array();
1932
- foreach ( self::$_instances as $slug => $instance ) {
1933
- if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
1934
- if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
1935
- $installed_addons[] = $instance;
1936
- }
1937
- }
1938
- }
1939
-
1940
- return $installed_addons;
1941
- }
1942
-
1943
- /**
1944
- * Check if any add-ons of the plugin are installed.
1945
- *
1946
- * @author Leo Fajardo (@leorw)
1947
- * @since 1.1.1
1948
- *
1949
- * @return bool
1950
- */
1951
- function has_installed_addons() {
1952
- if ( ! $this->_has_addons() ) {
1953
- return false;
1954
- }
1955
-
1956
- foreach ( self::$_instances as $slug => $instance ) {
1957
- if ( $instance->is_addon() && is_object( $instance->_parent_plugin ) ) {
1958
- if ( $this->_plugin->id == $instance->_parent_plugin->id ) {
1959
- return true;
1960
- }
1961
- }
1962
- }
1963
-
1964
- return false;
1965
- }
1966
-
1967
- /**
1968
- * Tell Freemius that the current plugin is an add-on.
1969
- *
1970
- * @author Vova Feldman (@svovaf)
1971
- * @since 1.0.6
1972
- *
1973
- * @param number $parent_plugin_id The parent plugin ID
1974
- */
1975
- function init_addon( $parent_plugin_id ) {
1976
- $this->_plugin->parent_plugin_id = $parent_plugin_id;
1977
- }
1978
-
1979
- /**
1980
- * @author Vova Feldman (@svovaf)
1981
- * @since 1.0.6
1982
- *
1983
- * @return bool
1984
- */
1985
- function is_addon() {
1986
- return isset( $this->_plugin->parent_plugin_id ) && is_numeric( $this->_plugin->parent_plugin_id );
1987
- }
1988
-
1989
- #endregion ------------------------------------------------------------------
1990
-
1991
- #region Sandbox ------------------------------------------------------------------
1992
-
1993
- /**
1994
- * Set Freemius into sandbox mode for debugging.
1995
- *
1996
- * @author Vova Feldman (@svovaf)
1997
- * @since 1.0.4
1998
- *
1999
- * @param string $secret_key
2000
- */
2001
- function init_sandbox( $secret_key ) {
2002
- $this->_plugin->secret_key = $secret_key;
2003
-
2004
- // Update plugin details.
2005
- FS_Plugin_Manager::instance( $this->_slug )->update( $this->_plugin, true );
2006
- }
2007
-
2008
- /**
2009
- * Check if running payments in sandbox mode.
2010
- *
2011
- * @author Vova Feldman (@svovaf)
2012
- * @since 1.0.4
2013
- *
2014
- * @return bool
2015
- */
2016
- function is_payments_sandbox() {
2017
- return ( ! $this->is_live() ) || isset( $this->_plugin->secret_key );
2018
- }
2019
-
2020
- #endregion Sandbox ------------------------------------------------------------------
2021
-
2022
- /**
2023
- * Check if running test vs. live plugin.
2024
- *
2025
- * @author Vova Feldman (@svovaf)
2026
- * @since 1.0.5
2027
- *
2028
- * @return bool
2029
- */
2030
- function is_live() {
2031
- return $this->_plugin->is_live;
2032
- }
2033
-
2034
- /**
2035
- * Check if the user skipped connecting the account with Freemius.
2036
- *
2037
- * @author Vova Feldman (@svovaf)
2038
- * @since 1.0.7
2039
- *
2040
- * @return bool
2041
- */
2042
- function is_anonymous() {
2043
- if ( ! isset( $this->_is_anonymous ) ) {
2044
- if ( ! isset( $this->_storage->is_anonymous ) ) {
2045
- // Not skipped.
2046
- $this->_is_anonymous = false;
2047
- } else if ( is_bool( $this->_storage->is_anonymous ) ) {
2048
- // For back compatibility, since the variable was boolean before.
2049
- $this->_is_anonymous = $this->_storage->is_anonymous;
2050
-
2051
- // Upgrade stored data format to 1.1.3 format.
2052
- $this->set_anonymous_mode( $this->_storage->is_anonymous );
2053
- } else {
2054
- // Version 1.1.3 and higher.
2055
- $this->_is_anonymous = $this->_storage->is_anonymous['is'];
2056
- }
2057
- }
2058
-
2059
- return $this->_is_anonymous;
2060
- }
2061
-
2062
- /**
2063
- * Check if user connected his account and install pending email activation.
2064
- *
2065
- * @author Vova Feldman (@svovaf)
2066
- * @since 1.0.7
2067
- *
2068
- * @return bool
2069
- */
2070
- function is_pending_activation() {
2071
- return $this->_storage->get( 'is_pending_activation', false );
2072
- }
2073
-
2074
- /**
2075
- * Check if plugin must be WordPress.org compliant.
2076
- *
2077
- * @since 1.0.7
2078
- *
2079
- * @return bool
2080
- */
2081
- function is_org_repo_compliant() {
2082
- return $this->_is_org_compliant;
2083
- }
2084
-
2085
- /**
2086
- * Background sync every 24 hours.
2087
- *
2088
- * @author Vova Feldman (@svovaf)
2089
- * @since 1.0.4
2090
- *
2091
- * @return bool If function actually executed the sync in this iteration.
2092
- */
2093
- private function _background_sync() {
2094
- $this->_logger->entrance();
2095
-
2096
- // Don't sync license on AJAX calls.
2097
- if ( $this->is_ajax() ) {
2098
- return false;
2099
- }
2100
-
2101
- // Asked to sync explicitly, no need for background sync.
2102
- if ( fs_request_is_action( $this->_slug . '_sync_license' ) ) {
2103
- return false;
2104
- }
2105
-
2106
- $sync_timestamp = $this->_storage->get( 'sync_timestamp' );
2107
-
2108
- if ( ! is_numeric( $sync_timestamp ) || $sync_timestamp >= time() ) {
2109
- // If updated not set or happens to be in the future, set as if was 24 hours earlier.
2110
- $sync_timestamp = time() - WP_FS__TIME_24_HOURS_IN_SEC;
2111
- $this->_storage->sync_timestamp = $sync_timestamp;
2112
- }
2113
-
2114
- if ( ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE && fs_request_has( 'background_sync' ) ) ||
2115
- ( $sync_timestamp <= time() - WP_FS__TIME_24_HOURS_IN_SEC )
2116
- ) {
2117
-
2118
- if ( $this->is_registered() ) {
2119
- // Initiate background plan sync.
2120
- $this->_sync_license( true );
2121
-
2122
- // Check for plugin updates.
2123
- $this->_check_updates( true );
2124
- }
2125
-
2126
- if ( ! $this->is_addon() ) {
2127
- if ( $this->is_registered() || $this->_has_addons ) {
2128
- // Try to fetch add-ons if registered or if plugin
2129
- // declared that it has add-ons.
2130
- $this->_sync_addons();
2131
- }
2132
- }
2133
-
2134
- // Update last sync timestamp.
2135
- $this->_storage->sync_timestamp = time();
2136
-
2137
- return true;
2138
- }
2139
-
2140
- return false;
2141
- }
2142
-
2143
- /**
2144
- * Show a notice that activation is currently pending.
2145
- *
2146
- * @author Vova Feldman (@svovaf)
2147
- * @since 1.0.7
2148
- *
2149
- * @param bool|string $email
2150
- */
2151
- function _add_pending_activation_notice( $email = false ) {
2152
- if ( ! is_string( $email ) ) {
2153
- $current_user = wp_get_current_user();
2154
- $email = $current_user->user_email;
2155
- }
2156
-
2157
- $this->_admin_notices->add_sticky(
2158
- sprintf(
2159
- __fs( 'pending-activation-message' ),
2160
- '<b>' . $this->get_plugin_name() . '</b>',
2161
- '<b>' . $email . '</b>'
2162
- ),
2163
- 'activation_pending',
2164
- 'Thanks!'
2165
- );
2166
- }
2167
-
2168
- /**
2169
- *
2170
- * NOTE: admin_menu action executed before admin_init.
2171
- *
2172
- * @author Vova Feldman (@svovaf)
2173
- * @since 1.0.7
2174
- */
2175
- function _admin_init_action() {
2176
- // Automatically redirect to connect/activation page after plugin activation.
2177
- if ( get_option( "fs_{$this->_slug}_activated", false ) ) {
2178
- delete_option( "fs_{$this->_slug}_activated" );
2179
- $this->_redirect_on_activation_hook();
2180
-
2181
- return;
2182
- }
2183
-
2184
- if ( fs_request_is_action( $this->_slug . '_skip_activation' ) ) {
2185
- check_admin_referer( $this->_slug . '_skip_activation' );
2186
-
2187
- $this->skip_connection();
2188
-
2189
- if ( fs_redirect( $this->get_after_activation_url( 'after_skip_url' ) ) ) {
2190
- exit();
2191
- }
2192
- }
2193
-
2194
- if ( ! $this->is_addon() && ! $this->is_registered() && ! $this->is_anonymous() ) {
2195
- if ( ! $this->is_pending_activation() ) {
2196
- if ( ! $this->_menu->is_activation_page() ) {
2197
- $this->_admin_notices->add(
2198
- sprintf(
2199
- __fs( 'you-are-step-away' ),
2200
- sprintf( '<b><a href="%s">%s</a></b>',
2201
- $this->get_activation_url(),
2202
- sprintf( __fs( 'activate-x-now' ), $this->get_plugin_name() )
2203
- )
2204
- ),
2205
- '',
2206
- 'update-nag'
2207
- );
2208
- }
2209
- }
2210
- }
2211
-
2212
- $this->_add_upgrade_action_link();
2213
- }
2214
-
2215
- /**
2216
- * Return current page's URL.
2217
- *
2218
- * @author Vova Feldman (@svovaf)
2219
- * @since 1.0.7
2220
- *
2221
- * @return string
2222
- */
2223
- function current_page_url() {
2224
- $url = 'http';
2225
-
2226
- if ( isset( $_SERVER["HTTPS"] ) ) {
2227
- if ( $_SERVER["HTTPS"] == "on" ) {
2228
- $url .= "s";
2229
- }
2230
- }
2231
- $url .= "://";
2232
- if ( $_SERVER["SERVER_PORT"] != "80" ) {
2233
- $url .= $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . $_SERVER["REQUEST_URI"];
2234
- } else {
2235
- $url .= $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"];
2236
- }
2237
-
2238
- return esc_url( $url );
2239
- }
2240
-
2241
- /**
2242
- * Check if the current page is the plugin's main admin settings page.
2243
- *
2244
- * @author Vova Feldman (@svovaf)
2245
- * @since 1.0.7
2246
- *
2247
- * @return bool
2248
- */
2249
- function _is_plugin_page() {
2250
- return fs_is_plugin_page( $this->_menu->get_raw_slug() ) ||
2251
- fs_is_plugin_page( $this->_slug );
2252
- }
2253
-
2254
- /* Events
2255
- ------------------------------------------------------------------------------------------------------------------*/
2256
- /**
2257
- * Delete site install from Database.
2258
- *
2259
- * @author Vova Feldman (@svovaf)
2260
- * @since 1.0.1
2261
- *
2262
- * @param bool $store
2263
- */
2264
- function _delete_site( $store = true ) {
2265
- $sites = self::get_all_sites();
2266
-
2267
- if ( isset( $sites[ $this->_slug ] ) ) {
2268
- unset( $sites[ $this->_slug ] );
2269
- }
2270
-
2271
- self::$_accounts->set_option( 'sites', $sites, $store );
2272
- }
2273
-
2274
- /**
2275
- * Delete plugin's plans information.
2276
- *
2277
- * @param bool $store Flush to Database if true.
2278
- *
2279
- * @author Vova Feldman (@svovaf)
2280
- * @since 1.0.9
2281
- */
2282
- private function _delete_plans( $store = true ) {
2283
- $this->_logger->entrance();
2284
-
2285
- $plans = self::get_all_plans();
2286
-
2287
- unset( $plans[ $this->_slug ] );
2288
-
2289
- self::$_accounts->set_option( 'plans', $plans, $store );
2290
- }
2291
-
2292
- /**
2293
- * Delete all plugin licenses.
2294
- *
2295
- * @author Vova Feldman (@svovaf)
2296
- * @since 1.0.9
2297
- *
2298
- * @param bool $store
2299
- * @param string|bool $plugin_slug
2300
- */
2301
- private function _delete_licenses( $store = true, $plugin_slug = false ) {
2302
- $this->_logger->entrance();
2303
-
2304
- $all_licenses = self::get_all_licenses();
2305
-
2306
- if ( ! is_string( $plugin_slug ) ) {
2307
- $plugin_slug = $this->_slug;
2308
- }
2309
-
2310
- unset( $all_licenses[ $plugin_slug ] );
2311
-
2312
- self::$_accounts->set_option( 'licenses', $all_licenses, $store );
2313
- }
2314
-
2315
- /**
2316
- * Plugin activated hook.
2317
- *
2318
- * @author Vova Feldman (@svovaf)
2319
- * @since 1.0.1
2320
- * @uses FS_Api
2321
- */
2322
- function _activate_plugin_event_hook() {
2323
- $this->_logger->entrance( 'slug = ' . $this->_slug );
2324
-
2325
- if ( ! current_user_can( 'activate_plugins' ) ) {
2326
- return;
2327
- }
2328
-
2329
- // Clear API cache on activation.
2330
- FS_Api::clear_cache();
2331
-
2332
- if ( $this->is_registered() ) {
2333
- // Send re-activation event and sync.
2334
- $this->sync_install( array(), true );
2335
-
2336
- /**
2337
- * @todo Work on automatic deactivation of the Free plugin version. It doesn't work since the slug of the free & premium versions is identical. Therefore, only one instance of Freemius is created and the activation hook of the premium version is not being added.
2338
- */
2339
- if ( $this->_plugin_basename !== $this->_free_plugin_basename ) {
2340
- // Deactivate Free plugin version on premium plugin activation.
2341
- deactivate_plugins( $this->_free_plugin_basename );
2342
-
2343
- $this->_admin_notices->add(
2344
- sprintf( __fs( 'successful-version-upgrade-message' ), sprintf( '<b>%s</b>', $this->_plugin->title ) ),
2345
- __fs( 'woot' ) . '!'
2346
- );
2347
- }
2348
- } else if ( $this->is_anonymous() ) {
2349
- /**
2350
- * Reset "skipped" click cache on the following:
2351
- * 1. Development mode.
2352
- * 2. If the user skipped the exact same version before.
2353
- *
2354
- * @todo 3. If explicitly asked to retry after every activation.
2355
- */
2356
- if ( WP_FS__DEV_MODE ||
2357
- $this->get_plugin_version() == $this->_storage->is_anonymous['version']
2358
- ) {
2359
- $this->reset_anonymous_mode();
2360
- }
2361
- }
2362
-
2363
- if ( $this->has_api_connectivity() ) {
2364
- // Store hint that the plugin was just activated to enable auto-redirection to settings.
2365
- add_option( "fs_{$this->_slug}_activated", true );
2366
- }
2367
- }
2368
-
2369
- /**
2370
- * Delete account.
2371
- *
2372
- * @author Vova Feldman (@svovaf)
2373
- * @since 1.0.3
2374
- *
2375
- * @param bool $check_user Enforce checking if user have plugins activation privileges.
2376
- */
2377
- function delete_account_event( $check_user = true ) {
2378
- $this->_logger->entrance( 'slug = ' . $this->_slug );
2379
-
2380
- if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
2381
- return;
2382
- }
2383
-
2384
- $this->do_action( 'before_account_delete' );
2385
-
2386
- // Clear all admin notices.
2387
- $this->_admin_notices->clear_all_sticky();
2388
-
2389
- $this->_delete_site( false );
2390
-
2391
- $this->_delete_plans( false );
2392
-
2393
- $this->_delete_licenses( false );
2394
-
2395
- // Delete add-ons related to plugin's account.
2396
- $this->_delete_account_addons( false );
2397
-
2398
- // @todo Delete plans and licenses of add-ons.
2399
-
2400
- self::$_accounts->store();
2401
-
2402
- // Clear all storage data.
2403
- $this->_storage->clear_all( true, array(
2404
- 'connectivity_test',
2405
- 'is_on',
2406
- ) );
2407
-
2408
- // Send delete event.
2409
- $this->get_api_site_scope()->call( '/', 'delete' );
2410
-
2411
- $this->do_action( 'after_account_delete' );
2412
- }
2413
-
2414
- /**
2415
- * Plugin deactivation hook.
2416
- *
2417
- * @author Vova Feldman (@svovaf)
2418
- * @since 1.0.1
2419
- */
2420
- function _deactivate_plugin_hook() {
2421
- $this->_logger->entrance( 'slug = ' . $this->_slug );
2422
-
2423
- if ( ! current_user_can( 'activate_plugins' ) ) {
2424
- return;
2425
- }
2426
-
2427
- $this->_admin_notices->clear_all_sticky();
2428
-
2429
- if ( ! $this->has_api_connectivity() ) {
2430
- // Reset connectivity test cache.
2431
- unset( $this->_storage->connectivity_test );
2432
- }
2433
-
2434
- if ( $this->is_registered() ) {
2435
- // Send deactivation event.
2436
- $this->sync_install( array(
2437
- 'is_active' => false,
2438
- ) );
2439
- }
2440
-
2441
- // Clear API cache on deactivation.
2442
- FS_Api::clear_cache();
2443
- }
2444
-
2445
- /**
2446
- * @author Vova Feldman (@svovaf)
2447
- * @since 1.1.3
2448
- *
2449
- * @param bool $is_anonymous
2450
- */
2451
- private function set_anonymous_mode( $is_anonymous = true ) {
2452
- // Store information regarding skip to try and opt-in the user
2453
- // again in the future.
2454
- $this->_storage->is_anonymous = array(
2455
- 'is' => $is_anonymous,
2456
- 'timestamp' => WP_FS__SCRIPT_START_TIME,
2457
- 'version' => $this->get_plugin_version(),
2458
- );
2459
- }
2460
-
2461
- /**
2462
- * @author Vova Feldman (@svovaf)
2463
- * @since 1.1.3
2464
- */
2465
- private function reset_anonymous_mode() {
2466
- unset( $this->_storage->is_anonymous );
2467
- }
2468
-
2469
- /**
2470
- * Skip account connect, and set anonymous mode.
2471
- *
2472
- * @author Vova Feldman (@svovaf)
2473
- * @since 1.1.1
2474
- */
2475
- private function skip_connection() {
2476
- $this->_logger->entrance();
2477
-
2478
- $this->set_anonymous_mode();
2479
-
2480
- // Send anonymous skip event.
2481
- // No user identified info nor any tracking will be sent after the user skips the opt-in.
2482
- $this->get_api_plugin_scope()->call( 'skip.json', 'put', array(
2483
- 'uid' => $this->get_anonymous_id(),
2484
- ) );
2485
- }
2486
-
2487
- /**
2488
- * Plugin version update hook.
2489
- *
2490
- * @author Vova Feldman (@svovaf)
2491
- * @since 1.0.4
2492
- */
2493
- private function update_plugin_version_event() {
2494
- $this->_logger->entrance( 'slug = ' . $this->_slug );
2495
-
2496
- $this->_site->version = $this->get_plugin_version();
2497
-
2498
- // Send update event.
2499
- $site = $this->send_install_update( array(), true );
2500
-
2501
- if ( false !== $site && ! $this->is_api_error( $site ) ) {
2502
- $this->_site = new FS_Site( $site );
2503
- $this->_store_site( true );
2504
- }
2505
- }
2506
-
2507
- /**
2508
- * Update install details.
2509
- *
2510
- * @author Vova Feldman (@svovaf)
2511
- * @since 1.1.2
2512
- *
2513
- * @param string[] string $override
2514
- *
2515
- * @return array
2516
- */
2517
- private function get_install_data_for_api( $override = array() ) {
2518
- return array_merge( array(
2519
- 'version' => $this->get_plugin_version(),
2520
- 'is_premium' => $this->is_premium(),
2521
- 'language' => get_bloginfo( 'language' ),
2522
- 'charset' => get_bloginfo( 'charset' ),
2523
- 'platform_version' => get_bloginfo( 'version' ),
2524
- 'programming_language_version' => phpversion(),
2525
- 'title' => get_bloginfo( 'name' ),
2526
- 'url' => get_site_url(),
2527
- // Special params.
2528
- 'is_active' => true,
2529
- 'is_uninstalled' => false,
2530
- ), $override );
2531
- }
2532
-
2533
- /**
2534
- * Update install only if changed.
2535
- *
2536
- * @author Vova Feldman (@svovaf)
2537
- * @since 1.0.9
2538
- *
2539
- * @param string[] string $override
2540
- * @param bool $flush
2541
- *
2542
- * @return false|object|string
2543
- */
2544
- private function send_install_update( $override = array(), $flush = false ) {
2545
- $this->_logger->entrance();
2546
-
2547
- $check_properties = $this->get_install_data_for_api( $override );
2548
-
2549
- if ( $flush ) {
2550
- $params = $check_properties;
2551
- } else {
2552
- $params = array();
2553
- $special = array();
2554
- $special_override = false;
2555
-
2556
- foreach ( $check_properties as $p => $v ) {
2557
- if ( property_exists( $this->_site, $p ) ) {
2558
- if ( ! empty( $this->_site->{$p} ) &&
2559
- $this->_site->{$p} != $v
2560
- ) {
2561
- $this->_site->{$p} = $v;
2562
- $params[ $p ] = $v;
2563
- }
2564
- } else {
2565
- $special[ $p ] = $v;
2566
-
2567
- if ( isset( $override[ $p ] ) ) {
2568
- $special_override = true;
2569
- }
2570
- }
2571
- }
2572
-
2573
- if ( $special_override || 0 < count( $params ) ) {
2574
- // Add special params only if has at least one
2575
- // standard param, or if explicitly requested to
2576
- // override a special param or a pram which is not exist
2577
- // in the install object.
2578
- $params = array_merge( $params, $special );
2579
- }
2580
- }
2581
-
2582
- if ( 0 < count( $params ) ) {
2583
- // Send updated values to FS.
2584
- return $this->get_api_site_scope()->call( '/', 'put', $params );
2585
- }
2586
-
2587
- return false;
2588
- }
2589
-
2590
- /**
2591
- * Update install only if changed.
2592
- *
2593
- * @author Vova Feldman (@svovaf)
2594
- * @since 1.0.9
2595
- *
2596
- * @param string[] string $override
2597
- * @param bool $flush
2598
- *
2599
- * @return false|object|string
2600
- */
2601
- private function sync_install( $override = array(), $flush = false ) {
2602
- $this->_logger->entrance();
2603
-
2604
- $site = $this->send_install_update( $override, $flush );
2605
-
2606
- if ( false === $site ) {
2607
- // No sync required.
2608
- return;
2609
- }
2610
-
2611
- if ( $this->is_api_error( $site ) ) {
2612
- // Failed to sync, don't update locally.
2613
- return;
2614
- }
2615
-
2616
- $plan = $this->get_plan();
2617
- $this->_site = new FS_Site( $site );
2618
- $this->_site->plan = $plan;
2619
-
2620
- $this->_store_site( true );
2621
- }
2622
-
2623
- /**
2624
- * Plugin uninstall hook.
2625
- *
2626
- * @author Vova Feldman (@svovaf)
2627
- * @since 1.0.1
2628
- *
2629
- * @param bool $check_user Enforce checking if user have plugins activation privileges.
2630
- */
2631
- function _uninstall_plugin_event( $check_user = true ) {
2632
- $this->_logger->entrance( 'slug = ' . $this->_slug );
2633
-
2634
- if ( $check_user && ! current_user_can( 'activate_plugins' ) ) {
2635
- return;
2636
- }
2637
-
2638
- $params = array();
2639
- if ( isset( $this->_storage->uninstall_reason ) ) {
2640
- $params['reason_id'] = $this->_storage->uninstall_reason->id;
2641
- $params['reason_info'] = $this->_storage->uninstall_reason->info;
2642
- }
2643
-
2644
- if ( ! $this->is_registered() && isset( $this->_storage->uninstall_reason ) ) {
2645
- // Send anonymous uninstall event only if user submitted a feedback.
2646
- $params['uid'] = $this->get_anonymous_id();
2647
- $this->get_api_plugin_scope()->call( 'uninstall.json', 'put', $params );
2648
- } else {
2649
- // Send uninstall event.
2650
- $this->send_install_update( array_merge( $params, array(
2651
- 'is_active' => false,
2652
- 'is_uninstalled' => true,
2653
- ) ) );
2654
- }
2655
-
2656
- // @todo Decide if we want to delete plugin information from db.
2657
- }
2658
-
2659
- /**
2660
- * @author Vova Feldman (@svovaf)
2661
- * @since 1.1.1
2662
- *
2663
- * @return string
2664
- */
2665
- private function premium_plugin_basename() {
2666
- return preg_replace( '/\//', '-premium/', $this->_free_plugin_basename, 1 );
2667
- }
2668
-
2669
- /**
2670
- * Uninstall plugin hook. Called only when connected his account with Freemius for active sites tracking.
2671
- *
2672
- * @author Vova Feldman (@svovaf)
2673
- * @since 1.0.2
2674
- */
2675
- public static function _uninstall_plugin_hook() {
2676
- self::_load_required_static();
2677
-
2678
- self::$_static_logger->entrance();
2679
-
2680
- if ( ! current_user_can( 'activate_plugins' ) ) {
2681
- return;
2682
- }
2683
-
2684
- $plugin_file = substr( current_filter(), strlen( 'uninstall_' ) );
2685
-
2686
- self::$_static_logger->info( 'plugin = ' . $plugin_file );
2687
-
2688
- define( 'WP_FS__UNINSTALL_MODE', true );
2689
-
2690
- $fs = self::get_instance_by_file( $plugin_file );
2691
-
2692
- if ( is_object( $fs ) ) {
2693
- self::require_plugin_essentials();
2694
-
2695
- if ( is_plugin_active( $fs->_free_plugin_basename ) ||
2696
- is_plugin_active( $fs->premium_plugin_basename() )
2697
- ) {
2698
- // Deleting Free or Premium plugin version while the other version still installed.
2699
- return;
2700
- }
2701
-
2702
- $fs->_uninstall_plugin_event();
2703
-
2704
- $fs->do_action( 'after_uninstall' );
2705
- }
2706
- }
2707
-
2708
- #region Plugin Information ------------------------------------------------------------------
2709
-
2710
- /**
2711
- * Load WordPress core plugin.php essential module.
2712
- *
2713
- * @author Vova Feldman (@svovaf)
2714
- * @since 1.1.1
2715
- */
2716
- private static function require_plugin_essentials() {
2717
- if ( ! function_exists( 'get_plugins' ) ) {
2718
- require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
2719
- }
2720
- }
2721
-
2722
- /**
2723
- * Load WordPress core pluggable.php module.
2724
- *
2725
- * @author Vova Feldman (@svovaf)
2726
- * @since 1.1.2
2727
- */
2728
- private static function require_pluggable_essentials() {
2729
- if ( ! function_exists( 'wp_get_current_user' ) ) {
2730
- require_once( ABSPATH . 'wp-includes/pluggable.php' );
2731
- }
2732
- }
2733
-
2734
- /**
2735
- * Return plugin data.
2736
- *
2737
- * @author Vova Feldman (@svovaf)
2738
- * @since 1.0.1
2739
- *
2740
- * @return array
2741
- */
2742
- function get_plugin_data() {
2743
- if ( ! isset( $this->_plugin_data ) ) {
2744
- self::require_plugin_essentials();
2745
-
2746
- $this->_plugin_data = get_plugin_data( $this->_plugin_main_file_path );
2747
- }
2748
-
2749
- return $this->_plugin_data;
2750
- }
2751
-
2752
- /**
2753
- * @author Vova Feldman (@svovaf)
2754
- * @since 1.0.1
2755
- *
2756
- * @return string Plugin slug.
2757
- */
2758
- function get_slug() {
2759
- return $this->_slug;
2760
- }
2761
-
2762
- /**
2763
- * @author Vova Feldman (@svovaf)
2764
- * @since 1.0.1
2765
- *
2766
- * @return number Plugin ID.
2767
- */
2768
- function get_id() {
2769
- return $this->_plugin->id;
2770
- }
2771
-
2772
- /**
2773
- * @author Vova Feldman (@svovaf)
2774
- * @since 1.0.1
2775
- *
2776
- * @return string Plugin public key.
2777
- */
2778
- function get_public_key() {
2779
- return $this->_plugin->public_key;
2780
- }
2781
-
2782
- /**
2783
- * Will be available only on sandbox mode.
2784
- *
2785
- * @author Vova Feldman (@svovaf)
2786
- * @since 1.0.4
2787
- *
2788
- * @return mixed Plugin secret key.
2789
- */
2790
- function get_secret_key() {
2791
- return $this->_plugin->secret_key;
2792
- }
2793
-
2794
- /**
2795
- * @author Vova Feldman (@svovaf)
2796
- * @since 1.1.1
2797
- *
2798
- * @return bool
2799
- */
2800
- function has_secret_key() {
2801
- return ! empty( $this->_plugin->secret_key );
2802
- }
2803
-
2804
- /**
2805
- * @author Vova Feldman (@svovaf)
2806
- * @since 1.0.9
2807
- *
2808
- * @return string
2809
- */
2810
- function get_plugin_name() {
2811
- $this->_logger->entrance();
2812
-
2813
- if ( ! isset( $this->_plugin_name ) ) {
2814
- $plugin_data = $this->get_plugin_data();
2815
-
2816
- // Get name.
2817
- $this->_plugin_name = $plugin_data['Name'];
2818
-
2819
- // Check if plugin name contains [Premium] suffix and remove it.
2820
- $suffix = '[premium]';
2821
- $suffix_len = strlen( $suffix );
2822
-
2823
- if ( strlen( $plugin_data['Name'] ) > $suffix_len &&
2824
- $suffix === substr( strtolower( $plugin_data['Name'] ), - $suffix_len )
2825
- ) {
2826
- $this->_plugin_name = substr( $plugin_data['Name'], 0, - $suffix_len );
2827
- }
2828
-
2829
- $this->_logger->departure( 'Name = ' . $this->_plugin_name );
2830
- }
2831
-
2832
- return $this->_plugin_name;
2833
- }
2834
-
2835
- /**
2836
- * @author Vova Feldman (@svovaf)
2837
- * @since 1.0.0
2838
- *
2839
- * @return string
2840
- */
2841
- function get_plugin_version() {
2842
- $this->_logger->entrance();
2843
-
2844
- $plugin_data = $this->get_plugin_data();
2845
-
2846
- $this->_logger->departure( 'Version = ' . $plugin_data['Version'] );
2847
-
2848
- return $plugin_data['Version'];
2849
- }
2850
-
2851
- /**
2852
- * @author Vova Feldman (@svovaf)
2853
- * @since 1.0.4
2854
- *
2855
- * @return string
2856
- */
2857
- function get_plugin_basename() {
2858
- return $this->_plugin_basename;
2859
- }
2860
-
2861
- function get_plugin_folder_name() {
2862
- $this->_logger->entrance();
2863
-
2864
- $plugin_folder = $this->_plugin_basename;
2865
-
2866
- while ( '.' !== dirname( $plugin_folder ) ) {
2867
- $plugin_folder = dirname( $plugin_folder );
2868
- }
2869
-
2870
- $this->_logger->departure( 'Folder Name = ' . $plugin_folder );
2871
-
2872
- return $plugin_folder;
2873
- }
2874
-
2875
- #endregion ------------------------------------------------------------------
2876
-
2877
- /* Account
2878
- ------------------------------------------------------------------------------------------------------------------*/
2879
-
2880
- /**
2881
- * Find plugin's slug by plugin's basename.
2882
- *
2883
- * @author Vova Feldman (@svovaf)
2884
- * @since 1.0.9
2885
- *
2886
- * @param string $plugin_base_name
2887
- *
2888
- * @return false|string
2889
- */
2890
- private static function find_slug_by_basename( $plugin_base_name ) {
2891
- $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
2892
-
2893
- if ( ! array( $file_slug_map ) || ! isset( $file_slug_map[ $plugin_base_name ] ) ) {
2894
- return false;
2895
- }
2896
-
2897
- return $file_slug_map[ $plugin_base_name ];
2898
- }
2899
-
2900
- /**
2901
- * Store the map between the plugin's basename to the slug.
2902
- *
2903
- * @author Vova Feldman (@svovaf)
2904
- * @since 1.0.9
2905
- */
2906
- private function store_file_slug_map() {
2907
- $file_slug_map = self::$_accounts->get_option( 'file_slug_map', array() );
2908
-
2909
- if ( ! array( $file_slug_map ) ) {
2910
- $file_slug_map = array();
2911
- }
2912
-
2913
- if ( ! isset( $file_slug_map[ $this->_plugin_basename ] ) ||
2914
- $file_slug_map[ $this->_plugin_basename ] !== $this->_slug
2915
- ) {
2916
- $file_slug_map[ $this->_plugin_basename ] = $this->_slug;
2917
- self::$_accounts->set_option( 'file_slug_map', $file_slug_map, true );
2918
- }
2919
- }
2920
-
2921
- /**
2922
- * @return FS_User[]
2923
- */
2924
- static function get_all_users() {
2925
- $users = self::$_accounts->get_option( 'users', array() );
2926
-
2927
- if ( ! is_array( $users ) ) {
2928
- $users = array();
2929
- }
2930
-
2931
- return $users;
2932
- }
2933
-
2934
- /**
2935
- * @return FS_Site[]
2936
- */
2937
- private static function get_all_sites() {
2938
- $sites = self::$_accounts->get_option( 'sites', array() );
2939
-
2940
- if ( ! is_array( $sites ) ) {
2941
- $sites = array();
2942
- }
2943
-
2944
- return $sites;
2945
- }
2946
-
2947
- /**
2948
- * @author Vova Feldman (@svovaf)
2949
- * @since 1.0.6
2950
- *
2951
- * @return FS_Plugin_License[]
2952
- */
2953
- private static function get_all_licenses() {
2954
- $licenses = self::$_accounts->get_option( 'licenses', array() );
2955
-
2956
- if ( ! is_array( $licenses ) ) {
2957
- $licenses = array();
2958
- }
2959
-
2960
- return $licenses;
2961
- }
2962
-
2963
- /**
2964
- * @return FS_Plugin_Plan[]
2965
- */
2966
- private static function get_all_plans() {
2967
- $plans = self::$_accounts->get_option( 'plans', array() );
2968
-
2969
- if ( ! is_array( $plans ) ) {
2970
- $plans = array();
2971
- }
2972
-
2973
- return $plans;
2974
- }
2975
-
2976
- /**
2977
- * @author Vova Feldman (@svovaf)
2978
- * @since 1.0.4
2979
- *
2980
- * @return FS_Plugin_Tag[]
2981
- */
2982
- private static function get_all_updates() {
2983
- $updates = self::$_accounts->get_option( 'updates', array() );
2984
-
2985
- if ( ! is_array( $updates ) ) {
2986
- $updates = array();
2987
- }
2988
-
2989
- return $updates;
2990
- }
2991
-
2992
- /**
2993
- * @author Vova Feldman (@svovaf)
2994
- * @since 1.0.6
2995
- *
2996
- * @return FS_Plugin[]|false
2997
- */
2998
- private static function get_all_addons() {
2999
- $addons = self::$_accounts->get_option( 'addons', array() );
3000
-
3001
- if ( ! is_array( $addons ) ) {
3002
- $addons = array();
3003
- }
3004
-
3005
- return $addons;
3006
- }
3007
-
3008
- /**
3009
- * @author Vova Feldman (@svovaf)
3010
- * @since 1.0.6
3011
- *
3012
- * @return FS_Plugin[]|false
3013
- */
3014
- private static function get_all_account_addons() {
3015
- $addons = self::$_accounts->get_option( 'account_addons', array() );
3016
-
3017
- if ( ! is_array( $addons ) ) {
3018
- $addons = array();
3019
- }
3020
-
3021
- return $addons;
3022
- }
3023
-
3024
- /**
3025
- * Check if user is registered.
3026
- *
3027
- * @author Vova Feldman (@svovaf)
3028
- * @since 1.0.1
3029
- * @return bool
3030
- */
3031
- function is_registered() {
3032
- return is_object( $this->_user );
3033
- }
3034
-
3035
- /**
3036
- * @author Vova Feldman (@svovaf)
3037
- * @since 1.0.4
3038
- *
3039
- * @return FS_Plugin
3040
- */
3041
- function get_plugin() {
3042
- return $this->_plugin;
3043
- }
3044
-
3045
- /**
3046
- * @author Vova Feldman (@svovaf)
3047
- * @since 1.0.3
3048
- *
3049
- * @return FS_User
3050
- */
3051
- function get_user() {
3052
- return $this->_user;
3053
- }
3054
-
3055
- /**
3056
- * @author Vova Feldman (@svovaf)
3057
- * @since 1.0.3
3058
- *
3059
- * @return FS_Site
3060
- */
3061
- function get_site() {
3062
- return $this->_site;
3063
- }
3064
-
3065
- /**
3066
- * @author Vova Feldman (@svovaf)
3067
- * @since 1.0.6
3068
- *
3069
- * @return FS_Plugin[]|false
3070
- */
3071
- function get_addons() {
3072
- $this->_logger->entrance();
3073
-
3074
- $addons = self::get_all_addons();
3075
-
3076
- if ( ! is_array( $addons ) ||
3077
- ! isset( $addons[ $this->_plugin->id ] ) ||
3078
- ! is_array( $addons[ $this->_plugin->id ] ) ||
3079
- 0 === count( $addons[ $this->_plugin->id ] )
3080
- ) {
3081
- return false;
3082
- }
3083
-
3084
- return $addons[ $this->_plugin->id ];
3085
- }
3086
-
3087
- /**
3088
- * @author Vova Feldman (@svovaf)
3089
- * @since 1.0.6
3090
- *
3091
- * @return FS_Plugin[]|false
3092
- */
3093
- function get_account_addons() {
3094
- $this->_logger->entrance();
3095
-
3096
- $addons = self::get_all_account_addons();
3097
-
3098
- if ( ! is_array( $addons ) ||
3099
- ! isset( $addons[ $this->_plugin->id ] ) ||
3100
- ! is_array( $addons[ $this->_plugin->id ] ) ||
3101
- 0 === count( $addons[ $this->_plugin->id ] )
3102
- ) {
3103
- return false;
3104
- }
3105
-
3106
- return $addons[ $this->_plugin->id ];
3107
- }
3108
-
3109
- /**
3110
- * Get add-on by ID (from local data).
3111
- *
3112
- * @author Vova Feldman (@svovaf)
3113
- * @since 1.0.6
3114
- *
3115
- * @param number $id
3116
- *
3117
- * @return FS_Plugin|false
3118
- */
3119
- function get_addon( $id ) {
3120
- $this->_logger->entrance();
3121
-
3122
- $addons = $this->get_addons();
3123
-
3124
- if ( is_array( $addons ) ) {
3125
- foreach ( $addons as $addon ) {
3126
- if ( $id == $addon->id ) {
3127
- return $addon;
3128
- }
3129
- }
3130
- }
3131
-
3132
- return false;
3133
- }
3134
-
3135
- /**
3136
- * Get add-on by slug (from local data).
3137
- *
3138
- * @author Vova Feldman (@svovaf)
3139
- * @since 1.0.6
3140
- *
3141
- * @param string $slug
3142
- *
3143
- * @return FS_Plugin|false
3144
- */
3145
- function get_addon_by_slug( $slug ) {
3146
- $this->_logger->entrance();
3147
-
3148
- $addons = $this->get_addons();
3149
-
3150
- if ( is_array( $addons ) ) {
3151
- foreach ( $addons as $addon ) {
3152
- if ( $slug == $addon->slug ) {
3153
- return $addon;
3154
- }
3155
- }
3156
- }
3157
-
3158
- return false;
3159
- }
3160
-
3161
- #region Plans & Licensing ------------------------------------------------------------------
3162
-
3163
- /**
3164
- * Check if running premium plugin code.
3165
- *
3166
- * @author Vova Feldman (@svovaf)
3167
- * @since 1.0.5
3168
- *
3169
- * @return bool
3170
- */
3171
- function is_premium() {
3172
- return $this->_plugin->is_premium;
3173
- }
3174
-
3175
- /**
3176
- * Get site's plan ID.
3177
- *
3178
- * @author Vova Feldman (@svovaf)
3179
- * @since 1.0.2
3180
- *
3181
- * @return number
3182
- */
3183
- function get_plan_id() {
3184
- return $this->_site->plan->id;
3185
- }
3186
-
3187
- /**
3188
- * Get site's plan title.
3189
- *
3190
- * @author Vova Feldman (@svovaf)
3191
- * @since 1.0.2
3192
- *
3193
- * @return string
3194
- */
3195
- function get_plan_title() {
3196
- return $this->_site->plan->title;
3197
- }
3198
-
3199
- /**
3200
- * @author Vova Feldman (@svovaf)
3201
- * @since 1.0.9
3202
- *
3203
- * @return FS_Plugin_Plan
3204
- */
3205
- function get_plan() {
3206
- return is_object( $this->_site->plan ) ? $this->_site->plan : false;
3207
- }
3208
-
3209
- /**
3210
- * @author Vova Feldman (@svovaf)
3211
- * @since 1.0.3
3212
- *
3213
- * @return bool
3214
- */
3215
- function is_trial() {
3216
- $this->_logger->entrance();
3217
-
3218
- if ( ! $this->is_registered() ) {
3219
- return false;
3220
- }
3221
-
3222
- // Paid plan beats trial.
3223
- return $this->is_free_plan() && $this->_site->is_trial();
3224
- }
3225
-
3226
- /**
3227
- * Check if trial already utilized.
3228
- *
3229
- * @since 1.0.9
3230
- *
3231
- * @return bool
3232
- */
3233
- function is_trial_utilized() {
3234
- $this->_logger->entrance();
3235
-
3236
- if ( ! $this->is_registered() ) {
3237
- return false;
3238
- }
3239
-
3240
- return $this->_site->is_trial_utilized();
3241
- }
3242
-
3243
- /**
3244
- * Get trial plan information (if in trial).
3245
- *
3246
- * @author Vova Feldman (@svovaf)
3247
- * @since 1.0.9
3248
- *
3249
- * @return bool|FS_Plugin_Plan
3250
- */
3251
- function get_trial_plan() {
3252
- $this->_logger->entrance();
3253
-
3254
- if ( ! $this->is_trial() ) {
3255
- return false;
3256
- }
3257
-
3258
- return $this->_storage->trial_plan;
3259
- }
3260
-
3261
- /**
3262
- * Check if the user has an activated and valid paid license on current plugin's install.
3263
- *
3264
- * @since 1.0.9
3265
- *
3266
- * @return bool
3267
- */
3268
- function is_paying() {
3269
- $this->_logger->entrance();
3270
-
3271
- if ( ! $this->is_registered() ) {
3272
- return false;
3273
- }
3274
-
3275
- return (
3276
- ! $this->is_trial() &&
3277
- 'free' !== $this->_site->plan->name &&
3278
- $this->has_features_enabled_license()
3279
- );
3280
- }
3281
-
3282
- /**
3283
- * @author Vova Feldman (@svovaf)
3284
- * @since 1.0.4
3285
- *
3286
- * @return bool
3287
- */
3288
- function is_free_plan() {
3289
- if ( ! $this->is_registered() ) {
3290
- return true;
3291
- }
3292
-
3293
- return (
3294
- 'free' === $this->_site->plan->name ||
3295
- ! $this->has_features_enabled_license()
3296
- );
3297
- }
3298
-
3299
- /**
3300
- * @author Vova Feldman (@svovaf)
3301
- * @since 1.0.5
3302
- *
3303
- * @return bool
3304
- */
3305
- function _has_premium_license() {
3306
- $this->_logger->entrance();
3307
-
3308
- $premium_license = $this->_get_available_premium_license();
3309
-
3310
- return ( false !== $premium_license );
3311
- }
3312
-
3313
- /**
3314
- * @author Vova Feldman (@svovaf)
3315
- * @since 1.0.5
3316
- *
3317
- * @return FS_Plugin_License
3318
- */
3319
- function _get_available_premium_license() {
3320
- $this->_logger->entrance();
3321
-
3322
- if ( is_array( $this->_licenses ) ) {
3323
- foreach ( $this->_licenses as $license ) {
3324
- if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
3325
- return $license;
3326
- }
3327
- }
3328
- }
3329
-
3330
- return false;
3331
- }
3332
-
3333
- /**
3334
- * Sync local plugin plans with remote server.
3335
- *
3336
- * @author Vova Feldman (@svovaf)
3337
- * @since 1.0.5
3338
- *
3339
- * @return FS_Plugin_Plan[]|object
3340
- */
3341
- function _sync_plans() {
3342
- $plans = $this->_fetch_plugin_plans();
3343
- if ( ! $this->is_api_error( $plans ) ) {
3344
- $this->_plans = $plans;
3345
- $this->_store_plans();
3346
- }
3347
-
3348
- $this->do_action( 'after_plans_sync', $plans );
3349
-
3350
- return $this->_plans;
3351
- }
3352
-
3353
- /**
3354
- * @author Vova Feldman (@svovaf)
3355
- * @since 1.0.5
3356
- *
3357
- * @param number $id
3358
- *
3359
- * @return FS_Plugin_Plan
3360
- */
3361
- function _get_plan_by_id( $id ) {
3362
- $this->_logger->entrance();
3363
-
3364
- if ( ! is_array( $this->_plans ) || 0 === count( $this->_plans ) ) {
3365
- $this->_sync_plans();
3366
- }
3367
-
3368
- foreach ( $this->_plans as $plan ) {
3369
- if ( $id == $plan->id ) {
3370
- return $plan;
3371
- }
3372
- }
3373
-
3374
- return false;
3375
- }
3376
-
3377
- /**
3378
- * Sync local plugin plans with remote server.
3379
- *
3380
- * @author Vova Feldman (@svovaf)
3381
- * @since 1.0.6
3382
- *
3383
- * @return FS_Plugin_License[]|object
3384
- */
3385
- function _sync_licenses() {
3386
- $licenses = $this->_fetch_licenses();
3387
- if ( ! isset( $licenses->error ) ) {
3388
- $this->_licenses = $licenses;
3389
- $this->_store_licenses();
3390
- }
3391
-
3392
- // Update current license.
3393
- if ( is_object( $this->_license ) ) {
3394
- $this->_license = $this->_get_license_by_id( $this->_license->id );
3395
- }
3396
-
3397
- return $this->_licenses;
3398
- }
3399
-
3400
- /**
3401
- * @author Vova Feldman (@svovaf)
3402
- * @since 1.0.5
3403
- *
3404
- * @param number $id
3405
- *
3406
- * @return FS_Plugin_License
3407
- */
3408
- function _get_license_by_id( $id ) {
3409
- $this->_logger->entrance();
3410
-
3411
- if ( ! is_numeric( $id ) ) {
3412
- return false;
3413
- }
3414
-
3415
- if ( ! is_array( $this->_licenses ) || 0 === count( $this->_licenses ) ) {
3416
- $this->_sync_licenses();
3417
- }
3418
-
3419
- foreach ( $this->_licenses as $license ) {
3420
- if ( $id == $license->id ) {
3421
- return $license;
3422
- }
3423
- }
3424
-
3425
- return false;
3426
- }
3427
-
3428
- /**
3429
- * Sync site's license with user licenses.
3430
- *
3431
- * @author Vova Feldman (@svovaf)
3432
- * @since 1.0.6
3433
- *
3434
- * @param FS_Plugin_License|null $new_license
3435
- */
3436
- function _update_site_license( $new_license ) {
3437
- $this->_logger->entrance();
3438
-
3439
- $this->_license = $new_license;
3440
-
3441
- if ( ! is_object( $new_license ) ) {
3442
- $this->_site->license_id = null;
3443
- $this->_sync_site_subscription( null );
3444
-
3445
- return;
3446
- }
3447
-
3448
- $this->_site->license_id = $this->_license->id;
3449
-
3450
- if ( ! is_array( $this->_licenses ) ) {
3451
- $this->_licenses = array();
3452
- }
3453
-
3454
- $is_license_found = false;
3455
- for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
3456
- if ( $new_license->id == $this->_licenses[ $i ]->id ) {
3457
- $this->_licenses[ $i ] = $new_license;
3458
-
3459
- $is_license_found = true;
3460
- break;
3461
- }
3462
- }
3463
-
3464
- // If new license just append.
3465
- if ( ! $is_license_found ) {
3466
- $this->_licenses[] = $new_license;
3467
- }
3468
-
3469
- $this->_sync_site_subscription( $new_license );
3470
- }
3471
-
3472
- /**
3473
- * Sync site's subscription.
3474
- *
3475
- * @author Vova Feldman (@svovaf)
3476
- * @since 1.0.9
3477
- *
3478
- * @param FS_Plugin_License|null $license
3479
- *
3480
- * @return bool|\FS_Subscription
3481
- */
3482
- private function _sync_site_subscription( $license ) {
3483
- if ( ! is_object( $license ) ) {
3484
- unset( $this->_storage->subscription );
3485
-
3486
- return false;
3487
- }
3488
-
3489
- // Load subscription details if not lifetime.
3490
- $subscription = $license->is_lifetime() ?
3491
- false :
3492
- $this->_fetch_site_license_subscription();
3493
-
3494
- if ( is_object( $subscription ) && ! isset( $subscription->error ) ) {
3495
- $this->_storage->subscription = $subscription;
3496
- } else {
3497
- unset( $this->_storage->subscription );
3498
- }
3499
-
3500
- return $subscription;
3501
- }
3502
-
3503
- /**
3504
- * @author Vova Feldman (@svovaf)
3505
- * @since 1.0.6
3506
- *
3507
- * @return bool|\FS_Plugin_License
3508
- */
3509
- function _get_license() {
3510
- return $this->_license;
3511
- }
3512
-
3513
- /**
3514
- * @return bool|\FS_Subscription
3515
- */
3516
- function _get_subscription() {
3517
- return isset( $this->_storage->subscription ) ?
3518
- $this->_storage->subscription :
3519
- false;
3520
- }
3521
-
3522
- /**
3523
- * @author Vova Feldman (@svovaf)
3524
- * @since 1.0.2
3525
- *
3526
- * @param string $plan Plan name
3527
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
3528
- *
3529
- * @return bool
3530
- */
3531
- function is_plan( $plan, $exact = false ) {
3532
- $this->_logger->entrance();
3533
-
3534
- if ( ! $this->is_registered() ) {
3535
- return false;
3536
- }
3537
-
3538
- $plan = strtolower( $plan );
3539
-
3540
- if ( $this->_site->plan->name === $plan ) // Exact plan.
3541
- {
3542
- return true;
3543
- } else if ( $exact ) // Required exact, but plans are different.
3544
- {
3545
- return false;
3546
- }
3547
-
3548
- $current_plan_order = - 1;
3549
- $required_plan_order = - 1;
3550
- for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
3551
- if ( $plan === $this->_plans[ $i ]->name ) {
3552
- $required_plan_order = $i;
3553
- } else if ( $this->_site->plan->name === $this->_plans[ $i ]->name ) {
3554
- $current_plan_order = $i;
3555
- }
3556
- }
3557
-
3558
- return ( $current_plan_order > $required_plan_order );
3559
- }
3560
-
3561
- /**
3562
- * Check if plan based on trial. If not in trial mode, should return false.
3563
- *
3564
- * @since 1.0.9
3565
- *
3566
- * @param string $plan Plan name
3567
- * @param bool $exact If true, looks for exact plan. If false, also check "higher" plans.
3568
- *
3569
- * @return bool
3570
- */
3571
- function is_trial_plan( $plan, $exact = false ) {
3572
- $this->_logger->entrance();
3573
-
3574
- if ( ! $this->is_registered() ) {
3575
- return false;
3576
- }
3577
-
3578
- if ( ! $this->is_trial() ) {
3579
- return false;
3580
- }
3581
-
3582
- if ( ! isset( $this->_storage->trial_plan ) ) {
3583
- // Store trial plan information.
3584
- $this->_enrich_site_trial_plan( true );
3585
- }
3586
-
3587
- if ( $this->_storage->trial_plan->name === $plan ) // Exact plan.
3588
- {
3589
- return true;
3590
- } else if ( $exact ) // Required exact, but plans are different.
3591
- {
3592
- return false;
3593
- }
3594
-
3595
- $current_plan_order = - 1;
3596
- $required_plan_order = - 1;
3597
- for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
3598
- if ( $plan === $this->_plans[ $i ]->name ) {
3599
- $required_plan_order = $i;
3600
- } else if ( $this->_storage->trial_plan->name === $this->_plans[ $i ]->name ) {
3601
- $current_plan_order = $i;
3602
- }
3603
- }
3604
-
3605
- return ( $current_plan_order > $required_plan_order );
3606
- }
3607
-
3608
- /**
3609
- * Check if plugin has any paid plans.
3610
- *
3611
- * @author Vova Feldman (@svovaf)
3612
- * @since 1.0.7
3613
- *
3614
- * @return bool
3615
- */
3616
- function has_paid_plan() {
3617
- return $this->_has_paid_plans || FS_Plan_Manager::instance()->has_paid_plan( $this->_plans );
3618
- }
3619
-
3620
- /**
3621
- * Check if plugin has any plan with a trail.
3622
- *
3623
- * @author Vova Feldman (@svovaf)
3624
- * @since 1.0.9
3625
- *
3626
- * @return bool
3627
- */
3628
- function has_trial_plan() {
3629
- if ( ! $this->is_registered() ) {
3630
- return false;
3631
- }
3632
-
3633
- return $this->_storage->get( 'has_trial_plan', false );
3634
- }
3635
-
3636
- /**
3637
- * Check if plugin has any free plan, or is it premium only.
3638
- *
3639
- * Note: If no plans configured, assume plugin is free.
3640
- *
3641
- * @author Vova Feldman (@svovaf)
3642
- * @since 1.0.7
3643
- *
3644
- * @return bool
3645
- */
3646
- function has_free_plan() {
3647
- return FS_Plan_Manager::instance()->has_free_plan( $this->_plans );
3648
- }
3649
-
3650
- #region URL Generators
3651
-
3652
- /**
3653
- * Alias to pricing_url().
3654
- *
3655
- * @author Vova Feldman (@svovaf)
3656
- * @since 1.0.2
3657
- *
3658
- * @uses pricing_url
3659
- *
3660
- * @param string $period Billing cycle
3661
- *
3662
- * @return string
3663
- */
3664
- function get_upgrade_url( $period = WP_FS__PERIOD_ANNUALLY ) {
3665
- return $this->pricing_url( $period );
3666
- }
3667
-
3668
- /**
3669
- * @author Vova Feldman (@svovaf)
3670
- * @since 1.0.9
3671
- *
3672
- * @uses get_upgrade_url
3673
- *
3674
- * @return string
3675
- */
3676
- function get_trial_url() {
3677
- return $this->get_upgrade_url( 'trial' );
3678
- }
3679
-
3680
- /**
3681
- * Plugin's pricing URL.
3682
- *
3683
- * @author Vova Feldman (@svovaf)
3684
- * @since 1.0.4
3685
- *
3686
- * @param string $period Billing cycle
3687
- *
3688
- * @return string
3689
- */
3690
- function pricing_url( $period = WP_FS__PERIOD_ANNUALLY ) {
3691
- $this->_logger->entrance();
3692
-
3693
- return $this->_get_admin_page_url( 'pricing', array( 'billing_cycle' => $period ) );
3694
- }
3695
-
3696
- /**
3697
- * Checkout page URL.
3698
- *
3699
- * @author Vova Feldman (@svovaf)
3700
- * @since 1.0.6
3701
- *
3702
- * @param string $period Billing cycle
3703
- * @param bool|string $plan_name
3704
- * @param bool|number $plan_id
3705
- * @param bool|int $licenses
3706
- *
3707
- * @return string
3708
- */
3709
- function checkout_url(
3710
- $period = WP_FS__PERIOD_ANNUALLY,
3711
- $plan_name = false,
3712
- $plan_id = false,
3713
- $licenses = false
3714
- ) {
3715
- $this->_logger->entrance();
3716
-
3717
- $params = array(
3718
- 'checkout' => 'true',
3719
- 'billing_cycle' => $period,
3720
- );
3721
-
3722
- if ( false !== $plan_name ) {
3723
- $params['plan_name'] = $plan_name;
3724
- }
3725
- if ( false !== $plan_id ) {
3726
- $params['plan_id'] = $plan_id;
3727
- }
3728
- if ( false !== $licenses ) {
3729
- $params['licenses'] = $licenses;
3730
- }
3731
-
3732
- return $this->_get_admin_page_url( 'pricing', $params );
3733
- }
3734
-
3735
- #endregion
3736
-
3737
- #endregion ------------------------------------------------------------------
3738
-
3739
- /**
3740
- * Check if plugin has any add-ons.
3741
- *
3742
- * @author Vova Feldman (@svovaf)
3743
- * @since 1.0.5
3744
- *
3745
- * @return bool
3746
- */
3747
- function _has_addons() {
3748
- $this->_logger->entrance();
3749
-
3750
- return ( $this->_has_addons || false !== $this->get_addons() );
3751
- }
3752
-
3753
- /**
3754
- * Check if plugin can work in anonymous mode.
3755
- *
3756
- * @author Vova Feldman (@svovaf)
3757
- * @since 1.0.9
3758
- *
3759
- * @return bool
3760
- */
3761
- function enable_anonymous() {
3762
- return $this->_enable_anonymous;
3763
- }
3764
-
3765
- /**
3766
- * Check if feature supported with current site's plan.
3767
- *
3768
- * @author Vova Feldman (@svovaf)
3769
- * @since 1.0.1
3770
- *
3771
- * @todo IMPLEMENT
3772
- *
3773
- * @param number $feature_id
3774
- *
3775
- * @throws Exception
3776
- */
3777
- function is_feature_supported( $feature_id ) {
3778
- throw new Exception( 'not implemented' );
3779
- }
3780
-
3781
- /**
3782
- * @author Vova Feldman (@svovaf)
3783
- * @since 1.0.1
3784
- *
3785
- * @return bool Is running in SSL/HTTPS
3786
- */
3787
- function is_ssl() {
3788
- return WP_FS__IS_HTTPS;
3789
- }
3790
-
3791
- /**
3792
- * @author Vova Feldman (@svovaf)
3793
- * @since 1.0.9
3794
- *
3795
- * @return bool Is running in AJAX call.
3796
- *
3797
- * @link http://wordpress.stackexchange.com/questions/70676/how-to-check-if-i-am-in-admin-ajax
3798
- */
3799
- function is_ajax() {
3800
- return ( defined( 'DOING_AJAX' ) && DOING_AJAX );
3801
- }
3802
-
3803
- /**
3804
- * Check if running in HTTPS and if site's plan matching the specified plan.
3805
- *
3806
- * @param string $plan
3807
- * @param bool $exact
3808
- *
3809
- * @return bool
3810
- */
3811
- function is_ssl_and_plan( $plan, $exact = false ) {
3812
- return ( $this->is_ssl() && $this->is_plan( $plan, $exact ) );
3813
- }
3814
-
3815
- /**
3816
- * Construct plugin's settings page URL.
3817
- *
3818
- * @author Vova Feldman (@svovaf)
3819
- * @since 1.0.4
3820
- *
3821
- * @param string $page
3822
- * @param array $params
3823
- *
3824
- * @return string
3825
- */
3826
- function _get_admin_page_url( $page = '', $params = array() ) {
3827
- if ( /*empty( $page ) && */ ! $this->_menu->is_top_level() ) {
3828
- $parent_slug = $this->_menu->get_parent_slug();
3829
- $menu_file = ( false !== strpos( $parent_slug, '.php' ) ) ?
3830
- $parent_slug :
3831
- 'admin.php';
3832
-
3833
- return add_query_arg( array_merge( $params, array(
3834
- 'page' => $this->_menu->get_slug( $page ),
3835
- ) ), admin_url( $menu_file, 'admin' ) );
3836
-
3837
-
3838
- // If not a Top-Level menu and asking for main settings page,
3839
- // then try to replicate plugin's main setting original page URL.
3840
- /*switch ( $this->_menu->get_type() ) {
3841
- case 'tools':
3842
- return add_query_arg( array_merge( $params, array(
3843
- 'page' => $this->_menu->get_raw_slug(),
3844
- ) ), admin_url( 'tools.php' ) );
3845
- case 'settings':
3846
- return add_query_arg( array_merge( $params, array(
3847
- 'page' => $this->_menu->get_raw_slug(),
3848
- ) ), admin_url( 'options-general.php' ) );
3849
- }*/
3850
- }
3851
-
3852
- if ( $this->_menu->is_cpt() ) {
3853
- if ( empty( $page ) && $this->is_activation_mode() ) {
3854
- return add_query_arg( array_merge( $params, array(
3855
- 'page' => $this->_menu->get_slug()
3856
- ) ), admin_url( 'admin.php', 'admin' ) );
3857
- } else {
3858
- if ( ! empty( $page ) ) {
3859
- $params['page'] = $this->_menu->get_slug( $page );
3860
- }
3861
-
3862
- return add_query_arg( $params, admin_url( $this->_menu->get_raw_slug(), 'admin' ) );
3863
- }
3864
- } else {
3865
- return add_query_arg( array_merge( $params, array(
3866
- 'page' => $this->_menu->get_slug( $page ),
3867
- ) ), admin_url( 'admin.php', 'admin' ) );
3868
- }
3869
- }
3870
-
3871
-
3872
- /**
3873
- * Plugin's account URL.
3874
- *
3875
- * @author Vova Feldman (@svovaf)
3876
- * @since 1.0.4
3877
- *
3878
- * @param bool|string $action
3879
- * @param array $params
3880
- *
3881
- * @param bool $add_action_nonce
3882
- *
3883
- * @return string
3884
- */
3885
- function get_account_url( $action = false, $params = array(), $add_action_nonce = true ) {
3886
- if ( is_string( $action ) ) {
3887
- $params['fs_action'] = $action;
3888
- }
3889
-
3890
- self::require_pluggable_essentials();
3891
-
3892
- return ( $add_action_nonce && is_string( $action ) ) ?
3893
- wp_nonce_url( $this->_get_admin_page_url( 'account', $params ), $action ) :
3894
- $this->_get_admin_page_url( 'account', $params );
3895
- }
3896
-
3897
- /**
3898
- * Plugin's account URL.
3899
- *
3900
- * @author Vova Feldman (@svovaf)
3901
- * @since 1.0.4
3902
- *
3903
- * @param bool|string $topic
3904
- * @param bool|string $message
3905
- *
3906
- * @return string
3907
- */
3908
- function contact_url( $topic = false, $message = false ) {
3909
- $params = array();
3910
- if ( is_string( $topic ) ) {
3911
- $params['topic'] = $topic;
3912
- }
3913
- if ( is_string( $message ) ) {
3914
- $params['message'] = $message;
3915
- }
3916
-
3917
- if ( $this->is_addon() ) {
3918
- $params['addon_id'] = $this->get_id();
3919
-
3920
- return $this->get_parent_instance()->_get_admin_page_url( 'contact', $params );
3921
- } else {
3922
- return $this->_get_admin_page_url( 'contact', $params );
3923
- }
3924
- }
3925
-
3926
- /**
3927
- * Add-on direct info URL.
3928
- *
3929
- * @author Vova Feldman (@svovaf)
3930
- * @since 1.1.0
3931
- *
3932
- * @param string $slug
3933
- *
3934
- * @return string
3935
- */
3936
- function addon_url( $slug ) {
3937
- return $this->_get_admin_page_url( 'addons', array(
3938
- 'slug' => $slug
3939
- ) );
3940
- }
3941
-
3942
- /* Logger
3943
- ------------------------------------------------------------------------------------------------------------------*/
3944
- /**
3945
- * @param string $id
3946
- * @param bool $prefix_slug
3947
- *
3948
- * @return FS_Logger
3949
- */
3950
- function get_logger( $id = '', $prefix_slug = true ) {
3951
- return FS_Logger::get_logger( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id );
3952
- }
3953
-
3954
- /**
3955
- * @param $id
3956
- * @param bool $load_options
3957
- * @param bool $prefix_slug
3958
- *
3959
- * @return FS_Option_Manager
3960
- */
3961
- function get_options_manager( $id, $load_options = false, $prefix_slug = true ) {
3962
- return FS_Option_Manager::get_manager( ( $prefix_slug ? $this->_slug : '' ) . ( ( ! $prefix_slug || empty( $id ) ) ? '' : '_' ) . $id, $load_options );
3963
- }
3964
-
3965
- /* Security
3966
- ------------------------------------------------------------------------------------------------------------------*/
3967
- private function _encrypt( $str ) {
3968
- if ( is_null( $str ) ) {
3969
- return null;
3970
- }
3971
-
3972
- return base64_encode( $str );
3973
- }
3974
-
3975
- private function _decrypt( $str ) {
3976
- if ( is_null( $str ) ) {
3977
- return null;
3978
- }
3979
-
3980
- return base64_decode( $str );
3981
- }
3982
-
3983
- /**
3984
- * @author Vova Feldman (@svovaf)
3985
- * @since 1.0.5
3986
- *
3987
- * @param FS_Entity $entity
3988
- *
3989
- * @return FS_Entity Return an encrypted clone entity.
3990
- */
3991
- private function _encrypt_entity( FS_Entity $entity ) {
3992
- $clone = clone $entity;
3993
- $props = get_object_vars( $entity );
3994
-
3995
- foreach ( $props as $key => $val ) {
3996
- $clone->{$key} = $this->_encrypt( $val );
3997
- }
3998
-
3999
- return $clone;
4000
- }
4001
-
4002
- /**
4003
- * @author Vova Feldman (@svovaf)
4004
- * @since 1.0.5
4005
- *
4006
- * @param FS_Entity $entity
4007
- *
4008
- * @return FS_Entity Return an decrypted clone entity.
4009
- */
4010
- private function _decrypt_entity( FS_Entity $entity ) {
4011
- $clone = clone $entity;
4012
- $props = get_object_vars( $entity );
4013
-
4014
- foreach ( $props as $key => $val ) {
4015
- $clone->{$key} = $this->_decrypt( $val );
4016
- }
4017
-
4018
- return $clone;
4019
- }
4020
-
4021
- /**
4022
- * Tries to activate account based on POST params.
4023
- *
4024
- * @author Vova Feldman (@svovaf)
4025
- * @since 1.0.2
4026
- */
4027
- function _activate_account() {
4028
- if ( $this->is_registered() ) {
4029
- // Already activated.
4030
- return;
4031
- }
4032
-
4033
- $this->_clean_admin_content_section();
4034
-
4035
- if ( fs_request_is_action( 'activate' ) && fs_request_is_post() ) {
4036
- // check_admin_referer( 'activate_' . $this->_plugin->public_key );
4037
-
4038
- // Verify matching plugin details.
4039
- if ( $this->_plugin->id != fs_request_get( 'plugin_id' ) || $this->_slug != fs_request_get( 'plugin_slug' ) ) {
4040
- return;
4041
- }
4042
-
4043
- $user = new FS_User();
4044
- $user->id = fs_request_get( 'user_id' );
4045
- $user->public_key = fs_request_get( 'user_public_key' );
4046
- $user->secret_key = fs_request_get( 'user_secret_key' );
4047
- $user->email = fs_request_get( 'user_email' );
4048
- $user->first = fs_request_get( 'user_first' );
4049
- $user->last = fs_request_get( 'user_last' );
4050
- $user->is_verified = fs_request_get_bool( 'user_is_verified' );
4051
-
4052
- $site = new FS_Site();
4053
- $site->id = fs_request_get( 'install_id' );
4054
- $site->public_key = fs_request_get( 'install_public_key' );
4055
- $site->secret_key = fs_request_get( 'install_secret_key' );
4056
- $site->plan->id = fs_request_get( 'plan_id' );
4057
- $site->plan->title = fs_request_get( 'plan_title' );
4058
- $site->plan->name = fs_request_get( 'plan_name' );
4059
-
4060
- $plans = array();
4061
- $plans_data = json_decode( urldecode( fs_request_get( 'plans' ) ) );
4062
- foreach ( $plans_data as $p ) {
4063
- $plans[] = new FS_Plugin_Plan( $p );
4064
- }
4065
-
4066
- $this->_set_account( $user, $site, $plans );
4067
-
4068
- // Reload the page with the keys.
4069
- if ( fs_redirect( $this->_get_admin_page_url() ) ) {
4070
- exit();
4071
- }
4072
- }
4073
- }
4074
-
4075
- /**
4076
- * @author Vova Feldman (@svovaf)
4077
- * @since 1.0.7
4078
- *
4079
- * @param string $email
4080
- *
4081
- * @return FS_User|bool
4082
- */
4083
- static function _get_user_by_email( $email ) {
4084
- self::$_static_logger->entrance();
4085
-
4086
- $email = trim( strtolower( $email ) );
4087
- $users = self::get_all_users();
4088
- if ( is_array( $users ) ) {
4089
- foreach ( $users as $u ) {
4090
- if ( $email === trim( strtolower( $u->email ) ) ) {
4091
- return $u;
4092
- }
4093
- }
4094
- }
4095
-
4096
- return false;
4097
- }
4098
-
4099
- #region Account (Loading, Updates & Activation) ------------------------------------------------------------------
4100
-
4101
- /***
4102
- * Load account information (user + site).
4103
- *
4104
- * @author Vova Feldman (@svovaf)
4105
- * @since 1.0.1
4106
- */
4107
- private function _load_account() {
4108
- $this->_logger->entrance();
4109
-
4110
- $this->do_action( 'before_account_load' );
4111
-
4112
- $sites = self::get_all_sites();
4113
- $users = self::get_all_users();
4114
- $plans = self::get_all_plans();
4115
- $licenses = self::get_all_licenses();
4116
-
4117
- if ( $this->_logger->is_on() && is_admin() ) {
4118
- $this->_logger->log( 'sites = ' . var_export( $sites, true ) );
4119
- $this->_logger->log( 'users = ' . var_export( $users, true ) );
4120
- $this->_logger->log( 'plans = ' . var_export( $plans, true ) );
4121
- $this->_logger->log( 'licenses = ' . var_export( $licenses, true ) );
4122
- }
4123
-
4124
- $site = isset( $sites[ $this->_slug ] ) ? $sites[ $this->_slug ] : false;
4125
-
4126
- if ( is_object( $site ) &&
4127
- is_numeric( $site->id ) &&
4128
- is_numeric( $site->user_id ) &&
4129
- is_object( $site->plan )
4130
- ) {
4131
- // Load site.
4132
- $this->_site = clone $site;
4133
- $this->_site->plan = $this->_decrypt_entity( $this->_site->plan );
4134
-
4135
- // Load relevant user.
4136
- $this->_user = clone $users[ $this->_site->user_id ];
4137
-
4138
- // Load plans.
4139
- $this->_plans = $plans[ $this->_slug ];
4140
- if ( ! is_array( $this->_plans ) || empty( $this->_plans ) ) {
4141
- $this->_sync_plans( true );
4142
- } else {
4143
- for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
4144
- if ( $this->_plans[ $i ] instanceof FS_Plugin_Plan ) {
4145
- $this->_plans[ $i ] = $this->_decrypt_entity( $this->_plans[ $i ] );
4146
- } else {
4147
- unset( $this->_plans[ $i ] );
4148
- }
4149
- }
4150
- }
4151
-
4152
- // Load licenses.
4153
- $this->_licenses = array();
4154
- if ( is_array( $licenses ) &&
4155
- isset( $licenses[ $this->_slug ] ) &&
4156
- isset( $licenses[ $this->_slug ][ $this->_user->id ] )
4157
- ) {
4158
- $this->_licenses = $licenses[ $this->_slug ][ $this->_user->id ];
4159
- }
4160
-
4161
- $this->_license = $this->_get_license_by_id( $this->_site->license_id );
4162
-
4163
- if ( $this->_site->version != $this->get_plugin_version() ) {
4164
- // If stored install version is different than current installed plugin version,
4165
- // then update plugin version event.
4166
- $this->update_plugin_version_event();
4167
- }
4168
- }
4169
-
4170
- $this->_register_account_hooks();
4171
- }
4172
-
4173
- /**
4174
- * @author Vova Feldman (@svovaf)
4175
- * @since 1.0.1
4176
- *
4177
- * @param FS_User $user
4178
- * @param FS_Site $site
4179
- * @param bool|array $plans
4180
- */
4181
- private function _set_account( FS_User $user, FS_Site $site, $plans = false ) {
4182
- $site->slug = $this->_slug;
4183
- $site->user_id = $user->id;
4184
-
4185
- $this->_site = $site;
4186
- $this->_user = $user;
4187
- if ( false !== $plans ) {
4188
- $this->_plans = $plans;
4189
- }
4190
-
4191
- $this->send_install_update( array(), true );
4192
-
4193
- $this->_store_account();
4194
-
4195
- }
4196
-
4197
- /**
4198
- * Set user and site identities.
4199
- *
4200
- * @author Vova Feldman (@svovaf)
4201
- * @since 1.0.9
4202
- *
4203
- * @param FS_User $user
4204
- * @param FS_Site $site
4205
- * @param bool $redirect
4206
- *
4207
- * @return bool False if account already set.
4208
- */
4209
- function setup_account( FS_User $user, FS_Site $site, $redirect = true ) {
4210
- $this->_user = $user;
4211
- $this->_site = $site;
4212
- $this->_enrich_site_plan( false );
4213
-
4214
- $this->_set_account( $user, $site );
4215
- $this->_sync_plans();
4216
-
4217
- if ( $this->is_trial() ) {
4218
- // Store trial plan information.
4219
- $this->_enrich_site_trial_plan( true );
4220
- }
4221
-
4222
- $this->do_action( 'after_account_connection', $user, $site );
4223
-
4224
- if ( is_numeric( $site->license_id ) ) {
4225
- $this->_license = $this->_get_license_by_id( $site->license_id );
4226
- }
4227
-
4228
- if ( $this->is_pending_activation() ) {
4229
- // Remove pending activation sticky notice (if still exist).
4230
- $this->_admin_notices->remove_sticky( 'activation_pending' );
4231
-
4232
- // Remove plugin from pending activation mode.
4233
- unset( $this->_storage->is_pending_activation );
4234
-
4235
- if ( ! $this->is_paying() ) {
4236
- $this->_admin_notices->add_sticky(
4237
- sprintf( __fs( 'plugin-x-activation-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
4238
- 'activation_complete'
4239
- );
4240
- }
4241
- }
4242
-
4243
- if ( $this->is_paying() && ! $this->is_premium() ) {
4244
- $this->_admin_notices->add_sticky(
4245
- sprintf(
4246
- __fs( 'activation-with-plan-x-message' ),
4247
- $this->_site->plan->title
4248
- ) . ' ' . $this->_get_latest_download_link( sprintf(
4249
- __fs( 'download-latest-x-version' ),
4250
- $this->_site->plan->title
4251
- ) ),
4252
- 'plan_upgraded',
4253
- __fs( 'yee-haw' ) . '!'
4254
- );
4255
- }
4256
-
4257
- $plugin_id = fs_request_get( 'plugin_id', false );
4258
-
4259
- // Store activation time ONLY for plugins (not add-ons).
4260
- if ( ! is_numeric( $plugin_id ) || ( $plugin_id == $this->_plugin->id ) ) {
4261
- $this->_storage->activation_timestamp = WP_FS__SCRIPT_START_TIME;
4262
- }
4263
-
4264
- if ( is_numeric( $plugin_id ) ) {
4265
- if ( $plugin_id != $this->_plugin->id ) {
4266
- // Add-on was installed - sync license right after install.
4267
- if ( $redirect && fs_redirect( fs_nonce_url( $this->_get_admin_page_url(
4268
- 'account',
4269
- array(
4270
- 'fs_action' => $this->_slug . '_sync_license',
4271
- 'plugin_id' => $plugin_id
4272
- )
4273
- ), $this->_slug . '_sync_license' ) )
4274
- ) {
4275
- exit();
4276
- }
4277
-
4278
- }
4279
- } else {
4280
- // Reload the page with the keys.
4281
- if ( $redirect && fs_redirect( $this->get_after_activation_url( 'after_connect_url' ) ) ) {
4282
- exit();
4283
- }
4284
- }
4285
- }
4286
-
4287
- /**
4288
- * Install plugin with new user information after approval.
4289
- *
4290
- * @author Vova Feldman (@svovaf)
4291
- * @since 1.0.7
4292
- */
4293
- function _install_with_new_user() {
4294
- if ( $this->is_registered() ) {
4295
- return;
4296
- }
4297
-
4298
- if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
4299
- // check_admin_referer( $this->_slug . '_activate_new' );
4300
-
4301
- if ( fs_request_has( 'user_secret_key' ) ) {
4302
- $user = new FS_User();
4303
- $user->id = fs_request_get( 'user_id' );
4304
- $user->public_key = fs_request_get( 'user_public_key' );
4305
- $user->secret_key = fs_request_get( 'user_secret_key' );
4306
-
4307
- $this->_user = $user;
4308
- $user_result = $this->get_api_user_scope()->get();
4309
- $user = new FS_User( $user_result );
4310
- $this->_user = $user;
4311
-
4312
- $site = new FS_Site();
4313
- $site->id = fs_request_get( 'install_id' );
4314
- $site->public_key = fs_request_get( 'install_public_key' );
4315
- $site->secret_key = fs_request_get( 'install_secret_key' );
4316
-
4317
- $this->_site = $site;
4318
- $site_result = $this->get_api_site_scope()->get();
4319
- $site = new FS_Site( $site_result );
4320
- $this->_site = $site;
4321
-
4322
- $this->setup_account( $this->_user, $this->_site );
4323
- } else if ( fs_request_has( 'pending_activation' ) ) {
4324
- // Install must be activated via email since
4325
- // user with the same email already exist.
4326
- $this->_storage->is_pending_activation = true;
4327
- $this->_add_pending_activation_notice( fs_request_get( 'user_email' ) );
4328
-
4329
- // Reload the page with with pending activation message.
4330
- if ( fs_redirect( $this->get_after_activation_url( 'after_pending_connect_url' ) ) ) {
4331
- exit();
4332
- }
4333
- }
4334
- }
4335
- }
4336
-
4337
- /**
4338
- * Install plugin with current logged WP user info.
4339
- *
4340
- * @author Vova Feldman (@svovaf)
4341
- * @since 1.0.7
4342
- */
4343
- function _install_with_current_user() {
4344
- if ( $this->is_registered() ) {
4345
- return;
4346
- }
4347
-
4348
- if ( fs_request_is_action( $this->_slug . '_activate_existing' ) && fs_request_is_post() ) {
4349
- // check_admin_referer( 'activate_existing_' . $this->_plugin->public_key );
4350
- // Get current logged WP user.
4351
- $current_user = wp_get_current_user();
4352
-
4353
- // Find the relevant FS user by the email.
4354
- $user = self::_get_user_by_email( $current_user->user_email );
4355
-
4356
- // We have to set the user before getting user scope API handler.
4357
- $this->_user = $user;
4358
-
4359
- // Install the plugin.
4360
- $install = $this->get_api_user_scope()->call(
4361
- "/plugins/{$this->get_id()}/installs.json",
4362
- 'post',
4363
- $this->get_install_data_for_api( array(
4364
- 'uid' => $this->get_anonymous_id(),
4365
- ) )
4366
- );
4367
-
4368
- if ( isset( $install->error ) ) {
4369
- $this->_admin_notices->add(
4370
- sprintf( __fs( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
4371
- __fs( 'contact-us-with-error-message' ) . ' ' . '<b>' . $install->error->message . '</b>',
4372
- __fs( 'oops' ) . '...',
4373
- 'error'
4374
- );
4375
-
4376
- return;
4377
- }
4378
-
4379
- $site = new FS_Site( $install );
4380
- $this->_site = $site;
4381
- // $this->_enrich_site_plan( false );
4382
-
4383
- // $this->_set_account( $user, $site );
4384
- // $this->_sync_plans();
4385
-
4386
- $this->setup_account( $this->_user, $this->_site );
4387
- }
4388
- }
4389
-
4390
- /**
4391
- * Tries to activate add-on account based on parent plugin info.
4392
- *
4393
- * @author Vova Feldman (@svovaf)
4394
- * @since 1.0.6
4395
- *
4396
- * @param Freemius $parent_fs
4397
- */
4398
- private function _activate_addon_account( Freemius $parent_fs ) {
4399
- if ( $this->is_registered() ) {
4400
- // Already activated.
4401
- return;
4402
- }
4403
-
4404
- // Activate add-on with parent plugin credentials.
4405
- $addon_install = $parent_fs->get_api_site_scope()->call(
4406
- "/addons/{$this->_plugin->id}/installs.json",
4407
- 'post',
4408
- $this->get_install_data_for_api( array(
4409
- 'uid' => $this->get_anonymous_id(),
4410
- ) )
4411
- );
4412
-
4413
- if ( isset( $addon_install->error ) ) {
4414
- $this->_admin_notices->add(
4415
- sprintf( __fs( 'could-not-activate-x' ), $this->get_plugin_name() ) . ' ' .
4416
- __fs( 'contact-us-with-error-message' ) . ' ' . '<b>' . $addon_install->error->message . '</b>',
4417
- __fs( 'oops' ) . '...',
4418
- 'error'
4419
- );
4420
-
4421
- return;
4422
- }
4423
-
4424
- // First of all, set site info - otherwise we won't
4425
- // be able to invoke API calls.
4426
- $this->_site = new FS_Site( $addon_install );
4427
-
4428
- // Sync add-on plans.
4429
- $this->_sync_plans();
4430
-
4431
- // Get site's current plan.
4432
- $this->_site->plan = $this->_get_plan_by_id( $this->_site->plan->id );
4433
-
4434
- // Get user information based on parent's plugin.
4435
- $user = $parent_fs->get_user();
4436
-
4437
- $this->_set_account( $user, $this->_site );
4438
-
4439
- // Sync licenses.
4440
- $this->_sync_licenses();
4441
-
4442
- // Try to activate premium license.
4443
- $this->_activate_license( true );
4444
- }
4445
-
4446
- #endregion ------------------------------------------------------------------
4447
-
4448
- #region Admin Menu Items ------------------------------------------------------------------
4449
-
4450
- private $_menu_items = array();
4451
-
4452
- /**
4453
- * @author Vova Feldman (@svovaf)
4454
- * @since 1.0.7
4455
- *
4456
- * @return string
4457
- */
4458
- function get_menu_slug() {
4459
- return $this->_menu->get_slug();
4460
- }
4461
-
4462
- /**
4463
- * @author Vova Feldman (@svovaf)
4464
- * @since 1.0.9
4465
- */
4466
- function _prepare_admin_menu() {
4467
- if ( ! $this->is_on() ) {
4468
- return;
4469
- }
4470
-
4471
- if ( ! $this->has_api_connectivity() && ! $this->enable_anonymous() ) {
4472
- $this->_menu->remove_menu_item();
4473
- } else {
4474
- $this->add_submenu_items();
4475
- $this->add_menu_action();
4476
- }
4477
- }
4478
-
4479
- /**
4480
- * Admin dashboard menu items modifications.
4481
- *
4482
- * NOTE: admin_menu action executed before admin_init.
4483
- *
4484
- * @author Vova Feldman (@svovaf)
4485
- * @since 1.0.7
4486
- *
4487
- */
4488
- private function add_menu_action() {
4489
- if ( $this->is_activation_mode() ) {
4490
- $this->override_plugin_menu_with_activation();
4491
- } else {
4492
- // If not registered try to install user.
4493
- if ( ! $this->is_registered() &&
4494
- fs_request_is_action( $this->_slug . '_activate_new' )
4495
- ) {
4496
- $this->_install_with_new_user();
4497
- }
4498
- }
4499
- }
4500
-
4501
- /**
4502
- * @author Vova Feldman (@svovaf)
4503
- * @since 1.0.1
4504
- *
4505
- * @return string
4506
- */
4507
- function _redirect_on_clicked_menu_link() {
4508
- $this->_logger->entrance();
4509
-
4510
- $page = strtolower( isset( $_REQUEST['page'] ) ? $_REQUEST['page'] : '' );
4511
-
4512
- $this->_logger->log( 'page = ' . $page );
4513
-
4514
- foreach ( $this->_menu_items as $priority => $items ) {
4515
- foreach ( $items as $item ) {
4516
- if ( isset( $item['url'] ) ) {
4517
- if ( $page === $item['menu_slug'] ) {
4518
- $this->_logger->log( 'Redirecting to ' . $item['url'] );
4519
-
4520
- fs_redirect( $item['url'] );
4521
- }
4522
- }
4523
- }
4524
- }
4525
- }
4526
-
4527
- /**
4528
- * Remove plugin's all admin menu items & pages, and replace with activation page.
4529
- *
4530
- * @author Vova Feldman (@svovaf)
4531
- * @since 1.0.1
4532
- */
4533
- private function override_plugin_menu_with_activation() {
4534
- $this->_logger->entrance();
4535
-
4536
- $hook = false;
4537
-
4538
- if ( $this->_menu->is_top_level() ) {
4539
- $hook = $this->_menu->override_menu_item( array( &$this, '_connect_page_render' ) );
4540
- if ( false === $hook ) {
4541
- // Create new menu item just for the opt-in.
4542
- $hook = add_menu_page(
4543
- $this->get_plugin_name(),
4544
- $this->get_plugin_name(),
4545
- 'manage_options',
4546
- $this->_menu->get_slug(),
4547
- array( &$this, '_connect_page_render' )
4548
- );
4549
- }
4550
- } else {
4551
- $menus = array( $this->_menu->get_parent_slug() );
4552
-
4553
- if ( $this->_menu->is_override_exact() ) {
4554
- // Make sure the current page is matching the activation page.
4555
- $activation_url = strtolower( $this->get_activation_url() );
4556
- $request_url = strtolower( $_SERVER['REQUEST_URI'] );
4557
-
4558
- if ( parse_url( $activation_url, PHP_URL_PATH ) !== parse_url( $request_url, PHP_URL_PATH ) ) {
4559
- // Different path - DO NOT OVERRIDE PAGE.
4560
- return;
4561
- }
4562
-
4563
- $activation_url_params = array();
4564
- parse_str( parse_url( $activation_url, PHP_URL_QUERY ), $activation_url_params );
4565
-
4566
- $request_url_params = array();
4567
- parse_str( parse_url( $request_url, PHP_URL_QUERY ), $request_url_params );
4568
-
4569
-
4570
- foreach ( $activation_url_params as $key => $val ) {
4571
- if ( ! isset( $request_url_params[ $key ] ) || $val != $request_url_params[ $key ] ) {
4572
- // Not matching query string - DO NOT OVERRIDE PAGE.
4573
- return;
4574
- }
4575
- }
4576
- }
4577
-
4578
- foreach ( $menus as $parent_slug ) {
4579
- $hook = $this->_menu->override_submenu_action(
4580
- $parent_slug,
4581
- $this->_menu->get_raw_slug(),
4582
- array( &$this, '_connect_page_render' )
4583
- );
4584
-
4585
- if ( false !== $hook ) {
4586
- // Found plugin's submenu item.
4587
- break;
4588
- }
4589
- }
4590
- }
4591
-
4592
- if ( $this->_menu->is_activation_page() ) {
4593
- // Clean admin page from distracting content.
4594
- $this->_clean_admin_content_section();
4595
- }
4596
-
4597
- if ( false !== $hook ) {
4598
- if ( fs_request_is_action( $this->_slug . '_activate_existing' ) ) {
4599
- add_action( "load-$hook", array( &$this, '_install_with_current_user' ) );
4600
- } else if ( fs_request_is_action( $this->_slug . '_activate_new' ) ) {
4601
- add_action( "load-$hook", array( &$this, '_install_with_new_user' ) );
4602
- }
4603
- }
4604
- }
4605
-
4606
- /**
4607
- * @author Vova Feldman (@svovaf)
4608
- * @since 1.0.0
4609
- *
4610
- * @return string
4611
- */
4612
- private function get_top_level_menu_slug() {
4613
- return ( $this->is_addon() ?
4614
- $this->get_parent_instance()->_menu->get_top_level_menu_slug() :
4615
- $this->_menu->get_top_level_menu_slug() );
4616
- }
4617
-
4618
- /**
4619
- * Add default Freemius menu items.
4620
- *
4621
- * @author Vova Feldman (@svovaf)
4622
- * @since 1.0.0
4623
- */
4624
- private function add_submenu_items() {
4625
- $this->_logger->entrance();
4626
-
4627
- $this->do_action( 'before_admin_menu_init' );
4628
-
4629
- if ( ! $this->is_addon() ) {
4630
- if ( $this->is_registered() || $this->is_anonymous() ) {
4631
- if ( $this->is_registered() ) {
4632
- // Add user account page.
4633
- $this->add_submenu_item(
4634
- __fs( 'account' ),
4635
- array( &$this, '_account_page_render' ),
4636
- $this->get_plugin_name() . ' &ndash; ' . __fs( 'account' ),
4637
- 'manage_options',
4638
- 'account',
4639
- array( &$this, '_account_page_load' ),
4640
- 10,
4641
- $this->_menu->is_submenu_item_visible( 'account' )
4642
- );
4643
- }
4644
-
4645
- // Add contact page.
4646
- $this->add_submenu_item(
4647
- __fs( 'contact-us' ),
4648
- array( &$this, '_contact_page_render' ),
4649
- $this->get_plugin_name() . ' &ndash; ' . __fs( 'contact-us' ),
4650
- 'manage_options',
4651
- 'contact',
4652
- array( &$this, '_clean_admin_content_section' ),
4653
- 10,
4654
- $this->_menu->is_submenu_item_visible( 'contact' )
4655
- );
4656
-
4657
- if ( $this->_has_addons() ) {
4658
- $this->add_submenu_item(
4659
- __fs( 'add-ons' ),
4660
- array( &$this, '_addons_page_render' ),
4661
- $this->get_plugin_name() . ' &ndash; ' . __fs( 'add-ons' ),
4662
- 'manage_options',
4663
- 'addons',
4664
- array( &$this, '_addons_page_load' ),
4665
- WP_FS__LOWEST_PRIORITY - 1,
4666
- $this->_menu->is_submenu_item_visible( 'addons' )
4667
- );
4668
- }
4669
-
4670
- // Add upgrade/pricing page.
4671
- $this->add_submenu_item(
4672
- ( $this->is_paying() ? __fs( 'pricing' ) : __fs( 'upgrade' ) . '&nbsp;&nbsp;&#x27a4;' ),
4673
- array( &$this, '_pricing_page_render' ),
4674
- $this->get_plugin_name() . ' &ndash; ' . __fs( 'pricing' ),
4675
- 'manage_options',
4676
- 'pricing',
4677
- array( &$this, '_clean_admin_content_section' ),
4678
- WP_FS__LOWEST_PRIORITY,
4679
- // If user don't have paid plans, add pricing page
4680
- // to support add-ons checkout but don't add the submenu item.
4681
- $this->_menu->is_submenu_item_visible( 'pricing' ) && ( $this->has_paid_plan() || ( isset( $_GET['page'] ) && $this->_menu->get_slug( 'pricing' ) == $_GET['page'] ) )
4682
- );
4683
- }
4684
- }
4685
-
4686
-
4687
- if ( 0 < count( $this->_menu_items ) ) {
4688
- if ( ! $this->_menu->is_top_level() ) {
4689
- fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
4690
-
4691
- // Append submenu items right after the plugin's submenu item.
4692
- $this->order_sub_submenu_items();
4693
- } else {
4694
- // Append submenu items.
4695
- $this->embed_submenu_items();
4696
- }
4697
- }
4698
- }
4699
-
4700
- /**
4701
- * Moved the actual submenu item additions to a separated function,
4702
- * in order to support sub-submenu items when the plugin's settings
4703
- * only have a submenu and not top-level menu item.
4704
- *
4705
- * @author Vova Feldman (@svovaf)
4706
- * @since 1.1.4
4707
- */
4708
- private function embed_submenu_items() {
4709
- $item_template = $this->_menu->is_top_level() ?
4710
- '<span class="fs-submenu-item">%s</span>' :
4711
- '<span class="fs-submenu-item fs-sub">%s</span>';
4712
-
4713
- ksort( $this->_menu_items );
4714
-
4715
- foreach ( $this->_menu_items as $priority => $items ) {
4716
- foreach ( $items as $item ) {
4717
- if ( ! isset( $item['url'] ) ) {
4718
- $hook = add_submenu_page(
4719
- $item['show_submenu'] ?
4720
- $this->get_top_level_menu_slug() :
4721
- null,
4722
- $item['page_title'],
4723
- sprintf( $item_template, $item['menu_title'] ),
4724
- $item['capability'],
4725
- $item['menu_slug'],
4726
- $item['render_function']
4727
- );
4728
-
4729
- if ( false !== $item['before_render_function'] ) {
4730
- add_action( "load-$hook", $item['before_render_function'] );
4731
- }
4732
- } else {
4733
- add_submenu_page(
4734
- $this->get_top_level_menu_slug(),
4735
- $item['page_title'],
4736
- sprintf( $item_template, $item['menu_title'] ),
4737
- $item['capability'],
4738
- $item['menu_slug'],
4739
- array( $this, '' )
4740
- );
4741
- }
4742
- }
4743
- }
4744
- }
4745
-
4746
- /**
4747
- * Re-order the submenu items so all Freemius added new submenu items
4748
- * are added right after the plugin's settings submenu item.
4749
- *
4750
- * @author Vova Feldman (@svovaf)
4751
- * @since 1.1.4
4752
- */
4753
- private function order_sub_submenu_items() {
4754
- global $submenu;
4755
-
4756
- $top_level_menu = &$submenu[ $this->_menu->get_top_level_menu_slug() ];
4757
-
4758
- $all_submenu_items_after = array();
4759
-
4760
- $found_submenu_item = false;
4761
-
4762
- foreach ( $top_level_menu as $submenu_id => $meta ) {
4763
- if ( $found_submenu_item ) {
4764
- // Remove all submenu items after the plugin's submenu item.
4765
- $all_submenu_items_after[] = $meta;
4766
- unset( $top_level_menu[ $submenu_id ] );
4767
- }
4768
-
4769
- if ( $this->_menu->get_raw_slug() === $meta[2] ) {
4770
- // Found the submenu item, put all below.
4771
- $found_submenu_item = true;
4772
- continue;
4773
- }
4774
- }
4775
-
4776
- // Embed all plugin's new submenu items.
4777
- $this->embed_submenu_items();
4778
-
4779
- // Start with specially high number to make sure it's appended.
4780
- $i = 10000;
4781
- foreach ( $all_submenu_items_after as $meta ) {
4782
- $top_level_menu[ $i ] = $meta;
4783
- $i ++;
4784
- }
4785
-
4786
- // Sort submenu items.
4787
- ksort( $top_level_menu );
4788
- }
4789
-
4790
- function _add_default_submenu_items() {
4791
- if ( ! $this->is_on() ) {
4792
- return;
4793
- }
4794
-
4795
- if ( $this->is_registered() ) {
4796
- if ( $this->_menu->is_submenu_item_visible( 'support' ) ) {
4797
- $this->add_submenu_link_item(
4798
- __fs( 'support-forum' ),
4799
- 'https://wordpress.org/support/plugin/' . $this->_slug,
4800
- 'wp-support-forum',
4801
- 'read',
4802
- 50
4803
- );
4804
- }
4805
- }
4806
- }
4807
-
4808
- /**
4809
- * @author Vova Feldman (@svovaf)
4810
- * @since 1.0.1
4811
- *
4812
- * @param string $menu_title
4813
- * @param callable $render_function
4814
- * @param bool|string $page_title
4815
- * @param string $capability
4816
- * @param bool|string $menu_slug
4817
- * @param bool|callable $before_render_function
4818
- * @param int $priority
4819
- * @param bool $show_submenu
4820
- */
4821
- function add_submenu_item(
4822
- $menu_title,
4823
- $render_function,
4824
- $page_title = false,
4825
- $capability = 'manage_options',
4826
- $menu_slug = false,
4827
- $before_render_function = false,
4828
- $priority = 10,
4829
- $show_submenu = true
4830
- ) {
4831
- $this->_logger->entrance( 'Title = ' . $menu_title );
4832
-
4833
- if ( $this->is_addon() ) {
4834
- $parent_fs = $this->get_parent_instance();
4835
-
4836
- if ( is_object( $parent_fs ) ) {
4837
- $parent_fs->add_submenu_item(
4838
- $menu_title,
4839
- $render_function,
4840
- $page_title,
4841
- $capability,
4842
- $menu_slug,
4843
- $before_render_function,
4844
- $priority,
4845
- $show_submenu
4846
- );
4847
-
4848
- return;
4849
- }
4850
- }
4851
-
4852
- if ( ! isset( $this->_menu_items[ $priority ] ) ) {
4853
- $this->_menu_items[ $priority ] = array();
4854
- }
4855
-
4856
- $this->_menu_items[ $priority ][] = array(
4857
- 'page_title' => is_string( $page_title ) ? $page_title : $menu_title,
4858
- 'menu_title' => $menu_title,
4859
- 'capability' => $capability,
4860
- 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
4861
- 'render_function' => $render_function,
4862
- 'before_render_function' => $before_render_function,
4863
- 'show_submenu' => $show_submenu,
4864
- );
4865
- }
4866
-
4867
- /**
4868
- * @author Vova Feldman (@svovaf)
4869
- * @since 1.0.1
4870
- *
4871
- * @param string $menu_title
4872
- * @param string $url
4873
- * @param bool $menu_slug
4874
- * @param string $capability
4875
- * @param int $priority
4876
- *
4877
- */
4878
- function add_submenu_link_item(
4879
- $menu_title,
4880
- $url,
4881
- $menu_slug = false,
4882
- $capability = 'read',
4883
- $priority = 10
4884
- ) {
4885
- $this->_logger->entrance( 'Title = ' . $menu_title . '; Url = ' . $url );
4886
-
4887
- if ( $this->is_addon() ) {
4888
- $parent_fs = $this->get_parent_instance();
4889
-
4890
- if ( is_object( $parent_fs ) ) {
4891
- $parent_fs->add_submenu_link_item(
4892
- $menu_title,
4893
- $url,
4894
- $menu_slug,
4895
- $capability,
4896
- $priority
4897
- );
4898
-
4899
- return;
4900
- }
4901
- }
4902
-
4903
- if ( ! isset( $this->_menu_items[ $priority ] ) ) {
4904
- $this->_menu_items[ $priority ] = array();
4905
- }
4906
-
4907
- $this->_menu_items[ $priority ][] = array(
4908
- 'menu_title' => $menu_title,
4909
- 'capability' => $capability,
4910
- 'menu_slug' => $this->_menu->get_slug( is_string( $menu_slug ) ? $menu_slug : strtolower( $menu_title ) ),
4911
- 'url' => $url,
4912
- 'page_title' => $menu_title,
4913
- 'render_function' => 'fs_dummy',
4914
- 'before_render_function' => '',
4915
- );
4916
- }
4917
-
4918
- #endregion ------------------------------------------------------------------
4919
-
4920
- /* Actions / Hooks / Filters
4921
- ------------------------------------------------------------------------------------------------------------------*/
4922
- /**
4923
- * Do action, specific for the current context plugin.
4924
- *
4925
- * @author Vova Feldman (@svovaf)
4926
- * @since 1.0.1
4927
- *
4928
- * @param string $tag The name of the action to be executed.
4929
- * @param mixed $arg,... Optional. Additional arguments which are passed on to the
4930
- * functions hooked to the action. Default empty.
4931
- *
4932
- * @uses do_action()
4933
- */
4934
- function do_action( $tag, $arg = '' ) {
4935
- $this->_logger->entrance( $tag );
4936
-
4937
- $args = func_get_args();
4938
-
4939
- call_user_func_array( 'do_action', array_merge(
4940
- array( 'fs_' . $tag . '_' . $this->_slug ),
4941
- array_slice( $args, 1 ) )
4942
- );
4943
- }
4944
-
4945
- /**
4946
- * Add action, specific for the current context plugin.
4947
- *
4948
- * @author Vova Feldman (@svovaf)
4949
- * @since 1.0.1
4950
- *
4951
- * @param string $tag
4952
- * @param callable $function_to_add
4953
- * @param int $priority
4954
- * @param int $accepted_args
4955
- *
4956
- * @uses add_action()
4957
- */
4958
- function add_action( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
4959
- $this->_logger->entrance( $tag );
4960
-
4961
- add_action( 'fs_' . $tag . '_' . $this->_slug, $function_to_add, $priority, $accepted_args );
4962
- }
4963
-
4964
- /**
4965
- * Apply filter, specific for the current context plugin.
4966
- *
4967
- * @author Vova Feldman (@svovaf)
4968
- * @since 1.0.9
4969
- *
4970
- * @param string $tag The name of the filter hook.
4971
- * @param mixed $value The value on which the filters hooked to `$tag` are applied on.
4972
- *
4973
- * @return mixed The filtered value after all hooked functions are applied to it.
4974
- *
4975
- * @uses apply_filters()
4976
- */
4977
- function apply_filters( $tag, $value ) {
4978
- $this->_logger->entrance( $tag );
4979
-
4980
- $args = func_get_args();
4981
-
4982
- return call_user_func_array( 'apply_filters', array_merge(
4983
- array( 'fs_' . $tag . '_' . $this->_slug ),
4984
- array_slice( $args, 1 ) )
4985
- );
4986
- }
4987
-
4988
- /**
4989
- * Add filter, specific for the current context plugin.
4990
- *
4991
- * @author Vova Feldman (@svovaf)
4992
- * @since 1.0.9
4993
- *
4994
- * @param string $tag
4995
- * @param callable $function_to_add
4996
- * @param int $priority
4997
- * @param int $accepted_args
4998
- *
4999
- * @uses add_filter()
5000
- */
5001
- function add_filter( $tag, $function_to_add, $priority = 10, $accepted_args = 1 ) {
5002
- $this->_logger->entrance( $tag );
5003
-
5004
- add_filter( 'fs_' . $tag . '_' . $this->_slug, $function_to_add, $priority, $accepted_args );
5005
- }
5006
-
5007
- /* Account Page
5008
- ------------------------------------------------------------------------------------------------------------------*/
5009
- /**
5010
- * Update site information.
5011
- *
5012
- * @author Vova Feldman (@svovaf)
5013
- * @since 1.0.1
5014
- *
5015
- * @param bool $store Flush to Database if true.
5016
- */
5017
- private function _store_site( $store = true ) {
5018
- $this->_logger->entrance();
5019
-
5020
- $encrypted_site = clone $this->_site;
5021
- $encrypted_site->plan = $this->_encrypt_entity( $this->_site->plan );
5022
-
5023
- $sites = self::get_all_sites();
5024
- $sites[ $this->_slug ] = $encrypted_site;
5025
- self::$_accounts->set_option( 'sites', $sites, $store );
5026
- }
5027
-
5028
- /**
5029
- * Update plugin's plans information.
5030
- *
5031
- * @author Vova Feldman (@svovaf)
5032
- * @since 1.0.2
5033
- *
5034
- * @param bool $store Flush to Database if true.
5035
- */
5036
- private function _store_plans( $store = true ) {
5037
- $this->_logger->entrance();
5038
-
5039
- $plans = self::get_all_plans();
5040
-
5041
- // Copy plans.
5042
- $encrypted_plans = array();
5043
- for ( $i = 0, $len = count( $this->_plans ); $i < $len; $i ++ ) {
5044
- $encrypted_plans[] = $this->_encrypt_entity( $this->_plans[ $i ] );
5045
- }
5046
-
5047
- $plans[ $this->_slug ] = $encrypted_plans;
5048
- self::$_accounts->set_option( 'plans', $plans, $store );
5049
- }
5050
-
5051
- /**
5052
- * Update user's plugin licenses.
5053
- *
5054
- * @author Vova Feldman (@svovaf)
5055
- * @since 1.0.5
5056
- *
5057
- * @param bool $store
5058
- * @param string|bool $plugin_slug
5059
- * @param FS_Plugin_License[] $licenses
5060
- */
5061
- private function _store_licenses( $store = true, $plugin_slug = false, $licenses = array() ) {
5062
- $this->_logger->entrance();
5063
-
5064
- $all_licenses = self::get_all_licenses();
5065
-
5066
- if ( ! is_string( $plugin_slug ) ) {
5067
- $plugin_slug = $this->_slug;
5068
- $licenses = $this->_licenses;
5069
- }
5070
-
5071
- if ( ! isset( $all_licenses[ $plugin_slug ] ) ) {
5072
- $all_licenses[ $plugin_slug ] = array();
5073
- }
5074
-
5075
- $all_licenses[ $plugin_slug ][ $this->_user->id ] = $licenses;
5076
-
5077
- self::$_accounts->set_option( 'licenses', $all_licenses, $store );
5078
- }
5079
-
5080
- /**
5081
- * Update user information.
5082
- *
5083
- * @author Vova Feldman (@svovaf)
5084
- * @since 1.0.1
5085
- *
5086
- * @param bool $store Flush to Database if true.
5087
- */
5088
- private function _store_user( $store = true ) {
5089
- $this->_logger->entrance();
5090
-
5091
- $users = self::get_all_users();
5092
- $users[ $this->_user->id ] = $this->_user;
5093
- self::$_accounts->set_option( 'users', $users, $store );
5094
- }
5095
-
5096
- /**
5097
- * Update new updates information.
5098
- *
5099
- * @author Vova Feldman (@svovaf)
5100
- * @since 1.0.4
5101
- *
5102
- * @param FS_Plugin_Tag|null $update
5103
- * @param bool $store Flush to Database if true.
5104
- * @param bool|number $plugin_id
5105
- */
5106
- private function _store_update( $update, $store = true, $plugin_id = false ) {
5107
- $this->_logger->entrance();
5108
-
5109
- if ( $update instanceof FS_Plugin_Tag ) {
5110
- $update->updated = time();
5111
- }
5112
-
5113
- if ( ! is_numeric( $plugin_id ) ) {
5114
- $plugin_id = $this->_plugin->id;
5115
- }
5116
-
5117
- $updates = self::get_all_updates();
5118
- $updates[ $plugin_id ] = $update;
5119
- self::$_accounts->set_option( 'updates', $updates, $store );
5120
- }
5121
-
5122
- /**
5123
- * Update new updates information.
5124
- *
5125
- * @author Vova Feldman (@svovaf)
5126
- * @since 1.0.6
5127
- *
5128
- * @param FS_Plugin[] $plugin_addons
5129
- * @param bool $store Flush to Database if true.
5130
- */
5131
- private function _store_addons( $plugin_addons, $store = true ) {
5132
- $this->_logger->entrance();
5133
-
5134
- $addons = self::get_all_addons();
5135
- $addons[ $this->_plugin->id ] = $plugin_addons;
5136
- self::$_accounts->set_option( 'addons', $addons, $store );
5137
- }
5138
-
5139
- /**
5140
- * Delete plugin's associated add-ons.
5141
- *
5142
- * @author Vova Feldman (@svovaf)
5143
- * @since 1.0.8
5144
- *
5145
- * @param bool $store
5146
- *
5147
- * @return bool
5148
- */
5149
- private function _delete_account_addons( $store = true ) {
5150
- $all_addons = self::get_all_account_addons();
5151
-
5152
- if ( ! isset( $all_addons[ $this->_plugin->id ] ) ) {
5153
- return false;
5154
- }
5155
-
5156
- unset( $all_addons[ $this->_plugin->id ] );
5157
-
5158
- self::$_accounts->set_option( 'account_addons', $all_addons, $store );
5159
-
5160
- return true;
5161
- }
5162
-
5163
- /**
5164
- * Update account add-ons list.
5165
- *
5166
- * @author Vova Feldman (@svovaf)
5167
- * @since 1.0.6
5168
- *
5169
- * @param FS_Plugin[] $addons
5170
- * @param bool $store Flush to Database if true.
5171
- */
5172
- private function _store_account_addons( $addons, $store = true ) {
5173
- $this->_logger->entrance();
5174
-
5175
- $all_addons = self::get_all_account_addons();
5176
- $all_addons[ $this->_plugin->id ] = $addons;
5177
- self::$_accounts->set_option( 'account_addons', $all_addons, $store );
5178
- }
5179
-
5180
- /**
5181
- * Store account params in the Database.
5182
- *
5183
- * @author Vova Feldman (@svovaf)
5184
- * @since 1.0.1
5185
- */
5186
- private function _store_account() {
5187
- $this->_logger->entrance();
5188
-
5189
- $this->_store_site( false );
5190
- $this->_store_user( false );
5191
- $this->_store_plans( false );
5192
- $this->_store_licenses( false );
5193
-
5194
- self::$_accounts->store();
5195
- }
5196
-
5197
- /**
5198
- * Sync user's information.
5199
- *
5200
- * @author Vova Feldman (@svovaf)
5201
- * @since 1.0.3
5202
- * @uses FS_Api
5203
- */
5204
- private function _handle_account_user_sync() {
5205
- $this->_logger->entrance();
5206
-
5207
- $api = $this->get_api_user_scope();
5208
-
5209
- // Get user's information.
5210
- $user = $api->get( '/', true );
5211
-
5212
- if ( isset( $user->id ) ) {
5213
- $this->_user->first = $user->first;
5214
- $this->_user->last = $user->last;
5215
- $this->_user->email = $user->email;
5216
-
5217
- if ( ( ! isset( $this->_user->is_verified ) || false === $this->_user->is_verified ) && $user->is_verified ) {
5218
- $this->_user->is_verified = $user->is_verified;
5219
-
5220
- $this->do_action( 'account_email_verified', $user->email );
5221
-
5222
- $this->_admin_notices->add(
5223
- __fs( 'email-verified-message' ),
5224
- __fs( 'right-on' ) . '!'
5225
- );
5226
- }
5227
-
5228
- // Flush user details to DB.
5229
- $this->_store_user();
5230
-
5231
- $this->do_action( 'after_account_user_sync', $user );
5232
- }
5233
- }
5234
-
5235
- /**
5236
- * @author Vova Feldman (@svovaf)
5237
- * @since 1.0.5
5238
- * @uses FS_Api
5239
- *
5240
- * @param bool $flush
5241
- *
5242
- * @return object|\FS_Site
5243
- */
5244
- private function _fetch_site( $flush = false ) {
5245
- $this->_logger->entrance();
5246
- $api = $this->get_api_site_scope();
5247
-
5248
- $site = $api->get( '/', $flush );
5249
-
5250
- if ( ! isset( $site->error ) ) {
5251
- $site = new FS_Site( $site );
5252
- $site->slug = $this->_slug;
5253
- $site->version = $this->get_plugin_version();
5254
- }
5255
-
5256
- return $site;
5257
- }
5258
-
5259
- /**
5260
- * @param bool $store
5261
- *
5262
- * @return FS_Plugin_Plan|object|false
5263
- */
5264
- private function _enrich_site_plan( $store = true ) {
5265
- // Try to load plan from local cache.
5266
- $plan = $this->_get_plan_by_id( $this->_site->plan->id );
5267
-
5268
- if ( false === $plan ) {
5269
- $plan = $this->_fetch_site_plan();
5270
- }
5271
-
5272
- if ( $plan instanceof FS_Plugin_Plan ) {
5273
- $this->_update_plan( $plan, $store );
5274
- }
5275
-
5276
- return $plan;
5277
- }
5278
-
5279
- /**
5280
- * @author Vova Feldman (@svovaf)
5281
- * @since 1.0.9
5282
- * @uses FS_Api
5283
- *
5284
- * @param bool $store
5285
- *
5286
- * @return FS_Plugin_Plan|object|false
5287
- */
5288
- private function _enrich_site_trial_plan( $store = true ) {
5289
- // Try to load plan from local cache.
5290
- $trial_plan = $this->_get_plan_by_id( $this->_site->trial_plan_id );
5291
-
5292
- if ( false === $trial_plan ) {
5293
- $trial_plan = $this->_fetch_site_plan( $this->_site->trial_plan_id );
5294
- }
5295
-
5296
- if ( $trial_plan instanceof FS_Plugin_Plan ) {
5297
- $this->_storage->store( 'trial_plan', $trial_plan, $store );
5298
- }
5299
-
5300
- return $trial_plan;
5301
- }
5302
-
5303
- /**
5304
- * @author Vova Feldman (@svovaf)
5305
- * @since 1.0.9
5306
- * @uses FS_Api
5307
- *
5308
- * @param number|bool $license_id
5309
- *
5310
- * @return FS_Subscription|object|bool
5311
- */
5312
- private function _fetch_site_license_subscription( $license_id = false ) {
5313
- $this->_logger->entrance();
5314
- $api = $this->get_api_site_scope();
5315
-
5316
- if ( ! is_numeric( $license_id ) ) {
5317
- $license_id = $this->_license->id;
5318
- }
5319
-
5320
- $result = $api->get( "/licenses/{$license_id}/subscriptions.json", true );
5321
-
5322
- return ! isset( $result->error ) ?
5323
- ( ( is_array( $result->subscriptions ) && 0 < count( $result->subscriptions ) ) ?
5324
- new FS_Subscription( $result->subscriptions[0] ) :
5325
- false
5326
- ) :
5327
- $result;
5328
- }
5329
-
5330
- /**
5331
- * @author Vova Feldman (@svovaf)
5332
- * @since 1.0.4
5333
- * @uses FS_Api
5334
- *
5335
- * @param number|bool $plan_id
5336
- *
5337
- * @return FS_Plugin_Plan|object
5338
- */
5339
- private function _fetch_site_plan( $plan_id = false ) {
5340
- $this->_logger->entrance();
5341
- $api = $this->get_api_site_scope();
5342
-
5343
- if ( ! is_numeric( $plan_id ) ) {
5344
- $plan_id = $this->_site->plan->id;
5345
- }
5346
-
5347
- $plan = $api->get( "/plans/{$plan_id}.json", true );
5348
-
5349
- return ! isset( $plan->error ) ? new FS_Plugin_Plan( $plan ) : $plan;
5350
- }
5351
-
5352
- /**
5353
- * @author Vova Feldman (@svovaf)
5354
- * @since 1.0.5
5355
- * @uses FS_Api
5356
- *
5357
- * @return FS_Plugin_Plan[]|object
5358
- */
5359
- private function _fetch_plugin_plans() {
5360
- $this->_logger->entrance();
5361
- $api = $this->get_api_site_scope();
5362
-
5363
- $result = $api->get( '/plans.json', true );
5364
-
5365
- if ( ! $this->is_api_error( $result ) ) {
5366
- for ( $i = 0, $len = count( $result->plans ); $i < $len; $i ++ ) {
5367
- $result->plans[ $i ] = new FS_Plugin_Plan( $result->plans[ $i ] );
5368
- }
5369
-
5370
- $result = $result->plans;
5371
- }
5372
-
5373
- return $result;
5374
- }
5375
-
5376
- /**
5377
- * @author Vova Feldman (@svovaf)
5378
- * @since 1.0.5
5379
- * @uses FS_Api
5380
- *
5381
- * @param number|bool $plugin_id
5382
- *
5383
- * @return FS_Plugin_License[]|object
5384
- */
5385
- private function _fetch_licenses( $plugin_id = false ) {
5386
- $this->_logger->entrance();
5387
-
5388
- $api = $this->get_api_user_scope();
5389
-
5390
- if ( ! is_numeric( $plugin_id ) ) {
5391
- $plugin_id = $this->_plugin->id;
5392
- }
5393
-
5394
- $result = $api->get( "/plugins/{$plugin_id}/licenses.json", true );
5395
-
5396
- if ( ! isset( $result->error ) ) {
5397
- for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
5398
- $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
5399
- }
5400
-
5401
- $result = $result->licenses;
5402
- }
5403
-
5404
- return $result;
5405
- }
5406
-
5407
- /**
5408
- * @author Vova Feldman (@svovaf)
5409
- * @since 1.0.4
5410
- *
5411
- * @param FS_Plugin_Plan $plan
5412
- * @param bool $store
5413
- */
5414
- private function _update_plan( $plan, $store = false ) {
5415
- $this->_logger->entrance();
5416
-
5417
- $this->_site->plan = $plan;
5418
- $this->_store_site( $store );
5419
- }
5420
-
5421
- /**
5422
- * @author Vova Feldman (@svovaf)
5423
- * @since 1.0.5
5424
- *
5425
- * @param FS_Plugin_License[] $licenses
5426
- * @param string|bool $plugin_slug
5427
- */
5428
- private function _update_licenses( $licenses, $plugin_slug = false ) {
5429
- $this->_logger->entrance();
5430
-
5431
- if ( is_array( $licenses ) ) {
5432
- for ( $i = 0, $len = count( $licenses ); $i < $len; $i ++ ) {
5433
- $licenses[ $i ]->updated = time();
5434
- }
5435
- }
5436
-
5437
- if ( ! is_string( $plugin_slug ) ) {
5438
- $this->_licenses = $licenses;
5439
- }
5440
-
5441
- $this->_store_licenses( true, $plugin_slug, $licenses );
5442
- }
5443
-
5444
- /**
5445
- * @author Vova Feldman (@svovaf)
5446
- * @since 1.0.4
5447
- *
5448
- * @param bool|number $plugin_id
5449
- *
5450
- * @return object|false New plugin tag info if exist.
5451
- */
5452
- private function _fetch_newer_version( $plugin_id = false ) {
5453
- $latest_tag = $this->_fetch_latest_version( $plugin_id );
5454
-
5455
- if ( ! is_object( $latest_tag ) ) {
5456
- return false;
5457
- }
5458
-
5459
- // Check if version is actually newer.
5460
- $has_new_version =
5461
- // If it's an non-installed add-on then always return latest.
5462
- ( $this->_is_addon_id( $plugin_id ) && ! $this->is_addon_activated( $plugin_id ) ) ||
5463
- // Compare versions.
5464
- version_compare( $this->get_plugin_version(), $latest_tag->version, '<' );
5465
-
5466
- $this->_logger->departure( $has_new_version ? 'Found newer plugin version ' . $latest_tag->version : 'No new version' );
5467
-
5468
- return $has_new_version ? $latest_tag : false;
5469
- }
5470
-
5471
- /**
5472
- * @author Vova Feldman (@svovaf)
5473
- * @since 1.0.5
5474
- *
5475
- * @param bool|number $plugin_id
5476
- *
5477
- * @return bool|FS_Plugin_Tag
5478
- */
5479
- function get_update( $plugin_id = false ) {
5480
- $this->_logger->entrance();
5481
-
5482
- if ( ! is_numeric( $plugin_id ) ) {
5483
- $plugin_id = $this->_plugin->id;
5484
- }
5485
-
5486
- $this->_check_updates( true, $plugin_id );
5487
- $updates = $this->get_all_updates();
5488
-
5489
- return isset( $updates[ $plugin_id ] ) && is_object( $updates[ $plugin_id ] ) ? $updates[ $plugin_id ] : false;
5490
- }
5491
-
5492
- /**
5493
- * Check if site assigned with active license.
5494
- *
5495
- * @author Vova Feldman (@svovaf)
5496
- * @since 1.0.6
5497
- */
5498
- function has_active_license() {
5499
- return (
5500
- is_object( $this->_license ) &&
5501
- is_numeric( $this->_license->id ) &&
5502
- ! $this->_license->is_expired()
5503
- );
5504
- }
5505
-
5506
- /**
5507
- * Check if site assigned with license with enabled features.
5508
- *
5509
- * @author Vova Feldman (@svovaf)
5510
- * @since 1.0.6
5511
- *
5512
- * @return bool
5513
- */
5514
- function has_features_enabled_license() {
5515
- return (
5516
- is_object( $this->_license ) &&
5517
- is_numeric( $this->_license->id ) &&
5518
- $this->_license->is_features_enabled()
5519
- );
5520
- }
5521
-
5522
- /**
5523
- * Sync site's plan.
5524
- *
5525
- * @author Vova Feldman (@svovaf)
5526
- * @since 1.0.3
5527
- *
5528
- * @uses FS_Api
5529
- *
5530
- * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
5531
- * the admin.
5532
- */
5533
- private function _sync_license( $background = false ) {
5534
- $this->_logger->entrance();
5535
-
5536
- $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
5537
-
5538
- $is_addon_sync = ( ! $this->_plugin->is_addon() && $plugin_id != $this->get_id() );
5539
-
5540
- if ( $is_addon_sync ) {
5541
- $this->_sync_addon_license( $plugin_id, $background );
5542
- } else {
5543
- $this->_sync_plugin_license( $background );
5544
- }
5545
-
5546
- $this->do_action( 'after_account_plan_sync', $this->_site->plan->name );
5547
- }
5548
-
5549
- /**
5550
- * Sync plugin's add-on license.
5551
- *
5552
- * @author Vova Feldman (@svovaf)
5553
- * @since 1.0.6
5554
- * @uses FS_Api
5555
- *
5556
- * @param number $addon_id
5557
- * @param bool $background
5558
- */
5559
- private function _sync_addon_license( $addon_id, $background ) {
5560
- $this->_logger->entrance();
5561
-
5562
- if ( $this->is_addon_activated( $addon_id ) ) {
5563
- // If already installed, use add-on sync.
5564
- $fs_addon = self::get_instance_by_id( $addon_id );
5565
- $fs_addon->_sync_license( $background );
5566
-
5567
- return;
5568
- }
5569
-
5570
- // Validate add-on exists.
5571
- $addon = $this->get_addon( $addon_id );
5572
-
5573
- if ( ! is_object( $addon ) ) {
5574
- return;
5575
- }
5576
-
5577
- // Add add-on into account add-ons.
5578
- $account_addons = $this->get_account_addons();
5579
- if ( ! is_array( $account_addons ) ) {
5580
- $account_addons = array();
5581
- }
5582
- $account_addons[] = $addon->id;
5583
- $account_addons = array_unique( $account_addons );
5584
- $this->_store_account_addons( $account_addons );
5585
-
5586
- // Load add-on licenses.
5587
- $licenses = $this->_fetch_licenses( $addon->id );
5588
-
5589
- // Sync add-on licenses.
5590
- if ( ! isset( $licenses->error ) ) {
5591
- $this->_update_licenses( $licenses, $addon->slug );
5592
-
5593
- if ( ! $this->is_addon_installed( $addon->slug ) && FS_License_Manager::has_premium_license( $licenses ) ) {
5594
- $plans_result = $this->get_api_site_or_plugin_scope()->get( "/addons/{$addon_id}/plans.json" );
5595
-
5596
- if ( ! isset( $plans_result->error ) ) {
5597
- $plans = array();
5598
- foreach ( $plans_result->plans as $plan ) {
5599
- $plans[] = new FS_Plugin_Plan( $plan );
5600
- }
5601
-
5602
- $this->_admin_notices->add_sticky(
5603
- FS_Plan_Manager::instance()->has_free_plan( $plans ) ?
5604
- sprintf(
5605
- __fs( 'addon-successfully-upgraded-message' ),
5606
- $addon->title
5607
- ) . ' ' . $this->_get_latest_download_link(
5608
- __fs( 'download-latest-version' ),
5609
- $addon_id
5610
- )
5611
- :
5612
- sprintf(
5613
- __fs( 'addon-successfully-purchased-message' ),
5614
- $addon->title
5615
- ) . ' ' . $this->_get_latest_download_link(
5616
- __fs( 'download-latest-version' ),
5617
- $addon_id
5618
- ),
5619
- 'addon_plan_upgraded_' . $addon->slug,
5620
- __fs( 'yee-haw' ) . '!'
5621
- );
5622
- }
5623
- }
5624
- }
5625
- }
5626
-
5627
- /**
5628
- * Sync site's plugin plan.
5629
- *
5630
- * @author Vova Feldman (@svovaf)
5631
- * @since 1.0.6
5632
- * @uses FS_Api
5633
- *
5634
- * @param bool $background Hints the method if it's a background sync. If false, it means that was initiated by
5635
- * the admin.
5636
- */
5637
- private function _sync_plugin_license( $background = false ) {
5638
- $this->_logger->entrance();
5639
-
5640
- // Sync site info.
5641
- $site = $this->send_install_update( array(), true );
5642
-
5643
- $plan_change = 'none';
5644
-
5645
- if ( $this->is_api_error( $site ) ) {
5646
- $api = $this->get_api_site_scope();
5647
-
5648
- // Try to ping API to see if not blocked.
5649
- if ( ! $api->test() ) {
5650
- // Failed to ping API - blocked!
5651
- $this->_admin_notices->add(
5652
- sprintf(
5653
- __fs( 'server-blocking-access' ),
5654
- $this->get_plugin_name(),
5655
- '<a href="' . $api->get_url() . '" target="_blank">' . $api->get_url() . '</a>'
5656
- ) . '<br> ' . __fs( 'server-error-message' ) . var_export( $site->error, true ),
5657
- __fs( 'oops' ) . '...',
5658
- 'error',
5659
- $background
5660
- );
5661
- } else {
5662
- // Authentication params are broken.
5663
- $this->_admin_notices->add(
5664
- __fs( 'wrong-authentication-param-message' ),
5665
- __fs( 'oops' ) . '...',
5666
- 'error'
5667
- );
5668
- }
5669
- } else {
5670
- $site = new FS_Site( $site );
5671
-
5672
- // Sync licenses.
5673
- $this->_sync_licenses();
5674
-
5675
- // Sync plans.
5676
- $this->_sync_plans();
5677
-
5678
- // Check if plan / license changed.
5679
- if ( ! FS_Entity::equals( $site->plan, $this->_site->plan ) ||
5680
- // Check if trial started.
5681
- $site->trial_plan_id != $this->_site->trial_plan_id ||
5682
- $site->trial_ends != $this->_site->trial_ends ||
5683
- // Check if license changed.
5684
- $site->license_id != $this->_site->license_id
5685
- ) {
5686
- if ( $site->is_trial() && ! $this->_site->is_trial() ) {
5687
- // New trial started.
5688
- $this->_site = $site;
5689
- $plan_change = 'trial_started';
5690
-
5691
- // Store trial plan information.
5692
- $this->_enrich_site_trial_plan( true );
5693
-
5694
- } else if ( $this->_site->is_trial() && ! $site->is_trial() && ! is_numeric( $site->license_id ) ) {
5695
- // Was in trial, but now trial expired and no license ID.
5696
- // New trial started.
5697
- $this->_site = $site;
5698
- $plan_change = 'trial_expired';
5699
-
5700
- // Clear trial plan information.
5701
- $this->_storage->trial_plan = null;
5702
-
5703
- } else {
5704
- $is_free = $this->is_free_plan();
5705
-
5706
- // Make sure license exist and not expired.
5707
- $new_license = is_null( $site->license_id ) ? null : $this->_get_license_by_id( $site->license_id );
5708
-
5709
- if ( $is_free && ( ( ! is_object( $new_license ) || $new_license->is_expired() ) ) ) {
5710
- // The license is expired, so ignore upgrade method.
5711
- } else {
5712
- // License changed.
5713
- $this->_site = $site;
5714
- $this->_update_site_license( $new_license );
5715
- $this->_store_licenses();
5716
- $this->_enrich_site_plan( true );
5717
-
5718
- $plan_change = $is_free ?
5719
- 'upgraded' :
5720
- ( is_object( $new_license ) ?
5721
- 'changed' :
5722
- 'downgraded' );
5723
- }
5724
- }
5725
-
5726
- // Store updated site info.
5727
- $this->_store_site();
5728
- } else {
5729
- if ( is_object( $this->_license ) && $this->_license->is_expired() ) {
5730
- if ( ! $this->has_features_enabled_license() ) {
5731
- $this->_deactivate_license();
5732
- $plan_change = 'downgraded';
5733
- } else {
5734
- $plan_change = 'expired';
5735
- }
5736
- }
5737
-
5738
- if ( is_numeric( $site->license_id ) && is_object( $this->_license ) ) {
5739
- $this->_sync_site_subscription( $this->_license );
5740
- }
5741
- }
5742
- }
5743
-
5744
- switch ( $plan_change ) {
5745
- case 'none':
5746
- if ( ! $background && is_admin() ) {
5747
- $this->_admin_notices->add(
5748
- sprintf(
5749
- __fs( 'plan-did-not-change-message' ) . ' ' .
5750
- sprintf(
5751
- '<a href="%s">%s</a>',
5752
- $this->contact_url(
5753
- 'bug',
5754
- sprintf( __fs( 'plan-did-not-change-email-message', 'freemius' ),
5755
- strtoupper( $this->_site->plan->name )
5756
- )
5757
- ),
5758
- __fs( 'contact-us-here' )
5759
- )
5760
- ),
5761
- __fs( 'hmm' ) . '...',
5762
- 'error'
5763
- );
5764
- }
5765
- break;
5766
- case 'upgraded':
5767
- $this->_admin_notices->add_sticky(
5768
- sprintf(
5769
- __fs( 'plan-upgraded-message' ),
5770
- '<i>' . $this->get_plugin_name() . '</i>'
5771
- ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
5772
- __fs( 'download-latest-x-version' ),
5773
- $this->_site->plan->title
5774
- ) )
5775
- ),
5776
- 'plan_upgraded',
5777
- __fs( 'yee-haw' ) . '!'
5778
- );
5779
-
5780
- $this->_admin_notices->remove_sticky( array(
5781
- 'trial_started',
5782
- 'trial_promotion',
5783
- 'trial_expired',
5784
- 'activation_complete',
5785
- ) );
5786
- break;
5787
- case 'changed':
5788
- $this->_admin_notices->add_sticky(
5789
- sprintf(
5790
- __fs( 'plan-changed-to-x-message' ),
5791
- $this->_site->plan->title
5792
- ),
5793
- 'plan_changed'
5794
- );
5795
-
5796
- $this->_admin_notices->remove_sticky( array(
5797
- 'trial_started',
5798
- 'trial_promotion',
5799
- 'trial_expired',
5800
- 'activation_complete',
5801
- ) );
5802
- break;
5803
- case 'downgraded':
5804
- $this->_admin_notices->add_sticky(
5805
- sprintf( __fs( 'license-expired-blocking-message' ) ),
5806
- 'license_expired',
5807
- __fs( 'hmm' ) . '...'
5808
- );
5809
- $this->_admin_notices->remove_sticky( 'plan_upgraded' );
5810
- break;
5811
- case 'expired':
5812
- $this->_admin_notices->add_sticky(
5813
- sprintf( __fs( 'license-expired-non-blocking-message' ), $this->_site->plan->title ),
5814
- 'license_expired',
5815
- __fs( 'hmm' ) . '...'
5816
- );
5817
- $this->_admin_notices->remove_sticky( 'plan_upgraded' );
5818
- break;
5819
- case 'trial_started':
5820
- $this->_admin_notices->add_sticky(
5821
- sprintf(
5822
- __fs( 'trial-started-message' ),
5823
- '<i>' . $this->get_plugin_name() . '</i>'
5824
- ) . ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
5825
- __fs( 'download-latest-x-version' ),
5826
- $this->_storage->trial_plan->title
5827
- ) ) ),
5828
- 'trial_started',
5829
- __fs( 'yee-haw' ) . '!'
5830
- );
5831
-
5832
- $this->_admin_notices->remove_sticky( array(
5833
- 'trial_promotion',
5834
- ) );
5835
- break;
5836
- case 'trial_expired':
5837
- $this->_admin_notices->add_sticky(
5838
- __fs( 'trial-expired-message' ),
5839
- 'trial_expired',
5840
- __fs( 'hmm' ) . '...'
5841
- );
5842
- $this->_admin_notices->remove_sticky( array(
5843
- 'trial_started',
5844
- 'trial_promotion',
5845
- 'plan_upgraded',
5846
- ) );
5847
- break;
5848
- }
5849
-
5850
- if ( 'none' !== $plan_change ) {
5851
- $this->do_action( 'after_license_change', $plan_change, $this->_site->plan );
5852
- }
5853
- }
5854
-
5855
- /**
5856
- * @author Vova Feldman (@svovaf)
5857
- * @since 1.0.5
5858
- *
5859
- * @param bool $background
5860
- */
5861
- protected function _activate_license( $background = false ) {
5862
- $this->_logger->entrance();
5863
-
5864
- $premium_license = $this->_get_available_premium_license();
5865
-
5866
- if ( ! is_object( $premium_license ) ) {
5867
- return;
5868
- }
5869
-
5870
- $api = $this->get_api_site_scope();
5871
- $license = $api->call( "/licenses/{$premium_license->id}.json", 'put' );
5872
-
5873
- if ( isset( $license->error ) ) {
5874
- if ( ! $background ) {
5875
- $this->_admin_notices->add(
5876
- __fs( 'license-activation-failed-message' ) . '<br> ' .
5877
- __fs( 'server-error-message' ) . ' ' . var_export( $license->error, true ),
5878
- __fs( 'hmm' ) . '...',
5879
- 'error'
5880
- );
5881
- }
5882
-
5883
- return;
5884
- }
5885
-
5886
- $premium_license = new FS_Plugin_License( $license );
5887
-
5888
- // Updated site plan.
5889
- $this->_site->plan->id = $premium_license->plan_id;
5890
- $this->_update_site_license( $premium_license );
5891
- $this->_enrich_site_plan( false );
5892
-
5893
- $this->_store_account();
5894
-
5895
- if ( ! $background ) {
5896
- $this->_admin_notices->add_sticky(
5897
- __fs( 'license-activated-message' ) .
5898
- ( $this->is_premium() ? '' : ' ' . $this->_get_latest_download_link( sprintf(
5899
- __fs( 'download-latest-x-version' ),
5900
- $this->_site->plan->title
5901
- ) ) ),
5902
- 'license_activated',
5903
- __fs( 'yee-haw' ) . '!'
5904
- );
5905
- }
5906
-
5907
- $this->_admin_notices->remove_sticky( array(
5908
- 'trial_promotion',
5909
- 'license_expired',
5910
- ) );
5911
- }
5912
-
5913
- /**
5914
- * @author Vova Feldman (@svovaf)
5915
- * @since 1.0.5
5916
- *
5917
- * @param bool $show_notice
5918
- */
5919
- protected function _deactivate_license( $show_notice = true ) {
5920
- $this->_logger->entrance();
5921
-
5922
- if ( ! is_object( $this->_license ) ) {
5923
- $this->_admin_notices->add(
5924
- sprintf( __fs( 'no-active-license-message' ), $this->_site->plan->title ),
5925
- __fs( 'hmm' ) . '...'
5926
- );
5927
-
5928
- return;
5929
- }
5930
-
5931
- $api = $this->get_api_site_scope();
5932
- $license = $api->call( "/licenses/{$this->_site->license_id}.json", 'delete' );
5933
-
5934
- if ( isset( $license->error ) ) {
5935
- $this->_admin_notices->add(
5936
- __fs( 'license-deactivation-failed-message' ) . '<br> ' .
5937
- __fs( 'server-error-message' ) . ' ' . var_export( $license->error, true ),
5938
- __fs( 'hmm' ) . '...',
5939
- 'error'
5940
- );
5941
-
5942
- return;
5943
- }
5944
-
5945
- // Update license cache.
5946
- for ( $i = 0, $len = count( $this->_licenses ); $i < $len; $i ++ ) {
5947
- if ( $license->id == $this->_licenses[ $i ]->id ) {
5948
- $this->_licenses[ $i ] = new FS_Plugin_License( $license );
5949
- }
5950
- }
5951
-
5952
- // Updated site plan to default.
5953
- $this->_sync_plans();
5954
- $this->_site->plan->id = $this->_plans[0]->id;
5955
- // Unlink license from site.
5956
- $this->_update_site_license( null );
5957
- $this->_enrich_site_plan( false );
5958
-
5959
- $this->_store_account();
5960
-
5961
- if ( $show_notice ) {
5962
- $this->_admin_notices->add(
5963
- sprintf( __fs( 'license-deactivation-message' ), $this->_site->plan->title ),
5964
- __fs( 'ok' )
5965
- );
5966
- }
5967
-
5968
- $this->_admin_notices->remove_sticky( array(
5969
- 'plan_upgraded',
5970
- 'license_activated',
5971
- ) );
5972
- }
5973
-
5974
- /**
5975
- * Site plan downgrade.
5976
- *
5977
- * @author Vova Feldman (@svovaf)
5978
- * @since 1.0.4
5979
- *
5980
- * @uses FS_Api
5981
- */
5982
- private function _downgrade_site() {
5983
- $this->_logger->entrance();
5984
-
5985
- $api = $this->get_api_site_scope();
5986
- $site = $api->call( 'downgrade.json', 'put' );
5987
-
5988
- $plan_downgraded = false;
5989
- $plan = false;
5990
- if ( ! isset( $site->error ) ) {
5991
- $prev_plan_id = $this->_site->plan->id;
5992
-
5993
- // Update new site plan id.
5994
- $this->_site->plan->id = $site->plan_id;
5995
-
5996
- $plan = $this->_enrich_site_plan();
5997
- $subscription = $this->_sync_site_subscription( $this->_license );
5998
-
5999
- // Plan downgraded if plan was changed or subscription was cancelled.
6000
- $plan_downgraded = ( $plan instanceof FS_Plugin_Plan && $prev_plan_id != $plan->id ) ||
6001
- ( is_object( $subscription ) && ! isset( $subscription->error ) && ! $subscription->is_active() );
6002
- } else {
6003
- // handle different error cases.
6004
-
6005
- }
6006
-
6007
- if ( $plan_downgraded ) {
6008
- // Remove previous sticky message about upgrade (if exist).
6009
- $this->_admin_notices->remove_sticky( 'plan_upgraded' );
6010
-
6011
- $this->_admin_notices->add(
6012
- sprintf( __fs( 'plan-x-downgraded-message' ),
6013
- $plan->title,
6014
- human_time_diff( time(), strtotime( $this->_license->expiration ) )
6015
- )
6016
- );
6017
-
6018
- // Store site updates.
6019
- $this->_store_site();
6020
- } else {
6021
- $this->_admin_notices->add(
6022
- __fs( 'plan-downgraded-failure-message' ),
6023
- __fs( 'oops' ) . '...',
6024
- 'error'
6025
- );
6026
- }
6027
- }
6028
-
6029
- /**
6030
- * Cancel site trial.
6031
- *
6032
- * @author Vova Feldman (@svovaf)
6033
- * @since 1.0.9
6034
- *
6035
- * @uses FS_Api
6036
- */
6037
- private function _cancel_trial() {
6038
- $this->_logger->entrance();
6039
-
6040
- if ( ! $this->is_trial() ) {
6041
- $this->_admin_notices->add(
6042
- __fs( 'trial-cancel-no-trial-message' ),
6043
- __fs( 'oops' ) . '...',
6044
- 'error'
6045
- );
6046
-
6047
- return;
6048
- }
6049
-
6050
- $api = $this->get_api_site_scope();
6051
- $site = $api->call( 'trials.json', 'delete' );
6052
-
6053
- $trial_cancelled = false;
6054
-
6055
- if ( ! isset( $site->error ) ) {
6056
- $prev_trial_ends = $this->_site->trial_ends;
6057
-
6058
- // Update new site plan id.
6059
- $this->_site->trial_ends = $site->trial_ends;
6060
-
6061
- $trial_cancelled = ( $prev_trial_ends != $site->trial_ends );
6062
- } else {
6063
- // handle different error cases.
6064
-
6065
- }
6066
-
6067
- if ( $trial_cancelled ) {
6068
- // Remove previous sticky message about upgrade (if exist).
6069
- $this->_admin_notices->remove_sticky( 'plan_upgraded' );
6070
-
6071
- $this->_admin_notices->add(
6072
- sprintf( __fs( 'trial-cancel-message' ), $this->_storage->trial_plan->title )
6073
- );
6074
-
6075
- $this->_admin_notices->remove_sticky( array(
6076
- 'trial_started',
6077
- 'trial_promotion',
6078
- 'plan_upgraded',
6079
- ) );
6080
-
6081
- // Store site updates.
6082
- $this->_store_site();
6083
-
6084
- // Clear trial plan information.
6085
- unset( $this->_storage->trial_plan );
6086
- } else {
6087
- $this->_admin_notices->add(
6088
- __fs( 'trial-cancel-failure-message' ),
6089
- __fs( 'oops' ) . '...',
6090
- 'error'
6091
- );
6092
- }
6093
- }
6094
-
6095
- /**
6096
- * @author Vova Feldman (@svovaf)
6097
- * @since 1.0.6
6098
- *
6099
- * @param bool|number $plugin_id
6100
- *
6101
- * @return bool
6102
- */
6103
- private function _is_addon_id( $plugin_id ) {
6104
- return is_numeric( $plugin_id ) && ( $this->get_id() != $plugin_id );
6105
- }
6106
-
6107
- /**
6108
- * Check if user eligible to download premium version updates.
6109
- *
6110
- * @author Vova Feldman (@svovaf)
6111
- * @since 1.0.6
6112
- *
6113
- * @return bool
6114
- */
6115
- private function _can_download_premium() {
6116
- return $this->has_active_license() ||
6117
- ( $this->is_trial() && ! $this->get_trial_plan()->is_free() );
6118
- }
6119
-
6120
- /**
6121
- *
6122
- * @author Vova Feldman (@svovaf)
6123
- * @since 1.0.6
6124
- *
6125
- * @param bool|number $addon_id
6126
- * @param string $type "json" or "zip"
6127
- *
6128
- * @return string
6129
- */
6130
- private function _get_latest_version_endpoint( $addon_id = false, $type = 'json' ) {
6131
-
6132
- $is_addon = $this->_is_addon_id( $addon_id );
6133
-
6134
- $is_premium = null;
6135
- if ( ! $is_addon ) {
6136
- $is_premium = $this->_can_download_premium();
6137
- } else if ( $this->is_addon_activated( $addon_id ) ) {
6138
- $is_premium = self::get_instance_by_id( $addon_id )->_can_download_premium();
6139
- }
6140
-
6141
- return // If add-on, then append add-on ID.
6142
- ( $is_addon ? "/addons/$addon_id" : '' ) .
6143
- '/updates/latest.' . $type .
6144
- // If add-on and not yet activated, try to fetch based on server licensing.
6145
- ( is_bool( $is_premium ) ? '?is_premium=' . json_encode( $is_premium ) : '' );
6146
- }
6147
-
6148
- /**
6149
- * @author Vova Feldman (@svovaf)
6150
- * @since 1.0.4
6151
- *
6152
- * @param bool|number $addon_id
6153
- *
6154
- * @return object|false Plugin latest tag info.
6155
- */
6156
- function _fetch_latest_version( $addon_id = false ) {
6157
- $tag = $this->get_api_site_or_plugin_scope()->get(
6158
- $this->_get_latest_version_endpoint( $addon_id, 'json' ),
6159
- true
6160
- );
6161
- $latest_version = ( is_object( $tag ) && isset( $tag->version ) ) ? $tag->version : 'couldn\'t get';
6162
- $this->_logger->departure( 'Latest version ' . $latest_version );
6163
-
6164
- return ( is_object( $tag ) && isset( $tag->version ) ) ? $tag : false;
6165
- }
6166
-
6167
- #region Download Plugin ------------------------------------------------------------------
6168
-
6169
- /**
6170
- * Download latest plugin version, based on plan.
6171
- * The download will be fetched via the API first.
6172
- *
6173
- * @author Vova Feldman (@svovaf)
6174
- * @since 1.0.4
6175
- *
6176
- * @param bool|number $plugin_id
6177
- *
6178
- * @uses FS_Api
6179
- *
6180
- * @deprecated
6181
- */
6182
- private function _download_latest( $plugin_id = false ) {
6183
- $this->_logger->entrance();
6184
-
6185
- $is_addon = $this->_is_addon_id( $plugin_id );
6186
-
6187
- $is_premium = $this->_can_download_premium();
6188
-
6189
- $latest = $this->get_api_site_scope()->call(
6190
- $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
6191
- );
6192
-
6193
- $slug = $this->_slug;
6194
- if ( $is_addon ) {
6195
- $addon = $this->get_addon( $plugin_id );
6196
- $slug = is_object( $addon ) ? $addon->slug : 'addon';
6197
- }
6198
-
6199
- if ( ! is_object( $latest ) ) {
6200
- header( "Content-Type: application/zip" );
6201
- header( "Content-Disposition: attachment; filename={$slug}" . ( ! $is_addon && $is_premium ? '-premium' : '' ) . ".zip" );
6202
- header( "Content-Length: " . strlen( $latest ) );
6203
- echo $latest;
6204
-
6205
- exit();
6206
- }
6207
- }
6208
-
6209
- /**
6210
- * Download latest plugin version, based on plan.
6211
- *
6212
- * Not like _download_latest(), this will redirect the page
6213
- * to secure download url to prevent dual download (from FS to WP server,
6214
- * and then from WP server to the client / browser).
6215
- *
6216
- * @author Vova Feldman (@svovaf)
6217
- * @since 1.0.9
6218
- *
6219
- * @param bool|number $plugin_id
6220
- *
6221
- * @uses FS_Api
6222
- * @uses wp_redirect()
6223
- */
6224
- private function _download_latest_directly( $plugin_id = false ) {
6225
- $this->_logger->entrance();
6226
-
6227
- wp_redirect( $this->_get_latest_download_api_url( $plugin_id ) );
6228
- }
6229
-
6230
- /**
6231
- * Get latest plugin FS API download URL.
6232
- *
6233
- * @author Vova Feldman (@svovaf)
6234
- * @since 1.0.9
6235
- *
6236
- * @param bool|number $plugin_id
6237
- *
6238
- * @return string
6239
- */
6240
- private function _get_latest_download_api_url( $plugin_id = false ) {
6241
- $this->_logger->entrance();
6242
-
6243
- return $this->get_api_site_scope()->get_signed_url(
6244
- $this->_get_latest_version_endpoint( $plugin_id, 'zip' )
6245
- );
6246
- }
6247
-
6248
- /**
6249
- * Get latest plugin download link.
6250
- *
6251
- * @author Vova Feldman (@svovaf)
6252
- * @since 1.0.9
6253
- *
6254
- * @param string $label
6255
- * @param bool|number $plugin_id
6256
- *
6257
- * @return string
6258
- */
6259
- private function _get_latest_download_link( $label, $plugin_id = false ) {
6260
- return sprintf(
6261
- '<a target="_blank" href="%s">%s</a>',
6262
- $this->_get_latest_download_local_url( $plugin_id ),
6263
- $label
6264
- );
6265
- }
6266
-
6267
- /**
6268
- * Get latest plugin download local URL.
6269
- *
6270
- * @author Vova Feldman (@svovaf)
6271
- * @since 1.0.9
6272
- *
6273
- * @param bool|number $plugin_id
6274
- *
6275
- * @return string
6276
- */
6277
- function _get_latest_download_local_url( $plugin_id = false ) {
6278
- // Add timestamp to protect from caching.
6279
- $params = array( 'ts' => WP_FS__SCRIPT_START_TIME );
6280
-
6281
- if ( ! empty( $plugin_id ) ) {
6282
- $params['plugin_id'] = $plugin_id;
6283
- }
6284
-
6285
- return $this->get_account_url( 'download_latest', $params );
6286
- }
6287
-
6288
- #endregion Download Plugin ------------------------------------------------------------------
6289
-
6290
- /**
6291
- * @author Vova Feldman (@svovaf)
6292
- * @since 1.0.4
6293
- *
6294
- * @uses FS_Api
6295
- *
6296
- * @param bool $background Hints the method if it's a background updates check. If false, it means that
6297
- * was initiated by the admin.
6298
- * @param bool|number $plugin_id
6299
- */
6300
- private function _check_updates( $background = false, $plugin_id = false ) {
6301
- $this->_logger->entrance();
6302
-
6303
- // Check if there's a newer version for download.
6304
- $new_version = $this->_fetch_newer_version( $plugin_id );
6305
-
6306
- $update = null;
6307
- if ( is_object( $new_version ) ) {
6308
- $update = new FS_Plugin_Tag( $new_version );
6309
-
6310
- if ( ! $background ) {
6311
- $this->_admin_notices->add(
6312
- sprintf(
6313
- __fs( 'version-x-released' ) . ' ' . __fS( 'please-download-x' ),
6314
- $update->version,
6315
- sprintf(
6316
- '<a href="%s" target="_blank">%s</a>',
6317
- $this->get_account_url( 'download_latest' ),
6318
- sprintf( __fs( 'latest-x-version' ), $this->_site->plan->title )
6319
- )
6320
- ),
6321
- __fs( 'new' ) . '!'
6322
- );
6323
- }
6324
- } else if ( false === $new_version && ! $background ) {
6325
- $this->_admin_notices->add(
6326
- __fs( 'you-have-latest' ),
6327
- __fs( 'you-are-good' )
6328
- );
6329
- }
6330
-
6331
- $this->_store_update( $update, true, $plugin_id );
6332
- }
6333
-
6334
- /**
6335
- * @author Vova Feldman (@svovaf)
6336
- * @since 1.0.4
6337
- *
6338
- * @uses FS_Api
6339
- *
6340
- */
6341
- private function _sync_addons() {
6342
- $this->_logger->entrance();
6343
-
6344
- $result = $this->get_api_site_or_plugin_scope()->get( '/addons.json?enriched=true', true );
6345
-
6346
- if ( isset( $result->error ) ) {
6347
- return;
6348
- }
6349
-
6350
- $addons = array();
6351
- for ( $i = 0, $len = count( $result->plugins ); $i < $len; $i ++ ) {
6352
- $addons[ $i ] = new FS_Plugin( $result->plugins[ $i ] );
6353
- }
6354
-
6355
- $this->_store_addons( $addons, true );
6356
- }
6357
-
6358
- /**
6359
- * Handle user email update.
6360
- *
6361
- * @author Vova Feldman (@svovaf)
6362
- * @since 1.0.3
6363
- * @uses FS_Api
6364
- *
6365
- * @param string $new_email
6366
- *
6367
- * @return object
6368
- */
6369
- private function _update_email( $new_email ) {
6370
- $this->_logger->entrance();
6371
-
6372
-
6373
- $api = $this->get_api_user_scope();
6374
- $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,email,is_verified", 'put', array(
6375
- 'email' => $new_email,
6376
- 'after_email_confirm_url' => $this->_get_admin_page_url(
6377
- 'account',
6378
- array( 'fs_action' => 'sync_user' )
6379
- ),
6380
- ) );
6381
-
6382
- if ( ! isset( $user->error ) ) {
6383
- $this->_user->email = $user->email;
6384
- $this->_user->is_verified = $user->is_verified;
6385
- $this->_store_user();
6386
- } else {
6387
- // handle different error cases.
6388
-
6389
- }
6390
-
6391
- return $user;
6392
- }
6393
-
6394
- /**
6395
- * @author Vova Feldman (@svovaf)
6396
- * @since 1.1.1
6397
- *
6398
- * @param mixed $result
6399
- *
6400
- * @return bool Is API result contains an error.
6401
- */
6402
- private function is_api_error( $result ) {
6403
- return ( is_object( $result ) && isset( $result->error ) ) ||
6404
- is_string( $result );
6405
- }
6406
-
6407
- /**
6408
- * Start install ownership change.
6409
- *
6410
- * @author Vova Feldman (@svovaf)
6411
- * @since 1.1.1
6412
- * @uses FS_Api
6413
- *
6414
- * @param string $candidate_email
6415
- *
6416
- * @return bool Is ownership change successfully initiated.
6417
- */
6418
- private function init_change_owner( $candidate_email ) {
6419
- $this->_logger->entrance();
6420
-
6421
- $api = $this->get_api_site_scope();
6422
- $result = $api->call( "/users/{$this->_user->id}.json", 'put', array(
6423
- 'email' => $candidate_email,
6424
- 'after_confirm_url' => $this->_get_admin_page_url(
6425
- 'account',
6426
- array( 'fs_action' => 'change_owner' )
6427
- ),
6428
- ) );
6429
-
6430
- return ! $this->is_api_error( $result );
6431
- }
6432
-
6433
- /**
6434
- * Handle install ownership change.
6435
- *
6436
- * @author Vova Feldman (@svovaf)
6437
- * @since 1.1.1
6438
- * @uses FS_Api
6439
- *
6440
- * @return bool Was ownership change successfully complete.
6441
- */
6442
- private function complete_change_owner() {
6443
- $this->_logger->entrance();
6444
-
6445
- $site_result = $this->get_api_site_scope( true )->get();
6446
- $site = new FS_Site( $site_result );
6447
- $this->_site = $site;
6448
-
6449
- $user = new FS_User();
6450
- $user->id = fs_request_get( 'user_id' );
6451
-
6452
- // Validate install's user and given user.
6453
- if ( $user->id != $this->_site->user_id ) {
6454
- return false;
6455
- }
6456
-
6457
- $user->public_key = fs_request_get( 'user_public_key' );
6458
- $user->secret_key = fs_request_get( 'user_secret_key' );
6459
-
6460
- // Fetch new user information.
6461
- $this->_user = $user;
6462
- $user_result = $this->get_api_user_scope( true )->get();
6463
- $user = new FS_User( $user_result );
6464
- $this->_user = $user;
6465
-
6466
- $this->_set_account( $user, $site );
6467
-
6468
- return true;
6469
- }
6470
-
6471
- /**
6472
- * Handle user name update.
6473
- *
6474
- * @author Vova Feldman (@svovaf)
6475
- * @since 1.0.9
6476
- * @uses FS_Api
6477
- *
6478
- * @return object
6479
- */
6480
- private function update_user_name() {
6481
- $this->_logger->entrance();
6482
- $name = fs_request_get( 'fs_user_name_' . $this->_slug, '' );
6483
-
6484
- $api = $this->get_api_user_scope();
6485
- $user = $api->call( "?plugin_id={$this->_plugin->id}&fields=id,first,last", 'put', array(
6486
- 'name' => $name,
6487
- ) );
6488
-
6489
- if ( ! isset( $user->error ) ) {
6490
- $this->_user->first = $user->first;
6491
- $this->_user->last = $user->last;
6492
- $this->_store_user();
6493
- } else {
6494
- // handle different error cases.
6495
-
6496
- }
6497
-
6498
- return $user;
6499
- }
6500
-
6501
- /**
6502
- * Verify user email.
6503
- *
6504
- * @author Vova Feldman (@svovaf)
6505
- * @since 1.0.3
6506
- * @uses FS_Api
6507
- */
6508
- private function verify_email() {
6509
- $this->_handle_account_user_sync();
6510
-
6511
- if ( $this->_user->is_verified() ) {
6512
- return;
6513
- }
6514
-
6515
- $api = $this->get_api_site_scope();
6516
- $result = $api->call( "/users/{$this->_user->id}/verify.json", 'put', array(
6517
- 'after_email_confirm_url' => $this->_get_admin_page_url(
6518
- 'account',
6519
- array( 'fs_action' => 'sync_user' )
6520
- )
6521
- ) );
6522
-
6523
- if ( ! isset( $result->error ) ) {
6524
- $this->_admin_notices->add( sprintf(
6525
- __fs( 'verification-email-sent-message' ),
6526
- sprintf( '<a href="mailto:%1s">%2s</a>', esc_url( $this->_user->email ), $this->_user->email )
6527
- ) );
6528
- } else {
6529
- // handle different error cases.
6530
-
6531
- }
6532
- }
6533
-
6534
- /**
6535
- * @author Vova Feldman (@svovaf)
6536
- * @since 1.1.2
6537
- *
6538
- * @return string
6539
- */
6540
- private function get_activation_url() {
6541
- return $this->apply_filters( 'connect_url', $this->_get_admin_page_url() );
6542
- }
6543
-
6544
- /**
6545
- * @author Vova Feldman (@svovaf)
6546
- * @since 1.1.3
6547
- *
6548
- * @param string $filter Filter name.
6549
- *
6550
- * @return string
6551
- */
6552
- private function get_after_activation_url( $filter ) {
6553
- $first_time_path = $this->_menu->get_first_time_path();
6554
-
6555
- return $this->apply_filters(
6556
- $filter,
6557
- empty( $first_time_path ) ?
6558
- $this->_get_admin_page_url() :
6559
- $first_time_path
6560
- );
6561
- }
6562
-
6563
- /**
6564
- * Handle account page updates / edits / actions.
6565
- *
6566
- * @author Vova Feldman (@svovaf)
6567
- * @since 1.0.2
6568
- *
6569
- */
6570
- private function _handle_account_edits() {
6571
- if ( ! current_user_can( 'activate_plugins' ) ) {
6572
- return;
6573
- }
6574
-
6575
- $plugin_id = fs_request_get( 'plugin_id', $this->get_id() );
6576
- $action = fs_get_action();
6577
-
6578
- switch ( $action ) {
6579
- case 'delete_account':
6580
- check_admin_referer( $action );
6581
-
6582
- if ( $plugin_id == $this->get_id() ) {
6583
- $this->delete_account_event();
6584
-
6585
- // Clear user and site.
6586
- $this->_site = null;
6587
- $this->_user = null;
6588
-
6589
- if ( fs_redirect( $this->get_activation_url() ) ) {
6590
- exit();
6591
- }
6592
- } else {
6593
- if ( $this->is_addon_activated( $plugin_id ) ) {
6594
- $fs_addon = self::get_instance_by_id( $plugin_id );
6595
- $fs_addon->delete_account_event();
6596
-
6597
- if ( fs_redirect( $this->_get_admin_page_url( 'account' ) ) ) {
6598
- exit();
6599
- }
6600
- }
6601
- }
6602
-
6603
- return;
6604
-
6605
- case 'downgrade_account':
6606
- check_admin_referer( $action );
6607
- $this->_downgrade_site();
6608
-
6609
- return;
6610
-
6611
- case 'activate_license':
6612
- check_admin_referer( $action );
6613
-
6614
- if ( $plugin_id == $this->get_id() ) {
6615
- $this->_activate_license();
6616
- } else {
6617
- if ( $this->is_addon_activated( $plugin_id ) ) {
6618
- $fs_addon = self::get_instance_by_id( $plugin_id );
6619
- $fs_addon->_activate_license();
6620
- }
6621
- }
6622
-
6623
- return;
6624
-
6625
- case 'deactivate_license':
6626
- check_admin_referer( $action );
6627
-
6628
- if ( $plugin_id == $this->get_id() ) {
6629
- $this->_deactivate_license();
6630
- } else {
6631
- if ( $this->is_addon_activated( $plugin_id ) ) {
6632
- $fs_addon = self::get_instance_by_id( $plugin_id );
6633
- $fs_addon->_deactivate_license();
6634
- }
6635
- }
6636
-
6637
- return;
6638
-
6639
- case 'check_updates':
6640
- check_admin_referer( $action );
6641
- $this->_check_updates();
6642
-
6643
- return;
6644
-
6645
- case 'change_owner':
6646
- $state = fs_request_get( 'state', 'init' );
6647
- switch ( $state ) {
6648
- case 'init':
6649
- $candidate_email = fs_request_get( 'candidate_email', '' );
6650
-
6651
- if ( $this->init_change_owner( $candidate_email ) ) {
6652
- $this->_admin_notices->add( sprintf( __fs( 'change-owner-request-sent-x' ), '<b>' . $this->_user->email . '</b>' ) );
6653
- }
6654
- break;
6655
- case 'owner_confirmed':
6656
- $candidate_email = fs_request_get( 'candidate_email', '' );
6657
-
6658
- $this->_admin_notices->add( sprintf( __fs( 'change-owner-request_owner-confirmed' ), '<b>' . $candidate_email . '</b>' ) );
6659
- break;
6660
- case 'candidate_confirmed':
6661
- if ( $this->complete_change_owner() ) {
6662
- $this->_admin_notices->add_sticky(
6663
- sprintf( __fs( 'change-owner-request_candidate-confirmed' ), '<b>' . $this->_user->email . '</b>' ),
6664
- 'ownership_changed',
6665
- __fs( 'congrats' ) . '!'
6666
- );
6667
- } else {
6668
- // @todo Handle failed ownership change message.
6669
- }
6670
- break;
6671
- }
6672
-
6673
- return;
6674
-
6675
- case 'update_email':
6676
- check_admin_referer( 'update_email' );
6677
-
6678
- $new_email = fs_request_get( 'fs_email_' . $this->_slug, '' );
6679
- $result = $this->_update_email( $new_email );
6680
-
6681
- if ( isset( $result->error ) ) {
6682
- switch ( $result->error->code ) {
6683
- case 'user_exist':
6684
- $this->_admin_notices->add(
6685
- __fs( 'user-exist-message' ) . ' ' .
6686
- sprintf( __fs( 'user-exist-message_ownership' ), '<b>' . $new_email . '</b>' ) .
6687
- sprintf(
6688
- '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
6689
- $this->get_account_url( 'change_owner', array(
6690
- 'state' => 'init',
6691
- 'candidate_email' => $new_email
6692
- ) ),
6693
- __fs( 'change-ownership' )
6694
- ),
6695
- __fs( 'oops' ) . '...',
6696
- 'error'
6697
- );
6698
- break;
6699
- }
6700
- } else {
6701
- $this->_admin_notices->add( __fs( 'email-updated-message' ) );
6702
- }
6703
-
6704
- return;
6705
-
6706
- case 'update_user_name':
6707
- check_admin_referer( 'update_user_name' );
6708
-
6709
- $result = $this->update_user_name();
6710
-
6711
- if ( isset( $result->error ) ) {
6712
- $this->_admin_notices->add(
6713
- __fs( 'name-update-failed-message' ),
6714
- __fs( 'oops' ) . '...',
6715
- 'error'
6716
- );
6717
- } else {
6718
- $this->_admin_notices->add( __fs( 'name-updated-message' ) );
6719
- }
6720
-
6721
- return;
6722
-
6723
- #region Actions that might be called from external links (e.g. email)
6724
-
6725
- case 'cancel_trial':
6726
- $this->_cancel_trial();
6727
-
6728
- return;
6729
-
6730
- case 'verify_email':
6731
- $this->verify_email();
6732
-
6733
- return;
6734
-
6735
- case 'sync_user':
6736
- $this->_handle_account_user_sync();
6737
-
6738
- return;
6739
-
6740
- case $this->_slug . '_sync_license':
6741
- $this->_sync_license();
6742
-
6743
- return;
6744
-
6745
- case 'download_latest':
6746
- $this->_download_latest_directly( $plugin_id );
6747
-
6748
- return;
6749
-
6750
- #endregion
6751
- }
6752
-
6753
- if ( WP_FS__IS_POST_REQUEST ) {
6754
- $properties = array( 'site_secret_key', 'site_id', 'site_public_key' );
6755
- foreach ( $properties as $p ) {
6756
- if ( 'update_' . $p === $action ) {
6757
- check_admin_referer( $action );
6758
-
6759
- $this->_logger->log( $action );
6760
-
6761
- $site_property = substr( $p, strlen( 'site_' ) );
6762
- $site_property_value = fs_request_get( 'fs_' . $p . '_' . $this->_slug, '' );
6763
- $this->get_site()->{$site_property} = $site_property_value;
6764
-
6765
- // Store account after modification.
6766
- $this->_store_site();
6767
-
6768
- $this->do_action( 'account_property_edit', 'site', $site_property, $site_property_value );
6769
-
6770
- $this->_admin_notices->add( sprintf(
6771
- __fs( 'x-updated' ),
6772
- '<b>' . str_replace( '_', ' ', $p ) . '</b>' ) );
6773
-
6774
- return;
6775
- }
6776
- }
6777
- }
6778
- }
6779
-
6780
- /**
6781
- * Account page resources load.
6782
- *
6783
- * @author Vova Feldman (@svovaf)
6784
- * @since 1.0.6
6785
- */
6786
- function _account_page_load() {
6787
- $this->_logger->entrance();
6788
-
6789
- $this->_logger->info( var_export( $_REQUEST, true ) );
6790
-
6791
- fs_enqueue_local_style( 'fs_account', '/admin/account.css' );
6792
-
6793
- if ( $this->_has_addons() ) {
6794
- wp_enqueue_script( 'plugin-install' );
6795
- add_thickbox();
6796
-
6797
- function fs_addons_body_class( $classes ) {
6798
- $classes .= ' plugins-php';
6799
-
6800
- return $classes;
6801
- }
6802
-
6803
- add_filter( 'admin_body_class', 'fs_addons_body_class' );
6804
- }
6805
-
6806
- $this->_handle_account_edits();
6807
-
6808
- $this->do_action( 'account_page_load_before_departure' );
6809
- }
6810
-
6811
- /**
6812
- * Render account page.
6813
- *
6814
- * @author Vova Feldman (@svovaf)
6815
- * @since 1.0.0
6816
- */
6817
- function _account_page_render() {
6818
- $this->_logger->entrance();
6819
-
6820
- $vars = array( 'slug' => $this->_slug );
6821
- fs_require_once_template( 'account.php', $vars );
6822
- }
6823
-
6824
- /**
6825
- * Render account connect page.
6826
- *
6827
- * @author Vova Feldman (@svovaf)
6828
- * @since 1.0.7
6829
- */
6830
- function _connect_page_render() {
6831
- $this->_logger->entrance();
6832
-
6833
- $vars = array( 'slug' => $this->_slug );
6834
- if ( $this->is_pending_activation() ) {
6835
- fs_require_once_template( 'pending-activation.php', $vars );
6836
- } else {
6837
- fs_require_once_template( 'connect.php', $vars );
6838
- }
6839
- }
6840
-
6841
- /**
6842
- * Load required resources before add-ons page render.
6843
- *
6844
- * @author Vova Feldman (@svovaf)
6845
- * @since 1.0.6
6846
- */
6847
- function _addons_page_load() {
6848
- $this->_logger->entrance();
6849
-
6850
- fs_enqueue_local_style( 'fs_addons', '/admin/add-ons.css' );
6851
-
6852
- wp_enqueue_script( 'plugin-install' );
6853
- add_thickbox();
6854
-
6855
- function fs_addons_body_class( $classes ) {
6856
- $classes .= ' plugins-php';
6857
-
6858
- return $classes;
6859
- }
6860
-
6861
- add_filter( 'admin_body_class', 'fs_addons_body_class' );
6862
-
6863
- if ( ! $this->is_registered() && $this->is_org_repo_compliant() ) {
6864
- $this->_admin_notices->add(
6865
- sprintf( __fs( 'addons-info-external-message' ), '<b>' . $this->get_plugin_name() . '</b>' ),
6866
- __fs( 'heads-up' ),
6867
- 'update-nag'
6868
- );
6869
- }
6870
- }
6871
-
6872
- /**
6873
- * Render add-ons page.
6874
- *
6875
- * @author Vova Feldman (@svovaf)
6876
- * @since 1.0.6
6877
- */
6878
- function _addons_page_render() {
6879
- $this->_logger->entrance();
6880
-
6881
- $vars = array( 'slug' => $this->_slug );
6882
- fs_require_once_template( 'add-ons.php', $vars );
6883
- }
6884
-
6885
- /* Pricing & Upgrade
6886
- ------------------------------------------------------------------------------------------------------------------*/
6887
- /**
6888
- * Render pricing page.
6889
- *
6890
- * @author Vova Feldman (@svovaf)
6891
- * @since 1.0.0
6892
- */
6893
- function _pricing_page_render() {
6894
- $this->_logger->entrance();
6895
-
6896
- $vars = array( 'slug' => $this->_slug );
6897
-
6898
- if ( 'true' === fs_request_get( 'checkout', false ) ) {
6899
- fs_require_once_template( 'checkout.php', $vars );
6900
- } else {
6901
- fs_require_once_template( 'pricing.php', $vars );
6902
- }
6903
- }
6904
-
6905
- #region Contact Us ------------------------------------------------------------------
6906
-
6907
- /**
6908
- * Render contact-us page.
6909
- *
6910
- * @author Vova Feldman (@svovaf)
6911
- * @since 1.0.3
6912
- */
6913
- function _contact_page_render() {
6914
- $this->_logger->entrance();
6915
-
6916
- $vars = array( 'slug' => $this->_slug );
6917
- fs_require_once_template( 'contact.php', $vars );
6918
- }
6919
-
6920
- #endregion ------------------------------------------------------------------
6921
-
6922
- /**
6923
- * Hide all admin notices to prevent distractions.
6924
- *
6925
- * @author Vova Feldman (@svovaf)
6926
- * @since 1.0.3
6927
- *
6928
- * @uses remove_all_actions()
6929
- */
6930
- function _hide_admin_notices() {
6931
- remove_all_actions( 'admin_notices' );
6932
- remove_all_actions( 'network_admin_notices' );
6933
- remove_all_actions( 'all_admin_notices' );
6934
- remove_all_actions( 'user_admin_notices' );
6935
- }
6936
-
6937
- function _clean_admin_content_section_hook() {
6938
- $this->_hide_admin_notices();
6939
-
6940
- // Hide footer.
6941
- echo '<style>#wpfooter { display: none !important; }</style>';
6942
- }
6943
-
6944
- /**
6945
- * Attach to admin_head hook to hide all admin notices.
6946
- *
6947
- * @author Vova Feldman (@svovaf)
6948
- * @since 1.0.3
6949
- */
6950
- function _clean_admin_content_section() {
6951
- add_action( 'admin_head', array( &$this, '_clean_admin_content_section_hook' ) );
6952
- }
6953
-
6954
- /* CSS & JavaScript
6955
- ------------------------------------------------------------------------------------------------------------------*/
6956
- /* function _enqueue_script($handle, $src) {
6957
- $url = plugins_url( substr( WP_FS__DIR_JS, strlen( $this->_plugin_dir_path ) ) . '/assets/js/' . $src );
6958
-
6959
- $this->_logger->entrance( 'script = ' . $url );
6960
-
6961
- wp_enqueue_script( $handle, $url );
6962
- }*/
6963
-
6964
- /* SDK
6965
- ------------------------------------------------------------------------------------------------------------------*/
6966
- private $_user_api;
6967
-
6968
- /**
6969
- *
6970
- * @author Vova Feldman (@svovaf)
6971
- * @since 1.0.2
6972
- *
6973
- * @param bool $flush
6974
- *
6975
- * @return FS_Api
6976
- */
6977
- function get_api_user_scope( $flush = false ) {
6978
- if ( ! isset( $this->_user_api ) || $flush ) {
6979
- $this->_user_api = FS_Api::instance(
6980
- $this->_slug,
6981
- 'user',
6982
- $this->_user->id,
6983
- $this->_user->public_key,
6984
- ! $this->is_live(),
6985
- $this->_user->secret_key
6986
- );
6987
- }
6988
-
6989
- return $this->_user_api;
6990
- }
6991
-
6992
- private $_site_api;
6993
-
6994
- /**
6995
- *
6996
- * @author Vova Feldman (@svovaf)
6997
- * @since 1.0.2
6998
- *
6999
- * @param bool $flush
7000
- *
7001
- * @return FS_Api
7002
- */
7003
- function get_api_site_scope( $flush = false ) {
7004
- if ( ! isset( $this->_site_api ) || $flush ) {
7005
- $this->_site_api = FS_Api::instance(
7006
- $this->_slug,
7007
- 'install',
7008
- $this->_site->id,
7009
- $this->_site->public_key,
7010
- ! $this->is_live(),
7011
- $this->_site->secret_key
7012
- );
7013
- }
7014
-
7015
- return $this->_site_api;
7016
- }
7017
-
7018
- private $_plugin_api;
7019
-
7020
- /**
7021
- * Get plugin public API scope.
7022
- *
7023
- * @author Vova Feldman (@svovaf)
7024
- * @since 1.0.7
7025
- *
7026
- * @return FS_Api
7027
- */
7028
- function get_api_plugin_scope() {
7029
- if ( ! isset( $this->_plugin_api ) ) {
7030
- $this->_plugin_api = FS_Api::instance(
7031
- $this->_slug,
7032
- 'plugin',
7033
- $this->_plugin->id,
7034
- $this->_plugin->public_key,
7035
- ! $this->is_live()
7036
- );
7037
- }
7038
-
7039
- return $this->_plugin_api;
7040
- }
7041
-
7042
- /**
7043
- * Get site API scope object (fallback to public plugin scope when not registered).
7044
- *
7045
- * @author Vova Feldman (@svovaf)
7046
- * @since 1.0.7
7047
- *
7048
- * @return FS_Api
7049
- */
7050
- function get_api_site_or_plugin_scope() {
7051
- return $this->is_registered() ?
7052
- $this->get_api_site_scope() :
7053
- $this->get_api_plugin_scope();
7054
- }
7055
-
7056
- /**
7057
- * Show trial promotional notice (if any trial exist).
7058
- *
7059
- * @author Vova Feldman (@svovaf)
7060
- * @since 1.0.9
7061
- *
7062
- * @param $plans
7063
- */
7064
- function _check_for_trial_plans( $plans ) {
7065
- $this->_storage->has_trial_plan = FS_Plan_Manager::instance()->has_trial_plan( $plans );
7066
- }
7067
-
7068
- /**
7069
- * Show trial promotional notice (if any trial exist).
7070
- *
7071
- * @author Vova Feldman (@svovaf)
7072
- * @since 1.0.9
7073
- */
7074
- function _add_trial_notice() {
7075
- // Check if trial already utilized.
7076
- if ( $this->_site->is_trial_utilized() ) {
7077
- return;
7078
- }
7079
-
7080
- // Check if already paying.
7081
- if ( $this->is_paying() ) {
7082
- return;
7083
- }
7084
-
7085
- // Check if trial message is already shown.
7086
- if ( $this->_admin_notices->has_sticky( 'trial_promotion' ) ) {
7087
- return;
7088
- }
7089
-
7090
- $trial_plans = FS_Plan_Manager::instance()->get_trial_plans( $this->_plans );
7091
- $trial_plans_count = count( $trial_plans );
7092
-
7093
- // Check if any of the plans contains trial.
7094
- if ( 0 === $trial_plans_count ) {
7095
- return;
7096
- }
7097
-
7098
- /**
7099
- * @var FS_Plugin_Plan $paid_plan
7100
- */
7101
- $paid_plan = $trial_plans[0];
7102
- $require_subscription = $paid_plan->is_require_subscription;
7103
- $upgrade_url = $this->get_trial_url();
7104
- $cc_string = $require_subscription ?
7105
- sprintf( __fs( 'no-commitment-for-x-days' ), $paid_plan->trial_period ) :
7106
- __fs( 'no-cc-required' ) . '!';
7107
-
7108
-
7109
- $total_paid_plans = count( $this->_plans ) - ( FS_Plan_Manager::instance()->has_free_plan( $this->_plans ) ? 1 : 0 );
7110
-
7111
- if ( $total_paid_plans === $trial_plans_count ) {
7112
- // All paid plans have trials.
7113
- $message = sprintf(
7114
- __fs( 'hey' ) . '! ' . __fs( 'trial-x-promotion-message' ),
7115
- sprintf( '<b>%s</b>', $this->get_plugin_name() ),
7116
- strtolower( __fs( 'awesome' ) ),
7117
- $paid_plan->trial_period
7118
- );
7119
- } else {
7120
- $plans_string = '';
7121
- for ( $i = 0; $i < $trial_plans_count; $i ++ ) {
7122
- $plans_string .= sprintf( '<a href="%s">%s</a>', $upgrade_url, $trial_plans[ $i ]->title );
7123
-
7124
- if ( $i < $trial_plans_count - 2 ) {
7125
- $plans_string .= ', ';
7126
- } else if ( $i == $trial_plans_count - 2 ) {
7127
- $plans_string .= ' and ';
7128
- }
7129
- }
7130
-
7131
- // Not all paid plans have trials.
7132
- $message = sprintf(
7133
- __fs( 'hey' ) . '! ' . __fs( 'trial-x-promotion-message' ),
7134
- sprintf( '<b>%s</b>', $this->get_plugin_name() ),
7135
- $plans_string,
7136
- $paid_plan->trial_period
7137
- );
7138
- }
7139
-
7140
- $message .= ' ' . $cc_string;
7141
-
7142
- // Add start trial button.
7143
- $message .= ' ' . sprintf(
7144
- '<a style="margin-left: 10px;" href="%s"><button class="button button-primary">%s &nbsp;&#10140;</button></a>',
7145
- $upgrade_url,
7146
- __fs( 'start-free-trial' )
7147
- );
7148
-
7149
- $this->_admin_notices->add_sticky(
7150
- $this->apply_filters( 'trial_promotion_message', $message ),
7151
- 'trial_promotion',
7152
- '',
7153
- 'promotion'
7154
- );
7155
-
7156
- $this->_storage->trial_promotion_shown = WP_FS__SCRIPT_START_TIME;
7157
- }
7158
-
7159
- /* Action Links
7160
- ------------------------------------------------------------------------------------------------------------------*/
7161
- private $_action_links_hooked = false;
7162
- private $_action_links = array();
7163
-
7164
- /**
7165
- * @author Vova Feldman (@svovaf)
7166
- * @since 1.0.0
7167
- *
7168
- * @return bool
7169
- */
7170
- private function is_plugin_action_links_hooked() {
7171
- $this->_logger->entrance( json_encode( $this->_action_links_hooked ) );
7172
-
7173
- return $this->_action_links_hooked;
7174
- }
7175
-
7176
- /**
7177
- * Hook to plugin action links filter.
7178
- *
7179
- * @author Vova Feldman (@svovaf)
7180
- * @since 1.0.0
7181
- */
7182
- private function hook_plugin_action_links() {
7183
- $this->_logger->entrance();
7184
-
7185
- $this->_action_links_hooked = true;
7186
-
7187
- $this->_logger->log( 'Adding action links hooks.' );
7188
-
7189
- // Add action link to settings page.
7190
- add_filter( 'plugin_action_links_' . $this->_plugin_basename, array(
7191
- &$this,
7192
- '_modify_plugin_action_links_hook'
7193
- ), 10, 2 );
7194
- add_filter( 'network_admin_plugin_action_links_' . $this->_plugin_basename, array(
7195
- &$this,
7196
- '_modify_plugin_action_links_hook'
7197
- ), 10, 2 );
7198
- }
7199
-
7200
- /**
7201
- * Add plugin action link.
7202
- *
7203
- * @author Vova Feldman (@svovaf)
7204
- * @since 1.0.0
7205
- *
7206
- * @param $label
7207
- * @param $url
7208
- * @param bool $external
7209
- * @param int $priority
7210
- * @param bool $key
7211
- */
7212
- function add_plugin_action_link( $label, $url, $external = false, $priority = 10, $key = false ) {
7213
- $this->_logger->entrance();
7214
-
7215
- if ( ! isset( $this->_action_links[ $priority ] ) ) {
7216
- $this->_action_links[ $priority ] = array();
7217
- }
7218
-
7219
- if ( false === $key ) {
7220
- $key = preg_replace( "/[^A-Za-z0-9 ]/", '', strtolower( $label ) );
7221
- }
7222
-
7223
- $this->_action_links[ $priority ][] = array(
7224
- 'label' => $label,
7225
- 'href' => $url,
7226
- 'key' => $key,
7227
- 'external' => $external
7228
- );
7229
- }
7230
-
7231
- /**
7232
- * Adds Upgrade and Add-Ons links to the main Plugins page link actions collection.
7233
- *
7234
- * @author Vova Feldman (@svovaf)
7235
- * @since 1.0.0
7236
- */
7237
- function _add_upgrade_action_link() {
7238
- $this->_logger->entrance();
7239
-
7240
- if ( $this->is_registered() ) {
7241
- if ( ! $this->is_paying() && $this->has_paid_plan() ) {
7242
- $this->add_plugin_action_link(
7243
- __fs( 'upgrade' ),
7244
- $this->get_upgrade_url(),
7245
- false,
7246
- 20,
7247
- 'upgrade'
7248
- );
7249
- }
7250
-
7251
- if ( $this->_has_addons() ) {
7252
- $this->add_plugin_action_link(
7253
- __fs( 'add-ons' ),
7254
- $this->_get_admin_page_url( 'addons' ),
7255
- false,
7256
- 10,
7257
- 'addons'
7258
- );
7259
- }
7260
- }
7261
- }
7262
-
7263
- /**
7264
- * Forward page to activation page.
7265
- *
7266
- * @author Vova Feldman (@svovaf)
7267
- * @since 1.0.3
7268
- */
7269
- function _redirect_on_activation_hook() {
7270
- $url = false;
7271
- $plugin_fs = false;
7272
-
7273
- if ( ! $this->is_addon() ) {
7274
- $first_time_path = $this->_menu->get_first_time_path();
7275
- $plugin_fs = $this;
7276
- $url = $plugin_fs->is_activation_mode() ?
7277
- $plugin_fs->get_activation_url() :
7278
- ( empty( $first_time_path ) ?
7279
- $this->_get_admin_page_url() :
7280
- $first_time_path );
7281
- } else {
7282
- if ( $this->is_parent_plugin_installed() ) {
7283
- $plugin_fs = self::get_parent_instance();
7284
- }
7285
-
7286
- if ( is_object( $plugin_fs ) ) {
7287
- if ( ! $plugin_fs->is_registered() ) {
7288
- // Forward to parent plugin connect when parent not registered.
7289
- $url = $plugin_fs->get_activation_url();
7290
- } else {
7291
- // Forward to account page.
7292
- $url = $plugin_fs->_get_admin_page_url( 'account' );
7293
- }
7294
- }
7295
- }
7296
-
7297
- if ( is_string( $url ) ) {
7298
- fs_redirect( $url );
7299
- exit();
7300
- }
7301
- }
7302
-
7303
- /**
7304
- * Modify plugin's page action links collection.
7305
- *
7306
- * @author Vova Feldman (@svovaf)
7307
- * @since 1.0.0
7308
- *
7309
- * @param array $links
7310
- * @param $file
7311
- *
7312
- * @return array
7313
- */
7314
- function _modify_plugin_action_links_hook( $links, $file ) {
7315
- $this->_logger->entrance();
7316
-
7317
- ksort( $this->_action_links );
7318
-
7319
- foreach ( $this->_action_links as $new_links ) {
7320
- foreach ( $new_links as $link ) {
7321
- $links[ $link['key'] ] = '<a href="' . $link['href'] . '"' . ( $link['external'] ? ' target="_blank"' : '' ) . '>' . $link['label'] . '</a>';
7322
- }
7323
- }
7324
-
7325
- /*
7326
- * This HTML element is used to identify the correct plugin when attaching an event to its Deactivate link.
7327
- *
7328
- * If user is paying or in trial and have the free version installed,
7329
- * assume that the deactivation is for the upgrade process, so this is not needed.
7330
- */
7331
- if ( ! $this->is_paying_or_trial() || $this->is_premium() ) {
7332
- if ( isset( $links['deactivate'] ) ) {
7333
- $links['deactivate'] .= '<i class="fs-slug" data-slug="' . $this->_slug . '"></i>';
7334
- }
7335
- }
7336
-
7337
- return $links;
7338
- }
7339
-
7340
- /**
7341
- * Adds admin message.
7342
- *
7343
- * @author Vova Feldman (@svovaf)
7344
- * @since 1.0.4
7345
- *
7346
- * @param string $message
7347
- * @param string $title
7348
- * @param string $type
7349
- */
7350
- function add_admin_message( $message, $title = '', $type = 'success' ) {
7351
- $this->_admin_notices->add( $message, $title, $type );
7352
- }
7353
-
7354
- /**
7355
- * Adds sticky admin message.
7356
- *
7357
- * @author Vova Feldman (@svovaf)
7358
- * @since 1.1.0
7359
- *
7360
- * @param string $message
7361
- * @param string $id
7362
- * @param string $title
7363
- * @param string $type
7364
- */
7365
- function add_sticky_admin_message( $message, $id, $title = '', $type = 'success' ) {
7366
- $this->_admin_notices->add_sticky( $message, $id, $title, $type );
7367
- }
7368
-
7369
- /* Plugin Auto-Updates (@since 1.0.4)
7370
- ------------------------------------------------------------------------------------------------------------------*/
7371
- /**
7372
- * @var string[]
7373
- */
7374
- private static $_auto_updated_plugins;
7375
-
7376
- /**
7377
- * @todo TEST IF IT WORKS!!!
7378
- *
7379
- * Include plugins for automatic updates based on stored settings.
7380
- *
7381
- * @see http://wordpress.stackexchange.com/questions/131394/how-do-i-exclude-plugins-from-getting-automatically-updated/131404#131404
7382
- *
7383
- * @author Vova Feldman (@svovaf)
7384
- * @since 1.0.4
7385
- *
7386
- * @param bool $update Whether to update (not used for plugins)
7387
- * @param object $item The plugin's info
7388
- *
7389
- * @return bool
7390
- */
7391
- static function _include_plugins_in_auto_update( $update, $item ) {
7392
- // Before version 3.8.2 the $item was the file name of the plugin,
7393
- // while in 3.8.2 statistics were added (https://core.trac.wordpress.org/changeset/27905).
7394
- $by_slug = ( (int) str_replace( '.', '', get_bloginfo( 'version' ) ) >= 382 );
7395
-
7396
- if ( ! isset( self::$_auto_updated_plugins ) ) {
7397
- $plugins = self::$_accounts->get_option( 'plugins', array() );
7398
-
7399
- $identifiers = array();
7400
- foreach ( $plugins as $p ) {
7401
- /**
7402
- * @var FS_Plugin $p
7403
- */
7404
- if ( isset( $p->auto_update ) && $p->auto_update ) {
7405
- $identifiers[] = ( $by_slug ? $p->slug : plugin_basename( $p->file ) );
7406
- }
7407
- }
7408
-
7409
- self::$_auto_updated_plugins = $identifiers;
7410
- }
7411
-
7412
- if ( in_array( $by_slug ? $item->slug : $item, self::$_auto_updated_plugins ) ) {
7413
- return true;
7414
- }
7415
-
7416
- // Pass update decision to next filters
7417
- return $update;
7418
- }
7419
-
7420
- #region Versioning ------------------------------------------------------------------
7421
-
7422
- /**
7423
- * Check if Freemius in SDK upgrade mode.
7424
- *
7425
- * @author Vova Feldman (@svovaf)
7426
- * @since 1.0.9
7427
- *
7428
- * @return bool
7429
- */
7430
- function is_sdk_upgrade_mode() {
7431
- return isset( $this->_storage->sdk_upgrade_mode ) ?
7432
- $this->_storage->sdk_upgrade_mode :
7433
- false;
7434
- }
7435
-
7436
- /**
7437
- * Turn SDK upgrade mode off.
7438
- *
7439
- * @author Vova Feldman (@svovaf)
7440
- * @since 1.0.9
7441
- *
7442
- * @return bool
7443
- */
7444
- function set_sdk_upgrade_complete() {
7445
- $this->_storage->sdk_upgrade_mode = false;
7446
- }
7447
-
7448
- /**
7449
- * Check if plugin upgrade mode.
7450
- *
7451
- * @author Vova Feldman (@svovaf)
7452
- * @since 1.0.9
7453
- *
7454
- * @return bool
7455
- */
7456
- function is_plugin_upgrade_mode() {
7457
- return isset( $this->_storage->plugin_upgrade_mode ) ?
7458
- $this->_storage->plugin_upgrade_mode :
7459
- false;
7460
- }
7461
-
7462
- /**
7463
- * Turn plugin upgrade mode off.
7464
- *
7465
- * @author Vova Feldman (@svovaf)
7466
- * @since 1.0.9
7467
- *
7468
- * @return bool
7469
- */
7470
- function set_plugin_upgrade_complete() {
7471
- $this->_storage->plugin_upgrade_mode = false;
7472
- }
7473
-
7474
- #endregion ------------------------------------------------------------------
7475
-
7476
- #region Marketing ------------------------------------------------------------------
7477
-
7478
- /**
7479
- * Check if current user purchased any other plugins before.
7480
- *
7481
- * @author Vova Feldman (@svovaf)
7482
- * @since 1.0.9
7483
- *
7484
- * @return bool
7485
- */
7486
- function has_purchased_before() {
7487
- // TODO: Implement has_purchased_before() method.
7488
- }
7489
-
7490
- /**
7491
- * Check if current user classified as an agency.
7492
- *
7493
- * @author Vova Feldman (@svovaf)
7494
- * @since 1.0.9
7495
- *
7496
- * @return bool
7497
- */
7498
- function is_agency() {
7499
- // TODO: Implement is_agency() method.
7500
- }
7501
-
7502
- /**
7503
- * Check if current user classified as a developer.
7504
- *
7505
- * @author Vova Feldman (@svovaf)
7506
- * @since 1.0.9
7507
- *
7508
- * @return bool
7509
- */
7510
- function is_developer() {
7511
- // TODO: Implement is_developer() method.
7512
- }
7513
-
7514
- /**
7515
- * Check if current user classified as a business.
7516
- *
7517
- * @author Vova Feldman (@svovaf)
7518
- * @since 1.0.9
7519
- *
7520
- * @return bool
7521
- */
7522
- function is_business() {
7523
- // TODO: Implement is_business() method.
7524
- }
7525
-
7526
- #endregion ------------------------------------------------------------------
7527
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-fs-api.php DELETED
@@ -1,350 +0,0 @@
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_Option_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
- if ( 0 === count( self::$_instances ) ) {
74
- self::_init();
75
- }
76
-
77
- self::$_instances[ $identifier ] = new FS_Api( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox );
78
- }
79
-
80
- return self::$_instances[ $identifier ];
81
- }
82
-
83
- private static function _init() {
84
- if ( ! class_exists( 'Freemius_Api' ) ) {
85
- require_once( WP_FS__DIR_SDK . '/Freemius.php' );
86
- }
87
-
88
- self::$_options = FS_Option_Manager::get_manager( WP_FS__OPTIONS_OPTION_NAME, true );
89
- self::$_cache = FS_Option_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME, true );
90
-
91
- self::$_clock_diff = self::$_options->get_option( 'api_clock_diff', 0 );
92
- Freemius_Api::SetClockDiff( self::$_clock_diff );
93
-
94
- if ( self::$_options->get_option( 'api_force_http', false ) ) {
95
- Freemius_Api::SetHttp();
96
- }
97
- }
98
-
99
- /**
100
- * @param string $slug
101
- * @param string $scope 'app', 'developer', 'user' or 'install'.
102
- * @param number $id Element's id.
103
- * @param string $public_key Public key.
104
- * @param bool|string $secret_key Element's secret key.
105
- * @param bool $is_sandbox
106
- */
107
- private function __construct( $slug, $scope, $id, $public_key, $secret_key, $is_sandbox ) {
108
- $this->_api = new Freemius_Api( $scope, $id, $public_key, $secret_key, $is_sandbox );
109
-
110
- $this->_slug = $slug;
111
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_api', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
112
- }
113
-
114
- /**
115
- * Find clock diff between server and API server, and store the diff locally.
116
- *
117
- * @param bool|int $diff
118
- *
119
- * @return bool|int False if clock diff didn't change, otherwise returns the clock diff in seconds.
120
- */
121
- private function _sync_clock_diff( $diff = false ) {
122
- $this->_logger->entrance();
123
-
124
- // Sync clock and store.
125
- $new_clock_diff = ( false === $diff ) ?
126
- $this->_api->FindClockDiff() :
127
- $diff;
128
-
129
- if ( $new_clock_diff === self::$_clock_diff ) {
130
- return false;
131
- }
132
-
133
- self::$_clock_diff = $new_clock_diff;
134
-
135
- // Update API clock's diff.
136
- $this->_api->SetClockDiff( self::$_clock_diff );
137
-
138
- // Store new clock diff in storage.
139
- self::$_options->set_option( 'api_clock_diff', self::$_clock_diff, true );
140
-
141
- return $new_clock_diff;
142
- }
143
-
144
- /**
145
- * Override API call to enable retry with servers' clock auto sync method.
146
- *
147
- * @param string $path
148
- * @param string $method
149
- * @param array $params
150
- * @param bool $retry Is in retry or first call attempt.
151
- *
152
- * @return array|mixed|string|void
153
- */
154
- private function _call( $path, $method = 'GET', $params = array(), $retry = false ) {
155
- $this->_logger->entrance();
156
-
157
- $result = $this->_api->Api( $path, $method, $params );
158
-
159
- if ( null !== $result &&
160
- isset( $result->error ) &&
161
- 'request_expired' === $result->error->code
162
- ) {
163
- if ( ! $retry ) {
164
- $diff = isset( $result->error->timestamp ) ?
165
- ( time() - strtotime( $result->error->timestamp ) ) :
166
- false;
167
-
168
- // Try to sync clock diff.
169
- if ( false !== $this->_sync_clock_diff( $diff ) ) {
170
- // Retry call with new synced clock.
171
- return $this->_call( $path, $method, $params, true );
172
- }
173
- }
174
- }
175
-
176
- if ( null !== $result && isset( $result->error ) ) {
177
- // Log API errors.
178
- $this->_logger->error( $result->error->message );
179
- }
180
-
181
- return $result;
182
- }
183
-
184
- /**
185
- * Override API call to wrap it in servers' clock sync method.
186
- *
187
- * @param string $path
188
- * @param string $method
189
- * @param array $params
190
- *
191
- * @return array|mixed|string|void
192
- * @throws Freemius_Exception
193
- */
194
- function call( $path, $method = 'GET', $params = array() ) {
195
- return $this->_call( $path, $method, $params );
196
- }
197
-
198
- /**
199
- * Get API request URL signed via query string.
200
- *
201
- * @param string $path
202
- *
203
- * @return string
204
- */
205
- function get_signed_url( $path ) {
206
- return $this->_api->GetSignedUrl( $path );
207
- }
208
-
209
- /**
210
- * @param string $path
211
- * @param bool $flush
212
- * @param int $expiration (optional) Time until expiration in seconds from now, defaults to 24 hours
213
- *
214
- * @return stdClass|mixed
215
- */
216
- function get( $path = '/', $flush = false, $expiration = WP_FS__TIME_24_HOURS_IN_SEC ) {
217
- $cache_key = $this->get_cache_key( $path );
218
-
219
- // Always flush during development.
220
- if ( WP_FS__DEV_MODE || $this->_api->IsSandbox() ) {
221
- $flush = true;
222
- }
223
-
224
- // Get result from cache.
225
- $cache_entry = self::$_cache->get_option( $cache_key, false );
226
-
227
- $fetch = false;
228
- if ( $flush ||
229
- false === $cache_entry ||
230
- ! isset( $cache_entry->timestamp ) ||
231
- ! is_numeric( $cache_entry->timestamp ) ||
232
- $cache_entry->timestamp < WP_FS__SCRIPT_START_TIME
233
- ) {
234
- $fetch = true;
235
- }
236
-
237
- if ( $fetch ) {
238
- $result = $this->call( $path );
239
-
240
- if ( ! is_object( $result ) || isset( $result->error ) ) {
241
- if ( is_object( $cache_entry ) &&
242
- isset( $cache_entry->result ) &&
243
- ! isset( $cache_entry->result->error )
244
- ) {
245
- // If there was an error during a newer data fetch,
246
- // fallback to older data version.
247
- $result = $cache_entry->result;
248
- } else {
249
- // If no older data version, return result without
250
- // caching the error.
251
- return $result;
252
- }
253
- }
254
-
255
- $cache_entry = new stdClass();
256
- $cache_entry->result = $result;
257
- $cache_entry->timestamp = WP_FS__SCRIPT_START_TIME + $expiration;
258
- self::$_cache->set_option( $cache_key, $cache_entry, true );
259
- }
260
-
261
- return $cache_entry->result;
262
- }
263
-
264
- private function get_cache_key( $path, $method = 'GET', $params = array() ) {
265
- $canonized = $this->_api->CanonizePath( $path );
266
- // $exploded = explode('/', $canonized);
267
- // return $method . '_' . array_pop($exploded) . '_' . md5($canonized . json_encode($params));
268
- return $method . ':' . $canonized . ( ! empty( $params ) ? '#' . md5( json_encode( $params ) ) : '' );
269
- }
270
-
271
- /**
272
- * Test API connectivity.
273
- *
274
- * @since 1.0.9 If fails, try to fallback to HTTP.
275
- *
276
- * @param null|string $unique_anonymous_id
277
- *
278
- * @return bool True if successful connectivity to the API.
279
- */
280
- function test( $unique_anonymous_id = null ) {
281
- $this->_logger->entrance();
282
-
283
- if ( ! function_exists( 'curl_version' ) ) {
284
- // cUrl extension is not active.
285
- return false;
286
- }
287
-
288
- $test = is_null( $unique_anonymous_id ) ?
289
- $this->_api->Test() :
290
- $this->_api->Test( $this->_call( 'ping.json?uid=' . $unique_anonymous_id ) );
291
-
292
- if ( false === $test && $this->_api->IsHttps() ) {
293
- // Fallback to HTTP, since HTTPS fails.
294
- $this->_api->SetHttp();
295
-
296
- self::$_options->set_option( 'api_force_http', true, true );
297
-
298
- $test = is_null( $unique_anonymous_id ) ?
299
- $this->_api->Test() :
300
- $this->_api->Test( $this->_call( 'ping.json?uid=' . $unique_anonymous_id ) );
301
- }
302
-
303
- return $test;
304
- }
305
-
306
- /**
307
- * Ping API for connectivity test, and return result object.
308
- *
309
- * @author Vova Feldman (@svovaf)
310
- * @since 1.0.9
311
- *
312
- * @param null|string $unique_anonymous_id
313
- *
314
- * @return object
315
- */
316
- function ping( $unique_anonymous_id = null ) {
317
- return is_null( $unique_anonymous_id ) ?
318
- $this->_api->Ping() :
319
- $this->_call( 'ping.json?uid=' . $unique_anonymous_id );
320
- }
321
-
322
- /**
323
- * Check if valid ping request result.
324
- *
325
- * @author Vova Feldman (@svovaf)
326
- * @since 1.1.1
327
- *
328
- * @param mixed $pong
329
- *
330
- * @return bool
331
- */
332
- function is_valid_ping( $pong ) {
333
- return $this->_api->Test( $pong );
334
- }
335
-
336
- function get_url( $path = '' ) {
337
- return $this->_api->GetUrl( $path );
338
- }
339
-
340
- /**
341
- * Clear API cache.
342
- *
343
- * @author Vova Feldman (@svovaf)
344
- * @since 1.0.9
345
- */
346
- static function clear_cache() {
347
- self::$_cache = FS_Option_Manager::get_manager( WP_FS__API_CACHE_OPTION_NAME, true );
348
- self::$_cache->clear( true );
349
- }
350
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-fs-logger.php DELETED
@@ -1,168 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Logger {
14
- private $_id;
15
- private $_on = false;
16
- private $_echo = false;
17
- private $_file_start = 0;
18
-
19
- private static $LOGGERS = array();
20
- private static $LOG = array();
21
- private static $CNT = 0;
22
- private static $_HOOKED_FOOTER = false;
23
-
24
- private function __construct( $id, $on = false, $echo = false ) {
25
- $this->_id = $id;
26
-
27
- $bt = debug_backtrace();
28
- $caller = $bt[2];
29
-
30
- $this->_file_start = strpos( $caller['file'], 'plugins' ) + strlen( 'plugins/' );
31
-
32
- if ( $on ) {
33
- $this->on();
34
- }
35
- if ( $echo ) {
36
- $this->echo_on();
37
- }
38
- }
39
-
40
- /**
41
- * @param string $id
42
- * @param bool $on
43
- * @param bool $echo
44
- *
45
- * @return FS_Logger
46
- */
47
- public static function get_logger( $id, $on = false, $echo = false ) {
48
- $id = strtolower( $id );
49
-
50
- if ( ! isset( self::$LOGGERS[ $id ] ) ) {
51
- self::$LOGGERS[ $id ] = new FS_Logger( $id, $on, $echo );
52
- }
53
-
54
- return self::$LOGGERS[ $id ];
55
- }
56
-
57
- private static function _hook_footer() {
58
- if ( self::$_HOOKED_FOOTER ) {
59
- return;
60
- }
61
-
62
- if ( is_admin() ) {
63
- add_action( 'admin_footer', 'FS_Logger::dump', 100 );
64
- } else {
65
- add_action( 'wp_footer', 'FS_Logger::dump', 100 );
66
- }
67
- }
68
-
69
- function is_on() {
70
- return $this->_on;
71
- }
72
-
73
- function on() {
74
- $this->_on = true;
75
-
76
- self::_hook_footer();
77
- }
78
-
79
- function echo_on() {
80
- $this->_on;
81
-
82
- $this->_echo = true;
83
- }
84
-
85
- function is_echo_on() {
86
- return $this->_echo;
87
- }
88
-
89
-
90
- private function _log( &$message, $type = 'log', $wrapper ) {
91
- if ( ! $this->is_on() ) {
92
- return;
93
- }
94
-
95
- $bt = debug_backtrace();
96
- $depth = $wrapper ? 3 : 2;
97
- while ( $depth < count( $bt ) - 1 && 'eval' === $bt[ $depth ]['function'] ) {
98
- $depth ++;
99
- }
100
-
101
- $caller = $bt[ $depth ];
102
-
103
- $log = array_merge( $caller, array(
104
- 'cnt' => self::$CNT ++,
105
- 'logger' => $this,
106
- 'timestamp' => date( WP_FS__LOG_DATETIME_FORMAT . ':u' ),
107
- 'type' => $type,
108
- 'msg' => $message,
109
- ) );
110
-
111
- self::$LOG[] = $log;
112
-
113
- if ( $this->is_echo_on() ) {
114
- echo self::_format_html( $log ) . "\n";
115
- }
116
- }
117
-
118
- function log( $message, $wrapper = false ) {
119
- $this->_log( $message, 'log', $wrapper );
120
- }
121
-
122
- function info( $message, $wrapper = false ) {
123
- $this->_log( $message, 'info', $wrapper );
124
- }
125
-
126
- function warn( $message, $wrapper = false ) {
127
- $this->_log( $message, 'warn', $wrapper );
128
- }
129
-
130
- function error( $message, $wrapper = false ) {
131
- $this->_log( $message, 'error', $wrapper );
132
- }
133
-
134
- function entrance( $message = '', $wrapper = false ) {
135
- $msg = 'Entrance' . ( empty( $message ) ? '' : ' > ' ) . $message;
136
-
137
- $this->_log( $msg, 'log', $wrapper );
138
- }
139
-
140
- function departure( $message = '', $wrapper = false ) {
141
- $msg = 'Departure' . ( empty( $message ) ? '' : ' > ' ) . $message;
142
-
143
- $this->_log( $msg, 'log', $wrapper );
144
- }
145
-
146
- private static function _format( $log, $show_type = true ) {
147
- return '[' . str_pad( $log['cnt'], strlen( self::$CNT ), '0', STR_PAD_LEFT ) . '] [' . $log['logger']->_id . '] ' . ( $show_type ? '[' . $log['type'] . ']' : '' ) . $log['function'] . ' >> ' . $log['msg'] . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ') ' : '' ) . ' [' . $log['timestamp'] . ']';
148
- }
149
-
150
- private static function _format_html( $log ) {
151
- return '<div style="font-size: 11px; padding: 3px; background: #ccc; margin-bottom: 3px;">[' . $log['cnt'] . '] [' . $log['logger']->_id . '] [' . $log['type'] . '] <b><code style="color: blue;">' . $log['function'] . '</code> >> <b style="color: darkorange;">' . $log['msg'] . '</b></b>' . ( isset( $log['file'] ) ? ' (' . substr( $log['file'], $log['logger']->_file_start ) . ' ' . $log['line'] . ')' : '' ) . ' [' . $log['timestamp'] . ']</div>';
152
- }
153
-
154
- static function dump() {
155
- ?>
156
- <!-- BEGIN: Freemius PHP Console Log -->
157
- <script type="text/javascript">
158
- <?php
159
- foreach (self::$LOG as $log)
160
- {
161
- echo 'console.' . $log['type'] . '(' . json_encode(self::_format($log, false)) . ')' . "\n";
162
- }
163
- ?>
164
- </script>
165
- <!-- END: Freemius PHP Console Log -->
166
- <?php
167
- }
168
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-fs-plugin-updater.php DELETED
@@ -1,253 +0,0 @@
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
- function __construct( Freemius $freemius ) {
32
- $this->_fs = $freemius;
33
-
34
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $freemius->get_slug() . '_updater', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
35
-
36
- $this->_filters();
37
- }
38
-
39
- /**
40
- * Initiate required filters.
41
- *
42
- * @author Vova Feldman (@svovaf)
43
- * @since 1.0.4
44
- */
45
- private function _filters() {
46
- // Override request for plugin information
47
- add_filter( 'plugins_api', array( &$this, 'plugins_api_filter' ), 10, 3 );
48
-
49
- // WP 3.0+
50
- add_filter( 'pre_set_site_transient_update_plugins', array(
51
- &$this,
52
- 'pre_set_site_transient_update_plugins_filter'
53
- ) );
54
-
55
- if ( ! WP_FS__IS_PRODUCTION_MODE ) {
56
- add_filter( 'http_request_host_is_external', array(
57
- $this,
58
- 'http_request_host_is_external_filter'
59
- ), 10, 3 );
60
- }
61
- }
62
-
63
- /**
64
- * Since WP version 3.6, a new security feature was added that denies access to repository with a local ip.
65
- * During development mode we want to be able updating plugin versions via our localhost repository. This
66
- * filter white-list all domains including "api.freemius".
67
- *
68
- * @link http://www.emanueletessore.com/wordpress-download-failed-valid-url-provided/
69
- *
70
- * @author Vova Feldman (@svovaf)
71
- * @since 1.0.4
72
- *
73
- * @param bool $allow
74
- * @param string $host
75
- * @param string $url
76
- *
77
- * @return bool
78
- */
79
- function http_request_host_is_external_filter( $allow, $host, $url ) {
80
- return ( false !== strpos( $host, 'freemius' ) ) ? true : $allow;
81
- }
82
-
83
- /**
84
- * Check for Updates at the defined API endpoint and modify the update array.
85
- *
86
- * This function dives into the update api just when WordPress creates its update array,
87
- * then adds a custom API call and injects the custom plugin data retrieved from the API.
88
- * It is reassembled from parts of the native WordPress plugin update code.
89
- * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
90
- *
91
- * @author Vova Feldman (@svovaf)
92
- * @since 1.0.4
93
- *
94
- * @uses FS_Api
95
- *
96
- * @param stdClass $transient_data Update array build by WordPress.
97
- *
98
- * @return array Modified update array with custom plugin data.
99
- */
100
- function pre_set_site_transient_update_plugins_filter( $transient_data ) {
101
- $this->_logger->entrance();
102
-
103
- if ( empty( $transient_data ) ||
104
- defined( 'WP_FS__UNINSTALL_MODE' )
105
- ) {
106
- return $transient_data;
107
- }
108
-
109
- // Get plugin's newest update.
110
- $new_version = $this->_fs->get_update();
111
-
112
- if ( is_object( $new_version ) ) {
113
- $this->_logger->log( 'Found newer plugin version ' . $new_version->version );
114
-
115
- $plugin_details = new stdClass();
116
- $plugin_details->slug = $this->_fs->get_slug();
117
- $plugin_details->new_version = $new_version->version;
118
- $plugin_details->url = WP_FS__ADDRESS;
119
- $plugin_details->package = $new_version->url;
120
- $plugin_details->plugin = $this->_fs->get_plugin_basename();
121
-
122
- // Add plugin to transient data.
123
- $transient_data->response[ $this->_fs->get_plugin_basename() ] = $plugin_details;
124
- }
125
-
126
- return $transient_data;
127
- }
128
-
129
- /**
130
- * Try to fetch plugin's info from .org repository.
131
- *
132
- * @author Vova Feldman (@svovaf)
133
- * @since 1.0.5
134
- *
135
- * @param string $action
136
- * @param array $args
137
- *
138
- * @return bool|mixed
139
- */
140
- private function _fetch_plugin_info_from_repository( $action, $args ) {
141
- $url = $http_url = 'http://api.wordpress.org/plugins/info/1.0/';
142
- if ( $ssl = wp_http_supports( array( 'ssl' ) ) ) {
143
- $url = set_url_scheme( $url, 'https' );
144
- }
145
-
146
- $args = array(
147
- 'timeout' => 15,
148
- 'body' => array(
149
- 'action' => $action,
150
- 'request' => serialize( $args )
151
- )
152
- );
153
-
154
- $request = wp_remote_post( $url, $args );
155
-
156
- if ( is_wp_error( $request ) ) {
157
- return false;
158
- }
159
-
160
- $res = maybe_unserialize( wp_remote_retrieve_body( $request ) );
161
-
162
- if ( ! is_object( $res ) && ! is_array( $res ) ) {
163
- return false;
164
- }
165
-
166
- return $res;
167
- }
168
-
169
- /**
170
- * Updates information on the "View version x.x details" page with custom data.
171
- *
172
- * @author Vova Feldman (@svovaf)
173
- * @since 1.0.4
174
- *
175
- * @uses FS_Api
176
- *
177
- * @param object $data
178
- * @param string $action
179
- * @param mixed $args
180
- *
181
- * @return object
182
- */
183
- function plugins_api_filter( $data, $action = '', $args = null ) {
184
- $this->_logger->entrance();
185
-
186
- if ( ( 'plugin_information' !== $action ) ||
187
- ! isset( $args->slug )
188
- ) {
189
- return $data;
190
- }
191
-
192
- $addon = false;
193
- $is_addon = false;
194
-
195
- if ( $this->_fs->get_slug() !== $args->slug ) {
196
- $addon = $this->_fs->get_addon_by_slug( $args->slug );
197
-
198
- if ( ! is_object( $addon ) ) {
199
- return $data;
200
- }
201
-
202
- $is_addon = true;
203
- }
204
-
205
- $plugin_in_repo = false;
206
- if ( ! $is_addon ) {
207
- // Try to fetch info from .org repository.
208
- $data = $this->_fetch_plugin_info_from_repository( $action, $args );
209
-
210
- $plugin_in_repo = ( false !== $data );
211
- }
212
-
213
- if ( ! $plugin_in_repo ) {
214
- $data = $args;
215
-
216
- // Fetch as much as possible info from local files.
217
- $plugin_local_data = $this->_fs->get_plugin_data();
218
- $data->name = $plugin_local_data['Name'];
219
- $data->author = $plugin_local_data['Author'];
220
- $data->sections = array(
221
- 'description' => 'Upgrade ' . $plugin_local_data['Name'] . ' to latest.',
222
- );
223
-
224
- // @todo Store extra plugin info on Freemius or parse readme.txt markup.
225
- /*$info = $this->_fs->get_api_site_scope()->call('/information.json');
226
-
227
- if ( !isset($info->error) ) {
228
- $data = $info;
229
- }*/
230
- }
231
-
232
- // Get plugin's newest update.
233
- $new_version = $this->_fs->_fetch_latest_version( $is_addon ? $addon->id : false );
234
-
235
- if ( $is_addon ) {
236
- $data->name = $addon->title . ' ' . __fs( 'addon' );
237
- $data->slug = $addon->slug;
238
- $data->url = WP_FS__ADDRESS;
239
- $data->package = $new_version->url;
240
- }
241
-
242
- if ( ! $plugin_in_repo ) {
243
- $data->last_updated = ! is_null( $new_version->updated ) ? $new_version->updated : $new_version->created;
244
- $data->requires = $new_version->requires_platform_version;
245
- $data->tested = $new_version->tested_up_to_version;
246
- }
247
-
248
- $data->version = $new_version->version;
249
- $data->download_link = $new_version->url;
250
-
251
- return $data;
252
- }
253
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/class-fs-security.php DELETED
@@ -1,61 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- define( 'WP_FS__SECURITY_PARAMS_PREFIX', 's_' );
14
-
15
- class FS_Security {
16
- /**
17
- * @var FS_Security
18
- * @since 1.0.3
19
- */
20
- private static $_instance;
21
- /**
22
- * @var FS_Logger
23
- * @since 1.0.3
24
- */
25
- private static $_logger;
26
-
27
- public static function instance() {
28
- if ( ! isset( self::$_instance ) ) {
29
- self::$_instance = new FS_Security();
30
- self::$_logger = FS_Logger::get_logger( WP_FS__SLUG, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
31
- }
32
-
33
- return self::$_instance;
34
- }
35
-
36
- private function __construct() {
37
- }
38
-
39
- function get_secure_token( FS_Scope_Entity $entity, $timestamp, $action = '' ) {
40
- return md5(
41
- $timestamp .
42
- $entity->id .
43
- $entity->secret_key .
44
- $entity->public_key .
45
- $action
46
- );
47
- }
48
-
49
- function get_context_params( FS_Scope_Entity $entity, $timestamp = false, $action = '' ) {
50
- if ( false === $timestamp ) {
51
- $timestamp = time();
52
- }
53
-
54
- return array(
55
- 's_ctx_type' => $entity->get_type(),
56
- 's_ctx_id' => $entity->id,
57
- 's_ctx_ts' => $timestamp,
58
- 's_ctx_secure' => $this->get_secure_token( $entity, $timestamp, $action ),
59
- );
60
- }
61
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-entity.php DELETED
@@ -1,149 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- /**
14
- * Get object's public variables.
15
- *
16
- * @author Vova Feldman (@svovaf)
17
- * @since 1.0.0
18
- *
19
- * @param object $object
20
- *
21
- * @return array
22
- */
23
- function fs_get_object_public_vars( $object ) {
24
- return get_object_vars( $object );
25
- }
26
-
27
- class FS_Entity {
28
- /**
29
- * @var number
30
- */
31
- public $id;
32
- /**
33
- * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
34
- */
35
- public $updated;
36
- /**
37
- * @var string Datetime value in 'YYYY-MM-DD HH:MM:SS' format.
38
- */
39
- public $created;
40
-
41
- /**
42
- * @param bool|stdClass $entity
43
- */
44
- function __construct( $entity = false ) {
45
- if ( ! ( $entity instanceof stdClass ) ) {
46
- return;
47
- }
48
-
49
- $props = fs_get_object_public_vars( $this );
50
-
51
- foreach ( $props as $key => $def_value ) {
52
- $this->{$key} = isset( $entity->{$key} ) ?
53
- $entity->{$key} :
54
- $def_value;
55
- }
56
- }
57
-
58
- static function get_type() {
59
- return 'type';
60
- }
61
-
62
- /**
63
- * @author Vova Feldman (@svovaf)
64
- * @since 1.0.6
65
- *
66
- * @param FS_Entity $entity1
67
- * @param FS_Entity $entity2
68
- *
69
- * @return bool
70
- */
71
- static function equals( $entity1, $entity2 ) {
72
- if ( is_null( $entity1 ) && is_null( $entity2 ) ) {
73
- return true;
74
- } else if ( is_object( $entity1 ) && is_object( $entity2 ) ) {
75
- return ( $entity1->id == $entity2->id );
76
- } else if ( is_object( $entity1 ) ) {
77
- return is_null( $entity1->id );
78
- } else {
79
- return is_null( $entity2->id );
80
- }
81
- }
82
-
83
- private $_is_updated = false;
84
-
85
- /**
86
- * Update object property.
87
- *
88
- * @author Vova Feldman (@svovaf)
89
- * @since 1.0.9
90
- *
91
- * @param string|array[string]mixed $key
92
- * @param string|bool $val
93
- *
94
- * @return bool
95
- */
96
- function update( $key, $val = false ) {
97
- if ( ! is_array( $key ) ) {
98
- $key = array( $key => $val );
99
- }
100
-
101
- $is_updated = false;
102
-
103
- foreach ( $key as $k => $v ) {
104
- if ( $this->{$k} === $v ) {
105
- continue;
106
- }
107
-
108
- if ( ( is_string( $this->{$k} ) && is_numeric( $v ) ||
109
- ( is_numeric( $this->{$k} ) && is_string( $v ) ) ) &&
110
- $this->{$k} == $v
111
- ) {
112
- continue;
113
- }
114
-
115
- // Update value.
116
- $this->{$k} = $v;
117
-
118
- $is_updated = true;
119
- }
120
-
121
- $this->_is_updated = $is_updated;
122
-
123
- return $is_updated;
124
- }
125
-
126
- /**
127
- * Checks if entity was updated.
128
- *
129
- * @author Vova Feldman (@svovaf)
130
- * @since 1.0.9
131
- *
132
- * @return bool
133
- */
134
- function is_updated() {
135
- return $this->_is_updated;
136
- }
137
-
138
- /**
139
- * @param $id
140
- *
141
- * @author Vova Feldman (@svovaf)
142
- * @since 1.1.2
143
- *
144
- * @return bool
145
- */
146
- static function is_valid_id($id){
147
- return is_numeric($id);
148
- }
149
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-plugin-info.php DELETED
@@ -1,34 +0,0 @@
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 DELETED
@@ -1,160 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.5
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Plugin_License extends FS_Entity {
14
-
15
- #region Properties
16
-
17
- /**
18
- * @var number
19
- */
20
- public $plugin_id;
21
- /**
22
- * @var number
23
- */
24
- public $user_id;
25
- /**
26
- * @var number
27
- */
28
- public $plan_id;
29
- /**
30
- * @var number
31
- */
32
- public $pricing_id;
33
- /**
34
- * @var int
35
- */
36
- public $quota;
37
- /**
38
- * @var int
39
- */
40
- public $activated;
41
- /**
42
- * @var int
43
- */
44
- public $activated_local;
45
- /**
46
- * @var string
47
- */
48
- public $expiration;
49
- /**
50
- * @var bool $is_free_localhost Defaults to true. If true, allow unlimited localhost installs with the same
51
- * license.
52
- */
53
- public $is_free_localhost;
54
- /**
55
- * @var bool $is_block_features Defaults to true. If false, don't block features after license expiry - only
56
- * block updates and support.
57
- */
58
- public $is_block_features;
59
- /**
60
- * @var bool
61
- */
62
- public $is_cancelled;
63
-
64
- #endregion Properties
65
-
66
- /**
67
- * @param stdClass|bool $license
68
- */
69
- function __construct( $license = false ) {
70
- parent::__construct( $license );
71
- }
72
-
73
- static function get_type() {
74
- return 'license';
75
- }
76
-
77
- /**
78
- * Check how many site activations left.
79
- *
80
- * @author Vova Feldman (@svovaf)
81
- * @since 1.0.5
82
- *
83
- * @return int
84
- */
85
- function left() {
86
- if ( $this->is_expired() ) {
87
- return 0;
88
- }
89
-
90
- return ( $this->quota - $this->activated - ( $this->is_free_localhost ? 0 : $this->activated_local ) );
91
- }
92
-
93
- /**
94
- * @author Vova Feldman (@svovaf)
95
- * @since 1.0.5
96
- *
97
- * @return bool
98
- */
99
- function is_expired() {
100
- return ! $this->is_lifetime() && ( strtotime( $this->expiration ) < WP_FS__SCRIPT_START_TIME );
101
- }
102
-
103
- /**
104
- * @author Vova Feldman (@svovaf)
105
- * @since 1.0.6
106
- *
107
- * @return bool
108
- */
109
- function is_lifetime() {
110
- return is_null( $this->expiration );
111
- }
112
-
113
- /**
114
- * Check if license is fully utilized.
115
- *
116
- * @author Vova Feldman (@svovaf)
117
- * @since 1.0.6
118
- *
119
- * @param bool $is_localhost
120
- *
121
- * @return bool
122
- */
123
- function is_utilized( $is_localhost = null ) {
124
- if ( is_null( $is_localhost ) ) {
125
- $is_localhost = WP_FS__IS_LOCALHOST_FOR_SERVER;
126
- }
127
-
128
- return ! ( $this->is_free_localhost && $is_localhost ) &&
129
- ( $this->quota <= $this->activated + ( $this->is_free_localhost ? 0 : $this->activated_local ) );
130
- }
131
-
132
- /**
133
- * Check if license's plan features are enabled.
134
- *
135
- * - Either if plan not expired
136
- * - If expired, based on the configuration to block features or not.
137
- *
138
- * @author Vova Feldman (@svovaf)
139
- * @since 1.0.6
140
- *
141
- * @return bool
142
- */
143
- function is_features_enabled() {
144
- return ( ! $this->is_block_features || ! $this->is_expired() );
145
- }
146
-
147
- /**
148
- * Subscription considered to be new without any payments
149
- * if the license expires in less than 24 hours
150
- * from the license creation.
151
- *
152
- * @author Vova Feldman (@svovaf)
153
- * @since 1.0.9
154
- *
155
- * @return bool
156
- */
157
- function is_first_payment_pending() {
158
- return ( WP_FS__TIME_24_HOURS_IN_SEC >= strtotime( $this->expiration ) - strtotime( $this->created ) );
159
- }
160
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-plugin-plan.php DELETED
@@ -1,71 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.5
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Plugin_Plan extends FS_Entity {
14
-
15
- #region Properties
16
-
17
- /**
18
- * @var string
19
- */
20
- public $title;
21
- /**
22
- * @var string
23
- */
24
- public $name;
25
- /**
26
- * @var int Trial days.
27
- */
28
- public $trial_period;
29
- /**
30
- * @var string If true, require payment for trial.
31
- */
32
- public $is_require_subscription;
33
-
34
- #endregion Properties
35
-
36
- /**
37
- * @param object|bool $plan
38
- */
39
- function __construct( $plan = false ) {
40
- parent::__construct( $plan );
41
-
42
- if ( is_object( $plan ) ) {
43
- $this->name = strtolower( $plan->name );
44
- }
45
- }
46
-
47
- static function get_type() {
48
- return 'plan';
49
- }
50
-
51
- /**
52
- * @author Vova Feldman (@svovaf)
53
- * @since 1.0.9
54
- *
55
- * @return bool
56
- */
57
- function is_free() {
58
- return ( 'free' === $this->name );
59
- }
60
-
61
- /**
62
- * @author Vova Feldman (@svovaf)
63
- * @since 1.0.9
64
- *
65
- * @return bool
66
- */
67
- function has_trial() {
68
- return ! $this->is_free() &&
69
- is_numeric( $this->trial_period ) && ( $this->trial_period > 0 );
70
- }
71
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-plugin-tag.php DELETED
@@ -1,24 +0,0 @@
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 DELETED
@@ -1,90 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Plugin extends FS_Scope_Entity {
14
- /**
15
- * @since 1.0.6
16
- * @var null|number
17
- */
18
- public $parent_plugin_id;
19
- /**
20
- * @var string
21
- */
22
- public $title;
23
- /**
24
- * @var string
25
- */
26
- public $slug;
27
-
28
- #region Install Specific Properties
29
-
30
- /**
31
- * @var string
32
- */
33
- public $file;
34
- /**
35
- * @var string
36
- */
37
- public $version;
38
- /**
39
- * @var bool
40
- */
41
- public $auto_update;
42
- /**
43
- * @var FS_Plugin_Info
44
- */
45
- public $info;
46
- /**
47
- * @since 1.0.9
48
- *
49
- * @var bool
50
- */
51
- public $is_premium;
52
- /**
53
- * @since 1.0.9
54
- *
55
- * @var bool
56
- */
57
- public $is_live;
58
-
59
- #endregion Install Specific Properties
60
-
61
- /**
62
- * @param stdClass|bool $plugin
63
- */
64
- function __construct( $plugin = false ) {
65
- parent::__construct( $plugin );
66
-
67
- $this->is_premium = false;
68
- $this->is_live = true;
69
-
70
- if ( isset( $plugin->info ) && is_object( $plugin->info ) ) {
71
- $this->info = new FS_Plugin_Info( $plugin->info );
72
- }
73
- }
74
-
75
- /**
76
- * Check if plugin is an add-on (has parent).
77
- *
78
- * @author Vova Feldman (@svovaf)
79
- * @since 1.0.6
80
- *
81
- * @return bool
82
- */
83
- function is_addon() {
84
- return isset( $this->parent_plugin_id ) && is_numeric( $this->parent_plugin_id );
85
- }
86
-
87
- static function get_type() {
88
- return 'plugin';
89
- }
90
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-scope-entity.php DELETED
@@ -1,29 +0,0 @@
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 DELETED
@@ -1,119 +0,0 @@
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 $user_id;
22
- /**
23
- * @var string
24
- */
25
- public $title;
26
- /**
27
- * @var string
28
- */
29
- public $url;
30
- /**
31
- * @var string
32
- */
33
- public $version;
34
- /**
35
- * @var string E.g. en-GB
36
- */
37
- public $language;
38
- /**
39
- * @var string E.g. UTF-8
40
- */
41
- public $charset;
42
- /**
43
- * @var string Platform version (e.g WordPress version).
44
- */
45
- public $platform_version;
46
- /**
47
- * @var string Programming language version (e.g PHP version).
48
- */
49
- public $programming_language_version;
50
- /**
51
- * @var FS_Plugin_Plan $plan
52
- */
53
- public $plan;
54
- /**
55
- * @var number|null
56
- */
57
- public $license_id;
58
- /**
59
- * @var number|null
60
- */
61
- public $trial_plan_id;
62
- /**
63
- * @var string|null
64
- */
65
- public $trial_ends;
66
- /**
67
- * @since 1.0.9
68
- *
69
- * @var bool
70
- */
71
- public $is_premium = false;
72
-
73
- /**
74
- * @param stdClass|bool $site
75
- */
76
- function __construct( $site = false ) {
77
- $this->plan = new FS_Plugin_Plan();
78
-
79
- parent::__construct( $site );
80
-
81
- if ( is_object( $site ) && isset( $site->plan_id ) ) {
82
- $this->plan->id = $site->plan_id;
83
- }
84
- }
85
-
86
- static function get_type() {
87
- return 'install';
88
- }
89
-
90
- function is_localhost() {
91
- // The server has no way to verify if localhost unless localhost appears in domain.
92
- return WP_FS__IS_LOCALHOST_FOR_SERVER;
93
- // return (substr($_SERVER['REMOTE_ADDR'], 0, 4) == '127.' || $_SERVER['REMOTE_ADDR'] == '::1');
94
- }
95
-
96
- /**
97
- * Check if site in trial.
98
- *
99
- * @author Vova Feldman (@svovaf)
100
- * @since 1.0.9
101
- *
102
- * @return bool
103
- */
104
- function is_trial() {
105
- return is_numeric( $this->trial_plan_id ) && ( strtotime( $this->trial_ends ) > WP_FS__SCRIPT_START_TIME );
106
- }
107
-
108
- /**
109
- * Check if user already utilized the trial with the current install.
110
- *
111
- * @author Vova Feldman (@svovaf)
112
- * @since 1.0.9
113
- *
114
- * @return bool
115
- */
116
- function is_trial_utilized() {
117
- return is_numeric( $this->trial_plan_id );
118
- }
119
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-subscription.php DELETED
@@ -1,117 +0,0 @@
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
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/entities/class-fs-user.php DELETED
@@ -1,62 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_User extends FS_Scope_Entity {
14
-
15
- #region Properties
16
-
17
- /**
18
- * @var string
19
- */
20
- public $email;
21
- /**
22
- * @var string
23
- */
24
- public $first;
25
- /**
26
- * @var string
27
- */
28
- public $last;
29
- /**
30
- * @var bool
31
- */
32
- public $is_verified;
33
- /**
34
- * @var string|null
35
- */
36
- public $customer_id;
37
- /**
38
- * @var float
39
- */
40
- public $gross;
41
-
42
- #endregion Properties
43
-
44
- /**
45
- * @param object|bool $user
46
- */
47
- function __construct( $user = false ) {
48
- parent::__construct( $user );
49
- }
50
-
51
- function get_name() {
52
- return trim( ucfirst( trim( is_string( $this->first ) ? $this->first : '' ) ) . ' ' . ucfirst( trim( is_string( $this->last ) ? $this->last : '' ) ) );
53
- }
54
-
55
- function is_verified() {
56
- return ( isset( $this->is_verified ) && true === $this->is_verified );
57
- }
58
-
59
- static function get_type() {
60
- return 'user';
61
- }
62
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/fs-core-functions.php DELETED
@@ -1,461 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- global $fs_core_logger;
14
-
15
- $fs_core_logger = FS_Logger::get_logger( WP_FS__SLUG . '_core', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
16
-
17
- function fs_dummy() {
18
- }
19
-
20
- /* Url.
21
- --------------------------------------------------------------------------------------------*/
22
- function fs_get_url_daily_cache_killer() {
23
- return date( '\YY\Mm\Dd' );
24
- }
25
-
26
- /* Templates / Views.
27
- --------------------------------------------------------------------------------------------*/
28
- function fs_get_template_path( $path ) {
29
- return WP_FS__DIR_TEMPLATES . '/' . trim( $path, '/' );
30
- }
31
-
32
- function fs_include_template( $path, &$params = null ) {
33
- $VARS = &$params;
34
- include( fs_get_template_path( $path ) );
35
- }
36
-
37
- function fs_include_once_template( $path, &$params = null ) {
38
- $VARS = &$params;
39
- include_once( fs_get_template_path( $path ) );
40
- }
41
-
42
- function fs_require_template( $path, &$params = null ) {
43
- $VARS = &$params;
44
- require( fs_get_template_path( $path ) );
45
- }
46
-
47
- function fs_require_once_template( $path, &$params = null ) {
48
- $VARS = &$params;
49
- require_once( fs_get_template_path( $path ) );
50
- }
51
-
52
- function fs_get_template( $path, &$params = null ) {
53
- ob_start();
54
-
55
- $VARS = &$params;
56
- require_once( fs_get_template_path( $path ) );
57
-
58
- return ob_get_clean();
59
- }
60
-
61
- function __fs( $key ) {
62
- global $fs_text;
63
-
64
- if ( ! isset( $fs_text ) ) {
65
- require_once( dirname( __FILE__ ) . '/i18n.php' );
66
- }
67
-
68
- return isset( $fs_text[ $key ] ) ? $fs_text[ $key ] : $key;
69
- }
70
-
71
- function _efs( $key ) {
72
- echo __fs( $key );
73
- }
74
-
75
- /* Scripts and styles including.
76
- --------------------------------------------------------------------------------------------*/
77
- function fs_enqueue_local_style( $handle, $path, $deps = array(), $ver = false, $media = 'all' ) {
78
- global $fs_core_logger;
79
- if ( $fs_core_logger->is_on() ) {
80
- $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
81
- $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_CSS . trim( $path, '/' ) ) );
82
- $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ) );
83
- }
84
-
85
- wp_enqueue_style( $handle, plugins_url( plugin_basename( WP_FS__DIR_CSS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $media );
86
- }
87
-
88
- function fs_enqueue_local_script( $handle, $path, $deps = array(), $ver = false, $in_footer = 'all' ) {
89
- global $fs_core_logger;
90
- if ( $fs_core_logger->is_on() ) {
91
- $fs_core_logger->info( 'handle = ' . $handle . '; path = ' . $path . ';' );
92
- $fs_core_logger->info( 'plugin_basename = ' . plugins_url( WP_FS__DIR_JS . trim( $path, '/' ) ) );
93
- $fs_core_logger->info( 'plugins_url = ' . plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ) );
94
- }
95
-
96
- wp_enqueue_script( $handle, plugins_url( plugin_basename( WP_FS__DIR_JS . '/' . trim( $path, '/' ) ) ), $deps, $ver, $in_footer );
97
- }
98
-
99
- function fs_img_url( $path ) {
100
- return plugins_url( plugin_basename( WP_FS__DIR_IMG . '/' . trim( $path, '/' ) ) );
101
- }
102
-
103
- /* Request handlers.
104
- --------------------------------------------------------------------------------------------*/
105
- /**
106
- * @param string $key
107
- * @param mixed $def
108
- *
109
- * @return mixed
110
- */
111
- function fs_request_get( $key, $def = false ) {
112
- return isset( $_REQUEST[ $key ] ) ? $_REQUEST[ $key ] : $def;
113
- }
114
-
115
- function fs_request_has( $key ) {
116
- return isset( $_REQUEST[ $key ] );
117
- }
118
-
119
- function fs_request_get_bool( $key, $def = false ) {
120
- return ( isset( $_REQUEST[ $key ] ) && ( 1 == $_REQUEST[ $key ] || 'true' === strtolower( $_REQUEST[ $key ] ) ) ) ? true : $def;
121
- }
122
-
123
- function fs_request_is_post() {
124
- return ( 'post' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
125
- }
126
-
127
- function fs_request_is_get() {
128
- return ( 'get' === strtolower( $_SERVER['REQUEST_METHOD'] ) );
129
- }
130
-
131
- function fs_get_action( $action_key = 'action' ) {
132
- if ( ! empty( $_REQUEST[ $action_key ] ) ) {
133
- return strtolower( $_REQUEST[ $action_key ] );
134
- }
135
-
136
- if ( 'action' == $action_key ) {
137
- $action_key = 'fs_action';
138
-
139
- if ( ! empty( $_REQUEST[ $action_key ] ) ) {
140
- return strtolower( $_REQUEST[ $action_key ] );
141
- }
142
- }
143
-
144
- return false;
145
- }
146
-
147
- function fs_request_is_action( $action, $action_key = 'action' ) {
148
- return ( strtolower( $action ) === fs_get_action( $action_key ) );
149
- }
150
-
151
- function fs_is_plugin_page( $menu_slug ) {
152
- return ( is_admin() && $_REQUEST['page'] === $menu_slug );
153
- }
154
-
155
- /**
156
- * Get client IP.
157
- *
158
- * @author Vova Feldman (@svovaf)
159
- * @since 1.1.2
160
- *
161
- * @return string|null
162
- */
163
- function fs_get_ip() {
164
- $fields = array(
165
- 'HTTP_CF_CONNECTING_IP',
166
- 'HTTP_CLIENT_IP',
167
- 'HTTP_X_FORWARDED_FOR',
168
- 'HTTP_X_FORWARDED',
169
- 'HTTP_FORWARDED_FOR',
170
- 'HTTP_FORWARDED',
171
- 'REMOTE_ADDR',
172
- );
173
-
174
- foreach ( $fields as $ip_field ) {
175
- if ( ! empty( $_SERVER[ $ip_field ] ) ) {
176
- return $_SERVER[ $ip_field ];
177
- }
178
- }
179
-
180
- return null;
181
- }
182
-
183
- /* Core UI.
184
- --------------------------------------------------------------------------------------------*/
185
- function fs_ui_action_button( $slug, $page, $action, $title, $params = array(), $is_primary = true ) {
186
- ?><a class="button<?php if ( $is_primary ) {
187
- echo ' button-primary';
188
- } ?>"
189
- 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
190
- }
191
-
192
- function fs_ui_action_link( $slug, $page, $action, $title, $params = array() ) {
193
- ?><a class=""
194
- 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
195
- }
196
-
197
- /* Core Redirect (copied from BuddyPress).
198
- --------------------------------------------------------------------------------------------*/
199
- /**
200
- * Redirects to another page, with a workaround for the IIS Set-Cookie bug.
201
- *
202
- * @link http://support.microsoft.com/kb/q176113/
203
- * @since 1.5.1
204
- * @uses apply_filters() Calls 'wp_redirect' hook on $location and $status.
205
- *
206
- * @param string $location The path to redirect to
207
- * @param int $status Status code to use
208
- *
209
- * @return bool False if $location is not set
210
- */
211
- function fs_redirect( $location, $status = 302 ) {
212
- global $is_IIS;
213
-
214
- if ( headers_sent() ) {
215
- return false;
216
- }
217
-
218
- if ( ! $location ) // allows the wp_redirect filter to cancel a redirect
219
- {
220
- return false;
221
- }
222
-
223
- $location = fs_sanitize_redirect( $location );
224
-
225
- if ( $is_IIS ) {
226
- header( "Refresh: 0;url=$location" );
227
- } else {
228
- if ( php_sapi_name() != 'cgi-fcgi' ) {
229
- status_header( $status );
230
- } // This causes problems on IIS and some FastCGI setups
231
- header( "Location: $location" );
232
- }
233
-
234
- return true;
235
- }
236
-
237
- /**
238
- * Sanitizes a URL for use in a redirect.
239
- *
240
- * @since 2.3
241
- *
242
- * @param string $location
243
- *
244
- * @return string redirect-sanitized URL
245
- */
246
- function fs_sanitize_redirect( $location ) {
247
- $location = preg_replace( '|[^a-z0-9-~+_.?#=&;,/:%!]|i', '', $location );
248
- $location = fs_kses_no_null( $location );
249
-
250
- // remove %0d and %0a from location
251
- $strip = array( '%0d', '%0a' );
252
- $found = true;
253
- while ( $found ) {
254
- $found = false;
255
- foreach ( (array) $strip as $val ) {
256
- while ( strpos( $location, $val ) !== false ) {
257
- $found = true;
258
- $location = str_replace( $val, '', $location );
259
- }
260
- }
261
- }
262
-
263
- return $location;
264
- }
265
-
266
- /**
267
- * Removes any NULL characters in $string.
268
- *
269
- * @since 1.0.0
270
- *
271
- * @param string $string
272
- *
273
- * @return string
274
- */
275
- function fs_kses_no_null( $string ) {
276
- $string = preg_replace( '/\0+/', '', $string );
277
- $string = preg_replace( '/(\\\\0)+/', '', $string );
278
-
279
- return $string;
280
- }
281
-
282
- /*function fs_error_handler($errno, $errstr, $errfile, $errline)
283
- {
284
- if (false === strpos($errfile, 'freemius/'))
285
- {
286
- // @todo Dump Freemius errors to local log.
287
- }
288
-
289
- // switch ($errno) {
290
- // case E_USER_ERROR:
291
- // break;
292
- // case E_WARNING:
293
- // case E_USER_WARNING:
294
- // break;
295
- // case E_NOTICE:
296
- // case E_USER_NOTICE:
297
- // break;
298
- // default:
299
- // break;
300
- // }
301
- }
302
-
303
- set_error_handler('fs_error_handler');*/
304
-
305
- if ( function_exists( 'wp_normalize_path' ) ) {
306
- /**
307
- * Normalize a filesystem path.
308
- *
309
- * Replaces backslashes with forward slashes for Windows systems, and ensures
310
- * no duplicate slashes exist.
311
- *
312
- * @param string $path Path to normalize.
313
- *
314
- * @return string Normalized path.
315
- */
316
- function fs_normalize_path( $path ) {
317
- return wp_normalize_path( $path );
318
- }
319
- } else {
320
- function fs_normalize_path( $path ) {
321
- $path = str_replace( '\\', '/', $path );
322
- $path = preg_replace( '|/+|', '/', $path );
323
-
324
- return $path;
325
- }
326
- }
327
-
328
- function fs_nonce_url( $actionurl, $action = - 1, $name = '_wpnonce' ) {
329
- // $actionurl = str_replace( '&amp;', '&', $actionurl );
330
- return add_query_arg( $name, wp_create_nonce( $action ), $actionurl );
331
- }
332
-
333
- /**
334
- * Check if string starts with.
335
- *
336
- * @author Vova Feldman (@svovaf)
337
- * @since 1.1.3
338
- *
339
- * @param string $haystack
340
- * @param string $needle
341
- *
342
- * @return bool
343
- */
344
- function fs_starts_with( $haystack, $needle ) {
345
- $length = strlen( $needle );
346
-
347
- return ( substr( $haystack, 0, $length ) === $needle );
348
- }
349
-
350
- #region Url Canonization ------------------------------------------------------------------
351
-
352
- /**
353
- * @author Vova Feldman (@svovaf)
354
- * @since 1.1.3
355
- *
356
- * @param string $url
357
- * @param bool $omit_host
358
- * @param array $ignore_params
359
- *
360
- * @return string
361
- */
362
- function fs_canonize_url( $url, $omit_host = false, $ignore_params = array() ) {
363
- $parsed_url = parse_url( strtolower( $url ) );
364
-
365
- // if ( ! isset( $parsed_url['host'] ) ) {
366
- // return $url;
367
- // }
368
-
369
- $canonical = ( ( $omit_host || ! isset( $parsed_url['host'] ) ) ? '' : $parsed_url['host'] ) . $parsed_url['path'];
370
-
371
- if ( isset( $parsed_url['query'] ) ) {
372
- parse_str( $parsed_url['query'], $queryString );
373
- $canonical .= '?' . fs_canonize_query_string( $queryString, $ignore_params );
374
- }
375
-
376
- return $canonical;
377
- }
378
-
379
- /**
380
- * @author Vova Feldman (@svovaf)
381
- * @since 1.1.3
382
- *
383
- * @param array $params
384
- * @param array $ignore_params
385
- * @param bool $params_prefix
386
- *
387
- * @return string
388
- */
389
- function fs_canonize_query_string( array $params, array &$ignore_params, $params_prefix = false ) {
390
- if ( ! is_array( $params ) || 0 === count( $params ) ) {
391
- return '';
392
- }
393
-
394
- // Urlencode both keys and values
395
- $keys = fs_urlencode_rfc3986( array_keys( $params ) );
396
- $values = fs_urlencode_rfc3986( array_values( $params ) );
397
- $params = array_combine( $keys, $values );
398
-
399
- // Parameters are sorted by name, using lexicographical byte value ordering.
400
- // Ref: Spec: 9.1.1 (1)
401
- uksort( $params, 'strcmp' );
402
-
403
- $pairs = array();
404
- foreach ( $params as $parameter => $value ) {
405
- $lower_param = strtolower( $parameter );
406
-
407
- // Skip ignore params.
408
- if ( in_array( $lower_param, $ignore_params ) || ( false !== $params_prefix && startsWith( $lower_param, $params_prefix ) ) ) {
409
- continue;
410
- }
411
-
412
- if ( is_array( $value ) ) {
413
- // If two or more parameters share the same name, they are sorted by their value
414
- // Ref: Spec: 9.1.1 (1)
415
- natsort( $value );
416
- foreach ( $value as $duplicate_value ) {
417
- $pairs[] = $lower_param . '=' . $duplicate_value;
418
- }
419
- } else {
420
- $pairs[] = $lower_param . '=' . $value;
421
- }
422
- }
423
-
424
- if ( 0 === count( $pairs ) ) {
425
- return '';
426
- }
427
-
428
- return implode( "&", $pairs );
429
- }
430
-
431
- /**
432
- * @author Vova Feldman (@svovaf)
433
- * @since 1.1.3
434
- *
435
- * @param string|string[] $input
436
- *
437
- * @return array|mixed|string
438
- */
439
- function fs_urlencode_rfc3986( $input ) {
440
- if ( is_array( $input ) ) {
441
- return array_map( 'fs_urlencode_rfc3986', $input );
442
- } else if ( is_scalar( $input ) ) {
443
- return str_replace( '+', ' ', str_replace( '%7E', '~', rawurlencode( $input ) ) );
444
- }
445
-
446
- return '';
447
- }
448
-
449
- #endregion Url Canonization ------------------------------------------------------------------
450
-
451
- function fs_download_image( $from, $to ) {
452
- $ch = curl_init( $from );
453
- $fp = fopen( fs_normalize_path( $to ), 'wb' );
454
- curl_setopt( $ch, CURLOPT_FILE, $fp );
455
- curl_setopt( $ch, CURLOPT_HEADER, 0 );
456
- curl_exec( $ch );
457
- curl_close( $ch );
458
- fclose( $fp );
459
- }
460
-
461
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/fs-plugin-functions.php DELETED
@@ -1,411 +0,0 @@
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
- * Display plugin information in dialog box form.
15
- *
16
- * @since 2.7.0
17
- */
18
- function fs_install_plugin_information() {
19
- global $tab;
20
-
21
- if ( empty( $_REQUEST['plugin'] ) ) {
22
- return;
23
- }
24
-
25
- $args = array(
26
- 'slug' => wp_unslash( $_REQUEST['plugin'] ),
27
- 'is_ssl' => is_ssl(),
28
- 'fields' => array( 'banners' => true, 'reviews' => true )
29
- );
30
-
31
- if ( is_array( $args ) ) {
32
- $args = (object) $args;
33
- }
34
-
35
- if ( ! isset( $args->per_page ) ) {
36
- $args->per_page = 24;
37
- }
38
-
39
- if ( ! isset( $args->locale ) ) {
40
- $args->locale = get_locale();
41
- }
42
-
43
- $api = apply_filters( 'fs_plugins_api', false, 'plugin_information', $args );
44
-
45
- if ( is_wp_error( $api ) ) {
46
- wp_die( $api );
47
- }
48
-
49
- $plugins_allowedtags = array(
50
- 'a' => array(
51
- 'href' => array(),
52
- 'title' => array(),
53
- 'target' => array(),
54
- // Add image style for screenshots.
55
- 'class' => array()
56
- ),
57
- 'style' => array(),
58
- 'abbr' => array( 'title' => array() ),
59
- 'acronym' => array( 'title' => array() ),
60
- 'code' => array(),
61
- 'pre' => array(),
62
- 'em' => array(),
63
- 'strong' => array(),
64
- 'div' => array( 'class' => array() ),
65
- 'span' => array( 'class' => array() ),
66
- 'p' => array(),
67
- 'ul' => array(),
68
- 'ol' => array(),
69
- 'li' => array( 'class' => array() ),
70
- 'i' => array( 'class' => array() ),
71
- 'h1' => array(),
72
- 'h2' => array(),
73
- 'h3' => array(),
74
- 'h4' => array(),
75
- 'h5' => array(),
76
- 'h6' => array(),
77
- 'img' => array( 'src' => array(), 'class' => array(), 'alt' => array() ),
78
- // 'table' => array(),
79
- // 'td' => array(),
80
- // 'tr' => array(),
81
- // 'th' => array(),
82
- // 'thead' => array(),
83
- // 'tbody' => array(),
84
- );
85
-
86
- $plugins_section_titles = array(
87
- 'description' => _x( 'Description', 'Plugin installer section title' ),
88
- 'installation' => _x( 'Installation', 'Plugin installer section title' ),
89
- 'faq' => _x( 'FAQ', 'Plugin installer section title' ),
90
- 'screenshots' => _x( 'Screenshots', 'Plugin installer section title' ),
91
- 'changelog' => _x( 'Changelog', 'Plugin installer section title' ),
92
- 'reviews' => _x( 'Reviews', 'Plugin installer section title' ),
93
- 'other_notes' => _x( 'Other Notes', 'Plugin installer section title' ),
94
- 'features' => __fs( 'features-and-pricing' ),
95
- );
96
-
97
- // Sanitize HTML
98
- // foreach ( (array) $api->sections as $section_name => $content ) {
99
- // $api->sections[$section_name] = wp_kses( $content, $plugins_allowedtags );
100
- // }
101
-
102
- foreach ( array( 'version', 'author', 'requires', 'tested', 'homepage', 'downloaded', 'slug' ) as $key ) {
103
- if ( isset( $api->$key ) ) {
104
- $api->$key = wp_kses( $api->$key, $plugins_allowedtags );
105
- }
106
- }
107
-
108
- $_tab = esc_attr( $tab );
109
-
110
- $section = isset( $_REQUEST['section'] ) ? wp_unslash( $_REQUEST['section'] ) : 'description'; // Default to the Description tab, Do not translate, API returns English.
111
- if ( empty( $section ) || ! isset( $api->sections[ $section ] ) ) {
112
- $section_titles = array_keys( (array) $api->sections );
113
- $section = array_shift( $section_titles );
114
- }
115
-
116
- iframe_header( __( 'Plugin Install' ) );
117
-
118
- $_with_banner = '';
119
-
120
- // var_dump($api->banners);
121
- if ( ! empty( $api->banners ) && ( ! empty( $api->banners['low'] ) || ! empty( $api->banners['high'] ) ) ) {
122
- $_with_banner = 'with-banner';
123
- $low = empty( $api->banners['low'] ) ? $api->banners['high'] : $api->banners['low'];
124
- $high = empty( $api->banners['high'] ) ? $api->banners['low'] : $api->banners['high'];
125
- ?>
126
- <style type="text/css">
127
- #plugin-information-title.with-banner
128
- {
129
- background-image: url( <?php echo esc_url( $low ); ?> );
130
- }
131
-
132
- @media only screen and ( -webkit-min-device-pixel-ratio: 1.5 )
133
- {
134
- #plugin-information-title.with-banner
135
- {
136
- background-image: url( <?php echo esc_url( $high ); ?> );
137
- }
138
- }
139
- </style>
140
- <?php
141
- }
142
-
143
- echo '<div id="plugin-information-scrollable">';
144
- echo "<div id='{$_tab}-title' class='{$_with_banner}'><div class='vignette'></div><h2>{$api->name}</h2></div>";
145
- echo "<div id='{$_tab}-tabs' class='{$_with_banner}'>\n";
146
-
147
- foreach ( (array) $api->sections as $section_name => $content ) {
148
- if ( 'reviews' === $section_name && ( empty( $api->ratings ) || 0 === array_sum( (array) $api->ratings ) ) ) {
149
- continue;
150
- }
151
-
152
- if ( isset( $plugins_section_titles[ $section_name ] ) ) {
153
- $title = $plugins_section_titles[ $section_name ];
154
- } else {
155
- $title = ucwords( str_replace( '_', ' ', $section_name ) );
156
- }
157
-
158
- $class = ( $section_name === $section ) ? ' class="current"' : '';
159
- $href = add_query_arg( array( 'tab' => $tab, 'section' => $section_name ) );
160
- $href = esc_url( $href );
161
- $san_section = esc_attr( $section_name );
162
- echo "\t<a name='$san_section' href='$href' $class>$title</a>\n";
163
- }
164
-
165
- echo "</div>\n";
166
-
167
- ?>
168
- <div id="<?php echo $_tab; ?>-content" class='<?php echo $_with_banner; ?>'>
169
- <div class="fyi">
170
- <?php if ( isset( $api->plans ) ) : ?>
171
- <div class="plugin-information-pricing">
172
- <?php foreach ($api->plans as $plan) : ?>
173
- <h3 data-plan="<?php echo $plan->id ?>"><?php printf( __fs( 'x-plan' ), $plan->title ) ?></h3>
174
- <ul>
175
- <?php $billing_cycle = 'annual' ?>
176
- <?php if ( 1 === count( $plan->pricing ) && 1 == $plan->pricing[0]->licenses ) : ?>
177
- <?php $pricing = $plan->pricing[0] ?>
178
- <li><label><?php _efs( 'price' ) ?>: $<?php
179
- if ( isset( $pricing->annual_price ) ) {
180
- echo $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
181
- $billing_cycle = 'annual';
182
- } else if ( isset( $pricing->monthly_price ) ) {
183
- echo $pricing->monthly_price . ' / mo';
184
- $billing_cycle = 'monthly';
185
- } else if ( isset( $pricing->lifetime_price ) ) {
186
- echo $pricing->lifetime_price;
187
- $billing_cycle = 'lifetime';
188
- }
189
- ?></label></li>
190
- <?php else : ?>
191
- <?php $first = true;
192
- foreach ( $plan->pricing as $pricing ) : ?>
193
- <li><label><input name="pricing-<?php echo $plan->id ?>" type="radio"
194
- value="<?php echo $pricing->id ?>"<?php checked( $first, true ) ?>><?php
195
- switch ( $pricing->licenses ) {
196
- case '1':
197
- _efs( 'license-single-site' );
198
- break;
199
- case null:
200
- _efs( 'license-unlimited' );
201
- break;
202
- default:
203
- printf( __fs( 'license-x-sites' ), $pricing->licenses );
204
- break;
205
- }
206
- ?> - $<?php
207
- if ( isset( $pricing->annual_price ) ) {
208
- echo $pricing->annual_price . ( $plan->is_block_features ? ' / year' : '' );
209
- $billing_cycle = 'annual';
210
- } else if ( isset( $pricing->monthly_price ) ) {
211
- echo $pricing->monthly_price . ' / mo';
212
- $billing_cycle = 'monthly';
213
- } else if ( isset( $pricing->lifetime_price ) ) {
214
- echo $pricing->lifetime_price;
215
- $billing_cycle = 'lifetime';
216
- }
217
- ?></label></li>
218
- <?php $first = false; endforeach ?>
219
- <?php endif ?>
220
- </ul>
221
- <?php echo ' <a class="button button-primary right" href="' . esc_url( add_query_arg( array(
222
- 'plugin_id' => $plan->plugin_id,
223
- 'plan_id' => $plan->id,
224
- 'pricing_id' => $plan->pricing[0]->id,
225
- 'billing_cycle' => $billing_cycle,
226
- ), $api->checkout_link ) ) . '" target="_parent">' . __fs( 'purchase' ) . '</a>' ?>
227
- </div>
228
- <?php endforeach ?>
229
- <?php wp_enqueue_script( 'jquery' ); ?>
230
- <script type="text/javascript">
231
- (function ($) {
232
- $('.plugin-information-pricing input[type=radio]').click(function () {
233
- var checkout_url = '<?php echo esc_url_raw(add_query_arg(array(
234
- 'plugin_id' => $plan->plugin_id,
235
- 'billing_cycle' => $billing_cycle,
236
- ), $api->checkout_link)) ?>&plan_id=' +
237
- $(this).parents('.plugin-information-pricing').find('h3').attr('data-plan') +
238
- '&pricing_id=' + $(this).val();
239
-
240
- $('.plugin-information-pricing .button, #plugin-information-footer .button').attr('href', checkout_url);
241
- });
242
- })(jQuery);
243
- </script>
244
- <?php endif ?>
245
- <div>
246
- <h3><?php _efs( 'details' ) ?></h3>
247
- <ul>
248
- <?php if ( ! empty( $api->version ) ) { ?>
249
- <li><strong><?php _e( 'Version:' ); ?></strong> <?php echo $api->version; ?></li>
250
- <?php }
251
- if ( ! empty( $api->author ) ) { ?>
252
- <li>
253
- <strong><?php _e( 'Author:' ); ?></strong> <?php echo links_add_target( $api->author, '_blank' ); ?>
254
- </li>
255
- <?php }
256
- if ( ! empty( $api->last_updated ) ) { ?>
257
- <li><strong><?php _e( 'Last Updated:' ); ?></strong> <span
258
- title="<?php echo $api->last_updated; ?>">
259
- <?php printf( __( '%s ago' ), human_time_diff( strtotime( $api->last_updated ) ) ); ?>
260
- </span></li>
261
- <?php }
262
- if ( ! empty( $api->requires ) ) { ?>
263
- <li>
264
- <strong><?php _e( 'Requires WordPress Version:' ); ?></strong> <?php printf( __( '%s or higher' ), $api->requires ); ?>
265
- </li>
266
- <?php }
267
- if ( ! empty( $api->tested ) ) { ?>
268
- <li><strong><?php _e( 'Compatible up to:' ); ?></strong> <?php echo $api->tested; ?></li>
269
- <?php }
270
- if ( ! empty( $api->downloaded ) ) { ?>
271
- <li>
272
- <strong><?php _e( 'Downloaded:' ); ?></strong> <?php printf( _n( '%s time', '%s times', $api->downloaded ), number_format_i18n( $api->downloaded ) ); ?>
273
- </li>
274
- <?php }
275
- if ( ! empty( $api->slug ) && empty( $api->external ) ) { ?>
276
- <li><a target="_blank"
277
- href="https://wordpress.org/plugins/<?php echo $api->slug; ?>/"><?php _e( 'WordPress.org Plugin Page &#187;' ); ?></a>
278
- </li>
279
- <?php }
280
- if ( ! empty( $api->homepage ) ) { ?>
281
- <li><a target="_blank"
282
- href="<?php echo esc_url( $api->homepage ); ?>"><?php _e( 'Plugin Homepage &#187;' ); ?></a>
283
- </li>
284
- <?php }
285
- if ( ! empty( $api->donate_link ) && empty( $api->contributors ) ) { ?>
286
- <li><a target="_blank"
287
- href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
288
- </li>
289
- <?php } ?>
290
- </ul>
291
- </div>
292
- <?php if ( ! empty( $api->rating ) ) { ?>
293
- <h3><?php _e( 'Average Rating' ); ?></h3>
294
- <?php wp_star_rating( array(
295
- 'rating' => $api->rating,
296
- 'type' => 'percent',
297
- 'number' => $api->num_ratings
298
- ) ); ?>
299
- <small><?php printf( _n( '(based on %s rating)', '(based on %s ratings)', $api->num_ratings ), number_format_i18n( $api->num_ratings ) ); ?></small>
300
- <?php
301
- }
302
-
303
- if ( ! empty( $api->ratings ) && array_sum( (array) $api->ratings ) > 0 ) {
304
- foreach ( $api->ratings as $key => $ratecount ) {
305
- // Avoid div-by-zero.
306
- $_rating = $api->num_ratings ? ( $ratecount / $api->num_ratings ) : 0;
307
- ?>
308
- <div class="counter-container">
309
- <span class="counter-label"><a
310
- href="https://wordpress.org/support/view/plugin-reviews/<?php echo $api->slug; ?>?filter=<?php echo $key; ?>"
311
- target="_blank"
312
- title="<?php echo esc_attr( sprintf( _n( 'Click to see reviews that provided a rating of %d star', 'Click to see reviews that provided a rating of %d stars', $key ), $key ) ); ?>"><?php printf( _n( '%d star', '%d stars', $key ), $key ); ?></a></span>
313
- <span class="counter-back">
314
- <span class="counter-bar" style="width: <?php echo 92 * $_rating; ?>px;"></span>
315
- </span>
316
- <span class="counter-count"><?php echo number_format_i18n( $ratecount ); ?></span>
317
- </div>
318
- <?php
319
- }
320
- }
321
- if ( ! empty( $api->contributors ) ) {
322
- ?>
323
- <h3><?php _e( 'Contributors' ); ?></h3>
324
- <ul class="contributors">
325
- <?php
326
- foreach ( (array) $api->contributors as $contrib_username => $contrib_profile ) {
327
- if ( empty( $contrib_username ) && empty( $contrib_profile ) ) {
328
- continue;
329
- }
330
- if ( empty( $contrib_username ) ) {
331
- $contrib_username = preg_replace( '/^.+\/(.+)\/?$/', '\1', $contrib_profile );
332
- }
333
- $contrib_username = sanitize_user( $contrib_username );
334
- if ( empty( $contrib_profile ) ) {
335
- echo "<li><img src='https://wordpress.org/grav-redirect.php?user={$contrib_username}&amp;s=36' width='18' height='18' />{$contrib_username}</li>";
336
- } else {
337
- 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>";
338
- }
339
- }
340
- ?>
341
- </ul>
342
- <?php if ( ! empty( $api->donate_link ) ) { ?>
343
- <a target="_blank"
344
- href="<?php echo esc_url( $api->donate_link ); ?>"><?php _e( 'Donate to this plugin &#187;' ); ?></a>
345
- <?php } ?>
346
- <?php } ?>
347
- </div>
348
- <div id="section-holder" class="wrap">
349
- <?php
350
- if ( ! empty( $api->tested ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->tested ) ), $api->tested, '>' ) ) {
351
- echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been tested with your current version of WordPress.' ) . '</p></div>';
352
- } else if ( ! empty( $api->requires ) && version_compare( substr( $GLOBALS['wp_version'], 0, strlen( $api->requires ) ), $api->requires, '<' ) ) {
353
- echo '<div class="notice notice-warning"><p>' . '<strong>' . __( 'Warning:' ) . '</strong> ' . __( 'This plugin has not been marked as compatible with your version of WordPress.' ) . '</p></div>';
354
- }
355
-
356
- foreach ( (array) $api->sections as $section_name => $content ) {
357
- $content = links_add_base_url( $content, 'https://wordpress.org/plugins/' . $api->slug . '/' );
358
- $content = links_add_target( $content, '_blank' );
359
-
360
- $san_section = esc_attr( $section_name );
361
-
362
- $display = ( $section_name === $section ) ? 'block' : 'none';
363
-
364
- echo "\t<div id='section-{$san_section}' class='section' style='display: {$display};'>\n";
365
- echo $content;
366
- echo "\t</div>\n";
367
- }
368
- echo "</div>\n";
369
- echo "</div>\n";
370
- echo "</div>\n"; // #plugin-information-scrollable
371
- echo "<div id='$tab-footer'>\n";
372
- if ( ( current_user_can( 'install_plugins' ) || current_user_can( 'update_plugins' ) ) ) {
373
-
374
- if ( ! empty( $api->checkout_link ) && isset( $api->plans ) && 0 < is_array( $api->plans ) ) {
375
- echo ' <a class="button button-primary right" href="' . esc_url( add_query_arg( array(
376
- 'plugin_id' => $plan->plugin_id,
377
- 'plan_id' => $plan->id,
378
- 'pricing_id' => $plan->pricing[0]->id,
379
- 'billing_cycle' => $billing_cycle,
380
- ), $api->checkout_link ) ) . '" target="_parent">' . __fs( 'purchase' ) . '</a>';
381
-
382
- // @todo Add Cart concept.
383
- // echo ' <a class="button right" href="' . $status['url'] . '" target="_parent">' . __( 'Add to Cart' ) . '</a>';
384
-
385
- } else if ( ! empty( $api->download_link ) ) {
386
- $status = install_plugin_install_status( $api );
387
- switch ( $status['status'] ) {
388
- case 'install':
389
- if ( $status['url'] ) {
390
- echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Now' ) . '</a>';
391
- }
392
- break;
393
- case 'update_available':
394
- if ( $status['url'] ) {
395
- echo '<a class="button button-primary right" href="' . $status['url'] . '" target="_parent">' . __( 'Install Update Now' ) . '</a>';
396
- }
397
- break;
398
- case 'newer_installed':
399
- echo '<a class="button button-primary right disabled">' . sprintf( __( 'Newer Version (%s) Installed' ), $status['version'] ) . '</a>';
400
- break;
401
- case 'latest_installed':
402
- echo '<a class="button button-primary right disabled">' . __( 'Latest Version Installed' ) . '</a>';
403
- break;
404
- }
405
- }
406
- }
407
- echo "</div>\n";
408
-
409
- iframe_footer();
410
- exit;
411
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/i18n.php DELETED
@@ -1,245 +0,0 @@
1
- <?php
2
- global $fs_text;
3
-
4
- $fs_text = array(
5
- 'account' => __( 'Account', 'freemius' ),
6
- 'addon' => __( 'Add On', 'freemius' ),
7
- 'contact-us' => __( 'Contact Us', 'freemius' ),
8
- 'change-ownership' => __( 'Change Ownership', 'freemius' ),
9
- 'support' => __( 'Support', 'freemius' ),
10
- 'support-forum' => __( 'Support Forum', 'freemius' ),
11
- 'add-ons' => __( 'Add Ons', 'freemius' ),
12
- 'upgrade' => _x( 'Upgrade', 'verb', 'freemius' ),
13
- 'awesome' => __( 'Awesome', 'freemius' ),
14
- 'pricing' => __( 'Pricing', 'noun', 'freemius' ),
15
- 'price' => _x( 'Price', 'noun', 'freemius' ),
16
- 'unlimited-updates' => __( 'Unlimited Updates', 'freemius' ),
17
- 'downgrade' => _x( 'Downgrade', 'verb', 'freemius' ),
18
- 'free-trial' => __( 'Free Trial', 'freemius' ),
19
- 'details' => __( 'Details', 'freemius' ),
20
- 'account-details' => __( 'Account Details', 'freemius' ),
21
- 'delete' => _x( 'Delete', 'verb', 'freemius' ),
22
- 'delete-account' => __( 'Delete Account', 'freemius' ),
23
- 'dismiss' => __( 'Dismiss', 'as close a window', 'freemius' ),
24
- 'plan' => _x( 'Plan', 'as product pricing plan', 'freemius' ),
25
- 'change-plan' => __( 'Change Plan', 'freemius' ),
26
- 'download-x-version' => _x( 'Download %s Version', 'as download professional version', 'freemius' ),
27
- 'download-x-version-now' => _x( 'Download %s version now', 'as download professional version now', 'freemius' ),
28
- 'download-latest' => _x( 'Download Latest', 'as download latest version', 'freemius' ),
29
- 'you-have-x-license' => _x( 'You have a %s license.', 'E.g. you have a professional license.', 'freemius' ),
30
- 'new' => __( 'New', 'freemius' ),
31
- 'free' => __( 'Free', 'freemius' ),
32
- 'trial' => _x( 'Trial', 'as trial plan', 'freemius' ),
33
- 'purchase' => _x( 'Purchase', 'verb', 'freemius' ),
34
- 'license-single-site' => __( 'Single Site License', 'freemius' ),
35
- 'license-unlimited' => __( 'Unlimited Licenses', 'freemius' ),
36
- 'license-x-sites' => __( 'Up to %s Sites', 'freemius' ),
37
- 'x-plan' => _x( '%s Plan', 'e.g. Professional Plan', 'freemius' ),
38
- 'you-are-step-away' => __( 'You are just one step away - %s', 'freemius' ),
39
- 'activate-x-now' => _x( 'Activate "%s" Now', '%s - plugin name. As activate "Jetpack" now', 'freemius' ),
40
- 'error' => __( 'Error', 'freemius' ),
41
- 'failed-finding-main-path' => __( 'Freemius SDK couldn\'t find the plugin\'s main file. Please contact sdk@freemius.com with the current error.', 'freemius' ),
42
- #region Account
43
-
44
- 'expiration' => _x( 'Expiration', 'as expiration date', 'freemius' ),
45
- 'not-verified' => __( 'not verified', 'freemius' ),
46
- 'verify-email' => __( 'Verify Email', 'freemius' ),
47
- 'expires-in' => _x( 'Expires in %s', 'e.g. expires in 2 months', 'freemius' ),
48
- 'renews-in' => _x( 'Auto renews in %s', 'e.g. auto renews in 2 months', 'freemius' ),
49
- 'no-expiration' => __( 'No expiration', 'freemius' ),
50
- 'expired' => __( 'Expired', 'freemius' ),
51
- 'in-x' => __( 'In %s', 'freemius' ),
52
- 'version' => _x( 'Version', 'as plugin version', 'freemius' ),
53
- 'name' => __( 'Name', 'freemius' ),
54
- 'email' => __( 'Email', 'freemius' ),
55
- 'verified' => __( 'Verified', 'freemius' ),
56
- 'plugin' => __( 'Plugin', 'freemius' ),
57
- 'title' => __( 'Title', 'freemius' ),
58
- 'slug' => _x( 'Slug', 'as WP plugin slug', 'freemius' ),
59
- 'id' => __( 'ID', 'freemius' ),
60
- 'users' => __( 'Users', 'freemius' ),
61
- 'plugin-installs' => __( 'Plugin Installs', 'freemius' ),
62
- 'sites' => _x( 'Sites', 'like websites', 'freemius' ),
63
- 'user-id' => __( 'User ID', 'freemius' ),
64
- 'site-id' => __( 'Site ID', 'freemius' ),
65
- 'public-key' => __( 'Public Key', 'freemius' ),
66
- 'secret-key' => __( 'Secret Key', 'freemius' ),
67
- 'no-secret' => _x( 'No Secret', 'as secret encryption key missing', 'freemius' ),
68
- 'no-id' => __( 'No ID', 'freemius' ),
69
- 'sync-license' => _x( 'Sync License', 'as synchronize license', 'freemius' ),
70
- 'deactivate-license' => __( 'Deactivate License', 'freemius' ),
71
- 'activate' => __( 'Activate', 'freemius' ),
72
- 'deactivate' => __( 'Deactivate', 'freemius' ),
73
- 'active' => _x( 'Active', 'active mode', 'freemius' ),
74
- 'install-now' => __( 'Install Now', 'freemius' ),
75
- 'install-update-now' => __( 'Install Update Now', 'freemius' ),
76
- 'more-information-about-x' => __( 'More information about %s', 'freemius' ),
77
- 'localhost' => __( 'Localhost', 'freemius' ),
78
- 'activate-x-plan' => _x( 'Activate %s Plan', 'as activate Professional plan', 'freemius' ),
79
- 'what-is-your-x' => __( 'What is your %s?', 'freemius' ),
80
- 'activate-this-addon' => __( 'Activate this add-on', 'freemius' ),
81
- 'deactivate-license-confirm' => __( 'Deactivating your license will block all premium features, but will enable you to activate the license on another site. Are you sure you want to proceed?', 'freemius' ),
82
- 'delete-account-x-confirm' => __( 'Deleting the account will automatically deactivate your %s plan license so you can use it on other sites. If you want to terminate the recurring payments as well, click the "Cancel" button, and first "Downgrade" your account. Are you sure you would like to continue with the deletion?', 'freemius' ),
83
- 'delete-account-confirm' => __( 'Deletion is not temporary. Only delete if you no longer want to use this plugin anymore. Are you sure you would like to continue with the deletion?', 'freemius' ),
84
- 'downgrade-x-confirm' => __( 'Downgrading your plan will immediately stop all future recurring payments and your %s plan license will expire in %s.', 'freemius' ),
85
- 'after-downgrade-non-blocking' => __( 'You can still enjoy all %s features but you will not have access to plugin updates and support.', 'freemius' ),
86
- 'after-downgrade-blocking' => __( 'Once your license expire you can still use the Free version but you will NOT have access to the %s features.', 'freemius' ),
87
- 'proceed-confirmation' => __( 'Are you sure you want to proceed?', 'freemius' ),
88
- #endregion Account
89
-
90
- 'add-ons-for-x' => __( 'Add Ons for %s', 'freemius' ),
91
- #region Plugin Deactivation
92
- 'deactivation-share-reason' => __( 'If you have a moment, please let us know why you are deactivating', 'freemius' ),
93
- 'deactivation-modal-button-deactivate' => __( 'Deactivate', 'freemius' ),
94
- 'deactivation-modal-button-confirm' => __( 'Yes - Deactivate', 'freemius' ),
95
- 'deactivation-modal-button-submit' => __( 'Submit & Deactivate', 'freemius' ),
96
- 'deactivation-modal-button-cancel' => _x( 'Cancel', 'the text of the cancel button of the plugin deactivation dialog box.', 'freemius' ),
97
- 'reason-no-longer-needed' => __( 'I no longer need the plugin', 'freemius' ),
98
- 'reason-found-a-better-plugin' => __( 'I found a better plugin', 'freemius' ),
99
- 'reason-needed-for-a-short-period' => __( 'I only needed the plugin for a short period', 'freemius' ),
100
- 'reason-broke-my-site' => __( 'The plugin broke my site', 'freemius' ),
101
- 'reason-suddenly-stopped-working' => __( 'The plugin suddenly stopped working', 'freemius' ),
102
- 'reason-cant-pay-anymore' => __( "I can't pay for it anymore", 'freemius' ),
103
- 'reason-other' => _x( 'Other', 'the text of the "other" reason for deactivating the plugin that is shown in the modal box.', 'freemius' ),
104
- 'placeholder-plugin-name' => __( "What's the plugin's name?", 'freemius' ),
105
- 'placeholder-comfortable-price' => __( 'What price would you feel comfortable paying?', 'freemius' ),
106
- 'reason-couldnt-make-it-work' => __( "I couldn't understand how to make it work", 'freemius' ),
107
- 'reason-great-but-need-specific-feature' => __( "The plugin is great, but I need specific feature that you don't support", 'freemius' ),
108
- 'reason-not-working' => __( 'The plugin is not working', 'freemius' ),
109
- 'reason-not-what-i-was-looking-for' => __( "It's not what I was looking for", 'freemius' ),
110
- 'reason-didnt-work-as-expected' => __( "The plugin didn't work as expected", 'freemius' ),
111
- 'placeholder-feature' => __( 'What feature?', 'freemius' ),
112
- 'placeholder-share-what-didnt-work' => __( "Kindly share what didn't work so we can fix it for future users...", 'freemius' ),
113
- 'placeholder-what-youve-been-looking-for' => __( "What you've been looking for?", 'freemius' ),
114
- 'placeholder-what-did-you-expect' => __( "What did you expect?", 'freemius' ),
115
- 'reason-didnt-work' => __( "The plugin didn't work", 'freemius' ),
116
- 'reason-dont-like-to-share-my-information' => __( "I don't like to share my information with you", 'freemius' ),
117
- #endregion Plugin Deactivation
118
-
119
- #region Connect
120
- 'hey-x' => _x( 'Hey %s,', 'greeting', 'freemius' ),
121
- 'thanks-x' => _x( 'Thanks %s!', 'a greeting. E.g. Thanks John!', 'freemius' ),
122
- 'connect-message' => __( 'In order to enjoy all our features and functionality, %s needs to connect your user, %s at %s, to %s', 'freemius' ),
123
- 'pending-activation-message' => __( 'You should receive an activation email for %s to your mailbox at %s. Please make sure you click the activation button in that email to complete the install.', 'freemius' ),
124
- 'what-permissions' => __( 'What permissions are being granted?', 'freemius' ),
125
- 'permissions-profile' => __( 'Your Profile Overview', 'freemius' ),
126
- 'permissions-profile_desc' => __( 'Name and email address', 'freemius' ),
127
- 'permissions-site' => __( 'Your Site Overview', 'freemius' ),
128
- 'permissions-site_desc' => __( 'Site address and WordPress version', 'freemius' ),
129
- 'permissions-events' => __( 'Current Plugin Events', 'freemius' ),
130
- 'permissions-events_desc' => __( 'Activation, deactivation and uninstall', 'freemius' ),
131
- 'privacy-policy' => __( 'Privacy Policy', 'freemius' ),
132
- 'tos' => __( 'Terms of Service', 'freemius' ),
133
- 'activating' => _x( 'Activating', 'as activating plugin', 'freemius' ),
134
- 'opt-in-connect' => _x( 'Allow & Continue', 'button label', 'freemius' ),
135
- 'skip' => _x( 'Skip', 'verb', 'freemius' ),
136
- 'resend-activation-email' => __( 'Re-send activation email', 'freemius' ),
137
- #endregion Connect
138
-
139
- #region Screenshots
140
- 'screenshots' => __( 'Screenshots', 'freemius' ),
141
- 'view-full-size-x' => __( 'Click to view full-size screenshot %d', 'freemius' ),
142
- #endregion Screenshots
143
-
144
- #region Debug
145
- 'addons-of-x' => __( 'Add Ons of Plugin %s', 'freemius' ),
146
- 'delete-all-confirm' => __( 'Are you sure you want to delete the all Freemius data?', 'freemius' ),
147
- 'delete-all-accounts' => __( 'Delete All Accounts', 'freemius' ),
148
- #endregion Debug
149
-
150
- #region Expressions
151
- 'congrats' => _x( 'Congrats', 'as congratulations', 'freemius' ),
152
- 'oops' => _x( 'Oops', 'exclamation', 'freemius' ),
153
- 'yee-haw' => _x( 'Yee-haw', 'interjection expressing joy or exuberance', 'freemius' ),
154
- 'woot' => _x( 'W00t', '(especially in electronic communication) used to express elation, enthusiasm, or triumph.', 'freemius' ),
155
- 'right-on' => _x( 'Right on', 'a positive response', 'freemius' ),
156
- 'hmm' => _x( 'Hmm', 'something somebody says when they are thinking about what you have just said. ', 'freemius' ),
157
- 'ok' => __( 'O.K', 'freemius' ),
158
- 'hey' => _x( 'Hey', 'exclamation', 'freemius' ),
159
- 'heads-up' => _x( 'Heads up', 'advance notice of something that will need attention.', 'freemius' ),
160
- #endregion Expressions
161
-
162
- #region Admin Notices
163
- 'you-have-latest' => __( 'Seems like you got the latest release.', 'freemius' ),
164
- 'you-are-good' => __( 'You are all good!', 'freemius' ),
165
- 'user-exist-message' => __( 'Sorry, we could not complete the email update. Another user with the same email is already registered.', 'freemius' ),
166
- 'user-exist-message_ownership' => __( 'If you would like to give up the ownership of the plugin\'s account to %s click the Change Ownership button.', 'freemius' ),
167
- 'email-updated-message' => __( 'Your email was successfully updated. You should receive an email with confirmation instructions in few moments.', 'freemius' ),
168
- 'name-updated-message' => __( 'Your name was successfully updated.', 'freemius' ),
169
- 'x-updated' => __( 'You have successfully updated your %s.', 'freemius' ),
170
- 'name-update-failed-message' => __( 'Please provide your full name.', 'freemius' ),
171
- 'verification-email-sent-message' => __( 'Verification mail was just sent to %s. If you can\'t find it after 5 min, please check your spam box.', 'freemius' ),
172
- 'addons-info-external-message' => __( 'Just letting you know that the add-ons information of %s is being pulled from external server.', 'freemius' ),
173
- 'no-cc-required' => __( 'No credit card required', 'freemius' ),
174
- 'premium-activated-message' => __( 'Premium plugin version was successfully activated.', 'freemius' ),
175
- 'successful-version-upgrade-message' => __( 'The upgrade of %s was successfully completed.', 'freemius' ),
176
- 'activation-with-plan-x-message' => __( 'Your account was successfully activated with the %s plan.', 'freemius' ),
177
- 'download-latest-x-version' => __( 'Download the latest %s version now', 'freemius' ),
178
- 'download-latest-version' => __( 'Download the latest version now', 'freemius' ),
179
- 'addon-successfully-purchased-message' => _x( '%s Add-on was successfully purchased.', '%s - product name, e.g. Facebook add-on was successfully...', 'freemius' ),
180
- 'addon-successfully-upgraded-message' => __( 'Your %s Add-on plan was successfully upgraded.', 'freemius' ),
181
- 'email-verified-message' => __( 'Your email has been successfully verified - you are AWESOME!', 'freemius' ),
182
- 'plan-upgraded-message' => __( 'Your plan was successfully upgraded.', 'freemius' ),
183
- 'plan-changed-to-x-message' => __( 'Your plan was successfully changed to %s.', 'freemius' ),
184
- 'license-expired-blocking-message' => __( 'Your license has expired. You can still continue using the free plugin forever.', 'freemius' ),
185
- 'trial-started-message' => __( 'Your trial has been successfully started.', 'freemius' ),
186
- 'license-activated-message' => __( 'Your license was successfully activated.', 'freemius' ),
187
- 'no-active-license-message' => __( 'It looks like your site currently don\'t have an active license.', 'freemius' ),
188
- 'license-deactivation-message' => __( 'Your license was successfully deactivated, you are back to the %s plan.', 'freemius' ),
189
- 'license-deactivation-failed-message' => __( 'It looks like the license deactivation failed.', 'freemius' ),
190
- 'license-activation-failed-message' => __( 'It looks like the license could not be activated.', 'freemius' ),
191
- 'server-error-message' => __( 'Error received from the server:', 'freemius' ),
192
- 'trial-expired-message' => __( 'Your trial has expired. You can still continue using all our free features.', 'freemius' ),
193
- 'plan-x-downgraded-message' => __( 'Your plan was successfully downgraded. Your %s plan license will expire in %s.', 'freemius' ),
194
- 'plan-downgraded-failure-message' => __( 'Seems like we are having some temporary issue with your plan downgrade. Please try again in few minutes.', 'freemius' ),
195
- 'trial-cancel-no-trial-message' => __( 'It looks like you are not in trial mode anymore so there\'s nothing to cancel :)', 'freemius' ),
196
- 'trial-cancel-message' => __( 'Your %s Plan trial was successfully cancelled.', 'freemius' ),
197
- 'version-x-released' => _x( 'Version %s was released.', '%s - numeric version number', 'freemius' ),
198
- 'please-download-x' => __( 'Please download %s.', 'freemius' ),
199
- 'latest-x-version' => _x( 'the latest %s version here', '%s - plan name, as the latest professional version here', 'freemius' ),
200
- 'trial-x-promotion-message' => __( 'How do you like %s so far? Test all our %s premium features with a %d-day free trial.', 'freemius' ),
201
- 'start-free-trial' => _x( 'Start free trial', 'call to action', 'freemius' ),
202
- 'trial-cancel-failure-message' => __( 'Seems like we are having some temporary issue with your trial cancellation. Please try again in few minutes.', 'freemius' ),
203
- 'no-commitment-for-x-days' => __( 'No commitment for %s days - cancel anytime!', 'freemius' ),
204
- 'license-expired-non-blocking-message' => __( 'Your license has expired. You can still continue using all the %s features, but you\'ll need to renew your license to continue getting updates and support.', 'freemius' ),
205
- 'could-not-activate-x' => __( 'Couldn\'t activate %s.', 'freemius' ),
206
- 'contact-us-with-error-message' => __( 'Please contact us with the following message:', 'freemius' ),
207
- 'plan-did-not-change-message' => __( 'It looks like your plan did\'t change. If you did upgrade, it\'s probably an issue on our side - sorry.', 'freemius' ),
208
- 'contact-us-here' => __( 'Please contact us here', 'freemius' ),
209
- 'plan-did-not-change-email-message' => __( 'I have upgraded my account but when I try to Sync the License, the plan remains %s.', 'freemius' ),
210
- #endregion Admin Notices
211
- #region Connectivity Issues
212
- 'connectivity-test-fails-message' => __( 'From unknown reason, the API connectivity test fails.', 'freemius' ),
213
- 'curl-missing-message' => __( 'We use PHP cURL library for the API calls, which is a very common library and usually installed out of the box. Unfortunately, cURL is not installed on your server.', 'freemius' ),
214
- 'cloudflare-blocks-connection-message' => __( 'From unknown reason, CloudFlare, the firewall we use, blocks the connection.', 'freemius' ),
215
- 'x-requires-access-to-api' => _x( '%s requires an access to our API.', 'as pluginX requires an access to our API', 'freemius' ),
216
- 'squid-blocks-connection-message' => __( 'It looks like your server is using Squid ACL (access control lists), which blocks the connection.', 'freemius' ),
217
- 'squid-no-clue-title' => __( 'I don\'t know what is Squid or ACL, help me!', 'freemius' ),
218
- 'squid-no-clue-desc' => __( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.' ),
219
- 'sysadmin-title' => __( 'I\'m a system administrator', 'freemius' ),
220
- 'squid-sysadmin-desc' => __( 'Great, please whitelist the following domains: %s. Once you done, deactivate the plugin and activate it again.' ),
221
- 'curl-missing-no-clue-title' => __( 'I don\'t know what is cURL or how to install it, help me!', 'freemius' ),
222
- 'curl-missing-no-clue-desc' => __( 'We\'ll make sure to contact your hosting company and resolve the issue. You will get a follow-up email to %s once we have an update.' ),
223
- 'curl-missing-sysadmin-desc' => __( 'Great, please install cURL and enable it in your php.ini file. To make sure it was successfully activated, use \'phpinfo()\'. Once activated, deactivate the plugin and reactivate it back again.' ),
224
- 'happy-to-resolve-issue-asap' => __( 'We are sure it\'s an issue on our side and more than happy to resolve it for you ASAP if you give us a chance.', 'freemius' ),
225
- 'fix-issue-title' => __( 'Yes - I\'m giving you a chance to fix it', 'freemius' ),
226
- 'fix-issue-desc' => __( 'We will do our best to whitelist your server and resolve this issue ASAP. You will get a follow-up email to %s once we have an update.', 'freemius' ),
227
- 'install-previous-title' => __( 'Let\'s try your previous version', 'freemius' ),
228
- 'install-previous-desc' => __( 'Uninstall this version and install the previous one.', 'freemius' ),
229
- 'deactivate-plugin-title' => __( 'That\'s exhausting, please deactivate', 'freemius' ),
230
- 'deactivate-plugin-desc' => __( 'We feel your frustration and sincerely apologize for the inconvenience. Hope to see you again in the future.', 'freemius' ),
231
- 'fix-request-sent-message' => __( 'Thank for giving us the chance to fix it! A message was just sent to our technical staff. We will get back to you as soon as we have an update to %s. Appreciate your patience.', 'freemius' ),
232
- 'server-blocking-access' => _x( 'Your server is blocking the access to Freemius\' API, which is crucial for %1s license synchronization. Please contact your host to whitelist %2s', '%1s - plugin title, %2s - API domain', 'freemius' ),
233
- 'wrong-authentication-param-message' => __( 'It seems like one of the authentication parameters is wrong. Update your Public Key, Secret Key & User ID, and try again.', 'freemius' ),
234
- #endregion Connectivity Issues
235
- #region Change Owner
236
- 'change-owner-request-sent-x' => __( 'Please check your mailbox, you should receive an email via %s to confirm the ownership change. From security reasons, you must confirm the change within the next 15 min. If you cannot find the email, please check your spam folder.', 'freemius' ),
237
- 'change-owner-request_owner-confirmed' => __( 'Thanks for confirming the ownership change. An email was just sent to %s for final approval.', 'freemius' ),
238
- 'change-owner-request_candidate-confirmed' => __( '%s is the new owner of the account.', 'freemius' ),
239
- #endregion Change Owner
240
- 'freemius-debug' => __( 'Freemius Debug', 'freemius' ),
241
- 'addon-x-cannot-run-without-y' => _x( '%s cannot run without %s.', 'addonX cannot run without pluginY', 'freemius' ),
242
- 'addon-x-cannot-run-without-parent' => _x( '%s cannot run without the plugin.', 'addonX cannot run...', 'freemius' ),
243
- 'plugin-x-activation-message' => _x( '%s activation was successfully completed.', 'pluginX activation was successfully...', 'freemius' ),
244
- 'features-and-pricing' => _x( 'Features & Pricing', 'Plugin installer section title', 'freemius' ),
245
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-admin-menu-manager.php DELETED
@@ -1,531 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.1.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Admin_Menu_Manager {
14
-
15
- #region Properties
16
-
17
- /**
18
- * @var string
19
- */
20
- protected $_plugin_slug;
21
-
22
- /**
23
- * @since 1.0.6
24
- *
25
- * @var string
26
- */
27
- private $_menu_slug;
28
- /**
29
- * @since 1.1.3
30
- *
31
- * @var string
32
- */
33
- private $_parent_slug;
34
- /**
35
- * @since 1.1.3
36
- *
37
- * @var string
38
- */
39
- private $_parent_type;
40
- /**
41
- * @since 1.1.3
42
- *
43
- * @var string
44
- */
45
- private $_type;
46
- /**
47
- * @since 1.1.3
48
- *
49
- * @var bool
50
- */
51
- private $_is_top_level;
52
- /**
53
- * @since 1.1.3
54
- *
55
- * @var bool
56
- */
57
- private $_is_override_exact;
58
- /**
59
- * @since 1.1.3
60
- *
61
- * @var string[]bool
62
- */
63
- private $_default_submenu_items;
64
- /**
65
- * @since 1.1.3
66
- *
67
- * @var string
68
- */
69
- private $_first_time_path;
70
-
71
- #endregion Properties
72
-
73
- /**
74
- * @var FS_Logger
75
- */
76
- protected $_logger;
77
-
78
- #region Singleton
79
-
80
- /**
81
- * @var FS_Admin_Menu_Manager[]
82
- */
83
- private static $_instances = array();
84
-
85
- /**
86
- * @param string $plugin_slug
87
- *
88
- * @return FS_Admin_Notice_Manager
89
- */
90
- static function instance( $plugin_slug ) {
91
- if ( ! isset( self::$_instances[ $plugin_slug ] ) ) {
92
- self::$_instances[ $plugin_slug ] = new FS_Admin_Menu_Manager( $plugin_slug );
93
- }
94
-
95
- return self::$_instances[ $plugin_slug ];
96
- }
97
-
98
- protected function __construct( $plugin_slug ) {
99
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $plugin_slug . '_admin_menu', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
100
-
101
- $this->_plugin_slug = $plugin_slug;
102
- }
103
-
104
- #endregion Singleton
105
-
106
- #region Helpers
107
-
108
- private function get_option( &$options, $key, $default = false ) {
109
- return ! empty( $options[ $key ] ) ? $options[ $key ] : $default;
110
- }
111
-
112
- private function get_bool_option( &$options, $key, $default = false ) {
113
- return isset( $options[ $key ] ) && is_bool( $options[ $key ] ) ? $options[ $key ] : $default;
114
- }
115
-
116
- #endregion Helpers
117
-
118
- /**
119
- * @param array $menu
120
- * @param bool $is_addon
121
- */
122
- function init( $menu, $is_addon = false ) {
123
- $this->_menu_slug = $menu['slug'];
124
-
125
- $this->_default_submenu_items = array();
126
- // @deprecated
127
- $this->_type = 'page';
128
- $this->_is_top_level = true;
129
- $this->_is_override_exact = false;
130
- $this->_parent_slug = false;
131
- // @deprecated
132
- $this->_parent_type = 'page';
133
-
134
- if ( ! $is_addon && isset( $menu ) ) {
135
- $this->_default_submenu_items = array(
136
- 'contact' => $this->get_bool_option( $menu, 'contact', true ),
137
- 'support' => $this->get_bool_option( $menu, 'support', true ),
138
- 'account' => $this->get_bool_option( $menu, 'account', true ),
139
- 'pricing' => $this->get_bool_option( $menu, 'pricing', true ),
140
- 'addons' => $this->get_bool_option( $menu, 'addons', true ),
141
- );
142
-
143
- // @deprecated
144
- $this->_type = $this->get_option( $menu, 'type', 'page' );
145
- $this->_is_override_exact = $this->get_bool_option( $menu, 'override_exact' );
146
-
147
- if ( isset( $menu['parent'] ) ) {
148
- $this->_parent_slug = $this->get_option( $menu['parent'], 'slug' );
149
- // @deprecated
150
- $this->_parent_type = $this->get_option( $menu['parent'], 'type', 'page' );
151
-
152
- // If parent's slug is different, then it's NOT a top level menu item.
153
- $this->_is_top_level = ( $this->_parent_slug === $this->_menu_slug );
154
- } else {
155
- /**
156
- * If no parent then top level if:
157
- * - Has custom admin menu ('page')
158
- * - CPT menu type ('cpt')
159
- */
160
- // $this->_is_top_level = in_array( $this->_type, array(
161
- // 'cpt',
162
- // 'page'
163
- // ) );
164
- }
165
-
166
- $this->_first_time_path = $this->get_option( $menu, 'first-path', false );
167
- if ( ! empty( $this->_first_time_path ) && is_string( $this->_first_time_path ) ) {
168
- $this->_first_time_path = admin_url( $this->_first_time_path, 'admin' );
169
- }
170
- }
171
- }
172
-
173
- /**
174
- * Check if top level menu.
175
- *
176
- * @author Vova Feldman (@svovaf)
177
- * @since 1.1.3
178
- *
179
- * @return bool False if submenu item.
180
- */
181
- function is_top_level() {
182
- return $this->_is_top_level;
183
- }
184
-
185
- /**
186
- * Check if the page should be override on exact URL match.
187
- *
188
- * @author Vova Feldman (@svovaf)
189
- * @since 1.1.3
190
- *
191
- * @return bool False if submenu item.
192
- */
193
- function is_override_exact() {
194
- return $this->_is_override_exact;
195
- }
196
-
197
-
198
- /**
199
- * Get the path of the page the user should be forwarded to after first activation.
200
- *
201
- * @author Vova Feldman (@svovaf)
202
- * @since 1.1.3
203
- *
204
- * @return string
205
- */
206
- function get_first_time_path() {
207
- return $this->_first_time_path;
208
- }
209
-
210
- /**
211
- * Check if plugin's menu item is part of a custom top level menu.
212
- *
213
- * @author Vova Feldman (@svovaf)
214
- * @since 1.1.3
215
- *
216
- * @return bool
217
- */
218
- function has_custom_parent() {
219
- return ! $this->_is_top_level && is_string( $this->_parent_slug );
220
- }
221
-
222
- /**
223
- * @author Vova Feldman (@svovaf)
224
- * @since 1.1.3
225
- *
226
- * @return string
227
- */
228
- // function slug(){
229
- // return $this->_menu_slug;
230
- // }
231
-
232
- /**
233
- * @author Vova Feldman (@svovaf)
234
- * @since 1.1.3
235
- *
236
- * @param string $id
237
- * @param bool $default
238
- *
239
- * @return bool
240
- */
241
- function is_submenu_item_visible( $id, $default = true ) {
242
- return $this->get_bool_option( $this->_default_submenu_items, $id, $default );
243
- }
244
-
245
- /**
246
- * Calculates admin settings menu slug.
247
- * If plugin's menu slug is a file (e.g. CPT), uses plugin's slug as the menu slug.
248
- *
249
- * @author Vova Feldman (@svovaf)
250
- * @since 1.1.3
251
- *
252
- * @param string $page
253
- *
254
- * @return string
255
- */
256
- function get_slug( $page = '' ) {
257
- return ( ( false === strpos( $this->_menu_slug, '.php?' ) ) ?
258
- $this->_menu_slug :
259
- $this->_plugin_slug ) . ( empty( $page ) ? '' : ( '-' . $page ) );
260
- }
261
-
262
- /**
263
- * @author Vova Feldman (@svovaf)
264
- * @since 1.1.3
265
- *
266
- * @return string
267
- */
268
- function get_parent_slug() {
269
- return $this->_parent_slug;
270
- }
271
-
272
- /**
273
- * @author Vova Feldman (@svovaf)
274
- * @since 1.1.3
275
- *
276
- * @return string
277
- */
278
- function get_type() {
279
- return $this->_type;
280
- }
281
-
282
- /**
283
- * @author Vova Feldman (@svovaf)
284
- * @since 1.1.3
285
- *
286
- * @return bool
287
- */
288
- function is_cpt() {
289
- return ( 0 === strpos( $this->_menu_slug, 'edit.php?post_type=' ) ||
290
- // Back compatibility.
291
- 'cpt' === $this->_type
292
- );
293
- }
294
-
295
- /**
296
- * @author Vova Feldman (@svovaf)
297
- * @since 1.1.3
298
- *
299
- * @return string
300
- */
301
- function get_parent_type() {
302
- return $this->_parent_type;
303
- }
304
-
305
- /**
306
- * @author Vova Feldman (@svovaf)
307
- * @since 1.1.3
308
- *
309
- * @return string
310
- */
311
- function get_raw_slug() {
312
- return $this->_menu_slug;
313
- }
314
-
315
- /**
316
- * Get plugin's original menu slug.
317
- *
318
- * @author Vova Feldman (@svovaf)
319
- * @since 1.1.3
320
- *
321
- * @return string
322
- */
323
- function get_original_menu_slug() {
324
- if ( 'cpt' === $this->_type ) {
325
- return add_query_arg( array(
326
- 'post_type' => $this->_menu_slug
327
- ), 'edit.php' );
328
- }
329
-
330
- if ( false === strpos( $this->_menu_slug, '.php?' ) ) {
331
- return $this->_menu_slug;
332
- } else {
333
- return $this->_plugin_slug;
334
- }
335
- }
336
-
337
- /**
338
- * @author Vova Feldman (@svovaf)
339
- * @since 1.1.3
340
- *
341
- * @return string
342
- */
343
- function get_top_level_menu_slug() {
344
- return $this->has_custom_parent() ?
345
- $this->get_parent_slug() :
346
- $this->get_raw_slug();
347
- }
348
-
349
- /**
350
- * Is user on plugin's admin activation page.
351
- *
352
- * @author Vova Feldman (@svovaf)
353
- * @since 1.0.8
354
- *
355
- * @return bool
356
- */
357
- function is_activation_page() {
358
- return isset( $_GET['page'] ) &&
359
- ( ( strtolower( $this->_menu_slug ) === strtolower( $_GET['page'] ) ) ||
360
- ( strtolower( $this->_plugin_slug ) === strtolower( $_GET['page'] ) ) );
361
- }
362
-
363
- #region Submenu Override
364
-
365
- /**
366
- * Override submenu's action.
367
- *
368
- * @author Vova Feldman (@svovaf)
369
- * @since 1.1.0
370
- *
371
- * @param string $parent_slug
372
- * @param string $menu_slug
373
- * @param callable $function
374
- *
375
- * @return false|string If submenu exist, will return the hook name.
376
- */
377
- function override_submenu_action( $parent_slug, $menu_slug, $function ) {
378
- global $submenu;
379
-
380
- $menu_slug = plugin_basename( $menu_slug );
381
- $parent_slug = plugin_basename( $parent_slug );
382
-
383
- if ( ! isset( $submenu[ $parent_slug ] ) ) {
384
- // Parent menu not exist.
385
- return false;
386
- }
387
-
388
- $found_submenu_item = false;
389
- foreach ( $submenu[ $parent_slug ] as $submenu_item ) {
390
- if ( $menu_slug === $submenu_item[2] ) {
391
- $found_submenu_item = $submenu_item;
392
- break;
393
- }
394
- }
395
-
396
- if ( false === $found_submenu_item ) {
397
- // Submenu item not found.
398
- return false;
399
- }
400
-
401
- // Remove current function.
402
- $hookname = get_plugin_page_hookname( $menu_slug, $parent_slug );
403
- remove_all_actions( $hookname );
404
-
405
- // Attach new action.
406
- add_action( $hookname, $function );
407
-
408
- return $hookname;
409
- }
410
-
411
- #endregion Submenu Override
412
-
413
- #region Top level menu Override
414
-
415
- /**
416
- * Find plugin's admin dashboard main menu item.
417
- *
418
- * @author Vova Feldman (@svovaf)
419
- * @since 1.0.2
420
- *
421
- * @return string[]|false
422
- */
423
- private function find_top_level_menu() {
424
- global $menu;
425
-
426
- $position = - 1;
427
- $found_menu = false;
428
-
429
- $menu_slug = $this->get_raw_slug();
430
-
431
- $hook_name = get_plugin_page_hookname( $menu_slug, '' );
432
- foreach ( $menu as $pos => $m ) {
433
- if ( $menu_slug === $m[2] ) {
434
- $position = $pos;
435
- $found_menu = $m;
436
- break;
437
- }
438
- }
439
-
440
- if ( false === $found_menu ) {
441
- return false;
442
- }
443
-
444
- return array(
445
- 'menu' => $found_menu,
446
- 'position' => $position,
447
- 'hook_name' => $hook_name
448
- );
449
- }
450
-
451
- /**
452
- * Remove all sub-menu items.
453
- *
454
- * @author Vova Feldman (@svovaf)
455
- * @since 1.0.7
456
- *
457
- * @return bool If submenu with plugin's menu slug was found.
458
- */
459
- private function remove_all_submenu_items() {
460
- global $submenu;
461
-
462
- $menu_slug = $this->get_raw_slug();
463
-
464
- if ( ! isset( $submenu[ $menu_slug ] ) ) {
465
- return false;
466
- }
467
-
468
- $submenu[ $menu_slug ] = array();
469
-
470
- return true;
471
- }
472
-
473
- /**
474
- *
475
- * @author Vova Feldman (@svovaf)
476
- * @since 1.0.9
477
- *
478
- * @return array[string]mixed
479
- */
480
- function remove_menu_item() {
481
- $this->_logger->entrance();
482
-
483
- // Find main menu item.
484
- $menu = $this->find_top_level_menu();
485
-
486
- if ( false === $menu ) {
487
- return false;
488
- }
489
-
490
- // Remove it with its actions.
491
- remove_all_actions( $menu['hook_name'] );
492
-
493
- // Remove all submenu items.
494
- $this->remove_all_submenu_items();
495
-
496
- return $menu;
497
- }
498
-
499
- /**
500
- *
501
- * @author Vova Feldman (@svovaf)
502
- * @since 1.1.4
503
- *
504
- * @param callable $function
505
- *
506
- * @return array[string]mixed
507
- */
508
- function override_menu_item( $function ) {
509
- $menu = $this->remove_menu_item();
510
-
511
- if ( false === $menu ) {
512
- return false;
513
- }
514
-
515
- // Override menu action.
516
- $hook = add_menu_page(
517
- $menu['menu'][3],
518
- $menu['menu'][0],
519
- 'manage_options',
520
- $this->get_slug(),
521
- $function,
522
- $menu['menu'][6],
523
- $menu['position']
524
- );
525
-
526
-
527
- return $hook;
528
- }
529
-
530
- #endregion Top level menu Override
531
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-admin-notice-manager.php DELETED
@@ -1,303 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.7
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Admin_Notice_Manager {
14
- /**
15
- * @var string
16
- */
17
- protected $_slug;
18
- /**
19
- * @var string
20
- */
21
- protected $_title;
22
- /**
23
- * @var array[]
24
- */
25
- private $_admin_messages = array();
26
- /**
27
- * @var FS_Key_Value_Storage
28
- */
29
- private $_sticky_storage;
30
- /**
31
- * @var FS_Plugin_Manager[]
32
- */
33
- private static $_instances = array();
34
- /**
35
- * @var FS_Logger
36
- */
37
- protected $_logger;
38
-
39
- /**
40
- * @param string $slug
41
- * @param string $title
42
- *
43
- * @return FS_Admin_Notice_Manager
44
- */
45
- static function instance( $slug, $title = '' ) {
46
- if ( ! isset( self::$_instances[ $slug ] ) ) {
47
- self::$_instances[ $slug ] = new FS_Admin_Notice_Manager( $slug, $title );
48
- }
49
-
50
- return self::$_instances[ $slug ];
51
- }
52
-
53
- protected function __construct( $slug, $title = '' ) {
54
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_data', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
55
-
56
- $this->_slug = $slug;
57
- $this->_title = ! empty( $title ) ? $title : '';
58
- $this->_sticky_storage = FS_Key_Value_Storage::instance( 'admin_notices', $this->_slug );
59
-
60
- if ( is_admin() ) {
61
- if ( 0 < count( $this->_sticky_storage ) ) {
62
- // If there are sticky notices for the current slug, add a callback
63
- // to the AJAX action that handles message dismiss.
64
- add_action( "wp_ajax_{$slug}_dismiss_notice_action", array(
65
- &$this,
66
- 'dismiss_notice_ajax_callback'
67
- ) );
68
-
69
- foreach ( $this->_sticky_storage as $id => $msg ) {
70
- // Add admin notice.
71
- $this->add(
72
- $msg['message'],
73
- $msg['title'],
74
- $msg['type'],
75
- true,
76
- $msg['all'],
77
- $msg['id'],
78
- false
79
- );
80
- }
81
- }
82
- }
83
- }
84
-
85
- /**
86
- * Remove sticky message by ID.
87
- *
88
- * @author Vova Feldman (@svovaf)
89
- * @since 1.0.7
90
- *
91
- */
92
- function dismiss_notice_ajax_callback() {
93
- $this->_sticky_storage->remove( $_POST['message_id'] );
94
- wp_die();
95
- }
96
-
97
- /**
98
- * Rendered sticky message dismiss JavaScript.
99
- *
100
- * @author Vova Feldman (@svovaf)
101
- * @since 1.0.7
102
- */
103
- static function _add_sticky_dismiss_javascript() {
104
- $params = array();
105
- fs_require_once_template( 'sticky-admin-notice-js.php', $params );
106
- }
107
-
108
- private static $_added_sticky_javascript = false;
109
-
110
- /**
111
- * Hook to the admin_footer to add sticky message dismiss JavaScript handler.
112
- *
113
- * @author Vova Feldman (@svovaf)
114
- * @since 1.0.7
115
- */
116
- private static function has_sticky_messages() {
117
- if ( ! self::$_added_sticky_javascript ) {
118
- add_action( 'admin_footer', array( 'FS_Admin_Notice_Manager', '_add_sticky_dismiss_javascript' ) );
119
- }
120
- }
121
-
122
- /**
123
- * Handle admin_notices by printing the admin messages stacked in the queue.
124
- *
125
- * @author Vova Feldman (@svovaf)
126
- * @since 1.0.4
127
- *
128
- */
129
- function _admin_notices_hook() {
130
- $notice_type = 'admin_notices';
131
-
132
- if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
133
- return;
134
- }
135
-
136
- foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
137
- fs_require_template( 'admin-notice.php', $msg );
138
-
139
- if ( $msg['sticky'] ) {
140
- self::has_sticky_messages();
141
- }
142
- }
143
- }
144
-
145
- /**
146
- * Handle all_admin_notices by printing the admin messages stacked in the queue.
147
- *
148
- * @author Vova Feldman (@svovaf)
149
- * @since 1.0.4
150
- *
151
- */
152
- function _all_admin_notices_hook() {
153
- $notice_type = 'all_admin_notices';
154
-
155
- if ( ! isset( $this->_admin_messages[ $notice_type ] ) || ! is_array( $this->_admin_messages[ $notice_type ] ) ) {
156
- return;
157
- }
158
-
159
- foreach ( $this->_admin_messages[ $notice_type ] as $id => $msg ) {
160
- fs_require_template( 'all-admin-notice.php', $msg );
161
- }
162
- }
163
-
164
- /**
165
- * Enqueue common stylesheet to style admin notice.
166
- *
167
- * @author Vova Feldman (@svovaf)
168
- * @since 1.0.7
169
- */
170
- function _enqueue_styles() {
171
- fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
172
- }
173
-
174
- /**
175
- * Add admin message to admin messages queue, and hook to admin_notices / all_admin_notices if not yet hooked.
176
- *
177
- * @author Vova Feldman (@svovaf)
178
- * @since 1.0.4
179
- *
180
- * @param string $message
181
- * @param string $title
182
- * @param string $type
183
- * @param bool $is_sticky
184
- * @param bool $all_admin
185
- * @param string $id Message ID
186
- * @param bool $store_if_sticky
187
- *
188
- * @uses add_action()
189
- */
190
- function add( $message, $title = '', $type = 'success', $is_sticky = false, $all_admin = false, $id = '', $store_if_sticky = true ) {
191
- $key = ( $all_admin ? 'all_admin_notices' : 'admin_notices' );
192
-
193
- if ( ! isset( $this->_admin_messages[ $key ] ) ) {
194
- $this->_admin_messages[ $key ] = array();
195
-
196
- add_action( $key, array( &$this, "_{$key}_hook" ) );
197
- add_action( 'admin_enqueue_scripts', array( &$this, '_enqueue_styles' ) );
198
-
199
- }
200
-
201
- if ( '' === $id ) {
202
- $id = md5( $title . ' ' . $message . ' ' . $type );
203
- }
204
-
205
- $message_object = array(
206
- 'message' => $message,
207
- 'title' => $title,
208
- 'type' => $type,
209
- 'sticky' => $is_sticky,
210
- 'id' => $id,
211
- 'all' => $all_admin,
212
- 'slug' => $this->_slug,
213
- 'plugin' => $this->_title,
214
- );
215
-
216
- if ( $is_sticky && $store_if_sticky ) {
217
- $this->_sticky_storage->{$id} = $message_object;
218
- }
219
-
220
- $this->_admin_messages[ $key ][ $id ] = $message_object;
221
- }
222
-
223
- /**
224
- * @author Vova Feldman (@svovaf)
225
- * @since 1.0.7
226
- *
227
- * @param string $ids
228
- */
229
- function remove_sticky( $ids ) {
230
- if ( ! is_array( $ids ) ) {
231
- $ids = array( $ids );
232
- }
233
-
234
- foreach ( $ids as $id ) {
235
- // Remove from sticky storage.
236
- $this->_sticky_storage->remove( $id );
237
-
238
- // Remove from current admin messages.
239
- if ( isset( $this->_admin_messages['all_admin_notices'] ) && isset( $this->_admin_messages['all_admin_notices'][ $id ] ) ) {
240
- unset( $this->_admin_messages['all_admin_notices'][ $id ] );
241
- }
242
- if ( isset( $this->_admin_messages['admin_notices'] ) && isset( $this->_admin_messages['admin_notices'][ $id ] ) ) {
243
- unset( $this->_admin_messages['admin_notices'][ $id ] );
244
- }
245
- }
246
- }
247
-
248
- /**
249
- * Check if sticky message exists by id.
250
- *
251
- * @author Vova Feldman (@svovaf)
252
- * @since 1.0.9
253
- *
254
- * @param $id
255
- *
256
- * @return bool
257
- */
258
- function has_sticky( $id ) {
259
- return isset( $this->_sticky_storage[ $id ] );
260
- }
261
-
262
- /**
263
- * Adds sticky admin notification.
264
- *
265
- * @author Vova Feldman (@svovaf)
266
- * @since 1.0.7
267
- *
268
- * @param string $message
269
- * @param string $id Message ID
270
- * @param string $title
271
- * @param string $type
272
- * @param bool $all_admin
273
- */
274
- function add_sticky( $message, $id, $title = '', $type = 'success', $all_admin = false ) {
275
- $this->add( $message, $title, $type, true, $all_admin, $id );
276
- }
277
-
278
- /**
279
- * Clear all sticky messages.
280
- *
281
- * @author Vova Feldman (@svovaf)
282
- * @since 1.0.8
283
- */
284
- function clear_all_sticky() {
285
- $this->_sticky_storage->clear_all();
286
- }
287
-
288
- /**
289
- * Add admin message to all admin messages queue, and hook to all_admin_notices if not yet hooked.
290
- *
291
- * @author Vova Feldman (@svovaf)
292
- * @since 1.0.4
293
- *
294
- * @param string $message
295
- * @param string $title
296
- * @param string $type
297
- * @param bool $is_sticky
298
- * @param string $id Message ID
299
- */
300
- function add_all( $message, $title = '', $type = 'success', $is_sticky = false, $id = '' ) {
301
- $this->add( $message, $title, $type, $is_sticky, true, $id );
302
- }
303
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-key-value-storage.php DELETED
@@ -1,289 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.7
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Key_Value_Storage implements ArrayAccess, Iterator, Countable {
14
- /**
15
- * @var string
16
- */
17
- protected $_id;
18
- /**
19
- * @var string
20
- */
21
- protected $_slug;
22
- /**
23
- * @var array
24
- */
25
- protected $_data;
26
-
27
- /**
28
- * @var FS_Plugin_Manager[]
29
- */
30
- private static $_instances = array();
31
- /**
32
- * @var FS_Logger
33
- */
34
- protected $_logger;
35
-
36
- /**
37
- * @param string $id
38
- * @param string $slug
39
- *
40
- * @return FS_Key_Value_Storage
41
- */
42
- static function instance( $id, $slug ) {
43
- $key = $id . ':' . $slug;
44
- if ( ! isset( self::$_instances[ $key ] ) ) {
45
- self::$_instances[ $key ] = new FS_Key_Value_Storage( $id, $slug );
46
- }
47
-
48
- return self::$_instances[ $key ];
49
- }
50
-
51
- protected function __construct( $id, $slug ) {
52
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
-
54
- $this->_slug = $slug;
55
- $this->_id = $id;
56
- $this->load();
57
- }
58
-
59
- protected function get_option_manager() {
60
- return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
61
- }
62
-
63
- protected function get_all_data() {
64
- return $this->get_option_manager()->get_option( $this->_id, array() );
65
- }
66
-
67
- /**
68
- * Load plugin data from local DB.
69
- *
70
- * @author Vova Feldman (@svovaf)
71
- * @since 1.0.7
72
- */
73
- function load() {
74
- $all_plugins_data = $this->get_all_data();
75
- $this->_data = isset( $all_plugins_data[ $this->_slug ] ) ?
76
- $all_plugins_data[ $this->_slug ] :
77
- array();
78
- }
79
-
80
- /**
81
- * @author Vova Feldman (@svovaf)
82
- * @since 1.0.7
83
- *
84
- * @param string $key
85
- * @param mixed $value
86
- * @param bool $flush
87
- */
88
- function store( $key, $value, $flush = true ) {
89
- if ( array_key_exists( $key, $this->_data ) && $value === $this->_data[ $key ] ) {
90
- // No need to store data if the value wasn't changed.
91
- return;
92
- }
93
-
94
- $all_data = $this->get_all_data();
95
-
96
- $this->_data[ $key ] = $value;
97
-
98
- $all_data[ $this->_slug ] = $this->_data;
99
-
100
- $options_manager = $this->get_option_manager();
101
- $options_manager->set_option( $this->_id, $all_data, $flush );
102
- }
103
-
104
- /**
105
- * @author Vova Feldman (@svovaf)
106
- * @since 1.0.7
107
- *
108
- * @param bool $store
109
- * @param string[] $exceptions Set of keys to keep and not clear.
110
- */
111
- function clear_all( $store = true, $exceptions = array() ) {
112
- $new_data = array();
113
- foreach ( $exceptions as $key ) {
114
- $new_data[ $key ] = $this->_data[ $key ];
115
- }
116
-
117
- $this->_data = $new_data;
118
-
119
- if ( $store ) {
120
- $all_data = $this->get_all_data();
121
- $all_data[ $this->_slug ] = $this->_data;
122
- $options_manager = $this->get_option_manager();
123
- $options_manager->set_option( $this->_id, $all_data, true );
124
- }
125
- }
126
-
127
- /**
128
- * Delete key-value storage.
129
- *
130
- * @author Vova Feldman (@svovaf)
131
- * @since 1.0.9
132
- */
133
- function delete() {
134
- $this->_data = array();
135
-
136
- $all_data = $this->get_all_data();
137
- unset( $all_data[ $this->_slug ] );
138
- $options_manager = $this->get_option_manager();
139
- $options_manager->set_option( $this->_id, $all_data, true );
140
- }
141
-
142
- /**
143
- * @author Vova Feldman (@svovaf)
144
- * @since 1.0.7
145
- *
146
- * @param string $key
147
- * @param bool $store
148
- */
149
- function remove( $key, $store = true ) {
150
- if ( ! array_key_exists( $key, $this->_data ) ) {
151
- return;
152
- }
153
-
154
- unset( $this->_data[ $key ] );
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
- * @author Vova Feldman (@svovaf)
166
- * @since 1.0.7
167
- *
168
- * @param string $key
169
- * @param mixed $default
170
- *
171
- * @return bool|\FS_Plugin
172
- */
173
- function get( $key, $default = false ) {
174
- return array_key_exists( $key, $this->_data ) ?
175
- $this->_data[ $key ] :
176
- $default;
177
- }
178
-
179
-
180
- /* ArrayAccess + Magic Access (better for refactoring)
181
- -----------------------------------------------------------------------------------*/
182
- function __set( $k, $v ) {
183
- $this->store( $k, $v );
184
- }
185
-
186
- function __isset( $k ) {
187
- return array_key_exists( $k, $this->_data );
188
- }
189
-
190
- function __unset( $k ) {
191
- $this->remove( $k );
192
- }
193
-
194
- function __get( $k ) {
195
- return $this->get( $k, null );
196
- }
197
-
198
- function offsetSet( $k, $v ) {
199
- if ( is_null( $k ) ) {
200
- throw new Exception( 'Can\'t append value to request params.' );
201
- } else {
202
- $this->{$k} = $v;
203
- }
204
- }
205
-
206
- function offsetExists( $k ) {
207
- return array_key_exists( $k, $this->_data );
208
- }
209
-
210
- function offsetUnset( $k ) {
211
- unset( $this->$k );
212
- }
213
-
214
- function offsetGet( $k ) {
215
- return $this->get( $k, null );
216
- }
217
-
218
- /**
219
- * (PHP 5 &gt;= 5.0.0)<br/>
220
- * Return the current element
221
- *
222
- * @link http://php.net/manual/en/iterator.current.php
223
- * @return mixed Can return any type.
224
- */
225
- public function current() {
226
- return current( $this->_data );
227
- }
228
-
229
- /**
230
- * (PHP 5 &gt;= 5.0.0)<br/>
231
- * Move forward to next element
232
- *
233
- * @link http://php.net/manual/en/iterator.next.php
234
- * @return void Any returned value is ignored.
235
- */
236
- public function next() {
237
- return next( $this->_data );
238
- }
239
-
240
- /**
241
- * (PHP 5 &gt;= 5.0.0)<br/>
242
- * Return the key of the current element
243
- *
244
- * @link http://php.net/manual/en/iterator.key.php
245
- * @return mixed scalar on success, or null on failure.
246
- */
247
- public function key() {
248
- return key( $this->_data );
249
- }
250
-
251
- /**
252
- * (PHP 5 &gt;= 5.0.0)<br/>
253
- * Checks if current position is valid
254
- *
255
- * @link http://php.net/manual/en/iterator.valid.php
256
- * @return boolean The return value will be casted to boolean and then evaluated.
257
- * Returns true on success or false on failure.
258
- */
259
- public function valid() {
260
- $key = key( $this->_data );
261
-
262
- return ( $key !== null && $key !== false );
263
- }
264
-
265
- /**
266
- * (PHP 5 &gt;= 5.0.0)<br/>
267
- * Rewind the Iterator to the first element
268
- *
269
- * @link http://php.net/manual/en/iterator.rewind.php
270
- * @return void Any returned value is ignored.
271
- */
272
- public function rewind() {
273
- reset( $this->_data );
274
- }
275
-
276
- /**
277
- * (PHP 5 &gt;= 5.1.0)<br/>
278
- * Count elements of an object
279
- *
280
- * @link http://php.net/manual/en/countable.count.php
281
- * @return int The custom count as an integer.
282
- * </p>
283
- * <p>
284
- * The return value is cast to an integer.
285
- */
286
- public function count() {
287
- return count( $this->_data );
288
- }
289
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-license-manager.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.6
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_License_Manager /*extends FS_Abstract_Manager*/
14
- {
15
- //
16
- //
17
- // /**
18
- // * @var FS_License_Manager[]
19
- // */
20
- // private static $_instances = array();
21
- //
22
- // static function instance( Freemius $fs ) {
23
- // $slug = strtolower( $fs->get_slug() );
24
- //
25
- // if ( ! isset( self::$_instances[ $slug ] ) ) {
26
- // self::$_instances[ $slug ] = new FS_License_Manager( $slug, $fs );
27
- // }
28
- //
29
- // return self::$_instances[ $slug ];
30
- // }
31
- //
32
- //// private function __construct($slug) {
33
- //// parent::__construct($slug);
34
- //// }
35
- //
36
- // function entry_id() {
37
- // return 'licenses';
38
- // }
39
- //
40
- // function sync( $id ) {
41
- //
42
- // }
43
- //
44
- // /**
45
- // * @author Vova Feldman (@svovaf)
46
- // * @since 1.0.5
47
- // * @uses FS_Api
48
- // *
49
- // * @param number|bool $plugin_id
50
- // *
51
- // * @return FS_Plugin_License[]|stdClass Licenses or API error.
52
- // */
53
- // function api_get_user_plugin_licenses( $plugin_id = false ) {
54
- // $api = $this->_fs->get_api_user_scope();
55
- //
56
- // if ( ! is_numeric( $plugin_id ) ) {
57
- // $plugin_id = $this->_fs->get_id();
58
- // }
59
- //
60
- // $result = $api->call( "/plugins/{$plugin_id}/licenses.json" );
61
- //
62
- // if ( ! isset( $result->error ) ) {
63
- // for ( $i = 0, $len = count( $result->licenses ); $i < $len; $i ++ ) {
64
- // $result->licenses[ $i ] = new FS_Plugin_License( $result->licenses[ $i ] );
65
- // }
66
- //
67
- // $result = $result->licenses;
68
- // }
69
- //
70
- // return $result;
71
- // }
72
- //
73
- // function api_get_many() {
74
- //
75
- // }
76
- //
77
- // function api_activate( $id ) {
78
- //
79
- // }
80
- //
81
- // function api_deactivate( $id ) {
82
- //
83
- // }
84
-
85
- /**
86
- * @param FS_Plugin_License[] $licenses
87
- *
88
- * @return bool
89
- */
90
- static function has_premium_license( $licenses ) {
91
- if ( is_array( $licenses ) ) {
92
- foreach ( $licenses as $license ) {
93
- if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
94
- return true;
95
- }
96
- }
97
- }
98
-
99
- return false;
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-option-manager.php DELETED
@@ -1,297 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.3
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- /**
14
- * 3-layer lazy options manager.
15
- * layer 3: Memory
16
- * layer 2: Cache (if there's any caching plugin and if WP_FS__DEBUG_SDK is FALSE)
17
- * layer 1: Database (options table). All options stored as one option record in the DB to reduce number of DB
18
- * queries.
19
- *
20
- * If load() is not explicitly called, starts as empty manager. Same thing about saving the data - you have to
21
- * explicitly call store().
22
- *
23
- * Class Freemius_Option_Manager
24
- */
25
- class FS_Option_Manager {
26
- /**
27
- * @var string
28
- */
29
- private $_id;
30
- /**
31
- * @var array
32
- */
33
- private $_options;
34
- /**
35
- * @var FS_Logger
36
- */
37
- private $_logger;
38
-
39
- /**
40
- * @var FS_Option_Manager[]
41
- */
42
- private static $_MANAGERS = array();
43
-
44
- /**
45
- * @author Vova Feldman (@svovaf)
46
- * @since 1.0.3
47
- *
48
- * @param string $id
49
- * @param bool $load
50
- */
51
- private function __construct( $id, $load = false ) {
52
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_opt_mngr_' . $id, WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
53
-
54
- $this->_logger->entrance();
55
- $this->_logger->log( 'id = ' . $id );
56
-
57
- $this->_id = $id;
58
-
59
- if ( $load ) {
60
- $this->load();
61
- }
62
- }
63
-
64
- /**
65
- * @author Vova Feldman (@svovaf)
66
- * @since 1.0.3
67
- *
68
- * @param $id
69
- * @param $load
70
- *
71
- * @return FS_Option_Manager
72
- */
73
- static function get_manager( $id, $load = false ) {
74
- $id = strtolower( $id );
75
-
76
- if ( ! isset( self::$_MANAGERS[ $id ] ) ) {
77
- self::$_MANAGERS[ $id ] = new FS_Option_Manager( $id, $load );
78
- } // If load required but not yet loaded, load.
79
- else if ( $load && ! self::$_MANAGERS[ $id ]->is_loaded() ) {
80
- self::$_MANAGERS[ $id ]->load();
81
- }
82
-
83
- return self::$_MANAGERS[ $id ];
84
- }
85
-
86
- private function _get_option_manager_name() {
87
- // return WP_FS__SLUG . '_' . $this->_id;
88
- return $this->_id;
89
- }
90
-
91
- /**
92
- * @author Vova Feldman (@svovaf)
93
- * @since 1.0.3
94
- *
95
- * @param bool $flush
96
- */
97
- function load( $flush = false ) {
98
- $this->_logger->entrance();
99
-
100
- $option_name = $this->_get_option_manager_name();
101
-
102
- if ( $flush || ! isset( $this->_options ) ) {
103
- if ( ! WP_FS__DEBUG_SDK ) {
104
- $this->_options = wp_cache_get( $option_name, WP_FS__SLUG );
105
- }
106
-
107
- // $this->_logger->info('wp_cache_get = ' . var_export($this->_options, true));
108
-
109
- // if ( is_array( $this->_options ) ) {
110
- // $this->clear();
111
- // }
112
-
113
- $cached = true;
114
-
115
- if ( empty( $this->_options ) ) {
116
- $this->_options = get_option( $option_name );
117
-
118
- if ( is_string( $this->_options ) ) {
119
- $this->_options = json_decode( $this->_options );
120
- }
121
-
122
- // $this->_logger->info('get_option = ' . var_export($this->_options, true));
123
-
124
- if ( false === $this->_options ) {
125
- $this->clear();
126
- }
127
-
128
- $cached = false;
129
- }
130
-
131
- if ( ! WP_FS__DEBUG_SDK && ! $cached ) // Set non encoded cache.
132
- {
133
- wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
134
- }
135
- }
136
- }
137
-
138
- /**
139
- * @author Vova Feldman (@svovaf)
140
- * @since 1.0.3
141
- *
142
- * @return bool
143
- */
144
- function is_loaded() {
145
- return isset( $this->_options );
146
- }
147
-
148
- /**
149
- * @author Vova Feldman (@svovaf)
150
- * @since 1.0.3
151
- *
152
- * @return bool
153
- */
154
- function is_empty() {
155
- return ( $this->is_loaded() && false === $this->_options );
156
- }
157
-
158
- /**
159
- * @author Vova Feldman (@svovaf)
160
- * @since 1.0.6
161
- *
162
- * @param bool $flush
163
- */
164
- function clear( $flush = false ) {
165
- $this->_logger->entrance();
166
-
167
- $this->_options = array();
168
-
169
- if ( $flush ) {
170
- $this->store();
171
- }
172
- }
173
-
174
- /**
175
- * Delete options manager from DB.
176
- *
177
- * @author Vova Feldman (@svovaf)
178
- * @since 1.0.9
179
- */
180
- function delete() {
181
- delete_option( $this->_get_option_manager_name() );
182
- }
183
-
184
- /**
185
- * @author Vova Feldman (@svovaf)
186
- * @since 1.0.6
187
- *
188
- * @param string $option
189
- *
190
- * @return bool
191
- */
192
- function has_option( $option ) {
193
- return array_key_exists( $option, $this->_options );
194
- }
195
-
196
- /**
197
- * @author Vova Feldman (@svovaf)
198
- * @since 1.0.3
199
- *
200
- * @param string $option
201
- * @param mixed $default
202
- *
203
- * @return mixed
204
- */
205
- function get_option( $option, $default = null ) {
206
- $this->_logger->entrance( 'option = ' . $option );
207
-
208
- if ( is_array( $this->_options ) ) {
209
- return isset( $this->_options[ $option ] ) ? $this->_options[ $option ] : $default;
210
- } else if ( is_object( $this->_options ) ) {
211
- return isset( $this->_options->{$option} ) ? $this->_options->{$option} : $default;
212
- }
213
-
214
- return $default;
215
- }
216
-
217
- /**
218
- * @author Vova Feldman (@svovaf)
219
- * @since 1.0.3
220
- *
221
- * @param string $option
222
- * @param mixed $value
223
- * @param bool $flush
224
- */
225
- function set_option( $option, $value, $flush = false ) {
226
- $this->_logger->entrance( 'option = ' . $option );
227
-
228
- if ( ! $this->is_loaded() ) {
229
- $this->clear();
230
- }
231
-
232
- if ( is_array( $this->_options ) ) {
233
- $this->_options[ $option ] = $value;
234
- } else if ( is_object( $this->_options ) ) {
235
- $this->_options->{$option} = $value;
236
- }
237
-
238
- if ( $flush ) {
239
- $this->store();
240
- }
241
- }
242
-
243
- /**
244
- * Unset option.
245
- *
246
- * @author Vova Feldman (@svovaf)
247
- * @since 1.0.3
248
- *
249
- * @param string $option
250
- * @param bool $flush
251
- */
252
- function unset_option( $option, $flush = false ) {
253
- $this->_logger->entrance( 'option = ' . $option );
254
-
255
- if ( is_array( $this->_options ) ) {
256
- if ( ! isset( $this->_options[ $option ] ) ) {
257
- return;
258
- }
259
-
260
- unset( $this->_options[ $option ] );
261
-
262
- } else if ( is_object( $this->_options ) ) {
263
- if ( ! isset( $this->_options->{$option} ) ) {
264
- return;
265
- }
266
-
267
- unset( $this->_options->{$option} );
268
- }
269
-
270
- if ( $flush ) {
271
- $this->store();
272
- }
273
- }
274
-
275
- /**
276
- * Dump options to database.
277
- *
278
- * @author Vova Feldman (@svovaf)
279
- * @since 1.0.3
280
- */
281
- function store() {
282
- $this->_logger->entrance();
283
-
284
- $option_name = $this->_get_option_manager_name();
285
-
286
- if ( $this->_logger->is_on() ) {
287
- $this->_logger->info( $option_name . ' = ' . var_export( $this->_options, true ) );
288
- }
289
-
290
- // Update DB.
291
- update_option( $option_name, $this->_options );
292
-
293
- if ( ! WP_FS__DEBUG_SDK ) {
294
- wp_cache_set( $option_name, $this->_options, WP_FS__SLUG );
295
- }
296
- }
297
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-plan-manager.php DELETED
@@ -1,147 +0,0 @@
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
- foreach ( $licenses as $license ) {
41
- if ( ! $license->is_utilized() && $license->is_features_enabled() ) {
42
- return true;
43
- }
44
- }
45
- }
46
-
47
- return false;
48
- }
49
-
50
- /**
51
- * Check if plugin has any paid plans.
52
- *
53
- * @author Vova Feldman (@svovaf)
54
- * @since 1.0.7
55
- *
56
- * @param FS_Plugin_Plan[] $plans
57
- *
58
- * @return bool
59
- */
60
- function has_paid_plan( $plans ) {
61
- if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
62
- return false;
63
- }
64
-
65
- for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
66
- if ( ! $plans[ $i ]->is_free() ) {
67
- return true;
68
- }
69
- }
70
-
71
- return false;
72
- }
73
-
74
- /**
75
- * Check if plugin has any free plan, or is it premium only.
76
- *
77
- * Note: If no plans configured, assume plugin is free.
78
- *
79
- * @author Vova Feldman (@svovaf)
80
- * @since 1.0.7
81
- *
82
- * @param FS_Plugin_Plan[] $plans
83
- *
84
- * @return bool
85
- */
86
- function has_free_plan( $plans ) {
87
- if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
88
- return true;
89
- }
90
-
91
- for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
92
- if ( $plans[ $i ]->is_free() ) {
93
- return true;
94
- }
95
- }
96
-
97
- return false;
98
- }
99
-
100
- /**
101
- * Find all plans that have trial.
102
- *
103
- * @author Vova Feldman (@svovaf)
104
- * @since 1.0.9
105
- *
106
- * @param FS_Plugin_Plan[] $plans
107
- *
108
- * @return FS_Plugin_Plan[]
109
- */
110
- function get_trial_plans( $plans ) {
111
- $trial_plans = array();
112
-
113
- if ( is_array( $plans ) && 0 < count( $plans ) ) {
114
- for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
115
- if ( $plans[ $i ]->has_trial() ) {
116
- $trial_plans[] = $plans[ $i ];
117
- }
118
- }
119
- }
120
-
121
- return $trial_plans;
122
- }
123
-
124
- /**
125
- * Check if plugin has any trial plan.
126
- *
127
- * @author Vova Feldman (@svovaf)
128
- * @since 1.0.9
129
- *
130
- * @param FS_Plugin_Plan[] $plans
131
- *
132
- * @return bool
133
- */
134
- function has_trial_plan( $plans ) {
135
- if ( ! is_array( $plans ) || 0 === count( $plans ) ) {
136
- return true;
137
- }
138
-
139
- for ( $i = 0, $len = count( $plans ); $i < $len; $i ++ ) {
140
- if ( $plans[ $i ]->has_trial() ) {
141
- return true;
142
- }
143
- }
144
-
145
- return false;
146
- }
147
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/managers/class-fs-plugin-manager.php DELETED
@@ -1,154 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.0.6
7
- */
8
-
9
- if ( ! defined( 'ABSPATH' ) ) {
10
- exit;
11
- }
12
-
13
- class FS_Plugin_Manager {
14
- /**
15
- * @var string
16
- */
17
- protected $_slug;
18
- /**
19
- * @var FS_Plugin
20
- */
21
- protected $_plugin;
22
-
23
- /**
24
- * @var FS_Plugin_Manager[]
25
- */
26
- private static $_instances = array();
27
- /**
28
- * @var FS_Logger
29
- */
30
- protected $_logger;
31
-
32
- /**
33
- * @param string $slug
34
- *
35
- * @return FS_Plugin_Manager
36
- */
37
- static function instance( $slug ) {
38
- if ( ! isset( self::$_instances[ $slug ] ) ) {
39
- self::$_instances[ $slug ] = new FS_Plugin_Manager( $slug );
40
- }
41
-
42
- return self::$_instances[ $slug ];
43
- }
44
-
45
- protected function __construct( $slug ) {
46
- $this->_logger = FS_Logger::get_logger( WP_FS__SLUG . '_' . $slug . '_' . 'plugins', WP_FS__DEBUG_SDK, WP_FS__ECHO_DEBUG_SDK );
47
-
48
- $this->_slug = $slug;
49
- $this->load();
50
- }
51
-
52
- protected function get_option_manager() {
53
- return FS_Option_Manager::get_manager( WP_FS__ACCOUNTS_OPTION_NAME, true );
54
- }
55
-
56
- protected function get_all_plugins() {
57
- return $this->get_option_manager()->get_option( 'plugins', array() );
58
- }
59
-
60
- /**
61
- * Load plugin data from local DB.
62
- *
63
- * @author Vova Feldman (@svovaf)
64
- * @since 1.0.6
65
- */
66
- function load() {
67
- $all_plugins = $this->get_all_plugins();
68
- $this->_plugin = isset( $all_plugins[ $this->_slug ] ) ?
69
- $all_plugins[ $this->_slug ] :
70
- null;
71
- }
72
-
73
- /**
74
- * Store plugin on local DB.
75
- *
76
- * @author Vova Feldman (@svovaf)
77
- * @since 1.0.6
78
- *
79
- * @param bool|FS_Plugin $plugin
80
- * @param bool $flush
81
- *
82
- * @return bool|\FS_Plugin
83
- */
84
- function store( $plugin = false, $flush = true ) {
85
- $all_plugins = $this->get_all_plugins();
86
-
87
- if ( false !== $plugin ) {
88
- $this->_plugin = $plugin;
89
- }
90
-
91
- $all_plugins[ $this->_slug ] = $this->_plugin;
92
-
93
- $options_manager = $this->get_option_manager();
94
- $options_manager->set_option( 'plugins', $all_plugins, $flush );
95
-
96
- return $this->_plugin;
97
- }
98
-
99
- /**
100
- * Update local plugin data if different.
101
- *
102
- * @author Vova Feldman (@svovaf)
103
- * @since 1.0.6
104
- *
105
- * @param \FS_Plugin $plugin
106
- * @param bool $store
107
- *
108
- * @return bool True if plugin was updated.
109
- */
110
- function update( FS_Plugin $plugin, $store = true ) {
111
- if ( ! ( $this->_plugin instanceof FS_Plugin ) ||
112
- $this->_plugin->slug != $plugin->slug ||
113
- $this->_plugin->public_key != $plugin->public_key ||
114
- $this->_plugin->secret_key != $plugin->secret_key ||
115
- $this->_plugin->parent_plugin_id != $plugin->parent_plugin_id ||
116
- $this->_plugin->title != $plugin->title
117
- ) {
118
- $this->store( $plugin, $store );
119
-
120
- return true;
121
- }
122
-
123
- return false;
124
- }
125
-
126
- /**
127
- * @author Vova Feldman (@svovaf)
128
- * @since 1.0.6
129
- *
130
- * @param FS_Plugin $plugin
131
- * @param bool $store
132
- */
133
- function set( FS_Plugin $plugin, $store = false ) {
134
- $this->_plugin = $plugin;
135
-
136
- if ( $store ) {
137
- $this->store();
138
- }
139
- }
140
-
141
- /**
142
- * @author Vova Feldman (@svovaf)
143
- * @since 1.0.6
144
- *
145
- * @return bool|\FS_Plugin
146
- */
147
- function get() {
148
- return isset( $this->_plugin ) ?
149
- $this->_plugin :
150
- false;
151
- }
152
-
153
-
154
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/sdk/Exceptions/ArgumentNotExistException.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- class Freemius_ArgumentNotExistException extends Freemius_InvalidArgumentException { }
 
 
freemius/includes/sdk/Exceptions/EmptyArgumentException.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- class Freemius_EmptyArgumentException extends Freemius_InvalidArgumentException { }
 
 
freemius/includes/sdk/Exceptions/Exception.php DELETED
@@ -1,75 +0,0 @@
1
- <?php
2
- /**
3
- * Thrown when an API call returns an exception.
4
- *
5
- */
6
- class Freemius_Exception extends Exception
7
- {
8
- protected $_result;
9
- protected $_type;
10
- protected $_code;
11
-
12
- /**
13
- * Make a new API Exception with the given result.
14
- *
15
- * @param array $result The result from the API server.
16
- */
17
- public function __construct($result)
18
- {
19
- $this->_result = $result;
20
-
21
- $code = 0;
22
- $message = 'Unknown error, please check GetResult().';
23
- $type = '';
24
-
25
- if (isset($result['error']) && is_array($result['error']))
26
- {
27
- if (isset($result['error']['code']))
28
- $code = $result['error']['code'];
29
- if (isset($result['error']['message']))
30
- $message = $result['error']['message'];
31
- if (isset($result['error']['type']))
32
- $type = $result['error']['type'];
33
- }
34
-
35
- $this->_type = $type;
36
- $this->_code = $code;
37
-
38
- parent::__construct($message, is_numeric($code) ? $code : 0);
39
- }
40
-
41
- /**
42
- * Return the associated result object returned by the API server.
43
- *
44
- * @return array The result from the API server
45
- */
46
- public function getResult()
47
- {
48
- return $this->_result;
49
- }
50
-
51
- public function getStringCode()
52
- {
53
- return $this->_code;
54
- }
55
-
56
- public function getType()
57
- {
58
- return $this->_type;
59
- }
60
-
61
- /**
62
- * To make debugging easier.
63
- *
64
- * @return string The string representation of the error
65
- */
66
- public function __toString()
67
- {
68
- $str = $this->getType() . ': ';
69
-
70
- if ($this->code != 0)
71
- $str .= $this->getStringCode() . ': ';
72
-
73
- return $str . $this->getMessage();
74
- }
75
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/sdk/Exceptions/InvalidArgumentException.php DELETED
@@ -1,2 +0,0 @@
1
- <?php
2
- class Freemius_InvalidArgumentException extends Freemius_Exception { }
 
 
freemius/includes/sdk/Exceptions/OAuthException.php DELETED
@@ -1,8 +0,0 @@
1
- <?php
2
- class Freemius_OAuthException extends Freemius_Exception
3
- {
4
- public function __construct($pResult)
5
- {
6
- parent::__construct($pResult);
7
- }
8
- }
 
 
 
 
 
 
 
 
freemius/includes/sdk/Freemius.php DELETED
@@ -1,403 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2014 Freemius, Inc.
4
- *
5
- * Licensed under the GPL v2 (the "License"); you may
6
- * not use this file except in compliance with the License. You may obtain
7
- * a copy of the License at
8
- *
9
- * http://choosealicense.com/licenses/gpl-v2/
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations
15
- * under the License.
16
- */
17
-
18
- require_once( dirname( __FILE__ ) . '/FreemiusBase.php' );
19
-
20
- define( 'FS_SDK__USER_AGENT', 'fs-php-' . Freemius_Api_Base::VERSION );
21
-
22
- if ( ! defined( 'FS_SDK__SIMULATE_NO_CURL' ) ) {
23
- define( 'FS_SDK__SIMULATE_NO_CURL', false );
24
- }
25
-
26
- if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE' ) ) {
27
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE', false );
28
- }
29
-
30
- if ( ! defined( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL' ) ) {
31
- define( 'FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL', false );
32
- }
33
-
34
- define( 'FS_SDK__HAS_CURL', ! FS_SDK__SIMULATE_NO_CURL && function_exists( 'curl_version' ) );
35
-
36
- if ( ! FS_SDK__HAS_CURL ) {
37
- $curl_version = array( 'version' => '7.0.0' );
38
- } else {
39
- $curl_version = curl_version();
40
- }
41
-
42
- define( 'FS_API__PROTOCOL', version_compare( $curl_version['version'], '7.37', '>=' ) ? 'https' : 'http' );
43
-
44
- if ( ! defined( 'FS_API__ADDRESS' ) ) {
45
- define( 'FS_API__ADDRESS', '://api.freemius.com' );
46
- }
47
- if ( ! defined( 'FS_API__SANDBOX_ADDRESS' ) ) {
48
- define( 'FS_API__SANDBOX_ADDRESS', '://sandbox-api.freemius.com' );
49
- }
50
-
51
- class Freemius_Api extends Freemius_Api_Base {
52
- /**
53
- * Default options for curl.
54
- */
55
- public static $CURL_OPTS = array(
56
- CURLOPT_CONNECTTIMEOUT => 10,
57
- CURLOPT_RETURNTRANSFER => true,
58
- CURLOPT_TIMEOUT => 60,
59
- CURLOPT_USERAGENT => FS_SDK__USER_AGENT,
60
- );
61
-
62
- /**
63
- * @param string $pScope 'app', 'developer', 'user' or 'install'.
64
- * @param number $pID Element's id.
65
- * @param string $pPublic Public key.
66
- * @param string|bool $pSecret Element's secret key.
67
- * @param bool $pSandbox Whether or not to run API in sandbox mode.
68
- */
69
- public function __construct( $pScope, $pID, $pPublic, $pSecret = false, $pSandbox = false ) {
70
- // If secret key not provided, use public key encryption.
71
- if ( is_bool( $pSecret ) ) {
72
- $pSecret = $pPublic;
73
- }
74
-
75
- parent::Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox );
76
- }
77
-
78
- public function GetUrl( $pCanonizedPath = '' ) {
79
- $address = ( $this->_sandbox ? FS_API__SANDBOX_ADDRESS : FS_API__ADDRESS );
80
-
81
- if ( ':' === $address[0] ) {
82
- $address = self::$_protocol . $address;
83
- }
84
-
85
- return $address . $pCanonizedPath;
86
- }
87
-
88
- /**
89
- * @var int Clock diff in seconds between current server to API server.
90
- */
91
- private static $_clock_diff = 0;
92
-
93
- /**
94
- * Set clock diff for all API calls.
95
- *
96
- * @since 1.0.3
97
- *
98
- * @param $pSeconds
99
- */
100
- public static function SetClockDiff( $pSeconds ) {
101
- self::$_clock_diff = $pSeconds;
102
- }
103
-
104
- /**
105
- * @var string http or https
106
- */
107
- private static $_protocol = FS_API__PROTOCOL;
108
-
109
- /**
110
- * Set API connection protocol.
111
- *
112
- * @since 1.0.4
113
- */
114
- public static function SetHttp() {
115
- self::$_protocol = 'http';
116
- }
117
-
118
- /**
119
- * @since 1.0.4
120
- *
121
- * @return bool
122
- */
123
- public static function IsHttps() {
124
- return ( 'https' === self::$_protocol );
125
- }
126
-
127
- /**
128
- * Sign request with the following HTTP headers:
129
- * Content-MD5: MD5(HTTP Request body)
130
- * Date: Current date (i.e Sat, 14 Feb 2015 20:24:46 +0000)
131
- * Authorization: FS {scope_entity_id}:{scope_entity_public_key}:base64encode(sha256(string_to_sign,
132
- * {scope_entity_secret_key}))
133
- *
134
- * @param string $pResourceUrl
135
- * @param array $opts
136
- */
137
- protected function SignRequest( $pResourceUrl, &$opts ) {
138
- $eol = "\n";
139
- $content_md5 = '';
140
- $now = ( time() - self::$_clock_diff );
141
- $date = date( 'r', $now );
142
- $content_type = '';
143
-
144
- if ( isset( $opts[ CURLOPT_POST ] ) && 0 < $opts[ CURLOPT_POST ] ) {
145
- $content_md5 = md5( $opts[ CURLOPT_POSTFIELDS ] );
146
- $opts[ CURLOPT_HTTPHEADER ][] = 'Content-MD5: ' . $content_md5;
147
- $content_type = 'application/json';
148
- }
149
-
150
- $opts[ CURLOPT_HTTPHEADER ][] = 'Date: ' . $date;
151
-
152
- $string_to_sign = implode( $eol, array(
153
- $opts[ CURLOPT_CUSTOMREQUEST ],
154
- $content_md5,
155
- $content_type,
156
- $date,
157
- $pResourceUrl
158
- ) );
159
-
160
- // If secret and public keys are identical, it means that
161
- // the signature uses public key hash encoding.
162
- $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
163
-
164
- // Add authorization header.
165
- $opts[ CURLOPT_HTTPHEADER ][] = 'Authorization: ' .
166
- $auth_type . ' ' .
167
- $this->_id . ':' .
168
- $this->_public . ':' .
169
- self::Base64UrlEncode(
170
- hash_hmac( 'sha256', $string_to_sign, $this->_secret )
171
- );
172
- }
173
-
174
- /**
175
- * Get API request URL signed via query string.
176
- *
177
- * @param string $pPath
178
- *
179
- * @throws Freemius_Exception
180
- *
181
- * @return string
182
- */
183
- function GetSignedUrl( $pPath ) {
184
- $resource = explode( '?', $this->CanonizePath( $pPath ) );
185
- $pResourceUrl = $resource[0];
186
-
187
- $eol = "\n";
188
- $content_md5 = '';
189
- $content_type = '';
190
- $now = ( time() - self::$_clock_diff );
191
- $date = date( 'r', $now );
192
-
193
- $string_to_sign = implode( $eol, array(
194
- 'GET',
195
- $content_md5,
196
- $content_type,
197
- $date,
198
- $pResourceUrl
199
- ) );
200
-
201
- // If secret and public keys are identical, it means that
202
- // the signature uses public key hash encoding.
203
- $auth_type = ( $this->_secret !== $this->_public ) ? 'FS' : 'FSP';
204
-
205
- return $this->GetUrl(
206
- $pResourceUrl . '?' .
207
- ( 1 < count( $resource ) && ! empty( $resource[1] ) ? $resource[1] . '&' : '' ) .
208
- http_build_query( array(
209
- 'auth_date' => $date,
210
- 'authorization' => $auth_type . ' ' . $this->_id . ':' .
211
- $this->_public . ':' .
212
- self::Base64UrlEncode( hash_hmac(
213
- 'sha256', $string_to_sign, $this->_secret
214
- ) )
215
- ) ) );
216
- }
217
-
218
- /**
219
- * Makes an HTTP request. This method can be overridden by subclasses if
220
- * developers want to do fancier things or use something other than curl to
221
- * make the request.
222
- *
223
- * @param string $pCanonizedPath The URL to make the request to
224
- * @param string $pMethod HTTP method
225
- * @param array $params The parameters to use for the POST body
226
- * @param null|resource $ch Initialized curl handle
227
- *
228
- * @return object[]|object|null
229
- *
230
- * @throws Freemius_Exception
231
- */
232
- public function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $params = array(), $ch = null ) {
233
- if ( !FS_SDK__HAS_CURL ) {
234
- $this->ThrowNoCurlException();
235
- }
236
-
237
- // Connectivity errors simulation.
238
- if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_CLOUDFLARE ) {
239
- $this->ThrowCloudFlareDDoSException();
240
- } else if ( FS_SDK__SIMULATE_NO_API_CONNECTIVITY_SQUID_ACL ) {
241
- $this->ThrowSquidAclException();
242
- }
243
-
244
- if ( ! $ch ) {
245
- $ch = curl_init();
246
- }
247
-
248
- $opts = self::$CURL_OPTS;
249
-
250
- if ( ! isset( $opts[ CURLOPT_HTTPHEADER ] ) || ! is_array( $opts[ CURLOPT_HTTPHEADER ] ) ) {
251
- $opts[ CURLOPT_HTTPHEADER ] = array();
252
- }
253
-
254
- if ( 'POST' === $pMethod || 'PUT' === $pMethod ) {
255
- if ( is_array( $params ) && 0 < count( $params ) ) {
256
- $opts[ CURLOPT_HTTPHEADER ][] = 'Content-Type: application/json';
257
- $opts[ CURLOPT_POST ] = count( $params );
258
- $opts[ CURLOPT_POSTFIELDS ] = json_encode( $params );
259
- }
260
-
261
- $opts[ CURLOPT_RETURNTRANSFER ] = true;
262
- }
263
-
264
- $opts[ CURLOPT_URL ] = $this->GetUrl( $pCanonizedPath );
265
- $opts[ CURLOPT_CUSTOMREQUEST ] = $pMethod;
266
-
267
- $resource = explode( '?', $pCanonizedPath );
268
-
269
- // Only sign request if not ping.json connectivity test.
270
- if ( '/v1/ping.json' !== strtolower( substr( $resource[0], - strlen( '/v1/ping.json' ) ) ) ) {
271
- $this->SignRequest( $resource[0], $opts );
272
- }
273
-
274
- // disable the 'Expect: 100-continue' behaviour. This causes CURL to wait
275
- // for 2 seconds if the server does not support this header.
276
- $opts[ CURLOPT_HTTPHEADER ][] = 'Expect:';
277
-
278
- if ( 'https' === substr( strtolower( $pCanonizedPath ), 0, 5 ) ) {
279
- $opts[ CURLOPT_SSL_VERIFYHOST ] = false;
280
- $opts[ CURLOPT_SSL_VERIFYPEER ] = false;
281
- }
282
-
283
- curl_setopt_array( $ch, $opts );
284
- $result = curl_exec( $ch );
285
-
286
- /*if (curl_errno($ch) == 60) // CURLE_SSL_CACERT
287
- {
288
- self::errorLog('Invalid or no certificate authority found, using bundled information');
289
- curl_setopt($ch, CURLOPT_CAINFO,
290
- dirname(__FILE__) . '/fb_ca_chain_bundle.crt');
291
- $result = curl_exec($ch);
292
- }*/
293
-
294
- // With dual stacked DNS responses, it's possible for a server to
295
- // have IPv6 enabled but not have IPv6 connectivity. If this is
296
- // the case, curl will try IPv4 first and if that fails, then it will
297
- // fall back to IPv6 and the error EHOSTUNREACH is returned by the
298
- // operating system.
299
- if ( false === $result && empty( $opts[ CURLOPT_IPRESOLVE ] ) ) {
300
- $matches = array();
301
- $regex = '/Failed to connect to ([^:].*): Network is unreachable/';
302
- if ( preg_match( $regex, curl_error( $ch ), $matches ) ) {
303
- if ( strlen( @inet_pton( $matches[1] ) ) === 16 ) {
304
- // self::errorLog('Invalid IPv6 configuration on server, Please disable or get native IPv6 on your server.');
305
- self::$CURL_OPTS[ CURLOPT_IPRESOLVE ] = CURL_IPRESOLVE_V4;
306
- curl_setopt( $ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 );
307
- $result = curl_exec( $ch );
308
- }
309
- }
310
- }
311
-
312
- if ( $result === false ) {
313
- $e = new Freemius_Exception( array(
314
- 'error' => array(
315
- 'code' => curl_errno( $ch ),
316
- 'message' => curl_error( $ch ),
317
- 'type' => 'CurlException',
318
- ),
319
- ) );
320
-
321
- curl_close( $ch );
322
- throw $e;
323
- }
324
-
325
- curl_close( $ch );
326
-
327
- if (empty($result))
328
- return null;
329
-
330
- $decoded = json_decode( $result );
331
-
332
- if ( is_null( $decoded ) ) {
333
- if ( preg_match( '/Please turn JavaScript on/i', $result ) &&
334
- preg_match( '/text\/javascript/', $result )
335
- ) {
336
- $this->ThrowCloudFlareDDoSException( $result );
337
- } 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 ) &&
338
- preg_match( '/squid/', $result )
339
- ) {
340
- $this->ThrowSquidAclException( $result );
341
- } else {
342
- $decoded = (object) array(
343
- 'error' => (object) array(
344
- 'type' => 'Unknown',
345
- 'message' => $result,
346
- 'code' => 'unknown',
347
- 'http' => 402
348
- )
349
- );
350
- }
351
- }
352
-
353
- return $decoded;
354
- }
355
-
356
- /**
357
- * @param string $pResult
358
- *
359
- * @throws Freemius_Exception
360
- */
361
- private function ThrowNoCurlException( $pResult = '' ) {
362
- throw new Freemius_Exception( array(
363
- 'error' => (object) array(
364
- 'type' => 'cUrlMissing',
365
- 'message' => $pResult,
366
- 'code' => 'curl_missing',
367
- 'http' => 402
368
- )
369
- ) );
370
- }
371
-
372
- /**
373
- * @param string $pResult
374
- *
375
- * @throws Freemius_Exception
376
- */
377
- private function ThrowCloudFlareDDoSException( $pResult = '' ) {
378
- throw new Freemius_Exception( array(
379
- 'error' => (object) array(
380
- 'type' => 'CloudFlareDDoSProtection',
381
- 'message' => $pResult,
382
- 'code' => 'cloudflare_ddos_protection',
383
- 'http' => 402
384
- )
385
- ) );
386
- }
387
-
388
- /**
389
- * @param string $pResult
390
- *
391
- * @throws Freemius_Exception
392
- */
393
- private function ThrowSquidAclException( $pResult = '' ) {
394
- throw new Freemius_Exception( array(
395
- 'error' => (object) array(
396
- 'type' => 'SquidCacheBlock',
397
- 'message' => $pResult,
398
- 'code' => 'squid_cache_block',
399
- 'http' => 402
400
- )
401
- ) );
402
- }
403
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/sdk/FreemiusBase.php DELETED
@@ -1,217 +0,0 @@
1
- <?php
2
- /**
3
- * Copyright 2014 Freemius, Inc.
4
- *
5
- * Licensed under the GPL v2 (the "License"); you may
6
- * not use this file except in compliance with the License. You may obtain
7
- * a copy of the License at
8
- *
9
- * http://choosealicense.com/licenses/gpl-v2/
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14
- * License for the specific language governing permissions and limitations
15
- * under the License.
16
- */
17
-
18
- define( 'FS_API__VERSION', '1' );
19
- define( 'FS_SDK__PATH', dirname( __FILE__ ) );
20
- define( 'FS_SDK__EXCEPTIONS_PATH', FS_SDK__PATH . '/Exceptions/' );
21
-
22
- if ( ! function_exists( 'json_decode' ) ) {
23
- throw new Exception( 'Freemius needs the JSON PHP extension.' );
24
- }
25
-
26
- // Include all exception files.
27
- $exceptions = array(
28
- 'Exception',
29
- 'InvalidArgumentException',
30
- 'ArgumentNotExistException',
31
- 'EmptyArgumentException',
32
- 'OAuthException'
33
- );
34
-
35
- foreach ( $exceptions as $e ) {
36
- require FS_SDK__EXCEPTIONS_PATH . $e . '.php';
37
- }
38
-
39
- abstract class Freemius_Api_Base {
40
- const VERSION = '1.0.4';
41
- const FORMAT = 'json';
42
-
43
- protected $_id;
44
- protected $_public;
45
- protected $_secret;
46
- protected $_scope;
47
- protected $_sandbox;
48
-
49
- /**
50
- * @param string $pScope 'app', 'developer', 'user' or 'install'.
51
- * @param number $pID Element's id.
52
- * @param string $pPublic Public key.
53
- * @param string $pSecret Element's secret key.
54
- * @param bool $pSandbox Whether or not to run API in sandbox mode.
55
- */
56
- public function Init( $pScope, $pID, $pPublic, $pSecret, $pSandbox = false ) {
57
- $this->_id = $pID;
58
- $this->_public = $pPublic;
59
- $this->_secret = $pSecret;
60
- $this->_scope = $pScope;
61
- $this->_sandbox = $pSandbox;
62
- }
63
-
64
- public function IsSandbox() {
65
- return $this->_sandbox;
66
- }
67
-
68
- function CanonizePath( $pPath ) {
69
- $pPath = trim( $pPath, '/' );
70
- $query_pos = strpos( $pPath, '?' );
71
- $query = '';
72
-
73
- if ( false !== $query_pos ) {
74
- $query = substr( $pPath, $query_pos );
75
- $pPath = substr( $pPath, 0, $query_pos );
76
- }
77
-
78
- // Trim '.json' suffix.
79
- $format_length = strlen( '.' . self::FORMAT );
80
- $start = $format_length * ( - 1 ); //negative
81
- if ( substr( strtolower( $pPath ), $start ) === ( '.' . self::FORMAT ) ) {
82
- $pPath = substr( $pPath, 0, strlen( $pPath ) - $format_length );
83
- }
84
-
85
- switch ( $this->_scope ) {
86
- case 'app':
87
- $base = '/apps/' . $this->_id;
88
- break;
89
- case 'developer':
90
- $base = '/developers/' . $this->_id;
91
- break;
92
- case 'user':
93
- $base = '/users/' . $this->_id;
94
- break;
95
- case 'plugin':
96
- $base = '/plugins/' . $this->_id;
97
- break;
98
- case 'install':
99
- $base = '/installs/' . $this->_id;
100
- break;
101
- default:
102
- throw new Freemius_Exception( 'Scope not implemented.' );
103
- }
104
-
105
- return '/v' . FS_API__VERSION . $base .
106
- ( ! empty( $pPath ) ? '/' : '' ) . $pPath .
107
- ( ( false === strpos( $pPath, '.' ) ) ? '.' . self::FORMAT : '' ) . $query;
108
- }
109
-
110
- abstract function MakeRequest( $pCanonizedPath, $pMethod = 'GET', $pParams = array() );
111
-
112
- /**
113
- * @param string $pPath
114
- * @param string $pMethod
115
- * @param array $pParams
116
- *
117
- * @return object[]|object|null
118
- */
119
- private function _Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
120
- $pMethod = strtoupper( $pMethod );
121
-
122
- try {
123
- $result = $this->MakeRequest( $pPath, $pMethod, $pParams );
124
- } catch ( Freemius_Exception $e ) {
125
- // Map to error object.
126
- $result = (object) $e->getResult();
127
- } catch ( Exception $e ) {
128
- // Map to error object.
129
- $result = (object) array(
130
- 'error' => array(
131
- 'type' => 'Unknown',
132
- 'message' => $e->getMessage() . ' (' . $e->getFile() . ': ' . $e->getLine() . ')',
133
- 'code' => 'unknown',
134
- 'http' => 402
135
- )
136
- );
137
- }
138
-
139
- return $result;
140
- }
141
-
142
- /**
143
- * If successful connectivity to the API endpoint using ping.json endpoint.
144
- *
145
- * - OR -
146
- *
147
- * Validate if ping result object is valid.
148
- *
149
- * @param mixed $pPong
150
- *
151
- * @return bool
152
- */
153
- public function Test( $pPong = null ) {
154
- $pong = is_null( $pPong ) ? $this->Ping() : $pPong;
155
-
156
- return ( is_object( $pong ) && isset( $pong->api ) && 'pong' === $pong->api );
157
- }
158
-
159
- /**
160
- * Ping API to test connectivity.
161
- *
162
- * @return object
163
- */
164
- public function Ping() {
165
- return $this->_Api( '/v' . FS_API__VERSION . '/ping.json' );
166
- }
167
-
168
- /**
169
- * Find clock diff between current server to API server.
170
- *
171
- * @since 1.0.2
172
- * @return int Clock diff in seconds.
173
- */
174
- public function FindClockDiff() {
175
- $time = time();
176
- $pong = $this->_Api( '/v' . FS_API__VERSION . '/ping.json' );
177
-
178
- return ( $time - strtotime( $pong->timestamp ) );
179
- }
180
-
181
- public function Api( $pPath, $pMethod = 'GET', $pParams = array() ) {
182
- return $this->_Api( $this->CanonizePath( $pPath ), $pMethod, $pParams );
183
- }
184
-
185
- /**
186
- * Base64 encoding that does not need to be urlencode()ed.
187
- * Exactly the same as base64_encode except it uses
188
- * - instead of +
189
- * _ instead of /
190
- * No padded =
191
- *
192
- * @param string $input base64UrlEncoded string
193
- *
194
- * @return string
195
- */
196
- protected static function Base64UrlDecode( $input ) {
197
- return base64_decode( strtr( $input, '-_', '+/' ) );
198
- }
199
-
200
- /**
201
- * Base64 encoding that does not need to be urlencode()ed.
202
- * Exactly the same as base64_encode except it uses
203
- * - instead of +
204
- * _ instead of /
205
- *
206
- * @param string $input string
207
- *
208
- * @return string base64Url encoded string
209
- */
210
- protected static function Base64UrlEncode( $input ) {
211
- $str = strtr( base64_encode( $input ), '+/', '-_' );
212
- $str = str_replace( '=', '', $str );
213
-
214
- return $str;
215
- }
216
-
217
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/includes/sdk/LICENSE.txt DELETED
@@ -1,340 +0,0 @@
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/start.php DELETED
@@ -1,95 +0,0 @@
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
- * Freemius hooks collection:
15
- * fs_after_license_loaded
16
- */
17
-
18
- if ( ! class_exists( 'Freemius' ) ) {
19
-
20
- // Configuration should be loaded first.
21
- require_once dirname( __FILE__ ) . '/config.php';
22
-
23
- // Logger must be loaded before any other.
24
- require_once WP_FS__DIR_INCLUDES . '/class-fs-logger.php';
25
-
26
- require_once WP_FS__DIR_INCLUDES . '/fs-core-functions.php';
27
- // require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-abstract-manager.php';
28
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-option-manager.php';
29
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-notice-manager.php';
30
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-admin-menu-manager.php';
31
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-key-value-storage.php';
32
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-license-manager.php';
33
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plan-manager.php';
34
- require_once WP_FS__DIR_INCLUDES . '/managers/class-fs-plugin-manager.php';
35
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-entity.php';
36
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-scope-entity.php';
37
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-user.php';
38
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-site.php';
39
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin.php';
40
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-info.php';
41
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-tag.php';
42
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-plan.php';
43
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-plugin-license.php';
44
- require_once WP_FS__DIR_INCLUDES . '/entities/class-fs-subscription.php';
45
- require_once WP_FS__DIR_INCLUDES . '/class-fs-api.php';
46
- require_once WP_FS__DIR_INCLUDES . '/class-fs-plugin-updater.php';
47
- require_once WP_FS__DIR_INCLUDES . '/class-fs-security.php';
48
- require_once WP_FS__DIR_INCLUDES . '/class-freemius-abstract.php';
49
- require_once WP_FS__DIR_INCLUDES . '/class-freemius.php';
50
-
51
- /**
52
- * Quick shortcut to get Freemius for specified plugin.
53
- * Used by various templates.
54
- *
55
- * @param string $slug
56
- *
57
- * @return Freemius
58
- */
59
- function freemius( $slug ) {
60
- return Freemius::instance( $slug );
61
- }
62
-
63
- /**
64
- * @param string $slug
65
- * @param number $plugin_id
66
- * @param string $public_key
67
- * @param bool $is_live Is live or test plugin.
68
- * @param bool $is_premium Hints freemius if running the premium plugin or not.
69
- *
70
- * @return Freemius
71
- */
72
- function fs_init( $slug, $plugin_id, $public_key, $is_live = true, $is_premium = true ) {
73
- $fs = Freemius::instance( $slug );
74
- $fs->init( $plugin_id, $public_key, $is_live, $is_premium );
75
-
76
- return $fs;
77
- }
78
-
79
- /**
80
- * @param array [string]string $plugin
81
- *
82
- * @return Freemius
83
- * @throws Freemius_Exception
84
- */
85
- function fs_dynamic_init( $plugin ) {
86
- $fs = Freemius::instance( $plugin['slug'] );
87
- $fs->dynamic_init( $plugin );
88
-
89
- return $fs;
90
- }
91
-
92
- function fs_dump_log() {
93
- FS_Logger::dump();
94
- }
95
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/account.php DELETED
@@ -1,442 +0,0 @@
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
- $slug = $VARS['slug'];
10
- /**
11
- * @var Freemius $fs
12
- */
13
- $fs = freemius( $slug );
14
-
15
- /**
16
- * @var FS_Plugin_Tag $update
17
- */
18
- $update = $fs->get_update();
19
-
20
- $is_paying = $fs->is_paying();
21
- $user = $fs->get_user();
22
- $site = $fs->get_site();
23
- $name = $user->get_name();
24
- $license = $fs->_get_license();
25
- $subscription = $fs->_get_subscription();
26
- $plan = $fs->get_plan();
27
- $is_active_subscription = ( is_object( $subscription ) && $subscription->is_active() );
28
- ?>
29
-
30
- <div class="wrap">
31
- <h2 class="nav-tab-wrapper">
32
- <a href="<?php $fs->get_account_url() ?>" class="nav-tab nav-tab-active"><?php _efs( 'account' ) ?></a>
33
- <?php if ( $fs->_has_addons() ) : ?>
34
- <a href="<?php echo $fs->_get_admin_page_url( 'addons' ) ?>" class="nav-tab"><?php _efs( 'add-ons' ) ?></a>
35
- <?php endif ?>
36
- <?php if ( $fs->is_not_paying() && $fs->has_paid_plan() ) : ?>
37
- <a href="<?php echo $fs->get_upgrade_url() ?>" class="nav-tab"><?php _efs( 'upgrade' ) ?></a>
38
- <?php if ( ! $fs->is_trial_utilized() && $fs->has_trial_plan() ) : ?>
39
- <a href="<?php echo $fs->get_trial_url() ?>" class="nav-tab"><?php _efs( 'free-trial' ) ?></a>
40
- <?php endif ?>
41
- <?php endif ?>
42
- </h2>
43
-
44
- <div id="poststuff">
45
- <div id="fs_account">
46
- <div class="has-sidebar has-right-sidebar">
47
- <div class="has-sidebar-content">
48
- <div class="postbox">
49
- <h3><?php _efs( 'account-details' ) ?></h3>
50
-
51
- <div class="fs-header-actions">
52
- <ul>
53
- <li>
54
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
55
- <input type="hidden" name="fs_action" value="delete_account">
56
- <?php wp_nonce_field( 'delete_account' ) ?>
57
- <a href="#" onclick="if (confirm('<?php
58
- if ( $is_active_subscription ) {
59
- echo esc_attr( sprintf( __fs( 'delete-account-x-confirm' ), $plan->title ) );
60
- } else {
61
- _efs( 'delete-account-confirm' );
62
- }
63
- ?>')) this.parentNode.submit(); return false;"><?php _efs( 'delete-account' ) ?></a>
64
- </form>
65
- </li>
66
- <?php if ( $is_paying ) : ?>
67
- <li>
68
- &nbsp;•&nbsp;
69
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
70
- <input type="hidden" name="fs_action" value="deactivate_license">
71
- <?php wp_nonce_field( 'deactivate_license' ) ?>
72
- <a href="#"
73
- onclick="if (confirm('<?php _efs( 'deactivate-license-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'deactivate-license' ) ?></a>
74
- </form>
75
- </li>
76
- <?php if ( ! $license->is_lifetime() &&
77
- $is_active_subscription
78
- ) : ?>
79
- <li>
80
- &nbsp;•&nbsp;
81
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
82
- <input type="hidden" name="fs_action" value="downgrade_account">
83
- <?php wp_nonce_field( 'downgrade_account' ) ?>
84
- <a href="#"
85
- onclick="if (confirm('<?php printf( __fs( 'downgrade-x-confirm' ), $plan->title, human_time_diff( time(), strtotime( $license->expiration ) ) ) ?> <?php if ( ! $license->is_block_features ) {
86
- printf( __fs( 'after-downgrade-non-blocking' ), $plan->title );
87
- } else {
88
- printf( __fs( 'after-downgrade-blocking' ), $plan->title );
89
- }?> <?php _efs( 'proceed-confirmation' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'downgrade' ) ?></a>
90
- </form>
91
- </li>
92
- <?php endif ?>
93
- <li>
94
- &nbsp;•&nbsp;
95
- <a href="<?php echo $fs->get_upgrade_url() ?>"><?php _efs( 'change-plan' ) ?></a>
96
- </li>
97
- <?php endif ?>
98
- </ul>
99
- </div>
100
- <div class="inside">
101
- <table id="fs_account_details" cellspacing="0" class="fs-key-value-table">
102
- <?php
103
- $profile = array();
104
- $profile[] = array(
105
- 'id' => 'user_name',
106
- 'title' => __fs( 'name' ),
107
- 'value' => $name
108
- );
109
- // if (isset($user->email) && false !== strpos($user->email, '@'))
110
- $profile[] = array(
111
- 'id' => 'email',
112
- 'title' => __fs( 'email' ),
113
- 'value' => $user->email
114
- );
115
- if ( is_numeric( $user->id ) ) {
116
- $profile[] = array(
117
- 'id' => 'user_id',
118
- 'title' => __fs( 'user-id' ),
119
- 'value' => $user->id
120
- );
121
- }
122
-
123
- $profile[] = array(
124
- 'id' => 'site_id',
125
- 'title' => __fs( 'site-id' ),
126
- 'value' => is_string( $site->id ) ?
127
- $site->id :
128
- __fs( 'no-id' )
129
- );
130
-
131
- $profile[] = array(
132
- 'id' => 'site_public_key',
133
- 'title' => __fs( 'public-key' ),
134
- 'value' => $site->public_key
135
- );
136
-
137
- $profile[] = array(
138
- 'id' => 'site_secret_key',
139
- 'title' => __fs( 'secret-key' ),
140
- 'value' => ( ( is_string( $site->secret_key ) ) ?
141
- $site->secret_key :
142
- __fs( 'no-secret' )
143
- )
144
- );
145
-
146
- if ( $fs->is_trial() ) {
147
- $trial_plan = $fs->get_trial_plan();
148
-
149
- $profile[] = array(
150
- 'id' => 'plan',
151
- 'title' => __fs( 'plan' ),
152
- 'value' => ( is_string( $trial_plan->name ) ?
153
- strtoupper( $trial_plan->title ) . ' ' :
154
- '' ) . strtoupper( __fs( 'trial' ) )
155
- );
156
- } else {
157
- $profile[] = array(
158
- 'id' => 'plan',
159
- 'title' => __fs( 'plan' ),
160
- 'value' => is_string( $site->plan->name ) ?
161
- strtoupper( $site->plan->title ) :
162
- strtoupper( __fs( 'free' ) )
163
- );
164
- }
165
-
166
- $profile[] = array(
167
- 'id' => 'version',
168
- 'title' => __fs( 'version' ),
169
- 'value' => $fs->get_plugin_version()
170
- );
171
- ?>
172
- <?php $odd = true;
173
- foreach ( $profile as $p ) : ?>
174
- <?php
175
- if ( 'plan' === $p['id'] && ! $fs->has_paid_plan() ) {
176
- // If plugin don't have any paid plans, there's no reason
177
- // to show current plan.
178
- continue;
179
- }
180
- ?>
181
- <tr class="fs-field-<?php echo $p['id'] ?><?php if ( $odd ) : ?> alternate<?php endif ?>">
182
- <td>
183
- <nobr><?php echo $p['title'] ?>:</nobr>
184
- </td>
185
- <td>
186
- <code><?php echo htmlspecialchars( $p['value'] ) ?></code>
187
- <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
188
- <label><?php _efs( 'not-verified' ) ?></label>
189
- <?php endif ?>
190
- <?php if ( 'plan' === $p['id'] ) : ?>
191
- <?php if ( $fs->is_trial() ) : ?>
192
- <label><?php printf( __fs( 'expires-in' ), human_time_diff( time(), strtotime( $site->trial_ends ) ) ) ?></label>
193
- <?php elseif ( is_object( $license ) && ! $license->is_lifetime() ) : ?>
194
- <?php if ( ! $is_active_subscription && ! $license->is_first_payment_pending() ) : ?>
195
- <label><?php printf( __fs( 'expires-in' ), human_time_diff( time(), strtotime( $license->expiration ) ) ) ?></label>
196
- <?php elseif ( $is_active_subscription && ! $subscription->is_first_payment_pending() ) : ?>
197
- <label><?php printf( __fs( 'renews-in' ), human_time_diff( time(), strtotime( $subscription->next_payment ) ) ) ?></label>
198
- <?php endif ?>
199
- <?php endif ?>
200
- <?php endif ?>
201
-
202
- </td>
203
- <td class="fs-right">
204
- <?php if ( 'email' === $p['id'] && ! $user->is_verified() ) : ?>
205
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST">
206
- <input type="hidden" name="fs_action" value="verify_email">
207
- <?php wp_nonce_field( 'verify_email' ) ?>
208
- <input type="submit" class="button button-small"
209
- value="<?php _efs( 'verify-email' ) ?>">
210
- </form>
211
- <?php endif ?>
212
- <?php if ( 'plan' === $p['id'] ) : ?>
213
- <div class="button-group">
214
- <?php $license = $fs->is_not_paying() ? $fs->_get_available_premium_license() : false ?>
215
- <?php if ( false !== $license && ( $license->left() > 0 || ( $site->is_localhost() && $license->is_free_localhost ) ) ) : ?>
216
- <?php $premium_plan = $fs->_get_plan_by_id( $license->plan_id ) ?>
217
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
218
- method="POST">
219
- <input type="hidden" name="fs_action" value="activate_license">
220
- <?php wp_nonce_field( 'activate_license' ) ?>
221
- <input type="submit" class="button button-primary"
222
- value="<?php printf(
223
- __fs( 'activate-x-plan' ),
224
- $premium_plan->title,
225
- ( $site->is_localhost() && $license->is_free_localhost ) ?
226
- '[' . __fs( 'localhost' ) . ']' :
227
- ( 1 < $license->left() ? $license->left() . ' left' : '' )
228
- ) ?> ">
229
- </form>
230
- <?php else : ?>
231
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>"
232
- method="POST" class="button-group">
233
- <input type="submit" class="button"
234
- value="<?php _efs( 'sync-license' ) ?>">
235
- <input type="hidden" name="fs_action"
236
- value="<?php echo $slug ?>_sync_license">
237
- <?php wp_nonce_field( $slug . '_sync_license' ) ?>
238
- <a href="<?php echo $fs->get_upgrade_url() ?>"
239
- class="button<?php if ( ! $is_paying ) {
240
- echo ' button-primary';
241
- } ?> button-upgrade"><?php ( ! $is_paying ) ?
242
- _efs( 'upgrade' ) :
243
- _efs( 'change-plan' )
244
- ?></a>
245
- </form>
246
- <?php endif ?>
247
- </div>
248
- <?php elseif ( 'version' === $p['id'] ) : ?>
249
- <div class="button-group">
250
- <?php if ( $is_paying || $fs->is_trial() ) : ?>
251
- <?php if ( ! $fs->is_allowed_to_install() ) : ?>
252
- <a target="_blank" class="button button-primary"
253
- href="<?php echo $fs->_get_latest_download_local_url() ?>"><?php echo sprintf( __fs( 'download-x-version' ), $site->plan->title ) . ( is_object( $update ) ? ' [' . $update->version . ']' : '' ) ?></a>
254
- <?php elseif ( is_object( $update ) ) : ?>
255
- <a class="button button-primary"
256
- href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' . $fs->get_plugin_basename() ), 'upgrade-plugin_' . $fs->get_plugin_basename() ) ?>"><?php echo __fs( 'install-update-now' ) . ' [' . $update->version . ']' ?></a>
257
- <?php endif ?>
258
- <?php endif; ?>
259
- </div>
260
- <?php
261
- elseif (/*in_array($p['id'], array('site_secret_key', 'site_id', 'site_public_key')) ||*/
262
- ( is_string( $user->secret_key ) && in_array( $p['id'], array(
263
- 'email',
264
- 'user_name'
265
- ) ) )
266
- ) : ?>
267
- <form action="<?php echo $fs->_get_admin_page_url( 'account' ) ?>" method="POST"
268
- onsubmit="var val = prompt('<?php printf( __fs( 'what-is-your-x' ), $p['title'] ) ?>', '<?php echo $p['value'] ?>'); if (null == val || '' === val) return false; jQuery('input[name=fs_<?php echo $p['id'] ?>_<?php echo $slug ?>]').val(val); return true;">
269
- <input type="hidden" name="fs_action" value="update_<?php echo $p['id'] ?>">
270
- <input type="hidden" name="fs_<?php echo $p['id'] ?>_<?php echo $slug ?>"
271
- value="">
272
- <?php wp_nonce_field( 'update_' . $p['id'] ) ?>
273
- <input type="submit" class="button button-small"
274
- value="<?php _ex( 'Edit', 'verb', 'freemius' ) ?>">
275
- </form>
276
- <?php endif ?>
277
- </td>
278
- </tr>
279
- <?php $odd = ! $odd; endforeach ?>
280
- </table>
281
- </div>
282
- </div>
283
- <?php
284
- $account_addons = $fs->get_account_addons();
285
- if ( ! is_array( $account_addons ) ) {
286
- $account_addons = array();
287
- }
288
-
289
- $installed_addons = $fs->get_installed_addons();
290
- $installed_addons_ids = array();
291
- foreach ( $installed_addons as $fs_addon ) {
292
- $installed_addons_ids[] = $fs_addon->get_id();
293
- }
294
-
295
- $addons_to_show = array_unique( array_merge( $installed_addons_ids, $account_addons ) );
296
- ?>
297
- <?php if ( 0 < count( $addons_to_show ) ) : ?>
298
- <div class="postbox">
299
- <table id="fs_addons" class="widefat">
300
- <thead>
301
- <tr>
302
- <th></th>
303
- <th><?php _efs( 'version' ) ?></th>
304
- <th><?php _efs( 'plan' ) ?></th>
305
- <th><?php _efs( 'expiration' ) ?></th>
306
- <th></th>
307
- <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
308
- <th></th>
309
- <?php endif ?>
310
- </tr>
311
- </thead>
312
- <tbody>
313
- <?php foreach ( $addons_to_show as $addon_id ) : ?>
314
- <?php
315
- $addon = $fs->get_addon( $addon_id );
316
- $is_addon_activated = $fs->is_addon_activated( $addon->slug );
317
-
318
- $fs_addon = $is_addon_activated ? freemius( $addon->slug ) : false;
319
- ?>
320
- <tr>
321
- <td>
322
- <?php echo $addon->title ?>
323
- </td>
324
- <?php if ( $is_addon_activated ) : ?>
325
- <?php // Add-on Installed ?>
326
- <?php $addon_site = $fs_addon->get_site(); ?>
327
- <td><?php echo $fs_addon->get_plugin_version() ?></td>
328
- <td><?php echo is_string( $addon_site->plan->name ) ? strtoupper( $addon_site->plan->title ) : 'FREE' ?></td>
329
- <?php
330
- $current_license = $fs_addon->_get_license();
331
- $is_current_license_expired = is_object( $current_license ) && $current_license->is_expired();
332
- ?>
333
- <?php if ( $fs_addon->is_not_paying() ) : ?>
334
- <?php if ( $is_current_license_expired ) : ?>
335
- <td><?php _efs( 'expired' ) ?></td>
336
- <?php endif ?>
337
- <?php $premium_license = $fs_addon->_get_available_premium_license() ?>
338
- <td<?php if ( ! $is_current_license_expired ) {
339
- echo ' colspan="2"';
340
- } ?>>
341
- <?php if ( is_object( $premium_license ) && ! $premium_license->is_utilized() ) : ?>
342
- <?php $site = $fs_addon->get_site() ?>
343
- <?php fs_ui_action_button(
344
- $slug, 'account',
345
- 'activate_license',
346
- sprintf( __fs( 'activate-x-plan' ), $fs_addon->get_plan_title(), ( $site->is_localhost() && $premium_license->is_free_localhost ) ? '[localhost]' : ( 1 < $premium_license->left() ? $premium_license->left() . ' left' : '' ) ),
347
- array( 'plugin_id' => $addon_id )
348
- ) ?>
349
- <?php else : ?>
350
- <div class="button-group">
351
- <?php fs_ui_action_button(
352
- $slug, 'account',
353
- $slug . '_sync_license',
354
- __fs( 'sync-license' ),
355
- array( 'plugin_id' => $addon_id ),
356
- false
357
- ) ?>
358
- <?php echo sprintf( '<a href="%s" class="thickbox button button-primary" aria-label="%s" data-title="%s">%s</a>',
359
- esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
360
- '&TB_iframe=true&width=600&height=550' ) ),
361
- esc_attr( sprintf( __fs( 'more-information-about-x' ), $addon->title ) ),
362
- esc_attr( $addon->title ),
363
- __fs( 'upgrade' )
364
- ) ?>
365
- </div>
366
- <?php endif ?>
367
- </td>
368
- <?php else : ?>
369
- <?php if ( is_object( $current_license ) ) : ?>
370
- <td><?php
371
- if ( $current_license->is_lifetime() ) {
372
- _efs( 'no-expiration' );
373
- } else if ( $current_license->is_expired() ) {
374
- _efs( 'expired' );
375
- } else {
376
- echo sprintf(
377
- __fs( 'in-x' ),
378
- human_time_diff( time(), strtotime( $current_license->expiration ) )
379
- );
380
- }
381
- ?></td>
382
- <td>
383
- <?php fs_ui_action_button(
384
- $slug, 'account',
385
- 'deactivate_license',
386
- __fs( 'deactivate-license' ),
387
- array( 'plugin_id' => $addon_id ),
388
- false
389
- ) ?>
390
- </td>
391
- <?php endif ?>
392
- <?php endif ?>
393
- <?php else : ?>
394
- <?php // Add-on NOT Installed
395
- ?>
396
- <td colspan="4">
397
- <?php if ( $fs->is_addon_installed( $addon->slug ) ) : ?>
398
- <?php $addon_file = $fs->get_addon_basename( $addon->slug ) ?>
399
- <a class="button button-primary"
400
- href="<?php echo wp_nonce_url( 'plugins.php?action=activate&amp;plugin=' . $addon_file, 'activate-plugin_' . $addon_file ) ?>"
401
- title="<?php esc_attr( __fs( 'activate-this-addon' ) ) ?>"
402
- class="edit"><?php _efs( 'activate' ) ?></a>
403
- <?php else : ?>
404
- <?php if ( $fs->is_allowed_to_install() ) : ?>
405
- <a class="button button-primary"
406
- href="<?php echo wp_nonce_url( self_admin_url( 'update.php?action=install-plugin&plugin=' . $addon->slug ), 'install-plugin_' . $addon->slug ) ?>"><?php _efs( 'install-now' ) ?></a>
407
- <?php else : ?>
408
- <a target="_blank" class="button button-primary"
409
- href="<?php echo $fs->_get_latest_download_local_url( $addon_id ) ?>"><?php _efs( 'download-latest' ) ?></a>
410
- <?php endif ?>
411
- <?php endif ?>
412
- </td>
413
- <?php endif ?>
414
- <?php if ( defined( 'WP_FS__DEV_MODE' ) && WP_FS__DEV_MODE ) : ?>
415
- <td>
416
- <?php
417
- if ( $is_addon_activated ) {
418
- fs_ui_action_button(
419
- $slug, 'account',
420
- 'delete_account',
421
- __fs( 'delete' ),
422
- array( 'plugin_id' => $addon_id ),
423
- false
424
- );
425
- }
426
- ?>
427
- </td>
428
- <?php endif ?>
429
- </tr>
430
- <?php endforeach ?>
431
- </tbody>
432
- </table>
433
- </div>
434
- <?php endif ?>
435
-
436
- <?php $fs->do_action( 'after_account_details' ) ?>
437
- </div>
438
- </div>
439
- </div>
440
- </div>
441
- </div>
442
- <?php fs_require_template( 'powered-by.php' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/add-ons.php DELETED
@@ -1,113 +0,0 @@
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
- $slug = $VARS['slug'];
10
- /**
11
- * @var Freemius
12
- */
13
- $fs = freemius( $slug );
14
-
15
- $open_addon_slug = fs_request_get( 'slug' );
16
-
17
- $open_addon = false;
18
-
19
- /**
20
- * @var FS_Plugin[]
21
- */
22
- $addons = $fs->get_addons();
23
- ?>
24
- <div id="fs_addons" class="wrap">
25
- <h2><?php printf( __fs( 'add-ons-for-x' ), $fs->get_plugin_name() ) ?></h2>
26
-
27
- <div id="poststuff">
28
- <ul class="fs-cards-list">
29
- <?php foreach ( $addons as $addon ) : ?>
30
- <?php
31
- $open_addon = ( $open_addon || ( $open_addon_slug === $addon->slug ) );
32
-
33
- $price = 0;
34
- $plans_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans.json" );
35
- if ( ! isset( $plans_result->error ) ) {
36
- $plans = $plans_result->plans;
37
- if ( is_array( $plans ) && 0 < count( $plans ) ) {
38
- $plan = $plans[0];
39
- $pricing_result = $fs->get_api_site_or_plugin_scope()->get( "/addons/{$addon->id}/plans/{$plan->id}/pricing.json" );
40
- if ( ! isset( $pricing_result->error ) ) {
41
- // Update plan's pricing.
42
- $plan->pricing = $pricing_result->pricing;
43
-
44
- if ( is_array( $plan->pricing ) && 0 < count( $plan->pricing ) ) {
45
- $min_price = 999999;
46
- foreach ( $plan->pricing as $pricing ) {
47
- if ( ! is_null( $pricing->annual_price ) && $pricing->annual_price > 0 ) {
48
- $min_price = min( $min_price, $pricing->annual_price );
49
- } else if ( ! is_null( $pricing->monthly_price ) && $pricing->monthly_price > 0 ) {
50
- $min_price = min( $min_price, 12 * $pricing->monthly_price );
51
- }
52
- }
53
-
54
- if ( $min_price < 999999 ) {
55
- $price = $min_price;
56
- }
57
- }
58
- }
59
- }
60
- }
61
- ?>
62
- <li class="fs-card" data-slug="<?php echo $addon->slug ?>">
63
- <?php
64
- echo sprintf( '<a href="%s" class="thickbox fs-overlay" aria-label="%s" data-title="%s"></a>',
65
- esc_url( network_admin_url( 'plugin-install.php?tab=plugin-information&parent_plugin_id=' . $fs->get_id() . '&plugin=' . $addon->slug .
66
- '&TB_iframe=true&width=600&height=550' ) ),
67
- esc_attr( sprintf( __fs( 'more-information-about-x' ), $addon->title ) ),
68
- esc_attr( $addon->title )
69
- );
70
- ?>
71
- <?php
72
- if ( is_null( $addon->info ) ) {
73
- $addon->info = new stdClass();
74
- }
75
- if ( ! isset( $addon->info->card_banner_url ) ) {
76
- $addon->info->card_banner_url = '//dashboard.freemius.com/assets/img/marketing/blueprint-300x100.jpg';
77
- }
78
- if ( ! isset( $addon->info->short_description ) ) {
79
- $addon->info->short_description = 'What\'s the one thing your add-on does really, really well?';
80
- }
81
- ?>
82
- <div class="fs-inner">
83
- <ul>
84
- <li class="fs-card-banner"
85
- style="background-image: url('<?php echo $addon->info->card_banner_url ?>');"></li>
86
- <li class="fs-title"><?php echo $addon->title ?></li>
87
- <li class="fs-offer">
88
- <span
89
- class="fs-price"><?php echo ( 0 == $price ) ? __fs( 'free' ) : '$' . number_format( $price, 2 ) ?></span>
90
- </li>
91
- <li class="fs-description"><?php echo ! empty( $addon->info->short_description ) ? $addon->info->short_description : 'SHORT DESCRIPTION' ?></li>
92
- </ul>
93
- </div>
94
- </li>
95
- <?php endforeach ?>
96
- </ul>
97
- </div>
98
- </div>
99
- <?php if ( $open_addon ) : ?>
100
- <script type="text/javascript">
101
- (function ($) {
102
- var interval = setInterval(function () {
103
- // Open add-on information page.
104
- $('.fs-card[data-slug=<?php echo $open_addon_slug ?>] a').click();
105
- if ($('#TB_iframeContent').length > 0) {
106
- clearInterval(interval);
107
- interval = null;
108
- }
109
- }, 200);
110
- })(jQuery);
111
- </script>
112
- <?php endif ?>
113
- <?php fs_require_template( 'powered-by.php' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/admin-notice.php DELETED
@@ -1,34 +0,0 @@
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
- <div data-id="<?php echo $VARS['id'] ?>" data-slug="<?php echo $VARS['slug'] ?>" class="<?php
10
- switch ( $VARS['type'] ) {
11
- case 'error':
12
- echo 'error form-invalid';
13
- break;
14
- case 'promotion':
15
- echo 'updated promotion';
16
- break;
17
- case 'update':
18
- // echo 'update-nag update';
19
- // break;
20
- case 'success':
21
- default:
22
- echo 'updated success';
23
- break;
24
- }
25
- ?> fs-notice<?php if ( $VARS['sticky'] ) {
26
- echo ' fs-sticky';
27
- } ?><?php if ( ! empty( $VARS['title'] ) ) {
28
- echo ' fs-has-title';
29
- } ?>"><?php if ( ! empty( $VARS['plugin'] ) ) : ?><label
30
- class="fs-plugin-title"><?php echo $VARS['plugin'] ?></label><?php endif ?><p>
31
- <?php if ( ! empty( $VARS['title'] ) ) : ?><b><?php echo $VARS['title'] ?></b> <?php endif ?>
32
- <?php echo $VARS['message'] ?>
33
- </p><?php if ( $VARS['sticky'] ) : ?><i class="fs-close dashicons dashicons-no"
34
- title="<?php _efs( 'dismiss' ) ?>"></i><?php endif ?></div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/all-admin-notice.php DELETED
@@ -1,31 +0,0 @@
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
- <div class="<?php
10
- switch ($VARS['type']) {
11
- case 'error':
12
- echo 'error form-invalid';
13
- break;
14
- case 'update-nag':
15
- echo 'update-nag ';
16
- break;
17
- case 'update':
18
- case 'success':
19
- default:
20
- echo 'updated success';
21
- break;
22
- }
23
- ?> fs-notice">
24
- <?php if ('update-nag' !== $VARS['type']) : ?><p><?php endif ?>
25
- <?php if (!empty($VARS['title'])) : ?>
26
- <b><?php echo $VARS['title'] ?></b>
27
- <?php endif ?>
28
- <?php echo $VARS['message'] ?>
29
- <?php if ('update-nag' !== $VARS['type']) : ?></p><?php endif ?>
30
- <?php if ($VARS['sticky']) : ?><i class="dashicons dashicons-no"></i><?php endif ?>
31
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/checkout.php DELETED
@@ -1,242 +0,0 @@
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
- wp_enqueue_script( 'jquery' );
10
- wp_enqueue_script( 'json2' );
11
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
- fs_enqueue_local_style( 'fs_common', '/admin/common.css' );
14
-
15
- $slug = $VARS['slug'];
16
- $fs = freemius( $slug );
17
-
18
- $timestamp = time();
19
-
20
- $context_params = array(
21
- 'plugin_id' => $fs->get_id(),
22
- 'plugin_public_key' => $fs->get_public_key(),
23
- 'plugin_version' => $fs->get_plugin_version(),
24
- );
25
-
26
- // Get site context secure params.
27
- if ( $fs->is_registered() ) {
28
- $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
29
- $fs->get_site(),
30
- $timestamp,
31
- 'checkout'
32
- ) );
33
- } else {
34
- $current_user = wp_get_current_user();
35
-
36
- // Add site and user info to the request, this information
37
- // is NOT being stored unless the user complete the purchase
38
- // and agrees to the TOS.
39
- $context_params = array_merge( $context_params, array(
40
- 'user_firstname' => $current_user->user_firstname,
41
- 'user_lastname' => $current_user->user_lastname,
42
- 'user_email' => $current_user->user_email,
43
- // 'user_nickname' => $current_user->user_nicename,
44
- // 'plugin_slug' => $slug,
45
- // 'site_url' => get_site_url(),
46
- // 'site_name' => get_bloginfo( 'name' ),
47
- // 'platform_version' => get_bloginfo( 'version' ),
48
- // 'language' => get_bloginfo( 'language' ),
49
- // 'charset' => get_bloginfo( 'charset' ),
50
- // 'account_url' => fs_nonce_url( $fs->_get_admin_page_url(
51
- // 'account',
52
- // array( 'fs_action' => 'sync_user' )
53
- // ), 'sync_user' ),
54
- ) );
55
-
56
- $fs_user = Freemius::_get_user_by_email( $current_user->user_email );
57
-
58
- if ( is_object( $fs_user ) ) {
59
- $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
60
- $fs_user,
61
- $timestamp,
62
- 'checkout'
63
- ) );
64
- }
65
- }
66
-
67
- if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
68
- {
69
- $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
70
- $fs->get_plugin(),
71
- $timestamp,
72
- 'checkout'
73
- );
74
- }
75
-
76
- $return_url = fs_nonce_url( $fs->_get_admin_page_url(
77
- 'account',
78
- array(
79
- 'fs_action' => $slug . '_sync_license',
80
- 'plugin_id' => isset( $_GET['plugin_id'] ) ? $_GET['plugin_id'] : $fs->get_id()
81
- )
82
- ), $slug . '_sync_license' );
83
-
84
- $query_params = array_merge( $context_params, $_GET, array(
85
- // Current plugin version.
86
- 'plugin_version' => $fs->get_plugin_version(),
87
- 'return_url' => $return_url,
88
- // Admin CSS URL for style/design competability.
89
- // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
90
- ) );
91
- ?>
92
- <div class="fs-secure-notice">
93
- <i class="dashicons dashicons-lock"></i>
94
- <span><b>Secure HTTPS Checkout</b> - PCI compliant, running via iframe from external domain</span>
95
- </div>
96
- <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
97
- <div id="iframe"></div>
98
- <script type="text/javascript">
99
- // http://stackoverflow.com/questions/4583703/jquery-post-request-not-ajax
100
- jQuery(function ($) {
101
- $.extend({
102
- form: function (url, data, method) {
103
- if (method == null) method = 'POST';
104
- if (data == null) data = {};
105
-
106
- var form = $('<form>').attr({
107
- method: method,
108
- action: url
109
- }).css({
110
- display: 'none'
111
- });
112
-
113
- var addData = function (name, data) {
114
- if ($.isArray(data)) {
115
- for (var i = 0; i < data.length; i++) {
116
- var value = data[i];
117
- addData(name + '[]', value);
118
- }
119
- } else if (typeof data === 'object') {
120
- for (var key in data) {
121
- if (data.hasOwnProperty(key)) {
122
- addData(name + '[' + key + ']', data[key]);
123
- }
124
- }
125
- } else if (data != null) {
126
- form.append($('<input>').attr({
127
- type : 'hidden',
128
- name : String(name),
129
- value: String(data)
130
- }));
131
- }
132
- };
133
-
134
- for (var key in data) {
135
- if (data.hasOwnProperty(key)) {
136
- addData(key, data[key]);
137
- }
138
- }
139
-
140
- return form.appendTo('body');
141
- }
142
- });
143
- });
144
-
145
- (function ($) {
146
- $(function () {
147
-
148
- var
149
- // Keep track of the iframe height.
150
- iframe_height = 800,
151
- base_url = '<?php echo WP_FS__ADDRESS ?>',
152
- // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
153
- // passed via query string or hard coded into the child page, it depends on your needs).
154
- src = base_url + '/checkout/?<?php echo (isset($_REQUEST['XDEBUG_SESSION']) ? 'XDEBUG_SESSION=' . $_REQUEST['XDEBUG_SESSION'] . '&' : '') . http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
155
-
156
- // Append the Iframe into the DOM.
157
- iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
158
- .appendTo('#iframe');
159
-
160
- FS.PostMessage.init(base_url);
161
- FS.PostMessage.receiveOnce('height', function (data) {
162
- var h = data.height;
163
- if (!isNaN(h) && h > 0 && h != iframe_height) {
164
- iframe_height = h;
165
- $("#iframe iframe").height(iframe_height + 'px');
166
- }
167
- });
168
-
169
- FS.PostMessage.receiveOnce('install', function (data) {
170
- // Post data to activation URL.
171
- $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
172
- 'fs_action' => $slug . '_activate_new',
173
- 'plugin_id' => isset($_GET['plugin_id']) ? $_GET['plugin_id'] : $fs->get_id()
174
- )), $slug . '_activate_new') ?>', {
175
- user_id : data.user.id,
176
- user_secret_key : data.user.secret_key,
177
- user_public_key : data.user.public_key,
178
- install_id : data.install.id,
179
- install_secret_key: data.install.secret_key,
180
- install_public_key: data.install.public_key
181
- }).submit();
182
- });
183
-
184
- FS.PostMessage.receiveOnce('pending_activation', function (data) {
185
- $.form('<?php echo fs_nonce_url($fs->_get_admin_page_url('account', array(
186
- 'fs_action' => $slug . '_activate_new',
187
- 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
188
- 'pending_activation' => true,
189
- )), $slug . '_activate_new') ?>', {
190
- user_email: data.user_email
191
- }).submit();
192
- });
193
-
194
- FS.PostMessage.receiveOnce('get_context', function () {
195
- console.debug('receiveOnce', 'get_context');
196
-
197
- // If the user didn't connect his account with Freemius,
198
- // once he accepts the Terms of Service and Privacy Policy,
199
- // and then click the purchase button, the context information
200
- // of the user will be shared with Freemius in order to complete the
201
- // purchase workflow and activate the license for the right user.
202
- <?php $current_user = wp_get_current_user() ?>
203
- FS.PostMessage.post('context', {
204
- // user_firstname: '<?php //echo $current_user->user_firstname ?>//',
205
- // user_lastname: '<?php //echo $current_user->user_lastname ?>//',
206
- // user_email: '<?php //echo $current_user->user_email ?>//'
207
- plugin_id : '<?php echo $fs->get_id() ?>',
208
- plugin_public_key: '<?php echo $fs->get_public_key() ?>',
209
- plugin_version : '<?php echo $fs->get_plugin_version() ?>',
210
- plugin_slug : '<?php echo $slug ?>',
211
- site_name : '<?php echo get_bloginfo('name') ?>',
212
- platform_version : '<?php echo get_bloginfo('version') ?>',
213
- language : '<?php echo get_bloginfo('language') ?>',
214
- charset : '<?php echo get_bloginfo('charset') ?>',
215
- return_url : '<?php echo $return_url ?>',
216
- account_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url(
217
- 'account',
218
- array('fs_action' => 'sync_user')
219
- ), 'sync_user') ?>',
220
- activation_url : '<?php echo fs_nonce_url($fs->_get_admin_page_url('',
221
- array(
222
- 'fs_action' => $slug . '_activate_new',
223
- 'plugin_id' => fs_request_get('plugin_id', $fs->get_id()),
224
-
225
- )),
226
- $slug . '_activate_new') ?>'
227
- }, iframe[0]);
228
- });
229
-
230
- FS.PostMessage.receiveOnce('get_dimensions', function (data) {
231
- console.debug('receiveOnce', 'get_dimensions');
232
-
233
- FS.PostMessage.post('dimensions', {
234
- height : $(document.body).height(),
235
- scrollTop: $(document).scrollTop()
236
- }, iframe[0]);
237
- });
238
- });
239
- })(jQuery);
240
- </script>
241
- </div>
242
- <?php fs_require_template( 'powered-by.php' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/connect.php DELETED
@@ -1,176 +0,0 @@
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
- wp_enqueue_script( 'jquery' );
10
- wp_enqueue_script( 'json2' );
11
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
-
14
- fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
15
-
16
- $slug = $VARS['slug'];
17
- $fs = freemius( $slug );
18
- $current_user = wp_get_current_user();
19
-
20
- $first_name = $current_user->user_firstname;
21
- if ( empty( $first_name ) ) {
22
- $first_name = $current_user->nickname;
23
- }
24
-
25
- $site_url = get_site_url();
26
- $protocol_pos = strpos( $site_url, '://' );
27
- if ( false !== $protocol_pos ) {
28
- $site_url = substr( $site_url, $protocol_pos + 3 );
29
- }
30
- ?>
31
- <div id="fs_connect" class="wrap<?php if ( ! $fs->enable_anonymous() ) {
32
- echo ' fs-anonymous-disabled';
33
- } ?>">
34
- <div class="fs-visual">
35
- <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
36
- <i class="dashicons dashicons-plus fs-first"></i>
37
- <?php
38
- $vars = array( 'slug' => $slug );
39
- fs_require_once_template( 'plugin-icon.php', $vars );
40
- ?>
41
- <i class="dashicons dashicons-plus fs-second"></i>
42
- <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
43
- </div>
44
- <div class="fs-content">
45
- <p><?php
46
- echo $fs->apply_filters( 'connect_message', sprintf(
47
- __fs( 'hey-x' ) . '<br>' .
48
- __fs( 'connect-message' ),
49
- $first_name,
50
- '<b>' . $fs->get_plugin_name() . '</b>',
51
- '<b>' . $current_user->user_login . '</b>',
52
- '<a href="' . get_site_url() . '" target="_blank">' . $site_url . '</a>',
53
- '<a href="https://freemius.com/wordpress/" target="_blank">freemius.com</a>'
54
- ) );
55
- ?></p>
56
- </div>
57
- <div class="fs-actions">
58
- <?php if ( $fs->enable_anonymous() ) : ?>
59
- <a href="<?php echo wp_nonce_url( $fs->_get_admin_page_url( '', array( 'fs_action' => $slug . '_skip_activation' ) ), $slug . '_skip_activation' ) ?>"
60
- class="button button-secondary" tabindex="2"><?php _efs( 'skip' ) ?></a>
61
- <?php endif ?>
62
- <?php $fs_user = Freemius::_get_user_by_email( $current_user->user_email ) ?>
63
- <?php if ( is_object( $fs_user ) ) : ?>
64
- <form action="" method="POST">
65
- <input type="hidden" name="fs_action" value="<?php echo $slug ?>_activate_existing">
66
- <?php wp_nonce_field( 'activate_existing_' . $fs->get_public_key() ) ?>
67
- <button class="button button-primary" tabindex="1"
68
- type="submit"><?php _efs( 'opt-in-connect' ) ?>
69
- &nbsp;&#10140;</button>
70
- </form>
71
- <?php else : ?>
72
- <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
73
- <?php
74
- $params = array(
75
- 'user_firstname' => $current_user->user_firstname,
76
- 'user_lastname' => $current_user->user_lastname,
77
- 'user_nickname' => $current_user->user_nicename,
78
- 'user_email' => $current_user->user_email,
79
- 'user_ip' => fs_get_ip(),
80
- 'plugin_slug' => $slug,
81
- 'plugin_id' => $fs->get_id(),
82
- 'plugin_public_key' => $fs->get_public_key(),
83
- 'plugin_version' => $fs->get_plugin_version(),
84
- 'return_url' => wp_nonce_url( $fs->_get_admin_page_url(
85
- '',
86
- array( 'fs_action' => $slug . '_activate_new' )
87
- ), $slug . '_activate_new' ),
88
- 'account_url' => wp_nonce_url( $fs->_get_admin_page_url(
89
- 'account',
90
- array( 'fs_action' => 'sync_user' )
91
- ), 'sync_user' ),
92
- 'site_uid' => $fs->get_anonymous_id(),
93
- 'site_url' => get_site_url(),
94
- 'site_name' => get_bloginfo( 'name' ),
95
- 'platform_version' => get_bloginfo( 'version' ),
96
- 'php_version' => phpversion(),
97
- 'language' => get_bloginfo( 'language' ),
98
- 'charset' => get_bloginfo( 'charset' ),
99
- );
100
-
101
- if ( WP_FS__SKIP_EMAIL_ACTIVATION && $fs->has_secret_key() ) {
102
- // Even though rand() is known for its security issues,
103
- // the timestamp adds another layer of protection.
104
- // It would be very hard for an attacker to get the secret key form here.
105
- // Plus, this should never run in production since the secret should never
106
- // be included in the production version.
107
- $params['ts'] = WP_FS__SCRIPT_START_TIME;
108
- $params['salt'] = md5( uniqid( rand() ) );
109
- $params['secure'] = md5(
110
- $params['ts'] .
111
- $params['salt'] .
112
- $fs->get_secret_key()
113
- );
114
- }
115
- ?>
116
- <?php foreach ( $params as $name => $value ) : ?>
117
- <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
118
- <?php endforeach ?>
119
- <button class="button button-primary" tabindex="1"
120
- type="submit"><?php _efs( 'opt-in-connect' ) ?>
121
- &nbsp;&#10140;</button>
122
- </form>
123
- <?php endif ?>
124
- </div>
125
- <div class="fs-permissions">
126
- <a class="fs-trigger" href="#"><?php _efs( 'what-permissions' ) ?></a>
127
- <ul>
128
- <li>
129
- <i class="dashicons dashicons-admin-users"></i>
130
-
131
- <div>
132
- <span><?php _efs( 'permissions-profile' ) ?></span>
133
-
134
- <p><?php _efs( 'permissions-profile_desc' ) ?></p>
135
- </div>
136
- </li>
137
- <li>
138
- <i class="dashicons dashicons-wordpress"></i>
139
-
140
- <div>
141
- <span><?php _efs( 'permissions-site' ) ?></span>
142
-
143
- <p><?php _efs( 'permissions-site_desc' ) ?></p>
144
- </div>
145
- </li>
146
- <li>
147
- <i class="dashicons dashicons-admin-plugins"></i>
148
-
149
- <div>
150
- <span><?php _efs( 'permissions-events' ) ?></span>
151
-
152
- <p><?php _efs( 'permissions-events_desc' ) ?></p>
153
- </div>
154
- </li>
155
- </ul>
156
- </div>
157
- <div class="fs-terms">
158
- <a href="https://freemius.com/privacy/" target="_blank"><?php _efs( 'privacy-policy' ) ?></a>
159
- &nbsp;&nbsp;-&nbsp;&nbsp;
160
- <a href="https://freemius.com/terms/" target="_blank"><?php _efs( 'tos' ) ?></a>
161
- </div>
162
- </div>
163
- <script type="text/javascript">
164
- (function ($) {
165
- $('.button').on('click', function () {
166
- // Set loading mode.
167
- $(document.body).css({'cursor': 'wait'});
168
- });
169
- $('.button.button-primary').on('click', function () {
170
- $(this).html('<?php _efs( 'activating' ) ?>...').css({'cursor': 'wait'});
171
- });
172
- $('.fs-permissions .fs-trigger').on('click', function () {
173
- $('.fs-permissions').toggleClass('fs-open');
174
- });
175
- })(jQuery);
176
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/contact.php DELETED
@@ -1,72 +0,0 @@
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
- wp_enqueue_script( 'jquery' );
10
- wp_enqueue_script( 'json2' );
11
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
- fs_enqueue_local_style( 'fs_checkout', '/admin/common.css' );
14
-
15
- $slug = $VARS['slug'];
16
- $fs = freemius( $slug );
17
-
18
- $context_params = array(
19
- 'plugin_id' => $fs->get_id(),
20
- 'plugin_public_key' => $fs->get_public_key(),
21
- 'plugin_version' => $fs->get_plugin_version(),
22
- );
23
-
24
-
25
- // Get site context secure params.
26
- if ( $fs->is_registered() ) {
27
- $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
28
- $fs->get_site(),
29
- time(),
30
- 'contact'
31
- ) );
32
- }
33
-
34
- $query_params = array_merge( $_GET, array_merge( $context_params, array(
35
- 'plugin_version' => $fs->get_plugin_version(),
36
- 'wp_login_url' => wp_login_url(),
37
- // 'wp_admin_css' => get_bloginfo('wpurl') . "/wp-admin/load-styles.php?c=1&load=buttons,wp-admin,dashicons",
38
- ) ) );
39
- ?>
40
- <div class="fs-secure-notice">
41
- <i class="dashicons dashicons-lock"></i>
42
- <span><b>Secure HTTPS contact page</b>, running via iframe from external domain</span>
43
- </div>
44
- <div id="fs_contact" class="wrap" style="margin: 40px 0 -65px -20px;">
45
- <div id="iframe"></div>
46
- <script type="text/javascript">
47
- (function ($) {
48
- $(function () {
49
-
50
- var
51
- // Keep track of the iframe height.
52
- iframe_height = 800,
53
- base_url = '<?php echo WP_FS__ADDRESS ?>',
54
- src = base_url + '/contact/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
55
-
56
- // Append the Iframe into the DOM.
57
- iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
58
- .appendTo('#iframe');
59
-
60
- FS.PostMessage.init(base_url);
61
- FS.PostMessage.receive('height', function (data) {
62
- var h = data.height;
63
- if (!isNaN(h) && h > 0 && h != iframe_height) {
64
- iframe_height = h;
65
- $("#iframe iframe").height(iframe_height + 'px');
66
- }
67
- });
68
- });
69
- })(jQuery);
70
- </script>
71
- </div>
72
- <?php fs_require_template( 'powered-by.php' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/deactivation-feedback-modal.php DELETED
@@ -1,196 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.1.2
7
- */
8
- $slug = $VARS['slug'];
9
- $fs = freemius( $slug );
10
-
11
- $confirmation_message = $fs->apply_filters( 'uninstall_confirmation_message', '' );
12
-
13
- $reasons = $VARS['reasons'];
14
-
15
- $reasons_list_items_html = '';
16
-
17
- foreach ( $reasons as $reason ) {
18
- $list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' );
19
- $reasons_list_items_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $reason['input_type'] . '" data-input-placeholder="' . $reason['input_placeholder'] . '"><label><span><input type="radio" name="selected-reason" value="' . $reason['id'] . '"/></span><span>' . $reason['text'] . '</span></label></li>';
20
- }
21
- ?>
22
- <script>
23
- (function( $ ) {
24
- var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
25
- modalHtml =
26
- '<div class="fs-modal<?php echo empty( $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
27
- + ' <div class="fs-modal-dialog">'
28
- + ' <div class="fs-modal-body">'
29
- + ' <div class="fs-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
30
- + ' <div class="fs-modal-panel active" data-panel-id="reasons"><h3><strong><?php printf( __fs( 'deactivation-share-reason' ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
31
- + ' </div>'
32
- + ' <div class="fs-modal-footer">'
33
- + ' <a href="#" class="button button-secondary button-deactivate"></a>'
34
- + ' <a href="#" class="button button-primary button-close"><?php printf( __fs( 'deactivation-modal-button-cancel' ) ); ?></a>'
35
- + ' </div>'
36
- + ' </div>'
37
- + '</div>',
38
- $modal = $( modalHtml ),
39
- $deactivateLink = $( '#the-list .deactivate > [data-slug=<?php echo $VARS['slug']; ?>].fs-slug' ).prev();
40
-
41
- $modal.appendTo( $( 'body' ) );
42
-
43
- registerEventHandlers();
44
-
45
- function registerEventHandlers() {
46
- $deactivateLink.click(function ( evt ) {
47
- evt.preventDefault();
48
-
49
- showModal();
50
- });
51
-
52
- $modal.on( 'click', '.button', function( evt ) {
53
- evt.preventDefault();
54
-
55
- if ( $( this ).hasClass( 'disabled' ) ) {
56
- return;
57
- }
58
-
59
- var _parent = $( this ).parents( '.fs-modal:first' );
60
- var _this = $( this );
61
-
62
- if ( _this.hasClass( 'allow-deactivate' ) ) {
63
- var $radio = $( 'input[type="radio"]:checked' );
64
-
65
- if ( 0 === $radio.length ) {
66
- // If no selected reason, just deactivate the plugin.
67
- window.location.href = $deactivateLink.attr( 'href' );
68
- return;
69
- }
70
-
71
- var $selected_reason = $radio.parents( 'li:first' ),
72
- $input = $selected_reason.find( 'textarea, input[type="text"]' );
73
-
74
- $.ajax({
75
- url: ajaxurl,
76
- method: 'POST',
77
- data: {
78
- 'action' : 'submit-uninstall-reason',
79
- 'reason_id' : $radio.val(),
80
- 'reason_info' : ( 0 !== $input.length ) ? $input.val().trim() : ''
81
- },
82
- beforeSend: function() {
83
- _parent.find( '.button' ).addClass( 'disabled' );
84
- _parent.find( '.button-secondary' ).text( 'Processing...' );
85
- },
86
- complete: function() {
87
- // Do not show the dialog box, deactivate the plugin.
88
- window.location.href = $deactivateLink.attr( 'href' );
89
- }
90
- });
91
- } else if ( _this.hasClass( 'button-deactivate' ) ) {
92
- // Change the Deactivate button's text and show the reasons panel.
93
- _parent.find( '.button-deactivate').addClass( 'allow-deactivate' );
94
-
95
- showPanel( 'reasons' );
96
- }
97
- });
98
-
99
- $modal.on( 'click', 'input[type="radio"]', function() {
100
- var _parent = $( this ).parents( 'li:first' );
101
-
102
- $modal.find( '.reason-input' ).remove();
103
- $modal.find( '.button-deactivate').text( '<?php printf( __fs( 'deactivation-modal-button-submit' ) ); ?>' );
104
-
105
- if ( _parent.hasClass( 'has-input' ) ) {
106
- var inputType = _parent.data( 'input-type' ),
107
- inputPlaceholder = _parent.data( 'input-placeholder' ),
108
- reasonInputHtml = '<div class="reason-input">' + ( ( 'textfield' === inputType ) ? '<input type="text" />' : '<textarea rows="5"></textarea>' ) + '</div>';
109
-
110
- _parent.append( $( reasonInputHtml ) );
111
- _parent.find( 'input, textarea' ).attr( 'placeholder', inputPlaceholder ).focus();
112
- }
113
- });
114
-
115
- // If the user has clicked outside the window, cancel it.
116
- $modal.on( 'click', function( evt ) {
117
- var $target = $( evt.target );
118
-
119
- // If the user has clicked anywhere in the modal dialog, just return.
120
- if ( $target.hasClass( 'fs-modal-body' ) || $target.hasClass( 'fs-modal-footer' ) ) {
121
- return;
122
- }
123
-
124
- // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
125
- if ( ! $target.hasClass( 'button-close' ) && ( $target.parents( '.fs-modal-body').length > 0 || $target.parents( '.fs-modal-footer').length > 0 ) ) {
126
- return;
127
- }
128
-
129
- closeModal();
130
- });
131
- }
132
-
133
- function showModal() {
134
- resetModal();
135
-
136
- // Display the dialog box.
137
- $modal.addClass( 'active' );
138
-
139
- $( 'body' ).addClass( 'has-fs-modal' );
140
- }
141
-
142
- function closeModal() {
143
- $modal.removeClass( 'active' );
144
-
145
- $( 'body' ).removeClass( 'has-fs-modal' );
146
- }
147
-
148
- function resetModal() {
149
- $modal.find( '.button' ).removeClass( 'disabled' );
150
-
151
- // Uncheck all radio buttons.
152
- $modal.find( 'input[type="radio"]' ).prop( 'checked', false );
153
-
154
- // Remove all input fields ( textfield, textarea ).
155
- $modal.find( '.reason-input' ).remove();
156
-
157
- var $deactivateButton = $modal.find( '.button-deactivate' );
158
-
159
- /*
160
- * If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
161
- * that clicking the deactivate button will actually deactivate the plugin.
162
- */
163
- if ( $modal.hasClass( 'no-confirmation-message' ) ) {
164
- $deactivateButton.addClass( 'allow-deactivate' );
165
-
166
- showPanel( 'reasons' );
167
- } else {
168
- $deactivateButton.removeClass( 'allow-deactivate' );
169
-
170
- showPanel( 'confirm' );
171
- }
172
- }
173
-
174
- function showPanel( panelType ) {
175
- $modal.find( '.fs-modal-panel' ).removeClass( 'active ');
176
- $modal.find( '[data-panel-id="' + panelType + '"]' ).addClass( 'active' );
177
-
178
- updateButtonLabels();
179
- }
180
-
181
- function updateButtonLabels() {
182
- var $deactivateButton = $modal.find( '.button-deactivate' );
183
-
184
- // Reset the deactivate button's text.
185
- if ( 'confirm' === getCurrentPanel() ) {
186
- $deactivateButton.text( '<?php printf( __fs( 'deactivation-modal-button-confirm' ) ); ?>' );
187
- } else {
188
- $deactivateButton.text( '<?php printf( __fs( 'deactivation-modal-button-deactivate' ) ); ?>' );
189
- }
190
- }
191
-
192
- function getCurrentPanel() {
193
- return $modal.find( '.fs-modal-panel.active' ).attr( 'data-panel-id' );
194
- }
195
- })( jQuery );
196
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/debug.php DELETED
@@ -1,103 +0,0 @@
1
- <h2><?php _efs( 'plugin-installs' ) ?> / <?php _efs( 'sites' ) ?></h2>
2
- <?php
3
- /**
4
- * @var FS_Site[] $sites
5
- */
6
- $sites = $VARS['sites'];
7
- ?>
8
- <table id="fs_installs" class="widefat">
9
- <thead>
10
- <tr>
11
- <th><?php _efs( 'id' ) ?></th>
12
- <th><?php _efs( 'plugin' ) ?></th>
13
- <th><?php _efs( 'plan' ) ?></th>
14
- <th><?php _efs( 'public-key' ) ?></th>
15
- <th><?php _efs( 'secret-key' ) ?></th>
16
- </tr>
17
- </thead>
18
- <tbody>
19
- <?php foreach ( $sites as $plugin_basename => $site ) : ?>
20
- <tr>
21
- <td><?php echo $site->id ?></td>
22
- <td><?php echo dirname( $plugin_basename ) ?></td>
23
- <td><?php
24
- echo is_object( $site->plan ) ? $site->plan->name : ''
25
- ?></td>
26
- <td><?php echo $site->public_key ?></td>
27
- <td><?php echo $site->secret_key ?></td>
28
- </tr>
29
- <?php endforeach ?>
30
- </tbody>
31
- </table>
32
- <?php
33
- $addons = $VARS['addons'];
34
- ?>
35
- <?php foreach ( $addons as $plugin_id => $plugin_addons ) : ?>
36
- <h2><?php printf( __fs( 'addons-of-x' ), $plugin_id ) ?></h2>
37
- <table id="fs_addons" class="widefat">
38
- <thead>
39
- <tr>
40
- <th><?php _efs( 'id' ) ?></th>
41
- <th><?php _efs( 'title' ) ?></th>
42
- <th><?php _efs( 'slug' ) ?></th>
43
- <th><?php _efs( 'version' ) ?></th>
44
- <th><?php _efs( 'public-key' ) ?></th>
45
- <th><?php _efs( 'secret-key' ) ?></th>
46
- </tr>
47
- </thead>
48
- <tbody>
49
- <?php
50
- /**
51
- * @var FS_Plugin[] $plugin_addons
52
- */
53
- foreach ( $plugin_addons as $addon ) : ?>
54
- <tr>
55
- <td><?php echo $addon->id ?></td>
56
- <td><?php echo $addon->title ?></td>
57
- <td><?php echo $addon->slug ?></td>
58
- <td><?php echo $addon->version ?></td>
59
- <td><?php echo $addon->public_key ?></td>
60
- <td><?php echo $addon->secret_key ?></td>
61
- </tr>
62
- <?php endforeach ?>
63
- </tbody>
64
- </table>
65
- <?php endforeach ?>
66
- <h2><?php _efs( 'users' ) ?></h2>
67
- <?php
68
- /**
69
- * @var FS_User[] $users
70
- */
71
- $users = $VARS['users'];
72
- ?>
73
- <table id="fs_users" class="widefat">
74
- <thead>
75
- <tr>
76
- <th><?php _efs( 'id' ) ?></th>
77
- <th><?php _efs( 'name' ) ?></th>
78
- <th><?php _efs( 'email' ) ?></th>
79
- <th><?php _efs( 'verified' ) ?></th>
80
- <th><?php _efs( 'public-key' ) ?></th>
81
- <th><?php _efs( 'secret-key' ) ?></th>
82
- </tr>
83
- </thead>
84
- <tbody>
85
- <?php foreach ( $users as $user_id => $user ) : ?>
86
- <tr>
87
- <td><?php echo $user->id ?></td>
88
- <td><?php echo $user->get_name() ?></td>
89
- <td><?php echo $user->email ?></td>
90
- <td><?php echo json_encode( $user->is_verified ) ?></td>
91
- <td><?php echo $user->public_key ?></td>
92
- <td><?php echo $user->secret_key ?></td>
93
- </tr>
94
- <?php endforeach ?>
95
- </tbody>
96
- </table>
97
- <br><br>
98
- <form action="" method="POST">
99
- <input type="hidden" name="fs_action" value="delete_all_accounts">
100
- <?php wp_nonce_field( 'delete_all_accounts' ) ?>
101
- <button class="button button-primary"
102
- onclick="if (confirm('<?php _efs( 'delete-all-confirm' ) ?>')) this.parentNode.submit(); return false;"><?php _efs( 'delete-all-accounts' ) ?></button>
103
- </form>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/email.php DELETED
@@ -1,42 +0,0 @@
1
- <?php
2
- /**
3
- * @package Freemius
4
- * @copyright Copyright (c) 2015, Freemius, Inc.
5
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
6
- * @since 1.1.1
7
- */
8
-
9
- $sections = $VARS['sections'];
10
- ?>
11
- <table>
12
- <?php
13
- foreach ( $sections as $section_id => $section ) {
14
- ?>
15
- <thead>
16
- <tr><th colspan="2" style="text-align: left; background: #333; color: #fff; padding: 5px;"><?php echo $section['title']; ?></th></tr>
17
- </thead>
18
- <tbody>
19
- <?php
20
- foreach ( $section['rows'] as $row_id => $row ) {
21
- $col_count = count( $row );
22
- ?>
23
- <tr>
24
- <?php
25
- if ( 1 === $col_count ) { ?>
26
- <td style="vertical-align: top;" colspan="2"><?php echo $row[0]; ?></td>
27
- <?php
28
- } else { ?>
29
- <td style="vertical-align: top;"><b><?php echo $row[0]; ?>:</b></td>
30
- <td><?php echo $row[1]; ?></td>
31
- <?php
32
- }
33
- ?>
34
- </tr>
35
- <?php
36
- }
37
- ?>
38
- </tbody>
39
- <?php
40
- }
41
- ?>
42
- </table>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/firewall-issues-js.php DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * API connectivity issues (CloudFlare's firewall) handler for handling different
4
- * scenarios selected by the user after connectivity issue is detected, by sending
5
- * AJAX call to the server in order to make the actual actions.
6
- *
7
- * @package Freemius
8
- * @copyright Copyright (c) 2015, Freemius, Inc.
9
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
- * @since 1.0.9
11
- */
12
- ?>
13
- <script type="text/javascript">
14
- jQuery(document).ready(function ($) {
15
- $('#fs_firewall_issue_options a.fs-resolve').click(function () {
16
- var
17
- error_type = $(this).attr('data-type'),
18
- notice = $(this).parents('.fs-notice'),
19
- slug = notice.attr('data-slug');
20
-
21
- var data = {
22
- action : slug + '_resolve_firewall_issues',
23
- slug : slug,
24
- error_type: error_type
25
- };
26
-
27
- if ('squid' === error_type) {
28
- data.hosting_company = prompt('What is the name or URL of your hosting company?');
29
- if (null == data.hosting_company)
30
- return false;
31
-
32
- if ('' === data.hosting_company) {
33
- alert('We won\'t be able to help without knowing your hosting company.');
34
- return false;
35
- }
36
- }
37
-
38
- $(this).css({'cursor': 'wait'});
39
-
40
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
41
- $.post(ajaxurl, data, function (response) {
42
- if (1 == response) {
43
- // Refresh page on success.
44
- location.reload();
45
- }
46
- });
47
- });
48
- });
49
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/pending-activation.php DELETED
@@ -1,146 +0,0 @@
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
- wp_enqueue_script( 'jquery' );
10
- wp_enqueue_script( 'json2' );
11
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
-
14
- fs_enqueue_local_style( 'fs_connect', '/admin/connect.css' );
15
-
16
- $slug = $VARS['slug'];
17
- $fs = freemius( $slug );
18
- $current_user = wp_get_current_user();
19
-
20
- $first_name = $current_user->user_firstname;
21
- if ( empty( $first_name ) ) {
22
- $first_name = $current_user->nickname;
23
- }
24
-
25
- $site_url = get_site_url();
26
- $protocol_pos = strpos( $site_url, '://' );
27
- if ( false !== $protocol_pos ) {
28
- $site_url = substr( $site_url, $protocol_pos + 3 );
29
- }
30
- ?>
31
- <div id="fs_connect" class="wrap fs-anonymous-disabled">
32
- <div class="fs-visual">
33
- <b class="fs-site-icon"><i class="dashicons dashicons-wordpress"></i></b>
34
- <i class="dashicons dashicons-plus fs-first"></i>
35
-
36
- <div class="fs-plugin-icon">
37
- <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-128x128.png" type="image/png">
38
- <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-128x128.jpg" type="image/png">
39
- <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-256x256.png"
40
- type="image/png">
41
- <object data="//plugins.svn.wordpress.org/<?php echo $slug ?>/assets/icon-256x256.jpg"
42
- type="image/png">
43
- <img src="//wimg.freemius.com/plugin-icon.png"/>
44
- </object>
45
- </object>
46
- </object>
47
- </object>
48
- </div>
49
- <i class="dashicons dashicons-plus fs-second"></i>
50
- <img class="fs-connect-logo" width="80" height="80" src="//img.freemius.com/connect-logo.png"/>
51
- </div>
52
- <div class="fs-content">
53
- <p><?php
54
- echo $fs->apply_filters( 'pending_activation_message', sprintf(
55
- __fs( 'thanks-x' ) . '<br>' .
56
- __fs( 'pending-activation-message' ),
57
- $first_name,
58
- '<b>' . $fs->get_plugin_name() . '</b>',
59
- '<b>' . $current_user->user_email . '</b>'
60
- ) )
61
- ?></p>
62
- </div>
63
- <div class="fs-actions">
64
- <?php $fs_user = Freemius::_get_user_by_email( $current_user->user_email ) ?>
65
- <form method="post" action="<?php echo WP_FS__ADDRESS ?>/action/service/user/install/">
66
- <?php
67
- $params = array(
68
- 'user_firstname' => $current_user->user_firstname,
69
- 'user_lastname' => $current_user->user_lastname,
70
- 'user_nickname' => $current_user->user_nicename,
71
- 'user_email' => $current_user->user_email,
72
- 'plugin_slug' => $slug,
73
- 'plugin_id' => $fs->get_id(),
74
- 'plugin_public_key' => $fs->get_public_key(),
75
- 'plugin_version' => $fs->get_plugin_version(),
76
- 'return_url' => wp_nonce_url( $fs->_get_admin_page_url(
77
- '',
78
- array( 'fs_action' => $slug . '_activate_new' )
79
- ), $slug . '_activate_new' ),
80
- 'account_url' => wp_nonce_url( $fs->_get_admin_page_url(
81
- 'account',
82
- array( 'fs_action' => 'sync_user' )
83
- ), 'sync_user' ),
84
- 'site_url' => get_site_url(),
85
- 'site_name' => get_bloginfo( 'name' ),
86
- 'platform_version' => get_bloginfo( 'version' ),
87
- 'language' => get_bloginfo( 'language' ),
88
- 'charset' => get_bloginfo( 'charset' ),
89
- );
90
- ?>
91
- <?php foreach ( $params as $name => $value ) : ?>
92
- <input type="hidden" name="<?php echo $name ?>" value="<?php echo esc_attr( $value ) ?>">
93
- <?php endforeach ?>
94
- <button class="button button-primary" tabindex="1"
95
- type="submit"><?php _efs( 'resend-activation-email' ) ?></button>
96
- </form>
97
- </div>
98
- <div class="fs-permissions">
99
- <a class="fs-trigger" href="#"><?php _efs( 'what-permissions' ) ?></a>
100
- <ul>
101
- <li>
102
- <i class="dashicons dashicons-admin-users"></i>
103
-
104
- <div>
105
- <span><?php _efs( 'permissions-profile' ) ?></span>
106
-
107
- <p><?php _efs( 'permissions-profile_desc' ) ?></p>
108
- </div>
109
- </li>
110
- <li>
111
- <i class="dashicons dashicons-wordpress"></i>
112
-
113
- <div>
114
- <span><?php _efs( 'permissions-site' ) ?></span>
115
-
116
- <p><?php _efs( 'permissions-site_desc' ) ?></p>
117
- </div>
118
- </li>
119
- <li>
120
- <i class="dashicons dashicons-admin-plugins"></i>
121
-
122
- <div>
123
- <span><?php _efs( 'permissions-events' ) ?></span>
124
-
125
- <p><?php _efs( 'permissions-events_desc' ) ?></p>
126
- </div>
127
- </li>
128
- </ul>
129
- </div>
130
- <div class="fs-terms">
131
- <a href="https://freemius.com/privacy/" target="_blank"><?php _efs( 'privacy-policy' ) ?></a>
132
- &nbsp;&nbsp;-&nbsp;&nbsp;
133
- <a href="https://freemius.com/terms/" target="_blank"><?php _efs( 'tos' ) ?></a>
134
- </div>
135
- </div>
136
- <script type="text/javascript">
137
- (function ($) {
138
- $('.button.button-primary').on('click', function () {
139
- $(document.body).css({'cursor': 'wait'});
140
- $(this).html('Sending email...').css({'cursor': 'wait'});
141
- });
142
- $('.fs-permissions .fs-trigger').on('click', function () {
143
- $('.fs-permissions').toggleClass('fs-open');
144
- });
145
- })(jQuery);
146
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/plugin-icon.php DELETED
@@ -1,58 +0,0 @@
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
- $slug = $VARS['slug'];
9
- $fs = freemius( $slug );
10
-
11
- $icons = glob( fs_normalize_path( WP_FS__DIR_IMG . '/icon.*' ) );
12
- if ( ! is_array( $icons ) || 0 === count( $icons ) ) {
13
- $icon_found = false;
14
- $local_path = fs_normalize_path( WP_FS__DIR_IMG . '/icon.png' );
15
-
16
- if ( WP_FS__IS_LOCALHOST && $fs->is_org_repo_compliant() ) {
17
- /**
18
- * IMPORTANT: THIS CODE WILL NEVER RUN AFTER THE PLUGIN IS IN THE REPO.
19
- *
20
- * This code will only be executed once during the testing
21
- * of the plugin in a local environment. The plugin icon file WILL
22
- * already exist in the assets folder when the plugin is deployed to
23
- * the repository.
24
- */
25
- $suffixes = array(
26
- '-128x128.png',
27
- '-128x128.jpg',
28
- '-256x256.png',
29
- '-256x256.jpg',
30
- '.svg',
31
- );
32
-
33
- $base_url = 'https://plugins.svn.wordpress.org/' . $slug . '/assets/icon';
34
-
35
- foreach ( $suffixes as $s ) {
36
- $headers = get_headers( $base_url . $s );
37
- if ( strpos( $headers[0], '200' ) ) {
38
- $local_path = fs_normalize_path( WP_FS__DIR_IMG . '/icon.' . substr( $s, strpos( $s, '.' ) + 1 ) );
39
- fs_download_image( $base_url . $s, $local_path );
40
- $icon_found = true;
41
- break;
42
- }
43
- }
44
- }
45
-
46
- if ( ! $icon_found ) {
47
- // No icons found, fallback to default icon.
48
- copy( fs_normalize_path( WP_FS__DIR_IMG . '/plugin-icon.png' ), $local_path );
49
- }
50
-
51
- $icons = array( $local_path );
52
- }
53
-
54
- $relative_url = fs_img_url( substr( $icons[0], strlen( fs_normalize_path( WP_FS__DIR_IMG ) ) ) );
55
- ?>
56
- <div class="fs-plugin-icon">
57
- <img src="<?php echo $relative_url ?>"/>
58
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/plugin-info/description.php DELETED
@@ -1,63 +0,0 @@
1
- <?php
2
- /**
3
- * @var FS_Plugin $plugin
4
- */
5
- $plugin = $VARS['plugin'];
6
-
7
- if ( ! empty( $plugin->info->selling_point_0 ) ||
8
- ! empty( $plugin->info->selling_point_1 ) ||
9
- ! empty( $plugin->info->selling_point_2 )
10
- ) : ?>
11
- <div class="fs-selling-points">
12
- <ul>
13
- <?php for ( $i = 0; $i < 3; $i ++ ) : ?>
14
- <?php if ( ! empty( $plugin->info->{'selling_point_' . $i} ) ) : ?>
15
- <li><i class="dashicons dashicons-yes"></i>
16
-
17
- <h3><?php echo $plugin->info->{'selling_point_' . $i} ?></h3></li>
18
- <?php endif ?>
19
- <?php endfor ?>
20
- </ul>
21
- </div>
22
- <?php endif ?>
23
- <div>
24
- <?php
25
- echo wp_kses( $plugin->info->description, array(
26
- 'a' => array( 'href' => array(), 'title' => array(), 'target' => array() ),
27
- 'b' => array(),
28
- 'i' => array(),
29
- 'p' => array(),
30
- 'blockquote' => array(),
31
- 'h2' => array(),
32
- 'h3' => array(),
33
- 'ul' => array(),
34
- 'ol' => array(),
35
- 'li' => array()
36
- ) );
37
- ?>
38
- </div>
39
- <?php if ( ! empty( $plugin->info->screenshots ) ) : ?>
40
- <?php $screenshots = $plugin->info->screenshots ?>
41
- <div class="fs-screenshots clearfix">
42
- <h2><?php _efs( 'screenshots' ) ?></h2>
43
- <ul>
44
- <?php $i = 0;
45
- foreach ( $screenshots as $s => $url ) : ?>
46
- <?php
47
- // Relative URLs are replaced with WordPress.org base URL
48
- // therefore we need to set absolute URLs.
49
- $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
50
- <li class="<?php echo ( 0 === $i % 2 ) ? 'odd' : 'even' ?>">
51
- <style>
52
- #section-description .fs-screenshots .fs-screenshot-<?php echo $i ?>
53
- {
54
- background-image: url('<?php echo $url ?>');
55
- }
56
- </style>
57
- <a href="<?php echo $url ?>" title="<?php printf( __fs( 'view-full-size-x' ), $i ) ?>"
58
- class="fs-screenshot-<?php echo $i ?>"></a>
59
- </li>
60
- <?php $i ++; endforeach ?>
61
- </ul>
62
- </div>
63
- <?php endif ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/plugin-info/features.php DELETED
@@ -1,81 +0,0 @@
1
- <?php
2
- $plans = $VARS['plans'];
3
-
4
- $features_plan_map = array();
5
- foreach ( $plans as $plan ) {
6
- foreach ( $plan->features as $feature ) {
7
- if ( ! isset( $features_plan_map[ $feature->id ] ) ) {
8
- $features_plan_map[ $feature->id ] = array( 'feature' => $feature, 'plans' => array() );
9
- }
10
-
11
- $features_plan_map[ $feature->id ]['plans'][ $plan->id ] = $feature;
12
- }
13
-
14
- // Add support as a feature.
15
- if ( ! empty( $plan->support_email ) ||
16
- ! empty( $plan->support_skype ) ||
17
- ! empty( $plan->support_phone ) ||
18
- true === $plan->is_success_manager
19
- ) {
20
- if ( ! isset( $features_plan_map['support'] ) ) {
21
- $support_feature = new stdClass();
22
- $support_feature->id = 'support';
23
- $support_feature->title = __fs( 'Support' );
24
- $features_plan_map[ $support_feature->id ] = array( 'feature' => $support_feature, 'plans' => array() );
25
- } else {
26
- $support_feature = $features_plan_map['support'];
27
- }
28
-
29
- $features_plan_map[ $support_feature->id ]['plans'][ $plan->id ] = $support_feature;
30
- }
31
- }
32
-
33
- // Add updates as a feature for all plans.
34
- $updates_feature = new stdClass();
35
- $updates_feature->id = 'updates';
36
- $updates_feature->title = __fs( 'unlimited-updates' );
37
- $features_plan_map[ $updates_feature->id ] = array( 'feature' => $updates_feature, 'plans' => array() );
38
- foreach ( $plans as $plan ) {
39
- $features_plan_map[ $updates_feature->id ]['plans'][ $plan->id ] = $updates_feature;
40
- }
41
- ?>
42
- <div class="fs-features">
43
- <table>
44
- <thead>
45
- <tr>
46
- <th></th>
47
- <?php foreach ( $plans as $plan ) : ?>
48
- <th>
49
- <?php echo $plan->title ?>
50
- <span class="fs-price">
51
- <?php foreach ( $plan->pricing as $pricing ) : ?>
52
- <?php if ( 1 == $pricing->licenses ) : ?>
53
- $<?php echo $pricing->annual_price ?> / year
54
- <?php endif ?>
55
- <?php endforeach ?>
56
- </span>
57
- </th>
58
- <?php endforeach ?>
59
- </tr>
60
- </thead>
61
- <tbody>
62
- <?php $odd = true;
63
- foreach ( $features_plan_map as $feature_id => $data ) : ?>
64
- <tr class="fs-<?php echo $odd ? 'odd' : 'even' ?>">
65
- <td><?php echo ucfirst( $data['feature']->title ) ?></td>
66
- <?php foreach ( $plans as $plan ) : ?>
67
- <td>
68
- <?php if ( isset( $data['plans'][ $plan->id ] ) ) : ?>
69
- <?php if ( ! empty( $data['plans'][ $plan->id ]->value ) ) : ?>
70
- <b><?php echo $data['plans'][ $plan->id ]->value ?></b>
71
- <?php else : ?>
72
- <i class="dashicons dashicons-yes"></i>
73
- <?php endif ?>
74
- <?php endif ?>
75
- </td>
76
- <?php endforeach ?>
77
- </tr>
78
- <?php $odd = ! $odd; endforeach ?>
79
- </tbody>
80
- </table>
81
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/plugin-info/screenshots.php DELETED
@@ -1,19 +0,0 @@
1
- <?php
2
- /**
3
- * @var FS_Plugin $plugin
4
- */
5
- $screenshots = $VARS['screenshots'];
6
- ?>
7
- <ol>
8
- <?php $i = 0;
9
- foreach ( $screenshots as $s => $url ) : ?>
10
- <?php
11
- // Relative URLs are replaced with WordPress.org base URL
12
- // therefore we need to set absolute URLs.
13
- $url = 'http' . ( WP_FS__IS_HTTPS ? 's' : '' ) . ':' . $url; ?>
14
- <li>
15
- <a href="<?php echo $url ?>" title="<?php printf( __fs( 'view-full-size-x' ), $i ) ?>"><img
16
- src="<?php echo $url ?>"></a>
17
- </li>
18
- <?php $i ++; endforeach ?>
19
- </ol>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/powered-by.php DELETED
@@ -1,37 +0,0 @@
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
- /**
10
- * KEEP THE POWERED BY TAB AND GET ADDITIONAL - 2% - OFF THE COMMISSION
11
- */
12
-
13
- wp_enqueue_script( 'jquery' );
14
- wp_enqueue_script( 'json2' );
15
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
16
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
17
- ?>
18
-
19
- <div id="piframe"></div>
20
- <script type="text/javascript">
21
- (function ($) {
22
- $(function () {
23
- var
24
- base_url = '<?php echo WP_FS__ADDRESS ?>',
25
- piframe = $('<iframe id="fs_promo_tab" src="' + base_url + '/promotional-tab/?page=contact#' + encodeURIComponent(document.location.href) + '" height="350" width="60" frameborder="0" style=" background: transparent; position: fixed; top: 20%; right: 0;" scrolling="no"></iframe>')
26
- .appendTo('#piframe');
27
-
28
- FS.PostMessage.init(base_url);
29
- FS.PostMessage.receive('state', function (state) {
30
- if ('closed' === state)
31
- $('#fs_promo_tab').css('width', '60px');
32
- else
33
- $('#fs_promo_tab').css('width', '345px');
34
- });
35
- });
36
- })(jQuery);
37
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/pricing.php DELETED
@@ -1,96 +0,0 @@
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
- wp_enqueue_script( 'jquery' );
10
- wp_enqueue_script( 'json2' );
11
- fs_enqueue_local_script( 'postmessage', 'nojquery.ba-postmessage.min.js' );
12
- fs_enqueue_local_script( 'fs-postmessage', 'postmessage.js' );
13
-
14
- $slug = $VARS['slug'];
15
- $fs = freemius( $slug );
16
- $timestamp = time();
17
-
18
- $context_params = array(
19
- 'plugin_id' => $fs->get_id(),
20
- 'plugin_public_key' => $fs->get_public_key(),
21
- 'plugin_version' => $fs->get_plugin_version(),
22
- );
23
-
24
- // Get site context secure params.
25
- if ( $fs->is_registered() ) {
26
- $context_params = array_merge( $context_params, FS_Security::instance()->get_context_params(
27
- $fs->get_site(),
28
- $timestamp,
29
- 'upgrade'
30
- ) );
31
- }
32
-
33
- if ( $fs->is_payments_sandbox() ) // Append plugin secure token for sandbox mode authentication.)
34
- {
35
- $context_params['sandbox'] = FS_Security::instance()->get_secure_token(
36
- $fs->get_plugin(),
37
- $timestamp,
38
- 'checkout'
39
- );
40
- }
41
-
42
- $query_params = array_merge( $context_params, $_GET, array(
43
- 'next' => $fs->_get_admin_page_url( 'account', array( 'fs_action' => $slug . '_sync_license' ) ),
44
- 'plugin_version' => $fs->get_plugin_version(),
45
- // Billing cycle.
46
- 'billing_cycle' => fs_request_get( 'billing_cycle', WP_FS__PERIOD_ANNUALLY ),
47
- ) );
48
- ?>
49
-
50
- <div id="fs_pricing" class="wrap" style="margin: 0 0 -65px -20px;">
51
- <div id="iframe"></div>
52
- <form action="" method="POST">
53
- <input type="hidden" name="user_id"/>
54
- <input type="hidden" name="user_email"/>
55
- <input type="hidden" name="site_id"/>
56
- <input type="hidden" name="public_key"/>
57
- <input type="hidden" name="secret_key"/>
58
- <input type="hidden" name="action" value="account"/>
59
- </form>
60
-
61
- <script type="text/javascript">
62
- (function ($, undef) {
63
- $(function () {
64
- var
65
- // Keep track of the iframe height.
66
- iframe_height = 800,
67
- base_url = '<?php echo WP_FS__ADDRESS ?>',
68
- // Pass the parent page URL into the Iframe in a meaningful way (this URL could be
69
- // passed via query string or hard coded into the child page, it depends on your needs).
70
- src = base_url + '/pricing/?<?php echo http_build_query($query_params) ?>#' + encodeURIComponent(document.location.href),
71
-
72
- // Append the Iframe into the DOM.
73
- iframe = $('<iframe " src="' + src + '" width="100%" height="' + iframe_height + 'px" scrolling="no" frameborder="0" style="background: transparent;"><\/iframe>')
74
- .appendTo('#iframe');
75
-
76
- FS.PostMessage.init(base_url);
77
-
78
- FS.PostMessage.receive('height', function (data) {
79
- var h = data.height;
80
- if (!isNaN(h) && h > 0 && h != iframe_height) {
81
- iframe_height = h;
82
- $("#iframe iframe").height(iframe_height + 'px');
83
- }
84
- });
85
-
86
- FS.PostMessage.receive('get_dimensions', function (data) {
87
- FS.PostMessage.post('dimensions', {
88
- height : $(document.body).height(),
89
- scrollTop: $(document).scrollTop()
90
- }, iframe[0]);
91
- });
92
- });
93
- })(jQuery);
94
- </script>
95
- </div>
96
- <?php fs_require_template( 'powered-by.php' ) ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
freemius/templates/sticky-admin-notice-js.php DELETED
@@ -1,36 +0,0 @@
1
- <?php
2
- /**
3
- * Sticky admin notices JavaScript handler for dismissing notice messages
4
- * by sending AJAX call to the server in order to remove the message from the Database.
5
- *
6
- * @package Freemius
7
- * @copyright Copyright (c) 2015, Freemius, Inc.
8
- * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
- * @since 1.0.7
10
- */
11
- ?>
12
- <script type="text/javascript" >
13
- jQuery(document).ready(function($) {
14
- $('.fs-notice.fs-sticky .fs-close').click(function(){
15
- var
16
- notice = $(this).parents('.fs-notice'),
17
- id = notice.attr('data-id'),
18
- slug = notice.attr('data-slug');
19
-
20
- notice.fadeOut('fast', function(){
21
- var data = {
22
- action: slug + '_dismiss_notice_action',
23
- slug: slug,
24
- message_id: id
25
- };
26
-
27
- // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
28
- $.post(ajaxurl, data, function(response) {
29
-
30
- });
31
-
32
- notice.remove();
33
- });
34
- });
35
- });
36
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
image-widget.php CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Image Widget
4
  Plugin URI: http://wordpress.org/extend/plugins/image-widget/
5
  Description: A simple image widget that uses the native WordPress media manager to add image widgets to your site.
6
  Author: Modern Tribe, Inc.
7
- Version: 4.2
8
  Author URI: http://m.tri.be/26
9
  */
10
 
@@ -13,37 +13,6 @@ if ( !defined('ABSPATH') ) {
13
  die('-1');
14
  }
15
 
16
- // Create a helper function for easy SDK access.
17
- function iw_fs() {
18
- global $iw_fs;
19
-
20
- if ( ! isset( $iw_fs ) ) {
21
- // Include Freemius SDK.
22
- require_once dirname(__FILE__) . '/freemius/start.php';
23
-
24
- $iw_fs = fs_dynamic_init( array(
25
- 'id' => '117',
26
- 'slug' => 'image-widget',
27
- 'public_key' => 'pk_355c4d1228571fd6f777fb989652e',
28
- 'is_premium' => false,
29
- 'has_addons' => false,
30
- 'has_paid_plans' => false,
31
- 'menu' => array(
32
- 'slug' => 'image-widget',
33
- 'first-path' => 'widgets.php',
34
- 'account' => false,
35
- 'contact' => false,
36
- 'support' => false,
37
- ),
38
- ) );
39
- }
40
-
41
- return $iw_fs;
42
- }
43
-
44
- // Init Freemius.
45
- iw_fs();
46
-
47
  // Load the widget on widgets_init
48
  function tribe_load_image_widget() {
49
  register_widget('Tribe_Image_Widget');
@@ -55,7 +24,7 @@ add_action('widgets_init', 'tribe_load_image_widget');
55
  **/
56
  class Tribe_Image_Widget extends WP_Widget {
57
 
58
- const VERSION = '4.2';
59
 
60
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
61
 
4
  Plugin URI: http://wordpress.org/extend/plugins/image-widget/
5
  Description: A simple image widget that uses the native WordPress media manager to add image widgets to your site.
6
  Author: Modern Tribe, Inc.
7
+ Version: 4.2.1
8
  Author URI: http://m.tri.be/26
9
  */
10
 
13
  die('-1');
14
  }
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
  // Load the widget on widgets_init
17
  function tribe_load_image_widget() {
18
  register_widget('Tribe_Image_Widget');
24
  **/
25
  class Tribe_Image_Widget extends WP_Widget {
26
 
27
+ const VERSION = '4.2.1';
28
 
29
  const CUSTOM_IMAGE_SIZE_SLUG = 'tribe_image_widget_custom';
30
 
index.php CHANGED
File without changes
lang/image_widget-da_DK.mo DELETED
Binary file
lang/image_widget-da_DK.po DELETED
@@ -1,146 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Image Widget\n"
4
- "POT-Creation-Date: 2015-05-06 13:08+0100\n"
5
- "PO-Revision-Date: 2015-05-06 13:11+0100\n"
6
- "Last-Translator: Casper Klenz-Kitenge <hi@cabgfx.com>\n"
7
- "Language-Team: Casper Klenz-Kitenge <hi@cabgfx.com>\n"
8
- "Language: da\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Generator: Poedit 1.7.6\n"
13
- "X-Poedit-Basepath: ..\n"
14
- "X-Poedit-SourceCharset: UTF-8\n"
15
- "X-Poedit-KeywordsList: __;_e;_n:1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;esc_attr__;"
16
- "esc_attr_e;esc_attr_x:1,2c;esc_html__;esc_html_e;esc_html_x:1,2c;_n_noop:1,2;"
17
- "_nx_noop:3c,1,2;__ngettext_noop:1,2\n"
18
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
- "X-Poedit-SearchPath-0: .\n"
20
- "X-Poedit-SearchPathExcluded-0: *.js\n"
21
-
22
- #: image-widget.php:37
23
- msgid "Showcase a single image with a Title, URL, and a Description"
24
- msgstr "Indsæt et billede med titel, URL og beskrivelse"
25
-
26
- #: image-widget.php:39
27
- msgid "Image Widget"
28
- msgstr "Image Widget"
29
-
30
- #: image-widget.php:73 views/widget-admin.php:13
31
- msgid "Select an Image"
32
- msgstr "Vælg et billede"
33
-
34
- #: image-widget.php:74 lib/ImageWidgetDeprecated.php:66
35
- msgid "Insert Into Widget"
36
- msgstr "Indsæt i widget"
37
-
38
- #: image-widget.php:394
39
- #, php-format
40
- msgid ""
41
- "Thanks for upgrading the Image Widget! If you like this plugin, please "
42
- "consider <a href=\"%s\" target=\"_blank\">rating it</a> and maybe even check "
43
- "out our premium plugins including our <a href=\"%s\" target=\"_blank"
44
- "\">Events Calendar Pro</a>!"
45
- msgstr ""
46
- "Tak fordi du opgraderede Image Widget! Hvis du kan lide dette plugin, vil vi "
47
- "sætte pris på at du <a href=\"%s\" target=\"_blank\">giver en bedømmelse</a> "
48
- "og måske endda tjekker vores betalte plugins, fx vores <a href=\"%s\" target="
49
- "\"_blank\">Events Calendar Pro</a>!"
50
-
51
- #: image-widget.php:409
52
- #, php-format
53
- msgid ""
54
- "Check out our other <a href=\"%s\" target=\"_blank\">plugins</a> including "
55
- "our <a href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
56
- msgstr ""
57
- "Tjek vores andre <a href=\"%s\" target=\"_blank\">plugins</a>, fx vores <a "
58
- "href=\"%s\" target=\"_blank\">Events Calendar Pro</a>!"
59
-
60
- #: views/widget-admin.deprecated.php:10 views/widget-admin.php:23
61
- msgid "Title"
62
- msgstr "Titel"
63
-
64
- #: views/widget-admin.deprecated.php:13
65
- msgid "Image"
66
- msgstr "Billede"
67
-
68
- #: views/widget-admin.deprecated.php:17
69
- msgid "Change Image"
70
- msgstr "Skift billede"
71
-
72
- #: views/widget-admin.deprecated.php:17
73
- msgid "Add Image"
74
- msgstr "Tilføj billede"
75
-
76
- #: views/widget-admin.deprecated.php:25 views/widget-admin.php:29
77
- msgid "Caption"
78
- msgstr "Billede-tekst"
79
-
80
- #: views/widget-admin.deprecated.php:28 views/widget-admin.php:32
81
- msgid "Link"
82
- msgstr "Link"
83
-
84
- #: views/widget-admin.deprecated.php:31 views/widget-admin.php:35
85
- msgid "Stay in Window"
86
- msgstr "Åbn i samme vindue"
87
-
88
- #: views/widget-admin.deprecated.php:32 views/widget-admin.php:36
89
- msgid "Open New Window"
90
- msgstr "Åbn i nyt vindue"
91
-
92
- #: views/widget-admin.deprecated.php:35 views/widget-admin.php:66
93
- msgid "Width"
94
- msgstr "Bredde"
95
-
96
- #: views/widget-admin.deprecated.php:38 views/widget-admin.php:69
97
- msgid "Height"
98
- msgstr "Højde"
99
-
100
- #: views/widget-admin.deprecated.php:41 views/widget-admin.php:74
101
- msgid "Align"
102
- msgstr "Justering"
103
-
104
- #: views/widget-admin.deprecated.php:43 views/widget-admin.php:76
105
- msgid "none"
106
- msgstr "ingen"
107
-
108
- #: views/widget-admin.deprecated.php:44 views/widget-admin.php:77
109
- msgid "left"
110
- msgstr "venstre"
111
-
112
- #: views/widget-admin.deprecated.php:45 views/widget-admin.php:78
113
- msgid "center"
114
- msgstr "centreret"
115
-
116
- #: views/widget-admin.deprecated.php:46 views/widget-admin.php:79
117
- msgid "right"
118
- msgstr "højre"
119
-
120
- #: views/widget-admin.deprecated.php:49 views/widget-admin.php:26
121
- msgid "Alternate Text"
122
- msgstr "Alternativ tekst"
123
-
124
- #: views/widget-admin.php:44
125
- msgid "Size"
126
- msgstr "Størrelse"
127
-
128
- #: views/widget-admin.php:49
129
- msgid "Full Size"
130
- msgstr "Fuld"
131
-
132
- #: views/widget-admin.php:50
133
- msgid "Thumbnail"
134
- msgstr "Miniature"
135
-
136
- #: views/widget-admin.php:51
137
- msgid "Medium"
138
- msgstr "Medium"
139
-
140
- #: views/widget-admin.php:52
141
- msgid "Large"
142
- msgstr "Stor"
143
-
144
- #: views/widget-admin.php:54
145
- msgid "Custom"
146
- msgstr "Brugerdefineret"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
lib/index.php CHANGED
File without changes
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, arabic, brazilian portuguese, dutch, german, hebrew, italian, japanese, polish, spanish, swedish, widget-only
5
  Requires at least: 3.5
6
  Tested up to: 4.4
7
- Stable tag: 4.2
8
 
9
  == Description ==
10
 
@@ -155,6 +155,10 @@ For more info on the philosophy here, check out our [blog post](http://tri.be/de
155
 
156
  == Changelog ==
157
 
 
 
 
 
158
  = 4.2 =
159
 
160
  * Security - Prevent direct access to directories (thank you @ramiy)
4
  Tags: widget, image, ad, banner, simple, upload, sidebar, admin, thickbox, resize, arabic, brazilian portuguese, dutch, german, hebrew, italian, japanese, polish, spanish, swedish, widget-only
5
  Requires at least: 3.5
6
  Tested up to: 4.4
7
+ Stable tag: 4.2.1
8
 
9
  == Description ==
10
 
155
 
156
  == Changelog ==
157
 
158
+ = 4.2.1 =
159
+
160
+ * Feature - Removing Freemius. Interesting experiment, but ultimately, not our cup of tea. Thanks for sticking with us!
161
+
162
  = 4.2 =
163
 
164
  * Security - Prevent direct access to directories (thank you @ramiy)
resources/index.php CHANGED
File without changes
resources/js/index.php CHANGED
File without changes
views/index.php CHANGED
File without changes