is_singular() ? get_queried_object_id() : null, 'is_404' => is_404(), ); if ( is_search() ) { $page['search_term'] = get_search_query( false ); $page['search_results'] = (int) $wp_query->found_posts; } $rules = array_values( array_filter( (array) get_option( 'footloom_event_rules', array() ), function ( $rule ) { return ! empty( $rule['enabled'] ); } ) ); wp_enqueue_script( 'footloom-tracker', Plugin::url( 'public/tracker.js' ), array(), Plugin::VERSION, array( 'in_footer' => true, 'strategy' => 'defer', ) ); wp_add_inline_script( 'footloom-tracker', 'window.footloomConfig = ' . wp_json_encode( array( // Relative URL so it always matches the page's own origin. 'collect' => wp_parse_url( home_url( '/' ), PHP_URL_PATH ) . '?footloom_collect=', 'page' => $page, 'rules' => $rules, ), JSON_HEX_TAG ) . ';', 'before' ); } }