Created
January 22, 2014 16:52
-
-
Save heydonovan/8562384 to your computer and use it in GitHub Desktop.
Digital Access Path (DAP) - Faux Cronjob
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Add a new interval of a week | |
// See http://codex.wordpress.org/Plugin_API/Filter_Reference/cron_schedules | |
add_filter( 'cron_schedules', 'myprefix_add_weekly_cron_schedule' ); | |
function myprefix_add_weekly_cron_schedule( $schedules ) { | |
$schedules['weekly'] = array( | |
'interval' => 600, // 10 minutes | |
'display' => __( 'Once Weekly' ), | |
); | |
return $schedules; | |
} | |
// Schedule an action if it's not already scheduled | |
if ( ! wp_next_scheduled( 'myprefix_my_cron_action' ) ) { | |
wp_schedule_event( time(), 'weekly', 'myprefix_my_cron_action' ); | |
} | |
// Hook into that action that'll fire weekly | |
add_action( 'myprefix_my_cron_action', 'myprefix_function_to_run' ); | |
function myprefix_function_to_run() { | |
$domain = $_SERVER['HTTP_HOST']; | |
// http://domain.com/dap/dap-cron.php | |
// (to run hourly cron) | |
file_get_contents("{$domain}/dap/dap-cron.php"); | |
// http://domain.com/dap/dap-emailorder.php | |
// (to run the email order cron that runs every 10 minutes) | |
file_get_contents("{$domain}/dap/dap-emailorder.php "); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment