/i', '', $html ); // // فرمت 2:
/i', '', $html ); // // فرمت 3: هر link که rel="canonical" داره (با فاصلههای مختلف) // $html = preg_replace( '/ ]*rel\s*=\s*["\']canonical["\'][^>]*>/i', '', $html ); // // فرمت 4: با single quote // $html = preg_replace( "/ ]*rel\s*=\s*'canonical'[^>]*>/i", '', $html ); // return $html; // } ); // }, 1 ); // Enqueue child theme style.css add_action( 'wp_enqueue_scripts', function() { wp_enqueue_style( 'child-style', get_stylesheet_uri() ); if ( is_rtl() ) { wp_enqueue_style( 'mylisting-rtl', get_template_directory_uri() . '/rtl.css', [], wp_get_theme()->get('Version') ); } }, 500 ); add_filter('woocommerce_loop_add_to_cart_link', 'custom_whatsapp_button_on_loop', 10, 2); // global $post; // $listing = MyListing\Src\Listing::get( $post ); function custom_whatsapp_button_on_loop($button, $product) { // $phone = '989123456789'; // $layout = $listing->type->get_layout(); // $phone = get_post_meta(get_the_ID(), 'job_phone', true); // $listing_id = get_post_meta(get_the_ID(), '_job_id', true); // این متا ممکنه بسته به سایتت متفاوت باشه // $phone = get_post_meta($listing_id, 'job_phone', true); // $job_id = get_the_ID(); if( $product->get_id() !='18287' && $product->get_id() !='18283' && $product->get_id() !='18288'){ global $wpdb; $product_id = $product->get_id(); // کوئری برای پیدا کردن آگهیای که این محصول در متای _select_products اون هست $listing_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_select_products' AND meta_value LIKE %s LIMIT 1", '%' . $wpdb->esc_like('i:' . $product_id . ';') . '%' )); if (!$listing_id) { $phone = '+971501007045'; $store_name = 'استپ این وی Stepinway'; $store_url = 'https://stepinway.com/listing/%d8%a7%d8%b3%d8%aa%d9%be-%d8%a7%db%8c%d9%86-%d9%88%db%8c-stepinway/'; }else{ // گرفتن شماره تلفن از متای آگهی $phone = str_replace(' ', '', get_post_meta($listing_id, '_job_phone', true)); $store_name = get_the_title( $listing_id ); $store_url = get_permalink( $listing_id ); } // echo '';
// print_r($store_name);
// die();
$product_name = $product->get_name();
$text = urlencode("سلام، من علاقهمند به خرید محصول: $product_name هستم.");
$whatsapp_url = "https://wa.me/$phone?text=$text";
// ساخت دکمه واتساپ
$button = '
سفارش در واتساپ
'.$store_name.'
';
}
return $button;
}
// add_filter( 'woocommerce_get_image_size_thumbnail', 'custom_product_thumbnail_size' );
// function custom_product_thumbnail_size( $size ) {
// if ( is_product() || is_shop() || is_product_category() ) {
// global $product;
// if ( in_array( $product->get_id(), [18287, 18288, 18283] ) ) {
// // ID محصولاتی که میخوای تغییر کنن
// return array(
// 'width' => 607, // عرض جدید
// 'height' => 1080, // ارتفاع جدید
// 'crop' => 1 // کراپ شدن
// );
// }
// }
// return $size;
// }
// حذف دکمه افزودن به سبد خرید
remove_action('woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30);
// قرار دادن دکمه واتساپ به جای اون
add_action('woocommerce_single_product_summary', 'custom_whatsapp_button_on_single_product', 30);
function custom_whatsapp_button_on_single_product() {
global $post, $wpdb;
$product_id = $post->ID;
// پیدا کردن آگهیای که این محصول در _select_products اون وجود داره
$listing_id = $wpdb->get_var( $wpdb->prepare(
"SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = '_select_products'
AND meta_value LIKE %s
LIMIT 1",
'%' . $wpdb->esc_like('i:' . $product_id . ';') . '%'
));
if (!$listing_id) {
$phone = '+971501007045';
}else{
// گرفتن شماره تلفن از متای آگهی
$phone = str_replace(' ', '', get_post_meta($listing_id, '_job_phone', true));
}
$product_title = get_the_title($product_id);
// لینک واتساپ
$text = urlencode("سلام، من علاقهمند به خرید محصول: $product_title هستم.");
$whatsapp_link = "https://wa.me/$phone?text=$text";
// نمایش دکمه واتساپ
echo '
';
}
add_filter( 'woocommerce_output_related_products_args', 'custom_related_products_args', 20 );
function custom_related_products_args( $args ) {
$args['columns'] = 4; // تعداد ستونها (مثلاً ۴ ستون در یک ردیف)
return $args;
}
add_action( 'wp_enqueue_scripts', 'override_single_listing_js', 100 );
function override_single_listing_js() {
// حذف فایل اصلی
wp_dequeue_script( 'mylisting-single-listing' );
wp_deregister_script( 'mylisting-single-listing' );
// افزودن فایل جدید از قالب فرزند
wp_enqueue_script(
'mylisting-single-listing',
get_stylesheet_directory_uri() . '/assets/dist/single-listing.js', // مسیر فایل ویرایششده
array('jquery'),
'1.0',
true
);
}
add_action('init', function () {
if (isset($_GET['action']) && $_GET['action'] === 'register' && strpos($_SERVER['REQUEST_URI'], 'wp-login.php') !== false) {
wp_die('Registration via default form is disabled.', 'Access Denied', ['response' => 403]);
}
});
// شورتکد نمایش یک برگه
// [term_page id="14949" show="content|title|excerpt" image="no|yes"]
add_shortcode('term_page', function($atts){
$a = shortcode_atts([
'id' => '',
'show' => 'content', // content | title | excerpt
'image' => 'no', // yes | no
], $atts, 'term_page');
$id = intval($a['id']);
if (!$id) return '';
$post = get_post($id);
if (!$post || $post->post_status !== 'publish') return '';
$out = '';
switch ($a['show']) {
case 'title':
$out = esc_html(get_the_title($post));
break;
case 'excerpt':
$excerpt = has_excerpt($post) ? $post->post_excerpt : wp_trim_words( wp_strip_all_tags($post->post_content), 40 );
$out = esc_html($excerpt);
break;
default: // content
$out = apply_filters('the_content', $post->post_content);
}
if (strtolower($a['image']) === 'yes') {
$thumb = get_the_post_thumbnail($post, 'large', ['loading' => 'lazy']);
if ($thumb) $out = $thumb . $out;
}
return ''.$out.'
';
});
// تغییر سایز عکس محصولات برای ID های خاص در ویجت ووکامرس
add_filter('woocommerce_product_get_image_size', 'custom_product_image_size_by_id', 10, 2);
function custom_product_image_size_by_id($size, $product = null) {
if (!$product) {
return $size;
}
$product_id = is_numeric($product) ? $product : $product->get_id();
// سه ID خاص که میخواهید سایز متفاوت داشته باشند
$special_ids = [18287, 18288, 18283];
if (in_array($product_id, $special_ids)) {
// برگرداندن آرایه با عرض و ارتفاع دلخواه [عرض، ارتفاع]
return [500, 300];
}
return $size;
}
// ===== پردازش شورتکد داخل توضیحات دستهها (مخصوص MyListing) =====
add_filter('get_term', function($term){
if ( ! is_admin() && isset($term->taxonomy) && in_array($term->taxonomy, ['job_listing_category','listing_category']) ) {
// اول شورتکدها رو اجرا کن
$term->description = do_shortcode($term->description);
// بعد پاراگراف بندی وردپرس رو اعمال کن
$term->description = wpautop($term->description);
}
return $term;
});
// // ⭐ اجرای شورتکد داخل توضیحات دستهای که Explore/Ajax برمیگردونه
// add_filter('mylisting/explore/taxonomy-term-data', function($term){
// if ( isset($term['description']) && strpos($term['description'], '[term_page') !== false ) {
// $desc = do_shortcode($term['description']);
// $desc = wpautop($desc);
// $term['description'] = $desc;
// }
// return $term;
// });
/**
* شورتکد نمایش یک برگه در توضیحات دستهبندی MyListing
* استفاده: [term_page id="123" show="content|title|excerpt" image="no|yes" inner_shortcodes="no|yes"]
*/
// تعریف شورتکد
add_shortcode('term_page', function($atts){
$a = shortcode_atts([
'id' => '',
'show' => 'content', // content | title | excerpt
'image' => 'no', // yes | no
'inner_shortcodes'=> 'no', // اگر yes شود شورتکدهای داخل محتوای برگه هم اجرا میشوند
], $atts, 'term_page');
$id = intval($a['id']);
if (!$id) return '';
$post = get_post($id);
if (!$post || $post->post_status !== 'publish') return '';
$out = '';
switch ($a['show']) {
case 'title':
$out = esc_html(get_the_title($post));
break;
case 'excerpt':
$excerpt = has_excerpt($post)
? $post->post_excerpt
: wp_trim_words( wp_strip_all_tags($post->post_content), 40 );
$out = esc_html($excerpt);
break;
default: // content
if ( strtolower($a['inner_shortcodes']) === 'yes' ) {
$out = apply_filters('the_content', $post->post_content);
} else {
$content = strip_shortcodes( $post->post_content );
if ( function_exists('do_blocks') ) {
$content = do_blocks( $content );
}
$out = wpautop( $content );
}
}
if (strtolower($a['image']) === 'yes') {
$thumb = get_the_post_thumbnail($post, 'large', ['loading' => 'lazy']);
if ($thumb) {
$out = $thumb . $out;
}
}
return ''.$out.'
';
});
/**
* ⭐ پردازش شورتکد داخل توضیحات دستهها (برای Explore/Ajax)
* MyListing وقتی Explore رو با Ajax لود میکنه، description خام رو میفرسته
* این هوک مطمئن میشه [term_page ...] قبل از رسیدن به Vue پردازش بشه
*/
add_action('mylisting_ajax_explore_terms', function( $results = null ){
if ( empty($results['taxonomies']) ) return;
foreach ( $results['taxonomies'] as &$tax ) {
if ( ! empty($tax['terms']) ) {
foreach ( $tax['terms'] as &$term ) {
if ( isset($term['description']) && strpos($term['description'], '[term_page') !== false ) {
$term['description'] = wpautop( do_shortcode( $term['description'] ) );
}
}
}
}
return $results;
}, 20 );
// add_action('woocommerce_process_product_meta', 'save_product_to_selected_listings');
// function save_product_to_selected_listings($product_id) {
// if ( isset($_POST['related_listings']) && is_array($_POST['related_listings']) ) {
// foreach ( $_POST['related_listings'] as $listing_id ) {
// $listing_id = intval($listing_id);
// // گرفتن مقادیر فعلی
// $existing = get_post_meta($listing_id, '_select_products', true);
// if ( !is_array($existing) ) {
// $existing = array();
// }
// // اگر محصول هنوز اضافه نشده
// if ( !in_array($product_id, $existing) ) {
// $existing[] = $product_id;
// }
// // ذخیره نهایی
// update_post_meta($listing_id, '_select_products', $existing);
// }
// }
// }
// // === Helper: رندر تمپلیت المنتور با ID
// function ml_render_elementor_template( $template_id ) {
// if ( class_exists('\Elementor\Plugin') && $template_id ) {
// return \Elementor\Plugin::instance()->frontend->get_builder_content_for_display( (int) $template_id );
// }
// return '';
// }
// // === شورتکد: [ml_dynamic_footer]
// // فقط محتوای مرتبط با تب/دسته فعلی را سرور-ساید تولید میکند.
// add_shortcode('ml_dynamic_footer', function($atts){
// $atts = shortcode_atts([
// 'default' => '', // آیدی تمپلیت پیشفرض (اختیاری)
// ], $atts, 'ml_dynamic_footer');
// // 1) پیکربندی تبها (type => Elementor Template ID)
// // اینجا آیدی تمپلیتهای المنتوری که برای هر تب ساختهای را بگذار:
// $type_map = [
// // 'slug-of-type' => TEMPLATE_ID,
// // 'add-services-form' => 1234,
// 'medical' => 14949,
// // 'restaurant' => 3456,
// ];
// // 2) خواندن type از URL
// $qs = $_GET;
// $type = isset($qs['type']) ? sanitize_key($qs['type']) : '';
// // اگر type ست باشد و در map باشد، همان را برگردان
// if ( $type && isset($type_map[$type]) ) {
// $html = ml_render_elementor_template( $type_map[$type] );
// if ( $html ) return $html;
// }
// // 3) اگر type نبود/مطابقت نداشت، از دسته استفاده کن (job_listing_category)
// $taxonomy = 'job_listing_category';
// $term = null;
// // سازگاری با حالتهای مختلف پارامتر:
// foreach ($qs as $key => $val) {
// if (strpos($key, 'tax-'.$taxonomy) === 0) {
// $selected = is_array($val) ? reset($val) : $val;
// if (is_numeric($selected)) { $term = get_term((int)$selected, $taxonomy); }
// else { $term = get_term_by('slug', sanitize_title($selected), $taxonomy); }
// break;
// }
// }
// if (!$term && isset($qs['search_category'])) {
// $selected = $qs['search_category'];
// if (is_numeric($selected)) { $term = get_term((int)$selected, $taxonomy); }
// else { $term = get_term_by('slug', sanitize_title($selected), $taxonomy); }
// }
// if ($term && !is_wp_error($term)) {
// // اول Template ID ترم، بعد HTML ترم، بعد توضیح ترم
// $tpl_id = get_term_meta($term->term_id, 'footer_template_id', true);
// $custom = get_term_meta($term->term_id, 'footer_custom_html', true);
// if ($tpl_id) {
// $html = ml_render_elementor_template( (int)$tpl_id );
// if ($html) return $html;
// }
// if ($custom) return do_shortcode( wp_kses_post($custom) );
// $desc = term_description($term->term_id, $taxonomy);
// if ($desc) return wpautop($desc);
// }
// // 4) پیشفرض (اگر آیدی تمپلیت دادی)
// if ( $atts['default'] ) {
// $html = ml_render_elementor_template( (int)$atts['default'] );
// if ($html) return $html;
// }
// return ''; // چیزی نشان نده
// });
// // === AJAX: برگرداندن خروجی همین شورتکد بر اساس query فعلی
// add_action('wp_ajax_ml_footer', 'ml_ajax_footer');
// add_action('wp_ajax_nopriv_ml_footer', 'ml_ajax_footer');
// function ml_ajax_footer(){
// // اجازه بده کل querystring را بدهیم توی پارامتر q
// if ( isset($_GET['q']) ) {
// parse_str( wp_unslash($_GET['q']), $new_qs );
// // موقتاً روی $_GET سِت میکنیم تا شورتکد همان منطق را اجرا کند
// $backup = $_GET;
// $_GET = $new_qs;
// $out = do_shortcode('[ml_dynamic_footer]');
// $_GET = $backup;
// } else {
// $out = do_shortcode('[ml_dynamic_footer]');
// }
// wp_send_json_success([ 'html' => $out ]);
// }
// // ajaxurl + nonce برای همه صفحات (بدون نیاز به فایل JS جدا)
// add_action('wp_enqueue_scripts', function () {
// // یک اسکریپت خالی رجیستر/enqueue میکنیم تا بتونیم localize کنیم
// wp_register_script('ml-dyn-footer-dummy', false);
// wp_enqueue_script('ml-dyn-footer-dummy');
// wp_localize_script('ml-dyn-footer-dummy', 'ML', [
// 'ajaxurl' => admin_url('admin-ajax.php'),
// 'nonce' => wp_create_nonce('ml_footer_nonce'),
// ]);
// });
/**
* AJAX: برگرداندن meta به نام 'more-desc' برای یک ترم
*/
// add_action('wp_ajax_siw_get_term_more_desc', 'siw_get_term_more_desc');
// add_action('wp_ajax_nopriv_siw_get_term_more_desc', 'siw_get_term_more_desc');
// function siw_get_term_more_desc() {
// // nonce باید با چیزی که در regular.php میسازیم یکی باشد
// check_ajax_referer('c27_ajax_nonce', 'security');
// $tax = isset($_POST['tax']) ? sanitize_key($_POST['tax']) : 'job_listing_category';
// $id = isset($_POST['term_id']) ? absint($_POST['term_id']) : 0;
// $slug = isset($_POST['slug']) ? sanitize_title($_POST['slug']) : '';
// if ($id) {
// $term = get_term($id, $tax);
// } elseif ($slug) {
// $term = get_term_by('slug', $slug, $tax);
// } else {
// $term = null;
// }
// if (!$term || is_wp_error($term)) {
// wp_send_json_success([
// 'found' => false,
// 'html' => '',
// 'title' => '',
// ]);
// }
// $html = (string) get_term_meta($term->term_id, 'more-desc', true);
// wp_send_json_success([
// 'found' => !empty($html),
// 'html' => $html,
// 'title' => $term->name,
// 'term' => [
// 'id' => $term->term_id,
// 'slug' => $term->slug,
// 'tax' => $term->taxonomy,
// ],
// ]);
// }
// /**
// * (اختیاری برای دیباگ 403) پینگ سادهی AJAX
// */
// add_action('wp_ajax_siw_ping', 'siw_ping');
// add_action('wp_ajax_nopriv_siw_ping', 'siw_ping');
// function siw_ping(){
// // check_ajax_referer('c27_ajax_nonce','security'); // برای تست 403 موقتاً خاموش
// wp_send_json_success(['ok'=>true,'who'=>(is_user_logged_in()?'user':'guest')]);
// }
// سشن لاگین طولانی فقط برای کاربران غیرمدیریتی
add_filter( 'auth_cookie_expiration', function( $seconds, $user_id, $remember ) {
// // برای مدیرها/ادیتورها مقدار پیشفرض هسته را نگه دار
// if ( user_can( $user_id, 'manage_options' ) || user_can( $user_id, 'edit_others_posts' ) ) {
// return $seconds;
// }
// اگر Remember me نخورد، مثلاً 30 روز؛ اگر خورد، یک سال
if ( $remember ) {
return YEAR_IN_SECONDS; // ~365 روز
} else {
return 30 * DAY_IN_SECONDS; // 30 روز
}
}, 10, 3 );
// /wp-json/siw/v1/term-desc?slug=car-rental&tax=job_listing_category
add_action('rest_api_init', function () {
register_rest_route('siw/v1', '/term-desc', [
'methods' => 'GET',
'callback' => function (\WP_REST_Request $req) {
$slug = sanitize_title($req->get_param('slug'));
$tax = sanitize_key($req->get_param('tax'));
if (!$slug) {
return new WP_REST_Response(['ok'=>false,'msg'=>'missing slug'], 400);
}
// اول تلاش با tax دریافتی، اگر نبود fallback
$tryTax = $tax ?: 'job_listing_category';
$term = get_term_by('slug', $slug, $tryTax);
if (!$term || is_wp_error($term)) {
$term = get_term_by('slug', $slug, 'category');
}
if (!$term || is_wp_error($term)) {
return new WP_REST_Response(['ok'=>false,'msg'=>'term not found'], 404);
}
$val = get_term_meta($term->term_id, 'more-desc', true);
// اجرای شورتکدها قبل از برگرداندن
if (!empty($val)) {
$val = do_shortcode($val);
$val = wpautop($val); // اضافه کردن پاراگرافها
}
return new WP_REST_Response([
'ok' => true,
'term_id' => (int) $term->term_id,
'tax' => $term->taxonomy,
'slug' => $term->slug,
'html' => $val, // حذف wp_kses_post چون شورتکدها ممکنه HTML خاص تولید کنن
], 200);
},
'permission_callback' => '__return_true', // داده عمومی است
]);
});
// AJAX handler for saving user name
add_action('wp_ajax_save_user_name', 'handle_save_user_name');
add_action('wp_ajax_nopriv_save_user_name', 'handle_save_user_name');
function handle_save_user_name() {
// Check nonce
if (!wp_verify_nonce($_POST['nonce'], 'save_user_name_nonce')) {
wp_send_json_error('Invalid nonce');
return;
}
// Check if user is logged in
if (!is_user_logged_in()) {
wp_send_json_error('User not logged in');
return;
}
$user_id = get_current_user_id();
$first_name = sanitize_text_field($_POST['first_name']);
$last_name = sanitize_text_field($_POST['last_name']);
$phone_number = sanitize_text_field($_POST['phone_number']);
if (empty($first_name) || empty($last_name) || empty($phone_number)) {
wp_send_json_error('نام، نام خانوادگی و شماره تلفن الزامی است');
return;
}
// Basic phone validation - just check length and basic format
$phone_clean = preg_replace('/[^0-9+\-\s\(\)]/', '', $phone_number);
if (strlen($phone_clean) < 7 || strlen($phone_clean) > 25) {
wp_send_json_error('شماره تلفن معتبر نیست');
return;
}
// Update user meta
$result1 = update_user_meta($user_id, 'first_name', $first_name);
$result2 = update_user_meta($user_id, 'last_name', $last_name);
$result3 = update_user_meta($user_id, 'Phone', $phone_clean);
// Also update the user object fields
wp_update_user(array(
'ID' => $user_id,
'user_firstname' => $first_name,
'user_lastname' => $last_name
));
// Check if at least one field was updated successfully
if ($result1 !== false || $result2 !== false || $result3 !== false) {
wp_send_json_success('اطلاعات با موفقیت ذخیره شد');
} else {
// Debug information
$debug_info = array(
'first_name_result' => $result1,
'last_name_result' => $result2,
'phone_result' => $result3,
'user_id' => $user_id
);
wp_send_json_error('خطا در ذخیره اطلاعات: ' . json_encode($debug_info));
}
}
/**
* تغییر لینک ریست پسورد در ایمیل به آدرس دلخواه /my-account/lost-password/
*/
add_filter('retrieve_password_message', function( $message, $key, $user_login, $user_data = null ) {
// پیدا کردن آیدی کاربر (اگر خواستی id رو ارسال کنی)
$user = get_user_by('login', $user_login);
$user_id = $user ? $user->ID : '';
// لینک سفارشی (میتواند هر اسلاگی باشد — اینجا my-account/lost-password)
$reset_link = home_url( '/my-account/lost-password/' ) . '?key=' . rawurlencode($key)
. '&id=' . rawurlencode($user_id)
. '&login=' . rawurlencode($user_login);
// متن ایمیل (متن ساده؛ میتوانی HTML هم بگذاری)
$new = "سلام {$user_login}\n\n";
$new .= "برای تغییر رمز حساب خود از لینک زیر استفاده کنید (اعتبار لینک محدود است):\n\n";
$new .= $reset_link . "\n\n";
$new .= "اگر این درخواست از طرف شما نیست، این ایمیل را نادیده بگیرید.\n\n";
return $new;
}, 10, 4);
// Load MyListing API Controller
require_once get_stylesheet_directory() . '/includes/controllers/mylisting-api-controller.php';
// Load QR Scanner Controller
require_once get_stylesheet_directory() . '/includes/controllers/qr-scanner-controller.php';
// Load QR Transactions Controller
require_once get_stylesheet_directory() . '/includes/controllers/qr-transactions-controller.php';
// Add QR Transaction Modal to footer
add_action( 'wp_footer', 'add_qr_transaction_modal' );
function add_qr_transaction_modal() {
if ( is_user_logged_in() ) {
$modal_file = get_stylesheet_directory() . '/partials/qr-transaction-modal.php';
if ( file_exists( $modal_file ) ) {
include $modal_file;
}
}
}
// Add QR Scanner and Transactions to WooCommerce My Account menu
add_filter('woocommerce_account_menu_items', 'add_qr_scanner_menu_item');
function add_qr_scanner_menu_item($items) {
// Insert QR Scanner and Transactions before logout
$logout = $items['customer-logout'];
unset($items['customer-logout']);
$items['qr-scanner'] = __('اسکنر QR کد', 'my-listing-child');
$items['transactions'] = __('تراکنشها', 'my-listing-child');
$items['customer-logout'] = $logout;
return $items;
}
// Handle QR Scanner and Transactions endpoints
add_action('init', 'add_qr_scanner_endpoint');
function add_qr_scanner_endpoint() {
add_rewrite_endpoint('qr-scanner', EP_ROOT | EP_PAGES);
add_rewrite_endpoint('transactions', EP_ROOT | EP_PAGES);
}
// Flush rewrite rules on activation
add_action('init', 'flush_qr_scanner_rewrite_rules');
function flush_qr_scanner_rewrite_rules() {
if (get_option('qr_scanner_flush_rewrite_rules_flag')) {
flush_rewrite_rules();
delete_option('qr_scanner_flush_rewrite_rules_flag');
}
}
// Add QR Scanner content
add_action('woocommerce_account_qr-scanner_endpoint', 'qr_scanner_content');
function qr_scanner_content() {
// Check if user is logged in
if (!is_user_logged_in()) {
wp_redirect(wp_login_url(get_permalink()));
exit;
}
// Load QR Scanner template
$template_path = get_stylesheet_directory() . '/templates/dashboard/qr-scanner.php';
if (file_exists($template_path)) {
include $template_path;
} else {
echo 'صفحه QR Scanner در حال آمادهسازی است.
';
}
}
// Add Transactions content
add_action('woocommerce_account_transactions_endpoint', 'transactions_content');
function transactions_content() {
// Check if user is logged in
if (!is_user_logged_in()) {
wp_redirect(wp_login_url(get_permalink()));
exit;
}
// Load Transactions template
$template_path = get_stylesheet_directory() . '/templates/dashboard/transactions.php';
if (file_exists($template_path)) {
include $template_path;
} else {
echo 'صفحه تراکنشها در حال آمادهسازی است.
';
}
}
// Flush rewrite rules on theme activation
add_action('after_switch_theme', 'qr_scanner_flush_rewrite_rules_on_activate');
function qr_scanner_flush_rewrite_rules_on_activate() {
add_qr_scanner_endpoint();
flush_rewrite_rules();
}
// Load Admin Transactions Page
if ( is_admin() ) {
require_once get_stylesheet_directory() . '/includes/src/admin-transactions.php';
}
/**
* استفاده از lat/lng بجای آدرس متنی برای لینک "Get Directions"
* این مشکل آدرسهای ناقص رو حل میکنه
*/
add_filter('mylisting/get-directions/use-latlng-query', '__return_true');
/**
* اطمینان از لود شدن المنتور assets در صفحه Explore
* برای اینکه accordion و widgets دیگه به درستی کار کنن
*/
add_action('wp_enqueue_scripts', function() {
// فقط در صفحه explore
if (!is_page_template('templates/explore.php') && !is_archive()) {
return;
}
// لود المنتور frontend styles و scripts
if (did_action('elementor/loaded')) {
\Elementor\Plugin::$instance->frontend->enqueue_styles();
\Elementor\Plugin::$instance->frontend->enqueue_scripts();
// لود widget styles (accordion, tabs, etc)
if (class_exists('\Elementor\Plugin')) {
wp_enqueue_style('elementor-frontend');
wp_enqueue_script('elementor-frontend');
// Widget-specific styles
wp_enqueue_style('elementor-post-2'); // global styles
// برای accordion
wp_enqueue_style('elementor-icons-fa-solid');
wp_enqueue_style('elementor-icons-fa-regular');
}
}
// لود فیکس CSS برای المنتور widgets
wp_enqueue_style(
'elementor-ajax-fix',
get_stylesheet_directory_uri() . '/assets/dist/elementor-fix.css',
[],
'1.0.0'
);
// لود فیکس JavaScript برای المنتور widgets
wp_enqueue_script(
'elementor-fallback',
get_stylesheet_directory_uri() . '/assets/dist/elementor-fallback.js',
['jquery'],
'1.0.0',
true
);
}, 999);
/**
* اضافه کردن محصول به سبد خرید، حذف بقیه و رفتن به checkout
* استفاده: ?add_to_cart_and_checkout=123
*/
add_action('template_redirect', 'add_to_cart_and_checkout_direct');
function add_to_cart_and_checkout_direct() {
if (isset($_GET['add_to_cart_and_checkout'])) {
$product_id = absint($_GET['add_to_cart_and_checkout']);
if ($product_id > 0) {
// پاک کردن کل سبد خرید
WC()->cart->empty_cart();
// اضافه کردن محصول جدید
$quantity = isset($_GET['quantity']) ? absint($_GET['quantity']) : 1;
WC()->cart->add_to_cart($product_id, $quantity);
// ریدایرکت به checkout
wp_safe_redirect(wc_get_checkout_url());
exit;
}
}
}
/**
* AJAX handler برای اضافه کردن به سبد و رفتن به checkout
*/
add_action('wp_ajax_add_to_cart_and_checkout', 'ajax_add_to_cart_and_checkout');
add_action('wp_ajax_nopriv_add_to_cart_and_checkout', 'ajax_add_to_cart_and_checkout');
function ajax_add_to_cart_and_checkout() {
check_ajax_referer('cart_checkout_nonce', 'nonce');
$product_id = isset($_POST['product_id']) ? absint($_POST['product_id']) : 0;
$quantity = isset($_POST['quantity']) ? absint($_POST['quantity']) : 1;
if ($product_id <= 0) {
wp_send_json_error(['message' => 'شناسه محصول نامعتبر است']);
return;
}
// پاک کردن کل سبد خرید
WC()->cart->empty_cart();
// اضافه کردن محصول
$added = WC()->cart->add_to_cart($product_id, $quantity);
if ($added) {
wp_send_json_success([
'message' => 'محصول به سبد خرید اضافه شد',
'checkout_url' => wc_get_checkout_url()
]);
} else {
wp_send_json_error(['message' => 'خطا در اضافه کردن محصول']);
}
}
/**
* افزودن اسکریپت و استایل Buy Now
*/
add_action('wp_enqueue_scripts', 'enqueue_buy_now_assets');
function enqueue_buy_now_assets() {
if (is_product() || is_shop() || is_product_category() || is_archive()) {
// افزودن CSS
wp_enqueue_style(
'buy-now-style',
get_stylesheet_directory_uri() . '/assets/dist/buy-now.css',
[],
'1.0.0'
);
// افزودن JavaScript
wp_enqueue_script(
'buy-now-script',
get_stylesheet_directory_uri() . '/assets/dist/buy-now.js',
['jquery'],
'1.0.0',
true
);
// افزودن دادههای JavaScript
wp_localize_script('buy-now-script', 'cart_checkout_data', [
'nonce' => wp_create_nonce('cart_checkout_nonce'),
'ajax_url' => admin_url('admin-ajax.php')
]);
}
}
نمایشگاه علمی و تجاری دندانپزشکی AEEDC Dubai - Step in way
نمایشگاه علمی و تجاری دندانپزشکی AEEDC Dubai
تاریخ ایونت
2026/01/19 - 2026/01/21
این رویداد ترکیبی است از کنفرانس علمی + نمایشگاه تجاری تجهیزات و فناوریهای دندانپزشکی.
شرکتکنندگان شامل دندانپزشکان، تکنسینهای دندان، دانشجویان، تولیدکنندگان تجهیزات، تأمینکنندگان مواد دندانپزشکی و فعالان صنعت بهداشت دهان هستند.
📅 زمان، مکان و آمار
دوره ۲۰۲۶: تاریخ برگزاری ۱۹ تا ۲۱ ژانویه ۲۰۲۶ در مرکز تجارت جهانی دبی (DWTC)
در دورههای اخیر، AEEDC میزبان هزاران برند بینالمللی، دهها هزار بازدیدکننده از صدها کشور است.
در دوره ۲۰۲۵، موضوع اصلی «هدایت دنیای دندان به سمت آینده» بوده و تأکید ویژه بر فناوری دیجیتال در دندانپزشکی شده است. Dental Tribune USA
🔍 آنچه در نمایشگاه انتظار میرود
معرفی فناوریهای نو مانند دندانپزشکی دیجیتال (Digital Dentistry)، سیستمهای CAD/CAM، تصویربرداری پیشرفته، لیزرها و تجهیزات هوشمند.
ارائه جلسات علمی، سخنرانیها و کارگاههای تخصصی با شرکت اساتید بینالمللی و امکان کسب امتیازهای آموزشی (CME) برای شرکتکنندگان.
فرصت شبکهسازی گسترده بین تولیدکنندگان، توزیعکنندگان، کلینیکها و فعالان صنعت دندانپزشکی.
بازدید از غرفههای تجهیزات دندانپزشکی، مواد مصرفی، دستگاهها و نوآوریهای حوزه دهان و دندان.
// $html = preg_replace( '/
افزودن دیدگاه