awesome9 / options
WordPress option manager.
1.0.1
2021-07-10 02:04 UTC
Requires
- php: >=5.6
This package is auto-updated.
Last update: 2024-11-10 09:55:09 UTC
README
📃 About Options
This package provides ease of managing options within WordPress.
💾 Installation
composer require awesome9/options
🕹 Usage
First, you need to register options for your theme/plugin.
Awesome9\Options\Options::get() ->register( 'awesome9', // Unique name which also can be used as function '_awesome9_plugin_options', // Option key for database // Defaults values. [ 'name' => 'Awesome9', 'social' => [ 'facebook' => 'https://facebook.com', 'twitter' => 'https://twitter.com', ] ] );
On plugin activation hook you can use install
method to add default option into system.
Awesome9\Options\Options::get()->install();
You can get value for an option you can use the option name to get value from it. You can also use id as path to get value.
Awesome9\Options\Options::get()->awesome9( 'name' ); // Awesome9 Awesome9\Options\Options::get()->awesome9( 'social.facebook' ); // https://facebook.com
You can update values from option temporary for session or permenantly.
// Temporary update for session. Awesome9\Options\Options::get()->awesome9()->update( 'name', 'Awesome Nine' ); // Permenant update Awesome9\Options\Options::get()->awesome9()->update( 'name', 'Awesome Nine', true );
You can remove values from option temporary for session or permenantly.
// Temporary remove for session. Awesome9\Options\Options::get()->awesome9()->remove( 'name' ); // Permenant remove Awesome9\Options\Options::get()->awesome9()->remove( 'name', true );
All the parameters remains the same as for the JSON
class.