WP Crontrol - Version 1.0-beta1

Version Description

Download this release

Release Info

Developer scompt
Plugin Icon 128x128 WP Crontrol
Version 1.0-beta1
Comparing to
See all releases

Code changes from version 0.3 to 1.0-beta1

JSON.php ADDED
@@ -0,0 +1,806 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
+
4
+ /**
5
+ * Converts to and from JSON format.
6
+ *
7
+ * JSON (JavaScript Object Notation) is a lightweight data-interchange
8
+ * format. It is easy for humans to read and write. It is easy for machines
9
+ * to parse and generate. It is based on a subset of the JavaScript
10
+ * Programming Language, Standard ECMA-262 3rd Edition - December 1999.
11
+ * This feature can also be found in Python. JSON is a text format that is
12
+ * completely language independent but uses conventions that are familiar
13
+ * to programmers of the C-family of languages, including C, C++, C#, Java,
14
+ * JavaScript, Perl, TCL, and many others. These properties make JSON an
15
+ * ideal data-interchange language.
16
+ *
17
+ * This package provides a simple encoder and decoder for JSON notation. It
18
+ * is intended for use with client-side Javascript applications that make
19
+ * use of HTTPRequest to perform server communication functions - data can
20
+ * be encoded into JSON notation for use in a client-side javascript, or
21
+ * decoded from incoming Javascript requests. JSON format is native to
22
+ * Javascript, and can be directly eval()'ed with no further parsing
23
+ * overhead
24
+ *
25
+ * All strings should be in ASCII or UTF-8 format!
26
+ *
27
+ * LICENSE: Redistribution and use in source and binary forms, with or
28
+ * without modification, are permitted provided that the following
29
+ * conditions are met: Redistributions of source code must retain the
30
+ * above copyright notice, this list of conditions and the following
31
+ * disclaimer. Redistributions in binary form must reproduce the above
32
+ * copyright notice, this list of conditions and the following disclaimer
33
+ * in the documentation and/or other materials provided with the
34
+ * distribution.
35
+ *
36
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
37
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
38
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
39
+ * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
40
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
41
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
42
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
43
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
44
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
45
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
46
+ * DAMAGE.
47
+ *
48
+ * @category
49
+ * @package Services_JSON
50
+ * @author Michal Migurski <mike-json@teczno.com>
51
+ * @author Matt Knapp <mdknapp[at]gmail[dot]com>
52
+ * @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
53
+ * @copyright 2005 Michal Migurski
54
+ * @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
55
+ * @license http://www.opensource.org/licenses/bsd-license.php
56
+ * @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
57
+ */
58
+
59
+ /**
60
+ * Marker constant for Services_JSON::decode(), used to flag stack state
61
+ */
62
+ define('SERVICES_JSON_SLICE', 1);
63
+
64
+ /**
65
+ * Marker constant for Services_JSON::decode(), used to flag stack state
66
+ */
67
+ define('SERVICES_JSON_IN_STR', 2);
68
+
69
+ /**
70
+ * Marker constant for Services_JSON::decode(), used to flag stack state
71
+ */
72
+ define('SERVICES_JSON_IN_ARR', 3);
73
+
74
+ /**
75
+ * Marker constant for Services_JSON::decode(), used to flag stack state
76
+ */
77
+ define('SERVICES_JSON_IN_OBJ', 4);
78
+
79
+ /**
80
+ * Marker constant for Services_JSON::decode(), used to flag stack state
81
+ */
82
+ define('SERVICES_JSON_IN_CMT', 5);
83
+
84
+ /**
85
+ * Behavior switch for Services_JSON::decode()
86
+ */
87
+ define('SERVICES_JSON_LOOSE_TYPE', 16);
88
+
89
+ /**
90
+ * Behavior switch for Services_JSON::decode()
91
+ */
92
+ define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
93
+
94
+ /**
95
+ * Converts to and from JSON format.
96
+ *
97
+ * Brief example of use:
98
+ *
99
+ * <code>
100
+ * // create a new instance of Services_JSON
101
+ * $json = new Services_JSON();
102
+ *
103
+ * // convert a complexe value to JSON notation, and send it to the browser
104
+ * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
105
+ * $output = $json->encode($value);
106
+ *
107
+ * print($output);
108
+ * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
109
+ *
110
+ * // accept incoming POST data, assumed to be in JSON notation
111
+ * $input = file_get_contents('php://input', 1000000);
112
+ * $value = $json->decode($input);
113
+ * </code>
114
+ */
115
+ class Services_JSON
116
+ {
117
+ /**
118
+ * constructs a new JSON instance
119
+ *
120
+ * @param int $use object behavior flags; combine with boolean-OR
121
+ *
122
+ * possible values:
123
+ * - SERVICES_JSON_LOOSE_TYPE: loose typing.
124
+ * "{...}" syntax creates associative arrays
125
+ * instead of objects in decode().
126
+ * - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
127
+ * Values which can't be encoded (e.g. resources)
128
+ * appear as NULL instead of throwing errors.
129
+ * By default, a deeply-nested resource will
130
+ * bubble up with an error, so all return values
131
+ * from encode() should be checked with isError()
132
+ */
133
+ function Services_JSON($use = 0)
134
+ {
135
+ $this->use = $use;
136
+ }
137
+
138
+ /**
139
+ * convert a string from one UTF-16 char to one UTF-8 char
140
+ *
141
+ * Normally should be handled by mb_convert_encoding, but
142
+ * provides a slower PHP-only method for installations
143
+ * that lack the multibye string extension.
144
+ *
145
+ * @param string $utf16 UTF-16 character
146
+ * @return string UTF-8 character
147
+ * @access private
148
+ */
149
+ function utf162utf8($utf16)
150
+ {
151
+ // oh please oh please oh please oh please oh please
152
+ if(function_exists('mb_convert_encoding')) {
153
+ return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
154
+ }
155
+
156
+ $bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
157
+
158
+ switch(true) {
159
+ case ((0x7F & $bytes) == $bytes):
160
+ // this case should never be reached, because we are in ASCII range
161
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
162
+ return chr(0x7F & $bytes);
163
+
164
+ case (0x07FF & $bytes) == $bytes:
165
+ // return a 2-byte UTF-8 character
166
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
167
+ return chr(0xC0 | (($bytes >> 6) & 0x1F))
168
+ . chr(0x80 | ($bytes & 0x3F));
169
+
170
+ case (0xFFFF & $bytes) == $bytes:
171
+ // return a 3-byte UTF-8 character
172
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
173
+ return chr(0xE0 | (($bytes >> 12) & 0x0F))
174
+ . chr(0x80 | (($bytes >> 6) & 0x3F))
175
+ . chr(0x80 | ($bytes & 0x3F));
176
+ }
177
+
178
+ // ignoring UTF-32 for now, sorry
179
+ return '';
180
+ }
181
+
182
+ /**
183
+ * convert a string from one UTF-8 char to one UTF-16 char
184
+ *
185
+ * Normally should be handled by mb_convert_encoding, but
186
+ * provides a slower PHP-only method for installations
187
+ * that lack the multibye string extension.
188
+ *
189
+ * @param string $utf8 UTF-8 character
190
+ * @return string UTF-16 character
191
+ * @access private
192
+ */
193
+ function utf82utf16($utf8)
194
+ {
195
+ // oh please oh please oh please oh please oh please
196
+ if(function_exists('mb_convert_encoding')) {
197
+ return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
198
+ }
199
+
200
+ switch(strlen($utf8)) {
201
+ case 1:
202
+ // this case should never be reached, because we are in ASCII range
203
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
204
+ return $utf8;
205
+
206
+ case 2:
207
+ // return a UTF-16 character from a 2-byte UTF-8 char
208
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
209
+ return chr(0x07 & (ord($utf8{0}) >> 2))
210
+ . chr((0xC0 & (ord($utf8{0}) << 6))
211
+ | (0x3F & ord($utf8{1})));
212
+
213
+ case 3:
214
+ // return a UTF-16 character from a 3-byte UTF-8 char
215
+ // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
216
+ return chr((0xF0 & (ord($utf8{0}) << 4))
217
+ | (0x0F & (ord($utf8{1}) >> 2)))
218
+ . chr((0xC0 & (ord($utf8{1}) << 6))
219
+ | (0x7F & ord($utf8{2})));
220
+ }
221
+
222
+ // ignoring UTF-32 for now, sorry
223
+ return '';
224
+ }
225
+
226
+ /**
227
+ * encodes an arbitrary variable into JSON format
228
+ *
229
+ * @param mixed $var any number, boolean, string, array, or object to be encoded.
230
+ * see argument 1 to Services_JSON() above for array-parsing behavior.
231
+ * if var is a strng, note that encode() always expects it
232
+ * to be in ASCII or UTF-8 format!
233
+ *
234
+ * @return mixed JSON string representation of input var or an error if a problem occurs
235
+ * @access public
236
+ */
237
+ function encode($var)
238
+ {
239
+ switch (gettype($var)) {
240
+ case 'boolean':
241
+ return $var ? 'true' : 'false';
242
+
243
+ case 'NULL':
244
+ return 'null';
245
+
246
+ case 'integer':
247
+ return (int) $var;
248
+
249
+ case 'double':
250
+ case 'float':
251
+ return (float) $var;
252
+
253
+ case 'string':
254
+ // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
255
+ $ascii = '';
256
+ $strlen_var = strlen($var);
257
+
258
+ /*
259
+ * Iterate over every character in the string,
260
+ * escaping with a slash or encoding to UTF-8 where necessary
261
+ */
262
+ for ($c = 0; $c < $strlen_var; ++$c) {
263
+
264
+ $ord_var_c = ord($var{$c});
265
+
266
+ switch (true) {
267
+ case $ord_var_c == 0x08:
268
+ $ascii .= '\b';
269
+ break;
270
+ case $ord_var_c == 0x09:
271
+ $ascii .= '\t';
272
+ break;
273
+ case $ord_var_c == 0x0A:
274
+ $ascii .= '\n';
275
+ break;
276
+ case $ord_var_c == 0x0C:
277
+ $ascii .= '\f';
278
+ break;
279
+ case $ord_var_c == 0x0D:
280
+ $ascii .= '\r';
281
+ break;
282
+
283
+ case $ord_var_c == 0x22:
284
+ case $ord_var_c == 0x2F:
285
+ case $ord_var_c == 0x5C:
286
+ // double quote, slash, slosh
287
+ $ascii .= '\\'.$var{$c};
288
+ break;
289
+
290
+ case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
291
+ // characters U-00000000 - U-0000007F (same as ASCII)
292
+ $ascii .= $var{$c};
293
+ break;
294
+
295
+ case (($ord_var_c & 0xE0) == 0xC0):
296
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
297
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
298
+ $char = pack('C*', $ord_var_c, ord($var{$c + 1}));
299
+ $c += 1;
300
+ $utf16 = $this->utf82utf16($char);
301
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
302
+ break;
303
+
304
+ case (($ord_var_c & 0xF0) == 0xE0):
305
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
306
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
307
+ $char = pack('C*', $ord_var_c,
308
+ ord($var{$c + 1}),
309
+ ord($var{$c + 2}));
310
+ $c += 2;
311
+ $utf16 = $this->utf82utf16($char);
312
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
313
+ break;
314
+
315
+ case (($ord_var_c & 0xF8) == 0xF0):
316
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
317
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
318
+ $char = pack('C*', $ord_var_c,
319
+ ord($var{$c + 1}),
320
+ ord($var{$c + 2}),
321
+ ord($var{$c + 3}));
322
+ $c += 3;
323
+ $utf16 = $this->utf82utf16($char);
324
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
325
+ break;
326
+
327
+ case (($ord_var_c & 0xFC) == 0xF8):
328
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
329
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
330
+ $char = pack('C*', $ord_var_c,
331
+ ord($var{$c + 1}),
332
+ ord($var{$c + 2}),
333
+ ord($var{$c + 3}),
334
+ ord($var{$c + 4}));
335
+ $c += 4;
336
+ $utf16 = $this->utf82utf16($char);
337
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
338
+ break;
339
+
340
+ case (($ord_var_c & 0xFE) == 0xFC):
341
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
342
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
343
+ $char = pack('C*', $ord_var_c,
344
+ ord($var{$c + 1}),
345
+ ord($var{$c + 2}),
346
+ ord($var{$c + 3}),
347
+ ord($var{$c + 4}),
348
+ ord($var{$c + 5}));
349
+ $c += 5;
350
+ $utf16 = $this->utf82utf16($char);
351
+ $ascii .= sprintf('\u%04s', bin2hex($utf16));
352
+ break;
353
+ }
354
+ }
355
+
356
+ return '"'.$ascii.'"';
357
+
358
+ case 'array':
359
+ /*
360
+ * As per JSON spec if any array key is not an integer
361
+ * we must treat the the whole array as an object. We
362
+ * also try to catch a sparsely populated associative
363
+ * array with numeric keys here because some JS engines
364
+ * will create an array with empty indexes up to
365
+ * max_index which can cause memory issues and because
366
+ * the keys, which may be relevant, will be remapped
367
+ * otherwise.
368
+ *
369
+ * As per the ECMA and JSON specification an object may
370
+ * have any string as a property. Unfortunately due to
371
+ * a hole in the ECMA specification if the key is a
372
+ * ECMA reserved word or starts with a digit the
373
+ * parameter is only accessible using ECMAScript's
374
+ * bracket notation.
375
+ */
376
+
377
+ // treat as a JSON object
378
+ if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
379
+ $properties = array_map(array($this, 'name_value'),
380
+ array_keys($var),
381
+ array_values($var));
382
+
383
+ foreach($properties as $property) {
384
+ if(Services_JSON::isError($property)) {
385
+ return $property;
386
+ }
387
+ }
388
+
389
+ return '{' . join(',', $properties) . '}';
390
+ }
391
+
392
+ // treat it like a regular array
393
+ $elements = array_map(array($this, 'encode'), $var);
394
+
395
+ foreach($elements as $element) {
396
+ if(Services_JSON::isError($element)) {
397
+ return $element;
398
+ }
399
+ }
400
+
401
+ return '[' . join(',', $elements) . ']';
402
+
403
+ case 'object':
404
+ $vars = get_object_vars($var);
405
+
406
+ $properties = array_map(array($this, 'name_value'),
407
+ array_keys($vars),
408
+ array_values($vars));
409
+
410
+ foreach($properties as $property) {
411
+ if(Services_JSON::isError($property)) {
412
+ return $property;
413
+ }
414
+ }
415
+
416
+ return '{' . join(',', $properties) . '}';
417
+
418
+ default:
419
+ return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
420
+ ? 'null'
421
+ : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
422
+ }
423
+ }
424
+
425
+ /**
426
+ * array-walking function for use in generating JSON-formatted name-value pairs
427
+ *
428
+ * @param string $name name of key to use
429
+ * @param mixed $value reference to an array element to be encoded
430
+ *
431
+ * @return string JSON-formatted name-value pair, like '"name":value'
432
+ * @access private
433
+ */
434
+ function name_value($name, $value)
435
+ {
436
+ $encoded_value = $this->encode($value);
437
+
438
+ if(Services_JSON::isError($encoded_value)) {
439
+ return $encoded_value;
440
+ }
441
+
442
+ return $this->encode(strval($name)) . ':' . $encoded_value;
443
+ }
444
+
445
+ /**
446
+ * reduce a string by removing leading and trailing comments and whitespace
447
+ *
448
+ * @param $str string string value to strip of comments and whitespace
449
+ *
450
+ * @return string string value stripped of comments and whitespace
451
+ * @access private
452
+ */
453
+ function reduce_string($str)
454
+ {
455
+ $str = preg_replace(array(
456
+
457
+ // eliminate single line comments in '// ...' form
458
+ '#^\s*//(.+)$#m',
459
+
460
+ // eliminate multi-line comments in '/* ... */' form, at start of string
461
+ '#^\s*/\*(.+)\*/#Us',
462
+
463
+ // eliminate multi-line comments in '/* ... */' form, at end of string
464
+ '#/\*(.+)\*/\s*$#Us'
465
+
466
+ ), '', $str);
467
+
468
+ // eliminate extraneous space
469
+ return trim($str);
470
+ }
471
+
472
+ /**
473
+ * decodes a JSON string into appropriate variable
474
+ *
475
+ * @param string $str JSON-formatted string
476
+ *
477
+ * @return mixed number, boolean, string, array, or object
478
+ * corresponding to given JSON input string.
479
+ * See argument 1 to Services_JSON() above for object-output behavior.
480
+ * Note that decode() always returns strings
481
+ * in ASCII or UTF-8 format!
482
+ * @access public
483
+ */
484
+ function decode($str)
485
+ {
486
+ $str = $this->reduce_string($str);
487
+
488
+ switch (strtolower($str)) {
489
+ case 'true':
490
+ return true;
491
+
492
+ case 'false':
493
+ return false;
494
+
495
+ case 'null':
496
+ return null;
497
+
498
+ default:
499
+ $m = array();
500
+
501
+ if (is_numeric($str)) {
502
+ // Lookie-loo, it's a number
503
+
504
+ // This would work on its own, but I'm trying to be
505
+ // good about returning integers where appropriate:
506
+ // return (float)$str;
507
+
508
+ // Return float or int, as appropriate
509
+ return ((float)$str == (integer)$str)
510
+ ? (integer)$str
511
+ : (float)$str;
512
+
513
+ } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
514
+ // STRINGS RETURNED IN UTF-8 FORMAT
515
+ $delim = substr($str, 0, 1);
516
+ $chrs = substr($str, 1, -1);
517
+ $utf8 = '';
518
+ $strlen_chrs = strlen($chrs);
519
+
520
+ for ($c = 0; $c < $strlen_chrs; ++$c) {
521
+
522
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
523
+ $ord_chrs_c = ord($chrs{$c});
524
+
525
+ switch (true) {
526
+ case $substr_chrs_c_2 == '\b':
527
+ $utf8 .= chr(0x08);
528
+ ++$c;
529
+ break;
530
+ case $substr_chrs_c_2 == '\t':
531
+ $utf8 .= chr(0x09);
532
+ ++$c;
533
+ break;
534
+ case $substr_chrs_c_2 == '\n':
535
+ $utf8 .= chr(0x0A);
536
+ ++$c;
537
+ break;
538
+ case $substr_chrs_c_2 == '\f':
539
+ $utf8 .= chr(0x0C);
540
+ ++$c;
541
+ break;
542
+ case $substr_chrs_c_2 == '\r':
543
+ $utf8 .= chr(0x0D);
544
+ ++$c;
545
+ break;
546
+
547
+ case $substr_chrs_c_2 == '\\"':
548
+ case $substr_chrs_c_2 == '\\\'':
549
+ case $substr_chrs_c_2 == '\\\\':
550
+ case $substr_chrs_c_2 == '\\/':
551
+ if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
552
+ ($delim == "'" && $substr_chrs_c_2 != '\\"')) {
553
+ $utf8 .= $chrs{++$c};
554
+ }
555
+ break;
556
+
557
+ case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
558
+ // single, escaped unicode character
559
+ $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
560
+ . chr(hexdec(substr($chrs, ($c + 4), 2)));
561
+ $utf8 .= $this->utf162utf8($utf16);
562
+ $c += 5;
563
+ break;
564
+
565
+ case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
566
+ $utf8 .= $chrs{$c};
567
+ break;
568
+
569
+ case ($ord_chrs_c & 0xE0) == 0xC0:
570
+ // characters U-00000080 - U-000007FF, mask 110XXXXX
571
+ //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
572
+ $utf8 .= substr($chrs, $c, 2);
573
+ ++$c;
574
+ break;
575
+
576
+ case ($ord_chrs_c & 0xF0) == 0xE0:
577
+ // characters U-00000800 - U-0000FFFF, mask 1110XXXX
578
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
579
+ $utf8 .= substr($chrs, $c, 3);
580
+ $c += 2;
581
+ break;
582
+
583
+ case ($ord_chrs_c & 0xF8) == 0xF0:
584
+ // characters U-00010000 - U-001FFFFF, mask 11110XXX
585
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
586
+ $utf8 .= substr($chrs, $c, 4);
587
+ $c += 3;
588
+ break;
589
+
590
+ case ($ord_chrs_c & 0xFC) == 0xF8:
591
+ // characters U-00200000 - U-03FFFFFF, mask 111110XX
592
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
593
+ $utf8 .= substr($chrs, $c, 5);
594
+ $c += 4;
595
+ break;
596
+
597
+ case ($ord_chrs_c & 0xFE) == 0xFC:
598
+ // characters U-04000000 - U-7FFFFFFF, mask 1111110X
599
+ // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
600
+ $utf8 .= substr($chrs, $c, 6);
601
+ $c += 5;
602
+ break;
603
+
604
+ }
605
+
606
+ }
607
+
608
+ return $utf8;
609
+
610
+ } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
611
+ // array, or object notation
612
+
613
+ if ($str{0} == '[') {
614
+ $stk = array(SERVICES_JSON_IN_ARR);
615
+ $arr = array();
616
+ } else {
617
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
618
+ $stk = array(SERVICES_JSON_IN_OBJ);
619
+ $obj = array();
620
+ } else {
621
+ $stk = array(SERVICES_JSON_IN_OBJ);
622
+ $obj = new stdClass();
623
+ }
624
+ }
625
+
626
+ array_push($stk, array('what' => SERVICES_JSON_SLICE,
627
+ 'where' => 0,
628
+ 'delim' => false));
629
+
630
+ $chrs = substr($str, 1, -1);
631
+ $chrs = $this->reduce_string($chrs);
632
+
633
+ if ($chrs == '') {
634
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
635
+ return $arr;
636
+
637
+ } else {
638
+ return $obj;
639
+
640
+ }
641
+ }
642
+
643
+ //print("\nparsing {$chrs}\n");
644
+
645
+ $strlen_chrs = strlen($chrs);
646
+
647
+ for ($c = 0; $c <= $strlen_chrs; ++$c) {
648
+
649
+ $top = end($stk);
650
+ $substr_chrs_c_2 = substr($chrs, $c, 2);
651
+
652
+ if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
653
+ // found a comma that is not inside a string, array, etc.,
654
+ // OR we've reached the end of the character list
655
+ $slice = substr($chrs, $top['where'], ($c - $top['where']));
656
+ array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
657
+ //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
658
+
659
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
660
+ // we are in an array, so just push an element onto the stack
661
+ array_push($arr, $this->decode($slice));
662
+
663
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
664
+ // we are in an object, so figure
665
+ // out the property name and set an
666
+ // element in an associative array,
667
+ // for now
668
+ $parts = array();
669
+
670
+ if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
671
+ // "name":value pair
672
+ $key = $this->decode($parts[1]);
673
+ $val = $this->decode($parts[2]);
674
+
675
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
676
+ $obj[$key] = $val;
677
+ } else {
678
+ $obj->$key = $val;
679
+ }
680
+ } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
681
+ // name:value pair, where name is unquoted
682
+ $key = $parts[1];
683
+ $val = $this->decode($parts[2]);
684
+
685
+ if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
686
+ $obj[$key] = $val;
687
+ } else {
688
+ $obj->$key = $val;
689
+ }
690
+ }
691
+
692
+ }
693
+
694
+ } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
695
+ // found a quote, and we are not inside a string
696
+ array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
697
+ //print("Found start of string at {$c}\n");
698
+
699
+ } elseif (($chrs{$c} == $top['delim']) &&
700
+ ($top['what'] == SERVICES_JSON_IN_STR) &&
701
+ ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
702
+ // found a quote, we're in a string, and it's not escaped
703
+ // we know that it's not escaped becase there is _not_ an
704
+ // odd number of backslashes at the end of the string so far
705
+ array_pop($stk);
706
+ //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
707
+
708
+ } elseif (($chrs{$c} == '[') &&
709
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
710
+ // found a left-bracket, and we are in an array, object, or slice
711
+ array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
712
+ //print("Found start of array at {$c}\n");
713
+
714
+ } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
715
+ // found a right-bracket, and we're in an array
716
+ array_pop($stk);
717
+ //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
718
+
719
+ } elseif (($chrs{$c} == '{') &&
720
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
721
+ // found a left-brace, and we are in an array, object, or slice
722
+ array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
723
+ //print("Found start of object at {$c}\n");
724
+
725
+ } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
726
+ // found a right-brace, and we're in an object
727
+ array_pop($stk);
728
+ //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
729
+
730
+ } elseif (($substr_chrs_c_2 == '/*') &&
731
+ in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
732
+ // found a comment start, and we are in an array, object, or slice
733
+ array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
734
+ $c++;
735
+ //print("Found start of comment at {$c}\n");
736
+
737
+ } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
738
+ // found a comment end, and we're in one now
739
+ array_pop($stk);
740
+ $c++;
741
+
742
+ for ($i = $top['where']; $i <= $c; ++$i)
743
+ $chrs = substr_replace($chrs, ' ', $i, 1);
744
+
745
+ //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
746
+
747
+ }
748
+
749
+ }
750
+
751
+ if (reset($stk) == SERVICES_JSON_IN_ARR) {
752
+ return $arr;
753
+
754
+ } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
755
+ return $obj;
756
+
757
+ }
758
+
759
+ }
760
+ }
761
+ }
762
+
763
+ /**
764
+ * @todo Ultimately, this should just call PEAR::isError()
765
+ */
766
+ function isError($data, $code = null)
767
+ {
768
+ if (class_exists('pear')) {
769
+ return PEAR::isError($data, $code);
770
+ } elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
771
+ is_subclass_of($data, 'services_json_error'))) {
772
+ return true;
773
+ }
774
+
775
+ return false;
776
+ }
777
+ }
778
+
779
+ if (class_exists('PEAR_Error')) {
780
+
781
+ class Services_JSON_Error extends PEAR_Error
782
+ {
783
+ function Services_JSON_Error($message = 'unknown error', $code = null,
784
+ $mode = null, $options = null, $userinfo = null)
785
+ {
786
+ parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
787
+ }
788
+ }
789
+
790
+ } else {
791
+
792
+ /**
793
+ * @todo Ultimately, this class shall be descended from PEAR_Error
794
+ */
795
+ class Services_JSON_Error
796
+ {
797
+ function Services_JSON_Error($message = 'unknown error', $code = null,
798
+ $mode = null, $options = null, $userinfo = null)
799
+ {
800
+
801
+ }
802
+ }
803
+
804
+ }
805
+
806
+ ?>
gettext/crontrol.pot CHANGED
@@ -1,5 +1,5 @@
1
  # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
  # This file is distributed under the same license as the PACKAGE package.
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
  #
