Custom Product Tabs for WooCommerce - Version 1.5

Version Description

  • December 20th, 2016 =
  • 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
  • UI: Complete overhaul of the custom tab interface for an easier, responsive tab creating experience.
  • Saved Tabs: A new settings page has been added for users to create / update / delete saved tabs (see FAQ for more information)
  • 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
  • Adding a new tab initializes a new wp_editor (WYSIWYG) instead of a plain textarea
  • Added warning message when two tabs have the same title
  • Tabs with empty titles are no longer shown on the product page
  • Added ability to remove the first tab
  • Adding, moving, and removing tabs works as expected when the user's 'Visual Editor' option is checked
  • On the product & settings pages, WYSIWYG editors will default to the visual tab (this helps prevent errors with dynamic wp_editor generation)
  • Added a filter yikes_woocommerce_default_editor_mode that can change the default-to-visual-tab behavior (use at your own risk!)
  • Updated the 'How To' text, and slight modification to the style
  • Changed the JavaScript methods controlling how tabs were added, deleted, and moved up/down
  • Cleaned up and commented on all PHP and JavaScript files
  • Added proper i18n, with languages/ folder, .pot file, and load_plugin_textdomain hook
  • Incremented version #
Download this release

Release Info

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

Code changes from version 1.4.4 to 1.5

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.yikes-woo-generate-html.php ADDED
@@ -0,0 +1,443 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
21
+ // If we don't have tab data, we display things slightly differently
22
+ $product_has_tabs = true;
23
+ if ( empty( $tab_data ) ) {
24
+ $product_has_tabs = false;
25
+ }
26
+
27
+ // Pull the saved array of reusable tabs
28
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
29
+
30
+ // Display the custom tab panel
31
+ echo '<div id="yikes_woocommerce_custom_product_tabs" class="panel wc-metaboxes-wrapper woocommerce_options_panel">';
32
+ echo '<div class="options_group">';
33
+
34
+ echo $this->display_yikes_how_to();
35
+
36
+ if ( $product_has_tabs === true ) {
37
+
38
+ // Loop through all the tabs and add all components
39
+ $this->generate_tab_html( $tab_data, $reusable_tab_options_array, $post );
40
+ }
41
+
42
+ // Add duplicate container
43
+ $this->generate_duplicate_html();
44
+
45
+ // Add a Saved Tab // Add Another Tab
46
+ echo $this->display_yikes_add_tabs_container( $product_has_tabs );
47
+
48
+ // Hidden input field holding # of tabs
49
+ echo $this->display_yikes_number_of_tabs( count( $tab_data ) );
50
+
51
+ echo '</div>';
52
+ echo '</div>';
53
+
54
+ }
55
+
56
+ /* Generate HTML Functions */
57
+
58
+ /**
59
+ * Generate the duplicate HTML block
60
+ *
61
+ * @since 1.5
62
+ *
63
+ */
64
+ protected function generate_duplicate_html() {
65
+
66
+ // duplicate_this_row content
67
+ echo '<div id="duplicate_this_row">';
68
+
69
+ // Override Saved Tab checkbox & hidden input fields (Duplicate)
70
+ echo $this->display_yikes_override_container_duplicate();
71
+
72
+ // Tab title input field
73
+ 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' ) );
74
+
75
+ // WYSIWYG Content field
76
+ $this->display_woocommerce_wp_wysiwyg_input_duplicate();
77
+
78
+ // Up & Down arrows && Remove Tab button (Duplicate)
79
+ echo $this->display_yikes_button_holder_container_duplicate();
80
+
81
+ echo '</div>';
82
+ }
83
+
84
+ /**
85
+ * Generate the normal tab HTML block
86
+ *
87
+ * @since 1.5
88
+ *
89
+ * @param array | $tab_data | Array of tab data
90
+ * @param array | $reusable_tab_options | Array of saved tab data
91
+ * @param object| $post | The global $post object
92
+ */
93
+ protected function generate_tab_html( $tab_data, $reusable_tab_options, $post ) {
94
+ $i = 1;
95
+
96
+ // Set up the initial display, by looping
97
+ foreach ( $tab_data as $tab ) {
98
+
99
+ $reusable_tab_flag = false;
100
+ $reusable_tab_id = '';
101
+
102
+ // If $tab is in the array of reusable tabs, set flag
103
+ if ( isset( $reusable_tab_options ) && isset( $reusable_tab_options[$post->ID] ) ) {
104
+
105
+ foreach( $reusable_tab_options[$post->ID] as $id => $reusable_tab_data ) {
106
+ if ( isset( $reusable_tab_data['tab_id'] ) && isset( $tab['id'] ) && $reusable_tab_data['tab_id'] === $tab['id'] ) {
107
+ $reusable_tab_flag = true;
108
+ $reusable_tab_id = $reusable_tab_data['reusable_tab_id'];
109
+ }
110
+ }
111
+ }
112
+
113
+ // Override Saved Tab checkbox & hidden input fields
114
+ echo $this->display_yikes_override_container( $i, $reusable_tab_flag, $reusable_tab_id );
115
+
116
+ // Tab Title input field
117
+ $this->display_woocommerce_wp_text_input( $i, $tab );
118
+
119
+ // Tab content wysiwyg
120
+ $this->display_woocommerce_wp_wysiwyg_input( $i, $tab );
121
+
122
+ // Up & Down arrows & Remove Tab button
123
+ echo $this->display_yikes_button_holder_container( $i );
124
+
125
+ // line separating tabs
126
+ echo $this->display_yikes_tab_divider( $i, count( $tab_data ) );
127
+
128
+ $i++;
129
+ }
130
+ }
131
+
132
+ /**
133
+ * Add how-to info HTML to page
134
+ *
135
+ * @since 1.5
136
+ *
137
+ * @return string HTML
138
+ */
139
+ protected function display_yikes_how_to() {
140
+ $return_html = '';
141
+ $return_html .= '<div class="yikes-woo-tabs-hidden-how-to-info">';
142
+ $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>';
143
+ $return_html .= '</div>';
144
+ $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>';
145
+
146
+ return $return_html;
147
+ }
148
+
149
+ /**
150
+ * Add override container HTML to page
151
+ *
152
+ * @since 1.5
153
+ *
154
+ * @param int $i Counter for tab generating loop
155
+ * @param bool $reusable_tab_flag Flag indicating whether this tab uses a saved/reusable tab
156
+ * @param int $reusable_tab_id ID of the saved/reusable tab
157
+ * @return string HTML
158
+ */
159
+ protected function display_yikes_override_container( $i, $reusable_tab_flag, $reusable_tab_id ) {
160
+ $return_html = '';
161
+
162
+ if ( $reusable_tab_flag === true ) {
163
+ $return_html .= '<p class="yikes_wc_override_reusable_tab_container" id="_yikes_wc_override_reusable_tab_container_' . $i . '" data-reusable-tab="true">';
164
+ $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_' . $i . '" data-tab-number="'. $i .'"';
165
+ $return_html .= 'title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '">';
166
+ $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">';
167
+ $return_html .= __( ' Override Saved Tab for this product' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
168
+ $return_html .= '</label>';
169
+ $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"';
170
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" value="none">';
171
+ $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"';
172
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" value="' . $reusable_tab_id . '">';
173
+ $return_html .= '</p>';
174
+ } else {
175
+ $return_html .= '<p class="yikes_wc_override_reusable_tab_container" id="_yikes_wc_override_reusable_tab_container_' . $i . '" style="display: none;">';
176
+ $return_html .= '<input type="checkbox" class="_yikes_wc_override_reusable_tab" id="_yikes_wc_override_reusable_tab_' . $i . '" data-tab-number="'. $i .'"';
177
+ $return_html .= 'title="' . __( 'Check this box to override the saved tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '">';
178
+ $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">';
179
+ $return_html .= __( ' Override Saved Tab for this product' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
180
+ $return_html .= '</label>';
181
+ $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"';
182
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action" value="none">';
183
+ $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"';
184
+ $return_html .= 'id="_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '" value="' . $reusable_tab_id . '">';
185
+ $return_html .= '</p>';
186
+ }
187
+
188
+ return $return_html;
189
+ }
190
+
191
+ /**
192
+ * Add button holder container HTML to page
193
+ *
194
+ * @since 1.5
195
+ *
196
+ * @param int $i Counter for tab generating loop
197
+ * @return string HTML
198
+ */
199
+ protected function display_yikes_button_holder_container( $i ) {
200
+ $return_html = '';
201
+
202
+ $return_html .= '<section class="button-holder" alt="' . $i . '">';
203
+ $return_html .= '<div class="yikes_wc_move_tab_container">';
204
+ $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
205
+ $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
206
+ $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
207
+ $return_html .= '</div>';
208
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab"><span class="dashicons dashicons-no-alt"></span>';
209
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
210
+ $return_html .= '</a>';
211
+ $return_html .= '</section>';
212
+
213
+ return $return_html;
214
+ }
215
+
216
+ /**
217
+ * Add tab divider HTML to page
218
+ *
219
+ * @since 1.5
220
+ *
221
+ * @param int $i Counter for tab generating loop
222
+ * @param int $tab_count Total # of tabs
223
+ * @return string HTML
224
+ */
225
+ protected function display_yikes_tab_divider( $i, $tab_count ) {
226
+ $return_html = '';
227
+ if ( $i != $tab_count ) {
228
+ $return_html .= '<div class="yikes-woo-custom-tab-divider"></div>';
229
+ }
230
+
231
+ return $return_html;
232
+ }
233
+
234
+ /**
235
+ * Call input field generation function and echo HTML to page
236
+ *
237
+ * @since 1.5
238
+ *
239
+ * @param int $i Counter for tab generating loop
240
+ * @param array $tab Array of tab data
241
+ */
242
+ protected function display_woocommerce_wp_text_input( $i, $tab ) {
243
+
244
+ 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') );
245
+ }
246
+
247
+ /**
248
+ * Call wp_editor wrapped function and echo HTML to page
249
+ *
250
+ * @since 1.5
251
+ *
252
+ * @param int $i Counter for tab generating loop
253
+ * @param array $tab Array of tab data
254
+ */
255
+ protected function display_woocommerce_wp_wysiwyg_input( $i, $tab ) {
256
+ 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">';
257
+ $this->woocommerce_wp_wysiwyg_input( array(
258
+ 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i ,
259
+ 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
260
+ 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
261
+ 'value' => $tab['content'],
262
+ 'style' => 'width:70%;height:10.5em;',
263
+ 'class' => 'yikes_woo_tabs_content_field',
264
+ 'number' => $i
265
+ ) );
266
+ echo '</div>';
267
+ }
268
+
269
+ /* Hidden Duplicate HTML Section */
270
+
271
+ /**
272
+ * Add duplicate override container HTML to page
273
+ *
274
+ * @since 1.5
275
+ *
276
+ * @return string HTML
277
+ */
278
+ protected function display_yikes_override_container_duplicate() {
279
+ $return_html = '';
280
+
281
+ $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;">';
282
+ $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' ) . '" />';
283
+ $return_html .= '<label class="_yikes_wc_override_reusable_tab_label_duplicate">' . __( 'Override Saved Tab for this product' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</label>';
284
+ $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">';
285
+ $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="">';
286
+ $return_html .= '</p>';
287
+
288
+ return $return_html;
289
+ }
290
+
291
+ /**
292
+ * Add duplicate remove tab button HTML to page
293
+ *
294
+ * @since 1.5
295
+ *
296
+ * @return string HTML
297
+ */
298
+ protected function display_yikes_remove_tab_duplicate() {
299
+ $return_html = '';
300
+
301
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
302
+ $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
303
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
304
+ $return_html .= '</a>';
305
+
306
+ return $return_html;
307
+ }
308
+
309
+ /**
310
+ * Call input field generation function and echo HTML to page
311
+ *
312
+ * @since 1.5
313
+ *
314
+ * @param array $tab Array of tab data
315
+ */
316
+ protected function display_woocommerce_wp_wysiwyg_input_duplicate() {
317
+
318
+ $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:70%;height:10.5em;' , 'class' => 'yikes_woo_tabs_content_field' ) );
319
+ }
320
+
321
+ /**
322
+ * Add duplicate button holder container HTML to page
323
+ *
324
+ * @since 1.5
325
+ *
326
+ * @return string HTML
327
+ */
328
+ protected function display_yikes_button_holder_container_duplicate() {
329
+ $return_html = '';
330
+
331
+ $return_html .= '<section class="button-holder" alt="">';
332
+ $return_html .= '<div class="yikes_wc_move_tab_container">';
333
+ $return_html .= '<p class="yikes_wc_move_tab">Move tab order</p>';
334
+ $return_html .= '<span class="dashicons dashicons-arrow-up move-tab-data-up"></span>';
335
+ $return_html .= '<span class="dashicons dashicons-arrow-down move-tab-data-down"></span>';
336
+ $return_html .= '</div>';
337
+ $return_html .= '<a href="#" onclick="return false;" class="button-secondary remove_this_tab">';
338
+ $return_html .= '<span class="dashicons dashicons-no-alt"></span>';
339
+ $return_html .= __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
340
+ $return_html .= '</a>';
341
+ $return_html .= '</section>';
342
+
343
+ return $return_html;
344
+ }
345
+
346
+ /**
347
+ * Add hidden input field for number of tabs to page
348
+ *
349
+ * @since 1.5
350
+ *
351
+ * @return string HTML
352
+ */
353
+ protected function display_yikes_number_of_tabs( $tab_count ) {
354
+ $return_html = '';
355
+
356
+ $return_html .= '<input type="hidden" value="' . $tab_count . '" id="number_of_tabs" name="number_of_tabs" >';
357
+
358
+ return $return_html;
359
+ }
360
+
361
+ /**
362
+ * Add 'Add Another Tab' and 'Add a Saved Tab' buttons to page
363
+ *
364
+ * @since 1.5
365
+ *
366
+ * @param bool | $product_has_tabs | flag indicating whether the product has any defined tabs
367
+ * @return string HTML
368
+ */
369
+ protected function display_yikes_add_tabs_container( $product_has_tabs ) {
370
+ $return_html = '';
371
+
372
+ // If we don't have any tabs, then add some classes
373
+ $classes_to_add = ( $product_has_tabs === false ) ? '_yikes_wc_add_tab_center_new _yikes_wc_add_tab_center' : '';
374
+
375
+ $return_html .= '<div class="add_tabs_container ' . $classes_to_add . '">';
376
+ $return_html .= '<span id="yikes_woo_ajax_save_feedback"></span>';
377
+ $return_html .= '<a href="#" class="button-secondary _yikes_wc_add_tabs" id="add_another_tab">';
378
+ $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
379
+ $return_html .= __( 'Add a Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
380
+ $return_html .= '</a>';
381
+ $return_html .= '<span class="yikes_wc_apply_reusable_tab_container">';
382
+ $return_html .= '<span class="button-secondary _yikes_wc_apply_a_saved_tab _yikes_wc_add_tabs" id="_yikes_wc_apply_a_saved_tab">';
383
+ $return_html .= '<i class="dashicons dashicons-plus-alt inline-button-dashicons"></i>';
384
+ $return_html .= __( 'Add a Saved Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' );
385
+ $return_html .= '</span>';
386
+ $return_html .= '</span>';
387
+ $return_html .= '<input name="save" class="button button-primary" id="yikes_woo_save_custom_tabs" value="Save Tabs" type="button">';
388
+ $return_html .= '</div>';
389
+
390
+ return $return_html;
391
+ }
392
+
393
+ /**
394
+ * Generates a textarea field for hidden duplicate HTML block
395
+ *
396
+ * @param array $field Array of HTML field related values
397
+ */
398
+ private function woocommerce_wp_textarea_input( $field ) {
399
+ global $thepostid, $post;
400
+
401
+ if ( ! $thepostid ) $thepostid = $post->ID;
402
+ if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
403
+ if ( ! isset( $field['class'] ) ) $field['class'] = 'short';
404
+ if ( ! isset( $field['value'] ) ) $field['value'] = get_post_meta( $thepostid, $field['id'], true );
405
+
406
+ 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> ';
407
+
408
+ if ( isset( $field['description'] ) && $field['description'] ) {
409
+ echo '<span class="description">' . $field['description'] . '</span>';
410
+ }
411
+
412
+ echo '</p>';
413
+ }
414
+
415
+ /**
416
+ * Wrapper function for wp_editor
417
+ *
418
+ * @param array $field Array of HTML field related values
419
+ */
420
+ private function woocommerce_wp_wysiwyg_input( $field ) {
421
+ global $thepostid, $post;
422
+
423
+ if ( ! $thepostid ) $thepostid = $post->ID;
424
+ if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
425
+ if ( ! isset( $field['class'] ) ) $field['class'] = 'short';
426
+ if ( ! isset( $field['value'] ) ) $field['value'] = get_post_meta( $thepostid, $field['id'], true );
427
+
428
+ $editor_settings = array(
429
+ 'textarea_name' => $field['id']
430
+ );
431
+
432
+ wp_editor( $field['value'], $field['id'], $editor_settings );
433
+
434
+ if ( isset( $field['description'] ) && $field['description'] ) {
435
+ echo '<span class="description">' . $field['description'] . '</span>';
436
+ }
437
+ }
438
+
439
+ /* END HTML Functions */
440
+ }
441
+ }
442
+
443
+ ?>
admin/page.yikes-woo-saved-tabs-single.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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> Oops. It looks like something went wrong. Please <a href="' . $redirect . '" title="go back">go back</a> and try again</p>';
8
+ }
9
+ exit;
10
+ }
11
+
12
+ // Set variables before using them
13
+ $tab_title = ( isset( $tab['tab_title'] ) && ! empty( $tab['tab_title'] ) ) ? $tab['tab_title'] : '';
14
+ $tab_content = ( isset( $tab['tab_content'] ) && ! empty( $tab['tab_content'] ) ) ? $tab['tab_content'] : '';
15
+ $tab_id = ( isset( $tab['tab_id'] ) && ! empty( $tab['tab_id'] ) ) ? (int) $tab['tab_id'] : 'new';
16
+
17
+ // Tab stats
18
+ $number_of_products_using_this_tab = count( $products );
19
+
20
+ ?>
21
+ <div class="wrap">
22
+ <h1 class="screen-media">
23
+ Custom Product Tabs for WooCommerce | <span id="yikes_woo_tab_title_header"><?php echo $tab_title; ?></span>
24
+ <span class="yikes_woo_tab_id page-title-action">ID: <?php echo $tab_id; ?></span>
25
+ </h1>
26
+
27
+ <?php if ( $new_tab !== true ) { ?>
28
+ <!-- Only show this if we're updating an existing tab -->
29
+ <div class="yikes_woo_settings_info">
30
+ <p>
31
+ <?php _e( "Any updates made here will apply to all products using this tab.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
32
+ </p>
33
+ </div>
34
+ <?php } ?>
35
+
36
+ <div id="poststuff">
37
+
38
+ <div class="yikes_woo_go_back_url">
39
+ <a href="<?php echo $redirect; ?>"><?php _e( 'Go Back to Saved Tabs list', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
40
+ </div>
41
+
42
+ <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; ?>">
43
+
44
+ <!-- Title -->
45
+ <div class="yikes_woo_reusable_tab_title">
46
+ <label class="yikes_woo_reusable_tab_title_label" for="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>">
47
+ <h3><?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
48
+ </label>
49
+ <input type="text" id="yikes_woo_reusable_tab_title_<?php echo $tab_id; ?>" value="<?php echo $tab_title; ?>" />
50
+ </div>
51
+
52
+ <!-- Content -->
53
+ <div class="yikes_woo_reusable_tab_content">
54
+ <label class="yikes_woo_reusable_tab_content_label" for="yikes_woo_reusable_tab_content_<?php echo $tab_id; ?>">
55
+ <h3><?php _e( 'Tab Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></h3>
56
+ </label>
57
+ <?php
58
+ 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 ) );
59
+ ?>
60
+ </div>
61
+
62
+ <!-- Buttons -->
63
+ <div class="yikes_woo_save_and_delete_tab_buttons">
64
+ <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; ?>">
65
+ <?php _e( 'Save Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
66
+ </span>
67
+ <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; ?>">
68
+ <i class="dashicons dashicons-dismiss inline-button-dashicons"></i>
69
+ <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
70
+ </span>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="yikes_woo_saved_tab_products">
75
+ <h3 class="yikes_woo_saved_tab_header">Products</h3>
76
+ <div class="inside entry-details-overview">
77
+ <?php if ( $number_of_products_using_this_tab === 0 ) { ?>
78
+ <p>
79
+ This tab is currently not used for any products.
80
+ </p>
81
+ <?php } else {
82
+ $plural_product_name = ( $number_of_products_using_this_tab > 1 ) ? 'products' : 'product';
83
+ ?>
84
+ <p>
85
+ This tab is currently used on <span class="yikes_woo_number_of_products"><?php echo $number_of_products_using_this_tab; ?></span> <?php echo $plural_product_name ?>
86
+ </p>
87
+ <?php foreach( $products as $product_id ) { ?>
88
+ <p>
89
+ <?php $edit_product_url = add_query_arg( array( 'post' => $product_id, 'action' => 'edit' ), esc_url_raw( 'post.php' ) ); ?>
90
+ <span> <a href="<?php echo $edit_product_url ?>"> <?php echo get_the_title( $product_id ); ?> </a> </span>
91
+ </p>
92
+ <?php } ?>
93
+ <?php } ?>
94
+ </div>
95
+ </div>
96
+ </div>
97
+ </div>
admin/page.yikes-woo-saved-tabs.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="wrap">
2
+
3
+ <h1>
4
+ Custom Product Tabs for WooCommerce | Saved Tabs
5
+ <span class="yikes_woo_add_another_tab page-title-action" id="yikes_woo_add_another_tab">
6
+ <a href="<?php echo $new_tab_url; ?>"> <?php _e( 'Add Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </a>
7
+ </span>
8
+ </h1>
9
+
10
+ <!-- Delete-success Message -->
11
+ <div id="yikes_woo_delete_success_message" class="deleted notice notice-success is-dismissible" style="<?php echo $delete_message_display ?>">
12
+ <p>
13
+ <?php _e( 'Tab deleted!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
14
+ </p>
15
+ <button type="button" class="notice-dismiss">
16
+ <span class="screen-reader-text">Dismiss this notice.</span>
17
+ </button>
18
+ </div>
19
+
20
+ <div class="yikes_woo_settings_info">
21
+ <p>
22
+ <?php _e( "Create and save tabs you can add to multiple products.", 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
23
+ </p>
24
+ </div>
25
+
26
+ <div id="poststuff">
27
+
28
+ <!-- Bulk Actions -->
29
+ <div class="tablenav top">
30
+ <div class="alignleft actions bulkactions">
31
+ <label for="bulk-action-selector-top" class="screen-reader-text"><?php _e( 'Select bulk action', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
32
+ <select name="action" id="bulk-action-selector-top">
33
+ <option value="-1"><?php _e( 'Bulk Actions', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
34
+ <option value="delete" class="hide-if-no-js"><?php _e( 'Delete', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></option>
35
+ </select>
36
+ <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' ) ?>">
37
+ </div>
38
+ <br class="clear">
39
+ </div>
40
+ <table class="widefat fixed" cellspacing="0">
41
+ <thead>
42
+ <tr>
43
+ <td id="cb" class="manage-column column-cb check-column" scope="col">
44
+ <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
45
+ <input id="cb-select-all-1" type="checkbox">
46
+ </td>
47
+ <th id="columnname" class="manage-column column-columnname" scope="col">
48
+ <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
49
+ </th>
50
+ <th id="columnname" class="manage-column column-columnname" scope="col">
51
+ <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
52
+ </th>
53
+ <th id="columnname" class="manage-column column-columnname" scope="col">&nbsp;</th>
54
+ </tr>
55
+ </thead>
56
+
57
+ <tfoot>
58
+ <tr>
59
+ <td id="cb" class="manage-column column-cb check-column" scope="col">
60
+ <label class="screen-reader-text" for="cb-select-all-1"><?php _e( 'Select All', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></label>
61
+ <input id="cb-select-all-1" type="checkbox">
62
+ </td>
63
+ <th id="columnname" class="manage-column column-columnname" scope="col">
64
+ <?php _e( 'Tab Title', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
65
+ </th>
66
+ <th id="columnname" class="manage-column column-columnname" scope="col">
67
+ <?php _e( 'Tab Content Preview', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
68
+ </th>
69
+ <th id="columnname" class="manage-column column-columnname" scope="col">&nbsp;</th>
70
+ </tr>
71
+ </tfoot>
72
+
73
+ <tbody>
74
+ <?php
75
+ if( ! empty( $yikes_custom_tab_data ) ) {
76
+
77
+ foreach ( $yikes_custom_tab_data as $key => $tab_data ) {
78
+
79
+ // Set variables before using them
80
+ $tab_title = ( isset( $tab_data['tab_title'] ) && ! empty( $tab_data['tab_title'] ) ) ? $tab_data['tab_title'] : '';
81
+ $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 ) ) : '';
82
+ $tab_id = ( isset( $tab_data['tab_id'] ) && ! empty( $tab_data['tab_id'] ) ) ? (int) $tab_data['tab_id'] : 0;
83
+ $edit_tab_url = ( isset( $settings_page_slug ) ) ? add_query_arg( array( 'saved-tab-id' => $tab_id ), esc_url_raw( 'options-general.php?page=' . $settings_page_slug ) ) : '';
84
+ ?>
85
+ <tr class="yikes_woo_saved_tabs_row" id="yikes_woo_saved_tabs_row_<?php echo $tab_id; ?>" data-tab-id="<?php echo $tab_id; ?>">
86
+ <th class="check-column" scope="row">
87
+ <input class="entry-bulk-action-checkbox" type="checkbox" value="<?php echo $tab_id; ?>" />
88
+ </th>
89
+ <td class="column-columnname">
90
+ <?php echo $tab_title; ?>
91
+ <div class="row-actions">
92
+ <span class="">
93
+ <a href="<?php echo $edit_tab_url ?>"><?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
94
+ </span> |
95
+ <span data-tab-id="<?php echo $tab_id; ?>" class="yikes_woo_delete_this_tab trash">
96
+ <?php _e( 'Delete Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
97
+ </span>
98
+ </div>
99
+ </td>
100
+ <td class="column-columnname"><?php echo $tab_content_excerpt; ?></td>
101
+ <td class="column-columnname" align="center">
102
+ <a href="<?php echo $edit_tab_url ?>" class="button-secondary view-saved-tab-button" data-entry-id="<?php echo (int) $tab_id; ?>">
103
+ <?php _e( 'Edit Tab', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?>
104
+ </a>
105
+ </td>
106
+ </tr>
107
+ <?php
108
+ }
109
+ } else {
110
+ ?>
111
+ <tr>
112
+ <td class="column-columnname" colspan="5">
113
+ <strong><?php _e( 'There are no saved tabs. Add one!', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?> </strong>
114
+ </td>
115
+ </tr>
116
+ <?php
117
+ }
118
+ ?>
119
+ </tbody>
120
+ </table>
121
+ </div>
122
+ </div>
css/dist/lity.min.css ADDED
@@ -0,0 +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{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}
css/font/yikes-woo-font.svg CHANGED
@@ -1,11 +1,11 @@
1
- <?xml version="1.0" standalone="no"?>
2
- <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
- <svg xmlns="http://www.w3.org/2000/svg">
4
- <metadata>Generated by IcoMoon</metadata>
5
- <defs>
6
- <font id="yikes-woo-font" horiz-adv-x="1024">
7
- <font-face units-per-em="1024" ascent="960" descent="-64" />
8
- <missing-glyph horiz-adv-x="1024" />
9
- <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
- <glyph unicode="&#xe600;" d="M0 531.478v-428.522h272.696l0.558-65.112c0.558-36.174 0.558-71.236 0.558-77.914-0.558-7.236 0.558-12.8 1.67-12.8s39.512 35.062 84.592 77.914l81.81 77.914h415.164v857.044h-857.044v-428.522zM516.452 719.582c3.896-3.896 6.678-10.016 6.678-13.914 0-7.236-133.564-330.574-148.034-358.956-12.8-24.486-46.748-18.366-46.748 8.348 0 9.462 72.348 188.104 129.112 320 20.036 46.192 23.93 51.2 37.286 51.2 8.348 0 17.81-2.784 21.704-6.678zM289.392 662.818c0-36.73-1.112-41.74-11.13-45.078-6.122-1.67-33.948-15.584-61.774-30.052l-50.644-27.27 61.774-32.278 61.774-32.834v-40.626c0-22.816-2.226-40.070-4.452-38.958-2.226 1.114-51.2 26.712-108.522 56.764l-104.070 55.652v64.558l26.712 14.47c114.088 62.33 177.53 95.722 183.652 96.278 4.452 0.558 6.678-11.13 6.678-40.626zM672.836 648.348l100.73-52.87v-69.010l-70.678-37.288c-39.514-20.592-86.818-45.634-105.74-56.21l-35.062-18.922v83.478l44.522 23.374c25.6 13.356 42.852 25.6 40.626 28.938-1.67 3.34-0.558 3.896 2.784 1.67 3.34-2.226 12.8-0.558 20.034 3.34 13.356 7.236 11.688 8.348-47.304 37.842l-60.662 30.61v40.626c0 22.818 2.226 40.070 5.010 38.956 2.784-0.558 50.086-25.6 105.74-54.538z" horiz-adv-x="858" />
11
  </font></defs></svg>
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
3
+ <svg xmlns="http://www.w3.org/2000/svg">
4
+ <metadata>Generated by IcoMoon</metadata>
5
+ <defs>
6
+ <font id="yikes-woo-font" horiz-adv-x="1024">
7
+ <font-face units-per-em="1024" ascent="960" descent="-64" />
8
+ <missing-glyph horiz-adv-x="1024" />
9
+ <glyph unicode="&#x20;" d="" horiz-adv-x="512" />
10
+ <glyph unicode="&#xe600;" d="M0 531.478v-428.522h272.696l0.558-65.112c0.558-36.174 0.558-71.236 0.558-77.914-0.558-7.236 0.558-12.8 1.67-12.8s39.512 35.062 84.592 77.914l81.81 77.914h415.164v857.044h-857.044v-428.522zM516.452 719.582c3.896-3.896 6.678-10.016 6.678-13.914 0-7.236-133.564-330.574-148.034-358.956-12.8-24.486-46.748-18.366-46.748 8.348 0 9.462 72.348 188.104 129.112 320 20.036 46.192 23.93 51.2 37.286 51.2 8.348 0 17.81-2.784 21.704-6.678zM289.392 662.818c0-36.73-1.112-41.74-11.13-45.078-6.122-1.67-33.948-15.584-61.774-30.052l-50.644-27.27 61.774-32.278 61.774-32.834v-40.626c0-22.816-2.226-40.070-4.452-38.958-2.226 1.114-51.2 26.712-108.522 56.764l-104.070 55.652v64.558l26.712 14.47c114.088 62.33 177.53 95.722 183.652 96.278 4.452 0.558 6.678-11.13 6.678-40.626zM672.836 648.348l100.73-52.87v-69.010l-70.678-37.288c-39.514-20.592-86.818-45.634-105.74-56.21l-35.062-18.922v83.478l44.522 23.374c25.6 13.356 42.852 25.6 40.626 28.938-1.67 3.34-0.558 3.896 2.784 1.67 3.34-2.226 12.8-0.558 20.034 3.34 13.356 7.236 11.688 8.348-47.304 37.842l-60.662 30.61v40.626c0 22.818 2.226 40.070 5.010 38.956 2.784-0.558 50.086-25.6 105.74-54.538z" horiz-adv-x="858" />
11
  </font></defs></svg>
css/repeatable-custom-tabs.css CHANGED
@@ -1 +1 @@
1
- .yikes_woo_tabs_title_field {
2
  position: absolute;
3
  right: 1em;
4
  top: 12px;
5
  border-top: 1px solid #a0a5aa;
6
  width: 100%;
7
  white-space: nowrap;
8
  max-width: 79%;
9
  max-width: 100%;
1
+ .yikes_woo_tabs_title_field {
2
  position: absolute;
3
  right: 1em;
4
  top: 12px;
5
  border-top: 1px solid #a0a5aa;
6
  width: 100%;
7
  white-space: nowrap;
8
  max-width: 79%;
9
  max-width: 100%;
css/repeatable-custom-tabs.min.css CHANGED
@@ -1,8 +1 @@
1
- /*
2
- * Minified Styles for YIKES Inc. Easy WooCommerce Repeatable Product Tabs
3
- *
4
- * @ Compiled By: Yikes Inc.
5
- * @ http://www.YIKESinc.com
6
- *
7
- */
8
- .yikes_woo_tabs_title_field{width:70%!important}#duplicate_this_row{display:none}a[href="#yikes_woocommerce_custom_product_tabs"]:before{font-family:yikes-woo-font!important;content:"\e600"!important;font-size:15px!important;display:block;float:left;margin-top:2px}#add_another_tab{float:right;margin-right:2em;background:#cc99c2;border-color:#b366a4;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);color:#fff;text-deconartion:none!important}#yikes_woocommerce_custom_product_tabs hr{margin:1.5em 2em 1.5em 1em}.yikes-woo-custom-tab-divider{display:block;width:92%;height:2px;margin:1.5em 0 1.5em 1em;border-bottom:1px solid rgba(182,182,182,.35)}#yikes_woocommerce_custom_product_tabs div.yikes-woo-custom-tab-divider:last-child{display:none!important}#yikes_woocommerce_custom_product_tabs .wp-editor-wrap{padding:5px 60px 5px 162px!important}.yikes-custom-wysiwyg-label{margin-left:1em!important;line-height:3;}.yikes-logo{position:absolute;top:0;right:0;margin-top:.75em;margin-right:.75em;opacity:.85}#yikes-woo-tabs-review-us{float:right}.yikes-woo-tabs-hidden-how-to-info{display:none;margin-top:.75em;padding-top:.5em;font-family:"Open Sans",sans-serif!important}.yikes-tabs-how-to-toggle{font-size:20px;padding:0 .5em;margin-top:.5em}.yikes-tabs-how-to-toggle:hover{cursor:pointer}.move-tab-data-down,.move-tab-data-up{font-size:25px;transition:color .2s}.move-tab-data-down:hover,.move-tab-data-up:hover{cursor:pointer;color:#4c9cce}.button-holder{float:right;margin-right:4.25em;width:117px;margin-top:.5em}@font-face{font-family:yikes-woo-font;src:url(./font/yikes-woo-font.eot?-394dt5);src:url(./font/yikes-woo-font.eot?#iefix-394dt5) format('embedded-opentype'),url(./font/yikes-woo-font.woff?-394dt5) format('woff'),url(./font/yikes-woo-font.ttf?-394dt5) format('truetype'),url(./font/yikes-woo-font.svg?-394dt5#yikes-woo-font) format('svg');font-weight:400;font-style:normal}[class*=" yikes-woo-"],[class^=yikes-woo-]{font-family:yikes-woo-font;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.yikes-woo-uniE600:before{content:"\e600"}
1
+ .yikes_woo_tabs_title_field{width:70%!important}#duplicate_this_row{display:none}a[href="#yikes_woocommerce_custom_product_tabs"]:before{font-family:yikes-woo-font!important;content:"\e600"!important;font-size:15px!important;display:block;float:left;margin-top:2px}#yikes_woocommerce_custom_product_tabs hr{margin:1.5em 0}#yikes_woocommerce_custom_product_tabs .options_group{padding:0 1em}#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel div.form-field-tinymce,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field-tinymce{max-width:85%;padding-left:0}#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field{padding:5px 0!important}#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel .form-field label{font-size:1.1em;font-weight:700;margin:2px 8px 0 0;width:auto}.yikes-woo-custom-tab-divider{display:block;height:2px;margin:2em 0 1.5em;border-bottom:1px solid #0073aa}.yikes-custom-wysiwyg-label{margin-left:1em;line-height:3}.yikes-logo{position:absolute;top:0;right:0;margin-top:.75em;margin-right:.75em;opacity:.85}#yikes-woo-tabs-review-us{float:right}.yikes-woo-tabs-hidden-how-to-info{display:none;font-family:"Open Sans",sans-serif!important;margin-right:30px}.woocommerce_options_panel p.yikes_woo_how_to_info{margin:9px 0 0;padding:0;text-align:right}.yikes-tabs-how-to-toggle{font-size:20px;position:absolute;right:1em;top:12px}.yikes-tabs-how-to-toggle:hover{cursor:pointer}.move-tab-data-down,.move-tab-data-up{font-size:25px;transition:color .2s}.move-tab-data-down:hover,.move-tab-data-up:hover{cursor:pointer;color:#4c9cce}.button-holder{margin-top:-190px;position:absolute;right:1em;width:110px}.yikes_wc_move_tab_container{margin-top:.5em;text-align:center}.woocommerce_options_panel p.yikes_wc_move_tab{line-height:1;margin:0;padding:0}.button-holder .button-secondary.remove_this_tab{background:#e35b5b;border-color:#dc3232;box-shadow:0 1px 0 #dc3232;color:#fff;cursor:pointer;margin-top:20px}.button-holder .button-secondary.remove_this_tab .dashicons{margin-top:-2px;vertical-align:middle}@font-face{font-family:yikes-woo-font;src:url(font/yikes-woo-font.eot?-394dt5);src:url(font/yikes-woo-font.eot?#iefix-394dt5) format('embedded-opentype'),url(font/yikes-woo-font.woff?-394dt5) format('woff'),url(font/yikes-woo-font.ttf?-394dt5) format('truetype'),url(font/yikes-woo-font.svg?-394dt5#yikes-woo-font) format('svg');font-weight:400;font-style:normal}[class*=" yikes-woo-"],[class^=yikes-woo-]{font-family:yikes-woo-font;speak:none;font-style:normal;font-weight:400;font-variant:normal;text-transform:none;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.yikes-woo-uniE600:before{content:"\e600"}.loading-wp-editor-gif{padding-left:350px}.loading-wp-editor-gif-settings{padding-left:50px}.dashicons.inline-button-dashicons{font-size:15px;vertical-align:bottom}.yikes_woo_save_success{color:#31843f;float:left;padding-top:1em}._yikes_wc_add_tab_center,.add_tabs_container{border-top:1px solid #a0a5aa;margin:2em 2px 0 0;text-align:right;width:100%}.add_tabs_container .button.button-primary{margin-top:10px}._yikes_wc_add_tab_center{border-top:none;text-align:center}#_yikes_wc_apply_a_saved_tab,#add_another_tab{background:#cc99c2;border-color:#b366a4;color:#fff;text-decoration:none!important}.add_tabs_container._yikes_wc_add_tab_center_new .button.button-primary{display:none}#add_another_tab{-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);margin-bottom:10px;margin-top:10px}#_yikes_wc_apply_a_saved_tab{-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);box-shadow:inset 0 1px 0 rgba(255,255,255,.25),0 1px 0 rgba(0,0,0,.15);margin:10px 0 0 8px}._yikes_wc_feedback_message{display:none;padding-left:3px}#yikes_woo_tab_error_message{color:red}#yikes_woo_tab_success_message{color:#31843f;margin-top:4px}.yikes_woo_how_to_h3{padding-left:10px;margin-top:0;font-weight:700}.yikes_woo_how_to_info,.yikes_woo_how_to_note{padding-left:23px!important}.yikes_woo_how_to_note{font-style:italic}.yikes-tabs-how-to-toggle-cursor{cursor:pointer}.yikes_woo_settings_info{font-family:"Open Sans",sans-serif}.yikes_woo_using_reusable_tab{opacity:.6;pointer-events:none}.lity-container{background:#fff;border-radius:6px;padding:.6em 1em 1em}.lity-container .lity-content::after{box-shadow:none}[class*=yikes_wc_lity_col]{float:left}.yikes_wc_lity_col_title{width:93%;padding:4px 20px 4px 2px;white-space:nowrap}.yikes_wc_lity_col_select{width:7%;padding-right:8px;padding-top:4px;cursor:pointer}.yikes_wc_lity_header{border-bottom:1px solid #555d66;margin-bottom:.4em;line-height:1;font-size:1.2em;font-weight:700;padding:0 0 8px;text-align:center;width:100%}.yikes_wc_lity_header>span{width:100px;text-align:center;white-space:nowrap}.display_saved_tabs_lity{min-width:300px}.yikes_woo_delete_this_tab{color:#0073aa;cursor:pointer}.yikes_woo_delete_this_tab:hover{color:#00a0d2}.yikes_woo_reusable_tab_title>input{width:100%}.yikes_woo_reusable_tab_content>label h3,.yikes_woo_reusable_tab_title>label h3{margin-bottom:6px}.yikes_woo_reusable_tab_content,.yikes_woo_reusable_tab_title{margin-bottom:20px}.wp-core-ui .button-secondary.yikes_woo_delete_this_tab{background:#e35b5b;border-color:#dc3232;box-shadow:0 1px 0 #dc3232;color:#fff;cursor:pointer}.yikes_woo_add_another_tab:hover>a{color:#fff}.yikes_woo_number_of_products{font-weight:700}.yikes_woo_save_and_delete_tab_buttons{margin-top:10px}._yikes_wc_title_red_overlay{background-color:#e68989!important}.woocommerce_options_panel p.yikes_wc_override_reusable_tab_container{line-height:1.1;margin-top:0;position:absolute;right:1em}.woocommerce_options_panel label._yikes_wc_override_reusable_tab_label{margin:2px 0 0 4px;float:none}@media screen and (max-width:1500px){#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel div.form-field-tinymce,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field-tinymce{max-width:79%}.woocommerce_options_panel p.yikes_wc_override_reusable_tab_container{max-width:100px}}@media screen and (max-width:1300px){.button-holder{margin-top:8px;position:relative;right:auto;text-align:center;width:100%}.woocommerce_options_panel p.yikes_wc_move_tab,.yikes_wc_move_tab_container{display:inline-block}.move-tab-data-down,.move-tab-data-up{margin-top:-5px}.button-holder .button-secondary.remove_this_tab{margin-left:26px;margin-top:0}#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel div.form-field-tinymce,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field,#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.form-field-tinymce{max-width:100%}.woocommerce_options_panel p.yikes_wc_override_reusable_tab_container{margin-bottom:0;max-width:100%;position:relative}#yikes_woocommerce_custom_product_tabs.woocommerce_options_panel p.yikes_woo_using_reusable_tab{margin-top:0}}
 
 
 
 
 
 
 
css/yikes-woo-tabs-font.css CHANGED
@@ -1,28 +1,28 @@
1
- @font-face {
2
- font-family: 'yikes-woo-font';
3
- src:url('./font/yikes-woo-font.eot?-394dt5');
4
- src:url('./font/yikes-woo-font.eot?#iefix-394dt5') format('embedded-opentype'),
5
- url('./font/yikes-woo-font.woff?-394dt5') format('woff'),
6
- url('./font/yikes-woo-font.ttf?-394dt5') format('truetype'),
7
- url('./font/yikes-woo-font.svg?-394dt5#yikes-woo-font') format('svg');
8
- font-weight: normal;
9
- font-style: normal;
10
- }
11
-
12
- [class^="yikes-woo-"], [class*=" yikes-woo-"] {
13
- font-family: 'yikes-woo-font';
14
- speak: none;
15
- font-style: normal;
16
- font-weight: normal;
17
- font-variant: normal;
18
- text-transform: none;
19
- line-height: 1;
20
-
21
- /* Better Font Rendering =========== */
22
- -webkit-font-smoothing: antialiased;
23
- -moz-osx-font-smoothing: grayscale;
24
- }
25
-
26
- .yikes-woo-uniE600:before {
27
- content: "\e600";
28
  }
1
+ @font-face {
2
+ font-family: 'yikes-woo-font';
3
+ src:url('./font/yikes-woo-font.eot?-394dt5');
4
+ src:url('./font/yikes-woo-font.eot?#iefix-394dt5') format('embedded-opentype'),
5
+ url('./font/yikes-woo-font.woff?-394dt5') format('woff'),
6
+ url('./font/yikes-woo-font.ttf?-394dt5') format('truetype'),
7
+ url('./font/yikes-woo-font.svg?-394dt5#yikes-woo-font') format('svg');
8
+ font-weight: normal;
9
+ font-style: normal;
10
+ }
11
+
12
+ [class^="yikes-woo-"], [class*=" yikes-woo-"] {
13
+ font-family: 'yikes-woo-font';
14
+ speak: none;
15
+ font-style: normal;
16
+ font-weight: normal;
17
+ font-variant: normal;
18
+ text-transform: none;
19
+ line-height: 1;
20
+
21
+ /* Better Font Rendering =========== */
22
+ -webkit-font-smoothing: antialiased;
23
+ -moz-osx-font-smoothing: grayscale;
24
+ }
25
+
26
+ .yikes-woo-uniE600:before {
27
+ content: "\e600";
28
  }
js/lity.min.js ADDED
@@ -0,0 +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});
js/repeatable-custom-tabs-settings.js ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ var tab_title = jQuery( '#yikes_woo_reusable_tab_title_' + tab_id ).val();
81
+ var tab_content = '';
82
+
83
+ if ( typeof( tinymce ) != 'undefined' && jQuery( '#wp-yikes_woo_reusable_tab_content_' + tab_id + '-wrap' ).hasClass( 'tmce-active' ) ) {
84
+ tab_content = tinymce.get( 'yikes_woo_reusable_tab_content_' + tab_id ).getContent();
85
+ } else {
86
+ tab_content = jQuery( '#yikes_woo_reusable_tab_content_' + tab_id ).val();
87
+ }
88
+
89
+ //If no tab_title || tab_content, show error message
90
+ if ( tab_title.length === 0 ) {
91
+ 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.', {} );
92
+ return;
93
+ }
94
+ if ( tab_content.length === 0 ) {
95
+ 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.', {} );
96
+ return;
97
+ }
98
+
99
+ // Create data object
100
+ var data = {
101
+ 'action': 'yikes_woo_save_tab_as_reusable',
102
+ 'tab_title': tab_title,
103
+ 'tab_content': tab_content,
104
+ 'tab_id': tab_id,
105
+ 'security_nonce': repeatable_custom_tabs_settings.save_tab_as_reusable_nonce
106
+ };
107
+
108
+ // AJAX
109
+ jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
110
+ if ( typeof( response.success ) !== 'undefined' && response.success === true ) {
111
+
112
+ // If redirect var is set, redirect!
113
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect ) !== 'undefined'
114
+ && response.data.redirect === true && typeof( response.data.redirect_url !== 'undefined' ) ) {
115
+ location.href = response.data.redirect_url;
116
+ } else {
117
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_success_message', 'Tab saved successfully.', {} );
118
+ }
119
+
120
+ jQuery( '#yikes_woo_tab_title_header' ).text( tab_title );
121
+ } else {
122
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.message ) !== 'undefined' ) {
123
+ yikes_woo_display_feedback_messages( '#yikes_woo_delete_this_tab_' + tab_id, 'yikes_woo_tab_error_message', response.data.message, {} );
124
+ } else {
125
+
126
+ // Ok, not sure what went wrong. Let's log it.
127
+ console.log( response );
128
+ }
129
+ }
130
+ });
131
+ }
132
+
133
+ /**
134
+ * @summary Delete a saved tab
135
+ *
136
+ * @since 1.5
137
+ *
138
+ * @param int | tab_id | the tab's unique ID in the database
139
+ * @param string | delete_method | a string signifying what to do after deleting tabs
140
+ *
141
+ */
142
+ function yikes_woo_handle_deleting_reusable_tab( tab_id, delete_method ) {
143
+
144
+ // Create data object
145
+ var data = {
146
+ action: 'yikes_woo_delete_reusable_tab_handler',
147
+ tab_id: tab_id,
148
+ security_nonce: repeatable_custom_tabs_settings.delete_reusable_tab_nonce
149
+ }
150
+
151
+ // AJAX
152
+ jQuery.post( repeatable_custom_tabs_settings.ajaxurl, data, function( response ) {
153
+ if ( response.success ) {
154
+
155
+ if ( delete_method === 'bulk' ) {
156
+
157
+ // fadeOut and remove all of the rows at once
158
+ jQuery( '.yikes_woo_bulk_delete_this_row' ).fadeOut( '600', function() {
159
+ jQuery( '.yikes_woo_bulk_delete_this_row' ).remove();
160
+ });
161
+ } else if ( delete_method === 'single' ) {
162
+
163
+ // If we have a redirect URL, redirect back to tab list
164
+ if ( typeof( response.data ) !== 'undefined' && typeof( response.data.redirect_url ) !== 'undefined' ) {
165
+ location.href = response.data.redirect_url;
166
+ }
167
+ } else {
168
+
169
+ // Remove the tab container
170
+ jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).fadeOut( '600', function() {
171
+ jQuery( '#yikes_woo_saved_tabs_row_' + tab_id ).remove();
172
+
173
+ // Display our delete-success message
174
+ jQuery( '#yikes_woo_delete_success_message' ).show();
175
+ });
176
+ }
177
+ } else {
178
+
179
+ // Ok, not sure what went wrong. Let's log it.
180
+ console.log( response );
181
+ }
182
+ });
183
+ }
js/repeatable-custom-tabs-settings.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function yikes_woo_handle_saving_reusable_tab(a){var b=jQuery("#yikes_woo_reusable_tab_title_"+a).val(),c="";if(c="undefined"!=typeof tinymce&&jQuery("#wp-yikes_woo_reusable_tab_content_"+a+"-wrap").hasClass("tmce-active")?tinymce.get("yikes_woo_reusable_tab_content_"+a).getContent():jQuery("#yikes_woo_reusable_tab_content_"+a).val(),0===b.length)return void yikes_woo_display_feedback_messages("#yikes_woo_delete_this_tab_"+a,"yikes_woo_tab_error_message","Please fill out the tab title before saving.",{});if(0===c.length)return void yikes_woo_display_feedback_messages("#yikes_woo_delete_this_tab_"+a,"yikes_woo_tab_error_message","Please fill out the tab content before saving.",{});var d={action:"yikes_woo_save_tab_as_reusable",tab_title:b,tab_content:c,tab_id:a,security_nonce:repeatable_custom_tabs_settings.save_tab_as_reusable_nonce};jQuery.post(repeatable_custom_tabs_settings.ajaxurl,d,function(c){"undefined"!=typeof c.success&&c.success===!0?("undefined"==typeof c.data||"undefined"==typeof c.data.redirect||c.data.redirect!==!0||("undefined"!==c.data.redirect_url,0)?yikes_woo_display_feedback_messages("#yikes_woo_delete_this_tab_"+a,"yikes_woo_tab_success_message","Tab saved successfully.",{}):location.href=c.data.redirect_url,jQuery("#yikes_woo_tab_title_header").text(b)):"undefined"!=typeof c.data&&"undefined"!=typeof c.data.message?yikes_woo_display_feedback_messages("#yikes_woo_delete_this_tab_"+a,"yikes_woo_tab_error_message",c.data.message,{}):console.log(c)})}function yikes_woo_handle_deleting_reusable_tab(a,b){var c={action:"yikes_woo_delete_reusable_tab_handler",tab_id:a,security_nonce:repeatable_custom_tabs_settings.delete_reusable_tab_nonce};jQuery.post(repeatable_custom_tabs_settings.ajaxurl,c,function(c){c.success?"bulk"===b?jQuery(".yikes_woo_bulk_delete_this_row").fadeOut("600",function(){jQuery(".yikes_woo_bulk_delete_this_row").remove()}):"single"===b?"undefined"!=typeof c.data&&"undefined"!=typeof c.data.redirect_url&&(location.href=c.data.redirect_url):jQuery("#yikes_woo_saved_tabs_row_"+a).fadeOut("600",function(){jQuery("#yikes_woo_saved_tabs_row_"+a).remove(),jQuery("#yikes_woo_delete_success_message").show()}):console.log(c)})}jQuery(document).ready(function(){jQuery(".yikes_woo_save_this_tab").click(function(){var a=jQuery(this).data("tab-id");yikes_woo_handle_saving_reusable_tab(a)}),jQuery(".yikes_woo_delete_this_tab").click(function(){var a=confirm("Are you sure you want to delete this tab?");if(a!==!1){var b=jQuery(this).data("tab-id");jQuery(this).hasClass("yikes_woo_delete_this_tab_single")?("new"===b&&(location.href=repeatable_custom_tabs_settings.tab_list_page_url),yikes_woo_handle_deleting_reusable_tab(b,"single")):yikes_woo_handle_deleting_reusable_tab(b,!1)}}),jQuery(".yikes_woo_handle_bulk_action").click(function(){if("delete"===jQuery("#bulk-action-selector-top").val()){var a=[];jQuery(".entry-bulk-action-checkbox").each(function(){jQuery(this).is(":checked")===!0&&(a.push(jQuery(this).val()),jQuery(this).parents("th").parents(".yikes_woo_saved_tabs_row").addClass("yikes_woo_bulk_delete_this_row"))}),yikes_woo_handle_deleting_reusable_tab(a,"bulk")}})});
js/repeatable-custom-tabs-shared.js ADDED
@@ -0,0 +1,221 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 ( 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
+ quicktags( { id: textarea_id } ); // buttons: 'strong,em,block,del,ul,ol,li,link,code,fullscreen' // currently do not work
45
+
46
+ // Initialize tinymce
47
+ if( typeof( tinymce ) != 'undefined' ) {
48
+ tinymce.execCommand( 'mceAddEditor', false, textarea_id );
49
+ }
50
+
51
+ // After tinymce is initialized, let's check if we need to disable the box (because it's a saved tab)
52
+ var tab_number = yikes_woo_get_tab_number_from_id( textarea_id );
53
+ if ( jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).hasClass( 'yikes_woo_disable_this_tab' ) ) {
54
+ jQuery( '#_yikes_wc_custom_repeatable_product_tabs_tab_title_' + tab_number ).removeClass( 'yikes_woo_disable_this_tab' );
55
+ yikes_woo_toggle_reusable_override_overlay( 'disable', tab_number );
56
+ }
57
+
58
+ return true;
59
+ });
60
+ }
61
+
62
+ /**
63
+ * @summary Get the numerical ID from a string ID
64
+ *
65
+ * @param string | id_string | an id of the form this_is_an_id_10
66
+ * @return string | tab_number | the numerical suffix of the string id passed in
67
+ */
68
+ function yikes_woo_get_tab_number_from_id( id_string ) {
69
+ return id_string.slice( ( id_string.lastIndexOf( '_' ) + 1 ) );
70
+ }
71
+
72
+ /**
73
+ * @summary Toggle disabling/hiding of UI buttons, this prevents potentially breaking the UI while AJAX is returning
74
+ *
75
+ * @since 1.5
76
+ *
77
+ * @param string | toggle_enable | 'disable' to disable/hide, 'enable' to enable/show
78
+ *
79
+ */
80
+ function yikes_woo_toggle_controls( toggle_enable ) {
81
+ if ( toggle_enable === 'disable' ) {
82
+ jQuery( '.remove_this_tab' ).attr( 'disabled', 'disabled' );
83
+ jQuery( '#add_another_tab' ).attr( 'disabled', 'disabled' );
84
+ jQuery( '._yikes_wc_apply_a_saved_tab' ).attr( 'disabled', 'disabled' );
85
+ jQuery( '.move-tab-data-up' ).hide();
86
+ jQuery( '.move-tab-data-down' ).hide();
87
+ } else {
88
+ jQuery( '.remove_this_tab' ).removeAttr( 'disabled' );
89
+ jQuery( '#add_another_tab' ).removeAttr( 'disabled' );
90
+ jQuery( '._yikes_wc_apply_a_saved_tab' ).removeAttr( 'disabled' )
91
+ jQuery( '.move-tab-data-up' ).show();
92
+ jQuery( '.move-tab-data-down' ).show();
93
+ }
94
+ }
95
+
96
+ /**
97
+ * @summary Display a simple error or success message
98
+ *
99
+ * @since 1.5
100
+ *
101
+ * @param string | anchor_element | a selector for an element we're going to display the message next to
102
+ * @param string | message_element_id| the ID of the element we're creating to hold the message
103
+ * @param string | message | the message we're displaying to the user
104
+ * @param object | options | Collection of options for customizing the error message
105
+ *
106
+ */
107
+ function yikes_woo_display_feedback_messages( anchor_element_id, message_element_id, message, options ) {
108
+
109
+ var defaults = {
110
+ 'inline': false,
111
+ 'classes': [],
112
+ 'css_string': '',
113
+ 'time': 3000
114
+ }
115
+
116
+ var opts = jQuery.extend( defaults, options );
117
+
118
+ //remove any other success / error message elements
119
+ jQuery( '._yikes_wc_feedback_message' ).remove();
120
+
121
+ // Construct style string
122
+ var style_string = '';
123
+ if ( opts.css_string.length > 0 ) {
124
+ style_string = opts.css_string;
125
+ }
126
+
127
+ // Construct class string
128
+ var classes = defaults.classes;
129
+ if ( opts.classes.length > 0 ) {
130
+ opts.classes.each( function( index, class_name ) {
131
+ classes += class_name;
132
+ });
133
+ }
134
+
135
+ var dynamic_message_elements = '';
136
+
137
+ // Construct our message
138
+ if ( opts.inline === true ) {
139
+ dynamic_message_elements = '<span id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</span>';
140
+ } else {
141
+ dynamic_message_elements = '<p id="' + message_element_id + '" class="_yikes_wc_feedback_message ' + classes + '" style="' + style_string + '">' + message + '</p>';
142
+ }
143
+
144
+ // Add our message to the DOM
145
+ jQuery( anchor_element_id ).after( dynamic_message_elements );
146
+
147
+ // Display message by fadein/fadeout
148
+ jQuery( '#' + message_element_id ).fadeIn( 500 ).delay( opts.time ).fadeOut( 500 );
149
+ }
150
+
151
+ /**
152
+ * @summary Slide down / slide up our 'How To' info and swap dashicons
153
+ *
154
+ * @since 1.5
155
+ *
156
+ */
157
+ function yikes_woo_toggle_how_to() {
158
+ jQuery( '.yikes-woo-tabs-hidden-how-to-info' ).slideToggle( 'fast', function() {
159
+ if ( jQuery( '#yikes-woo-help-me-icon' ).hasClass( 'dashicons-editor-help' ) ) {
160
+ jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-editor-help' ).addClass( 'dashicons-dismiss' );
161
+ } else {
162
+ jQuery( '#yikes-woo-help-me-icon' ).removeClass( 'dashicons-dismiss' ).addClass( 'dashicons-editor-help' );
163
+ }
164
+ });
165
+ }
166
+
167
+ /**
168
+ * Retrieve the content from the wp_editor
169
+ *
170
+ * @since 1.5
171
+ *
172
+ * @param string | editor_id | the id of the editor (without the prefacing #)
173
+ * @return string | content | the content of the editor
174
+ */
175
+ function yikes_woo_get_content_from_wysiwyg( editor_id ) {
176
+
177
+ var content = '';
178
+
179
+ // Check if tinymce is initialized, and if our instance is known
180
+ if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
181
+
182
+ // Store the content
183
+ content = tinymce.get( editor_id ).getContent();
184
+
185
+ // If we don't have any content, check the textarea for a value and use it
186
+ if ( content.length === 0 && jQuery( '#' + editor_id ).val().length > 0 ) {
187
+ content = jQuery( '#' + editor_id ).val();
188
+ }
189
+ } else {
190
+
191
+ // If tinymce is not initialized, try getting the content from the textarea value
192
+ content = jQuery( '#' + editor_id ).val();
193
+ }
194
+
195
+ return content;
196
+ }
197
+
198
+ /**
199
+ * Set the content for the wp_editor
200
+ *
201
+ * @since 1.5
202
+ *
203
+ * @param string | editor_id | the id of the editor (without the prefacing #)
204
+ * @param string | content | the content to supply the editor with
205
+ */
206
+ function yikes_woo_set_content_for_wysiwyg( editor_id, content ) {
207
+
208
+ // Check if tinymce is initialized, and if our instance is known
209
+ if ( tinymce !== 'undefined' && tinymce.get( editor_id ) !== null ) {
210
+
211
+ // If it's initialized, we can just set the content from here using setContent()
212
+ tinymce.get( editor_id ).setContent( content );
213
+
214
+ // tinyMCE stores the value in both places, so we need to set the textarea content from here too
215
+ jQuery( '#' + editor_id ).val( content );
216
+ } else {
217
+
218
+ // Else we need to set the value using the textarea's val
219
+ jQuery( '#' + editor_id ).val( content );
220
+ }
221
+ }
js/repeatable-custom-tabs-shared.min.js ADDED
@@ -0,0 +1 @@
 
1
+ function yikes_woo_get_wp_editor_ajax(a,b,c){var d={action:"yikes_woo_get_wp_editor",textarea_id:a,tab_content:c,security_nonce:repeatable_custom_tabs_shared.get_wp_editor_security_nonce};jQuery.post(repeatable_custom_tabs_shared.ajaxurl,d,function(c){if(yikes_woo_toggle_controls("enable"),0==c.success)return jQuery("."+a+"_field").html("<p>"+repeatable_custom_tabs_shared.get_wp_editor_failure_message+"</p>"),!1;b===!0&&jQuery(".button-holder").show(),jQuery("."+a+"_field").html(c).addClass("_yikes_wc_custom_repeatable_product_tabs_tab_content_field _yikes_wc_custom_repeatable_product_tabs_tab_content_field_dynamic"),quicktags({id:a}),"undefined"!=typeof tinymce&&tinymce.execCommand("mceAddEditor",!1,a);var d=yikes_woo_get_tab_number_from_id(a);return jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_title_"+d).hasClass("yikes_woo_disable_this_tab")&&(jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_title_"+d).removeClass("yikes_woo_disable_this_tab"),yikes_woo_toggle_reusable_override_overlay("disable",d)),!0})}function yikes_woo_get_tab_number_from_id(a){return a.slice(a.lastIndexOf("_")+1)}function yikes_woo_toggle_controls(a){"disable"===a?(jQuery(".remove_this_tab").attr("disabled","disabled"),jQuery("#add_another_tab").attr("disabled","disabled"),jQuery("._yikes_wc_apply_a_saved_tab").attr("disabled","disabled"),jQuery(".move-tab-data-up").hide(),jQuery(".move-tab-data-down").hide()):(jQuery(".remove_this_tab").removeAttr("disabled"),jQuery("#add_another_tab").removeAttr("disabled"),jQuery("._yikes_wc_apply_a_saved_tab").removeAttr("disabled"),jQuery(".move-tab-data-up").show(),jQuery(".move-tab-data-down").show())}function yikes_woo_display_feedback_messages(a,b,c,d){var e={inline:!1,classes:[],css_string:"",time:3e3},f=jQuery.extend(e,d);jQuery("._yikes_wc_feedback_message").remove();var g="";f.css_string.length>0&&(g=f.css_string);var h=e.classes;f.classes.length>0&&f.classes.each(function(a,b){h+=b});var i="";i=f.inline===!0?'<span id="'+b+'" class="_yikes_wc_feedback_message '+h+'" style="'+g+'">'+c+"</span>":'<p id="'+b+'" class="_yikes_wc_feedback_message '+h+'" style="'+g+'">'+c+"</p>",jQuery(a).after(i),jQuery("#"+b).fadeIn(500).delay(f.time).fadeOut(500)}function yikes_woo_toggle_how_to(){jQuery(".yikes-woo-tabs-hidden-how-to-info").slideToggle("fast",function(){jQuery("#yikes-woo-help-me-icon").hasClass("dashicons-editor-help")?jQuery("#yikes-woo-help-me-icon").removeClass("dashicons-editor-help").addClass("dashicons-dismiss"):jQuery("#yikes-woo-help-me-icon").removeClass("dashicons-dismiss").addClass("dashicons-editor-help")})}function yikes_woo_get_content_from_wysiwyg(a){var b="";return"undefined"!==tinymce&&null!==tinymce.get(a)?(b=tinymce.get(a).getContent(),0===b.length&&jQuery("#"+a).val().length>0&&(b=jQuery("#"+a).val())):b=jQuery("#"+a).val(),b}function yikes_woo_set_content_for_wysiwyg(a,b){"undefined"!==tinymce&&null!==tinymce.get(a)?(tinymce.get(a).setContent(b),jQuery("#"+a).val(b)):jQuery("#"+a).val(b)}
js/repeatable-custom-tabs.js CHANGED
@@ -1 +1 @@
1
- /*
2
  jQuery( '#_yikes_wc_apply_a_saved_tab' ).removeClass( 'disabled' );
1
+ /*
2
  jQuery( '#_yikes_wc_apply_a_saved_tab' ).removeClass( 'disabled' );
js/repeatable-custom-tabs.min.js CHANGED
@@ -1,8 +1 @@
1
- /*
2
- * Minified Script for YIKES Inc. Easy WooCommerce Repeatable Product Tabs
3
- *
4
- * @ Compiled By: Yikes Inc.
5
- * @ http://www.YIKESinc.com
6
- *
7
- */
8
- jQuery(document).ready(function(){jQuery(".yikes-custom-wysiwyg-label").each(function(){jQuery(this).insertBefore(jQuery(this).prev())}),jQuery("#add_another_tab").on("click",function(t){var e=jQuery("#duplicate_this_row"),_=(jQuery("#number_of_tabs").val(),parseInt(jQuery("#number_of_tabs").val())+parseInt(1)),a=jQuery("#duplicate_this_row .remove_this_tab"),r=jQuery("#duplicate_this_row .button-holder");e.children("p").each(function(){jQuery(this).clone().insertBefore("#duplicate_this_row").removeClass("hidden_duplicator_row_title_field").removeClass("hidden_duplicator_row_content_field").addClass("new_duplicate_row")}).promise().done(function(){jQuery(".new_duplicate_row").find("input").each(function(){jQuery(this).is('input[name="hidden_duplicator_row_title"]')&&jQuery(this).attr("name","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+_).attr("id","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+_).parents("p").addClass("_yikes_wc_custom_repeatable_product_tabs_tab_title_"+_+"_field").removeClass("hidden_duplicator_row_title_field").find("label").removeAttr("for").attr("for","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+_+"_field")}),jQuery(".new_duplicate_row").find("textarea").each(function(){jQuery(this).is('textarea[name="hidden_duplicator_row_content"]')&&jQuery(this).attr("name","_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_).attr("id","_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_).parents("p").addClass("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_+"_field").removeClass("hidden_duplicator_row_content_field").find("label").removeAttr("for").attr("for","_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_+"_field")}),jQuery("#number_of_tabs").val(_),jQuery(".new_duplicate_row").first().before('<div class="yikes-woo-custom-tab-divider"></div>')}),r.clone().insertAfter(jQuery(".yikes-woo-custom-tab-divider").last()).addClass("last-button-holder"),a.clone().prependTo(".last-button-holder").removeAttr("style"),jQuery(".last-button-holder").removeAttr("alt").attr("alt",_),setTimeout(function(){jQuery(".last-button-holder").removeClass("last-button-holder"),jQuery(".new_duplicate_row").removeClass("new_duplicate_row")},100),t.preventDefault()}),jQuery("body").on("click",".remove_this_tab",function(t){var e=jQuery(this),_=jQuery(this).parents(".button-holder").next();jQuery(".yikes-custom-wysiwyg-label").remove();var a=jQuery(this).parents(".button-holder").next().next(),r=jQuery(this).parents(".button-holder").prev(),o=(jQuery("#number_of_tabs").val(),parseInt(jQuery("#number_of_tabs").val())-parseInt(1));_.remove(),a.remove(),r.remove(),e.parents(".button-holder").remove(),setTimeout(function(){jQuery(".last-button-holder").removeClass("last-button-holder"),jQuery(".new_duplicate_row").removeClass("new_duplicate_row")},100);var s=1;jQuery(".yikes_woo_tabs_title_field").each(function(){jQuery(this).removeAttr("name").attr("name","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+s).removeAttr("id").attr("id","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+s),jQuery(this).prev().removeAttr("for").attr("for","_yikes_wc_custom_repeatable_product_tabs_tab_title_"+s),jQuery(this).parent("p").removeAttr("for").attr("for","form-field _yikes_wc_custom_repeatable_product_tabs_tab_title_"+s+"_field"),jQuery(this).parent("p").removeAttr("class").attr("class","form-field _yikes_wc_custom_repeatable_product_tabs_tab_title_"+s+"_field"),s++});var u=1;jQuery("#yikes_woocommerce_custom_product_tabs").find("textarea.wp-editor-area").each(function(){jQuery(this).attr("name","_yikes_wc_custom_repeatable_product_tabs_tab_content_"+u),jQuery(this).attr("id","_yikes_wc_custom_repeatable_product_tabs_tab_content_"+u),u++});var n=1;jQuery(".button-holder").each(function(){jQuery(this).removeAttr("alt").attr("alt",n),n++}),jQuery("#number_of_tabs").val(o),t.preventDefault()}),jQuery(".yikes-tabs-how-to-toggle").on("click",function(){jQuery(".yikes-woo-tabs-hidden-how-to-info").slideToggle("fast")}),jQuery("body").on("click",".move-tab-data-up",function(){var t=jQuery(this),e=t.parents(".button-holder").attr("alt"),_=jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+e+'"]').val(),a=tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+e).getContent();if(1==e)return!1;var r=parseInt(e)-parseInt(1),o=jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+r+'"]').val(),s=tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+r).getContent();jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+e+'"]').val(o),jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+r+'"]').val(_),tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+e).setContent(s),tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+r).setContent(a)}),jQuery("body").on("click",".move-tab-data-down",function(){var t=jQuery("#number_of_tabs").val(),e=jQuery(this),_=e.parents(".button-holder").attr("alt"),a=jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+_+'"]').val(),r=tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_).getContent();if(_==t)return!1;var o=parseInt(_)+parseInt(1),s=jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+o+'"]').val(),u=jQuery('textarea[name="_yikes_wc_custom_repeatable_product_tabs_tab_content_'+o+'"]').val();jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+_+'"]').val(s),jQuery('input[name="_yikes_wc_custom_repeatable_product_tabs_tab_title_'+o+'"]').val(a),tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+_).setContent(u),tinymce.get("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+o).setContent(r)})});
1
+ function yikes_woo_handle_reusable_tabs(){var a={action:"yikes_woo_fetch_reusable_tab",security_nonce:repeatable_custom_tabs.fetch_reusable_tab_nonce};jQuery.post(repeatable_custom_tabs.ajaxurl,a,function(a){if("undefined"!=typeof a.success&&a.success===!0)if("undefined"!=typeof a.data&&"undefined"!=typeof a.data.message)jQuery("#yikes_woo_ajax_save_feedback").removeClass().addClass("yikes_woo_save_success").text(a.data.message).fadeIn().delay("2000").fadeOut();else{var b=JSON.parse(a.data);lity_html=create_lity_manage_reusable_tabs_html(b),global_lity=lity(lity_html)}else"undefined"!=typeof a.success&&a.success===!1&&console.log(a);jQuery("#_yikes_wc_apply_a_saved_tab").removeClass("disabled")})}function create_lity_manage_reusable_tabs_html(a){var b=1,c="";return c+='<div class="display_saved_tabs_lity">',c+='<div class="yikes_wc_lity_header">',c+="<span> Choose a Tab </span>",c+="</div>",jQuery.each(a,function(a,d){c+='<div id="saved_tab_container_'+b+'" data-tab-id='+d.tab_id+">",c+='<div style="display:none;" id="yikes_woo_saved_tab_content_'+b+'">',c+=d.tab_content,c+="</div>",c+='<div class="yikes_wc_lity_col_title">',c+='<span class="yikes_woo_saved_tab_title_lity" id="yikes_woo_saved_tab_title_'+b+'">',c+=d.tab_title,c+="</span>",c+="</div>",c+='<div class="yikes_wc_lity_col_select">',c+='<span class="yikes_woo_saved_tab_selector_lity dashicons dashicons-plus-alt" data-saved-tab-number= "'+b+'"></span>',c+="</div>",c+="</div>",b++}),c+="</div>"}function yikes_woo_toggle_reusable_override_overlay(a,b){"disable"===a?(jQuery("#qt__yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"_toolbar").addClass("yikes_woo_using_reusable_tab"),jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b).addClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-media-buttons").addClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-editor-container").children(".mce-container").children(".mce-container-body").children(".mce-toolbar-grp").addClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-editor-container").children(".mce-tinymce").children(".mce-container-body").children(".mce-edit-area").addClass("yikes_woo_using_reusable_tab"),jQuery("._yikes_wc_custom_repeatable_product_tabs_tab_title_"+b+"_field").addClass("yikes_woo_using_reusable_tab")):(jQuery("#qt__yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"_toolbar").removeClass("yikes_woo_using_reusable_tab"),jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b).removeClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-media-buttons").removeClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-editor-container").children(".mce-container").children(".mce-container-body").children(".mce-toolbar-grp").removeClass("yikes_woo_using_reusable_tab"),jQuery("#wp-_yikes_wc_custom_repeatable_product_tabs_tab_content_"+b+"-editor-container").children(".mce-tinymce").children(".mce-container-body").children(".mce-edit-area").removeClass("yikes_woo_using_reusable_tab"),jQuery("._yikes_wc_custom_repeatable_product_tabs_tab_title_"+b+"_field").removeClass("yikes_woo_using_reusable_tab"))}function yikes_woo_check_for_reusable_tabs_and_disable(){jQuery(".yikes_wc_override_reusable_tab_container").each(function(){if(1==jQuery(this).data("reusable-tab")){var a=jQuery(this).children("._yikes_wc_override_reusable_tab").data("tab-number");yikes_woo_toggle_reusable_override_overlay("disable",a)}})}function yikes_woo_add_another_tab(a){yikes_woo_toggle_controls("disable"),jQuery("._yikes_wc_add_tab_center_new").removeClass("_yikes_wc_add_tab_center_new"),jQuery("#add_another_tab").parent(".add_tabs_container").removeClass("_yikes_wc_add_tab_center");var b=jQuery("#duplicate_this_row"),c=parseInt(jQuery("#number_of_tabs").val())+parseInt(1),d=jQuery("#duplicate_this_row .button-holder"),e="_yikes_wc_custom_repeatable_product_tabs_tab_content_"+c,f="_yikes_wc_custom_repeatable_product_tabs_tab_title_"+c;b.children("p").each(function(){jQuery(this).clone().insertBefore("#duplicate_this_row").removeClass("hidden_duplicator_row_title_field hidden_duplicator_row_content_field").addClass("new_duplicate_row")}).promise().done(function(){jQuery(".new_duplicate_row").removeClass("_yikes_wc_override_reusable_tab_container_duplicate").children("#_yikes_wc_override_reusable_tab_duplicate").attr("id","_yikes_wc_override_reusable_tab_"+c).attr("data-tab-number",c),jQuery(".new_duplicate_row").children("._yikes_wc_override_reusable_tab_label_duplicate").attr("for","_yikes_wc_override_reusable_tab_"+c).attr("id","_yikes_wc_override_reusable_tab_label_"+c).removeClass("_yikes_wc_override_reusable_tab_label_duplicate").addClass("_yikes_wc_override_reusable_tab_label"),jQuery(".new_duplicate_row").children("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_action_duplicate").attr("name","_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c+"_action").attr("id","_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c+"_action"),jQuery(".new_duplicate_row").children("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_duplicate").attr("name","_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c).attr("id","_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c),jQuery(".new_duplicate_row").find("input").each(function(){jQuery(this).is('input[name="hidden_duplicator_row_title"]')&&jQuery(this).attr("name",f).removeClass("yikes_woo_tabs_title_field_duplicate").attr("id",f).parents("p").addClass(f+"_field").removeClass("hidden_duplicator_row_title_field").find("label").removeAttr("for").attr("for",f+"_field")}),jQuery(".new_duplicate_row").find("textarea").each(function(){jQuery(this).is('textarea[name="hidden_duplicator_row_content"]')&&jQuery(this).attr("name",e).attr("id",e).parents("p").addClass(e+"_field").removeClass("hidden_duplicator_row_content_field").find("label").removeAttr("for").attr("for",e+"_field")}),jQuery("#number_of_tabs").val(c),c>1&&jQuery(".new_duplicate_row").first().before('<div class="yikes-woo-custom-tab-divider"></div>')}),jQuery("#_yikes_wc_override_reusable_tab_container_duplicate").first().attr("id","_yikes_wc_override_reusable_tab_container_"+c),d.clone().insertAfter(jQuery("."+e+"_field")).addClass("last-button-holder"),jQuery(".last-button-holder").removeAttr("alt").attr("alt",c).hide(),jQuery("."+e+"_field").html(repeatable_custom_tabs.loading_gif),yikes_woo_get_wp_editor_ajax(e,!0,a),jQuery(".last-button-holder").removeClass("last-button-holder"),jQuery(".new_duplicate_row").removeClass("new_duplicate_row")}jQuery(document).ready(function(){setTimeout(function(){yikes_woo_check_for_reusable_tabs_and_disable()},4e3),jQuery(".yikes-tabs-how-to-toggle").on("click",function(a){yikes_woo_toggle_how_to()}),jQuery("#add_another_tab").click(function(a){yikes_woo_add_another_tab(""),a.preventDefault()}),jQuery("body").on("click",".remove_this_tab",function(a){var b=jQuery(this),c=b.parents(".button-holder").attr("alt"),d=jQuery("#number_of_tabs").val(),e="_yikes_wc_custom_repeatable_product_tabs_tab_title_",f="_yikes_wc_custom_repeatable_product_tabs_tab_content_";if(c!==d)for(var g=parseInt(c);g<d;){var h="",i="",j=g+1;h=jQuery("#"+e+j).val(),jQuery("#"+e+g).val(h),i=yikes_woo_get_content_from_wysiwyg(f+j),yikes_woo_set_content_for_wysiwyg(f+g,i);var k=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+j+"_action").val(),l=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+j).val();jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g+"_action").val(k),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g).val(l);var m=jQuery("#_yikes_wc_override_reusable_tab_"+j).is(":checked");jQuery("#_yikes_wc_override_reusable_tab_"+g).prop("checked",m),jQuery("#_yikes_wc_override_reusable_tab_container_"+j).is(":visible")?jQuery("#_yikes_wc_override_reusable_tab_container_"+g).show():jQuery("#_yikes_wc_override_reusable_tab_container_"+g).hide(),jQuery("._yikes_wc_custom_repeatable_product_tabs_tab_title_"+j+"_field").hasClass("yikes_woo_using_reusable_tab")?yikes_woo_toggle_reusable_override_overlay("disable",g):yikes_woo_toggle_reusable_override_overlay("enable",g),g++}var e="_yikes_wc_custom_repeatable_product_tabs_tab_title_",f="_yikes_wc_custom_repeatable_product_tabs_tab_content_",n=f+d,o=jQuery("#_yikes_wc_override_reusable_tab_container_"+d),p=jQuery("."+e+d+"_field"),q=jQuery("."+f+d+"_field"),r=jQuery(".yikes-woo-custom-tab-divider").last(),s=jQuery("."+f+d+"_field").next(".button-holder"),t=parseInt(d)-parseInt(1);"undefined"!=typeof tinymce&&tinymce.execCommand("mceRemoveEditor",!1,n),o.remove(),p.remove(),q.remove(),r.remove(),s.remove(),jQuery("#number_of_tabs").val(t),0===parseInt(t)&&jQuery("#add_another_tab").parent(".add_tabs_container").addClass("_yikes_wc_add_tab_center"),a.preventDefault()}),jQuery("body").on("click",".move-tab-data-up",function(){var a=jQuery(this),b=a.parents(".button-holder").attr("alt");if(1==b)return!1;var c="_yikes_wc_custom_repeatable_product_tabs_tab_title_",d="_yikes_wc_custom_repeatable_product_tabs_tab_content_",e=jQuery("#"+c+b).val(),f=yikes_woo_get_content_from_wysiwyg(d+b),g=parseInt(b)-parseInt(1),h=jQuery("#"+c+g).val(),i=yikes_woo_get_content_from_wysiwyg(d+g);jQuery("."+c+b+"_field").hasClass("yikes_woo_using_reusable_tab")&&!jQuery("."+c+g+"_field").hasClass("yikes_woo_using_reusable_tab")?(yikes_woo_toggle_reusable_override_overlay("enable",b),yikes_woo_toggle_reusable_override_overlay("disable",g)):jQuery("."+c+g+"_field").hasClass("yikes_woo_using_reusable_tab")&&!jQuery("."+c+b+"_field").hasClass("yikes_woo_using_reusable_tab")&&(yikes_woo_toggle_reusable_override_overlay("disable",b),yikes_woo_toggle_reusable_override_overlay("enable",g));var j=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b+"_action").val(),k=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b).val(),l=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g+"_action").val(),m=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g).val();jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b+"_action").val(l),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g+"_action").val(j),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b).val(m),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+g).val(k),jQuery("#_yikes_wc_override_reusable_tab_"+b).is(":checked")===!0&&jQuery("#_yikes_wc_override_reusable_tab_"+g).is(":checked")===!1?(jQuery("#_yikes_wc_override_reusable_tab_"+g).prop("checked",!0),jQuery("#_yikes_wc_override_reusable_tab_"+b).prop("checked",!1)):jQuery("#_yikes_wc_override_reusable_tab_"+b).is(":checked")===!1&&jQuery("#_yikes_wc_override_reusable_tab_"+g).is(":checked")===!0&&(jQuery("#_yikes_wc_override_reusable_tab_"+g).prop("checked",!1),jQuery("#_yikes_wc_override_reusable_tab_"+b).prop("checked",!0)),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).is(":visible")===!0&&jQuery("#_yikes_wc_override_reusable_tab_container_"+g).is(":visible")===!1?(jQuery("#_yikes_wc_override_reusable_tab_container_"+g).show(),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).hide()):jQuery("#_yikes_wc_override_reusable_tab_container_"+b).is(":visible")===!1&&jQuery("#_yikes_wc_override_reusable_tab_container_"+g).is(":visible")===!0&&(jQuery("#_yikes_wc_override_reusable_tab_container_"+g).hide(),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).show()),jQuery("#"+c+b).val(h),jQuery("#"+c+g).val(e),yikes_woo_set_content_for_wysiwyg(d+b,i),yikes_woo_set_content_for_wysiwyg(d+g,f)}),jQuery("body").on("click",".move-tab-data-down",function(){var a=jQuery(this),b=a.parents(".button-holder").attr("alt"),c=jQuery("#number_of_tabs").val();if(b==c)return!1;var d="_yikes_wc_custom_repeatable_product_tabs_tab_title_",e="_yikes_wc_custom_repeatable_product_tabs_tab_content_",f=jQuery("#"+d+b).val(),g=yikes_woo_get_content_from_wysiwyg(e+b),h=parseInt(b)+parseInt(1),i=jQuery("#"+d+h).val(),j=yikes_woo_get_content_from_wysiwyg(e+h);jQuery("."+d+b+"_field").hasClass("yikes_woo_using_reusable_tab")&&!jQuery("."+d+h+"_field").hasClass("yikes_woo_using_reusable_tab")?(yikes_woo_toggle_reusable_override_overlay("enable",b),yikes_woo_toggle_reusable_override_overlay("disable",h)):jQuery("."+d+h+"_field").hasClass("yikes_woo_using_reusable_tab")&&!jQuery("."+d+b+"_field").hasClass("yikes_woo_using_reusable_tab")&&(yikes_woo_toggle_reusable_override_overlay("disable",b),yikes_woo_toggle_reusable_override_overlay("enable",h));var k=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b+"_action").val(),l=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b).val(),m=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+h+"_action").val(),n=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+h).val();jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b+"_action").val(m),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+h+"_action").val(k),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+b).val(n),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+h).val(l),jQuery("#_yikes_wc_override_reusable_tab_"+b).is(":checked")===!0&&jQuery("#_yikes_wc_override_reusable_tab_"+h).is(":checked")===!1?(jQuery("#_yikes_wc_override_reusable_tab_"+h).prop("checked",!0),jQuery("#_yikes_wc_override_reusable_tab_"+b).prop("checked",!1)):jQuery("#_yikes_wc_override_reusable_tab_"+b).is(":checked")===!1&&jQuery("#_yikes_wc_override_reusable_tab_"+h).is(":checked")===!0&&(jQuery("#_yikes_wc_override_reusable_tab_"+h).prop("checked",!1),jQuery("#_yikes_wc_override_reusable_tab_"+b).prop("checked",!0)),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).is(":visible")===!0&&jQuery("#_yikes_wc_override_reusable_tab_container_"+h).is(":visible")===!1?(jQuery("#_yikes_wc_override_reusable_tab_container_"+h).show(),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).hide()):jQuery("#_yikes_wc_override_reusable_tab_container_"+b).is(":visible")===!1&&jQuery("#_yikes_wc_override_reusable_tab_container_"+h).is(":visible")===!0&&(jQuery("#_yikes_wc_override_reusable_tab_container_"+h).hide(),jQuery("#_yikes_wc_override_reusable_tab_container_"+b).show()),jQuery("#"+d+b).val(i),jQuery("#"+d+h).val(f),yikes_woo_set_content_for_wysiwyg(e+b,j),yikes_woo_set_content_for_wysiwyg(e+h,g)}),jQuery("body").on("click","#_yikes_wc_apply_a_saved_tab",function(){return!jQuery(this).hasClass("disabled")&&(jQuery(this).addClass("disabled"),void yikes_woo_handle_reusable_tabs())}),jQuery("body").on("click",".yikes_woo_saved_tab_selector_lity",function(){var a=jQuery(this).data("saved-tab-number"),b="_yikes_wc_custom_repeatable_product_tabs_tab_title_",c=jQuery("#yikes_woo_saved_tab_content_"+a).html(),d=jQuery("#yikes_woo_saved_tab_title_"+a).text(),e=jQuery("#saved_tab_container_"+a).data("tab-id");yikes_woo_add_another_tab(c);var f=jQuery("#number_of_tabs").val();jQuery("#"+b+f).val(d),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+f+"_action").val("add"),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+f).val(e),jQuery("#qt__yikes_wc_custom_repeatable_product_tabs_tab_content_"+f+"_toolbar").length>0?yikes_woo_toggle_reusable_override_overlay("disable",f):jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_title_"+f).addClass("yikes_woo_disable_this_tab"),jQuery("#_yikes_wc_override_reusable_tab_container_"+f).show(),global_lity.close()}),jQuery("body").on("click","._yikes_wc_override_reusable_tab",function(){var a=jQuery(this).data("tab-number");jQuery(this).is(":checked")===!0?(yikes_woo_display_feedback_messages("_yikes_wc_override_reusable_tab_container_"+a,"_yikes_wc_override_reusable_tab_message","If you override this tab it will no longer recognize global tab changes.",!1),jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+a+"_action").val("remove"),yikes_woo_toggle_reusable_override_overlay("enable",a)):(jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+a+"_action").val("add"),yikes_woo_toggle_reusable_override_overlay("disable",a))}),jQuery("body").on("focusout",".yikes_woo_tabs_title_field",function(){var a=jQuery(this);if(1===parseInt(jQuery("#number_of_tabs").val()))return a.removeClass("_yikes_wc_title_red_overlay"),void a.parent(".form-field").children("._yikes_wc_duplicate_title_message").remove();var b=jQuery(this).attr("id"),c=jQuery(this).val(),d=!1;jQuery(".yikes_woo_tabs_title_field").each(function(e,f){jQuery(f).attr("id")!=b&&""!=jQuery(f).val()&&jQuery(f).val()===c&&(a.addClass("_yikes_wc_title_red_overlay"),a.parent(".form-field").children("._yikes_wc_duplicate_title_message").remove(),a.parent(".form-field").prepend('<span class="_yikes_wc_duplicate_title_message"> Please choose a unique tab name - duplicate tab names can create errors </span>'),d=!0)}),d===!1&&(jQuery("._yikes_wc_title_red_overlay").removeClass("_yikes_wc_title_red_overlay"),jQuery("._yikes_wc_duplicate_title_message").remove())}),jQuery("body").on("lity:close",function(){jQuery("#_yikes_wc_apply_a_saved_tab").removeClass("disabled")}),jQuery("#yikes_woo_save_custom_tabs").click(function(){if(jQuery("#yikes_woo_save_custom_tabs").hasClass("disabled")!==!0){jQuery("#yikes_woo_save_custom_tabs").addClass("disabled"),jQuery("#yikes_woo_ajax_save_feedback").fadeOut();for(var a=jQuery("#number_of_tabs").val(),b={action:"yikes_woo_save_product_tabs",post_id:repeatable_custom_tabs.global_post_id,number_of_tabs:a,security_nonce:repeatable_custom_tabs.save_product_tabs_nonce},c=1;c<=a;c++)b["_yikes_wc_custom_repeatable_product_tabs_tab_title_"+c]=jQuery("#_yikes_wc_custom_repeatable_product_tabs_tab_title_"+c).val(),b["_yikes_wc_custom_repeatable_product_tabs_tab_content_"+c]=yikes_woo_get_content_from_wysiwyg("_yikes_wc_custom_repeatable_product_tabs_tab_content_"+c),b["_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c]=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c).val(),b["_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c+"_action"]=jQuery("#_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_"+c+"_action").val();jQuery.post(repeatable_custom_tabs.ajaxurl,b,function(a){"undefined"!=typeof a.success&&(a.success===!0?feedback_message_class="yikes_woo_save_success":a.success===!1&&(feedback_message_class="yikes_woo_save_failure")),"undefined"!=typeof a.data&&"undefined"!=typeof a.data.message&&jQuery("#yikes_woo_ajax_save_feedback").removeClass().addClass(feedback_message_class).text(a.data.message).fadeIn().delay("2000").fadeOut(),jQuery("#yikes_woo_save_custom_tabs").removeClass("disabled")})}})});
 
 
 
 
 
 
 
languages/yikes-inc-easy-custom-woocommerce-product-tabs.pot ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: yikes-inc-easy-custom-woocommerce-product-tabs 1.5.0\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2016-12-20 14:50+0000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=CHARSET\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
20
+
21
+ #: admin/class.yikes-woo-generate-html.php:73
22
+ #: admin/class.yikes-woo-generate-html.php:244
23
+ #: admin/page.yikes-woo-saved-tabs-single.php:47
24
+ #: admin/page.yikes-woo-saved-tabs.php:48
25
+ #: admin/page.yikes-woo-saved-tabs.php:64
26
+ msgid "Tab Title"
27
+ msgstr ""
28
+
29
+ #: admin/class.yikes-woo-generate-html.php:73
30
+ #: admin/class.yikes-woo-generate-html.php:244
31
+ msgid "Custom Tab Title"
32
+ msgstr ""
33
+
34
+ #: admin/class.yikes-woo-generate-html.php:142
35
+ msgid ""
36
+ "For help using Custom Tabs please visit our <a href='https://yikesplugins."
37
+ "com/support/knowledge-base/product/easy-custom-product-tabs-for-"
38
+ "woocommerce/' target='_blank'>Knowledge Base</a>"
39
+ msgstr ""
40
+
41
+ #: admin/class.yikes-woo-generate-html.php:144
42
+ msgid "Help Me!"
43
+ msgstr ""
44
+
45
+ #: admin/class.yikes-woo-generate-html.php:165
46
+ #: admin/class.yikes-woo-generate-html.php:177
47
+ #: admin/class.yikes-woo-generate-html.php:282
48
+ msgid "Check this box to override the saved tab"
49
+ msgstr ""
50
+
51
+ #: admin/class.yikes-woo-generate-html.php:167
52
+ #: admin/class.yikes-woo-generate-html.php:179
53
+ msgid " Override Saved Tab for this product"
54
+ msgstr ""
55
+
56
+ #: admin/class.yikes-woo-generate-html.php:209
57
+ #: admin/class.yikes-woo-generate-html.php:303
58
+ #: admin/class.yikes-woo-generate-html.php:339
59
+ msgid "Remove Tab"
60
+ msgstr ""
61
+
62
+ #: admin/class.yikes-woo-generate-html.php:259
63
+ #: admin/class.yikes-woo-generate-html.php:318
64
+ msgid "Content"
65
+ msgstr ""
66
+
67
+ #: admin/class.yikes-woo-generate-html.php:260
68
+ #: admin/class.yikes-woo-generate-html.php:318
69
+ msgid "HTML and text to display."
70
+ msgstr ""
71
+
72
+ #: admin/class.yikes-woo-generate-html.php:283
73
+ msgid "Override Saved Tab for this product"
74
+ msgstr ""
75
+
76
+ #: admin/class.yikes-woo-generate-html.php:379
77
+ msgid "Add a Tab"
78
+ msgstr ""
79
+
80
+ #: admin/class.yikes-woo-generate-html.php:384
81
+ msgid "Add a Saved Tab"
82
+ msgstr ""
83
+
84
+ #: admin/page.yikes-woo-saved-tabs-single.php:31
85
+ msgid "Any updates made here will apply to all products using this tab."
86
+ msgstr ""
87
+
88
+ #: admin/page.yikes-woo-saved-tabs-single.php:39
89
+ msgid "Go Back to Saved Tabs list"
90
+ msgstr ""
91
+
92
+ #: admin/page.yikes-woo-saved-tabs-single.php:55
93
+ msgid "Tab Content"
94
+ msgstr ""
95
+
96
+ #: admin/page.yikes-woo-saved-tabs-single.php:65
97
+ msgid "Save Tab"
98
+ msgstr ""
99
+
100
+ #: admin/page.yikes-woo-saved-tabs-single.php:69
101
+ #: admin/page.yikes-woo-saved-tabs.php:96
102
+ msgid "Delete Tab"
103
+ msgstr ""
104
+
105
+ #: admin/page.yikes-woo-saved-tabs.php:6
106
+ msgid "Add Tab"
107
+ msgstr ""
108
+
109
+ #: admin/page.yikes-woo-saved-tabs.php:13
110
+ msgid "Tab deleted!"
111
+ msgstr ""
112
+
113
+ #: admin/page.yikes-woo-saved-tabs.php:22
114
+ msgid "Create and save tabs you can add to multiple products."
115
+ msgstr ""
116
+
117
+ #: admin/page.yikes-woo-saved-tabs.php:31
118
+ msgid "Select bulk action"
119
+ msgstr ""
120
+
121
+ #: admin/page.yikes-woo-saved-tabs.php:33
122
+ msgid "Bulk Actions"
123
+ msgstr ""
124
+
125
+ #: admin/page.yikes-woo-saved-tabs.php:34
126
+ msgid "Delete"
127
+ msgstr ""
128
+
129
+ #: admin/page.yikes-woo-saved-tabs.php:36
130
+ msgid "Apply"
131
+ msgstr ""
132
+
133
+ #: admin/page.yikes-woo-saved-tabs.php:44
134
+ #: admin/page.yikes-woo-saved-tabs.php:60
135
+ msgid "Select All"
136
+ msgstr ""
137
+
138
+ #: admin/page.yikes-woo-saved-tabs.php:51
139
+ #: admin/page.yikes-woo-saved-tabs.php:67
140
+ msgid "Tab Content Preview"
141
+ msgstr ""
142
+
143
+ #: admin/page.yikes-woo-saved-tabs.php:93
144
+ #: admin/page.yikes-woo-saved-tabs.php:103
145
+ msgid "Edit Tab"
146
+ msgstr ""
147
+
148
+ #: admin/page.yikes-woo-saved-tabs.php:113
149
+ msgid "There are no saved tabs. Add one!"
150
+ msgstr ""
151
+
152
+ #: node_modules/grunt-pot/test/fixtures/some-file.php:3
153
+ msgid "I'm a translatable string."
154
+ msgstr ""
155
+
156
+ #: node_modules/grunt-pot/test/fixtures/some-other-file.php:4
157
+ msgid "Me too"
158
+ msgstr ""
159
+
160
+ #: node_modules/grunt-pot/test/fixtures/some-other-file.php:7
161
+ #, php-format
162
+ msgid "I have %d apple"
163
+ msgid_plural "I have %d apples"
164
+ msgstr[0] ""
165
+ msgstr[1] ""
166
+
167
+ #. / TRANSLATORS: This should be translated as a shorthand for YEAR-MONTH-DAY using 4, 2 and 2 digits.
168
+ #: node_modules/grunt-pot/test/fixtures/some-other-file.php:16
169
+ msgid "yyyy-mm-dd"
170
+ msgstr ""
171
+
172
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:51
173
+ msgid ""
174
+ "Custom Product Tabs for WooCommerce could not be activated because "
175
+ "WooCommerce is not installed and active."
176
+ msgstr ""
177
+
178
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:52
179
+ msgid "Please install and activate "
180
+ msgstr ""
181
+
182
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:52
183
+ msgid " before activating the plugin."
184
+ msgstr ""
185
+
186
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:203
187
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:211
188
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:240
189
+ msgid ""
190
+ "Sorry! An error has occurred while trying to retrieve the editor. Please "
191
+ "refresh the page and try again."
192
+ msgstr ""
193
+
194
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:346
195
+ msgid "Custom Tabs"
196
+ msgstr ""
197
+
198
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:1016
199
+ msgid "Settings - Custom Product Tabs for WooCommerce"
200
+ msgstr ""
201
+
202
+ #: yikes-inc-easy-custom-woocommerce-product-tabs.php:1017
203
+ msgid "Custom Product Tabs for WooCommerce"
204
+ msgstr ""
readme.txt CHANGED
@@ -1,60 +1,97 @@
1
- === YIKES Custom Product Tabs for WooCommerce ===
2
- Contributors: yikesinc, eherman24, liljimmi
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: 4.7
7
  Requires WooCommerce at least: 2.0
8
- Tested WooCommerce up to: 2.5.2
9
- Stable tag: 1.4.4
10
  License: GPLv2 or later
11
 
12
- This plugin extends WooCommerce to allow site admins to add custom tabs to products.
13
 
14
  == Description ==
15
 
16
- This plugin extends the [WooCommerce](www.woothemes.com/woocommerce/) eCommerce plugin to allow site admins to add custom tabs to products.
17
 
18
- Tabs are managed on the Edit Product screen and can be added on a per product basis. Tabs can be easily added, deleted and rearranged.
19
 
20
- Tab content areas use the standard WYSIWYG WordPress editor, and may contain text, html or shortcodes.
21
 
22
  If you experience any problems, please submit a New Issue on our [Github Issue Tracker](https://github.com/yikesinc/yikes-inc-easy-custom-woocommerce-product-tabs/issues) and we'll look in to it as soon as possible.
23
 
24
- <i>Originally a fork of <a href="https://wordpress.org/plugins/woocommerce-custom-product-tabs-lite/" target="_blank">SkyVerge WooCommerce Custom Product Tabs Lite</a>, and customized for a <a href="http://www.yikesinc.com" target="_blank">YIKES</a> client site.</i>
25
 
26
  == Installation ==
27
 
28
- 1. Upload the entire 'yikes-inc-custom-repeatable-woo-product-tabs' folder to the '/wp-content/plugins/' directory
29
- 2. Activate the plugin through the 'Plugins' menu in WordPress
30
- 3. Edit a product, then click on 'Custom Tab' within the 'Product Data' panel
 
 
 
 
31
 
32
  == Screenshots ==
33
 
34
  1. Custom Tabs manager on the 'Edit Product' screen
35
  2. Custom product tab content displayed on the front end
36
- 3. Contact Form 7 shortcode rendered in custom product tab
 
37
 
38
  == Frequently Asked Questions ==
39
 
 
 
40
  = Where do I go to add tabs to a product? =
41
- When editing a product in WoCommerce, 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.
42
 
43
  = Where will these tabs appear? =
44
  When the product is viewed on your website you will see the tabs you created to the right of the default "Description" tab.
45
 
46
- = I added tabs, but they didn't appear on the front-end of the site. What's up? =
47
- Make sure you hit the Product's main Update button to save all the edits you made to custom tabs or they will not be saved.
48
-
49
  = How do I change the order of the tabs? =
50
- To change the order of the custom tabs use the up and down arrows to the right of the Tab Title.
 
 
 
 
 
 
51
 
52
- = Does the custom tab data get exported with the standard WooCommerce product data? =
53
- Yes! Since v1.4 we've added the necessary hooks and filters 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.
 
 
 
 
 
 
 
 
 
54
 
55
 
56
  == Changelog ==
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  = 1.4.4 - March 1st, 2016 =
59
  * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
60
 
@@ -70,7 +107,7 @@ Yes! Since v1.4 we've added the necessary hooks and filters to ensure the custom
70
  * Now custom product tab and row data/headers only get exported via 'Tools > Export > Products'
71
 
72
  = 1.4 - July 29th, 2015 =
73
- * Enhancement: Added the 'YIKES Custom Product Tabs for WooCommerce ' data to the standard WooCommerce export file, so custom tab data can be transferred between sites smoothly.
74
 
75
  = 1.3 - July 21st, 2015 =
76
  * Enhancement: Enabled WYSIWYG editor on tab content containers (enables shortcode and content to pass through the_content() filter)
1
+ === Custom Product Tabs for WooCommerce ===
2
+ Contributors: yikesinc, eherman24, liljimmi, yikesitskevin
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: 4.7
7
  Requires WooCommerce at least: 2.0
8
+ Tested WooCommerce up to: 2.6.9
9
+ Stable tag: 1.5
10
  License: GPLv2 or later
11
 
12
+ Add custom tabs with content to products in WooCommerce.
13
 
14
  == Description ==
15
 
16
+ 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.
17
 
18
+ 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.
19
 
20
+ Tab content areas use the standard WordPress text editor and may contain text, images, html or shortcodes.
21
 
22
  If you experience any problems, please submit a New Issue on our [Github Issue Tracker](https://github.com/yikesinc/yikes-inc-easy-custom-woocommerce-product-tabs/issues) and we'll look in to it as soon as possible.
23
 
24
+ <i>This plugin is a fork of <a href="https://wordpress.org/plugins/woocommerce-custom-product-tabs-lite/" target="_blank">SkyVerge WooCommerce Custom Product Tabs Lite</a></i>
25
 
26
  == Installation ==
27
 
28
+ 1. Download the plugin .zip file and make note of where on your computer you downloaded it to.
29
+ 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.
30
+ 3. On the following screen, click the "Upload Plugin" button.
31
+ 4. Browse your computer to where you downloaded the plugin .zip file, select it and click the "Install Now" button.
32
+ 5. After the plugin has successfully installed, click "Activate Plugin" and enjoy!
33
+ 6. Edit a product, then click on 'Custom Tab' within the 'Product Data' panel
34
+ 7. Create saved, reusable tabs under Settings > Custom Product Tabs for WooCommerce
35
 
36
  == Screenshots ==
37
 
38
  1. Custom Tabs manager on the 'Edit Product' screen
39
  2. Custom product tab content displayed on the front end
40
+ 3. All of the saved tabs on the settings page
41
+ 4. Editing a single saved tab
42
 
43
  == Frequently Asked Questions ==
44
 
45
+ **All documentation can be found in [our Knowledge Base](https://yikesplugins.com/support/knowledge-base/product/easy-custom-product-tabs-for-woocommerce/).**
46
+
47
  = Where do I go to add tabs to a product? =
48
+ 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.
49
 
50
  = Where will these tabs appear? =
51
  When the product is viewed on your website you will see the tabs you created to the right of the default "Description" tab.
52
 
 
 
 
53
  = How do I change the order of the tabs? =
54
+ To change the order of custom tabs use the up and down "Move tab order" arrows.
55
+
56
+ = How do saved tabs work? =
57
+ Saved tabs are tabs you can create under the Custom Product Tabs for WooCommerce settings page and then add to as many products you would like. If you update the tab from the settings page, the changes will take effect for all products using that tab.
58
+
59
+ = How do I create saved tabs? =
60
+ To create a saved tab, go to the 'Custom Product Tabs for WooCommerce' page found under the Settings menu and click the "Add Tab" button.
61
 
62
+ = How do I add a saved tab to a product? =
63
+ 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.
64
+
65
+ = What does overriding a saved tab do? =
66
+ When using a saved tab on the product page, a checkbox appears with the message 'Override Saved Tab for this product.' 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 the 'Custom Product Tabs for WooCommerce' settings page, will not be applied to that product.
67
+
68
+ = Why does the WYSIWYG editor default to the 'Visual' tab? =
69
+ 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.
70
+
71
+ = Does custom tab data get exported with standard WooCommerce product data? =
72
+ 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.
73
 
74
 
75
  == Changelog ==
76
 
77
+ = 1.5 - December 20th, 2016 =
78
+ * 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
79
+ * UI: Complete overhaul of the custom tab interface for an easier, responsive tab creating experience.
80
+ * Saved Tabs: A new settings page has been added for users to create / update / delete saved tabs (see FAQ for more information)
81
+ * 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
82
+ * Adding a new tab initializes a new wp_editor (WYSIWYG) instead of a plain textarea
83
+ * Added warning message when two tabs have the same title
84
+ * Tabs with empty titles are no longer shown on the product page
85
+ * Added ability to remove the first tab
86
+ * Adding, moving, and removing tabs works as expected when the user's 'Visual Editor' option is checked
87
+ * On the product & settings pages, WYSIWYG editors will default to the visual tab (this helps prevent errors with dynamic wp_editor generation)
88
+ * Added a filter `yikes_woocommerce_default_editor_mode` that can change the default-to-visual-tab behavior (use at your own risk!)
89
+ * Updated the 'How To' text, and slight modification to the style
90
+ * Changed the JavaScript methods controlling how tabs were added, deleted, and moved up/down
91
+ * Cleaned up and commented on all PHP and JavaScript files
92
+ * Added proper i18n, with languages/ folder, .pot file, and `load_plugin_textdomain` hook
93
+ * Incremented version #
94
+
95
  = 1.4.4 - March 1st, 2016 =
96
  * Re-named the tab ID's to support URL's with query args (eg: http://www.example.com/shop#tab-reviews)
97
 
107
  * Now custom product tab and row data/headers only get exported via 'Tools > Export > Products'
108
 
109
  = 1.4 - July 29th, 2015 =
110
+ * 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.
111
 
112
  = 1.3 - July 21st, 2015 =
113
  * Enhancement: Enabled WYSIWYG editor on tab content containers (enables shortcode and content to pass through the_content() filter)
yikes-inc-easy-custom-woocommerce-product-tabs.php CHANGED
@@ -1,13 +1,13 @@
1
  <?php
2
  /**
3
- * Plugin Name: YIKES 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.4.4
9
- * Tested up to: 4.3
10
  * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
 
11
  *
12
  * Copyright: (c) 2014-2015 YIKES Inc.
13
  *
@@ -48,8 +48,8 @@
48
  </style>
49
  <!-- display our error message -->
50
  <div class="error">
51
- <p><?php _e( 'YIKES YIKES Custom Product Tabs for WooCommerce could not be activated because WooCommerce is not installed and active.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
52
- <p><?php _e( 'Please install and activate ', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?><a href="<?php echo admin_url( 'plugin-install.php?tab=search&type=term&s=WooCommerce+-+excelling+eCommerce' ); ?>" title="WooCommerce">WooCommerce</a><?php _e( ' before activating the plugin.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
53
  </div>
54
  <?php
55
  }
@@ -62,7 +62,7 @@
62
  private $tab_data = false;
63
 
64
  /** plugin version number */
65
- const VERSION = "1.4.3";
66
 
67
  /** plugin text domain */
68
  const TEXT_DOMAIN = 'yikes-inc-easy-custom-woocommerce-product-tabs';
@@ -70,6 +70,15 @@
70
  /** plugin version name */
71
  const VERSION_OPTION_NAME = 'yikes_woocommerce_custom_product_tabs_db_version';
72
 
 
 
 
 
 
 
 
 
 
73
  /**
74
  * Gets things started by adding an action to initialize this plugin once
75
  * WooCommerce is known to be active and initialized
@@ -80,6 +89,13 @@
80
  add_action( 'woocommerce_init', array( $this, 'init' ) );
81
  global $typenow;
82
  add_action( 'init', array( $this, 'load_custom_export_filters' ) );
 
 
 
 
 
 
 
83
  }
84
 
85
  public function load_custom_export_filters() {
@@ -129,36 +145,109 @@
129
  * Init WooCommerce Product Tabs Lite extension once we know WooCommerce is active
130
  */
131
  public function init() {
132
- // backend stuff
133
  add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'render_custom_product_tabs' ) );
134
  add_action( 'woocommerce_product_write_panels', array( $this, 'product_page_yikes_custom_tabs_panel' ) );
135
  add_action( 'woocommerce_process_product_meta', array( $this, 'product_save_data' ), 10, 2 );
136
 
137
- // frontend stuff
138
  add_filter( 'woocommerce_product_tabs', array( $this, 'add_custom_product_tabs' ) );
139
 
140
- // allow the use of shortcodes within the tab content
141
  add_filter( 'yikes_woocommerce_custom_repeatable_product_tabs_content', 'do_shortcode' );
142
 
143
- // enqueue our custom js file, for repeatable tabs
144
- add_action( 'admin_enqueue_scripts' , array( $this , 'enqueue_repeatable_tab_script' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
145
  }
146
 
147
- /** Frontend methods ******************************************************/
148
- public function enqueue_repeatable_tab_script( $hook ) {
 
 
 
 
149
  global $post;
150
  if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
151
  if ( $post->post_type == 'product' ) {
 
152
  // script
153
- wp_register_script( 'repeatable-custom-tabs' , plugin_dir_url(__FILE__) . 'js/repeatable-custom-tabs.min.js' , array('jquery') , 'all' );
154
- wp_enqueue_script( 'repeatable-custom-tabs' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  // styles + font
156
- wp_register_style( 'repeatable-custom-tabs-styles' , plugin_dir_url(__FILE__) . 'css/repeatable-custom-tabs.min.css' , '' , 'all' );
157
  wp_enqueue_style( 'repeatable-custom-tabs-styles' );
 
 
 
 
158
  }
159
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
 
 
 
162
  /**
163
  * Add the custom product tab
164
  *
@@ -177,15 +266,28 @@
177
  */
178
  public function add_custom_product_tabs( $tabs ) {
179
  global $product;
180
- if ( get_post_meta( $product->id , 'yikes_woo_products_tabs' , true ) ) {
181
- $this->tab_data = get_post_meta( $product->id , 'yikes_woo_products_tabs' , true );
 
 
 
182
  $i = 25; // setup priorty to loop over, andrender tabs in proper order
183
  foreach ( $this->tab_data as $tab ) {
184
- $tabs[ $tab['id'] ] = array(
185
- 'title' => __( $tab['title'], 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
186
- 'priority' => $i++,
187
- 'callback' => array( $this, 'custom_product_tabs_panel_content' ),
188
- 'content' => $tab['content'], // custom field
 
 
 
 
 
 
 
 
 
 
189
  );
190
  }
191
  if ( isset( $tabs['reviews'] ) ) {
@@ -224,6 +326,19 @@
224
 
225
  /** Admin methods ******************************************************/
226
 
 
 
 
 
 
 
 
 
 
 
 
 
 
227
  /**
228
  * Adds a new tab to the Product Data postbox in the admin product interface
229
  */
@@ -236,98 +351,15 @@
236
  * Adds the panel to the Product Data postbox in the product interface
237
  */
238
  public function product_page_yikes_custom_tabs_panel() {
239
- global $post;
240
- // the product
241
 
242
- if ( defined( 'WOOCOMMERCE_VERSION' ) && version_compare( WOOCOMMERCE_VERSION, '2.1', '<' ) ) {
243
- ?>
244
- <style type="text/css">
245
- #woocommerce-product-data ul.product_data_tabs li.yikes_wc_product_tabs_tab a { padding:5px 5px 5px 28px;background-repeat:no-repeat;background-position:5px 7px; }
246
- </style>
247
- <?php
248
- }
249
 
250
- // pull the custom tab data out of the database
251
- $tab_data = maybe_unserialize( get_post_meta( $post->ID, 'yikes_woo_products_tabs', true ) );
252
-
253
- if ( empty( $tab_data ) ) {
254
- $tab_data['1'] = array( 'title' => '', 'content' => '' , 'duplicate' => '' );
255
- }
256
-
257
- $i = 1;
258
- // display the custom tab panel
259
- echo '<div id="yikes_woocommerce_custom_product_tabs" class="panel wc-metaboxes-wrapper woocommerce_options_panel">';
260
-
261
- echo $this->review_us_container();
262
-
263
- echo '<div class="yikes-woo-tabs-hidden-how-to-info"><h3 style="padding:0 13px;margin-top:0;">' . __( "How To" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . ':</h3><p style="margin:0;padding-left:13px;">' . __( "To generate tabs, click 'Add Another Tab' at the bottom of this container." , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . ' ' . __( "To delete tabs, click 'Remove Tab' to the right of the title field." , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</p> <p style="padding:0 0 0 13px;margin-top:0;margin-bottom:0;"><em>' . __( "Note : Re-save the product to initialize the WordPress content editor on newly created tab content." , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '</em></p></div>';
264
- echo '<div class="dashicons dashicons-editor-help yikes-tabs-how-to-toggle" title="' . __( "Help Me!" , 'yikes-inc-easy-custom-woocommerce-product-tabs' ) . '"></div>';
265
-
266
- // set up the initial display, by looping
267
- foreach ( $tab_data as $tab ) {
268
- if ( $i != 1 ) { ?>
269
- <section class="button-holder" alt="<?php echo $i; ?>">
270
- <!-- Remove tab button, should not generate for the first tab! -->
271
- <a href="#" onclick="return false;" class="button-secondary remove_this_tab"><span class="dashicons dashicons-no-alt" style="line-height:1.3;"></span><?php echo __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
272
- <div style="text-align:center;margin-top:.5em;">
273
- <span class="dashicons dashicons-arrow-up move-tab-data-up"></span>
274
- <span class="dashicons dashicons-arrow-down move-tab-data-down"></span>
275
- </div>
276
- </section>
277
- <?php } else { ?>
278
- <section style="margin-top:3.5em;" class="button-holder" alt="<?php echo $i; ?>">
279
- <div style="text-align:center;">
280
- <span class="dashicons dashicons-arrow-up move-tab-data-up"></span>
281
- <span class="dashicons dashicons-arrow-down move-tab-data-down"></span>
282
- </div>
283
- </section>
284
- <?php }
285
- 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') );
286
- $this->woocommerce_wp_wysiwyg_input( array(
287
- 'id' => '_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i ,
288
- 'label' => __( 'Content', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
289
- 'placeholder' => __( 'HTML and text to display.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ),
290
- 'value' => $tab['content'],
291
- 'style' => 'width:70%;height:10.5em;',
292
- 'class' => 'yikes_woo_tabs_content_field',
293
- 'number' => $i
294
- ) );
295
- if ( $i != count( $tab_data ) ) {
296
- echo '<div class="yikes-woo-custom-tab-divider"></div>';
297
- }
298
- $i++;
299
- }
300
-
301
- ?>
302
- <div id="duplicate_this_row">
303
- <a href="#" onclick="return false;" class="button-secondary remove_this_tab" style="float:right;margin-right:4.25em;"><span class="dashicons dashicons-no-alt" style="line-height:1.3;"></span><?php echo __( 'Remove Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
304
- <?php
305
- // lets add an empty row, to use for duplicating purposes
306
- 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' ) );
307
- $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:70%;height:10.5em;' , 'class' => 'yikes_woo_tabs_content_field' ) );
308
- ?>
309
- <section class="button-holder" alt="<?php echo $i; ?>">
310
- <div style="text-align:center;">
311
- <span class="dashicons dashicons-arrow-up move-tab-data-up"></span>
312
- <span class="dashicons dashicons-arrow-down move-tab-data-down"></span>
313
- </div>
314
- </section>
315
- </div>
316
-
317
- <p>
318
- <label style="display:block;" for="_yikes_wc_custom_repeatable_product_tabs_tab_content_<?php echo $i; ?>"></label>
319
- <a href="#" class="button-secondary" id="add_another_tab"><em class="dashicons dashicons-plus-alt" style="line-height:1.8;font-size:14px;"></em><?php echo __( 'Add Another Tab' , 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></a>
320
- </p>
321
-
322
- <?php
323
- // store number of tabs, for count!
324
- echo '<input type="hidden" value="' . count( $tab_data ) . '" id="number_of_tabs" name="number_of_tabs" >';
325
-
326
- echo '</div>';
327
-
328
  }
329
 
330
-
331
  /**
332
  * Saves the data inputed into the product boxes, as post meta data
333
  * identified by the name 'yikes_woo_products_tabs'
@@ -336,23 +368,51 @@
336
  * @param stdClass $post the post (product)
337
  */
338
  public function product_save_data( $post_id, $post ) {
339
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
340
  $tab_data = array();
341
 
342
  $number_of_tabs = $_POST['number_of_tabs'];
 
 
 
 
 
 
 
 
343
 
344
  $i = 1;
345
  while( $i <= $number_of_tabs ) {
 
 
346
 
347
- $tab_title = stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_'.$i] );
348
- $tab_content = stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_'.$i] );
349
 
350
  if ( empty( $tab_title ) && empty( $tab_content ) ) {
351
 
352
  // clean up if the custom tabs are removed
353
  unset( $tab_data[$i] );
354
 
355
- } elseif ( !empty( $tab_title ) || !empty( $tab_content ) ) {
356
 
357
  $tab_id = '';
358
 
@@ -374,76 +434,97 @@
374
  // prepend with 'tab-' string
375
  }
376
  }
 
 
377
  // push the data to the array
378
  $tab_data[$i] = array( 'title' => $tab_title, 'id' => $tab_id, 'content' => $tab_content );
379
  }
380
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
381
  $i++;
382
-
383
  }
384
-
385
- // reset the array count, when items are removed
386
- $tab_data = array_values( $tab_data );
387
- // update the post data
388
- update_post_meta( $post_id, 'yikes_woo_products_tabs', $tab_data );
389
-
390
- }
391
 
392
- /**
393
- * Generates our woo commerce
394
- * custom product tab textarea fields
395
- *
396
- * @param field
397
- */
398
- private function woocommerce_wp_textarea_input( $field ) {
399
- global $thepostid, $post;
400
 
401
- if ( ! $thepostid ) $thepostid = $post->ID;
402
- if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
403
- if ( ! isset( $field['class'] ) ) $field['class'] = 'short';
404
- if ( ! isset( $field['value'] ) ) $field['value'] = get_post_meta( $thepostid, $field['id'], true );
405
 
406
- echo '<p class="form-field ' . $field['id'] . '_field"><label style="display:block;" for="' . $field['id'] . '">' . $field['label'] . '</label><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> ';
 
 
 
 
 
407
 
408
- if ( isset( $field['description'] ) && $field['description'] ) {
409
- echo '<span class="description">' . $field['description'] . '</span>';
 
 
410
  }
411
-
412
- echo '</p>';
413
- }
414
-
415
- /**
416
- * Generates our woo commerce
417
- * custom product tab textarea fields
418
- *
419
- * @param field
420
- */
421
- private function woocommerce_wp_wysiwyg_input( $field ) {
422
- global $thepostid, $post;
423
-
424
- if ( ! $thepostid ) $thepostid = $post->ID;
425
- if ( ! isset( $field['placeholder'] ) ) $field['placeholder'] = '';
426
- if ( ! isset( $field['class'] ) ) $field['class'] = 'short';
427
- if ( ! isset( $field['value'] ) ) $field['value'] = get_post_meta( $thepostid, $field['id'], true );
428
-
429
- // esc_textarea( $field['value'] )
430
- // $editor_id = $field['id']
431
- $editor_settings = array(
432
- 'textarea_name' => $field['id']
433
- );
434
-
435
- echo '<label class="yikes-custom-wysiwyg-label" style="display:block;" for="' . $field['id'] . '">' . $field['label'] . '</label>'.
436
 
437
- wp_editor( $field['value'], $field['id'], $editor_settings );
438
-
439
- if ( isset( $field['description'] ) && $field['description'] ) {
440
- echo '<span class="description">' . $field['description'] . '</span>';
 
 
 
 
441
  }
442
-
443
  }
444
 
445
-
446
- /** Helper methods ******************************************************/
447
 
448
  /**
449
  * Lazy-load the product_tabs meta data, and return true if it exists,
@@ -478,7 +559,7 @@
478
  }
479
 
480
 
481
- /** Lifecycle methods ******************************************************/
482
 
483
  /**
484
  * Run every time.
@@ -496,19 +577,565 @@
496
  update_option( self::VERSION_OPTION_NAME, self::VERSION );
497
  }
498
  }
499
-
500
- /**
501
- Review Us Container
502
- - displays the yikes logo, inside of the 'Custom Tabs' container
 
 
 
 
 
 
 
 
503
  */
504
- public function review_us_container() {
505
- ?>
506
- <div id="yikes-woo-tabs-review-us">
507
- <a href="http://www.yikesinc.com" target="_blank">
508
- <img src="<?php echo plugin_dir_url(__FILE__) . 'images/yikes_logo.png';?>" title="Plugin created by YIKES Inc." height=40 width=50 class="yikes-logo" >
509
- </a>
510
- </div>
511
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
512
  }
513
 
514
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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.5
 
9
  * Text Domain: yikes-inc-easy-custom-woocommerce-product-tabs
10
+ * Domain Path: languages/
11
  *
12
  * Copyright: (c) 2014-2015 YIKES Inc.
13
  *
48
  </style>
49
  <!-- display our error message -->
50
  <div class="error">
51
+ <p><?php _e( 'Custom Product Tabs for WooCommerce could not be activated because WooCommerce is not installed and active.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
52
+ <p><?php _e( 'Please install and activate ', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?><a href="<?php echo admin_url( 'plugin-install.php?tab=search&type=term&s=WooCommerce' ); ?>" title="WooCommerce">WooCommerce</a><?php _e( ' before activating the plugin.', 'yikes-inc-easy-custom-woocommerce-product-tabs' ); ?></p>
53
  </div>
54
  <?php
55
  }
62
  private $tab_data = false;
63
 
64
  /** plugin version number */
65
+ const VERSION = "1.5";
66
 
67
  /** plugin text domain */
68
  const TEXT_DOMAIN = 'yikes-inc-easy-custom-woocommerce-product-tabs';
70
  /** plugin version name */
71
  const VERSION_OPTION_NAME = 'yikes_woocommerce_custom_product_tabs_db_version';
72
 
73
+ /**
74
+ * Define the page slug for our plugin's custom settings page in one central location
75
+ *
76
+ * @since 1.5
77
+ * @access protected
78
+ * @var string | $settings_page_slug | The page slug for our plugin's custom settings page
79
+ */
80
+ protected $settings_page_slug;
81
+
82
  /**
83
  * Gets things started by adding an action to initialize this plugin once
84
  * WooCommerce is known to be active and initialized
89
  add_action( 'woocommerce_init', array( $this, 'init' ) );
90
  global $typenow;
91
  add_action( 'init', array( $this, 'load_custom_export_filters' ) );
92
+
93
+ // Add our custom options for saving tabs
94
+ add_option( 'yikes_woo_reusable_products_tabs' );
95
+ add_option( 'yikes_woo_reusable_products_tabs_applied' );
96
+
97
+ //Set our variables
98
+ $this->settings_page_slug = 'yikes-woo-settings';
99
  }
100
 
101
  public function load_custom_export_filters() {
145
  * Init WooCommerce Product Tabs Lite extension once we know WooCommerce is active
146
  */
147
  public function init() {
148
+ // Backend stuff (show our custom product tabs on edit screen, handle saving data)
149
  add_action( 'woocommerce_product_write_panel_tabs', array( $this, 'render_custom_product_tabs' ) );
150
  add_action( 'woocommerce_product_write_panels', array( $this, 'product_page_yikes_custom_tabs_panel' ) );
151
  add_action( 'woocommerce_process_product_meta', array( $this, 'product_save_data' ), 10, 2 );
152
 
153
+ // Add our custom product tabs section to the product page
154
  add_filter( 'woocommerce_product_tabs', array( $this, 'add_custom_product_tabs' ) );
155
 
156
+ // Allow the use of shortcodes within the tab content
157
  add_filter( 'yikes_woocommerce_custom_repeatable_product_tabs_content', 'do_shortcode' );
158
 
159
+ // Enqueue our JS / CSS files
160
+ add_action( 'admin_enqueue_scripts' , array( $this , 'enqueue_tab_scripts' ) );
161
+
162
+ // Define our AJAX calls
163
+ add_action( 'wp_ajax_yikes_woo_get_wp_editor', array( $this, 'yikes_woo_get_wp_editor' ) );
164
+ add_action( 'wp_ajax_yikes_woo_save_tab_as_reusable', array( $this, 'yikes_woo_save_tab_as_reusable' ) );
165
+ add_action( 'wp_ajax_yikes_woo_fetch_reusable_tab', array( $this, 'yikes_woo_fetch_reusable_tab' ) );
166
+ add_action( 'wp_ajax_yikes_woo_delete_reusable_tab_handler', array( $this, 'yikes_woo_delete_reusable_tab_handler' ) );
167
+ add_action( 'wp_ajax_yikes_woo_save_product_tabs', array( $this, 'yikes_woo_save_product_tabs' ) );
168
+
169
+ // Add our custom settings page
170
+ add_action( 'admin_menu', array( $this, 'yikes_woo_register_settings_page' ) );
171
+
172
+ // Default WYSIWYG to 'visual'
173
+ add_filter( 'wp_default_editor', array( $this, 'yikes_woo_set_editor_to_visual' ) );
174
+
175
+ // i18n
176
+ add_action( 'plugins_loaded', array( $this, 'yikes_woo_load_plugin_textdomain' ) );
177
+
178
+ // Add settings link to plugin on plugins page
179
+ add_filter( 'plugin_action_links_' . plugin_basename(__FILE__), array( $this, 'add_plugin_action_links' ), 10, 1 );
180
  }
181
 
182
+ /**
183
+ * Enqueue all the required scripts and styles on the appropriate pages
184
+ *
185
+ * @param string | $hook | The current page slug
186
+ */
187
+ public function enqueue_tab_scripts( $hook ) {
188
  global $post;
189
  if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
190
  if ( $post->post_type == 'product' ) {
191
+
192
  // script
193
+ wp_enqueue_script ( 'repeatable-custom-tabs', plugin_dir_url(__FILE__) . 'js/repeatable-custom-tabs.min.js' , array( 'jquery' ) , 'all' );
194
+ wp_localize_script( 'repeatable-custom-tabs', 'repeatable_custom_tabs', array(
195
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
196
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
197
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
198
+ 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
199
+ 'fetch_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_fetch_reusable_tab_nonce' ),
200
+ 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' ),
201
+ 'save_product_tabs_nonce' => wp_create_nonce( 'yikes_woo_save_product_tabs_nonce' ),
202
+ 'global_post_id' => $post->ID,
203
+ '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')
204
+ ) );
205
+
206
+ wp_enqueue_script ( 'repeatable-custom-tabs-shared', plugin_dir_url(__FILE__) . 'js/repeatable-custom-tabs-shared.min.js' );
207
+ wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
208
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
209
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
210
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
211
+ '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'),
212
+ ) );
213
+
214
  // styles + font
215
+ wp_register_style( 'repeatable-custom-tabs-styles' , plugin_dir_url(__FILE__) . 'css/repeatable-custom-tabs.min.css', '', self::VERSION, 'all' );
216
  wp_enqueue_style( 'repeatable-custom-tabs-styles' );
217
+
218
+ // JS lity modal library and CSS
219
+ wp_enqueue_script( 'lity-js', plugin_dir_url(__FILE__) . 'js/lity.min.js' , array( 'jquery' ) , 'all' );
220
+ wp_enqueue_style( 'lity-css', plugin_dir_url(__FILE__) . 'css/dist/lity.min.css' );
221
  }
222
  }
223
+
224
+ if ( $hook === 'settings_page_' . $this->settings_page_slug ) {
225
+ // script
226
+ wp_enqueue_script ( 'repeatable-custom-tabs-settings', plugin_dir_url(__FILE__) . 'js/repeatable-custom-tabs-settings.min.js' , array( 'jquery' ) , 'all' );
227
+ wp_localize_script( 'repeatable-custom-tabs-settings', 'repeatable_custom_tabs_settings', array(
228
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif-settings" />',
229
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
230
+ 'tab_list_page_url' => admin_url( esc_url_raw( 'options-general.php?page=' . $this->settings_page_slug ) ),
231
+ 'save_tab_as_reusable_nonce' => wp_create_nonce( 'yikes_woo_save_tab_as_reusable_nonce' ),
232
+ 'delete_reusable_tab_nonce' => wp_create_nonce( 'yikes_woo_delete_reusable_tab_nonce' )
233
+ ) );
234
+
235
+ wp_enqueue_script ( 'repeatable-custom-tabs-shared', plugin_dir_url(__FILE__) . 'js/repeatable-custom-tabs-shared.min.js' );
236
+ wp_localize_script( 'repeatable-custom-tabs-shared', 'repeatable_custom_tabs_shared', array(
237
+ 'loading_gif' => '<img src="' . admin_url( 'images/loading.gif' ) . '" alt="preloader" class="loading-wp-editor-gif" />',
238
+ 'ajaxurl' => admin_url( 'admin-ajax.php' ),
239
+ 'get_wp_editor_security_nonce' => wp_create_nonce( 'yikes_woo_get_wp_editor_nonce' ),
240
+ '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'),
241
+ ) );
242
+
243
+ // styles + font
244
+ wp_register_style( 'repeatable-custom-tabs-styles' , plugin_dir_url(__FILE__) . 'css/repeatable-custom-tabs.min.css', '', self::VERSION, 'all' );
245
+ wp_enqueue_style( 'repeatable-custom-tabs-styles' );
246
+ }
247
  }
248
 
249
+ /** Frontend methods ******************************************************/
250
+
251
  /**
252
  * Add the custom product tab
253
  *
266
  */
267
  public function add_custom_product_tabs( $tabs ) {
268
  global $product;
269
+
270
+ $product_tabs = get_post_meta( $product->id , 'yikes_woo_products_tabs' , true );
271
+
272
+ if ( !empty( $product_tabs ) ) {
273
+ $this->tab_data = $product_tabs;
274
  $i = 25; // setup priorty to loop over, andrender tabs in proper order
275
  foreach ( $this->tab_data as $tab ) {
276
+
277
+ // Do not show tabs with empty titles on the front end
278
+ if ( empty( $tab['title'] ) ) {
279
+ continue;
280
+ }
281
+
282
+ $tab_key = $tab['id'];
283
+
284
+
285
+ $tabs[$tab_key] = array(
286
+ 'title' => $tab['title'],
287
+ 'priority' => $i++,
288
+ 'callback' => array( $this, 'custom_product_tabs_panel_content' ),
289
+ 'content' => $tab['content'], // custom field
290
+ 'class' => 'custom-css-class'
291
  );
292
  }
293
  if ( isset( $tabs['reviews'] ) ) {
326
 
327
  /** Admin methods ******************************************************/
328
 
329
+ /**
330
+ * Add a link to the settings page to the plugin's action links
331
+ *
332
+ * @since 1.5
333
+ *
334
+ * @param array | $links | array of links passed from the plugin_action_links_{plugin_name} filter
335
+ */
336
+ public function add_plugin_action_links( $links ) {
337
+ $href = admin_url( esc_url_raw( 'options-general.php?page=' . $this->settings_page_slug ) );
338
+ $links[] = '<a href="'. $href .'">Settings</a>';
339
+ return $links;
340
+ }
341
+
342
  /**
343
  * Adds a new tab to the Product Data postbox in the admin product interface
344
  */
351
  * Adds the panel to the Product Data postbox in the product interface
352
  */
353
  public function product_page_yikes_custom_tabs_panel() {
 
 
354
 
355
+ // Require & instantiate our HTML class
356
+ require_once( plugin_dir_path( __FILE__ ) . 'admin/class.yikes-woo-generate-html.php' );
357
+ $HTML = new Yikes_Woo_Custom_Product_Tabs_HTML();
 
 
 
 
358
 
359
+ // Call our function to generate the HTML
360
+ $HTML->generate_html();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  }
362
 
 
363
  /**
364
  * Saves the data inputed into the product boxes, as post meta data
365
  * identified by the name 'yikes_woo_products_tabs'
368
  * @param stdClass $post the post (product)
369
  */
370
  public function product_save_data( $post_id, $post ) {
371
+
372
+ // Make sure we have a $post_id
373
+ if ( empty( $post_id ) ) {
374
+ return;
375
+ }
376
+
377
+ // Save our tabs!
378
+ $this->save_tabs( $post_id, $is_ajax = false );
379
+ }
380
+
381
+ /**
382
+ * Save the tabs to the database
383
+ *
384
+ * @since 1.5
385
+ *
386
+ * @param int | $post_id | The ID of the post that has custom tabs
387
+ * @param bool | $is_ajax_flag | A flag signifying whether we're calling this function from an AJAX call
388
+ */
389
+ protected function save_tabs( $post_id, $is_ajax_flag ) {
390
  $tab_data = array();
391
 
392
  $number_of_tabs = $_POST['number_of_tabs'];
393
+
394
+ // Create an array for tab_ids that we will use later
395
+ $current_tab_id_array = array();
396
+ $post_has_reusable_tabs = false;
397
+ $remove_a_tab_from_reusable = false;
398
+
399
+ // Fetch the reusable tab options (we'll use this later)
400
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
401
 
402
  $i = 1;
403
  while( $i <= $number_of_tabs ) {
404
+
405
+ // Deal with saving the tab content
406
 
407
+ $tab_title = stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_title_' . $i] );
408
+ $tab_content = stripslashes( $_POST['_yikes_wc_custom_repeatable_product_tabs_tab_content_' . $i] );
409
 
410
  if ( empty( $tab_title ) && empty( $tab_content ) ) {
411
 
412
  // clean up if the custom tabs are removed
413
  unset( $tab_data[$i] );
414
 
415
+ } elseif ( ! empty( $tab_title ) || ! empty( $tab_content ) ) {
416
 
417
  $tab_id = '';
418
 
434
  // prepend with 'tab-' string
435
  }
436
  }
437
+ $current_tab_id_array[] = $tab_id;
438
+
439
  // push the data to the array
440
  $tab_data[$i] = array( 'title' => $tab_title, 'id' => $tab_id, 'content' => $tab_content );
441
  }
442
 
443
+ // Deal with saving / applying globally saved tabs
444
+
445
+ 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'] ) ) {
446
+
447
+ // Store the tab_id and action
448
+ $reusable_tab_id = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i];
449
+ $reusable_tab_action = $_POST['_yikes_wc_custom_repeatable_product_tabs_saved_tab_id_' . $i . '_action'];
450
+
451
+ // If $reusable_tab_options_array is not empty, we've done this before
452
+ if ( ! empty( $reusable_tab_options_array ) ) {
453
+
454
+ // Check if this tab has reusable tabs and set flag
455
+ if ( isset ( $reusable_tab_options_array[$post_id] ) ) {
456
+ $post_has_reusable_tabs = true;
457
+ }
458
+
459
+ // If action is 'add', add the tab!
460
+ if ( $reusable_tab_action == 'add' ) {
461
+
462
+ $reusable_tab_options_array[$post_id][$reusable_tab_id] = array(
463
+ 'post_id' => $post_id,
464
+ 'reusable_tab_id' => $reusable_tab_id,
465
+ 'tab_id' => $tab_id
466
+ );
467
+
468
+ // Update our applied tabs array
469
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
470
+
471
+ } elseif ( $reusable_tab_action == 'remove' ) {
472
+
473
+ // This tab will no longer be affected by the global/reusable tab changes
474
+ unset( $reusable_tab_options_array[$post_id][$reusable_tab_id] );
475
+
476
+ // Update our applied tabs array
477
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
478
+ }
479
+ } elseif ( $reusable_tab_action == 'add' ) {
480
+
481
+ // First time adding a new tab
482
+ $reusable_tab_options_array_to_save = array();
483
+ $reusable_tab_options_array_to_save[$post_id][$reusable_tab_id] = array(
484
+ 'post_id' => $post_id,
485
+ 'reusable_tab_id' => $reusable_tab_id,
486
+ 'tab_id' => $tab_id
487
+ );
488
+
489
+ // Update our applied tabs array
490
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array_to_save );
491
+ }
492
+ }
493
+
494
  $i++;
 
495
  }
 
 
 
 
 
 
 
496
 
497
+ // Let's check our $current_tab_id_array and see if we need to remove any reusable tabs
498
+ if ( $post_has_reusable_tabs === true ) {
 
 
 
 
 
 
499
 
500
+ // Loop through our reusable tab array
501
+ foreach( $reusable_tab_options_array[$post_id] as $id => $reusable_tab_array ) {
 
 
502
 
503
+ // If we find one of our reusable tabs is no longer part of this post, remove it
504
+ if ( ! in_array( $reusable_tab_array['tab_id'], $current_tab_id_array ) ) {
505
+ unset( $reusable_tab_options_array[$post_id][$id] );
506
+ $remove_a_tab_from_reusable = true;
507
+ }
508
+ }
509
 
510
+ // If we removed a tab, then update our applied tabs array
511
+ if ( $remove_a_tab_from_reusable === true ) {
512
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array );
513
+ }
514
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
515
 
516
+ // Reset the array count, when items are removed
517
+ $tab_data = array_values( $tab_data );
518
+
519
+ // update the post data
520
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $tab_data );
521
+
522
+ if ( $is_ajax_flag === true ) {
523
+ return true;
524
  }
 
525
  }
526
 
527
+ /* Helper methods */
 
528
 
529
  /**
530
  * Lazy-load the product_tabs meta data, and return true if it exists,
559
  }
560
 
561
 
562
+ /* Lifecycle methods */
563
 
564
  /**
565
  * Run every time.
577
  update_option( self::VERSION_OPTION_NAME, self::VERSION );
578
  }
579
  }
580
+
581
+ /* AJAX Functions */
582
+
583
+ /**
584
+ * [AJAX] Return wp_editor HTML
585
+ * (this is a bit funky, I know, but it's part of dynamically adding / removing the WYSIWYG )
586
+ *
587
+ * @since 1.5
588
+ *
589
+ * @param string $_POST['textarea_id'] ID of the textarea that we're initializing wp_editor with
590
+ * @param string $_POST['tab_content'] content to pre-supply the text editor with
591
+ * @return string wp_editor HTML
592
  */
593
+ public function yikes_woo_get_wp_editor() {
594
+
595
+ // Verify nonce
596
+ if ( ! check_ajax_referer( 'yikes_woo_get_wp_editor_nonce', 'security_nonce', false ) ) {
597
+ wp_send_json_error();
598
+ }
599
+
600
+ // Get & sanitize the $_POST var textarea_id
601
+ $textarea_id = filter_var( $_POST['textarea_id'], FILTER_SANITIZE_STRING );
602
+
603
+ // Check if we have tab content
604
+ $tab_content = isset( $_POST['tab_content'] ) ? $_POST['tab_content'] : '';
605
+
606
+ // Set up options
607
+ $wp_editor_options = array(
608
+ 'textarea_name' => $textarea_id,
609
+ 'textarea_rows' => 8
610
+ );
611
+
612
+ // Return wp_editor HTML
613
+ wp_editor( $tab_content, $textarea_id, $wp_editor_options );
614
+ wp_die();
615
  }
616
 
617
+ /**
618
+ * [AJAX] Save a tab as reusable
619
+ *
620
+ * @since 1.5
621
+ *
622
+ * @param string $_POST['tab_title'] Tab title to save
623
+ * @param string $_POST['tab_content'] Tab content to save
624
+ * @param string $_POST['tab_id'] Optional. Tab ID we're updating
625
+ * @return object success || failure
626
+ */
627
+ public function yikes_woo_save_tab_as_reusable() {
628
+
629
+ // Verify the nonce
630
+ if ( ! check_ajax_referer( 'yikes_woo_save_tab_as_reusable_nonce', 'security_nonce', false ) ) {
631
+ wp_send_json_error();
632
+ }
633
+
634
+ // Define it now, because we may use this later...
635
+ $return_redirect_url = '';
636
+
637
+ // Get our $_POST vars
638
+ if ( isset( $_POST['tab_title'] ) && ! empty( $_POST['tab_title'] ) ) {
639
+ $tab_title = stripslashes( $_POST['tab_title'] );
640
+
641
+ $tab_string_id = strtolower( $tab_title );
642
+ $tab_string_id = preg_replace( "/[^\w\s]/", '', $tab_string_id );
643
+ // remove non-alphas, numbers, underscores or whitespace
644
+ $tab_string_id = preg_replace( "/_+/", ' ', $tab_string_id );
645
+ // replace all underscores with single spaces
646
+ $tab_string_id = preg_replace( "/\s+/", '-', $tab_string_id );
647
+ } else {
648
+ wp_send_json_error( array( 'reason' => 'no tab title', 'message' => 'Please fill out the tab title before saving.' ) );
649
+ }
650
+
651
+ if ( isset( $_POST['tab_content'] ) && ! empty( $_POST['tab_content'] ) ) {
652
+ $tab_content = $_POST['tab_content'];
653
+ }
654
+
655
+ if ( isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ) {
656
+ $tab_id = $_POST['tab_id'];
657
+ }
658
+
659
+ // Get our saved tabs array
660
+ $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
661
+
662
+ // If the saved tabs array is empty, create a new array and save it (first time we've done this)
663
+ if ( empty( $yikes_custom_tab_data ) ) {
664
+ $yikes_custom_tab_options_array = array();
665
+
666
+ $yikes_custom_tab_options_array[1] = array(
667
+ 'tab_title' => $tab_title,
668
+ 'tab_content' => $tab_content,
669
+ 'tab_id' => 1
670
+ );
671
+
672
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_options_array );
673
+
674
+ // Return redirect URL
675
+ $return_redirect_url = admin_url( add_query_arg( array( 'saved-tab-id' => 1 ), esc_url_raw( 'options-general.php?page=' . $this->settings_page_slug ) ) );
676
+
677
+ // Send response
678
+ wp_send_json_success( array( 'tab_id' => 1, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
679
+ } else {
680
+
681
+ // this is a new tab and we need to create a unique ID
682
+ if ( $tab_id === 'new' ) {
683
+
684
+ // Get the max ID we have saved
685
+ foreach ( $yikes_custom_tab_data as $tab_data ) {
686
+ if ( ! isset( $highest_tab_id ) ) {
687
+ $highest_tab_id = $tab_data['tab_id'];
688
+ } else {
689
+ if ( $tab_data['tab_id'] > $highest_tab_id ) {
690
+ $highest_tab_id = $tab_data['tab_id'];
691
+ }
692
+ }
693
+ }
694
+
695
+ // Add 1 to the max ID
696
+ $new_tab_id = (int) $highest_tab_id + 1;
697
+
698
+ $yikes_custom_tab_data[$new_tab_id] = array(
699
+ 'tab_title' => $tab_title,
700
+ 'tab_content' => $tab_content,
701
+ 'tab_id' => $new_tab_id
702
+ );
703
+
704
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
705
+
706
+ // Return redirect URL
707
+ $return_redirect_url = admin_url( add_query_arg( array( 'saved-tab-id' => $new_tab_id ), esc_url_raw( 'options-general.php?page=' . $this->settings_page_slug ) ) );
708
+
709
+ // Send response
710
+ wp_send_json_success( array( 'tab_id' => $new_tab_id, 'redirect' => true, 'redirect_url' => $return_redirect_url ) );
711
+
712
+ } else {
713
+
714
+ // This is an existing tab, so just update it
715
+ $yikes_custom_tab_data[$tab_id] = array(
716
+ 'tab_title' => $tab_title,
717
+ 'tab_content' => $tab_content,
718
+ 'tab_id' => $tab_id
719
+ );
720
+
721
+ update_option( 'yikes_woo_reusable_products_tabs', $yikes_custom_tab_data );
722
+
723
+ // Now apply this updated tab's data to custom product tabs that use it
724
+
725
+ // Get the array of applied product tabs
726
+ $reusable_tab_options_array = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
727
+
728
+ // Flag so we know we found a post and we should update it
729
+ $update_post_meta_flag = false;
730
+
731
+ // Flag so we know we have to update the yikes_woo_reusable_products_tabs_applied
732
+ $update_applied_products_array = false;
733
+
734
+ foreach( $reusable_tab_options_array as $post_id => $reusable_tab_data ) {
735
+
736
+ // Fetch the relevant postmeta field
737
+ $custom_tab_data = get_post_meta( $post_id, 'yikes_woo_products_tabs', true );
738
+
739
+ // If we don't have custom tab data then continue
740
+ if ( empty( $custom_tab_data ) ) {
741
+ continue;
742
+ }
743
+
744
+ // Loop through $custom_tab_data and find the custom tab that was just updated
745
+ foreach( $custom_tab_data as $index => $tab ) {
746
+ if ( $tab['id'] === $reusable_tab_data[$tab_id]['tab_id'] ) {
747
+ $custom_tab_data[$index]['title'] = $tab_title;
748
+ $custom_tab_data[$index]['content'] = $tab_content;
749
+ $custom_tab_data[$index]['id'] = $tab_string_id;
750
+
751
+ // We may need to update the tab_string_id too
752
+ if ( $tab_string_id !== $tab['id'] ) {
753
+ $reusable_tab_options_array[$post_id][$tab_id]['tab_id'] = $tab_string_id;
754
+ $update_applied_products_array = true;
755
+ }
756
+ $update_post_meta_flag = true;
757
+ }
758
+ }
759
+
760
+ // If we updated a tab, save it
761
+ if ( $update_post_meta_flag === true ) {
762
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $custom_tab_data );
763
+ }
764
+
765
+ // If we updated the tab_string_id in the yikes_woo_reusable_products_tabs_applied array, save it
766
+ if ( $update_applied_products_array === true ) {
767
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $reusable_tab_options_array);
768
+ }
769
+ }
770
+ }
771
+ }
772
+
773
+ wp_send_json_success( array( 'redirect' => false ) );
774
+ }
775
+
776
+ /**
777
+ * [AJAX] Fetch all reusable tabs
778
+ *
779
+ * @since 1.5
780
+ *
781
+ * @return object success w/ saved_tabs || failure w/ message
782
+ */
783
+ public function yikes_woo_fetch_reusable_tab() {
784
+
785
+ // Verify the nonce
786
+ if ( ! check_ajax_referer( 'yikes_woo_fetch_reusable_tab_nonce', 'security_nonce', false ) ) {
787
+ wp_send_json_error();
788
+ }
789
+
790
+ // Get the array of saved tabs
791
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
792
+
793
+ // Convert special chars to HTML
794
+ foreach( $saved_tabs as $key => $tab ) {
795
+ if ( isset( $tab['tab_content'] ) ) {
796
+
797
+ // stripslashes() necessary for images
798
+ $saved_tabs[$key]['tab_content'] = stripslashes( $tab['tab_content'] );
799
+ }
800
+ }
801
+
802
+ if ( ! empty( $saved_tabs ) ) {
803
+ wp_send_json_success( json_encode( $saved_tabs ) );
804
+ } else {
805
+ wp_send_json_success( array( 'message' => 'No saved tabs were found.' ) );
806
+ }
807
+
808
+ // If we get this far, send error
809
+ wp_send_json_error( array( 'message' => 'Uh oh. Something went wrong.' ) );
810
+ }
811
+
812
+ /**
813
+ * [AJAX] Delete a reusable tab
814
+ *
815
+ * @since 1.5
816
+ *
817
+ * @param string $_POST['tab_id']
818
+ * @return object success w/ saved_tabs || failure w/ message
819
+ */
820
+ public function yikes_woo_delete_reusable_tab_handler() {
821
+
822
+ // Verify the nonce
823
+ if ( ! check_ajax_referer( 'yikes_woo_delete_reusable_tab_nonce', 'security_nonce', false ) ) {
824
+ wp_send_json_error();
825
+ }
826
+
827
+ // Get our tab_id
828
+ if ( isset( $_POST['tab_id'] ) && ! empty( $_POST['tab_id'] ) ) {
829
+
830
+ $tab_ids = $_POST['tab_id'];
831
+
832
+ // if $tab_ids isn't an array, turn it into one
833
+ if ( ! is_array( $tab_ids ) ) {
834
+ $tab_ids = array( $tab_ids );
835
+ }
836
+
837
+ // Set this up before we use it
838
+ $return_vars = array();
839
+
840
+ foreach( $tab_ids as $tab_id ) {
841
+
842
+ // Delete the tab, store the return values in $return_vars
843
+ $return_vars = $this->yikes_woo_delete_reusable_tab( $tab_id );
844
+
845
+ // Make sure $return_vars is what we think it is, and check if our delete failed
846
+ if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === false ) {
847
+
848
+ // If something failed, let's return
849
+ wp_send_json_error( $return_vars );
850
+ }
851
+ }
852
+ } else {
853
+
854
+ // Fail if we don't have a tab_id
855
+ wp_send_json_error( array( 'reason' => 'no tab id' ) );
856
+ }
857
+
858
+ // Make sure $return_vars is what we think it is, and check if our delete was successful
859
+ if ( is_array( $return_vars ) && isset( $return_vars['success'] ) && $return_vars['success'] === true ) {
860
+
861
+ // If nothing failed, let's return
862
+ wp_send_json_success( $return_vars );
863
+ }
864
+
865
+ // We shouldn't have gotten this far, but if we did let's return failure
866
+ wp_send_json_failure();
867
+ }
868
+
869
+ /**
870
+ * [AJAX] Save all tabs for the current product
871
+ *
872
+ * @since 1.5
873
+ *
874
+ * @param string $_POST['post_id'] | ID of the current product (post)
875
+ * @param array $_POST['product_tabs'] | array of all the tab data
876
+ * @return object success w/ message || failure w/ message
877
+ */
878
+ public function yikes_woo_save_product_tabs() {
879
+
880
+ // Verify the nonce
881
+ if ( ! check_ajax_referer( 'yikes_woo_save_product_tabs_nonce', 'security_nonce', false ) ) {
882
+ wp_send_json_error();
883
+ }
884
+
885
+ // Get our product id
886
+ if ( isset( $_POST['post_id'] ) ) {
887
+ $post_id = filter_var( $_POST['post_id'], FILTER_SANITIZE_NUMBER_INT );
888
+ } else {
889
+
890
+ // Fail gracefully...
891
+ wp_send_json_failure( array( 'message' => 'Could not find the product!' ) );
892
+ }
893
+
894
+ // Save our tabs!
895
+ $success = $this->save_tabs( $post_id, $is_ajax = true );
896
+
897
+ if ( $success === true ) {
898
+ wp_send_json_success( array( 'message' => 'Your tabs have been saved' ) );
899
+ } else {
900
+ wp_send_json_failure( array( 'message' => 'Uh oh! Something went wrong with saving. Please try again.' ) );
901
+ }
902
+ }
903
+
904
+ /* End AJAX Functions */
905
+
906
+ /* AJAX Helper Functions */
907
+
908
+ /**
909
+ * Delete a saved tab from the options array and delete the tab from the product's tabs array
910
+ *
911
+ * @since 1.5
912
+ *
913
+ * @param int | $tab_id | unique identifier of a tab
914
+ * @return array | $response | array of data signifying success, message, reason, and other needed data
915
+ */
916
+ protected function yikes_woo_delete_reusable_tab( $tab_id ) {
917
+
918
+ // The following code will remove the tab from our array of saved tabs
919
+
920
+ // Fetch all saved tabs
921
+ $saved_tabs = get_option( 'yikes_woo_reusable_products_tabs' );
922
+
923
+ // Check some stuff, then remove the tab from our array of saved tabs
924
+ if ( ! empty( $saved_tabs ) ) {
925
+ if ( isset( $saved_tabs[$tab_id] ) ) {
926
+ unset( $saved_tabs[$tab_id] );
927
+ update_option( 'yikes_woo_reusable_products_tabs', $saved_tabs );
928
+ } else {
929
+ $response = array(
930
+ 'success' => false,
931
+ 'tab_id' => $tab_id,
932
+ 'message' => 'No saved tab with id ' . $tab_id . ' found!',
933
+ 'reason' => 'no saved tab found'
934
+ );
935
+ return $response;
936
+ }
937
+ } else {
938
+ $response = array(
939
+ 'success' => false,
940
+ 'tab_id' => $tab_id,
941
+ 'message' => 'No saved tabs found!',
942
+ 'reason' => 'no saved tabs found'
943
+ );
944
+ return $response;
945
+ }
946
+
947
+ // The following code will remove the tab from our array of applied tabs and postmeta
948
+
949
+ // Fetch all applied tabs
950
+ $applied_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
951
+
952
+ // Set a flag so we know if we need to update the database
953
+ $unset_applied_tabs_flag = false;
954
+
955
+ if ( ! empty( $applied_tabs ) ) {
956
+
957
+ // Run through all the applied tabs and remove the ones with this ID
958
+ foreach( $applied_tabs as $post_id => $applied_tabs_array ) {
959
+
960
+ // If this ID is set, unset the array
961
+ if ( isset( $applied_tabs_array[$tab_id] ) ) {
962
+
963
+ // Now we also need to remove this entry from our postmeta
964
+ $post_tabs = get_post_meta( $post_id, 'yikes_woo_products_tabs', true );
965
+
966
+ // Make sure it exists
967
+ if ( ! empty( $post_tabs ) ) {
968
+ foreach ( $post_tabs as $index => $post_tab ) {
969
+ if ( $applied_tabs[$post_id][$tab_id]['tab_id'] === $post_tab['id'] ) {
970
+ unset( $post_tabs[$index] );
971
+ update_post_meta( $post_id, 'yikes_woo_products_tabs', $post_tabs );
972
+ }
973
+ }
974
+ }
975
+
976
+ unset( $applied_tabs[$post_id][$tab_id] );
977
+ $unset_applied_tabs_flag = true;
978
+ }
979
+ }
980
+
981
+ // If we unset an applied tab, update the database
982
+ if ( $unset_applied_tabs_flag === true ) {
983
+ update_option( 'yikes_woo_reusable_products_tabs_applied', $applied_tabs );
984
+ }
985
+ }
986
+
987
+ // If we're on the single tab edit screen, we want to redirect back to tab list so let's return a var
988
+ $return_redirect_url = admin_url( add_query_arg( array( 'delete-success' => true ), esc_url_raw( 'options-general.php?page=' . $this->settings_page_slug ) ) );
989
+
990
+ $response = array(
991
+ 'success' => true,
992
+ 'tab_id' => $tab_id,
993
+ 'message' => 'Tab successfully deleted!',
994
+ 'reason' => 'tab successfully deleted',
995
+ 'redirect_url' => $return_redirect_url
996
+ );
997
+
998
+ return $response;
999
+ }
1000
+
1001
+ /* End AJAX Helper Functions */
1002
+
1003
+ /* Plugin Settings Page */
1004
+
1005
+ /**
1006
+ * Register our settings page
1007
+ *
1008
+ * @since 1.5
1009
+ *
1010
+ */
1011
+ public function yikes_woo_register_settings_page() {
1012
+
1013
+ // Add our custom settings page
1014
+ add_submenu_page(
1015
+ 'options-general.php', // Parent slug
1016
+ __( 'Settings - Custom Product Tabs for WooCommerce', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Tab title name (HTML title)
1017
+ __( 'Custom Product Tabs for WooCommerce', 'yikes-inc-easy-custom-woocommerce-product-tabs' ), // Menu page name
1018
+ apply_filters( 'yikes_simple_taxonomy_ordering_capabilities', 'manage_options' ), // Capability required
1019
+ $this->settings_page_slug, // Page slug (?page=slug-name)
1020
+ array( $this, 'generate_yikes_settings_page' ) // Function to generate page
1021
+ );
1022
+ }
1023
+
1024
+ /**
1025
+ * Include our settings page
1026
+ *
1027
+ * @since 1.5
1028
+ *
1029
+ */
1030
+ public function generate_yikes_settings_page() {
1031
+
1032
+ // Get our settings page slug for redirect purposes
1033
+ $settings_page_slug = $this->settings_page_slug;
1034
+
1035
+ // Get our saved tabs array
1036
+ $yikes_custom_tab_data = get_option( 'yikes_woo_reusable_products_tabs', array() );
1037
+
1038
+ // If saved_tab_id is set, we should show the single saved tab // add new tab page
1039
+ if ( isset( $_GET['saved-tab-id'] ) && ! empty( $_GET['saved-tab-id'] ) ) {
1040
+
1041
+ // Are we trying to add a new tab?
1042
+ $new_tab = ( $_GET['saved-tab-id'] === 'new' ) ? true : false;
1043
+
1044
+ // Sanitize saved_tab_id
1045
+ $saved_tab_id = filter_var( $_GET['saved-tab-id'], FILTER_SANITIZE_NUMBER_INT );
1046
+
1047
+ // Get the tab
1048
+ $tab = isset( $yikes_custom_tab_data[$saved_tab_id] ) ? $yikes_custom_tab_data[$saved_tab_id] : array();
1049
+
1050
+ // Get all the products using this tab
1051
+ $products = $this->fetch_all_products_using_current_tab( $saved_tab_id );
1052
+
1053
+ // Redirect URL
1054
+ $redirect = admin_url( esc_url_raw( 'options-general.php?page=' . $settings_page_slug ) );
1055
+
1056
+ require_once( plugin_dir_path(__FILE__) . 'admin/page.yikes-woo-saved-tabs-single.php' );
1057
+
1058
+ } else {
1059
+ $delete_message_display = 'display: none;';
1060
+
1061
+ // Check if our $_GET variable 'delete-success' is set so we can display a nice success message
1062
+ if ( isset( $_GET['delete-success'] ) && $_GET['delete-success'] === '1' ) {
1063
+ $delete_message_display = '';
1064
+ }
1065
+
1066
+ // New tab URL - used to supply the 'Add Tab' href
1067
+ $new_tab_url = add_query_arg( array( 'saved-tab-id' => 'new' ), esc_url_raw( 'options-general.php?page=' . $settings_page_slug ) );
1068
+
1069
+ // Show tab table list
1070
+ require_once( plugin_dir_path(__FILE__) . 'admin/page.yikes-woo-saved-tabs.php' );
1071
+ }
1072
+ }
1073
+
1074
+ /**
1075
+ * Fetch all product ids that are using the saved tab
1076
+ *
1077
+ * @since 1.5
1078
+ *
1079
+ * @param int | $tab_id | unique identifier of a tab
1080
+ * @return array | $product_ids_array | array of product ids
1081
+ */
1082
+ protected function fetch_all_products_using_current_tab( $tab_id ) {
1083
+
1084
+ // Set up our return array
1085
+ $product_ids_array = array();
1086
+
1087
+ // Get all of the product IDs from the DB
1088
+ $applied_tabs = get_option( 'yikes_woo_reusable_products_tabs_applied', array() );
1089
+
1090
+ // If the option returns an empty array, C YA
1091
+ if ( empty( $applied_tabs ) ) {
1092
+ return $product_ids_array;
1093
+ }
1094
+
1095
+ // Loop through all of our applied tabs and get the product IDs
1096
+ foreach( $applied_tabs as $product_id => $saved_tabs_array ) {
1097
+
1098
+ // This means the product is using this saved tab
1099
+ if ( isset( $saved_tabs_array[$tab_id] ) ) {
1100
+ $product_ids_array[] = $product_id;
1101
+ }
1102
+ }
1103
+
1104
+ return $product_ids_array;
1105
+ }
1106
+
1107
+ /* End Plugin Settings Page */
1108
+
1109
+ /* i18n */
1110
+
1111
+ /**
1112
+ * Register the textdomain for proper i18n / l10n
1113
+ * @since 1.5
1114
+ */
1115
+ public function yikes_woo_load_plugin_textdomain() {
1116
+ load_plugin_textdomain(
1117
+ 'yikes-inc-easy-custom-woocommerce-product-tabs',
1118
+ false,
1119
+ plugin_dir_path(__FILE__) . 'languages/'
1120
+ );
1121
+ }
1122
+
1123
+ /* End i18n */
1124
+
1125
+
1126
+ /* Misc. */
1127
+
1128
+ /**
1129
+ * Default the wp_editor to 'Visual' tab (this helps prevent errors with dynamically generating WYSIWYG)
1130
+ *
1131
+ * @since 1.5
1132
+ *
1133
+ * @return string 'tinymce'
1134
+ */
1135
+ public function yikes_woo_set_editor_to_visual() {
1136
+ $default_editor_tab = apply_filters( 'yikes_woocommerce_default_editor_mode', 'tinymce' );
1137
+ return $default_editor_tab;
1138
+ }
1139
+
1140
+ /* End Misc. */
1141
+ }