Skip to content

Instantly share code, notes, and snippets.

View petenelson's full-sized avatar

Pete Nelson petenelson

View GitHub Profile
@markkelnar
markkelnar / gist:ebc2f147ce70116991b2
Created August 6, 2014 01:23
PHP lint checker - pre commit hook
#!/bin/bash
# Put this file in .git/hooks/pre-commit
# Change it to be executable! If you don't do this, it won't work
# chmod +x .git/hooks/pre-commit
git diff-index --diff-filter=ACMR --name-only --cached HEAD |
grep '.php$' |
xargs -tn1 php -l
if (( $? )); then
@ebinnion
ebinnion / .bash_profile
Last active August 29, 2015 14:00
Gist of helpful commands that I use in development.
PATH=$PATH:~/bin
export PATH
alias ll='ls -lah'
# Git aliases
alias softreset='git reset --soft HEAD^'
alias hardreset='git reset --hard HEAD^'
# Following http://viget.com/inspire/terminal-aliases-for-git
@thomaswardiii
thomaswardiii / bacon.php
Last active December 25, 2015 22:09
Bacon ipsum API command line script. Now with ~/.bacon default
#!/usr/bin/php
<?php
/**
* Bacon ipsum PHP-CLI script
*
* Generates sentences or paragraphs from baconipsum.com
*
* @version 1.0.1
* @author Thomas Ward III <thomaswardiii@gmail.com>
*/
@strangerstudios
strangerstudios / heartbeat-api-demo.php
Last active April 30, 2024 17:08
Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
<?php
/*
Plugin Name: Heartbeat API Demo
Plugin URI: http://www.strangerstudios.com/wp/heartbeat-api-demo
Description: Minimal example demonstrating the WordPress Heartbeat API being added in WP version 3.6.
Version: .1
Author: strangerstudios
If logged in as a user and viewing the frontend of your website,
every 15 seconds you should see the following in your Javascript console:
@paulund
paulund / debug-to-console.php
Last active December 18, 2015 07:09
Instead of sending debug data to a log file, just display it in the browser console with the following PHP snippet.
<?php
/**
* Send debug code to the Javascript console
*/
function debug_to_console($data) {
if(is_array($data) || is_object($data))
{
echo("<script>console.log('PHP: ".json_encode($data)."');</script>");
} else {
echo("<script>console.log('PHP: ".$data."');</script>");
@clarklab
clarklab / set_page_template.php
Created November 5, 2012 18:06
set a page template programmatically in WordPress
update_post_meta( $post_id, '_wp_page_template', 'page-contact.php' );
@BronsonQuick
BronsonQuick / add_custom_xml_tags_to_tinymce_wordpress.php
Created September 4, 2012 01:43
Add custom tags to TinyMCE in WordPress
<?php
/*
* Our client needed some data sent in XML tags from Gravity Forms notifications to their system. These tags were being stripped by
* TinyMCE when the client would switch from HTML to Visual. This was my fix for it.
*
*/
function sennza_add_custom_tinymce_tags( $init ) {
// Command separated string of extended elements
$ext = 'name[*],phone[*],src[*],ip[*],notes[*],email[*]';
@mjangda
mjangda / get_current_post_type.php
Created July 15, 2010 13:55
Get the current post_type context in the WordPress admin.
<?php
/**
* Gets the current global post type if one is set
*/
function x_get_current_post_type() {
global $post, $typenow, $current_screen;
if( $post && $post->post_type )
$post_type = $post->post_type;
elseif( $typenow )
@redoPop
redoPop / .gitignore
Created June 18, 2010 22:08
Template .gitignore file for WordPress projects
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your