Skip to content

Commit

Permalink
fix(settings): Fixed issue with first time settings save
Browse files Browse the repository at this point in the history
  • Loading branch information
merlijnvanlent committed Aug 23, 2024
1 parent ddedd72 commit 59c30a3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Includes/SettingsPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ public static function registerSettings(): void
'type' => 'array',
'sanitize_callback' => function ($value) {
return array_map(function (string $type) use ($value) {
return isset($value[$type]);
}, get_post_types(['public' => true])
);
return isset($value[$type]) && $value[$type];
}, get_post_types(['public' => true]));
},
'default' => [
'post' => true
Expand Down
4 changes: 1 addition & 3 deletions templates/admin/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
<?php settings_fields('vo-html-sitemap-settings') ?>
<?php do_settings_sections('vo-html-sitemap') ?>


<table class="form-table">
<tr>
<th scope="row">
Expand All @@ -16,8 +15,7 @@
</legend>
<?php foreach (get_post_types(['public' => true]) as $type): ?>
<label>
<input type="checkbox" name="vo-html-sitemap-post-types[<?php echo esc_attr( $type ) ?>]"
value="1" <?php echo checked(get_option('vo-html-sitemap-post-types')[$type] ?? false) ?>>
<input type="checkbox" name="vo-html-sitemap-post-types[<?php echo esc_attr( $type ) ?>]" <?php echo checked(get_option('vo-html-sitemap-post-types')[$type] ?: false) ?>>
<?php echo esc_html( get_post_type_object($type)->label ) ?>
</label>
<br>
Expand Down

0 comments on commit 59c30a3

Please sign in to comment.