This file contains hidden or 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 an attachement image as lazy loaded img based on ID | |
* @param string $size Thumbnail, medium, large, original, or {custom size} | |
* @param string $class CSS class name for the img tag | |
* @param integer $attachment_id ID of the attachment | |
* @param string $attachment_id The custom src atrribute to use, default to data-echo | |
* @return string Lazyload friendly HTML img tag | |
*/ | |
function get_attachemt_lazy($size, $class, $attachment_id = "", $src_attr = "data-echo") | |
{ |
This file contains hidden or 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
/** | |
* Cut string to lenght and add prefix | |
* @param string $string The string to truncate | |
* @param int $length The amount of characters wanted | |
* @param string $prefix The prefix, default ... | |
* @return string The modified string | |
*/ | |
function str_truncater($string, $length, $prefix = '...') | |
{ | |
return strlen($string) > $length ? substr($string, 0, $length).$prefix : $string; |
This file contains hidden or 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
/** | |
* Strips http:// and https:// and www. and the trailing slash / from URL | |
* @param string $url The URL to be processed | |
* @return string Modified URL | |
*/ | |
function strip_crap_from_url($url) | |
{ | |
return preg_replace('/https?:\/\/|www.|\/$/', '', $url); | |
} |
This file contains hidden or 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
/** | |
* Returns a URL to the page where user was before this page | |
* @param string $domain The sites domain name | |
* @param string $exeption_path The path to go to if not referer is not your site | |
* @return string URL string | |
*/ | |
function pps_back_href($domain, $exeption_path) | |
{ | |
// Get the referer, aka where user comes | |
$referer = htmlspecialchars($_SERVER['HTTP_REFERER']); |
This file contains hidden or 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']; |
This file contains hidden or 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 hidden or 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() { | |
/** | |
* Get the closest element of a given element by class | |
* | |
* Take an element (the firt param), and traverse the DOM upward from it | |
* untill it hits the element with a given class name (second parameter). | |
* This mimics jquery's `.closest()`. | |
* | |
* @param {element} el The element to start from | |
* @param {string} clazz The class name |
This file contains hidden or 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
'use strict'; | |
define(function() { | |
/** | |
* Toggles a drawer panel | |
* | |
* Click a button and a drawer is shown, click elswhere and it's closed, | |
* open it when element inside the drawer is focused with a keyboard. | |
* | |
* @param {string} trigger ID, class, or element name to the button that toggles the drawer |
This file contains hidden or 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 hidden or 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; |