Skip to content

Instantly share code, notes, and snippets.

@scottlee
scottlee / functions.php
Created November 1, 2012 15:30
Create a widgetized area for every top level page in WordPress.
/**
* Create widgetized sidebars for each page
*/
function xxx_custom_page_sidebars() {
$pages = get_pages( array(
'parent' => 0
)
);
foreach ( $pages as $page ) {
@scottlee
scottlee / gist:3841816
Created October 5, 2012 19:22
Trim "protected" from the title
function degweb_protected_title_trim($title) {
$title = attribute_escape($title);
$findthese = array(
'#Protected:#',
'#Private:#'
);
$replacewith = array(
'', // What to replace "Protected:" with
'' // What to replace "Private:" with
);
@scottlee
scottlee / gist:3841430
Created October 5, 2012 18:13
Display if excerpt exist
<?php if(!empty($post->post_excerpt)) {
//This post have an excerpt, let's display it
the_excerpt();
} else {
// This post have no excerpt
} ?>
@scottlee
scottlee / gist:1764206
Created February 8, 2012 01:43
Check current environment, set appropriate variables
/*
* Check for the current environment
*/
//define('WP_CACHE', true); //Added by WP-Cache Manager
if ($_SERVER["HTTP_HOST"] === 'domain.com') {
$db_name = 'dbname';
$db_user = 'dbuser';
$password = 'dbass';
} else if ($_SERVER["HTTP_HOST"] === 'local') {
@scottlee
scottlee / bug-hunt-one.php
Created January 9, 2012 17:04 — forked from EnvatoWP/bug-hunt-one.php
Bug Hunt One
<?php
/*
* Plugin Name: EnvatoWP Bug Hunt One
* Plugin URI: https://gist.github.com/
* Description: Bug Hunt One - Find all the bugs in this basic plugin
* Version: 0.1
* Author: EnvatoWP
* Author URI: http://envatowp.github.com/
* License: GPL2
*/
@scottlee
scottlee / GetWP
Created July 28, 2011 20:16
Here's my little local development only script I use to download and install WordPress. mac, osx, mamp
#!/bin/bash
##########
## Setup: hardcode your mysql user/pass. Yeah, yeah, I know...it's frowned upon.
## but for local development, I have no problem with it.
## Find and replace: MYSQLUSER / MYSQLPASS
##
## Usage: This script accepts only one variable, the site name.
##
#########
#!/bin/sh
# Alot of these configs have been taken from the various places
# on the web, most from here
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
# Set the colours you can use
black='\033[0;30m'
white='\033[0;37m'
red='\033[0;31m'