Skip to content

Instantly share code, notes, and snippets.

View allanemerson's full-sized avatar

Allan Emerson allanemerson

View GitHub Profile
@allanemerson
allanemerson / equalize-heights.js
Last active November 30, 2018 20:54
Equalize heights
/*
Usage:
equalizeHeights($('.your-target'));
Note: $w = $(window); and breakpoints = {}; defined elsewhere.
*/
var equalizeHeights = function($elements){
if( !$elements.length ) return;
@allanemerson
allanemerson / Pretty WP Login
Last active December 31, 2015 18:29
This will change the output of the log in/out links generated by Wordpress and allows for a pretty log in/out URL.
///// In your .htaccess: /////
RewriteRule ^login$ wp/wp-login.php
///// In your functions file: /////
function wplogin_filter( $url, $path, $orig_scheme ) {
// The logout link in the admin bar will does not include a direct.
// So, when you hit wp-login.php, the logout is completed and the page does a redirect to itself with 'loggedout=true' appended
// This results in a 404 with the new .htaccess rule in place. So, skip this filter on the admin logout link and all is well.
@allanemerson
allanemerson / gist:7042754
Created October 18, 2013 14:54
Bootstrap img css for IE 7/8
img {
width: auto\9;
height: auto;
max-width: 100%;
max-width: none\9;
vertical-align: middle;
border: 0;
-ms-interpolation-mode: bicubic;
}
@allanemerson
allanemerson / get-youtube-id.php
Created June 20, 2013 23:00
Gets the video ID out of the full youtube url or out of the "share" url.
// Extracts the video ID from a youtube URL
function get_youtube_id($url){
// share URL
if( strstr($url, 'youtu.be/') ){
$id = str_replace('http://youtu.be/', '', $url);
}else{
// full youtube URL
$query_string = array();
parse_str(parse_url($url, PHP_URL_QUERY), $query_string);
$id = $query_string["v"];
@allanemerson
allanemerson / gist:5810266
Last active December 18, 2015 16:19
Wordpress's excerpts kinda suck to customize. This function allows you to generate an excerpt at a desired word count with an optional "Read More" link. It also trims the result back to the last complete sentence to keep things pretty.
function custom_excerpt($limit = 55, $more = false){
// from wp_trim_excerpt() in /wp-includes/formatting.php
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
// wp already has a trim function
$text = wp_trim_words($text, $limit, ''); // pass an empty string in as $more, so we can define our own