Closed abid76 closed 11 months ago
Isn’t it possible to check your request and depending on that just deregister the actions of Embed Privacy here in your case?
https://github.com/epiphyt/embed-privacy/blob/main/inc/class-embed-privacy.php#L155-L163
Isn’t it possible to check your request and depending on that just deregister the actions of Embed Privacy here in your case?
https://github.com/epiphyt/embed-privacy/blob/main/inc/class-embed-privacy.php#L155-L163
Thanks for you suggestion. Unfortunately I cannot make it work. I placed the following lines in functions.php
but it does not change anything. Do you have any idea what I am missing?
add_action('wp_loaded', 'apollo_embed_privacy_remove_filters');
function apollo_embed_privacy_remove_filters() {
$post_type = get_post_type();
if ($post_type == 'scliveticker_tick') {
remove_filter('acf_the_content', 'Embed_Privacy::get_instance::replace_embeds' );
remove_filter('do_shortcode_tag', 'Embed_Privacy::get_instance::replace_embeds', 10 );
remove_filter('do_shortcode_tag', 'Embed_Privacy::get_instance::replace_maps_marker', 10 );
remove_filter('embed_oembed_html', 'Embed_Privacy::get_instance::replace_embeds_oembed', 10 );
remove_filter('embed_privacy_widget_output', 'Embed_Privacy::get_instance::replace_embeds' );
remove_filter('et_builder_get_oembed', 'Embed_Privacy::get_instance::replace_embeds_divi', 10 );
remove_filter('pll_get_post_types', 'Embed_Privacy::get_instance::register_polylang_post_type', 10 );
remove_filter('the_content', 'Embed_Privacy::get_instance::replace_embeds' );
remove_filter('wp_video_shortcode', 'Embed_Privacy::get_instance::replace_video_shortcode', 10 );
}
}
'Embed_Privacy::get_instance::replace_embeds'
would translate to a function with exactly this name, which is not available.
Try it with the second parameter as array:
\remove_filter( 'acf_the_content', [ Embed_Privacy::get_instance(), 'replace_embeds' ] );
Thanks! 🙂 That worked.
Complete solution in functions.php
:
add_action('the_post', 'apollo_embed_privacy_remove_filters');
function apollo_embed_privacy_remove_filters() {
if (!class_exists('epiphyt\Embed_Privacy\Embed_Privacy')) {
return;
}
$post_type = get_post_type();
if ($post_type == 'scliveticker_tick') {
remove_filter('acf_the_content', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds' ] );
remove_filter('do_shortcode_tag', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds' ] , 10 );
remove_filter('do_shortcode_tag', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_maps_marker' ] , 10 );
remove_filter('embed_oembed_html', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds_oembed' ] , 10 );
remove_filter('embed_privacy_widget_output', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds' ] );
remove_filter('et_builder_get_oembed', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds_divi' ], 10 );
remove_filter('pll_get_post_types', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'register_polylang_post_type' ], 10 );
remove_filter('the_content', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_embeds' ] );
remove_filter('wp_video_shortcode', [ epiphyt\Embed_Privacy\Embed_Privacy::get_instance(), 'replace_video_shortcode' ], 10 );
}
}
As there's now a working solution (which hopefully will function even after updates of Embed Privacy) I'll close this Pull request.
This pull request introduces a filter hook
embed_privacy_disable_provider
which is applied just as the very first statement inget_output_template
.This filter allows fine-grained control on when to disable an embed provider. It applies before the disabled-option from the Wordpress settings is checked (alternatively this could also be placed after checking of disabled option).
Our use case is to disable embed privacy for a Liveticker which receives it's messages as Wordpress post via Ajax. In this case embed privacy doesn't work. The messages of the Liveticker can be recognized by the post type
scliveticker_tick
.Other implementations of the filter may check the HTTP request or using the
wp_doing_ajax()
function (which wouldn't work in the actual Liveticker issue).