PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.7.0.9
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.7.0.9
1.8.13.1 1.8.13 1.8.12.3 1.8.12.2 1.8.12.1 1.8.12 1.8.11.3 1.8.11.2 1.8.11.1 1.8.11 1.6.6 1.6.60 1.6.7 1.6.8 1.6.9 1.7.0 1.7.0.1 1.7.0.11 1.7.0.12 1.7.0.14 1.7.0.2 1.7.0.3 1.7.0.5 1.7.0.6 1.7.0.7 All 212 releases
charitable / includes / admin / views / settings / licenses.php

licenses.php in Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) 1.7.0.9, at includes/admin/views/settings/licenses.php

150 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Display the table of products requiring licenses.
4 *
5 * @author David Bisset
6 * @package Charitable/Admin View/Settings
7 * @copyright Copyright (c) 2022, WP Charitable LLC
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 $slug = Charitable_Addons_Directory::get_current_plan_slug();
21 $is_legacy = Charitable_Addons_Directory::is_current_plan_legacy();
22
23 if ( false !== $slug && strtolower( $slug ) !== 'lite' && ! $is_legacy ) {
24
25 // there is a valid legacy license present
26 $new_tab_notification =
27 '<p>' .
28 sprintf(
29 wp_kses(
30 /* translators: %s - charitable.com upgrade URL. */
31 __( 'You already have a non-legacy license activate on this install, which you can deactivate <a href="%s">in the "General" tab</a>.', 'charitable' ),
32 [
33 'a' => [
34 'href' => [],
35 'class' => [],
36 'target' => [],
37 'rel' => [],
38 ],
39 'br' => [],
40 'strong' => [],
41 ]
42 ),
43 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
44 ) .
45 '</p>';
46
47 ?>
48
49 <div class="charitable-settings-notice license-notice" style="margin-bottom: 20px;">
50 <p><?php _e( 'This area is reserved for older (legacy) license keys.', 'charitable' ); ?></p>
51 <p><?php echo $new_tab_notification; ?></p>
52 </div>
53
54 <?php
55
56 } else {
57
58 $new_tab_notification =
59 '<p>' .
60 sprintf(
61 wp_kses(
62 /* translators: %s - charitable.com upgrade URL. */
63 __( 'If you have purchased your license key for <strong>Basic</strong>, <strong>Plus</strong>, <strong>Pro</strong>, or <strong>Agency</strong> recently, please enter your Chariable license key <a href="%s">in the "General" tab</a>.', 'charitable' ),
64 [
65 'a' => [
66 'href' => [],
67 'class' => [],
68 'target' => [],
69 'rel' => [],
70 ],
71 'br' => [],
72 'strong' => [],
73 ]
74 ),
75 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
76 ) .
77 '</p>';
78
79 ?>
80 <div class="charitable-settings-notice license-notice" style="margin-bottom: 20px;">
81 <p><?php _e( 'This area is reserved for older (legacy) license keys.', 'charitable' ); ?></p>
82 <p><?php echo $new_tab_notification; ?></p>
83 <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. Your license(s) can be disconnected at any time.', 'charitable' ); ?></p>
84 </div>
85 <?php
86
87 $_charitable_legacy_license_info = get_transient( '_charitable_legacy_license_info' );
88
89 foreach ( $products as $key => $product ) :
90
91 $license = $helper->get_license_details( $key );
92
93 // set a default invalid message.
94 $invalid_message = __( 'This is an invalid license.', 'charitable' );
95
96 if ( is_array( $license ) ) {
97 if ( isset( $license['expiration_date'] ) && false !== $license['expiration_date'] && isset( $license['valid'] ) && false !== $license['valid'] ) {
98 $is_active = $license['valid'];
99 $license_key = $license['license'];
100 } else {
101 $is_active = false;
102 $license_key = false;
103 // this is different because we try to avoid just a BAD license vs. an invalid-but-could-be-expired license.
104 $referer = wp_get_referer();
105 if ( admin_url( 'admin.php?page=charitable-settings&tab=advanced' ) === $referer ) {
106 if ( false !== $_charitable_legacy_license_info && is_array( $_charitable_legacy_license_info ) && array_key_exists( $key, $_charitable_legacy_license_info ) && '' !== trim( $_charitable_legacy_license_info[ $key ] ) ) {
107 $invalid_message = __( 'The license was not valid.', 'charitable' );
108 } else {
109 $invalid_message = false;
110 }
111 } else {
112 $invalid_message = false;
113 }
114 }
115 } else {
116 $is_active = false;
117 $license_key = $license;
118 }
119
120 ?>
121 <div class="charitable-settings-object charitable-licensed-product cf">
122 <h4><?php echo $product['name']; ?></h4>
123 <input type="text" name="charitable_settings[legacy_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; ?>" />
124 <?php if ( $license ) : ?>
125 <div class="license-meta">
126 <?php if ( $is_active ) : ?>
127 <a href="<?php echo $helper->get_license_deactivation_url( $key ); ?>" class="button-secondary license-deactivation"><?php _e( 'Deactivate License', 'charitable' ); ?></a>
128 <?php if ( 'lifetime' == $license['expiration_date'] ) : ?>
129 <span class="license-expiration-date"><?php _e( 'Lifetime license', 'charitable' ); ?></span>
130 <?php else : ?>
131 <span class="license-expiration-date"><?php printf( '%s %s.', __( 'Expiring in', 'charitable' ), human_time_diff( strtotime( $license['expiration_date'] ), time() ) ); ?></span>
132 <?php endif ?>
133 <?php elseif ( is_array( $license ) ) : ?>
134 <span class="license-invalid"><?php echo $invalid_message; ?></span>
135 <?php else : ?>
136 <span class="license-invalid"><?php _e( 'We could not validate this license.', 'charitable' ); ?></span>
137 <?php endif ?>
138 </div>
139 <?php endif ?>
140 </div>
141
142 <?php
143 endforeach;
144
145
146
147 delete_transient( '_charitable_legacy_license_info' );
148
149 }
150