ACF Photo Gallery Field - Version 1.7.6

Version Description

Download this release

Release Info

Developer navzme
Plugin Icon 128x128 ACF Photo Gallery Field
Version 1.7.6
Comparing to
See all releases

Code changes from version 1.6.9 to 1.7.6

LICENSE.txt CHANGED
@@ -1,339 +1,339 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
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
- <one line to give the program's name and a brief idea of what it does.>
294
- Copyright (C) <year> <name of author>
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.
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 2, June 1991
3
+
4
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
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
+ <one line to give the program's name and a brief idea of what it does.>
294
+ Copyright (C) <year> <name of author>
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.
aq_resizer.php CHANGED
@@ -1,250 +1,250 @@
1
- <?php
2
-
3
- /**
4
- * Title : Aqua Resizer
5
- * Description : Resizes WordPress images on the fly
6
- * Version : 1.2.1
7
- * Author : Syamil MJ
8
- * Author URI : http://aquagraphite.com
9
- * License : WTFPL - http://sam.zoy.org/wtfpl/
10
- * Documentation : https://github.com/sy4mil/Aqua-Resizer/
11
- *
12
- * @param string $url - (required) must be uploaded using wp media uploader
13
- * @param int $width - (required)
14
- * @param int $height - (optional)
15
- * @param bool $crop - (optional) default to soft crop
16
- * @param bool $single - (optional) returns an array if false
17
- * @param bool $upscale - (optional) resizes smaller images
18
- * @uses wp_upload_dir()
19
- * @uses image_resize_dimensions()
20
- * @uses wp_get_image_editor()
21
- *
22
- * @return str|array
23
- */
24
-
25
- if(!class_exists('Aq_Resize')) {
26
- class Aq_Exception extends Exception {}
27
-
28
- class Aq_Resize
29
- {
30
- /**
31
- * The singleton instance
32
- */
33
- static private $instance = null;
34
-
35
- /**
36
- * Should an Aq_Exception be thrown on error?
37
- * If false (default), then the error will just be logged.
38
- */
39
- public $throwOnError = false;
40
-
41
- /**
42
- * No initialization allowed
43
- */
44
- private function __construct() {}
45
-
46
- /**
47
- * No cloning allowed
48
- */
49
- private function __clone() {}
50
-
51
- /**
52
- * For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
53
- */
54
- static public function getInstance() {
55
- if(self::$instance == null) {
56
- self::$instance = new self;
57
- }
58
-
59
- return self::$instance;
60
- }
61
-
62
- /**
63
- * Run, forest.
64
- */
65
- public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
66
- try {
67
- // Validate inputs.
68
- if (!$url)
69
- throw new Aq_Exception('$url parameter is required');
70
- if (!$width)
71
- throw new Aq_Exception('$width parameter is required');
72
- if (!$height)
73
- throw new Aq_Exception('$height parameter is required');
74
-
75
- // Caipt'n, ready to hook.
76
- if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
77
-
78
- // Define upload path & dir.
79
- $upload_info = wp_upload_dir();
80
- $upload_dir = $upload_info['basedir'];
81
- $upload_url = $upload_info['baseurl'];
82
-
83
- $http_prefix = "http://";
84
- $https_prefix = "https://";
85
- $relative_prefix = "//"; // The protocol-relative URL
86
-
87
- /* if the $url scheme differs from $upload_url scheme, make them match
88
- if the schemes differe, images don't show up. */
89
- if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
90
- $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
91
- }
92
- elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
93
- $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
94
- }
95
- elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
96
- $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
97
- }
98
-
99
-
100
- // Check if $img_url is local.
101
- if ( false === strpos( $url, $upload_url ) )
102
- throw new Aq_Exception('Image must be local: ' . $url);
103
-
104
- // Define path of image.
105
- $rel_path = str_replace( $upload_url, '', $url );
106
- $img_path = $upload_dir . $rel_path;
107
-
108
- // Check if img path exists, and is an image indeed.
109
- if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
110
- throw new Aq_Exception('Image file does not exist (or is not an image): ' . $img_path);
111
-
112
- // Get image info.
113
- $info = pathinfo( $img_path );
114
- $ext = $info['extension'];
115
- list( $orig_w, $orig_h ) = getimagesize( $img_path );
116
-
117
- // Get image size after cropping.
118
- $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
119
- $dst_w = $dims[4];
120
- $dst_h = $dims[5];
121
-
122
- // Return the original image only if it exactly fits the needed measures.
123
- if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
124
- $img_url = $url;
125
- $dst_w = $orig_w;
126
- $dst_h = $orig_h;
127
- } else {
128
- // Use this to check if cropped image already exists, so we can return that instead.
129
- $suffix = "{$dst_w}x{$dst_h}";
130
- $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
131
- $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
132
-
133
- if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
134
- // Can't resize, so return false saying that the action to do could not be processed as planned.
135
- throw new Aq_Exception('Unable to resize image because image_resize_dimensions() failed');
136
- }
137
- // Else check if cache exists.
138
- elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
139
- $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
140
- }
141
- // Else, we resize the image and return the new resized image url.
142
- else {
143
-
144
- $editor = wp_get_image_editor( $img_path );
145
-
146
- if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
147
- throw new Aq_Exception('Unable to get WP_Image_Editor: ' .
148
- $editor->get_error_message() . ' (is GD or ImageMagick installed?)');
149
- }
150
-
151
- $resized_file = $editor->save();
152
-
153
- if ( ! is_wp_error( $resized_file ) ) {
154
- $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
155
- $img_url = $upload_url . $resized_rel_path;
156
- } else {
157
- throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message());
158
- }
159
-
160
- }
161
- }
162
-
163
- // Okay, leave the ship.
164
- if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
165
-
166
- // Return the output.
167
- if ( $single ) {
168
- // str return.
169
- $image = $img_url;
170
- } else {
171
- // array return.
172
- $image = array (
173
- 0 => $img_url,
174
- 1 => $dst_w,
175
- 2 => $dst_h
176
- );
177
- }
178
-
179
- return $image;
180
- }
181
- catch (Aq_Exception $ex) {
182
- error_log('Aq_Resize.process() error: ' . $ex->getMessage());
183
-
184
- if ($this->throwOnError) {
185
- // Bubble up exception.
186
- throw $ex;
187
- }
188
- else {
189
- // Return false, so that this patch is backwards-compatible.
190
- return false;
191
- }
192
- }
193
- }
194
-
195
- /**
196
- * Callback to overwrite WP computing of thumbnail measures
197
- */
198
- function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
199
- if ( ! $crop ) return null; // Let the wordpress default function handle this.
200
-
201
- // Here is the point we allow to use larger image size than the original one.
202
- $aspect_ratio = $orig_w / $orig_h;
203
- $new_w = $dest_w;
204
- $new_h = $dest_h;
205
-
206
- if ( ! $new_w ) {
207
- $new_w = intval( $new_h * $aspect_ratio );
208
- }
209
-
210
- if ( ! $new_h ) {
211
- $new_h = intval( $new_w / $aspect_ratio );
212
- }
213
-
214
- $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
215
-
216
- $crop_w = round( $new_w / $size_ratio );
217
- $crop_h = round( $new_h / $size_ratio );
218
-
219
- $s_x = floor( ( $orig_w - $crop_w ) / 2 );
220
- $s_y = floor( ( $orig_h - $crop_h ) / 2 );
221
-
222
- return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
223
- }
224
- }
225
- }
226
-
227
-
228
-
229
-
230
-
231
- if(!function_exists('aq_resize')) {
232
-
233
- /**
234
- * This is just a tiny wrapper function for the class above so that there is no
235
- * need to change any code in your own WP themes. Usage is still the same :)
236
- */
237
- function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
238
- /* WPML Fix */
239
- if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
240
- global $sitepress;
241
- $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
242
- }
243
- /* WPML Fix */
244
-
245
- $aq_resize = Aq_Resize::getInstance();
246
- return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
247
- }
248
- }
249
-
250
-
1
+ <?php
2
+
3
+ /**
4
+ * Title : Aqua Resizer
5
+ * Description : Resizes WordPress images on the fly
6
+ * Version : 1.2.1
7
+ * Author : Syamil MJ
8
+ * Author URI : http://aquagraphite.com
9
+ * License : WTFPL - http://sam.zoy.org/wtfpl/
10
+ * Documentation : https://github.com/sy4mil/Aqua-Resizer/
11
+ *
12
+ * @param string $url - (required) must be uploaded using wp media uploader
13
+ * @param int $width - (required)
14
+ * @param int $height - (optional)
15
+ * @param bool $crop - (optional) default to soft crop
16
+ * @param bool $single - (optional) returns an array if false
17
+ * @param bool $upscale - (optional) resizes smaller images
18
+ * @uses wp_upload_dir()
19
+ * @uses image_resize_dimensions()
20
+ * @uses wp_get_image_editor()
21
+ *
22
+ * @return str|array
23
+ */
24
+
25
+ if(!class_exists('Aq_Resize')) {
26
+ class Aq_Exception extends Exception {}
27
+
28
+ class Aq_Resize
29
+ {
30
+ /**
31
+ * The singleton instance
32
+ */
33
+ static private $instance = null;
34
+
35
+ /**
36
+ * Should an Aq_Exception be thrown on error?
37
+ * If false (default), then the error will just be logged.
38
+ */
39
+ public $throwOnError = false;
40
+
41
+ /**
42
+ * No initialization allowed
43
+ */
44
+ private function __construct() {}
45
+
46
+ /**
47
+ * No cloning allowed
48
+ */
49
+ private function __clone() {}
50
+
51
+ /**
52
+ * For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
53
+ */
54
+ static public function getInstance() {
55
+ if(self::$instance == null) {
56
+ self::$instance = new self;
57
+ }
58
+
59
+ return self::$instance;
60
+ }
61
+
62
+ /**
63
+ * Run, forest.
64
+ */
65
+ public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
66
+ try {
67
+ // Validate inputs.
68
+ if (!$url)
69
+ throw new Aq_Exception('$url parameter is required');
70
+ if (!$width)
71
+ throw new Aq_Exception('$width parameter is required');
72
+ if (!$height)
73
+ throw new Aq_Exception('$height parameter is required');
74
+
75
+ // Caipt'n, ready to hook.
76
+ if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
77
+
78
+ // Define upload path & dir.
79
+ $upload_info = wp_upload_dir();
80
+ $upload_dir = $upload_info['basedir'];
81
+ $upload_url = $upload_info['baseurl'];
82
+
83
+ $http_prefix = "http://";
84
+ $https_prefix = "https://";
85
+ $relative_prefix = "//"; // The protocol-relative URL
86
+
87
+ /* if the $url scheme differs from $upload_url scheme, make them match
88
+ if the schemes differe, images don't show up. */
89
+ if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
90
+ $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
91
+ }
92
+ elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
93
+ $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
94
+ }
95
+ elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
96
+ $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
97
+ }
98
+
99
+
100
+ // Check if $img_url is local.
101
+ if ( false === strpos( $url, $upload_url ) )
102
+ throw new Aq_Exception('Image must be local: ' . $url);
103
+
104
+ // Define path of image.
105
+ $rel_path = str_replace( $upload_url, '', $url );
106
+ $img_path = $upload_dir . $rel_path;
107
+
108
+ // Check if img path exists, and is an image indeed.
109
+ if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
110
+ throw new Aq_Exception('Image file does not exist (or is not an image): ' . $img_path);
111
+
112
+ // Get image info.
113
+ $info = pathinfo( $img_path );
114
+ $ext = $info['extension'];
115
+ list( $orig_w, $orig_h ) = getimagesize( $img_path );
116
+
117
+ // Get image size after cropping.
118
+ $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
119
+ $dst_w = $dims[4];
120
+ $dst_h = $dims[5];
121
+
122
+ // Return the original image only if it exactly fits the needed measures.
123
+ if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
124
+ $img_url = $url;
125
+ $dst_w = $orig_w;
126
+ $dst_h = $orig_h;
127
+ } else {
128
+ // Use this to check if cropped image already exists, so we can return that instead.
129
+ $suffix = "{$dst_w}x{$dst_h}";
130
+ $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
131
+ $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
132
+
133
+ if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
134
+ // Can't resize, so return false saying that the action to do could not be processed as planned.
135
+ throw new Aq_Exception('Unable to resize image because image_resize_dimensions() failed');
136
+ }
137
+ // Else check if cache exists.
138
+ elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
139
+ $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
140
+ }
141
+ // Else, we resize the image and return the new resized image url.
142
+ else {
143
+
144
+ $editor = wp_get_image_editor( $img_path );
145
+
146
+ if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
147
+ throw new Aq_Exception('Unable to get WP_Image_Editor: ' .
148
+ $editor->get_error_message() . ' (is GD or ImageMagick installed?)');
149
+ }
150
+
151
+ $resized_file = $editor->save();
152
+
153
+ if ( ! is_wp_error( $resized_file ) ) {
154
+ $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
155
+ $img_url = $upload_url . $resized_rel_path;
156
+ } else {
157
+ throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message());
158
+ }
159
+
160
+ }
161
+ }
162
+
163
+ // Okay, leave the ship.
164
+ if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
165
+
166
+ // Return the output.
167
+ if ( $single ) {
168
+ // str return.
169
+ $image = $img_url;
170
+ } else {
171
+ // array return.
172
+ $image = array (
173
+ 0 => $img_url,
174
+ 1 => $dst_w,
175
+ 2 => $dst_h
176
+ );
177
+ }
178
+
179
+ return $image;
180
+ }
181
+ catch (Aq_Exception $ex) {
182
+ error_log('Aq_Resize.process() error: ' . $ex->getMessage());
183
+
184
+ if ($this->throwOnError) {
185
+ // Bubble up exception.
186
+ throw $ex;
187
+ }
188
+ else {
189
+ // Return false, so that this patch is backwards-compatible.
190
+ return false;
191
+ }
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Callback to overwrite WP computing of thumbnail measures
197
+ */
198
+ function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
199
+ if ( ! $crop ) return null; // Let the wordpress default function handle this.
200
+
201
+ // Here is the point we allow to use larger image size than the original one.
202
+ $aspect_ratio = $orig_w / $orig_h;
203
+ $new_w = $dest_w;
204
+ $new_h = $dest_h;
205
+
206
+ if ( ! $new_w ) {
207
+ $new_w = intval( $new_h * $aspect_ratio );
208
+ }
209
+
210
+ if ( ! $new_h ) {
211
+ $new_h = intval( $new_w / $aspect_ratio );
212
+ }
213
+
214
+ $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
215
+
216
+ $crop_w = round( $new_w / $size_ratio );
217
+ $crop_h = round( $new_h / $size_ratio );
218
+
219
+ $s_x = floor( ( $orig_w - $crop_w ) / 2 );
220
+ $s_y = floor( ( $orig_h - $crop_h ) / 2 );
221
+
222
+ return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
223
+ }
224
+ }
225
+ }
226
+
227
+
228
+
229
+
230
+
231
+ if(!function_exists('aq_resize')) {
232
+
233
+ /**
234
+ * This is just a tiny wrapper function for the class above so that there is no
235
+ * need to change any code in your own WP themes. Usage is still the same :)
236
+ */
237
+ function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
238
+ /* WPML Fix */
239
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
240
+ global $sitepress;
241
+ $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
242
+ }
243
+ /* WPML Fix */
244
+
245
+ $aq_resize = Aq_Resize::getInstance();
246
+ return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
247
+ }
248
+ }
249
+
250
+
assets/css/acf-photo-gallery-field.css CHANGED
@@ -1,98 +1,98 @@
1
- .acf-photo-gallery-metabox-list li {
2
- display: inline-table;
3
- padding: 3px;
4
- border: 1px solid #ccc;
5
- margin: 8px;
6
- position: relative;
7
- vertical-align: top;
8
- width: 202px;
9
- height: 202px;
10
- }
11
-
12
- .acf-photo-gallery-metabox-list li img {
13
- width: 100%;
14
- }
15
-
16
- .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
17
- width: 150px;
18
- height: 150px;
19
- border: 1px dashed #ccc;
20
- }
21
-
22
- .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
23
- font-size: 150px;
24
- color: #ccc;
25
- }
26
-
27
- .acf-photo-gallery-metabox-list li .dashicons-dismiss {
28
- position: absolute;
29
- top: -9px;
30
- right: -9px;
31
- color: #fff;
32
- background: #000000;
33
- border-radius: 50%;
34
- }
35
-
36
- .acf-photo-gallery-metabox-list li .dashicons-edit {
37
- position: absolute;
38
- top: -9px;
39
- right: 12px;
40
- color: #fff;
41
- background: #000000;
42
- border-radius: 50%;
43
- }
44
-
45
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
46
- display: none;
47
- background: #F3F3F3;
48
- border: 2px solid #ccc;
49
- width: 380px;
50
- position: fixed;
51
- top: 10%;
52
- right: 0;
53
- z-index: 9999;
54
- padding: 15px;
55
- left: 43%;
56
- }
57
-
58
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery h3{
59
- background: #f1f1f1;
60
- padding: 12px 15px;
61
- margin-top: -17px;
62
- margin-left: -17px;
63
- width: 101%;
64
- border-bottom: 1px solid #ccc;
65
- }
66
-
67
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
68
- margin-top: 15px;
69
- }
70
-
71
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
72
- margin-top: 10px;
73
- display: block;
74
- }
75
-
76
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
77
- min-height: 100px
78
- }
79
-
80
- .acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
81
- border: 1px dashed #ccc;
82
- width: 150px;
83
- height: 150px;
84
- display: inline-block;
85
- }
86
-
87
- .acf-gallery-backdrop{
88
- background: #000000;
89
- opacity: 0.5;
90
- position: fixed;
91
- z-index: 9999;
92
- width: 100%;
93
- height: 100%;
94
- top: 0%;
95
- bottom: 0%;
96
- left: 0%;
97
- right: 0%;
98
  }
1
+ .acf-photo-gallery-metabox-list li {
2
+ display: inline-table;
3
+ padding: 3px;
4
+ border: 1px solid #ccc;
5
+ margin: 8px;
6
+ position: relative;
7
+ vertical-align: top;
8
+ width: 202px;
9
+ height: 202px;
10
+ }
11
+
12
+ .acf-photo-gallery-metabox-list li img {
13
+ width: 100%;
14
+ }
15
+
16
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
17
+ width: 150px;
18
+ height: 150px;
19
+ border: 1px dashed #ccc;
20
+ }
21
+
22
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
23
+ font-size: 150px;
24
+ color: #ccc;
25
+ }
26
+
27
+ .acf-photo-gallery-metabox-list li .dashicons-dismiss {
28
+ position: absolute;
29
+ top: -9px;
30
+ right: -9px;
31
+ color: #fff;
32
+ background: #000000;
33
+ border-radius: 50%;
34
+ }
35
+
36
+ .acf-photo-gallery-metabox-list li .dashicons-edit {
37
+ position: absolute;
38
+ top: -9px;
39
+ right: 12px;
40
+ color: #fff;
41
+ background: #000000;
42
+ border-radius: 50%;
43
+ }
44
+
45
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
46
+ display: none;
47
+ background: #F3F3F3;
48
+ border: 2px solid #ccc;
49
+ width: 380px;
50
+ position: fixed;
51
+ top: 10%;
52
+ right: 0;
53
+ z-index: 9999;
54
+ padding: 15px;
55
+ left: 43%;
56
+ }
57
+
58
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery h3{
59
+ background: #f1f1f1;
60
+ padding: 12px 15px;
61
+ margin-top: -17px;
62
+ margin-left: -17px;
63
+ width: 101%;
64
+ border-bottom: 1px solid #ccc;
65
+ }
66
+
67
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
68
+ margin-top: 15px;
69
+ }
70
+
71
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
72
+ margin-top: 10px;
73
+ display: block;
74
+ }
75
+
76
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
77
+ min-height: 100px
78
+ }
79
+
80
+ .acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
81
+ border: 1px dashed #ccc;
82
+ width: 150px;
83
+ height: 150px;
84
+ display: inline-block;
85
+ }
86
+
87
+ .acf-gallery-backdrop{
88
+ background: #000000;
89
+ opacity: 0.5;
90
+ position: fixed;
91
+ z-index: 9999;
92
+ width: 100%;
93
+ height: 100%;
94
+ top: 0%;
95
+ bottom: 0%;
96
+ left: 0%;
97
+ right: 0%;
98
  }
