Skip to content

Instantly share code, notes, and snippets.

View cobbman's full-sized avatar
🏠
Working Remotely

William cobbman

🏠
Working Remotely
View GitHub Profile
@cobbman
cobbman / .htaccess force www or non-www universally
Last active May 11, 2017 00:31
universal htaccess force www
### BEGIN FORCE WWW OR NON-WWW
<ifModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
#Force non-www:
#RewriteCond %{HTTP_HOST} www.(.*)$ [NC]
#RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
#Force www:
@cobbman
cobbman / keybase.md
Created October 12, 2016 17:46
Keybase Verification

Keybase proof

I hereby claim:

  • I am bigwilliam on github.
  • I am bigwilliam (https://keybase.io/bigwilliam) on keybase.
  • I have a public key ASDkUaWUk4TR5dm5VkcZPO3BAfCGq81Sg5xGitzpazGe4Qo

To claim this, I am signing this object:

@cobbman
cobbman / Preload Assets with Ajax
Created August 5, 2016 20:05
Preload js, css, and images with AJAX
# Please reference this article for the full description: https://perishablepress.com/3-ways-preload-images-css-javascript-ajax/
window.onload = function() {
setTimeout(function() {
// XHR to request a JS and a CSS
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://domain.tld/preload.js');
xhr.send('');
xhr = new XMLHttpRequest();
xhr.open('GET', 'http://domain.tld/preload.css');
@cobbman
cobbman / .htaccess (upload files from proxy)
Last active June 27, 2016 18:12
Checks for local files in wp-content/uploads and rewrites the URL to the live server if needed. Also checks that the HOST is local, so it won't run outside of your dev URL.
// Place this BEFORE the WordPress Rewrite rules
// Be sure to edit LOCALHOST and LIVESITE with the proper URL's
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /wp-content/uploads/
RewriteCond %{HTTP_HOST} ^LOCALHOST\.dev$ [NC]
RewriteCond %{REQUEST_URI} ^/wp-content/uploads/
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
@cobbman
cobbman / full-screen-me.js
Last active July 25, 2016 23:21
A jQuery snippet for making elements on your page full-screen. Update vars on line 8 & 9 to begin.
/*
* => FULL SCREEN
* => Author: William <hello@bigwilliam.com>
* ---------------------------------------------------------------------------*/
/*** Set these vars to the correct elements ***/
var fullScreenEl = '#fullScreenMe'; // This is the section/wrapper which should occupy the screen
var keepOnScreen = ['#keepOnScreen', '#wpadminbar', '.masthead']; // Siblings of FullScrenEl to keep on screen (i.e. header nav)
.gform_wrapper ul {
@extend .list-unstyled;
}
.gform_wrapper li {
@extend .form-group;
}
.gform_wrapper form {
margin-bottom: 0;
@cobbman
cobbman / login-logout-links.php
Created April 28, 2015 07:04
WP Append login/logout links
@cobbman
cobbman / functions.php
Last active August 29, 2015 14:20
Override WooCommerce Styles semantically
// This tip solves the issue of WooCommerce stylesheets being loaded after your custom ones.
// Which will save you from having to add !important, or getting overly specific with your CSS styles.
// Just make sure the WooCommerce syles are listed as a dependency, which automatically puts your CSS after WooCommerce
function my_custom_scripts() {
wp_enqueue_style(‘custom-css’, get_stylesheet_directory_uri().’/main.css’, array(‘woocommerce-general’));
/*** Deprecated method ***
// place wooCommerce styles before our main stlesheet
@cobbman
cobbman / Auto-center-elements-with-jQuery.markdown
Last active August 29, 2015 14:20
Auto-center elements with jQuery

Auto-center elements with jQuery

You should use CSS first, if you can. But if not, well, there's this.

A Pen by William on CodePen.

License.

@cobbman
cobbman / WordPress Debug Function
Created September 10, 2013 18:51
Print WordPress errors to the error log
/*
Log Me - Debug Function
@param {string} $message Message that you would like to pass to the debug.log file.
*/
function post_debug( $message ) {
if ( WP_DEBUG === true ) {
if ( is_array( $message ) || is_object( $message ) ) {
error_log( print_r( $message, true ) );
} else {
error_log( $message );