kollapsminoriteten/wp-content/plugins/jetpack/modules/videopress/class.videopress-options.php

80 lines
1.8 KiB
PHP
Raw Normal View History

2022-06-16 14:01:47 +02:00
<?php // phpcs:ignore WordPress.Files.FileName
/**
* VideoPress Options
*
* @package automattic/jetpack
*/
2019-11-15 23:26:29 +01:00
2022-06-16 14:01:47 +02:00
/**
* VideoPress Options class.
*/
2019-11-15 23:26:29 +01:00
class VideoPress_Options {
2022-06-16 14:01:47 +02:00
/**
* Option name.
*
* @var string $option_name The 'videopress' option name
*/
2019-11-15 23:26:29 +01:00
public static $option_name = 'videopress';
2022-06-16 14:01:47 +02:00
/**
* VideoPress Options.
*
* @var array $options An array of associated VideoPress options (default empty)
*/
2019-11-15 23:26:29 +01:00
protected static $options = array();
/**
* Get VideoPress options
2022-06-16 14:01:47 +02:00
*
* @return array An array of VideoPress options.
2019-11-15 23:26:29 +01:00
*/
public static function get_options() {
// Make sure we only get options from the database and services once per connection.
if ( count( self::$options ) > 0 ) {
return self::$options;
}
$defaults = array(
'meta' => array(
'max_upload_size' => 0,
),
);
self::$options = Jetpack_Options::get_option( self::$option_name, array() );
self::$options = array_merge( $defaults, self::$options );
// Make sure that the shadow blog id never comes from the options, but instead uses the
// associated shadow blog id, if videopress is enabled.
self::$options['shadow_blog_id'] = 0;
2022-06-16 14:01:47 +02:00
// Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress.
2019-11-15 23:26:29 +01:00
if ( Jetpack_Plan::supports( 'videopress' ) ) {
self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' );
}
return self::$options;
}
/**
* Update VideoPress options
2022-06-16 14:01:47 +02:00
*
* @param mixed $options VideoPress options.
2019-11-15 23:26:29 +01:00
*/
public static function update_options( $options ) {
Jetpack_Options::update_option( self::$option_name, $options );
self::$options = $options;
}
/**
* Runs when the VideoPress module is deactivated.
*/
public static function delete_options() {
Jetpack_Options::delete_option( self::$option_name );
self::$options = array();
}
}