Skip to content

Instantly share code, notes, and snippets.

View mattmcgiv's full-sized avatar
😎

Matt McGivney mattmcgiv

😎
View GitHub Profile
@mattmcgiv
mattmcgiv / keybase.md
Created February 6, 2015 14:20
keybase.md

Keybase proof

I hereby claim:

  • I am mattmcgiv on github.
  • I am mattmcgiv (https://keybase.io/mattmcgiv) on keybase.
  • I have a public key whose fingerprint is C582 CCFF 1819 FB5B AE64 4EDD 7762 A02A 193C A1B0

To claim this, I am signing this object:

Gulp workflow for WordPress theme development

Requirements

In order for Livereload to work, you need a Firefox or Chrome extension as Gulp doesn't inset it automatically. Alternatively, you can also manually put the livereload script in footer.php, just make sure to insert it only on development environment:

<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
@mattmcgiv
mattmcgiv / responsive-typography
Last active August 29, 2015 14:16
Sets root element font-size to 16px; uses rems thereafter.
html {
font-size: 16px; /*1rem=16px*/
}
h1 {
font-size: 3rem; /* 48px (16 times 3) */
}
h2 {
font-size: 2rem; /* 32px */
@mattmcgiv
mattmcgiv / add_to_wp-config.php
Created March 4, 2015 23:30
wordpress debugging
// Add this to wp-config.php
// Enable WP_DEBUG mode
define('WP_DEBUG', true);
// Enable Debug logging
define('WP_DEBUG_LOG', true);
/* PHP info will be logged to:
wp-content/debug.log
@mattmcgiv
mattmcgiv / gist:c2a0ad005fa66fe0f20e
Created March 13, 2015 12:23
Add JavaScript to a specific WordPress page or post
function mm_js_in_wp_head($pid){
global $post;
// only for post Id = 720
$mm_id_of_page="720";
if($post->ID==$mm_id_of_page){
echo "<script>alert('hello world');</script>";
}
}
add_action( 'wp_head', 'mm_js_in_wp_head' );
@mattmcgiv
mattmcgiv / wp-db-search-replace.sh
Created March 13, 2015 16:41
Generates SQL for replacing URLs in a WordPress database
#PURPOSE to easily generate SQL required to update a WP db to a new URL
#USAGE ./wp-db.bash http://source.com http://destination.com
echo "UPDATE wp_options SET option_value = REPLACE(option_value, '$1', '$2');"
echo "UPDATE wp_postmeta SET meta_value = REPLACE(meta_value, '$1', '$2');"
echo "UPDATE wp_posts SET guid = REPLACE(guid, '$1', '$2');"
echo "UPDATE wp_posts SET post_content = REPLACE(post_content, '$1', '$2');"
@mattmcgiv
mattmcgiv / freshbooks-invoice.list.xml
Created March 14, 2015 12:34
FreshBooks Invoice.list request
<!--?xml version="1.0" encoding="utf-8"?-->
<request method="invoice.list">
<!-- Filter by client (Optional) -->
<client_id>3</client_id>
<!-- Filter by recurring id (Optional) -->
<recurring_id>10</recurring_id>
<!-- Filter by status (Optional) -->
<status>draft</status>
<!-- Returns invoices with a number like this arg (Optional) -->
<number>FB00004</number>
<?php
function mm_get_html_from_file() {
$mm_html_file =
include '$mm_html_file';
?>
@mattmcgiv
mattmcgiv / enqueue-javascript.php
Last active August 29, 2015 14:25
enqueue javascript in WordPress
<?php
wp_enqueue_script('whatev-handle', __FILE__ . '/js/script.js', 'jquery', true);
/*
* Usage:
* wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
*
* @param string $handle Name of the script.
* @param string|bool $src Path to the script from the root directory of WordPress. Example: '/js/myscript.js'.
* @param array $deps An array of registered handles this script depends on. Default empty array.
@mattmcgiv
mattmcgiv / gist:198b0e3980efe5a75922
Created September 11, 2015 17:40
Some markup for a mapping app (h2h)
<span id="main-feedback" class="inline-block mt2" style="width:100%;">
<span class="col col-4 h2 inline-block left-align">Charge:<br><span class="h2">$225<span></span></span></span>
<span class="col col-4 inline-block left-align">
<form action="">
<input class="mb2" type="radio" value="am" name="tod">Daytime<br>
<input type="radio" name="tod" value="pm">After-hours
</form>
</span>
<span class="col col-4 inline-block left-align">
<span class="h3 block">Region: North</span>