Skip to content

Instantly share code, notes, and snippets.

# https redirection
RewriteEngine On
RewriteCond %{HTTPS} !on
RewriteRule ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [R=301,L]
# www to non-www
RewriteEngine On
RewriteCond %{HTTP_HOST} ^www\.(.+)
RewriteRule ^(.*)$ https://%1%{REQUEST_URI} [R,L]
@milesleif
milesleif / consoleoff.js
Last active April 16, 2016 12:58
No debug no console
if (!window.debug){
if (!window.console) window.console = {};
var methods = ["log", "debug", "warn", "info"];
for (var i=0;i<methods.length;i++){
console[methods[i]] = function(){};
}
@milesleif
milesleif / wp-config.local.php
Last active August 29, 2015 14:23
wordpress config.php local, staging, live
<?php
/**
* The LOCAL configuration.
*
* This file has the following configurations: MySQL settings.
*
* @package WordPress
*/
// ** MySQL Einstellungen - diese Angaben bekommst du von deinem Webhoster. ** //
@milesleif
milesleif / animationFrameLoop.js
Created June 23, 2015 07:09
Queueable loop for RequestAnimationFrame
var ReqAF = function($){
var reqAnimationFrame = function(){
// Detect request animation frame
var reqAnimationFrame = window.requestAnimationFrame ||
window.webkitRequestAnimationFrame ||
window.mozRequestAnimationFrame ||
window.msRequestAnimationFrame ||
@milesleif
milesleif / stopscroll.js
Created June 23, 2015 07:04
Stop scroll-animation on user input
// prevent ugly stuttering when user starts to scroll during animation
$(window).bind("scroll mousedown DOMMouseScroll mousewheel keyup", function(e){
if ( e.which > 0 || e.type === "mousedown" || e.type === "mousewheel"){
$('html, body').stop();
}
});
@milesleif
milesleif / antispambot
Last active August 29, 2015 14:18
Encode eMails-adddresses to unicode
// used by encode_emails
// available in wp-core
function antispambot( $email_address, $hex_encoding = 0 ) {
$email_no_spam_address = '';
for ( $i = 0; $i < strlen( $email_address ); $i++ ) {
$j = rand( 0, 1 + $hex_encoding );
if ( $j == 0 ) {
$email_no_spam_address .= '&#' . ord( $email_address[$i] ) . ';';
@milesleif
milesleif / themes.php
Last active August 29, 2015 13:56
Send to wp error log (wp-content/debug.log)
if (!function_exists('write_log')) {
function write_log ( $log ) {
if ( true === WP_DEBUG ) {
if ( is_array( $log ) || is_object( $log ) ) {
error_log( print_r( $log, true ) );
} else {
error_log( $log );
}
}
}
@milesleif
milesleif / pluginname.php
Created November 7, 2013 18:44
disable update of wp-plugins
// no updates for this plugin due to its hacked version
add_filter('site_transient_update_plugins', 'dd_remove_update_nag');
function dd_remove_update_nag($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}