Presto Player Shortcodes

Below, you’ll find a detailed guide on how to add the Presto Player 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 Presto Player Plugin shortcodes not to show or not to work correctly.

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

Plugin Icon
The Ultimate Video Player For WordPress – by Presto Player

"Presto Player is the ultimate video player for WordPress, designed to offer superior video streaming experience. Enhance your site's multimedia capabilities with smooth playback and user-friendly interface."

★★★★☆ (212) Active Installs: 90000+ Tested with: 6.2.3 PHP Version: 7.3
Included Shortcodes:
  • [presto_player]
  • [presto_timestamp]
  • [presto_playlist]

Presto Player [presto_player] Shortcode

The ‘presto_player’ shortcode is a versatile tool within the Presto Player plugin. It initiates the video player, allowing for extensive customization. This shortcode uses attributes such as ‘id’, ‘src’, ‘title’, ‘provider’, and more, to define player settings. If no source is provided, but an ID is, it fetches a reusable video block. It also ensures the necessary scripts are loaded.

Shortcode: [presto_player]

Parameters

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

  • id – Unique identifier of the video player.
  • src – Source URL of the video.
  • title – Title of the video.
  • provider – Video provider (e.g., YouTube, Vimeo).
  • class – CSS class to style the player.
  • custom_field – Custom field for additional data.
  • poster – Image URL to display before video loads.
  • preload – Determines how video preloads; ‘auto’ by default.
  • preset – Preset video settings; ‘0’ by default.
  • autoplay – Autoplay video setting; ‘false’ by default.
  • plays_inline – Inline play setting; ‘false’ by default.
  • chapters – Array for defining video chapters.
  • overlays – Array for defining video overlays.
  • muted_autoplay_preview – Mute during autoplay preview; ‘false’ by default.
  • muted_autoplay_caption_preview – Mute captions during autoplay preview; ‘false’ by default.

Examples and Usage

Basic example – Display a video using the ‘id’ attribute to reference the video.

[presto_player id=1 /]

Advanced examples

Display a video using the ‘src’ attribute to reference the video source URL and the ‘title’ attribute to set the video title.

[presto_player src="https://example.com/video.mp4" title="My Video" /]

Display a video using the ‘id’ attribute to reference the video, with ‘autoplay’ set to true and ‘plays_inline’ set to true. This will play the video automatically and within the page layout.

[presto_player id=1 autoplay=true plays_inline=true /]

Display a video using the ‘src’ attribute to reference the video source URL and the ‘poster’ attribute to set the video poster image URL.

[presto_player src="https://example.com/video.mp4" poster="https://example.com/poster.jpg" /]

Display a video using the ‘id’ attribute to reference the video, with ‘muted_autoplay_preview’ set to true. This will play the video automatically with sound muted.

[presto_player id=1 muted_autoplay_preview=true /]

Display a video using the ‘id’ attribute to reference the video, with ‘muted_autoplay_caption_preview’ set to true. This will play the video automatically with sound muted and captions displayed.

[presto_player id=1 muted_autoplay_caption_preview=true /]

PHP Function Code

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

Shortcode line:

add_shortcode('presto_player', [$this, 'playerShortcode'], 10, 2);

Shortcode PHP function:

function playerShortcode($atts, $content)
  {
    if (!is_admin()) {
      // global is the most reliable between page builders
      global $load_presto_js;
      $load_presto_js = true;
      (new Scripts())->blockAssets(); // enqueue block assets
    }

    $atts = shortcode_atts(
      [
        'id' => '',
        'src' => '',
        'title' => '',
        'provider' => '',
        'class' => '',
        'custom_field' => '',
        'poster' => '',
        'preload' => 'auto',
        'preset' => 0,
        'autoplay' => false,
        'plays_inline' => false,
        'chapters' => [],
        'overlays' => [],
        'muted_autoplay_preview' => false,
        'muted_autoplay_caption_preview' => false,
      ],
      $atts
    );

    // could not find source but ID is present.
    if (!$atts['src'] && !$atts['custom_field'] && $atts['id']) {
      return ReusableVideos::getBlock($atts['id']);
    }

    $atts = $this->parseAttributes($atts, $content);
    return $this->renderBlock($atts);
  }

