7 WordPress tricks and hacks to use on every site

Disable Woocommerce Analytics & another bloat

add_filter( 'woocommerce_admin_disabled', '__return_true' );

Bonus tip: Leverage Browser caching and enable GZIp compression

## LEVERAGE BROWSER CACHING ##
Header unset Pragma
FileETag None
Header unset ETag
## EXPIRES CACHING ##
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 month"
ExpiresByType image/jpeg "access 1 month"
ExpiresByType image/gif "access 1 month"
ExpiresByType image/png "access 1 month"
ExpiresByType text/css "access 1 week"
ExpiresByType text/html "access 0 seconds"
ExpiresByType text/xml "access 0 seconds
ExpiresByType text/json "access 0 seconds
ExpiresByType application/pdf "access 1 month"
ExpiresByType text/x-javascript "access 1 month"
ExpiresByType application/x-shockwave-flash "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
</IfModule>
## END LEVERAGE BROWSER CACHING ##

# GZIP COMPRESSION
<IfModule mod_deflate.c>
# Compress HTML, CSS, JavaScript, Text, XML and fonts
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE font/opentype
AddOutputFilterByType DEFLATE font/otf
AddOutputFilterByType DEFLATE font/ttf
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE image/x-icon
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/javascript
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
 
# Remove browser bugs (only needed for really old browsers)
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
Header append Vary User-Agent
</IfModule>
# END GZIP COMPRESSION

How to make Woocommerce checkout fields optional?

add_filter( 'woocommerce_default_address_fields' , 'optional_default_address_fields' );
 function optional_default_address_fields( $address_fields ) {
 	$address_fields['first_name']['required'] = true;	 
 	$address_fields['last_name']['required'] = true;
 	$address_fields['company']['required'] = false;
	$address_fields['address_1']['required'] = true;
	$address_fields['address_2']['required'] = false;
	$address_fields['country']['required'] = false;
 	$address_fields['postcode']['required'] = false;
 	$address_fields['city']['required'] = false;
 	$address_fields['state']['required'] = false;
 return $address_fields;
 }
// For billing email and phone fields
add_filter('woocommerce_billing_fields', 'optional_checkout_fields1', 1000, 1);
function optional_checkout_fields1( $fields ) {
    $fields['billing_email']['required'] = true;
    $fields['billing_phone']['required'] = false;
    return $fields;
}

Mobile Tabs at top of Nested Tabs

@media (max-width: 767px) {
  .e-n-tabs-mobile > .elementor-widget-container > .e-n-tabs > .e-n-tabs-heading {
   display: flex;
  flex-wrap: wrap !important;}

.elementor-widget-n-tabs .e-n-tabs-content .e-collapse.e-active {
  display: none;
}

.elementor-widget-n-tabs .e-n-tabs-content .e-collapse:not(:first-child) {
  display: none;
}

div.e-collapse:nth-child(1){display: none !important;}

#tabs-services {
    display: flex;
    
    flex-wrap: nowrap;
    overflow-x: auto;
    width: auto;
  }

  #tabs-services .tab-title {
    width: auto;
    flex: 0 0 auto;
  }
  
 .e-n-tab-title {
  flex-shrink: 0;
  max-width: 120px;
  flex-basis: auto;
}
}
<script>
jQuery(document).ready(function($) {
$('.copy-to-clipboard').on('click', function() {
var text = 'WRITETEXTHERE'; // replace with the text you want to copy
var $temp = $('<textarea>');
$('body').append($temp);
$temp.val(text).select();
document.execCommand('copy');
$temp.remove();

// Update the button text to "Copied!"
$(this).text('Copied!');

// Add the "clicked" class to the button
$(this).WRITEClass('clicked');
});
});
</script>

Table of Contents