Ticket #15739: internal-linking.diff
File internal-linking.diff, 8.1 KB (added by , 14 years ago) |
---|
-
wp-includes/js/tinymce/plugins/wplink/css/wplink.dev.css
57 57 padding: 4px 6px; 58 58 cursor: pointer; 59 59 } 60 #wp-link li:hover {60 #wp-link .link-item-wrap:hover { 61 61 background: #eaf2fa; 62 62 color: #151515; 63 63 } … … 69 69 cursor: auto; 70 70 color: #333; 71 71 } 72 #wp-link li.selected {72 #wp-link .selected { 73 73 background: #ddd; 74 74 color: #333; 75 75 } 76 #wp-link li.selected .item-title {76 #wp-link .selected .item-title { 77 77 font-weight: bold; 78 78 } 79 79 #wp-link .item-info { … … 106 106 #wp-link-update { 107 107 line-height: 23px; 108 108 float: right; 109 } 110 111 #wp-link .toggle{ 112 height: 14px; 113 width: 14px; 114 } 115 116 #wp-link .has-submenu .children, #wp-link .has-submenu ul .has-submenu .children{ 117 display: none; 118 } 119 120 #wp-link .wp-link-open .children, #wp-link .wp-link-open ul .wp-link-open .children{ 121 display: block; 122 } 123 124 #wp-link .has-submenu .toggle, #wp-link .has-submenu ul .has-submenu .toggle{ 125 clear: left; 126 float: left; 127 background: url('arrowc.png') no-repeat; 128 padding-bottom: 1px 2px 0 0; 129 } 130 131 #wp-link .wp-link-open .toggle, #wp-link .wp-link-open ul .wp-link-open .toggle{ 132 background: url('arrowo.png') no-repeat; 109 133 } 134 No newline at end of file -
wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
1 var wpLink ;1 var wpLink, riverMenu; 2 2 3 3 (function($){ 4 4 var inputs = {}, rivers = {}, ed, River, Query; 5 5 6 riverMenu = { 7 init : function(){ 8 var river = $(".query-results"); 9 10 $('.toggle', river).each(function(){ 11 var t = $(this), sub = t.siblings('.children'); 12 if( sub.length ) 13 t.click(function(){ riverMenu.toggle(sub); }); 14 else 15 t.hide(); 16 }); 17 18 this.restoreMenuState(); 19 }, 20 21 restoreMenuState: function(){ 22 $('li.has-submenu', '.query-results').each(function(i, e){ 23 var v = getUserSetting( 'l'+$(e).attr('id') ); 24 if( 'o' == v ){ 25 $(e).addClass('wp-link-open'); 26 }else if( 'c' == v ){ 27 $(e).removeClass('wp-link-open'); 28 } 29 }); 30 }, 31 32 toggle: function(el){ 33 el.slideToggle(150, function(){ 34 var id = el.parent().toggleClass('wp-link-open').attr('id'); 35 if( id ){ 36 $('li.has-submenu','.query-results').each(function(i, e){ 37 if( id == e.id ){ 38 var v = $(e).hasClass('wp-link-open') ? 'o' : 'c'; 39 setUserSetting( 'l'+id, v ); 40 } 41 }); 42 } 43 }); 44 45 return false; 46 }, 47 }; 48 6 49 wpLink = { 7 50 timeToTriggerRiver: 150, 8 51 minRiverAJAXDuration: 200, … … 23 66 rivers.search = new River( $('#search-results') ); 24 67 rivers.recent = new River( $('#most-recent-results') ); 25 68 rivers.elements = $('.query-results', inputs.dialog); 26 69 27 70 // Bind event handlers 28 71 inputs.dialog.keydown( wpLink.keydown ); 29 72 inputs.dialog.keyup( wpLink.keyup ); … … 37 80 38 81 inputs.search.keyup( wpLink.searchInternalLinks ); 39 82 40 inputs.dialog.bind('wpdialogrefresh', wpLink.refresh); 83 inputs.dialog.bind('wpdialogrefresh', wpLink.refresh); 41 84 }, 42 85 43 86 refresh : function() { … … 142 185 tinyMCEPopup.close(); 143 186 }, 144 187 145 updateFields : function( e, li, originalEvent ) { 188 updateFields : function( e, li, originalEvent ) { 146 189 inputs.url.val( li.children('.item-permalink').val() ); 147 190 inputs.title.val( li.hasClass('no-title') ? '' : li.children('.item-title').text() ); 191 148 192 if ( originalEvent && originalEvent.type == "click" ) 149 193 inputs.url.focus(); 150 194 }, … … 253 297 254 298 this.change( search ); 255 299 this.refresh(); 300 301 element.scroll( function(){ self.maybeLoad(); }); 302 element.delegate('.link-item-wrap', 'click', function(e){ self.select( $(this), e ); }); 256 303 257 element.scroll( function(){ self.maybeLoad(); });258 element.delegate('li', 'click', function(e){ self.select( $(this), e ); });259 304 }; 260 305 261 306 $.extend( River.prototype, { … … 341 386 this.element.scrollTop(0); 342 387 }, 343 388 process: function( results, params ) { 344 var list = '', alt = true, classes = '', 345 firstPage = params.page == 1; 389 var list = '', alt = true, classes = '', self = this, 390 delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration, 391 firstPage = params.page == 1; is_child = params.is_child; 346 392 347 393 if ( !results ) { 348 394 if ( firstPage ) { … … 350 396 + wpLinkL10n.noMatchesFound 351 397 + '</em></span></li>'; 352 398 } 353 } else { 354 $.each( results, function() { 399 } else { 400 $.each( results, function() { 355 401 classes = alt ? 'alternate' : ''; 356 402 classes += this['title'] ? '' : ' no-title'; 357 list += classes ? '<li class="' + classes + '">' : '<li>'; 358 list += '<input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />'; 403 classes += this['children'] ? ' has-submenu' : ''; 404 list += classes ? '<li class="' + classes + '"' : '<li'; 405 list += ' id="'+this['ID']+'">'; 406 list += '<div class="toggle"></div><div class="link-item-wrap"><input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />'; 359 407 list += '<span class="item-title">'; 360 408 list += this['title'] ? this['title'] : wpLinkL10n.noTitle; 361 list += '</span><span class="item-info">' + this['info'] + '</span></li>'; 409 list += '</span><span class="item-info">' + this['info'] + '</span></div>'; 410 if( this['children'] ){ 411 list += self.process( this['children'], {'is_child': '1'} ); 412 } 413 list += '</li>'; 362 414 alt = ! alt; 363 415 }); 416 364 417 } 365 366 this.ul[ firstPage ? 'html' : 'append' ]( list ); 418 419 this.ul[ firstPage ? 'html' : 'append' ]( list ); 420 riverMenu.init(); 421 422 if( is_child ){ 423 return '<ul class="children">'+list+'</ul>'; 424 } 425 367 426 }, 368 427 maybeLoad: function() { 369 428 var self = this, … … 420 479 } 421 480 }); 422 481 423 $(document).ready( wpLink.init ); 482 $(document).ready( wpLink.init ); 424 483 })(jQuery); 484 No newline at end of file -
wp-admin/includes/internal-linking.php
44 44 if ( ! $get_posts->post_count ) 45 45 return false; 46 46 47 // Build results. 48 $results = array(); 47 // Build results. 48 $parents = array(); 49 $children = array(); 49 50 foreach ( $posts as $post ) { 50 51 if ( 'post' == $post->post_type ) 51 52 $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); 52 53 else 53 54 $info = $pts[ $post->post_type ]->labels->singular_name; 54 55 $results[] = array( 56 'ID' => $post->ID, 57 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), 58 'permalink' => get_permalink( $post->ID ), 59 'info' => $info, 60 ); 55 56 if( $post->post_parent ){ 57 $children[$post->ID] = array( 58 'ID' => $post->ID, 59 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), 60 'permalink' => get_permalink( $post->ID ), 61 'info' => $info, 62 'post_parent' => $post->post_parent, 63 ); 64 } else{ 65 $parents[$post->ID] = array( 66 'ID' => $post->ID, 67 'title' => trim( esc_html( strip_tags( get_the_title( $post ) ) ) ), 68 'permalink' => get_permalink( $post->ID ), 69 'info' => $info, 70 ); 71 } 61 72 } 73 74 foreach( $children as $id => $child ){ 75 $parent_id = $child['post_parent']; 76 if( array_key_exists( $parent_id, $children ) ){ 77 $children[$parent_id]['children'][] = $child; 78 unset( $children[$id] ); 79 } 80 } 81 82 foreach( $children as $id => $child ){ 83 $parent_id = $child['post_parent']; 84 if( array_key_exists( $parent_id, $parents ) ){ 85 $parents[$parent_id]['children'][] = $child; 86 }else{ 87 //orphans 88 $parents[$id] = $child; 89 } 90 } 62 91 63 return $results; 92 return $parents; 93 64 94 } 65 95 66 96 /**