WordPress.org

Make WordPress Core

Ticket #21296: 21296.patch

File 21296.patch, 2.3 KB (added by abaumg, 11 months ago)
  • wp-admin/includes/ajax-actions.php

    function wp_ajax_find_posts() { 
    14401440                wp_die(); 
    14411441 
    14421442        if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) ) 
    1443                 $what = $_POST['post_type']; 
     1443                $what = sprintf("post_type = '%s'", $_POST['post_type']); 
     1444        elseif ($_POST['post_type'] == 'any') 
     1445                $what = '1=1'; 
    14441446        else 
    1445                 $what = 'post'; 
     1447                $what = "post_type = 'post'"; 
    14461448 
    14471449        $s = stripslashes($_POST['ps']); 
    14481450        preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); 
    function wp_ajax_find_posts() { 
    14581460        if ( count($search_terms) > 1 && $search_terms[0] != $s ) 
    14591461                $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; 
    14601462 
    1461         $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" ); 
     1463        $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE $what AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" ); 
    14621464 
    14631465        if ( ! $posts ) { 
    14641466                $posttype = get_post_type_object($what); 
    function wp_ajax_find_posts() { 
    14981500 
    14991501        $x = new WP_Ajax_Response(); 
    15001502        $x->add( array( 
    1501                 'what' => $what, 
     1503                'what' => $_POST['post_type'], 
    15021504                'data' => $html 
    15031505        )); 
    15041506        $x->send(); 
  • wp-admin/includes/template.php

    function find_posts_div($found_action = 
    13131313                                <input type="text" id="find-posts-input" name="ps" value="" /> 
    13141314                                <input type="button" id="find-posts-search" value="<?php esc_attr_e( 'Search' ); ?>" class="button" /><br /> 
    13151315 
     1316                                <input type="radio" name="find-posts-what" id="find-posts-any" value="any" /> 
     1317                                <label for="find-posts-any"><?php _e( 'Any' ); ?></label> 
    13161318                                <?php 
    13171319                                $post_types = get_post_types( array('public' => true), 'objects' ); 
    13181320                                foreach ( $post_types as $post ) {