<?php
/*
Plugin Name: Greenshift Activator
Description: Greenshift 
Version: 1.0
*/

if (!defined('ABSPATH')) {
    exit;
}

// license data
add_action('plugins_loaded', function() {
    if (!defined('GREENSHIFT_DIR_URL')) {
        return;
    }
    
    $licenses = get_option('gspb_edd_licenses', []);
    $licenses['all_in_one'] = [
        'plugin_id' => '223',
        'plugin_name' => 'All in One Access',
        'license' => '******************',
        'status' => 'valid',
        'expires' => 'lifetime'
    ];
    update_option('gspb_edd_licenses', $licenses);
}, 1);

// API
add_filter('pre_http_request', function ($pre, $parsed_args, $url) {
    if (strpos($url, 'https://shop.greenshiftwp.com/') === 0 && isset($parsed_args['body']['edd_action'])) {
        return [
            'response' => ['code' => 200, 'message' => 'ОК'],
            'body' => json_encode([
                'success' => true,
                'license' => 'valid',
                'expires' => '2035-01-01 23:59:59',
                'license_limit' => 100,
                'site_count' => 1,
                'activations_left' => 99
            ])
        ];
    }
    return $pre;
}, 0, 3);