Created
July 29, 2014 19:43
-
-
Save BFTrick/ca5b0773254818e03788 to your computer and use it in GitHub Desktop.
Sanitize the settings in your WooCommerce Integration
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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