Created
February 19, 2016 07:41
-
-
Save derpixler/3ee56b1a48c49e2a92f0 to your computer and use it in GitHub Desktop.
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: WordPress Simple Cronjob test | |
Plugin URI: | |
Description: This is a Simple WordPress Cronjob testplugin | |
Version: 1.1 | |
Author: Rene Reimann | |
Author URI: http://www.rene-reimann.de | |
*/ | |
add_filter( 'cron_schedules', 'wsct_add_schudle' ); | |
function wsct_add_schudle( $schedules ) { | |
// Adds once weekly to the existing schedules. | |
$schedules[ 'wsct_30_seconds' ] = array( | |
'interval' => 30, | |
'display' => __( 'WSCT 30 seconds' ) | |
); | |
return $schedules; | |
} | |
if ( ! wp_next_scheduled( 'wsct_task_hook' ) ) { | |
wp_schedule_event( time(), 'wsct_30_seconds', 'wsct_task_hook' ); | |
} | |
add_action( 'wsct_task_hook', 'wsct_task_function' ); | |
function wsct_task_function() { | |
$adress = 'YOUR@MAILADRESSE.TDL'; | |
$subject = 'WordPress Simple Cronjob test Automatic email'; | |
$content = "Automatic scheduled email from WordPress.\nSend From " . $_SERVER['SERVER_NAME']; | |
wp_mail( $adress, $subject, $content ); | |
} | |
register_deactivation_hook( __FILE__, 'wsct_deactivate' ); | |
function wsct_deactivate() { | |
wp_clear_scheduled_hook( 'wsct_task_hook' ); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment