Skip to content

Add function to replace URL #34

Description

@ouun

Dear KeyCDN-Team,
thank you very much for this amazing plugin. The latest updates are amazing!
However a simple helper function to replace a URL with the CDN URL would be awesome. Let's say for some reason I need to get the CDN URL of a path which does not contain one of the "CDN Inclusions". E.g. a hook for get_template_path() using the rewrite engine will not change the URL.

I have a workaround in place that adds and removes a fake JS file so that CDN Rewrite Engine processes it. However e.g. a simple get_cdn_url($url) function that uses the rewrite engine for whatever is passed. That would be awesome and replaces this:

add_filter('get_template_path', function ($url) {
            $workaround = '/workaround.js';

            // Workaround: Add & remove JS appendix to get recognized by Cache Enabler Rewrite Engine
            return str_replace($workaround, '', CDN_Enabler_Engine::rewriter($url . $workaround));
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions