VideoPress_Options::get_options PHP Method

get_options() public static method

Get VideoPress options
public static get_options ( )
    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;
        // Use the Jetpack ID for the shadow blog ID if we have a plan that supports VideoPress
        if (Jetpack::active_plan_supports('videopress')) {
            self::$options['shadow_blog_id'] = Jetpack_Options::get_option('id');
        }
        return self::$options;
    }

Usage Example

コード例 #1
0
 /**
  * Ajax method that is used by the VideoPress uploader to get a token to upload a file to the wpcom api.
  *
  * @return void
  */
 public function wp_ajax_videopress_get_upload_token()
 {
     $options = VideoPress_Options::get_options();
     $args = array('method' => 'POST');
     $endpoint = "sites/{$options['shadow_blog_id']}/media/token";
     $result = Jetpack_Client::wpcom_json_api_request_as_blog($endpoint, Jetpack_Client::WPCOM_JSON_API_VERSION, $args);
     if (is_wp_error($result)) {
         wp_send_json_error(array('message' => __('Could not obtain a VideoPress upload token. Please try again later.', 'jetpack')));
         return;
     }
     $response = json_decode($result['body'], true);
     if (empty($response['upload_token'])) {
         wp_send_json_error(array('message' => __('Could not obtain a VideoPress upload token. Please try again later.', 'jetpack')));
         return;
     }
     $title = sanitize_title(basename($_POST['filename']));
     $response['upload_action_url'] = videopress_make_media_upload_path($options['shadow_blog_id']);
     $response['upload_media_id'] = videopress_create_new_media_item($title);
     wp_send_json_success($response);
 }
All Usage Examples Of VideoPress_Options::get_options