AdSense Plugin WP QUADS - Version 1.4.0

Version Description

  • New: Add poll when AdSense plugin is deactivated
  • Fix: Responsive AdSense ads are not working if shortcode [quads] is used
  • Fix: On first time WP QUADS AdSense plugin installation make sure that post types post and blog are activated
  • Fix: On update installation make sure that post types post and blog are activated
  • Fix: Notice Undefined index on first time installation
  • Tweak: Remove mail address for support and link to our Google AdSense support ticket page
Download this release

Release Info

Developer ReneHermi
Plugin Icon 128x128 AdSense Plugin WP QUADS
Version 1.4.0
Comparing to
See all releases

Version 1.4.0

Files changed (74) hide show
  1. CONTRIBUTING.md +38 -0
  2. LICENSE +340 -0
  3. README.md +36 -0
  4. assets/css/chosen-sprite.png +0 -0
  5. assets/css/chosen-sprite@2x.png +0 -0
  6. assets/css/chosen.css +430 -0
  7. assets/css/chosen.min.css +3 -0
  8. assets/css/quads-admin.css +797 -0
  9. assets/css/quads-admin.min.css +1 -0
  10. assets/css/quads-plugins-admin.css +40 -0
  11. assets/css/quads-plugins-admin.min.css +40 -0
  12. assets/css/quads.css +10 -0
  13. assets/images/align_0.png +0 -0
  14. assets/images/align_1.png +0 -0
  15. assets/images/align_2.png +0 -0
  16. assets/images/arrow-close.png +0 -0
  17. assets/images/banner_250x296-cfm.png +0 -0
  18. assets/images/banner_300x250_quads.png +0 -0
  19. assets/images/box_arrow.png +0 -0
  20. assets/images/get_pro_overlay.png +0 -0
  21. assets/images/loader.gif +0 -0
  22. assets/images/loader1.gif +0 -0
  23. assets/images/quads_banner_250x521_buy.png +0 -0
  24. assets/images/saved.gif +0 -0
  25. assets/js/chosen.jquery.js +1284 -0
  26. assets/js/chosen.jquery.min.js +2 -0
  27. assets/js/quads-admin.js +1540 -0
  28. assets/js/quads-admin.min.js +1540 -0
  29. assets/js/quads-plugins-admin.js +80 -0
  30. assets/js/quads-plugins-admin.min.js +80 -0
  31. includes/QUADS_SL_Plugin_Updater.php +338 -0
  32. includes/admin/add-ons.php +79 -0
  33. includes/admin/admin-actions.php +32 -0
  34. includes/admin/admin-footer.php +35 -0
  35. includes/admin/admin-notices.php +240 -0
  36. includes/admin/admin-pages.php +64 -0
  37. includes/admin/plugins.php +62 -0
  38. includes/admin/settings/contextual-help.php +50 -0
  39. includes/admin/settings/display-settings.php +339 -0
  40. includes/admin/settings/register-settings.php +1963 -0
  41. includes/admin/tools.php +673 -0
  42. includes/admin/upgrades/upgrade-functions.php +157 -0
  43. includes/admin/views/deactivate-feedback.php +25 -0
  44. includes/admin/welcome.php +72 -0
  45. includes/api.php +136 -0
  46. includes/automattic-amp-ad.php +18 -0
  47. includes/class-quads-html-elements.php +328 -0
  48. includes/class-quads-license-handler.php +466 -0
  49. includes/conditionals.php +145 -0
  50. includes/helper-functions.php +85 -0
  51. includes/libraries/RolingCurlX.php +218 -0
  52. includes/libraries/browser.php +1082 -0
  53. includes/libraries/class-quads-html-elements.php +326 -0
  54. includes/logger.php +129 -0
  55. includes/meta-boxes.php +130 -0
  56. includes/post_types.php +46 -0
  57. includes/quads-utils.php +45 -0
  58. includes/quicktags.php +83 -0
  59. includes/render-ad-functions.php +400 -0
  60. includes/scripts.php +251 -0
  61. includes/shortcodes.php +109 -0
  62. includes/template-functions.php +519 -0
  63. includes/user_roles.php +32 -0
  64. includes/widgets.php +497 -0
  65. languages/README.md +17 -0
  66. languages/index.php +6 -0
  67. languages/quads-en_EN.mo +0 -0
  68. languages/quads-en_EN.po +489 -0
  69. languages/quads.po +489 -0
  70. languages/readme.txt +14 -0
  71. license.txt +281 -0
  72. quick-adsense-reloaded.php +436 -0
  73. readme.txt +358 -0
  74. uninstall.php +50 -0
CONTRIBUTING.md ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #Contribute To Quick AdSense Reloaded
2
+
3
+ Community made patches, localisations, bug reports and contributions are always welcome.
4
+
5
+ When contributing please ensure you follow the guidelines below so that we can keep on top of things.
6
+
7
+ __Please Note:__ GitHub is for bug reports and contributions only - if you have a support question or a request for a customisation don't post here, go to our [Support Forum](https://wordpress.org/support/plugin/quick-adsense-reloaded/) instead.
8
+
9
+ ## Getting Started
10
+
11
+ * Submit a ticket for your issue, assuming one does not already exist.
12
+ * Raise it on our [Issue Tracker](https://github.com/rene-hermenau/quick-adsense-reloaded/issues)
13
+ * Clearly describe the issue including steps to reproduce the bug.
14
+ * Make sure you fill in the earliest version that you know has the issue as well as the version of WordPress you're using.
15
+
16
+ ## Making Changes
17
+
18
+ * Fork the repository on GitHub
19
+ * Make the changes to your forked repository
20
+ * Ensure you stick to the [WordPress Coding Standards](https://codex.wordpress.org/WordPress_Coding_Standards)
21
+ * When committing, reference your issue (if present) and include a note about the fix
22
+ * (coming soon) If possible, and if applicable, please also add/update unit tests for your changes
23
+ * Push the changes to your fork and submit a pull request to the 'master' branch of the repository
24
+
25
+ ## Code Documentation
26
+
27
+ * We ensure that every function is documented well and follows the standards set by phpDoc
28
+ * An example function can be found [here](https://gist.github.com/rene-hermenau/8d3d7ee0633ee2f64b4b)
29
+ * Please make sure that every function is documented so that when we update our API Documentation it will complete
30
+ * If you're adding/editing a function in a class, make sure to add `@access {private|public|protected}`
31
+ * Finally, please use tabs and not spaces. The tab indent size should be 4 for all code.
32
+
33
+ At this point you're waiting on us to merge your pull request. We'll review all pull requests, and make suggestions and changes if necessary.
34
+
35
+ # Additional Resources
36
+ * [General GitHub Documentation](http://help.github.com/)
37
+ * [GitHub Pull Request documentation](http://help.github.com/send-pull-requests/)
38
+ * [PHPUnit Tests Guide](http://phpunit.de/manual/current/en/writing-tests-for-phpunit.html)
LICENSE ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
5
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6
+ Everyone is permitted to copy and distribute verbatim copies
7
+ of this license document, but changing it is not allowed.
8
+
9
+ Preamble
10
+
11
+ The licenses for most software are designed to take away your
12
+ freedom to share and change it. By contrast, the GNU General Public
13
+ License is intended to guarantee your freedom to share and change free
14
+ software--to make sure the software is free for all its users. This
15
+ General Public License applies to most of the Free Software
16
+ Foundation's software and to any other program whose authors commit to
17
+ using it. (Some other Free Software Foundation software is covered by
18
+ the GNU Lesser General Public License instead.) You can apply it to
19
+ your programs, too.
20
+
21
+ When we speak of free software, we are referring to freedom, not
22
+ price. Our General Public Licenses are designed to make sure that you
23
+ have the freedom to distribute copies of free software (and charge for
24
+ this service if you wish), that you receive source code or can get it
25
+ if you want it, that you can change the software or use pieces of it
26
+ in new free programs; and that you know you can do these things.
27
+
28
+ To protect your rights, we need to make restrictions that forbid
29
+ anyone to deny you these rights or to ask you to surrender the rights.
30
+ These restrictions translate to certain responsibilities for you if you
31
+ distribute copies of the software, or if you modify it.
32
+
33
+ For example, if you distribute copies of such a program, whether
34
+ gratis or for a fee, you must give the recipients all the rights that
35
+ you have. You must make sure that they, too, receive or can get the
36
+ source code. And you must show them these terms so they know their
37
+ rights.
38
+
39
+ We protect your rights with two steps: (1) copyright the software, and
40
+ (2) offer you this license which gives you legal permission to copy,
41
+ distribute and/or modify the software.
42
+
43
+ Also, for each author's protection and ours, we want to make certain
44
+ that everyone understands that there is no warranty for this free
45
+ software. If the software is modified by someone else and passed on, we
46
+ want its recipients to know that what they have is not the original, so
47
+ that any problems introduced by others will not reflect on the original
48
+ authors' reputations.
49
+
50
+ Finally, any free program is threatened constantly by software
51
+ patents. We wish to avoid the danger that redistributors of a free
52
+ program will individually obtain patent licenses, in effect making the
53
+ program proprietary. To prevent this, we have made it clear that any
54
+ patent must be licensed for everyone's free use or not licensed at all.
55
+
56
+ The precise terms and conditions for copying, distribution and
57
+ modification follow.
58
+
59
+ GNU GENERAL PUBLIC LICENSE
60
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
61
+
62
+ 0. This License applies to any program or other work which contains
63
+ a notice placed by the copyright holder saying it may be distributed
64
+ under the terms of this General Public License. The "Program", below,
65
+ refers to any such program or work, and a "work based on the Program"
66
+ means either the Program or any derivative work under copyright law:
67
+ that is to say, a work containing the Program or a portion of it,
68
+ either verbatim or with modifications and/or translated into another
69
+ language. (Hereinafter, translation is included without limitation in
70
+ the term "modification".) Each licensee is addressed as "you".
71
+
72
+ Activities other than copying, distribution and modification are not
73
+ covered by this License; they are outside its scope. The act of
74
+ running the Program is not restricted, and the output from the Program
75
+ is covered only if its contents constitute a work based on the
76
+ Program (independent of having been made by running the Program).
77
+ Whether that is true depends on what the Program does.
78
+
79
+ 1. You may copy and distribute verbatim copies of the Program's
80
+ source code as you receive it, in any medium, provided that you
81
+ conspicuously and appropriately publish on each copy an appropriate
82
+ copyright notice and disclaimer of warranty; keep intact all the
83
+ notices that refer to this License and to the absence of any warranty;
84
+ and give any other recipients of the Program a copy of this License
85
+ along with the Program.
86
+
87
+ You may charge a fee for the physical act of transferring a copy, and
88
+ you may at your option offer warranty protection in exchange for a fee.
89
+
90
+ 2. You may modify your copy or copies of the Program or any portion
91
+ of it, thus forming a work based on the Program, and copy and
92
+ distribute such modifications or work under the terms of Section 1
93
+ above, provided that you also meet all of these conditions:
94
+
95
+ a) You must cause the modified files to carry prominent notices
96
+ stating that you changed the files and the date of any change.
97
+
98
+ b) You must cause any work that you distribute or publish, that in
99
+ whole or in part contains or is derived from the Program or any
100
+ part thereof, to be licensed as a whole at no charge to all third
101
+ parties under the terms of this License.
102
+
103
+ c) If the modified program normally reads commands interactively
104
+ when run, you must cause it, when started running for such
105
+ interactive use in the most ordinary way, to print or display an
106
+ announcement including an appropriate copyright notice and a
107
+ notice that there is no warranty (or else, saying that you provide
108
+ a warranty) and that users may redistribute the program under
109
+ these conditions, and telling the user how to view a copy of this
110
+ License. (Exception: if the Program itself is interactive but
111
+ does not normally print such an announcement, your work based on
112
+ the Program is not required to print an announcement.)
113
+
114
+ These requirements apply to the modified work as a whole. If
115
+ identifiable sections of that work are not derived from the Program,
116
+ and can be reasonably considered independent and separate works in
117
+ themselves, then this License, and its terms, do not apply to those
118
+ sections when you distribute them as separate works. But when you
119
+ distribute the same sections as part of a whole which is a work based
120
+ on the Program, the distribution of the whole must be on the terms of
121
+ this License, whose permissions for other licensees extend to the
122
+ entire whole, and thus to each and every part regardless of who wrote it.
123
+
124
+ Thus, it is not the intent of this section to claim rights or contest
125
+ your rights to work written entirely by you; rather, the intent is to
126
+ exercise the right to control the distribution of derivative or
127
+ collective works based on the Program.
128
+
129
+ In addition, mere aggregation of another work not based on the Program
130
+ with the Program (or with a work based on the Program) on a volume of
131
+ a storage or distribution medium does not bring the other work under
132
+ the scope of this License.
133
+
134
+ 3. You may copy and distribute the Program (or a work based on it,
135
+ under Section 2) in object code or executable form under the terms of
136
+ Sections 1 and 2 above provided that you also do one of the following:
137
+
138
+ a) Accompany it with the complete corresponding machine-readable
139
+ source code, which must be distributed under the terms of Sections
140
+ 1 and 2 above on a medium customarily used for software interchange; or,
141
+
142
+ b) Accompany it with a written offer, valid for at least three
143
+ years, to give any third party, for a charge no more than your
144
+ cost of physically performing source distribution, a complete
145
+ machine-readable copy of the corresponding source code, to be
146
+ distributed under the terms of Sections 1 and 2 above on a medium
147
+ customarily used for software interchange; or,
148
+
149
+ c) Accompany it with the information you received as to the offer
150
+ to distribute corresponding source code. (This alternative is
151
+ allowed only for noncommercial distribution and only if you
152
+ received the program in object code or executable form with such
153
+ an offer, in accord with Subsection b above.)
154
+
155
+ The source code for a work means the preferred form of the work for
156
+ making modifications to it. For an executable work, complete source
157
+ code means all the source code for all modules it contains, plus any
158
+ associated interface definition files, plus the scripts used to
159
+ control compilation and installation of the executable. However, as a
160
+ special exception, the source code distributed need not include
161
+ anything that is normally distributed (in either source or binary
162
+ form) with the major components (compiler, kernel, and so on) of the
163
+ operating system on which the executable runs, unless that component
164
+ itself accompanies the executable.
165
+
166
+ If distribution of executable or object code is made by offering
167
+ access to copy from a designated place, then offering equivalent
168
+ access to copy the source code from the same place counts as
169
+ distribution of the source code, even though third parties are not
170
+ compelled to copy the source along with the object code.
171
+
172
+ 4. You may not copy, modify, sublicense, or distribute the Program
173
+ except as expressly provided under this License. Any attempt
174
+ otherwise to copy, modify, sublicense or distribute the Program is
175
+ void, and will automatically terminate your rights under this License.
176
+ However, parties who have received copies, or rights, from you under
177
+ this License will not have their licenses terminated so long as such
178
+ parties remain in full compliance.
179
+
180
+ 5. You are not required to accept this License, since you have not
181
+ signed it. However, nothing else grants you permission to modify or
182
+ distribute the Program or its derivative works. These actions are
183
+ prohibited by law if you do not accept this License. Therefore, by
184
+ modifying or distributing the Program (or any work based on the
185
+ Program), you indicate your acceptance of this License to do so, and
186
+ all its terms and conditions for copying, distributing or modifying
187
+ the Program or works based on it.
188
+
189
+ 6. Each time you redistribute the Program (or any work based on the
190
+ Program), the recipient automatically receives a license from the
191
+ original licensor to copy, distribute or modify the Program subject to
192
+ these terms and conditions. You may not impose any further
193
+ restrictions on the recipients' exercise of the rights granted herein.
194
+ You are not responsible for enforcing compliance by third parties to
195
+ this License.
196
+
197
+ 7. If, as a consequence of a court judgment or allegation of patent
198
+ infringement or for any other reason (not limited to patent issues),
199
+ conditions are imposed on you (whether by court order, agreement or
200
+ otherwise) that contradict the conditions of this License, they do not
201
+ excuse you from the conditions of this License. If you cannot
202
+ distribute so as to satisfy simultaneously your obligations under this
203
+ License and any other pertinent obligations, then as a consequence you
204
+ may not distribute the Program at all. For example, if a patent
205
+ license would not permit royalty-free redistribution of the Program by
206
+ all those who receive copies directly or indirectly through you, then
207
+ the only way you could satisfy both it and this License would be to
208
+ refrain entirely from distribution of the Program.
209
+
210
+ If any portion of this section is held invalid or unenforceable under
211
+ any particular circumstance, the balance of the section is intended to
212
+ apply and the section as a whole is intended to apply in other
213
+ circumstances.
214
+
215
+ It is not the purpose of this section to induce you to infringe any
216
+ patents or other property right claims or to contest validity of any
217
+ such claims; this section has the sole purpose of protecting the
218
+ integrity of the free software distribution system, which is
219
+ implemented by public license practices. Many people have made
220
+ generous contributions to the wide range of software distributed
221
+ through that system in reliance on consistent application of that
222
+ system; it is up to the author/donor to decide if he or she is willing
223
+ to distribute software through any other system and a licensee cannot
224
+ impose that choice.
225
+
226
+ This section is intended to make thoroughly clear what is believed to
227
+ be a consequence of the rest of this License.
228
+
229
+ 8. If the distribution and/or use of the Program is restricted in
230
+ certain countries either by patents or by copyrighted interfaces, the
231
+ original copyright holder who places the Program under this License
232
+ may add an explicit geographical distribution limitation excluding
233
+ those countries, so that distribution is permitted only in or among
234
+ countries not thus excluded. In such case, this License incorporates
235
+ the limitation as if written in the body of this License.
236
+
237
+ 9. The Free Software Foundation may publish revised and/or new versions
238
+ of the General Public License from time to time. Such new versions will
239
+ be similar in spirit to the present version, but may differ in detail to
240
+ address new problems or concerns.
241
+
242
+ Each version is given a distinguishing version number. If the Program
243
+ specifies a version number of this License which applies to it and "any
244
+ later version", you have the option of following the terms and conditions
245
+ either of that version or of any later version published by the Free
246
+ Software Foundation. If the Program does not specify a version number of
247
+ this License, you may choose any version ever published by the Free Software
248
+ Foundation.
249
+
250
+ 10. If you wish to incorporate parts of the Program into other free
251
+ programs whose distribution conditions are different, write to the author
252
+ to ask for permission. For software which is copyrighted by the Free
253
+ Software Foundation, write to the Free Software Foundation; we sometimes
254
+ make exceptions for this. Our decision will be guided by the two goals
255
+ of preserving the free status of all derivatives of our free software and
256
+ of promoting the sharing and reuse of software generally.
257
+
258
+ NO WARRANTY
259
+
260
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
+ REPAIR OR CORRECTION.
269
+
270
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
+ POSSIBILITY OF SUCH DAMAGES.
279
+
280
+ END OF TERMS AND CONDITIONS
281
+
282
+ How to Apply These Terms to Your New Programs
283
+
284
+ If you develop a new program, and you want it to be of the greatest
285
+ possible use to the public, the best way to achieve this is to make it
286
+ free software which everyone can redistribute and change under these terms.
287
+
288
+ To do so, attach the following notices to the program. It is safest
289
+ to attach them to the start of each source file to most effectively
290
+ convey the exclusion of warranty; and each file should have at least
291
+ the "copyright" line and a pointer to where the full notice is found.
292
+
293
+ {description}
294
+ Copyright (C) {year} {fullname}
295
+
296
+ This program is free software; you can redistribute it and/or modify
297
+ it under the terms of the GNU General Public License as published by
298
+ the Free Software Foundation; either version 2 of the License, or
299
+ (at your option) any later version.
300
+
301
+ This program is distributed in the hope that it will be useful,
302
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
303
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
304
+ GNU General Public License for more details.
305
+
306
+ You should have received a copy of the GNU General Public License along
307
+ with this program; if not, write to the Free Software Foundation, Inc.,
308
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
309
+
310
+ Also add information on how to contact you by electronic and paper mail.
311
+
312
+ If the program is interactive, make it output a short notice like this
313
+ when it starts in an interactive mode:
314
+
315
+ Gnomovision version 69, Copyright (C) year name of author
316
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
317
+ This is free software, and you are welcome to redistribute it
318
+ under certain conditions; type `show c' for details.
319
+
320
+ The hypothetical commands `show w' and `show c' should show the appropriate
321
+ parts of the General Public License. Of course, the commands you use may
322
+ be called something other than `show w' and `show c'; they could even be
323
+ mouse-clicks or menu items--whatever suits your program.
324
+
325
+ You should also get your employer (if you work as a programmer) or your
326
+ school, if any, to sign a "copyright disclaimer" for the program, if
327
+ necessary. Here is a sample; alter the names:
328
+
329
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
330
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
331
+
332
+ {signature of Ty Coon}, 1 April 1989
333
+ Ty Coon, President of Vice
334
+
335
+ This General Public License does not permit incorporating your program into
336
+ proprietary programs. If your program is a subroutine library, you may
337
+ consider it more useful to permit linking proprietary applications with the
338
+ library. If this is what you want to do, use the GNU Lesser General
339
+ Public License instead of this License.
340
+
README.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # [WP QUADS (Quick AdSense Reloaded)](https://wordpress.org/support/plugin/quick-adsense-reloaded)
2
+
3
+ ### Welcome to WP QUADS GitHub Repository
4
+
5
+ A further development of Quick Adsense! Insert Google AdSense or any Ads code into your website.
6
+
7
+ More information can be found at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded).
8
+
9
+ ## Note ##
10
+
11
+ This is the latest developer version of WP QUADS.
12
+ if you just want to use WP QUADS install the productive version which you get at [wordpress.org](https://wordpress.org/support/plugin/quick-adsense-reloaded)
13
+
14
+ ## Installation ##
15
+
16
+ 1. You can clone the GitHub repository: `https://github.com/rene-hermenau/quick-adsense-reloaded.git`
17
+ 2. Or download it directly as a ZIP file: `https://github.com/rene-hermenau/quick-adsense-reloaded/archive/master.zip`
18
+
19
+ This will download the latest developer copy of Quick AdSense Reloaded.
20
+
21
+ ## Bugs ##
22
+ If you find an issue, let us know [here](https://github.com/rene-hermenau/quick-adsense-reloaded/issues)!
23
+
24
+ ## Support ##
25
+ This is a developer's portal for WP QUADS and should _not_ be used for support.
26
+ Please visit the [support forums](https://wordpress.org/support/plugin/quick-adsense-reloaded/).
27
+
28
+ ## Contributions ##
29
+ Anyone is welcome to contribute to WP QUADS. Please read the [guidelines for contributing](https://github.com/rene-hermenau/quick-adsense-reloaded/blob/master/CONTRIBUTING.md) to this repository.
30
+
31
+ There are various ways you can contribute:
32
+
33
+ 1. Raise an [Issue](https://github.com/rene-hermenau/quick-adsense-reloaded/issues) on GitHub
34
+ 2. Send us a Pull Request with your bug fixes and/or new features to the dev branch
35
+ 3. Translate WP QUADS into different languages
36
+ 4. Provide feedback and suggestions on [enhancements](https://github.com/rene-hermenau/quick-adsense-reloaded/issues?direction=desc&labels=Enhancement&page=1&sort=created&state=open)
assets/css/chosen-sprite.png ADDED
Binary file
assets/css/chosen-sprite@2x.png ADDED
Binary file
assets/css/chosen.css ADDED
@@ -0,0 +1,430 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* @group Base */
2
+ .chosen-container {
3
+ position: relative;
4
+ display: inline-block;
5
+ vertical-align: middle;
6
+ font-size: 13px;
7
+ zoom: 1;
8
+ *display: inline;
9
+ -webkit-user-select: none;
10
+ -moz-user-select: none;
11
+ user-select: none;
12
+ }
13
+ .chosen-container .chosen-drop {
14
+ position: absolute;
15
+ top: 100%;
16
+ left: -9999px;
17
+ z-index: 1010;
18
+ -webkit-box-sizing: border-box;
19
+ -moz-box-sizing: border-box;
20
+ box-sizing: border-box;
21
+ width: 100%;
22
+ border: 1px solid #aaa;
23
+ border-top: 0;
24
+ background: #fff;
25
+ box-shadow: 0 4px 5px rgba(0, 0, 0, 0.15);
26
+ }
27
+ .chosen-container.chosen-with-drop .chosen-drop {
28
+ left: 0;
29
+ }
30
+ .chosen-container a {
31
+ cursor: pointer;
32
+ }
33
+
34
+ /* @end */
35
+ /* @group Single Chosen */
36
+ .chosen-container-single .chosen-single {
37
+ position: relative;
38
+ display: block;
39
+ overflow: hidden;
40
+ padding: 0 0 0 8px;
41
+ height: 23px;
42
+ border: 1px solid #aaa;
43
+ border-radius: 5px;
44
+ background-color: #fff;
45
+ background: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #ffffff), color-stop(50%, #f6f6f6), color-stop(52%, #eeeeee), color-stop(100%, #f4f4f4));
46
+ background: -webkit-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
47
+ background: -moz-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
48
+ background: -o-linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
49
+ background: linear-gradient(top, #ffffff 20%, #f6f6f6 50%, #eeeeee 52%, #f4f4f4 100%);
50
+ background-clip: padding-box;
51
+ box-shadow: 0 0 3px white inset, 0 1px 1px rgba(0, 0, 0, 0.1);
52
+ color: #444;
53
+ text-decoration: none;
54
+ white-space: nowrap;
55
+ line-height: 24px;
56
+ }
57
+ .chosen-container-single .chosen-default {
58
+ color: #999;
59
+ }
60
+ .chosen-container-single .chosen-single span {
61
+ display: block;
62
+ overflow: hidden;
63
+ margin-right: 26px;
64
+ text-overflow: ellipsis;
65
+ white-space: nowrap;
66
+ }
67
+ .chosen-container-single .chosen-single-with-deselect span {
68
+ margin-right: 38px;
69
+ }
70
+ .chosen-container-single .chosen-single abbr {
71
+ position: absolute;
72
+ top: 6px;
73
+ right: 26px;
74
+ display: block;
75
+ width: 12px;
76
+ height: 12px;
77
+ background: url('chosen-sprite.png') -42px 1px no-repeat;
78
+ font-size: 1px;
79
+ }
80
+ .chosen-container-single .chosen-single abbr:hover {
81
+ background-position: -42px -10px;
82
+ }
83
+ .chosen-container-single.chosen-disabled .chosen-single abbr:hover {
84
+ background-position: -42px -10px;
85
+ }
86
+ .chosen-container-single .chosen-single div {
87
+ position: absolute;
88
+ top: 0;
89
+ right: 0;
90
+ display: block;
91
+ width: 18px;
92
+ height: 100%;
93
+ }
94
+ .chosen-container-single .chosen-single div b {
95
+ display: block;
96
+ width: 100%;
97
+ height: 100%;
98
+ background: url('chosen-sprite.png') no-repeat 0px 2px;
99
+ }
100
+ .chosen-container-single .chosen-search {
101
+ position: relative;
102
+ z-index: 1010;
103
+ margin: 0;
104
+ padding: 3px 4px;
105
+ white-space: nowrap;
106
+ }
107
+ .chosen-container-single .chosen-search input[type="text"] {
108
+ -webkit-box-sizing: border-box;
109
+ -moz-box-sizing: border-box;
110
+ box-sizing: border-box;
111
+ margin: 1px 0;
112
+ padding: 4px 20px 4px 5px;
113
+ width: 100%;
114
+ height: auto;
115
+ outline: 0;
116
+ border: 1px solid #aaa;
117
+ background: white url('chosen-sprite.png') no-repeat 100% -20px;
118
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
119
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
120
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
121
+ background: url('chosen-sprite.png') no-repeat 100% -20px, -o-linear-gradient(#eeeeee 1%, #ffffff 15%);
122
+ background: url('chosen-sprite.png') no-repeat 100% -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
123
+ font-size: 1em;
124
+ font-family: sans-serif;
125
+ line-height: normal;
126
+ border-radius: 0;
127
+ }
128
+ .chosen-container-single .chosen-drop {
129
+ margin-top: -1px;
130
+ border-radius: 0 0 4px 4px;
131
+ background-clip: padding-box;
132
+ }
133
+ .chosen-container-single.chosen-container-single-nosearch .chosen-search {
134
+ position: absolute;
135
+ left: -9999px;
136
+ }
137
+
138
+ /* @end */
139
+ /* @group Results */
140
+ .chosen-container .chosen-results {
141
+ position: relative;
142
+ overflow-x: hidden;
143
+ overflow-y: auto;
144
+ margin: 0 4px 4px 0;
145
+ padding: 0 0 0 4px;
146
+ max-height: 240px;
147
+ -webkit-overflow-scrolling: touch;
148
+ }
149
+ .chosen-container .chosen-results li {
150
+ display: none;
151
+ margin: 0;
152
+ padding: 5px 6px;
153
+ list-style: none;
154
+ line-height: 15px;
155
+ }
156
+ .chosen-container .chosen-results li.active-result {
157
+ display: list-item;
158
+ cursor: pointer;
159
+ }
160
+ .chosen-container .chosen-results li.disabled-result {
161
+ display: list-item;
162
+ color: #ccc;
163
+ cursor: default;
164
+ }
165
+ .chosen-container .chosen-results li.highlighted {
166
+ background-color: #3875d7;
167
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #3875d7), color-stop(90%, #2a62bc));
168
+ background-image: -webkit-linear-gradient(#3875d7 20%, #2a62bc 90%);
169
+ background-image: -moz-linear-gradient(#3875d7 20%, #2a62bc 90%);
170
+ background-image: -o-linear-gradient(#3875d7 20%, #2a62bc 90%);
171
+ background-image: linear-gradient(#3875d7 20%, #2a62bc 90%);
172
+ color: #fff;
173
+ }
174
+ .chosen-container .chosen-results li.no-results {
175
+ display: list-item;
176
+ background: #f4f4f4;
177
+ }
178
+ .chosen-container .chosen-results li.group-result {
179
+ display: list-item;
180
+ font-weight: bold;
181
+ cursor: default;
182
+ }
183
+ .chosen-container .chosen-results li.group-option {
184
+ padding-left: 15px;
185
+ }
186
+ .chosen-container .chosen-results li em {
187
+ font-style: normal;
188
+ text-decoration: underline;
189
+ }
190
+
191
+ /* @end */
192
+ /* @group Multi Chosen */
193
+ .chosen-container-multi .chosen-choices {
194
+ position: relative;
195
+ overflow: hidden;
196
+ -webkit-box-sizing: border-box;
197
+ -moz-box-sizing: border-box;
198
+ box-sizing: border-box;
199
+ margin: 0;
200
+ padding: 0;
201
+ width: 100%;
202
+ height: auto !important;
203
+ height: 1%;
204
+ border: 1px solid #aaa;
205
+ background-color: #fff;
206
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
207
+ background-image: -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
208
+ background-image: -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
209
+ background-image: -o-linear-gradient(#eeeeee 1%, #ffffff 15%);
210
+ background-image: linear-gradient(#eeeeee 1%, #ffffff 15%);
211
+ cursor: text;
212
+ }
213
+ .chosen-container-multi .chosen-choices li {
214
+ float: left;
215
+ list-style: none;
216
+ }
217
+ .chosen-container-multi .chosen-choices li.search-field {
218
+ margin: 0;
219
+ padding: 0;
220
+ white-space: nowrap;
221
+ }
222
+ .chosen-container-multi .chosen-choices li.search-field input[type="text"] {
223
+ margin: 1px 0;
224
+ padding: 5px;
225
+ height: 15px;
226
+ outline: 0;
227
+ border: 0 !important;
228
+ background: transparent !important;
229
+ box-shadow: none;
230
+ color: #666;
231
+ font-size: 100%;
232
+ font-family: sans-serif;
233
+ line-height: normal;
234
+ border-radius: 0;
235
+ }
236
+ .chosen-container-multi .chosen-choices li.search-field .default {
237
+ color: #999;
238
+ }
239
+ .chosen-container-multi .chosen-choices li.search-choice {
240
+ position: relative;
241
+ margin: 3px 0 3px 5px;
242
+ padding: 3px 20px 3px 5px;
243
+ border: 1px solid #aaa;
244
+ border-radius: 3px;
245
+ background-color: #e4e4e4;
246
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
247
+ background-image: -webkit-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
248
+ background-image: -moz-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
249
+ background-image: -o-linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
250
+ background-image: linear-gradient(#f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
251
+ background-clip: padding-box;
252
+ box-shadow: 0 0 2px white inset, 0 1px 0 rgba(0, 0, 0, 0.05);
253
+ color: #333;
254
+ line-height: 13px;
255
+ cursor: default;
256
+ }
257
+ .chosen-container-multi .chosen-choices li.search-choice .search-choice-close {
258
+ position: absolute;
259
+ top: 4px;
260
+ right: 3px;
261
+ display: block;
262
+ width: 12px;
263
+ height: 12px;
264
+ background: url('chosen-sprite.png') -42px 1px no-repeat;
265
+ font-size: 1px;
266
+ }
267
+ .chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover {
268
+ background-position: -42px -10px;
269
+ }
270
+ .chosen-container-multi .chosen-choices li.search-choice-disabled {
271
+ padding-right: 5px;
272
+ border: 1px solid #ccc;
273
+ background-color: #e4e4e4;
274
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eeeeee));
275
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
276
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
277
+ background-image: -o-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
278
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eeeeee 100%);
279
+ color: #666;
280
+ }
281
+ .chosen-container-multi .chosen-choices li.search-choice-focus {
282
+ background: #d4d4d4;
283
+ }
284
+ .chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close {
285
+ background-position: -42px -10px;
286
+ }
287
+ .chosen-container-multi .chosen-results {
288
+ margin: 0;
289
+ padding: 0;
290
+ }
291
+ .chosen-container-multi .chosen-drop .result-selected {
292
+ display: list-item;
293
+ color: #ccc;
294
+ cursor: default;
295
+ }
296
+
297
+ /* @end */
298
+ /* @group Active */
299
+ .chosen-container-active .chosen-single {
300
+ border: 1px solid #5897fb;
301
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
302
+ }
303
+ .chosen-container-active.chosen-with-drop .chosen-single {
304
+ border: 1px solid #aaa;
305
+ -moz-border-radius-bottomright: 0;
306
+ border-bottom-right-radius: 0;
307
+ -moz-border-radius-bottomleft: 0;
308
+ border-bottom-left-radius: 0;
309
+ background-image: -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(20%, #eeeeee), color-stop(80%, #ffffff));
310
+ background-image: -webkit-linear-gradient(#eeeeee 20%, #ffffff 80%);
311
+ background-image: -moz-linear-gradient(#eeeeee 20%, #ffffff 80%);
312
+ background-image: -o-linear-gradient(#eeeeee 20%, #ffffff 80%);
313
+ background-image: linear-gradient(#eeeeee 20%, #ffffff 80%);
314
+ box-shadow: 0 1px 0 #fff inset;
315
+ }
316
+ .chosen-container-active.chosen-with-drop .chosen-single div {
317
+ border-left: none;
318
+ background: transparent;
319
+ }
320
+ .chosen-container-active.chosen-with-drop .chosen-single div b {
321
+ background-position: -18px 2px;
322
+ }
323
+ .chosen-container-active .chosen-choices {
324
+ border: 1px solid #5897fb;
325
+ box-shadow: 0 0 5px rgba(0, 0, 0, 0.3);
326
+ }
327
+ .chosen-container-active .chosen-choices li.search-field input[type="text"] {
328
+ color: #111 !important;
329
+ }
330
+
331
+ /* @end */
332
+ /* @group Disabled Support */
333
+ .chosen-disabled {
334
+ opacity: 0.5 !important;
335
+ cursor: default;
336
+ }
337
+ .chosen-disabled .chosen-single {
338
+ cursor: default;
339
+ }
340
+ .chosen-disabled .chosen-choices .search-choice .search-choice-close {
341
+ cursor: default;
342
+ }
343
+
344
+ /* @end */
345
+ /* @group Right to Left */
346
+ .chosen-rtl {
347
+ text-align: right;
348
+ }
349
+ .chosen-rtl .chosen-single {
350
+ overflow: visible;
351
+ padding: 0 8px 0 0;
352
+ }
353
+ .chosen-rtl .chosen-single span {
354
+ margin-right: 0;
355
+ margin-left: 26px;
356
+ direction: rtl;
357
+ }
358
+ .chosen-rtl .chosen-single-with-deselect span {
359
+ margin-left: 38px;
360
+ }
361
+ .chosen-rtl .chosen-single div {
362
+ right: auto;
363
+ left: 3px;
364
+ }
365
+ .chosen-rtl .chosen-single abbr {
366
+ right: auto;
367
+ left: 26px;
368
+ }
369
+ .chosen-rtl .chosen-choices li {
370
+ float: right;
371
+ }
372
+ .chosen-rtl .chosen-choices li.search-field input[type="text"] {
373
+ direction: rtl;
374
+ }
375
+ .chosen-rtl .chosen-choices li.search-choice {
376
+ margin: 3px 5px 3px 0;
377
+ padding: 3px 5px 3px 19px;
378
+ }
379
+ .chosen-rtl .chosen-choices li.search-choice .search-choice-close {
380
+ right: auto;
381
+ left: 4px;
382
+ }
383
+ .chosen-rtl.chosen-container-single-nosearch .chosen-search,
384
+ .chosen-rtl .chosen-drop {
385
+ left: 9999px;
386
+ }
387
+ .chosen-rtl.chosen-container-single .chosen-results {
388
+ margin: 0 0 4px 4px;
389
+ padding: 0 4px 0 0;
390
+ }
391
+ .chosen-rtl .chosen-results li.group-option {
392
+ padding-right: 15px;
393
+ padding-left: 0;
394
+ }
395
+ .chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div {
396
+ border-right: none;
397
+ }
398
+ .chosen-rtl .chosen-search input[type="text"] {
399
+ padding: 4px 5px 4px 20px;
400
+ background: white url('chosen-sprite.png') no-repeat -30px -20px;
401
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-gradient(linear, 50% 0%, 50% 100%, color-stop(1%, #eeeeee), color-stop(15%, #ffffff));
402
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -webkit-linear-gradient(#eeeeee 1%, #ffffff 15%);
403
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -moz-linear-gradient(#eeeeee 1%, #ffffff 15%);
404
+ background: url('chosen-sprite.png') no-repeat -30px -20px, -o-linear-gradient(#eeeeee 1%, #ffffff 15%);
405
+ background: url('chosen-sprite.png') no-repeat -30px -20px, linear-gradient(#eeeeee 1%, #ffffff 15%);
406
+ direction: rtl;
407
+ }
408
+ .chosen-rtl.chosen-container-single .chosen-single div b {
409
+ background-position: 6px 2px;
410
+ }
411
+ .chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b {
412
+ background-position: -12px 2px;
413
+ }
414
+
415
+ /* @end */
416
+ /* @group Retina compatibility */
417
+ @media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-resolution: 144dpi) {
418
+ .chosen-rtl .chosen-search input[type="text"],
419
+ .chosen-container-single .chosen-single abbr,
420
+ .chosen-container-single .chosen-single div b,
421
+ .chosen-container-single .chosen-search input[type="text"],
422
+ .chosen-container-multi .chosen-choices .search-choice .search-choice-close,
423
+ .chosen-container .chosen-results-scroll-down span,
424
+ .chosen-container .chosen-results-scroll-up span {
425
+ background-image: url('chosen-sprite@2x.png') !important;
426
+ background-size: 52px 37px !important;
427
+ background-repeat: no-repeat !important;
428
+ }
429
+ }
430
+ /* @end */
assets/css/chosen.min.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ /* Chosen v1.0.0 | (c) 2011-2013 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+
3
+ .chosen-container{position:relative;display:inline-block;vertical-align:middle;font-size:13px;zoom:1;*display:inline;-webkit-user-select:none;-moz-user-select:none;user-select:none}.chosen-container .chosen-drop{position:absolute;top:100%;left:-9999px;z-index:1010;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;width:100%;border:1px solid #aaa;border-top:0;background:#fff;box-shadow:0 4px 5px rgba(0,0,0,.15)}.chosen-container.chosen-with-drop .chosen-drop{left:0}.chosen-container a{cursor:pointer}.chosen-container-single .chosen-single{position:relative;display:block;overflow:hidden;padding:0 0 0 8px;height:23px;border:1px solid #aaa;border-radius:5px;background-color:#fff;background:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#fff),color-stop(50%,#f6f6f6),color-stop(52%,#eee),color-stop(100%,#f4f4f4));background:-webkit-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-moz-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:-o-linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background:linear-gradient(top,#fff 20%,#f6f6f6 50%,#eee 52%,#f4f4f4 100%);background-clip:padding-box;box-shadow:0 0 3px #fff inset,0 1px 1px rgba(0,0,0,.1);color:#444;text-decoration:none;white-space:nowrap;line-height:24px}.chosen-container-single .chosen-default{color:#999}.chosen-container-single .chosen-single span{display:block;overflow:hidden;margin-right:26px;text-overflow:ellipsis;white-space:nowrap}.chosen-container-single .chosen-single-with-deselect span{margin-right:38px}.chosen-container-single .chosen-single abbr{position:absolute;top:6px;right:26px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-single .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single.chosen-disabled .chosen-single abbr:hover{background-position:-42px -10px}.chosen-container-single .chosen-single div{position:absolute;top:0;right:0;display:block;width:18px;height:100%}.chosen-container-single .chosen-single div b{display:block;width:100%;height:100%;background:url(chosen-sprite.png) no-repeat 0 2px}.chosen-container-single .chosen-search{position:relative;z-index:1010;margin:0;padding:3px 4px;white-space:nowrap}.chosen-container-single .chosen-search input[type=text]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:1px 0;padding:4px 20px 4px 5px;width:100%;height:auto;outline:0;border:1px solid #aaa;background:#fff url(chosen-sprite.png) no-repeat 100% -20px;background:url(chosen-sprite.png) no-repeat 100% -20px,-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background:url(chosen-sprite.png) no-repeat 100% -20px,-webkit-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,-moz-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,-o-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat 100% -20px,linear-gradient(#eee 1%,#fff 15%);font-size:1em;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-single .chosen-drop{margin-top:-1px;border-radius:0 0 4px 4px;background-clip:padding-box}.chosen-container-single.chosen-container-single-nosearch .chosen-search{position:absolute;left:-9999px}.chosen-container .chosen-results{position:relative;overflow-x:hidden;overflow-y:auto;margin:0 4px 4px 0;padding:0 0 0 4px;max-height:240px;-webkit-overflow-scrolling:touch}.chosen-container .chosen-results li{display:none;margin:0;padding:5px 6px;list-style:none;line-height:15px}.chosen-container .chosen-results li.active-result{display:list-item;cursor:pointer}.chosen-container .chosen-results li.disabled-result{display:list-item;color:#ccc;cursor:default}.chosen-container .chosen-results li.highlighted{background-color:#3875d7;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#3875d7),color-stop(90%,#2a62bc));background-image:-webkit-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-moz-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:-o-linear-gradient(#3875d7 20%,#2a62bc 90%);background-image:linear-gradient(#3875d7 20%,#2a62bc 90%);color:#fff}.chosen-container .chosen-results li.no-results{display:list-item;background:#f4f4f4}.chosen-container .chosen-results li.group-result{display:list-item;font-weight:700;cursor:default}.chosen-container .chosen-results li.group-option{padding-left:15px}.chosen-container .chosen-results li em{font-style:normal;text-decoration:underline}.chosen-container-multi .chosen-choices{position:relative;overflow:hidden;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;margin:0;padding:0;width:100%;height:auto!important;height:1%;border:1px solid #aaa;background-color:#fff;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background-image:-webkit-linear-gradient(#eee 1%,#fff 15%);background-image:-moz-linear-gradient(#eee 1%,#fff 15%);background-image:-o-linear-gradient(#eee 1%,#fff 15%);background-image:linear-gradient(#eee 1%,#fff 15%);cursor:text}.chosen-container-multi .chosen-choices li{float:left;list-style:none}.chosen-container-multi .chosen-choices li.search-field{margin:0;padding:0;white-space:nowrap}.chosen-container-multi .chosen-choices li.search-field input[type=text]{margin:1px 0;padding:5px;height:15px;outline:0;border:0!important;background:transparent!important;box-shadow:none;color:#666;font-size:100%;font-family:sans-serif;line-height:normal;border-radius:0}.chosen-container-multi .chosen-choices li.search-field .default{color:#999}.chosen-container-multi .chosen-choices li.search-choice{position:relative;margin:3px 0 3px 5px;padding:3px 20px 3px 5px;border:1px solid #aaa;border-radius:3px;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-clip:padding-box;box-shadow:0 0 2px #fff inset,0 1px 0 rgba(0,0,0,.05);color:#333;line-height:13px;cursor:default}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close{position:absolute;top:4px;right:3px;display:block;width:12px;height:12px;background:url(chosen-sprite.png) -42px 1px no-repeat;font-size:1px}.chosen-container-multi .chosen-choices li.search-choice .search-choice-close:hover{background-position:-42px -10px}.chosen-container-multi .chosen-choices li.search-choice-disabled{padding-right:5px;border:1px solid #ccc;background-color:#e4e4e4;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#f4f4f4),color-stop(50%,#f0f0f0),color-stop(52%,#e8e8e8),color-stop(100%,#eee));background-image:-webkit-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-moz-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:-o-linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);background-image:linear-gradient(top,#f4f4f4 20%,#f0f0f0 50%,#e8e8e8 52%,#eee 100%);color:#666}.chosen-container-multi .chosen-choices li.search-choice-focus{background:#d4d4d4}.chosen-container-multi .chosen-choices li.search-choice-focus .search-choice-close{background-position:-42px -10px}.chosen-container-multi .chosen-results{margin:0;padding:0}.chosen-container-multi .chosen-drop .result-selected{display:list-item;color:#ccc;cursor:default}.chosen-container-active .chosen-single{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active.chosen-with-drop .chosen-single{border:1px solid #aaa;-moz-border-radius-bottomright:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;border-bottom-left-radius:0;background-image:-webkit-gradient(linear,50% 0,50% 100%,color-stop(20%,#eee),color-stop(80%,#fff));background-image:-webkit-linear-gradient(#eee 20%,#fff 80%);background-image:-moz-linear-gradient(#eee 20%,#fff 80%);background-image:-o-linear-gradient(#eee 20%,#fff 80%);background-image:linear-gradient(#eee 20%,#fff 80%);box-shadow:0 1px 0 #fff inset}.chosen-container-active.chosen-with-drop .chosen-single div{border-left:0;background:transparent}.chosen-container-active.chosen-with-drop .chosen-single div b{background-position:-18px 2px}.chosen-container-active .chosen-choices{border:1px solid #5897fb;box-shadow:0 0 5px rgba(0,0,0,.3)}.chosen-container-active .chosen-choices li.search-field input[type=text]{color:#111!important}.chosen-disabled{opacity:.5!important;cursor:default}.chosen-disabled .chosen-single{cursor:default}.chosen-disabled .chosen-choices .search-choice .search-choice-close{cursor:default}.chosen-rtl{text-align:right}.chosen-rtl .chosen-single{overflow:visible;padding:0 8px 0 0}.chosen-rtl .chosen-single span{margin-right:0;margin-left:26px;direction:rtl}.chosen-rtl .chosen-single-with-deselect span{margin-left:38px}.chosen-rtl .chosen-single div{right:auto;left:3px}.chosen-rtl .chosen-single abbr{right:auto;left:26px}.chosen-rtl .chosen-choices li{float:right}.chosen-rtl .chosen-choices li.search-field input[type=text]{direction:rtl}.chosen-rtl .chosen-choices li.search-choice{margin:3px 5px 3px 0;padding:3px 5px 3px 19px}.chosen-rtl .chosen-choices li.search-choice .search-choice-close{right:auto;left:4px}.chosen-rtl.chosen-container-single-nosearch .chosen-search,.chosen-rtl .chosen-drop{left:9999px}.chosen-rtl.chosen-container-single .chosen-results{margin:0 0 4px 4px;padding:0 4px 0 0}.chosen-rtl .chosen-results li.group-option{padding-right:15px;padding-left:0}.chosen-rtl.chosen-container-active.chosen-with-drop .chosen-single div{border-right:0}.chosen-rtl .chosen-search input[type=text]{padding:4px 5px 4px 20px;background:#fff url(chosen-sprite.png) no-repeat -30px -20px;background:url(chosen-sprite.png) no-repeat -30px -20px,-webkit-gradient(linear,50% 0,50% 100%,color-stop(1%,#eee),color-stop(15%,#fff));background:url(chosen-sprite.png) no-repeat -30px -20px,-webkit-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,-moz-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,-o-linear-gradient(#eee 1%,#fff 15%);background:url(chosen-sprite.png) no-repeat -30px -20px,linear-gradient(#eee 1%,#fff 15%);direction:rtl}.chosen-rtl.chosen-container-single .chosen-single div b{background-position:6px 2px}.chosen-rtl.chosen-container-single.chosen-with-drop .chosen-single div b{background-position:-12px 2px}@media only screen and (-webkit-min-device-pixel-ratio:2),only screen and (min-resolution:144dpi){.chosen-rtl .chosen-search input[type=text],.chosen-container-single .chosen-single abbr,.chosen-container-single .chosen-single div b,.chosen-container-single .chosen-search input[type=text],.chosen-container-multi .chosen-choices .search-choice .search-choice-close,.chosen-container .chosen-results-scroll-down span,.chosen-container .chosen-results-scroll-up span{background-image:url(chosen-sprite@2x.png)!important;background-size:52px 37px!important;background-repeat:no-repeat!important}}
assets/css/quads-admin.css ADDED
@@ -0,0 +1,797 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * QUADS Admin CSS
3
+ *
4
+ * @package QUADS
5
+ * @subpackage Admin CSS
6
+ * @copyright Copyright (c) 2015, René Hermenau
7
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
8
+ */
9
+
10
+ .quads-share-button-container{
11
+ margin: 5px 0;
12
+ }
13
+
14
+ .quads-share-button-container p{
15
+ margin:0px 0 10px 0;
16
+ }
17
+
18
+ .quads-share-button {
19
+ display: inline-block;
20
+ }
21
+
22
+ .quads-share-button a{
23
+ text-decoration:none;
24
+ }
25
+
26
+ .quads-share-button .quads-share {
27
+ font-family:sans-serif;
28
+ font-weight:bold;
29
+ text-decoration:none;
30
+ text-align:center;
31
+ }
32
+
33
+
34
+ .quads-share-button .quads-share {
35
+ -webkit-border-radius:2px;
36
+ -moz-border-radius:2px;
37
+ border-radius:2px;
38
+ color:#FFF;
39
+ display:inline;
40
+ font-size:16px;
41
+ width:40px;
42
+ padding:4px 8px;
43
+ }
44
+
45
+ .quads-share-button-twitter .quads-share {
46
+ background-color:#00ABF0;
47
+ }
48
+
49
+ .quads-share-button-facebook .quads-share {
50
+ background-color:#3b5998;
51
+ }
52
+
53
+ .quads-share-button-googleplus .quads-share {
54
+ background-color:#F53424;
55
+ }
56
+
57
+ .quads-share-button-twitter .share:active,.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active {
58
+ background-color:#353535;
59
+ }
60
+
61
+ /* Responsive */
62
+ @media (max-width: 925px) {
63
+ .quads-share-button .quads-share{
64
+ font-size:15px;
65
+ padding: 8px 16px; /* Double the padding */
66
+ }
67
+
68
+ }
69
+
70
+
71
+ /* Input forms */
72
+ /*.quads-textarea{
73
+ font-size:11px;
74
+ }*/
75
+ .quads-richeditor{
76
+ font-size:11px;
77
+ }
78
+
79
+
80
+
81
+ /* =Add Ons Styles
82
+ -------------------------------------------------------------- */
83
+ #quads-add-ons h2 { margin: 0 0 15px; }
84
+ #quads-add-ons .quadsshare-addons { float: left; margin: 0 15px 15px 0; background: #f0f0f0; border: 1px solid #ccc; width: 320px; padding: 8px; height: 315px; position: relative; }
85
+ #quads-add-ons .quadsshare-addons h3 { margin: 0 0 8px; font-size: 13px; }
86
+ #quads-add-ons .quadsshare-addons .button-secondary { position: absolute; bottom: 8px; left: 8px; }
87
+ /*#quads-add-ons .quadsshare-addons { clear:both; width:100%; }*/
88
+ #quads-add-ons .quadsshare-addons .third-party { display: none; }
89
+
90
+
91
+ /* System Info page styles
92
+ -------------------------------------------------------------- */
93
+ #system-info-textarea { width: 580px; height: 400px; font-family: Menlo, Monaco, monospace; background: none; white-space: pre; overflow: auto; display: block; }
94
+
95
+
96
+ /* General styles
97
+ -------------------------------------------------------------- */
98
+ .quads-select-chosen { width: 300px; }
99
+
100
+ input.large-text, textarea.large-text {
101
+ max-width: 600px;
102
+ }
103
+ input.medium-text, textarea.medium-text {
104
+ min-width: 190px;
105
+ }
106
+
107
+ /* CSS for Tabs */
108
+
109
+ #quads_tab_container ul {
110
+ /*height: 200px;*/
111
+ list-style: none;
112
+ margin: 0;
113
+ padding: 0;
114
+ background: #fff;
115
+ float: left;
116
+ padding-top: 0px;
117
+ /*list-style-type: square;*/
118
+ }
119
+
120
+ #quads_tab_container ul li:first-child.selected-tab {
121
+ border-top: none;
122
+ }
123
+
124
+ #quads_tab_container ul li a.selected-tab {
125
+ font-weight: bold;
126
+ text-decoration: none;
127
+ }
128
+
129
+
130
+
131
+ #quads_tab_container .row{
132
+ padding-top:12px;
133
+ padding-bottom:12px;
134
+ }
135
+
136
+
137
+ #quads_tab_container .row label strong, #tab_container .row strong {
138
+ font-weight: bold;
139
+ }
140
+
141
+ .quads-tabs a {
142
+ padding:5px;
143
+ color:#a1a1a1;
144
+ text-transform: uppercase;
145
+ }
146
+ .quads-tabs a strong {
147
+ font-weight: 700;
148
+ }
149
+
150
+ li.quads-tabs {
151
+ float:left;
152
+ margin-left:0px;
153
+ background-color: #e5e5e5;
154
+ }
155
+
156
+ /*@media only screen and (min-width:400px) {
157
+ li.quads-tabs {
158
+ float:left;
159
+ margin-left:14px;
160
+ }
161
+ }*/
162
+
163
+ #quads_tab_container > ul > li.quads-tabs.active {
164
+ background-color:#fff;
165
+ }
166
+ #quads_tab_container > ul > li.quads-tabs.active a {
167
+ color: #83c11f;
168
+ }
169
+
170
+
171
+
172
+ /* Layout of admin table and rows
173
+ */
174
+
175
+
176
+ #quads_tab_container .quads-panel-container {
177
+ background: #FFF;
178
+ padding:20px;
179
+ overflow:auto;
180
+ text-align:left;
181
+ margin-bottom:10px;
182
+ max-width: 640px;
183
+ float: left;
184
+ clear:both;
185
+ }
186
+
187
+ .form-table{
188
+ margin-top:-20px;
189
+ }
190
+
191
+ #quads_tab_container .form-table th {
192
+ vertical-align: top;
193
+ text-align: left;
194
+ padding: 20px 10px 20px 0;
195
+ width: 200px;
196
+ line-height: 1.3;
197
+ font-weight: bold;
198
+ font-size: 14px;
199
+ color:#484848;
200
+ width: 30%;
201
+ }
202
+
203
+ /*#quads_tab_container .form-table tr{
204
+ padding:0px;
205
+ }*/
206
+
207
+ #quads_tab_container .form-table tr {
208
+ border-bottom: 1px solid #E7E7E7;
209
+ }
210
+
211
+ #quads_tab_container span.description{
212
+ display: block;
213
+ font-weight: 400;
214
+ font-style: normal;
215
+ font-size: 13px;
216
+ margin-top: 7px;
217
+ color:#484848;
218
+ }
219
+
220
+ #quads_tab_container .col-title{
221
+ font-size: 18px;
222
+ color:#484848;
223
+ }
224
+
225
+ @media only screen and (max-width:680px) {
226
+ #quads_tab_container ul {
227
+ float:none;
228
+ background: #fff;
229
+ }
230
+ #quads_tab_container .form-table tr > th {
231
+ width:100%;
232
+ }
233
+ #quads_tab_container span.description{
234
+ font-size: 14px;
235
+ }
236
+ #quads_tab_container .form-table tr > th, #tab_container .form-table tr > td {
237
+ padding:10px;
238
+ }
239
+ #quads_tab_container .quads-tabs a{
240
+ text-align: left;
241
+ }
242
+ #quads_tab_container li.quads-tabs {
243
+ float:none;
244
+ margin-left:0px;
245
+ }
246
+ }
247
+
248
+ #quads_tab_container ul li.quads-tabs {
249
+ margin-bottom:0px;
250
+ }
251
+
252
+ #quads_tab_container ul li.quads-tabs a {
253
+ display: block;
254
+ padding:10px 10px 10px 10px;
255
+ text-decoration: none;
256
+ font-weight: bold;
257
+ }
258
+ #quads_tab_container ul li.quads-tabs a:hover {
259
+ color:#383838;
260
+ }
261
+ #quads_tab_container ul li.quads-tabs a.active {
262
+ text-decoration: underline;
263
+ }
264
+
265
+
266
+ #quads_tab_container table tbody tr:nth-child(1) > th > div {
267
+ font-size: 20px;
268
+ }
269
+
270
+
271
+
272
+ /* End layout of admin table and rows
273
+ */
274
+ #quadstabcontainer > .quadstabs {
275
+ background-color: #ffffff;
276
+ }
277
+
278
+ #quadstabcontainer ul .active {
279
+ background-color: #00adef;
280
+ color: white;
281
+ border-bottom-color: #0098D2;
282
+ }
283
+
284
+ #quadstabcontainer ul .active:hover {
285
+ background-color: #00A4E2;
286
+ color: white;
287
+ border-bottom-color: #0098D2;
288
+ }
289
+
290
+ #quadstabcontainer ul li a {
291
+ padding: 10px 14px 10px 14px;
292
+ background-color: #f3f3f3
293
+
294
+ }
295
+
296
+ #quadstabcontainer .quadstab-container {
297
+ border: 0px solid #ececec;
298
+ }
299
+
300
+ .quads-quote-docs {
301
+ font-family:Courier New,Courier,Fixed;
302
+ color:#050;
303
+ }
304
+
305
+ .quads-desc{
306
+ display:block;
307
+ font-style:italic;
308
+ padding-top:10px;
309
+ }
310
+
311
+ .quads-postbox {
312
+ padding:10px;
313
+ position: relative;
314
+ min-width: 255px;
315
+ border: 1px solid #e5e5e5;
316
+ -webkit-box-shadow: 0 1px 1px rgba(0,0,0,0.04);
317
+ box-shadow: 0 1px 1px rgba(0,0,0,0.04);
318
+ background: #fff;
319
+ margin-bottom:20px;
320
+ }
321
+
322
+ .nav-tab-active{
323
+ background-color: white;
324
+ border-bottom:0px;
325
+ }
326
+
327
+ /*.wp-admin .quads-align-input{
328
+ padding: 0px;
329
+ line-height: 23px;
330
+ height: 24px;
331
+ vertical-align: top;
332
+ }*/
333
+
334
+
335
+ #quads-add-ons {
336
+ padding: 20px;
337
+ }
338
+ .quads-toggle {
339
+ position: absolute;
340
+ right: 0px;
341
+ top: 0px;
342
+ }
343
+
344
+ .quads-box-close .quads-close-open-icon {
345
+ background-position: 0px -38px;
346
+ }
347
+
348
+ .quads-close-open-icon {
349
+ width: 38px;
350
+ height: 38px;
351
+ background: #f4f4f4 url("../images/arrow-close.png") repeat-y;
352
+ background-position: 0px 0px;
353
+ }
354
+ .quads-ad-toggle-header {
355
+ position: relative;
356
+ background-color: #f4f4f4;
357
+ margin-bottom: 2px;
358
+ padding: 10px 10px 10px 15px;
359
+ -moz-user-select: -moz-none;
360
+ -khtml-user-select: none;
361
+ -webkit-user-select: none;
362
+ -o-user-select: none;
363
+ user-select: none;
364
+ cursor: pointer !important;
365
+ }
366
+
367
+ .quads-ad-toggle-container{
368
+ padding:20px;
369
+ background-color: #f4f4f4;
370
+ }
371
+
372
+ .quads-toogle-title{
373
+ font-size:16px;
374
+ font-weight: bold;
375
+ }
376
+
377
+ .quads-advanced-description label{
378
+ float:left;
379
+ width:215px;
380
+ font-size: 12px;
381
+ font-weight: 600;
382
+ text-transform: uppercase;
383
+ }
384
+
385
+ .quads-advanced-ad-box{
386
+ clear: both;
387
+ margin-top:20px;
388
+ margin-bottom:20px;
389
+ }
390
+
391
+
392
+
393
+ .adsense-size-title {
394
+ margin-right: 0px;
395
+ float: left;
396
+ line-height: 32px;
397
+ margin-left: 14px;
398
+ min-width: 100px;
399
+ font-weight: 600;
400
+ font-size: 12px;
401
+ text-transform: uppercase;
402
+ }
403
+
404
+ .quads-select-style-overwrite {
405
+ border: 1px solid #e6e6e6;
406
+ width: 150px;
407
+ overflow: hidden;
408
+ background: #ffffff url("../images/box_arrow.png") repeat-y 120px 0px;
409
+ margin: 0px 0px 5px 0px;
410
+ }
411
+ .quads-select-style-overwrite select {
412
+ width:150px;
413
+ }
414
+
415
+ .quads-size-input {
416
+ position: relative;
417
+ top: -1px;
418
+ width: 110%;
419
+ border: none;
420
+ box-shadow: none;
421
+ background: transparent;
422
+ background-image: none;
423
+ -webkit-appearance: none;
424
+ font-family: 'Open Sans', arial, sans-serif;
425
+ color: #555555;
426
+ font-size: 12px;
427
+ /*margin-left:5px;*/
428
+ }
429
+
430
+ .quads-pro-overlay{
431
+ height: 200px;
432
+ }
433
+
434
+
435
+
436
+ .quads-license-error-notice,
437
+ .quads-license-expires-soon-notice {
438
+ background-color: #fff;
439
+ padding: 10px;
440
+ border-left: 4px solid #7ad03a;
441
+ overflow: auto;
442
+ -webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
443
+ box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
444
+ border: 1px solid #ECECEC;
445
+ border-radius: 3px;
446
+ }
447
+ .quads-license-error-notice a {
448
+ color: #0097df;
449
+ text-decoration: underline;
450
+ }
451
+ .quads-license-error-notice { border-left: 4px solid #dd3d36; }
452
+ .quads-license-lifetime-notice,
453
+ .quads-license-expiration-date-notice,
454
+ .quads-license-null { padding: 0 0 0 0px; }
455
+ .quads-license-lifetime-notice .quads-license-data p,
456
+ .quads-license-expiration-date-notice .quads-license-data p { color: #666; font-size: 14px; font-style: italic; margin: 4px 0 0; }
457
+
458
+ #quads_settingslicenses_header-nav{
459
+ display:none;
460
+ }
461
+
462
+ #quads_settingslicenses_header{
463
+ max-width:640px;
464
+ }
465
+
466
+ #quads_settingslicenses_header .row.th{
467
+ min-width:250px;
468
+ }
469
+
470
+ .quads-notice{
471
+ background: #fff;
472
+ border-left: 4px solid #46b450;
473
+ -webkit-box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
474
+ box-shadow: 0 1px 1px 0 rgba( 0, 0, 0, 0.1 );
475
+ margin: 5px 15px 2px;
476
+ padding: 1px 12px;
477
+ }
478
+
479
+ .quads_admin h2.nav-tab-wrapper{
480
+ border:0px;
481
+ }
482
+
483
+ .quads_admin .nav-tab{
484
+ border:0px;
485
+ text-transform: uppercase;
486
+ color: #a1a1a1;
487
+ font-weight: 700;
488
+ }
489
+
490
+ .quads-h1 {
491
+ font-size: 2.75em;
492
+ margin-bottom: 1.35rem;
493
+ font-size: 2.5em;
494
+ line-height: 3.68rem;
495
+ letter-spacing: normal;
496
+ }
497
+
498
+ .quads-h2 {
499
+ margin-top:0px;
500
+ margin-bottom: 1.2rem;
501
+ font-size: 30px;
502
+ line-height: 2.5rem;
503
+ }
504
+
505
+ .quads-heading-pro{
506
+ color: #83c11f;
507
+ font-weight: bold;
508
+ }
509
+
510
+ .quads-button.green {
511
+ display:inline-block;
512
+ background-color: #83c11f;
513
+ padding:10px;
514
+ min-width: 170px;
515
+ color: white;
516
+ font-size: 16px;
517
+ text-decoration: none;
518
+ text-align:center;
519
+ margin-top:20px;
520
+ }
521
+
522
+ #quads-add-ons .quads-footer {
523
+ clear:both;
524
+ margin-top:20px;
525
+ font-style: italic;
526
+ }
527
+
528
+ #quads-add-ons li {
529
+ font-size:18px;
530
+ line-height: 29px;
531
+ position: relative;
532
+ padding-left: 23px;
533
+ list-style: none!important;
534
+ }
535
+
536
+ #quads-add-ons li:before {
537
+ width: 1em;
538
+ height: 100%;
539
+ background: url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;
540
+ background-size: contain;
541
+ content: "";
542
+ position: absolute;
543
+ top: 0;
544
+ left: 0;
545
+ color: #77b227;
546
+ }
547
+
548
+ .adsense_admin_header {
549
+ font-size: 14px;
550
+ font-weight: 500;
551
+ }
552
+
553
+ #quads-adsense-bg-div{
554
+ position: fixed;
555
+ top: 0;
556
+ left: 0;
557
+ width: 100%;
558
+ height: 100%;
559
+ background-color: rgba(0, 0, 0, 0.65);
560
+ z-index: 250000;
561
+ }
562
+
563
+ #quads-adsense-container {
564
+ text-align: center;
565
+ width: 480px;
566
+ margin: 85px auto 0 auto;
567
+ background-color: #fff;
568
+ padding: 2%;
569
+ border-radius: 2px;
570
+ }
571
+ #quads-adsense-container h3{
572
+ margin-top:0px;
573
+ }
574
+
575
+ #quads-adsense-container textarea{
576
+ width: 100%;
577
+ }
578
+
579
+
580
+ .quads-ad-toggle-container textarea{
581
+ width: 100%;
582
+ }
583
+
584
+ .quads-ad-toggle-container input{
585
+ margin-top: 7px;
586
+ margin-bottom:10px;
587
+ }
588
+
589
+ .quads-adsense-code label, input{
590
+ margin-right:2px;
591
+ }
592
+
593
+ #quads_settings\5b ad2\5d \5b g_data_ad_client\5d {
594
+ width:200px;
595
+ }
596
+
597
+ .quads-ad-toggle-container label {
598
+ display: inline-block;
599
+ margin-right:2px;
600
+ margin-top:-3px;
601
+ }
602
+
603
+ /*.quads-adsense-code > label:nth-child(1){
604
+ min-width: 74px;
605
+ }*/
606
+
607
+ .quads_adsense_code .quads-add-adsense {
608
+ margin:20px;
609
+ margin-left:0px;
610
+ margin-right:5px;
611
+ }
612
+
613
+ .quads-label-left {
614
+ min-width: 71px;
615
+ }
616
+
617
+ #quads-label-Type {
618
+ min-width: 67px;
619
+ }
620
+
621
+ .quads-medium-size{
622
+ width: 110px;
623
+ }
624
+
625
+ #quads-msg{
626
+ display:none;
627
+ margin: 5px;
628
+ background-color: #c55c5c;
629
+ color: white;
630
+ }
631
+
632
+ .quads-success-modal {
633
+ display: block;
634
+ position: fixed;
635
+ top: 45%;
636
+ left: 25%;
637
+ width: 200px;
638
+ height: auto;
639
+ padding: 5px 20px;
640
+ z-index:1002;
641
+ overflow: auto;
642
+ }
643
+ .quads-loader {
644
+ display: block;
645
+ position: fixed;
646
+ top: 45%;
647
+ left: 25%;
648
+ width: 200px;
649
+ height: auto;
650
+ padding: 5px 20px;
651
+ z-index:1002;
652
+ overflow: auto;
653
+ }
654
+
655
+ .quads-form-table{
656
+ width: 100%;
657
+ }
658
+
659
+ .quads-left-box{
660
+ width:45%;
661
+ min-height:100px;
662
+ float:left;
663
+ line-height: 35px;
664
+ min-width: 300px;
665
+ }
666
+
667
+ @media screen and (max-width:700px){
668
+ .adsense-size-title {
669
+ margin-left: 0px;
670
+ }
671
+ .quads-left-box{
672
+ width:45%;
673
+ min-height:100px;
674
+ float:none;
675
+ line-height: 35px;
676
+ min-width: 300px;
677
+ }
678
+
679
+ .quads-style img{
680
+ max-width: 50px;
681
+ }
682
+
683
+ }
684
+
685
+ .adsense_admin_header ul li{
686
+ margin-top:2px;
687
+ margin-left:20px;
688
+ list-style-type: square;
689
+ }
690
+
691
+ .quads-helper {
692
+ border-radius: 50%;
693
+ border: 2px solid #fff;
694
+ background-color: #83c11f;
695
+ width: 15px;
696
+ height: 15px;
697
+ display: inline-block;
698
+ position: relative;
699
+ top: 4px;
700
+ margin-top: -4px;
701
+ cursor: pointer;
702
+ margin-left: 2px;
703
+ }
704
+
705
+ .quads-helper:after {
706
+ height: 20px;
707
+ font-family: sans-serif;
708
+ content: "?";
709
+ color: #fff;
710
+ font-size: 11px;
711
+ font-weight: bold;
712
+ left: 4px;
713
+ position: absolute;
714
+ margin-top: -10px;
715
+ }
716
+
717
+ .quads-general-helper:after {
718
+ height: 20px;
719
+ font-family: sans-serif;
720
+ content: "?";
721
+ color: #fff;
722
+ font-size: 11px;
723
+ font-weight: bold;
724
+ left: 4px;
725
+ position: absolute;
726
+ margin-top: -2px;
727
+ }
728
+ .quads-general-helper {
729
+ border-radius: 50%;
730
+ border: 2px solid #fff;
731
+ background-color: #83c11f;
732
+ width: 15px;
733
+ height: 15px;
734
+ display: inline-block;
735
+ position: relative;
736
+ top: 4px;
737
+ margin-top: -4px;
738
+ cursor: pointer;
739
+ margin-left: 2px;
740
+ }
741
+
742
+ .quads-message{
743
+ display:block;
744
+ padding: 10px;
745
+ border: 1px solid #FBFBFB;
746
+ border-radius: 2px;
747
+ background-color: #F8F8F8;
748
+ position: absolute;
749
+ max-width: 500px;
750
+ z-index: 9999;
751
+ display: none;
752
+ box-shadow: 0px 0px 5px rgba(0, 0, 0, 0.2);
753
+ font-weight: normal;
754
+ line-height: 20px;
755
+ text-transform: none;
756
+ font-size: 14px;
757
+ }
758
+
759
+ #quads-pro-hover{
760
+ background-color: #83c11f;
761
+ padding:20px;
762
+ min-width: 150px;
763
+ color:white;
764
+ display: block;
765
+ position: relative;
766
+ margin-top: -100px;
767
+ margin-left: 50%;
768
+ }
769
+
770
+ #quads-pro-hover-background{
771
+ width: 100%; height:100%;background:rgba(0,0,0,0.6);
772
+ }
773
+
774
+ #quads-open-toggle{
775
+ clear: both;
776
+ float:left;
777
+ margin-top:10px;
778
+ }
779
+
780
+ #quads_settingsadsense_header input[type="number"].small-text{
781
+ width: 55px;
782
+ }
783
+
784
+ .quads_adsense_code input.quads-bggrey {
785
+ background-color: whitesmoke;
786
+ color: #939393;
787
+ }
788
+
789
+ .quads-amp-code{
790
+ color: #939393;
791
+ height: 130px;
792
+ }
793
+
794
+ .quads-chosen-select .chosen-choices li.search-field input{
795
+ min-height: 25px;
796
+ }
797
+
assets/css/quads-admin.min.css ADDED
@@ -0,0 +1 @@
 
1
+ .quads-share-button-container{margin:5px 0}.quads-share-button-container p{margin:0 0 10px}.quads-share-button{display:inline-block}.quads-share-button a{text-decoration:none}.quads-share-button .quads-share{font-family:sans-serif;font-weight:700;text-decoration:none;text-align:center;-webkit-border-radius:2px;-moz-border-radius:2px;border-radius:2px;color:#FFF;display:inline;font-size:16px;width:40px;padding:4px 8px}.quads-share-button-twitter .quads-share{background-color:#00ABF0}.quads-share-button-facebook .quads-share{background-color:#3b5998}.quads-share-button-googleplus .quads-share{background-color:#F53424}.quads-share-button-facebook .share:active,.quads-share-button-googleplus .share:active,.quads-share-button-twitter .share:active{background-color:#353535}@media (max-width:925px){.quads-share-button .quads-share{font-size:15px;padding:8px 16px}}.quads-richeditor{font-size:11px}#quads-add-ons h2{margin:0 0 15px}#quads-add-ons .quadsshare-addons{float:left;margin:0 15px 15px 0;background:#f0f0f0;border:1px solid #ccc;width:320px;padding:8px;height:315px;position:relative}#quads-add-ons .quadsshare-addons h3{margin:0 0 8px;font-size:13px}#quads-add-ons .quadsshare-addons .button-secondary{position:absolute;bottom:8px;left:8px}#quads-add-ons .quadsshare-addons .third-party{display:none}#system-info-textarea{width:580px;height:400px;font-family:Menlo,Monaco,monospace;background:0 0;white-space:pre;overflow:auto;display:block}.quads-select-chosen{width:300px}input.large-text,textarea.large-text{max-width:600px}input.medium-text,textarea.medium-text{min-width:190px}#quads_tab_container ul{list-style:none;margin:0;padding:0;background:#fff;float:left}#quads_tab_container ul li:first-child.selected-tab{border-top:none}#quads_tab_container ul li a.selected-tab{font-weight:700;text-decoration:none}#quads_tab_container .row{padding-top:12px;padding-bottom:12px}#quads_tab_container .row label strong,#tab_container .row strong{font-weight:700}.quads-tabs a{padding:5px;color:#a1a1a1;text-transform:uppercase}.quads-tabs a strong{font-weight:700}li.quads-tabs{float:left;margin-left:0;background-color:#e5e5e5}#quads_tab_container>ul>li.quads-tabs.active{background-color:#fff}#quads_tab_container>ul>li.quads-tabs.active a{color:#83c11f}#quads_tab_container .quads-panel-container{background:#FFF;padding:20px;overflow:auto;text-align:left;margin-bottom:10px;max-width:640px;float:left;clear:both}.form-table{margin-top:-20px}#quads_tab_container .form-table th{vertical-align:top;text-align:left;padding:20px 10px 20px 0;line-height:1.3;font-weight:700;font-size:14px;color:#484848;width:30%}#quads_tab_container .form-table tr{border-bottom:1px solid #E7E7E7}#quads_tab_container span.description{display:block;font-weight:400;font-style:normal;font-size:13px;margin-top:7px;color:#484848}#quads_tab_container .col-title{font-size:18px;color:#484848}@media only screen and (max-width:680px){#quads_tab_container ul{float:none;background:#fff}#quads_tab_container .form-table tr>th{width:100%}#quads_tab_container span.description{font-size:14px}#quads_tab_container .form-table tr>th,#tab_container .form-table tr>td{padding:10px}#quads_tab_container .quads-tabs a{text-align:left}#quads_tab_container li.quads-tabs{float:none;margin-left:0}}#quads_tab_container ul li.quads-tabs{margin-bottom:0}#quads_tab_container ul li.quads-tabs a{display:block;padding:10px;text-decoration:none;font-weight:700}#quads_tab_container ul li.quads-tabs a:hover{color:#383838}#quads_tab_container ul li.quads-tabs a.active{text-decoration:underline}#quads_tab_container table tbody tr:nth-child(1)>th>div{font-size:20px}#quadstabcontainer>.quadstabs{background-color:#fff}#quadstabcontainer ul .active{background-color:#00adef;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul .active:hover{background-color:#00A4E2;color:#fff;border-bottom-color:#0098D2}#quadstabcontainer ul li a{padding:10px 14px;background-color:#f3f3f3}#quadstabcontainer .quadstab-container{border:0 solid #ececec}.quads-quote-docs{font-family:Courier New,Courier,Fixed;color:#050}.quads-desc{display:block;font-style:italic;padding-top:10px}.quads-postbox{padding:10px;position:relative;min-width:255px;border:1px solid #e5e5e5;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.04);box-shadow:0 1px 1px rgba(0,0,0,.04);background:#fff;margin-bottom:20px}.nav-tab-active{background-color:#fff;border-bottom:0}#quads-add-ons{padding:20px}.quads-toggle{position:absolute;right:0;top:0}.quads-box-close .quads-close-open-icon{background-position:0 -38px}.quads-close-open-icon{width:38px;height:38px;background:url(../images/arrow-close.png) repeat-y #f4f4f4}.quads-ad-toggle-header{position:relative;background-color:#f4f4f4;margin-bottom:2px;padding:10px 10px 10px 15px;-moz-user-select:-moz-none;-khtml-user-select:none;-webkit-user-select:none;-o-user-select:none;user-select:none;cursor:pointer!important}.quads-ad-toggle-container{padding:20px;background-color:#f4f4f4}.quads-toogle-title{font-size:16px;font-weight:700}.adsense-size-title,.quads-advanced-description label{font-weight:600;font-size:12px;text-transform:uppercase;float:left}.quads-advanced-description label{width:215px}.quads-advanced-ad-box{clear:both;margin-top:20px;margin-bottom:20px}.adsense-size-title{margin-right:0;line-height:32px;margin-left:14px;min-width:100px}.quads-select-style-overwrite{border:1px solid #e6e6e6;width:150px;overflow:hidden;background:url(../images/box_arrow.png) 120px 0 repeat-y #fff;margin:0 0 5px}.quads-select-style-overwrite select{width:150px}.quads-size-input{position:relative;top:-1px;width:110%;border:none;box-shadow:none;background:0 0;-webkit-appearance:none;font-family:'Open Sans',arial,sans-serif;color:#555;font-size:12px}.quads-pro-overlay{height:200px}.quads-license-error-notice,.quads-license-expires-soon-notice{background-color:#fff;padding:10px;overflow:auto;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);border:1px solid #ECECEC;border-radius:3px}.quads-license-error-notice a{color:#0097df;text-decoration:underline}.quads-license-error-notice{border-left:4px solid #dd3d36}.quads-license-expiration-date-notice,.quads-license-lifetime-notice,.quads-license-null{padding:0}.quads-license-expiration-date-notice .quads-license-data p,.quads-license-lifetime-notice .quads-license-data p{color:#666;font-size:14px;font-style:italic;margin:4px 0 0}#quads_settingslicenses_header-nav{display:none}#quads_settingslicenses_header{max-width:640px}#quads_settingslicenses_header .row.th{min-width:250px}.quads-notice{background:#fff;border-left:4px solid #46b450;-webkit-box-shadow:0 1px 1px 0 rgba(0,0,0,.1);box-shadow:0 1px 1px 0 rgba(0,0,0,.1);margin:5px 15px 2px;padding:1px 12px}.quads_admin h2.nav-tab-wrapper{border:0}.quads_admin .nav-tab{border:0;text-transform:uppercase;color:#a1a1a1;font-weight:700}.quads-h1{margin-bottom:1.35rem;font-size:2.5em;line-height:3.68rem;letter-spacing:normal}.quads-h2{margin-top:0;margin-bottom:1.2rem;font-size:30px;line-height:2.5rem}.quads-heading-pro{color:#83c11f;font-weight:700}.quads-button.green{display:inline-block;background-color:#83c11f;padding:10px;min-width:170px;color:#fff;font-size:16px;text-decoration:none;text-align:center;margin-top:20px}#quads-add-ons .quads-footer{clear:both;margin-top:20px;font-style:italic}#quads-add-ons li{font-size:18px;line-height:29px;position:relative;padding-left:23px;list-style:none!important}#quads-add-ons li:before{width:1em;height:100%;background:url(data:image/svg+xml;charset=utf8,%3Csvg%20width%3D%221792%22%20height%3D%221792%22%20viewBox%3D%220%200%201792%201792%22%20xmlns%3D%22http%3A%2F%2Fwww%2Ew3%2Eorg%2F2000%2Fsvg%22%3E%3Cpath%20fill%3D%22%2377B227%22%20d%3D%22M1671%20566q0%2040%2D28%2068l%2D724%20724%2D136%20136q%2D28%2028%2D68%2028t%2D68%2D28l%2D136%2D136%2D362%2D362q%2D28%2D28%2D28%2D68t28%2D68l136%2D136q28%2D28%2068%2D28t68%2028l294%20295%20656%2D657q28%2D28%2068%2D28t68%2028l136%20136q28%2028%2028%2068z%22%2F%3E%3C%2Fsvg%3E) left .4em no-repeat;background-size:contain;content:"";position:absolute;top:0;left:0;color:#77b227}.adsense_admin_header{font-size:14px;font-weight:500}#quads-adsense-bg-div{position:fixed;top:0;left:0;width:100%;height:100%;background-color:rgba(0,0,0,.65);z-index:250000}#quads-adsense-container{text-align:center;width:480px;margin:85px auto 0;background-color:#fff;padding:2%;border-radius:2px}#quads-adsense-container h3{margin-top:0}#quads-adsense-container textarea,.quads-ad-toggle-container textarea{width:100%}.quads-ad-toggle-container input{margin-top:7px;margin-bottom:10px}.quads-adsense-code label,input{margin-right:2px}#quads_settings\5b ad2\5d \5b g_data_ad_client\5d{width:200px}.quads-ad-toggle-container label{display:inline-block;margin-right:2px;margin-top:-3px}.quads_adsense_code .quads-add-adsense{margin:20px 5px 20px 0}.quads-label-left{min-width:71px}#quads-label-Type{min-width:67px}.quads-medium-size{width:110px}#quads-msg{display:none;margin:5px;background-color:#c55c5c;color:#fff}.quads-loader,.quads-success-modal{display:block;position:fixed;top:45%;left:25%;width:200px;height:auto;padding:5px 20px;z-index:1002;overflow:auto}.quads-form-table{width:100%}.quads-left-box{width:45%;min-height:100px;float:left;line-height:35px;min-width:300px}@media screen and (max-width:700px){.adsense-size-title{margin-left:0}.quads-left-box{width:45%;min-height:100px;float:none;line-height:35px;min-width:300px}.quads-style img{max-width:50px}}.adsense_admin_header ul li{margin-top:2px;margin-left:20px;list-style-type:square}.quads-general-helper,.quads-helper{background-color:#83c11f;width:15px;display:inline-block;top:4px;cursor:pointer;margin-left:2px}.quads-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px}.quads-general-helper:after,.quads-helper:after{height:20px;font-family:sans-serif;content:"?";font-size:11px;font-weight:700;left:4px;position:absolute;color:#fff}.quads-helper:after{margin-top:-10px}.quads-general-helper:after{margin-top:-2px}.quads-general-helper{border-radius:50%;border:2px solid #fff;height:15px;position:relative;margin-top:-4px}.quads-message{padding:10px;border:1px solid #FBFBFB;border-radius:2px;background-color:#F8F8F8;position:absolute;max-width:500px;z-index:9999;display:none;box-shadow:0 0 5px rgba(0,0,0,.2);font-weight:400;line-height:20px;text-transform:none;font-size:14px}#quads-pro-hover{background-color:#83c11f;padding:20px;min-width:150px;color:#fff;display:block;position:relative;margin-top:-100px;margin-left:50%}#quads-pro-hover-background{width:100%;height:100%;background:rgba(0,0,0,.6)}#quads-open-toggle{clear:both;float:left;margin-top:10px}#quads_settingsadsense_header input[type=number].small-text{width:55px}.quads_adsense_code input.quads-bggrey{background-color:#f5f5f5;color:#939393}.quads-amp-code{color:#939393;height:130px}.quads-chosen-select .chosen-choices li.search-field input{min-height:25px}
assets/css/quads-plugins-admin.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ PLUGINS ADMIN PAGE
3
+ */
4
+ #quick-adsense-reloaded-feedback-overlay {
5
+ /* Height & width depends on how you want to reveal the overlay (see JS below) */
6
+ height: 100%;
7
+ width: 100%;
8
+ position: fixed; /* Stay in place */
9
+ z-index: 10000; /* Sit on top */
10
+ left: 0;
11
+ top: 0;
12
+ background-color: rgb(120,120,120); /* Black fallback color */
13
+ background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
14
+ }
15
+ #quick-adsense-reloaded-feedback-content {
16
+ position: relative;
17
+ top: 25%; /* 25% from the top */
18
+ width: 500px;
19
+ max-width: 100%;
20
+ margin: auto;
21
+ margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
22
+ max-height: 50%;
23
+ padding: 20px;
24
+ background-color: #fff;
25
+ overflow-y: auto;
26
+ }
27
+ #quick-adsense-reloaded-feedback-content textarea,
28
+ #quick-adsense-reloaded-feedback-content input[type="text"] { display:none;width:100%; }
29
+ .quick-adsense-reloaded-feedback-not-deactivate { display: block; text-align: right; }
30
+
31
+ #quick-adsense-reloaded-feedback-content h3{
32
+ margin:5px;
33
+ }
34
+
35
+ @media screen and (max-width:400px){
36
+ #quick-adsense-reloaded-feedback-content {
37
+ padding:0px;
38
+ padding-bottom:50px;
39
+ }
40
+ }
assets/css/quads-plugins-admin.min.css ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ PLUGINS ADMIN PAGE
3
+ */
4
+ #quick-adsense-reloaded-feedback-overlay {
5
+ /* Height & width depends on how you want to reveal the overlay (see JS below) */
6
+ height: 100%;
7
+ width: 100%;
8
+ position: fixed; /* Stay in place */
9
+ z-index: 10000; /* Sit on top */
10
+ left: 0;
11
+ top: 0;
12
+ background-color: rgb(120,120,120); /* Black fallback color */
13
+ background-color: rgba(0,0,0, 0.5); /* Black w/opacity */
14
+ }
15
+ #quick-adsense-reloaded-feedback-content {
16
+ position: relative;
17
+ top: 25%; /* 25% from the top */
18
+ width: 500px;
19
+ max-width: 100%;
20
+ margin: auto;
21
+ margin-top: 30px; /* 30px top margin to avoid conflict with the close button on smaller screens */
22
+ max-height: 50%;
23
+ padding: 20px;
24
+ background-color: #fff;
25
+ overflow-y: auto;
26
+ }
27
+ #quick-adsense-reloaded-feedback-content textarea,
28
+ #quick-adsense-reloaded-feedback-content input[type="text"] { display:none;width:100%; }
29
+ .quick-adsense-reloaded-feedback-not-deactivate { display: block; text-align: right; }
30
+
31
+ #quick-adsense-reloaded-feedback-content h3{
32
+ margin:5px;
33
+ }
34
+
35
+ @media screen and (max-width:400px){
36
+ #quick-adsense-reloaded-feedback-content {
37
+ padding:0px;
38
+ padding-bottom:50px;
39
+ }
40
+ }
assets/css/quads.css ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ To change this license header, choose License Headers in Project Properties.
3
+ To change this template file, choose Tools | Templates
4
+ @version
5
+ */
6
+ /*
7
+ Created on : 20.10.2016, 10:37:23
8
+ Author : IronMan
9
+ */
10
+
assets/images/align_0.png ADDED
Binary file
assets/images/align_1.png ADDED
Binary file
assets/images/align_2.png ADDED
Binary file
assets/images/arrow-close.png ADDED
Binary file
assets/images/banner_250x296-cfm.png ADDED
Binary file
assets/images/banner_300x250_quads.png ADDED
Binary file
assets/images/box_arrow.png ADDED
Binary file
assets/images/get_pro_overlay.png ADDED
Binary file
assets/images/loader.gif ADDED
Binary file
assets/images/loader1.gif ADDED
Binary file
assets/images/quads_banner_250x521_buy.png ADDED
Binary file
assets/images/saved.gif ADDED
Binary file
assets/js/chosen.jquery.js ADDED
@@ -0,0 +1,1284 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*!
2
+ Chosen, a Select Box Enhancer for jQuery and Prototype
3
+ by Patrick Filler for Harvest, http://getharvest.com
4
+
5
+ Version 1.5.1
6
+ Full source at https://github.com/harvesthq/chosen
7
+ Copyright (c) 2011-2016 Harvest http://getharvest.com
8
+
9
+ MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md
10
+ This file is generated by `grunt build`, do not edit it by hand.
11
+ */
12
+
13
+ (function() {
14
+ var $, AbstractChosen, Chosen, SelectParser, _ref,
15
+ __hasProp = {}.hasOwnProperty,
16
+ __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
17
+
18
+ SelectParser = (function() {
19
+ function SelectParser() {
20
+ this.options_index = 0;
21
+ this.parsed = [];
22
+ }
23
+
24
+ SelectParser.prototype.add_node = function(child) {
25
+ if (child.nodeName.toUpperCase() === "OPTGROUP") {
26
+ return this.add_group(child);
27
+ } else {
28
+ return this.add_option(child);
29
+ }
30
+ };
31
+
32
+ SelectParser.prototype.add_group = function(group) {
33
+ var group_position, option, _i, _len, _ref, _results;
34
+ group_position = this.parsed.length;
35
+ this.parsed.push({
36
+ array_index: group_position,
37
+ group: true,
38
+ label: this.escapeExpression(group.label),
39
+ title: group.title ? group.title : void 0,
40
+ children: 0,
41
+ disabled: group.disabled,
42
+ classes: group.className
43
+ });
44
+ _ref = group.childNodes;
45
+ _results = [];
46
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
47
+ option = _ref[_i];
48
+ _results.push(this.add_option(option, group_position, group.disabled));
49
+ }
50
+ return _results;
51
+ };
52
+
53
+ SelectParser.prototype.add_option = function(option, group_position, group_disabled) {
54
+ if (option.nodeName.toUpperCase() === "OPTION") {
55
+ if (option.text !== "") {
56
+ if (group_position != null) {
57
+ this.parsed[group_position].children += 1;
58
+ }
59
+ this.parsed.push({
60
+ array_index: this.parsed.length,
61
+ options_index: this.options_index,
62
+ value: option.value,
63
+ text: option.text,
64
+ html: option.innerHTML,
65
+ title: option.title ? option.title : void 0,
66
+ selected: option.selected,
67
+ disabled: group_disabled === true ? group_disabled : option.disabled,
68
+ group_array_index: group_position,
69
+ group_label: group_position != null ? this.parsed[group_position].label : null,
70
+ classes: option.className,
71
+ style: option.style.cssText
72
+ });
73
+ } else {
74
+ this.parsed.push({
75
+ array_index: this.parsed.length,
76
+ options_index: this.options_index,
77
+ empty: true
78
+ });
79
+ }
80
+ return this.options_index += 1;
81
+ }
82
+ };
83
+
84
+ SelectParser.prototype.escapeExpression = function(text) {
85
+ var map, unsafe_chars;
86
+ if ((text == null) || text === false) {
87
+ return "";
88
+ }
89
+ if (!/[\&\<\>\"\'\`]/.test(text)) {
90
+ return text;
91
+ }
92
+ map = {
93
+ "<": "&lt;",
94
+ ">": "&gt;",
95
+ '"': "&quot;",
96
+ "'": "&#x27;",
97
+ "`": "&#x60;"
98
+ };
99
+ unsafe_chars = /&(?!\w+;)|[\<\>\"\'\`]/g;
100
+ return text.replace(unsafe_chars, function(chr) {
101
+ return map[chr] || "&amp;";
102
+ });
103
+ };
104
+
105
+ return SelectParser;
106
+
107
+ })();
108
+
109
+ SelectParser.select_to_array = function(select) {
110
+ var child, parser, _i, _len, _ref;
111
+ parser = new SelectParser();
112
+ _ref = select.childNodes;
113
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
114
+ child = _ref[_i];
115
+ parser.add_node(child);
116
+ }
117
+ return parser.parsed;
118
+ };
119
+
120
+ AbstractChosen = (function() {
121
+ function AbstractChosen(form_field, options) {
122
+ this.form_field = form_field;
123
+ this.options = options != null ? options : {};
124
+ if (!AbstractChosen.browser_is_supported()) {
125
+ return;
126
+ }
127
+ this.is_multiple = this.form_field.multiple;
128
+ this.set_default_text();
129
+ this.set_default_values();
130
+ this.setup();
131
+ this.set_up_html();
132
+ this.register_observers();
133
+ this.on_ready();
134
+ }
135
+
136
+ AbstractChosen.prototype.set_default_values = function() {
137
+ var _this = this;
138
+ this.click_test_action = function(evt) {
139
+ return _this.test_active_click(evt);
140
+ };
141
+ this.activate_action = function(evt) {
142
+ return _this.activate_field(evt);
143
+ };
144
+ this.active_field = false;
145
+ this.mouse_on_container = false;
146
+ this.results_showing = false;
147
+ this.result_highlighted = null;
148
+ this.allow_single_deselect = (this.options.allow_single_deselect != null) && (this.form_field.options[0] != null) && this.form_field.options[0].text === "" ? this.options.allow_single_deselect : false;
149
+ this.disable_search_threshold = this.options.disable_search_threshold || 0;
150
+ this.disable_search = this.options.disable_search || false;
151
+ this.enable_split_word_search = this.options.enable_split_word_search != null ? this.options.enable_split_word_search : true;
152
+ this.group_search = this.options.group_search != null ? this.options.group_search : true;
153
+ this.search_contains = this.options.search_contains || false;
154
+ this.single_backstroke_delete = this.options.single_backstroke_delete != null ? this.options.single_backstroke_delete : true;
155
+ this.max_selected_options = this.options.max_selected_options || Infinity;
156
+ this.inherit_select_classes = this.options.inherit_select_classes || false;
157
+ this.display_selected_options = this.options.display_selected_options != null ? this.options.display_selected_options : true;
158
+ this.display_disabled_options = this.options.display_disabled_options != null ? this.options.display_disabled_options : true;
159
+ this.include_group_label_in_selected = this.options.include_group_label_in_selected || false;
160
+ return this.max_shown_results = this.options.max_shown_results || Number.POSITIVE_INFINITY;
161
+ };
162
+
163
+ AbstractChosen.prototype.set_default_text = function() {
164
+ if (this.form_field.getAttribute("data-placeholder")) {
165
+ this.default_text = this.form_field.getAttribute("data-placeholder");
166
+ } else if (this.is_multiple) {
167
+ this.default_text = this.options.placeholder_text_multiple || this.options.placeholder_text || AbstractChosen.default_multiple_text;
168
+ } else {
169
+ this.default_text = this.options.placeholder_text_single || this.options.placeholder_text || AbstractChosen.default_single_text;
170
+ }
171
+ return this.results_none_found = this.form_field.getAttribute("data-no_results_text") || this.options.no_results_text || AbstractChosen.default_no_result_text;
172
+ };
173
+
174
+ AbstractChosen.prototype.choice_label = function(item) {
175
+ if (this.include_group_label_in_selected && (item.group_label != null)) {
176
+ return "<b class='group-name'>" + item.group_label + "</b>" + item.html;
177
+ } else {
178
+ return item.html;
179
+ }
180
+ };
181
+
182
+ AbstractChosen.prototype.mouse_enter = function() {
183
+ return this.mouse_on_container = true;
184
+ };
185
+
186
+ AbstractChosen.prototype.mouse_leave = function() {
187
+ return this.mouse_on_container = false;
188
+ };
189
+
190
+ AbstractChosen.prototype.input_focus = function(evt) {
191
+ var _this = this;
192
+ if (this.is_multiple) {
193
+ if (!this.active_field) {
194
+ return setTimeout((function() {
195
+ return _this.container_mousedown();
196
+ }), 50);
197
+ }
198
+ } else {
199
+ if (!this.active_field) {
200
+ return this.activate_field();
201
+ }
202
+ }
203
+ };
204
+
205
+ AbstractChosen.prototype.input_blur = function(evt) {
206
+ var _this = this;
207
+ if (!this.mouse_on_container) {
208
+ this.active_field = false;
209
+ return setTimeout((function() {
210
+ return _this.blur_test();
211
+ }), 100);
212
+ }
213
+ };
214
+
215
+ AbstractChosen.prototype.results_option_build = function(options) {
216
+ var content, data, data_content, shown_results, _i, _len, _ref;
217
+ content = '';
218
+ shown_results = 0;
219
+ _ref = this.results_data;
220
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
221
+ data = _ref[_i];
222
+ data_content = '';
223
+ if (data.group) {
224
+ data_content = this.result_add_group(data);
225
+ } else {
226
+ data_content = this.result_add_option(data);
227
+ }
228
+ if (data_content !== '') {
229
+ shown_results++;
230
+ content += data_content;
231
+ }
232
+ if (options != null ? options.first : void 0) {
233
+ if (data.selected && this.is_multiple) {
234
+ this.choice_build(data);
235
+ } else if (data.selected && !this.is_multiple) {
236
+ this.single_set_selected_text(this.choice_label(data));
237
+ }
238
+ }
239
+ if (shown_results >= this.max_shown_results) {
240
+ break;
241
+ }
242
+ }
243
+ return content;
244
+ };
245
+
246
+ AbstractChosen.prototype.result_add_option = function(option) {
247
+ var classes, option_el;
248
+ if (!option.search_match) {
249
+ return '';
250
+ }
251
+ if (!this.include_option_in_results(option)) {
252
+ return '';
253
+ }
254
+ classes = [];
255
+ if (!option.disabled && !(option.selected && this.is_multiple)) {
256
+ classes.push("active-result");
257
+ }
258
+ if (option.disabled && !(option.selected && this.is_multiple)) {
259
+ classes.push("disabled-result");
260
+ }
261
+ if (option.selected) {
262
+ classes.push("result-selected");
263
+ }
264
+ if (option.group_array_index != null) {
265
+ classes.push("group-option");
266
+ }
267
+ if (option.classes !== "") {
268
+ classes.push(option.classes);
269
+ }
270
+ option_el = document.createElement("li");
271
+ option_el.className = classes.join(" ");
272
+ option_el.style.cssText = option.style;
273
+ option_el.setAttribute("data-option-array-index", option.array_index);
274
+ option_el.innerHTML = option.search_text;
275
+ if (option.title) {
276
+ option_el.title = option.title;
277
+ }
278
+ return this.outerHTML(option_el);
279
+ };
280
+
281
+ AbstractChosen.prototype.result_add_group = function(group) {
282
+ var classes, group_el;
283
+ if (!(group.search_match || group.group_match)) {
284
+ return '';
285
+ }
286
+ if (!(group.active_options > 0)) {
287
+ return '';
288
+ }
289
+ classes = [];
290
+ classes.push("group-result");
291
+ if (group.classes) {
292
+ classes.push(group.classes);
293
+ }
294
+ group_el = document.createElement("li");
295
+ group_el.className = classes.join(" ");
296
+ group_el.innerHTML = group.search_text;
297
+ if (group.title) {
298
+ group_el.title = group.title;
299
+ }
300
+ return this.outerHTML(group_el);
301
+ };
302
+
303
+ AbstractChosen.prototype.results_update_field = function() {
304
+ this.set_default_text();
305
+ if (!this.is_multiple) {
306
+ this.results_reset_cleanup();
307
+ }
308
+ this.result_clear_highlight();
309
+ this.results_build();
310
+ if (this.results_showing) {
311
+ return this.winnow_results();
312
+ }
313
+ };
314
+
315
+ AbstractChosen.prototype.reset_single_select_options = function() {
316
+ var result, _i, _len, _ref, _results;
317
+ _ref = this.results_data;
318
+ _results = [];
319
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
320
+ result = _ref[_i];
321
+ if (result.selected) {
322
+ _results.push(result.selected = false);
323
+ } else {
324
+ _results.push(void 0);
325
+ }
326
+ }
327
+ return _results;
328
+ };
329
+
330
+ AbstractChosen.prototype.results_toggle = function() {
331
+ if (this.results_showing) {
332
+ return this.results_hide();
333
+ } else {
334
+ return this.results_show();
335
+ }
336
+ };
337
+
338
+ AbstractChosen.prototype.results_search = function(evt) {
339
+ if (this.results_showing) {
340
+ return this.winnow_results();
341
+ } else {
342
+ return this.results_show();
343
+ }
344
+ };
345
+
346
+ AbstractChosen.prototype.winnow_results = function() {
347
+ var escapedSearchText, option, regex, results, results_group, searchText, startpos, text, zregex, _i, _len, _ref;
348
+ this.no_results_clear();
349
+ results = 0;
350
+ searchText = this.get_search_text();
351
+ escapedSearchText = searchText.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
352
+ zregex = new RegExp(escapedSearchText, 'i');
353
+ regex = this.get_search_regex(escapedSearchText);
354
+ _ref = this.results_data;
355
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
356
+ option = _ref[_i];
357
+ option.search_match = false;
358
+ results_group = null;
359
+ if (this.include_option_in_results(option)) {
360
+ if (option.group) {
361
+ option.group_match = false;
362
+ option.active_options = 0;
363
+ }
364
+ if ((option.group_array_index != null) && this.results_data[option.group_array_index]) {
365
+ results_group = this.results_data[option.group_array_index];
366
+ if (results_group.active_options === 0 && results_group.search_match) {
367
+ results += 1;
368
+ }
369
+ results_group.active_options += 1;
370
+ }
371
+ option.search_text = option.group ? option.label : option.html;
372
+ if (!(option.group && !this.group_search)) {
373
+ option.search_match = this.search_string_match(option.search_text, regex);
374
+ if (option.search_match && !option.group) {
375
+ results += 1;
376
+ }
377
+ if (option.search_match) {
378
+ if (searchText.length) {
379
+ startpos = option.search_text.search(zregex);
380
+ text = option.search_text.substr(0, startpos + searchText.length) + '</em>' + option.search_text.substr(startpos + searchText.length);
381
+ option.search_text = text.substr(0, startpos) + '<em>' + text.substr(startpos);
382
+ }
383
+ if (results_group != null) {
384
+ results_group.group_match = true;
385
+ }
386
+ } else if ((option.group_array_index != null) && this.results_data[option.group_array_index].search_match) {
387
+ option.search_match = true;
388
+ }
389
+ }
390
+ }
391
+ }
392
+ this.result_clear_highlight();
393
+ if (results < 1 && searchText.length) {
394
+ this.update_results_content("");
395
+ return this.no_results(searchText);
396
+ } else {
397
+ this.update_results_content(this.results_option_build());
398
+ return this.winnow_results_set_highlight();
399
+ }
400
+ };
401
+
402
+ AbstractChosen.prototype.get_search_regex = function(escaped_search_string) {
403
+ var regex_anchor;
404
+ regex_anchor = this.search_contains ? "" : "^";
405
+ return new RegExp(regex_anchor + escaped_search_string, 'i');
406
+ };
407
+
408
+ AbstractChosen.prototype.search_string_match = function(search_string, regex) {
409
+ var part, parts, _i, _len;
410
+ if (regex.test(search_string)) {
411
+ return true;
412
+ } else if (this.enable_split_word_search && (search_string.indexOf(" ") >= 0 || search_string.indexOf("[") === 0)) {
413
+ parts = search_string.replace(/\[|\]/g, "").split(" ");
414
+ if (parts.length) {
415
+ for (_i = 0, _len = parts.length; _i < _len; _i++) {
416
+ part = parts[_i];
417
+ if (regex.test(part)) {
418
+ return true;
419
+ }
420
+ }
421
+ }
422
+ }
423
+ };
424
+
425
+ AbstractChosen.prototype.choices_count = function() {
426
+ var option, _i, _len, _ref;
427
+ if (this.selected_option_count != null) {
428
+ return this.selected_option_count;
429
+ }
430
+ this.selected_option_count = 0;
431
+ _ref = this.form_field.options;
432
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
433
+ option = _ref[_i];
434
+ if (option.selected) {
435
+ this.selected_option_count += 1;
436
+ }
437
+ }
438
+ return this.selected_option_count;
439
+ };
440
+
441
+ AbstractChosen.prototype.choices_click = function(evt) {
442
+ evt.preventDefault();
443
+ if (!(this.results_showing || this.is_disabled)) {
444
+ return this.results_show();
445
+ }
446
+ };
447
+
448
+ AbstractChosen.prototype.keyup_checker = function(evt) {
449
+ var stroke, _ref;
450
+ stroke = (_ref = evt.which) != null ? _ref : evt.keyCode;
451
+ this.search_field_scale();
452
+ switch (stroke) {
453
+ case 8:
454
+ if (this.is_multiple && this.backstroke_length < 1 && this.choices_count() > 0) {
455
+ return this.keydown_backstroke();
456
+ } else if (!this.pending_backstroke) {
457
+ this.result_clear_highlight();
458
+ return this.results_search();
459
+ }
460
+ break;
461
+ case 13:
462
+ evt.preventDefault();
463
+ if (this.results_showing) {
464
+ return this.result_select(evt);
465
+ }
466
+ break;
467
+ case 27:
468
+ if (this.results_showing) {
469
+ this.results_hide();
470
+ }
471
+ return true;
472
+ case 9:
473
+ case 38:
474
+ case 40:
475
+ case 16:
476
+ case 91:
477
+ case 17:
478
+ case 18:
479
+ break;
480
+ default:
481
+ return this.results_search();
482
+ }
483
+ };
484
+
485
+ AbstractChosen.prototype.clipboard_event_checker = function(evt) {
486
+ var _this = this;
487
+ return setTimeout((function() {
488
+ return _this.results_search();
489
+ }), 50);
490
+ };
491
+
492
+ AbstractChosen.prototype.container_width = function() {
493
+ if (this.options.width != null) {
494
+ return this.options.width;
495
+ } else {
496
+ return "" + this.form_field.offsetWidth + "px";
497
+ }
498
+ };
499
+
500
+ AbstractChosen.prototype.include_option_in_results = function(option) {
501
+ if (this.is_multiple && (!this.display_selected_options && option.selected)) {
502
+ return false;
503
+ }
504
+ if (!this.display_disabled_options && option.disabled) {
505
+ return false;
506
+ }
507
+ if (option.empty) {
508
+ return false;
509
+ }
510
+ return true;
511
+ };
512
+
513
+ AbstractChosen.prototype.search_results_touchstart = function(evt) {
514
+ this.touch_started = true;
515
+ return this.search_results_mouseover(evt);
516
+ };
517
+
518
+ AbstractChosen.prototype.search_results_touchmove = function(evt) {
519
+ this.touch_started = false;
520
+ return this.search_results_mouseout(evt);
521
+ };
522
+
523
+ AbstractChosen.prototype.search_results_touchend = function(evt) {
524
+ if (this.touch_started) {
525
+ return this.search_results_mouseup(evt);
526
+ }
527
+ };
528
+
529
+ AbstractChosen.prototype.outerHTML = function(element) {
530
+ var tmp;
531
+ if (element.outerHTML) {
532
+ return element.outerHTML;
533
+ }
534
+ tmp = document.createElement("div");
535
+ tmp.appendChild(element);
536
+ return tmp.innerHTML;
537
+ };
538
+
539
+ AbstractChosen.browser_is_supported = function() {
540
+ if (/iP(od|hone)/i.test(window.navigator.userAgent)) {
541
+ return false;
542
+ }
543
+ if (/Android/i.test(window.navigator.userAgent)) {
544
+ if (/Mobile/i.test(window.navigator.userAgent)) {
545
+ return false;
546
+ }
547
+ }
548
+ if (/IEMobile/i.test(window.navigator.userAgent)) {
549
+ return false;
550
+ }
551
+ if (/Windows Phone/i.test(window.navigator.userAgent)) {
552
+ return false;
553
+ }
554
+ if (/BlackBerry/i.test(window.navigator.userAgent)) {
555
+ return false;
556
+ }
557
+ if (/BB10/i.test(window.navigator.userAgent)) {
558
+ return false;
559
+ }
560
+ if (window.navigator.appName === "Microsoft Internet Explorer") {
561
+ return document.documentMode >= 8;
562
+ }
563
+ return true;
564
+ };
565
+
566
+ AbstractChosen.default_multiple_text = "Select Some Options";
567
+
568
+ AbstractChosen.default_single_text = "Select an Option";
569
+
570
+ AbstractChosen.default_no_result_text = "No results match";
571
+
572
+ return AbstractChosen;
573
+
574
+ })();
575
+
576
+ $ = jQuery;
577
+
578
+ $.fn.extend({
579
+ chosen: function(options) {
580
+ if (!AbstractChosen.browser_is_supported()) {
581
+ return this;
582
+ }
583
+ return this.each(function(input_field) {
584
+ var $this, chosen;
585
+ $this = $(this);
586
+ chosen = $this.data('chosen');
587
+ if (options === 'destroy') {
588
+ if (chosen instanceof Chosen) {
589
+ chosen.destroy();
590
+ }
591
+ return;
592
+ }
593
+ if (!(chosen instanceof Chosen)) {
594
+ $this.data('chosen', new Chosen(this, options));
595
+ }
596
+ });
597
+ }
598
+ });
599
+
600
+ Chosen = (function(_super) {
601
+ __extends(Chosen, _super);
602
+
603
+ function Chosen() {
604
+ _ref = Chosen.__super__.constructor.apply(this, arguments);
605
+ return _ref;
606
+ }
607
+
608
+ Chosen.prototype.setup = function() {
609
+ this.form_field_jq = $(this.form_field);
610
+ this.current_selectedIndex = this.form_field.selectedIndex;
611
+ return this.is_rtl = this.form_field_jq.hasClass("chosen-rtl");
612
+ };
613
+
614
+ Chosen.prototype.set_up_html = function() {
615
+ var container_classes, container_props;
616
+ container_classes = ["chosen-container"];
617
+ container_classes.push("chosen-container-" + (this.is_multiple ? "multi" : "single"));
618
+ if (this.inherit_select_classes && this.form_field.className) {
619
+ container_classes.push(this.form_field.className);
620
+ }
621
+ if (this.is_rtl) {
622
+ container_classes.push("chosen-rtl");
623
+ }
624
+ container_props = {
625
+ 'class': container_classes.join(' '),
626
+ 'style': "width: " + (this.container_width()) + ";",
627
+ 'title': this.form_field.title
628
+ };
629
+ if (this.form_field.id.length) {
630
+ container_props.id = this.form_field.id.replace(/[^\w]/g, '_') + "_chosen";
631
+ }
632
+ this.container = $("<div />", container_props);
633
+ if (this.is_multiple) {
634
+ this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="' + this.default_text + '" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>');
635
+ } else {
636
+ this.container.html('<a class="chosen-single chosen-default"><span>' + this.default_text + '</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>');
637
+ }
638
+ this.form_field_jq.hide().after(this.container);
639
+ this.dropdown = this.container.find('div.chosen-drop').first();
640
+ this.search_field = this.container.find('input').first();
641
+ this.search_results = this.container.find('ul.chosen-results').first();
642
+ this.search_field_scale();
643
+ this.search_no_results = this.container.find('li.no-results').first();
644
+ if (this.is_multiple) {
645
+ this.search_choices = this.container.find('ul.chosen-choices').first();
646
+ this.search_container = this.container.find('li.search-field').first();
647
+ } else {
648
+ this.search_container = this.container.find('div.chosen-search').first();
649
+ this.selected_item = this.container.find('.chosen-single').first();
650
+ }
651
+ this.results_build();
652
+ this.set_tab_index();
653
+ return this.set_label_behavior();
654
+ };
655
+
656
+ Chosen.prototype.on_ready = function() {
657
+ return this.form_field_jq.trigger("chosen:ready", {
658
+ chosen: this
659
+ });
660
+ };
661
+
662
+ Chosen.prototype.register_observers = function() {
663
+ var _this = this;
664
+ this.container.bind('touchstart.chosen', function(evt) {
665
+ _this.container_mousedown(evt);
666
+ return evt.preventDefault();
667
+ });
668
+ this.container.bind('touchend.chosen', function(evt) {
669
+ _this.container_mouseup(evt);
670
+ return evt.preventDefault();
671
+ });
672
+ this.container.bind('mousedown.chosen', function(evt) {
673
+ _this.container_mousedown(evt);
674
+ });
675
+ this.container.bind('mouseup.chosen', function(evt) {
676
+ _this.container_mouseup(evt);
677
+ });
678
+ this.container.bind('mouseenter.chosen', function(evt) {
679
+ _this.mouse_enter(evt);
680
+ });
681
+ this.container.bind('mouseleave.chosen', function(evt) {
682
+ _this.mouse_leave(evt);
683
+ });
684
+ this.search_results.bind('mouseup.chosen', function(evt) {
685
+ _this.search_results_mouseup(evt);
686
+ });
687
+ this.search_results.bind('mouseover.chosen', function(evt) {
688
+ _this.search_results_mouseover(evt);
689
+ });
690
+ this.search_results.bind('mouseout.chosen', function(evt) {
691
+ _this.search_results_mouseout(evt);
692
+ });
693
+ this.search_results.bind('mousewheel.chosen DOMMouseScroll.chosen', function(evt) {
694
+ _this.search_results_mousewheel(evt);
695
+ });
696
+ this.search_results.bind('touchstart.chosen', function(evt) {
697
+ _this.search_results_touchstart(evt);
698
+ });
699
+ this.search_results.bind('touchmove.chosen', function(evt) {
700
+ _this.search_results_touchmove(evt);
701
+ });
702
+ this.search_results.bind('touchend.chosen', function(evt) {
703
+ _this.search_results_touchend(evt);
704
+ });
705
+ this.form_field_jq.bind("chosen:updated.chosen", function(evt) {
706
+ _this.results_update_field(evt);
707
+ });
708
+ this.form_field_jq.bind("chosen:activate.chosen", function(evt) {
709
+ _this.activate_field(evt);
710
+ });
711
+ this.form_field_jq.bind("chosen:open.chosen", function(evt) {
712
+ _this.container_mousedown(evt);
713
+ });
714
+ this.form_field_jq.bind("chosen:close.chosen", function(evt) {
715
+ _this.input_blur(evt);
716
+ });
717
+ this.search_field.bind('blur.chosen', function(evt) {
718
+ _this.input_blur(evt);
719
+ });
720
+ this.search_field.bind('keyup.chosen', function(evt) {
721
+ _this.keyup_checker(evt);
722
+ });
723
+ this.search_field.bind('keydown.chosen', function(evt) {
724
+ _this.keydown_checker(evt);
725
+ });
726
+ this.search_field.bind('focus.chosen', function(evt) {
727
+ _this.input_focus(evt);
728
+ });
729
+ this.search_field.bind('cut.chosen', function(evt) {
730
+ _this.clipboard_event_checker(evt);
731
+ });
732
+ this.search_field.bind('paste.chosen', function(evt) {
733
+ _this.clipboard_event_checker(evt);
734
+ });
735
+ if (this.is_multiple) {
736
+ return this.search_choices.bind('click.chosen', function(evt) {
737
+ _this.choices_click(evt);
738
+ });
739
+ } else {
740
+ return this.container.bind('click.chosen', function(evt) {
741
+ evt.preventDefault();
742
+ });
743
+ }
744
+ };
745
+
746
+ Chosen.prototype.destroy = function() {
747
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
748
+ if (this.search_field[0].tabIndex) {
749
+ this.form_field_jq[0].tabIndex = this.search_field[0].tabIndex;
750
+ }
751
+ this.container.remove();
752
+ this.form_field_jq.removeData('chosen');
753
+ return this.form_field_jq.show();
754
+ };
755
+
756
+ Chosen.prototype.search_field_disabled = function() {
757
+ this.is_disabled = this.form_field_jq[0].disabled;
758
+ if (this.is_disabled) {
759
+ this.container.addClass('chosen-disabled');
760
+ this.search_field[0].disabled = true;
761
+ if (!this.is_multiple) {
762
+ this.selected_item.unbind("focus.chosen", this.activate_action);
763
+ }
764
+ return this.close_field();
765
+ } else {
766
+ this.container.removeClass('chosen-disabled');
767
+ this.search_field[0].disabled = false;
768
+ if (!this.is_multiple) {
769
+ return this.selected_item.bind("focus.chosen", this.activate_action);
770
+ }
771
+ }
772
+ };
773
+
774
+ Chosen.prototype.container_mousedown = function(evt) {
775
+ if (!this.is_disabled) {
776
+ if (evt && evt.type === "mousedown" && !this.results_showing) {
777
+ evt.preventDefault();
778
+ }
779
+ if (!((evt != null) && ($(evt.target)).hasClass("search-choice-close"))) {
780
+ if (!this.active_field) {
781
+ if (this.is_multiple) {
782
+ this.search_field.val("");
783
+ }
784
+ $(this.container[0].ownerDocument).bind('click.chosen', this.click_test_action);
785
+ this.results_show();
786
+ } else if (!this.is_multiple && evt && (($(evt.target)[0] === this.selected_item[0]) || $(evt.target).parents("a.chosen-single").length)) {
787
+ evt.preventDefault();
788
+ this.results_toggle();
789
+ }
790
+ return this.activate_field();
791
+ }
792
+ }
793
+ };
794
+
795
+ Chosen.prototype.container_mouseup = function(evt) {
796
+ if (evt.target.nodeName === "ABBR" && !this.is_disabled) {
797
+ return this.results_reset(evt);
798
+ }
799
+ };
800
+
801
+ Chosen.prototype.search_results_mousewheel = function(evt) {
802
+ var delta;
803
+ if (evt.originalEvent) {
804
+ delta = evt.originalEvent.deltaY || -evt.originalEvent.wheelDelta || evt.originalEvent.detail;
805
+ }
806
+ if (delta != null) {
807
+ evt.preventDefault();
808
+ if (evt.type === 'DOMMouseScroll') {
809
+ delta = delta * 40;
810
+ }
811
+ return this.search_results.scrollTop(delta + this.search_results.scrollTop());
812
+ }
813
+ };
814
+
815
+ Chosen.prototype.blur_test = function(evt) {
816
+ if (!this.active_field && this.container.hasClass("chosen-container-active")) {
817
+ return this.close_field();
818
+ }
819
+ };
820
+
821
+ Chosen.prototype.close_field = function() {
822
+ $(this.container[0].ownerDocument).unbind("click.chosen", this.click_test_action);
823
+ this.active_field = false;
824
+ this.results_hide();
825
+ this.container.removeClass("chosen-container-active");
826
+ this.clear_backstroke();
827
+ this.show_search_field_default();
828
+ return this.search_field_scale();
829
+ };
830
+
831
+ Chosen.prototype.activate_field = function() {
832
+ this.container.addClass("chosen-container-active");
833
+ this.active_field = true;
834
+ this.search_field.val(this.search_field.val());
835
+ return this.search_field.focus();
836
+ };
837
+
838
+ Chosen.prototype.test_active_click = function(evt) {
839
+ var active_container;
840
+ active_container = $(evt.target).closest('.chosen-container');
841
+ if (active_container.length && this.container[0] === active_container[0]) {
842
+ return this.active_field = true;
843
+ } else {
844
+ return this.close_field();
845
+ }
846
+ };
847
+
848
+ Chosen.prototype.results_build = function() {
849
+ this.parsing = true;
850
+ this.selected_option_count = null;
851
+ this.results_data = SelectParser.select_to_array(this.form_field);
852
+ if (this.is_multiple) {
853
+ this.search_choices.find("li.search-choice").remove();
854
+ } else if (!this.is_multiple) {
855
+ this.single_set_selected_text();
856
+ if (this.disable_search || this.form_field.options.length <= this.disable_search_threshold) {
857
+ this.search_field[0].readOnly = true;
858
+ this.container.addClass("chosen-container-single-nosearch");
859
+ } else {
860
+ this.search_field[0].readOnly = false;
861
+ this.container.removeClass("chosen-container-single-nosearch");
862
+ }
863
+ }
864
+ this.update_results_content(this.results_option_build({
865
+ first: true
866
+ }));
867
+ this.search_field_disabled();
868
+ this.show_search_field_default();
869
+ this.search_field_scale();
870
+ return this.parsing = false;
871
+ };
872
+
873
+ Chosen.prototype.result_do_highlight = function(el) {
874
+ var high_bottom, high_top, maxHeight, visible_bottom, visible_top;
875
+ if (el.length) {
876
+ this.result_clear_highlight();
877
+ this.result_highlight = el;
878
+ this.result_highlight.addClass("highlighted");
879
+ maxHeight = parseInt(this.search_results.css("maxHeight"), 10);
880
+ visible_top = this.search_results.scrollTop();
881
+ visible_bottom = maxHeight + visible_top;
882
+ high_top = this.result_highlight.position().top + this.search_results.scrollTop();
883
+ high_bottom = high_top + this.result_highlight.outerHeight();
884
+ if (high_bottom >= visible_bottom) {
885
+ return this.search_results.scrollTop((high_bottom - maxHeight) > 0 ? high_bottom - maxHeight : 0);
886
+ } else if (high_top < visible_top) {
887
+ return this.search_results.scrollTop(high_top);
888
+ }
889
+ }
890
+ };
891
+
892
+ Chosen.prototype.result_clear_highlight = function() {
893
+ if (this.result_highlight) {
894
+ this.result_highlight.removeClass("highlighted");
895
+ }
896
+ return this.result_highlight = null;
897
+ };
898
+
899
+ Chosen.prototype.results_show = function() {
900
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
901
+ this.form_field_jq.trigger("chosen:maxselected", {
902
+ chosen: this
903
+ });
904
+ return false;
905
+ }
906
+ this.container.addClass("chosen-with-drop");
907
+ this.results_showing = true;
908
+ this.search_field.focus();
909
+ this.search_field.val(this.search_field.val());
910
+ this.winnow_results();
911
+ return this.form_field_jq.trigger("chosen:showing_dropdown", {
912
+ chosen: this
913
+ });
914
+ };
915
+
916
+ Chosen.prototype.update_results_content = function(content) {
917
+ return this.search_results.html(content);
918
+ };
919
+
920
+ Chosen.prototype.results_hide = function() {
921
+ if (this.results_showing) {
922
+ this.result_clear_highlight();
923
+ this.container.removeClass("chosen-with-drop");
924
+ this.form_field_jq.trigger("chosen:hiding_dropdown", {
925
+ chosen: this
926
+ });
927
+ }
928
+ return this.results_showing = false;
929
+ };
930
+
931
+ Chosen.prototype.set_tab_index = function(el) {
932
+ var ti;
933
+ if (this.form_field.tabIndex) {
934
+ ti = this.form_field.tabIndex;
935
+ this.form_field.tabIndex = -1;
936
+ return this.search_field[0].tabIndex = ti;
937
+ }
938
+ };
939
+
940
+ Chosen.prototype.set_label_behavior = function() {
941
+ var _this = this;
942
+ this.form_field_label = this.form_field_jq.parents("label");
943
+ if (!this.form_field_label.length && this.form_field.id.length) {
944
+ this.form_field_label = $("label[for='" + this.form_field.id + "']");
945
+ }
946
+ if (this.form_field_label.length > 0) {
947
+ return this.form_field_label.bind('click.chosen', function(evt) {
948
+ if (_this.is_multiple) {
949
+ return _this.container_mousedown(evt);
950
+ } else {
951
+ return _this.activate_field();
952
+ }
953
+ });
954
+ }
955
+ };
956
+
957
+ Chosen.prototype.show_search_field_default = function() {
958
+ if (this.is_multiple && this.choices_count() < 1 && !this.active_field) {
959
+ this.search_field.val(this.default_text);
960
+ return this.search_field.addClass("default");
961
+ } else {
962
+ this.search_field.val("");
963
+ return this.search_field.removeClass("default");
964
+ }
965
+ };
966
+
967
+ Chosen.prototype.search_results_mouseup = function(evt) {
968
+ var target;
969
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
970
+ if (target.length) {
971
+ this.result_highlight = target;
972
+ this.result_select(evt);
973
+ return this.search_field.focus();
974
+ }
975
+ };
976
+
977
+ Chosen.prototype.search_results_mouseover = function(evt) {
978
+ var target;
979
+ target = $(evt.target).hasClass("active-result") ? $(evt.target) : $(evt.target).parents(".active-result").first();
980
+ if (target) {
981
+ return this.result_do_highlight(target);
982
+ }
983
+ };
984
+
985
+ Chosen.prototype.search_results_mouseout = function(evt) {
986
+ if ($(evt.target).hasClass("active-result" || $(evt.target).parents('.active-result').first())) {
987
+ return this.result_clear_highlight();
988
+ }
989
+ };
990
+
991
+ Chosen.prototype.choice_build = function(item) {
992
+ var choice, close_link,
993
+ _this = this;
994
+ choice = $('<li />', {
995
+ "class": "search-choice"
996
+ }).html("<span>" + (this.choice_label(item)) + "</span>");
997
+ if (item.disabled) {
998
+ choice.addClass('search-choice-disabled');
999
+ } else {
1000
+ close_link = $('<a />', {
1001
+ "class": 'search-choice-close',
1002
+ 'data-option-array-index': item.array_index
1003
+ });
1004
+ close_link.bind('click.chosen', function(evt) {
1005
+ return _this.choice_destroy_link_click(evt);
1006
+ });
1007
+ choice.append(close_link);
1008
+ }
1009
+ return this.search_container.before(choice);
1010
+ };
1011
+
1012
+ Chosen.prototype.choice_destroy_link_click = function(evt) {
1013
+ evt.preventDefault();
1014
+ evt.stopPropagation();
1015
+ if (!this.is_disabled) {
1016
+ return this.choice_destroy($(evt.target));
1017
+ }
1018
+ };
1019
+
1020
+ Chosen.prototype.choice_destroy = function(link) {
1021
+ if (this.result_deselect(link[0].getAttribute("data-option-array-index"))) {
1022
+ this.show_search_field_default();
1023
+ if (this.is_multiple && this.choices_count() > 0 && this.search_field.val().length < 1) {
1024
+ this.results_hide();
1025
+ }
1026
+ link.parents('li').first().remove();
1027
+ return this.search_field_scale();
1028
+ }
1029
+ };
1030
+
1031
+ Chosen.prototype.results_reset = function() {
1032
+ this.reset_single_select_options();
1033
+ this.form_field.options[0].selected = true;
1034
+ this.single_set_selected_text();
1035
+ this.show_search_field_default();
1036
+ this.results_reset_cleanup();
1037
+ this.form_field_jq.trigger("change");
1038
+ if (this.active_field) {
1039
+ return this.results_hide();
1040
+ }
1041
+ };
1042
+
1043
+ Chosen.prototype.results_reset_cleanup = function() {
1044
+ this.current_selectedIndex = this.form_field.selectedIndex;
1045
+ return this.selected_item.find("abbr").remove();
1046
+ };
1047
+
1048
+ Chosen.prototype.result_select = function(evt) {
1049
+ var high, item;
1050
+ if (this.result_highlight) {
1051
+ high = this.result_highlight;
1052
+ this.result_clear_highlight();
1053
+ if (this.is_multiple && this.max_selected_options <= this.choices_count()) {
1054
+ this.form_field_jq.trigger("chosen:maxselected", {
1055
+ chosen: this
1056
+ });
1057
+ return false;
1058
+ }
1059
+ if (this.is_multiple) {
1060
+ high.removeClass("active-result");
1061
+ } else {
1062
+ this.reset_single_select_options();
1063
+ }
1064
+ high.addClass("result-selected");
1065
+ item = this.results_data[high[0].getAttribute("data-option-array-index")];
1066
+ item.selected = true;
1067
+ this.form_field.options[item.options_index].selected = true;
1068
+ this.selected_option_count = null;
1069
+ if (this.is_multiple) {
1070
+ this.choice_build(item);
1071
+ } else {
1072
+ this.single_set_selected_text(this.choice_label(item));
1073
+ }
1074
+ if (!((evt.metaKey || evt.ctrlKey) && this.is_multiple)) {
1075
+ this.results_hide();
1076
+ }
1077
+ this.show_search_field_default();
1078
+ if (this.is_multiple || this.form_field.selectedIndex !== this.current_selectedIndex) {
1079
+ this.form_field_jq.trigger("change", {
1080
+ 'selected': this.form_field.options[item.options_index].value
1081
+ });
1082
+ }
1083
+ this.current_selectedIndex = this.form_field.selectedIndex;
1084
+ evt.preventDefault();
1085
+ return this.search_field_scale();
1086
+ }
1087
+ };
1088
+
1089
+ Chosen.prototype.single_set_selected_text = function(text) {
1090
+ if (text == null) {
1091
+ text = this.default_text;
1092
+ }
1093
+ if (text === this.default_text) {
1094
+ this.selected_item.addClass("chosen-default");
1095
+ } else {
1096
+ this.single_deselect_control_build();
1097
+ this.selected_item.removeClass("chosen-default");
1098
+ }
1099
+ return this.selected_item.find("span").html(text);
1100
+ };
1101
+
1102
+ Chosen.prototype.result_deselect = function(pos) {
1103
+ var result_data;
1104
+ result_data = this.results_data[pos];
1105
+ if (!this.form_field.options[result_data.options_index].disabled) {
1106
+ result_data.selected = false;
1107
+ this.form_field.options[result_data.options_index].selected = false;
1108
+ this.selected_option_count = null;
1109
+ this.result_clear_highlight();
1110
+ if (this.results_showing) {
1111
+ this.winnow_results();
1112
+ }
1113
+ this.form_field_jq.trigger("change", {
1114
+ deselected: this.form_field.options[result_data.options_index].value
1115
+ });
1116
+ this.search_field_scale();
1117
+ return true;
1118
+ } else {
1119
+ return false;
1120
+ }
1121
+ };
1122
+
1123
+ Chosen.prototype.single_deselect_control_build = function() {
1124
+ if (!this.allow_single_deselect) {
1125
+ return;
1126
+ }
1127
+ if (!this.selected_item.find("abbr").length) {
1128
+ this.selected_item.find("span").first().after("<abbr class=\"search-choice-close\"></abbr>");
1129
+ }
1130
+ return this.selected_item.addClass("chosen-single-with-deselect");
1131
+ };
1132
+
1133
+ Chosen.prototype.get_search_text = function() {
1134
+ return $('<div/>').text($.trim(this.search_field.val())).html();
1135
+ };
1136
+
1137
+ Chosen.prototype.winnow_results_set_highlight = function() {
1138
+ var do_high, selected_results;
1139
+ selected_results = !this.is_multiple ? this.search_results.find(".result-selected.active-result") : [];
1140
+ do_high = selected_results.length ? selected_results.first() : this.search_results.find(".active-result").first();
1141
+ if (do_high != null) {
1142
+ return this.result_do_highlight(do_high);
1143
+ }
1144
+ };
1145
+
1146
+ Chosen.prototype.no_results = function(terms) {
1147
+ var no_results_html;
1148
+ no_results_html = $('<li class="no-results">' + this.results_none_found + ' "<span></span>"</li>');
1149
+ no_results_html.find("span").first().html(terms);
1150
+ this.search_results.append(no_results_html);
1151
+ return this.form_field_jq.trigger("chosen:no_results", {
1152
+ chosen: this
1153
+ });
1154
+ };
1155
+
1156
+ Chosen.prototype.no_results_clear = function() {
1157
+ return this.search_results.find(".no-results").remove();
1158
+ };
1159
+
1160
+ Chosen.prototype.keydown_arrow = function() {
1161
+ var next_sib;
1162
+ if (this.results_showing && this.result_highlight) {
1163
+ next_sib = this.result_highlight.nextAll("li.active-result").first();
1164
+ if (next_sib) {
1165
+ return this.result_do_highlight(next_sib);
1166
+ }
1167
+ } else {
1168
+ return this.results_show();
1169
+ }
1170
+ };
1171
+
1172
+ Chosen.prototype.keyup_arrow = function() {
1173
+ var prev_sibs;
1174
+ if (!this.results_showing && !this.is_multiple) {
1175
+ return this.results_show();
1176
+ } else if (this.result_highlight) {
1177
+ prev_sibs = this.result_highlight.prevAll("li.active-result");
1178
+ if (prev_sibs.length) {
1179
+ return this.result_do_highlight(prev_sibs.first());
1180
+ } else {
1181
+ if (this.choices_count() > 0) {
1182
+ this.results_hide();
1183
+ }
1184
+ return this.result_clear_highlight();
1185
+ }
1186
+ }
1187
+ };
1188
+
1189
+ Chosen.prototype.keydown_backstroke = function() {
1190
+ var next_available_destroy;
1191
+ if (this.pending_backstroke) {
1192
+ this.choice_destroy(this.pending_backstroke.find("a").first());
1193
+ return this.clear_backstroke();
1194
+ } else {
1195
+ next_available_destroy = this.search_container.siblings("li.search-choice").last();
1196
+ if (next_available_destroy.length && !next_available_destroy.hasClass("search-choice-disabled")) {
1197
+ this.pending_backstroke = next_available_destroy;
1198
+ if (this.single_backstroke_delete) {
1199
+ return this.keydown_backstroke();
1200
+ } else {
1201
+ return this.pending_backstroke.addClass("search-choice-focus");
1202
+ }
1203
+ }
1204
+ }
1205
+ };
1206
+
1207
+ Chosen.prototype.clear_backstroke = function() {
1208
+ if (this.pending_backstroke) {
1209
+ this.pending_backstroke.removeClass("search-choice-focus");
1210
+ }
1211
+ return this.pending_backstroke = null;
1212
+ };
1213
+
1214
+ Chosen.prototype.keydown_checker = function(evt) {
1215
+ var stroke, _ref1;
1216
+ stroke = (_ref1 = evt.which) != null ? _ref1 : evt.keyCode;
1217
+ this.search_field_scale();
1218
+ if (stroke !== 8 && this.pending_backstroke) {
1219
+ this.clear_backstroke();
1220
+ }
1221
+ switch (stroke) {
1222
+ case 8:
1223
+ this.backstroke_length = this.search_field.val().length;
1224
+ break;
1225
+ case 9:
1226
+ if (this.results_showing && !this.is_multiple) {
1227
+ this.result_select(evt);
1228
+ }
1229
+ this.mouse_on_container = false;
1230
+ break;
1231
+ case 13:
1232
+ if (this.results_showing) {
1233
+ evt.preventDefault();
1234
+ }
1235
+ break;
1236
+ case 32:
1237
+ if (this.disable_search) {
1238
+ evt.preventDefault();
1239
+ }
1240
+ break;
1241
+ case 38:
1242
+ evt.preventDefault();
1243
+ this.keyup_arrow();
1244
+ break;
1245
+ case 40:
1246
+ evt.preventDefault();
1247
+ this.keydown_arrow();
1248
+ break;
1249
+ }
1250
+ };
1251
+
1252
+ Chosen.prototype.search_field_scale = function() {
1253
+ var div, f_width, h, style, style_block, styles, w, _i, _len;
1254
+ if (this.is_multiple) {
1255
+ h = 0;
1256
+ w = 0;
1257
+ style_block = "position:absolute; left: -1000px; top: -1000px; display:none;";
1258
+ styles = ['font-size', 'font-style', 'font-weight', 'font-family', 'line-height', 'text-transform', 'letter-spacing'];
1259
+ for (_i = 0, _len = styles.length; _i < _len; _i++) {
1260
+ style = styles[_i];
1261
+ style_block += style + ":" + this.search_field.css(style) + ";";
1262
+ }
1263
+ div = $('<div />', {
1264
+ 'style': style_block
1265
+ });
1266
+ div.text(this.search_field.val());
1267
+ $('body').append(div);
1268
+ w = div.width() + 25;
1269
+ div.remove();
1270
+ f_width = this.container.outerWidth();
1271
+ if (w > f_width - 10) {
1272
+ w = f_width - 10;
1273
+ }
1274
+ return this.search_field.css({
1275
+ 'width': w + 'px'
1276
+ });
1277
+ }
1278
+ };
1279
+
1280
+ return Chosen;
1281
+
1282
+ })(AbstractChosen);
1283
+
1284
+ }).call(this);
assets/js/chosen.jquery.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* Chosen v1.5.1 | (c) 2011-2016 by Harvest | MIT License, https://github.com/harvesthq/chosen/blob/master/LICENSE.md */
2
+ (function(){var a,AbstractChosen,Chosen,SelectParser,b,c={}.hasOwnProperty,d=function(a,b){function d(){this.constructor=a}for(var e in b)c.call(b,e)&&(a[e]=b[e]);return d.prototype=b.prototype,a.prototype=new d,a.__super__=b.prototype,a};SelectParser=function(){function SelectParser(){this.options_index=0,this.parsed=[]}return SelectParser.prototype.add_node=function(a){return"OPTGROUP"===a.nodeName.toUpperCase()?this.add_group(a):this.add_option(a)},SelectParser.prototype.add_group=function(a){var b,c,d,e,f,g;for(b=this.parsed.length,this.parsed.push({array_index:b,group:!0,label:this.escapeExpression(a.label),title:a.title?a.title:void 0,children:0,disabled:a.disabled,classes:a.className}),f=a.childNodes,g=[],d=0,e=f.length;e>d;d++)c=f[d],g.push(this.add_option(c,b,a.disabled));return g},SelectParser.prototype.add_option=function(a,b,c){return"OPTION"===a.nodeName.toUpperCase()?(""!==a.text?(null!=b&&(this.parsed[b].children+=1),this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,value:a.value,text:a.text,html:a.innerHTML,title:a.title?a.title:void 0,selected:a.selected,disabled:c===!0?c:a.disabled,group_array_index:b,group_label:null!=b?this.parsed[b].label:null,classes:a.className,style:a.style.cssText})):this.parsed.push({array_index:this.parsed.length,options_index:this.options_index,empty:!0}),this.options_index+=1):void 0},SelectParser.prototype.escapeExpression=function(a){var b,c;return null==a||a===!1?"":/[\&\<\>\"\'\`]/.test(a)?(b={"<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"},c=/&(?!\w+;)|[\<\>\"\'\`]/g,a.replace(c,function(a){return b[a]||"&amp;"})):a},SelectParser}(),SelectParser.select_to_array=function(a){var b,c,d,e,f;for(c=new SelectParser,f=a.childNodes,d=0,e=f.length;e>d;d++)b=f[d],c.add_node(b);return c.parsed},AbstractChosen=function(){function AbstractChosen(a,b){this.form_field=a,this.options=null!=b?b:{},AbstractChosen.browser_is_supported()&&(this.is_multiple=this.form_field.multiple,this.set_default_text(),this.set_default_values(),this.setup(),this.set_up_html(),this.register_observers(),this.on_ready())}return AbstractChosen.prototype.set_default_values=function(){var a=this;return this.click_test_action=function(b){return a.test_active_click(b)},this.activate_action=function(b){return a.activate_field(b)},this.active_field=!1,this.mouse_on_container=!1,this.results_showing=!1,this.result_highlighted=null,this.allow_single_deselect=null!=this.options.allow_single_deselect&&null!=this.form_field.options[0]&&""===this.form_field.options[0].text?this.options.allow_single_deselect:!1,this.disable_search_threshold=this.options.disable_search_threshold||0,this.disable_search=this.options.disable_search||!1,this.enable_split_word_search=null!=this.options.enable_split_word_search?this.options.enable_split_word_search:!0,this.group_search=null!=this.options.group_search?this.options.group_search:!0,this.search_contains=this.options.search_contains||!1,this.single_backstroke_delete=null!=this.options.single_backstroke_delete?this.options.single_backstroke_delete:!0,this.max_selected_options=this.options.max_selected_options||1/0,this.inherit_select_classes=this.options.inherit_select_classes||!1,this.display_selected_options=null!=this.options.display_selected_options?this.options.display_selected_options:!0,this.display_disabled_options=null!=this.options.display_disabled_options?this.options.display_disabled_options:!0,this.include_group_label_in_selected=this.options.include_group_label_in_selected||!1,this.max_shown_results=this.options.max_shown_results||Number.POSITIVE_INFINITY},AbstractChosen.prototype.set_default_text=function(){return this.form_field.getAttribute("data-placeholder")?this.default_text=this.form_field.getAttribute("data-placeholder"):this.is_multiple?this.default_text=this.options.placeholder_text_multiple||this.options.placeholder_text||AbstractChosen.default_multiple_text:this.default_text=this.options.placeholder_text_single||this.options.placeholder_text||AbstractChosen.default_single_text,this.results_none_found=this.form_field.getAttribute("data-no_results_text")||this.options.no_results_text||AbstractChosen.default_no_result_text},AbstractChosen.prototype.choice_label=function(a){return this.include_group_label_in_selected&&null!=a.group_label?"<b class='group-name'>"+a.group_label+"</b>"+a.html:a.html},AbstractChosen.prototype.mouse_enter=function(){return this.mouse_on_container=!0},AbstractChosen.prototype.mouse_leave=function(){return this.mouse_on_container=!1},AbstractChosen.prototype.input_focus=function(a){var b=this;if(this.is_multiple){if(!this.active_field)return setTimeout(function(){return b.container_mousedown()},50)}else if(!this.active_field)return this.activate_field()},AbstractChosen.prototype.input_blur=function(a){var b=this;return this.mouse_on_container?void 0:(this.active_field=!1,setTimeout(function(){return b.blur_test()},100))},AbstractChosen.prototype.results_option_build=function(a){var b,c,d,e,f,g,h;for(b="",e=0,h=this.results_data,f=0,g=h.length;g>f&&(c=h[f],d="",d=c.group?this.result_add_group(c):this.result_add_option(c),""!==d&&(e++,b+=d),(null!=a?a.first:void 0)&&(c.selected&&this.is_multiple?this.choice_build(c):c.selected&&!this.is_multiple&&this.single_set_selected_text(this.choice_label(c))),!(e>=this.max_shown_results));f++);return b},AbstractChosen.prototype.result_add_option=function(a){var b,c;return a.search_match&&this.include_option_in_results(a)?(b=[],a.disabled||a.selected&&this.is_multiple||b.push("active-result"),!a.disabled||a.selected&&this.is_multiple||b.push("disabled-result"),a.selected&&b.push("result-selected"),null!=a.group_array_index&&b.push("group-option"),""!==a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.style.cssText=a.style,c.setAttribute("data-option-array-index",a.array_index),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.result_add_group=function(a){var b,c;return(a.search_match||a.group_match)&&a.active_options>0?(b=[],b.push("group-result"),a.classes&&b.push(a.classes),c=document.createElement("li"),c.className=b.join(" "),c.innerHTML=a.search_text,a.title&&(c.title=a.title),this.outerHTML(c)):""},AbstractChosen.prototype.results_update_field=function(){return this.set_default_text(),this.is_multiple||this.results_reset_cleanup(),this.result_clear_highlight(),this.results_build(),this.results_showing?this.winnow_results():void 0},AbstractChosen.prototype.reset_single_select_options=function(){var a,b,c,d,e;for(d=this.results_data,e=[],b=0,c=d.length;c>b;b++)a=d[b],a.selected?e.push(a.selected=!1):e.push(void 0);return e},AbstractChosen.prototype.results_toggle=function(){return this.results_showing?this.results_hide():this.results_show()},AbstractChosen.prototype.results_search=function(a){return this.results_showing?this.winnow_results():this.results_show()},AbstractChosen.prototype.winnow_results=function(){var a,b,c,d,e,f,g,h,i,j,k,l;for(this.no_results_clear(),d=0,f=this.get_search_text(),a=f.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),i=new RegExp(a,"i"),c=this.get_search_regex(a),l=this.results_data,j=0,k=l.length;k>j;j++)b=l[j],b.search_match=!1,e=null,this.include_option_in_results(b)&&(b.group&&(b.group_match=!1,b.active_options=0),null!=b.group_array_index&&this.results_data[b.group_array_index]&&(e=this.results_data[b.group_array_index],0===e.active_options&&e.search_match&&(d+=1),e.active_options+=1),b.search_text=b.group?b.label:b.html,(!b.group||this.group_search)&&(b.search_match=this.search_string_match(b.search_text,c),b.search_match&&!b.group&&(d+=1),b.search_match?(f.length&&(g=b.search_text.search(i),h=b.search_text.substr(0,g+f.length)+"</em>"+b.search_text.substr(g+f.length),b.search_text=h.substr(0,g)+"<em>"+h.substr(g)),null!=e&&(e.group_match=!0)):null!=b.group_array_index&&this.results_data[b.group_array_index].search_match&&(b.search_match=!0)));return this.result_clear_highlight(),1>d&&f.length?(this.update_results_content(""),this.no_results(f)):(this.update_results_content(this.results_option_build()),this.winnow_results_set_highlight())},AbstractChosen.prototype.get_search_regex=function(a){var b;return b=this.search_contains?"":"^",new RegExp(b+a,"i")},AbstractChosen.prototype.search_string_match=function(a,b){var c,d,e,f;if(b.test(a))return!0;if(this.enable_split_word_search&&(a.indexOf(" ")>=0||0===a.indexOf("["))&&(d=a.replace(/\[|\]/g,"").split(" "),d.length))for(e=0,f=d.length;f>e;e++)if(c=d[e],b.test(c))return!0},AbstractChosen.prototype.choices_count=function(){var a,b,c,d;if(null!=this.selected_option_count)return this.selected_option_count;for(this.selected_option_count=0,d=this.form_field.options,b=0,c=d.length;c>b;b++)a=d[b],a.selected&&(this.selected_option_count+=1);return this.selected_option_count},AbstractChosen.prototype.choices_click=function(a){return a.preventDefault(),this.results_showing||this.is_disabled?void 0:this.results_show()},AbstractChosen.prototype.keyup_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),b){case 8:if(this.is_multiple&&this.backstroke_length<1&&this.choices_count()>0)return this.keydown_backstroke();if(!this.pending_backstroke)return this.result_clear_highlight(),this.results_search();break;case 13:if(a.preventDefault(),this.results_showing)return this.result_select(a);break;case 27:return this.results_showing&&this.results_hide(),!0;case 9:case 38:case 40:case 16:case 91:case 17:case 18:break;default:return this.results_search()}},AbstractChosen.prototype.clipboard_event_checker=function(a){var b=this;return setTimeout(function(){return b.results_search()},50)},AbstractChosen.prototype.container_width=function(){return null!=this.options.width?this.options.width:""+this.form_field.offsetWidth+"px"},AbstractChosen.prototype.include_option_in_results=function(a){return this.is_multiple&&!this.display_selected_options&&a.selected?!1:!this.display_disabled_options&&a.disabled?!1:a.empty?!1:!0},AbstractChosen.prototype.search_results_touchstart=function(a){return this.touch_started=!0,this.search_results_mouseover(a)},AbstractChosen.prototype.search_results_touchmove=function(a){return this.touch_started=!1,this.search_results_mouseout(a)},AbstractChosen.prototype.search_results_touchend=function(a){return this.touch_started?this.search_results_mouseup(a):void 0},AbstractChosen.prototype.outerHTML=function(a){var b;return a.outerHTML?a.outerHTML:(b=document.createElement("div"),b.appendChild(a),b.innerHTML)},AbstractChosen.browser_is_supported=function(){return/iP(od|hone)/i.test(window.navigator.userAgent)?!1:/Android/i.test(window.navigator.userAgent)&&/Mobile/i.test(window.navigator.userAgent)?!1:/IEMobile/i.test(window.navigator.userAgent)?!1:/Windows Phone/i.test(window.navigator.userAgent)?!1:/BlackBerry/i.test(window.navigator.userAgent)?!1:/BB10/i.test(window.navigator.userAgent)?!1:"Microsoft Internet Explorer"===window.navigator.appName?document.documentMode>=8:!0},AbstractChosen.default_multiple_text="Select Some Options",AbstractChosen.default_single_text="Select an Option",AbstractChosen.default_no_result_text="No results match",AbstractChosen}(),a=jQuery,a.fn.extend({chosen:function(b){return AbstractChosen.browser_is_supported()?this.each(function(c){var d,e;return d=a(this),e=d.data("chosen"),"destroy"===b?void(e instanceof Chosen&&e.destroy()):void(e instanceof Chosen||d.data("chosen",new Chosen(this,b)))}):this}}),Chosen=function(c){function Chosen(){return b=Chosen.__super__.constructor.apply(this,arguments)}return d(Chosen,c),Chosen.prototype.setup=function(){return this.form_field_jq=a(this.form_field),this.current_selectedIndex=this.form_field.selectedIndex,this.is_rtl=this.form_field_jq.hasClass("chosen-rtl")},Chosen.prototype.set_up_html=function(){var b,c;return b=["chosen-container"],b.push("chosen-container-"+(this.is_multiple?"multi":"single")),this.inherit_select_classes&&this.form_field.className&&b.push(this.form_field.className),this.is_rtl&&b.push("chosen-rtl"),c={"class":b.join(" "),style:"width: "+this.container_width()+";",title:this.form_field.title},this.form_field.id.length&&(c.id=this.form_field.id.replace(/[^\w]/g,"_")+"_chosen"),this.container=a("<div />",c),this.is_multiple?this.container.html('<ul class="chosen-choices"><li class="search-field"><input type="text" value="'+this.default_text+'" class="default" autocomplete="off" style="width:25px;" /></li></ul><div class="chosen-drop"><ul class="chosen-results"></ul></div>'):this.container.html('<a class="chosen-single chosen-default"><span>'+this.default_text+'</span><div><b></b></div></a><div class="chosen-drop"><div class="chosen-search"><input type="text" autocomplete="off" /></div><ul class="chosen-results"></ul></div>'),this.form_field_jq.hide().after(this.container),this.dropdown=this.container.find("div.chosen-drop").first(),this.search_field=this.container.find("input").first(),this.search_results=this.container.find("ul.chosen-results").first(),this.search_field_scale(),this.search_no_results=this.container.find("li.no-results").first(),this.is_multiple?(this.search_choices=this.container.find("ul.chosen-choices").first(),this.search_container=this.container.find("li.search-field").first()):(this.search_container=this.container.find("div.chosen-search").first(),this.selected_item=this.container.find(".chosen-single").first()),this.results_build(),this.set_tab_index(),this.set_label_behavior()},Chosen.prototype.on_ready=function(){return this.form_field_jq.trigger("chosen:ready",{chosen:this})},Chosen.prototype.register_observers=function(){var a=this;return this.container.bind("touchstart.chosen",function(b){return a.container_mousedown(b),b.preventDefault()}),this.container.bind("touchend.chosen",function(b){return a.container_mouseup(b),b.preventDefault()}),this.container.bind("mousedown.chosen",function(b){a.container_mousedown(b)}),this.container.bind("mouseup.chosen",function(b){a.container_mouseup(b)}),this.container.bind("mouseenter.chosen",function(b){a.mouse_enter(b)}),this.container.bind("mouseleave.chosen",function(b){a.mouse_leave(b)}),this.search_results.bind("mouseup.chosen",function(b){a.search_results_mouseup(b)}),this.search_results.bind("mouseover.chosen",function(b){a.search_results_mouseover(b)}),this.search_results.bind("mouseout.chosen",function(b){a.search_results_mouseout(b)}),this.search_results.bind("mousewheel.chosen DOMMouseScroll.chosen",function(b){a.search_results_mousewheel(b)}),this.search_results.bind("touchstart.chosen",function(b){a.search_results_touchstart(b)}),this.search_results.bind("touchmove.chosen",function(b){a.search_results_touchmove(b)}),this.search_results.bind("touchend.chosen",function(b){a.search_results_touchend(b)}),this.form_field_jq.bind("chosen:updated.chosen",function(b){a.results_update_field(b)}),this.form_field_jq.bind("chosen:activate.chosen",function(b){a.activate_field(b)}),this.form_field_jq.bind("chosen:open.chosen",function(b){a.container_mousedown(b)}),this.form_field_jq.bind("chosen:close.chosen",function(b){a.input_blur(b)}),this.search_field.bind("blur.chosen",function(b){a.input_blur(b)}),this.search_field.bind("keyup.chosen",function(b){a.keyup_checker(b)}),this.search_field.bind("keydown.chosen",function(b){a.keydown_checker(b)}),this.search_field.bind("focus.chosen",function(b){a.input_focus(b)}),this.search_field.bind("cut.chosen",function(b){a.clipboard_event_checker(b)}),this.search_field.bind("paste.chosen",function(b){a.clipboard_event_checker(b)}),this.is_multiple?this.search_choices.bind("click.chosen",function(b){a.choices_click(b)}):this.container.bind("click.chosen",function(a){a.preventDefault()})},Chosen.prototype.destroy=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.search_field[0].tabIndex&&(this.form_field_jq[0].tabIndex=this.search_field[0].tabIndex),this.container.remove(),this.form_field_jq.removeData("chosen"),this.form_field_jq.show()},Chosen.prototype.search_field_disabled=function(){return this.is_disabled=this.form_field_jq[0].disabled,this.is_disabled?(this.container.addClass("chosen-disabled"),this.search_field[0].disabled=!0,this.is_multiple||this.selected_item.unbind("focus.chosen",this.activate_action),this.close_field()):(this.container.removeClass("chosen-disabled"),this.search_field[0].disabled=!1,this.is_multiple?void 0:this.selected_item.bind("focus.chosen",this.activate_action))},Chosen.prototype.container_mousedown=function(b){return this.is_disabled||(b&&"mousedown"===b.type&&!this.results_showing&&b.preventDefault(),null!=b&&a(b.target).hasClass("search-choice-close"))?void 0:(this.active_field?this.is_multiple||!b||a(b.target)[0]!==this.selected_item[0]&&!a(b.target).parents("a.chosen-single").length||(b.preventDefault(),this.results_toggle()):(this.is_multiple&&this.search_field.val(""),a(this.container[0].ownerDocument).bind("click.chosen",this.click_test_action),this.results_show()),this.activate_field())},Chosen.prototype.container_mouseup=function(a){return"ABBR"!==a.target.nodeName||this.is_disabled?void 0:this.results_reset(a)},Chosen.prototype.search_results_mousewheel=function(a){var b;return a.originalEvent&&(b=a.originalEvent.deltaY||-a.originalEvent.wheelDelta||a.originalEvent.detail),null!=b?(a.preventDefault(),"DOMMouseScroll"===a.type&&(b=40*b),this.search_results.scrollTop(b+this.search_results.scrollTop())):void 0},Chosen.prototype.blur_test=function(a){return!this.active_field&&this.container.hasClass("chosen-container-active")?this.close_field():void 0},Chosen.prototype.close_field=function(){return a(this.container[0].ownerDocument).unbind("click.chosen",this.click_test_action),this.active_field=!1,this.results_hide(),this.container.removeClass("chosen-container-active"),this.clear_backstroke(),this.show_search_field_default(),this.search_field_scale()},Chosen.prototype.activate_field=function(){return this.container.addClass("chosen-container-active"),this.active_field=!0,this.search_field.val(this.search_field.val()),this.search_field.focus()},Chosen.prototype.test_active_click=function(b){var c;return c=a(b.target).closest(".chosen-container"),c.length&&this.container[0]===c[0]?this.active_field=!0:this.close_field()},Chosen.prototype.results_build=function(){return this.parsing=!0,this.selected_option_count=null,this.results_data=SelectParser.select_to_array(this.form_field),this.is_multiple?this.search_choices.find("li.search-choice").remove():this.is_multiple||(this.single_set_selected_text(),this.disable_search||this.form_field.options.length<=this.disable_search_threshold?(this.search_field[0].readOnly=!0,this.container.addClass("chosen-container-single-nosearch")):(this.search_field[0].readOnly=!1,this.container.removeClass("chosen-container-single-nosearch"))),this.update_results_content(this.results_option_build({first:!0})),this.search_field_disabled(),this.show_search_field_default(),this.search_field_scale(),this.parsing=!1},Chosen.prototype.result_do_highlight=function(a){var b,c,d,e,f;if(a.length){if(this.result_clear_highlight(),this.result_highlight=a,this.result_highlight.addClass("highlighted"),d=parseInt(this.search_results.css("maxHeight"),10),f=this.search_results.scrollTop(),e=d+f,c=this.result_highlight.position().top+this.search_results.scrollTop(),b=c+this.result_highlight.outerHeight(),b>=e)return this.search_results.scrollTop(b-d>0?b-d:0);if(f>c)return this.search_results.scrollTop(c)}},Chosen.prototype.result_clear_highlight=function(){return this.result_highlight&&this.result_highlight.removeClass("highlighted"),this.result_highlight=null},Chosen.prototype.results_show=function(){return this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.container.addClass("chosen-with-drop"),this.results_showing=!0,this.search_field.focus(),this.search_field.val(this.search_field.val()),this.winnow_results(),this.form_field_jq.trigger("chosen:showing_dropdown",{chosen:this}))},Chosen.prototype.update_results_content=function(a){return this.search_results.html(a)},Chosen.prototype.results_hide=function(){return this.results_showing&&(this.result_clear_highlight(),this.container.removeClass("chosen-with-drop"),this.form_field_jq.trigger("chosen:hiding_dropdown",{chosen:this})),this.results_showing=!1},Chosen.prototype.set_tab_index=function(a){var b;return this.form_field.tabIndex?(b=this.form_field.tabIndex,this.form_field.tabIndex=-1,this.search_field[0].tabIndex=b):void 0},Chosen.prototype.set_label_behavior=function(){var b=this;return this.form_field_label=this.form_field_jq.parents("label"),!this.form_field_label.length&&this.form_field.id.length&&(this.form_field_label=a("label[for='"+this.form_field.id+"']")),this.form_field_label.length>0?this.form_field_label.bind("click.chosen",function(a){return b.is_multiple?b.container_mousedown(a):b.activate_field()}):void 0},Chosen.prototype.show_search_field_default=function(){return this.is_multiple&&this.choices_count()<1&&!this.active_field?(this.search_field.val(this.default_text),this.search_field.addClass("default")):(this.search_field.val(""),this.search_field.removeClass("default"))},Chosen.prototype.search_results_mouseup=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c.length?(this.result_highlight=c,this.result_select(b),this.search_field.focus()):void 0},Chosen.prototype.search_results_mouseover=function(b){var c;return c=a(b.target).hasClass("active-result")?a(b.target):a(b.target).parents(".active-result").first(),c?this.result_do_highlight(c):void 0},Chosen.prototype.search_results_mouseout=function(b){return a(b.target).hasClass("active-result")?this.result_clear_highlight():void 0},Chosen.prototype.choice_build=function(b){var c,d,e=this;return c=a("<li />",{"class":"search-choice"}).html("<span>"+this.choice_label(b)+"</span>"),b.disabled?c.addClass("search-choice-disabled"):(d=a("<a />",{"class":"search-choice-close","data-option-array-index":b.array_index}),d.bind("click.chosen",function(a){return e.choice_destroy_link_click(a)}),c.append(d)),this.search_container.before(c)},Chosen.prototype.choice_destroy_link_click=function(b){return b.preventDefault(),b.stopPropagation(),this.is_disabled?void 0:this.choice_destroy(a(b.target))},Chosen.prototype.choice_destroy=function(a){return this.result_deselect(a[0].getAttribute("data-option-array-index"))?(this.show_search_field_default(),this.is_multiple&&this.choices_count()>0&&this.search_field.val().length<1&&this.results_hide(),a.parents("li").first().remove(),this.search_field_scale()):void 0},Chosen.prototype.results_reset=function(){return this.reset_single_select_options(),this.form_field.options[0].selected=!0,this.single_set_selected_text(),this.show_search_field_default(),this.results_reset_cleanup(),this.form_field_jq.trigger("change"),this.active_field?this.results_hide():void 0},Chosen.prototype.results_reset_cleanup=function(){return this.current_selectedIndex=this.form_field.selectedIndex,this.selected_item.find("abbr").remove()},Chosen.prototype.result_select=function(a){var b,c;return this.result_highlight?(b=this.result_highlight,this.result_clear_highlight(),this.is_multiple&&this.max_selected_options<=this.choices_count()?(this.form_field_jq.trigger("chosen:maxselected",{chosen:this}),!1):(this.is_multiple?b.removeClass("active-result"):this.reset_single_select_options(),b.addClass("result-selected"),c=this.results_data[b[0].getAttribute("data-option-array-index")],c.selected=!0,this.form_field.options[c.options_index].selected=!0,this.selected_option_count=null,this.is_multiple?this.choice_build(c):this.single_set_selected_text(this.choice_label(c)),(a.metaKey||a.ctrlKey)&&this.is_multiple||this.results_hide(),this.show_search_field_default(),(this.is_multiple||this.form_field.selectedIndex!==this.current_selectedIndex)&&this.form_field_jq.trigger("change",{selected:this.form_field.options[c.options_index].value}),this.current_selectedIndex=this.form_field.selectedIndex,a.preventDefault(),this.search_field_scale())):void 0},Chosen.prototype.single_set_selected_text=function(a){return null==a&&(a=this.default_text),a===this.default_text?this.selected_item.addClass("chosen-default"):(this.single_deselect_control_build(),this.selected_item.removeClass("chosen-default")),this.selected_item.find("span").html(a)},Chosen.prototype.result_deselect=function(a){var b;return b=this.results_data[a],this.form_field.options[b.options_index].disabled?!1:(b.selected=!1,this.form_field.options[b.options_index].selected=!1,this.selected_option_count=null,this.result_clear_highlight(),this.results_showing&&this.winnow_results(),this.form_field_jq.trigger("change",{deselected:this.form_field.options[b.options_index].value}),this.search_field_scale(),!0)},Chosen.prototype.single_deselect_control_build=function(){return this.allow_single_deselect?(this.selected_item.find("abbr").length||this.selected_item.find("span").first().after('<abbr class="search-choice-close"></abbr>'),this.selected_item.addClass("chosen-single-with-deselect")):void 0},Chosen.prototype.get_search_text=function(){return a("<div/>").text(a.trim(this.search_field.val())).html()},Chosen.prototype.winnow_results_set_highlight=function(){var a,b;return b=this.is_multiple?[]:this.search_results.find(".result-selected.active-result"),a=b.length?b.first():this.search_results.find(".active-result").first(),null!=a?this.result_do_highlight(a):void 0},Chosen.prototype.no_results=function(b){var c;return c=a('<li class="no-results">'+this.results_none_found+' "<span></span>"</li>'),c.find("span").first().html(b),this.search_results.append(c),this.form_field_jq.trigger("chosen:no_results",{chosen:this})},Chosen.prototype.no_results_clear=function(){return this.search_results.find(".no-results").remove()},Chosen.prototype.keydown_arrow=function(){var a;return this.results_showing&&this.result_highlight?(a=this.result_highlight.nextAll("li.active-result").first())?this.result_do_highlight(a):void 0:this.results_show()},Chosen.prototype.keyup_arrow=function(){var a;return this.results_showing||this.is_multiple?this.result_highlight?(a=this.result_highlight.prevAll("li.active-result"),a.length?this.result_do_highlight(a.first()):(this.choices_count()>0&&this.results_hide(),this.result_clear_highlight())):void 0:this.results_show()},Chosen.prototype.keydown_backstroke=function(){var a;return this.pending_backstroke?(this.choice_destroy(this.pending_backstroke.find("a").first()),this.clear_backstroke()):(a=this.search_container.siblings("li.search-choice").last(),a.length&&!a.hasClass("search-choice-disabled")?(this.pending_backstroke=a,this.single_backstroke_delete?this.keydown_backstroke():this.pending_backstroke.addClass("search-choice-focus")):void 0)},Chosen.prototype.clear_backstroke=function(){return this.pending_backstroke&&this.pending_backstroke.removeClass("search-choice-focus"),this.pending_backstroke=null},Chosen.prototype.keydown_checker=function(a){var b,c;switch(b=null!=(c=a.which)?c:a.keyCode,this.search_field_scale(),8!==b&&this.pending_backstroke&&this.clear_backstroke(),b){case 8:this.backstroke_length=this.search_field.val().length;break;case 9:this.results_showing&&!this.is_multiple&&this.result_select(a),this.mouse_on_container=!1;break;case 13:this.results_showing&&a.preventDefault();break;case 32:this.disable_search&&a.preventDefault();break;case 38:a.preventDefault(),this.keyup_arrow();break;case 40:a.preventDefault(),this.keydown_arrow()}},Chosen.prototype.search_field_scale=function(){var b,c,d,e,f,g,h,i,j;if(this.is_multiple){for(d=0,h=0,f="position:absolute; left: -1000px; top: -1000px; display:none;",g=["font-size","font-style","font-weight","font-family","line-height","text-transform","letter-spacing"],i=0,j=g.length;j>i;i++)e=g[i],f+=e+":"+this.search_field.css(e)+";";return b=a("<div />",{style:f}),b.text(this.search_field.val()),a("body").append(b),h=b.width()+25,b.remove(),c=this.container.outerWidth(),h>c-10&&(h=c-10),this.search_field.css({width:h+"px"})}},Chosen}(AbstractChosen)}).call(this);
assets/js/quads-admin.js ADDED
@@ -0,0 +1,1540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+
5
+ // Activate chosen select boxes
6
+ $(".quads-chosen-select").chosen({
7
+ inherit_select_classes: true
8
+ });
9
+
10
+ // Hid or show AMP code form on click on amp checkbox
11
+ $('.quads-activate-amp').click(function(){
12
+ var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
13
+ if ($(this).attr('checked') === 'checked') {
14
+ $('#' + parent).find('.quads-amp-code').show();
15
+ } else {
16
+ $('#' + parent).find('.quads-amp-code').hide();
17
+ }
18
+ });
19
+
20
+
21
+ // Hide or show AMP code form on loading
22
+ $('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
23
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
24
+ if ($(this).attr( 'checked') === 'checked' ) {
25
+ $('#' + parentContainerID).find('.quads-amp-code').show();
26
+ }else {
27
+ $('#' + parentContainerID).find('.quads-amp-code').hide();
28
+ }
29
+ });
30
+
31
+ // // remove content of amp code form if its clicked in
32
+ // $('.quads-amp-code').click(function(){
33
+ // $(this).val('');
34
+ // });
35
+
36
+ /**
37
+ * Toggle Button Open All Ads
38
+ */
39
+ $('#quads-open-toggle').click(function(){
40
+ if ($('#quads-open-toggle').html() == 'Open All Ads' ){
41
+ $('.quads-ad-toggle-container').show();
42
+ $('#quads-open-toggle').html('Close Tabs');
43
+ }else{
44
+ $('.quads-ad-toggle-container').hide();
45
+ $('#quads-open-toggle').html('Open All Ads');
46
+ }
47
+ });
48
+
49
+ // show / hide helper description
50
+ $('.quads-helper').click(function (e) {
51
+ e.preventDefault();
52
+ var icon = $(this),
53
+ bubble = $(this).next();
54
+
55
+ // Close any that are already open
56
+ $('.quads-message').not(bubble).hide();
57
+
58
+ var position = icon.position();
59
+ if (bubble.hasClass('bottom')) {
60
+ bubble.css({
61
+ 'left': (position.left - bubble.width() / 2) + 'px',
62
+ 'top': (position.top + icon.height() + 9) + 'px'
63
+ });
64
+ } else {
65
+ bubble.css({
66
+ 'left': (position.left + icon.width() + 9) + 'px',
67
+ 'top': (position.top + icon.height() / 2 - 18) + 'px'
68
+ });
69
+ }
70
+
71
+ bubble.toggle();
72
+ e.stopPropagation();
73
+ });
74
+ $('.quads-general-helper').click(function (e) {
75
+ e.preventDefault();
76
+ var icon = $(this),
77
+ bubble = $(this).next();
78
+
79
+ // Close any that are already open
80
+ $('.quads-message').not(bubble).hide();
81
+
82
+ var position = icon.position();
83
+ if (bubble.hasClass('bottom')) {
84
+ bubble.css({
85
+ 'left': (position.left - bubble.width() / 2) + 'px',
86
+ 'top': (position.top + icon.height() + 9) + 'px'
87
+ });
88
+ } else {
89
+ bubble.css({
90
+ 'left': (position.left + icon.width() + 9) + 'px',
91
+ 'top': (position.top + icon.height() / 2 - 18) + 'px'
92
+ });
93
+ }
94
+
95
+ bubble.toggle();
96
+ e.stopPropagation();
97
+ });
98
+
99
+ $('body').click(function () {
100
+ $('.quads-message').hide();
101
+ });
102
+
103
+ $('.quads-message').click(function (e) {
104
+ e.stopPropagation();
105
+ });
106
+
107
+ // Save settings via ajax
108
+ jQuery('#quads_settings').submit(function() {
109
+
110
+ // Check current url / settings page
111
+ var url = window.location.search;
112
+ var search = url.search("page=quads-settings&tab=imexport");
113
+
114
+ jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
115
+ jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
116
+ jQuery(this).ajaxSubmit({
117
+
118
+ success: function(){
119
+ jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
120
+ jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
121
+ quads_hide_success_message();
122
+ },
123
+ //,timeout: 0,
124
+
125
+ error: function(){
126
+ //Do not show alert on import/export tab
127
+ if ( search === -1 ){
128
+ alert ('Error: Can not save settings. Try again');
129
+ }
130
+ jQuery('#quads-save-result').hide('fast');
131
+ }
132
+ });
133
+ // Do not preventDefault on import/export tab
134
+ if ( search === -1 ){
135
+ return false;
136
+ }
137
+ });
138
+
139
+ function quads_hide_success_message(){
140
+ setTimeout("jQuery('#quads-save-message').hide()", 1000);
141
+ }
142
+
143
+
144
+ // Paste AdSense Code form
145
+ $(document).on('click', '#quads-paste-button', function () {
146
+
147
+ var content = $('#quads-adsense-form').val();
148
+ var parseResult = quadsParseAdSenseCode(content);
149
+ if (false !== parseResult) {
150
+ console.log(parseResult);
151
+ setDetailsFromAdCode(parseResult);
152
+ }else{
153
+ $('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
154
+ $('#quads-msg').show();
155
+ }
156
+ });
157
+
158
+
159
+ /**
160
+ * Populate AdSense Date Fields
161
+ *
162
+ * @param object adsense
163
+ * @param2 string id of the parent container
164
+ * @returns false
165
+ */
166
+ function setDetailsFromAdCode(GoogleAd) {
167
+
168
+ var containerID = $('#quads-adsense-id').val();
169
+
170
+ var id = containerID.replace("quads-toggle", "");
171
+
172
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
173
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
174
+ if ('normal' == GoogleAd.type) {
175
+ $('#quads_settings\\[' + id + '\\]\\[adsense_type\\]').val('normal');
176
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
177
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
178
+ }
179
+ if ('responsive' == GoogleAd.type) {
180
+ $('#quads_settings\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
181
+ //$('#ad-resize-type').val('auto');
182
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
183
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
184
+ }
185
+ // Trigger the ad type select
186
+ $('.quads-select-Type').trigger('change');
187
+ // Hide the overlay
188
+ $('#quads-adsense-bg-div').hide();
189
+ // Ad code input form must not be empty!
190
+ if ($('#' + containerID).children('textarea').val().length === 0){
191
+ $('#' + containerID).children('textarea').val('adsense');
192
+ }
193
+
194
+
195
+ }
196
+
197
+ /**
198
+ * Parse the adsense ad content
199
+ * @param {type} content
200
+ * @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
201
+ */
202
+ function quadsParseAdSenseCode(content) {
203
+
204
+ var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
205
+ var GoogleAd = {};
206
+ var theContent = $('<div />').html(rawContent);
207
+ var asyncGoogleAd = theContent.find('ins');
208
+ //var syncGoogleAd = theContent.search('google_ad_client');
209
+
210
+ // Its a async adsense ad
211
+ if (asyncGoogleAd.length > 0) {
212
+ console.log('async ad');
213
+
214
+ // Ad Slot ID
215
+ GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
216
+
217
+ if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
218
+ // Ad Publisher ID
219
+ GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
220
+ }
221
+
222
+ if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
223
+ GoogleAd.display = asyncGoogleAd.css('display');
224
+ GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
225
+ GoogleAd.style = asyncGoogleAd.attr('style');
226
+
227
+ if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
228
+ /* normal ad */
229
+ GoogleAd.type = 'normal';
230
+ GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
231
+ GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
232
+ return GoogleAd;
233
+ }
234
+
235
+ if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
236
+ /* Responsive ad, auto resize */
237
+ GoogleAd.type = 'responsive';
238
+ return GoogleAd;
239
+ }
240
+ return GoogleAd;
241
+ }
242
+
243
+ return false;
244
+ }
245
+
246
+ // Google syncronous ad
247
+ if (rawContent.search('google_ad_client') > 0) {
248
+ console.log('syncronous code');
249
+
250
+ // Ad Slot ID
251
+ GoogleAd.slotId = get_google_ad_slot(content);
252
+
253
+ console.log(get_google_ad_slot(content));
254
+ console.log(get_google_ad_client(content));
255
+ console.log(get_google_ad_height(content));
256
+ console.log(get_google_ad_width(content));
257
+
258
+ if (!quadsIsEmpty(get_google_ad_client(content))) {
259
+ // Ad Publisher ID
260
+ GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
261
+ }else{
262
+ return false;
263
+ }
264
+
265
+ if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
266
+
267
+ if (!quadsIsEmpty(get_google_ad_width(content))) {
268
+ GoogleAd.type = 'normal';
269
+ GoogleAd.width = get_google_ad_width(content);
270
+ GoogleAd.height = get_google_ad_height(content);
271
+ return GoogleAd;
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+
277
+ return false;
278
+ }
279
+
280
+ function get_google_ad_slot(content) {
281
+ const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
282
+ const str = content;
283
+ var m;
284
+ var result = {};
285
+
286
+ while ((m = regex.exec(str)) !== null) {
287
+ // This is necessary to avoid infinite loops with zero-width matches
288
+ if (m.index === regex.lastIndex) {
289
+ regex.lastIndex++;
290
+ }
291
+
292
+ // The result can be accessed through the `m`-variable.
293
+ m.forEach(function(match, index){
294
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
295
+ console.log(match);
296
+ result = match;
297
+ });
298
+ }
299
+ return result;
300
+ }
301
+ function get_google_ad_client(content) {
302
+ const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
303
+ const str = content;
304
+ var m;
305
+ var result = {};
306
+
307
+ while ((m = regex.exec(str)) !== null) {
308
+ // This is necessary to avoid infinite loops with zero-width matches
309
+ if (m.index === regex.lastIndex) {
310
+ regex.lastIndex++;
311
+ }
312
+
313
+ // The result can be accessed through the `m`-variable.
314
+ m.forEach(function(match, index){
315
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
316
+ console.log(match);
317
+ result = match;
318
+ });
319
+ }
320
+ return result;
321
+ }
322
+ function get_google_ad_width(content) {
323
+ const regex = /google_ad_width\s*=\s*(\d*);/g;
324
+ const str = content;
325
+ var m;
326
+ var result = {};
327
+
328
+ while ((m = regex.exec(str)) !== null) {
329
+ // This is necessary to avoid infinite loops with zero-width matches
330
+ if (m.index === regex.lastIndex) {
331
+ regex.lastIndex++;
332
+ }
333
+
334
+ // The result can be accessed through the `m`-variable.
335
+ m.forEach(function(match, index){
336
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
337
+ console.log(match);
338
+ result = match;
339
+ });
340
+ }
341
+ return result;
342
+ }
343
+ function get_google_ad_height(content) {
344
+ const regex = /google_ad_height\s*=\s*(\d*);/g;
345
+ const str = content;
346
+ var m;
347
+ var result = {};
348
+
349
+ while ((m = regex.exec(str)) !== null) {
350
+ // This is necessary to avoid infinite loops with zero-width matches
351
+ if (m.index === regex.lastIndex) {
352
+ regex.lastIndex++;
353
+ }
354
+
355
+ // The result can be accessed through the `m`-variable.
356
+ m.forEach(function(match, index){
357
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
358
+ console.log(match);
359
+ result = match;
360
+ });
361
+ }
362
+ return result;
363
+ }
364
+
365
+ /**
366
+ * Check if return value is empty or not
367
+ * @param {type} str
368
+ * @returns {Boolean}
369
+ */
370
+ function quadsIsEmpty(str) {
371
+ return (!str || 0 === str.length);
372
+ }
373
+
374
+ // AdSense Code Input Form
375
+ $(document).on('click', '.quads-add-adsense', function (e) {
376
+ e.preventDefault();
377
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
378
+ // Empty the ad plain text form
379
+ $('#quads-adsense-form').val('');
380
+ $('#quads-adsense-id').val(parentContainerID);
381
+ $('#quads-adsense-bg-div').show();
382
+ });
383
+ $(document).on('click', '#quads-close-button', function (e) {
384
+ e.preventDefault();
385
+ $('#quads-adsense-bg-div').hide();
386
+ });
387
+
388
+
389
+ // Toggle between AdSense or Plain Text
390
+ $(document).on('click', '.quads_adsense_type', function () {
391
+
392
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
393
+
394
+ if ($(this).val() === 'adsense') {
395
+ $('#' + parentContainerID).children('textarea').hide();
396
+ $('#' + parentContainerID).find('div.quads_adsense_code').show();
397
+
398
+ }
399
+ if ($(this).val() === 'plain_text') {
400
+ $('#' + parentContainerID).children('textarea').show();
401
+ $('#' + parentContainerID).children('div.quads_adsense_code').hide();
402
+ }
403
+ });
404
+
405
+
406
+ // Hide or show AdSense elements on loading
407
+ $('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
408
+
409
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
410
+
411
+ if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
412
+ $('#' + parentContainerID).children('textarea').fadeOut();
413
+ $('#' + parentContainerID).find('div.quads_adsense_code').show();
414
+ }
415
+ if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
416
+ $('#' + parentContainerID).children('textarea').fadeIn();
417
+ $('#' + parentContainerID).children('div.quads_adsense_code').hide();
418
+ }
419
+ });
420
+
421
+
422
+ // Hide or show AdSense width and height on loading
423
+ $('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
424
+
425
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
426
+
427
+ if ($(this).val() === 'responsive') {
428
+ $('#' + parentContainerID).find('.quads-type-normal').hide();
429
+ $('#' + parentContainerID).find('.quads-pro-notice').show();
430
+ $('#' + parentContainerID).find('.quads-sizes').show();
431
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
432
+ }
433
+ if ($(this).val() === 'normal') {
434
+ $('#' + parentContainerID).find('.quads-type-normal').show();
435
+ $('#' + parentContainerID).find('.quads-pro-notice').hide();
436
+ $('#' + parentContainerID).find('.quads-sizes').hide();
437
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
438
+ }
439
+ });
440
+
441
+
442
+ // Toggle between Fixed Size or Responsive ad type
443
+ $(document).on('change', '.quads-select-Type', function () {
444
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
445
+
446
+ if ($(this).val() === 'responsive') {
447
+ $('#' + parentContainerID).find('.quads-type-normal').hide();
448
+ $('#' + parentContainerID).find('.quads-pro-notice').show();
449
+ $('#' + parentContainerID).find('.quads-sizes').show();
450
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
451
+ }
452
+ if ($(this).val() === 'normal') {
453
+ $('#' + parentContainerID).find('.quads-type-normal').show();
454
+ $('#' + parentContainerID).find('.quads-pro-notice').hide();
455
+ $('#' + parentContainerID).find('.quads-sizes').hide();
456
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
457
+ }
458
+ });
459
+
460
+ //*[@id="quads-togglead1"]/div[2]
461
+ /**
462
+ * Toggle the adsense container
463
+ */
464
+ $('.quads-ad-toggle-header').click(function (e) {
465
+ e.preventDefault();
466
+
467
+ var container = $('#' + $(this).data('box-id'));
468
+
469
+ container.toggle(0, function () {
470
+ if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
471
+ // open the box
472
+ container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
473
+ } else {
474
+ container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
475
+ }
476
+ });
477
+ });
478
+
479
+ /*
480
+ * Quick Adsense import process
481
+ */
482
+
483
+ jQuery('.quads-import-settings').click(function (e) {
484
+ e.preventDefault();
485
+
486
+ if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
487
+ return;
488
+
489
+ jQuery('#quads-import-settings').addClass('loading');
490
+ var data = {
491
+ action: 'quads_import_quick_adsense',
492
+ nonce: quads.nonce,
493
+ };
494
+ $.post(ajaxurl, data, function (resp, status, xhr) {
495
+
496
+ //console.log('success:' + resp + status + xhr);
497
+ quads_show_message(resp);
498
+
499
+ }).fail(function (xhr) { // Will be executed when $.post() fails
500
+ quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
501
+ //console.log('error: ' + xhr.statusText);
502
+ });
503
+ });
504
+
505
+ jQuery('#quads_insert_ads_action').click(function (e) {
506
+ e.preventDefault();
507
+ jQuery('#quads_insert_ads_box').toggle();
508
+ });
509
+
510
+ jQuery('#quads_disable_ads_action').click(function (e) {
511
+ e.preventDefault();
512
+ jQuery('#quads_disable_ads_box').toggle();
513
+ });
514
+
515
+
516
+ /**
517
+ * Show error message and die()
518
+ * Writes error message into log file
519
+ *
520
+ * @param {string} $error notice
521
+ * @returns void
522
+ */
523
+ function quads_show_message(error) {
524
+ $('#quads-error-details').show();
525
+ $('#quads-error-details').html(error);
526
+ console.log(error);
527
+ }
528
+
529
+
530
+ // Start easytabs()
531
+ if ($(".quads-tabs").length) {
532
+ $('#quads_tab_container').easytabs({
533
+ animate: true,
534
+ updateHash: true,
535
+ animationSpeed: 'fast'
536
+ });
537
+ }
538
+
539
+ }); // document ready
540
+
541
+ /*
542
+ * jQuery hashchange event - v1.3 - 7/21/2010
543
+ * http://benalman.com/projects/jquery-hashchange-plugin/
544
+ *
545
+ * Copyright (c) 2010 "Cowboy" Ben Alman
546
+ * Dual licensed under the MIT and GPL licenses.
547
+ * http://benalman.com/about/license/
548
+ */
549
+ (function ($, e, b) {
550
+ var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
551
+ function a(j) {
552
+ j = j || location.href;
553
+ return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
554
+ }
555
+ $.fn[c] = function (j) {
556
+ return j ? this.bind(c, j) : this.trigger(c)
557
+ };
558
+ $.fn[c].delay = 50;
559
+ g[c] = $.extend(g[c], {setup: function () {
560
+ if (d) {
561
+ return false
562
+ }
563
+ $(f.start)
564
+ }, teardown: function () {
565
+ if (d) {
566
+ return false
567
+ }
568
+ $(f.stop)
569
+ }});
570
+ f = (function () {
571
+ var j = {}, p, m = a(), k = function (q) {
572
+ return q
573
+ }, l = k, o = k;
574
+ j.start = function () {
575
+ p || n()
576
+ };
577
+ j.stop = function () {
578
+ p && clearTimeout(p);
579
+ p = b
580
+ };
581
+ function n() {
582
+ var r = a(), q = o(m);
583
+ if (r !== m) {
584
+ l(m = r, q);
585
+ $(e).trigger(c)
586
+ } else {
587
+ if (q !== m) {
588
+ location.href = location.href.replace(/#.*/, "") + q
589
+ }
590
+ }
591
+ p = setTimeout(n, $.fn[c].delay)
592
+ }
593
+ $.browser.msie && !d && (function () {
594
+ var q, r;
595
+ j.start = function () {
596
+ if (!q) {
597
+ r = $.fn[c].src;
598
+ r = r && r + a();
599
+ q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
600
+ r || l(a());
601
+ n()
602
+ }).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
603
+ h.onpropertychange = function () {
604
+ try {
605
+ if (event.propertyName === "title") {
606
+ q.document.title = h.title
607
+ }
608
+ } catch (s) {
609
+ }
610
+ }
611
+ }
612
+ };
613
+ j.stop = k;
614
+ o = function () {
615
+ return a(q.location.href)
616
+ };
617
+ l = function (v, s) {
618
+ var u = q.document, t = $.fn[c].domain;
619
+ if (v !== s) {
620
+ u.title = h.title;
621
+ u.open();
622
+ t && u.write('<script>document.domain="' + t + '"<\/script>');
623
+ u.close();
624
+ q.location.hash = v
625
+ }
626
+ }
627
+ })();
628
+ return j
629
+ })()
630
+ })(jQuery, this);
631
+
632
+ /*
633
+ * jQuery EasyTabs plugin 3.2.0
634
+ *
635
+ * Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
636
+ *
637
+ * Dual licensed under the MIT and GPL licenses:
638
+ * http://www.opensource.org/licenses/mit-license.php
639
+ * http://www.gnu.org/licenses/gpl.html
640
+ *
641
+ * Date: Thu May 09 17:30:00 2013 -0500
642
+ */
643
+ (function (a) {
644
+ a.easytabs = function (j, e) {
645
+ var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
646
+ f.init = function () {
647
+ f.settings = r = a.extend({}, i, e);
648
+ r.bind_str = r.event + ".easytabs";
649
+ if (r.uiTabs) {
650
+ r.tabActiveClass = "ui-tabs-selected";
651
+ r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
652
+ r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
653
+ r.tabClass = "ui-state-default ui-corner-top";
654
+ r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
655
+ }
656
+ if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
657
+ r.collapsedByDefault = false
658
+ }
659
+ if (typeof (r.animationSpeed) === "string") {
660
+ r.animationSpeed = t[r.animationSpeed]
661
+ }
662
+ a("a.anchor").remove().prependTo("body");
663
+ q.data("easytabs", {});
664
+ f.setTransitions();
665
+ f.getTabs();
666
+ b();
667
+ g();
668
+ w();
669
+ n();
670
+ c();
671
+ q.attr("data-easytabs", true)
672
+ };
673
+ f.setTransitions = function () {
674
+ v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
675
+ };
676
+ f.getTabs = function () {
677
+ var x;
678
+ f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
679
+ var A = a(this), z = A.children("a"), y = A.children("a").data("target");
680
+ A.data("easytabs", {});
681
+ if (y !== undefined && y !== null) {
682
+ A.data("easytabs").ajax = z.attr("href")
683
+ } else {
684
+ y = z.attr("href")
685
+ }
686
+ y = y.match(/#([^\?]+)/)[1];
687
+ x = r.panelContext.find("#" + y);
688
+ if (x.length) {
689
+ x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
690
+ x.not(r.panelActiveClass).hide();
691
+ f.panels = f.panels.add(x);
692
+ A.data("easytabs").panel = x
693
+ } else {
694
+ f.tabs = f.tabs.not(A);
695
+ if ("console" in window) {
696
+ console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
697
+ }
698
+ }
699
+ })
700
+ };
701
+ f.selectTab = function (x, C) {
702
+ var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
703
+ if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
704
+ f.toggleTabCollapse(x, z, A, C)
705
+ } else {
706
+ if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
707
+ o(x, z, A, C)
708
+ } else {
709
+ if (!r.cache) {
710
+ o(x, z, A, C)
711
+ }
712
+ }
713
+ }
714
+ };
715
+ f.toggleTabCollapse = function (x, y, z, A) {
716
+ f.panels.stop(true, true);
717
+ if (u(q, "easytabs:before", [x, y, r])) {
718
+ f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
719
+ if (x.hasClass(r.collapsedClass)) {
720
+ if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
721
+ q.trigger("easytabs:ajax:beforeSend", [x, y]);
722
+ y.load(z, function (C, B, D) {
723
+ x.parent().data("easytabs").cached = true;
724
+ q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
725
+ })
726
+ }
727
+ x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
728
+ y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
729
+ q.trigger("easytabs:midTransition", [x, y, r]);
730
+ if (typeof A == "function") {
731
+ A()
732
+ }
733
+ })
734
+ } else {
735
+ x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
736
+ y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
737
+ q.trigger("easytabs:midTransition", [x, y, r]);
738
+ if (typeof A == "function") {
739
+ A()
740
+ }
741
+ })
742
+ }
743
+ }
744
+ };
745
+ f.matchTab = function (x) {
746
+ return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
747
+ };
748
+ f.matchInPanel = function (x) {
749
+ return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
750
+ };
751
+ f.validId = function (x) {
752
+ return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
753
+ };
754
+ f.selectTabFromHashChange = function () {
755
+ var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
756
+ if (r.updateHash) {
757
+ if (x.length) {
758
+ d = true;
759
+ f.selectTab(x)
760
+ } else {
761
+ z = f.matchInPanel(y);
762
+ if (z.length) {
763
+ y = "#" + z.attr("id");
764
+ x = f.matchTab(y);
765
+ d = true;
766
+ f.selectTab(x)
767
+ } else {
768
+ if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
769
+ if (y === "" || f.matchTab(m).length || q.closest(y).length) {
770
+ d = true;
771
+ f.selectTab(l)
772
+ }
773
+ }
774
+ }
775
+ }
776
+ }
777
+ };
778
+ f.cycleTabs = function (x) {
779
+ if (r.cycle) {
780
+ x = x % f.tabs.length;
781
+ $tab = a(f.tabs[x]).children("a").first();
782
+ d = true;
783
+ f.selectTab($tab, function () {
784
+ setTimeout(function () {
785
+ f.cycleTabs(x + 1)
786
+ }, r.cycle)
787
+ })
788
+ }
789
+ };
790
+ f.publicMethods = {select: function (x) {
791
+ var y;
792
+ if ((y = f.tabs.filter(x)).length === 0) {
793
+ if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
794
+ if ((y = f.tabs.find("a" + x)).length === 0) {
795
+ if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
796
+ if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
797
+ a.error("Tab '" + x + "' does not exist in tab set")
798
+ }
799
+ }
800
+ }
801
+ }
802
+ } else {
803
+ y = y.children("a").first()
804
+ }
805
+ f.selectTab(y)
806
+ }};
807
+ var u = function (A, x, z) {
808
+ var y = a.Event(x);
809
+ A.trigger(y, z);
810
+ return y.result !== false
811
+ };
812
+ var b = function () {
813
+ q.addClass(r.containerClass);
814
+ f.tabs.parent().addClass(r.tabsClass);
815
+ f.tabs.addClass(r.tabClass);
816
+ f.panels.addClass(r.panelClass)
817
+ };
818
+ var g = function () {
819
+ var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
820
+ if (x.length === 1) {
821
+ h = x;
822
+ r.cycle = false
823
+ } else {
824
+ z = f.matchInPanel(y);
825
+ if (z.length) {
826
+ y = "#" + z.attr("id");
827
+ h = f.matchTab(y).parent()
828
+ } else {
829
+ h = f.tabs.parent().find(r.defaultTab);
830
+ if (h.length === 0) {
831
+ a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
832
+ }
833
+ }
834
+ }
835
+ l = h.children("a").first();
836
+ p(x)
837
+ };
838
+ var p = function (z) {
839
+ var y, x;
840
+ if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
841
+ h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
842
+ } else {
843
+ y = a(h.data("easytabs").panel);
844
+ x = h.data("easytabs").ajax;
845
+ if (x && (!r.cache || !h.data("easytabs").cached)) {
846
+ q.trigger("easytabs:ajax:beforeSend", [l, y]);
847
+ y.load(x, function (B, A, C) {
848
+ h.data("easytabs").cached = true;
849
+ q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
850
+ })
851
+ }
852
+ h.data("easytabs").panel.show().addClass(r.panelActiveClass);
853
+ h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
854
+ }
855
+ q.trigger("easytabs:initialised", [l, y])
856
+ };
857
+ var w = function () {
858
+ f.tabs.children("a").bind(r.bind_str, function (x) {
859
+ r.cycle = false;
860
+ d = false;
861
+ f.selectTab(a(this));
862
+ x.preventDefault ? x.preventDefault() : x.returnValue = false
863
+ })
864
+ };
865
+ var o = function (z, D, E, H) {
866
+ f.panels.stop(true, true);
867
+ if (u(q, "easytabs:before", [z, D, r])) {
868
+ var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
869
+ if (r.animate) {
870
+ F = s(D);
871
+ x = A.length ? k(A) : 0;
872
+ C = F - x
873
+ }
874
+ m = B;
875
+ G = function () {
876
+ q.trigger("easytabs:midTransition", [z, D, r]);
877
+ if (r.animate && r.transitionIn == "fadeIn") {
878
+ if (C < 0) {
879
+ y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
880
+ }
881
+ }
882
+ if (r.updateHash && !d) {
883
+ window.location.hash = "#" + D.attr("id")
884
+ } else {
885
+ d = false
886
+ }
887
+ D[v.show](v.speed, r.transitionInEasing, function () {
888
+ y.css({height: "", "min-height": ""});
889
+ q.trigger("easytabs:after", [z, D, r]);
890
+ if (typeof H == "function") {
891
+ H()
892
+ }
893
+ })
894
+ };
895
+ if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
896
+ q.trigger("easytabs:ajax:beforeSend", [z, D]);
897
+ D.load(E, function (J, I, K) {
898
+ z.parent().data("easytabs").cached = true;
899
+ q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
900
+ })
901
+ }
902
+ if (r.animate && r.transitionOut == "fadeOut") {
903
+ if (C > 0) {
904
+ y.animate({height: (y.height() + C)}, v.halfSpeed)
905
+ } else {
906
+ y.css({"min-height": y.height()})
907
+ }
908
+ }
909
+ f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
910
+ f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
911
+ z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
912
+ f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
913
+ D.addClass(r.panelActiveClass);
914
+ if (A.length) {
915
+ A[v.hide](v.speed, r.transitionOutEasing, G)
916
+ } else {
917
+ D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
918
+ }
919
+ }
920
+ };
921
+ var s = function (z) {
922
+ if (z.data("easytabs") && z.data("easytabs").lastHeight) {
923
+ return z.data("easytabs").lastHeight
924
+ }
925
+ var B = z.css("display"), y, x;
926
+ try {
927
+ y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
928
+ } catch (A) {
929
+ y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
930
+ }
931
+ x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
932
+ z.unwrap();
933
+ z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
934
+ z.data("easytabs").lastHeight = x;
935
+ return x
936
+ };
937
+ var k = function (y) {
938
+ var x = y.outerHeight();
939
+ if (y.data("easytabs")) {
940
+ y.data("easytabs").lastHeight = x
941
+ } else {
942
+ y.data("easytabs", {lastHeight: x})
943
+ }
944
+ return x
945
+ };
946
+ var n = function () {
947
+ if (typeof a(window).hashchange === "function") {
948
+ a(window).hashchange(function () {
949
+ f.selectTabFromHashChange()
950
+ })
951
+ } else {
952
+ if (a.address && typeof a.address.change === "function") {
953
+ a.address.change(function () {
954
+ f.selectTabFromHashChange()
955
+ })
956
+ }
957
+ }
958
+ };
959
+ var c = function () {
960
+ var x;
961
+ if (r.cycle) {
962
+ x = f.tabs.index(h);
963
+ setTimeout(function () {
964
+ f.cycleTabs(x + 1)
965
+ }, r.cycle)
966
+ }
967
+ };
968
+ f.init()
969
+ };
970
+ a.fn.easytabs = function (c) {
971
+ var b = arguments;
972
+ return this.each(function () {
973
+ var e = a(this), d = e.data("easytabs");
974
+ if (undefined === d) {
975
+ d = new a.easytabs(this, c);
976
+ e.data("easytabs", d)
977
+ }
978
+ if (d.publicMethods[c]) {
979
+ return d.publicMethods[c](Array.prototype.slice.call(b, 1))
980
+ }
981
+ })
982
+ }
983
+ })(jQuery);
984
+
985
+
986
+ /*
987
+ colpick Color Picker
988
+ Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
989
+
990
+ For usage and examples: colpick.com/plugin
991
+ */
992
+
993
+ (function ($) {
994
+ var colpick = function () {
995
+ var
996
+ tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
997
+ defaults = {
998
+ showEvent: 'click',
999
+ onShow: function () {
1000
+ },
1001
+ onBeforeShow: function () {
1002
+ },
1003
+ onHide: function () {
1004
+ },
1005
+ onChange: function () {
1006
+ },
1007
+ onSubmit: function () {
1008
+ },
1009
+ colorScheme: 'light',
1010
+ color: '3289c7',
1011
+ livePreview: true,
1012
+ flat: false,
1013
+ layout: 'full',
1014
+ submit: 1,
1015
+ submitText: 'OK',
1016
+ height: 156
1017
+ },
1018
+ //Fill the inputs of the plugin
1019
+ fillRGBFields = function (hsb, cal) {
1020
+ var rgb = hsbToRgb(hsb);
1021
+ $(cal).data('colpick').fields
1022
+ .eq(1).val(rgb.r).end()
1023
+ .eq(2).val(rgb.g).end()
1024
+ .eq(3).val(rgb.b).end();
1025
+ },
1026
+ fillHSBFields = function (hsb, cal) {
1027
+ $(cal).data('colpick').fields
1028
+ .eq(4).val(Math.round(hsb.h)).end()
1029
+ .eq(5).val(Math.round(hsb.s)).end()
1030
+ .eq(6).val(Math.round(hsb.b)).end();
1031
+ },
1032
+ fillHexFields = function (hsb, cal) {
1033
+ $(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
1034
+ },
1035
+ //Set the round selector position
1036
+ setSelector = function (hsb, cal) {
1037
+ $(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
1038
+ $(cal).data('colpick').selectorIndic.css({
1039
+ left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
1040
+ top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
1041
+ });
1042
+ },
1043
+ //Set the hue selector position
1044
+ setHue = function (hsb, cal) {
1045
+ $(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
1046
+ },
1047
+ //Set current and new colors
1048
+ setCurrentColor = function (hsb, cal) {
1049
+ $(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
1050
+ },
1051
+ setNewColor = function (hsb, cal) {
1052
+ $(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
1053
+ },
1054
+ //Called when the new color is changed
1055
+ change = function (ev) {
1056
+ var cal = $(this).parent().parent(), col;
1057
+ if (this.parentNode.className.indexOf('_hex') > 0) {
1058
+ cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
1059
+ fillRGBFields(col, cal.get(0));
1060
+ fillHSBFields(col, cal.get(0));
1061
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
1062
+ cal.data('colpick').color = col = fixHSB({
1063
+ h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
1064
+ s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
1065
+ b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
1066
+ });
1067
+ fillRGBFields(col, cal.get(0));
1068
+ fillHexFields(col, cal.get(0));
1069
+ } else {
1070
+ cal.data('colpick').color = col = rgbToHsb(fixRGB({
1071
+ r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
1072
+ g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
1073
+ b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
1074
+ }));
1075
+ fillHexFields(col, cal.get(0));
1076
+ fillHSBFields(col, cal.get(0));
1077
+ }
1078
+ setSelector(col, cal.get(0));
1079
+ setHue(col, cal.get(0));
1080
+ setNewColor(col, cal.get(0));
1081
+ cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
1082
+ },
1083
+ //Change style on blur and on focus of inputs
1084
+ blur = function (ev) {
1085
+ $(this).parent().removeClass('colpick_focus');
1086
+ },
1087
+ focus = function () {
1088
+ $(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
1089
+ $(this).parent().addClass('colpick_focus');
1090
+ },
1091
+ //Increment/decrement arrows functions
1092
+ downIncrement = function (ev) {
1093
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1094
+ var field = $(this).parent().find('input').focus();
1095
+ var current = {
1096
+ el: $(this).parent().addClass('colpick_slider'),
1097
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
1098
+ y: ev.pageY,
1099
+ field: field,
1100
+ val: parseInt(field.val(), 10),
1101
+ preview: $(this).parent().parent().data('colpick').livePreview
1102
+ };
1103
+ $(document).mouseup(current, upIncrement);
1104
+ $(document).mousemove(current, moveIncrement);
1105
+ },
1106
+ moveIncrement = function (ev) {
1107
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
1108
+ if (ev.data.preview) {
1109
+ change.apply(ev.data.field.get(0), [true]);
1110
+ }
1111
+ return false;
1112
+ },
1113
+ upIncrement = function (ev) {
1114
+ change.apply(ev.data.field.get(0), [true]);
1115
+ ev.data.el.removeClass('colpick_slider').find('input').focus();
1116
+ $(document).off('mouseup', upIncrement);
1117
+ $(document).off('mousemove', moveIncrement);
1118
+ return false;
1119
+ },
1120
+ //Hue slider functions
1121
+ downHue = function (ev) {
1122
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1123
+ var current = {
1124
+ cal: $(this).parent(),
1125
+ y: $(this).offset().top
1126
+ };
1127
+ $(document).on('mouseup touchend', current, upHue);
1128
+ $(document).on('mousemove touchmove', current, moveHue);
1129
+
1130
+ var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
1131
+ change.apply(
1132
+ current.cal.data('colpick')
1133
+ .fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
1134
+ .get(0),
1135
+ [current.cal.data('colpick').livePreview]
1136
+ );
1137
+ return false;
1138
+ },
1139
+ moveHue = function (ev) {
1140
+ var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
1141
+ change.apply(
1142
+ ev.data.cal.data('colpick')
1143
+ .fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
1144
+ .get(0),
1145
+ [ev.data.preview]
1146
+ );
1147
+ return false;
1148
+ },
1149
+ upHue = function (ev) {
1150
+ fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1151
+ fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1152
+ $(document).off('mouseup touchend', upHue);
1153
+ $(document).off('mousemove touchmove', moveHue);
1154
+ return false;
1155
+ },
1156
+ //Color selector functions
1157
+ downSelector = function (ev) {
1158
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1159
+ var current = {
1160
+ cal: $(this).parent(),
1161
+ pos: $(this).offset()
1162
+ };
1163
+ current.preview = current.cal.data('colpick').livePreview;
1164
+
1165
+ $(document).on('mouseup touchend', current, upSelector);
1166
+ $(document).on('mousemove touchmove', current, moveSelector);
1167
+
1168
+ var payeX, pageY;
1169
+ if (ev.type == 'touchstart') {
1170
+ pageX = ev.originalEvent.changedTouches[0].pageX,
1171
+ pageY = ev.originalEvent.changedTouches[0].pageY;
1172
+ } else {
1173
+ pageX = ev.pageX;
1174
+ pageY = ev.pageY;
1175
+ }
1176
+
1177
+ change.apply(
1178
+ current.cal.data('colpick').fields
1179
+ .eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
1180
+ .eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
1181
+ .get(0),
1182
+ [current.preview]
1183
+ );
1184
+ return false;
1185
+ },
1186
+ moveSelector = function (ev) {
1187
+ var payeX, pageY;
1188
+ if (ev.type == 'touchmove') {
1189
+ pageX = ev.originalEvent.changedTouches[0].pageX,
1190
+ pageY = ev.originalEvent.changedTouches[0].pageY;
1191
+ } else {
1192
+ pageX = ev.pageX;
1193
+ pageY = ev.pageY;
1194
+ }
1195
+
1196
+ change.apply(
1197
+ ev.data.cal.data('colpick').fields
1198
+ .eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
1199
+ .eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
1200
+ .get(0),
1201
+ [ev.data.preview]
1202
+ );
1203
+ return false;
1204
+ },
1205
+ upSelector = function (ev) {
1206
+ fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1207
+ fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1208
+ $(document).off('mouseup touchend', upSelector);
1209
+ $(document).off('mousemove touchmove', moveSelector);
1210
+ return false;
1211
+ },
1212
+ //Submit button
1213
+ clickSubmit = function (ev) {
1214
+ var cal = $(this).parent();
1215
+ var col = cal.data('colpick').color;
1216
+ cal.data('colpick').origColor = col;
1217
+ setCurrentColor(col, cal.get(0));
1218
+ cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
1219
+ },
1220
+ //Show/hide the color picker
1221
+ show = function (ev) {
1222
+ // Prevent the trigger of any direct parent
1223
+ ev.stopPropagation();
1224
+ var cal = $('#' + $(this).data('colpickId'));
1225
+ cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
1226
+ var pos = $(this).offset();
1227
+ var top = pos.top + this.offsetHeight;
1228
+ var left = pos.left;
1229
+ var viewPort = getViewport();
1230
+ var calW = cal.width();
1231
+ if (left + calW > viewPort.l + viewPort.w) {
1232
+ left -= calW;
1233
+ }
1234
+ cal.css({left: left + 'px', top: top + 'px'});
1235
+ if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
1236
+ cal.show();
1237
+ }
1238
+ //Hide when user clicks outside
1239
+ $('html').mousedown({cal: cal}, hide);
1240
+ cal.mousedown(function (ev) {
1241
+ ev.stopPropagation();
1242
+ })
1243
+ },
1244
+ hide = function (ev) {
1245
+ if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
1246
+ ev.data.cal.hide();
1247
+ }
1248
+ $('html').off('mousedown', hide);
1249
+ },
1250
+ getViewport = function () {
1251
+ var m = document.compatMode == 'CSS1Compat';
1252
+ return {
1253
+ l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
1254
+ w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
1255
+ };
1256
+ },
1257
+ //Fix the values if the user enters a negative or high value
1258
+ fixHSB = function (hsb) {
1259
+ return {
1260
+ h: Math.min(360, Math.max(0, hsb.h)),
1261
+ s: Math.min(100, Math.max(0, hsb.s)),
1262
+ b: Math.min(100, Math.max(0, hsb.b))
1263
+ };
1264
+ },
1265
+ fixRGB = function (rgb) {
1266
+ return {
1267
+ r: Math.min(255, Math.max(0, rgb.r)),
1268
+ g: Math.min(255, Math.max(0, rgb.g)),
1269
+ b: Math.min(255, Math.max(0, rgb.b))
1270
+ };
1271
+ },
1272
+ fixHex = function (hex) {
1273
+ var len = 6 - hex.length;
1274
+ if (len > 0) {
1275
+ var o = [];
1276
+ for (var i = 0; i < len; i++) {
1277
+ o.push('0');
1278
+ }
1279
+ o.push(hex);
1280
+ hex = o.join('');
1281
+ }
1282
+ return hex;
1283
+ },
1284
+ restoreOriginal = function () {
1285
+ var cal = $(this).parent();
1286
+ var col = cal.data('colpick').origColor;
1287
+ cal.data('colpick').color = col;
1288
+ fillRGBFields(col, cal.get(0));
1289
+ fillHexFields(col, cal.get(0));
1290
+ fillHSBFields(col, cal.get(0));
1291
+ setSelector(col, cal.get(0));
1292
+ setHue(col, cal.get(0));
1293
+ setNewColor(col, cal.get(0));
1294
+ };
1295
+ return {
1296
+ init: function (opt) {
1297
+ opt = $.extend({}, defaults, opt || {});
1298
+ //Set color
1299
+ if (typeof opt.color == 'string') {
1300
+ opt.color = hexToHsb(opt.color);
1301
+ } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
1302
+ opt.color = rgbToHsb(opt.color);
1303
+ } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
1304
+ opt.color = fixHSB(opt.color);
1305
+ } else {
1306
+ return this;
1307
+ }
1308
+
1309
+ //For each selected DOM element
1310
+ return this.each(function () {
1311
+ //If the element does not have an ID
1312
+ if (!$(this).data('colpickId')) {
1313
+ var options = $.extend({}, opt);
1314
+ options.origColor = opt.color;
1315
+ //Generate and assign a random ID
1316
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
1317
+ $(this).data('colpickId', id);
1318
+ //Set the tpl's ID and get the HTML
1319
+ var cal = $(tpl).attr('id', id);
1320
+ //Add class according to layout
1321
+ cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
1322
+ //Add class if the color scheme is not default
1323
+ if (options.colorScheme != 'light') {
1324
+ cal.addClass('colpick_' + options.colorScheme);
1325
+ }
1326
+ //Setup submit button
1327
+ cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
1328
+ //Setup input fields
1329
+ options.fields = cal.find('input').change(change).blur(blur).focus(focus);
1330
+ cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
1331
+ //Setup hue selector
1332
+ options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
1333
+ options.selectorIndic = options.selector.find('div.colpick_selector_outer');
1334
+ //Store parts of the plugin
1335
+ options.el = this;
1336
+ options.hue = cal.find('div.colpick_hue_arrs');
1337
+ huebar = options.hue.parent();
1338
+ //Paint the hue bar
1339
+ var UA = navigator.userAgent.toLowerCase();
1340
+ var isIE = navigator.appName === 'Microsoft Internet Explorer';
1341
+ var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
1342
+ var ngIE = (isIE && IEver < 10);
1343
+ var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
1344
+ if (ngIE) {
1345
+ var i, div;
1346
+ for (i = 0; i <= 11; i++) {
1347
+ div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
1348
+ huebar.append(div);
1349
+ }
1350
+ } else {
1351
+ stopList = stops.join(',');
1352
+ huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
1353
+ }
1354
+ cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
1355
+ options.newColor = cal.find('div.colpick_new_color');
1356
+ options.currentColor = cal.find('div.colpick_current_color');
1357
+ //Store options and fill with default color
1358
+ cal.data('colpick', options);
1359
+ fillRGBFields(options.color, cal.get(0));
1360
+ fillHSBFields(options.color, cal.get(0));
1361
+ fillHexFields(options.color, cal.get(0));
1362
+ setHue(options.color, cal.get(0));
1363
+ setSelector(options.color, cal.get(0));
1364
+ setCurrentColor(options.color, cal.get(0));
1365
+ setNewColor(options.color, cal.get(0));
1366
+ //Append to body if flat=false, else show in place
1367
+ if (options.flat) {
1368
+ cal.appendTo(this).show();
1369
+ cal.css({
1370
+ position: 'relative',
1371
+ display: 'block'
1372
+ });
1373
+ } else {
1374
+ cal.appendTo(document.body);
1375
+ $(this).on(options.showEvent, show);
1376
+ cal.css({
1377
+ position: 'absolute'
1378
+ });
1379
+ }
1380
+ }
1381
+ });
1382
+ },
1383
+ //Shows the picker
1384
+ showPicker: function () {
1385
+ return this.each(function () {
1386
+ if ($(this).data('colpickId')) {
1387
+ show.apply(this);
1388
+ }
1389
+ });
1390
+ },
1391
+ //Hides the picker
1392
+ hidePicker: function () {
1393
+ return this.each(function () {
1394
+ if ($(this).data('colpickId')) {
1395
+ $('#' + $(this).data('colpickId')).hide();
1396
+ }
1397
+ });
1398
+ },
1399
+ //Sets a color as new and current (default)
1400
+ setColor: function (col, setCurrent) {
1401
+ setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
1402
+ if (typeof col == 'string') {
1403
+ col = hexToHsb(col);
1404
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
1405
+ col = rgbToHsb(col);
1406
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
1407
+ col = fixHSB(col);
1408
+ } else {
1409
+ return this;
1410
+ }
1411
+ return this.each(function () {
1412
+ if ($(this).data('colpickId')) {
1413
+ var cal = $('#' + $(this).data('colpickId'));
1414
+ cal.data('colpick').color = col;
1415
+ cal.data('colpick').origColor = col;
1416
+ fillRGBFields(col, cal.get(0));
1417
+ fillHSBFields(col, cal.get(0));
1418
+ fillHexFields(col, cal.get(0));
1419
+ setHue(col, cal.get(0));
1420
+ setSelector(col, cal.get(0));
1421
+
1422
+ setNewColor(col, cal.get(0));
1423
+ cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
1424
+ if (setCurrent) {
1425
+ setCurrentColor(col, cal.get(0));
1426
+ }
1427
+ }
1428
+ });
1429
+ }
1430
+ };
1431
+ }();
1432
+ //Color space convertions
1433
+ var hexToRgb = function (hex) {
1434
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
1435
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
1436
+ };
1437
+ var hexToHsb = function (hex) {
1438
+ return rgbToHsb(hexToRgb(hex));
1439
+ };
1440
+ var rgbToHsb = function (rgb) {
1441
+ var hsb = {h: 0, s: 0, b: 0};
1442
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
1443
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
1444
+ var delta = max - min;
1445
+ hsb.b = max;
1446
+ hsb.s = max != 0 ? 255 * delta / max : 0;
1447
+ if (hsb.s != 0) {
1448
+ if (rgb.r == max)
1449
+ hsb.h = (rgb.g - rgb.b) / delta;
1450
+ else if (rgb.g == max)
1451
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
1452
+ else
1453
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
1454
+ } else
1455
+ hsb.h = -1;
1456
+ hsb.h *= 60;
1457
+ if (hsb.h < 0)
1458
+ hsb.h += 360;
1459
+ hsb.s *= 100 / 255;
1460
+ hsb.b *= 100 / 255;
1461
+ return hsb;
1462
+ };
1463
+ var hsbToRgb = function (hsb) {
1464
+ var rgb = {};
1465
+ var h = hsb.h;
1466
+ var s = hsb.s * 255 / 100;
1467
+ var v = hsb.b * 255 / 100;
1468
+ if (s == 0) {
1469
+ rgb.r = rgb.g = rgb.b = v;
1470
+ } else {
1471
+ var t1 = v;
1472
+ var t2 = (255 - s) * v / 255;
1473
+ var t3 = (t1 - t2) * (h % 60) / 60;
1474
+ if (h == 360)
1475
+ h = 0;
1476
+ if (h < 60) {
1477
+ rgb.r = t1;
1478
+ rgb.b = t2;
1479
+ rgb.g = t2 + t3
1480
+ } else if (h < 120) {
1481
+ rgb.g = t1;
1482
+ rgb.b = t2;
1483
+ rgb.r = t1 - t3
1484
+ } else if (h < 180) {
1485
+ rgb.g = t1;
1486
+ rgb.r = t2;
1487
+ rgb.b = t2 + t3
1488
+ } else if (h < 240) {
1489
+ rgb.b = t1;
1490
+ rgb.r = t2;
1491
+ rgb.g = t1 - t3
1492
+ } else if (h < 300) {
1493
+ rgb.b = t1;
1494
+ rgb.g = t2;
1495
+ rgb.r = t2 + t3
1496
+ } else if (h < 360) {
1497
+ rgb.r = t1;
1498
+ rgb.g = t2;
1499
+ rgb.b = t1 - t3
1500
+ } else {
1501
+ rgb.r = 0;
1502
+ rgb.g = 0;
1503
+ rgb.b = 0
1504
+ }
1505
+ }
1506
+ return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
1507
+ };
1508
+ var rgbToHex = function (rgb) {
1509
+ var hex = [
1510
+ rgb.r.toString(16),
1511
+ rgb.g.toString(16),
1512
+ rgb.b.toString(16)
1513
+ ];
1514
+ $.each(hex, function (nr, val) {
1515
+ if (val.length == 1) {
1516
+ hex[nr] = '0' + val;
1517
+ }
1518
+ });
1519
+ return hex.join('');
1520
+ };
1521
+ var hsbToHex = function (hsb) {
1522
+ return rgbToHex(hsbToRgb(hsb));
1523
+ };
1524
+ $.fn.extend({
1525
+ colpick: colpick.init,
1526
+ colpickHide: colpick.hidePicker,
1527
+ colpickShow: colpick.showPicker,
1528
+ colpickSetColor: colpick.setColor
1529
+ });
1530
+ $.extend({
1531
+ colpick: {
1532
+ rgbToHex: rgbToHex,
1533
+ rgbToHsb: rgbToHsb,
1534
+ hsbToHex: hsbToHex,
1535
+ hsbToRgb: hsbToRgb,
1536
+ hexToHsb: hexToHsb,
1537
+ hexToRgb: hexToRgb
1538
+ }
1539
+ });
1540
+ })(jQuery);
assets/js/quads-admin.min.js ADDED
@@ -0,0 +1,1540 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+
5
+ // Activate chosen select boxes
6
+ $(".quads-chosen-select").chosen({
7
+ inherit_select_classes: true
8
+ });
9
+
10
+ // Hid or show AMP code form on click on amp checkbox
11
+ $('.quads-activate-amp').click(function(){
12
+ var parent = $(this).parents('.quads-ad-toggle-container').attr('id');
13
+ if ($(this).attr('checked') === 'checked') {
14
+ $('#' + parent).find('.quads-amp-code').show();
15
+ } else {
16
+ $('#' + parent).find('.quads-amp-code').hide();
17
+ }
18
+ });
19
+
20
+
21
+ // Hide or show AMP code form on loading
22
+ $('.quads-ad-toggle-container').find('.quads-activate-amp').each(function (index, value) {
23
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
24
+ if ($(this).attr( 'checked') === 'checked' ) {
25
+ $('#' + parentContainerID).find('.quads-amp-code').show();
26
+ }else {
27
+ $('#' + parentContainerID).find('.quads-amp-code').hide();
28
+ }
29
+ });
30
+
31
+ // // remove content of amp code form if its clicked in
32
+ // $('.quads-amp-code').click(function(){
33
+ // $(this).val('');
34
+ // });
35
+
36
+ /**
37
+ * Toggle Button Open All Ads
38
+ */
39
+ $('#quads-open-toggle').click(function(){
40
+ if ($('#quads-open-toggle').html() == 'Open All Ads' ){
41
+ $('.quads-ad-toggle-container').show();
42
+ $('#quads-open-toggle').html('Close Tabs');
43
+ }else{
44
+ $('.quads-ad-toggle-container').hide();
45
+ $('#quads-open-toggle').html('Open All Ads');
46
+ }
47
+ });
48
+
49
+ // show / hide helper description
50
+ $('.quads-helper').click(function (e) {
51
+ e.preventDefault();
52
+ var icon = $(this),
53
+ bubble = $(this).next();
54
+
55
+ // Close any that are already open
56
+ $('.quads-message').not(bubble).hide();
57
+
58
+ var position = icon.position();
59
+ if (bubble.hasClass('bottom')) {
60
+ bubble.css({
61
+ 'left': (position.left - bubble.width() / 2) + 'px',
62
+ 'top': (position.top + icon.height() + 9) + 'px'
63
+ });
64
+ } else {
65
+ bubble.css({
66
+ 'left': (position.left + icon.width() + 9) + 'px',
67
+ 'top': (position.top + icon.height() / 2 - 18) + 'px'
68
+ });
69
+ }
70
+
71
+ bubble.toggle();
72
+ e.stopPropagation();
73
+ });
74
+ $('.quads-general-helper').click(function (e) {
75
+ e.preventDefault();
76
+ var icon = $(this),
77
+ bubble = $(this).next();
78
+
79
+ // Close any that are already open
80
+ $('.quads-message').not(bubble).hide();
81
+
82
+ var position = icon.position();
83
+ if (bubble.hasClass('bottom')) {
84
+ bubble.css({
85
+ 'left': (position.left - bubble.width() / 2) + 'px',
86
+ 'top': (position.top + icon.height() + 9) + 'px'
87
+ });
88
+ } else {
89
+ bubble.css({
90
+ 'left': (position.left + icon.width() + 9) + 'px',
91
+ 'top': (position.top + icon.height() / 2 - 18) + 'px'
92
+ });
93
+ }
94
+
95
+ bubble.toggle();
96
+ e.stopPropagation();
97
+ });
98
+
99
+ $('body').click(function () {
100
+ $('.quads-message').hide();
101
+ });
102
+
103
+ $('.quads-message').click(function (e) {
104
+ e.stopPropagation();
105
+ });
106
+
107
+ // Save settings via ajax
108
+ jQuery('#quads_settings').submit(function() {
109
+
110
+ // Check current url / settings page
111
+ var url = window.location.search;
112
+ var search = url.search("page=quads-settings&tab=imexport");
113
+
114
+ jQuery('#quads-save-result').html("<div id='quads-loader' class='quads-loader'></div>");
115
+ jQuery('#quads-loader').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/loader1.gif"></p>').show();
116
+ jQuery(this).ajaxSubmit({
117
+
118
+ success: function(){
119
+ jQuery('#quads-save-result').html("<div id='quads-save-message' class='quads-success-modal'></div>");
120
+ jQuery('#quads-save-message').append('<p><img src="'+quads.path+'/wp-content/plugins/quick-adsense-reloaded/assets/images/saved.gif"></p>').show();
121
+ quads_hide_success_message();
122
+ },
123
+ //,timeout: 0,
124
+
125
+ error: function(){
126
+ //Do not show alert on import/export tab
127
+ if ( search === -1 ){
128
+ alert ('Error: Can not save settings. Try again');
129
+ }
130
+ jQuery('#quads-save-result').hide('fast');
131
+ }
132
+ });
133
+ // Do not preventDefault on import/export tab
134
+ if ( search === -1 ){
135
+ return false;
136
+ }
137
+ });
138
+
139
+ function quads_hide_success_message(){
140
+ setTimeout("jQuery('#quads-save-message').hide()", 1000);
141
+ }
142
+
143
+
144
+ // Paste AdSense Code form
145
+ $(document).on('click', '#quads-paste-button', function () {
146
+
147
+ var content = $('#quads-adsense-form').val();
148
+ var parseResult = quadsParseAdSenseCode(content);
149
+ if (false !== parseResult) {
150
+ console.log(parseResult);
151
+ setDetailsFromAdCode(parseResult);
152
+ }else{
153
+ $('#quads-msg').html('Can not parse AdSense Code. Is the code valid?');
154
+ $('#quads-msg').show();
155
+ }
156
+ });
157
+
158
+
159
+ /**
160
+ * Populate AdSense Date Fields
161
+ *
162
+ * @param object adsense
163
+ * @param2 string id of the parent container
164
+ * @returns false
165
+ */
166
+ function setDetailsFromAdCode(GoogleAd) {
167
+
168
+ var containerID = $('#quads-adsense-id').val();
169
+
170
+ var id = containerID.replace("quads-toggle", "");
171
+
172
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_slot\\]').val(GoogleAd.slotId);
173
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_client\\]').val(GoogleAd.pubId);
174
+ if ('normal' == GoogleAd.type) {
175
+ $('#quads_settings\\[' + id + '\\]\\[adsense_type\\]').val('normal');
176
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_width\\]').val(GoogleAd.width);
177
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_height\\]').val(GoogleAd.height);
178
+ }
179
+ if ('responsive' == GoogleAd.type) {
180
+ $('#quads_settings\\[' + id + '\\]\\[adsense_type\\]').val('responsive');
181
+ //$('#ad-resize-type').val('auto');
182
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_width\\]').val('');
183
+ $('#quads_settings\\[' + id + '\\]\\[g_data_ad_height\\]').val('');
184
+ }
185
+ // Trigger the ad type select
186
+ $('.quads-select-Type').trigger('change');
187
+ // Hide the overlay
188
+ $('#quads-adsense-bg-div').hide();
189
+ // Ad code input form must not be empty!
190
+ if ($('#' + containerID).children('textarea').val().length === 0){
191
+ $('#' + containerID).children('textarea').val('adsense');
192
+ }
193
+
194
+
195
+ }
196
+
197
+ /**
198
+ * Parse the adsense ad content
199
+ * @param {type} content
200
+ * @returns {quads-admin.min_L3.parseAdContent.GoogleAd|Boolean}
201
+ */
202
+ function quadsParseAdSenseCode(content) {
203
+
204
+ var rawContent = ('undefined' != typeof (content)) ? content.trim() : '';
205
+ var GoogleAd = {};
206
+ var theContent = $('<div />').html(rawContent);
207
+ var asyncGoogleAd = theContent.find('ins');
208
+ //var syncGoogleAd = theContent.search('google_ad_client');
209
+
210
+ // Its a async adsense ad
211
+ if (asyncGoogleAd.length > 0) {
212
+ console.log('async ad');
213
+
214
+ // Ad Slot ID
215
+ GoogleAd.slotId = asyncGoogleAd.attr('data-ad-slot');
216
+
217
+ if ('undefined' != typeof (asyncGoogleAd.attr('data-ad-client'))) {
218
+ // Ad Publisher ID
219
+ GoogleAd.pubId = asyncGoogleAd.attr('data-ad-client').substr(3);
220
+ }
221
+
222
+ if (undefined !== GoogleAd.slotId && '' != GoogleAd.pubId) {
223
+ GoogleAd.display = asyncGoogleAd.css('display');
224
+ GoogleAd.format = asyncGoogleAd.attr('data-ad-format');
225
+ GoogleAd.style = asyncGoogleAd.attr('style');
226
+
227
+ if ('undefined' == typeof (GoogleAd.format) && -1 != GoogleAd.style.indexOf('width')) {
228
+ /* normal ad */
229
+ GoogleAd.type = 'normal';
230
+ GoogleAd.width = asyncGoogleAd.css('width').replace('px', '');
231
+ GoogleAd.height = asyncGoogleAd.css('height').replace('px', '');
232
+ return GoogleAd;
233
+ }
234
+
235
+ if ('undefined' != typeof (GoogleAd.format) && 'auto' == GoogleAd.format) {
236
+ /* Responsive ad, auto resize */
237
+ GoogleAd.type = 'responsive';
238
+ return GoogleAd;
239
+ }
240
+ return GoogleAd;
241
+ }
242
+
243
+ return false;
244
+ }
245
+
246
+ // Google syncronous ad
247
+ if (rawContent.search('google_ad_client') > 0) {
248
+ console.log('syncronous code');
249
+
250
+ // Ad Slot ID
251
+ GoogleAd.slotId = get_google_ad_slot(content);
252
+
253
+ console.log(get_google_ad_slot(content));
254
+ console.log(get_google_ad_client(content));
255
+ console.log(get_google_ad_height(content));
256
+ console.log(get_google_ad_width(content));
257
+
258
+ if (!quadsIsEmpty(get_google_ad_client(content))) {
259
+ // Ad Publisher ID
260
+ GoogleAd.pubId = 'ca-pub-' + get_google_ad_client(content);
261
+ }else{
262
+ return false;
263
+ }
264
+
265
+ if (!quadsIsEmpty(GoogleAd.slotId) && !quadsIsEmpty(GoogleAd.pubId)) {
266
+
267
+ if (!quadsIsEmpty(get_google_ad_width(content))) {
268
+ GoogleAd.type = 'normal';
269
+ GoogleAd.width = get_google_ad_width(content);
270
+ GoogleAd.height = get_google_ad_height(content);
271
+ return GoogleAd;
272
+ }
273
+ }
274
+ return false;
275
+ }
276
+
277
+ return false;
278
+ }
279
+
280
+ function get_google_ad_slot(content) {
281
+ const regex = /google_ad_slot\s*=\s*"(\d*)";/g;
282
+ const str = content;
283
+ var m;
284
+ var result = {};
285
+
286
+ while ((m = regex.exec(str)) !== null) {
287
+ // This is necessary to avoid infinite loops with zero-width matches
288
+ if (m.index === regex.lastIndex) {
289
+ regex.lastIndex++;
290
+ }
291
+
292
+ // The result can be accessed through the `m`-variable.
293
+ m.forEach(function(match, index){
294
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
295
+ console.log(match);
296
+ result = match;
297
+ });
298
+ }
299
+ return result;
300
+ }
301
+ function get_google_ad_client(content) {
302
+ const regex = /google_ad_client\s*=\s*"ca-pub-(\d*)";/g;
303
+ const str = content;
304
+ var m;
305
+ var result = {};
306
+
307
+ while ((m = regex.exec(str)) !== null) {
308
+ // This is necessary to avoid infinite loops with zero-width matches
309
+ if (m.index === regex.lastIndex) {
310
+ regex.lastIndex++;
311
+ }
312
+
313
+ // The result can be accessed through the `m`-variable.
314
+ m.forEach(function(match, index){
315
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
316
+ console.log(match);
317
+ result = match;
318
+ });
319
+ }
320
+ return result;
321
+ }
322
+ function get_google_ad_width(content) {
323
+ const regex = /google_ad_width\s*=\s*(\d*);/g;
324
+ const str = content;
325
+ var m;
326
+ var result = {};
327
+
328
+ while ((m = regex.exec(str)) !== null) {
329
+ // This is necessary to avoid infinite loops with zero-width matches
330
+ if (m.index === regex.lastIndex) {
331
+ regex.lastIndex++;
332
+ }
333
+
334
+ // The result can be accessed through the `m`-variable.
335
+ m.forEach(function(match, index){
336
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
337
+ console.log(match);
338
+ result = match;
339
+ });
340
+ }
341
+ return result;
342
+ }
343
+ function get_google_ad_height(content) {
344
+ const regex = /google_ad_height\s*=\s*(\d*);/g;
345
+ const str = content;
346
+ var m;
347
+ var result = {};
348
+
349
+ while ((m = regex.exec(str)) !== null) {
350
+ // This is necessary to avoid infinite loops with zero-width matches
351
+ if (m.index === regex.lastIndex) {
352
+ regex.lastIndex++;
353
+ }
354
+
355
+ // The result can be accessed through the `m`-variable.
356
+ m.forEach(function(match, index){
357
+ //console.log(`Found match, group ${groupIndex}: ${match}`);
358
+ console.log(match);
359
+ result = match;
360
+ });
361
+ }
362
+ return result;
363
+ }
364
+
365
+ /**
366
+ * Check if return value is empty or not
367
+ * @param {type} str
368
+ * @returns {Boolean}
369
+ */
370
+ function quadsIsEmpty(str) {
371
+ return (!str || 0 === str.length);
372
+ }
373
+
374
+ // AdSense Code Input Form
375
+ $(document).on('click', '.quads-add-adsense', function (e) {
376
+ e.preventDefault();
377
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
378
+ // Empty the ad plain text form
379
+ $('#quads-adsense-form').val('');
380
+ $('#quads-adsense-id').val(parentContainerID);
381
+ $('#quads-adsense-bg-div').show();
382
+ });
383
+ $(document).on('click', '#quads-close-button', function (e) {
384
+ e.preventDefault();
385
+ $('#quads-adsense-bg-div').hide();
386
+ });
387
+
388
+
389
+ // Toggle between AdSense or Plain Text
390
+ $(document).on('click', '.quads_adsense_type', function () {
391
+
392
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
393
+
394
+ if ($(this).val() === 'adsense') {
395
+ $('#' + parentContainerID).children('textarea').hide();
396
+ $('#' + parentContainerID).find('div.quads_adsense_code').show();
397
+
398
+ }
399
+ if ($(this).val() === 'plain_text') {
400
+ $('#' + parentContainerID).children('textarea').show();
401
+ $('#' + parentContainerID).children('div.quads_adsense_code').hide();
402
+ }
403
+ });
404
+
405
+
406
+ // Hide or show AdSense elements on loading
407
+ $('.quads-ad-toggle-container').find('.quads_adsense_type').each(function (index, value) {
408
+
409
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
410
+
411
+ if ($(this).attr('checked') === 'checked' && $(this).val() === 'adsense') {
412
+ $('#' + parentContainerID).children('textarea').fadeOut();
413
+ $('#' + parentContainerID).find('div.quads_adsense_code').show();
414
+ }
415
+ if ($(this).attr('checked') === 'checked' && $(this).val() === 'plain_text') {
416
+ $('#' + parentContainerID).children('textarea').fadeIn();
417
+ $('#' + parentContainerID).children('div.quads_adsense_code').hide();
418
+ }
419
+ });
420
+
421
+
422
+ // Hide or show AdSense width and height on loading
423
+ $('.quads-ad-toggle-container').find('.quads-select-Type').each(function (index, value) {
424
+
425
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
426
+
427
+ if ($(this).val() === 'responsive') {
428
+ $('#' + parentContainerID).find('.quads-type-normal').hide();
429
+ $('#' + parentContainerID).find('.quads-pro-notice').show();
430
+ $('#' + parentContainerID).find('.quads-sizes').show();
431
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
432
+ }
433
+ if ($(this).val() === 'normal') {
434
+ $('#' + parentContainerID).find('.quads-type-normal').show();
435
+ $('#' + parentContainerID).find('.quads-pro-notice').hide();
436
+ $('#' + parentContainerID).find('.quads-sizes').hide();
437
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
438
+ }
439
+ });
440
+
441
+
442
+ // Toggle between Fixed Size or Responsive ad type
443
+ $(document).on('change', '.quads-select-Type', function () {
444
+ var parentContainerID = $(this).parents('.quads-ad-toggle-container').attr('id');
445
+
446
+ if ($(this).val() === 'responsive') {
447
+ $('#' + parentContainerID).find('.quads-type-normal').hide();
448
+ $('#' + parentContainerID).find('.quads-pro-notice').show();
449
+ $('#' + parentContainerID).find('.quads-sizes').show();
450
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','');
451
+ }
452
+ if ($(this).val() === 'normal') {
453
+ $('#' + parentContainerID).find('.quads-type-normal').show();
454
+ $('#' + parentContainerID).find('.quads-pro-notice').hide();
455
+ $('#' + parentContainerID).find('.quads-sizes').hide();
456
+ $('#' + parentContainerID).find('.quads-sizes-container').css('clear','both');
457
+ }
458
+ });
459
+
460
+ //*[@id="quads-togglead1"]/div[2]
461
+ /**
462
+ * Toggle the adsense container
463
+ */
464
+ $('.quads-ad-toggle-header').click(function (e) {
465
+ e.preventDefault();
466
+
467
+ var container = $('#' + $(this).data('box-id'));
468
+
469
+ container.toggle(0, function () {
470
+ if (container.parents('.quads-ad-toggle-header').hasClass('quads-box-close')) {
471
+ // open the box
472
+ container.parents('.quads-ad-toggle-header').removeClass('quads-box-close');
473
+ } else {
474
+ container.parents('.quads-ad-toggle-header').addClass('quads-box-close');
475
+ }
476
+ });
477
+ });
478
+
479
+ /*
480
+ * Quick Adsense import process
481
+ */
482
+
483
+ jQuery('.quads-import-settings').click(function (e) {
484
+ e.preventDefault();
485
+
486
+ if (!confirm('Importing settings from Quick AdSense will overwrite all your current settings. Are you sure?'))
487
+ return;
488
+
489
+ jQuery('#quads-import-settings').addClass('loading');
490
+ var data = {
491
+ action: 'quads_import_quick_adsense',
492
+ nonce: quads.nonce,
493
+ };
494
+ $.post(ajaxurl, data, function (resp, status, xhr) {
495
+
496
+ //console.log('success:' + resp + status + xhr);
497
+ quads_show_message(resp);
498
+
499
+ }).fail(function (xhr) { // Will be executed when $.post() fails
500
+ quads_show_message('Ajax Error: ' + xhr.status + ' ' + xhr.statusText);
501
+ //console.log('error: ' + xhr.statusText);
502
+ });
503
+ });
504
+
505
+ jQuery('#quads_insert_ads_action').click(function (e) {
506
+ e.preventDefault();
507
+ jQuery('#quads_insert_ads_box').toggle();
508
+ });
509
+
510
+ jQuery('#quads_disable_ads_action').click(function (e) {
511
+ e.preventDefault();
512
+ jQuery('#quads_disable_ads_box').toggle();
513
+ });
514
+
515
+
516
+ /**
517
+ * Show error message and die()
518
+ * Writes error message into log file
519
+ *
520
+ * @param {string} $error notice
521
+ * @returns void
522
+ */
523
+ function quads_show_message(error) {
524
+ $('#quads-error-details').show();
525
+ $('#quads-error-details').html(error);
526
+ console.log(error);
527
+ }
528
+
529
+
530
+ // Start easytabs()
531
+ if ($(".quads-tabs").length) {
532
+ $('#quads_tab_container').easytabs({
533
+ animate: true,
534
+ updateHash: true,
535
+ animationSpeed: 'fast'
536
+ });
537
+ }
538
+
539
+ }); // document ready
540
+
541
+ /*
542
+ * jQuery hashchange event - v1.3 - 7/21/2010
543
+ * http://benalman.com/projects/jquery-hashchange-plugin/
544
+ *
545
+ * Copyright (c) 2010 "Cowboy" Ben Alman
546
+ * Dual licensed under the MIT and GPL licenses.
547
+ * http://benalman.com/about/license/
548
+ */
549
+ (function ($, e, b) {
550
+ var c = "hashchange", h = document, f, g = $.event.special, i = h.documentMode, d = "on" + c in e && (i === b || i > 7);
551
+ function a(j) {
552
+ j = j || location.href;
553
+ return"#" + j.replace(/^[^#]*#?(.*)$/, "$1")
554
+ }
555
+ $.fn[c] = function (j) {
556
+ return j ? this.bind(c, j) : this.trigger(c)
557
+ };
558
+ $.fn[c].delay = 50;
559
+ g[c] = $.extend(g[c], {setup: function () {
560
+ if (d) {
561
+ return false
562
+ }
563
+ $(f.start)
564
+ }, teardown: function () {
565
+ if (d) {
566
+ return false
567
+ }
568
+ $(f.stop)
569
+ }});
570
+ f = (function () {
571
+ var j = {}, p, m = a(), k = function (q) {
572
+ return q
573
+ }, l = k, o = k;
574
+ j.start = function () {
575
+ p || n()
576
+ };
577
+ j.stop = function () {
578
+ p && clearTimeout(p);
579
+ p = b
580
+ };
581
+ function n() {
582
+ var r = a(), q = o(m);
583
+ if (r !== m) {
584
+ l(m = r, q);
585
+ $(e).trigger(c)
586
+ } else {
587
+ if (q !== m) {
588
+ location.href = location.href.replace(/#.*/, "") + q
589
+ }
590
+ }
591
+ p = setTimeout(n, $.fn[c].delay)
592
+ }
593
+ $.browser.msie && !d && (function () {
594
+ var q, r;
595
+ j.start = function () {
596
+ if (!q) {
597
+ r = $.fn[c].src;
598
+ r = r && r + a();
599
+ q = $('<iframe tabindex="-1" title="empty"/>').hide().one("load", function () {
600
+ r || l(a());
601
+ n()
602
+ }).attr("src", r || "javascript:0").insertAfter("body")[0].contentWindow;
603
+ h.onpropertychange = function () {
604
+ try {
605
+ if (event.propertyName === "title") {
606
+ q.document.title = h.title
607
+ }
608
+ } catch (s) {
609
+ }
610
+ }
611
+ }
612
+ };
613
+ j.stop = k;
614
+ o = function () {
615
+ return a(q.location.href)
616
+ };
617
+ l = function (v, s) {
618
+ var u = q.document, t = $.fn[c].domain;
619
+ if (v !== s) {
620
+ u.title = h.title;
621
+ u.open();
622
+ t && u.write('<script>document.domain="' + t + '"<\/script>');
623
+ u.close();
624
+ q.location.hash = v
625
+ }
626
+ }
627
+ })();
628
+ return j
629
+ })()
630
+ })(jQuery, this);
631
+
632
+ /*
633
+ * jQuery EasyTabs plugin 3.2.0
634
+ *
635
+ * Copyright (c) 2010-2011 Steve Schwartz (JangoSteve)
636
+ *
637
+ * Dual licensed under the MIT and GPL licenses:
638
+ * http://www.opensource.org/licenses/mit-license.php
639
+ * http://www.gnu.org/licenses/gpl.html
640
+ *
641
+ * Date: Thu May 09 17:30:00 2013 -0500
642
+ */
643
+ (function (a) {
644
+ a.easytabs = function (j, e) {
645
+ var f = this, q = a(j), i = {animate: true, panelActiveClass: "active", tabActiveClass: "active", defaultTab: "li:first-child", animationSpeed: "fast", tabs: "> ul > li", updateHash: true, cycle: false, collapsible: false, collapsedClass: "collapsed", collapsedByDefault: true, uiTabs: false, transitionIn: "fadeIn", transitionOut: "fadeOut", transitionInEasing: "swing", transitionOutEasing: "swing", transitionCollapse: "slideUp", transitionUncollapse: "slideDown", transitionCollapseEasing: "swing", transitionUncollapseEasing: "swing", containerClass: "", tabsClass: "", tabClass: "", panelClass: "", cache: true, event: "click", panelContext: q}, h, l, v, m, d, t = {fast: 200, normal: 400, slow: 600}, r;
646
+ f.init = function () {
647
+ f.settings = r = a.extend({}, i, e);
648
+ r.bind_str = r.event + ".easytabs";
649
+ if (r.uiTabs) {
650
+ r.tabActiveClass = "ui-tabs-selected";
651
+ r.containerClass = "ui-tabs ui-widget ui-widget-content ui-corner-all";
652
+ r.tabsClass = "ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all";
653
+ r.tabClass = "ui-state-default ui-corner-top";
654
+ r.panelClass = "ui-tabs-panel ui-widget-content ui-corner-bottom"
655
+ }
656
+ if (r.collapsible && e.defaultTab !== undefined && e.collpasedByDefault === undefined) {
657
+ r.collapsedByDefault = false
658
+ }
659
+ if (typeof (r.animationSpeed) === "string") {
660
+ r.animationSpeed = t[r.animationSpeed]
661
+ }
662
+ a("a.anchor").remove().prependTo("body");
663
+ q.data("easytabs", {});
664
+ f.setTransitions();
665
+ f.getTabs();
666
+ b();
667
+ g();
668
+ w();
669
+ n();
670
+ c();
671
+ q.attr("data-easytabs", true)
672
+ };
673
+ f.setTransitions = function () {
674
+ v = (r.animate) ? {show: r.transitionIn, hide: r.transitionOut, speed: r.animationSpeed, collapse: r.transitionCollapse, uncollapse: r.transitionUncollapse, halfSpeed: r.animationSpeed / 2} : {show: "show", hide: "hide", speed: 0, collapse: "hide", uncollapse: "show", halfSpeed: 0}
675
+ };
676
+ f.getTabs = function () {
677
+ var x;
678
+ f.tabs = q.find(r.tabs), f.panels = a(), f.tabs.each(function () {
679
+ var A = a(this), z = A.children("a"), y = A.children("a").data("target");
680
+ A.data("easytabs", {});
681
+ if (y !== undefined && y !== null) {
682
+ A.data("easytabs").ajax = z.attr("href")
683
+ } else {
684
+ y = z.attr("href")
685
+ }
686
+ y = y.match(/#([^\?]+)/)[1];
687
+ x = r.panelContext.find("#" + y);
688
+ if (x.length) {
689
+ x.data("easytabs", {position: x.css("position"), visibility: x.css("visibility")});
690
+ x.not(r.panelActiveClass).hide();
691
+ f.panels = f.panels.add(x);
692
+ A.data("easytabs").panel = x
693
+ } else {
694
+ f.tabs = f.tabs.not(A);
695
+ if ("console" in window) {
696
+ console.warn("Warning: tab without matching panel for selector '#" + y + "' removed from set")
697
+ }
698
+ }
699
+ })
700
+ };
701
+ f.selectTab = function (x, C) {
702
+ var y = window.location, B = y.hash.match(/^[^\?]*/)[0], z = x.parent().data("easytabs").panel, A = x.parent().data("easytabs").ajax;
703
+ if (r.collapsible && !d && (x.hasClass(r.tabActiveClass) || x.hasClass(r.collapsedClass))) {
704
+ f.toggleTabCollapse(x, z, A, C)
705
+ } else {
706
+ if (!x.hasClass(r.tabActiveClass) || !z.hasClass(r.panelActiveClass)) {
707
+ o(x, z, A, C)
708
+ } else {
709
+ if (!r.cache) {
710
+ o(x, z, A, C)
711
+ }
712
+ }
713
+ }
714
+ };
715
+ f.toggleTabCollapse = function (x, y, z, A) {
716
+ f.panels.stop(true, true);
717
+ if (u(q, "easytabs:before", [x, y, r])) {
718
+ f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
719
+ if (x.hasClass(r.collapsedClass)) {
720
+ if (z && (!r.cache || !x.parent().data("easytabs").cached)) {
721
+ q.trigger("easytabs:ajax:beforeSend", [x, y]);
722
+ y.load(z, function (C, B, D) {
723
+ x.parent().data("easytabs").cached = true;
724
+ q.trigger("easytabs:ajax:complete", [x, y, C, B, D])
725
+ })
726
+ }
727
+ x.parent().removeClass(r.collapsedClass).addClass(r.tabActiveClass).children().removeClass(r.collapsedClass).addClass(r.tabActiveClass);
728
+ y.addClass(r.panelActiveClass)[v.uncollapse](v.speed, r.transitionUncollapseEasing, function () {
729
+ q.trigger("easytabs:midTransition", [x, y, r]);
730
+ if (typeof A == "function") {
731
+ A()
732
+ }
733
+ })
734
+ } else {
735
+ x.addClass(r.collapsedClass).parent().addClass(r.collapsedClass);
736
+ y.removeClass(r.panelActiveClass)[v.collapse](v.speed, r.transitionCollapseEasing, function () {
737
+ q.trigger("easytabs:midTransition", [x, y, r]);
738
+ if (typeof A == "function") {
739
+ A()
740
+ }
741
+ })
742
+ }
743
+ }
744
+ };
745
+ f.matchTab = function (x) {
746
+ return f.tabs.find("[href='" + x + "'],[data-target='" + x + "']").first()
747
+ };
748
+ f.matchInPanel = function (x) {
749
+ return(x && f.validId(x) ? f.panels.filter(":has(" + x + ")").first() : [])
750
+ };
751
+ f.validId = function (x) {
752
+ return x.substr(1).match(/^[A-Za-z]+[A-Za-z0-9\-_:\.].$/)
753
+ };
754
+ f.selectTabFromHashChange = function () {
755
+ var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y), z;
756
+ if (r.updateHash) {
757
+ if (x.length) {
758
+ d = true;
759
+ f.selectTab(x)
760
+ } else {
761
+ z = f.matchInPanel(y);
762
+ if (z.length) {
763
+ y = "#" + z.attr("id");
764
+ x = f.matchTab(y);
765
+ d = true;
766
+ f.selectTab(x)
767
+ } else {
768
+ if (!h.hasClass(r.tabActiveClass) && !r.cycle) {
769
+ if (y === "" || f.matchTab(m).length || q.closest(y).length) {
770
+ d = true;
771
+ f.selectTab(l)
772
+ }
773
+ }
774
+ }
775
+ }
776
+ }
777
+ };
778
+ f.cycleTabs = function (x) {
779
+ if (r.cycle) {
780
+ x = x % f.tabs.length;
781
+ $tab = a(f.tabs[x]).children("a").first();
782
+ d = true;
783
+ f.selectTab($tab, function () {
784
+ setTimeout(function () {
785
+ f.cycleTabs(x + 1)
786
+ }, r.cycle)
787
+ })
788
+ }
789
+ };
790
+ f.publicMethods = {select: function (x) {
791
+ var y;
792
+ if ((y = f.tabs.filter(x)).length === 0) {
793
+ if ((y = f.tabs.find("a[href='" + x + "']")).length === 0) {
794
+ if ((y = f.tabs.find("a" + x)).length === 0) {
795
+ if ((y = f.tabs.find("[data-target='" + x + "']")).length === 0) {
796
+ if ((y = f.tabs.find("a[href$='" + x + "']")).length === 0) {
797
+ a.error("Tab '" + x + "' does not exist in tab set")
798
+ }
799
+ }
800
+ }
801
+ }
802
+ } else {
803
+ y = y.children("a").first()
804
+ }
805
+ f.selectTab(y)
806
+ }};
807
+ var u = function (A, x, z) {
808
+ var y = a.Event(x);
809
+ A.trigger(y, z);
810
+ return y.result !== false
811
+ };
812
+ var b = function () {
813
+ q.addClass(r.containerClass);
814
+ f.tabs.parent().addClass(r.tabsClass);
815
+ f.tabs.addClass(r.tabClass);
816
+ f.panels.addClass(r.panelClass)
817
+ };
818
+ var g = function () {
819
+ var y = window.location.hash.match(/^[^\?]*/)[0], x = f.matchTab(y).parent(), z;
820
+ if (x.length === 1) {
821
+ h = x;
822
+ r.cycle = false
823
+ } else {
824
+ z = f.matchInPanel(y);
825
+ if (z.length) {
826
+ y = "#" + z.attr("id");
827
+ h = f.matchTab(y).parent()
828
+ } else {
829
+ h = f.tabs.parent().find(r.defaultTab);
830
+ if (h.length === 0) {
831
+ a.error("The specified default tab ('" + r.defaultTab + "') could not be found in the tab set ('" + r.tabs + "') out of " + f.tabs.length + " tabs.")
832
+ }
833
+ }
834
+ }
835
+ l = h.children("a").first();
836
+ p(x)
837
+ };
838
+ var p = function (z) {
839
+ var y, x;
840
+ if (r.collapsible && z.length === 0 && r.collapsedByDefault) {
841
+ h.addClass(r.collapsedClass).children().addClass(r.collapsedClass)
842
+ } else {
843
+ y = a(h.data("easytabs").panel);
844
+ x = h.data("easytabs").ajax;
845
+ if (x && (!r.cache || !h.data("easytabs").cached)) {
846
+ q.trigger("easytabs:ajax:beforeSend", [l, y]);
847
+ y.load(x, function (B, A, C) {
848
+ h.data("easytabs").cached = true;
849
+ q.trigger("easytabs:ajax:complete", [l, y, B, A, C])
850
+ })
851
+ }
852
+ h.data("easytabs").panel.show().addClass(r.panelActiveClass);
853
+ h.addClass(r.tabActiveClass).children().addClass(r.tabActiveClass)
854
+ }
855
+ q.trigger("easytabs:initialised", [l, y])
856
+ };
857
+ var w = function () {
858
+ f.tabs.children("a").bind(r.bind_str, function (x) {
859
+ r.cycle = false;
860
+ d = false;
861
+ f.selectTab(a(this));
862
+ x.preventDefault ? x.preventDefault() : x.returnValue = false
863
+ })
864
+ };
865
+ var o = function (z, D, E, H) {
866
+ f.panels.stop(true, true);
867
+ if (u(q, "easytabs:before", [z, D, r])) {
868
+ var A = f.panels.filter(":visible"), y = D.parent(), F, x, C, G, B = window.location.hash.match(/^[^\?]*/)[0];
869
+ if (r.animate) {
870
+ F = s(D);
871
+ x = A.length ? k(A) : 0;
872
+ C = F - x
873
+ }
874
+ m = B;
875
+ G = function () {
876
+ q.trigger("easytabs:midTransition", [z, D, r]);
877
+ if (r.animate && r.transitionIn == "fadeIn") {
878
+ if (C < 0) {
879
+ y.animate({height: y.height() + C}, v.halfSpeed).css({"min-height": ""})
880
+ }
881
+ }
882
+ if (r.updateHash && !d) {
883
+ window.location.hash = "#" + D.attr("id")
884
+ } else {
885
+ d = false
886
+ }
887
+ D[v.show](v.speed, r.transitionInEasing, function () {
888
+ y.css({height: "", "min-height": ""});
889
+ q.trigger("easytabs:after", [z, D, r]);
890
+ if (typeof H == "function") {
891
+ H()
892
+ }
893
+ })
894
+ };
895
+ if (E && (!r.cache || !z.parent().data("easytabs").cached)) {
896
+ q.trigger("easytabs:ajax:beforeSend", [z, D]);
897
+ D.load(E, function (J, I, K) {
898
+ z.parent().data("easytabs").cached = true;
899
+ q.trigger("easytabs:ajax:complete", [z, D, J, I, K])
900
+ })
901
+ }
902
+ if (r.animate && r.transitionOut == "fadeOut") {
903
+ if (C > 0) {
904
+ y.animate({height: (y.height() + C)}, v.halfSpeed)
905
+ } else {
906
+ y.css({"min-height": y.height()})
907
+ }
908
+ }
909
+ f.tabs.filter("." + r.tabActiveClass).removeClass(r.tabActiveClass).children().removeClass(r.tabActiveClass);
910
+ f.tabs.filter("." + r.collapsedClass).removeClass(r.collapsedClass).children().removeClass(r.collapsedClass);
911
+ z.parent().addClass(r.tabActiveClass).children().addClass(r.tabActiveClass);
912
+ f.panels.filter("." + r.panelActiveClass).removeClass(r.panelActiveClass);
913
+ D.addClass(r.panelActiveClass);
914
+ if (A.length) {
915
+ A[v.hide](v.speed, r.transitionOutEasing, G)
916
+ } else {
917
+ D[v.uncollapse](v.speed, r.transitionUncollapseEasing, G)
918
+ }
919
+ }
920
+ };
921
+ var s = function (z) {
922
+ if (z.data("easytabs") && z.data("easytabs").lastHeight) {
923
+ return z.data("easytabs").lastHeight
924
+ }
925
+ var B = z.css("display"), y, x;
926
+ try {
927
+ y = a("<div></div>", {position: "absolute", visibility: "hidden", overflow: "hidden"})
928
+ } catch (A) {
929
+ y = a("<div></div>", {visibility: "hidden", overflow: "hidden"})
930
+ }
931
+ x = z.wrap(y).css({position: "relative", visibility: "hidden", display: "block"}).outerHeight();
932
+ z.unwrap();
933
+ z.css({position: z.data("easytabs").position, visibility: z.data("easytabs").visibility, display: B});
934
+ z.data("easytabs").lastHeight = x;
935
+ return x
936
+ };
937
+ var k = function (y) {
938
+ var x = y.outerHeight();
939
+ if (y.data("easytabs")) {
940
+ y.data("easytabs").lastHeight = x
941
+ } else {
942
+ y.data("easytabs", {lastHeight: x})
943
+ }
944
+ return x
945
+ };
946
+ var n = function () {
947
+ if (typeof a(window).hashchange === "function") {
948
+ a(window).hashchange(function () {
949
+ f.selectTabFromHashChange()
950
+ })
951
+ } else {
952
+ if (a.address && typeof a.address.change === "function") {
953
+ a.address.change(function () {
954
+ f.selectTabFromHashChange()
955
+ })
956
+ }
957
+ }
958
+ };
959
+ var c = function () {
960
+ var x;
961
+ if (r.cycle) {
962
+ x = f.tabs.index(h);
963
+ setTimeout(function () {
964
+ f.cycleTabs(x + 1)
965
+ }, r.cycle)
966
+ }
967
+ };
968
+ f.init()
969
+ };
970
+ a.fn.easytabs = function (c) {
971
+ var b = arguments;
972
+ return this.each(function () {
973
+ var e = a(this), d = e.data("easytabs");
974
+ if (undefined === d) {
975
+ d = new a.easytabs(this, c);
976
+ e.data("easytabs", d)
977
+ }
978
+ if (d.publicMethods[c]) {
979
+ return d.publicMethods[c](Array.prototype.slice.call(b, 1))
980
+ }
981
+ })
982
+ }
983
+ })(jQuery);
984
+
985
+
986
+ /*
987
+ colpick Color Picker
988
+ Copyright 2013 Jose Vargas. Licensed under GPL license. Based on Stefan Petre's Color Picker www.eyecon.ro, dual licensed under the MIT and GPL licenses
989
+
990
+ For usage and examples: colpick.com/plugin
991
+ */
992
+
993
+ (function ($) {
994
+ var colpick = function () {
995
+ var
996
+ tpl = '<div class="colpick"><div class="colpick_color"><div class="colpick_color_overlay1"><div class="colpick_color_overlay2"><div class="colpick_selector_outer"><div class="colpick_selector_inner"></div></div></div></div></div><div class="colpick_hue"><div class="colpick_hue_arrs"><div class="colpick_hue_larr"></div><div class="colpick_hue_rarr"></div></div></div><div class="colpick_new_color"></div><div class="colpick_current_color"></div><div class="colpick_hex_field"><div class="colpick_field_letter">#</div><input type="text" maxlength="6" size="6" /></div><div class="colpick_rgb_r colpick_field"><div class="colpick_field_letter">R</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_g colpick_field"><div class="colpick_field_letter">G</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_rgb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_h colpick_field"><div class="colpick_field_letter">H</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_s colpick_field"><div class="colpick_field_letter">S</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_hsb_b colpick_field"><div class="colpick_field_letter">B</div><input type="text" maxlength="3" size="3" /><div class="colpick_field_arrs"><div class="colpick_field_uarr"></div><div class="colpick_field_darr"></div></div></div><div class="colpick_submit"></div></div>',
997
+ defaults = {
998
+ showEvent: 'click',
999
+ onShow: function () {
1000
+ },
1001
+ onBeforeShow: function () {
1002
+ },
1003
+ onHide: function () {
1004
+ },
1005
+ onChange: function () {
1006
+ },
1007
+ onSubmit: function () {
1008
+ },
1009
+ colorScheme: 'light',
1010
+ color: '3289c7',
1011
+ livePreview: true,
1012
+ flat: false,
1013
+ layout: 'full',
1014
+ submit: 1,
1015
+ submitText: 'OK',
1016
+ height: 156
1017
+ },
1018
+ //Fill the inputs of the plugin
1019
+ fillRGBFields = function (hsb, cal) {
1020
+ var rgb = hsbToRgb(hsb);
1021
+ $(cal).data('colpick').fields
1022
+ .eq(1).val(rgb.r).end()
1023
+ .eq(2).val(rgb.g).end()
1024
+ .eq(3).val(rgb.b).end();
1025
+ },
1026
+ fillHSBFields = function (hsb, cal) {
1027
+ $(cal).data('colpick').fields
1028
+ .eq(4).val(Math.round(hsb.h)).end()
1029
+ .eq(5).val(Math.round(hsb.s)).end()
1030
+ .eq(6).val(Math.round(hsb.b)).end();
1031
+ },
1032
+ fillHexFields = function (hsb, cal) {
1033
+ $(cal).data('colpick').fields.eq(0).val(hsbToHex(hsb));
1034
+ },
1035
+ //Set the round selector position
1036
+ setSelector = function (hsb, cal) {
1037
+ $(cal).data('colpick').selector.css('backgroundColor', '#' + hsbToHex({h: hsb.h, s: 100, b: 100}));
1038
+ $(cal).data('colpick').selectorIndic.css({
1039
+ left: parseInt($(cal).data('colpick').height * hsb.s / 100, 10),
1040
+ top: parseInt($(cal).data('colpick').height * (100 - hsb.b) / 100, 10)
1041
+ });
1042
+ },
1043
+ //Set the hue selector position
1044
+ setHue = function (hsb, cal) {
1045
+ $(cal).data('colpick').hue.css('top', parseInt($(cal).data('colpick').height - $(cal).data('colpick').height * hsb.h / 360, 10));
1046
+ },
1047
+ //Set current and new colors
1048
+ setCurrentColor = function (hsb, cal) {
1049
+ $(cal).data('colpick').currentColor.css('backgroundColor', '#' + hsbToHex(hsb));
1050
+ },
1051
+ setNewColor = function (hsb, cal) {
1052
+ $(cal).data('colpick').newColor.css('backgroundColor', '#' + hsbToHex(hsb));
1053
+ },
1054
+ //Called when the new color is changed
1055
+ change = function (ev) {
1056
+ var cal = $(this).parent().parent(), col;
1057
+ if (this.parentNode.className.indexOf('_hex') > 0) {
1058
+ cal.data('colpick').color = col = hexToHsb(fixHex(this.value));
1059
+ fillRGBFields(col, cal.get(0));
1060
+ fillHSBFields(col, cal.get(0));
1061
+ } else if (this.parentNode.className.indexOf('_hsb') > 0) {
1062
+ cal.data('colpick').color = col = fixHSB({
1063
+ h: parseInt(cal.data('colpick').fields.eq(4).val(), 10),
1064
+ s: parseInt(cal.data('colpick').fields.eq(5).val(), 10),
1065
+ b: parseInt(cal.data('colpick').fields.eq(6).val(), 10)
1066
+ });
1067
+ fillRGBFields(col, cal.get(0));
1068
+ fillHexFields(col, cal.get(0));
1069
+ } else {
1070
+ cal.data('colpick').color = col = rgbToHsb(fixRGB({
1071
+ r: parseInt(cal.data('colpick').fields.eq(1).val(), 10),
1072
+ g: parseInt(cal.data('colpick').fields.eq(2).val(), 10),
1073
+ b: parseInt(cal.data('colpick').fields.eq(3).val(), 10)
1074
+ }));
1075
+ fillHexFields(col, cal.get(0));
1076
+ fillHSBFields(col, cal.get(0));
1077
+ }
1078
+ setSelector(col, cal.get(0));
1079
+ setHue(col, cal.get(0));
1080
+ setNewColor(col, cal.get(0));
1081
+ cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 0]);
1082
+ },
1083
+ //Change style on blur and on focus of inputs
1084
+ blur = function (ev) {
1085
+ $(this).parent().removeClass('colpick_focus');
1086
+ },
1087
+ focus = function () {
1088
+ $(this).parent().parent().data('colpick').fields.parent().removeClass('colpick_focus');
1089
+ $(this).parent().addClass('colpick_focus');
1090
+ },
1091
+ //Increment/decrement arrows functions
1092
+ downIncrement = function (ev) {
1093
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1094
+ var field = $(this).parent().find('input').focus();
1095
+ var current = {
1096
+ el: $(this).parent().addClass('colpick_slider'),
1097
+ max: this.parentNode.className.indexOf('_hsb_h') > 0 ? 360 : (this.parentNode.className.indexOf('_hsb') > 0 ? 100 : 255),
1098
+ y: ev.pageY,
1099
+ field: field,
1100
+ val: parseInt(field.val(), 10),
1101
+ preview: $(this).parent().parent().data('colpick').livePreview
1102
+ };
1103
+ $(document).mouseup(current, upIncrement);
1104
+ $(document).mousemove(current, moveIncrement);
1105
+ },
1106
+ moveIncrement = function (ev) {
1107
+ ev.data.field.val(Math.max(0, Math.min(ev.data.max, parseInt(ev.data.val - ev.pageY + ev.data.y, 10))));
1108
+ if (ev.data.preview) {
1109
+ change.apply(ev.data.field.get(0), [true]);
1110
+ }
1111
+ return false;
1112
+ },
1113
+ upIncrement = function (ev) {
1114
+ change.apply(ev.data.field.get(0), [true]);
1115
+ ev.data.el.removeClass('colpick_slider').find('input').focus();
1116
+ $(document).off('mouseup', upIncrement);
1117
+ $(document).off('mousemove', moveIncrement);
1118
+ return false;
1119
+ },
1120
+ //Hue slider functions
1121
+ downHue = function (ev) {
1122
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1123
+ var current = {
1124
+ cal: $(this).parent(),
1125
+ y: $(this).offset().top
1126
+ };
1127
+ $(document).on('mouseup touchend', current, upHue);
1128
+ $(document).on('mousemove touchmove', current, moveHue);
1129
+
1130
+ var pageY = ((ev.type == 'touchstart') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
1131
+ change.apply(
1132
+ current.cal.data('colpick')
1133
+ .fields.eq(4).val(parseInt(360 * (current.cal.data('colpick').height - (pageY - current.y)) / current.cal.data('colpick').height, 10))
1134
+ .get(0),
1135
+ [current.cal.data('colpick').livePreview]
1136
+ );
1137
+ return false;
1138
+ },
1139
+ moveHue = function (ev) {
1140
+ var pageY = ((ev.type == 'touchmove') ? ev.originalEvent.changedTouches[0].pageY : ev.pageY);
1141
+ change.apply(
1142
+ ev.data.cal.data('colpick')
1143
+ .fields.eq(4).val(parseInt(360 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.y)))) / ev.data.cal.data('colpick').height, 10))
1144
+ .get(0),
1145
+ [ev.data.preview]
1146
+ );
1147
+ return false;
1148
+ },
1149
+ upHue = function (ev) {
1150
+ fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1151
+ fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1152
+ $(document).off('mouseup touchend', upHue);
1153
+ $(document).off('mousemove touchmove', moveHue);
1154
+ return false;
1155
+ },
1156
+ //Color selector functions
1157
+ downSelector = function (ev) {
1158
+ ev.preventDefault ? ev.preventDefault() : ev.returnValue = false;
1159
+ var current = {
1160
+ cal: $(this).parent(),
1161
+ pos: $(this).offset()
1162
+ };
1163
+ current.preview = current.cal.data('colpick').livePreview;
1164
+
1165
+ $(document).on('mouseup touchend', current, upSelector);
1166
+ $(document).on('mousemove touchmove', current, moveSelector);
1167
+
1168
+ var payeX, pageY;
1169
+ if (ev.type == 'touchstart') {
1170
+ pageX = ev.originalEvent.changedTouches[0].pageX,
1171
+ pageY = ev.originalEvent.changedTouches[0].pageY;
1172
+ } else {
1173
+ pageX = ev.pageX;
1174
+ pageY = ev.pageY;
1175
+ }
1176
+
1177
+ change.apply(
1178
+ current.cal.data('colpick').fields
1179
+ .eq(6).val(parseInt(100 * (current.cal.data('colpick').height - (pageY - current.pos.top)) / current.cal.data('colpick').height, 10)).end()
1180
+ .eq(5).val(parseInt(100 * (pageX - current.pos.left) / current.cal.data('colpick').height, 10))
1181
+ .get(0),
1182
+ [current.preview]
1183
+ );
1184
+ return false;
1185
+ },
1186
+ moveSelector = function (ev) {
1187
+ var payeX, pageY;
1188
+ if (ev.type == 'touchmove') {
1189
+ pageX = ev.originalEvent.changedTouches[0].pageX,
1190
+ pageY = ev.originalEvent.changedTouches[0].pageY;
1191
+ } else {
1192
+ pageX = ev.pageX;
1193
+ pageY = ev.pageY;
1194
+ }
1195
+
1196
+ change.apply(
1197
+ ev.data.cal.data('colpick').fields
1198
+ .eq(6).val(parseInt(100 * (ev.data.cal.data('colpick').height - Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageY - ev.data.pos.top)))) / ev.data.cal.data('colpick').height, 10)).end()
1199
+ .eq(5).val(parseInt(100 * (Math.max(0, Math.min(ev.data.cal.data('colpick').height, (pageX - ev.data.pos.left)))) / ev.data.cal.data('colpick').height, 10))
1200
+ .get(0),
1201
+ [ev.data.preview]
1202
+ );
1203
+ return false;
1204
+ },
1205
+ upSelector = function (ev) {
1206
+ fillRGBFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1207
+ fillHexFields(ev.data.cal.data('colpick').color, ev.data.cal.get(0));
1208
+ $(document).off('mouseup touchend', upSelector);
1209
+ $(document).off('mousemove touchmove', moveSelector);
1210
+ return false;
1211
+ },
1212
+ //Submit button
1213
+ clickSubmit = function (ev) {
1214
+ var cal = $(this).parent();
1215
+ var col = cal.data('colpick').color;
1216
+ cal.data('colpick').origColor = col;
1217
+ setCurrentColor(col, cal.get(0));
1218
+ cal.data('colpick').onSubmit(col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el);
1219
+ },
1220
+ //Show/hide the color picker
1221
+ show = function (ev) {
1222
+ // Prevent the trigger of any direct parent
1223
+ ev.stopPropagation();
1224
+ var cal = $('#' + $(this).data('colpickId'));
1225
+ cal.data('colpick').onBeforeShow.apply(this, [cal.get(0)]);
1226
+ var pos = $(this).offset();
1227
+ var top = pos.top + this.offsetHeight;
1228
+ var left = pos.left;
1229
+ var viewPort = getViewport();
1230
+ var calW = cal.width();
1231
+ if (left + calW > viewPort.l + viewPort.w) {
1232
+ left -= calW;
1233
+ }
1234
+ cal.css({left: left + 'px', top: top + 'px'});
1235
+ if (cal.data('colpick').onShow.apply(this, [cal.get(0)]) != false) {
1236
+ cal.show();
1237
+ }
1238
+ //Hide when user clicks outside
1239
+ $('html').mousedown({cal: cal}, hide);
1240
+ cal.mousedown(function (ev) {
1241
+ ev.stopPropagation();
1242
+ })
1243
+ },
1244
+ hide = function (ev) {
1245
+ if (ev.data.cal.data('colpick').onHide.apply(this, [ev.data.cal.get(0)]) != false) {
1246
+ ev.data.cal.hide();
1247
+ }
1248
+ $('html').off('mousedown', hide);
1249
+ },
1250
+ getViewport = function () {
1251
+ var m = document.compatMode == 'CSS1Compat';
1252
+ return {
1253
+ l: window.pageXOffset || (m ? document.documentElement.scrollLeft : document.body.scrollLeft),
1254
+ w: window.innerWidth || (m ? document.documentElement.clientWidth : document.body.clientWidth)
1255
+ };
1256
+ },
1257
+ //Fix the values if the user enters a negative or high value
1258
+ fixHSB = function (hsb) {
1259
+ return {
1260
+ h: Math.min(360, Math.max(0, hsb.h)),
1261
+ s: Math.min(100, Math.max(0, hsb.s)),
1262
+ b: Math.min(100, Math.max(0, hsb.b))
1263
+ };
1264
+ },
1265
+ fixRGB = function (rgb) {
1266
+ return {
1267
+ r: Math.min(255, Math.max(0, rgb.r)),
1268
+ g: Math.min(255, Math.max(0, rgb.g)),
1269
+ b: Math.min(255, Math.max(0, rgb.b))
1270
+ };
1271
+ },
1272
+ fixHex = function (hex) {
1273
+ var len = 6 - hex.length;
1274
+ if (len > 0) {
1275
+ var o = [];
1276
+ for (var i = 0; i < len; i++) {
1277
+ o.push('0');
1278
+ }
1279
+ o.push(hex);
1280
+ hex = o.join('');
1281
+ }
1282
+ return hex;
1283
+ },
1284
+ restoreOriginal = function () {
1285
+ var cal = $(this).parent();
1286
+ var col = cal.data('colpick').origColor;
1287
+ cal.data('colpick').color = col;
1288
+ fillRGBFields(col, cal.get(0));
1289
+ fillHexFields(col, cal.get(0));
1290
+ fillHSBFields(col, cal.get(0));
1291
+ setSelector(col, cal.get(0));
1292
+ setHue(col, cal.get(0));
1293
+ setNewColor(col, cal.get(0));
1294
+ };
1295
+ return {
1296
+ init: function (opt) {
1297
+ opt = $.extend({}, defaults, opt || {});
1298
+ //Set color
1299
+ if (typeof opt.color == 'string') {
1300
+ opt.color = hexToHsb(opt.color);
1301
+ } else if (opt.color.r != undefined && opt.color.g != undefined && opt.color.b != undefined) {
1302
+ opt.color = rgbToHsb(opt.color);
1303
+ } else if (opt.color.h != undefined && opt.color.s != undefined && opt.color.b != undefined) {
1304
+ opt.color = fixHSB(opt.color);
1305
+ } else {
1306
+ return this;
1307
+ }
1308
+
1309
+ //For each selected DOM element
1310
+ return this.each(function () {
1311
+ //If the element does not have an ID
1312
+ if (!$(this).data('colpickId')) {
1313
+ var options = $.extend({}, opt);
1314
+ options.origColor = opt.color;
1315
+ //Generate and assign a random ID
1316
+ var id = 'collorpicker_' + parseInt(Math.random() * 1000);
1317
+ $(this).data('colpickId', id);
1318
+ //Set the tpl's ID and get the HTML
1319
+ var cal = $(tpl).attr('id', id);
1320
+ //Add class according to layout
1321
+ cal.addClass('colpick_' + options.layout + (options.submit ? '' : ' colpick_' + options.layout + '_ns'));
1322
+ //Add class if the color scheme is not default
1323
+ if (options.colorScheme != 'light') {
1324
+ cal.addClass('colpick_' + options.colorScheme);
1325
+ }
1326
+ //Setup submit button
1327
+ cal.find('div.colpick_submit').html(options.submitText).click(clickSubmit);
1328
+ //Setup input fields
1329
+ options.fields = cal.find('input').change(change).blur(blur).focus(focus);
1330
+ cal.find('div.colpick_field_arrs').mousedown(downIncrement).end().find('div.colpick_current_color').click(restoreOriginal);
1331
+ //Setup hue selector
1332
+ options.selector = cal.find('div.colpick_color').on('mousedown touchstart', downSelector);
1333
+ options.selectorIndic = options.selector.find('div.colpick_selector_outer');
1334
+ //Store parts of the plugin
1335
+ options.el = this;
1336
+ options.hue = cal.find('div.colpick_hue_arrs');
1337
+ huebar = options.hue.parent();
1338
+ //Paint the hue bar
1339
+ var UA = navigator.userAgent.toLowerCase();
1340
+ var isIE = navigator.appName === 'Microsoft Internet Explorer';
1341
+ var IEver = isIE ? parseFloat(UA.match(/msie ([0-9]{1,}[\.0-9]{0,})/)[1]) : 0;
1342
+ var ngIE = (isIE && IEver < 10);
1343
+ var stops = ['#ff0000', '#ff0080', '#ff00ff', '#8000ff', '#0000ff', '#0080ff', '#00ffff', '#00ff80', '#00ff00', '#80ff00', '#ffff00', '#ff8000', '#ff0000'];
1344
+ if (ngIE) {
1345
+ var i, div;
1346
+ for (i = 0; i <= 11; i++) {
1347
+ div = $('<div></div>').attr('style', 'height:8.333333%; filter:progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + '); -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=' + stops[i] + ', endColorstr=' + stops[i + 1] + ')";');
1348
+ huebar.append(div);
1349
+ }
1350
+ } else {
1351
+ stopList = stops.join(',');
1352
+ huebar.attr('style', 'background:-webkit-linear-gradient(top,' + stopList + '); background: -o-linear-gradient(top,' + stopList + '); background: -ms-linear-gradient(top,' + stopList + '); background:-moz-linear-gradient(top,' + stopList + '); -webkit-linear-gradient(top,' + stopList + '); background:linear-gradient(to bottom,' + stopList + '); ');
1353
+ }
1354
+ cal.find('div.colpick_hue').on('mousedown touchstart', downHue);
1355
+ options.newColor = cal.find('div.colpick_new_color');
1356
+ options.currentColor = cal.find('div.colpick_current_color');
1357
+ //Store options and fill with default color
1358
+ cal.data('colpick', options);
1359
+ fillRGBFields(options.color, cal.get(0));
1360
+ fillHSBFields(options.color, cal.get(0));
1361
+ fillHexFields(options.color, cal.get(0));
1362
+ setHue(options.color, cal.get(0));
1363
+ setSelector(options.color, cal.get(0));
1364
+ setCurrentColor(options.color, cal.get(0));
1365
+ setNewColor(options.color, cal.get(0));
1366
+ //Append to body if flat=false, else show in place
1367
+ if (options.flat) {
1368
+ cal.appendTo(this).show();
1369
+ cal.css({
1370
+ position: 'relative',
1371
+ display: 'block'
1372
+ });
1373
+ } else {
1374
+ cal.appendTo(document.body);
1375
+ $(this).on(options.showEvent, show);
1376
+ cal.css({
1377
+ position: 'absolute'
1378
+ });
1379
+ }
1380
+ }
1381
+ });
1382
+ },
1383
+ //Shows the picker
1384
+ showPicker: function () {
1385
+ return this.each(function () {
1386
+ if ($(this).data('colpickId')) {
1387
+ show.apply(this);
1388
+ }
1389
+ });
1390
+ },
1391
+ //Hides the picker
1392
+ hidePicker: function () {
1393
+ return this.each(function () {
1394
+ if ($(this).data('colpickId')) {
1395
+ $('#' + $(this).data('colpickId')).hide();
1396
+ }
1397
+ });
1398
+ },
1399
+ //Sets a color as new and current (default)
1400
+ setColor: function (col, setCurrent) {
1401
+ setCurrent = (typeof setCurrent === "undefined") ? 1 : setCurrent;
1402
+ if (typeof col == 'string') {
1403
+ col = hexToHsb(col);
1404
+ } else if (col.r != undefined && col.g != undefined && col.b != undefined) {
1405
+ col = rgbToHsb(col);
1406
+ } else if (col.h != undefined && col.s != undefined && col.b != undefined) {
1407
+ col = fixHSB(col);
1408
+ } else {
1409
+ return this;
1410
+ }
1411
+ return this.each(function () {
1412
+ if ($(this).data('colpickId')) {
1413
+ var cal = $('#' + $(this).data('colpickId'));
1414
+ cal.data('colpick').color = col;
1415
+ cal.data('colpick').origColor = col;
1416
+ fillRGBFields(col, cal.get(0));
1417
+ fillHSBFields(col, cal.get(0));
1418
+ fillHexFields(col, cal.get(0));
1419
+ setHue(col, cal.get(0));
1420
+ setSelector(col, cal.get(0));
1421
+
1422
+ setNewColor(col, cal.get(0));
1423
+ cal.data('colpick').onChange.apply(cal.parent(), [col, hsbToHex(col), hsbToRgb(col), cal.data('colpick').el, 1]);
1424
+ if (setCurrent) {
1425
+ setCurrentColor(col, cal.get(0));
1426
+ }
1427
+ }
1428
+ });
1429
+ }
1430
+ };
1431
+ }();
1432
+ //Color space convertions
1433
+ var hexToRgb = function (hex) {
1434
+ var hex = parseInt(((hex.indexOf('#') > -1) ? hex.substring(1) : hex), 16);
1435
+ return {r: hex >> 16, g: (hex & 0x00FF00) >> 8, b: (hex & 0x0000FF)};
1436
+ };
1437
+ var hexToHsb = function (hex) {
1438
+ return rgbToHsb(hexToRgb(hex));
1439
+ };
1440
+ var rgbToHsb = function (rgb) {
1441
+ var hsb = {h: 0, s: 0, b: 0};
1442
+ var min = Math.min(rgb.r, rgb.g, rgb.b);
1443
+ var max = Math.max(rgb.r, rgb.g, rgb.b);
1444
+ var delta = max - min;
1445
+ hsb.b = max;
1446
+ hsb.s = max != 0 ? 255 * delta / max : 0;
1447
+ if (hsb.s != 0) {
1448
+ if (rgb.r == max)
1449
+ hsb.h = (rgb.g - rgb.b) / delta;
1450
+ else if (rgb.g == max)
1451
+ hsb.h = 2 + (rgb.b - rgb.r) / delta;
1452
+ else
1453
+ hsb.h = 4 + (rgb.r - rgb.g) / delta;
1454
+ } else
1455
+ hsb.h = -1;
1456
+ hsb.h *= 60;
1457
+ if (hsb.h < 0)
1458
+ hsb.h += 360;
1459
+ hsb.s *= 100 / 255;
1460
+ hsb.b *= 100 / 255;
1461
+ return hsb;
1462
+ };
1463
+ var hsbToRgb = function (hsb) {
1464
+ var rgb = {};
1465
+ var h = hsb.h;
1466
+ var s = hsb.s * 255 / 100;
1467
+ var v = hsb.b * 255 / 100;
1468
+ if (s == 0) {
1469
+ rgb.r = rgb.g = rgb.b = v;
1470
+ } else {
1471
+ var t1 = v;
1472
+ var t2 = (255 - s) * v / 255;
1473
+ var t3 = (t1 - t2) * (h % 60) / 60;
1474
+ if (h == 360)
1475
+ h = 0;
1476
+ if (h < 60) {
1477
+ rgb.r = t1;
1478
+ rgb.b = t2;
1479
+ rgb.g = t2 + t3
1480
+ } else if (h < 120) {
1481
+ rgb.g = t1;
1482
+ rgb.b = t2;
1483
+ rgb.r = t1 - t3
1484
+ } else if (h < 180) {
1485
+ rgb.g = t1;
1486
+ rgb.r = t2;
1487
+ rgb.b = t2 + t3
1488
+ } else if (h < 240) {
1489
+ rgb.b = t1;
1490
+ rgb.r = t2;
1491
+ rgb.g = t1 - t3
1492
+ } else if (h < 300) {
1493
+ rgb.b = t1;
1494
+ rgb.g = t2;
1495
+ rgb.r = t2 + t3
1496
+ } else if (h < 360) {
1497
+ rgb.r = t1;
1498
+ rgb.g = t2;
1499
+ rgb.b = t1 - t3
1500
+ } else {
1501
+ rgb.r = 0;
1502
+ rgb.g = 0;
1503
+ rgb.b = 0
1504
+ }
1505
+ }
1506
+ return {r: Math.round(rgb.r), g: Math.round(rgb.g), b: Math.round(rgb.b)};
1507
+ };
1508
+ var rgbToHex = function (rgb) {
1509
+ var hex = [
1510
+ rgb.r.toString(16),
1511
+ rgb.g.toString(16),
1512
+ rgb.b.toString(16)
1513
+ ];
1514
+ $.each(hex, function (nr, val) {
1515
+ if (val.length == 1) {
1516
+ hex[nr] = '0' + val;
1517
+ }
1518
+ });
1519
+ return hex.join('');
1520
+ };
1521
+ var hsbToHex = function (hsb) {
1522
+ return rgbToHex(hsbToRgb(hsb));
1523
+ };
1524
+ $.fn.extend({
1525
+ colpick: colpick.init,
1526
+ colpickHide: colpick.hidePicker,
1527
+ colpickShow: colpick.showPicker,
1528
+ colpickSetColor: colpick.setColor
1529
+ });
1530
+ $.extend({
1531
+ colpick: {
1532
+ rgbToHex: rgbToHex,
1533
+ rgbToHsb: rgbToHsb,
1534
+ hsbToHex: hsbToHex,
1535
+ hsbToRgb: hsbToRgb,
1536
+ hexToHsb: hexToHsb,
1537
+ hexToRgb: hexToRgb
1538
+ }
1539
+ });
1540
+ })(jQuery);
assets/js/quads-plugins-admin.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+
5
+ /**
6
+ * DEACTIVATION FEEDBACK FORM
7
+ */
8
+ // show overlay when clicked on "deactivate"
9
+ quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
10
+ quads_deactivate_link_url = quads_deactivate_link.attr('href');
11
+
12
+ quads_deactivate_link.click(function (e) {
13
+ e.preventDefault();
14
+
15
+ // only show feedback form once per 30 days
16
+ var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
17
+
18
+ if (c_value === undefined) {
19
+ $('#quick-adsense-reloaded-feedback-overlay').show();
20
+ } else {
21
+ // click on the link
22
+ window.location.href = quads_deactivate_link_url;
23
+ }
24
+ });
25
+ // show text fields
26
+ $('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
27
+ // show text field if there is one
28
+ $(this).parents('li').next('li').children('input[type="text"], textarea').show();
29
+ });
30
+ // send form or close it
31
+ $('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
32
+ e.preventDefault();
33
+ // set cookie for 30 days
34
+ var exdate = new Date();
35
+ exdate.setSeconds(exdate.getSeconds() + 2592000);
36
+ document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
37
+
38
+ $('#quick-adsense-reloaded-feedback-overlay').hide();
39
+ if ('quick-adsense-reloaded-feedback-submit' === this.id) {
40
+ // Send form data
41
+ $.ajax({
42
+ type: 'POST',
43
+ url: ajaxurl,
44
+ dataType: 'json',
45
+ data: {
46
+ action: 'quads_send_feedback',
47
+ data: $('#quick-adsense-reloaded-feedback-content form').serialize()
48
+ },
49
+ complete: function (MLHttpRequest, textStatus, errorThrown) {
50
+ // deactivate the plugin and close the popup
51
+ $('#quick-adsense-reloaded-feedback-overlay').remove();
52
+ window.location.href = quads_deactivate_link_url;
53
+
54
+ }
55
+ });
56
+ } else {
57
+ $('#quick-adsense-reloaded-feedback-overlay').remove();
58
+ window.location.href = quads_deactivate_link_url;
59
+ }
60
+ });
61
+ // close form without doing anything
62
+ $('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
63
+ $('#quick-adsense-reloaded-feedback-overlay').hide();
64
+ });
65
+
66
+ function quads_admin_get_cookie (name) {
67
+ var i, x, y, quads_cookies = document.cookie.split( ";" );
68
+ for (i = 0; i < quads_cookies.length; i++)
69
+ {
70
+ x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
71
+ y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
72
+ x = x.replace( /^\s+|\s+$/g, "" );
73
+ if (x === name)
74
+ {
75
+ return unescape( y );
76
+ }
77
+ }
78
+ }
79
+
80
+ }); // document ready
assets/js/quads-plugins-admin.min.js ADDED
@@ -0,0 +1,80 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var strict;
2
+
3
+ jQuery(document).ready(function ($) {
4
+
5
+ /**
6
+ * DEACTIVATION FEEDBACK FORM
7
+ */
8
+ // show overlay when clicked on "deactivate"
9
+ quads_deactivate_link = $('.wp-admin.plugins-php tr[data-slug="quick-adsense-reloaded"] .row-actions .deactivate a');
10
+ quads_deactivate_link_url = quads_deactivate_link.attr('href');
11
+
12
+ quads_deactivate_link.click(function (e) {
13
+ e.preventDefault();
14
+
15
+ // only show feedback form once per 30 days
16
+ var c_value = quads_admin_get_cookie("quads_hide_deactivate_feedback");
17
+
18
+ if (c_value === undefined) {
19
+ $('#quick-adsense-reloaded-feedback-overlay').show();
20
+ } else {
21
+ // click on the link
22
+ window.location.href = quads_deactivate_link_url;
23
+ }
24
+ });
25
+ // show text fields
26
+ $('#quick-adsense-reloaded-feedback-content input[type="radio"]').click(function () {
27
+ // show text field if there is one
28
+ $(this).parents('li').next('li').children('input[type="text"], textarea').show();
29
+ });
30
+ // send form or close it
31
+ $('#quick-adsense-reloaded-feedback-content .button').click(function (e) {
32
+ e.preventDefault();
33
+ // set cookie for 30 days
34
+ var exdate = new Date();
35
+ exdate.setSeconds(exdate.getSeconds() + 2592000);
36
+ document.cookie = "quads_hide_deactivate_feedback=1; expires=" + exdate.toUTCString() + "; path=/";
37
+
38
+ $('#quick-adsense-reloaded-feedback-overlay').hide();
39
+ if ('quick-adsense-reloaded-feedback-submit' === this.id) {
40
+ // Send form data
41
+ $.ajax({
42
+ type: 'POST',
43
+ url: ajaxurl,
44
+ dataType: 'json',
45
+ data: {
46
+ action: 'quads_send_feedback',
47
+ data: $('#quick-adsense-reloaded-feedback-content form').serialize()
48
+ },
49
+ complete: function (MLHttpRequest, textStatus, errorThrown) {
50
+ // deactivate the plugin and close the popup
51
+ $('#quick-adsense-reloaded-feedback-overlay').remove();
52
+ window.location.href = quads_deactivate_link_url;
53
+
54
+ }
55
+ });
56
+ } else {
57
+ $('#quick-adsense-reloaded-feedback-overlay').remove();
58
+ window.location.href = quads_deactivate_link_url;
59
+ }
60
+ });
61
+ // close form without doing anything
62
+ $('.quick-adsense-reloaded-feedback-not-deactivate').click(function (e) {
63
+ $('#quick-adsense-reloaded-feedback-overlay').hide();
64
+ });
65
+
66
+ function quads_admin_get_cookie (name) {
67
+ var i, x, y, quads_cookies = document.cookie.split( ";" );
68
+ for (i = 0; i < quads_cookies.length; i++)
69
+ {
70
+ x = quads_cookies[i].substr( 0, quads_cookies[i].indexOf( "=" ) );
71
+ y = quads_cookies[i].substr( quads_cookies[i].indexOf( "=" ) + 1 );
72
+ x = x.replace( /^\s+|\s+$/g, "" );
73
+ if (x === name)
74
+ {
75
+ return unescape( y );
76
+ }
77
+ }
78
+ }
79
+
80
+ }); // document ready
includes/QUADS_SL_Plugin_Updater.php ADDED
@@ -0,0 +1,338 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // Debug mode - Force plugin update
4
+ //set_site_transient( 'update_plugins', null );
5
+
6
+ /**
7
+ * Allows plugins to use their own update API.
8
+ *
9
+ * @author Pippin Williamson
10
+ * @version 1.6
11
+ */
12
+ class QUADS_SL_Plugin_Updater {
13
+ private $api_url = '';
14
+ private $api_data = array();
15
+ private $name = '';
16
+ private $slug = '';
17
+ private $version = '';
18
+
19
+ /**
20
+ * Class constructor.
21
+ *
22
+ * @uses plugin_basename()
23
+ * @uses hook()
24
+ *
25
+ * @param string $_api_url The URL pointing to the custom API endpoint.
26
+ * @param string $_plugin_file Path to the plugin file.
27
+ * @param array $_api_data Optional data to send with API calls.
28
+ * @return void
29
+ */
30
+ function __construct( $_api_url, $_plugin_file, $_api_data = null ) {
31
+ $this->api_url = trailingslashit( $_api_url );
32
+ $this->api_data = $_api_data;
33
+ $this->name = plugin_basename( $_plugin_file );
34
+ $this->slug = basename( $_plugin_file, '.php' );
35
+ $this->version = $_api_data['version'];
36
+
37
+ // Set up hooks.
38
+ $this->init();
39
+ add_action( 'admin_init', array( $this, 'show_changelog' ) );
40
+ }
41
+
42
+ /**
43
+ * Set up WordPress filters to hook into WP's update process.
44
+ *
45
+ * @uses add_filter()
46
+ *
47
+ * @return void
48
+ */
49
+ public function init() {
50
+
51
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
52
+ add_filter( 'plugins_api', array( $this, 'plugins_api_filter' ), 10, 3 );
53
+
54
+ add_action( 'after_plugin_row_' . $this->name, array( $this, 'show_update_notification' ), 10, 2 );
55
+ }
56
+
57
+ /**
58
+ * Check for Updates at the defined API endpoint and modify the update array.
59
+ *
60
+ * This function dives into the update API just when WordPress creates its update array,
61
+ * then adds a custom API call and injects the custom plugin data retrieved from the API.
62
+ * It is reassembled from parts of the native WordPress plugin update code.
63
+ * See wp-includes/update.php line 121 for the original wp_update_plugins() function.
64
+ *
65
+ * @uses api_request()
66
+ *
67
+ * @param array $_transient_data Update array build by WordPress.
68
+ * @return array Modified update array with custom plugin data.
69
+ */
70
+ function check_update( $_transient_data ) {
71
+
72
+ global $pagenow;
73
+
74
+ if( ! is_object( $_transient_data ) ) {
75
+ $_transient_data = new stdClass;
76
+ }
77
+
78
+ if( 'plugins.php' == $pagenow && is_multisite() ) {
79
+ return $_transient_data;
80
+ }
81
+
82
+ if ( empty( $_transient_data->response ) || empty( $_transient_data->response[ $this->name ] ) ) {
83
+
84
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
85
+
86
+ if ( false !== $version_info && is_object( $version_info ) && isset( $version_info->new_version ) ) {
87
+
88
+ //$this->did_check = true;
89
+
90
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
91
+
92
+ $_transient_data->response[ $this->name ] = $version_info;
93
+
94
+ }
95
+
96
+ $_transient_data->last_checked = time();
97
+ $_transient_data->checked[ $this->name ] = $this->version;
98
+
99
+ }
100
+
101
+ }
102
+
103
+ return $_transient_data;
104
+ }
105
+
106
+ /**
107
+ * show update nofication row -- needed for multisite subsites, because WP won't tell you otherwise!
108
+ *
109
+ * @param string $file
110
+ * @param array $plugin
111
+ */
112
+ public function show_update_notification( $file, $plugin ) {
113
+
114
+ if( ! current_user_can( 'update_plugins' ) ) {
115
+ return;
116
+ }
117
+
118
+ if( ! is_multisite() ) {
119
+ return;
120
+ }
121
+
122
+ if ( $this->name != $file ) {
123
+ return;
124
+ }
125
+
126
+ // Remove our filter on the site transient
127
+ remove_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ), 10 );
128
+
129
+ $update_cache = get_site_transient( 'update_plugins' );
130
+
131
+ if ( ! is_object( $update_cache ) || empty( $update_cache->response ) || empty( $update_cache->response[ $this->name ] ) ) {
132
+
133
+ $cache_key = md5( 'edd_plugin_' .sanitize_key( $this->name ) . '_version_info' );
134
+ $version_info = get_transient( $cache_key );
135
+
136
+ if( false === $version_info ) {
137
+
138
+ $version_info = $this->api_request( 'plugin_latest_version', array( 'slug' => $this->slug ) );
139
+
140
+ set_transient( $cache_key, $version_info, 3600 );
141
+ }
142
+
143
+
144
+ if( ! is_object( $version_info ) ) {
145
+ return;
146
+ }
147
+
148
+ if( version_compare( $this->version, $version_info->new_version, '<' ) ) {
149
+
150
+ $update_cache->response[ $this->name ] = $version_info;
151
+
152
+ }
153
+
154
+ $update_cache->last_checked = time();
155
+ $update_cache->checked[ $this->name ] = $this->version;
156
+
157
+ set_site_transient( 'update_plugins', $update_cache );
158
+
159
+ } else {
160
+
161
+ $version_info = $update_cache->response[ $this->name ];
162
+
163
+ }
164
+
165
+ // Restore our filter
166
+ add_filter( 'pre_set_site_transient_update_plugins', array( $this, 'check_update' ) );
167
+
168
+ if ( ! empty( $update_cache->response[ $this->name ] ) && version_compare( $this->version, $version_info->new_version, '<' ) ) {
169
+
170
+ // build a plugin list row, with update notification
171
+ $wp_list_table = _get_list_table( 'WP_Plugins_List_Table' );
172
+ echo '<tr class="plugin-update-tr"><td colspan="' . $wp_list_table->get_column_count() . '" class="plugin-update colspanchange"><div class="update-message">';
173
+
174
+ $changelog_link = self_admin_url( 'index.php?edd_sl_action=view_plugin_changelog&plugin=' . $this->name . '&slug=' . $this->slug . '&TB_iframe=true&width=772&height=911' );
175
+
176
+ if ( empty( $version_info->download_link ) ) {
177
+ printf(
178
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a>.', 'edd' ),
179
+ esc_html( $version_info->name ),
180
+ esc_url( $changelog_link ),
181
+ esc_html( $version_info->new_version )
182
+ );
183
+ } else {
184
+ printf(
185
+ __( 'There is a new version of %1$s available. <a target="_blank" class="thickbox" href="%2$s">View version %3$s details</a> or <a href="%4$s">update now</a>.', 'edd' ),
186
+ esc_html( $version_info->name ),
187
+ esc_url( $changelog_link ),
188
+ esc_html( $version_info->new_version ),
189
+ esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $this->name, 'upgrade-plugin_' . $this->name ) )
190
+ );
191
+ }
192
+
193
+ echo '</div></td></tr>';
194
+ }
195
+ }
196
+
197
+
198
+ /**
199
+ * Updates information on the "View version x.x details" page with custom data.
200
+ *
201
+ * @uses api_request()
202
+ *
203
+ * @param mixed $_data
204
+ * @param string $_action
205
+ * @param object $_args
206
+ * @return object $_data
207
+ */
208
+ function plugins_api_filter( $_data, $_action = '', $_args = null ) {
209
+
210
+
211
+ if ( $_action != 'plugin_information' ) {
212
+
213
+ return $_data;
214
+
215
+ }
216
+
217
+ if ( ! isset( $_args->slug ) || ( $_args->slug != $this->slug ) ) {
218
+
219
+ return $_data;
220
+
221
+ }
222
+
223
+ $to_send = array(
224
+ 'slug' => $this->slug,
225
+ 'is_ssl' => is_ssl(),
226
+ 'fields' => array(
227
+ 'banners' => false, // These will be supported soon hopefully
228
+ 'reviews' => false
229
+ )
230
+ );
231
+
232
+ $api_response = $this->api_request( 'plugin_information', $to_send );
233
+
234
+ if ( false !== $api_response ) {
235
+ $_data = $api_response;
236
+ }
237
+
238
+ return $_data;
239
+ }
240
+
241
+
242
+ /**
243
+ * Disable SSL verification in order to prevent download update failures
244
+ *
245
+ * @param array $args
246
+ * @param string $url
247
+ * @return object $array
248
+ */
249
+ function http_request_args( $args, $url ) {
250
+ // If it is an https request and we are performing a package download, disable ssl verification
251
+ if ( strpos( $url, 'https://' ) !== false && strpos( $url, 'edd_action=package_download' ) ) {
252
+ $args['sslverify'] = false;
253
+ }
254
+ return $args;
255
+ }
256
+
257
+ /**
258
+ * Calls the API and, if successfull, returns the object delivered by the API.
259
+ *
260
+ * @uses get_bloginfo()
261
+ * @uses wp_remote_post()
262
+ * @uses is_wp_error()
263
+ *
264
+ * @param string $_action The requested action.
265
+ * @param array $_data Parameters for the API action.
266
+ * @return false||object
267
+ */
268
+ private function api_request( $_action, $_data ) {
269
+
270
+ global $wp_version, $edd_options;
271
+
272
+ $data = array_merge( $this->api_data, $_data );
273
+
274
+ if ( $data['slug'] != $this->slug )
275
+ return;
276
+ //if ( empty( $data['license']) && !isset( $edd_options['edd_sl_allow_update_notices'] ) )
277
+ if ( empty( $data['license']) )
278
+ return;
279
+
280
+ if( $this->api_url == home_url() ) {
281
+ return false; // Don't allow a plugin to ping itself
282
+ }
283
+
284
+ $api_params = array(
285
+ 'edd_action' => 'get_version',
286
+ 'license' => $data['license'],
287
+ 'item_name' => isset( $data['item_name'] ) ? $data['item_name'] : false,
288
+ 'item_id' => isset( $data['item_id'] ) ? $data['item_id'] : false,
289
+ 'slug' => $data['slug'],
290
+ 'author' => $data['author'],
291
+ 'url' => home_url()
292
+ );
293
+
294
+ $request = wp_remote_post( $this->api_url, array( 'timeout' => 15, 'sslverify' => false, 'body' => $api_params ) );
295
+
296
+ if ( ! is_wp_error( $request ) ) {
297
+ $request = json_decode( wp_remote_retrieve_body( $request ) );
298
+ }
299
+
300
+ if ( $request && isset( $request->sections ) ) {
301
+ $request->sections = maybe_unserialize( $request->sections );
302
+ } else {
303
+ $request = false;
304
+ }
305
+
306
+ return $request;
307
+ }
308
+
309
+ public function show_changelog() {
310
+
311
+
312
+ if( empty( $_REQUEST['edd_sl_action'] ) || 'view_plugin_changelog' != $_REQUEST['edd_sl_action'] ) {
313
+ return;
314
+ }
315
+
316
+ if( empty( $_REQUEST['plugin'] ) ) {
317
+ return;
318
+ }
319
+
320
+ if( empty( $_REQUEST['slug'] ) ) {
321
+ return;
322
+ }
323
+
324
+ if( ! current_user_can( 'update_plugins' ) ) {
325
+ wp_die( __( 'You do not have permission to install plugin updates', 'edd' ), __( 'Error', 'edd' ), array( 'response' => 403 ) );
326
+ }
327
+
328
+ $response = $this->api_request( 'plugin_latest_version', array( 'slug' => $_REQUEST['slug'] ) );
329
+
330
+ if( $response && isset( $response->sections['changelog'] ) ) {
331
+ echo '<div style="background:#fff;padding:10px;">' . $response->sections['changelog'] . '</div>';
332
+ }
333
+
334
+
335
+ exit;
336
+ }
337
+
338
+ }
includes/admin/add-ons.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Add-ons
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Add-ons
7
+ * @copyright Copyright (c) 2015, Rene Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.1.8
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Add-ons
17
+ *
18
+ * Renders the add-ons content.
19
+ *
20
+ * @since 1.1.8
21
+ * @return void
22
+ */
23
+ function quads_add_ons_page() {
24
+ ob_start(); ?>
25
+ <div class="wrap_" id="quads-add-ons">
26
+ <h2 class="quads-h1">WP QUADS Premium Integrations: </h2>
27
+ <div style="border: 2px solid white;padding: 20px;margin-bottom:20px;">
28
+ <h2 class="quads-h2">
29
+ <span class="quads-heading-pro"><?php _e( 'WP QUADS PRO', 'quick-adsense-reloaded' ); ?></span><?php _e( ', save time and earn more with next level AdSense integration!', 'quick-adsense-reloaded' ); ?>
30
+ </h2>
31
+ <h2 style="display:none;"><?php _e( 'Mobile and Responsive AdSense Support ', 'quick-adsense-reloaded' ); ?></h2>
32
+ <li><strong>Responsive Ads</strong> - <?php _e('individual AdSense sizes for Desktop, Phone and Tablet devices.','quick-adsense-reloaded' ); ?></li>
33
+ <li><strong>Visibility Conditionals</strong> - <?php _e('select if AdSense is visible on mobile, tablet or desktop', 'quick-adsense-reloaded' ); ?></li>
34
+ <li><strong>Automatic Mode</strong> - <?php _e('let the plugin detect optimal ad size on all devices.', 'quick-adsense-reloaded' ); ?></li>
35
+ <li><strong>High Performance</strong> - <?php _e('this plugin keeps the speed of your site', 'quick-adsense-reloaded' ); ?></li>
36
+ <a href="http://wpquads.com/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-quads-pro&utm_campaign=wpquads" target="_blank" class="quads-button green">Buy WP QUADS Pro</a>
37
+ <a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_self" style="margin-left:30px;">Skip - Go to Settings</a>
38
+ <div class="quads-footer"> <?php _e('Comes with our 30-day no questions asked money back guarantee','quick-adsense-reloaded'); ?></div>
39
+ </div>
40
+ <div style="float:left;width:50%;border: 2px solid white;padding: 20px;display:none;">
41
+ <h2>
42
+ <?php _e( 'Clickfraud Monitor Integration', 'quick-adsense-reloaded' ); ?>
43
+ <!--&nbsp;&mdash;&nbsp;<a href="https://www.quadsshare.net" class="button-primary" title="<?php _e( 'Visit Website', 'quick-adsense-reloaded' ); ?>" target="_blank"><?php _e( 'See Details', 'quick-adsense-reloaded' ); ?></a>-->
44
+ </h2>
45
+ <h2><?php _e( 'Protect your AdSense Account ', 'quick-adsense-reloaded' ); ?></h2>
46
+ <p><?php _e('Monitor and protect all your advertisements on your site.<br> Click protection for Google AdSense and other pay per click vendors.','quick-adsense-reloaded' ); ?></p>
47
+ <p><?php _e('Fully integrated in WP<strong>QUADS</strong> or completely independant and compatible with <br>any other AdSense Plugin, even with manual inserted ads.', 'quick-adsense-reloaded' ); ?></p>
48
+ <a href="http://demo.clickfraud-monitoring.com/pricing/?utm_source=wpquads&utm_medium=addon_page&utm_term=click-clickfraud&utm_campaign=wpquads" target="_blank" class="button button-primary">See Demo</a>
49
+ <a href="<?php echo admin_url(); ?>admin.php?page=quads-settings" target="_blank" class="button">Maybe later - Go to Settings</a>
50
+
51
+ </div>
52
+ </div>
53
+ <?php
54
+ echo ob_get_clean();
55
+ }
56
+
57
+ /**
58
+ * Add-ons Get Feed
59
+ *
60
+ * Gets the add-ons page feed.
61
+ *
62
+ * @since 0.9.0
63
+ * @return void
64
+ */
65
+ function quads_add_ons_get_feed() {
66
+ if ( false === ( $cache = get_transient( 'quadsshare_add_ons_feed' ) ) ) {
67
+ $feed = wp_remote_get( 'https://www.quadsshare.net/?feed=addons', array( 'sslverify' => false ) );
68
+ if ( ! is_wp_error( $feed ) ) {
69
+ if ( isset( $feed['body'] ) && strlen( $feed['body'] ) > 0 ) {
70
+ $cache = wp_remote_retrieve_body( $feed );
71
+ set_transient( 'quadsshare_add_ons_feed', $cache, 3600 );
72
+ }
73
+ } else {
74
+ $cache = '<div class="error"><p>' . __( 'There was an error retrieving the Quick AdSense Reloaded addon list from the server. Please try again later.', 'quick-adsense-reloaded' ) . '
75
+ <br>Visit instead the Quick AdSense Reloaded Addon Website <a href="https://www.quadsshare.net" class="button-primary" title="Quick AdSense Reloaded Add ons" target="_blank"> Get Add-Ons </a></div>';
76
+ }
77
+ }
78
+ return $cache;
79
+ }
includes/admin/admin-actions.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Actions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Actions
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Processes all QUADS actions sent via POST and GET by looking for the 'quads-action'
17
+ * request and running do_action() to call the function
18
+ *
19
+ * @since 1.0
20
+ * @return void
21
+ */
22
+ function quads_process_actions() {
23
+ if ( isset( $_POST['quads-action'] ) ) {
24
+ do_action( 'quads_' . $_POST['quads-action'], $_POST );
25
+ }
26
+
27
+ if ( isset( $_GET['quads-action'] ) ) {
28
+ do_action( 'quads_' . $_GET['quads-action'], $_GET );
29
+ }
30
+ }
31
+ add_action( 'admin_init', 'quads_process_actions' );
32
+
includes/admin/admin-footer.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Footer
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Footer
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if( !defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Add rating links to the admin dashboard
17
+ *
18
+ * @since 1.0.0
19
+ * @global string $typenow
20
+ * @param string $footer_text The existing footer text
21
+ * @return string
22
+ */
23
+ function quads_admin_rate_us( $footer_text ) {
24
+ global $typenow;
25
+
26
+ if ( quads_is_admin_page() ) {
27
+ $rate_text = sprintf( __( '<strong>Please do us a BIG favor and give us a 5 star rating <a href="%1$s" target="_blank">here</a> . If you`re not happy, please open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
28
+ 'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post',
29
+ 'http://wpquads.com/support/'
30
+ );
31
+ } else {
32
+ return $footer_text;
33
+ }
34
+ }
35
+ add_filter( 'admin_footer_text', 'quads_admin_rate_us' );
includes/admin/admin-notices.php ADDED
@@ -0,0 +1,240 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Notices
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Notices
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0.9
10
+ */
11
+ // Exit if accessed directly
12
+ if( !defined( 'ABSPATH' ) )
13
+ exit;
14
+
15
+ /**
16
+ * Admin Messages
17
+ *
18
+ * @since 2.2.3
19
+ * @global $mashsb_options Array of all the MASHSB Options
20
+ * @return void
21
+ */
22
+ function quads_admin_messages() {
23
+ global $quads_options;
24
+
25
+ if( !current_user_can( 'update_plugins' ) ){
26
+ return;
27
+ }
28
+
29
+ quads_theme_notice();
30
+
31
+ quads_update_notice();
32
+
33
+ //quads_plugin_deactivated_notice();
34
+
35
+ $install_date = get_option( 'quads_install_date' );
36
+ $display_date = date( 'Y-m-d h:i:s' );
37
+ $datetime1 = new DateTime( $install_date );
38
+ $datetime2 = new DateTime( $display_date );
39
+ $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
40
+
41
+
42
+ if( $diff_intrval >= 7 && get_option( 'quads_rating_div' ) == "no" || false === get_option( 'quads_rating_div' ) || quads_rate_again() ) {
43
+ echo '<div class="quads_fivestar updated " style="box-shadow: 0 1px 1px 0 rgba(0,0,0,.1);background-color:white;">
44
+ <p>Awesome, you\'ve been using <strong>WP QUADS</strong> for more than 1 week. <br> May i ask you to give it a <strong>5-star rating</strong> on Wordpress? </br>
45
+ This will help to spread its popularity and to make this plugin a better one.
46
+ <br><br>Your help is much appreciated. Thank you very much,<br> ~René Hermenau
47
+ <ul>
48
+ <li><a href="https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/?filter=5#new-post" class="thankyou" target="_new" title="Ok, you deserved it" style="font-weight:bold;">Ok, you deserved it</a></li>
49
+ <li><a href="javascript:void(0);" class="quadsHideRating" title="I already did" style="font-weight:bold;">I already did</a></li>
50
+ <li><a href="javascript:void(0);" class="quadsHideRating" title="No, not good enough" style="font-weight:bold;">No, not good enough</a></li>
51
+ <br>
52
+ <li><a href="javascript:void(0);" class="quadsHideRatingWeek" title="No, not good enough" style="font-weight:bold;">I want to rate it later. Ask me again in a week!</a></li>
53
+ <li class="spinner" style="float:none;display:list-item;margin:0px;"></li>
54
+ </ul>
55
+
56
+ </div>
57
+ <script>
58
+ jQuery( document ).ready(function( $ ) {
59
+
60
+ jQuery(\'.quadsHideRating\').click(function(){
61
+ jQuery(".spinner").addClass("is-active");
62
+ var data={\'action\':\'quads_hide_rating\'}
63
+ jQuery.ajax({
64
+
65
+ url: "' . admin_url( 'admin-ajax.php' ) . '",
66
+ type: "post",
67
+ data: data,
68
+ dataType: "json",
69
+ async: !0,
70
+ success: function(e) {
71
+ if (e=="success") {
72
+ jQuery(".spinner").removeClass("is-active");
73
+ jQuery(\'.quads_fivestar\').slideUp(\'fast\');
74
+
75
+ }
76
+ }
77
+ });
78
+ })
79
+
80
+ jQuery(\'.quadsHideRatingWeek\').click(function(){
81
+ jQuery(".spinner").addClass("is-active");
82
+ var data={\'action\':\'quads_hide_rating_week\'}
83
+ jQuery.ajax({
84
+
85
+ url: "' . admin_url( 'admin-ajax.php' ) . '",
86
+ type: "post",
87
+ data: data,
88
+ dataType: "json",
89
+ async: !0,
90
+ success: function(e) {
91
+ if (e=="success") {
92
+ jQuery(".spinner").removeClass("is-active");
93
+ jQuery(\'.quads_fivestar\').slideUp(\'fast\');
94
+
95
+ }
96
+ }
97
+ });
98
+ })
99
+
100
+ });
101
+ </script>
102
+ ';
103
+ }
104
+ }
105
+
106
+ add_action( 'admin_notices', 'quads_admin_messages' );
107
+
108
+
109
+ /* Hide the rating div
110
+ *
111
+ * @subpackage Admin/Notices
112
+ * @copyright Copyright (c) 2016, René Hermenau
113
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
114
+ * @since 1.0.9
115
+ *
116
+ * @return json string
117
+ *
118
+ */
119
+
120
+ function quads_hide_rating_div() {
121
+ update_option( 'quads_rating_div', 'yes' );
122
+ delete_option( 'quads_date_next_notice' );
123
+ echo json_encode( array("success") );
124
+ exit;
125
+ }
126
+ add_action( 'wp_ajax_quads_hide_rating', 'quads_hide_rating_div' );
127
+
128
+ /**
129
+ * Write the timestamp when rating notice will be opened again
130
+ */
131
+ function quads_hide_rating_notice_week() {
132
+ $nextweek = time() + (7 * 24 * 60 * 60);
133
+ $human_date = date( 'Y-m-d h:i:s', $nextweek );
134
+ update_option( 'quads_date_next_notice', $human_date );
135
+ update_option( 'quads_rating_div', 'yes' );
136
+ echo json_encode( array("success") );
137
+ exit;
138
+ }
139
+ add_action( 'wp_ajax_quads_hide_rating_week', 'quads_hide_rating_notice_week' );
140
+
141
+ /**
142
+ * Check if admin notice will open again after one week of closing
143
+ * @return boolean
144
+ */
145
+ function quads_rate_again(){
146
+
147
+ $rate_again_date = get_option( 'quads_date_next_notice' );
148
+
149
+ if (false === $rate_again_date){
150
+ return false;
151
+ }
152
+
153
+ $current_date = date( 'Y-m-d h:i:s' );
154
+ $datetime1 = new DateTime( $rate_again_date );
155
+ $datetime2 = new DateTime( $current_date );
156
+ $diff_intrval = round( ($datetime2->format( 'U' ) - $datetime1->format( 'U' )) / (60 * 60 * 24) );
157
+
158
+ if ($diff_intrval >= 0){
159
+ return true;
160
+ }
161
+ }
162
+
163
+
164
+ /**
165
+ * Show a message when pro or free plugin gets disabled
166
+ *
167
+ * @return void
168
+ * @not used
169
+ */
170
+ function quads_plugin_deactivated_notice() {
171
+ if( false !== ( $deactivated_notice_id = get_transient( 'quads_deactivated_notice_id' ) ) ) {
172
+ if( '1' === $deactivated_notice_id ) {
173
+ $message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS.", 'wpstg' );
174
+ } else {
175
+ $message = __( "WP QUADS and WP QUADS Pro cannot be activated both. We've automatically deactivated WP QUADS Pro.", 'wpstg' );
176
+ }
177
+ ?>
178
+ <div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
179
+ <p><?php echo esc_html( $message ); ?></p>
180
+ </div> <?php
181
+ delete_transient( 'quads_deactivated_notice_id' );
182
+ }
183
+ }
184
+
185
+ /**
186
+ * This notice is shown for user of the bimber and bunchy theme
187
+ *
188
+ * Not used at the moment
189
+ */
190
+ function quads_theme_notice(){
191
+
192
+ $show_notice = get_option('quads_show_theme_notice');
193
+
194
+ if( false !== $show_notice && 'no' !== $show_notice ) {
195
+ $message = __( '<strong>Extend the <strong>' . quads_is_commercial_theme(). '</strong> theme with <strong>WP QUADS PRO!</strong> Save time and earn more - Bring your AdSense earnings to next level. <a href="http://wpquads.com?utm_campaign=adminnotice&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank"> Purchase Now</a> or <a href="http://wpquads.com?utm_campaign=free_plugin&utm_source=admin_notice&utm_medium=admin&utm_content=bimber_upgrade_notice" target="_blank">Get Details</a></strong>', 'quick-adsense-reloaded' );
196
+ ?>
197
+ <div class="updated notice is-dismissible" style="border-left: 4px solid #ffba00;">
198
+ <p><?php echo $message; ?></p>
199
+ </div> <?php
200
+ update_option ('quads_show_theme_notice', 'no');
201
+ }
202
+ }
203
+
204
+ /**
205
+ * This notice is shown after updating to 1.3.9
206
+ *
207
+ */
208
+ function quads_update_notice() {
209
+
210
+ $show_notice = get_option( 'quads_show_update_notice' );
211
+
212
+ // do not do anything
213
+ if( false !== $show_notice ) {
214
+ return false;
215
+ }
216
+
217
+ if( (version_compare( QUADS_VERSION, '1.3.9', '>=' ) ) && quads_is_advanced() && (version_compare( QUADS_PRO_VERSION, '1.3.0', '<' ) ) ) {
218
+ $message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': <strong> Update WP QUADS PRO to get custom post type support from <a href="%s">General Settings</a>.', 'quick-adsense-reloaded' ), admin_url() . 'admin.php?page=quads-settings' );
219
+ $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
220
+ ?>
221
+ <div class="updated notice" style="border-left: 4px solid #ffba00;">
222
+ <p><?php echo $message; ?></p>
223
+ </div> <?php
224
+ //update_option ('quads_show_update_notice', 'no');
225
+ } else
226
+ if( !quads_is_advanced() ) {
227
+ $message = sprintf( __( '<strong>WP QUADS ' . QUADS_VERSION . ': <strong> Install <a href="%1s" target="_blank">WP QUADS PRO</a> to get custom post type support from <a href="%2s">General Settings</a>.', 'quick-adsense-reloaded' ), 'http://wpquads.com?utm_campaign=admin_notice&utm_source=admin_notice&utm_medium=admin&utm_content=custom_post_type', admin_url() . 'admin.php?page=quads-settings' );
228
+ $message .= '<br><br><a href="' . admin_url() . 'admin.php?page=quads-settings&quads-action=hide_update_notice" class="button-primary thankyou" target="_self" title="Close Notice" style="font-weight:bold;">Close Notice</a>';
229
+ ?>
230
+ <div class="updated notice" style="border-left: 4px solid #ffba00;">
231
+ <p><?php echo $message; ?></p>
232
+ </div>
233
+ <?php
234
+ }
235
+ }
236
+
237
+ function quads_hide_notice(){
238
+ update_option ('quads_show_update_notice', 'no');
239
+ }
240
+ add_action('quads_hide_update_notice', 'quads_hide_notice', 10);
includes/admin/admin-pages.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Pages
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Pages
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 2.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Creates the admin submenu pages under the Quick AdSense Reloaded menu and assigns their
17
+ * links to global variables
18
+ *
19
+ * @since 1.0
20
+ * @global $quads_settings_page
21
+ * @global $quads_add_ons_page
22
+ * @return void
23
+ */
24
+ function quads_add_options_link() {
25
+ global $quads_options, $quads_parent_page, $quads_add_ons_page, $quads_add_ons_page2, $quads_settings_page;
26
+
27
+ $label = quads_is_advanced() ? 'WP QUADS PRO' : 'WP QUADS';
28
+
29
+ $create_settings = isset($quads_options['create_settings']) ? true : false;
30
+ if ($create_settings){
31
+ $quads_settings_page = add_submenu_page( 'options-general.php', __( 'WP QUADS Settings', 'quick-adsense-reloaded' ), __( 'WPQUADS', 'quick-adsense-reloaded' ), 'manage_options', 'quads-settings', 'quads_options_page' );
32
+ }else{
33
+ $quads_parent_page = add_menu_page( 'Quick AdSense Reloaded Settings', $label, 'manage_options', 'quads-settings', 'quads_options_page' );
34
+ //if (quads_is_installed_clickfraud() ){
35
+ //$quads_add_ons_page = add_submenu_page('quads-settings', __('Click Fraud Monitor'), __('Click Fraud Monitor'), 'manage_options', 'cfmonitor-config', 'cfmonitor_conf');
36
+ //} else {
37
+ $quads_add_ons_page = add_submenu_page( 'quads-settings', __( 'Get Add-On', 'quick-adsense-reloaded' ), 'Get WP QUADS PRO', 'manage_options', 'quads-addons', 'quads_add_ons_page' );
38
+ }
39
+ }
40
+ add_action( 'admin_menu', 'quads_add_options_link', 10 );
41
+
42
+ /**
43
+ * Determines whether the current admin page is an QUADS admin page.
44
+ *
45
+ * Only works after the `wp_loaded` hook, & most effective
46
+ * starting on `admin_menu` hook.
47
+ *
48
+ * @since 1.9.6
49
+ * @return bool True if QUADS admin page.
50
+ */
51
+ function quads_is_admin_page() {
52
+ $currentpage = isset($_GET['page']) ? $_GET['page'] : '';
53
+ if ( ! is_admin() || ! did_action( 'wp_loaded' ) ) {
54
+ return false;
55
+ }
56
+
57
+ global $quads_parent_page, $pagenow, $typenow, $quads_settings_page, $quads_add_ons_page, $quads_tools_page;
58
+
59
+ if ( 'quads-settings' == $currentpage || 'quads-addons' == $currentpage || 'quads-tools' == $currentpage) {
60
+ return true;
61
+ }
62
+
63
+
64
+ }
includes/admin/plugins.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Plugins
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Plugins
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 2.0
10
+ */
11
+
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) ) exit;
15
+
16
+
17
+ /**
18
+ * Plugins row action links
19
+ *
20
+ * @author Michael Cannon <mc@aihr.us>
21
+ * @since 2.0
22
+ * @param array $links already defined action links
23
+ * @param string $file plugin file path and name being processed
24
+ * @return array $links
25
+ */
26
+ function quads_plugin_action_links( $links, $file ) {
27
+ $settings_link = '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'General Settings', 'quick-adsense-reloaded' ) . '</a>';
28
+
29
+ if ( $file == 'quick-adsense-reloaded/quick-adsense-reloaded.php' || $file == 'quads-pro/wpquads-pro.php' ){
30
+ array_unshift( $links, $settings_link );
31
+ }
32
+
33
+ return $links;
34
+ }
35
+ add_filter( 'plugin_action_links', 'quads_plugin_action_links', 10, 2 );
36
+
37
+
38
+
39
+ /**
40
+ * Plugin row meta links
41
+ *
42
+ * @author Michael Cannon <mc@aihr.us>
43
+ * @since 0.0.9
44
+ * @param array $input already defined meta links
45
+ * @param string $file plugin file path and name being processed
46
+ * @return array $input
47
+ */
48
+ //function quads_plugin_row_meta( $input, $file ) {
49
+ // if ( $file != 'quick-adsense-reloaded/quick-adsense-reloaded.php' && $file != 'quads-pro/wpquads-pro.php' ){
50
+ // return $input;
51
+ // }
52
+ //
53
+ // $links = array(
54
+ // '<a href="' . admin_url( 'options-general.php?page=quads-settings' ) . '">' . esc_html__( 'Getting Started', 'quick-adsense-reloaded' ) . '</a>',
55
+ // );
56
+ //
57
+ //
58
+ // $input = array_merge( $input, $links );
59
+ //
60
+ // return $input;
61
+ //}
62
+ //add_filter( 'plugin_row_meta', 'quads_plugin_row_meta', 10, 2 );
includes/admin/settings/contextual-help.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Contextual Help
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Settings
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 0.9.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * Settings contextual help.
17
+ *
18
+ * @access private
19
+ * @since 1.0
20
+ * @return void
21
+ */
22
+ function quads_settings_contextual_help() {
23
+ $screen = get_current_screen();
24
+
25
+ /*if ( $screen->id != 'quads-settings' )
26
+ return;
27
+ */
28
+ $screen->set_help_sidebar(
29
+ '<p><strong>' . $screen->id . sprintf( __( 'For more information:', 'quick-adsense-reloaded' ) . '</strong></p>' .
30
+ '<p>' . sprintf( __( 'Visit the <a href="%s">documentation</a> on the Quick AdSense Reloaded website.', 'quick-adsense-reloaded' ), esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ) ) ) . '</p>' .
31
+ '<p>' . sprintf(
32
+ __( '<a href="%s">Post an issue</a> on <a href="%s">Quick AdSense Reloaded</a>. View <a href="%s">extensions</a>.', 'quick-adsense-reloaded' ),
33
+ esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
34
+ esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' ),
35
+ esc_url( 'https://wordpress.org/plugins/quick-adsense-reloaded' )
36
+ ) . '</p>'
37
+ );
38
+
39
+ $screen->add_help_tab( array(
40
+ 'id' => 'quads-settings-general',
41
+ 'title' => __( 'General', 'quick-adsense-reloaded' ),
42
+ 'content' => '<p>' . __( 'This screen provides the most basic settings for configuring Quick AdSense Reloaded.', 'quick-adsense-reloaded' ) . '</p>'
43
+ ) );
44
+
45
+
46
+
47
+
48
+ do_action( 'quads_settings_contextual_help', $screen );
49
+ }
50
+ add_action( 'load-quads-settings', 'quads_settings_contextual_help' );
includes/admin/settings/display-settings.php ADDED
@@ -0,0 +1,339 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Admin Options Page
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Settings
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /* Returns list elements for jQuery tab navigation
16
+ * based on header callback
17
+ *
18
+ * @since 2.1.2
19
+ * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be much faster?
20
+ * @return string
21
+ */
22
+
23
+ function quads_get_tab_header($page, $section){
24
+ global $quads_options;
25
+ global $wp_settings_fields;
26
+
27
+ if (!isset($wp_settings_fields[$page][$section]))
28
+ return;
29
+
30
+ echo '<ul>';
31
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
32
+ $sanitizedID = str_replace('[', '', $field['id'] );
33
+ $sanitizedID = str_replace(']', '', $sanitizedID );
34
+ if ( strpos($field['callback'],'header') !== false && !quads_is_excluded(array('help', 'licenses') ) ) {
35
+ echo '<li class="quads-tabs"><a href="#' . $sanitizedID . '">' . $field['title'] .'</a></li>';
36
+ }
37
+ }
38
+ echo '</ul>';
39
+ }
40
+
41
+ /**
42
+ * Check if current page is excluded
43
+ *
44
+ * @param array $pages
45
+ * @return boolean
46
+ */
47
+ function quads_is_excluded($pages){
48
+ if (isset($_GET['tab'])){
49
+ $currentpage = $_GET['tab'];
50
+ if (isset($currentpage) && in_array($currentpage, $pages))
51
+ return true;
52
+ }
53
+ }
54
+
55
+ /**
56
+ * Print out the settings fields for a particular settings section
57
+ *
58
+ * Part of the Settings API. Use this in a settings page to output
59
+ * a specific section. Should normally be called by do_settings_sections()
60
+ * rather than directly.
61
+ *
62
+ * @global $wp_settings_fields Storage array of settings fields and their pages/sections
63
+ * @return string
64
+ *
65
+ * @since 2.1.2
66
+ *
67
+ * @param string $page Slug title of the admin page who's settings fields you want to show.
68
+ * @param section $section Slug title of the settings section who's fields you want to show.
69
+ *
70
+ * Copied from WP Core 4.0 /wp-admin/includes/template.php do_settings_fields()
71
+ * We use our own function to be able to create jQuery tabs with easytabs()
72
+ *
73
+ * We dont use tables here any longer. Are we stuck in the nineties?
74
+ * @todo Use sprintf to sanitize $field['id'] instead using str_replace() Should be faster?
75
+ * @todo some media queries for better responisbility
76
+ */
77
+ function quads_do_settings_fields($page, $section) {
78
+ global $wp_settings_fields;
79
+ $header = false;
80
+ $firstHeader = false;
81
+
82
+ if (!isset($wp_settings_fields[$page][$section]))
83
+ return;
84
+
85
+ // Check first if any callback header registered
86
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
87
+ strpos($field['callback'],'header') !== false ? $header = true : $header = false;
88
+
89
+ if ($header === true)
90
+ break;
91
+ }
92
+
93
+ foreach ((array) $wp_settings_fields[$page][$section] as $field) {
94
+
95
+ $sanitizedID = str_replace('[', '', $field['id'] );
96
+ $sanitizedID = str_replace(']', '', $sanitizedID );
97
+
98
+ // Check if header has been created previously
99
+ if (strpos($field['callback'],'header') !== false && $firstHeader === false) {
100
+
101
+ echo '<div id="' . $sanitizedID . '">';
102
+ echo '<table class="quads-form-table"><tbody>';
103
+ $firstHeader = true;
104
+
105
+ } elseif (strpos($field['callback'],'header') !== false && $firstHeader === true) {
106
+ // Header has been created previously so we have to close the first opened div
107
+ echo '</table></div><div id="' . $sanitizedID . '">';
108
+ echo '<table class="quads-form-table"><tbody>';
109
+ }
110
+
111
+ if (!empty($field['args']['label_for']) && !quads_is_excluded_title( $field['args']['id'] )){
112
+ echo '<tr class="row">';
113
+ echo '<td class="row th">';
114
+ echo '<label for="' . esc_attr($field['args']['label_for']) . '">' . $field['title'] . '</label>';
115
+ echo '</td></tr>';
116
+ }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) && !empty($field['args']['helper-desc'])){
117
+ echo '<tr class="row">';
118
+ echo '<td class="row th">';
119
+ echo '<div class="col-title">' . $field['title'] . '<a class="quads-general-helper" href="#"></a><div class="quads-message">' . $field['args']['helper-desc']. '</div></div>';
120
+ echo '</td></tr>';
121
+ }else if (!empty($field['title']) && !quads_is_excluded_title( $field['args']['id'] ) ){
122
+ echo '<tr class="row">';
123
+ echo '<td class="row th">';
124
+ echo '<div class="col-title">' . $field['title'] . '</div>';
125
+ echo '</td></tr>';
126
+ }
127
+
128
+ else {
129
+ echo '';
130
+ }
131
+
132
+
133
+ echo '<tr><td>';
134
+ call_user_func($field['callback'], $field['args']);
135
+ echo '<tr><td>';
136
+
137
+
138
+
139
+ }
140
+ echo '</tbody></table>';
141
+ if ($header === true){
142
+ echo '</div>';
143
+ }
144
+ }
145
+
146
+ /**
147
+ * If title is one of these entries do not show it
148
+ */
149
+ function quads_is_excluded_title($string){
150
+ $haystack = array('ad1','ad2','ad3','ad4','ad5','ad6','ad7','ad8','ad9','ad10',
151
+ 'ad1_widget',
152
+ 'ad2_widget',
153
+ 'ad3_widget',
154
+ 'ad4_widget',
155
+ 'ad5_widget',
156
+ 'ad6_widget',
157
+ 'ad7_widget',
158
+ 'ad8_widget',
159
+ 'ad9_widget',
160
+ 'ad10_widget'
161
+ );
162
+
163
+ if (in_array($string, $haystack)){
164
+ return true;
165
+ }
166
+ return false;
167
+ }
168
+
169
+ /**
170
+ * Options Page
171
+ *
172
+ * Renders the options page contents.
173
+ *
174
+ * @since 1.0
175
+ * @global $quads_options Array of all the QUADS Options
176
+ * @return void
177
+ */
178
+ function quads_options_page() {
179
+ global $quads_options;
180
+
181
+ $active_tab = isset( $_GET[ 'tab' ] ) && array_key_exists( $_GET['tab'], quads_get_settings_tabs() ) ? $_GET[ 'tab' ] : 'general';
182
+
183
+ ob_start();
184
+ ?>
185
+ <div class="wrap quads_admin">
186
+ <h1 style="text-align:center;"> <?php echo QUADS_NAME . ' ' . QUADS_VERSION; ?></h1>
187
+ <div class="about-text" style="font-weight: 400;line-height: 1.6em;text-align:center;">
188
+ <div class='quads-share-button-container'>
189
+ <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
190
+ <div clas='box'>
191
+ <a href="https://twitter.com/share?url=http://wpquads.com&text=WPQUADS+-+The quickest+and+most+easiest+way+to+integrate+AdSense+into+WordPress+websites+@wpquads" target='_blank'>
192
+ <span class='quads-share'><?php echo __('Shout out a tweet','quick-adsense-reloaded'); ?></span>
193
+ </a>
194
+ </div>
195
+ </div>
196
+ <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
197
+ <div class="box">
198
+ <a href="https://www.facebook.com/sharer/sharer.php?u=http://wpquads.com" target="_blank">
199
+ <span class='quads-share'><?php echo __('Share on Facebook','quick-adsense-reloaded'); ?></span>
200
+ </a>
201
+ </div>
202
+ </div>
203
+ </div>
204
+ </div>
205
+ <h2 class="nav-tab-wrapper">
206
+ <?php
207
+ foreach( quads_get_settings_tabs() as $tab_id => $tab_name ) {
208
+
209
+ $tab_url = esc_url(add_query_arg( array(
210
+ 'settings-updated' => false,
211
+ 'tab' => $tab_id
212
+ ) ));
213
+
214
+ $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
215
+
216
+ echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">';
217
+ echo esc_html( $tab_name );
218
+ echo '</a>';
219
+ }
220
+ ?>
221
+ </h2>
222
+ <div id="quads_tab_container" class="quads_tab_container">
223
+ <?php quads_get_tab_header( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab ); ?>
224
+ <div class="quads-panel-container"> <!-- new //-->
225
+ <form method="post" action="options.php" id="quads_settings">
226
+ <?php
227
+ settings_fields( 'quads_settings' );
228
+ quads_do_settings_fields( 'quads_settings_' . $active_tab, 'quads_settings_' . $active_tab );
229
+ ?>
230
+ <!--</table>-->
231
+
232
+ <?php settings_errors(); ?>
233
+ <?php
234
+ // do not show save button on add-on page
235
+ if ($active_tab !== 'addons'){
236
+ submit_button();
237
+ }
238
+ ?>
239
+ </form>
240
+ <?php
241
+ echo sprintf( __( '<strong>If you like this plugin please do us a BIG favor and give us a 5 star rating <a href="%s" target="_blank">here</a> . If you`re not happy, please open a <a href="%2s" target="_blank">support ticket</a>, so that we can sort it out. Thank you!</strong>', 'quick-adsense-reloaded' ),
242
+ 'https://wordpress.org/support/plugin/quick-adsense-reloaded/reviews/#new-post',
243
+ 'http://wpquads.com/support/'
244
+ );
245
+ ?>
246
+ </div> <!-- new //-->
247
+ <?php quads_get_advertising(); ?>
248
+ </div><!-- #tab_container-->
249
+ <div id="quads-save-result"></div>
250
+ <div class="quads-admin-debug"><?php echo quads_get_debug_messages(); ?></div>
251
+ <?php echo quads_render_adsense_form(); ?>
252
+ </div><!-- .wrap -->
253
+ <?php
254
+ echo ob_get_clean();
255
+ }
256
+
257
+ function quads_get_debug_messages(){
258
+ global $quads_options;
259
+
260
+ if (isset($quads_options['debug_mode'])){
261
+ echo '<pre style="clear:both;">';
262
+ var_dump($quads_options);
263
+ echo '</pre>';
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Render ad and return it when plugin is not pro version
269
+ * @return string
270
+ */
271
+ function quads_get_advertising() {
272
+
273
+ if ( quads_is_advanced() ){
274
+ return '';
275
+ }
276
+ ob_start();
277
+ ?>
278
+ <div class="quads-panel-sidebar" style="float:left;min-width: 301px;margin-left: 1px;margin-top:0px;">
279
+ <a href="http://wpquads.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-quads&utm_campaign=wpquads" target="_blank">
280
+ <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/quads_banner_250x521_buy.png'; ?>">
281
+ </a>
282
+ <br>
283
+ <a style="display:block;" href="http://demo.clickfraud-monitoring.com/?utm_source=wpquads&utm_medium=banner&utm_term=click-cfm&utm_campaign=wpquads" target="_blank">
284
+ <img src="<?php echo QUADS_PLUGIN_URL . '/assets/images/banner_250x296-cfm.png'; ?>">
285
+ </a>
286
+ </div>
287
+ <?php
288
+ echo ob_get_clean();
289
+ }
290
+
291
+ /**
292
+ * Render social buttons
293
+ *
294
+ * @return void
295
+ */
296
+ function quads_render_social(){
297
+ ob_start()?>
298
+
299
+ <div class='quads-share-button-container'>
300
+ <div class='quads-share-button quads-share-button-twitter' data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
301
+ <div clas='box'>
302
+ <a href="https://twitter.com/share?url=https://wordpress.org/plugins/quick-adsense-reloaded&text=Quick%20AdSense%20reloaded%20-%20a%20brand%20new%20fork%20of%20the%20popular%20AdSense%20Plugin%20Quick%20Adsense!" target='_blank'>
303
+ <span class='quads-share'><?php echo __('Tweet','quick-adsense-reloaded'); ?></span>
304
+ </a>
305
+ </div>
306
+ </div>
307
+
308
+ <div class="quads-share-button quads-share-button-facebook" data-share-url="https://wordpress.org/plugins/quick-adsense-reloaded">
309
+ <div class="box">
310
+ <a href="https://www.facebook.com/sharer/sharer.php?u=https://wordpress.org/plugins/quick-adsense-reloaded" target="_blank">
311
+ <span class='quads-share'><?php echo __('Share','quick-adsense-reloaded'); ?></span>
312
+ </a>
313
+ </div>
314
+ </div>
315
+ </div>
316
+
317
+ <?php
318
+ echo ob_get_clean();
319
+ }
320
+
321
+
322
+ /**
323
+ * Render AdSense Form
324
+ */
325
+ function quads_render_adsense_form(){
326
+
327
+ ?>
328
+ <div id="quads-adsense-bg-div" style="display: none;">
329
+ <div id="quads-adsense-container">
330
+ <h3><?php _e( 'Copy ad code from AdSense account and paste it here', 'quick-adsense-reloaded' ); ?></h3>
331
+ <textarea rows="15" cols="55" id="quads-adsense-form"></textarea><hr />
332
+ <button class="button button-primary" id="quads-paste-button"><?php _e( 'Get Code', 'quick-adsense-reloaded' ); ?></button>&nbsp;&nbsp;
333
+ <button class="button button-secondary" id="quads-close-button"><?php _e( 'Close', 'quick-adsense-reloaded' ); ?></button>
334
+ <div id="quads-msg"></div>
335
+ <input type="hidden" id="quads-adsense-id" value="">
336
+ </div>
337
+ </div>
338
+ <?php
339
+ }
includes/admin/settings/register-settings.php ADDED
@@ -0,0 +1,1963 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Register Settings
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Admin/Settings
8
+ * @copyright Copyright (c) 2015, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.0
11
+ */
12
+ // Exit if accessed directly
13
+ if( !defined( 'ABSPATH' ) )
14
+ exit;
15
+
16
+ /**
17
+ * Get an option
18
+ *
19
+ * Looks to see if the specified setting exists, returns default if not
20
+ *
21
+ * @since 1.0.0
22
+ * @return mixed
23
+ */
24
+ function quads_get_option( $key = '', $default = false ) {
25
+ global $quads_options;
26
+ $value = !empty( $quads_options[$key] ) ? $quads_options[$key] : $default;
27
+ $value = apply_filters( 'quads_get_option', $value, $key, $default );
28
+ return apply_filters( 'quads_get_option_' . $key, $value, $key, $default );
29
+ }
30
+
31
+ /**
32
+ * Get Settings
33
+ *
34
+ * Retrieves all plugin settings
35
+ *
36
+ * @since 1.0
37
+ * @return array QUADS settings
38
+ */
39
+ function quads_get_settings() {
40
+ $settings = get_option( 'quads_settings' );
41
+
42
+
43
+ if( empty( $settings ) ) {
44
+ // Update old settings with new single option
45
+ $general_settings = is_array( get_option( 'quads_settings_general' ) ) ? get_option( 'quads_settings_general' ) : array();
46
+ $ext_settings = is_array( get_option( 'quads_settings_extensions' ) ) ? get_option( 'quads_settings_extensions' ) : array();
47
+ $license_settings = is_array( get_option( 'quads_settings_licenses' ) ) ? get_option( 'quads_settings_licenses' ) : array();
48
+ $addons_settings = is_array( get_option( 'quads_settings_addons' ) ) ? get_option( 'quads_settings_addons' ) : array();
49
+ $imexport_settings = is_array( get_option( 'quads_settings_imexport' ) ) ? get_option( 'quads_settings_imexport' ) : array();
50
+ $help_settings = is_array( get_option( 'quads_settings_help' ) ) ? get_option( 'quads_settings_help' ) : array();
51
+
52
+ $settings = array_merge( $general_settings, $ext_settings, $imexport_settings, $help_settings );
53
+
54
+ update_option( 'quads_settings', $settings );
55
+ }
56
+ return apply_filters( 'quads_get_settings', $settings );
57
+ }
58
+
59
+ /**
60
+ * Add all settings sections and fields
61
+ *
62
+ * @since 1.0
63
+ * @return void
64
+ */
65
+ function quads_register_settings() {
66
+
67
+ if( false == get_option( 'quads_settings' ) ) {
68
+ add_option( 'quads_settings' );
69
+ }
70
+
71
+ foreach ( quads_get_registered_settings() as $tab => $settings ) {
72
+
73
+ add_settings_section(
74
+ 'quads_settings_' . $tab, __return_null(), '__return_false', 'quads_settings_' . $tab
75
+ );
76
+
77
+ foreach ( $settings as $option ) {
78
+
79
+ $name = isset( $option['name'] ) ? $option['name'] : '';
80
+
81
+ add_settings_field(
82
+ 'quads_settings[' . $option['id'] . ']', $name, function_exists( 'quads_' . $option['type'] . '_callback' ) ? 'quads_' . $option['type'] . '_callback' : 'quads_missing_callback', 'quads_settings_' . $tab, 'quads_settings_' . $tab, array(
83
+ 'id' => isset( $option['id'] ) ? $option['id'] : null,
84
+ 'desc' => !empty( $option['desc'] ) ? $option['desc'] : '',
85
+ 'desc2' => !empty( $option['desc2'] ) ? $option['desc2'] : '',
86
+ 'helper-desc' => !empty( $option['helper-desc'] ) ? $option['helper-desc'] : '',
87
+ 'name' => isset( $option['name'] ) ? $option['name'] : null,
88
+ 'section' => $tab,
89
+ 'size' => isset( $option['size'] ) ? $option['size'] : null,
90
+ 'options' => isset( $option['options'] ) ? $option['options'] : '',
91
+ 'std' => isset( $option['std'] ) ? $option['std'] : '',
92
+ 'placeholder' => isset( $option['placeholder'] ) ? $option['placeholder'] : '',
93
+ 'textarea_rows' => isset( $option['textarea_rows'] ) ? $option['textarea_rows'] : ''
94
+ )
95
+ );
96
+ }
97
+ }
98
+
99
+ // Store adsense values
100
+ quads_store_adsense_args();
101
+ // Store AdSense value
102
+ //quads_fix_ad_not_shown();
103
+
104
+ // Creates our settings in the options table
105
+ register_setting( 'quads_settings', 'quads_settings', 'quads_settings_sanitize' );
106
+ }
107
+
108
+ add_action( 'admin_init', 'quads_register_settings' );
109
+
110
+ /**
111
+ * Retrieve the array of plugin settings
112
+ *
113
+ * @since 1.8
114
+ * @return array
115
+ */
116
+ function quads_get_registered_settings() {
117
+
118
+ /**
119
+ * 'Whitelisted' QUADS settings, filters are provided for each settings
120
+ * section to allow extensions and other plugins to add their own settings
121
+ */
122
+ $quads_settings = array(
123
+ /** General Settings */
124
+ 'general' => apply_filters( 'quads_settings_general', array(
125
+ array(
126
+ 'id' => 'general_header',
127
+ 'name' => '<strong>' . __( 'General Settings', 'quick-adsense-reloaded' ) . '</strong>',
128
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
129
+ 'type' => 'header'
130
+ ),
131
+ 'maxads' => array(
132
+ 'id' => 'maxads',
133
+ 'name' => __( 'Limit Amount of ads:', 'quick-adsense-reloaded' ),
134
+ 'desc' => __( ' ads on a page.', 'quick-adsense-reloaded' ),
135
+ 'desc2' => sprintf(__( '<a href="%s" target="_blank">Read here</a> to learn how many AdSense ads are allowed. If you are unsure select 3 ads.', 'quick-adsense-reloaded' ), 'http://wpquads.com/google-adsense-allowed-number-ads/'),
136
+ 'type' => 'select',
137
+ 'std' => 3,
138
+ 'options' => array(
139
+ 1 => '1',
140
+ 2 => '2',
141
+ 3 => '3',
142
+ 4 => '4',
143
+ 5 => '5',
144
+ 6 => '6',
145
+ 7 => '7',
146
+ 8 => '8',
147
+ 9 => '9',
148
+ 10 => '10',
149
+ ),
150
+ ),
151
+ array(
152
+ 'id' => 'ad_position',
153
+ 'name' => __( 'Position', 'quick-adsense-reloaded' ),
154
+ 'desc' => __( 'Assign and activate ads on specific ad places', 'quick-adsense-reloaded' ),
155
+ 'type' => 'ad_position'
156
+ ),
157
+ array(
158
+ 'id' => 'visibility',
159
+ 'name' => __( 'Visibility', 'quick-adsense-reloaded' ),
160
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
161
+ 'type' => 'visibility'
162
+ ),
163
+ array(
164
+ "id" => "post_types",
165
+ "name" => __( "Post Types", "quick-adsense-reloaded" ),
166
+ "desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
167
+ "helper-desc" => __( "Select post types where ads are visible.", "quick-adsense-reloaded" ),
168
+ "type" => "multiselect",
169
+ "options" => quads_get_post_types(),
170
+ "placeholder" => __( "Select Post Type", "quick-adsense-reloaded" )
171
+ ),
172
+ array(
173
+ 'id' => 'quicktags',
174
+ 'name' => __( 'Quicktags', 'quick-adsense-reloaded' ),
175
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
176
+ 'type' => 'quicktags'
177
+ ),
178
+ /* 'load_scripts_footer' => array(
179
+ 'id' => 'load_scripts_footer',
180
+ 'name' => __( 'JS Load Order', 'quick-adsense-reloaded' ),
181
+ 'desc' => __( 'Enable this to load all *.js files into footer. Make sure your theme uses the wp_footer() template tag in the appropriate place. Default: Disabled', 'quick-adsense-reloaded' ),
182
+ 'type' => 'checkbox'
183
+ ), */
184
+ 'adsense_header' => array(
185
+ 'id' => 'adsense_header',
186
+ 'name' => '<strong>' . __( 'AdSense Code', 'quick-adsense-reloaded' ) . '</strong>',
187
+ 'desc' => '<div class="adsense_admin_header">' . sprintf( __( 'Paste up to 10 Ad codes on post body and up to 10 Ad codes on sidebar widget. <a href="%s" target="_blank">Read here</a> to find out the most effective AdSense banner sizes. </div>'
188
+ . '<ul style="margin-top:10px;">'
189
+ . '<li> Use option <i>AdSense</i> for unmodified AdSense code</li>'
190
+ . '<li> Use <i>Plain Text / HTML / JS</i> for modified AdSense code with custom css or for none AdSense ads</li></ul>', 'quick-adsense-reloaded' ), 'http://wpquads.com/effective-adsense-banner-size-formats/?utm_campaign=plugin&utm_source=general_tab&utm_medium=admin&utm_content=best_banner_sizes' )
191
+ . '</ul>'
192
+ . '<div id="quads-open-toggle" class="button">'.__('Open All Ads','quick-adsense-reloaded').'</div>',
193
+ 'type' => 'header'
194
+ ),
195
+ array(
196
+ 'id' => 'ad1',
197
+ 'name' => __( 'AD 1', 'quick-adsense-reloaded' ),
198
+ 'desc' => __( 'Shortcode: <strong>[quads id="1"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="1"]\');</strong>', 'quick-adsense-reloaded' ),
199
+ 'type' => 'adsense_code',
200
+ 'options' => quads_get_alignment(),
201
+ ),
202
+ array(
203
+ 'id' => 'ad2',
204
+ 'name' => __( 'AD 2', 'quick-adsense-reloaded' ),
205
+ 'desc' => __( 'Shortcode: <strong>[quads id="2"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="2"]\');</strong>', 'quick-adsense-reloaded' ),
206
+ 'type' => 'adsense_code',
207
+ 'options' => quads_get_alignment(),
208
+ ),
209
+ array(
210
+ 'id' => 'ad3',
211
+ 'name' => __( 'AD 3', 'quick-adsense-reloaded' ),
212
+ 'desc' => __( 'Shortcode: <strong>[quads id="3"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="3"]\');</strong>', 'quick-adsense-reloaded' ),
213
+ 'type' => 'adsense_code',
214
+ 'options' => quads_get_alignment(),
215
+ ),
216
+ array(
217
+ 'id' => 'ad4',
218
+ 'name' => __( 'AD 4', 'quick-adsense-reloaded' ),
219
+ 'desc' => __( 'Shortcode: <strong>[quads id="4"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="4"]\');</strong>', 'quick-adsense-reloaded' ),
220
+ 'type' => 'adsense_code',
221
+ 'options' => quads_get_alignment(),
222
+ ),
223
+ array(
224
+ 'id' => 'ad5',
225
+ 'name' => __( 'AD 5', 'quick-adsense-reloaded' ),
226
+ 'desc' => __( 'Shortcode: <strong>[quads id="5"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="5"]\');</strong>', 'quick-adsense-reloaded' ),
227
+ 'type' => 'adsense_code',
228
+ 'options' => quads_get_alignment(),
229
+ ),
230
+ array(
231
+ 'id' => 'ad6',
232
+ 'name' => __( 'AD 6', 'quick-adsense-reloaded' ),
233
+ 'desc' => __( 'Shortcode: <strong>[quads id="6"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="6"]\');</strong>', 'quick-adsense-reloaded' ),
234
+ 'type' => 'adsense_code',
235
+ 'options' => quads_get_alignment(),
236
+ ),
237
+ array(
238
+ 'id' => 'ad7',
239
+ 'name' => __( 'AD 7', 'quick-adsense-reloaded' ),
240
+ 'desc' => __( 'Shortcode: <strong>[quads id="7"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="7"]\');</strong>', 'quick-adsense-reloaded' ),
241
+ 'type' => 'adsense_code',
242
+ 'options' => quads_get_alignment(),
243
+ ),
244
+ array(
245
+ 'id' => 'ad8',
246
+ 'name' => __( 'AD 8', 'quick-adsense-reloaded' ),
247
+ 'desc' => __( 'Shortcode: <strong>[quads id="8"] </strong></br>PHP: <strong>echo do_shortcode(\'[quads id="8"]\');</strong>', 'quick-adsense-reloaded' ),
248
+ 'type' => 'adsense_code',
249
+ 'options' => quads_get_alignment(),
250
+ ),
251
+ array(
252
+ 'id' => 'ad9',
253
+ 'name' => __( 'AD 9', 'quick-adsense-reloaded' ),
254
+ 'desc' => __( 'Shortcode: <strong>[quads id="9"] </strong></br>Function: <strong>echo do_shortcode(\'[quads id="9"]\');</strong>', 'quick-adsense-reloaded' ),
255
+ 'type' => 'adsense_code',
256
+ 'options' => quads_get_alignment(),
257
+ ),
258
+ array(
259
+ 'id' => 'ad10',
260
+ 'name' => __( 'AD 10', 'quick-adsense-reloaded' ),
261
+ 'desc' => __( 'Shortcode: <strong>[quads id="10"] </strong></br>PHP <strong>echo do_shortcode(\'[quads id="10"]\');</strong>', 'quick-adsense-reloaded' ),
262
+ 'type' => 'adsense_code',
263
+ 'options' => quads_get_alignment(),
264
+ ),
265
+ 'widget_header' => array(
266
+ 'id' => 'widget_header',
267
+ 'name' => '<strong>' . __( 'Widgets Ad Code', 'quick-adsense-reloaded' ) . '</strong>',
268
+ 'desc' => sprintf( __( 'After creating your ads here go to <a href="%s" target="_self">Appearance->Widgets</a> and drag the WP QUADS widget into place.', 'quick-adsense-reloaded' ), admin_url() . 'widgets.php' ),
269
+ 'type' => 'header'
270
+ ),
271
+ 'ad1_widget' => array(
272
+ 'id' => 'ad1_widget',
273
+ 'name' => __( 'Ad widget 1', 'quick-adsense-reloaded' ),
274
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
275
+ 'type' => 'adsense_code',
276
+ 'size' => 4
277
+ ),
278
+ 'ad2_widget' => array(
279
+ 'id' => 'ad2_widget',
280
+ 'name' => __( 'Ad widget 2', 'quick-adsense-reloaded' ),
281
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
282
+ 'type' => 'adsense_code',
283
+ 'size' => 4
284
+ ),
285
+ 'ad3_widget' => array(
286
+ 'id' => 'ad3_widget',
287
+ 'name' => __( 'Ad widget 3', 'quick-adsense-reloaded' ),
288
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
289
+ 'type' => 'adsense_code',
290
+ 'size' => 4
291
+ ),
292
+ 'ad4_widget' => array(
293
+ 'id' => 'ad4_widget',
294
+ 'name' => __( 'Ad widget 4', 'quick-adsense-reloaded' ),
295
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
296
+ 'type' => 'adsense_code',
297
+ 'size' => 4
298
+ ),
299
+ 'ad5_widget' => array(
300
+ 'id' => 'ad5_widget',
301
+ 'name' => __( 'Ad widget 5', 'quick-adsense-reloaded' ),
302
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
303
+ 'type' => 'adsense_code',
304
+ 'size' => 4
305
+ ),
306
+ 'ad6_widget' => array(
307
+ 'id' => 'ad6_widget',
308
+ 'name' => __( 'Ad widget 6', 'quick-adsense-reloaded' ),
309
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
310
+ 'type' => 'adsense_code',
311
+ 'size' => 4
312
+ ),
313
+ 'ad7_widget' => array(
314
+ 'id' => 'ad7_widget',
315
+ 'name' => __( 'Ad widget 7', 'quick-adsense-reloaded' ),
316
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
317
+ 'type' => 'adsense_code',
318
+ 'size' => 4
319
+ ),
320
+ 'ad8_widget' => array(
321
+ 'id' => 'ad8_widget',
322
+ 'name' => __( 'Ad widget 8', 'quick-adsense-reloaded' ),
323
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
324
+ 'type' => 'adsense_code',
325
+ 'size' => 4
326
+ ),
327
+ 'ad9_widget' => array(
328
+ 'id' => 'ad9_widget',
329
+ 'name' => __( 'Ad widget 9', 'quick-adsense-reloaded' ),
330
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
331
+ 'type' => 'adsense_code',
332
+ 'size' => 4
333
+ ),
334
+ 'ad10_widget' => array(
335
+ 'id' => 'ad10_widget',
336
+ 'name' => __( 'Ad widget 10', 'quick-adsense-reloaded' ),
337
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
338
+ 'type' => 'adsense_code',
339
+ 'size' => 4
340
+ ),
341
+ array(
342
+ 'id' => 'plugin_header',
343
+ 'name' => '<strong>' . __( 'Plugin Settings', 'quick-adsense-reloaded' ) . '</strong>',
344
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
345
+ 'type' => 'header'
346
+ ),
347
+ 'priority' => array(
348
+ 'id' => 'priority',
349
+ 'name' => __( 'Load Priority', 'quick-adsense-reloaded' ),
350
+ 'desc' => __( 'Do not change this if everything is working fine. It could result in non showing ads! A lower value loads WP QUADS earlier than other Plugins. Use a higher value for loading WP QUADS later. Try to lower the value to a value less than 10 if not all ads are shown. <strong>Default:</strong> 20', 'quick-adsense-reloaded' ),
351
+ 'type' => 'number',
352
+ 'size' => 'small',
353
+ 'std' => 20
354
+ ),
355
+ 'create_settings' => array(
356
+ 'id' => 'create_settings',
357
+ 'name' => __( 'Settings link', 'quick-adsense-reloaded' ),
358
+ 'desc' => __( 'Make the WPQUADS settings available from <strong>Settings->WPQUADS</strong> This will remove the primary menu button from the admin sidebar', 'quick-adsense-reloaded' ),
359
+ 'type' => 'checkbox',
360
+ ),
361
+ 'uninstall_on_delete' => array(
362
+ 'id' => 'uninstall_on_delete',
363
+ 'name' => __( 'Remove Data on Uninstall?', 'quick-adsense-reloaded' ),
364
+ 'desc' => __( 'Check this box if you would like <strong>Settings->WPQUADS</strong> to completely remove all of its data when the plugin is deleted.', 'quick-adsense-reloaded' ),
365
+ 'type' => 'checkbox'
366
+ ),
367
+ )
368
+ ),
369
+ 'licenses' => apply_filters( 'quads_settings_licenses', array('licenses_header' => array(
370
+ 'id' => 'licenses_header',
371
+ 'name' => __( 'Activate Your License', 'quick-adsense-reloaded' ),
372
+ 'desc' => '',
373
+ 'type' => 'header'
374
+ ),)
375
+ ),
376
+ 'extensions' => apply_filters( 'quads_settings_extension', array()
377
+ ),
378
+ 'addons' => apply_filters( 'quads_settings_addons', array(
379
+ 'addons' => array(
380
+ 'id' => 'addons',
381
+ 'name' => __( '', 'quick-adsense-reloaded' ),
382
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
383
+ 'type' => 'addons'
384
+ ),
385
+ )
386
+ ),
387
+ 'imexport' => apply_filters( 'quads_settings_imexport', array(
388
+ 'imexport' => array(
389
+ 'id' => 'imexport',
390
+ 'name' => __( '', 'quick-adsense-reloaded' ),
391
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
392
+ 'type' => 'imexport'
393
+ )
394
+ )
395
+ ),
396
+ 'help' => apply_filters( 'quads_settings_help', array(
397
+ 'help_header' => array(
398
+ 'id' => 'help_header',
399
+ 'name' => '<strong>' . __( 'Help', 'quick-adsense-reloaded' ) . '</strong>',
400
+ 'desc' => quads_is_advanced() ? sprintf( __( 'Something not working as expected? Open a <a href="%1s" target="_blank">support ticket</a>', 'quick-adsense-reloaded' ), 'http://wpquads.com/support/' ) : sprintf( __( 'Something not working as expected? Visit the WP<strong>QUADS</strong> <a href="%1s" target="_blank">Support Forum</a>', 'quick-adsense-reloaded' ), 'https://wordpress.org/support/plugin/quick-adsense-reloaded' ),
401
+ 'type' => 'header'
402
+ ),
403
+ 'systeminfo' => array(
404
+ 'id' => 'systeminfo',
405
+ 'name' => __( 'Systeminfo', 'quick-adsense-reloaded' ),
406
+ 'desc' => __( '', 'quick-adsense-reloaded' ),
407
+ 'type' => 'systeminfo'
408
+ ),
409
+ 'debug_mode' => array(
410
+ 'id' => 'debug_mode',
411
+ 'name' => __( 'Debug mode', 'quick-adsense-reloaded' ),
412
+ 'desc' => __( 'This does not minify javascript and css files. This makes debugging much easier and is recommended setting for inspecting issues on your site', 'quick-adsense-reloaded' ),
413
+ 'type' => 'checkbox'
414
+ )
415
+ )
416
+ )
417
+ );
418
+
419
+ return $quads_settings;
420
+ }
421
+
422
+ /**
423
+ * return empty settings
424
+ * @return string empty one
425
+ */
426
+ function quads_empty_callback() {
427
+ return '';
428
+ }
429
+
430
+ /**
431
+ * Settings Sanitization
432
+ *
433
+ * Adds a settings error (for the updated message)
434
+ * At some point this will validate input
435
+ *
436
+ * @since 0.9.0
437
+ *
438
+ * @param array $input The value input in the field
439
+ *
440
+ * @return string $input Sanitized value
441
+ */
442
+ function quads_settings_sanitize( $input = array() ) {
443
+
444
+ global $quads_options;
445
+
446
+
447
+ if( empty( $_POST['_wp_http_referer'] ) ) {
448
+ return $input;
449
+ }
450
+
451
+ parse_str( $_POST['_wp_http_referer'], $referrer );
452
+
453
+ $settings = quads_get_registered_settings();
454
+ $tab = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
455
+
456
+ $input = $input ? $input : array();
457
+ $input = apply_filters( 'quads_settings_' . $tab . '_sanitize', $input );
458
+
459
+ // Loop through each setting being saved and pass it through a sanitization filter
460
+ foreach ( $input as $key => $value ) {
461
+
462
+ // Get the setting type (checkbox, select, etc)
463
+ $type = isset( $settings[$tab][$key]['type'] ) ? $settings[$tab][$key]['type'] : false;
464
+
465
+ if( $type ) {
466
+ // Field type specific filter
467
+ $input[$key] = apply_filters( 'quads_settings_sanitize_' . $type, $value, $key );
468
+ }
469
+
470
+ // General filter
471
+ $input[$key] = apply_filters( 'quads_settings_sanitize', $value, $key );
472
+ }
473
+
474
+ // Loop through the whitelist and unset any that are empty for the tab being saved
475
+ if( !empty( $settings[$tab] ) ) {
476
+ foreach ( $settings[$tab] as $key => $value ) {
477
+ // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
478
+ if( is_numeric( $key ) ) {
479
+ $key = $value['id'];
480
+ }
481
+
482
+ if( empty( $input[$key] ) ) {
483
+ unset( $quads_options[$key] );
484
+ }
485
+ }
486
+ }
487
+
488
+
489
+ // Merge our new settings with the existing
490
+ $output = array_merge( $quads_options, $input );
491
+
492
+
493
+ add_settings_error( 'quads-notices', '', __( 'Settings updated.', 'quick-adsense-reloaded' ), 'updated' );
494
+
495
+ return $output;
496
+ }
497
+
498
+ /**
499
+ * Sanitize text fields
500
+ *
501
+ * @since 1.8
502
+ * @param array $input The field value
503
+ * @return string $input Sanitizied value
504
+ */
505
+ function quads_sanitize_text_field( $input ) {
506
+ return trim( $input );
507
+ }
508
+
509
+ add_filter( 'quads_settings_sanitize_text', 'quads_sanitize_text_field' );
510
+
511
+ /**
512
+ * Retrieve settings tabs
513
+ *
514
+ * @since 1.8
515
+ * @param array $input The field value
516
+ * @return string $input Sanitizied value
517
+ */
518
+ function quads_get_settings_tabs() {
519
+
520
+ $settings = quads_get_registered_settings();
521
+
522
+ $tabs = array();
523
+ $tabs['general'] = __( 'General', 'quick-adsense-reloaded' );
524
+
525
+ if( !empty( $settings['visual'] ) ) {
526
+ $tabs['visual'] = __( 'Visual', 'quick-adsense-reloaded' );
527
+ }
528
+
529
+ if( !empty( $settings['networks'] ) ) {
530
+ //$tabs['networks'] = __( 'Social Networks', 'quick-adsense-reloaded' );
531
+ }
532
+
533
+ if( !empty( $settings['extensions'] ) ) {
534
+ $tabs['extensions'] = __( 'Add-On Setting', 'quick-adsense-reloaded' );
535
+ }
536
+
537
+
538
+ if( !empty( $settings['licenses'] ) && quads_is_advanced() ) {
539
+ $tabs['licenses'] = __( 'Licenses', 'quick-adsense-reloaded' );
540
+ }
541
+
542
+ //$tabs['addons'] = __( 'Add-Ons', 'quick-adsense-reloaded' );
543
+
544
+ $tabs['imexport'] = __( 'Import/Export', 'quick-adsense-reloaded' );
545
+
546
+ $tabs['help'] = __( 'Help', 'quick-adsense-reloaded' );
547
+
548
+ //$tabs['misc'] = __( 'Misc', 'quick-adsense-reloaded' );
549
+
550
+ return apply_filters( 'quads_settings_tabs', $tabs );
551
+ }
552
+
553
+ /**
554
+ * Header Callback
555
+ *
556
+ * Renders the header.
557
+ *
558
+ * @since 1.0
559
+ * @param array $args Arguments passed by the setting
560
+ * @return void
561
+ */
562
+ function quads_header_callback( $args ) {
563
+ if( !empty( $args['desc'] ) ) {
564
+ echo $args['desc'];
565
+ } else {
566
+ echo '&nbsp';
567
+ }
568
+ }
569
+
570
+ /**
571
+ * Checkbox Callback
572
+ *
573
+ * Renders checkboxes.
574
+ *
575
+ * @since 1.0
576
+ * @param array $args Arguments passed by the setting
577
+ * @global $quads_options Array of all the QUADS Options
578
+ * @return void
579
+ */
580
+ function quads_checkbox_callback( $args ) {
581
+ global $quads_options;
582
+
583
+ $checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
584
+ $html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
585
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
586
+
587
+ echo $html;
588
+ }
589
+ /**
590
+ * Checkbox Callback
591
+ *
592
+ * Renders checkboxes.
593
+ *
594
+ * @since 1.0
595
+ * @param array $args Arguments passed by the setting
596
+ * @global $quads_options Array of all the QUADS Options
597
+ * @return void
598
+ */
599
+ function quads_checkbox_adsense_callback( $args ) {
600
+ global $quads_options;
601
+
602
+ $checked = isset( $quads_options[$args['id']] ) ? checked( 1, $quads_options[$args['id']], false ) : '';
603
+ $html = '<input type="checkbox" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="1" ' . $checked . '/>';
604
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
605
+
606
+ return $html;
607
+ }
608
+
609
+ /**
610
+ * Multicheck Callback
611
+ *
612
+ * Renders multiple checkboxes.
613
+ *
614
+ * @since 1.0
615
+ * @param array $args Arguments passed by the setting
616
+ * @global $quads_options Array of all the QUADS Options
617
+ * @return void
618
+ */
619
+ function quads_multicheck_callback( $args ) {
620
+ global $quads_options;
621
+
622
+ if( !empty( $args['options'] ) ) {
623
+ foreach ( $args['options'] as $key => $option ):
624
+ if( isset( $quads_options[$args['id']][$key] ) ) {
625
+ $enabled = $option;
626
+ } else {
627
+ $enabled = NULL;
628
+ }
629
+ echo '<input name="quads_settings[' . $args['id'] . '][' . $key . ']" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
630
+ echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
631
+ endforeach;
632
+ echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
633
+ }
634
+ }
635
+
636
+ /**
637
+ * Radio Callback
638
+ *
639
+ * Renders radio boxes.
640
+ *
641
+ * @since 1.3.3
642
+ * @param array $args Arguments passed by the setting
643
+ * @global $quads_options Array of all the QUADS Options
644
+ * @return void
645
+ */
646
+ function quads_radio_callback( $args ) {
647
+ global $quads_options;
648
+
649
+ foreach ( $args['options'] as $key => $option ) :
650
+ $checked = false;
651
+
652
+ if( isset( $quads_options[$args['id']] ) && $quads_options[$args['id']] == $key )
653
+ $checked = true;
654
+ elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options[$args['id']] ) )
655
+ $checked = true;
656
+
657
+ echo '<input name="quads_settings[' . $args['id'] . ']"" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
658
+ echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
659
+ endforeach;
660
+
661
+ echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
662
+ }
663
+
664
+ /**
665
+ * Radio Callback for ad types
666
+ *
667
+ * Renders radio boxes for specific ads
668
+ *
669
+ * @since 1.2.7
670
+ * @param1 array $args Arguments passed by the setting
671
+ * @param2 id int ID of the ad
672
+ *
673
+ * @global $quads_options Array of all the QUADS Options
674
+ * @return void
675
+ */
676
+ function quads_adtype_callback( $id, $args ) {
677
+ global $quads_options;
678
+
679
+ foreach ( $args['options'] as $key => $option ) :
680
+ $checked = false;
681
+
682
+ if( isset( $quads_options[$id]['ad_type'] ) && $quads_options[$id]['ad_type'] == $key )
683
+ $checked = true;
684
+ elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options[$id]['ad_type'] ) )
685
+ $checked = true;
686
+
687
+ echo '<input name="quads_settings[' . $id . '][ad_type]" class="quads_adsense_type" id="quads_settings[' . $id . '][ad_type_'.$key.']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
688
+ echo '<label for="quads_settings[' . $id . '][ad_type_'.$key.']">' . $option . '</label>&nbsp;';
689
+ endforeach;
690
+
691
+ echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
692
+ }
693
+
694
+ /**
695
+ * Radio Callback for ad positions
696
+ *
697
+ * Renders radio boxes for left center right alignment
698
+ *
699
+ * @since 1.2.7
700
+ * @param1 array $args Arguments passed by the setting
701
+ * @param2 id int ID of the ad
702
+ *
703
+ * @global $quads_options Array of all the QUADS Options
704
+ * @return void
705
+ */
706
+ function quads_adposition_callback( $id, $args ) {
707
+ global $quads_options;
708
+
709
+ foreach ( $args['options'] as $key => $option ) :
710
+ $checked = false;
711
+
712
+ if( isset( $quads_options[$id]['align'] ) && $quads_options[$id]['align'] == $key )
713
+ $checked = true;
714
+ elseif( isset( $args['std'] ) && $args['std'] == $key && !isset( $quads_options[$id]['align'] ) )
715
+ $checked = true;
716
+
717
+ if ($key == '3'){
718
+ echo '<input name="quads_settings[' . $id . '][align]" class="quads_adsense_align" id="quads_settings[' . $id . '][align_'.$key.']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
719
+ echo '<label for="quads_settings[' . $id . '][align_'.$key.']">Default</label>&nbsp;';
720
+ } else {
721
+ echo '<input name="quads_settings[' . $id . '][align]" class="quads_adsense_positon" id="quads_settings[' . $id . '][align_'.$key.']" type="radio" value="' . $key . '" ' . checked( true, $checked, false ) . '/>&nbsp;';
722
+ echo '<label for="quads_settings[' . $id . '][align_'.$key.']"><img src="'.QUADS_PLUGIN_URL.'assets/images/align_'.$key.'.png" width="75" height="56"></label>&nbsp;';
723
+ }
724
+
725
+ endforeach;
726
+ }
727
+
728
+ /**
729
+ * Gateways Callback
730
+ *
731
+ * Renders gateways fields.
732
+ *
733
+ * @since 1.0
734
+ * @param array $args Arguments passed by the setting
735
+ * @global $quads_options Array of all the QUADS Options
736
+ * @return void
737
+ */
738
+ function quads_gateways_callback( $args ) {
739
+ global $quads_options;
740
+
741
+ foreach ( $args['options'] as $key => $option ) :
742
+ if( isset( $quads_options['gateways'][$key] ) )
743
+ $enabled = '1';
744
+ else
745
+ $enabled = null;
746
+
747
+ echo '<input name="quads_settings[' . $args['id'] . '][' . $key . ']"" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="1" ' . checked( '1', $enabled, false ) . '/>&nbsp;';
748
+ echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option['admin_label'] . '</label><br/>';
749
+ endforeach;
750
+ }
751
+
752
+ /**
753
+ * Text Callback
754
+ *
755
+ * Renders text fields.
756
+ *
757
+ * @since 1.0
758
+ * @param array $args Arguments passed by the setting
759
+ * @global $quads_options Array of all the QUADS Options
760
+ * @return void
761
+ */
762
+ function quads_text_callback( $args ) {
763
+ global $quads_options;
764
+
765
+ if( isset( $quads_options[$args['id']] ) )
766
+ $value = $quads_options[$args['id']];
767
+ else
768
+ $value = isset( $args['std'] ) ? $args['std'] : '';
769
+
770
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
771
+ $html = '<input type="text" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
772
+ $html .= '<label class="quads_hidden" class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
773
+
774
+ echo $html;
775
+ }
776
+
777
+ /**
778
+ * Number Callback
779
+ *
780
+ * Renders number fields.
781
+ *
782
+ * @since 1.9
783
+ * @param array $args Arguments passed by the setting
784
+ * @global $quads_options Array of all the QUADS Options
785
+ * @return void
786
+ */
787
+ function quads_number_callback( $args ) {
788
+ global $quads_options;
789
+
790
+ if( isset( $quads_options[$args['id']] ) )
791
+ $value = $quads_options[$args['id']];
792
+ else
793
+ $value = isset( $args['std'] ) ? $args['std'] : '';
794
+
795
+ $max = isset( $args['max'] ) ? $args['max'] : 999999;
796
+ $min = isset( $args['min'] ) ? $args['min'] : 0;
797
+ $step = isset( $args['step'] ) ? $args['step'] : 1;
798
+
799
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
800
+ $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
801
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
802
+
803
+ echo $html;
804
+ }
805
+
806
+ /**
807
+ * Textarea Callback
808
+ *
809
+ * Renders textarea fields.
810
+ *
811
+ * @since 1.0
812
+ * @param array $args Arguments passed by the setting
813
+ * @global $quads_options Array of all the QUADS Options
814
+ * @return void
815
+ */
816
+ function quads_textarea_callback( $args ) {
817
+ global $quads_options;
818
+
819
+ if( isset( $quads_options[$args['id']] ) )
820
+ $value = $quads_options[$args['id']];
821
+ else
822
+ $value = isset( $args['std'] ) ? $args['std'] : '';
823
+
824
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : '40';
825
+ $html = '<textarea class="large-text quads-textarea" cols="50" rows="' . $size . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
826
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
827
+
828
+ echo $html;
829
+ }
830
+
831
+
832
+ /**
833
+ * Password Callback
834
+ *
835
+ * Renders password fields.
836
+ *
837
+ * @since 1.3
838
+ * @param array $args Arguments passed by the setting
839
+ * @global $quads_options Array of all the QUADS Options
840
+ * @return void
841
+ */
842
+ function quads_password_callback( $args ) {
843
+ global $quads_options;
844
+
845
+ if( isset( $quads_options[$args['id']] ) )
846
+ $value = $quads_options[$args['id']];
847
+ else
848
+ $value = isset( $args['std'] ) ? $args['std'] : '';
849
+
850
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
851
+ $html = '<input type="password" class="' . $size . '-text" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
852
+ $html .= '<label for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
853
+
854
+ echo $html;
855
+ }
856
+
857
+ /**
858
+ * Missing Callback
859
+ *
860
+ * If a function is missing for settings callbacks alert the user.
861
+ *
862
+ * @since 1.3.1
863
+ * @param array $args Arguments passed by the setting
864
+ * @return void
865
+ */
866
+ function quads_missing_callback( $args ) {
867
+ printf( __( 'The callback function used for the <strong>%s</strong> setting is missing.', 'quick-adsense-reloaded' ), $args['id'] );
868
+ }
869
+
870
+ /**
871
+ * Select Callback
872
+ *
873
+ * Renders select fields.
874
+ *
875
+ * @since 1.0
876
+ * @param array $args Arguments passed by the setting
877
+ * @global $quads_options Array of all the QUADS Options
878
+ * @return void
879
+ */
880
+ function quads_select_callback( $args ) {
881
+ global $quads_options;
882
+
883
+ if( isset( $quads_options[$args['id']] ) )
884
+ $value = $quads_options[$args['id']];
885
+ else
886
+ $value = isset( $args['std'] ) ? $args['std'] : '';
887
+
888
+ $html = '<select id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']"/>';
889
+
890
+ foreach ( $args['options'] as $option => $name ) :
891
+ $selected = selected( $option, $value, false );
892
+ $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
893
+ endforeach;
894
+
895
+ $html .= '</select>';
896
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
897
+ $html .= '<br>' . $args['desc2'];
898
+
899
+ echo $html;
900
+ }
901
+ /**
902
+ * AdSense Type Select Callback
903
+ *
904
+ * Renders Adsense adsense type fields.
905
+ *
906
+ * @since 1.0
907
+ * @param1 array $args Arguments passed by the setting
908
+ * @param2 int $id if od the ad
909
+ * @global $quads_options Array of all the QUADS Options
910
+ * @return void
911
+ */
912
+ function quads_adense_select_callback( $id, $args ) {
913
+ global $quads_options;
914
+
915
+ if( isset( $quads_options[$id][$args['id']] ) )
916
+ $value = $quads_options[$id][$args['id']];
917
+ else
918
+ $value = isset( $args['std'] ) ? $args['std'] : '';
919
+
920
+ $size = !empty($args['size']) ? $args['size'] : 'quads-medium-size';
921
+
922
+ $html = '<label class="quads_hidden" id="quads-label-'.$args['desc'].'" for="quads_settings[' . $id . '][' . $args['id'] . ']"> ' . $args['desc'] . ' </label>';
923
+ $html .= ' <select class="quads-select-'.$args['desc'].' '.$size. '" id="quads_settings[' . $id . '][' . $args['id'] . ']" name="quads_settings[' . $id . '][' . $args['id'] . ']"/>';
924
+
925
+ foreach ( $args['options'] as $option => $name ) :
926
+ $selected = selected( $option, $value, false );
927
+ $html .= '<option value="' . $option . '" ' . $selected . '>' . $name . '</option>';
928
+ endforeach;
929
+
930
+ $html .= '</select>';
931
+ echo $html;
932
+ }
933
+
934
+ /**
935
+ * Color select Callback
936
+ *
937
+ * Renders color select fields.
938
+ *
939
+ * @since 2.1.2
940
+ * @param array $args Arguments passed by the setting
941
+ * @global $quads_options Array of all the QUADS Options
942
+ * @return void
943
+ */
944
+ function quads_color_select_callback( $args ) {
945
+ global $quads_options;
946
+
947
+ if( isset( $quads_options[$args['id']] ) )
948
+ $value = $quads_options[$args['id']];
949
+ else
950
+ $value = isset( $args['std'] ) ? $args['std'] : '';
951
+
952
+ $html = '<strong>#:</strong><input type="text" style="max-width:80px;border:1px solid #' . esc_attr( stripslashes( $value ) ) . ';border-right:20px solid #' . esc_attr( stripslashes( $value ) ) . ';" id="quads_settings[' . $args['id'] . ']" class="medium-text ' . $args['id'] . '" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
953
+
954
+ $html .= '</select>';
955
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
956
+
957
+ echo $html;
958
+ }
959
+
960
+ /**
961
+ * Rich Editor Callback
962
+ *
963
+ * Renders rich editor fields.
964
+ *
965
+ * @since 1.0
966
+ * @param array $args Arguments passed by the setting
967
+ * @global $quads_options Array of all the QUADS Options
968
+ * @global $wp_version WordPress Version
969
+ */
970
+ function quads_rich_editor_callback( $args ) {
971
+ global $quads_options, $wp_version;
972
+ if( isset( $quads_options[$args['id']] ) )
973
+ $value = $quads_options[$args['id']];
974
+ else
975
+ $value = isset( $args['std'] ) ? $args['std'] : '';
976
+
977
+ if( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
978
+ ob_start();
979
+ wp_editor( stripslashes( $value ), 'quads_settings_' . $args['id'], array('textarea_name' => 'quads_settings[' . $args['id'] . ']', 'textarea_rows' => $args['textarea_rows']) );
980
+ $html = ob_get_clean();
981
+ } else {
982
+ $html = '<textarea class="large-text quads-richeditor" rows="10" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
983
+ }
984
+
985
+ $html .= '<br/><label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
986
+
987
+ echo $html;
988
+ }
989
+
990
+ /**
991
+ * Upload Callback
992
+ *
993
+ * Renders upload fields.
994
+ *
995
+ * @since 1.0
996
+ * @param array $args Arguments passed by the setting
997
+ * @global $quads_options Array of all the QUADS Options
998
+ * @return void
999
+ */
1000
+ function quads_upload_callback( $args ) {
1001
+ global $quads_options;
1002
+
1003
+ if( isset( $quads_options[$args['id']] ) )
1004
+ $value = $quads_options[$args['id']];
1005
+ else
1006
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1007
+
1008
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1009
+ $html = '<input type="text" class="' . $size . '-text quads_upload_field" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
1010
+ $html .= '<span>&nbsp;<input type="button" class="quads_settings_upload_button button-secondary" value="' . __( 'Upload File', 'quick-adsense-reloaded' ) . '"/></span>';
1011
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
1012
+
1013
+ echo $html;
1014
+ }
1015
+
1016
+ /**
1017
+ * Color picker Callback
1018
+ *
1019
+ * Renders color picker fields.
1020
+ *
1021
+ * @since 1.6
1022
+ * @param array $args Arguments passed by the setting
1023
+ * @global $quads_options Array of all the QUADS Options
1024
+ * @return void
1025
+ */
1026
+ function quads_color_callback( $args ) {
1027
+ global $quads_options;
1028
+
1029
+ if( isset( $quads_options[$args['id']] ) )
1030
+ $value = $quads_options[$args['id']];
1031
+ else
1032
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1033
+
1034
+ $default = isset( $args['std'] ) ? $args['std'] : '';
1035
+
1036
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1037
+ $html = '<input type="text" class="quads-color-picker" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
1038
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
1039
+
1040
+ echo $html;
1041
+ }
1042
+
1043
+ /**
1044
+ * Registers the license field callback
1045
+ *
1046
+ * @since 3.0.0
1047
+ * @param array $args Arguments passed by the setting
1048
+ * @global $quads_options Array of all the QUADS options
1049
+ * @return void
1050
+ */
1051
+ if( !function_exists( 'quads_license_key_callback' ) ) {
1052
+
1053
+ function quads_license_key_callback( $args ) {
1054
+ global $quads_options;
1055
+
1056
+ $class = '';
1057
+
1058
+ $messages = array();
1059
+ $license = get_option( $args['options']['is_valid_license_option'] );
1060
+
1061
+
1062
+ if( isset( $quads_options[$args['id']] ) ) {
1063
+ $value = $quads_options[$args['id']];
1064
+ } else {
1065
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1066
+ }
1067
+
1068
+ if( !empty( $license ) && is_object( $license ) ) {
1069
+
1070
+ // activate_license 'invalid' on anything other than valid, so if there was an error capture it
1071
+ if( false === $license->success ) {
1072
+
1073
+ switch ( $license->error ) {
1074
+
1075
+ case 'expired' :
1076
+
1077
+ $class = 'error';
1078
+ $messages[] = sprintf(
1079
+ __( 'Your license key expired on %s. Please <a href="%s" target="_blank" title="Renew your license key">renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=license_tab&utm_medium=admin&utm_content=license-expired'
1080
+ );
1081
+
1082
+ $license_status = 'quads-license-' . $class . '-notice';
1083
+
1084
+ break;
1085
+
1086
+ case 'missing' :
1087
+
1088
+ $class = 'error';
1089
+ $messages[] = sprintf(
1090
+ __( 'Invalid license. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> and verify it.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license&utm_campaign=notice'
1091
+ );
1092
+
1093
+ $license_status = 'quads-license-' . $class . '-notice';
1094
+
1095
+ break;
1096
+
1097
+ case 'invalid' :
1098
+ case 'site_inactive' :
1099
+
1100
+ $class = 'error';
1101
+ $messages[] = sprintf(
1102
+ __( 'Your %s is not active for this URL. Please <a href="%s" target="_blank" title="Visit account page">visit your account page</a> to manage your license key URLs.', 'quick-adsense-reloaded' ), $args['name'], 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license'
1103
+ );
1104
+
1105
+ $license_status = 'quads-license-' . $class . '-notice';
1106
+
1107
+ break;
1108
+
1109
+ case 'item_name_mismatch' :
1110
+
1111
+ $class = 'error';
1112
+ $messages[] = sprintf( __( 'This is not a %s.', 'quick-adsense-reloaded' ), $args['name'] );
1113
+
1114
+ $license_status = 'quads-license-' . $class . '-notice';
1115
+
1116
+ break;
1117
+
1118
+ case 'no_activations_left':
1119
+
1120
+ $class = 'error';
1121
+ $messages[] = sprintf( __( 'Your license key has reached its activation limit. <a href="%s" target="_blank">View possible upgrades</a> now.', 'quick-adsense-reloaded' ), 'http://wpquads.com/your-account?utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin&utm_content=invalid-license' );
1122
+
1123
+ $license_status = 'quads-license-' . $class . '-notice';
1124
+
1125
+ break;
1126
+ }
1127
+ } else {
1128
+
1129
+ switch ( $license->license ) {
1130
+
1131
+ case 'valid' :
1132
+ default:
1133
+
1134
+ $class = 'valid';
1135
+
1136
+ $now = current_time( 'timestamp' );
1137
+ $expiration = strtotime( $license->expires, current_time( 'timestamp' ) );
1138
+
1139
+ if( 'lifetime' === $license->expires ) {
1140
+
1141
+ $messages[] = __( 'License key never expires.', 'quick-adsense-reloaded' );
1142
+
1143
+ $license_status = 'quads-license-lifetime-notice';
1144
+ } elseif( $expiration > $now && $expiration - $now < ( DAY_IN_SECONDS * 30 ) ) {
1145
+
1146
+ $messages[] = sprintf(
1147
+ __( 'Your license key expires soon! It expires on %s. <a href="%s" target="_blank" title="Renew license">Renew your license key</a>.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) ), 'http://wpquads.com/checkout/?edd_license_key=' . $value . '&utm_campaign=notice&utm_source=licenses-tab&utm_medium=admin'
1148
+ );
1149
+
1150
+ $license_status = 'quads-license-expires-soon-notice';
1151
+ } else {
1152
+
1153
+ $messages[] = sprintf(
1154
+ __( 'Your license key expires on %s.', 'quick-adsense-reloaded' ), date_i18n( get_option( 'date_format' ), strtotime( $license->expires, current_time( 'timestamp' ) ) )
1155
+ );
1156
+
1157
+ $license_status = 'quads-license-expiration-date-notice';
1158
+ }
1159
+
1160
+ break;
1161
+ }
1162
+ }
1163
+ } else {
1164
+ $license_status = null;
1165
+ }
1166
+
1167
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1168
+ $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" name="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
1169
+
1170
+ if( ( is_object( $license ) && 'valid' == $license->license ) || 'valid' == $license ) {
1171
+ $html .= '<input type="submit" class="button-secondary" name="' . $args['id'] . '_deactivate" value="' . __( 'Deactivate License', 'quick-adsense-reloaded' ) . '"/>';
1172
+ }
1173
+
1174
+ $html .= '<label for="quads_settings[' . quads_sanitize_key( $args['id'] ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
1175
+
1176
+ if( !empty( $messages ) ) {
1177
+ foreach ( $messages as $message ) {
1178
+
1179
+ $html .= '<div class="quads-license-data quads-license-' . $class . '">';
1180
+ $html .= '<p>' . $message . '</p>';
1181
+ $html .= '</div>';
1182
+ }
1183
+ }
1184
+
1185
+ wp_nonce_field( quads_sanitize_key( $args['id'] ) . '-nonce', quads_sanitize_key( $args['id'] ) . '-nonce' );
1186
+
1187
+ if( isset( $license_status ) ) {
1188
+ echo '<div class="' . $license_status . '">' . $html . '</div>';
1189
+ } else {
1190
+ echo '<div class="quads-license-null">' . $html . '</div>';
1191
+ }
1192
+ }
1193
+
1194
+ }
1195
+
1196
+ /**
1197
+ * Registers the Add-Ons field callback for WPQUADS Add-Ons
1198
+ *
1199
+ * @since 2.0.5
1200
+ * @param array $args Arguments passed by the setting
1201
+ * @return html
1202
+ */
1203
+ function quads_addons_callback( $args ) {
1204
+ $html = quads_add_ons_page();
1205
+ echo $html;
1206
+ }
1207
+
1208
+ /**
1209
+ * Registers the im/export callback for WPQUADS
1210
+ *
1211
+ * @since 0.9.0
1212
+ * @param array $args Arguments passed by the setting
1213
+ * @return html
1214
+ */
1215
+ function quads_imexport_callback( $args ) {
1216
+ $html = quads_tools_import_export_display();
1217
+ $html .= quads_import_quick_adsense_settings();
1218
+ echo $html;
1219
+ }
1220
+
1221
+ /**
1222
+ * Registers the system info for WPQUADS
1223
+ *
1224
+ * @since 0.9.0
1225
+ * @param array $args Arguments passed by the setting
1226
+ * @return html
1227
+ */
1228
+ function quads_systeminfo_callback( $args ) {
1229
+ $html = quads_tools_sysinfo_display();
1230
+ echo $html;
1231
+ }
1232
+
1233
+ /**
1234
+ * Registers the image upload field
1235
+ *
1236
+ * @since 1.0
1237
+ * @param array $args Arguments passed by the setting
1238
+ * @global $quads_options Array of all the QUADS Options
1239
+ * @return void
1240
+ */
1241
+ function quads_upload_image_callback( $args ) {
1242
+ global $quads_options;
1243
+
1244
+ if( isset( $quads_options[$args['id']] ) )
1245
+ $value = $quads_options[$args['id']];
1246
+ else
1247
+ $value = isset( $args['std'] ) ? $args['std'] : '';
1248
+
1249
+ $size = ( isset( $args['size'] ) && !is_null( $args['size'] ) ) ? $args['size'] : 'regular';
1250
+ $html = '<input type="text" class="' . $size . '-text ' . $args['id'] . '" id="quads_settings[' . $args['id'] . ']" name="quads_settings[' . $args['id'] . ']" value="' . esc_attr( $value ) . '"/>';
1251
+
1252
+ $html .= '<input type="submit" class="button-secondary quads_upload_image" name="' . $args['id'] . '_upload" value="' . __( 'Select Image', 'quick-adsense-reloaded' ) . '"/>';
1253
+
1254
+ $html .= '<label class="quads_hidden" for="quads_settings[' . $args['id'] . ']"> ' . $args['desc'] . '</label>';
1255
+
1256
+ echo $html;
1257
+ }
1258
+
1259
+ /*
1260
+ * Post Types Callback
1261
+ *
1262
+ * Adds a multiple choice drop box
1263
+ * for selecting where WPQUADS should be enabled
1264
+ *
1265
+ * @since 2.0.9
1266
+ * @param array $args Arguments passed by the setting
1267
+ * @return void
1268
+ *
1269
+ */
1270
+
1271
+ //function quads_posttypes_callback( $args ) {
1272
+ // global $quads_options;
1273
+ // $posttypes = get_post_types();
1274
+ //
1275
+ // if( !empty( $posttypes ) ) {
1276
+ // foreach ( $posttypes as $key => $option ):
1277
+ // if( isset( $quads_options[$args['id']][$key] ) ) {
1278
+ // $enabled = $option;
1279
+ // } else {
1280
+ // $enabled = NULL;
1281
+ // }
1282
+ // echo '<input name="quads_settings[' . $args['id'] . '][' . $key . ']" id="quads_settings[' . $args['id'] . '][' . $key . ']" type="checkbox" value="' . $option . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
1283
+ // echo '<label for="quads_settings[' . $args['id'] . '][' . $key . ']">' . $option . '</label><br/>';
1284
+ // endforeach;
1285
+ // echo '<p class="description quads_hidden">' . $args['desc'] . '</p>';
1286
+ // }
1287
+ //}
1288
+
1289
+ /*
1290
+ * Note Callback
1291
+ *
1292
+ * Show a note
1293
+ *
1294
+ * @since 2.2.8
1295
+ * @param array $args Arguments passed by the setting
1296
+ * @return void
1297
+ *
1298
+ */
1299
+
1300
+ function quads_note_callback( $args ) {
1301
+ global $quads_options;
1302
+ //$html = !empty($args['desc']) ? $args['desc'] : '';
1303
+ $html = '';
1304
+ echo $html;
1305
+ }
1306
+
1307
+ /**
1308
+ * Additional content Callback
1309
+ * Adds several content text boxes selectable via jQuery easytabs()
1310
+ *
1311
+ * @param array $args
1312
+ * @return string $html
1313
+ * @scince 2.3.2
1314
+ */
1315
+ function quads_add_content_callback( $args ) {
1316
+ global $quads_options;
1317
+
1318
+ $html = '<div id="quadstabcontainer" class="tabcontent_container"><ul class="quadstabs" style="width:99%;max-width:500px;">';
1319
+ foreach ( $args['options'] as $option => $name ) :
1320
+ $html .= '<li class="quadstab" style="float:left;margin-right:4px;"><a href="#' . $name['id'] . '">' . $name['name'] . '</a></li>';
1321
+ endforeach;
1322
+ $html .= '</ul>';
1323
+ $html .= '<div class="quadstab-container">';
1324
+ foreach ( $args['options'] as $option => $name ) :
1325
+ $value = isset( $quads_options[$name['id']] ) ? $quads_options[$name['id']] : '';
1326
+ $textarea = '<textarea class="large-text quads-textarea" cols="50" rows="15" id="quads_settings[' . $name['id'] . ']" name="quads_settings[' . $name['id'] . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
1327
+ $html .= '<div id="' . $name['id'] . '" style="max-width:500px;"><span style="padding-top:60px;display:block;">' . $name['desc'] . ':</span><br>' . $textarea . '</div>';
1328
+ endforeach;
1329
+ $html .= '</div>';
1330
+ $html .= '</div>';
1331
+ echo $html;
1332
+ }
1333
+
1334
+ /**
1335
+ * Hook Callback
1336
+ *
1337
+ * Adds a do_action() hook in place of the field
1338
+ *
1339
+ * @since 1.0.8.2
1340
+ * @param array $args Arguments passed by the setting
1341
+ * @return void
1342
+ */
1343
+ function quads_hook_callback( $args ) {
1344
+ do_action( 'quads_' . $args['id'] );
1345
+ }
1346
+
1347
+ /**
1348
+ * Set manage_options as the cap required to save QUADS settings pages
1349
+ *
1350
+ * @since 1.9
1351
+ * @return string capability required
1352
+ */
1353
+ function quads_set_settings_cap() {
1354
+ return 'manage_options';
1355
+ }
1356
+
1357
+ add_filter( 'option_page_capability_quads_settings', 'quads_set_settings_cap' );
1358
+
1359
+
1360
+
1361
+
1362
+ /* returns Cache Status if enabled or disabled
1363
+ *
1364
+ * @since 2.0.4
1365
+ * @return string
1366
+ */
1367
+
1368
+ function quads_cache_status() {
1369
+ global $quads_options;
1370
+ if( isset( $quads_options['disable_cache'] ) ) {
1371
+ return ' <strong style="color:red;">' . __( 'Transient Cache disabled! Enable it for performance increase.', 'quick-adsense-reloaded' ) . '</strong> ';
1372
+ }
1373
+ }
1374
+
1375
+ /* Permission check if logfile is writable
1376
+ *
1377
+ * @since 2.0.6
1378
+ * @return string
1379
+ */
1380
+
1381
+ function quads_log_permissions() {
1382
+ global $quads_options;
1383
+ if( !$quads->logger->checkDir() ) {
1384
+ return '<br><strong style="color:red;">' . __( 'Log file directory not writable! Set FTP permission to 755 or 777 for /wp-content/plugins/quadssharer/logs/', 'quick-adsense-reloaded' ) . '</strong> <br> Read here more about <a href="http://codex.wordpress.org/Changing_File_Permissions" target="_blank">file permissions</a> ';
1385
+ }
1386
+ }
1387
+
1388
+ /**
1389
+ * Get number of available ads
1390
+ *
1391
+ * @global $quads_options $quads_options
1392
+ * @return array
1393
+ */
1394
+ function quads_get_ads() {
1395
+ global $quads_options;
1396
+
1397
+ $ads = array(
1398
+ 0 => __( 'Random Ads', 'quick-adsense-reloaded' ),
1399
+ 1 => 'ad1',
1400
+ 2 => 'ad2',
1401
+ 3 => 'ad3',
1402
+ 4 => 'ad4',
1403
+ 5 => 'ad5',
1404
+ 6 => 'ad6',
1405
+ 7 => 'ad7',
1406
+ 8 => 'ad8',
1407
+ 9 => 'ad9',
1408
+ 10 => 'ad10'
1409
+ );
1410
+ return $ads;
1411
+ }
1412
+
1413
+ /**
1414
+ * Get array of 1 to 50 for image and paragraph dropdown values
1415
+ *
1416
+ * @global $quads_options $quads_options
1417
+ * @return array
1418
+ */
1419
+ function quads_get_values() {
1420
+
1421
+ $array = array(1);
1422
+ for ( $i = 1; $i <= 50; $i++ ) {
1423
+ $array[] = $i;
1424
+ }
1425
+ unset( $array[0] ); // remove the 0 and start the array with 1
1426
+ return $array;
1427
+ }
1428
+
1429
+ /**
1430
+ * Visibility Callback
1431
+ *
1432
+ * Renders fields for ad visibility
1433
+ *
1434
+ * @since 0.9.0
1435
+ * @param array $args Arguments passed by the setting
1436
+ * @global $quads_options Array of all the QUADS Options
1437
+ * @return void
1438
+ */
1439
+ function quads_visibility_callback( $args ) {
1440
+ global $quads_options, $quads;
1441
+
1442
+ // Posts & Pages
1443
+ //$html = $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppPost]', 'current' => !empty( $quads_options['visibility']['AppPost'] ) ? $quads_options['visibility']['AppPost'] : null, 'class' => 'quads-checkbox') );
1444
+ //$html .= __( 'Posts ', 'quick-adsense-reloaded' );
1445
+ //$html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppPage]', 'current' => !empty( $quads_options['visibility']['AppPage'] ) ? $quads_options['visibility']['AppPage'] : null, 'class' => 'quads-checkbox') );
1446
+ //$html .= ' ' . __( 'Pages', 'quick-adsense-reloaded' ) . '<br>';
1447
+ $html = $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppHome]', 'current' => !empty( $quads_options['visibility']['AppHome'] ) ? $quads_options['visibility']['AppHome'] : null, 'class' => 'quads-checkbox') ) . __( 'Homepage ', 'quick-adsense-reloaded' );
1448
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppCate]', 'current' => !empty( $quads_options['visibility']['AppCate'] ) ? $quads_options['visibility']['AppCate'] : null, 'class' => 'quads-checkbox') ) . __( 'Categories ', 'quick-adsense-reloaded' );
1449
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppArch]', 'current' => !empty( $quads_options['visibility']['AppArch'] ) ? $quads_options['visibility']['AppArch'] : null, 'class' => 'quads-checkbox') ) . __( 'Archives ', 'quick-adsense-reloaded' );
1450
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppTags]', 'current' => !empty( $quads_options['visibility']['AppTags'] ) ? $quads_options['visibility']['AppTags'] : null, 'class' => 'quads-checkbox') ) . __( 'Tags', 'quick-adsense-reloaded' ) . '<br>';
1451
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppSide]', 'current' => !empty( $quads_options['visibility']['AppSide'] ) ? $quads_options['visibility']['AppSide'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide AdsWidget on Homepage', 'quick-adsense-reloaded' ) . '<br>';
1452
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[visibility][AppLogg]', 'current' => !empty( $quads_options['visibility']['AppLogg'] ) ? $quads_options['visibility']['AppLogg'] : null, 'class' => 'quads-checkbox') ) . __( 'Hide Ads when user is logged in.', 'quick-adsense-reloaded' ) . '<br>';
1453
+
1454
+ echo $html;
1455
+ }
1456
+
1457
+ /**
1458
+ * Ad position Callback
1459
+ *
1460
+ * Renders multioptions fields for ad position
1461
+ *
1462
+ * @since 0.9.0
1463
+ * @param array $args Arguments passed by the setting
1464
+ * @global $quads_options Array of all the QUADS Options
1465
+ * @return void
1466
+ */
1467
+ function quads_ad_position_callback( $args ) {
1468
+ global $quads_options, $quads;
1469
+
1470
+
1471
+ // Pos 1
1472
+ $html = $quads->html->checkbox( array('name' => 'quads_settings[pos1][BegnAds]', 'current' => !empty( $quads_options['pos1']['BegnAds'] ) ? $quads_options['pos1']['BegnAds'] : null, 'class' => 'quads-checkbox') );
1473
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1474
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos1][BegnRnd]', 'selected' => !empty( $quads_options['pos1']['BegnRnd'] ) ? $quads_options['pos1']['BegnRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1475
+ $html .= ' ' . __( 'to <strong>Beginning of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
1476
+
1477
+ // Pos 2
1478
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos2][MiddAds]', 'current' => !empty( $quads_options['pos2']['MiddAds'] ) ? $quads_options['pos2']['MiddAds'] : null, 'class' => 'quads-checkbox') );
1479
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1480
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos2][MiddRnd]', 'selected' => !empty( $quads_options['pos2']['MiddRnd'] ) ? $quads_options['pos2']['MiddRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1481
+ $html .= ' ' . __( 'to <strong>Middle of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
1482
+
1483
+ // Pos 3
1484
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos3][EndiAds]', 'current' => !empty( $quads_options['pos3']['EndiAds'] ) ? $quads_options['pos3']['EndiAds'] : null, 'class' => 'quads-checkbox') );
1485
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1486
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos3][EndiRnd]', 'selected' => !empty( $quads_options['pos3']['EndiRnd'] ) ? $quads_options['pos3']['EndiRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1487
+ $html .= ' ' . __( 'to <strong>End of Post</strong>', 'quick-adsense-reloaded' ) . '</br>';
1488
+
1489
+ // Pos 4
1490
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos4][MoreAds]', 'current' => !empty( $quads_options['pos4']['MoreAds'] ) ? $quads_options['pos4']['MoreAds'] : null, 'class' => 'quads-checkbox') );
1491
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1492
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos4][MoreRnd]', 'selected' => !empty( $quads_options['pos4']['MoreRnd'] ) ? $quads_options['pos4']['MoreRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1493
+ $html .= ' ' . __( 'right after <strong>the <span style="font-family:Courier New,Courier,Fixed;">&lt;!--more--&gt;</span> tag</strong>', 'quick-adsense-reloaded' ) . '</br>';
1494
+
1495
+ // Pos 5
1496
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos5][LapaAds]', 'current' => !empty( $quads_options['pos5']['LapaAds'] ) ? $quads_options['pos5']['LapaAds'] : null, 'class' => 'quads-checkbox') );
1497
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1498
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos5][LapaRnd]', 'selected' => !empty( $quads_options['pos5']['LapaRnd'] ) ? $quads_options['pos5']['LapaRnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1499
+ $html .= ' ' . __( 'right before <strong>the last Paragraph</strong>', 'quick-adsense-reloaded' ) . ' </br>';
1500
+
1501
+ // Pos 6
1502
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Ads]', 'current' => !empty( $quads_options['pos6']['Par1Ads'] ) ? $quads_options['pos6']['Par1Ads'] : null, 'class' => 'quads-checkbox') );
1503
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1504
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos6][Par1Rnd]', 'selected' => !empty( $quads_options['pos6']['Par1Rnd'] ) ? $quads_options['pos6']['Par1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1505
+ $html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
1506
+ $html .= $quads->html->select( array('options' => quads_get_values(), 'name' => 'quads_settings[pos6][Par1Nup]', 'selected' => !empty( $quads_options['pos6']['Par1Nup'] ) ? $quads_options['pos6']['Par1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1507
+ $html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
1508
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos6][Par1Con]', 'current' => !empty( $quads_options['pos6']['Par1Con'] ) ? $quads_options['pos6']['Par1Con'] : null, 'class' => 'quads-checkbox') );
1509
+ $html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
1510
+
1511
+ // Pos 7
1512
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Ads]', 'current' => !empty( $quads_options['pos7']['Par2Ads'] ) ? $quads_options['pos7']['Par2Ads'] : null, 'class' => 'quads-checkbox') );
1513
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1514
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos7][Par2Rnd]', 'selected' => !empty( $quads_options['pos7']['Par2Rnd'] ) ? $quads_options['pos7']['Par2Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1515
+ $html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
1516
+ $html .= $quads->html->select( array('options' => quads_get_values(), 'name' => 'quads_settings[pos7][Par2Nup]', 'selected' => !empty( $quads_options['pos7']['Par2Nup'] ) ? $quads_options['pos7']['Par2Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1517
+ $html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
1518
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos7][Par2Con]', 'current' => !empty( $quads_options['pos7']['Par2Con'] ) ? $quads_options['pos7']['Par2Con'] : null, 'class' => 'quads-checkbox') );
1519
+ $html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
1520
+
1521
+ // Pos 8
1522
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Ads]', 'current' => !empty( $quads_options['pos8']['Par3Ads'] ) ? $quads_options['pos8']['Par3Ads'] : null, 'class' => 'quads-checkbox') );
1523
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1524
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos8][Par3Rnd]', 'selected' => !empty( $quads_options['pos8']['Par3Rnd'] ) ? $quads_options['pos8']['Par3Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1525
+ $html .= ' ' . __( '<strong>After Paragraph</strong>', 'quick-adsense-reloaded' ) . ' ';
1526
+ $html .= $quads->html->select( array('options' => quads_get_values(), 'name' => 'quads_settings[pos8][Par3Nup]', 'selected' => !empty( $quads_options['pos8']['Par3Nup'] ) ? $quads_options['pos8']['Par3Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1527
+ $html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
1528
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos8][Par3Con]', 'current' => !empty( $quads_options['pos8']['Par3Con'] ) ? $quads_options['pos8']['Par3Con'] : null, 'class' => 'quads-checkbox') );
1529
+ $html .= ' ' . __( 'to <strong>End of Post</strong> if fewer paragraphs are found.', 'quick-adsense-reloaded' ) . ' </br>';
1530
+
1531
+ // Pos 9
1532
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Ads]', 'current' => !empty( $quads_options['pos9']['Img1Ads'] ) ? $quads_options['pos9']['Img1Ads'] : null, 'class' => 'quads-checkbox') );
1533
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1534
+ $html .= $quads->html->select( array('options' => quads_get_ads(), 'name' => 'quads_settings[pos9][Img1Rnd]', 'selected' => !empty( $quads_options['pos9']['Img1Rnd'] ) ? $quads_options['pos9']['Img1Rnd'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1535
+ $html .= ' ' . __( '<strong>After Image</strong>', 'quick-adsense-reloaded' ) . ' ';
1536
+ $html .= $quads->html->select( array('options' => quads_get_values(), 'name' => 'quads_settings[pos9][Img1Nup]', 'selected' => !empty( $quads_options['pos9']['Img1Nup'] ) ? $quads_options['pos9']['Img1Nup'] : null, 'show_option_all' => false, 'show_option_none' => false) );
1537
+ $html .= ' ' . __( '→', 'quick-adsense-reloaded' ) . ' ';
1538
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[pos9][Img1Con]', 'current' => !empty( $quads_options['pos9']['Img1Con'] ) ? $quads_options['pos9']['Img1Con'] : null, 'class' => 'quads-checkbox') );
1539
+ $html .= ' ' . __( 'after <b>Image\'s outer</b><b><span style="font-family:Courier New,Courier,Fixed;"> &lt;div&gt; wp-caption</span></b> if any.', 'quick-adsense-reloaded' ) . ' </br>';
1540
+
1541
+ echo apply_filters( 'quads_ad_position_callback', $html );
1542
+ }
1543
+
1544
+ /**
1545
+ * Quicktags Callback
1546
+ *
1547
+ * Renders quicktags fields
1548
+ *
1549
+ * @since 0.9.0
1550
+ * @param array $args Arguments passed by the setting
1551
+ * @global $quads_options Array of all the QUADS Options
1552
+ * @return void
1553
+ */
1554
+ function quads_quicktags_callback( $args ) {
1555
+ global $quads_options, $quads;
1556
+
1557
+ // Quicktags info
1558
+ $html = '<div style="margin-bottom:5px;"><strong>Optional: </strong><a href="#" id="quads_insert_ads_action">' . __( ' Insert Ads into a post, on-the-fly', 'quick-adsense-reloaded' ) . '</a></br>' .
1559
+ '<ol style="margin-top:5px;display:none;" id="quads_insert_ads_box">
1560
+ <li>' . __( 'Insert <span class="quads-quote-docs">&lt;!--Ads1--&gt;</span>, <span class="quads-quote-docs">&lt;!--Ads2--&gt;</span>, etc. into a post to show the <b>Particular Ads</b> at specific location.', 'quick-adsense-reloaded' ) . '</li>
1561
+ <li>' . __( 'Insert <span class="quads-quote-docs">&lt;!--RndAds--&gt;</span> into a post to show the <b>Random Ads</b> at specific location', 'quick-adsense-reloaded' ) . '</li>
1562
+ </ol></div>';
1563
+
1564
+ $html .= $quads->html->checkbox( array('name' => 'quads_settings[quicktags][QckTags]', 'current' => !empty( $quads_options['quicktags']['QckTags'] ) ? $quads_options['quicktags']['QckTags'] : null, 'class' => 'quads-checkbox') );
1565
+ $html .= __( 'Show Quicktag Buttons on the HTML Post Editor', 'quick-adsense-reloaded' ) . '</br>';
1566
+ $html .= '<span class="quads-desc">' . __( 'Tags can be inserted into a post via the additional Quicktag Buttons at the HTML Edit Post SubPanel.', 'quick-adsense-reloaded' ) . '</span>';
1567
+ echo $html;
1568
+ }
1569
+
1570
+ /**
1571
+ * This hook should be removed and the hook function should replace entire "quads_ad_position_callback" function.
1572
+ */
1573
+ add_filter( 'quads_ad_position_callback', 'quads_render_ad_locations' );
1574
+
1575
+ /**
1576
+ * Return ad locations HTML based on new API.
1577
+ *
1578
+ * @param $html
1579
+ * @return string Locations HTML
1580
+ */
1581
+ function quads_render_ad_locations( $html ) {
1582
+ global $quads_options, $_quads_registered_ad_locations, $quads;
1583
+
1584
+ if( isset( $_quads_registered_ad_locations ) && is_array( $_quads_registered_ad_locations ) ) {
1585
+ foreach ( $_quads_registered_ad_locations as $location => $location_args ) {
1586
+
1587
+ $location_settings = quads_get_ad_location_settings( $location );
1588
+
1589
+ $html .= $quads->html->checkbox( array(
1590
+ 'name' => 'quads_settings[location_settings][' . $location . '][status]',
1591
+ 'current' => !empty( $location_settings['status'] ) ? $location_settings['status'] : null,
1592
+ 'class' => 'quads-checkbox'
1593
+ ) );
1594
+ $html .= ' ' . __( 'Assign', 'quick-adsense-reloaded' ) . ' ';
1595
+
1596
+ $html .= $quads->html->select( array(
1597
+ 'options' => quads_get_ads(),
1598
+ 'name' => 'quads_settings[location_settings][' . $location . '][ad]',
1599
+ 'selected' => !empty( $location_settings['ad'] ) ? $location_settings['ad'] : null,
1600
+ 'show_option_all' => false,
1601
+ 'show_option_none' => false
1602
+ ) );
1603
+ $html .= ' ' . $location_args['description'] . '</br>';
1604
+ }
1605
+ }
1606
+
1607
+ return $html;
1608
+ }
1609
+
1610
+ /**
1611
+ * AdSense Code Callback
1612
+ *
1613
+ * Renders adsense code fields
1614
+ *
1615
+ * @since 0.9.0
1616
+ * @param array $args Arguments passed by the setting
1617
+ * @global $quads_options Array of all the QUADS Options
1618
+ * @return void
1619
+ */
1620
+
1621
+ function quads_adsense_code_callback( $args ) {
1622
+ global $quads_options;
1623
+
1624
+ $name = empty($args['name']) ? '' : $args['name'];
1625
+
1626
+ $code = isset( $quads_options[$args['id']]['code'] ) ? $quads_options[$args['id']]['code'] : '';
1627
+
1628
+ $margin = isset( $quads_options[$args['id']]['margin'] ) ? esc_attr( stripslashes( $quads_options[$args['id']]['margin'] ) ) : 0;
1629
+
1630
+ $g_data_ad_client = isset( $quads_options[$args['id']]['g_data_ad_client'] ) ? $quads_options[$args['id']]['g_data_ad_client'] : '';
1631
+
1632
+ $g_data_ad_slot = isset( $quads_options[$args['id']]['g_data_ad_slot'] ) ? $quads_options[$args['id']]['g_data_ad_slot'] : '';
1633
+
1634
+ $g_data_ad_width = isset( $quads_options[$args['id']]['g_data_ad_width'] ) ? $quads_options[$args['id']]['g_data_ad_width'] : '';
1635
+
1636
+ $g_data_ad_height = isset( $quads_options[$args['id']]['g_data_ad_height'] ) ? $quads_options[$args['id']]['g_data_ad_height'] : '';
1637
+
1638
+ // Create a shorter var to make HTML cleaner
1639
+ $id = $args['id'];
1640
+ ?>
1641
+ <div class="quads-ad-toggle-header quads-box-close" data-box-id="quads-toggle<?php echo $id; ?>">
1642
+ <div class="quads-toogle-title"><?php echo $name; ?></div>
1643
+ <a class="quads-toggle" data-box-id="quads-toggle<?php echo $id; ?>" href="#"><div class="quads-close-open-icon"></div></a>
1644
+ </div>
1645
+ <div class="quads-ad-toggle-container" id="quads-toggle<?php echo $id; ?>" style="display:none;">
1646
+ <div>
1647
+ <?php
1648
+ $args_ad_type = array(
1649
+ 'id' => 'ad_type',
1650
+ 'name' => 'Type',
1651
+ 'desc' => '',
1652
+ 'std' => 'plain_text',
1653
+ 'options' => array(
1654
+ 'adsense' => 'AdSense',
1655
+ 'plain_text' => 'Plain Text / HTML / JS'
1656
+ )
1657
+ );
1658
+ echo quads_adtype_callback($id, $args_ad_type);
1659
+ ?>
1660
+ </div>
1661
+ <textarea style="vertical-align:top;margin-right:20px;" class="large-text quads-textarea" cols="50" rows="10" id="quads_settings[<?php echo $id; ?>][code]" name="quads_settings[<?php echo $id; ?>][code]"><?php echo esc_textarea( stripslashes( $code ) ); ?></textarea><label for="quads_settings[ <?php echo $id; ?> ][code]"> <?php echo $args['desc']; ?></label>
1662
+ <br>
1663
+ <div class="quads_adsense_code">
1664
+ <input type="button" style="vertical-align:inherit;" class="button button-primary quads-add-adsense" value="Copy / Paste AdSense Code"> <span>or add Ad Slot ID & Publisher ID manually below</span>
1665
+ <br />
1666
+ <?php //echo __('Generate Ad Slot & Publisher ID automatically from your adsense code', 'quick-adsense-reloaded')?>
1667
+ <label class="quads-label-left" for="quads_settings[<?php echo $id; ?>][g_data_ad_slot]">Ad Slot ID </label><input type="text" class="quads-medium-size quads-bggrey" id="quads_settings[<?php echo $id; ?>][g_data_ad_slot]" name="quads_settings[<?php echo $id; ?>][g_data_ad_slot]" value="<?php echo $g_data_ad_slot; ?>">
1668
+ <label for="quads_settings[<?php echo $id; ?>][g_data_ad_client]">Publisher ID</label><input type="text" id="quads_settings[<?php echo $id; ?>][g_data_ad_client]" class="medium-text quads-bggrey" name="quads_settings[<?php echo $id; ?>][g_data_ad_client]" value="<?php echo $g_data_ad_client; ?>">
1669
+ <br />
1670
+ <?php
1671
+ $args_adsense_type = array(
1672
+ 'id' => 'adsense_type',
1673
+ 'name' => 'Type',
1674
+ 'desc' => 'Type',
1675
+ 'options' => array(
1676
+ 'normal' => 'Fixed Size',
1677
+ 'responsive' => 'Responsive'
1678
+ )
1679
+ );
1680
+ echo quads_adense_select_callback($id, $args_adsense_type);
1681
+ ?>
1682
+ <?php if ( !quads_is_advanced()) {?>
1683
+ <span class="quads-pro-notice" style="display:block;margin-top:20px;"><?php echo sprintf(__('Install <a href="%s" target="_blank">WP QUADS PRO</a> to fully support AdSense Responsive ads.', 'quick-adsense-reloaded'),'http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin')?></span>
1684
+ <?php } ?>
1685
+ <br />
1686
+ <label class="quads-label-left quads-type-normal" for="quads_settings[<?php echo $id; ?>][g_data_ad_width]">Width </label><input type="number" step="1" id="quads_settings[<?php echo $id; ?>][g_data_ad_width]" name="quads_settings[<?php echo $id; ?>][g_data_ad_width]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_width; ?>">
1687
+ <label class="quads-type-normal" for="quads_settings[<?php echo $id; ?>][g_data_ad_height]">Height </label><input type="number" step="1" id="quads_settings[<?php echo $id; ?>][g_data_ad_height]" name="quads_settings[<?php echo $id; ?>][g_data_ad_height]" class="small-text quads-type-normal" value="<?php echo $g_data_ad_height; ?>">
1688
+ </div>
1689
+ <div class="quads-style">
1690
+ <h3>Layout</h3>
1691
+ <?php
1692
+ $args_ad_position = array(
1693
+ 'id' => 'align',
1694
+ 'name' => 'align',
1695
+ 'desc' => 'align',
1696
+ 'std' => '3',
1697
+ 'options' => array(
1698
+ '3' => 'Default',
1699
+ '0' => 'Left',
1700
+ '1' => 'Center',
1701
+ '2' => 'Right'
1702
+ )
1703
+ );
1704
+ echo quads_adposition_callback($id, $args_ad_position);
1705
+ // if WP QUADS PRO is installed and version number is higher or equal 1.2.7 show the new margin settings
1706
+ if ( !quads_is_advanced_1_2_7() ){
1707
+ ?>
1708
+
1709
+ <br />
1710
+ <label class="quads-label-left" for="quads_settings[<?php echo $id; ?>][margin]"><?php _e( 'Margin', 'quick-adsense-reloaded' );?></label>
1711
+ <input type="number" step="1" max="" min="" class="small-text" id="quads_settings[<?php echo $id; ?>][margin]" name="quads_settings[<?php echo $id; ?>][margin]" value="<?php echo esc_attr( stripslashes( $margin ) ); ?>"/>px
1712
+ <?php } echo apply_filters('quads_render_margin', '', $id); ?>
1713
+ </div>
1714
+ <?php
1715
+ echo apply_filters( 'quads_advanced_settings', '', $id );
1716
+ echo quads_pro_overlay();
1717
+ ?>
1718
+ </div>
1719
+ <?php
1720
+ }
1721
+
1722
+
1723
+
1724
+ /**
1725
+ * If advanced settings are not available load overlay image
1726
+ * @return string
1727
+ */
1728
+ function quads_pro_overlay() {
1729
+ if( quads_is_advanced() ) {
1730
+ return '';
1731
+ }
1732
+
1733
+ $html = '<div class="quads-advanced-ad-box quads-pro-overlay"><a href="http://wpquads.com/?utm_campaign=overlay&utm_source=free-plugin&utm_medium=admin" target="_blank"><img src="' . QUADS_PLUGIN_URL . '/assets/images/get_pro_overlay.png"></a></div>';
1734
+
1735
+ return $html;
1736
+ }
1737
+
1738
+ /**
1739
+ *
1740
+ * Return array of alignment options
1741
+ *
1742
+ * @return array
1743
+ */
1744
+ function quads_get_alignment() {
1745
+ // Do not change the key => value order for compatibility reasons
1746
+ return array(
1747
+ 3 => 'none',
1748
+ 0 => 'left',
1749
+ 1 => 'center',
1750
+ 2 => 'right',
1751
+ );
1752
+ }
1753
+
1754
+ /**
1755
+ * Check if plugin Clickfraud Monitoring is installed
1756
+ *
1757
+ * @return boolean true when it is installed and active
1758
+ */
1759
+ function quads_is_installed_clickfraud() {
1760
+ $plugin_file = 'cfmonitor/cfmonitor.php';
1761
+ $plugin_file2 = 'clickfraud-monitoring/cfmonitor.php';
1762
+
1763
+ if( is_plugin_active( $plugin_file ) || is_plugin_active( $plugin_file2 ) ) {
1764
+ return true;
1765
+ }
1766
+
1767
+ return false;
1768
+ }
1769
+
1770
+ /**
1771
+ *
1772
+ * @param array $args array(
1773
+ * 'id' => 'string),
1774
+ * 'type' => desktop, tablet_landscape, tablet_portrait, phone
1775
+ * @return string
1776
+ */
1777
+ function quads_render_size_option( $args ) {
1778
+ global $quads_options;
1779
+
1780
+ if( !isset( $args['id'] ) ) {
1781
+ return '';
1782
+ }
1783
+
1784
+ $checked = isset( $quads_options[$args['id']][$args['type']] ) ? $quads_options[$args['id']][$args['type']] : '';
1785
+ $html = '<div class="quads-select-style-overwrite">';
1786
+ $html .= '<select class="quads-size-input" id="quads_settings[' . $args['id'] . '][' . $args['type'] . ']" name="quads_settings[' . $args['id'] . '][' . $args['type'] . ']"/>';
1787
+ foreach ( quads_get_adsense_sizes() as $key => $value ) :
1788
+ $selected = selected( $key, $checked, false );
1789
+ $html .= '<option value="' . $key . '" ' . $selected . '>' . $value . '</option>';
1790
+ endforeach;
1791
+ $html .= '</select>';
1792
+ $html .= '</div>';
1793
+
1794
+ return $html;
1795
+ }
1796
+
1797
+ /**
1798
+ * Get all AdSense Sizes
1799
+ * @return array
1800
+ */
1801
+ function quads_get_adsense_sizes() {
1802
+ $sizes = array(
1803
+ 'Auto' => 'Auto',
1804
+ '120 x 90' => '120 x 90',
1805
+ '120 x 240' => '120 x 240',
1806
+ '120 x 600' => '120 x 600',
1807
+ '125 x 125' => '125 x 125',
1808
+ '160 x 90' => '160 x 90',
1809
+ '160 x 600' => '160 x 600',
1810
+ '180 x 90' => '180 x 90',
1811
+ '180 x 150' => '180 x 150',
1812
+ '200 x 90' => '200 x 90',
1813
+ '200 x 200' => '200 x 200',
1814
+ '234 x 60' => '234 x 60',
1815
+ '250 x 250' => '250 x 250',
1816
+ '320 x 100' => '320 x 100',
1817
+ '300 x 250' => '300 x 250',
1818
+ '300 x 600' => '300 x 600',
1819
+ '300 x 1050' => '300 x 1050',
1820
+ '320 x 50' => '320 x 50',
1821
+ '336 x 280' => '336 x 280',
1822
+ '360 x 300' => '360 x 300',
1823
+ '435 x 300' => '435 x 300',
1824
+ '468 x 15' => '468 x 15',
1825
+ '468 x 60' => '468 x 60',
1826
+ '640 x 165' => '640 x 165',
1827
+ '640 x 190' => '640 x 190',
1828
+ '640 x 300' => '640 x 300',
1829
+ '728 x 15' => '728 x 15',
1830
+ '728 x 90' => '728 x 90',
1831
+ '970 x 90' => '970 x 90',
1832
+ '970 x 250' => '970 x 250',
1833
+ '240 x 400' => '240 x 400 - Regional ad sizes',
1834
+ '250 x 360' => '250 x 360 - Regional ad sizes',
1835
+ '580 x 400' => '580 x 400 - Regional ad sizes',
1836
+ '750 x 100' => '750 x 100 - Regional ad sizes',
1837
+ '750 x 200' => '750 x 200 - Regional ad sizes',
1838
+ '750 x 300' => '750 x 300 - Regional ad sizes',
1839
+ '980 x 120' => '980 x 120 - Regional ad sizes',
1840
+ '930 x 180' => '930 x 180 - Regional ad sizes',
1841
+ );
1842
+
1843
+ return apply_filters( 'quads_adsense_size_formats', $sizes );
1844
+ }
1845
+
1846
+ /**
1847
+ * Store AdSense parameters
1848
+ *
1849
+ * @return boolean
1850
+ */
1851
+ function quads_store_adsense_args() {
1852
+ global $quads_options;
1853
+
1854
+ foreach ( $quads_options as $id => $values ) {
1855
+
1856
+ if( is_array( $values ) && array_key_exists( 'code', $values ) && !empty($values['code']) ) {
1857
+
1858
+ //check to see if it is google ad
1859
+ if( preg_match( '/googlesyndication.com/', $values['code'] ) ) {
1860
+
1861
+ // Test if its google asyncron ad
1862
+ if( preg_match( '/data-ad-client=/', $values['code'] ) ) {
1863
+ //*** GOOGLE ASYNCRON *************
1864
+ $quads_options[$id]['current_ad_type'] = 'google_async';
1865
+ //get g_data_ad_client
1866
+ $explode_ad_code = explode( 'data-ad-client', $values['code'] );
1867
+ preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
1868
+ $quads_options[$id]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
1869
+
1870
+ //get g_data_ad_slot
1871
+ $explode_ad_code = explode( 'data-ad-slot', $values['code'] );
1872
+ preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
1873
+ $quads_options[$id]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
1874
+ } else {
1875
+ //*** GOOGLE SYNCRON *************
1876
+ $quads_options[$id]['current_ad_type'] = 'google_sync';
1877
+ //get g_data_ad_client
1878
+ $explode_ad_code = explode( 'google_ad_client', $values['code'] );
1879
+ preg_match( '#"([a-zA-Z0-9-\s]+)"#', $explode_ad_code[1], $matches_add_client );
1880
+ $quads_options[$id]['g_data_ad_client'] = str_replace( array('"', ' '), array(''), $matches_add_client[1] );
1881
+
1882
+ //get g_data_ad_slot
1883
+ $explode_ad_code = explode( 'google_ad_slot', $values['code'] );
1884
+ preg_match( '#"([a-zA-Z0-9/\s]+)"#', $explode_ad_code[1], $matches_add_slot );
1885
+ $quads_options[$id]['g_data_ad_slot'] = str_replace( array('"', ' '), array(''), $matches_add_slot[1] );
1886
+ }
1887
+ } else {
1888
+ //$quads_options[$id]['current_ad_type'] = 'other';
1889
+ //$quads_options[$id]['g_data_ad_client'] = '';
1890
+ //$quads_options[$id]['g_data_ad_slot'] = '';
1891
+ }
1892
+ }
1893
+ }
1894
+ //var_dump($quads_options);
1895
+ update_option( 'quads_settings', $quads_options );
1896
+ }
1897
+
1898
+
1899
+ /**
1900
+ * Populate AdSense Code field otherwise ads are not shown on frontpage (Bug).
1901
+ * @todo
1902
+ *
1903
+ * @global $quads_options $quads_options
1904
+ * @deprecated since 1.3.8
1905
+ */
1906
+ //function quads_fix_ad_not_shown(){
1907
+ // global $quads_options;
1908
+ //
1909
+ // foreach ( $quads_options as $id => $values ) {
1910
+ // if( is_array( $values ) && array_key_exists( 'code', $values ) && array_key_exists( 'ad_type', $values ) && empty($values['code']) ) {
1911
+ // $quads_options[$id]['code'] = '...';
1912
+ // }
1913
+ // }
1914
+ //}
1915
+
1916
+ /**
1917
+ * Sanitizes a string key for QUADS Settings
1918
+ *
1919
+ * Keys are used as internal identifiers. Alphanumeric characters, dashes, underscores, stops, colons and slashes are allowed
1920
+ *
1921
+ * @since 2.0.0
1922
+ * @param string $key String key
1923
+ * @return string Sanitized key
1924
+ */
1925
+ function quads_sanitize_key( $key ) {
1926
+ $raw_key = $key;
1927
+ $key = preg_replace( '/[^a-zA-Z0-9_\-\.\:\/]/', '', $key );
1928
+ /**
1929
+ * Filter a sanitized key string.
1930
+ *
1931
+ * @since 2.5.8
1932
+ * @param string $key Sanitized key.
1933
+ * @param string $raw_key The key prior to sanitization.
1934
+ */
1935
+ return apply_filters( 'quads_sanitize_key', $key, $raw_key );
1936
+ }
1937
+
1938
+ /**
1939
+ * Multi Select Callback
1940
+ *
1941
+ * @since 1.3.8
1942
+ * @param array $args Arguments passed by the settings
1943
+ * @global $quads_options Array of all the QUADS Options
1944
+ * @return string $output dropdown
1945
+ */
1946
+ function quads_multiselect_callback( $args = array() ) {
1947
+ global $quads_options;
1948
+
1949
+ $placeholder = !empty($args['placeholder']) ? $args['placeholder'] : '';
1950
+ $selected = isset($quads_options[$args['id']]) ? $quads_options[$args['id']] : '';
1951
+ $checked = '';
1952
+
1953
+ $html = '<select name="quads_settings[' . $args['id'] . '][]" data-placeholder="'.$placeholder.'" style="width:550px;" multiple tabindex="4" class="quads-select quads-chosen-select">';
1954
+ $i = 0;
1955
+ foreach ( $args['options'] as $key => $value ) :
1956
+ if( is_array($selected)){
1957
+ $checked = selected( true, in_array( $key, $selected ), false );
1958
+ }
1959
+ $html .= '<option value="' . $key . '" ' . $checked . '>' . $value . '</option>';
1960
+ endforeach;
1961
+ $html .= '</select>';
1962
+ echo $html;
1963
+ }
includes/admin/tools.php ADDED
@@ -0,0 +1,673 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Tools
4
+ *
5
+ * These are functions used for displaying QUADS tools such as the import/export system.
6
+ *
7
+ * @package QUADS
8
+ * @subpackage Admin/Tools
9
+ * @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
10
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+ */
12
+
13
+ // Exit if accessed directly
14
+ if ( ! defined( 'ABSPATH' ) ) exit;
15
+
16
+ /**
17
+ * Tools
18
+ *
19
+ * Shows the tools panel which contains QUADS-specific tools including the
20
+ * built-in import/export system.
21
+ *
22
+ * @since 0.9.0
23
+ * @author Daniel J Griffiths, René Hermenau
24
+ * @return void
25
+ */
26
+ function quads_tools_page() {
27
+ $active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'import_export';
28
+ ?>
29
+ <div class="wrap">
30
+ <?php screen_icon(); ?>
31
+ <h2 class="nav-tab-wrapper">
32
+ <?php
33
+ foreach( quads_get_tools_tabs() as $tab_id => $tab_name ) {
34
+
35
+ $tab_url = add_query_arg( array(
36
+ 'tab' => $tab_id
37
+ ) );
38
+
39
+ $tab_url = remove_query_arg( array(
40
+ 'quads-message'
41
+ ), $tab_url );
42
+
43
+ $active = $active_tab == $tab_id ? ' nav-tab-active' : '';
44
+ echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">' . esc_html( $tab_name ) . '</a>';
45
+
46
+ }
47
+ ?>
48
+ </h2>
49
+ <div class="metabox-holder">
50
+ <?php
51
+ do_action( 'quads_tools_tab_' . $active_tab );
52
+ ?>
53
+ </div><!-- .metabox-holder -->
54
+ </div><!-- .wrap -->
55
+ <?php
56
+ }
57
+
58
+
59
+ /**
60
+ * Retrieve tools tabs
61
+ *
62
+ * @since 2.1.6
63
+ * @return array
64
+ */
65
+ function quads_get_tools_tabs() {
66
+
67
+ $tabs = array();
68
+ $tabs['import_export'] = __( 'Import/Export', 'quick-adsense-reloaded' );
69
+ $tabs['system_info'] = __( 'System Info', 'quick-adsense-reloaded' );
70
+
71
+ return apply_filters( 'quads_tools_tabs', $tabs );
72
+ }
73
+
74
+
75
+
76
+ /**
77
+ * Display the tools import/export tab
78
+ *
79
+ * @since 2.1.6
80
+ * @return void
81
+ */
82
+ function quads_tools_import_export_display() {
83
+
84
+ if( ! current_user_can( 'update_plugins' ) ) {
85
+ return;
86
+ }
87
+
88
+ do_action( 'quads_tools_import_export_before' );
89
+ ?>
90
+ <!-- We have to close the old form first//-->
91
+
92
+ <div class="quads-postbox">
93
+ <h3><span><?php _e( 'Export Settings', 'quick-adsense-reloaded' ); ?></span></h3>
94
+ <div class="inside">
95
+ <p><?php _e( 'Export the Quick AdSense Reloaded settings for this site as a .json file. This allows you to easily import the configuration into another site.', 'quick-adsense-reloaded' ); ?></p>
96
+ <form method="post" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>" id="quads-export-settings">
97
+ <p><input type="hidden" name="quads-action" value="export_settings" /></p>
98
+ <p>
99
+ <?php wp_nonce_field( 'quads_export_nonce', 'quads_export_nonce' ); ?>
100
+ <?php submit_button( __( 'Export', 'quick-adsense-reloaded' ), 'primary', 'submit', false ); ?>
101
+ </p>
102
+ </form>
103
+ </div><!-- .inside -->
104
+ </div><!-- .postbox -->
105
+
106
+ <div class="quads-postbox">
107
+ <h3><span><?php _e( 'Import Settings', 'quick-adsense-reloaded' ); ?></span></h3>
108
+ <div class="inside">
109
+ <p><?php _e( 'Import the Quick AdSense Reloaded settings from a .json file. This file can be obtained by exporting the settings on another site using the form above.', 'quick-adsense-reloaded' ); ?></p>
110
+ <form method="post" enctype="multipart/form-data" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>">
111
+ <p>
112
+ <input type="file" name="import_file"/>
113
+ </p>
114
+ <p>
115
+ <input type="hidden" name="quads-action" value="import_settings" />
116
+ <?php wp_nonce_field( 'quads_import_nonce', 'quads_import_nonce' ); ?>
117
+ <?php submit_button( __( 'Import', 'quick-adsense-reloaded' ), 'secondary', 'submit', false ); ?>
118
+ </p>
119
+ </form>
120
+ </div><!-- .inside -->
121
+ </div><!-- .postbox -->
122
+ <?php
123
+ do_action( 'quads_tools_import_export_after' );
124
+ }
125
+ add_action( 'quads_tools_tab_import_export', 'quads_tools_import_export_display' );
126
+
127
+ /* check if function is disabled or not
128
+ *
129
+ * @returns bool
130
+ * @since 2.1.6
131
+ */
132
+ function quads_is_func_disabled( $function ) {
133
+ $disabled = explode( ',', ini_get( 'disable_functions' ) );
134
+ return in_array( $function, $disabled );
135
+ }
136
+
137
+ /**
138
+ * Process a settings export that generates a .json file of the Quick AdSense Reloaded settings
139
+ *
140
+ * @since 2.1.6
141
+ * @return void
142
+ */
143
+ function quads_tools_import_export_process_export() {
144
+ if( empty( $_POST['quads_export_nonce'] ) )
145
+ return;
146
+
147
+ if( ! wp_verify_nonce( $_POST['quads_export_nonce'], 'quads_export_nonce' ) )
148
+ return;
149
+
150
+ if( ! current_user_can( 'manage_options' ) )
151
+ return;
152
+
153
+ $settings = array();
154
+ $settings = get_option( 'quads_settings' );
155
+
156
+ ignore_user_abort( true );
157
+
158
+ if ( ! quads_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) )
159
+ set_time_limit( 0 );
160
+
161
+ nocache_headers();
162
+ header( 'Content-Type: application/json; charset=utf-8' );
163
+ header( 'Content-Disposition: attachment; filename=' . apply_filters( 'quads_settings_export_filename', 'quads-settings-export-' . date( 'm-d-Y' ) ) . '.json' );
164
+ header( "Expires: 0" );
165
+
166
+ echo json_encode( $settings );
167
+ exit;
168
+ }
169
+ add_action( 'quads_export_settings', 'quads_tools_import_export_process_export' );
170
+
171
+ /**
172
+ * Get File Extension
173
+ *
174
+ * Returns the file extension of a filename.
175
+ *
176
+ * @since 1.0
177
+ * @param unknown $str File name
178
+ * @return mixed File extension
179
+ */
180
+ function quads_get_file_extension( $str ) {
181
+ $parts = explode( '.', $str );
182
+ return end( $parts );
183
+ }
184
+
185
+ /* Convert an object to an associative array.
186
+ * Can handle multidimensional arrays
187
+ *
188
+ * @returns array
189
+ * @since 2.1.6
190
+ */
191
+ function quads_object_to_array( $data ) {
192
+ if ( is_array( $data ) || is_object( $data ) ) {
193
+ $result = array();
194
+ foreach ( $data as $key => $value ) {
195
+ $result[ $key ] = quads_object_to_array( $value );
196
+ }
197
+ return $result;
198
+ }
199
+ return $data;
200
+ }
201
+
202
+ /**
203
+ * Process a settings import from a json file
204
+ *
205
+ * @since 2.1.6
206
+ * @return void
207
+ */
208
+ function quads_tools_import_export_process_import() {
209
+ if( empty( $_POST['quads_import_nonce'] ) )
210
+ return;
211
+
212
+ if( ! wp_verify_nonce( $_POST['quads_import_nonce'], 'quads_import_nonce' ) )
213
+ return;
214
+
215
+ if( ! current_user_can( 'update_plugins' ) )
216
+ return;
217
+
218
+ if( quads_get_file_extension( $_FILES['import_file']['name'] ) != 'json' ) {
219
+ wp_die( __( 'Please upload a valid .json file', 'quick-adsense-reloaded' ) );
220
+ }
221
+
222
+ $import_file = $_FILES['import_file']['tmp_name'];
223
+
224
+ if( empty( $import_file ) ) {
225
+ wp_die( __( 'Please upload a file to import', 'quick-adsense-reloaded' ) );
226
+ }
227
+
228
+ // Retrieve the settings from the file and convert the json object to an array
229
+ $settings = quads_object_to_array( json_decode( file_get_contents( $import_file ) ) );
230
+
231
+ update_option( 'quads_settings', $settings );
232
+
233
+ wp_safe_redirect( admin_url( 'admin.php?page=quads-settings&quads-message=settings-imported&tab=imexport' ) ); exit;
234
+
235
+ }
236
+ add_action( 'quads_import_settings', 'quads_tools_import_export_process_import' );
237
+
238
+
239
+ /**
240
+ * Display the system info tab
241
+ *
242
+ * @since 2.1.6
243
+ * @return void
244
+ * @change 2.3.1
245
+ */
246
+ function quads_tools_sysinfo_display() {
247
+
248
+ if( ! current_user_can( 'update_plugins' ) ) {
249
+ return;
250
+ }
251
+
252
+ ?>
253
+ <!--<form action="<?php echo esc_url( admin_url( 'admin.php?page=quads-settings&tab=system_info' ) ); ?>" method="post" dir="ltr">//-->
254
+ <textarea readonly="readonly" onclick="this.focus(); this.select()" id="system-info-textarea" name="quads-sysinfo" title="To copy the system info, click below then press Ctrl + C (PC) or Cmd + C (Mac)."><?php echo quads_tools_sysinfo_get(); ?></textarea>
255
+ <!--
256
+ <p class="submit">
257
+ <input type="hidden" name="quads-action" value="download_sysinfo" />-->
258
+ <?php //submit_button( 'Download System Info File', 'primary', 'quads-download-sysinfo', false ); ?>
259
+ <!--</p>//-->
260
+ <!--</form>//-->
261
+ <?php
262
+ }
263
+ add_action( 'quads_tools_tab_system_info', 'quads_tools_sysinfo_display' );
264
+
265
+
266
+ /**
267
+ * Get system info
268
+ *
269
+ * @since 2.1.6
270
+ * @access public
271
+ * @global object $wpdb Used to query the database using the WordPress Database API
272
+ * @global array $quads_options Array of all QUADS options
273
+ * @return string $return A string containing the info to output
274
+ */
275
+ function quads_tools_sysinfo_get() {
276
+ global $wpdb, $quads_options;
277
+
278
+ if( !class_exists( 'Browser' ) )
279
+ require_once QUADS_PLUGIN_DIR . 'includes/libraries/browser.php';
280
+
281
+ $browser = new Browser();
282
+
283
+ // Get theme info
284
+ if( get_bloginfo( 'version' ) < '3.4' ) {
285
+ $theme_data = get_theme_data( get_stylesheet_directory() . '/style.css' );
286
+ $theme = $theme_data['Name'] . ' ' . $theme_data['Version'];
287
+ } else {
288
+ $theme_data = wp_get_theme();
289
+ $theme = $theme_data->Name . ' ' . $theme_data->Version;
290
+ }
291
+
292
+
293
+ $return = '### Begin System Info ###' . "\n\n";
294
+
295
+ // Start with the basics...
296
+ $return .= '-- Site Info' . "\n\n";
297
+ $return .= 'Site URL: ' . site_url() . "\n";
298
+ $return .= 'Home URL: ' . home_url() . "\n";
299
+ $return .= 'Multisite: ' . ( is_multisite() ? 'Yes' : 'No' ) . "\n";
300
+
301
+ $return = apply_filters( 'quads_sysinfo_after_site_info', $return );
302
+
303
+
304
+ // The local users' browser information, handled by the Browser class
305
+ $return .= "\n" . '-- User Browser' . "\n\n";
306
+ $return .= $browser;
307
+
308
+ $return = apply_filters( 'quads_sysinfo_after_user_browser', $return );
309
+
310
+ // WordPress configuration
311
+ $return .= "\n" . '-- WordPress Configuration' . "\n\n";
312
+ $return .= 'Version: ' . get_bloginfo( 'version' ) . "\n";
313
+ $return .= 'Language: ' . ( defined( 'WPLANG' ) && WPLANG ? WPLANG : 'en_US' ) . "\n";
314
+ $return .= 'Permalink Structure: ' . ( get_option( 'permalink_structure' ) ? get_option( 'permalink_structure' ) : 'Default' ) . "\n";
315
+ $return .= 'Active Theme: ' . $theme . "\n";
316
+ $return .= 'Show On Front: ' . get_option( 'show_on_front' ) . "\n";
317
+
318
+ // Only show page specs if frontpage is set to 'page'
319
+ if( get_option( 'show_on_front' ) == 'page' ) {
320
+ $front_page_id = get_option( 'page_on_front' );
321
+ $blog_page_id = get_option( 'page_for_posts' );
322
+
323
+ $return .= 'Page On Front: ' . ( $front_page_id != 0 ? get_the_title( $front_page_id ) . ' (#' . $front_page_id . ')' : 'Unset' ) . "\n";
324
+ $return .= 'Page For Posts: ' . ( $blog_page_id != 0 ? get_the_title( $blog_page_id ) . ' (#' . $blog_page_id . ')' : 'Unset' ) . "\n";
325
+ }
326
+
327
+ // Make sure wp_remote_post() is working
328
+ $request['cmd'] = '_notify-validate';
329
+
330
+ $params = array(
331
+ 'sslverify' => false,
332
+ 'timeout' => 60,
333
+ 'user-agent' => 'QUADS/' . QUADS_VERSION,
334
+ 'body' => $request
335
+ );
336
+
337
+ $response = wp_remote_post( 'https://www.paypal.com/cgi-bin/webscr', $params );
338
+
339
+ if( !is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 ) {
340
+ $WP_REMOTE_POST = 'wp_remote_post() works';
341
+ } else {
342
+ $WP_REMOTE_POST = 'wp_remote_post() does not work';
343
+ }
344
+
345
+ $return .= 'Remote Post: ' . $WP_REMOTE_POST . "\n";
346
+ $return .= 'Table Prefix: ' . 'Length: ' . strlen( $wpdb->prefix ) . ' Status: ' . ( strlen( $wpdb->prefix ) > 16 ? 'ERROR: Too long' : 'Acceptable' ) . "\n";
347
+ $return .= 'WP_DEBUG: ' . ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? 'Enabled' : 'Disabled' : 'Not set' ) . "\n";
348
+ $return .= 'Memory Limit: ' . WP_MEMORY_LIMIT . "\n";
349
+ $return .= 'Registered Post Stati: ' . implode( ', ', get_post_stati() ) . "\n";
350
+
351
+ $return = apply_filters( 'quads_sysinfo_after_wordpress_config', $return );
352
+
353
+ // QUADS configuration
354
+ $return .= "\n" . '-- QUADS Configuration' . "\n\n";
355
+ $return .= 'Version: ' . QUADS_VERSION . "\n";
356
+ $return .= 'Upgraded From: ' . get_option( 'quads_version_upgraded_from', 'None' ) . "\n";
357
+
358
+ $return = apply_filters( 'quads_sysinfo_after_quads_config', $return );
359
+
360
+
361
+ // WordPress active plugins
362
+ $return .= "\n" . '-- WordPress Active Plugins' . "\n\n";
363
+
364
+ $plugins = get_plugins();
365
+ $active_plugins = get_option( 'active_plugins', array() );
366
+
367
+ foreach( $plugins as $plugin_path => $plugin ) {
368
+ if( !in_array( $plugin_path, $active_plugins ) )
369
+ continue;
370
+
371
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
372
+ }
373
+
374
+ $return = apply_filters( 'quads_sysinfo_after_wordpress_plugins', $return );
375
+
376
+ // WordPress inactive plugins
377
+ $return .= "\n" . '-- WordPress Inactive Plugins' . "\n\n";
378
+
379
+ foreach( $plugins as $plugin_path => $plugin ) {
380
+ if( in_array( $plugin_path, $active_plugins ) )
381
+ continue;
382
+
383
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
384
+ }
385
+
386
+ $return = apply_filters( 'quads_sysinfo_after_wordpress_plugins_inactive', $return );
387
+
388
+ if( is_multisite() ) {
389
+ // WordPress Multisite active plugins
390
+ $return .= "\n" . '-- Network Active Plugins' . "\n\n";
391
+
392
+ $plugins = wp_get_active_network_plugins();
393
+ $active_plugins = get_site_option( 'active_sitewide_plugins', array() );
394
+
395
+ foreach( $plugins as $plugin_path ) {
396
+ $plugin_base = plugin_basename( $plugin_path );
397
+
398
+ if( !array_key_exists( $plugin_base, $active_plugins ) )
399
+ continue;
400
+
401
+ $plugin = get_plugin_data( $plugin_path );
402
+ $return .= $plugin['Name'] . ': ' . $plugin['Version'] . "\n";
403
+ }
404
+
405
+ $return = apply_filters( 'quads_sysinfo_after_wordpress_ms_plugins', $return );
406
+ }
407
+
408
+ // Server configuration (really just versioning)
409
+ $return .= "\n" . '-- Webserver Configuration' . "\n\n";
410
+ $return .= 'PHP Version: ' . PHP_VERSION . "\n";
411
+ $return .= 'MySQL Version: ' . $wpdb->db_version() . "\n";
412
+ $return .= 'Webserver Info: ' . $_SERVER['SERVER_SOFTWARE'] . "\n";
413
+
414
+ $return = apply_filters( 'quads_sysinfo_after_webserver_config', $return );
415
+
416
+ // PHP configs... now we're getting to the important stuff
417
+ $return .= "\n" . '-- PHP Configuration' . "\n\n";
418
+ $return .= 'Safe Mode: ' . ( ini_get( 'safe_mode' ) ? 'Enabled' : 'Disabled' . "\n" );
419
+ $return .= 'Memory Limit: ' . ini_get( 'memory_limit' ) . "\n";
420
+ $return .= 'Upload Max Size: ' . ini_get( 'upload_max_filesize' ) . "\n";
421
+ $return .= 'Post Max Size: ' . ini_get( 'post_max_size' ) . "\n";
422
+ $return .= 'Upload Max Filesize: ' . ini_get( 'upload_max_filesize' ) . "\n";
423
+ $return .= 'Time Limit: ' . ini_get( 'max_execution_time' ) . "\n";
424
+ $return .= 'Max Input Vars: ' . ini_get( 'max_input_vars' ) . "\n";
425
+ $return .= 'Display Errors: ' . ( ini_get( 'display_errors' ) ? 'On (' . ini_get( 'display_errors' ) . ')' : 'N/A' ) . "\n";
426
+
427
+ $return = apply_filters( 'quads_sysinfo_after_php_config', $return );
428
+
429
+ // PHP extensions and such
430
+ $return .= "\n" . '-- PHP Extensions' . "\n\n";
431
+ $return .= 'cURL: ' . ( function_exists( 'curl_init' ) ? 'Supported' : 'Not Supported' ) . "\n";
432
+ $return .= 'fsockopen: ' . ( function_exists( 'fsockopen' ) ? 'Supported' : 'Not Supported' ) . "\n";
433
+ $return .= 'SOAP Client: ' . ( class_exists( 'SoapClient' ) ? 'Installed' : 'Not Installed' ) . "\n";
434
+ $return .= 'Suhosin: ' . ( extension_loaded( 'suhosin' ) ? 'Installed' : 'Not Installed' ) . "\n";
435
+
436
+ $return = apply_filters( 'quads_sysinfo_after_php_ext', $return );
437
+
438
+ $return .= "\n" . '### End System Info ###';
439
+
440
+ return $return;
441
+ }
442
+
443
+
444
+ /**
445
+ * Generates a System Info download file
446
+ *
447
+ * @since 2.0
448
+ * @return void
449
+ */
450
+ function quads_tools_sysinfo_download() {
451
+
452
+ if( ! current_user_can( 'update_plugins' ) )
453
+ return;
454
+
455
+ nocache_headers();
456
+
457
+ header( 'Content-Type: text/plain' );
458
+ header( 'Content-Disposition: attachment; filename="quads-system-info.txt"' );
459
+
460
+ echo wp_strip_all_tags( $_POST['quads-sysinfo'] );
461
+ wp_die();
462
+ }
463
+ add_action( 'quads_download_sysinfo', 'quads_tools_sysinfo_download' );
464
+
465
+ /*
466
+ * Import settings from Quick AdSense reloaded v. 1.9.2
467
+ */
468
+
469
+ function quads_import_quick_adsense_settings(){
470
+ // Check first if Quick AdSense is installed and version matches
471
+ if (!quads_check_quick_adsense_version())
472
+ return;
473
+
474
+
475
+ if( ! current_user_can( 'update_plugins' ) ) {
476
+ return;
477
+ }
478
+
479
+ do_action( 'quads_import_quick_adsense_settings_before' );
480
+ ?>
481
+ <div class="quads-postbox" id="quads-import-settings">
482
+ <h3><span><?php _e( 'Import from Quick AdSense', 'quick-adsense-reloaded' ); ?></span></h3>
483
+ <div class="inside">
484
+ <p><?php _e( 'Import the settings for Quick AdSense Reloaded from Quick AdSense v. 1.9.2.', 'quick-adsense-reloaded' ); ?></p>
485
+
486
+ <!--
487
+ <form id="quads_quick_adsense_input" method="post" action="<?php echo admin_url( 'admin.php?page=quads-settings&tab=imexport' ); ?>" onsubmit="return confirm('Importing the settings from Quick AdSense will overwrite all your current settings. Are you sure?');">
488
+ -->
489
+ <p><input type="hidden" name="quads-action" value="import_quick_adsense" /></p>
490
+ <p>
491
+ <?php wp_nonce_field( 'quads_quick_adsense_nonce', 'quads_quick_adsense_nonce' ); ?>
492
+ <?php submit_button( __( 'Start Import process', 'quick-adsense-reloaded' ), 'primary quads-import-settings', 'submit', false ); ?>
493
+ </p>
494
+ <!--</form>-->
495
+ <div id="quads-error-details"></div>
496
+ </div><!-- .inside -->
497
+ </div><!-- .postbox -->
498
+ <?php
499
+ do_action( 'quads_import_quick_adsense_settings_after' );
500
+ }
501
+ add_action( 'quads_import_quick_adsense_settings', 'quads_import_quick_adsense_settings' );
502
+
503
+ /**
504
+ * Ajax process a settings import from Quick AdSense
505
+ *
506
+ * @since 0.9.0
507
+ * @return string json
508
+ */
509
+ function quads_import_quick_adsense_process() {
510
+
511
+ check_ajax_referer( 'quads_ajax_nonce', 'nonce' );
512
+
513
+ if( ! current_user_can( 'manage_options' ) )
514
+ return;
515
+
516
+ ignore_user_abort( true );
517
+
518
+ if ( ! quads_is_func_disabled( 'set_time_limit' ) && ! ini_get( 'safe_mode' ) )
519
+ set_time_limit( 0 );
520
+
521
+
522
+ $quads_settings = get_quick_adsense_setting();
523
+ $quads_reloaded_settings = get_option('quads_settings');
524
+
525
+
526
+ if (update_option('quads_settings', $quads_settings ) ){
527
+ $message = __('Most of the settings have been sucessfully imported from Quick AdSense <br> but due to some inconsistencies there are still some options which needs your attention and manual adjusting.','quick-adsense-reloaded');
528
+ wp_send_json ( $message );
529
+ }
530
+
531
+ $message = __('Most of settings have been already imported successfully! (If not we probably have an unknown issue here)', 'quick-adsense-reloaded');
532
+ //$message = get_quick_adsense_setting();
533
+ wp_send_json ( $message );
534
+
535
+ }
536
+ //add_action( 'quads_import_quick_adsense', 'quads_import_quick_adsense_process' );
537
+ add_action('wp_ajax_quads_import_quick_adsense', 'quads_import_quick_adsense_process');
538
+
539
+ /**
540
+ * Check if Quick AdSense is installed and if version is 1.9.2
541
+ *
542
+ * @return boolean true when it is installed and version matches
543
+ */
544
+ function quads_check_quick_adsense_version(){
545
+ $plugin_file = 'quick-adsense/quick-adsense.php';
546
+ $plugin_abs_path = get_home_path() . '/wp-content/plugins/quick-adsense/quick-adsense.php';
547
+ $checkVersion = '1.9.2';
548
+
549
+ if ( is_plugin_active( $plugin_file ) ) {
550
+ $plugin_data = get_plugin_data( $plugin_abs_path, $markup = true, $translate = true );
551
+
552
+ if ($plugin_data['Version'] === $checkVersion)
553
+ return true;
554
+ }
555
+
556
+ if ( file_exists( $plugin_abs_path ) && is_plugin_inactive( $plugin_file ) ) {
557
+ $plugin_data = get_plugin_data( $plugin_abs_path, $markup = true, $translate = true );
558
+
559
+ if ($plugin_data['Version'] === $checkVersion)
560
+ return true;
561
+ }
562
+
563
+ }
564
+
565
+ /**
566
+ * Get all Quick AdSense settings and convert them to a Quick AdSense reloaded compatible array
567
+ *
568
+ * @since 0.9.0
569
+ * @return array
570
+ */
571
+ function get_quick_adsense_setting() {
572
+ $amountAds = 10;
573
+ $amountWidgets = 10;
574
+ $settings = array();
575
+ $new_align = '';
576
+
577
+
578
+ for ( $i = 1; $i <= $amountAds; $i++ ) {
579
+ if( get_option( 'AdsCode' . $i ) != '' ) {
580
+ $settings['ad' . $i]['code'] = get_option( 'AdsCode' . $i );
581
+ $settings['ad' . $i]['margin'] = get_option( 'AdsMargin' . $i );
582
+ //$settings['ad' . $i]['align'] = get_option( 'AdsAlign' . $i );
583
+ // convert the old margin values into the new ones
584
+ $old_align = get_option( 'AdsAlign' . $i );
585
+ if (isset($old_align) && $old_align === '1'){ // right
586
+ $new_align = '0';
587
+ } else if(isset($old_align) && $old_align === '2'){ // center
588
+ $new_align = '1';
589
+ } else if(isset($old_align) &&$old_align === '3'){ // right
590
+ $new_align = '2';
591
+ } else if(isset($old_align) &&$old_align === '4'){ // none
592
+ $new_align = '3';
593
+ }
594
+ $settings['ad' . $i]['align'] = $new_align;
595
+ }
596
+ }
597
+ for ( $i = 1; $i <= $amountWidgets; $i++ ) {
598
+ if( get_option( 'WidCode' . $i ) != '' ) {
599
+ $settings['ad' . $i . '_widget'] = get_option( 'WidCode' . $i );
600
+ }
601
+ }
602
+ $settings['maxads'] = get_option( 'AdsDisp' );
603
+ $settings['pos1']['BegnAds'] = get_option( 'BegnAds' );
604
+ $settings['pos1']['BegnRnd'] = get_option( 'BegnRnd' );
605
+ $settings['pos2']['MiddAds'] = get_option( 'MiddAds' );
606
+ $settings['pos2']['MiddRnd'] = get_option( 'MiddRnd' );
607
+ $settings['pos3']['EndiAds'] = get_option( 'EndiAds' );
608
+ $settings['pos3']['EndiRnd'] = get_option( 'EndiRnd' );
609
+ $settings['pos4']['MoreAds'] = get_option( 'MoreAds' );
610
+ $settings['pos4']['MoreRnd'] = get_option( 'MoreRnd' );
611
+ $settings['pos5']['LapaAds'] = get_option( 'LapaAds' );
612
+ $settings['pos5']['LapaRnd'] = get_option( 'LapaRnd' );
613
+ $rc = 3;
614
+ $value = 5;
615
+ for ( $j = 1; $j <= $rc; $j++ ) {
616
+ $key = $value + $j;
617
+ $settings['pos' . $key]['Par' . $j . 'Ads'] = get_option( 'Par' . $j . 'Ads' );
618
+ $settings['pos' . $key]['Par' . $j . 'Rnd'] = get_option( 'Par' . $j . 'Rnd' );
619
+ $settings['pos' . $key]['Par' . $j . 'Nup'] = get_option( 'Par' . $j . 'Nup' );
620
+ $settings['pos' . $key]['Par' . $j . 'Con'] = get_option( 'Par' . $j . 'Con' );
621
+ }
622
+ $settings['pos9']['Img1Ads'] = get_option( 'Img1Ads' );
623
+ $settings['pos9']['Img1Rnd'] = get_option( 'Img1Rnd' );
624
+ $settings['pos9']['Img1Nup'] = get_option( 'Img1Nup' );
625
+ $settings['pos9']['Img1Con'] = get_option( 'Img1Con' );
626
+ //$settings['visibility']['AppPost'] = get_option( 'AppPost' );
627
+ //$settings['visibility']['AppPage'] = get_option( 'AppPage' );
628
+ $settings['visibility']['AppHome'] = get_option( 'AppHome' );
629
+ $settings['visibility']['AppCate'] = get_option( 'AppCate' );
630
+ $settings['visibility']['AppArch'] = get_option( 'AppArch' );
631
+ $settings['visibility']['AppTags'] = get_option( 'AppTags' );
632
+ $settings['visibility']['AppMaxA'] = get_option( 'AppMaxA' );
633
+ $settings['visibility']['AppSide'] = get_option( 'AppSide' );
634
+ $settings['visibility']['AppLogg'] = get_option( 'AppLogg' );
635
+ $settings['quicktags']['QckTags'] = get_option( 'QckTags' );
636
+ $settings['quicktags']['QckRnds'] = get_option( 'QckRnds' );
637
+ $settings['quicktags']['QckOffs'] = get_option( 'QckOffs' );
638
+ $settings['quicktags']['QckOfPs'] = get_option( 'QckOfPs' );
639
+
640
+ // Get previous settings for AppPost and AppPage
641
+ $post_setting_old = (false !== get_option( 'AppPost' )) ? true : false;
642
+ $page_setting_old = (false !== get_option( 'AppPage' )) ? true : false;
643
+ // Store them in new array post_types
644
+ if (true === $post_setting_old && true === $page_setting_old) {
645
+ $settings['post_types'] = array('post', 'page');
646
+ } else if (true === $post_setting_old && false === $page_setting_old) {
647
+ $settings['post_types'] = array('post');
648
+ } else if (false === $post_setting_old && true === $page_setting_old) {
649
+ $settings['post_types'] = array('page');
650
+ }
651
+
652
+ $settings1 = quads_str_replace_json( "true", "1", $settings );
653
+ return $settings1;
654
+ }
655
+
656
+ /**
657
+ * A faster way to replace the strings in multidimensional array is to json_encode() it,
658
+ * do the str_replace() and then json_decode() it
659
+ *
660
+ * @param string $search
661
+ * @param string $replace
662
+ * @param array $subject
663
+ * @return array
664
+ */
665
+ function quads_str_replace_json($search, $replace, $subject){
666
+ $stdClass = json_decode(str_replace($search, $replace, json_encode($subject)));
667
+
668
+ return quads_object_to_array($stdClass);
669
+ }
670
+
671
+
672
+
673
+
includes/admin/upgrades/upgrade-functions.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Upgrade Functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Admin/Upgrades
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.3
11
+ */
12
+ // Exit if accessed directly
13
+ if( !defined( 'ABSPATH' ) )
14
+ exit;
15
+
16
+ /**
17
+ * Perform automatic upgrades when necessary
18
+ *
19
+ * @since 1.2.3
20
+ * @return void
21
+ */
22
+ function quads_do_automatic_upgrades() {
23
+
24
+ $did_upgrade = false;
25
+ // Get current installed version
26
+ $quads_version = preg_replace( '/[^0-9.].*/', '', get_option( 'quads_version' ) );
27
+
28
+ if( version_compare( $quads_version, '1.2.5', '<' ) ) {
29
+ quads_store_adsense_args();
30
+ }
31
+ if( version_compare( $quads_version, '1.2.7', '<' ) ) {
32
+ quads_change_widget_values();
33
+ }
34
+ if( version_compare( $quads_version, '1.4.0', '<' ) ) {
35
+ quads_import_post_type_settings();
36
+ quads_is_commercial_theme();
37
+ }
38
+
39
+ // Check if version number in DB is lower than version number of plugin
40
+ if( version_compare( $quads_version, QUADS_VERSION, '<' ) ) {
41
+ // Let us know that an upgrade has happened
42
+ $did_upgrade = true;
43
+ }
44
+
45
+ // Update Version number
46
+ if( $did_upgrade ) {
47
+ update_option( 'quads_version', preg_replace( '/[^0-9.].*/', '', QUADS_VERSION ) );
48
+ }
49
+ }
50
+ add_action( 'admin_init', 'quads_do_automatic_upgrades' );
51
+
52
+ /**
53
+ * Change array quads_settings['ad1_widget'] to quads_settings[ad1_widget][code]
54
+ *
55
+ * return mixed bool|void false when settings are empty
56
+ */
57
+ function quads_change_widget_values() {
58
+ $settings = get_option( 'quads_settings' );
59
+
60
+ if( empty( $settings ) ) {
61
+ return false;
62
+ }
63
+
64
+ foreach ( $settings as $key => $value ) {
65
+ if( $key === 'ad1_widget' && is_string( $settings['ad1_widget'] ) )
66
+ $new['ad1_widget']['code'] = $value;
67
+
68
+ else if( $key === 'ad2_widget' && is_string( $settings['ad2_widget'] ) )
69
+ $new['ad2_widget']['code'] = $value;
70
+
71
+ else if( $key === 'ad3_widget' && is_string( $settings['ad3_widget'] ) )
72
+ $new['ad3_widget']['code'] = $value;
73
+
74
+ else if( $key === 'ad4_widget' && is_string( $settings['ad4_widget'] ) )
75
+ $new['ad4_widget']['code'] = $value;
76
+
77
+ else if( $key === 'ad5_widget' && is_string( $settings['ad5_widget'] ) )
78
+ $new['ad5_widget']['code'] = $value;
79
+
80
+ else if( $key === 'ad6_widget' && is_string( $settings['ad6_widget'] ) )
81
+ $new['ad6_widget']['code'] = $value;
82
+
83
+ else if( $key === 'ad7_widget' && is_string( $settings['ad7_widget'] ) )
84
+ $new['ad7_widget']['code'] = $value;
85
+
86
+ else if( $key === 'ad8_widget' && is_string( $settings['ad8_widget'] ) )
87
+ $new['ad8_widget']['code'] = $value;
88
+
89
+ else if( $key === 'ad9_widget' && is_string( $settings['ad9_widget'] ) )
90
+ $new['ad9_widget']['code'] = $value;
91
+
92
+ else if( $key === 'ad10_widget' && is_string( $settings['ad10_widget'] ) )
93
+ $new['ad10_widget']['code'] = $value;
94
+ else
95
+ $new[$key] = $value;
96
+ }
97
+
98
+ update_option( 'quads_settings', $new );
99
+ //wp_die('<pre>' . var_dump($new));
100
+ }
101
+
102
+ /**
103
+ *
104
+ * @return mixed string | bool false name of the theme if theme is a known commercial theme
105
+ */
106
+ function quads_is_commercial_theme() {
107
+
108
+ // Get current theme name
109
+ $my_theme = wp_get_theme();
110
+
111
+ // Known commercial themes which are using WP QUADS
112
+ $themes = array('Bunchy', 'Bimber', 'boombox', 'Boombox');
113
+
114
+ if( is_object( $my_theme ) && in_array( $my_theme->get( 'Name' ), $themes ) ) {
115
+ update_option( 'quads_show_theme_notice', $my_theme->get( 'Name' ) );
116
+ return true;
117
+ }
118
+
119
+ return false;
120
+ }
121
+
122
+
123
+ /**
124
+ * Check if WP QUADS PRO is installed and version number is higher or equal 1.2.7
125
+ * @return boolean
126
+ */
127
+ function quads_is_advanced_1_2_7() {
128
+ if( quads_is_advanced() && version_compare( QUADS_PRO_VERSION, '1.2.7', '>=' ) ) {
129
+ return true;
130
+ }
131
+ return false;
132
+ }
133
+
134
+ /**
135
+ * Convert all post/page setting to new post_type global options array
136
+ * @global array $quads_options
137
+ * @return true if success
138
+ */
139
+ function quads_import_post_type_settings(){
140
+ global $quads_options;
141
+
142
+ // Get previous settings
143
+ $post_setting_old = isset($quads_options['visibility']['AppPost']) ? true : false;
144
+ $page_setting_old = isset($quads_options['visibility']['AppPage']) ? true : false;
145
+
146
+ // Store them in new array post_types
147
+ if (true === $post_setting_old && true === $page_setting_old) {
148
+ $quads_options['post_types'] = array('post', 'page');
149
+ } else if (true === $post_setting_old && false === $page_setting_old) {
150
+ $quads_options['post_types'] = array('post');
151
+ } else if (false === $post_setting_old && true === $page_setting_old) {
152
+ $quads_options['post_types'] = array('page');
153
+ } else {
154
+ // do nothing
155
+ }
156
+ update_option('quads_settings', $quads_options);
157
+ }
includes/admin/views/deactivate-feedback.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="quick-adsense-reloaded-feedback-overlay" style="display: none;">
2
+ <div id="quick-adsense-reloaded-feedback-content">
3
+ <form action="" method="post">
4
+ <h3><strong><?php _e('If you have a moment, please let us know why you are deactivating:', 'quick-adsense-reloaded'); ?></strong></h3>
5
+ <ul>
6
+ <li><label><input type="radio" name="quads_disable_reason" value="temporary"/><?php _e('It is only temporary', 'quick-adsense-reloaded'); ?></label></li>
7
+ <li><label><input type="radio" name="quads_disable_reason" value="stopped showing ads"/><?php _e('I stopped showing ads on my site', 'quick-adsense-reloaded'); ?></label></li>
8
+ <li><label><input type="radio" name="quads_disable_reason" value="missing feature"/><?php _e('I miss a feature', 'quick-adsense-reloaded'); ?></label></li>
9
+ <li><input type="text" name="quads_disable_text[]" value="" placeholder="Which one?"/></li>
10
+ <li><label><input type="radio" name="quads_disable_reason" value="technical issue"/><?php _e('I have a technical issue', 'quick-adsense-reloaded'); ?></label></li>
11
+ <li><textarea name="quads_disable_text[]" placeholder="<?php _e('Can we help? Please let us know how', 'quick-adsense-reloaded'); ?>"></textarea></li>
12
+ <li><label><input type="radio" name="quads_disable_reason" value="other plugin"/><?php _e('I switched to another plugin', 'quick-adsense-reloaded'); ?></label></li>
13
+ <li><input type="text" name="quads_disable_text[]" value="" placeholder="Which one?"/></li>
14
+ <li><label><input type="radio" name="quads_disable_reason" value="other"/><?php _e('other reason', 'quick-adsense-reloaded'); ?></label></li>
15
+ <li><textarea name="quads_disable_text[]" placeholder="<?php _e('Please specify, if possible', 'quick-adsense-reloaded'); ?>"></textarea></li>
16
+ </ul>
17
+ <?php if ($email) : ?>
18
+ <input type="hidden" name="quads_disable_from" value="<?php echo $email; ?>"/>
19
+ <?php endif; ?>
20
+ <input id="quick-adsense-reloaded-feedback-submit" class="button button-primary" type="submit" name="quads_disable_submit" value="<?php _e('Submit & Deactivate', 'quick-adsense-reloaded'); ?>"/>
21
+ <a class="button"><?php _e('Only Deactivate', 'quick-adsense-reloaded'); ?></a>
22
+ <a class="quick-adsense-reloaded-feedback-not-deactivate" href="#"><?php _e('Don\'t deactivate', 'quick-adsense-reloaded'); ?></a>
23
+ </form>
24
+ </div>
25
+ </div>
includes/admin/welcome.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Welcome Page Class
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Admin/Welcome
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 2.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ /**
16
+ * quads_Welcome Class
17
+ *
18
+ * A general class for About and Credits page.
19
+ *
20
+ * @since 1.4
21
+ */
22
+ class quads_Welcome {
23
+
24
+ /**
25
+ * @var string The capability users should have to view the page
26
+ */
27
+ public $minimum_capability = 'manage_options';
28
+
29
+ /**
30
+ * Get things started
31
+ *
32
+ * @since 1.0.1
33
+ */
34
+ public function __construct() {
35
+ add_action( 'admin_init', array( $this, 'welcome' ) );
36
+ }
37
+
38
+
39
+
40
+ /**
41
+ * Sends user to the Settings page on first activation of QUADS as well as each
42
+ * time QUADS is upgraded to a new version
43
+ *
44
+ * @access public
45
+ * @since 1.0.1
46
+ * @return void
47
+ */
48
+ public function welcome() {
49
+ // Bail if no activation redirect
50
+ if ( false === get_transient( 'quads_activation_redirect' ) ){
51
+ return;
52
+ }
53
+
54
+ // Delete the redirect transient
55
+ delete_transient( 'quads_activation_redirect' );
56
+
57
+ // Bail if activating from network, or bulk
58
+ if ( is_network_admin() || isset( $_GET['activate-multi'] ) ){
59
+ return;
60
+ }
61
+
62
+ $upgrade = get_option( 'quads_version_upgraded_from' );
63
+
64
+ //@since 2.0.3
65
+ if( ! $upgrade ) { // First time install
66
+ wp_safe_redirect( admin_url( 'admin.php?page=quads-addons' ) ); exit;
67
+ } else { // Update
68
+ wp_safe_redirect( admin_url( 'admin.php?page=quads-addons' ) ); exit;
69
+ }
70
+ }
71
+ }
72
+ new quads_Welcome();
includes/api.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * API Functions allow creation of custom ad positions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/API
8
+ * @copyright Copyright (c) 2015, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 0.9.9
11
+ */
12
+
13
+ /*
14
+ * Sample function for creating custom ad positions in your template files
15
+ * and option setting in WPQUADS admin settings.
16
+ *
17
+ * Use the code below in your functions.php to register custom ad positions:
18
+
19
+
20
+ <?php if (function_exists('quads_register_ad')){
21
+ quads_register_ad( array('location' => 'header', 'description' => 'Header position') );
22
+ quads_register_ad( array('location' => 'footer', 'description' => 'Footer position') );
23
+ quads_register_ad( array('location' => 'custom', 'description' => 'Custom position') );
24
+ }
25
+ ?>
26
+
27
+ Use this in your template files whereever you want to show a custom WPQUADS ad position on your site
28
+
29
+ <?php if (function_exists('quads_ad'))
30
+ echo quads_ad( array('location' => 'header') );
31
+ ?>
32
+ *
33
+ */
34
+
35
+
36
+ /**
37
+ * Register an ad position.
38
+ *
39
+ * @param array $args Location settings
40
+ */
41
+ function quads_register_ad( $args ) {
42
+ global $_quads_registered_ad_locations;
43
+ $defaults = array(
44
+ 'location' => '',
45
+ 'description' => ''
46
+ );
47
+ $args = wp_parse_args( $args, $defaults );
48
+ if ( empty( $args['location'] ) ) {
49
+ return;
50
+ }
51
+ if ( ! isset( $_quads_registered_ad_locations ) ) {
52
+ $_quads_registered_ad_locations = array();
53
+ }
54
+ $_quads_registered_ad_locations [ $args['location'] ] = $args;
55
+ }
56
+ /**
57
+ * Whether a registered ad location has an ad assigned to it.
58
+ *
59
+ * @param string $location Location id
60
+ * @return bool
61
+ */
62
+ function quads_has_ad( $location ) {
63
+ global $quads_options;
64
+ $result = false;
65
+
66
+ $location_settings = quads_get_ad_location_settings( $location );
67
+
68
+ if ( $location_settings['status'] && ! empty( $location_settings['ad'] ) ) {
69
+ $result = true;
70
+ }
71
+
72
+ if ( ! quads_ad_is_allowed() || quads_ad_reach_max_count() ) {
73
+ $result = false;
74
+ }
75
+
76
+ /**
77
+ * Filter whether an ad is assigned to the specified location.
78
+ */
79
+ return apply_filters( 'quads_has_ad', $result, $location );
80
+ }
81
+ /**
82
+ * Display an ad
83
+ *
84
+ * @param array $args Displaying options
85
+ * @return string|void Ad code or none if echo set to true
86
+ */
87
+ function quads_ad( $args ) {
88
+ $defaults = array(
89
+ 'location' => '',
90
+ 'echo' => true,
91
+ );
92
+ $args = wp_parse_args( $args, $defaults );
93
+ $code = '';
94
+
95
+ if ( quads_has_ad( $args['location'] ) ) {
96
+ global $quads_options;
97
+
98
+ quads_set_ad_count_custom(); // increase amount of shortcode ads
99
+
100
+ $location_settings = quads_get_ad_location_settings( $args['location'] );
101
+ $code .= "\n".'<!-- WP QUADS Custom Ad v. ' . QUADS_VERSION .' -->'."\n";
102
+ //$code .= $quads_options[ 'ad' . $location_settings['ad'] ]['code'];
103
+ $code .= '<div class="quads-location quads-ad' .$location_settings['ad']. '" id="quads-ad' .$location_settings['ad']. '">'."\n";
104
+ $code .= quads_render_ad( 'ad' . $location_settings['ad'], $quads_options[ 'ad' . $location_settings['ad'] ]['code'] );
105
+ $code .= '</div>';
106
+ }
107
+
108
+ if ( $args['echo'] ) {
109
+ echo $code;
110
+ } else {
111
+ return $code;
112
+ }
113
+ }
114
+ /**
115
+ * Return location settings.
116
+ *
117
+ * @param string $location Location id
118
+ * @return array
119
+ */
120
+ function quads_get_ad_location_settings( $location ) {
121
+ global $_quads_registered_ad_locations, $quads_options;
122
+
123
+ $result = array(
124
+ 'status' => false,
125
+ 'ad' => '',
126
+ );
127
+
128
+ $location_registered = isset( $_quads_registered_ad_locations ) && isset( $_quads_registered_ad_locations[ $location ] );
129
+ $location_settings_exist = isset( $quads_options['location_settings'] ) && isset( $quads_options['location_settings'][ $location ] );
130
+
131
+ if ( $location_registered && $location_settings_exist ) {
132
+ $result = wp_parse_args( $quads_options['location_settings'][ $location ], $result );
133
+ }
134
+
135
+ return $result;
136
+ }
includes/automattic-amp-ad.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Automattic AMP Functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Includes/automattic-amp-ad
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.9
11
+ */
12
+
13
+ add_action( 'amp_post_template_head', 'quads_amp_add_amp_ad_js' );
14
+ function quads_amp_add_amp_ad_js( $amp_template ) {
15
+ ?>
16
+ <script async custom-element="amp-ad" src="https://cdn.ampproject.org/v0/amp-ad-0.1.js"></script>
17
+ <?php
18
+ }
includes/class-quads-html-elements.php ADDED
@@ -0,0 +1,328 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * HTML elements
4
+ *
5
+ * A helper class for outputting common HTML elements, such as drop down and checkbox fields
6
+ *
7
+ * @package QUADS
8
+ * @subpackage Classes/HTML
9
+ * @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
10
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+ * @since 0.9.0
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) exit;
16
+
17
+ /**
18
+ * QUADS_HTML_Elements Class
19
+ *
20
+ * @since 0.9.0
21
+ */
22
+ class QUADS_HTML_Elements {
23
+
24
+
25
+ /**
26
+ * Renders an HTML Dropdown
27
+ *
28
+ * @since 0.9.0
29
+ *
30
+ * @param array $args
31
+ *
32
+ * @return string
33
+ */
34
+ public function select( $args = array() ) {
35
+ $defaults = array(
36
+ 'options' => array(),
37
+ 'name' => null,
38
+ 'class' => '',
39
+ 'id' => '',
40
+ 'selected' => 0,
41
+ 'chosen' => false,
42
+ 'placeholder' => null,
43
+ 'multiple' => false,
44
+ 'show_option_all' => _x( 'All', 'all dropdown items', 'easy-digital-downloads' ),
45
+ 'show_option_none' => _x( 'None', 'no dropdown items', 'easy-digital-downloads' )
46
+ );
47
+
48
+ $args = wp_parse_args( $args, $defaults );
49
+
50
+
51
+ if( $args['multiple'] ) {
52
+ $multiple = ' MULTIPLE';
53
+ } else {
54
+ $multiple = '';
55
+ }
56
+
57
+ if( $args['chosen'] ) {
58
+ $args['class'] .= ' quads-select-chosen';
59
+ }
60
+
61
+ if( $args['placeholder'] ) {
62
+ $placeholder = $args['placeholder'];
63
+ } else {
64
+ $placeholder = '';
65
+ }
66
+
67
+ $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="quads-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">';
68
+
69
+ if ( $args['show_option_all'] ) {
70
+ if( $args['multiple'] ) {
71
+ $selected = selected( true, in_array( 0, $args['selected'] ), false );
72
+ } else {
73
+ $selected = selected( $args['selected'], 0, false );
74
+ }
75
+ $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
76
+ }
77
+
78
+ if ( ! empty( $args['options'] ) ) {
79
+
80
+ if ( $args['show_option_none'] ) {
81
+ if( $args['multiple'] ) {
82
+ $selected = selected( true, in_array( -1, $args['selected'] ), false );
83
+ } else {
84
+ $selected = selected( $args['selected'], -1, false );
85
+ }
86
+ $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
87
+ }
88
+
89
+ foreach( $args['options'] as $key => $option ) {
90
+
91
+ if( $args['multiple'] && is_array( $args['selected'] ) ) {
92
+ $selected = selected( true, in_array( $key, $args['selected'] ), false );
93
+ } else {
94
+ $selected = selected( $args['selected'], $key, false );
95
+ }
96
+
97
+ $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
98
+ }
99
+ }
100
+
101
+ $output .= '</select>';
102
+
103
+ return $output;
104
+ }
105
+
106
+ /**
107
+ * Renders an HTML Checkbox
108
+ *
109
+ * @since 0.9.0
110
+ *
111
+ * @param array $args
112
+ *
113
+ * @return string
114
+ */
115
+ public function checkbox( $args = array() ) {
116
+ $defaults = array(
117
+ 'name' => null,
118
+ 'current' => null,
119
+ 'class' => 'quads-checkbox',
120
+ 'value' => "1",
121
+ 'options' => array(
122
+ 'disabled' => false,
123
+ 'readonly' => false
124
+ )
125
+
126
+ );
127
+
128
+ $args = wp_parse_args( $args, $defaults );
129
+
130
+ $options = '';
131
+ if ( ! empty( $args['options']['disabled'] ) ) {
132
+ $options .= ' disabled="disabled"';
133
+ } elseif ( ! empty( $args['options']['readonly'] ) ) {
134
+ $options .= ' readonly';
135
+ }
136
+
137
+ $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '"' . checked( $args['value'], $args['current'], false ) .' value="1" />';
138
+
139
+ return $output;
140
+ }
141
+
142
+ /**
143
+ * Renders an HTML Text field
144
+ *
145
+ * @since 0.9.0
146
+ *
147
+ * @param array $args Arguments for the text field
148
+ * @return string Text field
149
+ */
150
+ public function text( $args = array() ) {
151
+ // Backwards compatabliity
152
+ if ( func_num_args() > 1 ) {
153
+ $args = func_get_args();
154
+
155
+ $name = $args[0];
156
+ $value = isset( $args[1] ) ? $args[1] : '';
157
+ $label = isset( $args[2] ) ? $args[2] : '';
158
+ $desc = isset( $args[3] ) ? $args[3] : '';
159
+ }
160
+
161
+ $defaults = array(
162
+ 'id' => '',
163
+ 'name' => isset( $name ) ? $name : 'text',
164
+ 'value' => isset( $value ) ? $value : null,
165
+ 'label' => isset( $label ) ? $label : null,
166
+ 'desc' => isset( $desc ) ? $desc : null,
167
+ 'placeholder' => '',
168
+ 'class' => isset( $args['class'] ) ? 'regular-text ' . $args['class'] : 'regular-text',
169
+ 'disabled' => false,
170
+ 'autocomplete' => '',
171
+ 'data' => false
172
+ );
173
+
174
+ $args = wp_parse_args( $args, $defaults );
175
+
176
+ $disabled = '';
177
+ if( $args['disabled'] ) {
178
+ $disabled = ' disabled="disabled"';
179
+ }
180
+
181
+ $data = '';
182
+ if ( ! empty( $args['data'] ) ) {
183
+ foreach ( $args['data'] as $key => $value ) {
184
+ $data .= 'data-' . $key . '="' . $value . '" ';
185
+ }
186
+ }
187
+
188
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
189
+
190
+ $output .= '<label class="quads-label" for="' . sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
191
+
192
+ if ( ! empty( $args['desc'] ) ) {
193
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
194
+ }
195
+
196
+ $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
197
+
198
+ $output .= '</span>';
199
+
200
+ return $output;
201
+ }
202
+ /**
203
+ * Renders a date picker
204
+ *
205
+ * @since 0.9.0
206
+ *
207
+ * @param array $args Arguments for the text field
208
+ * @return string Datepicker field
209
+ */
210
+ public function date_field( $args = array() ) {
211
+
212
+ if( empty( $args['class'] ) ) {
213
+ $args['class'] = 'quads_datepicker';
214
+ } elseif( ! strpos( $args['class'], 'quads_datepicker' ) ) {
215
+ $args['class'] .= ' quads_datepicker';
216
+ }
217
+
218
+ return $this->text( $args );
219
+ }
220
+
221
+ /**
222
+ * Renders an HTML textarea
223
+ *
224
+ * @since 0.9.0
225
+ *
226
+ * @param array $args Arguments for the textarea
227
+ * @return string textarea
228
+ */
229
+ public function textarea( $args = array() ) {
230
+ $defaults = array(
231
+ 'name' => 'textarea',
232
+ 'value' => null,
233
+ 'label' => null,
234
+ 'desc' => null,
235
+ 'class' => 'large-text',
236
+ 'disabled' => false,
237
+ 'placeholder' => '',
238
+
239
+ );
240
+
241
+ $args = wp_parse_args( $args, $defaults );
242
+
243
+ $disabled = '';
244
+ if( $args['disabled'] ) {
245
+ $disabled = ' disabled="disabled"';
246
+ }
247
+
248
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
249
+
250
+ $output .= '<label class="quads-label" for="quads-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
251
+
252
+ $output .= '<textarea placeholder="' . esc_attr( $args['placeholder'] ) . '" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
253
+
254
+ if ( ! empty( $args['desc'] ) ) {
255
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
256
+ }
257
+
258
+ $output .= '</span>';
259
+
260
+ return $output;
261
+ }
262
+
263
+
264
+ /**
265
+ * Renders an HTML Dropdown of years
266
+ *
267
+ * @access public
268
+ * @since 0.9.0
269
+ * @param string $name Name attribute of the dropdown
270
+ * @param int $selected Year to select automatically
271
+ * @param int $years_before Number of years before the current year the dropdown should start with
272
+ * @param int $years_after Number of years after the current year the dropdown should finish at
273
+ * @return string $output Year dropdown
274
+ */
275
+ public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
276
+ $current = date( 'Y' );
277
+ $start_year = $current - absint( $years_before );
278
+ $end_year = $current + absint( $years_after );
279
+ $selected = empty( $selected ) ? date( 'Y' ) : $selected;
280
+ $options = array();
281
+
282
+ while ( $start_year <= $end_year ) {
283
+ $options[ absint( $start_year ) ] = $start_year;
284
+ $start_year++;
285
+ }
286
+
287
+ $output = $this->select( array(
288
+ 'name' => $name,
289
+ 'selected' => $selected,
290
+ 'options' => $options,
291
+ 'show_option_all' => false,
292
+ 'show_option_none' => false
293
+ ) );
294
+
295
+ return $output;
296
+ }
297
+
298
+ /**
299
+ * Renders an HTML Dropdown of months
300
+ *
301
+ * @access public
302
+ * @since 0.9.0
303
+ * @param string $name Name attribute of the dropdown
304
+ * @param int $selected Month to select automatically
305
+ * @return string $output Month dropdown
306
+ */
307
+ public function month_dropdown( $name = 'month', $selected = 0 ) {
308
+ $month = 1;
309
+ $options = array();
310
+ $selected = empty( $selected ) ? date( 'n' ) : $selected;
311
+
312
+ while ( $month <= 12 ) {
313
+ $options[ absint( $month ) ] = quads_month_num_to_name( $month );
314
+ $month++;
315
+ }
316
+
317
+ $output = $this->select( array(
318
+ 'name' => $name,
319
+ 'selected' => $selected,
320
+ 'options' => $options,
321
+ 'show_option_all' => false,
322
+ 'show_option_none' => false
323
+ ) );
324
+
325
+ return $output;
326
+ }
327
+
328
+ }
includes/class-quads-license-handler.php ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * License handler for WP QUADS
4
+ *
5
+ * This class should simplify the process of adding license information
6
+ * to WP QUADSs.
7
+ *
8
+ * @version 1.1
9
+ */
10
+
11
+ // Exit if accessed directly
12
+ if ( ! defined( 'ABSPATH' ) ) exit;
13
+
14
+ if ( ! class_exists( 'QUADS_License' ) ) :
15
+
16
+ /**
17
+ * QUADS_License Class
18
+ */
19
+ class QUADS_License {
20
+ private $file;
21
+ private $license;
22
+ private $item_name;
23
+ private $item_shortname;
24
+ private $version;
25
+ private $author;
26
+ private $api_url = 'http://wpquads.com/edd-sl-api/'; // production
27
+ //private $api_url = 'https://www.mashshare.net/edd-sl-api/'; // production
28
+ private $api_url_debug = 'http://src.wordpress-develop.dev/edd-sl-api/'; // development
29
+ /**
30
+ * Class constructor
31
+ *
32
+ * @global array $quads_options
33
+ * @param string $_file
34
+ * @param string $_item_name
35
+ * @param string $_version
36
+ * @param string $_author
37
+ * @param string $_optname
38
+ * @param string $_api_url
39
+ */
40
+ function __construct( $_file, $_item_name, $_version, $_author, $_optname = null, $_api_url = null ) {
41
+ global $quads_options;
42
+
43
+ $this->file = $_file;
44
+ $this->item_name = $_item_name;
45
+ $this->item_shortname = 'quads_' . preg_replace( '/[^a-zA-Z0-9_\s]/', '', str_replace( ' ', '_', strtolower( $this->item_name ) ) );
46
+ $this->version = $_version;
47
+ $this->license = isset( $quads_options[ $this->item_shortname . '_license_key' ] ) ? trim( $quads_options[ $this->item_shortname . '_license_key' ] ) : '';
48
+ $this->author = $_author;
49
+ if (QUADS_DEBUG){
50
+ $this->api_url = is_null( $_api_url ) ? $this->api_url_debug : $_api_url;
51
+ }else{
52
+ $this->api_url = is_null( $_api_url ) ? $this->api_url : $_api_url;
53
+ }
54
+
55
+
56
+
57
+ /**
58
+ * Allows for backwards compatibility with old license options,
59
+ * i.e. if the plugins had license key fields previously, the license
60
+ * handler will automatically pick these up and use those in lieu of the
61
+ * user having to reactive their license.
62
+ */
63
+ if ( ! empty( $_optname ) ) {
64
+ $opt = quads_get_option( $_optname, false );
65
+
66
+ if( isset( $opt ) && empty( $this->license ) ) {
67
+ $this->license = trim( $opt );
68
+ }
69
+ }
70
+
71
+ // Setup hooks
72
+ $this->includes();
73
+ $this->hooks();
74
+
75
+ }
76
+
77
+ /**
78
+ * Include the updater class
79
+ *
80
+ * @access private
81
+ * @return void
82
+ */
83
+ private function includes() {
84
+ if ( ! class_exists( 'QUADS_SL_Plugin_Updater' ) ) {
85
+ require_once 'QUADS_SL_Plugin_Updater.php';
86
+ }
87
+ }
88
+
89
+ /**
90
+ * Setup hooks
91
+ *
92
+ * @access private
93
+ * @return void
94
+ */
95
+ private function hooks() {
96
+
97
+ // Register settings
98
+ add_filter( 'quads_settings_licenses', array( $this, 'settings' ), 1 );
99
+
100
+ // Display help text at the top of the Licenses tab
101
+ add_action( 'quads_settings_tab_top', array( $this, 'license_help_text' ) );
102
+
103
+ // Activate license key on settings save
104
+ add_action( 'admin_init', array( $this, 'activate_license' ) );
105
+
106
+ // Deactivate license key
107
+ add_action( 'admin_init', array( $this, 'deactivate_license' ) );
108
+
109
+ // Check that license is valid once per week
110
+ add_action( 'quads_weekly_scheduled_events', array( $this, 'weekly_license_check' ) );
111
+
112
+ // For testing license notices, uncomment this line to force checks on every page load
113
+ //add_action( 'admin_init', array( $this, 'weekly_license_check' ) );
114
+
115
+ // Updater
116
+ add_action( 'admin_init', array( $this, 'auto_updater' ), 0 );
117
+
118
+ // Display notices to admins
119
+ add_action( 'admin_notices', array( $this, 'notices' ) );
120
+
121
+ add_action( 'in_plugin_update_message-' . plugin_basename( $this->file ), array( $this, 'plugin_row_license_missing' ), 10, 2 );
122
+
123
+ }
124
+
125
+ /**
126
+ * Auto updater
127
+ *
128
+ * @access private
129
+ * @return void
130
+ */
131
+ public function auto_updater() {
132
+
133
+ $args = array(
134
+ 'version' => $this->version,
135
+ 'license' => $this->license,
136
+ 'author' => $this->author
137
+ );
138
+
139
+ if( ! empty( $this->item_id ) ) {
140
+ $args['item_id'] = $this->item_id;
141
+ } else {
142
+ $args['item_name'] = $this->item_name;
143
+ }
144
+
145
+ // Setup the updater
146
+ $quads_updater = new QUADS_SL_Plugin_Updater(
147
+ $this->api_url,
148
+ $this->file,
149
+ $args
150
+ );
151
+ }
152
+
153
+
154
+ /**
155
+ * Add license field to settings
156
+ *
157
+ * @access public
158
+ * @param array $settings
159
+ * @return array
160
+ */
161
+ public function settings( $settings ) {
162
+ $quads_license_settings = array(
163
+ array(
164
+ 'id' => $this->item_shortname . '_license_key',
165
+ 'name' => sprintf( __( '%1$s License Key', 'quick-adsense-reloaded' ), $this->item_name ),
166
+ 'desc' => '',
167
+ 'type' => 'license_key',
168
+ 'options' => array( 'is_valid_license_option' => $this->item_shortname . '_license_active' ),
169
+ 'size' => 'regular'
170
+ )
171
+ );
172
+
173
+ return array_merge( $settings, $quads_license_settings );
174
+ }
175
+
176
+
177
+ /**
178
+ * Display help text at the top of the Licenses tag
179
+ *
180
+ * @access public
181
+ * @since 2.5
182
+ * @param string $active_tab
183
+ * @return void
184
+ */
185
+ public function license_help_text( $active_tab = '' ) {
186
+
187
+ static $has_ran;
188
+
189
+ if( 'licenses' !== $active_tab ) {
190
+ return;
191
+ }
192
+
193
+ if( ! empty( $has_ran ) ) {
194
+ return;
195
+ }
196
+
197
+ echo '<p>' . sprintf(
198
+ __( 'Enter your extension license keys here to receive updates for purchased extensions. If your license key has expired, please <a href="%s" target="_blank" title="License renewal FAQ">renew your license</a>.', 'quick-adsense-reloaded' ),
199
+ 'http://wpquads.com/renew-my-license/'
200
+ ) . '</p>';
201
+
202
+ $has_ran = true;
203
+
204
+ }
205
+
206
+
207
+ /**
208
+ * Activate the license key
209
+ *
210
+ * @access public
211
+ * @return void
212
+ */
213
+ public function activate_license() {
214
+
215
+
216
+ if ( ! isset( $_REQUEST[ $this->item_shortname . '_license_key-nonce'] ) || ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
217
+
218
+ return;
219
+
220
+ }
221
+
222
+ if ( ! current_user_can( 'manage_options' ) ) {
223
+ return;
224
+ }
225
+
226
+ if ( empty( $_POST['quads_settings'][ $this->item_shortname . '_license_key'] ) ) {
227
+
228
+ delete_option( $this->item_shortname . '_license_active' );
229
+
230
+ return;
231
+
232
+ }
233
+
234
+ foreach ( $_POST as $key => $value ) {
235
+ if( false !== strpos( $key, 'license_key_deactivate' ) ) {
236
+ // Don't activate a key when deactivating a different key
237
+ return;
238
+ }
239
+ }
240
+
241
+ $details = get_option( $this->item_shortname . '_license_active' );
242
+
243
+ if ( is_object( $details ) && 'valid' === $details->license ) {
244
+ return;
245
+ }
246
+
247
+ $license = sanitize_text_field( $_POST['quads_settings'][ $this->item_shortname . '_license_key'] );
248
+
249
+ if( empty( $license ) ) {
250
+ return;
251
+ }
252
+
253
+ // Data to send to the API
254
+ $api_params = array(
255
+ 'edd_action' => 'activate_license',
256
+ 'license' => $license,
257
+ 'item_name' => urlencode( $this->item_name ),
258
+ 'url' => home_url()
259
+ );
260
+
261
+ // Call the API
262
+ $response = wp_remote_post(
263
+ $this->api_url,
264
+ array(
265
+ 'timeout' => 15,
266
+ 'sslverify' => false,
267
+ 'body' => $api_params
268
+ )
269
+ );
270
+
271
+ // Make sure there are no errors
272
+ if ( is_wp_error( $response ) ) {
273
+ return;
274
+ }
275
+
276
+ // Tell WordPress to look for updates
277
+ set_site_transient( 'update_plugins', null );
278
+
279
+ // Decode license data
280
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
281
+
282
+ update_option( $this->item_shortname . '_license_active', $license_data );
283
+
284
+ }
285
+
286
+
287
+ /**
288
+ * Deactivate the license key
289
+ *
290
+ * @access public
291
+ * @return void
292
+ */
293
+ public function deactivate_license() {
294
+
295
+ if ( ! isset( $_POST['quads_settings'] ) )
296
+ return;
297
+
298
+ if ( ! isset( $_POST['quads_settings'][ $this->item_shortname . '_license_key'] ) )
299
+ return;
300
+
301
+ if( ! wp_verify_nonce( $_REQUEST[ $this->item_shortname . '_license_key-nonce'], $this->item_shortname . '_license_key-nonce' ) ) {
302
+
303
+ wp_die( __( 'Nonce verification failed', 'quick-adsense-reloaded' ), __( 'Error', 'quick-adsense-reloaded' ), array( 'response' => 403 ) );
304
+
305
+ }
306
+
307
+ if( ! current_user_can( 'manage_options' ) ) {
308
+ return;
309
+ }
310
+
311
+ // Run on deactivate button press
312
+ if ( isset( $_POST[ $this->item_shortname . '_license_key_deactivate'] ) ) {
313
+
314
+ // Data to send to the API
315
+ $api_params = array(
316
+ 'edd_action' => 'deactivate_license',
317
+ 'license' => $this->license,
318
+ 'item_name' => urlencode( $this->item_name ),
319
+ 'url' => home_url()
320
+ );
321
+
322
+ // Call the API
323
+ $response = wp_remote_post(
324
+ $this->api_url,
325
+ array(
326
+ 'timeout' => 15,
327
+ 'sslverify' => false,
328
+ 'body' => $api_params
329
+ )
330
+ );
331
+
332
+ // Make sure there are no errors
333
+ if ( is_wp_error( $response ) ) {
334
+ return;
335
+ }
336
+
337
+ // Decode the license data
338
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
339
+
340
+ delete_option( $this->item_shortname . '_license_active' );
341
+
342
+ }
343
+ }
344
+
345
+
346
+ /**
347
+ * Check if license key is valid once per week
348
+ *
349
+ * @access public
350
+ * @since 2.5
351
+ * @return void
352
+ */
353
+ public function weekly_license_check() {
354
+
355
+ if( ! empty( $_POST['quads_settings'] ) ) {
356
+ return; // Don't fire when saving settings
357
+ }
358
+
359
+ if( empty( $this->license ) ) {
360
+ return;
361
+ }
362
+
363
+ // data to send in our API request
364
+ $api_params = array(
365
+ 'edd_action'=> 'check_license',
366
+ 'license' => $this->license,
367
+ 'item_name' => urlencode( $this->item_name ),
368
+ 'url' => home_url()
369
+ );
370
+
371
+ // Call the API
372
+ $response = wp_remote_post(
373
+ $this->api_url,
374
+ array(
375
+ 'timeout' => 15,
376
+ 'sslverify' => false,
377
+ 'body' => $api_params
378
+ )
379
+ );
380
+
381
+ // make sure the response came back okay
382
+ if ( is_wp_error( $response ) ) {
383
+ return false;
384
+ }
385
+
386
+ $license_data = json_decode( wp_remote_retrieve_body( $response ) );
387
+
388
+ update_option( $this->item_shortname . '_license_active', $license_data );
389
+
390
+ }
391
+
392
+
393
+ /**
394
+ * Admin notices for errors
395
+ *
396
+ * @access public
397
+ * @return void
398
+ */
399
+ public function notices() {
400
+
401
+ static $showed_invalid_message;
402
+
403
+ if( empty( $this->license ) ) {
404
+ return;
405
+ }
406
+
407
+ if( ! current_user_can( 'manage_options' ) ) {
408
+ return;
409
+ }
410
+
411
+ $messages = array();
412
+
413
+ $license = get_option( $this->item_shortname . '_license_active' );
414
+
415
+ if( is_object( $license ) && 'valid' !== $license->license && empty( $showed_invalid_message ) ) {
416
+
417
+ if( empty( $_GET['tab'] ) || 'licenses' !== $_GET['tab'] ) {
418
+
419
+ $messages[] = sprintf(
420
+ __( 'You have invalid or expired license keys for WPQUADS PRO. Please go to the <a href="%s" title="Go to Licenses page">Licenses page</a> to correct this issue.', 'quick-adsense-reloaded' ),
421
+ admin_url( 'admin.php?page=quads-settings&tab=licenses' )
422
+ );
423
+
424
+ $showed_invalid_message = true;
425
+
426
+ }
427
+
428
+ }
429
+
430
+ if( ! empty( $messages ) ) {
431
+
432
+ foreach( $messages as $message ) {
433
+
434
+ echo '<div class="error">';
435
+ echo '<p>' . $message . '</p>';
436
+ echo '</div>';
437
+
438
+ }
439
+
440
+ }
441
+
442
+ }
443
+
444
+ /**
445
+ * Displays message inline on plugin row that the license key is missing
446
+ *
447
+ * @access public
448
+ * @since 2.5
449
+ * @return void
450
+ */
451
+ public function plugin_row_license_missing( $plugin_data, $version_info ) {
452
+
453
+ static $showed_imissing_key_message;
454
+
455
+ $license = get_option( $this->item_shortname . '_license_active' );
456
+
457
+ if( ( ! is_object( $license ) || 'valid' !== $license->license ) && empty( $showed_imissing_key_message[ $this->item_shortname ] ) ) {
458
+
459
+ echo '&nbsp;<strong><a href="' . esc_url( admin_url( 'admin.php?page=quads-settings&tab=licenses' ) ) . '">' . __( 'Enter valid license key for automatic updates.', 'quick-adsense-reloaded' ) . '</a></strong>';
460
+ $showed_imissing_key_message[ $this->item_shortname ] = true;
461
+ }
462
+
463
+ }
464
+ }
465
+
466
+ endif; // end class_exists check
includes/conditionals.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Conditionals
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/conditionals
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.8
11
+ */
12
+
13
+
14
+
15
+ /**
16
+ * Determine if ads are visible
17
+ *
18
+ * @global arr $quads_options
19
+ * @param string $content
20
+ * @since 0.9.4
21
+ * @return boolean true when ads are shown
22
+ */
23
+ function quads_ad_is_allowed( $content = null ) {
24
+ global $quads_options;
25
+
26
+ // Only show ads in main query
27
+ if( !is_main_query() ) {
28
+ return false;
29
+ }
30
+
31
+ $hide_ads = apply_filters('quads_hide_ads', false);
32
+
33
+ if(
34
+ (is_feed()) ||
35
+ (is_search()) ||
36
+ (is_404() ) ||
37
+ (strpos( $content, '<!--NoAds-->' ) !== false) ||
38
+ (strpos( $content, '<!--OffAds-->' ) !== false) ||
39
+ (is_front_page() && !( isset( $quads_options['visibility']['AppHome'] ) ) ) ||
40
+ //(is_single() && !( isset( $quads_options['visibility']['AppPost'] ) ) ) ||
41
+ //(is_page() && !( isset( $quads_options['visibility']['AppPage'] ) ) ) ||
42
+ (is_category() && !(isset( $quads_options['visibility']['AppCate'] ) ) ) ||
43
+ (is_archive() && !( isset( $quads_options['visibility']['AppArch'] ) ) ) ||
44
+ (is_tag() && !( isset( $quads_options['visibility']['AppTags'] ) ) ) ||
45
+ (!quads_user_roles_permission()) ||
46
+ (!quads_post_type_allowed()) ||
47
+ (is_user_logged_in() && ( isset( $quads_options['visibility']['AppLogg'] ) ) ) ||
48
+ true === $hide_ads
49
+ ) {
50
+ return false;
51
+ }
52
+ // else
53
+ return true;
54
+ }
55
+
56
+
57
+
58
+ /**
59
+ * Get the total number of active ads
60
+ *
61
+ * @global int $visibleShortcodeAds
62
+ * @global int $visibleContentAdsGlobal
63
+ * @global int $ad_count_custom
64
+ * @global int $ad_count_widget
65
+ * @return int number of active ads
66
+ */
67
+ function quads_get_total_ad_count(){
68
+ global $visibleShortcodeAds, $visibleContentAdsGlobal, $ad_count_custom, $ad_count_widget;
69
+
70
+ $shortcode = isset($visibleShortcodeAds) ? (int)$visibleShortcodeAds : 0;
71
+ $content = isset($visibleContentAdsGlobal) ? (int)$visibleContentAdsGlobal : 0;
72
+ $custom = isset($ad_count_custom) ? (int)$ad_count_custom : 0;
73
+ $widget = isset($ad_count_widget) ? (int)$ad_count_widget : 0;
74
+
75
+ return $shortcode + $content + $custom + $widget;
76
+ }
77
+
78
+ /**
79
+ * Check if the maximum amount of ads are reached
80
+ *
81
+ * @global arr $quads_options settings
82
+ * @var int amount of ads to activate
83
+
84
+ * @return bool true if max is reached
85
+ */
86
+
87
+ function quads_ad_reach_max_count(){
88
+ global $quads_options;
89
+
90
+ $maxads = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
91
+ if ( quads_get_total_ad_count() >= $maxads ){
92
+ return true;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Increment count of active ads generated in the_content
98
+ *
99
+ * @global int $ad_count
100
+ * @param type $ad_count
101
+ * @return int amount of active ads in the_content
102
+ */
103
+ function quads_set_ad_count_content(){
104
+ global $visibleContentAdsGlobal;
105
+
106
+ $visibleContentAdsGlobal++;
107
+ return $visibleContentAdsGlobal;
108
+ }
109
+
110
+ /**
111
+ * Increment count of active ads generated with shortcodes
112
+ *
113
+ * @return int amount of active shortcode ads in the_content
114
+ */
115
+ function quads_set_ad_count_shortcode(){
116
+ global $visibleShortcodeAds;
117
+
118
+ $visibleShortcodeAds++;
119
+ return $visibleShortcodeAds;
120
+ }
121
+
122
+ /**
123
+ * Increment count of custom active ads
124
+ *
125
+ * @return int amount of active custom ads
126
+ */
127
+ function quads_set_ad_count_custom(){
128
+ global $ad_count_custom;
129
+
130
+ $ad_count_custom++;
131
+ return $ad_count_custom;
132
+ }
133
+
134
+ /**
135
+ * Increment count of active ads generated on widgets
136
+ *
137
+ * @return int amount of active widget ads
138
+ */
139
+ function quads_set_ad_count_widget(){
140
+ global $ad_count_widget;
141
+
142
+ $ad_count_widget++;
143
+ return $ad_count_widget;
144
+ }
145
+
includes/helper-functions.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Helper Functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Helper/Templates
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.4.0
11
+ */
12
+ // Exit if accessed directly
13
+ if( !defined( 'ABSPATH' ) )
14
+ exit;
15
+
16
+ /**
17
+ * Helper method to check if user is in the plugins page.
18
+ *
19
+ * @author René Hermenau
20
+ * @since 1.4.0
21
+ *
22
+ * @return bool
23
+ */
24
+ function quads_is_plugins_page() {
25
+ global $pagenow;
26
+
27
+ return ( 'plugins.php' === $pagenow );
28
+ }
29
+
30
+ /**
31
+ * display deactivation logic on plugins page
32
+ *
33
+ * @since 1.7.14
34
+ */
35
+ function quads_add_deactivation_feedback_modal() {
36
+
37
+ $screen = get_current_screen();
38
+ if( !is_admin() && !quads_is_plugins_page()) {
39
+ return;
40
+ }
41
+
42
+ $current_user = wp_get_current_user();
43
+ if( !($current_user instanceof WP_User) ) {
44
+ $email = '';
45
+ } else {
46
+ $email = trim( $current_user->user_email );
47
+ }
48
+
49
+ include QUADS_PLUGIN_DIR . 'includes/admin/views/deactivate-feedback.php';
50
+ }
51
+
52
+ /**
53
+ * send feedback via email
54
+ *
55
+ * @since 1.4.0
56
+ */
57
+ function quads_send_feedback() {
58
+
59
+ if( isset( $_POST['data'] ) ) {
60
+ parse_str( $_POST['data'], $form );
61
+ }
62
+
63
+ $text = '';
64
+ if( isset( $form['quads_disable_text'] ) ) {
65
+ $text = implode( "\n\r", $form['quads_disable_text'] );
66
+ }
67
+
68
+ $headers = array();
69
+
70
+ $from = isset( $form['quads_disable_from'] ) ? $form['quads_disable_from'] : '';
71
+ if( $from ) {
72
+ $headers[] = "From: $from";
73
+ $headers[] = "Reply-To: $from";
74
+ }
75
+
76
+ $subject = isset( $form['quads_disable_reason'] ) ? $form['quads_disable_reason'] : '(no reason given)';
77
+
78
+ $success = wp_mail( 'makebetter@wpquads.com', $subject, $text, $headers );
79
+
80
+ //error_log(print_r($success, true));
81
+ //error_log($from . $subject . var_dump($form));
82
+ die();
83
+ }
84
+ add_action( 'wp_ajax_quads_send_feedback', 'quads_send_feedback' );
85
+
includes/libraries/RolingCurlX.php ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ * Based on RollingCurlX https://github.com/marcushat/rollingcurlx
4
+ *
5
+ * Modified for Quick AdSense Reloaded by René Hermenau to be compatible with php 5.3 and older versions
6
+ *
7
+ * @scince 2.2.7
8
+ */
9
+ Class RollingCurlX {
10
+ private $_maxConcurrent = 0; //max. number of simultaneous connections allowed
11
+ private $_options = array(); //shared cURL options
12
+ private $_headers = array(); //shared cURL request headers
13
+ private $_callback = NULL; //default callback
14
+ private $_timeout = 1; //timeout used for curl_multi_select() function in seconds. Lower this to zero increases total performance.
15
+ private $requests = array(); //request_queue
16
+
17
+ function __construct($max_concurrent = 10) {
18
+ $this->setMaxConcurrent($max_concurrent);
19
+ }
20
+
21
+ public function setMaxConcurrent($max_requests) {
22
+ if($max_requests > 0) {
23
+ $this->_maxConcurrent = $max_requests;
24
+ }
25
+ }
26
+
27
+ public function setOptions(array $options) {
28
+ $this->_options = $options;
29
+ }
30
+
31
+ public function setHeaders(array $headers) {
32
+ if(is_array($headers) && count($headers)) {
33
+ $this->_headers = $headers;
34
+ }
35
+ }
36
+
37
+
38
+ //public function setCallback(callable $callback) {
39
+ public function setCallback($callback) {
40
+ $this->_callback = $callback;
41
+ }
42
+
43
+ /* Bug on php 5.3 Do not use this
44
+
45
+ */
46
+ /*public function setTimeout($timeout) { //in milliseconds
47
+ if($timeout > 0) {
48
+ $this->_timeout = $timeout/1000; //to seconds
49
+ }
50
+ }*/
51
+
52
+ //Add a request to the request queue
53
+ public function addRequest(
54
+ $url,
55
+ array $post_data = NULL,
56
+ //callable $callback = NULL, //individual callback rhe
57
+ //$callback = NULL, //individual callback
58
+ array $callback = NULL,
59
+ $user_data = NULL,
60
+ array $options = NULL, //individual cURL options
61
+ array $headers = NULL //individual cURL request headers
62
+ ) { //Add to request queue
63
+ $this->requests[] = array(
64
+ 'url' => $url,
65
+ 'post_data' => ($post_data) ? $post_data : NULL,
66
+ 'callback' => ($callback) ? $callback : $this->_callback,
67
+ 'user_data' => ($user_data) ? $user_data : NULL,
68
+ 'options' => ($options) ? $options : NULL,
69
+ 'headers' => ($headers) ? $headers : NULL
70
+ );
71
+ return count($this->requests) - 1; //return request number/index
72
+ }
73
+
74
+ //Reset request queue
75
+ public function reset() {
76
+ $this->requests = array();
77
+ }
78
+
79
+ //Execute the request queue
80
+ public function execute() {
81
+ if(count($this->requests) < $this->_maxConcurrent) {
82
+ $this->_maxConcurrent = count($this->requests);
83
+ }
84
+ //the request map that maps the request queue to request curl handles
85
+ $requests_map = array();
86
+ $multi_handle = curl_multi_init();
87
+ //start processing the initial request queue
88
+ for($i = 0; $i < $this->_maxConcurrent; $i++) {
89
+ $ch = curl_init();
90
+
91
+ $request =& $this->requests[$i];
92
+ $this->addTimer($request);
93
+
94
+ curl_setopt_array($ch, $this->buildOptions($request));
95
+ curl_multi_add_handle($multi_handle, $ch);
96
+
97
+
98
+ //add curl handle of a request to the request map
99
+ $key = (string) $ch;
100
+ $requests_map[$key] = $i;
101
+ }
102
+ do{
103
+ while(($mh_status = curl_multi_exec($multi_handle, $active)) == CURLM_CALL_MULTI_PERFORM);
104
+ if($mh_status != CURLM_OK) {
105
+ break;
106
+ }
107
+
108
+ //a request is just completed, find out which one
109
+ while($completed = curl_multi_info_read($multi_handle)) {
110
+ $ch = $completed['handle'];
111
+ $request_info = curl_getinfo($ch);
112
+ if(curl_errno($ch) !== 0 || intval($request_info['http_code']) !== 200) { //if server responded with http error
113
+ $response = false;
114
+ } else { //sucessful response
115
+ $response = curl_multi_getcontent($ch);
116
+ }
117
+
118
+ //get request info
119
+ $key = (string) $ch;
120
+ $request =& $this->requests[$requests_map[$key]]; //map handler to request index to get request info
121
+ $url = $request['url'];
122
+ $callback = $request['callback'];
123
+ $user_data = $request['user_data'];
124
+ $options = $request['options'];
125
+ $this->stopTimer($request); //record request time
126
+ $time = $request['time'];
127
+
128
+ if($response && (isset($this->_options[CURLOPT_HEADER]) || isset($options[CURLOPT_HEADER]))) {
129
+ $k = intval($request_info['header_size']);
130
+ $request_info['response_header'] = substr($response, 0, $k);
131
+ $response = substr($response, $k);
132
+ }
133
+
134
+ //remove completed request and its curl handle
135
+ unset($requests_map[$key]);
136
+ curl_multi_remove_handle($multi_handle, $ch);
137
+
138
+ //call the callback function and pass request info and user data to it
139
+ if($callback) {
140
+ call_user_func($callback, $response, $url, $request_info, $user_data, $time);
141
+ }
142
+ $request = NULL; //free up memory now just incase response was large
143
+
144
+ //add/start a new request to the request queue
145
+ if($i < count($this->requests) && isset($this->requests[$i])) { //if requests left
146
+ $ch = curl_init();
147
+
148
+ $request =& $this->requests[$i];
149
+ $this->addTimer($request);
150
+
151
+ curl_setopt_array($ch, $this->buildOptions($request));
152
+ curl_multi_add_handle($multi_handle, $ch);
153
+
154
+ //add curl handle of a new request to the request map
155
+ $key = (string) $ch;
156
+ $requests_map[$key] = $i;
157
+ $i++;
158
+ }
159
+ }
160
+ if($active) {
161
+ if(curl_multi_select($multi_handle, $this->_timeout) === -1) { //wait for activity on any connection
162
+ usleep(5);
163
+ }
164
+
165
+ }
166
+ } while ($active || count($requests_map)); //End do-while
167
+
168
+ $this->reset();
169
+ curl_multi_close($multi_handle);
170
+ }
171
+
172
+
173
+
174
+ //Build individual cURL options for a request
175
+ private function buildOptions(array $request) {
176
+ $url = $request['url'];
177
+ $post_data = $request['post_data'];
178
+ $individual_opts = $request['options'];
179
+ $individual_headers = $request['headers'];
180
+
181
+ $options = ($individual_opts) ? $individual_opts + $this->_options : $this->_options; //merge shared and individual request options
182
+ $headers = ($individual_headers) ? $individual_headers + $this->_headers : $this->_headers; //merge shared and individual request headers
183
+
184
+ //the below will overide the corresponding default or individual options
185
+ $options[CURLOPT_RETURNTRANSFER] = true;
186
+ //$options[CURLOPT_TIMEOUT] = $this->_timeout; //timeout in ms. bug in php 5.3
187
+ $options[CURLOPT_TIMEOUT] = 5; //timeout in seconds;
188
+ if($url) {
189
+ $options[CURLOPT_URL] = $url;
190
+ }
191
+
192
+ if($headers) {
193
+ $options[CURLOPT_HTTPHEADER] = $headers;
194
+ }
195
+
196
+ // enable POST method and set POST parameters
197
+ if($post_data) {
198
+ $options[CURLOPT_POST] = 1;
199
+ $options[CURLOPT_POSTFIELDS] = is_array($post_data)? http_build_query($post_data) : $post_data;
200
+ }
201
+ return $options;
202
+ }
203
+
204
+
205
+
206
+ private function addTimer(array &$request) { //adds timer object to request
207
+ $request['timer'] = microtime(true);
208
+ $request['time'] = false; //default if not overridden by time later
209
+ }
210
+
211
+ private function stopTimer(array &$request) {
212
+ $start_time = $request['timer'];
213
+ $end_time = microtime(true);
214
+ $elapsed_time = rtrim(sprintf('%.20F', ($end_time - $start_time)), '0') . 'secs'; //convert float to string
215
+ $request['time'] = $elapsed_time*1000; //
216
+ unset($request['timer']);
217
+ }
218
+ }
includes/libraries/browser.php ADDED
@@ -0,0 +1,1082 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Modified to remove var
4
+ * Chris Christoff on 12/26/2012
5
+ * Changes: Changes vars to publics
6
+ *
7
+ * Modified to work for EDD by
8
+ * Chris Christoff on 12/23/2012
9
+ * Changes: Removed the browser string return and added spacing. Also removed return HTML formatting.
10
+ *
11
+ * Modified to add formatted User Agent string for EDD System Info by
12
+ * Chris Christoff on 12/23/2012
13
+ * Changes: Split user string and add formatting so we can print a nicely
14
+ * formatted user agent string on the EDD System Info
15
+ *
16
+ * File: Browser.php
17
+ * Author: Chris Schuld (http://chrisschuld.com/)
18
+ * Last Modified: August 20th, 2010
19
+ * @version 1.9
20
+ * @package PegasusPHP
21
+ *
22
+ * Copyright (C) 2008-2010 Chris Schuld (chris@chrisschuld.com)
23
+ *
24
+ * This program is free software; you can redistribute it and/or
25
+ * modify it under the terms of the GNU General Public License as
26
+ * published by the Free Software Foundation; either version 2 of
27
+ * the License, or (at your option) any later version.
28
+ *
29
+ * This program is distributed in the hope that it will be useful,
30
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
31
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
32
+ * GNU General Public License for more details at:
33
+ * http://www.gnu.org/copyleft/gpl.html
34
+ *
35
+ *
36
+ * Typical Usage:
37
+ *
38
+ * $browser = new Browser();
39
+ * if( $browser->getBrowser() == Browser::BROWSER_FIREFOX && $browser->getVersion() >= 2 ) {
40
+ * echo 'You have FireFox version 2 or greater';
41
+ * }
42
+ *
43
+ * User Agents Sampled from: http://www.useragentstring.com/
44
+ *
45
+ * This implementation is based on the original work from Gary White
46
+ * http://apptools.com/phptools/browser/
47
+ *
48
+ * UPDATES:
49
+ *
50
+ * 2010-08-20 (v1.9):
51
+ * + Added MSN Explorer Browser (legacy)
52
+ * + Added Bing/MSN Robot (Thanks Rob MacDonald)
53
+ * + Added the Android Platform (PLATFORM_ANDROID)
54
+ * + Fixed issue with Android 1.6/2.2 (Thanks Tom Hirashima)
55
+ *
56
+ * 2010-04-27 (v1.8):
57
+ * + Added iPad Support
58
+ *
59
+ * 2010-03-07 (v1.7):
60
+ * + *MAJOR* Rebuild (preg_match and other "slow" routine removal(s))
61
+ * + Almost allof Gary's original code has been replaced
62
+ * + Large PHPUNIT testing environment created to validate new releases and additions
63
+ * + Added FreeBSD Platform
64
+ * + Added OpenBSD Platform
65
+ * + Added NetBSD Platform
66
+ * + Added SunOS Platform
67
+ * + Added OpenSolaris Platform
68
+ * + Added support of the Iceweazel Browser
69
+ * + Added isChromeFrame() call to check if chromeframe is in use
70
+ * + Moved the Opera check in front of the Firefox check due to legacy Opera User Agents
71
+ * + Added the __toString() method (Thanks Deano)
72
+ *
73
+ * 2009-11-15:
74
+ * + Updated the checkes for Firefox
75
+ * + Added the NOKIA platform
76
+ * + Added Checks for the NOKIA brower(s)
77
+ *
78
+ * 2009-11-08:
79
+ * + PHP 5.3 Support
80
+ * + Added support for BlackBerry OS and BlackBerry browser
81
+ * + Added support for the Opera Mini browser
82
+ * + Added additional documenation
83
+ * + Added support for isRobot() and isMobile()
84
+ * + Added support for Opera version 10
85
+ * + Added support for deprecated Netscape Navigator version 9
86
+ * + Added support for IceCat
87
+ * + Added support for Shiretoko
88
+ *
89
+ * 2010-04-27 (v1.8):
90
+ * + Added iPad Support
91
+ *
92
+ * 2009-08-18:
93
+ * + Updated to support PHP 5.3 - removed all deprecated function calls
94
+ * + Updated to remove all double quotes (") -- converted to single quotes (')
95
+ *
96
+ * 2009-04-27:
97
+ * + Updated the IE check to remove a typo and bug (thanks John)
98
+ *
99
+ * 2009-04-22:
100
+ * + Added detection for GoogleBot
101
+ * + Added detection for the W3C Validator.
102
+ * + Added detection for Yahoo! Slurp
103
+ *
104
+ * 2009-03-14:
105
+ * + Added detection for iPods.
106
+ * + Added Platform detection for iPhones
107
+ * + Added Platform detection for iPods
108
+ *
109
+ * 2009-02-16: (Rick Hale)
110
+ * + Added version detection for Android phones.
111
+ *
112
+ * 2008-12-09:
113
+ * + Removed unused constant
114
+ *
115
+ * 2008-11-07:
116
+ * + Added Google's Chrome to the detection list
117
+ * + Added isBrowser(string) to the list of functions special thanks to
118
+ * Daniel 'mavrick' Lang for the function concept (http://mavrick.id.au)
119
+ *
120
+ *
121
+ * Gary White noted: "Since browser detection is so unreliable, I am
122
+ * no longer maintaining this script. You are free to use and or
123
+ * modify/update it as you want, however the author assumes no
124
+ * responsibility for the accuracy of the detected values."
125
+ *
126
+ * Anyone experienced with Gary's script might be interested in these notes:
127
+ *
128
+ * Added class constants
129
+ * Added detection and version detection for Google's Chrome
130
+ * Updated the version detection for Amaya
131
+ * Updated the version detection for Firefox
132
+ * Updated the version detection for Lynx
133
+ * Updated the version detection for WebTV
134
+ * Updated the version detection for NetPositive
135
+ * Updated the version detection for IE
136
+ * Updated the version detection for OmniWeb
137
+ * Updated the version detection for iCab
138
+ * Updated the version detection for Safari
139
+ * Updated Safari to remove mobile devices (iPhone)
140
+ * Added detection for iPhone
141
+ * Added detection for robots
142
+ * Added detection for mobile devices
143
+ * Added detection for BlackBerry
144
+ * Removed Netscape checks (matches heavily with firefox & mozilla)
145
+ *
146
+ */
147
+
148
+ class Browser {
149
+ public $_agent = '';
150
+ public $_browser_name = '';
151
+ public $_version = '';
152
+ public $_platform = '';
153
+ public $_os = '';
154
+ public $_is_aol = false;
155
+ public $_is_mobile = false;
156
+ public $_is_robot = false;
157
+ public $_aol_version = '';
158
+
159
+ public $BROWSER_UNKNOWN = 'unknown';
160
+ public $VERSION_UNKNOWN = 'unknown';
161
+
162
+ public $BROWSER_OPERA = 'Opera'; // Http://www.opera.com/
163
+ public $BROWSER_OPERA_MINI = 'Opera Mini'; // Http://www.opera.com/mini/
164
+ public $BROWSER_WEBTV = 'WebTV'; // Http://www.webtv.net/pc/
165
+ public $BROWSER_IE = 'Internet Explorer'; // Http://www.microsoft.com/ie/
166
+ public $BROWSER_POCKET_IE = 'Pocket Internet Explorer'; // Http://en.wikipedia.org/wiki/Internet_Explorer_Mobile
167
+ public $BROWSER_KONQUEROR = 'Konqueror'; // Http://www.konqueror.org/
168
+ public $BROWSER_ICAB = 'iCab'; // Http://www.icab.de/
169
+ public $BROWSER_OMNIWEB = 'OmniWeb'; // Http://www.omnigroup.com/applications/omniweb/
170
+ public $BROWSER_FIREBIRD = 'Firebird'; // Http://www.ibphoenix.com/
171
+ public $BROWSER_FIREFOX = 'Firefox'; // Http://www.mozilla.com/en-US/firefox/firefox.html
172
+ public $BROWSER_ICEWEASEL = 'Iceweasel'; // Http://www.geticeweasel.org/
173
+ public $BROWSER_SHIRETOKO = 'Shiretoko'; // Http://wiki.mozilla.org/Projects/shiretoko
174
+ public $BROWSER_MOZILLA = 'Mozilla'; // Http://www.mozilla.com/en-US/
175
+ public $BROWSER_AMAYA = 'Amaya'; // Http://www.w3.org/Amaya/
176
+ public $BROWSER_LYNX = 'Lynx'; // Http://en.wikipedia.org/wiki/Lynx
177
+ public $BROWSER_SAFARI = 'Safari'; // Http://apple.com
178
+ public $BROWSER_IPHONE = 'iPhone'; // Http://apple.com
179
+ public $BROWSER_IPOD = 'iPod'; // Http://apple.com
180
+ public $BROWSER_IPAD = 'iPad'; // Http://apple.com
181
+ public $BROWSER_CHROME = 'Chrome'; // Http://www.google.com/chrome
182
+ public $BROWSER_ANDROID = 'Android'; // Http://www.android.com/
183
+ public $BROWSER_GOOGLEBOT = 'GoogleBot'; // Http://en.wikipedia.org/wiki/Googlebot
184
+ public $BROWSER_SLURP = 'Yahoo! Slurp'; // Http://en.wikipedia.org/wiki/Yahoo!_Slurp
185
+ public $BROWSER_W3CVALIDATOR = 'W3C Validator'; // Http://validator.w3.org/
186
+ public $BROWSER_BLACKBERRY = 'BlackBerry'; // Http://www.blackberry.com/
187
+ public $BROWSER_ICECAT = 'IceCat'; // Http://en.wikipedia.org/wiki/GNU_IceCat
188
+ public $BROWSER_NOKIA_S60 = 'Nokia S60 OSS Browser'; // Http://en.wikipedia.org/wiki/Web_Browser_for_S60
189
+ public $BROWSER_NOKIA = 'Nokia Browser'; // * all other WAP-based browsers on the Nokia Platform
190
+ public $BROWSER_MSN = 'MSN Browser'; // Http://explorer.msn.com/
191
+ public $BROWSER_MSNBOT = 'MSN Bot'; // Http://search.msn.com/msnbot.htm
192
+ // Http://en.wikipedia.org/wiki/Msnbot (used for Bing as well)
193
+
194
+ public $BROWSER_NETSCAPE_NAVIGATOR = 'Netscape Navigator'; // Http://browser.netscape.com/ (DEPRECATED)
195
+ public $BROWSER_GALEON = 'Galeon'; // Http://galeon.sourceforge.net/ (DEPRECATED)
196
+ public $BROWSER_NETPOSITIVE = 'NetPositive'; // Http://en.wikipedia.org/wiki/NetPositive (DEPRECATED)
197
+ public $BROWSER_PHOENIX = 'Phoenix'; // Http://en.wikipedia.org/wiki/History_of_Mozilla_Firefox (DEPRECATED)
198
+
199
+ public $PLATFORM_UNKNOWN = 'unknown';
200
+ public $PLATFORM_WINDOWS = 'Windows';
201
+ public $PLATFORM_WINDOWS_CE = 'Windows CE';
202
+ public $PLATFORM_APPLE = 'Apple';
203
+ public $PLATFORM_LINUX = 'Linux';
204
+ public $PLATFORM_OS2 = 'OS/2';
205
+ public $PLATFORM_BEOS = 'BeOS';
206
+ public $PLATFORM_IPHONE = 'iPhone';
207
+ public $PLATFORM_IPOD = 'iPod';
208
+ public $PLATFORM_IPAD = 'iPad';
209
+ public $PLATFORM_BLACKBERRY = 'BlackBerry';
210
+ public $PLATFORM_NOKIA = 'Nokia';
211
+ public $PLATFORM_FREEBSD = 'FreeBSD';
212
+ public $PLATFORM_OPENBSD = 'OpenBSD';
213
+ public $PLATFORM_NETBSD = 'NetBSD';
214
+ public $PLATFORM_SUNOS = 'SunOS';
215
+ public $PLATFORM_OPENSOLARIS = 'OpenSolaris';
216
+ public $PLATFORM_ANDROID = 'Android';
217
+
218
+ public $OPERATING_SYSTEM_UNKNOWN = 'unknown';
219
+
220
+ function Browser($useragent="") {
221
+ $this->reset();
222
+ if( $useragent != "" ) {
223
+ $this->setUserAgent($useragent);
224
+ }
225
+ else {
226
+ $this->determine();
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Reset all properties
232
+ */
233
+ function reset() {
234
+ $this->_agent = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
235
+ $this->_browser_name = $this->BROWSER_UNKNOWN;
236
+ $this->_version = $this->VERSION_UNKNOWN;
237
+ $this->_platform = $this->PLATFORM_UNKNOWN;
238
+ $this->_os = $this->OPERATING_SYSTEM_UNKNOWN;
239
+ $this->_is_aol = false;
240
+ $this->_is_mobile = false;
241
+ $this->_is_robot = false;
242
+ $this->_aol_version = $this->VERSION_UNKNOWN;
243
+ }
244
+
245
+ /**
246
+ * Check to see if the specific browser is valid
247
+ * @param string $browserName
248
+ * @return True if the browser is the specified browser
249
+ */
250
+ function isBrowser($browserName) { return( 0 == strcasecmp($this->_browser_name, trim($browserName))); }
251
+
252
+ /**
253
+ * The name of the browser. All return types are from the class contants
254
+ * @return string Name of the browser
255
+ */
256
+ function getBrowser() { return $this->_browser_name; }
257
+ /**
258
+ * Set the name of the browser
259
+ * @param $browser The name of the Browser
260
+ */
261
+ function setBrowser($browser) { return $this->_browser_name = $browser; }
262
+ /**
263
+ * The name of the platform. All return types are from the class contants
264
+ * @return string Name of the browser
265
+ */
266
+ function getPlatform() { return $this->_platform; }
267
+ /**
268
+ * Set the name of the platform
269
+ * @param $platform The name of the Platform
270
+ */
271
+ function setPlatform($platform) { return $this->_platform = $platform; }
272
+ /**
273
+ * The version of the browser.
274
+ * @return string Version of the browser (will only contain alpha-numeric characters and a period)
275
+ */
276
+ function getVersion() { return $this->_version; }
277
+ /**
278
+ * Set the version of the browser
279
+ * @param $version The version of the Browser
280
+ */
281
+ function setVersion($version) { $this->_version = preg_replace('/[^0-9,.,a-z,A-Z-]/','',$version); }
282
+ /**
283
+ * The version of AOL.
284
+ * @return string Version of AOL (will only contain alpha-numeric characters and a period)
285
+ */
286
+ function getAolVersion() { return $this->_aol_version; }
287
+ /**
288
+ * Set the version of AOL
289
+ * @param $version The version of AOL
290
+ */
291
+ function setAolVersion($version) { $this->_aol_version = preg_replace('/[^0-9,.,a-z,A-Z]/','',$version); }
292
+ /**
293
+ * Is the browser from AOL?
294
+ * @return boolean True if the browser is from AOL otherwise false
295
+ */
296
+ function isAol() { return $this->_is_aol; }
297
+ /**
298
+ * Is the browser from a mobile device?
299
+ * @return boolean True if the browser is from a mobile device otherwise false
300
+ */
301
+ function isMobile() { return $this->_is_mobile; }
302
+ /**
303
+ * Is the browser from a robot (ex Slurp,GoogleBot)?
304
+ * @return boolean True if the browser is from a robot otherwise false
305
+ */
306
+ function isRobot() { return $this->_is_robot; }
307
+ /**
308
+ * Set the browser to be from AOL
309
+ * @param $isAol
310
+ */
311
+ function setAol($isAol) { $this->_is_aol = $isAol; }
312
+ /**
313
+ * Set the Browser to be mobile
314
+ * @param boolean $value is the browser a mobile brower or not
315
+ */
316
+ function setMobile($value=true) { $this->_is_mobile = $value; }
317
+ /**
318
+ * Set the Browser to be a robot
319
+ * @param boolean $value is the browser a robot or not
320
+ */
321
+ function setRobot($value=true) { $this->_is_robot = $value; }
322
+ /**
323
+ * Get the user agent value in use to determine the browser
324
+ * @return string The user agent from the HTTP header
325
+ */
326
+ function getUserAgent() { return $this->_agent; }
327
+ /**
328
+ * Set the user agent value (the construction will use the HTTP header value - this will overwrite it)
329
+ * @param $agent_string The value for the User Agent
330
+ */
331
+ function setUserAgent($agent_string) {
332
+ $this->reset();
333
+ $this->_agent = $agent_string;
334
+ $this->determine();
335
+ }
336
+ /**
337
+ * Used to determine if the browser is actually "chromeframe"
338
+ * @since 1.7
339
+ * @return boolean True if the browser is using chromeframe
340
+ */
341
+ function isChromeFrame() {
342
+ return( strpos($this->_agent,"chromeframe") !== false );
343
+ }
344
+ /**
345
+ * Returns a formatted string with a summary of the details of the browser.
346
+ * @return string formatted string with a summary of the browser
347
+ */
348
+ function __toString() {
349
+ $text1 = $this->getUserAgent(); //grabs the UA (user agent) string
350
+ $UAline1 = substr($text1, 0, 32); //the first line we print should only be the first 32 characters of the UA string
351
+ $text2 = $this->getUserAgent();//now we grab it again and save it to a string
352
+ $towrapUA = str_replace($UAline1, '', $text2);//the rest of the printoff (other than first line) is equivolent
353
+ // To the whole string minus the part we printed off. IE
354
+ // User Agent: thefirst32charactersfromUAline1
355
+ // the rest of it is now stored in
356
+ // $text2 to be printed off
357
+ // But we need to add spaces before each line that is split other than line 1
358
+ $space = '';
359
+ for($i = 0; $i < 25; $i++) {
360
+ $space .= ' ';
361
+ }
362
+ // Now we split the remaining string of UA ($text2) into lines that are prefixed by spaces for formatting
363
+ $wordwrapped = chunk_split($towrapUA, 32, "\n $space");
364
+ return "Platform: {$this->getPlatform()} \n".
365
+ "Browser Name: {$this->getBrowser()} \n" .
366
+ "Browser Version: {$this->getVersion()} \n" .
367
+ "User Agent String: $UAline1 \n\t\t\t " .
368
+ "$wordwrapped";
369
+ }
370
+ /**
371
+ * Protected routine to calculate and determine what the browser is in use (including platform)
372
+ */
373
+ function determine() {
374
+ $this->checkPlatform();
375
+ $this->checkBrowsers();
376
+ $this->checkForAol();
377
+ }
378
+ /**
379
+ * Protected routine to determine the browser type
380
+ * @return boolean True if the browser was detected otherwise false
381
+ */
382
+ function checkBrowsers() {
383
+ return (
384
+ // Well-known, well-used
385
+ // Special Notes:
386
+ // (1) Opera must be checked before FireFox due to the odd
387
+ // user agents used in some older versions of Opera
388
+ // (2) WebTV is strapped onto Internet Explorer so we must
389
+ // check for WebTV before IE
390
+ // (3) (deprecated) Galeon is based on Firefox and needs to be
391
+ // tested before Firefox is tested
392
+ // (4) OmniWeb is based on Safari so OmniWeb check must occur
393
+ // before Safari
394
+ // (5) Netscape 9+ is based on Firefox so Netscape checks
395
+ // before FireFox are necessary
396
+ $this->checkBrowserWebTv() ||
397
+ $this->checkBrowserInternetExplorer() ||
398
+ $this->checkBrowserOpera() ||
399
+ $this->checkBrowserGaleon() ||
400
+ $this->checkBrowserNetscapeNavigator9Plus() ||
401
+ $this->checkBrowserFirefox() ||
402
+ $this->checkBrowserChrome() ||
403
+ $this->checkBrowserOmniWeb() ||
404
+
405
+ // Common mobile
406
+ $this->checkBrowserAndroid() ||
407
+ $this->checkBrowseriPad() ||
408
+ $this->checkBrowseriPod() ||
409
+ $this->checkBrowseriPhone() ||
410
+ $this->checkBrowserBlackBerry() ||
411
+ $this->checkBrowserNokia() ||
412
+
413
+ // Common bots
414
+ $this->checkBrowserGoogleBot() ||
415
+ $this->checkBrowserMSNBot() ||
416
+ $this->checkBrowserSlurp() ||
417
+
418
+ // WebKit base check (post mobile and others)
419
+ $this->checkBrowserSafari() ||
420
+
421
+ // Everyone else
422
+ $this->checkBrowserNetPositive() ||
423
+ $this->checkBrowserFirebird() ||
424
+ $this->checkBrowserKonqueror() ||
425
+ $this->checkBrowserIcab() ||
426
+ $this->checkBrowserPhoenix() ||
427
+ $this->checkBrowserAmaya() ||
428
+ $this->checkBrowserLynx() ||
429
+
430
+ $this->checkBrowserShiretoko() ||
431
+ $this->checkBrowserIceCat() ||
432
+ $this->checkBrowserW3CValidator() ||
433
+ $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */
434
+ );
435
+ }
436
+
437
+ /**
438
+ * Determine if the user is using a BlackBerry (last updated 1.7)
439
+ * @return boolean True if the browser is the BlackBerry browser otherwise false
440
+ */
441
+ function checkBrowserBlackBerry() {
442
+ if( stripos($this->_agent,'blackberry') !== false ) {
443
+ $aresult = explode("/",stristr($this->_agent,"BlackBerry"));
444
+ $aversion = explode(' ',$aresult[1]);
445
+ $this->setVersion($aversion[0]);
446
+ $this->_browser_name = $this->BROWSER_BLACKBERRY;
447
+ $this->setMobile(true);
448
+ return true;
449
+ }
450
+ return false;
451
+ }
452
+
453
+ /**
454
+ * Determine if the user is using an AOL User Agent (last updated 1.7)
455
+ * @return boolean True if the browser is from AOL otherwise false
456
+ */
457
+ function checkForAol() {
458
+ $this->setAol(false);
459
+ $this->setAolVersion($this->VERSION_UNKNOWN);
460
+
461
+ if( stripos($this->_agent,'aol') !== false ) {
462
+ $aversion = explode(' ',stristr($this->_agent, 'AOL'));
463
+ $this->setAol(true);
464
+ $this->setAolVersion(preg_replace('/[^0-9\.a-z]/i', '', $aversion[1]));
465
+ return true;
466
+ }
467
+ return false;
468
+ }
469
+
470
+ /**
471
+ * Determine if the browser is the GoogleBot or not (last updated 1.7)
472
+ * @return boolean True if the browser is the GoogletBot otherwise false
473
+ */
474
+ function checkBrowserGoogleBot() {
475
+ if( stripos($this->_agent,'googlebot') !== false ) {
476
+ $aresult = explode('/',stristr($this->_agent,'googlebot'));
477
+ $aversion = explode(' ',$aresult[1]);
478
+ $this->setVersion(str_replace(';','',$aversion[0]));
479
+ $this->_browser_name = $this->BROWSER_GOOGLEBOT;
480
+ $this->setRobot(true);
481
+ return true;
482
+ }
483
+ return false;
484
+ }
485
+
486
+ /**
487
+ * Determine if the browser is the MSNBot or not (last updated 1.9)
488
+ * @return boolean True if the browser is the MSNBot otherwise false
489
+ */
490
+ function checkBrowserMSNBot() {
491
+ if( stripos($this->_agent,"msnbot") !== false ) {
492
+ $aresult = explode("/",stristr($this->_agent,"msnbot"));
493
+ $aversion = explode(" ",$aresult[1]);
494
+ $this->setVersion(str_replace(";","",$aversion[0]));
495
+ $this->_browser_name = $this->BROWSER_MSNBOT;
496
+ $this->setRobot(true);
497
+ return true;
498
+ }
499
+ return false;
500
+ }
501
+
502
+ /**
503
+ * Determine if the browser is the W3C Validator or not (last updated 1.7)
504
+ * @return boolean True if the browser is the W3C Validator otherwise false
505
+ */
506
+ function checkBrowserW3CValidator() {
507
+ if( stripos($this->_agent,'W3C-checklink') !== false ) {
508
+ $aresult = explode('/',stristr($this->_agent,'W3C-checklink'));
509
+ $aversion = explode(' ',$aresult[1]);
510
+ $this->setVersion($aversion[0]);
511
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
512
+ return true;
513
+ }
514
+ else if( stripos($this->_agent,'W3C_Validator') !== false ) {
515
+ // Some of the Validator versions do not delineate w/ a slash - add it back in
516
+ $ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->_agent);
517
+ $aresult = explode('/',stristr($ua,'W3C_Validator'));
518
+ $aversion = explode(' ',$aresult[1]);
519
+ $this->setVersion($aversion[0]);
520
+ $this->_browser_name = $this->BROWSER_W3CVALIDATOR;
521
+ return true;
522
+ }
523
+ return false;
524
+ }
525
+
526
+ /**
527
+ * Determine if the browser is the Yahoo! Slurp Robot or not (last updated 1.7)
528
+ * @return boolean True if the browser is the Yahoo! Slurp Robot otherwise false
529
+ */
530
+ function checkBrowserSlurp() {
531
+ if( stripos($this->_agent,'slurp') !== false ) {
532
+ $aresult = explode('/',stristr($this->_agent,'Slurp'));
533
+ $aversion = explode(' ',$aresult[1]);
534
+ $this->setVersion($aversion[0]);
535
+ $this->_browser_name = $this->BROWSER_SLURP;
536
+ $this->setRobot(true);
537
+ $this->setMobile(false);
538
+ return true;
539
+ }
540
+ return false;
541
+ }
542
+
543
+ /**
544
+ * Determine if the browser is Internet Explorer or not (last updated 1.7)
545
+ * @return boolean True if the browser is Internet Explorer otherwise false
546
+ */
547
+ function checkBrowserInternetExplorer() {
548
+
549
+ // Test for v1 - v1.5 IE
550
+ if( stripos($this->_agent,'microsoft internet explorer') !== false ) {
551
+ $this->setBrowser($this->BROWSER_IE);
552
+ $this->setVersion('1.0');
553
+ $aresult = stristr($this->_agent, '/');
554
+ if( preg_match('/308|425|426|474|0b1/i', $aresult) ) {
555
+ $this->setVersion('1.5');
556
+ }
557
+ return true;
558
+ }
559
+ // Test for versions > 1.5
560
+ else if( stripos($this->_agent,'msie') !== false && stripos($this->_agent,'opera') === false ) {
561
+ // See if the browser is the odd MSN Explorer
562
+ if( stripos($this->_agent,'msnb') !== false ) {
563
+ $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'MSN'));
564
+ $this->setBrowser( $this->BROWSER_MSN );
565
+ $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
566
+ return true;
567
+ }
568
+ $aresult = explode(' ',stristr(str_replace(';','; ',$this->_agent),'msie'));
569
+ $this->setBrowser( $this->BROWSER_IE );
570
+ $this->setVersion(str_replace(array('(',')',';'),'',$aresult[1]));
571
+ return true;
572
+ }
573
+ // Test for Pocket IE
574
+ else if( stripos($this->_agent,'mspie') !== false || stripos($this->_agent,'pocket') !== false ) {
575
+ $aresult = explode(' ',stristr($this->_agent,'mspie'));
576
+ $this->setPlatform( $this->PLATFORM_WINDOWS_CE );
577
+ $this->setBrowser( $this->BROWSER_POCKET_IE );
578
+ $this->setMobile(true);
579
+
580
+ if( stripos($this->_agent,'mspie') !== false ) {
581
+ $this->setVersion($aresult[1]);
582
+ }
583
+ else {
584
+ $aversion = explode('/',$this->_agent);
585
+ $this->setVersion($aversion[1]);
586
+ }
587
+ return true;
588
+ }
589
+ return false;
590
+ }
591
+
592
+ /**
593
+ * Determine if the browser is Opera or not (last updated 1.7)
594
+ * @return boolean True if the browser is Opera otherwise false
595
+ */
596
+ function checkBrowserOpera() {
597
+ if( stripos($this->_agent,'opera mini') !== false ) {
598
+ $resultant = stristr($this->_agent, 'opera mini');
599
+ if( preg_match('/\//',$resultant) ) {
600
+ $aresult = explode('/',$resultant);
601
+ $aversion = explode(' ',$aresult[1]);
602
+ $this->setVersion($aversion[0]);
603
+ }
604
+ else {
605
+ $aversion = explode(' ',stristr($resultant,'opera mini'));
606
+ $this->setVersion($aversion[1]);
607
+ }
608
+ $this->_browser_name = $this->BROWSER_OPERA_MINI;
609
+ $this->setMobile(true);
610
+ return true;
611
+ }
612
+ else if( stripos($this->_agent,'opera') !== false ) {
613
+ $resultant = stristr($this->_agent, 'opera');
614
+ if( preg_match('/Version\/(10.*)$/',$resultant,$matches) ) {
615
+ $this->setVersion($matches[1]);
616
+ }
617
+ else if( preg_match('/\//',$resultant) ) {
618
+ $aresult = explode('/',str_replace("("," ",$resultant));
619
+ $aversion = explode(' ',$aresult[1]);
620
+ $this->setVersion($aversion[0]);
621
+ }
622
+ else {
623
+ $aversion = explode(' ',stristr($resultant,'opera'));
624
+ $this->setVersion(isset($aversion[1])?$aversion[1]:"");
625
+ }
626
+ $this->_browser_name = $this->BROWSER_OPERA;
627
+ return true;
628
+ }
629
+ return false;
630
+ }
631
+
632
+ /**
633
+ * Determine if the browser is Chrome or not (last updated 1.7)
634
+ * @return boolean True if the browser is Chrome otherwise false
635
+ */
636
+ function checkBrowserChrome() {
637
+ if( stripos($this->_agent,'Chrome') !== false ) {
638
+ $aresult = explode('/',stristr($this->_agent,'Chrome'));
639
+ $aversion = explode(' ',$aresult[1]);
640
+ $this->setVersion($aversion[0]);
641
+ $this->setBrowser($this->BROWSER_CHROME);
642
+ return true;
643
+ }
644
+ return false;
645
+ }
646
+
647
+
648
+ /**
649
+ * Determine if the browser is WebTv or not (last updated 1.7)
650
+ * @return boolean True if the browser is WebTv otherwise false
651
+ */
652
+ function checkBrowserWebTv() {
653
+ if( stripos($this->_agent,'webtv') !== false ) {
654
+ $aresult = explode('/',stristr($this->_agent,'webtv'));
655
+ $aversion = explode(' ',$aresult[1]);
656
+ $this->setVersion($aversion[0]);
657
+ $this->setBrowser($this->BROWSER_WEBTV);
658
+ return true;
659
+ }
660
+ return false;
661
+ }
662
+
663
+ /**
664
+ * Determine if the browser is NetPositive or not (last updated 1.7)
665
+ * @return boolean True if the browser is NetPositive otherwise false
666
+ */
667
+ function checkBrowserNetPositive() {
668
+ if( stripos($this->_agent,'NetPositive') !== false ) {
669
+ $aresult = explode('/',stristr($this->_agent,'NetPositive'));
670
+ $aversion = explode(' ',$aresult[1]);
671
+ $this->setVersion(str_replace(array('(',')',';'),'',$aversion[0]));
672
+ $this->setBrowser($this->BROWSER_NETPOSITIVE);
673
+ return true;
674
+ }
675
+ return false;
676
+ }
677
+
678
+ /**
679
+ * Determine if the browser is Galeon or not (last updated 1.7)
680
+ * @return boolean True if the browser is Galeon otherwise false
681
+ */
682
+ function checkBrowserGaleon() {
683
+ if( stripos($this->_agent,'galeon') !== false ) {
684
+ $aresult = explode(' ',stristr($this->_agent,'galeon'));
685
+ $aversion = explode('/',$aresult[0]);
686
+ $this->setVersion($aversion[1]);
687
+ $this->setBrowser($this->BROWSER_GALEON);
688
+ return true;
689
+ }
690
+ return false;
691
+ }
692
+
693
+ /**
694
+ * Determine if the browser is Konqueror or not (last updated 1.7)
695
+ * @return boolean True if the browser is Konqueror otherwise false
696
+ */
697
+ function checkBrowserKonqueror() {
698
+ if( stripos($this->_agent,'Konqueror') !== false ) {
699
+ $aresult = explode(' ',stristr($this->_agent,'Konqueror'));
700
+ $aversion = explode('/',$aresult[0]);
701
+ $this->setVersion($aversion[1]);
702
+ $this->setBrowser($this->BROWSER_KONQUEROR);
703
+ return true;
704
+ }
705
+ return false;
706
+ }
707
+
708
+ /**
709
+ * Determine if the browser is iCab or not (last updated 1.7)
710
+ * @return boolean True if the browser is iCab otherwise false
711
+ */
712
+ function checkBrowserIcab() {
713
+ if( stripos($this->_agent,'icab') !== false ) {
714
+ $aversion = explode(' ',stristr(str_replace('/',' ',$this->_agent),'icab'));
715
+ $this->setVersion($aversion[1]);
716
+ $this->setBrowser($this->BROWSER_ICAB);
717
+ return true;
718
+ }
719
+ return false;
720
+ }
721
+
722
+ /**
723
+ * Determine if the browser is OmniWeb or not (last updated 1.7)
724
+ * @return boolean True if the browser is OmniWeb otherwise false
725
+ */
726
+ function checkBrowserOmniWeb() {
727
+ if( stripos($this->_agent,'omniweb') !== false ) {
728
+ $aresult = explode('/',stristr($this->_agent,'omniweb'));
729
+ $aversion = explode(' ',isset($aresult[1])?$aresult[1]:"");
730
+ $this->setVersion($aversion[0]);
731
+ $this->setBrowser($this->BROWSER_OMNIWEB);
732
+ return true;
733
+ }
734
+ return false;
735
+ }
736
+
737
+ /**
738
+ * Determine if the browser is Phoenix or not (last updated 1.7)
739
+ * @return boolean True if the browser is Phoenix otherwise false
740
+ */
741
+ function checkBrowserPhoenix() {
742
+ if( stripos($this->_agent,'Phoenix') !== false ) {
743
+ $aversion = explode('/',stristr($this->_agent,'Phoenix'));
744
+ $this->setVersion($aversion[1]);
745
+ $this->setBrowser($this->BROWSER_PHOENIX);
746
+ return true;
747
+ }
748
+ return false;
749
+ }
750
+
751
+ /**
752
+ * Determine if the browser is Firebird or not (last updated 1.7)
753
+ * @return boolean True if the browser is Firebird otherwise false
754
+ */
755
+ function checkBrowserFirebird() {
756
+ if( stripos($this->_agent,'Firebird') !== false ) {
757
+ $aversion = explode('/',stristr($this->_agent,'Firebird'));
758
+ $this->setVersion($aversion[1]);
759
+ $this->setBrowser($this->BROWSER_FIREBIRD);
760
+ return true;
761
+ }
762
+ return false;
763
+ }
764
+
765
+ /**
766
+ * Determine if the browser is Netscape Navigator 9+ or not (last updated 1.7)
767
+ * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)
768
+ * @return boolean True if the browser is Netscape Navigator 9+ otherwise false
769
+ */
770
+ function checkBrowserNetscapeNavigator9Plus() {
771
+ if( stripos($this->_agent,'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i',$this->_agent,$matches) ) {
772
+ $this->setVersion($matches[1]);
773
+ $this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
774
+ return true;
775
+ }
776
+ else if( stripos($this->_agent,'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i',$this->_agent,$matches) ) {
777
+ $this->setVersion($matches[1]);
778
+ $this->setBrowser($this->BROWSER_NETSCAPE_NAVIGATOR);
779
+ return true;
780
+ }
781
+ return false;
782
+ }
783
+
784
+ /**
785
+ * Determine if the browser is Shiretoko or not (https://wiki.mozilla.org/Projects/shiretoko) (last updated 1.7)
786
+ * @return boolean True if the browser is Shiretoko otherwise false
787
+ */
788
+ function checkBrowserShiretoko() {
789
+ if( stripos($this->_agent,'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i',$this->_agent,$matches) ) {
790
+ $this->setVersion($matches[1]);
791
+ $this->setBrowser($this->BROWSER_SHIRETOKO);
792
+ return true;
793
+ }
794
+ return false;
795
+ }
796
+
797
+ /**
798
+ * Determine if the browser is Ice Cat or not (http://en.wikipedia.org/wiki/GNU_IceCat) (last updated 1.7)
799
+ * @return boolean True if the browser is Ice Cat otherwise false
800
+ */
801
+ function checkBrowserIceCat() {
802
+ if( stripos($this->_agent,'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i',$this->_agent,$matches) ) {
803
+ $this->setVersion($matches[1]);
804
+ $this->setBrowser($this->BROWSER_ICECAT);
805
+ return true;
806
+ }
807
+ return false;
808
+ }
809
+
810
+ /**
811
+ * Determine if the browser is Nokia or not (last updated 1.7)
812
+ * @return boolean True if the browser is Nokia otherwise false
813
+ */
814
+ function checkBrowserNokia() {
815
+ if( preg_match("/Nokia([^\/]+)\/([^ SP]+)/i",$this->_agent,$matches) ) {
816
+ $this->setVersion($matches[2]);
817
+ if( stripos($this->_agent,'Series60') !== false || strpos($this->_agent,'S60') !== false ) {
818
+ $this->setBrowser($this->BROWSER_NOKIA_S60);
819
+ }
820
+ else {
821
+ $this->setBrowser( $this->BROWSER_NOKIA );
822
+ }
823
+ $this->setMobile(true);
824
+ return true;
825
+ }
826
+ return false;
827
+ }
828
+
829
+ /**
830
+ * Determine if the browser is Firefox or not (last updated 1.7)
831
+ * @return boolean True if the browser is Firefox otherwise false
832
+ */
833
+ function checkBrowserFirefox() {
834
+ if( stripos($this->_agent,'safari') === false ) {
835
+ if( preg_match("/Firefox[\/ \(]([^ ;\)]+)/i",$this->_agent,$matches) ) {
836
+ $this->setVersion($matches[1]);
837
+ $this->setBrowser($this->BROWSER_FIREFOX);
838
+ return true;
839
+ }
840
+ else if( preg_match("/Firefox$/i",$this->_agent,$matches) ) {
841
+ $this->setVersion("");
842
+ $this->setBrowser($this->BROWSER_FIREFOX);
843
+ return true;
844
+ }
845
+ }
846
+ return false;
847
+ }
848
+
849
+ /**
850
+ * Determine if the browser is Firefox or not (last updated 1.7)
851
+ * @return boolean True if the browser is Firefox otherwise false
852
+ */
853
+ function checkBrowserIceweasel() {
854
+ if( stripos($this->_agent,'Iceweasel') !== false ) {
855
+ $aresult = explode('/',stristr($this->_agent,'Iceweasel'));
856
+ $aversion = explode(' ',$aresult[1]);
857
+ $this->setVersion($aversion[0]);
858
+ $this->setBrowser($this->BROWSER_ICEWEASEL);
859
+ return true;
860
+ }
861
+ return false;
862
+ }
863
+ /**
864
+ * Determine if the browser is Mozilla or not (last updated 1.7)
865
+ * @return boolean True if the browser is Mozilla otherwise false
866
+ */
867
+ function checkBrowserMozilla() {
868
+ if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent) && stripos($this->_agent,'netscape') === false) {
869
+ $aversion = explode(' ',stristr($this->_agent,'rv:'));
870
+ preg_match('/rv:[0-9].[0-9][a-b]?/i',$this->_agent,$aversion);
871
+ $this->setVersion(str_replace('rv:','',$aversion[0]));
872
+ $this->setBrowser($this->BROWSER_MOZILLA);
873
+ return true;
874
+ }
875
+ else if( stripos($this->_agent,'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i',$this->_agent) && stripos($this->_agent,'netscape') === false ) {
876
+ $aversion = explode('',stristr($this->_agent,'rv:'));
877
+ $this->setVersion(str_replace('rv:','',$aversion[0]));
878
+ $this->setBrowser($this->BROWSER_MOZILLA);
879
+ return true;
880
+ }
881
+ else if( stripos($this->_agent,'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i',$this->_agent,$matches) && stripos($this->_agent,'netscape') === false ) {
882
+ $this->setVersion($matches[1]);
883
+ $this->setBrowser($this->BROWSER_MOZILLA);
884
+ return true;
885
+ }
886
+ return false;
887
+ }
888
+
889
+ /**
890
+ * Determine if the browser is Lynx or not (last updated 1.7)
891
+ * @return boolean True if the browser is Lynx otherwise false
892
+ */
893
+ function checkBrowserLynx() {
894
+ if( stripos($this->_agent,'lynx') !== false ) {
895
+ $aresult = explode('/',stristr($this->_agent,'Lynx'));
896
+ $aversion = explode(' ',(isset($aresult[1])?$aresult[1]:""));
897
+ $this->setVersion($aversion[0]);
898
+ $this->setBrowser($this->BROWSER_LYNX);
899
+ return true;
900
+ }
901
+ return false;
902
+ }
903
+
904
+ /**
905
+ * Determine if the browser is Amaya or not (last updated 1.7)
906
+ * @return boolean True if the browser is Amaya otherwise false
907
+ */
908
+ function checkBrowserAmaya() {
909
+ if( stripos($this->_agent,'amaya') !== false ) {
910
+ $aresult = explode('/',stristr($this->_agent,'Amaya'));
911
+ $aversion = explode(' ',$aresult[1]);
912
+ $this->setVersion($aversion[0]);
913
+ $this->setBrowser($this->BROWSER_AMAYA);
914
+ return true;
915
+ }
916
+ return false;
917
+ }
918
+
919
+ /**
920
+ * Determine if the browser is Safari or not (last updated 1.7)
921
+ * @return boolean True if the browser is Safari otherwise false
922
+ */
923
+ function checkBrowserSafari() {
924
+ if( stripos($this->_agent,'Safari') !== false && stripos($this->_agent,'iPhone') === false && stripos($this->_agent,'iPod') === false ) {
925
+ $aresult = explode('/',stristr($this->_agent,'Version'));
926
+ if( isset($aresult[1]) ) {
927
+ $aversion = explode(' ',$aresult[1]);
928
+ $this->setVersion($aversion[0]);
929
+ }
930
+ else {
931
+ $this->setVersion($this->VERSION_UNKNOWN);
932
+ }
933
+ $this->setBrowser($this->BROWSER_SAFARI);
934
+ return true;
935
+ }
936
+ return false;
937
+ }
938
+
939
+ /**
940
+ * Determine if the browser is iPhone or not (last updated 1.7)
941
+ * @return boolean True if the browser is iPhone otherwise false
942
+ */
943
+ function checkBrowseriPhone() {
944
+ if( stripos($this->_agent,'iPhone') !== false ) {
945
+ $aresult = explode('/',stristr($this->_agent,'Version'));
946
+ if( isset($aresult[1]) ) {
947
+ $aversion = explode(' ',$aresult[1]);
948
+ $this->setVersion($aversion[0]);
949
+ }
950
+ else {
951
+ $this->setVersion($this->VERSION_UNKNOWN);
952
+ }
953
+ $this->setMobile(true);
954
+ $this->setBrowser($this->BROWSER_IPHONE);
955
+ return true;
956
+ }
957
+ return false;
958
+ }
959
+
960
+ /**
961
+ * Determine if the browser is iPod or not (last updated 1.7)
962
+ * @return boolean True if the browser is iPod otherwise false
963
+ */
964
+ function checkBrowseriPad() {
965
+ if( stripos($this->_agent,'iPad') !== false ) {
966
+ $aresult = explode('/',stristr($this->_agent,'Version'));
967
+ if( isset($aresult[1]) ) {
968
+ $aversion = explode(' ',$aresult[1]);
969
+ $this->setVersion($aversion[0]);
970
+ }
971
+ else {
972
+ $this->setVersion($this->VERSION_UNKNOWN);
973
+ }
974
+ $this->setMobile(true);
975
+ $this->setBrowser($this->BROWSER_IPAD);
976
+ return true;
977
+ }
978
+ return false;
979
+ }
980
+
981
+ /**
982
+ * Determine if the browser is iPod or not (last updated 1.7)
983
+ * @return boolean True if the browser is iPod otherwise false
984
+ */
985
+ function checkBrowseriPod() {
986
+ if( stripos($this->_agent,'iPod') !== false ) {
987
+ $aresult = explode('/',stristr($this->_agent,'Version'));
988
+ if( isset($aresult[1]) ) {
989
+ $aversion = explode(' ',$aresult[1]);
990
+ $this->setVersion($aversion[0]);
991
+ }
992
+ else {
993
+ $this->setVersion($this->VERSION_UNKNOWN);
994
+ }
995
+ $this->setMobile(true);
996
+ $this->setBrowser($this->BROWSER_IPOD);
997
+ return true;
998
+ }
999
+ return false;
1000
+ }
1001
+
1002
+ /**
1003
+ * Determine if the browser is Android or not (last updated 1.7)
1004
+ * @return boolean True if the browser is Android otherwise false
1005
+ */
1006
+ function checkBrowserAndroid() {
1007
+ if( stripos($this->_agent,'Android') !== false ) {
1008
+ $aresult = explode(' ',stristr($this->_agent,'Android'));
1009
+ if( isset($aresult[1]) ) {
1010
+ $aversion = explode(' ',$aresult[1]);
1011
+ $this->setVersion($aversion[0]);
1012
+ }
1013
+ else {
1014
+ $this->setVersion($this->VERSION_UNKNOWN);
1015
+ }
1016
+ $this->setMobile(true);
1017
+ $this->setBrowser($this->BROWSER_ANDROID);
1018
+ return true;
1019
+ }
1020
+ return false;
1021
+ }
1022
+
1023
+ /**
1024
+ * Determine the user's platform (last updated 1.7)
1025
+ */
1026
+ function checkPlatform() {
1027
+ if( stripos($this->_agent, 'windows') !== false ) {
1028
+ $this->_platform = $this->PLATFORM_WINDOWS;
1029
+ }
1030
+ else if( stripos($this->_agent, 'iPad') !== false ) {
1031
+ $this->_platform = $this->PLATFORM_IPAD;
1032
+ }
1033
+ else if( stripos($this->_agent, 'iPod') !== false ) {
1034
+ $this->_platform = $this->PLATFORM_IPOD;
1035
+ }
1036
+ else if( stripos($this->_agent, 'iPhone') !== false ) {
1037
+ $this->_platform = $this->PLATFORM_IPHONE;
1038
+ }
1039
+ elseif( stripos($this->_agent, 'mac') !== false ) {
1040
+ $this->_platform = $this->PLATFORM_APPLE;
1041
+ }
1042
+ elseif( stripos($this->_agent, 'android') !== false ) {
1043
+ $this->_platform = $this->PLATFORM_ANDROID;
1044
+ }
1045
+ elseif( stripos($this->_agent, 'linux') !== false ) {
1046
+ $this->_platform = $this->PLATFORM_LINUX;
1047
+ }
1048
+ else if( stripos($this->_agent, 'Nokia') !== false ) {
1049
+ $this->_platform = $this->PLATFORM_NOKIA;
1050
+ }
1051
+ else if( stripos($this->_agent, 'BlackBerry') !== false ) {
1052
+ $this->_platform = $this->PLATFORM_BLACKBERRY;
1053
+ }
1054
+ elseif( stripos($this->_agent,'FreeBSD') !== false ) {
1055
+ $this->_platform = $this->PLATFORM_FREEBSD;
1056
+ }
1057
+ elseif( stripos($this->_agent,'OpenBSD') !== false ) {
1058
+ $this->_platform = $this->PLATFORM_OPENBSD;
1059
+ }
1060
+ elseif( stripos($this->_agent,'NetBSD') !== false ) {
1061
+ $this->_platform = $this->PLATFORM_NETBSD;
1062
+ }
1063
+ elseif( stripos($this->_agent, 'OpenSolaris') !== false ) {
1064
+ $this->_platform = $this->PLATFORM_OPENSOLARIS;
1065
+ }
1066
+ elseif( stripos($this->_agent, 'SunOS') !== false ) {
1067
+ $this->_platform = $this->PLATFORM_SUNOS;
1068
+ }
1069
+ elseif( stripos($this->_agent, 'OS\/2') !== false ) {
1070
+ $this->_platform = $this->PLATFORM_OS2;
1071
+ }
1072
+ elseif( stripos($this->_agent, 'BeOS') !== false ) {
1073
+ $this->_platform = $this->PLATFORM_BEOS;
1074
+ }
1075
+ elseif( stripos($this->_agent, 'win') !== false ) {
1076
+ $this->_platform = $this->PLATFORM_WINDOWS;
1077
+ }
1078
+
1079
+ }
1080
+ }
1081
+
1082
+ ?>
includes/libraries/class-quads-html-elements.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * HTML elements
4
+ *
5
+ * A helper class for outputting common HTML elements, such as drop down and checkbox fields
6
+ *
7
+ * @package QUADS
8
+ * @subpackage Classes/HTML
9
+ * @copyright Copyright (c) 2015, Pippin Williamson, René Hermenau
10
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
11
+ * @since 0.0.9
12
+ */
13
+
14
+ // Exit if accessed directly
15
+ if ( ! defined( 'ABSPATH' ) ) exit;
16
+
17
+ /**
18
+ * QUADS_HTML_Elements Class
19
+ *
20
+ * @since 0.0.9
21
+ */
22
+ class QUADS_HTML_Elements {
23
+
24
+
25
+ /**
26
+ * Renders an HTML Dropdown
27
+ *
28
+ * @since 0.0.9
29
+ *
30
+ * @param array $args
31
+ *
32
+ * @return string
33
+ */
34
+ public function select( $args = array() ) {
35
+ $defaults = array(
36
+ 'options' => array(),
37
+ 'name' => null,
38
+ 'class' => '',
39
+ 'id' => '',
40
+ 'selected' => 0,
41
+ 'chosen' => false,
42
+ 'placeholder' => null,
43
+ 'multiple' => false,
44
+ 'show_option_all' => _x( 'All', 'all dropdown items', 'easy-digital-downloads' ),
45
+ 'show_option_none' => _x( 'None', 'no dropdown items', 'easy-digital-downloads' )
46
+ );
47
+
48
+ $args = wp_parse_args( $args, $defaults );
49
+
50
+
51
+ if( $args['multiple'] ) {
52
+ $multiple = ' MULTIPLE';
53
+ } else {
54
+ $multiple = '';
55
+ }
56
+
57
+ if( $args['chosen'] ) {
58
+ $args['class'] .= ' quads-select-chosen';
59
+ }
60
+
61
+ if( $args['placeholder'] ) {
62
+ $placeholder = $args['placeholder'];
63
+ } else {
64
+ $placeholder = '';
65
+ }
66
+
67
+ $output = '<select name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( sanitize_key( str_replace( '-', '_', $args['id'] ) ) ) . '" class="quads-select ' . esc_attr( $args['class'] ) . '"' . $multiple . ' data-placeholder="' . $placeholder . '">';
68
+
69
+ if ( $args['show_option_all'] ) {
70
+ if( $args['multiple'] ) {
71
+ $selected = selected( true, in_array( 0, $args['selected'] ), false );
72
+ } else {
73
+ $selected = selected( $args['selected'], 0, false );
74
+ }
75
+ $output .= '<option value="all"' . $selected . '>' . esc_html( $args['show_option_all'] ) . '</option>';
76
+ }
77
+
78
+ if ( ! empty( $args['options'] ) ) {
79
+
80
+ if ( $args['show_option_none'] ) {
81
+ if( $args['multiple'] ) {
82
+ $selected = selected( true, in_array( -1, $args['selected'] ), false );
83
+ } else {
84
+ $selected = selected( $args['selected'], -1, false );
85
+ }
86
+ $output .= '<option value="-1"' . $selected . '>' . esc_html( $args['show_option_none'] ) . '</option>';
87
+ }
88
+
89
+ foreach( $args['options'] as $key => $option ) {
90
+
91
+ if( $args['multiple'] && is_array( $args['selected'] ) ) {
92
+ $selected = selected( true, in_array( $key, $args['selected'] ), false );
93
+ } else {
94
+ $selected = selected( $args['selected'], $key, false );
95
+ }
96
+
97
+ $output .= '<option value="' . esc_attr( $key ) . '"' . $selected . '>' . esc_html( $option ) . '</option>';
98
+ }
99
+ }
100
+
101
+ $output .= '</select>';
102
+
103
+ return $output;
104
+ }
105
+
106
+ /**
107
+ * Renders an HTML Checkbox
108
+ *
109
+ * @since 0.0.9
110
+ *
111
+ * @param array $args
112
+ *
113
+ * @return string
114
+ */
115
+ public function checkbox( $args = array() ) {
116
+ $defaults = array(
117
+ 'name' => null,
118
+ 'current' => null,
119
+ 'class' => 'quads-checkbox',
120
+ 'value' => 'on',
121
+ 'options' => array(
122
+ 'disabled' => false,
123
+ 'readonly' => false
124
+ )
125
+
126
+ );
127
+
128
+ $args = wp_parse_args( $args, $defaults );
129
+
130
+ $options = '';
131
+ if ( ! empty( $args['options']['disabled'] ) ) {
132
+ $options .= ' disabled="disabled"';
133
+ } elseif ( ! empty( $args['options']['readonly'] ) ) {
134
+ $options .= ' readonly';
135
+ }
136
+
137
+ $output = '<input type="checkbox"' . $options . ' name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . ' ' . esc_attr( $args['name'] ) . '" ' . checked( $args['value'], $args['current'], false ) . ' />\n';
138
+
139
+ return $output;
140
+ }
141
+
142
+ /**
143
+ * Renders an HTML Text field
144
+ *
145
+ * @since 0.0.9
146
+ *
147
+ * @param array $args Arguments for the text field
148
+ * @return string Text field
149
+ */
150
+ public function text( $args = array() ) {
151
+ // Backwards compatabliity
152
+ if ( func_num_args() > 1 ) {
153
+ $args = func_get_args();
154
+
155
+ $name = $args[0];
156
+ $value = isset( $args[1] ) ? $args[1] : '';
157
+ $label = isset( $args[2] ) ? $args[2] : '';
158
+ $desc = isset( $args[3] ) ? $args[3] : '';
159
+ }
160
+
161
+ $defaults = array(
162
+ 'id' => '',
163
+ 'name' => isset( $name ) ? $name : 'text',
164
+ 'value' => isset( $value ) ? $value : null,
165
+ 'label' => isset( $label ) ? $label : null,
166
+ 'desc' => isset( $desc ) ? $desc : null,
167
+ 'placeholder' => '',
168
+ 'class' => 'regular-text',
169
+ 'disabled' => false,
170
+ 'autocomplete' => '',
171
+ 'data' => false
172
+ );
173
+
174
+ $args = wp_parse_args( $args, $defaults );
175
+
176
+ $disabled = '';
177
+ if( $args['disabled'] ) {
178
+ $disabled = ' disabled="disabled"';
179
+ }
180
+
181
+ $data = '';
182
+ if ( ! empty( $args['data'] ) ) {
183
+ foreach ( $args['data'] as $key => $value ) {
184
+ $data .= 'data-' . $key . '="' . $value . '" ';
185
+ }
186
+ }
187
+
188
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
189
+
190
+ $output .= '<label class="quads-label" for="' . sanitize_key( $args['id'] ) . '">' . esc_html( $args['label'] ) . '</label>';
191
+
192
+ if ( ! empty( $args['desc'] ) ) {
193
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
194
+ }
195
+
196
+ $output .= '<input type="text" name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['id'] ) . '" autocomplete="' . esc_attr( $args['autocomplete'] ) . '" value="' . esc_attr( $args['value'] ) . '" placeholder="' . esc_attr( $args['placeholder'] ) . '" class="' . $args['class'] . '" ' . $data . '' . $disabled . '/>';
197
+
198
+ $output .= '</span>';
199
+
200
+ return $output;
201
+ }
202
+ /**
203
+ * Renders a date picker
204
+ *
205
+ * @since 0.0.9
206
+ *
207
+ * @param array $args Arguments for the text field
208
+ * @return string Datepicker field
209
+ */
210
+ public function date_field( $args = array() ) {
211
+
212
+ if( empty( $args['class'] ) ) {
213
+ $args['class'] = 'quads_datepicker';
214
+ } elseif( ! strpos( $args['class'], 'quads_datepicker' ) ) {
215
+ $args['class'] .= ' quads_datepicker';
216
+ }
217
+
218
+ return $this->text( $args );
219
+ }
220
+
221
+ /**
222
+ * Renders an HTML textarea
223
+ *
224
+ * @since 0.0.9
225
+ *
226
+ * @param array $args Arguments for the textarea
227
+ * @return string textarea
228
+ */
229
+ public function textarea( $args = array() ) {
230
+ $defaults = array(
231
+ 'name' => 'textarea',
232
+ 'value' => null,
233
+ 'label' => null,
234
+ 'desc' => null,
235
+ 'class' => 'large-text',
236
+ 'disabled' => false
237
+ );
238
+
239
+ $args = wp_parse_args( $args, $defaults );
240
+
241
+ $disabled = '';
242
+ if( $args['disabled'] ) {
243
+ $disabled = ' disabled="disabled"';
244
+ }
245
+
246
+ $output = '<span id="quads-' . sanitize_key( $args['name'] ) . '-wrap">';
247
+
248
+ $output .= '<label class="quads-label" for="quads-' . sanitize_key( $args['name'] ) . '">' . esc_html( $args['label'] ) . '</label>';
249
+
250
+ $output .= '<textarea name="' . esc_attr( $args['name'] ) . '" id="' . esc_attr( $args['name'] ) . '" class="' . $args['class'] . '"' . $disabled . '>' . esc_attr( $args['value'] ) . '</textarea>';
251
+
252
+ if ( ! empty( $args['desc'] ) ) {
253
+ $output .= '<span class="quads-description">' . esc_html( $args['desc'] ) . '</span>';
254
+ }
255
+
256
+ $output .= '</span>';
257
+
258
+ return $output;
259
+ }
260
+
261
+
262
+ /**
263
+ * Renders an HTML Dropdown of years
264
+ *
265
+ * @access public
266
+ * @since 0.0.9
267
+ * @param string $name Name attribute of the dropdown
268
+ * @param int $selected Year to select automatically
269
+ * @param int $years_before Number of years before the current year the dropdown should start with
270
+ * @param int $years_after Number of years after the current year the dropdown should finish at
271
+ * @return string $output Year dropdown
272
+ */
273
+ public function year_dropdown( $name = 'year', $selected = 0, $years_before = 5, $years_after = 0 ) {
274
+ $current = date( 'Y' );
275
+ $start_year = $current - absint( $years_before );
276
+ $end_year = $current + absint( $years_after );
277
+ $selected = empty( $selected ) ? date( 'Y' ) : $selected;
278
+ $options = array();
279
+
280
+ while ( $start_year <= $end_year ) {
281
+ $options[ absint( $start_year ) ] = $start_year;
282
+ $start_year++;
283
+ }
284
+
285
+ $output = $this->select( array(
286
+ 'name' => $name,
287
+ 'selected' => $selected,
288
+ 'options' => $options,
289
+ 'show_option_all' => false,
290
+ 'show_option_none' => false
291
+ ) );
292
+
293
+ return $output;
294
+ }
295
+
296
+ /**
297
+ * Renders an HTML Dropdown of months
298
+ *
299
+ * @access public
300
+ * @since 0.0.9
301
+ * @param string $name Name attribute of the dropdown
302
+ * @param int $selected Month to select automatically
303
+ * @return string $output Month dropdown
304
+ */
305
+ public function month_dropdown( $name = 'month', $selected = 0 ) {
306
+ $month = 1;
307
+ $options = array();
308
+ $selected = empty( $selected ) ? date( 'n' ) : $selected;
309
+
310
+ while ( $month <= 12 ) {
311
+ $options[ absint( $month ) ] = quads_month_num_to_name( $month );
312
+ $month++;
313
+ }
314
+
315
+ $output = $this->select( array(
316
+ 'name' => $name,
317
+ 'selected' => $selected,
318
+ 'options' => $options,
319
+ 'show_option_all' => false,
320
+ 'show_option_none' => false
321
+ ) );
322
+
323
+ return $output;
324
+ }
325
+
326
+ }
includes/logger.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Simple Logger Class
4
+ *
5
+ * @author Josh Nesbitt <josh@josh-nesbitt.net>
6
+ * @author René Hermenau info@mashshare.net
7
+ *
8
+ * By default will write to path/to/logger/ + log/filename.log
9
+ * Author url: https://raw.githubusercontent.com/joshnesbitt/logger/master/lib/logger.php
10
+ *
11
+ **/
12
+ class quadsLogger {
13
+ var $file, $path, $level, $stream;
14
+ const INFO = 4;
15
+ const DEBUG = 3;
16
+ const WARN = 2;
17
+ const ERROR = 1;
18
+ const FATAL = 0;
19
+
20
+ function __construct($file, $level)
21
+ {
22
+ $this->file = $file;
23
+ $this->level = $level;
24
+ $this->path = QUADS_PLUGIN_DIR . "logs/$this->file";
25
+ $this->folder = QUADS_PLUGIN_DIR . "logs";
26
+ $this->start();
27
+ }
28
+
29
+ function info($string)
30
+ {
31
+ return $this->check_level(self::INFO) ? true : $this->log($string);
32
+ }
33
+
34
+ function warn($string)
35
+ {
36
+ return $this->check_level(self::WARN) ? true : $this->log($string);
37
+ }
38
+
39
+ function debug($string)
40
+ {
41
+ return $this->check_level(self::DEBUG) ? true : $this->log($string);
42
+ }
43
+
44
+ function error($string)
45
+ {
46
+ return $this->check_level(self::ERROR) ? true : $this->log($string);
47
+ }
48
+
49
+ function fatal($string)
50
+ {
51
+ return $this->check_level(self::FATAL) ? true : $this->log($string);
52
+ }
53
+
54
+ function clear()
55
+ {
56
+ $this->close();
57
+ $this->open("w");
58
+ $this->close();
59
+ $this->open();
60
+ }
61
+
62
+ private function check_level($level)
63
+ {
64
+ return $this->level < $level;
65
+ }
66
+
67
+ /* Log - Only when Quick AdSense debug mode is enabled
68
+ */
69
+ private function log($string)
70
+ {
71
+ global $quads_options;
72
+ $enabled = isset($quads_options['debug_mode']) ? $quads_options['debug_mode'] : false;
73
+ if ($enabled)
74
+ $this->write("[". date('l jS F Y : h:i:sa') . "] ". $string . "\r\n");
75
+
76
+ return false;
77
+ }
78
+
79
+ private function write($string)
80
+ {
81
+ return fwrite($this->stream, $string);
82
+ }
83
+
84
+ /* Check if debug mode is enabled
85
+ *
86
+ * @return bool
87
+ */
88
+ private function start()
89
+ {
90
+ global $quads_options;
91
+ $enabled = isset($quads_options['debug_mode']) ? $quads_options['debug_mode'] : false;
92
+ if ($enabled)
93
+ return $this->open();
94
+
95
+ return false;
96
+ }
97
+
98
+ /* Check if directory is writable
99
+ *
100
+ * @return bool
101
+ */
102
+
103
+ function checkDir(){
104
+ $writable = is_writable($this->folder);
105
+ if ($writable)
106
+ return true;
107
+
108
+ return false;
109
+ }
110
+
111
+ /* Open the log file
112
+ *
113
+ * @return stream
114
+ */
115
+ private function open($mode="a")
116
+ {
117
+ if ($this->checkDir())
118
+ return $this->stream = fopen($this->path, $mode);
119
+ //or die("Cannot write to file '$this->path', please ensure '$this->path' is writable.");
120
+ }
121
+
122
+ private function close()
123
+ {
124
+ return fclose($this->stream);
125
+ }
126
+
127
+ }
128
+
129
+ ?>
includes/meta-boxes.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Meta box functions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions/Meta Boxes
7
+ * @copyright Copyright (c) 2015, René Hermenau, Lukasz Wesolowski
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 0.9.6
10
+ */
11
+ function quads_load_meta_box () {
12
+ new Quads_Meta_Box();
13
+ }
14
+ add_action( 'load-post.php', 'quads_load_meta_box' );
15
+ add_action( 'load-post-new.php', 'quads_load_meta_box' );
16
+ /**
17
+ * Ads options for a single post
18
+ */
19
+ class Quads_Meta_Box {
20
+ private $config_key;
21
+ private $meta_key_visibility;
22
+ public function __construct() {
23
+ $this->config_key = 'quads_config';
24
+ $this->meta_key_visibility = '_quads_config_visibility';
25
+ $this->setup_hooks();
26
+ }
27
+ public function setup_hooks() {
28
+ add_action( 'add_meta_boxes', array( $this, 'add_meta_boxes' ) );
29
+ add_action( 'save_post', array( $this, 'save' ) );
30
+ }
31
+ public function get_allowed_post_types () {
32
+ return apply_filters( 'quads_meta_box_post_types', array( 'post', 'page' ) );
33
+ }
34
+ public function add_meta_boxes ( $post_type ) {
35
+ if ( !in_array( $post_type, $this->get_allowed_post_types() ) ) {
36
+ return;
37
+ }
38
+ add_meta_box(
39
+ 'quads_meta_box', // id
40
+ __('WP QUADS - Hide Ads', 'quick-adsense-reloaded'), // title
41
+ array($this, 'render_meta_box'), // render function callback
42
+ $post_type, // post_type
43
+ 'normal', // context
44
+ 'default' // priority
45
+ );
46
+ }
47
+ public function render_meta_box ( $post, $meta_box ) {
48
+ // Secure the form with nonce field
49
+ $nonce = wp_nonce_field(
50
+ 'quads_config',
51
+ 'quads_config_nonce',
52
+ true,
53
+ false
54
+ );
55
+ // process visibility options
56
+ $visibility_value = get_post_meta( $post->ID, $this->meta_key_visibility, true );
57
+ // on first load, when post meta value is empty, we set defaults based on quicktags in content
58
+ $visibility_value = wp_parse_args( $visibility_value, quads_get_quicktags_from_content( $post->post_content ) );
59
+ $quicktags = quads_quicktag_list();
60
+ echo $nonce;
61
+ foreach ( $quicktags as $quicktag_id => $quicktag_label ) {
62
+ $checkbox_name = sprintf( '%s[visibility][%s]', $this->config_key, $quicktag_id );
63
+ ?>
64
+ <p>
65
+ <?php //echo 'id: ' . $quicktag_id . ' vid:' .$visibility_value[$quicktag_id];?>
66
+ <label>
67
+ <input id="<?php echo esc_attr( $checkbox_name ) ?>" type="checkbox" name="<?php echo esc_attr( $checkbox_name ) ?>" value="1" <?php checked( isset( $visibility_value[ $quicktag_id ] ), true ); ?> />
68
+ <?php echo esc_html( $quicktag_label ); ?>
69
+ </label>
70
+ </p>
71
+ <?php
72
+ }
73
+ }
74
+ public function save($post_id) {
75
+ // Don't save data automatically via autosave feature
76
+ if ($this->is_doing_autosave()) {
77
+ return $post_id;
78
+ }
79
+ // Don't save data when doing preview
80
+ if ($this->is_doing_preview()) {
81
+ return $post_id;
82
+ }
83
+ // Don't save data when using Quick Edit
84
+ if ($this->is_inline_edit()) {
85
+ return $post_id;
86
+ }
87
+ $post_type = isset($_POST['post_type']) ? $_POST['post_type'] : null;
88
+ // Update options only if they are appliable
89
+ if (!in_array($post_type, $this->get_allowed_post_types())) {
90
+ return $post_id;
91
+ }
92
+ // Check permissions
93
+ $post_type_obj = get_post_type_object($post_type);
94
+ if (!current_user_can($post_type_obj->cap->edit_post, $post_id)) {
95
+ return $post_id;
96
+ }
97
+ // Verify nonce
98
+ if (!check_admin_referer('quads_config', 'quads_config_nonce')) {
99
+ wp_die(__('Nonce incorrect!', 'quads'));
100
+ }
101
+ $config = isset($_POST[$this->config_key]) ? $_POST[$this->config_key] : array();
102
+ $visibility_config = isset($config['visibility']) ? $config['visibility'] : array();
103
+ // process visibility config
104
+ // store it in separate meta key
105
+ $checked_qtags = array();
106
+ $allowed_fields = quads_quicktag_list();
107
+ foreach ($allowed_fields as $qtag_id => $qtag_label) {
108
+ if (isset($visibility_config[$qtag_id])) {
109
+ $checked_qtags[$qtag_id] = 1;
110
+ }
111
+ }
112
+ // strip all forbidden values
113
+ foreach ($visibility_config as $qtag_id => $qtag_label) {
114
+ if (isset($allowed_fields[$qtag_id])) {
115
+ $checked_qtags[$qtag_id] = 1;
116
+ }
117
+ }
118
+ update_post_meta($post_id, $this->meta_key_visibility, $checked_qtags);
119
+ }
120
+
121
+ protected function is_doing_autosave() {
122
+ return defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ? true : false;
123
+ }
124
+ protected function is_inline_edit() {
125
+ return isset( $_POST['_inline_edit'] ) ? true : false;
126
+ }
127
+ protected function is_doing_preview () {
128
+ return !empty( $_POST['wp-preview'] );
129
+ }
130
+ }
includes/post_types.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Post Types
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/post_types
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.8
11
+ */
12
+
13
+ /**
14
+ * Get list of available post_types
15
+ *
16
+ * @return array list of post_types
17
+ */
18
+ function quads_get_post_types(){
19
+ $post_types = array('post'=>'post', 'page'=>'page');
20
+ return apply_filters('quads_post_types',$post_types);
21
+ }
22
+
23
+ /**
24
+ * Check if ad is allowed on specific post_type
25
+ *
26
+ * @global array $quads_options
27
+ * @global array $post
28
+ * @return boolean true if post_type is allowed
29
+ */
30
+ function quads_post_type_allowed(){
31
+ global $quads_options, $post;
32
+
33
+ if (!isset($post)){
34
+ return false;
35
+ }
36
+
37
+ if (!isset($quads_options['post_types']) || empty($quads_options['post_types'])){
38
+ return false;
39
+ }
40
+
41
+ $current_post_type = get_post_type($post->ID);
42
+ if ( in_array( $current_post_type, $quads_options['post_types'] )){
43
+ return true;
44
+ }
45
+ return false;
46
+ }
includes/quads-utils.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class QUADS_Utils {
4
+
5
+
6
+ /**
7
+ * Checks if another version of QUADS (Pro) is active and deactivates it.
8
+ * To be hooked on `activated_plugin` so other plugin is deactivated when current plugin is activated.
9
+ *
10
+ * @param string $plugin
11
+ *
12
+ */
13
+ public static function deactivate_other_instances( $plugin ) {
14
+
15
+ if ( ! in_array( basename( $plugin ), array( 'wp-quads-pro.php', 'quick-adsense-reloaded.php' ) ) ) {
16
+ return;
17
+ }
18
+
19
+ $plugin_to_deactivate = 'quick-adsense-reloaded.php';
20
+ $deactivated_notice_id = '1';
21
+ if ( basename( $plugin ) == $plugin_to_deactivate ) {
22
+ $plugin_to_deactivate = 'wp-quads-pro.php';
23
+ $deactivated_notice_id = '2';
24
+ }
25
+
26
+ if ( is_multisite() ) {
27
+ $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
28
+ $active_plugins = array_keys( $active_plugins );
29
+ } else {
30
+ $active_plugins = (array) get_option( 'active_plugins', array() );
31
+ }
32
+
33
+
34
+
35
+ foreach ( $active_plugins as $basename ) {
36
+ if ( false !== strpos( $basename, $plugin_to_deactivate ) ) {
37
+ set_transient( 'quads_deactivated_notice_id', $deactivated_notice_id, 1 * HOUR_IN_SECONDS );
38
+ deactivate_plugins( $basename );
39
+ return;
40
+ }
41
+ }
42
+ }
43
+
44
+
45
+ }
includes/quicktags.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Quicktags functions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions/Quicktags
7
+ * @copyright Copyright (c) 2015, René Hermenau, Lukasz Wesolowksi
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 0.9.6
10
+ */
11
+ add_filter( 'content_edit_pre', 'quads_strip_quicktags_from_content' );
12
+ add_filter( 'content_save_pre', 'quads_strip_quicktags_from_content' );
13
+ /**
14
+ * Removes all quicktags from content, but only if their config is already stored in post meta
15
+ *
16
+ * @param string $content
17
+ * @return string Filtered content
18
+ */
19
+ function quads_strip_quicktags_from_content ( $content ) {
20
+ $ads_visibility_config = get_post_meta( get_the_ID(), '_quads_config_visibility', true );
21
+ // if config exists, quicktags are handled via metabox
22
+ // so we don't need them anymore in the content
23
+ if ( $ads_visibility_config ) {
24
+ $content = quads_strip_quicktags( $content );
25
+ }
26
+ return $content;
27
+ }
28
+ /**
29
+ * Returns an array of all quicktags found in content
30
+ *
31
+ * @param string $content
32
+ * @return array List of quicktags
33
+ */
34
+ function quads_get_quicktags_from_content ( $content ) {
35
+ $found = array();
36
+ $quicktags = quads_quicktag_list();
37
+ // we can use preg_match instead of multiple calls of strpos(),
38
+ // but strpos is much faster and for such a small array should still be faster than preg_match()
39
+ foreach ( $quicktags as $id => $label ) {
40
+ if ( false !== strpos( $content, '<!--' . $id . '-->' ) ) {
41
+ $found[ $id ] = 1;
42
+ }
43
+ }
44
+ return $found;
45
+ }
46
+ /**
47
+ * Removes all quicktags from content
48
+ *
49
+ * @param string $content
50
+ * @return string Filtered content
51
+ */
52
+ function quads_strip_quicktags ( $content ) {
53
+ $quicktags = quads_quicktag_list();
54
+ foreach ( $quicktags as $id => $label ) {
55
+ $content = str_replace( '<!--'. $id .'-->', '', $content );
56
+ }
57
+ return $content;
58
+ }
59
+ /**
60
+ * Returns list of all allowed quicktags
61
+ *
62
+ * @return array List of quicktags
63
+ */
64
+ function quads_quicktag_list () {
65
+ return apply_filters( 'quads_quicktag_list', array(
66
+ /*'NoAds' => __( 'Disable all Ads <!--NoAds-->', 'quick-adsense-reloaded' ),
67
+ 'OffDef' => __( '<!--OffDef-->', 'quick-adsense-reloaded' ),
68
+ 'OffWidget' => __( '<!--OffWidget-->', 'quick-adsense-reloaded' ),
69
+ 'OffBegin' => __( '<!--OffBegin-->', 'quick-adsense-reloaded' ),
70
+ 'OffMiddle' => __( '<!--OffMiddle-->', 'quick-adsense-reloaded' ),
71
+ 'OffEnd' => __( '<!--OffEnd-->', 'quick-adsense-reloaded' ),
72
+ 'OffAfMore' => __( '<!--OffAfMore-->', 'quick-adsense-reloaded' ),
73
+ 'OffBfLastPara' => __( '<!--OffBfLastPara-->', 'quick-adsense-reloaded' ),*/
74
+ 'NoAds' => __( 'Hide all ads on page', 'quick-adsense-reloaded' ),
75
+ 'OffDef' => __( 'Hide default ads, use manually placed ads', 'quick-adsense-reloaded' ),
76
+ 'OffWidget' => __( 'Hide all ads in sidebar', 'quick-adsense-reloaded' ),
77
+ 'OffBegin' => __( 'Hide ad on beginning', 'quick-adsense-reloaded' ),
78
+ 'OffMiddle' => __( 'Hide ad in middle', 'quick-adsense-reloaded' ),
79
+ 'OffEnd' => __( 'Hide ad on end', 'quick-adsense-reloaded' ),
80
+ 'OffAfMore' => __( 'Hide ad after MoreTag', 'quick-adsense-reloaded' ),
81
+ 'OffBfLastPara' => __( 'Hide ad before last paragraph', 'quick-adsense-reloaded' ),
82
+ ) );
83
+ }
includes/render-ad-functions.php ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Render Ad Functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/Render Ad Functions
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 0.9.0
11
+ */
12
+ // Exit if accessed directly
13
+ if( !defined( 'ABSPATH' ) )
14
+ exit;
15
+
16
+ /**
17
+ * Render the adsense code
18
+ *
19
+ * @param1 string the ad id => ad1, ad2, ad3 etc
20
+ * @param2 string $string The adsense code
21
+ * @param3 bool True when function is called from widget
22
+ *
23
+ * @todo create support for widgets
24
+ * @return string HTML js adsense code
25
+ */
26
+ function quads_render_ad( $id, $string, $widget = false ) {
27
+
28
+ // Return empty string
29
+ if( empty( $id ) ) {
30
+ return '';
31
+ }
32
+
33
+
34
+ if (quads_is_amp_endpoint()){
35
+ return quads_render_amp($id);
36
+ }
37
+
38
+
39
+ // Return the original ad code if it's no adsense code
40
+ if( false === quads_is_adsense( $id, $string ) && !empty( $string ) ) {
41
+ // allow use of shortcodes in ad plain text content
42
+ $string = quadsCleanShortcode('quads', $string);
43
+ //wp_die('t1');
44
+ return apply_filters( 'quads_render_ad', $string );
45
+ }
46
+
47
+ // Return the adsense ad code
48
+ if( true === quads_is_adsense( $id, $string ) ) {
49
+ //wp_die('t2');
50
+ return apply_filters( 'quads_render_ad', quads_render_google_async( $id ) );
51
+ }
52
+
53
+ // Return empty string
54
+ //wp_die('t3');
55
+ return '';
56
+ }
57
+
58
+ /**
59
+ * Render Google async ad
60
+ *
61
+ * @global array $quads_options
62
+ * @param int $id
63
+ * @return html
64
+ */
65
+ function quads_render_google_async( $id ) {
66
+ global $quads_options;
67
+
68
+
69
+ // Default ad sizes - Option: Auto
70
+ $default_ad_sizes[$id] = array(
71
+ 'desktop_width' => '300',
72
+ 'desktop_height' => '250',
73
+ 'tbl_landscape_width' => '300',
74
+ 'tbl_landscape_height' => '250',
75
+ 'tbl_portrait_width' => '300',
76
+ 'tbl_portrait_height' => '250',
77
+ 'phone_width' => '300',
78
+ 'phone_height' => '250'
79
+ );
80
+
81
+ // Overwrite default values if there are ones
82
+ // Desktop big ad
83
+ if( !empty( $quads_options[$id]['desktop_size'] ) && $quads_options[$id]['desktop_size'] !== 'Auto' ) {
84
+ $ad_size_parts = explode( ' x ', $quads_options[$id]['desktop_size'] );
85
+ $default_ad_sizes[$id]['desktop_width'] = $ad_size_parts[0];
86
+ $default_ad_sizes[$id]['desktop_height'] = $ad_size_parts[1];
87
+ }
88
+
89
+
90
+ //tablet landscape
91
+ if( !empty( $quads_options[$id]['tbl_lands_size'] ) && $quads_options[$id]['tbl_lands_size'] !== 'Auto' ) {
92
+ $ad_size_parts = explode( ' x ', $quads_options[$id]['tbl_lands_size'] );
93
+ $default_ad_sizes[$id]['tbl_landscape_width'] = $ad_size_parts[0];
94
+ $default_ad_sizes[$id]['tbl_landscape_height'] = $ad_size_parts[1];
95
+ }
96
+
97
+
98
+ //tablet portrait
99
+ if( !empty( $quads_options[$id]['tbl_portr_size'] ) && $quads_options[$id]['tbl_portr_size'] !== 'Auto' ) {
100
+ $ad_size_parts = explode( ' x ', $quads_options[$id]['tbl_portr_size'] );
101
+ $default_ad_sizes[$id]['tbl_portrait_width'] = $ad_size_parts[0];
102
+ $default_ad_sizes[$id]['tbl_portrait_height'] = $ad_size_parts[1];
103
+ }
104
+
105
+
106
+ //phone
107
+ if( !empty( $quads_options[$id]['phone_size'] ) && $quads_options[$id]['phone_size'] !== 'Auto' ) {
108
+ $ad_size_parts = explode( ' x ', $quads_options[$id]['phone_size'] );
109
+ $default_ad_sizes[$id]['phone_width'] = $ad_size_parts[0];
110
+ $default_ad_sizes[$id]['phone_height'] = $ad_size_parts[1];
111
+ }
112
+
113
+
114
+ $html = "\n <!-- " . QUADS_NAME . " v." . QUADS_VERSION . " Content AdSense async --> \n\n";
115
+
116
+ //google async script
117
+ $html .= '<script async data-cfasync="false" src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>';
118
+
119
+ $html .= '<script type="text/javascript" data-cfasync="false">' . "\n";
120
+ $html .= 'var quads_screen_width = document.body.clientWidth;' . "\n";
121
+
122
+
123
+ $html .= quads_render_desktop_js( $id, $default_ad_sizes );
124
+ $html .= quads_render_tablet_landscape_js( $id, $default_ad_sizes );
125
+ $html .= quads_render_tablet_portrait_js( $id, $default_ad_sizes );
126
+ $html .= quads_render_phone_js( $id, $default_ad_sizes );
127
+
128
+ $html .= '</script>' . "\n";
129
+
130
+ $html .= "\n <!-- end WP QUADS --> \n\n";
131
+
132
+ return apply_filters( 'quads_render_adsense_async', $html );
133
+ }
134
+
135
+ /**
136
+ * Render Google Ad Code Java Script for desktop devices
137
+ *
138
+ * @global array $quads_options
139
+ * @param string $id
140
+ * @param array $default_ad_sizes
141
+ * @return string
142
+ */
143
+ function quads_render_desktop_js( $id, $default_ad_sizes ) {
144
+ global $quads_options;
145
+
146
+ $adtype = 'desktop';
147
+
148
+ $backgroundcolor = '';
149
+
150
+ $responsive_style = 'display:block;' . $backgroundcolor;
151
+
152
+ if( quads_is_advanced() && isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ) {
153
+ $width = $default_ad_sizes[$id][$adtype.'_width'];
154
+
155
+ $height = $default_ad_sizes[$id][$adtype.'_height'];
156
+
157
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
158
+
159
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' && (isset( $quads_options[$id][$adtype.'_size'] ) && $quads_options[$id][$adtype.'_size'] === 'Auto') ? $responsive_style : $normal_style;
160
+ } else {
161
+ $width = empty( $quads_options[$id]['g_data_ad_width'] ) ? $default_ad_sizes[$id][$adtype.'_width'] : $quads_options[$id]['g_data_ad_width'];
162
+
163
+ $height = empty( $quads_options[$id]['g_data_ad_height'] ) ? $default_ad_sizes[$id][$adtype.'_height'] : $quads_options[$id]['g_data_ad_height'];
164
+
165
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
166
+
167
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ? $responsive_style : $normal_style;
168
+ }
169
+
170
+ $ad_format = (isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive') && (isset( $quads_options[$id][$adtype.'_size'] ) && $quads_options[$id][$adtype.'_size'] === 'Auto') ? 'data-ad-format="auto"' : '';
171
+
172
+ $html = '<ins class="adsbygoogle" style="' . $style . '"';
173
+ $html .= ' data-ad-client="' . $quads_options[$id]['g_data_ad_client'] . '"';
174
+ $html .= ' data-ad-slot="' . $quads_options[$id]['g_data_ad_slot'] . '" ' . $ad_format . '></ins>';
175
+
176
+ if( !isset( $quads_options[$id][$adtype] ) and !empty( $default_ad_sizes[$id][$adtype.'_width'] ) and ! empty( $default_ad_sizes[$id][$adtype.'_height'] ) ) {
177
+ $js = 'if ( quads_screen_width >= 1140 ) {
178
+ /* desktop monitors */
179
+ document.write(\'' . $html . '\');
180
+ (adsbygoogle = window.adsbygoogle || []).push({});
181
+ }';
182
+ return $js;
183
+ }
184
+ }
185
+
186
+ /**
187
+ * Render Google Ad Code Java Script for tablet landscape devices
188
+ *
189
+ * @global array $quads_options
190
+ * @param string $id
191
+ * @param array $default_ad_sizes
192
+ * @return string
193
+ */
194
+ function quads_render_tablet_landscape_js( $id, $default_ad_sizes ) {
195
+ global $quads_options;
196
+
197
+ $adtype = 'tbl_landscape';
198
+ $adtype_short = 'tbl_lands';
199
+
200
+ //$backgroundcolor = 'background-color:white;'; // Pro Version
201
+ $backgroundcolor = '';
202
+
203
+ $responsive_style = 'display:block;' . $backgroundcolor;
204
+
205
+ if( quads_is_advanced() && isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ) {
206
+ $width = $default_ad_sizes[$id][$adtype.'_width'];
207
+
208
+ $height = $default_ad_sizes[$id][$adtype.'_height'];
209
+
210
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
211
+
212
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' && (isset( $quads_options[$id][$adtype_short.'_size'] ) && $quads_options[$id][$adtype_short.'_size'] === 'Auto') ? $responsive_style : $normal_style;
213
+ } else {
214
+ $width = empty( $quads_options[$id]['g_data_ad_width'] ) ? $default_ad_sizes[$id][$adtype.'_width'] : $quads_options[$id]['g_data_ad_width'];
215
+
216
+ $height = empty( $quads_options[$id]['g_data_ad_height'] ) ? $default_ad_sizes[$id][$adtype.'_height'] : $quads_options[$id]['g_data_ad_height'];
217
+
218
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
219
+
220
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ? $responsive_style : $normal_style;
221
+ }
222
+
223
+ $ad_format = (isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive') && (isset( $quads_options[$id][$adtype_short.'_size'] ) && $quads_options[$id][$adtype_short.'_size'] === 'Auto') ? 'data-ad-format="auto"' : '';
224
+
225
+
226
+ $html = '<ins class="adsbygoogle" style="' . $style . '"';
227
+ $html .= ' data-ad-client="' . $quads_options[$id]['g_data_ad_client'] . '"';
228
+ $html .= ' data-ad-slot="' . $quads_options[$id]['g_data_ad_slot'] . '" ' . $ad_format . '></ins>';
229
+
230
+ if( !isset( $quads_options[$id]['tablet_landscape'] ) and ! empty( $default_ad_sizes[$id][$adtype.'_width'] ) and ! empty( $default_ad_sizes[$id][$adtype.'_height'] ) ) {
231
+ $js = 'if ( quads_screen_width >= 1024 && quads_screen_width < 1140 ) {
232
+ /* tablet landscape */
233
+ document.write(\'' . $html . '\');
234
+ (adsbygoogle = window.adsbygoogle || []).push({});
235
+ }';
236
+ return $js;
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Render Google Ad Code Java Script for tablet portrait devices
242
+ *
243
+ * @global array $quads_options
244
+ * @param string $id
245
+ * @param array $default_ad_sizes
246
+ * @return string
247
+ */
248
+ function quads_render_tablet_portrait_js( $id, $default_ad_sizes ) {
249
+ global $quads_options;
250
+
251
+ $adtype = 'tbl_portrait';
252
+
253
+ $adtype_short = 'tbl_portr';
254
+
255
+ $backgroundcolor = '';
256
+
257
+ $responsive_style = 'display:block;' . $backgroundcolor;
258
+
259
+ if( quads_is_advanced() && isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ) {
260
+ $width = $default_ad_sizes[$id][$adtype.'_width'];
261
+
262
+ $height = $default_ad_sizes[$id][$adtype.'_height'];
263
+
264
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
265
+
266
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' && (isset( $quads_options[$id][$adtype_short.'_size'] ) && $quads_options[$id][$adtype_short.'_size'] === 'Auto') ? $responsive_style : $normal_style;
267
+ } else {
268
+ $width = empty( $quads_options[$id]['g_data_ad_width'] ) ? $default_ad_sizes[$id][$adtype.'_width'] : $quads_options[$id]['g_data_ad_width'];
269
+
270
+ $height = empty( $quads_options[$id]['g_data_ad_height'] ) ? $default_ad_sizes[$id][$adtype.'_height'] : $quads_options[$id]['g_data_ad_height'];
271
+
272
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
273
+
274
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ? $responsive_style : $normal_style;
275
+ }
276
+
277
+ $ad_format = (isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive') && (isset( $quads_options[$id][$adtype_short.'_size'] ) && $quads_options[$id][$adtype_short.'_size'] === 'Auto') ? 'data-ad-format="auto"' : '';
278
+
279
+ $html = '<ins class="adsbygoogle" style="' . $style . '"';
280
+ $html .= ' data-ad-client="' . $quads_options[$id]['g_data_ad_client'] . '"';
281
+ $html .= ' data-ad-slot="' . $quads_options[$id]['g_data_ad_slot'] . '" ' . $ad_format . '></ins>';
282
+
283
+ if( !isset( $quads_options[$id]['tablet_portrait'] ) and !empty( $default_ad_sizes[$id]['tbl_portrait_width'] ) and !empty( $default_ad_sizes[$id][$adtype.'_height'] ) ) {
284
+ $js = 'if ( quads_screen_width >= 768 && quads_screen_width < 1024 ) {
285
+ /* tablet portrait */
286
+ document.write(\'' . $html . '\');
287
+ (adsbygoogle = window.adsbygoogle || []).push({});
288
+ }';
289
+ return $js;
290
+ }
291
+ }
292
+
293
+ /**
294
+ * Render Google Ad Code Java Script for phone devices
295
+ *
296
+ * @global array $quads_options
297
+ * @param string $id
298
+ * @param array $default_ad_sizes
299
+ * @return string
300
+ */
301
+ function quads_render_phone_js( $id, $default_ad_sizes ) {
302
+ global $quads_options;
303
+
304
+ $adtype = 'phone';
305
+
306
+ $backgroundcolor = '';
307
+
308
+ $responsive_style = 'display:block;' . $backgroundcolor;
309
+
310
+ if( quads_is_advanced() && isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ) {
311
+ $width = $default_ad_sizes[$id][$adtype.'_width'];
312
+
313
+ $height = $default_ad_sizes[$id][$adtype.'_height'];
314
+
315
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
316
+
317
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' && (isset( $quads_options[$id][$adtype.'_size'] ) && $quads_options[$id][$adtype.'_size'] === 'Auto') ? $responsive_style : $normal_style;
318
+ } else {
319
+ $width = empty( $quads_options[$id]['g_data_ad_width'] ) ? $default_ad_sizes[$id][$adtype.'_width'] : $quads_options[$id]['g_data_ad_width'];
320
+
321
+ $height = empty( $quads_options[$id]['g_data_ad_height'] ) ? $default_ad_sizes[$id][$adtype.'_height'] : $quads_options[$id]['g_data_ad_height'];
322
+
323
+ $normal_style = 'display:inline-block;width:' . $width . 'px;height:' . $height . 'px;' . $backgroundcolor;
324
+
325
+ $style = isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive' ? $responsive_style : $normal_style;
326
+ }
327
+
328
+ $ad_format = (isset( $quads_options[$id]['adsense_type'] ) && $quads_options[$id]['adsense_type'] === 'responsive') && (isset( $quads_options[$id][$adtype.'_size'] ) && $quads_options[$id][$adtype.'_size'] === 'Auto') ? 'data-ad-format="auto"' : '';
329
+
330
+ $html = '<ins class="adsbygoogle" style="' . $style . '"';
331
+ $html .= ' data-ad-client="' . $quads_options[$id]['g_data_ad_client'] . '"';
332
+ $html .= ' data-ad-slot="' . $quads_options[$id]['g_data_ad_slot'] . '" ' . $ad_format . '></ins>';
333
+
334
+ if( !isset( $quads_options[$id][$adtype] ) and ! empty( $default_ad_sizes[$id][$adtype.'_width'] ) and ! empty( $default_ad_sizes[$id][$adtype.'_height'] ) ) {
335
+ $js = 'if ( quads_screen_width < 768 ) {
336
+ /* phone */
337
+ document.write(\'' . $html . '\');
338
+ (adsbygoogle = window.adsbygoogle || []).push({});
339
+ }';
340
+ return $js;
341
+ }
342
+ }
343
+
344
+
345
+ /**
346
+ * Check if ad code is adsense or other ad code
347
+ *
348
+ * @param1 id int id of the ad
349
+ * @param string $string ad code
350
+ * @return boolean
351
+ */
352
+ function quads_is_adsense( $id, $string ) {
353
+ global $quads_options;
354
+
355
+ if( isset($quads_options[$id]['ad_type']) && $quads_options[$id]['ad_type'] === 'adsense') {
356
+ return true;
357
+ }
358
+ return false;
359
+ }
360
+
361
+
362
+ /**
363
+ * Render advert on amp pages
364
+ *
365
+ * @global array $quads_options
366
+ * @param int $id
367
+ * @return string
368
+ */
369
+ function quads_render_amp($id){
370
+ global $quads_options;
371
+
372
+ // if amp is not activated return empty
373
+ if (!isset($quads_options[$id]['amp'])){
374
+ return '';
375
+ }
376
+
377
+ if (!empty($quads_options[$id]['amp_code'])){
378
+ $html = $quads_options[$id]['amp_code'];
379
+ } else {
380
+ // Return default adsense code
381
+ $html = '<amp-ad layout="responsive" width=300 height=250 type="adsense" data-ad-client="'. $quads_options[$id]['g_data_ad_client'] . '" data-ad-slot="'.$quads_options[$id]['g_data_ad_slot'].'"></amp-ad>';
382
+ }
383
+
384
+ return $html;
385
+ }
386
+
387
+ /**
388
+ * Check if page is AMP one
389
+ *
390
+ * @return boolean
391
+ */
392
+ function quads_is_amp_endpoint(){
393
+ // Automattic AMP plugin
394
+ if ( function_exists( 'is_amp_endpoint' )){
395
+ if ( is_amp_endpoint()){
396
+ return true;
397
+ }
398
+ }
399
+ return false;
400
+ }
includes/scripts.php ADDED
@@ -0,0 +1,251 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Scripts
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 0.9.0
10
+ */
11
+ // Exit if accessed directly
12
+ if( !defined( 'ABSPATH' ) )
13
+ exit;
14
+
15
+ add_action( 'wp_enqueue_scripts', 'quads_register_styles', 10 );
16
+ add_action( 'wp_print_styles', 'quads_inline_styles', 9999 );
17
+ add_action( 'admin_enqueue_scripts', 'quads_load_admin_scripts', 100 );
18
+ add_action( 'admin_enqueue_scripts', 'quads_load_plugins_admin_scripts', 100 );
19
+
20
+ /**
21
+ * Load Admin Scripts
22
+ *
23
+ * Enqueues the required admin scripts.
24
+ *
25
+ * @since 1.0
26
+ * @global $post
27
+ * @param string $hook Page hook
28
+ * @return void
29
+ */
30
+ function quads_load_admin_scripts( $hook ) {
31
+ if( !apply_filters( 'quads_load_admin_scripts', quads_is_admin_page(), $hook ) ) {
32
+ return;
33
+ }
34
+ global $wp_version;
35
+
36
+ $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
37
+ $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
38
+
39
+ // Use minified libraries if SCRIPT_DEBUG is turned off
40
+ $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
41
+
42
+ if ( quads_is_plugins_page() ){
43
+ wp_enqueue_script( 'quads-global-admin-scripts', $js_dir . 'quads-global-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
44
+ }
45
+
46
+ // These have to be global
47
+ wp_enqueue_script( 'quads-admin-scripts', $js_dir . 'quads-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
48
+ wp_enqueue_script( 'jquery-chosen', $js_dir . 'chosen.jquery' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
49
+ wp_enqueue_script( 'jquery-form' );
50
+
51
+ wp_enqueue_style( 'quads-admin', $css_dir . 'quads-admin' . $suffix . '.css', QUADS_VERSION );
52
+ wp_enqueue_style( 'jquery-chosen', $css_dir . 'chosen' . $suffix . '.css', QUADS_VERSION );
53
+
54
+ wp_localize_script( 'quads-admin-scripts', 'quads', array(
55
+ 'nonce' => wp_create_nonce( 'quads_ajax_nonce' ),
56
+ 'error' => __( "error", 'quick-adsense-reloaded' ),
57
+ 'path' => get_option( 'siteurl' ),
58
+ ) );
59
+ }
60
+
61
+ /**
62
+ * Load Admin Scripts available on plugins page
63
+ *
64
+ * Enqueues the required admin scripts.
65
+ *
66
+ * @since 1.0
67
+ * @global $post
68
+ * @param string $hook Page hook
69
+ * @return void
70
+ */
71
+ function quads_load_plugins_admin_scripts( $hook ) {
72
+ if( !apply_filters( 'quads_load_plugins_admin_scripts', quads_is_plugins_page(), $hook ) ) {
73
+ return;
74
+ }
75
+
76
+ $js_dir = QUADS_PLUGIN_URL . 'assets/js/';
77
+ $css_dir = QUADS_PLUGIN_URL . 'assets/css/';
78
+
79
+ // Use minified libraries if SCRIPT_DEBUG is turned off
80
+ $suffix = ( quadsIsDebugMode() ) ? '' : '.min';
81
+
82
+ wp_enqueue_script( 'quads-plugins-admin-scripts', $js_dir . 'quads-plugins-admin' . $suffix . '.js', array('jquery'), QUADS_VERSION, false );
83
+ wp_enqueue_style( 'quads-plugins-admin', $css_dir . 'quads-plugins-admin' . $suffix . '.css', QUADS_VERSION );
84
+
85
+
86
+ }
87
+
88
+ /**
89
+ * Register CSS Styles
90
+ *
91
+ * Checks the styles option and hooks the required filter.
92
+ *
93
+ * @since 1.0
94
+ * @global $mashsb_options
95
+ * @return void
96
+ */
97
+ function quads_register_styles( $hook ) {
98
+ global $quads_options;
99
+
100
+ // Register empty quads.css to be able to register quads_inline_styles()
101
+ $url = QUADS_PLUGIN_URL . 'assets/css/quads.css';
102
+
103
+ wp_enqueue_style( 'quads-styles', $url, array(), QUADS_VERSION );
104
+ }
105
+
106
+ /**
107
+ * Add dynamic CSS to write media queries for removing unwanted ads without the need to use any cache busting method
108
+ * that could affect performance and lead to lot of support tickets
109
+ *
110
+ * @since 1.0
111
+ * @global1 array options
112
+ * @global2 $quads_css dynamic build css
113
+ *
114
+ * @return string
115
+ */
116
+ function quads_inline_styles() {
117
+ global $quads_options;
118
+
119
+ $css = '';
120
+
121
+ foreach ($quads_options as $key => $value){
122
+ $css .= quads_render_media_query($key, $value);
123
+ }
124
+
125
+ wp_add_inline_style( 'quads-styles', $css );
126
+ }
127
+
128
+ /**
129
+ * Render Media Queries
130
+ *
131
+ * @param string $key
132
+ * @param string $value
133
+ * @return string
134
+ */
135
+ function quads_render_media_query($key, $value){
136
+
137
+ $html = '';
138
+
139
+ if (isset($value['desktop']) ){
140
+ $html .= '@media only screen and (min-width:1140px){.quads-'.$key.' {display:none;}}'. "\n";
141
+ }
142
+ if (isset($value['tablet_landscape']) ){
143
+ $html .= '@media only screen and (min-width:1024px) and (max:width:1140px) {.quads-'.$key.' {display:none;}}' . "\n";
144
+ }
145
+ if (isset($value['tablet_portrait']) ){
146
+ $html .= '@media only screen and (min-width:768px) and (max-width:1024px){.quads-'.$key.' {display:none;}}' . "\n";
147
+ }
148
+ if (isset($value['phone']) ){
149
+ $html .= '@media only screen and (max-width:768px){.quads-'.$key.' {display:none;}}' . "\n";
150
+ }
151
+
152
+ return $html;
153
+ }
154
+
155
+ /*
156
+ * Check if debug mode is enabled
157
+ *
158
+ * @since 0.9.0
159
+ * @return bool true if Mashshare debug mode is on
160
+ */
161
+ function quadsIsDebugMode(){
162
+ global $quads_options;
163
+
164
+ $debug_mode = isset($quads_options['debug_mode']) ? true : false;
165
+ return $debug_mode;
166
+ }
167
+
168
+ /**
169
+ * Create ad buttons for editor
170
+ *
171
+ * @author Tedd Garland, René Hermenau
172
+ * @since 0.9.0
173
+ */
174
+
175
+
176
+
177
+ $wpvcomp = (bool)(version_compare(get_bloginfo('version'), '3.1', '>='));
178
+ function quads_ads_head_script() {
179
+ global $quads_options, $wpvcomp;
180
+
181
+ if ( isset($quads_options['quicktags']['QckTags'] ) ) { ?>
182
+ <script type="text/javascript">
183
+ wpvcomp = <?php echo(($wpvcomp==1)?"true":"false"); ?>;
184
+ edaddID = new Array();
185
+ edaddNm = new Array();
186
+ if(typeof(edButtons)!='undefined') {
187
+ edadd = edButtons.length;
188
+ var dynads={"all":[
189
+ <?php for ($i=1;$i<=count( quads_get_ads() )-1;$i++) { if( isset($quads_options['ad'.$i]['code']) && $quads_options['ad'.$i]['code'] !='' ){echo('"1",');}else{echo('"0",');}; } ?>
190
+ "0"]};
191
+ for(i=1;i<=<?php echo count( quads_get_ads() ) -1; ?>;i++) {
192
+ if(dynads.all[i-1]=="1") {
193
+ edButtons[edButtons.length]=new edButton("ads"+i.toString(),"Ads"+i.toString(),"\n<!--Ads"+i.toString()+"-->\n","","",-1);
194
+ edaddID[edaddID.length] = "ads"+i.toString();
195
+ edaddNm[edaddNm.length] = "Ads"+i.toString();
196
+ }
197
+ }
198
+ <?php if( !isset($quads_options['quicktags']['QckRnds'] ) ){ ?>
199
+ edButtons[edButtons.length]=new edButton("random_ads","RndAds","\n<!--RndAds-->\n","","",-1);
200
+ edaddID[edaddID.length] = "random_ads";
201
+ edaddNm[edaddNm.length] = "RndAds";
202
+ <?php } ?>
203
+ edButtons[edButtons.length]=new edButton("no_ads","NoAds","\n<!--NoAds-->\n","","",-1);
204
+ edaddID[edaddID.length] = "no_ads";
205
+ edaddNm[edaddNm.length] = "NoAds";
206
+ <?php //if( !isset( $quads_options['quicktags']['QckOffs'] ) ){ ?>
207
+ //edButtons[edButtons.length]=new edButton("no_ads","NoAds","\n<!--NoAds-->\n","","",-1);
208
+ //edaddID[edaddID.length] = "no_ads";
209
+ //edaddNm[edaddNm.length] = "NoAds";
210
+ //edButtons[edButtons.length]=new edButton("off_def","OffDef","\n<!--OffDef-->\n","","",-1);
211
+ //edaddID[edaddID.length] = "off_def";
212
+ //edaddNm[edaddNm.length] = "OffDef";
213
+ //edButtons[edButtons.length]=new edButton("off_wid","OffWidget","\n<!--OffWidget-->\n","","",-1);
214
+ //edaddID[edaddID.length] = "off_wid";
215
+ //edaddNm[edaddNm.length] = "OffWidget";
216
+ <?php //} ?>
217
+ <?php //if( !isset( $quads_options['quicktags']['QckOfPs'] ) ){ ?>
218
+ //edButtons[edButtons.length]=new edButton("off_bgn","OffBegin","\n<!--OffBegin-->\n","","",-1);
219
+ //edaddID[edaddID.length] = "off_bgn";
220
+ //edaddNm[edaddNm.length] = "OffBegin";
221
+ //edButtons[edButtons.length]=new edButton("off_mid","OffMiddle","\n<!--OffMiddle-->\n","","",-1);
222
+ //edaddID[edaddID.length] = "off_mid";
223
+ //edaddNm[edaddNm.length] = "OffMiddle";
224
+ //edButtons[edButtons.length]=new edButton("off_end","OffEnd","\n<!--OffEnd-->\n","","",-1);
225
+ //edaddID[edaddID.length] = "off_end";
226
+ //edaddNm[edaddNm.length] = "OffEnd";
227
+ //edButtons[edButtons.length]=new edButton("off_more","OffAfMore","\n<!--OffAfMore-->\n","","",-1);
228
+ //edaddID[edaddID.length] = "off_more";
229
+ //edaddNm[edaddNm.length] = "OffAfMore";
230
+ //edButtons[edButtons.length]=new edButton("off_last","OffBfLastPara","\n<!--OffBfLastPara-->\n","","",-1);
231
+ //edaddID[edaddID.length] = "off_last";
232
+ //edaddNm[edaddNm.length] = "OffBfLastPara";
233
+ <?php //} ?>
234
+ };
235
+ (function(){
236
+ if(typeof(edButtons)!='undefined' && typeof(jQuery)!='undefined' && wpvcomp){
237
+ jQuery(document).ready(function(){
238
+ for(i=0;i<edaddID.length;i++) {
239
+ jQuery("#ed_toolbar").append('<input type="button" value="' + edaddNm[i] +'" id="' + edaddID[i] +'" class="ed_button" onclick="edInsertTag(edCanvas, ' + (edadd+i) + ');" title="' + edaddNm[i] +'" />');
240
+ }
241
+ });
242
+ }
243
+ }());
244
+ </script>
245
+ <?php }
246
+ }
247
+ if ($wpvcomp) {
248
+ add_action('admin_print_footer_scripts', 'quads_ads_head_script');
249
+ }else{
250
+ add_action('admin_head', 'quads_ads_head_javascript_script');
251
+ }
includes/shortcodes.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * shortcode functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/shortcodes
8
+ * @copyright Copyright (c) 2015, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 0.9.4
11
+ */
12
+
13
+
14
+ // add short codes
15
+ //@deprecated since 0.9.5
16
+ add_shortcode( 'quads_ad', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
17
+ // new shortcode since 0.9.5
18
+ add_shortcode( 'quads', 'quads_shortcode_display_ad', 1); // Important use a very early priority to be able to count total ads accurate
19
+
20
+
21
+ /**
22
+ * shortcode to include ads in frontend
23
+ *
24
+ * @since 0.9.4
25
+ * @param array $atts
26
+ */
27
+ function quads_shortcode_display_ad($atts) {
28
+ if ( !quads_ad_is_allowed() )
29
+ return;
30
+
31
+
32
+ //return quads_check_meta_setting('NoAds');
33
+ if ( quads_check_meta_setting('NoAds') === '1')
34
+ return;
35
+
36
+ $id = isset($atts['id']) ? (int) $atts['id'] : 0;
37
+ return do_shortcode(quads_get_ad($id));
38
+ }
39
+
40
+
41
+
42
+ /**
43
+ * return ad content
44
+ *
45
+ * @since 0.9.4
46
+ * @param int $id id of the ad
47
+ * @return string
48
+ */
49
+ function quads_get_ad($id = 0) {
50
+ global $quads_options;
51
+
52
+ if ( quads_ad_reach_max_count() ){
53
+ return;
54
+ }
55
+
56
+ if ( isset($quads_options['ad' . $id]['code']) ){
57
+ // Count how often the shortcode is used - Important
58
+ quads_set_ad_count_shortcode();
59
+ $code = "\n".'<!-- WP QUADS Shortcode Ad v. ' . QUADS_VERSION .' -->'."\n";
60
+ //return $code . $quads_options['ad' . $id]['code'];
61
+ return quads_render_ad('ad' . $id, $quads_options['ad' . $id]['code']);
62
+ }
63
+ }
64
+
65
+
66
+
67
+ /**
68
+ * Return value of quads meta box settings
69
+ *
70
+ * @param type $id id of meta settings
71
+ * @return mixed string | bool value if setting is active. False if there is no setting
72
+ */
73
+ function quads_check_meta_setting($key){
74
+ global $post;
75
+
76
+ if ( !isset($post->ID ) )
77
+ return false;
78
+
79
+ $meta_key = '_quads_config_visibility';
80
+
81
+ $value_arr = get_post_meta ( $post->ID, $meta_key, true );
82
+ $value_key = isset($value_arr[$key]) ? $value_arr[$key] : null;
83
+
84
+ if (!empty($value_key))
85
+ return (string)$value_key;
86
+
87
+ return false;
88
+ }
89
+
90
+ /*
91
+ * Return string through shortcode function and strip out specific shortcode from it to
92
+ * prevents infinte loops if shortcode contains same shortcode
93
+ *
94
+ * @since 1.3.6
95
+ * @param1 string shortcode e.g. quads
96
+ * @param1 string content to return via shortcode
97
+ * @return string / shortcodes parsed
98
+ */
99
+
100
+ function quadsCleanShortcode( $code, $content ) {
101
+ global $shortcode_tags;
102
+ $stack = $shortcode_tags;
103
+ $shortcode_tags = array($code => 1);
104
+ $content = strip_shortcodes( $content );
105
+ $shortcode_tags = $stack;
106
+
107
+ return do_shortcode( $content );
108
+ }
109
+
includes/template-functions.php ADDED
@@ -0,0 +1,519 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Template Functions
4
+ *
5
+ * @package QUADS
6
+ * @subpackage Functions/Templates
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 0.9.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'ABSPATH' ) ) exit;
14
+
15
+ // we need to hook into the_content on lower than default priority (that's why we use separate hook)
16
+ add_filter('the_content', 'quads_post_settings_to_quicktags', 5);
17
+ add_filter('the_content', 'quads_process_content', quads_get_load_priority());
18
+
19
+ /**
20
+ * Get load priority
21
+ *
22
+ * @global arr $quads_options
23
+ * @return int
24
+ */
25
+ function quads_get_load_priority(){
26
+ global $quads_options;
27
+
28
+ if (!empty($quads_options['priority'])){
29
+ return intval($quads_options['priority']);
30
+ }
31
+ return 20;
32
+ }
33
+
34
+ /**
35
+ * Adds quicktags, defined via post meta options, to content.
36
+ *
37
+ * @param $content Post content
38
+ *
39
+ * @return string
40
+ */
41
+ function quads_post_settings_to_quicktags ( $content ) {
42
+
43
+ // Return original content if QUADS is not allowed
44
+ if ( !quads_ad_is_allowed($content) )
45
+ return $content;
46
+
47
+ $quicktags_str = quads_get_visibility_quicktags_str();
48
+
49
+ return $content . $quicktags_str;
50
+ }
51
+ /**
52
+ * Returns quicktags based on post meta options.
53
+ * These quicktags define which ads should be hidden on current page.
54
+ *
55
+ * @param null $post_id Post id
56
+ *
57
+ * @return string
58
+ */
59
+ function quads_get_visibility_quicktags_str ( $post_id = null ) {
60
+
61
+ if ( ! $post_id ) {
62
+ $post_id = get_the_ID();
63
+ }
64
+
65
+ $str = '';
66
+ if (false === $post_id){
67
+ return $str;
68
+ }
69
+
70
+ $config = get_post_meta( $post_id, '_quads_config_visibility', true );
71
+
72
+
73
+ if ( !empty($config))
74
+ foreach ( $config as $qtag_id => $qtag_label ) {
75
+ $str .= '<!--' . $qtag_id . '-->';
76
+ }
77
+
78
+ return $str;
79
+ }
80
+
81
+ /**
82
+ * Main processing for the_content filter
83
+ *
84
+ * @global arr $quads_options all plugin settings
85
+ * @global int $visibleContentAds number of active content ads (reseted internally so we have to use a similar global below for external purposes: $visibleContentAdsGlobal)
86
+ * @global arr $AdsId Whitespace trimmed array of ad codes
87
+ * @global int $numberWidgets number of ad widgets
88
+ * @global int $numberAds number of maximum available ads
89
+ * @global string $AdsWidName name of widget
90
+ * @global int $visibleContentAdsGlobal number of active content ads
91
+ * @global int $visibleShortcodeAds number of active shortcode ads
92
+ * @param string $content
93
+ *
94
+ * @return string
95
+ *
96
+ * @since 0.9.0
97
+ */
98
+
99
+ function quads_process_content($content){
100
+ global $quads_options, $visibleContentAds, $AdsId, $numberWidgets, $numberAds, $AdsWidName, $visibleContentAdsGlobal, $visibleShortcodeAds;
101
+
102
+ // Return original content if QUADS is not allowed
103
+ if ( !quads_ad_is_allowed($content) ) {
104
+ $content = quads_clean_tags($content);
105
+ return $content;
106
+ }
107
+ // Maximum allowed ads
108
+ $maxAds = isset($quads_options['maxads']) ? $quads_options['maxads'] : 10;
109
+
110
+ if (strpos($content,'<!--OffWidget-->')===false) {
111
+ for($i=1;$i<=$numberWidgets;$i++) {
112
+ $wadsid = sanitize_title(str_replace(array('(',')'),'',sprintf($AdsWidName,$i)));
113
+ $maxAds -= (is_active_widget('', '', $wadsid)) ? 1 : 0 ;
114
+ }
115
+ }
116
+
117
+ // Return here if max visible ads are exceeded
118
+ if( $visibleContentAds+$visibleShortcodeAds >= $maxAds ) { // ShownAds === 0 or larger/equal than $maxAds
119
+ $content = quads_clean_tags($content);
120
+ return $content;
121
+ };
122
+
123
+ // Create array of valid id's
124
+ if( count( $AdsId ) === 0 ) { //
125
+ for ( $i = 1; $i <= $numberAds; $i++ ) {
126
+ $tmp = isset($quads_options['ad' . $i]['code']) ? trim( $quads_options['ad' . $i]['code'] ) : '';
127
+ // id is valid if there is either the plain text field populated or the adsense ad slot and the ad client id
128
+ if( !empty( $tmp ) || (!empty($quads_options['ad' . $i]['g_data_ad_slot']) && !empty($quads_options['ad' . $i]['g_data_ad_client'] ) ) ) {
129
+ $AdsId[] = $i;
130
+ }
131
+ }
132
+ // echo '<pre>';
133
+ // wp_die(var_dump($AdsId));
134
+ }
135
+
136
+ // Ad code array is empty so break here
137
+ if( count($AdsId) === 0 ) {
138
+ $content = quads_clean_tags($content);
139
+ return $content;
140
+ };
141
+
142
+ /* ... Tidy up content ... */
143
+ // Replace all <p></p> tags with placeholder ##QA-TP1##
144
+ // Replace all
145
+ $content = str_replace("<p></p>", "##QA-TP1##", $content);
146
+ // Replace all <p>&nbsp;</p> tags with placeholder ##QA-TP2##
147
+ $content = str_replace("<p>&nbsp;</p>", "##QA-TP2##", $content);
148
+ $offdef = (strpos($content,'<!--OffDef-->')!==false);
149
+
150
+ if( !$offdef ) {
151
+
152
+ $AdsIdCus = array();
153
+ $cusads = 'CusAds';
154
+ $cusrnd = 'CusRnd';
155
+
156
+ $begn1 = isset($quads_options['pos1']['BegnAds']) ? true : false;
157
+ $begn2 = isset($quads_options['pos1']['BegnRnd']) ? $quads_options['pos1']['BegnRnd'] : 0;
158
+
159
+ $midd1 = isset($quads_options['pos2']['MiddAds']) ? true : false;
160
+ $midd2 = isset($quads_options['pos2']['MiddRnd']) ? $quads_options['pos2']['MiddRnd'] : 0;
161
+
162
+ $endi1 = isset($quads_options['pos3']['EndiAds']) ? true : false;
163
+ $endi2 = isset($quads_options['pos3']['EndiRnd']) ? $quads_options['pos3']['EndiRnd'] : 0;
164
+
165
+ $more1 = isset($quads_options['pos4']['MoreAds']) ? true : false;
166
+ $more2 = isset($quads_options['pos4']['MoreRnd']) ? $quads_options['pos4']['MoreRnd'] : 0;
167
+
168
+ $lapa1 = isset($quads_options['pos5']['LapaAds']) ? true : false;
169
+ $lapa2 = isset($quads_options['pos5']['LapaRnd'])? $quads_options['pos5']['LapaRnd'] : 0 ;
170
+
171
+
172
+ $rc=3;
173
+ $default = 5;
174
+ for($i=1;$i<=$rc;$i++) {
175
+
176
+ $key = $default +$i; // 6;7;8
177
+
178
+ $para1[$i] = isset($quads_options['pos' . $key]['Par'.$i .'Ads']) ? $quads_options['pos' . $key]['Par'.$i .'Ads'] : 0;
179
+ $para2[$i] = isset($quads_options['pos' . $key]['Par'.$i .'Rnd']) ? $quads_options['pos' . $key]['Par'.$i .'Rnd'] : 0;
180
+ $para3[$i] = isset($quads_options['pos' . $key]['Par'.$i .'Nup']) ? $quads_options['pos' . $key]['Par'.$i .'Nup'] : 0;
181
+ $para4[$i] = isset($quads_options['pos' . $key]['Par'.$i .'Con']) ? $quads_options['pos' . $key]['Par'.$i .'Con'] : 0;
182
+
183
+ }
184
+
185
+ $imageActive = isset($quads_options['pos9']['Img1Ads']) ? $quads_options['pos9']['Img1Ads'] : false;
186
+ $imageAdNo = isset($quads_options['pos9']['Img1Rnd']) ? $quads_options['pos9']['Img1Rnd'] : false;
187
+ $imageNo = isset($quads_options['pos9']['Img1Nup']) ? $quads_options['pos9']['Img1Nup'] : false;
188
+ $imageCaption = isset($quads_options['pos9']['Img1Con']) ? $quads_options['pos9']['Img1Con'] : false;
189
+
190
+
191
+ if ( $begn2 == 0 ) { $b1 = $cusrnd; } else { $b1 = $cusads.$begn2; array_push($AdsIdCus, $begn2); };
192
+ if ( $more2 == 0 ) { $r1 = $cusrnd; } else { $r1 = $cusads.$more2; array_push($AdsIdCus, $more2); };
193
+ if ( $midd2 == 0 ) { $m1 = $cusrnd; } else { $m1 = $cusads.$midd2; array_push($AdsIdCus, $midd2); };
194
+ if ( $lapa2 == 0 ) { $g1 = $cusrnd; } else { $g1 = $cusads.$lapa2; array_push($AdsIdCus, $lapa2); };
195
+ if ( $endi2 == 0 ) { $b2 = $cusrnd; } else { $b2 = $cusads.$endi2; array_push($AdsIdCus, $endi2); };
196
+
197
+ for($i=1;$i<=$rc;$i++) {
198
+ if ( $para2[$i] == 0 ) { $b3[$i] = $cusrnd;
199
+
200
+ } else {
201
+ $b3[$i] = $cusads.$para2[$i];
202
+ array_push($AdsIdCus, $para2[$i]);
203
+
204
+ };
205
+ }
206
+
207
+ // Check if image ad is random one
208
+ if ( $imageAdNo == 0 ) {
209
+ $b4 = $cusrnd;
210
+ } else {
211
+ $b4 = $cusads.$imageAdNo;
212
+ array_push($AdsIdCus, $imageAdNo);
213
+ };
214
+
215
+ // Check if image ad is middle one
216
+ if( $midd1 && strpos($content,'<!--OffMiddle-->')===false) {
217
+ if( substr_count(strtolower($content), '</p>')>=2 ) {
218
+ $sch = "</p>";
219
+ $content = str_replace("</P>", $sch, $content);
220
+ $arr = explode($sch, $content);
221
+ $nn = 0; $mm = strlen($content)/2;
222
+ for($i=0;$i<count($arr);$i++) {
223
+ $nn += strlen($arr[$i]) + 4;
224
+ if($nn>$mm) {
225
+ if( ($mm - ($nn - strlen($arr[$i]))) > ($nn - $mm) && $i+1<count($arr) ) {
226
+ $arr[$i+1] = '<!--'.$m1.'-->'.$arr[$i+1];
227
+ } else {
228
+ $arr[$i] = '<!--'.$m1.'-->'.$arr[$i];
229
+ }
230
+ break;
231
+ }
232
+ }
233
+ $content = implode($sch, $arr);
234
+ }
235
+ }
236
+
237
+ // Check if image ad is "More Tag" one
238
+ if( $more1 && strpos($content,'<!--OffAfMore-->')===false) {
239
+ $mmr = '<!--'.$r1.'-->';
240
+ $postid = get_the_ID();
241
+ $content = str_replace('<span id="more-'.$postid.'"></span>', $mmr, $content);
242
+ }
243
+
244
+ if( $begn1 && strpos($content,'<!--OffBegin-->')===false) {
245
+ $content = '<!--'.$b1.'-->'.$content;
246
+ }
247
+ if( $endi1 && strpos($content,'<!--OffEnd-->')===false) {
248
+ $content = $content.'<!--'.$b2.'-->';
249
+ }
250
+ if( $lapa1 && strpos($content,'<!--OffBfLastPara-->')===false){
251
+ $sch = "<p>";
252
+ $content = str_replace("<P>", $sch, $content);
253
+ $arr = explode($sch, $content);
254
+ if ( count($arr) > 2 ) {
255
+ $content = implode($sch, array_slice($arr, 0, count($arr)-1)) .'<!--'.$g1.'-->'. $sch. $arr[count($arr)-1];
256
+ }
257
+ }
258
+ for($i=$rc;$i>=1;$i--) {
259
+ if ( $para1[$i] ){
260
+ $sch = "</p>";
261
+ $content = str_replace("</P>", $sch, $content);
262
+ $arr = explode($sch, $content);
263
+ if ( (int)$para3[$i] < count($arr) ) {
264
+ $content = implode($sch, array_slice($arr, 0, $para3[$i])).$sch .'<!--'.$b3[$i].'-->'. implode($sch, array_slice($arr, $para3[$i]));
265
+ } elseif ($para4[$i]) {
266
+ $content = implode($sch, $arr).'<!--'.$b3[$i].'-->';
267
+ }
268
+ }
269
+ }
270
+
271
+ if ( $imageActive ){
272
+
273
+ // Sanitation
274
+ $imgtag = "<img";
275
+ $delimiter = ">";
276
+ $caption = "[/caption]";
277
+ $atag = "</a>";
278
+ $content = str_replace("<IMG", $imgtag, $content);
279
+ $content = str_replace("</A>", $atag, $content);
280
+
281
+ // Start
282
+ $arr = explode($imgtag, $content);
283
+ if ( (int)$imageNo < count($arr) ) {
284
+ $arrImages = explode($delimiter, $arr[$imageNo]);
285
+ if ( count($arrImages) > 1 ) {
286
+ $tss = explode($caption, $arr[$imageNo]);
287
+ $ccp = ( count($tss) > 1 ) ? strpos(strtolower($tss[0]),'[caption ')===false : false ;
288
+ $arrAtag = explode($atag, $arr[$imageNo]);
289
+ $cdu = ( count($arrAtag) > 1 ) ? strpos(strtolower($arrAtag[0]),'<a href')===false : false ;
290
+ if ( $imageCaption && $ccp ) {
291
+ $arr[$imageNo] = implode($caption, array_slice($tss, 0, 1)).$caption. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($caption, array_slice($tss, 1));
292
+ }else if ( $cdu ) {
293
+ $arr[$imageNo] = implode($atag, array_slice($arrAtag, 0, 1)).$atag. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($atag, array_slice($arrAtag, 1));
294
+ }else{
295
+ $arr[$imageNo] = implode($delimiter, array_slice($arrImages, 0, 1)).$delimiter. "\r\n".'<!--'.$b4.'-->'."\r\n". implode($delimiter, array_slice($arrImages, 1));
296
+ }
297
+ }
298
+ $content = implode($imgtag, $arr);
299
+ }
300
+ }
301
+ }
302
+
303
+ /*
304
+ * Tidy up content
305
+ */
306
+ $content = '<!--EmptyClear-->'.$content."\n".'<div style="font-size:0px;height:0px;line-height:0px;margin:0;padding:0;clear:both"></div>';
307
+ $content = quads_clean_tags($content, true);
308
+
309
+
310
+ /*
311
+ * Replace Beginning/Middle/End Ads1-10
312
+ */
313
+
314
+ if( !$offdef ) {
315
+ for( $i=1; $i<=count($AdsIdCus); $i++ ) {
316
+
317
+ if( strpos($content,'<!--'.$cusads.$AdsIdCus[$i-1].'-->')!==false && in_array($AdsIdCus[$i-1], $AdsId)) {
318
+
319
+ $content = quads_replace_ads( $content, $cusads.$AdsIdCus[$i-1], $AdsIdCus[$i-1] );
320
+ $AdsId = quads_del_element($AdsId, array_search($AdsIdCus[$i-1], $AdsId)) ;
321
+ $visibleContentAds += 1;
322
+
323
+ quads_set_ad_count_content();
324
+ if ( quads_ad_reach_max_count() ){
325
+ $content = quads_clean_tags($content);
326
+ }
327
+ }
328
+ }
329
+ }
330
+
331
+ /**
332
+ * Replace Quicktags Ads1 to Ads10
333
+ **/
334
+
335
+ $tcn = count($AdsId); $tt = 0;
336
+ for( $i=1; $i<=$tcn; $i++ ) {
337
+ if( strpos($content, '<!--Ads'.$AdsId[$tt].'-->')!==false ) {
338
+ $content = quads_replace_ads( $content, 'Ads'.$AdsId[$tt], $AdsId[$tt] );
339
+ $AdsId = quads_del_element($AdsId, $tt) ;
340
+ $visibleContentAds += 1;
341
+ quads_set_ad_count_content();
342
+ if (quads_ad_reach_max_count()){
343
+ $content = quads_clean_tags($content);
344
+ return $content;
345
+ }
346
+
347
+ } else {
348
+ $tt += 1;
349
+ }
350
+ }
351
+
352
+
353
+
354
+ /* ... Replace Beginning/Middle/End random Ads ... */
355
+ if( !$offdef ) {
356
+ if( strpos($content, '<!--'.$cusrnd.'-->')!==false && is_singular() ) {
357
+ $tcx = count($AdsId);
358
+ $tcy = substr_count($content, '<!--'.$cusrnd.'-->');
359
+
360
+ for( $i=$tcx; $i<=$tcy-1; $i++ ) {
361
+ array_push($AdsId, -1);
362
+ }
363
+ shuffle($AdsId);
364
+ for( $i=1; $i<=$tcy; $i++ ) {
365
+ $content = quads_replace_ads( $content, $cusrnd, $AdsId[0] );
366
+ $AdsId = quads_del_element($AdsId, 0) ;
367
+ $visibleContentAds += 1;
368
+ quads_set_ad_count_content();
369
+ if (quads_ad_reach_max_count()){
370
+ $content = quads_clean_tags($content);
371
+ return $content;
372
+ }
373
+ }
374
+ }
375
+ }
376
+
377
+ /*
378
+ * Replace RndAds Random Ads
379
+ */
380
+ if( strpos($content, '<!--RndAds-->')!==false && is_singular() ) {
381
+ $AdsIdTmp = array();
382
+ shuffle($AdsId);
383
+ for( $i=1; $i<=$maxAds-$visibleContentAds; $i++ ) {
384
+ if( $i <= count($AdsId) ) {
385
+ array_push($AdsIdTmp, $AdsId[$i-1]);
386
+ }
387
+ }
388
+ $tcx = count($AdsIdTmp);
389
+ $tcy = substr_count($content, '<!--RndAds-->');
390
+ for( $i=$tcx; $i<=$tcy-1; $i++ ) {
391
+ array_push($AdsIdTmp, -1);
392
+ }
393
+ shuffle($AdsIdTmp);
394
+ for( $i=1; $i<=$tcy; $i++ ) {
395
+ $tmp = $AdsIdTmp[0];
396
+ $content = quads_replace_ads( $content, 'RndAds', $AdsIdTmp[0] );
397
+ $AdsIdTmp = quads_del_element($AdsIdTmp, 0) ;
398
+ if($tmp != -1){
399
+ $visibleContentAds += 1;
400
+ };
401
+ quads_set_ad_count_content();
402
+ if (quads_ad_reach_max_count()){
403
+ $content = quads_clean_tags($content);
404
+ return $content;
405
+ }
406
+ }
407
+ }
408
+
409
+ /* ... That's it. DONE :) ... */
410
+ $content = quads_clean_tags($content);
411
+ // Reset ad_count - Important!!!
412
+ $visibleContentAdsGlobal = 0;
413
+ return do_shortcode($content);
414
+ }
415
+ /**
416
+ * Revert content into original content without any ad code
417
+ *
418
+ * @global int $visibleContentAds
419
+ * @global array $AdsId
420
+ * @global array $quads_options
421
+ * @global int $ad_count
422
+ * @param string $content
423
+ * @param boolean $trimonly
424
+ *
425
+ * @return string content
426
+ */
427
+ function quads_clean_tags($content, $trimonly = false) {
428
+ global $visibleContentAds;
429
+ global $AdsId;
430
+ global $quads_options;
431
+ global $ad_count;
432
+
433
+ $tagnames = array('EmptyClear','RndAds','NoAds','OffDef','OffAds','OffWidget','OffBegin','OffMiddle','OffEnd','OffBfMore','OffAfLastPara','CusRnd');
434
+
435
+ for($i=1;$i<=10;$i++) {
436
+ array_push($tagnames, 'CusAds'.$i);
437
+ array_push($tagnames, 'Ads'.$i);
438
+ };
439
+
440
+
441
+ foreach ($tagnames as $tgn) {
442
+ if(strpos($content,'<!--'.$tgn.'-->')!==false || $tgn=='EmptyClear') {
443
+ if($trimonly) {
444
+ $content = str_replace('<p><!--'.$tgn.'--></p>', '<!--'.$tgn.'-->', $content);
445
+ }else{
446
+ $content = str_replace(array('<p><!--'.$tgn.'--></p>','<!--'.$tgn.'-->'), '', $content);
447
+ $content = str_replace("##QA-TP1##", "<p></p>", $content);
448
+ $content = str_replace("##QA-TP2##", "<p>&nbsp;</p>", $content);
449
+ }
450
+ }
451
+ }
452
+ if(!$trimonly && (is_single() || is_page()) ) {
453
+ $visibleContentAds = 0;
454
+ $AdsId = array();
455
+ }
456
+ return $content;
457
+ }
458
+
459
+ /**
460
+ * Replace ad code in content
461
+ *
462
+ * @global type $quads_options
463
+ * @param string $content
464
+ * @param string $nme Quicktag
465
+ * @param string $id id of the ad
466
+ * @return type
467
+ */
468
+ function quads_replace_ads($content, $nme, $id) {
469
+ global $quads_options;
470
+
471
+
472
+ if( strpos($content,'<!--'.$nme.'-->')===false ) {
473
+ return $content;
474
+ }
475
+ if ($id != -1) {
476
+ $arr = array(
477
+ 'float:left;margin:%1$dpx %1$dpx %1$dpx 0;',
478
+ 'float:none;margin:%1$dpx 0 %1$dpx 0;text-align:center;',
479
+ 'float:right;margin:%1$dpx 0 %1$dpx %1$dpx;',
480
+ 'float:none;margin:0px;');
481
+
482
+ $adsalign = $quads_options['ad' . $id]['align'];
483
+ $adsmargin = isset($quads_options['ad' . $id]['margin']) ? $quads_options['ad' . $id]['margin'] : '3'; // default
484
+ $margin = sprintf($arr[(int)$adsalign], $adsmargin);
485
+
486
+ // Do not create any inline style on AMP site
487
+ $style = !quads_is_amp_endpoint() ? apply_filters ('quads_filter_margins', $margin, 'ad'.$id ) : '';
488
+ $adscode = $quads_options['ad' . $id ]['code'];
489
+
490
+ $adscode =
491
+ "\n".'<!-- WP QUADS Content Ad Plugin v. ' . QUADS_VERSION .' -->'."\n".
492
+ '<div class="quads-location quads-ad' .$id. '" id="quads-ad' .$id. '" style="'.$style.'">'."\n".
493
+ quads_render_ad('ad'.$id, $adscode)."\n".
494
+ '</div>'. "\n";
495
+
496
+ } else {
497
+ $adscode ='';
498
+ }
499
+ $cont = explode('<!--'.$nme.'-->', $content, 2);
500
+
501
+ return $cont[0].$adscode.$cont[1];
502
+ }
503
+
504
+ /**
505
+ * Remove element from array
506
+ *
507
+ * @param array $array
508
+ * @param int $idx key to remove from array
509
+ * @return array
510
+ */
511
+ function quads_del_element($array, $idx) {
512
+ $copy = array();
513
+ for( $i=0; $i<count($array) ;$i++) {
514
+ if ( $idx != $i ) {
515
+ array_push($copy, $array[$i]);
516
+ }
517
+ }
518
+ return $copy;
519
+ }
includes/user_roles.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * User Roles
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/user_roles
8
+ * @copyright Copyright (c) 2016, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 1.2.8
11
+ */
12
+
13
+ /**
14
+ * Check if ad is hidden from current user role
15
+ *
16
+ * @global array $quads_options
17
+ * @return boolean true if the current user role is allowed to see ads
18
+ */
19
+ function quads_user_roles_permission(){
20
+ global $quads_options;
21
+
22
+ // No restriction. Show ads to all user_roles including public visitors without user role
23
+ if (!isset($quads_options['user_roles'])){
24
+ return true;
25
+ }
26
+ $roles = wp_get_current_user()->roles;
27
+ if ( isset ($quads_options['user_roles']) && count(array_intersect( $quads_options['user_roles'], $roles )) >= 1){
28
+ return false;
29
+ }
30
+
31
+ return true;
32
+ }
includes/widgets.php ADDED
@@ -0,0 +1,497 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Widget Functions
5
+ *
6
+ * @package QUADS
7
+ * @subpackage Functions/Widgets
8
+ * @copyright Copyright (c) 2015, René Hermenau
9
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
10
+ * @since 0.9.1
11
+ */
12
+ /**
13
+ * Register Widgets
14
+ *
15
+ * @return void
16
+ * @since 0.9.2
17
+ */
18
+ add_action( 'widgets_init', 'quads_register_widgets', 1 );
19
+
20
+ function quads_register_widgets() {
21
+
22
+
23
+ global $quads_options;
24
+ $amountWidgets = 10;
25
+ for ( $i = 1; $i <= $amountWidgets; $i++ ) {
26
+ if( !empty( $quads_options['ad' . $i . '_widget'] ) ) {
27
+ register_widget( 'quads_widgets_' . $i );
28
+ }
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Check if Ad widgets are visible on homepage
34
+ *
35
+ * @since 0.9.7
36
+ * return true when ad widgets are not visible on frontpage else false
37
+ * @deprecated since version 1.3.8
38
+ */
39
+ //function quads_hide_adwidget_on_homepage() {
40
+ // global $quads_options;
41
+ //
42
+ // $is_active = isset( $quads_options["visibility"]["AppSide"] ) ? $quads_options["visibility"]["AppSide"] : null;
43
+ //
44
+ // if( is_front_page() && $is_active )
45
+ // return true;
46
+ //
47
+ // return false;
48
+ //}
49
+
50
+ class quads_widgets_1 extends WP_Widget {
51
+
52
+ /**
53
+ * Register widget with WordPress.
54
+ */
55
+ function __construct() {
56
+ $this->adsID = '1';
57
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
58
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
59
+
60
+
61
+ parent::__construct(
62
+ $this->AdsWidID, // Base ID
63
+ $this->AdsWidName, // Name
64
+ array(
65
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
66
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
67
+ ) // Args
68
+ );
69
+ }
70
+
71
+ /**
72
+ * Create widget
73
+ *
74
+ * @global array $quads_options
75
+ * @param array $args
76
+ * @param array $instance
77
+ */
78
+ public function widget( $args, $instance ) {
79
+ global $quads_options, $ad_count_widget;
80
+ extract( $args );
81
+
82
+
83
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
84
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
85
+
86
+ quads_set_ad_count_widget();
87
+ //$codetxt = $quads_options['ad' . $this->adsID . '_widget'];
88
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
89
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
90
+ if( array_key_exists( 'before_widget', $args ) )
91
+ echo $args['before_widget'];
92
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
93
+ echo $code;
94
+ echo '</div>';
95
+ if( array_key_exists( 'after_widget', $args ) )
96
+ echo $args['after_widget'];
97
+ };
98
+ }
99
+
100
+ }
101
+
102
+ // class My_Widget1
103
+
104
+ class quads_widgets_2 extends WP_Widget {
105
+
106
+ /**
107
+ * Register widget with WordPress.
108
+ */
109
+ function __construct() {
110
+ $this->adsID = '2';
111
+
112
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
113
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
114
+ parent::__construct(
115
+ $this->AdsWidID, // Base ID
116
+ $this->AdsWidName, // Name
117
+ array(
118
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
119
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
120
+ ) // Args
121
+ );
122
+ }
123
+
124
+ public function widget( $args, $instance ) {
125
+ global $quads_options;
126
+ extract( $args );
127
+
128
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
129
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
130
+
131
+ quads_set_ad_count_widget();
132
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
133
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
134
+ //if (array_key_exists('before_widget', $args))
135
+ echo $args['before_widget'];
136
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
137
+ echo $code;
138
+ echo '</div>';
139
+ //if (array_key_exists('after_widget', $args))
140
+ echo $args['after_widget'];
141
+ };
142
+ }
143
+
144
+ }
145
+
146
+ // class My_Widget2
147
+ class quads_widgets_3 extends WP_Widget {
148
+
149
+ /**
150
+ * Register widget with WordPress.
151
+ */
152
+ function __construct() {
153
+
154
+ $this->adsID = '3';
155
+
156
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
157
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
158
+ parent::__construct(
159
+ $this->AdsWidID, // Base ID
160
+ $this->AdsWidName, // Name
161
+ array(
162
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
163
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
164
+ ) // Args
165
+ );
166
+ }
167
+
168
+ public function widget( $args, $instance ) {
169
+ global $quads_options;
170
+ extract( $args );
171
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
172
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
173
+
174
+ quads_set_ad_count_widget();
175
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
176
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
177
+ if( array_key_exists( 'before_widget', $args ) )
178
+ echo $args['before_widget'];
179
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
180
+ echo $code;
181
+ echo '</div>';
182
+ if( array_key_exists( 'after_widget', $args ) )
183
+ echo $args['after_widget'];
184
+ };
185
+ }
186
+
187
+ }
188
+
189
+ // class My_Widget3
190
+
191
+ class quads_widgets_4 extends WP_Widget {
192
+
193
+ /**
194
+ * Register widget with WordPress.
195
+ */
196
+ function __construct() {
197
+
198
+ $this->adsID = '4';
199
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
200
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
201
+ parent::__construct(
202
+ $this->AdsWidID, // Base ID
203
+ $this->AdsWidName, // Name
204
+ array(
205
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
206
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
207
+ ) // Args
208
+ );
209
+ }
210
+
211
+ public function widget( $args, $instance ) {
212
+ global $quads_options;
213
+
214
+ extract( $args );
215
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
216
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
217
+
218
+ quads_set_ad_count_widget();
219
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
220
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
221
+ if( array_key_exists( 'before_widget', $args ) )
222
+ echo $args['before_widget'];
223
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
224
+ echo $code;
225
+ echo '</div>';
226
+ if( array_key_exists( 'after_widget', $args ) )
227
+ echo $args['after_widget'];
228
+ };
229
+ }
230
+
231
+ }
232
+
233
+ // class My_Widget4
234
+
235
+ class quads_widgets_5 extends WP_Widget {
236
+
237
+ /**
238
+ * Register widget with WordPress.
239
+ */
240
+ function __construct() {
241
+
242
+ $this->adsID = '5';
243
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
244
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
245
+ parent::__construct(
246
+ $this->AdsWidID, // Base ID
247
+ $this->AdsWidName, // Name
248
+ array(
249
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
250
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
251
+ ) // Args
252
+ );
253
+ }
254
+
255
+ public function widget( $args, $instance ) {
256
+ global $quads_options;
257
+
258
+ extract( $args );
259
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
260
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
261
+
262
+ quads_set_ad_count_widget();
263
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
264
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
265
+ if( array_key_exists( 'before_widget', $args ) )
266
+ echo $args['before_widget'];
267
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
268
+ echo $code;
269
+ echo '</div>';
270
+ if( array_key_exists( 'after_widget', $args ) )
271
+ echo $args['after_widget'];
272
+ };
273
+ }
274
+
275
+ }
276
+
277
+ // class My_Widget5
278
+
279
+ class quads_widgets_6 extends WP_Widget {
280
+
281
+ /**
282
+ * Register widget with WordPress.
283
+ */
284
+ function __construct() {
285
+
286
+ $this->adsID = '6';
287
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
288
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
289
+ parent::__construct(
290
+ $this->AdsWidID, // Base ID
291
+ $this->AdsWidName, // Name
292
+ array(
293
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
294
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
295
+ ) // Args
296
+ );
297
+ }
298
+
299
+ public function widget( $args, $instance ) {
300
+ global $quads_options;
301
+
302
+ extract( $args );
303
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
304
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
305
+
306
+ quads_set_ad_count_widget();
307
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
308
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
309
+ if( array_key_exists( 'before_widget', $args ) )
310
+ echo $args['before_widget'];
311
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
312
+ echo $code;
313
+ echo '</div>';
314
+ if( array_key_exists( 'after_widget', $args ) )
315
+ echo $args['after_widget'];
316
+ };
317
+ }
318
+
319
+ }
320
+
321
+ // class My_Widget6
322
+
323
+ class quads_widgets_7 extends WP_Widget {
324
+
325
+ /**
326
+ * Register widget with WordPress.
327
+ */
328
+ function __construct() {
329
+
330
+ $this->adsID = '7';
331
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
332
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
333
+ parent::__construct(
334
+ $this->AdsWidID, // Base ID
335
+ $this->AdsWidName, // Name
336
+ array(
337
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
338
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
339
+ ) // Args
340
+ );
341
+ }
342
+
343
+ public function widget( $args, $instance ) {
344
+ global $quads_options;
345
+
346
+ extract( $args );
347
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
348
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
349
+
350
+ quads_set_ad_count_widget();
351
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
352
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
353
+ if( array_key_exists( 'before_widget', $args ) )
354
+ echo $args['before_widget'];
355
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
356
+ echo $code;
357
+ echo '</div>';
358
+ if( array_key_exists( 'after_widget', $args ) )
359
+ echo $args['after_widget'];
360
+ };
361
+ }
362
+
363
+ }
364
+
365
+ // class My_Widget7
366
+
367
+ class quads_widgets_8 extends WP_Widget {
368
+
369
+ /**
370
+ * Register widget with WordPress.
371
+ */
372
+ function __construct() {
373
+
374
+ $this->adsID = '8';
375
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
376
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
377
+ parent::__construct(
378
+ $this->AdsWidID, // Base ID
379
+ $this->AdsWidName, // Name
380
+ array(
381
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
382
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
383
+ ) // Args
384
+ );
385
+ }
386
+
387
+ public function widget( $args, $instance ) {
388
+ global $quads_options;
389
+
390
+ extract( $args );
391
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
392
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
393
+
394
+ quads_set_ad_count_widget();
395
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
396
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
397
+ if( array_key_exists( 'before_widget', $args ) )
398
+ echo $args['before_widget'];
399
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
400
+ echo $code;
401
+ echo '</div>';
402
+ if( array_key_exists( 'after_widget', $args ) )
403
+ echo $args['after_widget'];
404
+ };
405
+ }
406
+
407
+ }
408
+
409
+ // class My_Widget8
410
+
411
+ class quads_widgets_9 extends WP_Widget {
412
+
413
+ /**
414
+ * Register widget with WordPress.
415
+ */
416
+ function __construct() {
417
+
418
+ $this->adsID = '9';
419
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
420
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
421
+ parent::__construct(
422
+ $this->AdsWidID, // Base ID
423
+ $this->AdsWidName, // Name
424
+ array(
425
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
426
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
427
+ ) // Args
428
+ );
429
+ }
430
+
431
+ public function widget( $args, $instance ) {
432
+ global $quads_options;
433
+
434
+ extract( $args );
435
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
436
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
437
+
438
+ quads_set_ad_count_widget();
439
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
440
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
441
+ if( array_key_exists( 'before_widget', $args ) )
442
+ echo $args['before_widget'];
443
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
444
+ echo $code;
445
+ echo '</div>';
446
+ if( array_key_exists( 'after_widget', $args ) )
447
+ echo $args['after_widget'];
448
+ };
449
+ }
450
+
451
+ }
452
+
453
+ // class My_Widget9
454
+
455
+ class quads_widgets_10 extends WP_Widget {
456
+
457
+ /**
458
+ * Register widget with WordPress.
459
+ */
460
+ function __construct() {
461
+
462
+ $this->adsID = '10';
463
+ $this->AdsWidName = sprintf( 'AdsWidget%d (Quick Adsense Reloaded)', $this->adsID );
464
+ $this->AdsWidID = sanitize_title( str_replace( array('(', ')'), '', $this->AdsWidName ) );
465
+ parent::__construct(
466
+ $this->AdsWidID, // Base ID
467
+ $this->AdsWidName, // Name
468
+ array(
469
+ 'description' => __( 'Widget contains ad code', 'quick-adsense-reloaded' ),
470
+ 'classname' => 'quads-ad'.$this->adsID.'_widget'
471
+ ) // Args
472
+ );
473
+ }
474
+
475
+ public function widget( $args, $instance ) {
476
+ global $quads_options;
477
+
478
+ extract( $args );
479
+ $cont = quads_post_settings_to_quicktags( get_the_content() );
480
+ if( strpos( $cont, "<!--OffAds-->" ) === false && strpos( $cont, "<!--OffWidget-->" ) === false && quads_ad_is_allowed() && !quads_ad_reach_max_count() ) {
481
+
482
+ quads_set_ad_count_widget();
483
+ $code = quads_render_ad( 'ad' . $this->adsID . '_widget', $quads_options['ad' . $this->adsID . '_widget']['code'] );
484
+ echo "\n" . "<!-- Quick Adsense Reloaded -->" . "\n";
485
+ if( array_key_exists( 'before_widget', $args ) )
486
+ echo $args['before_widget'];
487
+ echo '<div id="quads-ad' . $this->adsID . '_widget">';
488
+ echo $code;
489
+ echo '</div>';
490
+ if( array_key_exists( 'after_widget', $args ) )
491
+ echo $args['after_widget'];
492
+ };
493
+ }
494
+
495
+ }
496
+
497
+ // class My_Widget10
languages/README.md ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Quick AdSense Reloaded I18n #
2
+
3
+ To help translate, review, or improve a translation, write Rene Hermenau at info@mashshare.net
4
+
5
+
6
+ # Quick Start #
7
+
8
+ In quick-adsense-reloaded/languages/ you find a file named quads.po
9
+
10
+ - Open it with the free editor: http://poedit.net/
11
+
12
+ - Translate the strings and save it. Poedit automatically creates the file quads.mo
13
+
14
+ - Rename this to your language specific translation. E.g. for italy the file is called quads-it_IT.mo and put it into the folder /quick-adsense-reloaded/languages/
15
+
16
+ I really appreciate it if you like to send me the generated mo file. I will put it than into the official Quick AdSense Reloaded Plugin repository.
17
+
languages/index.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Do not put custom translations here. They will be deleted on Quick AdSense Reloaded updates.
4
+ *
5
+ * Keep custom QUADS translations in /wp-content/languages/quads
6
+ */
languages/quads-en_EN.mo ADDED
Binary file
languages/quads-en_EN.po ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014
2
+ # This file is distributed under the same license as the package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: \n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/quadssharer\n"
7
+ "POT-Creation-Date: 2014-10-15 16:53:24+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: includes/admin/add-ons.php:27
16
+ msgid "Add Ons for Quick AdSense Reloaded"
17
+ msgstr ""
18
+
19
+ #: includes/admin/add-ons.php:28
20
+ msgid "Visit Website"
21
+ msgstr ""
22
+
23
+ #: includes/admin/add-ons.php:28
24
+ msgid "See Details"
25
+ msgstr ""
26
+
27
+ #: includes/admin/add-ons.php:30
28
+ msgid "These add-ons extend the functionality of Quick AdSense Reloaded."
29
+ msgstr ""
30
+
31
+ #: includes/admin/add-ons.php:54
32
+ msgid ""
33
+ "There was an error retrieving the Quick AdSense Reloaded addon list from the server. "
34
+ "Please try again later."
35
+ msgstr ""
36
+
37
+ #: includes/admin/admin-footer.php:27
38
+ msgid ""
39
+ "Thank you for using <a href=\"%1$s\" target=\"_blank\">Quick AdSense Reloaded</a>! Please "
40
+ "<a href=\"%2$s\" target=\"_blank\">rate us</a> on <a href=\"%2$s\" target="
41
+ "\"_blank\">WordPress.org</a> and help to support this project."
42
+ msgstr ""
43
+
44
+ #: includes/admin/admin-notices.php:46
45
+ msgid ""
46
+ "There seems to be an issue with the server. Please try again in a few "
47
+ "minutes."
48
+ msgstr ""
49
+
50
+ #: includes/admin/admin-pages.php:33
51
+ msgid "Quick AdSense Reloaded"
52
+ msgstr ""
53
+
54
+ #: includes/admin/admin-pages.php:34
55
+ msgid "Quick AdSense Reloaded Settings"
56
+ msgstr ""
57
+
58
+ #: includes/admin/admin-pages.php:34
59
+ msgid "Settings"
60
+ msgstr ""
61
+
62
+ #: includes/admin/admin-pages.php:35
63
+ msgid "Quick AdSense Reloaded Add Ons"
64
+ msgstr ""
65
+
66
+ #: includes/admin/admin-pages.php:35 includes/admin/plugins.php:51
67
+ msgid "Add Ons"
68
+ msgstr ""
69
+
70
+ #: includes/admin/plugins.php:27
71
+ msgid "General Settings"
72
+ msgstr ""
73
+
74
+ #: includes/admin/plugins.php:50
75
+ msgid "Getting Started"
76
+ msgstr ""
77
+
78
+ #: includes/admin/settings/contextual-help.php:29
79
+ msgid "For more information:"
80
+ msgstr ""
81
+
82
+ #: includes/admin/settings/contextual-help.php:30
83
+ msgid "Visit the <a href=\"%s\">documentation</a> on the quadsare website."
84
+ msgstr ""
85
+
86
+ #: includes/admin/settings/contextual-help.php:32
87
+ msgid ""
88
+ "<a href=\"%s\">Post an issue</a> on <a href=\"%s\">quadsare</a>. View <a href="
89
+ "\"%s\">extensions</a>."
90
+ msgstr ""
91
+
92
+ #: includes/admin/settings/contextual-help.php:41
93
+ #: includes/admin/settings/register-settings.php:498
94
+ msgid "General"
95
+ msgstr ""
96
+
97
+ #: includes/admin/settings/contextual-help.php:42
98
+ msgid "This screen provides the most basic settings for configuring Quick AdSense Reloaded."
99
+ msgstr ""
100
+
101
+ #: includes/admin/settings/display-settings.php:32
102
+ msgid "Welcome to Quick AdSense Reloaded "
103
+ msgstr ""
104
+
105
+ #: includes/admin/settings/display-settings.php:34
106
+ msgid "Thank you for updating to the latest version!"
107
+ msgstr ""
108
+
109
+ #: includes/admin/settings/display-settings.php:36
110
+ msgid "Quick AdSense Reloaded is ready to increase your Shares!"
111
+ msgstr ""
112
+
113
+ #: includes/admin/settings/display-settings.php:37
114
+ msgid ""
115
+ "php_curl is not working on your server. </span><a href=\"http://us."
116
+ "informatiweb.net/programmation/32--enable-curl-extension-of-php-on-windows."
117
+ "html\" target=\"_blank\">Please enable it.</a>"
118
+ msgstr ""
119
+
120
+ #: includes/admin/settings/register-settings.php:130
121
+ msgid "Cache expire"
122
+ msgstr ""
123
+
124
+ #: includes/admin/settings/register-settings.php:131
125
+ msgid ""
126
+ "The amount of shares are updated after time of \"cache expire\". Notice that "
127
+ "Sharedcount.com uses his own cache (30 - 60min) so it does not update "
128
+ "immediately when expire time is very low, e.g. 5 minutes."
129
+ msgstr ""
130
+
131
+ #: includes/admin/settings/register-settings.php:137
132
+ msgid "API Key - Important"
133
+ msgstr ""
134
+
135
+ #: includes/admin/settings/register-settings.php:138
136
+ msgid ""
137
+ "Get it FREE at <a href=\"https://admin.sharedcount.com/admin/signup.php\" "
138
+ "target=\"_blank\">SharedCount.com</a> for 10.000 free daily requests. It´s "
139
+ "essential for accurate function of this plugin. Make sure Curl is working on "
140
+ "your server."
141
+ msgstr ""
142
+
143
+ #: includes/admin/settings/register-settings.php:144
144
+ msgid "Disable Sharecount"
145
+ msgstr ""
146
+
147
+ #: includes/admin/settings/register-settings.php:145
148
+ msgid ""
149
+ "Use this when you can not enable curl_exec and share counts stays zero on "
150
+ "your site. In this mode the plugin do not calls the database and no SQL "
151
+ "queries are done. (Gives just a very little performance boost because all "
152
+ "database requests are cached in any case.)"
153
+ msgstr ""
154
+
155
+ #: includes/admin/settings/register-settings.php:150
156
+ msgid "Hide Sharecount"
157
+ msgstr ""
158
+
159
+ #: includes/admin/settings/register-settings.php:151
160
+ msgid ""
161
+ "Optional: If you fill in any number here, the shares for a specific post are "
162
+ "not shown until the share count of this number is reached."
163
+ msgstr ""
164
+
165
+ #: includes/admin/settings/register-settings.php:157
166
+ msgid "Exclude from"
167
+ msgstr ""
168
+
169
+ #: includes/admin/settings/register-settings.php:158
170
+ msgid ""
171
+ "Exclude share buttons from a list of specific posts and pages. Put in the "
172
+ "page id seperated by a comma, e.g. 23, 63, 114 "
173
+ msgstr ""
174
+
175
+ #: includes/admin/settings/register-settings.php:164
176
+ msgid "Execution Order"
177
+ msgstr ""
178
+
179
+ #: includes/admin/settings/register-settings.php:165
180
+ msgid ""
181
+ "If you use other content plugins you can define here the execution order. "
182
+ "Lower numbers mean earlier execution. E.g. Say \"0\" and Quick AdSense Reloaded is "
183
+ "executed before any other plugin (When the other plugin is not overwriting "
184
+ "our execution order). Default is \"1000\""
185
+ msgstr ""
186
+
187
+ #: includes/admin/settings/register-settings.php:172
188
+ msgid "Disable Transient Cache"
189
+ msgstr ""
190
+
191
+ #: includes/admin/settings/register-settings.php:178
192
+ msgid "Delete DB Cache"
193
+ msgstr ""
194
+
195
+ #: includes/admin/settings/register-settings.php:184
196
+ msgid "Debug mode"
197
+ msgstr ""
198
+
199
+ #: includes/admin/settings/register-settings.php:185
200
+ msgid ""
201
+ "<strong>Note: </strong> Check this box this before you get in contact with "
202
+ "our support team. This allows us to check publically hidden debug messages "
203
+ "on your website. Do not forget to disable it thereafter!"
204
+ msgstr ""
205
+
206
+ #: includes/admin/settings/register-settings.php:190
207
+ msgid "Fake Share counts"
208
+ msgstr ""
209
+
210
+ #: includes/admin/settings/register-settings.php:191
211
+ msgid ""
212
+ "This number will be aggregated to all your share counts multiplied with a "
213
+ "post specific factor based on title word count divided 10."
214
+ msgstr ""
215
+
216
+ #: includes/admin/settings/register-settings.php:197
217
+ msgid "Remove Data on Uninstall?"
218
+ msgstr ""
219
+
220
+ #: includes/admin/settings/register-settings.php:198
221
+ msgid ""
222
+ "Check this box if you would like Quick AdSense Reloaded to completely remove all of its "
223
+ "data when the plugin is deleted."
224
+ msgstr ""
225
+
226
+ #: includes/admin/settings/register-settings.php:207
227
+ msgid "Position"
228
+ msgstr ""
229
+
230
+ #: includes/admin/settings/register-settings.php:208
231
+ msgid ""
232
+ "Choose where you would like the social icons to appear, before or after the "
233
+ "main content. If set to Manual, you can use this code to place your Social "
234
+ "links anywhere you like in your templates files: <strong>&lt;?php do_action"
235
+ "(\"quadsshare\"); ?&gt;</strong> or use the shortcode: [quadsshare] in your "
236
+ "posts. Optional: <strong>[quadsshare shares=\"off\"]</strong> if you like to "
237
+ "disable the share number."
238
+ msgstr ""
239
+
240
+ #: includes/admin/settings/register-settings.php:211
241
+ msgid "Top"
242
+ msgstr ""
243
+
244
+ #: includes/admin/settings/register-settings.php:212
245
+ msgid "Bottom"
246
+ msgstr ""
247
+
248
+ #: includes/admin/settings/register-settings.php:213
249
+ msgid "Top and Bottom"
250
+ msgstr ""
251
+
252
+ #: includes/admin/settings/register-settings.php:214
253
+ msgid "Manual"
254
+ msgstr ""
255
+
256
+ #: includes/admin/settings/register-settings.php:220
257
+ msgid "Post Types"
258
+ msgstr ""
259
+
260
+ #: includes/admin/settings/register-settings.php:221
261
+ msgid ""
262
+ "Select on which post_types the share buttons appear. This values will be "
263
+ "ignored when position is specified \"manual\"."
264
+ msgstr ""
265
+
266
+ #: includes/admin/settings/register-settings.php:226
267
+ msgid "Frontpage"
268
+ msgstr ""
269
+
270
+ #: includes/admin/settings/register-settings.php:227
271
+ msgid "Enable share buttons on frontpage"
272
+ msgstr ""
273
+
274
+ #: includes/admin/settings/register-settings.php:232
275
+ msgid "Round Shares"
276
+ msgstr ""
277
+
278
+ #: includes/admin/settings/register-settings.php:233
279
+ msgid "Share counts more than 1000 are shown as 1k. More than 1 Million as 1M"
280
+ msgstr ""
281
+
282
+ #: includes/admin/settings/register-settings.php:238
283
+ msgid "Animate Shares"
284
+ msgstr ""
285
+
286
+ #: includes/admin/settings/register-settings.php:239
287
+ msgid ""
288
+ "Count up the shares on page loading with a nice looking and fast jQuery "
289
+ "animation. This only works on singular pages and not with shortcodes "
290
+ "generated buttons."
291
+ msgstr ""
292
+
293
+ #: includes/admin/settings/register-settings.php:244
294
+ msgid "Twitter Handle"
295
+ msgstr ""
296
+
297
+ #: includes/admin/settings/register-settings.php:245
298
+ msgid ""
299
+ "Optional: Using your twitter username, e.g. 'Quick AdSense Reloaded' results in via "
300
+ "@Quick AdSense Reloaded"
301
+ msgstr ""
302
+
303
+ #: includes/admin/settings/register-settings.php:251
304
+ msgid "Share color"
305
+ msgstr ""
306
+
307
+ #: includes/admin/settings/register-settings.php:252
308
+ msgid "Choose color of the share number in hex format, e.g. #7FC04C: "
309
+ msgstr ""
310
+
311
+ #: includes/admin/settings/register-settings.php:259
312
+ msgid "Border Radius"
313
+ msgstr ""
314
+
315
+ #: includes/admin/settings/register-settings.php:260
316
+ msgid ""
317
+ "Specify the border radius of all buttons in pixel. A border radius of 20px "
318
+ "results in circle buttons. Default value is zero."
319
+ msgstr ""
320
+
321
+ #: includes/admin/settings/register-settings.php:291
322
+ msgid "Style"
323
+ msgstr ""
324
+
325
+ #: includes/admin/settings/register-settings.php:292
326
+ msgid ""
327
+ "Load another style to change visual appearance of the share buttons. <br>if "
328
+ "you created a custom style and you want to make it available for the "
329
+ "community here, <a href=\"https://www.quadsshare.net/contact-support/\" "
330
+ "target=\"_blank\"> get in contact with me.</a>"
331
+ msgstr ""
332
+
333
+ #: includes/admin/settings/register-settings.php:304
334
+ msgid "Subscribe behavior"
335
+ msgstr ""
336
+
337
+ #: includes/admin/settings/register-settings.php:305
338
+ msgid ""
339
+ "Specify behavior of the subscribe button and decide if you like to link the "
340
+ "button directly to any content or to have a toggled content slider below the "
341
+ "button."
342
+ msgstr ""
343
+
344
+ #: includes/admin/settings/register-settings.php:316
345
+ msgid "Subscribe Link"
346
+ msgstr ""
347
+
348
+ #: includes/admin/settings/register-settings.php:317
349
+ msgid "The link to any place on your site, e.g. http://yoursite.com/subscribe"
350
+ msgstr ""
351
+
352
+ #: includes/admin/settings/register-settings.php:324
353
+ msgid "Subscribe content"
354
+ msgstr ""
355
+
356
+ #: includes/admin/settings/register-settings.php:325
357
+ msgid ""
358
+ "Define your subscribe content here. Forms, like button, links or any other "
359
+ "text. Shortcodes are also supported, e.g.: [contact-form-7]"
360
+ msgstr ""
361
+
362
+ #: includes/admin/settings/register-settings.php:332
363
+ msgid "Custom CSS"
364
+ msgstr ""
365
+
366
+ #: includes/admin/settings/register-settings.php:333
367
+ msgid "Put in some custom styles here"
368
+ msgstr ""
369
+
370
+ #: includes/admin/settings/register-settings.php:344
371
+ msgid "Large Buttons"
372
+ msgstr ""
373
+
374
+ #: includes/admin/settings/register-settings.php:345
375
+ msgid ""
376
+ "Specify how many services and social networks are visible before the \"Plus"
377
+ "\" Button is shown. This buttons turn into large prominent buttons."
378
+ msgstr ""
379
+
380
+ #: includes/admin/settings/register-settings.php:351
381
+ msgid "Services"
382
+ msgstr ""
383
+
384
+ #: includes/admin/settings/register-settings.php:352
385
+ msgid ""
386
+ "Drag and drop the Share Buttons to sort them and specify which ones should "
387
+ "be enabled. If you enable more services than the specified value \"Large "
388
+ "Buttons\", the plus sign is automatically added to the last visible big "
389
+ "share button.<br><strong>No Share Services visible after update?</strong> "
390
+ "Disable and enable the Quick AdSense Reloaded Plugin solves this. "
391
+ msgstr ""
392
+
393
+ #: includes/admin/settings/register-settings.php:368
394
+ #: includes/admin/settings/register-settings.php:515
395
+ msgid "Add-Ons"
396
+ msgstr ""
397
+
398
+ #: includes/admin/settings/register-settings.php:369
399
+ msgid "All Quick AdSense Reloaded Add-Ons at a glance"
400
+ msgstr ""
401
+
402
+ #: includes/admin/settings/register-settings.php:441
403
+ msgid "Settings updated."
404
+ msgstr ""
405
+
406
+ #: includes/admin/settings/register-settings.php:501
407
+ msgid "Visual"
408
+ msgstr ""
409
+
410
+ #: includes/admin/settings/register-settings.php:505
411
+ #: includes/admin/settings/register-settings.php:1042
412
+ msgid "Social Networks"
413
+ msgstr ""
414
+
415
+ #: includes/admin/settings/register-settings.php:509
416
+ msgid "Extensions"
417
+ msgstr ""
418
+
419
+ #: includes/admin/settings/register-settings.php:513
420
+ msgid "Licenses"
421
+ msgstr ""
422
+
423
+ #: includes/admin/settings/register-settings.php:807
424
+ msgid ""
425
+ "The callback function used for the <strong>%s</strong> setting is missing."
426
+ msgstr ""
427
+
428
+ #: includes/admin/settings/register-settings.php:938
429
+ msgid "Upload File"
430
+ msgstr ""
431
+
432
+ #: includes/admin/settings/register-settings.php:994
433
+ msgid "Deactivate License"
434
+ msgstr ""
435
+
436
+ #: includes/admin/settings/register-settings.php:1043
437
+ msgid "Enable"
438
+ msgstr ""
439
+
440
+ #: includes/admin/settings/register-settings.php:1044
441
+ msgid "Custom name"
442
+ msgstr ""
443
+
444
+ #: includes/admin/settings/register-settings.php:1097
445
+ msgid "Select Image"
446
+ msgstr ""
447
+
448
+ #: includes/admin/settings/register-settings.php:1170
449
+ msgid "All Services"
450
+ msgstr ""
451
+
452
+ #: includes/admin/settings/register-settings.php:1187
453
+ msgid ""
454
+ "DB cache deleted. Do not forget to uncheck this box for performance increase."
455
+ msgstr ""
456
+
457
+ #: includes/admin/settings/register-settings.php:1200
458
+ msgid "Transient Cache disabled! Enable it for performance increase."
459
+ msgstr ""
460
+
461
+ #: includes/class-quads-html-elements.php:43
462
+ msgctxt "all dropdown items"
463
+ msgid "All"
464
+ msgstr ""
465
+
466
+ #: includes/class-quads-html-elements.php:44
467
+ msgctxt "no dropdown items"
468
+ msgid "None"
469
+ msgstr ""
470
+
471
+ #: includes/class-quads-html-elements.php:232
472
+ msgid "Enter username"
473
+ msgstr ""
474
+
475
+ #: includes/class-quads-license-handler.php:133
476
+ msgid "%1$s License Key"
477
+ msgstr ""
478
+
479
+ #: includes/template-functions.php:210
480
+ msgid "Subscribe"
481
+ msgstr ""
482
+
483
+ #: includes/template-functions.php:393 includes/template-functions.php:448
484
+ msgid "SHARES"
485
+ msgstr ""
486
+
487
+ #: quadsshare.php:99 quadsshare.php:111
488
+ msgid "Cheatin&#8217; huh?"
489
+ msgstr ""
languages/quads.po ADDED
@@ -0,0 +1,489 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014
2
+ # This file is distributed under the same license as the package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: \n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/quadssharer\n"
7
+ "POT-Creation-Date: 2014-10-27 14:22:51+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: includes/admin/add-ons.php:27
16
+ msgid "Add Ons for Quick AdSense Reloaded"
17
+ msgstr ""
18
+
19
+ #: includes/admin/add-ons.php:28
20
+ msgid "Visit Website"
21
+ msgstr ""
22
+
23
+ #: includes/admin/add-ons.php:28
24
+ msgid "See Details"
25
+ msgstr ""
26
+
27
+ #: includes/admin/add-ons.php:30
28
+ msgid "These add-ons extend the functionality of Quick AdSense Reloaded."
29
+ msgstr ""
30
+
31
+ #: includes/admin/add-ons.php:54
32
+ msgid ""
33
+ "There was an error retrieving the Quick AdSense Reloaded addon list from the server. "
34
+ "Please try again later."
35
+ msgstr ""
36
+
37
+ #: includes/admin/admin-footer.php:27
38
+ msgid ""
39
+ "Thank you for using <a href=\"%1$s\" target=\"_blank\">Quick AdSense Reloaded</a>! Please "
40
+ "<a href=\"%2$s\" target=\"_blank\">rate us</a> on <a href=\"%2$s\" target="
41
+ "\"_blank\">WordPress.org</a> and help to support this project."
42
+ msgstr ""
43
+
44
+ #: includes/admin/admin-notices.php:46
45
+ msgid ""
46
+ "There seems to be an issue with the server. Please try again in a few "
47
+ "minutes."
48
+ msgstr ""
49
+
50
+ #: includes/admin/admin-pages.php:33
51
+ msgid "Quick AdSense Reloaded"
52
+ msgstr ""
53
+
54
+ #: includes/admin/admin-pages.php:34
55
+ msgid "Quick AdSense Reloaded Settings"
56
+ msgstr ""
57
+
58
+ #: includes/admin/admin-pages.php:34
59
+ msgid "Settings"
60
+ msgstr ""
61
+
62
+ #: includes/admin/admin-pages.php:35
63
+ msgid "Quick AdSense Reloaded Add Ons"
64
+ msgstr ""
65
+
66
+ #: includes/admin/admin-pages.php:35 includes/admin/plugins.php:51
67
+ msgid "Add Ons"
68
+ msgstr ""
69
+
70
+ #: includes/admin/plugins.php:27
71
+ msgid "General Settings"
72
+ msgstr ""
73
+
74
+ #: includes/admin/plugins.php:50
75
+ msgid "Getting Started"
76
+ msgstr ""
77
+
78
+ #: includes/admin/settings/contextual-help.php:29
79
+ msgid "For more information:"
80
+ msgstr ""
81
+
82
+ #: includes/admin/settings/contextual-help.php:30
83
+ msgid "Visit the <a href=\"%s\">documentation</a> on the quadsare website."
84
+ msgstr ""
85
+
86
+ #: includes/admin/settings/contextual-help.php:32
87
+ msgid ""
88
+ "<a href=\"%s\">Post an issue</a> on <a href=\"%s\">quadsare</a>. View <a href="
89
+ "\"%s\">extensions</a>."
90
+ msgstr ""
91
+
92
+ #: includes/admin/settings/contextual-help.php:41
93
+ #: includes/admin/settings/register-settings.php:498
94
+ msgid "General"
95
+ msgstr ""
96
+
97
+ #: includes/admin/settings/contextual-help.php:42
98
+ msgid "This screen provides the most basic settings for configuring Quick AdSense Reloaded."
99
+ msgstr ""
100
+
101
+ #: includes/admin/settings/display-settings.php:32
102
+ msgid "Welcome to Quick AdSense Reloaded "
103
+ msgstr ""
104
+
105
+ #: includes/admin/settings/display-settings.php:34
106
+ msgid "Thank you for updating to the latest version!"
107
+ msgstr ""
108
+
109
+ #: includes/admin/settings/display-settings.php:36
110
+ msgid "Quick AdSense Reloaded is ready to increase your Shares!"
111
+ msgstr ""
112
+
113
+ #: includes/admin/settings/display-settings.php:37
114
+ msgid ""
115
+ "php_curl is not working on your server. </span><a href=\"http://us."
116
+ "informatiweb.net/programmation/32--enable-curl-extension-of-php-on-windows."
117
+ "html\" target=\"_blank\">Please enable it.</a>"
118
+ msgstr ""
119
+
120
+ #: includes/admin/settings/register-settings.php:130
121
+ msgid "Cache expire"
122
+ msgstr ""
123
+
124
+ #: includes/admin/settings/register-settings.php:131
125
+ msgid ""
126
+ "The amount of shares are updated after time of \"cache expire\". Notice that "
127
+ "Sharedcount.com uses his own cache (30 - 60min) so it does not update "
128
+ "immediately when expire time is very low, e.g. 5 minutes."
129
+ msgstr ""
130
+
131
+ #: includes/admin/settings/register-settings.php:137
132
+ msgid "API Key - Important"
133
+ msgstr ""
134
+
135
+ #: includes/admin/settings/register-settings.php:138
136
+ msgid ""
137
+ "Get it FREE at <a href=\"https://admin.sharedcount.com/admin/signup.php\" "
138
+ "target=\"_blank\">SharedCount.com</a> for 10.000 free daily requests. It´s "
139
+ "essential for accurate function of this plugin. Make sure Curl is working on "
140
+ "your server."
141
+ msgstr ""
142
+
143
+ #: includes/admin/settings/register-settings.php:144
144
+ msgid "Disable Sharecount"
145
+ msgstr ""
146
+
147
+ #: includes/admin/settings/register-settings.php:145
148
+ msgid ""
149
+ "Use this when you can not enable curl_exec and share counts stays zero on "
150
+ "your site. In this mode the plugin do not calls the database and no SQL "
151
+ "queries are done. (Gives just a very little performance boost because all "
152
+ "database requests are cached in any case.)"
153
+ msgstr ""
154
+
155
+ #: includes/admin/settings/register-settings.php:150
156
+ msgid "Hide Sharecount"
157
+ msgstr ""
158
+
159
+ #: includes/admin/settings/register-settings.php:151
160
+ msgid ""
161
+ "Optional: If you fill in any number here, the shares for a specific post are "
162
+ "not shown until the share count of this number is reached."
163
+ msgstr ""
164
+
165
+ #: includes/admin/settings/register-settings.php:157
166
+ msgid "Exclude from"
167
+ msgstr ""
168
+
169
+ #: includes/admin/settings/register-settings.php:158
170
+ msgid ""
171
+ "Exclude share buttons from a list of specific posts and pages. Put in the "
172
+ "page id seperated by a comma, e.g. 23, 63, 114 "
173
+ msgstr ""
174
+
175
+ #: includes/admin/settings/register-settings.php:164
176
+ msgid "Execution Order"
177
+ msgstr ""
178
+
179
+ #: includes/admin/settings/register-settings.php:165
180
+ msgid ""
181
+ "If you use other content plugins you can define here the execution order. "
182
+ "Lower numbers mean earlier execution. E.g. Say \"0\" and Quick AdSense Reloaded is "
183
+ "executed before any other plugin (When the other plugin is not overwriting "
184
+ "our execution order). Default is \"1000\""
185
+ msgstr ""
186
+
187
+ #: includes/admin/settings/register-settings.php:172
188
+ msgid "Disable Transient Cache"
189
+ msgstr ""
190
+
191
+ #: includes/admin/settings/register-settings.php:178
192
+ msgid "Delete DB Cache"
193
+ msgstr ""
194
+
195
+ #: includes/admin/settings/register-settings.php:184
196
+ msgid "Debug mode"
197
+ msgstr ""
198
+
199
+ #: includes/admin/settings/register-settings.php:185
200
+ msgid ""
201
+ "<strong>Note: </strong> Check this box this before you get in contact with "
202
+ "our support team. This allows us to check publically hidden debug messages "
203
+ "on your website. Do not forget to disable it thereafter!"
204
+ msgstr ""
205
+
206
+ #: includes/admin/settings/register-settings.php:190
207
+ msgid "Fake Share counts"
208
+ msgstr ""
209
+
210
+ #: includes/admin/settings/register-settings.php:191
211
+ msgid ""
212
+ "This number will be aggregated to all your share counts multiplied with a "
213
+ "post specific factor based on title word count divided 10."
214
+ msgstr ""
215
+
216
+ #: includes/admin/settings/register-settings.php:197
217
+ msgid "Remove Data on Uninstall?"
218
+ msgstr ""
219
+
220
+ #: includes/admin/settings/register-settings.php:198
221
+ msgid ""
222
+ "Check this box if you would like Quick AdSense Reloaded to completely remove all of its "
223
+ "data when the plugin is deleted."
224
+ msgstr ""
225
+
226
+ #: includes/admin/settings/register-settings.php:207
227
+ msgid "Position"
228
+ msgstr ""
229
+
230
+ #: includes/admin/settings/register-settings.php:208
231
+ msgid ""
232
+ "Choose where you would like the social icons to appear, before or after the "
233
+ "main content. If set to Manual, you can use this code to place your Social "
234
+ "links anywhere you like in your templates files: <strong>&lt;?php do_action"
235
+ "(\"quadsshare\"); ?&gt;</strong> or use the shortcode: [quadsshare] in your "
236
+ "posts. Optional: <strong>[quadsshare shares=\"off\"]</strong> if you like to "
237
+ "disable the share number."
238
+ msgstr ""
239
+
240
+ #: includes/admin/settings/register-settings.php:211
241
+ msgid "Top"
242
+ msgstr ""
243
+
244
+ #: includes/admin/settings/register-settings.php:212
245
+ msgid "Bottom"
246
+ msgstr ""
247
+
248
+ #: includes/admin/settings/register-settings.php:213
249
+ msgid "Top and Bottom"
250
+ msgstr ""
251
+
252
+ #: includes/admin/settings/register-settings.php:214
253
+ msgid "Manual"
254
+ msgstr ""
255
+
256
+ #: includes/admin/settings/register-settings.php:220
257
+ msgid "Post Types"
258
+ msgstr ""
259
+
260
+ #: includes/admin/settings/register-settings.php:221
261
+ msgid ""
262
+ "Select on which post_types the share buttons appear. This values will be "
263
+ "ignored when position is specified \"manual\"."
264
+ msgstr ""
265
+
266
+ #: includes/admin/settings/register-settings.php:226
267
+ msgid "Frontpage"
268
+ msgstr ""
269
+
270
+ #: includes/admin/settings/register-settings.php:227
271
+ msgid "Enable share buttons on frontpage"
272
+ msgstr ""
273
+
274
+ #: includes/admin/settings/register-settings.php:232
275
+ msgid "Round Shares"
276
+ msgstr ""
277
+
278
+ #: includes/admin/settings/register-settings.php:233
279
+ msgid "Share counts more than 1000 are shown as 1k. More than 1 Million as 1M"
280
+ msgstr ""
281
+
282
+ #: includes/admin/settings/register-settings.php:238
283
+ msgid "Animate Shares"
284
+ msgstr ""
285
+
286
+ #: includes/admin/settings/register-settings.php:239
287
+ msgid ""
288
+ "Count up the shares on page loading with a nice looking and fast jQuery "
289
+ "animation. This only works on singular pages and not with shortcodes "
290
+ "generated buttons."
291
+ msgstr ""
292
+
293
+ #: includes/admin/settings/register-settings.php:244
294
+ msgid "Twitter Handle"
295
+ msgstr ""
296
+
297
+ #: includes/admin/settings/register-settings.php:245
298
+ msgid ""
299
+ "Optional: Using your twitter username, e.g. 'Quick AdSense Reloaded' results in via "
300
+ "@Quick AdSense Reloaded"
301
+ msgstr ""
302
+
303
+ #: includes/admin/settings/register-settings.php:251
304
+ msgid "Share color"
305
+ msgstr ""
306
+
307
+ #: includes/admin/settings/register-settings.php:252
308
+ msgid "Choose color of the share number in hex format, e.g. #7FC04C: "
309
+ msgstr ""
310
+
311
+ #: includes/admin/settings/register-settings.php:259
312
+ msgid "Border Radius"
313
+ msgstr ""
314
+
315
+ #: includes/admin/settings/register-settings.php:260
316
+ msgid ""
317
+ "Specify the border radius of all buttons in pixel. A border radius of 20px "
318
+ "results in circle buttons. Default value is zero."
319
+ msgstr ""
320
+
321
+ #: includes/admin/settings/register-settings.php:291
322
+ msgid "Style"
323
+ msgstr ""
324
+
325
+ #: includes/admin/settings/register-settings.php:292
326
+ msgid ""
327
+ "Load another style to change visual appearance of the share buttons. <br>if "
328
+ "you created a custom style and you want to make it available for the "
329
+ "community here, <a href=\"https://www.quadsshare.net/contact-support/\" "
330
+ "target=\"_blank\"> get in contact with me.</a>"
331
+ msgstr ""
332
+
333
+ #: includes/admin/settings/register-settings.php:304
334
+ msgid "Subscribe behavior"
335
+ msgstr ""
336
+
337
+ #: includes/admin/settings/register-settings.php:305
338
+ msgid ""
339
+ "Specify behavior of the subscribe button and decide if you like to link the "
340
+ "button directly to any content or to have a toggled content slider below the "
341
+ "button."
342
+ msgstr ""
343
+
344
+ #: includes/admin/settings/register-settings.php:316
345
+ msgid "Subscribe Link"
346
+ msgstr ""
347
+
348
+ #: includes/admin/settings/register-settings.php:317
349
+ msgid "The link to any place on your site, e.g. http://yoursite.com/subscribe"
350
+ msgstr ""
351
+
352
+ #: includes/admin/settings/register-settings.php:324
353
+ msgid "Subscribe content"
354
+ msgstr ""
355
+
356
+ #: includes/admin/settings/register-settings.php:325
357
+ msgid ""
358
+ "Define your subscribe content here. Forms, like button, links or any other "
359
+ "text. Shortcodes are also supported, e.g.: [contact-form-7]"
360
+ msgstr ""
361
+
362
+ #: includes/admin/settings/register-settings.php:332
363
+ msgid "Custom CSS"
364
+ msgstr ""
365
+
366
+ #: includes/admin/settings/register-settings.php:333
367
+ msgid "Put in some custom styles here"
368
+ msgstr ""
369
+
370
+ #: includes/admin/settings/register-settings.php:344
371
+ msgid "Large Buttons"
372
+ msgstr ""
373
+
374
+ #: includes/admin/settings/register-settings.php:345
375
+ msgid ""
376
+ "Specify how many services and social networks are visible before the \"Plus"
377
+ "\" Button is shown. This buttons turn into large prominent buttons."
378
+ msgstr ""
379
+
380
+ #: includes/admin/settings/register-settings.php:351
381
+ msgid "Services"
382
+ msgstr ""
383
+
384
+ #: includes/admin/settings/register-settings.php:352
385
+ msgid ""
386
+ "Drag and drop the Share Buttons to sort them and specify which ones should "
387
+ "be enabled. If you enable more services than the specified value \"Large "
388
+ "Buttons\", the plus sign is automatically added to the last visible big "
389
+ "share button.<br><strong>No Share Services visible after update?</strong> "
390
+ "Disable and enable the Quick AdSense Reloaded Plugin solves this. "
391
+ msgstr ""
392
+
393
+ #: includes/admin/settings/register-settings.php:368
394
+ #: includes/admin/settings/register-settings.php:515
395
+ msgid "Add-Ons"
396
+ msgstr ""
397
+
398
+ #: includes/admin/settings/register-settings.php:369
399
+ msgid "All Quick AdSense Reloaded Add-Ons at a glance"
400
+ msgstr ""
401
+
402
+ #: includes/admin/settings/register-settings.php:441
403
+ msgid "Settings updated."
404
+ msgstr ""
405
+
406
+ #: includes/admin/settings/register-settings.php:501
407
+ msgid "Visual"
408
+ msgstr ""
409
+
410
+ #: includes/admin/settings/register-settings.php:505
411
+ #: includes/admin/settings/register-settings.php:1042
412
+ msgid "Social Networks"
413
+ msgstr ""
414
+
415
+ #: includes/admin/settings/register-settings.php:509
416
+ msgid "Extensions"
417
+ msgstr ""
418
+
419
+ #: includes/admin/settings/register-settings.php:513
420
+ msgid "Licenses"
421
+ msgstr ""
422
+
423
+ #: includes/admin/settings/register-settings.php:807
424
+ msgid ""
425
+ "The callback function used for the <strong>%s</strong> setting is missing."
426
+ msgstr ""
427
+
428
+ #: includes/admin/settings/register-settings.php:938
429
+ msgid "Upload File"
430
+ msgstr ""
431
+
432
+ #: includes/admin/settings/register-settings.php:994
433
+ msgid "Deactivate License"
434
+ msgstr ""
435
+
436
+ #: includes/admin/settings/register-settings.php:1043
437
+ msgid "Enable"
438
+ msgstr ""
439
+
440
+ #: includes/admin/settings/register-settings.php:1044
441
+ msgid "Custom name"
442
+ msgstr ""
443
+
444
+ #: includes/admin/settings/register-settings.php:1097
445
+ msgid "Select Image"
446
+ msgstr ""
447
+
448
+ #: includes/admin/settings/register-settings.php:1170
449
+ msgid "All Services"
450
+ msgstr ""
451
+
452
+ #: includes/admin/settings/register-settings.php:1187
453
+ msgid ""
454
+ "DB cache deleted. Do not forget to uncheck this box for performance increase."
455
+ msgstr ""
456
+
457
+ #: includes/admin/settings/register-settings.php:1200
458
+ msgid "Transient Cache disabled! Enable it for performance increase."
459
+ msgstr ""
460
+
461
+ #: includes/class-quads-html-elements.php:43
462
+ msgctxt "all dropdown items"
463
+ msgid "All"
464
+ msgstr ""
465
+
466
+ #: includes/class-quads-html-elements.php:44
467
+ msgctxt "no dropdown items"
468
+ msgid "None"
469
+ msgstr ""
470
+
471
+ #: includes/class-quads-html-elements.php:232
472
+ msgid "Enter username"
473
+ msgstr ""
474
+
475
+ #: includes/class-quads-license-handler.php:133
476
+ msgid "%1$s License Key"
477
+ msgstr ""
478
+
479
+ #: includes/template-functions.php:210
480
+ msgid "Subscribe"
481
+ msgstr ""
482
+
483
+ #: includes/template-functions.php:393 includes/template-functions.php:448
484
+ msgid "SHARES"
485
+ msgstr ""
486
+
487
+ #: quadsshare.php:99 quadsshare.php:111
488
+ msgid "Cheatin&#8217; huh?"
489
+ msgstr ""
languages/readme.txt ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ********************************************************
2
+
3
+ Quick AdSense Reloaded I18n
4
+ ============================
5
+
6
+ Do not put custom translations here. They will be deleted
7
+ on Quick AdSense Reloaded updates.
8
+
9
+ Keep custom QUADS translations in /wp-content/languages/quads/
10
+
11
+ You want to translate, help, or improve a translation?
12
+ Write: info@mashshare.net
13
+
14
+ ********************************************************
license.txt ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
+ 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
+
7
+ Everyone is permitted to copy and distribute verbatim copies
8
+ of this license document, but changing it is not allowed.
9
+
10
+ Preamble
11
+
12
+ The licenses for most software are designed to take away your
13
+ freedom to share and change it. By contrast, the GNU General Public
14
+ License is intended to guarantee your freedom to share and change free
15
+ software--to make sure the software is free for all its users. This
16
+ General Public License applies to most of the Free Software
17
+ Foundation's software and to any other program whose authors commit to
18
+ using it. (Some other Free Software Foundation software is covered by
19
+ the GNU Library General Public License instead.) You can apply it to
20
+ your programs, too.
21
+
22
+ When we speak of free software, we are referring to freedom, not
23
+ price. Our General Public Licenses are designed to make sure that you
24
+ have the freedom to distribute copies of free software (and charge for
25
+ this service if you wish), that you receive source code or can get it
26
+ if you want it, that you can change the software or use pieces of it
27
+ in new free programs; and that you know you can do these things.
28
+
29
+ To protect your rights, we need to make restrictions that forbid
30
+ anyone to deny you these rights or to ask you to surrender the rights.
31
+ These restrictions translate to certain responsibilities for you if you
32
+ distribute copies of the software, or if you modify it.
33
+
34
+ For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must give the recipients all the rights that
36
+ you have. You must make sure that they, too, receive or can get the
37
+ source code. And you must show them these terms so they know their
38
+ rights.
39
+
40
+ We protect your rights with two steps: (1) copyright the software, and
41
+ (2) offer you this license which gives you legal permission to copy,
42
+ distribute and/or modify the software.
43
+
44
+ Also, for each author's protection and ours, we want to make certain
45
+ that everyone understands that there is no warranty for this free
46
+ software. If the software is modified by someone else and passed on, we
47
+ want its recipients to know that what they have is not the original, so
48
+ that any problems introduced by others will not reflect on the original
49
+ authors' reputations.
50
+
51
+ Finally, any free program is threatened constantly by software
52
+ patents. We wish to avoid the danger that redistributors of a free
53
+ program will individually obtain patent licenses, in effect making the
54
+ program proprietary. To prevent this, we have made it clear that any
55
+ patent must be licensed for everyone's free use or not licensed at all.
56
+
57
+ The precise terms and conditions for copying, distribution and
58
+ modification follow.
59
+
60
+ GNU GENERAL PUBLIC LICENSE
61
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
+
63
+ 0. This License applies to any program or other work which contains
64
+ a notice placed by the copyright holder saying it may be distributed
65
+ under the terms of this General Public License. The "Program", below,
66
+ refers to any such program or work, and a "work based on the Program"
67
+ means either the Program or any derivative work under copyright law:
68
+ that is to say, a work containing the Program or a portion of it,
69
+ either verbatim or with modifications and/or translated into another
70
+ language. (Hereinafter, translation is included without limitation in
71
+ the term "modification".) Each licensee is addressed as "you".
72
+
73
+ Activities other than copying, distribution and modification are not
74
+ covered by this License; they are outside its scope. The act of
75
+ running the Program is not restricted, and the output from the Program
76
+ is covered only if its contents constitute a work based on the
77
+ Program (independent of having been made by running the Program).
78
+ Whether that is true depends on what the Program does.
79
+
80
+ 1. You may copy and distribute verbatim copies of the Program's
81
+ source code as you receive it, in any medium, provided that you
82
+ conspicuously and appropriately publish on each copy an appropriate
83
+ copyright notice and disclaimer of warranty; keep intact all the
84
+ notices that refer to this License and to the absence of any warranty;
85
+ and give any other recipients of the Program a copy of this License
86
+ along with the Program.
87
+
88
+ You may charge a fee for the physical act of transferring a copy, and
89
+ you may at your option offer warranty protection in exchange for a fee.
90
+
91
+ 2. You may modify your copy or copies of the Program or any portion
92
+ of it, thus forming a work based on the Program, and copy and
93
+ distribute such modifications or work under the terms of Section 1
94
+ above, provided that you also meet all of these conditions:
95
+
96
+ a) You must cause the modified files to carry prominent notices
97
+ stating that you changed the files and the date of any change.
98
+
99
+ b) You must cause any work that you distribute or publish, that in
100
+ whole or in part contains or is derived from the Program or any
101
+ part thereof, to be licensed as a whole at no charge to all third
102
+ parties under the terms of this License.
103
+
104
+ c) If the modified program normally reads commands interactively
105
+ when run, you must cause it, when started running for such
106
+ interactive use in the most ordinary way, to print or display an
107
+ announcement including an appropriate copyright notice and a
108
+ notice that there is no warranty (or else, saying that you provide
109
+ a warranty) and that users may redistribute the program under
110
+ these conditions, and telling the user how to view a copy of this
111
+ License. (Exception: if the Program itself is interactive but
112
+ does not normally print such an announcement, your work based on
113
+ the Program is not required to print an announcement.)
114
+
115
+ These requirements apply to the modified work as a whole. If
116
+ identifiable sections of that work are not derived from the Program,
117
+ and can be reasonably considered independent and separate works in
118
+ themselves, then this License, and its terms, do not apply to those
119
+ sections when you distribute them as separate works. But when you
120
+ distribute the same sections as part of a whole which is a work based
121
+ on the Program, the distribution of the whole must be on the terms of
122
+ this License, whose permissions for other licensees extend to the
123
+ entire whole, and thus to each and every part regardless of who wrote it.
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
+
quick-adsense-reloaded.php ADDED
@@ -0,0 +1,436 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Plugin Name: AdSense Integration WP QUADS
5
+ * Plugin URI: https://wordpress.org/plugins/quick-adsense-reloaded/
6
+ * Description: Insert Google AdSense or any Ads code into your website. A fork of Quick AdSense
7
+ * Author: Rene Hermenau, WP-Staging
8
+ * Author URI: https://wordpress.org/plugins/quick-adsense-reloaded/
9
+ * Version: 1.4.0
10
+ * Text Domain: quick-adsense-reloaded
11
+ * Domain Path: languages
12
+ * Credits: WP QUADS - Quick AdSense Reloaded is a fork of Quick AdSense
13
+ *
14
+ * WP QUADS is free software: you can redistribute it and/or modify
15
+ * it under the terms of the GNU General Public License as published by
16
+ * the Free Software Foundation, either version 2 of the License, or
17
+ * any later version.
18
+ *
19
+ * WP QUADS is distributed in the hope that it will be useful,
20
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22
+ * GNU General Public License for more details.
23
+ *
24
+ * You should have received a copy of the GNU General Public License
25
+ * along with plugin. If not, see <http://www.gnu.org/licenses/>.
26
+ *
27
+ * @package QUADS
28
+ * @category Core
29
+ * @author René Hermenau
30
+ * @version 0.9.0
31
+ */
32
+ // Exit if accessed directly
33
+ if( !defined( 'ABSPATH' ) )
34
+ exit;
35
+
36
+ // Plugin version
37
+ if( !defined( 'QUADS_VERSION' ) ) {
38
+ define( 'QUADS_VERSION', '1.4.0' );
39
+ }
40
+
41
+ // Plugin name
42
+ if( !defined( 'QUADS_NAME' ) ) {
43
+ define( 'QUADS_NAME', 'WP QUADS - Quick AdSense Reloaded' );
44
+ }
45
+
46
+ // Debug
47
+ if( !defined( 'QUADS_DEBUG' ) ) {
48
+ define( 'QUADS_DEBUG', false );
49
+ }
50
+
51
+ // Files that needs to be loaded early
52
+ if( !class_exists( 'QUADS_Utils' ) ) {
53
+ require dirname( __FILE__ ) . '/includes/quads-utils.php';
54
+ }
55
+
56
+ // Define some globals
57
+ $visibleContentAds = 0; // Amount of ads which are shown
58
+ $visibleShortcodeAds = 0; // Number of active ads which are shown via shortcodes
59
+ $visibleContentAdsGlobal = 0; // Number of active ads which are shown in the_content
60
+ $ad_count_custom = 0; // Number of active custom ads which are shown on the site
61
+ $ad_count_widget = 0; // Number of active ads in widgets
62
+ $AdsId = array(); // Array of active ad id's
63
+ $adWidgets = 10; // number of widgets
64
+ $numberAds = 10; // number of regular ads
65
+ $AdsWidName = 'AdsWidget%d (WP QUADS)';
66
+
67
+
68
+ if( !class_exists( 'QuickAdsenseReloaded' ) ) :
69
+
70
+ /**
71
+ * Main QuickAdsenseReloaded Class
72
+ *
73
+ * @since 1.0.0
74
+ */
75
+ final class QuickAdsenseReloaded {
76
+ /** Singleton ************************************************************ */
77
+
78
+ /**
79
+ * @var QuickAdsenseReloaded The one and only QuickAdsenseReloaded
80
+ * @since 1.0
81
+ */
82
+ private static $instance;
83
+
84
+ /**
85
+ * QUADS HTML Element Helper Object
86
+ *
87
+ * @var object
88
+ * @since 2.0.0
89
+ */
90
+ public $html;
91
+
92
+ /* QUADS LOGGER Class
93
+ *
94
+ */
95
+ public $logger;
96
+
97
+ /**
98
+ * Main QuickAdsenseReloaded Instance
99
+ *
100
+ * Insures that only one instance of QuickAdsenseReloaded exists in memory at any one
101
+ * time. Also prevents needing to define globals all over the place.
102
+ *
103
+ * @since 1.0
104
+ * @static
105
+ * @static var array $instance
106
+ * @uses QuickAdsenseReloaded::setup_constants() Setup the constants needed
107
+ * @uses QuickAdsenseReloaded::includes() Include the required files
108
+ * @uses QuickAdsenseReloaded::load_textdomain() load the language files
109
+ * @see QUADS()
110
+ * @return The one true QuickAdsenseReloaded
111
+ */
112
+ public static function instance() {
113
+ if( !isset( self::$instance ) && !( self::$instance instanceof QuickAdsenseReloaded ) ) {
114
+ self::$instance = new QuickAdsenseReloaded;
115
+ self::$instance->setup_constants();
116
+ self::$instance->includes();
117
+ self::$instance->load_textdomain();
118
+ self::$instance->load_hooks();
119
+ self::$instance->logger = new quadsLogger( "quick_adsense_log_" . date( "Y-m-d" ) . ".log", quadsLogger::INFO );
120
+ self::$instance->html = new QUADS_HTML_Elements();
121
+ }
122
+ return self::$instance;
123
+ }
124
+
125
+ /**
126
+ * Throw error on object clone
127
+ *
128
+ * The whole idea of the singleton design pattern is that there is a single
129
+ * object therefore, we don't want the object to be cloned.
130
+ *
131
+ * @since 1.0
132
+ * @access protected
133
+ * @return void
134
+ */
135
+ public function __clone() {
136
+ // Cloning instances of the class is forbidden
137
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'QUADS' ), '1.0' );
138
+ }
139
+
140
+ /**
141
+ * Disable unserializing of the class
142
+ *
143
+ * @since 1.0
144
+ * @access protected
145
+ * @return void
146
+ */
147
+ public function __wakeup() {
148
+ // Unserializing instances of the class is forbidden
149
+ _doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'QUADS' ), '1.0' );
150
+ }
151
+
152
+ /**
153
+ * Setup plugin constants
154
+ *
155
+ * @access private
156
+ * @since 1.0
157
+ * @return void
158
+ */
159
+ private function setup_constants() {
160
+ global $wpdb;
161
+
162
+ // Plugin Folder Path
163
+ if( !defined( 'QUADS_PLUGIN_DIR' ) ) {
164
+ define( 'QUADS_PLUGIN_DIR', plugin_dir_path( __FILE__ ) );
165
+ }
166
+
167
+ // Plugin Folder URL
168
+ if( !defined( 'QUADS_PLUGIN_URL' ) ) {
169
+ define( 'QUADS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
170
+ }
171
+
172
+ // Plugin Root File
173
+ if( !defined( 'QUADS_PLUGIN_FILE' ) ) {
174
+ define( 'QUADS_PLUGIN_FILE', __FILE__ );
175
+ }
176
+ }
177
+
178
+
179
+ /**
180
+ * Include required files
181
+ *
182
+ * @access private
183
+ * @since 1.0
184
+ * @return void
185
+ */
186
+ private function includes() {
187
+ global $quads_options;
188
+
189
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/settings/register-settings.php';
190
+ $quads_options = quads_get_settings();
191
+ require_once QUADS_PLUGIN_DIR . 'includes/conditionals.php';
192
+ require_once QUADS_PLUGIN_DIR . 'includes/post_types.php';
193
+ require_once QUADS_PLUGIN_DIR . 'includes/user_roles.php';
194
+ require_once QUADS_PLUGIN_DIR . 'includes/template-functions.php';
195
+ require_once QUADS_PLUGIN_DIR . 'includes/class-quads-license-handler.php';
196
+ require_once QUADS_PLUGIN_DIR . 'includes/logger.php';
197
+ require_once QUADS_PLUGIN_DIR . 'includes/class-quads-html-elements.php';
198
+ require_once QUADS_PLUGIN_DIR . 'includes/widgets.php';
199
+ require_once QUADS_PLUGIN_DIR . 'includes/shortcodes.php';
200
+ require_once QUADS_PLUGIN_DIR . 'includes/api.php';
201
+ require_once QUADS_PLUGIN_DIR . 'includes/render-ad-functions.php';
202
+ require_once QUADS_PLUGIN_DIR . 'includes/scripts.php';
203
+ require_once QUADS_PLUGIN_DIR . 'includes/automattic-amp-ad.php';
204
+ require_once QUADS_PLUGIN_DIR . 'includes/helper-functions.php';
205
+
206
+ if( is_admin() || ( defined( 'WP_CLI' ) && WP_CLI ) ) {
207
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/add-ons.php';
208
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/admin-actions.php';
209
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/admin-footer.php';
210
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/admin-pages.php';
211
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/plugins.php';
212
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/welcome.php';
213
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/settings/display-settings.php';
214
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/settings/contextual-help.php';
215
+ //require_once QUADS_PLUGIN_DIR . 'includes/install.php';
216
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/tools.php';
217
+ require_once QUADS_PLUGIN_DIR . 'includes/meta-boxes.php';
218
+ require_once QUADS_PLUGIN_DIR . 'includes/quicktags.php';
219
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/admin-notices.php';
220
+ require_once QUADS_PLUGIN_DIR . 'includes/admin/upgrades/upgrade-functions.php';
221
+ }
222
+ }
223
+
224
+ public function load_hooks() {
225
+ if( is_admin() && quads_is_plugins_page() ) {
226
+ add_filter( 'admin_footer', 'quads_add_deactivation_feedback_modal' );
227
+ }
228
+ }
229
+
230
+ /**
231
+ * Loads the plugin language files
232
+ *
233
+ * @access public
234
+ * @since 1.0
235
+ * @return void
236
+ */
237
+ public function load_textdomain() {
238
+ // Set filter for plugin's languages directory
239
+ $quads_lang_dir = dirname( plugin_basename( QUADS_PLUGIN_FILE ) ) . '/languages/';
240
+ $quads_lang_dir = apply_filters( 'quads_languages_directory', $quads_lang_dir );
241
+
242
+ // Traditional WordPress plugin locale filter
243
+ $locale = apply_filters( 'plugin_locale', get_locale(), 'quick-adsense-reloaded' );
244
+ $mofile = sprintf( '%1$s-%2$s.mo', 'quick-adsense-reloaded', $locale );
245
+
246
+ // Setup paths to current locale file
247
+ $mofile_local = $quads_lang_dir . $mofile;
248
+ $mofile_global = WP_LANG_DIR . '/quads/' . $mofile;
249
+ //echo $mofile_local;
250
+ if( file_exists( $mofile_global ) ) {
251
+ // Look in global /wp-content/languages/quads folder
252
+ load_textdomain( 'quick-adsense-reloaded', $mofile_global );
253
+ } elseif( file_exists( $mofile_local ) ) {
254
+ // Look in local /wp-content/plugins/quick-adsense-reloaded/languages/ folder
255
+ load_textdomain( 'quick-adsense-reloaded', $mofile_local );
256
+ } else {
257
+ // Load the default language files
258
+ load_plugin_textdomain( 'quick-adsense-reloaded', false, $quads_lang_dir );
259
+ }
260
+ }
261
+
262
+ /*
263
+ * Activation function fires when the plugin is activated.
264
+ * Checks first if multisite is enabled
265
+ * @since 1.0.0
266
+ *
267
+ */
268
+
269
+ public static function activation( $networkwide ) {
270
+ global $wpdb;
271
+
272
+ if( function_exists( 'is_multisite' ) && is_multisite() ) {
273
+ // check if it is a network activation - if so, run the activation function for each blog id
274
+ if( $networkwide ) {
275
+ $old_blog = $wpdb->blogid;
276
+ // Get all blog ids
277
+ $blogids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
278
+ foreach ( $blogids as $blog_id ) {
279
+ switch_to_blog( $blog_id );
280
+ QuickAdsenseReloaded::during_activation();
281
+ }
282
+ switch_to_blog( $old_blog );
283
+ return;
284
+ }
285
+ }
286
+ QuickAdsenseReloaded::during_activation();
287
+ }
288
+ /**
289
+ * Deactivation function fires when the plugin is deactivated.
290
+ */
291
+ public static function deactivation() {
292
+ // Hook to plugin uninstall.
293
+ //register_uninstall_hook( $this, array('Freemius', '_uninstall_plugin_hook') );
294
+ wp_die('uninstall');
295
+ }
296
+
297
+ /**
298
+ * This function is fired from the activation method.
299
+ *
300
+ * @since 2.1.1
301
+ * @access public
302
+ *
303
+ * @return void
304
+ */
305
+ public static function during_activation() {
306
+
307
+ // Add Upgraded From Option
308
+ $current_version = get_option( 'quads_version' );
309
+ if( $current_version ) {
310
+ update_option( 'quads_version_upgraded_from', $current_version );
311
+ } else {
312
+ // First time installation
313
+ $quads_options['post_types'] = array('post', 'page');
314
+ $quads_options['visibility']['AppHome'] = "1";
315
+ $quads_options['visibility']['AppCate'] = "1";
316
+ $quads_options['visibility']['AppArch'] = "1";
317
+ $quads_options['visibility']['AppTags'] = "1";
318
+
319
+ update_option('quads_settings', $quads_options);
320
+ }
321
+
322
+ // Update the current version
323
+ // Its done from the upgrade-functions.php routine
324
+ //update_option( 'quads_version', QUADS_VERSION );
325
+
326
+ // Add plugin installation date and variable for rating div
327
+ add_option( 'quads_install_date', date( 'Y-m-d h:i:s' ) );
328
+ add_option( 'quads_rating_div', 'no' );
329
+ add_option( 'quads_show_theme_notice', 'yes' );
330
+
331
+ // Add the transient to redirect (not for multisites)
332
+ set_transient( 'quads_activation_redirect', true, 3600 );
333
+ }
334
+
335
+ }
336
+
337
+ endif; // End if class_exists check
338
+
339
+ /**
340
+ * The main function responsible for returning the one true QuickAdsenseReloaded
341
+ * Instance to functions everywhere.
342
+ *
343
+ * Use this function like you would a global variable, except without needing
344
+ * to declare the global.
345
+ *
346
+ * Example: $QUADS = QUADS();
347
+ *
348
+ * @since 2.0.0
349
+ * @return object The one true QuickAdsenseReloaded Instance
350
+ */
351
+ //function QUADS() {
352
+ // return QuickAdsenseReloaded::instance();
353
+ //}
354
+ //
355
+ //// Get QUADS Running
356
+ //QUADS();
357
+
358
+ /**
359
+ * Populate the $quads global with an instance of the QuickAdsenseReloaded class and return it.
360
+ *
361
+ * @return $quads a global instance class of the QuickAdsenseReloaded class.
362
+ */
363
+ function quads_loaded() {
364
+
365
+ global $quads;
366
+
367
+ if( !is_null( $quads ) ) {
368
+ return $quads;
369
+ }
370
+
371
+ $quads_instance = new QuickAdsenseReloaded;
372
+ $quads = $quads_instance->instance();
373
+ return $quads;
374
+ }
375
+
376
+ add_action( 'plugins_loaded', 'quads_loaded' );
377
+
378
+ /**
379
+ * The activation hook is called outside of the singleton because WordPress doesn't
380
+ * register the call from within the class hence, needs to be called outside and the
381
+ * function also needs to be static.
382
+ */
383
+ register_activation_hook( __FILE__, array('QuickAdsenseReloaded', 'activation') );
384
+
385
+
386
+ /**
387
+ * The deactivation hook is called outside of the singleton because WordPress doesn't
388
+ * register the call from within the class hence, needs to be called outside and the
389
+ * function also needs to be static.
390
+ */
391
+ //register_deactivation_hook( __FILE__, array('QuickAdsenseReloaded', 'deactivation') );
392
+
393
+
394
+ /**
395
+ * Check if advanced settings are available
396
+ *
397
+ * @return boolean
398
+ */
399
+ //function quads_is_advanced() {
400
+ // include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
401
+ // //$plugin = 'wp-quads-pro/wp-quads-pro.php';
402
+ // $plugin = 'wp-quads-pro.php';
403
+ // //$plugin = plugin_dir_path( __FILE__ ) . basename( __FILE__ );
404
+ //
405
+ // if( is_plugin_active( $plugin ) ) {
406
+ // return true;
407
+ // }
408
+ //
409
+ // return false;
410
+ //}
411
+
412
+ function quads_is_advanced(){
413
+ if ( function_exists( 'quads_is_active_pro' )){
414
+ return quads_is_active_pro();
415
+ } else {
416
+ return quads_is_active_deprecated();
417
+ }
418
+ return false;
419
+ }
420
+ /**
421
+ * Check if wp quads pro is active and installed
422
+ *
423
+ * @deprecated since version 1.3.0
424
+ * @return boolean
425
+ */
426
+ function quads_is_active_deprecated(){
427
+
428
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
429
+ $plugin = 'wp-quads-pro/wp-quads-pro.php';
430
+
431
+ if( is_plugin_active( $plugin ) ) {
432
+ return true;
433
+ }
434
+
435
+ return false;
436
+ }
readme.txt ADDED
@@ -0,0 +1,358 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === AdSense Plugin WP QUADS ===
2
+
3
+ Author URL: https://profiles.wordpress.org/renehermi/
4
+ Plugin URL: https://wordpress.org/plugins/quick-adsense-reloaded/
5
+ Contributors: ReneHermi, WP-Staging
6
+ Donate link:
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+ Tags: adsense, ads, ad, google adsense, advertising, amp, ad injection, ad inserter, ad manager
10
+ Requires at least: 3.6+
11
+ Tested up to: 4.7
12
+ Stable tag: 1.4.0
13
+
14
+ Quick Adsense Reloaded! Quickest way to insert Google AdSense & other ads into your website. Google AdSense integration with Google AMP support
15
+
16
+ == Description ==
17
+
18
+ > #### WPQUADS - Quick AdSense Reloaded
19
+ > This free Google AdSense plugin is a fork of the discontinued Quick AdSense ads
20
+ > plugin with more than 100k installations. Its rewritten from scratch with a solid code
21
+ > base and will be maintained and updated to be compatible with all future WordPress versions<br />
22
+ > Found a issue? Open a ticket in the [support forum](https://wordpress.org/support/plugin/quick-adsense-reloaded/ "support forum").
23
+ >
24
+ > Support of the popular Click Fraud Monitor plugin <br />
25
+ > Visit the site: [clickfraud-monitoring.com](http://demo.clickfraud-monitoring.com/) <br />
26
+ >
27
+ > <strong>NEW: AMP SUPPORT WITH WP QUADS PRO </strong><br>
28
+ > - AMP support! Add AMP ads automatically to your site<br />
29
+ > - Use mobile optimized and responsive AdSense ads<br />
30
+ > - Disable AdSense ads on phone, tablet or desktop devices<br />
31
+ > - Define AdSense size for different devices<br />
32
+ >
33
+ > AMP feature requires [Automattic AMP plugin](http://wpquads.com/?utm_source=wp_org&utm_medium=plugin_page&utm_term=check_out_wp_quads&utm_campaign=wpquads) installed <br />
34
+ > Get WP QUADS PRO: [wpquads.com](http://wpquads.com/?utm_source=wp_org&utm_medium=plugin_page&utm_term=check_out_wp_quads&utm_campaign=wpquads) <br />
35
+
36
+ = Why a Quick AdSense fork? =
37
+
38
+ Quick Adsense is a great plugin and used by more than 100.000 websites.
39
+ Although is not under maintainance and development for more than 3 years by the original author it is still downloaded hundred times a day.
40
+ So i decided to continue the project to make sure the plugin will also work in future with new WordPress versions.
41
+
42
+ Deprecated functions removed, bugs fixed and new filters and hooks created to make this plugin extensible by third party developers!
43
+
44
+ <strong>We Guarantee: </strong><br>
45
+ No revenue sharing from your Google AdSense advertising income. We never show our ads on your website.<br>
46
+ We are an active and engaged member of the WordPress community and we are following strongly the WordPress Codex in terms of code quality and good behave.
47
+
48
+ = Main Features =
49
+
50
+ * Import all ads settings from Quick AdSense v. 1.9.2 and convert them into serialized options.
51
+ * Visibility conditions, show / hide ads based on post type and user roles (needs WP QUADS PRO)
52
+ * Quicktags of Quick Adsense are 100% compatible to Quick AdSense Reloaded
53
+ * No external script dependencies. All plugin code reside on your site.
54
+ * Dynamic AdSense positioning: Assign Google AdSense ads to the beginning, middle and end of post, assign ads after 'more' tag, before last paragraph, after certain paragraphs & assign Ads after certain images.
55
+ * Insert Google AdSense ads specifically or randomly anywhere within a post.
56
+ * Support any Ads code, not limited to Google Adsense ads only.
57
+ * Display up to a maximum of 10 Ads on a page. Google TOS allows publishers to place up to 3 Google Adsense for Content on a page. If you are using other ads, you may display up to 10 Ads.
58
+ * Support up to a maximum of 10 Ads codes on Sidebar Widgets.
59
+ * Support up to a maximum of 10 Ads codes for specific placement & randomization within a post.
60
+ * Insert Google AdSense ads on-the-fly, insert &lt;!--Ads1--&gt;, &lt;!--Ads2--&gt; ... , &lt;!--RndAds--&gt; to a post to accomplish this.
61
+ * Disable Ads on-the-fly, insert &lt;!--NoAds--&gt;, &lt;!--OffDef--&gt;, &lt;!--OffWidget--&gt;, &lt;!--OffBegin--&gt; ... and more to a post to accomplish this.
62
+ * The above quicktags can be inserted into a post easily via the additional Quicktag Buttons added to the HTML Edit Post SubPanel.
63
+ * Use shortcodes within ads (Suppport advertisements from other ad plugins for example Simple Ads Manager or AdRotate)
64
+
65
+ = Improvements to original Quick AdSense Ads plugin =
66
+
67
+ * Performance improvements
68
+ * Serialized storing of Ad options instead storing every single option as separate table entry all over
69
+ * Multi language support
70
+ * Remove of small coding issues like "unexpected output" message when plugin is activated on several sites
71
+ * Import / Export function makes plugin migrating to other sites easier. Copy your ads code to other sites.
72
+
73
+ = Safety improvements =
74
+
75
+ * Exit code if Quick AdSense plugin is not called by WordPress directly
76
+ * Better sanitizing of user input
77
+
78
+ = We Distance Ourself From =
79
+ These are known AdSense plugins which are removed from the WordPress repository because of non ethic behavior:
80
+
81
+ * AdSense Extreme
82
+ * AdSense Insert
83
+
84
+ Make sure to switch to WP QUADS or any other AdSense plugin if you are still using these plugins!
85
+
86
+ <h3>WP QUADS PRO:</h3>
87
+
88
+ * Support for responsive Google AdSense ads
89
+ * GUI improvements
90
+
91
+ Check out WP QUADS PRO: [wpquads.com](http://wpquads.com/?utm_source=wp_org&utm_medium=plugin_page&utm_term=check_out_wp_quads&utm_campaign=wpquads) <br />
92
+
93
+ Do you have suggestions for more features?
94
+
95
+ = High Performance =
96
+
97
+ Quick AdSense Reloaded is *coded well and developed for high performance*.
98
+ It loads only the code it needs at the moment of execution, making it small and fast and with a lot of hooks easy extensible by third party developers.
99
+
100
+ ** GitHub **
101
+ Follow the development and improve the plugin.
102
+ You find it on [GitHub](https://github.com/rene-hermenau/quick-adsense-reloaded/)
103
+
104
+
105
+ == Frequently Asked Questions ==
106
+
107
+ Post your question in the [support forum](https://wordpress.org/support/plugin/quick-adsense-reloaded)
108
+
109
+ == Installation ==
110
+
111
+ Recommended Installation:
112
+
113
+ 1. Go to YourWebsite->Plugins->Add New
114
+ 2. Search for "Quick Adsense reloaded" or "WP QUADS"
115
+ 3. Click "install Now"
116
+
117
+ Alternative Installation:
118
+
119
+ 1. [Download the plugin](https://downloads.wordpress.org/plugin/quick-adsense-reloaded.latest-stable.zip) , unzip and place it in your wp-content/plugins/ folder.
120
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
121
+
122
+ == Screenshots ==
123
+
124
+ 1. The Quick AdSense Settings page
125
+ 2. General Settings
126
+ 3. AdSense Widgets
127
+ 4. AdSense Options from the post editor
128
+
129
+
130
+ == Changelog ==
131
+
132
+
133
+ = 1.4.0 =
134
+ * New: Add poll when AdSense plugin is deactivated
135
+ * Fix: Responsive AdSense ads are not working if shortcode [quads] is used
136
+ * Fix: On first time WP QUADS AdSense plugin installation make sure that post types post and blog are activated
137
+ * Fix: On update installation make sure that post types post and blog are activated
138
+ * Fix: Notice Undefined index on first time installation
139
+ * Tweak: Remove mail address for support and link to our Google AdSense support ticket page
140
+
141
+
142
+ = 1.3.9 =
143
+ * Fix: Redirect after first time installation not working
144
+ * New: Support for tag visibility condition with WP QUADS 1.3.1
145
+ * New: Add a "Rate Later" option to the rating container
146
+ * Tweak: Rename toggle button to "Open All Ads"
147
+
148
+ = 1.3.8 =
149
+ * Fix: Remove "three dots" content on unused adverts spots
150
+ * Fix: Even empty ads are taken into account for random ads
151
+ * Fix: Visibility conditionals for widget ads are not used
152
+ * Fix: Old align settings are not imported from old plugin Quick AdSense
153
+
154
+ * New: Show/Hide ads on custom post types with WP QUADS PRO
155
+ * New: Hide adverts for specific custom user role with WP QUADS PRO
156
+
157
+ * Tweak: Do not show menu link to WP QUADS PRO plugin if its already installed
158
+
159
+ = 1.3.7 =
160
+ * Fix: Do not show ads on 404 error pages
161
+ * New: Allow use of other amp vendor codes with use of wp quads pro
162
+
163
+ = 1.3.6 =
164
+ * Fix: Do not show ads on search pages
165
+ * Fix: Change ad condition for Tablet viewport to 1024px
166
+ * New: Allow recursive use of shortcodes in ad codes
167
+
168
+ = 1.3.5 =
169
+ * New: Support for multiple margin values: top, right, bottom, left (Needs WP QUADS PRO min. version 1.2.7)
170
+ * Fix: Undefined adalign notice
171
+
172
+ = 1.3.4 =
173
+ * Fix: Meta Box Settings "Hide ads" are ignored. Error caused by code changes in 1.3.2
174
+
175
+ = 1.3.3 =
176
+ * Skip version
177
+
178
+ = 1.3.2 =
179
+ * New: Button for opening all ads for easier editing
180
+ * Fix: Plain Text / HTML as default mode
181
+ * Fix: Invalid argument supplied for foreach() message when using custom shortcodes in ad content
182
+
183
+ = 1.3.1 =
184
+ * Tweak: Cleaner graphical admin tabs
185
+
186
+ = 1.3.0 =
187
+ * Fix: Make sure existing adsense code is not changed after updating
188
+ * Fix: Missing quads-ad class in custom Ad spots
189
+ * Fix: Hide on (mobile, desktop, tablet) device rules not working for custom Ad spots
190
+ * Fix: WP QUADS PRO can not be detected if folder name is not default wp-content/plugins/wp-quads-pro
191
+ * Fix: Can not export settings without reloading page
192
+ * Tweak: Change description of load order
193
+
194
+ = 1.2.9 =
195
+ * New: AMP support with WP QUADS PRO and Automattic AMP plugin
196
+
197
+ = 1.2.8 =
198
+ * Fix: Can not parse responsive AdSense async code when its custom modified
199
+ * Fix: Use custom AdSense ads with modified css rules
200
+ * Fix: Do not change adsense default format
201
+
202
+ = 1.2.7 =
203
+ * New: Ignore Cloudflare Rocket Script Loader for AdSense generated code
204
+ * New: Settings are saved without page reload
205
+ * New: Basic Responsive Support for Ads including widget ads
206
+ * New: No more script security errors when saving settings
207
+ * New: Improved Graphical User Interface
208
+ * New: Another class name for ad container
209
+ * Tweak: Remove deprecated debug code
210
+ * Tweak: Better description what to do after creating widget adsense code
211
+ * Fix: Adsense ad label 'Advertisment' not shown
212
+ * Fix: Remove ad container completely when it is deactivated via WP QUADS PRO
213
+
214
+ = 1.2.6 =
215
+ * Fix: WP auto P tags breaks inline javascript
216
+ * New: Support for Custom Banner Sizes and AdSense Label in WP QUADS PRO
217
+ * New: Banner for click fraud monitor plugin in admin settings
218
+ * Tweak: UI improvements in admin settings
219
+
220
+ = 1.2.5 =
221
+ * New: New cleaner design for adsense admin dashboard
222
+
223
+ = 1.2.4 =
224
+ * Fix: Error warning when plugin is activated
225
+
226
+ = 1.2.3 =
227
+ * Fix: AdSense Custom Theme API integration is ignoring the new responsive ads when WP QUADS PRO plugin is installed
228
+ * New: Ad Background color white per default
229
+ * Tweak: clean up code
230
+
231
+ = 1.2.2 =
232
+ * Fix: Some AdSense setting are not stored
233
+
234
+ = 1.2.1 =
235
+ * Fix: Fatal Error on frontpage
236
+
237
+ = 1.2.0 =
238
+ * New: Create AdSense pro version with mobile support
239
+ * New: AdSense WP QUADS Pro Version with responsive adsense support
240
+
241
+ = 1.1.9 =
242
+ * Fix: Change rating urls
243
+
244
+ = 1.1.8 =
245
+ * New: Click Fraud Monitor integration
246
+
247
+ = 1.1.7 =
248
+ * New: Tested up to WP 4.6.0
249
+ * New: Allow shortcodes in adsense input fields
250
+ * New: Add css class quads-id1-10 for ad container
251
+
252
+ = 1.1.6 =
253
+ * Tweak: Plugin Title
254
+ * Fix: Show ads only when query is main query
255
+
256
+ = 1.1.5 =
257
+ * Fix: Max ad count sometimes not working as expected and ads are not shown and max count is not reached, though
258
+ * Fix: Link to widget section not working
259
+
260
+ = 1.1.4 =
261
+ * Fix: Undefined var $showall
262
+
263
+ = 1.1.3 =
264
+ * Fix: Import Screen is showing No such file or directory error notice
265
+ * New: Tested up to WP 4.5.2
266
+
267
+ = 1.1.2 =
268
+ * New: Specify plugin load priority
269
+
270
+ = 1.1.1 =
271
+ * Fix: fopen error message on import settings page when Quick AdSense ist not installed and inactive
272
+
273
+ = 1.1.0 =
274
+ * Fix: Rating container not always hiding after rating the plugin
275
+
276
+ = 1.0.9 =
277
+ * Tweak: Disable all AdSense ads on 404 pages (Google AdSense does not allow this.)
278
+ * New: A nice looking rating div for asking to rate this plugin. Can be deactivated with one click and will never appear again.
279
+
280
+ = 1.0.8 =
281
+ * Tweak: Default alignment is center
282
+
283
+ = 1.0.7 =
284
+ * Fix: Change shortcode description to echo do_shortcode('[quads id="4"]');
285
+
286
+ = 1.0.6 =
287
+ * Fix: Url to widget section leads to 127.0.0.1
288
+
289
+ = 1.0.5 =
290
+ * Fix: Check if Quick AdSense is installed is throwing error message when it is not installed.
291
+ * New: Show a <!--NoAds--> Quicktag button in the html editor. Necessary to hide ads on not defined post_types like woocommerce product pages
292
+ * Tweak: Tested up to WP 4.5
293
+ * Tweak: Change author name to Rene Hermenau
294
+
295
+ = 1.0.4 =
296
+ * Tweak: Clean up code and remove admin-notices.php
297
+ * Tweak: Add new class quads-locations for ads wrapper in content
298
+
299
+ = 1.0.3 =
300
+ * Fix: php 5.2 does not support anonymous function
301
+ * Tweak: Lower amount of tags in readme.txt
302
+
303
+ = 1.0.2 =
304
+ * Fix: undefined var notice if plugin is installed first time
305
+ * Fix: Hide AdsWidget option on front page is ignored
306
+
307
+ = 1.0.1 =
308
+ * Fix: Undefined variable notice if plugin is activated first time
309
+
310
+ = 1.0.0 =
311
+ * Tweak: Remove is_main_query() check
312
+
313
+
314
+ = 0.9.9 =
315
+ * New: API for easy integration of custom ad positions. See /includes/api.php for how to use custom ads positions in your theme
316
+ (Custom ad positions are calculated within max allowed ads setting)
317
+
318
+ = 0.9.8 =
319
+ * Fix: Still not fixed on all systems: Invalid argument supplied for foreach()
320
+ * Fix: Undefined index in widgets.php
321
+
322
+ = 0.9.7 =
323
+ * Fix: Invalid argument supplied for foreach()
324
+ * Fix: undefined var cusrnd
325
+
326
+ = 0.9.6 =
327
+ * New: Use new Meta Box on post and pages for disabling ads instead using quicktags
328
+ * New: Remove quicktags for disabling ads from editor (backward compatible)
329
+
330
+ = 0.9.5 =
331
+ * New: Rebirth - Change name to WP QUADS
332
+ * New: Modify official shortcodes to [quads]. Old shortcodes [quads_ad] are still supported
333
+
334
+ = 0.9.4 =
335
+ * New: Allow the use of shortcodes to integrate google adsense ads, e.g. [quad_ad id="1"] or echo do_shortcode('[[quad_ad id="1"]]'); in template files. Max ad setting will be used for shortcode embeded ads as well.
336
+ * Tweak: Cleaner GUI
337
+ * Tweak: Clean up code and remove deprecated ads code
338
+ * Fix: Stored setting for ad position 9 was not shown properly in option field.
339
+ * Fix: Quicktags not shown
340
+
341
+ = 0.9.3 =
342
+ * Fix: Alignment is ignored
343
+
344
+ = 0.9.2 =
345
+ * Fix: AdSense Widgets shown although setting "Hide Ads when user is logged in" is enabled
346
+ * Fix: Empty quads.min.js loaded on frontend
347
+ * Fix: AdSense Widgets not created correctly
348
+ * Fix: Google AdSense max ads value ignored for widgets
349
+ * Tweak: Removing of create_function() due to security reasons ( Dont be evil() )
350
+
351
+
352
+ = 0.9.1 =
353
+ * Hooray! Quick Adsense Reloaded is alive
354
+
355
+ == Upgrade Notice ==
356
+
357
+ = 1.3.1 =
358
+ 1.3.1 Smaller, Faster, Quicker, Better - WP QUADS<a href="https://wordpress.org/plugins/quick-adsense-reloaded/changelog/" style="color:white;text-decoration: underline;">Complete changelog! </a>
uninstall.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Uninstall Quick adsense reloaded
4
+ *
5
+ * @package quads
6
+ * @subpackage Uninstall
7
+ * @copyright Copyright (c) 2015, René Hermenau
8
+ * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9
+ * @since 1.0.0
10
+ */
11
+
12
+ // Exit if accessed directly
13
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) exit;
14
+
15
+
16
+ /**
17
+ * Get an option
18
+ *
19
+ * Looks to see if the specified setting exists, returns default if not
20
+ *
21
+ * @since 1.0.0
22
+ * @return mixed
23
+ */
24
+ function quads_get_option_uninstall( $key = '', $default = false ) {
25
+ $quads_options = get_option('quads_settings');
26
+ $value = ! empty( $quads_options[ $key ] ) ? $quads_options[ $key ] : $default;
27
+ $value = apply_filters( 'quads_get_option', $value, $key, $default );
28
+ return apply_filters( 'quads_get_option_' . $key, $value, $key, $default );
29
+ }
30
+
31
+ if( quads_get_option_uninstall( 'uninstall_on_delete' ) ) {
32
+ /** Delete all the Plugin Options */
33
+ delete_option( 'quads_settings' );
34
+ delete_option( 'quads_install_date');
35
+ delete_option( 'quads_rating_div');
36
+ delete_option( 'quads_version');
37
+ delete_option( 'quads_version_upgraded_from');
38
+ delete_option( 'quads_show_theme_notice');
39
+ delete_option( 'quads_show_update_notice');
40
+
41
+ /* Delete all post meta options */
42
+ delete_post_meta_by_key( 'quads_timestamp' );
43
+ delete_post_meta_by_key( 'quads_shares' );
44
+ delete_post_meta_by_key( 'quads_jsonshares' );
45
+
46
+ // Delete transients
47
+ delete_transient ('quads_check_theme');
48
+ delete_transient ('quads_activation_redirect');
49
+
50
+ }