| @@ -11,28 +11,21 @@ | ||
| 11 | 11 | |
| 12 | 12 | defined( 'ABSPATH' ) || exit; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * Temporary license provider for active Pro releases older than 1.3.0. | |
| 15 | + * License management. | |
| 16 | 16 | * |
| 17 | - * Note for WordPress.org Plugin Review Team: Core registers this deprecated | |
| 18 | - * bridge only when it detects an active Content Control Pro version below | |
| 19 | - * 1.3.0. It preserves licensing and update access while that already-installed | |
| 20 | - * add-on is upgraded. Core alone and Pro 1.3.0 or later never instantiate it, | |
| 21 | - * and this class cannot install plugins. | |
| 17 | + * NOTE: For wordpress.org admins: This is only used if: | |
| 18 | + * - The user explicitly entered a license key. | |
| 22 | 19 | * |
| 23 | - * @see \ContentControl\Plugin\Core::is_legacy_pro_active() | |
| 24 | - * | |
| 25 | 20 | * @package ContentControl |
| 26 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 27 | 21 | */ |
| 28 | 22 | class License { |
| 29 | 23 | |
| 30 | 24 | /** |
| 31 | - * Legacy EDD API URL used only for active Pro releases older than 1.3.0. | |
| 25 | + * EDD API URL. | |
| 32 | 26 | * |
| 33 | 27 | * @var string |
| 34 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 35 | 28 | */ |
| 36 | 29 | const API_URL = 'https://contentcontrolplugin.com/edd-sl-api/'; |
| 37 | 30 | |
| 38 | 31 | /** |
| @@ -57,10 +50,8 @@ | ||
| 57 | 50 | private $license_data; |
| 58 | 51 | |
| 59 | 52 | /** |
| 60 | 53 | * Initialize license management. |
| 61 | - * | |
| 62 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 63 | 54 | */ |
| 64 | 55 | public function __construct() { |
| 65 | 56 | $this->register_hooks(); |
| 66 | 57 | } |
| @@ -68,9 +59,8 @@ | ||
| 68 | 59 | /** |
| 69 | 60 | * Register hooks. |
| 70 | 61 | * |
| 71 | 62 | * @return void |
| 72 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 73 | 63 | */ |
| 74 | 64 | public function register_hooks() { |
| 75 | 65 | add_action( 'init', [ $this, 'autoregister' ] ); |
| 76 | 66 | add_action( 'content_control_license_status_check', [ $this, 'refresh_license_status' ] ); |
| @@ -80,9 +70,8 @@ | ||
| 80 | 70 | /** |
| 81 | 71 | * Autoregister license. |
| 82 | 72 | * |
| 83 | 73 | * @return void |
| 84 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 85 | 74 | */ |
| 86 | 75 | public function autoregister() { |
| 87 | 76 | $key = defined( '\CONTENT_CONTROL_LICENSE_KEY' ) && '' !== \CONTENT_CONTROL_LICENSE_KEY ? \CONTENT_CONTROL_LICENSE_KEY : false; |
| 88 | 77 | |
| @@ -99,9 +88,8 @@ | ||
| 99 | 88 | /** |
| 100 | 89 | * Schedule cron jobs. |
| 101 | 90 | * |
| 102 | 91 | * @return void |
| 103 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 104 | 92 | */ |
| 105 | 93 | public function schedule_crons() { |
| 106 | 94 | if ( ! wp_next_scheduled( 'content_control_license_status_check' ) ) { |
| 107 | 95 | wp_schedule_event( time(), 'daily', 'content_control_license_status_check' ); |
| @@ -111,9 +99,8 @@ | ||
| 111 | 99 | /** |
| 112 | 100 | * Get license data. |
| 113 | 101 | * |
| 114 | 102 | * @return array{key:string|null,status:array<string,mixed>|null} |
| 115 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 116 | 103 | */ |
| 117 | 104 | public function get_license_data() { |
| 118 | 105 | if ( ! isset( $this->license_data ) ) { |
| 119 | 106 | $this->license_data = \get_option( self::OPTION_KEY, [ |
| @@ -143,9 +130,8 @@ | ||
| 143 | 130 | /** |
| 144 | 131 | * Get license key. |
| 145 | 132 | * |
| 146 | 133 | * @return string |
| 147 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 148 | 134 | */ |
| 149 | 135 | public function get_license_key() { |
| 150 | 136 | $license_data = $this->get_license_data(); |
| 151 | 137 | return ! empty( $license_data['key'] ) ? $license_data['key'] : ''; |
| @@ -156,9 +142,8 @@ | ||
| 156 | 142 | * |
| 157 | 143 | * @param bool $refresh Whether to refresh license status. |
| 158 | 144 | * |
| 159 | 145 | * @return array<string,mixed> Array of license status data. |
| 160 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 161 | 146 | */ |
| 162 | 147 | public function get_license_status( $refresh = false ) { |
| 163 | 148 | if ( $refresh ) { |
| 164 | 149 | $this->refresh_license_status(); |
| @@ -176,9 +161,8 @@ | ||
| 176 | 161 | * |
| 177 | 162 | * Only used in pro version. |
| 178 | 163 | * |
| 179 | 164 | * @return int Integer representing license level. |
| 180 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 181 | 165 | */ |
| 182 | 166 | public function get_license_level() { |
| 183 | 167 | $license_status = $this->get_license_status(); |
| 184 | 168 | |
| @@ -209,9 +193,8 @@ | ||
| 209 | 193 | * |
| 210 | 194 | * @param array{key:string|null,status:array<string,mixed>|null} $license_data License data. |
| 211 | 195 | * |
| 212 | 196 | * @return bool |
| 213 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 214 | 197 | */ |
| 215 | 198 | public function udpate_license_data( $license_data ) { |
| 216 | 199 | if ( \update_option( self::OPTION_KEY, $license_data ) ) { |
| 217 | 200 | $this->license_data = $license_data; |
| @@ -226,9 +209,8 @@ | ||
| 226 | 209 | * |
| 227 | 210 | * @param string $key License key. |
| 228 | 211 | * |
| 229 | 212 | * @return void |
| 230 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 231 | 213 | */ |
| 232 | 214 | public function update_license_key( $key ) { |
| 233 | 215 | $license_data = $this->get_license_data(); |
| 234 | 216 | |
| @@ -252,9 +234,8 @@ | ||
| 252 | 234 | * |
| 253 | 235 | * @param array<string,mixed> $license_status License status data. |
| 254 | 236 | * |
| 255 | 237 | * @return void |
| 256 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 257 | 238 | */ |
| 258 | 239 | public function update_license_status( $license_status ) { |
| 259 | 240 | $license_data = $this->get_license_data(); |
| 260 | 241 | |
| @@ -282,9 +263,8 @@ | ||
| 282 | 263 | * |
| 283 | 264 | * @param bool $as_datetime Whether to return as DateTime object. |
| 284 | 265 | * |
| 285 | 266 | * @return \DateTime|false|null |
| 286 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 287 | 267 | */ |
| 288 | 268 | public function get_license_expiration( $as_datetime = false ) { |
| 289 | 269 | $status = $this->get_license_status(); |
| 290 | 270 | |
| @@ -299,9 +279,8 @@ | ||
| 299 | 279 | * Fetch license status from remote server. |
| 300 | 280 | * This is a blocking request. |
| 301 | 281 | * |
| 302 | 282 | * @return void |
| 303 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 304 | 283 | */ |
| 305 | 284 | public function refresh_license_status() { |
| 306 | 285 | $key = $this->get_license_key(); |
| 307 | 286 | |
| @@ -323,9 +302,8 @@ | ||
| 323 | 302 | * |
| 324 | 303 | * @return array<string,mixed> License status data. |
| 325 | 304 | * |
| 326 | 305 | * @throws \Exception If there is an error. |
| 327 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 328 | 306 | */ |
| 329 | 307 | private function check_license() { |
| 330 | 308 | $api_params = [ |
| 331 | 309 | 'edd_action' => 'check_license', |
| @@ -339,10 +317,11 @@ | ||
| 339 | 317 | // Call the custom API. |
| 340 | 318 | $response = wp_remote_post( |
| 341 | 319 | self::API_URL, |
| 342 | 320 | [ |
| 343 | - 'timeout' => 15, | |
| 344 | - 'body' => $api_params, | |
| 321 | + 'timeout' => 15, | |
| 322 | + 'sslverify' => false, | |
| 323 | + 'body' => $api_params, | |
| 345 | 324 | ] |
| 346 | 325 | ); |
| 347 | 326 | |
| 348 | 327 | if ( is_wp_error( $response ) ) { |
| @@ -365,9 +344,8 @@ | ||
| 365 | 344 | * |
| 366 | 345 | * @return array<string,mixed> License status data. |
| 367 | 346 | * |
| 368 | 347 | * @throws \Exception If there is an error. |
| 369 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 370 | 348 | */ |
| 371 | 349 | public function activate_license( $key = null ) { |
| 372 | 350 | if ( ! empty( $key ) ) { |
| 373 | 351 | $this->update_license_key( $key ); |
| @@ -386,10 +364,11 @@ | ||
| 386 | 364 | // Call the custom API. |
| 387 | 365 | $response = wp_remote_post( |
| 388 | 366 | self::API_URL, |
| 389 | 367 | [ |
| 390 | - 'timeout' => 15, | |
| 391 | - 'body' => $api_params, | |
| 368 | + 'timeout' => 15, | |
| 369 | + 'sslverify' => false, | |
| 370 | + 'body' => $api_params, | |
| 392 | 371 | ] |
| 393 | 372 | ); |
| 394 | 373 | |
| 395 | 374 | // Make sure the response came back okay. |
| @@ -421,9 +400,8 @@ | ||
| 421 | 400 | * |
| 422 | 401 | * @return array<string,mixed> License status data. |
| 423 | 402 | * |
| 424 | 403 | * @throws \Exception If there is an error. |
| 425 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 426 | 404 | */ |
| 427 | 405 | public function deactivate_license() { |
| 428 | 406 | $api_params = [ |
| 429 | 407 | 'edd_action' => 'deactivate_license', |
| @@ -437,10 +415,11 @@ | ||
| 437 | 415 | // Call the custom API. |
| 438 | 416 | $response = wp_remote_post( |
| 439 | 417 | self::API_URL, |
| 440 | 418 | [ |
| 441 | - 'timeout' => 15, | |
| 442 | - 'body' => $api_params, | |
| 419 | + 'timeout' => 15, | |
| 420 | + 'sslverify' => false, | |
| 421 | + 'body' => $api_params, | |
| 443 | 422 | ] |
| 444 | 423 | ); |
| 445 | 424 | |
| 446 | 425 | // Make sure the response came back okay. |
| @@ -466,9 +445,8 @@ | ||
| 466 | 445 | * |
| 467 | 446 | * @param array<string,mixed> $license_status License status data. |
| 468 | 447 | * |
| 469 | 448 | * @return string |
| 470 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 471 | 449 | */ |
| 472 | 450 | public function get_license_error_message( $license_status ) { |
| 473 | 451 | switch ( $license_status['error'] ) { |
| 474 | 452 | case 'expired': |
| @@ -516,17 +494,10 @@ | ||
| 516 | 494 | /** |
| 517 | 495 | * Remove license. |
| 518 | 496 | * |
| 519 | 497 | * @return void |
| 520 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 521 | 498 | */ |
| 522 | 499 | public function remove_license() { |
| 523 | - if ( '' === $this->get_license_key() ) { | |
| 524 | - \delete_option( self::OPTION_KEY ); | |
| 525 | - $this->license_data = null; | |
| 526 | - return; | |
| 527 | - } | |
| 528 | - | |
| 529 | 500 | try { |
| 530 | 501 | $deactivated = $this->deactivate_license(); |
| 531 | 502 | } catch ( \Exception $e ) { |
| 532 | 503 | $deactivated = []; |
| @@ -540,9 +511,8 @@ | ||
| 540 | 511 | /** |
| 541 | 512 | * Check if license is active. |
| 542 | 513 | * |
| 543 | 514 | * @return bool |
| 544 | - * @deprecated 2.7.0 Content Control Pro 1.3.0+ owns licensing. | |
| 545 | 515 | */ |
| 546 | 516 | public function is_license_active() { |
| 547 | 517 | $license_status = $this->get_license_status(); |
| 548 | 518 | |