View gist:4359828
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 | |
add_shortcode('wp_caption', 'fixed_img_caption_shortcode'); | |
add_shortcode('caption', 'fixed_img_caption_shortcode'); | |
function fixed_img_caption_shortcode($attr, $content = null) { | |
// New-style shortcode with the caption inside the shortcode with the link and image tags. | |
if ( ! isset( $attr['caption'] ) ) { | |
if ( preg_match( '#((?:<a [^>]+>\s*)?<img [^>]+>(?:\s*</a>)?)(.*)#is', $content, $matches ) ) { | |
$content = $matches[1]; | |
$attr['caption'] = trim( $matches[2] ); | |
} |
View functions.php
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
// --------------------------------------------------------- | |
// ---------- WordPress functions.php boilerplate ---------- | |
// --------------------------------------------------------- | |
<?php | |
// ---------------------------------------------------------------------------- | |
// ---------- Translations can be filed in the /languages/ directory ---------- | |
// ---------------------------------------------------------------------------- | |
load_theme_textdomain( 'html5reset', TEMPLATEPATH . '/languages' ); |
View gist:4173416
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
// Add customer user fields in wp admin | |
function modify_contactmethods( $contactmethods ) { | |
// Remove unwanted fields // | |
unset($contactmethods['aim']); | |
unset($contactmethods['yim']); | |
unset($contactmethods['jabber']); | |
// Add new fields // | |
$contactmethods['twitter_handle'] = 'Twitter Handle (@)'; | |
$contactmethods['linkedin_url'] = 'LinkedIn Profile (URL)'; | |
return $contactmethods; |
View is_blog.php
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
function is_blog () { | |
global $post; | |
$posttype = get_post_type($post ); | |
return ( ((is_archive()) || (is_author()) || (is_category()) || (is_home()) || (is_tag())) && ( $posttype == 'post') ); | |
} | |
Usage: | |
<?php if (is_blog()) { echo 'You are on a blog page'; } ?> |
View gist:3837750
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
// If "i" is equal to 5, skip the echo statement below and continue evaluating the condition. | |
<?php | |
for($i=0; $i<=10; $i++) { | |
echo $i; | |
if($i==10) { | |
continue; | |
} | |
echo ", "; | |
} |
View gist:3837604
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 | |
for($i=0; $i<10; $i++) { | |
include("file.php"); | |
} | |
?> |
View gist:3837726
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
// If "i" is equal to 10, break out of the loop and ignore the echo statement below. | |
<?php | |
for($i=0; $i<=10; $i++) { | |
echo $i; | |
if($i==10) { | |
break; | |
} | |
echo ", "; | |
} |
View gist:3837644
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 | |
$i=0; | |
while($i<10) { | |
include("test.php"); | |
$i++; | |
} | |
?> |
View wp_functions_customUserFields.php
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
// ---------------------------------------------------------- | |
// ---------- Add customer user fields in wp admin ---------- | |
// ---------------------------------------------------------- | |
<?php | |
function modify_contactmethods( $contactmethods ) { | |
// Remove unwanted fields // | |
unset($contactmethods['aim']); | |
unset($contactmethods['yim']); | |
unset($contactmethods['jabber']); | |
// Add new fields // |
View wp_functions_excerptElipsis.php
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
// ------------------------------------------------------------------- | |
// ---------- Change default [...] string for post excerpts ---------- | |
// ------------------------------------------------------------------- | |
<?php | |
function new_excerpt_more($more) { | |
return '{...}'; | |
} | |
add_filter('excerpt_more', 'new_excerpt_more'); | |
?> |
NewerOlder