|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
class VideoPress_Options { |
|
4
|
|
|
|
|
5
|
|
|
/** @var string */ |
|
6
|
|
|
public static $option_name = 'videopress'; |
|
7
|
|
|
|
|
8
|
|
|
/** @var array */ |
|
9
|
|
|
public static $jetpack_plans_with_videopress = array( 'jetpack_premium', 'jetpack_business' ); |
|
10
|
|
|
|
|
11
|
|
|
/** @var array */ |
|
12
|
|
|
protected static $options = array(); |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Get VideoPress options |
|
16
|
|
|
*/ |
|
17
|
|
|
public static function get_options() { |
|
18
|
|
|
// Make sure we only get options from the database and services once per connection. |
|
19
|
|
|
if ( count( self::$options ) > 0 ) { |
|
20
|
|
|
return self::$options; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
$defaults = array( |
|
24
|
|
|
'freedom' => false, |
|
25
|
|
|
'hd' => true, |
|
26
|
|
|
'meta' => array( |
|
27
|
|
|
'max_upload_size' => 0, |
|
28
|
|
|
), |
|
29
|
|
|
); |
|
30
|
|
|
|
|
31
|
|
|
self::$options = Jetpack_Options::get_option( self::$option_name, array() ); |
|
|
|
|
|
|
32
|
|
|
|
|
33
|
|
|
// If options have not been saved yet, check for older VideoPress plugin options. |
|
34
|
|
|
if ( empty( self::$options ) ) { |
|
35
|
|
|
self::$options['freedom'] = (bool) get_option( 'video_player_freedom', false ); |
|
36
|
|
|
self::$options['hd'] = (bool) get_option( 'video_player_high_quality', false ); |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
self::$options = array_merge( $defaults, self::$options ); |
|
40
|
|
|
|
|
41
|
|
|
// Make sure that the shadow blog id never comes from the options, but instead uses the |
|
42
|
|
|
// associated shadow blog id, if videopress is enabled. |
|
43
|
|
|
self::$options['shadow_blog_id'] = 0; |
|
44
|
|
|
|
|
45
|
|
|
// Get the active Jetpack plan |
|
46
|
|
|
$plan = Jetpack::get_active_plan(); |
|
47
|
|
|
|
|
48
|
|
|
// Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress |
|
49
|
|
|
if ( in_array( 'videopress', $plan['supports'] ) ) { |
|
50
|
|
|
self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' ); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
return self::$options; |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Update VideoPress options |
|
58
|
|
|
*/ |
|
59
|
|
|
public static function update_options( $options ) { |
|
60
|
|
|
Jetpack_Options::update_option( self::$option_name, $options ); |
|
61
|
|
|
|
|
62
|
|
|
self::$options = $options; |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* Runs when the VideoPress module is deactivated. |
|
67
|
|
|
*/ |
|
68
|
|
|
public static function delete_options() { |
|
69
|
|
|
Jetpack_Options::delete_option( self::$option_name ); |
|
70
|
|
|
|
|
71
|
|
|
self::$options = array(); |
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
} |
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..