Last active
December 28, 2020 12:15
-
-
Save vishalkakadiya/0a81e97dcb1ec21704a3cd6b78dacdef to your computer and use it in GitHub Desktop.
Bypass sanitization with FieldManager's TextArea field which will allows to add HTML in metabox/metafield
This file contains hidden or 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 | |
/** | |
* Sometime we need to take input from user with Field Manager's TextArea field, FM is using sanitize_text_field](https://api.fieldmanager.org/source-class-Fieldmanager_Field.html#123) | |
* So below is the code to bypass or use your own validation logic. | |
*/ | |
$fm = new \Fieldmanager_TextArea( | |
array( | |
'name' => '_vk_videoembed_manual', | |
'sanitize' => 'validate_embed_field', // Link your own validation function here. | |
) | |
); | |
$fm->add_meta_box( __( 'Embed Code(Overrides Above `Video URL`):', 'slang' ), array( 'post' ), 'side', 'high' ); | |
/** | |
* Bypass string validation/or add your own validation for embed field. | |
* | |
* @param string $value Field value. | |
* | |
* @return string Field value. | |
*/ | |
function validate_embed_field( $value ) { | |
// You can add your own validation here to validate $value of the field. | |
return $value; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment