Add user role as class to body
add_filter( ‘body_class’, function( $classes ) { $user = wp_get_current_user(); $roles = $user->roles; return array_merge( $classes, $roles ); } );Continue reading
Join 2,000,000+ Professionals who use WPCode to Future-Proof Their Websites!
add_filter( ‘body_class’, function( $classes ) { $user = wp_get_current_user(); $roles = $user->roles; return array_merge( $classes, $roles ); } );Continue reading
// Enable Payment on account for third parties only (using cheque method) // Set available payment methods, based on category of products in cart add_filter( ‘woocommerce_available_payment_gateways’, ‘unset_gateway_by_category’ ); function unset_gateway_by_category( $available_gateways ) { if ( is_admin() ) return $available_gateways; if…Continue reading
add_filter( ‘login_head’, function () { // Update the line below with the URL to your own logo. // Adjust the Width & Height accordingly. $custom_logo = ‘/wp-content/themes/Divi-Child/login-logo.png’; $logo_width = 250; $logo_height = 250; printf( ‘.login h1 a {background-image:url(%1$s) !important; margin:0…Continue reading
/** * Change a currency symbol */ add_filter(‘woocommerce_currency_symbol’, ‘change_existing_currency_symbol’, 10, 2); function change_existing_currency_symbol( $currency_symbol, $currency ) { switch( $currency ) { case ‘مصري’: $currency_symbol = ‘جنيه’; break; } return $currency_symbol; }Continue reading
add_filter( ‘learnpress/admin/can-load-assets/lp-admin’, ‘aioseoDontLoadLearnPress’, 10, 2 ); add_filter( ‘learnpress/admin/can-load-assets/lp-admin-notice’, ‘aioseoDontLoadLearnPress’, 10, 2 ); function aioseoDontLoadLearnPress( $canLoad, $currentPage ) { if ( false === strpos( $currentPage, ‘aioseo’ ) ) { return $canLoad; } return false; }Continue reading
add_filter( ‘aioseo_robots_meta’, ‘aioseo_filter_robots_meta’ ); function aioseo_filter_robots_meta( $attributes ) { if ( is_singular() ) { $attributes[‘noindex’] = ‘index’; $attributes[‘nofollow’] = ‘nofollow’; } return $attributes; }Continue reading
add_filter( ‘aioseo_canonical_url’, ‘aioseo_filter_canonical_url’ ); function aioseo_filter_canonical_url( $url ) { $remove_from_ids = [5, 10]; $current_id = get_the_ID(); if ( is_singular() && in_array($current_id, $remove_from_ids) ) { return ”; } return $url; }Continue reading
add_action( ‘woocommerce_after_shipping_rate’, ‘action_after_shipping_rate’, 20, 2 ); function action_after_shipping_rate ( $method, $index ) { // Targeting checkout page only: if( is_cart() ) return; // Exit on cart page if( ‘flat_rate:1’ === $method->id ) { echo __(“ Cheltuielile de livare nu sunt…Continue reading
function add_alt_text_to_images( $html ) { // Check if the image has a title attribute if ( preg_match( ‘/(title=[“\’].*?[“\’])/’, $html, $matches ) ) { // Get the title $title = substr( $matches[0], 7, -1 ); // Check if the image has…Continue reading
/** * Disable the emojis in WordPress. */ add_action( ‘init’, function () { remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 ); remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ ); remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ ); remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ ); remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ ); remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ ); remove_filter( ‘wp_mail’,…Continue reading