| 1 |
<?php |
| 2 |
/** |
| 3 |
* Wistia Extension |
| 4 |
* |
| 5 |
* @package NotificationX\Extensions |
| 6 |
*/ |
| 7 |
|
| 8 |
namespace NotificationX\Extensions\GDPR; |
| 9 |
|
| 10 |
use NotificationX\GetInstance; |
| 11 |
use NotificationX\Core\Rules; |
| 12 |
use NotificationX\Extensions\GlobalFields; |
| 13 |
use NotificationX\Extensions\Extension; |
| 14 |
|
| 15 |
/** |
| 16 |
* GDPR Extension |
| 17 |
* @method static GDPR get_instance($args = null) |
| 18 |
*/ |
| 19 |
class GDPR_Notification extends Extension { |
| 20 |
/** |
| 21 |
* Instance of GDPR |
| 22 |
* |
| 23 |
* @var GDPR |
| 24 |
*/ |
| 25 |
use GetInstance; |
| 26 |
|
| 27 |
public $priority = 15; |
| 28 |
public $id = 'gdpr_notification'; |
| 29 |
public $doc_link = 'https://notificationx.com/docs/how-to-configure-cookies-policy-for-website/'; |
| 30 |
public $types = 'gdpr'; |
| 31 |
public $module = 'modules_gdpr'; |
| 32 |
// public $img = NOTIFICATIONX_ADMIN_URL . 'images/extensions/sources/GDPR.png'; |
| 33 |
|
| 34 |
/** |
| 35 |
* Initially Invoked when initialized. |
| 36 |
*/ |
| 37 |
public function __construct(){ |
| 38 |
parent::__construct(); |
| 39 |
add_filter('nx_design_tab_fields', [$this, 'design_fields'], 99); |
| 40 |
add_filter('nx_content_fields', array($this, 'content_fields'), 999); |
| 41 |
add_filter('nx_customize_fields', array($this, 'customize_fields'), 999); |
| 42 |
} |
| 43 |
|
| 44 |
public function init_extension() |
| 45 |
{ |
| 46 |
$this->title = __('GDPR', 'notificationx'); |
| 47 |
$this->module_title = __('Cookie Notice', 'notificationx'); |
| 48 |
} |
| 49 |
|
| 50 |
public function design_fields( $fields ) { |
| 51 |
if (isset($fields['advance_design_section']['fields']['design'])) { |
| 52 |
$fields['advance_design_section']['fields']['design'] = Rules::is('source', $this->id, true, $fields['advance_design_section']['fields']['design']); |
| 53 |
} |
| 54 |
if (isset($fields['advance_design_section']['fields']['typography'])) { |
| 55 |
$fields['advance_design_section']['fields']['typography'] = Rules::is('source', $this->id, true, $fields['advance_design_section']['fields']['typography']); |
| 56 |
} |
| 57 |
if (isset($fields['advance_design_section']['fields']['image-appearance'])) { |
| 58 |
$fields['advance_design_section']['fields']['image-appearance'] = Rules::is('source', $this->id, true, $fields['advance_design_section']['fields']['image-appearance']); |
| 59 |
} |
| 60 |
if (isset($fields['advance_design_section']['fields']['link_button_design'])) { |
| 61 |
$fields['advance_design_section']['fields']['link_button_design'] = Rules::is('source', $this->id, true, $fields['advance_design_section']['fields']['link_button_design']); |
| 62 |
} |
| 63 |
|
| 64 |
$fields['advance_design_section']['fields']['gdpr_design'] = [ |
| 65 |
'label' => __("Design", 'notificationx'), |
| 66 |
'name' => "gdpr_design", |
| 67 |
'type' => "section", |
| 68 |
'priority' => 5, |
| 69 |
'rules' => Rules::logicalRule([ |
| 70 |
Rules::is('source', $this->id, false), |
| 71 |
Rules::is('advance_edit', true), |
| 72 |
]), |
| 73 |
'fields' => [ |
| 74 |
[ |
| 75 |
'label' => __("Background Color", 'notificationx'), |
| 76 |
'name' => "gdpr_design_bg_color", |
| 77 |
'type' => "colorpicker", |
| 78 |
'default' => "", |
| 79 |
], |
| 80 |
[ |
| 81 |
'label' => __("Footer Background Color", 'notificationx'), |
| 82 |
'name' => "gdpr_design_ft_bg_color", |
| 83 |
'type' => "colorpicker", |
| 84 |
'default' => "", |
| 85 |
], |
| 86 |
[ |
| 87 |
'label' => __("Title Color", 'notificationx'), |
| 88 |
'name' => "title_text_color", |
| 89 |
'type' => "colorpicker", |
| 90 |
'default' => "", |
| 91 |
], |
| 92 |
[ |
| 93 |
'label' => __('Title Font Size', 'notificationx'), |
| 94 |
'name' => "title_font_size", |
| 95 |
'type' => "number", |
| 96 |
'default' => '20', |
| 97 |
'description' => 'px', |
| 98 |
'help' => __('This font size will be applied for <mark>Title</mark> only', 'notificationx'), |
| 99 |
], |
| 100 |
[ |
| 101 |
'label' => __("Description Color", 'notificationx'), |
| 102 |
'name' => "description_text_color", |
| 103 |
'type' => "colorpicker", |
| 104 |
'default' => "", |
| 105 |
], |
| 106 |
[ |
| 107 |
'label' => __('Description Font Size', 'notificationx'), |
| 108 |
'name' => "description_font_size", |
| 109 |
'type' => "number", |
| 110 |
'default' => '14', |
| 111 |
'description' => 'px', |
| 112 |
'help' => __('This font size will be applied for <mark>Description</mark> only', 'notificationx'), |
| 113 |
], |
| 114 |
[ |
| 115 |
'label' => __("Close Button Color", 'notificationx'), |
| 116 |
'name' => "close_btn_color", |
| 117 |
'type' => "colorpicker", |
| 118 |
'default' => "", |
| 119 |
'rules' => Rules::logicalRule([ |
| 120 |
Rules::is('themes', 'gdpr_theme-banner-light-one', true), |
| 121 |
Rules::is('themes', 'gdpr_theme-light-two', true), |
| 122 |
Rules::is('themes', 'gdpr_theme-light-four', true), |
| 123 |
Rules::is('themes', 'gdpr_theme-banner-dark-one', true), |
| 124 |
Rules::is('themes', 'gdpr_theme-dark-two', true), |
| 125 |
Rules::is('themes', 'gdpr_theme-dark-four', true), |
| 126 |
]), |
| 127 |
], |
| 128 |
[ |
| 129 |
'label' => __('Close Button Size', 'notificationx'), |
| 130 |
'name' => "close_btn_size", |
| 131 |
'type' => "number", |
| 132 |
'default' => '18', |
| 133 |
'description' => 'px', |
| 134 |
'rules' => Rules::logicalRule([ |
| 135 |
Rules::is('themes', 'gdpr_theme-banner-light-one', true), |
| 136 |
Rules::is('themes', 'gdpr_theme-light-two', true), |
| 137 |
Rules::is('themes', 'gdpr_theme-light-four', true), |
| 138 |
Rules::is('themes', 'gdpr_theme-banner-dark-one', true), |
| 139 |
Rules::is('themes', 'gdpr_theme-dark-two', true), |
| 140 |
Rules::is('themes', 'gdpr_theme-dark-four', true), |
| 141 |
]), |
| 142 |
], |
| 143 |
] |
| 144 |
]; |
| 145 |
|
| 146 |
$fields['advance_design_section']['fields']['gdpr_accept_btn'] = [ |
| 147 |
'label' => __("Accept Button", 'notificationx'), |
| 148 |
'name' => "gdpr_accept_btn", |
| 149 |
'type' => "section", |
| 150 |
'priority' => 6, |
| 151 |
'rules' => Rules::logicalRule([ |
| 152 |
Rules::is('source', $this->id, false), |
| 153 |
Rules::is('advance_edit', true), |
| 154 |
]), |
| 155 |
'fields' => [ |
| 156 |
[ |
| 157 |
'label' => __("Background Color", 'notificationx'), |
| 158 |
'name' => "gdpr_accept_btn_bg_color", |
| 159 |
'type' => "colorpicker", |
| 160 |
'default' => "", |
| 161 |
], |
| 162 |
[ |
| 163 |
'label' => __("Border Color", 'notificationx'), |
| 164 |
'name' => "gdpr_accept_btn_border_color", |
| 165 |
'type' => "colorpicker", |
| 166 |
'default' => "", |
| 167 |
], |
| 168 |
[ |
| 169 |
'label' => __("Text Color", 'notificationx'), |
| 170 |
'name' => "gdpr_accept_btn_text_color", |
| 171 |
'type' => "colorpicker", |
| 172 |
'default' => "", |
| 173 |
], |
| 174 |
[ |
| 175 |
'label' => __('Font Size', 'notificationx'), |
| 176 |
'name' => "gdpr_accept_btn_font_size", |
| 177 |
'type' => "number", |
| 178 |
'default' => '14', |
| 179 |
'description' => 'px', |
| 180 |
], |
| 181 |
] |
| 182 |
]; |
| 183 |
|
| 184 |
$fields['advance_design_section']['fields']['gdpr_reject_btn'] = [ |
| 185 |
'label' => __("Reject Button", 'notificationx'), |
| 186 |
'name' => "gdpr_reject_btn", |
| 187 |
'type' => "section", |
| 188 |
'priority' => 7, |
| 189 |
'rules' => Rules::logicalRule([ |
| 190 |
Rules::is('source', $this->id, false), |
| 191 |
Rules::is('advance_edit', true), |
| 192 |
Rules::is('themes', 'gdpr_theme-banner-light-two', true), |
| 193 |
Rules::is('themes', 'gdpr_theme-light-one', true), |
| 194 |
Rules::is('themes', 'gdpr_theme-light-three', true), |
| 195 |
Rules::is('themes', 'gdpr_theme-banner-dark-two', true), |
| 196 |
Rules::is('themes', 'gdpr_theme-dark-one', true), |
| 197 |
Rules::is('themes', 'gdpr_theme-dark-three', true), |
| 198 |
]), |
| 199 |
'fields' => [ |
| 200 |
[ |
| 201 |
'label' => __("Background Color", 'notificationx'), |
| 202 |
'name' => "gdpr_reject_btn_bg_color", |
| 203 |
'type' => "colorpicker", |
| 204 |
'default' => "", |
| 205 |
], |
| 206 |
[ |
| 207 |
'label' => __("Border Color", 'notificationx'), |
| 208 |
'name' => "gdpr_reject_btn_border_color", |
| 209 |
'type' => "colorpicker", |
| 210 |
'default' => "", |
| 211 |
], |
| 212 |
[ |
| 213 |
'label' => __("Text Color", 'notificationx'), |
| 214 |
'name' => "gdpr_reject_btn_text_color", |
| 215 |
'type' => "colorpicker", |
| 216 |
'default' => "", |
| 217 |
], |
| 218 |
[ |
| 219 |
'label' => __('Font Size', 'notificationx'), |
| 220 |
'name' => "gdpr_reject_btn_font_size", |
| 221 |
'type' => "number", |
| 222 |
'default' => '14', |
| 223 |
'description' => 'px', |
| 224 |
], |
| 225 |
] |
| 226 |
]; |
| 227 |
|
| 228 |
$fields['advance_design_section']['fields']['gdpr_customize_btn'] = [ |
| 229 |
'label' => __("Customize Button", 'notificationx'), |
| 230 |
'name' => "gdpr_customize_btn", |
| 231 |
'type' => "section", |
| 232 |
'priority' => 8, |
| 233 |
'rules' => Rules::logicalRule([ |
| 234 |
Rules::is('source', $this->id, false), |
| 235 |
Rules::is('advance_edit', true), |
| 236 |
]), |
| 237 |
'fields' => [ |
| 238 |
[ |
| 239 |
'label' => __("Background Color", 'notificationx'), |
| 240 |
'name' => "gdpr_customize_btn_bg_color", |
| 241 |
'type' => "colorpicker", |
| 242 |
'default' => "", |
| 243 |
], |
| 244 |
[ |
| 245 |
'label' => __("Border Color", 'notificationx'), |
| 246 |
'name' => "gdpr_customize_btn_border_color", |
| 247 |
'type' => "colorpicker", |
| 248 |
'default' => "", |
| 249 |
], |
| 250 |
[ |
| 251 |
'label' => __("Text Color", 'notificationx'), |
| 252 |
'name' => "gdpr_customize_btn_text_color", |
| 253 |
'type' => "colorpicker", |
| 254 |
'default' => "", |
| 255 |
], |
| 256 |
[ |
| 257 |
'label' => __('Font Size', 'notificationx'), |
| 258 |
'name' => "gdpr_customize_btn_font_size", |
| 259 |
'type' => "number", |
| 260 |
'default' => '14', |
| 261 |
'description' => 'px', |
| 262 |
], |
| 263 |
] |
| 264 |
]; |
| 265 |
|
| 266 |
return $fields; |
| 267 |
} |
| 268 |
|
| 269 |
public function customize_fields( $fields ) { |
| 270 |
if (isset($fields['appearance'])) { |
| 271 |
$fields['appearance'] = Rules::is('source', $this->id, true, $fields['appearance']); |
| 272 |
} |
| 273 |
if (isset($fields['queue_management'])) { |
| 274 |
$fields['queue_management'] = Rules::is('source', $this->id, true, $fields['queue_management']); |
| 275 |
} |
| 276 |
if (isset($fields['queue_management'])) { |
| 277 |
$fields['queue_management'] = Rules::is('source', $this->id, true, $fields['queue_management']); |
| 278 |
} |
| 279 |
if (isset($fields['timing'])) { |
| 280 |
$fields['timing'] = Rules::is('source', $this->id, true, $fields['timing']); |
| 281 |
} |
| 282 |
if (isset($fields['behaviour'])) { |
| 283 |
$fields['behaviour'] = Rules::is('source', $this->id, true, $fields['behaviour']); |
| 284 |
} |
| 285 |
if (isset($fields['sound_section'])) { |
| 286 |
$fields['sound_section'] = Rules::is('source', $this->id, true, $fields['sound_section']); |
| 287 |
} |
| 288 |
return $fields; |
| 289 |
} |
| 290 |
|
| 291 |
public function content_fields( $fields ) { |
| 292 |
if (isset($fields['utm_options'])) { |
| 293 |
$fields['utm_options'] = Rules::is('source', $this->id, true, $fields['utm_options']); |
| 294 |
} |
| 295 |
if (isset($fields['content'])) { |
| 296 |
$fields['content'] = Rules::is('source', $this->id, true, $fields['content']); |
| 297 |
} |
| 298 |
return $fields; |
| 299 |
} |
| 300 |
|
| 301 |
public function doc(){ |
| 302 |
/* translators: %1$s: step-by-step guides link URL, %2$s: tutorial link URL, %3$s: How to Display WordPress Cookie Notice Using NotificationX? link URL, %4$s: WP Consent API link URL */ |
| 303 |
return sprintf(__('<p>You can showcase Cookie Notice effortlessly on your WordPress site to ensure compliance with visitors. Need help? Follow our <a href="%1$s" target="_blank">step-by-step guides</a> for creating a Cookie Notice on the WordPress website.</p> |
| 304 |
<p>🎦 Watch the video <a target="_blank" href="%2$s">tutorial</a> for a quick guide.</p> |
| 305 |
<p><strong>Recommended Blogs:</strong></p> |
| 306 |
<p>🔥 <a target="_blank" href="%3$s">How to Display WordPress Cookie Notice Using NotificationX?</a></p> |
| 307 |
<p><strong>Recommended Plugins:</strong></p> |
| 308 |
<p>🔌 <a target="_blank" href="%4$s">WP Consent API</a> - Centralize cookie handling with a unified consent solution.</p>', 'notificationx'), |
| 309 |
'https://notificationx.com/docs/how-to-configure-cookies-policy-for-website/', |
| 310 |
'https://youtu.be/xMiRgH436SE', |
| 311 |
'https://notificationx.com/blog/display-wordpress-cookie-notice/', |
| 312 |
'https://wordpress.org/plugins/wp-consent-api/' |
| 313 |
); |
| 314 |
} |
| 315 |
|
| 316 |
} |
| 317 |
|