Skip to content

Instantly share code, notes, and snippets.

View ScottPhillips's full-sized avatar

Scott Phillips ScottPhillips

  • Los Angeles, CA
View GitHub Profile
@ScottPhillips
ScottPhillips / readme
Created April 6, 2012 18:32
Boilerplate Wordpress Widget
How to Use
Step 1.
Copy the custom_widget.php file and place it in your WordPress theme folder. Assuming WordPress is installed in the root of your server the file will be place in /wp-content/themes/yourtheme/
Step 2.
Open up functions.php and include the following piece of code somewhere in the file. include TEMPLATEPATH . '/custom_widget.php';
Step 3.
Edit the custom_widget.php file to suit your needs.
@ScottPhillips
ScottPhillips / readme
Created April 6, 2012 18:34
Boilerplate Wordpress Custom Post Type
<?php
/*
Setup and add our custom post types
*/
function create_post_types(){
@ScottPhillips
ScottPhillips / gist:2382192
Created April 14, 2012 04:56 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query
* Source: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/query.php
*/
$args = array(
@ScottPhillips
ScottPhillips / all-uris.php
Created May 9, 2012 03:19 — forked from thefuxia/all-uris.php
Plugin T5 All URIs
<?php # -*- coding: utf-8 -*-
declare ( encoding = 'UTF-8' );
/**
* Plugin Name: T5 All URIs
* Description: Creates a plaintext list of all URIs on your blog.
* Version: 2012.03.08
* Required: 3.3
* Author: Thomas Scholz <info@toscho.de>
* Author URI: http://toscho.de
* License: MIT
$(document).ready(function() {
/* Hide all elements outside the visible window */
$('body *').each( function(){
var top_of_object = $(this).position().top;
var bottom_of_window = $(window).scrollTop() + $(window).height();
if( bottom_of_window < top_of_object ){
@ScottPhillips
ScottPhillips / s3-public-bucket-policy.json
Created May 22, 2012 01:19
Amazon S3 Bucket Policy : Default Everything to Public
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@ScottPhillips
ScottPhillips / readme.txt
Created May 23, 2012 01:54
Amazon S3 Bucket Policy : Restrict Access to 1 IP Adress
This statement grants permissions to any user to perform any S3 action on objects in the specified bucket. However, the request must originate from the range of IP addresses specified in the condition. The condition in this statement identifies 192.168.143.* range of allowed IP addresses with one exception, 192.168.143.188.
Note that the IPAddress and NotIpAddress values specified in the condition uses CIDR notation described in RFC 2632. For more information, go to http://www.rfc-editor.org/rfc/rfc4632.txt.
@ScottPhillips
ScottPhillips / s3-public-bucket-policy.json
Created May 23, 2012 01:57
Amazon S3 Bucket Policy : Restrict Access to Specific Referer
{
"Version":"2008-10-17",
"Id":"http referer policy example",
"Statement":[
{
"Sid":"Allow get requests referred by www.mysite.com and mysite.com",
"Effect":"Allow",
"Principal":"*",
"Action":"s3:GetObject",
"Resource":"arn:aws:s3:::YOUR_S3_BUCKET_NAME/*",
@ScottPhillips
ScottPhillips / inspect_hooks.php
Created May 30, 2012 00:11 — forked from franz-josef-kaiser/inspect_hooks.php
Inspect hooks in WP by adding &debug=true&hook=my_hook_name to the request URl
<?php
/**
* Plugin Name: Hook Debug Output
* Plugin URI: http://unserkaiser.com
* Description: Debug Hooked filter callback functions with adding <code>?debug=secret&hook=your_hook_name</code> to the URl
* Version: 0.1
* Author: Stephen Harris, Franz Josef Kaiser
* Author URI: http://unserkaiser.com
*/
// Prevent loading this file directly - Busted!
@ScottPhillips
ScottPhillips / detect-bot.php
Created June 10, 2012 08:15
Detects a few common Search Bots
<?php
/* Detects some common web bots */
function detectBot($USER_AGENT) {
$crawlers_agents = strtolower('Bloglines subscriber|Dumbot|Sosoimagespider|QihooBot|FAST-WebCrawler|Superdownloads Spiderman|LinkWalker|msnbot|ASPSeek|WebAlta Crawler|Lycos|FeedFetcher-Google|Yahoo|YoudaoBot|AdsBot-Google|Googlebot|Scooter|Gigabot|Charlotte|eStyle|AcioRobot|GeonaBot|msnbot-media|Baidu|CocoCrawler|Google|Charlotte t|Yahoo! Slurp China|Sogou web spider|YodaoBot|MSRBOT|AbachoBOT|Sogou head spider|AltaVista|IDBot|Sosospider|Yahoo! Slurp|Java VM|DotBot|LiteFinder|Yeti|Rambler|Scrubby|Baiduspider|accoona');
$crawlers = explode("|", $crawlers_agents);
if(is_array($crawlers) {
foreach($crawlers as $crawler) {
if (strpos(strtolower($USER_AGENT), trim($crawler)) !== false) {
return true;
}