Version Description
- Major update - compatible with WP 5.7.x
- Feature: Compatible with Custom Post Types
- Feature: Copy custom fields (post-metadata)
- Feature: Add settings page with options
Download this release
Release Info
Developer | pattihis |
Plugin | Clone Posts |
Version | 2.0.0 |
Comparing to | |
See all releases |
Version 2.0.0
- LICENSE.txt +339 -0
- README.txt +70 -0
- admin/class-clone-posts-admin.php +479 -0
- admin/css/clone-posts-admin.css +4 -0
- admin/index.php +1 -0
- admin/js/clone-posts-admin.js +32 -0
- admin/partials/clone-posts-admin-display.php +28 -0
- clone-posts.php +112 -0
- includes/class-clone-posts-activator.php +40 -0
- includes/class-clone-posts-deactivator.php +36 -0
- includes/class-clone-posts-i18n.php +47 -0
- includes/class-clone-posts-loader.php +129 -0
- includes/class-clone-posts.php +227 -0
- includes/index.php +1 -0
- index.php +1 -0
- languages/clone-posts.pot +0 -0
- public/class-clone-posts-public.php +79 -0
- public/css/clone-posts-public.css +4 -0
- public/index.php +1 -0
- public/js/clone-posts-public.js +32 -0
- public/partials/clone-posts-public-display.php +16 -0
- uninstall.php +45 -0
LICENSE.txt
ADDED
@@ -0,0 +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.
|
README.txt
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Clone Posts ===
|
2 |
+
Contributors: lukaszwebmaster, pattihis
|
3 |
+
Donate link: https://profiles.wordpress.org/pattihis/
|
4 |
+
Tags: clone posts, clone pages, clone post, clone page, clone, page cloning, post cloning, posts cloning, pages cloning, page copy, page copy paste, post copy, posts copy paste, copy pages, copy posts, copy and paste posts, copy and paste pages, clone, cloning, copy and paste
|
5 |
+
Requires at least: 3.0.1
|
6 |
+
Tested up to: 5.7
|
7 |
+
Requires PHP: 5.6
|
8 |
+
Stable tag: 2.0.0
|
9 |
+
License: GPL2
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
+
|
12 |
+
Easily clone (duplicate) Posts, Pages and Custom Post Types, including their custom fields (post_meta)
|
13 |
+
|
14 |
+
== Description ==
|
15 |
+
|
16 |
+
This is a simple plugin that allows you to clone (duplicate) posts, pages and custom post types in WordPress.
|
17 |
+
|
18 |
+
### Features
|
19 |
+
|
20 |
+
* Enable clone feature for Posts, Pages or any Custom Post Type (CPT)
|
21 |
+
* Clone single Posts/Pages with one click
|
22 |
+
* Clone multiple Posts/pages with Bulk feature
|
23 |
+
* Set default Status & Date of cloned Posts/Pages
|
24 |
+
* Custom fields (post-metadata) are also copied when duplicating a Post
|
25 |
+
* Translations ready
|
26 |
+
* Free with lifetime updates
|
27 |
+
* Build according to best practices and WordPress coding standards
|
28 |
+
|
29 |
+
[Changelog](http://wordpress.org/extend/plugins/clone-posts/changelog/)
|
30 |
+
|
31 |
+
*Clone Posts* was originally developed by [Lukasz Kostrzewa](https://profiles.wordpress.org/lukaszwebmaster/). The plugin has been adopted and updated by [George Pattihis](https://profiles.wordpress.org/pattihis/) who will continue development.
|
32 |
+
|
33 |
+
== Installation ==
|
34 |
+
|
35 |
+
1. In your WordPress admin panel, go to Plugins > New Plugin, search for "Clone Posts" and click "Install now"
|
36 |
+
2. Alternatively, download the plugin and upload the contents of clone-posts.zip to your plugins directory, which usually is /wp-content/plugins/
|
37 |
+
3. Activate the plugin
|
38 |
+
4. Go to "Clone Posts" page under your Settings menu
|
39 |
+
5. Configure the plugin options with available settings
|
40 |
+
|
41 |
+
== Frequently Asked Questions ==
|
42 |
+
|
43 |
+
= When is "Clone Posts" needed? =
|
44 |
+
|
45 |
+
Whenever you want to copy all contents of a post, page or CPT then you can do that with 1-click when you have this plugin installed. You can even clone multiple posts at once using the Bulk action!
|
46 |
+
|
47 |
+
= Does it require manual coding or file editing? =
|
48 |
+
|
49 |
+
Absolutely not. No technical knowledge is needed and with just one click you can duplicate any post, page or custom post type! Check out the screenshots above.
|
50 |
+
|
51 |
+
= Is "Clone Posts" compatible with my theme/plugins? =
|
52 |
+
|
53 |
+
Of course! "Clone Posts" is compatible with any theme and plugin that follows WordPress coding standards.
|
54 |
+
|
55 |
+
== Screenshots ==
|
56 |
+
|
57 |
+
1. Settings page
|
58 |
+
2. Clone single post
|
59 |
+
3. Clone multiple posts
|
60 |
+
|
61 |
+
== Changelog ==
|
62 |
+
|
63 |
+
= 2.0.0 =
|
64 |
+
* Major update - compatible with WP 5.7.x
|
65 |
+
* Feature: Compatible with Custom Post Types
|
66 |
+
* Feature: Copy custom fields (post-metadata)
|
67 |
+
* Feature: Add settings page with options
|
68 |
+
|
69 |
+
= 1.0.0 =
|
70 |
+
* Initial version
|
admin/class-clone-posts-admin.php
ADDED
@@ -0,0 +1,479 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The admin-specific functionality of the plugin.
|
5 |
+
*
|
6 |
+
* @link https://profiles.wordpress.org/pattihis/
|
7 |
+
* @since 2.0.0
|
8 |
+
*
|
9 |
+
* @package Clone_Posts
|
10 |
+
* @subpackage Clone_Posts/admin
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The admin-specific functionality of the plugin.
|
15 |
+
*
|
16 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
+
* enqueue the admin-specific stylesheet and JavaScript.
|
18 |
+
*
|
19 |
+
* @package Clone_Posts
|
20 |
+
* @subpackage Clone_Posts/admin
|
21 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
22 |
+
*/
|
23 |
+
class Clone_Posts_Admin {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* The ID of this plugin.
|
27 |
+
*
|
28 |
+
* @since 2.0.0
|
29 |
+
* @access private
|
30 |
+
* @var string $plugin_name The ID of this plugin.
|
31 |
+
*/
|
32 |
+
private $plugin_name;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The version of this plugin.
|
36 |
+
*
|
37 |
+
* @since 2.0.0
|
38 |
+
* @access private
|
39 |
+
* @var string $version The current version of this plugin.
|
40 |
+
*/
|
41 |
+
private $version;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Initialize the class and set its properties.
|
45 |
+
*
|
46 |
+
* @since 2.0.0
|
47 |
+
* @param string $plugin_name The name of this plugin.
|
48 |
+
* @param string $version The version of this plugin.
|
49 |
+
*/
|
50 |
+
public function __construct( $plugin_name, $version ) {
|
51 |
+
|
52 |
+
$this->plugin_name = $plugin_name;
|
53 |
+
$this->version = $version;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Register the stylesheets for the admin area.
|
59 |
+
*
|
60 |
+
* @since 2.0.0
|
61 |
+
*/
|
62 |
+
public function enqueue_styles() {
|
63 |
+
|
64 |
+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/clone-posts-admin.css', array(), $this->version, 'all' );
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Register the JavaScript for the admin area.
|
70 |
+
*
|
71 |
+
* @since 2.0.0
|
72 |
+
*/
|
73 |
+
public function enqueue_scripts() {
|
74 |
+
|
75 |
+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/clone-posts-admin.js', array( 'jquery' ), $this->version, false );
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* Register the admin settings page
|
81 |
+
*
|
82 |
+
* @since 2.0.0
|
83 |
+
*/
|
84 |
+
public function clonePosts_admin_page() {
|
85 |
+
|
86 |
+
add_options_page(
|
87 |
+
'Clone Posts Settings',
|
88 |
+
'Clone Posts',
|
89 |
+
'manage_options',
|
90 |
+
'clone-posts-options',
|
91 |
+
[$this,'clonePosts_admin_display'],
|
92 |
+
null
|
93 |
+
);
|
94 |
+
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Render the settings page content
|
99 |
+
*
|
100 |
+
* @since 2.0.0
|
101 |
+
*/
|
102 |
+
public function clonePosts_admin_display() {
|
103 |
+
include_once 'partials/clone-posts-admin-display.php';
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Register the actual settings
|
108 |
+
*
|
109 |
+
* @since 2.0.0
|
110 |
+
*/
|
111 |
+
public function clonePosts_register_setting() {
|
112 |
+
|
113 |
+
add_settings_section(
|
114 |
+
'clone_posts_settings_section',
|
115 |
+
'',
|
116 |
+
'',
|
117 |
+
'clone-posts-options'
|
118 |
+
);
|
119 |
+
|
120 |
+
register_setting(
|
121 |
+
'clone_post_settings',
|
122 |
+
'clone_posts_post_status',
|
123 |
+
'sanitize_text_field'
|
124 |
+
);
|
125 |
+
|
126 |
+
add_settings_field(
|
127 |
+
'clone_posts_post_status',
|
128 |
+
'Post Status',
|
129 |
+
[$this,'clonePosts_option_post_status'],
|
130 |
+
'clone-posts-options',
|
131 |
+
'clone_posts_settings_section',
|
132 |
+
array(
|
133 |
+
'label_for' => 'clone_posts_post_status',
|
134 |
+
'class' => 'clone-posts',
|
135 |
+
)
|
136 |
+
);
|
137 |
+
|
138 |
+
register_setting(
|
139 |
+
'clone_post_settings',
|
140 |
+
'clone_posts_post_date',
|
141 |
+
'sanitize_text_field'
|
142 |
+
);
|
143 |
+
|
144 |
+
add_settings_field(
|
145 |
+
'clone_posts_post_date',
|
146 |
+
'Post Date',
|
147 |
+
[$this,'clonePosts_option_post_date'],
|
148 |
+
'clone-posts-options',
|
149 |
+
'clone_posts_settings_section',
|
150 |
+
array(
|
151 |
+
'label_for' => 'clone_posts_post_date',
|
152 |
+
'class' => 'clone-posts',
|
153 |
+
)
|
154 |
+
);
|
155 |
+
|
156 |
+
register_setting(
|
157 |
+
'clone_post_settings',
|
158 |
+
'clone_posts_post_type',
|
159 |
+
[$this,'clonePosts_sanitize_array'],
|
160 |
+
);
|
161 |
+
|
162 |
+
add_settings_field(
|
163 |
+
'clone_posts_post_type',
|
164 |
+
'Post Type',
|
165 |
+
[$this,'clonePosts_option_post_type'],
|
166 |
+
'clone-posts-options',
|
167 |
+
'clone_posts_settings_section',
|
168 |
+
array(
|
169 |
+
'label_for' => 'clone_posts_post_type',
|
170 |
+
'class' => 'clone-posts',
|
171 |
+
)
|
172 |
+
);
|
173 |
+
|
174 |
+
}
|
175 |
+
|
176 |
+
/**
|
177 |
+
* Field for Post Status option
|
178 |
+
*
|
179 |
+
* @since 2.0.0
|
180 |
+
*/
|
181 |
+
public function clonePosts_option_post_status() {
|
182 |
+
$option = get_option('clone_posts_post_status');
|
183 |
+
?>
|
184 |
+
<select name="clone_posts_post_status" id="clone_posts_post_status">
|
185 |
+
<option value="draft" <?php selected($option, 'draft'); ?>>Draft</option>
|
186 |
+
<option value="publish" <?php selected($option, 'publish'); ?>>Publish</option>
|
187 |
+
<option value="private" <?php selected($option, 'private'); ?>>Private</option>
|
188 |
+
<option value="pending" <?php selected($option, 'pending'); ?>>Pending</option>
|
189 |
+
</select>
|
190 |
+
<p>Select the <a href="https://wordpress.org/support/article/post-status/#default-statuses" target="_blank">status</a> of the cloned post</p>
|
191 |
+
<?php
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Field for Post Date option
|
196 |
+
*
|
197 |
+
* @since 2.0.0
|
198 |
+
*/
|
199 |
+
public function clonePosts_option_post_date() {
|
200 |
+
$option = get_option('clone_posts_post_date');
|
201 |
+
?>
|
202 |
+
<select name="clone_posts_post_date" id="clone_posts_post_date">
|
203 |
+
<option value="current" <?php selected($option, 'current'); ?>>Current Date/Time</option>
|
204 |
+
<option value="original" <?php selected($option, 'original'); ?>>Original Post Date</option>
|
205 |
+
</select>
|
206 |
+
<p>Select if the cloned post will have the same date as the<br>original or if it will be assigned the current date/time</p>
|
207 |
+
<?php
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Field for Post Type option
|
212 |
+
*
|
213 |
+
* @since 2.0.0
|
214 |
+
*/
|
215 |
+
public function clonePosts_option_post_type() {
|
216 |
+
$options = maybe_unserialize( get_option('clone_posts_post_type') );
|
217 |
+
$exclude_cpt = ['attachment'];
|
218 |
+
$post_types = get_post_types( array( 'public' => true, ), 'objects', 'and' );
|
219 |
+
echo '<fieldset>';
|
220 |
+
if ( $post_types ) {
|
221 |
+
foreach ( $post_types as $post_type ) {
|
222 |
+
if ( !in_array($post_type->name, $exclude_cpt) ) {
|
223 |
+
?>
|
224 |
+
<div>
|
225 |
+
<input type="checkbox" name="clone_posts_post_type[]" value="<?php echo $post_type->name ?>" id="post_type_<?php echo $post_type->name ?>" <?php checked( in_array( $post_type->name, $options ), 1 ); ?>>
|
226 |
+
<label for="post_type_<?php echo $post_type->name; ?>"><?php echo $post_type->labels->name; ?></label>
|
227 |
+
</div>
|
228 |
+
<?php
|
229 |
+
}
|
230 |
+
}
|
231 |
+
}
|
232 |
+
echo '<p>Enable Clone functionality on the selected Post Types</p></fieldset>';
|
233 |
+
}
|
234 |
+
|
235 |
+
/**
|
236 |
+
* A custom sanitization function for arrays.
|
237 |
+
*
|
238 |
+
* @since 2.0.0
|
239 |
+
* @param array $input The posted array.
|
240 |
+
* @return array $output The array sanitized.
|
241 |
+
*/
|
242 |
+
public function clonePosts_sanitize_array( $input ) {
|
243 |
+
$output = array();
|
244 |
+
foreach ( $input as $key => $val ) {
|
245 |
+
$output[ $key ] = ( isset( $input[ $key ] ) ) ? sanitize_text_field( $val ) : '';
|
246 |
+
}
|
247 |
+
return $output;
|
248 |
+
}
|
249 |
+
|
250 |
+
/**
|
251 |
+
* Add the custom Bulk Action to the select menus
|
252 |
+
*
|
253 |
+
* @since 2.0.0
|
254 |
+
*/
|
255 |
+
public function clonePosts_admin_footer() {
|
256 |
+
$options = maybe_unserialize( get_option('clone_posts_post_type') );
|
257 |
+
|
258 |
+
if ( !in_array( $GLOBALS['post_type'], $options ) ) {
|
259 |
+
return;
|
260 |
+
}
|
261 |
+
?>
|
262 |
+
<script type="text/javascript">
|
263 |
+
jQuery(function () {
|
264 |
+
jQuery('<option>').val('clone').text('<?php _e('Clone')?>').appendTo("select[name='action']");
|
265 |
+
jQuery('<option>').val('clone').text('<?php _e('Clone')?>').appendTo("select[name='action2']");
|
266 |
+
});
|
267 |
+
</script>
|
268 |
+
<?php
|
269 |
+
}
|
270 |
+
|
271 |
+
/**
|
272 |
+
* Handle the custom Bulk Action
|
273 |
+
*
|
274 |
+
* @since 2.0.0
|
275 |
+
*/
|
276 |
+
public function clonePosts_bulk_action() {
|
277 |
+
global $typenow;
|
278 |
+
$post_type = $typenow;
|
279 |
+
$plugin = new Clone_Posts;
|
280 |
+
|
281 |
+
// get the action
|
282 |
+
$wp_list_table = _get_list_table('WP_Posts_List_Table');
|
283 |
+
$action = $wp_list_table->current_action();
|
284 |
+
|
285 |
+
$allowed_actions = array("clone");
|
286 |
+
if ( ! in_array( $action, $allowed_actions )) {
|
287 |
+
return;
|
288 |
+
}
|
289 |
+
|
290 |
+
// security check
|
291 |
+
check_admin_referer('bulk-posts');
|
292 |
+
|
293 |
+
// make sure ids are submitted. depending on the resource type, this may be 'media' or 'ids'
|
294 |
+
if ( isset( $_REQUEST['post'] )) {
|
295 |
+
$post_ids = array_map( 'intval', $_REQUEST['post'] );
|
296 |
+
}
|
297 |
+
|
298 |
+
if ( empty( $post_ids )) {
|
299 |
+
return;
|
300 |
+
}
|
301 |
+
|
302 |
+
// this is based on wp-admin/edit.php
|
303 |
+
$sendback = remove_query_arg( array( 'cloned', 'untrashed', 'deleted', 'ids' ), wp_get_referer() );
|
304 |
+
if ( ! $sendback ) {
|
305 |
+
$sendback = admin_url( "edit.php?post_type=$post_type" );
|
306 |
+
}
|
307 |
+
|
308 |
+
$pagenum = $wp_list_table->get_pagenum();
|
309 |
+
$sendback = add_query_arg( 'paged', $pagenum, $sendback );
|
310 |
+
|
311 |
+
switch ( $action ) {
|
312 |
+
case 'clone':
|
313 |
+
|
314 |
+
$cloned = 0;
|
315 |
+
foreach ( $post_ids as $post_id ) {
|
316 |
+
|
317 |
+
if ( !current_user_can('edit_post', $post_id) ) {
|
318 |
+
wp_die( __('You are not allowed to clone this post.', $plugin->get_plugin_name) );
|
319 |
+
}
|
320 |
+
|
321 |
+
if ( ! $this->clonePosts_clone_single( $post_id )) {
|
322 |
+
wp_die( __('Error cloning post.', $plugin->get_plugin_name) );
|
323 |
+
}
|
324 |
+
|
325 |
+
$cloned++;
|
326 |
+
}
|
327 |
+
|
328 |
+
$sendback = add_query_arg( array( 'cloned' => $cloned, 'ids' => join(',', $post_ids) ), $sendback );
|
329 |
+
break;
|
330 |
+
|
331 |
+
default:
|
332 |
+
return;
|
333 |
+
}
|
334 |
+
|
335 |
+
$sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author',
|
336 |
+
'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
|
337 |
+
|
338 |
+
wp_redirect($sendback);
|
339 |
+
exit();
|
340 |
+
}
|
341 |
+
|
342 |
+
/**
|
343 |
+
* Display an admin notice on the Posts page after cloning
|
344 |
+
*
|
345 |
+
* @since 2.0.0
|
346 |
+
*/
|
347 |
+
function clonePosts_admin_notices() {
|
348 |
+
global $pagenow;
|
349 |
+
|
350 |
+
if ($pagenow == 'edit.php' && ! isset($_GET['trashed'] )) {
|
351 |
+
$cloned = 0;
|
352 |
+
if ( isset( $_REQUEST['cloned'] ) && (int) $_REQUEST['cloned'] ) {
|
353 |
+
$cloned = (int) $_REQUEST['cloned'];
|
354 |
+
} elseif ( isset($_GET['cloned']) && (int) $_GET['cloned'] ) {
|
355 |
+
$cloned = (int) $_GET['cloned'];
|
356 |
+
}
|
357 |
+
if ($cloned) {
|
358 |
+
$message = sprintf( _n( 'Post cloned.', '%s posts cloned.', $cloned ), number_format_i18n( $cloned ) );
|
359 |
+
echo "<div class=\"updated\"><p>{$message}</p></div>";
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
|
364 |
+
/**
|
365 |
+
* Filters the array of row action links on the admin table.
|
366 |
+
*
|
367 |
+
* @since 2.0.0
|
368 |
+
*/
|
369 |
+
public function clonePosts_post_row_actions( $actions, $post ) {
|
370 |
+
global $post_type;
|
371 |
+
$plugin = new Clone_Posts;
|
372 |
+
|
373 |
+
$options = maybe_unserialize( get_option('clone_posts_post_type') );
|
374 |
+
|
375 |
+
if ( !in_array( $post_type, $options ) ) {
|
376 |
+
return $actions;
|
377 |
+
}
|
378 |
+
|
379 |
+
$url = remove_query_arg( array( 'cloned', 'untrashed', 'deleted', 'ids' ), "" );
|
380 |
+
if ( ! $url ) {
|
381 |
+
$url = admin_url( "?post_type=$post_type" );
|
382 |
+
}
|
383 |
+
$url = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author',
|
384 |
+
'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $url );
|
385 |
+
$url = add_query_arg( array( 'action' => 'clone-single', 'post' => $post->ID, 'redirect' => $_SERVER['REQUEST_URI'] ), $url );
|
386 |
+
|
387 |
+
$actions['clone'] = '<a href=\''.$url.'\'>'.__('Clone', $plugin->get_plugin_name).'</a>';
|
388 |
+
return $actions;
|
389 |
+
}
|
390 |
+
|
391 |
+
/**
|
392 |
+
* Fires before admin_init, clears query args and redirects
|
393 |
+
*
|
394 |
+
* @since 2.0.0
|
395 |
+
*/
|
396 |
+
public function clonePosts_wp_loaded() {
|
397 |
+
global $post_type;
|
398 |
+
$plugin = new Clone_Posts;
|
399 |
+
|
400 |
+
if ( ! isset($_GET['action']) || $_GET['action'] !== "clone-single") {
|
401 |
+
return;
|
402 |
+
}
|
403 |
+
|
404 |
+
$post_id = (int) $_GET['post'];
|
405 |
+
|
406 |
+
if ( !current_user_can('edit_post', $post_id )) {
|
407 |
+
wp_die( __('You are not allowed to clone this post.', $plugin->get_plugin_name) );
|
408 |
+
}
|
409 |
+
|
410 |
+
if ( !$this->clonePosts_clone_single( $post_id )) {
|
411 |
+
wp_die( __('Error cloning post.', $plugin->get_plugin_name) );
|
412 |
+
}
|
413 |
+
|
414 |
+
$sendback = remove_query_arg( array( 'cloned', 'untrashed', 'deleted', 'ids' ), $_GET['redirect'] );
|
415 |
+
if ( ! $sendback ) {
|
416 |
+
$sendback = admin_url( "edit.php?post_type=$post_type" );
|
417 |
+
}
|
418 |
+
|
419 |
+
$sendback = add_query_arg( array( 'cloned' => 1 ), $sendback );
|
420 |
+
$sendback = remove_query_arg( array( 'action', 'action2', 'tags_input', 'post_author', 'comment_status', 'ping_status', '_status', 'post', 'bulk_edit', 'post_view'), $sendback );
|
421 |
+
wp_redirect($sendback);
|
422 |
+
exit();
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* Clone the Post
|
427 |
+
*
|
428 |
+
* @since 2.0.0
|
429 |
+
*/
|
430 |
+
public function clonePosts_clone_single( $id ) {
|
431 |
+
$p = get_post( $id );
|
432 |
+
if ($p == null) return false;
|
433 |
+
$plugin = new Clone_Posts;
|
434 |
+
|
435 |
+
$newpost = array(
|
436 |
+
'post_name' => $p->post_name,
|
437 |
+
'post_type' => $p->post_type,
|
438 |
+
'ping_status' => $p->ping_status,
|
439 |
+
'post_parent' => $p->post_parent,
|
440 |
+
'menu_order' => $p->menu_order,
|
441 |
+
'post_password' => $p->post_password,
|
442 |
+
'post_excerpt' => $p->post_excerpt,
|
443 |
+
'comment_status' => $p->comment_status,
|
444 |
+
'post_title' => $p->post_title . __('- clone', $plugin->get_plugin_name),
|
445 |
+
'post_content' => $p->post_content,
|
446 |
+
'post_author' => $p->post_author,
|
447 |
+
'to_ping' => $p->to_ping,
|
448 |
+
'pinged' => $p->pinged,
|
449 |
+
'post_content_filtered' => $p->post_content_filtered,
|
450 |
+
'post_category' => $p->post_category,
|
451 |
+
'tags_input' => $p->tags_input,
|
452 |
+
'tax_input' => $p->tax_input,
|
453 |
+
'page_template' => $p->page_template,
|
454 |
+
);
|
455 |
+
|
456 |
+
$post_status = get_option('clone_posts_post_status');
|
457 |
+
if ( $post_status !== 'draft' ) {
|
458 |
+
$newpost['post_status'] = $post_status;
|
459 |
+
}
|
460 |
+
|
461 |
+
$date = get_option('clone_posts_post_date');
|
462 |
+
if ( $date !== 'current' ) {
|
463 |
+
$newpost['post_date'] = $p->post_date;
|
464 |
+
$newpost['post_date_gmt'] = $p->post_date_gmt;
|
465 |
+
}
|
466 |
+
|
467 |
+
$newid = wp_insert_post($newpost);
|
468 |
+
$format = get_post_format($id);
|
469 |
+
set_post_format($newid, $format);
|
470 |
+
|
471 |
+
$meta = get_post_meta($id);
|
472 |
+
foreach($meta as $key=>$val) {
|
473 |
+
update_post_meta( $newid, $key, $val[0] );
|
474 |
+
}
|
475 |
+
|
476 |
+
return true;
|
477 |
+
}
|
478 |
+
|
479 |
+
}
|
admin/css/clone-posts-admin.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your admin-specific functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
admin/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
admin/js/clone-posts-admin.js
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function( $ ) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* All of the code for your admin-facing JavaScript source
|
6 |
+
* should reside in this file.
|
7 |
+
*
|
8 |
+
* Note: It has been assumed you will write jQuery code here, so the
|
9 |
+
* $ function reference has been prepared for usage within the scope
|
10 |
+
* of this function.
|
11 |
+
*
|
12 |
+
* This enables you to define handlers, for when the DOM is ready:
|
13 |
+
*
|
14 |
+
* $(function() {
|
15 |
+
*
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* When the window is loaded:
|
19 |
+
*
|
20 |
+
* $( window ).load(function() {
|
21 |
+
*
|
22 |
+
* });
|
23 |
+
*
|
24 |
+
* ...and/or other possibilities.
|
25 |
+
*
|
26 |
+
* Ideally, it is not considered best practise to attach more than a
|
27 |
+
* single DOM-ready or window-load handler for a particular page.
|
28 |
+
* Although scripts in the WordPress core, Plugins and Themes may be
|
29 |
+
* practising this, we should strive to set a better example in our own work.
|
30 |
+
*/
|
31 |
+
|
32 |
+
})( jQuery );
|
admin/partials/clone-posts-admin-display.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide a admin area view for the plugin
|
5 |
+
*
|
6 |
+
* This file is used to markup the admin-facing aspects of the plugin.
|
7 |
+
*
|
8 |
+
* @link https://profiles.wordpress.org/pattihis/
|
9 |
+
* @since 2.0.0
|
10 |
+
*
|
11 |
+
* @package Clone_Posts
|
12 |
+
* @subpackage Clone_Posts/admin/partials
|
13 |
+
*/
|
14 |
+
?>
|
15 |
+
|
16 |
+
<div class="wrap">
|
17 |
+
<h1>Clone Posts Settings</h1>
|
18 |
+
<form method="post" action="options.php">
|
19 |
+
<?php
|
20 |
+
settings_fields( 'clone_post_settings' );
|
21 |
+
do_settings_sections( 'clone-posts-options' );
|
22 |
+
submit_button();
|
23 |
+
?>
|
24 |
+
</form>
|
25 |
+
</div>
|
26 |
+
<div class="wrap">
|
27 |
+
<p>If you find this free plugin useful then please <a target="_blank" href="https://wordpress.org/support/plugin/clone-posts/reviews/?rate=5#new-post" title="Rate the plugin">rate the plugin ★★★★★</a> to support us. Thank you!</p>
|
28 |
+
</div>
|
clone-posts.php
ADDED
@@ -0,0 +1,112 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Clone Posts
|
4 |
+
*
|
5 |
+
* @package Clone_Posts
|
6 |
+
* @author George Pattihis
|
7 |
+
* @copyright 2021 George Pattihis
|
8 |
+
* @license GPL-2.0-or-later
|
9 |
+
* @link https://profiles.wordpress.org/pattihis/
|
10 |
+
* @since 2.0.0
|
11 |
+
*
|
12 |
+
* @wordpress-plugin
|
13 |
+
* Plugin Name: Clone Posts
|
14 |
+
* Plugin URI: http://wordpress.org/extend/plugins/clone-posts/
|
15 |
+
* Description: Easily clone (duplicate) Posts, Pages and Custom Post Types, including their custom fields (post_meta).
|
16 |
+
* Version: 2.0.0
|
17 |
+
* Requires at least: 5.2
|
18 |
+
* Requires PHP: 7.2
|
19 |
+
* Author: George Pattihis
|
20 |
+
* Author URI: https://profiles.wordpress.org/pattihis/
|
21 |
+
* License: GPL-2.0+
|
22 |
+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
|
23 |
+
* Text Domain: clone-posts
|
24 |
+
* Domain Path: /languages
|
25 |
+
*
|
26 |
+
*/
|
27 |
+
|
28 |
+
/* Copyright 2014 Lukasz Kostrzewa (email : lukasz.webmaster@gmail.com)
|
29 |
+
|
30 |
+
This program is free software; you can redistribute it and/or modify
|
31 |
+
it under the terms of the GNU General Public License, version 2, as
|
32 |
+
published by the Free Software Foundation.
|
33 |
+
|
34 |
+
This program is distributed in the hope that it will be useful,
|
35 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
36 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
37 |
+
GNU General Public License for more details.
|
38 |
+
|
39 |
+
You should have received a copy of the GNU General Public License
|
40 |
+
along with this program; if not, write to the Free Software
|
41 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
42 |
+
*/
|
43 |
+
|
44 |
+
/* Copyright 2021 George Pattihis (gpattihis@gmail.com)
|
45 |
+
|
46 |
+
"Clone Posts" is free software: you can redistribute it and/or modify
|
47 |
+
it under the terms of the GNU General Public License as published by
|
48 |
+
the Free Software Foundation, either version 2 of the License, or
|
49 |
+
any later version.
|
50 |
+
|
51 |
+
"Clone Posts" is distributed in the hope that it will be useful,
|
52 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
53 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
54 |
+
GNU General Public License for more details.
|
55 |
+
|
56 |
+
You should have received a copy of the GNU General Public License
|
57 |
+
"along with Clone Posts". If not, see http://www.gnu.org/licenses/gpl-2.0.txt.
|
58 |
+
*/
|
59 |
+
|
60 |
+
// If this file is called directly, abort.
|
61 |
+
if ( ! defined( 'WPINC' ) ) {
|
62 |
+
die;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Current plugin version.
|
67 |
+
*/
|
68 |
+
define( 'CLONE_POSTS_VERSION', '2.0.0' );
|
69 |
+
|
70 |
+
/**
|
71 |
+
* The code that runs during plugin activation.
|
72 |
+
* This action is documented in includes/class-clone-posts-activator.php
|
73 |
+
*/
|
74 |
+
function activate_clone_posts() {
|
75 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-clone-posts-activator.php';
|
76 |
+
Clone_Posts_Activator::activate();
|
77 |
+
}
|
78 |
+
|
79 |
+
/**
|
80 |
+
* The code that runs during plugin deactivation.
|
81 |
+
* This action is documented in includes/class-clone-posts-deactivator.php
|
82 |
+
*/
|
83 |
+
function deactivate_clone_posts() {
|
84 |
+
require_once plugin_dir_path( __FILE__ ) . 'includes/class-clone-posts-deactivator.php';
|
85 |
+
Clone_Posts_Deactivator::deactivate();
|
86 |
+
}
|
87 |
+
|
88 |
+
register_activation_hook( __FILE__, 'activate_clone_posts' );
|
89 |
+
register_deactivation_hook( __FILE__, 'deactivate_clone_posts' );
|
90 |
+
|
91 |
+
/**
|
92 |
+
* The core plugin class that is used to define internationalization,
|
93 |
+
* admin-specific hooks, and public-facing site hooks.
|
94 |
+
*/
|
95 |
+
require plugin_dir_path( __FILE__ ) . 'includes/class-clone-posts.php';
|
96 |
+
|
97 |
+
/**
|
98 |
+
* Begins execution of the plugin.
|
99 |
+
*
|
100 |
+
* Since everything within the plugin is registered via hooks,
|
101 |
+
* then kicking off the plugin from this point in the file does
|
102 |
+
* not affect the page life cycle.
|
103 |
+
*
|
104 |
+
* @since 2.0.0
|
105 |
+
*/
|
106 |
+
function run_clone_posts() {
|
107 |
+
|
108 |
+
$plugin = new Clone_Posts();
|
109 |
+
$plugin->run();
|
110 |
+
|
111 |
+
}
|
112 |
+
run_clone_posts();
|
includes/class-clone-posts-activator.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin activation
|
5 |
+
*
|
6 |
+
* @link https://profiles.wordpress.org/pattihis/
|
7 |
+
* @since 2.0.0
|
8 |
+
*
|
9 |
+
* @package Clone_Posts
|
10 |
+
* @subpackage Clone_Posts/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Fired during plugin activation.
|
15 |
+
*
|
16 |
+
* This class defines all code necessary to run during the plugin's activation.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @package Clone_Posts
|
20 |
+
* @subpackage Clone_Posts/includes
|
21 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
22 |
+
*/
|
23 |
+
class Clone_Posts_Activator {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Short Description. (use period)
|
27 |
+
*
|
28 |
+
* Long Description.
|
29 |
+
*
|
30 |
+
* @since 2.0.0
|
31 |
+
*/
|
32 |
+
public static function activate() {
|
33 |
+
|
34 |
+
update_option('clone_posts_post_status', 'draft');
|
35 |
+
update_option('clone_posts_post_date', 'current');
|
36 |
+
update_option('clone_posts_post_type', ['post']);
|
37 |
+
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
includes/class-clone-posts-deactivator.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired during plugin deactivation
|
5 |
+
*
|
6 |
+
* @link https://profiles.wordpress.org/pattihis/
|
7 |
+
* @since 2.0.0
|
8 |
+
*
|
9 |
+
* @package Clone_Posts
|
10 |
+
* @subpackage Clone_Posts/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Fired during plugin deactivation.
|
15 |
+
*
|
16 |
+
* This class defines all code necessary to run during the plugin's deactivation.
|
17 |
+
*
|
18 |
+
* @since 2.0.0
|
19 |
+
* @package Clone_Posts
|
20 |
+
* @subpackage Clone_Posts/includes
|
21 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
22 |
+
*/
|
23 |
+
class Clone_Posts_Deactivator {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Short Description. (use period)
|
27 |
+
*
|
28 |
+
* Long Description.
|
29 |
+
*
|
30 |
+
* @since 2.0.0
|
31 |
+
*/
|
32 |
+
public static function deactivate() {
|
33 |
+
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
includes/class-clone-posts-i18n.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Define the internationalization functionality
|
5 |
+
*
|
6 |
+
* Loads and defines the internationalization files for this plugin
|
7 |
+
* so that it is ready for translation.
|
8 |
+
*
|
9 |
+
* @link https://profiles.wordpress.org/pattihis/
|
10 |
+
* @since 2.0.0
|
11 |
+
*
|
12 |
+
* @package Clone_Posts
|
13 |
+
* @subpackage Clone_Posts/includes
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Define the internationalization functionality.
|
18 |
+
*
|
19 |
+
* Loads and defines the internationalization files for this plugin
|
20 |
+
* so that it is ready for translation.
|
21 |
+
*
|
22 |
+
* @since 2.0.0
|
23 |
+
* @package Clone_Posts
|
24 |
+
* @subpackage Clone_Posts/includes
|
25 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
26 |
+
*/
|
27 |
+
class Clone_Posts_i18n {
|
28 |
+
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Load the plugin text domain for translation.
|
32 |
+
*
|
33 |
+
* @since 2.0.0
|
34 |
+
*/
|
35 |
+
public function load_plugin_textdomain() {
|
36 |
+
|
37 |
+
load_plugin_textdomain(
|
38 |
+
'clone-posts',
|
39 |
+
false,
|
40 |
+
dirname( dirname( plugin_basename( __FILE__ ) ) ) . '/languages/'
|
41 |
+
);
|
42 |
+
|
43 |
+
}
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
}
|
includes/class-clone-posts-loader.php
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Register all actions and filters for the plugin
|
5 |
+
*
|
6 |
+
* @link https://profiles.wordpress.org/pattihis/
|
7 |
+
* @since 2.0.0
|
8 |
+
*
|
9 |
+
* @package Clone_Posts
|
10 |
+
* @subpackage Clone_Posts/includes
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* Register all actions and filters for the plugin.
|
15 |
+
*
|
16 |
+
* Maintain a list of all hooks that are registered throughout
|
17 |
+
* the plugin, and register them with the WordPress API. Call the
|
18 |
+
* run function to execute the list of actions and filters.
|
19 |
+
*
|
20 |
+
* @package Clone_Posts
|
21 |
+
* @subpackage Clone_Posts/includes
|
22 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
23 |
+
*/
|
24 |
+
class Clone_Posts_Loader {
|
25 |
+
|
26 |
+
/**
|
27 |
+
* The array of actions registered with WordPress.
|
28 |
+
*
|
29 |
+
* @since 2.0.0
|
30 |
+
* @access protected
|
31 |
+
* @var array $actions The actions registered with WordPress to fire when the plugin loads.
|
32 |
+
*/
|
33 |
+
protected $actions;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* The array of filters registered with WordPress.
|
37 |
+
*
|
38 |
+
* @since 2.0.0
|
39 |
+
* @access protected
|
40 |
+
* @var array $filters The filters registered with WordPress to fire when the plugin loads.
|
41 |
+
*/
|
42 |
+
protected $filters;
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Initialize the collections used to maintain the actions and filters.
|
46 |
+
*
|
47 |
+
* @since 2.0.0
|
48 |
+
*/
|
49 |
+
public function __construct() {
|
50 |
+
|
51 |
+
$this->actions = array();
|
52 |
+
$this->filters = array();
|
53 |
+
|
54 |
+
}
|
55 |
+
|
56 |
+
/**
|
57 |
+
* Add a new action to the collection to be registered with WordPress.
|
58 |
+
*
|
59 |
+
* @since 2.0.0
|
60 |
+
* @param string $hook The name of the WordPress action that is being registered.
|
61 |
+
* @param object $component A reference to the instance of the object on which the action is defined.
|
62 |
+
* @param string $callback The name of the function definition on the $component.
|
63 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
64 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1.
|
65 |
+
*/
|
66 |
+
public function add_action( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
67 |
+
$this->actions = $this->add( $this->actions, $hook, $component, $callback, $priority, $accepted_args );
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Add a new filter to the collection to be registered with WordPress.
|
72 |
+
*
|
73 |
+
* @since 2.0.0
|
74 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
75 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
76 |
+
* @param string $callback The name of the function definition on the $component.
|
77 |
+
* @param int $priority Optional. The priority at which the function should be fired. Default is 10.
|
78 |
+
* @param int $accepted_args Optional. The number of arguments that should be passed to the $callback. Default is 1
|
79 |
+
*/
|
80 |
+
public function add_filter( $hook, $component, $callback, $priority = 10, $accepted_args = 1 ) {
|
81 |
+
$this->filters = $this->add( $this->filters, $hook, $component, $callback, $priority, $accepted_args );
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* A utility function that is used to register the actions and hooks into a single
|
86 |
+
* collection.
|
87 |
+
*
|
88 |
+
* @since 2.0.0
|
89 |
+
* @access private
|
90 |
+
* @param array $hooks The collection of hooks that is being registered (that is, actions or filters).
|
91 |
+
* @param string $hook The name of the WordPress filter that is being registered.
|
92 |
+
* @param object $component A reference to the instance of the object on which the filter is defined.
|
93 |
+
* @param string $callback The name of the function definition on the $component.
|
94 |
+
* @param int $priority The priority at which the function should be fired.
|
95 |
+
* @param int $accepted_args The number of arguments that should be passed to the $callback.
|
96 |
+
* @return array The collection of actions and filters registered with WordPress.
|
97 |
+
*/
|
98 |
+
private function add( $hooks, $hook, $component, $callback, $priority, $accepted_args ) {
|
99 |
+
|
100 |
+
$hooks[] = array(
|
101 |
+
'hook' => $hook,
|
102 |
+
'component' => $component,
|
103 |
+
'callback' => $callback,
|
104 |
+
'priority' => $priority,
|
105 |
+
'accepted_args' => $accepted_args
|
106 |
+
);
|
107 |
+
|
108 |
+
return $hooks;
|
109 |
+
|
110 |
+
}
|
111 |
+
|
112 |
+
/**
|
113 |
+
* Register the filters and actions with WordPress.
|
114 |
+
*
|
115 |
+
* @since 2.0.0
|
116 |
+
*/
|
117 |
+
public function run() {
|
118 |
+
|
119 |
+
foreach ( $this->filters as $hook ) {
|
120 |
+
add_filter( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
121 |
+
}
|
122 |
+
|
123 |
+
foreach ( $this->actions as $hook ) {
|
124 |
+
add_action( $hook['hook'], array( $hook['component'], $hook['callback'] ), $hook['priority'], $hook['accepted_args'] );
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
}
|
includes/class-clone-posts.php
ADDED
@@ -0,0 +1,227 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The file that defines the core plugin class
|
5 |
+
*
|
6 |
+
* A class definition that includes attributes and functions used across both the
|
7 |
+
* public-facing side of the site and the admin area.
|
8 |
+
*
|
9 |
+
* @link https://profiles.wordpress.org/pattihis/
|
10 |
+
* @since 2.0.0
|
11 |
+
*
|
12 |
+
* @package Clone_Posts
|
13 |
+
* @subpackage Clone_Posts/includes
|
14 |
+
*/
|
15 |
+
|
16 |
+
/**
|
17 |
+
* The core plugin class.
|
18 |
+
*
|
19 |
+
* This is used to define internationalization, admin-specific hooks, and
|
20 |
+
* public-facing site hooks.
|
21 |
+
*
|
22 |
+
* Also maintains the unique identifier of this plugin as well as the current
|
23 |
+
* version of the plugin.
|
24 |
+
*
|
25 |
+
* @since 2.0.0
|
26 |
+
* @package Clone_Posts
|
27 |
+
* @subpackage Clone_Posts/includes
|
28 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
29 |
+
*/
|
30 |
+
class Clone_Posts {
|
31 |
+
|
32 |
+
/**
|
33 |
+
* The loader that's responsible for maintaining and registering all hooks that power
|
34 |
+
* the plugin.
|
35 |
+
*
|
36 |
+
* @since 2.0.0
|
37 |
+
* @access protected
|
38 |
+
* @var Clone_Posts_Loader $loader Maintains and registers all hooks for the plugin.
|
39 |
+
*/
|
40 |
+
protected $loader;
|
41 |
+
|
42 |
+
/**
|
43 |
+
* The unique identifier of this plugin.
|
44 |
+
*
|
45 |
+
* @since 2.0.0
|
46 |
+
* @access protected
|
47 |
+
* @var string $plugin_name The string used to uniquely identify this plugin.
|
48 |
+
*/
|
49 |
+
protected $plugin_name;
|
50 |
+
|
51 |
+
/**
|
52 |
+
* The current version of the plugin.
|
53 |
+
*
|
54 |
+
* @since 2.0.0
|
55 |
+
* @access protected
|
56 |
+
* @var string $version The current version of the plugin.
|
57 |
+
*/
|
58 |
+
protected $version;
|
59 |
+
|
60 |
+
/**
|
61 |
+
* Define the core functionality of the plugin.
|
62 |
+
*
|
63 |
+
* Set the plugin name and the plugin version that can be used throughout the plugin.
|
64 |
+
* Load the dependencies, define the locale, and set the hooks for the admin area and
|
65 |
+
* the public-facing side of the site.
|
66 |
+
*
|
67 |
+
* @since 2.0.0
|
68 |
+
*/
|
69 |
+
public function __construct() {
|
70 |
+
if ( defined( 'CLONE_POSTS_VERSION' ) ) {
|
71 |
+
$this->version = CLONE_POSTS_VERSION;
|
72 |
+
} else {
|
73 |
+
$this->version = '2.0.0';
|
74 |
+
}
|
75 |
+
$this->plugin_name = 'clone-posts';
|
76 |
+
|
77 |
+
$this->load_dependencies();
|
78 |
+
$this->set_locale();
|
79 |
+
$this->define_admin_hooks();
|
80 |
+
$this->define_public_hooks();
|
81 |
+
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* Load the required dependencies for this plugin.
|
86 |
+
*
|
87 |
+
* Include the following files that make up the plugin:
|
88 |
+
*
|
89 |
+
* - Clone_Posts_Loader. Orchestrates the hooks of the plugin.
|
90 |
+
* - Clone_Posts_i18n. Defines internationalization functionality.
|
91 |
+
* - Clone_Posts_Admin. Defines all hooks for the admin area.
|
92 |
+
* - Clone_Posts_Public. Defines all hooks for the public side of the site.
|
93 |
+
*
|
94 |
+
* Create an instance of the loader which will be used to register the hooks
|
95 |
+
* with WordPress.
|
96 |
+
*
|
97 |
+
* @since 2.0.0
|
98 |
+
* @access private
|
99 |
+
*/
|
100 |
+
private function load_dependencies() {
|
101 |
+
|
102 |
+
/**
|
103 |
+
* The class responsible for orchestrating the actions and filters of the
|
104 |
+
* core plugin.
|
105 |
+
*/
|
106 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-clone-posts-loader.php';
|
107 |
+
|
108 |
+
/**
|
109 |
+
* The class responsible for defining internationalization functionality
|
110 |
+
* of the plugin.
|
111 |
+
*/
|
112 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-clone-posts-i18n.php';
|
113 |
+
|
114 |
+
/**
|
115 |
+
* The class responsible for defining all actions that occur in the admin area.
|
116 |
+
*/
|
117 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-clone-posts-admin.php';
|
118 |
+
|
119 |
+
/**
|
120 |
+
* The class responsible for defining all actions that occur in the public-facing
|
121 |
+
* side of the site.
|
122 |
+
*/
|
123 |
+
require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-clone-posts-public.php';
|
124 |
+
|
125 |
+
$this->loader = new Clone_Posts_Loader();
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
/**
|
130 |
+
* Define the locale for this plugin for internationalization.
|
131 |
+
*
|
132 |
+
* Uses the Clone_Posts_i18n class in order to set the domain and to register the hook
|
133 |
+
* with WordPress.
|
134 |
+
*
|
135 |
+
* @since 2.0.0
|
136 |
+
* @access private
|
137 |
+
*/
|
138 |
+
private function set_locale() {
|
139 |
+
|
140 |
+
$plugin_i18n = new Clone_Posts_i18n();
|
141 |
+
|
142 |
+
$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );
|
143 |
+
|
144 |
+
}
|
145 |
+
|
146 |
+
/**
|
147 |
+
* Register all of the hooks related to the admin area functionality
|
148 |
+
* of the plugin.
|
149 |
+
*
|
150 |
+
* @since 2.0.0
|
151 |
+
* @access private
|
152 |
+
*/
|
153 |
+
private function define_admin_hooks() {
|
154 |
+
|
155 |
+
$plugin_admin = new Clone_Posts_Admin( $this->get_plugin_name(), $this->get_version() );
|
156 |
+
|
157 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
|
158 |
+
$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );
|
159 |
+
|
160 |
+
$this->loader->add_action( 'admin_init', $plugin_admin, 'clonePosts_register_setting' );
|
161 |
+
$this->loader->add_action( 'admin_menu', $plugin_admin, 'clonePosts_admin_page' );
|
162 |
+
$this->loader->add_action( 'admin_footer-edit.php', $plugin_admin, 'clonePosts_admin_footer' );
|
163 |
+
$this->loader->add_action( 'load-edit.php', $plugin_admin, 'clonePosts_bulk_action' );
|
164 |
+
$this->loader->add_action( 'admin_notices', $plugin_admin, 'clonePosts_admin_notices' );
|
165 |
+
$this->loader->add_filter( 'post_row_actions', $plugin_admin, 'clonePosts_post_row_actions', 10, 2 );
|
166 |
+
$this->loader->add_filter( 'page_row_actions', $plugin_admin, 'clonePosts_post_row_actions', 10, 2 );
|
167 |
+
$this->loader->add_action( 'wp_loaded', $plugin_admin, 'clonePosts_wp_loaded' );
|
168 |
+
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Register all of the hooks related to the public-facing functionality
|
173 |
+
* of the plugin.
|
174 |
+
*
|
175 |
+
* @since 2.0.0
|
176 |
+
* @access private
|
177 |
+
*/
|
178 |
+
private function define_public_hooks() {
|
179 |
+
|
180 |
+
$plugin_public = new Clone_Posts_Public( $this->get_plugin_name(), $this->get_version() );
|
181 |
+
|
182 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
|
183 |
+
$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
|
184 |
+
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Run the loader to execute all of the hooks with WordPress.
|
189 |
+
*
|
190 |
+
* @since 2.0.0
|
191 |
+
*/
|
192 |
+
public function run() {
|
193 |
+
$this->loader->run();
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* The name of the plugin used to uniquely identify it within the context of
|
198 |
+
* WordPress and to define internationalization functionality.
|
199 |
+
*
|
200 |
+
* @since 2.0.0
|
201 |
+
* @return string The name of the plugin.
|
202 |
+
*/
|
203 |
+
public function get_plugin_name() {
|
204 |
+
return $this->plugin_name;
|
205 |
+
}
|
206 |
+
|
207 |
+
/**
|
208 |
+
* The reference to the class that orchestrates the hooks with the plugin.
|
209 |
+
*
|
210 |
+
* @since 2.0.0
|
211 |
+
* @return Clone_Posts_Loader Orchestrates the hooks of the plugin.
|
212 |
+
*/
|
213 |
+
public function get_loader() {
|
214 |
+
return $this->loader;
|
215 |
+
}
|
216 |
+
|
217 |
+
/**
|
218 |
+
* Retrieve the version number of the plugin.
|
219 |
+
*
|
220 |
+
* @since 2.0.0
|
221 |
+
* @return string The version number of the plugin.
|
222 |
+
*/
|
223 |
+
public function get_version() {
|
224 |
+
return $this->version;
|
225 |
+
}
|
226 |
+
|
227 |
+
}
|
includes/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
languages/clone-posts.pot
ADDED
File without changes
|
public/class-clone-posts-public.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* The public-facing functionality of the plugin.
|
5 |
+
*
|
6 |
+
* @link https://profiles.wordpress.org/pattihis/
|
7 |
+
* @since 2.0.0
|
8 |
+
*
|
9 |
+
* @package Clone_Posts
|
10 |
+
* @subpackage Clone_Posts/public
|
11 |
+
*/
|
12 |
+
|
13 |
+
/**
|
14 |
+
* The public-facing functionality of the plugin.
|
15 |
+
*
|
16 |
+
* Defines the plugin name, version, and two examples hooks for how to
|
17 |
+
* enqueue the public-facing stylesheet and JavaScript.
|
18 |
+
*
|
19 |
+
* @package Clone_Posts
|
20 |
+
* @subpackage Clone_Posts/public
|
21 |
+
* @author George Pattihis <gpattihis@gmail.com>
|
22 |
+
*/
|
23 |
+
class Clone_Posts_Public {
|
24 |
+
|
25 |
+
/**
|
26 |
+
* The ID of this plugin.
|
27 |
+
*
|
28 |
+
* @since 2.0.0
|
29 |
+
* @access private
|
30 |
+
* @var string $plugin_name The ID of this plugin.
|
31 |
+
*/
|
32 |
+
private $plugin_name;
|
33 |
+
|
34 |
+
/**
|
35 |
+
* The version of this plugin.
|
36 |
+
*
|
37 |
+
* @since 2.0.0
|
38 |
+
* @access private
|
39 |
+
* @var string $version The current version of this plugin.
|
40 |
+
*/
|
41 |
+
private $version;
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Initialize the class and set its properties.
|
45 |
+
*
|
46 |
+
* @since 2.0.0
|
47 |
+
* @param string $plugin_name The name of the plugin.
|
48 |
+
* @param string $version The version of this plugin.
|
49 |
+
*/
|
50 |
+
public function __construct( $plugin_name, $version ) {
|
51 |
+
|
52 |
+
$this->plugin_name = $plugin_name;
|
53 |
+
$this->version = $version;
|
54 |
+
|
55 |
+
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Register the stylesheets for the public-facing side of the site.
|
59 |
+
*
|
60 |
+
* @since 2.0.0
|
61 |
+
*/
|
62 |
+
public function enqueue_styles() {
|
63 |
+
|
64 |
+
wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/clone-posts-public.css', array(), $this->version, 'all' );
|
65 |
+
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Register the JavaScript for the public-facing side of the site.
|
70 |
+
*
|
71 |
+
* @since 2.0.0
|
72 |
+
*/
|
73 |
+
public function enqueue_scripts() {
|
74 |
+
|
75 |
+
wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/clone-posts-public.js', array( 'jquery' ), $this->version, false );
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
}
|
public/css/clone-posts-public.css
ADDED
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
1 |
+
/**
|
2 |
+
* All of the CSS for your public-facing functionality should be
|
3 |
+
* included in this file.
|
4 |
+
*/
|
public/index.php
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
<?php // Silence is golden
|
public/js/clone-posts-public.js
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
(function( $ ) {
|
2 |
+
'use strict';
|
3 |
+
|
4 |
+
/**
|
5 |
+
* All of the code for your public-facing JavaScript source
|
6 |
+
* should reside in this file.
|
7 |
+
*
|
8 |
+
* Note: It has been assumed you will write jQuery code here, so the
|
9 |
+
* $ function reference has been prepared for usage within the scope
|
10 |
+
* of this function.
|
11 |
+
*
|
12 |
+
* This enables you to define handlers, for when the DOM is ready:
|
13 |
+
*
|
14 |
+
* $(function() {
|
15 |
+
*
|
16 |
+
* });
|
17 |
+
*
|
18 |
+
* When the window is loaded:
|
19 |
+
*
|
20 |
+
* $( window ).load(function() {
|
21 |
+
*
|
22 |
+
* });
|
23 |
+
*
|
24 |
+
* ...and/or other possibilities.
|
25 |
+
*
|
26 |
+
* Ideally, it is not considered best practise to attach more than a
|
27 |
+
* single DOM-ready or window-load handler for a particular page.
|
28 |
+
* Although scripts in the WordPress core, Plugins and Themes may be
|
29 |
+
* practising this, we should strive to set a better example in our own work.
|
30 |
+
*/
|
31 |
+
|
32 |
+
})( jQuery );
|
public/partials/clone-posts-public-display.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Provide a public-facing view for the plugin
|
5 |
+
*
|
6 |
+
* This file is used to markup the public-facing aspects of the plugin.
|
7 |
+
*
|
8 |
+
* @link https://profiles.wordpress.org/pattihis/
|
9 |
+
* @since 2.0.0
|
10 |
+
*
|
11 |
+
* @package Clone_Posts
|
12 |
+
* @subpackage Clone_Posts/public/partials
|
13 |
+
*/
|
14 |
+
?>
|
15 |
+
|
16 |
+
<!-- This file should primarily consist of HTML with a little bit of PHP. -->
|
uninstall.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Fired when the plugin is uninstalled.
|
5 |
+
*
|
6 |
+
*
|
7 |
+
* @link https://profiles.wordpress.org/pattihis/
|
8 |
+
* @since 2.0.0
|
9 |
+
*
|
10 |
+
* @package Clone_Posts
|
11 |
+
*/
|
12 |
+
|
13 |
+
// If uninstall not called from WordPress, then exit.
|
14 |
+
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
15 |
+
exit;
|
16 |
+
}
|
17 |
+
|
18 |
+
// If we are on a multisite installation clean up all subsites
|
19 |
+
if ( is_multisite() ) {
|
20 |
+
|
21 |
+
foreach (get_sites(['fields'=>'ids']) as $blog_id) {
|
22 |
+
switch_to_blog($blog_id);
|
23 |
+
clonePosts_cleanup();
|
24 |
+
restore_current_blog();
|
25 |
+
}
|
26 |
+
|
27 |
+
} else {
|
28 |
+
clonePosts_cleanup();
|
29 |
+
}
|
30 |
+
|
31 |
+
function clonePosts_cleanup(){
|
32 |
+
|
33 |
+
// Plugin options
|
34 |
+
$options = array(
|
35 |
+
'clone_posts_post_status',
|
36 |
+
'clone_posts_post_date',
|
37 |
+
'clone_posts_post_type',
|
38 |
+
);
|
39 |
+
|
40 |
+
// Loop through each option
|
41 |
+
foreach ( $options as $option ) {
|
42 |
+
delete_option( $option );
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|