[WordPress] 外掛分享: WP Theater

首頁外掛目錄 › WP Theater
WordPress 外掛 WP Theater 的封面圖片
200+
安裝啟用
★★★★
4.6/5 分(5 則評價)
3979 天前
最後更新
問題解決
WordPress 3.6+ v1.2.3 上架:2013-09-12

內容簡介

WP Theater 提供短碼 (shortcodes) 功能,可將 YouTube 和 Vimeo 影片嵌入及動態顯示到你的文章或小工具中。有不同的選項,包括傳統的嵌入方式、單一影片預覽、包含「Theater」特效的嵌入模式,以及從播放清單、頻道、影集和群組進行影片列表。 WP Theater是為開發人員而設計的,他們需要靈活性。因此,讓這個外掛保持簡單是做得最好的工作之一。

需求

當前版本在 WordPress 版本 3.9 及更高版本中測試。
要求 PHP 5.3 或更高版本以及 cURL。

用法

有關參數及其用法,請訪問:

http://redshiftstudio.com/wp-theater/

Boring Embed - 經典嵌入方式

預覽 - 單一影片的縮略圖和標題

Theater- 傳統嵌入方式,具備適配迷人的外觀,有可選的「燈光/暗」「全屏視窗」按鈕,具有響應式設計。

以下為默認包含「theater」的選項

用戶 - 列出用戶的影片

//有關 YouTube 的 v3 API 信息請參閱問答集,關於用戶上傳及播放清單的使用方法。

頻道 - 列出特定頻道中的影片

播放清單 - 列出來自用戶播放清單的影片

影集 - 列出特定影集中的影片

群組 - 列出特定群組中的影片

開發者常見問題
如何自定義輸出

已經存在可以完全自定義輸出的篩選器 (Filters)。可以透過「Filter_Hook」($ callback_params…)方式進行編寫。

顯示 - 覆蓋內建輸出

"wp_theater-pre_video_shortcode" (FALSE,$ feed,$ atts)
"wp_theater-pre_theater"(FALSE,$ atts,$ content,$ tag)
"wp_theater-pre_video_preview"(FALSE,$ video,$ atts,$ selected)

屬性

"wp_theater-format_params"($ atts,$ content,$ tag)

API Feeds - 覆蓋內建 API 請求和解析。注意:請記住,當緩存有效時,這些篩選器才會被調用。

"wp_theater-pre_get_request_url"(FALSE,$ atts,$ request,$ output)
"wp_theater-parse_{$service}_response"($ out,$ response ,$ atts)// v1.1.3

內容

"wp_theater-section_title"($ title)
"wp_theater-video_title"($ title)
"wp_theater-{$service}_more_url"(FALSE,$ atts,$ data)// v1.1.4

預設值

"wp_theater-get_preset"($ name)
"wp_theater-set_preset"($ arr,$ name)

如何添加自己的預設值

以下代碼將創建名為「my_preset」的預設值。我們目前沒有提供將預設值保存到數據庫以在佈景主題之間保留它們的方法,但正在計劃中。

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' ) );
}

外掛標籤

開發者團隊

⬇ 下載最新版 (v1.2.3) 或搜尋安裝

① 下載 ZIP → 後台「外掛 › 安裝外掛 › 上傳外掛」
② 後台搜尋「WP Theater」→ 直接安裝(推薦)
📦 歷史版本下載

原文外掛簡介

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.
Requirements

Current version tested on WordPress version 3.9 and later.
PHP 5.3 or later with cURL

Usage
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

Developer FAQ
How can I customize the output
Filters exist that can handle complete customization of the output. Written as “Filter_Hook” ($callback_params … )
Display — Override built in output

“wp_theater-pre_video_shortcode” ( FALSE, $feed, $atts )
“wp_theater-pre_theater” ( FALSE, $atts, $content, $tag )
“wp_theater-pre_video_preview” ( FALSE, $video, $atts, $selected )

Attributes

“wp_theater-format_params” ( $atts, $content, $tag )

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.

“wp_theater-pre_get_request_url” ( FALSE, $atts, $request, $output )
“wp_theater-parse_{$service}_response” ( $out, $response, $atts) // v1.1.3

Content

“wp_theater-section_title” ( $title )
“wp_theater-video_title” ( $title )
“wp_theater-{$service}_more_url” ( FALSE, $atts, $data ) // v1.1.4

Presets

“wp_theater-get_preset” ( $name )
“wp_theater-set_preset” ( $arr, $name )

How do I add my own preset?
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');

What values can I define in presets
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'
)
);

How can I modify the embed url?
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.
What do the formatted feeds look like?
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.

延伸相關外掛

文章
Filter
Apply Filters
Mastodon