LLMS_Events::should_track_client_events()
Determine if client side events from the current page should be tracked.
Return Return
(boolean)
Source Source
File: includes/class-llms-events.php
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 | protected function should_track_client_events() { $ret = false; /** * Filter the post types that should be tracked * * @since 3.36.0 * @since 3.36.1 Remove redundant check on `is_singular()` and `is_post_type_archive()`. * * @param string[]|string $post_types An array of post type names or a pre-defined setting as a string. * "llms" uses all public LifterLMS and LifterLMS Add-on post types. * "all" tracks everything. */ $post_types = apply_filters( 'llms_tracking_post_types' , 'llms' ); if ( 'all' === $post_types ) { $ret = true; } elseif ( 'llms' === $post_types ) { // Filter public post types to include LifterLMS public post types. $post_types = array_keys ( get_post_types( array ( 'public' => true ) ) ); foreach ( $post_types as $key => $type ) { if ( ! in_array( $type , array ( 'course' , 'lesson' ), true ) && 0 !== strpos ( $type , 'llms_' ) ) { unset( $post_types [ $key ] ); } } } if ( ! is_array ( $post_types ) ) { $ret = false; } elseif ( is_singular( $post_types ) ) { $ret = true; } elseif ( is_post_type_archive( $post_types ) ) { $ret = true; } elseif ( is_llms_account_page() || is_llms_checkout() ) { $ret = true; } /** * Filters whether or not the current page should track client-side events * * @since 3.36.0 * * @param bool $ret Whether or not to track the current page. * @param string[] $post_types Array of post types that should be tracked. */ return apply_filters( 'llms_tracking_should_track_client_events' , $ret , $post_types ); } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.36.0 | Introduced. |