Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changelogs/videopress-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
significance: patch
type: fixed
links:
- "#2533"
entry: Allow private VideoPress videos to play when the URL is pasted on Video
Embed URL.
33 changes: 31 additions & 2 deletions includes/abstracts/abstract.llms.post.model.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @package LifterLMS/Abstracts/Classes
*
* @since 3.0.0
* @version 6.5.0
* @version [version]
*/

defined( 'ABSPATH' ) || exit;
Expand Down Expand Up @@ -831,10 +831,11 @@ protected function get_creation_args( $args = null ) {
}

/**
* Get media embeds
* Get media embeds.
*
* @since 3.17.0
* @since 3.17.5 Unknown.
* @since [version] Added function to get provider support.
*
* @param string $type Optional. Embed type [video|audio]. Default is 'video'.
* @param string $prop Optional. Postmeta property name. Default is empty string.
Expand All @@ -849,6 +850,8 @@ protected function get_embed( $type = 'video', $prop = '' ) {
$url = $this->get( $prop );
if ( $url ) {

$this->get_provider_support( $url );

$ret = wp_oembed_get( $url );

if ( ! $ret ) {
Expand Down Expand Up @@ -1678,6 +1681,32 @@ public function toArray() {
return apply_filters( "llms_{$this->model_post_type}_to_array", $arr, $this );
}

/**
* Enqueues provider scripts for the URL.
*
* @since [version]
*
* @param string $url URL to check.
* @return null If no provider is found.
*/
public function get_provider_support( $url ) {

$host = wp_parse_url( $url, PHP_URL_HOST );

// VideoPress Provider.
if ( is_plugin_active( 'jetpack-videopress/jetpack-videopress.php' ) ) {
if ( strpos( $host, 'videopress.com' ) !== false || strpos( $host, 'video.wordpress.com' ) !== false ) {
wp_enqueue_script( 'videopress-token-bridge', plugins_url() . '/jetpack-videopress/jetpack_vendor/automattic/jetpack-videopress/src/../build/lib/token-bridge.js', array(), llms()->version, true );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not exactly sure why we need to specify the complete URL here, but it works!


wp_localize_script( 'videopress-token-bridge', 'videopressAjax', array() );
}
}

return null;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't need to return null here, could just return nothing.

}



/**
* Called before data is sorted and returned by $this->toArray()
*
Expand Down