PluginProbe
WP Courses LMS – Online Courses Builder, eLearning Courses, Courses Solution, Education Courses / trunk
WP Courses LMS – Online Courses Builder, eLearning Courses, Courses Solution, Education Courses vtrunk
3.2.30 trunk 3.1.40 3.1.41 3.1.42 3.1.43 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.23 3.2.24 3.2.25 All 36 releases
wp-courses / admin / front-end-editor.php

front-end-editor.php in WP Courses LMS – Online Courses Builder, eLearning Courses, Courses Solution, Education Courses trunk, at admin/front-end-editor.php

226 lines 13.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 function wpc_front_end_editor($post_id){ ?>
4 <script>
5 window.wpc_feePostId = <?php echo (int) $post_id; ?>;
6 </script>
7 <div class="wpc-fe-options-wrapper">
8 <div id="wpc-fe-options-accordion">
9 <h3 class="wpc-accordion-option-header"><?php esc_html_e('Size', 'wp-courses'); ?></h3>
10 <div class="wpc-accordion-option-content">
11 <div class="wpc-accordion-single-option wpc-range-option">
12 <?php
13 $width = get_option('wpc_row_width');
14 $width = wpc_esc_unit($width, 'px');
15
16 $width_unit = wpc_get_unit($width, '%');
17 ?>
18 <label><?php esc_html_e('Container Width', 'wp-courses'); ?> (px, em, %)</label><br>
19 <input class="wpc-range-ajax wpc-feo-text wpc-range-input" data-class="wpc-main" data-style="width" data-unit="<?php echo esc_attr($width_unit); ?>" data-option="wpc_row_width" type="text" placeholder="0" value="<?php echo esc_attr($width); ?>"/>
20 </div>
21 <div class="wpc-accordion-single-option wpc-range-option">
22 <?php
23 $max_width = get_option('wpc_row_max_width');
24 $max_width = wpc_esc_unit($max_width, 'px');
25
26 $max_width_unit = wpc_get_unit($max_width, 'px');
27 ?>
28 <label><?php _e('Container Max Width', 'wp-courses'); ?> (px, em, %)</label>
29 <br>
30 <input class="wpc-range-ajax wpc-feo-text wpc-range-input" data-class="wpc-main" data-style="max-width" data-unit="<?php echo esc_attr($max_width_unit); ?>" data-option="wpc_row_max_width" type="text" placeholder="0" value="<?php echo esc_attr($max_width); ?>"/>
31 </div>
32 <div class="wpc-accordion-single-option">
33 <?php
34 $container_padding_top = get_option('wpc_container_padding_top');
35 $container_padding_top = wpc_esc_unit($container_padding_top, 'px');
36
37 $container_padding_top_unit = wpc_get_unit($container_padding_top, 'px');
38 ?>
39 <label><?php _e('Container Padding', 'wp-courses'); ?> (px, em, %)</label><br>
40 <div class="wpc-spacing-wrapper">
41 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="padding-top" data-unit="<?php echo esc_attr($container_padding_top_unit); ?>" data-option="wpc_container_padding_top" type="text" placeholder="0" value="<?php echo esc_attr($container_padding_top); ?>"/>
42 <label class="wpcb-center-label">Top</label>
43 </div>
44 <?php
45 $container_padding_bottom = get_option('wpc_container_padding_bottom');
46 $container_padding_bottom = wpc_esc_unit($container_padding_bottom, 'px');
47
48 $container_padding_bottom_unit = wpc_get_unit($container_padding_bottom, 'px');
49 ?>
50 <div class="wpc-spacing-wrapper">
51 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="padding-bottom" data-unit="<?php echo esc_attr($container_padding_bottom_unit); ?>" data-option="wpc_container_padding_bottom" type="text" placeholder="0" value="<?php echo esc_attr($container_padding_bottom); ?>"/>
52 <label class="wpcb-center-label">Bottom</label>
53 </div>
54 <?php
55 $container_padding_left = get_option('wpc_container_padding_left');
56 $container_padding_left = wpc_esc_unit($container_padding_left, 'px');
57
58 $container_padding_left_unit = wpc_get_unit($container_padding_left, 'px');
59 ?>
60 <div class="wpc-spacing-wrapper">
61 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="padding-left" data-unit="<?php echo esc_attr($container_padding_left_unit); ?>" data-option="wpc_container_padding_left" type="text" placeholder="0" value="<?php echo esc_attr($container_padding_left); ?>"/>
62 <label class="wpcb-center-label">Left</label>
63 </div>
64 <?php
65 $container_padding_right = get_option('wpc_container_padding_right');
66 $container_padding_right = wpc_esc_unit($container_padding_right, 'px');
67
68 $container_padding_right_unit = wpc_get_unit($container_padding_right, 'px');
69 ?>
70 <div class="wpc-spacing-wrapper">
71 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="padding-right" data-unit="<?php echo esc_attr($container_padding_right_unit); ?>" data-option="wpc_container_padding_right" type="text" placeholder="0" value="<?php echo esc_attr($container_padding_right); ?>"/>
72 <label class="wpcb-center-label">Right</label>
73 </div>
74 </div>
75 <div class="wpc-accordion-single-option">
76 <?php
77 $container_margin_top = get_option('wpc_container_margin_top');
78 $container_margin_top = wpc_esc_unit($container_margin_top, 'px');
79
80 $container_margin_top_unit = wpc_get_unit($container_margin_top, 'px');
81 ?>
82 <label><?php _e('Container Margin', 'wp-courses'); ?> (px, em, %)</label><br>
83 <div class="wpc-spacing-wrapper">
84 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="margin-top" data-unit="<?php echo esc_attr($container_margin_top_unit); ?>" data-option="wpc_container_margin_top" type="text" placeholder="0" value="<?php echo esc_attr($container_margin_top); ?>"/>
85 <label class="wpcb-center-label">Top</label>
86 </div>
87 <?php
88 $container_margin_bottom = get_option('wpc_container_margin_bottom');
89 $container_margin_bottom = wpc_esc_unit($container_margin_bottom, 'px');
90
91 $container_margin_bottom_unit = wpc_get_unit($container_margin_bottom, 'px');
92 ?>
93 <div class="wpc-spacing-wrapper">
94 <input class="wpc-feo-text wpc-spacing-input" data-class="wpc-main" data-style="margin-bottom" data-unit="<?php echo esc_attr($container_margin_bottom_unit); ?>" data-option="wpc_container_margin_bottom" type="text" placeholder="0" value="<?php echo esc_attr($container_margin_bottom); ?>"/>
95 <label class="wpcb-center-label">Bottom</label>
96 </div>
97 </div>
98 </div>
99
100 <h3 class="wpc-accordion-option-header"><?php esc_html_e('Colors', 'wp-courses'); ?></h3>
101 <div class="wpc-accordion-option-content">
102
103 <?php $container_bg_color = get_option('wpc_primary_bg_color'); ?>
104 <div class="wpc-accordion-single-option">
105 <label><?php esc_html_e('Background', 'wp-courses'); ?></label><br>
106 <input type="color" class="wpc-fe-color-field" data-option="wpc_primary_bg_color" data-var="--wpcbg" value="<?php echo esc_attr($container_bg_color); ?>"/>
107 </div>
108
109 <?php $primary = get_option('wpc_primary_color'); ?>
110 <div class="wpc-accordion-single-option">
111 <label><?php esc_html_e('Detail Buttons', 'wp-courses'); ?></label><br>
112 <input type="color" class="wpc-fe-color-field" data-option="wpc_primary_color" data-var="--green" value="<?php echo esc_attr($primary); ?>"/>
113 </div>
114
115 <?php $secondary = get_option('wpc_secondary_color'); ?>
116 <div class="wpc-accordion-single-option">
117 <label><?php esc_html_e('Start Course & Add to Cart Buttons', 'wp-courses'); ?></label><br>
118 <input type="color" class="wpc-fe-color-field" data-option="wpc_secondary_color" data-var="--blue" value="<?php echo esc_attr($secondary); ?>"/>
119 </div>
120
121 <?php $secondary = get_option('wpc_toolbar_buttons_color'); ?>
122 <div class="wpc-accordion-single-option">
123 <label><?php esc_html_e('Toolbar Buttons', 'wp-courses'); ?></label><br>
124 <input type="color" class="wpc-fe-color-field" data-option="wpc_toolbar_buttons_color" data-var="--tool" value="<?php echo esc_attr($secondary); ?>"/>
125 </div>
126
127 <?php $secondary = get_option('wpc_selected_bg_color'); ?>
128 <div class="wpc-accordion-single-option">
129 <label><?php esc_html_e('Selected Item', 'wp-courses'); ?></label><br>
130 <input type="color" class="wpc-fe-color-field" data-option="wpc_selected_bg_color" data-var="--sele" value="<?php echo esc_attr($secondary); ?>"/>
131 </div>
132
133 <?php $secondary = get_option('wpc_link_color'); ?>
134 <div class="wpc-accordion-single-option">
135 <label><?php esc_html_e('Links', 'wp-courses'); ?></label><br>
136 <input type="color" class="wpc-fe-color-field" data-option="wpc_link_color" data-var="--link" value="<?php echo esc_attr($secondary); ?>"/>
137 </div>
138
139 <?php $secondary = get_option('wpc_standard_button_color'); ?>
140 <div class="wpc-accordion-single-option">
141 <label><?php esc_html_e('Standard Buttons', 'wp-courses'); ?></label><br>
142 <input type="color" class="wpc-fe-color-field" data-option="wpc_standard_button_color" data-var="--stand" value="<?php echo esc_attr($secondary); ?>"/>
143 </div>
144
145 </div>
146
147 <h3 class="wpc-accordion-option-header"><?php esc_html_e('Headings', 'wp-courses'); ?></h3>
148 <div class="wpc-accordion-option-content">
149 <?php
150 $h1 = get_option('wpc_h1_font_size');
151
152 $h1_unit = wpc_get_unit($h1, 'px');
153 ?>
154 <div class="wpc-accordion-single-option">
155 <label>H1 <?php esc_html_e('Font Size', 'wp-courses'); ?> (px, em, %)</label><br>
156 <input class="wpc-range-ajax wpc-feo-text wpc-range-input" data-class="wpc-h1" data-style="font-size" data-unit="<?php echo esc_attr($h1_unit); ?>" data-option="wpc_h1_font_size" type="text" placeholder="32px" value="<?php echo esc_attr($h1); ?>"/>
157 </div>
158 <?php
159 $h2 = get_option('wpc_h2_font_size');
160
161 $h2_unit = wpc_get_unit($h2, 'px');
162 ?>
163 <div class="wpc-accordion-single-option">
164 <label>H2 <?php _e('Font Size', 'wp-courses'); ?> (px, em, %)</label><br>
165 <input class="wpc-range-ajax wpc-feo-text wpc-range-input" data-class="wpc-h2" data-style="font-size" data-unit="<?php echo esc_attr($h2_unit); ?>" data-option="wpc_h2_font_size" type="text" placeholder="26px" value="<?php echo esc_attr($h2); ?>"/>
166 </div>
167 <?php
168 $h3 = get_option('wpc_h3_font_size');
169
170 $h3_unit = wpc_get_unit($h3, 'px');
171 ?>
172 <div class="wpc-accordion-single-option">
173 <label>H3 <?php _e('Font Size', 'wp-courses'); ?> (px, em, %)</label><br>
174 <input class="wpc-range-ajax wpc-feo-text wpc-range-input" data-class="wpc-h3" data-style="font-size" data-unit="<?php echo esc_attr($h3_unit); ?>"data-option="wpc_h3_font_size" type="text" placeholder="22px" value="<?php echo esc_attr($h3); ?>"/>
175 </div>
176 </div>
177 </div>
178 </div>
179
180 <div id="wpc-fe-setting-icon" data-open="false"><i class="fa fa-cog"></i></div>
181 <style id="wpc-fe-styles"></style>
182
183 <?php }
184
185 add_action('wp_head', 'wpc_front_end_options');
186
187 function wpc_front_end_options(){
188
189 $is_admin = current_user_can('administrator');
190 $post_type = get_post_type();
191 $post_id = get_the_ID();
192
193 if(
194 $is_admin && $post_type == 'course'
195 || $is_admin && $post_type == 'lesson'
196 || $is_admin && $post_type == 'wpc-quiz'
197 || $is_admin && $post_type == 'teacher'
198 || $is_admin && $post_type == 'wpc-certificate'
199 ){
200 wpc_front_end_editor($post_id); // FEE injected when course, lesson etc. posts are viewed directly
201 }
202 }
203
204 add_action( 'wp_ajax_save_fe_option', 'wpc_save_fe_option', 12 );
205
206 function wpc_save_fe_option() {
207 check_ajax_referer('wpc_nonce', 'security');
208
209 $post_id = (int) $_POST['post_id'];
210
211 if (!current_user_can( 'edit_page', $post_id ) && !current_user_can( 'edit_post', $post_id )) {
212 wp_die();
213 }
214
215 $option_name = sanitize_text_field($_POST['option']);
216 $option_value = sanitize_text_field($_POST['value']);
217
218 if ($option_name !== 'wpc_row_width' && $option_name !== 'wpc_row_max_width' && $option_name !== 'wpc_container_padding_top' && $option_name !== 'wpc_container_padding_bottom' && $option_name !== 'wpc_container_padding_left' && $option_name !== 'wpc_container_padding_right' && $option_name !== 'wpc_container_margin_bottom' && $option_name !== 'wpc_container_margin_top' && $option_name !== 'wpc_primary_bg_color' && $option_name !== 'wpc_primary_color' && $option_name !== 'wpc_secondary_color' && $option_name !== 'wpc_toolbar_buttons_color' && $option_name !== 'wpc_selected_bg_color' && $option_name !== 'wpc_link_color' && $option_name !== 'wpc_standard_button_color' && $option_name !== 'wpc_h1_font_size' && $option_name !== 'wpc_h2_font_size' && $option_name !== 'wpc_h3_font_size') {
219 wp_die();
220 }
221
222 update_option($option_name, $option_value);
223 wp_die();
224 }
225
226 ?>