Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tripflex
Created January 26, 2016 19:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tripflex/710e4f7e36253c0d4b14 to your computer and use it in GitHub Desktop.
Save tripflex/710e4f7e36253c0d4b14 to your computer and use it in GitHub Desktop.
Execute shortcode from field value (when using Auto Output, Widget, or Shortcode) THIS MAY CAUSE SECURITY VULNERABILITIES
<?php
// ^ the <?php above should only be in your functions.php file ONCE, at the top
//
// This code is provided for educational purposes only
//
// Executing shortcodes from user input is not support or recommended as this will
// allow users to input any shortcode even ones you may not want them to use.
// I do not support this and will not be held liable for anything done to your site
// as a result of executing shortcodes from user input. Use at your own risk.
// The filter is field_editor_output_as_value_METAKEY
// where you need to replace METAKEY with the actual meta key you want to filter the output for
// .... as you can see below you can also add multiple filters using the same function.
add_filter( 'field_editor_output_as_value_META_KEY_ONE', 'my_custom_exe_shortcode' );
add_filter( 'field_editor_output_as_value_META_KEY_TWO', 'my_custom_exe_shortcode' );
function my_custom_exe_shortcode( $value ){
if( empty( $value ) ) return $value;
return do_shortcode( $value );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment