PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 2.0.7
Vimeography: Vimeo Video Gallery WordPress Plugin v2.0.7
2.4.9 2.4.8 trunk 0.5.1 0.5.2 0.5.3 0.5.4 0.5.5 0.5.6 0.5.7 0.6 0.6.1 0.6.2 0.6.3 0.6.4 0.6.5 0.6.6 0.6.7 0.6.8 0.6.8.1 0.6.9 0.6.9.1 0.6.9.2 0.7 0.8 All 103 releases
vimeography / vimeography.php

vimeography.php in Vimeography: Vimeo Video Gallery WordPress Plugin 2.0.7, at vimeography.php

209 lines 7.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: Vimeography
4 Plugin URI: http://vimeography.com
5 Description: Vimeography is the easiest way to set up a custom Vimeo gallery on your site.
6 Version: 2.0.7
7 Requires PHP: 5.3
8 Author: Dave Kiss
9 Author URI: http://davekiss.com
10 License: GPL3
11 Text Domain: vimeography
12 */
13
14 if ( ! function_exists('json_decode') )
15 wp_die( __('Vimeography requires the JSON PHP extension.', 'vimeography') );
16
17 if ( ! class_exists( 'Vimeography' ) ) {
18
19 class Vimeography {
20 /**
21 * The Vimeography instance
22 *
23 * @var object
24 */
25 private static $instance = NULL;
26
27 /**
28 * Vimeography_Addons object
29 *
30 * @var object
31 * @since 1.2
32 */
33 public $addons;
34
35 /**
36 * Vimeography_Update object
37 *
38 * @var object
39 * @since 1.2
40 */
41 public $updater;
42
43 /**
44 * Creates or returns an instance of this class.
45 *
46 * @return Vimeography A single instance of this class.
47 */
48 public static function get_instance() {
49 if ( ! isset( self::$instance ) AND ! ( self::$instance instanceof Vimeography ) ) {
50 self::$instance = new self;
51 self::$instance->_define_constants();
52 self::$instance->_include_files();
53 Mustache_Autoloader::register();
54
55 if ( is_admin() ) {
56 new Vimeography_Admin_Scripts;
57 new Vimeography_Admin_Actions;
58 new Vimeography_Base;
59 new Vimeography_Admin_Menu;
60 new Vimeography_Admin_Welcome;
61 new Vimeography_Admin_Plugins;
62 self::$instance->updater = new Vimeography_Update;
63 }
64
65 // Can save these in public vars if need to access
66 new Vimeography_Database;
67 new Vimeography_Deprecated;
68 new Vimeography_Init;
69 self::$instance->addons = new Vimeography_Addons;
70 new Vimeography_Robots;
71 new Vimeography_Shortcode;
72 }
73
74 return self::$instance;
75 }
76
77 /**
78 * Empty constructor… boring.
79 */
80 public function __construct() { }
81
82 /**
83 * Define all of the constants used throughout the plugin.
84 *
85 * @return void
86 */
87 private function _define_constants() {
88 global $wpdb;
89
90 if ( ! isset( $wpdb->vimeography_gallery ) && ! isset( $wpdb->vimeography_gallery_meta ) ) {
91 $wpdb->vimeography_gallery = $wpdb->prefix . 'vimeography_gallery';
92 $wpdb->vimeography_gallery_meta = $wpdb->prefix . 'vimeography_gallery_meta';
93 }
94
95 define( 'VIMEOGRAPHY_URL', plugin_dir_url(__FILE__) );
96 define( 'VIMEOGRAPHY_PATH', plugin_dir_path(__FILE__) );
97 define( 'VIMEOGRAPHY_ASSETS_URL', VIMEOGRAPHY_URL . 'lib/shared/assets/' );
98 define( 'VIMEOGRAPHY_ASSETS_PATH', VIMEOGRAPHY_PATH. 'lib/shared/assets/' );
99 define( 'VIMEOGRAPHY_CACHE_PATH', WP_CONTENT_DIR . '/vimeography/cache/' );
100 define( 'VIMEOGRAPHY_CUSTOMIZATIONS_PATH', WP_CONTENT_DIR . '/vimeography/assets/css/' );
101 define( 'VIMEOGRAPHY_CUSTOMIZATIONS_URL', content_url() . '/vimeography/assets/css/' );
102 define( 'VIMEOGRAPHY_BASENAME', plugin_basename( __FILE__ ) );
103 define( 'VIMEOGRAPHY_VERSION', '2.0.7');
104 define( 'VIMEOGRAPHY_CURRENT_PAGE', basename($_SERVER['PHP_SELF']));
105 define( 'VIMEOGRAPHY_ACCESS_TOKEN', 'eaf47146f04b5550a3e394f3bbf8273f');
106 }
107
108 /**
109 * Include the files required by Vimeography.
110 * @return [type]
111 */
112 private function _include_files() {
113 require_once VIMEOGRAPHY_PATH . 'lib/exception.php';
114
115 // Require Mustache.php
116 if ( ! class_exists('Mustache_Engine') ) {
117 require_once VIMEOGRAPHY_PATH . '/vendor/mustache/mustache/src/Mustache/Autoloader.php';
118 }
119
120 if ( ! class_exists('\Vimeography\Vimeo') ) {
121 require_once VIMEOGRAPHY_PATH . 'vendor/vimeo/vimeo-api/src/Vimeo/Vimeo.php';
122 require_once VIMEOGRAPHY_PATH . 'vendor/vimeo/vimeo-api/src/Vimeo/Exceptions/ExceptionInterface.php';
123 require_once VIMEOGRAPHY_PATH . 'vendor/vimeo/vimeo-api/src/Vimeo/Exceptions/VimeoRequestException.php';
124 require_once VIMEOGRAPHY_PATH . 'vendor/vimeo/vimeo-api/src/Vimeo/Exceptions/VimeoUploadException.php';
125 }
126
127 require_once VIMEOGRAPHY_PATH . 'lib/database.php';
128 require_once VIMEOGRAPHY_PATH . 'lib/deprecated/deprecated.php';
129 require_once VIMEOGRAPHY_PATH . 'lib/addons.php';
130 require_once VIMEOGRAPHY_PATH . 'lib/rewrite.php';
131 require_once VIMEOGRAPHY_PATH . 'lib/filesystem.php';
132 require_once VIMEOGRAPHY_PATH . 'lib/init.php';
133 require_once VIMEOGRAPHY_PATH . 'lib/robots.php';
134
135 require_once VIMEOGRAPHY_PATH . 'lib/engine.php';
136 require_once VIMEOGRAPHY_PATH . 'lib/shortcode.php';
137 require_once VIMEOGRAPHY_PATH . 'vimeography-bugsauce/vimeography-bugsauce.php';
138 require_once VIMEOGRAPHY_PATH . 'vimeography-harvestone/vimeography-harvestone.php';
139
140 if ( is_admin() ) {
141 require_once VIMEOGRAPHY_PATH . 'lib/admin/scripts.php';
142 require_once VIMEOGRAPHY_PATH . 'lib/admin/actions.php';
143 require_once VIMEOGRAPHY_PATH . 'lib/admin/base.php';
144 require_once VIMEOGRAPHY_PATH . 'lib/admin/menu.php';
145 require_once VIMEOGRAPHY_PATH . 'lib/admin/welcome.php';
146 require_once VIMEOGRAPHY_PATH . 'lib/admin/plugins.php';
147 require_once VIMEOGRAPHY_PATH . 'lib/update.php';
148 }
149 }
150
151 /**
152 * Checks if the provided Vimeo URL is valid and if so, returns a
153 * string to be used as the collection endpoint.
154 *
155 * @param string $source_url Source collection of Vimeo videos.
156 * @return string Vimeo Resource
157 */
158 public static function validate_vimeo_source($source_url) {
159 // Add scheme if it wasn't provided in source url
160 $scheme = parse_url( $source_url );
161
162 if ( empty( $scheme['scheme'] ) ) {
163 $source_url = 'https://' . $source_url;
164 }
165
166 // Only continue if the parse_url function didn't fail
167 // and the host is one of vimeo.com or vimeopro.com
168 if ( ( ($url = parse_url($source_url) ) !== FALSE ) && (preg_match('~vimeo(?:pro)?\.com$~', $url['host']) > 0)) {
169 $host = $url['host'];
170
171 $url['path'] = str_replace('/manage', '', $url['path']);
172
173 // Create an array with the resource parts
174 $url = array_values(array_filter(explode('/', $url['path']), 'strlen'));
175
176 // If the array doesn't contain one of the following strings, it
177 // must be either a user or a video
178 if (in_array($url[0], array('album', 'albums', 'channels', 'groups', 'categories', 'tags')) !== TRUE) {
179 if (is_numeric($url[0])) {
180 array_unshift($url, 'videos');
181 } else {
182 array_unshift($url, 'users');
183 if ( isset($url[2]) ) {
184 if ($host != 'vimeo.com') {
185 // Convert /users/username/portfolio_name to /users/username/portfolios/portfolio_name
186 array_splice($url, 2, 0, array('portfolios'));
187 } elseif ($url[2] === 'videos') {
188 // Remove 'videos' from '/users/username/videos'
189 unset($url[2]);
190 }
191 }
192 }
193 }
194
195 // Make sure the resource is plural
196 $url[0] = rtrim($url[0], 's') . 's';
197 $resource = '/' . implode('/', $url);
198
199 return $resource;
200 } else {
201 throw new Vimeography_Exception(
202 __('That site doesn\'t look like a valid link to a Vimeo collection.', 'vimeography')
203 );
204 }
205 }
206 }
207 }
208
209 Vimeography::get_instance();