How to replace generated PHP Settings with Local Storage
This article explains how you can replace your generated PHP settings with Local Storage. We introduced Local Storage since Admin Columns Pro 5.1 which allows you to store column settings on the file system in PHP files. Local Storage is the replacement for the old Generated PHP Settings.
If you have been using the old Generate PHP, you can follow this guide to migrate these settings to Local Storage.
Before continuing, we also have a migration script you can use which automatically migrates the PHP column settings for you.
How to manually migrate the PHP settings to Local Storage
- Make sure you have installed the latest version of Admin Columns Pro ( at least 5.1 or higher)
- Go to the Setting page and check if you still see the PHP loaded columns. They are marked with a Lock icon.
Now you can set up Local Storage by adding this filter to your theme's functions.php. This will set the storage directory to a folder on your file system. Every time you save your column settings, a new PHP file will be created in the provided folder. Once this hook is loaded, all column settings will be loaded from your directory.
- Go to the Column Settings Page, and make a duplicate of each Column Set with a lock icon next to it.
- You should now have duplicates of the Column Sets with a lock icon, like so:
We will now make the duplicates read-only by adding this filter to your theme's functions.php
- They should now all have a lock icon, like so:
- The Column settings are now stored with Local Storage. You can remove the old PHP generated code from your theme.
The old code contains the function
- The column settings are now loaded with Local Storage.
Use Migration Snippet
We wrote a snippet that can automatically migrate all PHP loaded columns to Local Storage. Copy the snippet from the following page to your codebase and run the script as described in the script. Make sure that Local Storage is already configured.