View mod_rewrites
#### IMAGE PROTECTION #### | |
#protect images from hotlinking | |
RewriteEngine on | |
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domainname.com [NC] | |
RewriteRule \.(jpg|jpeg|png|gif|bmp|tiff|svg)$ - [NC,F,L] | |
#protect images from hotlinking send new image | |
RewriteEngine on | |
RewriteCond %{HTTP_REFERER} !^http(s)?://(www\.)?domainname.com [NC] |
View gist:58647dec3e453e62f949f61907747e5d
/** | |
* This code should be added to functions.php of your theme | |
**/ | |
add_filter('woocommerce_default_catalog_orderby', 'custom_default_catalog_orderby'); | |
function custom_default_catalog_orderby() { | |
return 'date'; // Can also use title and price | |
} | |
View Woocommerce product image alt
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2); | |
function change_attachement_image_attributes( $attr, $attachment ){ | |
// Get post parent | |
$parent = get_post_field( 'post_parent', $attachment); | |
// Get post type to check if it's product | |
$type = get_post_field( 'post_type', $parent); | |
if( $type != 'product' ){ | |
return $attr; |
View countries.sql
CREATE TABLE IF NOT EXISTS `country` ( | |
`id` int(11) NOT NULL AUTO_INCREMENT, | |
`iso` char(2) NOT NULL, | |
`name` varchar(80) NOT NULL, | |
`nicename` varchar(80) NOT NULL, | |
`iso3` char(3) DEFAULT NULL, | |
`numcode` smallint(6) DEFAULT NULL, | |
`phonecode` int(5) NOT NULL, | |
PRIMARY KEY (`id`) | |
) ENGINE=MyISAM DEFAULT CHARSET=latin1; |
View wc-advanced-fees-custom-subtotal.php
<?php | |
function custom_wcaf_fee_amount_subtotal( $subtotal ) { | |
$subtotal = 0; | |
$category_id = '61'; // Your category ID here. | |
$cart_items = WC()->cart->get_cart(); | |
foreach ( $cart_items as $key => $item ) { |
View jack-in-the-box-init.js
jQuery(function() { |