WordPress oEmbed W3C Validation

The class-oembed.php file reveals some of the available filters regarding the oEmbeds. We can use the oembed_result or oembed_dataparse filters to modify the HTML fetched from Vimeo before it’s cached in the post meta. Here’s an example for the latter: add_filter( ‘oembed_dataparse’, function( $return, $data, $url ) { // Target only Vimeo: if( is_object( $data … Read more

Does wp_insert_post validate the input?

The short answer; absolutely. wp_insert_post() will only SQL escape the content. Use the KSES library & wp_kses() to filter out the nasties, or esc_html() to escape all HTML. Most importantly, check out the codex on data validation (read: sanitization). A Note On KSES: Use wp_filter_kses() or wp_kses_data() to apply the same KSES rules as post … Read more

Server side validation

You can capture the form submission by creating a small plugin / or by editing your theme functions file, and you can do this using a ajax hook. In the plugin you would load this on the edit post page: jQuery(document).ready(function(){ jQuery(‘#post’).submit(function(){ var request = jQuery(this).serializeArray(); request.push({name: ‘action’, value: ‘check_some_stuff’}); jQuery.post(ajaxurl, request, function(response){ if(response.error){ response … Read more

Validating input using java.util.Scanner

Overview of Scanner.hasNextXXX methods java.util.Scanner has many hasNextXXX methods that can be used to validate input. Here’s a brief overview of all of them: hasNext() – does it have any token at all? hasNextLine() – does it have another line of input? For Java primitives hasNextInt() – does it have a token that can be parsed into an int? Also available are hasNextDouble(), hasNextFloat(), hasNextByte(), hasNextShort(), hasNextLong(), and hasNextBoolean() As bonus, there’s … Read more