$_gdin_module ) : if ( isset( $_gdin_module['tacking_id'] ) && $_gdin_module['tacking_id'] && $_gdin_module['status'] ) : $cache_array = apply_filters( 'gdpr_insert_integration_' . $_gdin_module_slug . '_snippet', $cache_array, $_gdin_module ); endif; endforeach; endif; return $cache_array; } /** * Loads the simplified admin top menu items * * @param array $active_tab Active Tab. * @param array $current_gcat Active Tab Category. * @param array $modal_options Plugin settings. * @return array $wpml_lang Translation slug. */ public static function gdpr_admin_top_nav_links_gcat( $active_tab, $current_gcat ) { $current_gcat = $current_gcat ? $current_gcat : ( ! isset( $_GET['tab'] ) && isset( $_GET['page'] ) && esc_attr( $_GET['page'] ) === 'moove-gdpr' ? 'settings' : '' ); $view_cnt = new GDPR_View(); $tab_data = $view_cnt->load( 'moove.admin.nav-tabs.' . $current_gcat, array( 'active_tab' => $active_tab, 'current_gcat' => $current_gcat )); apply_filters( 'gdpr_cc_keephtml', $tab_data, true ); } /** * Integration Extensions * * @param array $cache_array Cache array. * @param array $_gdin_module Integration Module. */ public static function gdpr_insert_integration_ga_snippet( $cache_array, $_gdin_module ) { if ( isset( $_gdin_module['tacking_id'] ) && $_gdin_module['tacking_id'] && intval( $_gdin_module['cookie_cat'] ) ) : $cookie_cat_n = ''; switch ( intval( $_gdin_module['cookie_cat'] ) ) { case 2: $cookie_cat_n = 'thirdparty'; break; case 3: $cookie_cat_n = 'advanced'; break; case 4: $cookie_cat_n = 'performance'; break; case 5: $cookie_cat_n = 'preference'; break; default: // code... break; } if ( $cookie_cat_n ) : ob_start(); ?> moove_gdpr_get_option_name(); $gdpr_options = get_option( $option_name ); $gdin_values = isset( $gdpr_options['gdin_values'] ) ? json_decode( $gdpr_options['gdin_values'], true ) : array(); $gdin_modules = gdpr_get_integration_modules( $gdpr_options, $gdin_values ); if ( isset( $gdin_modules['gtmc2'] ) && isset( $gdin_modules['gtmc2']['tacking_id'] ) && $gdin_modules['gtmc2']['status'] ) : self::gdpr_render_gtm_consent_default( $gdin_modules['gtmc2']['tacking_id'] ); endif; } /** * Renders the Consent Mode v2 head half: the 'consent default' call followed by * the GTM container or Google tag loader (see gdpr_render_google_tag_loader()). * * Shared by the free (default language) and premium (WPML language-specific) * entry points. It used to be duplicated, and the two copies drifted - the * premium one kept emitting a hardcoded all-denied default long after this one * learned to read the returning visitor's stored decision, so translated pages * silently lost the ecommerce behaviour described below. * * Read the user's stored consent before GTM loads so that returning visitors * who have already accepted cookies receive 'granted' defaults from the very * first gtag() call. Without this, the Consent Update fires after GTM has * already initialised, which is too late for ecommerce events * (view_item_list, view_item, add_to_cart) triggered on page load - those * events are blocked and never retro-fired by GTM. * * Consent type mapping (must stay in step with the update half - see * gdpr_insert_integration_gtmc2_snippet): * strict -> functionality_storage, security_storage * thirdparty -> analytics_storage (GA4 / GTM analytics tags) * advanced -> ad_storage, ad_user_data, ad_personalization * preference -> personalization_storage * * When the site has switched off thirdparty or advanced, the other one covers * its signals too - see gdpr_consent_signal_categories(). * * The state is resolved in the browser rather than rendered by PHP: this * markup is served from the page cache, so baking one visitor's decision * into it would hand that decision to every subsequent visitor. See * gdpr_consent_cookie_js_preamble(). The read is still synchronous and * still happens before GTM loads, so the ecommerce behaviour above is * unaffected. * * @param string $tag_id GTM container ID (GTM-XXXXXX) or Google tag ID (G-XXXXXXX). * @return void */ public static function gdpr_render_gtm_consent_default( $tag_id ) { // The ID lands inside a JS string in a '. A // container or tag ID is only ever [A-Za-z0-9_-], so constrain it to that // instead of relying on the output escaper alone. $tag_id = preg_replace( '/[^A-Za-z0-9_-]/', '', trim( $tag_id ) ); if ( ! $tag_id || defined( 'GDPR_CC_GTM2_HEAD_DONE' ) ) : return; endif; define( 'GDPR_CC_GTM2_HEAD_DONE', true ); // wait_for_update is off unless a site opts in through the filter. Google's // tag does not treat it as a maximum wait: GA4 holds its hits until a consent // update carrying the ad signals arrives, and the update half sends nothing // until the banner is answered - so any value here suppresses the Advanced // Consent Mode cookieless pings for first-time visitors. Stored consent is // read synchronously below, before GTM loads, so there is nothing to wait for. // When enabled it only applies on first visit (no stored consent); for // returning users the values are final. $wait_for_update_ms = absint( apply_filters( 'gdpr_cc_gtm2_wait_for_update', 0 ) ); $consent_regions = self::gdpr_consent_regions(); $signal_cats = self::gdpr_consent_signal_categories(); ?> block. */ private static function gdpr_consent_cookie_js_preamble() { // document.cookie throws in a sandboxed iframe without allow-same-origin; // both reads fail closed to 'denied' rather than leaving consent unset. $preamble = "var _gdpr_c = {}, _gdpr_m = null, _gdpr_has = false;\n" . "\t\t\t\ttry { _gdpr_m = document.cookie.match(/(?:^|;\\s*)moove_gdpr_popup=([^;]*)/); _gdpr_has = !! _gdpr_m; } catch ( e ) {}\n" . "\t\t\t\tif ( _gdpr_m ) { try { _gdpr_c = JSON.parse( decodeURIComponent( _gdpr_m[1] ) ) || {}; } catch ( e ) { _gdpr_c = {}; } }\n"; // Only while geo location is on: the session cookie outlives the setting, and // once it is off main.js ignores the cookie and shows the banner again. // Version and shape must match gdpr_geo_cache_write() in main.js - a cookie // of any other version is ignored there too. 'strict' is always on for these // visitors, as in moove_gdpr_check_cookie(). if ( self::gdpr_geo_location_enabled() ) : $preamble .= "\t\t\t\tif ( ! _gdpr_has ) { try {\n" . "\t\t\t\t\tvar _gdpr_g = document.cookie.match(/(?:^|;\\s*)moove_gdpr_geo_cache=([^;]*)/);\n" . "\t\t\t\t\t_gdpr_g = _gdpr_g ? JSON.parse( decodeURIComponent( _gdpr_g[1] ) ) : null;\n" . "\t\t\t\t\tif ( _gdpr_g && _gdpr_g.v === 3 && _gdpr_g.display_cookie_banner === 'false' && _gdpr_g.enabled_default ) {\n" . "\t\t\t\t\t\t_gdpr_g = _gdpr_g.enabled_default;\n" . "\t\t\t\t\t\t_gdpr_c = { strict: 1, thirdparty: _gdpr_g.third_party, advanced: _gdpr_g.advanced, performance: _gdpr_g.performance, preference: _gdpr_g.preference };\n" . "\t\t\t\t\t\t_gdpr_has = true;\n" . "\t\t\t\t\t}\n" . "\t\t\t\t} catch ( e ) {} }\n"; endif; return $preamble . "\t\t\t\tvar _gdpr_state = function( k ) { return _gdpr_has && parseInt( _gdpr_c[ k ], 10 ) === 1 ? 'granted' : 'denied'; };"; } /** * Whether the premium add-on's geo location rules decide who sees the banner. * * A site setting, not per-visitor state, so it is safe to bake into cached markup. * * @return bool */ private static function gdpr_geo_location_enabled() { $gdpr_default_content = new Moove_GDPR_Content(); $gdpr_options = get_option( $gdpr_default_content->moove_gdpr_get_option_name() ); return 'true' === apply_filters( 'gdpr_cc_geolocation_status', 'false', $gdpr_options ); } /** * The cookie categories the analytics and ad consent signals follow on this site. * * Analytics signals follow 'thirdparty' and ad signals 'advanced' - unless the * site has switched that category off. Enabling the Consent Mode v2 integration * only switches on the category picked for it ('Analytics' by default), so many * sites have just one of the two. The missing category's value in the consent * cookie then depends on the button pressed: "Accept all" stores 1 for every * category, saving the settings stores 0 for one that has no switch. Visitors * who opted in to the same thing got different ad signals, and a GTM tag that * required ad_storage never fired for anyone who saved their settings. With one * of the two categories off, the other one stands for both, as it does in the * banner. * * A site setting, not per-visitor state, so it is safe to bake into cached * markup. Saving either category, or the integrations, purges the script cache. * * Also handed to main.js, which denies the signals of a withdrawn category in * the current page - see gdpr_stop_withdrawn_google_tags() there. * * @return array 'analytics' and 'ads', each a cookie category key. */ public static function gdpr_consent_signal_categories() { $gdpr_default_content = new Moove_GDPR_Content(); $gdpr_options = get_option( $gdpr_default_content->moove_gdpr_get_option_name() ); $third_party = isset( $gdpr_options['moove_gdpr_third_party_cookies_enable'] ) && 1 === intval( $gdpr_options['moove_gdpr_third_party_cookies_enable'] ); $advanced = isset( $gdpr_options['moove_gdpr_advanced_cookies_enable'] ) && 1 === intval( $gdpr_options['moove_gdpr_advanced_cookies_enable'] ); return array( 'analytics' => $third_party || ! $advanced ? 'thirdparty' : 'advanced', 'ads' => $advanced || ! $third_party ? 'advanced' : 'thirdparty', ); } /** * Region-specific Consent Mode defaults for the premium add-on's geo location rules. * * With geo location on, whether a visitor is shown the banner is only known once * the location request answers, seconds after Google's tag has started. Until then * every first-time visitor was 'denied', so visitors outside the targeted regions * were measured without cookies on their first page view. Google's tag can apply * the rules itself from the start, given the regions. The add-on provides them * through the gdpr_cc_gtm2_consent_regions filter: * * array( 'default' => 'granted' | 'denied', 'regions' => array( 'US-CA', 'DE', ... ) ) * * 'default' applies outside the listed regions; inside them it is the opposite. * * A site setting, not per-visitor state, so it is safe to bake into cached markup. * * @return array 'default', 'inside' and 'regions', or an empty array when not in use. */ private static function gdpr_consent_regions() { if ( ! self::gdpr_geo_location_enabled() ) : return array(); endif; $gdpr_default_content = new Moove_GDPR_Content(); $gdpr_options = get_option( $gdpr_default_content->moove_gdpr_get_option_name() ); $config = apply_filters( 'gdpr_cc_gtm2_consent_regions', array(), $gdpr_options ); if ( ! is_array( $config ) || ! isset( $config['default'], $config['regions'] ) || ! is_array( $config['regions'] ) || empty( $config['regions'] ) ) : return array(); endif; if ( ! in_array( $config['default'], array( 'granted', 'denied' ), true ) ) : return array(); endif; // ISO 3166 country or subdivision codes only - they are printed into a script. // One bad code disables the lot: dropping it from a 'denied' list would grant // that region instead. foreach ( $config['regions'] as $region ) : if ( ! is_string( $region ) || ! preg_match( '/^[A-Z]{2}(-[A-Z0-9]{1,3})?$/', $region ) ) : return array(); endif; endforeach; return array( 'default' => $config['default'], 'inside' => 'granted' === $config['default'] ? 'denied' : 'granted', 'regions' => array_values( array_unique( $config['regions'] ) ), ); } /** * Microsoft Clarity - Consent API v2. * * Unlike the other snippet modules, Clarity is NOT held back until consent is * given. The Consent API is signal-based: the tag loads on every page view and * is told what it may store. With analytics_Storage denied Clarity runs in * "no-consent mode" - no first or third party cookies, a throwaway ID per page * view - which is what lets it keep working lawfully before the visitor decides. * * Emitting this on wp_head (rather than only after the banner is accepted) means * returning visitors get their stored decision applied on the very first call, * before Clarity has a chance to write anything. The state itself is resolved in * the browser - see gdpr_consent_cookie_js_preamble() for why. * * Consent type mapping: * analytics_Storage -> the category the module is assigned to on the * Integrations screen (Clarity is analytics tooling). * ad_Storage -> 'advanced', the plugin's advertising/targeting * category ('thirdparty' when the site has switched * it off), matching the Consent Mode v2 mapping above. * * @see https://learn.microsoft.com/en-us/clarity/setup-and-installation/clarity-consent-api-v2 */ public static function gdpr_clarity_consent_snippet() { $gdpr_default_content = new Moove_GDPR_Content(); $option_name = $gdpr_default_content->moove_gdpr_get_option_name(); $gdpr_options = get_option( $option_name ); $gdin_values = isset( $gdpr_options['gdin_values'] ) ? json_decode( $gdpr_options['gdin_values'], true ) : array(); $gdin_modules = gdpr_get_integration_modules( $gdpr_options, $gdin_values ); if ( ! isset( $gdin_modules['clarity'] ) || empty( $gdin_modules['clarity']['status'] ) ) : return; endif; $project_id = isset( $gdin_modules['clarity']['tacking_id'] ) ? trim( $gdin_modules['clarity']['tacking_id'] ) : ''; $cookie_cat = gdpr_get_cookie_cat_slug( $gdin_modules['clarity']['cookie_cat'] ); if ( ! $project_id || ! $cookie_cat ) : return; endif; $signal_cats = self::gdpr_consent_signal_categories(); ?> * signal mapping, or the plugin grants permissions the visitor was never asked * for: * * strict -> functionality_storage, security_storage * thirdparty -> analytics_storage (GA4 / GTM analytics tags) * advanced -> ad_storage, ad_user_data, ad_personalization * preference -> personalization_storage * * When the site has switched off thirdparty or advanced, the other one covers * its signals too - see gdpr_consent_signal_categories(). * * The mapping is fixed by Consent Mode semantics, so - as in the wp_head half - * the module's own 'cookie_cat' assignment is deliberately not consulted here. * It only ever decided which cache bucket the snippet landed in, which is what * previously made a single accepted category grant all seven signals. * * State is resolved in the browser rather than rendered by PHP: this markup is * cached per category and each bucket is served to whoever accepted that one * category, while the payload has to describe every category. See * gdpr_consent_cookie_js_preamble(). * * Injected into every gated bucket, because the visitor may have accepted any * subset of them and only the accepted buckets are delivered. The copies report * the same resolved state, and repeating it would duplicate the * 'cookie_consent_update' event and double-fire any GTM tag bound to it, so a * copy only sends a state that differs from the last one sent. That is the first * copy on page load, and the newly accepted category's copy when the visitor * turns on more categories without a reload: the update and the event then go * out again, so the tags waiting for that consent fire in this page. * * 'strict' is excluded on purpose: the AJAX delivery path never returns that * bucket, and the static path can inject it before the visitor has decided * anything (the "enabled on first visit" default). A visitor who accepts * nothing but strict therefore gets no update at all - correct, since the * wp_head defaults already describe that state. * * Withdrawal is handled in main.js: before the page reloads, it denies the * withdrawn signals and switches Google Analytics off in the current page (see * gdpr_stop_withdrawn_google_tags()). The wp_head snippet of the reloaded page * then emits the denied state. * * @param array $cache_array Cache array. * @param array $_gdin_module Integration Module. */ public static function gdpr_insert_integration_gtmc2_snippet( $cache_array, $_gdin_module ) { if ( ! isset( $_gdin_module['tacking_id'] ) || ! $_gdin_module['tacking_id'] ) : return $cache_array; endif; if ( defined( 'gdpr_i_gtmc2_h' ) ) : return $cache_array; endif; $signal_cats = self::gdpr_consent_signal_categories(); ob_start(); ?> 'moove_gdpr_third_party_cookies_enable', 'advanced' => 'moove_gdpr_advanced_cookies_enable', 'performance' => 'moove_gdpr_performance_ccat_enable', 'preference' => 'moove_gdpr_preference_ccat_enable', ) ); $gdpr_default_content = new Moove_GDPR_Content(); $gdpr_options = get_option( $gdpr_default_content->moove_gdpr_get_option_name() ); $injected = false; foreach ( $gated_buckets as $_bucket_key => $_enable_key ) : // Skip categories the site has switched off, so free installs do not // carry empty premium buckets around in the script cache. $enabled = ! $_enable_key || ( isset( $gdpr_options[ $_enable_key ] ) && 1 === intval( $gdpr_options[ $_enable_key ] ) ); if ( ! $enabled && ! isset( $cache_array[ $_bucket_key ] ) ) : continue; endif; if ( ! isset( $cache_array[ $_bucket_key ] ) || ! is_array( $cache_array[ $_bucket_key ] ) ) : $cache_array[ $_bucket_key ] = array( 'header' => '', 'body' => '', 'footer' => '', ); endif; if ( ! isset( $cache_array[ $_bucket_key ]['header'] ) ) : $cache_array[ $_bucket_key ]['header'] = ''; endif; // Ahead of the category's own scripts, so tags injected with it (the GA4 // integration, pasted Google tags) see the updated state before their // first hit rather than after it. $cache_array[ $_bucket_key ]['header'] = $gtmc2_snippet . $cache_array[ $_bucket_key ]['header']; $injected = true; endforeach; if ( $injected ) : define( 'gdpr_i_gtmc2_h', true ); endif; return $cache_array; } /** * The Consent Mode v2 update payload as _gdpr_update, shared by the update and * its re-assert so the category -> signal mapping exists once on this side. * * Expects _gdpr_state() in scope - see gdpr_consent_cookie_js_preamble(). * * @param array $signal_cats See gdpr_consent_signal_categories(). * @return string JavaScript, for embedding inside a moove_gdpr_get_option_name() ); $gdin_values = isset( $gdpr_options['gdin_values'] ) ? json_decode( $gdpr_options['gdin_values'], true ) : array(); $gdin_modules = gdpr_get_integration_modules( $gdpr_options, $gdin_values ); if ( ! empty( $gdin_modules['gtmc2']['status'] ) && ! empty( $gdin_modules['gtmc2']['tacking_id'] ) && 0 === strcasecmp( trim( $gdin_modules['gtmc2']['tacking_id'] ), trim( $_gdin_module['tacking_id'] ) ) ) : return $cache_array; endif; endif; if ( defined( 'GTM4WP_OPTIONS' ) && defined( 'GTM4WP_OPTION_GTM_PLACEMENT' ) && defined( 'GTM4WP_PLACEMENT_OFF' ) ) : $storedoptions = (array) get_option( GTM4WP_OPTIONS ); $gtm4wp_container_code_written = false; if ( ( isset( $storedoptions[ GTM4WP_OPTION_GTM_PLACEMENT ] ) && GTM4WP_PLACEMENT_OFF === $storedoptions[ GTM4WP_OPTION_GTM_PLACEMENT ] ) && isset( $_gdin_module['tacking_id'] ) && $_gdin_module['tacking_id'] && intval( $_gdin_module['cookie_cat'] ) ) : $cookie_cat_n = ''; switch ( intval( $_gdin_module['cookie_cat'] ) ) { case 2: $cookie_cat_n = 'thirdparty'; break; case 3: $cookie_cat_n = 'advanced'; break; case 4: $cookie_cat_n = 'performance'; break; case 5: $cookie_cat_n = 'preference'; break; default: // code... break; } if ( $cookie_cat_n && ! $gtm4wp_container_code_written ) : ob_start(); ?> ' . __( 'This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.', 'gdpr-cookie-compliance' ) . '
'; return $_content; } /** * Returns the GDPR activation key * * @param string $option_key Option key. */ public function gdpr_get_activation_key( $option_key ) { $value = get_option( $option_key ); if ( is_multisite() && ! $value ) : $_value = function_exists( 'get_site_option' ) ? get_site_option( $option_key ) : false; if ( $_value ) : $main_blog_id = get_main_site_id(); if ( $main_blog_id ) : switch_to_blog( $main_blog_id ); update_option( $option_key, $_value ); restore_current_blog(); delete_site_option( $option_key ); $value = $_value; endif; endif; endif; return $value; } /** * JavaScript localize extension */ public static function moove_gdpr_get_localize_scripts() { $loc_data = array(); $gdpr_loc_data = apply_filters( 'gdpr_extend_loc_data', $loc_data ); return $gdpr_loc_data; } /** * Strict Necessary Tab Content * * @return string Filtered Content. */ public function moove_gdpr_get_strict_necessary_content() { $_content = '' . __( 'Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.', 'gdpr-cookie-compliance' ) . '
'; return $_content; } /** * Advanced Cookies Tab Content * * @return string Filtered Content. */ public function moove_gdpr_get_advanced_cookies_content() { $_content = '' . __( 'This website uses the following additional cookies:
(List the cookies that you are using on the website here.)', 'gdpr-cookie-compliance' ) . '
'; return $_content; } /** * Third Party Cookies Tab Content * * @return string Filtered Content. */ public function moove_gdpr_get_third_party_content() { $_content = '' . __( 'This website uses Google Analytics to collect anonymous information such as the number of visitors to the site, and the most popular pages.', 'gdpr-cookie-compliance' ); $_content .= '
' . __( 'Keeping this cookie enabled helps us to improve our website.', 'gdpr-cookie-compliance' ) . '
'; return $_content; } /** * Cookie Policy Tab Content * * @return string Filtered Content. */ public function moove_gdpr_get_cookie_policy_content() { $privacy_policy_page = get_option( 'wp_page_for_privacy_policy' ); $privacy_policy_link = $privacy_policy_page ? esc_url( get_permalink( $privacy_policy_page ) ) : false; $privacy_policy_link = $privacy_policy_link ? $privacy_policy_link : '#'; $_content = '' . sprintf( __( 'More information about our [privacy_link]Cookie Policy[/privacy_link]', 'gdpr-cookie-compliance' ), $privacy_policy_link ) . '
'; $_content = str_replace( '[privacy_link]', '', $_content ); $_content = str_replace( '[/privacy_link]', '', $_content ); return $_content; } /** * Cookie Policy Tab Content * * @return string Filtered Content. */ public function moove_gdpr_ifb_content() { $_content = '' . __( 'Please enable the cookies to view this content', 'gdpr-cookie-compliance' );
$_content .= '
';
$_content .= '{accept}' . esc_html__( 'Accept', 'gdpr-cookie-compliance' ) . '{/accept} ';
$_content .= '{setting}' . esc_html__( 'Adjust your settings', 'gdpr-cookie-compliance' ) . '{/setting}';
return $_content;
}
/**
* Get option name
*/
public function moove_gdpr_get_option_name() {
return 'moove_gdpr_plugin_settings';
}
/**
* Get option name
*/
public function moove_gdpr_get_key_name() {
return 'moove_gdpr_plugin_key';
}
/**
* Get WMPL language code
*
* @param string $type Type.
*/
public function moove_gdpr_get_wpml_lang( $type = 'code' ) {
if ( function_exists( 'trp_get_languages' ) && isset( $_GET['gdpr-lang'] ) && is_admin() ) : // phpcs:ignore
$lang_code = sanitize_text_field( wp_unslash( $_GET['gdpr-lang'] ) ); // phpcs:ignore
if ( 'code' === $type ) :
return $lang_code;
else :
$trp_languages = trp_get_languages();
return isset( $trp_languages[ $lang_code ] ) ? $trp_languages[ $lang_code ] : '';
endif;
elseif ( class_exists( 'Falang' ) && isset( $_GET['gdpr-lang'] ) && is_admin() ) : // phpcs:ignore
$lang_code = sanitize_text_field( wp_unslash( $_GET['gdpr-lang'] ) ); // phpcs:ignore
if ( 'code' === $type ) :
return $lang_code;
else :
$falang_languages = Falang()->get_model()->get_languages_list();
$lang_name = $lang_code;
foreach ( $falang_languages as $language ) :
$_code = isset( $language->locale ) ? $language->locale : ( isset( $language->slug ) ? $language->slug : '' );
$lang_name = $_code === $lang_code && isset( $language->name ) ? $language->name : $lang_name;
endforeach;
return $lang_name;
endif;
else :
if ( function_exists( 'trp_get_languages' ) ) :
$trp_languages = trp_get_languages();
global $TRP_LANGUAGE; // phpcs:ignore
return 'code' === $type ? $TRP_LANGUAGE : $trp_languages[ $TRP_LANGUAGE ]; // phpcs:ignore
elseif ( class_exists( 'Falang' ) ) :
$current_language = Falang()->get_current_language();
if ( 'code' === $type ) :
$lang = isset( $current_language->locale ) ? $current_language->locale : ( isset( $current_language->slug ) ? $current_language->slug : '' );
else :
$lang = isset( $current_language->name ) ? $current_language->name : '';
endif;
return $lang;
elseif ( defined( 'ICL_LANGUAGE_CODE' ) ) :
$language_code = ICL_LANGUAGE_CODE;
if ( ICL_LANGUAGE_CODE === 'all' ) :
if ( function_exists( 'pll_default_language' ) ) :
$language_code = pll_default_language();
elseif ( class_exists( 'SitePress' ) ) :
global $sitepress;
$language_code = $sitepress->get_default_language();
endif;
endif;
return '_' . $language_code;
elseif ( isset( $GLOBALS['q_config']['language'] ) ) :
return $GLOBALS['q_config']['language'];
elseif ( function_exists( 'wpm_get_user_language' ) ) :
return wpm_get_user_language();
endif;
endif;
return '';
}
/**
* Licence token
*/
public function get_license_token() {
$license_token = trailingslashit( site_url() );
return $license_token;
}
/**
* Licence hash
*/
public function get_license_hash() {
$license_token = is_multisite() ? trailingslashit( network_home_url() ) : trailingslashit( site_url() );
return $license_token;
}
/**
* PHP Cookie Checker, available from version 1.3.0
*/
public function gdpr_get_php_cookies() {
$cookies_accepted = array(
'strict' => false,
'thirdparty' => false,
'advanced' => false,
'performance' => false,
'preference' => false,
);
if ( isset( $_COOKIE['moove_gdpr_popup'] ) ) :
$cookies = sanitize_text_field( wp_unslash( $_COOKIE['moove_gdpr_popup'] ) );
$cookies_decoded = json_decode( wp_unslash( $cookies ), true );
if ( $cookies_decoded && is_array( $cookies_decoded ) && ! empty( $cookies_decoded ) ) :
$cookies_accepted = array(
'strict' => isset( $cookies_decoded['strict'] ) && intval( $cookies_decoded['strict'] ) === 1 ? true : false,
'thirdparty' => isset( $cookies_decoded['thirdparty'] ) && intval( $cookies_decoded['thirdparty'] ) === 1 ? true : false,
'advanced' => isset( $cookies_decoded['advanced'] ) && intval( $cookies_decoded['advanced'] ) === 1 ? true : false,
'performance' => isset( $cookies_decoded['performance'] ) && intval( $cookies_decoded['performance'] ) === 1 ? true : false,
'preference' => isset( $cookies_decoded['preference'] ) && intval( $cookies_decoded['preference'] ) === 1 ? true : false,
);
endif;
else :
$options_name = $this->moove_gdpr_get_option_name();
$gdpr_options = get_option( $options_name );
$wpml_lang_options = $this->moove_gdpr_get_wpml_lang();
$strictly_functionality = isset( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) && intval( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) ? intval( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) : 1;
$strictly_default = isset( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) && intval( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) ? intval( $gdpr_options['moove_gdpr_strictly_necessary_cookies_functionality'] ) : 0;
$strictly_default = 4 === $strictly_default || 2 === $strictly_default ? 1 : 0;
$thirdparty_default = isset( $gdpr_options['moove_gdpr_third_party_cookies_enable_first_visit'] ) && intval( $gdpr_options['moove_gdpr_third_party_cookies_enable_first_visit'] ) ? intval( $gdpr_options['moove_gdpr_third_party_cookies_enable_first_visit'] ) : 0;
$advanced_default = isset( $gdpr_options['moove_gdpr_advanced_cookies_enable_first_visit'] ) && intval( $gdpr_options['moove_gdpr_advanced_cookies_enable_first_visit'] ) ? intval( $gdpr_options['moove_gdpr_advanced_cookies_enable_first_visit'] ) : 0;
$performance_default = isset( $gdpr_options['moove_gdpr_performance_ccat_enable_first_visit'] ) && intval( $gdpr_options['moove_gdpr_performance_ccat_enable_first_visit'] ) ? intval( $gdpr_options['moove_gdpr_performance_ccat_enable_first_visit'] ) : 0;
$preference_default = isset( $gdpr_options['moove_gdpr_preference_ccat_enable_first_visit'] ) && intval( $gdpr_options['moove_gdpr_preference_ccat_enable_first_visit'] ) ? intval( $gdpr_options['moove_gdpr_preference_ccat_enable_first_visit'] ) : 0;
if ( 1 === $strictly_functionality && 1 !== $strictly_default ) :
if ( 1 === $thirdparty_default || 1 === $advanced_default || 1 === $performance_default || 1 === $preference_default ) :
$strict_default = 1;
else :
$strict_default = 2 === $strictly_default ? 1 : 0;
endif;
else :
$strict_default = 1;
endif;
$cookies_accepted = array(
'strict' => $strict_default,
'thirdparty' => $thirdparty_default,
'advanced' => $advanced_default,
'performance' => $performance_default,
'preference' => $preference_default,
);
endif;
return $cookies_accepted;
}
/**
* GDPR Licence action button
*
* @param array $response Response.
* @param string $gdpr_key GDPR Key.
*/
public static function gdpr_licence_action_button( $response, $gdpr_key ) {
$type = isset( $response['type'] ) ? $response['type'] : false;
if ( 'server_unavailable' === $type && isset( $gdpr_key['activation'] ) ) :
// Licence is still active here, only the shop could not confirm it.
return;
endif;
if ( 'expired' === $type || 'activated' === $type || 'max_activation_reached' === $type ) :
if ( 'activated' !== $type ) :
?>
', $store_link ); $store_link = str_replace( '[/store_link]', '', $store_link ); apply_filters( 'gdpr_cc_keephtml', $store_link, true ); ?>
', $store_link ); $store_link = str_replace( '[/store_link]', '', $store_link ); apply_filters( 'gdpr_cc_keephtml', $store_link, true ); ?>
', $store_link ); $store_link = str_replace( '[/store_link]', '', $store_link ); apply_filters( 'gdpr_cc_keephtml', $store_link, true ); ?>
', $response['message'] ) : ''; if ( isset( $response['type'] ) && ( $response['type'] === 'inactive' || $response['type'] === 'max_activation_reached' || $response['type'] === 'suspended' ) ) : // phpcs:ignore $gdpr_default_content = new Moove_GDPR_Content(); $option_key = $gdpr_default_content->moove_gdpr_get_key_name(); $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); update_option( $option_key, array( 'key' => $response['key'], 'deactivation' => strtotime( 'now' ), ) ); $gdpr_key = $gdpr_default_content->gdpr_get_activation_key( $option_key ); endif; ?>
', $response['message'] ) : ''; ?>