Code file location:

presto-player/presto-player/inc/Services/Shortcodes.php

Presto Player [presto_timestamp] Shortcode

The Presto Player shortcode ‘presto_timestamp’ allows you to insert a customizable timestamp into your WordPress content. This shortcode accepts ‘time’ as an attribute, which can be adjusted to match your needs. The function ‘timestampShortcode’ returns a ‘presto-timestamp’ HTML tag with the specified time attribute and content. This enables you to embed a timestamp within your posts or pages.

Shortcode: [presto_timestamp]

Parameters

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

  • time – Specifies the timestamp for the presto player.

Examples and Usage

Basic example – A Presto Player timestamp shortcode that specifies a time in seconds.

[presto_timestamp time="120"]Your content here[/presto_timestamp]

Advanced examples

Using the Presto Player timestamp shortcode to embed a timestamp within the content. The timestamp will be displayed at the specified time in the video.

[presto_timestamp time="180"]This is a timestamp at the 3-minute mark[/presto_timestamp]

Another advanced usage of the Presto Player timestamp shortcode, this time with multiple timestamps within the same content. Each timestamp will be displayed at its specified time in the video.

[presto_timestamp time="60"]This is a timestamp at the 1-minute mark[/presto_timestamp]
[presto_timestamp time="120"]This is a timestamp at the 2-minute mark[/presto_timestamp]
[presto_timestamp time="180"]This is a timestamp at the 3-minute mark[/presto_timestamp]

PHP Function Code

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

Shortcode line:

add_shortcode('presto_timestamp', [$this, 'timestampShortcode'], 10, 2);

Shortcode PHP function:

function timestampShortcode($atts, $content)
  {
    $atts = shortcode_atts(
      [
        'time' => '',
      ],
      $atts
    );
    return '<presto-timestamp time="' . esc_attr($atts['time']) . '">' . $content . '</presto-timestamp>';
  }

Code file location:

presto-player/presto-player/inc/Services/Shortcodes.php

Presto Player [presto_playlist] Shortcode

The ‘presto_playlist’ shortcode from Presto Player plugin is used to generate a playlist on your webpage. It enqueues block assets and parses playlist attributes.

Shortcode: [presto_playlist]

Examples and Usage

Basic example – A simple usage of the presto_playlist shortcode, which will display the playlist with the given ID.

[presto_playlist id=1 /]

Advanced examples

Displaying a presto_playlist with additional parameters. In this example, the ‘autoplay’ attribute is set to ‘true’, which will automatically play the first video in the playlist when it loads. The ‘loop’ attribute is also set to ‘true’, meaning the playlist will start over from the beginning once it reaches the end.

[presto_playlist id=1 autoplay=true loop=true /]

Another advanced usage could be to include the ‘mute’ attribute, which will start the playlist without any sound. This can be useful in certain scenarios where you don’t want the sound to automatically play, such as a background video on a webpage.

[presto_playlist id=1 autoplay=true loop=true mute=true /]

Remember, the ID attribute is mandatory for the presto_playlist shortcode to work. The other attributes are optional and can be used to customize your playlist’s behavior according to your needs.

PHP Function Code

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

Shortcode line:

add_shortcode('presto_playlist', [$this, 'playlistShortcode'], 10, 2);

Shortcode PHP function:

function playlistShortcode($atts, $content)
  {
    if (!is_admin()) {
      // global is the most reliable between page builders
      global $load_presto_js;
      $load_presto_js = true;
      (new Scripts())->blockAssets(); // enqueue block assets
    }

    $atts = $this->parsePlaylistAttributes($atts, $content);

    return (new PlaylistBlock())->html($atts);
  }

Code file location:

presto-player/presto-player/inc/Services/Shortcodes.php

Conclusion

Now that you’ve learned how to embed the Presto Player 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 *