Index: wp-includes/js/tinymce/plugins/wplink/editor_plugin.js
===================================================================
--- wp-includes/js/tinymce/plugins/wplink/editor_plugin.js	(revision 0)
+++ wp-includes/js/tinymce/plugins/wplink/editor_plugin.js	(revision 0)
@@ -0,0 +1 @@
+(function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){a.addCommand("WP_Link",function(){a.windowManager.open({file:tinymce.baseURL+"/wp-mce-link.php",width:320,height:340,inline:1},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(d,c,e){c.setActive("wplink",e.nodeName=="A")})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();
\ No newline at end of file
Index: wp-includes/js/tinymce/plugins/wplink/js/wplink.js
===================================================================
--- wp-includes/js/tinymce/plugins/wplink/js/wplink.js	(revision 0)
+++ wp-includes/js/tinymce/plugins/wplink/js/wplink.js	(revision 0)
@@ -0,0 +1,296 @@
+(function($){
+	$.widget('wp.wpTabs', {
+		options: {},
+		_create: function() {
+			var self = this,
+				ul = this.element,
+				lis = ul.children();
+			
+			this.active = lis.filter('.wp-tab-active');
+			// Calculate panel IDs
+			lis.each(function() {
+				var panel = self._getPanel( $(this) );
+				if ( self.active[0] == this )
+					panel.show();
+				else
+					panel.hide();
+			});
+			
+			ul.delegate('li', 'click.wpTabs', function(e) {
+				var li = $(this);
+				
+				// Prevent any child link from redirecting the page.
+				e.preventDefault();
+				// Deactivate previous tab.
+				self._getPanel( self.active ).hide();
+				self.active.removeClass('wp-tab-active');
+				self._trigger("hide", e, self.widget() );
+				
+				// Activate current tab.
+				self.active = li.addClass('wp-tab-active');
+				self._getPanel( self.active ).show();
+				self._trigger("show", e, self.widget() );
+			});
+		},
+		widget: function() {
+			return {
+				ul: this.element,
+				tab: this.active,
+				panel: this._getPanel( this.active )
+			};
+		},
+		_setPanel: function( $el ) {
+			var panel = $( '#' + $el.children('.wp-tab-for-id').val() );
+			$el.data( 'wp-tab-panel', panel );
+			return panel;
+		},
+		_getPanel: function( $el ) {
+			var panel = $el.data('wp-tab-panel');
+			return ( !panel || !panel.length ) ? this._setPanel( $el ) : panel;
+		}
+	});
+	// Create tab bars by default.
+	$(function(){
+		$('.wp-tab-bar').wpTabs();
+	});
+})(jQuery);
+
+(function($){	
+	var inputs = {}, panels, active, ed,
+	wpLink = {
+		init : function() {
+			var e, etarget, eclass;
+			// Init shared vars
+			ed = tinyMCEPopup.editor;
+			// Secondary options
+			inputs.title = $('#link-title-field');
+			// Advanced Options
+			inputs.openInNewTab = $('#link-target-checkbox');
+			// Types
+			inputs.typeDropdown = $('#link-type');
+			inputs.typeOptions = inputs.typeDropdown.find('option');
+			
+			panels = $('.link-panel');
+			active = $('.link-panel-active');
+			
+			// Extract type names
+			inputs.typeOptions.each( function(){
+				var linkType = this.id.replace(/^link-option-id-/,''),
+					parts = linkType.split('-');
+				$(this).data( 'link-type', {
+					full : linkType,
+					type : parts[0],
+					name : parts[1] || ''
+				});
+			});
+			panels.each( function(){
+				var linkType = this.id.replace(/^link-panel-id-/,''),
+					parts = linkType.split('-');
+				$(this).data( 'link-type', {
+					full : linkType,
+					type : parts[0],
+					name : parts[1] || ''
+				});
+			});
+			
+			// Bind event handlers
+			inputs.typeDropdown.change( wpLink.selectPanel );
+			$('#wp-update').click( wpLink.update );
+			$('#wp-cancel').click( function() { tinyMCEPopup.close(); } );
+			$('.link-panel .wp-tab-bar').wpTabs('option', 'show', wpLink.maybeLoadPanel );
+			$('.link-panel .wp-tab-panel').delegate('li', 'click', wpLink.selectInternalLink );
+			$('.wp-tab-panel-pagelinks').delegate('a', 'click', wpLink.selectPageLink );
+			$('.link-panel .link-search-field').keyup( wpLink.searchInternalLinks );
+			
+			// If link exists, select proper values.
+			e = ed.dom.getParent(ed.selection.getNode(), 'A');
+			if ( ! e )
+				return;
+			
+			// @TODO: select proper panel/fill values when a link is edited
+			active.find('input.url-field').val( e.href );
+			inputs.title.val( ed.dom.getAttrib(e, 'title') );
+			// Advanced Options
+			
+			if ( "_blank" == ed.dom.getAttrib(e, 'target') )
+				inputs.openInNewTab.attr('checked','checked');
+		},
+		
+		update : function() {
+			var el,
+				ed = tinyMCEPopup.editor,
+				attrs = {
+					title : inputs.title.val(),
+					target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
+				}, defaultContent, e, b;
+			
+			if ( active.hasClass('link-panel-custom') ) {
+				attrs.href = active.find('input.url-field').val();
+				defaultContent = attrs.href;
+			} else {
+				el = active.find('li.selected:visible');
+				if ( !el.length )
+					return;
+				
+				attrs.href = el.children('input').val();
+				defaultContent = el.text();
+			}
+			
+			tinyMCEPopup.restoreSelection();
+			e = ed.dom.getParent(ed.selection.getNode(), 'A');
+			
+			// If the values are empty...
+			if ( ! attrs.href ) {
+				// ...and nothing is selected, we should return
+				if ( ed.selection.isCollapsed() ) {
+					tinyMCEPopup.close();
+					return;
+				// ...and a link exists, we should unlink and return
+				} else if ( e ) {
+					tinyMCEPopup.execCommand("mceBeginUndoLevel");
+					b = ed.selection.getBookmark();
+					ed.dom.remove(e, 1);
+					ed.selection.moveToBookmark(b);
+					tinyMCEPopup.execCommand("mceEndUndoLevel");
+					tinyMCEPopup.close();
+					return;
+				}
+			}
+			
+			tinyMCEPopup.execCommand("mceBeginUndoLevel");
+
+			if (e == null) {
+				ed.getDoc().execCommand("unlink", false, null);
+				
+				// If no selection exists, create a new link from scratch.
+				if ( ed.selection.isCollapsed() ) {
+					var el = ed.dom.create('a', { href: "#mce_temp_url#" }, defaultContent);
+					ed.selection.setNode(el);
+				// If a selection exists, wrap it in a link.
+				} else {
+					tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1});
+				}
+
+				tinymce.each(ed.dom.select("a"), function(n) {
+					if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') {
+						e = n;
+						ed.dom.setAttribs(e, attrs);
+					}
+				});
+			} else {
+				ed.dom.setAttribs(e, attrs);
+			}
+
+			// Don't move caret if selection was image
+			if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') {
+				ed.focus();
+				ed.selection.select(e);
+				ed.selection.collapse(0);
+				tinyMCEPopup.storeSelection();
+			}
+
+			tinyMCEPopup.execCommand("mceEndUndoLevel");
+			tinyMCEPopup.close();
+		},
+		
+		selectPanel : function( option ) {
+			var sel = inputs.typeOptions.filter(':selected');
+			
+			if ( option.jquery ) {
+				sel.removeAttr('selected');
+				sel = option.attr('selected', 'selected');
+			}
+			
+			active.removeClass('link-panel-active');
+			active = $('#link-panel-id-' + sel.data('link-type').full ).addClass('link-panel-active');
+			wpLink.maybeLoadPanel();
+		},
+		
+		maybeLoadPanel : function() {
+			var panel = active.find('.wp-tab-panel:visible');
+			if ( panel.length && panel.find('.wp-tab-panel-loading').length )
+				wpLink.linkPanelAJAX( panel );
+		},
+		
+		linkPanelAJAX : function( $panel, params, callback ) {
+			if ( ! $panel.hasClass('wp-tab-panel') )
+				$panel = $panel.parents('.wp-tab-panel');
+			
+			if ( ! $panel.length )
+				return;
+				
+			var query = $panel.children('.wp-tab-panel-query').val();
+			
+			wpLink.linkAJAX( $panel, $.extend({
+				preset : query,
+				page : 'all' == query ? 1 : 0
+			}, params), function(r, lt) {
+				var pagelinks = $panel.children('.wp-tab-panel-pagelinks');
+				
+				// Set results
+				$panel.children('ul').html( wpLink.generateListMarkup( r['results'], lt ) );
+				
+				// Handle page links
+				if ( r['page_links'] )
+					pagelinks.html( r['page_links'] ).show();
+				else
+					pagelinks.hide();
+				// Run callback
+				if ( callback )
+					callback(r, lt);
+			})
+		},
+		
+		selectInternalLink : function() {
+			var t = $(this);
+			if ( t.hasClass('unselectable') )
+				return;
+			t.siblings('.selected').removeClass('selected');
+			t.addClass('selected');
+		},
+		
+		selectPageLink : function(e) {
+			var page = e.target.href.match(/page=(\d+)/);
+			
+			page = page ? page[1] : 1; // If there's no match, it's the first page.
+			e.preventDefault(); // Prevent the link from redirecting.
+			
+			wpLink.linkPanelAJAX( $(this), { page : page });
+		},
+		
+		searchInternalLinks : function() {
+			var t = $(this),
+				waiting = t.siblings('img.waiting').show();
+				
+			wpLink.linkPanelAJAX( t, { title : t.val() }, function(){ waiting.hide(); });
+		},
+		
+		linkAJAX : function( el, params, callback ) {
+			var linkType = el.parents('.link-panel').data('link-type');
+			$.post( ajaxurl, $.extend({
+				action : 'wp-link-ajax',
+				type : linkType.type,
+				name : linkType.name
+			}, params ), function(r) {
+				return callback(r, linkType); 
+			}, "json" );
+		},
+		
+		generateListMarkup : function( results, linkType ) {
+			var s = '';
+			
+			if ( ! results )
+				return '<li class="no-matches-found unselectable"><em>' + wpLinkL10n.noMatchesFound + '</em></li>';
+			
+			$.each( results, function() {
+				s+= '<li id="link-to-' + linkType.full + '-' + this['ID'] + '">';
+				s+= '<input type="hidden" value="' + this['permalink'] + '" />';
+				s+= this['title'] ? this['title'] : '<em>'+ wpLinkL10n.untitled + '</em>';
+				s+= '</li>';
+			});
+			return s;
+		}
+	}
+	
+	$(document).ready( wpLink.init );
+})(jQuery);
\ No newline at end of file
Index: wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js
===================================================================
--- wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js	(revision 0)
+++ wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js	(revision 0)
@@ -0,0 +1,56 @@
+(function() {
+	tinymce.create('tinymce.plugins.wpLink', {
+		/**
+		 * Initializes the plugin, this will be executed after the plugin has been created.
+		 * This call is done before the editor instance has finished it's initialization so use the onInit event
+		 * of the editor instance to intercept that event.
+		 *
+		 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in.
+		 * @param {string} url Absolute URL to where the plugin is located.
+		 */
+		init : function(ed, url) {
+			// Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample');
+			ed.addCommand('WP_Link', function() {
+				ed.windowManager.open({
+					file : tinymce.baseURL + '/wp-mce-link.php',
+					width : 320,
+					height : 340,
+					inline : 1
+				}, {
+					plugin_url : url // Plugin absolute URL
+				});
+			});
+
+			// Register example button
+			ed.addButton('link', {
+				title : ed.getLang('advanced.link_desc'),
+				cmd : 'WP_Link'
+			});
+			
+			ed.addShortcut('alt+shift+a', ed.getLang('advanced.link_desc'), 'WP_Link');
+
+			// Add a node change handler, selects the button in the UI when a link is selected
+			ed.onNodeChange.add(function(ed, cm, n) {
+				cm.setActive('wplink', n.nodeName == 'A');
+			});
+		},
+		/**
+		 * Returns information about the plugin as a name/value array.
+		 * The current keys are longname, author, authorurl, infourl and version.
+		 *
+		 * @return {Object} Name/value array containing information about the plugin.
+		 */
+		getInfo : function() {
+			return {
+				longname : 'WordPress Link Dialog',
+				author : 'WordPress',
+				authorurl : 'http://wordpress.org',
+				infourl : '',
+				version : "1.0"
+			};
+		}
+	});
+
+	// Register plugin
+	tinymce.PluginManager.add('wplink', tinymce.plugins.wpLink);
+})();
\ No newline at end of file
Index: wp-includes/js/tinymce/wp-mce-link.php
===================================================================
--- wp-includes/js/tinymce/wp-mce-link.php	(revision 0)
+++ wp-includes/js/tinymce/wp-mce-link.php	(revision 0)
@@ -0,0 +1,201 @@
+<?php
+include 'wp-mce-link-includes.php';
+header('Content-Type: text/html; charset=' . get_bloginfo('charset'));
+?>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
+<head>
+<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
+<title><?php _e('Insert/edit link') ?></title>
+<script type="text/javascript">
+//<![CDATA[
+var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>',
+	wpLinkL10n = {
+		untitled : '<?php _e('Untitled'); ?>',
+		noMatchesFound : '<?php _e('No matches found.'); ?>'
+	};
+//]]>
+</script>
+<script type="text/javascript" src="tiny_mce_popup.js?ver=3223"></script>
+<?php
+wp_print_scripts( array('jquery', 'jquery-ui-widget') );
+?>
+<script type="text/javascript" src="plugins/wplink/js/wplink.js?ver=1.0"></script>
+<?php
+wp_admin_css( 'global', true );
+wp_admin_css( 'wp-admin', true );
+wp_admin_css( 'colors-fresh', true );
+?>
+<style>
+html, body {
+	background: #f1f1f1;
+}
+
+a:link, a:visited {
+	color: #21759B;
+}
+
+select {
+	height: 2em;
+}
+
+#link-header,
+#link-options,
+#link-advanced-options {
+	padding: 5px;
+	border-bottom: 1px solid #dfdfdf;
+}
+#link-type {
+	width: 140px;
+}
+
+.link-panel {
+	padding: 5px 5px 0;
+	display: none;
+}
+	.link-panel-active {
+		display: block;
+	}
+
+label input[type="text"] {
+	width: 220px;
+}
+	.wp-tab-panel label input[type="text"] {
+		float: left;
+		width: 200px;
+	}
+
+label span {
+	display: inline-block;
+	width: 80px;
+	text-align: right;
+	padding-right: 5px;
+}
+	.wp-tab-panel label span {
+		width: auto;
+		text-align: left;
+		float: left;
+		margin-top: 3px;
+	}
+	.link-search-wrapper {
+		padding: 5px;
+		border-bottom: solid 1px #dfdfdf;
+		display: block;
+		overflow: hidden;
+	}
+		.link-search-wrapper img.waiting {
+			margin: 4px 1px 0 4px;
+			float: left;
+			display: none;
+		}
+
+#open-in-new-tab {
+	padding-left: 87px;
+}
+	#open-in-new-tab span {
+		width: auto;
+		margin-left: 10px;
+		font-size: 11px;
+	}
+
+.submitbox {
+	padding: 5px;
+	font-size: 11px;
+	overflow: auto;
+	height: 29px;
+}
+#wp-cancel {
+	line-height: 25px;
+	float: left;
+}
+#wp-update {
+	line-height: 23px;
+	float: right;
+}
+#wp-update a {
+	display: inline-block;
+}
+.wp-tab-active,
+.wp-tab-panel {
+	background: #fff;
+}
+	.wp-tab-panel {
+		height: 160px;
+		padding: 0;
+	}
+.wp-tab-panel li {
+	margin-bottom: 0;
+	border-bottom: 1px solid #dfdfdf;
+	color: #555;
+	padding: 4px 6px;
+	cursor: pointer;
+}
+	.wp-tab-panel li:hover {
+		background: #EAF2FA;
+		color: #333;
+	}
+	.wp-tab-panel li.selected {
+		background: #f1f1f1;
+		font-weight: bold;
+		color: #333;
+	}
+.wp-tab-panel-pagelinks {
+	display: none;
+	padding:4px 0;
+	margin:0 auto;
+	text-align:center;
+}
+	.wp-tab-panel-pagelinks-top {
+		border-bottom: 1px solid #dfdfdf;
+	}
+</style>
+</head>
+<?php
+
+$pts = get_post_types( array( 'public' => true ), 'objects' );
+$queries = array(
+	array( 'preset' => 'all', 'label' => __('View All') ),
+	array( 'preset' => 'recent', 'label' => __('Most Recent') ),
+	array( 'preset' => 'search', 'label' => __('Search') )
+);
+
+?>
+<body id="post-body">
+<div id="link-header">
+	<label for="link-type">
+		<span><strong><?php _e('Link Type:'); ?></strong>
+		</span><select id="link-type">
+			<option id="link-option-id-custom" class="link-custom"><?php _e('External Link'); ?></option>
+		<?php
+		foreach ( $pts as $pt ) {
+			echo "<option id='link-option-id-pt-$pt->name' class='link-option-pt'>";
+			echo $pt->labels->singular_name . '</option>';
+		} ?>
+		</select>
+	</label>
+</div>
+<div id="link-selector">
+	<?php
+	wp_link_panel_custom();
+	foreach( $pts as $pt )
+		wp_link_panel_structure('pt', $pt->name, $queries);
+	?>
+	<div id="link-options">
+		<label for="link-title-field">
+			<span><?php _e('Description:'); ?></span><input id="link-title-field" type="text" />
+		</label>
+		<label for="link-target-checkbox" id="open-in-new-tab">
+			<input type="checkbox" id="link-target-checkbox" /><span><?php _e('Open in new tab'); ?></span>
+		</label>
+	</div>
+</div>
+<div class="submitbox">
+	<div id="wp-cancel">
+		<a class="submitdelete deletion"><?php _e('Cancel'); ?></a>
+	</div>
+	<div id="wp-update">
+		<a class="button-primary"><?php _e('Update'); ?></a>
+	</div>
+</div>
+</body>
+</html>
Index: wp-includes/js/tinymce/wp-mce-link-includes.php
===================================================================
--- wp-includes/js/tinymce/wp-mce-link-includes.php	(revision 0)
+++ wp-includes/js/tinymce/wp-mce-link-includes.php	(revision 0)
@@ -0,0 +1,214 @@
+<?php
+/** @ignore */
+if ( ! defined('ABSPATH') )
+	require_once('../../../wp-load.php');
+	
+
+class WP_Tab_Bar {
+	var $tabs = array();
+	
+	var $selected = '';
+	
+	function add( $id, $label, $url='' ) {
+		array_push( $this->tabs, array(
+			'label' => $label,
+			'for' => $id,
+			'url' => $url
+		));
+	}
+	
+	function select( $id ) {
+		$this->selected = $id;
+	}
+	
+	function render( $echo=true ) {
+		if ( empty( $this->selected ) )
+			$this->selected = $this->tabs[0]['for'];
+
+		$out = "<ul class='wp-tab-bar'>";
+		foreach( $this->tabs as $tab ) {
+			if ( !isset($tab['url']) )
+				$tab['url'] = '';
+
+			$out.= "<li class='";
+			$out.= $this->selected == $tab['for'] ? 'wp-tab-active' : '';
+			$out.= "'><input type='hidden' class='wp-tab-for-id' value='{$tab['for']}' />";
+			$out.= "<a href='{$tab['url']}#{$tab['for']}'>";
+			$out.= "{$tab['label']}</a></li>";
+		}
+		$out.= "</ul>";
+
+		if ( $echo )
+			echo $out;
+
+		return $out;
+	}
+}
+
+function wp_link_panel_custom() { ?>
+	<div id="link-panel-id-custom" class="link-panel link-panel-custom link-panel-active">
+		<input type="hidden" class="link-panel-type" value="custom" />
+		<label>
+			<span><?php _e('URL:'); ?></span><input class="url-field" type="text" />
+		</label>
+	</div>
+<?php }
+
+function wp_link_panel_structure( $panel_type, $name, $queries ) {
+	$id = $panel_type . '-' . $name;
+	
+	?>
+	<div id="link-panel-id-<?php echo $id; ?>" class="link-panel link-panel-<?php echo $panel_type; ?>">
+		<!-- <input type="hidden" class="link-panel-type" value="<?php echo $panel_type; ?>" /> -->
+		<!-- <input type="hidden" class="link-panel-id" value="" /> -->
+		<?php
+		
+		$tb = new WP_Tab_Bar();
+		foreach( $queries as $i => $query ) {
+			$queries[$i]['id'] = "$id-{$query['preset']}";
+			$tb->add( $queries[$i]['id'], $query['label'] );
+		}
+		$tb->render();
+
+		foreach( $queries as $query ): ?>
+			<div id="<?php echo $query['id']; ?>" class="wp-tab-panel">
+				<input type="hidden" class="wp-tab-panel-query" value="<?php echo $query['preset']; ?>" />
+				
+			<?php if ( 'search' == $query['preset'] ): ?>
+				<label for="<?php echo $id; ?>-search-field" class="link-search-wrapper">
+					<span><?php _e('Search:'); ?></span>
+					<input type="text" id="<?php echo $id; ?>-search-field" class="link-search-field" />
+					<img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" />
+				</label>
+				<ul id="<?php echo $id; ?>-search-results" class="link-search-results"></ul>
+				
+			<?php else: ?>
+				<div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-top"></div>
+				<ul>
+					<li class="wp-tab-panel-loading unselectable"><em><?php _e('Loading...'); ?></em></li>
+				</ul>
+				<div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-bottom"></div>
+			<?php endif; ?>
+			</div>
+		<?php endforeach; ?>
+	</div>
+<?php }
+
+function wp_link_query_post_type( $pt_obj, $preset='all', $opts=array() ) {
+	$args_base = array(
+		'post_type' => $pt_obj->name,
+		'suppress_filters' => true,
+		'update_post_term_cache' => false,
+		'update_post_meta_cache' => false,
+		'post_status' => 'publish',
+	);
+	
+	switch( $preset ) {
+	case 'all':
+		$args = array_merge( $args_base, array(
+			'order' => 'ASC',
+			'orderby' => 'title',
+			'posts_per_page' => 20,
+		));
+		break;
+	case 'recent':
+		$args = array_merge( $args_base, array(
+			'order' => 'DESC',
+			'orderby' => 'post_date',
+			'posts_per_page' => 15,
+		));
+		break;
+	case 'search':
+		$args = array_merge( $args_base, array(
+			's' => isset($opts['search']) ? $opts['search'] : '',
+			'posts_per_page' => 10
+		));
+		break;
+	}
+	
+	// Handle pages if a page number is specified.
+	if ( isset( $opts['pagenum'] ) && isset( $args['posts_per_page'] ) ) {
+		$pages = array(
+			'current' => $opts['pagenum'],
+			'per_page' => $args['posts_per_page']
+		);
+		
+		if ( ! isset( $args['offset'] ) )
+			$args['offset'] = 0 < $opts['pagenum'] ? $args['posts_per_page'] * ( $opts['pagenum'] - 1 ) : 0;
+		$pages['offset'] = $args['offset'];
+	}
+	
+	// Allow args to be extended.
+	if ( isset( $opts['args'] ) )
+		$args = array_merge( $args, $opts['args'] );
+	
+	// Do main query.
+	$get_posts = new WP_Query;
+	$posts = $get_posts->query( $args );
+	// Check if any posts were found.
+	if ( ! $get_posts->post_count )
+		return false;
+	
+	// Build results.
+	$results = array();
+	foreach ( $posts as $post ) {
+		$results[] = array(
+			'ID' => $post->ID,
+			'title' => $post->post_title,
+			'permalink' => get_permalink( $post->ID )
+		);
+	}
+	// Build response.
+	$resp = array(
+		'query' => $get_posts,
+		'objects' => $posts,
+		'results' => $results
+	);
+	
+	// Set remaining pages values.
+	if ( isset( $pages ) ) {
+		$pages['max'] = $resp['query']->max_num_pages;
+		$pages['page_links'] = paginate_links( array(
+			'prev_text' => __('&laquo;'),
+			'next_text' => __('&raquo;'),
+			'total' => $pages['max'],
+			'current' => $pages['current']
+		));
+		$resp['pages'] = $pages;
+	}
+	
+	return $resp;
+}
+
+function wp_link_ajax( $request ) {
+	if ( !isset($request['type']) || !isset($request['name']) || !isset($request['preset']) )
+		die('-1');
+
+	// Run only presets we recognize.
+	if ( 'pt' != $request['type'] || ! in_array( $request['preset'], array('all','search','recent') ) )
+		die('-1');
+	// Searches must have a search term.
+	else if ( 'search' == $request['preset'] && !isset($request['title']) )
+		die('-1');
+
+	$opts = array();
+	if ( 'search' == $request['preset'] ) {
+		$opts['search'] = $request['title'];
+	} else if ( ! empty( $request['page'] ) ) {
+		$opts['pagenum'] = $request['page'];
+	}
+		
+	if ( 'pt' == $request['type'] && $obj = get_post_type_object($request['name']) )
+		$resp = wp_link_query_post_type( $obj, $request['preset'], $opts );
+
+	if ( ! isset( $resp ) )
+		die('0');
+
+	$json = array( 'results' => $resp['results'] );
+	if ( isset( $resp['pages'] ) && !empty( $resp['pages']['page_links'] ) )
+		$json['page_links'] = $resp['pages']['page_links'];
+	
+	echo json_encode( $json );
+	echo "\n";
+}
+?>
\ No newline at end of file
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 15876)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -1102,6 +1102,13 @@
 
 	exit;
 	break;
