PluginProbe ʕ •ᴥ•ʔ
YITH WooCommerce Wishlist / 4.0.1
YITH WooCommerce Wishlist v4.0.1
trunk 2.1.0 2.1.1 2.1.2 2.2.0 2.2.1 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.17 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0.0 3.0.1 3.0.10 3.0.11 3.0.12 3.0.13 3.0.14 3.0.15 3.0.16 3.0.17 3.0.18 3.0.19 3.0.2 3.0.20 3.0.21 3.0.22 3.0.23 3.0.25 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.10.0 3.11.0 3.12.0 3.13.0 3.14.0 3.15.0 3.16.0 3.17.0 3.18.0 3.19.0 3.2.0 3.20.0 3.21.0 3.22.0 3.23.0 3.24.0 3.25.0 3.26.0 3.27.0 3.28.0 3.29.0 3.3.0 3.30.0 3.31.0 3.32.0 3.33.0 3.34.0 3.35.0 3.36.0 3.37.0 3.38.0 3.4.0 3.5.0 3.6.0 3.7.0 3.8.0 3.9.0 4.0.0 4.0.1 4.1.0 4.10.0 4.10.1 4.10.2 4.11.0 4.12.0 4.13.0 4.14.0 4.15.0 4.2.0 4.3.0 4.4.0 4.5.0 4.6.0 4.7.0 4.8.0 4.9.0
yith-woocommerce-wishlist / plugin-fw / includes / class-yit-video.php
yith-woocommerce-wishlist / plugin-fw / includes Last commit date
builders 2 years ago privacy 2 years ago class-yit-ajax.php 2 years ago class-yit-assets.php 2 years ago class-yit-cpt-unlimited.php 5 years ago class-yit-gradients.php 2 years ago class-yit-help-desk.php 2 years ago class-yit-icons.php 2 years ago class-yit-metabox.php 2 years ago class-yit-plugin-common.php 5 years ago class-yit-plugin-licence.php 2 years ago class-yit-plugin-panel-woocommerce.php 1 year ago class-yit-plugin-panel.php 1 year ago class-yit-plugin-subpanel.php 2 years ago class-yit-pointers.php 2 years ago class-yit-theme-licence.php 2 years ago class-yit-upgrade.php 5 years ago class-yit-video.php 5 years ago class-yith-bh-onboarding.php 3 years ago class-yith-dashboard.php 4 years ago class-yith-debug.php 2 years ago class-yith-external-services.php 1 year ago class-yith-post-type-admin.php 2 years ago class-yith-system-status.php 1 year ago
class-yit-video.php
193 lines
1 <?php
2 /**
3 * YITH Video Class
4 * manage videos from youtube, vimeo and other services.
5 *
6 * @class YIT_Video
7 * @package YITH\PluginFramework\Classes
8 */
9
10 defined( 'ABSPATH' ) || exit; // Exit if accessed directly.
11
12 if ( ! class_exists( 'YIT_Video' ) ) {
13 /**
14 * YIT_Video class.
15 *
16 * @deprecated 3.5
17 */
18 class YIT_Video {
19
20 /**
21 * Generate the HTML for a youtube video
22 *
23 * @param array $args Array of arguments to configure the video to generate.
24 *
25 * @return string
26 */
27 public static function youtube( $args = array() ) {
28 $defaults = array(
29 'id' => '',
30 'url' => '',
31 'width' => 425,
32 'height' => 356,
33 'echo' => false,
34 );
35 $args = wp_parse_args( $args, $defaults );
36
37 $id = $args['id'];
38 $url = $args['url'];
39 $width = $args['width'];
40 $height = $args['height'];
41 $echo = $args['echo'];
42 $html = '';
43
44 // Retrieve the video ID if we have only the URL.
45 if ( ! $id && ! ! $url ) {
46 $id = self::video_id_by_url( $url );
47 }
48
49 if ( $id ) {
50 $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
51 $id = preg_replace( '/(youtube|vimeo):/', '', $id );
52 $url = "https://www.youtube.com/embed/{$id}?wmode=transparent";
53
54 $html = '<div class="post_video youtube">' .
55 '<iframe wmode="transparent" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $url ) . '" frameborder="0" allowfullscreen></iframe>' .
56 '</div>';
57 $html = apply_filters( 'yit_video_youtube', $html );
58 }
59
60 if ( $echo ) {
61 echo wp_kses_post( $html );
62 }
63
64 return $html;
65 }
66
67 /**
68 * Generate the HTML for a vimeo video
69 *
70 * @param array $args Array of arguments to configure the video to generate.
71 *
72 * @return string
73 */
74 public static function vimeo( $args = array() ) {
75 $defaults = array(
76 'id' => '',
77 'url' => '',
78 'width' => 425,
79 'height' => 356,
80 'echo' => false,
81 );
82 $args = wp_parse_args( $args, $defaults );
83
84 $id = $args['id'];
85 $url = $args['url'];
86 $width = $args['width'];
87 $height = $args['height'];
88 $echo = $args['echo'];
89 $html = '';
90
91 // Retrieve the video ID if we have only the URL.
92 if ( ! $id && ! ! $url ) {
93 $id = self::video_id_by_url( $url );
94 }
95
96 if ( $id ) {
97 $id = preg_replace( '/[&|&amp;]feature=([\w\-]*)/', '', $id );
98 $id = preg_replace( '/(youtube|vimeo):/', '', $id );
99 $protocol = is_ssl() ? 'https' : 'http';
100 $url = "{$protocol}://player.vimeo.com/video/{$id}?title=0&amp;byline=0&amp;portrait=0";
101
102 $html = '<div class="post_video youtube">' .
103 '<iframe wmode="transparent" width="' . esc_attr( $width ) . '" height="' . esc_attr( $height ) . '" src="' . esc_url( $url ) . '" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>' .
104 '</div>';
105 $html = apply_filters( 'yit_video_vimeo', $html );
106 }
107
108 if ( $echo ) {
109 echo wp_kses_post( $html );
110 }
111
112 return $html;
113 }
114
115 /**
116 * Retrieve video ID from URL
117 *
118 * @param string $url URL of the video.
119 *
120 * @return bool|string
121 */
122 public static function video_id_by_url( $url ) {
123 $parsed = wp_parse_url( esc_url( $url ) );
124 $host = isset( $parsed['host'] ) ? $parsed['host'] : false;
125
126 switch ( $host ) {
127 case 'youtube.com':
128 case 'www.youtube.com':
129 case 'youtu.be':
130 case 'www.youtu.be':
131 $id = self::youtube_id_by_url( $url );
132 $video_id = "youtube:$id";
133 break;
134
135 case 'www.vimeo.com':
136 case 'vimeo.com':
137 preg_match( '/http(s)?:\/\/(\w+.)?vimeo\.com\/(.*\/)?([0-9]+)/', $url, $matches );
138
139 $id = trim( $matches[4], '/' );
140 $video_id = "vimeo:$id";
141 break;
142
143 default:
144 $video_id = false;
145
146 }
147
148 return $video_id;
149 }
150
151 /**
152 * Retrieve video ID from URL
153 *
154 * @param string $url URL of the video.
155 *
156 * @return bool|string
157 */
158 protected static function youtube_id_by_url( $url ) {
159 if ( preg_match( '/http(s)?:\/\/youtu.be/', $url, $matches ) ) {
160 $url = wp_parse_url( $url, PHP_URL_PATH );
161 $url = str_replace( '/', '', $url );
162
163 return $url;
164
165 } elseif ( preg_match( '/watch/', $url, $matches ) ) {
166 $arr = wp_parse_url( $url );
167 $url = str_replace( 'v=', '', $arr['query'] );
168
169 return $url;
170
171 } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/v/', $url, $matches ) ) {
172 $arr = wp_parse_url( $url );
173 $url = str_replace( '/v/', '', $arr['path'] );
174
175 return $url;
176
177 } elseif ( preg_match( '/http(s)?:\/\/(\w+.)?youtube.com\/embed/', $url, $matches ) ) {
178 $arr = wp_parse_url( $url );
179 $url = str_replace( '/embed/', '', $arr['path'] );
180
181 return $url;
182
183 } elseif ( preg_match( "#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=[0-9]/)[^&\n]+|(?<=v=)[^&\n]+#", $url, $matches ) ) {
184 return $matches[0];
185
186 } else {
187 return false;
188 }
189 }
190
191 }
192 }
193