-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from RRZE-Webteam/dev
Dev
- Loading branch information
Showing
12 changed files
with
99 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace RRZE\WP\Settings\Options; | ||
|
||
class Password extends Field | ||
{ | ||
public $template = 'password'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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')); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace RRZE\WP\Settings; | ||
|
||
defined('ABSPATH') || exit; | ||
?> | ||
<tr valign="top"> | ||
<th scope="row" class="rrze-wp-form-label"> | ||
<label for="<?php echo $option->getIdAttribute(); ?>" class="<?php echo $option->getLabelClassAttribute(); ?>"><?php echo $option->getLabel(); ?></label> | ||
</th> | ||
<td class="rrze-wp-form rrze-wp-form-password"> | ||
<input name="<?php echo esc_attr($option->getNameAttribute()); ?>" id="<?php echo $option->getIdAttribute(); ?>" type="password" value="<?php echo $option->getValueAttribute(); ?>" class="<?php echo $option->getInputClassAttribute(); ?>"> | ||
<?php if ($description = $option->getArg('description')) { ?> | ||
<p class="description"><?php echo $description; ?></p> | ||
<?php } ?> | ||
<?php if ($error = $option->hasError()) { ?> | ||
<div class="rrze-wp-settings-error"><?php echo $error; ?></div> | ||
<?php } ?> | ||
</td> | ||
</tr> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters