ad-list
5 months ago
conditions
5 months ago
notices
1 year ago
upgrades
1 year ago
ad-conditions-string-operators.php
3 months ago
checks.php
3 months ago
index.php
7 years ago
modal.php
3 months ago
overview-addons-line.php
5 months ago
overview-notice-row.php
1 year ago
overview-widget.php
1 year ago
placement-form.php
1 year ago
placement-injection-top.php
1 year ago
placement-types.php
3 years ago
placements-ad-label.php
1 year ago
placements-inline-css.php
1 year ago
placements-item.php
1 year ago
post-list-filter-dropdown.php
5 months ago
setting-license.php
1 year ago
support-callout.php
1 year ago
setting-license.php
103 lines
| 1 | <?php // phpcs:ignoreFile |
| 2 | /** |
| 3 | * Template for license fields. |
| 4 | * |
| 5 | * Do not move since it could be used by add-ons. |
| 6 | * |
| 7 | * @var string $index internal name of the add-on. |
| 8 | * @var string $plugin_name name of the add-on. |
| 9 | * @var string $options_slug slug of the add-on. |
| 10 | * @var string $license_status status code of the license. |
| 11 | */ |
| 12 | $errortext = false; |
| 13 | $expires = Advanced_Ads_Admin_Licenses::get_instance()->get_license_expires( $options_slug ); |
| 14 | $expired = false; |
| 15 | $expired_error = __( 'Your license expired.', 'advanced-ads' ); |
| 16 | |
| 17 | ob_start(); |
| 18 | ?> |
| 19 | <button type="button" class="button-secondary advads-license-activate" |
| 20 | data-addon="<?php echo esc_attr( $index ); ?>" |
| 21 | data-pluginname="<?php echo esc_attr( $plugin_name ); ?>" |
| 22 | data-optionslug="<?php echo esc_attr( $options_slug ); ?>" |
| 23 | name="advads_license_activate"><?php esc_html_e( 'Update expiry date', 'advanced-ads' ); ?></button> |
| 24 | <?php |
| 25 | $update_button = ob_get_clean(); |
| 26 | |
| 27 | $license_key_for_expired_link = $license_key ? $license_key : '%LICENSE_KEY%'; |
| 28 | //phpcs:ignore |
| 29 | $expired_error .= $expired_renew_link = ' ' . sprintf( |
| 30 | /* translators: 1: is a URL, 2: is HTML of a button. */ |
| 31 | __( 'Click on %2$s if you renewed it or have a subscription or <a href="%1$s" class="advads-renewal-link" target="_blank">renew your license</a>.', 'advanced-ads' ), // phpcs:ignore |
| 32 | 'https://wpadvancedads.com/checkout/?edd_license_key=' . esc_attr( $license_key_for_expired_link ) . '&utm_source=advanced-ads&utm_medium=link&utm_campaign=settings-licenses', |
| 33 | $update_button |
| 34 | ); |
| 35 | if ( 'lifetime' !== $expires ) { |
| 36 | $expires_time = strtotime( $expires ); |
| 37 | $days_left = ( $expires_time - time() ) / DAY_IN_SECONDS; |
| 38 | } |
| 39 | // phpcs:ignore |
| 40 | if ( 'lifetime' === $expires ) { |
| 41 | // do nothing. |
| 42 | } elseif ( $expired && $days_left <= 0 ) { |
| 43 | $plugin_url = isset( $plugin_url ) ? $plugin_url : 'https://wpadvancedads.com/'; |
| 44 | $errortext = $expired_error; |
| 45 | $expired = true; |
| 46 | } elseif ( 0 < $days_left && 31 > $days_left ) { |
| 47 | $errortext = sprintf( |
| 48 | /* translators: %d is a number of days. */ |
| 49 | esc_html__( '(%d days left)', 'advanced-ads' ), |
| 50 | $days_left |
| 51 | ); |
| 52 | } |
| 53 | $show_active = ( false !== $license_status && 'valid' === $license_status && ! $expired ) ? true : false; |
| 54 | ?> |
| 55 | <input type="text" class="regular-text advads-license-key" placeholder="<?php esc_html_e( 'License key', 'advanced-ads' ); ?>" |
| 56 | name="<?php echo esc_attr( ADVADS_SLUG ) . '-licenses'; ?>[<?php echo esc_attr( $index ); ?>]" |
| 57 | value="<?php echo esc_attr( $license_key ); ?>" |
| 58 | <?php |
| 59 | if ( false !== $license_status && 'valid' === $license_status && ! $expired ) : |
| 60 | ?> |
| 61 | readonly="readonly"<?php endif; ?>/> |
| 62 | |
| 63 | <button type="button" class="button-secondary advads-license-deactivate" |
| 64 | <?php |
| 65 | if ( 'valid' !== $license_status ) { |
| 66 | echo ' style="display: none;" '; |
| 67 | } |
| 68 | ?> |
| 69 | data-addon="<?php echo esc_attr( $index ); ?>" |
| 70 | data-pluginname="<?php echo esc_attr( $plugin_name ); ?>" |
| 71 | data-optionslug="<?php echo esc_attr( $options_slug ); ?>" |
| 72 | name="advads_license_activate"><?php esc_html_e( 'Deactivate License', 'advanced-ads' ); ?></button> |
| 73 | |
| 74 | <button type="button" class="button-primary advads-license-activate" |
| 75 | data-addon="<?php echo esc_attr( $index ); ?>" |
| 76 | data-pluginname="<?php echo esc_attr( $plugin_name ); ?>" |
| 77 | data-optionslug="<?php echo esc_attr( $options_slug ); ?>" |
| 78 | name="advads_license_activate"> |
| 79 | <?php |
| 80 | // phpcs:ignore |
| 81 | echo ( 'valid' === $license_status && ! $expired ) ? esc_html__( 'Update License', 'advanced-ads' ) : esc_html__( 'Activate License', 'advanced-ads' ); ?></button> |
| 82 | <?php |
| 83 | if ( '' === trim( $license_key ) ) { |
| 84 | $errortext = __( 'Please enter a valid license key', 'advanced-ads' ); |
| 85 | } elseif ( ! $expired && ! $errortext ) { |
| 86 | $errortext = ( 'invalid' === $license_status ) ? esc_html__( 'License key invalid', 'advanced-ads' ) : ''; |
| 87 | } |
| 88 | ?> |
| 89 | |
| 90 | <span class="advads-license-activate-active advads-notice-inline advads-check" <?php echo ( ! $show_active ) ? 'style="display: none;"' : ''; ?>><?php esc_html_e( 'active', 'advanced-ads' ); ?></span> |
| 91 | <span class="advads-license-activate-error advads-notice-inline advads-error" <?php echo ( ! $errortext ) ? 'style="display: none;"' : ''; ?>> |
| 92 | <?php |
| 93 | // phpcs:ignore |
| 94 | echo $errortext; |
| 95 | ?> |
| 96 | </span> |
| 97 | <span class="advads-license-expired-error advads-notice-inline advads-error" style="display: none;"> |
| 98 | <?php |
| 99 | // phpcs:ignore |
| 100 | echo $expired_error; |
| 101 | ?> |
| 102 | </span> |
| 103 |