Completed
Push — add/carousel-lightbox-single-i... ( 204ac6...43c884 )
by
unknown
09:26
created

VideoPress_Options::get_options()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 26
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 12
nc 3
nop 0
dl 0
loc 26
rs 8.8571
c 0
b 0
f 0
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
			'meta'           => array(
25
				'max_upload_size' => 0,
26
			),
27
		);
28
29
		self::$options = Jetpack_Options::get_option( self::$option_name, array() );
0 ignored issues
show
Documentation Bug introduced by
It seems like \Jetpack_Options::get_op...:$option_name, array()) of type * is incompatible with the declared type array of property $options.

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..

Loading history...
30
		self::$options = array_merge( $defaults, self::$options );
31
32
		// Make sure that the shadow blog id never comes from the options, but instead uses the
33
		// associated shadow blog id, if videopress is enabled.
34
		self::$options['shadow_blog_id'] = 0;
35
36
		// Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress
37
		if ( Jetpack::active_plan_supports( 'videopress' ) ) {
38
			self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' );
39
		}
40
41
		return self::$options;
42
	}
43
44
	/**
45
	 * Update VideoPress options
46
	 */
47
	public static function update_options( $options ) {
48
		Jetpack_Options::update_option( self::$option_name, $options );
49
50
		self::$options = $options;
51
	}
52
53
	/**
54
	 * Runs when the VideoPress module is deactivated.
55
	 */
56
	public static function delete_options() {
57
		Jetpack_Options::delete_option( self::$option_name );
58
59
		self::$options = array();
60
	}
61
62
}