Changeset 16038 for trunk/wp-includes/admin-bar.php
- Timestamp:
- 10/28/2010 08:31:36 AM (15 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/admin-bar.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/admin-bar.php
r15938 r16038 7 7 8 8 /** 9 * Instantiate the admin bar class and set it up as a global for access elsewhere. 9 * Instantiate the admin bar object and set it up as a global for access elsewhere. 10 * 11 * @since 3.1.0 12 * @return bool Whether the admin bar was successfully initialized. 10 13 */ 11 14 function wp_admin_bar_init() { 12 global $ current_user, $pagenow, $wp_admin_bar;13 14 if ( ! show_admin_bar() )15 global $wp_admin_bar; 16 17 if ( ! is_admin_bar_showing() ) 15 18 return false; 16 17 /* Set the protocol constant used throughout this code */18 if ( !defined( 'PROTO' ) )19 if ( is_ssl() ) define( 'PROTO', 'https://' ); else define( 'PROTO', 'http://' );20 21 /* Don't load the admin bar if the user is not logged in */22 if ( !is_user_logged_in() )23 return false;24 25 /* Set up the settings we need to render menu items */26 if ( !is_object( $current_user ) )27 $current_user = wp_get_current_user();28 29 /* Enqueue the JS files for the admin bar. */30 wp_enqueue_script( 'jquery', false, false, false, true );31 19 32 20 /* Load the admin bar class code ready for instantiation */ 33 21 require( ABSPATH . WPINC . '/admin-bar/admin-bar-class.php' ); 34 22 35 /* Only load super admin menu code if the logged in user is a super admin */ 36 if ( is_super_admin() ) { 37 require( ABSPATH . WPINC . '/admin-bar/admin-bar-debug.php' ); 38 require( ABSPATH . WPINC . '/admin-bar/admin-bar-superadmin.php' ); 39 } 40 41 /* Initialize the admin bar */ 42 $wp_admin_bar = new wp_admin_bar(); 43 44 add_action( 'wp_head', 'wp_admin_bar_css' ); 45 add_action( 'admin_head', 'wp_admin_bar_css' ); 46 47 do_action('admin_bar_init'); 23 /* Instantiate the admin bar */ 24 $admin_bar_class = apply_filters( 'wp_admin_bar_class', 'WP_Admin_Bar' ); 25 if ( class_exists( $admin_bar_class ) ) 26 $wp_admin_bar = new $admin_bar_class; 27 else 28 return false; 29 30 $wp_admin_bar->initialize(); 31 $wp_admin_bar->add_menus(); 32 33 return true; 48 34 } 49 35 add_action( 'init', 'wp_admin_bar_init' ); … … 57 43 * add new menus to the admin bar. That way you can be sure that you are adding at most optimal point, 58 44 * right before the admin bar is rendered. This also gives you access to the $post global, among others. 45 * 46 * @since 3.1.0 59 47 */ 60 48 function wp_admin_bar_render() { 61 49 global $wp_admin_bar; 62 50 63 if ( ! is_object( $wp_admin_bar ) )51 if ( ! is_object( $wp_admin_bar ) ) 64 52 return false; 65 53 … … 79 67 /** 80 68 * Show the logged in user's gravatar as a separator. 69 * 70 * @since 3.1.0 81 71 */ 82 72 function wp_admin_bar_me_separator() { 83 global $wp_admin_bar, $current_user; 84 85 if ( !is_object( $wp_admin_bar ) ) 86 return false; 87 88 $wp_admin_bar->add_menu( array( 'id' => 'me', 'title' => get_avatar( $current_user->ID, 16 ), 'href' => $wp_admin_bar->user->account_domain . 'wp-admin/profile.php' ) ); 89 } 90 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_me_separator', 10 ); 91 92 /** 93 * Use the $wp_admin_bar global to add the "My Account" menu and all submenus. 73 global $wp_admin_bar; 74 $wp_admin_bar->add_menu( array( 'id' => 'me', 'title' => get_avatar( get_current_user_id(), 16 ), 'href' => admin_url('profile.php'), ) ); 75 } 76 77 /** 78 * Add the "My Account" menu and all submenus. 79 * 80 * @since 3.1.0 94 81 */ 95 82 function wp_admin_bar_my_account_menu() { 96 global $wp_admin_bar, $current_user; 97 98 if ( !is_object( $wp_admin_bar ) ) 99 return false; 83 global $wp_admin_bar; 100 84 101 85 /* Add the 'My Account' menu */ 102 $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php')) );86 $wp_admin_bar->add_menu( array( 'id' => 'my-account', 'title' => __( 'My Account' ), 'href' => admin_url('profile.php'), ) ); 103 87 104 88 /* Add the "My Account" sub menus */ 105 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php') ) ); 106 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url() ) ); 107 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url() ) ); 108 } 109 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_account_menu', 20 ); 110 111 /** 112 * Use the $wp_admin_bar global to add the "My Sites/[Site Name]" menu and all submenus. 89 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Edit My Profile' ), 'href' => admin_url('profile.php'), ) ); 90 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Global Dashboard' ), 'href' => admin_url(), ) ); 91 $wp_admin_bar->add_menu( array( 'parent' => 'my-account', 'title' => __( 'Log Out' ), 'href' => wp_logout_url(), ) ); 92 } 93 94 /** 95 * Add the "My Sites/[Site Name]" menu and all submenus. 96 * 97 * @since 3.1.0 113 98 */ 114 99 function wp_admin_bar_my_blogs_menu() { 115 100 global $wpdb, $wp_admin_bar; 116 101 117 if ( !is_object( $wp_admin_bar ) )118 return false;119 120 102 /* Add the 'My Dashboards' menu if the user has more than one site. */ 121 103 if ( count( $wp_admin_bar->user->blogs ) > 1 ) { 122 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => $wp_admin_bar->user->account_domain) );104 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Sites' ), 'href' => $wp_admin_bar->user->account_domain, ) ); 123 105 124 106 $default = includes_url('images/wpmini-blue.png'); 125 107 126 $counter = 2;127 108 foreach ( (array) $wp_admin_bar->user->blogs as $blog ) { 128 109 $blogdomain = preg_replace( '!^https?://!', '', $blog->siteurl ); 129 110 // @todo Replace with some favicon lookup. 130 111 //$blavatar = '<img src="' . esc_url( blavatar_url( blavatar_domain( $blog->siteurl ), 'img', 16, $default ) ) . '" alt="Blavatar" width="16" height="16" />'; 131 $blavatar = '<img src="' . esc_url($default) . '" alt=" Blavatar" width="16" height="16" />';;112 $blavatar = '<img src="' . esc_url($default) . '" alt="' . esc_attr__( 'Blavatar' ) . '" width="16" height="16" />'; 132 113 133 114 $marker = ''; … … 140 121 $blogname = substr( $blog->blogname, 0, 35 ) . $marker; 141 122 142 if ( !isset( $blog->visible ) || $blog->visible === true ) { 143 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) ); 144 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/' ) ); 145 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/post-new.php' ) ); 123 if ( ! isset( $blog->visible ) || $blog->visible === true ) { 124 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-' . $blog->userblog_id, 'title' => $blavatar . $blogname, 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/', ) ); 125 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-d', 'title' => __( 'Dashboard' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/', ) ); 126 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-n', 'title' => __( 'New Post' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/post-new.php', ) ); 127 146 128 // @todo, stats plugins should add this: 147 //$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-s', 'title' => __( 'Site Stats' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/index.php?page=stats' ) ); 148 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => constant( 'PROTO' ) . $blogdomain . '/wp-admin/edit-comments.php' ) ); 149 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Site' ), 'href' => constant( 'PROTO' ) . $blogdomain ) ); 129 //$wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-s', 'title' => __( 'Site Stats' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/index.php?page=stats' ) ); 130 131 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-c', 'title' => __( 'Manage Comments' ), 'href' => $wp_admin_bar->proto . $blogdomain . '/wp-admin/edit-comments.php', ) ); 132 $wp_admin_bar->add_menu( array( 'parent' => 'blog-' . $blog->userblog_id, 'id' => 'blog-' . $blog->userblog_id . '-v', 'title' => __( 'Read Site' ), 'href' => $wp_admin_bar->proto . $blogdomain, ) ); 150 133 } 151 $counter++;152 134 } 153 135 154 136 /* Add the "Manage Sites" menu item */ 155 137 // @todo, use dashboard site. 156 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php') ) );138 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'manage-blogs', 'title' => __( 'Manage Sites' ), admin_url('my-sites.php'), ) ); 157 139 158 140 /* Add the 'My Dashboard' menu if the user only has one site. */ 159 141 } else { 160 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain ) );161 162 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1- d', 'title' => __( 'Dashboard' ), 'href' => admin_url()) );163 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php') ) ); 142 $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Site' ), 'href' => $wp_admin_bar->user->account_domain, ) ); 143 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-d', 'title' => __( 'Dashboard' ), 'href' => admin_url(),) ); 144 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-n', 'title' => __( 'New Post' ), 'href' => admin_url('post-new.php'),) ); 145 164 146 // @todo Stats plugins should add this. 165 147 //$wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-s', 'title' => __( 'Site Stats' ), 'href' => admin_ur;('index.php?page=stats') ) ); 166 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c', 'title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php') ) ); 167 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url() ) ); 148 149 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-c','title' => __( 'Manage Comments' ), 'href' => admin_url('edit-comments.php'), ) ); 150 $wp_admin_bar->add_menu( array( 'parent' => 'my-blogs', 'id' => 'blog-1-v', 'title' => __( 'Read Site' ), 'href' => home_url(),) ); 168 151 } 169 152 } 170 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_my_blogs_menu', 30 );171 153 172 154 /** 173 155 * Show the blavatar of the current site as a separator. 156 * 157 * @since 3.1.0 174 158 */ 175 159 function wp_admin_bar_blog_separator() { 176 global $wp_admin_bar, $current_user, $current_blog; 177 178 if ( !is_object( $wp_admin_bar ) ) 160 global $wp_admin_bar, $current_blog; 161 $default = includes_url('images/wpmini-blue.png'); 162 $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '<img class="avatar" src="' . $default . '" alt="' . esc_attr__( 'Current site avatar' ) . '" width="16" height="16" />', 'href' => home_url(), ) ); 163 } 164 165 /** 166 * Site info menu 167 * 168 * @since 3.1.0 169 */ 170 function wp_admin_bar_bloginfo_menu() { 171 global $wp_admin_bar; 172 173 /* Add the Site Info menu */ 174 $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '', ) ); 175 176 // TODO: Move this js out into a seperate file? 177 $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array( 178 'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName('link');var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute('rel')=='shortlink') {found=l.getAttribute('href');break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute('rel') == 'shortlink') {found = l.getAttribute('href');break;}}}if (found) {prompt('' . esc_js( __( 'URL:' ) ) . '', found);} else {alert('' . esc_js( __( 'No shortlink available for this page.' ) ) . ''); } } wpcomshort(); return false;' ) ) ); 179 } 180 181 /** 182 * Provide an edit link for posts and terms. 183 * 184 * @since 3.1.0 185 */ 186 function wp_admin_bar_edit_menu() { 187 global $wp_admin_bar, $wp_query; 188 189 $current_object = $wp_query->get_queried_object(); 190 191 if ( empty( $current_object ) ) 179 192 return false; 180 193 181 $default = includes_url('images/wpmini-blue.png'); 182 183 $wp_admin_bar->add_menu( array( 'id' => 'blog', 'title' => '<img class="avatar" src="' . $default . '" alt="' . __( 'Current site avatar' ) . '" width="16" height="16" />', 'href' => home_url() ) ); 184 } 185 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_blog_separator', 40 ); 186 187 /** 188 * Use the $wp_admin_bar global to add a menu for site info, accessable to all users. 189 */ 190 function wp_admin_bar_bloginfo_menu() { 191 global $wp_admin_bar; 192 193 if ( !is_object( $wp_admin_bar ) ) 194 return false; 195 196 /* Add the Site Info menu */ 197 $wp_admin_bar->add_menu( array( 'id' => 'bloginfo', 'title' => __( 'Site Info' ), 'href' => '' ) ); 198 199 $wp_admin_bar->add_menu( array( 'parent' => 'bloginfo', 'title' => __( 'Get Shortlink' ), 'href' => '', 'meta' => array( 'onclick' => 'javascript:function wpcomshort() { var url=document.location;var links=document.getElementsByTagName('link');var found=0;for(var i = 0, l; l = links[i]; i++){if(l.getAttribute('rel')=='shortlink') {found=l.getAttribute('href');break;}}if (!found) {for (var i = 0; l = document.links[i]; i++) {if (l.getAttribute('rel') == 'shortlink') {found = l.getAttribute('href');break;}}}if (found) {prompt('URL:', found);} else {alert('No shortlink available for this page'); } } wpcomshort(); return false;' ) ) ); 200 } 201 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_bloginfo_menu', 50 ); 202 203 /** 204 * Use the $wp_admin_bar global to add the "Edit Post" menu when viewing a single post. 205 */ 206 function wp_admin_bar_edit_menu() { 207 global $post, $wp_admin_bar; 208 209 if ( !is_object( $wp_admin_bar ) ) 210 return false; 211 212 if ( !is_single() && !is_page() ) 213 return false; 214 215 if ( !$post_type_object = get_post_type_object( $post->post_type ) ) 216 return false; 217 218 if ( !current_user_can( $post_type_object->cap->edit_post, $post->ID ) ) 219 return false; 220 221 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $post->ID ) ) ); 222 } 223 add_action( 'wp_before_admin_bar_render', 'wp_admin_bar_edit_menu', 100 ); 224 225 /** 226 * Load up the CSS needed to render the admin bar nice and pretty. 227 */ 228 function wp_admin_bar_css() { 229 global $pagenow, $wp_locale, $wp_admin_bar; 230 231 if ( !is_object( $wp_admin_bar ) ) 232 return false; 233 234 if ( !is_user_logged_in() ) 235 return; 236 237 $nobump = false; 238 239 /* Wish we could use wp_enqueue_style() here, but it will not let us pass GET params to the stylesheet correctly. */ 194 if ( ! empty( $current_object->post_type ) && ( $post_type_object = get_post_type_object( $current_object->post_type ) ) && current_user_can( $post_type_object->cap->edit_post, $current_object->ID ) ) { 195 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_post_link( $current_object->ID ), ) ); 196 } elseif ( ! empty( $current_object->taxonomy ) && ( $tax = get_taxonomy( $current_object->taxonomy ) ) && current_user_can( $tax->cap->edit_terms ) ) { 197 $wp_admin_bar->add_menu( array( 'id' => 'edit', 'title' => __( 'Edit' ), 'href' => get_edit_term_link( $current_object->term_id, $current_object->taxonomy ), ) ); 198 } 199 } 200 201 /** 202 * Style and scripts for the admin bar. 203 * 204 * @since 3.1.0 205 * @todo move js into a admin-bar js file 206 * 207 */ 208 function wp_admin_bar_header() { 240 209 ?> 241 <link rel="stylesheet" href="<?php echo includes_url('admin-bar/admin-bar-css.php') . '?t=' . get_current_theme() . '&a=' . is_admin() . '&p=' . is_ssl() . '&sa=' . is_super_admin() . '&td=' . $wp_locale->text_direction . '&inc=' . includes_url() . '&nobump=' . $nobump; ?>" type="text/css" /> 242 <!--[if IE 6]><style type="text/css">#wpadminbar, #wpadminbar .menupop a span, #wpadminbar .menupop ul li a:hover, #wpadminbar .myaccount a, .quicklinks a:hover,#wpadminbar .menupop:hover { background-image: none !important; } #wpadminbar .myaccount a { margin-left:0 !important; padding-left:12px !important;}</style><![endif]--> 243 <style type="text/css" media="print">#wpadminbar { display:none; }</style><?php 244 } 245 246 /** 247 * Load up the JS needed to allow the admin bar to function correctly. 248 */ 249 function wp_admin_bar_js() { 250 global $wp_admin_bar; 251 252 if ( !is_object( $wp_admin_bar ) ) 253 return false; 254 210 <style type="text/css" media="print">#wpadminbar { display:none; }</style> 211 <script type="text/javascript"> 212 /* <![CDATA[ */ 213 (function(d, w) { 214 var init = function() { 215 var b = d.getElementsByTagName('body')[0], 216 aB = d.getElementById('wpadminbar'), 217 s = d.getElementById('adminbar-search'); 218 219 if ( b && aB ) 220 b.appendChild( aB ); 221 222 if ( s ) { 223 if ( '' == s.value ) 224 s.value = s.getAttribute('title'); 225 226 s.onblur = function() { 227 this.value = '' == this.value ? this.getAttribute('title') : this.value; 228 } 229 s.onfocus = function() { 230 this.value = this.getAttribute('title') == this.value ? '' : this.value; 231 } 232 } 233 234 if ( w.location.hash ) 235 w.scrollBy(0,-32); 236 } 237 238 if ( w.addEventListener ) 239 w.addEventListener('load', init, false); 240 else if ( w.attachEvent ) 241 w.attachEvent('onload', init); 242 243 })(document, window); 244 /* ]]> */ 245 </script> 246 <?php 247 } 248 249 // @TODO do we still need this in core? 250 function wp_admin_body_style() { 255 251 ?> 256 <script type="text/javascript"> 257 /* <![CDATA[ */ 258 function pressthis(step) {if (step == 1) {if(navigator.userAgent.indexOf('Safari') >= 0) {Q=getSelection();}else {if(window.getSelection)Q=window.getSelection().toString();else if(document.selection)Q=document.selection.createRange().text;else Q=document.getSelection().toString();}} else {location.href='<?php echo $wp_admin_bar->user->account_domain; ?>wp-admin/post-new.php?text='+encodeURIComponent(Q.toString())+'&popupurl='+encodeURIComponent(location.href)+'&popuptitle='+encodeURIComponent(document.title);}} 259 function toggle_query_list() { var querylist = document.getElementById( 'querylist' );if( querylist.style.display == 'block' ) {querylist.style.display='none';} else {querylist.style.display='block';}} 260 261 jQuery( function() { 262 (function(jq){jq.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=jq.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){jq(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;jq(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{jq(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery); 263 ;(function(jq){jq.fn.superfish=function(op){var sf=jq.fn.superfish,c=sf.c,jqarrow=jq([''].join('')),over=function(){var jqjq=jq(this),menu=getMenu(jqjq);clearTimeout(menu.sfTimer);jqjq.showSuperfishUl().siblings().hideSuperfishUl();},out=function(){var jqjq=jq(this),menu=getMenu(jqjq),o=sf.op;clearTimeout(menu.sfTimer);menu.sfTimer=setTimeout(function(){o.retainPath=(jq.inArray(jqjq[0],o.jqpath)>-1);jqjq.hideSuperfishUl();if(o.jqpath.length&&jqjq.parents(['li.',o.hoverClass].join('')).length<1){over.call(o.jqpath);}},o.delay);},getMenu=function(jqmenu){var menu=jqmenu.parents(['ul.',c.menuClass,':first'].join(''))[0];sf.op=sf.o[menu.serial];return menu;},addArrow=function(jqa){jqa.addClass(c.anchorClass).append(jqarrow.clone());};return this.each(function(){var s=this.serial=sf.o.length;var o=jq.extend({},sf.defaults,op);o.jqpath=jq('li.'+o.pathClass,this).slice(0,o.pathLevels).each(function(){jq(this).addClass([o.hoverClass,c.bcClass].join(' ')).filter('li:has(ul)').removeClass(o.pathClass);});sf.o[s]=sf.op=o;jq('li:has(ul)',this)[(jq.fn.hoverIntent&&!o.disableHI)?'hoverIntent':'hover'](over,out).each(function(){if(o.autoArrows)addArrow(jq('>a:first-child',this));}).not('.'+c.bcClass).hideSuperfishUl();var jqa=jq('a',this);jqa.each(function(i){var jqli=jqa.eq(i).parents('li');jqa.eq(i).focus(function(){over.call(jqli);}).blur(function(){out.call(jqli);});});o.onInit.call(this);}).each(function(){var menuClasses=[c.menuClass];if(sf.op.dropShadows&&!(jq.browser.msie&&jq.browser.version<7))menuClasses.push(c.shadowClass);jq(this).addClass(menuClasses.join(' '));});};var sf=jq.fn.superfish;sf.o=[];sf.op={};sf.IE7fix=function(){var o=sf.op;if(jq.browser.msie&&jq.browser.version>6&&o.dropShadows&&o.animation.opacity!=undefined) this.toggleClass(sf.c.shadowClass+'-off');};sf.c={bcClass:'sf-breadcrumb',menuClass:'sf-js-enabled',anchorClass:'sf-with-ul',arrowClass:'sf-sub-indicator',shadowClass:'sf-shadow'};sf.defaults={hoverClass:'sfHover',pathClass:'overideThisToUse',pathLevels:1,delay:600,animation:{opacity:'show'},speed:100,autoArrows:false,dropShadows:false,disableHI:false,onInit:function(){},onBeforeShow:function(){},onShow:function(){},onHide:function(){}};jq.fn.extend({hideSuperfishUl:function(){var o=sf.op,not=(o.retainPath===true)?o.jqpath:'';o.retainPath=false;var jqul=jq(['li.',o.hoverClass].join(''),this).add(this).not(not).removeClass(o.hoverClass).find('>ul').hide().css('visibility','hidden');o.onHide.call(jqul);return this;},showSuperfishUl:function(){var o=sf.op,sh=sf.c.shadowClass+'-off',jqul=this.addClass(o.hoverClass).find('>ul:hidden').css('visibility','visible');sf.IE7fix.call(jqul);o.onBeforeShow.call(jqul);jqul.animate(o.animation,o.speed,function(){sf.IE7fix.call(jqul);o.onShow.call(jqul);});return this;}});})(jQuery); 264 265 <?php if ( is_single() ) : ?> 266 if ( jQuery(this).width() < 1100 ) jQuery("#adminbarsearch").hide(); 267 <?php endif; ?> 268 269 jQuery( '#wpadminbar li.ab-my-account, #wpadminbar li.ab-bloginfo' ).mouseover( function() { 270 if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpadminbar li.ab-me > a').addClass('hover'); 271 if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpadminbar li.ab-blog > a').addClass('hover'); 272 }); 273 274 jQuery( '#wpadminbar li.ab-my-account, #wpadminbar li.ab-bloginfo' ).mouseout( function() { 275 if ( jQuery(this).hasClass( 'ab-my-account' ) ) jQuery('#wpadminbar li.ab-me > a').removeClass('hover'); 276 if ( jQuery(this).hasClass( 'ab-bloginfo' ) ) jQuery('#wpadminbar li.ab-blog > a').removeClass('hover'); 277 }); 278 279 <?php if ( is_single() ) : ?> 280 jQuery(window).resize( function() { 281 if ( jQuery(this).width() < 1100 ) 282 jQuery("#adminbarsearch").hide(); 283 284 if ( jQuery(this).width() > 1100 ) 285 jQuery("#adminbarsearch").show(); 286 }); 287 <?php endif; ?> 288 289 jQuery( '#wpadminbar ul ul li a' ).mouseover( function() { 290 var root = jQuery(this).parents('div.quicklinks ul > li'); 291 var par = jQuery(this).parent(); 292 var children = par.children('ul'); 293 if ( root.hasClass('ab-sadmin') ) 294 jQuery(children[0]).css('<?php echo( is_rtl() ? 'left' : 'right' ); ?>',par.parents('ul').width() - 1 +'px' ); 295 else 296 jQuery(children[0]).css('<?php echo( is_rtl() ? 'right' : 'left' ); ?>',par.parents('ul').width() +'px' ); 297 298 jQuery(children[0]).css('top', '0' ); 299 }); 300 301 <?php if ( is_user_logged_in() ) : // Hash links scroll 32px back so admin bar doesn't cover. ?> 302 if ( window.location.hash ) window.scrollBy(0,-32); 303 <?php endif; ?> 252 <style type="text/css"> 253 <?php 304 254 305 }); 306 307 jQuery( function() { 308 jQuery('#wpadminbar').appendTo('body'); 309 jQuery("#wpadminbar ul").superfish(); 310 }); 311 312 /* ]]> */ 313 </script><?php 314 } 315 add_action( 'wp_footer', 'wp_admin_bar_js' ); 316 add_action( 'admin_footer', 'wp_admin_bar_js' ); 317 318 /** 319 * Return a rendered admin bar via AJAX for use on pages that do not run inside the 320 * WP environment. Used on bbPress forum pages to show the admin bar. 321 */ 322 function wp_admin_bar_ajax_render() { 323 global $wp_admin_bar; 324 325 wp_admin_bar_js(); 326 wp_admin_bar_css(); 327 wp_admin_bar_render(); 328 die; 329 } 330 add_action( 'wp_ajax_admin_bar_render', 'wp_admin_bar_ajax_render' ); 331 332 function is_admin_bar() { 333 return ( 0 === strpos($_SERVER['REQUEST_URI'], '/js/admin-bar') ); 334 } 335 336 function wp_admin_bar_lang($locale) { 337 if ( is_admin_bar() ) 338 $locale = get_locale(); 339 return $locale; 340 } 341 add_filter('locale', 'wp_admin_bar_lang'); 342 255 if ( 256 ( empty( $_GET['nobump'] ) || is_admin() ) && 257 ! strpos( $_SERVER['REQUEST_URI'], 'media-upload.php' ) 258 ) : 259 ?> 260 body { padding-top: 28px !important; } 261 <?php 262 endif; 263 264 if ( in_array( get_current_theme(), array('H3', 'H4', 'The Journalist v1.9') ) ) : 265 ?> 266 body { padding-top: 28px; background-position: 0px 28px; } 267 <?php 268 endif; 269 270 ?> 271 </style> 272 <?php 273 } 274 275 add_action('wp_head', 'wp_admin_body_style'); 276 add_action('admin_head', 'wp_admin_body_style'); 277 278 /** 279 * Determine whether the admin bar should be showing. 280 * 281 * @since 3.1.0 282 * 283 * @return bool Whether the admin bar should be showing. 284 */ 285 function is_admin_bar_showing() { 286 global $show_admin_bar; 287 288 if ( ! isset( $show_admin_bar ) || null === $show_admin_bar ) { 289 $show_admin_bar = true; 290 291 if ( defined('WP_SHOW_ADMIN_BAR') ) 292 $show_admin_bar = (bool) WP_SHOW_ADMIN_BAR; 293 294 if ( ! is_user_logged_in() ) 295 $show_admin_bar = false; 296 } 297 298 $show_admin_bar = apply_filters( 'show_admin_bar', $show_admin_bar ); 299 300 return $show_admin_bar; 301 } 343 302 ?>
Note: See TracChangeset
for help on using the changeset viewer.