CodeCaste Media and Safe SVG File Upload Rules lets you decide which files can be uploaded to your site and how big they can be. You set the rules once, and they are applied everywhere files can come in.
The same rules are used for:
/wp/v2/media)This means a file cannot slip past your limits just because it was uploaded through a different plugin. If you prefer not to check other plugins, you can turn that part off in the settings.
No extra database tables and no background tasks. Settings are stored in the normal WordPress options.
Open Media upload restrictions, go to the General tab, choose a maximum file size and click Save settings. This limit applies to every file type that has no rule of its own.
pdf).You can edit, switch off or delete a rule at any time from the Configured rules list.
On the Extension rules tab, switch on Allow SVG uploads and choose a maximum SVG size. Every SVG is cleaned before it is saved. SVG stays off until you turn it on.
Other plugins and themes can use the same rules.
Functions
gupc_evaluate_upload( array $file, string $route = 'custom_adapter' ) checks a file and returns a result object with the reason and message.gupc_is_upload_allowed( array $file, string $route = 'custom_adapter' ) returns true or false.gupc_get_effective_limit( string $extension ) returns the size limit in bytes for a file type (0 means blocked).Always check that the function exists first, for example if ( function_exists( 'gupc_is_upload_allowed' ) ).
Hooks
gupc_pre_evaluate_decision (filter): replace a decision before the rules run.gupc_upload_evaluated (action): runs after every decision, for logging.gupc_register_adapters (action): register your own upload adapter that implements GlobalUploadPolicyController\Adapters\Upload_Adapter_Interface.gupc_skip_request_guard (filter): skip the check for a request from another plugin.gupc_request_guard_skip_fields (filter): list upload field names the check should ignore.gupc_file_manager_ajax_actions (filter): add the AJAX action name of another file manager.