/** * Register hooks */ protected function class_init() { // Data storage add_action('init', array($this, 'register_post_type')); // Lock for post insertion, to guard against endless event creation when `wp_next_scheduled()` is misused Lock::prime_lock(self::LOCK); // Option interception add_filter('pre_option_cron', array($this, 'get_option')); add_filter('pre_update_option_cron', array($this, 'update_option'), 10, 2); }
/** * Prime the event-specific lock * * Used to ensure only one instance of a particular event, such as `wp_version_check` runs at one time * * @param $event array Event data */ private function prime_event_action_lock($event) { Lock::prime_lock($this->get_lock_key_for_event_action($event), JOB_LOCK_EXPIRY_IN_MINUTES * \MINUTE_IN_SECONDS); }