This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Stopping Cart Fragments From Updating in WooCommerce | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
add_action( 'wp_print_scripts', 'ns_cart_fragments', 100 ); | |
function ns_cart_fragments() { | |
wp_dequeue_script( 'wc-cart-fragments' ); | |
return true; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Remove Query Strings From Static Resources | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function ns_remove_script_version( $src ){ | |
$parts = explode( '?', $src ); | |
return $parts[0]; | |
} | |
add_filter( 'script_loader_src', 'ns_remove_script_version', 15, 1 ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Detect Browser : If you want to use a different stylesheet for different browsers you can use HTML conditional tags or you can use this. | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
add_filter('body_class','ns_browser_body_class'); | |
function ns_browser_body_class($classes) { | |
global $is_lynx, $is_gecko, $is_IE, $is_opera, $is_NS4, $is_safari, $is_chrome, $is_iphone; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** WordPress: Allow Contributors to Upload Images | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
if ( current_user_can('contributor') && !current_user_can('upload_files') ) | |
add_action('admin_init', 'ns_allow_contributor_uploads'); | |
function ns_allow_contributor_uploads() { | |
$contributor = get_role('contributor'); | |
$contributor->add_cap('upload_files'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** Remove Menus in WordPress Dashboard | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function ns_remove_menus () { | |
global $menu; | |
$restricted = array(__('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins')); | |
end ($menu); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Sources: | |
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites | |
# http://codex.wordpress.org/Output_Compression | |
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086 | |
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/ | |
# http://gtmetrix.com/configure-entity-tags-etags.html | |
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014 | |
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $prevPost = get_previous_post(); | |
$prevthumbnail = get_the_post_thumbnail($prevPost->ID,array(80,97)); ?> | |
<h2><?php previous_post_link('%link', 'Previous'); ?></h2> | |
<?php previous_post_link('%link', $prevthumbnail); ?> | |
<?php // Display the thumbnail of the next post ?> | |
<?php $nextPost = get_next_post(); | |
$nextthumbnail = get_the_post_thumbnail($nextPost->ID,array(80,97)); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Generate breadcrumbs | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function get_breadcrumb() { | |
echo '<a href="'.home_url().'" rel="nofollow">Home</a>'; | |
if (is_category() || is_single()) { | |
echo " » "; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h5 class="category-title"> | |
<?php | |
$terms = get_the_terms( $post->ID , 'sector' ); | |
foreach ( $terms as $term ) { | |
echo ' <a href="' .esc_url( home_url( '/' ) ). $term->slug . '" title="' . $term->name . '" ' . '>' . $term->name .'</a> '; | |
} | |
?> | |
</h5> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ensure cart contents update when products are added to the cart via AJAX | |
* | |
* https://www.nuno-sarmento.com | |
*/ | |
function my_header_add_to_cart_fragment( $fragments ) { | |
ob_start(); | |
$count = WC()->cart->cart_contents_count; |