PluginProbe
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages / 2.6.2
Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages v2.6.2
3.4.1 3.4.0 3.3.9 3.3.8 3.3.7 3.3.6 3.3.5 3.3.4 3.3.3 3.3.2 3.3.1 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 All 194 releases
convertkit / includes / cron-functions.php

cron-functions.php in Kit (formerly ConvertKit) – Email Newsletter, Email Marketing, Membership, Subscribers and Landing Pages 2.6.2, at includes/cron-functions.php

47 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 * ConvertKit WordPress Cron functions.
4 *
5 * @package ConvertKit
6 * @author ConvertKit
7 */
8
9 /**
10 * Refresh the Posts Resource cache, triggered by WordPress' Cron.
11 *
12 * @since 1.9.7.4
13 */
14 function convertkit_resource_refresh_posts() {
15
16 // Get Settings and Log classes.
17 $settings = new ConvertKit_Settings();
18 $log = new ConvertKit_Log( CONVERTKIT_PLUGIN_PATH );
19
20 // If debug logging is enabled, write to it now.
21 if ( $settings->debug_enabled() ) {
22 $log->add( 'CRON: convertkit_resource_refresh_posts(): Started' );
23 }
24
25 // Refresh Posts Resource.
26 $posts = new ConvertKit_Resource_Posts( 'cron' );
27 $result = $posts->refresh();
28
29 // If debug logging is enabled, write to it now.
30 if ( $settings->debug_enabled() ) {
31 // If an error occured, log it.
32 if ( is_wp_error( $result ) ) {
33 $log->add( 'CRON: convertkit_resource_refresh_posts(): Error: ' . $result->get_error_message() );
34 }
35 if ( is_array( $result ) ) {
36 $log->add( 'CRON: convertkit_resource_refresh_posts(): Success: ' . count( $result ) . ' broadcasts fetched from API and cached.' );
37 }
38
39 $log->add( 'CRON: convertkit_resource_refresh_posts(): Finished' );
40 }
41
42 }
43
44 // Register action to run above function; this action is created by WordPress' wp_schedule_event() function
45 // in the ConvertKit_Resource_Posts class.
46 add_action( 'convertkit_resource_refresh_posts', 'convertkit_resource_refresh_posts' );
47