Make WordPress Core


Ignore:
Timestamp:
05/25/2010 02:18:07 AM (15 years ago)
Author:
ryan
Message:

Allow searching custom post types when attaching media. Props markoheijnen. fixes #13229

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r14852 r14869  
    12551255        exit;
    12561256
    1257     $what = isset($_POST['pages']) ? 'page' : 'post';
     1257    if ( !empty($_POST['post_type']) && in_array( $_POST['post_type'], get_post_types() ) )
     1258        $what = $_POST['post_type'];
     1259    else
     1260        $what = 'post';
     1261
    12581262    $s = stripslashes($_POST['ps']);
    12591263    preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches);
     
    12721276    $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" );
    12731277
    1274     if ( ! $posts )
    1275         exit( __('No posts found.') );
     1278    if ( ! $posts ) {
     1279        $posttype = get_post_type_object($what);
     1280        exit($posttype->labels->not_found);
     1281    }
    12761282
    12771283    $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>';
Note: See TracChangeset for help on using the changeset viewer.