Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/Ahondev/portfolio-v2/llms.txt

Use this file to discover all available pages before exploring further.

The WP SSR framework provides a fluent PHP API for creating Advanced Custom Fields (ACF) options pages — persistent, site-wide settings stored in wp_options and accessible anywhere in PHP via get_field('field_name', 'option'). Options pages are defined in configuration/pages.php and automatically loaded by the framework at boot time through Option::init().

The Option Class

Options pages are created and configured through the static Option::create() factory, which returns a chainable Option instance. Once all tabs and fields are defined, call ->make() to register the ACF field group bound to the options page.

Option::create()

Option::create(string $slug, string $title, string $icon, int $position): Option
Registers an ACF options page in the WordPress admin menu and returns a new Option instance for chaining.
$slug
string
required
The unique menu slug for the options page. Used as the ACF location identifier and as the URL segment in the admin (/wp-admin/admin.php?page={slug}).
'site_options'
$title
string
required
The page title shown in the browser tab and at the top of the options page in WP Admin.
'Options'
$icon
string
required
A Dashicons identifier without the dashicons- prefix. The framework prepends dashicons- automatically.
'admin-settings'  // becomes dashicons-admin-settings
$position
int
required
The numeric position in the WordPress admin sidebar menu. Lower numbers appear higher. Standard WordPress items occupy positions 2, 4, 5, 10, 20, 25, 60, 65, 70, 75, and 80 — choose a gap to avoid conflicts.
12

Option->Tab()

Tab(string $title, array $fields): Option
Groups a set of ACF fields under a named tab on the options page. Tabs are rendered by ACF as clickable tab headers. Calling Tab() multiple times appends additional tabs.
$title
string
required
The display label for the tab.
$fields
array
required
An array of Extended ACF field objects. Common field types available from the Extended\ACF\Fields namespace:
ClassDescription
TextSingle-line text input
TextareaMulti-line text
ImageMedia library image picker
URLURL input with validation
SelectDropdown selection
RepeaterRepeatable group of sub-fields
WYSIWYGEditorFull TinyMCE rich-text editor
Fields are constructed with FieldClass::make(string $label, string $name).

Option->make()

make(): void
Finalises the options page by calling register_extended_field_group() with the accumulated tabs and fields. The field group is scoped exclusively to the options page via an ACF location rule (options_page equals $slug). Always call this last in the chain.

Defining Options Pages

All options pages must be defined inside configuration/pages.php. The framework calls Option::init() at boot time, which auto-requires this file:
// src/Options/Option.php (excerpt)
public static function init(): void
{
    require_once plugin_root('/configuration/pages.php');
}
Open configuration/pages.php and use the fluent API:
<?php

use Ahon\WPCMS\Options\Option;
use Extended\ACF\Fields\Text;

/**
 * Options page.
 * Use this to register your options pages.
 */
Option::create('site_options', 'Options', 'admin-settings', 12)
    ->Tab('Informations', [
        Text::make('Addresse e-mail', 'email'),
    ])
    ->make();
This produces a Settings → Options admin page at position 12 with a single Informations tab containing an email field. The field value is stored in wp_options and can be retrieved anywhere in PHP:
$email = get_field('email', 'option');

Multi-Tab Example

Build richer settings pages by chaining multiple Tab() calls before calling make():
use Ahon\WPCMS\Options\Option;
use Extended\ACF\Fields\Image;
use Extended\ACF\Fields\Text;
use Extended\ACF\Fields\Textarea;
use Extended\ACF\Fields\URL;

Option::create('site_options', 'Options', 'admin-settings', 12)
    ->Tab('Informations', [
        Text::make('Addresse e-mail', 'email'),
        Text::make('Numéro de téléphone', 'phone'),
    ])
    ->Tab('Réseaux sociaux', [
        URL::make('LinkedIn', 'linkedin_url'),
        URL::make('GitHub', 'github_url'),
    ])
    ->Tab('Médias', [
        Image::make('Logo principal', 'logo'),
        Image::make('Logo blanc', 'logo_white'),
    ])
    ->make();

WordPress Admin Settings (WP_Options)

Beyond ACF options pages, the framework exposes WP_Options — a fluent helper for tweaking native WordPress admin behaviour. Its configuration lives in configuration/options.php, auto-loaded via WP_Options::register().
<?php

// configuration/options.php
(new \Ahon\WPCMS\Options\WP_Options)
    ->removeMenuPages([
        'tools.php',
        'edit-comments.php',
        'edit.php?post_type=acf-field-group',
        'edit.php',
        'themes.php',
        'options-discussion.php',
    ])
    ->maxPostPerPages(20)
    ->adminTheme('modern');
The available WP_Options methods are:
MethodSignatureDescription
removeMenuPagesarray $pagesHides admin menu items by their menu slug
hideAdminBarbool $hideShows or hides the admin toolbar on the frontend
showOnFrontstring $typeSets show_on_front (page or posts)
pageOnFrontstring $slugSets the static front page by its post title
useClassicEditorarray $postTypesForces Classic Editor for the given post types (requires the Classic Editor plugin)
maxPostPerPagesint $nbPostSets posts_per_page globally
adminThemestring $themeSets the admin colour scheme for the current user
WP_Options methods are chainable — every method returns the WP_Options instance so you can pipe as many calls as needed before the statement ends.
ACF Pro is required for the Option class to function. The acf_add_options_page() and register_extended_field_group() calls will fatal-error if ACF is not active. See the Deployment guide for activation instructions.

Build docs developers (and LLMs) love