Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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 ' <p>' . sprintf( __( "Unable to find any images. Are you sure <a href='%s'>some exist</a>?", 'regenerate-thumbnails' ), admin_url( 'upload.php?post_mime_type=image' ) ) . "</p></div>";
- return;
- }
- @@ -327,6 +338,10 @@
- <p><?php _e( 'To begin, just press the button below.', 'regenerate-thumbnails '); ?></p>
- + <p>
- + <?php _e( 'Month to regenerate, in format YYYY/MM (leave blank to include all images)', 'regenerate-thumbnails' ); ?>
- + <input type="textfield" class="hide-if-no-js" name="regenerate-thumbnails-date" id="regenerate-thumbnails-date" value="<?php print date('Y/m'); ?>" />
- + </p>
- <p><input type="submit" class="button hide-if-no-js" name="regenerate-thumbnails" id="regenerate-thumbnails" value="<?php _e( 'Regenerate All Thumbnails', 'regenerate-thumbnails' ) ?>" /></p>
- <noscript><p><em><?php _e( 'You must enable Javascript in order to proceed!', 'regenerate-thumbnails' ) ?></em></p></noscript>
- @@ -396,4 +411,4 @@
- $RegenerateThumbnails = new RegenerateThumbnails();
- }
- -?>
- \ No newline at end of file
- +?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement