From c42318b5aaa40eed6903287d9a61c36869cb81d5 Mon Sep 17 00:00:00 2001
From: Remco Tolsma <869674+remcotolsma@users.noreply.github.com>
Date: Tue, 26 Mar 2024 12:29:20 +0100
Subject: [PATCH] Revert "Simplify entry existence checks in source filters."
This reverts commit 08cfbe8e7311eab0ae9aebbcb4373a33d1796961.
---
src/Extension.php | 60 +++++++++++++++--------------------------------
1 file changed, 19 insertions(+), 41 deletions(-)
diff --git a/src/Extension.php b/src/Extension.php
index f3a2823..6e2e2f8 100644
--- a/src/Extension.php
+++ b/src/Extension.php
@@ -271,26 +271,15 @@ public function pre_submission( $form ) {
* @return string
*/
public function source_text( $text, Payment $payment ) {
- $source_url = $this->source_url( '', $payment );
+ $text = __( 'Gravity Forms', 'pronamic_ideal' ) . '
';
- $entry_text = \sprintf(
- /* translators: %s: source id */
- __( 'Entry #%s', 'pronamic_ideal' ),
- $payment->get_source_id()
- );
+ $entry = $this->is_active() ? RGFormsModel::get_lead( $payment->get_source_id() ) : false;
- if ( '' !== $source_url ) {
- $entry_text = \sprintf(
- '%2$s',
- $source_url,
- $entry_text
- );
- }
-
- $text = \sprintf(
- '%1$s
%2$s',
- \__( 'Gravity Forms', 'pronamic_ideal' ),
- $entry_text
+ $text .= sprintf(
+ false === $entry ? '%2$s' : '%2$s',
+ add_query_arg( [ 'pronamic_gf_lid' => $payment->get_source_id() ], admin_url( 'admin.php' ) ),
+ /* translators: %s: source id */
+ sprintf( __( 'Entry #%s', 'pronamic_ideal' ), $payment->get_source_id() )
);
return $text;
@@ -317,9 +306,9 @@ public function source_description( $description, Payment $payment ) {
* @return string
*/
public function source_url( $url, Payment $payment ) {
- $count_entries = \GFAPI::count_entries( null, [ 'id' => $payment->get_source_id() ] );
+ $entry = RGFormsModel::get_lead( $payment->get_source_id() );
- if ( $count_entries > 0 ) {
+ if ( false !== $entry ) {
$url = add_query_arg(
[
'pronamic_gf_lid' => $payment->get_source_id(),
@@ -340,26 +329,15 @@ public function source_url( $url, Payment $payment ) {
* @return string
*/
public function subscription_source_text( $text, Subscription $subscription ) {
- $source_url = $this->subscription_source_url( '', $subscription );
+ $text = __( 'Gravity Forms', 'pronamic_ideal' ) . '
';
- $entry_text = \sprintf(
- /* translators: %s: source id */
- __( 'Entry #%s', 'pronamic_ideal' ),
- $subscription->get_source_id()
- );
-
- if ( '' !== $source_url ) {
- $entry_text = \sprintf(
- '%2$s',
- $source_url,
- $entry_text
- );
- }
+ $entry = $this->is_active() ? RGFormsModel::get_lead( $subscription->get_source_id() ) : false;
- $text = \sprintf(
- '%1$s
%2$s',
- \__( 'Gravity Forms', 'pronamic_ideal' ),
- $entry_text
+ $text .= sprintf(
+ false === $entry ? '%2$s' : '%2$s',
+ add_query_arg( [ 'pronamic_gf_lid' => $subscription->get_source_id() ], admin_url( 'admin.php' ) ),
+ /* translators: %s: source id */
+ sprintf( __( 'Entry #%s', 'pronamic_ideal' ), $subscription->get_source_id() )
);
return $text;
@@ -386,9 +364,9 @@ public function subscription_source_description( $description, Subscription $sub
* @return string
*/
public function subscription_source_url( $url, Subscription $subscription ) {
- $count_entries = \GFAPI::count_entries( null, [ 'id' => $subscription->get_source_id() ] );
+ $entry = RGFormsModel::get_lead( $subscription->get_source_id() );
- if ( $count_entries > 0 ) {
+ if ( false !== $entry ) {
$url = add_query_arg(
[
'pronamic_gf_lid' => $subscription->get_source_id(),
@@ -1253,7 +1231,7 @@ public function replace_merge_tags( $text, $form, $entry, $url_encode, $esc_html
/**
* Bank transfer recipient details.
- *
+ *
* Use bank transfer details from last subscription payment if available.
*/
$payment = null;