Skip to content

Commit e63cc58

Browse files
authored
Adding events promo (#3098)
* Add promo for events in the course builder. * Adding event promo when editing a lesson. * Formatting of promo. Have the llms-button-primary styling apply to links as well as buttons.
1 parent 8b77341 commit e63cc58

File tree

5 files changed

+150
-6
lines changed

5 files changed

+150
-6
lines changed

.changelogs/event-promo.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
significance: patch
2+
type: added
3+
entry: Adding tab for Events.

assets/js/builder/Schemas/Lesson.js

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,22 @@ define( [], function() {
194194
date_format: 'h:i A',
195195
id: 'time-available',
196196
label: LLMS.l10n.translate( 'Time' ),
197-
type: 'datepicker',
198-
},
199-
],
200-
],
197+
type: 'datepicker',
201198
},
199+
], [
200+
{
201+
label: LLMS.l10n.translate( 'Associated Event(s)' ),
202+
id: 'llms-events-promo',
203+
type: 'heading',
204+
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>',
205+
condition: function() {
206+
return ! window.llms_builder.events;
207+
},
208+
},
209+
],
210+
],
211+
},
202212

203-
} );
213+
} );
204214

205215
} );

assets/scss/admin/metaboxes/_llms-metabox.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989

9090
}
9191

92-
button.llms-button-primary {
92+
.llms-button-primary {
9393
border-radius: 8px;
9494
font-size: 16px;
9595
font-weight: 700;
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
/**
3+
* Lightweight Events add-on promotion in the LifterLMS core admin.
4+
*
5+
* Shows an "Events" tab in Course Options and Membership meta boxes
6+
* with a CTA to install the Events add-on when it is not active.
7+
*
8+
* Also adds an "Events" link in Course Builder lesson settings.
9+
*
10+
* @package LifterLMS/Admin/Classes
11+
*
12+
* @since 7.8.0
13+
*/
14+
15+
defined( 'ABSPATH' ) || exit;
16+
17+
/**
18+
* LLMS_Admin_Events_Promo class.
19+
*
20+
* @since 7.8.0
21+
*/
22+
class LLMS_Admin_Events_Promo {
23+
24+
/**
25+
* Constructor.
26+
*
27+
* @since 7.8.0
28+
*/
29+
public function __construct() {
30+
// Only show promo if the events plugin is not active.
31+
if ( class_exists( 'LLMS_Events_Plugin' ) ) {
32+
return;
33+
}
34+
35+
add_filter( 'llms_metabox_fields_lifterlms_course_options', array( $this, 'add_course_promo_tab' ) );
36+
add_filter( 'llms_metabox_fields_lifterlms_membership', array( $this, 'add_membership_promo_tab' ) );
37+
add_filter( 'llms_metabox_fields_lifterlms_lesson', array( $this, 'add_lesson_promo_tab' ) );
38+
}
39+
40+
/**
41+
* Add an Events promo tab to Course Options.
42+
*
43+
* @since 7.8.0
44+
*
45+
* @param array $tabs Existing tabs.
46+
* @return array
47+
*/
48+
public function add_course_promo_tab( $tabs ) {
49+
$tabs[] = array(
50+
'title' => __( 'Events', 'lifterlms' ),
51+
'fields' => array(
52+
array(
53+
'id' => '_llms_events_promo',
54+
'type' => 'custom-html',
55+
'label' => '',
56+
'value' => $this->get_promo_html(),
57+
),
58+
),
59+
);
60+
return $tabs;
61+
}
62+
63+
/**
64+
* Add an Events promo tab to Membership.
65+
*
66+
* @since 7.8.0
67+
*
68+
* @param array $tabs Existing tabs.
69+
* @return array
70+
*/
71+
public function add_membership_promo_tab( $tabs ) {
72+
$tabs[] = array(
73+
'title' => __( 'Events', 'lifterlms' ),
74+
'fields' => array(
75+
array(
76+
'id' => '_llms_events_promo',
77+
'type' => 'custom-html',
78+
'label' => '',
79+
'value' => $this->get_promo_html(),
80+
),
81+
),
82+
);
83+
return $tabs;
84+
}
85+
86+
/**
87+
* Add an Events promo tab to Lesson Settings.
88+
*
89+
* @since 7.8.0
90+
*
91+
* @param array $tabs Existing tabs.
92+
* @return array
93+
*/
94+
public function add_lesson_promo_tab( $tabs ) {
95+
$tabs[] = array(
96+
'title' => __( 'Events', 'lifterlms' ),
97+
'fields' => array(
98+
array(
99+
'id' => '_llms_events_promo',
100+
'type' => 'custom-html',
101+
'label' => '',
102+
'value' => $this->get_promo_html(),
103+
),
104+
),
105+
);
106+
return $tabs;
107+
}
108+
109+
/**
110+
* Get the promo HTML.
111+
*
112+
* @since 7.8.0
113+
*
114+
* @return string
115+
*/
116+
private function get_promo_html() {
117+
$html = '<div class="llms-metabox" style="padding:20px;text-align:center;">';
118+
$html .= '<div class="dashicons dashicons-calendar-alt" style="color:#2271b1;margin-bottom:12px;"></div>';
119+
$html .= '<h3>' . esc_html__( 'Schedule Events for Your Students', 'lifterlms' ) . '</h3>';
120+
$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>';
121+
$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">';
122+
$html .= esc_html__( 'Get LifterLMS Events', 'lifterlms' );
123+
$html .= '</a>';
124+
$html .= '</div>';
125+
126+
return $html;
127+
}
128+
}
129+
130+
new LLMS_Admin_Events_Promo();

includes/class-llms-loader.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ public function includes_admin() {
362362
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.notices.core.php';
363363
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.post-types.php';
364364
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.reviews.php';
365+
require_once LLMS_PLUGIN_DIR . 'includes/admin/class-llms-admin-events-promo.php';
365366
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.admin.user.custom.fields.php';
366367
require_once LLMS_PLUGIN_DIR . 'includes/admin/class-llms-admin-profile.php';
367368
require_once LLMS_PLUGIN_DIR . 'includes/admin/class.llms.student.bulk.enroll.php';

0 commit comments

Comments
 (0)