Plugin Directory

Changeset 3304864


Ignore:
Timestamp:
06/02/2025 11:05:49 AM (10 months ago)
Author:
aaextention
Message:

Update to AA Block Country Plugin

Location:
aa-block-country
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • aa-block-country/tags/1.0.1/aablockcountry.php

    r3304395 r3304864  
    11<?php
    2 /**
    3  * Plugin Name: AA Block Country
    4  * Plugin URI: https://wordpress.org/plugins/aa-block-country/
    5  * Description: Blocks visitors from selected countries using IP geolocation. GDPR-compliant with consent banner.
    6  * Version: 1.0.1
    7  * Author: Syed Ashik Mahmud
    8  * Author URI: https://aaextensions.com
    9  * License: GPL2
    10  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    11  * Text Domain: aa-block-country
    12  * Domain Path: /languages
    13  */
     2/*
     3Plugin Name: AA Block Country
     4Plugin URI: https://wordpress.org/plugins/aa-block-country/
     5Description: Blocks visitors from selected countries using IP geolocation. GDPR-compliant with consent banner.
     6Version: 1.0.1
     7Author: Syed Ashik Mahmud
     8Author URI: https://aaextensions.com
     9License: GPL2
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
     11Text Domain: aa-block-country
     12Domain Path: /languages
     13*/
    1414
    15 if (!defined('ABSPATH')) exit; // Exit if accessed directly
     15if (!defined('ABSPATH')) exit;
    1616
    17 // ===== Helper: Get visitor IP =====
     17// Load plugin textdomain
     18function aa_block_load_textdomain() {
     19    load_plugin_textdomain('aa-block-country', false, dirname(plugin_basename(__FILE__)) . '/languages');
     20}
     21add_action('plugins_loaded', 'aa_block_load_textdomain');
     22
     23// Get user IP
    1824function aa_block_get_user_ip() {
    1925    $client  = $_SERVER['HTTP_CLIENT_IP'] ?? '';
     
    2632}
    2733
    28 // ===== Helper: Get geolocation with transient caching =====
     34// Get user country code with caching
    2935function aa_block_get_user_country_code($ip) {
    3036    $transient_key = 'aa_geo_' . md5($ip);
     
    3844    $body = wp_remote_retrieve_body($response);
    3945    $data = json_decode($body);
    40    
     46
    4147    if (!empty($data->countryCode)) {
    4248        set_transient($transient_key, $data->countryCode, HOUR_IN_SECONDS * 24);
     
    4652}
    4753
    48 // ===== Main: Block user if needed =====
     54// Block user based on country
    4955function aa_block_country_check() {
    5056    if (is_admin()) return;
     
    5460
    5561    if ($require_consent && !isset($_COOKIE['aa_geo_consent'])) {
    56         return; // Skip blocking until consent given
     62        return;
    5763    }
    5864
     
    6167
    6268    $blocked_countries = array_map('trim', explode(',', get_option('aa_block_countries', '')));
    63     $blocked_message = get_option('aa_block_message', 'Access denied for your region.');
     69    $blocked_message = get_option('aa_block_message', __('Access denied for your region.', 'aa-block-country'));
    6470
    6571    if (in_array(strtoupper($user_country), $blocked_countries)) {
     
    6975add_action('init', 'aa_block_country_check');
    7076
    71 // ===== Admin: Register settings =====
     77// Register settings
    7278function aa_block_register_settings() {
    7379    register_setting('aa_block_settings_group', 'aa_block_countries', ['type' => 'string', 'sanitize_callback' => 'sanitize_text_field']);
     
    7783add_action('admin_init', 'aa_block_register_settings');
    7884
    79 // ===== Admin: Menu page =====
     85// Add admin menu
    8086function aa_block_admin_menu() {
    81     add_menu_page('Block Country Settings', 'Block Country', 'manage_options', 'aa-block-country', 'aa_block_settings_page', 'dashicons-shield-alt');
     87    add_menu_page(__('Block Country Settings', 'aa-block-country'), __('Block Country', 'aa-block-country'), 'manage_options', 'aa-block-country', 'aa_block_settings_page', 'dashicons-shield-alt');
    8288}
    8389add_action('admin_menu', 'aa_block_admin_menu');
    8490
    85 // ===== Admin: Settings page UI =====
     91// Admin settings page UI
    8692function aa_block_settings_page() {
    8793    ?>
    8894    <div class="wrap">
    89         <h1>Block Country Settings</h1>
     95        <h1><?php _e('Block Country Settings', 'aa-block-country'); ?></h1>
    9096        <form method="post" action="options.php">
    9197            <?php
     
    95101            <table class="form-table">
    96102                <tr>
    97                     <th scope="row">Blocked Country Codes</th>
     103                    <th scope="row"><?php _e('Blocked Country Codes', 'aa-block-country'); ?></th>
    98104                    <td>
    99105                        <input type="text" name="aa_block_countries" value="<?php echo esc_attr(get_option('aa_block_countries')); ?>" size="50" />
    100                         <p class="description">Comma-separated (e.g. <code>US, IN, CN</code>)</p>
     106                        <p class="description"><?php _e('Comma-separated (e.g. US, IN, CN)', 'aa-block-country'); ?></p>
    101107                    </td>
    102108                </tr>
    103109                <tr>
    104                     <th scope="row">Custom Blocked Message</th>
     110                    <th scope="row"><?php _e('Custom Blocked Message', 'aa-block-country'); ?></th>
    105111                    <td>
    106112                        <input type="text" name="aa_block_message" value="<?php echo esc_attr(get_option('aa_block_message')); ?>" size="70" />
     
    108114                </tr>
    109115                <tr>
    110                     <th scope="row">Require GDPR Consent</th>
     116                    <th scope="row"><?php _e('Require GDPR Consent', 'aa-block-country'); ?></th>
    111117                    <td>
    112118                        <input type="checkbox" name="aa_block_consent_required" value="1" <?php checked(1, get_option('aa_block_consent_required', 0)); ?> />
    113                         <label>Only block visitors after consent is given</label>
     119                        <label><?php _e('Only block visitors after consent is given', 'aa-block-country'); ?></label>
    114120                    </td>
    115121                </tr>
     
    121127}
    122128
    123 // ===== Frontend: GDPR consent banner =====
     129// GDPR Consent banner
    124130function aa_block_consent_banner() {
    125131    if (!is_admin() && get_option('aa_block_consent_required', false) && !isset($_COOKIE['aa_geo_consent'])) {
     
    149155        </style>
    150156        <div id="aa-gdpr-consent">
    151             This site uses geolocation to manage access. By continuing, you agree to our use of location data.
    152             <button onclick="aaConsentAccept()">I Agree</button>
     157            <?php _e('This site uses geolocation to manage access. By continuing, you agree to our use of location data.', 'aa-block-country'); ?>
     158            <button onclick="aaConsentAccept()"><?php _e('I Agree', 'aa-block-country'); ?></button>
    153159        </div>
    154160        <script>
  • aa-block-country/tags/1.0.1/readme.txt

    r3304397 r3304864  
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 It's unique plugin from AA Production House and it is created to block visitors from any country :)
     11It's unique plugin from AA Production House and it is created to block visitors from any country
    1212
    13 ==Description==
    14 It's unique plugin from AA Production House and it is created to block visitors from any country :) You can easily do that from settings option.
     13== Description ==
     14
     15It's unique plugin from AA Production House and it is created to block visitors from any country :) You can easily do that from settings option
    1516
    1617= Features =
    1718
    18 * Use settings options
     19<ol>
     20    <li>Blocks visitors based on their country using IP detection.</li>
     21    <li>Uses <code>ip-api.com</code> for geolocation with transient caching.</li>
     22    <li>Custom block message support via admin settings.</li>
     23    <li>Option to require GDPR consent before blocking.</li>
     24    <li>Displays a GDPR consent banner on the frontend (mobile-friendly).</li>
     25    <li>Admin panel with easy country code input and message editor.</li>
     26    <li>Modern, clean, responsive admin UI.</li>
     27    <li>Multilingual ready with <code>.pot</code> file support (text domain: <code>aa-block-country</code>).</li>
     28    <li>Secure coding practices and follows latest WordPress standards.</li>
     29    <li>Lightweight and optimized for performance.</li>
     30</ol>
    1931
    2032= How to use it =
    2133
    22 It is very easy to use.
     34<ol>
     35    <li>Install and activate the <strong>AA Block Country</strong> plugin in your WordPress admin.</li>
     36    <li>Go to <strong>Admin → Block Country</strong> from the dashboard menu.</li>
     37    <li>Enter the country codes you want to block (e.g., <code>US, IN, CN</code>).</li>
     38    <li>Customize the block message shown to restricted visitors.</li>
     39    <li>(Optional) Enable the GDPR consent toggle if required by law.</li>
     40    <li>Click <strong>Save</strong> to apply your settings.</li>
     41    <li>Visitors from blocked countries will now be denied access with your custom message.</li>
     42</ol>
    2343
    24 == Installation ==
    2544
    26 1. Install as regular WordPress plugin.<br />
    27 2. Go your plugin setting via WordPress Dashboard and find "<strong>AA Block country</strong>" activate it.<br />
     45= Installation =
     46
     47<ol>
     48    <li>Download the <strong>AA Block Country</strong> plugin ZIP file.</li>
     49    <li>Go to your WordPress dashboard → <strong>Plugins → Add New</strong>.</li>
     50    <li>Click <strong>Upload Plugin</strong> and choose the ZIP file.</li>
     51    <li>Click <strong>Install Now</strong>, then <strong>Activate</strong> the plugin.</li>
     52    <li>The settings panel will appear under <strong>Block Country</strong> in the admin menu.</li>
     53</ol>
     54
     55
     56= Screenshots =
     57
     58
     59= Changelog =
     60
     61<ol>
     62    <li><strong>Version 1.0.1</strong> (2025-06-02)
     63        <ol type="a">
     64            <li>Added multilingual support with text domain <code>aa-block-country</code>.</li>
     65            <li>Improved admin settings UI with better mobile responsiveness.</li>
     66            <li>Enhanced GDPR consent banner styling and accessibility.</li>
     67            <li>Sanitized and validated all user inputs for better security.</li>
     68            <li>Refactored code for compliance with latest WordPress coding standards.</li>
     69            <li>Optimized transient caching for IP-based geolocation.</li>
     70        </ol>
     71    </li>
     72</ol>
  • aa-block-country/trunk/aablockcountry.php

    r3304395 r3304864  
    11<?php
    2 /**
    3  * Plugin Name: AA Block Country
    4  * Plugin URI: https://wordpress.org/plugins/aa-block-country/
    5  * Description: Blocks visitors from selected countries using IP geolocation. GDPR-compliant with consent banner.
    6  * Version: 1.0.1
    7  * Author: Syed Ashik Mahmud
    8  * Author URI: https://aaextensions.com
    9  * License: GPL2
    10  * License URI: https://www.gnu.org/licenses/gpl-2.0.html
    11  * Text Domain: aa-block-country
    12  * Domain Path: /languages
    13  */
     2/*
     3Plugin Name: AA Block Country
     4Plugin URI: https://wordpress.org/plugins/aa-block-country/
     5Description: Blocks visitors from selected countries using IP geolocation. GDPR-compliant with consent banner.
     6Version: 1.0.1
     7Author: Syed Ashik Mahmud
     8Author URI: https://aaextensions.com
     9License: GPL2
     10License URI: https://www.gnu.org/licenses/gpl-2.0.html
     11Text Domain: aa-block-country
     12Domain Path: /languages
     13*/
    1414
    15 if (!defined('ABSPATH')) exit; // Exit if accessed directly
     15if (!defined('ABSPATH')) exit;
    1616
    17 // ===== Helper: Get visitor IP =====
     17// Load plugin textdomain
     18function aa_block_load_textdomain() {
     19    load_plugin_textdomain('aa-block-country', false, dirname(plugin_basename(__FILE__)) . '/languages');
     20}
     21add_action('plugins_loaded', 'aa_block_load_textdomain');
     22
     23// Get user IP
    1824function aa_block_get_user_ip() {
    1925    $client  = $_SERVER['HTTP_CLIENT_IP'] ?? '';
     
    2632}
    2733
    28 // ===== Helper: Get geolocation with transient caching =====
     34// Get user country code with caching
    2935function aa_block_get_user_country_code($ip) {
    3036    $transient_key = 'aa_geo_' . md5($ip);
     
    3844    $body = wp_remote_retrieve_body($response);
    3945    $data = json_decode($body);
    40    
     46
    4147    if (!empty($data->countryCode)) {
    4248        set_transient($transient_key, $data->countryCode, HOUR_IN_SECONDS * 24);
     
    4652}
    4753
    48 // ===== Main: Block user if needed =====
     54// Block user based on country
    4955function aa_block_country_check() {
    5056    if (is_admin()) return;
     
    5460
    5561    if ($require_consent && !isset($_COOKIE['aa_geo_consent'])) {
    56         return; // Skip blocking until consent given
     62        return;
    5763    }
    5864
     
    6167
    6268    $blocked_countries = array_map('trim', explode(',', get_option('aa_block_countries', '')));
    63     $blocked_message = get_option('aa_block_message', 'Access denied for your region.');
     69    $blocked_message = get_option('aa_block_message', __('Access denied for your region.', 'aa-block-country'));
    6470
    6571    if (in_array(strtoupper($user_country), $blocked_countries)) {
     
    6975add_action('init', 'aa_block_country_check');
    7076
    71 // ===== Admin: Register settings =====
     77// Register settings
    7278function aa_block_register_settings() {
    7379    register_setting('aa_block_settings_group', 'aa_block_countries', ['type' => 'string', 'sanitize_callback' => 'sanitize_text_field']);
     
    7783add_action('admin_init', 'aa_block_register_settings');
    7884
    79 // ===== Admin: Menu page =====
     85// Add admin menu
    8086function aa_block_admin_menu() {
    81     add_menu_page('Block Country Settings', 'Block Country', 'manage_options', 'aa-block-country', 'aa_block_settings_page', 'dashicons-shield-alt');
     87    add_menu_page(__('Block Country Settings', 'aa-block-country'), __('Block Country', 'aa-block-country'), 'manage_options', 'aa-block-country', 'aa_block_settings_page', 'dashicons-shield-alt');
    8288}
    8389add_action('admin_menu', 'aa_block_admin_menu');
    8490
    85 // ===== Admin: Settings page UI =====
     91// Admin settings page UI
    8692function aa_block_settings_page() {
    8793    ?>
    8894    <div class="wrap">
    89         <h1>Block Country Settings</h1>
     95        <h1><?php _e('Block Country Settings', 'aa-block-country'); ?></h1>
    9096        <form method="post" action="options.php">
    9197            <?php
     
    95101            <table class="form-table">
    96102                <tr>
    97                     <th scope="row">Blocked Country Codes</th>
     103                    <th scope="row"><?php _e('Blocked Country Codes', 'aa-block-country'); ?></th>
    98104                    <td>
    99105                        <input type="text" name="aa_block_countries" value="<?php echo esc_attr(get_option('aa_block_countries')); ?>" size="50" />
    100                         <p class="description">Comma-separated (e.g. <code>US, IN, CN</code>)</p>
     106                        <p class="description"><?php _e('Comma-separated (e.g. US, IN, CN)', 'aa-block-country'); ?></p>
    101107                    </td>
    102108                </tr>
    103109                <tr>
    104                     <th scope="row">Custom Blocked Message</th>
     110                    <th scope="row"><?php _e('Custom Blocked Message', 'aa-block-country'); ?></th>
    105111                    <td>
    106112                        <input type="text" name="aa_block_message" value="<?php echo esc_attr(get_option('aa_block_message')); ?>" size="70" />
     
    108114                </tr>
    109115                <tr>
    110                     <th scope="row">Require GDPR Consent</th>
     116                    <th scope="row"><?php _e('Require GDPR Consent', 'aa-block-country'); ?></th>
    111117                    <td>
    112118                        <input type="checkbox" name="aa_block_consent_required" value="1" <?php checked(1, get_option('aa_block_consent_required', 0)); ?> />
    113                         <label>Only block visitors after consent is given</label>
     119                        <label><?php _e('Only block visitors after consent is given', 'aa-block-country'); ?></label>
    114120                    </td>
    115121                </tr>
     
    121127}
    122128
    123 // ===== Frontend: GDPR consent banner =====
     129// GDPR Consent banner
    124130function aa_block_consent_banner() {
    125131    if (!is_admin() && get_option('aa_block_consent_required', false) && !isset($_COOKIE['aa_geo_consent'])) {
     
    149155        </style>
    150156        <div id="aa-gdpr-consent">
    151             This site uses geolocation to manage access. By continuing, you agree to our use of location data.
    152             <button onclick="aaConsentAccept()">I Agree</button>
     157            <?php _e('This site uses geolocation to manage access. By continuing, you agree to our use of location data.', 'aa-block-country'); ?>
     158            <button onclick="aaConsentAccept()"><?php _e('I Agree', 'aa-block-country'); ?></button>
    153159        </div>
    154160        <script>
  • aa-block-country/trunk/readme.txt

    r3304397 r3304864  
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1010
    11 It's unique plugin from AA Production House and it is created to block visitors from any country :)
     11It's unique plugin from AA Production House and it is created to block visitors from any country
    1212
    13 ==Description==
    14 It's unique plugin from AA Production House and it is created to block visitors from any country :) You can easily do that from settings option.
     13== Description ==
     14
     15It's unique plugin from AA Production House and it is created to block visitors from any country :) You can easily do that from settings option
    1516
    1617= Features =
    1718
    18 * Use settings options
     19<ol>
     20    <li>Blocks visitors based on their country using IP detection.</li>
     21    <li>Uses <code>ip-api.com</code> for geolocation with transient caching.</li>
     22    <li>Custom block message support via admin settings.</li>
     23    <li>Option to require GDPR consent before blocking.</li>
     24    <li>Displays a GDPR consent banner on the frontend (mobile-friendly).</li>
     25    <li>Admin panel with easy country code input and message editor.</li>
     26    <li>Modern, clean, responsive admin UI.</li>
     27    <li>Multilingual ready with <code>.pot</code> file support (text domain: <code>aa-block-country</code>).</li>
     28    <li>Secure coding practices and follows latest WordPress standards.</li>
     29    <li>Lightweight and optimized for performance.</li>
     30</ol>
    1931
    2032= How to use it =
    2133
    22 It is very easy to use.
     34<ol>
     35    <li>Install and activate the <strong>AA Block Country</strong> plugin in your WordPress admin.</li>
     36    <li>Go to <strong>Admin → Block Country</strong> from the dashboard menu.</li>
     37    <li>Enter the country codes you want to block (e.g., <code>US, IN, CN</code>).</li>
     38    <li>Customize the block message shown to restricted visitors.</li>
     39    <li>(Optional) Enable the GDPR consent toggle if required by law.</li>
     40    <li>Click <strong>Save</strong> to apply your settings.</li>
     41    <li>Visitors from blocked countries will now be denied access with your custom message.</li>
     42</ol>
    2343
    24 == Installation ==
    2544
    26 1. Install as regular WordPress plugin.<br />
    27 2. Go your plugin setting via WordPress Dashboard and find "<strong>AA Block country</strong>" activate it.<br />
     45= Installation =
     46
     47<ol>
     48    <li>Download the <strong>AA Block Country</strong> plugin ZIP file.</li>
     49    <li>Go to your WordPress dashboard → <strong>Plugins → Add New</strong>.</li>
     50    <li>Click <strong>Upload Plugin</strong> and choose the ZIP file.</li>
     51    <li>Click <strong>Install Now</strong>, then <strong>Activate</strong> the plugin.</li>
     52    <li>The settings panel will appear under <strong>Block Country</strong> in the admin menu.</li>
     53</ol>
     54
     55
     56= Screenshots =
     57
     58
     59= Changelog =
     60
     61<ol>
     62    <li><strong>Version 1.0.1</strong> (2025-06-02)
     63        <ol type="a">
     64            <li>Added multilingual support with text domain <code>aa-block-country</code>.</li>
     65            <li>Improved admin settings UI with better mobile responsiveness.</li>
     66            <li>Enhanced GDPR consent banner styling and accessibility.</li>
     67            <li>Sanitized and validated all user inputs for better security.</li>
     68            <li>Refactored code for compliance with latest WordPress coding standards.</li>
     69            <li>Optimized transient caching for IP-based geolocation.</li>
     70        </ol>
     71    </li>
     72</ol>
Note: See TracChangeset for help on using the changeset viewer.