PluginProbe
WPSSO Core – Complete Schema Markup and Meta Tags / trunk
WPSSO Core – Complete Schema Markup and Meta Tags vtrunk
22.6.1 22.6.0 22.5.3 22.5.2 22.5.1 22.4.0 22.3.0 22.2.1 22.2.0 22.1.3 22.1.2 22.1.1 22.1.0 22.0.0 21.13.3 21.13.2 trunk 21.13.1
wpsso / lib / std / media / facebook.php

facebook.php in WPSSO Core – Complete Schema Markup and Meta Tags trunk, at lib/std/media/facebook.php

108 lines 2.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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( 'WpssoStdMediaFacebook' ) ) {
14
15 class WpssoStdMediaFacebook {
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 'video_details' => 3,
43 ), $prio = 60 );
44 }
45
46 public function filter_video_details( $mt_single_video, $args, $mod ) {
47
48 if ( $this->p->debug->enabled ) {
49
50 $this->p->debug->mark();
51 }
52
53 if ( ! empty( $args[ 'attach_id' ] ) ) {
54
55 if ( $this->p->debug->enabled ) {
56
57 $this->p->debug->log( 'exiting early: have attachment ID' );
58 }
59
60 return array();
61
62 } elseif ( false === strpos( $args[ 'url' ], 'facebook.com' ) ) { // Optimize before preg_match().
63
64 if ( $this->p->debug->enabled ) {
65
66 $this->p->debug->log( 'exiting early: "facebook.com" string not found in video URL' );
67 }
68
69 return array();
70
71 /*
72 * Note that forward-slashes in the 'href' query value are encoded as %2F.
73 *
74 * Example: https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook%2Fvideos%2F10153231379946729%2F&width=500&show_text=false&appId=525239184171769&height=281
75 */
76 } elseif ( preg_match( '/^.*(facebook\.com)\/plugins\/video.php\?href=([^\/\?\&\#<>]+).*$/', $args[ 'url' ], $match ) ) {
77
78 if ( $this->p->debug->enabled ) {
79
80 $this->p->debug->log( 'Facebook video URL found but no video API modules' );
81 }
82
83 if ( $this->p->notice->is_admin_pre_notices() ) {
84
85 $this->p->msgs->pro_feature_video_found_notice( _x( 'Facebook', 'video service name', 'wpsso' ), $mod );
86 }
87
88 /*
89 * Example: https://www.facebook.com/DrDainHeer/videos/943226206036691/
90 */
91 } elseif ( preg_match( '/^(.*facebook\.com\/.*\/videos\/[^\?\#]+).*$/', $args[ 'url' ], $match ) ) {
92
93 if ( $this->p->debug->enabled ) {
94
95 $this->p->debug->log( 'Facebook video URL found but no video API modules' );
96 }
97
98 if ( $this->p->notice->is_admin_pre_notices() ) {
99
100 $this->p->msgs->pro_feature_video_found_notice( _x( 'Facebook', 'video service name', 'wpsso' ), $mod );
101 }
102 }
103
104 return array();
105 }
106 }
107 }
108