| 1 |
<?php |
| 2 |
|
| 3 |
namespace Codelight\GDPR\Components\CookiePopup; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) exit; |
| 6 |
|
| 7 |
use Codelight\GDPR\Admin\AdminTab; |
| 8 |
|
| 9 |
class AdminTabCookiePopup extends AdminTab |
| 10 |
{ |
| 11 |
/* @var string */ |
| 12 |
protected $slug = 'cookie-popup'; |
| 13 |
|
| 14 |
/* @var PolicyGenerator */ |
| 15 |
protected $policyGenerator; |
| 16 |
|
| 17 |
public function __construct() |
| 18 |
{ |
| 19 |
$this->title = _x('Cookie Popup', '(Admin)', 'gdpr-framework'); |
| 20 |
$this->registerSetting('gdpr_enable_popup'); |
| 21 |
$this->registerSetting('gdpr_onetime_popup'); |
| 22 |
$this->registerSetting('gdpr_policy_popup'); |
| 23 |
$this->registerSetting('gdpr_popup_content', 'sanitize_textarea_field'); |
| 24 |
$this->registerSetting('gdpr_header', 'sanitize_textarea_field'); |
| 25 |
$this->registerSetting('gdpr_popup_position'); |
| 26 |
$this->registerSetting('gdpr_popup_theme'); |
| 27 |
$this->registerSetting('gdpr_popup_allow_text', 'sanitize_text_field'); |
| 28 |
$this->registerSetting('gdpr_popup_dismiss_text', 'sanitize_text_field'); |
| 29 |
$this->registerSetting('gdpr_popup_learnmore_text', 'sanitize_text_field'); |
| 30 |
$this->registerSetting('gdpr_popup_background', 'sanitize_hex_color'); |
| 31 |
$this->registerSetting('gdpr_popup_text', 'sanitize_hex_color'); |
| 32 |
$this->registerSetting('gdpr_popup_link_target'); |
| 33 |
$this->registerSetting('gdpr_popup_button_background', 'sanitize_hex_color'); |
| 34 |
$this->registerSetting('gdpr_popup_button_text', 'sanitize_hex_color'); |
| 35 |
$this->registerSetting('gdpr_popup_border_text', 'sanitize_text_field'); |
| 36 |
add_action('gdpr/admin/action/CookiePopup/generate', [$this, 'generateCookiePopup']); |
| 37 |
} |
| 38 |
|
| 39 |
public function init() |
| 40 |
{ |
| 41 |
/** |
| 42 |
* General settings |
| 43 |
*/ |
| 44 |
$this->registerSettingSection( |
| 45 |
'gdpr_cookie_popup_setting', |
| 46 |
_x('Cookie Popup Settings', '(Admin)', 'gdpr-framework') |
| 47 |
); |
| 48 |
$this->registerSettingField( |
| 49 |
'gdpr_enable_popup', |
| 50 |
_x('Enable Cookie Acceptance Popup', '(Admin)', 'gdpr-framework'), |
| 51 |
[$this, 'renderEnableCheckboxpopup'], |
| 52 |
'gdpr_cookie_popup_setting' |
| 53 |
); |
| 54 |
$this->registerSettingField( |
| 55 |
'gdpr_onetime_popup', |
| 56 |
_x('Enable One Time Cookie Acceptance Popup', '(Admin)', 'gdpr-framework'), |
| 57 |
[$this, 'renderEnableOneTimeCheckboxpopup'], |
| 58 |
'gdpr_cookie_popup_setting' |
| 59 |
); |
| 60 |
$this->registerSettingField( |
| 61 |
'gdpr_policy_popup', |
| 62 |
_x('Enable Privacy policy on Popup', '(Admin)', 'gdpr-framework'), |
| 63 |
[$this, 'renderEnablePolicyOnPopup'], |
| 64 |
'gdpr_cookie_popup_setting' |
| 65 |
); |
| 66 |
$this->registerSettingField( |
| 67 |
'gdpr_header', |
| 68 |
_x('Cookie Acceptance Popup header', '(Admin)', 'gdpr-framework'), |
| 69 |
[$this, 'renderheaderCheckboxpopup'], |
| 70 |
'gdpr_cookie_popup_setting' |
| 71 |
); |
| 72 |
$this->registerSettingField( |
| 73 |
'gdpr_popup_content', |
| 74 |
_x('Cookie Acceptance Popup Content', '(Admin)', 'gdpr-framework'), |
| 75 |
[$this, 'rendercontentCheckboxpopup'], |
| 76 |
'gdpr_cookie_popup_setting' |
| 77 |
); |
| 78 |
/** |
| 79 |
* GDPR Popup setting |
| 80 |
*/ |
| 81 |
$this->registerSettingSection( |
| 82 |
'gdpr_popup_section', |
| 83 |
_x('Acceptance Popup Setting', '(Admin)', 'gdpr-framework') |
| 84 |
); |
| 85 |
|
| 86 |
$this->registerSettingField( |
| 87 |
'gdpr_popup_position', |
| 88 |
_x('Popup Position', '(Admin)', 'gdpr-framework'), |
| 89 |
[$this, 'renderPopupPositionSelector'], |
| 90 |
'gdpr_popup_section' |
| 91 |
); |
| 92 |
|
| 93 |
$this->registerSettingField( |
| 94 |
'gdpr_popup_theme', |
| 95 |
_x('Popup theme', '(Admin)', 'gdpr-framework'), |
| 96 |
[$this, 'renderPopupThemeSelector'], |
| 97 |
'gdpr_popup_section' |
| 98 |
); |
| 99 |
|
| 100 |
$this->registerSettingField( |
| 101 |
'gdpr_popup_allow_text', |
| 102 |
_x('Popup Allow Text', '(Admin)', 'gdpr-framework'), |
| 103 |
[$this, 'renderAllowContentPopup'], |
| 104 |
'gdpr_popup_section' |
| 105 |
); |
| 106 |
|
| 107 |
$this->registerSettingField( |
| 108 |
'gdpr_popup_dismiss_text', |
| 109 |
_x('Popup Dismiss Text', '(Admin)', 'gdpr-framework'), |
| 110 |
[$this, 'renderDismissContentPopup'], |
| 111 |
'gdpr_popup_section' |
| 112 |
); |
| 113 |
|
| 114 |
$this->registerSettingField( |
| 115 |
'gdpr_popup_learnmore_text', |
| 116 |
_x('Popup Learn More Text', '(Admin)', 'gdpr-framework'), |
| 117 |
[$this, 'renderlearnmorePopup'], |
| 118 |
'gdpr_popup_section' |
| 119 |
); |
| 120 |
|
| 121 |
$this->registerSettingField( |
| 122 |
'gdpr_popup_link_target', |
| 123 |
_x('Cookie Acceptance link target', '(Admin)', 'gdpr-framework'), |
| 124 |
[$this, 'renderpopuplinktarget'], |
| 125 |
'gdpr_popup_section' |
| 126 |
); |
| 127 |
|
| 128 |
$this->registerSettingField( |
| 129 |
'gdpr_popup_background', |
| 130 |
_x('Cookie Acceptance Background Color', '(Admin)', 'gdpr-framework'), |
| 131 |
[$this, 'renderpopupBackgroundcolor'], |
| 132 |
'gdpr_popup_section' |
| 133 |
); |
| 134 |
|
| 135 |
$this->registerSettingField( |
| 136 |
'gdpr_popup_text', |
| 137 |
_x('Cookie Acceptance Text Color', '(Admin)', 'gdpr-framework'), |
| 138 |
[$this, 'renderpopupTextcolor'], |
| 139 |
'gdpr_popup_section' |
| 140 |
); |
| 141 |
|
| 142 |
$this->registerSettingField( |
| 143 |
'gdpr_popup_button_background', |
| 144 |
_x('Cookie Acceptance Button Background Color', '(Admin)', 'gdpr-framework'), |
| 145 |
[$this, 'renderbuttonBackgroundcolor'], |
| 146 |
'gdpr_popup_section' |
| 147 |
); |
| 148 |
|
| 149 |
$this->registerSettingField( |
| 150 |
'gdpr_popup_button_text', |
| 151 |
_x('Cookie Acceptance Button Color', '(Admin)', 'gdpr-framework'), |
| 152 |
[$this, 'renderbuttonTextcolor'], |
| 153 |
'gdpr_popup_section' |
| 154 |
); |
| 155 |
|
| 156 |
$this->registerSettingField( |
| 157 |
'gdpr_popup_border_text', |
| 158 |
_x('Cookie Acceptance Border Color', '(Admin)', 'gdpr-framework'), |
| 159 |
[$this, 'renderborderTextcolor'], |
| 160 |
'gdpr_popup_section' |
| 161 |
); |
| 162 |
} |
| 163 |
|
| 164 |
public function renderHeader() |
| 165 |
{ |
| 166 |
echo gdpr('view')->render('admin/advanced-integration/header'); |
| 167 |
} |
| 168 |
public function renderEnableCheckbox() |
| 169 |
{ |
| 170 |
global $gdpr; |
| 171 |
$enabled = $gdpr->Options->get('enable'); |
| 172 |
echo gdpr('view')->render('admin/general/enable', compact('enabled')); |
| 173 |
} |
| 174 |
|
| 175 |
public function renderEnableCheckboxtac() |
| 176 |
{ |
| 177 |
global $gdpr; |
| 178 |
$enabled = $gdpr->Options->get('enable_tac'); |
| 179 |
echo gdpr('view')->render('admin/general/enable-tac', compact('enabled')); |
| 180 |
} |
| 181 |
public function renderCommentCheckbox() |
| 182 |
{ |
| 183 |
global $gdpr; |
| 184 |
$content['option_name'] = 'comment_checkbox'; |
| 185 |
$content['value'] = $gdpr->Options->get('comment_checkbox'); |
| 186 |
$content['option'] = _x('Disable Checkbox For Comments', '(Admin)', 'gdpr-framework'); |
| 187 |
echo gdpr('view')->render('admin/general/disble-checkbox', compact('content')); |
| 188 |
} |
| 189 |
public function renderRegisterCheckbox() |
| 190 |
{ |
| 191 |
global $gdpr; |
| 192 |
$content['option_name'] = 'register_checkbox'; |
| 193 |
$content['value'] = $gdpr->Options->get('register_checkbox'); |
| 194 |
$content['option'] = _x('Disable Checkbox For Register Form', '(Admin)', 'gdpr-framework'); |
| 195 |
echo gdpr('view')->render('admin/general/disble-checkbox', compact('content')); |
| 196 |
} |
| 197 |
public function renderEnableCheckboxpopup() |
| 198 |
{ |
| 199 |
global $gdpr; |
| 200 |
$enabled = $gdpr->Options->get('enable_popup'); |
| 201 |
echo gdpr('view')->render('admin/general/enable-popup', compact('enabled')); |
| 202 |
} |
| 203 |
public function renderEnableOneTimeCheckboxpopup() |
| 204 |
{ |
| 205 |
global $gdpr; |
| 206 |
$enabled = $gdpr->Options->get('onetime_popup'); |
| 207 |
echo gdpr('view')->render('admin/general/enable-onetime-popup', compact('enabled')); |
| 208 |
} |
| 209 |
public function renderEnablePolicyOnPopup() |
| 210 |
{ |
| 211 |
global $gdpr; |
| 212 |
$enabled = $gdpr->Options->get('policy_popup'); |
| 213 |
echo gdpr('view')->render('admin/general/enable-policy-popup', compact('enabled')); |
| 214 |
} |
| 215 |
public function renderheaderCheckboxpopup() |
| 216 |
{ |
| 217 |
global $gdpr; |
| 218 |
$content = $gdpr->Options->get('header'); |
| 219 |
echo gdpr('view')->render('admin/general/enable_popup_header', compact('content')); |
| 220 |
} |
| 221 |
public function rendercontentCheckboxpopup() |
| 222 |
{ |
| 223 |
global $gdpr; |
| 224 |
$content = $gdpr->Options->get('popup_content'); |
| 225 |
echo gdpr('view')->render('admin/general/enable_popup_content', compact('content')); |
| 226 |
} |
| 227 |
public function renderNameFrom() |
| 228 |
{ |
| 229 |
global $gdpr; |
| 230 |
$content = $gdpr->Options->get('name_from'); |
| 231 |
echo gdpr('view')->render('admin/general/name_from', compact('content')); |
| 232 |
} |
| 233 |
public function renderEmailFrom() |
| 234 |
{ |
| 235 |
global $gdpr; |
| 236 |
$content = $gdpr->Options->get('email_from'); |
| 237 |
echo gdpr('view')->render('admin/general/email_from', compact('content')); |
| 238 |
} |
| 239 |
public function renderAllowContentPopup() |
| 240 |
{ |
| 241 |
global $gdpr; |
| 242 |
$content = $gdpr->Options->get('popup_allow_text'); |
| 243 |
echo gdpr('view')->render('admin/general/enable_popup_allow_content', compact('content')); |
| 244 |
} |
| 245 |
public function renderDismissContentPopup() |
| 246 |
{ |
| 247 |
global $gdpr; |
| 248 |
$content = $gdpr->Options->get('popup_dismiss_text'); |
| 249 |
echo gdpr('view')->render('admin/general/enable_popup_dismiss_content', compact('content')); |
| 250 |
} |
| 251 |
public function renderlearnmorePopup() |
| 252 |
{ |
| 253 |
global $gdpr; |
| 254 |
$content = $gdpr->Options->get('popup_learnmore_text'); |
| 255 |
echo gdpr('view')->render('admin/general/enable_popup_learnmore_content', compact('content')); |
| 256 |
} |
| 257 |
public function renderpopupBackgroundcolor() |
| 258 |
{ |
| 259 |
global $gdpr; |
| 260 |
$content['value'] = $gdpr->Options->get('popup_background'); |
| 261 |
$content['option'] = 'background'; |
| 262 |
echo gdpr('view')->render('admin/general/popup_background_color_picker', compact('content')); |
| 263 |
} |
| 264 |
public function renderpopupTextcolor() |
| 265 |
{ |
| 266 |
global $gdpr; |
| 267 |
$content['value'] = $gdpr->Options->get('popup_text'); |
| 268 |
$content['option'] = 'text'; |
| 269 |
echo gdpr('view')->render('admin/general/popup_background_color_picker', compact('content')); |
| 270 |
} |
| 271 |
public function renderpopuplinktarget() |
| 272 |
{ |
| 273 |
global $gdpr; |
| 274 |
$content = $gdpr->Options->get('popup_link_target'); |
| 275 |
echo gdpr('view')->render('admin/general/popup_link_target', compact('content')); |
| 276 |
} |
| 277 |
public function renderbuttonBackgroundcolor() |
| 278 |
{ |
| 279 |
global $gdpr; |
| 280 |
$content['value'] = $gdpr->Options->get('popup_button_background'); |
| 281 |
$content['option'] = 'button_background'; |
| 282 |
echo gdpr('view')->render('admin/general/popup_background_color_picker', compact('content')); |
| 283 |
} |
| 284 |
public function renderbuttonTextcolor() |
| 285 |
{ |
| 286 |
global $gdpr; |
| 287 |
$content['value'] = $gdpr->Options->get('popup_button_text'); |
| 288 |
$content['option'] = 'button_text'; |
| 289 |
echo gdpr('view')->render('admin/general/popup_background_color_picker', compact('content')); |
| 290 |
} |
| 291 |
public function renderborderTextcolor() |
| 292 |
{ |
| 293 |
global $gdpr; |
| 294 |
$content['value'] = $gdpr->Options->get('popup_border_text'); |
| 295 |
$content['option'] = 'border_text'; |
| 296 |
echo gdpr('view')->render('admin/general/popup_background_color_picker', compact('content')); |
| 297 |
} |
| 298 |
public function renderPopupPositionSelector() |
| 299 |
{ |
| 300 |
global $gdpr; |
| 301 |
$positionAction = $gdpr->Options->get('popup_position'); |
| 302 |
echo gdpr('view')->render('admin/general/position-action', compact('positionAction')); |
| 303 |
echo gdpr('view')->render('admin/general/description-position-action'); |
| 304 |
} |
| 305 |
public function renderPopupThemeSelector() |
| 306 |
{ |
| 307 |
global $gdpr; |
| 308 |
$themeAction = $gdpr->Options->get('popup_theme'); |
| 309 |
echo gdpr('view')->render('admin/general/theme-action', compact('themeAction')); |
| 310 |
echo gdpr('view')->render('admin/general/description-theme-action'); |
| 311 |
} |
| 312 |
} |
| 313 |
|