1 | <?php |
---|
2 | /** |
---|
3 | * Integrations Doc Comment |
---|
4 | * |
---|
5 | * @category Views |
---|
6 | * @package gdpr-cookie-compliance |
---|
7 | * @author Moove Agency |
---|
8 | */ |
---|
9 | |
---|
10 | if ( ! defined( 'ABSPATH' ) ) { |
---|
11 | exit; |
---|
12 | } // Exit if accessed directly |
---|
13 | |
---|
14 | $gdpr_default_content = new Moove_GDPR_Content(); |
---|
15 | $option_name = $gdpr_default_content->moove_gdpr_get_option_name(); |
---|
16 | $gdpr_options = get_option( $option_name ); |
---|
17 | $wpml_lang = $gdpr_default_content->moove_gdpr_get_wpml_lang(); |
---|
18 | $gdpr_options = is_array( $gdpr_options ) ? $gdpr_options : array(); |
---|
19 | |
---|
20 | if ( isset( $_POST ) && isset( $_POST['moove_gdpr_nonce'] ) ) : |
---|
21 | $nonce = sanitize_key( $_POST['moove_gdpr_nonce'] ); |
---|
22 | if ( ! wp_verify_nonce( $nonce, 'moove_gdpr_nonce_field' ) ) : |
---|
23 | die( 'Security check' ); |
---|
24 | else : |
---|
25 | if ( isset( $_POST['gdpr_integrations'] ) && is_array( $_POST['gdpr_integrations'] ) ) : |
---|
26 | $gdpr_gdin_values = array(); |
---|
27 | |
---|
28 | $third_party_allowed = isset( $gdpr_options['moove_gdpr_third_party_cookies_enable'] ) && intval( $gdpr_options['moove_gdpr_third_party_cookies_enable'] ) === 1; |
---|
29 | $advanced_allowed = isset( $gdpr_options['moove_gdpr_advanced_cookies_enable'] ) && intval( $gdpr_options['moove_gdpr_advanced_cookies_enable'] ) === 1; |
---|
30 | foreach ( $_POST['gdpr_integrations'] as $_gdin_slug ) : |
---|
31 | $gdin_slug = sanitize_text_field( wp_unslash( $_gdin_slug ) ); |
---|
32 | $tracking_id = isset( $_POST['gdpr_integrations_'. $gdin_slug.'_id'] ) ? sanitize_text_field( wp_unslash( $_POST['gdpr_integrations_'. $gdin_slug.'_id'] ) ) : false; |
---|
33 | if ( $tracking_id ) : |
---|
34 | $gdin_value = isset( $_POST['gdpr_integrations_' . $gdin_slug ] ) && intval( $_POST['gdpr_integrations_' . $gdin_slug ] ) ? intval( $_POST['gdpr_integrations_' . $gdin_slug ] ) : 2; |
---|
35 | if ( $gdin_value === 2 && ! $third_party_allowed ) : |
---|
36 | $gdpr_options['moove_gdpr_third_party_cookies_enable'] = 1; |
---|
37 | endif; |
---|
38 | |
---|
39 | if ( $gdin_value === 3 && ! $advanced_allowed ) : |
---|
40 | $gdpr_options['moove_gdpr_advanced_cookies_enable'] = 1; |
---|
41 | endif; |
---|
42 | |
---|
43 | $gdpr_gdin_values[ $gdin_slug ] = $gdin_value; |
---|
44 | $gdpr_gdin_values[ $gdin_slug . '_id' ] = $tracking_id; |
---|
45 | endif; |
---|
46 | endforeach; |
---|
47 | $gdpr_options['gdin_values'] = json_encode( $gdpr_gdin_values ); |
---|
48 | else : |
---|
49 | $gdpr_options['gdin_values'] = json_encode( array() ); |
---|
50 | endif; |
---|
51 | |
---|
52 | update_option( $option_name, $gdpr_options ); |
---|
53 | $gdpr_options = get_option( $option_name ); |
---|
54 | if ( ! empty( $gdpr_gdin_values ) && isset( $gdpr_gdin_values['gtm4wp'] ) ) : |
---|
55 | if ( defined('GTM4WP_OPTIONS') ) : |
---|
56 | $storedoptions = (array) get_option( GTM4WP_OPTIONS ); |
---|
57 | if ( defined ( 'GTM4WP_OPTION_GTM_PLACEMENT' ) && defined ( 'GTM4WP_PLACEMENT_OFF' ) ) : |
---|
58 | $storedoptions[GTM4WP_OPTION_GTM_PLACEMENT] = GTM4WP_PLACEMENT_OFF; |
---|
59 | update_option( GTM4WP_OPTIONS, $storedoptions ); |
---|
60 | endif; |
---|
61 | endif; |
---|
62 | endif; |
---|
63 | |
---|
64 | do_action( 'gdpr_cookie_filter_settings' ); |
---|
65 | ?> |
---|
66 | <script> |
---|
67 | jQuery('#moove-gdpr-setting-error-settings_updated').show(); |
---|
68 | </script> |
---|
69 | <?php |
---|
70 | endif; |
---|
71 | endif; |
---|
72 | |
---|
73 | $nav_label_2 = isset( $gdpr_options[ 'moove_gdpr_performance_cookies_tab_title' . $wpml_lang ] ) && $gdpr_options[ 'moove_gdpr_performance_cookies_tab_title' . $wpml_lang ] ? $gdpr_options[ 'moove_gdpr_performance_cookies_tab_title' . $wpml_lang ] : __( '3rd Party Cookies', 'gdpr-cookie-compliance' ); |
---|
74 | |
---|
75 | $nav_label_3 = isset( $gdpr_options[ 'moove_gdpr_advanced_cookies_tab_title' . $wpml_lang ] ) && $gdpr_options[ 'moove_gdpr_advanced_cookies_tab_title' . $wpml_lang ] ? $gdpr_options[ 'moove_gdpr_advanced_cookies_tab_title' . $wpml_lang ] : __( 'Additional Cookies', 'gdpr-cookie-compliance' ); |
---|
76 | |
---|
77 | ?> |
---|
78 | <form action="<?php echo esc_url( admin_url( 'admin.php' ) ); ?>?page=moove-gdpr&tab=integrations" method="post"> |
---|
79 | <?php wp_nonce_field( 'moove_gdpr_nonce_field', 'moove_gdpr_nonce' ); ?> |
---|
80 | <h2><?php echo $wpml_lang ? esc_html__('Integrations for all languages','gdpr-cookie-compliance') : esc_html__('Integrations','gdpr-cookie-compliance'); ?></h2> |
---|
81 | <h4 class="description"> |
---|
82 | <?php esc_html_e('Connect your GA/GTM or Meta Pixel tracking easily to the cookie categories used by this plugin.','gdpr-cookie-compliance'); ?> |
---|
83 | <br> |
---|
84 | <?php esc_html_e('Using the settings below, you can ensure that the tracking scripts will be loaded only if your website visitors accept the selected cookie category.','gdpr-cookie-compliance'); ?> |
---|
85 | <br/> |
---|
86 | <?php esc_html_e('Please ensure that you remove any hard-coded GA/GTM or Facebook/Meta Pixel scripts from your website theme or other plugins (including any other parts of this plugin) to prevent duplicate activation of the same scripts.','gdpr-cookie-compliance'); ?> |
---|
87 | <?php if ( $wpml_lang ) : ?> |
---|
88 | <br/> |
---|
89 | <?php esc_html_e('If you enable these integrations, they will be applied to all your language variations.'); ?> |
---|
90 | <?php endif; ?> |
---|
91 | </h4> |
---|
92 | <table class="form-table"> |
---|
93 | <tbody> |
---|
94 | |
---|
95 | <tr> |
---|
96 | <td colspan="2" style="padding: 0;"> |
---|
97 | <table class="gdpr-gsk-table"> |
---|
98 | <thead> |
---|
99 | <tr> |
---|
100 | <th>Integration</th> |
---|
101 | <th>Status</th> |
---|
102 | <th>Tracking ID</th> |
---|
103 | <th>Cookie Category</th> |
---|
104 | </tr> |
---|
105 | </thead> |
---|
106 | <tbody> |
---|
107 | <?php |
---|
108 | $gdin_values = isset( $gdpr_options['gdin_values'] ) ? json_decode( $gdpr_options['gdin_values'], true ) : array(); |
---|
109 | $gdin_modules = gdpr_get_integration_modules( $gdpr_options, $gdin_values ); |
---|
110 | |
---|
111 | if ( ! empty( $gdin_modules ) && is_array( $gdin_modules ) ) : |
---|
112 | foreach ( $gdin_modules as $_gdin_module_slug => $_gdin_module ) : |
---|
113 | ?> |
---|
114 | <tr> |
---|
115 | <td> |
---|
116 | <strong><?php echo $_gdin_module['name']; ?></strong><br> |
---|
117 | <small><?php echo $_gdin_module['desc']; ?></small> |
---|
118 | </td> |
---|
119 | <td> |
---|
120 | <label class="gdpr-checkbox-toggle"> |
---|
121 | <input type="checkbox" id="gdpr_integrations_<?php echo $_gdin_module_slug; ?>" name="gdpr_integrations[]" <?php echo $_gdin_module['status'] ? 'checked' : ''; ?> id="gdpr_integrations" value="<?php echo $_gdin_module_slug; ?>" > |
---|
122 | <span class="gdpr-checkbox-slider" data-enable="<?php esc_html_e( 'Enabled', 'gdpr-cookie-compliance' ); ?>" data-disable="<?php esc_html_e( 'Disabled', 'gdpr-cookie-compliance' ); ?>"></span> |
---|
123 | </label> |
---|
124 | </td> |
---|
125 | <td> |
---|
126 | <div class="gdpr-conditional-field" data-dependency="#gdpr_integrations_<?php echo $_gdin_module_slug; ?>"> |
---|
127 | <input type="text" class="regular-text" <?php echo isset( $_gdin_module['atts'] ) && isset( $_gdin_module['atts']['input'] ) ? $_gdin_module['atts']['input'] : ''; ?> name="gdpr_integrations_<?php echo $_gdin_module_slug; ?>_id" placeholder="<?php echo $_gdin_module['id_format']; ?>" value="<?php echo isset( $_gdin_module['tacking_id'] ) && $_gdin_module['tacking_id'] ? $_gdin_module['tacking_id'] : ''; ?>"> |
---|
128 | <?php if ( isset( $_gdin_module['atts'] ) && isset( $_gdin_module['atts']['input'] ) && 'disabled' === $_gdin_module['atts']['input'] ) : ?> |
---|
129 | <input type="hidden" name="gdpr_integrations_<?php echo $_gdin_module_slug; ?>_id" value="<?php echo isset( $_gdin_module['tacking_id'] ) && $_gdin_module['tacking_id'] ? $_gdin_module['tacking_id'] : ''; ?>"> |
---|
130 | <?php endif; ?> |
---|
131 | </div> |
---|
132 | <!-- .gdpr-conditional-field --> |
---|
133 | </td> |
---|
134 | <td> |
---|
135 | <div class="gdpr-conditional-field" data-dependency="#gdpr_integrations_<?php echo $_gdin_module_slug; ?>"> |
---|
136 | <select name="gdpr_integrations_<?php echo $_gdin_module_slug; ?>" id="gdpr_integrations_<?php echo $_gdin_module_slug; ?>"> |
---|
137 | <option value="2" <?php echo isset( $_gdin_module['cookie_cat'] ) && intval( $_gdin_module['cookie_cat'] ) === 2 ? 'selected' : ''; ?> ><?php echo $nav_label_2; ?></option> |
---|
138 | |
---|
139 | <option value="3" <?php echo isset( $_gdin_module['cookie_cat'] ) && intval( $_gdin_module['cookie_cat'] ) === 3 ? 'selected' : ''; ?>><?php echo $nav_label_3; ?></option> |
---|
140 | </select> |
---|
141 | <!-- # --> |
---|
142 | </div> |
---|
143 | <!-- .gdpr-conditional-field --> |
---|
144 | </td> |
---|
145 | </tr> |
---|
146 | <?php |
---|
147 | endforeach; |
---|
148 | ?> |
---|
149 | <?php |
---|
150 | else : |
---|
151 | ?> |
---|
152 | <tr> |
---|
153 | <td colspan="8"><?php esc_html_e( 'No integration modules found.', 'gdpr-cookie-compliance-addon' ); ?></td> |
---|
154 | </tr> |
---|
155 | <?php |
---|
156 | endif; |
---|
157 | |
---|
158 | ?> |
---|
159 | </tbody> |
---|
160 | </table> |
---|
161 | </td> |
---|
162 | </tr> |
---|
163 | </tbody> |
---|
164 | </table> |
---|
165 | |
---|
166 | <?php do_action( 'gdpr_below_integrations_table' ); ?> |
---|
167 | <br> |
---|
168 | <hr /> |
---|
169 | <br /> |
---|
170 | <button type="submit" class="button button-primary"><?php esc_html_e( 'Save changes', 'gdpr-cookie-compliance-addon' ); ?></button> |
---|
171 | <?php do_action( 'gdpr_cc_banner_buttons_settings' ); ?> |
---|
172 | </form> |
---|