Skip to content

Instantly share code, notes, and snippets.

View naomicbush's full-sized avatar

Naomi C. Bush naomicbush

View GitHub Profile
@BFTrick
BFTrick / deploy.sh
Created September 22, 2012 18:28
WordPress Plugin Deploy Script
#! /bin/bash
# A modification of Dean Clatworthy's deploy script as found here: https://github.com/deanc/wordpress-plugin-git-svn
# The difference is that this script lives in the plugin's git repo & doesn't require an existing SVN repo.
# main config
PLUGINSLUG="______your-plugin-name______"
CURRENTDIR=`pwd`
MAINFILE="______your-plugin-name______.php" # this should be the name of your main php file in the wordpress plugin
# git config
@jmather
jmather / deploy.rb
Created September 13, 2012 16:25
Spiffy capistrano config for composer based projects
after "deploy", "deploy:cleanup"
after "deploy:update_code", "composer:install"
before "composer:install", "composer:copy_vendors"
after "composer:install", "phpunit:run_tests"
namespace :composer do
desc "Copy vendors from previous release"
task :copy_vendors, :except => { :no_release => true } do
run "if [ -d #{previous_release}/vendor ]; then cp -a #{previous_release}/vendor #{latest_release}/vendor; fi"
end
<?php
/**
* Database emtpying and file removing class.
*
* Truncates all necessary tables in the defined database and removes
* any files uploaded by the demo user.
*
* @since 1.0.0
*
* @author Thomas Griffin
@ericmann
ericmann / gist:2784237
Created May 24, 2012 21:05
Consolidating my Websites

When WordPress first rolled in multisite features, I was thrilled. I immediately activated them and merged the two sites I already had - my personal portfolio and my business blog. At the time, I also had to have a "parent network" site ... so it really became three sites:

  • eamann.com (my primary domain and network parent)
  • work.eamann.com (my portfolio)
  • mindsharestrategy.com (mapped domain for my business blog)

Over time, my business blog evolved to contain a whole slew of other content - articles on faith, the outdoors, creative writing, etc. I added a couple of new mapped domains to my network and branched the content out to keep things separate:

  • prosepainting.com (creative writing)
  • groundedchristianity.com (faith essays)
@ericmann
ericmann / gist:2591384
Created May 4, 2012 02:12
Non-parent theme psuedoframework

#Parent Themes There actually is nothing wrong with the parent/child theme model. I strongly believe that the only kind of theme that should ever be distributed is a parent theme - so clients/devs can create and modify a child theme on top of it.

But I have a problem with developing on top of a parent theme if the child theme is meant for general distribution. Child themes should never be re-sold or distributed.

If I'm planning to build a theme for release, starting with an existing parent theme and building a child theme is a really bad idea.

#Frameworks

Working with the popular theme frameworks is just an extension of this problem - i.e. using Genesis or Builder as a generic parent theme and building a custom design as a child theme on top of it.

@nijikokun
nijikokun / example-user.js
Created May 3, 2012 20:46
Beautiful Validation... Why have I never thought of this before?!
var user = {
validateCredentials: function (username, password) {
return (
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' }
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' }
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' }
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' }
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' }
: false
);
@bradyvercher
bradyvercher / url-tokens.php
Last active May 21, 2016 17:46
Basic URL signing functions for WordPress
<?php
/**
* Basic URL Signing functions for WordPress.
*
* @author Brady Vercher (twitter.com/bradyvercher)
* @link http://www.blazersix.com/blog/protect-your-products-and-improve-your-systems-with-signed-urls/
*/
/**
* Sign a URL to ensure it hasn't been tampered with.
@kovshenin
kovshenin / options.php
Created April 23, 2012 12:12
Reusable Settings API fields
<?php
/**
* Text Field
*
* A simple text field callback to use with the Settings API. Don't forget to pass in
* the arguments array. Here's an example call to add_settings_field() :
*
* add_settings_field( 'my_option', __( 'My Option' ), 'foo_field_text', 'theme_options', 'general', array(
* 'name' => 'my_theme_options[my_option]',
* 'value' => $options['my_option'], // assuming $options is declared
@nacin
nacin / gist:2323060
Created April 6, 2012 21:23
Nacin's SVN override
# SVN override to prevent commits that try to implicitly commit more than one file.
# Has weaned me off of svn ci -m very effectively. I now almost always use svn ci,
# which usually results in me writing longer and more helpful commit messages.
# Also, it prevents me from committing unrelated code, so there's that.
#
# Also checks for error_log, var_dump, and console.log, and rejects these commits.
function svn() {
if [ "$1" == "ci" ] && [ "$2" == "-m" ] && [ -z "$4" ] && [ "$(svn stat --ignore-externals | grep '^[^?X]' | wc -l | awk '{print $1}')" -gt 1 ]; then
svn stat --ignore-externals | grep '^[^?X]'
@mikeschinkel
mikeschinkel / rootbased-taxonomy-urls.php
Created March 26, 2012 04:29
Root-based Taxonomy URLs Plugin for WordPress
<?php
/*
* Plugin Name: Root-based Taxonomy URLs for WordPress
* Description: Enables root-based Taxonomy URLs, i.e. Makes /taxonomy/my-taxonomy/ URLs route as /my-taxonomy/
* Author: Mike Schinkel
* Author URI: http://about.me/mikeschinkel
* Plugin URI: https://gist.github.com/1421235
* Version: 0.1
* License: GPL 2+
* Notes: Must use register_root_based_taxonomy_url( $taxonomy[, $priority] ) in an 'init' hook to specify root_based taxonomy.