Skip to content

Use assets directly instead of using wp-json endpoint#4

Merged
erseco merged 1 commit intomainfrom
3-styles-are-not-loaded-on-some-hosted-wordpress-environments-like-tastewp
Mar 10, 2026
Merged

Use assets directly instead of using wp-json endpoint#4
erseco merged 1 commit intomainfrom
3-styles-are-not-loaded-on-some-hosted-wordpress-environments-like-tastewp

Conversation

@erseco
Copy link
Contributor

@erseco erseco commented Mar 9, 2026

This pull request makes significant improvements to how eXeLearning extracted content is served and secured. The main changes separate the handling of HTML files (which require proxying for security and CSP headers) from static assets (which can be served directly from uploads), and update the .htaccess rules to reflect this. Unit tests are also updated and expanded to verify the new behavior.

Content serving and URL rewriting:

  • Updated rewrite_relative_urls and related methods in class-content-proxy.php to serve HTML files via the proxy (for CSP headers), while static assets (CSS, JS, images, fonts, etc.) are served directly from the uploads directory. Introduced get_uploads_url and is_html_path helpers for this logic.

  • Updated unit tests in ContentProxyTest.php to expect asset URLs to use the uploads path, and added new tests to ensure HTML/HTM links are routed through the proxy.
    Security and access control:

  • Revised the .htaccess generation in class-elp-upload-handler.php to allow direct access to static assets but block HTML files, using mod_rewrite for fine-grained control and fallback rules for environments without mod_rewrite.

These changes improve compatibility with hosted environments, prevent 403/404 errors for assets, and ensure HTML files are securely proxied for CSP and other headers.

@erseco erseco self-assigned this Mar 9, 2026
@erseco erseco linked an issue Mar 9, 2026 that may be closed by this pull request
@erseco erseco force-pushed the 3-styles-are-not-loaded-on-some-hosted-wordpress-environments-like-tastewp branch from e2aa23e to 58921da Compare March 10, 2026 08:00
@github-actions
Copy link
Contributor

Test in WordPress Playground

Test the plugin with the code from this branch:

Open in WordPress Playground

⚠️ The embedded eXeLearning editor is not available in this preview (requires build). All other plugin features (ELP upload, shortcode, Gutenberg block, preview) work normally.

@erseco erseco merged commit 38ab966 into main Mar 10, 2026
4 checks passed
@erseco erseco deleted the 3-styles-are-not-loaded-on-some-hosted-wordpress-environments-like-tastewp branch March 10, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Styles are not loaded on some hosted WordPress environments like TasteWP

1 participant