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
<?php | |
/** | |
* Get menu items of nav menu attached to specified menu location | |
* | |
* @uses get_nav_menu_locations() | |
*/ | |
function pilau_get_menu_location_items( $location_slug, $max = 0 ) { | |
static $menu_locations = null; | |
if ( $menu_locations === null ) |
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
<?php | |
/** | |
* Get nav menu without markup containers | |
* | |
* @uses wp_nav_menu() | |
* @param string $menu The name given to the menu in Appearance > Menus | |
* @param integer $depth | |
* @return string | |
*/ |
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
<?php | |
/** | |
* Output WordPress content without first paragraph | |
* | |
* @uses get_the_content() | |
*/ | |
function pilau_the_content_without_first_paragraph() { | |
$content = trim( apply_filters( 'the_content', get_the_content() ) ); | |
$content = preg_replace( '#<[a-z]+>[^<]+</[a-z]+>#', '', $content, 1 ); |
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
<?php | |
/** | |
* Output first paragraph of WordPress content | |
* | |
* @uses get_the_content() | |
*/ | |
function pilau_the_content_first_paragraph() { | |
$content = trim( apply_filters( 'the_content', get_the_content() ) ); | |
preg_match( '#<[a-z]+>[^<]+</[a-z]+>#', $content, $matches ); |
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
<?php | |
/** | |
* List of downloads | |
* | |
* @uses get_children() | |
* @uses esc_url() | |
* @uses apply_filters() | |
* @uses get_attached_file() | |
* @uses pilau_format_filesize() (find on Gist) |
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
<?php | |
/** | |
* Return the formatted size of a file. | |
* | |
* @param string|int $input Either the path to a valid file, or a number in bytes | |
* @param string $default_output Optional. The string to output if the input can't be used (e.g. the file doesn't exist) | |
* @uses size_format() | |
* @return string The size, formatted | |
*/ |
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
<?php | |
/** | |
* Check if a WordPress page is "current", i.e. it's the current page or the ancestor of a current page | |
* | |
* @uses is_search() | |
* @uses get_post_type() | |
* @uses site_url() | |
* @uses get_permalink() | |
* @uses get_post_type_object() |
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
<?php | |
/** | |
* Fix height of embedded Flickr slideshows | |
*/ | |
add_filter( 'oembed_result', 'pilau_fix_flickr_slideshow_height', 10, 3 ); | |
function pilau_fix_flickr_slideshow_height( $html, $url, $args ) { | |
if ( strpos( $url, "flickr.com" ) !== false && substr( $url, -6 ) == "/show/" ) | |
$html = preg_replace( '/ height="([^"]+)"/', ' height="350"', $html ); | |
return $html; |
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
/** | |
* Image preloader | |
* | |
* @link http://engineeredweb.com/blog/09/12/preloading-images-jquery-and-javascript | |
*/ | |
var cache = []; | |
// Arguments are image paths relative to the current page. | |
function pilau_preload_images() { | |
var args_len, i, cache_image; | |
args_len = arguments.length; |
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
/** | |
* Scroll to an ID | |
* | |
* Example: | |
* <code>$( '#content' ).scrollView();</code> | |
* | |
* @link http://stackoverflow.com/questions/1586341/how-can-i-scroll-to-a-specific-location-on-the-page-using-jquery | |
*/ | |
jQuery.fn.scrollView = function () { | |
return this.each( function () { |