JW Player Plugin for WordPress does not register its shortcode like all other shortcodes, so strip_shortcodes()
will not know about it and not strip it. In the code there is a note that this is because it uses argument names with a .
in it, and WordPress does not support this.
There are probably multiple ways to solve this, but I would copy the relevant line from strip_shortcodes()
and integrate the regex from the plugin:
function custom_excerpt( $length, $more_text ) {
global $post;
$text = get_the_content();
$text = strip_shortcodes( $text );
// Strip JW Player shortcode too
$text = preg_replace( '/(.?)\[(jwplayer)\b(.*?)(?:(\/))?\](?:(.+?)\[\/\2\])?(.?)/s', '$1$6', $text );
$text = apply_filters('the_content', $text);
// Continue with the rest of your function ...