wp-media/options

Options Handler for WordPress Options API

This package's canonical repository appears to be gone and the package has been frozen as a result.

v4.0 2021-06-18 20:14 UTC

This package is auto-updated.

Last update: 2023-01-18 23:59:08 UTC


README

This package is a wrapper to make it easier to work with the WordPress Options API.

Installation

Using composer:

composer require wp-media/options

Description

This package contains the following:

  • OptionsInterface: Interface defining the mandatory methods to implement
  • AbstractOptions: Abstract class implementing OptionsInterface, with get/set/delete abstract methods
  • Options: Class extending AbstractOptions for single site options
  • SiteOptions: Class extending AbstractOptions for multisite options
  • OptionArray: Class to manage array data coming from an option

Usage Examples

For single site option

use WPMedia\Options;

$option = new Options( 'wp_media_' ); // optional prefix

$option->get( 'setting' );

For multisite option

use WPMedia\SiteOptions;

$option = new SiteOptions( 'wp_media_' ); // optional prefix

$option->get( 'setting' );

For option containing an array

use WPMedia\Options;
use WPMedia\OptionArray;

$option = new Options( 'wp_media_' ); // optional prefix

$data = new OptionArray( $option->get( 'setting' ), 'wpmedia' );

$data->get( 'setting_key' );