Version Description
- Released 2014-12-12
- Added settings panel for enabling/disabling the Reorder plugin for post types.
- Added advanced settings for overriding the menu order of post types.
- Added internationalization capabilities.
- Slightly adjusted the styles of the Reordering interface.
Download this release
Release Info
Developer | ronalfy |
Plugin | Reorder Posts |
Version | 2.0.0 |
Comparing to | |
See all releases |
Code changes from version 1.0.6 to 2.0.0
- LICENSE +340 -0
- class-reorder-admin.php +423 -0
- class-reorder.php +4 -17
- admin.css → css/admin.css +12 -3
- css/index.php +0 -0
- index.php +25 -6
- languages/index.php +0 -0
- languages/metronet-reorder-posts.pot +113 -0
- metronet-icon.png +0 -0
- readme.txt +69 -11
- screenshot-1.png +0 -0
- scripts/index.php +0 -0
- scripts/sort.js +2 -40
- uninstall.php +6 -0
LICENSE
ADDED
@@ -0,0 +1,340 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
GNU GENERAL PUBLIC LICENSE
|
2 |
+
Version 2, June 1991
|
3 |
+
|
4 |
+
Copyright (C) 1989, 1991 Free Software Foundation, Inc., <http://fsf.org/>
|
5 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
6 |
+
Everyone is permitted to copy and distribute verbatim copies
|
7 |
+
of this license document, but changing it is not allowed.
|
8 |
+
|
9 |
+
Preamble
|
10 |
+
|
11 |
+
The licenses for most software are designed to take away your
|
12 |
+
freedom to share and change it. By contrast, the GNU General Public
|
13 |
+
License is intended to guarantee your freedom to share and change free
|
14 |
+
software--to make sure the software is free for all its users. This
|
15 |
+
General Public License applies to most of the Free Software
|
16 |
+
Foundation's software and to any other program whose authors commit to
|
17 |
+
using it. (Some other Free Software Foundation software is covered by
|
18 |
+
the GNU Lesser General Public License instead.) You can apply it to
|
19 |
+
your programs, too.
|
20 |
+
|
21 |
+
When we speak of free software, we are referring to freedom, not
|
22 |
+
price. Our General Public Licenses are designed to make sure that you
|
23 |
+
have the freedom to distribute copies of free software (and charge for
|
24 |
+
this service if you wish), that you receive source code or can get it
|
25 |
+
if you want it, that you can change the software or use pieces of it
|
26 |
+
in new free programs; and that you know you can do these things.
|
27 |
+
|
28 |
+
To protect your rights, we need to make restrictions that forbid
|
29 |
+
anyone to deny you these rights or to ask you to surrender the rights.
|
30 |
+
These restrictions translate to certain responsibilities for you if you
|
31 |
+
distribute copies of the software, or if you modify it.
|
32 |
+
|
33 |
+
For example, if you distribute copies of such a program, whether
|
34 |
+
gratis or for a fee, you must give the recipients all the rights that
|
35 |
+
you have. You must make sure that they, too, receive or can get the
|
36 |
+
source code. And you must show them these terms so they know their
|
37 |
+
rights.
|
38 |
+
|
39 |
+
We protect your rights with two steps: (1) copyright the software, and
|
40 |
+
(2) offer you this license which gives you legal permission to copy,
|
41 |
+
distribute and/or modify the software.
|
42 |
+
|
43 |
+
Also, for each author's protection and ours, we want to make certain
|
44 |
+
that everyone understands that there is no warranty for this free
|
45 |
+
software. If the software is modified by someone else and passed on, we
|
46 |
+
want its recipients to know that what they have is not the original, so
|
47 |
+
that any problems introduced by others will not reflect on the original
|
48 |
+
authors' reputations.
|
49 |
+
|
50 |
+
Finally, any free program is threatened constantly by software
|
51 |
+
patents. We wish to avoid the danger that redistributors of a free
|
52 |
+
program will individually obtain patent licenses, in effect making the
|
53 |
+
program proprietary. To prevent this, we have made it clear that any
|
54 |
+
patent must be licensed for everyone's free use or not licensed at all.
|
55 |
+
|
56 |
+
The precise terms and conditions for copying, distribution and
|
57 |
+
modification follow.
|
58 |
+
|
59 |
+
GNU GENERAL PUBLIC LICENSE
|
60 |
+
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
61 |
+
|
62 |
+
0. This License applies to any program or other work which contains
|
63 |
+
a notice placed by the copyright holder saying it may be distributed
|
64 |
+
under the terms of this General Public License. The "Program", below,
|
65 |
+
refers to any such program or work, and a "work based on the Program"
|
66 |
+
means either the Program or any derivative work under copyright law:
|
67 |
+
that is to say, a work containing the Program or a portion of it,
|
68 |
+
either verbatim or with modifications and/or translated into another
|
69 |
+
language. (Hereinafter, translation is included without limitation in
|
70 |
+
the term "modification".) Each licensee is addressed as "you".
|
71 |
+
|
72 |
+
Activities other than copying, distribution and modification are not
|
73 |
+
covered by this License; they are outside its scope. The act of
|
74 |
+
running the Program is not restricted, and the output from the Program
|
75 |
+
is covered only if its contents constitute a work based on the
|
76 |
+
Program (independent of having been made by running the Program).
|
77 |
+
Whether that is true depends on what the Program does.
|
78 |
+
|
79 |
+
1. You may copy and distribute verbatim copies of the Program's
|
80 |
+
source code as you receive it, in any medium, provided that you
|
81 |
+
conspicuously and appropriately publish on each copy an appropriate
|
82 |
+
copyright notice and disclaimer of warranty; keep intact all the
|
83 |
+
notices that refer to this License and to the absence of any warranty;
|
84 |
+
and give any other recipients of the Program a copy of this License
|
85 |
+
along with the Program.
|
86 |
+
|
87 |
+
You may charge a fee for the physical act of transferring a copy, and
|
88 |
+
you may at your option offer warranty protection in exchange for a fee.
|
89 |
+
|
90 |
+
2. You may modify your copy or copies of the Program or any portion
|
91 |
+
of it, thus forming a work based on the Program, and copy and
|
92 |
+
distribute such modifications or work under the terms of Section 1
|
93 |
+
above, provided that you also meet all of these conditions:
|
94 |
+
|
95 |
+
a) You must cause the modified files to carry prominent notices
|
96 |
+
stating that you changed the files and the date of any change.
|
97 |
+
|
98 |
+
b) You must cause any work that you distribute or publish, that in
|
99 |
+
whole or in part contains or is derived from the Program or any
|
100 |
+
part thereof, to be licensed as a whole at no charge to all third
|
101 |
+
parties under the terms of this License.
|
102 |
+
|
103 |
+
c) If the modified program normally reads commands interactively
|
104 |
+
when run, you must cause it, when started running for such
|
105 |
+
interactive use in the most ordinary way, to print or display an
|
106 |
+
announcement including an appropriate copyright notice and a
|
107 |
+
notice that there is no warranty (or else, saying that you provide
|
108 |
+
a warranty) and that users may redistribute the program under
|
109 |
+
these conditions, and telling the user how to view a copy of this
|
110 |
+
License. (Exception: if the Program itself is interactive but
|
111 |
+
does not normally print such an announcement, your work based on
|
112 |
+
the Program is not required to print an announcement.)
|
113 |
+
|
114 |
+
These requirements apply to the modified work as a whole. If
|
115 |
+
identifiable sections of that work are not derived from the Program,
|
116 |
+
and can be reasonably considered independent and separate works in
|
117 |
+
themselves, then this License, and its terms, do not apply to those
|
118 |
+
sections when you distribute them as separate works. But when you
|
119 |
+
distribute the same sections as part of a whole which is a work based
|
120 |
+
on the Program, the distribution of the whole must be on the terms of
|
121 |
+
this License, whose permissions for other licensees extend to the
|
122 |
+
entire whole, and thus to each and every part regardless of who wrote it.
|
123 |
+
|
124 |
+
Thus, it is not the intent of this section to claim rights or contest
|
125 |
+
your rights to work written entirely by you; rather, the intent is to
|
126 |
+
exercise the right to control the distribution of derivative or
|
127 |
+
collective works based on the Program.
|
128 |
+
|
129 |
+
In addition, mere aggregation of another work not based on the Program
|
130 |
+
with the Program (or with a work based on the Program) on a volume of
|
131 |
+
a storage or distribution medium does not bring the other work under
|
132 |
+
the scope of this License.
|
133 |
+
|
134 |
+
3. You may copy and distribute the Program (or a work based on it,
|
135 |
+
under Section 2) in object code or executable form under the terms of
|
136 |
+
Sections 1 and 2 above provided that you also do one of the following:
|
137 |
+
|
138 |
+
a) Accompany it with the complete corresponding machine-readable
|
139 |
+
source code, which must be distributed under the terms of Sections
|
140 |
+
1 and 2 above on a medium customarily used for software interchange; or,
|
141 |
+
|
142 |
+
b) Accompany it with a written offer, valid for at least three
|
143 |
+
years, to give any third party, for a charge no more than your
|
144 |
+
cost of physically performing source distribution, a complete
|
145 |
+
machine-readable copy of the corresponding source code, to be
|
146 |
+
distributed under the terms of Sections 1 and 2 above on a medium
|
147 |
+
customarily used for software interchange; or,
|
148 |
+
|
149 |
+
c) Accompany it with the information you received as to the offer
|
150 |
+
to distribute corresponding source code. (This alternative is
|
151 |
+
allowed only for noncommercial distribution and only if you
|
152 |
+
received the program in object code or executable form with such
|
153 |
+
an offer, in accord with Subsection b above.)
|
154 |
+
|
155 |
+
The source code for a work means the preferred form of the work for
|
156 |
+
making modifications to it. For an executable work, complete source
|
157 |
+
code means all the source code for all modules it contains, plus any
|
158 |
+
associated interface definition files, plus the scripts used to
|
159 |
+
control compilation and installation of the executable. However, as a
|
160 |
+
special exception, the source code distributed need not include
|
161 |
+
anything that is normally distributed (in either source or binary
|
162 |
+
form) with the major components (compiler, kernel, and so on) of the
|
163 |
+
operating system on which the executable runs, unless that component
|
164 |
+
itself accompanies the executable.
|
165 |
+
|
166 |
+
If distribution of executable or object code is made by offering
|
167 |
+
access to copy from a designated place, then offering equivalent
|
168 |
+
access to copy the source code from the same place counts as
|
169 |
+
distribution of the source code, even though third parties are not
|
170 |
+
compelled to copy the source along with the object code.
|
171 |
+
|
172 |
+
4. You may not copy, modify, sublicense, or distribute the Program
|
173 |
+
except as expressly provided under this License. Any attempt
|
174 |
+
otherwise to copy, modify, sublicense or distribute the Program is
|
175 |
+
void, and will automatically terminate your rights under this License.
|
176 |
+
However, parties who have received copies, or rights, from you under
|
177 |
+
this License will not have their licenses terminated so long as such
|
178 |
+
parties remain in full compliance.
|
179 |
+
|
180 |
+
5. You are not required to accept this License, since you have not
|
181 |
+
signed it. However, nothing else grants you permission to modify or
|
182 |
+
distribute the Program or its derivative works. These actions are
|
183 |
+
prohibited by law if you do not accept this License. Therefore, by
|
184 |
+
modifying or distributing the Program (or any work based on the
|
185 |
+
Program), you indicate your acceptance of this License to do so, and
|
186 |
+
all its terms and conditions for copying, distributing or modifying
|
187 |
+
the Program or works based on it.
|
188 |
+
|
189 |
+
6. Each time you redistribute the Program (or any work based on the
|
190 |
+
Program), the recipient automatically receives a license from the
|
191 |
+
original licensor to copy, distribute or modify the Program subject to
|
192 |
+
these terms and conditions. You may not impose any further
|
193 |
+
restrictions on the recipients' exercise of the rights granted herein.
|
194 |
+
You are not responsible for enforcing compliance by third parties to
|
195 |
+
this License.
|
196 |
+
|
197 |
+
7. If, as a consequence of a court judgment or allegation of patent
|
198 |
+
infringement or for any other reason (not limited to patent issues),
|
199 |
+
conditions are imposed on you (whether by court order, agreement or
|
200 |
+
otherwise) that contradict the conditions of this License, they do not
|
201 |
+
excuse you from the conditions of this License. If you cannot
|
202 |
+
distribute so as to satisfy simultaneously your obligations under this
|
203 |
+
License and any other pertinent obligations, then as a consequence you
|
204 |
+
may not distribute the Program at all. For example, if a patent
|
205 |
+
license would not permit royalty-free redistribution of the Program by
|
206 |
+
all those who receive copies directly or indirectly through you, then
|
207 |
+
the only way you could satisfy both it and this License would be to
|
208 |
+
refrain entirely from distribution of the Program.
|
209 |
+
|
210 |
+
If any portion of this section is held invalid or unenforceable under
|
211 |
+
any particular circumstance, the balance of the section is intended to
|
212 |
+
apply and the section as a whole is intended to apply in other
|
213 |
+
circumstances.
|
214 |
+
|
215 |
+
It is not the purpose of this section to induce you to infringe any
|
216 |
+
patents or other property right claims or to contest validity of any
|
217 |
+
such claims; this section has the sole purpose of protecting the
|
218 |
+
integrity of the free software distribution system, which is
|
219 |
+
implemented by public license practices. Many people have made
|
220 |
+
generous contributions to the wide range of software distributed
|
221 |
+
through that system in reliance on consistent application of that
|
222 |
+
system; it is up to the author/donor to decide if he or she is willing
|
223 |
+
to distribute software through any other system and a licensee cannot
|
224 |
+
impose that choice.
|
225 |
+
|
226 |
+
This section is intended to make thoroughly clear what is believed to
|
227 |
+
be a consequence of the rest of this License.
|
228 |
+
|
229 |
+
8. If the distribution and/or use of the Program is restricted in
|
230 |
+
certain countries either by patents or by copyrighted interfaces, the
|
231 |
+
original copyright holder who places the Program under this License
|
232 |
+
may add an explicit geographical distribution limitation excluding
|
233 |
+
those countries, so that distribution is permitted only in or among
|
234 |
+
countries not thus excluded. In such case, this License incorporates
|
235 |
+
the limitation as if written in the body of this License.
|
236 |
+
|
237 |
+
9. The Free Software Foundation may publish revised and/or new versions
|
238 |
+
of the General Public License from time to time. Such new versions will
|
239 |
+
be similar in spirit to the present version, but may differ in detail to
|
240 |
+
address new problems or concerns.
|
241 |
+
|
242 |
+
Each version is given a distinguishing version number. If the Program
|
243 |
+
specifies a version number of this License which applies to it and "any
|
244 |
+
later version", you have the option of following the terms and conditions
|
245 |
+
either of that version or of any later version published by the Free
|
246 |
+
Software Foundation. If the Program does not specify a version number of
|
247 |
+
this License, you may choose any version ever published by the Free Software
|
248 |
+
Foundation.
|
249 |
+
|
250 |
+
10. If you wish to incorporate parts of the Program into other free
|
251 |
+
programs whose distribution conditions are different, write to the author
|
252 |
+
to ask for permission. For software which is copyrighted by the Free
|
253 |
+
Software Foundation, write to the Free Software Foundation; we sometimes
|
254 |
+
make exceptions for this. Our decision will be guided by the two goals
|
255 |
+
of preserving the free status of all derivatives of our free software and
|
256 |
+
of promoting the sharing and reuse of software generally.
|
257 |
+
|
258 |
+
NO WARRANTY
|
259 |
+
|
260 |
+
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
261 |
+
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
|
262 |
+
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
|
263 |
+
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
|
264 |
+
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
265 |
+
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
|
266 |
+
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
267 |
+
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
|
268 |
+
REPAIR OR CORRECTION.
|
269 |
+
|
270 |
+
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
271 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
272 |
+
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
273 |
+
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
274 |
+
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
275 |
+
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
276 |
+
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
277 |
+
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
278 |
+
POSSIBILITY OF SUCH DAMAGES.
|
279 |
+
|
280 |
+
END OF TERMS AND CONDITIONS
|
281 |
+
|
282 |
+
How to Apply These Terms to Your New Programs
|
283 |
+
|
284 |
+
If you develop a new program, and you want it to be of the greatest
|
285 |
+
possible use to the public, the best way to achieve this is to make it
|
286 |
+
free software which everyone can redistribute and change under these terms.
|
287 |
+
|
288 |
+
To do so, attach the following notices to the program. It is safest
|
289 |
+
to attach them to the start of each source file to most effectively
|
290 |
+
convey the exclusion of warranty; and each file should have at least
|
291 |
+
the "copyright" line and a pointer to where the full notice is found.
|
292 |
+
|
293 |
+
{description}
|
294 |
+
Copyright (C) {year} {fullname}
|
295 |
+
|
296 |
+
This program is free software; you can redistribute it and/or modify
|
297 |
+
it under the terms of the GNU General Public License as published by
|
298 |
+
the Free Software Foundation; either version 2 of the License, or
|
299 |
+
(at your option) any later version.
|
300 |
+
|
301 |
+
This program is distributed in the hope that it will be useful,
|
302 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
303 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
304 |
+
GNU General Public License for more details.
|
305 |
+
|
306 |
+
You should have received a copy of the GNU General Public License along
|
307 |
+
with this program; if not, write to the Free Software Foundation, Inc.,
|
308 |
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
309 |
+
|
310 |
+
Also add information on how to contact you by electronic and paper mail.
|
311 |
+
|
312 |
+
If the program is interactive, make it output a short notice like this
|
313 |
+
when it starts in an interactive mode:
|
314 |
+
|
315 |
+
Gnomovision version 69, Copyright (C) year name of author
|
316 |
+
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
317 |
+
This is free software, and you are welcome to redistribute it
|
318 |
+
under certain conditions; type `show c' for details.
|
319 |
+
|
320 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
321 |
+
parts of the General Public License. Of course, the commands you use may
|
322 |
+
be called something other than `show w' and `show c'; they could even be
|
323 |
+
mouse-clicks or menu items--whatever suits your program.
|
324 |
+
|
325 |
+
You should also get your employer (if you work as a programmer) or your
|
326 |
+
school, if any, to sign a "copyright disclaimer" for the program, if
|
327 |
+
necessary. Here is a sample; alter the names:
|
328 |
+
|
329 |
+
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
|
330 |
+
`Gnomovision' (which makes passes at compilers) written by James Hacker.
|
331 |
+
|
332 |
+
{signature of Ty Coon}, 1 April 1989
|
333 |
+
Ty Coon, President of Vice
|
334 |
+
|
335 |
+
This General Public License does not permit incorporating your program into
|
336 |
+
proprietary programs. If your program is a subroutine library, you may
|
337 |
+
consider it more useful to permit linking proprietary applications with the
|
338 |
+
library. If this is what you want to do, use the GNU Lesser General
|
339 |
+
Public License instead of this License.
|
340 |
+
|
class-reorder-admin.php
ADDED
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Reorder posts
|
4 |
+
*
|
5 |
+
* @package WordPress
|
6 |
+
* @subpackage Metronet Reorder Posts plugin
|
7 |
+
*/
|
8 |
+
|
9 |
+
|
10 |
+
/**
|
11 |
+
* Reorder posts
|
12 |
+
* Adds drag and drop editor for reordering WordPress posts
|
13 |
+
*
|
14 |
+
* This class is self-instantiated and should not be used directly
|
15 |
+
*
|
16 |
+
* @license http://www.gnu.org/licenses/gpl.html GPL
|
17 |
+
* @author Ronald Huereca
|
18 |
+
* @since 2.0.0
|
19 |
+
*/
|
20 |
+
class Reorder_Admin {
|
21 |
+
/**
|
22 |
+
* @var $instance
|
23 |
+
* @desc Instance of the admin class
|
24 |
+
* @access private
|
25 |
+
*/
|
26 |
+
private static $instance = null;
|
27 |
+
|
28 |
+
/**
|
29 |
+
* @var $options
|
30 |
+
* @desc WordPress options for access within this class
|
31 |
+
* @access private
|
32 |
+
*/
|
33 |
+
private $options = false;
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Class constructor
|
37 |
+
*
|
38 |
+
* Sets definitions
|
39 |
+
* Adds methods to appropriate hooks
|
40 |
+
*
|
41 |
+
* @author Ronald Huereca
|
42 |
+
* @since Reorder 1.1
|
43 |
+
* @access private
|
44 |
+
*/
|
45 |
+
private function __construct( ) {
|
46 |
+
//Filter to hide the admin panel options
|
47 |
+
if ( !apply_filters( 'metronet_reorder_post_allow_admin', true ) ) return; //Use this filter if you want to disable the admin panel settings for this plugin, including disabling the menu order overrides
|
48 |
+
|
49 |
+
//Initialize actions
|
50 |
+
/* Dev note: If you know what you're doing code-wise, add the menu_order in get_posts, pre_get_posts, or WP_Query, disable these filters, and/or disable the admin settings (see above). */
|
51 |
+
add_filter( 'posts_orderby', array( $this, 'modify_menu_order_sql' ), 30, 2 );
|
52 |
+
add_action( 'pre_get_posts', array( $this, 'modify_menu_order_pre' ), 30, 1 );
|
53 |
+
|
54 |
+
//Admin Settings
|
55 |
+
add_action( 'admin_menu', array( $this, 'add_admin_menu' ) );
|
56 |
+
add_action( 'admin_init', array( $this, 'init_admin_settings' ) );
|
57 |
+
|
58 |
+
//Plugin settings
|
59 |
+
add_filter( 'plugin_action_links_' . REORDER_BASENAME , array( $this, 'add_settings_link' ) );
|
60 |
+
}
|
61 |
+
|
62 |
+
//Singleton
|
63 |
+
public static function get_instance() {
|
64 |
+
if ( null == self::$instance ) {
|
65 |
+
self::$instance = new self;
|
66 |
+
}
|
67 |
+
return self::$instance;
|
68 |
+
} //end get_instance
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Initialize options page
|
72 |
+
*
|
73 |
+
* Create plugin options page and callback
|
74 |
+
*
|
75 |
+
* @since 2.0.0
|
76 |
+
* @access public
|
77 |
+
*
|
78 |
+
* @see init
|
79 |
+
*
|
80 |
+
*/
|
81 |
+
public function add_admin_menu() {
|
82 |
+
add_options_page( _x( 'Reorder Posts', 'Plugin Name - Settings Page Title', 'metronet-reorder-posts' ), _x( 'Reorder Posts', 'Plugin Name - Menu Item', 'metronet-reorder-posts' ), 'manage_options', 'metronet-reorder-posts', array( $this, 'options_page' ) );
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Add post types to be overridden using menu_order
|
87 |
+
*
|
88 |
+
* Output options for menu_order
|
89 |
+
*
|
90 |
+
* @since 1.0.0
|
91 |
+
* @access public
|
92 |
+
*
|
93 |
+
* @see init_admin_settings
|
94 |
+
*
|
95 |
+
* @param array $args {
|
96 |
+
@type string $desc Description for the setting.
|
97 |
+
|
98 |
+
}
|
99 |
+
*/
|
100 |
+
public function add_settings_field_menu_order( $args = array() ) {
|
101 |
+
//Get options/defaults
|
102 |
+
$settings = $this->get_plugin_options();
|
103 |
+
$settings_menu_order = isset( $settings[ 'menu_order' ] ) ? $settings[ 'menu_order' ] : array();
|
104 |
+
$post_types = get_post_types( array(), 'object' );
|
105 |
+
|
106 |
+
//Foreach loop to show de awesome post types
|
107 |
+
foreach( $post_types as $post_type_name => $post_type ) {
|
108 |
+
|
109 |
+
//Determine whether to show this post type (show_ui = true)
|
110 |
+
$show_ui = (bool)isset( $post_type->show_ui ) ? $post_type->show_ui : false;
|
111 |
+
if ( !$show_ui || 'attachment' === $post_type_name ) continue;
|
112 |
+
|
113 |
+
//Get post type labels for checkbox
|
114 |
+
$post_type_value = isset( $settings_post_types[ $post_type_name ] ) ? $settings_post_types[ $post_type_name ] : 'on';
|
115 |
+
$post_type_label = isset( $post_type->label ) ? $post_type->label : $post_type_name;
|
116 |
+
printf( '<div id="metronet-reorder-posts-%s">', esc_attr( $post_type_name ) );
|
117 |
+
printf( '<h3>%s</h3>', esc_html( $post_type_label ) );
|
118 |
+
|
119 |
+
//Get menu order arguments
|
120 |
+
$menu_orderby = isset( $settings_menu_order[ $post_type_name ][ 'orderby' ] ) ? $settings_menu_order[ $post_type_name ][ 'orderby' ] : 'none';
|
121 |
+
|
122 |
+
//Output Menu Order Arguments
|
123 |
+
printf( '<p>%s</p>', esc_html__( 'Sort by:', 'metronet-reorder-posts' ) );
|
124 |
+
printf( '<select name="metronet-reorder-posts[menu_order][%1$s][orderby]">', esc_attr( $post_type_name ) );
|
125 |
+
printf( '<option value="none" %s>%s</option>', selected( 'none', $menu_orderby, false ), esc_html__( 'None', 'metronet-reorder-posts' ) );
|
126 |
+
printf( '<option value="menu_order" %s>%s</option>', selected( 'menu_order', $menu_orderby, false ), esc_html__( 'Menu Order', 'metronet-reorder-posts' ) );
|
127 |
+
echo '</select>';
|
128 |
+
|
129 |
+
//Get order arguments
|
130 |
+
$menu_order = isset( $settings_menu_order[ $post_type_name ][ 'order' ] ) ? $settings_menu_order[ $post_type_name ][ 'order' ] : 'DESC'; //DESC is WP_Query default
|
131 |
+
//Output Menu Order Arguments
|
132 |
+
printf( '<p>%s</p>', esc_html__( 'Sort Order:', 'metronet-reorder-posts' ) );
|
133 |
+
printf( '<select name="metronet-reorder-posts[menu_order][%1$s][order]">', esc_attr( $post_type_name ) );
|
134 |
+
printf( '<option value="ASC" %s>%s</option>', selected( 'ASC', $menu_order, false ), esc_html__( 'ASC', 'metronet-reorder-posts' ) );
|
135 |
+
printf( '<option value="DESC" %s>%s</option>', selected( 'DESC', $menu_order, false ), esc_html__( 'DESC', 'metronet-reorder-posts' ) );
|
136 |
+
echo '</select>';
|
137 |
+
|
138 |
+
//Output closing div
|
139 |
+
echo '</div>';
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* Add post types to be reordered using the plugin
|
145 |
+
*
|
146 |
+
* Output checkboxes for post types
|
147 |
+
*
|
148 |
+
* @since 1.0.0
|
149 |
+
* @access public
|
150 |
+
*
|
151 |
+
* @see init_admin_settings
|
152 |
+
*
|
153 |
+
* @param array $args {
|
154 |
+
@type string $desc Description for the setting.
|
155 |
+
|
156 |
+
}
|
157 |
+
*/
|
158 |
+
public function add_settings_field_post_types( $args = array() ) {
|
159 |
+
//Get options/defaults
|
160 |
+
$settings = $this->get_plugin_options();
|
161 |
+
$settings_post_types = isset( $settings[ 'post_types' ] ) ? $settings[ 'post_types' ] : array();
|
162 |
+
$post_types = get_post_types( array(), 'object' );
|
163 |
+
|
164 |
+
//Foreach loop to show de awesome post types
|
165 |
+
foreach( $post_types as $post_type_name => $post_type ) {
|
166 |
+
|
167 |
+
//Determine whether to show this post type (show_ui = true)
|
168 |
+
$show_ui = (bool)isset( $post_type->show_ui ) ? $post_type->show_ui : false;
|
169 |
+
if ( !$show_ui || 'attachment' === $post_type_name ) continue;
|
170 |
+
|
171 |
+
//Get post type labels for checkbox
|
172 |
+
$post_type_value = isset( $settings_post_types[ $post_type_name ] ) ? $settings_post_types[ $post_type_name ] : 'on';
|
173 |
+
$post_type_label = isset( $post_type->label ) ? $post_type->label : $post_type_name;
|
174 |
+
$checked = '';
|
175 |
+
if ( $post_type_value === 'on' ) {
|
176 |
+
$checked = checked( true, true, false );
|
177 |
+
}
|
178 |
+
|
179 |
+
//Output post type option
|
180 |
+
printf( '<div><input type="hidden" name="metronet-reorder-posts[post_types][%1$s]" value="off" /> <input type="checkbox" name="metronet-reorder-posts[post_types][%1$s]" id="post_type_%1$s" value="on" %2$s /><label for="post_type_%1$s"> %3$s</label></div>', esc_attr( $post_type_name ), $checked, esc_html( $post_type_label ) );
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
public function add_settings_heading_menu_order() {
|
185 |
+
printf( '<p>%s</p>', esc_html__( 'These are advanced options and you should only use these if you know what you are doing. These can overwrite the menu orders of custom queries (using get_posts or WP_Query), custom post type archives, and even the order your blog posts display.', 'metronet-reorder-posts' ) );
|
186 |
+
}
|
187 |
+
/**
|
188 |
+
* Add a settings link to the plugin's options.
|
189 |
+
*
|
190 |
+
* Add a settings link on the WordPress plugin's page.
|
191 |
+
*
|
192 |
+
* @since 2.0.0
|
193 |
+
* @access public
|
194 |
+
*
|
195 |
+
* @see init
|
196 |
+
*
|
197 |
+
* @param array $links Array of plugin options
|
198 |
+
* @return array $links Array of plugin options
|
199 |
+
*/
|
200 |
+
public function add_settings_link( $links ) {
|
201 |
+
$settings_link = sprintf( '<a href="%s">%s</a>', esc_url( admin_url( 'options-general.php?page=metronet-reorder-posts' ) ), _x( 'Settings', 'Plugin settings link on the plugins page', 'metronet-reorder-posts' ) );
|
202 |
+
array_unshift($links, $settings_link);
|
203 |
+
return $links;
|
204 |
+
}
|
205 |
+
|
206 |
+
/**
|
207 |
+
* Initialize and return plugin options.
|
208 |
+
*
|
209 |
+
* Return an array of plugin options.
|
210 |
+
*
|
211 |
+
* @since 1.0.0
|
212 |
+
* @access public
|
213 |
+
*
|
214 |
+
* @see init
|
215 |
+
*
|
216 |
+
* @return array Plugin options
|
217 |
+
*/
|
218 |
+
public function get_plugin_options() {
|
219 |
+
if ( false === $this->options ) {
|
220 |
+
$settings = get_option( 'metronet-reorder-posts' );
|
221 |
+
} else {
|
222 |
+
$settings = $this->options;
|
223 |
+
}
|
224 |
+
|
225 |
+
if ( false === $settings || !is_array( $settings ) ) {
|
226 |
+
$defaults = array(
|
227 |
+
'post_types' => array(),
|
228 |
+
'menu_order' => array(),
|
229 |
+
);
|
230 |
+
update_option( 'metronet-reorder-posts', $defaults );
|
231 |
+
return $defaults;
|
232 |
+
}
|
233 |
+
$this->options = $settings;
|
234 |
+
return $settings;
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* Initialize options
|
239 |
+
*
|
240 |
+
* Initialize page settings, fields, and sections and their callbacks
|
241 |
+
*
|
242 |
+
* @since 2.0.0
|
243 |
+
* @access public
|
244 |
+
*
|
245 |
+
* @see init
|
246 |
+
*
|
247 |
+
*/
|
248 |
+
public function init_admin_settings() {
|
249 |
+
register_setting( 'metronet-reorder-posts', 'metronet-reorder-posts', array( $this, 'sanitization' ) );
|
250 |
+
|
251 |
+
add_settings_section( 'mn-reorder-post-types', _x( 'Enable Post Types', 'plugin settings heading' , 'metronet-reorder-posts' ), '__return_empty_string', 'metronet-reorder-posts' );
|
252 |
+
|
253 |
+
add_settings_section( 'mn-reorder-menu-order', _x( 'Advanced', 'plugin settings heading' , 'metronet-reorder-posts' ), array( $this, 'add_settings_heading_menu_order' ), 'metronet-reorder-posts' );
|
254 |
+
|
255 |
+
add_settings_field( 'mn-post-types', __( 'Post Types', 'metronet-reorder-posts' ), array( $this, 'add_settings_field_post_types' ), 'metronet-reorder-posts', 'mn-reorder-post-types', array( 'desc' => __( 'Select the post types you would like this plugin enabled for.', 'metronet-reorder-posts' ) ) );
|
256 |
+
|
257 |
+
add_settings_field( 'mn-menu-order', __( 'Select the menu order arguments.', 'metronet-reorder-posts' ), array( $this, 'add_settings_field_menu_order' ), 'metronet-reorder-posts', 'mn-reorder-menu-order', array( 'desc' => __( 'Select the menu order for the post types.', 'metronet-reorder-posts' ) ) );
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
//Used for get_posts calls
|
262 |
+
public function modify_menu_order_pre( $query ) {
|
263 |
+
if( $query->is_main_query() || is_admin() || is_feed() ) return;
|
264 |
+
|
265 |
+
if ( !apply_filters( 'metronet_reorder_allow_menu_order', true ) ) return; //Return false to disable this completely
|
266 |
+
|
267 |
+
//Get main plugin options
|
268 |
+
$plugin_options = $this->get_plugin_options();
|
269 |
+
if ( !isset( $plugin_options[ 'menu_order' ] ) || !is_array( $plugin_options[ 'menu_order' ] ) || empty( $plugin_options[ 'menu_order' ] ) ) return;
|
270 |
+
$menu_order = $plugin_options[ 'menu_order' ];
|
271 |
+
|
272 |
+
//Get main post type
|
273 |
+
$main_query = $query->query;
|
274 |
+
$post_type = false;
|
275 |
+
if( isset( $main_query[ 'post_type' ] ) ) {
|
276 |
+
//Typically set on post type archives or custom WP_Query or get_posts instances
|
277 |
+
$post_type = $main_query[ 'post_type' ];
|
278 |
+
}
|
279 |
+
if ( !$post_type ) return;
|
280 |
+
|
281 |
+
//See if suppress filters is on (using get_posts) (if it's not, use modify_menu_order_sql for that)
|
282 |
+
if ( !isset( $main_query[ 'suppress_filters' ] ) ) return;
|
283 |
+
|
284 |
+
if ( !apply_filters( 'metronet_reorder_allow_menu_order_' . $post_type, true ) ) return; //Return false to disable this for each individual post type as opposed to using a global filter above
|
285 |
+
|
286 |
+
//See if we're modifying the menu_order
|
287 |
+
$menu_order_orderby = isset( $menu_order[ $post_type ][ 'orderby' ] ) ? $menu_order[ $post_type ][ 'orderby' ] : 'none';
|
288 |
+
$menu_order_order = isset( $menu_order[ $post_type ][ 'order' ] ) ? $menu_order[ $post_type ][ 'order' ] : 'DESC';
|
289 |
+
|
290 |
+
//Return if post type is not be ordered
|
291 |
+
if ( $menu_order_orderby === 'none' ) return;
|
292 |
+
|
293 |
+
//Return of $menu_order_order is invalid
|
294 |
+
if ( $menu_order_order !== 'ASC' && $menu_order_order !== 'DESC' ) return;
|
295 |
+
|
296 |
+
//Overwrite the orderby clause
|
297 |
+
$query->set( 'orderby', 'menu_order' );
|
298 |
+
$query->set( 'order', $menu_order_order );
|
299 |
+
}
|
300 |
+
|
301 |
+
//Used on homepage archives, post type archives, or custom WP_Query calls
|
302 |
+
public function modify_menu_order_sql( $sql_orderby, $query ) {
|
303 |
+
if ( is_admin() || is_404() || is_feed() ) return $sql_orderby;
|
304 |
+
|
305 |
+
if ( !apply_filters( 'metronet_reorder_allow_menu_order', true ) ) return $sql_orderby; //Return false to disable this completely
|
306 |
+
|
307 |
+
//Get main plugin options
|
308 |
+
$plugin_options = $this->get_plugin_options();
|
309 |
+
if ( !isset( $plugin_options[ 'menu_order' ] ) || !is_array( $plugin_options[ 'menu_order' ] ) || empty( $plugin_options[ 'menu_order' ] ) ) return $sql_orderby;
|
310 |
+
|
311 |
+
$menu_order = $plugin_options[ 'menu_order' ];
|
312 |
+
|
313 |
+
$main_query = $query->query;
|
314 |
+
|
315 |
+
//Get main post type - Try to get post_type first, if not, see if we're on the main page showing blog posts
|
316 |
+
$post_type = false;
|
317 |
+
if( isset( $main_query[ 'post_type' ] ) ) {
|
318 |
+
//Typically set on post type archives or custom WP_Query or get_posts instances
|
319 |
+
$post_type = $main_query[ 'post_type' ];
|
320 |
+
} elseif ( is_home() ) {
|
321 |
+
$post_type = 'post';
|
322 |
+
}
|
323 |
+
if ( !$post_type ) return $sql_orderby;
|
324 |
+
|
325 |
+
if ( !apply_filters( 'metronet_reorder_allow_menu_order_' . $post_type, true ) ) return $sql_orderby; //Return false to disable this for each individual post type as opposed to using a global filter above
|
326 |
+
|
327 |
+
//See if we're modifying the menu_order
|
328 |
+
$menu_order_orderby = isset( $menu_order[ $post_type ][ 'orderby' ] ) ? $menu_order[ $post_type ][ 'orderby' ] : 'none';
|
329 |
+
$menu_order_order = isset( $menu_order[ $post_type ][ 'order' ] ) ? $menu_order[ $post_type ][ 'order' ] : 'DESC';
|
330 |
+
|
331 |
+
//Return if post type is not be ordered
|
332 |
+
if ( $menu_order_orderby === 'none' ) return $sql_orderby;
|
333 |
+
|
334 |
+
//Return of $menu_order_order is invalid
|
335 |
+
if ( $menu_order_order !== 'ASC' && $menu_order_order !== 'DESC' ) return $sql_orderby;
|
336 |
+
|
337 |
+
//Overwrite the orderby clause
|
338 |
+
global $wpdb;
|
339 |
+
$sql_orderby = sprintf( '%s.menu_order %s', $wpdb->posts, $menu_order_order ); //for devs: no sanitization required as tablename is from $wpdb and $menu_order_order is set to match only ASC or DESC.
|
340 |
+
|
341 |
+
//Return
|
342 |
+
return $sql_orderby;
|
343 |
+
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Output options page HTML.
|
348 |
+
*
|
349 |
+
* Output option page HTML and fields/sections.
|
350 |
+
*
|
351 |
+
* @since 2.0.0
|
352 |
+
* @access public
|
353 |
+
*
|
354 |
+
* @see add_admin_menu
|
355 |
+
*
|
356 |
+
*/
|
357 |
+
public function options_page() {
|
358 |
+
?>
|
359 |
+
<div class="wrap">
|
360 |
+
<h2><?php echo esc_html( _x( 'Reorder Posts', 'Plugin Name - Settings Page Title', 'metronet-reorder-posts' ) ); ?></h2>
|
361 |
+
<form action="<?php echo esc_url( admin_url( 'options.php' ) ); ?>" method="POST">
|
362 |
+
<?php settings_fields( 'metronet-reorder-posts' ); ?>
|
363 |
+
<?php do_settings_sections( 'metronet-reorder-posts' ); ?>
|
364 |
+
<?php submit_button(); ?>
|
365 |
+
</form>
|
366 |
+
</div>
|
367 |
+
<?php
|
368 |
+
}
|
369 |
+
|
370 |
+
/**
|
371 |
+
* Sanitize options before they are saved.
|
372 |
+
*
|
373 |
+
* Sanitize and prepare error messages when saving options.
|
374 |
+
*
|
375 |
+
* @since 2.0.0
|
376 |
+
* @access public
|
377 |
+
*
|
378 |
+
* @see init_admin_settings
|
379 |
+
*
|
380 |
+
* @param array $input {
|
381 |
+
@type array $post_types
|
382 |
+
@type array $menu_order
|
383 |
+
}
|
384 |
+
* @return array Sanitized array of options
|
385 |
+
*/
|
386 |
+
public function sanitization( $input = array() ) {
|
387 |
+
//Get post type options
|
388 |
+
$post_types = $input[ 'post_types' ];
|
389 |
+
if ( !empty( $post_types ) ) {
|
390 |
+
foreach( $post_types as $post_type_name => &$value ) {
|
391 |
+
if ( $value !== 'on' ) {
|
392 |
+
$value == 'off';
|
393 |
+
}
|
394 |
+
}
|
395 |
+
$input[ 'post_types' ] = $post_types;
|
396 |
+
}
|
397 |
+
|
398 |
+
//Get menu order options
|
399 |
+
$menu_order = $input[ 'menu_order' ];
|
400 |
+
if ( !empty( $menu_order ) ) {
|
401 |
+
foreach( $post_types as $post_type_name => &$values ) {
|
402 |
+
$orderby = isset( $values[ 'orderby' ] ) ? $values[ 'orderby' ] : 'none';
|
403 |
+
if ( $orderby !== 'menu_order' ) {
|
404 |
+
$values[ 'orderby' ] == 'none';
|
405 |
+
}
|
406 |
+
|
407 |
+
$order = isset( $values[ 'order' ] ) ? $values[ 'order' ] : 'DESC';
|
408 |
+
if ( $orderby !== 'ASC' ) {
|
409 |
+
$values[ 'order' ] == 'DESC';
|
410 |
+
}
|
411 |
+
}
|
412 |
+
$input[ 'menu_order' ] = $menu_order;
|
413 |
+
|
414 |
+
}
|
415 |
+
return $input;
|
416 |
+
}
|
417 |
+
|
418 |
+
} //end class Reorder_Admin
|
419 |
+
|
420 |
+
add_action( 'init', 'mn_reorder_admin_instantiate', 15 );
|
421 |
+
function mn_reorder_admin_instantiate() {
|
422 |
+
Reorder_Admin::get_instance();
|
423 |
+
}
|
class-reorder.php
CHANGED
@@ -78,13 +78,6 @@ class Reorder {
|
|
78 |
* @access private
|
79 |
*/
|
80 |
private $menu_label;
|
81 |
-
|
82 |
-
/**
|
83 |
-
* @var $icon
|
84 |
-
* @desc Admin page icon
|
85 |
-
* @access private
|
86 |
-
*/
|
87 |
-
private $icon;
|
88 |
|
89 |
/**
|
90 |
* Class constructor
|
@@ -103,7 +96,7 @@ class Reorder {
|
|
103 |
$defaults = array(
|
104 |
'post_type' => 'post', // Setting the post type to be reordered
|
105 |
'order' => 'ASC', // Setting the order of the posts
|
106 |
-
'heading' => __( 'Reorder', 'reorder' ), // Default text for heading
|
107 |
'initial' => '', // Initial text displayed before sorting code
|
108 |
'final' => '', // Initial text displayed before sorting code
|
109 |
'post_status' => 'publish', // Post status of posts to be reordered
|
@@ -117,7 +110,6 @@ class Reorder {
|
|
117 |
$this->initial = $initial;
|
118 |
$this->final = $final;
|
119 |
$this->menu_label = $menu_label;
|
120 |
-
$this->icon = $icon;
|
121 |
$this->post_status = $post_status;
|
122 |
$this->page_hook = $post_type . '_page_reorder-video';
|
123 |
|
@@ -147,7 +139,7 @@ class Reorder {
|
|
147 |
//Iterate through post data
|
148 |
$this->update_posts( $post_data, 0 );
|
149 |
|
150 |
-
die( json_encode( array( 'success' => '
|
151 |
} //end ajax_save_post_order
|
152 |
|
153 |
/**
|
@@ -193,7 +185,7 @@ class Reorder {
|
|
193 |
$pages = array( 'edit.php' );
|
194 |
|
195 |
if ( in_array( $pagenow, $pages ) )
|
196 |
-
wp_enqueue_style( 'reorderpages_style', REORDER_URL . '/admin.css' );
|
197 |
|
198 |
}
|
199 |
|
@@ -288,7 +280,7 @@ class Reorder {
|
|
288 |
setup_postdata( $post );
|
289 |
?>
|
290 |
<li id="list_<?php the_id(); ?>">
|
291 |
-
<div><?php the_title(); ?> <a href='#' style="float: right"><?php esc_html_e( 'Expand', 'reorder' ); ?></a></div>
|
292 |
<ul class='children'>
|
293 |
<?php $this->output_row_children( $post_children, $all_children ); ?>
|
294 |
</ul>
|
@@ -332,13 +324,8 @@ class Reorder {
|
|
332 |
*/
|
333 |
public function sort_posts() {
|
334 |
?>
|
335 |
-
<style type="text/css">
|
336 |
-
#icon-reorder-posts {
|
337 |
-
background:url(<?php echo $this->icon; ?>) no-repeat;
|
338 |
-
}
|
339 |
</style>
|
340 |
<div class="wrap">
|
341 |
-
<?php screen_icon( 'reorder-posts' ); ?>
|
342 |
<h2>
|
343 |
<?php echo $this->heading; ?>
|
344 |
<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" id="loading-animation" />
|
78 |
* @access private
|
79 |
*/
|
80 |
private $menu_label;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
|
82 |
/**
|
83 |
* Class constructor
|
96 |
$defaults = array(
|
97 |
'post_type' => 'post', // Setting the post type to be reordered
|
98 |
'order' => 'ASC', // Setting the order of the posts
|
99 |
+
'heading' => __( 'Reorder', 'metronet-reorder-posts' ), // Default text for heading
|
100 |
'initial' => '', // Initial text displayed before sorting code
|
101 |
'final' => '', // Initial text displayed before sorting code
|
102 |
'post_status' => 'publish', // Post status of posts to be reordered
|
110 |
$this->initial = $initial;
|
111 |
$this->final = $final;
|
112 |
$this->menu_label = $menu_label;
|
|
|
113 |
$this->post_status = $post_status;
|
114 |
$this->page_hook = $post_type . '_page_reorder-video';
|
115 |
|
139 |
//Iterate through post data
|
140 |
$this->update_posts( $post_data, 0 );
|
141 |
|
142 |
+
die( json_encode( array( 'success' => 'true' ) ) );
|
143 |
} //end ajax_save_post_order
|
144 |
|
145 |
/**
|
185 |
$pages = array( 'edit.php' );
|
186 |
|
187 |
if ( in_array( $pagenow, $pages ) )
|
188 |
+
wp_enqueue_style( 'reorderpages_style', REORDER_URL . '/css/admin.css' );
|
189 |
|
190 |
}
|
191 |
|
280 |
setup_postdata( $post );
|
281 |
?>
|
282 |
<li id="list_<?php the_id(); ?>">
|
283 |
+
<div><?php the_title(); ?> <a href='#' style="float: right"><?php esc_html_e( 'Expand', 'metronet-reorder-posts' ); ?></a></div>
|
284 |
<ul class='children'>
|
285 |
<?php $this->output_row_children( $post_children, $all_children ); ?>
|
286 |
</ul>
|
324 |
*/
|
325 |
public function sort_posts() {
|
326 |
?>
|
|
|
|
|
|
|
|
|
327 |
</style>
|
328 |
<div class="wrap">
|
|
|
329 |
<h2>
|
330 |
<?php echo $this->heading; ?>
|
331 |
<img src="<?php echo admin_url( 'images/loading.gif' ); ?>" id="loading-animation" />
|
admin.css → css/admin.css
RENAMED
@@ -14,9 +14,18 @@
|
|
14 |
background: -ms-linear-gradient(top, #f7f7f7, #e7e7e7); /* for IE 10+ */
|
15 |
cursor: move;
|
16 |
border: 1px solid #ddd;
|
17 |
-
border-raidus:
|
18 |
-
-moz-border-radius:
|
19 |
-
-webkit-border-radius:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
#post-list ul {
|
22 |
padding-left: 40px;
|
14 |
background: -ms-linear-gradient(top, #f7f7f7, #e7e7e7); /* for IE 10+ */
|
15 |
cursor: move;
|
16 |
border: 1px solid #ddd;
|
17 |
+
border-raidus: 5px;
|
18 |
+
-moz-border-radius: 5px;
|
19 |
+
-webkit-border-radius: 5px;
|
20 |
+
}
|
21 |
+
#post-list div:hover {
|
22 |
+
background: #f0f0f0; /* for non-css3 browsers */
|
23 |
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f7f7f7', endColorstr='#d8d8d8'); /* for IE 9 or older */
|
24 |
+
background: -webkit-gradient(linear, left top, left bottom, from(#f7f7f7), to(#d8d8d8)); /* for WebKit */
|
25 |
+
background: -webkit-linear-gradient(top, #f7f7f7, #d8d8d8); /* for newer versions of WebKit */
|
26 |
+
background: -moz-linear-gradient(top, #f7f7f7, #d8d8d8); /* for Firefox 3.6+ */
|
27 |
+
background: -o-linear-gradient(top, #f7f7f7, #d8d8d8); /* for Opera 11.1+ */
|
28 |
+
background: -ms-linear-gradient(top, #f7f7f7, #d8d8d8); /* for IE 10+ */
|
29 |
}
|
30 |
#post-list ul {
|
31 |
padding-left: 40px;
|
css/index.php
ADDED
File without changes
|
index.php
CHANGED
@@ -3,9 +3,11 @@
|
|
3 |
Plugin Name: Metronet Reorder Posts
|
4 |
Plugin URI: https://wordpress.org/plugins/metronet-reorder-posts/
|
5 |
Description: Reorder posts
|
6 |
-
Version:
|
7 |
-
Author: Ryan Hellyer
|
8 |
Author URI: http://geek.ryanhellyer.net/
|
|
|
|
|
9 |
|
10 |
------------------------------------------------------------------------
|
11 |
This program is free software; you can redistribute it and/or modify
|
@@ -40,6 +42,7 @@ if ( !defined( 'ABSPATH' ) )
|
|
40 |
* @author Ryan Hellyer <ryan@metronet.no>
|
41 |
*/
|
42 |
require( 'class-reorder.php' );
|
|
|
43 |
|
44 |
/**
|
45 |
* Define constants
|
@@ -49,6 +52,7 @@ require( 'class-reorder.php' );
|
|
49 |
*/
|
50 |
define( 'REORDER_DIR', rtrim( plugin_dir_path(__FILE__), '/' ) ); // Plugin folder DIR
|
51 |
define( 'REORDER_URL', rtrim( plugin_dir_url(__FILE__), '/' ) ); // Plugin folder URL
|
|
|
52 |
|
53 |
/**
|
54 |
* Instantiate admin panel
|
@@ -59,7 +63,17 @@ define( 'REORDER_URL', rtrim( plugin_dir_url(__FILE__), '/' ) ); // Plugin folde
|
|
59 |
*/
|
60 |
add_action( 'wp_loaded', 'mn_reorder_posts_init', 100 ); //Load low priority in init for other plugins to generate their post types
|
61 |
function mn_reorder_posts_init() {
|
62 |
-
$post_types = get_post_types(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
|
64 |
// Add filter to allow users to control which post-types the plugin is used with via their theme
|
65 |
$post_types = apply_filters( 'metronet_reorder_post_types', $post_types );
|
@@ -71,14 +85,19 @@ function mn_reorder_posts_init() {
|
|
71 |
array(
|
72 |
'post_type' => $post_type,
|
73 |
'order' => 'ASC',
|
74 |
-
'heading' => __( '
|
75 |
'final' => '',
|
76 |
'initial' => '',
|
77 |
-
'menu_label' => __( 'Reorder', 'reorder' ),
|
78 |
-
'icon' => REORDER_URL . '/metronet-icon.png',
|
79 |
'post_status' => 'publish',
|
80 |
)
|
81 |
);
|
82 |
}
|
83 |
} //end mt_reorder_posts_init
|
84 |
|
|
|
|
|
|
|
|
|
|
|
|
3 |
Plugin Name: Metronet Reorder Posts
|
4 |
Plugin URI: https://wordpress.org/plugins/metronet-reorder-posts/
|
5 |
Description: Reorder posts
|
6 |
+
Version: 2.0.0
|
7 |
+
Author: Ryan Hellyer, Ronald Huereca
|
8 |
Author URI: http://geek.ryanhellyer.net/
|
9 |
+
Text Domain: metronet-reorder-posts
|
10 |
+
Domain Path: /languages
|
11 |
|
12 |
------------------------------------------------------------------------
|
13 |
This program is free software; you can redistribute it and/or modify
|
42 |
* @author Ryan Hellyer <ryan@metronet.no>
|
43 |
*/
|
44 |
require( 'class-reorder.php' );
|
45 |
+
require( 'class-reorder-admin.php' );
|
46 |
|
47 |
/**
|
48 |
* Define constants
|
52 |
*/
|
53 |
define( 'REORDER_DIR', rtrim( plugin_dir_path(__FILE__), '/' ) ); // Plugin folder DIR
|
54 |
define( 'REORDER_URL', rtrim( plugin_dir_url(__FILE__), '/' ) ); // Plugin folder URL
|
55 |
+
define( 'REORDER_BASENAME', plugin_basename(__FILE__) ); //Plugin basename
|
56 |
|
57 |
/**
|
58 |
* Instantiate admin panel
|
63 |
*/
|
64 |
add_action( 'wp_loaded', 'mn_reorder_posts_init', 100 ); //Load low priority in init for other plugins to generate their post types
|
65 |
function mn_reorder_posts_init() {
|
66 |
+
$post_types = get_post_types( array(), 'names' );
|
67 |
+
|
68 |
+
//Get plugin options for post types and exclude as necessary
|
69 |
+
$plugin_options = get_option( 'metronet-reorder-posts', false );
|
70 |
+
if ( $plugin_options && isset( $plugin_options[ 'post_types' ] ) && is_array( $plugin_options[ 'post_types' ] ) ) {
|
71 |
+
foreach( $plugin_options[ 'post_types' ] as $post_type => $value ) {
|
72 |
+
if( $value === 'off' ) {
|
73 |
+
unset( $post_types[ $post_type ] );
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
|
78 |
// Add filter to allow users to control which post-types the plugin is used with via their theme
|
79 |
$post_types = apply_filters( 'metronet_reorder_post_types', $post_types );
|
85 |
array(
|
86 |
'post_type' => $post_type,
|
87 |
'order' => 'ASC',
|
88 |
+
'heading' => __( 'Reorder Posts', 'metronet-reorder-posts' ),
|
89 |
'final' => '',
|
90 |
'initial' => '',
|
91 |
+
'menu_label' => __( 'Reorder', 'metronet-reorder-posts' ),
|
|
|
92 |
'post_status' => 'publish',
|
93 |
)
|
94 |
);
|
95 |
}
|
96 |
} //end mt_reorder_posts_init
|
97 |
|
98 |
+
add_action( 'plugins_loaded', 'mn_reorder_init_language' );
|
99 |
+
function mn_reorder_init_language() {
|
100 |
+
//* Localization Code */
|
101 |
+
load_plugin_textdomain( 'metronet-reorder-posts', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
|
102 |
+
}
|
103 |
+
|
languages/index.php
ADDED
File without changes
|
languages/metronet-reorder-posts.pot
ADDED
@@ -0,0 +1,113 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# WordPress Blank Pot
|
2 |
+
# Copyright (C) 2014 ...
|
3 |
+
# This file is distributed under the GNU General Public License v2 or later.
|
4 |
+
msgid ""
|
5 |
+
msgstr ""
|
6 |
+
"Project-Id-Version: Metronet Reorder Posts v1.0.0\n"
|
7 |
+
"Report-Msgid-Bugs-To: Ronald Huereca <ronalfy@gmail.com>\n"
|
8 |
+
"POT-Creation-Date: 2014-12-13 19:25-0600\n"
|
9 |
+
"PO-Revision-Date: \n"
|
10 |
+
"Last-Translator: Ronald Huereca <ron@ronalfy.com>\n"
|
11 |
+
"Language-Team: Ronald Huereca <ronalfy@gmail.com>\n"
|
12 |
+
"Language: en_US\n"
|
13 |
+
"MIME-Version: 1.0\n"
|
14 |
+
"Content-Type: text/plain; charset=UTF-8\n"
|
15 |
+
"Content-Transfer-Encoding: 8bit\n"
|
16 |
+
"Plural-Forms: nplurals=2; plural=n != 1;\n"
|
17 |
+
"X-Textdomain-Support: yesX-Generator: Poedit 1.6.4\n"
|
18 |
+
"X-Poedit-SourceCharset: UTF-8\n"
|
19 |
+
"X-Poedit-KeywordsList: __;_e;esc_html_e;esc_html_x:1,2c;esc_html__;"
|
20 |
+
"esc_attr_e;esc_attr_x:1,2c;esc_attr__;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;"
|
21 |
+
"_x:1,2c;_n:1,2;_n_noop:1,2;__ngettext:1,2;__ngettext_noop:1,2;_c,_nc:4c,1,2\n"
|
22 |
+
"X-Poedit-Basepath: ../\n"
|
23 |
+
"X-Generator: Poedit 1.5.3\n"
|
24 |
+
"X-Poedit-SearchPath-0: .\n"
|
25 |
+
|
26 |
+
#: class-reorder-admin.php:81 class-reorder-admin.php:359
|
27 |
+
msgctxt "Plugin Name - Settings Page Title"
|
28 |
+
msgid "Reorder Posts"
|
29 |
+
msgstr ""
|
30 |
+
|
31 |
+
#: class-reorder-admin.php:81
|
32 |
+
msgctxt "Plugin Name - Menu Item"
|
33 |
+
msgid "Reorder Posts"
|
34 |
+
msgstr ""
|
35 |
+
|
36 |
+
#: class-reorder-admin.php:122
|
37 |
+
msgid "Sort by:"
|
38 |
+
msgstr ""
|
39 |
+
|
40 |
+
#: class-reorder-admin.php:124
|
41 |
+
msgid "None"
|
42 |
+
msgstr ""
|
43 |
+
|
44 |
+
#: class-reorder-admin.php:125
|
45 |
+
msgid "Menu Order"
|
46 |
+
msgstr ""
|
47 |
+
|
48 |
+
#: class-reorder-admin.php:131
|
49 |
+
msgid "Sort Order:"
|
50 |
+
msgstr ""
|
51 |
+
|
52 |
+
#: class-reorder-admin.php:133
|
53 |
+
msgid "ASC"
|
54 |
+
msgstr ""
|
55 |
+
|
56 |
+
#: class-reorder-admin.php:134
|
57 |
+
msgid "DESC"
|
58 |
+
msgstr ""
|
59 |
+
|
60 |
+
#: class-reorder-admin.php:184
|
61 |
+
msgid ""
|
62 |
+
"These are advanced options and you should only use these if you know what "
|
63 |
+
"you are doing. These can overwrite the menu orders of custom queries (using "
|
64 |
+
"get_posts or WP_Query), custom post type archives, and even the order your "
|
65 |
+
"blog posts display."
|
66 |
+
msgstr ""
|
67 |
+
|
68 |
+
#: class-reorder-admin.php:200
|
69 |
+
msgctxt "Plugin settings link on the plugins page"
|
70 |
+
msgid "Settings"
|
71 |
+
msgstr ""
|
72 |
+
|
73 |
+
#: class-reorder-admin.php:250
|
74 |
+
msgctxt "plugin settings heading"
|
75 |
+
msgid "Enable Post Types"
|
76 |
+
msgstr ""
|
77 |
+
|
78 |
+
#: class-reorder-admin.php:252
|
79 |
+
msgctxt "plugin settings heading"
|
80 |
+
msgid "Advanced"
|
81 |
+
msgstr ""
|
82 |
+
|
83 |
+
#: class-reorder-admin.php:254
|
84 |
+
msgid "Post Types"
|
85 |
+
msgstr ""
|
86 |
+
|
87 |
+
#: class-reorder-admin.php:254
|
88 |
+
msgid "Select the post types you would like this plugin enabled for."
|
89 |
+
msgstr ""
|
90 |
+
|
91 |
+
#: class-reorder-admin.php:256
|
92 |
+
msgid "Select the menu order arguments."
|
93 |
+
msgstr ""
|
94 |
+
|
95 |
+
#: class-reorder-admin.php:256
|
96 |
+
msgid "Select the menu order for the post types."
|
97 |
+
msgstr ""
|
98 |
+
|
99 |
+
#: class-reorder.php:99 index.php:91
|
100 |
+
msgid "Reorder"
|
101 |
+
msgstr ""
|
102 |
+
|
103 |
+
#: class-reorder.php:208 class-reorder.php:283
|
104 |
+
msgid "Expand"
|
105 |
+
msgstr ""
|
106 |
+
|
107 |
+
#: class-reorder.php:209
|
108 |
+
msgid "Collapse"
|
109 |
+
msgstr ""
|
110 |
+
|
111 |
+
#: index.php:88
|
112 |
+
msgid "Reorder Posts"
|
113 |
+
msgstr ""
|
metronet-icon.png
DELETED
Binary file
|
readme.txt
CHANGED
@@ -1,11 +1,13 @@
|
|
1 |
-
===
|
2 |
Contributors: ryanhellyer, metronet, ronalfy
|
3 |
-
Author URI:
|
4 |
-
Plugin URL:
|
5 |
-
Requires at Least: 3.
|
6 |
Tested up to: 4.1
|
7 |
Tags: reorder, re-order, posts, wordpress, post-type, ajax, admin, hierarchical, menu_order, ordering
|
8 |
-
Stable tag:
|
|
|
|
|
9 |
|
10 |
A simple and easy way to reorder your custom post-type posts in WordPress.
|
11 |
|
@@ -13,6 +15,41 @@ A simple and easy way to reorder your custom post-type posts in WordPress.
|
|
13 |
|
14 |
A simple and easy way to reorder your custom post-type posts in WordPress. Adds drag and drop functionality for post ordering in the WordPress admin panel. Works with custom post-types and regular posts.
|
15 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
== Installation ==
|
17 |
|
18 |
Either install the plugin via the WordPress admin panel, or ...
|
@@ -20,21 +57,29 @@ Either install the plugin via the WordPress admin panel, or ...
|
|
20 |
1. Upload `metronet-reorder-posts` to the `/wp-content/plugins/` directory.
|
21 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
22 |
|
23 |
-
|
|
|
|
|
24 |
|
25 |
== Frequently Asked Questions ==
|
26 |
|
27 |
= Where's the settings page? =
|
28 |
|
29 |
-
|
30 |
|
31 |
-
= Where is the "save" button? =
|
32 |
|
33 |
There isn't one. The changes are saved automatically.
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
= Can I use this on a single post type? =
|
36 |
|
37 |
-
|
38 |
|
39 |
`<?php
|
40 |
|
@@ -52,14 +97,22 @@ Yes, but be wary that the plugin now allows you to re-nest hierarchical items ea
|
|
52 |
|
53 |
= Does it work in older versions of WordPress? =
|
54 |
|
55 |
-
|
56 |
|
57 |
== Screenshots ==
|
58 |
|
59 |
-
1.
|
|
|
60 |
|
61 |
== Changelog ==
|
62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
= 1.0.6 =
|
64 |
* Updated 2014-12-11 - Ensuring WordPress 4.1 compatibility
|
65 |
* Released 2013-07-19
|
@@ -92,3 +145,8 @@ Probably, but we only support the latest version of WordPress.
|
|
92 |
|
93 |
= 1.0 =
|
94 |
* Initial plugin release
|
|
|
|
|
|
|
|
|
|
1 |
+
=== Reorder Posts ===
|
2 |
Contributors: ryanhellyer, metronet, ronalfy
|
3 |
+
Author URI: https://hellyer.kiwi/
|
4 |
+
Plugin URL: https://wordpress.org/plugins/metronet-reorder-posts/
|
5 |
+
Requires at Least: 3.7
|
6 |
Tested up to: 4.1
|
7 |
Tags: reorder, re-order, posts, wordpress, post-type, ajax, admin, hierarchical, menu_order, ordering
|
8 |
+
Stable tag: 2.0.0
|
9 |
+
License: GPLv2 or later
|
10 |
+
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
11 |
|
12 |
A simple and easy way to reorder your custom post-type posts in WordPress.
|
13 |
|
15 |
|
16 |
A simple and easy way to reorder your custom post-type posts in WordPress. Adds drag and drop functionality for post ordering in the WordPress admin panel. Works with custom post-types and regular posts.
|
17 |
|
18 |
+
A settings panel is available for determining which post types to enable ordering for. Advanced options allow you to change the menu order for post types.
|
19 |
+
|
20 |
+
<h3>Features</h3>
|
21 |
+
<ul>
|
22 |
+
<li>Adds "Reorder" sub-menu to all post types by default</li>
|
23 |
+
<li>Hierarchical post type support (i.e., supports nested posts)</li>
|
24 |
+
<li>Allows you to re-nest hierarchical posts</li>
|
25 |
+
<li>Auto-saves order without having to click an update button</li>
|
26 |
+
<li>Dedicated settings panel for determining which post types can be reordered</li>
|
27 |
+
<li>Advanced settings panel for overriding the menu order of custom post type queries</li>
|
28 |
+
</ul>
|
29 |
+
|
30 |
+
Advanced customization is allowed via hooks. See the <a href="https://github.com/ronalfy/reorder-posts#plugin-filters">Plugin Filters on GitHub</a>.
|
31 |
+
|
32 |
+
<h3>Spread the Word</h3>
|
33 |
+
If you like this plugin, please help spread the word. Rate the plugin. Write about the plugin. Something :)
|
34 |
+
|
35 |
+
<h3>Translations</h3>
|
36 |
+
None so far.
|
37 |
+
|
38 |
+
If you would like to contribute a translation, please leave a support request with a link to your translation.
|
39 |
+
|
40 |
+
You are welcome to help us out and <a href="https://github.com/ronalfy/reorder-posts">contribute on GitHub</a>.
|
41 |
+
|
42 |
+
<h3>Support</h3>
|
43 |
+
|
44 |
+
Please feel free to leave a support request here or create an <a href="https://github.com/ronalfy/reorder-posts/issues">issue on GitHub</a>. If you require immediate feedback, feel free to @reply us on Twitter with your support link: (<a href="https://twitter.com/ryanhellyer">@ryanhellyer</a> or <a href="https://twitter.com/ronalfy">@ronalfy</a>). Support is always free unless you require some advanced customization out of the scope of the plugin's existing features. We'll do our best to get with you when we can. Please rate/review the plugin if we have helped you to show thanks for the support.
|
45 |
+
|
46 |
+
<h3>Credits</h3>
|
47 |
+
This plugin was originally developed for <a href="https://metronet.no/">Metronet AS in Norway</a>.
|
48 |
+
|
49 |
+
The plugin is now independently developed by <a href="https://hellyer.kiwi/">Ryan Hellyer</a> and <a href="http://www.ronalfy.com">Ronald Huereca</a>.
|
50 |
+
|
51 |
+
Banner image courtesy of <a href="https://www.flickr.com/photos/pagedooley">Kevin Dooley</a>.
|
52 |
+
|
53 |
== Installation ==
|
54 |
|
55 |
Either install the plugin via the WordPress admin panel, or ...
|
57 |
1. Upload `metronet-reorder-posts` to the `/wp-content/plugins/` directory.
|
58 |
2. Activate the plugin through the 'Plugins' menu in WordPress.
|
59 |
|
60 |
+
For each post type, you will see a new "Reorder" submenu. Simply navigate to "Reorder" to change the order of your post types. Changes are saved immediately, there is no need to click a save or update button.
|
61 |
+
|
62 |
+
By default, ordering is enabled for all post types. A settings panel is available for determining which post types to enable ordering for. Advanced options allow you to change the menu order for post types.
|
63 |
|
64 |
== Frequently Asked Questions ==
|
65 |
|
66 |
= Where's the settings page? =
|
67 |
|
68 |
+
The settings are located under Settings->Reorder Posts. Settings are optional, of course, as the plugin will work with no configuration. We consider the settings useful for only advanced users (i.e., users with coding experience).
|
69 |
|
70 |
+
= Where is the "save" button when re-ordering? =
|
71 |
|
72 |
There isn't one. The changes are saved automatically.
|
73 |
|
74 |
+
= Do I need to add custom code to get this to work? =
|
75 |
+
|
76 |
+
Yes, and no. There are many ways to retrieve posts using the WordPress API, and if the code has a `menu_order` sort property, the changes should be reflected immediately.
|
77 |
+
|
78 |
+
Often, however, there is no `menu_order` argument. In the plugin's settings, there is an "Advanced" section which will attempt to override the `menu_order` property. Please use this with caution.
|
79 |
+
|
80 |
= Can I use this on a single post type? =
|
81 |
|
82 |
+
You are able to override the post types used via a filter (see below) or navigate to the plugin's settings and enable which post types you would like to use.
|
83 |
|
84 |
`<?php
|
85 |
|
97 |
|
98 |
= Does it work in older versions of WordPress? =
|
99 |
|
100 |
+
This plugin requires WordPress 3.7 or above. We urge you, however, to always use the latest version of WordPress.
|
101 |
|
102 |
== Screenshots ==
|
103 |
|
104 |
+
1. Reorder Posts allows you to easily drag and drop posts to change their order
|
105 |
+
2. Admin panel settings
|
106 |
|
107 |
== Changelog ==
|
108 |
|
109 |
+
= 2.0.0 =
|
110 |
+
* Released 2014-12-12
|
111 |
+
* Added settings panel for enabling/disabling the Reorder plugin for post types.
|
112 |
+
* Added advanced settings for overriding the menu order of post types.
|
113 |
+
* Added internationalization capabilities.
|
114 |
+
* Slightly adjusted the styles of the Reordering interface.
|
115 |
+
|
116 |
= 1.0.6 =
|
117 |
* Updated 2014-12-11 - Ensuring WordPress 4.1 compatibility
|
118 |
* Released 2013-07-19
|
145 |
|
146 |
= 1.0 =
|
147 |
* Initial plugin release
|
148 |
+
|
149 |
+
== Upgrade Notice ==
|
150 |
+
|
151 |
+
= 2.0.0 =
|
152 |
+
New admin panel settings for setting Reorder for post types, and advanced options for modifying the menu order of post type queries.
|
screenshot-1.png
DELETED
Binary file
|
scripts/index.php
ADDED
File without changes
|
scripts/sort.js
CHANGED
@@ -21,9 +21,9 @@ jQuery(document).ready(function($) {
|
|
21 |
update: function( event, ui ) {
|
22 |
var order = $('ul#post-list').nestedSortable( 'toHierarchy',{ listType: 'ul'});
|
23 |
order = JSON.stringify( order , null, 2);
|
24 |
-
|
25 |
-
//return;
|
26 |
$.post( ajaxurl, { action: 'post_sort', nonce: reorder_posts.sortnonce, data: order }, function( response ) {
|
|
|
27 |
}, 'json' );
|
28 |
|
29 |
}
|
@@ -37,42 +37,4 @@ jQuery(document).ready(function($) {
|
|
37 |
$( this ).parent().next( '.children' ).slideUp( "slow" );
|
38 |
return false;
|
39 |
} );
|
40 |
-
|
41 |
-
/*
|
42 |
-
|
43 |
-
postList.sortable({
|
44 |
-
update: function(event, ui) {
|
45 |
-
$('#loading-animation').show(); // Show the animate loading gif while waiting
|
46 |
-
|
47 |
-
opts = {
|
48 |
-
url: ajaxurl, // ajaxurl is defined by WordPress and points to /wp-admin/admin-ajax.php
|
49 |
-
type: 'POST',
|
50 |
-
async: true,
|
51 |
-
cache: false,
|
52 |
-
dataType: 'json',
|
53 |
-
data:{
|
54 |
-
action: 'post_sort', // Tell WordPress how to handle this ajax request
|
55 |
-
order: postList.sortable('toArray').toString(), // Passes ID's of list items in 1,3,2 format
|
56 |
-
nonce: sortnonce,
|
57 |
-
},
|
58 |
-
success: function(response) {
|
59 |
-
console.log( response );
|
60 |
-
return;
|
61 |
-
$('#loading-animation').hide(); // Hide the loading animation
|
62 |
-
$('#reorder-error').html('There was an error worked'); // Error message
|
63 |
-
$('#reorder-error').html(response); // Error message
|
64 |
-
|
65 |
-
console.log(response);
|
66 |
-
return;
|
67 |
-
},
|
68 |
-
error: function(xhr,textStatus,e) { // This can be expanded to provide more information
|
69 |
-
alert('There was an error saving the updates');
|
70 |
-
$('#loading-animation').hide(); // Hide the loading animation
|
71 |
-
return;
|
72 |
-
}
|
73 |
-
};
|
74 |
-
$.ajax(opts);
|
75 |
-
}
|
76 |
-
});
|
77 |
-
*/
|
78 |
});
|
21 |
update: function( event, ui ) {
|
22 |
var order = $('ul#post-list').nestedSortable( 'toHierarchy',{ listType: 'ul'});
|
23 |
order = JSON.stringify( order , null, 2);
|
24 |
+
$('#loading-animation').show();
|
|
|
25 |
$.post( ajaxurl, { action: 'post_sort', nonce: reorder_posts.sortnonce, data: order }, function( response ) {
|
26 |
+
$('#loading-animation').hide()
|
27 |
}, 'json' );
|
28 |
|
29 |
}
|
37 |
$( this ).parent().next( '.children' ).slideUp( "slow" );
|
38 |
return false;
|
39 |
} );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
});
|
uninstall.php
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( !defined('ABSPATH') && !defined('WP_UNINSTALL_PLUGIN') ) {
|
3 |
+
exit();
|
4 |
+
}
|
5 |
+
delete_option( 'metronet-reorder-posts' );
|
6 |
+
?>
|