PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.9
GiveWP – Donation Plugin and Fundraising Platform v4.16.9
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 2.3.2 2.30.0 All 255 releases
← All changes | includes/admin/plugins.php +70 -141 2.3.04.16.9 View file →
@@ -3,9 +3,9 @@
3 3 * Admin Plugins
4 4 *
5 5 * @package Give
6 6 * @subpackage Admin/Plugins
7 - * @copyright Copyright (c) 2016, WordImpress
7 + * @copyright Copyright (c) 2016, GiveWP
8 8 * @license https://opensource.org/licenses/gpl-license GNU Public License
9 9 * @since 1.4
10 10 */
11 11
@@ -23,15 +23,15 @@
23 23 *
24 24 * @return array An array of updated action links.
25 25 */
26 26 function give_plugin_action_links( $actions ) {
27 - $new_actions = array(
27 + $new_actions = [
28 28 'settings' => sprintf(
29 29 '<a href="%1$s">%2$s</a>',
30 30 admin_url( 'edit.php?post_type=give_forms&page=give-settings' ),
31 31 __( 'Settings', 'give' )
32 32 ),
33 - );
33 + ];
34 34
35 35 return array_merge( $new_actions, $actions );
36 36 }
37 37
@@ -42,9 +42,9 @@
42 42 * Plugin row meta links
43 43 *
44 44 * @since 1.4
45 45 *
46 - * @param array $plugin_meta An array of the plugin's metadata.
46 + * @param array $plugin_meta An array of the plugin's metadata.
47 47 * @param string $plugin_file Path to the plugin file, relative to the plugins directory.
48 48 *
49 49 * @return array
50 50 */
@@ -52,18 +52,19 @@
52 52 if ( GIVE_PLUGIN_BASENAME !== $plugin_file ) {
53 53 return $plugin_meta;
54 54 }
55 55
56 - $new_meta_links = array(
56 + $new_meta_links = [
57 57 sprintf(
58 58 '<a href="%1$s" target="_blank">%2$s</a>',
59 59 esc_url(
60 60 add_query_arg(
61 - array(
61 + [
62 62 'utm_source' => 'plugins-page',
63 63 'utm_medium' => 'plugin-row',
64 64 'utm_campaign' => 'admin',
65 - ), 'https://givewp.com/documentation/'
65 + ],
66 + 'https://givewp.com/documentation/'
66 67 )
67 68 ),
68 69 __( 'Documentation', 'give' )
69 70 ),
@@ -70,18 +71,19 @@
70 71 sprintf(
71 72 '<a href="%1$s" target="_blank">%2$s</a>',
72 73 esc_url(
73 74 add_query_arg(
74 - array(
75 + [
75 76 'utm_source' => 'plugins-page',
76 77 'utm_medium' => 'plugin-row',
77 78 'utm_campaign' => 'admin',
78 - ), 'https://givewp.com/addons/'
79 + ],
80 + 'https://givewp.com/addons/'
79 81 )
80 82 ),
81 83 __( 'Add-ons', 'give' )
82 84 ),
83 - );
85 + ];
84 86
85 87 return array_merge( $plugin_meta, $new_meta_links );
86 88 }
87 89
@@ -122,51 +124,8 @@
122 124 return $title;
123 125 }
124 126
125 127 /**
126 - * Store recently activated Give's addons to wp options.
127 - *
128 - * @since 2.1.0
129 - */
130 -function give_recently_activated_addons() {
131 - // Check if action is set.
132 - if ( isset( $_REQUEST['action'] ) ) {
133 - $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
134 - $plugins = array();
135 -
136 - switch ( $plugin_action ) {
137 - case 'activate': // Single add-on activation.
138 - $plugins[] = $_REQUEST['plugin'];
139 - break;
140 - case 'activate-selected': // If multiple add-ons activated.
141 - $plugins = $_REQUEST['checked'];
142 - break;
143 - }
144 -
145 -
146 - if ( ! empty( $plugins ) ) {
147 -
148 - $give_addons = give_get_recently_activated_addons();
149 -
150 - foreach ( $plugins as $plugin ) {
151 - // Get plugins which has 'Give-' as prefix.
152 - if ( stripos( $plugin, 'Give-' ) !== false ) {
153 - $give_addons[] = $plugin;
154 - }
155 - }
156 -
157 - if ( ! empty( $give_addons ) ) {
158 - // Update the Give's activated add-ons.
159 - update_option( 'give_recently_activated_addons', $give_addons, false );
160 - }
161 - }
162 - }
163 -}
164 -
165 -// Add add-on plugins to wp option table.
166 -add_action( 'activated_plugin', 'give_recently_activated_addons', 10 );
167 -
168 -/**
169 128 * Create new menu in plugin section that include all the add-on
170 129 *
171 130 * @since 2.1.0
172 131 *
@@ -176,18 +135,27 @@
176 135 */
177 136 function give_filter_addons_do_filter_addons( $plugin_menu ) {
178 137 global $plugins;
179 138
180 - foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {
139 + $give_addons = wp_list_pluck( give_get_plugins( [ 'only_add_on' => true ] ), 'Name' );
181 140
182 - if ( false !== strpos( $plugin_data['Name'], 'Give' ) && ( false !== strpos( $plugin_data['AuthorName'], 'WordImpress' ) || false !== strpos( $plugin_data['AuthorName'], 'GiveWP' ) ) ) {
183 - $plugins['give'][ $plugin_slug ] = $plugins['all'][ $plugin_slug ];
184 - $plugins['give'][ $plugin_slug ]['plugin'] = $plugin_slug;
185 - // replicate the next step.
186 - if ( current_user_can( 'update_plugins' ) ) {
187 - $current = get_site_transient( 'update_plugins' );
188 - if ( isset( $current->response[ $plugin_slug ] ) ) {
189 - $plugins['give'][ $plugin_slug ]['update'] = true;
141 + if ( ! empty( $give_addons ) ) {
142 + foreach ( $plugins['all'] as $file => $plugin_data ) {
143 +
144 + if ( in_array( $plugin_data['Name'], $give_addons ) ) {
145 + $plugins['give'][ $file ] = $plugins['all'][ $file ];
146 + $plugins['give'][ $file ]['plugin'] = $file;
147 +
148 + // Replicate the next step.
149 + if ( current_user_can( 'update_plugins' ) ) {
150 + $current = get_site_transient( 'update_plugins' );
151 +
152 + if ( isset( $current->response[ $file ] ) ) {
153 + $plugins['give'][ $file ]['update'] = true;
154 + $plugins['give'][ $file ] = array_merge( (array) $current->response[ $file ], $plugins['give'][ $file ] );
155 + } elseif ( isset( $current->no_update[ $file ] ) ) {
156 + $plugins['give'][ $file ] = array_merge( (array) $current->no_update[ $file ], $plugins['give'][ $file ] );
157 + }
190 158 }
191 159 }
192 160 }
193 161 }
@@ -349,13 +317,13 @@
349 317 * @return string
350 318 */
351 319 function give_parse_plugin_update_notice( $content, $new_version ) {
352 320 $version_parts = explode( '.', $new_version );
353 - $check_for_notices = array(
321 + $check_for_notices = [
354 322 $version_parts[0] . '.0',
355 323 $version_parts[0] . '.0.0',
356 324 $version_parts[0] . '.' . $version_parts[1] . '.' . '0',
357 - );
325 + ];
358 326
359 327 // Regex to extract Upgrade notice from the readme.txt file.
360 328 $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
361 329
@@ -426,27 +394,21 @@
426 394
427 395 add_action( 'admin_head', 'give_plugin_notice_css' );
428 396
429 397 /**
430 - * Get list of add-on last activated.
431 - *
432 - * @since 2.1.3
433 - *
434 - * @return mixed|array list of recently activated add-on
435 - */
436 -function give_get_recently_activated_addons() {
437 - return get_option( 'give_recently_activated_addons', array() );
438 -}
439 -
440 -/**
441 398 * Renders the Give Deactivation Survey Form.
442 399 * Note: only for internal use
443 400 *
401 + * @since 4.10.0 Updated the icon path to the new build directory.
444 402 * @since 2.2
445 403 */
446 404 function give_deactivation_popup() {
405 + // Bailout.
406 + if ( ! current_user_can( 'delete_plugins' ) ) {
407 + give_die();
408 + }
447 409
448 - $results = array();
410 + $results = [];
449 411
450 412 // Start output buffering.
451 413 ob_start();
452 414 ?>
@@ -451,10 +413,10 @@
451 413 ob_start();
452 414 ?>
453 415
454 416 <h2 id="deactivation-survey-title">
455 - <img src="<?php echo esc_url( GIVE_PLUGIN_URL ) ?>/assets/dist/images/give-icon-full-circle.svg">
456 - <span><?php esc_html_e( 'Give Deactivation', 'give' ); ?></span>
417 + <img src="<?php echo esc_url( GIVE_PLUGIN_URL ); ?>/build/assets/dist/images/give-icon-full-circle.svg">
418 + <span><?php esc_html_e( 'GiveWP Deactivation', 'give' ); ?></span>
457 419 </h2>
458 420 <form class="deactivation-survey-form" method="POST">
459 421 <p><?php esc_html_e( 'If you have a moment, please let us know why you are deactivating Give. All submissions are anonymous and we only use this feedback to improve this plugin.', 'give' ); ?></p>
460 422
@@ -497,18 +459,19 @@
497 459 <?php esc_html_e( 'The plugin broke my site', 'give' ); ?>
498 460 </label>
499 461
500 462 <div class="give-survey-extra-field">
501 - <p><?php
463 + <p>
464 + <?php
502 465 printf(
503 466 '%1$s %2$s %3$s',
504 467 __( "We're sorry to hear that, check", 'give' ),
505 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
468 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
506 469 __( 'Can you describe the issue?', 'give' )
507 470 );
508 - ?>
471 + ?>
509 472 </p>
510 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
473 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
511 474 </div>
512 475 </div>
513 476
514 477 <div>
@@ -517,18 +480,19 @@
517 480 <?php esc_html_e( 'The plugin suddenly stopped working', 'give' ); ?>
518 481 </label>
519 482
520 483 <div class="give-survey-extra-field">
521 - <p><?php
484 + <p>
485 + <?php
522 486 printf(
523 487 '%1$s %2$s %3$s',
524 488 __( "We're sorry to hear that, check", 'give' ),
525 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
489 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
526 490 __( 'Can you describe the issue?', 'give' )
527 491 );
528 - ?>
492 + ?>
529 493 </p>
530 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
494 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
531 495 </div>
532 496 </div>
533 497
534 498 <div>
@@ -538,9 +502,9 @@
538 502 </label>
539 503
540 504 <div class="give-survey-extra-field">
541 505 <p><?php esc_html_e( "Please describe why you're deactivating Give", 'give' ); ?></p>
542 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
506 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
543 507 </div>
544 508 </div>
545 509
546 510 <div id="survey-and-delete-data">
@@ -546,21 +510,15 @@
546 510 <div id="survey-and-delete-data">
547 511 <p>
548 512 <label>
549 513 <input type="checkbox" name="confirm_reset_store" value="1">
550 - <?php esc_html_e( 'Would you like to delete all Give data?', 'give' ); ?>
514 + <?php esc_html_e( 'Would you like to delete all GiveWP data?', 'give' ); ?>
551 515 </label>
552 516 <section class="give-field-description">
553 - <?php esc_html_e( 'By default the custom roles, Give options, and database entries are not deleted when you deactivate Give. If you are deleting Give completely from your website and want those items removed as well check this option. Note: This will permanently delete all Give data from your database.', 'give' ); ?>
517 + <?php esc_html_e( 'By default the custom roles, GiveWP options, and database entries are not deleted when you deactivate Give. If you are deleting GiveWP completely from your website and want those items removed as well check this option. Note: This will permanently delete all GiveWP data from your database.', 'give' ); ?>
554 518 </section>
555 519 </p>
556 520 </div>
557 - <?php
558 - $current_user = wp_get_current_user();
559 - $current_user_email = $current_user->user_email;
560 - ?>
561 - <input type="hidden" name="current-user-email" value="<?php echo $current_user_email; ?>">
562 - <input type="hidden" name="current-site-url" value="<?php echo esc_url( get_bloginfo( 'url' ) ); ?>">
563 521 <input type="hidden" name="give-export-class" value="Give_Tools_Reset_Stats">
564 522 <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
565 523 </form>
566 524
@@ -566,13 +524,10 @@
566 524
567 525 <?php
568 526
569 527 // Echo content (deactivation form) from the output buffer.
570 - $output = ob_get_contents();
528 + $output = ob_get_clean();
571 529
572 - // Erase and stop output buffer.
573 - ob_end_clean();
574 -
575 530 $results['html'] = $output;
576 531
577 532 wp_send_json( $results );
578 533 }
@@ -588,9 +543,8 @@
588 543 function give_deactivation_form_submit() {
589 544
590 545 if ( ! check_ajax_referer( 'deactivation_survey_nonce', 'nonce', false ) ) {
591 546 wp_send_json_error();
592 - wp_die();
593 547 }
594 548
595 549 $form_data = give_clean( wp_parse_args( $_POST['form-data'] ) );
596 550
@@ -599,53 +553,28 @@
599 553
600 554 // Get the reason if any radio button has an optional text field.
601 555 $user_reason = isset( $form_data['user-reason'] ) ? $form_data['user-reason'] : '';
602 556
603 - // Get the email of the user who deactivated the plugin.
604 - $user_email = isset( $form_data['current-user-email'] ) ? $form_data['current-user-email'] : '';
605 -
606 - // Get the URL of the website on which Give plugin is being deactivated.
607 - $site_url = isset( $form_data['current-site-url'] ) ? $form_data['current-site-url'] : '';
608 -
609 557 // Get the value of the checkbox for deleting Give's data.
610 558 $delete_data = isset( $form_data['confirm_reset_store'] ) ? $form_data['confirm_reset_store'] : '';
611 559
612 - /**
613 - * Make a POST request to the endpoint to send the survey data.
614 - */
615 - $response = wp_remote_post(
616 - 'http://survey.givewp.com/wp-json/give/v2/survey/',
617 - array(
618 - 'body' => array(
619 - 'radio_value' => $radio_value,
620 - 'user_reason' => $user_reason,
621 - 'current_user_email' => $user_email,
622 - 'site_url' => $site_url,
623 - ),
624 - )
625 - );
560 + // Send data to survey server. It doesn't matter if it fails.
561 + wp_remote_post(
562 + 'http://survey.givewp.com/wp-json/give/v2/survey/',
563 + [
564 + 'body' => [
565 + 'radio_value' => $radio_value,
566 + 'user_reason' => $user_reason,
567 + ],
568 + 'timeout' => 0.1
569 + ]
570 + );
626 571
627 - // Check if the data is sent and stored correctly.
628 - $response = wp_remote_retrieve_body( $response );
572 + if ( '1' === $delete_data ) {
573 + give_update_option( 'uninstall_on_delete', 'enabled' );
574 + wp_send_json_success( [ 'delete_data' => true ] );
575 + }
629 576
630 - if ( 'true' === $response ) {
631 - if ( '1' === $delete_data ) {
632 - wp_send_json_success(
633 - array(
634 - 'delete_data' => true,
635 - )
636 - );
637 - } else {
638 - wp_send_json_success(
639 - array(
640 - 'delete_data' => false,
641 - )
642 - );
643 - }
644 - } else {
645 - wp_send_json_error();
646 - }
647 -
648 - wp_die();
577 + wp_send_json_success( [ 'delete_data' => false ] );
649 578 }
650 579
651 580 add_action( 'wp_ajax_deactivation_form_submit', 'give_deactivation_form_submit' );