Skip to content

Instantly share code, notes, and snippets.

View ataylorme's full-sized avatar

Andrew Taylor ataylorme

View GitHub Profile
@ataylorme
ataylorme / replace-template-directory-with-stylesheet-directory
Created December 7, 2012 14:35
Replace bloginfo('template_directory') with bloginfo('stylesheet_directory') - Great for child themes
if( !function_exists('replace_template_directory_with_stylesheet_directory')):
function replace_template_directory_with_stylesheet_directory($text, $show){
if( $show == 'template_directory' )
$text = get_bloginfo('stylesheet_directory');
return $text;
}//end replace_template_directory_with_stylesheet_directory
endif; //replace_template_directory_with_stylesheet_directory function does not exist
add_filter('bloginfo_url', 'replace_template_directory_with_stylesheet_directory', 10, 2); //hook replace_template_directory_with_stylesheet_directory function to bloginfo_url info
@ataylorme
ataylorme / php-modernizr-html-tag-ie
Created November 21, 2012 16:25
PHP moderizr html tags for IE
<?php if( preg_match('/(?i)msie [1-6]/',$_SERVER['HTTP_USER_AGENT']) ){ ?>
<!-- the "no-js" class is for Modernizr. -->
<html class="ie ie6 no-js">
<?php } elseif( preg_match('/(?i)msie [7]/',$_SERVER['HTTP_USER_AGENT']) ){ //end if IE 6 ?>
<!-- the "no-js" class is for Modernizr. -->
<html class="ie ie7 no-js">
<?php } elseif( preg_match('/(?i)msie [8]/',$_SERVER['HTTP_USER_AGENT']) ){ //end if IE 7 ?>
<!-- the "no-js" class is for Modernizr. -->
<html class="ie ie8 no-js">
<?php } elseif( preg_match('/(?i)msie [9]/',$_SERVER['HTTP_USER_AGENT']) ){ //end if IE 8 ?>
@ataylorme
ataylorme / wufoo-webhook-zoho-crm
Last active October 13, 2015 02:28
Wufoo WebHook script to add lead to Zoho CRM
<?php
//verify handshake key
if( $_POST['HandshakeKey'] == 'ENTER YOUR HANDSHAKE KEY HERE' ):
//define $zoho_api_key
$zoho_api_key = "ENTER YOUR ZOHO API KEY HERE";
//define $data
$data = array ();
@ataylorme
ataylorme / updating-date-time-function
Created November 17, 2012 23:21
jQuery updating date time function
function updatingClock(selector, type) {
function currentDate() {
var currentDate = new Date;
var Day = currentDate.getDate();
if (Day < 10) {
Day = '0' + Day;
} //end if
var Month = currentDate.getMonth() + 1;
if (Month < 10) {
Month = '0' + Month;
@ataylorme
ataylorme / split-ul
Created November 17, 2012 23:20
Split <ul> with jQuery
$(document).ready(function() {
function splitSubmenu(ulSelector,maxNumItems) {
$(ulSelector).each(function () {
// get all child li tags
var list$ = $(this).children("li");
var num, nextAfter$, after$ = $(this);
// as long as the current list is too long, loop
@ataylorme
ataylorme / simple-accordion
Created November 17, 2012 23:17
Simple jQuery accordion
var headings = $('h3'),
paras = $('p');
paras.hide().eq(0).show();
headings.click(function() {
var cur = $(this); //save the element that has been clicked for easy referal
cur.siblings('p').slideUp(); //hide all the paragraphs
cur.next('p').slideDown(); //get the next paragraph after the clicked header and show it
})​;​
@ataylorme
ataylorme / set-screen-option-for-postpage-pagination-in-backend
Created November 17, 2012 23:16
Set screen option for post/page pagination in backend
function pages_per_col_admin(){
return 12;
}
add_filter( 'edit_page_per_page', 'pages_per_col_admin' );
@ataylorme
ataylorme / set-virtual-robots-to-no-index-on-test-domain
Created November 17, 2012 23:15
Set virtual robots to no index on test domain
if( stristr(get_bloginfo('url'), 'testdomain.com') !== FALSE)
update_option('blog_public',0);
@ataylorme
ataylorme / restricted-admin-menu-by-user-id
Created November 17, 2012 23:11
Restricted admin menu by user ID
/* ========== START RESTICTED ADMIN MENU ACCESS ========== */
if( !function_exists('my_restricted_menu_access') ):
function my_restricted_menu_access() {
global $menu;
//array of restricted menu items
$restricted = array( __('Dashboard'), __('Posts'), __('Media'), __('Links'), __('Pages'), __('Appearance'), __('Tools'), __('Users'), __('Settings'), __('Comments'), __('Plugins') );
end ($menu);
$current_user = wp_get_current_user();
//array of restricted user IDs
$restrictedUsers = array(2);
@ataylorme
ataylorme / remove-twentyeleven-theme-options-from-child-theme
Created November 17, 2012 23:08
Remove twentyeleven theme options from child theme
//Remove the custom options provided by the default twentyeleven theme.
add_action( 'after_setup_theme','remove_twentyeleven_options', 100 );
function remove_twentyeleven_options() {
remove_custom_background();
remove_custom_image_header();
remove_action('admin_menu', 'twentyeleven_theme_options_add_page');
}