| @@ -8,8 +8,10 @@ | ||
| 8 | 8 | * @license https://opensource.org/licenses/gpl-license GNU Public License |
| 9 | 9 | * @since 2.5.0 |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | +use Give\VendorOverrides\Harbor\Actions\HarborHasLoaded; | |
| 13 | + | |
| 12 | 14 | // Exit if accessed directly. |
| 13 | 15 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | 16 | exit; |
| 15 | 17 | } |
| @@ -201,8 +203,9 @@ | ||
| 201 | 203 | * Ajax license inquiry handler |
| 202 | 204 | * |
| 203 | 205 | * Note: only for internal use |
| 204 | 206 | * |
| 207 | + * @since 4.16.7 Redirect unified license keys (LWSW-) to the Unified License Manager, when it is available. | |
| 205 | 208 | * @since 2.5.0 |
| 206 | 209 | */ |
| 207 | 210 | function give_get_license_info_handler() { |
| 208 | 211 | check_admin_referer( 'give-license-activator-nonce' ); |
| @@ -221,8 +224,26 @@ | ||
| 221 | 224 | if ( ! $license_key ) { |
| 222 | 225 | wp_send_json_error( |
| 223 | 226 | [ |
| 224 | 227 | 'errorMsg' => __( 'You entered an invalid key. Confirm your license key on your GiveWP dashboard and try again.', 'give' ), |
| 228 | + ] | |
| 229 | + ); | |
| 230 | + | |
| 231 | + } elseif ( 0 === stripos( $license_key, 'LWSW-' ) ) { | |
| 232 | + // The Unified License Manager is only available once a premium add-on is installed and active. | |
| 233 | + $harborHasLoaded = give( HarborHasLoaded::class )(); | |
| 234 | + | |
| 235 | + $error_message = $harborHasLoaded | |
| 236 | + ? sprintf( | |
| 237 | + /* translators: %s: URL to the Unified License Manager page */ | |
| 238 | + __( 'This is a unified license key. To activate it, enter your license in the <a href="%s" target="_blank">Unified License Manager</a> instead.', 'give' ), | |
| 239 | + esc_url( lw_harbor_get_license_page_url() ) | |
| 240 | + ) | |
| 241 | + : __( 'This is a unified license key. It can be added from the Unified License Manager, which appears under GiveWP > Licensing once an add-on is installed.', 'give' ); | |
| 242 | + | |
| 243 | + wp_send_json_error( | |
| 244 | + [ | |
| 245 | + 'errorMsg' => $error_message, | |
| 225 | 246 | ] |
| 226 | 247 | ); |
| 227 | 248 | |
| 228 | 249 | } elseif ( |