Page speed .htaccess code
## GZIP Compression ##
AddType application/x-javascript .js
AddType text/css .css
AddOutputFilterByType DEFLATE text/css application/x-javascript text/x-component text/html text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon application/javascript
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 env=!dont-vary
SetOutputFilter DEFLATE
SetEnvIfNoCase Request_URI \.(?:rar|zip)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:gif|jpg|png)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.(?:avi|mov|mp4)$ no-gzip dont-vary
SetEnvIfNoCase Request_URI \.mp3$ no-gzip dont-vary
## EXPIRES CACHING ##
ExpiresActive On
ExpiresByType image/jpg “access 1 year”
ExpiresByType image/jpeg “access 1 year”
ExpiresByType image/gif “access 1 year”
ExpiresByType image/png “access 1 year”
ExpiresByType text/css “access 1 month”
ExpiresByType text/html “access 1 month”
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”
## EXPIRES CACHING ##
## Vary: Accept-Encoding header ##
Header append Vary: Accept-Encoding
Use HTML tag in editor
function myextensionTinyMCE($init) {
// Command separated string of extended elements
$ext = ‘span[id|name|class|style]’;
// Add to extended_valid_elements if it alreay exists
if ( isset( $init[‘extended_valid_elements’] ) ) {
$init[‘extended_valid_elements’] .= ‘,’ . $ext;
} else {
$init[‘extended_valid_elements’] = $ext;
}
// Super important: return $init!
return $init;
}
add_filter(‘tiny_mce_before_init’, ‘myextensionTinyMCE’);
Useful link
Get meta value
https://metabox.io/docs/get-meta-value/
Newest Review first
https://wordpress.stackexchange.com/questions/133667/display-woocommerce-newest-product-reviews-on-top
Woocommerce Comment
https://www.smashingmagazine.com/2012/05/adding-custom-fields-in-wordpress-comment-form/
Ajax thumbnail rebuild
https://wordpress.org/plugins/ajax-thumbnail-rebuild/
Woocommerce widget overide
https://www.skyverge.com/blog/overriddin-woocommerce-widgets/
Woocommerce plugin variation
https://wordpress.org/plugins/color-and-image-swatches-for-variable-product-attributes/
https://codecanyon.net/item/wooswatches-woocommerce-color-or-image-variation-swatches/7444039
Thumbnail cropping function add image size
https://havecamerawilltravel.com/photographer/wordpress-thumbnail-crop
Requirement vacancy list
https://themeisle.workable.com/j/03EFACD750
AWS integration and setup
WordPress update disable
Reference link to disable update
https://www.wpoptimus.com/626/7-ways-disable-update-wordpress-notifications/
Disable all file edit from wordpress admin also hide plugin and all update navigation.
define(‘DISALLOW_FILE_MODS’,true);
/**********************Disable wordpress core update*****************************/
add_action( ‘init’, create_function( ‘$a’, “remove_action( ‘init’, ‘wp_version_check’ );” ), 2 );
add_filter( ‘pre_option_update_core’, create_function( ‘$a’, “return null;” ) );
# 2.8+:
remove_action( ‘wp_version_check’, ‘wp_version_check’ );
remove_action( ‘admin_init’, ‘_maybe_update_core’ );
add_filter( ‘pre_transient_update_core’, create_function( ‘$a’, “return null;” ) );
# 3.0+:
add_filter( ‘pre_site_transient_update_core’, create_function( ‘$a’, “return null;” ) );
/**********************Disable wordpress plugin and theme update*****************************/
add_action( ‘admin_menu’, create_function( ‘$a’, “remove_action( ‘load-plugins.php’, ‘wp_update_plugins’ );”) );
# Why use the admin_menu hook? It’s the only one available between the above hook being added and being applied
add_action( ‘admin_init’, create_function( ‘$a’, “remove_action( ‘admin_init’, ‘wp_update_plugins’ );”), 2 );
add_action( ‘init’, create_function( ‘$a’, “remove_action( ‘init’, ‘wp_update_plugins’ );”), 2 );
add_filter( ‘pre_option_update_plugins’, create_function( ‘$a’, “return null;” ) );
# 2.8 to 3.0:
remove_action( ‘load-plugins.php’, ‘wp_update_plugins’ );
remove_action( ‘load-update.php’, ‘wp_update_plugins’ );
remove_action( ‘admin_init’, ‘_maybe_update_plugins’ );
remove_action( ‘wp_update_plugins’, ‘wp_update_plugins’ );
add_filter( ‘pre_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );
# 3.0:
remove_action( ‘load-update-core.php’, ‘wp_update_plugins’ );
add_filter( ‘pre_site_transient_update_plugins’, create_function( ‘$a’, “return null;” ) );
Woocmmerce add spinner to quantity box
$(document).on(“updated_cart_totals”, function(){
$(‘.qty’).spinner({
change: function (event, ui) {
},
spin: function( event, ui ) {
$(“[name=update_cart]”).prop(“disabled”, false);
}
});
});
$(‘.qty’).spinner({
change: function (event, ui) {
},
spin: function( event, ui ) {
$(“[name=update_cart]”).prop(“disabled”, false);
}
});
Woocommerce variation js
$(document).ready(function () {
var tr_ = $(“”);
var td_ = $(“”);
$(“.main-product-detail .qty-title”).appendTo(td_);
tr_.append(td_);
$(“.main-product-detail .quantity”).appendTo(td_);
tr_.append(td_);
$(“.variations tr”).last().before(tr_);
$(“#picker_pa_style ul li”).last().before(“or”);
$(“.entry-summary .woocommerce-variation-price”).hide();
$(“.variations_form”).on(“found_variation”, function (event, variation) {
if (variation.price_html) {
$(“.entry-summary .novar”).hide();
$(“.entry-summary .woocommerce-variation-price”).hide();
$(“.entry-summary .variations-p”).show();
$(“.entry-summary .variations-p”).html(variation.price_html);
}
});
$(“.variations_form”).on(“hide_variation”, function (event) {
$(“.entry-summary .novar”).show();
$(“.entry-summary .variations-p”).hide();
});
});
Woocommerce product gallery thumbnail slider
add_action( ‘after_setup_theme’, ‘yourtheme_setup’ );
function yourtheme_setup() {
add_theme_support( ‘wc-product-gallery-zoom’ );
add_theme_support( ‘wc-product-gallery-lightbox’ );
add_theme_support( ‘wc-product-gallery-slider’ );
}
/**********************Add js to js file on header or footer*********************************/
$(window).load(function () {
setTimeout(function () {
var thubmNav = $(“.woocommerce-product-gallery .flex-control-nav”);
if (thubmNav.length) {
//console.log(“asd”, !thubmNav.closest(“.navWrapper”).length)
if (!thubmNav.closest(“.navWrapper”).length) {
thubmNav.addClass(“slides”);
thubmNav.wrap(“
“);
$(‘.navWrapper’).flexslider({
animation: “slide”,
controlNav: false,
animationLoop: true,
slideshow: false,
itemWidth: 100,
itemMargin: 24,
maxItems: 4,
minItems: 3,
});
}
}
}, 100)
});
/****************Variation product js code ****************************************/
$(“.variations_form”).on(“wc_additional_variation_images_frontend_ajax_response_callback”, function (event, variation) {
console.log(“variation”);
setTimeout(function () {
var thubmNav = $(“.woocommerce-product-gallery .flex-control-nav”);
if (thubmNav.length) {
/*if(!thubmNav.parent().hasClass(“navWrapper”)){
thubmNav.wrap(“
“);
var itemsLength_ = thubmNav.children(“li”).length
var itemWidth_ = thubmNav.children(“li”).outerWidth();
thubmNav.width( itemWidth_* itemsLength_);
thubmNav.parent().css({“width”: $(“.woocommerce-product-gallery”).width(), “overflow”:”hidden”});
var navigationDiv_ = $(“
var leftNavigation_ = $(““, {class: “leftNavigation”});
var rightNavigation_ = $(““, {class: “rightNavigation”});
navigationDiv_.append(leftNavigation_).append(rightNavigation_);
navigationDiv_.insertAfter(thubmNav);
leftNavigation_.on(“click”, function(){
});
rightNavigation_.on(“click”, function(){
});
}*/
//console.log(“asd”, !thubmNav.closest(“.navWrapper”).length)
if (!thubmNav.closest(“.navWrapper”).length) {
thubmNav.addClass(“slides”);
thubmNav.wrap(“
“);
$(‘.navWrapper’).flexslider({
animation: “slide”,
controlNav: false,
animationLoop: false,
slideshow: false,
itemWidth: 100,
itemMargin: 24,
maxItems: 4,
minItems: 3,
});
}
}
}, 100)
});
Woocommerce single product tab
Unset woocommerce product tab
add_filter( ‘woocommerce_product_tabs’, ‘woo_remove_product_tabs’, 98 );
function woo_remove_product_tabs( $tabs ) {
unset( $tabs[‘description’] ); // Remove the description tab
//unset( $tabs[‘reviews’] ); // Remove the reviews tab
unset( $tabs[‘additional_information’] ); // Remove the additional information tab
return $tabs;
}
Woocommerce category listing layout custumization
Add your custom structure and wrap div to title and image.
remove_action( ‘woocommerce_shop_loop_item_title’, ‘woocommerce_template_loop_product_title’, 10 );
remove_action( ‘woocommerce_before_shop_loop_item_title’, ‘woocommerce_template_loop_product_thumbnail’, 10 );
add_action( ‘woocommerce_before_shop_loop_item_title’, ‘sls_woocommerce_template_loop_product_thumbnail’, 10 );
function sls_woocommerce_template_loop_product_thumbnail() {
global $post;
if(is_product_category()){
get_the_title();
echo woocommerce_get_product_thumbnail();
}else{
echo woocommerce_get_product_thumbnail();
get_the_title();
}
}