@@ -7,168 +7,292 @@
7
  msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2008-04-25 17:22+0200\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
  "MIME-Version: 1.0\n"
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
 
18
 
19
- #: wp-crontrol.php:102 wp-crontrol.php:111
20
  msgid "You are not allowed to add new cron events."
21
  msgstr ""
22
 
23
- #: wp-crontrol.php:122
24
  msgid "You are not allowed to add new cron schedules."
25
  msgstr ""
26
 
27
- #: wp-crontrol.php:147
28
  msgid "You are not allowed to delete cron schedules."
29
  msgstr ""
30
 
31
- #: wp-crontrol.php:154
32
  msgid "You are not allowed to delete cron events."
33
  msgstr ""
34
 
35
- #: wp-crontrol.php:161
36
  msgid "You are not allowed to run cron events."
37
  msgstr ""
38
 
39
- #: wp-crontrol.php:218
40
  msgid "Twice Daily"
41
  msgstr ""
42
 
43
- #: wp-crontrol.php:258
44
- #, possible-php-format
45
  msgid "Successfully deleted the cron schedule <b>%s</b>"
46
  msgstr ""
47
 
48
- #: wp-crontrol.php:269
 
 
 
 
 
 
 
 
 
 
49
  msgid "Cron Schedules"
50
  msgstr ""
51
 
52
- #: wp-crontrol.php:270
53
  msgid ""
54
  "Cron schedules are the time intervals that are available to WordPress and "
55
  "plugin developers to schedule events. You can only delete cron schedules "
56
  "that you have created with WP-Crontrol."
57
  msgstr ""
58
 
59
- #: wp-crontrol.php:275
60
  msgid "Name"
61
  msgstr ""
62
 
63
- #: wp-crontrol.php:276 wp-crontrol.php:311
64
  msgid "Interval"
65
  msgstr ""
66
 
67
- #: wp-crontrol.php:277
68
  msgid "Display Name"
69
  msgstr ""
70
 
71
- #: wp-crontrol.php:278 wp-crontrol.php:354
72
  msgid "Actions"
73
  msgstr ""
74
 
75
- #: wp-crontrol.php:301
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  msgid "Add new cron schedule"
77
  msgstr ""
78
 
79
- #: wp-crontrol.php:302
80
  msgid ""
81
  "Adding a new cron schedule will allow you to schedule events that re-occur "
82
  "at the given interval."
83
  msgstr ""
84
 
85
- #: wp-crontrol.php:307
86
  msgid "Internal name"
87
  msgstr ""
88
 
89
- #: wp-crontrol.php:315
90
  msgid "Display name"
91
  msgstr ""
92
 
93
- #: wp-crontrol.php:319
94
  msgid "Add Cron Schedule &raquo;"
95
  msgstr ""
96
 
97
- #: wp-crontrol.php:331
98
- #, possible-php-format
99
  msgid "Successfully executed the cron entry <b>%s</b>"
100
  msgstr ""
101
 
102
- #: wp-crontrol.php:332
103
- #, possible-php-format
104
  msgid "Successfully edited the cron entry <b>%s</b>"
105
  msgstr ""
106
 
107
- #: wp-crontrol.php:333
108
- #, possible-php-format
109
  msgid "Successfully created the cron entry <b>%s</b>"
110
  msgstr ""
111
 
112
- #: wp-crontrol.php:334
113
- #, possible-php-format
114
  msgid "Successfully deleted the cron entry <b>%s</b>"
115
  msgstr ""
116
 
117
- #: wp-crontrol.php:345
 
 
 
 
 
 
 
 
 
 
118
  msgid "WP-Cron Entries"
119
  msgstr ""
120
 
121
- #: wp-crontrol.php:351
122
  msgid "Hook Name"
123
  msgstr ""
124
 
125
- #: wp-crontrol.php:352
 
 
 
 
126
  msgid "Next Run"
127
  msgstr ""
128
 
129
- #: wp-crontrol.php:353
130
  msgid "Recurrence"
131
  msgstr ""
132
 
133
- #: wp-crontrol.php:386
 
 
 
 
134
  msgid "Edit cron entry"
135
  msgstr ""
136
 
137
- #: wp-crontrol.php:386
138
  msgid "Add new"
139
  msgstr ""
140
 
141
- #: wp-crontrol.php:392 wp-crontrol.php:422
142
  msgid "Hook name"
143
  msgstr ""
144
 
145
- #: wp-crontrol.php:395 wp-crontrol.php:425
 
 
 
 
146
  msgid "Next run"
147
  msgstr ""
148
 
149
- #: wp-crontrol.php:398 wp-crontrol.php:428
150
  msgid "Entry schedule"
151
  msgstr ""
152
 
153
- #: wp-crontrol.php:411
154
  msgid "Modify Cron Entry &raquo;"
155
  msgstr ""
156
 
157
- #: wp-crontrol.php:416
 
 
 
 
 
158
  msgid "Add new cron entry"
159
  msgstr ""
160
 
161
- #: wp-crontrol.php:417
162
  msgid ""
163
  "Cron entries trigger actions in your code. After adding a new cron entry "
164
  "here, you will need to add a corresponding action hook somewhere in code, "
165
  "perhaps the <code>functions.php</code> file in your theme."
166
  msgstr ""
167
 
168
- #: wp-crontrol.php:440
169
  msgid "Add Cron Entry &raquo;"
170
  msgstr ""
171
 
172
- #: wp-crontrol.php:471
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
  msgid "now"
174
  msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR Edward Dale
3
  # This file is distributed under the same license as the PACKAGE package.
4
  # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
  #
7
  msgid ""
8
  msgstr ""
9
  "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/wp-crontrol\n"
11
+ "POT-Creation-Date: 2008-06-02 07:15+0000\n"
12
  "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
  "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
  "Language-Team: LANGUAGE <LL@li.org>\n"
15
  "MIME-Version: 1.0\n"
