In the plugin_options_validate()
function the return value of get_option( 'plugin_options' )
is never used.
Let’s step through the function by adding some comments:
// Retrieve the options.
$options = get_option('plugin_options');
// Replace the options without checking if
// trim( $input['text_string'] ) and trim( $input['text_string_name'] )
// actually return strings and if $input['text_string'] and
// $input['text_string_name'] have anything in them.
$options['text_string'] = trim($input['text_string']);
$options['text_string_name'] = trim($input['text_string_name']);
// This part never runs. `$options` will never be empty!
if ( empty( $options ) ) {
$options['text_string'] = '[email protected]';
$options['text_string_name'] = 'Polyindustry';
}
Effectively, this function is the same thing you have written:
// Validate options.
function plugin_options_validate( $input ) {
$options['text_string'] = trim( $input['text_string'] );
$options['text_string_name'] = trim( $input['text_string_name'] );
return $options;
}