Preserve options when using multiple pages and the settings api
See my previous paste for the whole class (minus this) http://kuttler.eu/code/wordpress-plugintheme-options-page/
<?php
class Foo {
[...]
/**
* Whitelist the Foo options
*
* @return none
*/
function register_settings () {
register_setting( 'Foo_options' , 'Foo', array( &$this, 'merge_options' ) );
}
/**
* Preserve options when using multiple pages
*
* @return merged data
*/
function merge_options( $data ) {
$existing = $this->options; // this contains get_option( 'Foo' );
if ( !is_array( $existing ) || !is_array( $data ) ) // something went wrong
return $data;
return array_merge( $existing, $data );
}
}
?>
1 comment
Reply