Skip to content

Instantly share code, notes, and snippets.

View nielslange's full-sized avatar
👨‍💻
Moving bits and bytes around the globe

Niels Lange nielslange

👨‍💻
Moving bits and bytes around the globe
View GitHub Profile
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:18
Add link shortcode to widget title
<?php
//* Add link shortcode to widget title
//* Usage: [link href = https://www.google.com]Google[link]
add_filter( 'widget_title', 'link_widget_title' );
function link_widget_title( $title ) {
$title = str_replace( '[link', '<a', $title );
$title = str_replace( '[/link]', '</a>', $title );
$title = str_replace( ']', '>', $title );
return $title;
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:19
Trim length of featured post title
<?php
//* Trim length of featured post title
add_filter( 'genesis_featured_post_title', 'smntcs_genesis_featured_post_title' );
function smntcs_genesis_featured_post_title( $title ) {
return mb_strimwidth($title, 0, 65, '...');
}
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:20
Hide all login errors
<?php
//* Hide all login errors
add_filter( 'login_errors', 'nl_hide_login_errors' );
function nl_hide_login_errors(){
return null;
}
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:22
Add taxonomies to post type page
<?php
//* Add taxomonies to page
add_action( 'init', 'nl_add_taxonomies_to_pages' );
function nl_add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:23
Enhance WordPress customizer
<?php
//* Enhance customizer
add_action( 'customize_register', 'nl_enhance_customizer' );
function nl_enhance_customizer( $wp_customize ) {
$wp_customize->add_section(
'footer_section',
array(
'title' => __('Title of the settings box', 'theme_name'),
'description' => __('Description of the settings box'),
'priority' => 150,
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:24
Hide admin bar
<?php
//* Hide admin bar
add_filter('show_admin_bar', '__return_false');
@nielslange
nielslange / functions.php
Created February 19, 2017 05:28
WooCommerce: Add a basic surcharge to all transactions
<?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() {
@nielslange
nielslange / functions.php
Created February 19, 2017 05:34
WooCommerce: Change breadcrumb home text
<?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;
}
@nielslange
nielslange / functions.php
Created February 19, 2017 05:42
WooCommerce: Change the breadcrumb separator
<?php
//* Change the breadcrumb separator from '/' to '»'
add_filter( 'woocommerce_breadcrumb_defaults', 'nl_change_breadcrumb_delimiter' );
function nl_change_breadcrumb_delimiter( $defaults ) {
$defaults['delimiter'] = ' &raquo; ';
return $defaults;
}
@nielslange
nielslange / .gitignore
Last active February 20, 2017 07:29
WordPress .gitignore
# Ignore everything in the root except the "wp-content" directory, the config
# fies and the meta files.
/*
.*
~*
!wp-content/
!.gitignore
!.htaccess
!.htpasswd
!README.md