PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0
GiveWP – Donation Plugin and Fundraising Platform v4.18.0
4.18.0 4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 All 257 releases
← All changes | includes/admin/settings/class-settings-license.php +213 -48 2.3.0 → 4.18.0 View file →
@@ -3,9 +3,9 @@
3 3 * Give Settings Page/Tab
4 4 *
5 5 * @package Give
6 6 * @subpackage Classes/Give_Settings_License
7 - * @copyright Copyright (c) 2016, WordImpress
7 + * @copyright Copyright (c) 2016, GiveWP
8 8 * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
9 9 * @since 1.8
10 10 */
11 11
@@ -14,14 +14,16 @@
14 14 }
15 15
16 16 if ( ! class_exists( 'Give_Settings_License' ) ) :
17 17
18 - /**
19 - * Give_Settings_License.
20 - *
21 - * @sine 1.8
22 - */
18 + /**
19 + * Give_Settings_License.
20 + *
21 + * @since 4.15.0 added legacy license page notice
22 + * @since 1.8
23 + */
23 24 class Give_Settings_License extends Give_Settings_Page {
25 + protected $enable_save = false;
24 26
25 27 /**
26 28 * Constructor.
27 29 */
@@ -30,18 +32,27 @@
30 32 $this->label = esc_html__( 'Licenses', 'give' );
31 33
32 34 parent::__construct();
33 35
34 - // Filter to remove the license tab.
35 - add_filter( 'give-settings_tabs_array', array( $this, 'remove_license_tab' ), 9999999, 1 );
36 + // Do not use main form for this tab.
37 + if ( give_get_current_setting_tab() === $this->id ) {
36 38
39 + // Remove default parent form.
40 + add_action( 'give-settings_open_form', '__return_empty_string' );
41 + add_action( 'give-settings_close_form', '__return_empty_string' );
42 +
43 + lw_harbor_display_legacy_license_page_notice('GiveWP');
44 +
45 + // Refresh licenses when visit license setting page.
46 + give_refresh_licenses();
47 + }
37 48 }
38 49
39 50 /**
40 51 * Get settings array.
41 52 *
53 + * @return array
42 54 * @since 1.8
43 - * @return array
44 55 */
45 56 public function get_settings() {
46 57 $settings = array();
47 58
@@ -53,11 +64,11 @@
53 64
54 65 /**
55 66 * Filter the settings.
56 67 *
68 + * @param array $settings
69 + *
57 70 * @since 1.8
58 - *
59 - * @param array $settings
60 71 */
61 72 $settings = apply_filters( 'give_get_settings_' . $this->id, $settings );
62 73
63 74 // Output.
@@ -64,51 +75,205 @@
64 75 return $settings;
65 76 }
66 77
67 78 /**
68 - * Remove the license tab if no Give addon
69 - * is activated.
79 + * Render license key field
70 80 *
71 - * @param array $tabs Give Settings Tabs.
72 - *
73 - * @since 2.1.4
74 - *
75 - * @return array
81 + * @since 2.5.0
76 82 */
77 - public function remove_license_tab( $tabs ) {
78 - /**
79 - * Remove the license tab if no Give licensed addon
80 - * is activated.
81 - */
82 - if ( ! $this->is_show_setting_page() ) {
83 - unset( $tabs['licenses'] );
84 - }
83 + public function output() {
84 + ob_start();
85 + ?>
86 + <div class="give-license-settings-wrap">
85 87
86 - return $tabs;
87 - }
88 + <div class="give-grid-row">
88 89
89 - /**
90 - * Returns if at least one Give addon is activated.
91 - * Note: note only for internal logic
92 - *
93 - * @since 2.1.4
94 - * @access private
95 - *
96 - * @return bool
97 - */
98 - private function is_show_setting_page() {
99 - $licensed_addons = Give_License::get_licensed_addons();
100 - $activated_plugins = get_option( 'active_plugins', array() );
90 + <div class="give-grid-col-6">
91 + <div id="give-license-activator-wrap" class="give-license-top-widget">
92 + <div id="give-license-activator-inner">
101 93
102 - // Get list of network enabled plugin.
103 - if ( is_multisite() ) {
104 - $sitewide_activated_plugins = array_keys( get_site_option( 'active_sitewide_plugins', array() ) );
105 - $activated_plugins = ! empty( $activated_plugins )
106 - ? array_merge( $sitewide_activated_plugins, $activated_plugins )
107 - : $sitewide_activated_plugins;
108 - }
94 + <h2 class="give-license-widget-heading">
95 + <span class="dashicons dashicons-plugins-checked"></span>
96 + <?php _e( 'Activate an Add-on License', 'give' ); ?>
97 + </h2>
109 98
110 - return (bool) count( array_intersect( $activated_plugins, $licensed_addons ) );
99 + <p class="give-field-description">
100 + <?php
101 + printf(
102 + __( 'Enter your license key below to unlock your GiveWP add-ons. You can access your licenses anytime from the <a href="%1$s" target="_blank">My Account</a> section on the GiveWP website. ', 'give' ),
103 + Give_License::get_account_url()
104 + );
105 + ?>
106 + </p>
107 +
108 + <form method="post" action="" class="give-license-activation-form">
109 +
110 + <div class="give-license-notices"></div>
111 +
112 + <?php wp_nonce_field( 'give-license-activator-nonce', 'give_license_activator_nonce' ); ?>
113 +
114 + <label
115 + for="give-license-activator"
116 + class="screen-reader-text">
117 + <?php _e( 'Activate License', 'give' ); ?>
118 + </label>
119 +
120 + <input
121 + id="give-license-activator"
122 + type="text"
123 + name="give_license_key"
124 + placeholder="<?php _e( 'Enter your license key', 'give' ); ?>"
125 + />
126 +
127 + <input
128 + data-activate="<?php _e( 'Activate License', 'give' ); ?>"
129 + data-activating="<?php _e( 'Verifying License...', 'give' ); ?>"
130 + value="<?php _e( 'Activate License', 'give' ); ?>"
131 + type="submit"
132 + class="button button-primary"
133 + />
134 +
135 + </form>
136 +
137 + </div>
138 + </div>
139 + </div><!-- /.give-grid-col-6 -->
140 +
141 + <div class="give-grid-col-6">
142 + <div id="give-addon-uploader-wrap" class="give-license-top-widget"
143 + ondragover="event.preventDefault()">
144 + <div id="give-addon-uploader-inner">
145 + <h2 class="give-license-widget-heading">
146 + <span class="dashicons dashicons-upload"></span>
147 + <?php _e( 'Upload and Activate an Add-on', 'give' ); ?>
148 + </h2>
149 +
150 + <?php if ( ! is_multisite() ) : ?>
151 +
152 + <p class="give-field-description">
153 + <?php
154 + printf(
155 + __( 'Drag an add-on zip file below to upload and activate it. Access your downloads by activating a license or via the <a href="%1$s" target="_blank">My Downloads</a> section on the GiveWP website. ', 'give' ),
156 + Give_License::get_downloads_url()
157 + );
158 + ?>
159 + </p>
160 +
161 + <?php if ( 'direct' !== get_filesystem_method() ) : ?>
162 + <div class="give-notice notice notice-error inline">
163 + <p>
164 + <?php
165 + echo sprintf(
166 + __( 'Sorry, you can not upload plugin from here because we do not have direct access to file system. Please <a href="%1$s" target="_blank">click here</a> to upload GiveWP Add-on.', 'give' ),
167 + admin_url( 'plugin-install.php?tab=upload' )
168 + );
169 + ?>
170 + </p>
171 + </div>
172 + <?php else : ?>
173 + <div class="give-upload-addon-form-wrap">
174 + <form
175 + method="post"
176 + enctype="multipart/form-data"
177 + class="give-upload-addon-form"
178 + action="/">
179 +
180 + <div class="give-addon-upload-notices"></div>
181 +
182 + <div class="give-activate-addon-wrap">
183 + <p><span
184 + class="dashicons dashicons-yes"></span> <?php _e( 'Add-on succesfully uploaded.', 'give' ); ?>
185 + </p>
186 + <button
187 + class="give-activate-addon-btn button-primary"
188 + data-activate="<?php _e( 'Activate Add-on', 'give' ); ?>"
189 + data-activating="<?php _e( 'Activating Add-on...', 'give' ); ?>"
190 + ><?php _e( 'Activate Add-on', 'give' ); ?></button>
191 + </div>
192 +
193 + <?php wp_nonce_field( 'give-upload-addon', '_give_upload_addon' ); ?>
194 +
195 + <p class="give-upload-addon-instructions">
196 + <?php _e( 'Drag a plugin zip file here to upload', 'give' ); ?><br>
197 + <span><?php _e( 'or', 'give' ); ?></span>
198 + </p>
199 +
200 + <label for="give-upload-addon-file-select" class="button button-small">
201 + <?php _e( 'Select a File', 'give' ); ?>
202 + </label>
203 +
204 + <input
205 + id="give-upload-addon-file-select"
206 + type="file"
207 + name="addon"
208 + value="<?php _e( 'Select File', 'give' ); ?>"
209 + />
210 +
211 + </form>
212 + </div>
213 + <?php endif; ?>
214 + <?php
215 + else :
216 + printf(
217 + __( 'Because of security reasons you can not upload add-ons from here. Please <a href="%1$s" target="_blank">visit network plugin install page</a> to install add-ons.', 'give' ),
218 + network_admin_url( 'plugin-install.php' )
219 + );
220 + ?>
221 + <?php endif; ?>
222 + </div>
223 + </div>
224 + </div>
225 + </div>
226 +
227 + <div class="give-grid-row<?php echo get_option( 'give_licenses', array() ) ? '' : ' give-hidden'; ?>">
228 + <div class="give-grid-col-12">
229 +
230 + <div class="give-licenses-list-header give-clearfix">
231 + <h2><?php _e( 'Licenses and Add-ons', 'give' ); ?></h2>
232 +
233 + <?php
234 + $refresh_status = Give_License::refresh_license_status();
235 + $is_allow_refresh = ( $refresh_status['compare'] === date( 'Ymd' ) && 5 > $refresh_status['count'] ) || ( $refresh_status['compare'] < date( 'Ymd' ) );
236 + $button_title = __( 'Refresh limit reached. Licenses can only be refreshed 5 times per day.', 'give' );
237 + $local_date = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $refresh_status['time'] ) ) );
238 + ?>
239 +
240 + <div id="give-refresh-button-wrap">
241 + <button id="give-button__refresh-licenses"
242 + class="button-secondary"
243 + data-activate="<?php _e( 'Refresh All Licenses', 'give' ); ?>"
244 + data-activating="<?php _e( 'Refreshing All Licenses...', 'give' ); ?>"
245 + data-nonce="<?php echo wp_create_nonce( 'give-refresh-all-licenses' ); ?>"
246 + <?php echo $is_allow_refresh ? '' : 'disabled'; ?>
247 + <?php echo $is_allow_refresh ? '' : sprintf( 'title="%1$s"', $button_title ); ?>>
248 + <?php _e( 'Refresh All Licenses', 'give' ); ?>
249 + </button>
250 + <span id="give-last-refresh-notice">
251 + <?php
252 + echo sprintf(
253 + __( 'Last refreshed on %1$s at %2$s', 'give' ),
254 + date( give_date_format(), $local_date ),
255 + date( 'g:i a', $local_date )
256 + );
257 + ?>
258 + </span>
259 + </div>
260 +
261 + <hr>
262 + <p class="give-field-description"><?php _e( 'The following list displays your add-ons and their corresponding activation and license statuses.', 'give' ); ?></p>
263 +
264 + </div>
265 +
266 + <section id="give-licenses-container">
267 + <?php echo Give_License::render_licenses_list(); ?>
268 + </section>
269 +
270 + </div>
271 + </div>
272 + </div>
273 +
274 + <?php
275 + echo ob_get_clean();
111 276 }
112 277 }
113 278
114 279 endif;