Skip to content

Commit

Permalink
Fix for setting new default values
Browse files Browse the repository at this point in the history
  • Loading branch information
XjSv committed Nov 14, 2024
1 parent e6c038a commit 4a12c96
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 92 deletions.
14 changes: 9 additions & 5 deletions includes/class.cooked-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,14 @@ public static function get() {
foreach ( $tab['fields'] as $name => $field ) {
if ( $field['type'] == 'nonce' || $field['type'] == 'misc_button' ) continue;

if ( $field['type'] == 'checkboxes' && $cooked_settings_saved && $version_compare >= 0 ) {
$_cooked_settings[$name] = isset($_cooked_settings[$name]) ? $_cooked_settings[$name] : [];
} else {
$_cooked_settings[$name] = isset($_cooked_settings[$name]) ? $_cooked_settings[$name] : ( isset( $field['default'] ) ? $field['default'] : false );
if ( $cooked_settings_saved && $version_compare >= 0 ) {
if ( $field['type'] == 'checkboxes' ) {
$_cooked_settings[$name] = isset($_cooked_settings[$name]) ? $_cooked_settings[$name] : ( isset( $field['default'] ) ? $field['default'] : [] );
} else {
$_cooked_settings[$name] = isset($_cooked_settings[$name]) ? $_cooked_settings[$name] : ( isset( $field['default'] ) ? $field['default'] : false );
}

// Update the settings only if the version has changed.
$update_settings = true;
}
}
Expand Down Expand Up @@ -385,7 +389,7 @@ public static function pages_array( $choose_text, $none_text = false ) {
if( !empty($pages) ) {
$page_array[0] = $choose_text;
foreach ($pages as $_page) {
$page_array[$_page->ID] = $_page->post_title;
$page_array[$_page->ID] = $_page->post_title . ' (ID:' . $_page->ID . ')';
}
} elseif ( $none_text ) {
$page_array[0] = $none_text;
Expand Down
Loading

0 comments on commit 4a12c96

Please sign in to comment.