Ticket #11420: internal-linking.second-pass.2.diff

File internal-linking.second-pass.2.diff, 34.3 KB (added by koopersmith, 3 years ago)
  • wp-includes/js/tinymce/plugins/wplink/editor_plugin.js

     
     1(function() { 
     2        tinymce.create('tinymce.plugins.wpLink', { 
     3                /** 
     4                 * Initializes the plugin, this will be executed after the plugin has been created. 
     5                 * This call is done before the editor instance has finished it's initialization so use the onInit event 
     6                 * of the editor instance to intercept that event. 
     7                 * 
     8                 * @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. 
     9                 * @param {string} url Absolute URL to where the plugin is located. 
     10                 */ 
     11                init : function(ed, url) { 
     12                        // Register the command so that it can be invoked by using tinyMCE.activeEditor.execCommand('mceExample'); 
     13                        ed.addCommand('WP_Link', function() { 
     14                                ed.windowManager.open({ 
     15                                        file : tinymce.baseURL + '/wp-mce-link.php', 
     16                                        width : 320, 
     17                                        height : 380, 
     18                                        inline : 1 
     19                                }, { 
     20                                        plugin_url : url // Plugin absolute URL 
     21                                }); 
     22                        }); 
     23 
     24                        // Register example button 
     25                        ed.addButton('wplink', { 
     26                                title : ed.getLang('wplink.link_desc'), 
     27                                cmd : 'WP_Link' 
     28                        }); 
     29                         
     30                        ed.addShortcut('alt+shift+a', ed.getLang('wplink.link_desc'), 'WP_Link'); 
     31 
     32                        // Add a node change handler, selects the button in the UI when a link is selected 
     33                        ed.onNodeChange.add(function(ed, cm, n) { 
     34                                cm.setActive('wplink', n.nodeName == 'A'); 
     35                        }); 
     36                }, 
     37                /** 
     38                 * Returns information about the plugin as a name/value array. 
     39                 * The current keys are longname, author, authorurl, infourl and version. 
     40                 * 
     41                 * @return {Object} Name/value array containing information about the plugin. 
     42                 */ 
     43                getInfo : function() { 
     44                        return { 
     45                                longname : 'WordPress Link Dialog', 
     46                                author : 'WordPress', 
     47                                authorurl : 'http://wordpress.org', 
     48                                infourl : '', 
     49                                version : "1.0" 
     50                        }; 
     51                } 
     52        }); 
     53 
     54        // Register plugin 
     55        tinymce.PluginManager.add('wplink', tinymce.plugins.wpLink); 
     56})(); 
     57 No newline at end of file 
  • wp-includes/js/tinymce/plugins/wplink/js/wplink.js

     
     1// WPTABS 
     2(function($){ 
     3        $.widget('wp.wpTabs', { 
     4                options: { 
     5                         
     6                }, 
     7                _create: function() { 
     8                        var self = this, 
     9                                ul = this.element, 
     10                                lis = ul.children(); 
     11                         
     12                        this.active = lis.filter('.wp-tab-active'); 
     13                        // Calculate panel IDs 
     14                        lis.each(function() { 
     15                                var panel = self._getPanel( $(this) ); 
     16                                if ( self.active[0] == this ) 
     17                                        panel.show(); 
     18                                else 
     19                                        panel.hide(); 
     20                        }); 
     21                         
     22                        ul.delegate('li', 'click.wpTabs', function(e) { 
     23                                var li = $(this); 
     24                                 
     25                                // Prevent any child link from redirecting the page. 
     26                                e.preventDefault(); 
     27                                // Deactivate previous tab. 
     28                                self._getPanel( self.active ).hide(); 
     29                                self.active.removeClass('wp-tab-active'); 
     30                                // Activate current tab. 
     31                                self.active = li.addClass('wp-tab-active'); 
     32                                self._getPanel( self.active ).show(); 
     33                        }); 
     34                }, 
     35                _setPanel: function( $el ) { 
     36                        var panel = $( '#' + $el[0].id.replace('wp-tab-for-','') ); 
     37                        $el.data( 'wp-tab-panel', panel ); 
     38                        return panel; 
     39                }, 
     40                _getPanel: function( $el ) { 
     41                        var panel = $el.data('wp-tab-panel'); 
     42                        return ( !panel || !panel.length ) ? this._setPanel( $el ) : panel; 
     43                } 
     44        }); 
     45        // Create tab bars by default. 
     46        $(function(){ 
     47                $('.wp-tab-bar').wpTabs(); 
     48        }); 
     49})(jQuery); 
     50 
     51(function($){    
     52        var inputs = {}, panels, active, ed, 
     53        wpLink = { 
     54                init : function() { 
     55                        var e, etarget, eclass; 
     56                        // Init shared vars 
     57                        ed = tinyMCEPopup.editor; 
     58                        // Secondary options 
     59                        inputs.title = $('#link-title-field'); 
     60                        // Advanced Options 
     61                        inputs.advancedOptions = $('#link-advanced-options'); 
     62                        inputs.target = $('#link-target-select'); 
     63                        inputs['class'] = $('#link-class-select'); 
     64                        // Types 
     65                        inputs.typeDropdown = $('#link-type'); 
     66                        inputs.typeOptions = inputs.typeDropdown.find('option'); 
     67                         
     68                        panels = $('.link-panel'); 
     69                        active = $('.link-panel-active'); 
     70                         
     71                        // Build lists 
     72                        wpLink.fillClassList('link-class-select'); 
     73                        wpLink.fillTargetList('link-target-select'); 
     74                         
     75                        // Extract type names 
     76                        inputs.typeOptions.each( function(){ 
     77                                var linkType = this.id.replace(/^link-option-id-/,''), 
     78                                        parts = linkType.split('-'); 
     79                                $(this).data( 'link-type', { 
     80                                        full : linkType, 
     81                                        type : parts[0], 
     82                                        name : parts[1] || '' 
     83                                }); 
     84                        }); 
     85                        panels.each( function(){ 
     86                                var linkType = this.id.replace(/^link-panel-id-/,''), 
     87                                        parts = linkType.split('-'); 
     88                                $(this).data( 'link-type', { 
     89                                        full : linkType, 
     90                                        type : parts[0], 
     91                                        name : parts[1] || '' 
     92                                }); 
     93                        }); 
     94                         
     95                        // Bind event handlers 
     96                        inputs.typeDropdown.change( wpLink.selectPanel ); 
     97                        $('#wp-update').click( wpLink.update ); 
     98                        $('#wp-cancel').click( function() { tinyMCEPopup.close(); } ); 
     99                        $('#link-advanced-options-toggle').click( wpLink.toggleAdvancedOptions ); 
     100                        $('.link-panel .wp-tab-panel').delegate('li', 'click', wpLink.selectInternalLink ) 
     101                        $('.wp-tab-panel-pagelinks').delegate('a', 'click', wpLink.selectPageLink ); 
     102                        $('.link-panel .link-search-field').keyup( wpLink.searchInternalLinks ); 
     103                         
     104                        // If link exists, select proper values. 
     105                        e = ed.dom.getParent(ed.selection.getNode(), 'A'); 
     106                        if ( ! e ) 
     107                                return; 
     108                         
     109                        // @TODO: select proper panel/fill values when a link is edited 
     110                        active.find('input.url-field').val( e.href ); 
     111                        inputs.title.val( ed.dom.getAttrib(e, 'title') ); 
     112                        // Advanced Options 
     113                        inputs.target.val( etarget = ed.dom.getAttrib(e, 'target') ); 
     114                        inputs['class'].val( eclass = ed.dom.getAttrib(e, 'class') ); 
     115                        if ( etarget || eclass ) // Open the adv. options if one is set. 
     116                                inputs.advancedOptions.toggleClass('adv-options-active'); 
     117                }, 
     118                 
     119                update : function() { 
     120                        var el, 
     121                                ed = tinyMCEPopup.editor, 
     122                                attrs = { 
     123                                        title : inputs.title.val(), 
     124                                        target : inputs.target.val(), 
     125                                        'class' : inputs['class'].val() 
     126                                }, defaultContent, e, b; 
     127                         
     128                        if ( active.hasClass('link-panel-custom') ) { 
     129                                attrs.href = active.find('input.url-field').val(); 
     130                                defaultContent = attrs.href; 
     131                        } else { 
     132                                el = active.find('li.selected:visible'); 
     133                                if ( !el.length ) 
     134                                        return; 
     135                                 
     136                                attrs.href = el.children('input').val(); 
     137                                defaultContent = el.text(); 
     138                        } 
     139                         
     140                        tinyMCEPopup.restoreSelection(); 
     141                        e = ed.dom.getParent(ed.selection.getNode(), 'A'); 
     142                         
     143                        // If the values are empty... 
     144                        if ( ! attrs.href ) { 
     145                                // ...and nothing is selected, we should return 
     146                                if ( ed.selection.isCollapsed() ) { 
     147                                        tinyMCEPopup.close(); 
     148                                        return; 
     149                                // ...and a link exists, we should unlink and return 
     150                                } else if ( e ) { 
     151                                        tinyMCEPopup.execCommand("mceBeginUndoLevel"); 
     152                                        b = ed.selection.getBookmark(); 
     153                                        ed.dom.remove(e, 1); 
     154                                        ed.selection.moveToBookmark(b); 
     155                                        tinyMCEPopup.execCommand("mceEndUndoLevel"); 
     156                                        tinyMCEPopup.close(); 
     157                                        return; 
     158                                } 
     159                        } 
     160                         
     161                        tinyMCEPopup.execCommand("mceBeginUndoLevel"); 
     162 
     163                        if (e == null) { 
     164                                ed.getDoc().execCommand("unlink", false, null); 
     165                                 
     166                                // If no selection exists, create a new link from scratch. 
     167                                if ( ed.selection.isCollapsed() ) { 
     168                                        var el = ed.dom.create('a', { href: "#mce_temp_url#" }, defaultContent); 
     169                                        ed.selection.setNode(el); 
     170                                // If a selection exists, wrap it in a link. 
     171                                } else { 
     172                                        tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1}); 
     173                                } 
     174 
     175                                tinymce.each(ed.dom.select("a"), function(n) { 
     176                                        if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { 
     177                                                e = n; 
     178                                                ed.dom.setAttribs(e, attrs); 
     179                                        } 
     180                                }); 
     181                        } else { 
     182                                ed.dom.setAttribs(e, attrs); 
     183                        } 
     184 
     185                        // Don't move caret if selection was image 
     186                        if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') { 
     187                                ed.focus(); 
     188                                ed.selection.select(e); 
     189                                ed.selection.collapse(0); 
     190                                tinyMCEPopup.storeSelection(); 
     191                        } 
     192 
     193                        tinyMCEPopup.execCommand("mceEndUndoLevel"); 
     194                        tinyMCEPopup.close(); 
     195                }, 
     196                 
     197                selectPanel : function( option ) { 
     198                        var sel = inputs.typeOptions.filter(':selected'); 
     199                         
     200                        if ( option.jquery ) { 
     201                                sel.removeAttr('selected'); 
     202                                sel = option.attr('selected', 'selected'); 
     203                        } 
     204                         
     205                        active.removeClass('link-panel-active'); 
     206                        active = $('#link-panel-id-' + sel.data('link-type').full ).addClass('link-panel-active'); 
     207                }, 
     208                 
     209                toggleAdvancedOptions : function() { 
     210                        inputs.advancedOptions.toggleClass('adv-options-active'); 
     211                        return false; 
     212                }, 
     213                 
     214                selectInternalLink : function() { 
     215                        $(this).siblings('.selected').removeClass('selected'); 
     216                        $(this).addClass('selected'); 
     217                }, 
     218                 
     219                selectPageLink : function(e) { 
     220                        var t = $(this), 
     221                                page = e.target.href.match(/page=(\d+)/); 
     222                         
     223                        page = page ? page[1] : 1; // If there's no match, it's the first page. 
     224                        e.preventDefault(); // Prevent the link from redirecting. 
     225                         
     226                        wpLink.linkAJAX( t, { 
     227                                action : 'wp-link-page', 
     228                                page : page 
     229                        }, function(r, lt) { 
     230                                var p = t.parent(); 
     231                                p.siblings('ul').html( wpLink.generateListMarkup( r['results'], lt ) ); 
     232                                p.siblings('.wp-tab-panel-pagelinks').andSelf().html( r['page_links'] ); 
     233                        }); 
     234                }, 
     235                 
     236                searchInternalLinks : function() { 
     237                        var t = $(this), 
     238                                waiting = t.siblings('img.waiting').show(); 
     239                                 
     240                        wpLink.linkAJAX( t, { 
     241                                action : 'wp-link-search', 
     242                                title : t.val() 
     243                        }, function(r, lt) { 
     244                                t.parent().siblings('ul').html( wpLink.generateListMarkup( r, lt ) ); 
     245                                waiting.hide(); 
     246                        }); 
     247                }, 
     248                 
     249                linkAJAX : function( el, params, callback ) { 
     250                        var linkType = el.parents('.link-panel').data('link-type'); 
     251                        $.post( ajaxurl, $.extend({ 
     252                                type : linkType.type, 
     253                                name : linkType.name 
     254                        }, params ), function(r) { 
     255                                return callback(r, linkType);  
     256                        }, "json" ); 
     257                }, 
     258                 
     259                generateListMarkup : function( results, linkType ) { 
     260                        var s = ''; 
     261                        $.each( results, function() { 
     262                                s+= '<li id="link-to-' + linkType.full + '-' + this['ID'] + '">'; 
     263                                s+= '<input type="hidden" value="' + this['permalink'] + '" />'; 
     264                                s+= this['title'] ? this['title'] : '<em>'+ wpLinkL10n.untitled + '</em>'; 
     265                                s+= '</li>'; 
     266                        }); 
     267                        return s; 
     268                }, 
     269                 
     270                /** 
     271                 * Taken from themes/advanced/js/link.js 
     272                 */ 
     273                fillClassList : function(id) { 
     274                        var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; 
     275 
     276                        if (v = tinyMCEPopup.getParam('theme_advanced_styles')) { 
     277                                cl = []; 
     278 
     279                                tinymce.each(v.split(';'), function(v) { 
     280                                        var p = v.split('='); 
     281 
     282                                        cl.push({'title' : p[0], 'class' : p[1]}); 
     283                                }); 
     284                        } else 
     285                                cl = tinyMCEPopup.editor.dom.getClasses(); 
     286 
     287                        if (cl.length > 0) { 
     288                                lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); 
     289 
     290                                tinymce.each(cl, function(o) { 
     291                                        lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); 
     292                                }); 
     293                        } else 
     294                                dom.remove(dom.getParent(id, 'tr')); 
     295                }, 
     296 
     297                /** 
     298                 * Taken from themes/advanced/js/link.js 
     299                 */ 
     300                fillTargetList : function(id) { 
     301                        var dom = tinyMCEPopup.dom, lst = dom.get(id), v; 
     302 
     303                        lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); 
     304                        lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self'); 
     305                        lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank'); 
     306 
     307                        if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) { 
     308                                tinymce.each(v.split(','), function(v) { 
     309                                        v = v.split('='); 
     310                                        lst.options[lst.options.length] = new Option(v[0], v[1]); 
     311                                }); 
     312                        } 
     313                } 
     314        } 
     315         
     316        $(document).ready( wpLink.init ); 
     317})(jQuery); 
     318 No newline at end of file 
  • wp-includes/js/tinymce/langs/wp-langs-en.js

     
    429429caption:"Edit Image Caption", 
    430430alt:"Edit Alternate Text" 
    431431}); 
     432 
     433tinyMCE.addI18n("en.wplink",{ 
     434link_desc:"Insert/edit link", 
     435unlink_desc:"Unlink (Alt+Shift+S)" 
     436}); 
  • wp-includes/js/tinymce/langs/wp-langs.php

     
    452452caption:"' . mce_escape( __('Edit Image Caption') ) . '", 
    453453alt:"' . mce_escape( __('Edit Alternate Text') ) . '" 
    454454}); 
     455 
     456tinyMCE.addI18n("' . $language . '.wplink",{ 
     457link_desc:"' . mce_escape( __('Insert/edit link') ) . '", 
     458unlink_desc:"' . mce_escape( __('Unlink') ) . ' (Alt+Shift+S)" 
     459}); 
    455460'; 
  • wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css

     
    274274.wp_themeSkin span.mce_anchor {background-position:-200px 0} 
    275275.wp_themeSkin span.mce_indent {background-position:-400px 0} 
    276276.wp_themeSkin span.mce_outdent {background-position:-540px 0} 
    277 .wp_themeSkin span.mce_link {background-position:-500px 0} 
     277.wp_themeSkin span.mce_link, 
     278.wp_themeSkin span.mce_wplink {background-position:-500px 0} 
    278279.wp_themeSkin span.mce_unlink {background-position:-640px 0} 
    279280.wp_themeSkin span.mce_sub {background-position:-600px 0} 
    280281.wp_themeSkin span.mce_sup {background-position:-620px 0} 
  • wp-includes/js/tinymce/wp-mce-link.php

     
     1<?php 
     2include 'wp-mce-link-includes.php'; 
     3header('Content-Type: text/html; charset=' . get_bloginfo('charset')); 
     4?> 
     5<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
     6<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 
     7<head> 
     8<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 
     9<title><?php _e('Insert/edit link') ?></title> 
     10<script type="text/javascript"> 
     11//<![CDATA[ 
     12var ajaxurl = '<?php echo admin_url('admin-ajax.php'); ?>', 
     13        wpLinkL10n = { 
     14                untitled : '<?php _e('Untitled'); ?>' 
     15        }; 
     16//]]> 
     17</script> 
     18<script type="text/javascript" src="tiny_mce_popup.js?ver=3223"></script> 
     19<?php 
     20wp_print_scripts( array('jquery', 'jquery-ui-widget') ); 
     21?> 
     22<script type="text/javascript" src="plugins/wplink/js/wplink.js?ver=1.0"></script> 
     23<?php 
     24wp_admin_css( 'global', true ); 
     25wp_admin_css( 'wp-admin', true ); 
     26wp_admin_css( 'colors-fresh', true ); 
     27?> 
     28<style> 
     29html, body { 
     30        background: #f1f1f1; 
     31} 
     32 
     33a:link, a:visited { 
     34        color: #21759B; 
     35} 
     36 
     37select { 
     38        height: 2em; 
     39} 
     40 
     41#link-header, 
     42#link-options, 
     43#link-advanced-options { 
     44        padding: 5px; 
     45        border-bottom: 1px solid #dfdfdf; 
     46} 
     47#link-type { 
     48        width: 140px; 
     49} 
     50 
     51.link-panel { 
     52        padding: 5px 5px 0; 
     53        display: none; 
     54} 
     55        .link-panel-active { 
     56                display: block; 
     57        } 
     58 
     59label input[type="text"] { 
     60        width: 220px; 
     61} 
     62        .wp-tab-panel label input[type="text"] { 
     63                float: left; 
     64                width: 200px; 
     65        } 
     66 
     67label span { 
     68        display: inline-block; 
     69        width: 80px; 
     70        text-align: right; 
     71        padding-right: 5px; 
     72} 
     73        .wp-tab-panel label span { 
     74                width: auto; 
     75                text-align: left; 
     76                float: left; 
     77                margin-top: 3px; 
     78        } 
     79        .link-search-wrapper { 
     80                padding: 5px; 
     81                border-bottom: solid 1px #dfdfdf; 
     82                display: block; 
     83                overflow: hidden; 
     84        } 
     85                .link-search-wrapper img.waiting { 
     86                        margin: 4px 1px 0 4px; 
     87                        float: left; 
     88                        display: none; 
     89                } 
     90 
     91#link-advanced-options, 
     92#link-advanced-options select, 
     93#link-advanced-options option { 
     94        font-size: 11px; 
     95} 
     96 
     97#link-advanced-options { 
     98        background: #f9f9f9; 
     99        padding: 3px 5px; 
     100} 
     101        #link-advanced-options label select { 
     102                width: 195px; 
     103        } 
     104 
     105#link-advanced-options-toggle { 
     106        display: block; 
     107} 
     108 
     109#link-advanced-options label { 
     110        padding-top: 2px; 
     111        display: none; 
     112} 
     113        #link-advanced-options.adv-options-active label { 
     114                display: block; 
     115        } 
     116 
     117.submitbox { 
     118        padding: 5px; 
     119        font-size: 11px; 
     120        overflow: auto; 
     121        height: 29px; 
     122} 
     123#wp-cancel { 
     124        line-height: 25px; 
     125        float: left; 
     126} 
     127#wp-update { 
     128        line-height: 23px; 
     129        float: right; 
     130} 
     131#wp-update a { 
     132        display: inline-block; 
     133} 
     134.wp-tab-active, 
     135.wp-tab-panel { 
     136        background: #fff; 
     137} 
     138        .wp-tab-panel { 
     139                height: 160px; 
     140                padding: 0; 
     141        } 
     142.wp-tab-panel li { 
     143        margin-bottom: 0; 
     144        border-bottom: 1px solid #dfdfdf; 
     145        color: #555; 
     146        padding: 4px 6px; 
     147        cursor: pointer; 
     148} 
     149        .wp-tab-panel li:hover { 
     150                background: #EAF2FA; 
     151                color: #333; 
     152        } 
     153        .wp-tab-panel li.selected { 
     154                background: #f1f1f1; 
     155                font-weight: bold; 
     156                color: #333; 
     157        } 
     158.wp-tab-panel-pagelinks { 
     159        padding:4px 0; 
     160        margin:0 auto; 
     161        text-align:center; 
     162} 
     163        .wp-tab-panel-pagelinks-top { 
     164                border-bottom: 1px solid #dfdfdf; 
     165        } 
     166</style> 
     167</head> 
     168<?php 
     169 
     170 
     171$panels = array(); 
     172foreach ( $pts as $pt_obj ) { 
     173        $panel = new WP_Link_Panel( 'pt', $pt_obj, array( 
     174                array( 'preset' => 'all', 'label' => __('View All'), 'pagenum' => 1 ), 
     175                array( 'preset' => 'recent', 'label' => __('Most Recent') ), 
     176        )); 
     177        if ( !empty( $panel->queries[0]['data'] ) ) 
     178                $panels[] = $panel; 
     179} 
     180foreach ( $taxes as $tax_obj ) { 
     181        $panel = new WP_Link_Panel( 'tax', $tax_obj, array( 
     182                array( 'preset' => 'all', 'label' => __('View All'), 'pagenum' => 1 ), 
     183                array( 'preset' => 'popular', 'label' => __('Most Used') ), 
     184        )); 
     185        if ( !empty( $panel->queries[0]['data'] ) ) 
     186                $panels[] = $panel; 
     187} 
     188 
     189?> 
     190<body id="post-body"> 
     191<div id="link-header"> 
     192        <label for="link-type"> 
     193                <span><strong><?php _e('Link Type:'); ?></strong> 
     194                </span><select id="link-type"> 
     195                        <option id="link-option-id-custom" class="link-custom"><?php _e('External Link'); ?></option> 
     196                <?php 
     197                foreach ( $panels as $panel ) { 
     198                        echo "<option id='link-option-id-$panel->id' class='link-option-pt'>"; 
     199                        echo $panel->labels->singular_name . '</option>'; 
     200                } ?> 
     201                </select> 
     202        </label> 
     203</div> 
     204<div id="link-selector"> 
     205        <?php 
     206        wp_link_panel_custom(); 
     207        foreach( $panels as $panel ) 
     208                $panel->render(); 
     209        ?> 
     210        <div id="link-options"> 
     211                <label for="link-title-field"> 
     212                        <span><?php _e('Description:'); ?></span><input id="link-title-field" type="text" /> 
     213                </label> 
     214        </div> 
     215        <div id="link-advanced-options"> 
     216                <a id="link-advanced-options-toggle" href="#"><?php _e('Advanced Options'); ?></a> 
     217                <label for="link-target-select"> 
     218                        <span><?php _e('Target:'); ?></span><select id="link-target-select"></select> 
     219                </label> 
     220                <label for="link-class-select"> 
     221                        <span><?php _e('Class:'); ?></span><select id="link-class-select"></select> 
     222                </label> 
     223        </div> 
     224</div> 
     225<div class="submitbox"> 
     226        <div id="wp-cancel"> 
     227                <a class="submitdelete deletion"><?php _e('Cancel'); ?></a> 
     228        </div> 
     229        <div id="wp-update"> 
     230                <a class="button-primary"><?php _e('Update'); ?></a> 
     231        </div> 
     232</div> 
     233</body> 
     234</html> 
  • wp-includes/js/tinymce/wp-mce-link-includes.php

     
     1<?php 
     2/** @ignore */ 
     3if ( ! defined('ABSPATH') ) 
     4        require_once('../../../wp-load.php'); 
     5 
     6function wp_tab_bar( $tabs, $active=null, $echo=true ) { 
     7        if ( empty( $active ) ) 
     8                $active = $tabs[0]['for']; 
     9         
     10        $out = "<ul class='wp-tab-bar'>"; 
     11        foreach( $tabs as $tab ) { 
     12                if ( !isset($tab['url']) ) 
     13                        $tab['url'] = ''; 
     14                 
     15                $out.= "<li id='wp-tab-for-{$tab['for']}' class='"; 
     16                $out.= $active == $tab['for'] ? 'wp-tab-active' : ''; 
     17                $out.= "'><a href='{$tab['url']}#{$tab['for']}'>"; 
     18                $out.= "{$tab['title']}</a></li>"; 
     19        } 
     20        $out.= "</ul>"; 
     21         
     22        if ( $echo ) 
     23                echo $out; 
     24         
     25        return $out; 
     26} 
     27 
     28function wp_tab_bar_item( $title, $id, $url='' ) { 
     29        return array( 
     30                'title' => $title, 
     31                'for' => $id, 
     32                'url' => $url 
     33        ); 
     34} 
     35 
     36// Set up some vars 
     37$pts = get_post_types( array( 'public' => true, 'show_ui' => true ), 'objects' ); 
     38$taxes = get_taxonomies( array( 'public' => true, 'show_ui' => true ), 'objects' ); 
     39 
     40// Helper functions 
     41function wp_link_panel_custom() { ?> 
     42        <div id="link-panel-id-custom" class="link-panel link-panel-custom link-panel-active"> 
     43                <label> 
     44                        <span><?php _e('URL:'); ?></span><input class="url-field" type="text" /> 
     45                </label> 
     46        </div> 
     47<?php } 
     48 
     49class WP_Link_Panel { 
     50        /** 
     51         * The type of data contained: post type or taxonomy. 
     52         *  
     53         * @var string 'pt' or 'tax' 
     54         */ 
     55        var $obj_type; 
     56        /** 
     57         * Either a post type object or a taxonomy object. 
     58         * 
     59         * @var object 
     60         */ 
     61        var $obj; 
     62        /** 
     63         * An array of array('slug' => string, 'preset' => string, 'label' => string, ['pagenum' => int]) 
     64         * 
     65         * @var array 
     66         */ 
     67        var $queries; 
     68        /** 
     69         * The pt/tax name. 
     70         * 
     71         * @var string 
     72         */ 
     73        var $name; 
     74        /** 
     75         * The pt/tax id (combined with the obj_type). 
     76         * 
     77         * @var string 
     78         */ 
     79        var $id; 
     80        /** 
     81         * The pt/tax labels. 
     82         * 
     83         * @var string 
     84         */ 
     85        var $labels; 
     86         
     87        function WP_Link_Panel( $obj_type, $obj, $queries ) { 
     88                if ( !in_array( $obj_type, array('pt','tax') ) ) 
     89                        return; 
     90                 
     91                $this->obj_type = $obj_type; 
     92                $this->obj = $obj; 
     93                $this->name = $obj->name; 
     94                $this->id = esc_attr("$this->obj_type-$this->name"); 
     95                $this->labels = $obj->labels; 
     96                 
     97                foreach( $queries as $i => $query ) { 
     98                        if ( !isset( $query['slug'] ) ) 
     99                                $queries[$i]['slug'] = $query['preset']; 
     100                         
     101                        $args = array(); 
     102                        if ( isset( $query['pagenum'] ) ) 
     103                                $args['pagenum'] = $query['pagenum']; 
     104                         
     105                        if ( 'pt' == $this->obj_type ) 
     106                                $queries[$i]['data'] = wp_link_query_post_type( $this->obj, $query['preset'], $args ); 
     107                        else 
     108                                $queries[$i]['data'] = wp_link_query_taxonomy( $this->obj, $query['preset'], $args ); 
     109                } 
     110                 
     111                $this->queries = $queries; 
     112        } 
     113         
     114        /** 
     115         * Render the link data. 
     116         */ 
     117        function render() { 
     118                $id = $this->id; 
     119                $tabs = $this->queries; 
     120                ?> 
     121                <div id="link-panel-id-<?php echo $id; ?>" class="link-panel link-panel-<?php echo $this->obj_type; ?>"> 
     122                        <?php 
     123 
     124                        $tbitems = array(); 
     125                        foreach( $tabs as $i => $tab ) { 
     126                                $tabs[$i]['id'] = "$id-{$tabs[$i]['slug']}"; 
     127                                $tbitems[] = wp_tab_bar_item( $tabs[$i]['label'], $tabs[$i]['id'] ); 
     128                        } 
     129                        array_push( $tbitems, wp_tab_bar_item( __('Search'), "$id-search" ) ); 
     130                        wp_tab_bar( $tbitems ); 
     131 
     132                        foreach( $tabs as $tab ): 
     133                                $data = $tab['data']; 
     134                                $slug = $tab['slug']; 
     135                                ?> 
     136                        <div id="<?php echo $tab['id']; ?>" class="wp-tab-panel"> 
     137                                <?php if ( isset( $data['pages'] ) && ! empty( $data['pages']['page_links'] ) ) : ?> 
     138                                        <div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-top"> 
     139                                                <?php echo $data['pages']['page_links']; ?> 
     140                                        </div> 
     141                                <?php endif; ?> 
     142                                <ul> 
     143                                        <?php 
     144                                        foreach( $data['results'] as $result ): ?> 
     145                                        <li id="link-to-<?php echo "$id-" . esc_attr( $result['ID'] ); ?>"> 
     146                                                <input type="hidden" value="<?php echo esc_url( $result['permalink'] ); ?>" /> 
     147                                                <?php 
     148                                                echo empty( $result['title'] ) ? '<em>' . __('Untitled') . '</em>' : esc_html( $result['title'] ); ?> 
     149                                        </li> 
     150                                        <?php endforeach; ?> 
     151                                </ul> 
     152                                <?php if ( isset( $data['pages'] ) && ! empty( $data['pages']['page_links'] ) ) : ?> 
     153                                        <div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-bottom"> 
     154                                                <?php echo $data['pages']['page_links']; ?> 
     155                                        </div> 
     156                                <?php endif; ?> 
     157                        </div> 
     158                        <?php endforeach; ?> 
     159                        <div id="<?php echo $id; ?>-search" class="wp-tab-panel"> 
     160                                <label for="<?php echo $id; ?>-search-field" class="link-search-wrapper"> 
     161                                        <span><?php _e('Search:'); ?></span> 
     162                                        <input type="text" id="<?php echo $id; ?>-search-field" class="link-search-field" /> 
     163                                        <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 
     164                                </label> 
     165                                <ul id="<?php echo $id; ?>-search-results" class="link-search-results"></ul> 
     166                        </div> 
     167                </div> 
     168        <?php } 
     169} 
     170 
     171function wp_link_query_post_type( $pt_obj, $preset='all', $opts=array() ) { 
     172        $args_base = array( 
     173                'post_type' => $pt_obj->name, 
     174                'suppress_filters' => true, 
     175                'update_post_term_cache' => false, 
     176                'update_post_meta_cache' => false, 
     177                'post_status' => 'publish', 
     178        ); 
     179         
     180        switch( $preset ) { 
     181                case 'all': 
     182                        $args = array_merge( $args_base, array( 
     183                                'order' => 'ASC', 
     184                                'orderby' => 'title', 
     185                                'posts_per_page' => 20, 
     186                        )); 
     187                        break; 
     188                case 'recent': 
     189                        $args = array_merge( $args_base, array( 
     190                                'order' => 'DESC', 
     191                                'orderby' => 'post_date', 
     192                                'posts_per_page' => 15, 
     193                        )); 
     194                        break; 
     195        case 'search': 
     196                $args = array_merge( $args_base, array( 
     197                        's' => $opts['search'], 
     198                        'posts_per_page' => 10 
     199                )); 
     200                break; 
     201        } 
     202         
     203        // Handle pages if a page number is specified. 
     204        if ( isset( $opts['pagenum'] ) && isset( $args['posts_per_page'] ) ) { 
     205                $pages = array( 
     206                        'current' => $opts['pagenum'], 
     207                        'per_page' => $args['posts_per_page'] 
     208                ); 
     209                 
     210                if ( ! isset( $args['offset'] ) ) 
     211                        $args['offset'] = 0 < $opts['pagenum'] ? $args['posts_per_page'] * ( $opts['pagenum'] - 1 ) : 0; 
     212                $pages['offset'] = $args['offset']; 
     213        } 
     214         
     215        // Do main query. 
     216        $get_posts = new WP_Query; 
     217        $posts = $get_posts->query( $args ); 
     218        // Check if any posts were found. 
     219        if ( ! $get_posts->post_count ) 
     220                return false; 
     221         
     222        // Build results. 
     223        $results = array(); 
     224        foreach ( $posts as $post ) { 
     225                $results[] = array( 
     226                        'ID' => $post->ID, 
     227                        'title' => $post->post_title, 
     228                        'permalink' => get_permalink( $post->ID ) 
     229                ); 
     230        } 
     231        // Build response. 
     232        $resp = array( 
     233                'query' => $get_posts, 
     234                'objects' => $posts, 
     235                'results' => $results 
     236        ); 
     237         
     238        // Set remaining pages values. 
     239        if ( isset( $pages ) ) { 
     240                $pages['max'] = $resp['query']->max_num_pages; 
     241                $pages['page_links'] = paginate_links( array( 
     242                        'prev_text' => __('&laquo;'), 
     243                        'next_text' => __('&raquo;'), 
     244                        'total' => $pages['max'], 
     245                        'current' => $pages['current'] 
     246                )); 
     247                $resp['pages'] = $pages; 
     248        } 
     249         
     250        return $resp; 
     251} 
     252 
     253function wp_link_query_taxonomy( $tax_obj, $preset='all', $opts=array() ) { 
     254        switch( $preset ) { 
     255                case 'all': 
     256                        $args = array( 
     257                                'child_of' => 0, 
     258                                'exclude' => '', 
     259                                'hide_empty' => false, 
     260                                'hierarchical' => 1, 
     261                                'include' => '', 
     262                                'include_last_update_time' => false, 
     263                                'number' => 30, 
     264                                'order' => 'ASC', 
     265                                'orderby' => 'name', 
     266                                'pad_counts' => false, 
     267                        ); 
     268                        break; 
     269                case 'popular': 
     270                        $args = array( 
     271                                'orderby' => 'count', 
     272                                'order' => 'DESC', 
     273                                'number' => 10, 
     274                                'hierarchical' => false 
     275                        ); 
     276                        break; 
     277                case 'search': 
     278                        $args = array( 
     279                                'name__like' => $opts['search'], 
     280                                'number' => 10 
     281                        ); 
     282                        break; 
     283        } 
     284         
     285        // Handle pages if a page number is specified. 
     286        if ( isset( $opts['pagenum'] ) && isset( $args['number'] ) ) { 
     287                $pages = array( 
     288                        'current' => $opts['pagenum'], 
     289                        'per_page' => $args['number'] 
     290                ); 
     291                 
     292                $pages['max'] = ceil( wp_count_terms( $tax_obj->name , array_merge( $args, array('number' => '', 'offset' => '') ) ) / $pages['per_page'] ); 
     293                 
     294                if ( ! isset( $args['offset'] ) ) 
     295                        $args['offset'] = 0 < $opts['pagenum'] ? $args['number'] * ( $opts['pagenum'] - 1 ) : 0; 
     296                $pages['offset'] = $args['offset']; 
     297                 
     298                $pages['page_links'] = paginate_links( array( 
     299                        'prev_text' => __('&laquo;'), 
     300                        'next_text' => __('&raquo;'), 
     301                        'total' => $pages['max'], 
     302                        'current' => $pages['current'] 
     303                )); 
     304        } 
     305         
     306        // Do the main query. 
     307        $terms = get_terms( $tax_obj->name, $args ); 
     308        // Check if any terms were found. 
     309        if ( ! $terms || is_wp_error($terms) ) 
     310                return false; 
     311         
     312        // Build results. 
     313        $results = array(); 
     314        foreach ( $terms as $term ) { 
     315                $results[] = array( 
     316                        'ID' => $term->term_id, 
     317                        'title' => $term->name, 
     318                        'permalink' => get_term_link( $term ) 
     319                ); 
     320        } 
     321         
     322        // Build response. 
     323        $resp = array( 
     324                'objects' => $terms, 
     325                'results' => $results 
     326        ); 
     327        if ( isset( $pages ) ) 
     328                $resp['pages'] = $pages; 
     329         
     330        return $resp; 
     331} 
     332?> 
     333 No newline at end of file 
  • wp-admin/admin-ajax.php

     
    11021102 
    11031103        exit; 
    11041104        break; 
     1105case 'wp-link-search': 
     1106        require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link-includes.php'; 
     1107 
     1108        if ( !isset($_REQUEST['type']) || !isset($_REQUEST['name']) || !isset($_REQUEST['title']) ) 
     1109                die('-1'); 
     1110 
     1111        if ( 'pt' == $_REQUEST['type'] && $obj = get_post_type_object($_REQUEST['name']) ) 
     1112                $resp = wp_link_query_post_type( $obj, 'search', array('search' => $_REQUEST['title']) ); 
     1113        else if ( 'tax' == $_REQUEST['type'] && $obj = get_taxonomy($_REQUEST['name']) ) 
     1114                $resp = wp_link_query_taxonomy( $obj, 'search', array('search' => $_REQUEST['title']) ); 
     1115        else 
     1116                die('-1'); 
     1117 
     1118        if ( !$resp ) 
     1119                die('0'); 
     1120 
     1121        echo json_encode($resp['results']); 
     1122        echo "\n"; 
     1123 
     1124        exit; 
     1125        break; 
     1126case 'wp-link-page': 
     1127        require_once ABSPATH . WPINC . '/js/tinymce/wp-mce-link-includes.php'; 
     1128 
     1129        if ( !isset($_REQUEST['type']) || !isset($_REQUEST['name']) || !isset($_REQUEST['page']) ) 
     1130                die('-1'); 
     1131 
     1132        if ( 'pt' == $_REQUEST['type'] && $obj = get_post_type_object($_REQUEST['name']) ) 
     1133                $resp = wp_link_query_post_type( $obj, 'all', array('pagenum' => $_REQUEST['page']) ); 
     1134        else if ( 'tax' == $_REQUEST['type'] && $obj = get_taxonomy($_REQUEST['name']) ) 
     1135                $resp = wp_link_query_taxonomy( $obj, 'all', array('pagenum' => $_REQUEST['page']) ); 
     1136        else 
     1137                die('-1'); 
     1138 
     1139        if ( !$resp ) 
     1140                die('0'); 
     1141 
     1142        echo json_encode( array( 
     1143                'results' => $resp['results'], 
     1144                'page_links' => $resp['pages']['page_links'] 
     1145        )); 
     1146        echo "\n"; 
     1147 
     1148        exit; 
     1149        break; 
    11051150case 'menu-locations-save': 
    11061151        if ( ! current_user_can( 'edit_theme_options' ) ) 
    11071152                die('-1'); 
  • wp-admin/includes/post.php

     
    13111311        $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'); 
    13121312 
    13131313        if ( $teeny ) { 
    1314                 $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'media', 'fullscreen', 'wordpress') ); 
     1314                $plugins = apply_filters( 'teeny_mce_plugins', array('inlinepopups', 'media', 'fullscreen', 'wordpress', 'wplink') ); 
    13151315                $ext_plugins = ''; 
    13161316        } else { 
    1317                 $plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus' ); 
     1317                $plugins = array( 'inlinepopups', 'spellchecker', 'paste', 'wordpress', 'media', 'fullscreen', 'wpeditimage', 'wpgallery', 'tabfocus', 'wplink' ); 
    13181318 
    13191319                /* 
    13201320                The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. 
     
    13981398        $plugins = implode($plugins, ','); 
    13991399 
    14001400        if ( $teeny ) { 
    1401                 $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, link, unlink, fullscreen') ); 
     1401                $mce_buttons = apply_filters( 'teeny_mce_buttons', array('bold, italic, underline, blockquote, separator, strikethrough, bullist, numlist,justifyleft, justifycenter, justifyright, undo, redo, wplink, unlink, fullscreen') ); 
    14021402                $mce_buttons = implode($mce_buttons, ','); 
    14031403                $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = ''; 
    14041404        } else { 
    1405                 $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'link', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); 
     1405                $mce_buttons = apply_filters('mce_buttons', array('bold', 'italic', 'strikethrough', '|', 'bullist', 'numlist', 'blockquote', '|', 'justifyleft', 'justifycenter', 'justifyright', '|', 'wplink', 'unlink', 'wp_more', '|', 'spellchecker', 'fullscreen', 'wp_adv' )); 
    14061406                $mce_buttons = implode($mce_buttons, ','); 
    14071407 
    14081408                $mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|' ); 
  • wp-admin/css/colors-fresh.dev.css

     
    110110} 
    111111 
    112112div.tabs-panel, 
     113.wp-tab-panel, 
    113114ul.category-tabs li.tabs, 
    114 ul.add-menu-item-tabs li.tabs { 
     115ul.add-menu-item-tabs li.tabs, 
     116.wp-tab-active { 
    115117        border-color: #dfdfdf; 
    116118} 
    117119 
    118120ul.category-tabs li.tabs, 
    119 ul.add-menu-item-tabs li.tabs { 
     121ul.add-menu-item-tabs li.tabs, 
     122.wp-tab-active { 
    120123        background-color: #f1f1f1; 
    121124} 
    122125 
     
    382385} 
    383386 
    384387#side-sortables .category-tabs .tabs a, 
    385 #side-sortables .add-menu-item-tabs .tabs a { 
     388#side-sortables .add-menu-item-tabs .tabs a, 
     389.wp-tab-bar .wp-tab-active a { 
    386390        color: #333; 
    387391} 
    388392 
  • wp-admin/css/wp-admin.dev.css

     
    20292029        text-decoration: none; 
    20302030} 
    20312031 
     2032.wp-tab-panel, 
    20322033.categorydiv div.tabs-panel, 
    20332034.customlinkdiv div.tabs-panel, 
    20342035.posttypediv div.tabs-panel, 
     
    20632064} 
    20642065 
    20652066#side-sortables .category-tabs li, 
    2066 #side-sortables .add-menu-item-tabs li { 
     2067#side-sortables .add-menu-item-tabs li, 
     2068.wp-tab-bar li { 
    20672069        display: inline; 
    20682070} 
    20692071 
    20702072#side-sortables .category-tabs a, 
    2071 #side-sortables .add-menu-item-tabs a { 
     2073#side-sortables .add-menu-item-tabs a, 
     2074.wp-tab-bar a { 
    20722075        text-decoration: none; 
    20732076} 
    20742077 
    20752078#side-sortables .category-tabs, 
    2076 #side-sortables .add-menu-item-tabs { 
     2079#side-sortables .add-menu-item-tabs, 
     2080.wp-tab-bar { 
    20772081        margin-bottom: 3px; 
    20782082} 
    20792083 
     
    21102114        margin-bottom: 0px; 
    21112115} 
    21122116 
    2113 .categorydiv .tabs-panel, 
    2114 .customlinkdiv .tabs-panel, 
    2115 .posttypediv .tabs-panel, 
    2116 .taxonomydiv .tabs-panel { 
    2117         border-width: 3px; 
    2118         border-style: solid; 
    2119 } 
    2120  
    21212117ul.category-tabs, 
    2122 ul.add-menu-item-tabs { 
     2118ul.add-menu-item-tabs, 
     2119ul.wp-tab-bar { 
    21232120        margin-top: 12px; 
    21242121} 
    21252122 
    21262123ul.category-tabs li.tabs, 
    2127 ul.add-menu-item-tabs li.tabs { 
     2124ul.add-menu-item-tabs li.tabs, 
     2125.wp-tab-active { 
    21282126        border-style: solid solid none; 
    21292127        border-width: 1px 1px 0; 
    21302128} 
     
    21372135} 
    21382136 
    21392137ul.category-tabs li, 
    2140 ul.add-menu-item-tabs li { 
     2138ul.add-menu-item-tabs li, 
     2139ul.wp-tab-bar li { 
    21412140        padding: 5px; 
    21422141        -moz-border-radius: 3px 3px 0 0; 
    21432142        -webkit-border-top-left-radius: 3px;