Skip to content

Commit

Permalink
Address review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mukeshpanchal27 committed Oct 25, 2023
1 parent 1bc96bc commit 678e534
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
7 changes: 1 addition & 6 deletions assets/js/plugin-check-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,6 @@
canRunChecks();
pluginsList.addEventListener( 'change', canRunChecks );

/**
* Saves the user settings.
*
* @since n.e.x.t
*/
function saveUserSettings() {
const selectedCategories = [];

Expand All @@ -52,7 +47,7 @@

// Join the selected category slugs with '__' and save it as a user setting.
const settingValue = selectedCategories.join( '__' );
window.setUserSetting( 'category_preferences', settingValue );
window.setUserSetting( 'plugin_check_category_preferences', settingValue );

Check failure on line 50 in assets/js/plugin-check-admin.js

View workflow job for this annotation

GitHub Actions / Lint

Replace `·'plugin_check_category_preferences',·settingValue·` with `⏎↹↹↹'plugin_check_category_preferences',⏎↹↹↹settingValue⏎↹↹`
}

// Attach the saveUserSettings function when a category checkbox is clicked.
Expand Down
4 changes: 3 additions & 1 deletion includes/Admin/Admin_Page.php
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,9 @@ public function render_page() {

$categories = Check_Categories::get_categories();

$user_settings = get_user_setting( 'category_preferences' );
// Get user settings for category preferences and set a default value to check all categories by default.
$user_settings = get_user_setting( 'plugin_check_category_preferences', 'all_categories' );
$user_settings = explode( '__', $user_settings );

require WP_PLUGIN_CHECK_PLUGIN_DIR_PATH . 'templates/admin-page.php';
}
Expand Down
13 changes: 1 addition & 12 deletions templates/admin-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,7 @@
<fieldset>
<legend class="screen-reader-text"><?php echo esc_html( $category ); ?></legend>
<label for="<?php echo esc_attr( $category ); ?>">
<?php
$checked = false;
if ( $user_settings ) {
$selected_categories = explode( '__', $user_settings );
if ( in_array( $category, $selected_categories, true ) ) {
$checked = true;
}
} else {
$checked = true;
}
?>
<input type="checkbox" id="<?php echo esc_attr( $category ); ?>" name="categories" value="<?php echo esc_attr( $category ); ?>"<?php echo ( $checked ? ' checked="checked"' : '' ); ?> />
<input type="checkbox" id="<?php echo esc_attr( $category ); ?>" name="categories" value="<?php echo esc_attr( $category ); ?>" <?php checked( in_array( 'all_categories', $user_settings, true ) || in_array( $category, $user_settings, true ) ); ?> />
<?php echo esc_html( ucfirst( str_replace( '_', ' ', $category ) ) ); ?>
</label>
</fieldset>
Expand Down

0 comments on commit 678e534

Please sign in to comment.