Changeset 3421335
- Timestamp:
- 12/16/2025 06:29:19 PM (2 months ago)
- Location:
- fitconsent-cmp/trunk
- Files:
-
- 2 edited
-
fitconsent-cmp.php (modified) (4 diffs)
-
readme.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
fitconsent-cmp/trunk/fitconsent-cmp.php
r3410990 r3421335 4 4 * Plugin URI: https://fitconsent.com 5 5 * Description: Integrates the FitConsent Consent Management Platform with WordPress and the WP Consent API for Google Site Kit compatibility. 6 * Version: 1.0. 26 * Version: 1.0.3 7 7 * Author: DIGITLOAD 8 8 * Author URI: https://digitload.ca … … 10 10 */ 11 11 12 if ( ! defined( 'ABSPATH' )) {12 if (!defined('ABSPATH')) { 13 13 exit; 14 14 } 15 15 16 define( 'FITCONSENT_VERSION', '1.0.2');17 define( 'FITCONSENT_PLUGIN_FILE', __FILE__);18 define( 'FITCONSENT_PLUGIN_PATH', plugin_dir_path( FITCONSENT_PLUGIN_FILE ));19 define( 'FITCONSENT_PLUGIN_URL', plugin_dir_url( FITCONSENT_PLUGIN_FILE ));16 define('FITCONSENT_VERSION', '1.0.3'); 17 define('FITCONSENT_PLUGIN_FILE', __FILE__); 18 define('FITCONSENT_PLUGIN_PATH', plugin_dir_path(FITCONSENT_PLUGIN_FILE)); 19 define('FITCONSENT_PLUGIN_URL', plugin_dir_url(FITCONSENT_PLUGIN_FILE)); 20 20 21 21 /** 22 22 * Load the admin settings page. 23 23 */ 24 if ( is_admin()) {24 if (is_admin()) { 25 25 require_once FITCONSENT_PLUGIN_PATH . 'includes/admin-settings.php'; 26 26 } 27 27 28 28 /** 29 * Add the default consent state with the developer ID. 30 * This runs before other scripts to ensure proper consent defaults. 31 */ 32 function fitconsent_add_consent_default_script() 33 { 34 ?> 35 <script> 36 window.dataLayer = window.dataLayer || []; 37 function gtag() { dataLayer.push(arguments); } 38 gtag('consent', 'default', { 39 'ad_storage': 'denied', 40 'ad_user_data': 'denied', 41 'ad_personalization': 'denied', 42 'analytics_storage': 'denied', 43 'developer_id.dYTJjND': true // Google CMP Partner ID 44 }); 45 </script> 46 <?php 47 } 48 add_action('wp_head', 'fitconsent_add_consent_default_script', 1); 49 50 /** 29 51 * Enqueue the FitConsent banner and integration scripts on the frontend. 30 52 */ 31 function fitconsent_enqueue_scripts() { 32 $options = get_option( 'fitconsent_settings', [] ); 33 $website_id = isset( $options['website_id'] ) ? trim( $options['website_id'] ) : ''; 53 function fitconsent_enqueue_scripts() 54 { 55 $options = get_option('fitconsent_settings', []); 56 $website_id = isset($options['website_id']) ? trim($options['website_id']) : ''; 34 57 35 if ( empty( $website_id )) {58 if (empty($website_id)) { 36 59 return; 37 60 } … … 40 63 wp_enqueue_script( 41 64 'fitconsent-banner', 42 esc_url( "https://app.fitconsent.com/api/banner?websiteId={$website_id}"),65 esc_url("https://app.fitconsent.com/api/banner?websiteId={$website_id}"), 43 66 [], 44 67 FITCONSENT_VERSION, … … 50 73 'fitconsent-integration', 51 74 FITCONSENT_PLUGIN_URL . 'js/integration.js', 52 [ 'wp-consent-api'],75 ['wp-consent-api'], 53 76 FITCONSENT_VERSION, 54 77 true 55 78 ); 56 79 } 57 add_action( 'wp_enqueue_scripts', 'fitconsent_enqueue_scripts');80 add_action('wp_enqueue_scripts', 'fitconsent_enqueue_scripts'); 58 81 59 82 /** 60 83 * Add a Settings link on the plugins page. 61 84 */ 62 function fitconsent_add_settings_link( $links ) { 63 $settings_link = '<a href="options-general.php?page=fitconsent">' . esc_html__( 'Settings', 'fitconsent-cmp' ) . '</a>'; 64 array_unshift( $links, $settings_link ); 85 function fitconsent_add_settings_link($links) 86 { 87 $settings_link = '<a href="options-general.php?page=fitconsent">' . esc_html__('Settings', 'fitconsent-cmp') . '</a>'; 88 array_unshift($links, $settings_link); 65 89 return $links; 66 90 } 67 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'fitconsent_add_settings_link');91 add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'fitconsent_add_settings_link'); 68 92 69 93 /** 70 94 * Declare compliance with the WP Consent API. 71 95 */ 72 $fitconsent_plugin_basename = plugin_basename( __FILE__);73 add_filter( "wp_consent_api_registered_{$fitconsent_plugin_basename}", '__return_true');96 $fitconsent_plugin_basename = plugin_basename(__FILE__); 97 add_filter("wp_consent_api_registered_{$fitconsent_plugin_basename}", '__return_true'); 74 98 75 99 /** 76 100 * Optionally register cookies for transparency (GDPR info) 77 101 */ 78 function fitconsent_register_cookies() { 79 if ( function_exists( 'wp_add_cookie_info' ) ) { 102 function fitconsent_register_cookies() 103 { 104 if (function_exists('wp_add_cookie_info')) { 80 105 wp_add_cookie_info( 81 106 'fitconsent_choices', 82 107 'FitConsent Banner', 83 108 'necessary', 84 __( 'Stores user consent preferences.', 'fitconsent-cmp'),85 __( '1 year', 'fitconsent-cmp')109 __('Stores user consent preferences.', 'fitconsent-cmp'), 110 __('1 year', 'fitconsent-cmp') 86 111 ); 87 112 } 88 113 } 89 add_action( 'plugins_loaded', 'fitconsent_register_cookies');114 add_action('plugins_loaded', 'fitconsent_register_cookies'); -
fitconsent-cmp/trunk/readme.txt
r3410990 r3421335 4 4 Requires at least: 5.8 5 5 Tested up to: 6.9 6 Stable tag: 1.0. 26 Stable tag: 1.0.3 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset
for help on using the changeset viewer.