class.videopress-options.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <?php
  2. class VideoPress_Options {
  3. /** @var string */
  4. public static $option_name = 'videopress';
  5. /** @var array */
  6. public static $jetpack_plans_with_videopress = array( 'jetpack_premium', 'jetpack_business' );
  7. /** @var array */
  8. protected static $options = array();
  9. /**
  10. * Get VideoPress options
  11. */
  12. public static function get_options() {
  13. // Make sure we only get options from the database and services once per connection.
  14. if ( count( self::$options ) > 0 ) {
  15. return self::$options;
  16. }
  17. $defaults = array(
  18. 'meta' => array(
  19. 'max_upload_size' => 0,
  20. ),
  21. );
  22. self::$options = Jetpack_Options::get_option( self::$option_name, array() );
  23. self::$options = array_merge( $defaults, self::$options );
  24. // Make sure that the shadow blog id never comes from the options, but instead uses the
  25. // associated shadow blog id, if videopress is enabled.
  26. self::$options['shadow_blog_id'] = 0;
  27. // Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress
  28. if ( Jetpack::active_plan_supports( 'videopress' ) ) {
  29. self::$options['shadow_blog_id'] = Jetpack_Options::get_option( 'id' );
  30. }
  31. return self::$options;
  32. }
  33. /**
  34. * Update VideoPress options
  35. */
  36. public static function update_options( $options ) {
  37. Jetpack_Options::update_option( self::$option_name, $options );
  38. self::$options = $options;
  39. }
  40. /**
  41. * Runs when the VideoPress module is deactivated.
  42. */
  43. public static function delete_options() {
  44. Jetpack_Options::delete_option( self::$option_name );
  45. self::$options = array();
  46. }
  47. }