PluginProbe
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) / 1.8.12.2
Charitable – Donation & Fundraising Platform (Donation Forms, Recurring Donations & Fundraising Campaigns) v1.8.12.2
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.8.12.2, at includes/admin/views/settings/licenses.php

156 lines 6.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly.
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit;
6 }
7
8 /**
9 * Display the table of products requiring licenses.
10 *
11 * @author David Bisset
12 * @package Charitable/Admin View/Settings
13 * @copyright Copyright (c) 2023, WP Charitable LLC
14 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
15 * @since 1.0.0
16 * @version 1.8.8.6
17 */
18
19 $charitable_helper = charitable_get_helper( 'licenses' );
20 $charitable_products = $charitable_helper->get_products();
21
22 if ( empty( $charitable_products ) ) :
23 return;
24 endif;
25
26 $charitable_slug = Charitable_Addons_Directory::get_current_plan_slug();
27 $charitable_is_legacy = Charitable_Addons_Directory::is_current_plan_legacy();
28
29 if ( false !== $charitable_slug && strtolower( $charitable_slug ) !== 'lite' && ! $charitable_is_legacy ) {
30
31 // there is a valid legacy license present.
32 $charitable_new_tab_notification =
33 '<p>' .
34 sprintf(
35 wp_kses(
36 /* translators: %s - charitable.com upgrade URL. */
37 __( 'You already have a non-legacy license activated on this install, which you can deactivate <a href="%s">in the "General" tab</a>.', 'charitable' ),
38 array(
39 'a' => array(
40 'href' => array(),
41 'class' => array(),
42 'target' => array(),
43 'rel' => array(),
44 ),
45 'br' => array(),
46 'strong' => array(),
47 )
48 ),
49 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
50 ) .
51 '</p>';
52
53 ?>
54
55 <div class="charitable-settings-notice license-notice" style="margin-bottom: 20px;">
56 <p><?php esc_html_e( 'This area is reserved for older (legacy) license keys.', 'charitable' ); ?></p>
57 <p><?php echo $charitable_new_tab_notification; // phpcs:ignore ?></p>
58 </div>
59
60 <?php
61
62 } else {
63
64 $charitable_new_tab_notification =
65 '<p>' .
66 sprintf(
67 wp_kses(
68 /* translators: %s - charitable.com upgrade URL. */
69 __( 'If you have purchased your license key for <strong>Basic</strong>, <strong>Plus</strong>, <strong>Pro</strong>, or <strong>Agency / Elite</strong> recently, please enter your charitable license key <a href="%s">in the "General" tab</a>.', 'charitable' ),
70 array(
71 'a' => array(
72 'href' => array(),
73 'class' => array(),
74 'target' => array(),
75 'rel' => array(),
76 ),
77 'br' => array(),
78 'strong' => array(),
79 )
80 ),
81 esc_url( admin_url( 'admin.php?page=charitable-settings&tab=general' ) )
82 ) .
83 '</p>';
84
85 ?>
86 <div class="charitable-settings-notice license-notice" style="margin-bottom: 20px;">
87 <p><?php esc_html_e( 'This area is reserved for older (legacy) license keys.', 'charitable' ); ?></p>
88 <p><?php echo $charitable_new_tab_notification; // phpcs:ignore ?></p>
89 <p><?php esc_html_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>
90 </div>
91 <?php
92
93 $_charitable_legacy_license_info = get_transient( '_charitable_legacy_license_info' ); // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- $_charitable_legacy_license_info is a transient key used by WordPress transients API.
94
95 foreach ( $charitable_products as $charitable_key => $charitable_product ) :
96
97 $charitable_license = $charitable_helper->get_license_details( $charitable_key );
98
99 // set a default invalid message.
100 $charitable_invalid_message = __( 'This is an invalid license.', 'charitable' );
101
102 if ( is_array( $charitable_license ) ) {
103 if ( isset( $charitable_license['expiration_date'] ) && false !== $charitable_license['expiration_date'] && isset( $charitable_license['valid'] ) && false !== $charitable_license['valid'] ) {
104 $charitable_is_active = $charitable_license['valid'];
105 $charitable_license_key = $charitable_license['license'];
106 } else {
107 $charitable_is_active = false;
108 $charitable_license_key = false;
109 // this is different because we try to avoid just a BAD license vs. an invalid-but-could-be-expired license.
110 $charitable_referer = wp_get_referer();
111 if ( admin_url( 'admin.php?page=charitable-settings&tab=advanced' ) === $charitable_referer ) {
112 if ( false !== $_charitable_legacy_license_info && is_array( $_charitable_legacy_license_info ) && array_key_exists( $charitable_key, $_charitable_legacy_license_info ) && '' !== trim( $_charitable_legacy_license_info[ $charitable_key ] ) ) {
113 $charitable_invalid_message = __( 'The license was not valid.', 'charitable' );
114 } else {
115 $charitable_invalid_message = false;
116 }
117 } else {
118 $charitable_invalid_message = false;
119 }
120 }
121 } else {
122 $charitable_is_active = false;
123 $charitable_license_key = $charitable_license;
124 }
125
126 ?>
127 <div class="charitable-settings-object charitable-licensed-product">
128 <h4><?php echo esc_html( $charitable_product['name'] ); ?></h4>
129 <input type="text" name="charitable_settings[legacy_licenses][<?php echo esc_attr( $charitable_key ); ?>]" id="charitable_settings_licenses_<?php echo esc_attr( $charitable_key ); ?>" class="charitable-settings-field" placeholder="<?php esc_attr_e( 'Add your license key', 'charitable' ); ?>" value="<?php echo esc_attr( $charitable_license_key ); ?>" />
130 <?php if ( $charitable_license ) : ?>
131 <div class="license-meta">
132 <?php if ( $charitable_is_active ) : ?>
133 <a href="<?php echo esc_url( $charitable_helper->get_license_deactivation_url( $charitable_key ) ); ?>" class="button-secondary license-deactivation"><?php esc_html_e( 'Deactivate License', 'charitable' ); ?></a>
134 <?php if ( 'lifetime' === $charitable_license['expiration_date'] ) : ?>
135 <span class="license-expiration-date"><?php esc_html_e( 'Lifetime license', 'charitable' ); ?></span>
136 <?php else : ?>
137 <span class="license-expiration-date"><?php printf( '%s %s.', esc_html__( 'Expiring in', 'charitable' ), human_time_diff( strtotime( $charitable_license['expiration_date'] ), time() ) ); // phpcs:ignore ?></span>
138 <?php endif ?>
139 <?php elseif ( is_array( $charitable_license ) ) : ?>
140 <span class="license-invalid"><?php echo $charitable_invalid_message; // phpcs:ignore ?></span>
141 <?php else : ?>
142 <span class="license-invalid"><?php esc_html_e( 'We could not validate this license.', 'charitable' ); ?></span>
143 <?php endif ?>
144 </div>
145 <?php endif ?>
146 </div>
147
148 <?php
149 endforeach;
150
151
152
153 delete_transient( '_charitable_legacy_license_info' );
154
155 }
156