PluginProbe
Kubio AI Page Builder / 1.7.0
Kubio AI Page Builder v1.7.0
2.9.1 2.9.0 2.8.6 2.8.5 2.8.4 2.8.3 2.8.2 2.8.1 trunk 1.0.0 1.0.1 1.1.0 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.6.0 All 70 releases
kubio / lib / src / Core / License / CheckForm.php
CheckForm.php
48 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Kubio\Core\License;
3
4 class CheckForm {
5
6 public function __construct() {
7 add_action( 'wp_ajax_kubiowp-page-builder-check-license', array( $this, 'callCheckLicenseEndpoint' ) );
8 }
9
10 public function printForm() {
11 wp_enqueue_script( 'wp-util' );
12 add_action( 'admin_notices', array( $this, 'makeNotice' ) );
13 }
14
15 public function makeNotice() {
16 License::getInstance()->getActivationForm()->makeActivateNotice( 'kubio-page-builder-check-license', array( 'hidden' ) );
17 }
18
19 public function callCheckLicenseEndpoint() {
20 $response = Endpoint::check();
21 $response_message = $response->getMessage( true );
22
23 if ( $response->isWPError() ) {
24 $url = esc_attr( License::getInstance()->getDashboardUrl() );
25 // translators: %1$s - string with server error response
26 $response_message = sprintf( __( 'There was an error calling Kubio License Server: <code>%1$s</code>. Please contact us for support on <a href="%2$s" target="_blank">Kubio</a> website', 'kubio' ), $response_message, $url );
27 }
28
29 if ( $response->isSuccess() ) {
30 License::getInstance()->touch();
31 } else {
32 if ( ! $response->isWPError() && $response->getResponseCode() === 403 ) {
33 delete_option( 'kubiowp_builder_license_key' );
34 // translators: %s - string with server error response
35 $response_message = sprintf( __( 'Current license key was removed! Reason: %s', 'kubio' ), $response_message );
36 }
37 }
38
39 wp_send_json(
40 array(
41 'data' => $response_message,
42 'success' => $response->isSuccess(),
43 ),
44 $response->getResponseCode()
45 );
46 }
47 }
48