functions.php (copy)

jQuery(function($) { $(document).on(‘click’, ‘.favorite-toggle’, function(e) { e.preventDefault(); const btn = $(this); const post_id = btn.data(‘post-id’); const isFavorited = btn.attr(‘data-favorited’) === ‘1’; $.post(”, { action: ‘toggle_favorite’, post_id: post_id }, function(response) { if (response.success) { btn.text(isFavorited ? ‘♡’ : ‘❤️’).attr(‘data-favorited’, isFavorited ?…Continue reading

Disable Attachment Pages

add_action( ‘template_redirect’, function () { global $post; if ( ! is_attachment() || ! isset( $post->post_parent ) || ! is_numeric( $post->post_parent ) ) { return; } // Does the attachment have a parent post? // If the post is trashed, fallback…Continue reading

schools_rest_api 7182025

add_action(‘rest_api_init’, function() { register_rest_route(‘schools/v1’, ‘/schools’, [ ‘methods’ => WP_REST_Server::READABLE, ‘callback’ => ‘fetch_schools’, ‘permission_callback’ => ‘__return_true’, ‘args’ => [ ‘lat’ => [ ‘required’ => true, ‘validate_callback’ => function($param) { return is_numeric($param) && $param >= -90 && $param function($param) { return floatval($param);…Continue reading

all important 3

add_action(‘admin_menu’, ‘custom_order_status_checker_menu’); function custom_order_status_checker_menu() { add_menu_page( ‘بررسی وضعیت گروهی سفارش‌ها’, // عنوان صفحه ‘بررسی وضعیت گروهی’, // عنوان منو در پیشخوان ‘manage_woocommerce’, // سطح دسترسی ‘check-orders-status’, // slug منو ‘custom_order_status_checker_page’, // تابع نمایش محتوا ‘dashicons-search’, // آیکون منو 56 //…Continue reading

log

// افزودن متا باکس به صفحه سفارش function add_order_view_log_meta_box() { add_meta_box( ‘order_view_log’, // ID متا باکس __(‘لاگ بازدید سفارش’, ‘woocommerce’), // عنوان متا باکس ‘render_order_view_log_meta_box’, // تابع نمایش محتوا ‘shop_order’, // نوع پست (صفحه سفارش) ‘normal’, // موقعیت متا باکس…Continue reading

ajax search

function wc_admin_custom_search_system() { // ایجاد صفحه “سرچ سوپر فست” در وردپرس add_action(‘admin_menu’, function () { add_menu_page( ‘سرچ سوپر فست’, // عنوان صفحه ‘سرچ سوپر فست’, // عنوان منو ‘edit_shop_orders’, // قابلیت مورد نیاز (فقط ادمین‌هایی که می‌توانند سفارشات را ویرایش…Continue reading