WebP Auto Convert: Hooks and filters
The wpwac_capability filter, the WordPress upload filters the converter uses, and the options where settings and counters are stored.
wpwac_capability
Filters the capability needed to see the Settings → WebP Auto Convert menu item and screen.
$capability(string) — defaultmanage_options.
The settings are saved through WordPress’s options.php, which checks the capability for the wpwac_settings_group settings group separately. If you lower the capability, filter that too, otherwise the screen opens but saving is refused:
// Let editors open and save Settings → WebP Auto Convert.
add_filter( 'wpwac_capability', function () {
return 'edit_others_posts';
} );
// Saving goes through options.php, which checks its own capability
// for the settings group — raise it to match.
add_filter( 'option_page_capability_wpwac_settings_group', function () {
return 'edit_others_posts';
} );
Where the converter hooks in
The plugin has no actions of its own. It converts files from two WordPress core filters, both at priority 10 with 2 arguments:
wp_handle_upload— normal uploads (Media Library, editors, REST API file uploads).wp_handle_sideload— files WordPress fetches or sideloads, such as images downloaded from a URL.
The callback receives the upload array (file, url, type) and returns it with the WebP path, URL and image/webp type. Your own callbacks on these filters at a later priority see the converted file. To turn conversion off for one job, remove the callbacks temporarily — the converter object is available as wpwac()->converter:
// Skip conversion while a particular import runs.
$converter = wpwac()->converter;
remove_filter( 'wp_handle_upload', array( $converter, 'maybe_convert' ), 10 );
remove_filter( 'wp_handle_sideload', array( $converter, 'maybe_convert' ), 10 );
// ... run your import ...
add_filter( 'wp_handle_upload', array( $converter, 'maybe_convert' ), 10, 2 );
add_filter( 'wp_handle_sideload', array( $converter, 'maybe_convert' ), 10, 2 );
Stored options
wpwac_settings— array withenabled,max_width,max_height,quality,formats(MIME types) anddelete_original.wpwac_stats—count,original_bytesandnew_bytesfor the counters.
Both are deleted when the plugin is deleted from the Plugins screen.
Did this answer the question? No — open a support request