Tools/WordPress/WordPress Settings API Generator
WordPress Tool

WordPress Settings API Generator

Generate safe WordPress Settings API starter code with register_setting(), sanitization and optional REST exposure.

Runs locally in your browser

Starter code only. Match sanitization and REST schemas to the data your plugin accepts.

Generate safer WordPress settings code

This generator creates starter PHP for plugin settings using register_setting(). It helps you choose a settings group, option name, value type, sanitization callback and optional REST exposure.

Why use the Settings API?

WordPress provides a supported settings workflow instead of requiring plugins to process arbitrary admin form submissions themselves. A complete screen can combine register_setting(), settings sections and fields, settings_fields(), do_settings_sections() and submit_button().

Sanitization must match the data

The generator suggests common callbacks for simple scalar values. URLs, emails, arrays, constrained choices and structured objects need validation designed for the actual accepted data.

REST API considerations

Enabling show_in_rest can expose a registered setting through WordPress REST settings infrastructure. Complex array settings require an item schema, and settings should not be exposed merely for convenience.

How to verify the result

  1. Test on staging.
  2. Save expected and deliberately invalid values.
  3. Confirm the stored option is sanitized.
  4. If REST exposure is enabled, verify schema and permissions.
  5. Reload the admin page and confirm saved values render correctly.

Related: Try the Plugin Header Generator, PHP Requirements Checker and Debug Log Analyzer.