| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly! |
| 4 |
} |
| 5 |
|
| 6 |
if ( ! class_exists( 'WPSC_License' ) ) : |
| 7 |
|
| 8 |
final class WPSC_License { |
| 9 |
|
| 10 |
/** |
| 11 |
* Initialize this class |
| 12 |
* |
| 13 |
* @return void |
| 14 |
*/ |
| 15 |
public static function init() { |
| 16 |
|
| 17 |
add_action( 'wp_ajax_wpsc_license_sync', array( __CLASS__, 'sync_licenses' ) ); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* Activate license keys for add-ons |
| 22 |
* |
| 23 |
* @return void |
| 24 |
*/ |
| 25 |
public static function layout() { |
| 26 |
?> |
| 27 |
<div class="wrap"> |
| 28 |
<hr class="wp-header-end"> |
| 29 |
<div id="wpsc-container"> |
| 30 |
<h1> |
| 31 |
<?php esc_attr_e( 'Licenses', 'supportcandy' ); ?> |
| 32 |
<button class="sync page-title-action"><?php esc_attr_e( 'Sync', 'supportcandy' ); ?></button> |
| 33 |
</h1> |
| 34 |
</div> |
| 35 |
<p> |
| 36 |
<?php |
| 37 |
printf( |
| 38 |
/* translators: %s: Documentation link */ |
| 39 |
esc_html__( 'Activate license keys for add-ons in order to get support and updates. For detailed instructions, please visit our %s.', 'supportcandy' ), |
| 40 |
sprintf( |
| 41 |
'<a href="%s" target="_blank" rel="noopener">%s</a>', |
| 42 |
esc_url( 'https://supportcandy.net/docs/license-activation/' ), |
| 43 |
esc_html__( 'documentation page', 'supportcandy' ) |
| 44 |
) |
| 45 |
); |
| 46 |
?> |
| 47 |
</p></p> |
| 48 |
<div class="wpsc-licenses-container"> |
| 49 |
<?php do_action( 'wpsc_licenses' ); ?> |
| 50 |
</div> |
| 51 |
</div> |
| 52 |
<script> |
| 53 |
jQuery(document).ready(function(){ |
| 54 |
jQuery('button.sync').click(function(){ |
| 55 |
jQuery(this).text(supportcandy.translations.please_wait); |
| 56 |
const data = { action: 'wpsc_license_sync' }; |
| 57 |
jQuery.post(supportcandy.ajax_url, data, function (response) { |
| 58 |
window.location.reload(); |
| 59 |
}); |
| 60 |
}); |
| 61 |
}); |
| 62 |
</script> |
| 63 |
<?php |
| 64 |
} |
| 65 |
|
| 66 |
/** |
| 67 |
* Sync licenses |
| 68 |
* |
| 69 |
* @return void |
| 70 |
*/ |
| 71 |
public static function sync_licenses() { |
| 72 |
|
| 73 |
if ( ! WPSC_Functions::is_site_admin() ) { |
| 74 |
wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ) ); |
| 75 |
} |
| 76 |
|
| 77 |
do_action( 'wpsc_license_checker' ); |
| 78 |
wp_die(); |
| 79 |
} |
| 80 |
} |
| 81 |
endif; |
| 82 |
|
| 83 |
WPSC_License::init(); |
| 84 |
|