Topics

Storage

ImpressPages storage is a key-value storage, where any plugin can store it's data. You can store strings, arrays or anything else that can be encoded using json_encode and decoded using json_decode PHP functions.

Store a value to the storage

<?php ipStorage()->set('MyPlugin', 'myPluginSetting', 'Hello world!'); ?>

The sample code above creates a new storage record or updates an existing record for MyPlugin option called myPluginSetting.

Get a value from the storage

<?php $myValue = ipStorage()->get('MyPlugin', 'myPluginSetting'); ?>

You can pass a third parameter which is the default value in case there is no such value in the storage 

Get an array of all stored values

<?php $myValues = ipStorage()->getAll('MyPlugin'); ?>

Remove a value from the storage

<?php ipStorage()->remove('MyPlugin', 'myPluginSetting'); ?>

Remove all values of particular plugin

<?php ipStorage()->removeAll('MyPlugin'); ?>
comments powered by Disqus