• Anonymous User 20443167

    (@anonymized-20443167)


    Hello Jose.
    This plugin seems to be what I’m looking for. But it will need some tweaking to work with my setup.

    I use classic editor.

    When I copy a YouTube link on it, it’s automatically picked up and embedded. This is seen on both back end editor and front end.

    I would need to first have a function/snippet that completely disable this feature. No longer loading any of the assets WP uses for embedding.
    (Maybe your plugin already does this?)

    Second, I would need a code snippet to automatically add your short code to all YouTube links in the content. So I don’t have to manually type it every time. It will also take care of old links. Something like this:

    function modify_youtube_links($content) {
        
        $pattern = '/https:\/\/www\.youtube\.com\/watch\?v=([a-zA-Z0-9_-]+)/';
        
        $replacement = '<p>[load_video_on_click link="https://www.youtube.com/watch?v=$1"]</p>';
        
        $content = preg_replace_callback($pattern, function($matches) use ($replacement) {
            return preg_replace('/\$1/', $matches[1], $replacement);
        }, $content);
    
        return $content;
    }
    
    add_filter('the_content', 'modify_youtube_links');

    I hope to hear from you to see if I’m in the right track and what’s your opinion on this.

  • The topic ‘Classic editor implementation’ is closed to new replies.