| 开发者 |
blackswanlab
amirhpcom |
|---|---|
| 更新时间 | 2026年3月10日 04:48 |
| 捐献地址: | 去捐款 |
| PHP版本: | 5.4 及以上 |
| WordPress版本: | 6.8 |
| 版权: | GPLv2 or later |
| 版权网址: | 版权信息 |
wp_remote_get / wp_remote_post calls via the pre_http_request filter. Add domains to the blacklist and they'll be blocked before the request is even made. Whitelist specific URL patterns to let essential requests through (e.g. plugin update API).
Browser-side Resource Blocking (JS/CSS by Domain)
Deregisters enqueued JavaScript and CSS files loaded from blacklisted external domains. Toggle separately for admin panel and public frontend. Your own site's assets are never touched.
Block Specific Resources (by URL)
Block individual JS or CSS files by full URL, partial path, or even just a filename — works for both local and external resources. Per-item backend/frontend toggle. Perfect for removing unwanted plugin assets without editing code.
Features
?bswan-safe=1 — emergency bypass for any admin pageautoload=no for performanceBlackSwan\block_external_request\block_url_list
Filter the array of blocked domain strings. Each entry is matched via strpos() against the full request URL.
add_filter( 'BlackSwan\block_external_request\block_url_list', function( $domains ) { $domains[] = 'analytics.example.com'; return $domains; });
BlackSwan\block_external_request\whitelist_urls
Filter the array of whitelisted URL patterns. If a blocked URL also matches a whitelist pattern (via strpos()), the request is allowed through.
add_filter( 'BlackSwan\block_external_request\whitelist_urls', function( $patterns ) { $patterns[] = '//api.example.com/v2/license'; return $patterns; });
Whitelist patterns take priority over blacklist domains. Both filters accept and return a flat array of strings.
Links
blackswan-block-external-request folder to /wp-content/plugins/It depends on what you block. The default blacklist blocks common domains that slow down the admin panel (wordpress.org, google.com, yoast.com, etc.). The default whitelist ensures plugin update API calls still work. If something breaks, use the Pause button or Safe Mode to quickly restore access.
Add ?bswan-safe=1 to any admin URL (e.g. yoursite.com/wp-admin/?bswan-safe=1). This bypasses all blocking for that page load. The plugin settings page also automatically skips resource blocking.
Server-side HTTP blocking applies everywhere. Browser-side resource blocking and specific resource blocking have separate toggles for backend and frontend — you control where each applies.
All settings are stored as a single JSON value in wp_options with autoload=no for optimal performance. No separate database tables.
Yes. The Export/Import panel in the sidebar lets you download all settings as a JSON file and import it on another site.
We welcome contributions! You can:
BlackSwan\block_external_request\blocked_resources filter to allow programmatic blocking of specific JS/CSS resources by URL patternwp_nonce_url for one-click activationpostbox-header, handle-actions, handlediv)postboxes.add_postbox_toggles(pagenow)?bswan-safe=1 to any admin URL to bypass all blockingautoload=noBlackSwan\block_external_request\whitelist_urls filterpre_http_request filterBlackSwan\block_external_request\block_url_list for customization