Updaters
The updating of various types of database data is separated case by case into “Updater” PHP classes. This allows not only separation of concerns, but also provides a path for extensibility.
The process for implementing a custom update is as follows:
- Create a custom PHP class which extends the
\Go_Live_Update_Urls\Updaters\Updaters_Abstract
class. - Use the
go-live-update-urls/updaters/repo/updaters
filter to register the updater.
Example
Support updating a URL which is stored with a base64 encoded string in the database.
We start by creating a custom PHP class which will handle encoding the URL for replacement.
Once we have the PHP class ready, we register it using a filter.
WordPress Hooks
This plugin is highly extendable using WordPress filter API. Below are brief descriptions of each of the actions and filters.
Filters
go-live-update-urls-pro/checkboxes/list
Changes the list of sections and the corresponding database tables. Affects both the display on the tools page and the database tables which are updated.
Default sections with their related tables:
- posts
- comments
- terms
- user
- custom
- options
- network
Accepts 2 arguments:
array $checkboxes
– List of sections and corresponding tables.Checkboxes $class
– Full checkboxes class.
go-live-update-urls-pro/core/old-url
Changes the prepopulated URL in the Old URL field when the tools page loads. Overrides the predictive URL feature for the Old URL field.
Accepts 1 argument:
string $value
– Old URL based on the predictive URL feature
go-live-update-urls-pro/core/new-url
Changes the prepopulated URL in the New URL field when the tools page loads. Overrides the predictive URL feature for the New URL field.
Accepts 1 argument:
string $value
– New URL based on the predictive URL feature
go-live-update-urls-pro/history/tracking/limit
Changes the limit of URL changes which are stored in the site address history.
Defaults to 8 items.
Accepts 1 argument:
int $limit
– The default number of history to track.
go-live-update-urls-pro/tests/domain-messages
Changes the messages displayed for the results of the verify this site is accessible from the new URL URL test.
Notice: You must keep the default array keys intact.
Accepts 1 argument:
array $messages
– List of default messages.
go-live-update-urls-pro/tests/scheme-messages
Changes the messages displayed for the results of the verify the Old URL and New URL have matching structures test.
Notice: You must keep the default array keys intact.
Accepts 1 argument:
array $messages
– List of default messages.
go-live-update-urls-pro/tests/trailing-slash-messages
Changes the messages displayed for the results of the verify the Old URL and New URL have matching slashes test.
Notice: You must keep the default array keys intact.
Accepts 1 argument:
array $messages
– List of default messages.
go-live-update-urls-pro/tests/repo/tests
Changes the tests which run during URL testing.
Must be a list of PHP class names. Defaults to:
Scheme::class
Trailing_Slash::class
Domain::class
Accepts 1 argument:
array $tests
– Default test class names.
Actions
go-live-update-urls-pro/admin/render
Fires within the admin tools page below the content.
Accepts 0 arguments.
go-live-update-urls-pro/admin/render/before
Fires within the admin tools page above the content.
Accepts 0 arguments.