assets/css/acf-photo-galley-bootstrap.css CHANGED
@@ -1,122 +1,122 @@
1
- .modal-open {
2
- overflow: hidden;
3
- }
4
- .modal {
5
- position: fixed;
6
- top: 0;
7
- right: 0;
8
- bottom: 0;
9
- left: 0;
10
- z-index: 1050;
11
- display: none;
12
- overflow: hidden;
13
- -webkit-overflow-scrolling: touch;
14
- outline: 0;
15
- }
16
- .modal.fade .modal-dialog {
17
- -webkit-transform: translate(0, -25%);
18
- -ms-transform: translate(0, -25%);
19
- -o-transform: translate(0, -25%);
20
- transform: translate(0, -25%);
21
- -webkit-transition: -webkit-transform 0.3s ease-out;
22
- -o-transition: -o-transform 0.3s ease-out;
23
- transition: transform 0.3s ease-out;
24
- }
25
- .modal.in .modal-dialog {
26
- -webkit-transform: translate(0, 0);
27
- -ms-transform: translate(0, 0);
28
- -o-transform: translate(0, 0);
29
- transform: translate(0, 0);
30
- }
31
- .modal-open .modal {
32
- overflow-x: hidden;
33
- overflow-y: auto;
34
- }
35
- .modal-dialog {
36
- position: relative;
37
- width: auto;
38
- margin: 10px;
39
- }
40
- .modal-content {
41
- position: relative;
42
- background-color: #ffffff;
43
- -webkit-background-clip: padding-box;
44
- background-clip: padding-box;
45
- border: 1px solid #999999;
46
- border: 1px solid rgba(0, 0, 0, 0.2);
47
- -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
48
- box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
49
- outline: 0;
50
- }
51
- .modal-backdrop {
52
- position: fixed;
53
- top: 0;
54
- right: 0;
55
- bottom: 0;
56
- left: 0;
57
- z-index: 1040;
58
- background-color: #000000;
59
- }
60
- .modal-backdrop.fade {
61
- filter: alpha(opacity=0);
62
- opacity: 0;
63
- }
64
- .modal-backdrop.in {
65
- filter: alpha(opacity=50);
66
- opacity: 0.5;
67
- }
68
- .modal-header {
69
- padding: 15px;
70
- border-bottom: 1px solid #e5e5e5;
71
- }
72
- .modal-header .close {
73
- margin-top: -2px;
74
- }
75
- .modal-title {
76
- margin: 0;
77
- line-height: 1.42857143;
78
- }
79
- .modal-body {
80
- position: relative;
81
- padding: 15px;
82
- }
83
- .modal-footer {
84
- padding: 15px;
85
- text-align: right;
86
- border-top: 1px solid #e5e5e5;
87
- }
88
- .modal-footer .btn + .btn {
89
- margin-bottom: 0;
90
- margin-left: 5px;
91
- }
92
- .modal-footer .btn-group .btn + .btn {
93
- margin-left: -1px;
94
- }
95
- .modal-footer .btn-block + .btn-block {
96
- margin-left: 0;
97
- }
98
- .modal-scrollbar-measure {
99
- position: absolute;
100
- top: -9999px;
101
- width: 50px;
102
- height: 50px;
103
- overflow: scroll;
104
- }
105
- @media (min-width: 768px) {
106
- .modal-dialog {
107
- width: 600px;
108
- margin: 30px auto;
109
- }
110
- .modal-content {
111
- -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
112
- box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
113
- }
114
- .modal-sm {
115
- width: 300px;
116
- }
117
- }
118
- @media (min-width: 992px) {
119
- .modal-lg {
120
- width: 900px;
121
- }
122
  }
1
+ .modal-open {
2
+ overflow: hidden;
3
+ }
4
+ .modal {
5
+ position: fixed;
6
+ top: 0;
7
+ right: 0;
8
+ bottom: 0;
9
+ left: 0;
10
+ z-index: 1050;
11
+ display: none;
12
+ overflow: hidden;
13
+ -webkit-overflow-scrolling: touch;
14
+ outline: 0;
15
+ }
16
+ .modal.fade .modal-dialog {
17
+ -webkit-transform: translate(0, -25%);
18
+ -ms-transform: translate(0, -25%);
19
+ -o-transform: translate(0, -25%);
20
+ transform: translate(0, -25%);
21
+ -webkit-transition: -webkit-transform 0.3s ease-out;
22
+ -o-transition: -o-transform 0.3s ease-out;
23
+ transition: transform 0.3s ease-out;
24
+ }
25
+ .modal.in .modal-dialog {
26
+ -webkit-transform: translate(0, 0);
27
+ -ms-transform: translate(0, 0);
28
+ -o-transform: translate(0, 0);
29
+ transform: translate(0, 0);
30
+ }
31
+ .modal-open .modal {
32
+ overflow-x: hidden;
33
+ overflow-y: auto;
34
+ }
35
+ .modal-dialog {
36
+ position: relative;
37
+ width: auto;
38
+ margin: 10px;
39
+ }
40
+ .modal-content {
41
+ position: relative;
42
+ background-color: #ffffff;
43
+ -webkit-background-clip: padding-box;
44
+ background-clip: padding-box;
45
+ border: 1px solid #999999;
46
+ border: 1px solid rgba(0, 0, 0, 0.2);
47
+ -webkit-box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
48
+ box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
49
+ outline: 0;
50
+ }
51
+ .modal-backdrop {
52
+ position: fixed;
53
+ top: 0;
54
+ right: 0;
55
+ bottom: 0;
56
+ left: 0;
57
+ z-index: 1040;
58
+ background-color: #000000;
59
+ }
60
+ .modal-backdrop.fade {
61
+ filter: alpha(opacity=0);
62
+ opacity: 0;
63
+ }
64
+ .modal-backdrop.in {
65
+ filter: alpha(opacity=50);
66
+ opacity: 0.5;
67
+ }
68
+ .modal-header {
69
+ padding: 15px;
70
+ border-bottom: 1px solid #e5e5e5;
71
+ }
72
+ .modal-header .close {
73
+ margin-top: -2px;
74
+ }
75
+ .modal-title {
76
+ margin: 0;
77
+ line-height: 1.42857143;
78
+ }
79
+ .modal-body {
80
+ position: relative;
81
+ padding: 15px;
82
+ }
83
+ .modal-footer {
84
+ padding: 15px;
85
+ text-align: right;
86
+ border-top: 1px solid #e5e5e5;
87
+ }
88
+ .modal-footer .btn + .btn {
89
+ margin-bottom: 0;
90
+ margin-left: 5px;
91
+ }
92
+ .modal-footer .btn-group .btn + .btn {
93
+ margin-left: -1px;
94
+ }
95
+ .modal-footer .btn-block + .btn-block {
96
+ margin-left: 0;
97
+ }
98
+ .modal-scrollbar-measure {
99
+ position: absolute;
100
+ top: -9999px;
101
+ width: 50px;
102
+ height: 50px;
103
+ overflow: scroll;
104
+ }
105
+ @media (min-width: 768px) {
106
+ .modal-dialog {
107
+ width: 600px;
108
+ margin: 30px auto;
109
+ }
110
+ .modal-content {
111
+ -webkit-box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
112
+ box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
113
+ }
114
+ .modal-sm {
115
+ width: 300px;
116
+ }
117
+ }
118
+ @media (min-width: 992px) {
119
+ .modal-lg {
120
+ width: 900px;
121
+ }
122
  }
assets/css/input.css CHANGED
@@ -1,75 +1,75 @@
1
- .acf-photo-gallery-metabox-list li {
2
- display: inline-table;
3
- padding: 3px;
4
- border: 1px solid #ccc;
5
- margin: 8px;
6
- position: relative;
7
- vertical-align: top;
8
- width: 202px;
9
- height: 202px;
10
- }
11
-
12
- .acf-photo-gallery-metabox-list li img {
13
- width: 100%;
14
- }
15
-
16
- .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
17
- width: 150px;
18
- height: 150px;
19
- border: 1px dashed #ccc;
20
- }
21
-
22
- .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
23
- font-size: 150px;
24
- color: #ccc;
25
- }
26
-
27
- .acf-photo-gallery-metabox-list li .dashicons-dismiss {
28
- position: absolute;
29
- top: -9px;
30
- right: -9px;
31
- color: #fff;
32
- background: #000000;
33
- border-radius: 50%;
34
- }
35
-
36
- .acf-photo-gallery-metabox-list li .dashicons-edit {
37
- position: absolute;
38
- top: -9px;
39
- right: 12px;
40
- color: #fff;
41
- background: #000000;
42
- border-radius: 50%;
43
- }
44
-
45
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
46
- display: none;
47
- background: #F3F3F3;
48
- border: 2px solid #ccc;
49
- width: 308px;
50
- position: absolute;
51
- top: 0px;
52
- right: 0;
53
- z-index: 9999;
54
- padding: 15px;
55
- }
56
-
57
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
58
- margin-top: 15px;
59
- }
60
-
61
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
62
- margin-top: 10px;
63
- display: block;
64
- }
65
-
66
- #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
67
- min-height: 100px
68
- }
69
-
70
- .acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
71
- border: 1px dashed #ccc;
72
- width: 150px;
73
- height: 150px;
74
- display: inline-block;
75
  }
1
+ .acf-photo-gallery-metabox-list li {
2
+ display: inline-table;
3
+ padding: 3px;
4
+ border: 1px solid #ccc;
5
+ margin: 8px;
6
+ position: relative;
7
+ vertical-align: top;
8
+ width: 202px;
9
+ height: 202px;
10
+ }
11
+
12
+ .acf-photo-gallery-metabox-list li img {
13
+ width: 100%;
14
+ }
15
+
16
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder {
17
+ width: 150px;
18
+ height: 150px;
19
+ border: 1px dashed #ccc;
20
+ }
21
+
22
+ .acf-photo-gallery-metabox-list .acf-photo-gallery-media-box-placeholder .dashicons-format-image {
23
+ font-size: 150px;
24
+ color: #ccc;
25
+ }
26
+
27
+ .acf-photo-gallery-metabox-list li .dashicons-dismiss {
28
+ position: absolute;
29
+ top: -9px;
30
+ right: -9px;
31
+ color: #fff;
32
+ background: #000000;
33
+ border-radius: 50%;
34
+ }
35
+
36
+ .acf-photo-gallery-metabox-list li .dashicons-edit {
37
+ position: absolute;
38
+ top: -9px;
39
+ right: 12px;
40
+ color: #fff;
41
+ background: #000000;
42
+ border-radius: 50%;
43
+ }
44
+
45
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery {
46
+ display: none;
47
+ background: #F3F3F3;
48
+ border: 2px solid #ccc;
49
+ width: 308px;
50
+ position: absolute;
51
+ top: 0px;
52
+ right: 0;
53
+ z-index: 9999;
54
+ padding: 15px;
55
+ }
56
+
57
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery .save-changes-wrap {
58
+ margin-top: 15px;
59
+ }
60
+
61
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery label {
62
+ margin-top: 10px;
63
+ display: block;
64
+ }
65
+
66
+ #acf-photo-gallery-metabox-edit .acf-edit-photo-gallery textarea {
67
+ min-height: 100px
68
+ }
69
+
70
+ .acf-photo-gallery-metabox-list li.acf-photo-gallery-sortable-placeholder {
71
+ border: 1px dashed #ccc;
72
+ width: 150px;
73
+ height: 150px;
74
+ display: inline-block;
75
  }
