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 / .htaccess
Last active March 28, 2019 03:58 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#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 July 1, 2022 18:12
Common 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 February 18, 2017 14:24
Hide admin bar
<?php
//* Hide admin bar
add_filter('show_admin_bar', '__return_false');
@nielslange
nielslange / functions.php
Last active February 18, 2017 14:13
Access WC variables
<?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 September 7, 2018 15:08
Web Development Checklist

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 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: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:14
Forward all WC email notifications
<?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 <[email protected]>';
$headers[] = 'Content-Type: text/html';
return $headers;
}
@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 / .htaccess
Last active March 21, 2018 19:29
Improve WordPress security
# 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])">