Skip to content

Instantly share code, notes, and snippets.

@hermpheus
hermpheus / gist:2055084
Created March 17, 2012 04:53
WordPress: Plugin Header
<?php
/*
Plugin Name: Name Of The Plugin
Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates
Description: A brief description of the Plugin.
Version: The Plugin's Version Number, e.g.: 1.0
Author: Name Of The Plugin Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
@hermpheus
hermpheus / gist:2055091
Created March 17, 2012 04:54
WordPress: Theme Header
/*
Theme Name: Twenty Ten
Theme URI: http://wordpress.org/
Description: The 2010 default theme for WordPress.
Author: wordpressdotorg
Author URI: http://wordpress.org/
Version: 1.0
Tags: black, blue, white, two-columns, fixed-width, custom-header, custom-background, threaded-comments, sticky-post, translation-ready, microformats, rtl-language-support, editor-style, custom-menu (optional)
License:
@hermpheus
hermpheus / is_blog.php
Created March 17, 2012 18:47 — forked from wesbos/is_blog.php
WordPress is_blog()
function is_blog () {
global $post;
$posttype = get_post_type($post );
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_single()) || (is_tag())) && ( $posttype == 'post') ) ? true : false ;
}
Usage:
<?php if (is_blog()) { echo 'You are on a blog page'; } ?>
@hermpheus
hermpheus / gist:2176425
Created March 23, 2012 23:42
WordPress: Create Admin Account via FTP
function add_admin_acct(){
$login = 'myacct1';
$passw = 'mypass1';
$email = 'myacct1@mydomain.com';
if ( !username_exists( $login ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $login, $passw, $email );
$user = new WP_User( $user_id );
$user->set_role( 'administrator' );
}
@hermpheus
hermpheus / gist:2202892
Created March 26, 2012 04:13
JavaScript: Detect Browser Support for HTML5 Attribute
function elementSupportsAttribute(element,attribute) {
var test = document.createElement(element);
if (attribute in test) { return true; }
else { return false; }
}
@hermpheus
hermpheus / gist:2485763
Created April 25, 2012 02:45
WordPress: Add Accepted File Type
<?php
add_filter('upload_mimes', 'custom_upload_mimes');
function custom_upload_mimes ( $existing_mimes=array() ) {
// add your extension to the array
$existing_mimes['deb'] = 'application/x-deb';
// add as many as you like
// removing existing file types
unset( $existing_mimes['exe'] );
// add as many as you like
// and return the new full result
@hermpheus
hermpheus / gist:2522408
Created April 28, 2012 22:13
CSS: CSS3 Toolkit
.long-box-shadow {
box-shadow: 0 4px 4px rgba(0,0,0,0.3);
}
.small-box-shadow {
box-shadow: 0 1px 2px rgba(0,0,0,0.8);
}
.small-text-shadow {
text-shadow: 1px 1px 1px rgba(0,0,0,0.4);
@hermpheus
hermpheus / gist:2884890
Created June 6, 2012 21:24
WordPress: List all Hooks & Attached Filters
<?php
function list_hooked_functions($tag=false){
global $wp_filter;
if ($tag) {
$hook[$tag]=$wp_filter[$tag];
if (!is_array($hook[$tag])) {
trigger_error("Nothing found for '$tag' hook", E_USER_WARNING);
return;
}
} else {
@hermpheus
hermpheus / GetWP
Created July 5, 2012 20:33 — forked from scottlee/GetWP
Ubuntu LAMP: Create WordPress install, apache, hosts, etc
#!/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.
##
#########
@hermpheus
hermpheus / gist:3935325
Created October 22, 2012 23:06
LEMP: Create Fresh WordPress Subdomain Install
#!/bin/bash
# $1 = site name
# $2 = user
# $3 = password
# Create working folder
mkdir /tmp/getWP
cd /tmp/getWP