[ label, detection callback ]. */ public static function providers() { return apply_filters( 'nodebook_consent_providers', array( 'wpconsent' => array( 'WP Consent API', static function () { return function_exists( 'wp_has_consent' ); } ), 'complianz' => array( 'Complianz', static function () { return defined( 'cmplz_version' ) || defined( 'CMPLZ_VERSION' ) || function_exists( 'cmplz_has_consent' ); } ), 'cookieyes' => array( 'CookieYes', static function () { return defined( 'CKY_APP_ASSETS_URL' ) || defined( 'CKY_VERSION' ) || defined( 'CLI_VERSION' ); } ), 'cookiebot' => array( 'Cookiebot', static function () { return class_exists( 'cybot\\cookiebot\\Cookiebot_WP' ) || class_exists( 'Cookiebot_WP' ) || defined( 'CYBOT_COOKIEBOT_VERSION' ); } ), 'borlabs' => array( 'Borlabs Cookie', static function () { return defined( 'BORLABS_COOKIE_VERSION' ); } ), 'rcb' => array( 'Real Cookie Banner', static function () { return defined( 'RCB_VERSION' ) || defined( 'RCB_FILE' ); } ), 'moove' => array( 'GDPR Cookie Compliance (Moove)', static function () { return defined( 'MOOVE_GDPR_VERSION' ); } ), ) ); } /** Labels of the consent tools active on this site. */ public static function detected() { $out = array(); foreach ( self::providers() as $key => $p ) { if ( call_user_func( $p[1] ) ) { $out[ $key ] = $p[0]; } } return $out; } /** May Nodebook set cookies / record visits for this request? */ public static function allowed() { if ( ! Nodebook_Settings::get( 'require_consent' ) ) { return true; } if ( function_exists( 'wp_has_consent' ) && wp_has_consent( 'statistics' ) ) { return true; } // Only the consent plugins' own cookies, each sanitized. $cookies = array(); foreach ( array( 'CookieConsent', 'borlabs-cookie', 'cmplz_statistics', 'cookielawinfo-checkbox-analytics', 'cookieyes-consent', 'moove_gdpr_popup' ) as $name ) { if ( isset( $_COOKIE[ $name ] ) && is_string( $_COOKIE[ $name ] ) ) { $cookies[ $name ] = sanitize_text_field( wp_unslash( $_COOKIE[ $name ] ) ); } } return (bool) apply_filters( 'nodebook_has_consent', self::from_cookies( $cookies ) ); } /** * Statistics/analytics consent read from known consent-plugin cookies. * * @param array $cookies Usually $_COOKIE. */ public static function from_cookies( array $cookies ) { $get = static function ( $name ) use ( $cookies ) { return isset( $cookies[ $name ] ) && is_string( $cookies[ $name ] ) ? sanitize_text_field( $cookies[ $name ] ) : ''; }; // Complianz. if ( 'allow' === $get( 'cmplz_statistics' ) ) { return true; } // CookieYes ("consent:yes,action:yes,necessary:yes,analytics:yes,…"). if ( preg_match( '/(^|,)analytics:yes(,|$)/', $get( 'cookieyes-consent' ) ) ) { return true; } // GDPR Cookie Consent (WebToffee/CookieYes legacy). if ( 'yes' === $get( 'cookielawinfo-checkbox-analytics' ) ) { return true; } // Cookiebot ("{stamp:'…',necessary:true,preferences:true,statistics:true,…}"). if ( preg_match( '/statistics:\s*true/', rawurldecode( $get( 'CookieConsent' ) ) ) ) { return true; } // Borlabs Cookie (JSON with consents.statistics). $borlabs = json_decode( rawurldecode( $get( 'borlabs-cookie' ) ), true ); if ( is_array( $borlabs ) && ! empty( $borlabs['consents']['statistics'] ) ) { return true; } // Moove GDPR ({"strict":"1","thirdparty":"1","advanced":"…"}). $moove = json_decode( rawurldecode( $get( 'moove_gdpr_popup' ) ), true ); if ( is_array( $moove ) && ! empty( $moove['thirdparty'] ) && '0' !== (string) $moove['thirdparty'] ) { return true; } return false; } }