PHPackages                             devgeniem/wp-readonly-options - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. devgeniem/wp-readonly-options

ActiveWordpress-muplugin[Database &amp; ORM](/categories/database)

devgeniem/wp-readonly-options
=============================

Predefine WordPress options in your code and force get\_option() results.

1.2.2(6y ago)958.0k—9.5%4[1 issues](https://github.com/devgeniem/wp-readonly-options/issues)[1 PRs](https://github.com/devgeniem/wp-readonly-options/pulls)1GPL-2.0PHPPHP &gt;=7.0

Since Aug 13Pushed 6y ago10 watchersCompare

[ Source](https://github.com/devgeniem/wp-readonly-options)[ Packagist](https://packagist.org/packages/devgeniem/wp-readonly-options)[ Docs](https://github.com/devgeniem/wp-must-use-options)[ RSS](/packages/devgeniem-wp-readonly-options/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (7)Used By (1)

[![geniem-github-banner](https://cloud.githubusercontent.com/assets/5691777/14319886/9ae46166-fc1b-11e5-9630-d60aa3dc4f9e.png)](https://cloud.githubusercontent.com/assets/5691777/14319886/9ae46166-fc1b-11e5-9630-d60aa3dc4f9e.png)

WP Plugin: Readonly Options
===========================

[](#wp-plugin-readonly-options)

[![Build Status](https://camo.githubusercontent.com/bbd27c3e15a72471e5659b26fe9f94f601fa4f3a42439a1b03fecdb8fb674777/68747470733a2f2f7472617669732d63692e6f72672f64657667656e69656d2f77702d726561646f6e6c792d6f7074696f6e732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/devgeniem/wp-readonly-options) [![Latest Stable Version](https://camo.githubusercontent.com/1001b2c3377281e5229cacedb3c8e99381f9e5286aaac08af9319180ed6e1f03/68747470733a2f2f706f7365722e707567782e6f72672f64657667656e69656d2f77702d726561646f6e6c792d6f7074696f6e732f762f737461626c65)](https://packagist.org/packages/devgeniem/wp-readonly-options) [![Total Downloads](https://camo.githubusercontent.com/2d1f896c021bf6d7d00a7cde38de48a536d34a9ccedebbd732b3ce4ee0400af1/68747470733a2f2f706f7365722e707567782e6f72672f64657667656e69656d2f77702d726561646f6e6c792d6f7074696f6e732f646f776e6c6f616473)](https://packagist.org/packages/devgeniem/wp-readonly-options) [![Latest Unstable Version](https://camo.githubusercontent.com/f24d4da15325300f501017d0876e3fe2ef5c31b2b9c39bba35287a8096508e72/68747470733a2f2f706f7365722e707567782e6f72672f64657667656e69656d2f77702d726561646f6e6c792d6f7074696f6e732f762f756e737461626c65)](https://packagist.org/packages/devgeniem/wp-readonly-options) [![License](https://camo.githubusercontent.com/ca5bf42b32113c28c31f3bb09cbfb83c9bdbc5003c510b5efac1acbddfaf31a5/68747470733a2f2f706f7365722e707567782e6f72672f64657667656e69656d2f77702d726561646f6e6c792d6f7074696f6e732f6c6963656e7365)](https://packagist.org/packages/devgeniem/wp-readonly-options)

Have you ever wanted to set all your options as `define('PLUGIN_OPTION','some_value')` in `wp_config.php`?

Sometimes you need to use 3rd party plugins that only gives you those options in admin pages and GUI. And now you can't use git to version control your settings as you would love to do.

This plugin helps you to set all your settings in your code and doesn't force you to go over to admin pages.

How it works
------------

[](#how-it-works)

It works by allowing you to force the results of `get_option()` to your predefined values.

This also adds tiny amount if javascript into admin pages so that it can set readonly attributes to your options: ``. This makes it easier for the users to understand that these options can't be changed.

This only works in `php7.0` version or better since we use arrays when defining constants. We also like to use scalar type hintings. Sorry legacy projects :(

Installation
------------

[](#installation)

Prefered installation is with composer:

```
{
    "require": {
        "devgeniem/wp-readonly-options": "^1.1"
    },
    "extra": {
        "installer-paths": {
          "web/app/mu-plugins/{$name}/": ["type:wordpress-muplugin"],
        },
    }
}
```

Code Example
------------

[](#code-example)

My options page looks so empty and lonely:

[![Before](https://cloud.githubusercontent.com/assets/5691777/17637568/14e14110-60ed-11e6-867b-7f921d73fb02.png)](https://cloud.githubusercontent.com/assets/5691777/17637568/14e14110-60ed-11e6-867b-7f921d73fb02.png)

I'll look up the keys from `/wp-admin/options.php` and I see that they are `sm_bucket` and `sm_key_json`.

You can also see the names by using Google Chrome inspector. Key name is same as input element ID.

I can use those keys with `WP_READONLY_OPTIONS` and I add the following code to my `wp-config.php`:

**php7.0**

```
define( 'WP_READONLY_OPTIONS', array(
    'sm_bucket' => 'my-bucket.example.com'
    'sm_key_json' => '{
      "type": "service_account",
      "project_id": "XXXXXXXXXXXXXXXXXXXXXXX",
      "private_key_id": "XXXXXXXXXXXXXXXXXXXX",
      "private_key": "-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -----END PRIVATE KEY-----
    }'
));
```

**php5.X**

```
define( 'WP_READONLY_OPTIONS', serialize( array(
    'sm_bucket' => 'my-bucket.example.com'
    'sm_key_json' => '{
      "type": "service_account",
      "project_id": "XXXXXXXXXXXXXXXXXXXXXXX",
      "private_key_id": "XXXXXXXXXXXXXXXXXXXX",
      "private_key": "-----BEGIN PRIVATE KEY-----\nXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
      -----END PRIVATE KEY-----
    }'
)));
```

Afterwise I can see the values in readonly mode:

[![After](https://cloud.githubusercontent.com/assets/5691777/17637575/1c282f42-60ed-11e6-8622-7cff2466578b.png)](https://cloud.githubusercontent.com/assets/5691777/17637575/1c282f42-60ed-11e6-8622-7cff2466578b.png)

Configuration
-------------

[](#configuration)

Disables readonly attribute setter Javascript hack. It might be incompatible with something.

```
define('WP_READONLY_OPTIONS_NO_JS',true);
```

License
-------

[](#license)

GPLv2

Maintainers
-----------

[](#maintainers)

[@onnimonni](https://github.com/onnimonni)

[@villepietarinen](https://github.com/villepietarinen)

###  Health Score

37

—

LowBetter than 83% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity37

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 88.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~297 days

Total

5

Last Release

2377d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5691777?v=4)[Onni Hakala](/maintainers/onnimonni)[@onnimonni](https://github.com/onnimonni)

![](https://avatars.githubusercontent.com/u/11960000?v=4)[Hion Digital Oy](/maintainers/devgeniem)[@devgeniem](https://github.com/devgeniem)

---

Top Contributors

[![onnimonni](https://avatars.githubusercontent.com/u/5691777?v=4)](https://github.com/onnimonni "onnimonni (16 commits)")[![jeremyzahner](https://avatars.githubusercontent.com/u/1925488?v=4)](https://github.com/jeremyzahner "jeremyzahner (1 commits)")[![villepietarinen](https://avatars.githubusercontent.com/u/5517842?v=4)](https://github.com/villepietarinen "villepietarinen (1 commits)")

---

Tags

wordpressdatabaseoptionwpmust-useforce

### Embed Badge

![Health badge](/badges/devgeniem-wp-readonly-options/health.svg)

```
[![Health](https://phpackages.com/badges/devgeniem-wp-readonly-options/health.svg)](https://phpackages.com/packages/devgeniem-wp-readonly-options)
```

###  Alternatives

[dbout/wp-orm

WordPress ORM with Eloquent.

1279.6k1](/packages/dbout-wp-orm)[devgeniem/better-wp-db-error

Better WordPress database error handling.

1161.3k](/packages/devgeniem-better-wp-db-error)[olliejones/index-wp-mysql-for-speed

Speed up your WordPress site by adding high-performance keys (database indexes) to your MySQL database tables.

1481.8k](/packages/olliejones-index-wp-mysql-for-speed)[codesvault/howdy-qb

Mysql Query Builder for WordPress

371.2k1](/packages/codesvault-howdy-qb)[williarin/wordpress-interop

Interoperability library to work with WordPress database in third party apps

6610.9k2](/packages/williarin-wordpress-interop)[pixelstudio/wp-sync-db

WordPress plugin to sync database between different installs

472.5k1](/packages/pixelstudio-wp-sync-db)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
