execute function IF criteria is met - wordpress
<p>At the moment i have a function and a filter which shortens titles if they are longer than 25characters and appends the triple dot '...'</p>

<p>However, it appends the dots to all the titles. How can i get the following code to run only if the title is longer than 25 characters?</p>

<pre><code>function japanworm_shorten_title( $title ) {
    $newTitle = substr( $title, 0, 25 ); // Only take the first 25 characters

    return $newTitle . " &amp;hellip;"; // Append the elipsis to the text (...) 
}
add_filter( 'the_title', 'japanworm_shorten_title', 10, 1 );
</code></pre>
