is_block_editor ) ) { wp_enqueue_style( 'brandy-editor-style', BRANDY_TEMPLATE_URL . '/assets/css/admin/editor.min.css', array(), BRANDY_VERSION ); $this->enqueue_libs(); } } ); } /** * Enqueue callback */ public function enqueue_scripts() { /** Enqueue styles */ wp_enqueue_script( 'wc-cart-fragments' ); wp_enqueue_script( 'brandy-frontend', BRANDY_TEMPLATE_URL . '/assets/js/frontend.min.js', array( 'jquery', 'wp-data' ), BRANDY_SCRIPT_VERSION, true ); wp_localize_script( 'brandy-frontend', 'brandyData', $this->get_localize_data() ); FrontendVite::enqueue_vite(); $this->enqueue_libs(); /* Enqueue styles */ if ( is_customize_preview() ) { wp_enqueue_style( 'brandy-customize-preview-style', BRANDY_TEMPLATE_URL . '/assets/css/frontend/customize-preview.min.css', array(), BRANDY_SCRIPT_VERSION ); } } private function enqueue_libs() { if ( $this->can_enqueue_swiper() ) { if ( ! wp_script_is( 'brandy-swiper-script' ) ) { wp_enqueue_script( 'brandy-swiper-script', BRANDY_TEMPLATE_URL . '/assets/lib/swiper/swiper.min.js', array(), BRANDY_SCRIPT_VERSION, true ); } if ( ! wp_style_is( 'brandy-swiper-style' ) && wp_script_is( 'brandy-swiper-script' ) ) { wp_enqueue_style( 'brandy-swiper-style', BRANDY_TEMPLATE_URL . '/assets/lib/swiper/swiper.min.css', array(), BRANDY_SCRIPT_VERSION ); } } } private function get_localize_data() { return array_merge( array( 'ajax' => array( 'path' => admin_url( 'admin-ajax.php' ), 'nonces' => array( 'update_cart' => wp_create_nonce( 'brandy_update_cart' ), 'send_subscribe_mail' => wp_create_nonce( 'send_subscribe_mail' ), ), ), ), is_brandy_blocks_installed() ? array( 'brandy_blocks' => array(), ) : array(), array( 'urls' => array( 'cart' => brandy_get_cart_page_url(), 'assets' => BRANDY_TEMPLATE_URL . '/assets', ), 'blocks_data' => apply_filters( 'brandy_blocks_data', array() ), ), array( 'swiper' => array( 'nextIcon' => brandy_swiper_navigation_icon( 'next' ), 'backIcon' => brandy_swiper_navigation_icon(), ), ) ); } private function can_enqueue_swiper() { $deps = array( 'brandy/wp-post-template', 'brandy/woocommerce-product-categories', 'brandy/woocommerce-product-collection', 'brandy/woocommerce-product-image-gallery', ); foreach ( $deps as $dep ) { if ( wp_script_is( $dep ) ) { return true; } } return false; } }