Improve WordPress security (.htaccess)
# Enable .htpasswd authentication
<If "%{HTTP_HOST} != 'dev'">
AuthType Basic
AuthName "Login to dashboard"
<?php | |
//* Remove query strings | |
add_filter( 'script_loader_src', 'nl_remove_query_strings', 15, 1 ); | |
add_filter( 'style_loader_src', 'nl_remove_query_strings', 15, 1 ); | |
function nl_remove_query_strings( $src ){ | |
$parts = explode( '?ver', $src ); | |
return $parts[0]; | |
} |
Add a surcharge to cart and checkout – uses fees API
Customize the WooCommerce breadcrumb
<?php | |
/** | |
* Add a 1% surcharge to your cart / checkout | |
* change the $percentage to set the surcharge to a value to suit | |
* Uses the WooCommerce fees API | |
* | |
* Add to theme functions.php | |
*/ | |
add_action( 'woocommerce_cart_calculate_fees','woocommerce_custom_surcharge' ); | |
function woocommerce_custom_surcharge() { |
<?php | |
/** | |
* Add a 1% surcharge to your cart / checkout based on delivery country | |
* Taxes, shipping costs and order subtotal are all included in the surcharge amount | |
* | |
* Change $percentage to set the surcharge to a value to suit | |
* | |
* Add countries to array('US'); to include more countries to surcharge | |
* http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes for available alpha-2 country codes | |
* |
<?php | |
//* Change breadcrumb home text | |
add_filter( 'woocommerce_breadcrumb_defaults', 'nl_change_breadcrumb_home_text' ); | |
function nl_change_breadcrumb_home_text( $defaults ) { | |
$defaults['home'] = 'Start'; | |
return $defaults; | |
} |
<?php | |
//* Change the breadcrumb separator from '/' to '»' | |
add_filter( 'woocommerce_breadcrumb_defaults', 'nl_change_breadcrumb_delimiter' ); | |
function nl_change_breadcrumb_delimiter( $defaults ) { | |
$defaults['delimiter'] = ' » '; | |
return $defaults; | |
} |
<?php | |
/** | |
* Keep links in Excerpts | |
* | |
* @package WordPress | |
* @subpackage BeTheme Child | |
* @since BeTheme Child 1.0 | |
*/ | |
remove_filter('get_the_excerpt', 'wp_trim_excerpt'); | |
add_filter('get_the_excerpt', 'nl_wp_trim_excerpt'); |
<?php | |
//* Exclude CPT for search results | |
add_filter('pre_get_posts', 'nl_exclude_cpt_from_search'); | |
function nl_exclude_cpt_from_search($query) { | |
if (!$query->is_admin && $query->is_search) { | |
$query->set('post_type', array('post', 'page', 'cpt-slug-to-include')); | |
} | |
return $query; | |
} |