Loader That assists with adding GDPR-compliant exporters to a WordPress website.
composer require underpin/exporter-loader
This plugin uses a built-in autoloader, so as long as it is required before Underpin, it should work as-expected.
require_once(__DIR__ . '/underpin-exporters/exporters.php');
- Install Underpin. See Underpin Docs
- Register new exporters menus as-needed.
A very basic example could look something like this.
// Register exporter
underpin()->exporters()->add( 'exporter', [
'id' => 'example-exporter', // required
'name' => __( 'translate-able name', 'domain' ), // required
'get_data_callback' => '__return_empty_array', // Required. See Exporter::get_data
'get_items_callback' => '__return_true', // Required. See Exporter::get_items
] );
Alternatively, you can extend Exporter
and reference the extended class directly, like so:
underpin()->exporters()->add('exporter-key','Namespace\To\Class');