I advise you to only relocate assets that have filterable links. Altering links that are not filtered would require modifying core or other’s source files, which is strongly discouraged. Relatively speaking, WP assets do not amount to all that much resource and are not worth doing dirty hacks to accomplish relocation.
As to which assets are filterable, it varies. You’d have to track down how each is referenced and trace through source code. Identifying filters in syntax highlighted source code is relatively easy, but all the various ways assets are referenced start adding up.
What do you mean by filterable links ?
Well, no one has done it? I need to know which asset files are working together in wordpress from a wordpress developer, like
wp-admin got it’s own css,js, images, icons files…
and there are other static files, these files must be declared or used in a organised way. I just need to know which files are locating where and doing what.
Then as you have suggested, I should not edit core files but I can relocate other files right ?
I am trying to use of full facility of object storage and minimalist wordpress docker development.
Thanks for the reply, any further reply to clear my understanding ?
You “just” need to know which files are where and doing what 🙂 That’s a much more complex topic than “just” a forum reply would be able to answer. There are many hundreds of resource files doing many things throughout the hundreds of core PHP files. Depending the nature of your site, many of these resources are little used, if used at all. Most are only a few kilobytes in size or less.
Perhaps an even bigger issue is many of these files are updated when WP is updated. After each update, you would again need to move these files to DO storage.
How and where these files are referenced in core is quite varied and diverse. For each file you want to move, find where it’s referenced in served pages, then identify the code responsible for that output. Review the code to see if there is an apply_filters() call or some related mechanism where the link can be altered through custom plugin code without altering core code.
Let’s look at just one static file reference as an example. One of the most referenced of static files is /wp-includes/js/jquery/jquery.js. This file is not literally filterable by using add_filter() hooks, but it is a registered and enqueued script file, so it can be deregistered and reregistered using a new path.
Script registration for front end pages is done during the “wp_enqueue_scripts” action. In your custom plugin, hook this action with a large priority argument so your callback is called later than core callbacks. Within your action callback, you might have this:
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://www.storage-url.com/path-to-your-account/jquery/jquery.js');
Now when any code enqueues jQuery, the script tag src attribute will reference storage-url.com instead of your domain name.
Similar research and solutions are required for every file you want to move. In many cases, there may not be any solution available and the file cannot be properly relocated.
Okay, Thanks for the valuable information, I will try according to your suggestion and let you know the results.
Thanks.