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

[filters] [pricing-url] Updated the pricing_url filter so that it als… #722

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

fajardoleo
Copy link
Contributor

…o updates the pricing/upgrade submenu item's URL.

@fajardoleo fajardoleo requested a review from swashata July 17, 2024 08:00
@fajardoleo fajardoleo self-assigned this Jul 17, 2024
@swashata swashata force-pushed the feature/pricing-url-filter-enhancement branch from c17d025 to 8cac031 Compare July 23, 2024 06:38
( $add_submenu_items && $show_pricing ),
$pricing_class
);
$custom_pricing_url = $this->apply_filters( 'pricing_url', null );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fajardoleo Could you please refactor the pricing_url method and extract the logic to apply the filter in a private function

function pricing_url(...) {
  $url = ...;

  return $this->get_pricing_url_with_filter( $url );
}

private function get_pricing_url_with_filter( $url ) {
  return $this->apply_filters( 'pricing_url', $url );
}

Then here, instead of calling the filter ad-hoc, you can do

$custom_pricing_url = $this->get_pricing_url_with_filter( null );

This will result in a single source of truth where the filter pricing_url is applied so it less error prone. Thanks.

@fajardoleo fajardoleo force-pushed the feature/pricing-url-filter-enhancement branch from 8cac031 to 72212f6 Compare July 23, 2024 11:17
…o updates the pricing/upgrade submenu item's URL.
@fajardoleo fajardoleo force-pushed the feature/pricing-url-filter-enhancement branch from 72212f6 to de76663 Compare July 23, 2024 11:17
Copy link
Contributor

@swashata swashata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👏

@swashata swashata merged commit de76663 into develop Jul 23, 2024
5 checks passed
@swashata swashata deleted the feature/pricing-url-filter-enhancement branch July 23, 2024 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants