• Hi All — if you go to https://www.whittenweb.com you will likely see what i’m trying to do.

    I’m not very experienced with writing wp plugins. What I would like to do is create a simple tag (like

    <yte>{youtube video id}</yte> and have that expand when a post is viewed to the following:

    <object width="425" height="350"><param name="movie" value="https://www.youtube.com/v/{youtube video id}"></param><embed src="https://www.youtube.com/v/{youtube video id}" type="application/x-shockwave-flash" width="425" height="350"></embed></object>

    This seems fairly simple — just not sure i’m looking in the right places on where i’d add this type of code. Any help?

    thanks!

Viewing 1 replies (of 1 total)
  • Thread Starter notwen

    (@notwen)

    Never mind — I figured it out — easy of course, once I could figure out where to put it!


    <?php
    /*
    Plugin Name: You Tube Embed
    Plugin URI: <none yet>
    Description: Adds quicktags for embedding youtube videos in your blog
    Version: 1.0
    Author: Notwen
    Author URI: <none yet>
    */

    /*

    Drop in your /wp-content/plugins/
    Activate the plug-in via admin

    */

    add_filter('the_content', 'notwen_yte');

    function notwen_yte($post_content)
    {
    $pattern ='@<yte>(.*?)</yte>@';
    $replace = '<object width="425" height="350"><param name="movie" value="https://www.youtube.com/v/$1"></param><embed src="https://www.youtube.com/v/$1&quot; type="application/x-shockwave-flash" width="425" height="350"></embed></object>';
    return preg_replace ($pattern, $replace, $post_content);
    }

    ?>

Viewing 1 replies (of 1 total)
  • The topic ‘help adding simple tag to MCE’ is closed to new replies.