Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Moving bits and bytes around the globe

Niels Lange nielslange

👨‍💻
Moving bits and bytes around the globe
View GitHub Profile
@nielslange
nielslange / wp-config.php
Last active Jul 18, 2016
Common wp-config.php
View wp-config.php
<?php
switch ($_SERVER['HTTP_HOST']) {
case 'dev.mydomain.com':
define('DB_NAME', '' );
define('DB_USER', '' );
define('DB_PASSWORD', '' );
define('DB_HOST', '127.0.0.1' );
define('WP_CACHE', false);
define('WP_DEBUG', true);
@nielslange
nielslange / *.php
Created Jan 24, 2017
Make page templates selectable for CPT "chiptuing" when using WP All Import
View *.php
<?php
//* Changed file: controllers/admin/import.php ************************************************************************************
//* OLD:
$hide_fields = array('_wp_page_template', '_edit_lock', '_edit_last', '_wp_trash_meta_status', '_wp_trash_meta_time');
//* NEW:
$hide_fields = array('_edit_lock', '_edit_last', '_wp_trash_meta_status', '_wp_trash_meta_time');
@nielslange
nielslange / template-chiptuning-single.php
Last active Jan 24, 2017
Create dynamic chart based on original nm and upgraded nm
View template-chiptuning-single.php
<?php
//* Load Google charts library
add_action( 'wp_enqueue_scripts', 'wp_enqueue_chiptuning_scripts' );
function wp_enqueue_chiptuning_scripts( ) {
wp_enqueue_script( 'google-charts-script', 'https://www.gstatic.com/charts/loader.js' );
}
//* Replace Genesis loop
remove_action( 'genesis_loop', 'genesis_do_loop' );
@nielslange
nielslange / functions.php
Created Jan 31, 2017
Highlight parent menu item
View functions.php
<?php
//* Highlight parent menu item
add_action('nav_menu_css_class', 'nl_nav_menu_css_class', 10, 2 );
function nl_nav_menu_css_class($classes, $item) {
global $post;
$current_post_type = get_post_type_object(get_post_type($post->ID));
$current_post_type_slug = $current_post_type->rewrite['slug'];
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
WordPress: Disable emojis
View functions.php
<?php
//* Disable the emoji's
add_action( 'init', 'nl_disable_wp_emojis' );
function nl_disable_wp_emojis() {
remove_action( 'wp_head', 'print_emoji_detection_script', 7 );
remove_action( 'admin_print_scripts', 'print_emoji_detection_script' );
remove_action( 'wp_print_styles', 'print_emoji_styles' );
remove_action( 'admin_print_styles', 'print_emoji_styles' );
remove_filter( 'the_content_feed', 'wp_staticize_emoji' );
remove_filter( 'comment_text_rss', 'wp_staticize_emoji' );
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
WordPress: Disable embed script
View functions.php
<?php
//* Disable embed script
add_action('init', 'nl_disable_wp_embed');
function nl_disable_wp_embed() {
if (!is_admin()) {
wp_deregister_script('wp-embed');
}
}
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
WordPress: Remove query strings
View functions.php
<?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];
}
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
Add page slug as id to widget title
View functions.php
<?php
//* Add page slug as id to widget title
add_filter('widget_title', 'add_slug_id_to_widget_title', 15, 3);
function add_slug_id_to_widget_title($title, $instance, $args){
$page = get_page_by_title($title);
$title = sprintf('<span id="%s">%s</span>', $page->post_name, $title);
return $title;
}
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
Access WC variables
View functions.php
<?php
//* Get global WC object
global $woocommerce;
//* Access various WooCommerce cart variables, see also https://docs.woothemes.com/wc-apidocs/class-WC_Cart.html
$woocommerce->cart->get_cart_subtotal();
$woocommerce->cart->get_cart_tax();
$woocommerce->cart->get_cart_total();
//* Access various WooCommerce customer variables, see also @see https://docs.woothemes.com/wc-apidocs/class-WC_Customer.html
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
Forward all WC email notifications
View functions.php
<?php
//* Forward all WC email notifications
add_filter( 'woocommerce_email_headers', 'nl_forward_wc_email_notifocations', 10, 2);
function nl_forward_wc_email_notifocations($headers, $object) {
$headers = array();
$headers[] = 'Bcc: Niels Lange <info@nielslange.com>';
$headers[] = 'Content-Type: text/html';
return $headers;
}
You can’t perform that action at this time.