Nenhuma Descrição

class.videopress-options.php 1.4KB

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