<?php
defined('ABSPATH') || exit;
abstract class WC_Abstract_Privacy
{
public $name;
protected $exporters = array();
protected $erasers = array();
protected $export_priority;
protected $erase_priority;
public function __construct($name = '', $export_priority = 5, $erase_priority = 10)
{
$this->name = $name;
$this->export_priority = $export_priority;
$this->erase_priority = $erase_priority;
$this->init();
}
protected function init()
{
add_action('admin_init', array($this, 'add_privacy_message'));
add_filter('wp_privacy_personal_data_exporters', array($this, 'register_exporters'), $this->export_priority);
add_filter('wp_privacy_personal_data_erasers', array($this, 'register_erasers'), $this->erase_priority);
}
public function add_privacy_message()
{
if (function_exists('wp_add_privacy_policy_content')) {
$content = $this->get_privacy_message();
if ($content) {
wp_add_privacy_policy_content($this->name, $this->get_privacy_message());
}
}
}
public function get_privacy_message()
{
return '';
}
public function register_exporters($exporters = array())
{
foreach ($this->exporters as $id => $exporter) {
$exporters[$id] = $exporter;
}
return $exporters;
}
public function register_erasers($erasers = array())
{
foreach ($this->erasers as $id => $eraser) {
$erasers[$id] = $eraser;
}
return $erasers;
}
public function add_exporter($id, $name, $callback)
{
$this->exporters[$id] = array('exporter_friendly_name' => $name, 'callback' => $callback);
return $this->exporters;
}
public function add_eraser($id, $name, $callback)
{
$this->erasers[$id] = array('eraser_friendly_name' => $name, 'callback' => $callback);
return $this->erasers;
}
}