From 395618dab437d9361bddf529db691daba6bdefeb Mon Sep 17 00:00:00 2001 From: rvdforst Date: Tue, 28 Nov 2023 10:48:10 +0100 Subject: [PATCH 01/12] Create Password.php --- src/Settings/Options/Password.php | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/Settings/Options/Password.php diff --git a/src/Settings/Options/Password.php b/src/Settings/Options/Password.php new file mode 100644 index 0000000..780e380 --- /dev/null +++ b/src/Settings/Options/Password.php @@ -0,0 +1,8 @@ + Date: Tue, 28 Nov 2023 10:48:13 +0100 Subject: [PATCH 02/12] Create README.md --- src/Settings/README.md | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/Settings/README.md diff --git a/src/Settings/README.md b/src/Settings/README.md new file mode 100644 index 0000000..5a9cf6d --- /dev/null +++ b/src/Settings/README.md @@ -0,0 +1,53 @@ +# RRZE\WP\Settings + +The objective of this package is to simplify the process of creating settings pages for WordPress plugins. Traditionally, developers have utilized the Settings API or custom code for this purpose. Although the Settings API functions well, it necessitates substantial setup effort. For instance, you must manually write the HTML code for your options. Additionally, incorporating tabs and tab-sections can become rather complex. This package aims to streamline these tasks and make settings page creation more straightforward. + +## Usage + +### Basic example + +```php +use RRZE\WP\Settings; + +$settings = new Settings(__('My Plugin Settings')); + +$tab = $settings->addTab(__('General', 'textdomain')); + +$section = $tab->addSection('General Section'); + +$section->addOption('text', [ + 'name' => 'title', + 'label' => __('Title', 'textdomain') +]); + +$settings->build(); +``` + +### Initializing the Settings class + +```php +use RRZE\WP\Settings; + +$settings = new Settings(__('Custom Settings')); +``` + +The constructor supports two parameters, namely `$title` and `$slug`. By default, the page slug is generated by sanitizing the title. However, if you have a specific slug preference, you can pass it as the second parameter to the constructor. + +Additional methods available in this class include: + +```php +$settings->setCapability('manage_options') + ->setOptionName('my_plugin_option') + ->setMenuTitle(__('My Plugin', 'textdomain')) + ->setMenuIcon('dashicons-admin-generic') + ->setMenuPosition(5) + ->setMenuParentSlug('options-general.php'); +``` + +### Tabs + +Tabs will be displayed only if there is more than one tab available. + +```php +$settings->addTab(__('General', 'textdomain')); +``` From 861d9085ddf00c64212e4087d57b9476be9869f6 Mon Sep 17 00:00:00 2001 From: rvdforst Date: Tue, 28 Nov 2023 10:48:15 +0100 Subject: [PATCH 03/12] Update checkbox.php --- src/Settings/templates/options/checkbox.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Settings/templates/options/checkbox.php b/src/Settings/templates/options/checkbox.php index 3e16180..819ddb6 100644 --- a/src/Settings/templates/options/checkbox.php +++ b/src/Settings/templates/options/checkbox.php @@ -5,11 +5,10 @@ defined('ABSPATH') || exit; ?> - + - - +