16
  "Content-Type: text/plain; charset=CHARSET\n"
17
  "Content-Transfer-Encoding: 8bit\n"
18
+ "Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\n"
19
 
20
+ #: wp-crontrol.php:88 wp-crontrol.php:96
21
  msgid "You are not allowed to add new cron events."
22
  msgstr ""
23
 
24
+ #: wp-crontrol.php:106
25
  msgid "You are not allowed to add new cron schedules."
26
  msgstr ""
27
 
28
+ #: wp-crontrol.php:131
29
  msgid "You are not allowed to delete cron schedules."
30
  msgstr ""
31
 
32
+ #: wp-crontrol.php:138
33
  msgid "You are not allowed to delete cron events."
34
  msgstr ""
35
 
36
+ #: wp-crontrol.php:150
37
  msgid "You are not allowed to run cron events."
38
  msgstr ""
39
 
40
+ #: wp-crontrol.php:256
41
  msgid "Twice Daily"
42
  msgstr ""
43
 
44
+ #: wp-crontrol.php:301
45
+ #, php-format
46
  msgid "Successfully deleted the cron schedule <b>%s</b>"
47
  msgstr ""
48
 
49
+ #: wp-crontrol.php:302
50
+ #, php-format
51
+ msgid "Successfully added the cron schedule <b>%s</b>"
52
+ msgstr ""
53
+
54
+ #: wp-crontrol.php:303
55
+ #, php-format
56
+ msgid "Cron schedule not added because there was a problem parsing <b>%s</b>"
57
+ msgstr ""
58
+
59
+ #: wp-crontrol.php:312
60
  msgid "Cron Schedules"
61
  msgstr ""
62
 
63
+ #: wp-crontrol.php:313
64
  msgid ""
65
  "Cron schedules are the time intervals that are available to WordPress and "
66
  "plugin developers to schedule events. You can only delete cron schedules "
67
  "that you have created with WP-Crontrol."
68
  msgstr ""
69
 
70
+ #: wp-crontrol.php:318
71
  msgid "Name"
72
  msgstr ""
73
 
74
+ #: wp-crontrol.php:319 wp-crontrol.php:361
75
  msgid "Interval"
76
  msgstr ""
77
 
78
+ #: wp-crontrol.php:320
79
  msgid "Display Name"
80
  msgstr ""
81
 
82
+ #: wp-crontrol.php:321 wp-crontrol.php:419
83
  msgid "Actions"
84
  msgstr ""
85
 
86
+ #: wp-crontrol.php:328
87
+ msgid "You currently have no cron schedules. Add one below!"
88
+ msgstr ""
89
+
90
+ #: wp-crontrol.php:338
91
+ #, php-format
92
+ msgid ""
93
+ "You are about to delete the schedule '%s'.\n"
94
+ "'OK' to delete, 'Cancel' to stop."
95
+ msgstr ""
96
+
97
+ #: wp-crontrol.php:338
98
+ msgid "Delete"
99
+ msgstr ""
100
+
101
+ #: wp-crontrol.php:351
102
  msgid "Add new cron schedule"
103
  msgstr ""
104
 
105
+ #: wp-crontrol.php:352
106
  msgid ""
107
  "Adding a new cron schedule will allow you to schedule events that re-occur "
108
  "at the given interval."
109
  msgstr ""
110
 
111
+ #: wp-crontrol.php:357
112
  msgid "Internal name"
113
  msgstr ""
114
 
115
+ #: wp-crontrol.php:365
116
  msgid "Display name"
117
  msgstr ""
118
 
119
+ #: wp-crontrol.php:369
120
  msgid "Add Cron Schedule &raquo;"
121
  msgstr ""
122
 
123
+ #: wp-crontrol.php:393
124
+ #, php-format
125
  msgid "Successfully executed the cron entry <b>%s</b>"
126
  msgstr ""
127
 
128
+ #: wp-crontrol.php:394
129
+ #, php-format
130
  msgid "Successfully edited the cron entry <b>%s</b>"
131
  msgstr ""
132
 
133
+ #: wp-crontrol.php:395
134
+ #, php-format
135
  msgid "Successfully created the cron entry <b>%s</b>"
136
  msgstr ""
137
 
138
+ #: wp-crontrol.php:396
139
+ #, php-format
140
  msgid "Successfully deleted the cron entry <b>%s</b>"
141
  msgstr ""
142
 
143
+ #: wp-crontrol.php:397
144
+ #, php-format
145
+ msgid "Failed to the delete the cron entry <b>%s</b>"
146
+ msgstr ""
147
+
148
+ #: wp-crontrol.php:398
149
+ #, php-format
150
+ msgid "Failed to the execute the cron entry <b>%s</b>"
151
+ msgstr ""
152
+
153
+ #: wp-crontrol.php:410
154
  msgid "WP-Cron Entries"
155
  msgstr ""
156
 
157
+ #: wp-crontrol.php:415
158
  msgid "Hook Name"
159
  msgstr ""
160
 
161
+ #: wp-crontrol.php:416 wp-crontrol.php:472 wp-crontrol.php:502
162
+ msgid "Arguments"
163
+ msgstr ""
164
+
165
+ #: wp-crontrol.php:417
166
  msgid "Next Run"
167
  msgstr ""
168
 
169
+ #: wp-crontrol.php:418
170
  msgid "Recurrence"
171
  msgstr ""
172
 
173
+ #: wp-crontrol.php:426
174
+ msgid "You currently have no cron entries. Add one below!"
175
+ msgstr ""
176
+
177
+ #: wp-crontrol.php:461
178
  msgid "Edit cron entry"
179
  msgstr ""
180
 
181
+ #: wp-crontrol.php:461
182
  msgid "Add new"
183
  msgstr ""
184
 
185
+ #: wp-crontrol.php:469 wp-crontrol.php:499
186
  msgid "Hook name"
187
  msgstr ""
188
 
189
+ #: wp-crontrol.php:472 wp-crontrol.php:502
190
+ msgid "e.g., [], [25], [\"asdf\"], or [\"i\",\"want\",25,\"cakes\"]"
191
+ msgstr ""
192
+
193
+ #: wp-crontrol.php:475 wp-crontrol.php:505
194
  msgid "Next run"
195
  msgstr ""
196
 
197
+ #: wp-crontrol.php:478 wp-crontrol.php:508
198
  msgid "Entry schedule"
199
  msgstr ""
200
 
201
+ #: wp-crontrol.php:484
202
  msgid "Modify Cron Entry &raquo;"
203
  msgstr ""
204
 
205
+ #: wp-crontrol.php:490
206
+ #, php-format
207
+ msgid "Could not load cron entry <b>%s</b>"
208
+ msgstr ""
209
+
210
+ #: wp-crontrol.php:493
211
  msgid "Add new cron entry"
212
  msgstr ""
213
 
214
+ #: wp-crontrol.php:494
215
  msgid ""
216
  "Cron entries trigger actions in your code. After adding a new cron entry "
217
  "here, you will need to add a corresponding action hook somewhere in code, "
218
  "perhaps the <code>functions.php</code> file in your theme."
219
  msgstr ""
220
 
221
+ #: wp-crontrol.php:514
222
  msgid "Add Cron Entry &raquo;"
223
  msgstr ""
224
 
225
+ #: wp-crontrol.php:535
226
+ #, php-format
227
+ msgid "%s year"
228
+ msgid_plural "%s years"
229
+ msgstr[0] ""
230
+ msgstr[1] ""
231
+
232
+ #: wp-crontrol.php:536
233
+ #, php-format
234
+ msgid "%s month"
235
+ msgid_plural "%s months"
236
+ msgstr[0] ""
237
+ msgstr[1] ""
238
+
239
+ #: wp-crontrol.php:537
240
+ #, php-format
241
+ msgid "%s week"
242
+ msgid_plural "%s weeks"
243
+ msgstr[0] ""
244
+ msgstr[1] ""
245
+
246
+ #: wp-crontrol.php:538
247
+ #, php-format
248
+ msgid "%s day"
249
+ msgid_plural "%s days"
250
+ msgstr[0] ""
251
+ msgstr[1] ""
252
+
253
+ #: wp-crontrol.php:539
254
+ #, php-format
255
+ msgid "%s hour"
256
+ msgid_plural "%s hours"
257
+ msgstr[0] ""
258
+ msgstr[1] ""
259
+
260
+ #: wp-crontrol.php:540
261
+ #, php-format
262
+ msgid "%s minute"
263
+ msgid_plural "%s minutes"
264
+ msgstr[0] ""
265
+ msgstr[1] ""
266
+
267
+ #: wp-crontrol.php:541
268
+ #, php-format
269
+ msgid "%s second"
270
+ msgid_plural "%s seconds"
271
+ msgstr[0] ""
272
+ msgstr[1] ""
273
+
274
+ #: wp-crontrol.php:546
275
  msgid "now"
276
  msgstr ""
277
+
278
+ #. Plugin Name of an extension
279
+ msgid "WP-Crontrol"
280
+ msgstr ""
281
+
282
+ #. Plugin URI of an extension
283
+ msgid "http://www.scompt.com/projects/wp-crontrol"
284
+ msgstr ""
285
+
286
+ #. Description of an extension
287
+ msgid ""
288
+ "WP-Crontrol lets you take control over what's happening in the WP-Cron "
289
+ "system."
290
+ msgstr ""
291
+
292
+ #. Author of an extension
293
+ msgid "Edward Dale"
294
+ msgstr ""
295
+
296
+ #. Author URI of an extension
297
+ msgid "http://www.scompt.com"
298
+ msgstr ""
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: scompt
3
  Donate link: http://scompt.com/projects/wp-crontrol
4
  Tags: admin, cron, plugin, control
5
  Requires at least: 2.1
6
- Tested up to: 2.5
7
  Stable tag: 0.3
8
 
9
  WP-Crontrol lets you take control over what's happening in the WP-Cron system.
@@ -25,7 +25,11 @@ WP-Crontrol lets you take control over what's happening in the WP-Cron system.
25
 
26
  Cron schedules are used by WordPress and WordPress plugins to allow you to schedule commands to be executed at regular intervals. Intervals must be provided by the WordPress core or a plugin in order to be used. An example of a plugin that uses these schedules is [WordPress Database Backup](http://www.ilfilosofo.com/blog/wp-db-backup/). Out of the box, only daily and hourly backups are supported. In order to do a weekly backup, a weekly cron schedule must be entered into WP-Crontrol first and then the backup plugin can take advantage of it as an interval.
27
 
28
- = How do I create a new cron entry? =
 
 
 
 
29
 
30
  There are two steps to getting a functioning cron entry that executes regularly. The first step is telling WordPress about the hook. This is the part that WP-Crontrol was created to provide. The second step is calling your function when your hook is executed. You've got to do that on your own, but I'll explain how below.
31
 
@@ -47,7 +51,7 @@ The next step is to write your function. Here's a simple example:
47
 
48
  = Do I really need the entire `wp-crontrol` directory? =
49
 
50
- Nope! The only file that you really need is `wp-crontrol.php`. Toss this file in your `wp-content/plugins` directory and you're good to go.
51
 
52
  = How do I ask a frequently asked question? =
53
 
@@ -58,13 +62,6 @@ Email [me](mailto:scompt@scompt.com).
58
  1. New cron entries can be added, modified, and deleted. In addition, they can be executed on-demand.
59
  1. New cron schedules can be added to WordPress, giving plugin developers more options when scheduling commands.
60
 
61
- == Future Plans ==
62
-
63
- = Coming up in Version 0.4! =
64
-
65
- * Ability to add PHP code to be executed for the hook name
66
- * German localization
67
-
68
  == Version History ==
69
 
70
  = Version 0.1 =
@@ -84,4 +81,10 @@ Email [me](mailto:scompt@scompt.com).
84
  * Editing/deleting/execution of cron entries
85
  * More text, status messages, etc.
86
  * Allow a user to enter a schedule entry in a human manner
87
- * Looks better on WordPress 2.5
 
 
 
 
 
 
3
  Donate link: http://scompt.com/projects/wp-crontrol
4
  Tags: admin, cron, plugin, control
5
  Requires at least: 2.1
6
+ Tested up to: 2.5.1
7
  Stable tag: 0.3
8
 
9
  WP-Crontrol lets you take control over what's happening in the WP-Cron system.
25
 
26
  Cron schedules are used by WordPress and WordPress plugins to allow you to schedule commands to be executed at regular intervals. Intervals must be provided by the WordPress core or a plugin in order to be used. An example of a plugin that uses these schedules is [WordPress Database Backup](http://www.ilfilosofo.com/blog/wp-db-backup/). Out of the box, only daily and hourly backups are supported. In order to do a weekly backup, a weekly cron schedule must be entered into WP-Crontrol first and then the backup plugin can take advantage of it as an interval.
27
 
28
+ = How do I create a new PHP cron entry? =
29
+
30
+ In the Manage->Crontrol admin panel, click on the "add new PHP entry" link underneath the cron entry table. In the form that appears, enter the schedule and next run time in the boxes. Next run is the next time that the hook will execute. This can be entered in using [GNU Date Input Formats](http://www.gnu.org/software/tar/manual/html_node/tar_113.html), but often *now* is good enough. The entry schedule is how often your hook will be executed. If you don't see a good interval, then add one in the Options->Crontrol admin panel. In the "Hook code" area, enter the PHP code that should be run when your cron entry is executed. You don't need to provide the PHP opening tag (`<?php`).
31
+
32
+ = How do I create a new regular cron entry? =
33
 
34
  There are two steps to getting a functioning cron entry that executes regularly. The first step is telling WordPress about the hook. This is the part that WP-Crontrol was created to provide. The second step is calling your function when your hook is executed. You've got to do that on your own, but I'll explain how below.
35
 
51
 
52
  = Do I really need the entire `wp-crontrol` directory? =
53
 
54
+ Maybe... The most important file is `wp-crontrol.php`. If your server is running PHP4, you'll need `JSON.php` also. If you're on PHP5, then you can get rid of the whole directory and just use `wp-crontrol.php`.
55
 
56
  = How do I ask a frequently asked question? =
57
 
62
  1. New cron entries can be added, modified, and deleted. In addition, they can be executed on-demand.
63
  1. New cron schedules can be added to WordPress, giving plugin developers more options when scheduling commands.
64
 
 
 
 
 
 
 
 
65
  == Version History ==
66
 
67
  = Version 0.1 =
81
  * Editing/deleting/execution of cron entries
82
  * More text, status messages, etc.
83
  * Allow a user to enter a schedule entry in a human manner
84
+ * Looks better on WordPress 2.5
85
+
86
+ = Version 1.0 =
87
+
88
+ * Input of PHP code for cron entries
89
+ * Non-repeating cron entries
90
+ * Handles cron entries with arguments
trunk/COPYING DELETED
@@ -1,280 +0,0 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
- 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 Library 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/gettext/crontrol-de_DE.mo DELETED
Binary file
trunk/gettext/crontrol-de_DE.po DELETED
@@ -1,170 +0,0 @@
1
- # German translations for PACKAGE package
2
- # German messages for PACKAGE.
3
- # Copyright (C) 2008 THE PACKAGE'S COPYRIGHT HOLDER
4
- # This file is distributed under the same license as the PACKAGE package.
5
- # Edward Dale <>, 2008.
6
- #
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2008-04-25 17:22+0200\n"
12
- "PO-Revision-Date: 2008-04-25 17:27+0200\n"
13
- "Last-Translator: Edward Dale <>\n"
14
- "Language-Team: German\n"
15
- "MIME-Version: 1.0\n"
16
- "Content-Type: text/plain; charset=UTF-8\n"
17
- "Content-Transfer-Encoding: 8bit\n"
18
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
-
20
- #: wp-crontrol.php:102 wp-crontrol.php:111
21
- msgid "You are not allowed to add new cron events."
22
- msgstr ""
23
-
24
- #: wp-crontrol.php:122
25
- msgid "You are not allowed to add new cron schedules."
26
- msgstr ""
27
-
28
- #: wp-crontrol.php:147
29
- msgid "You are not allowed to delete cron schedules."
30
- msgstr ""
31
-
32
- #: wp-crontrol.php:154
33
- msgid "You are not allowed to delete cron events."
34
- msgstr ""
35
-
36
- #: wp-crontrol.php:161
37
- msgid "You are not allowed to run cron events."
38
- msgstr ""
39
-
40
- #: wp-crontrol.php:218
41
- msgid "Twice Daily"
42
- msgstr ""
43
-
44
- #: wp-crontrol.php:258
45
- msgid "Successfully deleted the cron schedule <b>%s</b>"
46
- msgstr "Cron Zeitplan <b>%s</b> erfolgreich gel&ouml;scht"
47
-
48
- #: wp-crontrol.php:269
49
- msgid "Cron Schedules"
50
- msgstr "Cron Zeitpl&auml;ne"
51
-
52
- #: wp-crontrol.php:270
53
- msgid ""
54
- "Cron schedules are the time intervals that are available to WordPress and "
55
- "plugin developers to schedule events. You can only delete cron schedules "
56
- "that you have created with WP-Crontrol."
57
- msgstr ""
58
-
59
- #: wp-crontrol.php:275
60
- msgid "Name"
61
- msgstr "Name"
62
-
63
- #: wp-crontrol.php:276 wp-crontrol.php:311
64
- msgid "Interval"
65
- msgstr "Intervall"
66
-
67
- #: wp-crontrol.php:277
68
- msgid "Display Name"
69
- msgstr ""
70
-
71
- #: wp-crontrol.php:278 wp-crontrol.php:354
72
- msgid "Actions"
73
- msgstr ""
74
-
75
- #: wp-crontrol.php:301
76
- msgid "Add new cron schedule"
77
- msgstr ""
78
-
79
- #: wp-crontrol.php:302
80
- msgid ""
81
- "Adding a new cron schedule will allow you to schedule events that re-occur "
82
- "at the given interval."
83
- msgstr ""
84
-
85
- #: wp-crontrol.php:307
86
- msgid "Internal name"
87
- msgstr ""
88
-
89
- #: wp-crontrol.php:315
90
- msgid "Display name"
91
- msgstr ""
92
-
93
- #: wp-crontrol.php:319
94
- msgid "Add Cron Schedule &raquo;"
95
- msgstr ""
96
-
97
- #: wp-crontrol.php:331
98
- msgid "Successfully executed the cron entry <b>%s</b>"
99
- msgstr "Cron Eintrag <b>%s</b> erfolgreich ausgef&uuml;hrt"
100
-
101
- #: wp-crontrol.php:332
102
- msgid "Successfully edited the cron entry <b>%s</b>"
103
- msgstr "Cron Eintrag <b>%s</b> erfolgreich bearbeitet"
104
-
105
- #: wp-crontrol.php:333
106
- msgid "Successfully created the cron entry <b>%s</b>"
107
- msgstr "Cron Eintrag <b>%s</b> erfolgreich geschaffen"
108
-
109
- #: wp-crontrol.php:334
110
- msgid "Successfully deleted the cron entry <b>%s</b>"
111
- msgstr "Cron Eintrag <b>%s</b> erfolgreich gel&ouml;scht"
112
-
113
- #: wp-crontrol.php:345
114
- msgid "WP-Cron Entries"
115
- msgstr "WP-Cron Eintr&auml;ge"
116
-
117
- #: wp-crontrol.php:351
118
- msgid "Hook Name"
119
- msgstr ""
120
-
121
- #: wp-crontrol.php:352
122
- msgid "Next Run"
123
- msgstr ""
124
-
125
- #: wp-crontrol.php:353
126
- msgid "Recurrence"
127
- msgstr ""
128
-
129
- #: wp-crontrol.php:386
130
- msgid "Edit cron entry"
131
- msgstr ""
132
-
133
- #: wp-crontrol.php:386
134
- msgid "Add new"
135
- msgstr ""
136
-
137
- #: wp-crontrol.php:392 wp-crontrol.php:422
138
- msgid "Hook name"
139
- msgstr ""
140
-
141
- #: wp-crontrol.php:395 wp-crontrol.php:425
142
- msgid "Next run"
143
- msgstr ""
144
-
145
- #: wp-crontrol.php:398 wp-crontrol.php:428
146
- msgid "Entry schedule"
147
- msgstr ""
148
-
149
- #: wp-crontrol.php:411
150
- msgid "Modify Cron Entry &raquo;"
151
- msgstr ""
152
-
153
- #: wp-crontrol.php:416
154
- msgid "Add new cron entry"
155
- msgstr ""
156
-
157
- #: wp-crontrol.php:417
158
- msgid ""
159
- "Cron entries trigger actions in your code. After adding a new cron entry "
160
- "here, you will need to add a corresponding action hook somewhere in code, "
161
- "perhaps the <code>functions.php</code> file in your theme."
162
- msgstr ""
163
-
164
- #: wp-crontrol.php:440
165
- msgid "Add Cron Entry &raquo;"
166
- msgstr ""
167
-
168
- #: wp-crontrol.php:471
169
- msgid "now"
170
- msgstr "jetzt"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/gettext/crontrol.pot DELETED
@@ -1,174 +0,0 @@
1
- # SOME DESCRIPTIVE TITLE.
2
- # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
- # This file is distributed under the same license as the PACKAGE package.
4
- # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
- #
6
- #, fuzzy
7
- msgid ""
8
- msgstr ""
9
- "Project-Id-Version: PACKAGE VERSION\n"
10
- "Report-Msgid-Bugs-To: \n"
11
- "POT-Creation-Date: 2008-04-25 17:22+0200\n"
12
- "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
- "Language-Team: LANGUAGE <LL@li.org>\n"
15
- "MIME-Version: 1.0\n"
16
- "Content-Type: text/plain; charset=CHARSET\n"
17
- "Content-Transfer-Encoding: 8bit\n"
18
-
19
- #: wp-crontrol.php:102 wp-crontrol.php:111
20
- msgid "You are not allowed to add new cron events."
21
- msgstr ""
22
-
23
- #: wp-crontrol.php:122
24
- msgid "You are not allowed to add new cron schedules."
25
- msgstr ""
26
-
27
- #: wp-crontrol.php:147
28
- msgid "You are not allowed to delete cron schedules."
29
- msgstr ""
30
-
31
- #: wp-crontrol.php:154
32
- msgid "You are not allowed to delete cron events."
33
- msgstr ""
34
-
35
- #: wp-crontrol.php:161
36
- msgid "You are not allowed to run cron events."
37
- msgstr ""
38
-
39
- #: wp-crontrol.php:218
40
- msgid "Twice Daily"
41
- msgstr ""
42
-
43
- #: wp-crontrol.php:258
44
- #, possible-php-format
45
- msgid "Successfully deleted the cron schedule <b>%s</b>"
46
- msgstr ""
47
-
48
- #: wp-crontrol.php:269
49
- msgid "Cron Schedules"
50
- msgstr ""
51
-
52
- #: wp-crontrol.php:270
53
- msgid ""
54
- "Cron schedules are the time intervals that are available to WordPress and "
55
- "plugin developers to schedule events. You can only delete cron schedules "
56
- "that you have created with WP-Crontrol."
57
- msgstr ""
58
-
59
- #: wp-crontrol.php:275
60
- msgid "Name"
61
- msgstr ""
62
-
63
- #: wp-crontrol.php:276 wp-crontrol.php:311
64
- msgid "Interval"
65
- msgstr ""
66
-
67
- #: wp-crontrol.php:277
68
- msgid "Display Name"
69
- msgstr ""
70
-
71
- #: wp-crontrol.php:278 wp-crontrol.php:354
72
- msgid "Actions"
73
- msgstr ""
74
-
75
- #: wp-crontrol.php:301
76
- msgid "Add new cron schedule"
77
- msgstr ""
78
-
79
- #: wp-crontrol.php:302
80
- msgid ""
81
- "Adding a new cron schedule will allow you to schedule events that re-occur "
82
- "at the given interval."
83
- msgstr ""
84
-
85
- #: wp-crontrol.php:307
86
- msgid "Internal name"
87
- msgstr ""
88
-
89
- #: wp-crontrol.php:315
90
- msgid "Display name"
91
- msgstr ""
92
-
93
- #: wp-crontrol.php:319
94
- msgid "Add Cron Schedule &raquo;"
95
- msgstr ""
96
-
97
- #: wp-crontrol.php:331
98
- #, possible-php-format
99
- msgid "Successfully executed the cron entry <b>%s</b>"
100
- msgstr ""
101
-
102
- #: wp-crontrol.php:332
103
- #, possible-php-format
104
- msgid "Successfully edited the cron entry <b>%s</b>"
105
- msgstr ""
106
-
107
- #: wp-crontrol.php:333
108
- #, possible-php-format
109
- msgid "Successfully created the cron entry <b>%s</b>"
110
- msgstr ""
111
-
112
- #: wp-crontrol.php:334
113
- #, possible-php-format
114
- msgid "Successfully deleted the cron entry <b>%s</b>"
115
- msgstr ""
116
-
117
- #: wp-crontrol.php:345
118
- msgid "WP-Cron Entries"
119
- msgstr ""
120
-
121
- #: wp-crontrol.php:351
122
- msgid "Hook Name"
123
- msgstr ""
124
-
125
- #: wp-crontrol.php:352
126
- msgid "Next Run"
127
- msgstr ""
128
-
129
- #: wp-crontrol.php:353
130
- msgid "Recurrence"
131
- msgstr ""
132
-
133
- #: wp-crontrol.php:386
134
- msgid "Edit cron entry"
135
- msgstr ""
136
-
137
- #: wp-crontrol.php:386
138
- msgid "Add new"
139
- msgstr ""
140
-
141
- #: wp-crontrol.php:392 wp-crontrol.php:422
142
- msgid "Hook name"
143
- msgstr ""
144
-
145
- #: wp-crontrol.php:395 wp-crontrol.php:425
146
- msgid "Next run"
147
- msgstr ""
148
-
149
- #: wp-crontrol.php:398 wp-crontrol.php:428
150
- msgid "Entry schedule"
151
- msgstr ""
152
-
153
- #: wp-crontrol.php:411
154
- msgid "Modify Cron Entry &raquo;"
155
- msgstr ""
156
-
157
- #: wp-crontrol.php:416
158
- msgid "Add new cron entry"
159
- msgstr ""
160
-
161
- #: wp-crontrol.php:417
162
- msgid ""
163
- "Cron entries trigger actions in your code. After adding a new cron entry "
164
- "here, you will need to add a corresponding action hook somewhere in code, "
165
- "perhaps the <code>functions.php</code> file in your theme."
166
- msgstr ""
167
-
168
- #: wp-crontrol.php:440
169
- msgid "Add Cron Entry &raquo;"
170
- msgstr ""
171
-
172
- #: wp-crontrol.php:471
173
- msgid "now"
174
- msgstr ""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/readme.txt DELETED
@@ -1,87 +0,0 @@
1
- === WP-Crontrol ===
2
- Contributors: scompt
3
- Donate link: http://scompt.com/projects/wp-crontrol
4
- Tags: admin, cron, plugin, control
5
- Requires at least: 2.1
6
- Tested up to: 2.5
7
- Stable tag: 0.3
8
-
9
- WP-Crontrol lets you take control over what's happening in the WP-Cron system.
10
-
11
- == Description ==
12
-
13
- WP-Crontrol lets you take control over what's happening in the WP-Cron system.
14
-
15
- == Installation ==
16
-
17
- 1. Upload the `wp-crontrol` directory to the `/wp-content/plugins/` directory
18
- 1. Activate the plugin through the 'Plugins' menu in WordPress
19
- 1. Goto the Options->Crontrol panel to add some new cron schedules.
20
- 1. Goto the Manage->Crontrol panel to see what cron entries are scheduled and to add some new ones.
21
-
22
- == Frequently Asked Questions ==
23
-
24
- = What's the use of adding new cron schedules? =
25
-
26
- Cron schedules are used by WordPress and WordPress plugins to allow you to schedule commands to be executed at regular intervals. Intervals must be provided by the WordPress core or a plugin in order to be used. An example of a plugin that uses these schedules is [WordPress Database Backup](http://www.ilfilosofo.com/blog/wp-db-backup/). Out of the box, only daily and hourly backups are supported. In order to do a weekly backup, a weekly cron schedule must be entered into WP-Crontrol first and then the backup plugin can take advantage of it as an interval.
27
-
28
- = How do I create a new cron entry? =
29
-
30
- There are two steps to getting a functioning cron entry that executes regularly. The first step is telling WordPress about the hook. This is the part that WP-Crontrol was created to provide. The second step is calling your function when your hook is executed. You've got to do that on your own, but I'll explain how below.
31
-
32
- *Step One: Adding the hook*
33
-
34
- In the Manage->Crontrol admin panel, enter the details of the hook. You're best off having a hookname that conforms to normal PHP variable naming conventions. This could save you trouble later. Other than that, the hookname can be whatever you want it to be. Next run is the next time that the hook will execute. This can be entered in using [GNU Date Input Formats](http://www.gnu.org/software/tar/manual/html_node/tar_113.html), but often *now* is good enough. The entry schedule is how often your hook will be executed. If you don't see a good interval, then add one in the Options->Crontrol admin panel.
35
-
36
- *Step Two: Writing the function*
37
-
38
- This part takes place in PHP code (for example, in the `functions.php` file from your theme). To execute your hook, WordPress runs an [action](http://codex.wordpress.org/Plugin_API#Actions). For this reason, we need to now tell WordPress which function to execute when this action is run. The following line accomplishes that:
39
-
40
- `add_action('my_hookname', 'my_function');`
41
-
42
- The next step is to write your function. Here's a simple example:
43
-
44
- `function my_function() {
45
- wp_mail('scompt@scompt.com', 'WP-Crontrol', 'WP-Crontrol rocks!');
46
- }`
47
-
48
- = Do I really need the entire `wp-crontrol` directory? =
49
-
50
- Nope! The only file that you really need is `wp-crontrol.php`. Toss this file in your `wp-content/plugins` directory and you're good to go.
51
-
52
- = How do I ask a frequently asked question? =
53
-
54
- Email [me](mailto:scompt@scompt.com).
55
-
56
- == Screenshots ==
57
-
58
- 1. New cron entries can be added, modified, and deleted. In addition, they can be executed on-demand.
59
- 1. New cron schedules can be added to WordPress, giving plugin developers more options when scheduling commands.
60
-
61
- == Future Plans ==
62
-
63
- = Coming up in Version 0.4! =
64
-
65
- * Ability to add PHP code to be executed for the hook name
66
- * German localization
67
-
68
- == Version History ==
69
-
70
- = Version 0.1 =
71
-
72
- * Super basic, look at what's in WP-Cron functionality.
73
-
74
- = Version 0.2 =
75
-
76
- * Fully documented the code.
77
- * Fixed the bug that the activate action wouldn't be run if the plugin wasn't in a subdirectory.
78
- * Now will play nicely in case any other plugins specify additional cron schedules.
79
- * Minor cosmetic fixes.
80
-
81
- = Version 0.3 =
82
-
83
- * Internationalization
84
- * Editing/deleting/execution of cron entries
85
- * More text, status messages, etc.
86
- * Allow a user to enter a schedule entry in a human manner
87
- * Looks better on WordPress 2.5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
trunk/screenshot-1.png DELETED
Binary file
trunk/screenshot-2.png DELETED
Binary file
trunk/wp-crontrol.php DELETED
@@ -1,552 +0,0 @@
1
- <?php
2
- /*
3
- * Plugin Name: WP-Crontrol
4
- * Plugin URI: http://www.scompt.com/projects/wp-crontrol
5
- * Description: WP-Crontrol lets you take control over what's happening in the WP-Cron system.
6
- * Author: Edward Dale
7
- * Version: 0.3
8
- * Author URI: http://www.scompt.com
9
- */
10
-
11
- /**
12
- * WP-Crontrol lets you take control over what's happening in the WP-Cron system.
13
- *
14
- * LICENSE
15
- * This file is part of WP-Crontrol.
16
- *
17
- * WP-Crontrol is free software; you can redistribute it and/or
18
- * modify it under the terms of the GNU General Public License
19
- * as published by the Free Software Foundation; either version 2
20
- * of the License, or (at your option) any later version.
21
- *
22
- * This program is distributed in the hope that it will be useful,
23
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
24
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25
- * GNU General Public License for more details.
26
- *
27
- * You should have received a copy of the GNU General Public License
28
- * along with this program; if not, write to the Free Software
29
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
- *
31
- * @package WP-Crontrol
32
- * @author Edward Dale <scompt@scompt.com>
33
- * @copyright Copyright 2007 Edward Dale
34
- * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
35
- * @version $Id: wp-crontrol.php 42732 2008-04-25 19:41:50Z scompt $
36
- * @link http://www.scompt.com/projects/wp-crontrol
37
- * @since 0.2
38
- */
39
- class Crontrol {
40
-
41
- /**
42
- * Hook onto all of the actions and filters needed by the plugin.
43
- */
44
- function Crontrol() {
45
- if( function_exists('add_action') ) {
46
- add_action('init', array(&$this, 'init'));
47
- add_action('init', array(&$this, 'handle_posts'));
48
- add_action('admin_menu', array(&$this, 'admin_menu'));
49
-
50
- // Make sure the activation works from subdirectories as well as
51
- // directly in the plugin directory.
52
- $activate_action = str_replace(ABSPATH.PLUGINDIR.'/', 'activate_', __FILE__);
53
- add_action($activate_action, array(&$this, 'activate'));
54
-
55
- add_filter('cron_schedules', array(&$this, 'cron_schedules'));
56
- add_action('wp_ajax_delete-sched', array(&$this, 'handle_ajax'));
57
- add_action('wp_ajax_delete-cron', array(&$this, 'handle_ajax'));
58
- }
59
- }
60
-
61
- /**
62
- * Run using the 'init' action.
63
- */
64
- function init() {
65
- load_plugin_textdomain('crontrol', str_replace(ABSPATH, '', dirname(__FILE__).'/gettext'));
66
- }
67
-
68
- /**
69
- * Run using the 'admin_print_scripts' action. Added in the 'admin_menu'
70
- * hook.
71
- */
72
- function scripts() {
73
- wp_enqueue_script( 'listman');
74
- }
75
-
76
- /**
77
- * Handles any ajax requests made by the plugin. Run using
78
- * the 'wp_ajax_*' actions.
79
- */
80
- function handle_ajax() {
81
- switch( $_POST['action'] ) {
82
- case 'delete-sched':
83
- if( !current_user_can('manage_options') ) die('-1');
84
- $to_delete = $_POST['id'];
85
- $this->delete_schedule($to_delete);
86
- exit('1');
87
- break;
88
- case 'delete-cron':
89
- if( !current_user_can('manage_options') ) die('-1');
90
- $to_delete = $_POST['id'];
91
- $this->delete_cron($to_delete);
92
- exit('1');
93
- break;
94
- }
95
- }
96
-
97
- /**
98
- * Handles any POSTs made by the plugin. Run using the 'init' action.
99
- */
100
- function handle_posts() {
101
- if( isset($_POST['new_cron']) ) {
102
- if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
103
- check_admin_referer("new-cron");
104
- $next_run = $_POST['nextrun'];
105
- $schedule = $_POST['schedule'];
106
- $hookname = $_POST['hookname'];
107
- $this->add_cron($next_run, $schedule, $hookname);
108
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=5&crontrol_name=$hookname");
109
-
110
- } else if( isset($_POST['edit_cron']) ) {
111
- if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
112
- $next_run = $_POST['nextrun'];
113
- $schedule = $_POST['schedule'];
114
- $hookname = $_POST['hookname'];
115
- $original_hookname = $_POST['original_hookname'];
116
- check_admin_referer("edit-cron_{$original_hookname}");
117
- $this->delete_cron($original_hookname);
118
- $this->add_cron($next_run, $schedule, $hookname);
119
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=4&crontrol_name=$hookname");
120
-
121
- } else if( isset($_POST['new_schedule']) ) {
122
- if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron schedules.', 'crontrol'));
123
- check_admin_referer("new-sched");
124
- $name = $_POST['internal_name'];
125
- $interval = $_POST['interval'];
126
- $display = $_POST['display_name'];
127
-
128
- // The user entered something that wasn't a number.
129
- // Try to convert it with strtotime
130
- if( !is_numeric($interval) ) {
131
- $now = time();
132
- $future = strtotime($interval, $now);
133
- if( $future===FALSE || $future == -1 || $now>$future) {
134
- wp_redirect("options-general.php?page=crontrol_admin_options_page&crontrol_message=7&crontrol_name=".urlencode($interval));
135
- return;
136
- }
137
- $interval = $future-$now;
138
- } else if( $interval<=0 ) {
139
- wp_redirect("options-general.php?page=crontrol_admin_options_page&crontrol_message=7&crontrol_name=".urlencode($interval));
140
- return;
141
- }
142
-
143
- $this->add_schedule($name, $interval, $display);
144
- wp_redirect("options-general.php?page=crontrol_admin_options_page&crontrol_message=3&crontrol_name=$name");
145
-
146
- } else if( isset($_GET['action']) && $_GET['action']=='delete-sched') {
147
- if( !current_user_can('manage_options') ) die(__('You are not allowed to delete cron schedules.', 'crontrol'));
148
- $id = $_GET['id'];
149
- check_admin_referer("delete-sched_$id");
150
- $this->delete_schedule($id);
151
- wp_redirect("options-general.php?page=crontrol_admin_options_page&crontrol_message=2&crontrol_name=$id");
152
-
153
- } else if( isset($_GET['action']) && $_GET['action']=='delete-cron') {
154
- if( !current_user_can('manage_options') ) die(__('You are not allowed to delete cron events.', 'crontrol'));
155
- $id = $_GET['id'];
156
- check_admin_referer("delete-cron_$id");
157
- $this->delete_cron($id);
158
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=6&crontrol_name=$id");
159
-
160
- } else if( isset($_GET['action']) && $_GET['action']=='run-cron') {
161
- if( !current_user_can('manage_options') ) die(__('You are not allowed to run cron events.', 'crontrol'));
162
- $id = $_GET['id'];
163
- check_admin_referer("run-cron_$id");
164
- $this->run_cron($id);
165
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=1&crontrol_name=$id");
166
- }
167
- }
168
-
169
- /**
170
- * Executes a cron entry immediately.
171
- *
172
- * Executes an entry by deleting it and adding it again with a
173
- * run time of 'now'.
174
- *
175
- * @param string $hookname The hookname of the cron entry to run
176
- */
177
- function run_cron($hookname) {
178
- $sched = wp_get_schedule($hookname);
179
- wp_clear_scheduled_hook($hookname);
180
- $this->add_cron('now', $sched, $hookname);
181
-
182
- }
183
-
184
- /**
185
- * Adds a new cron entry.
186
- *
187
- * @param string $next_run A human-readable (strtotime) time that the entry should be run at
188
- * @param string $schedule The recurrence of the cron entry
189
- * @param string $hookname The name of the hook to execute
190
- */
191
- function add_cron($next_run, $schedule, $hookname) {
192
- $next_run = strtotime($next_run);
193
- if( $next_run===FALSE || $next_run==-1 ) $next_run=time();
194
- if( !wp_schedule_event( $next_run, $schedule, $hookname ) ) {
195
- $error=True;
196
- }
197
- }
198
-
199
- /**
200
- * Deletes a cron entry.
201
- *
202
- * @param string $name The hookname of the entry to delete.
203
- */
204
- function delete_cron($to_delete) {
205
- wp_clear_scheduled_hook($to_delete);
206
- }
207
-
208
- /**
209
- * Adds a new custom cron schedule.
210
- *
211
- * @param string $name The internal name of the schedule
212
- * @param int $interval The interval between executions of the new schedule
213
- * @param string $display The display name of the schedule
214
- */
215
- function add_schedule($name, $interval, $display) {
216
- $old_scheds = get_option('crontrol_schedules');
217
- $old_scheds[$name] = array('interval'=>$interval, 'display'=>$display);
218
- update_option('crontrol_schedules', $old_scheds);
219
- }
220
-
221
- /**
222
- * Deletes a custom cron schedule.
223
- *
224
- * @param string $name The internal_name of the schedule to delete.
225
- */
226
- function delete_schedule($name) {
227
- $scheds = get_option('crontrol_schedules');
228
- unset($scheds[$name]);
229
- update_option('crontrol_schedules', $scheds);
230
- }
231
-
232
- /**
233
- * Sets up the plugin environment upon first activation.
234
- *
235
- * Run using the 'activate_' action.
236
- */
237
- function activate() {
238
- $extra_scheds = array('twicedaily'=>array('interval'=>43200, 'display'=>__('Twice Daily', 'crontrol')));
239
- add_option('crontrol_schedules', $extra_scheds);
240
-
241
- // if there's never been a cron entry, _get_cron_array will return FALSE
242
- if( _get_cron_array() === FALSE ) {
243
- _set_cron_array(array());
244
- }
245
- }
246
-
247
- /**
248
- * Adds options & management pages to the admin menu.
249
- *
250
- * Run using the 'admin_menu' action.
251
- */
252
- function admin_menu() {
253
- $page = add_options_page('Crontrol', 'Crontrol', 'manage_options', 'crontrol_admin_options_page', array(&$this, 'admin_options_page') );
254
- add_action("admin_print_scripts-$page", array(&$this, 'scripts') );
255
-
256
- $page = add_management_page('Crontrol', "Crontrol", 'manage_options', 'crontrol_admin_manage_page', array(&$this, 'admin_manage_page') );
257
- add_action("admin_print_scripts-$page", array(&$this, 'scripts') );
258
- }
259
-
260
- /**
261
- * Gives WordPress the plugin's set of cron schedules.
262
- *
263
- * Called by the 'cron_schedules' filter.
264
- *
265
- * @param array $scheds The current cron schedules. Usually an empty array.
266
- * @return array The existing cron schedules along with the plugin's schedules.
267
- */
268
- function cron_schedules($scheds) {
269
- $new_scheds = get_option('crontrol_schedules');
270
- return array_merge($new_scheds, $scheds);
271
- }
272
-
273
- /**
274
- * Displays the options page for the plugin.
275
- */
276
- function admin_options_page() {
277
- $schedules = wp_get_schedules();
278
- $custom_schedules = get_option('crontrol_schedules');
279
- $custom_keys = array_keys($custom_schedules);
280
- uasort($schedules, create_function('$a,$b', 'return $a["interval"]-$b["interval"];'));
281
-
282
- if( isset($_GET['crontrol_message']) ) {
283
- $messages = array( '2' => __("Successfully deleted the cron schedule <b>%s</b>", 'crontrol'),
284
- '3' => __("Successfully added the cron schedule <b>%s</b>", 'crontrol'),
285
- '7' => __("Cron schedule not added because there was a problem parsing <b>%s</b>", 'crontrol'));
286
- $hook = $_GET['crontrol_name'];
287
- $msg = sprintf($messages[$_GET['crontrol_message']], $hook);
288
-
289
- echo "<div id=\"message\" class=\"updated fade\"><p>$msg</p></div>";
290
- }
291
-
292
- ?>
293
- <div class="wrap">
294
- <h2><?php _e("Cron Schedules", "crontrol"); ?></h2>
295
- <p><?php _e('Cron schedules are the time intervals that are available to WordPress and plugin developers to schedule events. You can only delete cron schedules that you have created with WP-Crontrol.', 'crontrol'); ?></p>
296
- <div id="ajax-response"></div>
297
- <table class="widefat" id="the-list">
298
- <thead>
299
- <tr>
300
- <th><?php _e('Name', 'crontrol'); ?></th>
301
- <th><?php _e('Interval', 'crontrol'); ?></th>
302
- <th><?php _e('Display Name', 'crontrol'); ?></th>
303
- <th><?php _e('Actions', 'crontrol'); ?></th>
304
- </tr>
305
- </thead>
306
- <tbody>
307
- <?php
308
- if( empty($schedules) ) {
309
- ?>
310
- <tr colspan="4"><td><?php _e('You currently have no cron schedules. Add one below!', 'crontrol') ?></td></tr>
311
- <?php
312
- } else {
313
- $class = "";
314
- foreach( $schedules as $name=>$data ) {
315
- echo "<tr id=\"sched-$name\" class=\"$class\">";
316
- echo "<td>$name</td>";
317
- echo "<td>{$data['interval']} (".$this->interval($data['interval']).")</td>";
318
- echo "<td>{$data['display']}</td>";
319
- if( in_array($name, $custom_keys) ) {
320
- echo "<td><a href='" . wp_nonce_url( "options-general.php?page=crontrol_admin_options_page&amp;action=delete-sched&amp;id=$name", 'delete-sched_' . $name ) . "' onclick=\"return deleteSomething( 'sched', '$name', '" . js_escape(sprintf( __("You are about to delete the schedule '%s'.\n'OK' to delete, 'Cancel' to stop.", 'crontrol' ), $name)) . "' );\" class='delete'>".__( 'Delete' )."</a></td>";
321
- } else {
322
- echo "<td>&nbsp;</td>\n";
323
- }
324
- echo "</tr>";
325
- $class = empty($class)?"alternate":"";
326
- }
327
- }
328
- ?>
329
- </tbody>
330
- </table>
331
- </div>
332
- <div class="wrap narrow">
333
- <h2><?php _e('Add new cron schedule', 'crontrol'); ?></h2>
334
- <p><?php _e('Adding a new cron schedule will allow you to schedule events that re-occur at the given interval.', 'crontrol'); ?></p>
335
- <form method="post" action="options-general.php?page=crontrol_admin_options_page">
336
- <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table">
337
- <tbody>
338
- <tr>
339
- <th width="33%" valign="top" scope="row"><label for="internal_name"><?php _e('Internal name', 'crontrol'); ?>:</label></th>
340
- <td width="67%"><input type="text" size="40" value="" id="internal_name" name="internal_name"/></td>
341
- </tr>
342
- <tr>
343
- <th width="33%" valign="top" scope="row"><label for="interval"><?php _e('Interval', 'crontrol'); ?>:</label></th>
344
- <td width="67%"><input type="text" size="40" value="" id="interval" name="interval"/></td>
345
- </tr>
346
- <tr>
347
- <th width="33%" valign="top" scope="row"><label for="display_name"><?php _e('Display name', 'crontrol'); ?>:</label></th>
348
- <td width="67%"><input type="text" size="40" value="" id="display_name" name="display_name"/></td>
349
- </tr>
350
- </tbody></table>
351
- <p class="submit"><input id="schedadd-submit" type="submit" value="<?php _e('Add Cron Schedule &raquo;', 'crontrol'); ?>" name="new_schedule"/></p>
352
- <?php wp_nonce_field('new-sched') ?>
353
- </form>
354
- </div>
355
- <?php
356
- }
357
-
358
- /**
359
- * Displays the manage page for the plugin.
360
- */
361
- function admin_manage_page() {
362
- if( isset($_GET['crontrol_message']) ) {
363
- $messages = array( '1' => __('Successfully executed the cron entry <b>%s</b>', 'crontrol'),
364
- '4' => __('Successfully edited the cron entry <b>%s</b>', 'crontrol'),
365
- '5' => __('Successfully created the cron entry <b>%s</b>', 'crontrol'),
366
- '6' => __('Successfully deleted the cron entry <b>%s</b>', 'crontrol'));
367
- $hook = $_GET['crontrol_name'];
368
- $msg = sprintf($messages[$_GET['crontrol_message']], $hook);
369
-
370
- echo "<div id=\"message\" class=\"updated fade\"><p>$msg</p></div>";
371
- }
372
- $crons = _get_cron_array();
373
- $schedules = wp_get_schedules();
374
- $doing_edit = (isset( $_GET['action']) && $_GET['action']=='edit-cron') ? $_GET['id'] : false ;
375
- ?>
376
- <div class="wrap">
377
- <h2><?php _e('WP-Cron Entries', 'crontrol'); ?></h2>
378
- <p></p>
379
- <div id="ajax-response"></div>
380
- <table class="widefat" id="the-list">
381
- <thead>
382
- <tr>
383
- <th><?php _e('Hook Name', 'crontrol'); ?></th>
384
- <th><?php _e('Next Run', 'crontrol'); ?></th>
385
- <th><?php _e('Recurrence', 'crontrol'); ?></th>
386
- <th colspan="3"><?php _e('Actions', 'crontrol'); ?></th>
387
- </tr>
388
- </thead>
389
- <tbody>
390
- <?php
391
- if( empty($crons) ) {
392
- ?>
393
- <tr colspan="6"><td><?php _e('You currently have no cron entries. Add one below!', 'crontrol') ?></td></tr>
394
- <?php
395
- } else {
396
- $class = "";
397
- foreach( $crons as $time=>$cron ) {
398
- foreach( $cron as $hook=>$data) {
399
- $data = array_shift($data);
400
- if( $doing_edit && $doing_edit==$hook ) {
401
- $doing_edit = array('hookname'=>$hook,
402
- 'nextrun'=>$time,
403
- 'schedule'=>$data['schedule']);
404
- }
405
-
406
- echo "<tr id=\"cron-$hook\" class=\"$class\">";
407
- echo "<td>$hook</td>";
408
- echo "<td>".strftime("%D %T", $time)." (".$this->time_since(time(), $time).")</td>";
409
- echo "<td>{$data['interval']} (".$this->interval($data['interval']).")</td>";
410
- echo "<td><a class='view' href='edit.php?page=crontrol_admin_manage_page&amp;action=edit-cron&amp;id=$hook'>Edit</a></td>";
411
- echo "<td><a class='view' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=run-cron&amp;id=$hook", 'run-cron_' . $hook)."' onclick=\"return confirm('". js_escape(sprintf(__("You are about to execute a cron entry.\nPress 'OK' to continue or 'Cancel' to stop.", 'crontrol')))."');\">Do Now</a></td>";
412
- echo "<td><a class='delete' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=delete-cron&amp;id=$hook", 'delete-cron_' . $hook)."' onclick=\"return deleteSomething( 'cron', '$hook', '" . js_escape(sprintf( __("You are about to delete the cron entry '%s'.\n'OK' to delete, 'Cancel' to stop.", 'crontrol'), $hook)) . "' );\">Delete</a></td>";
413
- echo "</tr>";
414
- $class = empty($class)?"alternate":"";
415
- }
416
- }
417
- }
418
- ?>
419
- </tbody>
420
- </table>
421
- </div>
422
- <?php if( is_array( $doing_edit ) ): ?>
423
- <div class="wrap narrow">
424
- <h2><?php _e('Edit cron entry', 'crontrol'); ?> (<a href="edit.php?page=crontrol_admin_manage_page"><?php _e('Add new', 'crontrol'); ?></a>)</h2>
425
- <form method="post">
426
- <?php wp_nonce_field('edit-cron_'.$doing_edit['hookname']) ?>
427
- <input name="original_hookname" type="hidden" value="<?php echo $doing_edit['hookname'] ?>" />
428
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
429
- <tbody><tr>
430
- <th width="33%" valign="top" scope="row"><label for="hookname"><?php _e('Hook name', 'crontrol'); ?>:</label></th>
431
- <td width="67%"><input type="text" size="40" id="hookname" name="hookname" value="<?php echo $doing_edit['hookname'] ?>"/></td>
432
- </tr><tr>
433
- <th width="33%" valign="top" scope="row"><label for="nextrun"><?php _e('Next run', 'crontrol'); ?>:</label></th>
434
- <td width="67%"><input type="text" size="40" id="nextrun" name="nextrun" value="<?php echo strftime("%D %T", $doing_edit['nextrun']) ?>"/></td>
435
- </tr><tr>
436
- <th valign="top" scope="row"><label for="schedule"><?php _e('Entry schedule', 'crontrol'); ?>:</label></th>
437
- <td>
438
- <select class="postform" name="schedule">
439
- <?php
440
- foreach( $schedules as $sched_name=>$sched_data ) {
441
- $selected = $doing_edit['schedule']==$sched_name ? 'selected="selected"' : '';
442
- echo "<option $selected value=\"$sched_name\">{$sched_data['display']} (".$this->interval($sched_data['interval']).")</option>\n";
443
- }
444
- ?>
445
- </select>
446
- </td>
447
- </tr>
448
- </tbody></table>
449
- <p class="submit"><input type="submit" value="<?php _e('Modify Cron Entry &raquo;', 'crontrol'); ?>" name="edit_cron"/></p>
450
- </form>
451
- </div>
452
- <?php else: ?>
453
- <div class="wrap narrow">
454
- <h2><?php _e('Add new cron entry', 'crontrol'); ?></h2>
455
- <p><?php _e('Cron entries trigger actions in your code. After adding a new cron entry here, you will need to add a corresponding action hook somewhere in code, perhaps the <code>functions.php</code> file in your theme.', 'crontrol'); ?></p>
456
- <form method="post">
457
- <?php wp_nonce_field('new-cron') ?>
458
- <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table">
459
- <tbody><tr>
460
- <th width="33%" valign="top" scope="row"><label for="hookname"><?php _e('Hook name', 'crontrol'); ?>:</label></th>
461
- <td width="67%"><input type="text" size="40" value="" id="hookname" name="hookname"/></td>
462
- </tr><tr>
463
- <th width="33%" valign="top" scope="row"><label for="nextrun"><?php _e('Next run', 'crontrol'); ?>:</label></th>
464
- <td width="67%"><input type="text" size="40" value="now" id="nextrun" name="nextrun"/></td>
465
- </tr><tr>
466
- <th valign="top" scope="row"><label for="schedule"><?php _e('Entry schedule', 'crontrol'); ?>:</label></th>
467
- <td>
468
- <select class="postform" name="schedule">
469
- <?php
470
- foreach( $schedules as $sched_name=>$sched_data ) {
471
- echo "<option value=\"$sched_name\">{$sched_data['display']} (".$this->interval($sched_data['interval']).")</option>\n";
472
- }
473
- ?>
474
- </select>
475
- </td>
476
- </tr>
477
- </tbody></table>
478
- <p class="submit"><input type="submit" value="<?php _e('Add Cron Entry &raquo;', 'crontrol'); ?>" name="new_cron"/></p>
479
- </form>
480
- </div>
481
- <?php endif;
482
- }
483
-
484
- /**
485
- * Pretty-prints the difference in two times.
486
- *
487
- * @param time $older_date
488
- * @param time $newer_date
489
- * @return string The pretty time_since value
490
- * @link http://binarybonsai.com/code/timesince.txt
491
- */
492
- function time_since($older_date, $newer_date) {
493
- return $this->interval( $newer_date - $older_date );
494
- }
495
-
496
- function interval( $since ) {
497
- // array of time period chunks
498
- $chunks = array(
499
- array(60 * 60 * 24 * 365 , 'year'),
500
- array(60 * 60 * 24 * 30 , 'month'),
501
- array(60 * 60 * 24 * 7, 'week'),
502
- array(60 * 60 * 24 , 'day'),
503
- array(60 * 60 , 'hour'),
504
- array(60 , 'minute'),
505
- array( 1 , 'second'),
506
- );
507
-
508
- if( $since <= 0 ) {
509
- return __('now', 'crontrol');
510
- }
511
-
512
- // we only want to output two chunks of time here, eg:
513
- // x years, xx months
514
- // x days, xx hours
515
- // so there's only two bits of calculation below:
516
-
517
- // step one: the first chunk
518
- for ($i = 0, $j = count($chunks); $i < $j; $i++)
519
- {
520
- $seconds = $chunks[$i][0];
521
- $name = $chunks[$i][1];
522
-
523
- // finding the biggest chunk (if the chunk fits, break)
524
- if (($count = floor($since / $seconds)) != 0)
525
- {
526
- break;
527
- }
528
- }
529
-
530
- // set output var
531
- $output = ($count == 1) ? '1 '.$name : "$count {$name}s";
532
-
533
- // step two: the second chunk
534
- if ($i + 1 < $j)
535
- {
536
- $seconds2 = $chunks[$i + 1][0];
537
- $name2 = $chunks[$i + 1][1];
538
-
539
- if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
540
- {
541
- // add to output var
542
- $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
543
- }
544
- }
545
-
546
- return $output;
547
- }
548
- }
549
-
550
- // Get this show on the road
551
- new Crontrol();
552
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
wp-crontrol.php CHANGED
@@ -4,7 +4,7 @@
4
  * Plugin URI: http://www.scompt.com/projects/wp-crontrol
5
  * Description: WP-Crontrol lets you take control over what's happening in the WP-Cron system.
6
  * Author: Edward Dale
7
- * Version: 0.2
8
  * Author URI: http://www.scompt.com
9
  */
10
 
@@ -32,16 +32,19 @@
32
  * @author Edward Dale <scompt@scompt.com>
33
  * @copyright Copyright 2007 Edward Dale
34
  * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
35
- * @version $Id: wp-crontrol.php 42706 2008-04-25 16:46:42Z scompt $
36
  * @link http://www.scompt.com/projects/wp-crontrol
37
  * @since 0.2
38
  */
39
  class Crontrol {
40
-
 
41
  /**
42
  * Hook onto all of the actions and filters needed by the plugin.
43
  */
44
  function Crontrol() {
 
 
45
  if( function_exists('add_action') ) {
46
  add_action('init', array(&$this, 'init'));
47
  add_action('init', array(&$this, 'handle_posts'));
@@ -53,70 +56,67 @@ class Crontrol {
53
  add_action($activate_action, array(&$this, 'activate'));
54
 
55
  add_filter('cron_schedules', array(&$this, 'cron_schedules'));
56
- add_action('wp_ajax_delete-sched', array(&$this, 'handle_ajax'));
57
- add_action('wp_ajax_delete-cron', array(&$this, 'handle_ajax'));
58
  }
59
  }
60
-
61
  /**
62
- * Run using the 'init' action.
63
  */
64
- function init() {
65
- load_plugin_textdomain('crontrol', str_replace(ABSPATH, '', dirname(__FILE__).'/gettext'));
66
  }
67
 
68
  /**
69
- * Run using the 'admin_print_scripts' action. Added in the 'admin_menu'
70
- * hook.
71
- */
72
- function scripts() {
73
- wp_enqueue_script( 'listman');
74
- }
75
-
76
- /**
77
- * Handles any ajax requests made by the plugin. Run using
78
- * the 'wp_ajax_*' actions.
79
  */
80
- function handle_ajax() {
81
- switch( $_POST['action'] ) {
82
- case 'delete-sched':
83
- if( !current_user_can('manage_options') ) die('-1');
84
- $to_delete = $_POST['id'];
85
- $this->delete_schedule($to_delete);
86
- exit('1');
87
- break;
88
- case 'delete-cron':
89
- if( !current_user_can('manage_options') ) die('-1');
90
- $to_delete = $_POST['id'];
91
- $this->delete_cron($to_delete);
92
- exit('1');
93
- break;
94
- }
95
  }
96
 
97
  /**
98
  * Handles any POSTs made by the plugin. Run using the 'init' action.
99
  */
100
  function handle_posts() {
 
101
  if( isset($_POST['new_cron']) ) {
102
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
103
  check_admin_referer("new-cron");
104
- $next_run = $_POST['nextrun'];
105
- $schedule = $_POST['schedule'];
106
- $hookname = $_POST['hookname'];
107
- $this->add_cron($next_run, $schedule, $hookname);
108
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=5&crontrol_name=$hookname");
109
 
110
- } else if( isset($_POST['edit_cron']) ) {
111
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
112
- $next_run = $_POST['nextrun'];
113
- $schedule = $_POST['schedule'];
114
- $hookname = $_POST['hookname'];
115
- $original_hookname = $_POST['original_hookname'];
116
- check_admin_referer("edit-cron_{$original_hookname}");
117
- $this->delete_cron($original_hookname);
118
- $this->add_cron($next_run, $schedule, $hookname);
119
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=4&crontrol_name=$hookname");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
 
121
  } else if( isset($_POST['new_schedule']) ) {
122
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron schedules.', 'crontrol'));
@@ -153,32 +153,46 @@ class Crontrol {
153
  } else if( isset($_GET['action']) && $_GET['action']=='delete-cron') {
154
  if( !current_user_can('manage_options') ) die(__('You are not allowed to delete cron events.', 'crontrol'));
155
  $id = $_GET['id'];
156
- check_admin_referer("delete-cron_$id");
157
- $this->delete_cron($id);
158
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=6&crontrol_name=$id");
 
 
 
 
 
159
 
160
  } else if( isset($_GET['action']) && $_GET['action']=='run-cron') {
161
  if( !current_user_can('manage_options') ) die(__('You are not allowed to run cron events.', 'crontrol'));
162
  $id = $_GET['id'];
163
- check_admin_referer("run-cron_$id");
164
- $this->run_cron($id);
165
- wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=1&crontrol_name=$id");
 
 
 
 
166
  }
167
  }
168
 
169
  /**
170
  * Executes a cron entry immediately.
171
  *
172
- * Executes an entry by deleting it and adding it again with a
173
- * run time of 'now'.
174
  *
175
  * @param string $hookname The hookname of the cron entry to run
176
  */
177
- function run_cron($hookname) {
178
- $sched = wp_get_schedule($hookname);
179
- wp_clear_scheduled_hook($hookname);
180
- $this->add_cron('now', $sched, $hookname);
181
-
 
 
 
 
 
 
182
  }
183
 
184
  /**
@@ -187,12 +201,16 @@ class Crontrol {
187
  * @param string $next_run A human-readable (strtotime) time that the entry should be run at
188
  * @param string $schedule The recurrence of the cron entry
189
  * @param string $hookname The name of the hook to execute
 
190
  */
191
- function add_cron($next_run, $schedule, $hookname) {
192
  $next_run = strtotime($next_run);
193
  if( $next_run===FALSE || $next_run==-1 ) $next_run=time();
194
- if( !wp_schedule_event( $next_run, $schedule, $hookname ) ) {
195
- $error=True;
 
 
 
196
  }
197
  }
198
 
@@ -201,8 +219,14 @@ class Crontrol {
201
  *
202
  * @param string $name The hookname of the entry to delete.
203
  */
204
- function delete_cron($to_delete) {
205
- wp_clear_scheduled_hook($to_delete);
 
 
 
 
 
 
206
  }
207
 
208
  /**
@@ -251,10 +275,7 @@ class Crontrol {
251
  */
252
  function admin_menu() {
253
  $page = add_options_page('Crontrol', 'Crontrol', 'manage_options', 'crontrol_admin_options_page', array(&$this, 'admin_options_page') );
254
- add_action("admin_print_scripts-$page", array(&$this, 'scripts') );
255
-
256
  $page = add_management_page('Crontrol', "Crontrol", 'manage_options', 'crontrol_admin_manage_page', array(&$this, 'admin_manage_page') );
257
- add_action("admin_print_scripts-$page", array(&$this, 'scripts') );
258
  }
259
 
260
  /**
@@ -274,10 +295,9 @@ class Crontrol {
274
  * Displays the options page for the plugin.
275
  */
276
  function admin_options_page() {
277
- $schedules = wp_get_schedules();
278
  $custom_schedules = get_option('crontrol_schedules');
279
  $custom_keys = array_keys($custom_schedules);
280
- uasort($schedules, create_function('$a,$b', 'return $a["interval"]-$b["interval"];'));
281
 
282
  if( isset($_GET['crontrol_message']) ) {
283
  $messages = array( '2' => __("Successfully deleted the cron schedule <b>%s</b>", 'crontrol'),
@@ -294,7 +314,7 @@ class Crontrol {
294
  <h2><?php _e("Cron Schedules", "crontrol"); ?></h2>
295
  <p><?php _e('Cron schedules are the time intervals that are available to WordPress and plugin developers to schedule events. You can only delete cron schedules that you have created with WP-Crontrol.', 'crontrol'); ?></p>
296
  <div id="ajax-response"></div>
297
- <table class="widefat" id="the-list">
298
  <thead>
299
  <tr>
300
  <th><?php _e('Name', 'crontrol'); ?></th>
@@ -317,7 +337,7 @@ class Crontrol {
317
  echo "<td>{$data['interval']} (".$this->interval($data['interval']).")</td>";
318
  echo "<td>{$data['display']}</td>";
319
  if( in_array($name, $custom_keys) ) {
320
- echo "<td><a href='" . wp_nonce_url( "options-general.php?page=crontrol_admin_options_page&amp;action=delete-sched&amp;id=$name", 'delete-sched_' . $name ) . "' onclick=\"return deleteSomething( 'sched', '$name', '" . js_escape(sprintf( __("You are about to delete the schedule '%s'.\n'OK' to delete, 'Cancel' to stop.", 'crontrol' ), $name)) . "' );\" class='delete'>".__( 'Delete' )."</a></td>";
321
  } else {
322
  echo "<td>&nbsp;</td>\n";
323
  }
@@ -355,6 +375,100 @@ class Crontrol {
355
  <?php
356
  }
357
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
358
  /**
359
  * Displays the manage page for the plugin.
360
  */
@@ -363,24 +477,26 @@ class Crontrol {
363
  $messages = array( '1' => __('Successfully executed the cron entry <b>%s</b>', 'crontrol'),
364
  '4' => __('Successfully edited the cron entry <b>%s</b>', 'crontrol'),
365
  '5' => __('Successfully created the cron entry <b>%s</b>', 'crontrol'),
366
- '6' => __('Successfully deleted the cron entry <b>%s</b>', 'crontrol'));
 
 
367
  $hook = $_GET['crontrol_name'];
368
  $msg = sprintf($messages[$_GET['crontrol_message']], $hook);
369
 
370
  echo "<div id=\"message\" class=\"updated fade\"><p>$msg</p></div>";
371
  }
372
  $crons = _get_cron_array();
373
- $schedules = wp_get_schedules();
374
  $doing_edit = (isset( $_GET['action']) && $_GET['action']=='edit-cron') ? $_GET['id'] : false ;
375
  ?>
376
  <div class="wrap">
377
  <h2><?php _e('WP-Cron Entries', 'crontrol'); ?></h2>
378
  <p></p>
379
- <div id="ajax-response"></div>
380
- <table class="widefat" id="the-list">
381
  <thead>
382
  <tr>
383
  <th><?php _e('Hook Name', 'crontrol'); ?></th>
 
384
  <th><?php _e('Next Run', 'crontrol'); ?></th>
385
  <th><?php _e('Recurrence', 'crontrol'); ?></th>
386
  <th colspan="3"><?php _e('Actions', 'crontrol'); ?></th>
@@ -395,23 +511,27 @@ class Crontrol {
395
  } else {
396
  $class = "";
397
  foreach( $crons as $time=>$cron ) {
398
- foreach( $cron as $hook=>$data) {
399
- $data = array_shift($data);
400
- if( $doing_edit && $doing_edit==$hook ) {
401
- $doing_edit = array('hookname'=>$hook,
402
- 'nextrun'=>$time,
403
- 'schedule'=>$data['schedule']);
404
- }
 
 
405
 
406
- echo "<tr id=\"cron-$hook\" class=\"$class\">";
407
- echo "<td>$hook</td>";
408
- echo "<td>".strftime("%D %T", $time)." (".$this->time_since(time(), $time).")</td>";
409
- echo "<td>{$data['interval']} (".$this->interval($data['interval']).")</td>";
410
- echo "<td><a class='view' href='edit.php?page=crontrol_admin_manage_page&amp;action=edit-cron&amp;id=$hook'>Edit</a></td>";
411
- echo "<td><a class='view' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=run-cron&amp;id=$hook", 'run-cron_' . $hook)."' onclick=\"return confirm('". js_escape(sprintf(__("You are about to execute a cron entry.\nPress 'OK' to continue or 'Cancel' to stop.", 'crontrol')))."');\">Do Now</a></td>";
412
- echo "<td><a class='delete' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=delete-cron&amp;id=$hook", 'delete-cron_' . $hook)."' onclick=\"return deleteSomething( 'cron', '$hook', '" . js_escape(sprintf( __("You are about to delete the cron entry '%s'.\n'OK' to delete, 'Cancel' to stop.", 'crontrol'), $hook)) . "' );\">Delete</a></td>";
413
- echo "</tr>";
414
- $class = empty($class)?"alternate":"";
 
 
415
  }
416
  }
417
  }
@@ -419,66 +539,12 @@ class Crontrol {
419
  </tbody>
420
  </table>
421
  </div>
422
- <?php if( is_array( $doing_edit ) ): ?>
423
- <div class="wrap narrow">
424
- <h2><?php _e('Edit cron entry', 'crontrol'); ?> (<a href="edit.php?page=crontrol_admin_manage_page"><?php _e('Add new', 'crontrol'); ?></a>)</h2>
425
- <form method="post">
426
- <?php wp_nonce_field('edit-cron_'.$doing_edit['hookname']) ?>
427
- <input name="original_hookname" type="hidden" value="<?php echo $doing_edit['hookname'] ?>" />
428
- <table width="100%" cellspacing="2" cellpadding="5" class="editform">
429
- <tbody><tr>
430
- <th width="33%" valign="top" scope="row"><label for="hookname"><?php _e('Hook name', 'crontrol'); ?>:</label></th>
431
- <td width="67%"><input type="text" size="40" id="hookname" name="hookname" value="<?php echo $doing_edit['hookname'] ?>"/></td>
432
- </tr><tr>
433
- <th width="33%" valign="top" scope="row"><label for="nextrun"><?php _e('Next run', 'crontrol'); ?>:</label></th>
434
- <td width="67%"><input type="text" size="40" id="nextrun" name="nextrun" value="<?php echo strftime("%D %T", $doing_edit['nextrun']) ?>"/></td>
435
- </tr><tr>
436
- <th valign="top" scope="row"><label for="schedule"><?php _e('Entry schedule', 'crontrol'); ?>:</label></th>
437
- <td>
438
- <select class="postform" name="schedule">
439
- <?php
440
- foreach( $schedules as $sched_name=>$sched_data ) {
441
- $selected = $doing_edit['schedule']==$sched_name ? 'selected="selected"' : '';
442
- echo "<option $selected value=\"$sched_name\">{$sched_data['display']} (".$this->interval($sched_data['interval']).")</option>\n";
443
- }
444
- ?>
445
- </select>
446
- </td>
447
- </tr>
448
- </tbody></table>
449
- <p class="submit"><input type="submit" value="<?php _e('Modify Cron Entry &raquo;', 'crontrol'); ?>" name="edit_cron"/></p>
450
- </form>
451
- </div>
452
- <?php else: ?>
453
- <div class="wrap narrow">
454
- <h2><?php _e('Add new cron entry', 'crontrol'); ?></h2>
455
- <p><?php _e('Cron entries trigger actions in your code. After adding a new cron entry here, you will need to add a corresponding action hook somewhere in code, perhaps the <code>functions.php</code> file in your theme.', 'crontrol'); ?></p>
456
- <form method="post">
457
- <?php wp_nonce_field('new-cron') ?>
458
- <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table">
459
- <tbody><tr>
460
- <th width="33%" valign="top" scope="row"><label for="hookname"><?php _e('Hook name', 'crontrol'); ?>:</label></th>
461
- <td width="67%"><input type="text" size="40" value="" id="hookname" name="hookname"/></td>
462
- </tr><tr>
463
- <th width="33%" valign="top" scope="row"><label for="nextrun"><?php _e('Next run', 'crontrol'); ?>:</label></th>
464
- <td width="67%"><input type="text" size="40" value="now" id="nextrun" name="nextrun"/></td>
465
- </tr><tr>
466
- <th valign="top" scope="row"><label for="schedule"><?php _e('Entry schedule', 'crontrol'); ?>:</label></th>
467
- <td>
468
- <select class="postform" name="schedule">
469
- <?php
470
- foreach( $schedules as $sched_name=>$sched_data ) {
471
- echo "<option value=\"$sched_name\">{$sched_data['display']} (".$this->interval($sched_data['interval']).")</option>\n";
472
- }
473
- ?>
474
- </select>
475
- </td>
476
- </tr>
477
- </tbody></table>
478
- <p class="submit"><input type="submit" value="<?php _e('Add Cron Entry &raquo;', 'crontrol'); ?>" name="new_cron"/></p>
479
- </form>
480
- </div>
481
- <?php endif;
482
  }
483
 
484
  /**
@@ -496,14 +562,15 @@ class Crontrol {
496
  function interval( $since ) {
497
  // array of time period chunks
498
  $chunks = array(
499
- array(60 * 60 * 24 * 365 , 'year'),
500
- array(60 * 60 * 24 * 30 , 'month'),
501
- array(60 * 60 * 24 * 7, 'week'),
502
- array(60 * 60 * 24 , 'day'),
503
- array(60 * 60 , 'hour'),
504
- array(60 , 'minute'),
505
- array( 1 , 'second'),
506
  );
 
507
 
508
  if( $since <= 0 ) {
509
  return __('now', 'crontrol');
@@ -528,7 +595,7 @@ class Crontrol {
528
  }
529
 
530
  // set output var
531
- $output = ($count == 1) ? '1 '.$name : "$count {$name}s";
532
 
533
  // step two: the second chunk
534
  if ($i + 1 < $j)
@@ -539,7 +606,7 @@ class Crontrol {
539
  if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
540
  {
541
  // add to output var
542
- $output .= ($count2 == 1) ? ', 1 '.$name2 : ", $count2 {$name2}s";
543
  }
544
  }
545
 
@@ -547,6 +614,32 @@ class Crontrol {
547
  }
548
  }
549
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
550
  // Get this show on the road
551
  new Crontrol();
552
  ?>
4
  * Plugin URI: http://www.scompt.com/projects/wp-crontrol
5
  * Description: WP-Crontrol lets you take control over what's happening in the WP-Cron system.
6
  * Author: Edward Dale
7
+ * Version: 1.0-beta1
8
  * Author URI: http://www.scompt.com
9
  */
10
 
32
  * @author Edward Dale <scompt@scompt.com>
33
  * @copyright Copyright 2007 Edward Dale
34
  * @license http://www.gnu.org/licenses/gpl.txt GPL 2.0
35
+ * @version $Id: wp-crontrol.php 49088 2008-06-04 13:40:40Z scompt $
36
  * @link http://www.scompt.com/projects/wp-crontrol
37
  * @since 0.2
38
  */
39
  class Crontrol {
40
+ var $json;
41
+
42
  /**
43
  * Hook onto all of the actions and filters needed by the plugin.
44
  */
45
  function Crontrol() {
46
+ define( 'CRONTROL_CRON_JOB', 'crontrol_cron_job');
47
+ $this->json = new Crontrol_JSON();
48
  if( function_exists('add_action') ) {
49
  add_action('init', array(&$this, 'init'));
50
  add_action('init', array(&$this, 'handle_posts'));
56
  add_action($activate_action, array(&$this, 'activate'));
57
 
58
  add_filter('cron_schedules', array(&$this, 'cron_schedules'));
59
+ add_action(CRONTROL_CRON_JOB, array(&$this, 'php_cron_entry'));
 
60
  }
61
  }
62
+
63
  /**
64
+ * Evaluates the provided code using eval.
65
  */
66
+ function php_cron_entry($code) {
67
+ eval($code);
68
  }
69
 
70
  /**
71
+ * Run using the 'init' action.
 
 
 
 
 
 
 
 
 
72
  */
73
+ function init() {
74
+ load_plugin_textdomain('crontrol', str_replace(ABSPATH, '', dirname(__FILE__).'/gettext'));
 
 
 
 
 
 
 
 
 
 
 
 
 
75
  }
76
 
77
  /**
78
  * Handles any POSTs made by the plugin. Run using the 'init' action.
79
  */
80
  function handle_posts() {
81
+ var_dump('asdf');
82
  if( isset($_POST['new_cron']) ) {
83
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
84
  check_admin_referer("new-cron");
85
+ extract($_POST, EXTR_PREFIX_ALL, 'in');
86
+ $in_args = $this->json->decode(stripslashes($in_args));
87
+ $this->add_cron($in_next_run, $in_schedule, $in_hookname, $in_args);
88
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=5&crontrol_name={$in_hookname}");
 
89
 
90
+ } else if( isset($_POST['new_php_cron']) ) {
91
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron events.', 'crontrol'));
92
+ check_admin_referer("new-cron");
93
+ extract($_POST, EXTR_PREFIX_ALL, 'in');
94
+ $args = array('code'=>stripslashes($in_hookcode));
95
+ $hookname = CRONTROL_CRON_JOB;
96
+ $this->add_cron($in_next_run, $in_schedule, $hookname, $args);
97
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=5&crontrol_name={$in_hookname}");
98
+
99
+ } else if( isset($_POST['edit_cron']) ) {
100
+ if( !current_user_can('manage_options') ) die(__('You are not allowed to edit cron events.', 'crontrol'));
101
+
102
+ extract($_POST, EXTR_PREFIX_ALL, 'in');
103
+ check_admin_referer("edit-cron_{$in_original_hookname}_{$in_original_sig}_{$in_original_next_run}");
104
+ $in_args = $this->json->decode(stripslashes($in_args));
105
+ $i=$this->delete_cron($in_original_hookname, $in_original_sig, $in_original_next_run);
106
+ $i=$this->add_cron($in_next_run, $in_schedule, $in_hookname, $in_args);
107
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=4&crontrol_name={$in_hookname}");
108
+
109
+ } else if( isset($_POST['edit_php_cron']) ) {
110
+ if( !current_user_can('manage_options') ) die(__('You are not allowed to edit cron events.', 'crontrol'));
111
+
112
+ extract($_POST, EXTR_PREFIX_ALL, 'in');
113
+ check_admin_referer("edit-cron_{$in_original_hookname}_{$in_original_sig}_{$in_original_next_run}");
114
+ $args['code'] = stripslashes($in_hookcode);
115
+ $hookname = CRONTROL_CRON_JOB;
116
+ $args = array('code'=>stripslashes($in_hookcode));
117
+ $i=$this->delete_cron($in_original_hookname, $in_original_sig, $in_original_next_run);
118
+ $i=$this->add_cron($in_next_run, $in_schedule, $hookname, $args);
119
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=4&crontrol_name={$in_hookname}");
120
 
121
  } else if( isset($_POST['new_schedule']) ) {
122
  if( !current_user_can('manage_options') ) die(__('You are not allowed to add new cron schedules.', 'crontrol'));
153
  } else if( isset($_GET['action']) && $_GET['action']=='delete-cron') {
154
  if( !current_user_can('manage_options') ) die(__('You are not allowed to delete cron events.', 'crontrol'));
155
  $id = $_GET['id'];
156
+ $sig = $_GET['sig'];
157
+ $next_run = $_GET['next_run'];
158
+ check_admin_referer("delete-cron_$id_$sig_{$next_run}");
159
+ if( $this->delete_cron($id, $sig, $next_run) ) {
160
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=6&crontrol_name=$id");
161
+ } else {
162
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=7&crontrol_name=$id");
163
+ };
164
 
165
  } else if( isset($_GET['action']) && $_GET['action']=='run-cron') {
166
  if( !current_user_can('manage_options') ) die(__('You are not allowed to run cron events.', 'crontrol'));
167
  $id = $_GET['id'];
168
+ $sig = $_GET['sig'];
169
+ check_admin_referer("run-cron_$id_$sig");
170
+ if( $this->run_cron($id, $sig) ) {
171
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=1&crontrol_name=$id");
172
+ } else {
173
+ wp_redirect("edit.php?page=crontrol_admin_manage_page&crontrol_message=8&crontrol_name=$id");
174
+ }
175
  }
176
  }
177
 
178
  /**
179
  * Executes a cron entry immediately.
180
  *
181
+ * Executes an entry by scheduling a new single event with the same arguments.
 
182
  *
183
  * @param string $hookname The hookname of the cron entry to run
184
  */
185
+ function run_cron($hookname, $sig) {
186
+ $crons = _get_cron_array();
187
+ foreach( $crons as $time=>$cron ) {
188
+ if( isset( $cron[$hookname][$sig] ) ) {
189
+ $args = $cron[$hookname][$sig]['args'];
190
+ wp_schedule_single_event(time()-1, $hookname, $args);
191
+ spawn_cron();
192
+ return true;
193
+ }
194
+ }
195
+ return false;
196
  }
197
 
198
  /**
201
  * @param string $next_run A human-readable (strtotime) time that the entry should be run at
202
  * @param string $schedule The recurrence of the cron entry
203
  * @param string $hookname The name of the hook to execute
204
+ * @param array $args Arguments to add to the cron entry
205
  */
206
+ function add_cron($next_run, $schedule, $hookname, $args) {
207
  $next_run = strtotime($next_run);
208
  if( $next_run===FALSE || $next_run==-1 ) $next_run=time();
209
+ if( !is_array($args) ) $args=array();
210
+ if( $schedule == '_oneoff' ) {
211
+ return wp_schedule_single_event($next_run, $hookname, $args) === NULL;
212
+ } else {
213
+ return wp_schedule_event( $next_run, $schedule, $hookname, $args ) === NULL;
214
  }
215
  }
216
 
219
  *
220
  * @param string $name The hookname of the entry to delete.
221
  */
222
+ function delete_cron($to_delete, $sig, $next_run) {
223
+ $crons = _get_cron_array();
224
+ if( isset( $crons[$next_run][$to_delete][$sig] ) ) {
225
+ $args = $crons[$next_run][$to_delete][$sig]['args'];
226
+ wp_unschedule_event($next_run, $to_delete, $args);
227
+ return true;
228
+ }
229
+ return false;
230
  }
231
 
232
  /**
275
  */
276
  function admin_menu() {
277
  $page = add_options_page('Crontrol', 'Crontrol', 'manage_options', 'crontrol_admin_options_page', array(&$this, 'admin_options_page') );
 
 
278
  $page = add_management_page('Crontrol', "Crontrol", 'manage_options', 'crontrol_admin_manage_page', array(&$this, 'admin_manage_page') );
 
279
  }
280
 
281
  /**
295
  * Displays the options page for the plugin.
296
  */
297
  function admin_options_page() {
298
+ $schedules = $this->get_schedules();
299
  $custom_schedules = get_option('crontrol_schedules');
300
  $custom_keys = array_keys($custom_schedules);
 
301
 
302
  if( isset($_GET['crontrol_message']) ) {
303
  $messages = array( '2' => __("Successfully deleted the cron schedule <b>%s</b>", 'crontrol'),
314
  <h2><?php _e("Cron Schedules", "crontrol"); ?></h2>
315
  <p><?php _e('Cron schedules are the time intervals that are available to WordPress and plugin developers to schedule events. You can only delete cron schedules that you have created with WP-Crontrol.', 'crontrol'); ?></p>
316
  <div id="ajax-response"></div>
317
+ <table class="widefat">
318
  <thead>
319
  <tr>
320
  <th><?php _e('Name', 'crontrol'); ?></th>
337
  echo "<td>{$data['interval']} (".$this->interval($data['interval']).")</td>";
338
  echo "<td>{$data['display']}</td>";
339
  if( in_array($name, $custom_keys) ) {
340
+ echo "<td><a href='" . wp_nonce_url( "options-general.php?page=crontrol_admin_options_page&amp;action=delete-sched&amp;id=$name", 'delete-sched_' . $name ) . "' class='delete'>".__( 'Delete' )."</a></td>";
341
  } else {
342
  echo "<td>&nbsp;</td>\n";
343
  }
375
  <?php
376
  }
377
 
378
+ /**
379
+ * Gets a sorted (according to interval) list of the cron schedules
380
+ */
381
+ function get_schedules() {
382
+ $schedules = wp_get_schedules();
383
+ uasort($schedules, create_function('$a,$b', 'return $a["interval"]-$b["interval"];'));
384
+ return $schedules;
385
+ }
386
+
387
+ /**
388
+ * Displays a dropdown filled with the possible schedules, including non-repeating.
389
+ *
390
+ * @param boolean $current The currently selected schedule
391
+ */
392
+ function schedules_dropdown($current=false) {
393
+ $schedules = $this->get_schedules();
394
+ echo '<select class="postform" name="schedule">';
395
+ foreach( $schedules as $sched_name=>$sched_data ) { ?>
396
+ <option <?php selected($current, $sched_name) ?> value="<?php echo $sched_name ?>">
397
+ <?php echo $sched_data['display'] ?> (<?php echo $this->interval($sched_data['interval']) ?>)
398
+ </option>
399
+ <?php } ?>
400
+ <option <?php selected($current, '_oneoff') ?> value="_oneoff"><?php _e('Non-repeating', 'crontrol') ?></option>
401
+ </select><?php
402
+ }
403
+
404
+ /**
405
+ * Shows the form used to add/edit cron entries.
406
+ *
407
+ * @param boolean $is_php Whether this is a PHP cron entry
408
+ * @param mixed $existing An array of existing values for the cron entry, or NULL
409
+ */
410
+ function show_cron_form($is_php, $existing) {
411
+ if( $is_php ) {
412
+ $helper_text = __('Cron entries trigger actions in your code. Using the form below, you can enter the schedule of the action, as well as the PHP code for the action itself. Alternatively, the schedule can be specified from within WordPress and the code for the action in a file on on your server using <a href="edit.php?page=crontrol_admin_manage_page&action=new-cron#crontrol_form">this form</a>.', 'crontrol');
413
+ $link = ' (<a href="edit.php?page=crontrol_admin_manage_page#crontrol_form">'. __('Add new entry', 'crontrol') .'</a>)';
414
+ } else {
415
+ $helper_text = __('Cron entries trigger actions in your code. A cron entry added using the form below needs a corresponding action hook somewhere in code, perhaps the <code>functions.php</code> file in your theme. It is also possible to create your action hook from within WordPress using <a href="edit.php?page=crontrol_admin_manage_page&action=new-php-cron#crontrol_form">this form</a>.', 'crontrol');
416
+ $link = ' (<a href="edit.php?page=crontrol_admin_manage_page&amp;action=new-php-cron#crontrol_form">'. __('Add new PHP entry', 'crontrol') .'</a>)';
417
+ }
418
+ if( is_array($existing) ) {
419
+ $other_fields = wp_nonce_field( "edit-cron_{$existing['hookname']}_{$existing['sig']}_{$existing['next_run']}", "_wpnonce", true, false );
420
+ $other_fields .= '<input name="original_hookname" type="hidden" value="'. $existing['hookname'] .'" />';
421
+ $other_fields .= '<input name="original_sig" type="hidden" value="'. $existing['sig'] .'" />';
422
+ $other_fields .= '<input name="original_next_run" type="hidden" value="'. $existing['next_run'] .'" />';
423
+ $existing['args'] = $is_php ? $existing['args']['code'] : htmlentities($this->json->encode($existing['args']));
424
+ $existing['next_run'] = strftime("%D %T", $existing['next_run']);
425
+ $action = $is_php ? 'edit_php_cron' : 'edit_cron';
426
+ $button = $is_php ? __('Modify PHP Cron Entry', 'crontrol') : __('Modify Cron Entry', 'crontrol');
427
+ $link = false;
428
+ } else {
429
+ $other_fields = wp_nonce_field( "new-cron", "_wpnonce", true, false );
430
+ $existing = array('hookname'=>'','hookcode'=>'','args'=>'','next_run'=>'now','schedule'=>false);
431
+ $action = $is_php ? 'new_php_cron' : 'new_cron';
432
+ $button = $is_php ? __('Add PHP Cron Entry', 'crontrol') : __('Add Cron Entry', 'crontrol');
433
+ }
434
+ ?>
435
+ <div id="crontrol_form" class="wrap narrow">
436
+ <h2><?php echo $button; if($link) echo '<span style="font-size:xx-small">'.$link.'</span>'; ?></h2>
437
+ <p><?php echo $helper_text ?></p>
438
+ <form method="post">
439
+ <?php echo $other_fields ?>
440
+ <table width="100%" cellspacing="2" cellpadding="5" class="editform form-table"><tbody>
441
+ <?php if( $is_php ): ?>
442
+ <tr>
443
+ <th width="33%" valign="top" scope="row"><label for="hookcode"><?php _e('Hook code', 'crontrol'); ?>:</label></th>
444
+ <td width="67%"><textarea style="width:95%" name="hookcode"><?php echo $existing['args'] ?></textarea></td>
445
+ </tr>
446
+ <?php else: ?>
447
+ <tr>
448
+ <th width="33%" valign="top" scope="row"><label for="hookname"><?php _e('Hook name', 'crontrol'); ?>:</label></th>
449
+ <td width="67%"><input type="text" size="40" id="hookname" name="hookname" value="<?php echo $existing['hookname'] ?>"/></td>
450
+ </tr>
451
+ <tr>
452
+ <th width="33%" valign="top" scope="row"><label for="args"><?php _e('Arguments', 'crontrol'); ?>:</label><br /><span style="font-size:xx-small"><?php _e('e.g., [], [25], ["asdf"], or ["i","want",25,"cakes"]', 'crontrol') ?></span></th>
453
+ <td width="67%"><input type="text" size="40" id="args" name="args" value="<?php echo $existing['args'] ?>"/></td>
454
+ </tr>
455
+ <?php endif; ?>
456
+ <tr>
457
+ <th width="33%" valign="top" scope="row"><label for="next_run"><?php _e('Next run', 'crontrol'); ?>:</label><br /><span style="font-size:xx-small"><?php _e('e.g., "now", "tomorrow", "+2 days", or "06/04/08 15:27:09"', 'crontrol') ?></th>
458
+ <td width="67%"><input type="text" size="40" id="next_run" name="next_run" value="<?php echo $existing['next_run'] ?>"/></td>
459
+ </tr><tr>
460
+ <th valign="top" scope="row"><label for="schedule"><?php _e('Entry schedule', 'crontrol'); ?>:</label></th>
461
+ <td>
462
+ <?php $this->schedules_dropdown($existing['schedule']) ?>
463
+ </td>
464
+ </tr>
465
+ </tbody></table>
466
+ <p class="submit"><input type="submit" value="<?php echo $button ?> &raquo;" name="<?php echo $action ?>"/></p>
467
+ </form>
468
+ </div>
469
+ <?php
470
+ }
471
+
472
  /**
473
  * Displays the manage page for the plugin.
474
  */
477
  $messages = array( '1' => __('Successfully executed the cron entry <b>%s</b>', 'crontrol'),
478
  '4' => __('Successfully edited the cron entry <b>%s</b>', 'crontrol'),
479
  '5' => __('Successfully created the cron entry <b>%s</b>', 'crontrol'),
480
+ '6' => __('Successfully deleted the cron entry <b>%s</b>', 'crontrol'),
481
+ '7' => __('Failed to the delete the cron entry <b>%s</b>', 'crontrol'),
482
+ '8' => __('Failed to the execute the cron entry <b>%s</b>', 'crontrol'));
483
  $hook = $_GET['crontrol_name'];
484
  $msg = sprintf($messages[$_GET['crontrol_message']], $hook);
485
 
486
  echo "<div id=\"message\" class=\"updated fade\"><p>$msg</p></div>";
487
  }
488
  $crons = _get_cron_array();
489
+ $schedules = $this->get_schedules();
490
  $doing_edit = (isset( $_GET['action']) && $_GET['action']=='edit-cron') ? $_GET['id'] : false ;
491
  ?>
492
  <div class="wrap">
493
  <h2><?php _e('WP-Cron Entries', 'crontrol'); ?></h2>
494
  <p></p>
495
+ <table class="widefat">
 
496
  <thead>
497
  <tr>
498
  <th><?php _e('Hook Name', 'crontrol'); ?></th>
499
+ <th><?php _e('Arguments', 'crontrol'); ?></th>
500
  <th><?php _e('Next Run', 'crontrol'); ?></th>
501
  <th><?php _e('Recurrence', 'crontrol'); ?></th>
502
  <th colspan="3"><?php _e('Actions', 'crontrol'); ?></th>
511
  } else {
512
  $class = "";
513
  foreach( $crons as $time=>$cron ) {
514
+ foreach( $cron as $hook=>$dings) {
515
+ foreach( $dings as $sig=>$data ) {
516
+ if( $doing_edit && $doing_edit==$hook && $time == $_GET['next_run'] && $sig==$_GET['sig'] ) {
517
+ $doing_edit = array('hookname'=>$hook,
518
+ 'next_run'=>$time,
519
+ 'schedule'=>($data['schedule'] ? $data['schedule'] : '_oneoff'),
520
+ 'sig'=>$sig,
521
+ 'args'=>$data['args']);
522
+ }
523
 
524
+ echo "<tr id=\"cron-$hook-$sig\" class=\"$class\">";
525
+ echo "<td>".($hook==CRONTROL_CRON_JOB ? __('<i>PHP Cron</i>', 'crontrol') : $hook)."</td>";
526
+ echo "<td>".($hook==CRONTROL_CRON_JOB ? __('<i>PHP Code</i>', 'crontrol') : $this->json->encode($data['args']))."</td>";
527
+ echo "<td>".strftime("%D %T", $time)." (".$this->time_since(time(), $time).")</td>";
528
+ echo "<td>".($data['schedule'] ? $data['interval'].' ('.$this->interval($data['interval']).')' : __('Non-repeating', 'crontrol'))."</td>";
529
+ echo "<td><a class='view' href='edit.php?page=crontrol_admin_manage_page&amp;action=edit-cron&amp;id=$hook&amp;sig=$sig&amp;next_run=$time#crontrol_form'>Edit</a></td>";
530
+ echo "<td><a class='view' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=run-cron&amp;id=$hook&amp;sig=$sig", "run-cron_$hook_$sig")."'>Do Now</a></td>";
531
+ echo "<td><a class='delete' href='".wp_nonce_url("edit.php?page=crontrol_admin_manage_page&amp;action=delete-cron&amp;id=$hook&amp;sig=$sig&amp;next_run=$time", "delete-cron_$hook_$sig_$time")."'>Delete</a></td>";
532
+ echo "</tr>";
533
+ $class = empty($class)?"alternate":"";
534
+ }
535
  }
536
  }
537
  }
539
  </tbody>
540
  </table>
541
  </div>
542
+ <?php
543
+ if( is_array( $doing_edit ) ) {
544
+ $this->show_cron_form($doing_edit['hookname']==CRONTROL_CRON_JOB, $doing_edit);
545
+ } else {
546
+ $this->show_cron_form($_GET['action']=='new-php-cron', false);
547
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
548
  }
549
 
550
  /**
562
  function interval( $since ) {
563
  // array of time period chunks
564
  $chunks = array(
565
+ array(60 * 60 * 24 * 365 , __ngettext_noop('%s year', '%s years', 'crontrol')),
566
+ array(60 * 60 * 24 * 30 , __ngettext_noop('%s month', '%s months', 'crontrol')),
567
+ array(60 * 60 * 24 * 7, __ngettext_noop('%s week', '%s weeks', 'crontrol')),
568
+ array(60 * 60 * 24 , __ngettext_noop('%s day', '%s days', 'crontrol')),
569
+ array(60 * 60 , __ngettext_noop('%s hour', '%s hours', 'crontrol')),
570
+ array(60 , __ngettext_noop('%s minute', '%s minutes', 'crontrol')),
571
+ array( 1 , __ngettext_noop('%s second', '%s seconds', 'crontrol')),
572
  );
573
+
574
 
575
  if( $since <= 0 ) {
576
  return __('now', 'crontrol');
595
  }
596
 
597
  // set output var
598
+ $output = sprintf(__ngettext($name[0], $name[1], $count, 'crontrol'), $count);
599
 
600
  // step two: the second chunk
601
  if ($i + 1 < $j)
606
  if (($count2 = floor(($since - ($seconds * $count)) / $seconds2)) != 0)
607
  {
608
  // add to output var
609
+ $output .= ' '.sprintf(__ngettext($name2[0], $name2[1], $count2, 'crontrol'), $count2);
610
  }
611
  }
612
 
614
  }
615
  }
616
 
617
+ if( !function_exists('json_encode' ) ) {
618
+ if( !class_exists('Services_JSON') )
619
+ require_once('JSON.php');
620
+
621
+ class Crontrol_JSON {
622
+ var $json;
623
+ function Crontrol_JSON() {
624
+ $this->json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE);
625
+ }
626
+ function encode($in) {
627
+ return $this->json->encode($in);
628
+ }
629
+ function decode($in) {
630
+ return $this->json->decode($in);
631
+ }
632
+ }
633
+ } else {
634
+ class Crontrol_JSON {
635
+ function encode($in) {
636
+ return json_encode($in);
637
+ }
638
+ function decode($in) {
639
+ return json_decode($in, true);
640
+ }
641
+ }
642
+ }
643
  // Get this show on the road
644
  new Crontrol();
645
  ?>