Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/unserialize-user-info-GIVE-1176
Browse files Browse the repository at this point in the history
  • Loading branch information
jonwaldstein authored Sep 6, 2024
2 parents cfd74e4 + 5fbfa63 commit c15c28f
Show file tree
Hide file tree
Showing 109 changed files with 3,600 additions and 614 deletions.
2 changes: 1 addition & 1 deletion assets/src/js/admin/admin-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -3149,7 +3149,7 @@ const gravatar = require('gravatar');
orderedOptions.push({
text: option.textContent,
value: option.value,
selected: false,
selected: option.selected,
});
}
});
Expand Down
1 change: 1 addition & 0 deletions assets/src/js/admin/paypal-commerce/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,7 @@ window.addEventListener('DOMContentLoaded', function () {
formData.append('action', 'give_paypal_commerce_disconnect_account');
formData.append('mode', button.getAttribute('data-mode'));
formData.append('keep-webhooks', Boolean(keepWebhooks));
formData.append('_ajax_nonce', button.getAttribute('data-nonce'));

requestData.method = 'POST';
requestData.body = formData;
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@
"exclude_from_copy": {
"packages": [
"symfony/deprecation-contracts"
],
"file_patterns": [
"/Tests/"
]
},
"delete_vendor_packages": true,
Expand Down
5 changes: 3 additions & 2 deletions give.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: The most robust, flexible, and intuitive way to accept donations on WordPress.
* Author: GiveWP
* Author URI: https://givewp.com/
* Version: 3.15.1
* Version: 3.16.0
* Requires at least: 6.4
* Requires PHP: 7.2
* Text Domain: give
Expand Down Expand Up @@ -239,6 +239,7 @@ final class Give
Give\PaymentGateways\Gateways\ServiceProvider::class,
Give\EventTickets\ServiceProvider::class,
Give\BetaFeatures\ServiceProvider::class,
Give\FormTaxonomies\ServiceProvider::class,
Give\DonationSpam\ServiceProvider::class,
];

Expand Down Expand Up @@ -405,7 +406,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.15.1');
define('GIVE_VERSION', '3.16.0');
}

