PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
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 / lesson / lp-lesson-functions.php

lp-lesson-functions.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.1.7.3, at inc/lesson/lp-lesson-functions.php

82 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Lession function.
4 *
5 * @author ThimPress
6 * @version 4.0.0
7 */
8
9 defined( 'ABSPATH' ) || exit();
10
11 function learn_press_lesson_comment_form_fields( $post_id ) {
12 if ( empty( $_REQUEST['content-item-only'] ) ) {
13 return;
14 }
15 ?>
16
17 <input type="hidden" name="content-item-only-redirect" value="<?php echo learn_press_get_current_url(); ?>"/>
18 <input type="hidden" name="content-item-only" value="yes"/>
19
20 <?php
21 }
22 add_action( 'comment_form', 'learn_press_lesson_comment_form_fields' );
23
24 if ( ! function_exists( 'learn_press_get_only_content_permalink' ) ) {
25 function learn_press_get_only_content_permalink( $redirect, $comment ) {
26 if ( empty( $_REQUEST['content-item-only'] ) || sanitize_text_field( $_REQUEST['content-item-only'] ) !== 'yes' ) {
27 return $redirect;
28 }
29
30 if ( empty( $_REQUEST['content-item-only-redirect'] ) ) {
31 return $redirect;
32 }
33
34 if ( get_post_type( $comment->comment_post_ID ) != 'lp_lesson' ) {
35 return $redirect;
36 }
37
38 return esc_url_raw( add_query_arg( 'content-item-only', 'yes', LP_Helper::sanitize_params_submitted( $_REQUEST['content-item-only-redirect'] ) ) );
39 }
40 }
41 add_filter( 'comment_post_redirect', 'learn_press_get_only_content_permalink', 10, 2 );
42
43 /*function learn_press_lesson_comment_form() {
44 global $post;
45
46 $course = learn_press_get_course();
47 if ( ! $course ) {
48 return;
49 }
50
51 $lesson = LP_Global::course_item();
52 if ( ! $lesson ) {
53 return;
54 }
55
56 $user = learn_press_get_current_user();
57
58 if ( $lesson->setup_postdata() ) {
59 if ( comments_open() || get_comments_number() ) {
60 add_filter( 'deprecated_file_trigger_error', '__return_false' );
61 comments_template();
62 remove_filter( 'deprecated_file_trigger_error', '__return_false' );
63 }
64
65 $lesson->reset_postdata();
66 }
67
68 }*/
69
70 /**
71 * Remove data section after remove lesson
72 */
73 function learn_press_lesson_before_delete_post( $post_id, $force = false ) {
74 global $wpdb;
75
76 if ( 'lp_lesson' === get_post_type( $post_id ) ) {
77 $sql = 'DELETE FROM `' . $wpdb->prefix . 'learnpress_section_items` WHERE `item_id` = ' . $post_id . ' AND `item_type` = "lp_lesson"';
78 $wpdb->query( $sql );
79 }
80 }
81 add_action( 'delete_post', 'learn_press_lesson_before_delete_post', 10, 2 );
82