{"id":15396022,"url":"https://github.com/luizbills/wp-options-page","last_synced_at":"2025-04-16T00:13:48.238Z","repository":{"id":65545572,"uuid":"594395910","full_name":"luizbills/wp-options-page","owner":"luizbills","description":"The easiest way to build :gear: settings pages in your WordPress plugins and themes.","archived":false,"fork":false,"pushed_at":"2023-12-14T20:02:56.000Z","size":131,"stargazers_count":24,"open_issues_count":3,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-16T00:13:38.214Z","etag":null,"topics":["wordpress","wordpress-development","wordpress-plugin"],"latest_commit_sha":null,"homepage":"https://github.com/luizbills/wp-options-page/wiki","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/luizbills.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"luizbills","custom":"https://www.luizpb.com/donate/"}},"created_at":"2023-01-28T12:25:52.000Z","updated_at":"2025-03-25T20:43:30.000Z","dependencies_parsed_at":"2023-12-13T18:21:13.461Z","dependency_job_id":null,"html_url":"https://github.com/luizbills/wp-options-page","commit_stats":{"total_commits":84,"total_committers":1,"mean_commits":84.0,"dds":0.0,"last_synced_commit":"92fdf0cb54aba6be5729e56d5fc7b6e21417111b"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizbills%2Fwp-options-page","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizbills%2Fwp-options-page/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizbills%2Fwp-options-page/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/luizbills%2Fwp-options-page/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/luizbills","download_url":"https://codeload.github.com/luizbills/wp-options-page/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249173086,"owners_count":21224484,"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-development","wordpress-plugin"],"created_at":"2024-10-01T15:30:28.970Z","updated_at":"2025-04-16T00:13:48.219Z","avatar_url":"https://github.com/luizbills.png","language":"PHP","funding_links":["https://github.com/sponsors/luizbills","https://www.luizpb.com/donate/"],"categories":[],"sub_categories":[],"readme":"# WP Options Page\n\nA class to build options pages for your WordPress plugins and themes.\n\n## Documentation\n\nLearn more in our [wiki](https://github.com/luizbills/wp-options-page/wiki).\n\n## Install\n\nInstall using composer:\n\n```\ncomposer require luizbills/wp-options-page\n```\n\n## Getting Started\n\nJust create an `WP_Options_Page` class instance on `init` action hook:\n\n```php\nfunction yourprefix_create_settings_page () {\n\t$page = new WP_Options_Page();\n\n\t// give your page a ID\n\t$page-\u003eid = 'my_settings_page';\n\n\t// set the menu name\n\t$page-\u003emenu_title = 'My Settings';\n\n\t// register your options fields\n\t$page-\u003efields = [\n\t\t// a simple text input field\n\t\t[\n\t\t\t'id' =\u003e 'api_key',\n\t\t\t'title' =\u003e 'API Key',\n\t\t\t'type' =\u003e 'text',\n\t\t]\n\t];\n\n\t// register the page\n\t$page-\u003einit();\n\n\t// access the stored options\n\t$api_key = $page-\u003eget_option( 'api_key' );\n\n\t// store this page in a global object or variable\n\t// So you can easily your instance class later\n\t// example: My_Plugin-\u003esettings = $page;\n}\nadd_action( 'init', 'yourprefix_create_settings_page' );\n```\n\nOr create your own derived class:\n\n```php\nclass My_Settings_Page extends WP_Options_Page {\n\t// I recommend using Singleton pattern\n\t// So you can easily retrieve the class later\n\t// example: My_Settings_Page::instance()-\u003eget_option( 'api_key' );\n\tprivate static $instance = null;\n\tpublic static function instance () {\n\t\tif ( ! self::$instance ) self::$instance = new self();\n\t\treturn self::$instance;\n\t}\n\n\tprivate function __construct () {\n\t\tadd_action( 'init', [ $this, 'init' ] );\n\t}\n\n\t// overrides the `init` method to setup your page\n\tpublic function init () {\n\t\t// give your page a ID\n\t\t$this-\u003eid = 'my_settings_page';\n\n\t\t// set the menu name\n\t\t$this-\u003emenu_title = 'My Settings';\n\n\t\t// register the page\n\t\tparent::init();\n\t}\n\n\t// overrides the `get_fields` method to register your fields\n\tpublic function get_fields () {\n\t\treturn [\n\t\t\t[\n\t\t\t\t'id' =\u003e 'api_key',\n\t\t\t\t'title' =\u003e 'API Key',\n\t\t\t\t'type' =\u003e 'text',\n\t\t\t]\n\t\t];\n\t}\n}\n\n// start your class\nMy_Settings_Page::instance();\n```\n\nPreview:\n\n![](https://user-images.githubusercontent.com/1798830/215272911-9a90f0fd-d62d-49f4-bc64-7906f513695a.png)\n\n---\n\nAlso, you can install and study our [Demo Plugin](https://github.com/luizbills/wp-options-page-demo).\n\n## LICENSE\n\nGPLv2 or later\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizbills%2Fwp-options-page","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fluizbills%2Fwp-options-page","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fluizbills%2Fwp-options-page/lists"}