/** * Increment total entry number on each submission * * @link https://wpforms.com/developers/how-to-increment-a-count-on-each-form-submission */ function wpf_dev_update_total_field( $fields, $entry, $form_data ) { $my_form_id = 1000; // Form ID to track if( $form_data[ ‘id’ ] != $my_form_id ) { return $fields; }…Continue reading
function display_user_biography_in_order_page( $post ) { // دریافت ID کاربر بر اساس سفارش $order = wc_get_order( $post->ID ); $user_id = $order->get_user_id(); // دریافت بیوگرافی کاربر از پروفایل $user_bio = get_user_meta( $user_id, ‘description’, true ); // بررسی اینکه آیا بیوگرافی وجود دارد…Continue reading
// Disable WooCommerce Header in WordPress Admin add_action(‘admin_head’, ‘Hide_WooCommerce_Breadcrumb’); function Hide_WooCommerce_Breadcrumb() { echo ‘ ‘; } $current_user = wp_get_current_user(); if (!current_user_can(‘poshtiban’)) { add_filter(‘show_admin_bar’, ‘__return_false’); } else if (in_array(‘poshtiban’, $current_user->roles)) { add_action(‘admin_head’, ‘Custom_Style_For_Poshtiban’); } function Custom_Style_For_Poshtiban() { echo ‘ ‘; }…Continue reading
// افزودن متاباکس به صفحه تک سفارش ووکامرس add_action(‘add_meta_boxes’, ‘add_order_status_history_metabox’); function add_order_status_history_metabox() { add_meta_box( ‘order_status_history’, ‘چند روز / ساعت سفارش تو چه وضعیتی بوده’, ‘render_order_status_history_metabox’, ‘shop_order’, ‘normal’, // موقعیت متاباکس (normal برای پایین صفحه) ‘low’ // اولویت پایین ); }…Continue reading
function combine_css_files() { wp_enqueue_style(‘combined-styles’, get_template_directory_uri() . ‘/css/combined.min.css’, array(), null, ‘all’); // Dequeue individual files if they are now part of the combined file wp_dequeue_style(‘style-one’); wp_dequeue_style(‘style-two’); } add_action(‘wp_enqueue_scripts’, ‘combine_css_files’);Continue reading
function async_css($tag, $handle) { // Add ‘async’ to CSS file that you want to load asynchronously if (‘your-style-handle’ !== $handle) { return $tag; } return str_replace(‘ href’, ‘ async=”async” href’, $tag); } add_filter(‘style_loader_tag’, ‘async_css’, 10, 2);Continue reading
function remove_unused_css() { // Check if it’s not the homepage or not a specific post type if ( !is_front_page() && !is_page(‘your-page-slug’) ) { wp_dequeue_style(‘unused-stylesheet-handle’); wp_deregister_style(‘unused-stylesheet-handle’); } } add_action(‘wp_enqueue_scripts’, ‘remove_unused_css’);Continue reading