Fix warning: Missing argument

do_action( 'after_setup_theme' ); doesn’t pass any parameter. You are cutting something of the length 0 after theme setup. Why?

Plus, your registration with add_action doesn’t tell WordPress that you want two parameters. The default is one parameter.

You don’t need this call at all. If you define the function in your functions.php it will be available in the loop.

Learn the Plugin API, it isn’t so hard. 🙂

Always prefix you functions. Otherwise your users may get fatal errors when someone else has written a function with the same name.

If your function does what I think it does, you may have a look at my function utf8_truncate(). No regex needed.