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,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 : 380,
+					inline : 1
+				}, {
+					plugin_url : url // Plugin absolute URL
+				});
+			});
+
+			// Register example button
+			ed.addButton('wplink', {
+				title : ed.getLang('wplink.link_desc'),
+				cmd : 'WP_Link'
+			});
+			
+			ed.addShortcut('alt+shift+a', ed.getLang('wplink.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/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,287 @@
+// WPTABS
+(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');
+				// Activate current tab.
+				self.active = li.addClass('wp-tab-active');
+				self._getPanel( self.active ).show();
+			});
+		},
+		_setPanel: function( $el ) {
+			var panel = $( '#' + $el[0].id.replace('wp-tab-for-','') );
+			$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.advancedOptions = $('#link-advanced-options');
+			inputs.target = $('#link-target-select');
+			inputs['class'] = $('#link-class-select');
+			// Types
+			inputs.typeDropdown = $('#link-type');
+			inputs.typeOptions = inputs.typeDropdown.find('option');
+			
+			panels = $('.link-panel');
+			active = $('.link-panel-active');
+			
+			// Build lists
+			wpLink.fillClassList('link-class-select');
+			wpLink.fillTargetList('link-target-select');
+			
+			// 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-advanced-options-toggle').click( wpLink.toggleAdvancedOptions );
+			$('.link-panel .wp-tab-panel').delegate('li', 'click', wpLink.selectInternalLink );
+			$('.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
+			inputs.target.val( etarget = ed.dom.getAttrib(e, 'target') );
+			inputs['class'].val( eclass = ed.dom.getAttrib(e, 'class') );
+			if ( etarget || eclass ) // Open the adv. options if one is set.
+				inputs.advancedOptions.toggleClass('adv-options-active');
+		},
+		
+		update : function() {
+			var el,
+				ed = tinyMCEPopup.editor,
+				attrs = {
+					title : inputs.title.val(),
+					target : inputs.target.val(),
+					'class' : inputs['class'].val()
+				}, 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');
+		},
+		
+		toggleAdvancedOptions : function() {
+			inputs.advancedOptions.toggleClass('adv-options-active');
+			return false;
+		},
+		
+		selectInternalLink : function() {
+			$(this).siblings('.selected').removeClass('selected');
+			$(this).addClass('selected');
+		},
+		
+		searchInternalLinks : function() {
+			var t = $(this),
+				linkType = t.parents('.link-panel').data('link-type'),
+				waiting = t.siblings('img.waiting').show();
+			$.post( ajaxurl, {
+				action : 'wp-link-search',
+				type : linkType.type,
+				name : linkType.name,
+				title : t.val()
+			}, function(r) {
+				var s = '';
+				$.each( r, function() {
+					s+= '<li id="link-to-' + linkType.full + '-' + this['ID'] + '">';
+					s+= '<input type="hidden" value="' + this['permalink'] + '" />';
+					s+= this['title'] + '</li>';
+				});
+				
+				t.parent().siblings('ul').html( s );
+				waiting.hide();
+			}, "json");
+		},
+		
+		/**
+		 * Taken from themes/advanced/js/link.js
+		 */
+		fillClassList : function(id) {
+			var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl;
+
+			if (v = tinyMCEPopup.getParam('theme_advanced_styles')) {
+				cl = [];
+
+				tinymce.each(v.split(';'), function(v) {
+					var p = v.split('=');
+
+					cl.push({'title' : p[0], 'class' : p[1]});
+				});
+			} else
+				cl = tinyMCEPopup.editor.dom.getClasses();
+
+			if (cl.length > 0) {
+				lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
+
+				tinymce.each(cl, function(o) {
+					lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']);
+				});
+			} else
+				dom.remove(dom.getParent(id, 'tr'));
+		},
+
+		/**
+		 * Taken from themes/advanced/js/link.js
+		 */
+		fillTargetList : function(id) {
+			var dom = tinyMCEPopup.dom, lst = dom.get(id), v;
+
+			lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), '');
+			lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self');
+			lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank');
+
+			if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) {
+				tinymce.each(v.split(','), function(v) {
+					v = v.split('=');
+					lst.options[lst.options.length] = new Option(v[0], v[1]);
+				});
+			}
+		}
+	}
+	
+	$(document).ready( wpLink.init );
+})(jQuery);
\ No newline at end of file
Index: wp-includes/js/tinymce/langs/wp-langs-en.js
===================================================================
--- wp-includes/js/tinymce/langs/wp-langs-en.js	(revision 15788)
+++ wp-includes/js/tinymce/langs/wp-langs-en.js	(working copy)
@@ -429,3 +429,8 @@
 caption:"Edit Image Caption",
 alt:"Edit Alternate Text"
 });
+
+tinyMCE.addI18n("en.wplink",{
+link_desc:"Insert/edit link",
+unlink_desc:"Unlink (Alt+Shift+S)"
+});
Index: wp-includes/js/tinymce/langs/wp-langs.php
===================================================================
--- wp-includes/js/tinymce/langs/wp-langs.php	(revision 15788)
+++ wp-includes/js/tinymce/langs/wp-langs.php	(working copy)
@@ -452,4 +452,9 @@
 caption:"' . mce_escape( __('Edit Image Caption') ) . '",
 alt:"' . mce_escape( __('Edit Alternate Text') ) . '"
 });
+
+tinyMCE.addI18n("' . $language . '.wplink",{
+link_desc:"' . mce_escape( __('Insert/edit link') ) . '",
+unlink_desc:"' . mce_escape( __('Unlink') ) . ' (Alt+Shift+S)"
+});
 ';
Index: wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css
===================================================================
--- wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css	(revision 15788)
+++ wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css	(working copy)
@@ -274,7 +274,8 @@
 .wp_themeSkin span.mce_anchor {background-position:-200px 0}
 .wp_themeSkin span.mce_indent {background-position:-400px 0}
 .wp_themeSkin span.mce_outdent {background-position:-540px 0}
-.wp_themeSkin span.mce_link {background-position:-500px 0}
+.wp_themeSkin span.mce_link,
+.wp_themeSkin span.mce_wplink {background-position:-500px 0}
 .wp_themeSkin span.mce_unlink {background-position:-640px 0}
 .wp_themeSkin span.mce_sub {background-position:-600px 0}
 .wp_themeSkin span.mce_sup {background-position:-620px 0}
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,231 @@
+<?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'); ?>';
+//]]>
+</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;
+		}
+
+#link-advanced-options,
+#link-advanced-options select,
+#link-advanced-options option {
+	font-size: 11px;
+}
+
+#link-advanced-options {
+	background: #f9f9f9;
+	padding: 3px 5px;
+}
+	#link-advanced-options label select {
+		width: 195px;
+	}
+
+#link-advanced-options-toggle {
+	display: block;
+}
+
+#link-advanced-options label {
+	padding-top: 2px;
+	display: none;
+}
+	#link-advanced-options.adv-options-active label {
+		display: block;
+	}
+
+.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 {
+	padding:4px 0;
+	margin:0 auto;
+	text-align:center;
+}
+	.wp-tab-panel-pagelinks-top {
+		border-bottom: 1px solid #dfdfdf;
+	}
+</style>
+</head>
+<?php
+
+
+$panels = array();
+foreach ( $pts as $pt_obj ) {
+	$panel = new WP_Link_Panel( 'pt', $pt_obj, array(
+		array( 'preset' => 'all', 'label' => __('View All'), 'pagenum' => 1 ),
+		array( 'preset' => 'recent', 'label' => __('Most Recent') ),
+	));
+	if ( !empty( $panel->queries[0]['data'] ) )
+		$panels[] = $panel;
+}
+foreach ( $taxes as $tax_obj ) {
+	$panel = new WP_Link_Panel( 'tax', $tax_obj, array(
+		array( 'preset' => 'all', 'label' => __('View All'), 'pagenum' => 1 ),
+		array( 'preset' => 'popular', 'label' => __('Most Used') ),
+	));
+	if ( !empty( $panel->queries[0]['data'] ) )
+		$panels[] = $panel;
+}
+
+?>
+<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 ( $panels as $panel ) {
+			echo "<option id='link-option-id-$panel->id' class='link-option-pt'>";
+			echo $panel->labels->singular_name . '</option>';
+		} ?>
+		</select>
+	</label>
+</div>
+<div id="link-selector">
+	<?php
+	wp_link_panel_custom();
+	foreach( $panels as $panel )
+		$panel->render();
+	?>
+	<div id="link-options">
+		<label for="link-title-field">
+			<span><?php _e('Description:'); ?></span><input id="link-title-field" type="text" />
+		</label>
+	</div>
+	<div id="link-advanced-options">
+		<a id="link-advanced-options-toggle" href="#"><?php _e('Advanced Options'); ?></a>
+		<label for="link-target-select">
+			<span><?php _e('Target:'); ?></span><select id="link-target-select"></select>
+		</label>
+		<label for="link-class-select">
+			<span><?php _e('Class:'); ?></span><select id="link-class-select"></select>
+		</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,332 @@
+<?php
+/** @ignore */
+if ( ! defined('ABSPATH') )
+	require_once('../../../wp-load.php');
+
+function wp_tab_bar( $tabs, $active=null, $echo=true ) {
+	if ( empty( $active ) )
+		$active = $tabs[0]['for'];
+	
+	$out = "<ul class='wp-tab-bar'>";
+	foreach( $tabs as $tab ) {
+		if ( !isset($tab['url']) )
+			$tab['url'] = '';
+		
+		$out.= "<li id='wp-tab-for-{$tab['for']}' class='";
+		$out.= $active == $tab['for'] ? 'wp-tab-active' : '';
+		$out.= "'><a href='{$tab['url']}#{$tab['for']}'>";
+		$out.= "{$tab['title']}</a></li>";
+	}
+	$out.= "</ul>";
+	
+	if ( $echo )
+		echo $out;
+	
+	return $out;
+}
+
+function wp_tab_bar_item( $title, $id, $url='' ) {
+	return array(
+		'title' => $title,
+		'for' => $id,
+		'url' => $url
+	);
+}
+
+// Set up some vars
+$pts = get_post_types( array( 'public' => true, 'show_ui' => true ), 'objects' );
+$taxes = get_taxonomies( array( 'public' => true, 'show_ui' => true ), 'objects' );
+
+// Helper functions
+function wp_link_panel_custom() { ?>
+	<div id="link-panel-id-custom" class="link-panel link-panel-custom link-panel-active">
+		<label>
+			<span><?php _e('URL:'); ?></span><input class="url-field" type="text" />
+		</label>
+	</div>
+<?php }
+
+class WP_Link_Panel {
+	/**
+	 * The type of data contained: post type or taxonomy.
+	 * 
+	 * @var string 'pt' or 'tax'
+	 */
+	var $obj_type;
+	/**
+	 * Either a post type object or a taxonomy object.
+	 *
+	 * @var object
+	 */
+	var $obj;
+	/**
+	 * An array of array('slug' => string, 'preset' => string, 'label' => string, ['pagenum' => int])
+	 *
+	 * @var array
+	 */
+	var $queries;
+	/**
+	 * The pt/tax name.
+	 *
+	 * @var string
+	 */
+	var $name;
+	/**
+	 * The pt/tax id (combined with the obj_type).
+	 *
+	 * @var string
+	 */
+	var $id;
+	/**
+	 * The pt/tax labels.
+	 *
+	 * @var string
+	 */
+	var $labels;
+	
+	function WP_Link_Panel( $obj_type, $obj, $queries ) {
+		if ( !in_array( $obj_type, array('pt','tax') ) )
+			return;
+		
+		$this->obj_type = $obj_type;
+		$this->obj = $obj;
+		$this->name = $obj->name;
+		$this->id = esc_attr("$this->obj_type-$this->name");
+		$this->labels = $obj->labels;
+		
+		foreach( $queries as $i => $query ) {
+			if ( !isset( $query['slug'] ) )
+				$queries[$i]['slug'] = $query['preset'];
+			
+			$args = array();
+			if ( isset( $query['pagenum'] ) )
+				$args['pagenum'] = $query['pagenum'];
+			
+			if ( 'pt' == $this->obj_type )
+				$queries[$i]['data'] = wp_link_query_post_type( $this->obj, $query['preset'], $args );
+			else
+				$queries[$i]['data'] = wp_link_query_taxonomy( $this->obj, $query['preset'], $args );
+		}
+		
+		$this->queries = $queries;
+	}
+	
+	/**
+	 * Render the link data.
+	 */
+	function render() {
+		$id = $this->id;
+		$tabs = $this->queries;
+		?>
+		<div id="link-panel-id-<?php echo $id; ?>" class="link-panel link-panel-<?php echo $this->obj_type; ?>">
+			<?php
+
+			$tbitems = array();
+			foreach( $tabs as $i => $tab ) {
+				$tabs[$i]['id'] = "$id-{$tabs[$i]['slug']}";
+				$tbitems[] = wp_tab_bar_item( $tabs[$i]['label'], $tabs[$i]['id'] );
+			}
+			array_push( $tbitems, wp_tab_bar_item( __('Search'), "$id-search" ) );
+			wp_tab_bar( $tbitems );
+
+			foreach( $tabs as $tab ):
+				$data = $tab['data'];
+				$slug = $tab['slug'];
+				?>
+			<div id="<?php echo $tab['id']; ?>" class="wp-tab-panel">
+				<?php if ( isset( $data['pages'] ) && ! empty( $data['pages']['page_links'] ) ) : ?>
+					<div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-top">
+						<?php echo $data['pages']['page_links']; ?>
+					</div>
+				<?php endif; ?>
+				<ul>
+					<?php
+					foreach( $data['results'] as $result ): ?>
+					<li id="link-to-<?php echo "$id-" . esc_attr( $result['ID'] ); ?>">
+						<input type="hidden" value="<?php echo esc_url( $result['permalink'] ); ?>" />
+						<?php
+						echo empty( $result['title'] ) ? '<em>' . __('Untitled') . '</em>' : esc_html( $result['title'] ); ?>
+					</li>
+					<?php endforeach; ?>
+				</ul>
+				<?php if ( isset( $data['pages'] ) && ! empty( $data['pages']['page_links'] ) ) : ?>
+					<div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-bottom">
+						<?php echo $data['pages']['page_links']; ?>
+					</div>
+				<?php endif; ?>
+			</div>
+			<?php endforeach; ?>
+			<div id="<?php echo $id; ?>-search" class="wp-tab-panel">
+				<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>
+			</div>
+		</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' => $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'];
+	}
+	
+	// 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_query_taxonomy( $tax_obj, $preset='all', $opts=array() ) {
+	switch( $preset ) {
+		case 'all':
+			$args = array(
+				'child_of' => 0,
+				'exclude' => '',
+				'hide_empty' => false,
+				'hierarchical' => 1,
+				'include' => '',
+				'include_last_update_time' => false,
+				'number' => 30,
+				'order' => 'ASC',
+				'orderby' => 'name',
+				'pad_counts' => false,
+			);
+			break;
+		case 'popular':
+			$args = array(
+				'orderby' => 'count',
+				'order' => 'DESC',
+				'number' => 10,
+				'hierarchical' => false
+			);
+			break;
+		case 'search':
+			$args = array(
+				'name__like' => $opts['search'],
+				'number' => 10
+			);
+			break;
+	}
+	
+	// Handle pages if a page number is specified.
+	if ( isset( $opts['pagenum'] ) && isset( $args['number'] ) ) {
+		$pages = array(
+			'current' => $opts['pagenum'],
+			'per_page' => $args['number']
+		);
+		
+		$pages['max'] = ceil( wp_count_terms( $tax_obj->name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $pages['per_page'] );
+		
+		if ( ! isset( $args['offset'] ) )
+			$args['offset'] = 0 < $opts['pagenum'] ? $args['number'] * ( $opts['pagenum'] - 1 ) : 0;
+		$pages['offset'] = $args['offset'];
+		
+		$pages['page_links'] = paginate_links( array(
+			'prev_text' => __('&laquo;'),
+			'next_text' => __('&raquo;'),
+			'total' => $pages['max'],
+			'current' => $pages['current']
+		));
+	}
+	
+	// Do the main query.
+	$terms = get_terms( $tax_obj->name, $args );
+	// Check if any terms were found.
+	if ( ! $terms || is_wp_error($terms) )
+		return false;
+	
+	// Build results.
+	$results = array();
+	foreach ( $terms as $term ) {
+		$results[] = array(
+			'ID' => $term->term_id,
+			'title' => $term->name,
+			'permalink' => get_term_link( $term )
+		);
+	}
+	
+	// Build response.
+	$resp = array(
+		'objects' => $terms,
+		'results' => $results
+	);
+	if ( isset( $pages ) )
+		$resp['pages'] = $pages;
+	
+	return $resp;
+}
+?>
\ No newline at end of file
Index: wp-admin/admin-ajax.php
===================================================================
--- wp-admin/admin-ajax.php	(revision 15788)
+++ wp-admin/admin-ajax.php	(working copy)
@@ -1102,6 +1102,27 @@
 
 	exit;
 	break;
