Index: regenerate-thumbnails.php =================================================================== --- regenerate-thumbnails.php (revision 49478) +++ regenerate-thumbnails.php (revision 49749) @@ -164,7 +164,18 @@ // Directly querying the database is normally frowned upon, but all // of the API functions will return the full post objects which will // suck up lots of memory. This is best, just not as future proof. - if ( ! $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%' ORDER BY ID DESC" ) ) { + + // If a month was selected, let's validate it and plug it into query. + // The month date should be in format YYYY/MM + if ( ! empty( $_POST['regenerate-thumbnails-date'] ) ) { + if ( preg_match( '/(\d{4})\/(\d{2})/', $_POST['regenerate-thumbnails-date'], $date_parts ) ) { + $month = $date_parts[1] . '/' . $date_parts[2]; + } + } + // Next, build the SQL to inject into query + $where_date = !empty( $month ) ? "AND DATE_FORMAT(post_date, '%Y/%m') = '$month'" : ""; + + if ( ! $images = $wpdb->get_results( "SELECT ID FROM $wpdb->posts WHERE post_type = 'attachment' AND post_mime_type LIKE 'image/%' $where_date ORDER BY ID DESC" ) ) { echo '

' . sprintf( __( "Unable to find any images. Are you sure some exist?", 'regenerate-thumbnails' ), admin_url( 'upload.php?post_mime_type=image' ) ) . "

"; return; } @@ -327,6 +338,10 @@

+

+ + +

@@ -396,4 +411,4 @@ $RegenerateThumbnails = new RegenerateThumbnails(); } -?> \ No newline at end of file +?>