assets/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
assets/js/acf-photo-gallery-bootstrap.js DELETED
@@ -1,11 +0,0 @@
1
- /*!
2
- * Generated using the Bootstrap Customizer (https://getbootstrap.com/docs/3.4/customize/)
3
- */
4
-
5
- /*!
6
- * Bootstrap v3.4.1 (https://getbootstrap.com/)
7
- * Copyright 2011-2019 Twitter, Inc.
8
- * Licensed under the MIT license
9
- */
10
-
11
- if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(t){"use strict";var e=t.fn.jquery.split(" ")[0].split(".");if(e[0]<2&&e[1]<9||1==e[0]&&9==e[1]&&e[2]<1||e[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(t){"use strict";function e(e,o){return this.each(function(){var s=t(this),n=s.data("bs.modal"),a=t.extend({},i.DEFAULTS,s.data(),"object"==typeof e&&e);n||s.data("bs.modal",n=new i(this,a)),"string"==typeof e?n[e](o):a.show&&n.show(o)})}var i=function(e,i){this.options=i,this.$body=t(document.body),this.$element=t(e),this.$dialog=this.$element.find(".modal-dialog"),this.$backdrop=null,this.isShown=null,this.originalBodyPad=null,this.scrollbarWidth=0,this.ignoreBackdropClick=!1,this.fixedContent=".navbar-fixed-top, .navbar-fixed-bottom",this.options.remote&&this.$element.find(".modal-content").load(this.options.remote,t.proxy(function(){this.$element.trigger("loaded.bs.modal")},this))};i.VERSION="3.4.1",i.TRANSITION_DURATION=300,i.BACKDROP_TRANSITION_DURATION=150,i.DEFAULTS={backdrop:!0,keyboard:!0,show:!0},i.prototype.toggle=function(t){return this.isShown?this.hide():this.show(t)},i.prototype.show=function(e){var o=this,s=t.Event("show.bs.modal",{relatedTarget:e});this.$element.trigger(s),this.isShown||s.isDefaultPrevented()||(this.isShown=!0,this.checkScrollbar(),this.setScrollbar(),this.$body.addClass("modal-open"),this.escape(),this.resize(),this.$element.on("click.dismiss.bs.modal",'[data-dismiss="modal"]',t.proxy(this.hide,this)),this.$dialog.on("mousedown.dismiss.bs.modal",function(){o.$element.one("mouseup.dismiss.bs.modal",function(e){t(e.target).is(o.$element)&&(o.ignoreBackdropClick=!0)})}),this.backdrop(function(){var s=t.support.transition&&o.$element.hasClass("fade");o.$element.parent().length||o.$element.appendTo(o.$body),o.$element.show().scrollTop(0),o.adjustDialog(),s&&o.$element[0].offsetWidth,o.$element.addClass("in"),o.enforceFocus();var n=t.Event("shown.bs.modal",{relatedTarget:e});s?o.$dialog.one("bsTransitionEnd",function(){o.$element.trigger("focus").trigger(n)}).emulateTransitionEnd(i.TRANSITION_DURATION):o.$element.trigger("focus").trigger(n)}))},i.prototype.hide=function(e){e&&e.preventDefault(),e=t.Event("hide.bs.modal"),this.$element.trigger(e),this.isShown&&!e.isDefaultPrevented()&&(this.isShown=!1,this.escape(),this.resize(),t(document).off("focusin.bs.modal"),this.$element.removeClass("in").off("click.dismiss.bs.modal").off("mouseup.dismiss.bs.modal"),this.$dialog.off("mousedown.dismiss.bs.modal"),t.support.transition&&this.$element.hasClass("fade")?this.$element.one("bsTransitionEnd",t.proxy(this.hideModal,this)).emulateTransitionEnd(i.TRANSITION_DURATION):this.hideModal())},i.prototype.enforceFocus=function(){t(document).off("focusin.bs.modal").on("focusin.bs.modal",t.proxy(function(t){document===t.target||this.$element[0]===t.target||this.$element.has(t.target).length||this.$element.trigger("focus")},this))},i.prototype.escape=function(){this.isShown&&this.options.keyboard?this.$element.on("keydown.dismiss.bs.modal",t.proxy(function(t){27==t.which&&this.hide()},this)):this.isShown||this.$element.off("keydown.dismiss.bs.modal")},i.prototype.resize=function(){this.isShown?t(window).on("resize.bs.modal",t.proxy(this.handleUpdate,this)):t(window).off("resize.bs.modal")},i.prototype.hideModal=function(){var t=this;this.$element.hide(),this.backdrop(function(){t.$body.removeClass("modal-open"),t.resetAdjustments(),t.resetScrollbar(),t.$element.trigger("hidden.bs.modal")})},i.prototype.removeBackdrop=function(){this.$backdrop&&this.$backdrop.remove(),this.$backdrop=null},i.prototype.backdrop=function(e){var o=this,s=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var n=t.support.transition&&s;if(this.$backdrop=t(document.createElement("div")).addClass("modal-backdrop "+s).appendTo(this.$body),this.$element.on("click.dismiss.bs.modal",t.proxy(function(t){return this.ignoreBackdropClick?void(this.ignoreBackdropClick=!1):void(t.target===t.currentTarget&&("static"==this.options.backdrop?this.$element[0].focus():this.hide()))},this)),n&&this.$backdrop[0].offsetWidth,this.$backdrop.addClass("in"),!e)return;n?this.$backdrop.one("bsTransitionEnd",e).emulateTransitionEnd(i.BACKDROP_TRANSITION_DURATION):e()}else if(!this.isShown&&this.$backdrop){this.$backdrop.removeClass("in");var a=function(){o.removeBackdrop(),e&&e()};t.support.transition&&this.$element.hasClass("fade")?this.$backdrop.one("bsTransitionEnd",a).emulateTransitionEnd(i.BACKDROP_TRANSITION_DURATION):a()}else e&&e()},i.prototype.handleUpdate=function(){this.adjustDialog()},i.prototype.adjustDialog=function(){var t=this.$element[0].scrollHeight>document.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&t?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!t?this.scrollbarWidth:""})},i.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},i.prototype.checkScrollbar=function(){var t=window.innerWidth;if(!t){var e=document.documentElement.getBoundingClientRect();t=e.right-Math.abs(e.left)}this.bodyIsOverflowing=document.body.clientWidth<t,this.scrollbarWidth=this.measureScrollbar()},i.prototype.setScrollbar=function(){var e=parseInt(this.$body.css("padding-right")||0,10);this.originalBodyPad=document.body.style.paddingRight||"";var i=this.scrollbarWidth;this.bodyIsOverflowing&&(this.$body.css("padding-right",e+i),t(this.fixedContent).each(function(e,o){var s=o.style.paddingRight,n=t(o).css("padding-right");t(o).data("padding-right",s).css("padding-right",parseFloat(n)+i+"px")}))},i.prototype.resetScrollbar=function(){this.$body.css("padding-right",this.originalBodyPad),t(this.fixedContent).each(function(e,i){var o=t(i).data("padding-right");t(i).removeData("padding-right"),i.style.paddingRight=o?o:""})},i.prototype.measureScrollbar=function(){var t=document.createElement("div");t.className="modal-scrollbar-measure",this.$body.append(t);var e=t.offsetWidth-t.clientWidth;return this.$body[0].removeChild(t),e};var o=t.fn.modal;t.fn.modal=e,t.fn.modal.Constructor=i,t.fn.modal.noConflict=function(){return t.fn.modal=o,this},t(document).on("click.bs.modal.data-api",'[data-toggle="modal"]',function(i){var o=t(this),s=o.attr("href"),n=o.attr("data-target")||s&&s.replace(/.*(?=#[^\s]+$)/,""),a=t(document).find(n),r=a.data("bs.modal")?"toggle":t.extend({remote:!/#/.test(s)&&s},a.data(),o.data());o.is("a")&&i.preventDefault(),a.one("show.bs.modal",function(t){t.isDefaultPrevented()||a.one("hidden.bs.modal",function(){o.is(":visible")&&o.trigger("focus")})}),e.call(a,r,this)})}(jQuery);
 
 
 
 
 
 
 
 
 
 
 
assets/js/acf-photo-gallery-field.js CHANGED
@@ -4,9 +4,9 @@
4
  //$el.doStuff();
5
  }
6
 
7
- function acf_photo_gallery_remove_media( id, field ){
8
  $('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
9
- if( $('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list li').length < 1 ){
10
  $('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
11
  }
12
  }
@@ -71,32 +71,32 @@
71
  var id = button.prev();
72
  var field = button.attr('data-field');
73
  var JsonField = jQuery.parseJSON(field);
74
-
75
  //On click of the add images button, check if the image limit has been reached
76
  var pre_selected_list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-mediabox');
77
  var images_limit = $('.acf-photo-gallery-group-' + JsonField.key + ' input[name=\'acf-photo-gallery-images_limit\']').val();
78
  console.log(images_limit);
79
- if( images_limit != "" && pre_selected_list.length == images_limit ){
80
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
81
  return false;
82
  }
83
 
84
- $(document).on('click', '.media-modal-content .attachments-browser .attachments li', function(){
85
  var selection_list = $('.media-modal-content .attachments-browser .attachments li[aria-checked=true]').length;
86
  var check_image_limit = pre_selected_list.length + selection_list;
87
  console.log(images_limit);
88
- if( images_limit != "" && check_image_limit > images_limit ){
89
  $(this).click();
90
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
91
  return false;
92
  }
93
  });
94
 
95
- wp.media.editor.send.attachment = function(props, attachment){
96
  acf_photo_gallery_html(attachment, field, { index: 0, splice: 0 });
97
  };
98
 
99
- wp.media.editor.open( button, function(){} );
100
  if ($('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
101
  $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
102
  }
@@ -107,16 +107,16 @@
107
  };
108
  }
109
 
110
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function(){
111
  var id = $(this).attr('data-id');
112
  var field = $(this).attr('data-field');
113
- if ( confirm('You are about to remove this photo from the gallery. Are you sure?') ){
114
  acf_photo_gallery_remove_media(id, field);
115
  }
116
  return false;
117
  });
118
 
119
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function(){
120
  var id;
121
  id = $(this).attr('data-close');
122
  $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
@@ -125,7 +125,7 @@
125
  return false;
126
  });
127
 
128
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function(){
129
  var button, field, data, post, attachment, action, nonce, fieldname, form = {};
130
  button = $(this);
131
  url = $(this).attr('data-ajaxurl');
@@ -133,11 +133,11 @@
133
  attachment = $(this).attr('data-id');
134
  fieldname = button.attr('data-fieldname');
135
 
136
- $('div.acf-photo-gallery-group-' + fieldname + ' #acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj){
137
  if (obj.name == 'acf-pg-hidden-action') {
138
  form['action'] = obj.value;
139
- } else if( obj.type == 'checkbox'){
140
- if( $(this).prop("checked") ){
141
  form[obj.name] = obj.value;
142
  } else {
143
  form[obj.name] = null;
@@ -150,13 +150,14 @@
150
  button.attr('disabled', true).html('Saving...');
151
  $.post(url, form, function(data) {
152
  button.attr('disabled', false).html('Save Changes');
153
- $('.acf-gallery-backdrop').remove();
154
  $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
 
 
155
  });
156
  return false;
157
  });
158
 
159
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function(){
160
  var $btn = $(this);
161
  var id = $btn.attr('data-id');
162
  var field = $btn.attr('data-field');
@@ -167,7 +168,7 @@
167
  $('body').css('overflow', 'hidden');
168
 
169
  if (modal === 'Native') {
170
- wp.media.editor.send.attachment = function(_, attachment){
171
  acf_photo_gallery_html(attachment, field, {
172
  index: index,
173
  splice: 1
@@ -184,8 +185,8 @@
184
  /**
185
  * @param {{ id: number }} deleted
186
  */
187
- var handleDestroy = function (deleted) {
188
- $list.children().each(function () {
189
  var $elem = $(this);
190
 
191
  if ($elem.data('id') === deleted.id) {
@@ -197,7 +198,7 @@
197
  var library = editor.get('library');
198
  library.on('destroy', handleDestroy);
199
 
200
- editor.on('close', function () {
201
  library.off('destroy', handleDestroy);
202
  });
203
 
@@ -227,7 +228,7 @@
227
  // search $el for fields of type 'photo_gallery'
228
  acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
229
  initialize_field($(this));
230
- acf_photo_gallery_add_media( $(this) );
231
  });
232
  });
233
  } else {
@@ -248,11 +249,11 @@
248
  $(document).on('acf/setup_fields', function(e, postbox) {
249
  $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
250
  initialize_field($(this));
251
- acf_photo_gallery_add_media( $(this) );
252
  //acf_photo_gallery_edit_popover( $(this) );
253
  //acf_photo_gallery_limit_images( $(this) );
254
  });
255
  });
256
  }
257
-
258
  })(jQuery);
4
  //$el.doStuff();
5
  }
6
 
7
+ function acf_photo_gallery_remove_media(id, field) {
8
  $('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
9
+ if ($('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
10
  $('.acf-photo-gallery-group-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
11
  }
12
  }
71
  var id = button.prev();
72
  var field = button.attr('data-field');
73
  var JsonField = jQuery.parseJSON(field);
74
+
75
  //On click of the add images button, check if the image limit has been reached
76
  var pre_selected_list = $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-mediabox');
77
  var images_limit = $('.acf-photo-gallery-group-' + JsonField.key + ' input[name=\'acf-photo-gallery-images_limit\']').val();
78
  console.log(images_limit);
79
+ if (images_limit != "" && pre_selected_list.length == images_limit) {
80
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
81
  return false;
82
  }
83
 
84
+ $(document).on('click', '.media-modal-content .attachments-browser .attachments li', function() {
85
  var selection_list = $('.media-modal-content .attachments-browser .attachments li[aria-checked=true]').length;
86
  var check_image_limit = pre_selected_list.length + selection_list;
87
  console.log(images_limit);
88
+ if (images_limit != "" && check_image_limit > images_limit) {
89
  $(this).click();
90
  swal('Limit has been reached', 'Your website administrator has set a limit of ' + images_limit + ' images that can be added to this gallery.', 'error')
91
  return false;
92
  }
93
  });
94
 
95
+ wp.media.editor.send.attachment = function(props, attachment) {
96
  acf_photo_gallery_html(attachment, field, { index: 0, splice: 0 });
97
  };
98
 
99
+ wp.media.editor.open(button, function() {});
100
  if ($('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
101
  $('.acf-photo-gallery-group-' + JsonField.key + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
102
  }
107
  };
108
  }
109
 
110
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
111
  var id = $(this).attr('data-id');
112
  var field = $(this).attr('data-field');
113
+ if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
114
  acf_photo_gallery_remove_media(id, field);
115
  }
116
  return false;
117
  });
118
 
119
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
120
  var id;
121
  id = $(this).attr('data-close');
122
  $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
125
  return false;
126
  });
127
 
128
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
129
  var button, field, data, post, attachment, action, nonce, fieldname, form = {};
130
  button = $(this);
131
  url = $(this).attr('data-ajaxurl');
133
  attachment = $(this).attr('data-id');
134
  fieldname = button.attr('data-fieldname');
135
 
136
+ $('div.acf-photo-gallery-group-' + fieldname + ' #acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
137
  if (obj.name == 'acf-pg-hidden-action') {
138
  form['action'] = obj.value;
139
+ } else if (obj.type == 'checkbox') {
140
+ if ($(this).prop("checked")) {
141
  form[obj.name] = obj.value;
142
  } else {
143
  form[obj.name] = null;
150
  button.attr('disabled', true).html('Saving...');
151
  $.post(url, form, function(data) {
152
  button.attr('disabled', false).html('Save Changes');
 
153
  $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
154
+ $('.acf-gallery-backdrop').remove();
155
+ $('body').css('overflow', 'auto');
156
  });
157
  return false;
158
  });
159
 
160
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
161
  var $btn = $(this);
162
  var id = $btn.attr('data-id');
163
  var field = $btn.attr('data-field');
168
  $('body').css('overflow', 'hidden');
169
 
170
  if (modal === 'Native') {
171
+ wp.media.editor.send.attachment = function(_, attachment) {
172
  acf_photo_gallery_html(attachment, field, {
173
  index: index,
174
  splice: 1
185
  /**
186
  * @param {{ id: number }} deleted
187
  */
188
+ var handleDestroy = function(deleted) {
189
+ $list.children().each(function() {
190
  var $elem = $(this);
191
 
192
  if ($elem.data('id') === deleted.id) {
198
  var library = editor.get('library');
199
  library.on('destroy', handleDestroy);
200
 
201
+ editor.on('close', function() {
202
  library.off('destroy', handleDestroy);
203
  });
204
 
228
  // search $el for fields of type 'photo_gallery'
229
  acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
230
  initialize_field($(this));
231
+ acf_photo_gallery_add_media($(this));
232
  });
233
  });
234
  } else {
249
  $(document).on('acf/setup_fields', function(e, postbox) {
250
  $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
251
  initialize_field($(this));
252
+ acf_photo_gallery_add_media($(this));
253
  //acf_photo_gallery_edit_popover( $(this) );
254
  //acf_photo_gallery_limit_images( $(this) );
255
  });
256
  });
257
  }
258
+
259
  })(jQuery);
assets/js/input.js CHANGED
@@ -1,196 +1,196 @@
1
- (function($) {
2
-
3
- function initialize_field($el) {
4
- //$el.doStuff();
5
- }
6
-
7
- $(document).ready(function() {
8
- $(".acf-photo-gallery-metabox-list").sortable({
9
- containment: "parent",
10
- placeholder: "acf-photo-gallery-sortable-placeholder",
11
- tolerance: 'pointer'
12
- }).disableSelection();
13
- });
14
-
15
- /*function acf_photo_gallery_limit_images( $el ){
16
- var field = $el.context.id;
17
- $(document).on('click', '.attachments-browser ul.attachments li.attachment', function(){
18
- var max = $('#' + field + ' input[name="acf-photo-gallery-field-max"]').val();
19
- var selCount = $('#' + field + ' .acf-photo-gallery-metabox-list li').length;
20
- var count = $('.attachments-browser ul.attachments li.attachment[aria-checked=true]').length;
21
- var finalCount = selCount + +count;
22
- if( finalCount > max ){
23
- alert('You are only allowed to select maximum of ' + max + ' images.');
24
- $(this).attr('aria-checked', false).removeClass('selected details');
25
- return false;
26
- }
27
- });
28
- }*/
29
-
30
- function acf_photo_gallery_edit(id, url, title, caption) {
31
- var html;
32
- html = '<div id="acf-photo-gallery-metabox-edit-' + id + '" class="acf-edit-photo-gallery">';
33
- html += '<h3>Edit Image</h3>';
34
- html += '<label>URL</label><input type="text" value="' + url + '"/>';
35
- html += '<label><input type="checkbox" value="1"/>Open in new tab</label>';
36
- html += '<label>Title</label><input type="text" value="' + title + '"/>';
37
- html += '<label>Caption</label><textarea>' + caption + '</textarea>';
38
- html += '<button class="button button-primary button-large" type="button">Save Changes</button>';
39
- html += '<button class="button button-large button-close" type="button" data-close="' + id + '">Close</button>';
40
- html += '</div>';
41
- return html;
42
- }
43
-
44
- function acf_photo_gallery_html(attachment, field) {
45
- var html, id, url, title, caption;
46
- id = attachment.id;
47
- url = attachment.url;
48
- title = attachment.title;
49
- caption = attachment.caption;
50
-
51
- if (typeof attachment.sizes.thumbnail != 'undefined') {
52
- url = attachment.sizes.thumbnail.url
53
- }
54
-
55
- html = acf_photo_gallery_edit(id, url, title, caption);
56
- $('#acf-' + field + ' .acf-photo-gallery-metabox-edit').append(html);
57
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list').prepend('<li class="acf-photo-gallery-mediabox" id="acf-photo-gallery-mediabox-' + id + '" data-id="' + id + '"><a class="dashicons dashicons-edit" href="#" title="Edit" data-id="' + id + '"></a><a class="dashicons dashicons-dismiss" href="#" data-id="' + id + '" data-field="' + field + '" title="Remove this photo from the gallery"></a><input type="hidden" name="' + field + '[]" value="' + id + '"/><img src="' + url + '"/></li>');
58
- }
59
-
60
- function acf_photo_gallery_add_media($el) {
61
- var acf_photo_gallery_ids = new Array();
62
- if ($('#acf-photo-gallery-metabox-add-images').length > 0) {
63
- if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
64
- $('.wrap').on('click', '#acf-photo-gallery-metabox-add-images', function(e) {
65
- e.preventDefault();
66
- var button = $(this);
67
- var id = button.prev();
68
- var field = button.attr('data-id');
69
-
70
- var pre_selected_list = $('#acf-' + field + ' .acf-photo-gallery-metabox-list li');
71
- var pre_selected = pre_selected_list.length;
72
-
73
- wp.media.editor.send.attachment = function(props, attachment){
74
- acf_photo_gallery_html(attachment, field);
75
- };
76
-
77
- wp.media.editor.open( button, function(){} );
78
- if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
79
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
80
- }
81
-
82
- /*if( pre_selected > 0 ){
83
- pre_selected_list.each(function( key, item ){
84
- var pre_selected_id = $(this).attr('data-id');
85
- //$('.attachments-browser ul.attachments li[data-id=' + pre_selected_id + ']').attr('aria-checked', true).addClass('details selected');
86
- console.log( $('.attachments-browser ul.attachments li[data-id=269]').attr('class') );
87
- $('.attachments-browser ul.attachments li[data-id="' + pre_selected_id + '"]').attr('aria-checked', true);
88
- });
89
- }*/
90
-
91
- return false;
92
- });
93
- }
94
- };
95
- }
96
-
97
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
98
- var url = $(this).attr('href');
99
- var id = $(this).attr('data-id');
100
- var field = $(this).attr('data-field');
101
- if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
102
- $.get(url, function(data) {
103
- $('#acf-' + field + ' #acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
104
- if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
105
- $('#acf-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
106
- }
107
- });
108
- }
109
- return false;
110
- });
111
-
112
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
113
- var id;
114
- id = $(this).attr('data-close');
115
- $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
116
- return false;
117
- });
118
-
119
- $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
120
- var button, field, data, post, attachment, action, nonce, form = {};
121
- action = 'acf_photo_gallery_edit_save';
122
- attachment = $(this).attr('data-id');
123
-
124
- $('#acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
125
- if (obj.name == 'acf-pg-hidden-action') {
126
- form['action'] = obj.value;
127
- } else {
128
- form[obj.name] = obj.value;
129
- }
130
- });
131
-
132
- button = $(this);
133
- button.attr('disabled', true).html('Saving...');
134
- $.post(acf.ajaxurl, form, function(data) {
135
- button.attr('disabled', false).html('Save Changes');
136
- $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
137
- });
138
- return false;
139
- });
140
-
141
- $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
142
- var id, field;
143
- id = $(this).attr('data-id');
144
- field = $(this).attr('data-field');
145
- $('#acf-' + field + ' #acf-photo-gallery-metabox-edit-' + id).fadeToggle('fast');
146
- return false;
147
- });
148
-
149
- if (typeof acf.add_action !== 'undefined') {
150
- /*
151
- * ready append (ACF5)
152
- *
153
- * These are 2 events which are fired during the page load
154
- * ready = on page load similar to $(document).ready()
155
- * append = on new DOM elements appended via repeater field
156
- *
157
- * @type event
158
- * @date 20/07/13
159
- *
160
- * @param $el (jQuery selection) the jQuery element which contains the ACF fields
161
- * @return n/a
162
- */
163
- acf.add_action('ready append', function($el) {
164
- // search $el for fields of type 'photo_gallery'
165
- acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
166
- initialize_field($(this));
167
- acf_photo_gallery_add_media( $(this) );
168
- //acf_photo_gallery_edit_popover( $(this) );
169
- //acf_photo_gallery_limit_images( $(this) );
170
- });
171
- });
172
- } else {
173
- /*
174
- * acf/setup_fields (ACF4)
175
- *
176
- * This event is triggered when ACF adds any new elements to the DOM.
177
- *
178
- * @type function
179
- * @since 1.0.0
180
- * @date 01/01/12
181
- *
182
- * @param event e: an event object. This can be ignored
183
- * @param Element postbox: An element which contains the new HTML
184
- *
185
- * @return n/a
186
- */
187
- $(document).on('acf/setup_fields', function(e, postbox) {
188
- $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
189
- initialize_field($(this));
190
- acf_photo_gallery_add_media( $(this) );
191
- //acf_photo_gallery_edit_popover( $(this) );
192
- //acf_photo_gallery_limit_images( $(this) );
193
- });
194
- });
195
- }
196
  })(jQuery);
1
+ (function($) {
2
+
3
+ function initialize_field($el) {
4
+ //$el.doStuff();
5
+ }
6
+
7
+ $(document).ready(function() {
8
+ $(".acf-photo-gallery-metabox-list").sortable({
9
+ containment: "parent",
10
+ placeholder: "acf-photo-gallery-sortable-placeholder",
11
+ tolerance: 'pointer'
12
+ }).disableSelection();
13
+ });
14
+
15
+ /*function acf_photo_gallery_limit_images( $el ){
16
+ var field = $el.context.id;
17
+ $(document).on('click', '.attachments-browser ul.attachments li.attachment', function(){
18
+ var max = $('#' + field + ' input[name="acf-photo-gallery-field-max"]').val();
19
+ var selCount = $('#' + field + ' .acf-photo-gallery-metabox-list li').length;
20
+ var count = $('.attachments-browser ul.attachments li.attachment[aria-checked=true]').length;
21
+ var finalCount = selCount + +count;
22
+ if( finalCount > max ){
23
+ alert('You are only allowed to select maximum of ' + max + ' images.');
24
+ $(this).attr('aria-checked', false).removeClass('selected details');
25
+ return false;
26
+ }
27
+ });
28
+ }*/
29
+
30
+ function acf_photo_gallery_edit(id, url, title, caption) {
31
+ var html;
32
+ html = '<div id="acf-photo-gallery-metabox-edit-' + id + '" class="acf-edit-photo-gallery">';
33
+ html += '<h3>Edit Image</h3>';
34
+ html += '<label>URL</label><input type="text" value="' + url + '"/>';
35
+ html += '<label><input type="checkbox" value="1"/>Open in new tab</label>';
36
+ html += '<label>Title</label><input type="text" value="' + title + '"/>';
37
+ html += '<label>Caption</label><textarea>' + caption + '</textarea>';
38
+ html += '<button class="button button-primary button-large" type="button">Save Changes</button>';
39
+ html += '<button class="button button-large button-close" type="button" data-close="' + id + '">Close</button>';
40
+ html += '</div>';
41
+ return html;
42
+ }
43
+
44
+ function acf_photo_gallery_html(attachment, field) {
45
+ var html, id, url, title, caption;
46
+ id = attachment.id;
47
+ url = attachment.url;
48
+ title = attachment.title;
49
+ caption = attachment.caption;
50
+
51
+ if (typeof attachment.sizes.thumbnail != 'undefined') {
52
+ url = attachment.sizes.thumbnail.url
53
+ }
54
+
55
+ html = acf_photo_gallery_edit(id, url, title, caption);
56
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-edit').append(html);
57
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list').prepend('<li class="acf-photo-gallery-mediabox" id="acf-photo-gallery-mediabox-' + id + '" data-id="' + id + '"><a class="dashicons dashicons-edit" href="#" title="Edit" data-id="' + id + '"></a><a class="dashicons dashicons-dismiss" href="#" data-id="' + id + '" data-field="' + field + '" title="Remove this photo from the gallery"></a><input type="hidden" name="' + field + '[]" value="' + id + '"/><img src="' + url + '"/></li>');
58
+ }
59
+
60
+ function acf_photo_gallery_add_media($el) {
61
+ var acf_photo_gallery_ids = new Array();
62
+ if ($('#acf-photo-gallery-metabox-add-images').length > 0) {
63
+ if (typeof wp !== 'undefined' && wp.media && wp.media.editor) {
64
+ $('.wrap').on('click', '#acf-photo-gallery-metabox-add-images', function(e) {
65
+ e.preventDefault();
66
+ var button = $(this);
67
+ var id = button.prev();
68
+ var field = button.attr('data-id');
69
+
70
+ var pre_selected_list = $('#acf-' + field + ' .acf-photo-gallery-metabox-list li');
71
+ var pre_selected = pre_selected_list.length;
72
+
73
+ wp.media.editor.send.attachment = function(props, attachment){
74
+ acf_photo_gallery_html(attachment, field);
75
+ };
76
+
77
+ wp.media.editor.open( button, function(){} );
78
+ if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').length > 0) {
79
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list li.acf-photo-gallery-media-box-placeholder').remove();
80
+ }
81
+
82
+ /*if( pre_selected > 0 ){
83
+ pre_selected_list.each(function( key, item ){
84
+ var pre_selected_id = $(this).attr('data-id');
85
+ //$('.attachments-browser ul.attachments li[data-id=' + pre_selected_id + ']').attr('aria-checked', true).addClass('details selected');
86
+ console.log( $('.attachments-browser ul.attachments li[data-id=269]').attr('class') );
87
+ $('.attachments-browser ul.attachments li[data-id="' + pre_selected_id + '"]').attr('aria-checked', true);
88
+ });
89
+ }*/
90
+
91
+ return false;
92
+ });
93
+ }
94
+ };
95
+ }
96
+
97
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-dismiss', function() {
98
+ var url = $(this).attr('href');
99
+ var id = $(this).attr('data-id');
100
+ var field = $(this).attr('data-field');
101
+ if (confirm('You are about to remove this photo from the gallery. Are you sure?')) {
102
+ $.get(url, function(data) {
103
+ $('#acf-' + field + ' #acf-photo-gallery-mediabox-' + id).fadeOut('fast').remove();
104
+ if ($('#acf-' + field + ' .acf-photo-gallery-metabox-list li').length < 1) {
105
+ $('#acf-' + field + ' .acf-photo-gallery-metabox-list').append('<li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li>');
106
+ }
107
+ });
108
+ }
109
+ return false;
110
+ });
111
+
112
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-close', function() {
113
+ var id;
114
+ id = $(this).attr('data-close');
115
+ $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + id).fadeOut('fast');
116
+ return false;
117
+ });
118
+
119
+ $(document).on('click', '#acf-photo-gallery-metabox-edit .acf-edit-photo-gallery button.button-primary', function() {
120
+ var button, field, data, post, attachment, action, nonce, form = {};
121
+ action = 'acf_photo_gallery_edit_save';
122
+ attachment = $(this).attr('data-id');
123
+
124
+ $('#acf-photo-gallery-metabox-edit-' + attachment + ' .acf-photo-gallery-edit-field').each(function(i, obj) {
125
+ if (obj.name == 'acf-pg-hidden-action') {
126
+ form['action'] = obj.value;
127
+ } else {
128
+ form[obj.name] = obj.value;
129
+ }
130
+ });
131
+
132
+ button = $(this);
133
+ button.attr('disabled', true).html('Saving...');
134
+ $.post(acf.ajaxurl, form, function(data) {
135
+ button.attr('disabled', false).html('Save Changes');
136
+ $('#acf-photo-gallery-metabox-edit #acf-photo-gallery-metabox-edit-' + attachment).fadeOut('fast');
137
+ });
138
+ return false;
139
+ });
140
+
141
+ $(document).on('click', '.acf-photo-gallery-metabox-list .dashicons-edit', function() {
142
+ var id, field;
143
+ id = $(this).attr('data-id');
144
+ field = $(this).attr('data-field');
145
+ $('#acf-' + field + ' #acf-photo-gallery-metabox-edit-' + id).fadeToggle('fast');
146
+ return false;
147
+ });
148
+
149
+ if (typeof acf.add_action !== 'undefined') {
150
+ /*
151
+ * ready append (ACF5)
152
+ *
153
+ * These are 2 events which are fired during the page load
154
+ * ready = on page load similar to $(document).ready()
155
+ * append = on new DOM elements appended via repeater field
156
+ *
157
+ * @type event
158
+ * @date 20/07/13
159
+ *
160
+ * @param $el (jQuery selection) the jQuery element which contains the ACF fields
161
+ * @return n/a
162
+ */
163
+ acf.add_action('ready append', function($el) {
164
+ // search $el for fields of type 'photo_gallery'
165
+ acf.get_fields({ type: 'photo_gallery' }, $el).each(function() {
166
+ initialize_field($(this));
167
+ acf_photo_gallery_add_media( $(this) );
168
+ //acf_photo_gallery_edit_popover( $(this) );
169
+ //acf_photo_gallery_limit_images( $(this) );
170
+ });
171
+ });
172
+ } else {
173
+ /*
174
+ * acf/setup_fields (ACF4)
175
+ *
176
+ * This event is triggered when ACF adds any new elements to the DOM.
177
+ *
178
+ * @type function
179
+ * @since 1.0.0
180
+ * @date 01/01/12
181
+ *
182
+ * @param event e: an event object. This can be ignored
183
+ * @param Element postbox: An element which contains the new HTML
184
+ *
185
+ * @return n/a
186
+ */
187
+ $(document).on('acf/setup_fields', function(e, postbox) {
188
+ $(postbox).find('.field[data-field_type="photo_gallery"]').each(function() {
189
+ initialize_field($(this));
190
+ acf_photo_gallery_add_media( $(this) );
191
+ //acf_photo_gallery_edit_popover( $(this) );
192
+ //acf_photo_gallery_limit_images( $(this) );
193
+ });
194
+ });
195
+ }
196
  })(jQuery);
