__('Primary Navigation', 'rar-storefront'), 'footer' => __('Footer Navigation', 'rar-storefront'), ]); } add_action('after_setup_theme', 'rar_setup'); // ─── Enqueue Assets ───────────────────────────────────────────────────────── function rar_enqueue_assets() { // Google Fonts wp_enqueue_style( 'rar-fonts', 'https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,500;0,9..144,600;1,9..144,400;1,9..144,500&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400;500;600&display=swap', [], null ); // Theme stylesheet wp_enqueue_style('rar-style', get_stylesheet_uri(), ['rar-fonts'], '1.0.0'); // Theme JS wp_enqueue_script('rar-main', get_template_directory_uri() . '/js/rar.js', [], '1.0.0', true); // Pass data to JS wp_localize_script('rar-main', 'rarData', [ 'ajaxUrl' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('rar-nonce'), 'cartUrl' => wc_get_cart_url(), 'shopUrl' => get_permalink(wc_get_page_id('shop')), ]); } add_action('wp_enqueue_scripts', 'rar_enqueue_assets'); // ─── Remove default WC styles we override ─────────────────────────────────── add_filter('woocommerce_enqueue_styles', function($styles) { // Keep WooCommerce core but remove some defaults we fully override return $styles; }); // ─── Widget Areas ──────────────────────────────────────────────────────────── function rar_register_sidebars() { register_sidebar([ 'name' => 'Shop Filter Sidebar', 'id' => 'shop-filter', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ]); } add_action('widgets_init', 'rar_register_sidebars'); // ─── WooCommerce: remove default wrappers ─────────────────────────────────── remove_action('woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action('woocommerce_after_main_content', 'woocommerce_output_content_wrapper_end', 10); add_action('woocommerce_before_main_content', function() { echo '
'; }); add_action('woocommerce_after_main_content', function() { echo '
'; }); // ─── Remove WC breadcrumb (we build our own) ──────────────────────────────── remove_action('woocommerce_before_main_content', 'woocommerce_breadcrumb', 20); // ─── Product loop: 3 columns ──────────────────────────────────────────────── add_filter('loop_shop_columns', fn() => 3); add_filter('loop_shop_per_page', fn() => 12, 20); // ─── Custom product loop template ─────────────────────────────────────────── add_filter('woocommerce_product_loop_start', function($html) { return ''; }); // ─── Helper: announcement bar ─────────────────────────────────────────────── function rar_announcement_bar() { $msg = get_option('rar_announcement', 'FREE DESK-CHAIR DELIVERY ON ORDERS OVER $40 · CIRCULATE TO YOUR TEAM · DOC. REV. 04.26'); if ($msg) { echo '
' . esc_html($msg) . '
'; } } // ─── Helper: nav ──────────────────────────────────────────────────────────── function rar_nav() { $cart_count = WC()->cart ? WC()->cart->get_cart_contents_count() : 0; $cart_url = wc_get_cart_url(); $shop_url = get_permalink(wc_get_page_id('shop')); ?> '; if (function_exists('woocommerce_breadcrumb')) { woocommerce_breadcrumb(['wrap_before' => '', 'wrap_after' => '', 'before' => '', 'after' => '', 'delimiter' => ' / ']); } else { echo 'Home / '; if (is_singular()) { echo '' . get_the_title() . ''; } elseif (is_archive()) { echo '' . get_the_archive_title() . ''; } } echo ''; } // ─── Helper: section header ────────────────────────────────────────────────── function rar_section_head($form, $title, $meta = '') { echo '
'; echo '
'; echo '
' . esc_html($form) . '
'; echo '

' . esc_html($title) . '

'; echo '
'; if ($meta) { echo '
' . wp_kses_post($meta) . '
'; } echo '
'; } // ─── Add WooCommerce cart fragment support ─────────────────────────────────── add_filter('woocommerce_add_to_cart_fragments', function($fragments) { $cart_count = WC()->cart->get_cart_contents_count(); $fragments['.rar-nav__cart'] = ' Cart (' . $cart_count . ') '; return $fragments; }); // ─── Custom image sizes ────────────────────────────────────────────────────── add_image_size('rar-product-card', 600, 600, true); add_image_size('rar-blog-thumb', 800, 450, true); add_image_size('rar-hero', 900, 1125, true); // ─── Page templates ────────────────────────────────────────────────────────── add_filter('theme_page_templates', function($templates) { $templates['page-designs.php'] = 'Designs Index'; $templates['page-design-detail.php'] = 'Design Detail'; $templates['page-about.php'] = 'About'; return $templates; }); // ─── AJAX: add to cart from homepage ──────────────────────────────────────── add_action('wp_ajax_rar_add_to_cart', 'rar_ajax_add_to_cart'); add_action('wp_ajax_nopriv_rar_add_to_cart', 'rar_ajax_add_to_cart'); function rar_ajax_add_to_cart() { check_ajax_referer('rar-nonce', 'nonce'); $product_id = absint($_POST['product_id'] ?? 0); $qty = absint($_POST['qty'] ?? 1); if ($product_id) { WC()->cart->add_to_cart($product_id, $qty); wp_send_json_success(['count' => WC()->cart->get_cart_contents_count()]); } wp_send_json_error(); } // ─── Customizer settings ───────────────────────────────────────────────────── add_action('customize_register', function($wp_customize) { $wp_customize->add_section('rar_options', [ 'title' => __('Reply All Regrets Settings', 'rar-storefront'), 'priority' => 30, ]); $wp_customize->add_setting('rar_announcement', [ 'default' => 'FREE DESK-CHAIR DELIVERY ON ORDERS OVER $40 · CIRCULATE TO YOUR TEAM · DOC. REV. 04.26', 'transport' => 'refresh', ]); $wp_customize->add_control('rar_announcement', [ 'label' => __('Announcement Bar Text', 'rar-storefront'), 'section' => 'rar_options', 'type' => 'text', ]); $wp_customize->add_setting('rar_hero_tagline', [ 'default' => 'Office supplies for people who hate the office.', 'transport' => 'postMessage', ]); $wp_customize->add_control('rar_hero_tagline', [ 'label' => __('Hero Tagline', 'rar-storefront'), 'section' => 'rar_options', 'type' => 'textarea', ]); });