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

#374 - Integrates hook to remove content filters #375

Conversation

ypsilon-p
Copy link

see #374

@ypsilon-p ypsilon-p marked this pull request as draft March 15, 2024 09:41
@ypsilon-p ypsilon-p marked this pull request as ready for review March 15, 2024 09:53
@ypsilon-p
Copy link
Author

ypsilon-p commented Mar 15, 2024

I chose the solution with two actions. The filters made it very inflexible and confusing. When integrating it into our project, we realised that the option of using actions gives us a great deal of flexibility in terms of the functions to be executed.

@ypsilon-p
Copy link
Author

Here is an example how we use the actions:

function togglePaywallFilter(): void
{
    $contentFilterName = '\Paywall\Generator::paywall_for_the_content';
    if (has_filter('the_content', $contentFilterName)) {
        remove_filter('the_content', $contentFilterName);

        return;
    }

    add_filter('the_content', $contentFilterName);
}

add_action('beyondwords_before_content', 'togglePaywallFilter', 10, 1);
add_action('beyondwords_after_content', 'togglePaywallFilter', 10, 1);

I know of other projects where the content is manipulated depending on certain actions and filters. In these projects, the use of actions is a great added value to deactivate the actions and filters only for the moment of processing by BeyondWords.

@galbus
Copy link
Collaborator

galbus commented Mar 21, 2024

@ypsilon-p your action example is very nice and I agree it's better than adding the filters, but to merge in actions like this we would also need tests written and docs written by us too at https://docs.beyondwords.io/docs-and-guides/content/connect-cms/wordpress. We are also aiming to keep the number of filters and actions to a minimum to reduce complexity, especially in our docs.

I have proposed a solution in PR #378 that may work, especially with respect to paywalls. If this works then that would require less overall effort on our side and we would be able to ship it faster. I'm hoping it does. 🤞

@galbus galbus added enhancement php Pull requests that update Php code labels Mar 21, 2024
@galbus galbus linked an issue Mar 21, 2024 that may be closed by this pull request
@galbus
Copy link
Collaborator

galbus commented Mar 28, 2024

@ypsilon-p #378 is favourable because we are intentionally limiting the amount of filters and actions we provide.

If this update does not fix your issue and you believe an action or filter is required then please provide more detail and we can discuss alternative approaches.

The update will be shipped today in plugin version 3.6.1.

@galbus galbus closed this Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement php Pull requests that update Php code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate hook to remove content filter
2 participants