Ticket #20164: 20164.diff
File 20164.diff, 9.4 KB (added by , 12 years ago) |
---|
-
wp-admin/includes/ajax-actions.php
1422 1422 1423 1423 check_ajax_referer( 'find-posts' ); 1424 1424 1425 if ( empty($_POST['ps']) ) 1426 wp_die(); 1425 $what = get_post_types( array( 'public' => true ) ); 1426 unset( $what['attachment'] ); 1427 $what = "'" . implode( "', '", $what ) . "'"; 1427 1428 1428 if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )1429 $what = $_POST['post_type'];1430 else1431 $what = 'post';1432 1433 1429 $s = stripslashes($_POST['ps']); 1434 1430 preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); 1435 1431 $search_terms = array_map('_search_terms_tidy', $matches[0]); … … 1444 1440 if ( count($search_terms) > 1 && $search_terms[0] != $s ) 1445 1441 $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; 1446 1442 1447 $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" ); 1443 if ( empty($_POST['ps']) ) 1444 $search = ''; 1445 else 1446 $search = 'AND (' . $search . ')'; 1448 1447 1448 $posts = $wpdb->get_results( "SELECT ID, post_title, post_type, post_status, post_date FROM $wpdb->posts WHERE post_type IN ($what) AND post_status IN ('draft', 'publish') $search ORDER BY post_date_gmt DESC LIMIT 50" ); 1449 1449 1450 if ( ! $posts ) { 1450 $posttype = get_post_type_object($what); 1451 wp_die( $posttype->labels->not_found ); 1451 wp_die( __('No items found.') ); 1452 1452 } 1453 1453 1454 $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__(' Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>';1454 $html = '<table class="widefat" cellspacing="0"><thead><tr><th class="found-radio"><br /></th><th>'.__('Title').'</th><th>'.__('Type').'</th><th>'.__('Date').'</th><th>'.__('Status').'</th></tr></thead><tbody>'; 1455 1455 foreach ( $posts as $post ) { 1456 1456 1457 1457 switch ( $post->post_status ) { … … 1478 1478 } 1479 1479 1480 1480 $html .= '<tr class="found-posts"><td class="found-radio"><input type="radio" id="found-'.$post->ID.'" name="found_post_id" value="' . esc_attr($post->ID) . '"></td>'; 1481 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n";1481 $html .= '<td><label for="found-'.$post->ID.'">'.esc_html( $post->post_title ).'</label></td><td>'.esc_html( ucfirst( $post->post_type ) ).'</td><td>'.esc_html( $time ).'</td><td>'.esc_html( $stat ).'</td></tr>'."\n\n"; 1482 1482 } 1483 1483 $html .= '</tbody></table>'; 1484 1484 1485 1485 $x = new WP_Ajax_Response(); 1486 1486 $x->add( array( 1487 'what' => $what,1488 1487 'data' => $html 1489 1488 )); 1490 1489 $x->send(); -
wp-admin/includes/template.php
1278 1278 <?php wp_nonce_field( 'find-posts', '_ajax_nonce', false ); ?> 1279 1279 <label class="screen-reader-text" for="find-posts-input"><?php _e( 'Search' ); ?></label> 1280 1280 <input type="text" id="find-posts-input" name="ps" value="" /> 1281 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 1282 1283 <?php 1284 $post_types = get_post_types( array('public' => true), 'objects' ); 1285 foreach ( $post_types as $post ) { 1286 if ( 'attachment' == $post->name ) 1287 continue; 1288 ?> 1289 <input type="radio" name="find-posts-what" id="find-posts-<?php echo esc_attr($post->name); ?>" value="<?php echo esc_attr($post->name); ?>" <?php checked($post->name, 'post'); ?> /> 1290 <label for="find-posts-<?php echo esc_attr($post->name); ?>"><?php echo $post->label; ?></label> 1291 <?php 1292 } ?> 1281 <span class="spinner"></span> 1282 <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /> 1293 1283 </div> 1294 1284 <div id="find-posts-response"></div> 1295 1285 </div> -
wp-admin/js/media.js
3 3 (function($){ 4 4 findPosts = { 5 5 open : function(af_name, af_val) { 6 var st = document.documentElement.scrollTop || $(document).scrollTop(); 6 var st = document.documentElement.scrollTop || $(document).scrollTop(), 7 overlay = $( '.ui-find-overlay' ); 7 8 9 if ( overlay.length == 0 ) { 10 $( 'body' ).append( '<div class="ui-find-overlay"></div>' ); 11 findPosts.overlay(); 12 } 13 14 overlay.show() 15 8 16 if ( af_name && af_val ) { 9 17 $('#affected').attr('name', af_name).val(af_val); 10 18 } 11 19 $('#find-posts').show().draggable({ 12 20 handle: '#find-posts-head' 13 }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'- 250px'});21 }).css({'top':st + 50 + 'px','left':'50%','marginLeft':'-328px'}); 14 22 15 23 $('#find-posts-input').focus().keyup(function(e){ 16 24 if (e.which == 27) { findPosts.close(); } // close on Escape 17 25 }); 18 26 27 // Pull some results up by default 28 findPosts.send(); 29 19 30 return false; 20 31 }, 21 32 22 33 close : function() { 23 34 $('#find-posts-response').html(''); 24 35 $('#find-posts').draggable('destroy').hide(); 36 $( '.ui-find-overlay' ).hide(); 25 37 }, 26 38 39 overlay : function() { 40 $( '.ui-find-overlay' ).css( 41 { 'z-index': '999', 'width': $( document ).width() + 'px', 'height': $( document ).height() + 'px' } 42 ).on('click', function () { 43 findPosts.close(); 44 }); 45 }, 46 27 47 send : function() { 28 48 var post = { 29 ps: $('#find-posts-input').val(),30 action: 'find_posts',31 _ajax_nonce: $('#_ajax_nonce').val(),32 post_type: $('input[name="find-posts-what"]:checked').val()33 };49 ps: $('#find-posts-input').val(), 50 action: 'find_posts', 51 _ajax_nonce: $('#_ajax_nonce').val() 52 }, 53 spinner = $( '.find-box-search .spinner' ); 34 54 55 spinner.show(); 56 35 57 $.ajax({ 36 58 type : 'POST', 37 59 url : ajaxurl, 38 60 data : post, 39 success : function(x) { findPosts.show(x); },40 error : function(r) { findPosts.error(r); }61 success : function(x) { findPosts.show(x); spinner.hide(); }, 62 error : function(r) { findPosts.error(r); spinner.hide(); } 41 63 }); 42 64 }, 43 65 … … 55 77 } 56 78 r = r.responses[0]; 57 79 $('#find-posts-response').html(r.data); 80 81 // Enable whole row to be clicked 82 $( '.found-posts td' ).on( 'click', function () { 83 $( this ).parent().find( '.found-radio input' ).prop( 'checked', true ); 84 }); 58 85 }, 59 86 60 87 error : function(r) { … … 91 118 }); 92 119 }); 93 120 }); 121 $(window).resize(function() { 122 findPosts.overlay(); 123 }); 94 124 })(jQuery); -
wp-admin/css/colors-fresh.css
21 21 ------------------------------------------------------------------------------*/ 22 22 23 23 .find-box-search { 24 border-color: #dfdfdf; 25 background-color: #f1f1f1; 24 background-color: #f7f7f7; 26 25 } 27 26 28 27 .find-box { 28 background-color: #444; 29 } 30 31 .find-box-buttons { 29 32 background-color: #f1f1f1; 30 33 } 31 34 35 .find-box-head { 36 color: #eee; 37 } 38 32 39 .find-box-inside { 33 40 background-color: #fff; 34 41 } … … 139 146 h3.dashboard-widget-title, 140 147 h3.dashboard-widget-title span, 141 148 h3.dashboard-widget-title small, 142 .find-box-head,143 149 .sidebar-name, 144 150 #nav-menu-header, 145 151 #nav-menu-footer, … … 436 442 .widefat tfoot tr th, 437 443 h3.dashboard-widget-title, 438 444 h3.dashboard-widget-title span, 439 h3.dashboard-widget-title small, 440 .find-box-head { 445 h3.dashboard-widget-title small { 441 446 color: #333; 442 447 } 443 448 -
wp-admin/css/wp-admin.css
4004 4004 ------------------------------------------------------------------------------*/ 4005 4005 4006 4006 .find-box { 4007 width: 500px;4007 width: 600px; 4008 4008 height: 300px; 4009 4009 overflow: hidden; 4010 padding: 33px 5px 40px;4010 padding: 33px 0 51px; 4011 4011 position: absolute; 4012 4012 z-index: 1000; 4013 4013 } … … 4025 4025 4026 4026 .find-box-inside { 4027 4027 overflow: auto; 4028 width: 100%;4028 padding: 6px; 4029 4029 height: 100%; 4030 4030 } 4031 4031 4032 .find-posts-options { 4033 margin-left: 9px; 4034 overflow: hidden; 4035 } 4036 4037 .find-posts-options input { 4038 float: left; 4039 margin: 7px 4px 0 7px; 4040 } 4041 4042 .find-posts-options label { 4043 float: left; 4044 margin-top: 6px; 4045 } 4046 4032 4047 .find-box-search { 4033 padding: 12px;4034 border-width: 1px;4035 border-style: none none solid;4048 overflow: hidden; 4049 padding: 9px; 4050 position: relative; 4036 4051 } 4037 4052 4053 .find-box-search .spinner { 4054 float: none; 4055 left: 126px; 4056 position: absolute; 4057 top: 9px; 4058 } 4059 4060 #find-posts-input { 4061 float: left; 4062 height: 24px; 4063 } 4064 4065 #find-posts-search { 4066 float: left; 4067 margin: 1px 4px 0 3px; 4068 } 4069 4038 4070 #find-posts-response { 4039 4071 margin: 8px 0; 4040 4072 padding: 0 1px; … … 4045 4077 } 4046 4078 4047 4079 #find-posts-response .found-radio { 4048 padding: 5px 0 0 8px;4080 padding: 3px 0 0 8px; 4049 4081 width: 15px; 4050 4082 } 4051 4083 4052 4084 .find-box-buttons { 4053 width: 480px;4054 margin: 8px;4085 padding: 8px; 4086 overflow: hidden; 4055 4087 } 4056 4088 4057 .find-box-search label {4058 padding-right: 6px;4059 }4060 4061 4089 .find-box #resize-se { 4062 4090 position: absolute; 4063 4091 right: 1px; 4064 4092 bottom: 1px; 4065 4093 } 4066 4094 4095 .ui-find-overlay { 4096 position: absolute; 4097 top: 0; 4098 left: 0; 4099 background-color: #000; 4100 opacity: 0.6; 4101 filter: alpha(opacity=60); 4102 } 4103 4067 4104 ul#dismissed-updates { 4068 4105 display: none; 4069 4106 }