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 / .htaccess
Last active Mar 28, 2019 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
View .htaccess
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@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 / functions.php
Last active Feb 18, 2017
Hide admin bar
View functions.php
<?php
//* Hide admin bar
add_filter('show_admin_bar', '__return_false');
@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 / readme.md
Last active Sep 7, 2018
Web Development Checklist
View readme.md

Web Development Checklist

  • Remove obsolete content, e.g. Hello World
  • Remove obsolete plugins, e.g. Hello Dolly
  • Replace all placeholder texts, e.g. Lorem Ipsum
  • Replace all placeholder images, e.g. placeholder.png
  • Find and remove all broken links, e.g. with Broken Link Checker
  • Create 404 page
  • Create contact page
  • Create legal pages, e.g. Terms and conditions and Privacy Policy
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
Enhance WordPress customizer
View functions.php
<?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 Feb 18, 2017
Add taxonomies to post type page
View functions.php
<?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 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;
}
@nielslange
nielslange / functions.php
Last active Feb 18, 2017
Hide all login errors
View functions.php
<?php
//* Hide all login errors
add_filter( 'login_errors', 'nl_hide_login_errors' );
function nl_hide_login_errors(){
return null;
}
@nielslange
nielslange / .htaccess
Last active Mar 21, 2018
Improve WordPress security
View .htaccess
# Enable .htpasswd authentication
# <If "%{HTTP_HOST} != 'dev'">
# AuthType Basic
# AuthName "Login to dashboard"
# AuthUserFile /path/to/.htpasswd
# Require valid-user
# </If>
# Deny access to all .htaccess files
<files ~ "^.*\.([Hh][Tt][Aa])">
You can’t perform that action at this time.