Skip to content

Instantly share code, notes, and snippets.

@ryanmcgrath
ryanmcgrath / load_proper.js
Created January 5, 2011 22:16
How to properly branch loading of JS
/* Since script loading is dynamic, we take
a callback function with our loadScript call
that executes once the script is done downloading/parsing
on the page.
*/
var loadScript = function(src, callbackfn) {
var newScript = document.createElement("script");
newScript.type = "text/javascript";
newScript.setAttribute("async", "true");
newScript.setAttribute("src", src);
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@duanecilliers
duanecilliers / wp-bootstrap-walker-class.php
Created February 13, 2012 14:45
Extended Walker Class for Twitter Bootsrap Navigation Wordpress Integration
<?php
class Bootstrap_Walker_Nav_Menu extends Walker_Nav_Menu {
function start_lvl( &$output, $depth ) {
//In a child UL, add the 'dropdown-menu' class
$indent = str_repeat( "\t", $depth );
$output .= "\n$indent<ul class=\"dropdown-menu\">\n";
@BronsonQuick
BronsonQuick / functions.php
Created March 26, 2012 05:59
Add a Gravity Forms validation filter to check default values
<?php
// Append the Gravity Forms ID to the end of the filter so that the validation only runs on this form
add_filter('gform_validation_1', 'custom_validation');
function custom_validation($validation_result){
$form = $validation_result["form"];
foreach($form['fields'] as &$field){
/* Check that the value of the field that was submitted. e.g. the name="input_1" that is generated by Gravity Forms */
if($_POST['input_1'] == "Your First Name"){
// set the form validation to false
$validation_result["is_valid"] = false;
@gregrickaby
gregrickaby / functions.php
Created June 7, 2012 13:48
Allow HTML in WordPress Custom Menu Descriptions
/**
* Create HTML list of nav menu items and allow HTML tags.
* Replacement for the native menu Walker, echoing the description.
* This is the ONLY known way to display the Description field.
*
* @see http://wordpress.stackexchange.com/questions/51609/
*
*/
class Description_Walker extends Walker_Nav_Menu {
function soliloquy_slider_header_home() {
if (is_home()&& function_exists( 'soliloquy_slider' ) ) {
soliloquy_slider( '88' );
}
}
add_action('genesis_header', 'soliloquy_slider_header_home');
/**
* @author Brad Dalton - WP Sites
* @example http://wpsites.net/best-plugins/add-soliloquy-slider-in-header-of-any-theme/
*/
@JPry
JPry / git.sh
Created April 23, 2013 14:37
New Git repository
cd ~/wordpress/my_wordpress_app
git init .
git add . --all
git commit -m "initial commit"
@JPry
JPry / git.sh
Created April 23, 2013 15:00
force push to produciton
git push -f production master