Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions inc/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,28 @@ function register_settings_fields() {
'writing',
'tenup_isc_most_read_palette',
array(
'type' => 'boolean',
'show_in_rest' => true,
'default' => false,
'type' => 'boolean',
'show_in_rest' => true,
'default' => false,
'sanitize_callback' => function( $input ) {
// Accept only true, 'on', or 1
if ( $input === 'on' || $input === true || $input === 1 || $input === '1' ) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for raising this fix @aditigodse10

I found an issue, that when you try to save the settings with the checkbox unchecked, the Invalid value for Most Used Palette setting. error is shown on top of the page. This is because $input is null when it is unchecked. Can you fix that?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes sure, will do.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aditigodse10 checking in to see if you'll be able to updated based on the code review feedback above?

return true;
}

// If input is invalid, add an admin error message
add_settings_error(
'tenup_isc_most_read_palette',
esc_attr( 'invalid_input' ),
__( 'Invalid value for Most Used Palette setting.', 'insert-special-characters' ),
'error'
);

return false;
},
)
);


add_settings_section(
'tenup_isc_writing_section',
Expand Down
Loading