[Plugin: Plugins] Basic Schedule Not Working
-
Hi, I’m a newbie to wordpress plugins (but not PHP). I’ve followed a couple of tutorials and I simply can’t get a schedule working. I basically want to create the equivalent of a cronjob to send today’s posts out to every user of the system.
First thing’s first, I can’t even get the most basic schedule working. Please advise?
<?php /* Plugin Name: testschedule Version: 0.1 Description: A simple plugin to test schedules are working Plugin URI: lololol Author: Moi Author URI: http://www.j7mbo.co.uk */ $plugin_dir = plugin_basename(__FILE__); $plugin_dir = str_replace(basename($plugin_dir), '', $plugin_dir); define('TESTSCHEDULE_DIR', WP_PLUGIN_DIR . '/' . $plugin_dir); define('TESTSCHEDULE_URL', WP_PLUGIN_URL . '/' . $plugin_dir); define('TESTSCHEDULE_VERSION', 0.1); class testschedule { private static $instance; public static function forge() { if (!isset(self::$instance)) { $className = __CLASS__; self::$instance = new $className; } return self::$instance; } private function __construct() { add_action('daily_schedule', array($this, 'main') ); } private function main() { // Do something echo '<br><br><br>OMG'; die; } } global $testschedule; $testschedule = testschedule::forge(); register_activation_hook(__FILE__, 'activate'); register_deactivation_hook(__FILE__, 'deactivate'); function activate() { if ( !wp_next_scheduled( 'daily_schedule' ) ) { wp_schedule_event( '1342021600', 'daily', 'daily_schedule'); // Daily at 4:50pm = 1342025400 } } function deactivate() { wp_clear_scheduled_hook('activate'); }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[Plugin: Plugins] Basic Schedule Not Working’ is closed to new replies.