Youtube Embed Plus Shortcodes

Below, you’ll find a detailed guide on how to add the Youtube Embed Plus Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Youtube Embed Plus Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Youtube Embed Plus Plugin and the shortcodes it provides:

Plugin Icon
Embed Plus YouTube WordPress Plugin With YouTube Gallery, Channel, Playlist, Live Stream

"Embed Plus YouTube WordPress Plugin with YouTube Gallery, Channel, Playlist, Live Stream is a versatile tool for integrating YouTube content into your WordPress site. This plugin allows effortless embedding of videos, playlists, channels, and live streams."

★★★★☆ (557) Active Installs: 200000+ Tested with: 6.3.2 PHP Version: false
Included Shortcodes:
  • [embed-vi-ad]
  • [embedyt]
  • [youtube]
  • [embedplusvideo]

Youtube Embed Plus [embed-vi-ad] Shortcode

The ’embed-vi-ad’ shortcode from the YouTube-Embed-Plus plugin is designed to embed video ads in your WordPress site. This shortcode calls the ‘vi_js_shortcode’ function, which in turn invokes the ‘vi_script_tag’ function. This process ultimately generates the necessary script tag to embed the video advertisement.

Shortcode: [embed-vi-ad]

Examples and Usage

Basic example – Embeds a YouTube video advertisement using the shortcode ’embed-vi-ad’ without any additional parameters.

[embed-vi-ad /]

PHP Function Code

In case you have difficulties debugging what causing issues with [embed-vi-ad] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('embed-vi-ad', array(get_class(), 'vi_js_shortcode'));

Shortcode PHP function:

function vi_js_shortcode($atts, $content = null)
    {
        return self::vi_script_tag();
    }

Code file location:

youtube-embed-plus/youtube-embed-plus/includes/vi/vi_actions.php

Youtube Embed Plus [embedyt] Shortcode

The Youtube-Embed-Plus plugin’s ’embedyt’ shortcode is designed to apply user preferences to embedded YouTube videos. It executes the ‘apply_prefs_shortcode’ function, which checks if the content matches a specified URL pattern. If it does, it returns the HTML for the YouTube video with the user’s preferences applied. If not, it returns an empty string.

Shortcode: [embedyt]

Examples and Usage

Basic example – Embed a YouTube video using a URL.

[embedyt] https://www.youtube.com/watch?v=dQw4w9WgXcQ [/embedyt]

PHP Function Code

In case you have difficulties debugging what causing issues with [embedyt] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('embedyt', array(get_class(), 'apply_prefs_shortcode'));

Shortcode PHP function:

function apply_prefs_shortcode($atts, $content = null)
    {
        $content = trim($content);
        $currfilter = current_filter();
        if (preg_match(self::$justurlregex, $content))
        {
            return self::get_html(array($content), strpos($currfilter, 'widget_text') === 0 ? false : true, false);
        }
        return '';
    }

Code file location:

youtube-embed-plus/youtube-embed-plus/youtube.php

Youtube Embed Plus [youtube] Shortcode

The YouTube Embed Plus plugin shortcode is designed to embed YouTube videos into your WordPress posts or pages. This shortcode takes a YouTube video URL as its content and embeds the video into your post. It uses the ‘apply_prefs_shortcode_youtube’ function to do so. This function checks if the content is a valid YouTube URL and then returns the HTML needed to embed the video. If the content is not a valid YouTube URL, it returns an empty string.

Shortcode: [youtube]

Examples and Usage

Basic example – Embeds a YouTube video by using its video ID. The video ID is the string of characters that appear after “v=” in a YouTube video URL.

[youtube 'dQw4w9WgXcQ' /]

PHP Function Code

In case you have difficulties debugging what causing issues with [youtube] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('youtube', array(get_class(), 'apply_prefs_shortcode_youtube'));

Shortcode PHP function:

function apply_prefs_shortcode_youtube($atts, $content = null)
    {
        $content = 'https://www.youtube.com/watch?v=' . trim($content);
        $currfilter = current_filter();
        if (preg_match(self::$justurlregex, $content))
        {
            return self::get_html(array($content), $currfilter == 'widget_text' ? false : true, false);
        }
        return '';
    }

Code file location:

youtube-embed-plus/youtube-embed-plus/youtube.php

Youtube Embed Plus [embedplusvideo] Shortcode

The YouTube-Embed-Plus plugin shortcode is designed to embed a YouTube video into your WordPress site. It allows customization of height, width, and other parameters like start and end time. The shortcode generates a unique ID for each embedded video, ensuring no conflicts. It also corrects any formatting issues in the ‘vars’ attribute, ensuring a smooth video playback experience.

Shortcode: [embedplusvideo]

Parameters

Here is a list of all possible embedplusvideo shortcode parameters and attributes:

  • height – Determines the video’s display height on the webpage.
  • width – Specifies the video’s display width on the webpage.
  • vars – Additional variables to customize video parameters.
  • standard – Allows standard youtube video parameters.
  • id – Unique identifier for each embedded video.
  • ytid – The YouTube video’s unique ID.
  • start – Sets the video start time in seconds.
  • end or stop – Sets the video end time in seconds.

Examples and Usage

Basic example – Embeds a YouTube video by using the video’s unique ID

[embedplusvideo vars="ytid=6Dh-RL__uN4" /]

Advanced examples

Embeds a YouTube video with a specified start and end time. The video will start playing at the 30th second and stop at the 60th second.

[embedplusvideo vars="ytid=6Dh-RL__uN4&start=30&end=60" /]

Embeds a YouTube video with a defined height and width. The video will be displayed with a width of 800px and a height of 600px.

[embedplusvideo height="600" width="800" vars="ytid=6Dh-RL__uN4" /]

Embeds a YouTube video with a custom ID. This can be useful if you want to manipulate the embedded video with JavaScript or CSS.

[embedplusvideo id="customID" vars="ytid=6Dh-RL__uN4" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [embedplusvideo] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode('embedplusvideo', array(get_class(), 'apply_prefs_shortcode_embedplusvideo'));

Shortcode PHP function:

function apply_prefs_shortcode_embedplusvideo($atts, $content = null)
    {
        $atts = shortcode_atts(array(
            "height" => self::$defaultheight,
            "width" => self::$defaultwidth,
            "vars" => "",
            "standard" => "",
            "id" => "ep" . rand(10000, 99999)
                ), $atts);

        $epvars = $atts['vars'];
        $epvars = preg_replace('/\s/', '', $epvars);
        $epvars = preg_replace('/¬/', '&not', $epvars);
        $epvars = str_replace('&', '&', $epvars);

        $epparams = self::keyvalue($epvars, true);

        if (isset($epparams) && isset($epparams['ytid']))
        {
            $start = isset($epparams['start']) && is_numeric($epparams['start']) ? '&start=' . intval($epparams['start']) : '';
            $end = isset($epparams['end']) && is_numeric($epparams['end']) ? '&end=' . intval($epparams['end']) : '';
            $end = isset($epparams['stop']) && is_numeric($epparams['stop']) ? '&end=' . intval($epparams['stop']) : '';

            $url = 'https://www.youtube.com/watch?v=' . trim($epparams['ytid']) . $start . $end;

            $currfilter = current_filter();
            if (preg_match(self::$justurlregex, $url))
            {
                return self::get_html(array($url), $currfilter == 'widget_text' ? false : true, false);
            }
        }
        return '';
    }

Code file location:

youtube-embed-plus/youtube-embed-plus/youtube.php

Conclusion

Now that you’ve learned how to embed the Youtube Embed Plus Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *