Skip to content

Instantly share code, notes, and snippets.

View jasontucker's full-sized avatar

Jason Tucker jasontucker

View GitHub Profile
@jasontucker
jasontucker / gist:3981506
Created October 30, 2012 16:54
jQuery - Prevent multiple submit of your form
//Multiple submissions of the same form is definitely one of the most common problem seen when working with web forms. //Here’s a super useful piece of code to prevent multiple submissions of the same form.
$(document).ready(function() {
$('form').submit(function() {
if(typeof jQuery.data(this, "disabledOnSubmit") == 'undefined') {
jQuery.data(this, "disabledOnSubmit", { submited: true });
$('input[type=submit], input[type=button]', this).each(function() {
$(this).attr("disabled", "disabled");
});
return true;
@jasontucker
jasontucker / gist:4008744
Created November 3, 2012 20:58
Wordpress - Create new folder in /uploads directory on activation.
//Here’s a code snippet that allows your plugin to create a new folder in the /uploads directory on activation. Could be useful if your plugin needs to allow imports or uploads and you want them stored in a separate directory.
function myplugin_activate() {
$upload = wp_upload_dir();
$upload_dir = $upload['basedir'];
$upload_dir = $upload_dir . '/mypluginfiles';
if (! is_dir($upload_dir)) {
mkdir( $upload_dir, 0700 );
}
@jasontucker
jasontucker / folderupload.php
Created November 4, 2012 03:22
WordPress - Create a new folder in /uploads folder on plugin activation
//Here’s a code snippet that allows your plugin to create a new folder in the /uploads directory on activation. Could be useful if your plugin needs to allow imports or uploads and you want them stored in a separate directory.
function myplugin_activate() {
$upload = wp_upload_dir();
$upload_dir = $upload['basedir'];
$upload_dir = $upload_dir . '/mypluginfiles';
if (! is_dir($upload_dir)) {
mkdir( $upload_dir, 0700 );
}
@jasontucker
jasontucker / filter_generator_pages_feeds.php
Created November 6, 2012 20:19
Remove generator WordPress version number from pages and feeds
//Simply paste the code snippet below in your functions.php file:
add_filter('the_generator', 'digwp_complete_version_removal');
function digwp_complete_version_removal() {
return '';
}
@jasontucker
jasontucker / function.php
Created November 17, 2012 07:42
Display template name of the page you are currently on at the top of the page.
//WordPress uses a variable $template to store the template being used. Therefore, for debugging (not recommended for a live site), you can put this in your theme's functions.php:
add_action('wp_head', 'show_template');
function show_template() {
global $template;
print_r($template);
}
@jasontucker
jasontucker / gist:4134188
Created November 23, 2012 05:58
Allow shortcodes in sidebars
add_filter('widget_text', 'do_shortcode');
@jasontucker
jasontucker / plugin.php
Created November 28, 2012 00:41
Genesis Tabs with first tab showing all categories.
<?php
/*
Plugin Name: Genesis Tabs
Plugin URI: http://www.studiopress.com/plugins/genesis-tabs
Description: Genesis Simple Tabs extends the Featured Post widget to create a simple tabbed area.
Author: StudioPress
Author URI: http://www.studiopress.com
Version: 0.9.0
@jasontucker
jasontucker / gist:4400339
Created December 28, 2012 18:04
Use SFC with Yoast SEO.
<?php
remove_action('wp_head','sfc_base_meta'); // Removes Simple Facebook Connect Meta
remove_action('wp_head','sgc_base_meta');// Removes Simple Google Connect Meta
?>
<?php
function twentyten_custom_scripts() {
add_action('template_redirect', 'twentyten_custom_scripts');
if( is_page('Contact')) {
// how is_page works http://codex.wordpress.org/Function_Reference/is_page
// is_page();
// When any single Page is being displayed.
// is_page(42);
// When Page 42 (ID) is being displayed.
@jasontucker
jasontucker / gist:4504080
Last active December 10, 2015 22:38 — forked from billerickson/gist:1325515
Bill's code resulted in having the <span></span> be included in the id="title" which was problematic for the site I as working on my method breaks up the title a bit more to not including the <span></span> in the title attribute.
<?php
/**
* Set a span around the letters "WP" in Site Title
* @author Jason Tucker
* Based on code by Bill Erickson
*
* Why fork?
* Bill's code resulted in having the <span></span>
* be included in the id="title" which was problematic
* for the site I as working on my method breaks up the