admin_url( 'admin-ajax.php' ), 'action' => 'srpp_track', 'nonce' => wp_create_nonce( 'srpp_track' ), 'enabled' => (int) srpp_get_option( 'analytics_enabled', 1 ), ) ); } /** * Work out ahead of output which Displays will run, so their CSS can go in * the head rather than the footer. */ public function preload() { if ( is_admin() || is_feed() ) { return; } $post_id = is_singular() ? get_queried_object_id() : 0; foreach ( SRPP_Display::active() as $display ) { $placement = $display->opt( 'placement' ); $is_woo = SRPP_Woo::is_woo_placement( $placement ); if ( ! $is_woo && ! SRPP_Placement::is_content_placement( $placement ) ) { continue; } if ( ! $is_woo && ! $post_id ) { continue; } $context = $is_woo ? 'shop' : 'singular'; if ( ! SRPP_Conditions::passes( $display, $post_id, $context ) ) { continue; } self::mark_used( $display->opt( 'layout' ), $display->opt( 'template' ) ); } } /** * Flag the assets a rendered block needs. * * @param string $layout Layout key. * @param string $template Template ID. */ public static function mark_used( $layout, $template ) { if ( ! self::$base && srpp_get_option( 'load_base_css', 1 ) ) { self::$base = true; wp_enqueue_style( 'srpp' ); } if ( srpp_get_option( 'analytics_enabled', 1 ) ) { wp_enqueue_script( 'srpp-analytics' ); } if ( ! self::$carousel && ( 'carousel' === $layout || 'tpl-12' === $template ) ) { self::$carousel = true; wp_enqueue_script( 'srpp-carousel' ); } } }