Skip to content

Instantly share code, notes, and snippets.

@tripflex
Last active September 23, 2018 18:48
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/db634bb0e9d422a4947770f6525e47f4 to your computer and use it in GitHub Desktop.
Save tripflex/db634bb0e9d422a4947770f6525e47f4 to your computer and use it in GitHub Desktop.
Remove sanitation on textarea field type for specific meta key when using WP Job Manager Field Editor (from frontend)
<?php
add_filter( 'job_manager_get_posted_textarea_field', function(){
return 'smyles_no_sanitize_textarea_metakey_handler';
});
function smyles_no_sanitize_textarea_metakey_handler( $key, $field ){
$dirty = isset( $_POST[ $key ] ) ? trim( $_POST[ $key ] ) : '';
$clean = isset( $_POST[ $key ] ) ? wp_kses_post( trim( stripslashes( $_POST[ $key ] ) ) ) : '';
// Replace 'some_meta_key' with the meta key you want to allow dirty (unsanitized) value to be saved to listing
return $key === 'some_meta_key' ? $dirty : $clean;
}
@tripflex
Copy link
Author

If you want to save value without sanitation in admin area use this code:
https://gist.github.com/tripflex/fca9ccda2315ab13bc390f41dcc6ba98

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment