← All changes
|
vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php
+13
-15
3.10.3
→
3.4.2
View file →
| @@ -26,9 +26,9 @@ | ||
| 26 | 26 | class Logger extends Abstract_Module { |
| 27 | 27 | /** |
| 28 | 28 | * Endpoint where to collect logs. |
| 29 | 29 | */ |
| 30 | - const TRACKING_ENDPOINT = 'https://api.themeisle.com/tracking/log'; | |
| 30 | + const TRACKING_ENDPOINT = 'http://log.themeisle.com/wp-json/v1/logs/'; | |
| 31 | 31 | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * Check if we should load the module for this product. |
| @@ -77,9 +77,9 @@ | ||
| 77 | 77 | return; |
| 78 | 78 | } |
| 79 | 79 | $action_key = $this->product->get_key() . '_log_activity'; |
| 80 | 80 | if ( ! wp_next_scheduled( $action_key ) ) { |
| 81 | - wp_schedule_single_event( time() + ( wp_rand( 1, 24 ) * 3600 ), $action_key ); | |
| 81 | + wp_schedule_single_event( time() + ( rand( 1, 24 ) * 3600 ), $action_key ); | |
| 82 | 82 | } |
| 83 | 83 | add_action( $action_key, array( $this, 'send_log' ) ); |
| 84 | 84 | |
| 85 | 85 | } |
| @@ -89,24 +89,21 @@ | ||
| 89 | 89 | * |
| 90 | 90 | * @return bool Is logger active? |
| 91 | 91 | */ |
| 92 | 92 | private function is_logger_active() { |
| 93 | - $default = 'no'; | |
| 94 | - | |
| 95 | 93 | if ( ! $this->product->is_wordpress_available() ) { |
| 96 | - $default = 'yes'; | |
| 97 | - } else { | |
| 98 | - $pro_slug = $this->product->get_pro_slug(); | |
| 94 | + return true; | |
| 95 | + } | |
| 96 | + $pro_slug = $this->product->get_pro_slug(); | |
| 99 | 97 | |
| 100 | - if ( ! empty( $pro_slug ) ) { | |
| 101 | - $all_products = Loader::get_products(); | |
| 102 | - if ( isset( $all_products[ $pro_slug ] ) ) { | |
| 103 | - $default = 'yes'; | |
| 104 | - } | |
| 98 | + if ( ! empty( $pro_slug ) ) { | |
| 99 | + $all_products = Loader::get_products(); | |
| 100 | + if ( isset( $all_products[ $pro_slug ] ) ) { | |
| 101 | + return true; | |
| 105 | 102 | } |
| 106 | 103 | } |
| 107 | 104 | |
| 108 | - return ( get_option( $this->product->get_key() . '_logger_flag', $default ) === 'yes' ); | |
| 105 | + return ( get_option( $this->product->get_key() . '_logger_flag', 'no' ) === 'yes' ); | |
| 109 | 106 | } |
| 110 | 107 | |
| 111 | 108 | /** |
| 112 | 109 | * Add notification to queue. |
| @@ -153,9 +150,8 @@ | ||
| 153 | 150 | $theme = wp_get_theme(); |
| 154 | 151 | $environment['theme'] = array(); |
| 155 | 152 | $environment['theme']['name'] = $theme->get( 'Name' ); |
| 156 | 153 | $environment['theme']['author'] = $theme->get( 'Author' ); |
| 157 | - $environment['theme']['parent'] = $theme->parent() !== false ? $theme->parent()->get( 'Name' ) : $theme->get( 'Name' ); | |
| 158 | 154 | $environment['plugins'] = get_option( 'active_plugins' ); |
| 159 | 155 | global $wp_version; |
| 160 | 156 | wp_remote_post( |
| 161 | 157 | self::TRACKING_ENDPOINT, |
| @@ -162,14 +158,16 @@ | ||
| 162 | 158 | array( |
| 163 | 159 | 'method' => 'POST', |
| 164 | 160 | 'timeout' => 3, |
| 165 | 161 | 'redirection' => 5, |
| 162 | + 'headers' => array( | |
| 163 | + 'X-ThemeIsle-Event' => 'log_site', | |
| 164 | + ), | |
| 166 | 165 | 'body' => array( |
| 167 | 166 | 'site' => get_site_url(), |
| 168 | 167 | 'slug' => $this->product->get_slug(), |
| 169 | 168 | 'version' => $this->product->get_version(), |
| 170 | 169 | 'wp_version' => $wp_version, |
| 171 | - 'locale' => get_locale(), | |
| 172 | 170 | 'data' => apply_filters( $this->product->get_key() . '_logger_data', array() ), |
| 173 | 171 | 'environment' => $environment, |
| 174 | 172 | 'license' => apply_filters( $this->product->get_key() . '_license_status', '' ), |
| 175 | 173 | ), |