Changeset 2362708
- Timestamp:
- 08/17/2020 04:38:53 AM (6 years ago)
- Location:
- woo-license-keys/trunk
- Files:
-
- 5 added
- 29 edited
-
README.txt (modified) (2 diffs)
-
app/Config/app.php (modified) (2 diffs)
-
app/Controllers/AccountController.php (modified) (4 diffs)
-
app/Controllers/ValidatorController.php (modified) (14 diffs)
-
app/Controllers/WooCommerceController.php (modified) (3 diffs)
-
app/Core/ApiFatalException.php (added)
-
app/Interfaces (added)
-
app/Interfaces/Validatable.php (added)
-
app/Main.php (modified) (3 diffs)
-
app/Models/LicenseKey.php (modified) (8 diffs)
-
app/Validators (added)
-
app/Validators/ApiValidator.php (added)
-
assets/languages/woo-license-keys-es_AR.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_AR.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_CL.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_CL.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_CO.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_CO.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_CR.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_CR.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_ES.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_ES.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_GT.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_GT.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_MX.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_MX.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_PE.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_PE.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_PR.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_PR.po (modified) (3 diffs)
-
assets/languages/woo-license-keys-es_VE.mo (modified) (previous)
-
assets/languages/woo-license-keys-es_VE.po (modified) (3 diffs)
-
assets/languages/woo-license-keys.pot (modified) (3 diffs)
-
plugin.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
woo-license-keys/trunk/README.txt
r2362481 r2362708 7 7 Requires PHP: 5.4 8 8 Tested up to: 5.5 9 Stable tag: 1. 4.19 Stable tag: 1.5.0 10 10 License: GPLv3 11 11 License URI: https://www.gnu.org/licenses/gpl-3.0.html … … 86 86 == Changelog == 87 87 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 88 95 = 1.4.1 = 89 96 *Release Date - 16 Aug 2020* -
woo-license-keys/trunk/app/Config/app.php
r2362481 r2362708 19 19 ], 20 20 21 'version' => '1. 4.1',21 'version' => '1.5.0', 22 22 23 23 'author' => '10 Quality Studio <https://www.10quality.com/>', … … 39 39 40 40 // Enables or disables auto-enqueue of assets 41 'enabled' => false,41 'enabled' => true, 42 42 // 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 ], 44 59 45 60 ], -
woo-license-keys/trunk/app/Controllers/AccountController.php
r2362481 r2362708 10 10 use LicenseKeys\Core\ValidationException; 11 11 /** 12 * AccountController controller.12 * WooCommerce "My Account" related hooks. 13 13 * Handles all account related business logic. 14 14 * … … 18 18 * @license GPLv3 19 19 * @package woo-license-keys 20 * @version 1. 4.020 * @version 1.5.0 21 21 */ 22 22 class AccountController extends Controller … … 73 73 $vars[] = self::VIEW_ENDPOINT; 74 74 return $vars; 75 }76 /**77 * Retuns endpoint title.78 * @since 1.0.079 *80 * @hook the_title81 *82 * @global object $wp_query Wordpress query string manager.83 *84 * @param string $title Current title.85 *86 * @return string87 */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;105 75 } 106 76 /** … … 234 204 public function view_enqueue() 235 205 { 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' ); 251 251 } 252 252 } -
woo-license-keys/trunk/app/Controllers/ValidatorController.php
r2274899 r2362708 7 7 use WPMVC\Response; 8 8 use WPMVC\MVC\Controller; 9 use LicenseKeys\Interfaces\Validatable; 10 use LicenseKeys\Core\ApiFatalException; 9 11 use LicenseKeys\Core\ValidationException; 10 use LicenseKeys\Models\LicenseKey; 11 12 use LicenseKeys\Validators\ApiValidator; 12 13 /** 13 14 * API Validator controller. … … 18 19 * @license GPLv3 19 20 * @package woo-license-keys 20 * @version 1. 3.621 * @version 1.5.0 21 22 */ 22 23 class ValidatorController extends Controller 23 24 { 24 25 /** 26 * API validator. 27 * @since 1.5.0 28 * 29 * @var \LicenseKeys\Interfaces\Validatable 30 */ 31 protected $validator; 32 /** 25 33 * Activation service. 26 34 * @since 1.0.0 … … 34 42 $response = new Response(); 35 43 try { 44 $this->set_validator(); 36 45 // Prepare request 37 46 if ( ! is_array( $request ) ) … … 43 52 'error_format' => get_option( 'license_keys_response_errors_format', 'property' ), 44 53 ] ); 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 ); 67 56 // Customization support 68 57 $request = apply_filters( 'woocommerce_license_keys_activate_request_preval', $request, $response ); … … 116 105 isset( $request ) ? $request : [] 117 106 ); 107 } catch ( ApiFatalException $e ) { 108 Log::error( $e ); 109 $response->message = $e->getMessage(); 118 110 } catch ( Exception $e ) { 119 111 Log::error( $e ); … … 140 132 $response = new Response(); 141 133 try { 134 $this->set_validator(); 142 135 // Prepare request 143 136 if ( ! is_array( $request ) ) … … 149 142 'error_format' => get_option( 'license_keys_response_errors_format', 'property' ), 150 143 ] ); 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 ); 175 146 // Customization support 176 147 $request = apply_filters( 'woocommerce_license_keys_validate_request_preval', $request, $response ); … … 199 170 isset( $request ) ? $request : [] 200 171 ); 172 } catch ( ApiFatalException $e ) { 173 Log::error( $e ); 174 $response->message = $e->getMessage(); 201 175 } catch ( Exception $e ) { 202 176 Log::error( $e ); … … 223 197 $response = new Response(); 224 198 try { 199 $this->set_validator(); 225 200 // Prepare request 226 201 if ( ! is_array( $request ) ) … … 232 207 'error_format' => get_option( 'license_keys_response_errors_format', 'property' ), 233 208 ] ); 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 ); 258 211 // Customization support 259 212 $request = apply_filters( 'woocommerce_license_keys_deactivate_request_preval', $request, $response ); … … 286 239 isset( $request ) ? $request : [] 287 240 ); 241 } catch ( ApiFatalException $e ) { 242 Log::error( $e ); 243 $response->message = $e->getMessage(); 288 244 } catch ( Exception $e ) { 289 245 Log::error( $e ); … … 297 253 } 298 254 return $response; 299 }300 /**301 * Returns flag indicating if validation was successfull.302 * @since 1.0.0303 *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 bool310 */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 !== null367 && time() > $request['license_key']->expire368 ) {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 !== null386 && ( $is_desktop387 || ( ! preg_match( '/localhost/', $request['domain'] )388 || $request['license_key']->limit_dev389 )390 )391 && $request['license_key']->limit_type !== null392 && $request['license_key']->limit_reach !== null393 && $request['license_key']->limit_count >= $request['license_key']->limit_reach394 && ( $is_desktop395 || ( $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 !== null415 && preg_match( '/localhost/' , $request['domain'] )416 && !$request['license_key']->limit_dev417 && $request['activation_id'] === 404418 ) {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_desktop425 || $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;438 255 } 439 256 /** … … 464 281 { 465 282 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.0471 *472 * @param arrat &$request Request data.473 * @param object &$response Response.474 * @param array &$args Additional arguments.475 *476 * @return bool477 */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 ) !== 2486 ) {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.0500 *501 * @param arrat &$request Request data.502 * @param object &$response Response.503 * @param array &$args Additional arguments.504 *505 * @return bool506 */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;516 283 } 517 284 /** … … 548 315 } 549 316 } 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 } 550 362 } -
woo-license-keys/trunk/app/Controllers/WooCommerceController.php
r2274899 r2362708 18 18 * @license GPLv3 19 19 * @package woo-license-keys 20 * @version 1. 4.020 * @version 1.5.0 21 21 */ 22 22 class WooCommerceController extends Controller … … 524 524 ], 525 525 [ 526 'name' => __( ' HTTPResponse', 'woo-license-keys' ),526 'name' => __( 'API Response', 'woo-license-keys' ), 527 527 'type' => 'title', 528 528 'id' => 'license_keys_response', … … 539 539 'desc_tip' => __( 'Indicates how should errors be returned in API responses.', 'woo-license-keys' ), 540 540 '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, 541 577 ], 542 578 [ -
woo-license-keys/trunk/app/Main.php
r2362481 r2362708 15 15 * @license GPLv3 16 16 * @package woo-license-keys 17 * @version 1. 4.117 * @version 1.5.0 18 18 */ 19 19 class Main extends Bridge … … 42 42 $this->add_action( 'init', 'AccountController@add_endpoint' ); 43 43 $this->add_filter( 'query_vars', 'AccountController@query_vars' ); 44 $this->add_filter( 'the_title', 'AccountController@title' );45 44 $this->add_action( 'woocommerce_license_key_enqueue', 'AccountController@view_enqueue' ); 46 45 $this->add_filter( 'woocommerce_account_menu_items', 'AccountController@menu_items' ); 47 46 $this->add_action( 'woocommerce_account_' . Account::ENDPOINT . '_endpoint', 'AccountController@endpoint' ); 48 47 $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 ); 49 51 // Cart related 50 52 $this->add_filter( 'woocommerce_get_item_data', 'CartController@license_key_details', 30, 2 ); … … 52 54 $this->add_filter( 'woocommerce_license_keys_enable_sku_validation', 'ValidatorController@enable_sku_validation', 1 ); 53 55 $this->add_filter( 'woocommerce_license_keys_enable_domain_validation', 'ValidatorController@enable_domain_validation', 1 ); 54 // Validatorendpoints56 // API endpoints 55 57 $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 ); 56 60 // API Handler 57 61 $handler = get_option( 'license_keys_api_handler', 'wp_ajax' ); -
woo-license-keys/trunk/app/Models/LicenseKey.php
r2215470 r2362708 6 6 use LicenseKeys\Traits\FindTrait; 7 7 use LicenseKeys\Controllers\AccountController as Account; 8 9 8 /** 10 9 * License Key data model. … … 14 13 * @license GPLv3 15 14 * @package woo-license-keys 16 * @version 1. 2.1115 * @version 1.5.0 17 16 */ 18 17 class LicenseKey extends Model … … 22 21 * Aliases. 23 22 * @since 1.0.0 24 * @since 1.1.0 is_valid added.25 23 * 26 24 * @var array … … 47 45 * Hidden properties for casting. 48 46 * @since 1.0.0 49 * @since 1.1.0 is_valid added.50 47 * 51 48 * @var array … … 62 59 'offline', 63 60 'key_index', 61 'order', 64 62 'order_id', 65 63 'order_item_id', … … 72 70 * Returns license key URL. 73 71 * @since 1.0.0 74 * @since 1.1.5 Fixes url on permalink variations.75 72 * 76 73 * @link https://developer.wordpress.org/reference/functions/add_query_arg/ … … 80 77 protected function get_url() 81 78 { 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 } 87 86 return add_query_arg( 88 87 'key', … … 94 93 * Returns an order URL. 95 94 * @since 1.0.0 96 * @since 1.1.5 Fixes url on permalink variations.97 95 * 98 96 * @link https://developer.wordpress.org/reference/functions/add_query_arg/ -
woo-license-keys/trunk/assets/languages/woo-license-keys-es_AR.po
r2215470 r2362708 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:20-0600\n"5 "PO-Revision-Date: 2020-08-16 22:00-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:26-0600\n"5 "PO-Revision-Date: 2020-08-16 22:00-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:26-0600\n"5 "PO-Revision-Date: 2020-08-16 22:00-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:26-0600\n"5 "PO-Revision-Date: 2020-08-16 22:00-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:00-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:01-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:01-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:01-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:01-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "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 3 3 "Project-Id-Version: WooCommerce License Keys\n" 4 4 "POT-Creation-Date: 2018-05-22 22:00-0600\n" 5 "PO-Revision-Date: 20 19-12-19 17:27-0600\n"5 "PO-Revision-Date: 2020-08-16 22:01-0600\n" 6 6 "Last-Translator: \n" 7 7 "Language-Team: 10 Quality <info@10quality.com>\n" … … 274 274 msgstr "DOCUMENTACION" 275 275 276 msgid " HTTPResponse"277 msgstr "Respuesta HTTP"276 msgid "API Response" 277 msgstr "Respuesta API" 278 278 279 279 msgid "Errors output" … … 384 384 msgid "Do not auto-generate codes" 385 385 msgstr "No genere códigos automáticamente" 386 387 msgid "Include user email" 388 msgstr "Incluir el email del usuario" 389 390 msgid "Includes the user's email in the API response." 391 msgstr "Incluye el correo electrónico del usuario en la respuesta de la API." 392 393 msgid "Include product name" 394 msgstr "Incluir el nombre del producto" 395 396 msgid "Includes the product's name in the API response." 397 msgstr "Incluye el nombre del producto en la respuesta de la API." 398 399 msgid "Include product SKU" 400 msgstr "Incluir SKU del producto" 401 402 msgid "Includes the product's SKU in the API response." 403 msgstr "Incluye el SKU del producto en la respuesta de la API." -
woo-license-keys/trunk/assets/languages/woo-license-keys.pot
r2215470 r2362708 4 4 "Project-Id-Version: woo-license-keys\n" 5 5 "POT-Creation-Date: 2018-05-23 01:35-0600\n" 6 "PO-Revision-Date: 20 19-12-1901:36-0600\n"6 "PO-Revision-Date: 2020-08-16 01:36-0600\n" 7 7 "Language-Team: 10 Quality\n" 8 8 "MIME-Version: 1.0\n" … … 272 272 msgstr "" 273 273 274 msgid " HTTPResponse"274 msgid "API Response" 275 275 msgstr "" 276 276 … … 382 382 msgid "Do not auto-generate codes" 383 383 msgstr "" 384 385 msgid "Include user email" 386 msgstr "" 387 388 msgid "Includes the user's email in the API response." 389 msgstr "" 390 391 msgid "Include product name" 392 msgstr "" 393 394 msgid "Includes the product's name in the API response." 395 msgstr "" 396 397 msgid "Include product SKU" 398 msgstr "" 399 400 msgid "Includes the product's SKU in the API response." 401 msgstr "" -
woo-license-keys/trunk/plugin.php
r2362481 r2362708 4 4 Plugin URI: https://www.10quality.com/product/woocommerce-license-keys/ 5 5 Description: Enable and handle "License Keys" with WooCommerce. 6 Version: 1. 4.16 Version: 1.5.0 7 7 Author: 10 Quality 8 8 Author URI: https://www.10quality.com/
Note: See TracChangeset
for help on using the changeset viewer.