| @@ -1,42 +1,42 @@ | ||
| 1 | -<?php | |
| 2 | -namespace LearnPress\Background; | |
| 3 | - | |
| 4 | -use LP_Settings; | |
| 5 | - | |
| 6 | -defined( 'ABSPATH' ) || exit; | |
| 7 | - | |
| 8 | -/** | |
| 9 | - * Class LPBackgroundAjax | |
| 10 | - * To handle a function that can be run in background | |
| 11 | - * Via call class:method extends AbstractAjax | |
| 12 | - * $data_send: must have key 'lp-load-ajax' to call method handle | |
| 13 | - * | |
| 14 | - * @since 4.2.9.1 | |
| 15 | - * @version 1.0.1 | |
| 16 | - */ | |
| 17 | -class LPBackgroundAjax { | |
| 18 | - /** | |
| 19 | - * Method async handle | |
| 20 | - */ | |
| 21 | - public static function handle( array $data_send = [], array $args = [] ) { | |
| 22 | - $url = LP_Settings::url_handle_lp_ajax(); | |
| 23 | - $data_send = array_merge( | |
| 24 | - [ 'nonce' => wp_create_nonce( 'wp_rest' ) ], | |
| 25 | - $data_send | |
| 26 | - ); | |
| 27 | - $args = array_merge( | |
| 28 | - [ | |
| 29 | - 'timeout' => 0.01, | |
| 30 | - 'blocking' => false, | |
| 31 | - 'body' => $data_send, | |
| 32 | - 'cookies' => $_COOKIE, | |
| 33 | - 'sslverify' => is_ssl(), | |
| 34 | - 'headers' => [ | |
| 35 | - 'Referer' => $url, | |
| 36 | - ], | |
| 37 | - ], | |
| 38 | - $args | |
| 39 | - ); | |
| 40 | - wp_remote_post( $url, $args ); | |
| 41 | - } | |
| 42 | -} | |
| 1 | +<?php | |
| 2 | +namespace LearnPress\Background; | |
| 3 | + | |
| 4 | +use LP_Settings; | |
| 5 | + | |
| 6 | +defined( 'ABSPATH' ) || exit; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * Class LPBackgroundAjax | |
| 10 | + * To handle a function that can be run in background | |
| 11 | + * Via call class:method extends AbstractAjax | |
| 12 | + * $data_send: must have key 'lp-load-ajax' to call method handle | |
| 13 | + * | |
| 14 | + * @since 4.2.9.1 | |
| 15 | + * @version 1.0.1 | |
| 16 | + */ | |
| 17 | +class LPBackgroundAjax { | |
| 18 | + /** | |
| 19 | + * Method async handle | |
| 20 | + */ | |
| 21 | + public static function handle( array $data_send = [], array $args = [] ) { | |
| 22 | + $url = LP_Settings::url_handle_lp_ajax(); | |
| 23 | + $data_send = array_merge( | |
| 24 | + [ 'nonce' => wp_create_nonce( 'wp_rest' ) ], | |
| 25 | + $data_send | |
| 26 | + ); | |
| 27 | + $args = array_merge( | |
| 28 | + [ | |
| 29 | + 'timeout' => 0.01, | |
| 30 | + 'blocking' => false, | |
| 31 | + 'body' => $data_send, | |
| 32 | + 'cookies' => $_COOKIE, | |
| 33 | + 'sslverify' => is_ssl(), | |
| 34 | + 'headers' => [ | |
| 35 | + 'Referer' => $url, | |
| 36 | + ], | |
| 37 | + ], | |
| 38 | + $args | |
| 39 | + ); | |
| 40 | + wp_remote_post( $url, $args ); | |
| 41 | + } | |
| 42 | +} | |