ith( $attachment->post_mime_type, 'video/' ); } /** * Removes the jetpack_videopress field from the response if the * given attachment is not a video. * * @param WP_REST_Response $response Response from the attachment endpoint. * @param WP_Post $attachment The original attachment object. * * @return mixed */ public function remove_field_for_non_videos( $response, $attachment ) { if ( ! $this->is_video( $attachment ) ) { unset( $response->data[ $this->field_name ] ); } return $response; } /** * Determines if a video is private based on the video privacy * setting and the site default privacy setting. * * @param int $video_privacy_setting The privacy setting for the video. * @param bool $private_enabled_for_site Flag stating if the default video privacy is private. * * @return bool */ private function video_is_private( $video_privacy_setting, $private_enabled_for_site ) { if ( $video_privacy_setting === \VIDEOPRESS_PRIVACY::IS_PUBLIC ) { return false; } if ( $video_privacy_setting === \VIDEOPRESS_PRIVACY::IS_PRIVATE ) { return true; } return $private_enabled_for_site; } } if ( defined( 'IS_WPCOM' ) && IS_WPCOM ) { wpcom_rest_api_v2_load_plugin( 'Automattic\Jetpack\VideoPress\WPCOM_REST_API_V2_Attachment_VideoPress_Data' ); }