added additional plugins

This commit is contained in:
Rodolfo Martinez 2025-12-12 19:05:48 -05:00
parent c85895d306
commit 00e60ec1b7
132 changed files with 27514 additions and 0 deletions

View file

@ -0,0 +1,75 @@
/* Maple GDPR Cookies - Admin Styles */
.mgc-admin-wrap {
max-width: 1200px;
margin: 20px 0;
}
.mgc-panel {
background: #fff;
border: 1px solid #ccd0d4;
box-shadow: 0 1px 1px rgba(0,0,0,.04);
margin-bottom: 20px;
}
.mgc-panel-header {
background: #f6f7f7;
border-bottom: 1px solid #ccd0d4;
padding: 15px 20px;
}
.mgc-panel-header h3 {
margin: 0;
font-size: 16px;
font-weight: 600;
}
.mgc-panel-body {
padding: 20px;
}
.mgc-form-row {
margin-bottom: 20px;
}
.mgc-form-row label {
display: block;
margin-bottom: 8px;
font-weight: 600;
}
.mgc-form-row input[type="text"],
.mgc-form-row input[type="url"],
.mgc-form-row input[type="number"],
.mgc-form-row textarea,
.mgc-form-row select {
width: 100%;
max-width: 600px;
}
.mgc-form-row input[type="text"]#mgc_custom_button_color,
.mgc-form-row input[type="text"]#mgc_custom_button_hover_color {
max-width: 200px;
font-family: monospace;
font-size: 14px;
}
.mgc-form-row .description {
margin-top: 5px;
font-style: italic;
color: #666;
}
.mgc-form-row textarea {
min-height: 100px;
}
.mgc-preview {
border: 1px solid #ddd;
padding: 20px;
background: #f9f9f9;
margin-top: 20px;
}
.mgc-save-button {
margin-top: 20px;
}

View file

@ -0,0 +1,12 @@
<?php
/**
* Silence is golden.
*
* Prevent direct access to this file.
*
* @package WordPress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

View file

@ -0,0 +1,12 @@
<?php
/**
* Silence is golden.
*
* Prevent direct access to this file.
*
* @package WordPress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

View file

@ -0,0 +1,120 @@
/* Maple GDPR Cookies - Admin JavaScript */
(function ($) {
"use strict";
$(document).ready(function () {
// Initialize color picker
if ($.fn.wpColorPicker) {
$(".mgc-color-picker").wpColorPicker();
}
// Custom color input preview
function updateColorPreview(input) {
var color = $(input).val();
var hexPattern = /^#[0-9A-F]{6}$/i;
if (hexPattern.test(color)) {
$(input).css({
"border-left": "5px solid " + color,
"border-color": color,
});
} else {
$(input).css({
"border-left": "",
"border-color": "",
});
}
}
// Add event listeners for custom color inputs
$("#mgc_custom_button_color, #mgc_custom_button_hover_color").on(
"input change",
function () {
updateColorPreview(this);
},
);
// Initialize preview on page load
$("#mgc_custom_button_color, #mgc_custom_button_hover_color").each(
function () {
updateColorPreview(this);
},
);
// Preview functionality
$("#mgc-preview-button").on("click", function (e) {
e.preventDefault();
// Trigger preview update
updatePreview();
});
function updatePreview() {
// Simple preview update logic
console.log("Preview updated");
}
// Handle preference display type radio buttons
var $preferenceRadios = $('input[name="mgc_preference_display_type"]');
var $gdprWarning = $("#mgc-gdpr-warning");
// Function to toggle GDPR warning visibility
function toggleGdprWarning() {
var selectedType = $(
'input[name="mgc_preference_display_type"]:checked',
).val();
if (selectedType === "neither") {
// Create warning if it doesn't exist
if ($gdprWarning.length === 0) {
var warningHtml =
'<div id="mgc-gdpr-warning" style="background: #fff3cd; padding: 12px; border-left: 4px solid #ffc107; margin-top: 10px; margin-bottom: 15px;">' +
'<strong style="color: #856404;">⚠️ GDPR Compliance Reminder:</strong>' +
'<p style="margin: 5px 0; color: #856404;">To remain GDPR compliant, you must add this shortcode to your footer or make it easily accessible on all pages:</p>' +
'<code style="background: #fff; padding: 6px 10px; border-radius: 3px; display: inline-block; font-size: 14px; border: 1px solid #ffc107;">[mgc_cookie_preferences]</code>' +
'<p style="margin: 10px 0 0 0; font-size: 12px; color: #856404;">GDPR requires users to have easy access to withdraw their consent at any time.</p>' +
"</div>";
$(warningHtml).insertAfter($preferenceRadios.last().parent());
$gdprWarning = $("#mgc-gdpr-warning");
}
$gdprWarning.slideDown(200);
} else {
if ($gdprWarning.length > 0) {
$gdprWarning.slideUp(200);
}
}
}
// Initialize warning on page load
toggleGdprWarning();
// Handle radio button changes
$preferenceRadios.on("change", function () {
toggleGdprWarning();
});
// Form validation
$("form").on("submit", function (e) {
// Validate hex colors
var customColor = $("#mgc_custom_button_color").val();
var customHoverColor = $("#mgc_custom_button_hover_color").val();
var hexPattern = /^#[0-9A-F]{6}$/i;
if (customColor && !hexPattern.test(customColor)) {
alert("Custom Button Color must be a valid hex color (e.g., #3498db)");
$("#mgc_custom_button_color").focus();
return false;
}
if (customHoverColor && !hexPattern.test(customHoverColor)) {
alert(
"Custom Button Hover Color must be a valid hex color (e.g., #2980b9)",
);
$("#mgc_custom_button_hover_color").focus();
return false;
}
return true;
});
});
})(jQuery);

