A lightweight PHP class for creating custom options pages in the WordPress admin area.
Find a file
2026-02-09 08:58:03 +01:00
assets/js Add inline comments to media field script 2026-02-08 08:59:25 +01:00
class-option-page.php Add support for color input field 2026-02-08 09:16:07 +01:00
LICENSE Add the GPL license 2023-11-23 15:04:19 +01:00
README.md Update README with simplified usage examples 2026-02-09 08:58:03 +01:00

WordPress Options Page

A lightweight PHP class for creating custom options pages in the WordPress admin area.

Features

  • Text, email, url, number, color, checkbox, textarea, select fields
  • Group fields into sections
  • Media library integration via placeholder keywords
  • Automatic image size selection
  • Built-in sanitization per field type

Setup

require_once 'path/to/wp-options-page/class-option-page.php';

Usage

$option = new Option_Page( 'Site Settings', 'site_settings' );

$option->add_section( 'general', 'General' );

$option->add_field( 'text', 'site_tagline', array( 'label' => 'Tagline', 'section' => 'general' ) );
$option->add_field( 'color', 'brand_color', array( 'label' => 'Brand color', 'section' => 'general' ) );

$option->add_field( 'email', 'contact_email', array( 'label' => 'Email' ) );
$option->add_field( 'select', 'layout', array( 'label' => 'Layout', 'choices' => array( 'grid', 'list' ) ) );

License

GPL v2