Changeset 3435517
- Timestamp:
- 01/08/2026 10:45:17 PM (4 days ago)
- Location:
- ad-unblock/trunk
- Files:
-
- 5 edited
-
ad-unblock.php (modified) (6 diffs)
-
assets/css/admin.css (modified) (1 diff)
-
assets/js/admin.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
uninstall.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ad-unblock/trunk/ad-unblock.php
r3396365 r3435517 4 4 * Plugin Name: Ad Unblock 5 5 * Description: Integrates your WordPress site with Ad Unblock service to recover ad revenue lost to ad blockers. 6 * Version: 1.1. 16 * Version: 1.1.2 7 7 * Author: Ad Unblock 8 8 * Author URI: https://ad-unblock.com … … 17 17 } 18 18 19 define('AD_UNBLOCK_VERSION', '1.1. 1');19 define('AD_UNBLOCK_VERSION', '1.1.2'); 20 20 define('AD_UNBLOCK_PLUGIN_DIR', plugin_dir_path(__FILE__)); 21 21 define('AD_UNBLOCK_PLUGIN_URL', plugin_dir_url(__FILE__)); … … 109 109 register_setting('ad_unblock_options', 'ad_unblock_verification_code', array( 110 110 'sanitize_callback' => 'sanitize_text_field', 111 'default' => '', 112 )); 113 114 register_setting('ad_unblock_options', 'ad_unblock_custom_api_endpoint', array( 115 'sanitize_callback' => 'esc_url_raw', 111 116 'default' => '', 112 117 )); … … 141 146 esc_html__('Enable On Pages', 'ad-unblock'), 142 147 array($this, 'render_page_rules_field'), 148 'ad_unblock', 149 'ad_unblock_section_main' 150 ); 151 152 add_settings_field( 153 'ad_unblock_custom_api_endpoint', 154 esc_html__('API Endpoint', 'ad-unblock'), 155 array($this, 'render_custom_api_endpoint_field'), 143 156 'ad_unblock', 144 157 'ad_unblock_section_main' … … 272 285 </p> 273 286 </div> 287 <?php 288 } 289 290 /** 291 * Render custom API endpoint field 292 */ 293 public function render_custom_api_endpoint_field() 294 { 295 $custom_endpoint = get_option('ad_unblock_custom_api_endpoint', ''); 296 $use_custom = !empty($custom_endpoint); 297 ?> 298 <fieldset> 299 <legend class="screen-reader-text"><?php esc_html_e('API Endpoint', 'ad-unblock'); ?></legend> 300 301 <p> 302 <label> 303 <input type="radio" name="ad_unblock_endpoint_type" value="default" 304 <?php checked(!$use_custom); ?> class="ad-unblock-endpoint-toggle"> 305 <?php esc_html_e('Use default endpoint', 'ad-unblock'); ?> 306 </label> 307 <br> 308 <span class="description" style="margin-left: 25px;"> 309 <code><?php echo esc_html(self::API_ENDPOINT); ?></code> 310 </span> 311 </p> 312 313 <p> 314 <label> 315 <input type="radio" name="ad_unblock_endpoint_type" value="custom" 316 <?php checked($use_custom); ?> class="ad-unblock-endpoint-toggle"> 317 <?php esc_html_e('Use custom endpoint', 'ad-unblock'); ?> 318 </label> 319 </p> 320 321 <div id="ad_unblock_custom_endpoint_wrapper" style="<?php echo $use_custom ? '' : 'display:none;'; ?>"> 322 <input type="url" name="ad_unblock_custom_api_endpoint" id="ad_unblock_custom_api_endpoint" 323 value="<?php echo esc_attr($custom_endpoint); ?>" class="regular-text" 324 placeholder="https://example.com/api/scripts"> 325 <p class="description"> 326 <?php esc_html_e('Enter the custom API endpoint URL to fetch unblock script sources.', 'ad-unblock'); ?> 327 </p> 328 </div> 329 </fieldset> 274 330 <?php 275 331 } … … 547 603 548 604 /** 605 * Get the API endpoint to use (custom or default) 606 */ 607 private function get_api_endpoint() 608 { 609 $custom_endpoint = get_option('ad_unblock_custom_api_endpoint', ''); 610 return !empty($custom_endpoint) ? $custom_endpoint : self::API_ENDPOINT; 611 } 612 613 /** 549 614 * Fetch script sources from API 550 615 */ 551 616 private function fetch_script_sources_from_api() 552 617 { 553 $response = wp_remote_get(self::API_ENDPOINT, array('timeout' => 10)); 618 $api_endpoint = $this->get_api_endpoint(); 619 $response = wp_remote_get($api_endpoint, array('timeout' => 10)); 554 620 555 621 if (is_wp_error($response) || 200 !== wp_remote_retrieve_response_code($response)) { -
ad-unblock/trunk/assets/css/admin.css
r3342583 r3435517 105 105 } 106 106 107 #ad_unblock_custom_endpoint_wrapper { 108 margin-top: 10px; 109 margin-left: 25px; 110 padding: 15px; 111 background: #f9f9f9; 112 border-radius: 4px; 113 border-left: 3px solid #2271b1; 114 } 115 116 #ad_unblock_custom_endpoint_wrapper input[type="url"] { 117 width: 100%; 118 max-width: 600px; 119 } 120 121 #ad_unblock_custom_endpoint_wrapper .description { 122 margin-top: 8px; 123 } 124 125 .ad-unblock-endpoint-toggle { 126 margin-right: 5px; 127 } 128 107 129 /* Cache Status Styles */ 108 130 .ad-unblock-cache-status { -
ad-unblock/trunk/assets/js/admin.js
r3366120 r3435517 44 44 }); 45 45 46 // Handle custom API endpoint toggle 47 var $endpointRadios = $(".ad-unblock-endpoint-toggle"); 48 var $customEndpointWrapper = $("#ad_unblock_custom_endpoint_wrapper"); 49 var $customEndpointInput = $("#ad_unblock_custom_api_endpoint"); 50 51 function toggleCustomEndpoint(animate) { 52 var selectedValue = $('input[name="ad_unblock_endpoint_type"]:checked').val(); 53 54 if (selectedValue === "custom") { 55 if (animate !== false) { 56 $customEndpointWrapper.slideDown(200); 57 } else { 58 $customEndpointWrapper.show(); 59 } 60 } else { 61 if (animate !== false) { 62 $customEndpointWrapper.slideUp(200); 63 } else { 64 $customEndpointWrapper.hide(); 65 } 66 // Clear the input when switching to default 67 $customEndpointInput.val(""); 68 } 69 } 70 71 // Set initial state without animation 72 if ($endpointRadios.length > 0) { 73 toggleCustomEndpoint(false); 74 } 75 76 // Handle radio button change with animation 77 $endpointRadios.on("change", function() { 78 toggleCustomEndpoint(true); 79 }); 80 46 81 // Handle "Enable on all pages" checkbox 47 82 var $allPagesCheckbox = $('input[name="ad_unblock_page_rules[all_pages]"]'); -
ad-unblock/trunk/readme.txt
r3396365 r3435517 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 1.1. 16 Stable tag: 1.1.2 7 7 Requires PHP: 7.0 8 8 License: GPLv2 or later … … 75 75 == Changelog == 76 76 77 = 1.1.2 = 78 * Added custom API endpoint option with toggle to use default or custom URL 79 77 80 = 1.1.1 = 78 81 * Update server side API URL -
ad-unblock/trunk/uninstall.php
r3396365 r3435517 4 4 * 5 5 * @link https://ad-unblock.com 6 * @since 1.1. 16 * @since 1.1.2 7 7 * 8 8 * @package Ad_Unblock
Note: See TracChangeset
for help on using the changeset viewer.