get('Version') ); // Enqueue jQuery wp_enqueue_script('jquery'); // Enqueue Quick View script wp_enqueue_script( 'blynex-quick-view', get_template_directory_uri() . '/assets/js/quick-view.js', ['jquery'], wp_get_theme()->get('Version'), true ); // Add WooCommerce AJAX URL for Quick View functionality wp_localize_script('blynex-quick-view', 'blynex_quick_view', array( 'ajaxurl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('blynex-quick-view-nonce') )); } /** * Enqueue block assets * * Registers and enqueues styles and scripts for blocks. * Handles both frontend and editor assets. */ public function enqueue_block_assets() { // Get theme version $theme_version = wp_get_theme()->get('Version'); // Load shared block styles for both frontend and editor wp_register_style( 'blynex-block-styles', get_template_directory_uri() . '/build/style-index.css', [], $theme_version ); wp_register_style( 'blynex-block-styles-rtl', get_template_directory_uri() . '/build/style-index-rtl.css', [], $theme_version ); wp_register_style( 'blynex-block-library', get_template_directory_uri() . '/build/index.css', [], $theme_version ); // wp_register_style( // 'blynex-block-library-rtl', // get_template_directory_uri() . '/build/index-rtl.css', // [], // $theme_version // ); wp_enqueue_style('blynex-block-styles'); wp_enqueue_style('blynex-block-library'); wp_enqueue_style('blynex-block-styles-rtl'); // wp_enqueue_style('blynex-block-library-rtl'); // Load frontend image filter script on frontend if (!is_admin()) { wp_register_script( 'blynex-image-filter-frontend', get_template_directory_uri() . '/assets/js/image-filter-frontend.js', array(), $theme_version, true ); wp_enqueue_script('blynex-image-filter-frontend'); return; } // Only enqueue editor-specific scripts/styles in admin if (is_admin()) { // Enqueue editor script $asset_file = get_template_directory() . '/build/index.asset.php'; if (file_exists($asset_file)) { $asset_data = require $asset_file; wp_enqueue_script( 'blynex-editor-script', get_template_directory_uri() . '/build/index.js', $asset_data['dependencies'], $asset_data['version'], true ); } // Optionally enqueue helper script wp_register_script( 'blynex-helper-script', get_template_directory_uri() . '/assets/js/helper.js', [], $theme_version, true ); wp_enqueue_script('blynex-helper-script'); } } /** * Enqueue block editor assets * * Specifically loads assets for the block editor. */ public function enqueue_block_editor_assets() { // Get theme version for cache busting $theme_version = wp_get_theme()->get('Version'); // Load editor scripts $asset_path = get_template_directory() . '/build/index.asset.php'; if (file_exists($asset_path)) { $asset_data = require $asset_path; // Register main editor script wp_register_script( 'blynex-block-editor-script', get_template_directory_uri() . '/build/index.js', $asset_data['dependencies'], $asset_data['version'], true ); // Enqueue the script wp_enqueue_script('blynex-block-editor-script'); wp_localize_script('blynex-block-editor-script', 'blynexParams', array( 'zolo_pro_status' => get_option('zolo_pro_status') ? 'active' : 'inactive', 'zoloblocks_installer' => array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('blynex_zoloblocks_nonce'), 'strings' => array( 'installing' => __('Installing ZoloBlocks plugin...', 'blynex'), 'activating' => __('Activating ZoloBlocks plugin...', 'blynex'), 'success' => __('ZoloBlocks plugin is ready!', 'blynex'), 'reloading' => __('Reloading page to initialize ZoloBlocks plugin...', 'blynex'), 'error' => __('Error: ', 'blynex'), 'permission_error' => __('You do not have permission to install plugins.', 'blynex'), 'plugin_required' => __('ZoloBlocks plugin is required to use the template library.', 'blynex'), 'plugin_not_installed' => __('ZoloBlocks plugin is not installed. Would you like to install it now?', 'blynex'), 'plugin_not_activated' => __('ZoloBlocks plugin is installed but not activated. Would you like to activate it now?', 'blynex'), 'install_activate' => __('Install & Activate', 'blynex'), 'activate' => __('Activate', 'blynex'), 'cancel' => __('Cancel', 'blynex') ) ) )); } } } // Initialize the class add_action('after_setup_theme', function () { new Blynex_Block_Assets(); }); }