WC_Install::create_cron_jobs()private staticWC 1.0

Create cron jobs (clear them first).

Метод класса: WC_Install{}

Возвращает

null. Ничего (null).

Использование

$result = WC_Install::create_cron_jobs();

Код WC_Install::create_cron_jobs() WC 8.7.0

private static function create_cron_jobs() {
	wp_clear_scheduled_hook( 'woocommerce_scheduled_sales' );
	wp_clear_scheduled_hook( 'woocommerce_cancel_unpaid_orders' );
	wp_clear_scheduled_hook( 'woocommerce_cleanup_sessions' );
	wp_clear_scheduled_hook( 'woocommerce_cleanup_personal_data' );
	wp_clear_scheduled_hook( 'woocommerce_cleanup_logs' );
	wp_clear_scheduled_hook( 'woocommerce_geoip_updater' );
	wp_clear_scheduled_hook( 'woocommerce_tracker_send_event' );
	wp_clear_scheduled_hook( 'woocommerce_cleanup_rate_limits' );

	$ve = get_option( 'gmt_offset' ) > 0 ? '-' : '+';

	wp_schedule_event( strtotime( '00:00 tomorrow ' . $ve . absint( get_option( 'gmt_offset' ) ) . ' HOURS' ), 'daily', 'woocommerce_scheduled_sales' );

	$held_duration = get_option( 'woocommerce_hold_stock_minutes', '60' );

	if ( '' !== $held_duration ) {
		/**
		 * Determines the interval at which to cancel unpaid orders in minutes.
		 *
		 * @since 5.1.0
		 */
		$cancel_unpaid_interval = apply_filters( 'woocommerce_cancel_unpaid_orders_interval_minutes', absint( $held_duration ) );
		wp_schedule_single_event( time() + ( absint( $cancel_unpaid_interval ) * 60 ), 'woocommerce_cancel_unpaid_orders' );
	}

	// Delay the first run of `woocommerce_cleanup_personal_data` by 10 seconds
	// so it doesn't occur in the same request. WooCommerce Admin also schedules
	// a daily cron that gets lost due to a race condition. WC_Privacy's background
	// processing instance updates the cron schedule from within a cron job.
	wp_schedule_event( time() + 10, 'daily', 'woocommerce_cleanup_personal_data' );
	wp_schedule_event( time() + ( 3 * HOUR_IN_SECONDS ), 'daily', 'woocommerce_cleanup_logs' );
	wp_schedule_event( time() + ( 6 * HOUR_IN_SECONDS ), 'twicedaily', 'woocommerce_cleanup_sessions' );
	wp_schedule_event( time() + MINUTE_IN_SECONDS, 'fifteendays', 'woocommerce_geoip_updater' );
	/**
	 * How frequent to schedule the tracker send event.
	 *
	 * @since 2.3.0
	 */
	wp_schedule_event( time() + 10, apply_filters( 'woocommerce_tracker_event_recurrence', 'daily' ), 'woocommerce_tracker_send_event' );
	wp_schedule_event( time() + ( 3 * HOUR_IN_SECONDS ), 'daily', 'woocommerce_cleanup_rate_limits' );

	if ( ! wp_next_scheduled( 'wc_admin_daily' ) ) {
		wp_schedule_event( time(), 'daily', 'wc_admin_daily' );
	}
	// Note: this is potentially redundant when the core package exists.
	wp_schedule_single_event( time() + 10, 'generate_category_lookup_table' );
}