diff --git functions.php functions.php
index 24cc677..8a3e4f4 100644
|
|
class WordPressTV_Theme { |
13 | 13 | require_once get_template_directory() . '/plugins/wordpresstv-rest/wordpresstv-rest.php'; |
14 | 14 | require_once get_template_directory() . '/plugins/wordpresstv-anon-upload/anon-upload.php'; |
15 | 15 | require_once get_template_directory() . '/plugins/wordpresstv-upload-subtitles/wordpresstv-upload-subtitles.php'; |
| 16 | require_once get_template_directory() . '/plugins/wordpresstv-twitter-player/wordpresstv-twitter-player.php'; |
16 | 17 | |
17 | 18 | add_action( 'after_setup_theme', array( $this, 'setup' ) ); |
18 | 19 | } |
diff --git plugins/wordpresstv-twitter-player/wordpresstv-twitter-player.php plugins/wordpresstv-twitter-player/wordpresstv-twitter-player.php
new file mode 100644
index 0000000..28cf8c4
-
|
+
|
|
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * Add Twitter card player |
| 5 | * |
| 6 | */ |
| 7 | |
| 8 | class WordPressTV_TwitterPlayer { |
| 9 | |
| 10 | function __construct() { |
| 11 | |
| 12 | global $wp_query; |
| 13 | $post = $wp_query->post; |
| 14 | $atts = shortcode_parse_atts($post->post_content); |
| 15 | $video_id = false; |
| 16 | $output = false; |
| 17 | |
| 18 | preg_match_all( '/' . get_shortcode_regex() . '/s', $post->post_content, $matches, PREG_SET_ORDER ); |
| 19 | |
| 20 | // Loop through matched shortcodes |
| 21 | foreach ( $matches as $match ) { |
| 22 | // Check for wpvideo |
| 23 | if ( isset($match[2]) && $match[2] == 'wpvideo' ) { |
| 24 | $video_id = isset($match[3]) ? $match[3] : false; |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | // If an ID was found print twitter:card tags |
| 29 | if ( $video_id ) { |
| 30 | $output = '<meta name="twitter:player" content="https://videopress.com/v/' . $video_id . '?autoplay=0" />'; |
| 31 | |
| 32 | // This meta value should be the mp4 value from VideoPress |
| 33 | $output .= '<meta name="twitter:player:stream" content="" />'; |
| 34 | } |
| 35 | |
| 36 | if ( $output ) { |
| 37 | echo $output; |
| 38 | } |
| 39 | |
| 40 | } |
| 41 | |
| 42 | } |
| 43 | |
| 44 | function wptv_twitterplayer_init() { |
| 45 | $WordPressTV_TwitterPlayer = new WordPressTV_TwitterPlayer(); |
| 46 | } |
| 47 | |
| 48 | add_action( 'wp_head', 'wptv_twitterplayer_init' ); |