PluginProbe
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI / 8.0.3
GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI v8.0.3
8.0.4 8.0.3 8.0.1 8.0.2 8.0.0 7.9.9.7 7.9.9.6 7.9.9.5 7.9.9.4 7.9.9.3 7.9.9.2 7.9.9.1 7.9.9 7.9.8 7.9.7 7.9.6 7.9.5 7.9.4 7.9.3 7.9.2 7.9.1 7.9.0 7.8.9 7.8.8 7.8.7 All 46 releases
gamipress / integrations / vimeo / includes / functions.php

functions.php in GamiPress – Gamification plugin to reward points, badges & ranks in WordPress, now with AI 8.0.3, at integrations/vimeo/includes/functions.php

55 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Admin
4 *
5 * @package GamiPress\Vimeo\Admin
6 * @since 1.0.0
7 */
8 // Exit if accessed directly
9 if( !defined( 'ABSPATH' ) ) exit;
10
11 /**
12 * Extract the video ID from the given URL
13 *
14 * @since 1.0.0
15 *
16 * @param string $url
17 *
18 * @return string
19 */
20 function gamipress_vimeo_get_video_id_from_url( $url ) {
21
22 // Support for the following valid URLs
23 // http://vimeo.com/{video_id}
24 // http://player.vimeo.com/video/{video_id}
25 // http://player.vimeo.com/video/{video_id}?title=0&byline=0&portrait=0
26 // http://vimeo.com/channels/user/{video_id}
27 preg_match("#(?:https?://)?(?:www.)?(?:player.)?vimeo.com/(?:[a-z]*/)*([0-9]{6,11})[?]?.*#", $url, $matches);
28
29 $video_id = (isset( $matches[1] ) ? $matches[1] : $url );
30
31 return $video_id;
32
33 }
34
35 /**
36 * Check the video ID format
37 *
38 * @since 1.0.0
39 *
40 * @param string $video_id
41 *
42 * @return string
43 */
44 function gamipress_vimeo_check_video_id_format( $video_id ) {
45
46 $video_id = trim( $video_id );
47
48 // Check if video ID has 6 to 11 characters
49 if ( preg_match( '/^[0-9]{6,11}$/', $video_id ) ) {
50 return true;
51 }
52
53 return false;
54
55 }