Plugin Directory

Changeset 2362708


Ignore:
Timestamp:
08/17/2020 04:38:53 AM (6 years ago)
Author:
10quality
Message:

Updated to version 1.5.0

Location:
woo-license-keys/trunk
Files:
5 added
29 edited

Legend:

Unmodified
Added
Removed
  • woo-license-keys/trunk/README.txt

    r2362481 r2362708  
    77Requires PHP: 5.4
    88Tested up to: 5.5
    9 Stable tag: 1.4.1
     9Stable tag: 1.5.0
    1010License: GPLv3
    1111License URI: https://www.gnu.org/licenses/gpl-3.0.html
     
    8686== Changelog ==
    8787
     88= 1.5.0 =
     89*Release Date - 17 Aug 2020*
     90* ApiValidator customizable class.
     91* New settings that will allow to add extra data to API's response.
     92* Better integration with WooCommerce "My Account".
     93* Added hooks.
     94
    8895= 1.4.1 =
    8996*Release Date - 16 Aug 2020*
  • woo-license-keys/trunk/app/Config/app.php

    r2362481 r2362708  
    1919    ],
    2020
    21     'version' => '1.4.1',
     21    'version' => '1.5.0',
    2222
    2323    'author' => '10 Quality Studio <https://www.10quality.com/>',
     
    3939
    4040        // Enables or disables auto-enqueue of assets
    41         'enabled'       => false,
     41        'enabled'       => true,
    4242        // Assets to auto-enqueue
    43         'assets'        => [],
     43        'assets'        => [
     44            [
     45                'id'        => 'clipboard',
     46                'asset'     => 'js/clipboard.min.js',
     47                'version'   => '2.6.0',
     48                'footer'    => true,
     49                'enqueue'   => false,
     50            ],
     51            [
     52                'id'        => 'woo-license-keys',
     53                'asset'     => 'js/app.js',
     54                'dep'       => ['clipboard', 'jquery'],
     55                'footer'    => true,
     56                'enqueue'   => false,
     57            ],
     58        ],
    4459
    4560    ],
  • woo-license-keys/trunk/app/Controllers/AccountController.php

    r2362481 r2362708  
    1010use LicenseKeys\Core\ValidationException;
    1111/**
    12  * AccountController controller.
     12 * WooCommerce "My Account" related hooks.
    1313 * Handles all account related business logic.
    1414 *
     
    1818 * @license GPLv3
    1919 * @package woo-license-keys
    20  * @version 1.4.0
     20 * @version 1.5.0
    2121 */
    2222class AccountController extends Controller
     
    7373        $vars[] = self::VIEW_ENDPOINT;
    7474        return $vars;
    75     }
    76     /**
    77      * Retuns endpoint title.
    78      * @since 1.0.0
    79      *
    80      * @hook the_title
    81      *
    82      * @global object $wp_query Wordpress query string manager.
    83      *
    84      * @param string $title Current title.
    85      *
    86      * @return string
    87      */
    88     public function title( $title )
    89     {
    90         global $wp_query;
    91         if ( ! is_admin()
    92             && is_main_query()
    93             && in_the_loop()
    94             && is_account_page()
    95         ) {
    96             if ( isset( $wp_query->query_vars[ self::ENDPOINT ] ) ) {
    97                 $title = __( 'License Keys', 'woo-license-keys' );
    98                 remove_filter( 'the_title', [ $this, 'title' ] );
    99             } else if ( isset( $wp_query->query_vars[ self::VIEW_ENDPOINT ] ) ) {
    100                 $title = __( 'License Key', 'woo-license-keys' );
    101                 remove_filter( 'the_title', [ $this, 'title' ] );
    102             }
    103         }
    104         return $title;
    10575    }
    10676    /**
     
    234204    public function view_enqueue()
    235205    {
    236         global $licensekeys;
    237         wp_enqueue_script(
    238             'clipboard',
    239             assets_url( 'js/clipboard.min.js', __DIR__ ),
    240             [],
    241             '2.0.6',
    242             true
    243         );
    244         wp_enqueue_script(
    245             'license-keys-app',
    246             assets_url( 'js/app.js', __DIR__ ),
    247             ['clipboard', 'jquery'],
    248             $licensekeys->config->get( 'version' ),
    249             true
    250         );
     206        wp_enqueue_script( 'woo-license-keys' );
     207    }
     208    /**
     209     * Returns query vars for custom endpoint.
     210     * @since 1.5.0
     211     *
     212     * @hook woocommerce_get_query_vars
     213     *
     214     * @param array $vars
     215     *
     216     * @return array
     217     */
     218    public function wc_query_vars( $vars )
     219    {
     220        $vars[self::ENDPOINT] = self::ENDPOINT;
     221        $vars[self::VIEW_ENDPOINT] = self::VIEW_ENDPOINT;
     222        return $vars;
     223    }
     224    /**
     225     * Returns endpoint title.
     226     * @since 1.5.0
     227     *
     228     * @hook woocommerce_endpoint_{self::ENDPOINT}_title
     229     *
     230     * @param string $title
     231     *
     232     * @return string
     233     */
     234    public function endpoint_title()
     235    {
     236        return __( 'License Keys', 'woo-license-keys' );
     237    }
     238    /**
     239     * Returns view endpoint title.
     240     * @since 1.5.0
     241     *
     242     * @hook woocommerce_endpoint_{self::VIEW_ENDPOINT}_title
     243     *
     244     * @param string $title
     245     *
     246     * @return string
     247     */
     248    public function view_endpoint_title()
     249    {
     250        return __( 'License Key', 'woo-license-keys' );
    251251    }
    252252}
  • woo-license-keys/trunk/app/Controllers/ValidatorController.php

    r2274899 r2362708  
    77use WPMVC\Response;
    88use WPMVC\MVC\Controller;
     9use LicenseKeys\Interfaces\Validatable;
     10use LicenseKeys\Core\ApiFatalException;
    911use LicenseKeys\Core\ValidationException;
    10 use LicenseKeys\Models\LicenseKey;
    11 
     12use LicenseKeys\Validators\ApiValidator;
    1213/**
    1314 * API Validator controller.
     
    1819 * @license GPLv3
    1920 * @package woo-license-keys
    20  * @version 1.3.6
     21 * @version 1.5.0
    2122 */
    2223class ValidatorController extends Controller
    2324{
    2425    /**
     26     * API validator.
     27     * @since 1.5.0
     28     *
     29     * @var \LicenseKeys\Interfaces\Validatable
     30     */
     31    protected $validator;
     32    /**
    2533     * Activation service.
    2634     * @since 1.0.0
     
    3442        $response = new Response();
    3543        try {
     44            $this->set_validator();
    3645            // Prepare request
    3746            if ( ! is_array( $request ) )
     
    4352                'error_format'  => get_option( 'license_keys_response_errors_format', 'property' ),
    4453            ] );
    45             // Breakable validations
    46             if ( ! $this->is_valid( 'empty_store_code', $request, $response, $validation_args ) )
    47                 throw new ValidationException();
    48             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    49                 throw new ValidationException();
    50             if ( ! $this->is_valid( 'empty_license_key', $request, $response, $validation_args ) )
    51                 throw new ValidationException();
    52             if ( ! $this->is_valid( 'store_code', $request, $response, $validation_args ) )
    53                 throw new ValidationException();
    54             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    55                 throw new ValidationException();
    56             if ( ! $this->is_valid( 'license_key_format', $request, $response, $validation_args ) )
    57                 throw new ValidationException();
    58             if ( ! $this->parse_license_key( $request, $response, $validation_args ) )
    59                 throw new ValidationException();
    60             if ( ! $this->get_license_key( $request, $response, $validation_args ) )
    61                 throw new ValidationException();
    62             if ( ! $this->is_valid( 'sku', $request, $response, $validation_args ) )
    63                 throw new ValidationException();
    64             // Validations
    65             $this->is_valid( 'license_key_expire', $request, $response, $validation_args );
    66             $this->is_valid( 'license_key_limit', $request, $response, $validation_args );
     54            // Validator
     55            $this->validator->activate( $request, $response, $validation_args );
    6756            // Customization support
    6857            $request = apply_filters( 'woocommerce_license_keys_activate_request_preval', $request, $response );
     
    116105                isset( $request ) ? $request : []
    117106            );
     107        } catch ( ApiFatalException $e ) {
     108            Log::error( $e );
     109            $response->message = $e->getMessage();
    118110        } catch ( Exception $e ) {
    119111            Log::error( $e );
     
    140132        $response = new Response();
    141133        try {
     134            $this->set_validator();
    142135            // Prepare request
    143136            if ( ! is_array( $request ) )
     
    149142                'error_format'  => get_option( 'license_keys_response_errors_format', 'property' ),
    150143            ] );
    151             // Breakable validations
    152             if ( ! $this->is_valid( 'empty_store_code', $request, $response, $validation_args ) )
    153                 throw new ValidationException();
    154             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    155                 throw new ValidationException();
    156             if ( ! $this->is_valid( 'empty_license_key', $request, $response, $validation_args ) )
    157                 throw new ValidationException();
    158             if ( ! $this->is_valid( 'store_code', $request, $response, $validation_args ) )
    159                 throw new ValidationException();
    160             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    161                 throw new ValidationException();
    162             if ( ! $this->is_valid( 'empty_activation_id', $request, $response, $validation_args ) )
    163                 throw new ValidationException();
    164             if ( ! $this->is_valid( 'license_key_format', $request, $response, $validation_args ) )
    165                 throw new ValidationException();
    166             if ( ! $this->parse_license_key( $request, $response, $validation_args ) )
    167                 throw new ValidationException();
    168             if ( ! $this->get_license_key( $request, $response, $validation_args ) )
    169                 throw new ValidationException();
    170             if ( ! $this->is_valid( 'sku', $request, $response, $validation_args ) )
    171                 throw new ValidationException();
    172             // Validations
    173             $this->is_valid( 'license_key_expire', $request, $response, $validation_args );
    174             $this->is_valid( 'activation_id', $request, $response, $validation_args );
     144            // Validator
     145            $this->validator->validate( $request, $response, $validation_args );
    175146            // Customization support
    176147            $request = apply_filters( 'woocommerce_license_keys_validate_request_preval', $request, $response );
     
    199170                isset( $request ) ? $request : []
    200171            );
     172        } catch ( ApiFatalException $e ) {
     173            Log::error( $e );
     174            $response->message = $e->getMessage();
    201175        } catch ( Exception $e ) {
    202176            Log::error( $e );
     
    223197        $response = new Response();
    224198        try {
     199            $this->set_validator();
    225200            // Prepare request
    226201            if ( ! is_array( $request ) )
     
    232207                'error_format'  => get_option( 'license_keys_response_errors_format', 'property' ),
    233208            ] );
    234             // Breakable validations
    235             if ( ! $this->is_valid( 'empty_store_code', $request, $response, $validation_args ) )
    236                 throw new ValidationException();
    237             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    238                 throw new ValidationException();
    239             if ( ! $this->is_valid( 'empty_license_key', $request, $response, $validation_args ) )
    240                 throw new ValidationException();
    241             if ( ! $this->is_valid( 'store_code', $request, $response, $validation_args ) )
    242                 throw new ValidationException();
    243             if ( ! $this->is_valid( 'empty_sku', $request, $response, $validation_args ) )
    244                 throw new ValidationException();
    245             if ( ! $this->is_valid( 'empty_activation_id', $request, $response, $validation_args ) )
    246                 throw new ValidationException();
    247             if ( ! $this->is_valid( 'license_key_format', $request, $response, $validation_args ) )
    248                 throw new ValidationException();
    249             if ( ! $this->parse_license_key( $request, $response, $validation_args ) )
    250                 throw new ValidationException();
    251             if ( ! $this->get_license_key( $request, $response, $validation_args ) )
    252                 throw new ValidationException();
    253             if ( ! $this->is_valid( 'sku', $request, $response, $validation_args ) )
    254                 throw new ValidationException();
    255             // Validations
    256             $this->is_valid( 'license_key_expire', $request, $response, $validation_args );
    257             $this->is_valid( 'activation_id', $request, $response, $validation_args );
     209            // Validator
     210            $this->validator->deactivate( $request, $response, $validation_args );
    258211            // Customization support
    259212            $request = apply_filters( 'woocommerce_license_keys_deactivate_request_preval', $request, $response );
     
    286239                isset( $request ) ? $request : []
    287240            );
     241        } catch ( ApiFatalException $e ) {
     242            Log::error( $e );
     243            $response->message = $e->getMessage();
    288244        } catch ( Exception $e ) {
    289245            Log::error( $e );
     
    297253        }
    298254        return $response;
    299     }
    300     /**
    301      * Returns flag indicating if validation was successfull.
    302      * @since 1.0.0
    303      *
    304      * @param string $validation Validation to make.
    305      * @param array  &$request   Request data.
    306      * @param object &$response  Response.
    307      * @param array  &$args      Additional arguments.
    308      *
    309      * @return bool
    310      */
    311     private function is_valid( $validation, &$request, &$response, $args = [] )
    312     {
    313         $is_code = isset( $args['error_format'] ) && $args['error_format'] === 'code';
    314         switch ( $validation ) {
    315             case 'store_code':
    316                 if ( get_option( 'woocommerce_store_code', false ) !== $request['store_code'] ) {
    317                     $response->error( ( $is_code ? 1 : 'store_code' ), __( 'Invalid code.', 'woo-license-keys' ) );
    318                     return false;
    319                 }
    320                 break;
    321             case 'license_key_format':
    322                 if ( apply_filters( 'woocommerce_license_keys_enable_format_validation', true )
    323                     && ( ! preg_match( '/[A-Za-z0-9]+\-[0-9]+/', $request['key_code'], $matches )
    324                         || $matches[0] !== $request['key_code']
    325                     )
    326                 ) {
    327                     $response->error( ( $is_code ? 2 : 'license_key' ), __( 'Invalid license key.', 'woo-license-keys' ) );
    328                     return false;
    329                 }
    330                 break;
    331             case 'sku':
    332                 if ( apply_filters( 'woocommerce_license_keys_enable_sku_validation', true )
    333                     && $request['license_key']->product->get_sku() !== $request['sku']
    334                 ) {
    335                     $response->error( ( $is_code ? 3 : 'license_key' ), __( 'Invalid license key.', 'woo-license-keys' ) );
    336                     return false;
    337                 }
    338                 break;
    339             case 'empty_sku':
    340                 if ( apply_filters( 'woocommerce_license_keys_enable_sku_validation', true )
    341                     && empty( $request['sku'] )
    342                 ) {
    343                     $response->error( ( $is_code ? 100 : 'sku' ), __( 'Required.', 'woo-license-keys' ) );
    344                     return false;
    345                 }
    346                 break;
    347             case 'empty_license_key':
    348                 if ( empty( $request['key_code'] ) ) {
    349                     $response->error( ( $is_code ? 101 : 'license_key' ), __( 'Required.', 'woo-license-keys' ) );
    350                     return false;
    351                 }
    352                 break;
    353             case 'empty_store_code':
    354                 if ( empty( $request['store_code'] ) ) {
    355                     $response->error( ( $is_code ? 102 : 'store_code' ), __( 'Required.', 'woo-license-keys' ) );
    356                     return false;
    357                 }
    358                 break;
    359             case 'empty_activation_id':
    360                 if ( empty( $request['activation_id'] ) ) {
    361                     $response->error( ( $is_code ? 103 : 'activation_id' ), __( 'Required.', 'woo-license-keys' ) );
    362                     return false;
    363                 }
    364                 break;
    365             case 'license_key_expire':
    366                 if ( $request['license_key']->expire !== null
    367                     && time() > $request['license_key']->expire
    368                 ) {
    369                     $response->error( ( $is_code ? 200 : 'license_key' ), __( 'License key has expired.', 'woo-license-keys' ) );
    370                     return false;
    371                 }
    372                 break;
    373             case 'domain':
    374                 if ( apply_filters( 'woocommerce_license_keys_enable_domain_validation', true )
    375                     && get_post_meta( $request['license_key']->product->get_id(), '_desktop', true ) !== 'yes'
    376                     && empty( $request['domain'] )
    377                 ) {
    378                     $response->error( ( $is_code ? 104 : 'domain' ), __( 'Required.', 'woo-license-keys' ) );
    379                     return false;
    380                 }
    381                 break;
    382             case 'license_key_limit':
    383                 $is_desktop = get_post_meta( $request['license_key']->product->get_id(), '_desktop', true ) === 'yes';
    384                 if ( apply_filters( 'woocommerce_license_keys_has_extended', false )
    385                     && $request['license_key']->limit !== null
    386                     && ( $is_desktop
    387                         || ( ! preg_match( '/localhost/', $request['domain'] )
    388                             || $request['license_key']->limit_dev
    389                         )
    390                     )
    391                     && $request['license_key']->limit_type !== null
    392                     && $request['license_key']->limit_reach !== null
    393                     && $request['license_key']->limit_count >= $request['license_key']->limit_reach
    394                     && ( $is_desktop
    395                         || ( $request['license_key']->limit_type !== 'domain'
    396                             || ! $request['license_key']->has_domain( $request['domain'] )
    397                         )
    398                     )
    399                 ) {
    400                     switch ( $request['license_key']->limit_type ) {
    401                         case 'count':
    402                             $response->error( ( $is_code ? 201 : 'license_key' ), __( 'License key activation limit reached. Deactivate one of the registered activations to proceed.', 'woo-license-keys' ) );
    403                             break;
    404                         case 'domain':
    405                             $response->error( ( $is_code ? 202 : 'license_key' ), __( 'License key domain activation limit reached. Deactivate one or more of the registered activations to proceed.', 'woo-license-keys' ) );
    406                             break;
    407                     }
    408                     return false;
    409                 }
    410                 break;
    411             case 'activation_id':
    412                 $is_desktop = get_post_meta( $request['license_key']->product->get_id(), '_desktop', true ) === 'yes';
    413                 if ( apply_filters( 'woocommerce_license_keys_has_extended', false )
    414                     && $request['license_key']->limit !== null
    415                     && preg_match( '/localhost/' , $request['domain'] )
    416                     && !$request['license_key']->limit_dev
    417                     && $request['activation_id'] === 404
    418                 ) {
    419                     return true;
    420                 }
    421                 foreach ( $request['license_key']->uses as $activation ) {
    422                     if ( $activation['date'] === $request['activation_id']
    423                         && ( ! apply_filters( 'woocommerce_license_keys_enable_domain_validation', true )
    424                             || $is_desktop
    425                             || $activation['domain'] === $request['domain']
    426                         )
    427                     ) {
    428                         return true;
    429                     }
    430                 }
    431                 $response->error( ( $is_code ? 203 : 'activation_id' ), __( 'Invalid activation.', 'woo-license-keys' ) );
    432                 if ( ! $is_code )
    433                     $response->error( 'license_key', __( 'Invalid license key.', 'woo-license-keys' ) );
    434                 return false;
    435                 break;
    436         }
    437         return true;
    438255    }
    439256    /**
     
    464281    {
    465282        return get_option( 'license_keys_enable_domain_val', $flag ) ? true : false;
    466     }
    467     /**
    468      * Returns flag indicating key parsing was successfull.
    469      * Parses license key into code and order_item_id.
    470      * @since 1.0.0
    471      *
    472      * @param arrat  &$request   Request data.
    473      * @param object &$response  Response.
    474      * @param array  &$args      Additional arguments.
    475      *
    476      * @return bool
    477      */
    478     private function parse_license_key( &$request, &$response, $args = [] )
    479     {
    480         $is_code = isset( $args['error_format'] ) && $args['error_format'] === 'code';
    481         $key = apply_filters( 'woocommerce_license_keys_enable_parse_validation', true )
    482             ? explode( '-', $request['key_code'] )
    483             : [];
    484         if ( apply_filters( 'woocommerce_license_keys_enable_parse_validation', true )
    485             && count( $key ) !== 2
    486         ) {
    487             $response->error( ( $is_code ? 4 : 'license_key' ), __( 'Invalid license key.', 'woo-license-keys' ) );
    488             return false;
    489         }
    490         if ( count( $key ) === 2 ) {
    491             $request['code'] = $key[0];
    492             $request['order_item_id'] = intval( $key[1] );
    493         }
    494         return true;
    495     }
    496     /**
    497      * Returns flag indicating if license key was found.
    498      * Stores license key model in request.
    499      * @since 1.0.0
    500      *
    501      * @param arrat  &$request   Request data.
    502      * @param object &$response  Response.
    503      * @param array  &$args      Additional arguments.
    504      *
    505      * @return bool
    506      */
    507     private function get_license_key( &$request, &$response, $args = [] )
    508     {
    509         $is_code = isset( $args['error_format'] ) && $args['error_format'] === 'code';
    510         $request['license_key'] = wc_find_license_key( $request );
    511         if ( $request['license_key'] === null ) {
    512             $response->error( ( $is_code ? 5 : 'license_key' ), __( 'Invalid license key.', 'woo-license-keys' ) );
    513             return false;
    514         }
    515         return true;
    516283    }
    517284    /**
     
    548315        }
    549316    }
     317    /**
     318     * Returns API successful responses with additional data
     319     * added based on settings.
     320     * @since 1.5.0
     321     *
     322     * @hook woocommerce_license_keys_activate_success_response
     323     * @hook woocommerce_license_keys_validate_success_response
     324     *
     325     * @param \WPMVC\Response $response
     326     * @param array           $request
     327     *
     328     * @return \WPMVC\Response
     329     */
     330    public function success_response( $response, $request )
     331    {
     332        if ( get_option( 'license_keys_include_user_email', false ) ) {
     333            $order = wc_get_order( $request['license_key']->order_id );
     334            $user = get_user_by( 'id', $order->get_customer_id() );
     335            $response->data['email'] = $user->user_email;
     336        }
     337        if ( get_option( 'license_keys_include_product_name', false ) ) {
     338            $response->data['name'] = $request['license_key']->product->get_name();
     339        }
     340        if ( get_option( 'license_keys_include_product_sku', false )
     341            && $request['license_key']->product->get_sku()
     342        ) {
     343            $response->data['sku'] = $request['license_key']->product->get_sku();
     344        }
     345        return $response;
     346    }
     347    /**
     348     * Sets API validator to use.
     349     * @since 1.5.0
     350     */
     351    private function set_validator()
     352    {
     353        $validator_class = apply_filters( 'woocommerce_license_keys_api_validator_class', 'LicenseKeys\Validators\ApiValidator' );
     354        if ( empty( $validator_class ) )
     355            throw new ApiFatalException( 'Empty License Keys API validator class.' );
     356        if ( !class_exists( $validator_class ) )
     357            throw new ApiFatalException( sprintf( 'License Keys API validator "%s" does not exist.', $validator_class ) );
     358        $this->validator = new $validator_class();
     359        if ( !$this->validator instanceof Validatable )
     360            throw new ApiFatalException( 'License Keys API validator must implement "LicenseKeys\Interfaces\Validatable" interface.' );
     361    }
    550362}
  • woo-license-keys/trunk/app/Controllers/WooCommerceController.php

    r2274899 r2362708  
    1818 * @license GPLv3
    1919 * @package woo-license-keys
    20  * @version 1.4.0
     20 * @version 1.5.0
    2121 */
    2222class WooCommerceController extends Controller
     
    524524                ],
    525525                [
    526                     'name'  => __( 'HTTP Response', 'woo-license-keys' ),
     526                    'name'  => __( 'API Response', 'woo-license-keys' ),
    527527                    'type'  => 'title',
    528528                    'id'    => 'license_keys_response',
     
    539539                    'desc_tip' => __( 'Indicates how should errors be returned in API responses.', 'woo-license-keys' ),
    540540                    'default' => 'property',
     541                ],
     542                [
     543                    'name'  => __( 'Include user email', 'woo-license-keys' ),
     544                    'id'    => 'license_keys_include_user_email',
     545                    'type'  => 'select',
     546                    'options' => apply_filters( 'woocommerce_license_key_response_settings_options',
     547                            [
     548                                1 => __( 'Yes', 'woo-license-keys' ),
     549                                0 => __( 'No', 'woo-license-keys' ),
     550                            ] ),
     551                    'desc_tip' => __( 'Includes the user\'s email in the API response.', 'woo-license-keys' ),
     552                    'default' => 0,
     553                ],
     554                [
     555                    'name'  => __( 'Include product name', 'woo-license-keys' ),
     556                    'id'    => 'license_keys_include_product_name',
     557                    'type'  => 'select',
     558                    'options' => apply_filters( 'woocommerce_license_key_response_settings_options',
     559                            [
     560                                1 => __( 'Yes', 'woo-license-keys' ),
     561                                0 => __( 'No', 'woo-license-keys' ),
     562                            ] ),
     563                    'desc_tip' => __( 'Includes the product\'s name in the API response.', 'woo-license-keys' ),
     564                    'default' => 0,
     565                ],
     566                [
     567                    'name'  => __( 'Include product SKU', 'woo-license-keys' ),
     568                    'id'    => 'license_keys_include_product_sku',
     569                    'type'  => 'select',
     570                    'options' => apply_filters( 'woocommerce_license_key_response_settings_options',
     571                            [
     572                                1 => __( 'Yes', 'woo-license-keys' ),
     573                                0 => __( 'No', 'woo-license-keys' ),
     574                            ] ),
     575                    'desc_tip' => __( 'Includes the product\'s SKU in the API response.', 'woo-license-keys' ),
     576                    'default' => 0,
    541577                ],
    542578                [
  • woo-license-keys/trunk/app/Main.php

    r2362481 r2362708  
    1515 * @license GPLv3
    1616 * @package woo-license-keys
    17  * @version 1.4.1
     17 * @version 1.5.0
    1818 */
    1919class Main extends Bridge
     
    4242        $this->add_action( 'init', 'AccountController@add_endpoint' );
    4343        $this->add_filter( 'query_vars', 'AccountController@query_vars' );
    44         $this->add_filter( 'the_title', 'AccountController@title' );
    4544        $this->add_action( 'woocommerce_license_key_enqueue', 'AccountController@view_enqueue' );
    4645        $this->add_filter( 'woocommerce_account_menu_items', 'AccountController@menu_items' );
    4746        $this->add_action( 'woocommerce_account_' . Account::ENDPOINT . '_endpoint', 'AccountController@endpoint' );
    4847        $this->add_action( 'woocommerce_account_' . Account::VIEW_ENDPOINT . '_endpoint', 'AccountController@view_endpoint' );
     48        $this->add_filter( 'woocommerce_get_query_vars', 'AccountController@wc_query_vars' );
     49        $this->add_filter( 'woocommerce_endpoint_' . Account::ENDPOINT . '_title', 'AccountController@endpoint_title', 1 );
     50        $this->add_filter( 'woocommerce_endpoint_' . Account::VIEW_ENDPOINT . '_title', 'AccountController@view_endpoint_title', 1 );
    4951        // Cart related
    5052        $this->add_filter( 'woocommerce_get_item_data', 'CartController@license_key_details', 30, 2 );
     
    5254        $this->add_filter( 'woocommerce_license_keys_enable_sku_validation', 'ValidatorController@enable_sku_validation', 1 );
    5355        $this->add_filter( 'woocommerce_license_keys_enable_domain_validation', 'ValidatorController@enable_domain_validation', 1 );
    54         // Validator endpoints
     56        // API endpoints
    5557        $this->add_action( 'woocommerce_license_key_api_headers', 'ValidatorController@set_headers' );
     58        $this->add_filter( 'woocommerce_license_keys_activate_success_response', 'ValidatorController@success_response', 1, 2 );
     59        $this->add_filter( 'woocommerce_license_keys_validate_success_response', 'ValidatorController@success_response', 1, 2 );
    5660        // API Handler
    5761        $handler = get_option( 'license_keys_api_handler', 'wp_ajax' );
  • woo-license-keys/trunk/app/Models/LicenseKey.php

    r2215470 r2362708  
    66use LicenseKeys\Traits\FindTrait;
    77use LicenseKeys\Controllers\AccountController as Account;
    8 
    98/**
    109 * License Key data model.
     
    1413 * @license GPLv3
    1514 * @package woo-license-keys
    16  * @version 1.2.11
     15 * @version 1.5.0
    1716 */
    1817class LicenseKey extends Model
     
    2221     * Aliases.
    2322     * @since 1.0.0
    24      * @since 1.1.0 is_valid added.
    2523     *
    2624     * @var array
     
    4745     * Hidden properties for casting.
    4846     * @since 1.0.0
    49      * @since 1.1.0 is_valid added.
    5047     *
    5148     * @var array
     
    6259        'offline',
    6360        'key_index',
     61        'order',
    6462        'order_id',
    6563        'order_item_id',
     
    7270     * Returns license key URL.
    7371     * @since 1.0.0
    74      * @since 1.1.5 Fixes url on permalink variations.
    7572     *
    7673     * @link https://developer.wordpress.org/reference/functions/add_query_arg/
     
    8077    protected function get_url()
    8178    {
    82         $url = add_query_arg(
    83             Account::VIEW_ENDPOINT,
    84             1,
    85             get_permalink( get_option( 'woocommerce_myaccount_page_id' ) )
    86         );
     79        $url = wc_get_endpoint_url( Account::VIEW_ENDPOINT );
     80        if ( strpos( 'http', $url ) === false ) {
     81            $url = get_permalink( get_option( 'woocommerce_myaccount_page_id' ) );
     82            if ( substr( $url, -1 ) !== '/' )
     83                $url .= '/';
     84            $url .= Account::VIEW_ENDPOINT . '/';
     85        }
    8786        return add_query_arg(
    8887            'key',
     
    9493     * Returns an order URL.
    9594     * @since 1.0.0
    96      * @since 1.1.5 Fixes url on permalink variations.
    9795     *
    9896     * @link https://developer.wordpress.org/reference/functions/add_query_arg/
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_AR.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:20-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:00-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_CL.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:26-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:00-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_CO.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:26-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:00-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_CR.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:26-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:00-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_ES.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:00-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_GT.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:01-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_MX.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:01-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_PE.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:01-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_PR.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:01-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys-es_VE.po

    r2215470 r2362708  
    33"Project-Id-Version: WooCommerce License Keys\n"
    44"POT-Creation-Date: 2018-05-22 22:00-0600\n"
    5 "PO-Revision-Date: 2019-12-19 17:27-0600\n"
     5"PO-Revision-Date: 2020-08-16 22:01-0600\n"
    66"Last-Translator: \n"
    77"Language-Team: 10 Quality <info@10quality.com>\n"
     
    274274msgstr "DOCUMENTACION"
    275275
    276 msgid "HTTP Response"
    277 msgstr "Respuesta HTTP"
     276msgid "API Response"
     277msgstr "Respuesta API"
    278278
    279279msgid "Errors output"
     
    384384msgid "Do not auto-generate codes"
    385385msgstr "No genere códigos automáticamente"
     386
     387msgid "Include user email"
     388msgstr "Incluir el email del usuario"
     389
     390msgid "Includes the user's email in the API response."
     391msgstr "Incluye el correo electrónico del usuario en la respuesta de la API."
     392
     393msgid "Include product name"
     394msgstr "Incluir el nombre del producto"
     395
     396msgid "Includes the product's name in the API response."
     397msgstr "Incluye el nombre del producto en la respuesta de la API."
     398
     399msgid "Include product SKU"
     400msgstr "Incluir SKU del producto"
     401
     402msgid "Includes the product's SKU in the API response."
     403msgstr "Incluye el SKU del producto en la respuesta de la API."
  • woo-license-keys/trunk/assets/languages/woo-license-keys.pot

    r2215470 r2362708  
    44"Project-Id-Version: woo-license-keys\n"
    55"POT-Creation-Date: 2018-05-23 01:35-0600\n"
    6 "PO-Revision-Date: 2019-12-19 01:36-0600\n"
     6"PO-Revision-Date: 2020-08-16 01:36-0600\n"
    77"Language-Team: 10 Quality\n"
    88"MIME-Version: 1.0\n"
     
    272272msgstr ""
    273273
    274 msgid "HTTP Response"
     274msgid "API Response"
    275275msgstr ""
    276276
     
    382382msgid "Do not auto-generate codes"
    383383msgstr ""
     384
     385msgid "Include user email"
     386msgstr ""
     387
     388msgid "Includes the user's email in the API response."
     389msgstr ""
     390
     391msgid "Include product name"
     392msgstr ""
     393
     394msgid "Includes the product's name in the API response."
     395msgstr ""
     396
     397msgid "Include product SKU"
     398msgstr ""
     399
     400msgid "Includes the product's SKU in the API response."
     401msgstr ""
  • woo-license-keys/trunk/plugin.php

    r2362481 r2362708  
    44Plugin URI: https://www.10quality.com/product/woocommerce-license-keys/
    55Description: Enable and handle "License Keys" with WooCommerce.
    6 Version: 1.4.1
     6Version: 1.5.0
    77Author: 10 Quality
    88Author URI: https://www.10quality.com/
Note: See TracChangeset for help on using the changeset viewer.