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
<?php | |
/** | |
* Gets the current displayed url | |
* @strip array of key names to be stripped from the url | |
* @returns the url | |
*/ | |
protected function get_current_url( $strip = NULL ) { | |
$url = isset( $_SERVER["HTTPS"] ) && $_SERVER['HTTPS'] == "on" ? 'https://' : 'http://'; | |
$url .= ( strlen( $_SERVER["SERVER_NAME"] ) ? $_SERVER["SERVER_NAME"] : $_SERVER['HTTP_HOST']); | |
$url .= ( !in_array( strval( $_SERVER["SERVER_PORT"] ), array( "80", "443" ) ) ) ? $_SERVER["SERVER_PORT"] : ''; |
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
<?php | |
/** | |
* Gets the thumbnail resize sizes. | |
* | |
* These are the sizes defined by the media options page or custom added sizes, rather than the actual | |
* thumbnail image sizes. Falls back to thumbnail if size does not exist. Put your size parameter first | |
* through the 'post_thumbnail_size' filter if you want WordPress get_post_thumbnail behaviour. | |
* | |
* @size either string with thumbnail name size or array with dimensions | |
* @returns array with width, height and crop parameters |
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
<?php | |
/** | |
* Preferably the plugin is (in) a class, so use: | |
* add_action( array( &$this, 'textdomain_init'); | |
*/ | |
add_action( 'plugins_loaded', 'textdomain_init' ); | |
/** | |
* Initializes the textdomain for this plugin | |
*/ |
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
<?php | |
/** | |
* Changes the login logo and sets the appropiate sizes | |
*/ | |
function custom_login_logo() { | |
$path = '/images/logo_login.png'; | |
$size = getimagesize( get_template_directory() . $path ); | |
if ( $size ) : | |
echo '<style type="text/css"> | |
.login h1 a { |
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
<?php | |
/** | |
* Creates a human readable list of an array | |
* | |
* @param string[] $ranges array to list items of | |
* @param string $glue normal glue between items | |
* @param string $last glue between last two items | |
* | |
* @remarks works with 0, 1, 2 or 3+ items | |
* @returns string 'item1, item2, item3 or item4' |
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
.inline-block-hack { | |
/* Other css */ | |
zoom:1; /* << sets has layout */ | |
*display:inline; /* << but inline (with layout = inline-block) */ | |
} |
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
<?php | |
function regex_nested( $content ) { | |
$pattern = "/\[(?P<type>[^\]\s]+)(?P<props>[^\]]*?)((?P<tagclose>\s*\/\])|". | |
"(\](?P<inner>([^\[]*|\<\!\-\-.*?\-\-\>|(?R))*)\[\/\\1\s*\]))/sm"; | |
if ( !preg_match_all($pattern, $content, $matches, PREG_OFFSET_CAPTURE) ) | |
return $content; | |
$elements = array(); | |
foreach ( $matches[0] as $key => $match ) { | |
array_push( $elements, (object)array( |
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
<?php | |
function regex_attributes( &$element ) { | |
$matches = array(); | |
$pattern = '/\s*(?P<key>[^\s=\'"]+)(?:=(?:([\'"])(?P<value>[^\'"]+)[\'"])|\s|$)\s*/sm'; | |
if ( !preg_match_all( $pattern, $element->attributes_raw, $matches, PREG_OFFSET_CAPTURE ) ) | |
return; | |
foreach ( $matches[0] as $key => $match ) | |
$element->attributes[ $matches['key'][$key][0] ] = $matches['value'][$key][0]; | |
} |
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
<?php | |
/** | |
* Executes a prepared query | |
* | |
* @param string $query the query to execute | |
* @param string $types the types of the bind (s: string or d: integer for each value) | |
* @param mixed[] $values array of values | |
* @param string $error referenced error variable | |
* @returns null|boolean|integer|mixed[] the results | |
*/ |
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
$(document).ready( function(){ | |
// Thank you underscorejs | |
var debounce = function(func, wait, immediate) { | |
var timeout, result; | |
return function() { | |
var context = this, args = arguments; | |
var later = function() { | |
timeout = null; | |
if (!immediate) result = func.apply(context, args); |
OlderNewer