WordPress管理员登录自定义徽标

时间:2013-12-18 作者:ashraf

我知道这可能不可能。但我只是想深入了解wordpress。是否可以用自定义页面替换默认的管理员登录页面?

2 个回复
SO网友:Howdy_McGee

我个人喜欢用这样的东西。这将查找logo 模板中的图像/images/ 文件夹或目录,然后将其显示在默认Wordpress徽标的位置。

function my_login_logo() { 
    if(file_exists(TEMPLATEPATH.\'/images/logo.png\'))
        $logo = \'/images/logo.png\';
    else if(file_exists(TEMPLATEPATH.\'/images/logo.jpg\'))
        $logo = \'/images/logo.jpg\';
    else if(file_exists(TEMPLATEPATH.\'/images/logo.gif\'))
        $logo = \'/images/logo.gif\';
?>
    <style type="text/css">
        body.login div#login h1 a {
            background-image: url(<?php echo get_bloginfo(\'template_directory\').$logo; ?>);
            padding-bottom: 40px;
            background-size: auto;
            width: auto;
            height: auto;
        }
    </style>
<?php 
}
add_action( \'login_enqueue_scripts\', \'my_login_logo\' );
Alternatively 正如@G.M.在评论中所建议的,您可以使用child_theme 友好的做法如下:

function my_login_logo() { 
    $locate = locate_template( array(\'images/logo.png\', \'images/logo.jpg\', \'images/logo.gif\'), false ); 
    if ( empty($locate) ) return;
    $base = is_child_theme() && substr_count($locate , get_stylesheet_directory()) ? get_stylesheet_directory_uri() : get_template_directory_uri();
    $logo = $base . \'/images/\' . basename($locate);
?>
<style type="text/css">
body.login div#login h1 a {
  background-image: url(<?php echo $logo; ?>);
  padding-bottom: 40px;
  background-size: auto;
  width: auto;
  height: auto;
}
</style>
<?php 
}
add_action( \'login_enqueue_scripts\', \'my_login_logo\' );
nbsp;

单击徽标横幅后,以下两个功能将更改指向的位置,在我的第一个功能中,我将其替换为指向主页的链接。

第二个函数将把悬停文本替换为在中设置的博客描述符Settings 作为您的标记线。

/** Change Banner Link **/
function custom_loginlogo_url($url) {
    return home_url();
}
add_filter( \'login_headerurl\', \'custom_loginlogo_url\' );

/** Change Link Title to Tagline **/
function custom_login_logo_link_title(){
    return get_option(\'blogdescription\');  
}
add_filter(\'login_headertitle\', \'custom_login_logo_link_title\');
所有这些都需要放入function.php 让他们工作。

SO网友:Abhik

function my_login_logo() { ?>
<style type="text/css">
    body.login div#login h1 a {
        background-image: url(<?php echo get_bloginfo( \'template_directory\' ) ?>/images/site-login-logo.png);
        padding-bottom: 30px;
    }
</style>
<?php }
add_action( \'login_enqueue_scripts\', \'my_login_logo\' );
您只需将URL替换为徽标URL。

结束

相关推荐

将内容添加到/wp-admin/plugin-install.php管理屏幕

我想向上显示的插件信息添加一些外部内容/wp-admin/plugin-install.php 管理屏幕。/wp-admin/plugin-install.php 调用以下命令:$wp_list_table = _get_list_table(\'WP_Plugin_Install_List_Table\'); 如果我破解这个核心文件作为测试,我可以添加内容,我想,好的。然而,作为一名新的WP开发者,我真的很难看到如何通过插件添加这些内容。class WP_Plugin_Install_List