60, 'width' => 200, 'flex-height' => true, 'flex-width' => true, 'header-text' => array( 'site-title', 'site-description' ), ) ); add_theme_support( 'woocommerce' ); add_theme_support( 'wc-product-gallery-zoom' ); add_theme_support( 'wc-product-gallery-lightbox' ); add_theme_support( 'wc-product-gallery-slider' ); add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption', 'style', 'script', ) ); add_theme_support( 'align-wide' ); add_theme_support( 'responsive-embeds' ); register_nav_menus( array( 'primary' => esc_html__( 'منوی اصلی', 'motayeb' ), 'footer' => esc_html__( 'منوی فوتر', 'motayeb' ), ) ); add_image_size( 'motayeb-product-grid', 400, 400, true ); add_image_size( 'motayeb-product-single', 600, 600, true ); } add_action( 'after_setup_theme', 'motayeb_theme_setup' ); // ============================================================ // ۲. بارگذاری فایل‌های استایل و اسکریپت (Enqueue) // ============================================================ function motayeb_scripts() { wp_enqueue_style( 'motayeb-style', get_stylesheet_uri(), array(), wp_get_theme()->get( 'Version' ) ); if ( class_exists( 'WooCommerce' ) ) { wp_enqueue_style( 'motayeb-woocommerce', get_theme_file_uri( '/assets/css/woocommerce.css' ), array( 'motayeb-style' ), wp_get_theme()->get( 'Version' ) ); } wp_enqueue_style( 'motayeb-responsive', get_theme_file_uri( '/assets/css/responsive.css' ), array( 'motayeb-style' ), wp_get_theme()->get( 'Version' ) ); wp_enqueue_script( 'motayeb-main', get_theme_file_uri( '/assets/js/main.js' ), array( 'jquery' ), wp_get_theme()->get( 'Version' ), true ); if ( class_exists( 'WooCommerce' ) ) { wp_enqueue_script( 'motayeb-woocommerce', get_theme_file_uri( '/assets/js/woocommerce.js' ), array( 'jquery', 'motayeb-main' ), wp_get_theme()->get( 'Version' ), true ); } wp_enqueue_script( 'motayeb-darkmode', get_theme_file_uri( '/assets/js/darkmode.js' ), array( 'jquery' ), wp_get_theme()->get( 'Version' ), true ); wp_localize_script( 'motayeb-main', 'motayeb_ajax', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'motayeb_nonce' ), 'checkout_url' => wc_get_checkout_url(), 'cart_url' => wc_get_cart_url(), ) ); if ( is_product() ) { wp_enqueue_script( 'wc-single-product' ); } if ( is_cart() ) { wp_enqueue_script( 'wc-cart' ); } if ( is_checkout() ) { wp_enqueue_script( 'wc-checkout' ); } } add_action( 'wp_enqueue_scripts', 'motayeb_scripts' ); // ============================================================ // ۳. ثبت ناحیه‌های ویجت (Widget Areas) // ============================================================ function motayeb_widgets_init() { register_sidebar( array( 'name' => esc_html__( 'سایدبار اصلی', 'motayeb' ), 'id' => 'sidebar-main', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); if ( class_exists( 'WooCommerce' ) ) { register_sidebar( array( 'name' => esc_html__( 'سایدبار فروشگاه', 'motayeb' ), 'id' => 'sidebar-shop', 'before_widget' => '
', 'after_widget' => '
', 'before_title' => '

', 'after_title' => '

', ) ); } for ( $i = 1; $i <= 4; $i++ ) { register_sidebar( array( 'name' => esc_html__( 'فوتر - ستون ' . $i, 'motayeb' ), 'id' => 'footer-' . $i, 'before_widget' => '', 'before_title' => '', ) ); } } add_action( 'widgets_init', 'motayeb_widgets_init' ); // ============================================================ // ۴. توابع کمکی ووکامرس // ============================================================ add_filter( 'loop_shop_columns', function() { return 4; } ); add_filter( 'loop_shop_per_page', function() { return 12; } ); function motayeb_body_classes( $classes ) { if ( class_exists( 'WooCommerce' ) ) { if ( is_product() ) { $classes[] = 'motayeb-product-page'; } if ( is_shop() ) { $classes[] = 'motayeb-shop-page'; } } if ( isset( $_COOKIE['motayeb_darkmode'] ) && 'on' === $_COOKIE['motayeb_darkmode'] ) { $classes[] = 'dark-mode'; } return $classes; } add_filter( 'body_class', 'motayeb_body_classes' ); // ============================================================ // ۵. کلاس‌های Walker برای منو // ============================================================ class Motayeb_Desktop_Walker extends Walker_Nav_Menu { public function start_lvl( &$output, $depth = 0, $args = array() ) { $output .= '