Changeset 3420435
- Timestamp:
- 12/15/2025 06:20:28 PM (5 weeks ago)
- Location:
- mdi-http-referer-block
- Files:
-
- 7 added
- 4 edited
-
assets/banner-772x250.png (modified) (previous)
-
assets/icon-128x128.png (modified) (previous)
-
tags/1.0.1 (added)
-
tags/1.0.1/assets (added)
-
tags/1.0.1/assets/js (added)
-
tags/1.0.1/assets/js/mdi-referrer-tracker.js (added)
-
tags/1.0.1/mdi-http-referer-block.php (added)
-
tags/1.0.1/readme.txt (added)
-
tags/1.0.1/uninstall.php (added)
-
trunk/mdi-http-referer-block.php (modified) (14 diffs)
-
trunk/readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
mdi-http-referer-block/trunk/mdi-http-referer-block.php
r3383476 r3420435 2 2 3 3 /** 4 * Plugin Name: MDI HTTP Referer Block4 * Plugin Name: Smart Traffic Source Filter for WordPress 5 5 * Description: Hide elements or redirect users when arriving from configured referrer domains. Supports PHP-side and client-side checks and optional notification. 6 6 * Version: 1.0 … … 12 12 */ 13 13 14 if (! defined('ABSPATH')) {14 if (!defined('ABSPATH')) { 15 15 exit; 16 16 } … … 23 23 { 24 24 return array( 25 'show_notification' => 0,26 'enable_js_check' => 0,25 'show_notification' => 0, 26 'enable_js_check' => 0, 27 27 'syndicated_domains' => '', 28 'element_selector' => '',29 'redirect_url' => '',30 'cookie_lifetime' => 1, // days28 'element_selector' => '', 29 'redirect_url' => '', 30 'cookie_lifetime' => 1, // days 31 31 ); 32 32 } … … 96 96 97 97 // 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'])) { 99 99 $referrer = sanitize_text_field(esc_url_raw(wp_unslash($_SERVER['HTTP_REFERER']))); 100 100 … … 113 113 // If PHP-side cookie set, output immediate CSS or redirect (safe) 114 114 if (isset($_COOKIE['mdihtreb_syndicated_ref']) && '1' === $_COOKIE['mdihtreb_syndicated_ref']) { 115 if (! empty($options['element_selector'])) {115 if (!empty($options['element_selector'])) { 116 116 117 117 // Only allow simple selectors … … 123 123 } 124 124 125 if (! empty($options['redirect_url'])) {125 if (!empty($options['redirect_url'])) { 126 126 $redirect = esc_url_raw($options['redirect_url']); 127 127 128 if (! empty($redirect)) {128 if (!empty($redirect)) { 129 129 wp_register_script('mdihtreb-redirect', false, array(), '1.0', true); 130 130 wp_enqueue_script('mdihtreb-redirect'); … … 135 135 136 136 // Enqueue client-side script if enabled 137 if (! empty($options['enable_js_check'])) {137 if (!empty($options['enable_js_check'])) { 138 138 $domains = array_filter(array_map('trim', explode(',', $options['syndicated_domains']))); 139 139 $data = array( 140 'domains' => array_values($domains),140 'domains' => array_values($domains), 141 141 'element_selector' => $options['element_selector'], 142 'redirect_url' => $options['redirect_url'],142 'redirect_url' => $options['redirect_url'], 143 143 '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' 146 146 ); 147 147 … … 220 220 $output = array(); 221 221 // capability check 222 if (! current_user_can('manage_options')) {222 if (!current_user_can('manage_options')) { 223 223 return get_option('mdihtreb_settings', $defaults); 224 224 } 225 225 226 226 // 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; 229 229 230 230 // syndicated domains - keep as comma-separated list of domains/strings … … 254 254 function mdihtreb_settings_page() 255 255 { 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 ?> 262 262 <div class="wrap"> 263 263 <h1><?php esc_html_e('HTTP Referer Settings', 'mdi-http-referer-block'); ?></h1> … … 271 271 <th><?php esc_html_e('Blocked Referer Domains', 'mdi-http-referer-block'); ?></th> 272 272 <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> 275 278 </td> 276 279 </tr> … … 278 281 <th><?php esc_html_e('Element Selector to Hide', 'mdi-http-referer-block'); ?></th> 279 282 <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> 282 288 </td> 283 289 </tr> … … 285 291 <th><?php esc_html_e('Redirect URL', 'mdi-http-referer-block'); ?></th> 286 292 <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> 289 298 </td> 290 299 </tr> … … 292 301 <th><?php esc_html_e('Cookie Lifetime (Days)', 'mdi-http-referer-block'); ?></th> 293 302 <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> 296 307 </td> 297 308 </tr> … … 300 311 </form> 301 312 </div> 302 <?php313 <?php 303 314 } 304 315 -
mdi-http-referer-block/trunk/readme.txt
r3395664 r3420435 1 === MDI HTTP Referer Block===1 === Smart Traffic Source Filter for WordPress === 2 2 Contributors: mediuminteractive 3 3 Tags: referer, referrer, redirect, cookie, hide-content 4 4 Requires at least: 5.6 5 Tested up to: 6. 86 Stable tag: 1.0 5 Tested up to: 6.9 6 Stable tag: 1.0.1 7 7 License: GPLv2 or later 8 8 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 54 54 = 1.0 = 55 55 * Initial public release. 56 57 = 1.0.1 = 58 * Update assets
Note: See TracChangeset
for help on using the changeset viewer.