PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.9
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.9
4.4.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 All 140 releases
← All changes | inc/Ajax/AbstractAjax.php +47 -47 4.3.8 → 4.4.9 View file →
@@ -1,47 +1,47 @@
1 -<?php
2 -/**
3 - * class AjaxBase
4 - *
5 - * @since 4.2.7.6
6 - * @version 1.0.6
7 - */
8 -
9 -namespace LearnPress\Ajax;
10 -
11 -use LP_Request;
12 -
13 -/**
14 - * @use LoadContentViaAjax::load_content_via_ajax
15 - *
16 - * $action must unique name on all Ajax classes.
17 - * Because not specify a specific class.
18 - */
19 -abstract class AbstractAjax {
20 - public static function catch_lp_ajax() {
21 - if ( ! empty( $_REQUEST['lp-load-ajax'] ) ) {
22 - $action = LP_Request::get_param( 'lp-load-ajax' );
23 - $nonce = LP_Request::get_param( 'nonce' );
24 - $class = new static();
25 -
26 - if ( ! method_exists( $class, $action ) ) {
27 - return;
28 - }
29 -
30 - // For case cache HTML, so cache nonce is not required.
31 - $class_no_nonce = [
32 - LoadContentViaAjax::class,
33 - ];
34 -
35 - // Todo: should write separation check none login and none not login
36 - if ( ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
37 - if ( ! in_array( get_class( $class ), $class_no_nonce ) ) {
38 - wp_die( 'Invalid request!', 400 );
39 - }
40 - }
41 -
42 - if ( is_callable( [ $class, $action ] ) ) {
43 - call_user_func( [ $class, $action ] );
44 - }
45 - }
46 - }
47 -}
1 +<?php
2 +/**
3 + * class AjaxBase
4 + *
5 + * @since 4.2.7.6
6 + * @version 1.0.6
7 + */
8 +
9 +namespace LearnPress\Ajax;
10 +
11 +use LP_Request;
12 +
13 +/**
14 + * @use LoadContentViaAjax::load_content_via_ajax
15 + *
16 + * $action must unique name on all Ajax classes.
17 + * Because not specify a specific class.
18 + */
19 +abstract class AbstractAjax {
20 + public static function catch_lp_ajax() {
21 + if ( ! empty( $_REQUEST['lp-load-ajax'] ) ) {
22 + $action = LP_Request::get_param( 'lp-load-ajax' );
23 + $nonce = LP_Request::get_param( 'nonce' );
24 + $class = new static();
25 +
26 + if ( ! method_exists( $class, $action ) ) {
27 + return;
28 + }
29 +
30 + // For case cache HTML, so cache nonce is not required.
31 + $class_no_nonce = [
32 + LoadContentViaAjax::class,
33 + ];
34 +
35 + // Todo: should write separation check none login and none not login
36 + if ( ! wp_verify_nonce( $nonce, 'wp_rest' ) ) {
37 + if ( ! in_array( get_class( $class ), $class_no_nonce ) ) {
38 + wp_die( 'Invalid request!', 400 );
39 + }
40 + }
41 +
42 + if ( is_callable( [ $class, $action ] ) ) {
43 + call_user_func( [ $class, $action ] );
44 + }
45 + }
46 + }
47 +}