Skip to content

Instantly share code, notes, and snippets.

@helen
helen / wp-chosen-tax-metabox.php
Last active April 24, 2022 02:25
Use Chosen for a replacement WordPress taxonomy metabox
<?php
/**
* WordPress Chosen Taxonomy Metabox
* Author: Helen Hou-Sandi
*
* Use Chosen for a replacement taxonomy metabox in WordPress
* Useful for taxonomies that aren't changed much on the fly and are
* non-hierarchical in nature, as Chosen is for flat selection only.
* You can always use the taxonomy admin screen to add/edit taxonomy terms.
* Categories need slightly different treatment from the rest in order to
@AAS
AAS / gist:2036916
Created March 14, 2012 14:37
OS X 10.7 Lion Finder - Folders on top
Open Terminal.
Type this command:
cd /System/Library/CoreServices/Finder.app/Contents/Resources/English.lproj/
Now, the file we want to mess around is the InfoPlist.strings. But unfortunately, this file cannot be edited directly using text editor in Lion. But no worries. Run this command to make it editable.
sudo plutil -convert xml1 InfoPlist.strings
Now the file should be editable and readable. Use your favorite text editor and open InfoPlist.strings. I just used vim
sudo vim InfoPlist.strings
@nfreear
nfreear / git-hook_pre-commit_lint.php
Last active October 15, 2015 04:05
Git pre-commit hook to run PHP lint, check for [CR] Mac-only line endings..
#!/C/xampp/php/php
<?php
#!/usr/bin/env php
/**
* Git pre-commit hook to run php lint.
*
* Git hooks on Windows: Ensure that the path to PHP is added to the %PATH% variable, and run `git commit` via the Bash shell.
*
* @copyright 2012-04-30 N.D.Freear.
* @license MIT
@thefuxia
thefuxia / plugin-class-demo.php
Last active April 11, 2024 13:50
Plugin Class Demo
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: Plugin Class Demo
* Description: How I am using the base class in plugins.
* Plugin URI:
* Version: 2012.09.29
* Author: Fuxia Scholz
* License: GPL
* Text Domain: plugin_unique_name
* Domain Path: /languages
@norcross
norcross / login-string-check.php
Created December 20, 2012 01:15
check login URL for specific query string
<?php
/*
* Check the URL of the WordPress login
* page for a specific query string
*
* assumes login string is
* http://mysite.com/wp-login.php?question=answer
*/
function rkv_login_stringcheck() {
@deckerweb
deckerweb / genesiswp-dev-chat_2013-01-18.txt
Created January 18, 2013 18:39
#GenesisWP Dev Chat from 2012-01-18
deckerweb 17:18:10
hi there!
wpconsult 17:18:18
GaryJ did someone look at that thing I posted yesterday?
nathanrice 17:18:28
there are a lot of pretty simple tickets, so go ahead and get your feet wet
@mattonomics
mattonomics / prying-eyes.php
Last active December 12, 2015 12:39
This will make sure that only logged in users can view ANY content on the site. Drop it at the tip top of your functions.php file.
<?php
// fancy PHP 5.3+ style
add_action( 'template_redirect', function() {
if ( ! is_user_logged_in() ) {
wp_redirect( wp_login_url() );
exit;
}
} );
@robneu
robneu / wp-config
Created February 26, 2013 20:48
Set your GF license key in wp-config
/** Define Gravity Forms License Key */
define("GF_LICENSE_KEY", "YOUR-LICENSE-KEY-HERE");
@norcross
norcross / url-spamcheck.php
Created April 26, 2013 17:41
checks the URL posted by a commenter
<?php
function rkv_url_spamcheck( $approved , $commentdata ) {
$author_url = $commentdata['comment_author_url'];
$author_url_length = strlen($author_url);
if ($author_url_length > 50 )
$approved = 'spam';
@JiveDig
JiveDig / post_class_columns.php
Last active June 11, 2016 00:06
Use post_class (post class) to break post into columns Last example shows how to conditionally use post class, for specific templates or pages
/**
* Breaks the posts into 4 columns
* @link http://www.billerickson.net/code/grid-loop-using-post-class
*/
add_filter( 'post_class', 'tsm_archive_post_class' );
function tsm_archive_post_class( $classes ) {
global $wp_query;
// Keeps columns out of secondary loops ie: Genesis Featured Post widgets
if( ! $wp_query->is_main_query() ) {
return $classes;