feat: support self-hosted OpenPanel instances - #2
Open
eightam wants to merge 1 commit into
Open
Conversation
Adds configurable API and tracking script URLs so the plugin can be used with self-hosted OpenPanel deployments. - New settings: API URL and Tracking script URL (Settings > OpenPanel), empty by default to keep using the hosted openpanel.dev services - New filters, taking precedence over settings: * openpanel_api_url - overrides the API base the proxy forwards to * openpanel_script_url - overrides the op1.js URL that gets cached/inlined * openpanel_proxy_allowed_hosts - extends the proxy hostname whitelist - Proxy whitelist now always includes the effective API host while keeping the hosted openpanel.dev endpoints enabled by default - op1.js cache is keyed by script URL so switching endpoints never serves a stale cached script; cache-clear clears old and URL-keyed entries - URL settings are sanitized to http(s) URLs with a host - Docs: README.md + readme.txt (installation steps, FAQ, changelog) Bump version to 1.1.0.
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for self-hosted OpenPanel instances. Previously the proxy endpoint (
https://api.openpanel.dev/) and tracking script URL (https://openpanel.dev/op1.js) were hardcoded, making the plugin unusable with self-hosted deployments.Fully backward compatible: leaving both new settings empty keeps the current hosted behavior.
Changes
Settings (Settings → OpenPanel)
https://analytics.example.com/api). Empty = hostedhttps://api.openpanel.dev/.op1.jsfor fully self-hosted setups. Empty = hostedhttps://openpanel.dev/op1.js.Filters (code-level overrides, take precedence over settings)
openpanel_api_urlopenpanel_script_urlop1.jsis loaded fromopenpanel_proxy_allowed_hostsPrecedence everywhere: filter > saved setting > hosted default.
Security
openpanel.devhosts, which remain allowed by default). A self-hosted API host is whitelisted automatically; arbitrary hosts are still rejected with403 invalid_target.openpanel_proxy_allowed_hostsexists so operators can deliberately whitelist additional hosts (e.g. a dedicated ingest subdomain).Caching
op1.jstransient cache is now keyed by script URL (op_wp_op1_js_<md5(url)>), so switching between hosted/self-hosted never serves a stale cached script. The cache-clear action clears both the legacy and new keys.Docs
README.md: new "Self-Hosted OpenPanel" section with the filter reference table.readme.txt: installation steps, new FAQ entries (self-hosted + code-level overrides), updated External Services section, changelog and upgrade notice.Testing
php -lclean.Example usage
Or, non-technically: Settings → OpenPanel → API URL.