js
2 months ago
tus
1 month ago
videopress-divi
2 months ago
videopress-divi-5
2 months ago
class-access-control.php
5 days ago
class-admin-ui.php
2 weeks ago
class-ajax.php
1 month ago
class-attachment-handler.php
1 month ago
class-block-editor-content.php
1 month ago
class-block-editor-extensions.php
2 weeks ago
class-block-replacement.php
9 months ago
class-caption-tracks.php
1 month ago
class-data.php
1 month ago
class-divi.php
2 months ago
class-initial-state.php
2 weeks ago
class-initializer.php
5 days ago
class-jwt-token-bridge.php
2 years ago
class-module-control.php
3 years ago
class-options.php
2 years ago
class-package-version.php
5 days ago
class-plan.php
2 years ago
class-rest-controller.php
1 month ago
class-site.php
3 years ago
class-stats.php
1 year ago
class-status.php
9 months ago
class-upload-exception.php
3 years ago
class-uploader-rest-endpoints.php
2 weeks ago
class-uploader.php
1 month ago
class-utils.php
3 months ago
class-video-block-email-renderer.php
2 months ago
class-videopress-rest-api-v1-features.php
6 months ago
class-videopress-rest-api-v1-settings.php
1 month ago
class-videopress-rest-api-v1-site.php
2 weeks ago
class-videopress-rest-api-v1-stats.php
3 years ago
class-videopresstoken.php
1 month ago
class-wpcom-rest-api-v2-attachment-field-videopress.php
9 months ago
class-wpcom-rest-api-v2-attachment-videopress-data.php
1 month ago
class-wpcom-rest-api-v2-endpoint-videopress-caption-tracks.php
1 month ago
class-wpcom-rest-api-v2-endpoint-videopress.php
2 weeks ago
class-xmlrpc.php
1 month ago
utility-functions.php
4 weeks ago
class-options.php
84 lines
| 1 | <?php |
| 2 | /** |
| 3 | * VideoPress Options |
| 4 | * |
| 5 | * @package automattic/jetpack-videopress |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\VideoPress; |
| 9 | |
| 10 | use Automattic\Jetpack\Current_Plan; |
| 11 | use Jetpack_Options; |
| 12 | |
| 13 | /** |
| 14 | * VideoPress Options class. |
| 15 | */ |
| 16 | class Options { |
| 17 | |
| 18 | /** |
| 19 | * Option name. |
| 20 | * |
| 21 | * @var string $option_name The 'videopress' option name |
| 22 | */ |
| 23 | public static $option_name = 'videopress'; |
| 24 | |
| 25 | /** |
| 26 | * VideoPress Options. |
| 27 | * |
| 28 | * @var array $options An array of associated VideoPress options (default empty) |
| 29 | */ |
| 30 | protected static $options = array(); |
| 31 | |
| 32 | /** |
| 33 | * Get VideoPress options |
| 34 | * |
| 35 | * @return array An array of VideoPress options. |
| 36 | */ |
| 37 | public static function get_options() { |
| 38 | // Make sure we only get options from the database and services once per connection. |
| 39 | if ( array() !== self::$options ) { |
| 40 | return self::$options; |
| 41 | } |
| 42 | |
| 43 | $defaults = array( |
| 44 | 'meta' => array( |
| 45 | 'max_upload_size' => 0, |
| 46 | ), |
| 47 | ); |
| 48 | |
| 49 | self::$options = Jetpack_Options::get_option( self::$option_name, array() ); |
| 50 | self::$options = array_merge( $defaults, self::$options ); |
| 51 | |
| 52 | // Make sure that the shadow blog id never comes from the options, but instead uses the |
| 53 | // associated shadow blog id, if videopress is enabled. |
| 54 | self::$options['shadow_blog_id'] = 0; |
| 55 | |
| 56 | // Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress. |
| 57 | if ( Current_Plan::supports( 'videopress' ) ) { |
| 58 | self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' ); |
| 59 | } |
| 60 | |
| 61 | return self::$options; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Update VideoPress options |
| 66 | * |
| 67 | * @param mixed $options VideoPress options. |
| 68 | */ |
| 69 | public static function update_options( $options ) { |
| 70 | Jetpack_Options::update_option( self::$option_name, $options ); |
| 71 | |
| 72 | self::$options = $options; |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Runs when the VideoPress module is deactivated. |
| 77 | */ |
| 78 | public static function delete_options() { |
| 79 | Jetpack_Options::delete_option( self::$option_name ); |
| 80 | |
| 81 | self::$options = array(); |
| 82 | } |
| 83 | } |
| 84 |