fields/acf-photo_gallery-v4.php CHANGED
@@ -1,102 +1,102 @@
1
- <?php
2
-
3
- // exit if accessed directly
4
- if( ! defined( 'ABSPATH' ) ) exit;
5
-
6
- if( !defined('ACF_VERSION') ){ define('ACF_VERSION', $version); }
7
-
8
- //Saving the gallery image ids into the database postmeta table in the same order.
9
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_save.php' );
10
-
11
- //Remove photo from the database array
12
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_remove_photo.php' );
13
-
14
- //Editing and saving photo details
15
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_edit_save.php' );
16
-
17
- // check if class already exists
18
- if( !class_exists('acf_field_photo_gallery') ) :
19
-
20
- class acf_field_photo_gallery extends acf_field {
21
-
22
- // vars
23
- var $settings, // will hold info such as dir / path
24
- $defaults; // will hold default field options
25
-
26
-
27
- /*
28
- * __construct
29
- *
30
- * Set name / label needed for actions / filters
31
- *
32
- * @since 3.6
33
- * @date 23/01/13
34
- */
35
-
36
- function __construct( $settings )
37
- {
38
- include( dirname(dirname(__FILE__)) . '/includes/__construct.php' );
39
- }
40
-
41
-
42
- /*
43
- * create_options()
44
- *
45
- * Create extra options for your field. This is rendered when editing a field.
46
- * The value of $field['name'] can be used (like below) to save extra data to the $field
47
- *
48
- * @type action
49
- * @since 3.6
50
- * @date 23/01/13
51
- *
52
- * @param $field - an array holding all the field's data
53
- */
54
-
55
- function create_options($field)
56
- {
57
- include( dirname(dirname(__FILE__)) . '/includes/v4/create_options.php' );
58
- }
59
-
60
- /*
61
- * create_field()
62
- *
63
- * Create the HTML interface for your field
64
- *
65
- * @param $field - an array holding all the field's data
66
- *
67
- * @type action
68
- * @since 3.6
69
- * @date 23/01/13
70
- */
71
-
72
- function create_field( $field )
73
- {
74
- include( dirname(dirname(__FILE__)) . '/includes/render_field.php' );
75
- }
76
-
77
-
78
- /*
79
- * input_admin_enqueue_scripts()
80
- *
81
- * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
82
- * Use this action to add CSS + JavaScript to assist your create_field() action.
83
- *
84
- * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
85
- * @type action
86
- * @since 3.6
87
- * @date 23/01/13
88
- */
89
-
90
- function input_admin_enqueue_scripts()
91
- {
92
- include( dirname(dirname(__FILE__)) . '/includes/input_admin_enqueue_scripts.php' );
93
- }
94
-
95
- }
96
-
97
- // initialize
98
- new acf_field_photo_gallery( $this->settings );
99
-
100
-
101
- // class_exists check
102
  endif;
1
+ <?php
2
+
3
+ // exit if accessed directly
4
+ if( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ if( !defined('ACF_VERSION') ){ define('ACF_VERSION', $version); }
7
+
8
+ //Saving the gallery image ids into the database postmeta table in the same order.
9
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_save.php' );
10
+
11
+ //Remove photo from the database array
12
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_remove_photo.php' );
13
+
14
+ //Editing and saving photo details
15
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_edit_save.php' );
16
+
17
+ // check if class already exists
18
+ if( !class_exists('acf_field_photo_gallery') ) :
19
+
20
+ class acf_field_photo_gallery extends acf_field {
21
+
22
+ // vars
23
+ var $settings, // will hold info such as dir / path
24
+ $defaults; // will hold default field options
25
+
26
+
27
+ /*
28
+ * __construct
29
+ *
30
+ * Set name / label needed for actions / filters
31
+ *
32
+ * @since 3.6
33
+ * @date 23/01/13
34
+ */
35
+
36
+ function __construct( $settings )
37
+ {
38
+ include( dirname(dirname(__FILE__)) . '/includes/__construct.php' );
39
+ }
40
+
41
+
42
+ /*
43
+ * create_options()
44
+ *
45
+ * Create extra options for your field. This is rendered when editing a field.
46
+ * The value of $field['name'] can be used (like below) to save extra data to the $field
47
+ *
48
+ * @type action
49
+ * @since 3.6
50
+ * @date 23/01/13
51
+ *
52
+ * @param $field - an array holding all the field's data
53
+ */
54
+
55
+ function create_options($field)
56
+ {
57
+ include( dirname(dirname(__FILE__)) . '/includes/v4/create_options.php' );
58
+ }
59
+
60
+ /*
61
+ * create_field()
62
+ *
63
+ * Create the HTML interface for your field
64
+ *
65
+ * @param $field - an array holding all the field's data
66
+ *
67
+ * @type action
68
+ * @since 3.6
69
+ * @date 23/01/13
70
+ */
71
+
72
+ function create_field( $field )
73
+ {
74
+ include( dirname(dirname(__FILE__)) . '/includes/render_field.php' );
75
+ }
76
+
77
+
78
+ /*
79
+ * input_admin_enqueue_scripts()
80
+ *
81
+ * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
82
+ * Use this action to add CSS + JavaScript to assist your create_field() action.
83
+ *
84
+ * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
85
+ * @type action
86
+ * @since 3.6
87
+ * @date 23/01/13
88
+ */
89
+
90
+ function input_admin_enqueue_scripts()
91
+ {
92
+ include( dirname(dirname(__FILE__)) . '/includes/input_admin_enqueue_scripts.php' );
93
+ }
94
+
95
+ }
96
+
97
+ // initialize
98
+ new acf_field_photo_gallery( $this->settings );
99
+
100
+
101
+ // class_exists check
102
  endif;
fields/acf-photo_gallery-v5.php CHANGED
@@ -1,112 +1,112 @@
1
- <?php
2
-
3
- // exit if accessed directly
4
- if( ! defined( 'ABSPATH' ) ) exit;
5
-
6
- if( !defined('ACF_VERSION') ){ define('ACF_VERSION', $version); }
7
-
8
- //Saving the gallery image ids into the database postmeta table in the same order.
9
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_save.php' );
10
-
11
- //Remove photo from the database array
12
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_remove_photo.php' );
13
-
14
- //Editing and saving photo details
15
- include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_edit_save.php' );
16
-
17
- // check if class already exists
18
- if( !class_exists('acf_field_photo_gallery') ) :
19
-
20
- class acf_field_photo_gallery extends acf_field {
21
-
22
-
23
- /*
24
- * __construct
25
- *
26
- * This function will setup the field type data
27
- *
28
- * @type function
29
- * @date 5/03/2014
30
- * @since 5.0.0
31
- *
32
- * @param n/a
33
- * @return n/a
34
- */
35
-
36
- function __construct( $settings )
37
- {
38
- //add_filter('acf/load_value', array($this, 'load_value'), 10, 3);
39
- include( dirname(dirname(__FILE__)) . '/includes/__construct.php' );
40
- }
41
-
42
- function load_value( $value, $post_id, $field ) {
43
- if( !is_admin() ){
44
- return acf_photo_gallery_make_images($value, $field, $post_id);
45
- }
46
- return $value;
47
- }
48
-
49
- /*
50
- * render_field_settings()
51
- *
52
- * Create extra settings for your field. These are visible when editing a field
53
- *
54
- * @type action
55
- * @since 3.6
56
- * @date 23/01/13
57
- *
58
- * @param $field (array) the $field being edited
59
- * @return n/a
60
- */
61
-
62
- function render_field_settings( $field )
63
- {
64
- include( dirname(dirname(__FILE__)) . '/includes/v5/render_field_settings.php' );
65
- }
66
-
67
-
68
- /*
69
- * render_field()
70
- *
71
- * Create the HTML interface for your field
72
- *
73
- * @param $field (array) the $field being rendered
74
- *
75
- * @type action
76
- * @since 3.6
77
- * @date 23/01/13
78
- *
79
- * @param $field (array) the $field being edited
80
- * @return n/a
81
- */
82
-
83
- function render_field( $field )
84
- {
85
- include( dirname(dirname(__FILE__)) . '/includes/render_field.php' );
86
- }
87
-
88
-
89
- /*
90
- * input_admin_enqueue_scripts()
91
- *
92
- * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
93
- * Use this action to add CSS + JavaScript to assist your create_field() action.
94
- *
95
- * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
96
- * @type action
97
- * @since 3.6
98
- * @date 23/01/13
99
- */
100
-
101
- function input_admin_enqueue_scripts()
102
- {
103
- include( dirname(dirname(__FILE__)) . '/includes/input_admin_enqueue_scripts.php' );
104
- }
105
-
106
- }
107
-
108
- // initialize
109
- new acf_field_photo_gallery( $this->settings );
110
-
111
- // class_exists check
112
  endif;
1
+ <?php
2
+
3
+ // exit if accessed directly
4
+ if( ! defined( 'ABSPATH' ) ) exit;
5
+
6
+ if( !defined('ACF_VERSION') ){ define('ACF_VERSION', $version); }
7
+
8
+ //Saving the gallery image ids into the database postmeta table in the same order.
9
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_save.php' );
10
+
11
+ //Remove photo from the database array
12
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_remove_photo.php' );
13
+
14
+ //Editing and saving photo details
15
+ include( dirname(dirname(__FILE__)) . '/includes/acf_photo_gallery_edit_save.php' );
16
+
17
+ // check if class already exists
18
+ if( !class_exists('acf_field_photo_gallery') ) :
19
+
20
+ class acf_field_photo_gallery extends acf_field {
21
+
22
+
23
+ /*
24
+ * __construct
25
+ *
26
+ * This function will setup the field type data
27
+ *
28
+ * @type function
29
+ * @date 5/03/2014
30
+ * @since 5.0.0
31
+ *
32
+ * @param n/a
33
+ * @return n/a
34
+ */
35
+
36
+ function __construct( $settings )
37
+ {
38
+ //add_filter('acf/load_value', array($this, 'load_value'), 10, 3);
39
+ include( dirname(dirname(__FILE__)) . '/includes/__construct.php' );
40
+ }
41
+
42
+ function load_value( $value, $post_id, $field ) {
43
+ if( !is_admin() ){
44
+ return acf_photo_gallery_make_images($value, $field, $post_id);
45
+ }
46
+ return $value;
47
+ }
48
+
49
+ /*
50
+ * render_field_settings()
51
+ *
52
+ * Create extra settings for your field. These are visible when editing a field
53
+ *
54
+ * @type action
55
+ * @since 3.6
56
+ * @date 23/01/13
57
+ *
58
+ * @param $field (array) the $field being edited
59
+ * @return n/a
60
+ */
61
+
62
+ function render_field_settings( $field )
63
+ {
64
+ include( dirname(dirname(__FILE__)) . '/includes/v5/render_field_settings.php' );
65
+ }
66
+
67
+
68
+ /*
69
+ * render_field()
70
+ *
71
+ * Create the HTML interface for your field
72
+ *
73
+ * @param $field (array) the $field being rendered
74
+ *
75
+ * @type action
76
+ * @since 3.6
77
+ * @date 23/01/13
78
+ *
79
+ * @param $field (array) the $field being edited
80
+ * @return n/a
81
+ */
82
+
83
+ function render_field( $field )
84
+ {
85
+ include( dirname(dirname(__FILE__)) . '/includes/render_field.php' );
86
+ }
87
+
88
+
89
+ /*
90
+ * input_admin_enqueue_scripts()
91
+ *
92
+ * This action is called in the admin_enqueue_scripts action on the edit screen where your field is created.
93
+ * Use this action to add CSS + JavaScript to assist your create_field() action.
94
+ *
95
+ * $info http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts
96
+ * @type action
97
+ * @since 3.6
98
+ * @date 23/01/13
99
+ */
100
+
101
+ function input_admin_enqueue_scripts()
102
+ {
103
+ include( dirname(dirname(__FILE__)) . '/includes/input_admin_enqueue_scripts.php' );
104
+ }
105
+
106
+ }
107
+
108
+ // initialize
109
+ new acf_field_photo_gallery( $this->settings );
110
+
111
+ // class_exists check
112
  endif;
fields/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
includes/__construct.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- // vars
4
- $this->name = 'photo_gallery';
5
- $this->label = __('Photo Gallery');
6
- $this->category = __("Content",'acf'); // Basic, Content, Choice, etc
7
- $this->defaults = array(
8
- // add default here to merge into your field.
9
- // This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg:
10
- 'edit_modal' => 'Default',
11
- //'preview_size' => 'thumbnail'
12
- );
13
-
14
-
15
- // do not delete!
16
- parent::__construct();
17
-
18
- // settings
19
- $this->settings = $settings;
1
+ <?php
2
+
3
+ // vars
4
+ $this->name = 'photo_gallery';
5
+ $this->label = __('Photo Gallery');
6
+ $this->category = __("Content",'acf'); // Basic, Content, Choice, etc
7
+ $this->defaults = array(
8
+ // add default here to merge into your field.
9
+ // This makes life easy when creating the field options as you don't need to use any if( isset('') ) logic. eg:
10
+ 'edit_modal' => 'Default',
11
+ //'preview_size' => 'thumbnail'
12
+ );
13
+
14
+
15
+ // do not delete!
16
+ parent::__construct();
17
+
18
+ // settings
19
+ $this->settings = $settings;
includes/acf_photo_gallery.php CHANGED
@@ -1,41 +1,46 @@
1
- <?php
2
-
3
- //Helper function that makes the images into a resuable array
4
- function acf_photo_gallery_make_images($images, $field, $post_id, $order = 'ASC', $orderby = 'post__in'){
5
- global $wpdb;
6
- if( !is_array($images) ){ $images = explode(',', $images); }
7
- $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $images, 'order' => $order, 'orderby' => $orderby );
8
- $images = get_posts( $args );
9
- $images = array_filter($images);
10
- $array = array();
11
- if( count($images) ):
12
- foreach($images as $image):
13
- $title = $image->post_title;
14
- $content = $image->post_content;
15
- $full_url = wp_get_attachment_url($image->ID);
16
- $thumbnail_url = wp_get_attachment_thumb_url($image->ID);
17
- $meta_data = wp_get_attachment_metadata($image->ID);
18
- $large_srcset = wp_get_attachment_image_srcset( $image->ID,'large', $meta_data);
19
- $medium_srcset = wp_get_attachment_image_srcset( $image->ID,'medium', $meta_data);
20
- $url = get_post_meta($image->ID, $field . '_url', true);
21
- $target = get_post_meta($image->ID, $field . '_target', true);
22
- $array[] = array(
23
- 'id' => $image->ID,
24
- 'title' => $title,
25
- 'caption' => $content,
26
- 'full_image_url' => $full_url,
27
- 'thumbnail_image_url' => $thumbnail_url,
28
- 'large_srcset' => $large_srcset,
29
- 'medium_srcset' => $medium_srcset,
30
- 'url' => $url,
31
- 'target' => $target
32
- );
33
- endforeach;
34
- endif;
35
- return $array;
36
- }
37
-
38
- function acf_photo_gallery($field = null, $post_id, $order = 'ASC', $orderby = 'post__in'){
39
- $images = get_post_meta($post_id, $field, true);
40
- return acf_photo_gallery_make_images($images, $field, $post_id, $order, $orderby);
 
 
 
 
 
41
  }
1
+ <?php
2
+
3
+ //Helper function that makes the images into a resuable array
4
+ function acf_photo_gallery_make_images($attachment_ids, $field, $post_id = null, $order = 'ASC', $orderby = 'post__in'){
5
+ global $wpdb;
6
+ $attach_ids = explode(',', $attachment_ids);
7
+ $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $attach_ids, 'order' => $order, 'orderby' => $orderby );
8
+ $get_images = get_posts( $args );
9
+ $images = array_filter($get_images);
10
+ if( is_array($field) ){
11
+ $fieldname = $field['name'];
12
+ } else {
13
+ $fieldname = $field;
14
+ }
15
+ $array = array();
16
+ if( count($images) ):
17
+ foreach($images as $image):
18
+ $title = $image->post_title;
19
+ $content = $image->post_content;
20
+ $full_url = wp_get_attachment_url($image->ID);
21
+ $thumbnail_url = wp_get_attachment_thumb_url($image->ID);
22
+ $meta_data = wp_get_attachment_metadata($image->ID);
23
+ $large_srcset = wp_get_attachment_image_srcset( $image->ID,'large', $meta_data);
24
+ $medium_srcset = wp_get_attachment_image_srcset( $image->ID,'medium', $meta_data);
25
+ $url = get_post_meta($image->ID, $fieldname . '_url', true);
26
+ $target = get_post_meta($image->ID, $fieldname . '_target', true);
27
+ $array[] = array(
28
+ 'id' => $image->ID,
29
+ 'title' => $title,
30
+ 'caption' => $content,
31
+ 'full_image_url' => $full_url,
32
+ 'thumbnail_image_url' => $thumbnail_url,
33
+ 'large_srcset' => $large_srcset,
34
+ 'medium_srcset' => $medium_srcset,
35
+ 'url' => $url,
36
+ 'target' => $target
37
+ );
38
+ endforeach;
39
+ endif;
40
+ return $array;
41
+ }
42
+
43
+ function acf_photo_gallery($field = null, $post_id = null, $order = 'ASC', $orderby = 'post__in'){
44
+ $images = get_post_meta($post_id, $field, true);
45
+ return acf_photo_gallery_make_images($images, $field, $post_id, $order, $orderby);
46
  }
