承接 ralfhortt/wp-settings 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

ralfhortt/wp-settings

Composer 安装命令:

composer require ralfhortt/wp-settings

包简介

A helper package for working with the WordPress Settings

README 文档

README

A helper package for working with the WordPress Settings API

Installation

composer require ralfhortt/wp-settings

Usage

Settings Page

The Settings Page approach uses the WordPress Settings API to create admin settings pages and subpages.

Basic Usage

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page('My Theme Settings')
    ->subpageUnder('options-general.php')
    ->panel( __('My Panel', 'textdomain') )
        ->section( __('My Section', 'textdomain') )
            ->checkbox( 'my-checkbox', __('Checkbox', 'textdomain') )
            ->color( 'my-color', __('Color', 'textdomain') )
            ->file( 'my-file', __('File', 'textdomain') )
            ->image( 'my-image', __('Image', 'textdomain') )
            ->pageDropdown( 'my-page', __('Page', 'textdomain') )
            ->radio( 'my-radio', __('Radio', 'textdomain'), ['option1' => 'Option 1', 'option2' => 'Option 2'] )
            ->select( 'my-select', __('Select', 'textdomain'), ['option1' => 'Option 1', 'option2' => 'Option 2'] )
            ->text( 'my-text', __('Text', 'textdomain') )
            ->textarea( 'my-textarea', __('Textarea', 'textdomain') )
            ->url( 'my-url', __('Url', 'textdomain') )
    ->register();

Settings Page Configuration

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page(
        'Theme Configuration',
        'Theme Config',                    // menu title
        'my-theme-config',                // slug
        'edit_theme_options'              // capability
    )
    ->subpageUnder('options-general.php') // parent (Settings menu)
    ->panel('Design Settings')
        ->section('Colors')
            ->color('primary-color', 'Primary Color')
    ->register();

Top-Level Menu Page

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page(
        'Brand Manager',        // title
        null,                   // menu title (defaults to title)
        null,                   // slug (auto-generated)
        'manage_options'        // capability
    )
    ->topLevel('dashicons-art', 25)
    ->panel('Brand Assets')
        ->section('Logos')
            ->image('main-logo', 'Main Logo')
    ->register();

Available Parent Menus

  • 'themes.php' - Appearance menu
  • 'options-general.php' - Settings menu (default)
  • 'tools.php' - Tools menu
  • null - Top-level menu (requires icon and position)
  • Custom parent slug for submenus

Advanced Usage

Settings Page Advanced Features

Options Storage

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page('My Settings')
    ->subpageUnder('options-general.php')
    ->panel( __('My Panel', 'textdomain')  )
        ->section( __('My Section', 'textdomain') )
            ->text(
                'my-text',                    // identifier
                __('My Text', 'textdomain'),  // label
                ''                            // default value
            )
    ->register();

Check for a capability

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page('My Settings')
    ->subpageUnder('options-general.php')
    ->panel( 'My Panel' )
        ->section( __('My Section', 'textdomain') )
            ->text(
                'my-text',                    // identifier
                __('My Text', 'textdomain'),  // label
                '',                           // default value
                'edit_posts'                  // capability
            )
    ->register();

Add a description

<?php
use RalfHortt\Settings\SettingsPage;

(new SettingsPage)
    ->page('My Settings')
    ->subpageUnder('options-general.php')
    ->panel( 'My Panel' )
        ->section( 'My Section' )
            ->text(
                'my-text',                               // identifier
                'Text',                                  // label
                '',                                      // default value
                '',                                      // capability
                __('This is awesome', 'textdomain')     // description
            )
    ->register();

Retrieving data

<?php
// Retrieve data from your settings page fields
$option = get_option('my-text');

Changelog

v1.0.0

  • Initial release

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固