| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codelight\GDPR\Admin; |
| 4 |
|
| 5 |
class AdminHelper |
| 6 |
{ |
| 7 |
public function __construct() |
| 8 |
{ |
| 9 |
$this->toolsHelper(); |
| 10 |
$this->autoinstallHelper(); |
| 11 |
$this->policyHelper(); |
| 12 |
$this->settingsHelper(); |
| 13 |
} |
| 14 |
|
| 15 |
protected function toolsHelper() |
| 16 |
{ |
| 17 |
global $gdpr; |
| 18 |
$toolsPage = $gdpr->Options->get('tools_page'); |
| 19 |
|
| 20 |
// Display the notice only on Tools page |
| 21 |
if (!$toolsPage || !isset($_GET['post']) || $_GET['post'] !== $toolsPage) { |
| 22 |
return; |
| 23 |
} |
| 24 |
|
| 25 |
$post = get_post($toolsPage); |
| 26 |
$helpUrl = gdpr('helpers')->siteOwnersGuide(); |
| 27 |
|
| 28 |
if (!stristr($post->post_content, '<!-- wp:shortcode -->[gdpr_privacy_tools]<!-- /wp:shortcode -->')) { |
| 29 |
gdpr('admin-notice')->add('admin/notices/helper-tools', compact('helpUrl')); |
| 30 |
} |
| 31 |
} |
| 32 |
|
| 33 |
protected function autoinstallHelper() |
| 34 |
{ |
| 35 |
if (!isset($_GET['gdpr-notice']) || empty($_GET['gdpr-notice']) || 'autoinstall' !== $_GET['gdpr-notice']) { |
| 36 |
return; |
| 37 |
} |
| 38 |
|
| 39 |
$helpUrl = gdpr('helpers')->PrivacyPolicy(); |
| 40 |
|
| 41 |
gdpr('admin-notice')->add('admin/notices/helper-autoinstall', compact('helpUrl')); |
| 42 |
} |
| 43 |
|
| 44 |
protected function policyHelper() |
| 45 |
{ |
| 46 |
global $gdpr; |
| 47 |
$policyPage = $gdpr->Options->get('policy_page'); |
| 48 |
|
| 49 |
// Display the notice only on Policy page |
| 50 |
if (!$policyPage || !isset($_GET['post']) || $_GET['post'] !== $policyPage) { |
| 51 |
return; |
| 52 |
} |
| 53 |
|
| 54 |
$post = get_post($policyPage); |
| 55 |
$helpUrl = gdpr('helpers')->docs(); |
| 56 |
|
| 57 |
if (stristr($post->post_content, '[TODO]')) { |
| 58 |
gdpr('admin-notice')->add('admin/notices/helper-policy', compact('helpUrl')); |
| 59 |
} |
| 60 |
} |
| 61 |
|
| 62 |
protected function settingsHelper() |
| 63 |
{ |
| 64 |
global $gdpr; |
| 65 |
if ($gdpr->Options->get('is_installed') && |
| 66 |
((!$gdpr->Options->get('tools_page') || is_null(get_post($gdpr->Options->get('tools_page'))))) && !$gdpr->Options->get('custom_tools_page')) { |
| 67 |
$this->renderSettingsHelperNotice(); |
| 68 |
} |
| 69 |
|
| 70 |
if ('download_and_notify' === $gdpr->Options->get('export_action') || 'notify' === $gdpr->Options->get('export_action')) { |
| 71 |
if (!$gdpr->Options->get('export_action_email')) { |
| 72 |
$this->renderSettingsHelperNotice(); |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
if ('anonymize_and_notify' === $gdpr->Options->get('delete_action') || |
| 77 |
'delete_and_notify' === $gdpr->Options->get('delete_action') || |
| 78 |
'notify' === $gdpr->Options->get('delete_action') |
| 79 |
) { |
| 80 |
if (!$gdpr->Options->get('delete_action_email')) { |
| 81 |
$this->renderSettingsHelperNotice(); |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
protected function renderSettingsHelperNotice() |
| 87 |
{ |
| 88 |
gdpr('admin-notice')->add('admin/notices/helper-settings'); |
| 89 |
} |
| 90 |
} |
| 91 |
|