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 +65 -140 2.3.24.16.9 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
@@ -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,22 +394,12 @@
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() {
447 405 // Bailout.
@@ -448,9 +406,9 @@
448 406 if ( ! current_user_can( 'delete_plugins' ) ) {
449 407 give_die();
450 408 }
451 409
452 - $results = array();
410 + $results = [];
453 411
454 412 // Start output buffering.
455 413 ob_start();
456 414 ?>
@@ -455,10 +413,10 @@
455 413 ob_start();
456 414 ?>
457 415
458 416 <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>
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>
461 419 </h2>
462 420 <form class="deactivation-survey-form" method="POST">
463 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>
464 422
@@ -501,18 +459,19 @@
501 459 <?php esc_html_e( 'The plugin broke my site', 'give' ); ?>
502 460 </label>
503 461
504 462 <div class="give-survey-extra-field">
505 - <p><?php
463 + <p>
464 + <?php
506 465 printf(
507 466 '%1$s %2$s %3$s',
508 467 __( "We're sorry to hear that, check", 'give' ),
509 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
468 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
510 469 __( 'Can you describe the issue?', 'give' )
511 470 );
512 - ?>
471 + ?>
513 472 </p>
514 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
473 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
515 474 </div>
516 475 </div>
517 476
518 477 <div>
@@ -521,18 +480,19 @@
521 480 <?php esc_html_e( 'The plugin suddenly stopped working', 'give' ); ?>
522 481 </label>
523 482
524 483 <div class="give-survey-extra-field">
525 - <p><?php
484 + <p>
485 + <?php
526 486 printf(
527 487 '%1$s %2$s %3$s',
528 488 __( "We're sorry to hear that, check", 'give' ),
529 - '<a href="https://wordpress.org/support/plugin/give">Give Support</a>.',
489 + '<a href="https://wordpress.org/support/plugin/give">GiveWP Support</a>.',
530 490 __( 'Can you describe the issue?', 'give' )
531 491 );
532 - ?>
492 + ?>
533 493 </p>
534 - <textarea disabled name="user-reason" class="widefat" rows="6"></textarea disabled>
494 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
535 495 </div>
536 496 </div>
537 497
538 498 <div>
@@ -542,9 +502,9 @@
542 502 </label>
543 503
544 504 <div class="give-survey-extra-field">
545 505 <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>
506 + <textarea disabled name="user-reason" class="widefat" rows="6"></textarea>
547 507 </div>
548 508 </div>
549 509
550 510 <div id="survey-and-delete-data">
@@ -550,21 +510,15 @@
550 510 <div id="survey-and-delete-data">
551 511 <p>
552 512 <label>
553 513 <input type="checkbox" name="confirm_reset_store" value="1">
554 - <?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' ); ?>
555 515 </label>
556 516 <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' ); ?>
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' ); ?>
558 518 </section>
559 519 </p>
560 520 </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 521 <input type="hidden" name="give-export-class" value="Give_Tools_Reset_Stats">
568 522 <?php wp_nonce_field( 'give_ajax_export', 'give_ajax_export' ); ?>
569 523 </form>
570 524
@@ -570,13 +524,10 @@
570 524
571 525 <?php
572 526
573 527 // Echo content (deactivation form) from the output buffer.
574 - $output = ob_get_contents();
528 + $output = ob_get_clean();
575 529
576 - // Erase and stop output buffer.
577 - ob_end_clean();
578 -
579 530 $results['html'] = $output;
580 531
581 532 wp_send_json( $results );
582 533 }
@@ -592,9 +543,8 @@
592 543 function give_deactivation_form_submit() {
593 544
594 545 if ( ! check_ajax_referer( 'deactivation_survey_nonce', 'nonce', false ) ) {
595 546 wp_send_json_error();
596 - wp_die();
597 547 }
598 548
599 549 $form_data = give_clean( wp_parse_args( $_POST['form-data'] ) );
600 550
@@ -603,53 +553,28 @@
603 553
604 554 // Get the reason if any radio button has an optional text field.
605 555 $user_reason = isset( $form_data['user-reason'] ) ? $form_data['user-reason'] : '';
606 556
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 557 // Get the value of the checkbox for deleting Give's data.
614 558 $delete_data = isset( $form_data['confirm_reset_store'] ) ? $form_data['confirm_reset_store'] : '';
615 559
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 - );
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 + );
630 571
631 - // Check if the data is sent and stored correctly.
632 - $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 + }
633 576
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();
577 + wp_send_json_success( [ 'delete_data' => false ] );
653 578 }
654 579
655 580 add_action( 'wp_ajax_deactivation_form_submit', 'give_deactivation_form_submit' );