PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / 2.6.2
GiveWP – Donation Plugin and Fundraising Platform v2.6.2
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 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / add-ons / actions.php
give / includes / admin / add-ons Last commit date
actions.php 6 years ago
actions.php
684 lines
1 <?php
2 /**
3 * Admin Add-ons Actions
4 *
5 * @package Give
6 * @subpackage Admin/Add-ons/Actions
7 * @copyright Copyright (c) 2019, GiveWP
8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 * @since 2.5.0
10 */
11
12 // Exit if accessed directly.
13 if ( ! defined( 'ABSPATH' ) ) {
14 exit;
15 }
16
17 /**
18 * Ajax addon upload handler
19 *
20 * Note: only for internal use
21 *
22 * @since 2.5.0
23 */
24 function give_upload_addon_handler() {
25 /* @var WP_Filesystem_Direct $wp_filesystem */
26 global $wp_filesystem;
27
28 check_admin_referer( 'give-upload-addon' );
29
30 // Remove version from file name.
31 $filename = preg_replace( array( '/\(\d\).zip/', '/(.\d).*[\(\d\)]/' ), '', $_FILES['file']['name'] );
32 $filename = basename( trim( $filename ), '.zip' );
33
34 // Bailout if user does not has permission.
35 if ( ! current_user_can( 'upload_plugins' ) ) {
36 wp_send_json_error( array( 'errorMsg' => __( 'Sorry, you are not allowed to upload add-ons on this site.', 'give' ) ) );
37 }
38
39 $access_type = get_filesystem_method();
40
41 if ( 'direct' !== $access_type ) {
42 wp_send_json_error(
43 array(
44 'errorMsg' => sprintf(
45 __( 'Sorry, you can not upload plugins because GiveWP does not have direct access to the file system. Please <a href="%1$s" target="_blank">click here</a> to upload the add-on.', 'give' ),
46 admin_url( 'plugin-install.php?tab=upload' )
47 ),
48 )
49 );
50 }
51
52 $file_type = wp_check_filetype( $_FILES['file']['name'], array( 'zip' => 'application/zip' ) );
53
54 if ( empty( $file_type['ext'] ) ) {
55 wp_send_json_error( array( 'errorMsg' => __( 'Only zip file type allowed to upload. Please upload a valid add-on file.', 'give' ) ) );
56 }
57
58 $give_addons_list = give_get_plugins();
59 $is_addon_installed = array();
60
61 if ( ! empty( $give_addons_list ) ) {
62 foreach ( $give_addons_list as $addon => $give_addon ) {
63 if ( false !== stripos( $addon, $filename ) ) {
64 $is_addon_installed = $give_addon;
65 }
66 }
67 }
68
69 // Bailout if addon already installed
70 if ( ! empty( $is_addon_installed ) ) {
71 wp_send_json_error(
72 array(
73 'errorMsg' => __( 'This add-on is already installed.', 'give' ),
74 'pluginInfo' => $is_addon_installed,
75 )
76 );
77 }
78
79 $upload_status = wp_handle_upload( $_FILES['file'], array( 'test_form' => false ) );
80
81 // Bailout if has any upload error
82 if ( empty( $upload_status['file'] ) ) {
83 wp_send_json_error( $upload_status );
84 }
85
86 // @todo: check how WordPress verify plugin files before uploading to plugin directory
87
88 /* you can safely run request_filesystem_credentials() without any issues and don't need to worry about passing in a URL */
89 $creds = request_filesystem_credentials( site_url() . '/wp-admin/', '', false, false, array() );
90
91 /* initialize the API */
92 if ( ! WP_Filesystem( $creds ) ) {
93 /* any problems and we exit */
94 wp_send_json_error(
95 array(
96 'errorMsg' => __( 'File system does not load correctly.', 'give' ),
97 )
98 );
99 }
100
101 $unzip_status = unzip_file( $upload_status['file'], $wp_filesystem->wp_plugins_dir() );
102
103 // Remove file.
104 @unlink( $upload_status['file'] );
105
106 // Bailout if not able to unzip file successfully
107 if ( is_wp_error( $unzip_status ) ) {
108 wp_send_json_error(
109 array(
110 'errorMsg' => $unzip_status,
111 )
112 );
113 }
114
115 // Delete cache and get current installed addon plugin path.
116 wp_clean_plugins_cache( true );
117
118 $give_addons_list = give_get_plugins();
119 $installed_addon = array();
120
121 if ( ! empty( $give_addons_list ) ) {
122 foreach ( $give_addons_list as $addon => $give_addon ) {
123 if ( false !== stripos( $addon, $filename ) ) {
124 $installed_addon = $give_addon;
125 $installed_addon['path'] = $addon;
126 }
127 }
128 }
129
130 wp_send_json_success(
131 array(
132 'pluginPath' => $installed_addon['path'],
133 'pluginName' => $installed_addon['Name'],
134 'nonce' => wp_create_nonce( "give_activate-{$installed_addon['path']}" ),
135 'licenseSectionHtml' => Give_License::render_licenses_list(),
136 )
137 );
138 }
139
140 add_action( 'wp_ajax_give_upload_addon', 'give_upload_addon_handler' );
141
142 /**
143 * Ajax license inquiry handler
144 *
145 * Note: only for internal use
146 *
147 * @since 2.5.0
148 */
149 function give_get_license_info_handler() {
150 check_admin_referer( 'give-license-activator-nonce' );
151
152 // check user permission.
153 if ( ! current_user_can( 'manage_give_settings' ) ) {
154 give_die();
155 }
156
157 $license_key = ! empty( $_POST['license'] ) ? give_clean( $_POST['license'] ) : '';
158 $is_activating_single_license = ! empty( $_POST['single'] ) ? absint( $_POST['single'] ) : '';
159 $is_reactivating_license = ! empty( $_POST['reactivate'] ) ? absint( $_POST['reactivate'] ) : '';
160 $plugin_slug = $is_activating_single_license ? give_clean( $_POST['addon'] ) : '';
161 $licenses = get_option( 'give_licenses', array() );
162
163 if ( ! $license_key ) {
164 wp_send_json_error(
165 array(
166 'errorMsg' => __( 'Sorry, you entered an invalid key.', 'give' ),
167 )
168 );
169
170 } elseif (
171 ! $is_reactivating_license
172 && array_key_exists( $license_key, $licenses )
173 ) {
174 // If admin already activated license but did not install add-on then send license info show notice to admin with download link.
175 $license = $licenses[ $license_key ];
176 if ( empty( $license['is_all_access_pass'] ) ) {
177 $plugin_data = Give_License::get_plugin_by_slug( $license['plugin_slug'] );
178
179 // Plugin license activated but does not install, sent notice which allow admin to download add-on.
180 if ( empty( $plugin_data ) ) {
181 wp_send_json_success( $license );
182 }
183 }
184
185 wp_send_json_error(
186 array(
187 'errorMsg' => __( 'This license key is already in use on this website.', 'give' ),
188 )
189 );
190 }
191
192 // Check license.
193 $check_license_res = Give_License::request_license_api(
194 array(
195 'edd_action' => 'check_license',
196 'license' => $license_key,
197 ),
198 true
199 );
200
201 // Make sure there are no errors.
202 if ( is_wp_error( $check_license_res ) ) {
203 wp_send_json_error(
204 array(
205 'errorMsg' => $check_license_res->get_error_message(),
206 )
207 );
208 }
209
210 // Check if license valid or not.
211 if ( ! $check_license_res['success'] ) {
212 wp_send_json_error(
213 array(
214 'errorMsg' => sprintf(
215 __( 'Sorry, this license was unable to activate because the license status returned as <code>%2$s</code>. Please visit your <a href="%1$s" target="_blank">license dashboard</a> to check the details and access priority support.', 'give' ),
216 Give_License::get_account_url(),
217 $check_license_res['license']
218 ),
219 )
220 );
221 }
222
223 if (
224 $is_activating_single_license
225 && ! empty( $check_license_res['plugin_slug'] )
226 && $plugin_slug !== $check_license_res['plugin_slug']
227 ) {
228 wp_send_json_error(
229 array(
230 'errorMsg' => sprintf(
231 __( 'Sorry, we are unable to activate this license because this key does not belong to this add-on. Please visit your <a href="%1$s" target="_blank">license dashboard</a> to check the details and access priority support.', 'give' ),
232 Give_License::get_account_url()
233 ),
234 )
235 );
236 }
237
238 // Activate license.
239 $activate_license_res = Give_License::request_license_api(
240 array(
241 'edd_action' => 'activate_license',
242 'item_name' => $check_license_res['item_name'],
243 'license' => $license_key,
244 ),
245 true
246 );
247
248 if ( is_wp_error( $activate_license_res ) ) {
249 wp_send_json_error(
250 array(
251 'errorMsg' => $check_license_res->get_error_message(),
252 )
253 );
254 }
255
256 // Return error if license activation is not success and admin is not reactivating add-on.
257 if ( ! $is_reactivating_license && ! $activate_license_res['success'] ) {
258
259 $response['errorMsg'] = sprintf(
260 __( 'Sorry, this license was unable to activate because the license status returned as <code>%2$s</code>. Please visit your <a href="%1$s" target="_blank">license dashboard</a> to check the details and access priority support.', 'give' ),
261 Give_License::get_account_url(),
262 $check_license_res['license']
263 );
264
265 wp_send_json_error( $response );
266 }
267
268 $check_license_res['license'] = $activate_license_res['license'];
269 $check_license_res['site_count'] = $activate_license_res['site_count'];
270 $check_license_res['activations_left'] = $activate_license_res['activations_left'];
271
272 $licenses[ $check_license_res['license_key'] ] = $check_license_res;
273 update_option( 'give_licenses', $licenses );
274
275 // Get license section HTML.
276 $response = $check_license_res;
277 $response['html'] = $is_activating_single_license && empty( $check_license_res['is_all_access_pass'] )
278 ? Give_License::html_by_plugin( Give_License::get_plugin_by_slug( $check_license_res['plugin_slug'] ) )
279 : Give_License::render_licenses_list();
280
281 // Return error if license activation is not success and admin is reactivating add-on.
282 if ( $is_reactivating_license && ! $activate_license_res['success'] ) {
283
284 $response['errorMsg'] = sprintf(
285 __( 'Sorry, this license was unable to activate because the license status returned as <code>%2$s</code>. Please visit your <a href="%1$s" target="_blank">license dashboard</a> to check the details and access priority support.', 'give' ),
286 Give_License::get_account_url(),
287 $check_license_res['license']
288 );
289
290 wp_send_json_error( $response );
291 }
292
293 // Tell WordPress to look for updates.
294 give_refresh_licenses();
295
296 wp_send_json_success( $response );
297 }
298
299 add_action( 'wp_ajax_give_get_license_info', 'give_get_license_info_handler' );
300
301
302 /**
303 * Activate addon handler
304 *
305 * Note: only for internal use
306 *
307 * @since 2.5.0
308 */
309 function give_activate_addon_handler() {
310 $plugin_path = give_clean( $_POST['plugin'] );
311
312 check_admin_referer( "give_activate-{$plugin_path}" );
313
314 // check user permission.
315 if ( ! current_user_can( 'manage_give_settings' ) ) {
316 give_die();
317 }
318
319 $status = activate_plugin( $plugin_path );
320
321 if ( is_wp_error( $status ) ) {
322 wp_send_json_error( array( 'errorMsg' => $status->get_error_message() ) );
323 }
324
325 // Tell WordPress to look for updates.
326 give_refresh_licenses();
327
328 wp_send_json_success(
329 array(
330 'licenseSectionHtml' => Give_License::render_licenses_list(),
331 )
332 );
333 }
334
335 add_action( 'wp_ajax_give_activate_addon', 'give_activate_addon_handler' );
336
337
338 /**
339 * deactivate addon handler
340 *
341 * Note: only for internal use
342 *
343 * @since 2.5.0
344 */
345 function give_deactivate_license_handler() {
346 $license = give_clean( $_POST['license'] );
347 $item_name = give_clean( $_POST['item_name'] );
348 $plugin_dirname = give_clean( $_POST['plugin_dirname'] );
349
350 if ( ! $license || ! $item_name ) {
351 wp_send_json_error();
352 }
353
354 check_admin_referer( "give-deactivate-license-{$item_name}" );
355
356 // check user permission.
357 if ( ! current_user_can( 'manage_give_settings' ) ) {
358 give_die();
359 }
360
361 $give_licenses = get_option( 'give_licenses', array() );
362
363 if ( empty( $give_licenses[ $license ] ) ) {
364 wp_send_json_error(
365 array(
366 'errorMsg' => __( 'We are unable to deactivate invalid license', 'give' ),
367 )
368 );
369 }
370
371 /* @var array|WP_Error $response */
372 $response = Give_License::request_license_api(
373 array(
374 'edd_action' => 'deactivate_license',
375 'license' => $license,
376 'item_name' => $item_name,
377 ),
378 true
379 );
380
381 if ( is_wp_error( $response ) ) {
382 wp_send_json_error(
383 array(
384 'errorMsg' => $response->get_error_message(),
385 'response' => $license,
386 )
387 );
388 }
389
390 $is_all_access_pass = $give_licenses[ $license ]['is_all_access_pass'];
391
392 if ( ! empty( $give_licenses[ $license ] ) ) {
393 unset( $give_licenses[ $license ] );
394 update_option( 'give_licenses', $give_licenses );
395 }
396
397 $response['html'] = $is_all_access_pass
398 ? Give_License::render_licenses_list()
399 : Give_License::html_by_plugin( Give_License::get_plugin_by_slug( $plugin_dirname ) );
400
401 $response['msg'] = __( 'You have successfully deactivated the license.', 'give' );
402
403 // Tell WordPress to look for updates.
404 give_refresh_licenses();
405
406 wp_send_json_success( $response );
407 }
408
409 add_action( 'wp_ajax_give_deactivate_license', 'give_deactivate_license_handler' );
410
411
412 /**
413 * Refresh all addons licenses handler
414 *
415 * Note: only for internal use
416 *
417 * @since 2.5.0
418 */
419 function give_refresh_all_licenses_handler() {
420 check_admin_referer( 'give-refresh-all-licenses' );
421
422 // check user permission.
423 if ( ! current_user_can( 'manage_give_settings' ) ) {
424 give_die();
425 }
426
427 $data = Give_License::refresh_license_status();
428
429 // Update date and reset counter.
430 if ( $data['compare'] === date( 'Ymd' ) && 5 <= $data['count'] ) {
431 wp_send_json_error();
432 }
433
434 // Update date and reset counter.
435 if ( $data['compare'] < date( 'Ymd' ) ) {
436 $data['compare'] = date( 'Ymd' );
437 $data['count'] = 0;
438 }
439
440 // Update time.
441 $data['time'] = time();
442
443 ++ $data['count'];
444
445 update_option( 'give_licenses_refreshed_last_checked', $data, 'no' );
446
447 give_refresh_licenses();
448
449 $local_date = strtotime( get_date_from_gmt( date( 'Y-m-d H:i:s', $data['time'] ) ) );
450 wp_send_json_success(
451 array(
452 'html' => Give_License::render_licenses_list(),
453 'refreshButton' => 5 <= $data['count'],
454 'refreshStatus' => $data,
455 'lastUpdateMsg' => sprintf(
456 __( 'Last refreshed on %1$s at %2$s', 'give' ),
457 date( give_date_format(), $local_date ),
458 date( 'g:i a', $local_date )
459 ),
460 )
461 );
462 }
463
464 add_action( 'wp_ajax_give_refresh_all_licenses', 'give_refresh_all_licenses_handler' );
465
466
467 /**
468 * Updates information on the "View version x.x details" page with custom data.
469 * Note: only for internal use
470 *
471 * @param mixed $_data
472 * @param string $_action
473 * @param object $_args
474 *
475 * @return object $_data
476 * @since 2.5.0
477 * @uses api_request()
478 */
479 function give_plugins_api_filter( $_data, $_action = '', $_args = null ) {
480 // Exit.
481 if ( 'plugin_information' !== $_action ) {
482 return $_data;
483 }
484
485 $plugin = Give_License::get_plugin_by_slug( $_args->slug );
486
487 if (
488 ! $plugin
489 || 'add-on' !== $plugin['Type']
490 || false === strpos( $_args->slug, 'give-' )
491 ) {
492 return $_data;
493 }
494
495 $plugin_data = get_site_transient( 'update_plugins' );
496
497 if ( ! $plugin_data ) {
498 give_refresh_licenses();
499 }
500
501 $plugin_data = ! empty( $plugin_data->response[ $plugin['Path'] ] )
502 ? $plugin_data->response[ $plugin['Path'] ]
503 : array();
504
505 if ( ! $plugin_data ) {
506 return $_data;
507 }
508
509 $_data = $plugin_data;
510
511 return $_data;
512 }
513
514 add_filter( 'plugins_api', 'give_plugins_api_filter', 9999, 3 );
515
516
517 /**
518 * Check add-ons updates when WordPress check plugin updates
519 *
520 * @since 2.5.0
521 */
522 add_filter( 'pre_set_site_transient_update_plugins', 'give_check_addon_updates', 999, 1 );
523
524
525 /**
526 * Show plugin update notification on multi-site
527 *
528 * @param string $file
529 * @param array $plugin
530 *
531 * @since 2.5.0
532 */
533 function give_show_update_notification_on_multisite( $file, $plugin ) {
534 if ( is_network_admin() ) {
535 return;
536 }
537
538 if ( ! current_user_can( 'update_plugins' ) ) {
539 return;
540 }
541
542 if ( ! is_multisite() ) {
543 return;
544 }
545
546 if (
547 ! $plugin
548 || empty( $plugin['slug'] )
549 || false === strpos( $plugin['slug'], 'give-' )
550 ) {
551 return;
552 }
553
554 $plugin_data = Give_License::get_plugin_by_slug( $plugin['slug'] );
555
556 // Only show notices for Give add-ons
557 if ( 'add-on' !== $plugin_data['Type'] ) {
558 return;
559 }
560
561 // Do not print any message if updates does not exist.
562 $update_cache = get_site_transient( 'update_plugins' );
563
564 if ( ! isset( $update_cache->response[ $file ] ) ) {
565 return;
566 }
567
568 if ( ! empty( $update_cache->response[ $plugin_data['Path'] ] ) && version_compare( $plugin_data['Version'], $plugin['new_version'], '<' ) ) {
569 printf(
570 '<tr class="plugin-update-tr %3$s" id="%1$s-update" data-slug="%1$s" data-plugin="%2$s">',
571 $plugin['slug'],
572 $file,
573 'active' === $plugin_data['Status'] ? 'active' : 'inactive'
574 );
575
576 echo '<td colspan="3" class="plugin-update colspanchange">';
577 echo '<div class="update-message notice inline notice-warning notice-alt"><p>';
578
579 $changelog_link = self_admin_url( "plugin-install.php?tab=plugin-information&plugin={$plugin['slug']}&section=changelog&TB_iframe=true&width=772&height=299" );
580
581 if ( empty( $plugin['download_link'] ) ) {
582 printf(
583 __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give' ),
584 esc_html( $plugin_data['Name'] ),
585 '<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
586 esc_html( $plugin['new_version'] ),
587 '</a>'
588 );
589 } else {
590 printf(
591 __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s or %5$supdate now%6$s.', 'give' ),
592 esc_html( $plugin_data['Name'] ),
593 '<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
594 esc_html( $plugin['new_version'] ),
595 '</a>',
596 '<a target="_blank" class="update-link" href="' . esc_url( wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $file, 'upgrade-plugin_' . $file ) ) . '">',
597 '</a>'
598 );
599 }
600
601 do_action( "in_plugin_update_message-{$file}", $plugin, $plugin );
602
603 echo '</p></div></td></tr>';
604 }
605 }
606
607 add_action( 'after_plugin_row', 'give_show_update_notification_on_multisite', 10, 2 );
608
609 /**
610 * Show plugin update notification on single site
611 *
612 * @param $file
613 * @param $plugin
614 *
615 * @since 2.5.0
616 */
617 function give_show_update_notification_on_single_site( $file, $plugin ) {
618 if ( ! current_user_can( 'update_plugins' ) || is_multisite() ) {
619 return;
620 }
621
622 if (
623 ! $plugin
624 || empty( $plugin['slug'] )
625 || false === strpos( $plugin['slug'], 'give-' )
626 ) {
627 return;
628 }
629
630 $plugin_data = Give_License::get_plugin_by_slug( $plugin['slug'] );
631
632 // Only show notices for Give add-ons
633 if (
634 'add-on' !== $plugin_data['Type']
635 || $plugin_data['License']
636 ) {
637 return;
638 }
639
640 // Do not print any message if updates does not exist.
641 $update_plugins = get_site_transient( 'update_plugins' );
642 if ( ! isset( $update_plugins->response[ $file ] ) ) {
643 return;
644 }
645
646 // Remove core update notice.
647 remove_action( "after_plugin_row_{$file}", 'wp_plugin_update_row' );
648
649 $update_notice_wrap = '<tr class="plugin-update-tr %3$s"><td colspan="3" class="colspanchange"><div class="update-message notice inline notice-warning notice-alt give-invalid-license"><p>%1$s %2$s</p></div></td></tr>';
650 $changelog_link = self_admin_url( "plugin-install.php?tab=plugin-information&plugin={$plugin['slug']}&section=changelog&TB_iframe=true&width=772&height=299" );
651
652 echo sprintf(
653 $update_notice_wrap,
654 sprintf(
655 __( 'There is a new version of %1$s available. %2$sView version %3$s details%4$s.', 'give' ),
656 esc_html( $plugin_data['Name'] ),
657 '<a target="_blank" class="thickbox open-plugin-details-modal" href="' . esc_url( $changelog_link ) . '">',
658 esc_html( $plugin['new_version'] ),
659 '</a>'
660 ),
661 sprintf(
662 'Please <a href="%1$s" target="_blank">activate your license</a> to receive updates and support.',
663 esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-settings&tab=licenses' ) )
664 ),
665 'active' === $plugin_data['Status'] ? 'active' : 'inactive'
666 );
667 }
668
669 add_action( 'after_plugin_row', 'give_show_update_notification_on_single_site', 1, 2 );
670
671 /**
672 * Look for Give core add-ons update when someone manually presses the "Check Again" button within WP's Dashboard > Updates
673 *
674 * @since 2.5.11
675 */
676 function give_refresh_license_on_force_check() {
677 if ( isset( $_GET['force-check'] ) ) {
678 give_refresh_licenses();
679 }
680 }
681 add_action( 'load-update-core.php', 'give_refresh_license_on_force_check', 9 );
682
683
684