Skip to content

Instantly share code, notes, and snippets.

@JPry
Created February 14, 2012 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPry/1828091 to your computer and use it in GitHub Desktop.
Save JPry/1828091 to your computer and use it in GitHub Desktop.
<?php
/**
* This is an example of the proper way to take advantage of wp_cron() processes. For more information,
* see http://codex.wordpress.org/Function_Reference/wp_cron.
*
*/
// We use an if statement to see if there is already a scheduled event so that we don't add one for every page view.
if ( ! wp_next_scheduled( 'foxyshop_email_cron_test' ) ) {
wp_schedule_event( time(), 'hourly', 'foxyshop_email_cron_test' );
}
// In order to get our actual function to run, we use add_action() to the name of the event in wp_next_scheduled()
add_action( 'foxyshop_email_cron_test', 'foxyshop_email_cron_job' );
/**
* This function runs our email cron job
*
* @uses foxyshop_auto_email_sales_stats()
*/
function foxyshop_email_cron_job() {
require_once( CHILD_DIR . '/foxyshop/auto-email-script.php' );
foxyshop_auto_email_sales_stats();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment