diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 3304aa0286..3829adf76d 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1206,7 +1206,7 @@ case 'find_posts': $search_terms = array_map('_search_terms_tidy', $matches[0]); $searchand = $search = ''; - foreach( (array) $search_terms as $term) { + foreach ( (array) $search_terms as $term ) { $term = addslashes_gpc($term); $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; $searchand = ' AND '; @@ -1215,12 +1215,12 @@ case 'find_posts': if ( count($search_terms) > 1 && $search_terms[0] != $s ) $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; - $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND $search ORDER BY post_date_gmt DESC LIMIT 50" ); + $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); if ( ! $posts ) exit( __('No posts found.') ); - $html = '
'.__('Title').' | '.__('Time').' | '.__('Status').' |
---|
'.__('Title').' | '.__('Date').' | '.__('Status').' | > | +> + |
]*?>/g,"")}if(c){a("#find-posts-response").html(c)}}};a(document).ready(function(){a("#find-posts-submit").click(function(b){if(""==a("#find-posts-response").html()){b.preventDefault()}});a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){if(a(this).val()=="attach"){b.preventDefault();findPosts.open()}})})})})(jQuery);
\ No newline at end of file
+var findPosts;(function(a){findPosts={open:function(d,c){var b=document.documentElement.scrollTop||a(document).scrollTop();if(d&&c){a("#affected").attr("name",d).val(c)}a("#find-posts").show().draggable({handle:"#find-posts-head"}).css({top:b+50+"px",left:"50%",marginLeft:"-250px"});a("#find-posts-input").focus().keyup(function(f){if(f.which==27){findPosts.close()}});return false},close:function(){a("#find-posts-response").html("");a("#find-posts").draggable("destroy").hide()},send:function(){var b={ps:a("#find-posts-input").val(),action:"find_posts",_ajax_nonce:a("#_ajax_nonce").val()};if(a("#find-posts-pages").is(":checked")){b.pages=1}else{b.posts=1}a.ajax({type:"POST",url:ajaxurl,data:b,success:function(c){findPosts.show(c)},error:function(c){findPosts.error(c)}})},show:function(b){if(typeof(b)=="string"){this.error({responseText:b});return}var c=wpAjax.parseAjaxResponse(b);if(c.errors){this.error({responseText:wpAjax.broken})}c=c.responses[0];a("#find-posts-response").html(c.data)},error:function(b){var c=b.statusText;if(b.responseText){c=b.responseText.replace(/<.[^<>]*?>/g,"")}if(c){a("#find-posts-response").html(c)}}};a(document).ready(function(){a("#find-posts-submit").click(function(b){if(""==a("#find-posts-response").html()){b.preventDefault()}});a("#doaction, #doaction2").click(function(b){a('select[name^="action"]').each(function(){if(a(this).val()=="attach"){b.preventDefault();findPosts.open()}})})})})(jQuery);
\ No newline at end of file
diff --git a/wp-admin/upload.php b/wp-admin/upload.php
index 3607fde8d8..5ad2e7ffc4 100644
--- a/wp-admin/upload.php
+++ b/wp-admin/upload.php
@@ -62,7 +62,7 @@ if ( isset($_GET['find_detached']) ) {
$location = $referer;
}
- $location = add_query_arg( array( 'detached' => 1, 'attached' => $attached ) , $location );
+ $location = add_query_arg( array( 'attached' => $attached ) , $location );
wp_redirect($location);
exit;
}
@@ -76,13 +76,14 @@ if ( isset($_GET['find_detached']) ) {
} elseif ( ( $_GET['action'] != -1 || $_GET['action2'] != -1 ) && ( isset($_GET['media']) || isset($_GET['ids']) ) ) {
$post_ids = isset($_GET['media']) ? $_GET['media'] : explode(',', $_GET['ids']);
$doaction = ($_GET['action'] != -1) ? $_GET['action'] : $_GET['action2'];
- } else
+ } else {
wp_redirect($_SERVER['HTTP_REFERER']);
+ }
$location = 'upload.php';
if ( $referer = wp_get_referer() ) {
if ( false !== strpos($referer, 'upload.php') )
- $location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids'), $referer );
+ $location = remove_query_arg( array('trashed', 'untrashed', 'deleted', 'message', 'ids', 'posted'), $referer );
}
switch ( $doaction ) {
@@ -118,7 +119,6 @@ if ( isset($_GET['find_detached']) ) {
break;
}
- $location = remove_query_arg('posted', $location);
wp_redirect($location);
exit;
} elseif ( isset($_GET['_wp_http_referer']) && ! empty($_GET['_wp_http_referer']) ) {
@@ -134,16 +134,20 @@ if ( ! isset( $_GET['paged'] ) || $_GET['paged'] < 1 )
if ( isset($_GET['detached']) ) {
+ $media_per_page = (int) get_user_option('upload_per_page');
+ if ( empty($media_per_page) )
+ $media_per_page = 20;
+
if ( !empty($lost) ) {
- $start = ( $_GET['paged'] - 1 ) * 50;
- $page_links_total = ceil(count($lost) / 50);
+ $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
+ $page_links_total = ceil(count($lost) / $media_per_page);
$lost = implode(',', $lost);
- $orphans = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN ($lost) LIMIT $start, 50" );
+ $orphans = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' AND ID IN (%s) LIMIT %d, %d", $lost, $start, $media_per_page ) );
} else {
- $start = ( $_GET['paged'] - 1 ) * 25;
- $orphans = $wpdb->get_results( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT $start, 25" );
- $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / 25);
+ $start = ( (int) $_GET['paged'] - 1 ) * $media_per_page;
+ $orphans = $wpdb->get_results( $wpdb->prepare( "SELECT SQL_CALC_FOUND_ROWS * FROM $wpdb->posts WHERE post_type = 'attachment' AND post_status != 'trash' AND post_parent < 1 LIMIT %d, %d", $start, $media_per_page ) );
+ $page_links_total = ceil($wpdb->get_var( "SELECT FOUND_ROWS()" ) / $media_per_page);
}
$post_mime_types = get_post_mime_types();
@@ -429,7 +433,7 @@ foreach ($arc_result as $arc_row) {
---|