View file

@ -0,0 +1,12 @@
<?php
/**
* Silence is golden.
*
* Prevent direct access to this file.
*
* @package WordPress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

View file

@ -0,0 +1,12 @@
<?php
/**
* Silence is golden.
*
* Prevent direct access to this file.
*
* @package WordPress
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}

View file

@ -0,0 +1,106 @@
<?php
/**
* Consent Logs View
*/
if (!defined('ABSPATH')) {
exit;
}
global $wpdb;
$table_name = $wpdb->prefix . 'mgc_consent_logs';
// Get logs with pagination
$per_page = 50;
$page = isset($_GET['paged']) ? absint($_GET['paged']) : 1;
$offset = ($page - 1) * $per_page;
$logs = $wpdb->get_results(
$wpdb->prepare(
"SELECT * FROM $table_name ORDER BY consent_date DESC LIMIT %d OFFSET %d",
$per_page,
$offset
)
);
$total_logs = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
$total_pages = ceil($total_logs / $per_page);
?>
<div class="wrap mgc-admin-wrap">
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
<div class="mgc-panel">
<div class="mgc-panel-header">
<h3><?php _e('Consent Logs', 'maple-gdpr-cookies'); ?></h3>
</div>
<div class="mgc-panel-body">
<p><?php printf(__('Total logs: %d', 'maple-gdpr-cookies'), $total_logs); ?></p>
<?php if (!empty($logs)) : ?>
<table class="wp-list-table widefat fixed striped">
<thead>
<tr>
<th><?php _e('Date', 'maple-gdpr-cookies'); ?></th>
<th><?php _e('User', 'maple-gdpr-cookies'); ?></th>
<th><?php _e('IP Address', 'maple-gdpr-cookies'); ?></th>
<th><?php _e('Consent Type', 'maple-gdpr-cookies'); ?></th>
<th><?php _e('Categories', 'maple-gdpr-cookies'); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($logs as $log) : ?>
<tr>
<td><?php echo esc_html($log->consent_date); ?></td>
<td>
<?php
if ($log->user_id) {
$user = get_userdata($log->user_id);
echo $user ? esc_html($user->display_name) : __('Unknown', 'maple-gdpr-cookies');
} else {
echo __('Guest', 'maple-gdpr-cookies');
}
?>
</td>
<td><?php echo esc_html($log->ip_address); ?></td>
<td>
<span class="mgc-consent-<?php echo esc_attr($log->consent_type); ?>">
<?php echo esc_html(ucfirst($log->consent_type)); ?>
</span>
</td>
<td>
<?php
$categories = json_decode($log->categories, true);
if (!empty($categories) && is_array($categories)) {
echo esc_html(implode(', ', $categories));
} else {
echo __('N/A', 'maple-gdpr-cookies');
}
?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($total_pages > 1) : ?>
<div class="tablenav">
<div class="tablenav-pages">
<?php
echo paginate_links(array(
'base' => add_query_arg('paged', '%#%'),
'format' => '',
'prev_text' => __('&laquo;'),
'next_text' => __('&raquo;'),
'total' => $total_pages,
'current' => $page
));
?>
</div>
</div>
<?php endif; ?>
<?php else : ?>
<p><?php _e('No consent logs found.', 'maple-gdpr-cookies'); ?></p>
<?php endif; ?>
</div>
</div>
</div>

View file

@ -0,0 +1,172 @@
<?php
/**
* Admin Settings View
*/
if (!defined('ABSPATH')) {
exit;
}
?>
<div class="wrap mgc-admin-wrap">
<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
<?php settings_errors('mgc_messages'); ?>
<form method="post" action="">
<?php wp_nonce_field('mgc_settings_nonce'); ?>
<!-- General Settings Panel -->
<div class="mgc-panel">
<div class="mgc-panel-header">
<h3><?php _e('General Settings', 'maple-gdpr-cookies'); ?></h3>
</div>
<div class="mgc-panel-body">
<div class="mgc-form-row">
<label>
<input type="checkbox" name="mgc_enabled" value="1" <?php checked(get_option('mgc_enabled', true), true); ?>>
<?php _e('Enable Cookie Notice', 'maple-gdpr-cookies'); ?>
</label>
</div>
<div class="mgc-form-row">
<label for="mgc_notice_text"><?php _e('Notice Text', 'maple-gdpr-cookies'); ?></label>
<textarea id="mgc_notice_text" name="mgc_notice_text" rows="4"><?php echo esc_textarea(get_option('mgc_notice_text')); ?></textarea>
</div>
<div class="mgc-form-row">
<label for="mgc_accept_button_text"><?php _e('Accept Button Text', 'maple-gdpr-cookies'); ?></label>
<input type="text" id="mgc_accept_button_text" name="mgc_accept_button_text" value="<?php echo esc_attr(get_option('mgc_accept_button_text')); ?>">
</div>
<div class="mgc-form-row">
<label for="mgc_reject_button_text"><?php _e('Reject Button Text', 'maple-gdpr-cookies'); ?></label>
<input type="text" id="mgc_reject_button_text" name="mgc_reject_button_text" value="<?php echo esc_attr(get_option('mgc_reject_button_text')); ?>">
</div>
<div class="mgc-form-row">
<label for="mgc_privacy_policy_url"><?php _e('Privacy Policy URL', 'maple-gdpr-cookies'); ?></label>
<input type="url" id="mgc_privacy_policy_url" name="mgc_privacy_policy_url" value="<?php echo esc_url(get_option('mgc_privacy_policy_url')); ?>">
</div>
<div class="mgc-form-row">
<label for="mgc_cookie_expiry"><?php _e('Cookie Expiry (days)', 'maple-gdpr-cookies'); ?></label>
<input type="number" id="mgc_cookie_expiry" name="mgc_cookie_expiry" value="<?php echo esc_attr(get_option('mgc_cookie_expiry', 365)); ?>" min="1" max="365">
</div>
</div>
</div>
<!-- Appearance Panel -->
<div class="mgc-panel">
<div class="mgc-panel-header">
<h3><?php _e('Appearance', 'maple-gdpr-cookies'); ?></h3>
</div>
<div class="mgc-panel-body">
<div class="mgc-form-row">
<label for="mgc_position"><?php _e('Position', 'maple-gdpr-cookies'); ?></label>
<select id="mgc_position" name="mgc_position">
<option value="bottom" <?php selected(get_option('mgc_position', 'bottom'), 'bottom'); ?>><?php _e('Bottom', 'maple-gdpr-cookies'); ?></option>
<option value="top" <?php selected(get_option('mgc_position'), 'top'); ?>><?php _e('Top', 'maple-gdpr-cookies'); ?></option>
<option value="center" <?php selected(get_option('mgc_position'), 'center'); ?>><?php _e('Center Modal', 'maple-gdpr-cookies'); ?></option>
</select>
</div>
<div class="mgc-form-row">
<label for="mgc_theme"><?php _e('Theme', 'maple-gdpr-cookies'); ?></label>
<select id="mgc_theme" name="mgc_theme">
<option value="light" <?php selected(get_option('mgc_theme', 'light'), 'light'); ?>><?php _e('Light', 'maple-gdpr-cookies'); ?></option>
<option value="dark" <?php selected(get_option('mgc_theme'), 'dark'); ?>><?php _e('Dark', 'maple-gdpr-cookies'); ?></option>
</select>
</div>
<div class="mgc-form-row">
<label for="mgc_button_color"><?php _e('Button Color', 'maple-gdpr-cookies'); ?></label>
<select id="mgc_button_color" name="mgc_button_color">
<option value="black" <?php selected(get_option('mgc_button_color', 'blue'), 'black'); ?>><?php _e('Black', 'maple-gdpr-cookies'); ?></option>
<option value="dark-grey" <?php selected(get_option('mgc_button_color', 'blue'), 'dark-grey'); ?>><?php _e('Dark Grey', 'maple-gdpr-cookies'); ?></option>
<option value="blue" <?php selected(get_option('mgc_button_color', 'blue'), 'blue'); ?>><?php _e('Blue', 'maple-gdpr-cookies'); ?></option>
<option value="red" <?php selected(get_option('mgc_button_color', 'blue'), 'red'); ?>><?php _e('Red', 'maple-gdpr-cookies'); ?></option>
<option value="green" <?php selected(get_option('mgc_button_color', 'blue'), 'green'); ?>><?php _e('Green', 'maple-gdpr-cookies'); ?></option>
</select>
<p class="description"><?php _e('Select the color for all cookie notice buttons.', 'maple-gdpr-cookies'); ?></p>
</div>
<div class="mgc-form-row">
<label for="mgc_custom_button_color"><?php _e('Custom Button Color', 'maple-gdpr-cookies'); ?></label>
<input type="text" id="mgc_custom_button_color" name="mgc_custom_button_color" value="<?php echo esc_attr(get_option('mgc_custom_button_color', '')); ?>" placeholder="#3498db" pattern="^#[a-fA-F0-9]{6}$" maxlength="7">
<p class="description"><?php _e('Enter a hex color code (e.g., #3498db). If set, this overrides the dropdown selection above.', 'maple-gdpr-cookies'); ?></p>
</div>
<div class="mgc-form-row">
<label for="mgc_custom_button_hover_color"><?php _e('Custom Button Hover Color', 'maple-gdpr-cookies'); ?></label>
<input type="text" id="mgc_custom_button_hover_color" name="mgc_custom_button_hover_color" value="<?php echo esc_attr(get_option('mgc_custom_button_hover_color', '')); ?>" placeholder="#2980b9" pattern="^#[a-fA-F0-9]{6}$" maxlength="7">
<p class="description"><?php _e('Enter a hex color code for button hover state (e.g., #2980b9). If set, this overrides the default hover color.', 'maple-gdpr-cookies'); ?></p>
</div>
<div class="mgc-form-row">
<label for="mgc_custom_css"><?php _e('Custom CSS', 'maple-gdpr-cookies'); ?></label>
<textarea id="mgc_custom_css" name="mgc_custom_css" rows="10" placeholder=".mgc-notice { /* your styles */ }"><?php echo esc_textarea(get_option('mgc_custom_css')); ?></textarea>
</div>
<div class="mgc-form-row">
<label><?php _e('Preference Display Type', 'maple-gdpr-cookies'); ?></label>
<p class="description" style="margin-bottom: 10px;"><?php _e('Choose how users can access cookie preferences after giving consent (GDPR requirement for easy withdrawal).', 'maple-gdpr-cookies'); ?></p>
<label style="display: block; margin-bottom: 8px;">
<input type="radio" name="mgc_preference_display_type" value="icon" <?php checked(get_option('mgc_preference_display_type', 'icon'), 'icon'); ?>>
<?php _e('Floating Cookie Icon - A circular button with cookie icon in the bottom-left corner', 'maple-gdpr-cookies'); ?>
</label>
<label style="display: block; margin-bottom: 8px;">
<input type="radio" name="mgc_preference_display_type" value="footer" <?php checked(get_option('mgc_preference_display_type', 'icon'), 'footer'); ?>>
<?php _e('Footer Text Link - A small "Cookie Preferences" link in the bottom-left corner', 'maple-gdpr-cookies'); ?>
</label>
<label style="display: block; margin-bottom: 10px;">
<input type="radio" name="mgc_preference_display_type" value="neither" <?php checked(get_option('mgc_preference_display_type', 'icon'), 'neither'); ?>>
<?php _e('Neither - I will use the shortcode instead', 'maple-gdpr-cookies'); ?>
</label>
<div style="background: #f0f0f1; padding: 12px; border-left: 4px solid #2271b1; margin-top: 15px;">
<strong><?php _e('Shortcode Option:', 'maple-gdpr-cookies'); ?></strong>
<p style="margin: 5px 0;"><?php _e('You can also place a cookie preferences link anywhere using the shortcode:', 'maple-gdpr-cookies'); ?></p>
<code style="background: #fff; padding: 4px 8px; border-radius: 3px; display: inline-block; font-size: 13px;">[mgc_cookie_preferences]</code>
<p style="margin: 10px 0 5px 0; font-size: 13px;"><?php _e('Customize the text:', 'maple-gdpr-cookies'); ?></p>
<code style="background: #fff; padding: 4px 8px; border-radius: 3px; display: inline-block; font-size: 13px;">[mgc_cookie_preferences text="Manage Cookies"]</code>
<p style="margin: 10px 0 0 0; font-size: 12px; color: #666;"><?php _e('Perfect for adding to your footer widget, pages, or posts.', 'maple-gdpr-cookies'); ?></p>
</div>
</div>
</div>
</div>
<!-- Advanced Settings Panel -->
<div class="mgc-panel">
<div class="mgc-panel-header">
<h3><?php _e('Advanced Settings', 'maple-gdpr-cookies'); ?></h3>
</div>
<div class="mgc-panel-body">
<div class="mgc-form-row">
<label>
<input type="checkbox" name="mgc_enable_logging" value="1" <?php checked(get_option('mgc_enable_logging', true), true); ?>>
<?php _e('Enable Consent Logging', 'maple-gdpr-cookies'); ?>
</label>
<p class="description"><?php _e('Log all consent decisions for GDPR compliance.', 'maple-gdpr-cookies'); ?></p>
</div>
<div class="mgc-form-row">
<label>
<input type="checkbox" name="mgc_show_reject_button" value="1" <?php checked(get_option('mgc_show_reject_button', true), true); ?>>
<?php _e('Show Reject Button', 'maple-gdpr-cookies'); ?>
</label>
</div>
<div class="mgc-form-row">
<label>
<input type="checkbox" name="mgc_show_settings_button" value="1" <?php checked(get_option('mgc_show_settings_button', true), true); ?>>
<?php _e('Show Settings Button', 'maple-gdpr-cookies'); ?>
</label>
</div>
</div>
</div>
<div class="mgc-save-button">
<?php submit_button(__('Save Settings', 'maple-gdpr-cookies'), 'primary', 'mgc_save_settings'); ?>
</div>
</form>
</div>