Skip to content

Instantly share code, notes, and snippets.

View chrisguitarguy's full-sized avatar

Christopher Davis chrisguitarguy

View GitHub Profile
@chrisguitarguy
chrisguitarguy / category-endpoint.php
Created October 18, 2011 22:01
Add a year endpoint to WordPress categories.
<?php
/*
Plugin Name: Yearly Archives for Categories
Plugin URI: http://pmg.co/category/wordpress
Description: Adds an endpoint to categories for yearly archives.
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
License: Public Domain
*/
@chrisguitarguy
chrisguitarguy / menu-order.php
Created October 20, 2011 15:57
Add menu order to WordPress posts
<?php
/*
Plugin Name: Add Menu Order to Posts
Plugin URI: http://pmg.co/category/wordpress
Description: Adds menu order and template to post types.
Version: n/a
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
*/
@chrisguitarguy
chrisguitarguy / xml.py
Created October 21, 2011 21:18
Parse an XML sitemap with Python, requests and BeautifulSoup
from __future__ import with_statement # we'll use this later, has to be here
from argparse import ArgumentParser
import requests
from BeautifulSoup import BeautifulStoneSoup as Soup
def parse_sitemap(url):
resp = requests.get(url)
# we didn't get a valid response, bail
@chrisguitarguy
chrisguitarguy / server.py
Created October 24, 2011 03:14
Super simple python socket server and HTTP request class.
import socket, traceback
HOST = ''
PORT = 51235
CLRF = '\r\n'
class InvalidRequest(Exception):
pass
class Request(object):
@chrisguitarguy
chrisguitarguy / kill-trackbacks.php
Created October 24, 2011 16:25
Kill all WordPress pingback/trackback functionality
<?php
/*
Plugin Name: Kill Trackbacks
Plugin URI: http://pmg.co/category/wordpress
Description: Kill all trackbacks on WordPress
Version: 1.0
Author: Christopher Davis
Author URI: http://pmg.co/people/chris
*/
@chrisguitarguy
chrisguitarguy / email-regex.py
Created November 3, 2011 03:17
ridiculous Python regular expression to check for emails
re.compile(r'\b([^@\s([]+)\s*(\(|\[)?\s*(@|at)\s*(\)|\])?\s*(hotmail\s*(\(|\[)?\s*(\.|dot)\s*(\)|\])?\s*com)\b', re.I)
@chrisguitarguy
chrisguitarguy / wpse32871.php
Created November 4, 2011 03:29
Adding shortcodes
<?php
/*
Plugin Name: wpse32871 Shortcode tester
*/
add_action( 'init', 'wpse32871_add_shortcodes' );
function wpse32871_add_shortcodes()
{
add_shortcode( 'wpse32871', 'wpse32871_shortcode_cb' );
@chrisguitarguy
chrisguitarguy / post-editing.php
Created November 4, 2011 04:44
Page by page editting permissions for WordPress
<?php
/*
Plugin Name: Restrict Page Access
Plugin URI: https://gist.github.com/1338673
Description: Allows administrators to give editors permission to edit only certain posts
Author: Christopher Davis
Author URI: http://christopherdavis.me
License: GPL2
*/
@chrisguitarguy
chrisguitarguy / post-layout.php
Created November 5, 2011 14:33
change the class of a post based on a postmeta value in WordPress
<?php
/*
Plugin Name: wpse32973 Post Layout
Author: Christopher Davis
Author URI: http://www.christopherguitar.net/wordpress/
Description: Change the post class (for styling purposes) so posts can be formatted correctly.
*/
// register the meta box
add_action( 'add_meta_boxes', 'wpse32973_add_meta_box' );
@chrisguitarguy
chrisguitarguy / members.php
Created November 6, 2011 04:22
Custom menus (and much more) for logged in WordPress users
<?php
/*
Plugin Name: Gallery Members (for wpse32840)
Description: Only allow members to view one page
Author: Christopher Davis
Author URI: http://www.christopherguitar.net/
*/
register_activation_hook( __FILE__, 'wpse32840_activation' );
function wpse32840_activation()