This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get the first image inserted into a post body | |
*/ | |
function get_first_inserted_image() | |
{ | |
global $post, $posts; | |
preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); | |
$first_img = $matches [1] [0]; | |
// Spew it out as an imege | |
$first_img = '<img alt="Blog Post Image" src="' . $first_img . '">'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Lazy load images inserted into the post body | |
* @link http://wptheming.com/2013/03/lazy-loading-images/ | |
*/ | |
function add_image_placeholders($content) | |
{ | |
// Don't lazyload for feeds | |
if (is_feed()) { | |
return $content; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Prints out array in human readable form, just a helper function | |
* @param array $arr The wanted array to be printed | |
* @return array The array in human readable form | |
*/ | |
function printr_func($arr) | |
{ | |
echo "<pre class='printr'><code>"; | |
print_r($arr); | |
echo "</code></pre>"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$str = preg_replace('/[^0-9.]+/', '', $str); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Colors | |
color_echo() { | |
# Parameters | |
local message=$1 | |
local color=${2-'default'} | |
local attribute=${3-'none'} | |
# Other vars | |
local color_type='3' | |
local color_code='0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Get paths to the js files to use in yepnope | |
* window.thePath is defined in footer | |
*/ | |
(function(yepnope) { | |
// Domain name | |
// var domain = window.location.host, | |
// origin = window.location.origin; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Detect a browser | |
* http://stackoverflow.com/questions/13478303/correct-way-to-use-modernizr-to-detect-ie | |
*/ | |
var BrowserDetect = | |
{ | |
init: function () | |
{ | |
this.browser = this.searchString(this.dataBrowser) || "Other"; | |
this.version = this.searchVersion(navigator.userAgent) || this.searchVersion(navigator.appVersion) || "Unknown"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
define(function() { | |
return { | |
/** | |
* Adds a class name to an element | |
* @param {element} el The target element | |
* @param {string} clazz The class names wanted to add | |
*/ | |
add: function addClass(el, clazz) { | |
var cn = el.className; | |
// Test for existance |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Gets a slug of a custom posty | |
* @param string $post_type The post type wanted | |
* @return string Slug for the post type | |
*/ | |
function slugger($post_type) | |
{ | |
if ($post_type) { | |
$post_type_data = get_post_type_object($post_type); | |
$post_type_slug = $post_type_data->rewrite['slug']; |
OlderNewer