Skip to content

Commit 67b5743

Browse files
committed
added get_option retriever function in readme
1 parent 4bcc372 commit 67b5743

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

readme.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ It's a PHP class wrapper for handling WordPress [Settings API](http://codex.word
66
Usage Example
77
---------------
88

9-
A nice tutorial is presented can be found [here](http://tareq.wedevs.com/2012/06/wordpress-settings-api-php-class/) about how to use this PHP class
9+
A nice tutorial is presented can be found [here](https://tareq.co/2012/06/wordpress-settings-api-php-class/) about how to use this PHP class
1010

1111
## Package Installation (via Composer)
1212

@@ -24,12 +24,37 @@ Now run:
2424

2525
`$ composer install`
2626

27+
#### Retrieving saved options
28+
29+
```php
30+
/**
31+
* Get the value of a settings field
32+
*
33+
* @param string $option settings field name
34+
* @param string $section the section name this field belongs to
35+
* @param string $default default text if it's not found
36+
*
37+
* @return mixed
38+
*/
39+
function prefix_get_option( $option, $section, $default = '' ) {
40+
41+
$options = get_option( $section );
42+
43+
if ( isset( $options[$option] ) ) {
44+
return $options[$option];
45+
}
46+
47+
return $default;
48+
}
49+
```
2750

2851
Screenshot
2952
----------------------
3053

3154
![Option Panel](https://github.com/tareq1988/wordpress-settings-api-class/raw/master/screenshot-1.png "The options panel build on the fly using the PHP Class")
3255

56+
57+
3358
Frequently Asked Questions
3459
---------------
3560

0 commit comments

Comments
 (0)