Skip to content

Commit

Permalink
(#46) Fixing 3.0.0 upgrade bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ErinMorelli committed Jan 30, 2017
1 parent ac9ca0e commit d35edef
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
18 changes: 17 additions & 1 deletion em-beer-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,23 @@ function EMBM_Plugin_activate()
'embm_group_slug' => 'group',
'embm_reviews_count_single' => '5'
);
update_option('embm_options', $defaults);

// Get any existing options
$options = get_option('embm_options');

// If options exist, fill in any missing with defaults
if (is_array($options)) {
foreach ($defaults as $key => $value) {
if (!array_key_exists($key, $options)) {
$options[$key] = $value;
}
}
} else {
$options = $defaults;
}

// Save the updated options
update_option('embm_options', $options);

// Load core files
if (!function_exists('EMBM_Core_beer')) {
Expand Down
6 changes: 3 additions & 3 deletions includes/embm-output.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,17 +428,17 @@ function EMBM_Output_Rating_stars($rating_score)

if ($full_count > 0) {
foreach (range(1, $full_count) as $full_star) {
$stars .= file_get_contents(EMBM_PLUGIN_URL.'assets/img/star-full.svg');
$stars .= file_get_contents(EMBM_PLUGIN_DIR.'assets/img/star-full.svg');
}
}

if ($fraction) {
$stars .= file_get_contents(EMBM_PLUGIN_URL.'assets/img/star-'.$fraction.'.svg');
$stars .= file_get_contents(EMBM_PLUGIN_DIR.'assets/img/star-'.$fraction.'.svg');
}

if ($empty_count > 0) {
foreach (range(1, $empty_count) as $empty_star) {
$stars .= file_get_contents(EMBM_PLUGIN_URL.'assets/img/star-empty.svg');
$stars .= file_get_contents(EMBM_PLUGIN_DIR.'assets/img/star-empty.svg');
}
}

Expand Down

0 comments on commit d35edef

Please sign in to comment.