​This is a great custom plugin we came across that will automatically format any field in ExpressionEngine.

Create a “util” folder and a php file named pi.util.php for the plugin.

Put the “util” folder in expressionengine/third_party/

PHP Snippet

<?php
$plugin_info       = array(
    'pi_name'        => 'Utility Functions',
    'pi_version'     => '1.0.0',
    'pi_author'      => 'Lea Hayes',
    'pi_author_url'  => 'http://leahayes.co.uk',
    'pi_description' => 'A selection of utility functions for use in templates.',
    'pi_usage'       => util::usage()
);

class util {

    public function htmlspecialchars() {
        $this->EE = &get_instance();
        return htmlspecialchars($this->EE->TMPL->tagdata);
    }

    public static function usage() {
        return '{exp:util:htmlspecialchars}Place unescaped content here...{/exp:util:htmlspecialchars}';
    }

}
/* End of file pi.util.php */
/* Location: ./system/third_party/util/pi.util.php */
          

ExpressionEngine Snippet

{exp:channel:entries channel="blog"}


{exp:util:htmlspecialchars}{meta_description}{/exp:util:htmlspecialchars}