Skip to content

29798 theme plugin uploader#8913

Open
nimesh-xecurify wants to merge 3 commits intoWordPress:trunkfrom
nimesh-xecurify:29798-theme-plugin-uploader
Open

29798 theme plugin uploader#8913
nimesh-xecurify wants to merge 3 commits intoWordPress:trunkfrom
nimesh-xecurify:29798-theme-plugin-uploader

Conversation

@nimesh-xecurify
Copy link

Added a check for package type (plugin / theme) before further processing while plugin & theme web upload. Display appropriate message and hyperlink (for better UX).

Trac ticket: WordPress Trac ticket #29798


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

@github-actions
Copy link

github-actions bot commented Jun 5, 2025

Hi @nimesh-xecurify! 👋

Thank you for your contribution to WordPress! 💖

It looks like this is your first pull request to wordpress-develop. Here are a few things to be aware of that may help you out!

No one monitors this repository for new pull requests. Pull requests must be attached to a Trac ticket to be considered for inclusion in WordPress Core. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description.

Pull requests are never merged on GitHub. The WordPress codebase continues to be managed through the SVN repository that this GitHub repository mirrors. Please feel free to open pull requests to work on any contribution you are making.

More information about how GitHub pull requests can be used to contribute to WordPress can be found in the Core Handbook.

Please include automated tests. Including tests in your pull request is one way to help your patch be considered faster. To learn about WordPress' test suites, visit the Automated Testing page in the handbook.

If you have not had a chance, please review the Contribute with Code page in the WordPress Core Handbook.

The Developer Hub also documents the various coding standards that are followed:

Thank you,
The WordPress Project

@github-actions
Copy link

github-actions bot commented Jun 5, 2025

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props nimeshatxecurify, karmatosed, circlecube.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@github-actions
Copy link

github-actions bot commented Jun 5, 2025

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@karmatosed
Copy link
Member

karmatosed commented Jul 16, 2025

@nimesh-xecurify can you share some visual screenshots what your PR does against the existing one please, along with confirm if this is just adding messaging?

@nimesh-xecurify
Copy link
Author

upload-plugin upload-theme

@circlecube
Copy link

I tested this and reproduced the issue where uploading a plugin or theme to the theme or plugin page (respectively) gives an error in core:
upload-plugin-as-theme-error
Upload plugin as theme error.
upload-theme-as-plugin-error
Upload theme as plugin error.

This patch adds code that adds a check to see if the upload is a plugin or theme, and if so, provides a link to the plugin/theme page to upload the zip there. The patch does look to work in my testing, redoing the above in the patched playground:
upload-plugin-as-theme-error-patch
Patched upload plugin as theme error with link to upload a plugin.
upload-theme-as-plugin-error-patch
Patched upload theme as plugin error with link to upload a theme.

I'm not sure if this code is run in every case or only when it detects there is an error with the uploaded zip. Ideally, we don't add this check when the file is as expected, for example, when a plugin zip is uploaded and a plugin zip is expected, it shouldn't also check if it's a theme. Also, I'm not entirely sure why the additional $environment value is added to the check_package method. Is this to be used in other cases?

I also tested uploading a non-plugin/theme zip file, and continue to see the original errors in those cases. The updated error is displayed only when the zip is found to be a plugin or theme that is uploaded in the wrong context.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants