Meta Box
Support › MB Settings Page › Code Simplification
Is there a way to simplify this code or is this the correct way to map the data in the frontend?
<?php $field_id = 'hello_bar'; if ( !empty( $settings[$field_id] ) ) { echo '' . $settings[$field_id] . ''; } ?>
I think it would be better if you have default values for your settings, and then you don't need to check with if:
if
$default = array(); $settings = get_option( 'setting_id' ); $settings = wp_parse_args( $settings, $default ); // Then echo $settings[$field_id];
Thank-you 🙂