PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.6.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.6.9
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / inc / admin / meta-box / fields / course-permalink.php

course-permalink.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.6.9, at inc/admin/meta-box/fields/course-permalink.php

88 lines 3.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 flush_rewrite_rules();
3
4 $settings = LP_Settings::instance();
5 global $wp_post_types;
6
7 if ( ! empty( $wp_post_types[ LP_COURSE_CPT ] ) ) {
8 $course_type = $wp_post_types[ LP_COURSE_CPT ];
9 $default_courses_slug = $course_type->rewrite['slug'];
10 } else {
11 $default_courses_slug = '';
12 }
13
14 $course_permalink = $settings->get( 'course_base' );
15 $courses_page_id = learn_press_get_page_id( 'courses' );
16 $base_slug = urldecode( ( $courses_page_id > 0 && get_post( $courses_page_id ) ) ? get_page_uri( $courses_page_id ) : _x( 'courses', 'default-slug', 'learnpress' ) );
17 $course_base = _x( 'course', 'default-slug', 'learnpress' );
18
19 $structures = array(
20 0 => array(
21 'value' => '',
22 'text' => esc_html__( 'Default', 'learnpress' ),
23 'code' => home_url() . '/?lp_course=sample-course',
24 ),
25 1 => array(
26 'value' => '/' . trailingslashit( $course_base ),
27 'text' => esc_html__( 'Course', 'learnpress' ),
28 'code' => esc_html( sprintf( '%s/%s/sample-course/', home_url(), $course_base ) ),
29 ),
30 2 => array(
31 'value' => '/' . trailingslashit( $base_slug ),
32 'text' => esc_html__( 'Courses base', 'learnpress' ),
33 'code' => esc_html( sprintf( '%s/%s/sample-course/', home_url(), $base_slug ) ),
34 ),
35 3 => array(
36 'value' => '/' . trailingslashit( $base_slug ) . trailingslashit( '%course_category%' ),
37 'text' => esc_html__( 'Courses base with category', 'learnpress' ),
38 'code' => esc_html( sprintf( '%s/%s/course-category/sample-course/', home_url(), $base_slug ) ),
39 ),
40 );
41
42 $base_type = get_option( 'learn_press_course_base_type' );
43 $is_custom = ( $base_type == 'custom' && $course_permalink != '' );
44 ?>
45
46 <tr valign="top">
47 <th scope="row" class="titledesc">
48 <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo $value['title']; ?> <?php echo $tooltip_html; ?></label>
49 </th>
50 <td class="forminp forminp-<?php echo esc_attr( sanitize_title( $value['type'] ) ); ?>">&lrm;
51 <ul>
52 <?php foreach ( $structures as $k => $structure ) : ?>
53 <li class="learn-press-single-course-permalink
54 <?php
55 if ( $k == 2 || $k == 3 ) {
56 echo ' learn-press-courses-page-id';
57 echo ! $courses_page_id ? ' hide-if-js' : '';
58 }
59 ?>
60 " style="margin-bottom: 20px;">
61 <?php
62 $is_checked = ( $course_permalink == '' && $structure['value'] == '' ) || ( $structure['value'] == trailingslashit( $course_permalink ) );
63 $is_checked = checked( $is_checked, true, false );
64
65 if ( $is_custom && $is_checked ) {
66 $is_custom = false;
67 }
68 ?>
69 <label>
70 <input name="<?php echo $value['id']; ?>" type="radio" value="<?php echo esc_attr( $structure['value'] ); ?>" class="learn-press-course-base" <?php echo $is_checked; ?> />
71 <?php echo $structure['text']; ?>
72 <p><code><?php echo $structure['code']; ?></code></p>
73 </label>
74 </li>
75 <?php endforeach; ?>
76
77 <li class="learn-press-single-course-permalink custom-base">
78 <label>
79 <input name="<?php echo $value['id']; ?>" id="learn_press_custom_permalink" type="radio" value="custom" <?php checked( $is_custom, true ); ?> />
80 <?php esc_html_e( 'Custom Base', 'learnpress' ); ?>
81 <input name="course_permalink_structure" id="course_permalink_structure" readonly="<?php echo ! $is_custom ? 'readonly' : false; ?>" type="text" value="<?php echo $course_permalink ? esc_attr( trailingslashit( $course_permalink ) ) : ''; ?>" class="regular-text code"/>
82 </label>
83 <p class="description"><?php esc_html_e( 'Enter a custom base to use. A base must be set or WordPress will use default values instead.', 'learnpress' ); ?></p>
84 </li>
85 </ul>
86 </td>
87 </tr>
88