Sanitizing output that contains quotes?

Another solution would be to put the style directly in the header, and only put the escaped values in, which would solve the double quote issue, but in the case that no styling has been set I’m left with an empty style in my element, and that also seems kinda unnecessary. You could e.g. check … Read more

What’s a safe / good way to output HTML safely within WordPress templates?

It depends on the context. In a template you’d just echo it: <div> <?php echo parse_html_for_images(); ?> </div> In a function you might want to concatenate it with something else: function wpse_303376_thumbnail() { return ‘<div>’ . parse_html_for_images() . ‘</div>’; } In a shortcode callback with lots other markup you might want to use output buffering, … Read more

textarea field is getting escaped for some unknown reason

WordPress always adds magic quotes regardless of server settings. This ensures consistency regardless of the environment. Even though magic quotes has been removed or deprecated from PHP, WordPress keeps this behaviour for backwards compatibility with older versions of PHP and plugins that were written with older versions of PHP in mind. If you want to … Read more

Does meta-data need to be sanitized?

Yes, it’s a good practice to sanitize input and escape output. It’s important to use the correct function, though, so that you don’t inadvertently mess up your data. Since it’s for a URL, use esc_url_raw() (it is specifically for db usage). (Note: it may seem odd using a function with the “esc_” stem for sanitizing, … Read more

confused about sanitize_email after is_email [duplicate]

Regarding the edited question, here’s another old Q&A, which might actually be a better reference, Should I sanitize an email address before passing it to the is_email() function?, especially @kaiser’s answer. And regarding kaiser’s Funny sidefact now as I had a look at the sources for both functions (is_email(), sanitize_email()), they are indeed basically the … Read more

How to escape $_GET and check if isset?

The proper way to do that is using filter_input(). Here is an example for using a custom sanitize function: $tab = filter_input( INPUT_GET, ‘tab’, FILTER_CALLBACK, [‘options’ => ‘esc_html’] ); $tab = $tab ?: ‘front_page_options’;

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)