Changeset 3090556
- Timestamp:
- 05/22/2024 05:31:56 AM (2 months ago)
- Location:
- abwpwoo
- Files:
-
- 2 edited
- 5 copied
Legend:
- Unmodified
- Added
- Removed
-
abwpwoo/tags/5.3/readme.txt
r3043038 r3090556 3 3 Tags: ab-inspiration,woocommerce,wp courseware,lms,learning management system,online courses 4 4 Requires at least: 4.8 5 Tested up to: 6. 4.36 Stable tag: 5. 25 Tested up to: 6. 6 Stable tag: 5. 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 57 57 58 58 == Changelog == 59 60 61 62 59 63 = 5.2 = 60 64 * удален текст /Завершено на/ -
abwpwoo/tags/5.3/wwpcouseware-extra-settings.php
r3043038 r3090556 2 2 /** 3 3 * Plugin Name: Addon for AB-Inspiration, WooCommerce and WP Courseware 4 * Version: 5. 24 * Version: 5. 5 5 * Plugin URI: https://ab-inspiration.com 6 6 * Description: The official extension AB-Inspiration for add integration for WP Courseware and WooCommmerce. … … 11 11 * License: GPL v2 or later 12 12 */ 13 14 15 13 /***************Plugin Functions****************/ 16 14 17 18 15 function my_plugin_load_plugin_textdomain() { 19 load_plugin_textdomain( 'wpcoursewarextra', FALSE, basename( dirname( __FILE__ ) ) . '/languages/');20 } 21 add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain');16 ); 17 } 18 add_action(); 22 19 23 20 function wpcw_custom_script() { 24 25 // Register the script 26 wp_register_script( 'wpcw_custom', plugin_dir_url( __FILE__ ) . 'js/wpcw-custom.js', array('jquery'), true ); 27 28 // Localize the script with new data 29 $translation_array = array( 30 'course_complete_text' => __( ' ', 'wpcoursewarextra' ) 31 32 ); 33 wp_localize_script( 'wpcw_custom', 'course_complete', $translation_array ); 34 35 // Enqueued script with localized data. 36 wp_enqueue_script( 'wpcw_custom' ); 37 } 38 add_action( 'wp_enqueue_scripts', 'wpcw_custom_script' ); 39 40 41 21 // Register the script 22 wp_register_script('wpcw_custom', plugin_dir_url(__FILE__) . 'js/wpcw-custom.js', array('jquery'), true); 23 24 // Localize the script with new data 25 $translation_array = array( 26 'course_complete_text' => __(' ', 'wpcoursewarextra') 27 ); 28 wp_localize_script('wpcw_custom', 'course_complete', $translation_array); 29 30 // Enqueued script with localized data. 31 wp_enqueue_script('wpcw_custom'); 32 } 33 add_action('wp_enqueue_scripts', 'wpcw_custom_script'); 42 34 function ABIWPWOO_register_settings() { 43 add_option( 'ab_wpcourseware', 'Дополнительные настройки'); 44 register_setting( 'abwpwoo_options_group', 'ab_wpcourseware', 'abwpwoo_callback' ); 45 } 46 add_action( 'admin_init', 'ABIWPWOO_register_settings' ); 47 35 $defaults = array( 36 'sanitize_callback' => null, 37 'default' => null 38 ); 39 add_option('ab_wpcourseware', 'Дополнительные настройки'); 40 register_setting('abwpwoo_options_group', 'ab_wpcourseware', $defaults); 41 } 42 add_action('admin_init', 'ABIWPWOO_register_settings'); 48 43 function abwpwoo_register_options_page() { 49 add_submenu_page('wpcw', __( 'Доп. настройки', 'wpcoursewarextra' ), __( 'Доп. настройки', 'wpcoursewarextra' ), 'manage_options', 'abwpwoo', 'abwpwoo_options_page'); 50 } 51 add_action('admin_menu', 'abwpwoo_register_options_page',11); 52 53 54 $ab_wpcourseware = get_option('ab_wpcourseware'); 55 56 function abwpwoo_options_page() 57 { 58 ?> 59 60 61 62 <div> 63 <?php screen_icon(); ?> 64 <h2><?php _e( 'Дополнительные настройки для плагина WP Courseware', 'wpcoursewarextra' ); ?></h2> 65 <form method="post" action="options.php"> 66 <?php settings_fields( 'abwpwoo_options_group' ); ?> 67 68 69 <div> 70 <table class="form-table"> 71 72 <tr valign="top"> 73 <th scope="row"><?php _e( 'Исключить курсы из каталога:', 'wpcoursewarextra' ); ?></th> 74 <td colspan="2"> 75 76 <?php 77 78 79 function abwpwoo_courses( $post_type ) { // post_list 80 global $ab_wpcourseware; 81 82 $items = get_posts( array ( 83 'post_type' => $post_type, 84 'posts_per_page' => -1 85 )); 86 foreach($items as $item) { 87 88 ?> 89 <input type="checkbox" value="<?php echo $item->ID; ?>" name="ab_wpcourseware[id_courses][]" id="<?php echo $item->ID; ?>" <?php echo in_array($item->ID, $ab_wpcourseware["id_courses"]) ? 'checked' : ''; ?> /> 90 <label for="<?php echo $item->ID; ?>"><?php echo $item->post_title; ?></label><br /> <?php 91 } // end foreach 92 93 } 94 echo abwpwoo_courses( 'wpcw_course' ); 95 ?> 96 97 </td> 98 </tr> 99 100 101 <tr valign="top"> 102 <th scope="row"><?php _e( 'Курс + Товар:', 'wpcoursewarextra' ); ?></th> 103 <td colspan="2"> 104 105 <?php 106 function abwpwoo_courses_products() { // post_list 107 global $ab_wpcourseware; 108 109 $items = get_posts( array ( 110 'post_type' => 'wpcw_course', 111 'posts_per_page' => -1, 112 'orderby' => 'ID', 113 'order' => 'ASC', 114 )); 115 116 $itemsp = get_posts( array ( 117 'post_type' => 'product', 118 'posts_per_page' => -1 119 )); 120 121 foreach($items as $item => $itm) { ?> 122 123 <tr style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none;<?php } ?>"> 124 125 <td class="<?php echo $itm->ID; ?>"> 126 <input type="checkbox" <?php if(!in_array($itm->ID, $ab_wpcourseware["id_courses"])) {echo 'checked'; } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses][]" id="<?php echo $itm->ID; ?>" style="display:none" /> 127 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 128 129 </td> 130 131 <td class="<?php echo $item; ?>"> 132 <select name="ab_wpcourseware[id_courses_product][<?php echo $item; ?>]" style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none<?php } ?>"> 133 <option value=""><?php _e( 'Курс бесплатный', 'wpcoursewarextra' ); ?></option> 134 <?php foreach($itemsp as $itemp => $it) { ?> 135 136 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 137 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_product'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 138 <?php } ?> 139 <?php } ?></select> 140 141 </td></tr> 142 143 <?php } 144 145 } 146 147 echo abwpwoo_courses_products(); ?> 148 </td> 149 </tr> 150 151 <tr valign="top"> 152 <th scope="row"><?php _e( 'Курс + Страницы Лендинги:', 'wpcoursewarextra' ); ?></th> 153 <td colspan="2"> 154 155 156 <?php 157 function abwpwoo_courses_pages() {// post_list 158 global $ab_wpcourseware; 159 160 $items = get_posts( array ( 161 'post_type' => 'wpcw_course', 162 'posts_per_page' => -1, 163 'orderby' => 'ID', 164 'order' => 'ASC', 165 )); 166 167 $itemsp = get_posts( array ( 168 'post_type' => 'page', 169 'posts_per_page' => -1 170 )); 171 172 173 $itemsl = get_posts( array ( 174 'post_type' => 'e-landing-page', 175 'posts_per_page' => -1 176 )); 177 178 179 foreach($items as $item => $itm) { ?> 180 <tr style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none;<?php } ?>"><td class="<?php echo $itm->ID; ?>"><input type="checkbox" <?php if(!in_array($itm->ID, $ab_wpcourseware["id_courses"])) {echo 'checked'; } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses_pages][]" id="<?php echo $itm->ID; ?>" style="display:none" /> 181 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 182 183 </td> 184 <td class="<?php echo $item; ?>"> 185 186 <select name="ab_wpcourseware[id_courses_pages][<?php echo $item; ?>]" style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none<?php } ?>"> 187 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 188 <option value=""><?php _e( 'Оставить страницу курса', 'wpcoursewarextra' ); ?></option> <?php } ?> 189 190 <optgroup label = "Страницы"> 191 <?php foreach($itemsp as $itemp => $it) { ?> 192 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 193 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_pages'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 194 <?php } ?> 195 196 197 198 199 200 201 <?php } ?> 202 </optgroup> 203 <optgroup label = "Лендинги Elementor"> 204 205 <?php foreach($itemsl as $itemp => $it) { ?> 206 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 207 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_pages'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 208 <?php } ?> 209 <?php } ?> 210 </optgroup> 211 212 </select> 213 214 </td></tr> 215 216 <?php } 217 218 } 219 echo abwpwoo_courses_pages(); ?> 220 221 </td> 222 </tr> 223 224 225 226 227 228 <tr valign="top"> 229 <th scope="row"><?php _e( 'Расположение курсов на странице Курсы:', 'wpcoursewarextra' ); ?></th> 230 <td colspan="2"> 231 232 233 <?php 234 function abwpwoo_courses_layout() { 235 global $ab_wpcourseware; ?> 236 237 <input type="checkbox" id="checkbox_example" name="ab_wpcourseware[checkbox_example]" value="1" <?php if ( 1 == $ab_wpcourseware['checkbox_example'] ) echo 'checked="checked"'; ?>> 238 239 240 <label for="checkbox_example">Отметьте галочкой, если хотите, чтобы курсы располагались горизонтально </label> 241 242 243 <?php } 244 245 echo abwpwoo_courses_layout(); ?> 246 247 </td> 248 </tr> 249 250 251 252 253 254 </table> 255 </div> 256 257 <?php submit_button(); ?> 258 </form> 259 </div> 260 <?php 261 } 262 263 264 function abwpwoo_headline_link() {} 265 266 function abwpwoo_price_wpcourseware_woocommerce() {} 267 268 function abwpwoo_display_gravatar($atts) { 269 extract( shortcode_atts( array( 270 'wpb_user_email' => '', 271 ), $atts ) ); 272 if ( is_user_logged_in() ) { 273 if ($wpb_user_email == '') { 274 global $current_user; 275 wp_get_current_user(); 276 $getuseremail = $current_user->user_email; 277 $getusername = $current_user->user_firstname; 278 $getuserlastname = $current_user->user_lastname; 279 280 } else { 281 $getuseremail = $wpb_user_email; 282 } 283 $usergravatar = '//www.gravatar.com/avatar/' . md5($getuseremail) . '?s=100'; 284 285 echo '<div style=""><div style="float:left;margin-bottom:30px; "><img style="border:1px solid #eaeaea; border-radius:50%" src="' . $usergravatar . '" /></div><div style="float:left; font-size:24px; font-weight:bold; margin-top: 20px; 286 margin-left: 20px;">'. $current_user->display_name; 287 echo '</div></div> '; 288 echo '<div style="clear:both"></div>'; 289 }} 44 add_submenu_page('wpcw', __('Доп. настройки', 'wpcoursewarextra'), __('Доп. настройки', 'wpcoursewarextra'), 'manage_options', 'abwpwoo', 'abwpwoo_options_page'); 45 } 46 add_action('admin_menu', 'abwpwoo_register_options_page', 11); 47 48 $ab_wpcourseware = get_option('ab_wpcourseware'); 49 function abwpwoo_options_page() { ?> 50 <div> 51 <h2><?php _e('Дополнительные настройки для плагина WP Courseware', 'wpcoursewarextra'); ?></h2> 52 <form method="post" action="options.php"> 53 <?php settings_fields('abwpwoo_options_group'); ?> 54 <div> 55 <table class="form-table"> 56 <tr valign="top"> 57 <th scope="row"><?php _e('Исключить курсы из каталога:', 'wpcoursewarextra'); ?></th> 58 <td colspan="2"> 59 <?php function abwpwoo_courses($post_type) { // post_list 60 global $ab_wpcourseware; 61 62 $items = get_posts( 63 array( 64 'post_type' => $post_type, 65 'posts_per_page' => -1 66 ) 67 ); 68 69 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 70 $a = (array) $abwpcourseware; 71 72 foreach ($items as $item) { ?> 73 <input type="checkbox" value="<?php echo $item->ID; ?>" name="ab_wpcourseware[id_courses][]" 74 id="<?php echo $item->ID; ?>" <?php echo in_array($item->ID, $a) ? 'checked' : ''; ?> /> 75 <label for="<?php echo $item->ID; ?>"><?php echo $item->post_title; ?></label><br /> 76 <?php 77 } // end foreach 78 } 79 echo abwpwoo_courses('wpcw_course'); ?> 80 </td> 81 </tr> 82 <tr valign="top"> 83 <th scope="row"><?php _e('Курс + Товар:', 'wpcoursewarextra'); ?></th> 84 <td colspan="2"> 85 <?php function abwpwoo_courses_products() { // post_list 86 global $ab_wpcourseware; 87 88 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 89 $a = (array) $abwpcourseware; 90 $abwpcoursewareb = $ab_wpcourseware['id_courses_product'] ?? ''; 91 $b = (array) $abwpcoursewareb; 92 93 $items = get_posts( 94 array( 95 'post_type' => 'wpcw_course', 96 'posts_per_page' => -1, 97 'orderby' => 'ID', 98 'order' => 'ASC', 99 ) 100 ); 101 $itemsp = get_posts( 102 array( 103 'post_type' => 'product', 104 'posts_per_page' => -1 105 ) 106 ); 107 108 foreach ($items as $item => $itm) { ?> 109 110 <tr style="<?php if (in_array($itm->ID, $a)) { ?>display:none;<?php } ?>"> 111 112 <td class="<?php echo $itm->ID; ?>"> 113 <input type="checkbox" <?php if (!in_array($itm->ID, $a)) { 114 echo 'checked'; 115 } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses][]" id="<?php echo $itm->ID; ?>" 116 style="display:none" /> 117 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 118 119 </td> 120 121 <td class="<?php echo $item; ?>"> 122 <select name="ab_wpcourseware[id_courses_product][<?php echo $item; ?>]" 123 style="<?php if (in_array($itm->ID, $a)) { ?>display:none<?php } ?>"> 124 <option value=""><?php _e('Курс бесплатный', 'wpcoursewarextra'); ?></option> 125 <?php foreach ($itemsp as $itemp => $it) { ?> 126 127 <?php if (!in_array($itm->ID, $a)) { ?> 128 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 129 echo 'selected="selected"'; 130 } ?>> 131 <?php echo $it->post_title; ?> 132 </option> 133 <?php } ?> 134 <?php } ?> 135 </select> 136 </td> 137 </tr> 138 <?php } 139 } 140 echo abwpwoo_courses_products(); ?> 141 </td> 142 </tr> 143 144 <tr valign="top"> 145 <th scope="row"><?php _e('Курс + Страницы Лендинги:', 'wpcoursewarextra'); ?></th> 146 <td colspan="2"> 147 148 <?php 149 function abwpwoo_courses_pages() { // post_list 150 global $ab_wpcourseware; 151 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 152 $a = (array) $abwpcourseware; 153 $abwpcoursewareb = $ab_wpcourseware['id_courses_pages'] ?? ''; 154 $b = (array) $abwpcoursewareb; 155 156 $items = get_posts( 157 array( 158 'post_type' => 'wpcw_course', 159 'posts_per_page' => -1, 160 'orderby' => 'ID', 161 'order' => 'ASC', 162 ) 163 ); 164 165 $itemsp = get_posts( 166 array( 167 'post_type' => 'page', 168 'posts_per_page' => -1 169 ) 170 ); 171 172 $itemsl = get_posts( 173 array( 174 'post_type' => 'e-landing-page', 175 'posts_per_page' => -1 176 ) 177 ); 178 179 foreach ($items as $item => $itm) { ?> 180 <tr style="<?php if (in_array($itm->ID, $a)) { ?>display:none;<?php } ?>"> 181 <td class="<?php echo $itm->ID; ?>"><input type="checkbox" <?php if (!in_array($itm->ID, $a)) { 182 echo 'checked'; 183 } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses_pages][]" 184 id="<?php echo $itm->ID; ?>" style="display:none" /> 185 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 186 187 </td> 188 <td class="<?php echo $item; ?>"> 189 190 <select name="ab_wpcourseware[id_courses_pages][<?php echo $item; ?>]" 191 style="<?php if (in_array($itm->ID, $a)) { ?>display:none<?php } ?>"> 192 <?php if (!in_array($itm->ID, $a)) { ?> 193 <option value=""><?php _e('Оставить страницу курса', 'wpcoursewarextra'); ?></option> 194 <?php } ?> 195 196 <optgroup label="Страницы"> 197 <?php foreach ($itemsp as $itemp => $it) { ?> 198 <?php if (!in_array($itm->ID, $a)) { ?> 199 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 200 echo 'selected="selected"'; 201 } ?>> 202 <?php echo $it->post_title; ?> 203 </option> 204 <?php } ?> 205 <?php } ?> 206 </optgroup> 207 <optgroup label="Лендинги Elementor"> 208 <?php foreach ($itemsl as $itemp => $it) { ?> 209 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 210 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 211 echo 'selected="selected"'; 212 } ?>> 213 <?php echo $it->post_title; ?> 214 </option> 215 <?php } ?> 216 <?php } ?> 217 </optgroup> 218 </select> 219 </td> 220 </tr> 221 <?php } 222 } 223 echo abwpwoo_courses_pages(); ?> 224 225 </td> 226 </tr> 227 <tr valign="top"> 228 <th scope="row"><?php _e('Расположение курсов на странице Курсы:', 'wpcoursewarextra'); ?></th> 229 <td colspan="2"> 230 231 <?php 232 function abwpwoo_courses_layout() { 233 global $ab_wpcourseware; 234 235 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 236 $a = (array) $abwpcourseware; 237 $abwpcoursewareb = $ab_wpcourseware['checkbox_example'] ?? ''; 238 $b = (bool) $abwpcoursewareb; ?> 239 <input type="checkbox" id="checkbox_example" name="ab_wpcourseware[checkbox_example]" value="1" <?php if (1 == $b) 240 echo 'checked="checked"'; ?>> 241 242 <label for="checkbox_example">Отметьте галочкой, если хотите, чтобы курсы располагались 243 горизонтально </label> 244 245 <?php } 246 echo abwpwoo_courses_layout(); ?> 247 248 </td> 249 </tr> 250 251 </table> 252 </div> 253 254 <?php submit_button(); ?> 255 </form> 256 </div> 257 <?php 258 } 259 260 function abwpwoo_headline_link() { 261 } 262 263 function abwpwoo_price_wpcourseware_woocommerce() { 264 } 265 function abwpwoo_display_gravatar($atts) { 266 extract(shortcode_atts(array('wpb_user_email' => '', ), $atts)); 267 if (is_user_logged_in()) { 268 if ($wpb_user_email == '') { 269 global $current_user; 270 wp_get_current_user(); 271 $getuseremail = $current_user->user_email; 272 $getusername = $current_user->user_firstname; 273 $getuserlastname = $current_user->user_lastname; 274 } else { 275 $getuseremail = $wpb_user_email; 276 } 277 $usergravatar = '//www.gravatar.com/avatar/' . md5($getuseremail) . '?s=100'; 278 279 echo '<div style=""><div style="float:left;margin-bottom:30px; "><img style="border:1px solid #eaeaea; border-radius:50%" src="' . $usergravatar . '" /></div><div style="float:left; font-size:24px; font-weight:bold; margin-top: 20px; margin-left: 20px;">' . $current_user->display_name; 280 echo '</div></div> '; 281 echo '<div style="clear:both"></div>'; 282 } 283 } 290 284 291 285 add_shortcode('wpb_gravatar', 'abwpwoo_display_gravatar'); 292 286 293 294 add_filter( 'wpcw_ignore_active_membership_integration', '__return_true' ); 295 296 297 add_filter( 'wpcw_course_enrollment_success_message', function( $message, $course_id, $user_id ) { 298 // Do something with the message. Replace it, append to it, etc... 299 $message .= __( 'Вы успешно зачислены на курс. Выбранные вами курсы смотрите в ЛИЧНОМ КАБИНЕТЕ в разделе КУРСЫ', 'wpcoursewarextra' ); 300 return $message; 301 }, 10, 3 ); 302 303 304 function abwpwoo_content_progressBar( $percentage, $cssClass = false, $extraHTML = false ) { 305 return sprintf( ' 287 add_filter('wpcw_ignore_active_membership_integration', '__return_true'); 288 289 add_filter('wpcw_course_enrollment_success_message', function ($message, $course_id, $user_id) { 290 // Do something with the message. Replace it, append to it, etc... 291 $message .= __('Вы успешно зачислены на курс. Выбранные вами курсы смотрите в ЛИЧНОМ КАБИНЕТЕ в разделе КУРСЫ', 'wpcoursewarextra'); 292 return $message; 293 }, 10, 3); 294 295 function abwpwoo_content_progressBar($percentage, $cssClass = false, $extraHTML = false) { 296 return sprintf( 297 ' 306 298 <span class="wpcw_progress_wrap %s"> 307 299 <span class="wpcw_progress"> … … 311 303 %s 312 304 </span>', 313 $cssClass, 314 $percentage, 315 $percentage, 316 $extraHTML 317 ); 318 } 319 320 321 322 323 324 325 /** 326 * Course Enroll Shortcode. 327 * 328 * e.g. [wpcourse_enroll courses="2,3" enroll_text="Enroll Here"] 329 * 330 * @since 4.3.0 331 * 332 * @param array $atts The shortcode attributes. 333 * @param string $content The shortcode content. 334 * 335 * @return string The course enroll button string. 336 */ 337 function course_enroll_shortcode_link( $atts, $content = '' ) { 338 $shortcode_atts = shortcode_atts( array( 339 'courses' => false, 340 'enroll_text' => esc_html__( 'Enroll Now', 'wp-courseware' ), 341 'purchase_text' => esc_html__( 'Purchase', 'wp-courseware' ), 342 'installments_text' => esc_html__( 'Installments', 'wp-courseware' ), 343 'display_messages' => true, 344 'display_raw' => false, 345 'redirect' => false, 346 ), $atts, 'wpcourse_enroll' ); 347 348 // Check for courses. 349 if ( ! $shortcode_atts['courses'] && ! is_null( $shortcode_atts['courses'] ) ) { 350 return; 351 } 352 $courses_to_enroll = array(); 353 354 355 356 $courses = array(); 357 358 foreach ( $courses as $key => $course ) { 359 360 361 $courses_to_enroll[ 'course_id[0]' ] = esc_html( $shortcode_atts['courses'] ); 362 } 363 364 365 366 367 368 $courses_to_enroll[ 'course_id[0]' ] = esc_html( $shortcode_atts['courses'] ); 369 $enroll_text = esc_html( $shortcode_atts['enroll_text'] ); 370 371 $query_args = array( $courses_to_enroll, array( 'unit_redirect' => $redirect ) ); 372 $course_enrollment_url = wp_nonce_url( add_query_arg( $query_args, wp_registration_url() ), 'wpcw_enroll', '_wp_enroll' ); 373 $shortcode_html .= sprintf( __( '%s', 'wp-courseware' ), esc_url_raw( $course_enrollment_url ), esc_html( $enroll_text ) ); 374 375 376 377 378 return apply_filters( 'wpcw_course_enroll_shortcode_html', $shortcode_html ); 379 } 380 381 add_shortcode( 'wpcourse_enroll_link', 'course_enroll_shortcode_link' ); 305 $cssClass, 306 $percentage, 307 $percentage, 308 $extraHTML 309 ); 310 } 311 312 /** 313 * Course Enroll Shortcode. 314 * 315 * e.g. [wpcourse_enroll courses="2,3" enroll_text="Enroll Here"] 316 * 317 * @since 4.3.0 318 * 319 * @param array $atts The shortcode attributes. 320 * @param string $content The shortcode content. 321 * 322 * @return string The course enroll button string. 323 */ 324 function course_enroll_shortcode_link($atts, $content = '') { 325 $shortcode_atts = shortcode_atts( 326 array( 327 'courses' => false, 328 'enroll_text' => esc_html__('Enroll Now', 'wp-courseware'), 329 'purchase_text' => esc_html__('Purchase', 'wp-courseware'), 330 'installments_text' => esc_html__('Installments', 'wp-courseware'), 331 'display_messages' => true, 332 'display_raw' => false, 333 'redirect' => false, 334 ), $atts, 'wpcourse_enroll'); 335 336 // Check for courses. 337 if (!$shortcode_atts['courses'] && !is_null($shortcode_atts['courses'])) { 338 return; 339 } 340 $courses_to_enroll = array(); 341 342 $courses = array(); 343 344 foreach ($courses as $key => $course) { 345 $courses_to_enroll['course_id[0]'] = esc_html($shortcode_atts['courses']); 346 } 347 348 $courses_to_enroll['course_id[0]'] = esc_html($shortcode_atts['courses']); 349 $enroll_text = esc_html($shortcode_atts['enroll_text']); 350 351 $query_args = array($courses_to_enroll); 352 $course_enrollment_url = wp_nonce_url(add_query_arg($query_args, wp_registration_url()), 'wpcw_enroll', '_wp_enroll'); 353 $shortcode_html .= sprintf(__('%s', 'wp-courseware'), esc_url_raw($course_enrollment_url), esc_html($enroll_text)); 354 355 return apply_filters('wpcw_course_enroll_shortcode_html', $shortcode_html); 356 } 357 358 add_shortcode('wpcourse_enroll_link', 'course_enroll_shortcode_link'); -
abwpwoo/trunk/readme.txt
r3043038 r3090556 3 3 Tags: ab-inspiration,woocommerce,wp courseware,lms,learning management system,online courses 4 4 Requires at least: 4.8 5 Tested up to: 6. 4.36 Stable tag: 5. 25 Tested up to: 6. 6 Stable tag: 5. 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 57 57 58 58 == Changelog == 59 60 61 62 59 63 = 5.2 = 60 64 * удален текст /Завершено на/ -
abwpwoo/trunk/wwpcouseware-extra-settings.php
r3043038 r3090556 2 2 /** 3 3 * Plugin Name: Addon for AB-Inspiration, WooCommerce and WP Courseware 4 * Version: 5. 24 * Version: 5. 5 5 * Plugin URI: https://ab-inspiration.com 6 6 * Description: The official extension AB-Inspiration for add integration for WP Courseware and WooCommmerce. … … 11 11 * License: GPL v2 or later 12 12 */ 13 14 15 13 /***************Plugin Functions****************/ 16 14 17 18 15 function my_plugin_load_plugin_textdomain() { 19 load_plugin_textdomain( 'wpcoursewarextra', FALSE, basename( dirname( __FILE__ ) ) . '/languages/');20 } 21 add_action( 'plugins_loaded', 'my_plugin_load_plugin_textdomain');16 ); 17 } 18 add_action(); 22 19 23 20 function wpcw_custom_script() { 24 25 // Register the script 26 wp_register_script( 'wpcw_custom', plugin_dir_url( __FILE__ ) . 'js/wpcw-custom.js', array('jquery'), true ); 27 28 // Localize the script with new data 29 $translation_array = array( 30 'course_complete_text' => __( ' ', 'wpcoursewarextra' ) 31 32 ); 33 wp_localize_script( 'wpcw_custom', 'course_complete', $translation_array ); 34 35 // Enqueued script with localized data. 36 wp_enqueue_script( 'wpcw_custom' ); 37 } 38 add_action( 'wp_enqueue_scripts', 'wpcw_custom_script' ); 39 40 41 21 // Register the script 22 wp_register_script('wpcw_custom', plugin_dir_url(__FILE__) . 'js/wpcw-custom.js', array('jquery'), true); 23 24 // Localize the script with new data 25 $translation_array = array( 26 'course_complete_text' => __(' ', 'wpcoursewarextra') 27 ); 28 wp_localize_script('wpcw_custom', 'course_complete', $translation_array); 29 30 // Enqueued script with localized data. 31 wp_enqueue_script('wpcw_custom'); 32 } 33 add_action('wp_enqueue_scripts', 'wpcw_custom_script'); 42 34 function ABIWPWOO_register_settings() { 43 add_option( 'ab_wpcourseware', 'Дополнительные настройки'); 44 register_setting( 'abwpwoo_options_group', 'ab_wpcourseware', 'abwpwoo_callback' ); 45 } 46 add_action( 'admin_init', 'ABIWPWOO_register_settings' ); 47 35 $defaults = array( 36 'sanitize_callback' => null, 37 'default' => null 38 ); 39 add_option('ab_wpcourseware', 'Дополнительные настройки'); 40 register_setting('abwpwoo_options_group', 'ab_wpcourseware', $defaults); 41 } 42 add_action('admin_init', 'ABIWPWOO_register_settings'); 48 43 function abwpwoo_register_options_page() { 49 add_submenu_page('wpcw', __( 'Доп. настройки', 'wpcoursewarextra' ), __( 'Доп. настройки', 'wpcoursewarextra' ), 'manage_options', 'abwpwoo', 'abwpwoo_options_page'); 50 } 51 add_action('admin_menu', 'abwpwoo_register_options_page',11); 52 53 54 $ab_wpcourseware = get_option('ab_wpcourseware'); 55 56 function abwpwoo_options_page() 57 { 58 ?> 59 60 61 62 <div> 63 <?php screen_icon(); ?> 64 <h2><?php _e( 'Дополнительные настройки для плагина WP Courseware', 'wpcoursewarextra' ); ?></h2> 65 <form method="post" action="options.php"> 66 <?php settings_fields( 'abwpwoo_options_group' ); ?> 67 68 69 <div> 70 <table class="form-table"> 71 72 <tr valign="top"> 73 <th scope="row"><?php _e( 'Исключить курсы из каталога:', 'wpcoursewarextra' ); ?></th> 74 <td colspan="2"> 75 76 <?php 77 78 79 function abwpwoo_courses( $post_type ) { // post_list 80 global $ab_wpcourseware; 81 82 $items = get_posts( array ( 83 'post_type' => $post_type, 84 'posts_per_page' => -1 85 )); 86 foreach($items as $item) { 87 88 ?> 89 <input type="checkbox" value="<?php echo $item->ID; ?>" name="ab_wpcourseware[id_courses][]" id="<?php echo $item->ID; ?>" <?php echo in_array($item->ID, $ab_wpcourseware["id_courses"]) ? 'checked' : ''; ?> /> 90 <label for="<?php echo $item->ID; ?>"><?php echo $item->post_title; ?></label><br /> <?php 91 } // end foreach 92 93 } 94 echo abwpwoo_courses( 'wpcw_course' ); 95 ?> 96 97 </td> 98 </tr> 99 100 101 <tr valign="top"> 102 <th scope="row"><?php _e( 'Курс + Товар:', 'wpcoursewarextra' ); ?></th> 103 <td colspan="2"> 104 105 <?php 106 function abwpwoo_courses_products() { // post_list 107 global $ab_wpcourseware; 108 109 $items = get_posts( array ( 110 'post_type' => 'wpcw_course', 111 'posts_per_page' => -1, 112 'orderby' => 'ID', 113 'order' => 'ASC', 114 )); 115 116 $itemsp = get_posts( array ( 117 'post_type' => 'product', 118 'posts_per_page' => -1 119 )); 120 121 foreach($items as $item => $itm) { ?> 122 123 <tr style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none;<?php } ?>"> 124 125 <td class="<?php echo $itm->ID; ?>"> 126 <input type="checkbox" <?php if(!in_array($itm->ID, $ab_wpcourseware["id_courses"])) {echo 'checked'; } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses][]" id="<?php echo $itm->ID; ?>" style="display:none" /> 127 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 128 129 </td> 130 131 <td class="<?php echo $item; ?>"> 132 <select name="ab_wpcourseware[id_courses_product][<?php echo $item; ?>]" style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none<?php } ?>"> 133 <option value=""><?php _e( 'Курс бесплатный', 'wpcoursewarextra' ); ?></option> 134 <?php foreach($itemsp as $itemp => $it) { ?> 135 136 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 137 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_product'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 138 <?php } ?> 139 <?php } ?></select> 140 141 </td></tr> 142 143 <?php } 144 145 } 146 147 echo abwpwoo_courses_products(); ?> 148 </td> 149 </tr> 150 151 <tr valign="top"> 152 <th scope="row"><?php _e( 'Курс + Страницы Лендинги:', 'wpcoursewarextra' ); ?></th> 153 <td colspan="2"> 154 155 156 <?php 157 function abwpwoo_courses_pages() {// post_list 158 global $ab_wpcourseware; 159 160 $items = get_posts( array ( 161 'post_type' => 'wpcw_course', 162 'posts_per_page' => -1, 163 'orderby' => 'ID', 164 'order' => 'ASC', 165 )); 166 167 $itemsp = get_posts( array ( 168 'post_type' => 'page', 169 'posts_per_page' => -1 170 )); 171 172 173 $itemsl = get_posts( array ( 174 'post_type' => 'e-landing-page', 175 'posts_per_page' => -1 176 )); 177 178 179 foreach($items as $item => $itm) { ?> 180 <tr style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none;<?php } ?>"><td class="<?php echo $itm->ID; ?>"><input type="checkbox" <?php if(!in_array($itm->ID, $ab_wpcourseware["id_courses"])) {echo 'checked'; } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses_pages][]" id="<?php echo $itm->ID; ?>" style="display:none" /> 181 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 182 183 </td> 184 <td class="<?php echo $item; ?>"> 185 186 <select name="ab_wpcourseware[id_courses_pages][<?php echo $item; ?>]" style="<?php if (in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?>display:none<?php } ?>"> 187 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 188 <option value=""><?php _e( 'Оставить страницу курса', 'wpcoursewarextra' ); ?></option> <?php } ?> 189 190 <optgroup label = "Страницы"> 191 <?php foreach($itemsp as $itemp => $it) { ?> 192 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 193 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_pages'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 194 <?php } ?> 195 196 197 198 199 200 201 <?php } ?> 202 </optgroup> 203 <optgroup label = "Лендинги Elementor"> 204 205 <?php foreach($itemsl as $itemp => $it) { ?> 206 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 207 <option value="<?php echo $it->ID; ?>" <?php if ($ab_wpcourseware['id_courses_pages'][$item] == $it->ID) { echo 'selected="selected"';} ?>><?php echo $it->post_title; ?></option> 208 <?php } ?> 209 <?php } ?> 210 </optgroup> 211 212 </select> 213 214 </td></tr> 215 216 <?php } 217 218 } 219 echo abwpwoo_courses_pages(); ?> 220 221 </td> 222 </tr> 223 224 225 226 227 228 <tr valign="top"> 229 <th scope="row"><?php _e( 'Расположение курсов на странице Курсы:', 'wpcoursewarextra' ); ?></th> 230 <td colspan="2"> 231 232 233 <?php 234 function abwpwoo_courses_layout() { 235 global $ab_wpcourseware; ?> 236 237 <input type="checkbox" id="checkbox_example" name="ab_wpcourseware[checkbox_example]" value="1" <?php if ( 1 == $ab_wpcourseware['checkbox_example'] ) echo 'checked="checked"'; ?>> 238 239 240 <label for="checkbox_example">Отметьте галочкой, если хотите, чтобы курсы располагались горизонтально </label> 241 242 243 <?php } 244 245 echo abwpwoo_courses_layout(); ?> 246 247 </td> 248 </tr> 249 250 251 252 253 254 </table> 255 </div> 256 257 <?php submit_button(); ?> 258 </form> 259 </div> 260 <?php 261 } 262 263 264 function abwpwoo_headline_link() {} 265 266 function abwpwoo_price_wpcourseware_woocommerce() {} 267 268 function abwpwoo_display_gravatar($atts) { 269 extract( shortcode_atts( array( 270 'wpb_user_email' => '', 271 ), $atts ) ); 272 if ( is_user_logged_in() ) { 273 if ($wpb_user_email == '') { 274 global $current_user; 275 wp_get_current_user(); 276 $getuseremail = $current_user->user_email; 277 $getusername = $current_user->user_firstname; 278 $getuserlastname = $current_user->user_lastname; 279 280 } else { 281 $getuseremail = $wpb_user_email; 282 } 283 $usergravatar = '//www.gravatar.com/avatar/' . md5($getuseremail) . '?s=100'; 284 285 echo '<div style=""><div style="float:left;margin-bottom:30px; "><img style="border:1px solid #eaeaea; border-radius:50%" src="' . $usergravatar . '" /></div><div style="float:left; font-size:24px; font-weight:bold; margin-top: 20px; 286 margin-left: 20px;">'. $current_user->display_name; 287 echo '</div></div> '; 288 echo '<div style="clear:both"></div>'; 289 }} 44 add_submenu_page('wpcw', __('Доп. настройки', 'wpcoursewarextra'), __('Доп. настройки', 'wpcoursewarextra'), 'manage_options', 'abwpwoo', 'abwpwoo_options_page'); 45 } 46 add_action('admin_menu', 'abwpwoo_register_options_page', 11); 47 48 $ab_wpcourseware = get_option('ab_wpcourseware'); 49 function abwpwoo_options_page() { ?> 50 <div> 51 <h2><?php _e('Дополнительные настройки для плагина WP Courseware', 'wpcoursewarextra'); ?></h2> 52 <form method="post" action="options.php"> 53 <?php settings_fields('abwpwoo_options_group'); ?> 54 <div> 55 <table class="form-table"> 56 <tr valign="top"> 57 <th scope="row"><?php _e('Исключить курсы из каталога:', 'wpcoursewarextra'); ?></th> 58 <td colspan="2"> 59 <?php function abwpwoo_courses($post_type) { // post_list 60 global $ab_wpcourseware; 61 62 $items = get_posts( 63 array( 64 'post_type' => $post_type, 65 'posts_per_page' => -1 66 ) 67 ); 68 69 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 70 $a = (array) $abwpcourseware; 71 72 foreach ($items as $item) { ?> 73 <input type="checkbox" value="<?php echo $item->ID; ?>" name="ab_wpcourseware[id_courses][]" 74 id="<?php echo $item->ID; ?>" <?php echo in_array($item->ID, $a) ? 'checked' : ''; ?> /> 75 <label for="<?php echo $item->ID; ?>"><?php echo $item->post_title; ?></label><br /> 76 <?php 77 } // end foreach 78 } 79 echo abwpwoo_courses('wpcw_course'); ?> 80 </td> 81 </tr> 82 <tr valign="top"> 83 <th scope="row"><?php _e('Курс + Товар:', 'wpcoursewarextra'); ?></th> 84 <td colspan="2"> 85 <?php function abwpwoo_courses_products() { // post_list 86 global $ab_wpcourseware; 87 88 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 89 $a = (array) $abwpcourseware; 90 $abwpcoursewareb = $ab_wpcourseware['id_courses_product'] ?? ''; 91 $b = (array) $abwpcoursewareb; 92 93 $items = get_posts( 94 array( 95 'post_type' => 'wpcw_course', 96 'posts_per_page' => -1, 97 'orderby' => 'ID', 98 'order' => 'ASC', 99 ) 100 ); 101 $itemsp = get_posts( 102 array( 103 'post_type' => 'product', 104 'posts_per_page' => -1 105 ) 106 ); 107 108 foreach ($items as $item => $itm) { ?> 109 110 <tr style="<?php if (in_array($itm->ID, $a)) { ?>display:none;<?php } ?>"> 111 112 <td class="<?php echo $itm->ID; ?>"> 113 <input type="checkbox" <?php if (!in_array($itm->ID, $a)) { 114 echo 'checked'; 115 } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses][]" id="<?php echo $itm->ID; ?>" 116 style="display:none" /> 117 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 118 119 </td> 120 121 <td class="<?php echo $item; ?>"> 122 <select name="ab_wpcourseware[id_courses_product][<?php echo $item; ?>]" 123 style="<?php if (in_array($itm->ID, $a)) { ?>display:none<?php } ?>"> 124 <option value=""><?php _e('Курс бесплатный', 'wpcoursewarextra'); ?></option> 125 <?php foreach ($itemsp as $itemp => $it) { ?> 126 127 <?php if (!in_array($itm->ID, $a)) { ?> 128 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 129 echo 'selected="selected"'; 130 } ?>> 131 <?php echo $it->post_title; ?> 132 </option> 133 <?php } ?> 134 <?php } ?> 135 </select> 136 </td> 137 </tr> 138 <?php } 139 } 140 echo abwpwoo_courses_products(); ?> 141 </td> 142 </tr> 143 144 <tr valign="top"> 145 <th scope="row"><?php _e('Курс + Страницы Лендинги:', 'wpcoursewarextra'); ?></th> 146 <td colspan="2"> 147 148 <?php 149 function abwpwoo_courses_pages() { // post_list 150 global $ab_wpcourseware; 151 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 152 $a = (array) $abwpcourseware; 153 $abwpcoursewareb = $ab_wpcourseware['id_courses_pages'] ?? ''; 154 $b = (array) $abwpcoursewareb; 155 156 $items = get_posts( 157 array( 158 'post_type' => 'wpcw_course', 159 'posts_per_page' => -1, 160 'orderby' => 'ID', 161 'order' => 'ASC', 162 ) 163 ); 164 165 $itemsp = get_posts( 166 array( 167 'post_type' => 'page', 168 'posts_per_page' => -1 169 ) 170 ); 171 172 $itemsl = get_posts( 173 array( 174 'post_type' => 'e-landing-page', 175 'posts_per_page' => -1 176 ) 177 ); 178 179 foreach ($items as $item => $itm) { ?> 180 <tr style="<?php if (in_array($itm->ID, $a)) { ?>display:none;<?php } ?>"> 181 <td class="<?php echo $itm->ID; ?>"><input type="checkbox" <?php if (!in_array($itm->ID, $a)) { 182 echo 'checked'; 183 } ?> value="<?php echo $itm->ID; ?>" name="ab_wpcourseware[id_courses_courses_pages][]" 184 id="<?php echo $itm->ID; ?>" style="display:none" /> 185 <label for="<?php echo $itm->ID; ?>"><?php echo $itm->post_title; ?></label><br /> 186 187 </td> 188 <td class="<?php echo $item; ?>"> 189 190 <select name="ab_wpcourseware[id_courses_pages][<?php echo $item; ?>]" 191 style="<?php if (in_array($itm->ID, $a)) { ?>display:none<?php } ?>"> 192 <?php if (!in_array($itm->ID, $a)) { ?> 193 <option value=""><?php _e('Оставить страницу курса', 'wpcoursewarextra'); ?></option> 194 <?php } ?> 195 196 <optgroup label="Страницы"> 197 <?php foreach ($itemsp as $itemp => $it) { ?> 198 <?php if (!in_array($itm->ID, $a)) { ?> 199 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 200 echo 'selected="selected"'; 201 } ?>> 202 <?php echo $it->post_title; ?> 203 </option> 204 <?php } ?> 205 <?php } ?> 206 </optgroup> 207 <optgroup label="Лендинги Elementor"> 208 <?php foreach ($itemsl as $itemp => $it) { ?> 209 <?php if (!in_array($itm->ID, $ab_wpcourseware["id_courses"])) { ?> 210 <option value="<?php echo $it->ID; ?>" <?php if ($b[$item] == $it->ID) { 211 echo 'selected="selected"'; 212 } ?>> 213 <?php echo $it->post_title; ?> 214 </option> 215 <?php } ?> 216 <?php } ?> 217 </optgroup> 218 </select> 219 </td> 220 </tr> 221 <?php } 222 } 223 echo abwpwoo_courses_pages(); ?> 224 225 </td> 226 </tr> 227 <tr valign="top"> 228 <th scope="row"><?php _e('Расположение курсов на странице Курсы:', 'wpcoursewarextra'); ?></th> 229 <td colspan="2"> 230 231 <?php 232 function abwpwoo_courses_layout() { 233 global $ab_wpcourseware; 234 235 $abwpcourseware = $ab_wpcourseware['id_courses'] ?? ''; 236 $a = (array) $abwpcourseware; 237 $abwpcoursewareb = $ab_wpcourseware['checkbox_example'] ?? ''; 238 $b = (bool) $abwpcoursewareb; ?> 239 <input type="checkbox" id="checkbox_example" name="ab_wpcourseware[checkbox_example]" value="1" <?php if (1 == $b) 240 echo 'checked="checked"'; ?>> 241 242 <label for="checkbox_example">Отметьте галочкой, если хотите, чтобы курсы располагались 243 горизонтально </label> 244 245 <?php } 246 echo abwpwoo_courses_layout(); ?> 247 248 </td> 249 </tr> 250 251 </table> 252 </div> 253 254 <?php submit_button(); ?> 255 </form> 256 </div> 257 <?php 258 } 259 260 function abwpwoo_headline_link() { 261 } 262 263 function abwpwoo_price_wpcourseware_woocommerce() { 264 } 265 function abwpwoo_display_gravatar($atts) { 266 extract(shortcode_atts(array('wpb_user_email' => '', ), $atts)); 267 if (is_user_logged_in()) { 268 if ($wpb_user_email == '') { 269 global $current_user; 270 wp_get_current_user(); 271 $getuseremail = $current_user->user_email; 272 $getusername = $current_user->user_firstname; 273 $getuserlastname = $current_user->user_lastname; 274 } else { 275 $getuseremail = $wpb_user_email; 276 } 277 $usergravatar = '//www.gravatar.com/avatar/' . md5($getuseremail) . '?s=100'; 278 279 echo '<div style=""><div style="float:left;margin-bottom:30px; "><img style="border:1px solid #eaeaea; border-radius:50%" src="' . $usergravatar . '" /></div><div style="float:left; font-size:24px; font-weight:bold; margin-top: 20px; margin-left: 20px;">' . $current_user->display_name; 280 echo '</div></div> '; 281 echo '<div style="clear:both"></div>'; 282 } 283 } 290 284 291 285 add_shortcode('wpb_gravatar', 'abwpwoo_display_gravatar'); 292 286 293 294 add_filter( 'wpcw_ignore_active_membership_integration', '__return_true' ); 295 296 297 add_filter( 'wpcw_course_enrollment_success_message', function( $message, $course_id, $user_id ) { 298 // Do something with the message. Replace it, append to it, etc... 299 $message .= __( 'Вы успешно зачислены на курс. Выбранные вами курсы смотрите в ЛИЧНОМ КАБИНЕТЕ в разделе КУРСЫ', 'wpcoursewarextra' ); 300 return $message; 301 }, 10, 3 ); 302 303 304 function abwpwoo_content_progressBar( $percentage, $cssClass = false, $extraHTML = false ) { 305 return sprintf( ' 287 add_filter('wpcw_ignore_active_membership_integration', '__return_true'); 288 289 add_filter('wpcw_course_enrollment_success_message', function ($message, $course_id, $user_id) { 290 // Do something with the message. Replace it, append to it, etc... 291 $message .= __('Вы успешно зачислены на курс. Выбранные вами курсы смотрите в ЛИЧНОМ КАБИНЕТЕ в разделе КУРСЫ', 'wpcoursewarextra'); 292 return $message; 293 }, 10, 3); 294 295 function abwpwoo_content_progressBar($percentage, $cssClass = false, $extraHTML = false) { 296 return sprintf( 297 ' 306 298 <span class="wpcw_progress_wrap %s"> 307 299 <span class="wpcw_progress"> … … 311 303 %s 312 304 </span>', 313 $cssClass, 314 $percentage, 315 $percentage, 316 $extraHTML 317 ); 318 } 319 320 321 322 323 324 325 /** 326 * Course Enroll Shortcode. 327 * 328 * e.g. [wpcourse_enroll courses="2,3" enroll_text="Enroll Here"] 329 * 330 * @since 4.3.0 331 * 332 * @param array $atts The shortcode attributes. 333 * @param string $content The shortcode content. 334 * 335 * @return string The course enroll button string. 336 */ 337 function course_enroll_shortcode_link( $atts, $content = '' ) { 338 $shortcode_atts = shortcode_atts( array( 339 'courses' => false, 340 'enroll_text' => esc_html__( 'Enroll Now', 'wp-courseware' ), 341 'purchase_text' => esc_html__( 'Purchase', 'wp-courseware' ), 342 'installments_text' => esc_html__( 'Installments', 'wp-courseware' ), 343 'display_messages' => true, 344 'display_raw' => false, 345 'redirect' => false, 346 ), $atts, 'wpcourse_enroll' ); 347 348 // Check for courses. 349 if ( ! $shortcode_atts['courses'] && ! is_null( $shortcode_atts['courses'] ) ) { 350 return; 351 } 352 $courses_to_enroll = array(); 353 354 355 356 $courses = array(); 357 358 foreach ( $courses as $key => $course ) { 359 360 361 $courses_to_enroll[ 'course_id[0]' ] = esc_html( $shortcode_atts['courses'] ); 362 } 363 364 365 366 367 368 $courses_to_enroll[ 'course_id[0]' ] = esc_html( $shortcode_atts['courses'] ); 369 $enroll_text = esc_html( $shortcode_atts['enroll_text'] ); 370 371 $query_args = array( $courses_to_enroll, array( 'unit_redirect' => $redirect ) ); 372 $course_enrollment_url = wp_nonce_url( add_query_arg( $query_args, wp_registration_url() ), 'wpcw_enroll', '_wp_enroll' ); 373 $shortcode_html .= sprintf( __( '%s', 'wp-courseware' ), esc_url_raw( $course_enrollment_url ), esc_html( $enroll_text ) ); 374 375 376 377 378 return apply_filters( 'wpcw_course_enroll_shortcode_html', $shortcode_html ); 379 } 380 381 add_shortcode( 'wpcourse_enroll_link', 'course_enroll_shortcode_link' ); 305 $cssClass, 306 $percentage, 307 $percentage, 308 $extraHTML 309 ); 310 } 311 312 /** 313 * Course Enroll Shortcode. 314 * 315 * e.g. [wpcourse_enroll courses="2,3" enroll_text="Enroll Here"] 316 * 317 * @since 4.3.0 318 * 319 * @param array $atts The shortcode attributes. 320 * @param string $content The shortcode content. 321 * 322 * @return string The course enroll button string. 323 */ 324 function course_enroll_shortcode_link($atts, $content = '') { 325 $shortcode_atts = shortcode_atts( 326 array( 327 'courses' => false, 328 'enroll_text' => esc_html__('Enroll Now', 'wp-courseware'), 329 'purchase_text' => esc_html__('Purchase', 'wp-courseware'), 330 'installments_text' => esc_html__('Installments', 'wp-courseware'), 331 'display_messages' => true, 332 'display_raw' => false, 333 'redirect' => false, 334 ), $atts, 'wpcourse_enroll'); 335 336 // Check for courses. 337 if (!$shortcode_atts['courses'] && !is_null($shortcode_atts['courses'])) { 338 return; 339 } 340 $courses_to_enroll = array(); 341 342 $courses = array(); 343 344 foreach ($courses as $key => $course) { 345 $courses_to_enroll['course_id[0]'] = esc_html($shortcode_atts['courses']); 346 } 347 348 $courses_to_enroll['course_id[0]'] = esc_html($shortcode_atts['courses']); 349 $enroll_text = esc_html($shortcode_atts['enroll_text']); 350 351 $query_args = array($courses_to_enroll); 352 $course_enrollment_url = wp_nonce_url(add_query_arg($query_args, wp_registration_url()), 'wpcw_enroll', '_wp_enroll'); 353 $shortcode_html .= sprintf(__('%s', 'wp-courseware'), esc_url_raw($course_enrollment_url), esc_html($enroll_text)); 354 355 return apply_filters('wpcw_course_enroll_shortcode_html', $shortcode_html); 356 } 357 358 add_shortcode('wpcourse_enroll_link', 'course_enroll_shortcode_link');
Note: See TracChangeset
for help on using the changeset viewer.