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
3 changes: 3 additions & 0 deletions .changelogs/event-promo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
significance: patch
type: added
entry: Adding tab for Events.
20 changes: 15 additions & 5 deletions assets/js/builder/Schemas/Lesson.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,22 @@ define( [], function() {
date_format: 'h:i A',
id: 'time-available',
label: LLMS.l10n.translate( 'Time' ),
type: 'datepicker',
},
],
],
type: 'datepicker',
},
], [
{
label: LLMS.l10n.translate( 'Associated Event(s)' ),
id: 'llms-events-promo',
type: 'heading',
detail: LLMS.l10n.translate( 'Schedule events for your lessons with the LifterLMS Events add-on.' ) + ' <a href="https://lifterlms.com/product/lifterlms-events/?utm_source=LifterLMS%20Plugin&utm_medium=Lesson%20Builder&utm_campaign=Events%20Addon%20Upsell" target="_blank">' + LLMS.l10n.translate( 'Learn More' ) + '</a>',
condition: function() {
return ! window.llms_builder.events;
},
},
],
],
},

} );
} );

} );
2 changes: 1 addition & 1 deletion assets/scss/admin/metaboxes/_llms-metabox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

}

button.llms-button-primary {
.llms-button-primary {
border-radius: 8px;
font-size: 16px;
font-weight: 700;
Expand Down
130 changes: 130 additions & 0 deletions includes/admin/class-llms-admin-events-promo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
<?php
/**
* Lightweight Events add-on promotion in the LifterLMS core admin.
*
* Shows an "Events" tab in Course Options and Membership meta boxes
* with a CTA to install the Events add-on when it is not active.
*
* Also adds an "Events" link in Course Builder lesson settings.
*
* @package LifterLMS/Admin/Classes
*
* @since 7.8.0
*/

defined( 'ABSPATH' ) || exit;

/**
* LLMS_Admin_Events_Promo class.
*
* @since 7.8.0
*/
class LLMS_Admin_Events_Promo {

/**
* Constructor.
*
* @since 7.8.0
*/
public function __construct() {
// Only show promo if the events plugin is not active.
if ( class_exists( 'LLMS_Events_Plugin' ) ) {
return;
}

add_filter( 'llms_metabox_fields_lifterlms_course_options', array( $this, 'add_course_promo_tab' ) );
add_filter( 'llms_metabox_fields_lifterlms_membership', array( $this, 'add_membership_promo_tab' ) );
add_filter( 'llms_metabox_fields_lifterlms_lesson', array( $this, 'add_lesson_promo_tab' ) );
}

/**
* Add an Events promo tab to Course Options.
*
* @since 7.8.0
*
* @param array $tabs Existing tabs.
* @return array
*/
public function add_course_promo_tab( $tabs ) {
$tabs[] = array(
'title' => __( 'Events', 'lifterlms' ),
'fields' => array(
array(
'id' => '_llms_events_promo',
'type' => 'custom-html',
'label' => '',
'value' => $this->get_promo_html(),
),
),
);
return $tabs;
}

/**
* Add an Events promo tab to Membership.
*
* @since 7.8.0
*
* @param array $tabs Existing tabs.
* @return array
*/
public function add_membership_promo_tab( $tabs ) {
$tabs[] = array(
'title' => __( 'Events', 'lifterlms' ),
'fields' => array(
array(
'id' => '_llms_events_promo',
'type' => 'custom-html',
'label' => '',
'value' => $this->get_promo_html(),
),
),
);
return $tabs;
}

/**
* Add an Events promo tab to Lesson Settings.
*
* @since 7.8.0
*
* @param array $tabs Existing tabs.
* @return array
*/
public function add_lesson_promo_tab( $tabs ) {
$tabs[] = array(
'title' => __( 'Events', 'lifterlms' ),
'fields' => array(
array(
'id' => '_llms_events_promo',
'type' => 'custom-html',
'label' => '',
'value' => $this->get_promo_html(),
),
),
);
return $tabs;
}

/**
* Get the promo HTML.
*
* @since 7.8.0
*
* @return string
*/
private function get_promo_html() {
$html = '<div class="llms-metabox" style="padding:20px;text-align:center;">';
$html .= '<div class="dashicons dashicons-calendar-alt" style="color:#2271b1;margin-bottom:12px;"></div>';
$html .= '<h3>' . esc_html__( 'Schedule Events for Your Students', 'lifterlms' ) . '</h3>';
$html .= '<p>' . esc_html__( 'Add live events, webinars, and in-person sessions to your courses and memberships. Students can subscribe to calendar feeds and never miss an event.', 'lifterlms' ) . '</p>';
$html .= '<a href="https://lifterlms.com/product/lifterlms-events/?utm_source=LifterLMS%20Plugin&utm_medium=Course%20Editor&utm_campaign=Events%20Promo" target="_blank" class="llms-button-primary">';
$html .= esc_html__( 'Get LifterLMS Events', 'lifterlms' );
$html .= '</a>';
$html .= '</div>';

return $html;
}
}

new LLMS_Admin_Events_Promo();
1 change: 1 addition & 0 deletions includes/class-llms-loader.php
Original file line number Diff line number Diff line change
Expand Up @@ -363,6 +363,7 @@ public function includes_admin() {
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.notices.core.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.post-types.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.reviews.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class-llms-admin-events-promo.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.user.custom.fields.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class-llms-admin-profile.php';
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.student.bulk.enroll.php';
Expand Down
Loading