Version Description
Download this release
Release Info
Developer | johnbillion |
Plugin | WP Crontrol |
Version | 1.7.0 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.7.0
- LICENSE +339 -0
- composer.json +24 -0
- readme.txt +2 -2
- wp-crontrol.php +198 -120
LICENSE
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 |
+
{{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.
|
composer.json
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "johnbillion/wp-crontrol",
|
3 |
+
"description": "WP Crontrol lets you view and control what's happening in the WP-Cron system.",
|
4 |
+
"homepage" : "https://github.com/johnbillion/wp-crontrol/",
|
5 |
+
"license" : "GPL-2.0+",
|
6 |
+
"type" : "wordpress-plugin",
|
7 |
+
"authors" : [
|
8 |
+
{
|
9 |
+
"name" : "John Blackbourn",
|
10 |
+
"homepage": "https://johnblackbourn.com/"
|
11 |
+
},
|
12 |
+
{
|
13 |
+
"name" : "Edward Dale",
|
14 |
+
"homepage": "http://scompt.com/"
|
15 |
+
}
|
16 |
+
],
|
17 |
+
"require-dev": {
|
18 |
+
"wp-coding-standards/wpcs": "^2",
|
19 |
+
"dealerdirect/phpcodesniffer-composer-installer": "^0.5"
|
20 |
+
},
|
21 |
+
"require": {
|
22 |
+
"composer/installers": "~1.0"
|
23 |
+
}
|
24 |
+
}
|
readme.txt
CHANGED
@@ -2,8 +2,8 @@
|
|
2 |
Contributors: johnbillion, scompt
|
3 |
Tags: admin, cron, plugin, control, wp-cron, crontrol
|
4 |
Requires at least: 4.1
|
5 |
-
Tested up to:
|
6 |
-
Stable tag: 1.
|
7 |
|
8 |
WP Crontrol lets you view and control what's happening in the WP-Cron system.
|
9 |
|
2 |
Contributors: johnbillion, scompt
|
3 |
Tags: admin, cron, plugin, control, wp-cron, crontrol
|
4 |
Requires at least: 4.1
|
5 |
+
Tested up to: 5.1
|
6 |
+
Stable tag: 1.7.0
|
7 |
|
8 |
WP Crontrol lets you view and control what's happening in the WP-Cron system.
|
9 |
|
wp-crontrol.php
CHANGED
@@ -1,18 +1,14 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
* Plugin Name: WP Crontrol
|
4 |
* Plugin URI: https://wordpress.org/plugins/wp-crontrol/
|
5 |
* Description: WP Crontrol lets you view and control what's happening in the WP-Cron system.
|
6 |
-
* Author: John Blackbourn &
|
7 |
* Author URI: https://github.com/johnbillion/wp-crontrol/graphs/contributors
|
8 |
-
* Version: 1.
|
9 |
* Text Domain: wp-crontrol
|
10 |
* Domain Path: /languages/
|
11 |
* License: GPL v2 or later
|
12 |
-
*/
|
13 |
-
|
14 |
-
/**
|
15 |
-
* WP Crontrol lets you view and control what's happening in the WP-Cron system.
|
16 |
*
|
17 |
* LICENSE
|
18 |
* This file is part of WP Crontrol.
|
@@ -27,20 +23,19 @@
|
|
27 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
28 |
* GNU General Public License for more details.
|
29 |
*
|
30 |
-
* You should have received a copy of the GNU General Public License
|
31 |
-
* along with this program; if not, write to the Free Software
|
32 |
-
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
33 |
-
*
|
34 |
* @package WP Crontrol
|
35 |
* @author Edward Dale <scompt@scompt.com> & John Blackbourn <john@johnblackbourn.com>
|
36 |
-
* @copyright Copyright 2008 Edward Dale, 2012-
|
37 |
* @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
|
38 |
* @link https://wordpress.org/plugins/wp-crontrol/
|
39 |
* @since 0.2
|
40 |
*/
|
41 |
|
42 |
-
defined( 'ABSPATH' )
|
43 |
|
|
|
|
|
|
|
44 |
class Crontrol {
|
45 |
|
46 |
/**
|
@@ -66,6 +61,8 @@ class Crontrol {
|
|
66 |
|
67 |
/**
|
68 |
* Evaluates the provided code using eval.
|
|
|
|
|
69 |
*/
|
70 |
public function action_php_cron_event( $code ) {
|
71 |
eval( $code ); // @codingStandardsIgnoreLine
|
@@ -84,15 +81,15 @@ class Crontrol {
|
|
84 |
public function action_handle_posts() {
|
85 |
if ( isset( $_POST['new_cron'] ) ) {
|
86 |
if ( ! current_user_can( 'manage_options' ) ) {
|
87 |
-
wp_die( esc_html__( 'You are not allowed to add new cron events.', 'wp-crontrol' ) );
|
88 |
}
|
89 |
check_admin_referer( 'new-cron' );
|
90 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
91 |
if ( 'crontrol_cron_job' === $in_hookname && ! current_user_can( 'edit_files' ) ) {
|
92 |
-
wp_die( esc_html__( 'You are not allowed to add new PHP cron events.', 'wp-crontrol' ) );
|
93 |
}
|
94 |
$in_args = json_decode( $in_args, true );
|
95 |
-
$next_run = $in_next_run_date
|
96 |
$this->add_cron( $next_run, $in_schedule, $in_hookname, $in_args );
|
97 |
$redirect = array(
|
98 |
'page' => 'crontrol_admin_manage_page',
|
@@ -104,7 +101,7 @@ class Crontrol {
|
|
104 |
|
105 |
} elseif ( isset( $_POST['new_php_cron'] ) ) {
|
106 |
if ( ! current_user_can( 'edit_files' ) ) {
|
107 |
-
wp_die( esc_html__( 'You are not allowed to add new PHP cron events.', 'wp-crontrol' ) );
|
108 |
}
|
109 |
check_admin_referer( 'new-cron' );
|
110 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
@@ -112,7 +109,7 @@ class Crontrol {
|
|
112 |
'code' => $in_hookcode,
|
113 |
'name' => $in_eventname,
|
114 |
);
|
115 |
-
$next_run = $in_next_run_date
|
116 |
$this->add_cron( $next_run, $in_schedule, 'crontrol_cron_job', $args );
|
117 |
$hookname = ( ! empty( $in_eventname ) ) ? $in_eventname : __( 'PHP Cron', 'wp-crontrol' );
|
118 |
$redirect = array(
|
@@ -125,19 +122,19 @@ class Crontrol {
|
|
125 |
|
126 |
} elseif ( isset( $_POST['edit_cron'] ) ) {
|
127 |
if ( ! current_user_can( 'manage_options' ) ) {
|
128 |
-
wp_die( esc_html__( 'You are not allowed to edit cron events.', 'wp-crontrol' ) );
|
129 |
}
|
130 |
|
131 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
132 |
check_admin_referer( "edit-cron_{$in_original_hookname}_{$in_original_sig}_{$in_original_next_run}" );
|
133 |
|
134 |
if ( 'crontrol_cron_job' === $in_hookname && ! current_user_can( 'edit_files' ) ) {
|
135 |
-
wp_die( esc_html__( 'You are not allowed to edit PHP cron events.', 'wp-crontrol' ) );
|
136 |
}
|
137 |
|
138 |
$in_args = json_decode( $in_args, true );
|
139 |
$i = $this->delete_cron( $in_original_hookname, $in_original_sig, $in_original_next_run );
|
140 |
-
$next_run = $in_next_run_date
|
141 |
$i = $this->add_cron( $next_run, $in_schedule, $in_hookname, $in_args );
|
142 |
$redirect = array(
|
143 |
'page' => 'crontrol_admin_manage_page',
|
@@ -149,7 +146,7 @@ class Crontrol {
|
|
149 |
|
150 |
} elseif ( isset( $_POST['edit_php_cron'] ) ) {
|
151 |
if ( ! current_user_can( 'edit_files' ) ) {
|
152 |
-
wp_die( esc_html__( 'You are not allowed to edit PHP cron events.', 'wp-crontrol' ) );
|
153 |
}
|
154 |
|
155 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
@@ -161,7 +158,7 @@ class Crontrol {
|
|
161 |
'name' => $in_eventname,
|
162 |
);
|
163 |
$i = $this->delete_cron( $in_original_hookname, $in_original_sig, $in_original_next_run );
|
164 |
-
$next_run = $in_next_run_date
|
165 |
$i = $this->add_cron( $next_run, $in_schedule, 'crontrol_cron_job', $args );
|
166 |
$hookname = ( ! empty( $in_eventname ) ) ? $in_eventname : __( 'PHP Cron', 'wp-crontrol' );
|
167 |
$redirect = array(
|
@@ -174,7 +171,7 @@ class Crontrol {
|
|
174 |
|
175 |
} elseif ( isset( $_POST['new_schedule'] ) ) {
|
176 |
if ( ! current_user_can( 'manage_options' ) ) {
|
177 |
-
wp_die( esc_html__( 'You are not allowed to add new cron schedules.', 'wp-crontrol' ) );
|
178 |
}
|
179 |
check_admin_referer( 'new-sched' );
|
180 |
$name = wp_unslash( $_POST['internal_name'] );
|
@@ -182,7 +179,7 @@ class Crontrol {
|
|
182 |
$display = wp_unslash( $_POST['display_name'] );
|
183 |
|
184 |
// The user entered something that wasn't a number.
|
185 |
-
// Try to convert it with strtotime
|
186 |
if ( ! is_numeric( $interval ) ) {
|
187 |
$now = time();
|
188 |
$future = strtotime( $interval, $now );
|
@@ -217,7 +214,7 @@ class Crontrol {
|
|
217 |
|
218 |
} elseif ( isset( $_GET['action'] ) && 'delete-sched' == $_GET['action'] ) {
|
219 |
if ( ! current_user_can( 'manage_options' ) ) {
|
220 |
-
wp_die( esc_html__( 'You are not allowed to delete cron schedules.', 'wp-crontrol' ) );
|
221 |
}
|
222 |
$id = wp_unslash( $_GET['id'] );
|
223 |
check_admin_referer( "delete-sched_{$id}" );
|
@@ -232,7 +229,7 @@ class Crontrol {
|
|
232 |
|
233 |
} elseif ( isset( $_POST['delete_crons'] ) ) {
|
234 |
if ( ! current_user_can( 'manage_options' ) ) {
|
235 |
-
wp_die( esc_html__( 'You are not allowed to delete cron events.', 'wp-crontrol' ) );
|
236 |
}
|
237 |
check_admin_referer( 'bulk-delete-crons' );
|
238 |
|
@@ -264,7 +261,7 @@ class Crontrol {
|
|
264 |
|
265 |
} elseif ( isset( $_GET['action'] ) && 'delete-cron' == $_GET['action'] ) {
|
266 |
if ( ! current_user_can( 'manage_options' ) ) {
|
267 |
-
wp_die( esc_html__( 'You are not allowed to delete cron events.', 'wp-crontrol' ) );
|
268 |
}
|
269 |
$id = wp_unslash( $_GET['id'] );
|
270 |
$sig = wp_unslash( $_GET['sig'] );
|
@@ -272,7 +269,7 @@ class Crontrol {
|
|
272 |
check_admin_referer( "delete-cron_{$id}_{$sig}_{$next_run}" );
|
273 |
|
274 |
if ( 'crontrol_cron_job' === $id && ! current_user_can( 'edit_files' ) ) {
|
275 |
-
wp_die( esc_html__( 'You are not allowed to delete PHP cron events.', 'wp-crontrol' ) );
|
276 |
}
|
277 |
|
278 |
if ( $this->delete_cron( $id, $sig, $next_run ) ) {
|
@@ -296,7 +293,7 @@ class Crontrol {
|
|
296 |
|
297 |
} elseif ( isset( $_GET['action'] ) && 'run-cron' == $_GET['action'] ) {
|
298 |
if ( ! current_user_can( 'manage_options' ) ) {
|
299 |
-
wp_die( esc_html__( 'You are not allowed to run cron events.', 'wp-crontrol' ) );
|
300 |
}
|
301 |
$id = wp_unslash( $_GET['id'] );
|
302 |
$sig = wp_unslash( $_GET['sig'] );
|
@@ -326,7 +323,8 @@ class Crontrol {
|
|
326 |
*
|
327 |
* Executes an event by scheduling a new single event with the same arguments.
|
328 |
*
|
329 |
-
* @param string $hookname The
|
|
|
330 |
*/
|
331 |
public function run_cron( $hookname, $sig ) {
|
332 |
$crons = _get_cron_array();
|
@@ -345,10 +343,10 @@ class Crontrol {
|
|
345 |
/**
|
346 |
* Adds a new cron event.
|
347 |
*
|
348 |
-
* @param string $next_run A
|
349 |
-
* @param string $schedule The recurrence of the cron event
|
350 |
-
* @param string $hookname The name of the hook to execute
|
351 |
-
* @param array
|
352 |
*/
|
353 |
public function add_cron( $next_run, $schedule, $hookname, $args ) {
|
354 |
$next_run = strtotime( $next_run );
|
@@ -370,7 +368,9 @@ class Crontrol {
|
|
370 |
/**
|
371 |
* Deletes a cron event.
|
372 |
*
|
373 |
-
* @param string $
|
|
|
|
|
374 |
*/
|
375 |
public function delete_cron( $to_delete, $sig, $next_run ) {
|
376 |
$crons = _get_cron_array();
|
@@ -385,9 +385,9 @@ class Crontrol {
|
|
385 |
/**
|
386 |
* Adds a new custom cron schedule.
|
387 |
*
|
388 |
-
* @param string $name The internal name of the schedule
|
389 |
-
* @param int $interval The interval between executions of the new schedule
|
390 |
-
* @param string $display The display name of the schedule
|
391 |
*/
|
392 |
public function add_schedule( $name, $interval, $display ) {
|
393 |
$old_scheds = get_option( 'crontrol_schedules', array() );
|
@@ -417,7 +417,7 @@ class Crontrol {
|
|
417 |
public function action_activate() {
|
418 |
add_option( 'crontrol_schedules', array() );
|
419 |
|
420 |
-
//
|
421 |
if ( _get_cron_array() === false ) {
|
422 |
_set_cron_array( array() );
|
423 |
}
|
@@ -433,6 +433,15 @@ class Crontrol {
|
|
433 |
add_management_page( esc_html__( 'Cron Events', 'wp-crontrol' ), esc_html__( 'Cron Events', 'wp-crontrol' ), 'manage_options', 'crontrol_admin_manage_page', array( $this, 'admin_manage_page' ) );
|
434 |
}
|
435 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
|
437 |
$actions['crontrol-events'] = sprintf(
|
438 |
'<a href="%s">%s</a>',
|
@@ -512,17 +521,21 @@ class Crontrol {
|
|
512 |
<?php
|
513 |
} else {
|
514 |
foreach ( $schedules as $name => $data ) {
|
515 |
-
printf(
|
|
|
516 |
esc_attr( $name )
|
517 |
);
|
518 |
-
printf(
|
|
|
519 |
esc_html( $name )
|
520 |
);
|
521 |
-
printf(
|
|
|
522 |
esc_html( $data['interval'] ),
|
523 |
esc_html( $this->interval( $data['interval'] ) )
|
524 |
);
|
525 |
-
printf(
|
|
|
526 |
esc_html( $data['display'] )
|
527 |
);
|
528 |
|
@@ -555,11 +568,12 @@ class Crontrol {
|
|
555 |
</div>
|
556 |
<div class="wrap">
|
557 |
<p class="description">
|
558 |
-
<?php
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
|
|
563 |
?>
|
564 |
</p>
|
565 |
</div>
|
@@ -598,6 +612,14 @@ class Crontrol {
|
|
598 |
return $schedules;
|
599 |
}
|
600 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
601 |
protected function sort_schedules( $a, $b ) {
|
602 |
return ( $a['interval'] - $b['interval'] );
|
603 |
}
|
@@ -605,7 +627,7 @@ class Crontrol {
|
|
605 |
/**
|
606 |
* Displays a dropdown filled with the possible schedules, including non-repeating.
|
607 |
*
|
608 |
-
* @param
|
609 |
*/
|
610 |
public function schedules_dropdown( $current = false ) {
|
611 |
$schedules = $this->get_schedules();
|
@@ -630,6 +652,8 @@ class Crontrol {
|
|
630 |
/**
|
631 |
* Gets the status of WP-Cron functionality on the site by performing a test spawn. Cached for one hour when all is well.
|
632 |
*
|
|
|
|
|
633 |
*/
|
634 |
public function test_cron_spawn( $cache = true ) {
|
635 |
global $wp_version;
|
@@ -684,7 +708,6 @@ class Crontrol {
|
|
684 |
|
685 |
/**
|
686 |
* Shows the status of WP-Cron functionality on the site. Only displays a message when there's a problem.
|
687 |
-
*
|
688 |
*/
|
689 |
public function show_cron_status() {
|
690 |
|
@@ -700,13 +723,15 @@ class Crontrol {
|
|
700 |
} else {
|
701 |
?>
|
702 |
<div id="cron-status-error" class="error">
|
703 |
-
<p
|
|
|
704 |
printf(
|
705 |
/* translators: 1: Error message text. */
|
706 |
esc_html__( 'There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron events on your site may not work. The problem was: %s', 'wp-crontrol' ),
|
707 |
'<br><strong>' . esc_html( $status->get_error_message() ) . '</strong>'
|
708 |
);
|
709 |
-
|
|
|
710 |
</div>
|
711 |
<?php
|
712 |
}
|
@@ -739,8 +764,8 @@ class Crontrol {
|
|
739 |
/**
|
740 |
* Shows the form used to add/edit cron events.
|
741 |
*
|
742 |
-
* @param
|
743 |
-
* @param mixed $existing An array of existing values for the cron event, or null
|
744 |
*/
|
745 |
public function show_cron_form( $is_php, $existing ) {
|
746 |
$new_tabs = array(
|
@@ -782,7 +807,7 @@ class Crontrol {
|
|
782 |
$action = $is_php ? 'edit_php_cron' : 'edit_cron';
|
783 |
$button = $is_php ? $modify_tabs['php-cron'] : $modify_tabs['cron'];
|
784 |
$show_edit_tab = true;
|
785 |
-
|
786 |
} else {
|
787 |
$other_fields = wp_nonce_field( 'new-cron', '_wpnonce', true, false );
|
788 |
$existing = array(
|
@@ -794,7 +819,6 @@ class Crontrol {
|
|
794 |
$action = $is_php ? 'new_php_cron' : 'new_cron';
|
795 |
$button = $is_php ? $new_tabs['php-cron'] : $new_tabs['cron'];
|
796 |
$show_edit_tab = false;
|
797 |
-
$next_run_time = '';
|
798 |
$next_run_date = '';
|
799 |
}
|
800 |
if ( $is_php ) {
|
@@ -810,8 +834,8 @@ class Crontrol {
|
|
810 |
?>
|
811 |
<div id="crontrol_form" class="wrap narrow">
|
812 |
<h2 class="nav-tab-wrapper">
|
813 |
-
<a href="<?php echo esc_url( $new_links['cron'] ); ?>" class="nav-tab<?php
|
814 |
-
<a href="<?php echo esc_url( $new_links['php-cron'] ); ?>" class="nav-tab<?php
|
815 |
<?php if ( $show_edit_tab ) { ?>
|
816 |
<span class="nav-tab nav-tab-active"><?php echo esc_html( $button ); ?></span>
|
817 |
<?php } ?>
|
@@ -867,38 +891,53 @@ class Crontrol {
|
|
867 |
<tr>
|
868 |
<th valign="top" scope="row"><label for="next_run_date"><?php esc_html_e( 'Next Run', 'wp-crontrol' ); ?></label></th>
|
869 |
<td>
|
870 |
-
<
|
871 |
-
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
|
876 |
-
|
877 |
-
|
878 |
-
|
879 |
-
|
880 |
-
|
881 |
-
|
882 |
-
|
883 |
-
|
884 |
-
|
885 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
886 |
<p class="description">
|
887 |
<?php
|
888 |
printf(
|
889 |
-
/* translators:
|
890 |
-
esc_html__( '
|
891 |
-
'<code>
|
|
|
892 |
);
|
893 |
?>
|
894 |
</p>
|
895 |
-
<p class="description
|
896 |
<?php
|
897 |
-
|
898 |
-
/* translators: %s
|
899 |
-
|
900 |
-
|
901 |
-
)
|
902 |
?>
|
903 |
</p>
|
904 |
</td>
|
@@ -929,6 +968,11 @@ class Crontrol {
|
|
929 |
<?php
|
930 |
}
|
931 |
|
|
|
|
|
|
|
|
|
|
|
932 |
public function get_cron_events() {
|
933 |
|
934 |
$crons = _get_cron_array();
|
@@ -945,7 +989,7 @@ class Crontrol {
|
|
945 |
foreach ( $cron as $hook => $dings ) {
|
946 |
foreach ( $dings as $sig => $data ) {
|
947 |
|
948 |
-
|
949 |
$events[ "$hook-$sig-$time" ] = (object) array(
|
950 |
'hook' => $hook,
|
951 |
'time' => $time,
|
@@ -990,7 +1034,7 @@ class Crontrol {
|
|
990 |
printf( '<div id="message" class="updated notice is-dismissible"><p>%s</p></div>', $msg ); // WPCS:: XSS ok.
|
991 |
}
|
992 |
$events = $this->get_cron_events();
|
993 |
-
$doing_edit = ( isset( $_GET['action'] ) && 'edit-cron' === $_GET['action'] ) ? wp_unslash( $_GET['id'] ) : false
|
994 |
$time_format = 'Y-m-d H:i:s';
|
995 |
$can_edit_files = current_user_can( 'edit_files' );
|
996 |
|
@@ -1099,7 +1143,15 @@ class Crontrol {
|
|
1099 |
|
1100 |
echo '<td style="white-space:nowrap">';
|
1101 |
if ( $event->schedule ) {
|
1102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1103 |
} else {
|
1104 |
esc_html_e( 'Non-repeating', 'wp-crontrol' );
|
1105 |
}
|
@@ -1154,6 +1206,15 @@ class Crontrol {
|
|
1154 |
?>
|
1155 |
</tbody>
|
1156 |
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1157 |
<?php
|
1158 |
wp_nonce_field( 'bulk-delete-crons' );
|
1159 |
submit_button(
|
@@ -1169,10 +1230,16 @@ class Crontrol {
|
|
1169 |
if ( is_array( $doing_edit ) ) {
|
1170 |
$this->show_cron_form( 'crontrol_cron_job' == $doing_edit['hookname'], $doing_edit );
|
1171 |
} else {
|
1172 |
-
$this->show_cron_form( ( isset( $_GET['action'] )
|
1173 |
}
|
1174 |
}
|
1175 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1176 |
protected function get_action_callbacks( $name ) {
|
1177 |
global $wp_filter;
|
1178 |
|
@@ -1180,7 +1247,7 @@ class Crontrol {
|
|
1180 |
|
1181 |
if ( isset( $wp_filter[ $name ] ) ) {
|
1182 |
|
1183 |
-
|
1184 |
$action = $wp_filter[ $name ];
|
1185 |
|
1186 |
foreach ( $action as $priority => $callbacks ) {
|
@@ -1188,8 +1255,8 @@ class Crontrol {
|
|
1188 |
$callback = self::populate_callback( $callback );
|
1189 |
|
1190 |
$actions[] = array(
|
1191 |
-
'priority'
|
1192 |
-
'callback'
|
1193 |
);
|
1194 |
}
|
1195 |
}
|
@@ -1198,9 +1265,14 @@ class Crontrol {
|
|
1198 |
return $actions;
|
1199 |
}
|
1200 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1201 |
public static function populate_callback( array $callback ) {
|
1202 |
-
|
1203 |
-
// If Query Monitor is installed, use its rich callback analysis:
|
1204 |
if ( method_exists( 'QM_Util', 'populate_callback' ) ) {
|
1205 |
return QM_Util::populate_callback( $callback );
|
1206 |
}
|
@@ -1234,11 +1306,17 @@ class Crontrol {
|
|
1234 |
|
1235 |
}
|
1236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
1237 |
public static function output_callback( array $callback ) {
|
1238 |
$qm = WP_PLUGIN_DIR . '/query-monitor/query-monitor.php';
|
1239 |
$html = plugin_dir_path( $qm ) . 'output/Html.php';
|
1240 |
|
1241 |
-
// If Query Monitor is installed, use its rich callback output
|
1242 |
if ( class_exists( 'QueryMonitor' ) && file_exists( $html ) ) {
|
1243 |
require_once $html;
|
1244 |
|
@@ -1274,11 +1352,11 @@ class Crontrol {
|
|
1274 |
* echo self::interval( 90 );
|
1275 |
* // 1 minute 30 seconds
|
1276 |
*
|
1277 |
-
* @param int
|
1278 |
-
* @return string
|
1279 |
*/
|
1280 |
public function interval( $since ) {
|
1281 |
-
//
|
1282 |
$chunks = array(
|
1283 |
/* translators: 1: The number of years in an interval of time. */
|
1284 |
array( 60 * 60 * 24 * 365, _n_noop( '%s year', '%s years', 'wp-crontrol' ) ),
|
@@ -1300,35 +1378,36 @@ class Crontrol {
|
|
1300 |
return __( 'now', 'wp-crontrol' );
|
1301 |
}
|
1302 |
|
1303 |
-
|
1304 |
-
|
1305 |
-
|
1306 |
-
|
1307 |
-
|
|
|
1308 |
$j = count( $chunks );
|
1309 |
|
1310 |
-
//
|
1311 |
for ( $i = 0; $i < $j; $i++ ) {
|
1312 |
$seconds = $chunks[ $i ][0];
|
1313 |
$name = $chunks[ $i ][1];
|
1314 |
|
1315 |
-
//
|
1316 |
$count = floor( $since / $seconds );
|
1317 |
if ( $count ) {
|
1318 |
break;
|
1319 |
}
|
1320 |
}
|
1321 |
|
1322 |
-
//
|
1323 |
$output = sprintf( translate_nooped_plural( $name, $count, 'wp-crontrol' ), $count );
|
1324 |
|
1325 |
-
//
|
1326 |
if ( $i + 1 < $j ) {
|
1327 |
$seconds2 = $chunks[ $i + 1 ][0];
|
1328 |
$name2 = $chunks[ $i + 1 ][1];
|
1329 |
$count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
|
1330 |
if ( $count2 ) {
|
1331 |
-
//
|
1332 |
$output .= ' ' . sprintf( translate_nooped_plural( $name2, $count2, 'wp-crontrol' ), $count2 );
|
1333 |
}
|
1334 |
}
|
@@ -1337,23 +1416,19 @@ class Crontrol {
|
|
1337 |
}
|
1338 |
|
1339 |
/**
|
1340 |
-
* Returns the schedule display name for a given
|
1341 |
-
*
|
1342 |
-
* Falls back to the time interval if no corresponding schedule exists.
|
1343 |
*
|
1344 |
-
* @param
|
1345 |
-
* @return string The interval display name.
|
1346 |
*/
|
1347 |
-
protected function get_schedule_name( $
|
1348 |
$schedules = $this->get_schedules();
|
1349 |
|
1350 |
-
|
1351 |
-
|
1352 |
-
return $schedule['display'];
|
1353 |
-
}
|
1354 |
}
|
1355 |
|
1356 |
-
return
|
1357 |
}
|
1358 |
|
1359 |
/**
|
@@ -1400,12 +1475,15 @@ class Crontrol {
|
|
1400 |
) );
|
1401 |
}
|
1402 |
|
|
|
|
|
|
|
1403 |
public static function init() {
|
1404 |
|
1405 |
static $instance = null;
|
1406 |
|
1407 |
if ( ! $instance ) {
|
1408 |
-
$instance = new Crontrol;
|
1409 |
}
|
1410 |
|
1411 |
return $instance;
|
@@ -1413,5 +1491,5 @@ class Crontrol {
|
|
1413 |
}
|
1414 |
}
|
1415 |
|
1416 |
-
// Get this show on the road
|
1417 |
Crontrol::init();
|
1 |
<?php
|
2 |
+
/**
|
3 |
* Plugin Name: WP Crontrol
|
4 |
* Plugin URI: https://wordpress.org/plugins/wp-crontrol/
|
5 |
* Description: WP Crontrol lets you view and control what's happening in the WP-Cron system.
|
6 |
+
* Author: John Blackbourn & crontributors
|
7 |
* Author URI: https://github.com/johnbillion/wp-crontrol/graphs/contributors
|
8 |
+
* Version: 1.7.0
|
9 |
* Text Domain: wp-crontrol
|
10 |
* Domain Path: /languages/
|
11 |
* License: GPL v2 or later
|
|
|
|
|
|
|
|
|
12 |
*
|
13 |
* LICENSE
|
14 |
* This file is part of WP Crontrol.
|
23 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
24 |
* GNU General Public License for more details.
|
25 |
*
|
|
|
|
|
|
|
|
|
26 |
* @package WP Crontrol
|
27 |
* @author Edward Dale <scompt@scompt.com> & John Blackbourn <john@johnblackbourn.com>
|
28 |
+
* @copyright Copyright 2008 Edward Dale, 2012-2019 John Blackbourn
|
29 |
* @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
|
30 |
* @link https://wordpress.org/plugins/wp-crontrol/
|
31 |
* @since 0.2
|
32 |
*/
|
33 |
|
34 |
+
defined( 'ABSPATH' ) || die();
|
35 |
|
36 |
+
/**
|
37 |
+
* The main encapsulating class for WP Control.
|
38 |
+
*/
|
39 |
class Crontrol {
|
40 |
|
41 |
/**
|
61 |
|
62 |
/**
|
63 |
* Evaluates the provided code using eval.
|
64 |
+
*
|
65 |
+
* @param string $code The PHP code to evaluate.
|
66 |
*/
|
67 |
public function action_php_cron_event( $code ) {
|
68 |
eval( $code ); // @codingStandardsIgnoreLine
|
81 |
public function action_handle_posts() {
|
82 |
if ( isset( $_POST['new_cron'] ) ) {
|
83 |
if ( ! current_user_can( 'manage_options' ) ) {
|
84 |
+
wp_die( esc_html__( 'You are not allowed to add new cron events.', 'wp-crontrol' ), 401 );
|
85 |
}
|
86 |
check_admin_referer( 'new-cron' );
|
87 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
88 |
if ( 'crontrol_cron_job' === $in_hookname && ! current_user_can( 'edit_files' ) ) {
|
89 |
+
wp_die( esc_html__( 'You are not allowed to add new PHP cron events.', 'wp-crontrol' ), 401 );
|
90 |
}
|
91 |
$in_args = json_decode( $in_args, true );
|
92 |
+
$next_run = ( 'custom' === $in_next_run_date ) ? $in_next_run_date_custom : $in_next_run_date;
|
93 |
$this->add_cron( $next_run, $in_schedule, $in_hookname, $in_args );
|
94 |
$redirect = array(
|
95 |
'page' => 'crontrol_admin_manage_page',
|
101 |
|
102 |
} elseif ( isset( $_POST['new_php_cron'] ) ) {
|
103 |
if ( ! current_user_can( 'edit_files' ) ) {
|
104 |
+
wp_die( esc_html__( 'You are not allowed to add new PHP cron events.', 'wp-crontrol' ), 401 );
|
105 |
}
|
106 |
check_admin_referer( 'new-cron' );
|
107 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
109 |
'code' => $in_hookcode,
|
110 |
'name' => $in_eventname,
|
111 |
);
|
112 |
+
$next_run = ( 'custom' === $in_next_run_date ) ? $in_next_run_date_custom : $in_next_run_date;
|
113 |
$this->add_cron( $next_run, $in_schedule, 'crontrol_cron_job', $args );
|
114 |
$hookname = ( ! empty( $in_eventname ) ) ? $in_eventname : __( 'PHP Cron', 'wp-crontrol' );
|
115 |
$redirect = array(
|
122 |
|
123 |
} elseif ( isset( $_POST['edit_cron'] ) ) {
|
124 |
if ( ! current_user_can( 'manage_options' ) ) {
|
125 |
+
wp_die( esc_html__( 'You are not allowed to edit cron events.', 'wp-crontrol' ), 401 );
|
126 |
}
|
127 |
|
128 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
129 |
check_admin_referer( "edit-cron_{$in_original_hookname}_{$in_original_sig}_{$in_original_next_run}" );
|
130 |
|
131 |
if ( 'crontrol_cron_job' === $in_hookname && ! current_user_can( 'edit_files' ) ) {
|
132 |
+
wp_die( esc_html__( 'You are not allowed to edit PHP cron events.', 'wp-crontrol' ), 401 );
|
133 |
}
|
134 |
|
135 |
$in_args = json_decode( $in_args, true );
|
136 |
$i = $this->delete_cron( $in_original_hookname, $in_original_sig, $in_original_next_run );
|
137 |
+
$next_run = ( 'custom' === $in_next_run_date ) ? $in_next_run_date_custom : $in_next_run_date;
|
138 |
$i = $this->add_cron( $next_run, $in_schedule, $in_hookname, $in_args );
|
139 |
$redirect = array(
|
140 |
'page' => 'crontrol_admin_manage_page',
|
146 |
|
147 |
} elseif ( isset( $_POST['edit_php_cron'] ) ) {
|
148 |
if ( ! current_user_can( 'edit_files' ) ) {
|
149 |
+
wp_die( esc_html__( 'You are not allowed to edit PHP cron events.', 'wp-crontrol' ), 401 );
|
150 |
}
|
151 |
|
152 |
extract( wp_unslash( $_POST ), EXTR_PREFIX_ALL, 'in' );
|
158 |
'name' => $in_eventname,
|
159 |
);
|
160 |
$i = $this->delete_cron( $in_original_hookname, $in_original_sig, $in_original_next_run );
|
161 |
+
$next_run = ( 'custom' === $in_next_run_date ) ? $in_next_run_date_custom : $in_next_run_date;
|
162 |
$i = $this->add_cron( $next_run, $in_schedule, 'crontrol_cron_job', $args );
|
163 |
$hookname = ( ! empty( $in_eventname ) ) ? $in_eventname : __( 'PHP Cron', 'wp-crontrol' );
|
164 |
$redirect = array(
|
171 |
|
172 |
} elseif ( isset( $_POST['new_schedule'] ) ) {
|
173 |
if ( ! current_user_can( 'manage_options' ) ) {
|
174 |
+
wp_die( esc_html__( 'You are not allowed to add new cron schedules.', 'wp-crontrol' ), 401 );
|
175 |
}
|
176 |
check_admin_referer( 'new-sched' );
|
177 |
$name = wp_unslash( $_POST['internal_name'] );
|
179 |
$display = wp_unslash( $_POST['display_name'] );
|
180 |
|
181 |
// The user entered something that wasn't a number.
|
182 |
+
// Try to convert it with strtotime.
|
183 |
if ( ! is_numeric( $interval ) ) {
|
184 |
$now = time();
|
185 |
$future = strtotime( $interval, $now );
|
214 |
|
215 |
} elseif ( isset( $_GET['action'] ) && 'delete-sched' == $_GET['action'] ) {
|
216 |
if ( ! current_user_can( 'manage_options' ) ) {
|
217 |
+
wp_die( esc_html__( 'You are not allowed to delete cron schedules.', 'wp-crontrol' ), 401 );
|
218 |
}
|
219 |
$id = wp_unslash( $_GET['id'] );
|
220 |
check_admin_referer( "delete-sched_{$id}" );
|
229 |
|
230 |
} elseif ( isset( $_POST['delete_crons'] ) ) {
|
231 |
if ( ! current_user_can( 'manage_options' ) ) {
|
232 |
+
wp_die( esc_html__( 'You are not allowed to delete cron events.', 'wp-crontrol' ), 401 );
|
233 |
}
|
234 |
check_admin_referer( 'bulk-delete-crons' );
|
235 |
|
261 |
|
262 |
} elseif ( isset( $_GET['action'] ) && 'delete-cron' == $_GET['action'] ) {
|
263 |
if ( ! current_user_can( 'manage_options' ) ) {
|
264 |
+
wp_die( esc_html__( 'You are not allowed to delete cron events.', 'wp-crontrol' ), 401 );
|
265 |
}
|
266 |
$id = wp_unslash( $_GET['id'] );
|
267 |
$sig = wp_unslash( $_GET['sig'] );
|
269 |
check_admin_referer( "delete-cron_{$id}_{$sig}_{$next_run}" );
|
270 |
|
271 |
if ( 'crontrol_cron_job' === $id && ! current_user_can( 'edit_files' ) ) {
|
272 |
+
wp_die( esc_html__( 'You are not allowed to delete PHP cron events.', 'wp-crontrol' ), 401 );
|
273 |
}
|
274 |
|
275 |
if ( $this->delete_cron( $id, $sig, $next_run ) ) {
|
293 |
|
294 |
} elseif ( isset( $_GET['action'] ) && 'run-cron' == $_GET['action'] ) {
|
295 |
if ( ! current_user_can( 'manage_options' ) ) {
|
296 |
+
wp_die( esc_html__( 'You are not allowed to run cron events.', 'wp-crontrol' ), 401 );
|
297 |
}
|
298 |
$id = wp_unslash( $_GET['id'] );
|
299 |
$sig = wp_unslash( $_GET['sig'] );
|
323 |
*
|
324 |
* Executes an event by scheduling a new single event with the same arguments.
|
325 |
*
|
326 |
+
* @param string $hookname The hook name of the cron event to run.
|
327 |
+
* @param string $sig The cron event signature.
|
328 |
*/
|
329 |
public function run_cron( $hookname, $sig ) {
|
330 |
$crons = _get_cron_array();
|
343 |
/**
|
344 |
* Adds a new cron event.
|
345 |
*
|
346 |
+
* @param string $next_run A GMT time that the event should be run at.
|
347 |
+
* @param string $schedule The recurrence of the cron event.
|
348 |
+
* @param string $hookname The name of the hook to execute.
|
349 |
+
* @param array $args Arguments to add to the cron event.
|
350 |
*/
|
351 |
public function add_cron( $next_run, $schedule, $hookname, $args ) {
|
352 |
$next_run = strtotime( $next_run );
|
368 |
/**
|
369 |
* Deletes a cron event.
|
370 |
*
|
371 |
+
* @param string $to_delete The hook name of the event to delete.
|
372 |
+
* @param string $sig The cron event signature.
|
373 |
+
* @param string $next_run The GMT time that the event would be run at.
|
374 |
*/
|
375 |
public function delete_cron( $to_delete, $sig, $next_run ) {
|
376 |
$crons = _get_cron_array();
|
385 |
/**
|
386 |
* Adds a new custom cron schedule.
|
387 |
*
|
388 |
+
* @param string $name The internal name of the schedule.
|
389 |
+
* @param int $interval The interval between executions of the new schedule.
|
390 |
+
* @param string $display The display name of the schedule.
|
391 |
*/
|
392 |
public function add_schedule( $name, $interval, $display ) {
|
393 |
$old_scheds = get_option( 'crontrol_schedules', array() );
|
417 |
public function action_activate() {
|
418 |
add_option( 'crontrol_schedules', array() );
|
419 |
|
420 |
+
// If there's never been a cron event, _get_cron_array will return false.
|
421 |
if ( _get_cron_array() === false ) {
|
422 |
_set_cron_array( array() );
|
423 |
}
|
433 |
add_management_page( esc_html__( 'Cron Events', 'wp-crontrol' ), esc_html__( 'Cron Events', 'wp-crontrol' ), 'manage_options', 'crontrol_admin_manage_page', array( $this, 'admin_manage_page' ) );
|
434 |
}
|
435 |
|
436 |
+
/**
|
437 |
+
* Adds items to the plugin's action links on the Plugins listing screen.
|
438 |
+
*
|
439 |
+
* @param string[] $actions Array of action links.
|
440 |
+
* @param string $plugin_file Path to the plugin file relative to the plugins directory.
|
441 |
+
* @param array $plugin_data An array of plugin data.
|
442 |
+
* @param string $context The plugin context.
|
443 |
+
* @return string[] Array of action links.
|
444 |
+
*/
|
445 |
public function plugin_action_links( $actions, $plugin_file, $plugin_data, $context ) {
|
446 |
$actions['crontrol-events'] = sprintf(
|
447 |
'<a href="%s">%s</a>',
|
521 |
<?php
|
522 |
} else {
|
523 |
foreach ( $schedules as $name => $data ) {
|
524 |
+
printf(
|
525 |
+
'<tr id="sched-%s">',
|
526 |
esc_attr( $name )
|
527 |
);
|
528 |
+
printf(
|
529 |
+
'<td>%s</td>',
|
530 |
esc_html( $name )
|
531 |
);
|
532 |
+
printf(
|
533 |
+
'<td>%s (%s)</td>',
|
534 |
esc_html( $data['interval'] ),
|
535 |
esc_html( $this->interval( $data['interval'] ) )
|
536 |
);
|
537 |
+
printf(
|
538 |
+
'<td>%s</td>',
|
539 |
esc_html( $data['display'] )
|
540 |
);
|
541 |
|
568 |
</div>
|
569 |
<div class="wrap">
|
570 |
<p class="description">
|
571 |
+
<?php
|
572 |
+
printf(
|
573 |
+
'<a href="%s">%s</a>',
|
574 |
+
esc_url( admin_url( 'tools.php?page=crontrol_admin_manage_page' ) ),
|
575 |
+
esc_html__( 'Manage Cron Events', 'wp-crontrol' )
|
576 |
+
);
|
577 |
?>
|
578 |
</p>
|
579 |
</div>
|
612 |
return $schedules;
|
613 |
}
|
614 |
|
615 |
+
/**
|
616 |
+
* Internal sorting comparison callback function. Compares schedules by their interval.
|
617 |
+
*
|
618 |
+
* @param array $a The first schedule to compare for sorting.
|
619 |
+
* @param array $b The second schedule to compare for sorting.
|
620 |
+
* @return int An integer less than, equal to, or greater than zero if the first argument is considered to be
|
621 |
+
* respectively less than, equal to, or greater than the second.
|
622 |
+
*/
|
623 |
protected function sort_schedules( $a, $b ) {
|
624 |
return ( $a['interval'] - $b['interval'] );
|
625 |
}
|
627 |
/**
|
628 |
* Displays a dropdown filled with the possible schedules, including non-repeating.
|
629 |
*
|
630 |
+
* @param bool $current The currently selected schedule.
|
631 |
*/
|
632 |
public function schedules_dropdown( $current = false ) {
|
633 |
$schedules = $this->get_schedules();
|
652 |
/**
|
653 |
* Gets the status of WP-Cron functionality on the site by performing a test spawn. Cached for one hour when all is well.
|
654 |
*
|
655 |
+
* @param bool $cache Whether to use the cached result from previous calls.
|
656 |
+
* @return true|WP_Error Boolean true if the cron spawner is working as expected, or a WP_Error object if not.
|
657 |
*/
|
658 |
public function test_cron_spawn( $cache = true ) {
|
659 |
global $wp_version;
|
708 |
|
709 |
/**
|
710 |
* Shows the status of WP-Cron functionality on the site. Only displays a message when there's a problem.
|
|
|
711 |
*/
|
712 |
public function show_cron_status() {
|
713 |
|
723 |
} else {
|
724 |
?>
|
725 |
<div id="cron-status-error" class="error">
|
726 |
+
<p>
|
727 |
+
<?php
|
728 |
printf(
|
729 |
/* translators: 1: Error message text. */
|
730 |
esc_html__( 'There was a problem spawning a call to the WP-Cron system on your site. This means WP-Cron events on your site may not work. The problem was: %s', 'wp-crontrol' ),
|
731 |
'<br><strong>' . esc_html( $status->get_error_message() ) . '</strong>'
|
732 |
);
|
733 |
+
?>
|
734 |
+
</p>
|
735 |
</div>
|
736 |
<?php
|
737 |
}
|
764 |
/**
|
765 |
* Shows the form used to add/edit cron events.
|
766 |
*
|
767 |
+
* @param bool $is_php Whether this is a PHP cron event.
|
768 |
+
* @param mixed $existing An array of existing values for the cron event, or null.
|
769 |
*/
|
770 |
public function show_cron_form( $is_php, $existing ) {
|
771 |
$new_tabs = array(
|
807 |
$action = $is_php ? 'edit_php_cron' : 'edit_cron';
|
808 |
$button = $is_php ? $modify_tabs['php-cron'] : $modify_tabs['cron'];
|
809 |
$show_edit_tab = true;
|
810 |
+
$next_run_date = get_date_from_gmt( date( 'Y-m-d H:i:s', $existing['next_run'] ), 'Y-m-d H:i:s' );
|
811 |
} else {
|
812 |
$other_fields = wp_nonce_field( 'new-cron', '_wpnonce', true, false );
|
813 |
$existing = array(
|
819 |
$action = $is_php ? 'new_php_cron' : 'new_cron';
|
820 |
$button = $is_php ? $new_tabs['php-cron'] : $new_tabs['cron'];
|
821 |
$show_edit_tab = false;
|
|
|
822 |
$next_run_date = '';
|
823 |
}
|
824 |
if ( $is_php ) {
|
834 |
?>
|
835 |
<div id="crontrol_form" class="wrap narrow">
|
836 |
<h2 class="nav-tab-wrapper">
|
837 |
+
<a href="<?php echo esc_url( $new_links['cron'] ); ?>" class="nav-tab<?php echo ( ! $show_edit_tab && ! $is_php ) ? ' nav-tab-active' : ''; ?>"><?php echo esc_html( $new_tabs['cron'] ); ?></a>
|
838 |
+
<a href="<?php echo esc_url( $new_links['php-cron'] ); ?>" class="nav-tab<?php echo ( ! $show_edit_tab && $is_php ) ? ' nav-tab-active' : ''; ?>"><?php echo esc_html( $new_tabs['php-cron'] ); ?></a>
|
839 |
<?php if ( $show_edit_tab ) { ?>
|
840 |
<span class="nav-tab nav-tab-active"><?php echo esc_html( $button ); ?></span>
|
841 |
<?php } ?>
|
891 |
<tr>
|
892 |
<th valign="top" scope="row"><label for="next_run_date"><?php esc_html_e( 'Next Run', 'wp-crontrol' ); ?></label></th>
|
893 |
<td>
|
894 |
+
<ul>
|
895 |
+
<li>
|
896 |
+
<label>
|
897 |
+
<input type="radio" name="next_run_date" value="now()" checked>
|
898 |
+
<?php esc_html_e( 'Now', 'wp-crontrol' ); ?>
|
899 |
+
</label>
|
900 |
+
</li>
|
901 |
+
<li>
|
902 |
+
<label>
|
903 |
+
<input type="radio" name="next_run_date" value="+1 day">
|
904 |
+
<?php esc_html_e( 'Tomorrow', 'wp-crontrol' ); ?>
|
905 |
+
</label>
|
906 |
+
</li>
|
907 |
+
<li>
|
908 |
+
<label>
|
909 |
+
<input type="radio" name="next_run_date" value="custom" id="next_run_date_custom" <?php checked( $show_edit_tab ); ?>>
|
910 |
+
<?php
|
911 |
+
printf(
|
912 |
+
/* translators: %s: An input field for specifying a date and time */
|
913 |
+
esc_html__( 'At: %s', 'wp-crontrol' ),
|
914 |
+
sprintf(
|
915 |
+
'<input type="text" name="next_run_date_custom" value="%s" class="regular-text" onfocus="jQuery(\'#next_run_date_custom\').prop(\'checked\',true);" />',
|
916 |
+
esc_attr( $next_run_date )
|
917 |
+
)
|
918 |
+
);
|
919 |
+
?>
|
920 |
+
</label>
|
921 |
+
</li>
|
922 |
+
</ul>
|
923 |
+
|
924 |
<p class="description">
|
925 |
<?php
|
926 |
printf(
|
927 |
+
/* translators: 1: Date/time format for an input field, 2: PHP function name. */
|
928 |
+
esc_html__( 'Format: %1$s or anything accepted by %2$s', 'wp-crontrol' ),
|
929 |
+
'<code>YYYY-MM-DD HH:MM:SS</code>',
|
930 |
+
'<a href="https://secure.php.net/manual/en/function.strtotime.html"><code>strtotime()</code></a>'
|
931 |
);
|
932 |
?>
|
933 |
</p>
|
934 |
+
<p class="description">
|
935 |
<?php
|
936 |
+
printf(
|
937 |
+
/* translators: %s Timezone name. */
|
938 |
+
esc_html__( 'Timezone: %s', 'wp-crontrol' ),
|
939 |
+
'<code>' . esc_html( $this->get_timezone_name() ) . '</code>'
|
940 |
+
);
|
941 |
?>
|
942 |
</p>
|
943 |
</td>
|
968 |
<?php
|
969 |
}
|
970 |
|
971 |
+
/**
|
972 |
+
* Returns a flattened array of cron events.
|
973 |
+
*
|
974 |
+
* @return array[]|WP_Error An array of cron event arrays, or a WP_Error object if there's an error or no events.
|
975 |
+
*/
|
976 |
public function get_cron_events() {
|
977 |
|
978 |
$crons = _get_cron_array();
|
989 |
foreach ( $cron as $hook => $dings ) {
|
990 |
foreach ( $dings as $sig => $data ) {
|
991 |
|
992 |
+
// This is a prime candidate for a Crontrol_Event class but I'm not bothering currently.
|
993 |
$events[ "$hook-$sig-$time" ] = (object) array(
|
994 |
'hook' => $hook,
|
995 |
'time' => $time,
|
1034 |
printf( '<div id="message" class="updated notice is-dismissible"><p>%s</p></div>', $msg ); // WPCS:: XSS ok.
|
1035 |
}
|
1036 |
$events = $this->get_cron_events();
|
1037 |
+
$doing_edit = ( isset( $_GET['action'] ) && 'edit-cron' === $_GET['action'] ) ? wp_unslash( $_GET['id'] ) : false;
|
1038 |
$time_format = 'Y-m-d H:i:s';
|
1039 |
$can_edit_files = current_user_can( 'edit_files' );
|
1040 |
|
1143 |
|
1144 |
echo '<td style="white-space:nowrap">';
|
1145 |
if ( $event->schedule ) {
|
1146 |
+
$schedule_name = $this->get_schedule_name( $event );
|
1147 |
+
if ( is_wp_error( $schedule_name ) ) {
|
1148 |
+
printf(
|
1149 |
+
'<span class="dashicons dashicons-warning"></span>%s',
|
1150 |
+
esc_html( $schedule_name->get_error_message() )
|
1151 |
+
);
|
1152 |
+
} else {
|
1153 |
+
echo esc_html( $schedule_name );
|
1154 |
+
}
|
1155 |
} else {
|
1156 |
esc_html_e( 'Non-repeating', 'wp-crontrol' );
|
1157 |
}
|
1206 |
?>
|
1207 |
</tbody>
|
1208 |
</table>
|
1209 |
+
<p style="float:right">
|
1210 |
+
<?php
|
1211 |
+
echo esc_html( sprintf(
|
1212 |
+
/* translators: %s: The current date and time */
|
1213 |
+
__( 'Current site time: %s', 'wp-crontrol' ),
|
1214 |
+
date_i18n( 'Y-m-d H:i:s' )
|
1215 |
+
) );
|
1216 |
+
?>
|
1217 |
+
</p>
|
1218 |
<?php
|
1219 |
wp_nonce_field( 'bulk-delete-crons' );
|
1220 |
submit_button(
|
1230 |
if ( is_array( $doing_edit ) ) {
|
1231 |
$this->show_cron_form( 'crontrol_cron_job' == $doing_edit['hookname'], $doing_edit );
|
1232 |
} else {
|
1233 |
+
$this->show_cron_form( ( isset( $_GET['action'] ) && 'new-php-cron' === $_GET['action'] ), false );
|
1234 |
}
|
1235 |
}
|
1236 |
|
1237 |
+
/**
|
1238 |
+
* Returns an array of the callback functions that are attached to the given hook name.
|
1239 |
+
*
|
1240 |
+
* @param string $name The hook name.
|
1241 |
+
* @return array[] Array of callbacks attached to the hook.
|
1242 |
+
*/
|
1243 |
protected function get_action_callbacks( $name ) {
|
1244 |
global $wp_filter;
|
1245 |
|
1247 |
|
1248 |
if ( isset( $wp_filter[ $name ] ) ) {
|
1249 |
|
1250 |
+
// See http://core.trac.wordpress.org/ticket/17817.
|
1251 |
$action = $wp_filter[ $name ];
|
1252 |
|
1253 |
foreach ( $action as $priority => $callbacks ) {
|
1255 |
$callback = self::populate_callback( $callback );
|
1256 |
|
1257 |
$actions[] = array(
|
1258 |
+
'priority' => $priority,
|
1259 |
+
'callback' => $callback,
|
1260 |
);
|
1261 |
}
|
1262 |
}
|
1265 |
return $actions;
|
1266 |
}
|
1267 |
|
1268 |
+
/**
|
1269 |
+
* Populates the details of the given callback function.
|
1270 |
+
*
|
1271 |
+
* @param array $callback A callback entry.
|
1272 |
+
* @return The updated callback entry.
|
1273 |
+
*/
|
1274 |
public static function populate_callback( array $callback ) {
|
1275 |
+
// If Query Monitor is installed, use its rich callback analysis.
|
|
|
1276 |
if ( method_exists( 'QM_Util', 'populate_callback' ) ) {
|
1277 |
return QM_Util::populate_callback( $callback );
|
1278 |
}
|
1306 |
|
1307 |
}
|
1308 |
|
1309 |
+
/**
|
1310 |
+
* Returns a user-friendly representation of the callback function.
|
1311 |
+
*
|
1312 |
+
* @param array $callback The callback entry.
|
1313 |
+
* @return string The displayable version of the callback name.
|
1314 |
+
*/
|
1315 |
public static function output_callback( array $callback ) {
|
1316 |
$qm = WP_PLUGIN_DIR . '/query-monitor/query-monitor.php';
|
1317 |
$html = plugin_dir_path( $qm ) . 'output/Html.php';
|
1318 |
|
1319 |
+
// If Query Monitor is installed, use its rich callback output.
|
1320 |
if ( class_exists( 'QueryMonitor' ) && file_exists( $html ) ) {
|
1321 |
require_once $html;
|
1322 |
|
1352 |
* echo self::interval( 90 );
|
1353 |
* // 1 minute 30 seconds
|
1354 |
*
|
1355 |
+
* @param int $since A period of time in seconds.
|
1356 |
+
* @return string An interval represented as a string.
|
1357 |
*/
|
1358 |
public function interval( $since ) {
|
1359 |
+
// Array of time period chunks.
|
1360 |
$chunks = array(
|
1361 |
/* translators: 1: The number of years in an interval of time. */
|
1362 |
array( 60 * 60 * 24 * 365, _n_noop( '%s year', '%s years', 'wp-crontrol' ) ),
|
1378 |
return __( 'now', 'wp-crontrol' );
|
1379 |
}
|
1380 |
|
1381 |
+
/**
|
1382 |
+
* We only want to output two chunks of time here, eg:
|
1383 |
+
* x years, xx months
|
1384 |
+
* x days, xx hours
|
1385 |
+
* so there's only two bits of calculation below:
|
1386 |
+
*/
|
1387 |
$j = count( $chunks );
|
1388 |
|
1389 |
+
// Step one: the first chunk.
|
1390 |
for ( $i = 0; $i < $j; $i++ ) {
|
1391 |
$seconds = $chunks[ $i ][0];
|
1392 |
$name = $chunks[ $i ][1];
|
1393 |
|
1394 |
+
// Finding the biggest chunk (if the chunk fits, break).
|
1395 |
$count = floor( $since / $seconds );
|
1396 |
if ( $count ) {
|
1397 |
break;
|
1398 |
}
|
1399 |
}
|
1400 |
|
1401 |
+
// Set output var.
|
1402 |
$output = sprintf( translate_nooped_plural( $name, $count, 'wp-crontrol' ), $count );
|
1403 |
|
1404 |
+
// Step two: the second chunk.
|
1405 |
if ( $i + 1 < $j ) {
|
1406 |
$seconds2 = $chunks[ $i + 1 ][0];
|
1407 |
$name2 = $chunks[ $i + 1 ][1];
|
1408 |
$count2 = floor( ( $since - ( $seconds * $count ) ) / $seconds2 );
|
1409 |
if ( $count2 ) {
|
1410 |
+
// Add to output var.
|
1411 |
$output .= ' ' . sprintf( translate_nooped_plural( $name2, $count2, 'wp-crontrol' ), $count2 );
|
1412 |
}
|
1413 |
}
|
1416 |
}
|
1417 |
|
1418 |
/**
|
1419 |
+
* Returns the schedule display name for a given event.
|
|
|
|
|
1420 |
*
|
1421 |
+
* @param stdClass $event A WP-Cron event.
|
1422 |
+
* @return string|WP_Error The interval display name, or a WP_Error object if no such schedule exists.
|
1423 |
*/
|
1424 |
+
protected function get_schedule_name( stdClass $event ) {
|
1425 |
$schedules = $this->get_schedules();
|
1426 |
|
1427 |
+
if ( isset( $schedules[ $event->schedule ] ) ) {
|
1428 |
+
return $schedules[ $event->schedule ]['display'];
|
|
|
|
|
1429 |
}
|
1430 |
|
1431 |
+
return new WP_Error( 'unknown_schedule', __( 'Unknown', 'wp-crontrol' ) );
|
1432 |
}
|
1433 |
|
1434 |
/**
|
1475 |
) );
|
1476 |
}
|
1477 |
|
1478 |
+
/**
|
1479 |
+
* Singleton instance instantiator.
|
1480 |
+
*/
|
1481 |
public static function init() {
|
1482 |
|
1483 |
static $instance = null;
|
1484 |
|
1485 |
if ( ! $instance ) {
|
1486 |
+
$instance = new Crontrol();
|
1487 |
}
|
1488 |
|
1489 |
return $instance;
|
1491 |
}
|
1492 |
}
|
1493 |
|
1494 |
+
// Get this show on the road.
|
1495 |
Crontrol::init();
|