PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
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
← All changes | inc/lp-webhooks.php +95 -95 4.3.94.4.8 View file →
@@ -1,95 +1,95 @@
1 -<?php
2 -/**
3 - * Common functions to process the webhooks
4 - *
5 - * @author ThimPress
6 - * @package LearnPress/Functions
7 - * @version 1.0
8 - * @deprecated 4.2.5.4 Addon learnpress-2checkout-payment v4.0.1 is using
9 - */
10 -
11 -defined( 'ABSPATH' ) || exit();
12 -
13 -/**
14 - * Register a webhook
15 - *
16 - * @param $key
17 - * @param $param
18 - */
19 -function learn_press_register_web_hook( $key, $param ) {
20 - if ( ! $key ) {
21 - return;
22 - }
23 - if ( empty( $GLOBALS['learn_press']['web_hooks'] ) ) {
24 - $GLOBALS['learn_press']['web_hooks'] = array();
25 - }
26 - $GLOBALS['learn_press']['web_hooks'][ $key ] = $param;
27 - do_action( 'learn_press_register_web_hook', $key, $param );
28 -}
29 -
30 -/**
31 - * Return all registered webhooks
32 - *
33 - * @return mixed|void
34 - */
35 -function learn_press_get_web_hooks() {
36 - $web_hooks = empty( $GLOBALS['learn_press']['web_hooks'] ) ? array() : (array) $GLOBALS['learn_press']['web_hooks'];
37 - return apply_filters( 'learn_press_web_hooks', $web_hooks );
38 -}
39 -
40 -/**
41 - * Return a registered webhook by it's name
42 - *
43 - * @param $key
44 - *
45 - * @return mixed|void
46 - */
47 -function learn_press_get_web_hook( $key ) {
48 - $web_hooks = learn_press_get_web_hooks();
49 - $web_hook = empty( $web_hooks[ $key ] ) ? false : $web_hooks[ $key ];
50 -
51 - return apply_filters( 'learn_press_web_hook', $web_hook, $key );
52 -}
53 -
54 -/**
55 - * Process all registered webhooks
56 - */
57 -function learn_press_process_web_hooks() {
58 - $web_hooks = learn_press_get_web_hooks();
59 - $web_hooks_processed = array();
60 -
61 - foreach ( $web_hooks as $key => $param ) {
62 - if ( ! empty( $_REQUEST[ $param ] ) ) {
63 - // $web_hooks_processed = true;
64 - $request_scheme = is_ssl() ? 'https://' : 'http://';
65 - $requested_web_hook_url = untrailingslashit( $request_scheme . esc_url_raw( $_SERVER['HTTP_HOST'] ) ) . esc_url_raw( $_SERVER['REQUEST_URI'] );
66 - $parsed_requested_web_hook_url = parse_url( $requested_web_hook_url );
67 - $required_web_hook_url = add_query_arg( $param, '1', trailingslashit( get_home_url() /* SITE_URL */ ) );
68 - $parsed_required_web_hook_url = parse_url( $required_web_hook_url );
69 - $web_hook_diff = array_diff_assoc( $parsed_requested_web_hook_url, $parsed_required_web_hook_url );
70 -
71 - if ( empty( $web_hook_diff ) ) {
72 - do_action( 'learn_press_web_hook_' . $param, $_REQUEST );
73 - } else {
74 -
75 - }
76 - $web_hooks_processed[ $param ] = LP_Helper::sanitize_params_submitted( $_REQUEST );
77 - break;
78 - }
79 - }
80 - if ( $web_hooks_processed ) {
81 - do_action( 'learn_press_web_hooks_processed' );
82 - ob_start();
83 - foreach ( $web_hooks_processed as $k => $v ) {
84 - echo "\n===============================================================\n<br />";
85 - printf( __( 'LearnPress webhook %s process completed', 'learnpress' ), $k );
86 - echo "\n<pre>";
87 - print_r( $v );
88 - echo "</pre>\n===============================================================\n";
89 - }
90 - $output = ob_get_clean();
91 - wp_die( $output, __( 'The LearnPress webhook process is complete', 'learnpress' ), array( 'response' => 200 ) );
92 - }
93 -}
94 -
95 -add_action( 'wp_loaded', 'learn_press_process_web_hooks', 999 );
1 +<?php
2 +/**
3 + * Common functions to process the webhooks
4 + *
5 + * @author ThimPress
6 + * @package LearnPress/Functions
7 + * @version 1.0
8 + * @deprecated 4.2.5.4 Addon learnpress-2checkout-payment v4.0.1 is using
9 + */
10 +
11 +defined( 'ABSPATH' ) || exit();
12 +
13 +/**
14 + * Register a webhook
15 + *
16 + * @param $key
17 + * @param $param
18 + */
19 +function learn_press_register_web_hook( $key, $param ) {
20 + if ( ! $key ) {
21 + return;
22 + }
23 + if ( empty( $GLOBALS['learn_press']['web_hooks'] ) ) {
24 + $GLOBALS['learn_press']['web_hooks'] = array();
25 + }
26 + $GLOBALS['learn_press']['web_hooks'][ $key ] = $param;
27 + do_action( 'learn_press_register_web_hook', $key, $param );
28 +}
29 +
30 +/**
31 + * Return all registered webhooks
32 + *
33 + * @return mixed|void
34 + */
35 +function learn_press_get_web_hooks() {
36 + $web_hooks = empty( $GLOBALS['learn_press']['web_hooks'] ) ? array() : (array) $GLOBALS['learn_press']['web_hooks'];
37 + return apply_filters( 'learn_press_web_hooks', $web_hooks );
38 +}
39 +
40 +/**
41 + * Return a registered webhook by it's name
42 + *
43 + * @param $key
44 + *
45 + * @return mixed|void
46 + */
47 +function learn_press_get_web_hook( $key ) {
48 + $web_hooks = learn_press_get_web_hooks();
49 + $web_hook = empty( $web_hooks[ $key ] ) ? false : $web_hooks[ $key ];
50 +
51 + return apply_filters( 'learn_press_web_hook', $web_hook, $key );
52 +}
53 +
54 +/**
55 + * Process all registered webhooks
56 + */
57 +function learn_press_process_web_hooks() {
58 + $web_hooks = learn_press_get_web_hooks();
59 + $web_hooks_processed = array();
60 +
61 + foreach ( $web_hooks as $key => $param ) {
62 + if ( ! empty( $_REQUEST[ $param ] ) ) {
63 + // $web_hooks_processed = true;
64 + $request_scheme = is_ssl() ? 'https://' : 'http://';
65 + $requested_web_hook_url = untrailingslashit( $request_scheme . esc_url_raw( $_SERVER['HTTP_HOST'] ) ) . esc_url_raw( $_SERVER['REQUEST_URI'] );
66 + $parsed_requested_web_hook_url = parse_url( $requested_web_hook_url );
67 + $required_web_hook_url = add_query_arg( $param, '1', trailingslashit( get_home_url() /* SITE_URL */ ) );
68 + $parsed_required_web_hook_url = parse_url( $required_web_hook_url );
69 + $web_hook_diff = array_diff_assoc( $parsed_requested_web_hook_url, $parsed_required_web_hook_url );
70 +
71 + if ( empty( $web_hook_diff ) ) {
72 + do_action( 'learn_press_web_hook_' . $param, $_REQUEST );
73 + } else {
74 +
75 + }
76 + $web_hooks_processed[ $param ] = LP_Helper::sanitize_params_submitted( $_REQUEST );
77 + break;
78 + }
79 + }
80 + if ( $web_hooks_processed ) {
81 + do_action( 'learn_press_web_hooks_processed' );
82 + ob_start();
83 + foreach ( $web_hooks_processed as $k => $v ) {
84 + echo "\n===============================================================\n<br />";
85 + printf( __( 'LearnPress webhook %s process completed', 'learnpress' ), $k );
86 + echo "\n<pre>";
87 + print_r( $v );
88 + echo "</pre>\n===============================================================\n";
89 + }
90 + $output = ob_get_clean();
91 + wp_die( $output, __( 'The LearnPress webhook process is complete', 'learnpress' ), array( 'response' => 200 ) );
92 + }
93 +}
94 +
95 +add_action( 'wp_loaded', 'learn_press_process_web_hooks', 999 );