Skip to content

Instantly share code, notes, and snippets.

@markoheijnen
Last active December 14, 2015 15:29
Show Gist options
  • Select an option

  • Save markoheijnen/5108283 to your computer and use it in GitHub Desktop.

Select an option

Save markoheijnen/5108283 to your computer and use it in GitHub Desktop.
How to escape this? I'm now using sanitize_text_field(). Was first esc_attr().
<?php
function ajax_save_columns() {
global $wp_registered_sidebars;
header( "Content-Type: application/json" );
if( isset( $_POST['sidebar'], $_POST['amount_columns'] ) && ! empty( $wp_registered_sidebars[ $_POST['sidebar'] ] ) ) {
$options = get_option( 'horizontal_sidebar_columns', array() );
$options[ $_POST['sidebar'] ] = absint( $_POST['amount_columns'] );
update_option( 'horizontal_sidebar_columns', $options );
echo json_encode( array( 'success' => true ) );
}
else {
echo json_encode( array( 'success' => false ) );
}
die();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment