1 | Index: wp-includes/post.php |
---|
2 | =================================================================== |
---|
3 | --- wp-includes/post.php (revision 14447) |
---|
4 | +++ wp-includes/post.php (working copy) |
---|
5 | @@ -26,6 +26,7 @@ |
---|
6 | 'hierarchical' => false, |
---|
7 | 'rewrite' => false, |
---|
8 | 'query_var' => false, |
---|
9 | + 'media_add' => true, |
---|
10 | 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions' ), |
---|
11 | ) ); |
---|
12 | |
---|
13 | @@ -40,6 +41,7 @@ |
---|
14 | 'hierarchical' => true, |
---|
15 | 'rewrite' => false, |
---|
16 | 'query_var' => false, |
---|
17 | + 'media_add' => true, |
---|
18 | 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'page-attributes', 'custom-fields', 'comments', 'revisions' ), |
---|
19 | ) ); |
---|
20 | |
---|
21 | @@ -811,7 +813,7 @@ |
---|
22 | $wp_post_types = array(); |
---|
23 | |
---|
24 | // Args prefixed with an underscore are reserved for internal use. |
---|
25 | - $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK, 'can_export' => true ); |
---|
26 | + $defaults = array('label' => false, 'singular_label' => false, 'description' => '', 'publicly_queryable' => null, 'exclude_from_search' => null, '_builtin' => false, '_edit_link' => 'post.php?post=%d', 'capability_type' => 'post', 'hierarchical' => false, 'public' => false, 'rewrite' => true, 'query_var' => true, 'supports' => array(), 'register_meta_box_cb' => null, 'taxonomies' => array(), 'show_ui' => null, 'menu_position' => null, 'menu_icon' => null, 'permalink_epmask' => EP_PERMALINK, 'can_export' => true, 'media_add' => false ); |
---|
27 | $args = wp_parse_args($args, $defaults); |
---|
28 | $args = (object) $args; |
---|
29 | |
---|
30 | Index: wp-admin/admin-ajax.php |
---|
31 | =================================================================== |
---|
32 | --- wp-admin/admin-ajax.php (revision 14447) |
---|
33 | +++ wp-admin/admin-ajax.php (working copy) |
---|
34 | @@ -1253,7 +1253,12 @@ |
---|
35 | if ( empty($_POST['ps']) ) |
---|
36 | exit; |
---|
37 | |
---|
38 | - $what = isset($_POST['pages']) ? 'page' : 'post'; |
---|
39 | + if($wp_post_types[$_POST['post_type']]->media_add === true ) { |
---|
40 | + $what = $_POST['post_type']; |
---|
41 | + } else { |
---|
42 | + $what = 'post'; |
---|
43 | + } |
---|
44 | + |
---|
45 | $s = stripslashes($_POST['ps']); |
---|
46 | preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
---|
47 | $search_terms = array_map('_search_terms_tidy', $matches[0]); |
---|
48 | @@ -1271,7 +1276,7 @@ |
---|
49 | $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" ); |
---|
50 | |
---|
51 | if ( ! $posts ) |
---|
52 | - exit( __('No posts found.') ); |
---|
53 | + exit( __('No '. $what .' found.') ); |
---|
54 | |
---|
55 | $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>'; |
---|
56 | foreach ( $posts as $post ) { |
---|
57 | Index: wp-admin/includes/template.php |
---|
58 | =================================================================== |
---|
59 | --- wp-admin/includes/template.php (revision 14447) |
---|
60 | +++ wp-admin/includes/template.php (working copy) |
---|
61 | @@ -3269,6 +3269,7 @@ |
---|
62 | * @param unknown_type $found_action |
---|
63 | */ |
---|
64 | function find_posts_div($found_action = '') { |
---|
65 | + global $wp_post_types; |
---|
66 | ?> |
---|
67 | <div id="find-posts" class="find-box" style="display:none;"> |
---|
68 | <div id="find-posts-head" class="find-box-head"><?php _e('Find Posts or Pages'); ?></div> |
---|
69 | @@ -3284,10 +3285,18 @@ |
---|
70 | <input type="text" id="find-posts-input" name="ps" value="" /> |
---|
71 | <input type="button" onclick="findPosts.send();" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> |
---|
72 | |
---|
73 | - <input type="radio" name="find-posts-what" id="find-posts-posts" checked="checked" value="posts" /> |
---|
74 | - <label for="find-posts-posts"><?php _e( 'Posts' ); ?></label> |
---|
75 | - <input type="radio" name="find-posts-what" id="find-posts-pages" value="pages" /> |
---|
76 | - <label for="find-posts-pages"><?php _e( 'Pages' ); ?></label> |
---|
77 | + <?php |
---|
78 | + $selected = 'checked="checked" '; |
---|
79 | + foreach ($wp_post_types AS $post) { |
---|
80 | + if($post->media_add === true) { |
---|
81 | + |
---|
82 | + ?> |
---|
83 | + <input type="radio" name="find-posts-what" id="find-posts-<?php echo $post->name; ?>" value="<?php echo $post->name; ?>" <?php echo $selected?>/> |
---|
84 | + <label for="find-posts-<?php echo $post->name; ?>"><?php echo $post->label; ?></label> |
---|
85 | + <?php |
---|
86 | + } |
---|
87 | + $selected = ''; |
---|
88 | + } ?> |
---|
89 | </div> |
---|
90 | <div id="find-posts-response"></div> |
---|
91 | </div> |
---|
92 | Index: wp-admin/js/media.dev.js |
---|
93 | =================================================================== |
---|
94 | --- wp-admin/js/media.dev.js (revision 14447) |
---|
95 | +++ wp-admin/js/media.dev.js (working copy) |
---|
96 | @@ -31,11 +31,10 @@ |
---|
97 | _ajax_nonce: $('#_ajax_nonce').val() |
---|
98 | }; |
---|
99 | |
---|
100 | - if ( $('#find-posts-pages').is(':checked') ) { |
---|
101 | - post['pages'] = 1; |
---|
102 | - } else { |
---|
103 | - post['posts'] = 1; |
---|
104 | - } |
---|
105 | + var selectedItem; |
---|
106 | + $("input[@name='itemSelect[]']:checked").each(function() { selectedItem = $(this).val() }); |
---|
107 | + post['post_type'] = selectedItem; |
---|
108 | + |
---|
109 | $.ajax({ |
---|
110 | type : 'POST', |
---|
111 | url : ajaxurl, |
---|