Skip to content

Commit

Permalink
ThemeSettings: Check keys exist before using them
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryJones committed Aug 7, 2017
1 parent b881912 commit c5584ba
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/ThemeSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,15 @@ class ThemeSettings extends Brick
*/
public function apply()
{
// Change the theme settings defaults.
add_filter('genesis_theme_settings_defaults', [ $this, 'themeSettingsDefaults' ]);
if ($this->config->hasKey(self::DEFAULTS)) {
// Change the theme settings defaults.
add_filter('genesis_theme_settings_defaults', [$this, 'themeSettingsDefaults']);
}

// Force specific values to be returned.
$this->forceValues();
if ($this->config->hasKey(self::FORCE)) {
// Force specific values to be returned.
$this->forceValues();
}
}

/**
Expand All @@ -118,7 +122,7 @@ public function themeSettingsDefaults($defaults): array
{
$defaultsConfig = $this->config->getSubConfig(self::DEFAULTS);
foreach ($defaultsConfig->getArrayCopy() as $key => $value) {
$defaults[ $key ] = $value;
$defaults[$key] = $value;
}

return $defaults;
Expand Down

0 comments on commit c5584ba

Please sign in to comment.