PluginProbe
Visualizer – Tables & Charts Manager with Built-in AI Generator / 3.11.10
Visualizer – Tables & Charts Manager with Built-in AI Generator v3.11.10
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
← All changes | vendor/codeinwp/themeisle-sdk/src/Modules/Logger.php +28 -27 3.10.103.11.10 View file →
@@ -78,15 +78,21 @@
78 78 public function setup_actions() {
79 79 if ( ! $this->is_logger_active() ) {
80 80 return;
81 81 }
82 +
83 + add_action(
84 + 'admin_enqueue_scripts',
85 + function() {
86 + if ( ! apply_filters( 'themeisle_sdk_enable_telemetry', false ) ) {
87 + return;
88 + }
82 89
83 - $can_load_telemetry = apply_filters( 'themeisle_sdk_enable_telemetry', false );
90 + $this->load_telemetry();
91 + },
92 + PHP_INT_MAX
93 + );
84 94
85 - if ( $can_load_telemetry ) {
86 - add_action( 'admin_enqueue_scripts', array( $this, 'load_telemetry' ) );
87 - }
88 -
89 95 $action_key = $this->product->get_key() . '_log_activity';
90 96 if ( ! wp_next_scheduled( $action_key ) ) {
91 97 wp_schedule_single_event( time() + ( wp_rand( 1, 24 ) * 3600 ), $action_key );
92 98 }
@@ -125,9 +131,9 @@
125 131 * @return array All notifications.
126 132 */
127 133 public function add_notification( $all_notifications ) {
128 134
129 - $message = apply_filters( $this->product->get_key() . '_logger_heading', 'Do you enjoy <b>{product}</b>? Become a contributor by opting in to our anonymous data tracking. We guarantee no sensitive data is collected.' );
135 + $message = apply_filters( $this->product->get_key() . '_logger_heading', Loader::$labels['logger']['notice'] );
130 136
131 137 $message = str_replace(
132 138 array( '{product}' ),
133 139 $this->product->get_friendly_name(),
@@ -132,10 +138,10 @@
132 138 array( '{product}' ),
133 139 $this->product->get_friendly_name(),
134 140 $message
135 141 );
136 - $button_submit = apply_filters( $this->product->get_key() . '_logger_button_submit', 'Sure, I would love to help.' );
137 - $button_cancel = apply_filters( $this->product->get_key() . '_logger_button_cancel', 'No, thanks.' );
142 + $button_submit = apply_filters( $this->product->get_key() . '_logger_button_submit', Loader::$labels['logger']['cta_y'] );
143 + $button_cancel = apply_filters( $this->product->get_key() . '_logger_button_cancel', Loader::$labels['logger']['cta_n'] );
138 144
139 145 $all_notifications[] = [
140 146 'id' => $this->product->get_key() . '_logger_flag',
141 147 'message' => $message,
@@ -187,9 +193,9 @@
187 193 }
188 194
189 195 /**
190 196 * Load telemetry.
191 - *
197 + *
192 198 * @return void
193 199 */
194 200 public function load_telemetry() {
195 201 // See which products have telemetry enabled.
@@ -197,37 +203,37 @@
197 203 $products_with_telemetry = array();
198 204 $all_products = Loader::get_products();
199 205 $all_products[ $this->product->get_slug() ] = $this->product; // Add current product to the list of products to check for telemetry.
200 206
207 + // Register telemetry params for eligible products.
201 208 foreach ( $all_products as $product_slug => $product ) {
202 -
203 - // Ignore pro products.
209 +
210 + // Ignore PRO products.
204 211 if ( false !== strstr( $product_slug, 'pro' ) ) {
205 212 continue;
206 213 }
207 214
208 - $default = 'no';
215 + $pro_slug = $product->get_pro_slug();
216 + $logger_key = $product->get_key() . '_logger_flag';
209 217
210 - if ( ! $product->is_wordpress_available() ) {
211 - $default = 'yes';
212 - } else {
213 - $pro_slug = $product->get_pro_slug();
218 + // If the product is not available in the WordPress store, or it's PRO version is installed, activate the logger if it was not initialized -- Pro users are opted in by default.
219 + if ( ! $product->is_wordpress_available() || ( ! empty( $pro_slug ) && isset( $all_products[ $pro_slug ] ) ) ) {
220 + $logger_flag = get_option( $logger_key );
214 221
215 - if ( ! empty( $pro_slug ) && isset( $all_products[ $pro_slug ] ) ) {
216 - $default = 'yes';
222 + if ( false === $logger_flag ) {
223 + update_option( $logger_key, 'yes' );
217 224 }
218 225 }
219 226
220 - if ( 'yes' === get_option( $product->get_key() . '_logger_flag', $default ) ) {
227 + if ( 'yes' === get_option( $product->get_key() . '_logger_flag', 'no' ) ) {
221 228
222 229 $main_slug = explode( '-', $product_slug );
223 230 $main_slug = $main_slug[0];
224 - $pro_slug = $product->get_pro_slug();
225 231 $track_hash = Licenser::create_license_hash( str_replace( '-', '_', ! empty( $pro_slug ) ? $pro_slug : $product_slug ) );
226 232
227 233 // Check if product was already tracked.
228 234 $active_telemetry = false;
229 - foreach ( $products_with_telemetry as &$product_with_telemetry ) {
235 + foreach ( $products_with_telemetry as $product_with_telemetry ) {
230 236 if ( $product_with_telemetry['slug'] === $main_slug ) {
231 237 $active_telemetry = true;
232 238 break;
233 239 }
@@ -235,9 +241,9 @@
235 241
236 242 if ( $active_telemetry ) {
237 243 continue;
238 244 }
239 -
245 +
240 246 $products_with_telemetry[] = array(
241 247 'slug' => $main_slug,
242 248 'trackHash' => $track_hash ? $track_hash : 'free',
243 249 'consent' => true,
@@ -250,9 +256,8 @@
250 256 if ( 0 === count( $products_with_telemetry ) ) {
251 257 return;
252 258 }
253 259
254 -
255 260 $tracking_handler = apply_filters( 'themeisle_sdk_dependency_script_handler', 'tracking' );
256 261 if ( ! empty( $tracking_handler ) ) {
257 262 do_action( 'themeisle_sdk_dependency_enqueue_script', 'tracking' );
258 263 wp_localize_script(
@@ -264,12 +269,8 @@
264 269 )
265 270 );
266 271 }
267 272 } catch ( \Exception $e ) {
268 - if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
269 - error_log( $e->getMessage() ); // phpcs:ignore
270 - }
271 - } catch ( \Error $e ) {
272 273 if ( defined( 'WP_DEBUG' ) && WP_DEBUG && defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ) {
273 274 error_log( $e->getMessage() ); // phpcs:ignore
274 275 }
275 276 } finally {