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

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