I am using this part of the code in my WordPress plugin to update the option.

update_option('button_loc_shop_page', $_POST['button_loc_shop_page']);

I want to sanitize this. How can I properly sanitize it? Any comments or pointers would be really appreciated.

  • Register your setting and you can define the callback function that receives the data during the saving operation.
    – t31os
    Commented Nov 5, 2022 at 8:49
  • Hi, I have tried to do that, but couldn't find the way to sanitize it, because here the updat_option is using a POST request as a value. So, not quite sure how can I do that. Can you please share a rough line of code on how can I achieve that? Thanks!! Commented Nov 6, 2022 at 7:51
  • There's an answer posted with a link to sanitization functions.
    – t31os
    Commented Nov 6, 2022 at 12:45

1 Answer 1


You can use sanitize the data with sanitize functions in reference below.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.