PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 3.21.1
GiveWP – Donation Plugin and Fundraising Platform v3.21.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 2.31.0 2.31.1 All 253 releases
← All changes | includes/admin/plugins.php +66 -89 2.3.13.21.1 View file →
@@ -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
@@ -130,9 +132,9 @@
130 132 function give_recently_activated_addons() {
131 133 // Check if action is set.
132 134 if ( isset( $_REQUEST['action'] ) ) {
133 135 $plugin_action = ( '-1' !== $_REQUEST['action'] ) ? $_REQUEST['action'] : ( isset( $_REQUEST['action2'] ) ? $_REQUEST['action2'] : '' );
134 - $plugins = array();
136 + $plugins = [];
135 137
136 138 switch ( $plugin_action ) {
137 139 case 'activate': // Single add-on activation.
138 140 $plugins[] = $_REQUEST['plugin'];
@@ -141,9 +143,8 @@
141 143 $plugins = $_REQUEST['checked'];
142 144 break;
143 145 }
144 146
145 -
146 147 if ( ! empty( $plugins ) ) {
147 148
148 149 $give_addons = give_get_recently_activated_addons();
149 150
@@ -176,18 +177,27 @@
176 177 */
177 178 function give_filter_addons_do_filter_addons( $plugin_menu ) {
178 179 global $plugins;
179 180
180 - foreach ( $plugins['all'] as $plugin_slug => $plugin_data ) {
181 + $give_addons = wp_list_pluck( give_get_plugins( [ 'only_add_on' => true ] ), 'Name' );
181 182
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;
183 + if ( ! empty( $give_addons ) ) {
184 + foreach ( $plugins['all'] as $file => $plugin_data ) {
185 +
186 + if ( in_array( $plugin_data['Name'], $give_addons ) ) {
187 + $plugins['give'][ $file ] = $plugins['all'][ $file ];
188 + $plugins['give'][ $file ]['plugin'] = $file;
189 +
190 + // Replicate the next step.
191 + if ( current_user_can( 'update_plugins' ) ) {
192 + $current = get_site_transient( 'update_plugins' );
193 +
194 + if ( isset( $current->response[ $file ] ) ) {
195 + $plugins['give'][ $file ]['update'] = true;
196 + $plugins['give'][ $file ] = array_merge( (array) $current->response[ $file ], $plugins['give'][ $file ] );
197 + } elseif ( isset( $current->no_update[ $file ] ) ) {
198 + $plugins['give'][ $file ] = array_merge( (array) $current->no_update[ $file ], $plugins['give'][ $file ] );
199 + }
190 200 }
191 201 }
192 202 }
193 203 }
@@ -349,13 +359,13 @@
349 359 * @return string
350 360 */
351 361 function give_parse_plugin_update_notice( $content, $new_version ) {
352 362 $version_parts = explode( '.', $new_version );
353 - $check_for_notices = array(
363 + $check_for_notices = [
354 364 $version_parts[0] . '.0',
355 365 $version_parts[0] . '.0.0',
356 366 $version_parts[0] . '.' . $version_parts[1] . '.' . '0',
357 - );
367 + ];
358 368
359 369 // Regex to extract Upgrade notice from the readme.txt file.
360 370 $notice_regexp = '~==\s*Upgrade Notice\s*==\s*=\s*(.*)\s*=(.*)(=\s*' . preg_quote( $new_version ) . '\s*=|$)~Uis';
361 371
@@ -433,9 +443,9 @@
433 443 *
434 444 * @return mixed|array list of recently activated add-on
435 445 */
436 446 function give_get_recently_activated_addons() {
437 - return get_option( 'give_recently_activated_addons', array() );
447 + return get_option( 'give_recently_activated_addons', [] );
438 448 }
439 449
440 450 /**
441 451 * Renders the Give Deactivation Survey Form.
@@ -448,9 +458,9 @@
448 458 if ( ! current_user_can( 'delete_plugins' ) ) {
449 459 give_die();
450 460 }
451 461
452 - $results = array();
462 + $results = [];
453 463
454 464 // Start output buffering.
455 465 ob_start();
456 466 ?>
@@ -455,10 +465,10 @@
455 465 ob_start();
456 466 ?>
457 467
458 468 <h2 id="deactivation-survey-title">
459 - <img src="<?php echo esc_url( GIVE_PLUGIN_URL ) ?>/assets/dist/images/give-icon-full-circle.svg">
460 - <span><?php esc_html_e( 'Give Deactivation', 'give' ); ?></span>
469 + <img src="<?php echo esc_url( GIVE_PLUGIN_URL ); ?>/assets/dist/images/give-icon-full-circle.svg">
470 + <span><?php esc_html_e( 'GiveWP Deactivation', 'give' ); ?></span>
461 471 </h2>
462 472 <form class="deactivation-survey-form" method="POST">
463 473 <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>
464 474
@@ -501,18 +511,19 @@
501 511 <?php esc_html_e( 'The plugin broke my site', 'give' ); ?>
502 512 </label>
503 513
504 514 <div class="give-survey-extra-field">
505 - <p><?php
515 + <p>
516 + <?php
506 517 printf(
507 518 '%1$s %2$s %3$s',
508 519 __( "We're sorry to hear that, check", 'give' ),
509 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
520 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
510 521 __( 'Can you describe the issue?', 'give' )
511 522 );
512 - ?>
523 + ?>
513 524 </p>
514 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
525 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
515 526 </div>
516 527 </div>
517 528
518 529 <div>
@@ -521,18 +532,19 @@
521 532 <?php esc_html_e( 'The plugin suddenly stopped working', 'give' ); ?>
522 533 </label>
523 534
524 535 <div class="give-survey-extra-field">
525 - <p><?php
536 + <p>
537 + <?php
526 538 printf(
527 539 '%1$s %2$s %3$s',
528 540 __( "We're sorry to hear that, check", 'give' ),
529 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
541 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
530 542 __( 'Can you describe the issue?', 'give' )
531 543 );
532 - ?>
544 + ?>
533 545 </p>
534 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
546 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
535 547 </div>
536 548 </div>
537 549
538 550 <div>
@@ -542,9 +554,9 @@
542 554 </label>
543 555
544 556 <div class="give-survey-extra-field">
545 557 <p><?php esc_html_e( "Please describe why you're deactivating Give", 'give' ); ?></p>
546 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
558 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
547 559 </div>
548 560 </div>
549 561
550 562 <div id="survey-and-delete-data">
@@ -550,21 +562,15 @@
550 562 <div id="survey-and-delete-data">
551 563 <p>
552 564 <label>
553 565 <input type="checkbox" name="confirm_reset_store" value="1">
554 - <?php esc_html_e( 'Would you like to delete all Give data?', 'give' ); ?>
566 + <?php esc_html_e( 'Would you like to delete all GiveWP data?', 'give' ); ?>
555 567 </label>
556 568 <section class="give-field-description">
557 - <?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' ); ?>
569 + <?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' ); ?>
558 570 </section>
559 571 </p>
560 572 </div>
561 - <?php
562 - $current_user = wp_get_current_user();
563 - $current_user_email = $current_user->user_email;
564 - ?>
565 - <input type="hidden" name="current-user-email" value="<?php echo $current_user_email; ?>">
566 - <input type="hidden" name="current-site-url" value="<?php echo esc_url( get_bloginfo( 'url' ) ); ?>">
567 573 <input type="hidden" name="give-export-class" value="Give_Tools_Reset_Stats">
568 574 <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
569 575 </form>
570 576
@@ -570,13 +576,10 @@
570 576
571 577 <?php
572 578
573 579 // Echo content (deactivation form) from the output buffer.
574 - $output = ob_get_contents();
580 + $output = ob_get_clean();
575 581
576 - // Erase and stop output buffer.
577 - ob_end_clean();
578 -
579 582 $results['html'] = $output;
580 583
581 584 wp_send_json( $results );
582 585 }
@@ -592,9 +595,8 @@
592 595 function give_deactivation_form_submit() {
593 596
594 597 if ( ! check_ajax_referer( 'deactivation_survey_nonce', 'nonce', false ) ) {
595 598 wp_send_json_error();
596 - wp_die();
597 599 }
598 600
599 601 $form_data = give_clean( wp_parse_args( $_POST['form-data'] ) );
600 602
@@ -603,53 +605,28 @@
603 605
604 606 // Get the reason if any radio button has an optional text field.
605 607 $user_reason = isset( $form_data['user-reason'] ) ? $form_data['user-reason'] : '';
606 608
607 - // Get the email of the user who deactivated the plugin.
608 - $user_email = isset( $form_data['current-user-email'] ) ? $form_data['current-user-email'] : '';
609 -
610 - // Get the URL of the website on which Give plugin is being deactivated.
611 - $site_url = isset( $form_data['current-site-url'] ) ? $form_data['current-site-url'] : '';
612 -
613 609 // Get the value of the checkbox for deleting Give's data.
614 610 $delete_data = isset( $form_data['confirm_reset_store'] ) ? $form_data['confirm_reset_store'] : '';
615 611
616 - /**
617 - * Make a POST request to the endpoint to send the survey data.
618 - */
619 - $response = wp_remote_post(
620 - 'http://survey.givewp.com/wp-json/give/v2/survey/',
621 - array(
622 - 'body' => array(
623 - 'radio_value' => $radio_value,
624 - 'user_reason' => $user_reason,
625 - 'current_user_email' => $user_email,
626 - 'site_url' => $site_url,
627 - ),
628 - )
629 - );
612 + // Send data to survey server. It doesn't matter if it fails.
613 + wp_remote_post(
614 + 'http://survey.givewp.com/wp-json/give/v2/survey/',
615 + [
616 + 'body' => [
617 + 'radio_value' => $radio_value,
618 + 'user_reason' => $user_reason,
619 + ],
620 + 'timeout' => 0.1
621 + ]
622 + );
630 623
631 - // Check if the data is sent and stored correctly.
632 - $response = wp_remote_retrieve_body( $response );
624 + if ( '1' === $delete_data ) {
625 + give_update_option( 'uninstall_on_delete', 'enabled' );
626 + wp_send_json_success( [ 'delete_data' => true ] );
627 + }
633 628
634 - if ( 'true' === $response ) {
635 - if ( '1' === $delete_data ) {
636 - wp_send_json_success(
637 - array(
638 - 'delete_data' => true,
639 - )
640 - );
641 - } else {
642 - wp_send_json_success(
643 - array(
644 - 'delete_data' => false,
645 - )
646 - );
647 - }
648 - } else {
649 - wp_send_json_error();
650 - }
651 -
652 - wp_die();
629 + wp_send_json_success( [ 'delete_data' => false ] );
653 630 }
654 631
655 632 add_action( 'wp_ajax_deactivation_form_submit', 'give_deactivation_form_submit' );