• Resolved saiflok

    (@saiflok)


    Hey, is it possible that this plugin only works when the embeds are part of the_content()?

    I have a page that displays the actual content via a lot of different template functions, the actual post content (the_content) is empty. It seems that the plugin tries to alter the_content instead of parsing/reading the entire current page. Is that true?

    If so, is there any chance to make sure “everything” gets parsed/replaced and not just the_content?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Matthias Kittsteiner

    (@kittmedia)

    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

    Thread Starter saiflok

    (@saiflok)

    You mean the Embed_Privacy::get_single_overlay() part?

    Two questions regarding that:

    1. How can I make sure my custom content is being checked for all providers (including custom ones I provided)? get_single_overlay($myCustomContent, ”, ”, []) ?
    2. Does this also work for detection via JavaScript? I am using a caching plugin.

    Thank you very much.

    Plugin Author Matthias Kittsteiner

    (@kittmedia)

    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. 🙂

    Thread Starter saiflok

    (@saiflok)

    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, []);
                    }
                }
    Plugin Author Matthias Kittsteiner

    (@kittmedia)

    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.

    Thread Starter saiflok

    (@saiflok)

    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.
Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Does it only work with “the_content”?’ is closed to new replies.