PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 2.1.0
Visualizer – Tables & Charts Manager with Built-in AI Generator v2.1.0
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.10.0 3.10.1 3.10.10 3.10.11 3.10.12 3.10.13 3.10.14 3.10.15 3.10.2 3.10.3 All 149 releases
visualizer / vendor / codeinwp / themeisle-sdk / class-themeisle-sdk-logger.php

class-themeisle-sdk-logger.php in Visualizer – Tables & Charts Manager with Built-in AI Generator 2.1.0, at vendor/codeinwp/themeisle-sdk/class-themeisle-sdk-logger.php

81 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * The main loader class for ThemeIsle SDK
4 *
5 * @package ThemeIsleSDK
6 * @subpackage Logger
7 * @copyright Copyright (c) 2017, Marius Cristea
8 * @license http://opensource.org/licenses/gpl-3.0.php GNU Public License
9 * @since 1.0.0
10 */
11 if ( ! class_exists( 'ThemeIsle_SDK_Logger' ) ) :
12 /**
13 * Class ThemeIsle_SDK_Logger
14 *
15 * Send the statistics to the Themeisle Endpoint
16 */
17 /**
18 * Class ThemeIsle_SDK_Logger
19 */
20 class ThemeIsle_SDK_Logger {
21
22 /**
23 * @var string $logging_url Url where to send the logs
24 */
25 private $logging_url = 'http://mirror.themeisle.com';
26
27 /**
28 * @var ThemeIsle_SDK_Product $product Themeisle Product.
29 */
30 private $product;
31
32 /**
33 * @var string $product_cron Cron name handler
34 */
35 private $product_cron;
36
37 /**
38 * ThemeIsle_SDK_Logger constructor.
39 *
40 * @param ThemeIsle_SDK_Product $product_object Product Object.
41 */
42 public function __construct( $product_object ) {
43 if ( $product_object instanceof ThemeIsle_SDK_Product ) {
44 $this->product = $product_object;
45 $this->product_cron = $product_object->get_key() . '_log_activity';
46 }
47 }
48
49
50 /**
51 * Start the cron to send the log. It will randomize the interval in order to not send all the logs at the same time.
52 */
53 public function enable() {
54 if ( ! wp_next_scheduled( $this->product_cron ) ) {
55 wp_schedule_single_event( time() + ( rand( 15, 24 ) * 3600 ), $this->product_cron );
56 }
57 add_action( $this->product_cron, array( $this, 'send_log' ) );
58 }
59
60 /**
61 * Send the statistics to the api endpoint
62 */
63 public function send_log() {
64 wp_remote_post( $this->logging_url, array(
65 'method' => 'POST',
66 'timeout' => 3,
67 'redirection' => 5,
68 'headers' => array(
69 'X-ThemeIsle-Event' => 'log_site',
70 ),
71 'body' => array(
72 'site' => get_site_url(),
73 'product' => $this->product->get_slug(),
74 'version' => $this->product->get_version(),
75 ),
76 ) );
77 }
78
79 }
80 endif;
81