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 startsWith($haystack, $needle) | |
{ | |
$length = strlen($needle); | |
return (substr($haystack, 0, $length) === $needle); | |
} | |
function endsWith($haystack, $needle) | |
{ | |
$length = strlen($needle); | |
if ($length == 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
/* | |
* Replaces the default media-type icon library in wp-includes/images/crystal with wp-content/themes/{theme-name}/images/ | |
* WordPress default media types include archive, audio, code, document, interactive, spreadsheet, text, and video. | |
* | |
*/ | |
add_filter( 'icon_dir', 'wpdocs_theme_icon_directory' ); | |
add_filter( 'icon_dir_uri', 'wpdocs_theme_icon_uri' ); | |
/* | |
* Return my desired icon directory |
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
{ | |
"meta":{ | |
"version":"2.6.11", | |
"build":1509578938 | |
}, | |
"pods":{ | |
"527":{ | |
"id":527, | |
"name":"credit_card", | |
"label":"Credit Cards", |
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
Code Samples for Hooks And Filters Class | |
<?php | |
/* Filter the title to add a page number if necessary. | |
------------------------------------------------------------------------------------ */ | |
add_filter( 'wp_title', 'page_numbered_wp_title', 10, 2 ); | |
function page_numbered_wp_title( $title, $sep ) { |
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 | |
function ppsc_array_sort (&$array, $key) { | |
$sorter=array(); | |
$ret=array(); | |
reset($array); | |
foreach ($array as $ii => $va) { | |
$sorter[$ii]=$va[$key]; | |
} | |
asort($sorter); | |
foreach ($sorter as $ii => $va) { |
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_shortcode('wcs_count', 'wcs_count_shortcode_handler'); | |
function wcs_count_shortcode_handler($atts) | |
{ | |
// extract parameters | |
$parms = shortcode_atts(array( | |
'type' => 'posts', | |
'format' => 'true', | |
'extra' => '1', | |
), $atts); | |
$type = strtolower($parms['type']); |
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 munge_mail_shortcode( $atts , $content=null ) { | |
for ($i = 0; $i < strlen($content); $i++) $encodedmail .= "&#" . ord($content[$i]) . ';'; | |
return '<a href="mailto:'.$encodedmail.'">'.$encodedmail.'</a>'; | |
} | |
add_shortcode('mailto', 'munge_mail_shortcode'); |
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 echo apply_filters('the_content', get_post_meta($post->ID, 'your_custom_field_here', true)); ?> |
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 pdflink($attr, $content) { | |
if ($attr['href']) { | |
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $attr['href'] . '">'.$content.'</a>'; | |
} else { | |
$src = str_replace("=", "", $attr[0]); | |
return '<a class="pdf" href="http://docs.google.com/viewer?url=' . $src . '">'.$content.'</a>'; | |
} | |
} | |
add_shortcode('pdf', 'pdflink'); |
NewerOlder