some wp admin bar related snippets
-
first of all, here is the site I will be talking about: https://zice.ro
I am using a php file from inside mu-plugins to modify the wp admin bar to my likings and need some help.
a) the part on the far left of the bar where it says: zice.ro is generated by this snippet:
function addLinkHome( $wp_admin_bar) { $wp_admin_bar->add_menu( array( 'title' => __( 'zice.ro' ), 'href' => 'https://zice.ro/' ) ); ?> <style type="text/css"> #wp-admin-bar-zice-ro { background: #FA0502 url('https://zice.ro/favicon.ico') no-repeat left top;} </style> <?php } add_action( 'admin_bar_menu', 'addLinkHome', 0 ); //try add_action( 'admin_bar_menu', 'addLinkMenu', 999 );
I was trying to put the favicon of the site in front of it just like the avatar that appears when you are logged in, check this screen shot: https://screencast.com/t/HoIX3RYzvbK
a) The second part from the left, where it says “Blog aleator” should actually be on the far right hand side but I can’t position it there. Here is the code that generates it:
function addLinkRandom( $wp_admin_bar) { $wp_admin_bar->add_menu( array( 'title' => __( 'Blog aleator' ), 'href' => 'https://zice.ro/next.php' ) );} add_action( 'admin_bar_menu', 'addLinkRandom', 0 ); //try add_action( 'admin_bar_menu', 'addLinkMenu', 999 );
Unfortunately this code generates the menu into the .quicklinks part. How to get it to show on the far right hand side?
c) what is the difference between these two snippets as c1) works and c2) doesn’t
c1)
function addNetworkComments() { global $wp_admin_bar; if ( is_user_logged_in() ){ $wp_admin_bar->add_menu( array( 'parent' => 'comments', 'title' => __( 'Discutiile mele'), 'href' => admin_url( 'index.php?page=my_network_comments' ) ) ); }} add_action('wp_before_admin_bar_render', 'addNetworkComments', 0);
c2)
function addNetworkComments( $wp_admin_bar) { if ( is_user_logged_in() ){ $wp_admin_bar->add_menu( array( 'parent' => 'comments', 'title' => __( 'Discutiile mele'), 'href' => admin_url( 'index.php?page=my_network_comments' ) ) ); }} add_action('admin_bar_menu', 'addNetworkComments', 0);
- The topic ‘some wp admin bar related snippets’ is closed to new replies.