| 1 |
<?php |
| 2 |
/** |
| 3 |
* Display the table of products requiring licenses. |
| 4 |
* |
| 5 |
* @author Eric Daams |
| 6 |
* @package Charitable/Admin View/Settings |
| 7 |
* @copyright Copyright (c) 2019, Studio 164a |
| 8 |
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License |
| 9 |
* @since 1.0.0 |
| 10 |
* @version 1.0.0 |
| 11 |
*/ |
| 12 |
|
| 13 |
$helper = charitable_get_helper( 'licenses' ); |
| 14 |
$products = $helper->get_products(); |
| 15 |
|
| 16 |
if ( empty( $products ) ) : |
| 17 |
return; |
| 18 |
endif; |
| 19 |
?> |
| 20 |
<div class="charitable-settings-notice" style="margin-bottom: 20px;"> |
| 21 |
<p><?php _e( 'By adding your license keys, you agree for your website to send requests to wpcharitable.com to check license details and provide automatic plugin updates.', 'charitable' ); ?></p> |
| 22 |
<p><?php _e( 'Your license can be disconnected at any time.', 'charitable' ); ?></p> |
| 23 |
</div> |
| 24 |
<?php |
| 25 |
foreach ( $products as $key => $product ) : |
| 26 |
|
| 27 |
$license = $helper->get_license_details( $key ); |
| 28 |
|
| 29 |
if ( is_array( $license ) ) { |
| 30 |
$is_active = $license['valid']; |
| 31 |
$license_key = $license['license']; |
| 32 |
} else { |
| 33 |
$is_active = false; |
| 34 |
$license_key = $license; |
| 35 |
} |
| 36 |
|
| 37 |
?> |
| 38 |
<div class="charitable-settings-object charitable-licensed-product cf"> |
| 39 |
<h4><?php echo $product['name']; ?></h4> |
| 40 |
<input type="text" name="charitable_settings[licenses][<?php echo $key; ?>]" id="charitable_settings_licenses_<?php echo $key; ?>" class="charitable-settings-field" placeholder="<?php _e( 'Add your license key', 'charitable' ); ?>" value="<?php echo $license_key; ?>" /> |
| 41 |
<?php if ( $license ) : ?> |
| 42 |
<div class="license-meta"> |
| 43 |
<?php if ( $is_active ) : ?> |
| 44 |
<a href="<?php echo $helper->get_license_deactivation_url( $key ); ?>" class="button-secondary license-deactivation"><?php _e( 'Deactivate License', 'charitable' ); ?></a> |
| 45 |
<?php if ( 'lifetime' == $license['expiration_date'] ) : ?> |
| 46 |
<span class="license-expiration-date"><?php _e( 'Lifetime license', 'charitable' ); ?></span> |
| 47 |
<?php else : ?> |
| 48 |
<span class="license-expiration-date"><?php printf( '%s %s.', __( 'Expiring in', 'charitable' ), human_time_diff( strtotime( $license['expiration_date'] ), time() ) ); ?></span> |
| 49 |
<?php endif ?> |
| 50 |
<?php elseif ( is_array( $license ) ) : ?> |
| 51 |
<span class="license-invalid"><?php _e( 'This license is not valid', 'charitable' ); ?></span> |
| 52 |
<?php else : ?> |
| 53 |
<span class="license-invalid"><?php _e( 'We could not validate this license', 'charitable' ); ?></span> |
| 54 |
<?php endif ?> |
| 55 |
</div> |
| 56 |
<?php endif ?> |
| 57 |
</div> |
| 58 |
|
| 59 |
<?php |
| 60 |
endforeach; |
| 61 |
|