Plugin Directory

Changeset 3206591


Ignore:
Timestamp:
12/11/2024 09:00:59 PM (15 months ago)
Author:
ignitionwp
Message:

Added support for premium Enterprise license

Location:
ignitiondeck/trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • ignitiondeck/trunk/idf-functions.php

    r3142505 r3206591  
    951951}
    952952
     953/**
     954 * Get the unified download list for all license types.
     955 *
     956 * @return array Array of license types and their corresponding download IDs
     957 */
     958function idf_get_download_list() {
     959    return array(
     960        // Enterprise licenses
     961        '30' => '83885',    // Enterprise Annual
     962        'ide' => '83885',   // Enterprise Annual (legacy)
     963        'ide_premium' => '138068', // Enterprise Premium
     964        // IMCP licenses
     965        'imcp_monthly' => '196344',
     966        'imcp_annual' => '196335',
     967        // Echelon licenses
     968        '29' => '83887',    // Echelon Annual
     969        'idc' => '83887',   // Echelon Annual (legacy)
     970        // Free
     971        '1' => '1',
     972        'free' => '1'
     973    );
     974}
     975
     976/**
     977 * Get the list of declined license statuses.
     978 *
     979 * @return array Array of declined license statuses
     980 */
     981function idf_get_declined_license_statuses() {
     982    return array(
     983        'invalid',
     984        'disabled',
     985        'expired',
     986    );
     987}
     988
     989/**
     990 * Get the list of declined license error codes.
     991 *
     992 * @return array Array of declined license error codes
     993 */
     994function idf_get_declined_license_error_codes() {
     995    return array(
     996        'expired',
     997        'disabled',
     998        'missing',
     999        'missing_url',
     1000        'no_activations_left',
     1001        'license_not_activable',
     1002        'invalid_item_id',
     1003        'key_mismatch',
     1004        'item_name_mismatch',
     1005        'blank',
     1006    );
     1007}
     1008
     1009/**
     1010 * Update license state based on the validated license type.
     1011 *
     1012 * @param string $license_type The validated license type
     1013 * @return void
     1014 */
     1015function idf_update_license_state($license_type) {
     1016    if (is_bool($license_type)) {
     1017        return;
     1018    }
     1019
     1020    // Enterprise and IMCP licenses
     1021    if (in_array($license_type, array('30', 'ide', 'ide_premium', 'imcp_monthly', 'imcp_annual'))) {
     1022        $is_pro = 1;
     1023        $is_idc_licensed = 1;
     1024        $is_basic = 0;
     1025    }
     1026    // Echelon licenses
     1027    else if (in_array($license_type, array('29', 'idc'))) {
     1028        $is_idc_licensed = 1;
     1029        $is_basic = 1;
     1030        $is_pro = 0;
     1031    }
     1032    // Free or unknown
     1033    else {
     1034        $is_pro = $is_idc_licensed = $is_basic = 0;
     1035    }
     1036
     1037    // Update all options and transients
     1038    update_option('is_id_pro', $is_pro);
     1039    update_option('is_idc_licensed', $is_idc_licensed);
     1040    update_option('is_id_basic', $is_basic);
     1041    set_transient('is_id_pro', $is_pro);
     1042    set_transient('is_idc_licensed', $is_idc_licensed);
     1043    set_transient('is_id_basic', $is_basic);
     1044   
     1045    // Store the exact license type for reference
     1046    update_option('idf_license_type', $license_type);
     1047}
     1048
     1049/**
     1050 * Process API response and update license expiry.
     1051 *
     1052 * @param array $response_array The API response array
     1053 * @return void
     1054 */
     1055function idf_process_license_response($response_array) {
     1056    if (!empty($response_array['expires'])) {
     1057        update_option('license_expiry', $response_array['expires']);
     1058    }
     1059    if (!empty($response_array['item_id'])) {
     1060        update_option('license_item_id', $response_array['item_id']);
     1061    }
     1062    if (!empty($response_array['license_post_id'])) {
     1063        update_option('license_post_id', $response_array['license_post_id']);
     1064    }
     1065}
     1066
    9531067?>
  • ignitiondeck/trunk/idf-idc.php

    r3134431 r3206591  
    5757function idf_idc_validate_key($key) {
    5858    $id_account = get_option('id_account');
    59     $download_list = array(
    60         '30' => '83885', //Enterprise Annual
    61         '29' => '83887', //Echelon Annual
    62         '1' => '1'
    63     );
    64 
    65     $declined_license_statuses = array(
    66         'invalid',
    67         'disabled',
    68         'expired',
    69     );
    70     $declined_license_error_codes = array(
    71         'expired',
    72         'disabled',
    73         'missing',
    74         'missing_url',
    75         'no_activations_left',
    76         'license_not_activable',
    77         'invalid_item_id',
    78         'key_mismatch',
    79         'item_name_mismatch',
    80         'blank',
    81     );
     59    $download_list = idf_get_download_list();
     60    $declined_license_statuses = idf_get_declined_license_statuses();
     61    $declined_license_error_codes = idf_get_declined_license_error_codes();
    8262
    8363    $api_url = 'https://members.ignitiondeck.com/';
     
    142122    } elseif ($response_array['success'] == 1 && $response_array['license'] == 'valid') {
    143123        $response_array = apply_filters('edd_product_ids', $response_array);
    144         update_option('license_expiry', $response_array['expires']);
     124        idf_process_license_response($response_array);
    145125        echo wp_kses_post(edd_api_notice('valid'));
    146126        return array_search($response_array['item_id'], $download_list);
     
    166146 */
    167147function idc_license_update($idc_license_key) {
    168     $valid = 0;
    169148    $general = get_option('md_receipt_settings');
    170149    $general = maybe_unserialize($general);
    171150    $general['license_key'] = $idc_license_key;
    172151    update_option('md_receipt_settings', $general);
     152   
    173153    $validate = idf_idc_validate_key($idc_license_key);
    174 
    175     if ( ! is_bool( $validate ) ) {
    176         switch ($validate) {
    177             case '30':
    178                 $is_pro = 1;
    179                 $is_idc_licensed = 1;
    180                 $is_basic = 0;
    181                 break;
    182             case '29':
    183                 $is_idc_licensed = $is_basic = 1;
    184                 $is_pro = 0;
    185                 break;
    186             default:
    187                 $is_pro = $is_idc_licensed = $is_basic = 0;
    188                 break;
    189         }
    190         #devnote we can set transients from the option? Can we push these to idcf/idc php?
     154    if (!is_bool($validate)) {
    191155        update_option('idcf_updated', true);
    192 
    193         update_option('is_id_pro', $is_pro);
    194         update_option('is_idc_licensed', $is_idc_licensed);
    195         update_option('is_id_basic', $is_basic);
    196         set_transient('is_id_pro', $is_pro);
    197         set_transient('is_idc_licensed', $is_idc_licensed);
    198         set_transient('is_id_basic', $is_basic);
     156        idf_update_license_state($validate);
    199157    }
    200158}
  • ignitiondeck/trunk/idf-idcf.php

    r3134431 r3206591  
    1313function idf_idcf_validate_license($key) {
    1414    $id_account = get_option('id_account');
    15     $download_list = array(
    16         '30' => '83885', // Enterprise Annual
    17         '29' => '83887', // Echelon Annual
    18         '1'  => '1'
    19     );
    20 
    21     $declined_license_statuses = array(
    22         'invalid',
    23         'disabled',
    24         'expired',
    25     );
    26     $declined_license_error_codes = array(
    27         'expired',
    28         'disabled',
    29         'missing',
    30         'missing_url',
    31         'no_activations_left',
    32         'license_not_activable',
    33         'invalid_item_id',
    34         'key_mismatch',
    35         'item_name_mismatch',
    36         'blank',
    37     );
     15    $download_list = idf_get_download_list();
     16    $declined_license_statuses = idf_get_declined_license_statuses();
     17    $declined_license_error_codes = idf_get_declined_license_error_codes();
    3818
    3919    $api_url = 'https://members.ignitiondeck.com/';
     
    10989    } elseif ($response_array['success'] == 1 && $response_array['license'] == 'valid') {
    11090        $response_array = apply_filters('edd_product_ids', $response_array);
    111         update_option('license_expiry', $response_array['expires']);
    112         update_option('license_item_id', $response_array['item_id']);
    113         if (!empty($response_array['license_post_id'])) {
    114             update_option('license_post_id', $response_array['license_post_id']);
    115         }
     91        idf_process_license_response($response_array);
    11692        echo wp_kses_post(edd_api_notice('valid'));
    117         return array_search($response_array['item_id'], $download_list);
     93       
     94        // Check for both numeric and string keys
     95        $item_id = $response_array['item_id'];
     96        $license_type = array_search($item_id, $download_list);
     97       
     98        // If not found, try to match the item_id directly
     99        if ($license_type === false) {
     100            $license_type = isset($download_list[$item_id]) ? $item_id : false;
     101        }
     102       
     103        return $license_type;
    118104    } else {
    119105        if (isset($response_array['error'])) {
     
    206192 */
    207193function idcf_license_update($license_key) {
    208     $is_pro = 0;
    209     $is_basic = 0;
    210     update_option('id_license_key', $license_key);
    211     $validate = idf_idcf_validate_license($license_key);
    212 
    213     if ( ! is_bool( $validate ) ) {
    214         switch ($validate) {
    215             case '30':
    216                 $is_pro = 1;
    217                 $is_idc_licensed = 1;
    218                 $is_basic = 0;
    219                 break;
    220             case '29':
    221                 $is_idc_licensed = $is_basic = 1;
    222                 $is_pro = 0;
    223                 break;
    224             default:
    225                 $is_pro = $is_idc_licensed = $is_basic = 0;
    226                 break;
    227         }
    228         #devnote we can set transients from the option? Can we push these to idcf/idc php?
    229         update_option('is_id_pro', $is_pro);
    230         update_option('is_idc_licensed', $is_idc_licensed);
    231         update_option('is_id_basic', $is_basic);
    232         set_transient('is_id_pro', $is_pro);
    233         set_transient('is_idc_licensed', $is_idc_licensed);
    234         set_transient('is_id_basic', $is_basic);
    235     }
     194    update_option('id_license_key', $license_key);
     195    $validate = idf_idcf_validate_license($license_key);
     196    if (!is_bool($validate)) {
     197        idf_update_license_state($validate);
     198    }
    236199}
    237200
  • ignitiondeck/trunk/idf-update.php

    r3154744 r3206591  
    2727    update_option('id_account', $id_account);
    2828    $license_level = idf_id_validate_account($id_account);
    29 
    30     if ( ! is_bool( $license_level ) ) {
    31         switch ($license_level) {
    32             case 'ide':
    33             case 'imcp_monthly':
    34             case 'imcp_annual':
    35                 $is_pro = 1;
    36                 $is_idc_licensed = 1;
    37                 $is_basic = 0;
    38                 break;
    39             case 'idc':
    40                 $is_idc_licensed = $is_basic = 1;
    41                 $is_pro = 0;
    42                 break;
    43             default:
    44                 $is_pro = $is_idc_licensed = $is_basic = 0;
    45                 break;
    46         }
    47         #devnote we can set transients from the option? Can we push these to idcf/idc php?
    48         update_option('is_id_pro', $is_pro);
    49         update_option('is_idc_licensed', $is_idc_licensed);
    50         update_option('is_id_basic', $is_basic);
    51         set_transient('is_id_pro', $is_pro);
    52         set_transient('is_idc_licensed', $is_idc_licensed);
    53         set_transient('is_id_basic', $is_basic);
     29    if (!is_bool($license_level)) {
     30        idf_update_license_state($license_level);
    5431    }
    5532}
     
    6441 */
    6542function idf_id_validate_account($id_account) {
    66     $download_list = array(
    67         'ide'          => '83885', // Enterprise Annual
    68         'idc'          => '83887', // Echelon Annual
    69         'imcp_monthly' => '196344',
    70         'imcp_annual'  => '196335',
    71         'free'         => '1'
    72     );
    73 
    74     $declined_license_statuses = array(
    75         'invalid',
    76         'disabled',
    77         'expired',
    78     );
    79 
    80     $declined_license_error_codes = array(
    81         'expired',
    82         'disabled',
    83         'missing',
    84         'missing_url',
    85         'no_activations_left',
    86         'license_not_activable',
    87         'invalid_item_id',
    88         'key_mismatch',
    89         'item_name_mismatch',
    90         'blank',
    91     );
     43    $download_list = idf_get_download_list();
     44    $declined_license_statuses = idf_get_declined_license_statuses();
     45    $declined_license_error_codes = idf_get_declined_license_error_codes();
    9246
    9347    // Activate License
     
    154108    } elseif ($return['success'] == 1 && $return['license'] == 'valid') {
    155109        $return = apply_filters('edd_product_ids', $return);
    156         update_option('license_expiry', $return['expires']);
     110        idf_process_license_response($return);
    157111        echo wp_kses_post(edd_api_notice('valid'));
    158112        return array_search($return['item_id'], $download_list);
  • ignitiondeck/trunk/idf.php

    r3154744 r3206591  
    88URI: https://IgnitionDeck.com
    99Description: A crowdfunding and ecommerce plugin for WordPress that helps you crowdfund, pre-order, and sell goods online.
    10 Version: 1.10.3
     10Version: 1.10.4
    1111Author: IgnitionDeck
    1212Author URI: https://IgnitionDeck.com
     
    1818require_once 'idf-globals.php';
    1919global $active_plugins, $idf_current_version;
    20 $idf_current_version = '1.10.3';
     20$idf_current_version = '1.10.4';
    2121require_once 'idf-update.php';
    2222require_once 'classes/class-idf_requirements.php';
  • ignitiondeck/trunk/languages_default/idf.pot

    r3142505 r3206591  
    33msgstr ""
    44"Project-Id-Version: IgnitionDeck Framework\n"
    5 "POT-Creation-Date: 2024-08-27 13:44-0800\n"
     5"POT-Creation-Date: 2024-11-21 13:44-0800\n"
    66"PO-Revision-Date: 2016-10-05 20:02-0400\n"
    77"Last-Translator: Ignition WP LLC <[email protected]>\n"
  • ignitiondeck/trunk/readme.txt

    r3154744 r3206591  
    44Donate link: https://www.ignitiondeck.com
    55Requires at least: 4.9
    6 Tested up to: 6.6
    7 Stable tag: 1.10.3
     6Tested up to: 6.7
     7Stable tag: 1.10.4
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    139139== Changelog ==
    140140
     141= 1.10.4 =
     142
     143* Added support for new subscription option, drop us a line at [email protected] if you'd like to learn more!
     144
    141145= 1.10.3 =
    142146
Note: See TracChangeset for help on using the changeset viewer.