8000 Membership featured video & audio by brianhogg · Pull Request #2909 · gocodebox/lifterlms · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Membership featured video & audio #2909

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions .changelogs/membership-featured-video-audio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: minor
type: added
entry: Featured video and audio options for Memberships.
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,28 @@ public function get_fields() {
array(
'title' => __( 'General', 'lifterlms' ),
'fields' => array(
array(
'type' => 'text',
'label' => __( 'Featured Video', 'lifterlms' ),
'desc' => sprintf( __( 'Paste the url for a Wistia, Vimeo or Youtube video or a hosted video file. For a full list of supported providers see %s.', 'lifterlms' ), '<a href="https://wordpress.org/documentation/article/embeds/#list-of-sites-you-can-embed-from" target="_blank">WordPress oEmbeds</a>' ),
'id' => $this->prefix . 'video_embed',
'class' => 'code input-full',
),
array(
'desc' => __( 'When enabled, the featured video will be displayed on the course tile in addition to the course page.', 'lifterlms' ),
'desc_class' => 'd-3of4 t-3of4 m-1of2',
'id' => $this->prefix . 'tile_featured_video',
'label' => __( 'Display Featured Video on Course Tile', 'lifterlms' ),
'type' => 'checkbox',
'value' => 'yes',
),
array(
'type' => 'text',
'label' => __( 'Featured Audio', 'lifterlms' ),
'desc' => sprintf( __( 'Paste the url for a SoundCloud or Spotify song or a hosted audio file. For a full list of supported providers see %s.', 'lifterlms' ), '<a href="https://wordpress.org/documentation/article/embeds/#list-of-sites-you-can-embed-from" target="_blank">WordPress oEmbeds</a>' ),
'id' => $this->prefix . 'audio_embed',
'class' => 'code input-full',
),
array(
'type' => 'basic-editor',
'label' => __( 'Featured Pricing Information', 'lifterlms' ),
Expand Down Expand Up @@ -329,6 +351,9 @@ public function save( $post_id ) {
$this->prefix . 'sales_page_content_type',
$this->prefix . 'sales_page_content_url',
$this->prefix . 'featured_pricing',
$this->prefix . 'video_embed',
$this->prefix . 'audio_embed',
$this->prefix . 'tile_featured_video',
);

if ( ! is_array( $fields ) ) {
Expand Down
8 changes: 4 additions & 4 deletions includes/functions/llms.functions.templates.loop.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ function lifterlms_loop_end() {
*/
function lifterlms_loop_featured_video() {
global $post;
if ( 'course' === $post->post_type ) {
$course = llms_get_post( $post );
if ( 'yes' === $course->get( 'tile_featured_video' ) ) {
$video = $course->get_video();
if ( 'course' === $post->post_type || 'llms_membership' === $post->post_type ) {
$product = llms_get_post( $post );
if ( 'yes' === $product->get( 'tile_featured_video' ) ) {
$video = $product->get_video();
if ( $video ) {
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo '<div class="llms-video-wrapper">' . $video . '</div>';
Expand Down
27 changes: 27 additions & 0 deletions includes/llms.template.functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,20 @@ function lifterlms_template_single_video() {
}
}

/**
* Membership Video Embed Template Include
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_membership_video' ) ) {

function lifterlms_template_single_membership_video() {

llms_get_template( 'membership/video.php' );
}
}


/**
* Lesson Video Embed Template Include
*
Expand All @@ -300,6 +314,19 @@ function lifterlms_template_single_audio() {
}
}

/**
* Membership Audio Embed Template Include.
*
* @return void
*/
if ( ! function_exists( 'lifterlms_template_single_membership_audio' ) ) {

function lifterlms_template_single_membership_audio() {

llms_get_template( 'membership/audio.php' );
}
}

/**
* Lesson Audio Template Include
*
Expand Down
3 changes: 3 additions & 0 deletions includes/llms.template.hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@
*
* @since Unknown
*/
add_action( 'lifterlms_single_membership_before_summary', 'lifterlms_template_single_membership_video', 20 );
add_action( 'lifterlms_single_membership_before_summary', 'lifterlms_template_single_membership_audio', 30 );

add_action( 'lifterlms_single_membership_after_summary', 'lifterlms_template_pricing_table', 10 );

/**
Expand Down
5 changes: 5 additions & 0 deletions includes/models/model.llms.membership.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @since 5.2.1 Check for an empty sales page URL or ID.
* @since 5.3.0 Move sales page methods to `LLMS_Trait_Sales_Page`.
*
* @property string $audio_embed URL to an oEmbed enable audio URL.
* @property int[] $auto_enroll Array of course IDs that users will be autoenrolled in upon successful enrollment in this membership.
* @property array $instructors Course instructor user information.
* @property string $restriction_redirect_type What type of redirect action to take when content is restricted by this membership [none|membership|page|custom].
Expand All @@ -33,9 +34,11 @@
* @property int $sales_page_content_page_id WP Post ID of the WP page to redirect to when $sales_page_content_type is 'page'.
* @property string $sales_page_content_type Sales page behavior [none,content,page,url].
* @property string $sales_page_content_url Redirect URL for a sales page, when $sales_page_content_type is 'url'.
* @property string $video_embed URL to an oEmbed enable video URL.
*/
class LLMS_Membership extends LLMS_Post_Model implements LLMS_Interface_Post_Instructors {

use LLMS_Trait_Audio_Video_Embed;
use LLMS_Trait_Sales_Page;

/**
Expand All @@ -52,6 +55,7 @@ class LLMS_Membership extends LLMS_Post_Model implements LLMS_Interface_Post_Ins
'restriction_redirect_type' => 'text',
'redirect_custom_url' => 'text',
'featured_pricing' => 'html',
'tile_featured_video' => 'yesno',
);

/**
Expand All @@ -78,6 +82,7 @@ class LLMS_Membership extends LLMS_Post_Model implements LLMS_In 9E88 terface_Post_Ins
*/
public function __construct( $model, $args = array() ) {

$this->construct_audio_video_embed();
$this->construct_sales_page();
parent::__construct( $model, $args );
}
Expand Down
8 changes: 4 additions & 4 deletions templates/loop/featured-image.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@

global $post;

// Short circuit if the featured video tile option is enabled for a course.
if ( 'course' === $post->post_type ) {
$course = llms_get_post( $post );
if ( 'yes' === $course->get( 'tile_featured_video' ) && $course->get( 'video_embed' ) ) {
// Short circuit if the featured video tile option is enabled for a course or membership.
if ( 'course' === $post->post_type || 'llms_membership' === $post->post_type ) {
$product = llms_get_post( $post );
if ( 'yes' === $product->get( 'tile_featured_video' ) && $product->get( 'video_embed' ) ) {
return;
}
}
Expand Down
24 changes: 24 additions & 0 deletions templates/membership/audio.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
/**
* @author codeBOX
* @package lifterLMS/Templates
*/

defined( 'ABSPATH' ) || exit;

global $post;

$membership = new LLMS_Membership( $post );

if ( ! $membership->get_audio() ) {
return; }
?>

<div class="llms-audio-wrapper">
<div class="center-audio">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $membership->get_audio();
?>
</div>
</div>
25 changes: 25 additions & 0 deletions templates/membership/video.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/**
* @author LifterLMS
* @package LifterLMS/Templates
*/

defined( 'ABSPATH' ) || exit;

global $post;

$membership = new LLMS_Membership( $post );

if ( ! $membership->get_video() ) {
return; }

?>

<div class="llms-video-wrapper">
<div class="center-video">
<?php
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
echo $membership->get_video();
?>
</div>
</div>
Loading
0