Changeset 16393
- Timestamp:
- 11/15/2010 11:48:24 PM (14 years ago)
- Location:
- trunk/wp-includes/js/tinymce
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js
r15940 r16393 14 14 ed.windowManager.open({ 15 15 file : tinymce.baseURL + '/wp-mce-link.php', 16 width : 320,17 height : 340,16 width : 480, 17 height : 400, 18 18 inline : 1 19 19 }, { -
trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js
r15940 r16393 1 (function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){a.addCommand("WP_Link",function(){a.windowManager.open({file:tinymce.baseURL+"/wp-mce-link.php",width: 320,height:340,inline:1},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(d,c,e){c.setActive("wplink",e.nodeName=="A")})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})();1 (function(){tinymce.create("tinymce.plugins.wpLink",{init:function(a,b){a.addCommand("WP_Link",function(){a.windowManager.open({file:tinymce.baseURL+"/wp-mce-link.php",width:480,height:400,inline:1},{plugin_url:b})});a.addButton("link",{title:a.getLang("advanced.link_desc"),cmd:"WP_Link"});a.addShortcut("alt+shift+a",a.getLang("advanced.link_desc"),"WP_Link");a.onNodeChange.add(function(d,c,e){c.setActive("wplink",e.nodeName=="A")})},getInfo:function(){return{longname:"WordPress Link Dialog",author:"WordPress",authorurl:"http://wordpress.org",infourl:"",version:"1.0"}}});tinymce.PluginManager.add("wplink",tinymce.plugins.wpLink)})(); -
trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js
r16391 r16393 1 (function($){2 $.widget('wp.wpTabs', {3 options: {},4 _create: function() {5 var self = this,6 ul = this.element,7 lis = ul.children();8 9 this.active = lis.filter('.wp-tab-active');10 // Calculate panel IDs11 lis.each(function() {12 var panel = self._getPanel( $(this) );13 if ( self.active[0] == this )14 panel.show();15 else16 panel.hide();17 });18 19 ul.delegate('li', 'click.wpTabs', function(e) {20 var li = $(this);21 22 // Prevent any child link from redirecting the page.23 e.preventDefault();24 // Deactivate previous tab.25 self._getPanel( self.active ).hide();26 self.active.removeClass('wp-tab-active');27 self._trigger("hide", e, self.widget() );28 29 // Activate current tab.30 self.active = li.addClass('wp-tab-active');31 self._getPanel( self.active ).show();32 self._trigger("show", e, self.widget() );33 });34 },35 widget: function() {36 return {37 ul: this.element,38 tab: this.active,39 panel: this._getPanel( this.active )40 };41 },42 _setPanel: function( $el ) {43 var panel = $( '#' + $el.children('.wp-tab-for-id').val() );44 $el.data( 'wp-tab-panel', panel );45 return panel;46 },47 _getPanel: function( $el ) {48 var panel = $el.data('wp-tab-panel');49 return ( !panel || !panel.length ) ? this._setPanel( $el ) : panel;50 }51 });52 // Create tab bars by default.53 $(function(){54 $('.wp-tab-bar').wpTabs();55 });56 })(jQuery);57 58 1 (function($){ 59 var inputs = {}, panels, active, ed,2 var inputs = {}, results = {}, ed, 60 3 wpLink = { 61 4 init : function() { … … 63 6 // Init shared vars 64 7 ed = tinyMCEPopup.editor; 8 9 10 // URL 11 inputs.url = $('#url-field'); 65 12 // Secondary options 66 13 inputs.title = $('#link-title-field'); 67 14 // Advanced Options 68 15 inputs.openInNewTab = $('#link-target-checkbox'); 69 70 panels = $('.link-panel'); 71 active = $('.link-panel-active'); 72 $('#link-panel-tab-bar').wpTabs({ 73 show: function(e, widget) { 74 active = widget.panel; 75 active.addClass('link-panel-active'); 76 wpLink.maybeLoadPanel(); 77 }, 78 hide: function(e, widget) { 79 active.removeClass('link-panel-active'); 80 } 81 }) 82 83 panels.each( function(){ 84 var linkType = this.id.replace(/^link-panel-id-/,''), 85 parts = linkType.split('-'); 86 $(this).data( 'link-type', { 87 full : linkType, 88 type : parts[0], 89 name : parts[1] || '' 90 }); 91 }); 16 inputs.search = $('#search-field'); 17 // Result lists 18 results.search = $('#search-results'); 19 results.recent = $('#most-recent-results'); 92 20 93 21 // Bind event handlers 94 22 $('#wp-update').click( wpLink.update ); 95 23 $('#wp-cancel').click( function() { tinyMCEPopup.close(); } ); 96 $('.link-panel .wp-tab-bar').wpTabs('option', 'show', wpLink.maybeLoadPanel ); 97 $('.link-panel .wp-tab-panel').delegate('li', 'click', wpLink.selectInternalLink ); 98 $('.wp-tab-panel-pagelinks').delegate('a', 'click', wpLink.selectPageLink ); 99 $('.link-panel .link-search-field').keyup( wpLink.searchInternalLinks ); 100 101 active.find('input.url-field').focus(); 24 $('.query-results').delegate('li', 'click', wpLink.selectInternalLink ); 25 $('.wp-results-pagelinks').delegate('a', 'click', wpLink.selectPageLink ); 26 inputs.search.keyup( wpLink.searchInternalLinks ); 102 27 103 28 // If link exists, select proper values. 104 e = ed.dom.getParent(ed.selection.getNode(), 'A'); 105 if ( ! e ) 106 return; 107 108 active.find('input.url-field').val( e.href ); 109 inputs.title.val( ed.dom.getAttrib(e, 'title') ); 110 // Advanced Options 111 112 if ( "_blank" == ed.dom.getAttrib(e, 'target') ) 113 inputs.openInNewTab.attr('checked','checked'); 29 if ( e = ed.dom.getParent(ed.selection.getNode(), 'A') ) { 30 // Set URL and description. 31 inputs.url.val( e.href ); 32 inputs.title.val( ed.dom.getAttrib(e, 'title') ); 33 // Set open in new tab. 34 if ( "_blank" == ed.dom.getAttrib(e, 'target') ) 35 inputs.openInNewTab.attr('checked','checked'); 36 } 114 37 }, 115 38 … … 118 41 ed = tinyMCEPopup.editor, 119 42 attrs = { 43 href : inputs.url.val(), 120 44 title : inputs.title.val(), 121 45 target : inputs.openInNewTab.attr('checked') ? '_blank' : '' 122 }, defaultContent, e, b; 123 124 if ( active.hasClass('link-panel-custom') ) { 125 attrs.href = active.find('input.url-field').val(); 126 defaultContent = attrs.href; 127 } else { 128 el = active.find('li.selected:visible'); 129 if ( !el.length ) 130 return; 131 132 attrs.href = el.children('input').val(); 133 defaultContent = el.text(); 134 } 46 }, e, b, 47 defaultContent = attrs.title ? attrs.title : attrs.href; 135 48 136 49 tinyMCEPopup.restoreSelection(); … … 191 104 }, 192 105 193 maybeLoadPanel : function() {194 var panel = active.find('.wp-tab-panel:visible');195 if ( panel.length && panel.find('.wp-tab-panel-loading').length )196 wpLink.linkPanelAJAX( panel );197 },198 199 linkPanelAJAX : function( $panel, params, callback ) {200 if ( ! $panel.hasClass('wp-tab-panel') )201 $panel = $panel.parents('.wp-tab-panel');202 203 if ( ! $panel.length )204 return;205 206 var query = $panel.children('.wp-tab-panel-query').val();207 208 wpLink.linkAJAX( $panel, $.extend({209 preset : query,210 page : 'all' == query ? 1 : 0211 }, params), function(r, lt) {212 var pagelinks = $panel.children('.wp-tab-panel-pagelinks');213 214 // Set results215 $panel.children('ul').html( wpLink.generateListMarkup( r['results'], lt ) );216 217 // Handle page links218 if ( r['page_links'] )219 pagelinks.html( r['page_links'] ).show();220 else221 pagelinks.hide();222 // Run callback223 if ( callback )224 callback(r, lt);225 })226 },227 228 106 selectInternalLink : function() { 229 107 var t = $(this); … … 232 110 t.siblings('.selected').removeClass('selected'); 233 111 t.addClass('selected'); 112 inputs.url.val( t.children('.item-permalink').val() ); 113 inputs.title.val( t.children('.item-title').text() ); 234 114 }, 235 115 … … 240 120 e.preventDefault(); // Prevent the link from redirecting. 241 121 242 wpLink.link PanelAJAX( $(this), { page : page });122 wpLink.linkAJAX( $(this), { page : page }); 243 123 }, 244 124 245 125 searchInternalLinks : function() { 246 var t = $(this), 126 var t = $(this), waiting, 127 title = t.val(); 128 129 if ( title ) { 130 results.recent.hide(); 131 results.search.show(); 247 132 waiting = t.siblings('img.waiting').show(); 248 249 wpLink.linkPanelAJAX( t, { title : t.val() }, function(){ waiting.hide(); }); 133 wpLink.linkAJAX( results.search, { title : title }, function(){ waiting.hide(); }); 134 } else { 135 results.search.hide(); 136 results.recent.show(); 137 } 250 138 }, 251 139 252 linkAJAX : function( el, params, callback ) { 253 var linkType = el.parents('.link-panel').data('link-type'); 140 linkAJAX : function( $panel, params, callback ) { 141 if ( ! $panel.hasClass('query-results') ) 142 $panel = $panel.parents('.query-results'); 143 144 if ( ! $panel.length ) 145 return; 146 254 147 $.post( ajaxurl, $.extend({ 255 action : 'wp-link-ajax', 256 type : linkType.type, 257 name : linkType.name 148 action : 'wp-link-ajax' 258 149 }, params ), function(r) { 259 return callback(r, linkType); 150 var pagelinks = $panel.children('.wp-results-pagelinks'); 151 152 // Set results 153 $panel.children('ul').html( wpLink.generateListMarkup( r['results'] ) ); 154 155 // Handle page links 156 if ( r['page_links'] ) 157 pagelinks.html( r['page_links'] ).show(); 158 else 159 pagelinks.hide(); 160 161 // Run callback 162 if ( callback ) 163 callback( r['results'] ); 260 164 }, "json" ); 261 165 }, 262 166 263 generateListMarkup : function( results , linkType) {167 generateListMarkup : function( results ) { 264 168 var s = ''; 265 169 266 170 if ( ! results ) 267 return '<li class="no-matches-found unselectable">< em>' + wpLinkL10n.noMatchesFound + '</em></li>';171 return '<li class="no-matches-found unselectable"><span class="item-title"><em>' + wpLinkL10n.noMatchesFound + '</em></span></li>'; 268 172 269 173 $.each( results, function() { 270 s+= '<li id="link-to-' + linkType.full + '-' + this['ID'] + '">';271 s+= '< input type="hidden" value="' + this['permalink'] + '" />';174 s+= '<li><input type="hidden" class="item-permalink" value="' + this['permalink'] + '" />'; 175 s+= '<span class="item-title">' 272 176 s+= this['title'] ? this['title'] : '<em>'+ wpLinkL10n.untitled + '</em>'; 177 s+= '</span><span class="item-info">' + this['info'] + '</span>'; 273 178 s+= '</li>'; 274 179 }); -
trunk/wp-includes/js/tinymce/wp-mce-link-includes.php
r16159 r16393 1 1 <?php 2 // args expects optionally 'pagenum' and 's' 3 function wp_link_query( $args = array() ) { 4 $pts = get_post_types( array( 'publicly_queryable' => true ), 'objects' ); 5 $pt_names = array_keys( $pts ); 2 6 3 class WP_Tab_Bar { 4 var $tabs = array(); 5 6 var $id = ''; 7 var $classes = array(); 8 9 var $selected = ''; 10 11 function add( $id, $label, $url='' ) { 12 array_push( $this->tabs, array( 13 'label' => $label, 14 'for' => $id, 15 'url' => $url 16 )); 17 } 18 19 function select( $id ) { 20 $this->selected = $id; 21 } 22 23 function render( $echo=true ) { 24 if ( empty( $this->selected ) ) 25 $this->selected = $this->tabs[0]['for']; 26 27 array_unshift( $this->classes, 'wp-tab-bar' ); 28 29 $out = "<ul id='$this->id' class='" . esc_attr( implode( ' ', $this->classes ) ) . "'>"; 30 foreach( $this->tabs as $tab ) { 31 if ( !isset($tab['url']) ) 32 $tab['url'] = ''; 33 34 $out.= "<li class='"; 35 $out.= $this->selected == $tab['for'] ? 'wp-tab-active' : ''; 36 $out.= "'><input type='hidden' class='wp-tab-for-id' value='{$tab['for']}' />"; 37 $out.= "<a href='{$tab['url']}#{$tab['for']}'>"; 38 $out.= "{$tab['label']}</a></li>"; 39 } 40 $out.= "</ul>"; 41 42 if ( $echo ) 43 echo $out; 44 45 return $out; 46 } 47 } 48 49 function wp_link_panel_custom() { ?> 50 <div id="link-panel-id-custom" class="link-panel link-panel-custom link-panel-active"> 51 <input type="hidden" class="link-panel-type" value="custom" /> 52 <label> 53 <span><?php _e('URL:'); ?></span><input class="url-field" type="text" /> 54 </label> 55 </div> 56 <?php } 57 58 function wp_link_panel_structure( $panel_type, $name, $queries ) { 59 $id = $panel_type . '-' . $name; 60 61 ?> 62 <div id="link-panel-id-<?php echo $id; ?>" class="link-panel link-panel-<?php echo $panel_type; ?>"> 63 <!-- <input type="hidden" class="link-panel-type" value="<?php echo $panel_type; ?>" /> --> 64 <!-- <input type="hidden" class="link-panel-id" value="" /> --> 65 <?php 66 67 $tb = new WP_Tab_Bar(); 68 foreach( $queries as $i => $query ) { 69 $queries[$i]['id'] = "$id-{$query['preset']}"; 70 $tb->add( $queries[$i]['id'], $query['label'] ); 71 } 72 $tb->render(); 73 74 foreach( $queries as $query ): ?> 75 <div id="<?php echo $query['id']; ?>" class="wp-tab-panel"> 76 <input type="hidden" class="wp-tab-panel-query" value="<?php echo $query['preset']; ?>" /> 77 78 <?php if ( 'search' == $query['preset'] ): ?> 79 <label for="<?php echo $id; ?>-search-field" class="link-search-wrapper"> 80 <span><?php _e('Search:'); ?></span> 81 <input type="text" id="<?php echo $id; ?>-search-field" class="link-search-field" /> 82 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 83 </label> 84 <ul id="<?php echo $id; ?>-search-results" class="link-search-results"></ul> 85 86 <?php else: ?> 87 <div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-top"></div> 88 <ul> 89 <li class="wp-tab-panel-loading unselectable"><em><?php _e('Loading...'); ?></em></li> 90 </ul> 91 <div class="wp-tab-panel-pagelinks wp-tab-panel-pagelinks-bottom"></div> 92 <?php endif; ?> 93 </div> 94 <?php endforeach; ?> 95 </div> 96 <?php } 97 98 function wp_link_query_post_type( $pt_obj, $preset='all', $opts=array() ) { 99 $args_base = array( 100 'post_type' => $pt_obj->name, 7 $query = array( 8 'post_type' => $pt_names, 101 9 'suppress_filters' => true, 102 10 'update_post_term_cache' => false, 103 11 'update_post_meta_cache' => false, 104 12 'post_status' => 'publish', 13 'order' => 'DESC', 14 'orderby' => 'post_date', 15 'posts_per_page' => 20, 105 16 ); 106 107 switch( $preset ) { 108 case 'all': 109 $args = array_merge( $args_base, array( 110 'order' => 'ASC', 111 'orderby' => 'title', 112 'posts_per_page' => 20, 113 )); 114 break; 115 case 'recent': 116 $args = array_merge( $args_base, array( 117 'order' => 'DESC', 118 'orderby' => 'post_date', 119 'posts_per_page' => 15, 120 )); 121 break; 122 case 'search': 123 $args = array_merge( $args_base, array( 124 's' => isset($opts['search']) ? $opts['search'] : '', 125 'posts_per_page' => 10 126 )); 127 break; 128 } 129 130 // Handle pages if a page number is specified. 131 if ( isset( $opts['pagenum'] ) && isset( $args['posts_per_page'] ) ) { 132 $pages = array( 133 'current' => $opts['pagenum'], 134 'per_page' => $args['posts_per_page'] 135 ); 136 137 if ( ! isset( $args['offset'] ) ) 138 $args['offset'] = 0 < $opts['pagenum'] ? $args['posts_per_page'] * ( $opts['pagenum'] - 1 ) : 0; 139 $pages['offset'] = $args['offset']; 140 } 141 142 // Allow args to be extended. 143 if ( isset( $opts['args'] ) ) 144 $args = array_merge( $args, $opts['args'] ); 145 17 18 $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1; 19 20 if ( isset( $args['s'] ) ) 21 $query['s'] = $args['s']; 22 23 $pagination = array( 24 'current' => $args['pagenum'], 25 'per_page' => $query['posts_per_page'], 26 ); 27 28 $query['offset'] = $pagination['offset'] = $args['pagenum'] > 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0; 29 146 30 // Do main query. 147 31 $get_posts = new WP_Query; 148 $posts = $get_posts->query( $ args);32 $posts = $get_posts->query( $query ); 149 33 // Check if any posts were found. 150 34 if ( ! $get_posts->post_count ) … … 154 38 $results = array(); 155 39 foreach ( $posts as $post ) { 40 if ( 'post' == $post->post_type ) 41 $info = mysql2date( __( 'Y/m/d' ), $post->post_date ); 42 else 43 $info = $pts[ $post->post_type ]->labels->singular_name; 44 156 45 $results[] = array( 157 46 'ID' => $post->ID, 158 'title' => $post->post_title, 159 'permalink' => get_permalink( $post->ID ) 160 ); 47 'title' => esc_html( strip_tags($post->post_title) ), 48 'permalink' => get_permalink( $post->ID ), 49 'info' => $info, 50 );; 161 51 } 52 53 // Remaining pagination values. 54 $pagination['max'] = $get_posts->max_num_pages; 55 $pagination['page_links'] = paginate_links( array( 56 'prev_text' => __('«'), 57 'next_text' => __('»'), 58 'total' => $pagination['max'], 59 'current' => $pagination['current'] 60 ) ); 61 162 62 // Build response. 163 63 $resp = array( 164 64 'query' => $get_posts, 165 65 'objects' => $posts, 166 'results' => $results 66 'results' => $results, 67 'pages' => $pagination, 167 68 ); 168 169 // Set remaining pages values. 170 if ( isset( $pages ) ) { 171 $pages['max'] = $resp['query']->max_num_pages; 172 $pages['page_links'] = paginate_links( array( 173 'prev_text' => __('«'), 174 'next_text' => __('»'), 175 'total' => $pages['max'], 176 'current' => $pages['current'] 177 )); 178 $resp['pages'] = $pages; 179 } 180 69 181 70 return $resp; 182 71 } 183 72 184 73 function wp_link_ajax( $request ) { 185 if ( !isset($request['type']) || !isset($request['name']) || !isset($request['preset']) ) 186 die('-1'); 74 // Searches have a title term. 75 if ( isset( $request['title'] ) ) 76 $args['s'] = stripslashes( $request['title'] ); 77 $args['pagenum'] = ! empty( $request['page'] ) ? absint( $request['page'] ) : 1; 187 78 188 // Run only presets we recognize. 189 if ( 'pt' != $request['type'] || ! in_array( $request['preset'], array('all','search','recent') ) ) 190 die('-1'); 191 // Searches must have a search term. 192 else if ( 'search' == $request['preset'] && !isset($request['title']) ) 193 die('-1'); 194 195 $opts = array(); 196 if ( 'search' == $request['preset'] ) { 197 $opts['search'] = $request['title']; 198 } else if ( ! empty( $request['page'] ) ) { 199 $opts['pagenum'] = $request['page']; 200 } 201 202 if ( 'pt' == $request['type'] && $obj = get_post_type_object($request['name']) ) 203 $resp = wp_link_query_post_type( $obj, $request['preset'], $opts ); 79 $resp = wp_link_query( $args ); 204 80 205 81 if ( ! isset( $resp ) ) 206 die( '0');82 die( '0' ); 207 83 208 84 $json = array( 'results' => $resp['results'] ); … … 213 89 echo "\n"; 214 90 } 91 215 92 ?> -
trunk/wp-includes/js/tinymce/wp-mce-link.php
r16159 r16393 24 24 wp_print_scripts( array('jquery', 'jquery-ui-widget') ); 25 25 ?> 26 <script type="text/javascript" src="plugins/wplink/js/wplink.js?ver=20101023"></script> 26 <?php 27 $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '.dev' : ''; 28 $src = "plugins/wplink/js/wplink$suffix.js?ver=20101023"; 29 ?> 30 <script type="text/javascript" src="<?php echo $src; ?>"></script> 27 31 <?php 28 32 wp_admin_css( 'global', true ); … … 44 48 } 45 49 46 #link-header,47 50 #link-options, 48 51 #link-advanced-options { … … 50 53 border-bottom: 1px solid #dfdfdf; 51 54 } 52 #link-header {53 padding-bottom: 0;54 background: #fff;55 }56 #link-panel-tab-bar li {57 font-weight: bold;58 border: #dfdfdf solid;59 margin-right: 5px;60 border-width: 1px 1px 0;61 }62 #link-panel-tab-bar .wp-tab-active {63 border-color:#ccc;64 background-color: #f1f1f1;65 }66 55 67 56 #link-type { … … 78 67 79 68 label input[type="text"] { 80 width: 220px; 81 } 82 .wp-tab-panel label input[type="text"] { 83 float: left; 84 width: 200px; 85 } 69 width: 360px; 70 margin-top: 5px; 71 } 86 72 87 73 label span { … … 91 77 padding-right: 5px; 92 78 } 93 .wp-tab-panel label span {94 width: auto;95 text-align: left;96 float: left;97 margin-top: 3px;98 }99 79 .link-search-wrapper { 100 80 padding: 5px; 101 border-bottom: solid 1px #dfdfdf;102 81 display: block; 103 82 overflow: hidden; 104 83 } 84 .link-search-wrapper span { 85 float: left; 86 margin-top: 6px; 87 } 88 .link-search-wrapper input[type="text"] { 89 float: left; 90 width: 220px; 91 } 105 92 .link-search-wrapper img.waiting { 106 margin: 4px 1px 0 4px;93 margin: 8px 1px 0 4px; 107 94 float: left; 108 95 display: none; … … 117 104 font-size: 11px; 118 105 } 106 107 .query-results { 108 border: #dfdfdf solid; 109 border-width: 1px 0; 110 margin: 5px 0; 111 background: #fff; 112 height: 220px; 113 overflow: auto; 114 } 115 .query-results li { 116 margin-bottom: 0; 117 border-bottom: 1px solid #dfdfdf; 118 color: #555; 119 padding: 4px 6px; 120 cursor: pointer; 121 } 122 .query-results li:hover { 123 background: #EAF2FA; 124 color: #333; 125 } 126 .query-results li.selected { 127 background: #f1f1f1; 128 font-weight: bold; 129 color: #333; 130 } 131 .item-info { 132 text-transform: uppercase; 133 color: #aaa; 134 font-weight: bold; 135 font-size: 11px; 136 float: right; 137 } 138 #search-results { 139 display: none; 140 } 141 142 .wp-results-pagelinks { 143 padding:4px 0; 144 margin:0 auto; 145 text-align:center; 146 } 147 .wp-results-pagelinks-top { 148 border-bottom: 1px solid #dfdfdf; 149 } 119 150 120 151 .submitbox { 121 padding: 5px ;152 padding: 5px 5px 0; 122 153 font-size: 11px; 123 154 overflow: auto; … … 135 166 display: inline-block; 136 167 } 137 .wp-tab-active,138 .wp-tab-panel {139 background: #fff;140 }141 .wp-tab-panel {142 height: 160px;143 padding: 0;144 }145 .wp-tab-panel li {146 margin-bottom: 0;147 border-bottom: 1px solid #dfdfdf;148 color: #555;149 padding: 4px 6px;150 cursor: pointer;151 }152 .wp-tab-panel li:hover {153 background: #EAF2FA;154 color: #333;155 }156 .wp-tab-panel li.selected {157 background: #f1f1f1;158 font-weight: bold;159 color: #333;160 }161 .wp-tab-panel-pagelinks {162 display: none;163 padding:4px 0;164 margin:0 auto;165 text-align:center;166 }167 .wp-tab-panel-pagelinks-top {168 border-bottom: 1px solid #dfdfdf;169 }170 168 </style> 171 169 </head> 172 170 <?php 173 // @TODO: Support custom post types.174 // $pts = get_post_types( array( 'public' => true ), 'objects' );175 $pts = array( get_post_type_object( 'post' ), get_post_type_object( 'page' ) );176 $queries = array(177 array( 'preset' => 'all', 'label' => __('View All') ),178 array( 'preset' => 'recent', 'label' => __('Most Recent') ),179 array( 'preset' => 'search', 'label' => __('Search') )180 );181 182 $tb = new WP_Tab_Bar();183 $tb->id = 'link-panel-tab-bar';184 $tb->add( 'link-panel-id-custom', __('External Link') );185 foreach( $pts as $pt ) {186 $tb->add( "link-panel-id-pt-$pt->name", $pt->labels->singular_name );187 }188 171 189 172 190 173 ?> 191 174 <body id="post-body"> 192 <div id="link-header">193 <?php $tb->render(); ?>194 </div>195 175 <div id="link-selector"> 196 <?php197 wp_link_panel_custom();198 foreach( $pts as $pt )199 wp_link_panel_structure('pt', $pt->name, $queries);200 ?>201 176 <div id="link-options"> 177 <label for="url-field"> 178 <span><?php _e('URL:'); ?></span><input id="url-field" type="text" /> 179 </label> 202 180 <label for="link-title-field"> 203 181 <span><?php _e('Description:'); ?></span><input id="link-title-field" type="text" /> … … 206 184 <input type="checkbox" id="link-target-checkbox" /><span><?php _e('Open in new tab'); ?></span> 207 185 </label> 186 </div> 187 <div id="search-panel"> 188 <label for="search-field" class="link-search-wrapper"> 189 <span><?php _e('Search:'); ?></span> 190 <input type="text" id="search-field" class="link-search-field" /> 191 <img class="waiting" src="<?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?>" alt="" /> 192 </label> 193 194 <div id="search-results" class="query-results"> 195 <div class="wp-results-pagelinks wp-results-pagelinks-top"></div> 196 <ul> 197 <li class="wp-results-loading unselectable"><em><?php _e('Loading...'); ?></em></li> 198 </ul> 199 <div class="wp-results-pagelinks wp-results-pagelinks-bottom"></div> 200 </div> 201 202 <?php $most_recent = wp_link_query(); ?> 203 <div id="most-recent-results" class="query-results"> 204 <div class="wp-results-pagelinks wp-results-pagelinks-top"> 205 <?php echo $most_recent['pages']['page_links']; ?> 206 </div> 207 <ul> 208 <?php foreach ( $most_recent['results'] as $item ): ?> 209 <li> 210 <input type="hidden" class="item-permalink" value="<?php echo esc_url( $item['permalink'] ); ?>" /> 211 <span class="item-title"><?php echo $item['title']; ?></span> 212 <span class="item-info"><?php echo esc_html( $item['info'] ); ?></span> 213 </li> 214 <?php endforeach; ?> 215 </ul> 216 <div class="wp-results-pagelinks wp-results-pagelinks-bottom"> 217 <?php echo $most_recent['pages']['page_links']; ?> 218 </div> 219 </div> 208 220 </div> 209 221 </div>
Note: See TracChangeset
for help on using the changeset viewer.