Shortcodes for YouTube and Vimeo. Includes embeds, "Theater" embed, thumbed previews, playlist, channel, user uploads and groups.
WP Theater provides shortcodes for integrating YouTube and Vimeo video embeds and feeds into your posts or widgets. Some options include traditional embedding, single video previews, a wrapped “Theater” embed, and video listings from playlists, channels, albums and groups. WP Theater was built with developers in mind, those who need flexibility. With that said, great effort was put into making sure this plugin stayed simple.
For parameters and their usage please visit:
http://redshiftstudio.com/wp-theater/
Boring Embed – The classic
Preview – Thumbnail and title of a single video
Theater – Traditional embed that’s wrapped for styling, has optional Lower Lights and Full Window buttons, and is responsive.
The following contain a “theater” by default
User – Listing of a user’s videos
// for YouTube's v3 API see FAQ about user uploads vs playlists.
Channel – Listing of videos from a specific channel
Playlist – Listing of videos from a user’s playlist
Album – Listing of videos from a specific album
Group – Listing of videos from a specific group
Filters exist that can handle complete customization of the output. Written as “Filter_Hook” ($callback_params … )
Display — Override built in output
Attributes
API Feeds — Override built in api request and parsing. NOTE: Keep in mind that these filters will only be called when the transient cache is updated.
Content
Presets
The following code will create a preset named “my_preset”. We do not currently, but are planning to, offer a method of saving presets to the database so that they stick around between theme’s.
function my_preset_init ($presets) { $presets->set_preset( 'my_preset', shortcode_atts( $presets->get_preset( 'youtube' ), array( 'embed_width' => 342, 'embed_height' => 192, 'max' => 9, ) ) ); add_shortcode( 'my_preset', array( WP_Theater::$shortcodes, 'video_shortcode' ) ); } add_action('wp_theater-shortcodes_init', 'my_preset_init');
Listed below are all of the possible settings you can define in a preset with their base values
array( // general options 'preset' => '', 'service' => '', 'mode' => 'embed', 'id' => '', 'embed_width' => FALSE, 'embed_height' => FALSE, 'class' => '', 'cache' => FALSE, // preview & listing options 'img_size' => 'medium', 'columns' => 3, 'max' => 12, 'autoplay_onclick' => TRUE, // Title options 'show_title' => TRUE, 'show_video_title' => TRUE, 'title' => '', // More link options 'show_more_link' => TRUE, 'more_url' => FALSE, 'more_text' => FALSE, // Theater options 'show_theater' => TRUE, 'theater_id' => FALSE, 'show_fullwindow' => FALSE, 'show_lowerlights' => FALSE, 'keep_ratio' => TRUE, 'iframe_placeholder' = > TRUE // since 1.2.0 // can only be defined in presets 'modes' => array(), // the modes array with matching link formats 'classes' => array( // the classes to apply to their respective elements 'section' => 'entry-section wp-theater-section %service%', 'theater' => 'wp-theater-bigscreen', 'embed' => 'wp-theater-iframe', 'list' => 'wp-theater-listing', 'preview' => 'video-preview' ) );
Each preset requires a modes array to store the different link formats used. You can directly access and modify these yourself through a theme’s functions.php.
e.g.
// make youtube embed with https and youtube-nocookie.com function my_preset_init ($presets) { $youtube_preset = $presets->get_preset( 'youtube' ); $youtube_preset['modes']['embed'] = 'https://www.youtube-nocookie.com/embed/%id%?wmode=transparent&autohide=1'; $presets->set_preset( 'youtube', $youtube_preset ); } add_action('wp_theater-shortcodes_init', 'my_preset_init');
NOTE: Each mode URL must have %id% in the place of the id. And, it’s a bit dumb but, for now you must include at least one query parameter in an embed’s url.
Vimeo’s feed will return exactly what their API states except we merge their info and video requests into one and clone values to help normalize the feeds. Youtube on the other hand is almost completely reformatted into a format based on Vimeo’s
You can count on the full feeds returning the following content with an exception being that single preview feeds do not have the feed title or url.
Also, with YouTube’s v3 API enabled, rating, likeCount and viewCount will always be empty strings since you must use OAuth2 and be a verified content owner:
object 'title' => string 'url' => string 'videos' => array 0 => object 'title' => string 'id' => string 'url' => string 'upload_date' => string 'description' => string 'category' => string 'duration' => string 'rating' => string 'likeCount' => string 'viewCount' => string 'width' => string 'height' => string 'thumbnails' => array 'small' => string 'medium' => string 'large' => string 'cover' => string // since 1.2.0 -- set to the largest available image.
Please check the Other Notes section for futher development information.
This is to avoid an extra request from YouTube. Since YouTube automatically does a Uploads playlist, it is much easier to use that instead. So for v3, user and playlist modes are identical except for the titles.
To find your uploads playlist go to your user’s channel and hover over the Uploads section (not menu button). A play button will appear that links to your uploads playlist. Odd, I know. A bit of a PITA, I know.
No, this plugin will only show publically available content. It will skip any videos that are not publicly embeddable, even password protected videos. If you need this feature now then you are looking for a plugin that requires OAuth2 credentials from that service.
Not right now. Single previews, e.g. , are really only meant as a nice way to link to a video or for use with a popup.
Not for now, we suggest using playlists, albums or channels for this task. Benifits of both are the ability to add another user’s video as well as adding and reordering them directly from YouTube or Vimeo.
This is a stretch of this plugins scope but there is a possible fix. We followed TwentyFourteens method of the body element having a “masthead-fixed” class and the main header must have either an id of “masthead” or class of “site-header”.
Outside of the shortcode’s parameters there are settings for you to disable the loaded assets as well setting cache expirations, if used.
iframe_placeholder
image for playlist, user, group, album or channel modes (default: TRUE). More testing is needed before offering the same for stand alone embeds and theaters.