Created
September 23, 2018 08:37
-
-
Save Hotfirenet/8a1df9588249707d02a5708f325f89d6 to your computer and use it in GitHub Desktop.
Test cron wordpress
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 | |
/* | |
Plugin Name: HFN test schedule | |
Version: 0.0.1 | |
Plugin URI: http://hotfirenet.com/ | |
Description: Plugin qui test le cron | |
Author: Johan VIVIEN | |
Author URI: http://hotfirenet.com | |
*/ | |
defined( 'ABSPATH' ) or die( 'Cheatin’ uh?' ); | |
if ( ! wp_next_scheduled( 'hfn_crontask_hook' ) ) { | |
wp_schedule_event( time(), 'hourly', 'hfn_crontask_hook' ); | |
} | |
add_action( 'hfn_crontask_hook', function () { | |
$myTime = the_time( get_option( 'date_format' ) ); | |
update_option( 'hfn_date_last_schedule', $myTime ); | |
wp_mail( get_option('admin_email'), 'Automatic email', 'Automatic scheduled email from WordPress.'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment