/
class-llms-theme-support.php
247 lines (201 loc) · 5.77 KB
/
class-llms-theme-support.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
<?php
/**
* Manage Theme Support classes
*
* @package LifterLMS/ThemeSupport/Classes
*
* @since 3.37.0
* @version 5.8.0
*/
defined( 'ABSPATH' ) || exit;
/**
* LLMS_Twenty_Twenty class.
*
* @since 3.37.0
*/
class LLMS_Theme_Support {
/**
* Constructor
*
* @since 3.37.0
* @since 4.3.0 Load includes during `after_setup_theme` instead of `plugins_loaded`.
*
* @return void
*/
public function __construct() {
add_action( 'after_setup_theme', array( $this, 'includes' ) );
}
/**
* Retrieve formatted inline CSS for a given list of selectors and rules
*
* @since 4.10.0
*
* @param string[] $selectors Array of CSS selectors.
* @param string[] $rules Associative array of CSS rules and properties. For example: `array( 'color' => '#fff' )`.
* @param string $selector_prefix A CSS selector to prefix each item in $selectors with.
* @return string
*/
public static function get_css( $selectors, $rules, $selector_prefix = '' ) {
// Convert the $rules array to a list of CSS strings.
$rules_list = array();
foreach ( $rules as $prop => $val ) {
$val = is_array( $val ) ? $val : array( $val );
foreach ( $val as $value ) {
$rules_list[] = sprintf( '%1$s: %2$s;', $prop, $value );
}
}
// When supplied, prefix each selector.
if ( $selector_prefix ) {
foreach ( $selectors as &$selector ) {
$selector = $selector_prefix . ' ' . $selector;
}
}
// Return the formatted CSS.
return implode( ', ', $selectors ) . ' { ' . implode( ' ', $rules_list ) . ' }';
}
/**
* Retrieve a list of CSS selectors for elements where the primary color is used as the background
*
* The primary color is a bright blue (#2295ff).
*
* @since 4.10.0
*
* @return string[] A list of CSS selectors.
*/
public static function get_selectors_primary_color_background() {
/**
* Filter the list of CSS selectors for elements where the primary color is used as the background
*
* @since 4.10.0
*
* @param string[] $selectors A list of CSS selectors.
*/
return apply_filters(
'llms_theme_support_get_selectors_primary_color_background',
array(
// Buttons.
'.llms-button-primary',
'.llms-button-primary:hover',
'.llms-button-primary.clicked',
'.llms-button-primary:focus',
'.llms-button-primary:active',
'.llms-button-action',
'.llms-button-action:hover',
'.llms-button-action.clicked',
'.llms-button-action:focus',
'.llms-button-action:active',
// Pricing Tables.
'.llms-access-plan-title',
'.llms-access-plan .stamp',
'.llms-access-plan.featured .llms-access-plan-featured',
// Checkout.
'.llms-checkout-wrapper .llms-form-heading',
// Notices.
'.llms-notice:not(.llms-debug)',
// Progress Bar.
'.llms-progress .progress-bar-complete',
// My Grades.
'.llms-sd-widgets .llms-sd-widget .llms-sd-widget-title',
// Instructor.
'.llms-instructor-info .llms-instructors .llms-author .avatar',
// Quizzes.
'.llms-question-wrapper ol.llms-question-choices li.llms-choice input:checked + .llms-marker',
)
);
}
/**
* Retrieve a list of CSS selectors for elements where the primary color is used as the border color
*
* The primary color is a bright blue (#2295ff).
*
* @since 4.10.0
*
* @return string[] A list of CSS selectors.
*/
public static function get_selectors_primary_color_border() {
/**
* Filter the list of CSS selectors for elements where the primary color is used as the border
*
* @since 4.10.0
*
* @param string[] $selectors A list of CSS selectors.
*/
return apply_filters(
'llms_theme_support_get_selectors_primary_color_background',
array(
// Notifications.
'.llms-notification',
// Featured access plan.
'.llms-access-plan.featured .llms-access-plan-content',
'.llms-access-plan.featured .llms-access-plan-footer',
// Checkout.
'.llms-checkout-section',
'.llms-checkout-wrapper form.llms-login',
// Notices.
'.llms-notice:not(.llms-debug)',
// Instructor.
'.llms-instructor-info .llms-instructors .llms-author',
'.llms-instructor-info .llms-instructors .llms-author .avatar',
)
);
}
/**
* Retrieve a list of CSS selectors for elements where the primary color is used as the text color
*
* The primary color is a bright blue (#2295ff).
*
* @since 4.10.0
*
* @return string[] A list of CSS selectors.
*/
public static function get_selectors_primary_color_text() {
/**
* Filter the list of CSS selectors for elements where the primary color is used as the text color
*
* @since 4.10.0
*
* @param string[] $selectors A list of CSS selectors.
*/
return apply_filters(
'llms_theme_support_get_selectors_primary_color_background',
array(
// Pricing Tables.
'.llms-access-plan-restrictions a',
'.llms-access-plan-restrictions a:hover',
// Loop.
'.llms-loop-item-content .llms-loop-title:hover',
// Donuts.
'.llms-donut',
// Checks on Syllabus.
'.llms-lesson-preview.is-free .llms-lesson-complete',
'.llms-lesson-preview.is-complete .llms-lesson-complete',
)
);
}
/**
* Conditionally require additional theme support classes.
*
* @since 3.37.0
* @since 4.3.0 Method access changed to `public`.
* @since 5.8.0 Added twenty-twenty-two compatibility.
*
* @return void
*/
public function includes() {
switch ( get_template() ) {
case 'twentynineteen':
require_once 'class-llms-twenty-nineteen.php';
break;
case 'twentytwenty':
require_once 'class-llms-twenty-twenty.php';
break;
case 'twentytwentyone':
require_once 'class-llms-twenty-twenty-one.php';
break;
case 'twentytwentytwo':
require_once 'class-llms-twenty-twenty-two.php';
break;
}
}
}
return new LLMS_Theme_Support();