Skip to content

Instantly share code, notes, and snippets.

View norcross's full-sized avatar
somone said this would be easy. someone LIED.

Norcross norcross

somone said this would be easy. someone LIED.
View GitHub Profile
anonymous
anonymous / Redirect post
Created December 17, 2012 23:57
Redirect post's in certain category to new location on "template_redirect"
if ( in_category( 'sent-from-my-iphone', $post ) ) {
//jeanaater.com/..../../....
$permalink = str_replace( '.com', '.wordpress.com', get_permalink( $post->ID ) );
wp_redirect( $permalink, 301 ); exit;
}
@c3mdigital
c3mdigital / front-end-uploads.php
Created November 16, 2012 17:14
Two file upload handler functions
/**
* File upload ajax handler function to save the file and send image or file html back to the browser
* These functions are part of a class
*/
function ajax_upload_file() {
check_ajax_referer( 'ugc_user_upload', 'nonce' );
$file_data = array(
'name' => $_FILES['ugc_attachment_file']['name'],
'type' => $_FILES['ugc_attachment_file']['type'],
'tmp_name' => $_FILES['ugc_attachment_file']['tmp_name'],
@markjaquith
markjaquith / plugin-deploy.sh
Created November 16, 2012 05:04 — forked from scribu/plugin-deploy.sh
Plugin deploy script
#!/bin/bash
# args
MSG=${1-'deploy from git'}
BRANCH=${2-'trunk'}
# paths
SRC_DIR=$(git rev-parse --show-toplevel)
DIR_NAME=$(basename $SRC_DIR)
DEST_DIR=~/svn/wp-plugins/$DIR_NAME/$BRANCH
@clarklab
clarklab / gist:3702300
Created September 11, 2012 21:42
WP_Query snippet for Sublime Text 2
<snippet>
<content><![CDATA[
\$${1:query} = new WP_Query('posts_per_page=5');
while (\$${1:query}->have_posts()) : \$${1:query}->the_post();
${0:// do something}
endwhile;
]]></content>
<tabTrigger>wpq</tabTrigger>
<scope>source.php</scope>
<description>WP_Query basic loop</description>
@xentek
xentek / wp-unit-tests.md
Created August 26, 2012 19:06
WordPress Unit Tests Quick Start

WordPress Unit Tests Quick Start Guide

This quick start guide is geared towards installing PHPUnit on OSX in order to run the WordPress unit tests. It uses homebrew to install PHP using homebrew-php. You can likely skip this step if you've already got php and pear installed properly.

If you use MAMP, then try these instructions to use MAMP's php and pear to install PHPUnit.

install homebrew

ruby &lt;(curl -fsSkL raw.github.com/mxcl/homebrew/go)
@johnpbloch
johnpbloch / README.md
Created August 23, 2012 13:55
A bash script to make .pot files for WordPress plugins

Installation

To install, you need to have the WordPress i18n library on your computer. Check it out using SVN:

sudo svn co http://i18n.svn.wordpress.org/tools/trunk/ /usr/lib/wpi18n

You don't have to put the library in /usr/lib/wpi18n, but if you don't put it there, make sure to set the $WP_I18N_LIB environment variable in your .bashrc file (with no trailing slash):

export WP_I18N_LIB="/path/to/i18n/lib"

@brandonb927
brandonb927 / osx-for-hackers.sh
Last active June 13, 2024 02:39
OSX for Hackers: Yosemite/El Capitan Edition. This script tries not to be *too* opinionated and any major changes to your system require a prompt. You've been warned.
#!/bin/sh
###
# SOME COMMANDS WILL NOT WORK ON macOS (Sierra or newer)
# For Sierra or newer, see https://github.com/mathiasbynens/dotfiles/blob/master/.macos
###
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/5b3c8418ed42d93af2e647dc9d122f25cc034871/.osx
@imathis
imathis / tweetbot-mute-regex.md
Created June 27, 2012 19:45
Tweetbot can use regular expressions to mute tweets in your timeline and mentions.

Hashtag abuse

Three or more hashtags.

#[^#]+#[^#]+#

Long hashtags (15+ characters): #hashtagpunchline

@ramseyp
ramseyp / featured_img_url.php
Created June 12, 2012 20:40
Getting the URL of a featured image in WordPress
@jbroadway
jbroadway / Slimdown.md
Last active February 5, 2024 10:43
Slimdown - A simple regex-based Markdown parser.