= 2 && $variant <= 5 ) ) { // Envato-safe: only load CSS (never PHP) from uploads demo storage. $upload = wp_upload_dir(); $u_rel = 'bongoto-shop/demo/bongoto-shop/headers/topbar.css'; $u_path = trailingslashit( $upload['basedir'] ) . $u_rel; if ( file_exists( $u_path ) && filesize( $u_path ) > 0 ) { // Dashicons are used for the topbar icons. wp_enqueue_style( 'dashicons' ); wp_enqueue_style( 'bongoto-shop-topbar', trailingslashit( $upload['baseurl'] ) . $u_rel, $style_deps, (string) filemtime( $u_path ) ); } } // === JS === $js_files = array( 'assets/js/main.js', 'assets/js/header.js', ); if ( class_exists( 'WooCommerce' ) ) { $js_files[] = 'assets/js/woo-enhancements.js'; } foreach ( $js_files as $rel ) { $slug = sanitize_title( basename( $rel, '.js' ) ); // main, header, woo-enhancements $handle = 'bongoto-shop-' . $slug; $uri = get_template_directory_uri() . '/' . ltrim( $rel, '/' ); $path = get_template_directory() . '/' . ltrim( $rel, '/' ); if ( file_exists( $path ) ) { wp_enqueue_script( $handle, $uri, array( 'jquery' ), bongoto_shop_file_version( $rel ), true ); } } /** * Hook for extensions to enqueue after theme assets. */ do_action( 'bongoto_shop/after_enqueue_front' ); } add_action( 'wp_enqueue_scripts', 'bongoto_shop_enqueue_frontend_assets', 20 ); /** * Block editor styles. */ function bongoto_shop_enqueue_editor_assets() { $rel = 'assets/css/main.css'; $path = get_template_directory() . '/' . ltrim( $rel, '/' ); if ( file_exists( $path ) ) { wp_enqueue_style( 'bongoto-shop-editor-style', get_template_directory_uri() . '/' . ltrim( $rel, '/' ), array(), bongoto_shop_file_version( $rel ) ); } } add_action( 'enqueue_block_editor_assets', 'bongoto_shop_enqueue_editor_assets' ); /** * Customizer live preview script. */ function bongoto_shop_enqueue_customizer_assets() { $rel = 'assets/js/customizer.js'; $path = get_template_directory() . '/' . ltrim( $rel, '/' ); if ( file_exists( $path ) ) { wp_enqueue_script( 'bongoto-shop-customizer', get_template_directory_uri() . '/' . ltrim( $rel, '/' ), array( 'customize-preview', 'jquery' ), bongoto_shop_file_version( $rel ), true ); } } add_action( 'customize_preview_init', 'bongoto_shop_enqueue_customizer_assets' );