Skip to content

Instantly share code, notes, and snippets.

// Released under MIT license: http://www.opensource.org/licenses/mit-license.php
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);

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
@sharpmachine
sharpmachine / jetpack.php
Created January 4, 2013 21:18
Get Jetpack to work on localhost: Replace the wp-content/plugins/jetpack/jetpack.php with this:
<?php
/*
* Plugin Name: Jetpack by WordPress.com
* Plugin URI: http://wordpress.org/extend/plugins/jetpack/
* Description: Bring the power of the WordPress.com cloud to your self-hosted WordPress. Jetpack enables you to connect your blog to a WordPress.com account to use the powerful features normally only available to WordPress.com users.
* Author: Automattic
* Version: 2.0.4
* Author URI: http://jetpack.me
* License: GPL2+
@sharpmachine
sharpmachine / social-fields.php
Created January 8, 2013 19:41
Add this to functions.php to unset and add fields in the user profile section in the backend.
function extra_contact_info($contactmethods) {
unset($contactmethods['aim']);
unset($contactmethods['yim']);
unset($contactmethods['jabber']);
$contactmethods['facebook'] = 'Facebook';
@sharpmachine
sharpmachine / Fluid Video
Created October 4, 2013 16:47
Fluid video snippet for responsive designs
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px;
height: 0;
overflow: hidden;
iframe {
position: absolute;
top: 0;
@sharpmachine
sharpmachine / Fluid Container Height Based on its Background Image Height
Created October 30, 2013 15:26
This might be a solution to make fluid container height to follow it’s background image height. Same with the technique to make a fluid height video with pure CSS. Set the container height to `0` and create a large bottom (or top) padding based on it’s background image ratio to fake the container height:
.fluid-bg {
background:yellow url('img/400x150.jpg') no-repeat 50% 0;
background-size:100% auto;
height:0;
padding-top:37.5%; /* `150/400 × 100` */
}
@sharpmachine
sharpmachine / Short title
Last active December 31, 2015 04:59
Creates a short title from the_title
//Put in functions.php
function short_title($limit) {
global $post;
$title = get_the_title($post->ID);
if(strlen($title) > $limit) {
$title = substr($title, 0, $limit) . '...';
}
echo $title;
}
@sharpmachine
sharpmachine / no-update.php
Created January 1, 2014 18:03
Remove update notification for plugin
// Remove Update Notification
add_filter('site_transient_update_plugins', 'dd_remove_update_nag');
function dd_remove_update_nag($value) {
unset($value->response[ plugin_basename(__FILE__) ]);
return $value;
}
<?php global $woocommerce; ?>
<a class="cart-contents" href="<?php echo $woocommerce->cart->get_cart_url(); ?>" title="<?php _e('View your shopping cart', 'woothemes'); ?>"><?php echo sprintf(_n('%d item', '%d items', $woocommerce->cart->cart_contents_count, 'woothemes'), $woocommerce->cart->cart_contents_count);?> - <?php echo $woocommerce->cart->get_cart_total(); ?></a>
@sharpmachine
sharpmachine / gist:8835575
Created February 5, 2014 23:31
Affix.js fix for when html, body { height: 100% }
Change the following is affix.js
From
this.$element.offset({ top: document.body.offsetHeight - offsetBottom - this.$element.height() })
To
this.$element.offset({ top: scrollHeight - offsetBottom - this.$element.height() })