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

Use wp_get_upload_dir() instead of wp_upload_dir() during plugin bootstrap #140

Open
kasparsd opened this issue Sep 2, 2024 · 0 comments

Comments

@kasparsd
Copy link

kasparsd commented Sep 2, 2024

During the plugin bootstrap logic in wp-shortpixel.php calls wp_upload_dir() which determines the path of the uploads directory for the current month and attempts to create it whenever a new month rolls over.

$sp__uploads = wp_upload_dir();

This logic is triggered on every pageload of the site when the plugin file is loaded and will create new directories even for months when no new files were uploaded.

Consider switching to wp_get_upload_dir() which returns the same data but doesn’t do the file operation.

Alternatively, consider delaying the call to any of these functions (in bootstrap logic in general) until the data is actually needed for the first time (when rendering an image).

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

No branches or pull requests

1 participant