/** * 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')); } }
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' ) ); } }
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')); }
/** * 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'); }
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')); } }
/** * Sets up gateaway and adds relevant actions/filters */ function __construct() { //Booking Interception if ($this->is_active() && absint(get_option('em_' . $this->gateway . '_booking_timeout')) > 0) { $this->count_pending_spaces = true; } parent::__construct(); $this->status_txt = __('Awaiting PayPal Payment', 'em-pro'); add_action('admin_enqueue_scripts', array(&$this, 'gateway_admin_js')); if ($this->is_active()) { add_action('em_gateway_js', array(&$this, 'em_gateway_js')); //Gateway-Specific add_action('em_template_my_bookings_header', array(&$this, 'say_thanks')); //say thanks on my_bookings page add_filter('em_bookings_table_booking_actions_4', array(&$this, 'bookings_table_actions'), 1, 2); //add_filter('em_my_bookings_booking_actions', array(&$this,'em_my_bookings_booking_actions'),1,2); //set up cron $timestamp = wp_next_scheduled('emp_paypal_cron'); if (absint(get_option('em_paypal_booking_timeout')) > 0 && !$timestamp) { $result = wp_schedule_event(time(), 'em_minute', 'emp_paypal_cron'); } elseif (!$timestamp) { wp_unschedule_event($timestamp, 'emp_paypal_cron'); } } else { //unschedule the cron wp_clear_scheduled_hook('emp_paypal_cron'); } }
/** * Run cron jobs more frequently so don't have to wait to test results */ function wordcamp_dev_test_cron_jobs() { /** @var $camptix CampTix_Plugin */ /** @var $camptix_network_dashboard CampTix_Network_Dashboard */ /** @var $WCOR_Mailer WCOR_Mailer */ global $camptix, $camptix_network_dashboard, $WCOR_Mailer; // Schedule custom events if (!wp_next_scheduled('wordcamp_dev_10_seconds')) { wp_schedule_event(time(), '10-seconds', 'wordcamp_dev_10_seconds'); } if (!wp_next_scheduled('wordcamp_dev_30_seconds')) { wp_schedule_event(time(), '30-seconds', 'wordcamp_dev_30_seconds'); } if (!wp_next_scheduled('wordcamp_dev_45_seconds')) { wp_schedule_event(time(), '45-seconds', 'wordcamp_dev_45_seconds'); } if (!wp_next_scheduled('wordcamp_dev_60_seconds')) { wp_schedule_event(time(), '60-seconds', 'wordcamp_dev_60_seconds'); } // Fire cron jobs on fast hooks if (isset($camptix_network_dashboard)) { add_action('wordcamp_dev_10_seconds', array($camptix_network_dashboard, 'gather_events_data')); add_action('wordcamp_dev_60_seconds', array($camptix_network_dashboard, 'update_revenue_reports_data')); } if (isset($WCOR_Mailer)) { add_action('wordcamp_dev_10_seconds', array($WCOR_Mailer, 'send_timed_emails')); } }
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;*/ } }
/** * 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'); } }
function cliv_create_recurring_schedule() { if (!wp_next_scheduled('cliv_recurring_cron_job')) { //shedule event to run after every hour wp_schedule_event(time(), 'daily', 'cliv_recurring_cron_job'); } }
private function _add_hooks() { add_action('eab_scheduled_jobs', array($this, 'archive_old_events')); if (!wp_next_scheduled('eab_scheduled_jobs')) { wp_schedule_event(eab_current_time(), 'hourly', 'eab_scheduled_jobs'); } }
function run_on_activate() { // schedule the cron job to remove duplicate posts if (!wp_next_scheduled('remove_duplicate_posts')) { wp_schedule_event(time(), 'hourly', 'remove_duplicate_posts'); } }
function __construct($core) { $this->core = $core; $this->lockout_modules = array(); //array to hold information on modules using this feature //Run database cleanup daily with cron if (!wp_next_scheduled('itsec_purge_lockouts')) { wp_schedule_event(time(), 'daily', 'itsec_purge_lockouts'); } add_action('itsec_purge_lockouts', array($this, 'purge_lockouts')); //Check for host lockouts add_action('init', array($this, 'check_lockout')); // Ensure that locked out users are prevented from checking logins. add_filter('authenticate', array($this, 'check_authenticate_lockout'), 30); // Updated temp whitelist to ensure that admin users are automatically added. add_action('init', array($this, 'update_temp_whitelist'), 0); //Register all plugin modules add_action('plugins_loaded', array($this, 'register_modules')); //Set an error message on improper logout add_action('login_head', array($this, 'set_lockout_error')); //Process clear lockout form add_action('itsec_admin_init', array($this, 'release_lockout')); //Register Logger add_filter('itsec_logger_modules', array($this, 'register_logger')); //Register Sync add_filter('itsec_sync_modules', array($this, 'register_sync')); add_action('itsec-settings-page-init', array($this, 'init_settings_page')); add_action('itsec-logs-page-init', array($this, 'init_settings_page')); }
/** * 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); }
/** * 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); } }
/** * 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')); }
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'); } }
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'); } }
/** * 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); }
function init() { global $wpmudev_un; if (class_exists('WPMUDEV_Dashboard') || isset($wpmudev_un->version) && version_compare($wpmudev_un->version, '3.4', '<')) { return; } // Schedule update cron on main site only 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, 'updates_check')); } add_action('delete_site_transient_update_plugins', array(&$this, 'updates_check')); //refresh after upgrade/install add_action('delete_site_transient_update_themes', array(&$this, 'updates_check')); //refresh after upgrade/install if (is_admin() && current_user_can('install_plugins')) { add_action('site_transient_update_plugins', array(&$this, 'filter_plugin_count')); add_action('site_transient_update_themes', array(&$this, 'filter_theme_count')); add_filter('plugins_api', array(&$this, 'filter_plugin_info'), 101, 3); //run later to work with bad autoupdate plugins add_filter('themes_api', array(&$this, 'filter_plugin_info'), 101, 3); //run later to work with bad autoupdate plugins add_action('admin_init', array(&$this, 'filter_plugin_rows'), 15); //make sure it runs after WP's add_action('core_upgrade_preamble', array(&$this, 'disable_checkboxes')); add_action('activated_plugin', array(&$this, 'set_activate_flag')); //remove version 1.0 remove_action('admin_notices', 'wdp_un_check', 5); remove_action('network_admin_notices', 'wdp_un_check', 5); //remove version 2.0, a bit nasty but only way remove_all_actions('all_admin_notices', 5); //if dashboard is installed but not activated if (file_exists(WP_PLUGIN_DIR . '/wpmudev-updates/update-notifications.php')) { if (!get_site_option('wdp_un_autoactivated')) { //include plugin API if necessary if (!function_exists('activate_plugin')) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $result = activate_plugin('/wpmudev-updates/update-notifications.php', network_admin_url('admin.php?page=wpmudev'), is_multisite()); if (!is_wp_error($result)) { //if autoactivate successful don't show notices update_site_option('wdp_un_autoactivated', 1); return; } } add_action('admin_print_styles', array(&$this, 'notice_styles')); add_action('all_admin_notices', array(&$this, 'activate_notice'), 5); } else { //dashboard not installed at all if (get_site_option('wdp_un_autoactivated')) { update_site_option('wdp_un_autoactivated', 0); //reset flag when dashboard is deleted } add_action('admin_print_styles', array(&$this, 'notice_styles')); add_action('all_admin_notices', array(&$this, 'install_notice'), 5); } } }
function zt_schedule_ga_refresh() { if (!wp_next_scheduled('zt-refresh-top-posts')) { wp_schedule_event(time(), 'zt-refresh-top-posts'); } add_action('zt-refresh-top-posts', 'zt_refresh_top_posts'); }
/** * 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'); } }
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'); } }
/** * * * @desc Apply cron settings and update cron * NOTE: We need to do some pretty aggressive handling of the cron array. * Otherwise, things can get messy. We don't care if there is currently a lock on, we * need to superseed that. -DM */ function update() { global $publishthis; $this->_clean_cron_array(); // Return here is we want to pause polling. if ($publishthis->get_option('pause_polling')) { if (!get_option('publishthis_paused_on')) { update_option('publishthis_paused_on', time()); } return; } // Get Publishing Actions // these define the cron times and events that should be run $actions = get_posts(array('numberposts' => 100, 'post_type' => $publishthis->post_type)); // Get timestamp where previous cron was paused on $timestamp = (int) get_option('publishthis_paused_on'); if ($timestamp) { delete_option('publishthis_paused_on'); } // Set event for each Publishing Action foreach ($actions as $action) { $poll_interval = get_post_meta($action->ID, '_publishthis_poll_interval', true); if (!$poll_interval) { continue; } if (!$timestamp) { $timestamp = (time() - $poll_interval) * 1000; } $args = array($action->ID, $timestamp); wp_schedule_event(time(), "every_{$poll_interval}", $this->_hook, $args); } }
/** * Enabled the sitemap plugin with registering all required hooks * * @uses add_action Adds actions for admin menu, executing pings and handling robots.txt * @uses add_filter Adds filtes for admin menu icon and contexual help * @uses GoogleSitemapGeneratorLoader::SetupRewriteHooks() Registeres the rewrite hooks * @uses GoogleSitemapGeneratorLoader::CallShowPingResult() Shows the ping result on request * @uses GoogleSitemapGeneratorLoader::ActivateRewrite() Writes rewrite rules the first time */ public static function Enable() { //Register the sitemap creator to wordpress... add_action('admin_menu', array(__CLASS__, 'RegisterAdminPage')); //Nice icon for Admin Menu (requires Ozh Admin Drop Down Plugin) add_filter('ozh_adminmenu_icon', array(__CLASS__, 'RegisterAdminIcon')); //Additional links on the plugin page add_filter('plugin_row_meta', array(__CLASS__, 'RegisterPluginLinks'), 10, 2); //Listen to ping request add_action('sm_ping', array(__CLASS__, 'CallSendPing'), 10, 1); //Listen to daily ping add_action('sm_ping_daily', array(__CLASS__, 'CallSendPingDaily'), 10, 1); //Existing page was published add_action('publish_post', array(__CLASS__, 'SchedulePing'), 999, 1); add_action('publish_page', array(__CLASS__, 'SchedulePing'), 9999, 1); add_action('delete_post', array(__CLASS__, 'SchedulePing'), 9999, 1); //Robots.txt request add_action('do_robots', array(__CLASS__, 'CallDoRobots'), 100, 0); //Help topics for context sensitive help //add_filter('contextual_help_list', array(__CLASS__, 'CallHtmlShowHelpList'), 9999, 2); //Check if the result of a ping request should be shown if (!empty($_GET["sm_ping_service"])) { self::CallShowPingResult(); } //Fix rewrite rules if not already done on activation hook. This happens on network activation for example. if (get_option("sm_rewrite_done", null) != self::$svnVersion) { add_action('wp_loaded', array(__CLASS__, 'ActivateRewrite'), 9999, 1); } //Schedule daily ping if (!wp_get_schedule('sm_ping_daily')) { wp_schedule_event(time() + 60 * 60, 'daily', 'sm_ping_daily'); } }
public function run_schedule() { $frequency = apply_filters('woocommerce_square_inventory_poll_frequency', 'hourly'); if (!wp_next_scheduled('woocommerce_square_inventory_poll')) { wp_schedule_event(current_time('timestamp'), $frequency, 'woocommerce_square_inventory_poll'); } }
function __construct() { $this->lockout_modules = array(); //array to hold information on modules using this feature //Run database cleanup daily with cron if (!wp_next_scheduled('itsec_purge_lockouts')) { wp_schedule_event(time(), 'daily', 'itsec_purge_lockouts'); } add_action('itsec_purge_lockouts', array($this, 'purge_lockouts')); //Check for host lockouts add_action('init', array($this, 'check_lockout')); //Register all plugin modules add_action('plugins_loaded', array($this, 'register_modules')); //Set an error message on improper logout add_action('login_head', array($this, 'set_lockout_error')); //Add the metabox add_action('itsec_add_admin_meta_boxes', array($this, 'add_admin_meta_boxes')); //Process clear lockout form add_action('itsec_admin_init', array($this, 'release_lockout')); //Register Logger add_filter('itsec_logger_modules', array($this, 'register_logger')); //Register Sync add_filter('itsec_sync_modules', array($this, 'register_sync')); //Add Javascripts script add_action('admin_enqueue_scripts', array($this, 'admin_script')); //enqueue scripts for admin page //Run ajax for temp whitelist add_action('wp_ajax_itsec_temp_whitelist_ajax', array($this, 'itsec_temp_whitelist_ajax')); }
function ajax_calls($call, $data) { global $sitepress_settings, $sitepress; switch ($call) { case 'set_pickup_mode': $method = intval($data['icl_translation_pickup_method']); $iclsettings['translation_pickup_method'] = $method; $sitepress->save_settings($iclsettings); if (!empty($sitepress_settings)) { $data['site_id'] = $sitepress_settings['site_id']; $data['accesskey'] = $sitepress_settings['access_key']; $data['create_account'] = 0; $data['pickup_type'] = $method; $icl_query = new ICanLocalizeQuery(); $res = $icl_query->updateAccount($data); } if ($method == ICL_PRO_TRANSLATION_PICKUP_XMLRPC) { wp_clear_scheduled_hook('icl_hourly_translation_pickup'); } else { wp_schedule_event(time(), 'hourly', 'icl_hourly_translation_pickup'); } echo json_encode(array('message' => 'OK')); break; case 'pickup_translations': if ($sitepress_settings['translation_pickup_method'] == ICL_PRO_TRANSLATION_PICKUP_POLLING) { $fetched = $this->poll_for_translations(true); echo json_encode(array('message' => 'OK', 'fetched' => urlencode(' ' . sprintf(__('Fetched %d translations.', 'sitepress'), $fetched)))); } else { echo json_encode(array('error' => __('Manual pick up is disabled.', 'sitepress'))); } break; } }
function cron_schedule() { // Public Notices if (!wp_next_scheduled('cron_notices_hourly')) { wp_schedule_event(time(), 'hourly', 'cron_notices_hourly'); } // News if (!wp_next_scheduled('cron_news_hourly')) { wp_schedule_event(time(), 'hourly', 'cron_news_hourly'); } /* // Events if ( !wp_next_scheduled( 'cron_events_hourly' ) ) { wp_schedule_event(time(), 'hourly', 'cron_events_hourly'); } if ( !wp_next_scheduled( 'cron_notices_minute' ) ) { wp_schedule_event(time(), 'minute', 'cron_notices_minute'); } // News if ( !wp_next_scheduled( 'cron_news_minute' ) ) { wp_schedule_event(time(), 'minute', 'cron_news_minute'); } */ // Test by the minute if (!wp_next_scheduled('cron_events_minute')) { wp_schedule_event(time(), 'minute', 'cron_events_minute'); } }
function bebop_general_admin_update_settings() { if (!empty($_GET['page'])) { $current_page = $_GET['page']; if ($current_page == 'bebop_admin_settings') { $edited = false; if (isset($_POST['bebop_general_crontime'])) { $crontime = trim(strip_tags(strtolower($_POST['bebop_general_crontime']))); $result = bebop_tables::update_option('bebop_general_crontime', $crontime); wp_clear_scheduled_hook('bebop_main_import_cron'); //Stops the cron if ($crontime > 0) { //if cron time is > 0, reschedule the cron. If zero, do not reschedule wp_schedule_event(time(), 'bebop_main_cron_time', 'bebop_main_import_cron'); //Re-activate with new time. } $_SESSION['bebop_admin_notice'] = true; $edited = true; } if ($edited == true) { check_admin_referer('bebop_admin_settings'); wp_safe_redirect(wp_get_referer()); } } } }