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

190 lines 6.1 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
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');
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 require_once VIMEOGRAPHY_PATH . 'vendor/davekiss/vimeo-php/vimeo.php';
113
114 require_once VIMEOGRAPHY_PATH . 'lib/database.php';
115 require_once VIMEOGRAPHY_PATH . 'lib/upgrade.php';
116 require_once VIMEOGRAPHY_PATH . 'lib/deprecated.php';
117 require_once VIMEOGRAPHY_PATH . 'lib/addons.php';
118 require_once VIMEOGRAPHY_PATH . 'lib/ajax.php';
119 require_once VIMEOGRAPHY_PATH . 'lib/rewrite.php';
120 require_once VIMEOGRAPHY_PATH . 'lib/filesystem.php';
121 require_once VIMEOGRAPHY_PATH . 'lib/init.php';
122 require_once VIMEOGRAPHY_PATH . 'lib/robots.php';
123 require_once VIMEOGRAPHY_PATH . 'lib/shortcode.php';
124 require_once VIMEOGRAPHY_PATH . 'vimeography-bugsauce/vimeography-bugsauce.php';
125
126 if ( is_admin() ) {
127 require_once VIMEOGRAPHY_PATH . 'lib/admin/actions.php';
128 require_once VIMEOGRAPHY_PATH . 'lib/admin/menu.php';
129 require_once VIMEOGRAPHY_PATH . 'lib/admin/plugins.php';
130 require_once VIMEOGRAPHY_PATH . 'lib/update.php';
131 }
132 }
133
134 /**
135 * Checks if the provided Vimeo URL is valid and if so, returns a
136 * string to be used as the collection endpoint.
137 *
138 * @param string $source_url Source collection of Vimeo videos.
139 * @return string Vimeo Resource
140 */
141 public static function validate_vimeo_source($source_url) {
142 // Add scheme if it wasn't provided in source url
143 $scheme = parse_url( $source_url );
144
145 if ( empty( $scheme['scheme'] ) ) {
146 $source_url = 'https://' . $source_url;
147 }
148
149 // Only continue if the parse_url function didn't fail
150 // and the host is one of vimeo.com or vimeopro.com
151 if ( ( ($url = parse_url($source_url) ) !== FALSE ) && (preg_match('~vimeo(?:pro)?\.com$~', $url['host']) > 0)) {
152 $host = $url['host'];
153
154 // Create an array with the resource parts
155 $url = array_values(array_filter(explode('/', $url['path']), 'strlen'));
156
157 // If the array doesn't contain one of the following strings, it
158 // must be either a user or a video
159 if (in_array($url[0], array('album', 'channels', 'groups', 'categories')) !== TRUE) {
160 if (is_numeric($url[0])) {
161 array_unshift($url, 'videos');
162 } else {
163 array_unshift($url, 'users');
164 if ( isset($url[2]) ) {
165 if ($host != 'vimeo.com') {
166 // Convert /users/username/portfolio_name to /users/username/portfolios/portfolio_name
167 array_splice($url, 2, 0, array('portfolios'));
168 } elseif ($url[2] === 'videos') {
169 // Remove 'videos' from '/users/username/videos'
170 unset($url[2]);
171 }
172 }
173 }
174 }
175
176 // Make sure the resource is plural
177 $url[0] = rtrim($url[0], 's') . 's';
178 $resource = '/' . implode('/', $url);
179
180 return $resource;
181 } else {
182 throw new Vimeography_Exception(
183 __('That site doesn\'t look like a valid link to a Vimeo collection.', 'vimeography')
184 );
185 }
186 }
187 }
188
189 Vimeography::get_instance();
190