// دعم إضافي لـ Elementor function nammariq_elementor_widgets_support() { // تسجيل مناطق Elementor if (function_exists('elementor_theme_do_location')) { add_action('get_header', 'nammariq_elementor_header'); add_action('get_footer', 'nammariq_elementor_footer'); } } add_action('init', 'nammariq_elementor_widgets_support'); // دعم Elementor Header function nammariq_elementor_header() { if (function_exists('elementor_theme_do_location') && elementor_theme_do_location('header')) { remove_action('wp_head', '_wp_render_title_tag', 1); } } // دعم Elementor Footer function nammariq_elementor_footer() { if (function_exists('elementor_theme_do_location') && elementor_theme_do_location('footer')) { return; } } // إضافة دعم Elementor Canvas function nammariq_elementor_canvas_support() { if (class_exists('\Elementor\Plugin')) { add_filter('body_class', function($classes) { if (\Elementor\Plugin::$instance->preview->is_preview_mode()) { $classes[] = 'elementor-preview'; } return $classes; }); } } add_action('wp_body_open', 'nammariq_elementor_canvas_support'); // تحسين أداء Elementor function nammariq_elementor_performance() { // تحسين تحميل الخطوط add_filter('elementor/frontend/print_google_fonts', '__return_false'); // تحسين تحميل الأيقونات add_action('elementor/frontend/after_enqueue_styles', function() { wp_dequeue_style('elementor-icons-fa-solid'); wp_dequeue_style('elementor-icons-fa-regular'); wp_dequeue_style('elementor-icons-fa-brands'); }); } add_action('wp_enqueue_scripts', 'nammariq_elementor_performance', 20); // إضافة ودجت مخصص لعرض المنتجات في Elementor function nammariq_register_elementor_widgets() { if (class_exists('\Elementor\Widget_Base')) { require_once get_template_directory() . '/elementor-widgets/products-widget.php'; \Elementor\Plugin::instance()->widgets_manager->register_widget_type(new \Nammariq_Products_Widget()); } } add_action('elementor/widgets/widgets_registered', 'nammariq_register_elementor_widgets'); // إنشاء مجلد ودجات Elementor function nammariq_create_elementor_widgets_folder() { $widgets_dir = get_template_directory() . '/elementor-widgets'; if (!file_exists($widgets_dir)) { wp_mkdir_p($widgets_dir); } } add_action('after_setup_theme', 'nammariq_create_elementor_widgets_folder'); // دعم البحث السريع AJAX function nammariq_quick_search() { check_ajax_referer('nammariq_nonce', 'nonce'); $query = sanitize_text_field($_POST['query']); $search_query = new WP_Query(array( 's' => $query, 'post_type' => array('post', 'product'), 'posts_per_page' => 5, )); if ($search_query->have_posts()) { echo '