includes/acf_photo_gallery_edit.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- function acf_photo_gallery_edit($field, $nonce, $attachment, $url = '', $title, $caption, $target = 0, $acf_fieldkey){
4
- $args = array();
5
- $args['url'] = $url;
6
- $args['title'] = $title;
7
- $args['caption'] = $caption;
8
- $args['target'] = $target;
9
- $fields = apply_filters( 'acf_photo_gallery_image_fields', $args, $attachment, $field, $acf_fieldkey);
10
- include( dirname(__FILE__) . '/acf_photo_gallery_metabox_edit.php');
11
- }
1
+ <?php
2
+
3
+ function acf_photo_gallery_edit($field, $nonce, $attachment, $url = null, $title = null, $caption = null, $target = 0, $acf_fieldkey = null){
4
+ $args = array();
5
+ $args['url'] = $url;
6
+ $args['title'] = $title;
7
+ $args['caption'] = $caption;
8
+ $args['target'] = $target;
9
+ $fields = apply_filters( 'acf_photo_gallery_image_fields', $args, $attachment, $field, $acf_fieldkey);
10
+ include( dirname(__FILE__) . '/acf_photo_gallery_metabox_edit.php');
11
+ }
includes/acf_photo_gallery_edit_save.php CHANGED
@@ -1,46 +1,46 @@
1
- <?php
2
-
3
- //Fires off when ediitn the details of the photo
4
- function acf_photo_gallery_edit_save(){
5
- if( wp_verify_nonce( $_POST['acf-pg-hidden-nonce'], 'acf_photo_gallery_edit_save') and !empty($_POST['acf-pg-hidden-field']) and !empty($_POST['acf-pg-hidden-post']) and !empty($_POST['acf-pg-hidden-attachment']) ){
6
-
7
- $request = $_POST;
8
- $field = sanitize_text_field($request['acf-pg-hidden-field']);
9
- $post = sanitize_text_field($request['acf-pg-hidden-post']);
10
- $attachment = sanitize_text_field($request['acf-pg-hidden-attachment']);
11
- $title = sanitize_text_field($request['title']);
12
- $caption = sanitize_text_field($request['caption']);
13
-
14
- unset( $request['acf-pg-hidden-field'] );
15
- unset( $request['acf-pg-hidden-post'] );
16
- unset( $request['acf-pg-hidden-attachment'] );
17
- unset( $request['action'] );
18
- unset( $request['acf-pg-hidden-nonce'] );
19
- unset( $request['title'] );
20
- unset( $request['caption'] );
21
-
22
- $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $request);
23
- if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
24
- $captionColumn = 'post_excerpt';
25
- } else {
26
- $captionColumn = 'post_content';
27
- }
28
-
29
- $post = array('ID' => $attachment, 'post_title' => $title, $captionColumn => $caption);
30
- wp_update_post( $post );
31
-
32
- foreach( $request as $name => $value ){
33
- $name = sanitize_text_field( $name );
34
- $value = sanitize_text_field( $value );
35
-
36
- if( !empty($value) ){
37
- update_post_meta( $attachment, $field . '_' . $name, $value);
38
- } else {
39
- delete_post_meta( $attachment, $field . '_' . $name);
40
- }
41
- }
42
-
43
- }
44
- die();
45
- }
46
- add_action( 'wp_ajax_acf_photo_gallery_edit_save', 'acf_photo_gallery_edit_save' );
1
+ <?php
2
+
3
+ //Fires off when ediitn the details of the photo
4
+ function acf_photo_gallery_edit_save(){
5
+ if( wp_verify_nonce( $_POST['acf-pg-hidden-nonce'], 'acf_photo_gallery_edit_save') and !empty($_POST['acf-pg-hidden-field']) and !empty($_POST['acf-pg-hidden-post']) and !empty($_POST['acf-pg-hidden-attachment']) ){
6
+
7
+ $request = $_POST;
8
+ $field = sanitize_text_field($request['acf-pg-hidden-field']);
9
+ $post = sanitize_text_field($request['acf-pg-hidden-post']);
10
+ $attachment = sanitize_text_field($request['acf-pg-hidden-attachment']);
11
+ $title = sanitize_text_field($request['title']);
12
+ $caption = sanitize_textarea_field($request['caption']);
13
+
14
+ unset( $request['acf-pg-hidden-field'] );
15
+ unset( $request['acf-pg-hidden-post'] );
16
+ unset( $request['acf-pg-hidden-attachment'] );
17
+ unset( $request['action'] );
18
+ unset( $request['acf-pg-hidden-nonce'] );
19
+ unset( $request['title'] );
20
+ unset( $request['caption'] );
21
+
22
+ $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $request);
23
+ if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
24
+ $captionColumn = 'post_excerpt';
25
+ } else {
26
+ $captionColumn = 'post_content';
27
+ }
28
+
29
+ $post = array('ID' => $attachment, 'post_title' => $title, $captionColumn => $caption);
30
+ wp_update_post( $post );
31
+
32
+ foreach( $request as $name => $value ){
33
+ $name = sanitize_text_field( $name );
34
+ $value = sanitize_text_field( $value );
35
+
36
+ if( !empty($value) ){
37
+ update_post_meta( $attachment, $field . '_' . $name, $value);
38
+ } else {
39
+ delete_post_meta( $attachment, $field . '_' . $name);
40
+ }
41
+ }
42
+
43
+ }
44
+ die();
45
+ }
46
+ add_action( 'wp_ajax_acf_photo_gallery_edit_save', 'acf_photo_gallery_edit_save' );
includes/acf_photo_gallery_image_fields.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
- function acf_photo_gallery_image_fields( $args, $attachment_id, $field){
4
- return array(
5
- 'url' => array(
6
- 'type' => 'text',
7
- 'label' => 'URL',
8
- 'name' => 'url',
9
- 'value' => ($args['url'])?$args['url']:null
10
- ),
11
- 'target' => array(
12
- 'type' => 'checkbox',
13
- 'label' => 'Open in new tab',
14
- 'name' => 'target',
15
- 'value' => ($args['target'])?$args['target']:null
16
- ),
17
- 'title' => array(
18
- 'type' => 'text',
19
- 'label' => 'Title',
20
- 'name' => 'title',
21
- 'value' => ($args['title'])?$args['title']:null
22
- ),
23
- 'caption' => array(
24
- 'type' => 'textarea',
25
- 'label' => 'Caption',
26
- 'name' => 'caption',
27
- 'value' => ($args['caption'])?$args['caption']:null
28
- )
29
- );
30
- }
31
- add_filter( 'acf_photo_gallery_image_fields', 'acf_photo_gallery_image_fields', 10, 3 );
1
+ <?php
2
+
3
+ function acf_photo_gallery_image_fields( $args, $attachment_id, $field){
4
+ return array(
5
+ 'url' => array(
6
+ 'type' => 'text',
7
+ 'label' => 'URL',
8
+ 'name' => 'url',
9
+ 'value' => ($args['url'])? esc_url($args['url']):null
10
+ ),
11
+ 'target' => array(
12
+ 'type' => 'checkbox',
13
+ 'label' => 'Open in new tab',
14
+ 'name' => 'target',
15
+ 'value' => ($args['target'])? esc_attr($args['target']):null
16
+ ),
17
+ 'title' => array(
18
+ 'type' => 'text',
19
+ 'label' => 'Title',
20
+ 'name' => 'title',
21
+ 'value' => ($args['title'])? esc_attr($args['title']):null
22
+ ),
23
+ 'caption' => array(
24
+ 'type' => 'textarea',
25
+ 'label' => 'Caption',
26
+ 'name' => 'caption',
27
+ 'value' => ($args['caption'])? esc_attr($args['caption']):null
28
+ )
29
+ );
30
+ }
31
+ add_filter( 'acf_photo_gallery_image_fields', 'acf_photo_gallery_image_fields', 10, 3 );
includes/acf_photo_gallery_metabox_edit.php CHANGED
@@ -1,48 +1,48 @@
1
- <div id="acf-photo-gallery-metabox-edit-<?php echo $attachment; ?>" class="acf-edit-photo-gallery">
2
- <h3>Edit Image</h3>
3
- <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-field" value="<?php echo $field; ?>"/>
4
- <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-post" value="<?php echo $_GET['post']; ?>"/>
5
- <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-attachment" value="<?php echo $attachment; ?>"/>
6
- <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-action" value="acf_photo_gallery_edit_save"/>
7
- <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-nonce" value="<?php echo $nonce; ?>"/>
8
- <?php
9
- foreach( $fields as $key => $item ){
10
- $type = ($item['type'])?$item['type']:null;
11
- $label = $item['label']?$item['label']:null;
12
- $name = $item['name']?$item['name']:null;
13
- $value = $item['value']?$item['value']:null;
14
- ?>
15
- <?php if( in_array($type, array('text', 'date', 'color', 'datetime-local', 'email', 'number', 'tel', 'time', 'url', 'week', 'range')) ){ ?>
16
- <label><?php echo $label; ?></label>
17
- <input class="acf-photo-gallery-edit-field" type="<?php echo $type; ?>" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
18
- <?php } ?>
19
- <?php if( $type == 'checkbox' ){ ?>
20
- <label>
21
- <input class="acf-photo-gallery-edit-field" type="checkbox" name="<?php echo $name; ?>" value="true" <?php echo ($value=='true')?'checked':''; ?>/>
22
- <?php echo $label; ?>
23
- </label>
24
- <?php } ?>
25
- <?php if( $type == 'radio' ){ ?>
26
- <label>
27
- <input class="acf-photo-gallery-edit-field" type="radio" name="<?php echo $name; ?>" value="true" <?php echo ($value=='true')?'checked':''; ?>/>
28
- <?php echo $label; ?>
29
- </label>
30
- <?php } ?>
31
- <?php if( $type == 'textarea' ){ ?>
32
- <label><?php echo $label; ?></label>
33
- <textarea class="acf-photo-gallery-edit-field" name="<?php echo $name; ?>"><?php echo $value; ?></textarea>
34
- <?php } ?>
35
- <?php if( $type == 'select' ){ ?>
36
- <label><?php echo $label; ?></label>
37
- <select class="acf-photo-gallery-edit-field" name="<?php echo $name; ?>">
38
- <?php foreach($value[0] as $key => $item){ ?>
39
- <option value="<?php echo $key; ?>" <?php echo $key==$value[1]?'selected':''; ?>><?php echo $item; ?></option>
40
- <?php } ?>
41
- </select>
42
- <?php } ?>
43
- <?php } ?>
44
- <div class="save-changes-wrap">
45
- <button class="button button-primary button-large" type="submit" data-fieldname="<?php echo $acf_fieldkey; ?>" data-id="<?php echo $attachment; ?>" data-ajaxurl="<?php echo admin_url('admin-ajax.php'); ?>">Save Changes</button>
46
- <button class="button button-large button-close" type="button" data-close="<?php echo $attachment; ?>">Close</button>
47
- </div>
48
  </div>
1
+ <div id="acf-photo-gallery-metabox-edit-<?php echo esc_attr($attachment); ?>" class="acf-edit-photo-gallery">
2
+ <h3>Edit Image</h3>
3
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-field" value="<?php echo esc_attr($field); ?>"/>
4
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-post" value="<?php echo esc_attr($_GET['post']); ?>"/>
5
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-attachment" value="<?php echo esc_attr($attachment); ?>"/>
6
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-action" value="acf_photo_gallery_edit_save"/>
7
+ <input class="acf-photo-gallery-edit-field" type="hidden" name="acf-pg-hidden-nonce" value="<?php echo $nonce; ?>"/>
8
+ <?php
9
+ foreach( $fields as $key => $item ){
10
+ $type = esc_attr($item['type'])?$item['type']:null;
11
+ $label = esc_attr($item['label'])?$item['label']:null;
12
+ $name = esc_attr($item['name'])?$item['name']:null;
13
+ $value = esc_attr($item['value'])?$item['value']:null;
14
+ ?>
15
+ <?php if( in_array($type, array('text', 'date', 'color', 'datetime-local', 'email', 'number', 'tel', 'time', 'url', 'week', 'range')) ){ ?>
16
+ <label><?php echo esc_attr($label); ?></label>
17
+ <input class="acf-photo-gallery-edit-field" type="<?php echo $type; ?>" name="<?php echo esc_attr($name); ?>" value="<?php echo esc_attr($value); ?>"/>
18
+ <?php } ?>
19
+ <?php if( $type == 'checkbox' ){ ?>
20
+ <label>
21
+ <input class="acf-photo-gallery-edit-field" type="checkbox" name="<?php echo esc_attr($name); ?>" value="true" <?php echo ($value=='true')?'checked':''; ?>/>
22
+ <?php echo esc_attr($label); ?>
23
+ </label>
24
+ <?php } ?>
25
+ <?php if( $type == 'radio' ){ ?>
26
+ <label>
27
+ <input class="acf-photo-gallery-edit-field" type="radio" name="<?php echo esc_attr($name); ?>" value="true" <?php echo ($value=='true')?'checked':''; ?>/>
28
+ <?php echo esc_attr($label); ?>
29
+ </label>
30
+ <?php } ?>
31
+ <?php if( $type == 'textarea' ){ ?>
32
+ <label><?php echo esc_attr($label); ?></label>
33
+ <textarea class="acf-photo-gallery-edit-field" name="<?php echo esc_attr($name); ?>"><?php echo esc_textarea($value); ?></textarea>
34
+ <?php } ?>
35
+ <?php if( $type == 'select' ){ ?>
36
+ <label><?php echo esc_attr($label); ?></label>
37
+ <select class="acf-photo-gallery-edit-field" name="<?php echo esc_attr($name); ?>">
38
+ <?php foreach($value[0] as $key => $item){ ?>
39
+ <option value="<?php echo esc_attr($key); ?>" <?php echo $key==$value[1]?'selected':''; ?>><?php echo esc_attr($item); ?></option>
40
+ <?php } ?>
41
+ </select>
42
+ <?php } ?>
43
+ <?php } ?>
44
+ <div class="save-changes-wrap">
45
+ <button class="button button-primary button-large" type="submit" data-fieldname="<?php echo esc_attr($acf_fieldkey); ?>" data-id="<?php echo esc_attr($attachment); ?>" data-ajaxurl="<?php echo admin_url('admin-ajax.php'); ?>">Save Changes</button>
46
+ <button class="button button-large button-close" type="button" data-close="<?php echo esc_attr($attachment); ?>">Close</button>
47
+ </div>
48
  </div>
