rockiger / reactpress

Plugin that lets you easily create, build and deploy React apps into your existing WordPress sites.
https://rockiger.com/en/reactpress/
GNU General Public License v2.0
50 stars 6 forks source link

Path structure issues #49

Closed dylanlawrence closed 4 months ago

dylanlawrence commented 4 months ago

I'm using an environment that has a custom directory structure, so when it comes to content path it requires the correct wp call for the specific directory.

My main issue is shows up in the app_path method,
which I'm able to solve with WP_CONTENT_DIR like so:

$apppath = escapeshellcmd(REPR_APPS_PATH . "/{$appname}");
   // $document_root = rtrim(ABSPATH,  '/') ?? '';
if ($relative_to_home_path) {
  return explode(WP_CONTENT_DIR, $apppath)[1];

I'm also seeing several other similar issues, that can be easily corrected by prefixing with - content_url() before asset files

example - /plugins/reactpress/public/User.php:247 wp_enqueue_script('rp-react-app-asset-' . $app_index . '-' . $index, content_url() . $js_file, array(), '1', true);

then also the admin react form for Target Pages > Edit needs a base admin_url() / wp-admin.php ; example : echo wp_json_encode(['status' => 1, 'admin_url' => admin_url(), 'apps' => $apps]); then you would need to build this in your app with the ${admin_url}/edit link path etc.

rockiger commented 4 months ago

Unfortunatley that doesn't work in my test environment. REPR_APPS_PATH is based WP_CONTENT_DIR.

Could you share your configuration? I don't know much about custom folder configurations in WordPress, except that they exist.

dylanlawrence commented 4 months ago

I just use https://roots.io/bedrock/ for WordPress projects. It just moves some directories to a more sensible app structure and creates a config with multiple environments.

On Sun, Feb 18, 2024, 2:34 PM rockiger @.***> wrote:

Unfortunatley that doesn't work in my test environment. REPR_APPS_PATH is based WP_CONTENT_DIR.

Could you share your configuration? I don't know much about custom folder configurations in WordPress, except that they exist.

— Reply to this email directly, view it on GitHub https://github.com/rockiger/reactpress/issues/49#issuecomment-1951467944, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANQLA5I7SDDXK4KIMX2QTLYUJ6W5AVCNFSM6AAAAABDJJYQSGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNJRGQ3DOOJUGQ . You are receiving this because you authored the thread.Message ID: @.***>

rockiger commented 4 months ago

Ok, thanks. I will try to find a solution for Bedrock that doesn't collide with the default structure (at least with my LocalWP installation).

Do I understand this correctly: You did create a workaround for yourself to ReactPress and can wait to until the next release for any fixing this issue?

dylanlawrence commented 4 months ago

Yes WP_CONTENT_DIR and WP_CONTENT_URL seems to work as prefix.

I have another issue though where I have to remove & re-add the Target Page after it breaks during the "Update Dev-Environment". I think it's related to the same path issue, but I can't figure out why.

rockiger commented 4 months ago

I created a pull request with changes regarding the loading of the css- and js-assets. It works on my local Bedrock installation. Do you care to give it a try?

Feature/path structure issues #49

dylanlawrence commented 4 months ago

This looks good, the only thing I see now is the "Edit" on the Admin App, I was having issues with PR for this branch, maybe a patch - adminAppEdit.patch

rockiger commented 4 months ago

Great, I applied the patch. It works great.

I will wait a few days until I create a new release. Another user had a similar problem (that is why I use ABSPATH constant) and want to give him the chance to test and provide feedback on our solution.

I hope this fine with you?