PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 4.7.4
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v4.7.4
4.7.4 4.7.5 4.7.3 4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 All 95 releases
cookiebot / src / addons / controller / addons / jetpack / widget / Googleplus_Badge_Jetpack_Widget.php

Googleplus_Badge_Jetpack_Widget.php in Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode 4.7.4, at src/addons/controller/addons/jetpack/widget/Googleplus_Badge_Jetpack_Widget.php

71 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace cybot\cookiebot\addons\controller\addons\jetpack\widget;
4
5 use function cybot\cookiebot\lib\cookiebot_addons_cookieconsent_optout;
6
7 class Googleplus_Badge_Jetpack_Widget extends Base_Jetpack_Widget {
8
9
10 const LABEL = 'Google Plus Badge';
11 const WIDGET_OPTION_NAME = 'googleplus_badge';
12 const DEFAULT_PLACEHOLDER = 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to enable google plus badge.';
13
14 /**
15 * @var array list of supported cookie types
16 *
17 * @since 1.3.0
18 */
19 private $cookie_types = array();
20
21 /**
22 * Load configuration
23 */
24 public function load_configuration() {
25 if (
26 // The widget is active
27 is_active_widget( false, false, 'googleplus-badge', true ) &&
28 // The widget is enabled in Prior consent
29 $this->is_widget_enabled() &&
30 // The visitor didn't check the required cookie types
31 ! $this->cookie_consent->are_cookie_states_accepted( $this->get_widget_cookie_types() )
32 ) {
33 $this->cookie_types = $this->get_widget_cookie_types();
34
35 $this->disable_javascript_file();
36
37 if ( $this->is_widget_placeholder_enabled() ) {
38 add_action( 'jetpack_stats_extra', array( $this, 'display_div_message_to_go_to_consent_settings' ), 10, 2 );
39 }
40 }
41 }
42
43 /**
44 * Disable javascript file if marketing consent is not given
45 *
46 * @since 1.2.0
47 */
48 private function disable_javascript_file() {
49 $this->script_loader_tag->add_tag( 'googleplus-widget', $this->cookie_types );
50 }
51
52 /**
53 * Show a message to go to consent settings
54 *
55 * @param $view string
56 * @param $widget string
57 *
58 * @since 1.2.0
59 */
60 public function display_div_message_to_go_to_consent_settings( $view, $widget ) {
61 if (
62 ( $widget === 'googleplus-badge' && $view === 'widget_view' ) &&
63 ( is_array( $this->cookie_types ) && count( $this->cookie_types ) > 0 )
64 ) {
65 $classname = cookiebot_addons_cookieconsent_optout( $this->cookie_types );
66 $inner_html = $this->get_widget_placeholder();
67 echo '<div class="' . esc_attr( $classname ) . '">' . esc_html( $inner_html ) . '</div>';
68 }
69 }
70 }
71