Skip to content

Instantly share code, notes, and snippets.

View sunnyratilal's full-sized avatar

Sunny Ratilal sunnyratilal

View GitHub Profile
@sunnyratilal
sunnyratilal / EDD Function Example.php
Created April 4, 2013 09:15
Example Easy Digital Downloads Function
<?php
/**
* Example function description
*
* @since {Next EDD Version}
* @param {array, string, int, objext} {$variable_name} {Short description}
* @return {array, string, int, mixed, object} {$variable_name} {Short description}
* {@internal Any To-Dos etc.}
*/
/** Debugging WP */
define('WP_DEBUG', true); //enable the reporting of notices during development - E_ALL
define('WP_DEBUG_DISPLAY', true); //use the globally configured setting for display_errors and not force errors to be displayed
define('WP_DEBUG_LOG', true); //error logging to wp-content/debug.log
define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS and disables compression and concatenation,
//define('E_DEPRECATED', false); //E_ALL & ~E_DEPRECATED & ~E_STRICT
define('AUTOSAVE_INTERVAL', '300'); // Autosave interval
define('SAVEQUERIES', true); // Analyse queries
/** Debugging WP */
define('WP_DEBUG', true); //enable the reporting of notices during development - E_ALL
define('WP_DEBUG_DISPLAY', true); //use the globally configured setting for display_errors and not force errors to be displayed
define('WP_DEBUG_LOG', true); //error logging to wp-content/debug.log
define('SCRIPT_DEBUG', true); //loads the development (non-minified) versions of all scripts and CSS and disables compression and concatenation,
//define('E_DEPRECATED', false); //E_ALL & ~E_DEPRECATED & ~E_STRICT
define('AUTOSAVE_INTERVAL', '300'); // Autosave interval
define('SAVEQUERIES', true); // Analyse queries
<?php
function rv_twitter_text($ret) {
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w]+[^ \"\n\r\t< ]*)#", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[^ \"\t\n\r< ]*)#", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
$ret = preg_replace("/@(\w+)/", "<a href=\"http://www.twitter.com/\\1\" target=\"_blank\">@\\1</a>", $ret);
$ret = preg_replace("/#(\w+)/", "<a href=\"http://search.twitter.com/search?q=\\1\" target=\"_blank\">#\\1</a>", $ret);
return $ret;
}
<?php
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr($cookie, 'wordpress_logged_in_') )
$loggedin = true;
}
return $loggedin;
}
if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() )
<?php
/*
* Plugin Name: Hacky Taxonomy Archives
* Description: Don't use this on a live site, plz. Proof of concept for Aaron Holbrook.
* Author: Andrew Nacin
*/
add_action( 'template_redirect', function() {
global $wp_rewrite;
$taxonomy = 'fruits';
// Modific default settings
{
// Name of a region icon
// Valid icon names are dot, circle, bookmark and cross
"region_icon": "circle",
// You can use your commands instead of plain "git" or "svn"
// e.g. "/usr/bin/git" or "C:\bin\git.exe"
"vcs": [
["svn", "/usr/bin/svn"],
function wptest() {
TESTROOT=/Users/nacin/Sites/tests
ARGS="--colors $@"
FORCE=0
DEBUG=0
REPLACE=$(echo $ARGS | sed -e 's/ -f\>//')
if [ "$ARGS" != "$REPLACE" ]; then
FORCE=1
ARGS=$REPLACE
<?php
add_action( 'init', function() {
register_taxonomy( 'some-taxonomy', 'post', array(
'show_ui' => true,
'rewrite' => false,
'public' => true,
'labels' => array(
'name' => 'Some Taxonomy',
'singular_name' => 'Some Taxonomy',
# custom login link
RewriteRule ^login$ http://localhost/whitelabel/wp-login.php [NC,L]