Placing assets for external use
-
05-11-2019 - |
Question
I'm developing a plugin, that is meant to work on external requests to a wordpress site.
The plugin will generate a .json
file, and will come with 2 default .css
style and 1 .css
file that will contain the common styling rules (I will combine them later).
My concerns stands at, where should I place the files and is it safe to create a simlink
between plugin's assets folder and where the .json
file is generated at.
Plugin folder structure:
plugin/
assets/
common.css
blue.css
clear.css
plugin.php
plugin-class.php
And were currently the json
file is generated:
$dir = wp_upload_dir();
$dir = $dir['basedir'].'/plugin';
WP_Filesystem();
global $wp_filesystem;
if (wp_mkdir_p($dir))
$wp_filesystem->put_contents($dir.'/latestArticles.json', 'callback('.json_encode($toExport).')', 0644);
On a future release, I will allow the possibility for the files to be uploaded to a S3 Bucket, but meanwhile, I am currently placing them to the path mentioned above, mainly because all may requests to mm.site.com/...
are going through CloudFront
So, I am asking that if is safe to have (or recommended) a simlink
from site/wp-content/plugins/plugin/assets/
to site/wp-content/uploads/plugin/assets
? If not, where should I place my file, so they can be available from external requests?
No correct solution