get_option returns false causing array warnings
-
/** * Retrieves WP OAuth Server settings * * @param [type] $key [description] * * @return [type] [description] */ function wo_setting( $key = null ) { $default_settings = _WO()->defualt_settings; $settings = get_option( 'wo_options' ); $settings = array_merge( $default_settings, array_filter( $settings, function ( $value ) { return $value !== ''; } ) );This code throws warnings whenever
get_optionreturnsfalse, meaning the option did not already exist. This is a valid use case for theget_optionfunction. Thearray_filterthen throws a warning as you’re passing a boolean to a function that accepts an array. After that,array_mergethrows another warning as you’re then passing that same boolean to it when it expects an array.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘get_option returns false causing array warnings’ is closed to new replies.