{"id":21100628,"url":"https://github.com/sharazghouri/soution-box-settings","last_synced_at":"2025-06-26T09:39:39.383Z","repository":{"id":146432787,"uuid":"616045116","full_name":"sharazghouri/soution-box-settings","owner":"sharazghouri","description":"A settings framework for the WordPress settings API","archived":false,"fork":false,"pushed_at":"2024-06-07T17:37:33.000Z","size":3793,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-05T09:34:38.608Z","etag":null,"topics":["wordpress","wordpress-plugin","wordpress-settings","wordpress-settings-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sharazghouri.png","metadata":{"files":{"readme":"README.md","changelog":"changelog.txt","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T13:09:34.000Z","updated_at":"2024-08-28T13:51:55.000Z","dependencies_parsed_at":"2024-05-28T15:39:41.366Z","dependency_job_id":null,"html_url":"https://github.com/sharazghouri/soution-box-settings","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharazghouri%2Fsoution-box-settings","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharazghouri%2Fsoution-box-settings/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharazghouri%2Fsoution-box-settings/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sharazghouri%2Fsoution-box-settings/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sharazghouri","download_url":"https://codeload.github.com/sharazghouri/soution-box-settings/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254576314,"owners_count":22094337,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["wordpress","wordpress-plugin","wordpress-settings","wordpress-settings-api"],"created_at":"2024-11-19T23:14:42.492Z","updated_at":"2025-05-16T17:30:32.352Z","avatar_url":"https://github.com/sharazghouri.png","language":"PHP","funding_links":["https://www.paypal.me/jamesckemp"],"categories":[],"sub_categories":[],"readme":"WordPress Settings Framework\n============================\n\u003cp align=\"center\"\u003e\n\n\u003ca href=\"https://packagist.org/packages/solutionbox/wordpress-settings-framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/solutionbox/wordpress-settings-framework\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/solutionbox/wordpress-settings-framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/solutionbox/wordpress-settings-framework\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n\u003ca href=\"https://packagist.org/packages/solutionbox/wordpress-settings-framework\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/solutionbox/wordpress-settings-framework\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\nThe WordPress Settings Framework aims to take the pain out of creating settings pages for your WordPress plugins\nby effectively creating a wrapper around the WordPress settings API and making it super simple to create and maintain\nsettings pages.\n\nThis repo is actually a working plugin which demonstrates how to implement SBSA in your plugins. See `src/sbsa-test.php`\nfor details.\n\nYou can use this framework with composer if you are using auto loading in your plugin.\n\n## Installation\n\n```php\ncomposer require solutionbox/wordpress-settings-framework\n```\n\nSetting Up Your Plugin\n----------------------\n\n1. Install the package via composer.\n2. Create a \"settings\" folder in your plugin root.\n3. Create a settings file in your new \"settings\" folder (e.g. `settings-general.php`)\n\nNow you can set up your plugin like:\n\n```php\nuse  Solution_Box_Settings;\n\nclass SBSATest {\n\t/**\n\t * @var string\n\t */\n\tprivate $plugin_path;\n\n\t/**\n\t * @var WordPressSettingsFramework\n\t */\n\tprivate $sbsa;\n\n\t/**\n\t * SBSATest constructor.\n\t */\n\tfunction __construct() {\n\t\t$this-\u003eplugin_path = plugin_dir_path( __FILE__ );\n\n\t\t$this-\u003esbsa = new Solution_Box_Settings\\SettingsAPI( $this-\u003eplugin_path . 'src/settings/example-settings.php', 'my_example_settings' );\n\n\t\t// Add admin menu\n\t\tadd_action( 'admin_menu', array( $this, 'add_settings_page' ), 20 );\n\t\t\n\t\t// Add an optional settings validation filter (recommended)\n\t\tadd_filter( $this-\u003esbsa-\u003eget_option_group() . '_settings_validate', array( \u0026$this, 'validate_settings' ) );\n\t}\n\n\t/**\n\t * Add WooCommerce sub settings page.\n\t */\n\tfunction add_settings_page() {\n\t\t$this-\u003esbsa-\u003eadd_settings_page( array(\n\t\t\t'parent_slug' =\u003e 'woocommerce',\n\t\t\t'page_title'  =\u003e __( 'Page Title', 'text-domain' ),\n\t\t\t'menu_title'  =\u003e __( 'menu Title', 'text-domain' ),\n\t\t\t'capability'  =\u003e 'manage_woocommerce',\n\t\t) );\n\t}\n\n\t/**\n\t * Validate settings.\n\t * \n\t * @param $input\n\t *\n\t * @return mixed\n\t */\n\tfunction validate_settings( $input ) {\n\t\t// Do your settings validation here\n\t\t// Same as $sanitize_callback from http://codex.wordpress.org/Function_Reference/register_setting\n\t\treturn $input;\n\t}\n\n\t// ...\n}\n```\n\nYour settings values can be accessed like so:\n\n```php\n// Get settings\n$this-\u003esbsa-\u003eget_settings();\n```\n\nThis will get either the saved setting values, or the default values that you set in your settings file.\n\nOr by getting individual settings:\n\n```php\n// Get individual setting\n$setting = Solution_Box_Settings\\SettingsAPI::get_setting( 'prefix_settings_general', 'general', 'text' );\n```\n\n\nThe Settings Files\n------------------\n\nThe settings files work by filling the global `$sbsa_settings` array with data in the following format:\n\n```php\n$sbsa_settings[] = array(\n    'section_id' =\u003e 'general', // The section ID (required)\n    'section_title' =\u003e 'General Settings', // The section title (required)\n    'section_description' =\u003e 'Some intro description about this section.', // The section description (optional)\n    'section_order' =\u003e 5, // The order of the section (required)\n    'fields' =\u003e array(\n        array(\n            'id' =\u003e 'text',\n            'title' =\u003e 'Text',\n            'desc' =\u003e 'This is a description.',\n            'placeholder' =\u003e 'This is a placeholder.',\n            'type' =\u003e 'text',\n            'default' =\u003e 'This is the default value'\n        ),\n        array(\n            'id' =\u003e 'select',\n            'title' =\u003e 'Select',\n            'desc' =\u003e 'This is a description.',\n            'type' =\u003e 'select',\n            'default' =\u003e 'green',\n            'choices' =\u003e array(\n                'red' =\u003e 'Red',\n                'green' =\u003e 'Green',\n                'blue' =\u003e 'Blue'\n            )\n        ),\n\n        // add as many fields as you need...\n\n    )\n);\n```\n\nValid `fields` values are:\n\n* `id` - Field ID\n* `title` - Field title\n* `desc` - Field description\n* `placeholder` - Field placeholder\n* `type` - Field type (text/password/textarea/select/radio/checkbox/checkboxes/color/file/editor/code_editor)\n* `default` - Default value (or selected option)\n* `choices` - Array of options (for select/radio/checkboxes)\n* `mimetype` - Any valid mime type accepted by Code Mirror for syntax highlighting (for code_editor)\n\nSee `settings/example-settings.php` for an example of possible values.\n\n\nAPI Details\n-----------\n\n    new Solution_Box_Settings\\SettingsAPI( string $settings_file [, string $option_group = ''] )\n\nCreates a new settings [option_group](http://codex.wordpress.org/Function_Reference/register_setting) based on a settings file.\n\n* `$settings_file` - path to the settings file\n* `$option_group` - optional \"option_group\" override (by default this will be set to the basename of the settings file)\n\n\u003cpre\u003e Solution_Box_Settings\\SettingsAPI::get_setting( $option_group, $section_id, $field_id )\u003c/pre\u003e\n\nGet a setting from an option group\n\n* `$option_group` - option group id.\n* `$section_id` - section id (change to `[{$tab_id}_{$section_id}]` when using tabs.\n* `$field_id` - field id.\n\n\u003cpre\u003eSolution_Box_Settings\\SettingsAPI::delete_settings( $option_group )\u003c/pre\u003e\n\nDelete all the saved settings from a option group\n\n* `$option_group` - option group id\n\nActions \u0026 Filters\n---------------\n\n**Filters**\n\n* `sbsa_register_settings_[option_group]` - The filter used to register your settings. See `settings/example-settings.php` for an example.\n* `[option_group]_settings_validate` - Basically the `$sanitize_callback` from [register_setting](http://codex.wordpress.org/Function_Reference/register_setting). Use `$sbsa-\u003eget_option_group()` to get the option group id.\n* `sbsa_defaults_[option_group]` - Default args for a settings field\n\n**Actions**\n\n* `sbsa_before_settings_page_[option_group]` - Before setting page HTML is output\n* `sbsa_after_settings_page_[option_group]` - After setting page HTML is output\n* `sbsa_before_settings_page_header_[option_group]` - Before setting page header HTML is output\n* `sbsa_after_settings_page_header_[option_group]` - After setting page header HTML is output\n* `sbsa_settings_sections_args_[option_group]` - Section extra args for to wrap the section with HTML and extra class [More](https://developer.wordpress.org/reference/functions/add_settings_section/#parameters)\n* `sbsa_before_field_[option_group]` - Before a field HTML is output\n* `sbsa_before_field_[option_group]_[field_id]` - Before a field HTML is output\n* `sbsa_after_field_[option_group]` - After a field HTML is output\n* `sbsa_after_field_[option_group]_[field_id]` - After a field HTML is output\n* `sbsa_before_settings_[option_group]` - Before settings form HTML is output\n* `sbsa_after_settings_[option_group]` - After settings form HTML is output\n* `sbsa_before_tabless_settings_[option_group]` - Before settings  section HTML is output\n* `sbsa_after_tabless_settings_[option_group]` - After settings section HTML is output\n* `sbsa_before_settings_fields_[option_group]` - Before settings form fields HTML is output (inside the `\u003cform\u003e`)\n* `sbsa_do_settings_sections_[option_group]` - Settings form fields HTMLoutput (inside the `\u003cform\u003e`)\n* `sbsa_before_tab_links_[option_group]` - Before tabs HTML is output\n* `sbsa_after_tab_links_[option_group]` - After tabs HTML is output\n\nExamples\n-----------\n**Example 1 Tabless settings**\n\u003cimg width=\"1190\" alt=\"image\" src=\"https://user-images.githubusercontent.com/17900945/227388614-e0bb62c4-f09a-49f9-875f-b37e2d0e9fce.png\"\u003e\n\n**Example 2 Tabbed settings**\n\u003cimg width=\"1251\" alt=\"image\" src=\"https://user-images.githubusercontent.com/17900945/227388843-719a1f93-39f7-4459-afa1-13642c799a31.png\"\u003e\n\nCredits\n-------\n\nThe WordPress Settings Framework was Cloned from [iconicwp](https://github.com/iconicwp/WordPress-Settings-Framework) then converted into php package with more features.\n\nPlease contribute by [reporting bugs](https://github.com/sharazghouri/soution-box-settings/issues) and submitting [pull requests](https://github.com/sharazghouri/soution-box-settings/pulls).\n\nWant to say thanks? [Consider tipping me](https://www.paypal.me/jamesckemp).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharazghouri%2Fsoution-box-settings","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsharazghouri%2Fsoution-box-settings","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsharazghouri%2Fsoution-box-settings/lists"}