snip_FetchPriority version 0

add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { // Check if the image has the class “highfetchprio” if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; }…Continue reading

snip_FetchPriority version 2

add_filter( ‘wp_get_attachment_image_attributes’, function( $attr, $attachment ) { // Check if the image has the class “highfetchprio” if ( isset( $attr[‘class’] ) && strpos( $attr[‘class’], ‘highfetchprio’ ) !== false ) { $attr[‘loading’] = ‘eager’; $attr[‘fetchpriority’] = ‘high’; $attr[‘decoding’] = ‘async’; }…Continue reading

Helper Functions (dep)

/** * WPCode Snippet: get_page_by_title Compatibility Helper * * This snippet provides a backward-compatible replacement for the deprecated * get_page_by_title() function that was removed in WordPress 6.2.0 * * To use this snippet: * 1. Go to WPCode > +…Continue reading

snip_FetchPriority

add_action(‘template_redirect’, function () { // On initialise un tableau global $GLOBALS[‘highfetchprio_preload’] = []; ob_start(function ($html) { // 1. On modifie les balises ciblées $html = preg_replace_callback( ‘#]+class=”[^”]*highfetchprio[^”]*”[^>]*)>#i’, function ($matches) { $img = $matches[0]; // Supprimer lazyload et attributs inutiles $img…Continue reading

3 Month

add_action( ‘init’, ‘export_all_completed_orders_test’ ); function export_all_completed_orders_test() { if ( isset( $_GET[‘export_customers’] ) && $_GET[‘export_customers’] === ‘1’ ) { if ( ! current_user_can( ‘manage_options’ ) ) { wp_die( ‘Access denied’ ); } header( ‘Content-Type: text/csv; charset=utf-8’ ); header( ‘Content-Disposition: attachment; filename=all_completed_orders.csv’…Continue reading

Add vendor’s details on customer’s order email

add_action(‘woocommerce_email_after_order_table’, ‘wcv_add_vendor_info_to_email’, 20, 4); function wcv_add_vendor_info_to_email($order, $sent_to_admin, $plain_text, $email) { if (!class_exists(‘WCV_Vendors’)) { return; // WC Vendors not active } // Collect vendor IDs from order items $vendor_ids = array(); foreach ($order->get_items() as $item) { $product_id = $item->get_product_id(); $vendor_id =…Continue reading