+case 'wp-link-ajax':
+	require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link-includes.php';
+
+	wp_link_ajax( $_REQUEST );
+	
+	exit;
+	break;
 case 'menu-locations-save':
 	if ( ! current_user_can( 'edit_theme_options' ) )
 		die('-1');
Index: wp-admin/includes/post.php
===================================================================
--- wp-admin/includes/post.php	(revision 15876)
+++ wp-admin/includes/post.php	(working copy)
@@ -1311,10 +1311,10 @@
 	$mce_spellchecker_languages = apply_filters('mce_spellchecker_languages', '+English=en,Danish=da,Dutch=nl,Finnish=fi,French=fr,German=de,Italian=it,Polish=pl,Portuguese=pt,Spanish=es,Swedish=sv');
 
 	if ( $teeny ) {
-		$plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'media', 'fullscreen', 'wordpress') );
+		$plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'media', 'fullscreen', 'wordpress', 'wplink') );
 		$ext_plugins = '';
 	} else {
-		$plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus' );
+		$plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink' );
 
 		/*
 		The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'.
Index: wp-admin/css/colors-fresh.dev.css
===================================================================
--- wp-admin/css/colors-fresh.dev.css	(revision 15876)
+++ wp-admin/css/colors-fresh.dev.css	(working copy)
@@ -110,13 +110,16 @@
 }
 
 div.tabs-panel,
+.wp-tab-panel,
 ul.category-tabs li.tabs,
-ul.add-menu-item-tabs li.tabs {
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
 	border-color: #dfdfdf;
 }
 
 ul.category-tabs li.tabs,
-ul.add-menu-item-tabs li.tabs {
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
 	background-color: #f1f1f1;
 }
 
@@ -382,7 +385,8 @@
 }
 
 #side-sortables .category-tabs .tabs a,
-#side-sortables .add-menu-item-tabs .tabs a {
+#side-sortables .add-menu-item-tabs .tabs a,
+.wp-tab-bar .wp-tab-active a {
 	color: #333;
 }
 
Index: wp-admin/css/wp-admin.dev.css
===================================================================
--- wp-admin/css/wp-admin.dev.css	(revision 15876)
+++ wp-admin/css/wp-admin.dev.css	(working copy)
@@ -2029,6 +2029,7 @@
 	text-decoration: none;
 }
 
+.wp-tab-panel,
 .categorydiv div.tabs-panel,
 .customlinkdiv div.tabs-panel,
 .posttypediv div.tabs-panel,
@@ -2063,17 +2064,20 @@
 }
 
 #side-sortables .category-tabs li,
-#side-sortables .add-menu-item-tabs li {
+#side-sortables .add-menu-item-tabs li,
+.wp-tab-bar li {
 	display: inline;
 }
 
 #side-sortables .category-tabs a,
-#side-sortables .add-menu-item-tabs a {
+#side-sortables .add-menu-item-tabs a,
+.wp-tab-bar a {
 	text-decoration: none;
 }
 
 #side-sortables .category-tabs,
-#side-sortables .add-menu-item-tabs {
+#side-sortables .add-menu-item-tabs,
+.wp-tab-bar {
 	margin-bottom: 3px;
 }
 
@@ -2110,21 +2114,15 @@
 	margin-bottom: 0px;
 }
 
-.categorydiv .tabs-panel,
-.customlinkdiv .tabs-panel,
-.posttypediv .tabs-panel,
-.taxonomydiv .tabs-panel {
-	border-width: 3px;
-	border-style: solid;
-}
-
 ul.category-tabs,
-ul.add-menu-item-tabs {
+ul.add-menu-item-tabs,
+ul.wp-tab-bar {
 	margin-top: 12px;
 }
 
 ul.category-tabs li.tabs,
-ul.add-menu-item-tabs li.tabs {
+ul.add-menu-item-tabs li.tabs,
+.wp-tab-active {
 	border-style: solid solid none;
 	border-width: 1px 1px 0;
 }
@@ -2137,7 +2135,8 @@
 }
 
 ul.category-tabs li,
-ul.add-menu-item-tabs li {
+ul.add-menu-item-tabs li,
+ul.wp-tab-bar li {
 	padding: 5px;
 	-moz-border-radius: 3px 3px 0 0;
 	-webkit-border-top-left-radius: 3px;
