A member site I manage has a significant amount of protected content that has a private post status and is made available to members of a specific role via use of the capability read_private_posts. I often want to link to these posts but am unable to easily do so because of the following:

The Limitation

A search of existing content within the Insert/edit link modal returns only published posts.

The Solution

// Add private posts to the queried post status argument
function uamv_link_query_private( $query ) {

    $query['post_status'] = array( 'publish', 'private' );

    return $query;

}
add_filter( 'wp_link_query_args', 'uamv_link_query_private', 10, 1 );

// Prepend displayed post type with 'Private: '
function uamv_link_query_private_prepend( $results, $query ) {

    foreach ( $results as $key => $result ) {

        if ( 'private' == get_post_status( $result['ID'] ) ) {

            $results[ $key ]['info'] = 'Private: ' . $results[ $key ]['info'];

        }

    }

    return $results;
}
add_filter('wp_link_query', 'uamv_link_query_private_prepend', 10, 2 );

The wp_link_query_args filter gives control over any arguments passed to the WP_Query class.

The wp_link_query gives control over the following returned results prior to display:

$results = array( 'ID', 'title', 'permalink', 'info' );