| @@ -24,4 +24,25 @@ | ||
| 24 | 24 | unset( $wp_to_buffer ); |
| 25 | 25 | |
| 26 | 26 | } |
| 27 | 27 | add_action( 'wp_to_buffer_log_cleanup_cron', 'wp_to_buffer_log_cleanup_cron' ); |
| 28 | + | |
| 29 | +/** | |
| 30 | + * Define the WP Cron function to perform the Media Library cleanup | |
| 31 | + * of Text to Image generations | |
| 32 | + * | |
| 33 | + * @since 4.1.0 | |
| 34 | + */ | |
| 35 | +function wp_to_buffer_media_cleanup_cron() { | |
| 36 | + | |
| 37 | + // Initialise Plugin. | |
| 38 | + $wp_to_buffer = WP_To_Buffer::get_instance(); | |
| 39 | + $wp_to_buffer->initialize(); | |
| 40 | + | |
| 41 | + // Call Media Cleanup function. | |
| 42 | + $wp_to_buffer->get_class( 'media_library' )->cleanup(); | |
| 43 | + | |
| 44 | + // Shutdown. | |
| 45 | + unset( $wp_to_buffer ); | |
| 46 | + | |
| 47 | +} | |
| 48 | +add_action( 'wp_to_buffer_media_cleanup_cron', 'wp_to_buffer_media_cleanup_cron' ); | |