PHP code example of wp-forge / wp-options

1. Go to this page and download the library: Download wp-forge/wp-options library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

wp-forge / wp-options example snippets




use WP_Forge\Options\Options;

$options = new Options('my_plugin_options');

// Pass the option name and option value as parameters.
$options->set('name', 'value');



use WP_Forge\Options\Options;

$options = new Options('my_plugin_options');

// Pass the option name and a default value as parameters.
// If a default value is not provided, `null` will be the default return value.
$options->get('name', 'default');



use WP_Forge\Options\Options;

$options = new Options('my_plugin_options');

// Pass the option name to be deleted as a parameter.
$options->delete('name');



use WP_Forge\Options\Options;

$options = new Options('my_plugin_options');

// Pass the option name as a parameter.
$options->has('name');



use WP_Forge\Options\Options;

$options = new Options('my_plugin_options');

// Pass the option name and option value as parameters
$options->save();