Forum Replies Created

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter nadunindunil

    (@nadunindunil)

    Hi @bcworkz ,
    Sorry for the confusion,
    word_embed_handler is actually the function attached to the hook oembed_response_data I just wanted to mention it didn’t work in my previous reply.

    “Unless you’ve done something to disable it” – We have disabled it. This was a previous requirement I guess. Users should not be able to embed all kinds of URLs.

    “I’m not sure where ’embed-handler’ is really coming from. It’s not from the code you linked earlier” – sorry again, this should be Embed Handler

    In fact, I tried the method even without an if block. Ex:

    add_filter( 'oembed_response_data', __NAMESPACE__ . '\\my_modify_oembed_provider_name', 10, 4);
    
    function my_modify_oembed_provider_name( $data, $post, $width, $height ) {      
         $data['provider_name'] = 'wordhub';
        return $data;
    }

    No luck though.

    Apologies for the ignorance again. I understand this is very niche. It’s due to that the customer is using a complex system with a WP headless CMS. So there are hundreds of custom implementations in the System. I was looking for a way to achieve this using an existing code in WordPress. However, considering all these restrictions from the custom tweaks, I feel like I might need to introduce a new block into the editor.
    Let me know your thoughts, Thank you very much for your help!
    I really appreciate it.

    Thread Starter nadunindunil

    (@nadunindunil)

    Hi @bcworkz ,
    Thank you very much for the prompt reply!
    Apologies for my ignorance I am really new to the WP ecosystem!

    I have already tried that hook, however, that didn’t work for me.
    The way I used it is as follows,

    function my_modify_oembed_provider_name( $data, $post, $width, $height ) {
        if ( $data['provider_name'] === 'embed-handler' ) {
             // Change provider_name to wordhub
         $data['provider_name'] = 'wordhub';
        }
    
        return $data;
    }

    However, now I understand why this didn’t work. (since the response didn’t return anything yet) Could you please help me to understand what kind of object will be sent into this hook when I create the block variation mentioned above? So depending on that, I could change the response conditionally.

    More Findings that might help you to understand the context:
    It is important to note that since the current site is not an oEmbed-supported site, the oEmbed request is failing. This is why line 215 of the code is being executed. It’s worth mentioning that the oembed_response_data hook is triggered only when the oEmbed request is successful and returns valid response data. In this case, since the request has failed, there is no response to trigger the hook.

    Thank you very much for your help!
    I really appreciate it.

    • This reply was modified 2 years, 1 month ago by nadunindunil.
Viewing 2 replies - 1 through 2 (of 2 total)