/**
 * @since 0.9
 * @deprecated 1.3
 */
function ctfw_edd_license_auto_check_deactivation()
{
    _deprecated_function(__FUNCTION__, '1.3', 'ctfw_edd_license_auto_sync()');
    ctfw_edd_license_sync();
}
/**
 * Sync remote/local status automatically
 *
 * Check for remote status change periodically on relevant pages: Dashboard, Theme License, Themes, Updates
 * Check in real-time on Theme License page so if remote change was made, they see it immediately as if in account.
 *
 * Once daily is enough to keep notice on dashboard and updates up to date without hammering remote server.
 *
 * @since 0.9
 */
function ctfw_edd_license_auto_sync()
{
    // Theme supports this?
    if (!current_theme_supports('ctfw-edd-license')) {
        return;
    }
    // Admin only
    if (!is_admin()) {
        return;
    }
    // Theme stores local option?
    if (!ctfw_edd_license_config('options_page')) {
        return;
    }
    // Periodically in relevant areas or always on Theme License page
    $screen = get_current_screen();
    if (in_array($screen->base, array('dashboard', 'appearance_page_theme-license', 'themes', 'update-core'))) {
        // Has this been checked in last day or is it theme license page?
        if (!get_transient('ctfw_edd_license_auto_sync') || 'appearance_page_theme-license' == $screen->base) {
            // Check remote status and sync both ways if necessary
            ctfw_edd_license_sync();
            // Set transient to prevent check until next day
            // Once per day is enough to keep notice on dashboard and updates pages without hammering remote server
            set_transient('ctfw_edd_license_auto_sync', true, DAY_IN_SECONDS);
        }
    }
}