PluginProbe ʕ •ᴥ•ʔ
Complianz – GDPR/CCPA Cookie Consent / 7.4.6
Complianz – GDPR/CCPA Cookie Consent v7.4.6
7.4.6 trunk 6.5.6 7.0.4 7.0.5 7.1.0 7.1.4 7.1.5 7.2.0 7.3.0 7.3.1 7.4.0 7.4.0.1 7.4.1 7.4.2 7.4.3 7.4.4 7.4.4.1 7.4.4.2 7.4.5 beta
complianz-gdpr / class-company.php
complianz-gdpr Last commit date
DNSMPD 2 months ago assets 1 month ago config 2 months ago cookie 1 month ago cookiebanner 1 month ago cron 7 months ago documents 2 months ago gutenberg 1 month ago integrations 1 month ago languages 1 month ago mailer 1 year ago onboarding 1 year ago placeholders 7 months ago progress 2 years ago proof-of-consent 1 month ago rest-api 1 month ago settings 1 month ago templates 6 months ago upgrade 1 month ago websitescan 2 months ago LICENSE.txt 4 years ago README.md 7 months ago class-admin.php 6 months ago class-company.php 2 years ago class-cookie-blocker.php 7 months ago class-export.php 2 years ago class-installer.php 2 years ago class-review.php 11 months ago complianz-gpdr.php 1 month ago functions-legacy.php 2 years ago functions.php 2 months ago index.php 7 years ago loco.xml 4 years ago readme.txt 1 month ago security.md 2 years ago system-status.php 1 year ago uninstall.php 1 month ago upgrade.php 2 months ago
class-company.php
156 lines
1 <?php
2 defined( 'ABSPATH' ) or die( "you do not have access to this page!" );
3
4 if ( ! class_exists( "cmplz_company" ) ) {
5 class cmplz_company {
6 private static $_this;
7
8
9 function __construct() {
10 if ( isset( self::$_this ) ) {
11 wp_die( sprintf( '%s is a singleton class and you cannot create a second instance.',
12 get_class( $this ) ) );
13 }
14 self::$_this = $this;
15 }
16
17 static function this() {
18 return self::$_this;
19 }
20
21 /**
22 * Get the default region based on region settings
23 * - if we have one region selected, return this
24 * - if we have more than one, try to get the one this company is based in
25 * - if nothing found, return company region
26 *
27 * @return string region
28 */
29
30 public function get_default_region() {
31 //check default region
32 $company_region_code = $this->get_company_region_code();
33 $regions = cmplz_get_regions();
34 $region = false;
35
36 if ( is_array( $regions ) ) {
37 $multiple_regions = count( $regions ) > 1;
38 foreach ( $regions as $region_code ) {
39
40 //if we have one region, just return the first result
41 if ( ! $multiple_regions ) {
42 return $region_code;
43 }
44
45 //if we have several regions, get the one this company is located in
46 if ( $company_region_code === $region_code ) {
47 $region = $region_code;
48 }
49 }
50 }
51
52 //fallback one: company location
53 if ( ! $region && is_array( $regions ) ) {
54 reset( $regions );
55 $region = key( $regions );
56 }
57
58 //fallback two: company location
59 if ( ! $region && ! empty( $company_region_code ) ) {
60 $region = $company_region_code;
61 }
62
63 //fallback if no array was returned.
64 if ( ! $region ) {
65 $region = CMPLZ_DEFAULT_REGION;
66 }
67
68 return $region;
69 }
70
71
72 /**
73 * Get the default consenttype based on region settings
74 *
75 * @return string consenttype
76 */
77
78 public function get_default_consenttype() {
79 //check default region
80 $region = $this->get_default_region();
81 $selected_regions = cmplz_get_regions();
82 if (!empty($selected_regions) && !in_array( $region, $selected_regions, true )) {
83 //get the first value in the array if it exists
84 $region = $selected_regions[0] ?? 'eu';
85 }
86 return apply_filters('cmplz_default_consenttype', cmplz_get_consenttype_for_region( $region ));
87 }
88
89 /**
90 * Get the company region code. The EU is a region, as is the US
91 *
92 * @return string region_code
93 *
94 * */
95
96 public function get_company_region_code() {
97 $country_code = cmplz_get_option( 'country_company' );
98 $countries = COMPLIANZ::$config->countries;
99 if ( !isset($countries[$country_code]) ) {
100 $country_code = 'US';
101 }
102 $region = cmplz_get_region_for_country( $country_code );
103 if ( $region ) {
104 return $region;
105 }
106
107 return CMPLZ_DEFAULT_REGION;
108 }
109
110 /**
111 * Check if data was sold in the past 12 months
112 *
113 * @return bool
114 */
115 public function sold_data_12months() {
116 if ( ! cmplz_sells_personal_data() ) {
117 return false;
118 }
119
120 $cats = cmplz_get_option( 'data_sold_us' );
121 if ( ! empty( $cats ) ) {
122 foreach ( $cats as $cat => $value ) {
123 if ( $value == 1 ) {
124 return true;
125 }
126 }
127 }
128
129 return false;
130
131 }
132
133 /**
134 * Check if data has been disclosed in the past 12 months
135 *
136 * @return bool
137 *
138 */
139 public function disclosed_data_12months() {
140 $cats = cmplz_get_option( 'data_disclosed_us' );
141 if ( ! empty( $cats ) ) {
142 foreach ( $cats as $cat => $value ) {
143 if ( $value == 1 ) {
144 return true;
145 }
146 }
147 }
148
149 return false;
150
151 }
152
153
154 }
155 } //class closure
156