Custom Product Tabs for WooCommerce - Version 1.6.11

Version Description

  • September 25th, 2019 =
  • Adding additional checks to post global before enqueueing assets.
Download this release

Release Info

Developer fmixell
Plugin Icon 128x128 Custom Product Tabs for WooCommerce
Version 1.6.11
Comparing to
See all releases

Code changes from version 1.6.10 to 1.6.11

LICENSE CHANGED
@@ -1,340 +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
-
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
+
admin/class.export.php CHANGED
@@ -1,33 +1,33 @@
1
- <?php
2
-
3
- /**
4
- * Class YIKES_Custom_Product_Tabs_Export.
5
- */
6
- class YIKES_Custom_Product_Tabs_Export {
7
-
8
- /**
9
- * Define our hooks.
10
- */
11
- public function __construct() {
12
- add_filter( 'woocommerce_product_export_meta_value', array( $this, 'prep_product_tabs_for_export' ), 10, 4 );
13
- }
14
-
15
- /**
16
- * Prep our tabs for an export.
17
- *
18
- * @param mixed $meta_value The meta value.
19
- * @param object $meta The meta field.
20
- * @param WC_Product $product Product being exported.
21
- * @param array $row Row data.
22
- */
23
- public function prep_product_tabs_for_export( $meta_value, $meta, $product, $row ) {
24
- if ( isset( $meta->key ) && $meta->key === 'yikes_woo_products_tabs' ) {
25
- if ( is_array( $meta_value ) ) {
26
- return serialize( $meta_value );
27
- }
28
- }
29
- return $meta_value;
30
- }
31
- }
32
-
33
- new YIKES_Custom_Product_Tabs_Export();
1
+ <?php
2
+
3
+ /**
4
+ * Class YIKES_Custom_Product_Tabs_Export.
5
+ */
6
+ class YIKES_Custom_Product_Tabs_Export {
7
+
8
+ /**
9
+ * Define our hooks.
10
+ */
11
+ public function __construct() {
12
+ add_filter( 'woocommerce_product_export_meta_value', array( $this, 'prep_product_tabs_for_export' ), 10, 4 );
13
+ }
14
+
15
+ /**
16
+ * Prep our tabs for an export.
17
+ *
18
+ * @param mixed $meta_value The meta value.
19
+ * @param object $meta The meta field.
20
+ * @param WC_Product $product Product being exported.
21
+ * @param array $row Row data.
22
+ */
23
+ public function prep_product_tabs_for_export( $meta_value, $meta, $product, $row ) {
24
+ if ( isset( $meta->key ) && $meta->key === 'yikes_woo_products_tabs' ) {
25
+ if ( is_array( $meta_value ) ) {
26
+ return serialize( $meta_value );
27
+ }
28
+ }
29
+ return $meta_value;
30
+ }
31
+ }
32
+
33
+ new YIKES_Custom_Product_Tabs_Export();
admin/class.import.php CHANGED
@@ -1,47 +1,47 @@
1
- <?php
2
-
3
- /**
4
- * Class YIKES_Custom_Product_Tabs_Import.
5
- */
6
- class YIKES_Custom_Product_Tabs_Import {
7
-
8
- /**
9
- * Define hooks.
10
- */
11
- public function __construct() {
12
- add_filter( 'woocommerce_product_importer_formatting_callbacks', array( $this, 'remove_wp_kses_posts_callback_from_import' ), 10, 2 );
13
- }
14
-
15
- /**
16
- * When importing our meta field via WooCommerce's native import, replace the wp_kses_post sanitization callback with trim().
17
- *
18
- * The wp_kses_post function gets ran on all meta and this breaks some serialized arrays.
19
- */
20
- public function remove_wp_kses_posts_callback_from_import( $callbacks, $importer ) {
21
-
22
- $meta_key = false;
23
-
24
- // Go through the file's keys and look for our meta field.
25
- if ( method_exists( $importer, 'get_mapped_keys' ) ) {
26
- foreach ( $importer->get_mapped_keys() as $key_number => $field_name ) {
27
- if ( $field_name === 'meta:yikes_woo_products_tabs' ) {
28
- $meta_key = $key_number;
29
- break;
30
- }
31
- }
32
- }
33
-
34
- // Set our meta field's callback to `trim()`.
35
- if ( $meta_key !== false ) {
36
- foreach ( $callbacks as $key => $callback ) {
37
- if ( $key === $meta_key ) {
38
- $callbacks[ $key ] = 'trim';
39
- }
40
- }
41
- }
42
-
43
- return $callbacks;
44
- }
45
- }
46
-
47
- new YIKES_Custom_Product_Tabs_Import();
1
+ <?php
2
+
3
+ /**
4
+ * Class YIKES_Custom_Product_Tabs_Import.
5
+ */
6
+ class YIKES_Custom_Product_Tabs_Import {
7
+
8
+ /**
9
+ * Define hooks.
10
+ */
11
+ public function __construct() {
12
+ add_filter( 'woocommerce_product_importer_formatting_callbacks', array( $this, 'remove_wp_kses_posts_callback_from_import' ), 10, 2 );
13
+ }
14
+
15
+ /**
16
+ * When importing our meta field via WooCommerce's native import, replace the wp_kses_post sanitization callback with trim().
17
+ *
18
+ * The wp_kses_post function gets ran on all meta and this breaks some serialized arrays.
19
+ */
20
+ public function remove_wp_kses_posts_callback_from_import( $callbacks, $importer ) {
21
+
22
+ $meta_key = false;
23
+
24
+ // Go through the file's keys and look for our meta field.
25
+ if ( method_exists( $importer, 'get_mapped_keys' ) ) {
26
+ foreach ( $importer->get_mapped_keys() as $key_number => $field_name ) {
27
+ if ( $field_name === 'meta:yikes_woo_products_tabs' ) {
28
+ $meta_key = $key_number;
29
+ break;
30
+ }
31
+ }
32
+ }
33
+
34
+ // Set our meta field's callback to `trim()`.
35
+ if ( $meta_key !== false ) {
36
+ foreach ( $callbacks as $key => $callback ) {
37
+ if ( $key === $meta_key ) {
38
+ $callbacks[ $key ] = 'trim';
39
+ }
40
+ }
41
+ }
42
+
43
+ return $callbacks;
44
+ }
45
+ }
46
+
47
+ new YIKES_Custom_Product_Tabs_Import();
admin/class.premium.php CHANGED
@@ -1,121 +1,121 @@
1
- <?php
2
-
3
- class YIKES_Custom_Product_Tabs_Premium {
4
-
5
- /**
6
- * Constructah >:^)
7
- */
8
- public function __construct() {
9
-
10
- // Add our custom settings page
11
- add_action( 'admin_menu', array( $this, 'register_premium_subpage' ), 30 );
12
-
13
- // Enqueue scripts & styles
14
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );
15
-
16
- // Display an ad for CPTPRO
17
- add_action( 'yikes-woo-saved-tabs-list-ad', array( $this, 'display_cptpro_ad' ), 10 );
18
- }
19
-
20
- /**
21
- * Enqueue our scripts and styes
22
- *
23
- * @param string | $page | The slug of the page we're currently on
24
- */
25
- public function enqueue_scripts( $page ) {
26
-
27
- if ( $page === 'custom-product-tabs_page_' . YIKES_Custom_Product_Tabs_Premium_Page ) {
28
-
29
- wp_enqueue_style ( 'lightslider-styles', YIKES_Custom_Product_Tabs_URI . 'slider/css/lightslider.min.css' );
30
- wp_enqueue_style ( 'repeatable-custom-tabs-styles', YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css' );
31
- wp_enqueue_script( 'lightslider-scripts', YIKES_Custom_Product_Tabs_URI . 'slider/js/lightslider.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
32
- wp_enqueue_script( 'premium-scripts', YIKES_Custom_Product_Tabs_URI . 'js/premium.min.js', array( 'lightslider-scripts' ), YIKES_Custom_Product_Tabs_Version );
33
- wp_enqueue_style ( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
34
- }
35
- }
36
-
37
- /**
38
- * Register our premium page
39
- */
40
- public function register_premium_subpage() {
41
-
42
- if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
43
- return;
44
- }
45
-
46
- // Add our custom settings page
47
- add_submenu_page(
48
- YIKES_Custom_Product_Tabs_Settings_Page, // Parent menu item slug
49
- __( 'Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Tab title name (HTML title)
50
- __( 'Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Menu page name
51
- apply_filters( 'yikes-woo-premium-capability', 'publish_products' ), // Capability required
52
- YIKES_Custom_Product_Tabs_Premium_Page, // Page slug (?page=slug-name)
53
- array( $this, 'premium_page' ) // Function to generate page
54
- );
55
- }
56
-
57
- /**
58
- * Include our settings page
59
- */
60
- public function premium_page() {
61
-
62
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/page.premium.php';
63
- }
64
-
65
- /**
66
- * Display an ad for CPTPRO on the saved tabs list and saved tabs single pages
67
- */
68
- public function display_cptpro_ad() {
69
-
70
- if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
71
- return;
72
- }
73
-
74
- ?>
75
- <div class="yikes-woo-all-about-us">
76
- <div class="postbox yikes-woo-review-us">
77
-
78
- <h3 class="yikes-woo-review-us-title">Show Us Some Love</h3>
79
- <div class="yikes-woo-review-us-body">
80
- <div class="yikes-woo-review-us yikes-woo-all-about-us-box" id="yikes-woo-review-us">
81
-
82
- <p><?php _e( 'Leave a review!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
83
- <p class="star-container">
84
- <a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/reviews/?rate=5#new-post" target="_blank">
85
- <span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span>
86
- </a>
87
- </p>
88
- </div>
89
-
90
- <div class="yikes-woo-all-about-us-separator"></div>
91
-
92
- <div class="yikes-woo-tweet-us yikes-woo-all-about-us-box" id="yikes-woo-tweet-us">
93
-
94
- <p><?php _e( 'Tweet about us!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
95
- <a class="twitter-share-button"
96
- href="https://twitter.com/intent/tweet?text=I use Custom Product Tabs for WooCommerce by @yikesinc to help sell products online. Awesome #WordPress #plugins &url=https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/"
97
- data-size="large">
98
- <?php _e( 'Tweet', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
99
- </div>
100
-
101
- <p class="yikes-woo-review-us-footer">This plugin made with <span class="dashicons dashicons-heart yikes-love"></span> by <a href="http://www.yikesinc.com" target="_blank" title="YIKES Inc.">YIKES Inc.</a></p>
102
- </div><!-- .yikes-woo-review-us-body -->
103
- </div>
104
-
105
- <div class="postbox yikes-woo-buy-us yikes-woo-all-about-us-box" id="yikes-woo-buy-us">
106
- <h3 class="yikes-woo-buy-us-title">Custom Product Tabs Pro</h3>
107
- <div class="yikes-woo-buy-us-body">
108
- <h4><?php _e( 'Check out Custom Product Tabs Pro!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h4>
109
- <p><?php _e( 'Create global tabs, add tabs to products based on categories or tags, add tab content to search results, and more!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
110
- <a class="button button-primary" href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">
111
- <?php _e( 'Custom Product Tabs Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
112
- </a>
113
- </div><!-- .yikes-woo-buy-us-body -->
114
- </div>
115
- </div>
116
- <?php
117
- }
118
-
119
- }
120
-
121
  new YIKES_Custom_Product_Tabs_Premium();
1
+ <?php
2
+
3
+ class YIKES_Custom_Product_Tabs_Premium {
4
+
5
+ /**
6
+ * Constructah >:^)
7
+ */
8
+ public function __construct() {
9
+
10
+ // Add our custom settings page
11
+ add_action( 'admin_menu', array( $this, 'register_premium_subpage' ), 30 );
12
+
13
+ // Enqueue scripts & styles
14
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );
15
+
16
+ // Display an ad for CPTPRO
17
+ add_action( 'yikes-woo-saved-tabs-list-ad', array( $this, 'display_cptpro_ad' ), 10 );
18
+ }
19
+
20
+ /**
21
+ * Enqueue our scripts and styes
22
+ *
23
+ * @param string | $page | The slug of the page we're currently on
24
+ */
25
+ public function enqueue_scripts( $page ) {
26
+
27
+ if ( $page === 'custom-product-tabs_page_' . YIKES_Custom_Product_Tabs_Premium_Page ) {
28
+
29
+ wp_enqueue_style ( 'lightslider-styles', YIKES_Custom_Product_Tabs_URI . 'slider/css/lightslider.min.css' );
30
+ wp_enqueue_style ( 'repeatable-custom-tabs-styles', YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css' );
31
+ wp_enqueue_script( 'lightslider-scripts', YIKES_Custom_Product_Tabs_URI . 'slider/js/lightslider.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
32
+ wp_enqueue_script( 'premium-scripts', YIKES_Custom_Product_Tabs_URI . 'js/premium.min.js', array( 'lightslider-scripts' ), YIKES_Custom_Product_Tabs_Version );
33
+ wp_enqueue_style ( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
34
+ }
35
+ }
36
+
37
+ /**
38
+ * Register our premium page
39
+ */
40
+ public function register_premium_subpage() {
41
+
42
+ if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
43
+ return;
44
+ }
45
+
46
+ // Add our custom settings page
47
+ add_submenu_page(
48
+ YIKES_Custom_Product_Tabs_Settings_Page, // Parent menu item slug
49
+ __( 'Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Tab title name (HTML title)
50
+ __( 'Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Menu page name
51
+ apply_filters( 'yikes-woo-premium-capability', 'publish_products' ), // Capability required
52
+ YIKES_Custom_Product_Tabs_Premium_Page, // Page slug (?page=slug-name)
53
+ array( $this, 'premium_page' ) // Function to generate page
54
+ );
55
+ }
56
+
57
+ /**
58
+ * Include our settings page
59
+ */
60
+ public function premium_page() {
61
+
62
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/page.premium.php';
63
+ }
64
+
65
+ /**
66
+ * Display an ad for CPTPRO on the saved tabs list and saved tabs single pages
67
+ */
68
+ public function display_cptpro_ad() {
69
+
70
+ if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
71
+ return;
72
+ }
73
+
74
+ ?>
75
+ <div class="yikes-woo-all-about-us">
76
+ <div class="postbox yikes-woo-review-us">
77
+
78
+ <h3 class="yikes-woo-review-us-title">Show Us Some Love</h3>
79
+ <div class="yikes-woo-review-us-body">
80
+ <div class="yikes-woo-review-us yikes-woo-all-about-us-box" id="yikes-woo-review-us">
81
+
82
+ <p><?php _e( 'Leave a review!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
83
+ <p class="star-container">
84
+ <a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs/reviews/?rate=5#new-post" target="_blank">
85
+ <span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span><span class="dashicons dashicons-star-filled"></span>
86
+ </a>
87
+ </p>
88
+ </div>
89
+
90
+ <div class="yikes-woo-all-about-us-separator"></div>
91
+
92
+ <div class="yikes-woo-tweet-us yikes-woo-all-about-us-box" id="yikes-woo-tweet-us">
93
+
94
+ <p><?php _e( 'Tweet about us!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
95
+ <a class="twitter-share-button"
96
+ href="https://twitter.com/intent/tweet?text=I use Custom Product Tabs for WooCommerce by @yikesinc to help sell products online. Awesome #WordPress #plugins &url=https://wordpress.org/plugins/yikes-inc-easy-custom-woocommerce-product-tabs/"
97
+ data-size="large">
98
+ <?php _e( 'Tweet', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
99
+ </div>
100
+
101
+ <p class="yikes-woo-review-us-footer">This plugin made with <span class="dashicons dashicons-heart yikes-love"></span> by <a href="http://www.yikesinc.com" target="_blank" title="YIKES Inc.">YIKES Inc.</a></p>
102
+ </div><!-- .yikes-woo-review-us-body -->
103
+ </div>
104
+
105
+ <div class="postbox yikes-woo-buy-us yikes-woo-all-about-us-box" id="yikes-woo-buy-us">
106
+ <h3 class="yikes-woo-buy-us-title">Custom Product Tabs Pro</h3>
107
+ <div class="yikes-woo-buy-us-body">
108
+ <h4><?php _e( 'Check out Custom Product Tabs Pro!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h4>
109
+ <p><?php _e( 'Create global tabs, add tabs to products based on categories or tags, add tab content to search results, and more!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
110
+ <a class="button button-primary" href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">
111
+ <?php _e( 'Custom Product Tabs Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
112
+ </a>
113
+ </div><!-- .yikes-woo-buy-us-body -->
114
+ </div>
115
+ </div>
116
+ <?php
117
+ }
118
+
119
+ }
120
+
121
  new YIKES_Custom_Product_Tabs_Premium();
admin/class.support.php CHANGED
@@ -1,111 +1,111 @@
1
- <?php
2
-
3
- class YIKES_Custom_Product_Tabs_Support {
4
-
5
- /**
6
- * Constructah >:^)
7
- */
8
- public function __construct() {
9
-
10
- // Add our custom settings page
11
- add_action( 'admin_menu', array( $this, 'register_support_subpage' ), 20 );
12
-
13
- // Enqueue scripts & styles
14
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );
15
-
16
- // Add our free support page HTML
17
- add_action( 'yikes-woo-support-page-free', array( $this, 'render_support_page' ), 100 );
18
- }
19
-
20
- /**
21
- * Enqueue our scripts and styes
22
- *
23
- * @param string | $page | The slug of the page we're currently on
24
- */
25
- public function enqueue_scripts( $page ) {
26
-
27
- if ( $page === 'custom-product-tabs_page_' . YIKES_Custom_Product_Tabs_Support_Page ) {
28
-
29
- wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
30
- }
31
- }
32
-
33
- /**
34
- * Register our settings page
35
- */
36
- public function register_support_subpage() {
37
-
38
- // Add our custom settings page
39
- add_submenu_page(
40
- YIKES_Custom_Product_Tabs_Settings_Page, // Parent menu item slug
41
- __( 'Support', YIKES_Custom_Product_Tabs_Settings_Page ), // Tab title name (HTML title)
42
- __( 'Support', YIKES_Custom_Product_Tabs_Settings_Page ), // Menu page name
43
- apply_filters( 'yikes-woo-support-capability', 'publish_products' ), // Capability required
44
- YIKES_Custom_Product_Tabs_Support_Page, // Page slug (?page=slug-name)
45
- array( $this, 'support_page' ) // Function to generate page
46
- );
47
- }
48
-
49
- /**
50
- * Include our settings page
51
- */
52
- public function support_page() {
53
-
54
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/page.support.php';
55
- }
56
-
57
- /**
58
- * Show our support page HTML
59
- */
60
- public function render_support_page() {
61
- if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
62
- return;
63
- }
64
- ?>
65
- <div class="cptpro-settings cptpro-settings-support-help-container">
66
- <p>
67
- <?php
68
- echo sprintf( __( 'Before submitting a support request, please visit our %1sKnowledge Base%2s where we have step-by-step guides and troubleshooting help.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
69
- '<a href="https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/" target="_blank">', '</a>' );
70
- ?>
71
- </p>
72
-
73
- <p>
74
- <?php
75
- echo sprintf( __( 'Custom Product Tabs Pro users qualify for premium support. Check out %1sCustom Product Tabs Pro%2s!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
76
- '<a href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">', '</a>' );
77
- ?>
78
- </p>
79
-
80
- <hr />
81
-
82
-
83
- <h1>
84
- <span class="dashicons dashicons-wordpress-alt"></span> <?php _e( 'WordPress.org Support Forums', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
85
- </h1>
86
-
87
- <p>
88
- <?php
89
- echo sprintf( __( 'If you need help with free Custom Product Tabs, please post questions to %1sour support forum on the WordPress Plugin Directory%2s. We aim to respond to support requests within a week.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
90
- '<a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">', '</a>' );
91
- ?>
92
- </p>
93
-
94
- <p>
95
- <a class="button button-primary" href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">
96
- <?php _e( 'Submit a Support Request', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
97
- </a>
98
- </p>
99
-
100
- <a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">
101
- <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/support-screenshot.png' ?>" />
102
- </a>
103
-
104
- </div>
105
- <?php
106
- }
107
-
108
-
109
- }
110
-
111
  new YIKES_Custom_Product_Tabs_Support();
1
+ <?php
2
+
3
+ class YIKES_Custom_Product_Tabs_Support {
4
+
5
+ /**
6
+ * Constructah >:^)
7
+ */
8
+ public function __construct() {
9
+
10
+ // Add our custom settings page
11
+ add_action( 'admin_menu', array( $this, 'register_support_subpage' ), 20 );
12
+
13
+ // Enqueue scripts & styles
14
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 10, 1 );
15
+
16
+ // Add our free support page HTML
17
+ add_action( 'yikes-woo-support-page-free', array( $this, 'render_support_page' ), 100 );
18
+ }
19
+
20
+ /**
21
+ * Enqueue our scripts and styes
22
+ *
23
+ * @param string | $page | The slug of the page we're currently on
24
+ */
25
+ public function enqueue_scripts( $page ) {
26
+
27
+ if ( $page === 'custom-product-tabs_page_' . YIKES_Custom_Product_Tabs_Support_Page ) {
28
+
29
+ wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Register our settings page
35
+ */
36
+ public function register_support_subpage() {
37
+
38
+ // Add our custom settings page
39
+ add_submenu_page(
40
+ YIKES_Custom_Product_Tabs_Settings_Page, // Parent menu item slug
41
+ __( 'Support', YIKES_Custom_Product_Tabs_Settings_Page ), // Tab title name (HTML title)
42
+ __( 'Support', YIKES_Custom_Product_Tabs_Settings_Page ), // Menu page name
43
+ apply_filters( 'yikes-woo-support-capability', 'publish_products' ), // Capability required
44
+ YIKES_Custom_Product_Tabs_Support_Page, // Page slug (?page=slug-name)
45
+ array( $this, 'support_page' ) // Function to generate page
46
+ );
47
+ }
48
+
49
+ /**
50
+ * Include our settings page
51
+ */
52
+ public function support_page() {
53
+
54
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/page.support.php';
55
+ }
56
+
57
+ /**
58
+ * Show our support page HTML
59
+ */
60
+ public function render_support_page() {
61
+ if ( defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ) {
62
+ return;
63
+ }
64
+ ?>
65
+ <div class="cptpro-settings cptpro-settings-support-help-container">
66
+ <p>
67
+ <?php
68
+ echo sprintf( __( 'Before submitting a support request, please visit our %1sKnowledge Base%2s where we have step-by-step guides and troubleshooting help.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
69
+ '<a href="https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/" target="_blank">', '</a>' );
70
+ ?>
71
+ </p>
72
+
73
+ <p>
74
+ <?php
75
+ echo sprintf( __( 'Custom Product Tabs Pro users qualify for premium support. Check out %1sCustom Product Tabs Pro%2s!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
76
+ '<a href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">', '</a>' );
77
+ ?>
78
+ </p>
79
+
80
+ <hr />
81
+
82
+
83
+ <h1>
84
+ <span class="dashicons dashicons-wordpress-alt"></span> <?php _e( 'WordPress.org Support Forums', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
85
+ </h1>
86
+
87
+ <p>
88
+ <?php
89
+ echo sprintf( __( 'If you need help with free Custom Product Tabs, please post questions to %1sour support forum on the WordPress Plugin Directory%2s. We aim to respond to support requests within a week.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
90
+ '<a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">', '</a>' );
91
+ ?>
92
+ </p>
93
+
94
+ <p>
95
+ <a class="button button-primary" href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">
96
+ <?php _e( 'Submit a Support Request', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
97
+ </a>
98
+ </p>
99
+
100
+ <a href="https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs#new-post" target="_blank">
101
+ <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/support-screenshot.png' ?>" />
102
+ </a>
103
+
104
+ </div>
105
+ <?php
106
+ }
107
+
108
+
109
+ }
110
+
111
  new YIKES_Custom_Product_Tabs_Support();
admin/class.yikes-woo-generate-html.php CHANGED
@@ -1,396 +1,396 @@
1
- <?php
2
-
3
- if ( ! class_exists( 'Yikes_Woo_Custom_Product_Tabs_HTML' ) ) {
4
- class Yikes_Woo_Custom_Product_Tabs_HTML {
5
-
6
- public function __construct() {
7
- // empty...
8
- }
9
-
10
- /**
11
- * Creates all of the HTML required for tabs on the product edit screen
12
- *
13
- * @since 1.5
14
- */
15
- public function generate_html() {
16
- global $post;
17
-
18
- // Pull the custom tab data out of the database
19
- $tab_data = maybe_unserialize( get_post_meta( $post->ID, 'yikes_woo_products_tabs', true ) );
20
- $tab_data = is_array( $tab_data ) ? $tab_data : array();
21
-
22
- // If we don't have tab data, we display things slightly differently
23
- $product_has_tabs = true;
24
- if ( empty( $tab_data ) ) {
25
- $product_has_tabs = false;
26
- }
27
-
28
- // Pull the saved array of reusable tabs
29
- $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
30
-
31
- // Display the custom tab panel
32
- echo '<div id="yikes_woocommerce_custom_product_tabs" class="panel wc-metaboxes-wrapper woocommerce_options_panel">';
33
- echo '<div class="options_group">';
34
-
35
- echo $this->display_yikes_how_to();
36
-
37
- if ( $product_has_tabs === true ) {
38
-
39
- // Loop through all the tabs and add all components
40
- $this->generate_tab_html( $tab_data, $reusable_tab_options_array, $post );
41
- }
42
-
43
- // Add duplicate container
44
- $this->generate_duplicate_html();
45
-
46
- // Add a Saved Tab // Add Another Tab
47
- echo $this->display_yikes_add_tabs_container( $product_has_tabs );
48
-
49
- // Hidden input field holding # of tabs
50
- echo $this->display_yikes_number_of_tabs( count( $tab_data ) );
51
-
52
- echo '</div>';
53
- echo '</div>';
54
-
55
- }
56
-
57
- /* Generate HTML Functions */
58
-
59
- /**
60
- * Generate the duplicate HTML block
61
- *
62
- * @since 1.5
63
- *
64
- */
65
- protected function generate_duplicate_html() {
66
-
67
- // duplicate_this_row content
68
- echo '<div id="duplicate_this_row">';
69
-
70
- // Tab title input field
71
- woocommerce_wp_text_input( array( 'id' => 'hidden_duplicator_row_title' , 'label' => __( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'description' => '', 'placeholder' => __( 'Custom Tab Title' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'class' => 'yikes_woo_tabs_title_field yikes_woo_tabs_title_field_duplicate' ) );
72
-
73
- // WYSIWYG Content field
74
- $this->display_woocommerce_wp_wysiwyg_input_duplicate();
75
-
76
- // Override Saved Tab checkbox & hidden input fields - Up & Down arrows && Remove Tab button (Duplicate)
77
- echo $this->display_yikes_button_holder_container_duplicate();
78
-
79
- echo '</div>';
80
- }
81
-
82
- /**
83
- * Generate the normal tab HTML block
84
- *
85
- * @since 1.5
86
- *
87
- * @param array | $tab_data | Array of tab data
88
- * @param array | $reusable_tab_options | Array of saved tab data
89
- * @param object| $post | The global $post object
90
- */
91
- protected function generate_tab_html( $tab_data, $reusable_tab_options, $post ) {
92
- $i = 1;
93
-
94
- // Set up the initial display, by looping
95
- foreach ( $tab_data as $tab ) {
96
-
97
- $reusable_tab_flag = false;
98
- $reusable_tab_id = '';
99
-
100
- // If $tab is in the array of reusable tabs, set flag
101
- if ( isset( $reusable_tab_options ) && isset( $reusable_tab_options[$post->ID] ) ) {
102
-
103
- foreach( $reusable_tab_options[$post->ID] as $id => $reusable_tab_data ) {
104
- if ( isset( $reusable_tab_data['tab_id'] ) && isset( $tab['id'] ) && $reusable_tab_data['tab_id'] === $tab['id'] ) {
105
- $reusable_tab_flag = true;
106
- $reusable_tab_id = $reusable_tab_data['reusable_tab_id'];
107
- }
108
- }
109
- }
110
-
111
- // Tab Title input field
112
- $this->display_woocommerce_wp_text_input( $i, $tab );
113
-
114
- // Tab content wysiwyg
115
- $this->display_woocommerce_wp_wysiwyg_input( $i, $tab );
116
-
117
- // Override Saved Tab checkbox & hidden input fields, Up & Down arrows, Remove Tab button
118
- echo $this->display_yikes_button_holder_container( $i, $reusable_tab_flag, $reusable_tab_id );
119
-
120
- // line separating tabs
121
- echo $this->display_yikes_tab_divider( $i, count( $tab_data ) );
122
-
123
- $i++;
124
- }
125
- }
126
-
127
- /**
128
- * Add how-to info HTML to page
129
- *
130
- * @since 1.5
131
- *
132
- * @return string HTML
133
- */
134
- protected function display_yikes_how_to() {
135
- $return_html = '';
136
- $return_html .= '<div class="yikes-woo-tabs-hidden-how-to-info">';
137
- $return_html .= '<p class="yikes_woo_how_to_info">' . __( "For help using Custom Tabs please visit our <a href='https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/' target='_blank'>Knowledge Base</a>" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</p>';
138
- $return_html .= '</div>';
139
- $return_html .= '<div id="yikes-woo-help-me-icon" class="dashicons dashicons-editor-help yikes-tabs-how-to-toggle" title="' . __( "Help Me!" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '"></div>';
140
-
141
- return $return_html;
142
- }
143
-
144
- /**
145
- * Add button holder container HTML to page
146
- *
147
- * @since 1.5
148
- *
149
- * @param int $i Counter for tab generating loop
150
- * @return string HTML
151
- */
152
- protected function display_yikes_button_holder_container( $i, $reusable_tab_flag, $reusable_tab_id ) {
153
- $return_html = '';
154
-
155
- $return_html .= '<section class="button-holder" alt="' . $i . '">';
156
-
157
- $return_html .= '<p class="yikes_wc_override_reusable_tab_container" id="_yikes_wc_override_reusable_tab_container_' . $i . '" ';
158
- if ( $reusable_tab_flag === true ) {
159
- $return_html .= ' data-reusable-tab="true">';
160
- } else {
161
- $return_html .= ' style="display: none;">';
162
- }
163
- $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_' . $i . '" data-tab-number="'. $i .'"';
164
- $return_html .= 'title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '">';
165
- $return_html .= '<label id="_yikes_wc_override_reusable_tab_label_' . $i . '" for="_yikes_wc_override_reusable_tab_' . $i . '" class="_yikes_wc_override_reusable_tab_label">';
166
- $return_html .= __( ' Override Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
167
- $return_html .= '</label>';
168
- $return_html .= '<input type="hidden" name="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action"';
169
- $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" value="none">';
170
- $return_html .= '<input type="hidden" name="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id"';
171
- $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" value="' . $reusable_tab_id . '">';
172
- $return_html .= '</p>';
173
-
174
- $return_html .= '<div class="yikes_wc_move_tab_container">';
175
- $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
176
- $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
177
- $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
178
- $return_html .= '</div>';
179
- $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab"><span class="dashicons dashicons-no-alt"></span>';
180
- $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
181
- $return_html .= '</a>';
182
- $return_html .= '</section>';
183
-
184
- return $return_html;
185
- }
186
-
187
- /**
188
- * Add tab divider HTML to page
189
- *
190
- * @since 1.5
191
- *
192
- * @param int $i Counter for tab generating loop
193
- * @param int $tab_count Total # of tabs
194
- * @return string HTML
195
- */
196
- protected function display_yikes_tab_divider( $i, $tab_count ) {
197
- $return_html = '';
198
- if ( $i != $tab_count ) {
199
- $return_html .= '<div class="yikes-woo-custom-tab-divider"></div>';
200
- }
201
-
202
- return $return_html;
203
- }
204
-
205
- /**
206
- * Call input field generation function and echo HTML to page
207
- *
208
- * @since 1.5
209
- *
210
- * @param int $i Counter for tab generating loop
211
- * @param array $tab Array of tab data
212
- */
213
- protected function display_woocommerce_wp_text_input( $i, $tab ) {
214
-
215
- woocommerce_wp_text_input( array( 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i , 'label' => __( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'description' => '', 'value' => $tab['title'] , 'placeholder' => __( 'Custom Tab Title' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'class' => 'yikes_woo_tabs_title_field') );
216
- }
217
-
218
- /**
219
- * Call wp_editor wrapped function and echo HTML to page
220
- *
221
- * @since 1.5
222
- *
223
- * @param int $i Counter for tab generating loop
224
- * @param array $tab Array of tab data
225
- */
226
- protected function display_woocommerce_wp_wysiwyg_input( $i, $tab ) {
227
- echo '<div class="form-field-tinymce _yikes_wc_custom_repeatable_product_tabs_tab_content_field _yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i . '_field">';
228
- $this->woocommerce_wp_wysiwyg_input( array(
229
- 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i ,
230
- 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
231
- 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
232
- 'value' => $tab['content'],
233
- 'style' => 'width:100%;min-height:10rem;',
234
- 'class' => 'yikes_woo_tabs_content_field',
235
- 'number' => $i
236
- ) );
237
- echo '</div>';
238
- }
239
-
240
- /* Hidden Duplicate HTML Section */
241
-
242
- /**
243
- * Add duplicate remove tab button HTML to page
244
- *
245
- * @since 1.5
246
- *
247
- * @return string HTML
248
- */
249
- protected function display_yikes_remove_tab_duplicate() {
250
- $return_html = '';
251
-
252
- $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
253
- $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
254
- $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
255
- $return_html .= '</a>';
256
-
257
- return $return_html;
258
- }
259
-
260
- /**
261
- * Call input field generation function and echo HTML to page
262
- *
263
- * @since 1.5
264
- *
265
- * @param array $tab Array of tab data
266
- */
267
- protected function display_woocommerce_wp_wysiwyg_input_duplicate() {
268
-
269
- $this->woocommerce_wp_textarea_input( array( 'id' => 'hidden_duplicator_row_content' , 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'style' => 'width:100%; min-height:10rem;' , 'class' => 'yikes_woo_tabs_content_field' ) );
270
- }
271
-
272
- /**
273
- * Add duplicate button holder container HTML to page
274
- *
275
- * @since 1.5
276
- *
277
- * @return string HTML
278
- */
279
- protected function display_yikes_button_holder_container_duplicate() {
280
- $return_html = '';
281
-
282
- $return_html .= '<section class="button-holder" alt="">';
283
- $return_html .= '<p class="yikes_wc_override_reusable_tab_container _yikes_wc_override_reusable_tab_container_duplicate" id="_yikes_wc_override_reusable_tab_container_duplicate" style="display: none;">';
284
- $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_duplicate" title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '" />';
285
- $return_html .= '<label class="_yikes_wc_override_reusable_tab_label_duplicate">' . __( 'Override Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</label>';
286
- $return_html .= '<input type="hidden" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action" id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action_duplicate" value="none">';
287
- $return_html .= '<input type="hidden" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id" id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_duplicate" value="">';
288
- $return_html .= '</p>';
289
- $return_html .= '<div class="yikes_wc_move_tab_container">';
290
- $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
291
- $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
292
- $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
293
- $return_html .= '</div>';
294
- $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
295
- $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
296
- $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
297
- $return_html .= '</a>';
298
- $return_html .= '</section>';
299
-
300
- return $return_html;
301
- }
302
-
303
- /**
304
- * Add hidden input field for number of tabs to page
305
- *
306
- * @since 1.5
307
- *
308
- * @return string HTML
309
- */
310
- protected function display_yikes_number_of_tabs( $tab_count ) {
311
- $return_html = '';
312
-
313
- $return_html .= '<input type="hidden" value="' . $tab_count . '" id="number_of_tabs" name="number_of_tabs" >';
314
-
315
- return $return_html;
316
- }
317
-
318
- /**
319
- * Add 'Add Another Tab' and 'Add a Saved Tab' buttons to page
320
- *
321
- * @since 1.5
322
- *
323
- * @param bool | $product_has_tabs | flag indicating whether the product has any defined tabs
324
- * @return string HTML
325
- */
326
- protected function display_yikes_add_tabs_container( $product_has_tabs ) {
327
- $return_html = '';
328
-
329
- // If we don't have any tabs, then add some classes
330
- $classes_to_add = ( $product_has_tabs === false ) ? '_yikes_wc_add_tab_center_new _yikes_wc_add_tab_center' : '';
331
-
332
- $return_html .= '<div class="add_tabs_container ' . $classes_to_add . '">';
333
- $return_html .= '<span id="yikes_woo_ajax_save_feedback"></span>';
334
- $return_html .= '<a href="#" class="button-secondary _yikes_wc_add_tabs" id="add_another_tab">';
335
- $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
336
- $return_html .= __( 'Add a Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
337
- $return_html .= '</a>';
338
- $return_html .= '<span class="yikes_wc_apply_reusable_tab_container">';
339
- $return_html .= '<span class="button-secondary _yikes_wc_apply_a_saved_tab _yikes_wc_add_tabs" id="_yikes_wc_apply_a_saved_tab">';
340
- $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
341
- $return_html .= __( 'Add a Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
342
- $return_html .= '</span>';
343
- $return_html .= '</span>';
344
- $return_html .= '<input name="save" class="button button-primary" id="yikes_woo_save_custom_tabs" value="Save Tabs" type="button">';
345
- $return_html .= '</div>';
346
-
347
- return $return_html;
348
- }
349
-
350
- /**
351
- * Generates a textarea field for hidden duplicate HTML block
352
- *
353
- * @param array $field Array of HTML field related values
354
- */
355
- private function woocommerce_wp_textarea_input( $field ) {
356
-
357
- if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
358
- if ( ! isset( $field['class'] ) ) $field['class'] = '';
359
- if ( ! isset( $field['value'] ) ) $field['value'] = '';
360
-
361
- echo '<p class="form-field-tinymce ' . $field['id'] . '_field"> <textarea class="' . $field['class'] . '" name="' . $field['id'] . '" id="' . $field['id'] . '" placeholder="' . $field['placeholder'] . '" rows="2" cols="20"' . (isset( $field['style'] ) ? ' style="' . $field['style'] . '"' : '') . '>' . $field['value'] . '</textarea> ';
362
-
363
- if ( isset( $field['description'] ) && $field['description'] ) {
364
- echo '<span class="description">' . $field['description'] . '</span>';
365
- }
366
-
367
- echo '</p>';
368
- }
369
-
370
- /**
371
- * Wrapper function for wp_editor
372
- *
373
- * @param array $field Array of HTML field related values
374
- */
375
- private function woocommerce_wp_wysiwyg_input( $field ) {
376
-
377
- if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
378
- if ( ! isset( $field['class'] ) ) $field['class'] = '';
379
- if ( ! isset( $field['value'] ) ) $field['value'] = '';
380
-
381
- $editor_settings = array(
382
- 'textarea_name' => $field['id']
383
- );
384
-
385
- wp_editor( $field['value'], $field['id'], $editor_settings );
386
-
387
- if ( isset( $field['description'] ) && $field['description'] ) {
388
- echo '<span class="description">' . $field['description'] . '</span>';
389
- }
390
- }
391
-
392
- /* END HTML Functions */
393
- }
394
- }
395
-
396
  ?>
1
+ <?php
2
+
3
+ if ( ! class_exists( 'Yikes_Woo_Custom_Product_Tabs_HTML' ) ) {
4
+ class Yikes_Woo_Custom_Product_Tabs_HTML {
5
+
6
+ public function __construct() {
7
+ // empty...
8
+ }
9
+
10
+ /**
11
+ * Creates all of the HTML required for tabs on the product edit screen
12
+ *
13
+ * @since 1.5
14
+ */
15
+ public function generate_html() {
16
+ global $post;
17
+
18
+ // Pull the custom tab data out of the database
19
+ $tab_data = maybe_unserialize( get_post_meta( $post->ID, 'yikes_woo_products_tabs', true ) );
20
+ $tab_data = is_array( $tab_data ) ? $tab_data : array();
21
+
22
+ // If we don't have tab data, we display things slightly differently
23
+ $product_has_tabs = true;
24
+ if ( empty( $tab_data ) ) {
25
+ $product_has_tabs = false;
26
+ }
27
+
28
+ // Pull the saved array of reusable tabs
29
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
30
+
31
+ // Display the custom tab panel
32
+ echo '<div id="yikes_woocommerce_custom_product_tabs" class="panel wc-metaboxes-wrapper woocommerce_options_panel">';
33
+ echo '<div class="options_group">';
34
+
35
+ echo $this->display_yikes_how_to();
36
+
37
+ if ( $product_has_tabs === true ) {
38
+
39
+ // Loop through all the tabs and add all components
40
+ $this->generate_tab_html( $tab_data, $reusable_tab_options_array, $post );
41
+ }
42
+
43
+ // Add duplicate container
44
+ $this->generate_duplicate_html();
45
+
46
+ // Add a Saved Tab // Add Another Tab
47
+ echo $this->display_yikes_add_tabs_container( $product_has_tabs );
48
+
49
+ // Hidden input field holding # of tabs
50
+ echo $this->display_yikes_number_of_tabs( count( $tab_data ) );
51
+
52
+ echo '</div>';
53
+ echo '</div>';
54
+
55
+ }
56
+
57
+ /* Generate HTML Functions */
58
+
59
+ /**
60
+ * Generate the duplicate HTML block
61
+ *
62
+ * @since 1.5
63
+ *
64
+ */
65
+ protected function generate_duplicate_html() {
66
+
67
+ // duplicate_this_row content
68
+ echo '<div id="duplicate_this_row">';
69
+
70
+ // Tab title input field
71
+ woocommerce_wp_text_input( array( 'id' => 'hidden_duplicator_row_title' , 'label' => __( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'description' => '', 'placeholder' => __( 'Custom Tab Title' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'class' => 'yikes_woo_tabs_title_field yikes_woo_tabs_title_field_duplicate' ) );
72
+
73
+ // WYSIWYG Content field
74
+ $this->display_woocommerce_wp_wysiwyg_input_duplicate();
75
+
76
+ // Override Saved Tab checkbox & hidden input fields - Up & Down arrows && Remove Tab button (Duplicate)
77
+ echo $this->display_yikes_button_holder_container_duplicate();
78
+
79
+ echo '</div>';
80
+ }
81
+
82
+ /**
83
+ * Generate the normal tab HTML block
84
+ *
85
+ * @since 1.5
86
+ *
87
+ * @param array | $tab_data | Array of tab data
88
+ * @param array | $reusable_tab_options | Array of saved tab data
89
+ * @param object| $post | The global $post object
90
+ */
91
+ protected function generate_tab_html( $tab_data, $reusable_tab_options, $post ) {
92
+ $i = 1;
93
+
94
+ // Set up the initial display, by looping
95
+ foreach ( $tab_data as $tab ) {
96
+
97
+ $reusable_tab_flag = false;
98
+ $reusable_tab_id = '';
99
+
100
+ // If $tab is in the array of reusable tabs, set flag
101
+ if ( isset( $reusable_tab_options ) && isset( $reusable_tab_options[$post->ID] ) ) {
102
+
103
+ foreach( $reusable_tab_options[$post->ID] as $id => $reusable_tab_data ) {
104
+ if ( isset( $reusable_tab_data['tab_id'] ) && isset( $tab['id'] ) && $reusable_tab_data['tab_id'] === $tab['id'] ) {
105
+ $reusable_tab_flag = true;
106
+ $reusable_tab_id = $reusable_tab_data['reusable_tab_id'];
107
+ }
108
+ }
109
+ }
110
+
111
+ // Tab Title input field
112
+ $this->display_woocommerce_wp_text_input( $i, $tab );
113
+
114
+ // Tab content wysiwyg
115
+ $this->display_woocommerce_wp_wysiwyg_input( $i, $tab );
116
+
117
+ // Override Saved Tab checkbox & hidden input fields, Up & Down arrows, Remove Tab button
118
+ echo $this->display_yikes_button_holder_container( $i, $reusable_tab_flag, $reusable_tab_id );
119
+
120
+ // line separating tabs
121
+ echo $this->display_yikes_tab_divider( $i, count( $tab_data ) );
122
+
123
+ $i++;
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Add how-to info HTML to page
129
+ *
130
+ * @since 1.5
131
+ *
132
+ * @return string HTML
133
+ */
134
+ protected function display_yikes_how_to() {
135
+ $return_html = '';
136
+ $return_html .= '<div class="yikes-woo-tabs-hidden-how-to-info">';
137
+ $return_html .= '<p class="yikes_woo_how_to_info">' . __( "For help using Custom Tabs please visit our <a href='https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/' target='_blank'>Knowledge Base</a>" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</p>';
138
+ $return_html .= '</div>';
139
+ $return_html .= '<div id="yikes-woo-help-me-icon" class="dashicons dashicons-editor-help yikes-tabs-how-to-toggle" title="' . __( "Help Me!" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '"></div>';
140
+
141
+ return $return_html;
142
+ }
143
+
144
+ /**
145
+ * Add button holder container HTML to page
146
+ *
147
+ * @since 1.5
148
+ *
149
+ * @param int $i Counter for tab generating loop
150
+ * @return string HTML
151
+ */
152
+ protected function display_yikes_button_holder_container( $i, $reusable_tab_flag, $reusable_tab_id ) {
153
+ $return_html = '';
154
+
155
+ $return_html .= '<section class="button-holder" alt="' . $i . '">';
156
+
157
+ $return_html .= '<p class="yikes_wc_override_reusable_tab_container" id="_yikes_wc_override_reusable_tab_container_' . $i . '" ';
158
+ if ( $reusable_tab_flag === true ) {
159
+ $return_html .= ' data-reusable-tab="true">';
160
+ } else {
161
+ $return_html .= ' style="display: none;">';
162
+ }
163
+ $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_' . $i . '" data-tab-number="'. $i .'"';
164
+ $return_html .= 'title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '">';
165
+ $return_html .= '<label id="_yikes_wc_override_reusable_tab_label_' . $i . '" for="_yikes_wc_override_reusable_tab_' . $i . '" class="_yikes_wc_override_reusable_tab_label">';
166
+ $return_html .= __( ' Override Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
167
+ $return_html .= '</label>';
168
+ $return_html .= '<input type="hidden" name="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action"';
169
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" value="none">';
170
+ $return_html .= '<input type="hidden" name="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id"';
171
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" value="' . $reusable_tab_id . '">';
172
+ $return_html .= '</p>';
173
+
174
+ $return_html .= '<div class="yikes_wc_move_tab_container">';
175
+ $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
176
+ $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
177
+ $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
178
+ $return_html .= '</div>';
179
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab"><span class="dashicons dashicons-no-alt"></span>';
180
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
181
+ $return_html .= '</a>';
182
+ $return_html .= '</section>';
183
+
184
+ return $return_html;
185
+ }
186
+
187
+ /**
188
+ * Add tab divider HTML to page
189
+ *
190
+ * @since 1.5
191
+ *
192
+ * @param int $i Counter for tab generating loop
193
+ * @param int $tab_count Total # of tabs
194
+ * @return string HTML
195
+ */
196
+ protected function display_yikes_tab_divider( $i, $tab_count ) {
197
+ $return_html = '';
198
+ if ( $i != $tab_count ) {
199
+ $return_html .= '<div class="yikes-woo-custom-tab-divider"></div>';
200
+ }
201
+
202
+ return $return_html;
203
+ }
204
+
205
+ /**
206
+ * Call input field generation function and echo HTML to page
207
+ *
208
+ * @since 1.5
209
+ *
210
+ * @param int $i Counter for tab generating loop
211
+ * @param array $tab Array of tab data
212
+ */
213
+ protected function display_woocommerce_wp_text_input( $i, $tab ) {
214
+
215
+ woocommerce_wp_text_input( array( 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i , 'label' => __( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'description' => '', 'value' => $tab['title'] , 'placeholder' => __( 'Custom Tab Title' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'class' => 'yikes_woo_tabs_title_field') );
216
+ }
217
+
218
+ /**
219
+ * Call wp_editor wrapped function and echo HTML to page
220
+ *
221
+ * @since 1.5
222
+ *
223
+ * @param int $i Counter for tab generating loop
224
+ * @param array $tab Array of tab data
225
+ */
226
+ protected function display_woocommerce_wp_wysiwyg_input( $i, $tab ) {
227
+ echo '<div class="form-field-tinymce _yikes_wc_custom_repeatable_product_tabs_tab_content_field _yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i . '_field">';
228
+ $this->woocommerce_wp_wysiwyg_input( array(
229
+ 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i ,
230
+ 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
231
+ 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
232
+ 'value' => $tab['content'],
233
+ 'style' => 'width:100%;min-height:10rem;',
234
+ 'class' => 'yikes_woo_tabs_content_field',
235
+ 'number' => $i
236
+ ) );
237
+ echo '</div>';
238
+ }
239
+
240
+ /* Hidden Duplicate HTML Section */
241
+
242
+ /**
243
+ * Add duplicate remove tab button HTML to page
244
+ *
245
+ * @since 1.5
246
+ *
247
+ * @return string HTML
248
+ */
249
+ protected function display_yikes_remove_tab_duplicate() {
250
+ $return_html = '';
251
+
252
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
253
+ $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
254
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
255
+ $return_html .= '</a>';
256
+
257
+ return $return_html;
258
+ }
259
+
260
+ /**
261
+ * Call input field generation function and echo HTML to page
262
+ *
263
+ * @since 1.5
264
+ *
265
+ * @param array $tab Array of tab data
266
+ */
267
+ protected function display_woocommerce_wp_wysiwyg_input_duplicate() {
268
+
269
+ $this->woocommerce_wp_textarea_input( array( 'id' => 'hidden_duplicator_row_content' , 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), 'style' => 'width:100%; min-height:10rem;' , 'class' => 'yikes_woo_tabs_content_field' ) );
270
+ }
271
+
272
+ /**
273
+ * Add duplicate button holder container HTML to page
274
+ *
275
+ * @since 1.5
276
+ *
277
+ * @return string HTML
278
+ */
279
+ protected function display_yikes_button_holder_container_duplicate() {
280
+ $return_html = '';
281
+
282
+ $return_html .= '<section class="button-holder" alt="">';
283
+ $return_html .= '<p class="yikes_wc_override_reusable_tab_container _yikes_wc_override_reusable_tab_container_duplicate" id="_yikes_wc_override_reusable_tab_container_duplicate" style="display: none;">';
284
+ $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_duplicate" title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '" />';
285
+ $return_html .= '<label class="_yikes_wc_override_reusable_tab_label_duplicate">' . __( 'Override Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</label>';
286
+ $return_html .= '<input type="hidden" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action" id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action_duplicate" value="none">';
287
+ $return_html .= '<input type="hidden" class="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id" id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_duplicate" value="">';
288
+ $return_html .= '</p>';
289
+ $return_html .= '<div class="yikes_wc_move_tab_container">';
290
+ $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
291
+ $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
292
+ $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
293
+ $return_html .= '</div>';
294
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
295
+ $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
296
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
297
+ $return_html .= '</a>';
298
+ $return_html .= '</section>';
299
+
300
+ return $return_html;
301
+ }
302
+
303
+ /**
304
+ * Add hidden input field for number of tabs to page
305
+ *
306
+ * @since 1.5
307
+ *
308
+ * @return string HTML
309
+ */
310
+ protected function display_yikes_number_of_tabs( $tab_count ) {
311
+ $return_html = '';
312
+
313
+ $return_html .= '<input type="hidden" value="' . $tab_count . '" id="number_of_tabs" name="number_of_tabs" >';
314
+
315
+ return $return_html;
316
+ }
317
+
318
+ /**
319
+ * Add 'Add Another Tab' and 'Add a Saved Tab' buttons to page
320
+ *
321
+ * @since 1.5
322
+ *
323
+ * @param bool | $product_has_tabs | flag indicating whether the product has any defined tabs
324
+ * @return string HTML
325
+ */
326
+ protected function display_yikes_add_tabs_container( $product_has_tabs ) {
327
+ $return_html = '';
328
+
329
+ // If we don't have any tabs, then add some classes
330
+ $classes_to_add = ( $product_has_tabs === false ) ? '_yikes_wc_add_tab_center_new _yikes_wc_add_tab_center' : '';
331
+
332
+ $return_html .= '<div class="add_tabs_container ' . $classes_to_add . '">';
333
+ $return_html .= '<span id="yikes_woo_ajax_save_feedback"></span>';
334
+ $return_html .= '<a href="#" class="button-secondary _yikes_wc_add_tabs" id="add_another_tab">';
335
+ $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
336
+ $return_html .= __( 'Add a Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
337
+ $return_html .= '</a>';
338
+ $return_html .= '<span class="yikes_wc_apply_reusable_tab_container">';
339
+ $return_html .= '<span class="button-secondary _yikes_wc_apply_a_saved_tab _yikes_wc_add_tabs" id="_yikes_wc_apply_a_saved_tab">';
340
+ $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
341
+ $return_html .= __( 'Add a Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
342
+ $return_html .= '</span>';
343
+ $return_html .= '</span>';
344
+ $return_html .= '<input name="save" class="button button-primary" id="yikes_woo_save_custom_tabs" value="Save Tabs" type="button">';
345
+ $return_html .= '</div>';
346
+
347
+ return $return_html;
348
+ }
349
+
350
+ /**
351
+ * Generates a textarea field for hidden duplicate HTML block
352
+ *
353
+ * @param array $field Array of HTML field related values
354
+ */
355
+ private function woocommerce_wp_textarea_input( $field ) {
356
+
357
+ if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
358
+ if ( ! isset( $field['class'] ) ) $field['class'] = '';
359
+ if ( ! isset( $field['value'] ) ) $field['value'] = '';
360
+
361
+ echo '<p class="form-field-tinymce ' . $field['id'] . '_field"> <textarea class="' . $field['class'] . '" name="' . $field['id'] . '" id="' . $field['id'] . '" placeholder="' . $field['placeholder'] . '" rows="2" cols="20"' . (isset( $field['style'] ) ? ' style="' . $field['style'] . '"' : '') . '>' . $field['value'] . '</textarea> ';
362
+
363
+ if ( isset( $field['description'] ) && $field['description'] ) {
364
+ echo '<span class="description">' . $field['description'] . '</span>';
365
+ }
366
+
367
+ echo '</p>';
368
+ }
369
+
370
+ /**
371
+ * Wrapper function for wp_editor
372
+ *
373
+ * @param array $field Array of HTML field related values
374
+ */
375
+ private function woocommerce_wp_wysiwyg_input( $field ) {
376
+
377
+ if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
378
+ if ( ! isset( $field['class'] ) ) $field['class'] = '';
379
+ if ( ! isset( $field['value'] ) ) $field['value'] = '';
380
+
381
+ $editor_settings = array(
382
+ 'textarea_name' => $field['id']
383
+ );
384
+
385
+ wp_editor( $field['value'], $field['id'], $editor_settings );
386
+
387
+ if ( isset( $field['description'] ) && $field['description'] ) {
388
+ echo '<span class="description">' . $field['description'] . '</span>';
389
+ }
390
+ }
391
+
392
+ /* END HTML Functions */
393
+ }
394
+ }
395
+
396
  ?>
admin/class.yikes-woo-saved-tabs.php CHANGED
@@ -1,627 +1,627 @@
1
- <?php
2
-
3
- if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Saved_Tabs' ) ) {
4
-
5
- class YIKES_Custom_Product_Tabs_Saved_Tabs {
6
-
7
- public function __construct() {
8
-
9
- // Add our custom settings page
10
- add_action( 'admin_menu', array( $this, 'yikes_woo_register_settings_page' ), 10 );
11
-
12
- // Define our options and filters
13
- add_action( 'admin_init', array( $this, 'init' ) );
14
- }
15
-
16
- public function init() {
17
-
18
- // Add our custom options for saved tabs
19
- add_option( 'yikes_woo_reusable_products_tabs', array() );
20
- add_option( 'yikes_woo_reusable_products_tabs_applied', array() );
21
-
22
- // Enqueue our JS / CSS files
23
- add_action( 'admin_enqueue_scripts' , array( $this , 'enqueue_scripts_and_styles' ), 10, 1 );
24
-
25
- // Define our AJAX calls
26
- add_action( 'wp_ajax_yikes_woo_save_tab_as_reusable', array( $this, 'yikes_woo_save_tab_as_reusable' ) );
27
- add_action( 'wp_ajax_yikes_woo_fetch_reusable_tabs', array( $this, 'yikes_woo_fetch_reusable_tabs' ) );
28
- add_action( 'wp_ajax_yikes_woo_fetch_reusable_tab', array( $this, 'yikes_woo_fetch_reusable_tab' ) );
29
- add_action( 'wp_ajax_yikes_woo_delete_reusable_tab_handler', array( $this, 'yikes_woo_delete_reusable_tab_handler' ) );
30
-
31
- // Duplicate any saved tabs when a product is duplicated
32
- add_filter( 'woocommerce_product_duplicate', array( $this, 'yikes_woo_dupe_saved_tabs_on_product_dupe' ), 11, 2 );
33
-
34
- // Delete any saved tabs when a product is deleted
35
- add_action( 'delete_post', array( $this, 'delete_saved_tabs_on_product_delete' ), 10, 1 );
36
- }
37
-
38
- /**
39
- * Enqueue our scripts and styles
40
- *
41
- * @param string | $hook | The current page
42
- */
43
- public function enqueue_scripts_and_styles( $hook ) {
44
-
45
- if ( $hook === 'toplevel_page_' . YIKES_Custom_Product_Tabs_Settings_Page ) {
46
-
47
- // JavaScript
48
- wp_enqueue_script ( 'repeatable-custom-tabs-settings', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-settings.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
49
- wp_localize_script( 'repeatable-custom-tabs-settings', 'repeatable_custom_tabs_settings', array(
50
- 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif-settings" />',
51
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
52
- 'tab_list_page_url' => esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) ),
53
- 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
54
- 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' ),
55
- 'is_cptpro_enabled' => defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ? true : false,
56
- ) );
57
-
58
- wp_enqueue_script ( 'repeatable-custom-tabs-shared', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-shared.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
59
- wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
60
- 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
61
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
62
- 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
63
- 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
64
- ) );
65
-
66
- // Twitter script for our Tweet Us button
67
- wp_enqueue_script( 'twitter-button', YIKES_Custom_Product_Tabs_URI . 'js/twitter-embed.js', null, YIKES_Custom_Product_Tabs_Version );
68
-
69
- // CSS
70
- wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
71
- }
72
-
73
- }
74
-
75
- /* AJAX Functions */
76
-
77
- /**
78
- * [AJAX] Save a tab as reusable
79
- *
80
- * @since 1.5
81
- *
82
- * @param string | $_POST['tab_title'] | Tab title to save
83
- * @param string | $_POST['tab_content'] | Tab content to save
84
- * @param string | $_POST['tab_id'] | Optional. Tab ID we're updating
85
- * @param string | $_POST['tab_name'] | Tab name to save
86
- * @param array | $_POST['taxonomies'] | Optional. Array of taxonomies.
87
- *
88
- * @return string | JSON response
89
- */
90
- public function yikes_woo_save_tab_as_reusable() {
91
-
92
- // Verify the nonce
93
- if ( ! check_ajax_referer( 'yikes_woo_save_tab_as_reusable_nonce', 'security_nonce', false ) ) {
94
- wp_send_json_error();
95
- }
96
-
97
- // Define it now, because we may use this later...
98
- $return_redirect_url = '';
99
-
100
- // Get our $_POST vars
101
- if ( isset( $_POST['tab_title'] ) && ! empty( $_POST['tab_title'] ) ) {
102
- $tab_title = stripslashes( $_POST['tab_title'] );
103
- $tab_string_id = urldecode( sanitize_title( $tab_title ) );
104
- } else {
105
- wp_send_json_error( array( 'reason' => 'no tab title', 'message' => 'Please fill out the tab title before saving.' ) );
106
- }
107
-
108
- $tab_content = isset( $_POST['tab_content'] ) && ! empty( $_POST['tab_content'] ) ? $_POST['tab_content'] : '';
109
- $tab_id = isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ? $_POST['tab_id'] : '';
110
- $tab_name = isset( $_POST['tab_name'] ) ? $_POST['tab_name'] : '';
111
- $global_tab = isset( $_POST['global_tab'] ) && $_POST['global_tab'] === 'true' ? true : false;
112
-
113
- // Remove taxonomies if we're using a global tab
114
- $taxonomies = isset( $_POST['taxonomies'] ) && ! empty( $_POST['taxonomies'] ) && $global_tab === false ? $_POST['taxonomies'] : array();
115
-
116
- // Get our saved tabs array
117
- $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
118
-
119
- // If the saved tabs array is empty, create a new array and save it (first time we've done this)
120
- if ( empty( $yikes_custom_tab_data ) ) {
121
- $yikes_custom_tab_options_array = array();
122
- $new_tab = array(
123
- 'tab_title' => $tab_title,
124
- 'tab_name' => $tab_name,
125
- 'tab_content' => $tab_content,
126
- 'tab_id' => 1,
127
- 'taxonomies' => $taxonomies,
128
- 'tab_slug' => $tab_string_id,
129
- 'global_tab' => $global_tab,
130
- );
131
-
132
- $yikes_custom_tab_options_array[1] = $new_tab;
133
-
134
- do_action( 'yikes-woo-handle-tab-save', $new_tab, 'new' );
135
-
136
- update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_options_array );
137
-
138
- // Return redirect URL
139
- $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => 1 ), admin_url() ) );
140
-
141
- // Send response
142
- wp_send_json_success( array( 'tab_id' => 1, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
143
- } else {
144
-
145
- // this is a new tab and we need to create a unique ID
146
- if ( $tab_id === 'new' ) {
147
-
148
- // Get the max ID we have saved
149
- foreach ( $yikes_custom_tab_data as $tab_data ) {
150
- if ( ! isset( $highest_tab_id ) ) {
151
- $highest_tab_id = $tab_data['tab_id'];
152
- } else {
153
- if ( $tab_data['tab_id'] > $highest_tab_id ) {
154
- $highest_tab_id = $tab_data['tab_id'];
155
- }
156
- }
157
- }
158
-
159
- // Add 1 to the max ID
160
- $new_tab_id = (int) $highest_tab_id + 1;
161
-
162
- $new_tab = array(
163
- 'tab_title' => $tab_title,
164
- 'tab_name' => $tab_name,
165
- 'tab_content' => $tab_content,
166
- 'tab_id' => $new_tab_id,
167
- 'taxonomies' => $taxonomies,
168
- 'tab_slug' => $tab_string_id,
169
- 'global_tab' => $global_tab,
170
- );
171
-
172
- $yikes_custom_tab_data[$new_tab_id] = $new_tab;
173
-
174
- do_action( 'yikes-woo-handle-tab-save', $new_tab, 'new' );
175
-
176
- update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
177
-
178
- // Return redirect URL
179
- $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => $new_tab_id ), admin_url() ) );
180
-
181
- // Send response
182
- wp_send_json_success( array( 'tab_id' => $new_tab_id, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
183
-
184
- } else {
185
-
186
- // This is an existing tab, so just update it
187
- $saved_tab = array(
188
- 'tab_title' => $tab_title,
189
- 'tab_name' => $tab_name,
190
- 'tab_content' => $tab_content,
191
- 'tab_id' => $tab_id,
192
- 'taxonomies' => $taxonomies,
193
- 'tab_slug' => $tab_string_id,
194
- 'global_tab' => $global_tab,
195
- );
196
-
197
- $yikes_custom_tab_data[$tab_id] = $saved_tab;
198
-
199
- do_action( 'yikes-woo-handle-tab-save', $saved_tab, 'existing' );
200
-
201
- update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
202
-
203
- // Now apply this updated tab's data to custom product tabs that use it
204
-
205
- // Get the array of applied product tabs
206
- $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
207
-
208
- // Flag so we know we found a post and we should update it
209
- $update_post_meta_flag = false;
210
-
211
- // Flag so we know we have to update the yikes_woo_reusable_products_tabs_applied
212
- $update_applied_products_array = false;
213
-
214
- foreach( $reusable_tab_options_array as $post_id => $reusable_tab_data ) {
215
-
216
- // Fetch the relevant postmeta field
217
- $custom_tab_data = maybe_unserialize( get_post_meta( $post_id, 'yikes_woo_products_tabs', true ) );
218
-
219
- // If we don't have custom tab data then continue
220
- if ( empty( $custom_tab_data ) ) {
221
- continue;
222
- }
223
-
224
- // Loop through $custom_tab_data and find the custom tab that was just updated
225
- foreach( $custom_tab_data as $index => $tab ) {
226
- if ( isset( $reusable_tab_data[ $tab_id ] ) && $tab['id'] === $reusable_tab_data[ $tab_id ]['tab_id'] ) {
227
- $custom_tab_data[$index]['title'] = $tab_title;
228
- $custom_tab_data[$index]['name'] = $tab_name;
229
- $custom_tab_data[$index]['content'] = $tab_content;
230
- $custom_tab_data[$index]['id'] = $tab_string_id;
231
-
232
- // We may need to update the tab_string_id too
233
- if ( $tab_string_id !== $tab['id'] ) {
234
- $reusable_tab_options_array[$post_id][$tab_id]['tab_id'] = $tab_string_id;
235
- $update_applied_products_array = true;
236
- }
237
- $update_post_meta_flag = true;
238
- }
239
- }
240
-
241
- // If we updated a tab, save it
242
- if ( $update_post_meta_flag === true ) {
243
- update_post_meta( $post_id, 'yikes_woo_products_tabs', $custom_tab_data );
244
- }
245
- }
246
-
247
- // If we updated the tab_string_id in the yikes_woo_reusable_products_tabs_applied array, save it
248
- if ( $update_applied_products_array === true ) {
249
- update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array);
250
- }
251
- }
252
- }
253
-
254
- wp_send_json_success( array( 'redirect' => false ) );
255
- }
256
-
257
- /**
258
- * [AJAX] Fetch a single reusable
259
- *
260
- * @since 1.5
261
- *
262
- * @return object success w/ tab data || failure w/ message
263
- */
264
- public function yikes_woo_fetch_reusable_tab() {
265
-
266
- // Verify the nonce
267
- if ( ! check_ajax_referer( 'yikes_woo_fetch_reusable_tab_nonce', 'security_nonce', false ) ) {
268
- wp_send_json_error();
269
- }
270
-
271
- $tab_id = isset( $_POST['tab_id'] ) ? filter_var( $_POST['tab_id'], FILTER_SANITIZE_NUMBER_INT ) : '';
272
-
273
- // Get the array of saved tabs
274
- $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
275
-
276
- $tab = isset( $saved_tabs[$tab_id] ) ? $saved_tabs[$tab_id] : false;
277
-
278
- if ( $tab !== false ) {
279
-
280
- $tab['tab_content'] = stripslashes( $tab['tab_content'] );
281
-
282
- wp_send_json_success( $tab );
283
- } else {
284
- wp_send_json_success( array( 'message' => __( 'Could not find the tab. Please try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ) );
285
- }
286
-
287
- // If we get this far, send error
288
- wp_send_json_error( array( 'message' => __( 'Uh oh. Something went wrong.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ) );
289
- }
290
-
291
- /**
292
- * [AJAX] Fetch all reusable tabs
293
- *
294
- * @since 1.5
295
- *
296
- * @return object success w/ saved_tabs || failure w/ message
297
- */
298
- public function yikes_woo_fetch_reusable_tabs() {
299
-
300
- // Verify the nonce
301
- if ( ! check_ajax_referer( 'yikes_woo_fetch_reusable_tabs_nonce', 'security_nonce', false ) ) {
302
- wp_send_json_error();
303
- }
304
-
305
- // Get the array of saved tabs
306
- $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
307
-
308
- $fetch_tab_content = isset( $_POST['fetch_tab_content'] ) ? filter_var( $_POST['fetch_tab_content'], FILTER_VALIDATE_BOOLEAN ) : false;
309
-
310
- // We don't need to pass the content back, and it could be a LOT, so let's just remove it
311
- if ( $fetch_tab_content === false && ! empty( $saved_tabs ) ) {
312
- foreach( $saved_tabs as $key => $tab ) {
313
- unset( $saved_tabs[$key]['tab_content'] );
314
- }
315
- }
316
-
317
- if ( ! empty( $saved_tabs ) ) {
318
- wp_send_json_success( json_encode( $saved_tabs ) );
319
- } else {
320
- wp_send_json_success( array( 'message' => 'No saved tabs were found.' ) );
321
- }
322
-
323
- // If we get this far, send error
324
- wp_send_json_error( array( 'message' => 'Uh oh. Something went wrong.' ) );
325
- }
326
-
327
- /**
328
- * [AJAX] Delete a reusable tab
329
- *
330
- * @since 1.5
331
- *
332
- * @param string $_POST['tab_id']
333
- * @return object success w/ saved_tabs || failure w/ message
334
- */
335
- public function yikes_woo_delete_reusable_tab_handler() {
336
-
337
- // Verify the nonce
338
- if ( ! check_ajax_referer( 'yikes_woo_delete_reusable_tab_nonce', 'security_nonce', false ) ) {
339
- wp_send_json_error();
340
- }
341
-
342
- // Get our tab_id
343
- if ( isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ) {
344
-
345
- $tab_ids = $_POST['tab_id'];
346
-
347
- // if $tab_ids isn't an array, turn it into one
348
- if ( ! is_array( $tab_ids ) ) {
349
- $tab_ids = array( $tab_ids );
350
- }
351
-
352
- // Set this up before we use it
353
- $return_vars = array();
354
-
355
- foreach( $tab_ids as $tab_id ) {
356
-
357
- // Delete the tab, store the return values in $return_vars
358
- $return_vars = $this->yikes_woo_delete_reusable_tab( $tab_id );
359
-
360
- // Make sure $return_vars is what we think it is, and check if our delete failed
361
- if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === false ) {
362
-
363
- // If something failed, let's return
364
- wp_send_json_error( $return_vars );
365
- }
366
- }
367
- } else {
368
-
369
- // Fail if we don't have a tab_id
370
- wp_send_json_error( array( 'reason' => 'no tab id' ) );
371
- }
372
-
373
- // Make sure $return_vars is what we think it is, and check if our delete was successful
374
- if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === true ) {
375
-
376
- // If nothing failed, let's return
377
- wp_send_json_success( $return_vars );
378
- }
379
-
380
- // We shouldn't have gotten this far, but if we did let's return failure
381
- wp_send_json_error();
382
- }
383
-
384
- /* End AJAX Functions */
385
-
386
- /* AJAX Helper Functions */
387
-
388
- /**
389
- * Delete a saved tab from the options array and delete the tab from the product's tabs array
390
- *
391
- * @since 1.5
392
- *
393
- * @param int | $tab_id | unique identifier of a tab
394
- * @return array | $response | array of data signifying success, message, reason, and other needed data
395
- */
396
- protected function yikes_woo_delete_reusable_tab( $tab_id ) {
397
-
398
- // The following code will remove the tab from our array of saved tabs
399
-
400
- // Fetch all saved tabs
401
- $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
402
-
403
- // Check some stuff, then remove the tab from our array of saved tabs
404
- if ( ! empty( $saved_tabs ) ) {
405
- if ( isset( $saved_tabs[$tab_id] ) ) {
406
- unset( $saved_tabs[$tab_id] );
407
- update_option( 'yikes_woo_reusable_products_tabs', $saved_tabs );
408
- } else {
409
- $response = array(
410
- 'success' => false,
411
- 'tab_id' => $tab_id,
412
- 'message' => 'No saved tab with id ' . $tab_id . ' found!',
413
- 'reason' => 'no saved tab found'
414
- );
415
- return $response;
416
- }
417
- } else {
418
- $response = array(
419
- 'success' => false,
420
- 'tab_id' => $tab_id,
421
- 'message' => 'No saved tabs found!',
422
- 'reason' => 'no saved tabs found'
423
- );
424
- return $response;
425
- }
426
-
427
- // The following code will remove the tab from our array of applied tabs and postmeta
428
-
429
- // Fetch all applied tabs
430
- $applied_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
431
-
432
- // Set a flag so we know if we need to update the database
433
- $unset_applied_tabs_flag = false;
434
-
435
- if ( ! empty( $applied_tabs ) ) {
436
-
437
- // Run through all the applied tabs and remove the ones with this ID
438
- foreach( $applied_tabs as $post_id => $applied_tabs_array ) {
439
-
440
- // If this ID is set, unset the array
441
- if ( isset( $applied_tabs_array[$tab_id] ) ) {
442
-
443
- // Now we also need to remove this entry from our postmeta
444
- $post_tabs = maybe_unserialize( get_post_meta( $post_id, 'yikes_woo_products_tabs', true ) );
445
-
446
- // Make sure it exists
447
- if ( ! empty( $post_tabs ) ) {
448
- foreach ( $post_tabs as $index => $post_tab ) {
449
- if ( $applied_tabs[$post_id][$tab_id]['tab_id'] === $post_tab['id'] ) {
450
- unset( $post_tabs[$index] );
451
- update_post_meta( $post_id, 'yikes_woo_products_tabs', $post_tabs );
452
- }
453
- }
454
- }
455
-
456
- // Unset the array of our applied saved tabs
457
- unset( $applied_tabs[ $post_id ][ $tab_id ] );
458
-
459
- // If that was the only saved tab for this product, unset the product's array key
460
- if ( empty( $applied_tabs[ $post_id ] ) ) {
461
- unset( $applied_tabs[ $post_id ] );
462
- }
463
- $unset_applied_tabs_flag = true;
464
- }
465
- }
466
-
467
- // If we unset an applied tab, update the database
468
- if ( $unset_applied_tabs_flag === true ) {
469
- update_option( 'yikes_woo_reusable_products_tabs_applied', $applied_tabs );
470
- }
471
- }
472
-
473
- // If we're on the single tab edit screen, we want to redirect back to tab list so let's return a var
474
- $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'delete-success' => true ), admin_url() ) );
475
-
476
- $response = array(
477
- 'success' => true,
478
- 'tab_id' => $tab_id,
479
- 'message' => 'Tab successfully deleted!',
480
- 'reason' => 'tab successfully deleted',
481
- 'redirect_url' => $return_redirect_url
482
- );
483
-
484
- return $response;
485
- }
486
-
487
- /* End AJAX Helper Functions */
488
-
489
-
490
- /* Plugin Settings Page */
491
-
492
- /**
493
- * Register our settings page
494
- *
495
- * @since 1.5
496
- *
497
- */
498
- public function yikes_woo_register_settings_page() {
499
-
500
- // Add our custom settings page
501
- add_menu_page(
502
- apply_filters( 'yikes-woo-settings-menu-title', __( 'Custom Product Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ), // Tab title name (HTML title)
503
- apply_filters( 'yikes-woo-settings-menu-title', __( 'Custom Product Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ), // Menu page name
504
- apply_filters( 'yikes-woo-settings-menu-capability', 'publish_products' ), // Capability required
505
- YIKES_Custom_Product_Tabs_Settings_Page, // Page slug (?page=slug-name)
506
- array( $this, 'generate_yikes_settings_page' ), // Function to generate page
507
- 'dashicons-exerpt-view', // Icon
508
- apply_filters( 'yikes-woo-settings-menu-priority', 100 ) // Position
509
- );
510
- }
511
-
512
- /**
513
- * Include our settings page
514
- *
515
- * @since 1.5
516
- *
517
- */
518
- public function generate_yikes_settings_page() {
519
-
520
- // Get our saved tabs array
521
- $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
522
-
523
- // New tab URL - used to supply the 'Add Tab' href
524
- $new_tab_url = esc_url( add_query_arg( array( 'saved-tab-id' => 'new' ), '?page=' . YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() );
525
-
526
- // If saved_tab_id is set, we should show the single saved tab // add new tab page
527
- if ( isset( $_GET['saved-tab-id'] ) && ! empty( $_GET['saved-tab-id'] ) ) {
528
-
529
- // Are we trying to add a new tab?
530
- $new_tab = ( $_GET['saved-tab-id'] === 'new' ) ? true : false;
531
-
532
- // Sanitize saved_tab_id
533
- $saved_tab_id = filter_var( $_GET['saved-tab-id'], FILTER_SANITIZE_NUMBER_INT );
534
-
535
- // Get the tab
536
- $tab = isset( $yikes_custom_tab_data[$saved_tab_id] ) ? $yikes_custom_tab_data[$saved_tab_id] : array();
537
-
538
- // Redirect URL
539
- $redirect = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) );
540
-
541
- require_once( YIKES_Custom_Product_Tabs_Path . 'admin/page.yikes-woo-saved-tabs-single.php' );
542
-
543
- } else {
544
- $delete_message_display = 'display: none;';
545
-
546
- // Check if our $_GET variable 'delete-success' is set so we can display a nice success message
547
- if ( isset( $_GET['delete-success'] ) && $_GET['delete-success'] === '1' ) {
548
- $delete_message_display = '';
549
- }
550
-
551
- // Show tab table list
552
- require_once( YIKES_Custom_Product_Tabs_Path . 'admin/page.yikes-woo-saved-tabs.php' );
553
- }
554
- }
555
-
556
- /* End Plugin Settings Page */
557
-
558
- /* Misc. */
559
-
560
- /**
561
- * When a WooCommere product is duplicated, check for and duplicate the saved tabs.
562
- *
563
- * @param object | $duplicated_product | The new, duplicated product
564
- * @param object | $original_product | The original product
565
- */
566
- public function yikes_woo_dupe_saved_tabs_on_product_dupe( $duplicate_product, $original_product ) {
567
-
568
- // First, let's grab our applied saved tab options array
569
- $saved_tabs_array = get_option( 'yikes_woo_reusable_products_tabs_applied' );
570
-
571
- // Grab the old post's ID
572
- $old_post_id = method_exists( $original_product, 'get_id' ) === true ? $original_product->get_id() : $original_product->ID;
573
-
574
- // (1) Make sure we have a non-empty array of saved tabs,
575
- // (2) Makre sure we have the ID of the old post, and then
576
- // (3) Check for the old post's saved tabs. (If we don't find any, do nothing)
577
- if ( ! empty( $saved_tabs_array ) && is_array( $saved_tabs_array ) && ! empty( $old_post_id ) && isset( $saved_tabs_array[$old_post_id] ) ) {
578
-
579
- // Grab the new post's ID
580
- $new_post_id = method_exists( $duplicate_product, 'get_id' ) === true ? $duplicate_product->get_id() : $duplicate_product->ID;
581
-
582
- // Loop through the $saved_tabs_array and update the post_id item
583
- $new_products_saved_tabs = $saved_tabs_array[$old_post_id];
584
- foreach ( $new_products_saved_tabs as $saved_tab_id => $saved_tab ) {
585
- $new_products_saved_tabs[$saved_tab_id]['post_id'] = $new_post_id;
586
- }
587
-
588
- // Add the old post's saved tabs, with the new post's ID as the key
589
- $saved_tabs_array[$new_post_id] = $new_products_saved_tabs;
590
-
591
- // Update the saved tab's option
592
- update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs_array );
593
- }
594
- }
595
-
596
- /**
597
- * When a WooCommerce product is deleted, delete any saved tabs from the saved tabs option
598
- *
599
- * @param int | $post_id
600
- */
601
- public function delete_saved_tabs_on_product_delete( $post_id ) {
602
-
603
- $post = get_post( $post_id );
604
-
605
- if ( $post->post_type !== 'product' ) {
606
- return;
607
- }
608
-
609
- // Get our saved tabs option
610
- $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied' );
611
-
612
- if ( empty( $saved_tabs ) ) {
613
- return;
614
- }
615
-
616
- if ( ! empty( $saved_tabs[ $post_id ] ) ) {
617
- unset( $saved_tabs[ $post_id ] );
618
- update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs );
619
- }
620
- }
621
-
622
- /* End Misc. */
623
-
624
- }
625
-
626
- new YIKES_Custom_Product_Tabs_Saved_Tabs();
627
  }
1
+ <?php
2
+
3
+ if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Saved_Tabs' ) ) {
4
+
5
+ class YIKES_Custom_Product_Tabs_Saved_Tabs {
6
+
7
+ public function __construct() {
8
+
9
+ // Add our custom settings page
10
+ add_action( 'admin_menu', array( $this, 'yikes_woo_register_settings_page' ), 10 );
11
+
12
+ // Define our options and filters
13
+ add_action( 'admin_init', array( $this, 'init' ) );
14
+ }
15
+
16
+ public function init() {
17
+
18
+ // Add our custom options for saved tabs
19
+ add_option( 'yikes_woo_reusable_products_tabs', array() );
20
+ add_option( 'yikes_woo_reusable_products_tabs_applied', array() );
21
+
22
+ // Enqueue our JS / CSS files
23
+ add_action( 'admin_enqueue_scripts' , array( $this , 'enqueue_scripts_and_styles' ), 10, 1 );
24
+
25
+ // Define our AJAX calls
26
+ add_action( 'wp_ajax_yikes_woo_save_tab_as_reusable', array( $this, 'yikes_woo_save_tab_as_reusable' ) );
27
+ add_action( 'wp_ajax_yikes_woo_fetch_reusable_tabs', array( $this, 'yikes_woo_fetch_reusable_tabs' ) );
28
+ add_action( 'wp_ajax_yikes_woo_fetch_reusable_tab', array( $this, 'yikes_woo_fetch_reusable_tab' ) );
29
+ add_action( 'wp_ajax_yikes_woo_delete_reusable_tab_handler', array( $this, 'yikes_woo_delete_reusable_tab_handler' ) );
30
+
31
+ // Duplicate any saved tabs when a product is duplicated
32
+ add_filter( 'woocommerce_product_duplicate', array( $this, 'yikes_woo_dupe_saved_tabs_on_product_dupe' ), 11, 2 );
33
+
34
+ // Delete any saved tabs when a product is deleted
35
+ add_action( 'delete_post', array( $this, 'delete_saved_tabs_on_product_delete' ), 10, 1 );
36
+ }
37
+
38
+ /**
39
+ * Enqueue our scripts and styles
40
+ *
41
+ * @param string | $hook | The current page
42
+ */
43
+ public function enqueue_scripts_and_styles( $hook ) {
44
+
45
+ if ( $hook === 'toplevel_page_' . YIKES_Custom_Product_Tabs_Settings_Page ) {
46
+
47
+ // JavaScript
48
+ wp_enqueue_script ( 'repeatable-custom-tabs-settings', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-settings.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
49
+ wp_localize_script( 'repeatable-custom-tabs-settings', 'repeatable_custom_tabs_settings', array(
50
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif-settings" />',
51
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
52
+ 'tab_list_page_url' => esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) ),
53
+ 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
54
+ 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' ),
55
+ 'is_cptpro_enabled' => defined( 'YIKES_Custom_Product_Tabs_Pro_Enabled' ) ? true : false,
56
+ ) );
57
+
58
+ wp_enqueue_script ( 'repeatable-custom-tabs-shared', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-shared.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
59
+ wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
60
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
61
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
62
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
63
+ 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
64
+ ) );
65
+
66
+ // Twitter script for our Tweet Us button
67
+ wp_enqueue_script( 'twitter-button', YIKES_Custom_Product_Tabs_URI . 'js/twitter-embed.js', null, YIKES_Custom_Product_Tabs_Version );
68
+
69
+ // CSS
70
+ wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
71
+ }
72
+
73
+ }
74
+
75
+ /* AJAX Functions */
76
+
77
+ /**
78
+ * [AJAX] Save a tab as reusable
79
+ *
80
+ * @since 1.5
81
+ *
82
+ * @param string | $_POST['tab_title'] | Tab title to save
83
+ * @param string | $_POST['tab_content'] | Tab content to save
84
+ * @param string | $_POST['tab_id'] | Optional. Tab ID we're updating
85
+ * @param string | $_POST['tab_name'] | Tab name to save
86
+ * @param array | $_POST['taxonomies'] | Optional. Array of taxonomies.
87
+ *
88
+ * @return string | JSON response
89
+ */
90
+ public function yikes_woo_save_tab_as_reusable() {
91
+
92
+ // Verify the nonce
93
+ if ( ! check_ajax_referer( 'yikes_woo_save_tab_as_reusable_nonce', 'security_nonce', false ) ) {
94
+ wp_send_json_error();
95
+ }
96
+
97
+ // Define it now, because we may use this later...
98
+ $return_redirect_url = '';
99
+
100
+ // Get our $_POST vars
101
+ if ( isset( $_POST['tab_title'] ) && ! empty( $_POST['tab_title'] ) ) {
102
+ $tab_title = stripslashes( $_POST['tab_title'] );
103
+ $tab_string_id = urldecode( sanitize_title( $tab_title ) );
104
+ } else {
105
+ wp_send_json_error( array( 'reason' => 'no tab title', 'message' => 'Please fill out the tab title before saving.' ) );
106
+ }
107
+
108
+ $tab_content = isset( $_POST['tab_content'] ) && ! empty( $_POST['tab_content'] ) ? $_POST['tab_content'] : '';
109
+ $tab_id = isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ? $_POST['tab_id'] : '';
110
+ $tab_name = isset( $_POST['tab_name'] ) ? $_POST['tab_name'] : '';
111
+ $global_tab = isset( $_POST['global_tab'] ) && $_POST['global_tab'] === 'true' ? true : false;
112
+
113
+ // Remove taxonomies if we're using a global tab
114
+ $taxonomies = isset( $_POST['taxonomies'] ) && ! empty( $_POST['taxonomies'] ) && $global_tab === false ? $_POST['taxonomies'] : array();
115
+
116
+ // Get our saved tabs array
117
+ $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
118
+
119
+ // If the saved tabs array is empty, create a new array and save it (first time we've done this)
120
+ if ( empty( $yikes_custom_tab_data ) ) {
121
+ $yikes_custom_tab_options_array = array();
122
+ $new_tab = array(
123
+ 'tab_title' => $tab_title,
124
+ 'tab_name' => $tab_name,
125
+ 'tab_content' => $tab_content,
126
+ 'tab_id' => 1,
127
+ 'taxonomies' => $taxonomies,
128
+ 'tab_slug' => $tab_string_id,
129
+ 'global_tab' => $global_tab,
130
+ );
131
+
132
+ $yikes_custom_tab_options_array[1] = $new_tab;
133
+
134
+ do_action( 'yikes-woo-handle-tab-save', $new_tab, 'new' );
135
+
136
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_options_array );
137
+
138
+ // Return redirect URL
139
+ $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => 1 ), admin_url() ) );
140
+
141
+ // Send response
142
+ wp_send_json_success( array( 'tab_id' => 1, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
143
+ } else {
144
+
145
+ // this is a new tab and we need to create a unique ID
146
+ if ( $tab_id === 'new' ) {
147
+
148
+ // Get the max ID we have saved
149
+ foreach ( $yikes_custom_tab_data as $tab_data ) {
150
+ if ( ! isset( $highest_tab_id ) ) {
151
+ $highest_tab_id = $tab_data['tab_id'];
152
+ } else {
153
+ if ( $tab_data['tab_id'] > $highest_tab_id ) {
154
+ $highest_tab_id = $tab_data['tab_id'];
155
+ }
156
+ }
157
+ }
158
+
159
+ // Add 1 to the max ID
160
+ $new_tab_id = (int) $highest_tab_id + 1;
161
+
162
+ $new_tab = array(
163
+ 'tab_title' => $tab_title,
164
+ 'tab_name' => $tab_name,
165
+ 'tab_content' => $tab_content,
166
+ 'tab_id' => $new_tab_id,
167
+ 'taxonomies' => $taxonomies,
168
+ 'tab_slug' => $tab_string_id,
169
+ 'global_tab' => $global_tab,
170
+ );
171
+
172
+ $yikes_custom_tab_data[$new_tab_id] = $new_tab;
173
+
174
+ do_action( 'yikes-woo-handle-tab-save', $new_tab, 'new' );
175
+
176
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
177
+
178
+ // Return redirect URL
179
+ $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => $new_tab_id ), admin_url() ) );
180
+
181
+ // Send response
182
+ wp_send_json_success( array( 'tab_id' => $new_tab_id, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
183
+
184
+ } else {
185
+
186
+ // This is an existing tab, so just update it
187
+ $saved_tab = array(
188
+ 'tab_title' => $tab_title,
189
+ 'tab_name' => $tab_name,
190
+ 'tab_content' => $tab_content,
191
+ 'tab_id' => $tab_id,
192
+ 'taxonomies' => $taxonomies,
193
+ 'tab_slug' => $tab_string_id,
194
+ 'global_tab' => $global_tab,
195
+ );
196
+
197
+ $yikes_custom_tab_data[$tab_id] = $saved_tab;
198
+
199
+ do_action( 'yikes-woo-handle-tab-save', $saved_tab, 'existing' );
200
+
201
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
202
+
203
+ // Now apply this updated tab's data to custom product tabs that use it
204
+
205
+ // Get the array of applied product tabs
206
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
207
+
208
+ // Flag so we know we found a post and we should update it
209
+ $update_post_meta_flag = false;
210
+
211
+ // Flag so we know we have to update the yikes_woo_reusable_products_tabs_applied
212
+ $update_applied_products_array = false;
213
+
214
+ foreach( $reusable_tab_options_array as $post_id => $reusable_tab_data ) {
215
+
216
+ // Fetch the relevant postmeta field
217
+ $custom_tab_data = maybe_unserialize( get_post_meta( $post_id, 'yikes_woo_products_tabs', true ) );
218
+
219
+ // If we don't have custom tab data then continue
220
+ if ( empty( $custom_tab_data ) ) {
221
+ continue;
222
+ }
223
+
224
+ // Loop through $custom_tab_data and find the custom tab that was just updated
225
+ foreach( $custom_tab_data as $index => $tab ) {
226
+ if ( isset( $reusable_tab_data[ $tab_id ] ) && $tab['id'] === $reusable_tab_data[ $tab_id ]['tab_id'] ) {
227
+ $custom_tab_data[$index]['title'] = $tab_title;
228
+ $custom_tab_data[$index]['name'] = $tab_name;
229
+ $custom_tab_data[$index]['content'] = $tab_content;
230
+ $custom_tab_data[$index]['id'] = $tab_string_id;
231
+
232
+ // We may need to update the tab_string_id too
233
+ if ( $tab_string_id !== $tab['id'] ) {
234
+ $reusable_tab_options_array[$post_id][$tab_id]['tab_id'] = $tab_string_id;
235
+ $update_applied_products_array = true;
236
+ }
237
+ $update_post_meta_flag = true;
238
+ }
239
+ }
240
+
241
+ // If we updated a tab, save it
242
+ if ( $update_post_meta_flag === true ) {
243
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $custom_tab_data );
244
+ }
245
+ }
246
+
247
+ // If we updated the tab_string_id in the yikes_woo_reusable_products_tabs_applied array, save it
248
+ if ( $update_applied_products_array === true ) {
249
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array);
250
+ }
251
+ }
252
+ }
253
+
254
+ wp_send_json_success( array( 'redirect' => false ) );
255
+ }
256
+
257
+ /**
258
+ * [AJAX] Fetch a single reusable
259
+ *
260
+ * @since 1.5
261
+ *
262
+ * @return object success w/ tab data || failure w/ message
263
+ */
264
+ public function yikes_woo_fetch_reusable_tab() {
265
+
266
+ // Verify the nonce
267
+ if ( ! check_ajax_referer( 'yikes_woo_fetch_reusable_tab_nonce', 'security_nonce', false ) ) {
268
+ wp_send_json_error();
269
+ }
270
+
271
+ $tab_id = isset( $_POST['tab_id'] ) ? filter_var( $_POST['tab_id'], FILTER_SANITIZE_NUMBER_INT ) : '';
272
+
273
+ // Get the array of saved tabs
274
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
275
+
276
+ $tab = isset( $saved_tabs[$tab_id] ) ? $saved_tabs[$tab_id] : false;
277
+
278
+ if ( $tab !== false ) {
279
+
280
+ $tab['tab_content'] = stripslashes( $tab['tab_content'] );
281
+
282
+ wp_send_json_success( $tab );
283
+ } else {
284
+ wp_send_json_success( array( 'message' => __( 'Could not find the tab. Please try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ) );
285
+ }
286
+
287
+ // If we get this far, send error
288
+ wp_send_json_error( array( 'message' => __( 'Uh oh. Something went wrong.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ) );
289
+ }
290
+
291
+ /**
292
+ * [AJAX] Fetch all reusable tabs
293
+ *
294
+ * @since 1.5
295
+ *
296
+ * @return object success w/ saved_tabs || failure w/ message
297
+ */
298
+ public function yikes_woo_fetch_reusable_tabs() {
299
+
300
+ // Verify the nonce
301
+ if ( ! check_ajax_referer( 'yikes_woo_fetch_reusable_tabs_nonce', 'security_nonce', false ) ) {
302
+ wp_send_json_error();
303
+ }
304
+
305
+ // Get the array of saved tabs
306
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
307
+
308
+ $fetch_tab_content = isset( $_POST['fetch_tab_content'] ) ? filter_var( $_POST['fetch_tab_content'], FILTER_VALIDATE_BOOLEAN ) : false;
309
+
310
+ // We don't need to pass the content back, and it could be a LOT, so let's just remove it
311
+ if ( $fetch_tab_content === false && ! empty( $saved_tabs ) ) {
312
+ foreach( $saved_tabs as $key => $tab ) {
313
+ unset( $saved_tabs[$key]['tab_content'] );
314
+ }
315
+ }
316
+
317
+ if ( ! empty( $saved_tabs ) ) {
318
+ wp_send_json_success( json_encode( $saved_tabs ) );
319
+ } else {
320
+ wp_send_json_success( array( 'message' => 'No saved tabs were found.' ) );
321
+ }
322
+
323
+ // If we get this far, send error
324
+ wp_send_json_error( array( 'message' => 'Uh oh. Something went wrong.' ) );
325
+ }
326
+
327
+ /**
328
+ * [AJAX] Delete a reusable tab
329
+ *
330
+ * @since 1.5
331
+ *
332
+ * @param string $_POST['tab_id']
333
+ * @return object success w/ saved_tabs || failure w/ message
334
+ */
335
+ public function yikes_woo_delete_reusable_tab_handler() {
336
+
337
+ // Verify the nonce
338
+ if ( ! check_ajax_referer( 'yikes_woo_delete_reusable_tab_nonce', 'security_nonce', false ) ) {
339
+ wp_send_json_error();
340
+ }
341
+
342
+ // Get our tab_id
343
+ if ( isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ) {
344
+
345
+ $tab_ids = $_POST['tab_id'];
346
+
347
+ // if $tab_ids isn't an array, turn it into one
348
+ if ( ! is_array( $tab_ids ) ) {
349
+ $tab_ids = array( $tab_ids );
350
+ }
351
+
352
+ // Set this up before we use it
353
+ $return_vars = array();
354
+
355
+ foreach( $tab_ids as $tab_id ) {
356
+
357
+ // Delete the tab, store the return values in $return_vars
358
+ $return_vars = $this->yikes_woo_delete_reusable_tab( $tab_id );
359
+
360
+ // Make sure $return_vars is what we think it is, and check if our delete failed
361
+ if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === false ) {
362
+
363
+ // If something failed, let's return
364
+ wp_send_json_error( $return_vars );
365
+ }
366
+ }
367
+ } else {
368
+
369
+ // Fail if we don't have a tab_id
370
+ wp_send_json_error( array( 'reason' => 'no tab id' ) );
371
+ }
372
+
373
+ // Make sure $return_vars is what we think it is, and check if our delete was successful
374
+ if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === true ) {
375
+
376
+ // If nothing failed, let's return
377
+ wp_send_json_success( $return_vars );
378
+ }
379
+
380
+ // We shouldn't have gotten this far, but if we did let's return failure
381
+ wp_send_json_error();
382
+ }
383
+
384
+ /* End AJAX Functions */
385
+
386
+ /* AJAX Helper Functions */
387
+
388
+ /**
389
+ * Delete a saved tab from the options array and delete the tab from the product's tabs array
390
+ *
391
+ * @since 1.5
392
+ *
393
+ * @param int | $tab_id | unique identifier of a tab
394
+ * @return array | $response | array of data signifying success, message, reason, and other needed data
395
+ */
396
+ protected function yikes_woo_delete_reusable_tab( $tab_id ) {
397
+
398
+ // The following code will remove the tab from our array of saved tabs
399
+
400
+ // Fetch all saved tabs
401
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
402
+
403
+ // Check some stuff, then remove the tab from our array of saved tabs
404
+ if ( ! empty( $saved_tabs ) ) {
405
+ if ( isset( $saved_tabs[$tab_id] ) ) {
406
+ unset( $saved_tabs[$tab_id] );
407
+ update_option( 'yikes_woo_reusable_products_tabs', $saved_tabs );
408
+ } else {
409
+ $response = array(
410
+ 'success' => false,
411
+ 'tab_id' => $tab_id,
412
+ 'message' => 'No saved tab with id ' . $tab_id . ' found!',
413
+ 'reason' => 'no saved tab found'
414
+ );
415
+ return $response;
416
+ }
417
+ } else {
418
+ $response = array(
419
+ 'success' => false,
420
+ 'tab_id' => $tab_id,
421
+ 'message' => 'No saved tabs found!',
422
+ 'reason' => 'no saved tabs found'
423
+ );
424
+ return $response;
425
+ }
426
+
427
+ // The following code will remove the tab from our array of applied tabs and postmeta
428
+
429
+ // Fetch all applied tabs
430
+ $applied_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
431
+
432
+ // Set a flag so we know if we need to update the database
433
+ $unset_applied_tabs_flag = false;
434
+
435
+ if ( ! empty( $applied_tabs ) ) {
436
+
437
+ // Run through all the applied tabs and remove the ones with this ID
438
+ foreach( $applied_tabs as $post_id => $applied_tabs_array ) {
439
+
440
+ // If this ID is set, unset the array
441
+ if ( isset( $applied_tabs_array[$tab_id] ) ) {
442
+
443
+ // Now we also need to remove this entry from our postmeta
444
+ $post_tabs = maybe_unserialize( get_post_meta( $post_id, 'yikes_woo_products_tabs', true ) );
445
+
446
+ // Make sure it exists
447
+ if ( ! empty( $post_tabs ) ) {
448
+ foreach ( $post_tabs as $index => $post_tab ) {
449
+ if ( $applied_tabs[$post_id][$tab_id]['tab_id'] === $post_tab['id'] ) {
450
+ unset( $post_tabs[$index] );
451
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $post_tabs );
452
+ }
453
+ }
454
+ }
455
+
456
+ // Unset the array of our applied saved tabs
457
+ unset( $applied_tabs[ $post_id ][ $tab_id ] );
458
+
459
+ // If that was the only saved tab for this product, unset the product's array key
460
+ if ( empty( $applied_tabs[ $post_id ] ) ) {
461
+ unset( $applied_tabs[ $post_id ] );
462
+ }
463
+ $unset_applied_tabs_flag = true;
464
+ }
465
+ }
466
+
467
+ // If we unset an applied tab, update the database
468
+ if ( $unset_applied_tabs_flag === true ) {
469
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $applied_tabs );
470
+ }
471
+ }
472
+
473
+ // If we're on the single tab edit screen, we want to redirect back to tab list so let's return a var
474
+ $return_redirect_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'delete-success' => true ), admin_url() ) );
475
+
476
+ $response = array(
477
+ 'success' => true,
478
+ 'tab_id' => $tab_id,
479
+ 'message' => 'Tab successfully deleted!',
480
+ 'reason' => 'tab successfully deleted',
481
+ 'redirect_url' => $return_redirect_url
482
+ );
483
+
484
+ return $response;
485
+ }
486
+
487
+ /* End AJAX Helper Functions */
488
+
489
+
490
+ /* Plugin Settings Page */
491
+
492
+ /**
493
+ * Register our settings page
494
+ *
495
+ * @since 1.5
496
+ *
497
+ */
498
+ public function yikes_woo_register_settings_page() {
499
+
500
+ // Add our custom settings page
501
+ add_menu_page(
502
+ apply_filters( 'yikes-woo-settings-menu-title', __( 'Custom Product Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ), // Tab title name (HTML title)
503
+ apply_filters( 'yikes-woo-settings-menu-title', __( 'Custom Product Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ), // Menu page name
504
+ apply_filters( 'yikes-woo-settings-menu-capability', 'publish_products' ), // Capability required
505
+ YIKES_Custom_Product_Tabs_Settings_Page, // Page slug (?page=slug-name)
506
+ array( $this, 'generate_yikes_settings_page' ), // Function to generate page
507
+ 'dashicons-exerpt-view', // Icon
508
+ apply_filters( 'yikes-woo-settings-menu-priority', 100 ) // Position
509
+ );
510
+ }
511
+
512
+ /**
513
+ * Include our settings page
514
+ *
515
+ * @since 1.5
516
+ *
517
+ */
518
+ public function generate_yikes_settings_page() {
519
+
520
+ // Get our saved tabs array
521
+ $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
522
+
523
+ // New tab URL - used to supply the 'Add Tab' href
524
+ $new_tab_url = esc_url( add_query_arg( array( 'saved-tab-id' => 'new' ), '?page=' . YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() );
525
+
526
+ // If saved_tab_id is set, we should show the single saved tab // add new tab page
527
+ if ( isset( $_GET['saved-tab-id'] ) && ! empty( $_GET['saved-tab-id'] ) ) {
528
+
529
+ // Are we trying to add a new tab?
530
+ $new_tab = ( $_GET['saved-tab-id'] === 'new' ) ? true : false;
531
+
532
+ // Sanitize saved_tab_id
533
+ $saved_tab_id = filter_var( $_GET['saved-tab-id'], FILTER_SANITIZE_NUMBER_INT );
534
+
535
+ // Get the tab
536
+ $tab = isset( $yikes_custom_tab_data[$saved_tab_id] ) ? $yikes_custom_tab_data[$saved_tab_id] : array();
537
+
538
+ // Redirect URL
539
+ $redirect = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) );
540
+
541
+ require_once( YIKES_Custom_Product_Tabs_Path . 'admin/page.yikes-woo-saved-tabs-single.php' );
542
+
543
+ } else {
544
+ $delete_message_display = 'display: none;';
545
+
546
+ // Check if our $_GET variable 'delete-success' is set so we can display a nice success message
547
+ if ( isset( $_GET['delete-success'] ) && $_GET['delete-success'] === '1' ) {
548
+ $delete_message_display = '';
549
+ }
550
+
551
+ // Show tab table list
552
+ require_once( YIKES_Custom_Product_Tabs_Path . 'admin/page.yikes-woo-saved-tabs.php' );
553
+ }
554
+ }
555
+
556
+ /* End Plugin Settings Page */
557
+
558
+ /* Misc. */
559
+
560
+ /**
561
+ * When a WooCommere product is duplicated, check for and duplicate the saved tabs.
562
+ *
563
+ * @param object | $duplicated_product | The new, duplicated product
564
+ * @param object | $original_product | The original product
565
+ */
566
+ public function yikes_woo_dupe_saved_tabs_on_product_dupe( $duplicate_product, $original_product ) {
567
+
568
+ // First, let's grab our applied saved tab options array
569
+ $saved_tabs_array = get_option( 'yikes_woo_reusable_products_tabs_applied' );
570
+
571
+ // Grab the old post's ID
572
+ $old_post_id = method_exists( $original_product, 'get_id' ) === true ? $original_product->get_id() : $original_product->ID;
573
+
574
+ // (1) Make sure we have a non-empty array of saved tabs,
575
+ // (2) Makre sure we have the ID of the old post, and then
576
+ // (3) Check for the old post's saved tabs. (If we don't find any, do nothing)
577
+ if ( ! empty( $saved_tabs_array ) && is_array( $saved_tabs_array ) && ! empty( $old_post_id ) && isset( $saved_tabs_array[$old_post_id] ) ) {
578
+
579
+ // Grab the new post's ID
580
+ $new_post_id = method_exists( $duplicate_product, 'get_id' ) === true ? $duplicate_product->get_id() : $duplicate_product->ID;
581
+
582
+ // Loop through the $saved_tabs_array and update the post_id item
583
+ $new_products_saved_tabs = $saved_tabs_array[$old_post_id];
584
+ foreach ( $new_products_saved_tabs as $saved_tab_id => $saved_tab ) {
585
+ $new_products_saved_tabs[$saved_tab_id]['post_id'] = $new_post_id;
586
+ }
587
+
588
+ // Add the old post's saved tabs, with the new post's ID as the key
589
+ $saved_tabs_array[$new_post_id] = $new_products_saved_tabs;
590
+
591
+ // Update the saved tab's option
592
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs_array );
593
+ }
594
+ }
595
+
596
+ /**
597
+ * When a WooCommerce product is deleted, delete any saved tabs from the saved tabs option
598
+ *
599
+ * @param int | $post_id
600
+ */
601
+ public function delete_saved_tabs_on_product_delete( $post_id ) {
602
+
603
+ $post = get_post( $post_id );
604
+
605
+ if ( $post->post_type !== 'product' ) {
606
+ return;
607
+ }
608
+
609
+ // Get our saved tabs option
610
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied' );
611
+
612
+ if ( empty( $saved_tabs ) ) {
613
+ return;
614
+ }
615
+
616
+ if ( ! empty( $saved_tabs[ $post_id ] ) ) {
617
+ unset( $saved_tabs[ $post_id ] );
618
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs );
619
+ }
620
+ }
621
+
622
+ /* End Misc. */
623
+
624
+ }
625
+
626
+ new YIKES_Custom_Product_Tabs_Saved_Tabs();
627
  }
admin/class.yikes-woo-tabs.php CHANGED
@@ -1,365 +1,365 @@
1
- <?php
2
-
3
- if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Custom_Tabs' ) ) {
4
-
5
- class YIKES_Custom_Product_Tabs_Custom_Tabs {
6
-
7
-
8
- public function __construct() {
9
-
10
- add_action( 'woocommerce_init', array( $this, 'init' ) );
11
- }
12
-
13
- public function init() {
14
-
15
- // Add our Custom Product Tabs panel to the WooCommerce panel container
16
- add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'render_custom_product_tabs' ) );
17
- add_action( 'woocommerce_product_data_panels', array( $this, 'product_page_yikes_custom_tabs_panel' ) );
18
-
19
- // Save custom tab data
20
- add_action( 'woocommerce_process_product_meta', array( $this, 'product_save_data' ), 10, 2 );
21
-
22
- // Enqueue our JS / CSS files
23
- add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ), 10, 1 );
24
-
25
- // Define our AJAX calls
26
- add_action( 'wp_ajax_yikes_woo_get_wp_editor', array( $this, 'yikes_woo_get_wp_editor' ) );
27
- add_action( 'wp_ajax_yikes_woo_save_product_tabs', array( $this, 'yikes_woo_save_product_tabs' ) );
28
-
29
- // Duplicate any custom tabs when a product is duplicated
30
- add_action( 'woocommerce_product_duplicate', array( $this, 'yikes_woo_dupe_custom_product_tabs' ), 10, 2 );
31
- }
32
-
33
-
34
- /**
35
- * Enqueue all the required scripts and styles on the appropriate pages
36
- *
37
- * @param string | $hook | The current page slug
38
- */
39
- public function enqueue_scripts_and_styles( $hook ) {
40
- global $post;
41
- global $wp_version;
42
- if ( $hook === 'post-new.php' || $hook === 'post.php' ) {
43
- if ( $post->post_type === 'product' ) {
44
-
45
- // Enqueue WordPress' built-in editor functions - added in WPv4.8
46
- if ( function_exists( 'wp_enqueue_editor' ) ) {
47
- wp_enqueue_editor();
48
- }
49
-
50
- // script
51
- wp_enqueue_script ( 'repeatable-custom-tabs', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs.min.js' , array( 'jquery' ) , YIKES_Custom_Product_Tabs_Version );
52
- wp_localize_script( 'repeatable-custom-tabs', 'repeatable_custom_tabs', array(
53
- 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
54
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
55
- 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
56
- 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
57
- 'fetch_reusable_tabs_nonce' => wp_create_nonce( 'yikes_woo_fetch_reusable_tabs_nonce' ),
58
- 'fetch_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_fetch_reusable_tab_nonce' ),
59
- 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' ),
60
- 'save_product_tabs_nonce' => wp_create_nonce( 'yikes_woo_save_product_tabs_nonce' ),
61
- 'global_post_id' => $post->ID,
62
- 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
63
- 'wp_version_four_eight' => $wp_version >= '4.8',
64
- ) );
65
-
66
- wp_enqueue_script ( 'repeatable-custom-tabs-shared', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-shared.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
67
- wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
68
- 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
69
- 'ajaxurl' => admin_url( 'admin-ajax.php' ),
70
- 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
71
- 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
72
- ) );
73
-
74
- // styles
75
- wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
76
-
77
- // JS lity modal library and CSS
78
- wp_enqueue_script( 'lity-js', YIKES_Custom_Product_Tabs_URI . 'js/lity.min.js' , array( 'jquery' ) , YIKES_Custom_Product_Tabs_Version );
79
- wp_enqueue_style( 'lity-css', YIKES_Custom_Product_Tabs_URI . 'css/dist/lity.min.css' );
80
- }
81
- }
82
- }
83
-
84
- /**
85
- * Adds a new tab to the Product Data postbox in the admin product interface
86
- */
87
- public function render_custom_product_tabs() {
88
- echo "<li class=\"yikes_wc_product_tabs_tab\"><a href=\"#yikes_woocommerce_custom_product_tabs\"><span>" . __( 'Custom Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . "</span></a></li>";
89
- }
90
-
91
-
92
- /**
93
- * Adds the panel to the Product Data postbox in the product interface
94
- */
95
- public function product_page_yikes_custom_tabs_panel() {
96
-
97
- // Require & instantiate our HTML class
98
- require_once( YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-generate-html.php' );
99
- $HTML = new Yikes_Woo_Custom_Product_Tabs_HTML();
100
-
101
- // Call our function to generate the HTML
102
- $HTML->generate_html();
103
- }
104
-
105
- /**
106
- * Save the tab data.
107
- *
108
- * @param int | $post_id
109
- * @param object | $post
110
- */
111
- public function product_save_data( $post_id, $post ) {
112
-
113
- // Make sure we have a $post_id
114
- if ( empty( $post_id ) ) {
115
- return;
116
- }
117
-
118
- // Save our tabs!
119
- $this->save_tabs( $post_id, $is_ajax = false );
120
- }
121
-
122
- /**
123
- * Save the tabs to the database
124
- *
125
- * @since 1.5
126
- *
127
- * @param int | $post_id | The ID of the post that has custom tabs
128
- * @param bool | $is_ajax_flag | A flag signifying whether we're calling this function from an AJAX call
129
- */
130
- protected function save_tabs( $post_id, $is_ajax_flag ) {
131
- $tab_data = array();
132
-
133
- $number_of_tabs = $_POST['number_of_tabs'];
134
-
135
- // Create an array for tab_ids that we will use later
136
- $current_saved_tab_id_array = array();
137
- $remove_a_tab_from_reusable = false;
138
-
139
- // Fetch the reusable tab options (we'll use this later)
140
- $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
141
-
142
- // Check if this tab has reusable tabs and set flag
143
- $post_has_reusable_tabs = false;
144
- if ( isset ( $reusable_tab_options_array[$post_id] ) ) {
145
- $post_has_reusable_tabs = true;
146
- }
147
-
148
- $i = 1;
149
- while( $i <= $number_of_tabs ) {
150
-
151
- // Deal with saving the tab content
152
-
153
- $tab_title = isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i] ) ? stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i] ) : '';
154
- $tab_content = isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i] ) ? stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i] ) : '';
155
-
156
- if ( empty( $tab_title ) && empty( $tab_content ) ) {
157
-
158
- // clean up if the custom tabs are removed
159
- unset( $tab_data[$i] );
160
-
161
- } else {
162
-
163
- $tab_id = '';
164
-
165
- if ( $tab_title ) {
166
- $tab_id = urldecode( sanitize_title( $tab_title ) );
167
- }
168
-
169
- // push the data to the array
170
- $tab_data[$i] = array( 'title' => $tab_title, 'id' => $tab_id, 'content' => $tab_content );
171
- }
172
-
173
- // Deal with saving / applying globally saved tabs
174
-
175
- if ( isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i] ) && isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'] )
176
- && ! empty( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i] ) && ! empty( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'] ) ) {
177
-
178
- // Store the tab_id and action
179
- $reusable_tab_id = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i];
180
- $reusable_tab_action = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'];
181
-
182
- // If $reusable_tab_options_array is not empty, we've done this before
183
- if ( ! empty( $reusable_tab_options_array ) ) {
184
-
185
- // If action is 'add', add the tab!
186
- if ( $reusable_tab_action === 'add' ) {
187
-
188
- $reusable_tab_options_array[$post_id][$reusable_tab_id] = array(
189
- 'post_id' => $post_id,
190
- 'reusable_tab_id' => $reusable_tab_id,
191
- 'tab_id' => $tab_id
192
- );
193
-
194
- // Update our applied tabs array
195
- update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
196
-
197
- } elseif ( $reusable_tab_action === 'remove' ) {
198
-
199
- // This tab will no longer be affected by the global/reusable tab changes
200
- unset( $reusable_tab_options_array[$post_id][$reusable_tab_id] );
201
-
202
- // Update our applied tabs array
203
- update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
204
- }
205
- } elseif ( $reusable_tab_action === 'add' ) {
206
-
207
- // First time adding a new tab
208
- $reusable_tab_options_array_to_save = array();
209
- $reusable_tab_options_array_to_save[$post_id][$reusable_tab_id] = array(
210
- 'post_id' => $post_id,
211
- 'reusable_tab_id' => $reusable_tab_id,
212
- 'tab_id' => $tab_id
213
- );
214
-
215
- // Update our applied tabs array
216
- update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array_to_save );
217
- }
218
-
219
-
220
- // Add this ID to our array of saved tab IDs
221
- $current_saved_tab_id_array[] = $tab_id;
222
- }
223
-
224
- $i++;
225
- }
226
-
227
- // Let's check our $current_saved_tab_id_array and see if we need to remove any reusable tabs
228
- if ( $post_has_reusable_tabs === true ) {
229
-
230
- // If we have tabs...
231
- if ( ! empty( $current_saved_tab_id_array ) ) {
232
-
233
- // Loop through our reusable tab array
234
- foreach( $reusable_tab_options_array[ $post_id ] as $id => $reusable_tab_array ) {
235
-
236
- // If we find one of our reusable tabs is no longer part of this post, remove it
237
- if ( ! in_array( $reusable_tab_array['tab_id'], $current_saved_tab_id_array ) ) {
238
-
239
- unset( $reusable_tab_options_array[ $post_id ][ $id ] );
240
- $remove_a_tab_from_reusable = true;
241
- }
242
- }
243
- } else {
244
-
245
- // If we don't have any current tabs then we need to delete this post's option
246
- unset( $reusable_tab_options_array[ $post_id ] );
247
- $remove_a_tab_from_reusable = true;
248
- }
249
-
250
- // If we removed a tab, then update our applied tabs array
251
- if ( $remove_a_tab_from_reusable === true ) {
252
- update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
253
- }
254
- }
255
-
256
- // Reset the array count, when items are removed
257
- $tab_data = array_values( $tab_data );
258
-
259
- // update the post data
260
- update_post_meta( $post_id, 'yikes_woo_products_tabs', $tab_data );
261
-
262
- if ( $is_ajax_flag === true ) {
263
- return true;
264
- } else {
265
-
266
- // Fire off our Custom Product Tabs PRO action for taxonomy handling
267
- do_action( 'yikes-woo-handle-tabs-on-product-save', $post_id );
268
- }
269
- }
270
-
271
- /* AJAX Functions */
272
-
273
- /**
274
- * [AJAX] Return wp_editor HTML
275
- * (this is a bit funky, I know, but it's part of dynamically adding / removing the WYSIWYG )
276
- *
277
- * @since 1.5
278
- *
279
- * @param string $_POST['textarea_id'] ID of the textarea that we're initializing wp_editor with
280
- * @param string $_POST['tab_content'] content to pre-supply the text editor with
281
- * @return string wp_editor HTML
282
- */
283
- public function yikes_woo_get_wp_editor() {
284
-
285
- // Verify nonce
286
- if ( ! check_ajax_referer( 'yikes_woo_get_wp_editor_nonce', 'security_nonce', false ) ) {
287
- wp_send_json_error();
288
- }
289
-
290
- // Get & sanitize the $_POST var textarea_id
291
- $textarea_id = filter_var( $_POST['textarea_id'], FILTER_SANITIZE_STRING );
292
-
293
- // Check if we have tab content
294
- $tab_content = isset( $_POST['tab_content'] ) ? $_POST['tab_content'] : '';
295
-
296
- // Set up options
297
- $wp_editor_options = array(
298
- 'textarea_name' => $textarea_id,
299
- 'textarea_rows' => 8,
300
- );
301
-
302
- // Return wp_editor HTML
303
- wp_editor( stripslashes( $tab_content ), $textarea_id, $wp_editor_options );
304
- exit;
305
- }
306
-
307
- /**
308
- * [AJAX] Save all tabs for the current product
309
- *
310
- * @since 1.5
311
- *
312
- * @param string $_POST['post_id'] | ID of the current product (post)
313
- * @param array $_POST['product_tabs'] | array of all the tab data
314
- * @return object success w/ message || failure w/ message
315
- */
316
- public function yikes_woo_save_product_tabs() {
317
-
318
- // Verify the nonce
319
- if ( ! check_ajax_referer( 'yikes_woo_save_product_tabs_nonce', 'security_nonce', false ) ) {
320
- wp_send_json_error();
321
- }
322
-
323
- // Get our product id
324
- if ( isset( $_POST['post_id'] ) ) {
325
- $post_id = filter_var( $_POST['post_id'], FILTER_SANITIZE_NUMBER_INT );
326
- } else {
327
-
328
- // Fail gracefully...
329
- wp_send_json_error( array( 'message' => 'Could not find the product!' ) );
330
- }
331
-
332
- // Save our tabs!
333
- $success = $this->save_tabs( $post_id, $is_ajax = true );
334
-
335
- if ( $success === true ) {
336
- wp_send_json_success( array( 'message' => 'Your tabs have been saved' ) );
337
- } else {
338
- wp_send_json_error( array( 'message' => 'Uh oh! Something went wrong with saving. Please try again.' ) );
339
- }
340
- }
341
-
342
- /**
343
- * When a WooCommere product is duplicated, check for and duplicate the custom tabs.
344
- *
345
- * @param object | $duplicated_product | The new, duplicated product
346
- * @param object | $original_product | The original product
347
- */
348
- public function yikes_woo_dupe_custom_product_tabs( $duplicate_product, $original_product ) {
349
- $old_post_id = method_exists( $original_product, 'get_id' ) === true ? $original_product->get_id() : $original_product->ID;
350
- $new_post_id = method_exists( $duplicate_product, 'get_id' ) === true ? $duplicate_product->get_id() : $duplicate_product->ID;
351
-
352
- $current_products_tabs = get_post_meta( $old_post_id, 'yikes_woo_products_tabs', true );
353
-
354
- if ( ! empty( $current_products_tabs ) ) {
355
- update_post_meta( $new_post_id, 'yikes_woo_products_tabs', $current_products_tabs );
356
- }
357
- }
358
-
359
-
360
-
361
- }
362
-
363
- new YIKES_Custom_Product_Tabs_Custom_Tabs();
364
- }
365
-
1
+ <?php
2
+
3
+ if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Custom_Tabs' ) ) {
4
+
5
+ class YIKES_Custom_Product_Tabs_Custom_Tabs {
6
+
7
+
8
+ public function __construct() {
9
+
10
+ add_action( 'woocommerce_init', array( $this, 'init' ) );
11
+ }
12
+
13
+ public function init() {
14
+
15
+ // Add our Custom Product Tabs panel to the WooCommerce panel container
16
+ add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'render_custom_product_tabs' ) );
17
+ add_action( 'woocommerce_product_data_panels', array( $this, 'product_page_yikes_custom_tabs_panel' ) );
18
+
19
+ // Save custom tab data
20
+ add_action( 'woocommerce_process_product_meta', array( $this, 'product_save_data' ), 10, 2 );
21
+
22
+ // Enqueue our JS / CSS files
23
+ add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ), 10, 1 );
24
+
25
+ // Define our AJAX calls
26
+ add_action( 'wp_ajax_yikes_woo_get_wp_editor', array( $this, 'yikes_woo_get_wp_editor' ) );
27
+ add_action( 'wp_ajax_yikes_woo_save_product_tabs', array( $this, 'yikes_woo_save_product_tabs' ) );
28
+
29
+ // Duplicate any custom tabs when a product is duplicated
30
+ add_action( 'woocommerce_product_duplicate', array( $this, 'yikes_woo_dupe_custom_product_tabs' ), 10, 2 );
31
+ }
32
+
33
+
34
+ /**
35
+ * Enqueue all the required scripts and styles on the appropriate pages
36
+ *
37
+ * @param string | $hook | The current page slug
38
+ */
39
+ public function enqueue_scripts_and_styles( $hook ) {
40
+ global $post;
41
+ global $wp_version;
42
+ if ( $hook === 'post-new.php' || $hook === 'post.php' ) {
43
+ if ( isset( $post->post_type ) && $post->post_type === 'product' ) {
44
+
45
+ // Enqueue WordPress' built-in editor functions - added in WPv4.8
46
+ if ( function_exists( 'wp_enqueue_editor' ) ) {
47
+ wp_enqueue_editor();
48
+ }
49
+
50
+ // script
51
+ wp_enqueue_script ( 'repeatable-custom-tabs', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs.min.js' , array( 'jquery' ) , YIKES_Custom_Product_Tabs_Version );
52
+ wp_localize_script( 'repeatable-custom-tabs', 'repeatable_custom_tabs', array(
53
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
54
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
55
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
56
+ 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
57
+ 'fetch_reusable_tabs_nonce' => wp_create_nonce( 'yikes_woo_fetch_reusable_tabs_nonce' ),
58
+ 'fetch_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_fetch_reusable_tab_nonce' ),
59
+ 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' ),
60
+ 'save_product_tabs_nonce' => wp_create_nonce( 'yikes_woo_save_product_tabs_nonce' ),
61
+ 'global_post_id' => $post->ID,
62
+ 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
63
+ 'wp_version_four_eight' => $wp_version >= '4.8',
64
+ ) );
65
+
66
+ wp_enqueue_script ( 'repeatable-custom-tabs-shared', YIKES_Custom_Product_Tabs_URI . 'js/repeatable-custom-tabs-shared.min.js', array( 'jquery' ), YIKES_Custom_Product_Tabs_Version );
67
+ wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
68
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
69
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
70
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
71
+ 'get_wp_editor_failure_message' => __( 'Sorry! An error has occurred while trying to retrieve the editor. Please refresh the page and try again.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
72
+ ) );
73
+
74
+ // styles
75
+ wp_enqueue_style( 'repeatable-custom-tabs-styles' , YIKES_Custom_Product_Tabs_URI . 'css/repeatable-custom-tabs.min.css', '', YIKES_Custom_Product_Tabs_Version, 'all' );
76
+
77
+ // JS lity modal library and CSS
78
+ wp_enqueue_script( 'lity-js', YIKES_Custom_Product_Tabs_URI . 'js/lity.min.js' , array( 'jquery' ) , YIKES_Custom_Product_Tabs_Version );
79
+ wp_enqueue_style( 'lity-css', YIKES_Custom_Product_Tabs_URI . 'css/dist/lity.min.css' );
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Adds a new tab to the Product Data postbox in the admin product interface
86
+ */
87
+ public function render_custom_product_tabs() {
88
+ echo "<li class=\"yikes_wc_product_tabs_tab\"><a href=\"#yikes_woocommerce_custom_product_tabs\"><span>" . __( 'Custom Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . "</span></a></li>";
89
+ }
90
+
91
+
92
+ /**
93
+ * Adds the panel to the Product Data postbox in the product interface
94
+ */
95
+ public function product_page_yikes_custom_tabs_panel() {
96
+
97
+ // Require & instantiate our HTML class
98
+ require_once( YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-generate-html.php' );
99
+ $HTML = new Yikes_Woo_Custom_Product_Tabs_HTML();
100
+
101
+ // Call our function to generate the HTML
102
+ $HTML->generate_html();
103
+ }
104
+
105
+ /**
106
+ * Save the tab data.
107
+ *
108
+ * @param int | $post_id
109
+ * @param object | $post
110
+ */
111
+ public function product_save_data( $post_id, $post ) {
112
+
113
+ // Make sure we have a $post_id
114
+ if ( empty( $post_id ) ) {
115
+ return;
116
+ }
117
+
118
+ // Save our tabs!
119
+ $this->save_tabs( $post_id, $is_ajax = false );
120
+ }
121
+
122
+ /**
123
+ * Save the tabs to the database
124
+ *
125
+ * @since 1.5
126
+ *
127
+ * @param int | $post_id | The ID of the post that has custom tabs
128
+ * @param bool | $is_ajax_flag | A flag signifying whether we're calling this function from an AJAX call
129
+ */
130
+ protected function save_tabs( $post_id, $is_ajax_flag ) {
131
+ $tab_data = array();
132
+
133
+ $number_of_tabs = $_POST['number_of_tabs'];
134
+
135
+ // Create an array for tab_ids that we will use later
136
+ $current_saved_tab_id_array = array();
137
+ $remove_a_tab_from_reusable = false;
138
+
139
+ // Fetch the reusable tab options (we'll use this later)
140
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
141
+
142
+ // Check if this tab has reusable tabs and set flag
143
+ $post_has_reusable_tabs = false;
144
+ if ( isset ( $reusable_tab_options_array[$post_id] ) ) {
145
+ $post_has_reusable_tabs = true;
146
+ }
147
+
148
+ $i = 1;
149
+ while( $i <= $number_of_tabs ) {
150
+
151
+ // Deal with saving the tab content
152
+
153
+ $tab_title = isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i] ) ? stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i] ) : '';
154
+ $tab_content = isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i] ) ? stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i] ) : '';
155
+
156
+ if ( empty( $tab_title ) && empty( $tab_content ) ) {
157
+
158
+ // clean up if the custom tabs are removed
159
+ unset( $tab_data[$i] );
160
+
161
+ } else {
162
+
163
+ $tab_id = '';
164
+
165
+ if ( $tab_title ) {
166
+ $tab_id = urldecode( sanitize_title( $tab_title ) );
167
+ }
168
+
169
+ // push the data to the array
170
+ $tab_data[$i] = array( 'title' => $tab_title, 'id' => $tab_id, 'content' => $tab_content );
171
+ }
172
+
173
+ // Deal with saving / applying globally saved tabs
174
+
175
+ if ( isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i] ) && isset( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'] )
176
+ && ! empty( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i] ) && ! empty( $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'] ) ) {
177
+
178
+ // Store the tab_id and action
179
+ $reusable_tab_id = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i];
180
+ $reusable_tab_action = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'];
181
+
182
+ // If $reusable_tab_options_array is not empty, we've done this before
183
+ if ( ! empty( $reusable_tab_options_array ) ) {
184
+
185
+ // If action is 'add', add the tab!
186
+ if ( $reusable_tab_action === 'add' ) {
187
+
188
+ $reusable_tab_options_array[$post_id][$reusable_tab_id] = array(
189
+ 'post_id' => $post_id,
190
+ 'reusable_tab_id' => $reusable_tab_id,
191
+ 'tab_id' => $tab_id
192
+ );
193
+
194
+ // Update our applied tabs array
195
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
196
+
197
+ } elseif ( $reusable_tab_action === 'remove' ) {
198
+
199
+ // This tab will no longer be affected by the global/reusable tab changes
200
+ unset( $reusable_tab_options_array[$post_id][$reusable_tab_id] );
201
+
202
+ // Update our applied tabs array
203
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
204
+ }
205
+ } elseif ( $reusable_tab_action === 'add' ) {
206
+
207
+ // First time adding a new tab
208
+ $reusable_tab_options_array_to_save = array();
209
+ $reusable_tab_options_array_to_save[$post_id][$reusable_tab_id] = array(
210
+ 'post_id' => $post_id,
211
+ 'reusable_tab_id' => $reusable_tab_id,
212
+ 'tab_id' => $tab_id
213
+ );
214
+
215
+ // Update our applied tabs array
216
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array_to_save );
217
+ }
218
+
219
+
220
+ // Add this ID to our array of saved tab IDs
221
+ $current_saved_tab_id_array[] = $tab_id;
222
+ }
223
+
224
+ $i++;
225
+ }
226
+
227
+ // Let's check our $current_saved_tab_id_array and see if we need to remove any reusable tabs
228
+ if ( $post_has_reusable_tabs === true ) {
229
+
230
+ // If we have tabs...
231
+ if ( ! empty( $current_saved_tab_id_array ) ) {
232
+
233
+ // Loop through our reusable tab array
234
+ foreach( $reusable_tab_options_array[ $post_id ] as $id => $reusable_tab_array ) {
235
+
236
+ // If we find one of our reusable tabs is no longer part of this post, remove it
237
+ if ( ! in_array( $reusable_tab_array['tab_id'], $current_saved_tab_id_array ) ) {
238
+
239
+ unset( $reusable_tab_options_array[ $post_id ][ $id ] );
240
+ $remove_a_tab_from_reusable = true;
241
+ }
242
+ }
243
+ } else {
244
+
245
+ // If we don't have any current tabs then we need to delete this post's option
246
+ unset( $reusable_tab_options_array[ $post_id ] );
247
+ $remove_a_tab_from_reusable = true;
248
+ }
249
+
250
+ // If we removed a tab, then update our applied tabs array
251
+ if ( $remove_a_tab_from_reusable === true ) {
252
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
253
+ }
254
+ }
255
+
256
+ // Reset the array count, when items are removed
257
+ $tab_data = array_values( $tab_data );
258
+
259
+ // update the post data
260
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $tab_data );
261
+
262
+ if ( $is_ajax_flag === true ) {
263
+ return true;
264
+ } else {
265
+
266
+ // Fire off our Custom Product Tabs PRO action for taxonomy handling
267
+ do_action( 'yikes-woo-handle-tabs-on-product-save', $post_id );
268
+ }
269
+ }
270
+
271
+ /* AJAX Functions */
272
+
273
+ /**
274
+ * [AJAX] Return wp_editor HTML
275
+ * (this is a bit funky, I know, but it's part of dynamically adding / removing the WYSIWYG )
276
+ *
277
+ * @since 1.5
278
+ *
279
+ * @param string $_POST['textarea_id'] ID of the textarea that we're initializing wp_editor with
280
+ * @param string $_POST['tab_content'] content to pre-supply the text editor with
281
+ * @return string wp_editor HTML
282
+ */
283
+ public function yikes_woo_get_wp_editor() {
284
+
285
+ // Verify nonce
286
+ if ( ! check_ajax_referer( 'yikes_woo_get_wp_editor_nonce', 'security_nonce', false ) ) {
287
+ wp_send_json_error();
288
+ }
289
+
290
+ // Get & sanitize the $_POST var textarea_id
291
+ $textarea_id = filter_var( $_POST['textarea_id'], FILTER_SANITIZE_STRING );
292
+
293
+ // Check if we have tab content
294
+ $tab_content = isset( $_POST['tab_content'] ) ? $_POST['tab_content'] : '';
295
+
296
+ // Set up options
297
+ $wp_editor_options = array(
298
+ 'textarea_name' => $textarea_id,
299
+ 'textarea_rows' => 8,
300
+ );
301
+
302
+ // Return wp_editor HTML
303
+ wp_editor( stripslashes( $tab_content ), $textarea_id, $wp_editor_options );
304
+ exit;
305
+ }
306
+
307
+ /**
308
+ * [AJAX] Save all tabs for the current product
309
+ *
310
+ * @since 1.5
311
+ *
312
+ * @param string $_POST['post_id'] | ID of the current product (post)
313
+ * @param array $_POST['product_tabs'] | array of all the tab data
314
+ * @return object success w/ message || failure w/ message
315
+ */
316
+ public function yikes_woo_save_product_tabs() {
317
+
318
+ // Verify the nonce
319
+ if ( ! check_ajax_referer( 'yikes_woo_save_product_tabs_nonce', 'security_nonce', false ) ) {
320
+ wp_send_json_error();
321
+ }
322
+
323
+ // Get our product id
324
+ if ( isset( $_POST['post_id'] ) ) {
325
+ $post_id = filter_var( $_POST['post_id'], FILTER_SANITIZE_NUMBER_INT );
326
+ } else {
327
+
328
+ // Fail gracefully...
329
+ wp_send_json_error( array( 'message' => 'Could not find the product!' ) );
330
+ }
331
+
332
+ // Save our tabs!
333
+ $success = $this->save_tabs( $post_id, $is_ajax = true );
334
+
335
+ if ( $success === true ) {
336
+ wp_send_json_success( array( 'message' => 'Your tabs have been saved' ) );
337
+ } else {
338
+ wp_send_json_error( array( 'message' => 'Uh oh! Something went wrong with saving. Please try again.' ) );
339
+ }
340
+ }
341
+
342
+ /**
343
+ * When a WooCommere product is duplicated, check for and duplicate the custom tabs.
344
+ *
345
+ * @param object | $duplicated_product | The new, duplicated product
346
+ * @param object | $original_product | The original product
347
+ */
348
+ public function yikes_woo_dupe_custom_product_tabs( $duplicate_product, $original_product ) {
349
+ $old_post_id = method_exists( $original_product, 'get_id' ) === true ? $original_product->get_id() : $original_product->ID;
350
+ $new_post_id = method_exists( $duplicate_product, 'get_id' ) === true ? $duplicate_product->get_id() : $duplicate_product->ID;
351
+
352
+ $current_products_tabs = get_post_meta( $old_post_id, 'yikes_woo_products_tabs', true );
353
+
354
+ if ( ! empty( $current_products_tabs ) ) {
355
+ update_post_meta( $new_post_id, 'yikes_woo_products_tabs', $current_products_tabs );
356
+ }
357
+ }
358
+
359
+
360
+
361
+ }
362
+
363
+ new YIKES_Custom_Product_Tabs_Custom_Tabs();
364
+ }
365
+
admin/page.premium.php CHANGED
@@ -1,91 +1,91 @@
1
- <div class="wrap woo-ct-admin-page-wrap">
2
-
3
- <h1>
4
- <span class="dashicons dashicons-exerpt-view"></span>
5
- <?php _e( 'Custom Product Tabs for WooCommerce | Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
6
- </h1>
7
-
8
-
9
- <div class="cptpro-settings cptpro-settings-pro-container">
10
-
11
- <p>
12
- <a class="button button-primary" href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">
13
- <?php _e( 'Upgrade to Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
14
- </a>
15
- </p>
16
-
17
- <p>
18
- <?php
19
- echo sprintf( __( 'Upgrade to %1sCustom Product Tabs Pro%2s for complete control of Tabs and enhanced features.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
20
- '<a href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">', '</a>' );
21
- ?>
22
- </p>
23
-
24
- <p>
25
- <?php
26
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Global Tabs</strong> - Apply saved tabs to all of your products.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
27
- ?>
28
- </p>
29
-
30
- <p>
31
- <?php
32
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Category/Tag Tabs</strong> - Assign tabs to products by category or tag.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
33
- ?>
34
- </p>
35
-
36
- <p>
37
- <?php
38
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>WooCommerce Bulk Edit</strong> - Assign tabs to products via WooCommerce\'s bulk editor.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
39
- ?>
40
- </p>
41
-
42
- <p>
43
- <?php
44
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Search</strong> - Make tab content searchable by WordPress\' standard search or WooCommerce\'s search widget.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
45
- ?>
46
- </p>
47
-
48
- <p>
49
- <?php
50
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Premium Support</strong> - Get support via our form directly from your dashboard.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
51
- ?>
52
- </p>
53
-
54
- <p>
55
- <?php
56
- echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>And More!</strong>', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
57
- ?>
58
- </p>
59
-
60
- <ul id="lightslider">
61
- <li>
62
- <h3> <?php _e( 'Global Tabs & Taxonomy Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
63
-
64
- <p>
65
- <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-saved-tab.png' ?>" class="cptpro-image"/>
66
- <p><?php _e( 'Assign taxonomy terms to tabs or set tabs as global so they apply to all products.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
67
- </p>
68
- </li>
69
-
70
- <li>
71
- <h3> <?php _e( 'WooCommerce Bulk Edit', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
72
- <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-bulk-edit.png' ?>" class="cptpro-image"/>
73
- <p><?php _e( 'Assign saved tabs to products via the product\'s default bulk edit screen.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
74
- </li>
75
-
76
- <li>
77
- <h3> <?php _e( 'Settings', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
78
- <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-settings.png' ?>" class="cptpro-image"/>
79
- <p><?php _e( 'Remove the tab title from tab content site-wide without needing a filter', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
80
- <p><?php _e( 'Make WordPress\' and/or WooCommerce\'s search aware of Custom Product Tab information', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
81
- </li>
82
-
83
- <li>
84
- <h3> <?php _e( ' Premium Support', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
85
- <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-support-form.png' ?>" class="cptpro-image"/>
86
- <p><?php _e( 'Premium support with a ticket form accessible directly from your dashboard', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
87
- </li>
88
- </ul>
89
-
90
- </div>
91
  </div>
1
+ <div class="wrap woo-ct-admin-page-wrap">
2
+
3
+ <h1>
4
+ <span class="dashicons dashicons-exerpt-view"></span>
5
+ <?php _e( 'Custom Product Tabs for WooCommerce | Go Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
6
+ </h1>
7
+
8
+
9
+ <div class="cptpro-settings cptpro-settings-pro-container">
10
+
11
+ <p>
12
+ <a class="button button-primary" href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">
13
+ <?php _e( 'Upgrade to Pro', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
14
+ </a>
15
+ </p>
16
+
17
+ <p>
18
+ <?php
19
+ echo sprintf( __( 'Upgrade to %1sCustom Product Tabs Pro%2s for complete control of Tabs and enhanced features.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
20
+ '<a href="https://yikesplugins.com/plugin/custom-product-tabs-pro/" target="_blank">', '</a>' );
21
+ ?>
22
+ </p>
23
+
24
+ <p>
25
+ <?php
26
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Global Tabs</strong> - Apply saved tabs to all of your products.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
27
+ ?>
28
+ </p>
29
+
30
+ <p>
31
+ <?php
32
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Category/Tag Tabs</strong> - Assign tabs to products by category or tag.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
33
+ ?>
34
+ </p>
35
+
36
+ <p>
37
+ <?php
38
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>WooCommerce Bulk Edit</strong> - Assign tabs to products via WooCommerce\'s bulk editor.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
39
+ ?>
40
+ </p>
41
+
42
+ <p>
43
+ <?php
44
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Search</strong> - Make tab content searchable by WordPress\' standard search or WooCommerce\'s search widget.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
45
+ ?>
46
+ </p>
47
+
48
+ <p>
49
+ <?php
50
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>Premium Support</strong> - Get support via our form directly from your dashboard.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
51
+ ?>
52
+ </p>
53
+
54
+ <p>
55
+ <?php
56
+ echo sprintf( __( '<span class="dashicons dashicons-thumbs-up"></span> <strong>And More!</strong>', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) );
57
+ ?>
58
+ </p>
59
+
60
+ <ul id="lightslider">
61
+ <li>
62
+ <h3> <?php _e( 'Global Tabs & Taxonomy Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
63
+
64
+ <p>
65
+ <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-saved-tab.png' ?>" class="cptpro-image"/>
66
+ <p><?php _e( 'Assign taxonomy terms to tabs or set tabs as global so they apply to all products.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
67
+ </p>
68
+ </li>
69
+
70
+ <li>
71
+ <h3> <?php _e( 'WooCommerce Bulk Edit', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
72
+ <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-bulk-edit.png' ?>" class="cptpro-image"/>
73
+ <p><?php _e( 'Assign saved tabs to products via the product\'s default bulk edit screen.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
74
+ </li>
75
+
76
+ <li>
77
+ <h3> <?php _e( 'Settings', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
78
+ <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-settings.png' ?>" class="cptpro-image"/>
79
+ <p><?php _e( 'Remove the tab title from tab content site-wide without needing a filter', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
80
+ <p><?php _e( 'Make WordPress\' and/or WooCommerce\'s search aware of Custom Product Tab information', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
81
+ </li>
82
+
83
+ <li>
84
+ <h3> <?php _e( ' Premium Support', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </h3>
85
+ <img src="<?php echo YIKES_Custom_Product_Tabs_URI . 'images/cptpro-support-form.png' ?>" class="cptpro-image"/>
86
+ <p><?php _e( 'Premium support with a ticket form accessible directly from your dashboard', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </p>
87
+ </li>
88
+ </ul>
89
+
90
+ </div>
91
  </div>
admin/page.support.php CHANGED
@@ -1,15 +1,15 @@
1
- <div class="wrap woo-ct-admin-page-wrap">
2
-
3
- <!-- Title -->
4
- <h1>
5
- <span class="dashicons dashicons-exerpt-view"></span>
6
- <?php _e( 'Custom Product Tabs for WooCommerce | Support', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
7
- </h1>
8
-
9
- <!-- Free Support-content Hook -->
10
- <?php do_action( 'yikes-woo-support-page-free' ); ?>
11
-
12
- <!-- Pro Support-content Hook -->
13
- <?php do_action( 'yikes-woo-support-page-pro' ); ?>
14
-
15
  </div>
1
+ <div class="wrap woo-ct-admin-page-wrap">
2
+
3
+ <!-- Title -->
4
+ <h1>
5
+ <span class="dashicons dashicons-exerpt-view"></span>
6
+ <?php _e( 'Custom Product Tabs for WooCommerce | Support', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
7
+ </h1>
8
+
9
+ <!-- Free Support-content Hook -->
10
+ <?php do_action( 'yikes-woo-support-page-free' ); ?>
11
+
12
+ <!-- Pro Support-content Hook -->
13
+ <?php do_action( 'yikes-woo-support-page-pro' ); ?>
14
+
15
  </div>
admin/page.yikes-woo-saved-tabs-single.php CHANGED
@@ -1,103 +1,103 @@
1
- <?php
2
-
3
- // For safety purposes...
4
- // Make sure we have a tab
5
- if ( ! $new_tab && ( ! isset( $tab ) || empty( $tab ) ) ) {
6
- if ( isset( $redirect ) ) {
7
- echo '<p>';
8
- echo sprintf( __( 'It looks like something went wrong. Please %1sgo back%2s. and try again', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
9
- '<a href="' . $redirect . '" title="go back">', '</a>' );
10
- echo '</p>';
11
- }
12
- exit;
13
- }
14
-
15
- // Set variables before using them
16
- $tab_title = isset( $tab['tab_title'] ) && ! empty( $tab['tab_title'] ) ? $tab['tab_title'] : '';
17
- $tab_content = isset( $tab['tab_content'] ) && ! empty( $tab['tab_content'] ) ? $tab['tab_content'] : '';
18
- $tab_id = isset( $tab['tab_id'] ) && ! empty( $tab['tab_id'] ) ? (int) $tab['tab_id'] : 'new';
19
- $tab_name = isset( $tab['tab_name'] ) ? $tab['tab_name'] : '';
20
- $taxonomies = isset( $tab['taxonomies'] ) && ! empty( $tab['taxonomies'] ) ? $tab['taxonomies'] : '';
21
- $global = isset( $tab['global_tab'] ) && $tab['global_tab'] === true ? true : false;
22
-
23
- ?>
24
- <div class="wrap woo-ct-admin-page-wrap">
25
- <h1>
26
- <span class="dashicons dashicons-exerpt-view"></span>
27
- Custom Product Tabs for WooCommerce | <span id="yikes_woo_tab_title_header"><?php echo $tab_title; ?></span>
28
- <span class="yikes_woo_add_another_tab page-title-action" id="yikes_woo_add_another_tab">
29
- <a href="<?php echo $new_tab_url; ?>"> <?php _e( 'Add Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </a>
30
- </span>
31
- </h1>
32
-
33
- <div class="cptpro-settings cptpro-savedtabs-pro-container cptpro-savedtabs-single-pro-container <?php do_action( 'yikes-woo-saved-tabs-table-classes' ); ?>">
34
- <div class="yikes_woo_go_back_url">
35
- <span class="dashicons dashicons-arrow-left-alt"></span> <a href="<?php echo $redirect; ?>">
36
- <?php _e( 'Go Back to All Saved Tabs list', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
37
- </a>
38
- </div>
39
-
40
- <div id="poststuff">
41
-
42
- <?php if ( $new_tab !== true ) { ?>
43
- <!-- Only show this if we're updating an existing tab -->
44
- <div class="yikes_woo_settings_info">
45
- <p>
46
- <?php _e( "Any updates made here will apply to all products using this tab.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
47
- </p>
48
- </div>
49
- <?php } ?>
50
-
51
- <?php do_action( 'yikes-woo-display-too-many-products-warning' ); ?>
52
-
53
- <div class="row yikes_woo_reusable_tabs_container" id="yikes_woo_reusable_tabs_container_<?php echo $tab_id ?>" data-tab-id="<?php echo $tab_id; ?>">
54
-
55
- <!-- Title -->
56
- <div class="yikes_woo_reusable_tab_title">
57
- <label class="yikes_woo_reusable_tab_title_label" for="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>">
58
- <h3><?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
59
- </label>
60
- <input type="text" id="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>" value="<?php echo $tab_title; ?>" />
61
- </div>
62
-
63
- <!-- Tab Name -->
64
- <div class="yikes_woo_reusable_tab_title">
65
- <label class="yikes_woo_reusable_tab_title_label" for="yikes_woo_reusable_tab_name_<?php echo $tab_id; ?>">
66
- <h3><?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
67
- </label>
68
- <input type="text" id="yikes_woo_reusable_tab_name_<?php echo $tab_id; ?>" value="<?php echo $tab_name; ?>" />
69
- <div class="yikes_woo_reusable_tab_title_note"><?php _e( 'This is for your reference only.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></div>
70
- </div>
71
-
72
- <!-- Content -->
73
- <div class="yikes_woo_reusable_tab_content">
74
- <label class="yikes_woo_reusable_tab_content_label" for="yikes_woo_reusable_tab_content_<?php echo $tab_id; ?>">
75
- <h3><?php _e( 'Tab Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
76
- </label>
77
- <?php
78
- wp_editor( stripslashes( $tab_content ), 'yikes_woo_reusable_tab_content_' . $tab_id, array( 'textarea_name' => 'yikes_woo_reusable_tab_content_' . $tab_id, 'textarea_rows' => 8 ) );
79
- ?>
80
- </div>
81
-
82
- <?php do_action( 'yikes-woo-saved-tab-before-save-buttons', $saved_tab_id, $taxonomies, $global ); ?>
83
-
84
- <!-- Buttons -->
85
- <div class="yikes_woo_save_and_delete_tab_buttons">
86
- <span class="button button-primary yikes_woo_save_this_tab" id="yikes_woo_save_this_tab_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>">
87
- <?php _e( 'Save Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
88
- </span>
89
- <span class="button button-secondary yikes_woo_delete_this_tab yikes_woo_delete_this_tab_single" id="yikes_woo_delete_this_tab_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>">
90
- <i class="dashicons dashicons-dismiss inline-button-dashicons"></i>
91
- <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
92
- </span>
93
- </div>
94
-
95
- </div>
96
-
97
- <?php do_action( 'yikes-woo-saved-tab-after-save-buttons', $saved_tab_id ); ?>
98
- </div><!-- #poststuff -->
99
-
100
- </div>
101
-
102
- <?php do_action( 'yikes-woo-saved-tabs-list-ad' ); ?>
103
  </div>
1
+ <?php
2
+
3
+ // For safety purposes...
4
+ // Make sure we have a tab
5
+ if ( ! $new_tab && ( ! isset( $tab ) || empty( $tab ) ) ) {
6
+ if ( isset( $redirect ) ) {
7
+ echo '<p>';
8
+ echo sprintf( __( 'It looks like something went wrong. Please %1sgo back%2s. and try again', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
9
+ '<a href="' . $redirect . '" title="go back">', '</a>' );
10
+ echo '</p>';
11
+ }
12
+ exit;
13
+ }
14
+
15
+ // Set variables before using them
16
+ $tab_title = isset( $tab['tab_title'] ) && ! empty( $tab['tab_title'] ) ? $tab['tab_title'] : '';
17
+ $tab_content = isset( $tab['tab_content'] ) && ! empty( $tab['tab_content'] ) ? $tab['tab_content'] : '';
18
+ $tab_id = isset( $tab['tab_id'] ) && ! empty( $tab['tab_id'] ) ? (int) $tab['tab_id'] : 'new';
19
+ $tab_name = isset( $tab['tab_name'] ) ? $tab['tab_name'] : '';
20
+ $taxonomies = isset( $tab['taxonomies'] ) && ! empty( $tab['taxonomies'] ) ? $tab['taxonomies'] : '';
21
+ $global = isset( $tab['global_tab'] ) && $tab['global_tab'] === true ? true : false;
22
+
23
+ ?>
24
+ <div class="wrap woo-ct-admin-page-wrap">
25
+ <h1>
26
+ <span class="dashicons dashicons-exerpt-view"></span>
27
+ Custom Product Tabs for WooCommerce | <span id="yikes_woo_tab_title_header"><?php echo $tab_title; ?></span>
28
+ <span class="yikes_woo_add_another_tab page-title-action" id="yikes_woo_add_another_tab">
29
+ <a href="<?php echo $new_tab_url; ?>"> <?php _e( 'Add Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </a>
30
+ </span>
31
+ </h1>
32
+
33
+ <div class="cptpro-settings cptpro-savedtabs-pro-container cptpro-savedtabs-single-pro-container <?php do_action( 'yikes-woo-saved-tabs-table-classes' ); ?>">
34
+ <div class="yikes_woo_go_back_url">
35
+ <span class="dashicons dashicons-arrow-left-alt"></span> <a href="<?php echo $redirect; ?>">
36
+ <?php _e( 'Go Back to All Saved Tabs list', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
37
+ </a>
38
+ </div>
39
+
40
+ <div id="poststuff">
41
+
42
+ <?php if ( $new_tab !== true ) { ?>
43
+ <!-- Only show this if we're updating an existing tab -->
44
+ <div class="yikes_woo_settings_info">
45
+ <p>
46
+ <?php _e( "Any updates made here will apply to all products using this tab.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
47
+ </p>
48
+ </div>
49
+ <?php } ?>
50
+
51
+ <?php do_action( 'yikes-woo-display-too-many-products-warning' ); ?>
52
+
53
+ <div class="row yikes_woo_reusable_tabs_container" id="yikes_woo_reusable_tabs_container_<?php echo $tab_id ?>" data-tab-id="<?php echo $tab_id; ?>">
54
+
55
+ <!-- Title -->
56
+ <div class="yikes_woo_reusable_tab_title">
57
+ <label class="yikes_woo_reusable_tab_title_label" for="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>">
58
+ <h3><?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
59
+ </label>
60
+ <input type="text" id="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>" value="<?php echo $tab_title; ?>" />
61
+ </div>
62
+
63
+ <!-- Tab Name -->
64
+ <div class="yikes_woo_reusable_tab_title">
65
+ <label class="yikes_woo_reusable_tab_title_label" for="yikes_woo_reusable_tab_name_<?php echo $tab_id; ?>">
66
+ <h3><?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
67
+ </label>
68
+ <input type="text" id="yikes_woo_reusable_tab_name_<?php echo $tab_id; ?>" value="<?php echo $tab_name; ?>" />
69
+ <div class="yikes_woo_reusable_tab_title_note"><?php _e( 'This is for your reference only.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></div>
70
+ </div>
71
+
72
+ <!-- Content -->
73
+ <div class="yikes_woo_reusable_tab_content">
74
+ <label class="yikes_woo_reusable_tab_content_label" for="yikes_woo_reusable_tab_content_<?php echo $tab_id; ?>">
75
+ <h3><?php _e( 'Tab Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
76
+ </label>
77
+ <?php
78
+ wp_editor( stripslashes( $tab_content ), 'yikes_woo_reusable_tab_content_' . $tab_id, array( 'textarea_name' => 'yikes_woo_reusable_tab_content_' . $tab_id, 'textarea_rows' => 8 ) );
79
+ ?>
80
+ </div>
81
+
82
+ <?php do_action( 'yikes-woo-saved-tab-before-save-buttons', $saved_tab_id, $taxonomies, $global ); ?>
83
+
84
+ <!-- Buttons -->
85
+ <div class="yikes_woo_save_and_delete_tab_buttons">
86
+ <span class="button button-primary yikes_woo_save_this_tab" id="yikes_woo_save_this_tab_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>">
87
+ <?php _e( 'Save Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
88
+ </span>
89
+ <span class="button button-secondary yikes_woo_delete_this_tab yikes_woo_delete_this_tab_single" id="yikes_woo_delete_this_tab_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>">
90
+ <i class="dashicons dashicons-dismiss inline-button-dashicons"></i>
91
+ <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
92
+ </span>
93
+ </div>
94
+
95
+ </div>
96
+
97
+ <?php do_action( 'yikes-woo-saved-tab-after-save-buttons', $saved_tab_id ); ?>
98
+ </div><!-- #poststuff -->
99
+
100
+ </div>
101
+
102
+ <?php do_action( 'yikes-woo-saved-tabs-list-ad' ); ?>
103
  </div>
admin/page.yikes-woo-saved-tabs.php CHANGED
@@ -1,147 +1,147 @@
1
- <div class="wrap woo-ct-admin-page-wrap">
2
-
3
- <h1>
4
- <span class="dashicons dashicons-exerpt-view"></span>
5
- <?php echo __( 'Custom Product Tabs for WooCommerce | Saved Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
6
- <span class="yikes_woo_add_another_tab page-title-action" id="yikes_woo_add_another_tab">
7
- <a href="<?php echo $new_tab_url; ?>"> <?php _e( 'Add Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </a>
8
- </span>
9
- </h1>
10
-
11
- <div class="cptpro-settings cptpro-savedtabs-pro-container <?php do_action( 'yikes-woo-saved-tabs-table-classes' ); ?>">
12
-
13
- <!-- Delete-success Message -->
14
- <div id="yikes_woo_delete_success_message" class="deleted notice notice-success is-dismissible" style="<?php echo $delete_message_display ?>">
15
- <p>
16
- <?php _e( 'Tab deleted!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
17
- </p>
18
- <button type="button" class="notice-dismiss">
19
- <span class="screen-reader-text">Dismiss this notice.</span>
20
- </button>
21
- </div>
22
-
23
- <div class="yikes_woo_settings_info">
24
- <p>
25
- <?php _e( "Create and save tabs you can add to multiple products.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
26
- </p>
27
- </div>
28
-
29
- <?php do_action( 'yikes-woo-display-too-many-products-warning' ); ?>
30
-
31
- <div id="poststuff" class="yikes-saved-tabs-row">
32
-
33
- <!-- Bulk Actions -->
34
- <div class="tablenav top">
35
- <div class="alignleft actions bulkactions">
36
- <label for="bulk-action-selector-top" class="screen-reader-text"><?php _e( 'Select bulk action', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
37
- <select name="action" id="bulk-action-selector-top">
38
- <option value="-1"><?php _e( 'Bulk Actions', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
39
- <option value="delete" class="hide-if-no-js"><?php _e( 'Delete', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
40
- </select>
41
- <input type="button" id="bulk-action-button" class="button action yikes_woo_handle_bulk_action" value="<?php _e( 'Apply', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ?>">
42
- </div>
43
- <br class="clear">
44
- </div>
45
- <table id="yikes-woo-saved-tabs-list-table" class="widefat fixed" cellspacing="0">
46
- <thead>
47
- <tr>
48
- <td id="cb" class="manage-column column-cb check-column" scope="col">
49
- <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
50
- <input id="cb-select-all-1" type="checkbox">
51
- </td>
52
- <th class="manage-column column-tab-title" scope="col">
53
- <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
54
- </th>
55
- <th class="manage-column column-tab-name" scope="col">
56
- <?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
57
- </th>
58
- <th class="manage-column column-tab-content-preview" scope="col">
59
- <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
60
- </th>
61
- <?php do_action( 'yikes-woo-saved-tabs-table-header' ); ?>
62
- <th class="manage-column column-edit" scope="col">&nbsp;</th>
63
- </tr>
64
- </thead>
65
-
66
- <tfoot>
67
- <tr>
68
- <td id="cb" class="manage-column column-cb check-column" scope="col">
69
- <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
70
- <input id="cb-select-all-1" type="checkbox">
71
- </td>
72
- <th class="manage-column column-title" scope="col">
73
- <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
74
- </th>
75
- <th class="manage-column column-name" scope="col">
76
- <?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
77
- </th>
78
- <th class="manage-column column-content" scope="col">
79
- <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
80
- </th>
81
- <?php do_action( 'yikes-woo-saved-tabs-table-header' ); ?>
82
- <th class="manage-column column-edit" scope="col">&nbsp;</th>
83
- </tr>
84
- </tfoot>
85
-
86
- <tbody id="yikes-woo-saved-tabs-list-tbody">
87
- <?php
88
- if( ! empty( $yikes_custom_tab_data ) ) {
89
-
90
- $yikes_custom_tab_data = apply_filters( 'yikes_woo_reorder_saved_tabs', $yikes_custom_tab_data );
91
- $tab_order = 1;
92
-
93
- foreach ( $yikes_custom_tab_data as $key => $tab_data ) {
94
-
95
- // Set variables before using them.
96
- $tab_title = isset( $tab_data['tab_title'] ) && ! empty( $tab_data['tab_title'] ) ? $tab_data['tab_title'] : '';
97
- $tab_name = isset( $tab_data['tab_name'] ) ? $tab_data['tab_name'] : '';
98
- $tab_content_excerpt = isset( $tab_data['tab_content'] ) && ! empty( $tab_data['tab_content'] ) ? stripslashes( substr( wp_strip_all_tags( $tab_data['tab_content'] ), 0, 150 ) ) : '';
99
- $tab_id = isset( $tab_data['tab_id'] ) && ! empty( $tab_data['tab_id'] ) ? (int) $tab_data['tab_id'] : 0;
100
- $edit_tab_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => $tab_id ), admin_url() ) );
101
- ?>
102
- <tr class="yikes_woo_saved_tabs_row" id="yikes_woo_saved_tabs_row_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>" data-order="<?php echo esc_attr( $tab_order ); ?>">
103
- <th class="check-column" scope="row">
104
- <input class="entry-bulk-action-checkbox" type="checkbox" value="<?php echo $tab_id; ?>" />
105
- </th>
106
- <td class="column-title">
107
- <?php echo $tab_title; ?>
108
- <div class="row-actions">
109
- <span class="">
110
- <a href="<?php echo $edit_tab_url ?>"><?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
111
- </span> |
112
- <span data-tab-id="<?php echo $tab_id; ?>" class="yikes_woo_delete_this_tab trash">
113
- <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
114
- </span>
115
- </div>
116
- </td>
117
- <td class="column-name"><?php echo $tab_name; ?></td>
118
- <td class="column-content"><?php echo $tab_content_excerpt; ?></td>
119
- <?php do_action( 'yikes-woo-saved-tabs-table-column', $tab_data ); ?>
120
- <td class="column-edit" align="center">
121
- <a href="<?php echo $edit_tab_url ?>" class="button-secondary view-saved-tab-button" data-entry-id="<?php echo (int) $tab_id; ?>">
122
- <?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
123
- </a>
124
- </td>
125
- </tr>
126
- <?php
127
- $tab_order++;
128
- }
129
- } else {
130
- ?>
131
- <tr>
132
- <td class="column-columnname" colspan="5">
133
- <strong><?php _e( 'There are no saved tabs. Add one!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </strong>
134
- </td>
135
- </tr>
136
- <?php
137
- }
138
- ?>
139
- </tbody>
140
- </table>
141
- </div>
142
-
143
- </div>
144
-
145
- <?php do_action( 'yikes-woo-saved-tabs-list-ad' ); ?>
146
-
147
  </div>
1
+ <div class="wrap woo-ct-admin-page-wrap">
2
+
3
+ <h1>
4
+ <span class="dashicons dashicons-exerpt-view"></span>
5
+ <?php echo __( 'Custom Product Tabs for WooCommerce | Saved Tabs', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
6
+ <span class="yikes_woo_add_another_tab page-title-action" id="yikes_woo_add_another_tab">
7
+ <a href="<?php echo $new_tab_url; ?>"> <?php _e( 'Add Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </a>
8
+ </span>
9
+ </h1>
10
+
11
+ <div class="cptpro-settings cptpro-savedtabs-pro-container <?php do_action( 'yikes-woo-saved-tabs-table-classes' ); ?>">
12
+
13
+ <!-- Delete-success Message -->
14
+ <div id="yikes_woo_delete_success_message" class="deleted notice notice-success is-dismissible" style="<?php echo $delete_message_display ?>">
15
+ <p>
16
+ <?php _e( 'Tab deleted!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
17
+ </p>
18
+ <button type="button" class="notice-dismiss">
19
+ <span class="screen-reader-text">Dismiss this notice.</span>
20
+ </button>
21
+ </div>
22
+
23
+ <div class="yikes_woo_settings_info">
24
+ <p>
25
+ <?php _e( "Create and save tabs you can add to multiple products.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
26
+ </p>
27
+ </div>
28
+
29
+ <?php do_action( 'yikes-woo-display-too-many-products-warning' ); ?>
30
+
31
+ <div id="poststuff" class="yikes-saved-tabs-row">
32
+
33
+ <!-- Bulk Actions -->
34
+ <div class="tablenav top">
35
+ <div class="alignleft actions bulkactions">
36
+ <label for="bulk-action-selector-top" class="screen-reader-text"><?php _e( 'Select bulk action', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
37
+ <select name="action" id="bulk-action-selector-top">
38
+ <option value="-1"><?php _e( 'Bulk Actions', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
39
+ <option value="delete" class="hide-if-no-js"><?php _e( 'Delete', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
40
+ </select>
41
+ <input type="button" id="bulk-action-button" class="button action yikes_woo_handle_bulk_action" value="<?php _e( 'Apply', 'yikes-inc-easy-custom-woocommerce-product-tabs' ) ?>">
42
+ </div>
43
+ <br class="clear">
44
+ </div>
45
+ <table id="yikes-woo-saved-tabs-list-table" class="widefat fixed" cellspacing="0">
46
+ <thead>
47
+ <tr>
48
+ <td id="cb" class="manage-column column-cb check-column" scope="col">
49
+ <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
50
+ <input id="cb-select-all-1" type="checkbox">
51
+ </td>
52
+ <th class="manage-column column-tab-title" scope="col">
53
+ <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
54
+ </th>
55
+ <th class="manage-column column-tab-name" scope="col">
56
+ <?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
57
+ </th>
58
+ <th class="manage-column column-tab-content-preview" scope="col">
59
+ <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
60
+ </th>
61
+ <?php do_action( 'yikes-woo-saved-tabs-table-header' ); ?>
62
+ <th class="manage-column column-edit" scope="col">&nbsp;</th>
63
+ </tr>
64
+ </thead>
65
+
66
+ <tfoot>
67
+ <tr>
68
+ <td id="cb" class="manage-column column-cb check-column" scope="col">
69
+ <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
70
+ <input id="cb-select-all-1" type="checkbox">
71
+ </td>
72
+ <th class="manage-column column-title" scope="col">
73
+ <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
74
+ </th>
75
+ <th class="manage-column column-name" scope="col">
76
+ <?php _e( 'Tab Name', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
77
+ </th>
78
+ <th class="manage-column column-content" scope="col">
79
+ <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
80
+ </th>
81
+ <?php do_action( 'yikes-woo-saved-tabs-table-header' ); ?>
82
+ <th class="manage-column column-edit" scope="col">&nbsp;</th>
83
+ </tr>
84
+ </tfoot>
85
+
86
+ <tbody id="yikes-woo-saved-tabs-list-tbody">
87
+ <?php
88
+ if( ! empty( $yikes_custom_tab_data ) ) {
89
+
90
+ $yikes_custom_tab_data = apply_filters( 'yikes_woo_reorder_saved_tabs', $yikes_custom_tab_data );
91
+ $tab_order = 1;
92
+
93
+ foreach ( $yikes_custom_tab_data as $key => $tab_data ) {
94
+
95
+ // Set variables before using them.
96
+ $tab_title = isset( $tab_data['tab_title'] ) && ! empty( $tab_data['tab_title'] ) ? $tab_data['tab_title'] : '';
97
+ $tab_name = isset( $tab_data['tab_name'] ) ? $tab_data['tab_name'] : '';
98
+ $tab_content_excerpt = isset( $tab_data['tab_content'] ) && ! empty( $tab_data['tab_content'] ) ? stripslashes( substr( wp_strip_all_tags( $tab_data['tab_content'] ), 0, 150 ) ) : '';
99
+ $tab_id = isset( $tab_data['tab_id'] ) && ! empty( $tab_data['tab_id'] ) ? (int) $tab_data['tab_id'] : 0;
100
+ $edit_tab_url = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page, 'saved-tab-id' => $tab_id ), admin_url() ) );
101
+ ?>
102
+ <tr class="yikes_woo_saved_tabs_row" id="yikes_woo_saved_tabs_row_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>" data-order="<?php echo esc_attr( $tab_order ); ?>">
103
+ <th class="check-column" scope="row">
104
+ <input class="entry-bulk-action-checkbox" type="checkbox" value="<?php echo $tab_id; ?>" />
105
+ </th>
106
+ <td class="column-title">
107
+ <?php echo $tab_title; ?>
108
+ <div class="row-actions">
109
+ <span class="">
110
+ <a href="<?php echo $edit_tab_url ?>"><?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
111
+ </span> |
112
+ <span data-tab-id="<?php echo $tab_id; ?>" class="yikes_woo_delete_this_tab trash">
113
+ <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
114
+ </span>
115
+ </div>
116
+ </td>
117
+ <td class="column-name"><?php echo $tab_name; ?></td>
118
+ <td class="column-content"><?php echo $tab_content_excerpt; ?></td>
119
+ <?php do_action( 'yikes-woo-saved-tabs-table-column', $tab_data ); ?>
120
+ <td class="column-edit" align="center">
121
+ <a href="<?php echo $edit_tab_url ?>" class="button-secondary view-saved-tab-button" data-entry-id="<?php echo (int) $tab_id; ?>">
122
+ <?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
123
+ </a>
124
+ </td>
125
+ </tr>
126
+ <?php
127
+ $tab_order++;
128
+ }
129
+ } else {
130
+ ?>
131
+ <tr>
132
+ <td class="column-columnname" colspan="5">
133
+ <strong><?php _e( 'There are no saved tabs. Add one!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </strong>
134
+ </td>
135
+ </tr>
136
+ <?php
137
+ }
138
+ ?>
139
+ </tbody>
140
+ </table>
141
+ </div>
142
+
143
+ </div>
144
+
145
+ <?php do_action( 'yikes-woo-saved-tabs-list-ad' ); ?>
146
+
147
  </div>
css/dist/lity.min.css CHANGED
@@ -1,3 +1,3 @@
1
- /*! Lity - v3.0.0-dev - 2016-11-04
2
- * http://sorgalla.com/lity/
3
  * Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */.lity{z-index:9990;position:fixed;top:0;right:0;bottom:0;left:0;white-space:nowrap;background:#0b0b0b;background:rgba(0,0,0,.9);outline:none!important;opacity:0;-webkit-transition:opacity .3s ease;transition:opacity .3s ease}.lity.lity-opened{opacity:1}.lity.lity-closed{opacity:0}.lity *{box-sizing:border-box}.lity-wrap{z-index:9990;position:fixed;top:0;right:0;bottom:0;left:0;text-align:center;outline:none!important}.lity-wrap:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em}.lity-loader{z-index:9991;color:#fff;position:absolute;top:50%;margin-top:-.8em;width:100%;text-align:center;font-size:14px;font-family:Arial,Helvetica,sans-serif;opacity:0;-webkit-transition:opacity .3s ease;transition:opacity .3s ease}.lity-loading .lity-loader{opacity:1}.lity-container{overflow: auto;z-index:9992;position:relative;text-align:left;vertical-align:middle;display:inline-block;white-space:normal;max-width:100%;max-height:100%;outline:none!important}.lity-content{z-index:9993;width:100%;-webkit-transform:scale(1);transform:scale(1);-webkit-transition:-webkit-transform .3s ease;transition:-webkit-transform .3s ease;transition:transform .3s ease;transition:transform .3s ease,-webkit-transform .3s ease}.lity-closed .lity-content,.lity-loading .lity-content{-webkit-transform:scale(.8);transform:scale(.8)}.lity-content:after{content:'';position:absolute;left:0;top:0;bottom:0;display:block;right:0;width:auto;height:auto;z-index:-1;box-shadow:0 0 8px rgba(0,0,0,.6)}.lity-close{z-index:9994;width:35px;height:35px;position:fixed;right:0;top:0;-webkit-appearance:none;cursor:pointer;text-decoration:none;text-align:center;padding:0;color:#fff;font-style:normal;font-size:35px;font-family:Arial,Baskerville,monospace;line-height:35px;text-shadow:0 1px 2px rgba(0,0,0,.6);border:0;background:none;outline:none;box-shadow:none}.lity-close::-moz-focus-inner{border:0;padding:0}.lity-close:active,.lity-close:focus,.lity-close:hover,.lity-close:visited{text-decoration:none;text-align:center;padding:0;color:#fff;font-style:normal;font-size:35px;font-family:Arial,Baskerville,monospace;line-height:35px;text-shadow:0 1px 2px rgba(0,0,0,.6);border:0;background:none;outline:none;box-shadow:none}.lity-close:active{top:1px}.lity-image img{max-width:100%;display:block;line-height:0;border:0}.lity-iframe .lity-container{width:100%;max-width:964px}.lity-iframe-container{width:100%;height:0;padding-top:56.25%;overflow:auto;pointer-events:auto;-webkit-transform:translateZ(0);transform:translateZ(0);-webkit-overflow-scrolling:touch}.lity-iframe-container iframe{position:absolute;display:block;top:0;left:0;width:100%;height:100%;box-shadow:0 0 8px rgba(0,0,0,.6);background:#000}.lity-hide{display:none}
1
+ /*! Lity - v3.0.0-dev - 2016-11-04
2
+ * http://sorgalla.com/lity/
3
  * Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */.lity{z-index:9990;position:fixed;top:0;right:0;bottom:0;left:0;white-space:nowrap;background:#0b0b0b;background:rgba(0,0,0,.9);outline:none!important;opacity:0;-webkit-transition:opacity .3s ease;transition:opacity .3s ease}.lity.lity-opened{opacity:1}.lity.lity-closed{opacity:0}.lity *{box-sizing:border-box}.lity-wrap{z-index:9990;position:fixed;top:0;right:0;bottom:0;left:0;text-align:center;outline:none!important}.lity-wrap:before{content:'';display:inline-block;height:100%;vertical-align:middle;margin-right:-.25em}.lity-loader{z-index:9991;color:#fff;position:absolute;top:50%;margin-top:-.8em;width:100%;text-align:center;font-size:14px;font-family:Arial,Helvetica,sans-serif;opacity:0;-webkit-transition:opacity .3s ease;transition:opacity .3s ease}.lity-loading .lity-loader{opacity:1}.lity-container{overflow: auto;z-index:9992;position:relative;text-align:left;vertical-align:middle;display:inline-block;white-space:normal;max-width:100%;max-height:100%;outline:none!important}.lity-content{z-index:9993;width:100%;-webkit-transform:scale(1);transform:scale(1);-webkit-transition:-webkit-transform .3s ease;transition:-webkit-transform .3s ease;transition:transform .3s ease;transition:transform .3s ease,-webkit-transform .3s ease}.lity-closed .lity-content,.lity-loading .lity-content{-webkit-transform:scale(.8);transform:scale(.8)}.lity-content:after{content:'';position:absolute;left:0;top:0;bottom:0;display:block;right:0;width:auto;height:auto;z-index:-1;box-shadow:0 0 8px rgba(0,0,0,.6)}.lity-close{z-index:9994;width:35px;height:35px;position:fixed;right:0;top:0;-webkit-appearance:none;cursor:pointer;text-decoration:none;text-align:center;padding:0;color:#fff;font-style:normal;font-size:35px;font-family:Arial,Baskerville,monospace;line-height:35px;text-shadow:0 1px 2px rgba(0,0,0,.6);border:0;background:none;outline:none;box-shadow:none}.lity-close::-moz-focus-inner{border:0;padding:0}.lity-close:active,.lity-close:focus,.lity-close:hover,.lity-close:visited{text-decoration:none;text-align:center;padding:0;color:#fff;font-style:normal;font-size:35px;font-family:Arial,Baskerville,monospace;line-height:35px;text-shadow:0 1px 2px rgba(0,0,0,.6);border:0;background:none;outline:none;box-shadow:none}.lity-close:active{top:1px}.lity-image img{max-width:100%;display:block;line-height:0;border:0}.lity-iframe .lity-container{width:100%;max-width:964px}.lity-iframe-container{width:100%;height:0;padding-top:56.25%;overflow:auto;pointer-events:auto;-webkit-transform:translateZ(0);transform:translateZ(0);-webkit-overflow-scrolling:touch}.lity-iframe-container iframe{position:absolute;display:block;top:0;left:0;width:100%;height:100%;box-shadow:0 0 8px rgba(0,0,0,.6);background:#000}.lity-hide{display:none}
js/lity.min.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! Lity - v3.0.0-dev - 2016-11-04
2
- * http://sorgalla.com/lity/
3
- * Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */
4
  !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(c){return b(a,c)}):"object"==typeof module&&"object"==typeof module.exports?module.exports=b(a,require("jquery")):a.lity=b(a,a.jQuery||a.Zepto)}("undefined"!=typeof window?window:this,function(a,b){"use strict";function c(a){var b=C();return O&&a.length?(a.one(O,b.resolve),setTimeout(b.resolve,500)):b.resolve(),b.promise()}function d(a,c,d){if(1===arguments.length)return b.extend({},a);if("string"==typeof c){if("undefined"==typeof d)return"undefined"==typeof a[c]?null:a[c];a[c]=d}else b.extend(a,c);return this}function e(a){var b=a.indexOf("?");b>-1&&(a=a.substr(b+1));for(var c,d=decodeURI(a.split("#")[0]).split("&"),e={},f=0,g=d.length;f<g;f++)d[f]&&(c=d[f].split("="),e[c[0]]=c[1]);return e}function f(a,c){if(!c)return a;if("string"===b.type(c)&&(c=e(c)),a.indexOf("?")>-1){var d=a.split("?");a=d.shift(),c=b.extend({},e(d[0]),c)}return a+"?"+b.param(c)}function g(a,b){var c=a.indexOf("#");return-1===c?b:(c>0&&(a=a.substr(c)),b+a)}function h(a,b,c,d){return b&&b.element().addClass("lity-iframe"),c&&(a=f(a,c)),d&&(a=g(d,a)),'<div class="lity-iframe-container"><iframe frameborder="0" allowfullscreen src="'+a+'"/></div>'}function i(a){return b('<span class="lity-error"/>').append(a)}function j(a,c){var d=c.opener()&&c.opener().data("lity-desc")||"Image with no description",e=b('<img src="'+a+'" alt="'+d+'"/>'),f=C(),g=function(){f.reject(i("Failed loading image"))};return e.on("load",function(){return 0===this.naturalWidth?g():void f.resolve(e)}).on("error",g),f.promise()}function k(a,c){var d,e,f;try{d=b(a)}catch(a){return!1}return!!d.length&&(e=b('<i style="display:none !important"/>'),f=d.hasClass("lity-hide"),c.element().one("lity:remove",function(){e.before(d).remove(),f&&!d.closest(".lity-content").length&&d.addClass("lity-hide")}),d.removeClass("lity-hide").after(e))}function l(a,b){var c=K.exec(a);return!!c&&h("https://www.youtube"+(c[2]||"")+".com/embed/"+c[4]+"?autoplay=1",b,c[5],a)}function m(a,b){var c=L.exec(a);return!!c&&h("https://player.vimeo.com/video/"+c[3]+"?autoplay=1",b,c[4],a)}function n(a,b){var c=N.exec(a);return!!c&&(0!==a.indexOf("http")&&(a="https:"+a),h("https://www.facebook.com/plugins/video.php?href="+a+"&autoplay=1",b,c[4],a))}function o(a,b){var c=M.exec(a);return!!c&&h("https://www.google."+c[3]+"/maps?"+c[6],b,{output:c[6].indexOf("layer=c")>0?"svembed":"embed"},a)}function p(a,b){return h(a,b)}function q(){return A.documentElement.clientHeight?A.documentElement.clientHeight:Math.round(B.height())}function r(a){var b=w();b&&(27===a.keyCode&&b.close(),9===a.keyCode&&s(a,b))}function s(a,b){var c=b.element().find(H),d=c.index(A.activeElement);a.shiftKey&&d<=0?(c.get(c.length-1).focus(),a.preventDefault()):a.shiftKey||d!==c.length-1||(c.get(0).focus(),a.preventDefault())}function t(){b.each(E,function(a,b){b.resize()})}function u(a){1===E.unshift(a)&&(D.addClass("lity-active"),B.on({resize:t,keydown:r})),b("body > *").not(a.element()).addClass("lity-hidden").each(function(){var a=b(this);void 0===a.data(G)&&a.data(G,a.attr(F)||null)}).attr(F,"true")}function v(a){var c;a.element().attr(F,"true"),1===E.length&&(D.removeClass("lity-active"),B.off({resize:t,keydown:r})),E=b.grep(E,function(b){return a!==b}),c=E.length?E[0].element():b(".lity-hidden"),c.removeClass("lity-hidden").each(function(){var a=b(this),c=a.data(G);c?a.attr(F,c):a.removeAttr(F),a.removeData(G)})}function w(){return 0===E.length?null:E[0]}function x(a,c,d,e){var f,g="inline",h=b.extend({},d);return e&&h[e]?(f=h[e](a,c),g=e):(b.each(["inline","iframe"],function(a,b){delete h[b],h[b]=d[b]}),b.each(h,function(b,d){return!d||(!(!d.test||d.test(a,c))||(f=d(a,c),!1!==f?(g=b,!1):void 0))})),{handler:g,content:f||""}}function y(a,e,f,g){function h(a){k=b(a).css("max-height",q()+"px"),j.find(".lity-loader").each(function(){var a=b(this);c(a).always(function(){a.remove()})}),j.removeClass("lity-loading").find(".lity-content").empty().append(k),m=!0,k.trigger("lity:ready",[l])}var i,j,k,l=this,m=!1,n=!1;e=b.extend({},I,e),j=b(e.template),l.element=function(){return j},l.opener=function(){return f},l.content=function(){return k},l.options=b.proxy(d,l,e),l.handlers=b.proxy(d,l,e.handlers),l.resize=function(){m&&!n&&k.css("max-height",q()+"px").trigger("lity:resize",[l])},l.close=function(){if(m&&!n){n=!0,v(l);var a=C();return g&&b.contains(j[0],A.activeElement)&&g.focus(),k.trigger("lity:close",[l]),j.removeClass("lity-opened").addClass("lity-closed"),c(k.add(j)).always(function(){k.trigger("lity:remove",[l]),j.remove(),j=void 0,a.resolve()}),a.promise()}},i=x(a,l,e.handlers,e.handler),j.attr(F,"false").addClass("lity-loading lity-opened lity-"+i.handler).appendTo("body").focus().on("click","[data-lity-close]",function(a){b(a.target).is("[data-lity-close]")&&l.close()}).trigger("lity:open",[l]),u(l),b.when(i.content).always(h)}function z(a,c,d){a.preventDefault?(a.preventDefault(),d=b(this),a=d.data("lity-target")||d.attr("href")||d.attr("src")):d=b(d);var e=new y(a,b.extend({},d.data("lity-options")||d.data("lity"),c),d,A.activeElement);if(!a.preventDefault)return e}var A=a.document,B=b(a),C=b.Deferred,D=b("html"),E=[],F="aria-hidden",G="lity-"+F,H='a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,[contenteditable],[tabindex]:not([tabindex^="-"])',I={handler:null,handlers:{image:j,inline:k,youtube:l,vimeo:m,googlemaps:o,facebookvideo:n,iframe:p},template:'<div class="lity" role="dialog" aria-label="Dialog Window (Press escape to close)" tabindex="-1"><div class="lity-wrap" data-lity-close role="document"><div class="lity-loader" aria-hidden="true">Loading...</div><div class="lity-container"><div class="lity-content"></div><button class="lity-close" type="button" aria-label="Close (Press escape to close)" data-lity-close>&times;</button></div></div></div>'},J=/(^data:image\/)|(\.(png|jpe?g|gif|svg|webp|bmp|ico|tiff?)(\?\S*)?$)/i,K=/(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i,L=/(vimeo(pro)?\.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/,M=/((maps|www)\.)?google\.([^\/\?]+)\/?((maps\/?)?\?)(.*)/i,N=/(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i,O=function(){var a=A.createElement("div"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return b[c];return!1}();return j.test=function(a){return J.test(a)},z.version="3.0.0-dev",z.options=b.proxy(d,z,I),z.handlers=b.proxy(d,z,I.handlers),z.current=w,z.iframe=h,b(A).on("click.lity","[data-lity]",z),z});
1
+ /*! Lity - v3.0.0-dev - 2016-11-04
2
+ * http://sorgalla.com/lity/
3
+ * Copyright (c) 2015-2016 Jan Sorgalla; Licensed MIT */
4
  !function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(c){return b(a,c)}):"object"==typeof module&&"object"==typeof module.exports?module.exports=b(a,require("jquery")):a.lity=b(a,a.jQuery||a.Zepto)}("undefined"!=typeof window?window:this,function(a,b){"use strict";function c(a){var b=C();return O&&a.length?(a.one(O,b.resolve),setTimeout(b.resolve,500)):b.resolve(),b.promise()}function d(a,c,d){if(1===arguments.length)return b.extend({},a);if("string"==typeof c){if("undefined"==typeof d)return"undefined"==typeof a[c]?null:a[c];a[c]=d}else b.extend(a,c);return this}function e(a){var b=a.indexOf("?");b>-1&&(a=a.substr(b+1));for(var c,d=decodeURI(a.split("#")[0]).split("&"),e={},f=0,g=d.length;f<g;f++)d[f]&&(c=d[f].split("="),e[c[0]]=c[1]);return e}function f(a,c){if(!c)return a;if("string"===b.type(c)&&(c=e(c)),a.indexOf("?")>-1){var d=a.split("?");a=d.shift(),c=b.extend({},e(d[0]),c)}return a+"?"+b.param(c)}function g(a,b){var c=a.indexOf("#");return-1===c?b:(c>0&&(a=a.substr(c)),b+a)}function h(a,b,c,d){return b&&b.element().addClass("lity-iframe"),c&&(a=f(a,c)),d&&(a=g(d,a)),'<div class="lity-iframe-container"><iframe frameborder="0" allowfullscreen src="'+a+'"/></div>'}function i(a){return b('<span class="lity-error"/>').append(a)}function j(a,c){var d=c.opener()&&c.opener().data("lity-desc")||"Image with no description",e=b('<img src="'+a+'" alt="'+d+'"/>'),f=C(),g=function(){f.reject(i("Failed loading image"))};return e.on("load",function(){return 0===this.naturalWidth?g():void f.resolve(e)}).on("error",g),f.promise()}function k(a,c){var d,e,f;try{d=b(a)}catch(a){return!1}return!!d.length&&(e=b('<i style="display:none !important"/>'),f=d.hasClass("lity-hide"),c.element().one("lity:remove",function(){e.before(d).remove(),f&&!d.closest(".lity-content").length&&d.addClass("lity-hide")}),d.removeClass("lity-hide").after(e))}function l(a,b){var c=K.exec(a);return!!c&&h("https://www.youtube"+(c[2]||"")+".com/embed/"+c[4]+"?autoplay=1",b,c[5],a)}function m(a,b){var c=L.exec(a);return!!c&&h("https://player.vimeo.com/video/"+c[3]+"?autoplay=1",b,c[4],a)}function n(a,b){var c=N.exec(a);return!!c&&(0!==a.indexOf("http")&&(a="https:"+a),h("https://www.facebook.com/plugins/video.php?href="+a+"&autoplay=1",b,c[4],a))}function o(a,b){var c=M.exec(a);return!!c&&h("https://www.google."+c[3]+"/maps?"+c[6],b,{output:c[6].indexOf("layer=c")>0?"svembed":"embed"},a)}function p(a,b){return h(a,b)}function q(){return A.documentElement.clientHeight?A.documentElement.clientHeight:Math.round(B.height())}function r(a){var b=w();b&&(27===a.keyCode&&b.close(),9===a.keyCode&&s(a,b))}function s(a,b){var c=b.element().find(H),d=c.index(A.activeElement);a.shiftKey&&d<=0?(c.get(c.length-1).focus(),a.preventDefault()):a.shiftKey||d!==c.length-1||(c.get(0).focus(),a.preventDefault())}function t(){b.each(E,function(a,b){b.resize()})}function u(a){1===E.unshift(a)&&(D.addClass("lity-active"),B.on({resize:t,keydown:r})),b("body > *").not(a.element()).addClass("lity-hidden").each(function(){var a=b(this);void 0===a.data(G)&&a.data(G,a.attr(F)||null)}).attr(F,"true")}function v(a){var c;a.element().attr(F,"true"),1===E.length&&(D.removeClass("lity-active"),B.off({resize:t,keydown:r})),E=b.grep(E,function(b){return a!==b}),c=E.length?E[0].element():b(".lity-hidden"),c.removeClass("lity-hidden").each(function(){var a=b(this),c=a.data(G);c?a.attr(F,c):a.removeAttr(F),a.removeData(G)})}function w(){return 0===E.length?null:E[0]}function x(a,c,d,e){var f,g="inline",h=b.extend({},d);return e&&h[e]?(f=h[e](a,c),g=e):(b.each(["inline","iframe"],function(a,b){delete h[b],h[b]=d[b]}),b.each(h,function(b,d){return!d||(!(!d.test||d.test(a,c))||(f=d(a,c),!1!==f?(g=b,!1):void 0))})),{handler:g,content:f||""}}function y(a,e,f,g){function h(a){k=b(a).css("max-height",q()+"px"),j.find(".lity-loader").each(function(){var a=b(this);c(a).always(function(){a.remove()})}),j.removeClass("lity-loading").find(".lity-content").empty().append(k),m=!0,k.trigger("lity:ready",[l])}var i,j,k,l=this,m=!1,n=!1;e=b.extend({},I,e),j=b(e.template),l.element=function(){return j},l.opener=function(){return f},l.content=function(){return k},l.options=b.proxy(d,l,e),l.handlers=b.proxy(d,l,e.handlers),l.resize=function(){m&&!n&&k.css("max-height",q()+"px").trigger("lity:resize",[l])},l.close=function(){if(m&&!n){n=!0,v(l);var a=C();return g&&b.contains(j[0],A.activeElement)&&g.focus(),k.trigger("lity:close",[l]),j.removeClass("lity-opened").addClass("lity-closed"),c(k.add(j)).always(function(){k.trigger("lity:remove",[l]),j.remove(),j=void 0,a.resolve()}),a.promise()}},i=x(a,l,e.handlers,e.handler),j.attr(F,"false").addClass("lity-loading lity-opened lity-"+i.handler).appendTo("body").focus().on("click","[data-lity-close]",function(a){b(a.target).is("[data-lity-close]")&&l.close()}).trigger("lity:open",[l]),u(l),b.when(i.content).always(h)}function z(a,c,d){a.preventDefault?(a.preventDefault(),d=b(this),a=d.data("lity-target")||d.attr("href")||d.attr("src")):d=b(d);var e=new y(a,b.extend({},d.data("lity-options")||d.data("lity"),c),d,A.activeElement);if(!a.preventDefault)return e}var A=a.document,B=b(a),C=b.Deferred,D=b("html"),E=[],F="aria-hidden",G="lity-"+F,H='a[href],area[href],input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),iframe,object,embed,[contenteditable],[tabindex]:not([tabindex^="-"])',I={handler:null,handlers:{image:j,inline:k,youtube:l,vimeo:m,googlemaps:o,facebookvideo:n,iframe:p},template:'<div class="lity" role="dialog" aria-label="Dialog Window (Press escape to close)" tabindex="-1"><div class="lity-wrap" data-lity-close role="document"><div class="lity-loader" aria-hidden="true">Loading...</div><div class="lity-container"><div class="lity-content"></div><button class="lity-close" type="button" aria-label="Close (Press escape to close)" data-lity-close>&times;</button></div></div></div>'},J=/(^data:image\/)|(\.(png|jpe?g|gif|svg|webp|bmp|ico|tiff?)(\?\S*)?$)/i,K=/(youtube(-nocookie)?\.com|youtu\.be)\/(watch\?v=|v\/|u\/|embed\/?)?([\w-]{11})(.*)?/i,L=/(vimeo(pro)?\.com)\/(?:[^\d]+)?(\d+)\??(.*)?$/,M=/((maps|www)\.)?google\.([^\/\?]+)\/?((maps\/?)?\?)(.*)/i,N=/(facebook\.com)\/([a-z0-9_-]*)\/videos\/([0-9]*)(.*)?$/i,O=function(){var a=A.createElement("div"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return b[c];return!1}();return j.test=function(a){return J.test(a)},z.version="3.0.0-dev",z.options=b.proxy(d,z,I),z.handlers=b.proxy(d,z,I.handlers),z.current=w,z.iframe=h,b(A).on("click.lity","[data-lity]",z),z});
js/premium.js CHANGED
@@ -1,53 +1,53 @@
1
- jQuery( document ).ready( function() {
2
- jQuery( '#lightslider' ).lightSlider({
3
- item: 1,
4
- autoWidth: false,
5
- slideMove: 1, // slidemove will be 1 if loop is true
6
- slideMargin: 10,
7
-
8
- addClass: '',
9
- mode: "slide",
10
- useCSS: true,
11
- cssEasing: 'ease', //'cubic-bezier(0.25, 0, 0.25, 1)',//
12
- easing: 'linear', //'for jquery animation',////
13
-
14
- speed: 400, //ms'
15
- auto: true,
16
- loop: true,
17
- slideEndAnimation: true,
18
- pause: 5000,
19
-
20
- keyPress: false,
21
- controls: true,
22
- prevHtml: '<span class="dashicons dashicons-arrow-left-alt2">',
23
- nextHtml: '<span class="dashicons dashicons-arrow-right-alt2">',
24
-
25
- rtl:false,
26
- adaptiveHeight:false,
27
-
28
- vertical:false,
29
- verticalHeight:500,
30
- vThumbWidth:100,
31
-
32
- thumbItem:10,
33
- pager: true,
34
- gallery: false,
35
- galleryMargin: 5,
36
- thumbMargin: 5,
37
- currentPagerPosition: 'middle',
38
-
39
- enableTouch:true,
40
- enableDrag:true,
41
- freeMove:true,
42
- swipeThreshold: 40,
43
-
44
- responsive : [],
45
-
46
- onBeforeStart: function (el) {},
47
- onSliderLoad: function (el) {},
48
- onBeforeSlide: function (el) {},
49
- onAfterSlide: function (el) {},
50
- onBeforeNextSlide: function (el) {},
51
- onBeforePrevSlide: function (el) {}
52
- });
53
  });
1
+ jQuery( document ).ready( function() {
2
+ jQuery( '#lightslider' ).lightSlider({
3
+ item: 1,
4
+ autoWidth: false,
5
+ slideMove: 1, // slidemove will be 1 if loop is true
6
+ slideMargin: 10,
7
+
8
+ addClass: '',
9
+ mode: "slide",
10
+ useCSS: true,
11
+ cssEasing: 'ease', //'cubic-bezier(0.25, 0, 0.25, 1)',//
12
+ easing: 'linear', //'for jquery animation',////
13
+
14
+ speed: 400, //ms'
15
+ auto: true,
16
+ loop: true,
17
+ slideEndAnimation: true,
18
+ pause: 5000,
19
+
20
+ keyPress: false,
21
+ controls: true,
22
+ prevHtml: '<span class="dashicons dashicons-arrow-left-alt2">',
23
+ nextHtml: '<span class="dashicons dashicons-arrow-right-alt2">',
24
+
25
+ rtl:false,
26
+ adaptiveHeight:false,
27
+
28
+ vertical:false,
29
+ verticalHeight:500,
30
+ vThumbWidth:100,
31
+
32
+ thumbItem:10,
33
+ pager: true,
34
+ gallery: false,
35
+ galleryMargin: 5,
36
+ thumbMargin: 5,
37
+ currentPagerPosition: 'middle',
38
+
39
+ enableTouch:true,
40
+ enableDrag:true,
41
+ freeMove:true,
42
+ swipeThreshold: 40,
43
+
44
+ responsive : [],
45
+
46
+ onBeforeStart: function (el) {},
47
+ onSliderLoad: function (el) {},
48
+ onBeforeSlide: function (el) {},
49
+ onAfterSlide: function (el) {},
50
+ onBeforeNextSlide: function (el) {},
51
+ onBeforePrevSlide: function (el) {}
52
+ });
53
  });
js/repeatable-custom-tabs-settings.js CHANGED
@@ -1,220 +1,220 @@
1
- /*
2
- * jQuery for repeatable woo commerce tabs (on settings page)
3
- * somewhat cool / very cool
4
- * YIKES Inc. / Kevin Utz
5
- */
6
- jQuery( document ).ready(function() {
7
-
8
- // Save a tab
9
- jQuery( '.yikes_woo_save_this_tab' ).click( function() {
10
- var tab_id = jQuery( this ).data( 'tab-id' );
11
-
12
- yikes_woo_handle_saving_reusable_tab( tab_id );
13
- });
14
-
15
- // Delete a saved tab
16
- jQuery( '.yikes_woo_delete_this_tab' ).click( function() {
17
-
18
- // Confirm: Are you sure?
19
- var continue_delete = confirm( 'Are you sure you want to delete this tab?' );
20
-
21
- if ( continue_delete === false ) {
22
- return;
23
- }
24
-
25
- // Store the tab_id
26
- var tab_id = jQuery( this ).data( 'tab-id' );
27
-
28
- if ( jQuery( this ).hasClass( 'yikes_woo_delete_this_tab_single' ) ) {
29
-
30
- // If we're on the single page and trying to delete a new tab, then just redirect!
31
- if ( tab_id === 'new' ) {
32
- location.href = repeatable_custom_tabs_settings.tab_list_page_url;
33
- }
34
- yikes_woo_handle_deleting_reusable_tab( tab_id, 'single' );
35
- } else {
36
- yikes_woo_handle_deleting_reusable_tab( tab_id, false );
37
- }
38
- });
39
-
40
- // Handle bulk actions
41
- jQuery( '.yikes_woo_handle_bulk_action' ).click( function() {
42
-
43
- // Currently only supporting 'delete' bulk action, so make sure that is the value of the dropdown
44
- if ( jQuery( '#bulk-action-selector-top' ).val() !== 'delete' ) {
45
- return;
46
- }
47
-
48
- // Set up an array of IDs to delete
49
- var tab_ids_to_delete = [];
50
-
51
- // Loop through all of the rows and check if checkbox is checked
52
- jQuery( '.entry-bulk-action-checkbox' ).each( function() {
53
- if ( jQuery( this ).is( ':checked' ) === true ) {
54
-
55
- // Add tab_id to array
56
- tab_ids_to_delete.push( jQuery( this ).val() );
57
-
58
- // Add class to the row (we will target this class later to remove all rows)
59
- jQuery( this ).parents( 'th' ).parents( '.yikes_woo_saved_tabs_row' ).addClass( 'yikes_woo_bulk_delete_this_row' );
60
- }
61
- });
62
-
63
- // delete the tabs!
64
- yikes_woo_handle_deleting_reusable_tab( tab_ids_to_delete, 'bulk' );
65
-
66
- });
67
-
68
- }); // End document.ready
69
-
70
- /**
71
- * @summary Save a tab for re-use
72
- *
73
- * @since 1.5
74
- *
75
- * @param mixed | tab_id | the uniquely identifying suffix of the current tab ('new' for new tabs)
76
- *
77
- */
78
- function yikes_woo_handle_saving_reusable_tab( tab_id ) {
79
-
80
- // Add loading spinner
81
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', repeatable_custom_tabs_settings.loading_gif, {'time': 100000} );
82
-
83
- var tab_title = jQuery( '#yikes_woo_reusable_tab_title_' + tab_id ).val();
84
- var tab_name = jQuery( '#yikes_woo_reusable_tab_name_' + tab_id ).val();
85
- var tab_content = '';
86
- var taxonomies = {};
87
- var global_tab = false;
88
-
89
- if ( typeof( tinymce ) !== 'undefined' && jQuery( '#wp-yikes_woo_reusable_tab_content_' + tab_id + '-wrap' ).hasClass( 'tmce-active' ) ) {
90
- tab_content = tinymce.get( 'yikes_woo_reusable_tab_content_' + tab_id ).getContent();
91
- } else {
92
- tab_content = jQuery( '#yikes_woo_reusable_tab_content_' + tab_id ).val();
93
- }
94
-
95
- //If no tab_title || tab_content, show error message
96
- if ( tab_title.length === 0 ) {
97
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', 'Please fill out the tab title before saving.', {} );
98
- return;
99
- }
100
- if ( tab_content.length === 0 ) {
101
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', 'Please fill out the tab content before saving.', {} );
102
- return;
103
- }
104
-
105
- // CPTPRO: Grab & format taxonomy data
106
- if ( jQuery( '.cptpro-taxonomies' ).length > 0 ) {
107
-
108
- // Create an object with taxonomy name => array( taxonomy_values )
109
- jQuery( '.taxonomy-label' ).each( function() {
110
- var taxonomy = jQuery( this ).data( 'taxonomy' );
111
- taxonomies[ taxonomy ] = {};
112
-
113
- jQuery( 'input[name="' + taxonomy + '[]"].selected' ).each( function() {
114
- taxonomies[ taxonomy ][ jQuery( this ).data( 'tt-id' ) ] = this.value;
115
- });
116
- });
117
- }
118
-
119
- // CPTPRO: Grab global value
120
- if ( jQuery( '.global-section' ).length > 0 ) {
121
- global_tab = jQuery( '#global-checkbox' ).prop( 'checked' );
122
- }
123
-
124
- // Create data object
125
- var data = {
126
- 'action' : 'yikes_woo_save_tab_as_reusable',
127
- 'tab_title' : tab_title,
128
- 'tab_content' : tab_content,
129
- 'tab_id' : tab_id,
130
- 'tab_name' : tab_name,
131
- 'taxonomies' : taxonomies,
132
- 'global_tab' : global_tab,
133
- 'security_nonce': repeatable_custom_tabs_settings.save_tab_as_reusable_nonce
134
- };
135
-
136
- // AJAX
137
- jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
138
- if ( typeof( response.success ) !== 'undefined' && response.success === true ) {
139
-
140
- // If redirect var is set, redirect!
141
- if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect ) !== 'undefined'
142
- && response.data.redirect === true && typeof( response.data.redirect_url !== 'undefined' ) ) {
143
- location.href = response.data.redirect_url;
144
- } else {
145
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', 'Tab saved successfully.', {} );
146
-
147
- if ( repeatable_custom_tabs_settings.is_cptpro_enabled === '1' && typeof cptpro_show_products_using_this_tab === 'function' ) {
148
- cptpro_show_products_using_this_tab( tab_id );
149
- }
150
- }
151
-
152
- jQuery( '#yikes_woo_tab_title_header' ).text( tab_title );
153
- } else {
154
- if ( typeof( response.data ) !== 'undefined' && typeof( response.data.message ) !== 'undefined' ) {
155
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', response.data.message, {} );
156
- } else {
157
-
158
- // Ok, not sure what went wrong. Let's log it.
159
- console.log( response );
160
- }
161
- }
162
- });
163
- }
164
-
165
- /**
166
- * @summary Delete a saved tab
167
- *
168
- * @since 1.5
169
- *
170
- * @param int | tab_id | the tab's unique ID in the database
171
- * @param string | delete_method | a string signifying what to do after deleting tabs
172
- *
173
- */
174
- function yikes_woo_handle_deleting_reusable_tab( tab_id, delete_method ) {
175
-
176
- // Add a spinner...
177
- if ( delete_method === 'single' ) {
178
- yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', repeatable_custom_tabs_settings.loading_gif, {'time': 100000} );
179
- }
180
-
181
- // Create data object
182
- var data = {
183
- action: 'yikes_woo_delete_reusable_tab_handler',
184
- tab_id: tab_id,
185
- security_nonce: repeatable_custom_tabs_settings.delete_reusable_tab_nonce
186
- }
187
-
188
- // AJAX
189
- jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
190
- if ( response.success ) {
191
-
192
- if ( delete_method === 'bulk' ) {
193
-
194
- // fadeOut and remove all of the rows at once
195
- jQuery( '.yikes_woo_bulk_delete_this_row' ).fadeOut( '600', function() {
196
- jQuery( '.yikes_woo_bulk_delete_this_row' ).remove();
197
- });
198
- } else if ( delete_method === 'single' ) {
199
-
200
- // If we have a redirect URL, redirect back to tab list
201
- if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect_url ) !== 'undefined' ) {
202
- location.href = response.data.redirect_url;
203
- }
204
- } else {
205
-
206
- // Remove the tab container
207
- jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).fadeOut( '600', function() {
208
- jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).remove();
209
-
210
- // Display our delete-success message
211
- jQuery( '#yikes_woo_delete_success_message' ).show();
212
- });
213
- }
214
- } else {
215
-
216
- // Ok, not sure what went wrong. Let's log it.
217
- console.log( response );
218
- }
219
- });
220
  }
1
+ /*
2
+ * jQuery for repeatable woo commerce tabs (on settings page)
3
+ * somewhat cool / very cool
4
+ * YIKES Inc. / Kevin Utz
5
+ */
6
+ jQuery( document ).ready(function() {
7
+
8
+ // Save a tab
9
+ jQuery( '.yikes_woo_save_this_tab' ).click( function() {
10
+ var tab_id = jQuery( this ).data( 'tab-id' );
11
+
12
+ yikes_woo_handle_saving_reusable_tab( tab_id );
13
+ });
14
+
15
+ // Delete a saved tab
16
+ jQuery( '.yikes_woo_delete_this_tab' ).click( function() {
17
+
18
+ // Confirm: Are you sure?
19
+ var continue_delete = confirm( 'Are you sure you want to delete this tab?' );
20
+
21
+ if ( continue_delete === false ) {
22
+ return;
23
+ }
24
+
25
+ // Store the tab_id
26
+ var tab_id = jQuery( this ).data( 'tab-id' );
27
+
28
+ if ( jQuery( this ).hasClass( 'yikes_woo_delete_this_tab_single' ) ) {
29
+
30
+ // If we're on the single page and trying to delete a new tab, then just redirect!
31
+ if ( tab_id === 'new' ) {
32
+ location.href = repeatable_custom_tabs_settings.tab_list_page_url;
33
+ }
34
+ yikes_woo_handle_deleting_reusable_tab( tab_id, 'single' );
35
+ } else {
36
+ yikes_woo_handle_deleting_reusable_tab( tab_id, false );
37
+ }
38
+ });
39
+
40
+ // Handle bulk actions
41
+ jQuery( '.yikes_woo_handle_bulk_action' ).click( function() {
42
+
43
+ // Currently only supporting 'delete' bulk action, so make sure that is the value of the dropdown
44
+ if ( jQuery( '#bulk-action-selector-top' ).val() !== 'delete' ) {
45
+ return;
46
+ }
47
+
48
+ // Set up an array of IDs to delete
49
+ var tab_ids_to_delete = [];
50
+
51
+ // Loop through all of the rows and check if checkbox is checked
52
+ jQuery( '.entry-bulk-action-checkbox' ).each( function() {
53
+ if ( jQuery( this ).is( ':checked' ) === true ) {
54
+
55
+ // Add tab_id to array
56
+ tab_ids_to_delete.push( jQuery( this ).val() );
57
+
58
+ // Add class to the row (we will target this class later to remove all rows)
59
+ jQuery( this ).parents( 'th' ).parents( '.yikes_woo_saved_tabs_row' ).addClass( 'yikes_woo_bulk_delete_this_row' );
60
+ }
61
+ });
62
+
63
+ // delete the tabs!
64
+ yikes_woo_handle_deleting_reusable_tab( tab_ids_to_delete, 'bulk' );
65
+
66
+ });
67
+
68
+ }); // End document.ready
69
+
70
+ /**
71
+ * @summary Save a tab for re-use
72
+ *
73
+ * @since 1.5
74
+ *
75
+ * @param mixed | tab_id | the uniquely identifying suffix of the current tab ('new' for new tabs)
76
+ *
77
+ */
78
+ function yikes_woo_handle_saving_reusable_tab( tab_id ) {
79
+
80
+ // Add loading spinner
81
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', repeatable_custom_tabs_settings.loading_gif, {'time': 100000} );
82
+
83
+ var tab_title = jQuery( '#yikes_woo_reusable_tab_title_' + tab_id ).val();
84
+ var tab_name = jQuery( '#yikes_woo_reusable_tab_name_' + tab_id ).val();
85
+ var tab_content = '';
86
+ var taxonomies = {};
87
+ var global_tab = false;
88
+
89
+ if ( typeof( tinymce ) !== 'undefined' && jQuery( '#wp-yikes_woo_reusable_tab_content_' + tab_id + '-wrap' ).hasClass( 'tmce-active' ) ) {
90
+ tab_content = tinymce.get( 'yikes_woo_reusable_tab_content_' + tab_id ).getContent();
91
+ } else {
92
+ tab_content = jQuery( '#yikes_woo_reusable_tab_content_' + tab_id ).val();
93
+ }
94
+
95
+ //If no tab_title || tab_content, show error message
96
+ if ( tab_title.length === 0 ) {
97
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', 'Please fill out the tab title before saving.', {} );
98
+ return;
99
+ }
100
+ if ( tab_content.length === 0 ) {
101
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', 'Please fill out the tab content before saving.', {} );
102
+ return;
103
+ }
104
+
105
+ // CPTPRO: Grab & format taxonomy data
106
+ if ( jQuery( '.cptpro-taxonomies' ).length > 0 ) {
107
+
108
+ // Create an object with taxonomy name => array( taxonomy_values )
109
+ jQuery( '.taxonomy-label' ).each( function() {
110
+ var taxonomy = jQuery( this ).data( 'taxonomy' );
111
+ taxonomies[ taxonomy ] = {};
112
+
113
+ jQuery( 'input[name="' + taxonomy + '[]"].selected' ).each( function() {
114
+ taxonomies[ taxonomy ][ jQuery( this ).data( 'tt-id' ) ] = this.value;
115
+ });
116
+ });
117
+ }
118
+
119
+ // CPTPRO: Grab global value
120
+ if ( jQuery( '.global-section' ).length > 0 ) {
121
+ global_tab = jQuery( '#global-checkbox' ).prop( 'checked' );
122
+ }
123
+
124
+ // Create data object
125
+ var data = {
126
+ 'action' : 'yikes_woo_save_tab_as_reusable',
127
+ 'tab_title' : tab_title,
128
+ 'tab_content' : tab_content,
129
+ 'tab_id' : tab_id,
130
+ 'tab_name' : tab_name,
131
+ 'taxonomies' : taxonomies,
132
+ 'global_tab' : global_tab,
133
+ 'security_nonce': repeatable_custom_tabs_settings.save_tab_as_reusable_nonce
134
+ };
135
+
136
+ // AJAX
137
+ jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
138
+ if ( typeof( response.success ) !== 'undefined' && response.success === true ) {
139
+
140
+ // If redirect var is set, redirect!
141
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect ) !== 'undefined'
142
+ && response.data.redirect === true && typeof( response.data.redirect_url !== 'undefined' ) ) {
143
+ location.href = response.data.redirect_url;
144
+ } else {
145
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', 'Tab saved successfully.', {} );
146
+
147
+ if ( repeatable_custom_tabs_settings.is_cptpro_enabled === '1' && typeof cptpro_show_products_using_this_tab === 'function' ) {
148
+ cptpro_show_products_using_this_tab( tab_id );
149
+ }
150
+ }
151
+
152
+ jQuery( '#yikes_woo_tab_title_header' ).text( tab_title );
153
+ } else {
154
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.message ) !== 'undefined' ) {
155
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', response.data.message, {} );
156
+ } else {
157
+
158
+ // Ok, not sure what went wrong. Let's log it.
159
+ console.log( response );
160
+ }
161
+ }
162
+ });
163
+ }
164
+
165
+ /**
166
+ * @summary Delete a saved tab
167
+ *
168
+ * @since 1.5
169
+ *
170
+ * @param int | tab_id | the tab's unique ID in the database
171
+ * @param string | delete_method | a string signifying what to do after deleting tabs
172
+ *
173
+ */
174
+ function yikes_woo_handle_deleting_reusable_tab( tab_id, delete_method ) {
175
+
176
+ // Add a spinner...
177
+ if ( delete_method === 'single' ) {
178
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', repeatable_custom_tabs_settings.loading_gif, {'time': 100000} );
179
+ }
180
+
181
+ // Create data object
182
+ var data = {
183
+ action: 'yikes_woo_delete_reusable_tab_handler',
184
+ tab_id: tab_id,
185
+ security_nonce: repeatable_custom_tabs_settings.delete_reusable_tab_nonce
186
+ }
187
+
188
+ // AJAX
189
+ jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
190
+ if ( response.success ) {
191
+
192
+ if ( delete_method === 'bulk' ) {
193
+
194
+ // fadeOut and remove all of the rows at once
195
+ jQuery( '.yikes_woo_bulk_delete_this_row' ).fadeOut( '600', function() {
196
+ jQuery( '.yikes_woo_bulk_delete_this_row' ).remove();
197
+ });
198
+ } else if ( delete_method === 'single' ) {
199
+
200
+ // If we have a redirect URL, redirect back to tab list
201
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect_url ) !== 'undefined' ) {
202
+ location.href = response.data.redirect_url;
203
+ }
204
+ } else {
205
+
206
+ // Remove the tab container
207
+ jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).fadeOut( '600', function() {
208
+ jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).remove();
209
+
210
+ // Display our delete-success message
211
+ jQuery( '#yikes_woo_delete_success_message' ).show();
212
+ });
213
+ }
214
+ } else {
215
+
216
+ // Ok, not sure what went wrong. Let's log it.
217
+ console.log( response );
218
+ }
219
+ });
220
  }
js/repeatable-custom-tabs-shared.js CHANGED
@@ -1,384 +1,384 @@
1
- /**
2
- * @summary Fetch the wp_editor HTML via AJAX.
3
- *
4
- * @since 1.5
5
- *
6
- * @param string | textarea_id | ID of the textarea where we're initializing the WYSIWYG editor
7
- * @param bool | product_page | bool indicating whether we're on the product page (true) or settings page (false)
8
- * @param string | tab_content | String to pre-populate the editor with content
9
- *
10
- * @return bool
11
- */
12
- function yikes_woo_get_wp_editor_ajax( textarea_id, product_page, tab_content ) {
13
-
14
- // Create data object for AJAX call
15
- var data = {
16
- 'action': 'yikes_woo_get_wp_editor',
17
- 'textarea_id': textarea_id,
18
- 'tab_content': tab_content,
19
- 'security_nonce': repeatable_custom_tabs_shared.get_wp_editor_security_nonce
20
- };
21
-
22
- // AJAX
23
- jQuery.post( repeatable_custom_tabs_shared.ajaxurl, data, function( response ) {
24
-
25
- // Re-enable buttons / arrows
26
- yikes_woo_toggle_controls( 'enable' );
27
-
28
- // If call failed, show error message
29
- if ( typeof( response.success ) !== 'undefined' && response.success === false ) {
30
- jQuery( '.' + textarea_id + '_field' ).html( '<p>' + repeatable_custom_tabs_shared.get_wp_editor_failure_message + '</p>' );
31
-
32
- return false;
33
- }
34
-
35
- // If we're on the button page, show the button holder (we temporarily hide it for UI/UX purposes)
36
- // if ( product_page === true ) {
37
- // jQuery( '.button-holder' ).show();
38
- // }
39
-
40
- // Add wp_editor HTML to the page
41
- jQuery( '.' + textarea_id + '_field' ).html( response ).addClass( '_yikes_wc_custom_repeatable_product_tabs_tab_content_field _yikes_wc_custom_repeatable_product_tabs_tab_content_field_dynamic' );
42
-
43
- // Initialize quicktags (for working in 'Text tab' mode)
44
- if ( typeof( QTags ) !== 'undefined' ) {
45
- quicktags( textarea_id );
46
- QTags._buttonsInit();
47
- }
48
-
49
- // These are WordPress default editor settings, retrieved from wp-includes\class-wp-editor.php
50
- // The `setup:` function is not part of the WordPress core, but the default styles were not being applied
51
- tinymce.init({
52
- branding: false,
53
- selector: '#' + textarea_id,
54
- theme: 'modern',
55
- skin: 'lightgray',
56
- language: 'en',
57
- formats: {
58
- alignleft: [
59
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'left' } },
60
- { selector: 'img,table,dl.wp-caption', classes: 'alignleft' }
61
- ],
62
- aligncenter: [
63
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'center' } },
64
- { selector: 'img,table,dl.wp-caption', classes: 'aligncenter' }
65
- ],
66
- alignright: [
67
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'right' } },
68
- { selector: 'img,table,dl.wp-caption', classes: 'alignright' }
69
- ],
70
- strikethrough: { inline: 'del' }
71
- },
72
- relative_urls: false,
73
- remove_script_host: false,
74
- convert_urls: false,
75
- browser_spellcheck: true,
76
- fix_list_elements: true,
77
- entities: '38,amp,60,lt,62,gt',
78
- entity_encoding: 'raw',
79
- keep_styles: false,
80
- paste_webkit_styles: 'font-weight font-style color',
81
- preview_styles: 'font-family font-size font-weight font-style text-decoration text-transform',
82
- end_container_on_empty_block: true,
83
- wpeditimage_disable_captions: false,
84
- wpeditimage_html5_captions: true,
85
- plugins: 'charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview',
86
- resize: true,
87
- menubar: false,
88
- wpautop: true,
89
- indent: false,
90
- toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,unlink,wp_adv',
91
- toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
92
- toolbar3: '',
93
- toolbar4: '',
94
- tabfocus_elements: ':prev,:next',
95
- body_class: 'id post-type-post post-status-publish post-format-standard',
96
- setup: function( editor ) {
97
- editor.on( 'init', function() {
98
- this.getBody().style.fontFamily = 'Georgia, "Times New Roman", "Bitstream Charter", Times, serif';
99
- this.getBody().style.fontSize = '16px';
100
- this.getBody().style.color = '#333';
101
- });
102
- }
103
- });
104
-
105
- // Initialize tinymce
106
- if( typeof( tinymce ) != 'undefined' ) {
107
- tinymce.execCommand( 'mceAddEditor', false, textarea_id );
108
- }
109
-
110
- // After tinymce is initialized, let's check if we need to disable the box (because it's a saved tab)
111
- var tab_number = yikes_woo_get_tab_number_from_id( textarea_id );
112
- if ( jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).hasClass( 'yikes_woo_disable_this_tab' ) ) {
113
- jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).removeClass( 'yikes_woo_disable_this_tab' );
114
- yikes_woo_toggle_reusable_override_overlay( 'disable', tab_number );
115
- }
116
-
117
- return true;
118
- });
119
- }
120
-
121
- function yikes_woo_get_wp_editor_foureight( textarea_id, product_page, tab_content ) {
122
-
123
- if ( ! wp || ! wp.editor || ! wp.editor.initialize ) {
124
- yikes_woo_get_wp_editor_ajax( textarea_id, product_page, tab_content );
125
- return false;
126
- }
127
-
128
- // Re-enable buttons / arrows
129
- yikes_woo_toggle_controls( 'enable' );
130
-
131
- var settings = {
132
- tinymce: {
133
- branding: false,
134
- theme: 'modern',
135
- skin: 'lightgray',
136
- language: 'en',
137
- formats: {
138
- alignleft: [
139
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'left' } },
140
- { selector: 'img,table,dl.wp-caption', classes: 'alignleft' }
141
- ],
142
- aligncenter: [
143
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'center' } },
144
- { selector: 'img,table,dl.wp-caption', classes: 'aligncenter' }
145
- ],
146
- alignright: [
147
- { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'right' } },
148
- { selector: 'img,table,dl.wp-caption', classes: 'alignright' }
149
- ],
150
- strikethrough: { inline: 'del' }
151
- },
152
- relative_urls: false,
153
- remove_script_host: false,
154
- convert_urls: false,
155
- browser_spellcheck: true,
156
- fix_list_elements: true,
157
- entities: '38,amp,60,lt,62,gt',
158
- entity_encoding: 'raw',
159
- keep_styles: false,
160
- paste_webkit_styles: 'font-weight font-style color',
161
- preview_styles: 'font-family font-size font-weight font-style text-decoration text-transform',
162
- end_container_on_empty_block: true,
163
- wpeditimage_disable_captions: false,
164
- wpeditimage_html5_captions: true,
165
- plugins: 'charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview',
166
- menubar: false,
167
- wpautop: true,
168
- indent: false,
169
- resize: true,
170
- theme_advanced_resizing: true,
171
- theme_advanced_resize_horizontal: false,
172
- statusbar: true,
173
- toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,unlink,wp_adv',
174
- toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
175
- toolbar3: '',
176
- toolbar4: '',
177
- tabfocus_elements: ':prev,:next',
178
- // width: '100%',
179
- // body_class: 'id post-type-post post-status-publish post-format-standard',
180
- setup: function( editor ) {
181
- editor.on( 'init', function() {
182
- this.getBody().style.fontFamily = 'Georgia, "Times New Roman", "Bitstream Charter", Times, serif';
183
- this.getBody().style.fontSize = '16px';
184
- this.getBody().style.color = '#333';
185
- if ( tab_content.length > 0 ) {
186
- this.setContent( tab_content );
187
- }
188
- });
189
- },
190
- },
191
- quicktags: {
192
- buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,close"
193
- }
194
- }
195
-
196
- wp.editor.initialize( textarea_id, settings );
197
-
198
- // If we're on the button page, show the button holder (we temporarily hide it for UI/UX purposes)
199
- // if ( product_page === true ) {
200
- // jQuery( '.button-holder' ).show();
201
- // }
202
-
203
- // After tinymce is initialized, let's check if we need to disable the box (because it's a saved tab)
204
- var tab_number = yikes_woo_get_tab_number_from_id( textarea_id );
205
- if ( jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).hasClass( 'yikes_woo_disable_this_tab' ) ) {
206
- jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).removeClass( 'yikes_woo_disable_this_tab' );
207
- yikes_woo_toggle_reusable_override_overlay( 'disable', tab_number );
208
- }
209
-
210
- // Add an 'Add Media' button
211
- // The plugin is included with the instantiation of the editor but there is no HTML button to trigger the associated functions
212
- var add_media_button = '<div id="wp-' + textarea_id + '-media-buttons" class="wp-media-buttons"> \
213
- <button type="button" id="insert-media-button" class="button insert-media add_media" data-editor="' + textarea_id + '"><span class="wp-media-buttons-icon"></span> Add Media</button>\
214
- </div>';
215
- jQuery( '#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_' + tab_number + '-wrap > .wp-editor-tools' ).prepend( add_media_button );
216
-
217
- return true;
218
- }
219
-
220
- /**
221
- * @summary Get the numerical ID from a string ID
222
- *
223
- * @param string | id_string | an id of the form this_is_an_id_10
224
- * @return string | tab_number | the numerical suffix of the string id passed in
225
- */
226
- function yikes_woo_get_tab_number_from_id( id_string ) {
227
- return id_string.slice( ( id_string.lastIndexOf( '_' ) + 1 ) );
228
- }
229
-
230
- /**
231
- * @summary Toggle disabling/hiding of UI buttons, this prevents potentially breaking the UI while AJAX is returning
232
- *
233
- * @since 1.5
234
- *
235
- * @param string | toggle_enable | 'disable' to disable/hide, 'enable' to enable/show
236
- *
237
- */
238
- function yikes_woo_toggle_controls( toggle_enable ) {
239
- if ( toggle_enable === 'disable' ) {
240
- jQuery( '.remove_this_tab' ).attr( 'disabled', 'disabled' );
241
- jQuery( '#add_another_tab' ).attr( 'disabled', 'disabled' );
242
- jQuery( '._yikes_wc_apply_a_saved_tab' ).attr( 'disabled', 'disabled' );
243
- jQuery( '.move-tab-data-up' ).hide();
244
- jQuery( '.move-tab-data-down' ).hide();
245
- } else {
246
- jQuery( '.remove_this_tab' ).removeAttr( 'disabled' );
247
- jQuery( '#add_another_tab' ).removeAttr( 'disabled' );
248
- jQuery( '._yikes_wc_apply_a_saved_tab' ).removeAttr( 'disabled' )
249
- jQuery( '.move-tab-data-up' ).show();
250
- jQuery( '.move-tab-data-down' ).show();
251
- }
252
- }
253
-
254
- /**
255
- * @summary Display a simple error or success message
256
- *
257
- * @since 1.5
258
- *
259
- * @param string | anchor_element | a selector for an element we're going to display the message next to
260
- * @param string | message_element_id| the ID of the element we're creating to hold the message
261
- * @param string | message | the message we're displaying to the user
262
- * @param object | options | Collection of options for customizing the error message
263
- *
264
- */
265
- function yikes_woo_display_feedback_messages( anchor_element_id, message_element_id, message, options ) {
266
-
267
- var defaults = {
268
- 'inline': false,
269
- 'classes': [],
270
- 'css_string': '',
271
- 'time': 3000
272
- }
273
-
274
- var opts = jQuery.extend( defaults, options );
275
-
276
- //remove any other success / error message elements
277
- jQuery( '._yikes_wc_feedback_message' ).remove();
278
-
279
- // Construct style string
280
- var style_string = '';
281
- if ( opts.css_string.length > 0 ) {
282
- style_string = opts.css_string;
283
- }
284
-
285
- // Construct class string
286
- var classes = defaults.classes;
287
- if ( opts.classes.length > 0 ) {
288
- opts.classes.each( function( index, class_name ) {
289
- classes += class_name;
290
- });
291
- }
292
-
293
- var dynamic_message_elements = '';
294
-
295
- // Construct our message
296
- if ( opts.inline === true ) {
297
- dynamic_message_elements = '<span id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</span>';
298
- } else {
299
- dynamic_message_elements = '<p id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</p>';
300
- }
301
-
302
- // Add our message to the DOM
303
- jQuery( anchor_element_id ).after( dynamic_message_elements );
304
-
305
- // Display message by fadein/fadeout
306
- jQuery( '#' + message_element_id ).fadeIn( 500 ).delay( opts.time ).fadeOut( 500 );
307
- }
308
-
309
- /**
310
- * @summary Slide down / slide up our 'How To' info and swap dashicons
311
- *
312
- * @since 1.5
313
- *
314
- */
315
- function yikes_woo_toggle_how_to() {
316
- jQuery( '.yikes-woo-tabs-hidden-how-to-info' ).slideToggle( 'fast', function() {
317
- if ( jQuery( '#yikes-woo-help-me-icon' ).hasClass( 'dashicons-editor-help' ) ) {
318
- jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-editor-help' ).addClass( 'dashicons-dismiss' );
319
- } else {
320
- jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-dismiss' ).addClass( 'dashicons-editor-help' );
321
- }
322
- });
323
- }
324
-
325
- /**
326
- * Retrieve the content from the wp_editor
327
- *
328
- * @since 1.5
329
- *
330
- * @param string | editor_id | the id of the editor (without the prefacing #)
331
- * @return string | content | the content of the editor
332
- */
333
- function yikes_woo_get_content_from_wysiwyg( editor_id ) {
334
-
335
- var content = '';
336
-
337
- // Check if tinymce is initialized, and if our instance is known
338
- if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
339
-
340
- // Store the content
341
- content = tinymce.get( editor_id ).getContent();
342
-
343
- // If we don't have any content, check the textarea for a value and use it
344
- if ( content.length === 0 && jQuery( '#' + editor_id ).val().length > 0 ) {
345
- content = jQuery( '#' + editor_id ).val();
346
- }
347
- } else {
348
-
349
- // If tinymce is not initialized, try getting the content from the textarea value
350
- content = jQuery( '#' + editor_id ).val();
351
- }
352
-
353
- return content;
354
- }
355
-
356
- /**
357
- * Set the content for the wp_editor
358
- *
359
- * @since 1.5
360
- *
361
- * @param string | editor_id | the id of the editor (without the prefacing #)
362
- * @param string | content | the content to supply the editor with
363
- */
364
- function yikes_woo_set_content_for_wysiwyg( editor_id, content ) {
365
-
366
- // Check if tinymce is initialized, and if our instance is known
367
- if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
368
-
369
- // If it's initialized, we can just set the content from here using setContent()
370
- tinymce.get( editor_id ).setContent( content );
371
-
372
- // tinyMCE stores the value in both places, so we need to set the textarea content from here too
373
- jQuery( '#' + editor_id ).val( content );
374
- } else {
375
-
376
- // Else we need to set the value using the textarea's val
377
- jQuery( '#' + editor_id ).val( content );
378
- }
379
- }
380
-
381
-
382
-
383
-
384
-
1
+ /**
2
+ * @summary Fetch the wp_editor HTML via AJAX.
3
+ *
4
+ * @since 1.5
5
+ *
6
+ * @param string | textarea_id | ID of the textarea where we're initializing the WYSIWYG editor
7
+ * @param bool | product_page | bool indicating whether we're on the product page (true) or settings page (false)
8
+ * @param string | tab_content | String to pre-populate the editor with content
9
+ *
10
+ * @return bool
11
+ */
12
+ function yikes_woo_get_wp_editor_ajax( textarea_id, product_page, tab_content ) {
13
+
14
+ // Create data object for AJAX call
15
+ var data = {
16
+ 'action': 'yikes_woo_get_wp_editor',
17
+ 'textarea_id': textarea_id,
18
+ 'tab_content': tab_content,
19
+ 'security_nonce': repeatable_custom_tabs_shared.get_wp_editor_security_nonce
20
+ };
21
+
22
+ // AJAX
23
+ jQuery.post( repeatable_custom_tabs_shared.ajaxurl, data, function( response ) {
24
+
25
+ // Re-enable buttons / arrows
26
+ yikes_woo_toggle_controls( 'enable' );
27
+
28
+ // If call failed, show error message
29
+ if ( typeof( response.success ) !== 'undefined' && response.success === false ) {
30
+ jQuery( '.' + textarea_id + '_field' ).html( '<p>' + repeatable_custom_tabs_shared.get_wp_editor_failure_message + '</p>' );
31
+
32
+ return false;
33
+ }
34
+
35
+ // If we're on the button page, show the button holder (we temporarily hide it for UI/UX purposes)
36
+ // if ( product_page === true ) {
37
+ // jQuery( '.button-holder' ).show();
38
+ // }
39
+
40
+ // Add wp_editor HTML to the page
41
+ jQuery( '.' + textarea_id + '_field' ).html( response ).addClass( '_yikes_wc_custom_repeatable_product_tabs_tab_content_field _yikes_wc_custom_repeatable_product_tabs_tab_content_field_dynamic' );
42
+
43
+ // Initialize quicktags (for working in 'Text tab' mode)
44
+ if ( typeof( QTags ) !== 'undefined' ) {
45
+ quicktags( textarea_id );
46
+ QTags._buttonsInit();
47
+ }
48
+
49
+ // These are WordPress default editor settings, retrieved from wp-includes\class-wp-editor.php
50
+ // The `setup:` function is not part of the WordPress core, but the default styles were not being applied
51
+ tinymce.init({
52
+ branding: false,
53
+ selector: '#' + textarea_id,
54
+ theme: 'modern',
55
+ skin: 'lightgray',
56
+ language: 'en',
57
+ formats: {
58
+ alignleft: [
59
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'left' } },
60
+ { selector: 'img,table,dl.wp-caption', classes: 'alignleft' }
61
+ ],
62
+ aligncenter: [
63
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'center' } },
64
+ { selector: 'img,table,dl.wp-caption', classes: 'aligncenter' }
65
+ ],
66
+ alignright: [
67
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'right' } },
68
+ { selector: 'img,table,dl.wp-caption', classes: 'alignright' }
69
+ ],
70
+ strikethrough: { inline: 'del' }
71
+ },
72
+ relative_urls: false,
73
+ remove_script_host: false,
74
+ convert_urls: false,
75
+ browser_spellcheck: true,
76
+ fix_list_elements: true,
77
+ entities: '38,amp,60,lt,62,gt',
78
+ entity_encoding: 'raw',
79
+ keep_styles: false,
80
+ paste_webkit_styles: 'font-weight font-style color',
81
+ preview_styles: 'font-family font-size font-weight font-style text-decoration text-transform',
82
+ end_container_on_empty_block: true,
83
+ wpeditimage_disable_captions: false,
84
+ wpeditimage_html5_captions: true,
85
+ plugins: 'charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview',
86
+ resize: true,
87
+ menubar: false,
88
+ wpautop: true,
89
+ indent: false,
90
+ toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,unlink,wp_adv',
91
+ toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
92
+ toolbar3: '',
93
+ toolbar4: '',
94
+ tabfocus_elements: ':prev,:next',
95
+ body_class: 'id post-type-post post-status-publish post-format-standard',
96
+ setup: function( editor ) {
97
+ editor.on( 'init', function() {
98
+ this.getBody().style.fontFamily = 'Georgia, "Times New Roman", "Bitstream Charter", Times, serif';
99
+ this.getBody().style.fontSize = '16px';
100
+ this.getBody().style.color = '#333';
101
+ });
102
+ }
103
+ });
104
+
105
+ // Initialize tinymce
106
+ if( typeof( tinymce ) != 'undefined' ) {
107
+ tinymce.execCommand( 'mceAddEditor', false, textarea_id );
108
+ }
109
+
110
+ // After tinymce is initialized, let's check if we need to disable the box (because it's a saved tab)
111
+ var tab_number = yikes_woo_get_tab_number_from_id( textarea_id );
112
+ if ( jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).hasClass( 'yikes_woo_disable_this_tab' ) ) {
113
+ jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).removeClass( 'yikes_woo_disable_this_tab' );
114
+ yikes_woo_toggle_reusable_override_overlay( 'disable', tab_number );
115
+ }
116
+
117
+ return true;
118
+ });
119
+ }
120
+
121
+ function yikes_woo_get_wp_editor_foureight( textarea_id, product_page, tab_content ) {
122
+
123
+ if ( ! wp || ! wp.editor || ! wp.editor.initialize ) {
124
+ yikes_woo_get_wp_editor_ajax( textarea_id, product_page, tab_content );
125
+ return false;
126
+ }
127
+
128
+ // Re-enable buttons / arrows
129
+ yikes_woo_toggle_controls( 'enable' );
130
+
131
+ var settings = {
132
+ tinymce: {
133
+ branding: false,
134
+ theme: 'modern',
135
+ skin: 'lightgray',
136
+ language: 'en',
137
+ formats: {
138
+ alignleft: [
139
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'left' } },
140
+ { selector: 'img,table,dl.wp-caption', classes: 'alignleft' }
141
+ ],
142
+ aligncenter: [
143
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'center' } },
144
+ { selector: 'img,table,dl.wp-caption', classes: 'aligncenter' }
145
+ ],
146
+ alignright: [
147
+ { selector: 'p,h1,h2,h3,h4,h5,h6,td,th,div,ul,ol,li', styles: { textAlign:'right' } },
148
+ { selector: 'img,table,dl.wp-caption', classes: 'alignright' }
149
+ ],
150
+ strikethrough: { inline: 'del' }
151
+ },
152
+ relative_urls: false,
153
+ remove_script_host: false,
154
+ convert_urls: false,
155
+ browser_spellcheck: true,
156
+ fix_list_elements: true,
157
+ entities: '38,amp,60,lt,62,gt',
158
+ entity_encoding: 'raw',
159
+ keep_styles: false,
160
+ paste_webkit_styles: 'font-weight font-style color',
161
+ preview_styles: 'font-family font-size font-weight font-style text-decoration text-transform',
162
+ end_container_on_empty_block: true,
163
+ wpeditimage_disable_captions: false,
164
+ wpeditimage_html5_captions: true,
165
+ plugins: 'charmap,colorpicker,hr,lists,media,paste,tabfocus,textcolor,fullscreen,wordpress,wpautoresize,wpeditimage,wpemoji,wpgallery,wplink,wpdialogs,wptextpattern,wpview',
166
+ menubar: false,
167
+ wpautop: true,
168
+ indent: false,
169
+ resize: true,
170
+ theme_advanced_resizing: true,
171
+ theme_advanced_resize_horizontal: false,
172
+ statusbar: true,
173
+ toolbar1: 'formatselect,bold,italic,bullist,numlist,blockquote,alignleft,aligncenter,alignright,link,unlink,wp_adv',
174
+ toolbar2: 'strikethrough,hr,forecolor,pastetext,removeformat,charmap,outdent,indent,undo,redo,wp_help',
175
+ toolbar3: '',
176
+ toolbar4: '',
177
+ tabfocus_elements: ':prev,:next',
178
+ // width: '100%',
179
+ // body_class: 'id post-type-post post-status-publish post-format-standard',
180
+ setup: function( editor ) {
181
+ editor.on( 'init', function() {
182
+ this.getBody().style.fontFamily = 'Georgia, "Times New Roman", "Bitstream Charter", Times, serif';
183
+ this.getBody().style.fontSize = '16px';
184
+ this.getBody().style.color = '#333';
185
+ if ( tab_content.length > 0 ) {
186
+ this.setContent( tab_content );
187
+ }
188
+ });
189
+ },
190
+ },
191
+ quicktags: {
192
+ buttons:"strong,em,link,block,del,ins,img,ul,ol,li,code,more,close"
193
+ }
194
+ }
195
+
196
+ wp.editor.initialize( textarea_id, settings );
197
+
198
+ // If we're on the button page, show the button holder (we temporarily hide it for UI/UX purposes)
199
+ // if ( product_page === true ) {
200
+ // jQuery( '.button-holder' ).show();
201
+ // }
202
+
203
+ // After tinymce is initialized, let's check if we need to disable the box (because it's a saved tab)
204
+ var tab_number = yikes_woo_get_tab_number_from_id( textarea_id );
205
+ if ( jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).hasClass( 'yikes_woo_disable_this_tab' ) ) {
206
+ jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).removeClass( 'yikes_woo_disable_this_tab' );
207
+ yikes_woo_toggle_reusable_override_overlay( 'disable', tab_number );
208
+ }
209
+
210
+ // Add an 'Add Media' button
211
+ // The plugin is included with the instantiation of the editor but there is no HTML button to trigger the associated functions
212
+ var add_media_button = '<div id="wp-' + textarea_id + '-media-buttons" class="wp-media-buttons"> \
213
+ <button type="button" id="insert-media-button" class="button insert-media add_media" data-editor="' + textarea_id + '"><span class="wp-media-buttons-icon"></span> Add Media</button>\
214
+ </div>';
215
+ jQuery( '#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_' + tab_number + '-wrap > .wp-editor-tools' ).prepend( add_media_button );
216
+
217
+ return true;
218
+ }
219
+
220
+ /**
221
+ * @summary Get the numerical ID from a string ID
222
+ *
223
+ * @param string | id_string | an id of the form this_is_an_id_10
224
+ * @return string | tab_number | the numerical suffix of the string id passed in
225
+ */
226
+ function yikes_woo_get_tab_number_from_id( id_string ) {
227
+ return id_string.slice( ( id_string.lastIndexOf( '_' ) + 1 ) );
228
+ }
229
+
230
+ /**
231
+ * @summary Toggle disabling/hiding of UI buttons, this prevents potentially breaking the UI while AJAX is returning
232
+ *
233
+ * @since 1.5
234
+ *
235
+ * @param string | toggle_enable | 'disable' to disable/hide, 'enable' to enable/show
236
+ *
237
+ */
238
+ function yikes_woo_toggle_controls( toggle_enable ) {
239
+ if ( toggle_enable === 'disable' ) {
240
+ jQuery( '.remove_this_tab' ).attr( 'disabled', 'disabled' );
241
+ jQuery( '#add_another_tab' ).attr( 'disabled', 'disabled' );
242
+ jQuery( '._yikes_wc_apply_a_saved_tab' ).attr( 'disabled', 'disabled' );
243
+ jQuery( '.move-tab-data-up' ).hide();
244
+ jQuery( '.move-tab-data-down' ).hide();
245
+ } else {
246
+ jQuery( '.remove_this_tab' ).removeAttr( 'disabled' );
247
+ jQuery( '#add_another_tab' ).removeAttr( 'disabled' );
248
+ jQuery( '._yikes_wc_apply_a_saved_tab' ).removeAttr( 'disabled' )
249
+ jQuery( '.move-tab-data-up' ).show();
250
+ jQuery( '.move-tab-data-down' ).show();
251
+ }
252
+ }
253
+
254
+ /**
255
+ * @summary Display a simple error or success message
256
+ *
257
+ * @since 1.5
258
+ *
259
+ * @param string | anchor_element | a selector for an element we're going to display the message next to
260
+ * @param string | message_element_id| the ID of the element we're creating to hold the message
261
+ * @param string | message | the message we're displaying to the user
262
+ * @param object | options | Collection of options for customizing the error message
263
+ *
264
+ */
265
+ function yikes_woo_display_feedback_messages( anchor_element_id, message_element_id, message, options ) {
266
+
267
+ var defaults = {
268
+ 'inline': false,
269
+ 'classes': [],
270
+ 'css_string': '',
271
+ 'time': 3000
272
+ }
273
+
274
+ var opts = jQuery.extend( defaults, options );
275
+
276
+ //remove any other success / error message elements
277
+ jQuery( '._yikes_wc_feedback_message' ).remove();
278
+
279
+ // Construct style string
280
+ var style_string = '';
281
+ if ( opts.css_string.length > 0 ) {
282
+ style_string = opts.css_string;
283
+ }
284
+
285
+ // Construct class string
286
+ var classes = defaults.classes;
287
+ if ( opts.classes.length > 0 ) {
288
+ opts.classes.each( function( index, class_name ) {
289
+ classes += class_name;
290
+ });
291
+ }
292
+
293
+ var dynamic_message_elements = '';
294
+
295
+ // Construct our message
296
+ if ( opts.inline === true ) {
297
+ dynamic_message_elements = '<span id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</span>';
298
+ } else {
299
+ dynamic_message_elements = '<p id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</p>';
300
+ }
301
+
302
+ // Add our message to the DOM
303
+ jQuery( anchor_element_id ).after( dynamic_message_elements );
304
+
305
+ // Display message by fadein/fadeout
306
+ jQuery( '#' + message_element_id ).fadeIn( 500 ).delay( opts.time ).fadeOut( 500 );
307
+ }
308
+
309
+ /**
310
+ * @summary Slide down / slide up our 'How To' info and swap dashicons
311
+ *
312
+ * @since 1.5
313
+ *
314
+ */
315
+ function yikes_woo_toggle_how_to() {
316
+ jQuery( '.yikes-woo-tabs-hidden-how-to-info' ).slideToggle( 'fast', function() {
317
+ if ( jQuery( '#yikes-woo-help-me-icon' ).hasClass( 'dashicons-editor-help' ) ) {
318
+ jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-editor-help' ).addClass( 'dashicons-dismiss' );
319
+ } else {
320
+ jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-dismiss' ).addClass( 'dashicons-editor-help' );
321
+ }
322
+ });
323
+ }
324
+
325
+ /**
326
+ * Retrieve the content from the wp_editor
327
+ *
328
+ * @since 1.5
329
+ *
330
+ * @param string | editor_id | the id of the editor (without the prefacing #)
331
+ * @return string | content | the content of the editor
332
+ */
333
+ function yikes_woo_get_content_from_wysiwyg( editor_id ) {
334
+
335
+ var content = '';
336
+
337
+ // Check if tinymce is initialized, and if our instance is known
338
+ if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
339
+
340
+ // Store the content
341
+ content = tinymce.get( editor_id ).getContent();
342
+
343
+ // If we don't have any content, check the textarea for a value and use it
344
+ if ( content.length === 0 && jQuery( '#' + editor_id ).val().length > 0 ) {
345
+ content = jQuery( '#' + editor_id ).val();
346
+ }
347
+ } else {
348
+
349
+ // If tinymce is not initialized, try getting the content from the textarea value
350
+ content = jQuery( '#' + editor_id ).val();
351
+ }
352
+
353
+ return content;
354
+ }
355
+
356
+ /**
357
+ * Set the content for the wp_editor
358
+ *
359
+ * @since 1.5
360
+ *
361
+ * @param string | editor_id | the id of the editor (without the prefacing #)
362
+ * @param string | content | the content to supply the editor with
363
+ */
364
+ function yikes_woo_set_content_for_wysiwyg( editor_id, content ) {
365
+
366
+ // Check if tinymce is initialized, and if our instance is known
367
+ if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
368
+
369
+ // If it's initialized, we can just set the content from here using setContent()
370
+ tinymce.get( editor_id ).setContent( content );
371
+
372
+ // tinyMCE stores the value in both places, so we need to set the textarea content from here too
373
+ jQuery( '#' + editor_id ).val( content );
374
+ } else {
375
+
376
+ // Else we need to set the value using the textarea's val
377
+ jQuery( '#' + editor_id ).val( content );
378
+ }
379
+ }
380
+
381
+
382
+
383
+
384
+
js/twitter-embed.js CHANGED
@@ -1,17 +1,17 @@
1
- /** Used for the Tweet Button **/
2
- window.twttr = (function(d, s, id) {
3
- var js, fjs = d.getElementsByTagName(s)[0],
4
- t = window.twttr || {};
5
- if (d.getElementById(id)) return t;
6
- js = d.createElement(s);
7
- js.id = id;
8
- js.src = "https://platform.twitter.com/widgets.js";
9
- fjs.parentNode.insertBefore(js, fjs);
10
-
11
- t._e = [];
12
- t.ready = function(f) {
13
- t._e.push(f);
14
- };
15
-
16
- return t;
17
  }(document, "script", "twitter-wjs"));
1
+ /** Used for the Tweet Button **/
2
+ window.twttr = (function(d, s, id) {
3
+ var js, fjs = d.getElementsByTagName(s)[0],
4
+ t = window.twttr || {};
5
+ if (d.getElementById(id)) return t;
6
+ js = d.createElement(s);
7
+ js.id = id;
8
+ js.src = "https://platform.twitter.com/widgets.js";
9
+ fjs.parentNode.insertBefore(js, fjs);
10
+
11
+ t._e = [];
12
+ t.ready = function(f) {
13
+ t._e.push(f);
14
+ };
15
+
16
+ return t;
17
  }(document, "script", "twitter-wjs"));
public/class.yikes-woo-tabs-display.php CHANGED
@@ -1,123 +1,123 @@
1
- <?php
2
-
3
- if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Display' ) ) {
4
-
5
- class YIKES_Custom_Product_Tabs_Display {
6
-
7
-
8
- public function __construct() {
9
-
10
- add_action( 'woocommerce_init', array( $this, 'init' ) );
11
- }
12
-
13
- public function init() {
14
-
15
- // Add our custom product tabs section to the product page
16
- add_filter( 'woocommerce_product_tabs', array( $this, 'add_custom_product_tabs' ) );
17
-
18
- // Allow the use of shortcodes within the tab content
19
- add_filter( 'yikes_woocommerce_custom_repeatable_product_tabs_content', 'do_shortcode' );
20
- }
21
-
22
- /**
23
- * Add the custom product tab to the front-end single product page
24
- *
25
- * $tabs structure:
26
- * Array(
27
- * id => Array(
28
- * 'title' => (string) Tab title,
29
- * 'priority' => (string) Tab priority,
30
- * 'callback' => (mixed) callback function,
31
- * )
32
- * )
33
- *
34
- * @param array | $tabs | Array representing this product's current tabs
35
- *
36
- * @return array | Array of this product's current tabs plus our custom tabs
37
- */
38
- public function add_custom_product_tabs( $tabs ) {
39
- global $product;
40
-
41
- $product_id = method_exists( $product, 'get_id' ) === true ? $product->get_id() : $product->ID;
42
-
43
- $product_tabs = maybe_unserialize( get_post_meta( $product_id, 'yikes_woo_products_tabs' , true ) );
44
-
45
- if ( ! empty( $product_tabs ) ) {
46
-
47
- // Setup priorty to loop over, and render tabs in proper order
48
- $i = 25;
49
-
50
- foreach ( $product_tabs as $tab ) {
51
-
52
- // Do not show tabs with empty titles on the front end
53
- if ( empty( $tab['title'] ) ) {
54
- continue;
55
- }
56
-
57
- $tab_key = $tab['id'];
58
-
59
- $tabs[ $tab_key ] = array(
60
- 'title' => $tab['title'],
61
- 'priority' => $i++,
62
- 'callback' => array( $this, 'custom_product_tabs_panel_content' ),
63
- 'content' => $tab['content']
64
- );
65
- }
66
- if ( isset( $tabs['reviews'] ) ) {
67
-
68
- // Make sure the reviews tab remains on the end (if it is set)
69
- $tabs['reviews']['priority'] = $i;
70
- }
71
- }
72
-
73
- /**
74
- * Filter: 'yikes_woo_filter_all_product_tabs'
75
- *
76
- * Generic filter that passes all of the tab info and the corresponding product. Cheers.
77
- *
78
- * Note: This passes all of the tabs for the current product, not just the Custom Product Tabs created by this plugin.
79
- *
80
- * @param array | $tab | Array of $tab data arrays.
81
- * @param object | $product | The WooCommerce product these tabs are for
82
- */
83
- $tabs = apply_filters( 'yikes_woo_filter_all_product_tabs', $tabs, $product );
84
-
85
- return $tabs;
86
-
87
- }
88
-
89
-
90
- /**
91
- * Render the custom product tab panel content for the given $tab
92
- *
93
- * $tab structure:
94
- * Array(
95
- * 'title' => (string) Tab title,
96
- * 'priority' => (string) Tab priority,
97
- * 'callback' => (mixed) callback function,
98
- * 'id' => (int) tab post identifier,
99
- * 'content' => (sring) tab content,
100
- * )
101
- *
102
- **/
103
- public function custom_product_tabs_panel_content( $key, $tab ) {
104
-
105
- $content = '';
106
-
107
- $use_the_content_filter = apply_filters( 'yikes_woo_use_the_content_filter', true );
108
-
109
- if ( $use_the_content_filter === true ) {
110
- $content = apply_filters( 'the_content', $tab['content'] );
111
- } else {
112
- $content = apply_filters( 'yikes_woo_filter_main_tab_content', $tab['content'] );
113
- }
114
-
115
- $tab_title_html = '<h2 class="yikes-custom-woo-tab-title yikes-custom-woo-tab-title-' . urldecode( sanitize_title( $tab['title'] ) ) . '">' . $tab['title'] . '</h2>';
116
- echo apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_heading', $tab_title_html, $tab );
117
- echo apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_content', $content, $tab );
118
- }
119
-
120
- }
121
-
122
- new YIKES_Custom_Product_Tabs_Display();
123
  }
1
+ <?php
2
+
3
+ if ( ! class_exists( 'YIKES_Custom_Product_Tabs_Display' ) ) {
4
+
5
+ class YIKES_Custom_Product_Tabs_Display {
6
+
7
+
8
+ public function __construct() {
9
+
10
+ add_action( 'woocommerce_init', array( $this, 'init' ) );
11
+ }
12
+
13
+ public function init() {
14
+
15
+ // Add our custom product tabs section to the product page
16
+ add_filter( 'woocommerce_product_tabs', array( $this, 'add_custom_product_tabs' ) );
17
+
18
+ // Allow the use of shortcodes within the tab content
19
+ add_filter( 'yikes_woocommerce_custom_repeatable_product_tabs_content', 'do_shortcode' );
20
+ }
21
+
22
+ /**
23
+ * Add the custom product tab to the front-end single product page
24
+ *
25
+ * $tabs structure:
26
+ * Array(
27
+ * id => Array(
28
+ * 'title' => (string) Tab title,
29
+ * 'priority' => (string) Tab priority,
30
+ * 'callback' => (mixed) callback function,
31
+ * )
32
+ * )
33
+ *
34
+ * @param array | $tabs | Array representing this product's current tabs
35
+ *
36
+ * @return array | Array of this product's current tabs plus our custom tabs
37
+ */
38
+ public function add_custom_product_tabs( $tabs ) {
39
+ global $product;
40
+
41
+ $product_id = method_exists( $product, 'get_id' ) === true ? $product->get_id() : $product->ID;
42
+
43
+ $product_tabs = maybe_unserialize( get_post_meta( $product_id, 'yikes_woo_products_tabs' , true ) );
44
+
45
+ if ( ! empty( $product_tabs ) ) {
46
+
47
+ // Setup priorty to loop over, and render tabs in proper order
48
+ $i = 25;
49
+
50
+ foreach ( $product_tabs as $tab ) {
51
+
52
+ // Do not show tabs with empty titles on the front end
53
+ if ( empty( $tab['title'] ) ) {
54
+ continue;
55
+ }
56
+
57
+ $tab_key = $tab['id'];
58
+
59
+ $tabs[ $tab_key ] = array(
60
+ 'title' => $tab['title'],
61
+ 'priority' => $i++,
62
+ 'callback' => array( $this, 'custom_product_tabs_panel_content' ),
63
+ 'content' => $tab['content']
64
+ );
65
+ }
66
+ if ( isset( $tabs['reviews'] ) ) {
67
+
68
+ // Make sure the reviews tab remains on the end (if it is set)
69
+ $tabs['reviews']['priority'] = $i;
70
+ }
71
+ }
72
+
73
+ /**
74
+ * Filter: 'yikes_woo_filter_all_product_tabs'
75
+ *
76
+ * Generic filter that passes all of the tab info and the corresponding product. Cheers.
77
+ *
78
+ * Note: This passes all of the tabs for the current product, not just the Custom Product Tabs created by this plugin.
79
+ *
80
+ * @param array | $tab | Array of $tab data arrays.
81
+ * @param object | $product | The WooCommerce product these tabs are for
82
+ */
83
+ $tabs = apply_filters( 'yikes_woo_filter_all_product_tabs', $tabs, $product );
84
+
85
+ return $tabs;
86
+
87
+ }
88
+
89
+
90
+ /**
91
+ * Render the custom product tab panel content for the given $tab
92
+ *
93
+ * $tab structure:
94
+ * Array(
95
+ * 'title' => (string) Tab title,
96
+ * 'priority' => (string) Tab priority,
97
+ * 'callback' => (mixed) callback function,
98
+ * 'id' => (int) tab post identifier,
99
+ * 'content' => (sring) tab content,
100
+ * )
101
+ *
102
+ **/
103
+ public function custom_product_tabs_panel_content( $key, $tab ) {
104
+
105
+ $content = '';
106
+
107
+ $use_the_content_filter = apply_filters( 'yikes_woo_use_the_content_filter', true );
108
+
109
+ if ( $use_the_content_filter === true ) {
110
+ $content = apply_filters( 'the_content', $tab['content'] );
111
+ } else {
112
+ $content = apply_filters( 'yikes_woo_filter_main_tab_content', $tab['content'] );
113
+ }
114
+
115
+ $tab_title_html = '<h2 class="yikes-custom-woo-tab-title yikes-custom-woo-tab-title-' . urldecode( sanitize_title( $tab['title'] ) ) . '">' . $tab['title'] . '</h2>';
116
+ echo apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_heading', $tab_title_html, $tab );
117
+ echo apply_filters( 'yikes_woocommerce_custom_repeatable_product_tabs_content', $content, $tab );
118
+ }
119
+
120
+ }
121
+
122
+ new YIKES_Custom_Product_Tabs_Display();
123
  }
readme.txt CHANGED
@@ -1,241 +1,244 @@
1
- === Custom Product Tabs for WooCommerce ===
2
- Contributors: yikesinc, eherman24, liljimmi, yikesitskevin, metalandcoffee, mialevesque
3
- Donate link: http://yikesinc.com
4
- Tags: woocommerce, product tabs, repeatable, duplicate, customize, custom, tabs, product, woo, commerce
5
- Requires at least: 3.8
6
- Tested up to: 5.2.0
7
- Stable tag: 1.6.10
8
- License: GPLv2 or later
9
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
-
11
- Add custom tabs with content to products in WooCommerce.
12
-
13
- == Description ==
14
-
15
- This plugin extends [WooCommerce](www.woothemes.com/woocommerce/) to allow shop owners to add custom tabs to products. The tabs are displayed on the individual product pages to the right of the default "Description" tab.
16
-
17
- Individual product tabs are managed on the WooCommerce Edit Product screen and can be added on a per product basis. You can also create saved tabs and add them to multiple products as needed. Tabs can be easily added, deleted and rearranged.
18
-
19
- Tab content areas use the standard WordPress text editor and may contain text, images, HTML or shortcodes.
20
-
21
- If you experience any problems, please submit a ticket on our [Free WordPress Support Forums](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs) and we'll look in to it as soon as possible.
22
-
23
- This plugin is compatible with WPML.
24
-
25
- Upgrade to [Custom Product Tabs Pro](https://yikesplugins.com/plugin/custom-product-tabs-pro/) for great enhanced features!
26
-
27
- == Installation ==
28
-
29
- 1. Download the plugin .zip file and make note of where on your computer you downloaded it to.
30
- 2. In the WordPress admin (yourdomain.com/wp-admin) go to Plugins > Add New or click the "Add New" button on the main plugins screen.
31
- 3. On the following screen, click the "Upload Plugin" button.
32
- 4. Browse your computer to where you downloaded the plugin .zip file, select it and click the "Install Now" button.
33
- 5. After the plugin has successfully installed, click "Activate Plugin" and enjoy!
34
- 6. Edit a product, then click on 'Custom Tab' within the 'Product Data' panel
35
- 7. Create saved, reusable tabs under Settings > Custom Product Tabs for WooCommerce
36
-
37
- == Screenshots ==
38
-
39
- 1. Custom Tabs manager on the 'Edit Product' screen
40
- 2. Custom product tab content displayed on the front end
41
- 3. All of the saved tabs on the settings page
42
- 4. Editing a single saved tab
43
-
44
- == Frequently Asked Questions ==
45
-
46
- **All documentation can be found in [our Knowledge Base](https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/).**
47
-
48
- = Where do I go to add tabs to a product? =
49
- When editing a product in WooCommerce, you will find "Custom Tabs" in the bottom left corner of the Product Data box. Click on "Custom Tabs" to reveal the custom tab manager.
50
-
51
- = Where will these tabs appear? =
52
- When the product is viewed on your website you will see the tabs you created to the right of the default "Description" tab.
53
-
54
- = How do I change the order of the tabs? =
55
- To change the order of custom tabs use the up and down "Move tab order" arrows.
56
-
57
- = How do saved tabs work? =
58
- Saved tabs are tabs you can create and then add to as many products you would like. If you update a saved tab, the changes will be updated for all products using that tab.
59
-
60
- = How do I create saved tabs? =
61
- To create a saved tab, click on the 'Custom Product Tabs' item on the WordPress dashboard menu and click the "Add Tab" button.
62
-
63
- = How do I add a saved tab to a product? =
64
- To add a saved tab to a product, go to the custom tabs section on the edit product screen, click the 'Add a Saved Tab' button above the tab, and choose which tab you would like to add.
65
-
66
- = What does overriding a saved tab do? =
67
- When using a saved tab on a product, a checkbox appears with the message 'Override Saved Tab' If you click that checkbox, edit the tab and save, the tab will be changed for that product only. Any edits to that saved tab under 'Custom Product Tabs' will not be applied to that product.
68
-
69
- = Why does the WYSIWYG editor default to the 'Visual' tab? =
70
- This was added in version 1.5 to support the dynamic adding and removing of the wp_editor/WYSIWYG editor. Without this setting, the WYSIWYG editor does not load the correct toolbar and the editor can potentially break.
71
-
72
- = Does custom tab data get exported with standard WooCommerce product data? =
73
- Yes! Since v1.4 we've added the necessary code to ensure the custom tab data is exported with all of the other standard WooCommerce data. This ensures a smooth transition of products between sites.
74
-
75
-
76
- == Changelog ==
77
-
78
- = 1.6.10 - April 19th, 2019 =
79
- * Updating WC compatibility.
80
- * Fixing JS issue with WP backwards compatibility for versions < 4.7.
81
-
82
- = 1.6.9 - January 18th, 2019 =
83
- * Fixing an issue where the visual editor shows a small portion of the content on product edit pages.
84
-
85
- = 1.6.8 - January 2nd, 2019 =
86
- * Fixing some HTML markup.
87
- * Applying PHPCS fixes.
88
-
89
- = 1.6.7 - December 18th, 2018 =
90
- * Adding filter to help allow importing of custom tabs.
91
- * Changing our export filters so custom tabs work with WooCommerce's native meta export/import features.
92
- * The default capability for all admin pages is now `publish_products`.
93
-
94
- = 1.6.6 - October 26th, 2018 =
95
- * Bumping WooCo Compatibility.
96
- * Changed `wp_send_json_failure()` to `wp_send_json_error()`.
97
-
98
- = 1.6.5 - October 3rd, 2018 =
99
- * Bumping WooCo Compatibility.
100
-
101
- = 1.6.4 - January 9th, 2018 =
102
- * Happy new year!
103
- * The editor is now vertically resizeable.
104
- * The default capability for interacting with saved tabs is now Publish Products (publish_products)
105
-
106
- = 1.6.3 - November 1st, 2017 =
107
- * Declaring compatibility with WooCommerce and WordPress
108
-
109
- = 1.6.2 - October 13th, 2017 =
110
- * Fixed a PHP Fatal Error that was occurring for users with PHP versions < 5.5.
111
- * Updated some of our documentation and language
112
-
113
- = 1.6.1 - October 12th, 2017 =
114
- * Fixed an issue with handling foreign characters. Foreign character tab titles should be working properly now. Sorry about that everyone!
115
- * Added support for native WooCommerce exporting. You can now export and import your tabs with just WooCommerce!
116
- * Fixed some styling issues
117
- * Added a new "Support" page
118
- * Added a new "Go Pro" page - check out [Custom Product Tabs Pro](https://yikesplugins.com/plugin/custom-product-tabs-pro/)
119
-
120
- = 1.6.0 - October 9th, 2017 =
121
- * Complete re-organization of all plugin files and removal of legacy code
122
- * Added a "name" field for saved tabs. This field is used only on the admin as a way of identifying tabs.
123
- * Tab "slugs" are now created via the WP Core `sanitize_title()` function. This should allow meaningful tab slugs when foreign characters are used in a title.
124
- * Re-added the "Add Media" button to the editor when it's first initialized. This had disappeared when WP4.8 was released.
125
- * Fixed some issues with loading saved tab content into the editor. This should fix the issue that some users were experiencing where adding a saved tab would only work the second time.
126
- * Setting the width of the editor to 100%.
127
- * Custom Product Tabs is now a top-level menu item instead of a sub-menu item.
128
- * Cleaning up the saved tab's array so we don't leave orphaned data (e.g. added a hook so we delete a product's tabs when the product is deleted)
129
- * Added a data update script to update all existing tab slugs to use `sanitize_title()` function.
130
- * Generated new POT file.
131
- * Added support and hooks for our new Custom Product Tabs Pro plugin!
132
-
133
- = 1.5.17 - August 23rd, 2017 =
134
- * Cleaning up some PHP Notices being thrown - thanks to @ZombiEquinox on GitHub for reporting this
135
- * Updating readme compatibility values
136
-
137
- = 1.5.16 - August 1st, 2017 =
138
- * Adding a proper deactivation hook. The plugin will leave no trace.
139
-
140
- = 1.5.15 - June 8th, 2017 =
141
- * WordPress 4.8 support - using the new JavaScript Editor API functions to instantiate the editor and removed requiring WordPress' wpembed plugin
142
-
143
- = 1.5.14 - May 8th, 2017 =
144
- * Updating some CSS for the admin tabs table - the table should now render correctly regardless of "Visual" or "Text" tab and the saved tabs list should include a scrollbar if necessary
145
-
146
- = 1.5.13 - April 17th, 2017 =
147
- * Updating a WooCommerce action - now using the proper one instead of a deprecated one
148
-
149
- = 1.5.12 - April 10th, 2017 =
150
- * Adding some CSS to allow the editor's text mode to function properly
151
-
152
- = 1.5.11 - April 6th, 2017 =
153
- * Checking for the existence of the `get_id()` method before using it.
154
-
155
- = 1.5.10 - April 5th, 2017 =
156
- * Duplicating a product now duplicates custom product tabs and saved tabs correctly
157
-
158
- = 1.5.9 - April 4th, 2017 =
159
- * Tested and updated the plugin for WooCommerce v3.0.0
160
-
161
- = 1.5.8 - March 17th, 2017 =
162
- * Replaced the saved tab's ID w/ an "Add New" button on the single saved tab page - it should be easier to add saved tabs in bulk now
163
- * Added a filter for all of the custom tab content - it should allow you to apply custom logic such as permissions in one central location
164
- * Changed the way saved tabs are applied on the edit product page - it should allow embed content (especially Google Maps Embed content) to function correctly in all instances.
165
-
166
- = 1.5.7 - February 27th, 2017 =
167
- * Duplicating a product now duplicates the corresponding saved tabs correctly
168
- * Added two filters (`yikes_woo_use_the_content_filter` and `yikes_woo_filter_main_tab_content`) to help provide a work-around to using the standard `the_content` filter which has caused numerous issues due to plugin conflicts.
169
-
170
- = 1.5.6 - February 16th, 2017 =
171
- * Fixed an issue where the "Add a Saved Tab" modal was displaying YouTube videos if a saved tab had a YouTube URL in its content
172
-
173
- = 1.5.5 - January 23rd, 2017 =
174
- * Re-did 1.5.4 changes - checking for function existence before using it
175
-
176
- = 1.5.4 - January 23rd, 2017 =
177
- * Re-did 1.5.3 changes - `the_content` filter is reapplied and the specific Site Builder plugin's filters are
178
-
179
- = 1.5.3 - January 23rd, 2017 =
180
- * Replaced the use of `the_content` filter with the filter's associated functions (e.g. `wptexturize`, `wpautop`)
181
-
182
- = 1.5.2 - December 23rd, 2016 =
183
- * The editor should only default to the 'Visual' tab for our Custom Product Tabs (no other editors)
184
- * Added all of the default WordPress settings to the editor
185
-
186
- = 1.5.1 - December 22nd, 2016 =
187
- * Fixed bug that caused content to be copied incorrectly when moving tabs up / down
188
- * Only on the product page will the editor default to 'Visual' (instead of every page)
189
-
190
- = 1.5 - December 20th, 2016 =
191
- * Version 1.5 includes a brand new feature - saved tabs - as well as a number of bug fixes, style tweaks, code clean-up, and comments
192
- * UI: Complete overhaul of the custom tab interface for an easier, responsive tab creating experience.
193
- * Saved Tabs: A new settings page has been added for users to create / update / delete saved tabs (see FAQ for more information)
194
- * Saved Tabs: On the product edit page, a new button ('Add a Saved Tab') has been added that allows you to choose one of your saved tabs and add it to the current product
195
- * Adding a new tab initializes a new wp_editor (WYSIWYG) instead of a plain textarea
196
- * Added warning message when two tabs have the same title
197
- * Tabs with empty titles are no longer shown on the product page
198
- * Added ability to remove the first tab
199
- * Adding, moving, and removing tabs works as expected when the user's 'Visual Editor' option is checked
200
- * On the product & settings pages, WYSIWYG editors will default to the visual tab (this helps prevent errors with dynamic wp_editor generation)
201
- * Added a filter `yikes_woocommerce_default_editor_mode` that can change the default-to-visual-tab behavior (use at your own risk!)
202
- * Updated the 'How To' text, and slight modification to the style
203
- * Changed the JavaScript methods controlling how tabs were added, deleted, and moved up/down
204
- * Cleaned up and commented on all PHP and JavaScript files
205
- * Added proper i18n, with languages/ folder, .pot file, and `load_plugin_textdomain` hook
206
- * Incremented version #
207
-
208
- = 1.4.4 - March 1st, 2016 =
209
- * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
210
-
211
- = 1.4.3 - February 18th, 2016 =
212
- * Wrapped missing 'Custom Tab Title' in localization/translation functions. (Plugin is now 100% translatable)
213
- * Removed i18n class files, and old .po/.mo files (less bloat)
214
-
215
- = 1.4.2 - February 17th, 2016 =
216
- * Updated the internationalization strings ( `yikes-inc-woocommerce-custom-product-tabs` to `yikes-inc-easy-custom-woocommerce-product-tabs` )
217
-
218
- = 1.4.1 - August 20th, 2015 =
219
- * Fixed conflict with other CSV export plugins for WooCommerce
220
- * Now custom product tab and row data/headers only get exported via 'Tools > Export > Products'
221
-
222
- = 1.4 - July 29th, 2015 =
223
- * Enhancement: Added the 'Custom Product Tabs for WooCommerce ' data to the standard WooCommerce export file, so custom tab data can be transferred between sites smoothly.
224
-
225
- = 1.3 - July 21st, 2015 =
226
- * Enhancement: Enabled WYSIWYG editor on tab content containers (enables shortcode and content to pass through the_content() filter)
227
- * Updated repo screenshots and descriptions
228
-
229
- = 1.2 - March 18th, 2015 =
230
- * Enhancement: Fixed issue where non utf8 characters in tab titles caused front end not to generate the tabs
231
- * Enhancement: When user doesn't have WooCommerce installed, they are now redirected to the plugin install search page, with WooCommerce at the top.
232
-
233
- = 1.1 =
234
- * Added class to the Woo tabs content title, for targeting via CSS ( `.yikes-custom-woo-tab-title` )
235
-
236
- = 1.0.0 =
237
- * Initial Release
238
-
239
- == Upgrade Notice ==
240
- = 1.4.4 - March 1st, 2016 =
 
 
 
241
  * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
1
+ === Custom Product Tabs for WooCommerce ===
2
+ Contributors: yikesinc, eherman24, liljimmi, yikesitskevin, metalandcoffee, mialevesque
3
+ Donate link: http://yikesinc.com
4
+ Tags: woocommerce, product tabs, repeatable, duplicate, customize, custom, tabs, product, woo, commerce
5
+ Requires at least: 3.8
6
+ Tested up to: 5.3
7
+ Stable tag: 1.6.11
8
+ License: GPLv2 or later
9
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
+
11
+ Add custom tabs with content to products in WooCommerce.
12
+
13
+ == Description ==
14
+
15
+ This plugin extends [WooCommerce](www.woothemes.com/woocommerce/) to allow shop owners to add custom tabs to products. The tabs are displayed on the individual product pages to the right of the default "Description" tab.
16
+
17
+ Individual product tabs are managed on the WooCommerce Edit Product screen and can be added on a per product basis. You can also create saved tabs and add them to multiple products as needed. Tabs can be easily added, deleted and rearranged.
18
+
19
+ Tab content areas use the standard WordPress text editor and may contain text, images, HTML or shortcodes.
20
+
21
+ If you experience any problems, please submit a ticket on our [Free WordPress Support Forums](https://wordpress.org/support/plugin/yikes-inc-easy-custom-woocommerce-product-tabs) and we'll look in to it as soon as possible.
22
+
23
+ This plugin is compatible with WPML.
24
+
25
+ Upgrade to [Custom Product Tabs Pro](https://yikesplugins.com/plugin/custom-product-tabs-pro/) for great enhanced features!
26
+
27
+ == Installation ==
28
+
29
+ 1. Download the plugin .zip file and make note of where on your computer you downloaded it to.
30
+ 2. In the WordPress admin (yourdomain.com/wp-admin) go to Plugins > Add New or click the "Add New" button on the main plugins screen.
31
+ 3. On the following screen, click the "Upload Plugin" button.
32
+ 4. Browse your computer to where you downloaded the plugin .zip file, select it and click the "Install Now" button.
33
+ 5. After the plugin has successfully installed, click "Activate Plugin" and enjoy!
34
+ 6. Edit a product, then click on 'Custom Tab' within the 'Product Data' panel
35
+ 7. Create saved, reusable tabs under Settings > Custom Product Tabs for WooCommerce
36
+
37
+ == Screenshots ==
38
+
39
+ 1. Custom Tabs manager on the 'Edit Product' screen
40
+ 2. Custom product tab content displayed on the front end
41
+ 3. All of the saved tabs on the settings page
42
+ 4. Editing a single saved tab
43
+
44
+ == Frequently Asked Questions ==
45
+
46
+ **All documentation can be found in [our Knowledge Base](https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/).**
47
+
48
+ = Where do I go to add tabs to a product? =
49
+ When editing a product in WooCommerce, you will find "Custom Tabs" in the bottom left corner of the Product Data box. Click on "Custom Tabs" to reveal the custom tab manager.
50
+
51
+ = Where will these tabs appear? =
52
+ When the product is viewed on your website you will see the tabs you created to the right of the default "Description" tab.
53
+
54
+ = How do I change the order of the tabs? =
55
+ To change the order of custom tabs use the up and down "Move tab order" arrows.
56
+
57
+ = How do saved tabs work? =
58
+ Saved tabs are tabs you can create and then add to as many products you would like. If you update a saved tab, the changes will be updated for all products using that tab.
59
+
60
+ = How do I create saved tabs? =
61
+ To create a saved tab, click on the 'Custom Product Tabs' item on the WordPress dashboard menu and click the "Add Tab" button.
62
+
63
+ = How do I add a saved tab to a product? =
64
+ To add a saved tab to a product, go to the custom tabs section on the edit product screen, click the 'Add a Saved Tab' button above the tab, and choose which tab you would like to add.
65
+
66
+ = What does overriding a saved tab do? =
67
+ When using a saved tab on a product, a checkbox appears with the message 'Override Saved Tab' If you click that checkbox, edit the tab and save, the tab will be changed for that product only. Any edits to that saved tab under 'Custom Product Tabs' will not be applied to that product.
68
+
69
+ = Why does the WYSIWYG editor default to the 'Visual' tab? =
70
+ This was added in version 1.5 to support the dynamic adding and removing of the wp_editor/WYSIWYG editor. Without this setting, the WYSIWYG editor does not load the correct toolbar and the editor can potentially break.
71
+
72
+ = Does custom tab data get exported with standard WooCommerce product data? =
73
+ Yes! Since v1.4 we've added the necessary code to ensure the custom tab data is exported with all of the other standard WooCommerce data. This ensures a smooth transition of products between sites.
74
+
75
+
76
+ == Changelog ==
77
+
78
+ = 1.6.11 - September 25th, 2019 =
79
+ * Adding additional checks to post global before enqueueing assets.
80
+
81
+ = 1.6.10 - April 19th, 2019 =
82
+ * Updating WC compatibility.
83
+ * Fixing JS issue with WP backwards compatibility for versions < 4.7.
84
+
85
+ = 1.6.9 - January 18th, 2019 =
86
+ * Fixing an issue where the visual editor shows a small portion of the content on product edit pages.
87
+
88
+ = 1.6.8 - January 2nd, 2019 =
89
+ * Fixing some HTML markup.
90
+ * Applying PHPCS fixes.
91
+
92
+ = 1.6.7 - December 18th, 2018 =
93
+ * Adding filter to help allow importing of custom tabs.
94
+ * Changing our export filters so custom tabs work with WooCommerce's native meta export/import features.
95
+ * The default capability for all admin pages is now `publish_products`.
96
+
97
+ = 1.6.6 - October 26th, 2018 =
98
+ * Bumping WooCo Compatibility.
99
+ * Changed `wp_send_json_failure()` to `wp_send_json_error()`.
100
+
101
+ = 1.6.5 - October 3rd, 2018 =
102
+ * Bumping WooCo Compatibility.
103
+
104
+ = 1.6.4 - January 9th, 2018 =
105
+ * Happy new year!
106
+ * The editor is now vertically resizeable.
107
+ * The default capability for interacting with saved tabs is now Publish Products (publish_products)
108
+
109
+ = 1.6.3 - November 1st, 2017 =
110
+ * Declaring compatibility with WooCommerce and WordPress
111
+
112
+ = 1.6.2 - October 13th, 2017 =
113
+ * Fixed a PHP Fatal Error that was occurring for users with PHP versions < 5.5.
114
+ * Updated some of our documentation and language
115
+
116
+ = 1.6.1 - October 12th, 2017 =
117
+ * Fixed an issue with handling foreign characters. Foreign character tab titles should be working properly now. Sorry about that everyone!
118
+ * Added support for native WooCommerce exporting. You can now export and import your tabs with just WooCommerce!
119
+ * Fixed some styling issues
120
+ * Added a new "Support" page
121
+ * Added a new "Go Pro" page - check out [Custom Product Tabs Pro](https://yikesplugins.com/plugin/custom-product-tabs-pro/)
122
+
123
+ = 1.6.0 - October 9th, 2017 =
124
+ * Complete re-organization of all plugin files and removal of legacy code
125
+ * Added a "name" field for saved tabs. This field is used only on the admin as a way of identifying tabs.
126
+ * Tab "slugs" are now created via the WP Core `sanitize_title()` function. This should allow meaningful tab slugs when foreign characters are used in a title.
127
+ * Re-added the "Add Media" button to the editor when it's first initialized. This had disappeared when WP4.8 was released.
128
+ * Fixed some issues with loading saved tab content into the editor. This should fix the issue that some users were experiencing where adding a saved tab would only work the second time.
129
+ * Setting the width of the editor to 100%.
130
+ * Custom Product Tabs is now a top-level menu item instead of a sub-menu item.
131
+ * Cleaning up the saved tab's array so we don't leave orphaned data (e.g. added a hook so we delete a product's tabs when the product is deleted)
132
+ * Added a data update script to update all existing tab slugs to use `sanitize_title()` function.
133
+ * Generated new POT file.
134
+ * Added support and hooks for our new Custom Product Tabs Pro plugin!
135
+
136
+ = 1.5.17 - August 23rd, 2017 =
137
+ * Cleaning up some PHP Notices being thrown - thanks to @ZombiEquinox on GitHub for reporting this
138
+ * Updating readme compatibility values
139
+
140
+ = 1.5.16 - August 1st, 2017 =
141
+ * Adding a proper deactivation hook. The plugin will leave no trace.
142
+
143
+ = 1.5.15 - June 8th, 2017 =
144
+ * WordPress 4.8 support - using the new JavaScript Editor API functions to instantiate the editor and removed requiring WordPress' wpembed plugin
145
+
146
+ = 1.5.14 - May 8th, 2017 =
147
+ * Updating some CSS for the admin tabs table - the table should now render correctly regardless of "Visual" or "Text" tab and the saved tabs list should include a scrollbar if necessary
148
+
149
+ = 1.5.13 - April 17th, 2017 =
150
+ * Updating a WooCommerce action - now using the proper one instead of a deprecated one
151
+
152
+ = 1.5.12 - April 10th, 2017 =
153
+ * Adding some CSS to allow the editor's text mode to function properly
154
+
155
+ = 1.5.11 - April 6th, 2017 =
156
+ * Checking for the existence of the `get_id()` method before using it.
157
+
158
+ = 1.5.10 - April 5th, 2017 =
159
+ * Duplicating a product now duplicates custom product tabs and saved tabs correctly
160
+
161
+ = 1.5.9 - April 4th, 2017 =
162
+ * Tested and updated the plugin for WooCommerce v3.0.0
163
+
164
+ = 1.5.8 - March 17th, 2017 =
165
+ * Replaced the saved tab's ID w/ an "Add New" button on the single saved tab page - it should be easier to add saved tabs in bulk now
166
+ * Added a filter for all of the custom tab content - it should allow you to apply custom logic such as permissions in one central location
167
+ * Changed the way saved tabs are applied on the edit product page - it should allow embed content (especially Google Maps Embed content) to function correctly in all instances.
168
+
169
+ = 1.5.7 - February 27th, 2017 =
170
+ * Duplicating a product now duplicates the corresponding saved tabs correctly
171
+ * Added two filters (`yikes_woo_use_the_content_filter` and `yikes_woo_filter_main_tab_content`) to help provide a work-around to using the standard `the_content` filter which has caused numerous issues due to plugin conflicts.
172
+
173
+ = 1.5.6 - February 16th, 2017 =
174
+ * Fixed an issue where the "Add a Saved Tab" modal was displaying YouTube videos if a saved tab had a YouTube URL in its content
175
+
176
+ = 1.5.5 - January 23rd, 2017 =
177
+ * Re-did 1.5.4 changes - checking for function existence before using it
178
+
179
+ = 1.5.4 - January 23rd, 2017 =
180
+ * Re-did 1.5.3 changes - `the_content` filter is reapplied and the specific Site Builder plugin's filters are
181
+
182
+ = 1.5.3 - January 23rd, 2017 =
183
+ * Replaced the use of `the_content` filter with the filter's associated functions (e.g. `wptexturize`, `wpautop`)
184
+
185
+ = 1.5.2 - December 23rd, 2016 =
186
+ * The editor should only default to the 'Visual' tab for our Custom Product Tabs (no other editors)
187
+ * Added all of the default WordPress settings to the editor
188
+
189
+ = 1.5.1 - December 22nd, 2016 =
190
+ * Fixed bug that caused content to be copied incorrectly when moving tabs up / down
191
+ * Only on the product page will the editor default to 'Visual' (instead of every page)
192
+
193
+ = 1.5 - December 20th, 2016 =
194
+ * Version 1.5 includes a brand new feature - saved tabs - as well as a number of bug fixes, style tweaks, code clean-up, and comments
195
+ * UI: Complete overhaul of the custom tab interface for an easier, responsive tab creating experience.
196
+ * Saved Tabs: A new settings page has been added for users to create / update / delete saved tabs (see FAQ for more information)
197
+ * Saved Tabs: On the product edit page, a new button ('Add a Saved Tab') has been added that allows you to choose one of your saved tabs and add it to the current product
198
+ * Adding a new tab initializes a new wp_editor (WYSIWYG) instead of a plain textarea
199
+ * Added warning message when two tabs have the same title
200
+ * Tabs with empty titles are no longer shown on the product page
201
+ * Added ability to remove the first tab
202
+ * Adding, moving, and removing tabs works as expected when the user's 'Visual Editor' option is checked
203
+ * On the product & settings pages, WYSIWYG editors will default to the visual tab (this helps prevent errors with dynamic wp_editor generation)
204
+ * Added a filter `yikes_woocommerce_default_editor_mode` that can change the default-to-visual-tab behavior (use at your own risk!)
205
+ * Updated the 'How To' text, and slight modification to the style
206
+ * Changed the JavaScript methods controlling how tabs were added, deleted, and moved up/down
207
+ * Cleaned up and commented on all PHP and JavaScript files
208
+ * Added proper i18n, with languages/ folder, .pot file, and `load_plugin_textdomain` hook
209
+ * Incremented version #
210
+
211
+ = 1.4.4 - March 1st, 2016 =
212
+ * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
213
+
214
+ = 1.4.3 - February 18th, 2016 =
215
+ * Wrapped missing 'Custom Tab Title' in localization/translation functions. (Plugin is now 100% translatable)
216
+ * Removed i18n class files, and old .po/.mo files (less bloat)
217
+
218
+ = 1.4.2 - February 17th, 2016 =
219
+ * Updated the internationalization strings ( `yikes-inc-woocommerce-custom-product-tabs` to `yikes-inc-easy-custom-woocommerce-product-tabs` )
220
+
221
+ = 1.4.1 - August 20th, 2015 =
222
+ * Fixed conflict with other CSV export plugins for WooCommerce
223
+ * Now custom product tab and row data/headers only get exported via 'Tools > Export > Products'
224
+
225
+ = 1.4 - July 29th, 2015 =
226
+ * Enhancement: Added the 'Custom Product Tabs for WooCommerce ' data to the standard WooCommerce export file, so custom tab data can be transferred between sites smoothly.
227
+
228
+ = 1.3 - July 21st, 2015 =
229
+ * Enhancement: Enabled WYSIWYG editor on tab content containers (enables shortcode and content to pass through the_content() filter)
230
+ * Updated repo screenshots and descriptions
231
+
232
+ = 1.2 - March 18th, 2015 =
233
+ * Enhancement: Fixed issue where non utf8 characters in tab titles caused front end not to generate the tabs
234
+ * Enhancement: When user doesn't have WooCommerce installed, they are now redirected to the plugin install search page, with WooCommerce at the top.
235
+
236
+ = 1.1 =
237
+ * Added class to the Woo tabs content title, for targeting via CSS ( `.yikes-custom-woo-tab-title` )
238
+
239
+ = 1.0.0 =
240
+ * Initial Release
241
+
242
+ == Upgrade Notice ==
243
+ = 1.4.4 - March 1st, 2016 =
244
  * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
slider/css/lightslider.css CHANGED
@@ -1,395 +1,395 @@
1
- /*! lightslider - v1.1.6 - 2016-10-25
2
- * https://github.com/sachinchoolur/lightslider
3
- * Copyright (c) 2016 Sachin N; Licensed MIT */
4
- /*! lightslider - v1.1.3 - 2015-04-14
5
- * https://github.com/sachinchoolur/lightslider
6
- * Copyright (c) 2015 Sachin N; Licensed MIT */
7
- /** /!!! core css Should not edit !!!/**/
8
-
9
- .lSSlideOuter {
10
- overflow: hidden;
11
- -webkit-touch-callout: none;
12
- -webkit-user-select: none;
13
- -khtml-user-select: none;
14
- -moz-user-select: none;
15
- -ms-user-select: none;
16
- user-select: none
17
- }
18
- .lightSlider:before, .lightSlider:after {
19
- content: " ";
20
- display: table;
21
- }
22
- .lightSlider {
23
- overflow: hidden;
24
- margin: 0;
25
- }
26
- .lSSlideWrapper {
27
- max-width: 100%;
28
- overflow: hidden;
29
- position: relative;
30
- }
31
- .lSSlideWrapper > .lightSlider:after {
32
- clear: both;
33
- }
34
- .lSSlideWrapper .lSSlide {
35
- -webkit-transform: translate(0px, 0px);
36
- -ms-transform: translate(0px, 0px);
37
- transform: translate(0px, 0px);
38
- -webkit-transition: all 1s;
39
- -webkit-transition-property: -webkit-transform,height;
40
- -moz-transition-property: -moz-transform,height;
41
- transition-property: transform,height;
42
- -webkit-transition-duration: inherit !important;
43
- transition-duration: inherit !important;
44
- -webkit-transition-timing-function: inherit !important;
45
- transition-timing-function: inherit !important;
46
- }
47
- .lSSlideWrapper .lSFade {
48
- position: relative;
49
- }
50
- .lSSlideWrapper .lSFade > * {
51
- position: absolute !important;
52
- top: 0;
53
- left: 0;
54
- z-index: 9;
55
- margin-right: 0;
56
- width: 100%;
57
- }
58
- .lSSlideWrapper.usingCss .lSFade > * {
59
- opacity: 0;
60
- -webkit-transition-delay: 0s;
61
- transition-delay: 0s;
62
- -webkit-transition-duration: inherit !important;
63
- transition-duration: inherit !important;
64
- -webkit-transition-property: opacity;
65
- transition-property: opacity;
66
- -webkit-transition-timing-function: inherit !important;
67
- transition-timing-function: inherit !important;
68
- }
69
- .lSSlideWrapper .lSFade > *.active {
70
- z-index: 10;
71
- }
72
- .lSSlideWrapper.usingCss .lSFade > *.active {
73
- opacity: 1;
74
- }
75
- /** /!!! End of core css Should not edit !!!/**/
76
-
77
- /* Pager */
78
- .lSSlideOuter .lSPager.lSpg {
79
- margin: 10px 0 0;
80
- padding: 0;
81
- text-align: center;
82
- }
83
- .lSSlideOuter .lSPager.lSpg > li {
84
- cursor: pointer;
85
- display: inline-block;
86
- padding: 0 5px;
87
- }
88
- .lSSlideOuter .lSPager.lSpg > li a {
89
- background-color: #222222;
90
- border-radius: 30px;
91
- display: inline-block;
92
- height: 8px;
93
- overflow: hidden;
94
- text-indent: -999em;
95
- width: 8px;
96
- position: relative;
97
- z-index: 99;
98
- -webkit-transition: all 0.5s linear 0s;
99
- transition: all 0.5s linear 0s;
100
- }
101
- .lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a {
102
- background-color: #428bca;
103
- }
104
- .lSSlideOuter .media {
105
- opacity: 0.8;
106
- }
107
- .lSSlideOuter .media.active {
108
- opacity: 1;
109
- }
110
- /* End of pager */
111
-
112
- /** Gallery */
113
- .lSSlideOuter .lSPager.lSGallery {
114
- list-style: none outside none;
115
- padding-left: 0;
116
- margin: 0;
117
- overflow: hidden;
118
- transform: translate3d(0px, 0px, 0px);
119
- -moz-transform: translate3d(0px, 0px, 0px);
120
- -ms-transform: translate3d(0px, 0px, 0px);
121
- -webkit-transform: translate3d(0px, 0px, 0px);
122
- -o-transform: translate3d(0px, 0px, 0px);
123
- -webkit-transition-property: -webkit-transform;
124
- -moz-transition-property: -moz-transform;
125
- -webkit-touch-callout: none;
126
- -webkit-user-select: none;
127
- -khtml-user-select: none;
128
- -moz-user-select: none;
129
- -ms-user-select: none;
130
- user-select: none;
131
- }
132
- .lSSlideOuter .lSPager.lSGallery li {
133
- overflow: hidden;
134
- -webkit-transition: border-radius 0.12s linear 0s 0.35s linear 0s;
135
- transition: border-radius 0.12s linear 0s 0.35s linear 0s;
136
- }
137
- .lSSlideOuter .lSPager.lSGallery li.active, .lSSlideOuter .lSPager.lSGallery li:hover {
138
- border-radius: 5px;
139
- }
140
- .lSSlideOuter .lSPager.lSGallery img {
141
- display: block;
142
- height: auto;
143
- max-width: 100%;
144
- }
145
- .lSSlideOuter .lSPager.lSGallery:before, .lSSlideOuter .lSPager.lSGallery:after {
146
- content: " ";
147
- display: table;
148
- }
149
- .lSSlideOuter .lSPager.lSGallery:after {
150
- clear: both;
151
- }
152
- /* End of Gallery*/
153
-
154
- /* slider actions */
155
- .lSAction > a {
156
- width: 32px;
157
- display: block;
158
- top: 50%;
159
- height: 32px;
160
- background-image: url('../img/controls.png');
161
- cursor: pointer;
162
- position: absolute;
163
- z-index: 99;
164
- margin-top: -16px;
165
- opacity: 0.5;
166
- -webkit-transition: opacity 0.35s linear 0s;
167
- transition: opacity 0.35s linear 0s;
168
- }
169
- .lSAction > a:hover {
170
- opacity: 1;
171
- }
172
- .lSAction > .lSPrev {
173
- background-position: 0 0;
174
- left: 10px;
175
- }
176
- .lSAction > .lSNext {
177
- background-position: -32px 0;
178
- right: 10px;
179
- }
180
- .lSAction > a.disabled {
181
- pointer-events: none;
182
- }
183
- .cS-hidden {
184
- height: 1px;
185
- opacity: 0;
186
- filter: alpha(opacity=0);
187
- overflow: hidden;
188
- }
189
-
190
-
191
- /* vertical */
192
- .lSSlideOuter.vertical {
193
- position: relative;
194
- }
195
- .lSSlideOuter.vertical.noPager {
196
- padding-right: 0px !important;
197
- }
198
- .lSSlideOuter.vertical .lSGallery {
199
- position: absolute !important;
200
- right: 0;
201
- top: 0;
202
- }
203
- .lSSlideOuter.vertical .lightSlider > * {
204
- width: 100% !important;
205
- max-width: none !important;
206
- }
207
-
208
- /* vertical controlls */
209
- .lSSlideOuter.vertical .lSAction > a {
210
- left: 50%;
211
- margin-left: -14px;
212
- margin-top: 0;
213
- }
214
- .lSSlideOuter.vertical .lSAction > .lSNext {
215
- background-position: 31px -31px;
216
- bottom: 10px;
217
- top: auto;
218
- }
219
- .lSSlideOuter.vertical .lSAction > .lSPrev {
220
- background-position: 0 -31px;
221
- bottom: auto;
222
- top: 10px;
223
- }
224
- /* vertical */
225
-
226
-
227
- /* Rtl */
228
- .lSSlideOuter.lSrtl {
229
- direction: rtl;
230
- }
231
- .lSSlideOuter .lightSlider, .lSSlideOuter .lSPager {
232
- padding-left: 0;
233
- list-style: none outside none;
234
- }
235
- .lSSlideOuter.lSrtl .lightSlider, .lSSlideOuter.lSrtl .lSPager {
236
- padding-right: 0;
237
- }
238
- .lSSlideOuter .lightSlider > *, .lSSlideOuter .lSGallery li {
239
- float: left;
240
- }
241
- .lSSlideOuter.lSrtl .lightSlider > *, .lSSlideOuter.lSrtl .lSGallery li {
242
- float: right !important;
243
- }
244
- /* Rtl */
245
-
246
- @-webkit-keyframes rightEnd {
247
- 0% {
248
- left: 0;
249
- }
250
-
251
- 50% {
252
- left: -15px;
253
- }
254
-
255
- 100% {
256
- left: 0;
257
- }
258
- }
259
- @keyframes rightEnd {
260
- 0% {
261
- left: 0;
262
- }
263
-
264
- 50% {
265
- left: -15px;
266
- }
267
-
268
- 100% {
269
- left: 0;
270
- }
271
- }
272
- @-webkit-keyframes topEnd {
273
- 0% {
274
- top: 0;
275
- }
276
-
277
- 50% {
278
- top: -15px;
279
- }
280
-
281
- 100% {
282
- top: 0;
283
- }
284
- }
285
- @keyframes topEnd {
286
- 0% {
287
- top: 0;
288
- }
289
-
290
- 50% {
291
- top: -15px;
292
- }
293
-
294
- 100% {
295
- top: 0;
296
- }
297
- }
298
- @-webkit-keyframes leftEnd {
299
- 0% {
300
- left: 0;
301
- }
302
-
303
- 50% {
304
- left: 15px;
305
- }
306
-
307
- 100% {
308
- left: 0;
309
- }
310
- }
311
- @keyframes leftEnd {
312
- 0% {
313
- left: 0;
314
- }
315
-
316
- 50% {
317
- left: 15px;
318
- }
319
-
320
- 100% {
321
- left: 0;
322
- }
323
- }
324
- @-webkit-keyframes bottomEnd {
325
- 0% {
326
- bottom: 0;
327
- }
328
-
329
- 50% {
330
- bottom: -15px;
331
- }
332
-
333
- 100% {
334
- bottom: 0;
335
- }
336
- }
337
- @keyframes bottomEnd {
338
- 0% {
339
- bottom: 0;
340
- }
341
-
342
- 50% {
343
- bottom: -15px;
344
- }
345
-
346
- 100% {
347
- bottom: 0;
348
- }
349
- }
350
- .lSSlideOuter .rightEnd {
351
- -webkit-animation: rightEnd 0.3s;
352
- animation: rightEnd 0.3s;
353
- position: relative;
354
- }
355
- .lSSlideOuter .leftEnd {
356
- -webkit-animation: leftEnd 0.3s;
357
- animation: leftEnd 0.3s;
358
- position: relative;
359
- }
360
- .lSSlideOuter.vertical .rightEnd {
361
- -webkit-animation: topEnd 0.3s;
362
- animation: topEnd 0.3s;
363
- position: relative;
364
- }
365
- .lSSlideOuter.vertical .leftEnd {
366
- -webkit-animation: bottomEnd 0.3s;
367
- animation: bottomEnd 0.3s;
368
- position: relative;
369
- }
370
- .lSSlideOuter.lSrtl .rightEnd {
371
- -webkit-animation: leftEnd 0.3s;
372
- animation: leftEnd 0.3s;
373
- position: relative;
374
- }
375
- .lSSlideOuter.lSrtl .leftEnd {
376
- -webkit-animation: rightEnd 0.3s;
377
- animation: rightEnd 0.3s;
378
- position: relative;
379
- }
380
- /*/ GRab cursor */
381
- .lightSlider.lsGrab > * {
382
- cursor: -webkit-grab;
383
- cursor: -moz-grab;
384
- cursor: -o-grab;
385
- cursor: -ms-grab;
386
- cursor: grab;
387
- }
388
- .lightSlider.lsGrabbing > * {
389
- cursor: move;
390
- cursor: -webkit-grabbing;
391
- cursor: -moz-grabbing;
392
- cursor: -o-grabbing;
393
- cursor: -ms-grabbing;
394
- cursor: grabbing;
395
  }
1
+ /*! lightslider - v1.1.6 - 2016-10-25
2
+ * https://github.com/sachinchoolur/lightslider
3
+ * Copyright (c) 2016 Sachin N; Licensed MIT */
4
+ /*! lightslider - v1.1.3 - 2015-04-14
5
+ * https://github.com/sachinchoolur/lightslider
6
+ * Copyright (c) 2015 Sachin N; Licensed MIT */
7
+ /** /!!! core css Should not edit !!!/**/
8
+
9
+ .lSSlideOuter {
10
+ overflow: hidden;
11
+ -webkit-touch-callout: none;
12
+ -webkit-user-select: none;
13
+ -khtml-user-select: none;
14
+ -moz-user-select: none;
15
+ -ms-user-select: none;
16
+ user-select: none
17
+ }
18
+ .lightSlider:before, .lightSlider:after {
19
+ content: " ";
20
+ display: table;
21
+ }
22
+ .lightSlider {
23
+ overflow: hidden;
24
+ margin: 0;
25
+ }
26
+ .lSSlideWrapper {
27
+ max-width: 100%;
28
+ overflow: hidden;
29
+ position: relative;
30
+ }
31
+ .lSSlideWrapper > .lightSlider:after {
32
+ clear: both;
33
+ }
34
+ .lSSlideWrapper .lSSlide {
35
+ -webkit-transform: translate(0px, 0px);
36
+ -ms-transform: translate(0px, 0px);
37
+ transform: translate(0px, 0px);
38
+ -webkit-transition: all 1s;
39
+ -webkit-transition-property: -webkit-transform,height;
40
+ -moz-transition-property: -moz-transform,height;
41
+ transition-property: transform,height;
42
+ -webkit-transition-duration: inherit !important;
43
+ transition-duration: inherit !important;
44
+ -webkit-transition-timing-function: inherit !important;
45
+ transition-timing-function: inherit !important;
46
+ }
47
+ .lSSlideWrapper .lSFade {
48
+ position: relative;
49
+ }
50
+ .lSSlideWrapper .lSFade > * {
51
+ position: absolute !important;
52
+ top: 0;
53
+ left: 0;
54
+ z-index: 9;
55
+ margin-right: 0;
56
+ width: 100%;
57
+ }
58
+ .lSSlideWrapper.usingCss .lSFade > * {
59
+ opacity: 0;
60
+ -webkit-transition-delay: 0s;
61
+ transition-delay: 0s;
62
+ -webkit-transition-duration: inherit !important;
63
+ transition-duration: inherit !important;
64
+ -webkit-transition-property: opacity;
65
+ transition-property: opacity;
66
+ -webkit-transition-timing-function: inherit !important;
67
+ transition-timing-function: inherit !important;
68
+ }
69
+ .lSSlideWrapper .lSFade > *.active {
70
+ z-index: 10;
71
+ }
72
+ .lSSlideWrapper.usingCss .lSFade > *.active {
73
+ opacity: 1;
74
+ }
75
+ /** /!!! End of core css Should not edit !!!/**/
76
+
77
+ /* Pager */
78
+ .lSSlideOuter .lSPager.lSpg {
79
+ margin: 10px 0 0;
80
+ padding: 0;
81
+ text-align: center;
82
+ }
83
+ .lSSlideOuter .lSPager.lSpg > li {
84
+ cursor: pointer;
85
+ display: inline-block;
86
+ padding: 0 5px;
87
+ }
88
+ .lSSlideOuter .lSPager.lSpg > li a {
89
+ background-color: #222222;
90
+ border-radius: 30px;
91
+ display: inline-block;
92
+ height: 8px;
93
+ overflow: hidden;
94
+ text-indent: -999em;
95
+ width: 8px;
96
+ position: relative;
97
+ z-index: 99;
98
+ -webkit-transition: all 0.5s linear 0s;
99
+ transition: all 0.5s linear 0s;
100
+ }
101
+ .lSSlideOuter .lSPager.lSpg > li:hover a, .lSSlideOuter .lSPager.lSpg > li.active a {
102
+ background-color: #428bca;
103
+ }
104
+ .lSSlideOuter .media {
105
+ opacity: 0.8;
106
+ }
107
+ .lSSlideOuter .media.active {
108
+ opacity: 1;
109
+ }
110
+ /* End of pager */
111
+
112
+ /** Gallery */
113
+ .lSSlideOuter .lSPager.lSGallery {
114
+ list-style: none outside none;
115
+ padding-left: 0;
116
+ margin: 0;
117
+ overflow: hidden;
118
+ transform: translate3d(0px, 0px, 0px);
119
+ -moz-transform: translate3d(0px, 0px, 0px);
120
+ -ms-transform: translate3d(0px, 0px, 0px);
121
+ -webkit-transform: translate3d(0px, 0px, 0px);
122
+ -o-transform: translate3d(0px, 0px, 0px);
123
+ -webkit-transition-property: -webkit-transform;
124
+ -moz-transition-property: -moz-transform;
125
+ -webkit-touch-callout: none;
126
+ -webkit-user-select: none;
127
+ -khtml-user-select: none;
128
+ -moz-user-select: none;
129
+ -ms-user-select: none;
130
+ user-select: none;
131
+ }
132
+ .lSSlideOuter .lSPager.lSGallery li {
133
+ overflow: hidden;
134
+ -webkit-transition: border-radius 0.12s linear 0s 0.35s linear 0s;
135
+ transition: border-radius 0.12s linear 0s 0.35s linear 0s;
136
+ }
137
+ .lSSlideOuter .lSPager.lSGallery li.active, .lSSlideOuter .lSPager.lSGallery li:hover {
138
+ border-radius: 5px;
139
+ }
140
+ .lSSlideOuter .lSPager.lSGallery img {
141
+ display: block;
142
+ height: auto;
143
+ max-width: 100%;
144
+ }
145
+ .lSSlideOuter .lSPager.lSGallery:before, .lSSlideOuter .lSPager.lSGallery:after {
146
+ content: " ";
147
+ display: table;
148
+ }
149
+ .lSSlideOuter .lSPager.lSGallery:after {
150
+ clear: both;
151
+ }
152
+ /* End of Gallery*/
153
+
154
+ /* slider actions */
155
+ .lSAction > a {
156
+ width: 32px;
157
+ display: block;
158
+ top: 50%;
159
+ height: 32px;
160
+ background-image: url('../img/controls.png');
161
+ cursor: pointer;
162
+ position: absolute;
163
+ z-index: 99;
164
+ margin-top: -16px;
165
+ opacity: 0.5;
166
+ -webkit-transition: opacity 0.35s linear 0s;
167
+ transition: opacity 0.35s linear 0s;
168
+ }
169
+ .lSAction > a:hover {
170
+ opacity: 1;
171
+ }
172
+ .lSAction > .lSPrev {
173
+ background-position: 0 0;
174
+ left: 10px;
175
+ }
176
+ .lSAction > .lSNext {
177
+ background-position: -32px 0;
178
+ right: 10px;
179
+ }
180
+ .lSAction > a.disabled {
181
+ pointer-events: none;
182
+ }
183
+ .cS-hidden {
184
+ height: 1px;
185
+ opacity: 0;
186
+ filter: alpha(opacity=0);
187
+ overflow: hidden;
188
+ }
189
+
190
+
191
+ /* vertical */
192
+ .lSSlideOuter.vertical {
193
+ position: relative;
194
+ }
195
+ .lSSlideOuter.vertical.noPager {
196
+ padding-right: 0px !important;
197
+ }
198
+ .lSSlideOuter.vertical .lSGallery {
199
+ position: absolute !important;
200
+ right: 0;
201
+ top: 0;
202
+ }
203
+ .lSSlideOuter.vertical .lightSlider > * {
204
+ width: 100% !important;
205
+ max-width: none !important;
206
+ }
207
+
208
+ /* vertical controlls */
209
+ .lSSlideOuter.vertical .lSAction > a {
210
+ left: 50%;
211
+ margin-left: -14px;
212
+ margin-top: 0;
213
+ }
214
+ .lSSlideOuter.vertical .lSAction > .lSNext {
215
+ background-position: 31px -31px;
216
+ bottom: 10px;
217
+ top: auto;
218
+ }
219
+ .lSSlideOuter.vertical .lSAction > .lSPrev {
220
+ background-position: 0 -31px;
221
+ bottom: auto;
222
+ top: 10px;
223
+ }
224
+ /* vertical */
225
+
226
+
227
+ /* Rtl */
228
+ .lSSlideOuter.lSrtl {
229
+ direction: rtl;
230
+ }
231
+ .lSSlideOuter .lightSlider, .lSSlideOuter .lSPager {
232
+ padding-left: 0;
233
+ list-style: none outside none;
234
+ }
235
+ .lSSlideOuter.lSrtl .lightSlider, .lSSlideOuter.lSrtl .lSPager {
236
+ padding-right: 0;
237
+ }
238
+ .lSSlideOuter .lightSlider > *, .lSSlideOuter .lSGallery li {
239
+ float: left;
240
+ }
241
+ .lSSlideOuter.lSrtl .lightSlider > *, .lSSlideOuter.lSrtl .lSGallery li {
242
+ float: right !important;
243
+ }
244
+ /* Rtl */
245
+
246
+ @-webkit-keyframes rightEnd {
247
+ 0% {
248
+ left: 0;
249
+ }
250
+
251
+ 50% {
252
+ left: -15px;
253
+ }
254
+
255
+ 100% {
256
+ left: 0;
257
+ }
258
+ }
259
+ @keyframes rightEnd {
260
+ 0% {
261
+ left: 0;
262
+ }
263
+
264
+ 50% {
265
+ left: -15px;
266
+ }
267
+
268
+ 100% {
269
+ left: 0;
270
+ }
271
+ }
272
+ @-webkit-keyframes topEnd {
273
+ 0% {
274
+ top: 0;
275
+ }
276
+
277
+ 50% {
278
+ top: -15px;
279
+ }
280
+
281
+ 100% {
282
+ top: 0;
283
+ }
284
+ }
285
+ @keyframes topEnd {
286
+ 0% {
287
+ top: 0;
288
+ }
289
+
290
+ 50% {
291
+ top: -15px;
292
+ }
293
+
294
+ 100% {
295
+ top: 0;
296
+ }
297
+ }
298
+ @-webkit-keyframes leftEnd {
299
+ 0% {
300
+ left: 0;
301
+ }
302
+
303
+ 50% {
304
+ left: 15px;
305
+ }
306
+
307
+ 100% {
308
+ left: 0;
309
+ }
310
+ }
311
+ @keyframes leftEnd {
312
+ 0% {
313
+ left: 0;
314
+ }
315
+
316
+ 50% {
317
+ left: 15px;
318
+ }
319
+
320
+ 100% {
321
+ left: 0;
322
+ }
323
+ }
324
+ @-webkit-keyframes bottomEnd {
325
+ 0% {
326
+ bottom: 0;
327
+ }
328
+
329
+ 50% {
330
+ bottom: -15px;
331
+ }
332
+
333
+ 100% {
334
+ bottom: 0;
335
+ }
336
+ }
337
+ @keyframes bottomEnd {
338
+ 0% {
339
+ bottom: 0;
340
+ }
341
+
342
+ 50% {
343
+ bottom: -15px;
344
+ }
345
+
346
+ 100% {
347
+ bottom: 0;
348
+ }
349
+ }
350
+ .lSSlideOuter .rightEnd {
351
+ -webkit-animation: rightEnd 0.3s;
352
+ animation: rightEnd 0.3s;
353
+ position: relative;
354
+ }
355
+ .lSSlideOuter .leftEnd {
356
+ -webkit-animation: leftEnd 0.3s;
357
+ animation: leftEnd 0.3s;
358
+ position: relative;
359
+ }
360
+ .lSSlideOuter.vertical .rightEnd {
361
+ -webkit-animation: topEnd 0.3s;
362
+ animation: topEnd 0.3s;
363
+ position: relative;
364
+ }
365
+ .lSSlideOuter.vertical .leftEnd {
366
+ -webkit-animation: bottomEnd 0.3s;
367
+ animation: bottomEnd 0.3s;
368
+ position: relative;
369
+ }
370
+ .lSSlideOuter.lSrtl .rightEnd {
371
+ -webkit-animation: leftEnd 0.3s;
372
+ animation: leftEnd 0.3s;
373
+ position: relative;
374
+ }
375
+ .lSSlideOuter.lSrtl .leftEnd {
376
+ -webkit-animation: rightEnd 0.3s;
377
+ animation: rightEnd 0.3s;
378
+ position: relative;
379
+ }
380
+ /*/ GRab cursor */
381
+ .lightSlider.lsGrab > * {
382
+ cursor: -webkit-grab;
383
+ cursor: -moz-grab;
384
+ cursor: -o-grab;
385
+ cursor: -ms-grab;
386
+ cursor: grab;
387
+ }
388
+ .lightSlider.lsGrabbing > * {
389
+ cursor: move;
390
+ cursor: -webkit-grabbing;
391
+ cursor: -moz-grabbing;
392
+ cursor: -o-grabbing;
393
+ cursor: -ms-grabbing;
394
+ cursor: grabbing;
395
  }
slider/css/lightslider.min.css CHANGED
@@ -1,3 +1,3 @@
1
- /*! lightslider - v1.1.3 - 2015-04-14
2
- * https://github.com/sachinchoolur/lightslider
3
  * Copyright (c) 2015 Sachin N; Licensed MIT */.lSSlideWrapper,.lSSlideWrapper .lSFade{position:relative}.lSSlideWrapper .lSSlide,.lSSlideWrapper.usingCss .lSFade>*{-webkit-transition-timing-function:inherit!important;transition-timing-function:inherit!important;-webkit-transition-duration:inherit!important;transition-duration:inherit!important}.lSSlideOuter,.lSSlideOuter .lSPager.lSGallery{-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-touch-callout:none;-webkit-user-select:none}.lSSlideOuter .lSPager.lSGallery:after,.lSSlideWrapper>.lightSlider:after{clear:both}.lSSlideOuter{overflow:hidden;user-select:none}.lightSlider:after,.lightSlider:before{content:" ";display:table}.lightSlider{overflow:hidden;margin:0}.lSSlideWrapper{max-width:100%;overflow:hidden}.lSSlideWrapper .lSSlide{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);-webkit-transition:all 1s;-webkit-transition-property:-webkit-transform,height;-moz-transition-property:-moz-transform,height;transition-property:transform,height}.lSSlideWrapper .lSFade>*{position:absolute!important;top:0;left:0;z-index:9;margin-right:0;width:100%}.lSSlideWrapper.usingCss .lSFade>*{opacity:0;-webkit-transition-delay:0s;transition-delay:0s;-webkit-transition-property:opacity;transition-property:opacity}.lSSlideWrapper .lSFade>.active{z-index:10}.lSSlideWrapper.usingCss .lSFade>.active{opacity:1}.lSSlideOuter .lSPager.lSpg{margin:10px 0 0;padding:0;text-align:center}.lSSlideOuter .lSPager.lSpg>li{cursor:pointer;display:inline-block;padding:0 5px}.lSSlideOuter .lSPager.lSpg>li a{background-color:#222;border-radius:30px;display:inline-block;height:8px;overflow:hidden;text-indent:-999em;width:8px;position:relative;z-index:99;-webkit-transition:all .5s linear 0s;transition:all .5s linear 0s}.lSSlideOuter .lSPager.lSpg>li.active a,.lSSlideOuter .lSPager.lSpg>li:hover a{background-color:#428bca}.lSSlideOuter .media{opacity:.8}.lSSlideOuter .media.active{opacity:1}.lSSlideOuter .lSPager.lSGallery{list-style:none;padding-left:0;margin:0;overflow:hidden;transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-webkit-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);-webkit-transition-property:-webkit-transform;-moz-transition-property:-moz-transform;user-select:none}.lSSlideOuter .lSPager.lSGallery li{overflow:hidden;-webkit-transition:border-radius .12s linear 0s .35s linear 0s;transition:border-radius .12s linear 0s .35s linear 0s}.lSSlideOuter .lSPager.lSGallery li.active,.lSSlideOuter .lSPager.lSGallery li:hover{border-radius:5px}.lSSlideOuter .lSPager.lSGallery img{display:block;height:auto;max-width:100%}.lSSlideOuter .lSPager.lSGallery:after,.lSSlideOuter .lSPager.lSGallery:before{content:" ";display:table}.lSAction>a{width:32px;display:block;top:50%;height:32px;background-image:url(../img/controls.png);cursor:pointer;position:absolute;z-index:99;margin-top:-16px;opacity:.5;-webkit-transition:opacity .35s linear 0s;transition:opacity .35s linear 0s}.lSAction>a:hover{opacity:1}.lSAction>.lSPrev{background-position:0 0;left:10px}.lSAction>.lSNext{background-position:-32px 0;right:10px}.lSAction>a.disabled{pointer-events:none}.cS-hidden{height:1px;opacity:0;filter:alpha(opacity=0);overflow:hidden}.lSSlideOuter.vertical{position:relative}.lSSlideOuter.vertical.noPager{padding-right:0!important}.lSSlideOuter.vertical .lSGallery{position:absolute!important;right:0;top:0}.lSSlideOuter.vertical .lightSlider>*{width:100%!important;max-width:none!important}.lSSlideOuter.vertical .lSAction>a{left:50%;margin-left:-14px;margin-top:0}.lSSlideOuter.vertical .lSAction>.lSNext{background-position:31px -31px;bottom:10px;top:auto}.lSSlideOuter.vertical .lSAction>.lSPrev{background-position:0 -31px;bottom:auto;top:10px}.lSSlideOuter.lSrtl{direction:rtl}.lSSlideOuter .lSPager,.lSSlideOuter .lightSlider{padding-left:0;list-style:none}.lSSlideOuter.lSrtl .lSPager,.lSSlideOuter.lSrtl .lightSlider{padding-right:0}.lSSlideOuter .lSGallery li,.lSSlideOuter .lightSlider>*{float:left}.lSSlideOuter.lSrtl .lSGallery li,.lSSlideOuter.lSrtl .lightSlider>*{float:right!important}@-webkit-keyframes rightEnd{0%,100%{left:0}50%{left:-15px}}@keyframes rightEnd{0%,100%{left:0}50%{left:-15px}}@-webkit-keyframes topEnd{0%,100%{top:0}50%{top:-15px}}@keyframes topEnd{0%,100%{top:0}50%{top:-15px}}@-webkit-keyframes leftEnd{0%,100%{left:0}50%{left:15px}}@keyframes leftEnd{0%,100%{left:0}50%{left:15px}}@-webkit-keyframes bottomEnd{0%,100%{bottom:0}50%{bottom:-15px}}@keyframes bottomEnd{0%,100%{bottom:0}50%{bottom:-15px}}.lSSlideOuter .rightEnd{-webkit-animation:rightEnd .3s;animation:rightEnd .3s;position:relative}.lSSlideOuter .leftEnd{-webkit-animation:leftEnd .3s;animation:leftEnd .3s;position:relative}.lSSlideOuter.vertical .rightEnd{-webkit-animation:topEnd .3s;animation:topEnd .3s;position:relative}.lSSlideOuter.vertical .leftEnd{-webkit-animation:bottomEnd .3s;animation:bottomEnd .3s;position:relative}.lSSlideOuter.lSrtl .rightEnd{-webkit-animation:leftEnd .3s;animation:leftEnd .3s;position:relative}.lSSlideOuter.lSrtl .leftEnd{-webkit-animation:rightEnd .3s;animation:rightEnd .3s;position:relative}.lightSlider.lsGrab>*{cursor:-webkit-grab;cursor:-moz-grab;cursor:-o-grab;cursor:-ms-grab;cursor:grab}.lightSlider.lsGrabbing>*{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:-o-grabbing;cursor:-ms-grabbing;cursor:grabbing}
1
+ /*! lightslider - v1.1.3 - 2015-04-14
2
+ * https://github.com/sachinchoolur/lightslider
3
  * Copyright (c) 2015 Sachin N; Licensed MIT */.lSSlideWrapper,.lSSlideWrapper .lSFade{position:relative}.lSSlideWrapper .lSSlide,.lSSlideWrapper.usingCss .lSFade>*{-webkit-transition-timing-function:inherit!important;transition-timing-function:inherit!important;-webkit-transition-duration:inherit!important;transition-duration:inherit!important}.lSSlideOuter,.lSSlideOuter .lSPager.lSGallery{-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;-webkit-touch-callout:none;-webkit-user-select:none}.lSSlideOuter .lSPager.lSGallery:after,.lSSlideWrapper>.lightSlider:after{clear:both}.lSSlideOuter{overflow:hidden;user-select:none}.lightSlider:after,.lightSlider:before{content:" ";display:table}.lightSlider{overflow:hidden;margin:0}.lSSlideWrapper{max-width:100%;overflow:hidden}.lSSlideWrapper .lSSlide{-webkit-transform:translate(0,0);-ms-transform:translate(0,0);transform:translate(0,0);-webkit-transition:all 1s;-webkit-transition-property:-webkit-transform,height;-moz-transition-property:-moz-transform,height;transition-property:transform,height}.lSSlideWrapper .lSFade>*{position:absolute!important;top:0;left:0;z-index:9;margin-right:0;width:100%}.lSSlideWrapper.usingCss .lSFade>*{opacity:0;-webkit-transition-delay:0s;transition-delay:0s;-webkit-transition-property:opacity;transition-property:opacity}.lSSlideWrapper .lSFade>.active{z-index:10}.lSSlideWrapper.usingCss .lSFade>.active{opacity:1}.lSSlideOuter .lSPager.lSpg{margin:10px 0 0;padding:0;text-align:center}.lSSlideOuter .lSPager.lSpg>li{cursor:pointer;display:inline-block;padding:0 5px}.lSSlideOuter .lSPager.lSpg>li a{background-color:#222;border-radius:30px;display:inline-block;height:8px;overflow:hidden;text-indent:-999em;width:8px;position:relative;z-index:99;-webkit-transition:all .5s linear 0s;transition:all .5s linear 0s}.lSSlideOuter .lSPager.lSpg>li.active a,.lSSlideOuter .lSPager.lSpg>li:hover a{background-color:#428bca}.lSSlideOuter .media{opacity:.8}.lSSlideOuter .media.active{opacity:1}.lSSlideOuter .lSPager.lSGallery{list-style:none;padding-left:0;margin:0;overflow:hidden;transform:translate3d(0,0,0);-moz-transform:translate3d(0,0,0);-ms-transform:translate3d(0,0,0);-webkit-transform:translate3d(0,0,0);-o-transform:translate3d(0,0,0);-webkit-transition-property:-webkit-transform;-moz-transition-property:-moz-transform;user-select:none}.lSSlideOuter .lSPager.lSGallery li{overflow:hidden;-webkit-transition:border-radius .12s linear 0s .35s linear 0s;transition:border-radius .12s linear 0s .35s linear 0s}.lSSlideOuter .lSPager.lSGallery li.active,.lSSlideOuter .lSPager.lSGallery li:hover{border-radius:5px}.lSSlideOuter .lSPager.lSGallery img{display:block;height:auto;max-width:100%}.lSSlideOuter .lSPager.lSGallery:after,.lSSlideOuter .lSPager.lSGallery:before{content:" ";display:table}.lSAction>a{width:32px;display:block;top:50%;height:32px;background-image:url(../img/controls.png);cursor:pointer;position:absolute;z-index:99;margin-top:-16px;opacity:.5;-webkit-transition:opacity .35s linear 0s;transition:opacity .35s linear 0s}.lSAction>a:hover{opacity:1}.lSAction>.lSPrev{background-position:0 0;left:10px}.lSAction>.lSNext{background-position:-32px 0;right:10px}.lSAction>a.disabled{pointer-events:none}.cS-hidden{height:1px;opacity:0;filter:alpha(opacity=0);overflow:hidden}.lSSlideOuter.vertical{position:relative}.lSSlideOuter.vertical.noPager{padding-right:0!important}.lSSlideOuter.vertical .lSGallery{position:absolute!important;right:0;top:0}.lSSlideOuter.vertical .lightSlider>*{width:100%!important;max-width:none!important}.lSSlideOuter.vertical .lSAction>a{left:50%;margin-left:-14px;margin-top:0}.lSSlideOuter.vertical .lSAction>.lSNext{background-position:31px -31px;bottom:10px;top:auto}.lSSlideOuter.vertical .lSAction>.lSPrev{background-position:0 -31px;bottom:auto;top:10px}.lSSlideOuter.lSrtl{direction:rtl}.lSSlideOuter .lSPager,.lSSlideOuter .lightSlider{padding-left:0;list-style:none}.lSSlideOuter.lSrtl .lSPager,.lSSlideOuter.lSrtl .lightSlider{padding-right:0}.lSSlideOuter .lSGallery li,.lSSlideOuter .lightSlider>*{float:left}.lSSlideOuter.lSrtl .lSGallery li,.lSSlideOuter.lSrtl .lightSlider>*{float:right!important}@-webkit-keyframes rightEnd{0%,100%{left:0}50%{left:-15px}}@keyframes rightEnd{0%,100%{left:0}50%{left:-15px}}@-webkit-keyframes topEnd{0%,100%{top:0}50%{top:-15px}}@keyframes topEnd{0%,100%{top:0}50%{top:-15px}}@-webkit-keyframes leftEnd{0%,100%{left:0}50%{left:15px}}@keyframes leftEnd{0%,100%{left:0}50%{left:15px}}@-webkit-keyframes bottomEnd{0%,100%{bottom:0}50%{bottom:-15px}}@keyframes bottomEnd{0%,100%{bottom:0}50%{bottom:-15px}}.lSSlideOuter .rightEnd{-webkit-animation:rightEnd .3s;animation:rightEnd .3s;position:relative}.lSSlideOuter .leftEnd{-webkit-animation:leftEnd .3s;animation:leftEnd .3s;position:relative}.lSSlideOuter.vertical .rightEnd{-webkit-animation:topEnd .3s;animation:topEnd .3s;position:relative}.lSSlideOuter.vertical .leftEnd{-webkit-animation:bottomEnd .3s;animation:bottomEnd .3s;position:relative}.lSSlideOuter.lSrtl .rightEnd{-webkit-animation:leftEnd .3s;animation:leftEnd .3s;position:relative}.lSSlideOuter.lSrtl .leftEnd{-webkit-animation:rightEnd .3s;animation:rightEnd .3s;position:relative}.lightSlider.lsGrab>*{cursor:-webkit-grab;cursor:-moz-grab;cursor:-o-grab;cursor:-ms-grab;cursor:grab}.lightSlider.lsGrabbing>*{cursor:move;cursor:-webkit-grabbing;cursor:-moz-grabbing;cursor:-o-grabbing;cursor:-ms-grabbing;cursor:grabbing}
slider/js/lightslider.js CHANGED
@@ -1,1143 +1,1143 @@
1
- /*! lightslider - v1.1.6 - 2016-10-25
2
- * https://github.com/sachinchoolur/lightslider
3
- * Copyright (c) 2016 Sachin N; Licensed MIT */
4
- (function ($, undefined) {
5
- 'use strict';
6
- var defaults = {
7
- item: 3,
8
- autoWidth: false,
9
- slideMove: 1,
10
- slideMargin: 10,
11
- addClass: '',
12
- mode: 'slide',
13
- useCSS: true,
14
- cssEasing: 'ease', //'cubic-bezier(0.25, 0, 0.25, 1)',
15
- easing: 'linear', //'for jquery animation',//
16
- speed: 400, //ms'
17
- auto: false,
18
- pauseOnHover: false,
19
- loop: false,
20
- slideEndAnimation: true,
21
- pause: 2000,
22
- keyPress: false,
23
- controls: true,
24
- prevHtml: '',
25
- nextHtml: '',
26
- rtl: false,
27
- adaptiveHeight: false,
28
- vertical: false,
29
- verticalHeight: 500,
30
- vThumbWidth: 100,
31
- thumbItem: 10,
32
- pager: true,
33
- gallery: false,
34
- galleryMargin: 5,
35
- thumbMargin: 5,
36
- currentPagerPosition: 'middle',
37
- enableTouch: true,
38
- enableDrag: true,
39
- freeMove: true,
40
- swipeThreshold: 40,
41
- responsive: [],
42
- /* jshint ignore:start */
43
- onBeforeStart: function ($el) {},
44
- onSliderLoad: function ($el) {},
45
- onBeforeSlide: function ($el, scene) {},
46
- onAfterSlide: function ($el, scene) {},
47
- onBeforeNextSlide: function ($el, scene) {},
48
- onBeforePrevSlide: function ($el, scene) {}
49
- /* jshint ignore:end */
50
- };
51
- $.fn.lightSlider = function (options) {
52
- if (this.length === 0) {
53
- return this;
54
- }
55
-
56
- if (this.length > 1) {
57
- this.each(function () {
58
- $(this).lightSlider(options);
59
- });
60
- return this;
61
- }
62
-
63
- var plugin = {},
64
- settings = $.extend(true, {}, defaults, options),
65
- settingsTemp = {},
66
- $el = this;
67
- plugin.$el = this;
68
-
69
- if (settings.mode === 'fade') {
70
- settings.vertical = false;
71
- }
72
- var $children = $el.children(),
73
- windowW = $(window).width(),
74
- breakpoint = null,
75
- resposiveObj = null,
76
- length = 0,
77
- w = 0,
78
- on = false,
79
- elSize = 0,
80
- $slide = '',
81
- scene = 0,
82
- property = (settings.vertical === true) ? 'height' : 'width',
83
- gutter = (settings.vertical === true) ? 'margin-bottom' : 'margin-right',
84
- slideValue = 0,
85
- pagerWidth = 0,
86
- slideWidth = 0,
87
- thumbWidth = 0,
88
- interval = null,
89
- isTouch = ('ontouchstart' in document.documentElement);
90
- var refresh = {};
91
-
92
- refresh.chbreakpoint = function () {
93
- windowW = $(window).width();
94
- if (settings.responsive.length) {
95
- var item;
96
- if (settings.autoWidth === false) {
97
- item = settings.item;
98
- }
99
- if (windowW < settings.responsive[0].breakpoint) {
100
- for (var i = 0; i < settings.responsive.length; i++) {
101
- if (windowW < settings.responsive[i].breakpoint) {
102
- breakpoint = settings.responsive[i].breakpoint;
103
- resposiveObj = settings.responsive[i];
104
- }
105
- }
106
- }
107
- if (typeof resposiveObj !== 'undefined' && resposiveObj !== null) {
108
- for (var j in resposiveObj.settings) {
109
- if (resposiveObj.settings.hasOwnProperty(j)) {
110
- if (typeof settingsTemp[j] === 'undefined' || settingsTemp[j] === null) {
111
- settingsTemp[j] = settings[j];
112
- }
113
- settings[j] = resposiveObj.settings[j];
114
- }
115
- }
116
- }
117
- if (!$.isEmptyObject(settingsTemp) && windowW > settings.responsive[0].breakpoint) {
118
- for (var k in settingsTemp) {
119
- if (settingsTemp.hasOwnProperty(k)) {
120
- settings[k] = settingsTemp[k];
121
- }
122
- }
123
- }
124
- if (settings.autoWidth === false) {
125
- if (slideValue > 0 && slideWidth > 0) {
126
- if (item !== settings.item) {
127
- scene = Math.round(slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove));
128
- }
129
- }
130
- }
131
- }
132
- };
133
-
134
- refresh.calSW = function () {
135
- if (settings.autoWidth === false) {
136
- slideWidth = (elSize - ((settings.item * (settings.slideMargin)) - settings.slideMargin)) / settings.item;
137
- }
138
- };
139
-
140
- refresh.calWidth = function (cln) {
141
- var ln = cln === true ? $slide.find('.lslide').length : $children.length;
142
- if (settings.autoWidth === false) {
143
- w = ln * (slideWidth + settings.slideMargin);
144
- } else {
145
- w = 0;
146
- for (var i = 0; i < ln; i++) {
147
- w += (parseInt($children.eq(i).width()) + settings.slideMargin);
148
- }
149
- }
150
- return w;
151
- };
152
- plugin = {
153
- doCss: function () {
154
- var support = function () {
155
- var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
156
- var root = document.documentElement;
157
- for (var i = 0; i < transition.length; i++) {
158
- if (transition[i] in root.style) {
159
- return true;
160
- }
161
- }
162
- };
163
- if (settings.useCSS && support()) {
164
- return true;
165
- }
166
- return false;
167
- },
168
- keyPress: function () {
169
- if (settings.keyPress) {
170
- $(document).on('keyup.lightslider', function (e) {
171
- if (!$(':focus').is('input, textarea')) {
172
- if (e.preventDefault) {
173
- e.preventDefault();
174
- } else {
175
- e.returnValue = false;
176
- }
177
- if (e.keyCode === 37) {
178
- $el.goToPrevSlide();
179
- } else if (e.keyCode === 39) {
180
- $el.goToNextSlide();
181
- }
182
- }
183
- });
184
- }
185
- },
186
- controls: function () {
187
- if (settings.controls) {
188
- $el.after('<div class="lSAction"><a class="lSPrev">' + settings.prevHtml + '</a><a class="lSNext">' + settings.nextHtml + '</a></div>');
189
- if (!settings.autoWidth) {
190
- if (length <= settings.item) {
191
- $slide.find('.lSAction').hide();
192
- }
193
- } else {
194
- if (refresh.calWidth(false) < elSize) {
195
- $slide.find('.lSAction').hide();
196
- }
197
- }
198
- $slide.find('.lSAction a').on('click', function (e) {
199
- if (e.preventDefault) {
200
- e.preventDefault();
201
- } else {
202
- e.returnValue = false;
203
- }
204
- if ($(this).attr('class') === 'lSPrev') {
205
- $el.goToPrevSlide();
206
- } else {
207
- $el.goToNextSlide();
208
- }
209
- return false;
210
- });
211
- }
212
- },
213
- initialStyle: function () {
214
- var $this = this;
215
- if (settings.mode === 'fade') {
216
- settings.autoWidth = false;
217
- settings.slideEndAnimation = false;
218
- }
219
- if (settings.auto) {
220
- settings.slideEndAnimation = false;
221
- }
222
- if (settings.autoWidth) {
223
- settings.slideMove = 1;
224
- settings.item = 1;
225
- }
226
- if (settings.loop) {
227
- settings.slideMove = 1;
228
- settings.freeMove = false;
229
- }
230
- settings.onBeforeStart.call(this, $el);
231
- refresh.chbreakpoint();
232
- $el.addClass('lightSlider').wrap('<div class="lSSlideOuter ' + settings.addClass + '"><div class="lSSlideWrapper"></div></div>');
233
- $slide = $el.parent('.lSSlideWrapper');
234
- if (settings.rtl === true) {
235
- $slide.parent().addClass('lSrtl');
236
- }
237
- if (settings.vertical) {
238
- $slide.parent().addClass('vertical');
239
- elSize = settings.verticalHeight;
240
- $slide.css('height', elSize + 'px');
241
- } else {
242
- elSize = $el.outerWidth();
243
- }
244
- $children.addClass('lslide');
245
- if (settings.loop === true && settings.mode === 'slide') {
246
- refresh.calSW();
247
- refresh.clone = function () {
248
- if (refresh.calWidth(true) > elSize) {
249
- /**/
250
- var tWr = 0,
251
- tI = 0;
252
- for (var k = 0; k < $children.length; k++) {
253
- tWr += (parseInt($el.find('.lslide').eq(k).width()) + settings.slideMargin);
254
- tI++;
255
- if (tWr >= (elSize + settings.slideMargin)) {
256
- break;
257
- }
258
- }
259
- var tItem = settings.autoWidth === true ? tI : settings.item;
260
-
261
- /**/
262
- if (tItem < $el.find('.clone.left').length) {
263
- for (var i = 0; i < $el.find('.clone.left').length - tItem; i++) {
264
- $children.eq(i).remove();
265
- }
266
- }
267
- if (tItem < $el.find('.clone.right').length) {
268
- for (var j = $children.length - 1; j > ($children.length - 1 - $el.find('.clone.right').length); j--) {
269
- scene--;
270
- $children.eq(j).remove();
271
- }
272
- }
273
- /**/
274
- for (var n = $el.find('.clone.right').length; n < tItem; n++) {
275
- $el.find('.lslide').eq(n).clone().removeClass('lslide').addClass('clone right').appendTo($el);
276
- scene++;
277
- }
278
- for (var m = $el.find('.lslide').length - $el.find('.clone.left').length; m > ($el.find('.lslide').length - tItem); m--) {
279
- $el.find('.lslide').eq(m - 1).clone().removeClass('lslide').addClass('clone left').prependTo($el);
280
- }
281
- $children = $el.children();
282
- } else {
283
- if ($children.hasClass('clone')) {
284
- $el.find('.clone').remove();
285
- $this.move($el, 0);
286
- }
287
- }
288
- };
289
- refresh.clone();
290
- }
291
- refresh.sSW = function () {
292
- length = $children.length;
293
- if (settings.rtl === true && settings.vertical === false) {
294
- gutter = 'margin-left';
295
- }
296
- if (settings.autoWidth === false) {
297
- $children.css(property, slideWidth + 'px');
298
- }
299
- $children.css(gutter, settings.slideMargin + 'px');
300
- w = refresh.calWidth(false);
301
- $el.css(property, w + 'px');
302
- if (settings.loop === true && settings.mode === 'slide') {
303
- if (on === false) {
304
- scene = $el.find('.clone.left').length;
305
- }
306
- }
307
- };
308
- refresh.calL = function () {
309
- $children = $el.children();
310
- length = $children.length;
311
- };
312
- if (this.doCss()) {
313
- $slide.addClass('usingCss');
314
- }
315
- refresh.calL();
316
- if (settings.mode === 'slide') {
317
- refresh.calSW();
318
- refresh.sSW();
319
- if (settings.loop === true) {
320
- slideValue = $this.slideValue();
321
- this.move($el, slideValue);
322
- }
323
- if (settings.vertical === false) {
324
- this.setHeight($el, false);
325
- }
326
-
327
- } else {
328
- this.setHeight($el, true);
329
- $el.addClass('lSFade');
330
- if (!this.doCss()) {
331
- $children.fadeOut(0);
332
- $children.eq(scene).fadeIn(0);
333
- }
334
- }
335
- if (settings.loop === true && settings.mode === 'slide') {
336
- $children.eq(scene).addClass('active');
337
- } else {
338
- $children.first().addClass('active');
339
- }
340
- },
341
- pager: function () {
342
- var $this = this;
343
- refresh.createPager = function () {
344
- thumbWidth = (elSize - ((settings.thumbItem * (settings.thumbMargin)) - settings.thumbMargin)) / settings.thumbItem;
345
- var $children = $slide.find('.lslide');
346
- var length = $slide.find('.lslide').length;
347
- var i = 0,
348
- pagers = '',
349
- v = 0;
350
- for (i = 0; i < length; i++) {
351
- if (settings.mode === 'slide') {
352
- // calculate scene * slide value
353
- if (!settings.autoWidth) {
354
- v = i * ((slideWidth + settings.slideMargin) * settings.slideMove);
355
- } else {
356
- v += ((parseInt($children.eq(i).width()) + settings.slideMargin) * settings.slideMove);
357
- }
358
- }
359
- var thumb = $children.eq(i * settings.slideMove).attr('data-thumb');
360
- if (settings.gallery === true) {
361
- pagers += '<li style="width:100%;' + property + ':' + thumbWidth + 'px;' + gutter + ':' + settings.thumbMargin + 'px"><a href="#"><img src="' + thumb + '" /></a></li>';
362
- } else {
363
- pagers += '<li><a href="#">' + (i + 1) + '</a></li>';
364
- }
365
- if (settings.mode === 'slide') {
366
- if ((v) >= w - elSize - settings.slideMargin) {
367
- i = i + 1;
368
- var minPgr = 2;
369
- if (settings.autoWidth) {
370
- pagers += '<li><a href="#">' + (i + 1) + '</a></li>';
371
- minPgr = 1;
372
- }
373
- if (i < minPgr) {
374
- pagers = null;
375
- $slide.parent().addClass('noPager');
376
- } else {
377
- $slide.parent().removeClass('noPager');
378
- }
379
- break;
380
- }
381
- }
382
- }
383
- var $cSouter = $slide.parent();
384
- $cSouter.find('.lSPager').html(pagers);
385
- if (settings.gallery === true) {
386
- if (settings.vertical === true) {
387
- // set Gallery thumbnail width
388
- $cSouter.find('.lSPager').css('width', settings.vThumbWidth + 'px');
389
- }
390
- pagerWidth = (i * (settings.thumbMargin + thumbWidth)) + 0.5;
391
- $cSouter.find('.lSPager').css({
392
- property: pagerWidth + 'px',
393
- 'transition-duration': settings.speed + 'ms'
394
- });
395
- if (settings.vertical === true) {
396
- $slide.parent().css('padding-right', (settings.vThumbWidth + settings.galleryMargin) + 'px');
397
- }
398
- $cSouter.find('.lSPager').css(property, pagerWidth + 'px');
399
- }
400
- var $pager = $cSouter.find('.lSPager').find('li');
401
- $pager.first().addClass('active');
402
- $pager.on('click', function () {
403
- if (settings.loop === true && settings.mode === 'slide') {
404
- scene = scene + ($pager.index(this) - $cSouter.find('.lSPager').find('li.active').index());
405
- } else {
406
- scene = $pager.index(this);
407
- }
408
- $el.mode(false);
409
- if (settings.gallery === true) {
410
- $this.slideThumb();
411
- }
412
- return false;
413
- });
414
- };
415
- if (settings.pager) {
416
- var cl = 'lSpg';
417
- if (settings.gallery) {
418
- cl = 'lSGallery';
419
- }
420
- $slide.after('<ul class="lSPager ' + cl + '"></ul>');
421
- var gMargin = (settings.vertical) ? 'margin-left' : 'margin-top';
422
- $slide.parent().find('.lSPager').css(gMargin, settings.galleryMargin + 'px');
423
- refresh.createPager();
424
- }
425
-
426
- setTimeout(function () {
427
- refresh.init();
428
- }, 0);
429
- },
430
- setHeight: function (ob, fade) {
431
- var obj = null,
432
- $this = this;
433
- if (settings.loop) {
434
- obj = ob.children('.lslide ').first();
435
- } else {
436
- obj = ob.children().first();
437
- }
438
- var setCss = function () {
439
- var tH = obj.outerHeight(),
440
- tP = 0,
441
- tHT = tH;
442
- if (fade) {
443
- tH = 0;
444
- tP = ((tHT) * 100) / elSize;
445
- }
446
- ob.css({
447
- 'height': tH + 'px',
448
- 'padding-bottom': tP + '%'
449
- });
450
- };
451
- setCss();
452
- if (obj.find('img').length) {
453
- if ( obj.find('img')[0].complete) {
454
- setCss();
455
- if (!interval) {
456
- $this.auto();
457
- }
458
- }else{
459
- obj.find('img').on('load', function () {
460
- setTimeout(function () {
461
- setCss();
462
- if (!interval) {
463
- $this.auto();
464
- }
465
- }, 100);
466
- });
467
- }
468
- }else{
469
- if (!interval) {
470
- $this.auto();
471
- }
472
- }
473
- },
474
- active: function (ob, t) {
475
- if (this.doCss() && settings.mode === 'fade') {
476
- $slide.addClass('on');
477
- }
478
- var sc = 0;
479
- if (scene * settings.slideMove < length) {
480
- ob.removeClass('active');
481
- if (!this.doCss() && settings.mode === 'fade' && t === false) {
482
- ob.fadeOut(settings.speed);
483
- }
484
- if (t === true) {
485
- sc = scene;
486
- } else {
487
- sc = scene * settings.slideMove;
488
- }
489
- //t === true ? sc = scene : sc = scene * settings.slideMove;
490
- var l, nl;
491
- if (t === true) {
492
- l = ob.length;
493
- nl = l - 1;
494
- if (sc + 1 >= l) {
495
- sc = nl;
496
- }
497
- }
498
- if (settings.loop === true && settings.mode === 'slide') {
499
- //t === true ? sc = scene - $el.find('.clone.left').length : sc = scene * settings.slideMove;
500
- if (t === true) {
501
- sc = scene - $el.find('.clone.left').length;
502
- } else {
503
- sc = scene * settings.slideMove;
504
- }
505
- if (t === true) {
506
- l = ob.length;
507
- nl = l - 1;
508
- if (sc + 1 === l) {
509
- sc = nl;
510
- } else if (sc + 1 > l) {
511
- sc = 0;
512
- }
513
- }
514
- }
515
-
516
- if (!this.doCss() && settings.mode === 'fade' && t === false) {
517
- ob.eq(sc).fadeIn(settings.speed);
518
- }
519
- ob.eq(sc).addClass('active');
520
- } else {
521
- ob.removeClass('active');
522
- ob.eq(ob.length - 1).addClass('active');
523
- if (!this.doCss() && settings.mode === 'fade' && t === false) {
524
- ob.fadeOut(settings.speed);
525
- ob.eq(sc).fadeIn(settings.speed);
526
- }
527
- }
528
- },
529
- move: function (ob, v) {
530
- if (settings.rtl === true) {
531
- v = -v;
532
- }
533
- if (this.doCss()) {
534
- if (settings.vertical === true) {
535
- ob.css({
536
- 'transform': 'translate3d(0px, ' + (-v) + 'px, 0px)',
537
- '-webkit-transform': 'translate3d(0px, ' + (-v) + 'px, 0px)'
538
- });
539
- } else {
540
- ob.css({
541
- 'transform': 'translate3d(' + (-v) + 'px, 0px, 0px)',
542
- '-webkit-transform': 'translate3d(' + (-v) + 'px, 0px, 0px)',
543
- });
544
- }
545
- } else {
546
- if (settings.vertical === true) {
547
- ob.css('position', 'relative').animate({
548
- top: -v + 'px'
549
- }, settings.speed, settings.easing);
550
- } else {
551
- ob.css('position', 'relative').animate({
552
- left: -v + 'px'
553
- }, settings.speed, settings.easing);
554
- }
555
- }
556
- var $thumb = $slide.parent().find('.lSPager').find('li');
557
- this.active($thumb, true);
558
- },
559
- fade: function () {
560
- this.active($children, false);
561
- var $thumb = $slide.parent().find('.lSPager').find('li');
562
- this.active($thumb, true);
563
- },
564
- slide: function () {
565
- var $this = this;
566
- refresh.calSlide = function () {
567
- if (w > elSize) {
568
- slideValue = $this.slideValue();
569
- $this.active($children, false);
570
- if ((slideValue) > w - elSize - settings.slideMargin) {
571
- slideValue = w - elSize - settings.slideMargin;
572
- } else if (slideValue < 0) {
573
- slideValue = 0;
574
- }
575
- $this.move($el, slideValue);
576
- if (settings.loop === true && settings.mode === 'slide') {
577
- if (scene >= (length - ($el.find('.clone.left').length / settings.slideMove))) {
578
- $this.resetSlide($el.find('.clone.left').length);
579
- }
580
- if (scene === 0) {
581
- $this.resetSlide($slide.find('.lslide').length);
582
- }
583
- }
584
- }
585
- };
586
- refresh.calSlide();
587
- },
588
- resetSlide: function (s) {
589
- var $this = this;
590
- $slide.find('.lSAction a').addClass('disabled');
591
- setTimeout(function () {
592
- scene = s;
593
- $slide.css('transition-duration', '0ms');
594
- slideValue = $this.slideValue();
595
- $this.active($children, false);
596
- plugin.move($el, slideValue);
597
- setTimeout(function () {
598
- $slide.css('transition-duration', settings.speed + 'ms');
599
- $slide.find('.lSAction a').removeClass('disabled');
600
- }, 50);
601
- }, settings.speed + 100);
602
- },
603
- slideValue: function () {
604
- var _sV = 0;
605
- if (settings.autoWidth === false) {
606
- _sV = scene * ((slideWidth + settings.slideMargin) * settings.slideMove);
607
- } else {
608
- _sV = 0;
609
- for (var i = 0; i < scene; i++) {
610
- _sV += (parseInt($children.eq(i).width()) + settings.slideMargin);
611
- }
612
- }
613
- return _sV;
614
- },
615
- slideThumb: function () {
616
- var position;
617
- switch (settings.currentPagerPosition) {
618
- case 'left':
619
- position = 0;
620
- break;
621
- case 'middle':
622
- position = (elSize / 2) - (thumbWidth / 2);
623
- break;
624
- case 'right':
625
- position = elSize - thumbWidth;
626
- }
627
- var sc = scene - $el.find('.clone.left').length;
628
- var $pager = $slide.parent().find('.lSPager');
629
- if (settings.mode === 'slide' && settings.loop === true) {
630
- if (sc >= $pager.children().length) {
631
- sc = 0;
632
- } else if (sc < 0) {
633
- sc = $pager.children().length;
634
- }
635
- }
636
- var thumbSlide = sc * ((thumbWidth + settings.thumbMargin)) - (position);
637
- if ((thumbSlide + elSize) > pagerWidth) {
638
- thumbSlide = pagerWidth - elSize - settings.thumbMargin;
639
- }
640
- if (thumbSlide < 0) {
641
- thumbSlide = 0;
642
- }
643
- this.move($pager, thumbSlide);
644
- },
645
- auto: function () {
646
- if (settings.auto) {
647
- clearInterval(interval);
648
- interval = setInterval(function () {
649
- $el.goToNextSlide();
650
- }, settings.pause);
651
- }
652
- },
653
- pauseOnHover: function(){
654
- var $this = this;
655
- if (settings.auto && settings.pauseOnHover) {
656
- $slide.on('mouseenter', function(){
657
- $(this).addClass('ls-hover');
658
- $el.pause();
659
- settings.auto = true;
660
- });
661
- $slide.on('mouseleave',function(){
662
- $(this).removeClass('ls-hover');
663
- if (!$slide.find('.lightSlider').hasClass('lsGrabbing')) {
664
- $this.auto();
665
- }
666
- });
667
- }
668
- },
669
- touchMove: function (endCoords, startCoords) {
670
- $slide.css('transition-duration', '0ms');
671
- if (settings.mode === 'slide') {
672
- var distance = endCoords - startCoords;
673
- var swipeVal = slideValue - distance;
674
- if ((swipeVal) >= w - elSize - settings.slideMargin) {
675
- if (settings.freeMove === false) {
676
- swipeVal = w - elSize - settings.slideMargin;
677
- } else {
678
- var swipeValT = w - elSize - settings.slideMargin;
679
- swipeVal = swipeValT + ((swipeVal - swipeValT) / 5);
680
-
681
- }
682
- } else if (swipeVal < 0) {
683
- if (settings.freeMove === false) {
684
- swipeVal = 0;
685
- } else {
686
- swipeVal = swipeVal / 5;
687
- }
688
- }
689
- this.move($el, swipeVal);
690
- }
691
- },
692
-
693
- touchEnd: function (distance) {
694
- $slide.css('transition-duration', settings.speed + 'ms');
695
- if (settings.mode === 'slide') {
696
- var mxVal = false;
697
- var _next = true;
698
- slideValue = slideValue - distance;
699
- if ((slideValue) > w - elSize - settings.slideMargin) {
700
- slideValue = w - elSize - settings.slideMargin;
701
- if (settings.autoWidth === false) {
702
- mxVal = true;
703
- }
704
- } else if (slideValue < 0) {
705
- slideValue = 0;
706
- }
707
- var gC = function (next) {
708
- var ad = 0;
709
- if (!mxVal) {
710
- if (next) {
711
- ad = 1;
712
- }
713
- }
714
- if (!settings.autoWidth) {
715
- var num = slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove);
716
- scene = parseInt(num) + ad;
717
- if (slideValue >= (w - elSize - settings.slideMargin)) {
718
- if (num % 1 !== 0) {
719
- scene++;
720
- }
721
- }
722
- } else {
723
- var tW = 0;
724
- for (var i = 0; i < $children.length; i++) {
725
- tW += (parseInt($children.eq(i).width()) + settings.slideMargin);
726
- scene = i + ad;
727
- if (tW >= slideValue) {
728
- break;
729
- }
730
- }
731
- }
732
- };
733
- if (distance >= settings.swipeThreshold) {
734
- gC(false);
735
- _next = false;
736
- } else if (distance <= -settings.swipeThreshold) {
737
- gC(true);
738
- _next = false;
739
- }
740
- $el.mode(_next);
741
- this.slideThumb();
742
- } else {
743
- if (distance >= settings.swipeThreshold) {
744
- $el.goToPrevSlide();
745
- } else if (distance <= -settings.swipeThreshold) {
746
- $el.goToNextSlide();
747
- }
748
- }
749
- },
750
-
751
-
752
-
753
- enableDrag: function () {
754
- var $this = this;
755
- if (!isTouch) {
756
- var startCoords = 0,
757
- endCoords = 0,
758
- isDraging = false;
759
- $slide.find('.lightSlider').addClass('lsGrab');
760
- $slide.on('mousedown', function (e) {
761
- if (w < elSize) {
762
- if (w !== 0) {
763
- return false;
764
- }
765
- }
766
- if ($(e.target).attr('class') !== ('lSPrev') && $(e.target).attr('class') !== ('lSNext')) {
767
- startCoords = (settings.vertical === true) ? e.pageY : e.pageX;
768
- isDraging = true;
769
- if (e.preventDefault) {
770
- e.preventDefault();
771
- } else {
772
- e.returnValue = false;
773
- }
774
- // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
775
- $slide.scrollLeft += 1;
776
- $slide.scrollLeft -= 1;
777
- // *
778
- $slide.find('.lightSlider').removeClass('lsGrab').addClass('lsGrabbing');
779
- clearInterval(interval);
780
- }
781
- });
782
- $(window).on('mousemove', function (e) {
783
- if (isDraging) {
784
- endCoords = (settings.vertical === true) ? e.pageY : e.pageX;
785
- $this.touchMove(endCoords, startCoords);
786
- }
787
- });
788
- $(window).on('mouseup', function (e) {
789
- if (isDraging) {
790
- $slide.find('.lightSlider').removeClass('lsGrabbing').addClass('lsGrab');
791
- isDraging = false;
792
- endCoords = (settings.vertical === true) ? e.pageY : e.pageX;
793
- var distance = endCoords - startCoords;
794
- if (Math.abs(distance) >= settings.swipeThreshold) {
795
- $(window).on('click.ls', function (e) {
796
- if (e.preventDefault) {
797
- e.preventDefault();
798
- } else {
799
- e.returnValue = false;
800
- }
801
- e.stopImmediatePropagation();
802
- e.stopPropagation();
803
- $(window).off('click.ls');
804
- });
805
- }
806
-
807
- $this.touchEnd(distance);
808
-
809
- }
810
- });
811
- }
812
- },
813
-
814
-
815
-
816
-
817
- enableTouch: function () {
818
- var $this = this;
819
- if (isTouch) {
820
- var startCoords = {},
821
- endCoords = {};
822
- $slide.on('touchstart', function (e) {
823
- endCoords = e.originalEvent.targetTouches[0];
824
- startCoords.pageX = e.originalEvent.targetTouches[0].pageX;
825
- startCoords.pageY = e.originalEvent.targetTouches[0].pageY;
826
- clearInterval(interval);
827
- });
828
- $slide.on('touchmove', function (e) {
829
- if (w < elSize) {
830
- if (w !== 0) {
831
- return false;
832
- }
833
- }
834
- var orig = e.originalEvent;
835
- endCoords = orig.targetTouches[0];
836
- var xMovement = Math.abs(endCoords.pageX - startCoords.pageX);
837
- var yMovement = Math.abs(endCoords.pageY - startCoords.pageY);
838
- if (settings.vertical === true) {
839
- if ((yMovement * 3) > xMovement) {
840
- e.preventDefault();
841
- }
842
- $this.touchMove(endCoords.pageY, startCoords.pageY);
843
- } else {
844
- if ((xMovement * 3) > yMovement) {
845
- e.preventDefault();
846
- }
847
- $this.touchMove(endCoords.pageX, startCoords.pageX);
848
- }
849
-
850
- });
851
- $slide.on('touchend', function () {
852
- if (w < elSize) {
853
- if (w !== 0) {
854
- return false;
855
- }
856
- }
857
- var distance;
858
- if (settings.vertical === true) {
859
- distance = endCoords.pageY - startCoords.pageY;
860
- } else {
861
- distance = endCoords.pageX - startCoords.pageX;
862
- }
863
- $this.touchEnd(distance);
864
- });
865
- }
866
- },
867
- build: function () {
868
- var $this = this;
869
- $this.initialStyle();
870
- if (this.doCss()) {
871
-
872
- if (settings.enableTouch === true) {
873
- $this.enableTouch();
874
- }
875
- if (settings.enableDrag === true) {
876
- $this.enableDrag();
877
- }
878
- }
879
-
880
- $(window).on('focus', function(){
881
- $this.auto();
882
- });
883
-
884
- $(window).on('blur', function(){
885
- clearInterval(interval);
886
- });
887
-
888
- $this.pager();
889
- $this.pauseOnHover();
890
- $this.controls();
891
- $this.keyPress();
892
- }
893
- };
894
- plugin.build();
895
- refresh.init = function () {
896
- refresh.chbreakpoint();
897
- if (settings.vertical === true) {
898
- if (settings.item > 1) {
899
- elSize = settings.verticalHeight;
900
- } else {
901
- elSize = $children.outerHeight();
902
- }
903
- $slide.css('height', elSize + 'px');
904
- } else {
905
- elSize = $slide.outerWidth();
906
- }
907
- if (settings.loop === true && settings.mode === 'slide') {
908
- refresh.clone();
909
- }
910
- refresh.calL();
911
- if (settings.mode === 'slide') {
912
- $el.removeClass('lSSlide');
913
- }
914
- if (settings.mode === 'slide') {
915
- refresh.calSW();
916
- refresh.sSW();
917
- }
918
- setTimeout(function () {
919
- if (settings.mode === 'slide') {
920
- $el.addClass('lSSlide');
921
- }
922
- }, 1000);
923
- if (settings.pager) {
924
- refresh.createPager();
925
- }
926
- if (settings.adaptiveHeight === true && settings.vertical === false) {
927
- $el.css('height', $children.eq(scene).outerHeight(true));
928
- }
929
- if (settings.adaptiveHeight === false) {
930
- if (settings.mode === 'slide') {
931
- if (settings.vertical === false) {
932
- plugin.setHeight($el, false);
933
- }else{
934
- plugin.auto();
935
- }
936
- } else {
937
- plugin.setHeight($el, true);
938
- }
939
- }
940
- if (settings.gallery === true) {
941
- plugin.slideThumb();
942
- }
943
- if (settings.mode === 'slide') {
944
- plugin.slide();
945
- }
946
- if (settings.autoWidth === false) {
947
- if ($children.length <= settings.item) {
948
- $slide.find('.lSAction').hide();
949
- } else {
950
- $slide.find('.lSAction').show();
951
- }
952
- } else {
953
- if ((refresh.calWidth(false) < elSize) && (w !== 0)) {
954
- $slide.find('.lSAction').hide();
955
- } else {
956
- $slide.find('.lSAction').show();
957
- }
958
- }
959
- };
960
- $el.goToPrevSlide = function () {
961
- if (scene > 0) {
962
- settings.onBeforePrevSlide.call(this, $el, scene);
963
- scene--;
964
- $el.mode(false);
965
- if (settings.gallery === true) {
966
- plugin.slideThumb();
967
- }
968
- } else {
969
- if (settings.loop === true) {
970
- settings.onBeforePrevSlide.call(this, $el, scene);
971
- if (settings.mode === 'fade') {
972
- var l = (length - 1);
973
- scene = parseInt(l / settings.slideMove);
974
- }
975
- $el.mode(false);
976
- if (settings.gallery === true) {
977
- plugin.slideThumb();
978
- }
979
- } else if (settings.slideEndAnimation === true) {
980
- $el.addClass('leftEnd');
981
- setTimeout(function () {
982
- $el.removeClass('leftEnd');
983
- }, 400);
984
- }
985
- }
986
- };
987
- $el.goToNextSlide = function () {
988
- var nextI = true;
989
- if (settings.mode === 'slide') {
990
- var _slideValue = plugin.slideValue();
991
- nextI = _slideValue < w - elSize - settings.slideMargin;
992
- }
993
- if (((scene * settings.slideMove) < length - settings.slideMove) && nextI) {
994
- settings.onBeforeNextSlide.call(this, $el, scene);
995
- scene++;
996
- $el.mode(false);
997
- if (settings.gallery === true) {
998
- plugin.slideThumb();
999
- }
1000
- } else {
1001
- if (settings.loop === true) {
1002
- settings.onBeforeNextSlide.call(this, $el, scene);
1003
- scene = 0;
1004
- $el.mode(false);
1005
- if (settings.gallery === true) {
1006
- plugin.slideThumb();
1007
- }
1008
- } else if (settings.slideEndAnimation === true) {
1009
- $el.addClass('rightEnd');
1010
- setTimeout(function () {
1011
- $el.removeClass('rightEnd');
1012
- }, 400);
1013
- }
1014
- }
1015
- };
1016
- $el.mode = function (_touch) {
1017
- if (settings.adaptiveHeight === true && settings.vertical === false) {
1018
- $el.css('height', $children.eq(scene).outerHeight(true));
1019
- }
1020
- if (on === false) {
1021
- if (settings.mode === 'slide') {
1022
- if (plugin.doCss()) {
1023
- $el.addClass('lSSlide');
1024
- if (settings.speed !== '') {
1025
- $slide.css('transition-duration', settings.speed + 'ms');
1026
- }
1027
- if (settings.cssEasing !== '') {
1028
- $slide.css('transition-timing-function', settings.cssEasing);
1029
- }
1030
- }
1031
- } else {
1032
- if (plugin.doCss()) {
1033
- if (settings.speed !== '') {
1034
- $el.css('transition-duration', settings.speed + 'ms');
1035
- }
1036
- if (settings.cssEasing !== '') {
1037
- $el.css('transition-timing-function', settings.cssEasing);
1038
- }
1039
- }
1040
- }
1041
- }
1042
- if (!_touch) {
1043
- settings.onBeforeSlide.call(this, $el, scene);
1044
- }
1045
- if (settings.mode === 'slide') {
1046
- plugin.slide();
1047
- } else {
1048
- plugin.fade();
1049
- }
1050
- if (!$slide.hasClass('ls-hover')) {
1051
- plugin.auto();
1052
- }
1053
- setTimeout(function () {
1054
- if (!_touch) {
1055
- settings.onAfterSlide.call(this, $el, scene);
1056
- }
1057
- }, settings.speed);
1058
- on = true;
1059
- };
1060
- $el.play = function () {
1061
- $el.goToNextSlide();
1062
- settings.auto = true;
1063
- plugin.auto();
1064
- };
1065
- $el.pause = function () {
1066
- settings.auto = false;
1067
- clearInterval(interval);
1068
- };
1069
- $el.refresh = function () {
1070
- refresh.init();
1071
- };
1072
- $el.getCurrentSlideCount = function () {
1073
- var sc = scene;
1074
- if (settings.loop) {
1075
- var ln = $slide.find('.lslide').length,
1076
- cl = $el.find('.clone.left').length;
1077
- if (scene <= cl - 1) {
1078
- sc = ln + (scene - cl);
1079
- } else if (scene >= (ln + cl)) {
1080
- sc = scene - ln - cl;
1081
- } else {
1082
- sc = scene - cl;
1083
- }
1084
- }
1085
- return sc + 1;
1086
- };
1087
- $el.getTotalSlideCount = function () {
1088
- return $slide.find('.lslide').length;
1089
- };
1090
- $el.goToSlide = function (s) {
1091
- if (settings.loop) {
1092
- scene = (s + $el.find('.clone.left').length - 1);
1093
- } else {
1094
- scene = s;
1095
- }
1096
- $el.mode(false);
1097
- if (settings.gallery === true) {
1098
- plugin.slideThumb();
1099
- }
1100
- };
1101
- $el.destroy = function () {
1102
- if ($el.lightSlider) {
1103
- $el.goToPrevSlide = function(){};
1104
- $el.goToNextSlide = function(){};
1105
- $el.mode = function(){};
1106
- $el.play = function(){};
1107
- $el.pause = function(){};
1108
- $el.refresh = function(){};
1109
- $el.getCurrentSlideCount = function(){};
1110
- $el.getTotalSlideCount = function(){};
1111
- $el.goToSlide = function(){};
1112
- $el.lightSlider = null;
1113
- refresh = {
1114
- init : function(){}
1115
- };
1116
- $el.parent().parent().find('.lSAction, .lSPager').remove();
1117
- $el.removeClass('lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right').removeAttr('style').unwrap().unwrap();
1118
- $el.children().removeAttr('style');
1119
- $children.removeClass('lslide active');
1120
- $el.find('.clone').remove();
1121
- $children = null;
1122
- interval = null;
1123
- on = false;
1124
- scene = 0;
1125
- }
1126
-
1127
- };
1128
- setTimeout(function () {
1129
- settings.onSliderLoad.call(this, $el);
1130
- }, 10);
1131
- $(window).on('resize orientationchange', function (e) {
1132
- setTimeout(function () {
1133
- if (e.preventDefault) {
1134
- e.preventDefault();
1135
- } else {
1136
- e.returnValue = false;
1137
- }
1138
- refresh.init();
1139
- }, 200);
1140
- });
1141
- return this;
1142
- };
1143
- }(jQuery));
1
+ /*! lightslider - v1.1.6 - 2016-10-25
2
+ * https://github.com/sachinchoolur/lightslider
3
+ * Copyright (c) 2016 Sachin N; Licensed MIT */
4
+ (function ($, undefined) {
5
+ 'use strict';
6
+ var defaults = {
7
+ item: 3,
8
+ autoWidth: false,
9
+ slideMove: 1,
10
+ slideMargin: 10,
11
+ addClass: '',
12
+ mode: 'slide',
13
+ useCSS: true,
14
+ cssEasing: 'ease', //'cubic-bezier(0.25, 0, 0.25, 1)',
15
+ easing: 'linear', //'for jquery animation',//
16
+ speed: 400, //ms'
17
+ auto: false,
18
+ pauseOnHover: false,
19
+ loop: false,
20
+ slideEndAnimation: true,
21
+ pause: 2000,
22
+ keyPress: false,
23
+ controls: true,
24
+ prevHtml: '',
25
+ nextHtml: '',
26
+ rtl: false,
27
+ adaptiveHeight: false,
28
+ vertical: false,
29
+ verticalHeight: 500,
30
+ vThumbWidth: 100,
31
+ thumbItem: 10,
32
+ pager: true,
33
+ gallery: false,
34
+ galleryMargin: 5,
35
+ thumbMargin: 5,
36
+ currentPagerPosition: 'middle',
37
+ enableTouch: true,
38
+ enableDrag: true,
39
+ freeMove: true,
40
+ swipeThreshold: 40,
41
+ responsive: [],
42
+ /* jshint ignore:start */
43
+ onBeforeStart: function ($el) {},
44
+ onSliderLoad: function ($el) {},
45
+ onBeforeSlide: function ($el, scene) {},
46
+ onAfterSlide: function ($el, scene) {},
47
+ onBeforeNextSlide: function ($el, scene) {},
48
+ onBeforePrevSlide: function ($el, scene) {}
49
+ /* jshint ignore:end */
50
+ };
51
+ $.fn.lightSlider = function (options) {
52
+ if (this.length === 0) {
53
+ return this;
54
+ }
55
+
56
+ if (this.length > 1) {
57
+ this.each(function () {
58
+ $(this).lightSlider(options);
59
+ });
60
+ return this;
61
+ }
62
+
63
+ var plugin = {},
64
+ settings = $.extend(true, {}, defaults, options),
65
+ settingsTemp = {},
66
+ $el = this;
67
+ plugin.$el = this;
68
+
69
+ if (settings.mode === 'fade') {
70
+ settings.vertical = false;
71
+ }
72
+ var $children = $el.children(),
73
+ windowW = $(window).width(),
74
+ breakpoint = null,
75
+ resposiveObj = null,
76
+ length = 0,
77
+ w = 0,
78
+ on = false,
79
+ elSize = 0,
80
+ $slide = '',
81
+ scene = 0,
82
+ property = (settings.vertical === true) ? 'height' : 'width',
83
+ gutter = (settings.vertical === true) ? 'margin-bottom' : 'margin-right',
84
+ slideValue = 0,
85
+ pagerWidth = 0,
86
+ slideWidth = 0,
87
+ thumbWidth = 0,
88
+ interval = null,
89
+ isTouch = ('ontouchstart' in document.documentElement);
90
+ var refresh = {};
91
+
92
+ refresh.chbreakpoint = function () {
93
+ windowW = $(window).width();
94
+ if (settings.responsive.length) {
95
+ var item;
96
+ if (settings.autoWidth === false) {
97
+ item = settings.item;
98
+ }
99
+ if (windowW < settings.responsive[0].breakpoint) {
100
+ for (var i = 0; i < settings.responsive.length; i++) {
101
+ if (windowW < settings.responsive[i].breakpoint) {
102
+ breakpoint = settings.responsive[i].breakpoint;
103
+ resposiveObj = settings.responsive[i];
104
+ }
105
+ }
106
+ }
107
+ if (typeof resposiveObj !== 'undefined' && resposiveObj !== null) {
108
+ for (var j in resposiveObj.settings) {
109
+ if (resposiveObj.settings.hasOwnProperty(j)) {
110
+ if (typeof settingsTemp[j] === 'undefined' || settingsTemp[j] === null) {
111
+ settingsTemp[j] = settings[j];
112
+ }
113
+ settings[j] = resposiveObj.settings[j];
114
+ }
115
+ }
116
+ }
117
+ if (!$.isEmptyObject(settingsTemp) && windowW > settings.responsive[0].breakpoint) {
118
+ for (var k in settingsTemp) {
119
+ if (settingsTemp.hasOwnProperty(k)) {
120
+ settings[k] = settingsTemp[k];
121
+ }
122
+ }
123
+ }
124
+ if (settings.autoWidth === false) {
125
+ if (slideValue > 0 && slideWidth > 0) {
126
+ if (item !== settings.item) {
127
+ scene = Math.round(slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove));
128
+ }
129
+ }
130
+ }
131
+ }
132
+ };
133
+
134
+ refresh.calSW = function () {
135
+ if (settings.autoWidth === false) {
136
+ slideWidth = (elSize - ((settings.item * (settings.slideMargin)) - settings.slideMargin)) / settings.item;
137
+ }
138
+ };
139
+
140
+ refresh.calWidth = function (cln) {
141
+ var ln = cln === true ? $slide.find('.lslide').length : $children.length;
142
+ if (settings.autoWidth === false) {
143
+ w = ln * (slideWidth + settings.slideMargin);
144
+ } else {
145
+ w = 0;
146
+ for (var i = 0; i < ln; i++) {
147
+ w += (parseInt($children.eq(i).width()) + settings.slideMargin);
148
+ }
149
+ }
150
+ return w;
151
+ };
152
+ plugin = {
153
+ doCss: function () {
154
+ var support = function () {
155
+ var transition = ['transition', 'MozTransition', 'WebkitTransition', 'OTransition', 'msTransition', 'KhtmlTransition'];
156
+ var root = document.documentElement;
157
+ for (var i = 0; i < transition.length; i++) {
158
+ if (transition[i] in root.style) {
159
+ return true;
160
+ }
161
+ }
162
+ };
163
+ if (settings.useCSS && support()) {
164
+ return true;
165
+ }
166
+ return false;
167
+ },
168
+ keyPress: function () {
169
+ if (settings.keyPress) {
170
+ $(document).on('keyup.lightslider', function (e) {
171
+ if (!$(':focus').is('input, textarea')) {
172
+ if (e.preventDefault) {
173
+ e.preventDefault();
174
+ } else {
175
+ e.returnValue = false;
176
+ }
177
+ if (e.keyCode === 37) {
178
+ $el.goToPrevSlide();
179
+ } else if (e.keyCode === 39) {
180
+ $el.goToNextSlide();
181
+ }
182
+ }
183
+ });
184
+ }
185
+ },
186
+ controls: function () {
187
+ if (settings.controls) {
188
+ $el.after('<div class="lSAction"><a class="lSPrev">' + settings.prevHtml + '</a><a class="lSNext">' + settings.nextHtml + '</a></div>');
189
+ if (!settings.autoWidth) {
190
+ if (length <= settings.item) {
191
+ $slide.find('.lSAction').hide();
192
+ }
193
+ } else {
194
+ if (refresh.calWidth(false) < elSize) {
195
+ $slide.find('.lSAction').hide();
196
+ }
197
+ }
198
+ $slide.find('.lSAction a').on('click', function (e) {
199
+ if (e.preventDefault) {
200
+ e.preventDefault();
201
+ } else {
202
+ e.returnValue = false;
203
+ }
204
+ if ($(this).attr('class') === 'lSPrev') {
205
+ $el.goToPrevSlide();
206
+ } else {
207
+ $el.goToNextSlide();
208
+ }
209
+ return false;
210
+ });
211
+ }
212
+ },
213
+ initialStyle: function () {
214
+ var $this = this;
215
+ if (settings.mode === 'fade') {
216
+ settings.autoWidth = false;
217
+ settings.slideEndAnimation = false;
218
+ }
219
+ if (settings.auto) {
220
+ settings.slideEndAnimation = false;
221
+ }
222
+ if (settings.autoWidth) {
223
+ settings.slideMove = 1;
224
+ settings.item = 1;
225
+ }
226
+ if (settings.loop) {
227
+ settings.slideMove = 1;
228
+ settings.freeMove = false;
229
+ }
230
+ settings.onBeforeStart.call(this, $el);
231
+ refresh.chbreakpoint();
232
+ $el.addClass('lightSlider').wrap('<div class="lSSlideOuter ' + settings.addClass + '"><div class="lSSlideWrapper"></div></div>');
233
+ $slide = $el.parent('.lSSlideWrapper');
234
+ if (settings.rtl === true) {
235
+ $slide.parent().addClass('lSrtl');
236
+ }
237
+ if (settings.vertical) {
238
+ $slide.parent().addClass('vertical');
239
+ elSize = settings.verticalHeight;
240
+ $slide.css('height', elSize + 'px');
241
+ } else {
242
+ elSize = $el.outerWidth();
243
+ }
244
+ $children.addClass('lslide');
245
+ if (settings.loop === true && settings.mode === 'slide') {
246
+ refresh.calSW();
247
+ refresh.clone = function () {
248
+ if (refresh.calWidth(true) > elSize) {
249
+ /**/
250
+ var tWr = 0,
251
+ tI = 0;
252
+ for (var k = 0; k < $children.length; k++) {
253
+ tWr += (parseInt($el.find('.lslide').eq(k).width()) + settings.slideMargin);
254
+ tI++;
255
+ if (tWr >= (elSize + settings.slideMargin)) {
256
+ break;
257
+ }
258
+ }
259
+ var tItem = settings.autoWidth === true ? tI : settings.item;
260
+
261
+ /**/
262
+ if (tItem < $el.find('.clone.left').length) {
263
+ for (var i = 0; i < $el.find('.clone.left').length - tItem; i++) {
264
+ $children.eq(i).remove();
265
+ }
266
+ }
267
+ if (tItem < $el.find('.clone.right').length) {
268
+ for (var j = $children.length - 1; j > ($children.length - 1 - $el.find('.clone.right').length); j--) {
269
+ scene--;
270
+ $children.eq(j).remove();
271
+ }
272
+ }
273
+ /**/
274
+ for (var n = $el.find('.clone.right').length; n < tItem; n++) {
275
+ $el.find('.lslide').eq(n).clone().removeClass('lslide').addClass('clone right').appendTo($el);
276
+ scene++;
277
+ }
278
+ for (var m = $el.find('.lslide').length - $el.find('.clone.left').length; m > ($el.find('.lslide').length - tItem); m--) {
279
+ $el.find('.lslide').eq(m - 1).clone().removeClass('lslide').addClass('clone left').prependTo($el);
280
+ }
281
+ $children = $el.children();
282
+ } else {
283
+ if ($children.hasClass('clone')) {
284
+ $el.find('.clone').remove();
285
+ $this.move($el, 0);
286
+ }
287
+ }
288
+ };
289
+ refresh.clone();
290
+ }
291
+ refresh.sSW = function () {
292
+ length = $children.length;
293
+ if (settings.rtl === true && settings.vertical === false) {
294
+ gutter = 'margin-left';
295
+ }
296
+ if (settings.autoWidth === false) {
297
+ $children.css(property, slideWidth + 'px');
298
+ }
299
+ $children.css(gutter, settings.slideMargin + 'px');
300
+ w = refresh.calWidth(false);
301
+ $el.css(property, w + 'px');
302
+ if (settings.loop === true && settings.mode === 'slide') {
303
+ if (on === false) {
304
+ scene = $el.find('.clone.left').length;
305
+ }
306
+ }
307
+ };
308
+ refresh.calL = function () {
309
+ $children = $el.children();
310
+ length = $children.length;
311
+ };
312
+ if (this.doCss()) {
313
+ $slide.addClass('usingCss');
314
+ }
315
+ refresh.calL();
316
+ if (settings.mode === 'slide') {
317
+ refresh.calSW();
318
+ refresh.sSW();
319
+ if (settings.loop === true) {
320
+ slideValue = $this.slideValue();
321
+ this.move($el, slideValue);
322
+ }
323
+ if (settings.vertical === false) {
324
+ this.setHeight($el, false);
325
+ }
326
+
327
+ } else {
328
+ this.setHeight($el, true);
329
+ $el.addClass('lSFade');
330
+ if (!this.doCss()) {
331
+ $children.fadeOut(0);
332
+ $children.eq(scene).fadeIn(0);
333
+ }
334
+ }
335
+ if (settings.loop === true && settings.mode === 'slide') {
336
+ $children.eq(scene).addClass('active');
337
+ } else {
338
+ $children.first().addClass('active');
339
+ }
340
+ },
341
+ pager: function () {
342
+ var $this = this;
343
+ refresh.createPager = function () {
344
+ thumbWidth = (elSize - ((settings.thumbItem * (settings.thumbMargin)) - settings.thumbMargin)) / settings.thumbItem;
345
+ var $children = $slide.find('.lslide');
346
+ var length = $slide.find('.lslide').length;
347
+ var i = 0,
348
+ pagers = '',
349
+ v = 0;
350
+ for (i = 0; i < length; i++) {
351
+ if (settings.mode === 'slide') {
352
+ // calculate scene * slide value
353
+ if (!settings.autoWidth) {
354
+ v = i * ((slideWidth + settings.slideMargin) * settings.slideMove);
355
+ } else {
356
+ v += ((parseInt($children.eq(i).width()) + settings.slideMargin) * settings.slideMove);
357
+ }
358
+ }
359
+ var thumb = $children.eq(i * settings.slideMove).attr('data-thumb');
360
+ if (settings.gallery === true) {
361
+ pagers += '<li style="width:100%;' + property + ':' + thumbWidth + 'px;' + gutter + ':' + settings.thumbMargin + 'px"><a href="#"><img src="' + thumb + '" /></a></li>';
362
+ } else {
363
+ pagers += '<li><a href="#">' + (i + 1) + '</a></li>';
364
+ }
365
+ if (settings.mode === 'slide') {
366
+ if ((v) >= w - elSize - settings.slideMargin) {
367
+ i = i + 1;
368
+ var minPgr = 2;
369
+ if (settings.autoWidth) {
370
+ pagers += '<li><a href="#">' + (i + 1) + '</a></li>';
371
+ minPgr = 1;
372
+ }
373
+ if (i < minPgr) {
374
+ pagers = null;
375
+ $slide.parent().addClass('noPager');
376
+ } else {
377
+ $slide.parent().removeClass('noPager');
378
+ }
379
+ break;
380
+ }
381
+ }
382
+ }
383
+ var $cSouter = $slide.parent();
384
+ $cSouter.find('.lSPager').html(pagers);
385
+ if (settings.gallery === true) {
386
+ if (settings.vertical === true) {
387
+ // set Gallery thumbnail width
388
+ $cSouter.find('.lSPager').css('width', settings.vThumbWidth + 'px');
389
+ }
390
+ pagerWidth = (i * (settings.thumbMargin + thumbWidth)) + 0.5;
391
+ $cSouter.find('.lSPager').css({
392
+ property: pagerWidth + 'px',
393
+ 'transition-duration': settings.speed + 'ms'
394
+ });
395
+ if (settings.vertical === true) {
396
+ $slide.parent().css('padding-right', (settings.vThumbWidth + settings.galleryMargin) + 'px');
397
+ }
398
+ $cSouter.find('.lSPager').css(property, pagerWidth + 'px');
399
+ }
400
+ var $pager = $cSouter.find('.lSPager').find('li');
401
+ $pager.first().addClass('active');
402
+ $pager.on('click', function () {
403
+ if (settings.loop === true && settings.mode === 'slide') {
404
+ scene = scene + ($pager.index(this) - $cSouter.find('.lSPager').find('li.active').index());
405
+ } else {
406
+ scene = $pager.index(this);
407
+ }
408
+ $el.mode(false);
409
+ if (settings.gallery === true) {
410
+ $this.slideThumb();
411
+ }
412
+ return false;
413
+ });
414
+ };
415
+ if (settings.pager) {
416
+ var cl = 'lSpg';
417
+ if (settings.gallery) {
418
+ cl = 'lSGallery';
419
+ }
420
+ $slide.after('<ul class="lSPager ' + cl + '"></ul>');
421
+ var gMargin = (settings.vertical) ? 'margin-left' : 'margin-top';
422
+ $slide.parent().find('.lSPager').css(gMargin, settings.galleryMargin + 'px');
423
+ refresh.createPager();
424
+ }
425
+
426
+ setTimeout(function () {
427
+ refresh.init();
428
+ }, 0);
429
+ },
430
+ setHeight: function (ob, fade) {
431
+ var obj = null,
432
+ $this = this;
433
+ if (settings.loop) {
434
+ obj = ob.children('.lslide ').first();
435
+ } else {
436
+ obj = ob.children().first();
437
+ }
438
+ var setCss = function () {
439
+ var tH = obj.outerHeight(),
440
+ tP = 0,
441
+ tHT = tH;
442
+ if (fade) {
443
+ tH = 0;
444
+ tP = ((tHT) * 100) / elSize;
445
+ }
446
+ ob.css({
447
+ 'height': tH + 'px',
448
+ 'padding-bottom': tP + '%'
449
+ });
450
+ };
451
+ setCss();
452
+ if (obj.find('img').length) {
453
+ if ( obj.find('img')[0].complete) {
454
+ setCss();
455
+ if (!interval) {
456
+ $this.auto();
457
+ }
458
+ }else{
459
+ obj.find('img').on('load', function () {
460
+ setTimeout(function () {
461
+ setCss();
462
+ if (!interval) {
463
+ $this.auto();
464
+ }
465
+ }, 100);
466
+ });
467
+ }
468
+ }else{
469
+ if (!interval) {
470
+ $this.auto();
471
+ }
472
+ }
473
+ },
474
+ active: function (ob, t) {
475
+ if (this.doCss() && settings.mode === 'fade') {
476
+ $slide.addClass('on');
477
+ }
478
+ var sc = 0;
479
+ if (scene * settings.slideMove < length) {
480
+ ob.removeClass('active');
481
+ if (!this.doCss() && settings.mode === 'fade' && t === false) {
482
+ ob.fadeOut(settings.speed);
483
+ }
484
+ if (t === true) {
485
+ sc = scene;
486
+ } else {
487
+ sc = scene * settings.slideMove;
488
+ }
489
+ //t === true ? sc = scene : sc = scene * settings.slideMove;
490
+ var l, nl;
491
+ if (t === true) {
492
+ l = ob.length;
493
+ nl = l - 1;
494
+ if (sc + 1 >= l) {
495
+ sc = nl;
496
+ }
497
+ }
498
+ if (settings.loop === true && settings.mode === 'slide') {
499
+ //t === true ? sc = scene - $el.find('.clone.left').length : sc = scene * settings.slideMove;
500
+ if (t === true) {
501
+ sc = scene - $el.find('.clone.left').length;
502
+ } else {
503
+ sc = scene * settings.slideMove;
504
+ }
505
+ if (t === true) {
506
+ l = ob.length;
507
+ nl = l - 1;
508
+ if (sc + 1 === l) {
509
+ sc = nl;
510
+ } else if (sc + 1 > l) {
511
+ sc = 0;
512
+ }
513
+ }
514
+ }
515
+
516
+ if (!this.doCss() && settings.mode === 'fade' && t === false) {
517
+ ob.eq(sc).fadeIn(settings.speed);
518
+ }
519
+ ob.eq(sc).addClass('active');
520
+ } else {
521
+ ob.removeClass('active');
522
+ ob.eq(ob.length - 1).addClass('active');
523
+ if (!this.doCss() && settings.mode === 'fade' && t === false) {
524
+ ob.fadeOut(settings.speed);
525
+ ob.eq(sc).fadeIn(settings.speed);
526
+ }
527
+ }
528
+ },
529
+ move: function (ob, v) {
530
+ if (settings.rtl === true) {
531
+ v = -v;
532
+ }
533
+ if (this.doCss()) {
534
+ if (settings.vertical === true) {
535
+ ob.css({
536
+ 'transform': 'translate3d(0px, ' + (-v) + 'px, 0px)',
537
+ '-webkit-transform': 'translate3d(0px, ' + (-v) + 'px, 0px)'
538
+ });
539
+ } else {
540
+ ob.css({
541
+ 'transform': 'translate3d(' + (-v) + 'px, 0px, 0px)',
542
+ '-webkit-transform': 'translate3d(' + (-v) + 'px, 0px, 0px)',
543
+ });
544
+ }
545
+ } else {
546
+ if (settings.vertical === true) {
547
+ ob.css('position', 'relative').animate({
548
+ top: -v + 'px'
549
+ }, settings.speed, settings.easing);
550
+ } else {
551
+ ob.css('position', 'relative').animate({
552
+ left: -v + 'px'
553
+ }, settings.speed, settings.easing);
554
+ }
555
+ }
556
+ var $thumb = $slide.parent().find('.lSPager').find('li');
557
+ this.active($thumb, true);
558
+ },
559
+ fade: function () {
560
+ this.active($children, false);
561
+ var $thumb = $slide.parent().find('.lSPager').find('li');
562
+ this.active($thumb, true);
563
+ },
564
+ slide: function () {
565
+ var $this = this;
566
+ refresh.calSlide = function () {
567
+ if (w > elSize) {
568
+ slideValue = $this.slideValue();
569
+ $this.active($children, false);
570
+ if ((slideValue) > w - elSize - settings.slideMargin) {
571
+ slideValue = w - elSize - settings.slideMargin;
572
+ } else if (slideValue < 0) {
573
+ slideValue = 0;
574
+ }
575
+ $this.move($el, slideValue);
576
+ if (settings.loop === true && settings.mode === 'slide') {
577
+ if (scene >= (length - ($el.find('.clone.left').length / settings.slideMove))) {
578
+ $this.resetSlide($el.find('.clone.left').length);
579
+ }
580
+ if (scene === 0) {
581
+ $this.resetSlide($slide.find('.lslide').length);
582
+ }
583
+ }
584
+ }
585
+ };
586
+ refresh.calSlide();
587
+ },
588
+ resetSlide: function (s) {
589
+ var $this = this;
590
+ $slide.find('.lSAction a').addClass('disabled');
591
+ setTimeout(function () {
592
+ scene = s;
593
+ $slide.css('transition-duration', '0ms');
594
+ slideValue = $this.slideValue();
595
+ $this.active($children, false);
596
+ plugin.move($el, slideValue);
597
+ setTimeout(function () {
598
+ $slide.css('transition-duration', settings.speed + 'ms');
599
+ $slide.find('.lSAction a').removeClass('disabled');
600
+ }, 50);
601
+ }, settings.speed + 100);
602
+ },
603
+ slideValue: function () {
604
+ var _sV = 0;
605
+ if (settings.autoWidth === false) {
606
+ _sV = scene * ((slideWidth + settings.slideMargin) * settings.slideMove);
607
+ } else {
608
+ _sV = 0;
609
+ for (var i = 0; i < scene; i++) {
610
+ _sV += (parseInt($children.eq(i).width()) + settings.slideMargin);
611
+ }
612
+ }
613
+ return _sV;
614
+ },
615
+ slideThumb: function () {
616
+ var position;
617
+ switch (settings.currentPagerPosition) {
618
+ case 'left':
619
+ position = 0;
620
+ break;
621
+ case 'middle':
622
+ position = (elSize / 2) - (thumbWidth / 2);
623
+ break;
624
+ case 'right':
625
+ position = elSize - thumbWidth;
626
+ }
627
+ var sc = scene - $el.find('.clone.left').length;
628
+ var $pager = $slide.parent().find('.lSPager');
629
+ if (settings.mode === 'slide' && settings.loop === true) {
630
+ if (sc >= $pager.children().length) {
631
+ sc = 0;
632
+ } else if (sc < 0) {
633
+ sc = $pager.children().length;
634
+ }
635
+ }
636
+ var thumbSlide = sc * ((thumbWidth + settings.thumbMargin)) - (position);
637
+ if ((thumbSlide + elSize) > pagerWidth) {
638
+ thumbSlide = pagerWidth - elSize - settings.thumbMargin;
639
+ }
640
+ if (thumbSlide < 0) {
641
+ thumbSlide = 0;
642
+ }
643
+ this.move($pager, thumbSlide);
644
+ },
645
+ auto: function () {
646
+ if (settings.auto) {
647
+ clearInterval(interval);
648
+ interval = setInterval(function () {
649
+ $el.goToNextSlide();
650
+ }, settings.pause);
651
+ }
652
+ },
653
+ pauseOnHover: function(){
654
+ var $this = this;
655
+ if (settings.auto && settings.pauseOnHover) {
656
+ $slide.on('mouseenter', function(){
657
+ $(this).addClass('ls-hover');
658
+ $el.pause();
659
+ settings.auto = true;
660
+ });
661
+ $slide.on('mouseleave',function(){
662
+ $(this).removeClass('ls-hover');
663
+ if (!$slide.find('.lightSlider').hasClass('lsGrabbing')) {
664
+ $this.auto();
665
+ }
666
+ });
667
+ }
668
+ },
669
+ touchMove: function (endCoords, startCoords) {
670
+ $slide.css('transition-duration', '0ms');
671
+ if (settings.mode === 'slide') {
672
+ var distance = endCoords - startCoords;
673
+ var swipeVal = slideValue - distance;
674
+ if ((swipeVal) >= w - elSize - settings.slideMargin) {
675
+ if (settings.freeMove === false) {
676
+ swipeVal = w - elSize - settings.slideMargin;
677
+ } else {
678
+ var swipeValT = w - elSize - settings.slideMargin;
679
+ swipeVal = swipeValT + ((swipeVal - swipeValT) / 5);
680
+
681
+ }
682
+ } else if (swipeVal < 0) {
683
+ if (settings.freeMove === false) {
684
+ swipeVal = 0;
685
+ } else {
686
+ swipeVal = swipeVal / 5;
687
+ }
688
+ }
689
+ this.move($el, swipeVal);
690
+ }
691
+ },
692
+
693
+ touchEnd: function (distance) {
694
+ $slide.css('transition-duration', settings.speed + 'ms');
695
+ if (settings.mode === 'slide') {
696
+ var mxVal = false;
697
+ var _next = true;
698
+ slideValue = slideValue - distance;
699
+ if ((slideValue) > w - elSize - settings.slideMargin) {
700
+ slideValue = w - elSize - settings.slideMargin;
701
+ if (settings.autoWidth === false) {
702
+ mxVal = true;
703
+ }
704
+ } else if (slideValue < 0) {
705
+ slideValue = 0;
706
+ }
707
+ var gC = function (next) {
708
+ var ad = 0;
709
+ if (!mxVal) {
710
+ if (next) {
711
+ ad = 1;
712
+ }
713
+ }
714
+ if (!settings.autoWidth) {
715
+ var num = slideValue / ((slideWidth + settings.slideMargin) * settings.slideMove);
716
+ scene = parseInt(num) + ad;
717
+ if (slideValue >= (w - elSize - settings.slideMargin)) {
718
+ if (num % 1 !== 0) {
719
+ scene++;
720
+ }
721
+ }
722
+ } else {
723
+ var tW = 0;
724
+ for (var i = 0; i < $children.length; i++) {
725
+ tW += (parseInt($children.eq(i).width()) + settings.slideMargin);
726
+ scene = i + ad;
727
+ if (tW >= slideValue) {
728
+ break;
729
+ }
730
+ }
731
+ }
732
+ };
733
+ if (distance >= settings.swipeThreshold) {
734
+ gC(false);
735
+ _next = false;
736
+ } else if (distance <= -settings.swipeThreshold) {
737
+ gC(true);
738
+ _next = false;
739
+ }
740
+ $el.mode(_next);
741
+ this.slideThumb();
742
+ } else {
743
+ if (distance >= settings.swipeThreshold) {
744
+ $el.goToPrevSlide();
745
+ } else if (distance <= -settings.swipeThreshold) {
746
+ $el.goToNextSlide();
747
+ }
748
+ }
749
+ },
750
+
751
+
752
+
753
+ enableDrag: function () {
754
+ var $this = this;
755
+ if (!isTouch) {
756
+ var startCoords = 0,
757
+ endCoords = 0,
758
+ isDraging = false;
759
+ $slide.find('.lightSlider').addClass('lsGrab');
760
+ $slide.on('mousedown', function (e) {
761
+ if (w < elSize) {
762
+ if (w !== 0) {
763
+ return false;
764
+ }
765
+ }
766
+ if ($(e.target).attr('class') !== ('lSPrev') && $(e.target).attr('class') !== ('lSNext')) {
767
+ startCoords = (settings.vertical === true) ? e.pageY : e.pageX;
768
+ isDraging = true;
769
+ if (e.preventDefault) {
770
+ e.preventDefault();
771
+ } else {
772
+ e.returnValue = false;
773
+ }
774
+ // ** Fix for webkit cursor issue https://code.google.com/p/chromium/issues/detail?id=26723
775
+ $slide.scrollLeft += 1;
776
+ $slide.scrollLeft -= 1;
777
+ // *
778
+ $slide.find('.lightSlider').removeClass('lsGrab').addClass('lsGrabbing');
779
+ clearInterval(interval);
780
+ }
781
+ });
782
+ $(window).on('mousemove', function (e) {
783
+ if (isDraging) {
784
+ endCoords = (settings.vertical === true) ? e.pageY : e.pageX;
785
+ $this.touchMove(endCoords, startCoords);
786
+ }
787
+ });
788
+ $(window).on('mouseup', function (e) {
789
+ if (isDraging) {
790
+ $slide.find('.lightSlider').removeClass('lsGrabbing').addClass('lsGrab');
791
+ isDraging = false;
792
+ endCoords = (settings.vertical === true) ? e.pageY : e.pageX;
793
+ var distance = endCoords - startCoords;
794
+ if (Math.abs(distance) >= settings.swipeThreshold) {
795
+ $(window).on('click.ls', function (e) {
796
+ if (e.preventDefault) {
797
+ e.preventDefault();
798
+ } else {
799
+ e.returnValue = false;
800
+ }
801
+ e.stopImmediatePropagation();
802
+ e.stopPropagation();
803
+ $(window).off('click.ls');
804
+ });
805
+ }
806
+
807
+ $this.touchEnd(distance);
808
+
809
+ }
810
+ });
811
+ }
812
+ },
813
+
814
+
815
+
816
+
817
+ enableTouch: function () {
818
+ var $this = this;
819
+ if (isTouch) {
820
+ var startCoords = {},
821
+ endCoords = {};
822
+ $slide.on('touchstart', function (e) {
823
+ endCoords = e.originalEvent.targetTouches[0];
824
+ startCoords.pageX = e.originalEvent.targetTouches[0].pageX;
825
+ startCoords.pageY = e.originalEvent.targetTouches[0].pageY;
826
+ clearInterval(interval);
827
+ });
828
+ $slide.on('touchmove', function (e) {
829
+ if (w < elSize) {
830
+ if (w !== 0) {
831
+ return false;
832
+ }
833
+ }
834
+ var orig = e.originalEvent;
835
+ endCoords = orig.targetTouches[0];
836
+ var xMovement = Math.abs(endCoords.pageX - startCoords.pageX);
837
+ var yMovement = Math.abs(endCoords.pageY - startCoords.pageY);
838
+ if (settings.vertical === true) {
839
+ if ((yMovement * 3) > xMovement) {
840
+ e.preventDefault();
841
+ }
842
+ $this.touchMove(endCoords.pageY, startCoords.pageY);
843
+ } else {
844
+ if ((xMovement * 3) > yMovement) {
845
+ e.preventDefault();
846
+ }
847
+ $this.touchMove(endCoords.pageX, startCoords.pageX);
848
+ }
849
+
850
+ });
851
+ $slide.on('touchend', function () {
852
+ if (w < elSize) {
853
+ if (w !== 0) {
854
+ return false;
855
+ }
856
+ }
857
+ var distance;
858
+ if (settings.vertical === true) {
859
+ distance = endCoords.pageY - startCoords.pageY;
860
+ } else {
861
+ distance = endCoords.pageX - startCoords.pageX;
862
+ }
863
+ $this.touchEnd(distance);
864
+ });
865
+ }
866
+ },
867
+ build: function () {
868
+ var $this = this;
869
+ $this.initialStyle();
870
+ if (this.doCss()) {
871
+
872
+ if (settings.enableTouch === true) {
873
+ $this.enableTouch();
874
+ }
875
+ if (settings.enableDrag === true) {
876
+ $this.enableDrag();
877
+ }
878
+ }
879
+
880
+ $(window).on('focus', function(){
881
+ $this.auto();
882
+ });
883
+
884
+ $(window).on('blur', function(){
885
+ clearInterval(interval);
886
+ });
887
+
888
+ $this.pager();
889
+ $this.pauseOnHover();
890
+ $this.controls();
891
+ $this.keyPress();
892
+ }
893
+ };
894
+ plugin.build();
895
+ refresh.init = function () {
896
+ refresh.chbreakpoint();
897
+ if (settings.vertical === true) {
898
+ if (settings.item > 1) {
899
+ elSize = settings.verticalHeight;
900
+ } else {
901
+ elSize = $children.outerHeight();
902
+ }
903
+ $slide.css('height', elSize + 'px');
904
+ } else {
905
+ elSize = $slide.outerWidth();
906
+ }
907
+ if (settings.loop === true && settings.mode === 'slide') {
908
+ refresh.clone();
909
+ }
910
+ refresh.calL();
911
+ if (settings.mode === 'slide') {
912
+ $el.removeClass('lSSlide');
913
+ }
914
+ if (settings.mode === 'slide') {
915
+ refresh.calSW();
916
+ refresh.sSW();
917
+ }
918
+ setTimeout(function () {
919
+ if (settings.mode === 'slide') {
920
+ $el.addClass('lSSlide');
921
+ }
922
+ }, 1000);
923
+ if (settings.pager) {
924
+ refresh.createPager();
925
+ }
926
+ if (settings.adaptiveHeight === true && settings.vertical === false) {
927
+ $el.css('height', $children.eq(scene).outerHeight(true));
928
+ }
929
+ if (settings.adaptiveHeight === false) {
930
+ if (settings.mode === 'slide') {
931
+ if (settings.vertical === false) {
932
+ plugin.setHeight($el, false);
933
+ }else{
934
+ plugin.auto();
935
+ }
936
+ } else {
937
+ plugin.setHeight($el, true);
938
+ }
939
+ }
940
+ if (settings.gallery === true) {
941
+ plugin.slideThumb();
942
+ }
943
+ if (settings.mode === 'slide') {
944
+ plugin.slide();
945
+ }
946
+ if (settings.autoWidth === false) {
947
+ if ($children.length <= settings.item) {
948
+ $slide.find('.lSAction').hide();
949
+ } else {
950
+ $slide.find('.lSAction').show();
951
+ }
952
+ } else {
953
+ if ((refresh.calWidth(false) < elSize) && (w !== 0)) {
954
+ $slide.find('.lSAction').hide();
955
+ } else {
956
+ $slide.find('.lSAction').show();
957
+ }
958
+ }
959
+ };
960
+ $el.goToPrevSlide = function () {
961
+ if (scene > 0) {
962
+ settings.onBeforePrevSlide.call(this, $el, scene);
963
+ scene--;
964
+ $el.mode(false);
965
+ if (settings.gallery === true) {
966
+ plugin.slideThumb();
967
+ }
968
+ } else {
969
+ if (settings.loop === true) {
970
+ settings.onBeforePrevSlide.call(this, $el, scene);
971
+ if (settings.mode === 'fade') {
972
+ var l = (length - 1);
973
+ scene = parseInt(l / settings.slideMove);
974
+ }
975
+ $el.mode(false);
976
+ if (settings.gallery === true) {
977
+ plugin.slideThumb();
978
+ }
979
+ } else if (settings.slideEndAnimation === true) {
980
+ $el.addClass('leftEnd');
981
+ setTimeout(function () {
982
+ $el.removeClass('leftEnd');
983
+ }, 400);
984
+ }
985
+ }
986
+ };
987
+ $el.goToNextSlide = function () {
988
+ var nextI = true;
989
+ if (settings.mode === 'slide') {
990
+ var _slideValue = plugin.slideValue();
991
+ nextI = _slideValue < w - elSize - settings.slideMargin;
992
+ }
993
+ if (((scene * settings.slideMove) < length - settings.slideMove) && nextI) {
994
+ settings.onBeforeNextSlide.call(this, $el, scene);
995
+ scene++;
996
+ $el.mode(false);
997
+ if (settings.gallery === true) {
998
+ plugin.slideThumb();
999
+ }
1000
+ } else {
1001
+ if (settings.loop === true) {
1002
+ settings.onBeforeNextSlide.call(this, $el, scene);
1003
+ scene = 0;
1004
+ $el.mode(false);
1005
+ if (settings.gallery === true) {
1006
+ plugin.slideThumb();
1007
+ }
1008
+ } else if (settings.slideEndAnimation === true) {
1009
+ $el.addClass('rightEnd');
1010
+ setTimeout(function () {
1011
+ $el.removeClass('rightEnd');
1012
+ }, 400);
1013
+ }
1014
+ }
1015
+ };
1016
+ $el.mode = function (_touch) {
1017
+ if (settings.adaptiveHeight === true && settings.vertical === false) {
1018
+ $el.css('height', $children.eq(scene).outerHeight(true));
1019
+ }
1020
+ if (on === false) {
1021
+ if (settings.mode === 'slide') {
1022
+ if (plugin.doCss()) {
1023
+ $el.addClass('lSSlide');
1024
+ if (settings.speed !== '') {
1025
+ $slide.css('transition-duration', settings.speed + 'ms');
1026
+ }
1027
+ if (settings.cssEasing !== '') {
1028
+ $slide.css('transition-timing-function', settings.cssEasing);
1029
+ }
1030
+ }
1031
+ } else {
1032
+ if (plugin.doCss()) {
1033
+ if (settings.speed !== '') {
1034
+ $el.css('transition-duration', settings.speed + 'ms');
1035
+ }
1036
+ if (settings.cssEasing !== '') {
1037
+ $el.css('transition-timing-function', settings.cssEasing);
1038
+ }
1039
+ }
1040
+ }
1041
+ }
1042
+ if (!_touch) {
1043
+ settings.onBeforeSlide.call(this, $el, scene);
1044
+ }
1045
+ if (settings.mode === 'slide') {
1046
+ plugin.slide();
1047
+ } else {
1048
+ plugin.fade();
1049
+ }
1050
+ if (!$slide.hasClass('ls-hover')) {
1051
+ plugin.auto();
1052
+ }
1053
+ setTimeout(function () {
1054
+ if (!_touch) {
1055
+ settings.onAfterSlide.call(this, $el, scene);
1056
+ }
1057
+ }, settings.speed);
1058
+ on = true;
1059
+ };
1060
+ $el.play = function () {
1061
+ $el.goToNextSlide();
1062
+ settings.auto = true;
1063
+ plugin.auto();
1064
+ };
1065
+ $el.pause = function () {
1066
+ settings.auto = false;
1067
+ clearInterval(interval);
1068
+ };
1069
+ $el.refresh = function () {
1070
+ refresh.init();
1071
+ };
1072
+ $el.getCurrentSlideCount = function () {
1073
+ var sc = scene;
1074
+ if (settings.loop) {
1075
+ var ln = $slide.find('.lslide').length,
1076
+ cl = $el.find('.clone.left').length;
1077
+ if (scene <= cl - 1) {
1078
+ sc = ln + (scene - cl);
1079
+ } else if (scene >= (ln + cl)) {
1080
+ sc = scene - ln - cl;
1081
+ } else {
1082
+ sc = scene - cl;
1083
+ }
1084
+ }
1085
+ return sc + 1;
1086
+ };
1087
+ $el.getTotalSlideCount = function () {
1088
+ return $slide.find('.lslide').length;
1089
+ };
1090
+ $el.goToSlide = function (s) {
1091
+ if (settings.loop) {
1092
+ scene = (s + $el.find('.clone.left').length - 1);
1093
+ } else {
1094
+ scene = s;
1095
+ }
1096
+ $el.mode(false);
1097
+ if (settings.gallery === true) {
1098
+ plugin.slideThumb();
1099
+ }
1100
+ };
1101
+ $el.destroy = function () {
1102
+ if ($el.lightSlider) {
1103
+ $el.goToPrevSlide = function(){};
1104
+ $el.goToNextSlide = function(){};
1105
+ $el.mode = function(){};
1106
+ $el.play = function(){};
1107
+ $el.pause = function(){};
1108
+ $el.refresh = function(){};
1109
+ $el.getCurrentSlideCount = function(){};
1110
+ $el.getTotalSlideCount = function(){};
1111
+ $el.goToSlide = function(){};
1112
+ $el.lightSlider = null;
1113
+ refresh = {
1114
+ init : function(){}
1115
+ };
1116
+ $el.parent().parent().find('.lSAction, .lSPager').remove();
1117
+ $el.removeClass('lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right').removeAttr('style').unwrap().unwrap();
1118
+ $el.children().removeAttr('style');
1119
+ $children.removeClass('lslide active');
1120
+ $el.find('.clone').remove();
1121
+ $children = null;
1122
+ interval = null;
1123
+ on = false;
1124
+ scene = 0;
1125
+ }
1126
+
1127
+ };
1128
+ setTimeout(function () {
1129
+ settings.onSliderLoad.call(this, $el);
1130
+ }, 10);
1131
+ $(window).on('resize orientationchange', function (e) {
1132
+ setTimeout(function () {
1133
+ if (e.preventDefault) {
1134
+ e.preventDefault();
1135
+ } else {
1136
+ e.returnValue = false;
1137
+ }
1138
+ refresh.init();
1139
+ }, 200);
1140
+ });
1141
+ return this;
1142
+ };
1143
+ }(jQuery));
slider/js/lightslider.min.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! lightslider - v1.1.6 - 2016-10-25
2
- * https://github.com/sachinchoolur/lightslider
3
- * Copyright (c) 2016 Sachin N; Licensed MIT */
4
  !function(a,b){"use strict";var c={item:3,autoWidth:!1,slideMove:1,slideMargin:10,addClass:"",mode:"slide",useCSS:!0,cssEasing:"ease",easing:"linear",speed:400,auto:!1,pauseOnHover:!1,loop:!1,slideEndAnimation:!0,pause:2e3,keyPress:!1,controls:!0,prevHtml:"",nextHtml:"",rtl:!1,adaptiveHeight:!1,vertical:!1,verticalHeight:500,vThumbWidth:100,thumbItem:10,pager:!0,gallery:!1,galleryMargin:5,thumbMargin:5,currentPagerPosition:"middle",enableTouch:!0,enableDrag:!0,freeMove:!0,swipeThreshold:40,responsive:[],onBeforeStart:function(a){},onSliderLoad:function(a){},onBeforeSlide:function(a,b){},onAfterSlide:function(a,b){},onBeforeNextSlide:function(a,b){},onBeforePrevSlide:function(a,b){}};a.fn.lightSlider=function(b){if(0===this.length)return this;if(this.length>1)return this.each(function(){a(this).lightSlider(b)}),this;var d={},e=a.extend(!0,{},c,b),f={},g=this;d.$el=this,"fade"===e.mode&&(e.vertical=!1);var h=g.children(),i=a(window).width(),j=null,k=null,l=0,m=0,n=!1,o=0,p="",q=0,r=e.vertical===!0?"height":"width",s=e.vertical===!0?"margin-bottom":"margin-right",t=0,u=0,v=0,w=0,x=null,y="ontouchstart"in document.documentElement,z={};return z.chbreakpoint=function(){if(i=a(window).width(),e.responsive.length){var b;if(e.autoWidth===!1&&(b=e.item),i<e.responsive[0].breakpoint)for(var c=0;c<e.responsive.length;c++)i<e.responsive[c].breakpoint&&(j=e.responsive[c].breakpoint,k=e.responsive[c]);if("undefined"!=typeof k&&null!==k)for(var d in k.settings)k.settings.hasOwnProperty(d)&&(("undefined"==typeof f[d]||null===f[d])&&(f[d]=e[d]),e[d]=k.settings[d]);if(!a.isEmptyObject(f)&&i>e.responsive[0].breakpoint)for(var g in f)f.hasOwnProperty(g)&&(e[g]=f[g]);e.autoWidth===!1&&t>0&&v>0&&b!==e.item&&(q=Math.round(t/((v+e.slideMargin)*e.slideMove)))}},z.calSW=function(){e.autoWidth===!1&&(v=(o-(e.item*e.slideMargin-e.slideMargin))/e.item)},z.calWidth=function(a){var b=a===!0?p.find(".lslide").length:h.length;if(e.autoWidth===!1)m=b*(v+e.slideMargin);else{m=0;for(var c=0;b>c;c++)m+=parseInt(h.eq(c).width())+e.slideMargin}return m},d={doCss:function(){var a=function(){for(var a=["transition","MozTransition","WebkitTransition","OTransition","msTransition","KhtmlTransition"],b=document.documentElement,c=0;c<a.length;c++)if(a[c]in b.style)return!0};return e.useCSS&&a()?!0:!1},keyPress:function(){e.keyPress&&a(document).on("keyup.lightslider",function(b){a(":focus").is("input, textarea")||(b.preventDefault?b.preventDefault():b.returnValue=!1,37===b.keyCode?g.goToPrevSlide():39===b.keyCode&&g.goToNextSlide())})},controls:function(){e.controls&&(g.after('<div class="lSAction"><a class="lSPrev">'+e.prevHtml+'</a><a class="lSNext">'+e.nextHtml+"</a></div>"),e.autoWidth?z.calWidth(!1)<o&&p.find(".lSAction").hide():l<=e.item&&p.find(".lSAction").hide(),p.find(".lSAction a").on("click",function(b){return b.preventDefault?b.preventDefault():b.returnValue=!1,"lSPrev"===a(this).attr("class")?g.goToPrevSlide():g.goToNextSlide(),!1}))},initialStyle:function(){var a=this;"fade"===e.mode&&(e.autoWidth=!1,e.slideEndAnimation=!1),e.auto&&(e.slideEndAnimation=!1),e.autoWidth&&(e.slideMove=1,e.item=1),e.loop&&(e.slideMove=1,e.freeMove=!1),e.onBeforeStart.call(this,g),z.chbreakpoint(),g.addClass("lightSlider").wrap('<div class="lSSlideOuter '+e.addClass+'"><div class="lSSlideWrapper"></div></div>'),p=g.parent(".lSSlideWrapper"),e.rtl===!0&&p.parent().addClass("lSrtl"),e.vertical?(p.parent().addClass("vertical"),o=e.verticalHeight,p.css("height",o+"px")):o=g.outerWidth(),h.addClass("lslide"),e.loop===!0&&"slide"===e.mode&&(z.calSW(),z.clone=function(){if(z.calWidth(!0)>o){for(var b=0,c=0,d=0;d<h.length&&(b+=parseInt(g.find(".lslide").eq(d).width())+e.slideMargin,c++,!(b>=o+e.slideMargin));d++);var f=e.autoWidth===!0?c:e.item;if(f<g.find(".clone.left").length)for(var i=0;i<g.find(".clone.left").length-f;i++)h.eq(i).remove();if(f<g.find(".clone.right").length)for(var j=h.length-1;j>h.length-1-g.find(".clone.right").length;j--)q--,h.eq(j).remove();for(var k=g.find(".clone.right").length;f>k;k++)g.find(".lslide").eq(k).clone().removeClass("lslide").addClass("clone right").appendTo(g),q++;for(var l=g.find(".lslide").length-g.find(".clone.left").length;l>g.find(".lslide").length-f;l--)g.find(".lslide").eq(l-1).clone().removeClass("lslide").addClass("clone left").prependTo(g);h=g.children()}else h.hasClass("clone")&&(g.find(".clone").remove(),a.move(g,0))},z.clone()),z.sSW=function(){l=h.length,e.rtl===!0&&e.vertical===!1&&(s="margin-left"),e.autoWidth===!1&&h.css(r,v+"px"),h.css(s,e.slideMargin+"px"),m=z.calWidth(!1),g.css(r,m+"px"),e.loop===!0&&"slide"===e.mode&&n===!1&&(q=g.find(".clone.left").length)},z.calL=function(){h=g.children(),l=h.length},this.doCss()&&p.addClass("usingCss"),z.calL(),"slide"===e.mode?(z.calSW(),z.sSW(),e.loop===!0&&(t=a.slideValue(),this.move(g,t)),e.vertical===!1&&this.setHeight(g,!1)):(this.setHeight(g,!0),g.addClass("lSFade"),this.doCss()||(h.fadeOut(0),h.eq(q).fadeIn(0))),e.loop===!0&&"slide"===e.mode?h.eq(q).addClass("active"):h.first().addClass("active")},pager:function(){var a=this;if(z.createPager=function(){w=(o-(e.thumbItem*e.thumbMargin-e.thumbMargin))/e.thumbItem;var b=p.find(".lslide"),c=p.find(".lslide").length,d=0,f="",h=0;for(d=0;c>d;d++){"slide"===e.mode&&(e.autoWidth?h+=(parseInt(b.eq(d).width())+e.slideMargin)*e.slideMove:h=d*(v+e.slideMargin)*e.slideMove);var i=b.eq(d*e.slideMove).attr("data-thumb");if(f+=e.gallery===!0?'<li style="width:100%;'+r+":"+w+"px;"+s+":"+e.thumbMargin+'px"><a href="#"><img src="'+i+'" /></a></li>':'<li><a href="#">'+(d+1)+"</a></li>","slide"===e.mode&&h>=m-o-e.slideMargin){d+=1;var j=2;e.autoWidth&&(f+='<li><a href="#">'+(d+1)+"</a></li>",j=1),j>d?(f=null,p.parent().addClass("noPager")):p.parent().removeClass("noPager");break}}var k=p.parent();k.find(".lSPager").html(f),e.gallery===!0&&(e.vertical===!0&&k.find(".lSPager").css("width",e.vThumbWidth+"px"),u=d*(e.thumbMargin+w)+.5,k.find(".lSPager").css({property:u+"px","transition-duration":e.speed+"ms"}),e.vertical===!0&&p.parent().css("padding-right",e.vThumbWidth+e.galleryMargin+"px"),k.find(".lSPager").css(r,u+"px"));var l=k.find(".lSPager").find("li");l.first().addClass("active"),l.on("click",function(){return e.loop===!0&&"slide"===e.mode?q+=l.index(this)-k.find(".lSPager").find("li.active").index():q=l.index(this),g.mode(!1),e.gallery===!0&&a.slideThumb(),!1})},e.pager){var b="lSpg";e.gallery&&(b="lSGallery"),p.after('<ul class="lSPager '+b+'"></ul>');var c=e.vertical?"margin-left":"margin-top";p.parent().find(".lSPager").css(c,e.galleryMargin+"px"),z.createPager()}setTimeout(function(){z.init()},0)},setHeight:function(a,b){var c=null,d=this;c=e.loop?a.children(".lslide ").first():a.children().first();var f=function(){var d=c.outerHeight(),e=0,f=d;b&&(d=0,e=100*f/o),a.css({height:d+"px","padding-bottom":e+"%"})};f(),c.find("img").length?c.find("img")[0].complete?(f(),x||d.auto()):c.find("img").on("load",function(){setTimeout(function(){f(),x||d.auto()},100)}):x||d.auto()},active:function(a,b){this.doCss()&&"fade"===e.mode&&p.addClass("on");var c=0;if(q*e.slideMove<l){a.removeClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||a.fadeOut(e.speed),c=b===!0?q:q*e.slideMove;var d,f;b===!0&&(d=a.length,f=d-1,c+1>=d&&(c=f)),e.loop===!0&&"slide"===e.mode&&(c=b===!0?q-g.find(".clone.left").length:q*e.slideMove,b===!0&&(d=a.length,f=d-1,c+1===d?c=f:c+1>d&&(c=0))),this.doCss()||"fade"!==e.mode||b!==!1||a.eq(c).fadeIn(e.speed),a.eq(c).addClass("active")}else a.removeClass("active"),a.eq(a.length-1).addClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||(a.fadeOut(e.speed),a.eq(c).fadeIn(e.speed))},move:function(a,b){e.rtl===!0&&(b=-b),this.doCss()?a.css(e.vertical===!0?{transform:"translate3d(0px, "+-b+"px, 0px)","-webkit-transform":"translate3d(0px, "+-b+"px, 0px)"}:{transform:"translate3d("+-b+"px, 0px, 0px)","-webkit-transform":"translate3d("+-b+"px, 0px, 0px)"}):e.vertical===!0?a.css("position","relative").animate({top:-b+"px"},e.speed,e.easing):a.css("position","relative").animate({left:-b+"px"},e.speed,e.easing);var c=p.parent().find(".lSPager").find("li");this.active(c,!0)},fade:function(){this.active(h,!1);var a=p.parent().find(".lSPager").find("li");this.active(a,!0)},slide:function(){var a=this;z.calSlide=function(){m>o&&(t=a.slideValue(),a.active(h,!1),t>m-o-e.slideMargin?t=m-o-e.slideMargin:0>t&&(t=0),a.move(g,t),e.loop===!0&&"slide"===e.mode&&(q>=l-g.find(".clone.left").length/e.slideMove&&a.resetSlide(g.find(".clone.left").length),0===q&&a.resetSlide(p.find(".lslide").length)))},z.calSlide()},resetSlide:function(a){var b=this;p.find(".lSAction a").addClass("disabled"),setTimeout(function(){q=a,p.css("transition-duration","0ms"),t=b.slideValue(),b.active(h,!1),d.move(g,t),setTimeout(function(){p.css("transition-duration",e.speed+"ms"),p.find(".lSAction a").removeClass("disabled")},50)},e.speed+100)},slideValue:function(){var a=0;if(e.autoWidth===!1)a=q*(v+e.slideMargin)*e.slideMove;else{a=0;for(var b=0;q>b;b++)a+=parseInt(h.eq(b).width())+e.slideMargin}return a},slideThumb:function(){var a;switch(e.currentPagerPosition){case"left":a=0;break;case"middle":a=o/2-w/2;break;case"right":a=o-w}var b=q-g.find(".clone.left").length,c=p.parent().find(".lSPager");"slide"===e.mode&&e.loop===!0&&(b>=c.children().length?b=0:0>b&&(b=c.children().length));var d=b*(w+e.thumbMargin)-a;d+o>u&&(d=u-o-e.thumbMargin),0>d&&(d=0),this.move(c,d)},auto:function(){e.auto&&(clearInterval(x),x=setInterval(function(){g.goToNextSlide()},e.pause))},pauseOnHover:function(){var b=this;e.auto&&e.pauseOnHover&&(p.on("mouseenter",function(){a(this).addClass("ls-hover"),g.pause(),e.auto=!0}),p.on("mouseleave",function(){a(this).removeClass("ls-hover"),p.find(".lightSlider").hasClass("lsGrabbing")||b.auto()}))},touchMove:function(a,b){if(p.css("transition-duration","0ms"),"slide"===e.mode){var c=a-b,d=t-c;if(d>=m-o-e.slideMargin)if(e.freeMove===!1)d=m-o-e.slideMargin;else{var f=m-o-e.slideMargin;d=f+(d-f)/5}else 0>d&&(e.freeMove===!1?d=0:d/=5);this.move(g,d)}},touchEnd:function(a){if(p.css("transition-duration",e.speed+"ms"),"slide"===e.mode){var b=!1,c=!0;t-=a,t>m-o-e.slideMargin?(t=m-o-e.slideMargin,e.autoWidth===!1&&(b=!0)):0>t&&(t=0);var d=function(a){var c=0;if(b||a&&(c=1),e.autoWidth)for(var d=0,f=0;f<h.length&&(d+=parseInt(h.eq(f).width())+e.slideMargin,q=f+c,!(d>=t));f++);else{var g=t/((v+e.slideMargin)*e.slideMove);q=parseInt(g)+c,t>=m-o-e.slideMargin&&g%1!==0&&q++}};a>=e.swipeThreshold?(d(!1),c=!1):a<=-e.swipeThreshold&&(d(!0),c=!1),g.mode(c),this.slideThumb()}else a>=e.swipeThreshold?g.goToPrevSlide():a<=-e.swipeThreshold&&g.goToNextSlide()},enableDrag:function(){var b=this;if(!y){var c=0,d=0,f=!1;p.find(".lightSlider").addClass("lsGrab"),p.on("mousedown",function(b){return o>m&&0!==m?!1:void("lSPrev"!==a(b.target).attr("class")&&"lSNext"!==a(b.target).attr("class")&&(c=e.vertical===!0?b.pageY:b.pageX,f=!0,b.preventDefault?b.preventDefault():b.returnValue=!1,p.scrollLeft+=1,p.scrollLeft-=1,p.find(".lightSlider").removeClass("lsGrab").addClass("lsGrabbing"),clearInterval(x)))}),a(window).on("mousemove",function(a){f&&(d=e.vertical===!0?a.pageY:a.pageX,b.touchMove(d,c))}),a(window).on("mouseup",function(g){if(f){p.find(".lightSlider").removeClass("lsGrabbing").addClass("lsGrab"),f=!1,d=e.vertical===!0?g.pageY:g.pageX;var h=d-c;Math.abs(h)>=e.swipeThreshold&&a(window).on("click.ls",function(b){b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopImmediatePropagation(),b.stopPropagation(),a(window).off("click.ls")}),b.touchEnd(h)}})}},enableTouch:function(){var a=this;if(y){var b={},c={};p.on("touchstart",function(a){c=a.originalEvent.targetTouches[0],b.pageX=a.originalEvent.targetTouches[0].pageX,b.pageY=a.originalEvent.targetTouches[0].pageY,clearInterval(x)}),p.on("touchmove",function(d){if(o>m&&0!==m)return!1;var f=d.originalEvent;c=f.targetTouches[0];var g=Math.abs(c.pageX-b.pageX),h=Math.abs(c.pageY-b.pageY);e.vertical===!0?(3*h>g&&d.preventDefault(),a.touchMove(c.pageY,b.pageY)):(3*g>h&&d.preventDefault(),a.touchMove(c.pageX,b.pageX))}),p.on("touchend",function(){if(o>m&&0!==m)return!1;var d;d=e.vertical===!0?c.pageY-b.pageY:c.pageX-b.pageX,a.touchEnd(d)})}},build:function(){var b=this;b.initialStyle(),this.doCss()&&(e.enableTouch===!0&&b.enableTouch(),e.enableDrag===!0&&b.enableDrag()),a(window).on("focus",function(){b.auto()}),a(window).on("blur",function(){clearInterval(x)}),b.pager(),b.pauseOnHover(),b.controls(),b.keyPress()}},d.build(),z.init=function(){z.chbreakpoint(),e.vertical===!0?(o=e.item>1?e.verticalHeight:h.outerHeight(),p.css("height",o+"px")):o=p.outerWidth(),e.loop===!0&&"slide"===e.mode&&z.clone(),z.calL(),"slide"===e.mode&&g.removeClass("lSSlide"),"slide"===e.mode&&(z.calSW(),z.sSW()),setTimeout(function(){"slide"===e.mode&&g.addClass("lSSlide")},1e3),e.pager&&z.createPager(),e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),e.adaptiveHeight===!1&&("slide"===e.mode?e.vertical===!1?d.setHeight(g,!1):d.auto():d.setHeight(g,!0)),e.gallery===!0&&d.slideThumb(),"slide"===e.mode&&d.slide(),e.autoWidth===!1?h.length<=e.item?p.find(".lSAction").hide():p.find(".lSAction").show():z.calWidth(!1)<o&&0!==m?p.find(".lSAction").hide():p.find(".lSAction").show()},g.goToPrevSlide=function(){if(q>0)e.onBeforePrevSlide.call(this,g,q),q--,g.mode(!1),e.gallery===!0&&d.slideThumb();else if(e.loop===!0){if(e.onBeforePrevSlide.call(this,g,q),"fade"===e.mode){var a=l-1;q=parseInt(a/e.slideMove)}g.mode(!1),e.gallery===!0&&d.slideThumb()}else e.slideEndAnimation===!0&&(g.addClass("leftEnd"),setTimeout(function(){g.removeClass("leftEnd")},400))},g.goToNextSlide=function(){var a=!0;if("slide"===e.mode){var b=d.slideValue();a=b<m-o-e.slideMargin}q*e.slideMove<l-e.slideMove&&a?(e.onBeforeNextSlide.call(this,g,q),q++,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.loop===!0?(e.onBeforeNextSlide.call(this,g,q),q=0,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.slideEndAnimation===!0&&(g.addClass("rightEnd"),setTimeout(function(){g.removeClass("rightEnd")},400))},g.mode=function(a){e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),n===!1&&("slide"===e.mode?d.doCss()&&(g.addClass("lSSlide"),""!==e.speed&&p.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&p.css("transition-timing-function",e.cssEasing)):d.doCss()&&(""!==e.speed&&g.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&g.css("transition-timing-function",e.cssEasing))),a||e.onBeforeSlide.call(this,g,q),"slide"===e.mode?d.slide():d.fade(),p.hasClass("ls-hover")||d.auto(),setTimeout(function(){a||e.onAfterSlide.call(this,g,q)},e.speed),n=!0},g.play=function(){g.goToNextSlide(),e.auto=!0,d.auto()},g.pause=function(){e.auto=!1,clearInterval(x)},g.refresh=function(){z.init()},g.getCurrentSlideCount=function(){var a=q;if(e.loop){var b=p.find(".lslide").length,c=g.find(".clone.left").length;a=c-1>=q?b+(q-c):q>=b+c?q-b-c:q-c}return a+1},g.getTotalSlideCount=function(){return p.find(".lslide").length},g.goToSlide=function(a){q=e.loop?a+g.find(".clone.left").length-1:a,g.mode(!1),e.gallery===!0&&d.slideThumb()},g.destroy=function(){g.lightSlider&&(g.goToPrevSlide=function(){},g.goToNextSlide=function(){},g.mode=function(){},g.play=function(){},g.pause=function(){},g.refresh=function(){},g.getCurrentSlideCount=function(){},g.getTotalSlideCount=function(){},g.goToSlide=function(){},g.lightSlider=null,z={init:function(){}},g.parent().parent().find(".lSAction, .lSPager").remove(),g.removeClass("lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right").removeAttr("style").unwrap().unwrap(),g.children().removeAttr("style"),h.removeClass("lslide active"),g.find(".clone").remove(),h=null,x=null,n=!1,q=0)},setTimeout(function(){e.onSliderLoad.call(this,g)},10),a(window).on("resize orientationchange",function(a){setTimeout(function(){a.preventDefault?a.preventDefault():a.returnValue=!1,z.init()},200)}),this}}(jQuery);
1
+ /*! lightslider - v1.1.6 - 2016-10-25
2
+ * https://github.com/sachinchoolur/lightslider
3
+ * Copyright (c) 2016 Sachin N; Licensed MIT */
4
  !function(a,b){"use strict";var c={item:3,autoWidth:!1,slideMove:1,slideMargin:10,addClass:"",mode:"slide",useCSS:!0,cssEasing:"ease",easing:"linear",speed:400,auto:!1,pauseOnHover:!1,loop:!1,slideEndAnimation:!0,pause:2e3,keyPress:!1,controls:!0,prevHtml:"",nextHtml:"",rtl:!1,adaptiveHeight:!1,vertical:!1,verticalHeight:500,vThumbWidth:100,thumbItem:10,pager:!0,gallery:!1,galleryMargin:5,thumbMargin:5,currentPagerPosition:"middle",enableTouch:!0,enableDrag:!0,freeMove:!0,swipeThreshold:40,responsive:[],onBeforeStart:function(a){},onSliderLoad:function(a){},onBeforeSlide:function(a,b){},onAfterSlide:function(a,b){},onBeforeNextSlide:function(a,b){},onBeforePrevSlide:function(a,b){}};a.fn.lightSlider=function(b){if(0===this.length)return this;if(this.length>1)return this.each(function(){a(this).lightSlider(b)}),this;var d={},e=a.extend(!0,{},c,b),f={},g=this;d.$el=this,"fade"===e.mode&&(e.vertical=!1);var h=g.children(),i=a(window).width(),j=null,k=null,l=0,m=0,n=!1,o=0,p="",q=0,r=e.vertical===!0?"height":"width",s=e.vertical===!0?"margin-bottom":"margin-right",t=0,u=0,v=0,w=0,x=null,y="ontouchstart"in document.documentElement,z={};return z.chbreakpoint=function(){if(i=a(window).width(),e.responsive.length){var b;if(e.autoWidth===!1&&(b=e.item),i<e.responsive[0].breakpoint)for(var c=0;c<e.responsive.length;c++)i<e.responsive[c].breakpoint&&(j=e.responsive[c].breakpoint,k=e.responsive[c]);if("undefined"!=typeof k&&null!==k)for(var d in k.settings)k.settings.hasOwnProperty(d)&&(("undefined"==typeof f[d]||null===f[d])&&(f[d]=e[d]),e[d]=k.settings[d]);if(!a.isEmptyObject(f)&&i>e.responsive[0].breakpoint)for(var g in f)f.hasOwnProperty(g)&&(e[g]=f[g]);e.autoWidth===!1&&t>0&&v>0&&b!==e.item&&(q=Math.round(t/((v+e.slideMargin)*e.slideMove)))}},z.calSW=function(){e.autoWidth===!1&&(v=(o-(e.item*e.slideMargin-e.slideMargin))/e.item)},z.calWidth=function(a){var b=a===!0?p.find(".lslide").length:h.length;if(e.autoWidth===!1)m=b*(v+e.slideMargin);else{m=0;for(var c=0;b>c;c++)m+=parseInt(h.eq(c).width())+e.slideMargin}return m},d={doCss:function(){var a=function(){for(var a=["transition","MozTransition","WebkitTransition","OTransition","msTransition","KhtmlTransition"],b=document.documentElement,c=0;c<a.length;c++)if(a[c]in b.style)return!0};return e.useCSS&&a()?!0:!1},keyPress:function(){e.keyPress&&a(document).on("keyup.lightslider",function(b){a(":focus").is("input, textarea")||(b.preventDefault?b.preventDefault():b.returnValue=!1,37===b.keyCode?g.goToPrevSlide():39===b.keyCode&&g.goToNextSlide())})},controls:function(){e.controls&&(g.after('<div class="lSAction"><a class="lSPrev">'+e.prevHtml+'</a><a class="lSNext">'+e.nextHtml+"</a></div>"),e.autoWidth?z.calWidth(!1)<o&&p.find(".lSAction").hide():l<=e.item&&p.find(".lSAction").hide(),p.find(".lSAction a").on("click",function(b){return b.preventDefault?b.preventDefault():b.returnValue=!1,"lSPrev"===a(this).attr("class")?g.goToPrevSlide():g.goToNextSlide(),!1}))},initialStyle:function(){var a=this;"fade"===e.mode&&(e.autoWidth=!1,e.slideEndAnimation=!1),e.auto&&(e.slideEndAnimation=!1),e.autoWidth&&(e.slideMove=1,e.item=1),e.loop&&(e.slideMove=1,e.freeMove=!1),e.onBeforeStart.call(this,g),z.chbreakpoint(),g.addClass("lightSlider").wrap('<div class="lSSlideOuter '+e.addClass+'"><div class="lSSlideWrapper"></div></div>'),p=g.parent(".lSSlideWrapper"),e.rtl===!0&&p.parent().addClass("lSrtl"),e.vertical?(p.parent().addClass("vertical"),o=e.verticalHeight,p.css("height",o+"px")):o=g.outerWidth(),h.addClass("lslide"),e.loop===!0&&"slide"===e.mode&&(z.calSW(),z.clone=function(){if(z.calWidth(!0)>o){for(var b=0,c=0,d=0;d<h.length&&(b+=parseInt(g.find(".lslide").eq(d).width())+e.slideMargin,c++,!(b>=o+e.slideMargin));d++);var f=e.autoWidth===!0?c:e.item;if(f<g.find(".clone.left").length)for(var i=0;i<g.find(".clone.left").length-f;i++)h.eq(i).remove();if(f<g.find(".clone.right").length)for(var j=h.length-1;j>h.length-1-g.find(".clone.right").length;j--)q--,h.eq(j).remove();for(var k=g.find(".clone.right").length;f>k;k++)g.find(".lslide").eq(k).clone().removeClass("lslide").addClass("clone right").appendTo(g),q++;for(var l=g.find(".lslide").length-g.find(".clone.left").length;l>g.find(".lslide").length-f;l--)g.find(".lslide").eq(l-1).clone().removeClass("lslide").addClass("clone left").prependTo(g);h=g.children()}else h.hasClass("clone")&&(g.find(".clone").remove(),a.move(g,0))},z.clone()),z.sSW=function(){l=h.length,e.rtl===!0&&e.vertical===!1&&(s="margin-left"),e.autoWidth===!1&&h.css(r,v+"px"),h.css(s,e.slideMargin+"px"),m=z.calWidth(!1),g.css(r,m+"px"),e.loop===!0&&"slide"===e.mode&&n===!1&&(q=g.find(".clone.left").length)},z.calL=function(){h=g.children(),l=h.length},this.doCss()&&p.addClass("usingCss"),z.calL(),"slide"===e.mode?(z.calSW(),z.sSW(),e.loop===!0&&(t=a.slideValue(),this.move(g,t)),e.vertical===!1&&this.setHeight(g,!1)):(this.setHeight(g,!0),g.addClass("lSFade"),this.doCss()||(h.fadeOut(0),h.eq(q).fadeIn(0))),e.loop===!0&&"slide"===e.mode?h.eq(q).addClass("active"):h.first().addClass("active")},pager:function(){var a=this;if(z.createPager=function(){w=(o-(e.thumbItem*e.thumbMargin-e.thumbMargin))/e.thumbItem;var b=p.find(".lslide"),c=p.find(".lslide").length,d=0,f="",h=0;for(d=0;c>d;d++){"slide"===e.mode&&(e.autoWidth?h+=(parseInt(b.eq(d).width())+e.slideMargin)*e.slideMove:h=d*(v+e.slideMargin)*e.slideMove);var i=b.eq(d*e.slideMove).attr("data-thumb");if(f+=e.gallery===!0?'<li style="width:100%;'+r+":"+w+"px;"+s+":"+e.thumbMargin+'px"><a href="#"><img src="'+i+'" /></a></li>':'<li><a href="#">'+(d+1)+"</a></li>","slide"===e.mode&&h>=m-o-e.slideMargin){d+=1;var j=2;e.autoWidth&&(f+='<li><a href="#">'+(d+1)+"</a></li>",j=1),j>d?(f=null,p.parent().addClass("noPager")):p.parent().removeClass("noPager");break}}var k=p.parent();k.find(".lSPager").html(f),e.gallery===!0&&(e.vertical===!0&&k.find(".lSPager").css("width",e.vThumbWidth+"px"),u=d*(e.thumbMargin+w)+.5,k.find(".lSPager").css({property:u+"px","transition-duration":e.speed+"ms"}),e.vertical===!0&&p.parent().css("padding-right",e.vThumbWidth+e.galleryMargin+"px"),k.find(".lSPager").css(r,u+"px"));var l=k.find(".lSPager").find("li");l.first().addClass("active"),l.on("click",function(){return e.loop===!0&&"slide"===e.mode?q+=l.index(this)-k.find(".lSPager").find("li.active").index():q=l.index(this),g.mode(!1),e.gallery===!0&&a.slideThumb(),!1})},e.pager){var b="lSpg";e.gallery&&(b="lSGallery"),p.after('<ul class="lSPager '+b+'"></ul>');var c=e.vertical?"margin-left":"margin-top";p.parent().find(".lSPager").css(c,e.galleryMargin+"px"),z.createPager()}setTimeout(function(){z.init()},0)},setHeight:function(a,b){var c=null,d=this;c=e.loop?a.children(".lslide ").first():a.children().first();var f=function(){var d=c.outerHeight(),e=0,f=d;b&&(d=0,e=100*f/o),a.css({height:d+"px","padding-bottom":e+"%"})};f(),c.find("img").length?c.find("img")[0].complete?(f(),x||d.auto()):c.find("img").on("load",function(){setTimeout(function(){f(),x||d.auto()},100)}):x||d.auto()},active:function(a,b){this.doCss()&&"fade"===e.mode&&p.addClass("on");var c=0;if(q*e.slideMove<l){a.removeClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||a.fadeOut(e.speed),c=b===!0?q:q*e.slideMove;var d,f;b===!0&&(d=a.length,f=d-1,c+1>=d&&(c=f)),e.loop===!0&&"slide"===e.mode&&(c=b===!0?q-g.find(".clone.left").length:q*e.slideMove,b===!0&&(d=a.length,f=d-1,c+1===d?c=f:c+1>d&&(c=0))),this.doCss()||"fade"!==e.mode||b!==!1||a.eq(c).fadeIn(e.speed),a.eq(c).addClass("active")}else a.removeClass("active"),a.eq(a.length-1).addClass("active"),this.doCss()||"fade"!==e.mode||b!==!1||(a.fadeOut(e.speed),a.eq(c).fadeIn(e.speed))},move:function(a,b){e.rtl===!0&&(b=-b),this.doCss()?a.css(e.vertical===!0?{transform:"translate3d(0px, "+-b+"px, 0px)","-webkit-transform":"translate3d(0px, "+-b+"px, 0px)"}:{transform:"translate3d("+-b+"px, 0px, 0px)","-webkit-transform":"translate3d("+-b+"px, 0px, 0px)"}):e.vertical===!0?a.css("position","relative").animate({top:-b+"px"},e.speed,e.easing):a.css("position","relative").animate({left:-b+"px"},e.speed,e.easing);var c=p.parent().find(".lSPager").find("li");this.active(c,!0)},fade:function(){this.active(h,!1);var a=p.parent().find(".lSPager").find("li");this.active(a,!0)},slide:function(){var a=this;z.calSlide=function(){m>o&&(t=a.slideValue(),a.active(h,!1),t>m-o-e.slideMargin?t=m-o-e.slideMargin:0>t&&(t=0),a.move(g,t),e.loop===!0&&"slide"===e.mode&&(q>=l-g.find(".clone.left").length/e.slideMove&&a.resetSlide(g.find(".clone.left").length),0===q&&a.resetSlide(p.find(".lslide").length)))},z.calSlide()},resetSlide:function(a){var b=this;p.find(".lSAction a").addClass("disabled"),setTimeout(function(){q=a,p.css("transition-duration","0ms"),t=b.slideValue(),b.active(h,!1),d.move(g,t),setTimeout(function(){p.css("transition-duration",e.speed+"ms"),p.find(".lSAction a").removeClass("disabled")},50)},e.speed+100)},slideValue:function(){var a=0;if(e.autoWidth===!1)a=q*(v+e.slideMargin)*e.slideMove;else{a=0;for(var b=0;q>b;b++)a+=parseInt(h.eq(b).width())+e.slideMargin}return a},slideThumb:function(){var a;switch(e.currentPagerPosition){case"left":a=0;break;case"middle":a=o/2-w/2;break;case"right":a=o-w}var b=q-g.find(".clone.left").length,c=p.parent().find(".lSPager");"slide"===e.mode&&e.loop===!0&&(b>=c.children().length?b=0:0>b&&(b=c.children().length));var d=b*(w+e.thumbMargin)-a;d+o>u&&(d=u-o-e.thumbMargin),0>d&&(d=0),this.move(c,d)},auto:function(){e.auto&&(clearInterval(x),x=setInterval(function(){g.goToNextSlide()},e.pause))},pauseOnHover:function(){var b=this;e.auto&&e.pauseOnHover&&(p.on("mouseenter",function(){a(this).addClass("ls-hover"),g.pause(),e.auto=!0}),p.on("mouseleave",function(){a(this).removeClass("ls-hover"),p.find(".lightSlider").hasClass("lsGrabbing")||b.auto()}))},touchMove:function(a,b){if(p.css("transition-duration","0ms"),"slide"===e.mode){var c=a-b,d=t-c;if(d>=m-o-e.slideMargin)if(e.freeMove===!1)d=m-o-e.slideMargin;else{var f=m-o-e.slideMargin;d=f+(d-f)/5}else 0>d&&(e.freeMove===!1?d=0:d/=5);this.move(g,d)}},touchEnd:function(a){if(p.css("transition-duration",e.speed+"ms"),"slide"===e.mode){var b=!1,c=!0;t-=a,t>m-o-e.slideMargin?(t=m-o-e.slideMargin,e.autoWidth===!1&&(b=!0)):0>t&&(t=0);var d=function(a){var c=0;if(b||a&&(c=1),e.autoWidth)for(var d=0,f=0;f<h.length&&(d+=parseInt(h.eq(f).width())+e.slideMargin,q=f+c,!(d>=t));f++);else{var g=t/((v+e.slideMargin)*e.slideMove);q=parseInt(g)+c,t>=m-o-e.slideMargin&&g%1!==0&&q++}};a>=e.swipeThreshold?(d(!1),c=!1):a<=-e.swipeThreshold&&(d(!0),c=!1),g.mode(c),this.slideThumb()}else a>=e.swipeThreshold?g.goToPrevSlide():a<=-e.swipeThreshold&&g.goToNextSlide()},enableDrag:function(){var b=this;if(!y){var c=0,d=0,f=!1;p.find(".lightSlider").addClass("lsGrab"),p.on("mousedown",function(b){return o>m&&0!==m?!1:void("lSPrev"!==a(b.target).attr("class")&&"lSNext"!==a(b.target).attr("class")&&(c=e.vertical===!0?b.pageY:b.pageX,f=!0,b.preventDefault?b.preventDefault():b.returnValue=!1,p.scrollLeft+=1,p.scrollLeft-=1,p.find(".lightSlider").removeClass("lsGrab").addClass("lsGrabbing"),clearInterval(x)))}),a(window).on("mousemove",function(a){f&&(d=e.vertical===!0?a.pageY:a.pageX,b.touchMove(d,c))}),a(window).on("mouseup",function(g){if(f){p.find(".lightSlider").removeClass("lsGrabbing").addClass("lsGrab"),f=!1,d=e.vertical===!0?g.pageY:g.pageX;var h=d-c;Math.abs(h)>=e.swipeThreshold&&a(window).on("click.ls",function(b){b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopImmediatePropagation(),b.stopPropagation(),a(window).off("click.ls")}),b.touchEnd(h)}})}},enableTouch:function(){var a=this;if(y){var b={},c={};p.on("touchstart",function(a){c=a.originalEvent.targetTouches[0],b.pageX=a.originalEvent.targetTouches[0].pageX,b.pageY=a.originalEvent.targetTouches[0].pageY,clearInterval(x)}),p.on("touchmove",function(d){if(o>m&&0!==m)return!1;var f=d.originalEvent;c=f.targetTouches[0];var g=Math.abs(c.pageX-b.pageX),h=Math.abs(c.pageY-b.pageY);e.vertical===!0?(3*h>g&&d.preventDefault(),a.touchMove(c.pageY,b.pageY)):(3*g>h&&d.preventDefault(),a.touchMove(c.pageX,b.pageX))}),p.on("touchend",function(){if(o>m&&0!==m)return!1;var d;d=e.vertical===!0?c.pageY-b.pageY:c.pageX-b.pageX,a.touchEnd(d)})}},build:function(){var b=this;b.initialStyle(),this.doCss()&&(e.enableTouch===!0&&b.enableTouch(),e.enableDrag===!0&&b.enableDrag()),a(window).on("focus",function(){b.auto()}),a(window).on("blur",function(){clearInterval(x)}),b.pager(),b.pauseOnHover(),b.controls(),b.keyPress()}},d.build(),z.init=function(){z.chbreakpoint(),e.vertical===!0?(o=e.item>1?e.verticalHeight:h.outerHeight(),p.css("height",o+"px")):o=p.outerWidth(),e.loop===!0&&"slide"===e.mode&&z.clone(),z.calL(),"slide"===e.mode&&g.removeClass("lSSlide"),"slide"===e.mode&&(z.calSW(),z.sSW()),setTimeout(function(){"slide"===e.mode&&g.addClass("lSSlide")},1e3),e.pager&&z.createPager(),e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),e.adaptiveHeight===!1&&("slide"===e.mode?e.vertical===!1?d.setHeight(g,!1):d.auto():d.setHeight(g,!0)),e.gallery===!0&&d.slideThumb(),"slide"===e.mode&&d.slide(),e.autoWidth===!1?h.length<=e.item?p.find(".lSAction").hide():p.find(".lSAction").show():z.calWidth(!1)<o&&0!==m?p.find(".lSAction").hide():p.find(".lSAction").show()},g.goToPrevSlide=function(){if(q>0)e.onBeforePrevSlide.call(this,g,q),q--,g.mode(!1),e.gallery===!0&&d.slideThumb();else if(e.loop===!0){if(e.onBeforePrevSlide.call(this,g,q),"fade"===e.mode){var a=l-1;q=parseInt(a/e.slideMove)}g.mode(!1),e.gallery===!0&&d.slideThumb()}else e.slideEndAnimation===!0&&(g.addClass("leftEnd"),setTimeout(function(){g.removeClass("leftEnd")},400))},g.goToNextSlide=function(){var a=!0;if("slide"===e.mode){var b=d.slideValue();a=b<m-o-e.slideMargin}q*e.slideMove<l-e.slideMove&&a?(e.onBeforeNextSlide.call(this,g,q),q++,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.loop===!0?(e.onBeforeNextSlide.call(this,g,q),q=0,g.mode(!1),e.gallery===!0&&d.slideThumb()):e.slideEndAnimation===!0&&(g.addClass("rightEnd"),setTimeout(function(){g.removeClass("rightEnd")},400))},g.mode=function(a){e.adaptiveHeight===!0&&e.vertical===!1&&g.css("height",h.eq(q).outerHeight(!0)),n===!1&&("slide"===e.mode?d.doCss()&&(g.addClass("lSSlide"),""!==e.speed&&p.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&p.css("transition-timing-function",e.cssEasing)):d.doCss()&&(""!==e.speed&&g.css("transition-duration",e.speed+"ms"),""!==e.cssEasing&&g.css("transition-timing-function",e.cssEasing))),a||e.onBeforeSlide.call(this,g,q),"slide"===e.mode?d.slide():d.fade(),p.hasClass("ls-hover")||d.auto(),setTimeout(function(){a||e.onAfterSlide.call(this,g,q)},e.speed),n=!0},g.play=function(){g.goToNextSlide(),e.auto=!0,d.auto()},g.pause=function(){e.auto=!1,clearInterval(x)},g.refresh=function(){z.init()},g.getCurrentSlideCount=function(){var a=q;if(e.loop){var b=p.find(".lslide").length,c=g.find(".clone.left").length;a=c-1>=q?b+(q-c):q>=b+c?q-b-c:q-c}return a+1},g.getTotalSlideCount=function(){return p.find(".lslide").length},g.goToSlide=function(a){q=e.loop?a+g.find(".clone.left").length-1:a,g.mode(!1),e.gallery===!0&&d.slideThumb()},g.destroy=function(){g.lightSlider&&(g.goToPrevSlide=function(){},g.goToNextSlide=function(){},g.mode=function(){},g.play=function(){},g.pause=function(){},g.refresh=function(){},g.getCurrentSlideCount=function(){},g.getTotalSlideCount=function(){},g.goToSlide=function(){},g.lightSlider=null,z={init:function(){}},g.parent().parent().find(".lSAction, .lSPager").remove(),g.removeClass("lightSlider lSFade lSSlide lsGrab lsGrabbing leftEnd right").removeAttr("style").unwrap().unwrap(),g.children().removeAttr("style"),h.removeClass("lslide active"),g.find(".clone").remove(),h=null,x=null,n=!1,q=0)},setTimeout(function(){e.onSliderLoad.call(this,g)},10),a(window).on("resize orientationchange",function(a){setTimeout(function(){a.preventDefault?a.preventDefault():a.returnValue=!1,z.init()},200)}),this}}(jQuery);
uninstall.php CHANGED
@@ -1,28 +1,28 @@
1
- <?php
2
-
3
- if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
- exit;
5
- }
6
-
7
-
8
- // When the plugin is uninstalled, brush away all footprints; there shall be no trace.
9
- global $wpdb;
10
-
11
- // Remove all of our 'yikes_woo_products_tabs' post meta
12
- $wpdb->delete(
13
-
14
- // Table
15
- "{$wpdb->prefix}postmeta",
16
-
17
- // Where
18
- array( 'meta_key' => 'yikes_woo_products_tabs' )
19
- );
20
-
21
- // Remove our 'yikes_woo_reusable_products_tabs' option
22
- delete_option( 'yikes_woo_reusable_products_tabs' );
23
-
24
- // Remove our 'yikes_woo_reusable_products_tabs_applied' option
25
- delete_option( 'yikes_woo_reusable_products_tabs_applied' );
26
-
27
- // Remove our DB version option (legacy)
28
  delete_option( 'yikes_woocommerce_custom_product_tabs_db_version' );
1
+ <?php
2
+
3
+ if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
4
+ exit;
5
+ }
6
+
7
+
8
+ // When the plugin is uninstalled, brush away all footprints; there shall be no trace.
9
+ global $wpdb;
10
+
11
+ // Remove all of our 'yikes_woo_products_tabs' post meta
12
+ $wpdb->delete(
13
+
14
+ // Table
15
+ "{$wpdb->prefix}postmeta",
16
+
17
+ // Where
18
+ array( 'meta_key' => 'yikes_woo_products_tabs' )
19
+ );
20
+
21
+ // Remove our 'yikes_woo_reusable_products_tabs' option
22
+ delete_option( 'yikes_woo_reusable_products_tabs' );
23
+
24
+ // Remove our 'yikes_woo_reusable_products_tabs_applied' option
25
+ delete_option( 'yikes_woo_reusable_products_tabs_applied' );
26
+
27
+ // Remove our DB version option (legacy)
28
  delete_option( 'yikes_woocommerce_custom_product_tabs_db_version' );
yikes-inc-easy-custom-woocommerce-product-tabs.php CHANGED
@@ -1,322 +1,322 @@
1
- <?php
2
- /**
3
- * Plugin Name: Custom Product Tabs for WooCommerce
4
- * Plugin URI: http://www.yikesinc.com
5
- * Description: Extend WooCommerce to add and manage custom product tabs. Create as many product tabs as needed per product.
6
- * Author: YIKES, Inc.
7
- * Author URI: http://www.yikesinc.com
8
- * Version: 1.6.10
9
- * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
10
- * Domain Path: languages/
11
- *
12
- * WC requires at least: 3.0.0
13
- * WC tested up to: 3.6
14
- *
15
- * Copyright: (c) 2014-2015 YIKES Inc.
16
- *
17
- * License: GNU General Public License v3.0
18
- * License URI: http://www.gnu.org/licenses/gpl-3.0.html
19
- *
20
- * This plugin is originally a fork of SkyVerge WooCommerce Custom Product Tabs Lite.
21
- */
22
-
23
- // Exit if accessed directly.
24
- if ( ! defined( 'ABSPATH' ) ) exit;
25
-
26
- // Must include plugin.php to use is_plugin_active().
27
- require_once ABSPATH . 'wp-admin/includes/plugin.php';
28
-
29
- if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
30
- new YIKES_Custom_Product_Tabs();
31
- } else {
32
- // Deactivate the plugin, and display our error notification.
33
- deactivate_plugins( '/yikes-inc-easy-custom-woocommerce-product-tabs/yikes-inc-easy-custom-woocommerce-product-tabs.php' );
34
- add_action( 'admin_notices', 'yikes_woo_display_admin_notice_error' );
35
- }
36
-
37
- /**
38
- * Display our error admin notice if WooCommerce is not installed + active.
39
- */
40
- function yikes_woo_display_admin_notice_error() {
41
- ?>
42
- <!-- hide the 'Plugin Activated' default message -->
43
- <style>
44
- #message.updated {
45
- display: none;
46
- }
47
- </style>
48
- <!-- display our error message -->
49
- <div class="error">
50
- <p>
51
- <?php
52
- esc_html_e( 'Custom Product Tabs for WooCommerce could not be activated because WooCommerce is not installed and active.', 'yikes-inc-easy-custom-woocommerce-product-tabs' );
53
- ?>
54
- </p>
55
- <p>
56
- <?php
57
- /* translators: The placeholder is a URL to the WooCommerce plugin. */
58
- echo sprintf( esc_html( 'Please install and activate %1s before activating the plugin.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=WooCommerce' ) ) . '" title="WooCommerce">WooCommerce</a>' );
59
- ?>
60
- </p>
61
- </div>
62
- <?php
63
- }
64
-
65
- /**
66
- * Initialize the Custom Product Tab Class.
67
- */
68
- class YIKES_Custom_Product_Tabs {
69
-
70
- /**
71
- * Define hooks/require files.
72
- */
73
- public function __construct() {
74
-
75
- $this->define_constants();
76
-
77
- add_action( 'admin_init', array( $this, 'run_update_check' ) );
78
-
79
- // Require our classes.
80
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-saved-tabs.php';
81
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-tabs.php';
82
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.support.php';
83
- require_once YIKES_Custom_Product_Tabs_Path . 'public/class.yikes-woo-tabs-display.php';
84
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.premium.php';
85
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.export.php';
86
- require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.import.php';
87
-
88
- add_action( 'admin_init', array( $this, 'init' ) );
89
- }
90
-
91
- /**
92
- * Define our constants.
93
- */
94
- private function define_constants() {
95
-
96
- /**
97
- * Define the page slug for our plugin's custom settings page in one central location.
98
- */
99
- if ( ! defined( 'YIKES_Custom_Product_Tabs_Settings_Page' ) ) {
100
- define( 'YIKES_Custom_Product_Tabs_Settings_Page', 'yikes-woo-settings' );
101
- }
102
-
103
- /**
104
- * Define the plugin's version.
105
- */
106
- if ( ! defined( 'YIKES_Custom_Product_Tabs_Version' ) ) {
107
- define( 'YIKES_Custom_Product_Tabs_Version', '1.6.10' );
108
- }
109
-
110
- /**
111
- * Define the plugin's URI.
112
- */
113
- if ( ! defined( 'YIKES_Custom_Product_Tabs_URI' ) ) {
114
- define( 'YIKES_Custom_Product_Tabs_URI', plugin_dir_url( __FILE__ ) );
115
- }
116
-
117
- /**
118
- * Define the plugin's path.
119
- */
120
- if ( ! defined( 'YIKES_Custom_Product_Tabs_Path' ) ) {
121
- define( 'YIKES_Custom_Product_Tabs_Path', plugin_dir_path( __FILE__ ) );
122
- }
123
-
124
- /**
125
- * Define the page slug for our plugin's support page.
126
- */
127
- if ( ! defined( 'YIKES_Custom_Product_Tabs_Support_Page' ) ) {
128
- define( 'YIKES_Custom_Product_Tabs_Support_Page', 'yikes-woo-support' );
129
- }
130
-
131
- /**
132
- * Define the page slug for our plugin's premium page.
133
- */
134
- if ( ! defined( 'YIKES_Custom_Product_Tabs_Premium_Page' ) ) {
135
- define( 'YIKES_Custom_Product_Tabs_Premium_Page', 'yikes-woo-premium' );
136
- }
137
- }
138
-
139
- /**
140
- * Run any update scripts.
141
- */
142
- public function run_update_check() {
143
-
144
- $run_onesixone_data_update = get_option( 'custom_product_tabs_onesixone_data_update' );
145
-
146
- // If we don't have a value for this option then run our update again.
147
- if ( empty( $run_onesixone_data_update ) ) {
148
- $this->run_onesixone_data_update();
149
- }
150
-
151
- }
152
-
153
- /**
154
- * Run the v1.6 update. This changes the tabs' slug and adds some default elements to our tab items.
155
- */
156
- private function run_onesixone_data_update() {
157
-
158
- // Update Saved Tabs.
159
- $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
160
-
161
- if ( ! empty( $saved_tabs ) ) {
162
-
163
- foreach ( $saved_tabs as $tab_id => &$tab ) {
164
-
165
- // Set the tab slug to the sanitized tab's title.
166
- $tab['tab_slug'] = urldecode( sanitize_title( $tab['tab_title'] ) );
167
-
168
- // Default these elements.
169
- $tab['taxonomies'] = ! isset( $tab['taxonomies'] ) ? array() : $tab['taxonomies'];
170
- $tab['global_tab'] = ! isset( $tab['global_tab'] ) ? false : $tab['global_tab'];
171
- $tab['tab_name'] = ! isset( $tab['tab_name'] ) ? '' : $tab['tab_name'];
172
- }
173
-
174
- update_option( 'yikes_woo_reusable_products_tabs', $saved_tabs );
175
-
176
- }
177
-
178
- // Update Saved Tabs Applied.
179
- $saved_tabs_applied = get_option( 'yikes_woo_reusable_products_tabs_applied' );
180
-
181
- if ( ! empty( $saved_tabs_applied ) ) {
182
-
183
- foreach ( $saved_tabs_applied as $product_id => &$tabs ) {
184
-
185
- if ( ! empty( $tabs ) ) {
186
-
187
- foreach ( $tabs as $saved_tab_id => &$tab ) {
188
-
189
- if ( ! empty( $tab ) ) {
190
-
191
- if ( isset( $saved_tabs[ $saved_tab_id ] ) ) {
192
-
193
- // Set the tab ID to the saved tab's slug.
194
- $tab_id = $saved_tabs[ $saved_tab_id ]['tab_slug'];
195
- $tab['tab_id'] = $tab_id;
196
- }
197
- } else {
198
-
199
- // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
200
- unset( $tab );
201
- }
202
- }
203
- } else {
204
-
205
- // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
206
- unset( $saved_tabs_applied[ $product_id ] );
207
- }
208
- }
209
-
210
- update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs_applied );
211
- }
212
-
213
- // Update Post Meta.
214
- global $wpdb;
215
-
216
- // Fetch all of the post meta items where meta_key = 'yikes_woo_products_tabs'.
217
- $yikes_woo_products_tabs = $wpdb->get_results(
218
- "
219
- SELECT *
220
- FROM {$wpdb->postmeta}
221
- WHERE meta_key = 'yikes_woo_products_tabs'
222
- "
223
- );
224
-
225
- if ( ! empty( $yikes_woo_products_tabs ) ) {
226
-
227
- foreach ( $yikes_woo_products_tabs as $table_row ) {
228
-
229
- // Unserialize our tabs.
230
- $tabs = unserialize( $table_row->meta_value );
231
-
232
- // If we have tabs...
233
- if ( ! empty( $tabs ) ) {
234
-
235
- foreach ( $tabs as &$tab ) {
236
-
237
- // Set the tab slug ('id') to the sanitized tab's title.
238
- $tab['id'] = urldecode( sanitize_title( $tab['title'] ) );
239
- }
240
-
241
- update_post_meta( $table_row->post_id, 'yikes_woo_products_tabs', $tabs );
242
-
243
- } else {
244
-
245
- // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
246
- delete_post_meta( $table_row->post_id, 'yikes_woo_products_tabs' );
247
- }
248
- }
249
- }
250
-
251
- // Set a flag so we don't run this update more than once.
252
- add_option( 'custom_product_tabs_onesixone_data_update', true );
253
- }
254
-
255
-
256
- /**
257
- * Run our basic plugin setup.
258
- */
259
- public function init() {
260
-
261
- // Default WYSIWYG to 'visual'.
262
- add_filter( 'wp_default_editor', array( $this, 'yikes_woo_set_editor_to_visual' ), 10, 1 );
263
-
264
- // i18n.
265
- add_action( 'plugins_loaded', array( $this, 'yikes_woo_load_plugin_textdomain' ) );
266
-
267
- // Add settings link to plugin on plugins page.
268
- add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_action_links' ), 10, 1 );
269
- }
270
-
271
- /**
272
- * Add a link to the settings page to the plugin's action links
273
- *
274
- * @since 1.5
275
- *
276
- * @param array $links An array of links passed from the plugin_action_links_{plugin_name} filter.
277
- *
278
- * @return array $links The $links array, with our saved tabs page appended.
279
- */
280
- public function add_plugin_action_links( $links ) {
281
- $href = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) );
282
- $links[] = '<a href="' . $href . '">Saved Tabs</a>';
283
- return $links;
284
- }
285
-
286
- /**
287
- * Register the textdomain for proper i18n / l10n.
288
- */
289
- public function yikes_woo_load_plugin_textdomain() {
290
- load_plugin_textdomain(
291
- 'yikes-inc-easy-custom-woocommerce-product-tabs',
292
- false,
293
- YIKES_Custom_Product_Tabs_Path . 'languages/'
294
- );
295
- }
296
-
297
- /**
298
- * Default the wp_editor to 'Visual' tab (this helps prevent errors with dynamically generating WYSIWYG)
299
- *
300
- * @since 1.5
301
- *
302
- * @param string $mode The current mode of the editor.
303
- *
304
- * @return string 'tinymce' || $mode
305
- */
306
- public function yikes_woo_set_editor_to_visual( $mode ) {
307
- global $post;
308
-
309
- // Only continue if we're on the products page.
310
- if ( isset( $post ) && isset( $post->post_type ) && $post->post_type !== 'product' ) {
311
- return $mode;
312
- }
313
-
314
- // This is funky, but only default the editor when we don't have a post (and we're on the product page).
315
- // This a result of calling the wp_editor via AJAX - I think.
316
- if ( ! isset( $post ) ) {
317
- return apply_filters( 'yikes_woocommerce_default_editor_mode', 'tinymce' );
318
- } else {
319
- return $mode;
320
- }
321
- }
322
- }
1
+ <?php
2
+ /**
3
+ * Plugin Name: Custom Product Tabs for WooCommerce
4
+ * Plugin URI: http://www.yikesinc.com
5
+ * Description: Extend WooCommerce to add and manage custom product tabs. Create as many product tabs as needed per product.
6
+ * Author: YIKES, Inc.
7
+ * Author URI: http://www.yikesinc.com
8
+ * Version: 1.6.11
9
+ * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
10
+ * Domain Path: languages/
11
+ *
12
+ * WC requires at least: 3.0.0
13
+ * WC tested up to: 3.7
14
+ *
15
+ * Copyright: (c) 2014-2015 YIKES Inc.
16
+ *
17
+ * License: GNU General Public License v3.0
18
+ * License URI: http://www.gnu.org/licenses/gpl-3.0.html
19
+ *
20
+ * This plugin is originally a fork of SkyVerge WooCommerce Custom Product Tabs Lite.
21
+ */
22
+
23
+ // Exit if accessed directly.
24
+ if ( ! defined( 'ABSPATH' ) ) exit;
25
+
26
+ // Must include plugin.php to use is_plugin_active().
27
+ require_once ABSPATH . 'wp-admin/includes/plugin.php';
28
+
29
+ if ( is_plugin_active( 'woocommerce/woocommerce.php' ) ) {
30
+ new YIKES_Custom_Product_Tabs();
31
+ } else {
32
+ // Deactivate the plugin, and display our error notification.
33
+ deactivate_plugins( '/yikes-inc-easy-custom-woocommerce-product-tabs/yikes-inc-easy-custom-woocommerce-product-tabs.php' );
34
+ add_action( 'admin_notices', 'yikes_woo_display_admin_notice_error' );
35
+ }
36
+
37
+ /**
38
+ * Display our error admin notice if WooCommerce is not installed + active.
39
+ */
40
+ function yikes_woo_display_admin_notice_error() {
41
+ ?>
42
+ <!-- hide the 'Plugin Activated' default message -->
43
+ <style>
44
+ #message.updated {
45
+ display: none;
46
+ }
47
+ </style>
48
+ <!-- display our error message -->
49
+ <div class="error">
50
+ <p>
51
+ <?php
52
+ esc_html_e( 'Custom Product Tabs for WooCommerce could not be activated because WooCommerce is not installed and active.', 'yikes-inc-easy-custom-woocommerce-product-tabs' );
53
+ ?>
54
+ </p>
55
+ <p>
56
+ <?php
57
+ /* translators: The placeholder is a URL to the WooCommerce plugin. */
58
+ echo sprintf( esc_html( 'Please install and activate %1s before activating the plugin.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=WooCommerce' ) ) . '" title="WooCommerce">WooCommerce</a>' );
59
+ ?>
60
+ </p>
61
+ </div>
62
+ <?php
63
+ }
64
+
65
+ /**
66
+ * Initialize the Custom Product Tab Class.
67
+ */
68
+ class YIKES_Custom_Product_Tabs {
69
+
70
+ /**
71
+ * Define hooks/require files.
72
+ */
73
+ public function __construct() {
74
+
75
+ $this->define_constants();
76
+
77
+ add_action( 'admin_init', array( $this, 'run_update_check' ) );
78
+
79
+ // Require our classes.
80
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-saved-tabs.php';
81
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.yikes-woo-tabs.php';
82
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.support.php';
83
+ require_once YIKES_Custom_Product_Tabs_Path . 'public/class.yikes-woo-tabs-display.php';
84
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.premium.php';
85
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.export.php';
86
+ require_once YIKES_Custom_Product_Tabs_Path . 'admin/class.import.php';
87
+
88
+ add_action( 'admin_init', array( $this, 'init' ) );
89
+ }
90
+
91
+ /**
92
+ * Define our constants.
93
+ */
94
+ private function define_constants() {
95
+
96
+ /**
97
+ * Define the page slug for our plugin's custom settings page in one central location.
98
+ */
99
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_Settings_Page' ) ) {
100
+ define( 'YIKES_Custom_Product_Tabs_Settings_Page', 'yikes-woo-settings' );
101
+ }
102
+
103
+ /**
104
+ * Define the plugin's version.
105
+ */
106
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_Version' ) ) {
107
+ define( 'YIKES_Custom_Product_Tabs_Version', '1.6.11' );
108
+ }
109
+
110
+ /**
111
+ * Define the plugin's URI.
112
+ */
113
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_URI' ) ) {
114
+ define( 'YIKES_Custom_Product_Tabs_URI', plugin_dir_url( __FILE__ ) );
115
+ }
116
+
117
+ /**
118
+ * Define the plugin's path.
119
+ */
120
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_Path' ) ) {
121
+ define( 'YIKES_Custom_Product_Tabs_Path', plugin_dir_path( __FILE__ ) );
122
+ }
123
+
124
+ /**
125
+ * Define the page slug for our plugin's support page.
126
+ */
127
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_Support_Page' ) ) {
128
+ define( 'YIKES_Custom_Product_Tabs_Support_Page', 'yikes-woo-support' );
129
+ }
130
+
131
+ /**
132
+ * Define the page slug for our plugin's premium page.
133
+ */
134
+ if ( ! defined( 'YIKES_Custom_Product_Tabs_Premium_Page' ) ) {
135
+ define( 'YIKES_Custom_Product_Tabs_Premium_Page', 'yikes-woo-premium' );
136
+ }
137
+ }
138
+
139
+ /**
140
+ * Run any update scripts.
141
+ */
142
+ public function run_update_check() {
143
+
144
+ $run_onesixone_data_update = get_option( 'custom_product_tabs_onesixone_data_update' );
145
+
146
+ // If we don't have a value for this option then run our update again.
147
+ if ( empty( $run_onesixone_data_update ) ) {
148
+ $this->run_onesixone_data_update();
149
+ }
150
+
151
+ }
152
+
153
+ /**
154
+ * Run the v1.6 update. This changes the tabs' slug and adds some default elements to our tab items.
155
+ */
156
+ private function run_onesixone_data_update() {
157
+
158
+ // Update Saved Tabs.
159
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
160
+
161
+ if ( ! empty( $saved_tabs ) ) {
162
+
163
+ foreach ( $saved_tabs as $tab_id => &$tab ) {
164
+
165
+ // Set the tab slug to the sanitized tab's title.
166
+ $tab['tab_slug'] = urldecode( sanitize_title( $tab['tab_title'] ) );
167
+
168
+ // Default these elements.
169
+ $tab['taxonomies'] = ! isset( $tab['taxonomies'] ) ? array() : $tab['taxonomies'];
170
+ $tab['global_tab'] = ! isset( $tab['global_tab'] ) ? false : $tab['global_tab'];
171
+ $tab['tab_name'] = ! isset( $tab['tab_name'] ) ? '' : $tab['tab_name'];
172
+ }
173
+
174
+ update_option( 'yikes_woo_reusable_products_tabs', $saved_tabs );
175
+
176
+ }
177
+
178
+ // Update Saved Tabs Applied.
179
+ $saved_tabs_applied = get_option( 'yikes_woo_reusable_products_tabs_applied' );
180
+
181
+ if ( ! empty( $saved_tabs_applied ) ) {
182
+
183
+ foreach ( $saved_tabs_applied as $product_id => &$tabs ) {
184
+
185
+ if ( ! empty( $tabs ) ) {
186
+
187
+ foreach ( $tabs as $saved_tab_id => &$tab ) {
188
+
189
+ if ( ! empty( $tab ) ) {
190
+
191
+ if ( isset( $saved_tabs[ $saved_tab_id ] ) ) {
192
+
193
+ // Set the tab ID to the saved tab's slug.
194
+ $tab_id = $saved_tabs[ $saved_tab_id ]['tab_slug'];
195
+ $tab['tab_id'] = $tab_id;
196
+ }
197
+ } else {
198
+
199
+ // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
200
+ unset( $tab );
201
+ }
202
+ }
203
+ } else {
204
+
205
+ // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
206
+ unset( $saved_tabs_applied[ $product_id ] );
207
+ }
208
+ }
209
+
210
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $saved_tabs_applied );
211
+ }
212
+
213
+ // Update Post Meta.
214
+ global $wpdb;
215
+
216
+ // Fetch all of the post meta items where meta_key = 'yikes_woo_products_tabs'.
217
+ $yikes_woo_products_tabs = $wpdb->get_results(
218
+ "
219
+ SELECT *
220
+ FROM {$wpdb->postmeta}
221
+ WHERE meta_key = 'yikes_woo_products_tabs'
222
+ "
223
+ );
224
+
225
+ if ( ! empty( $yikes_woo_products_tabs ) ) {
226
+
227
+ foreach ( $yikes_woo_products_tabs as $table_row ) {
228
+
229
+ // Unserialize our tabs.
230
+ $tabs = unserialize( $table_row->meta_value );
231
+
232
+ // If we have tabs...
233
+ if ( ! empty( $tabs ) ) {
234
+
235
+ foreach ( $tabs as &$tab ) {
236
+
237
+ // Set the tab slug ('id') to the sanitized tab's title.
238
+ $tab['id'] = urldecode( sanitize_title( $tab['title'] ) );
239
+ }
240
+
241
+ update_post_meta( $table_row->post_id, 'yikes_woo_products_tabs', $tabs );
242
+
243
+ } else {
244
+
245
+ // In previous versions of the plugin we were leaving some empty arrays. Clean 'em up.
246
+ delete_post_meta( $table_row->post_id, 'yikes_woo_products_tabs' );
247
+ }
248
+ }
249
+ }
250
+
251
+ // Set a flag so we don't run this update more than once.
252
+ add_option( 'custom_product_tabs_onesixone_data_update', true );
253
+ }
254
+
255
+
256
+ /**
257
+ * Run our basic plugin setup.
258
+ */
259
+ public function init() {
260
+
261
+ // Default WYSIWYG to 'visual'.
262
+ add_filter( 'wp_default_editor', array( $this, 'yikes_woo_set_editor_to_visual' ), 10, 1 );
263
+
264
+ // i18n.
265
+ add_action( 'plugins_loaded', array( $this, 'yikes_woo_load_plugin_textdomain' ) );
266
+
267
+ // Add settings link to plugin on plugins page.
268
+ add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), array( $this, 'add_plugin_action_links' ), 10, 1 );
269
+ }
270
+
271
+ /**
272
+ * Add a link to the settings page to the plugin's action links
273
+ *
274
+ * @since 1.5
275
+ *
276
+ * @param array $links An array of links passed from the plugin_action_links_{plugin_name} filter.
277
+ *
278
+ * @return array $links The $links array, with our saved tabs page appended.
279
+ */
280
+ public function add_plugin_action_links( $links ) {
281
+ $href = esc_url_raw( add_query_arg( array( 'page' => YIKES_Custom_Product_Tabs_Settings_Page ), admin_url() ) );
282
+ $links[] = '<a href="' . $href . '">Saved Tabs</a>';
283
+ return $links;
284
+ }
285
+
286
+ /**
287
+ * Register the textdomain for proper i18n / l10n.
288
+ */
289
+ public function yikes_woo_load_plugin_textdomain() {
290
+ load_plugin_textdomain(
291
+ 'yikes-inc-easy-custom-woocommerce-product-tabs',
292
+ false,
293
+ YIKES_Custom_Product_Tabs_Path . 'languages/'
294
+ );
295
+ }
296
+
297
+ /**
298
+ * Default the wp_editor to 'Visual' tab (this helps prevent errors with dynamically generating WYSIWYG)
299
+ *
300
+ * @since 1.5
301
+ *
302
+ * @param string $mode The current mode of the editor.
303
+ *
304
+ * @return string 'tinymce' || $mode
305
+ */
306
+ public function yikes_woo_set_editor_to_visual( $mode ) {
307
+ global $post;
308
+
309
+ // Only continue if we're on the products page.
310
+ if ( isset( $post ) && isset( $post->post_type ) && $post->post_type !== 'product' ) {
311
+ return $mode;
312
+ }
313
+
314
+ // This is funky, but only default the editor when we don't have a post (and we're on the product page).
315
+ // This a result of calling the wp_editor via AJAX - I think.
316
+ if ( ! isset( $post ) ) {
317
+ return apply_filters( 'yikes_woocommerce_default_editor_mode', 'tinymce' );
318
+ } else {
319
+ return $mode;
320
+ }
321
+ }
322
+ }