Skip to content

Conversation

@dev-alamin
Copy link
Contributor

Summary

This PR adds comprehensive validation for all plugin settings and improves the user experience on the settings page by slightly enlarging input fields.

Changes Introduced

New Method: validate_settings()

  • Added a dedicated method to validate all fields before saving.
  • Checks required fields:
  • Client ID
  • Client Secret
  • Sanitizes optional fields:
  • Whitelisted domains
  • Registration enabled checkbox
  • One Tap login and screen selection
  • Prevents saving empty or invalid values and displays proper admin notices using add_settings_error().

Integrated with register_setting():

register_setting(
    'wp_google_login',
    'wp_google_login_settings',
    [
        'sanitize_callback' => [ $this, 'validate_settings' ],
        'default'           => [],
    ] 
);
  • Input Field Enhancement
  • Added regular-text class to relevant input fields to make them slightly larger and improve readability.

Benefits

  • Ensures required fields cannot be left empty, preventing misconfiguration.
  • Improves UX on the settings page with more user-friendly input sizes.
  • Ready for future additions — new fields can be validated easily through validate_settings().

Testing

  • Manual testing done on a local setup:
  • Verified empty Client ID / Secret triggers admin error notice.
  • Verified optional fields save correctly.
  • Input field sizes updated as expected.

Notes

  • On next release: remember to add version number to this method: validate_settings()
  • Remember to regenerate/update .pot file as new error text added.
  • This PR does not include changes to composer/vendor or node_modules.
  • Only includes plugin PHP files and POT updates for new strings.
  • Fully backward-compatible with existing settings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant