Plugin Directory

Changeset 3420435


Ignore:
Timestamp:
12/15/2025 06:20:28 PM (5 weeks ago)
Author:
mediuminteractive
Message:

Update assets

Location:
mdi-http-referer-block
Files:
7 added
4 edited

Legend:

Unmodified
Added
Removed
  • mdi-http-referer-block/trunk/mdi-http-referer-block.php

    r3383476 r3420435  
    22
    33/**
    4  * Plugin Name:       MDI HTTP Referer Block
     4 * Plugin Name:       Smart Traffic Source Filter for WordPress
    55 * Description:       Hide elements or redirect users when arriving from configured referrer domains. Supports PHP-side and client-side checks and optional notification.
    66 * Version:           1.0
     
    1212 */
    1313
    14 if (! defined('ABSPATH')) {
     14if (!defined('ABSPATH')) {
    1515    exit;
    1616}
     
    2323{
    2424    return array(
    25         'show_notification'  => 0,
    26         'enable_js_check'    => 0,
     25        'show_notification' => 0,
     26        'enable_js_check' => 0,
    2727        'syndicated_domains' => '',
    28         'element_selector'   => '',
    29         'redirect_url'       => '',
    30         'cookie_lifetime'    => 1, // days
     28        'element_selector' => '',
     29        'redirect_url' => '',
     30        'cookie_lifetime' => 1, // days
    3131    );
    3232}
     
    9696
    9797    // Show notification — sanitize output and escape.
    98     if (! empty($options['show_notification']) && ! empty($_SERVER['HTTP_REFERER'])) {
     98    if (!empty($options['show_notification']) && !empty($_SERVER['HTTP_REFERER'])) {
    9999        $referrer = sanitize_text_field(esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER'])));
    100100
     
    113113    // If PHP-side cookie set, output immediate CSS or redirect (safe)
    114114    if (isset($_COOKIE['mdihtreb_syndicated_ref']) && '1' === $_COOKIE['mdihtreb_syndicated_ref']) {
    115         if (! empty($options['element_selector'])) {
     115        if (!empty($options['element_selector'])) {
    116116
    117117            // Only allow simple selectors
     
    123123        }
    124124
    125         if (! empty($options['redirect_url'])) {
     125        if (!empty($options['redirect_url'])) {
    126126            $redirect = esc_url_raw($options['redirect_url']);
    127127
    128             if (! empty($redirect)) {
     128            if (!empty($redirect)) {
    129129                wp_register_script('mdihtreb-redirect', false, array(), '1.0', true);
    130130                wp_enqueue_script('mdihtreb-redirect');
     
    135135
    136136    // Enqueue client-side script if enabled
    137     if (! empty($options['enable_js_check'])) {
     137    if (!empty($options['enable_js_check'])) {
    138138        $domains = array_filter(array_map('trim', explode(',', $options['syndicated_domains'])));
    139139        $data = array(
    140             'domains'         => array_values($domains),
     140            'domains' => array_values($domains),
    141141            'element_selector' => $options['element_selector'],
    142             'redirect_url'    => $options['redirect_url'],
     142            'redirect_url' => $options['redirect_url'],
    143143            'cookie_lifetime' => max(1, (int) $options['cookie_lifetime']),
    144             'cookie_path'     => defined('COOKIEPATH') ? COOKIEPATH : '/',
    145             'cookie_name'     => 'mdihtreb_syndicated_ref'
     144            'cookie_path' => defined('COOKIEPATH') ? COOKIEPATH : '/',
     145            'cookie_name' => 'mdihtreb_syndicated_ref'
    146146        );
    147147
     
    220220    $output = array();
    221221    // capability check
    222     if (! current_user_can('manage_options')) {
     222    if (!current_user_can('manage_options')) {
    223223        return get_option('mdihtreb_settings', $defaults);
    224224    }
    225225
    226226    // boolean flags
    227     $output['show_notification'] = ! empty($input['show_notification']) ? 1 : 0;
    228     $output['enable_js_check']   = ! empty($input['enable_js_check']) ? 1 : 0;
     227    $output['show_notification'] = !empty($input['show_notification']) ? 1 : 0;
     228    $output['enable_js_check'] = !empty($input['enable_js_check']) ? 1 : 0;
    229229
    230230    // syndicated domains - keep as comma-separated list of domains/strings
     
    254254function mdihtreb_settings_page()
    255255{
    256     if (! current_user_can('manage_options')) {
    257         return;
    258     }
    259 
    260     $options = wp_parse_args(get_option('mdihtreb_settings', array()), mdihtreb_get_default_options());
    261 ?>
     256    if (!current_user_can('manage_options')) {
     257        return;
     258    }
     259
     260    $options = wp_parse_args(get_option('mdihtreb_settings', array()), mdihtreb_get_default_options());
     261    ?>
    262262    <div class="wrap">
    263263        <h1><?php esc_html_e('HTTP Referer Settings', 'mdi-http-referer-block'); ?></h1>
     
    271271                    <th><?php esc_html_e('Blocked Referer Domains', 'mdi-http-referer-block'); ?></th>
    272272                    <td>
    273                         <input type="text" name="mdihtreb_settings[syndicated_domains]" value="<?php echo esc_attr($options['syndicated_domains']); ?>" class="regular-text" />
    274                         <p class="description"><?php esc_html_e('Comma-separated list. Partial domain matches are supported (e.g. example.com, partner.example).', 'mdi-http-referer-block'); ?></p>
     273                        <input type="text" name="mdihtreb_settings[syndicated_domains]"
     274                            value="<?php echo esc_attr($options['syndicated_domains']); ?>" class="regular-text" />
     275                        <p class="description">
     276                            <?php esc_html_e('Comma-separated list. Partial domain matches are supported (e.g. example.com, partner.example).', 'mdi-http-referer-block'); ?>
     277                        </p>
    275278                    </td>
    276279                </tr>
     
    278281                    <th><?php esc_html_e('Element Selector to Hide', 'mdi-http-referer-block'); ?></th>
    279282                    <td>
    280                         <input type="text" name="mdihtreb_settings[element_selector]" value="<?php echo esc_attr($options['element_selector']); ?>" class="regular-text" />
    281                         <p class="description"><?php esc_html_e('CSS selector to hide for flagged visitors. Example: ".price, #buy-button"', 'mdi-http-referer-block'); ?></p>
     283                        <input type="text" name="mdihtreb_settings[element_selector]"
     284                            value="<?php echo esc_attr($options['element_selector']); ?>" class="regular-text" />
     285                        <p class="description">
     286                            <?php esc_html_e('CSS selector to hide for flagged visitors. Example: ".price, #buy-button"', 'mdi-http-referer-block'); ?>
     287                        </p>
    282288                    </td>
    283289                </tr>
     
    285291                    <th><?php esc_html_e('Redirect URL', 'mdi-http-referer-block'); ?></th>
    286292                    <td>
    287                         <input type="url" name="mdihtreb_settings[redirect_url]" value="<?php echo esc_attr($options['redirect_url']); ?>" class="regular-text" />
    288                         <p class="description"><?php esc_html_e('Optional. When set, flagged visitors will be redirected to this URL.', 'mdi-http-referer-block'); ?></p>
     293                        <input type="url" name="mdihtreb_settings[redirect_url]"
     294                            value="<?php echo esc_attr($options['redirect_url']); ?>" class="regular-text" />
     295                        <p class="description">
     296                            <?php esc_html_e('Optional. When set, flagged visitors will be redirected to this URL.', 'mdi-http-referer-block'); ?>
     297                        </p>
    289298                    </td>
    290299                </tr>
     
    292301                    <th><?php esc_html_e('Cookie Lifetime (Days)', 'mdi-http-referer-block'); ?></th>
    293302                    <td>
    294                         <input type="number" name="mdihtreb_settings[cookie_lifetime]" value="<?php echo esc_attr($options['cookie_lifetime']); ?>" min="1" class="small-text" />
    295                         <p class="description"><?php esc_html_e('Number of days the cookie remains valid.', 'mdi-http-referer-block'); ?></p>
     303                        <input type="number" name="mdihtreb_settings[cookie_lifetime]"
     304                            value="<?php echo esc_attr($options['cookie_lifetime']); ?>" min="1" class="small-text" />
     305                        <p class="description">
     306                            <?php esc_html_e('Number of days the cookie remains valid.', 'mdi-http-referer-block'); ?></p>
    296307                    </td>
    297308                </tr>
     
    300311        </form>
    301312    </div>
    302 <?php
     313    <?php
    303314}
    304315
  • mdi-http-referer-block/trunk/readme.txt

    r3395664 r3420435  
    1 === MDI HTTP Referer Block ===
     1=== Smart Traffic Source Filter for WordPress ===
    22Contributors: mediuminteractive
    33Tags: referer, referrer, redirect, cookie, hide-content
    44Requires at least: 5.6
    5 Tested up to: 6.8
    6 Stable tag: 1.0
     5Tested up to: 6.9
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    5454= 1.0 =
    5555* Initial public release.
     56
     57= 1.0.1 =
     58* Update assets
Note: See TracChangeset for help on using the changeset viewer.