Skip to content

Instantly share code, notes, and snippets.

@BFTrick
Created July 29, 2014 19:43
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 BFTrick/ca5b0773254818e03788 to your computer and use it in GitHub Desktop.
Save BFTrick/ca5b0773254818e03788 to your computer and use it in GitHub Desktop.
Sanitize the settings in your WooCommerce Integration
/**
* Init and hook in the integration.
*/
public function __construct() {
// do other constructor stuff first
// Filters.
add_filter( 'woocommerce_settings_api_sanitized_fields_' . $this->id, array( $this, 'sanitize_settings' ) );
}
/**
* Sanitize our settings
*/
public function sanitize_settings( $settings ) {
// We're just going to make the api key all upper case characters since that's how our imaginary API works
if ( isset( $settings ) &&
isset( $settings['api_key'] ) ) {
$settings['api_key'] = strtoupper( $settings['api_key'] );
}
return $settings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment