| 1 |
<?php |
| 2 |
|
| 3 |
use Imagify\Traits\InstanceGetterTrait; |
| 4 |
|
| 5 |
/** |
| 6 |
* Class that handles the cron that calculate and cache the library size. |
| 7 |
* |
| 8 |
* @since 1.7 |
| 9 |
* @author Grégory Viguier |
| 10 |
*/ |
| 11 |
class Imagify_Cron_Library_Size extends Imagify_Abstract_Cron { |
| 12 |
use InstanceGetterTrait; |
| 13 |
|
| 14 |
/** |
| 15 |
* Class version. |
| 16 |
* |
| 17 |
* @var string |
| 18 |
* @since 1.7 |
| 19 |
*/ |
| 20 |
const VERSION = '1.0'; |
| 21 |
|
| 22 |
/** |
| 23 |
* Cron name. |
| 24 |
* |
| 25 |
* @var string |
| 26 |
* @since 1.7 |
| 27 |
* @access protected |
| 28 |
*/ |
| 29 |
protected $event_name = 'imagify_update_library_size_calculations_event'; |
| 30 |
|
| 31 |
/** |
| 32 |
* Cron recurrence. |
| 33 |
* |
| 34 |
* @var string |
| 35 |
* @since 1.7 |
| 36 |
* @access protected |
| 37 |
*/ |
| 38 |
protected $event_recurrence = 'weekly'; |
| 39 |
|
| 40 |
/** |
| 41 |
* Cron time. |
| 42 |
* |
| 43 |
* @var string |
| 44 |
* @since 1.7 |
| 45 |
* @access protected |
| 46 |
*/ |
| 47 |
protected $event_time = '04:00'; |
| 48 |
|
| 49 |
/** ----------------------------------------------------------------------------------------- */ |
| 50 |
/** HOOKS =================================================================================== */ |
| 51 |
/** ----------------------------------------------------------------------------------------- */ |
| 52 |
|
| 53 |
/** |
| 54 |
* The event action. |
| 55 |
* |
| 56 |
* @since 1.7 |
| 57 |
* @access public |
| 58 |
* @author Grégory Viguier |
| 59 |
*/ |
| 60 |
public function do_event() { |
| 61 |
imagify_do_async_job( |
| 62 |
[ |
| 63 |
'action' => 'imagify_update_estimate_sizes', |
| 64 |
'_ajax_nonce' => wp_create_nonce( 'update_estimate_sizes' ), |
| 65 |
] |
| 66 |
); |
| 67 |
} |
| 68 |
} |
| 69 |
|