Hi there,
it basically does, yes. Aside of that only widgets are handled differently. There is currently no plan to change that behavior since processing the whole HTML would easily result in false positives since there is no real context available there.
Embed Privacy though comes with the possibility to use it for custom content parts. See the documentation for more information.
Best regards,
Matthias
You mean the Embed_Privacy::get_single_overlay() part?
Two questions regarding that:
- How can I make sure my custom content is being checked for all providers (including custom ones I provided)? get_single_overlay($myCustomContent, ”, ”, []) ?
- Does this also work for detection via JavaScript? I am using a caching plugin.
Thank you very much.
No, it doesn’t check all embed providers by default. It it primarily meant to process a custom embed provider programmatically. You can however use Embed_Privacy::get_embeds() first and iterate through each embed providers and then use the said code.
It does also work with the JavaScript detection as long as you use the mentioned methods. 🙂
Specifically providing embed_provider and embed_provider_lowercase will detect and swap the iframe with the right overlay – fine.
Iterating over all Providers however will just replace the iframe with an overlay of the first Provider (amazon-kindle) – clicking on it will reveal the correct iframe again however.
if (class_exists('epiphyt\Embed_Privacy\Embed_Privacy')) {
$allEmbeds = epiphyt\Embed_Privacy\Embed_Privacy::get_instance()->get_embeds();
foreach ($allEmbeds as $post) {
$customContent = epiphyt\Embed_Privacy\Embed_Privacy::get_instance()->get_single_overlay($werkDetailsContent, $post->post_title, $post->post_name, []);
}
}
You’ve missed the check for the regular expression for each provider as stated in the example in the documentation. Embed_Privacy::get_single_overlay() doesn’t do the check for you.
Ok, that was not obvious to me, sorry. Done now!
For anyone else wondering, how to use this with custom content, that is not filtered by the_content():
if (class_exists('epiphyt\Embed_Privacy\Embed_Privacy')) {
$allEmbeds = epiphyt\Embed_Privacy\Embed_Privacy::get_instance()->get_embeds();
foreach ($allEmbeds as $post) {
$regex = trim(get_post_meta($post->ID, 'regex_default', true), '/');
if (!empty($regex)) {
$regex = '/' . $regex . '/';
} else {
continue;
}
$args = [
'regex' => $regex,
];
$customContent = epiphyt\Embed_Privacy\Embed_Privacy::get_instance()->get_single_overlay($customContent, $post->post_title, $post->post_name, $args);
}
}
Thank you very much for the support @kittmedia !
-
This reply was modified 2 years, 11 months ago by
saiflok.