Skip to content

Commit

Permalink
Make sure text_* options are always set from defaults.
Browse files Browse the repository at this point in the history
  • Loading branch information
dannyvankooten committed Nov 13, 2015
1 parent 9dfb7d7 commit d1f1cf6
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,24 @@ private function get_defaults() {
* @return array
*/
private function load_options() {
$defaults = $this->get_defaults();
$options = (array) get_option( $this->options_key, array() );
$options = array_merge( $this->get_defaults(), $options );
$options = array_merge( $defaults, $options );

// for BC with MailChimp Top Bar v1.2.3, always fill text option keys
$text_keys = array(
'text_subscribed',
'text_error',
'text_invalid_email',
'text_already_subscribed'
);

foreach( $text_keys as $text_key ) {
if( empty( $options[ $text_key ] ) && ! empty( $defaults[ $text_key ] ) ) {
$options[ $text_key ] = $defaults[ $text_key ];
}
}

return $options;
}

Expand Down

0 comments on commit d1f1cf6

Please sign in to comment.