Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: narrow scope of checking if editing v2 forms #7135

Merged
merged 2 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/DonationForms/V2/DonationFormsAdminPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,13 +269,14 @@ public static function isShowing(): bool
/**
* Helper function to determine if current page is the edit v2 form page
*
* @unreleased added global $post to isset
* @since 3.0.0
*
* @return bool
*/
private function isShowingEditV2FormPage(): bool
{
return isset($_GET['action']) && $_GET['action'] === 'edit' && $GLOBALS['post']->post_type === 'give_forms';
return isset($_GET['action'], $GLOBALS['post']) && $_GET['action'] === 'edit' && $GLOBALS['post']->post_type === 'give_forms';
}

/**
Expand Down
13 changes: 5 additions & 8 deletions src/Promotions/InPluginUpsells/LegacyFormEditor.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,18 +48,15 @@ public function renderDonationOptionsRecurringRecommendation()
}

/**
*
* @unreleased replaced logic to be give_forms post_type specific
* @since 2.27.1
*
*/
public static function isShowing(): bool
{
$queryParameters = $_GET;

if (isset($queryParameters['action']) && $queryParameters['action'] === 'edit' && $queryParameters['post']) {
return true;
}
global $post, $pagenow;

return false;
return $post &&
in_array($pagenow, ['post-new.php', 'post.php'], true) &&
'give_forms' === get_post_type($post);
}
}
Loading