Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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 / 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+

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
// 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);