I’d simply set a flag as second input argument for the function:
function new_wp_trim_excerpt( $text, $case="plain" )
{
switch ( $case )
{
default :
case 'plain' :
// do stuff - your function so far
break;
case 'image' :
break;
}
}
Notes:
- Avoid names like
class="moarplz"
. It’s hard to read for others and hard for yourself in a year. - Never
count
inside anif/for/while/foreach/else/elseif
statement – it’s up to 5 times slower than counting it in the line before.