epiphyt / embed-privacy

Embed Privacy prevents loading of embedded external content and allows your site visitors to opt-in.
https://epiph.yt/en/embed-privacy/
GNU General Public License v2.0
19 stars 12 forks source link

Filter hook for finegrained control of active provider #201

Closed abid76 closed 11 months ago

abid76 commented 11 months ago

This filter hook makes it possible to have more control about when to enable an embed type.

E.g. you can check the post's content and active an embed if certain conditions are met.

abid76 commented 11 months ago

See also https://wordpress.org/support/topic/assets-scripts-etc-arent-loaded/#post-17259810

MatzeKitt commented 11 months ago

Thank you for your effort!

Please make sure to work according to the contribution guidelines: https://github.com/epiphyt/embed-privacy/blob/main/CONTRIBUTING.md

It lacks documentation as well as code style.

Also, I don’t think that this is the right area to check for such a functionality, since $content is hardly filterable at all. This would only work in a very limited case and thus is not the preferred way for implementation in a broader way.

abid76 commented 11 months ago

Thanks for your comment. Surely I can add documentation and conform to code style.

But first, I'd like to clarify how to actually solve the problem.

My need is to omit embed privacy under certain circumstances (currently when an ajax request is processed).

The proposed solution is not optimal and doesn't seem to work in all cases. Possible alternatives:

  1. Provide a filter hook in the beginning of get_output_template which controls if the method should be processed.
  2. Implement a filter on the_content hook which parses the html and removes all embed privacy html code (quite hard to implement).

May 1. be a proper proposal? Do you have any other idea?