Download the PHP package objectivco/wordpress-simple-settings without Composer

On this page you can find all versions of the php package objectivco/wordpress-simple-settings. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wordpress-simple-settings

WordPress Simple Settings

A minimalist framework for managing WordPress plugin or theme settings.

What Is This

This is a super simple framework for managing options in your WordPress plugin or theme. No cumbersome field section registration or other overhead is required. Just add some settings, update them, get them. Whatever.

It handles nonces, field names, and etc magically!

How Does It Work

WordPress Simple Settings is an abstract class which you extend in your own plugin class, theme class, or wherever you need it.

It takes a prefix, set by you and builds a settings object which is stored in a single option in the database.

This last bit should be a clue to what type of data you should store using this API: small amounts!

Just like the built-in Options API (which this framework uses!), you only want to use this for small bits of data. Don't try to store your customer database here!

Installation

The best way is to use composer: composer require objectivco/wordpress-simple-settings

You can also clone the repository into your lib or inc directory and require wordpress-simple-settings.php. But composer is better.

You can get a quick idea of how to implement in our example plugin: examples/awesome-plugin.

The gist is, you'll instantiate your plugin class as extension of WP_SimpleSettings. You'll then set a prefix as a class variable called $prefix.

If you don't set $prefix, the framework will try to use your child class name. But this will only work in PHP 5.3+. So, really, just set a prefix ok?

Change Log

0.7.2

0.7.1

0.3.0

0.2.2

0.2.1

0.2

0.1

Usage

Here are the basic functions available to you within your plugin.

add_setting($option_name, $value)

This is essentially a wrapper for update_setting that respectfully does not make any changes if the option in question is already set.

You'll most frequently use this in your activation hook.

delete_setting($option_name)

Removes setting.

get_setting($option_name, $type)

Retrieves a specific option. Returns string by default. If you specify array as $type, it will treat the value as a delimited string (default semi-colon) and return an array.

update_setting($option_name, $new_value)

Updates a specific option.

get_field_name($option_name, $type)

Gets an HTML field name. If you set $type to array, the field value will be treated as a delimited string (default semi-colon) and stored as an array.

the_nonce()

Call $YourPluginInstance->the_nonce() somewhere in your admin form to generate the nonce used to validate / save settings.

save_settings()

There is no need to call this unless you want to override the default functionality. This function will be called on admin_init and automagically saves settings, if the right nonce and $_REQUEST is set.

Settings Object

One of my goals in building this framework was to have an easily accessible settings object that can be used directly when the getters / setters are inconvenient. This is done by simply using $this->settings[$option_name].

Obviously this should be used in read-only applications. Setting values here will not update them in the database.

Feedback

I'm in no way claiming to have the perfect, final answer to managing options in WordPress themes or plugins.

The goal of this minimalist approach is that you can simply build your plugin rather than contorting it to work with more demanding APIs.

If you have any ideas for how I can improve on what I have here, please let me know!


All versions of wordpress-simple-settings with dependencies

PHP Build Version
Package Version
Requires php Version >=5.2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package objectivco/wordpress-simple-settings contains the following files

Loading the files please wait ....