+	case 'wp-link-search':
+		require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link-includes.php';
+
+		if ( !isset($_REQUEST['type']) || !isset($_REQUEST['name']) || !isset($_REQUEST['title']) )
+			die('-1');
+
+		if ( 'pt' == $_REQUEST['type'] && $obj = get_post_type_object($_REQUEST['name']) )
+			$resp = wp_link_query_post_type( $obj, 'search', array('search' => $_REQUEST['title']) );
+		else if ( 'tax' == $_REQUEST['type'] && $obj = get_taxonomy($_REQUEST['name']) )
+			$resp = wp_link_query_taxonomy( $obj, 'search', array('search' => $_REQUEST['title']) );
+		else
+			die('-1');
+
+		if ( !$resp )
+			die('0');
+
+		echo json_encode($resp['results']);
+		echo "\n";
+
+		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 15788)
+++ 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'.
@@ -1398,11 +1398,11 @@
 	$plugins = implode($plugins, ',');
 
 	if ( $teeny ) {
-		$mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') );
+		$mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, wplink, unlink, fullscreen') );
 		$mce_buttons = implode($mce_buttons, ',');
 		$mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = '';
 	} else {
-		$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
+		$mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'wplink', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' ));
 		$mce_buttons = implode($mce_buttons, ',');
 
 		$mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|' );
Index: wp-admin/css/colors-fresh.dev.css
===================================================================
--- wp-admin/css/colors-fresh.dev.css	(revision 15788)
+++ 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 15788)
+++ 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;
