2017 © Pedro Peláez
 

wordpress-muplugin decisions

Not Options

image

johnpbloch/decisions

Not Options

  • Tuesday, March 8, 2016
  • by johnpbloch
  • Repository
  • 1 Watchers
  • 8 Stars
  • 17 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 1 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Decisions

Define values in a JSON file and they will override corresponding option values from the database. ALWAYS., (*1)

Requirements

  • PHP 5.3
    • Sorry
    • Not sorry.

Usage

You REALLY should use this as a must-use plugin, but that would require some know-how and extra setup. If you don't know how MU plugins work or how to get this set up as one, maybe you don't really need this plugin? Or you might want to better understand why you need it?, (*2)

By default, this will look for a configuration file in ABSPATH . '.decisions.json'. You can change this location in your config file thusly:, (*3)

define( 'JPB\Decisions\DECISIONS', 'wherever/you/want' );

Any options you want to be set by default go into the standard hash:, (*4)

{
  "standard": {
    "blogname": "Super Serial Blog Name",
    "admin_email": "john@example.com"
  }
}

In a multisite network, you can add or override standard options with a site specific hash. The site options should be keyed by site domain + site path with slashes and protocol trimmed (so http://example.com/subsite/ becomes example.com/subsite). Site-specific options go under the sites key:, (*5)

{
  "sites": {
    "example.com/subsite": {
      "admin_email": "jane@example.com"
    },
    "something-else.com/multinetwork": {
      "omgwat": "Still works"
    }
  }
}

In multisite you can also add network-wide options using the network hash:, (*6)

{
  "network": {
    "auth_policy": "Gandalf"
  }
}

JSON gets decoded as associative arrays rather than objects. If you need an object, you can serialize the data and store the serialized string directly. All values get passed through maybe_unserialize before use., (*7)

Qs I Think Will Be FA'ed

JSON? Y U NO USE YAML/RAML/XML/LOLSPEAK?

PHP has core JSON decoding. Ain't nobody got time for userland libraries., (*8)

What about options fetched before this plugin runs?

I can't really help you there. That falls well outside the 80/20 rule. Maybe set the DB value directly and then short-circuit any attempt to update that key?, (*9)

Do you?

I did., (*10)

License

MIT, (*11)

The Versions

08/03 2016

dev-master

9999999-dev

Not Options

  Sources   Download

MIT

by John P Bloch

07/03 2016

1.0.0

1.0.0.0

Not Options

  Sources   Download

MIT

by John P Bloch