PluginProbe
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels / 2.3.8
Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels v2.3.8
2.9.1 2.9.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 2.0.0 2.1.0 2.2.0 2.3.2 2.3.3 2.3.5 2.3.6 2.3.8 2.3.9 2.4.3 All 37 releases
automatic-youtube-gallery / public / cron.php

cron.php in Automatic YouTube Gallery – Embed Auto-Updating YouTube Video Galleries, Feeds, Playlists & Channels 2.3.8, at public/cron.php

73 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Cron Jobs.
5 *
6 * @link https://plugins360.com
7 * @since 2.3.0
8 *
9 * @package Automatic_YouTube_Gallery
10 */
11
12 // Exit if accessed directly
13 if ( ! defined( 'WPINC' ) ) {
14 die;
15 }
16
17 /**
18 * AYG_Public_Cron class.
19 *
20 * @since 2.3.0
21 */
22 class AYG_Public_Cron {
23
24 /**
25 * Add a custom weekly cron schedule.
26 *
27 * @since 2.3.0
28 * @param array $schedules An array of non-default cron schedules.
29 * @return array $schedules Filtered array of non-default cron schedules.
30 */
31 public function cron_schedules( $schedules ) {
32 $schedules['weekly'] = array(
33 'interval' => 7 * DAY_IN_SECONDS,
34 'display' => __( 'Weekly', 'automatic-youtube-gallery' )
35 );
36
37 return $schedules;
38 }
39
40 /**
41 * Schedule an action if it's not already scheduled.
42 *
43 * @since 2.3.0
44 */
45 public function schedule_events() {
46 if ( ! wp_next_scheduled( 'ayg_schedule_weekly' ) ) {
47 wp_schedule_event( time(), 'weekly', 'ayg_schedule_weekly' );
48 }
49 }
50
51 /**
52 * Called weekly.
53 *
54 * @since 2.3.0
55 */
56 public function cron_event() {
57 $existing_keys = get_option( 'ayg_transient_keys', array() );
58
59 if ( is_array( $existing_keys ) ) {
60 $filtered_keys = array();
61
62 foreach ( $existing_keys as $key ) {
63 if ( get_transient( $key ) ) {
64 $filtered_keys[] = $key;
65 }
66 }
67
68 update_option( 'ayg_transient_keys', $filtered_keys );
69 }
70 }
71
72 }
73