Custom page with variables in url. Nice url with add_rewrite_rule

I think the add_rewrite_tag() is not needed, and can be replaced with adding the variables to the public query vars directly: // Either directly (in your init hook): $wp->add_query_var( ‘var1’ ); $wp->add_query_var( ‘var2’ ); // Or via a filter: add_filter( ‘query_vars’, ‘wpse12965_query_vars’ ); function wpse12965_query_vars( $query_vars ) { $query_vars[] = ‘var1’; $query_vars[] = ‘var2’; return … Read more

What is the difference between wp_strip_all_tags and wp_filter_nohtml_kses?

The wp_strip_all_tags() function will remove all HTML, including the content of script and style tags. The PHP strip_tags() function largely does the same thing, except it won’t eliminate the content of script and style tags. WP’s wp_strip_all_tags() function uses this after eliminating the scripts and styles manually. The wp_filter_nohtml_kses() function uses kses to remove all … Read more

Sanitize and data validation with apply_filters() function

There’s some confusion here, because not all of these are validation, there are 2 others that are necessary to understand what’s appropriate: validation sanitisation escaping Sanitisation Sanitisation makes things clean and well formed This cleans up the data, e.g. trimming trailing spaces, removing letters in a number field, making an all lowercase field all lowercase, … Read more

How safe / sanitized is wp_insert_posts()?

You don’t have to do anything. On WP load: ‘init’ hook -> kses_init() -> kses_init_filters() Later: wp_insert_post() -> sanitize_post() -> sanitize_post_field() -> ‘content_save_pre’ -> wp_filter_post_kses() Similarly for post titles, comment text etc. Conclusion: wp_insert_post() is very sanitized. 🙂

Data sanitization: Best Practices with code examples

This codex page explains it pretty well I think. The most important and commonly used function is probably esc_attr. Take this example: <a href=”https://wordpress.stackexchange.com/questions/48660/<?php print $author_url; ?>” title=”<?php print $author_name; ?>”> <?php print $author_name; ?> </a> If $author_name contains a ” character you get your attribute closed, and if that character is followed by onclick=”do_something();” … Read more

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