includes/acf_photo_gallery_remove_photo.php CHANGED
@@ -1,30 +1,30 @@
1
- <?php
2
-
3
- //Helper function that will remove photo from the gallery
4
- function acf_photo_gallery_remove_photo(){
5
- if( wp_verify_nonce( $_GET['_wpnonce'], 'nonce_acf_photo_gallery') and !empty($_GET['post']) and !empty($_GET['photo']) ){
6
- $field = $_GET['field'];
7
- $post = $_GET['post'];
8
- $photo = $_GET['photo'];
9
- $photo = preg_replace('/\D/', '', $photo);
10
- $id = str_replace('acf-field-', '', $_GET['id']);
11
- $meta = get_post_meta($post, $id, true);
12
- $meta_arr = explode(',', $meta);
13
- if( in_array($photo, $meta_arr) ){
14
- foreach($meta_arr as $key => $value){
15
- if( $photo == $value ){
16
- unset($meta_arr[$key]);
17
- if( count($meta_arr) > 0 ){
18
- $meta_arr = implode(',', $meta_arr);
19
- update_post_meta( $post, $id, $meta_arr );
20
- } else {
21
- delete_post_meta( $post, $id );
22
- }
23
- }
24
- }
25
- }
26
- }
27
- die();
28
- }
29
- //add_action( 'wp_ajax_nopriv_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
30
- add_action( 'wp_ajax_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
1
+ <?php
2
+
3
+ //Helper function that will remove photo from the gallery
4
+ function acf_photo_gallery_remove_photo(){
5
+ if( wp_verify_nonce( $_GET['_wpnonce'], 'nonce_acf_photo_gallery') and !empty($_GET['post']) and !empty($_GET['photo']) ){
6
+ $field = sanitize_text_field($_GET['field']);
7
+ $post = sanitize_text_field($_GET['post']);
8
+ $photo = sanitize_text_field($_GET['photo']);
9
+ $photo = preg_replace('/\D/', '', $photo);
10
+ $id = str_replace('acf-field-', '', sanitize_text_field($_GET['id']));
11
+ $meta = get_post_meta($post, $id, true);
12
+ $meta_arr = explode(',', $meta);
13
+ if( in_array($photo, $meta_arr) ){
14
+ foreach($meta_arr as $key => $value){
15
+ if( $photo == $value ){
16
+ unset($meta_arr[$key]);
17
+ if( count($meta_arr) > 0 ){
18
+ $meta_arr = implode(',', $meta_arr);
19
+ update_post_meta( $post, $id, $meta_arr );
20
+ } else {
21
+ delete_post_meta( $post, $id );
22
+ }
23
+ }
24
+ }
25
+ }
26
+ }
27
+ die();
28
+ }
29
+ //add_action( 'wp_ajax_nopriv_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
30
+ add_action( 'wp_ajax_acf_photo_gallery_remove_photo', 'acf_photo_gallery_remove_photo' );
includes/acf_photo_gallery_resize_image.php CHANGED
@@ -1,14 +1,14 @@
1
- <?php
2
-
3
- //Helper function that resizes the images from the specified args
4
- function acf_photo_gallery_resize_image( $img_url, $width = 150, $height = 150){
5
- if( !function_exists('aq_resize') ){
6
- require_once( dirname(__FILE__) . '/aq_resizer.php');
7
- }
8
- $extension = explode('.', $img_url);
9
- $extension = strtolower(end($extension));
10
- if( $extension != 'svg' ){
11
- $img_url = aq_resize( $img_url, $width, $height, true, true, true);
12
- }
13
- return $img_url;
14
  }
1
+ <?php
2
+
3
+ //Helper function that resizes the images from the specified args
4
+ function acf_photo_gallery_resize_image( $img_url, $width = 150, $height = 150){
5
+ if( !function_exists('aq_resize') ){
6
+ require_once( dirname(__FILE__) . '/aq_resizer.php');
7
+ }
8
+ $extension = explode('.', $img_url);
9
+ $extension = strtolower(end($extension));
10
+ if( $extension != 'svg' ){
11
+ $img_url = aq_resize( $img_url, $width, $height, true, true, true);
12
+ }
13
+ return $img_url;
14
  }
includes/acf_photo_gallery_save.php CHANGED
@@ -1,31 +1,35 @@
1
- <?php
2
-
3
- //Fires off when the WordPress update button is clicked
4
- function acf_photo_gallery_save( $post_id ){
5
-
6
- // If this is a revision, get real post ID
7
- if ( $parent_id = wp_is_post_revision( $post_id ) )
8
- $post_id = $parent_id;
9
- // unhook this function so it doesn't loop infinitely
10
- remove_action( 'save_post', 'acf_photo_gallery_save' );
11
-
12
- $field = isset($_POST['acf-photo-gallery-groups'])? $_POST['acf-photo-gallery-groups']: null;
13
- if( !empty($field) ){
14
- foreach($field as $k => $v ){
15
- $field_id = isset($_POST['acf-photo-gallery-groups'][$k])? $_POST['acf-photo-gallery-groups'][$k]: null;
16
- if (!empty($field_id)) {
17
- $ids = !empty($field) && isset($_POST[$field_id])? $_POST[$field_id]: null;
18
- if (!empty($ids)) {
19
- $ids = implode(',', $ids);
20
- update_post_meta($post_id, $field_id, $ids);
21
- } else {
22
- delete_post_meta($post_id, $v);
23
- }
24
- }
25
- }
26
- }
27
-
28
- // re-hook this function
29
- add_action( 'save_post', 'acf_photo_gallery_save' );
30
- }
31
- add_action( 'save_post', 'acf_photo_gallery_save' );
 
 
 
 
1
+ <?php
2
+
3
+ //Fires off when the WordPress update button is clicked
4
+ function acf_photo_gallery_save( $post_id ){
5
+
6
+ // If this is a revision, get real post ID
7
+ if ( $parent_id = wp_is_post_revision( $post_id ) )
8
+ $post_id = $parent_id;
9
+ // unhook this function so it doesn't loop infinitely
10
+ remove_action( 'save_post', 'acf_photo_gallery_save' );
11
+
12
+ $field = !empty($_POST['acf-photo-gallery-groups'])? $_POST['acf-photo-gallery-groups']: null;
13
+
14
+ if( !empty($field) ){
15
+ $field_key = sanitize_text_field($_POST['acf-photo-gallery-field']);
16
+ foreach($field as $k => $v ){
17
+ $field_id = isset($_POST['acf-photo-gallery-groups'][$k])? sanitize_text_field($_POST['acf-photo-gallery-groups'][$k]): null;
18
+ if (!empty($field_id)) {
19
+ $ids = !empty($field) && isset($_POST[$field_id])? $_POST[$field_id]: null;
20
+ if (!empty($ids)) {
21
+ $ids = implode(',', $ids);
22
+ update_post_meta($post_id, $field_id, $ids);
23
+ acf_update_metadata($post_id, $field_id, $field_key, true);
24
+ } else {
25
+ delete_post_meta($post_id, $v);
26
+ acf_delete_metadata($post_id, $field_id, true);
27
+ }
28
+ }
29
+ }
30
+ }
31
+
32
+ // re-hook this function
33
+ add_action( 'save_post', 'acf_photo_gallery_save' );
34
+ }
35
+ add_action( 'save_post', 'acf_photo_gallery_save' );
includes/aq_resizer.php CHANGED
@@ -1,246 +1,246 @@
1
- <?php
2
-
3
- /**
4
- * Title : Aqua Resizer
5
- * Description : Resizes WordPress images on the fly
6
- * Version : 1.2.1
7
- * Author : Syamil MJ
8
- * Author URI : http://aquagraphite.com
9
- * License : WTFPL - http://sam.zoy.org/wtfpl/
10
- * Documentation : https://github.com/sy4mil/Aqua-Resizer/
11
- *
12
- * @param string $url - (required) must be uploaded using wp media uploader
13
- * @param int $width - (required)
14
- * @param int $height - (optional)
15
- * @param bool $crop - (optional) default to soft crop
16
- * @param bool $single - (optional) returns an array if false
17
- * @param bool $upscale - (optional) resizes smaller images
18
- * @uses wp_upload_dir()
19
- * @uses image_resize_dimensions()
20
- * @uses wp_get_image_editor()
21
- *
22
- * @return str|array
23
- */
24
-
25
- if(!class_exists('Aq_Resize')) {
26
- class Aq_Exception extends Exception {}
27
-
28
- class Aq_Resize
29
- {
30
- /**
31
- * The singleton instance
32
- */
33
- static private $instance = null;
34
-
35
- /**
36
- * Should an Aq_Exception be thrown on error?
37
- * If false (default), then the error will just be logged.
38
- */
39
- public $throwOnError = false;
40
-
41
- /**
42
- * No initialization allowed
43
- */
44
- private function __construct() {}
45
-
46
- /**
47
- * No cloning allowed
48
- */
49
- private function __clone() {}
50
-
51
- /**
52
- * For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
53
- */
54
- static public function getInstance() {
55
- if(self::$instance == null) {
56
- self::$instance = new self;
57
- }
58
-
59
- return self::$instance;
60
- }
61
-
62
- /**
63
- * Run, forest.
64
- */
65
- public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
66
- try {
67
- // Validate inputs.
68
- if (!$url)
69
- throw new Aq_Exception('$url parameter is required');
70
- if (!$width)
71
- throw new Aq_Exception('$width parameter is required');
72
- if (!$height)
73
- throw new Aq_Exception('$height parameter is required');
74
-
75
- // Caipt'n, ready to hook.
76
- if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
77
-
78
- // Define upload path & dir.
79
- $upload_info = wp_upload_dir();
80
- $upload_dir = $upload_info['basedir'];
81
- $upload_url = $upload_info['baseurl'];
82
-
83
- $http_prefix = "http://";
84
- $https_prefix = "https://";
85
- $relative_prefix = "//"; // The protocol-relative URL
86
-
87
- /* if the $url scheme differs from $upload_url scheme, make them match
88
- if the schemes differe, images don't show up. */
89
- if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
90
- $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
91
- }
92
- elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
93
- $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
94
- }
95
- elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
96
- $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
97
- }
98
-
99
-
100
- // Check if $img_url is local.
101
- if ( false === strpos( $url, $upload_url ) )
102
- throw new Aq_Exception('Image must be local: ' . $url);
103
-
104
- // Define path of image.
105
- $rel_path = str_replace( $upload_url, '', $url );
106
- $img_path = $upload_dir . $rel_path;
107
-
108
- // Check if img path exists, and is an image indeed.
109
- if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
110
- throw new Aq_Exception('Image file does not exist (or is not an image): ' . $img_path);
111
-
112
- // Get image info.
113
- $info = pathinfo( $img_path );
114
- $ext = $info['extension'];
115
- list( $orig_w, $orig_h ) = getimagesize( $img_path );
116
-
117
- // Get image size after cropping.
118
- $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
119
- $dst_w = $dims[4];
120
- $dst_h = $dims[5];
121
-
122
- // Return the original image only if it exactly fits the needed measures.
123
- if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
124
- $img_url = $url;
125
- $dst_w = $orig_w;
126
- $dst_h = $orig_h;
127
- } else {
128
- // Use this to check if cropped image already exists, so we can return that instead.
129
- $suffix = "{$dst_w}x{$dst_h}";
130
- $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
131
- $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
132
-
133
- if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
134
- // Can't resize, so return false saying that the action to do could not be processed as planned.
135
- throw new Aq_Exception('Unable to resize image because image_resize_dimensions() failed');
136
- }
137
- // Else check if cache exists.
138
- elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
139
- $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
140
- }
141
- // Else, we resize the image and return the new resized image url.
142
- else {
143
-
144
- $editor = wp_get_image_editor( $img_path );
145
-
146
- if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
147
- throw new Aq_Exception('Unable to get WP_Image_Editor: ' .
148
- $editor->get_error_message() . ' (is GD or ImageMagick installed?)');
149
- }
150
-
151
- $resized_file = $editor->save();
152
-
153
- if ( ! is_wp_error( $resized_file ) ) {
154
- $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
155
- $img_url = $upload_url . $resized_rel_path;
156
- } else {
157
- throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message());
158
- }
159
-
160
- }
161
- }
162
-
163
- // Okay, leave the ship.
164
- if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
165
-
166
- // Return the output.
167
- if ( $single ) {
168
- // str return.
169
- $image = $img_url;
170
- } else {
171
- // array return.
172
- $image = array (
173
- 0 => $img_url,
174
- 1 => $dst_w,
175
- 2 => $dst_h
176
- );
177
- }
178
-
179
- return $image;
180
- }
181
- catch (Aq_Exception $ex) {
182
- error_log('Aq_Resize.process() error: ' . $ex->getMessage());
183
-
184
- if ($this->throwOnError) {
185
- // Bubble up exception.
186
- throw $ex;
187
- }
188
- else {
189
- // Return false, so that this patch is backwards-compatible.
190
- return false;
191
- }
192
- }
193
- }
194
-
195
- /**
196
- * Callback to overwrite WP computing of thumbnail measures
197
- */
198
- function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
199
- if ( ! $crop ) return null; // Let the wordpress default function handle this.
200
-
201
- // Here is the point we allow to use larger image size than the original one.
202
- $aspect_ratio = $orig_w / $orig_h;
203
- $new_w = $dest_w;
204
- $new_h = $dest_h;
205
-
206
- if ( ! $new_w ) {
207
- $new_w = intval( $new_h * $aspect_ratio );
208
- }
209
-
210
- if ( ! $new_h ) {
211
- $new_h = intval( $new_w / $aspect_ratio );
212
- }
213
-
214
- $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
215
-
216
- $crop_w = round( $new_w / $size_ratio );
217
- $crop_h = round( $new_h / $size_ratio );
218
-
219
- $s_x = floor( ( $orig_w - $crop_w ) / 2 );
220
- $s_y = floor( ( $orig_h - $crop_h ) / 2 );
221
-
222
- return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
223
- }
224
- }
225
- }
226
-
227
- if(!function_exists('aq_resize')) {
228
-
229
- /**
230
- * This is just a tiny wrapper function for the class above so that there is no
231
- * need to change any code in your own WP themes. Usage is still the same :)
232
- */
233
- function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
234
- /* WPML Fix */
235
- if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
236
- global $sitepress;
237
- $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
238
- }
239
- /* WPML Fix */
240
-
241
- $aq_resize = Aq_Resize::getInstance();
242
- return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
243
- }
244
- }
245
-
246
-
1
+ <?php
2
+
3
+ /**
4
+ * Title : Aqua Resizer
5
+ * Description : Resizes WordPress images on the fly
6
+ * Version : 1.2.1
7
+ * Author : Syamil MJ
8
+ * Author URI : http://aquagraphite.com
9
+ * License : WTFPL - http://sam.zoy.org/wtfpl/
10
+ * Documentation : https://github.com/sy4mil/Aqua-Resizer/
11
+ *
12
+ * @param string $url - (required) must be uploaded using wp media uploader
13
+ * @param int $width - (required)
14
+ * @param int $height - (optional)
15
+ * @param bool $crop - (optional) default to soft crop
16
+ * @param bool $single - (optional) returns an array if false
17
+ * @param bool $upscale - (optional) resizes smaller images
18
+ * @uses wp_upload_dir()
19
+ * @uses image_resize_dimensions()
20
+ * @uses wp_get_image_editor()
21
+ *
22
+ * @return str|array
23
+ */
24
+
25
+ if(!class_exists('Aq_Resize')) {
26
+ class Aq_Exception extends Exception {}
27
+
28
+ class Aq_Resize
29
+ {
30
+ /**
31
+ * The singleton instance
32
+ */
33
+ static private $instance = null;
34
+
35
+ /**
36
+ * Should an Aq_Exception be thrown on error?
37
+ * If false (default), then the error will just be logged.
38
+ */
39
+ public $throwOnError = false;
40
+
41
+ /**
42
+ * No initialization allowed
43
+ */
44
+ private function __construct() {}
45
+
46
+ /**
47
+ * No cloning allowed
48
+ */
49
+ private function __clone() {}
50
+
51
+ /**
52
+ * For your custom default usage you may want to initialize an Aq_Resize object by yourself and then have own defaults
53
+ */
54
+ static public function getInstance() {
55
+ if(self::$instance == null) {
56
+ self::$instance = new self;
57
+ }
58
+
59
+ return self::$instance;
60
+ }
61
+
62
+ /**
63
+ * Run, forest.
64
+ */
65
+ public function process( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
66
+ try {
67
+ // Validate inputs.
68
+ if (!$url)
69
+ throw new Aq_Exception('$url parameter is required');
70
+ if (!$width)
71
+ throw new Aq_Exception('$width parameter is required');
72
+ if (!$height)
73
+ throw new Aq_Exception('$height parameter is required');
74
+
75
+ // Caipt'n, ready to hook.
76
+ if ( true === $upscale ) add_filter( 'image_resize_dimensions', array($this, 'aq_upscale'), 10, 6 );
77
+
78
+ // Define upload path & dir.
79
+ $upload_info = wp_upload_dir();
80
+ $upload_dir = $upload_info['basedir'];
81
+ $upload_url = $upload_info['baseurl'];
82
+
83
+ $http_prefix = "http://";
84
+ $https_prefix = "https://";
85
+ $relative_prefix = "//"; // The protocol-relative URL
86
+
87
+ /* if the $url scheme differs from $upload_url scheme, make them match
88
+ if the schemes differe, images don't show up. */
89
+ if(!strncmp($url,$https_prefix,strlen($https_prefix))){ //if url begins with https:// make $upload_url begin with https:// as well
90
+ $upload_url = str_replace($http_prefix,$https_prefix,$upload_url);
91
+ }
92
+ elseif(!strncmp($url,$http_prefix,strlen($http_prefix))){ //if url begins with http:// make $upload_url begin with http:// as well
93
+ $upload_url = str_replace($https_prefix,$http_prefix,$upload_url);
94
+ }
95
+ elseif(!strncmp($url,$relative_prefix,strlen($relative_prefix))){ //if url begins with // make $upload_url begin with // as well
96
+ $upload_url = str_replace(array( 0 => "$http_prefix", 1 => "$https_prefix"),$relative_prefix,$upload_url);
97
+ }
98
+
99
+
100
+ // Check if $img_url is local.
101
+ if ( false === strpos( $url, $upload_url ) )
102
+ throw new Aq_Exception('Image must be local: ' . $url);
103
+
104
+ // Define path of image.
105
+ $rel_path = str_replace( $upload_url, '', $url );
106
+ $img_path = $upload_dir . $rel_path;
107
+
108
+ // Check if img path exists, and is an image indeed.
109
+ if ( ! file_exists( $img_path ) or ! getimagesize( $img_path ) )
110
+ throw new Aq_Exception('Image file does not exist (or is not an image): ' . $img_path);
111
+
112
+ // Get image info.
113
+ $info = pathinfo( $img_path );
114
+ $ext = $info['extension'];
115
+ list( $orig_w, $orig_h ) = getimagesize( $img_path );
116
+
117
+ // Get image size after cropping.
118
+ $dims = image_resize_dimensions( $orig_w, $orig_h, $width, $height, $crop );
119
+ $dst_w = $dims[4];
120
+ $dst_h = $dims[5];
121
+
122
+ // Return the original image only if it exactly fits the needed measures.
123
+ if ( ! $dims && ( ( ( null === $height && $orig_w == $width ) xor ( null === $width && $orig_h == $height ) ) xor ( $height == $orig_h && $width == $orig_w ) ) ) {
124
+ $img_url = $url;
125
+ $dst_w = $orig_w;
126
+ $dst_h = $orig_h;
127
+ } else {
128
+ // Use this to check if cropped image already exists, so we can return that instead.
129
+ $suffix = "{$dst_w}x{$dst_h}";
130
+ $dst_rel_path = str_replace( '.' . $ext, '', $rel_path );
131
+ $destfilename = "{$upload_dir}{$dst_rel_path}-{$suffix}.{$ext}";
132
+
133
+ if ( ! $dims || ( true == $crop && false == $upscale && ( $dst_w < $width || $dst_h < $height ) ) ) {
134
+ // Can't resize, so return false saying that the action to do could not be processed as planned.
135
+ throw new Aq_Exception('Unable to resize image because image_resize_dimensions() failed');
136
+ }
137
+ // Else check if cache exists.
138
+ elseif ( file_exists( $destfilename ) && getimagesize( $destfilename ) ) {
139
+ $img_url = "{$upload_url}{$dst_rel_path}-{$suffix}.{$ext}";
140
+ }
141
+ // Else, we resize the image and return the new resized image url.
142
+ else {
143
+
144
+ $editor = wp_get_image_editor( $img_path );
145
+
146
+ if ( is_wp_error( $editor ) || is_wp_error( $editor->resize( $width, $height, $crop ) ) ) {
147
+ throw new Aq_Exception('Unable to get WP_Image_Editor: ' .
148
+ $editor->get_error_message() . ' (is GD or ImageMagick installed?)');
149
+ }
150
+
151
+ $resized_file = $editor->save();
152
+
153
+ if ( ! is_wp_error( $resized_file ) ) {
154
+ $resized_rel_path = str_replace( $upload_dir, '', $resized_file['path'] );
155
+ $img_url = $upload_url . $resized_rel_path;
156
+ } else {
157
+ throw new Aq_Exception('Unable to save resized image file: ' . $editor->get_error_message());
158
+ }
159
+
160
+ }
161
+ }
162
+
163
+ // Okay, leave the ship.
164
+ if ( true === $upscale ) remove_filter( 'image_resize_dimensions', array( $this, 'aq_upscale' ) );
165
+
166
+ // Return the output.
167
+ if ( $single ) {
168
+ // str return.
169
+ $image = $img_url;
170
+ } else {
171
+ // array return.
172
+ $image = array (
173
+ 0 => $img_url,
174
+ 1 => $dst_w,
175
+ 2 => $dst_h
176
+ );
177
+ }
178
+
179
+ return $image;
180
+ }
181
+ catch (Aq_Exception $ex) {
182
+ error_log('Aq_Resize.process() error: ' . $ex->getMessage());
183
+
184
+ if ($this->throwOnError) {
185
+ // Bubble up exception.
186
+ throw $ex;
187
+ }
188
+ else {
189
+ // Return false, so that this patch is backwards-compatible.
190
+ return false;
191
+ }
192
+ }
193
+ }
194
+
195
+ /**
196
+ * Callback to overwrite WP computing of thumbnail measures
197
+ */
198
+ function aq_upscale( $default, $orig_w, $orig_h, $dest_w, $dest_h, $crop ) {
199
+ if ( ! $crop ) return null; // Let the wordpress default function handle this.
200
+
201
+ // Here is the point we allow to use larger image size than the original one.
202
+ $aspect_ratio = $orig_w / $orig_h;
203
+ $new_w = $dest_w;
204
+ $new_h = $dest_h;
205
+
206
+ if ( ! $new_w ) {
207
+ $new_w = intval( $new_h * $aspect_ratio );
208
+ }
209
+
210
+ if ( ! $new_h ) {
211
+ $new_h = intval( $new_w / $aspect_ratio );
212
+ }
213
+
214
+ $size_ratio = max( $new_w / $orig_w, $new_h / $orig_h );
215
+
216
+ $crop_w = round( $new_w / $size_ratio );
217
+ $crop_h = round( $new_h / $size_ratio );
218
+
219
+ $s_x = floor( ( $orig_w - $crop_w ) / 2 );
220
+ $s_y = floor( ( $orig_h - $crop_h ) / 2 );
221
+
222
+ return array( 0, 0, (int) $s_x, (int) $s_y, (int) $new_w, (int) $new_h, (int) $crop_w, (int) $crop_h );
223
+ }
224
+ }
225
+ }
226
+
227
+ if(!function_exists('aq_resize')) {
228
+
229
+ /**
230
+ * This is just a tiny wrapper function for the class above so that there is no
231
+ * need to change any code in your own WP themes. Usage is still the same :)
232
+ */
233
+ function aq_resize( $url, $width = null, $height = null, $crop = null, $single = true, $upscale = false ) {
234
+ /* WPML Fix */
235
+ if ( defined( 'ICL_SITEPRESS_VERSION' ) ){
236
+ global $sitepress;
237
+ $url = $sitepress->convert_url( $url, $sitepress->get_default_language() );
238
+ }
239
+ /* WPML Fix */
240
+
241
+ $aq_resize = Aq_Resize::getInstance();
242
+ return $aq_resize->process( $url, $width, $height, $crop, $single, $upscale );
243
+ }
244
+ }
245
+
246
+
includes/elementor_register_tag.php ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use ElementorPro\Modules\DynamicTags\Tags\Base\Data_Tag;
4
+
5
+ class register_tag extends Data_Tag {
6
+
7
+ /**
8
+ * Get Name
9
+ *
10
+ * Returns the Name of the tag
11
+ *
12
+ * @since 2.0.0
13
+ * @access public
14
+ *
15
+ * @return string
16
+ */
17
+ public function get_name() {
18
+ return 'acf-photo-gallery';
19
+ }
20
+
21
+ /**
22
+ * Get Title
23
+ *
24
+ * Returns the title of the Tag
25
+ *
26
+ * @since 2.0.0
27
+ * @access public
28
+ *
29
+ * @return string
30
+ */
31
+ public function get_title() {
32
+ return __( 'ACF Photo Gallery', 'elementor-pro' );
33
+ }
34
+
35
+ /**
36
+ * Get Group
37
+ *
38
+ * Returns the Group of the tag
39
+ *
40
+ * @since 2.0.0
41
+ * @access public
42
+ *
43
+ * @return string
44
+ */
45
+ public function get_group() {
46
+ return 'acf';
47
+ }
48
+
49
+ /**
50
+ * Get Categories
51
+ *
52
+ * Returns an array of tag categories
53
+ *
54
+ * @since 2.0.0
55
+ * @access public
56
+ *
57
+ * @return array
58
+ */
59
+ public function get_categories() {
60
+ return [ \Elementor\Modules\DynamicTags\Module::GALLERY_CATEGORY ];
61
+ }
62
+
63
+ /**
64
+ * Register Controls
65
+ *
66
+ * Registers the Dynamic tag controls
67
+ *
68
+ * @since 2.0.0
69
+ * @access protected
70
+ *
71
+ * @return void
72
+ */
73
+ protected function register_controls() {
74
+ $this->add_control(
75
+ 'Key',
76
+ [
77
+ 'label' => __( 'Key', 'elementor-pro' ),
78
+ 'type' => \Elementor\Controls_Manager::SELECT,
79
+ 'groups' => self::get_control_options(),
80
+ ]
81
+ );
82
+ }
83
+
84
+ /**
85
+ * Render
86
+ *
87
+ * Prints out the value of the Dynamic tag
88
+ *
89
+ * @since 2.0.0
90
+ * @access public
91
+ *
92
+ * @return void
93
+ */
94
+ public function render() {
95
+ $key = $this->get_settings( 'Key' );
96
+ if ( !empty($key) ){
97
+ list( $field_key, $meta_key ) = explode( ':', $key );
98
+ if ( 'options' === $field_key ) {
99
+ $field = get_field_object( $meta_key, $field_key );
100
+ } else {
101
+ $field = get_field_object( $field_key, get_queried_object() );
102
+ }
103
+ echo $field;
104
+ }
105
+ return;
106
+ }
107
+
108
+ public function get_value( array $options = [] ) {
109
+ $images = [];
110
+ $key = $this->get_settings( 'Key' );
111
+
112
+ list( $field, $meta_key ) = explode( ':', $key );
113
+
114
+ //$field = get_field($meta_key, get_the_ID());
115
+ //$value = explode(',', $field);
116
+ $value = get_field($meta_key, get_the_ID());
117
+
118
+ if ( is_array( $value ) && !empty( $value ) ) {
119
+ foreach ( $value as $image ) {
120
+ $images[] = [
121
+ 'id' => $image['id'],
122
+ ];
123
+ }
124
+ }
125
+
126
+ return $images;
127
+ }
128
+
129
+
130
+ public static function get_control_options() {
131
+
132
+ // ACF >= 5.0.0
133
+ if ( function_exists( 'acf_get_field_groups' ) ) {
134
+ $acf_groups = acf_get_field_groups();
135
+ } else {
136
+ $acf_groups = apply_filters( 'acf/get_field_groups', [] );
137
+ }
138
+
139
+ $groups = [];
140
+
141
+ $options_page_groups_ids = [];
142
+
143
+ if ( function_exists( 'acf_options_page' ) ) {
144
+ $pages = acf_options_page()->get_pages();
145
+ foreach ( $pages as $slug => $page ) {
146
+ $options_page_groups = acf_get_field_groups( [
147
+ 'options_page' => $slug,
148
+ ] );
149
+
150
+ foreach ( $options_page_groups as $options_page_group ) {
151
+ $options_page_groups_ids[] = $options_page_group['ID'];
152
+ }
153
+ }
154
+ }
155
+
156
+ foreach ( $acf_groups as $acf_group ) {
157
+ // ACF >= 5.0.0
158
+ if ( function_exists( 'acf_get_fields' ) ) {
159
+ if ( isset( $acf_group['ID'] ) && ! empty( $acf_group['ID'] ) ) {
160
+ $fields = acf_get_fields( $acf_group['ID'] );
161
+ } else {
162
+ $fields = acf_get_fields( $acf_group );
163
+ }
164
+ } else {
165
+ $fields = apply_filters( 'acf/field_group/get_fields', [], $acf_group['id'] );
166
+ }
167
+
168
+ $options = [];
169
+
170
+ if ( ! is_array( $fields ) ) {
171
+ continue;
172
+ }
173
+
174
+ $has_option_page_location = in_array( $acf_group['ID'], $options_page_groups_ids, true );
175
+ $is_only_options_page = $has_option_page_location && 1 === count( $acf_group['location'] );
176
+
177
+ foreach ( $fields as $field ) {
178
+ if ( ! in_array( $field['type'], array('photo_gallery'), true ) ) {
179
+ continue;
180
+ }
181
+
182
+ // Use group ID for unique keys
183
+ if ( $has_option_page_location ) {
184
+ $key = 'options:' . $field['name'];
185
+ $options[ $key ] = __( 'Options', 'elementor-pro' ) . ':' . $field['label'];
186
+ if ( $is_only_options_page ) {
187
+ continue;
188
+ }
189
+ }
190
+
191
+ $key = $field['key'] . ':' . $field['name'];
192
+ $options[ $key ] = $field['label'];
193
+ }
194
+
195
+ if ( empty( $options ) ) {
196
+ continue;
197
+ }
198
+
199
+ if ( 1 === count( $options ) ) {
200
+ $options = [ -1 => ' -- ' ] + $options;
201
+ }
202
+
203
+ $groups[] = [
204
+ 'label' => $acf_group['title'],
205
+ 'options' => $options,
206
+ ];
207
+ } // End foreach().
208
+
209
+ return $groups;
210
+ }
211
+
212
+ }
includes/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
includes/input_admin_enqueue_scripts.php CHANGED
@@ -1,22 +1,22 @@
1
- <?php
2
-
3
- // vars
4
- $url = $this->settings['url'];
5
- $version = $this->settings['version'];
6
-
7
- // register & include JS
8
- wp_enqueue_script( 'jquery-ui-sortable' );
9
-
10
- wp_register_script( 'acf-input-photo_gallery', "{$url}assets/js/acf-photo-gallery-field.js", array('acf-input'), $version );
11
- wp_enqueue_script( 'acf-input-photo_gallery');
12
-
13
- wp_register_script( 'acf-input-photo_gallery_swal', "{$url}assets/js/sweetalert2.min.js", array('acf-input'), $version );
14
- wp_enqueue_script( 'acf-input-photo_gallery_swal');
15
-
16
-
17
- // register & include CSS
18
- wp_register_style( 'acf-input-photo_gallery', "{$url}assets/css/acf-photo-gallery-field.css", array('acf-input'), $version );
19
- wp_enqueue_style('acf-input-photo_gallery');
20
-
21
- wp_register_style( 'acf-input-photo_gallery_swal', "{$url}assets/css/sweetalert2.min.css", array('acf-input'), $version );
22
  wp_enqueue_style('acf-input-photo_gallery_swal');
