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

Multisite: Show upload space usage for a subsite #8303

Open
wants to merge 10 commits into
base: trunk
Choose a base branch
from

Conversation

lenasterg
Copy link

@lenasterg lenasterg commented Feb 12, 2025

This pull request fixes the issues descripted in the
Trac ticket: https://core.trac.wordpress.org/ticket/60549

In superadmin 'Edit site' page:

  1. Shows the network default Site upload space
  2. The site's current use.

and also displays space usage information to the sub site administration in the media gallery pages.

This update introduces a new function, get_space_usage(), which enhances the way WordPress reports upload space usage for a site. The function calculates the space used for uploads and provides a detailed or simplified report based on whether the upload space check is enabled or disabled.

When upload space check is disabled: The function returns a simple message showing the space used in megabytes (e.g., "500 MB Space Used").

When upload space check is enabled: The function provides a more detailed report, including the percentage of space used and the total space allowed (e.g., "Used: 500 MB (50%) of 1 GB").

This enhancement improves transparency and usability for site administrators by offering clearer insights into their site's storage usage. The function also uses localization-friendly strings, ensuring compatibility with multilingual setups.

Technical Details:

The function get_space_usage() leverages existing helper functions like get_space_used(), get_space_allowed(), and size_format() to calculate and format the space usage.

The function respects the upload_space_check_disabled site option to determine the level of detail in the output.

This change is backward-compatible and does not affect existing functionality. It is particularly useful for multisite networks where storage management is critical.
The following images show the visual changes to the various pages.

In "Edit site"
edit_site_space

In 'Dashboard'
Before the suggested changes, when the upload_space_check_disabled site option was enabled, the admin had no information about the storage space.
blog_space_no_limit_before
After the suggested changes:
blog_space_no_limit_after
blog_space_limit

In 'Media Gallery'
gallery_limit
gallery_no_limit

In media upload pages
post-upload-ui-3
post-upload-ui-2
post-upload-ui

Adds functionality to display space usage information for a sub site, to the superadmin in 'Edit site' and to the sub site administration in the media gallery pages.
Copy link

github-actions bot commented Feb 12, 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 lenasterg, audrasjb.

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

Copy link

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.

@audrasjb
Copy link
Contributor

I added some commits to fix a handful of WPCS issues.

@audrasjb
Copy link
Contributor

Phew, all the coding standard issues are now fixed 😅

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.

2 participants