Html5 Video Player Shortcode

Below, you’ll find a detailed guide on how to add the Html5 Video Player Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Html5 Video Player Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the Html5 Video Player Plugin and the shortcodes it provides:

Plugin Icon
Html5 Video Player – mp4 player, Video Player for WordPress

"Html5 Video Player – mp4 player, Video Player for WordPress is a dynamic plugin that lets you seamlessly integrate and play mp4 videos on your WordPress site. Its user-friendly design ensures a hassle-free viewing experience."

★★★★☆ (179) Active Installs: 30000+ Tested with: 6.3.2 PHP Version: 7.1
Included Shortcodes:

Html5 Video Player Shortcode

The Video Player shortcode is a custom PHP function in WordPress that dynamically generates HTML for a video player. It checks if the ‘id’ attribute is set in the shortcode. If not, it returns false. It then checks if the post is a Gutenberg post by getting the ‘isGutenberg’ post meta. Depending on the result, it outputs the HTML for either the AdvanceSystem or AnalogSystem. The generated HTML is stored in an output buffer and returned as a string.

Shortcode:

Parameters

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

  • id – Unique identifier for the specific video
  • isGutenberg – Determines if Gutenberg editor was used

Examples and Usage

Basic example – A simple usage of the video shortcode to display a video by referencing its ID.

Advanced examples

Using the shortcode to display a video by referencing its ID and setting the ‘isGutenberg’ meta value to true. If ‘isGutenberg’ is set to true, the AdvanceSystem::html method will be used to generate the video’s HTML. If ‘isGutenberg’ is not set or is false, the AnalogSystem::html method will be used instead.

Using the shortcode to display a video by referencing its ID and setting the ‘isGutenberg’ meta value to false. In this case, the AnalogSystem::html method will be used to generate the video’s HTML.

PHP Function Code

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

Shortcode line:

add_shortcode('video', [$this, 'video']);

Shortcode PHP function:

function video($atts){
        if(!isset($atts['id'])){
            return false;
        }

        $isGutenberg = get_post_meta($atts['id'], 'isGutenberg', true);

        ob_start();
        if($isGutenberg){
            echo( AdvanceSystem::html($atts['id']));
        }else {
            echo AnalogSystem::html($atts['id']);
        }
        $output = ob_get_contents();
        ob_end_clean();
        return $output;
     }

Code file location:

html5-video-player/html5-video-player/inc/Services/Shortcode.php

Conclusion

Now that you’ve learned how to embed the Html5 Video Player Plugin shortcode, 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 *