WP Manifestindependent plugin directory
manifest / multisite / wp-global-options

WP Global Options

Implements a global option storage in WordPress.

★ 8stars
51composer installs
1.0.0-beta.1latest · never

Install

Download source zip No release zip yet

This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.

Install straight from GitHub with WP-CLI:

wp plugin install https://github.com/felixarntz/wp-global-options/archive/refs/heads/master.zip

On Packagist as felixarntz/wp-global-options:

composer require felixarntz/wp-global-options
No built-in updater. New versions won't appear under Dashboard → Updates. Install new releases yourself, or let Git Updater track the repository.

Latest Stable Version License

WP Global Options

Implements a global option storage in WordPress.

What it does

  • introduces a database table global_options
  • introduces a CRUD API for global options, including sanitization and validation
  • introduces a CRUD API for global transients
  • introduces an API for registering/unregistering global settings
  • includes a wp global-options command for WP-CLI

How to install

The plugin can either be installed as a network-wide regular plugin or alternatively as a must-use plugin.

Recommendations

  • While it is a best practice to prefix plugin functions and classes, this plugin is a proof-of-concept for WordPress core, and several functions may end up there eventually. This plugin only prefixes functions and classes that are specific to the plugin, internal helper functions for itself or hooks. Non-prefixed functions and classes are wrapped in a conditional so that, if WordPress core adapts them, their core variant will be loaded instead. Therefore, do not define any of the following functions or classes:
    • sanitize_global_option()
    • get_global_option()
    • update_global_option()
    • add_global_option()
    • delete_global_option()
    • wp_load_global_alloptions()
    • get_global_transient()
    • set_global_transient()
    • delete_global_transient()
    • register_global_setting()
    • unregister_global_setting()
    • get_registered_global_settings()
    • filter_default_global_option()

Usage

Managing Global Options

  • Function: get_global_option( string $option, mixed $default = false ): mixed
  • Function: update_global_option( string $option, mixed $value, string|bool $autoload = null ): bool
  • Function: add_global_option( string $option, mixed $value, string|bool $autoload = 'no' ): bool
  • Function: delete_global_option( string $option ): bool

Managing Global Transients

  • Function: get_global_transient( string $transient ): mixed
  • Function: set_global_transient( string $transient, mixed $value, int $expiration = 0 ): bool
  • Function: delete_global_transient( string $transient ): bool

Managing Global Settings

  • Function: register_global_setting( string $option_group, string $option_name, array $args = array() )
  • Function: unregister_global_setting( string $option_group, string $option_name )
  • Function: get_registered_global_settings()

Hooks

  • Filter: sanitize_global_option_{$option}
  • Filter: validate_global_option_{$option}
  • Filter: pre_global_option_{$option}
  • Filter: default_global_option_{$option}
  • Filter: global_option_{$option}
  • Filter: pre_update_global_option_{$option}
  • Filter: pre_update_global_option
  • Filter: pre_global_transient_{$transient}
  • Filter: global_transient_{$transient}
  • Filter: pre_set_global_transient_{$transient}
  • Filter: expiration_of_global_transient_{$transient}
  • Action: update_global_option
  • Action: update_global_option_{$option}
  • Action: updated_global_option
  • Action: add_global_option
  • Action: add_global_option_{$option}
  • Action: added_global_option
  • Action: pre_delete_global_option_{$option}
  • Action: delete_global_option_{$option}
  • Action: deleted_global_option
  • Action: set_global_transient_{$transient}
  • Action: setted_global_transient
  • Action: delete_global_transient_{$transient}
  • Action: deleted_global_transient

Releases

1 release.

Tag
Published
1.0.0-beta.1 latest
Feb 21, 2018 8 years ago

These releases are tags only. The author does not attach a packaged zip, so there are no download counts to report.