1
+ <?php
2
+
3
+ // vars
4
+ $url = $this->settings['url'];
5
+ $version = $this->settings['version'];
6
+
7
+ // register & include JS
8
+ wp_enqueue_script( 'jquery-ui-sortable' );
9
+
10
+ wp_register_script( 'acf-input-photo_gallery', "{$url}assets/js/acf-photo-gallery-field.js", array('acf-input'), $version );
11
+ wp_enqueue_script( 'acf-input-photo_gallery');
12
+
13
+ wp_register_script( 'acf-input-photo_gallery_swal', "{$url}assets/js/sweetalert2.min.js", array('acf-input'), $version );
14
+ wp_enqueue_script( 'acf-input-photo_gallery_swal');
15
+
16
+
17
+ // register & include CSS
18
+ wp_register_style( 'acf-input-photo_gallery', "{$url}assets/css/acf-photo-gallery-field.css", array('acf-input'), $version );
19
+ wp_enqueue_style('acf-input-photo_gallery');
20
+
21
+ wp_register_style( 'acf-input-photo_gallery_swal', "{$url}assets/css/sweetalert2.min.css", array('acf-input'), $version );
22
  wp_enqueue_style('acf-input-photo_gallery_swal');
includes/render_field.php CHANGED
@@ -1,70 +1,80 @@
1
- <?php
2
-
3
- global $pagenow;
4
- if( $pagenow == 'edit-tags.php'){
5
- echo 'ACF Photo Gallery Field is not supported on taxonomy.';
6
- } else {
7
-
8
- // create Field HTML
9
- global $post;
10
- $nonce_acf_photo_gallery = wp_create_nonce( 'nonce_acf_photo_gallery' );
11
- if( ACF_VERSION >= 4 and ACF_VERSION < 5 ){
12
- $filename = $field['_name'];
13
- $value = $field['value'];
14
- $key = $field['key'];
15
- $edit_model = (!empty($field['edit_modal']))?$field['edit_modal']:'Default';
16
- } else if( ACF_VERSION >= 5 and ACF_VERSION < 6 ){
17
- $filename = $field['_name'];
18
- $value = $field['value'];
19
- $key = $field['key'];
20
- $edit_model = (!empty($field['fields[' . $filename]['edit_modal']))?$field['fields[' . $filename]['edit_modal']:'Default';
21
- $images_limit = (!empty($field['fields[' . $filename]['images_limit']))?$field['fields[' . $filename]['images_limit']:null;
22
- $replace_textarea_editor = (!empty($field['fields[' . $filename]['replace_caption_tinymce']))?$field['fields[' . $filename]['replace_caption_tinymce']:null;
23
- }
24
- ?>
25
- <div class="acf-photo-gallery-group-<?php echo $key; ?>">
26
- <input type="hidden" name="acf-photo-gallery-edit-modal" value="<?php echo $edit_model; ?>" />
27
- <input type="hidden" name="acf-photo-gallery-groups[]" value="<?php echo $field['_name']; ?>"/>
28
- <input type="hidden" name="acf-photo-gallery-images_limit" value="<?php echo $images_limit; ?>"/>
29
- <div id="acf-photo-gallery-metabox-edit">
30
- <?php
31
- if( $value ):
32
- $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $field);
33
- $acf_photo_gallery_attachments = $value;
34
- $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
35
- $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $acf_photo_gallery_attachments );
36
- $acf_photo_gallery_attachments = get_posts( $args );
37
- $nonce = wp_create_nonce('acf_photo_gallery_edit_save');
38
- foreach($acf_photo_gallery_attachments as $attachment):
39
- $id = $attachment->ID;
40
- $url = get_post_meta($id, $field['_name'] . '_url', true);
41
- $target = get_post_meta($id, $field['_name'] . '_target', true);
42
- $title = $attachment->post_title;
43
- if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
44
- $caption = wp_get_attachment_caption( $id );
45
- } else {
46
- $caption = $attachment->post_content;
47
- }
48
- acf_photo_gallery_edit($field['_name'], $nonce, $id, $url, $title, $caption, $target, $key, $replace_textarea_editor);
49
- endforeach;
50
- endif;
51
- ?>
52
- </div>
53
- <ul id="acf-photo-gallery-metabox-list" class="acf-photo-gallery-metabox-list">
54
- <?php
55
- if( $value ):
56
- $acf_photo_gallery_attachments = $value;
57
- $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
58
- foreach($acf_photo_gallery_attachments as $image):
59
- ?>
60
- <li class="acf-photo-gallery-mediabox acf-photo-gallery-mediabox-<?php echo $image; ?>">
61
- <a class="dashicons dashicons-edit" href="#" title="Edit" data-id="<?php echo $image; ?>" data-field="<?php echo $key; ?>"></a>
62
- <a class="dashicons dashicons-dismiss" href="#" data-id="<?php echo $image; ?>" data-field="<?php echo $key; ?>" title="Remove this photo from the gallery"></a>
63
- <input type="hidden" name="<?php echo $field['_name']; ?>[]" value="<?php echo $image; ?>"/>
64
- <img src="<?php echo wp_get_attachment_thumb_url( $image ); ?>"/>
65
- </li>
66
- <?php endforeach; else: ?><li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li><?php endif; ?>
67
- </ul>
68
- <button class="button button-primary button-large acf-photo-gallery-metabox-add-images" type="button" data-field="<?php echo htmlspecialchars(json_encode($field), ENT_QUOTES, 'UTF-8'); ?>">Add Images</button>
69
- </div>
 
 
 
 
 
 
 
 
 
 
70
  <?php } ?>
1
+ <?php
2
+
3
+ global $pagenow;
4
+ if( $pagenow == 'edit-tags.php'){
5
+ echo 'ACF Photo Gallery Field is not supported on taxonomy.';
6
+ } else {
7
+
8
+ $remove_edit_button = "";
9
+ $remove_delete_button = "";
10
+ $images_limit = "";
11
+
12
+ global $post;
13
+ $nonce_acf_photo_gallery = wp_create_nonce( 'nonce_acf_photo_gallery' );
14
+ if( ACF_VERSION >= 4 and ACF_VERSION < 5 ){
15
+ $fieldname = $field['_name'];
16
+ $value = $field['value'];
17
+ $key = $field['key'];
18
+ $edit_model = (!empty($field['edit_modal']))? esc_attr($field['edit_modal']):'Default';
19
+ } else if( ACF_VERSION >= 5 and ACF_VERSION < 6 ){
20
+ $fieldname = $field['_name'];
21
+ $value = $field['value'];
22
+ $key = $field['key'];
23
+ $remove_edit_button = (!empty($field['fields[' . $fieldname]['remove_edit_button']))? esc_attr($field['fields[' . $fieldname]['remove_edit_button']):null;
24
+ $remove_delete_button = (!empty($field['fields[' . $fieldname]['remove_delete_button']))? esc_attr($field['fields[' . $fieldname]['remove_delete_button']):null;
25
+ $edit_model = (!empty($field['fields[' . $fieldname]['edit_modal']))? esc_attr($field['fields[' . $fieldname]['edit_modal']):'Default';
26
+ $images_limit = (!empty($field['fields[' . $fieldname]['images_limit']))? esc_attr($field['fields[' . $fieldname]['images_limit']):null;
27
+ $replace_textarea_editor = (!empty($field['fields[' . $fieldname]['replace_caption_tinymce']))? esc_attr($field['fields[' . $fieldname]['replace_caption_tinymce']):null;
28
+ }
29
+ ?>
30
+ <div class="acf-photo-gallery-group-<?php echo esc_attr($key); ?>">
31
+ <input type="hidden" name="acf-photo-gallery-edit-modal" value="<?php echo esc_attr($edit_model); ?>" />
32
+ <input type="hidden" name="acf-photo-gallery-groups[]" value="<?php echo esc_attr($field['_name']); ?>"/>
33
+ <input type="hidden" name="acf-photo-gallery-images_limit" value="<?php echo esc_attr($images_limit); ?>"/>
34
+ <input type="hidden" name="acf-photo-gallery-field" value="<?php echo esc_attr($key); ?>"/>
35
+ <div id="acf-photo-gallery-metabox-edit">
36
+ <?php
37
+ if( $value ):
38
+ $acf_photo_gallery_editbox_caption_from_attachment = apply_filters( 'acf_photo_gallery_editbox_caption_from_attachment', $field);
39
+ $acf_photo_gallery_attachments = $value;
40
+ $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
41
+ $args = array( 'post_type' => 'attachment', 'posts_per_page' => -1, 'post__in' => $acf_photo_gallery_attachments );
42
+ $acf_photo_gallery_attachments = get_posts( $args );
43
+ $nonce = wp_create_nonce('acf_photo_gallery_edit_save');
44
+ foreach($acf_photo_gallery_attachments as $attachment):
45
+ $id = $attachment->ID;
46
+ $url = get_post_meta($id, $field['_name'] . '_url', true);
47
+ $target = get_post_meta($id, $field['_name'] . '_target', true);
48
+ $title = $attachment->post_title;
49
+ if( $acf_photo_gallery_editbox_caption_from_attachment == 1 ){
50
+ $caption = wp_get_attachment_caption( $id );
51
+ } else {
52
+ $caption = $attachment->post_content;
53
+ }
54
+ acf_photo_gallery_edit($field['_name'], $nonce, $id, $url, $title, $caption, $target, $key, $replace_textarea_editor);
55
+ endforeach;
56
+ endif;
57
+ ?>
58
+ </div>
59
+ <ul id="acf-photo-gallery-metabox-list" class="acf-photo-gallery-metabox-list">
60
+ <?php
61
+ if( $value ):
62
+ $acf_photo_gallery_attachments = $value;
63
+ $acf_photo_gallery_attachments = explode(',', $acf_photo_gallery_attachments);
64
+ foreach($acf_photo_gallery_attachments as $image):
65
+ ?>
66
+ <li class="acf-photo-gallery-mediabox acf-photo-gallery-mediabox-<?php echo esc_attr($image); ?>">
67
+ <?php if($remove_edit_button != "Yes") { ?>
68
+ <a class="dashicons dashicons-edit" href="#" title="Edit" data-id="<?php echo esc_attr($image); ?>" data-field="<?php echo esc_attr($key); ?>"></a>
69
+ <?php } ?>
70
+ <?php if($remove_delete_button != "Yes") { ?>
71
+ <a class="dashicons dashicons-dismiss" href="#" data-id="<?php echo esc_attr($image); ?>" data-field="<?php echo esc_attr($key); ?>" title="Remove this photo from the gallery"></a>
72
+ <?php } ?>
73
+ <input type="hidden" name="<?php echo $field['_name']; ?>[]" value="<?php echo esc_attr($image); ?>"/>
74
+ <img src="<?php echo wp_get_attachment_thumb_url( $image ); ?>"/>
75
+ </li>
76
+ <?php endforeach; else: ?><li class="acf-photo-gallery-media-box-placeholder"><span class="dashicons dashicons-format-image"></span></li><?php endif; ?>
77
+ </ul>
78
+ <button class="button button-primary button-large acf-photo-gallery-metabox-add-images" type="button" data-field="<?php echo htmlspecialchars(json_encode($field), ENT_QUOTES, 'UTF-8'); ?>">Add Images</button>
79
+ </div>
80
  <?php } ?>
includes/v4/create_options.php CHANGED
@@ -1,20 +1,20 @@
1
- <?php
2
- $field = array_merge($this->defaults, $field);
3
- $key = $field['name'];
4
- ?>
5
- <tr class="field_option field_option_<?php echo $this->name; ?>">
6
- <td class="label">
7
- <label><?php _e("Edit modal",'acf'); ?></label>
8
- <p class="description"><?php _e("Native lets you delete permanently or select another, but is heavier",'acf'); ?></p>
9
- </td>
10
- <td>
11
- <?php
12
- do_action('acf/create_field', array(
13
- 'type' => 'select',
14
- 'name' => 'fields['.$key.'][edit_modal]',
15
- 'value' => $field['edit_modal'],
16
- 'choices' => array('Default' => 'Default', 'Native' => 'Native')
17
- ));
18
- ?>
19
- </td>
20
  </tr>
1
+ <?php
2
+ $field = array_merge($this->defaults, $field);
3
+ $key = $field['name'];
4
+ ?>
5
+ <tr class="field_option field_option_<?php echo $this->name; ?>">
6
+ <td class="label">
7
+ <label><?php _e("Edit modal",'acf'); ?></label>
8
+ <p class="description"><?php _e("Native lets you delete permanently or select another, but is heavier",'acf'); ?></p>
9
+ </td>
10
+ <td>
11
+ <?php
12
+ do_action('acf/create_field', array(
13
+ 'type' => 'select',
14
+ 'name' => 'fields['.$key.'][edit_modal]',
15
+ 'value' => $field['edit_modal'],
16
+ 'choices' => array('Default' => 'Default', 'Native' => 'Native')
17
+ ));
18
+ ?>
19
+ </td>
20
  </tr>
includes/v4/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
includes/v5/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
includes/v5/render_field_settings.php CHANGED
@@ -1,28 +1,44 @@
1
- <?php
2
- /*
3
- * acf_render_field_setting
4
- *
5
- * This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
6
- * The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
7
- *
8
- * More than one setting can be added by copy/paste the above code.
9
- * Please note that you must also have a matching $defaults value for the field name (font_size)
10
- */
11
-
12
- $name = $field['name'];
13
- $value = $field['fields['.$name];
14
-
15
- acf_render_field_setting( $field, array(
16
- 'label' => __('Edit modal','TEXTDOMAIN'),
17
- 'type' => 'select',
18
- 'name' => 'fields['.$name.'][edit_modal]',
19
- 'value' => $value['edit_modal'],
20
- 'choices' => array('Default' => 'Default', 'Native' => 'Native')
21
- ));
22
-
23
- acf_render_field_setting( $field, array(
24
- 'label' => __('Images Limit','TEXTDOMAIN'),
25
- 'type' => 'number',
26
- 'name' => 'fields['.$name.'][images_limit]',
27
- 'value' => $value['images_limit']
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  ));
1
+ <?php
2
+ /*
3
+ * acf_render_field_setting
4
+ *
5
+ * This function will create a setting for your field. Simply pass the $field parameter and an array of field settings.
6
+ * The array of settings does not require a `value` or `prefix`; These settings are found from the $field array.
7
+ *
8
+ * More than one setting can be added by copy/paste the above code.
9
+ * Please note that you must also have a matching $defaults value for the field name (font_size)
10
+ */
11
+
12
+ $name = $field['name'];
13
+ $value = $field['fields['.$name];
14
+
15
+ acf_render_field_setting( $field, array(
16
+ 'label' => __('Edit modal','TEXTDOMAIN'),
17
+ 'type' => 'select',
18
+ 'name' => 'fields['.$name.'][edit_modal]',
19
+ 'value' => $value['edit_modal'],
20
+ 'choices' => array('Default' => 'Default', 'Native' => 'Native')
21
+ ));
22
+
23
+ acf_render_field_setting( $field, array(
24
+ 'label' => __('Images Limit','TEXTDOMAIN'),
25
+ 'type' => 'number',
26
+ 'name' => 'fields['.$name.'][images_limit]',
27
+ 'value' => $value['images_limit']
28
+ ));
29
+
30
+ acf_render_field_setting( $field, array(
31
+ 'label' => __('Remove edit button','TEXTDOMAIN'),
32
+ 'type' => 'select',
33
+ 'name' => 'fields['.$name.'][remove_edit_button]',
34
+ 'value' => $value['remove_edit_button'],
35
+ 'choices' => array('No' => 'No', 'Yes' => 'Yes')
36
+ ));
37
+
38
+ acf_render_field_setting( $field, array(
39
+ 'label' => __('Remove delete button','TEXTDOMAIN'),
40
+ 'type' => 'select',
41
+ 'name' => 'fields['.$name.'][remove_delete_button]',
42
+ 'value' => $value['remove_delete_button'],
43
+ 'choices' => array('No' => 'No', 'Yes' => 'Yes')
44
  ));
index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
lang/index.php CHANGED
@@ -1,2 +1,2 @@
1
- <?php
2
- // Silence is golden.
1
+ <?php
2
+ // Silence is golden.
navz-photo-gallery.php CHANGED
@@ -1,9 +1,10 @@
1
  <?php
 
2
  /*
3
  Plugin Name: ACF Photo Gallery Field
4
  Plugin URI: http://www.navz.me/
5
  Description: An extension for Advance Custom Fields which lets you add photo gallery functionality on your websites.
6
- Version: 1.6.9
7
  Author: Navneil Naicker
8
  Author URI: http://www.navz.me/
9
  License: GPLv2 or later
@@ -36,30 +37,28 @@ if( !class_exists('acf_plugin_photo_gallery') ) :
36
  */
37
 
