1 | <?php |
||
7 | class Jetpack_VideoPress { |
||
8 | /** @var string */ |
||
9 | public $module = 'videopress'; |
||
10 | |||
11 | /** @var int */ |
||
12 | public $version = 5; |
||
13 | |||
14 | /** |
||
15 | * Singleton |
||
16 | */ |
||
17 | public static function init() { |
||
26 | |||
27 | /** |
||
28 | * Jetpack_VideoPress constructor. |
||
29 | * |
||
30 | * Sets up the initializer and makes sure that videopress activates and deactivates properly. |
||
31 | */ |
||
32 | private function __construct() { |
||
37 | |||
38 | /** |
||
39 | * Fires on init |
||
40 | */ |
||
41 | public function on_init() { |
||
42 | add_action( 'wp_enqueue_media', array( $this, 'enqueue_admin_scripts' ) ); |
||
43 | add_filter( 'plupload_default_settings', array( $this, 'videopress_pluploder_config' ) ); |
||
44 | add_filter( 'wp_get_attachment_url', array( $this, 'update_attachment_url_for_videopress' ), 10, 2 ); |
||
45 | |||
46 | add_action( 'admin_print_footer_scripts', array( $this, 'print_in_footer_open_media_add_new' ) ); |
||
47 | add_action( 'admin_menu', array( $this,'change_add_new_menu_location' ), 999 ); |
||
48 | add_action( 'admin_head', array( $this, 'enqueue_admin_styles' ) ); |
||
49 | |||
50 | VideoPress_Scheduler::init(); |
||
51 | VideoPress_XMLRPC::init(); |
||
52 | } |
||
53 | |||
54 | /** |
||
55 | * Runs when the VideoPress module is deactivated. |
||
56 | */ |
||
57 | public function jetpack_module_deactivated() { |
||
60 | |||
61 | /** |
||
62 | * A can of coke |
||
63 | * |
||
64 | * Similar to current_user_can, but internal to VideoPress. Returns |
||
65 | * true if the given VideoPress capability is allowed by the given user. |
||
66 | */ |
||
67 | public function can( $cap, $user_id = false ) { |
||
93 | |||
94 | /** |
||
95 | * Returns true if the provided user is the Jetpack connection owner. |
||
96 | */ |
||
97 | public function is_connection_owner( $user_id = false ) { |
||
106 | |||
107 | /** |
||
108 | * Register and enqueue VideoPress admin styles. |
||
109 | */ |
||
110 | public function enqueue_admin_styles() { |
||
114 | |||
115 | /** |
||
116 | * Register VideoPress admin scripts. |
||
117 | */ |
||
118 | public function enqueue_admin_scripts() { |
||
157 | |||
158 | /** |
||
159 | * An override for the attachment url, which returns back the WPCOM videopress original url, |
||
160 | * if it is set to the the objects metadata. this allows us to show the original uploaded |
||
161 | * file on the WPCOM architecture, instead of the locally uplodaded file, |
||
162 | * which doeasn't exist. |
||
163 | * |
||
164 | * @param string $url |
||
165 | * @param int $post_id |
||
166 | * |
||
167 | * @return mixed |
||
168 | */ |
||
169 | public function update_attachment_url_for_videopress( $url, $post_id ) { |
||
181 | |||
182 | /** |
||
183 | * Modify the default plupload config to turn on videopress specific filters. |
||
184 | */ |
||
185 | public function videopress_pluploder_config( $config ) { |
||
198 | |||
199 | |||
200 | /** |
||
201 | * Helper function to determine if the media uploader should be overridden. |
||
202 | * |
||
203 | * The rules are simple, only try to load the script when on the edit post or new post pages. |
||
204 | * |
||
205 | * @return bool |
||
206 | */ |
||
207 | protected function should_override_media_uploader() { |
||
224 | |||
225 | /** |
||
226 | * A work-around / hack to make it possible to go to the media library with the add new box open. |
||
227 | * |
||
228 | * @return bool |
||
229 | */ |
||
230 | public function print_in_footer_open_media_add_new() { |
||
257 | |||
258 | /** |
||
259 | * Changes the add new menu location, so that VideoPress will be enabled |
||
260 | * when a user clicks that button. |
||
261 | */ |
||
262 | public function change_add_new_menu_location() { |
||
267 | } |
||
268 | |||
271 |