Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with zip file creation on Windows #602

Closed
nicholasingham opened this issue Apr 26, 2024 · 3 comments · Fixed by #606
Closed

Problem with zip file creation on Windows #602

nicholasingham opened this issue Apr 26, 2024 · 3 comments · Fixed by #606

Comments

@nicholasingham
Copy link

When creating zip files on Windows, e.g. using LocalWP, the plugin creates files called

  • twentytwentythree/partspost-meta.html
  • twentytwentythree/templatesindex.html

rather than

  • twentytwentythree/parts/post-meta.html
  • twentytwentythree/parts/index.html

I'm not quite sure what the odd character is but it appears as a bold dot in Windows file explorer.

This only happens on Windows where DIRECTORY_SEPARATOR has been set to the backslash character

We've managed to create a workaround by changing the code on lines 175 and 198 in theme-zip.php from

$template_folders['wp_template'] . DIRECTORY_SEPARATOR . $template->slug . '.html',

and

$template_folders['wp_template_part'] . DIRECTORY_SEPARATOR . $template->slug . '.html',

to

$template_folders['wp_template'] . '/' . $template->slug . '.html',

and

$template_folders['wp_template_part'] . '/' . $template->slug . '.html',

The problem does not occur on a Linux host.

@t-hamano
Copy link
Contributor

Hi @nicholasingham,

What is the WindowsOS version and CBT plugin version? I tested it on Windows 11, CBT plugin version 2.1.2, but could not reproduce it.

image

@nicholasingham
Copy link
Author

Apologies. The problem is more obscure and difficult to reproduce than than I first realised.

I've just done a fresh install of Wordpress 6.5.2 using LocalWP on Windows 10 and installed Create Block Theme plugin 2.1.2.

I've then exported both the standard 2024 and 2023 themes using the CBT Export Zip option.

I've now noticed that if I unzip the files using 7-Zip, I see the problem with odd files names that I described earlier.

However, if I unzip the files using Windows built in "Extract All" feature in Windows Explorer, I do not see the oddly named files.

I can also successfully import these exported zip files into another Windows LocalWP instance of Wordpress (and also to a site on a rather old version of XAMPP).

However, if I try to install these theme files to a Wordpress instance on our cPanel Linux hosting running PHP8.1 I get the following error

"The package could not be installed. Template is missing. Standalone themes need to have a templates/index.html or index.php template file. Child themes need to have a Template header in the style.css stylesheet."

So it seems that the problem is only apparent using certain unzip programs e.g. 7-Zip and whatever PHP unzip library our cPanel hosting uses.

Hope that makes sense.

@t-hamano
Copy link
Contributor

Thanks for the reply.

I can reproduce the problem too and I think your suggestion makes sense. I believe #606 will fix this problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants