| 1 |
<?php |
| 2 |
/* |
| 3 |
* License: GPLv3 |
| 4 |
* License URI: https://www.gnu.org/licenses/gpl.txt |
| 5 |
* Copyright 2012-2026 Jean-Sebastien Morisset (https://wpsso.com/) |
| 6 |
*/ |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
|
| 10 |
die( 'These aren\'t the droids you\'re looking for.' ); |
| 11 |
} |
| 12 |
|
| 13 |
if ( ! class_exists( 'WpssoStdMediaWpvideoshortcode' ) ) { |
| 14 |
|
| 15 |
class WpssoStdMediaWpvideoshortcode { |
| 16 |
|
| 17 |
private $p; // Wpsso class object. |
| 18 |
|
| 19 |
public function __construct( &$plugin ) { |
| 20 |
|
| 21 |
$this->p =& $plugin; |
| 22 |
|
| 23 |
if ( $this->p->debug->enabled ) { |
| 24 |
|
| 25 |
$this->p->debug->mark(); |
| 26 |
} |
| 27 |
|
| 28 |
/* |
| 29 |
* Filter priorities: |
| 30 |
* |
| 31 |
* 10 = Youtube Videos. |
| 32 |
* 20 = Vimeo Videos. |
| 33 |
* 30 = Wistia Videos. |
| 34 |
* 40 = Slideshare Presentations. |
| 35 |
* 60 = Facebook Videos. |
| 36 |
* 80 = Soundcloud Tracks. |
| 37 |
* 100 = WP Media Library Video Blocks. |
| 38 |
* 110 = WP Media Library Video Shortcodes. |
| 39 |
* 1000 = Gravatar Images. |
| 40 |
*/ |
| 41 |
$this->p->util->add_plugin_filters( $this, array( |
| 42 |
'content_videos' => 3, |
| 43 |
), $prio = 110 ); |
| 44 |
} |
| 45 |
|
| 46 |
public function filter_content_videos( $videos, $content, $mod ) { |
| 47 |
|
| 48 |
if ( $this->p->debug->enabled ) { |
| 49 |
|
| 50 |
$this->p->debug->mark(); |
| 51 |
} |
| 52 |
|
| 53 |
/* |
| 54 |
* Example video shortcode: |
| 55 |
* |
| 56 |
* <video class="wp-video-shortcode" id="video-6937-1" width="850" height="478" |
| 57 |
* poster="https://f9affd5f1846f0e624eb81ef-fzsx3idmvfhl.netdna-ssl.com/wp-content/uploads/2018/01/cover-min.png" |
| 58 |
* preload="none" controls="controls"> |
| 59 |
* |
| 60 |
* <source type="video/mp4" src="https://f9affd5f1846f0e624eb81ef-fzsx3idmvfhl.netdna-ssl.com/wp-content/uploads/2018/01/ranking_2.mp4" /> |
| 61 |
* |
| 62 |
* <a href="https://f9affd5f1846f0e624eb81ef-fzsx3idmvfhl.netdna-ssl.com/wp-content/uploads/2018/01/ranking_2.mp4"> |
| 63 |
* https://www.forwardpathway.com/wp-content/uploads/2018/01/ranking_2.mp4 |
| 64 |
* </a> |
| 65 |
* |
| 66 |
* </video> |
| 67 |
*/ |
| 68 |
if ( preg_match_all( '/<video class="wp-video-shortcode[^"]*" [^<>]*>[^<>]*' . |
| 69 |
'<source type=[\'"]([^\'"<>]+)[\'"] src=[\'"]([^\'"<>]+)[\'"].*<\/video>/Ui', |
| 70 |
$content, $all_matches, PREG_SET_ORDER ) ) { |
| 71 |
|
| 72 |
if ( $this->p->debug->enabled ) { |
| 73 |
|
| 74 |
$this->p->debug->log( 'WordPress shortcode video URL found but no video API modules' ); |
| 75 |
} |
| 76 |
|
| 77 |
if ( $this->p->notice->is_admin_pre_notices() ) { |
| 78 |
|
| 79 |
$this->p->msgs->pro_feature_video_found_notice( _x( 'WordPress shortcode', 'video service name', 'wpsso' ), $mod ); |
| 80 |
} |
| 81 |
|
| 82 |
} elseif ( $this->p->debug->enabled ) { |
| 83 |
|
| 84 |
$this->p->debug->log( 'no <video/> WordPress video shortcode tag(s) found' ); |
| 85 |
} |
| 86 |
|
| 87 |
return $videos; |
| 88 |
} |
| 89 |
} |
| 90 |
} |
| 91 |
|