Skip to content

Instantly share code, notes, and snippets.

@mauryaratan
Created March 11, 2013 08:40
Show Gist options
  • Save mauryaratan/5132836 to your computer and use it in GitHub Desktop.
Save mauryaratan/5132836 to your computer and use it in GitHub Desktop.
Useful WordPress functions for random needs.
<?php
function is_sidebar_active( $index = 1){
$sidebars = wp_get_sidebars_widgets();
$count = count($sidebars['sidebar-'.$index]);
if($count === 0){
return false;
}else{
return true;
}
}
/* Custom text length */
function stag_trim_text($text, $cut, $suffix = '...') {
if ($cut < strlen($text)) {
return substr($text, '0', $cut) . $suffix;
} else {
return substr($text, '0', $cut);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment