PluginProbe
Vimeography: Vimeo Video Gallery WordPress Plugin / 1.3
Vimeography: Vimeo Video Gallery WordPress Plugin v1.3
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 1.3, at vimeography.php

198 lines 6.7 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: 1.3
7 Author: Dave Kiss
8 Author URI: http://davekiss.com
9 License: GPL3
10 Text Domain: vimeography
11 */
12
13 if ( ! function_exists('json_decode') )
14 wp_die( __('Vimeography requires the JSON PHP extension.', 'vimeography') );
15
16 if ( ! class_exists( 'Vimeography' ) ) {
17
18 class Vimeography {
19 /**
20 * The Vimeography instance
21 *
22 * @var object
23 */
24 private static $instance = NULL;
25
26 /**
27 * Vimeography_Addons object
28 *
29 * @var object
30 * @since 1.2
31 */
32 public $addons;
33
34 /**
35 * Vimeography_Update object
36 *
37 * @var object
38 * @since 1.2
39 */
40 public $updater;
41
42 /**
43 * Creates or returns an instance of this class.
44 *
45 * @return Vimeography A single instance of this class.
46 */
47 public static function get_instance() {
48 if ( ! isset( self::$instance ) AND ! ( self::$instance instanceof Vimeography ) ) {
49 self::$instance = new self;
50 self::$instance->_define_constants();
51 self::$instance->_include_files();
52 Mustache_Autoloader::register();
53
54 if ( is_admin() ) {
55 new Vimeography_Admin_Scripts;
56 new Vimeography_Admin_Actions;
57 new Vimeography_Base;
58 new Vimeography_Admin_Menu;
59 new Vimeography_Admin_Plugins;
60 self::$instance->updater = new Vimeography_Update;
61 }
62
63 // Can save these in public vars if need to access
64 new Vimeography_Database;
65 new Vimeography_Upgrade;
66 new Vimeography_Deprecated;
67 new Vimeography_Init;
68 new Vimeography_Ajax;
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 define( 'VIMEOGRAPHY_URL', plugin_dir_url(__FILE__) );
90 define( 'VIMEOGRAPHY_PATH', plugin_dir_path(__FILE__) );
91 define( 'VIMEOGRAPHY_ASSETS_URL', VIMEOGRAPHY_URL . 'lib/shared/assets/' );
92 define( 'VIMEOGRAPHY_ASSETS_PATH', VIMEOGRAPHY_PATH. 'lib/shared/assets/' );
93 define( 'VIMEOGRAPHY_CACHE_PATH', WP_CONTENT_DIR . '/vimeography/cache/' );
94 define( 'VIMEOGRAPHY_CUSTOMIZATIONS_PATH', WP_CONTENT_DIR . '/vimeography/assets/css/' );
95 define( 'VIMEOGRAPHY_CUSTOMIZATIONS_URL', content_url() . '/vimeography/assets/css/' );
96 define( 'VIMEOGRAPHY_BASENAME', plugin_basename( __FILE__ ) );
97 define( 'VIMEOGRAPHY_VERSION', '1.3');
98 define( 'VIMEOGRAPHY_GALLERY_TABLE', $wpdb->prefix . "vimeography_gallery");
99 define( 'VIMEOGRAPHY_GALLERY_META_TABLE', $wpdb->prefix . "vimeography_gallery_meta");
100 define( 'VIMEOGRAPHY_CURRENT_PAGE', basename($_SERVER['PHP_SELF']));
101 define( 'VIMEOGRAPHY_CLIENT_ID', 'fc0927c077cb47345eadf7c513d70f4aa564f30d');
102 }
103
104 /**
105 * Include the files required by Vimeography.
106 * @return [type]
107 */
108 private function _include_files() {
109 require_once VIMEOGRAPHY_PATH . 'lib/exception.php';
110
111 // Require Mustache.php
112 if ( ! class_exists('Mustache_Engine') ) {
113 require_once VIMEOGRAPHY_PATH . '/vendor/mustache/mustache/src/Mustache/Autoloader.php';
114 }
115
116 if ( ! class_exists('Vimeography_Vimeo') ) {
117 require_once VIMEOGRAPHY_PATH . 'vendor/davekiss/vimeo-php/vimeo.php';
118 }
119
120 require_once VIMEOGRAPHY_PATH . 'lib/database.php';
121 require_once VIMEOGRAPHY_PATH . 'lib/upgrade.php';
122 require_once VIMEOGRAPHY_PATH . 'lib/deprecated.php';
123 require_once VIMEOGRAPHY_PATH . 'lib/addons.php';
124 require_once VIMEOGRAPHY_PATH . 'lib/ajax.php';
125 require_once VIMEOGRAPHY_PATH . 'lib/rewrite.php';
126 require_once VIMEOGRAPHY_PATH . 'lib/filesystem.php';
127 require_once VIMEOGRAPHY_PATH . 'lib/init.php';
128 require_once VIMEOGRAPHY_PATH . 'lib/robots.php';
129 require_once VIMEOGRAPHY_PATH . 'lib/shortcode.php';
130 require_once VIMEOGRAPHY_PATH . 'vimeography-bugsauce/vimeography-bugsauce.php';
131
132 if ( is_admin() ) {
133 require_once VIMEOGRAPHY_PATH . 'lib/admin/scripts.php';
134 require_once VIMEOGRAPHY_PATH . 'lib/admin/actions.php';
135 require_once VIMEOGRAPHY_PATH . 'lib/admin/base.php';
136 require_once VIMEOGRAPHY_PATH . 'lib/admin/menu.php';
137 require_once VIMEOGRAPHY_PATH . 'lib/admin/plugins.php';
138 require_once VIMEOGRAPHY_PATH . 'lib/update.php';
139 }
140 }
141
142 /**
143 * Checks if the provided Vimeo URL is valid and if so, returns a
144 * string to be used as the collection endpoint.
145 *
146 * @param string $source_url Source collection of Vimeo videos.
147 * @return string Vimeo Resource
148 */
149 public static function validate_vimeo_source($source_url) {
150 // Add scheme if it wasn't provided in source url
151 $scheme = parse_url( $source_url );
152
153 if ( empty( $scheme['scheme'] ) ) {
154 $source_url = 'https://' . $source_url;
155 }
156
157 // Only continue if the parse_url function didn't fail
158 // and the host is one of vimeo.com or vimeopro.com
159 if ( ( ($url = parse_url($source_url) ) !== FALSE ) && (preg_match('~vimeo(?:pro)?\.com$~', $url['host']) > 0)) {
160 $host = $url['host'];
161
162 // Create an array with the resource parts
163 $url = array_values(array_filter(explode('/', $url['path']), 'strlen'));
164
165 // If the array doesn't contain one of the following strings, it
166 // must be either a user or a video
167 if (in_array($url[0], array('album', 'channels', 'groups', 'categories')) !== TRUE) {
168 if (is_numeric($url[0])) {
169 array_unshift($url, 'videos');
170 } else {
171 array_unshift($url, 'users');
172 if ( isset($url[2]) ) {
173 if ($host != 'vimeo.com') {
174 // Convert /users/username/portfolio_name to /users/username/portfolios/portfolio_name
175 array_splice($url, 2, 0, array('portfolios'));
176 } elseif ($url[2] === 'videos') {
177 // Remove 'videos' from '/users/username/videos'
178 unset($url[2]);
179 }
180 }
181 }
182 }
183
184 // Make sure the resource is plural
185 $url[0] = rtrim($url[0], 's') . 's';
186 $resource = '/' . implode('/', $url);
187
188 return $resource;
189 } else {
190 throw new Vimeography_Exception(
191 __('That site doesn\'t look like a valid link to a Vimeo collection.', 'vimeography')
192 );
193 }
194 }
195 }
196 }
197
198 Vimeography::get_instance();