// Plugin Root File.
Expand Down
13 changes: 6 additions & 7 deletions includes/admin/forms/dashboard-columns.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ function give_form_columns( $give_form_columns ) {
/**
* Render Give Form Columns
*
* @since 3.16.0 Add new filters for the "donations count" and "revenue" columns
* @since 1.0
*
* @param string $column_name Column name
Expand Down Expand Up @@ -86,6 +87,7 @@ function give_render_form_columns( $column_name, $post_id ) {
break;
case 'goal':
if ( give_is_setting_enabled( give_get_meta( $post_id, '_give_goal_option', true ) ) ) {
do_action('give_admin_form_list_view_donations_goal_column_before', $post_id);

echo give_admin_form_goal_stats( $post_id );

Expand All @@ -105,7 +107,7 @@ function give_render_form_columns( $column_name, $post_id ) {
printf(
'<a href="%1$s">%2$s</a>',
esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&form_id=' . $post_id ) ),
give_get_form_sales_stats( $post_id )
apply_filters('give_admin_form_list_view_donations_count_column_value', give_get_form_sales_stats( $post_id ), $post_id)
);
} else {
echo '-';
Expand All @@ -116,7 +118,7 @@ function give_render_form_columns( $column_name, $post_id ) {
printf(
'<a href="%1$s">%2$s</a>',
esc_url( admin_url( 'edit.php?post_type=give_forms&page=give-reports&tab=forms&form-id=' . $post_id ) ),
give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), [ 'sanitize' => false ] ) )
apply_filters('give_admin_form_list_view_revenue_column_value', give_currency_filter( give_format_amount( give_get_form_earnings_stats( $post_id ), [ 'sanitize' => false ] ) ), $post_id)
);
} else {
echo '-';
Expand Down Expand Up @@ -168,7 +170,8 @@ function give_sortable_form_columns( $columns ) {
/**
* Sorts Columns in the Forms List Table
*
* @since 3.14.0 Use the 'give_donate_form_get_sales" filter to ensure the correct donation count will be used
* @since 3.16.0 Remove "give_donate_form_get_sales" filter logic
* @since 3.14.0 Use the "give_donate_form_get_sales" filter to ensure the correct donation count will be used
* @since 1.0
*
* @param array $vars Array of all the sort variables.
Expand All @@ -181,10 +184,6 @@ function give_sort_forms( $vars ) {
return $vars;
}

add_filter('give_donate_form_get_sales', function ($sales, $donationFormId) {
return (new Give\MultiFormGoals\ProgressBar\Model(['ids' => [$donationFormId]]))->getDonationCount();
}, 10, 2);

switch ( $vars['orderby'] ) {
// Check if 'orderby' is set to "sales".
case 'sales':
Expand Down
2 changes: 1 addition & 1 deletion includes/admin/settings/class-settings-advanced.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ public function get_settings() {
],
],
[
'name' => 'GiveWP Cache',
'name' => __( 'GiveWP Cache', 'give' ),
'id' => 'give-clear-cache',
'buttonTitle' => __( 'Clear Cache', 'give' ),
'desc' => __( 'Click this button if you want to clear GiveWP\'s cache. The plugin stores common settings and queries in cache to optimize performance. Clearing cache will remove and begin rebuilding these saved queries.', 'give' ),
Expand Down
21 changes: 11 additions & 10 deletions includes/forms/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
exit;
}

use Give\DonationForms\DonationQuery;
use Give\Helpers\Form\Utils as FormUtils;

/**
Expand Down Expand Up @@ -1249,7 +1248,8 @@ function give_set_form_closed_status( $form_id ) {
/**
* Show Form Goal Stats in Admin ( Listing and Detail page )
*
* @since 3.14.0 Use the 'give_get_form_earnings_stats" filter to ensure the correct value will be displayed in the form progress bar
* @since 3.16.0 Remove "give_donate_form_get_sales" filter logic
* @since 3.14.0 Use the "give_get_form_earnings_stats" filter to ensure the correct value will be displayed in the form progress bar
* @since 2.19.0 Prevent divide by zero issue in goal percentage calculation logic.
*
* @since 2.1.0
Expand All @@ -1259,13 +1259,11 @@ function give_set_form_closed_status( $form_id ) {
* @return string
*/
function give_admin_form_goal_stats( $form_id ) {
add_filter('give_get_form_earnings_stats', function ($earnings, $donationFormId) {
return (new DonationQuery())->form($donationFormId)->sumAmount();
}, 10, 2);

$html = '';
$goal_stats = give_goal_progress_stats( $form_id );
$percent_complete = $goal_stats['raw_goal'] ? round( ( $goal_stats['raw_actual'] / $goal_stats['raw_goal'] ), 3 ) * 100 : 0;
$percent_complete = $goal_stats['raw_goal'] && is_numeric($goal_stats['raw_actual']) && is_numeric($goal_stats['raw_goal'])
? round(($goal_stats['raw_actual'] / $goal_stats['raw_goal']), 3) * 100
: 0;

$html .= sprintf(
'<div class="give-admin-progress-bar" role="progressbar" aria-valuemin="0" aria-valuemax="100" aria-valuenow="%1$s">
Expand All @@ -1285,9 +1283,12 @@ function give_admin_form_goal_stats( $form_id ) {
( 'donors' === $goal_stats['format'] ? __( 'donors', 'give' ) : ( 'donation' === $goal_stats['format'] ? __( 'donations', 'give' ) : '' ) )
);

if ( $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ) {
$html .= sprintf( '<span class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>', __( 'Goal achieved', 'give' ) );
}
$opacity = $goal_stats['raw_actual'] >= $goal_stats['raw_goal'] ? 1 : 0;
$html .= sprintf(
'<span style="opacity:%s" class="give-admin-goal-achieved"><span class="dashicons dashicons-star-filled"></span> %s</span>',
apply_filters('give_admin_goal_progress_achieved_opacity', $opacity),
__('Goal achieved', 'give')
);

$html .= '</div>';

Expand Down
24 changes: 14 additions & 10 deletions includes/misc-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
* @since 1.0
*/

// Exit if accessed directly.
use Give\DonationForms\DonationQuery;
use Give\DonationForms\AsyncData\AsyncDataHelpers;
use Give\License\PremiumAddonsListManager;

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Expand Down Expand Up @@ -1928,10 +1928,12 @@ function give_get_nonce_field( $action, $name, $referer = false ) {
/**
* Display/Return a formatted goal for a donation form
*
* @since 3.16.0 Add form_id to the array return
* @since 2.1
*
* @param int|Give_Donate_Form $form Form ID or Form Object.
*
* @return array
* @since 2.1
*/
function give_goal_progress_stats( $form ) {

Expand All @@ -1943,7 +1945,6 @@ function give_goal_progress_stats( $form ) {

/**
* Filter the form.
* @since 3.14.0 Replace "$form->earnings" with (new DonationQuery())->form($form->ID)->sumIntendedAmount()
* @since 1.8.8
*/
$total_goal = apply_filters( 'give_goal_amount_target_output', round( give_maybe_sanitize_amount( $form->goal ), 2 ), $form->ID, $form );
Expand Down Expand Up @@ -1971,12 +1972,14 @@ function give_goal_progress_stats( $form ) {
$actual = apply_filters( 'give_goal_donors_target_output', give_get_form_donor_count( $form->ID ), $form->ID, $form );
break;
default:
/**
* Filter the form income.
*
* @since 1.8.8
*/
$actual = apply_filters( 'give_goal_amount_raised_output', (new DonationQuery())->form($form->ID)->sumIntendedAmount(), $form->ID, $form );
/**
* Filter the form income.
*
* @since 3.16.0 Revert changes implemented on the 3.14.0 version
* @since 3.14.0 Replace "$form->earnings" with (new DonationQuery())->form($form->ID)->sumIntendedAmount()
* @since 1.8.8
*/
$actual = apply_filters( 'give_goal_amount_raised_output', $form->earnings, $form->ID, $form );
break;
}

Expand Down Expand Up @@ -2018,6 +2021,7 @@ function give_goal_progress_stats( $form ) {
'actual' => $actual,
'goal' => $total_goal,
'format' => $goal_format,
'form_id' => $form->ID
],
$stats_array
);
Expand Down
7 changes: 5 additions & 2 deletions includes/shortcodes.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ function give_register_form_shortcode( $atts ) {
*
* Shows a donation receipt.
*
* @since 3.16.0 add give_donation_confirmation_page_enqueue_scripts
* @since 3.7.0 Sanitize and escape attributes
* @since 1.0
*
Expand Down Expand Up @@ -390,13 +391,15 @@ function give_receipt_shortcode( $atts ) {
if ( ! wp_doing_ajax() ) {
give_get_template_part( 'receipt/placeholder' );

return sprintf(
do_action('give_donation_confirmation_page_enqueue_scripts');

return apply_filters('give_receipt_shortcode_output', sprintf(
'<div id="give-receipt" data-shortcode="%1$s" data-receipt-type="%2$s" data-donation-key="%3$s" >%4$s</div>',
htmlspecialchars( wp_json_encode( $give_receipt_args ) ),
esc_attr($receipt_type),
esc_attr($donation_id),
ob_get_clean()
);
));
}

return give_display_donation_receipt( $atts );
Expand Down
17 changes: 15 additions & 2 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tags: donation, donate, recurring donations, fundraising, crowdfunding
Requires at least: 6.4
Tested up to: 6.6
Requires PHP: 7.2
Stable tag: 3.15.1
Stable tag: 3.16.0
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -262,6 +262,19 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri
10. Use almost any payment gateway integration with GiveWP through our add-ons or by creating your own add-on.

== Changelog ==
= 3.16.0: Aug 28th, 2024 =
* New: Added support for form taxonomy tags and categories in the visual form builder settings
* New: Added a setting to the visual form builder to enable redirecting to an individual donation confirmation page
* Enhancement: Multi-step form designs now scroll to the top of the form on step change
* Enhancement: Added individual form migration links to the donation form list table
* Enhancement: Updated various strings throughout GiveWP to be translatable (Open-source contribution by @DAnn2012)
* Security: Resolved security issues related to file paths and permissions (CVE-2024-6551)
* Security: Resolved security issue related to the PayPal disconnect button
* Fix: Added prevention of subscription renewals with gateway transaction IDs already used previously
* Fix: Resolved an issue where the donation form list table and form grid not loading properly on sites with a large number of forms and donations
* Fix: Resolved an issue with the form grid not showing header images and link previews
* Fix: Resolved an issue with the subscription payment failed email not saving the supported gateways information

= 3.15.1: Aug 22nd, 2024 =
* Fix: Resolved an issue with the Akismet integration preventing form submissions when settings are not yet configured

Expand All @@ -272,7 +285,7 @@ The 2% fee on Stripe donations only applies to donations taken via our free Stri
* Fix: Resolved an issue with Give Subscribers accessing their donor dashboard history

= 3.14.2: Aug 7th, 2024 =
* Security: Added additional security measures to the option-based donation form and the donor dashboard
* Security: Added additional security measures to the option-based donation form and the donor dashboard (CVE-2024-37099)

= 3.14.1: July 24th, 2024 =
* Fix: Resolved an error with the give_totals shortcode when using multiple form IDs
Expand Down
10 changes: 7 additions & 3 deletions src/Controller/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function loadTemplateOnFrontend()
/**
* Load receipt view.
*
* @since 3.16.0 add action give_donation_confirmation_page_enqueue_scripts
* @since 2.7.0
*/
public function loadReceiptView()
Expand All @@ -71,6 +72,8 @@ public function loadReceiptView()
return;
}

do_action('give_donation_confirmation_page_enqueue_scripts');

// Handle success page.
if (FormUtils::isViewingFormReceipt() && ! FormUtils::isLegacyForm()) {
/* @var Template $formTemplate */
Expand Down Expand Up @@ -113,7 +116,6 @@ public function loadReceiptView()
include $formTemplate->getReceiptView();
exit();
}

// Render receipt on success page in iframe.
add_filter('the_content', [$this, 'showReceiptInIframeOnSuccessPage'], 1);
}
Expand Down Expand Up @@ -164,6 +166,7 @@ public function setFailedTransactionError()
/**
* Handle receipt shortcode on success page
*
* @since 3.16.0 add filter give_donation_confirmation_success_page_shortcode_view
* @since 2.7.0
*
* @param string $content
Expand All @@ -173,9 +176,10 @@ public function setFailedTransactionError()
public function showReceiptInIframeOnSuccessPage($content)
{
$receiptShortcode = ShortcodeUtils::getReceiptShortcodeFromConfirmationPage();
$content = str_replace($receiptShortcode, give_form_shortcode([]), $content);

return $content;
$view = apply_filters('give_donation_confirmation_success_page_shortcode_view', give_form_shortcode([]));

return str_replace($receiptShortcode, $view, $content);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ public function __invoke(DonateControllerData $formData, Donation $donation, ?Su
(new AddRedirectUrlsToGatewayData())($formData, $donation);
(new UpdateDonationLevelId())($formData->getDonationForm(), $donation);
}
}
}
29 changes: 29 additions & 0 deletions src/DonationForms/Actions/PrintFormMetaTags.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Give\DonationForms\Actions;

use Give\DonationForms\Models\DonationForm;
use Give\Helpers\Form\Utils;

/**
* @since 3.16.0
*/
class PrintFormMetaTags
{
public function __invoke()
{
global $post;

if (
$post->post_type === 'give_forms'
&& Utils::isV3Form($post->ID)
) {
$form = DonationForm::find($post->ID);

// og:image
if ( ! empty($form->settings->designSettingsImageUrl)) {
printf('<meta property="og:image" content="%s" />', esc_url($form->settings->designSettingsImageUrl));
}
}
}
}
Loading

0 comments on commit c15c28f

Please sign in to comment.