Is default functions like update_post_meta safe to use user inputs?

Is default functions like update_post_meta() safe to use user inputs? e.g. update_post_meta(76, ‘my_key’, $_GET[‘value’]) Or should I use $_GET[‘value’] = sanitize_text_field($_GET[‘value’]); before using update_post_meta(76, ‘my_key’, $_GET[‘value’]) 2 Answers 2 After upvoting @pieter’s answer…. In recent time I came to the realization that it is much better to handle “bad” data gracefully when it is used … Read more

Multiple register settings, with same option name – issue

I already posted this question in wordpress support forums here but I didn’t get any help and nor could I find a solution yet. As the title says, I am calling register_settings functions multiple times, for different groups of option, but for the same option name, as follows: // Create Basic Settings register_setting( ‘posttype_basic_group’, //option … Read more

How to save html and text in the database?

I have two fields. The first is for plain text (but with special characters) and the second for html content (wp_editor is used). Both are later needed for phpmailer. <textarea style=”width:100%;height:200px;” name=”doi-altbody”><?php echo $epn_doi_altbody; ?></textarea> wp_editor( $epn_doi_body, ‘doi-body’, array( ‘editor_height’ => ‘300px’ ) ); 1) How do i correctly secure them after submitting the form … Read more

where to apply “apply filters” and other Sanitization Functions

I got to learn something new today here on this post. I have code written for a Post widget → <?php class chimp_post_widget extends WP_Widget { function __construct() { //Create Widget parent::__construct( ‘post_display_widget’, esc_html__(‘The Post Widget’,’simplisto’), array( ‘classname’ => ‘post-widget’, ‘description’ => esc_html__(‘A Post Thumbnail Widget’, ‘simplisto’ ) ) ); } public function form( $instance … Read more

Coding a plugin on WordPress; when should I sanitize? [duplicate]

This question already has answers here: In Which Contexts are Plugins Responsible for Data Validation/Sanitization? (2 answers) Sanitize and data validation with apply_filters() function (1 answer) Closed 3 years ago. I am developing a custom plugin on WordPress for a client. Just a simple question: when I am using update_post_meta() and update_user_meta(), do I need … Read more

Must I serialize/sanitize/escape array data before using set_transient?

Everything is in the question. For a notices system to show warnings/errors in the admin, I´m using transient. When I published my first plugin, I received an email to ask me to sanitize/validate/escape data which inserts in database so… I´m doing a function to wrap set_transient() to do this but I´m not sure if in … Read more