← WordPress

Adicionar links à barra de administração

Lida 1901 vezes

Offline

Rogério Moreira 
Editor
Mensagens 1313 Gostos 11
Feedback +15

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Tenth year Anniversary Nineth year Anniversary Eighth year Anniversary Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter

Boa noite pessoal.

Queria fazer algo deste género:

http://www.escolawp.com/2012/08/truques-para-customizar-a-barra-de-administracao-do-wordpress/

no entanto o código que está aí não funciona.

Alguém tem uma alternativa ou código para isto?

Abraço
Offline

genius 
Membro
Mensagens 410 Gostos 1
Feedback +3

Troféus totais: 26
Trófeus: (Ver todos)
Windows User Super Combination Combination Topic Starter Poll Voter Level 5 Level 4 Level 3 Level 2 Level 1

Por acaso ainda hoje de tarde estive com isto em mãos, aqui fica uma ajuda que eu usei:

http://blog.rutwick.com/add-items-anywhere-to-the-wp-3-3-admin-bar


Todo o código da admin bar está localizado aqui /wp-includes/admin-bar.php

No meu caso usei isto:

Código: [Seleccione]
$args = array(
'parent' => 'top-secondary',
            'id'    => 'my-item',
            'title' => 'Teste',
            'href'  => '#',
            'meta'  => array(
                    'title' => __('Click Me'),
                    ),
            );

Espero ter ajudado
Offline

alexandreperei 
Membro
Mensagens 85 Gostos 0
Troféus totais: 23
Trófeus: (Ver todos)
Super Combination Combination Topic Starter Poll Voter Level 4 Level 3 Level 2 Level 1 50 Posts 10 Posts

Eu colei os eguinte código no ficheiro  funstions.php do template que uso:

function mytheme_admin_bar_render() {
   global $wp_admin_bar;
   $wp_admin_bar->add_menu( array(
      'parent' => 'new-content', // use 'false' for a root menu, or pass the ID of the parent menu
      'id' => 'new_media', // link ID, defaults to a sanitized title value
      'title' => __('Media'), // link title
      'href' => admin_url( 'media-new.php'), // name of file
      'meta' => false // array of any of the following options: array( 'html' => '', 'class' => '', 'onclick' => '', target => '', title => '' );
   ));
}
add_action( 'wp_before_admin_bar_render', 'mytheme_admin_bar_render' );
Offline

Rogério Moreira 
Editor
Mensagens 1313 Gostos 11
Feedback +15

Troféus totais: 32
Trófeus: (Ver todos)
Level 6 Tenth year Anniversary Nineth year Anniversary Eighth year Anniversary Super Combination Combination Topic Starter 10 Poll Votes Poll Voter Poll Starter

Isto resolveu-me tudo:

Código: [Seleccione]
// always show admin bar
function pjw_login_adminbar( $wp_admin_bar) {
if ( !is_user_logged_in() )
$wp_admin_bar->add_menu( array( 'title' => __( 'Log In' ), 'href' => wp_login_url() ) );
}
add_action( 'admin_bar_menu', 'pjw_login_adminbar' );
add_filter( 'show_admin_bar', '__return_true' , 1000 );