Completely Disable Comments (copy)

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Completely Disable Comments (copy)

add_action(‘admin_init’, function () { // Redirect any user trying to access comments page global $pagenow; if ($pagenow === ‘edit-comments.php’) { wp_safe_redirect(admin_url()); exit; } // Remove comments metabox from dashboard remove_meta_box(‘dashboard_recent_comments’, ‘dashboard’, ‘normal’); // Disable support for comments and trackbacks in…Continue reading

Webhook custom aggiornamento stock – aggiunta dati prodotto

add_action(‘woocommerce_product_set_stock’, function($product) { do_action(‘wc_product_stock_updated’, [ ‘id’ => $product->get_id(), ‘sku’ => $product->get_sku(), ‘qty’ => $product->get_stock_quantity(), ‘status’ => $product->get_stock_status(), ]); }, 10, 1); add_action(‘woocommerce_variation_set_stock’, function($product) { do_action(‘wc_product_stock_updated’, [ ‘id’ => $product->get_id(), ‘parent_id’ => $product->get_parent_id(), ‘sku’ => $product->get_sku(), ‘qty’ => $product->get_stock_quantity(), ‘status’ =>…Continue reading

wpallimport Updated_at Last Edited

/** * WP All Import: only update a post if the feed’s updated_at is NEWER than the WP post’s modified date. * Network-activate this snippet for multisite if you run imports on subsites. */ add_filter(‘wp_all_import_is_post_to_update’, function ($continue_import, $post_id, $data, $import_id)…Continue reading

Status Count (subsite)

/** * Subsite Post Status Report (WPCode snippet ready) * * Adds a Site Admin page: Tools → Post Status Report * – Shows counts of posts by post_status for the selected post type * – Each status is a…Continue reading

Notify if Stripe is put in Test Mode

add_action(‘update_option_woocommerce_stripe_settings’, function($old_value, $value, $option) { if (!isset($old_value[‘testmode’]) || !isset($value[‘testmode’])) { return; } if ($old_value[‘testmode’] === $value[‘testmode’]) { return; } $optionName = ‘woocommerce_stripe_testmode_log’; $entry = [ ‘time’ => current_time(‘mysql’), ‘uri’ => $_SERVER[‘REQUEST_URI’] ?? ”, ‘hook’ => current_filter(), ‘old’ => $old_value[‘testmode’], ‘new’…Continue reading

Performance-Clean Head

add_action(‘init’, function () { remove_action(‘wp_head’,’print_emoji_detection_script’,7); remove_action(‘wp_print_styles’,’print_emoji_styles’); remove_action(‘wp_head’,’wp_oembed_add_discovery_links’,10); remove_action(‘wp_head’,’rest_output_link_wp_head’,10); });Continue reading