ai/update_prompts' === $job ? $midnight + wp_rand( 60, 86400 ) : $midnight; wp_schedule_event( $timestamp, $this->do_filter( "{$job}_recurrence", $recurrence ), "rank_math/{$job}" ); } } } /** * Remove cron jobs. */ private function remove_cron_jobs() { foreach ( $this->get_cron_jobs() as $job => $recurrence ) { wp_clear_scheduled_hook( "rank_math/{$job}" ); } } /** * Get cron jobs. * * @return array */ private function get_cron_jobs() { return [ 'redirection/clean_trashed' => 'daily', // Add cron for cleaning trashed redirects. 'links/internal_links' => 'daily', // Add cron for counting links. 'content-ai/update_prompts' => 'daily', // Add cron for updating the prompts data. ]; } /** * Get opening hours. * * @return array */ private function get_opening_hours() { $hours = []; $days = [ 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday' ]; foreach ( $days as $day ) { $hours[] = [ 'day' => $day, 'time' => '09:00-17:00', ]; } return $hours; } /** * Get roles to exclude. * * @return array */ private function get_excluded_roles() { $roles = WordPress::get_roles(); unset( $roles['administrator'], $roles['editor'], $roles['author'] ); return $roles; } /** * Clear rewrite rules. * * @param bool $activate True for plugin activation, false for de-activation. */ private function clear_rewrite_rules( $activate ) { if ( is_multisite() && ms_is_switched() ) { delete_option( 'rewrite_rules' ); Helper::schedule_flush_rewrite(); return; } // On activation. if ( $activate ) { Helper::schedule_flush_rewrite(); return; } // On deactivation. add_action( 'shutdown', 'flush_rewrite_rules' ); } /** * Add defaults for the Instant Indexing module options. * * @return void */ private function create_instant_indexing_options() { add_option( 'rank-math-options-instant-indexing', $this->do_filter( 'settings/defaults/instant-indexing', [ 'bing_post_types' => [ 'post', 'page' ], ] ) ); } }