Skip to content

Instantly share code, notes, and snippets.

Avatar

Catalin Badea hollyboom

  • Rumania
View GitHub Profile
@hollyboom
hollyboom / mod_rewrites
Last active Jun 21, 2018 — forked from redesigned/mod_rewrites
Helpful Mod Rewrites and .htaccess rules
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]
@hollyboom
hollyboom / gist:58647dec3e453e62f949f61907747e5d
Created Feb 11, 2018 — forked from mikejolley/gist:1622323
WooCommerce - Change default catalog sort order
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;
@hollyboom
hollyboom / countries.sql
Created Mar 29, 2017 — forked from adhipg/countries.sql
Sql dump of all the Countries, Country Codes, Phone codes.
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 ) {
You can’t perform that action at this time.