Plugin Directory

Changeset 3421335


Ignore:
Timestamp:
12/16/2025 06:29:19 PM (2 months ago)
Author:
digitload330
Message:

Update the default consent state with the developer ID

Location:
fitconsent-cmp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • fitconsent-cmp/trunk/fitconsent-cmp.php

    r3410990 r3421335  
    44 * Plugin URI:        https://fitconsent.com
    55 * Description:       Integrates the FitConsent Consent Management Platform with WordPress and the WP Consent API for Google Site Kit compatibility.
    6  * Version:           1.0.2
     6 * Version:           1.0.3
    77 * Author:            DIGITLOAD
    88 * Author URI:        https://digitload.ca
     
    1010 */
    1111
    12 if ( ! defined( 'ABSPATH' ) ) {
     12if (!defined('ABSPATH')) {
    1313    exit;
    1414}
    1515
    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 ) );
     16define('FITCONSENT_VERSION', '1.0.3');
     17define('FITCONSENT_PLUGIN_FILE', __FILE__);
     18define('FITCONSENT_PLUGIN_PATH', plugin_dir_path(FITCONSENT_PLUGIN_FILE));
     19define('FITCONSENT_PLUGIN_URL', plugin_dir_url(FITCONSENT_PLUGIN_FILE));
    2020
    2121/**
    2222 * Load the admin settings page.
    2323 */
    24 if ( is_admin() ) {
     24if (is_admin()) {
    2525    require_once FITCONSENT_PLUGIN_PATH . 'includes/admin-settings.php';
    2626}
    2727
    2828/**
     29 * Add the default consent state with the developer ID.
     30 * This runs before other scripts to ensure proper consent defaults.
     31 */
     32function 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}
     48add_action('wp_head', 'fitconsent_add_consent_default_script', 1);
     49
     50/**
    2951 * Enqueue the FitConsent banner and integration scripts on the frontend.
    3052 */
    31 function fitconsent_enqueue_scripts() {
    32     $options     = get_option( 'fitconsent_settings', [] );
    33     $website_id  = isset( $options['website_id'] ) ? trim( $options['website_id'] ) : '';
     53function fitconsent_enqueue_scripts()
     54{
     55    $options = get_option('fitconsent_settings', []);
     56    $website_id = isset($options['website_id']) ? trim($options['website_id']) : '';
    3457
    35     if ( empty( $website_id ) ) {
     58    if (empty($website_id)) {
    3659        return;
    3760    }
     
    4063    wp_enqueue_script(
    4164        '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}"),
    4366        [],
    4467        FITCONSENT_VERSION,
     
    5073        'fitconsent-integration',
    5174        FITCONSENT_PLUGIN_URL . 'js/integration.js',
    52         [ 'wp-consent-api' ],
     75        ['wp-consent-api'],
    5376        FITCONSENT_VERSION,
    5477        true
    5578    );
    5679}
    57 add_action( 'wp_enqueue_scripts', 'fitconsent_enqueue_scripts' );
     80add_action('wp_enqueue_scripts', 'fitconsent_enqueue_scripts');
    5881
    5982/**
    6083 * Add a Settings link on the plugins page.
    6184 */
    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 );
     85function 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);
    6589    return $links;
    6690}
    67 add_filter( 'plugin_action_links_' . plugin_basename( __FILE__ ), 'fitconsent_add_settings_link' );
     91add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'fitconsent_add_settings_link');
    6892
    6993/**
    7094 * Declare compliance with the WP Consent API.
    7195 */
    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__);
     97add_filter("wp_consent_api_registered_{$fitconsent_plugin_basename}", '__return_true');
    7498
    7599/**
    76100 * Optionally register cookies for transparency (GDPR info)
    77101 */
    78 function fitconsent_register_cookies() {
    79     if ( function_exists( 'wp_add_cookie_info' ) ) {
     102function fitconsent_register_cookies()
     103{
     104    if (function_exists('wp_add_cookie_info')) {
    80105        wp_add_cookie_info(
    81106            'fitconsent_choices',
    82107            'FitConsent Banner',
    83108            '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')
    86111        );
    87112    }
    88113}
    89 add_action( 'plugins_loaded', 'fitconsent_register_cookies' );
     114add_action('plugins_loaded', 'fitconsent_register_cookies');
  • fitconsent-cmp/trunk/readme.txt

    r3410990 r3421335  
    44Requires at least: 5.8
    55Tested up to: 6.9
    6 Stable tag: 1.0.2
     6Stable tag: 1.0.3
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.