Ticket #11420: internal-linking.first-pass.diff
| File internal-linking.first-pass.diff, 17.4 KB (added by , 16 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 : 260, 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 (function($){ 2 var inputs = {}, panels, active, ed, 3 wpLink = { 4 init : function() { 5 var e, etarget, eclass; 6 // Init shared vars 7 ed = tinyMCEPopup.editor; 8 // Secondary options 9 inputs.title = $('#link-title-field'); 10 // Advanced Options 11 inputs.advancedOptions = $('#link-advanced-options'); 12 inputs.target = $('#link-target-select'); 13 inputs['class'] = $('#link-class-select'); 14 // Types 15 inputs.typeDropdown = $('#link-type'); 16 inputs.typeOptions = inputs.typeDropdown.find('option'); 17 18 panels = $('.link-panel'); 19 active = $('.link-panel-active'); 20 21 // Build lists 22 wpLink.fillClassList('link-class-select'); 23 wpLink.fillTargetList('link-target-select'); 24 25 // Extract type names 26 inputs.typeOptions.each( function(){ 27 $(this).data( 'link-type', this.id.replace('link-option-id-','') ); 28 }); 29 panels.each( function(){ 30 $(this).data( 'link-type', this.id.replace('link-panel-id-','') ); 31 }); 32 33 // Bind event handlers 34 inputs.typeDropdown.change( wpLink.selectPanel ); 35 $('#wp-update').click( wpLink.update ); 36 $('#wp-cancel').click( function() { tinyMCEPopup.close(); } ); 37 $('#link-advanced-options-toggle').click( wpLink.toggleAdvancedOptions ); 38 39 // If link exists, select proper values. 40 e = ed.dom.getParent(ed.selection.getNode(), 'A'); 41 if ( ! e ) 42 return; 43 44 // @TODO: select proper panel/fill values when a link is edited 45 active.find('input.url-field').val( e.href ); 46 inputs.title.val( ed.dom.getAttrib(e, 'title') ); 47 // Advanced Options 48 inputs.target.val( etarget = ed.dom.getAttrib(e, 'target') ); 49 inputs['class'].val( eclass = ed.dom.getAttrib(e, 'class') ); 50 if ( etarget || eclass ) // Open the adv. options if one is set. 51 inputs.advancedOptions.toggleClass('adv-options-active'); 52 }, 53 54 update : function() { 55 var ed = tinyMCEPopup.editor, 56 attrs = { 57 href : active.find('input.url-field').val(), 58 title : inputs.title.val(), 59 target : inputs.target.val(), 60 'class' : inputs['class'].val() 61 }, defaultContent, e, b; 62 63 if ( active.hasClass('link-panel-custom') ) 64 defaultContent = attrs.href; 65 else // @TODO: Update to use the title 66 defaultContent = attrs.href; 67 68 tinyMCEPopup.restoreSelection(); 69 e = ed.dom.getParent(ed.selection.getNode(), 'A'); 70 71 // If the values are empty... 72 if ( ! attrs.href ) { 73 // ...and nothing is selected, we should return 74 if ( ed.selection.isCollapsed() ) { 75 tinyMCEPopup.close(); 76 return; 77 // ...and a link exists, we should unlink and return 78 } else if ( e ) { 79 tinyMCEPopup.execCommand("mceBeginUndoLevel"); 80 b = ed.selection.getBookmark(); 81 ed.dom.remove(e, 1); 82 ed.selection.moveToBookmark(b); 83 tinyMCEPopup.execCommand("mceEndUndoLevel"); 84 tinyMCEPopup.close(); 85 return; 86 } 87 } 88 89 tinyMCEPopup.execCommand("mceBeginUndoLevel"); 90 91 if (e == null) { 92 ed.getDoc().execCommand("unlink", false, null); 93 94 // If no selection exists, create a new link from scratch. 95 if ( ed.selection.isCollapsed() ) { 96 var el = ed.dom.create('a', { href: "#mce_temp_url#" }, defaultContent); 97 ed.selection.setNode(el); 98 // If a selection exists, wrap it in a link. 99 } else { 100 tinyMCEPopup.execCommand("CreateLink", false, "#mce_temp_url#", {skip_undo : 1}); 101 } 102 103 tinymce.each(ed.dom.select("a"), function(n) { 104 if (ed.dom.getAttrib(n, 'href') == '#mce_temp_url#') { 105 e = n; 106 ed.dom.setAttribs(e, attrs); 107 } 108 }); 109 } else { 110 ed.dom.setAttribs(e, attrs); 111 } 112 113 // Don't move caret if selection was image 114 if (e.childNodes.length != 1 || e.firstChild.nodeName != 'IMG') { 115 ed.focus(); 116 ed.selection.select(e); 117 ed.selection.collapse(0); 118 tinyMCEPopup.storeSelection(); 119 } 120 121 tinyMCEPopup.execCommand("mceEndUndoLevel"); 122 tinyMCEPopup.close(); 123 }, 124 125 selectPanel : function( option ) { 126 var sel = inputs.typeOptions.filter(':selected'); 127 128 if ( option.jquery ) { 129 sel.removeAttr('selected'); 130 sel = option.attr('selected', 'selected'); 131 } 132 133 active.removeClass('link-panel-active'); 134 active = $('#link-panel-id-' + sel.data('link-type') ).addClass('link-panel-active'); 135 }, 136 137 toggleAdvancedOptions : function() { 138 inputs.advancedOptions.toggleClass('adv-options-active'); 139 return false; 140 }, 141 142 /** 143 * Taken from themes/advanced/js/link.js 144 */ 145 fillClassList : function(id) { 146 var dom = tinyMCEPopup.dom, lst = dom.get(id), v, cl; 147 148 if (v = tinyMCEPopup.getParam('theme_advanced_styles')) { 149 cl = []; 150 151 tinymce.each(v.split(';'), function(v) { 152 var p = v.split('='); 153 154 cl.push({'title' : p[0], 'class' : p[1]}); 155 }); 156 } else 157 cl = tinyMCEPopup.editor.dom.getClasses(); 158 159 if (cl.length > 0) { 160 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); 161 162 tinymce.each(cl, function(o) { 163 lst.options[lst.options.length] = new Option(o.title || o['class'], o['class']); 164 }); 165 } else 166 dom.remove(dom.getParent(id, 'tr')); 167 }, 168 169 /** 170 * Taken from themes/advanced/js/link.js 171 */ 172 fillTargetList : function(id) { 173 var dom = tinyMCEPopup.dom, lst = dom.get(id), v; 174 175 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('not_set'), ''); 176 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_same'), '_self'); 177 lst.options[lst.options.length] = new Option(tinyMCEPopup.getLang('advanced_dlg.link_target_blank'), '_blank'); 178 179 if (v = tinyMCEPopup.getParam('theme_advanced_link_targets')) { 180 tinymce.each(v.split(','), function(v) { 181 v = v.split('='); 182 lst.options[lst.options.length] = new Option(v[0], v[1]); 183 }); 184 } 185 } 186 } 187 188 $(document).ready( wpLink.init ); 189 })(jQuery); 190 No newline at end of file -
wp-includes/js/tinymce/langs/wp-langs-en.js
429 429 caption:"Edit Image Caption", 430 430 alt:"Edit Alternate Text" 431 431 }); 432 433 tinyMCE.addI18n("en.wplink",{ 434 link_desc:"Insert/edit link", 435 unlink_desc:"Unlink (Alt+Shift+S)" 436 }); -
wp-includes/js/tinymce/langs/wp-langs.php
452 452 caption:"' . mce_escape( __('Edit Image Caption') ) . '", 453 453 alt:"' . mce_escape( __('Edit Alternate Text') ) . '" 454 454 }); 455 456 tinyMCE.addI18n("' . $language . '.wplink",{ 457 link_desc:"' . mce_escape( __('Insert/edit link') ) . '", 458 unlink_desc:"' . mce_escape( __('Unlink') ) . ' (Alt+Shift+S)" 459 }); 455 460 '; -
wp-includes/js/tinymce/themes/advanced/skins/wp_theme/ui.css
274 274 .wp_themeSkin span.mce_anchor {background-position:-200px 0} 275 275 .wp_themeSkin span.mce_indent {background-position:-400px 0} 276 276 .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} 278 279 .wp_themeSkin span.mce_unlink {background-position:-640px 0} 279 280 .wp_themeSkin span.mce_sub {background-position:-600px 0} 280 281 .wp_themeSkin span.mce_sup {background-position:-620px 0} -
wp-includes/js/tinymce/wp-mce-link.php
1 <?php 2 /** @ignore */ 3 require_once('../../../wp-load.php'); 4 5 // Set up some vars 6 $pts = get_post_types( array( 'show_ui' => true ), 'objects' ); 7 $taxes = get_taxonomies( array( 'show_ui' => true ), 'objects' ); 8 9 // Helper functions 10 function wp_link_panel_custom() { ?> 11 <div id="link-panel-id-custom" class="link-panel link-panel-custom link-panel-active"> 12 <label> 13 <span><?php _e('URL:'); ?></span><input class="url-field" type="text" /> 14 </label> 15 </div> 16 <?php } 17 function wp_link_panel_post_type( $pt_obj ) { ?> 18 <div id="link-panel-id-<?php echo $pt_obj->name; ?>" class="link-panel link-panel-pt"> 19 <label> 20 <span><?php _e('URL:'); ?></span><input class="url-field" type="text" /> 21 </label> 22 </div> 23 <?php } 24 function wp_link_panel_taxonomy( $tax_obj ) { ?> 25 <div id="link-panel-id-<?php echo $tax_obj->name; ?>" class="link-panel link-panel-tax"> 26 <label> 27 <span><?php _e('URL:'); ?></span><input class="url-field" type="text" /> 28 </label> 29 </div> 30 <?php } 31 32 33 header('Content-Type: text/html; charset=' . get_bloginfo('charset')); 34 ?> 35 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 36 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>> 37 <head> 38 <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" /> 39 <title><?php _e('Insert/edit link') ?></title> 40 <script type="text/javascript" src="tiny_mce_popup.js?ver=3223"></script> 41 <?php 42 wp_print_scripts( array('jquery') ); 43 ?> 44 <script type="text/javascript" src="plugins/wplink/js/wplink.js?ver=1.0"></script> 45 <?php 46 wp_admin_css( 'global', true ); 47 wp_admin_css( 'wp-admin', true ); 48 wp_admin_css( 'colors-fresh', true ); 49 ?> 50 <style> 51 html, body { 52 background: #f1f1f1; 53 } 54 55 a:link, a:visited { 56 color: #21759B; 57 } 58 59 select { 60 height: 2em; 61 } 62 63 #link-header, 64 #link-options, 65 #link-advanced-options { 66 padding: 5px; 67 border-bottom: 1px solid #dfdfdf; 68 } 69 #link-type { 70 width: 140px; 71 } 72 73 .link-panel { 74 padding: 5px 5px 0; 75 display: none; 76 } 77 .link-panel-active { 78 display: block; 79 } 80 81 label input[type="text"] { 82 width: 220px; 83 } 84 85 label span { 86 display: inline-block; 87 width: 80px; 88 text-align: right; 89 padding-right: 5px; 90 } 91 92 #link-advanced-options, 93 #link-advanced-options select, 94 #link-advanced-options option { 95 font-size: 11px; 96 } 97 98 #link-advanced-options { 99 background: #f9f9f9; 100 padding: 3px 5px; 101 } 102 #link-advanced-options label select { 103 width: 195px; 104 } 105 106 #link-advanced-options-toggle { 107 display: block; 108 } 109 110 #link-advanced-options label { 111 padding-top: 2px; 112 display: none; 113 } 114 #link-advanced-options.adv-options-active label { 115 display: block; 116 } 117 118 .submitbox { 119 padding: 5px; 120 font-size: 11px; 121 overflow: auto; 122 height: 29px; 123 } 124 #wp-cancel { 125 line-height: 25px; 126 float: left; 127 } 128 #wp-update { 129 line-height: 23px; 130 float: right; 131 } 132 #wp-update a { 133 display: inline-block; 134 } 135 </style> 136 </head> 137 <body> 138 <div id="link-header"> 139 <label for="link-type"> 140 <span><strong><?php _e('Link Type:'); ?></strong> 141 </span><select id="link-type"> 142 <option id="link-option-id-custom" class="link-custom"><?php _e('External Link'); ?></option> 143 <?php 144 foreach ( $pts as $pt_obj ) 145 echo '<option id="link-option-id-' . $pt_obj->name . '" class="link-option-pt">' . $pt_obj->labels->singular_name . '</option>'; 146 foreach ( $taxes as $tax_obj ) 147 echo '<option id="link-option-id-' . $tax_obj->name . '" class="link-option-tax">' . $tax_obj->labels->singular_name . '</option>'; 148 ?> 149 </select> 150 </label> 151 </div> 152 <div id="link-selector"> 153 <?php 154 wp_link_panel_custom(); 155 foreach ( $pts as $pt_obj ) { 156 wp_link_panel_post_type( $pt_obj ); 157 } 158 foreach ( $taxes as $tax_obj ) { 159 wp_link_panel_taxonomy( $tax_obj ); 160 } 161 ?> 162 <div id="link-options"> 163 <label for="link-title-field"> 164 <span><?php _e('Description:'); ?></span><input id="link-title-field" type="text" /> 165 </label> 166 </div> 167 <div id="link-advanced-options"> 168 <a id="link-advanced-options-toggle" href="#"><?php _e('Advanced Options'); ?></a> 169 <label for="link-target-select"> 170 <span><?php _e('Target:'); ?></span><select id="link-target-select"></select> 171 </label> 172 <label for="link-class-select"> 173 <span><?php _e('Class:'); ?></span><select id="link-class-select"></select> 174 </label> 175 </div> 176 </div> 177 <div class="submitbox"> 178 <div id="wp-cancel"> 179 <a class="submitdelete deletion"><?php _e('Cancel'); ?></a> 180 </div> 181 <div id="wp-update"> 182 <a class="button-primary"><?php _e('Update'); ?></a> 183 </div> 184 </div> 185 </body> 186 </html> -
wp-admin/includes/post.php
1311 1311 $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'); 1312 1312 1313 1313 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') ); 1315 1315 $ext_plugins = ''; 1316 1316 } 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' ); 1318 1318 1319 1319 /* 1320 1320 The following filter takes an associative array of external plugins for TinyMCE in the form 'plugin_name' => 'url'. … … 1398 1398 $plugins = implode($plugins, ','); 1399 1399 1400 1400 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') ); 1402 1402 $mce_buttons = implode($mce_buttons, ','); 1403 1403 $mce_buttons_2 = $mce_buttons_3 = $mce_buttons_4 = ''; 1404 1404 } 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' )); 1406 1406 $mce_buttons = implode($mce_buttons, ','); 1407 1407 1408 1408 $mce_buttons_2 = array('formatselect', 'underline', 'justifyfull', 'forecolor', '|', 'pastetext', 'pasteword', 'removeformat', '|' );