<?php

if ( ! defined( 'ABSPATH' ) ) {
	// Exit if accessed directly.
	exit;
}

if ( ! function_exists( 'qode_optimizer_plugin_updater' ) ) {

	function qode_optimizer_plugin_updater() {
		// To support auto-updates, this needs to run during the wp_version_check cron job for privileged users.
		$doing_cron = defined( 'DOING_CRON' ) && DOING_CRON;
		if ( ! current_user_can( 'manage_options' ) && ! $doing_cron ) {
			return;
		}

		// setup the updater.
		$edd_updater = new Qode_Optimizer_Updater(
			QODE_OPTIMIZER_STORE_URL,
			QODE_OPTIMIZER_PLUGIN_BASE_FILE,
			array(
				'version' => QODE_OPTIMIZER_VERSION,
				'item_id' => QODE_OPTIMIZER_ITEM_ID,
				'author'  => QODE_OPTIMIZER_ITEM_AUTHOR,
				'beta'    => false,
			)
		);
	}

	add_action( 'init', 'qode_optimizer_plugin_updater' );
}
