How to prevent escaping when saving HTML code in an option value?
stripslashes(wp_filter_post_kses(addslashes($_POST[‘sidebar_code’]))); but you should know that the kses filter is not 100% safe.
stripslashes(wp_filter_post_kses(addslashes($_POST[‘sidebar_code’]))); but you should know that the kses filter is not 100% safe.
The general rule, at least as espoused by Mark Jaquith, is sanitize on input, escape on output (the corollary to this rule being sanitize early, escape late). So: use sanitization filters (such as the kses() family) when storing untrusted data in the database, and use escaping filters (i.e. the esc_*() family) when outputting untrusted data … Read more
The MySQL documentation you cite actually says a little bit more than you mention. It also says, A “’” inside a string quoted with “’” may be written as “””. (Also, you linked to the MySQL 5.0 version of Table 8.1. Special Character Escape Sequences, and the current version is 5.6 — but the current Table 8.1. Special Character … Read more
To escape ‘ you simly need to put another before: ” As the second answer shows it’s possible to escape single quote like this: result will be If you’re concatenating SQL into a VARCHAR to execute (i.e. dynamic SQL), then I’d recommend parameterising the SQL. This has the benefit of helping guard against SQL injection … Read more
Use backslash “Workers\’_Compensation”; Inside a selector you would require 2 of them “Workers\\’_Compensation”; Check Fiddle
The specification defines the syntax for normal elements as: Normal elements can have text, character references, other elements, and comments, but the text must not contain the character U+003C LESS-THAN SIGN (<) or an ambiguous ampersand. Some normal elements also have yet more restrictions on what content they are allowed to hold, beyond the restrictions imposed by … Read more
If you use an appropriate class or library, they will do the escaping for you. Many XML issues are caused by string concatenation. XML escape characters There are only five: Escaping characters depends on where the special character is used. The examples can be validated at the W3C Markup Validation Service. Text The safe way is … Read more