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 / wp-easy-file-path.php
Last active July 9, 2018 02:28
wp easy file path
<?php
/*
* Returns a WP file path
* Parameter: path to file relative to current file
*/
function mm_get_file_path($relative_path_no_preceding_slash) {
return plugin_dir_path(__FILE__) . $relative_path_no_preceding_slash;
}
?>
@mattmcgiv
mattmcgiv / wp-plugin-simple.php
Last active January 4, 2016 17:02
A simple WordPress plugin for getting started quickly on a project.
<?php
/*
Plugin Name: Antym Plugin
Plugin URI: http://antym.com
Description: Adds some features to the site...
Version: .6
Author: Matt McGivney
Author URI: http://antym.com
License: GPL2
License URI: https://www.gnu.org/licenses/gpl-2.0.html