Created
December 6, 2017 23:25
-
-
Save tripflex/04f4fa05726ce9f5aa5d20518c67cd82 to your computer and use it in GitHub Desktop.
Output script tag with URL from a field value when using WP Job Manager Field Editor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ^ the <?php above should only be in your functions.php file ONCE, at the top | |
// Because sanitation strips out script tags, if you want to output a custom script tag, you can use this filter to only have to specify the URL in a field | |
// The filter is field_editor_output_as_value_METAKEY | |
// Below this example assumes the meta key is "some_script_url" | |
add_filter( 'field_editor_output_as_value_some_script_url', 'smyles_output_some_custom_script_tag', 10, 4 ); | |
function smyles_output_some_custom_script_tag( $value, $meta_key, $listing_id, $args ) { | |
// Do not want to output if a value does not exist | |
if ( empty( $value ) ) { | |
return $value; | |
} | |
$output = '<script type="text/javascript" src="' . $value . '"></script>'; | |
return $output; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example surfline widget output:
https://gist.github.com/tripflex/01500fd95c0beedb69b40dd95d17b9bb
When configuring the auto output, you should set the output to VALUE ONLY (not standard)