Skip to content

Instantly share code, notes, and snippets.

@jazzsequence
Last active September 10, 2018 19:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jazzsequence/160f34ee5c06d34f934a25f0630bacd8 to your computer and use it in GitHub Desktop.
Save jazzsequence/160f34ee5c06d34f934a25f0630bacd8 to your computer and use it in GitHub Desktop.
<?php
/**
* Save the screen option setting.
*
* @param string $status The default value for the filter. Using anything other than false assumes you are handling saving the option.
* @param string $option The option name.
* @param array $value Whatever option you're setting.
*/
function set_option( $status, $option, $value ) {
if ( isset( $_POST['wp_screen_options_nonce'] ) && wp_verify_nonce( sanitize_text_field( wp_unslash( $_POST['wp_screen_options_nonce'] ) ), 'wp_screen_options_nonce' ) ) {
if ( 'wordpress_screen_options_demo_options' === $option ) {
$value = isset( $_POST['wordpress_screen_options_demo'] ) && is_array( $_POST['wordpress_screen_options_demo'] ) ? $_POST['wordpress_screen_options_demo'] : []; // WPCS: Sanitization ok.
}
}
return $value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment