From 5a43b80f84e37269e1145dc3457137e1bc42c419 Mon Sep 17 00:00:00 2001 From: Karin Taliga Date: Thu, 24 Jul 2014 22:56:35 +0200 Subject: [PATCH] Parse in default theme options in `thematic_get_theme_opt()` Use wp_parse_args() to use default theme options even when no options have been saved to the database yet. See #110 --- library/extensions/theme-options.php | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/library/extensions/theme-options.php b/library/extensions/theme-options.php index a91fb59..2715415 100644 --- a/library/extensions/theme-options.php +++ b/library/extensions/theme-options.php @@ -106,17 +106,18 @@ function thematic_get_wp_opt( $option_name, $default = false ) { */ function thematic_get_theme_opt( $opt_key, $echo = false ) { - $theme_opt = thematic_get_wp_opt( 'thematic_theme_opt' ); + $theme_opt = wp_parse_args( thematic_get_wp_opt( 'thematic_theme_opt', array() ), thematic_default_opt() ); - if ( isset( $theme_opt[$opt_key] ) ) { - if ( false === $echo ) { - return $theme_opt[$opt_key] ; - } else { - echo $theme_opt[$opt_key]; - } - } else { + if ( !isset( $theme_opt[$opt_key] ) ) { return false; } + + if ( false === $echo ) { + return $theme_opt[$opt_key]; + } else { + echo $theme_opt[$opt_key]; + } + }