本文整理汇总了PHP中wp_schedule_event函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_schedule_event函数的具体用法?PHP wp_schedule_event怎么用?PHP wp_schedule_event使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_schedule_event函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
function __construct() {
global $itsec_globals;
//make sure the log file info is there or generate it. This should only affect beta users.
if ( ! isset( $itsec_globals['settings']['log_info'] ) ) {
$itsec_globals['settings']['log_info'] = substr( sanitize_title( get_bloginfo( 'name' ) ), 0, 20 ) . '-' . ITSEC_Lib::get_random( mt_rand( 0, 10 ) );
update_site_option( 'itsec_global', $itsec_globals['settings'] );
}
//Make sure the logs directory was created
if ( ! is_dir( $itsec_globals['ithemes_log_dir'] ) ) {
@mkdir( trailingslashit( $itsec_globals['ithemes_dir'] ) . 'logs' );
}
//don't create a log file if we don't need it.
if ( isset( $itsec_globals['settings']['log_type'] ) && $itsec_globals['settings']['log_type'] !== 0 ) {
$this->log_file = $itsec_globals['ithemes_log_dir'] . '/event-log-' . $itsec_globals['settings']['log_info'] . '.log';
$this->start_log(); //create a log file if we don't have one
}
$this->logger_modules = array(); //array to hold information on modules using this feature
$this->logger_displays = array(); //array to hold metabox information
$this->module_path = ITSEC_Lib::get_module_path( __FILE__ );
add_action( 'plugins_loaded', array( $this, 'register_modules' ) );
add_action( 'admin_enqueue_scripts', array( $this, 'admin_script' ) ); //enqueue scripts for admin page
//Run database cleanup daily with cron
if ( ! wp_next_scheduled( 'itsec_purge_logs' ) ) {
wp_schedule_event( time(), 'daily', 'itsec_purge_logs' );
}
add_action( 'itsec_purge_logs', array( $this, 'purge_logs' ) );
if ( is_admin() ) {
require( trailingslashit( $itsec_globals['plugin_dir'] ) . 'core/lib/class-itsec-wp-list-table.php' ); //used for generating log tables
add_action( 'itsec_add_admin_meta_boxes', array( $this, 'add_admin_meta_boxes' ) ); //add log meta boxes
}
if ( isset( $_POST['itsec_clear_logs'] ) && $_POST['itsec_clear_logs'] === 'clear_logs' ) {
global $itsec_clear_all_logs;
$itsec_clear_all_logs = true;
add_action( 'plugins_loaded', array( $this, 'purge_logs' ) );
}
}
示例2: __construct
public function __construct()
{
if (!wp_next_scheduled('fileaway_scheduled_cleanup')) {
wp_schedule_event(time(), 'hourly', 'fileaway_scheduled_cleanup');
}
add_action('fileaway_scheduled_cleanup', array($this, 'cleanup'));
}
示例3: cron
/**
* Set up crons. CLear any existing scheduled hooks, and add ours.
*
* @since Astoundify Crowdfunding 1.6
*
* @return void
*/
public static function cron()
{
wp_clear_scheduled_hook('atcf_check_for_completed_campaigns');
wp_schedule_event(time(), 'hourly', 'atcf_check_for_completed_campaigns');
wp_clear_scheduled_hook('atcf_process_payments');
wp_schedule_event(time(), 'hourly', 'atcf_process_payments');
}
示例4: load
public function load($parent)
{
$this->parent = $parent;
//delete_option('redux-framework-tracking');
$this->options = get_option('redux-framework-tracking');
$this->options['dev_mode'] = $parent->args['dev_mode'];
if (!isset($this->options['hash']) || !$this->options['hash'] || empty($this->options['hash'])) {
$this->options['hash'] = md5(site_url() . '-' . $_SERVER['REMOTE_ADDR']);
update_option('redux-framework-tracking', $this->options);
}
if (isset($_GET['redux_framework_disable_tracking']) && !empty($_GET['redux_framework_disable_tracking'])) {
$this->options['allow_tracking'] = false;
update_option('redux-framework-tracking', $this->options);
}
if (isset($_GET['redux_framework_enable_tracking']) && !empty($_GET['redux_framework_enable_tracking'])) {
$this->options['allow_tracking'] = true;
update_option('redux-framework-tracking', $this->options);
}
if (isset($_GET['page']) && $_GET['page'] == $this->parent->args['page_slug']) {
if (!isset($this->options['allow_tracking'])) {
add_action('admin_enqueue_scripts', array($this, '_enqueue_tracking'));
} else {
if (!isset($this->options['tour']) && ($this->parent->args['dev_mode'] == "true" || $this->parent->args['page_slug'] == "redux_demo")) {
add_action('admin_enqueue_scripts', array($this, '_enqueue_newsletter'));
}
}
}
if (isset($this->options['allow_tracking']) && $this->options['allow_tracking'] == true) {
// The tracking checks daily, but only sends new data every 7 days.
if (!wp_next_scheduled('redux_tracking')) {
wp_schedule_event(time(), 'daily', 'redux_tracking');
}
add_action('redux_tracking', array($this, 'tracking'));
}
}
示例5: setSchedule
public function setSchedule($code, $value)
{
switch ($code) {
case 'sch_every_hour':
$value ? wp_schedule_event(time(), 'hourly', 'bup_cron_hour') : wp_clear_scheduled_hook('bup_cron_hour');
break;
case 'sch_every_day':
$value ? wp_schedule_event(time(), 'daily', 'bup_cron_day') : wp_clear_scheduled_hook('bup_cron_day');
break;
case 'sch_every_day_twice':
$value ? wp_schedule_event(time(), 'twicedaily', 'bup_cron_day_twice') : wp_clear_scheduled_hook('bup_cron_day_twice');
break;
case 'sch_every_week':
$value ? wp_schedule_event(time(), 'weekly', 'bup_cron_weekly') : wp_clear_scheduled_hook('bup_cron_weekly');
break;
case 'sch_every_month':
$value ? wp_schedule_event(time(), 'monthly', 'bup_cron_monthly') : wp_clear_scheduled_hook('bup_cron_monthly');
break;
/* test
case 'sch_every_hour': $value ? wp_schedule_event(time(), 'test_hour', 'bup_cron_hour') : false; break;
case 'sch_every_day': $value ? wp_schedule_event(time(), 'test_daily', 'bup_cron_day') : false; break;
case 'sch_every_day_twice': $value ? wp_schedule_event(time(), 'test_2daily', 'bup_cron_day_twice') : false; break;
case 'sch_every_week': $value ? wp_schedule_event(time(), 'test_weekly', 'bup_cron_weekly') : false; break;
case 'sch_every_month': $value ? wp_schedule_event(time(), 'test_monthly', 'bup_cron_monthly') : false; break;*/
}
}
示例6: plugin_activate
/**
* Perform one-time operations on plugin activation.
*
* @since 1.0.0
*/
public function plugin_activate()
{
// Setup version check twice a day.
if (!wp_next_scheduled('slack_notif_check_versions')) {
wp_schedule_event(time(), 'twicedaily', 'slack_notif_check_versions');
}
}
示例7: check_cron
/**
* Check whether WP Cron needs to add new task.
*/
public function check_cron()
{
if (!is_admin()) {
return;
}
// set wp cron task
if (Post_Views_Counter()->get_attribute('options', 'general', 'cron_run')) {
// not set or need to be updated?
if (!wp_next_scheduled('pvc_reset_counts') || Post_Views_Counter()->get_attribute('options', 'general', 'cron_update')) {
// task is added but need to be updated
if (Post_Views_Counter()->get_attribute('options', 'general', 'cron_update')) {
// remove old schedule
wp_clear_scheduled_hook('pvc_reset_counts');
// set update to false
$general = Post_Views_Counter()->get_attribute('options', 'general');
$general['cron_update'] = false;
// update settings
update_option('post_views_counter_settings_general', $general);
}
// set schedule
wp_schedule_event(Post_Views_Counter()->get_instance('counter')->get_timestamp(Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'type'), Post_Views_Counter()->get_attribute('options', 'general', 'reset_counts', 'number')), 'post_views_counter_interval', 'pvc_reset_counts');
}
} else {
// remove schedule
wp_clear_scheduled_hook('pvc_reset_counts');
remove_action('pvc_reset_counts', array(&$this, 'reset_counts'));
}
}
示例8: run
/**
* Setup the module's functionality
*
* Loads the file change detection module's unpriviledged functionality including
* performing the scans themselves
*
* @since 4.0.0
*
* @return void
*/
function run()
{
global $itsec_globals;
$settings = ITSEC_Modules::get_settings('file-change');
$interval = 86400;
//Run daily
// If we're splitting the file check run it every 6 hours.
if (isset($settings['split']) && true === $settings['split']) {
$interval = 12342;
}
add_action('itsec_execute_file_check_cron', array($this, 'run_scan'));
//Action to execute during a cron run.
add_filter('itsec_logger_displays', array($this, 'itsec_logger_displays'));
//adds logs metaboxes
add_filter('itsec_logger_modules', array($this, 'itsec_logger_modules'));
add_filter('itsec_sync_modules', array($this, 'itsec_sync_modules'));
//register sync modules
if ((!defined('DOING_AJAX') || DOING_AJAX === false) && isset($settings['last_run']) && $itsec_globals['current_time'] - $interval > $settings['last_run'] && (!defined('ITSEC_FILE_CHECK_CRON') || false === ITSEC_FILE_CHECK_CRON)) {
wp_clear_scheduled_hook('itsec_file_check');
add_action('init', array($this, 'run_scan'));
} elseif (defined('ITSEC_FILE_CHECK_CRON') && true === ITSEC_FILE_CHECK_CRON && !wp_next_scheduled('itsec_execute_file_check_cron')) {
//Use cron if needed
wp_schedule_event(time(), 'daily', 'itsec_execute_file_check_cron');
}
}
示例9: scheduleProcessComments
public function scheduleProcessComments()
{
$options = get_option($this->prefix . 'settings');
if (!wp_get_schedule($this->prefix . 'process') && 1 === $options['use_txs_polling']) {
wp_schedule_event(time(), 'hourly', $this->prefix . 'process');
}
}
示例10: __construct
/**
* Set up the API module.
*
* @since 4.0.0
* @internal
*/
public function __construct()
{
if (WPMUDEV_CUSTOM_API_SERVER) {
$this->server_root = trailingslashit(WPMUDEV_CUSTOM_API_SERVER);
}
$this->server_url = $this->server_root . $this->rest_api;
if (defined('WPMUDEV_APIKEY') && WPMUDEV_APIKEY) {
$this->api_key = WPMUDEV_APIKEY;
} else {
// If 'clear_key' is present in URL then do not load the key from DB.
$this->api_key = get_site_option('wpmudev_apikey');
}
// Schedule automatic data update on the main site of the network.
if (is_main_site()) {
if (!wp_next_scheduled('wpmudev_scheduled_jobs')) {
wp_schedule_event(time(), 'twicedaily', 'wpmudev_scheduled_jobs');
}
add_action('wpmudev_scheduled_jobs', array($this, 'refresh_membership_data'));
} elseif (wp_next_scheduled('wpmudev_scheduled_jobs')) {
// In case the cron job was already installed in a sub-site...
wp_clear_scheduled_hook('wpmudev_scheduled_jobs');
}
/**
* Run custom initialization code for the API module.
*
* @since 4.0.0
* @var WPMUDEV_Dashboard_Api The dashboards API module.
*/
do_action('wpmudev_dashboard_api_init', $this);
}
示例11: installHooks
/**
* Install the hooks required to run periodic update checks and inject update info
* into WP data structures.
*
* @return void
*/
function installHooks()
{
//Override requests for plugin information
add_filter('plugins_api', array(&$this, 'injectInfo'), 10, 3);
//Insert our update info into the update array maintained by WP
add_filter('site_transient_update_plugins', array(&$this, 'injectUpdate'));
//WP 3.0+
add_filter('transient_update_plugins', array(&$this, 'injectUpdate'));
//WP 2.8+
//Set up the periodic update checks
$cronHook = 'check_plugin_updates-' . $this->slug;
if ($this->checkPeriod > 0) {
//Trigger the check via Cron
add_filter('cron_schedules', array(&$this, '_addCustomSchedule'));
if (!wp_next_scheduled($cronHook) && !defined('WP_INSTALLING')) {
$scheduleName = 'every' . $this->checkPeriod . 'hours';
wp_schedule_event(time(), $scheduleName, $cronHook);
}
add_action($cronHook, array(&$this, 'checkForUpdates'));
//In case Cron is disabled or unreliable, we also manually trigger
//the periodic checks while the user is browsing the Dashboard.
add_action('admin_init', array(&$this, 'maybeCheckForUpdates'));
} else {
//Periodic checks are disabled.
wp_clear_scheduled_hook($cronHook);
}
//Add action for extra notifications
add_action('in_plugin_update_message-' . $this->pluginFile, array(&$this, 'maybeInjectUpgradeNotice'), 10, 2);
}
示例12: registerCronTask
/**
* Register a cron task
* @param string $cronActionName The name of the action that will be registered with wp-cron
* @param string $callback The function to register with wp-cron
* @param string $interval can only be one of the following: hourly, daily and twicedaily if no other custom intervals are registered. Defaults to daily
* @return void
*/
public static function registerCronTask($cronActionName, $callback, $interval = 'daily')
{
if (!is_callable($callback)) {
return;
}
// if cron disabled -> run callback
if (!self::canRegisterCronTask()) {
self::registerTask($callback);
return;
}
$interval = strtolower($interval);
if (empty($interval)) {
$interval = 'daily';
} else {
// check to see if the time interval is valid
$timeIntervals = wp_get_schedules();
if (!array_key_exists($interval, $timeIntervals)) {
$interval = 'daily';
}
}
// avoid duplicate crons
add_action($cronActionName, $callback);
if (!wp_next_scheduled($cronActionName)) {
wp_schedule_event(time(), $interval, $cronActionName);
array_push(self::$_cronTasks, $cronActionName);
}
}
示例13: hook
/**
* Add hooks.
*/
public function hook()
{
if (!wp_next_scheduled('boxzilla_check_license_status')) {
wp_schedule_event(time(), 'daily', 'boxzilla_check_license_status');
}
add_action('boxzilla_check_license_status', array($this, 'run'));
}
示例14: fp_rac_cron_job_setting_savings
public static function fp_rac_cron_job_setting_savings()
{
wp_clear_scheduled_hook('rac_cron_job');
if (wp_next_scheduled('rac_cron_job') == false) {
wp_schedule_event(time(), 'xhourly', 'rac_cron_job');
}
}
示例15: cbrobot_create_cronjob
function cbrobot_create_cronjob()
{
$options = unserialize(get_option("cbrobot_options"));
if (!wp_next_scheduled('cbrobot_job_event')) {
wp_schedule_event(time(), $options['cbrobot_time'], 'cbrobot_job_event');
}
}