Coder Social home page Coder Social logo

decisions's Introduction

Decisions

Define values in a JSON file and they will override corresponding option values from the database. ALWAYS.

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?

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

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

Any options you want to be set by default go into the standard hash:

{
  "standard": {
    "blogname": "Super Serial Blog Name",
    "admin_email": "[email protected]"
  }
}

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:

{
  "sites": {
    "example.com/subsite": {
      "admin_email": "[email protected]"
    },
    "something-else.com/multinetwork": {
      "omgwat": "Still works"
    }
  }
}

In multisite you can also add network-wide options using the network hash:

{
  "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.

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.

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?

Do you?

I did.

License

MIT

decisions's People

Contributors

johnpbloch avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.