38
  function __construct() {
39
-
40
- // vars
41
  $this->settings = array(
42
- 'version' => '1.6.9',
43
  'url' => plugin_dir_url( __FILE__ ),
44
  'path' => plugin_dir_path( __FILE__ )
45
  );
46
-
47
- // set text domain
48
- // https://codex.wordpress.org/Function_Reference/load_plugin_textdomain
49
  load_plugin_textdomain( 'acf-photo_gallery', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' );
50
-
51
  add_action( 'admin_enqueue_scripts', array($this, 'acf_photo_gallery_sortable') );
52
-
53
- // include field
54
  add_action('acf/include_field_types', array($this, 'include_field_types')); // v5
55
  add_action('acf/register_fields', array($this, 'include_field_types')); // v4
56
-
57
- //Pull the caption from attachment caption field
58
  add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_false' );
59
-
60
- //Add support for REST API
61
  add_filter("rest_prepare_page", array($this, 'rest_prepare_post'), 10, 3);
 
 
62
 
 
 
 
 
 
 
 
 
63
  }
64
 
65
  //Add in jquery-ui-sortable script
@@ -133,53 +132,4 @@ require_once( dirname(__FILE__) . '/includes/acf_photo_gallery_resize_image.php'
133
  require_once( dirname(__FILE__) . '/includes/acf_photo_gallery_image_fields.php' );
134
 
135
  //Metabox for the photo edit
136
- require_once( dirname(__FILE__) . '/includes/acf_photo_gallery_edit.php' );
137
-
138
- add_action('admin_notices', 'acf_pgf_admin_notice');
139
- function acf_pgf_admin_notice(){
140
- if( get_option('acf-pgf-dnt-show-msg') == 'yes' ){ ?>
141
- <div class="notice notice-info is-dismissible">
142
- <p>ACF Photo Gallery Field is a free to use plugin. It would be nice you could donate $5.00 USD to help in future development of this plugin. To donate please
143
- <a href="http://shop.navz.me/donation"
144
- target="_blank"
145
- style="background:#E14D43;color:#fff;text-decoration: none;padding: 5px 12px;border-radius: 3px;margin-left: 5px;">Click here</a> |
146
- <a href="<?php echo admin_url('admin-ajax.php?action=acf_pgf_dnt_msg_never&nonce='.wp_create_nonce("navz-photo-gallery/navz-photo-gallery.php")); ?>"
147
- class="acf-pgf-dnt-msg-never">Don't show me again</a>
148
- </p>
149
- </div>
150
- <?php }
151
- }
152
-
153
- add_action('upgrader_process_complete', 'acf_pgf_upgrader_process_complete',10, 2);
154
- function acf_pgf_upgrader_process_complete($upgrader_object, $options){
155
- $current_plugin_path_name = 'navz-photo-gallery/navz-photo-gallery.php';
156
- if ($options['action'] == 'update' && $options['type'] == 'plugin'){
157
- foreach($options['plugins'] as $each_plugin){
158
- if ($each_plugin == $current_plugin_path_name){
159
- update_option('acf-pgf-dnt-show-msg', 'yes');
160
- }
161
- }
162
- }
163
- }
164
-
165
- add_action("wp_ajax_acf_pgf_dnt_msg_never", "acf_pgf_dnt_msg_never");
166
- function acf_pgf_dnt_msg_never(){
167
- update_option('acf-pgf-dnt-show-msg', 'no');
168
- wp_redirect($_SERVER['HTTP_REFERER']);
169
- die();
170
- }
171
-
172
- add_filter('cron_schedules', 'acf_pgf_schedules');
173
- function acf_pgf_schedules($schedules){
174
- $schedules['acf_pgf_cron_weekly'] = array('interval' => 604800, 'display' => 'Once Weekly');
175
- return $schedules;
176
- }
177
-
178
- if (!wp_next_scheduled('acf_pgf_cron_weekly')){
179
- wp_schedule_event(1481799444, 'acf_pgf_cron_weekly', 'acf_pgf_cron_weekly');
180
- }
181
-
182
- add_action('acf_pgf_cron_weekly', 'acf_pgf_cron_weekly_exec');
183
- function acf_pgf_cron_weekly_exec(){
184
- update_option('acf-pgf-dnt-show-msg', 'yes');
185
- }
1
  <?php
2
+
3
  /*
4
  Plugin Name: ACF Photo Gallery Field
5
  Plugin URI: http://www.navz.me/
6
  Description: An extension for Advance Custom Fields which lets you add photo gallery functionality on your websites.
7
+ Version: 1.7.6
8
  Author: Navneil Naicker
9
  Author URI: http://www.navz.me/
10
  License: GPLv2 or later
37
  */
38
 
39
  function __construct() {
 
 
40
  $this->settings = array(
41
+ 'version' => '1.7.6',
42
  'url' => plugin_dir_url( __FILE__ ),
43
  'path' => plugin_dir_path( __FILE__ )
44
  );
 
 
 
45
  load_plugin_textdomain( 'acf-photo_gallery', false, plugin_basename( dirname( __FILE__ ) ) . '/lang' );
 
46
  add_action( 'admin_enqueue_scripts', array($this, 'acf_photo_gallery_sortable') );
 
 
47
  add_action('acf/include_field_types', array($this, 'include_field_types')); // v5
48
  add_action('acf/register_fields', array($this, 'include_field_types')); // v4
 
 
49
  add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_false' );
 
 
50
  add_filter("rest_prepare_page", array($this, 'rest_prepare_post'), 10, 3);
51
+ add_action('elementor/dynamic_tags/register_tags', array($this, 'register_tags'));
52
+ }
53
 
54
+ function register_tags( $dynamic_tags ){
55
+ if (class_exists('ElementorPro\Modules\DynamicTags\Tags\Base\Data_Tag')) {
56
+ \Elementor\Plugin::$instance->dynamic_tags->register_group( 'acf-photo-gallery', [
57
+ 'title' => 'ACF'
58
+ ]);
59
+ include(__DIR__ . '/includes/elementor_register_tag.php');
60
+ $dynamic_tags->register_tag( 'register_tag' );
61
+ }
62
  }
63
 
64
  //Add in jquery-ui-sortable script
132
  require_once( dirname(__FILE__) . '/includes/acf_photo_gallery_image_fields.php' );
133
 
134
  //Metabox for the photo edit
135
+ require_once( dirname(__FILE__) . '/includes/acf_photo_gallery_edit.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.txt CHANGED
@@ -1,199 +1,220 @@
1
- === ACF Photo Gallery Field ===
2
- Contributors: navzme
3
- Tags: acf, advanced, custom, fields, photo, gallery, album, fancybox, litebox, lightbox
4
- Requires at least: 3.8
5
- Tested up to: 5.7.2
6
- Stable tag: 1.6.9
7
- License: GPLv2 or later
8
- License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
-
10
- A lightweight extension of Advanced Custom Field (ACF) that adds Photo Gallery field to any post/pages on your WordPress website.
11
-
12
- == Description ==
13
-
14
- A lightweight extension of Advanced Custom Field (ACF) that adds **Photo Gallery** field to any post/pages on your WordPress website.
15
-
16
- * Visually create your Fields
17
- * Add multiple photos and you can also modify title, caption and link to anything
18
- * Assign your fields to multiple edit pages (via custom location rules)
19
- * Easily load data through a simple and friendly API
20
- * Uses the native WordPress custom post type for ease of use and fast processing
21
- * Uses the native WordPress metadata for ease of use and fast processing
22
-
23
- = Note =
24
- This plugin is alternative of ACF Gallery Pro. You need to have knowledge of coding because you’ll be required to edit your WordPress theme source code. If you are looking for shortcodes and prebuilt gallery then this plugin is **NOT** for you. This plugin will give you PHP array of images and you’ll need to make the gallery layout as you wish.
25
-
26
- = Usage =
27
- *acf_photo_gallery* is a helper function that takes in **ACF_FIELD_NAME** and **POST_ID** will query the database and compile the images for you. The output of this function will be an array.
28
-
29
- `acf_photo_gallery(ACF_FIELD_NAME, POST_ID);`
30
-
31
- = Example =
32
- The following example is using Twitter Bootstrap framework to layout. You can use any framework of your choice.
33
-
34
- `<?php
35
- //Get the images ids from the post_metadata
36
- $images = acf_photo_gallery('vacation_photos', $post->ID);
37
- //Check if return array has anything in it
38
- if( count($images) ):
39
- //Cool, we got some data so now let's loop over it
40
- foreach($images as $image):
41
- $id = $image['id']; // The attachment id of the media
42
- $title = $image['title']; //The title
43
- $caption= $image['caption']; //The caption
44
- $full_image_url= $image['full_image_url']; //Full size image url
45
- $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
46
- $thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px
47
- $url= $image['url']; //Goto any link when clicked
48
- $target= $image['target']; //Open normal or new tab
49
- $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
50
- $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
51
- ?>
52
- <div class="col-xs-6 col-md-3">
53
- <div class="thumbnail">
54
- <?php if( !empty($url) ){ ?><a href="<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
55
- <img src="<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
56
- <?php if( !empty($url) ){ ?></a><?php } ?>
57
- </div>
58
- </div>
59
- <?php endforeach; endif; ?>`
60
-
61
- = Add Extra Fields =
62
- To add extra fields add the following to your themes functions.php file.
63
-
64
- `//Create extra fields called Altnative Text and Status
65
- function my_extra_gallery_fields( $args, $attachment_id, $field ){
66
- $args['alt'] = array(
67
- 'type' => 'text',
68
- 'label' => 'Altnative Text',
69
- 'name' => 'alt',
70
- 'value' => get_field($field . '_alt', $attachment_id)
71
- );
72
- $args['status'] = array(
73
- 'type' => 'select',
74
- 'label' => 'Status',
75
- 'name' => 'status',
76
- 'value' => array(
77
- array(
78
- '1' => 'Active',
79
- '2' => 'Inactive'
80
- ),
81
- get_field($field . '_status', $attachment_id)
82
- )
83
- );
84
- return $args;
85
- }
86
- add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );`
87
-
88
- Supported field types:
89
- * text, date, color, datetime-local, email, number, tel, time, url, week, range, checkbox, radio, textarea, select
90
-
91
- = How to get values of extra fields =
92
- You can use ACF helper function `get_field`
93
-
94
- `get_field('photo_gallery_alt', $id);`
95
- `get_field('photo_gallery_class', $id);`
96
-
97
- = Pull caption from attachment caption field =
98
- By default the caption is being pulled from description field. Add the following filter to your `function.php` to pull the caption from attachment caption field.
99
-
100
- `add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_true' );`
101
-
102
- = REST API =
103
- Send HTTP Request to URL to get JSON response of all posts
104
-
105
- `http://{domain}/wp-json/wp/v2/{POST_TYPE}/`
106
-
107
- Send HTTP Request to URL to get JSON response of specific post
108
-
109
- `http://{domain}/wp-json/wp/v2/{POST_TYPE}/{POST_ID}/`
110
-
111
- When you receive the response, see the ACF item which contains ACF photo gallery name and array of images.
112
-
113
- = Compatibility =
114
- This ACF field type is compatible with:
115
- * ACF 4
116
- * ACF 5
117
-
118
- = Issues =
119
- Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website <http://www.navz.me/>
120
-
121
- == Installation ==
122
-
123
- 1. Copy the `navz-photo-gallery` folder into your `wp-content/plugins` folder
124
- 2. Activate the Advanced Custom Fields: Photo Gallery plugin via the plugins admin page
125
- 3. Create a new field via ACF and select the Photo Gallery type
126
- 4. Please refer to the description for more info regarding the field type settings
127
-
128
- == Changelog ==
129
- =1.6.9=
130
- * [Added] Support for WordPress 5.7.2
131
- * [Added] Donation message
132
-
133
- =1.6.8=
134
- * [Bugfix] Make gallery images limit optional
135
-
136
- =1.6.7=
137
- * [Removed] Support to ACF get_field() function due to bug
138
-
139
- =1.6.6=
140
- * [Add] Added support to ACF get_field() function
141
- * [Add] Added more fields types to extra fields
142
- * [Add] Added in SweetAlert and images limit options
143
- * [Add] Added message that ACF Photo Gallery isn't supported on taxonomy
144
-
145
- =1.6.5=
146
- * [Bugfix] Remove not empty condition from checkbox item on edit
147
- * [Remove] Remove support for ACF to REST API plugin
148
- * [Add] Native support for REST API
149
-
150
- =1.6.4=
151
- * [Bugfix] JavaScript error in the console when removing images from the WordPress metabox
152
-
153
- =1.6.3=
154
- * [Added] Support for ACF 5
155
- * [Added] Edit gallery with built-in or WordPress native model. Thanks to Github @makepost
156
- * [Added] Under the hood improvements of the codebase
157
- * [Added] Support for RESTFul API with ACF to REST API plugin
158
-
159
- =1.6.2=
160
- * [Bugfix] Keep data synced with the attachment data
161
- * [Bugfix] Pull caption attachment caption using add filters
162
- * [Bugfix] PHP 7.2 count() error
163
-
164
- =1.6.1=
165
- * [Bugfix] Edit image box disappears on click of pencil edit button reported by @rickytoof9
166
-
167
- =1.6.0=
168
- * [Bugfix] Error on saving post with empty gallery. Patch provided by @ugy
169
- * [Bugfix] Showing multiple photo gallery fields in the same page reported by @rickytoof9
170
- * [Added] Support for srcset. Special thanks to @ugy for the code
171
-
172
- = 1.5.0 =
173
- * [Added] Support for SVG
174
- * [Added] Support for legacy PHP version
175
- * [Added] Add extra fields
176
-
177
- = 1.4.0 =
178
- * [Added] Can sortable gallery images
179
- * [Bugfix] Fixed the order to follow the sort order for gallery images
180
-
181
- = 1.3.0 =
182
- * Change the meta_key from acf field_key to acf field_name
183
- * [Added] Helper function acf_photo_gallery() to pull images
184
- * [Added] Helper function acf_photo_gallery_resize_image to resize the image on fly and save it
185
- * [Bugfix] Issue with target parameter in config
186
- * [Bugfix] Issue with url not saving properly
187
-
188
- = 1.2.0 =
189
- * [Bugfix] Support for WordPress 4.6
190
- * [Added] Some changes on on the display
191
- * [Added] Fetch the data from the database
192
-
193
- = 1.1.0 =
194
- * [Bugfix] Undefined index: acf-photo-gallery-field on file acf-photo_gallery-v4
195
- * [Bugfix] When delete the photos from the gallery, the last photo was not deleting
196
- * [Bugfix] Gallery photos was not saving in the database
197
-
198
- = 1.0.0 =
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
199
  * Initial Release.
1
+ === ACF Photo Gallery Field ===
2
+ Contributors: navzme
3
+ Tags: acf, advanced, custom, fields, photo, gallery, album, fancybox, litebox, lightbox
4
+ Requires at least: 4.7.0
5
+ Tested up to: 5.8.1
6
+ Stable tag: 1.7.6
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ A lightweight extension of Advanced Custom Field (ACF) that adds Photo Gallery field to any post/pages on your WordPress website.
11
+
12
+ == Description ==
13
+
14
+ A lightweight extension of Advanced Custom Field (ACF) that adds **Photo Gallery** field to any post/pages on your WordPress website.
15
+
16
+ * Visually create your Fields
17
+ * Add multiple photos and you can also modify title, caption and link to anything
18
+ * Assign your fields to multiple edit pages (via custom location rules)
19
+ * Easily load data through a simple and friendly API
20
+ * Uses the native WordPress custom post type for ease of use and fast processing
21
+ * Uses the native WordPress metadata for ease of use and fast processing
22
+ * Supports Elementor
23
+ * RESTFul API
24
+
25
+ = Note =
26
+ This plugin is alternative of ACF Gallery Pro. You need to have knowledge of coding because you’ll be required to edit your WordPress theme source code. If you are looking for shortcodes and prebuilt gallery then this plugin is **NOT** for you. This plugin will give you PHP array of images and you’ll need to make the gallery layout as you wish.
27
+
28
+ = Usage =
29
+ *acf_photo_gallery* is a helper function that takes in **ACF_FIELD_NAME** and **POST_ID** will query the database and compile the images for you. The output of this function will be an array.
30
+
31
+ `acf_photo_gallery(ACF_FIELD_NAME, POST_ID);`
32
+
33
+ = Example =
34
+ The following example is using Twitter Bootstrap framework to layout. You can use any framework of your choice.
35
+
36
+ `<?php
37
+ //Get the images ids from the post_metadata
38
+ $images = acf_photo_gallery('vacation_photos', $post->ID);
39
+ //Check if return array has anything in it
40
+ if( count($images) ):
41
+ //Cool, we got some data so now let's loop over it
42
+ foreach($images as $image):
43
+ $id = $image['id']; // The attachment id of the media
44
+ $title = $image['title']; //The title
45
+ $caption= $image['caption']; //The caption
46
+ $full_image_url= $image['full_image_url']; //Full size image url
47
+ $full_image_url = acf_photo_gallery_resize_image($full_image_url, 262, 160); //Resized size to 262px width by 160px height image url
48
+ $thumbnail_image_url= $image['thumbnail_image_url']; //Get the thumbnail size image url 150px by 150px
49
+ $url= $image['url']; //Goto any link when clicked
50
+ $target= $image['target']; //Open normal or new tab
51
+ $alt = get_field('photo_gallery_alt', $id); //Get the alt which is a extra field (See below how to add extra fields)
52
+ $class = get_field('photo_gallery_class', $id); //Get the class which is a extra field (See below how to add extra fields)
53
+ ?>
54
+ <div class="col-xs-6 col-md-3">
55
+ <div class="thumbnail">
56
+ <?php if( !empty($url) ){ ?><a href="<?php echo $url; ?>" <?php echo ($target == 'true' )? 'target="_blank"': ''; ?>><?php } ?>
57
+ <img src="<?php echo $full_image_url; ?>" alt="<?php echo $title; ?>" title="<?php echo $title; ?>">
58
+ <?php if( !empty($url) ){ ?></a><?php } ?>
59
+ </div>
60
+ </div>
61
+ <?php endforeach; endif; ?>`
62
+
63
+ = Add Extra Fields =
64
+ To add extra fields add the following to your themes functions.php file.
65
+
66
+ `//Create extra fields called Altnative Text and Status
67
+ function my_extra_gallery_fields( $args, $attachment_id, $field ){
68
+ $args['alt'] = array(
69
+ 'type' => 'text',
70
+ 'label' => 'Altnative Text',
71
+ 'name' => 'alt',
72
+ 'value' => get_field($field . '_alt', $attachment_id)
73
+ );
74
+ $args['status'] = array(
75
+ 'type' => 'select',
76
+ 'label' => 'Status',
77
+ 'name' => 'status',
78
+ 'value' => array(
79
+ array(
80
+ '1' => 'Active',
81
+ '2' => 'Inactive'
82
+ ),
83
+ get_field($field . '_status', $attachment_id)
84
+ )
85
+ );
86
+ return $args;
87
+ }
88
+ add_filter( 'acf_photo_gallery_image_fields', 'my_extra_gallery_fields', 10, 3 );`
89
+
90
+ Supported field types:
91
+ * text, date, color, datetime-local, email, number, tel, time, url, week, range, checkbox, radio, textarea, select
92
+
93
+ = How to get values of extra fields =
94
+ You can use ACF helper function `get_field`
95
+
96
+ `get_field('photo_gallery_alt', $id);`
97
+ `get_field('photo_gallery_class', $id);`
98
+
99
+ = Pull caption from attachment caption field =
100
+ By default the caption is being pulled from description field. Add the following filter to your `function.php` to pull the caption from attachment caption field.
101
+
102
+ `add_filter( 'acf_photo_gallery_caption_from_attachment', '__return_true' );`
103
+
104
+ = REST API =
105
+ Send HTTP Request to URL to get JSON response of all posts
106
+
107
+ `http://{domain}/wp-json/wp/v2/{POST_TYPE}/`
108
+
109
+ Send HTTP Request to URL to get JSON response of specific post
110
+
111
+ `http://{domain}/wp-json/wp/v2/{POST_TYPE}/{POST_ID}/`
112
+
113
+ When you receive the response, see the ACF item which contains ACF photo gallery name and array of images.
114
+
115
+ = Compatibility =
116
+ This ACF field type is compatible with:
117
+ * ACF 4
118
+ * ACF 5
119
+
120
+ = Issues =
121
+ Just like any other WordPress plugin, this plugin can also cause issues with other themes and plugins. If you are facing issues making this plugin work on your WordPress site, please do ask for help in the support forum. This way we can help you out and prevent this issue from happening to someone else. If you want to talk to me directly, you can contact me via my website <http://www.navz.me/>
122
+
123
+ == Installation ==
124
+
125
+ 1. Copy the `navz-photo-gallery` folder into your `wp-content/plugins` folder
126
+ 2. Activate the Advanced Custom Fields: Photo Gallery plugin via the plugins admin page
127
+ 3. Create a new field via ACF and select the Photo Gallery type
128
+ 4. Please refer to the description for more info regarding the field type settings
129
+
130
+ == Changelog ==
131
+ =1.7.6=
132
+ * [Bugfix] Sanitizing and escaping inputs
133
+
134
+ =1.7.5=
135
+ * [Bugfix] Security issue and reset body overflow
136
+
137
+ =1.7.4=
138
+ * [Bugfix] Security issue
139
+
140
+ =1.7.3=
141
+ * [Bugfix] Remove edit and delete image button conditions
142
+
143
+ =1.7.2=
144
+ * [Bugfix] Illegal string offset error
145
+
146
+ =1.7.1=
147
+ * [Bugfix] ElementorPro class not found
148
+ * [Bugfix] Warning: Undefined array key "acf-photo-gallery-field"
149
+
150
+ =1.7.0=
151
+ * [Add] Option for to show/hide edit and remove button
152
+ * [Add] Support for Elementor
153
+
154
+ =1.6.8=
155
+ * [Bugfix] Make gallery images limit optional
156
+
157
+ =1.6.7=
158
+ * [Removed] Support to ACF get_field() function due to bug
159
+
160
+ =1.6.6=
161
+ * [Add] Added support to ACF get_field() function
162
+ * [Add] Added more fields types to extra fields
163
+ * [Add] Added in SweetAlert and images limit options
164
+ * [Add] Added message that ACF Photo Gallery isn't supported on taxonomy
165
+
166
+ =1.6.5=
167
+ * [Bugfix] Remove not empty condition from checkbox item on edit
168
+ * [Remove] Remove support for ACF to REST API plugin
169
+ * [Add] Native support for REST API
170
+
171
+ =1.6.4=
172
+ * [Bugfix] JavaScript error in the console when removing images from the WordPress metabox
173
+
174
+ =1.6.3=
175
+ * [Added] Support for ACF 5
176
+ * [Added] Edit gallery with built-in or WordPress native model. Thanks to Github @makepost
177
+ * [Added] Under the hood improvements of the codebase
178
+ * [Added] Support for RESTFul API with ACF to REST API plugin
179
+
180
+ =1.6.2=
181
+ * [Bugfix] Keep data synced with the attachment data
182
+ * [Bugfix] Pull caption attachment caption using add filters
183
+ * [Bugfix] PHP 7.2 count() error
184
+
185
+ =1.6.1=
186
+ * [Bugfix] Edit image box disappears on click of pencil edit button reported by @rickytoof9
187
+
188
+ =1.6.0=
189
+ * [Bugfix] Error on saving post with empty gallery. Patch provided by @ugy
190
+ * [Bugfix] Showing multiple photo gallery fields in the same page reported by @rickytoof9
191
+ * [Added] Support for srcset. Special thanks to @ugy for the code
192
+
193
+ = 1.5.0 =
194
+ * [Added] Support for SVG
195
+ * [Added] Support for legacy PHP version
196
+ * [Added] Add extra fields
197
+
198
+ = 1.4.0 =
199
+ * [Added] Can sortable gallery images
200
+ * [Bugfix] Fixed the order to follow the sort order for gallery images
201
+
202
+ = 1.3.0 =
203
+ * Change the meta_key from acf field_key to acf field_name
204
+ * [Added] Helper function acf_photo_gallery() to pull images
205
+ * [Added] Helper function acf_photo_gallery_resize_image to resize the image on fly and save it
206
+ * [Bugfix] Issue with target parameter in config
207
+ * [Bugfix] Issue with url not saving properly
208
+
209
+ = 1.2.0 =
210
+ * [Bugfix] Support for WordPress 4.6
211
+ * [Added] Some changes on on the display
212
+ * [Added] Fetch the data from the database
213
+
214
+ = 1.1.0 =
215
+ * [Bugfix] Undefined index: acf-photo-gallery-field on file acf-photo_gallery-v4
216
+ * [Bugfix] When delete the photos from the gallery, the last photo was not deleting
217
+ * [Bugfix] Gallery photos was not saving in the database
218
+
219
+ = 1.0.0 =
220
  * Initial Release.