Skip to content

Commit

Permalink
Merge branch 'hotfix/fatal-error-legacy-forms-7057' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
angelablake committed Oct 20, 2023
2 parents de7f1d0 + a2bc9af commit 5788332
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 9 deletions.
4 changes: 2 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.0.2
* Version: 3.0.3
* Requires at least: 6.0
* Requires PHP: 7.2
* Text Domain: give
Expand Down Expand Up @@ -391,7 +391,7 @@ private function setup_constants()
{
// Plugin version.
if (!defined('GIVE_VERSION')) {
define('GIVE_VERSION', '3.0.2');
define('GIVE_VERSION', '3.0.1');
}

// Plugin Root File.
Expand Down
5 changes: 4 additions & 1 deletion 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.0
Tested up to: 6.4
Requires PHP: 7.2
Stable tag: 3.0.2
Stable tag: 3.0.3
License: GPLv3
License URI: http://www.gnu.org/licenses/gpl-3.0.html

Expand Down Expand Up @@ -262,6 +262,9 @@ 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.0.3: October 20th, 2023 =
* Fix: Forms no longer have fatal errors on Elementor websites when the Display Content option is enabled

= 3.0.1: October 17th, 2023 =
* Fix: Resolved a conflict with Matomo plugin that was causing a fatal error

Expand Down
15 changes: 13 additions & 2 deletions src/DonationForms/FormPage/TemplateHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@

namespace Give\DonationForms\FormPage;

use Give\Helpers\Form\Utils;
use WP_Post as Post;

/**
* @since 3.0.0
*/
class TemplateHandler
{
/**
Expand All @@ -22,17 +26,24 @@ public function __construct( $post, string $formPageTemplatePath )
$this->formPageTemplatePath = $formPageTemplatePath;
}

/**
* @since 3.0.0
*/
public function handle($template)
{
return $this->isNextGenForm()
? $this->formPageTemplatePath
: $template;
}

/**
* @since 3.0.3 Use isV3Form() method instead of 'post_content' to check if the form is built with Visual Builder
* @since 3.0.0
*/
protected function isNextGenForm(): bool
{
return $this->post
&& $this->post->post_content
&&'give_forms' === $this->post->post_type;
&& Utils::isV3Form($this->post->ID)
&& 'give_forms' === $this->post->post_type;
}
}
6 changes: 3 additions & 3 deletions src/DonationForms/Repositories/DonationFormRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Give\Framework\PaymentGateways\PaymentGateway;
use Give\Framework\PaymentGateways\PaymentGatewayRegister;
use Give\Framework\Support\Facades\DateTime\Temporal;
use Give\Helpers\Form\Utils;
use Give\Helpers\Hooks;
use Give\Log\Log;

Expand Down Expand Up @@ -477,13 +478,12 @@ function ($value, Closure $fail, string $key, array $values) use ($formId) {
}

/**
* @since 3.0.3 Use isV3Form() method instead of 'post_content' to check if it's a legacy form
* @since 3.0.0
*/
public function isLegacyForm(int $formId): bool
{
$form = DB::table('posts')->select(['post_content', 'data'])->where('ID', $formId)->get();

return empty($form->data);
return ! Utils::isV3Form($formId);
}

/**
Expand Down
4 changes: 3 additions & 1 deletion src/FormBuilder/Routes/EditFormRoute.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@
namespace Give\FormBuilder\Routes;

use Give\FormBuilder\FormBuilderRouteBuilder;
use Give\Helpers\Form\Utils;

/**
* Route to edit an existing form
*/
class EditFormRoute
{
/**
* @since 3.0.3 Use isV3Form() method instead of 'post_content' to check if the form is built with Visual Builder
* @since 3.0.0
*
* @return void
Expand All @@ -18,7 +20,7 @@ public function __invoke()
{
if (isset($_GET['post'], $_GET['action']) && 'edit' === $_GET['action']) {
$post = get_post(abs($_GET['post']));
if ('give_forms' === $post->post_type && $post->post_content) {
if ('give_forms' === $post->post_type && Utils::isV3Form($post->ID)) {
wp_redirect(FormBuilderRouteBuilder::makeEditFormRoute($post->ID));
exit();
}
Expand Down

0 comments on commit 5788332

Please sign in to comment.