Skip to content

Instantly share code, notes, and snippets.

@hereswhatidid
Created August 27, 2021 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hereswhatidid/bf6caac81fc300d1284a4b00d35f3253 to your computer and use it in GitHub Desktop.
Save hereswhatidid/bf6caac81fc300d1284a4b00d35f3253 to your computer and use it in GitHub Desktop.
Pass parameters to Regenerate Thumbnails plugin
<?php
/**
* Preselect the delete old and only missing checkboxes based on the `deleteold` query param
**/
add_filter( 'regenerate_thumbnails_options_onlymissingthumbnails', function( $checked ) {
return ( empty( $_GET['deleteold'] ) && ( $_GET['deleteold'] !== 'yes' ) );
});
add_filter( 'regenerate_thumbnails_options_deleteoldthumbnails', function( $checked ) {
return ( ! empty( $_GET['deleteold'] ) && ( $_GET['deleteold'] === 'yes' ) );
});
/**
* URL structure for passing specific images: /wp-admin/tools.php?page=regenerate-thumbnails&ids=7033%2C7028%2C7027%2C7026
**/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment