Skip to content

Instantly share code, notes, and snippets.

@joemcgill
joemcgill / textbg.css
Created Nov 5, 2012
Inline Text Background (CSS only)
View textbg.css
/*
* Class for defining text with background on text only and not the whole block.
* May require definition of html element (i.e. p.textbg) in order to make line-height
* and font-size work.
*/
.textbg {
padding:5px 0; /* top and bottom padding */
color:#fff;
font-size: 24px;
@joemcgill
joemcgill / WP Fix Image Margins
Last active Oct 14, 2016
Removes the silly 10px margin from caption based images in WP (H/T Justin Adie)
View WP Fix Image Margins
/**
* Description: removes the silly 10px margin from caption based images
* Author: Justin Adie
* Version: 0.1.0
* Author URI: http://rathercurious.net
*/
class fixImageMargins{
public $xs = 0; //change this to change the amount of extra spacing
@joemcgill
joemcgill / WP custom post time
Created May 25, 2013
A custom post time function for WordPress that allows you to change the output for posts that are published today.
View WP custom post time
/**
* custom post time function
*
* @uses global $post, get_the_time() and get_the_date()
* @vars $d (for custom date formatting), $t (for custom time formatting)
* @returns $my_post_time
*/
function my_post_time($d, $t) {
global $post;
View Contract Killer 3.md

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

@joemcgill
joemcgill / parse_youtube_url
Created Sep 16, 2013
A handy javascript function for parsing YouTube urls and returning just the video URI (adapted from: http://stackoverflow.com/posts/9102270/revisions).
View parse_youtube_url
function parse_youtube_url(url) {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=v=|\&v=)([^#\&\?]*).*/;
var match = url.match(regExp);
if (match&&match[2].length==11){
return match[2];
}else{
//error
}
}
@joemcgill
joemcgill / Bootstrapped Contact Forms 7
Last active May 16, 2016
Boilerplate form code for the WP Contact Forms 7 plugin that makes use of Bootstrap styles
View Bootstrapped Contact Forms 7
<div class="form-group">
<label for="your-name">My Name</label>[text your-name class:form-control]
</div>
<div class="form-group">
<label for="your-email">Email Address</label>[email your-email class:form-control]
</div>
<div class="form-group">
<label for="your-message">Your Message</label>[textarea your-message class:form-control]
@joemcgill
joemcgill / location.attr reference
Created Oct 14, 2013
Nice reference of browswer location attributes cribbed from this Stack Overflow thread: http://stackoverflow.com/questions/406192/how-to-get-the-current-url-in-javascript
View location.attr reference
http://www.refulz.com:8082/index.php#tab2?foo=123
Property Result
-------------------------------------------
host www.refulz.com:8082
hostname www.refulz.com
port 8082
protocol http
pathname index.php
@joemcgill
joemcgill / Customize TinyMCE in WP
Last active Oct 14, 2016
Set of functions for easily customizing the tinyMCE editor in WordPress. More references: Wes Bos – http://wesbos.com/custom-wordpress-tinymce-wysiwyg-classes/ TinyMCE Reference – http://www.tinymce.com/wiki.php/TinyMCE3x:Buttons/controls
View Customize TinyMCE in WP
// add style selector drop down
function my_mce_buttons_2( $buttons ) {
array_unshift( $buttons, 'styleselect' );
return $buttons;
}
add_filter( 'mce_buttons_2', 'my_mce_buttons_2' );
// customize the MCE editor
function my_customize_mce( $init ) {
@joemcgill
joemcgill / wp_kill_parent_post
Created Nov 17, 2013
Remove a custom post type from a parent theme in WordPress.
View wp_kill_parent_post
add_action('after_setup_theme', 'wp_kill_parent_post');
function wp_kill_parent_post() {
remove_action('init', '<% parent post name %>');
}
// Register your own version in place of the parent post type if you want
@joemcgill
joemcgill / README.md
Created Nov 22, 2013 — forked from oodavid/README.md
Steps for deploying a site with Git
View README.md

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
    • apache's home directory is /var/www/