WordPress 技巧:侧边栏登录窗口

文章目录[隐藏] WPJAM TOC

有没有想过不用跑到登录界面,直接在首页就能登录到 WordPress 呢?先帖几张屏幕截图,是在本站使用的 BLIX 主题下测试的效果:

登录窗口
侧边拦的登录窗口

登录之后
侧边拦的登录窗口登录之后

详细代码如下:


<li>
    <?php global $user_ID, $user_identity, $user_level ?>
    <?php if ( $user_ID ) : ?>

<h2 ><a name="toc-1"></a>Control panel</h2>
<ul>
<li>Identified as <strong><?php echo $user_identity ?></strong>.
<ul>
<li><a href="<?php bloginfo('url') ?>/wp-admin/">Dashboard</a></li>
            <?php if ( $user_level >= 1 ) : ?>

<li><a href="<?php bloginfo('url') ?>/wp-admin/post-new.php">Write an article</a></li>
            <?php endif // $user_level >= 1 ?>

<li><a href="<?php bloginfo('url') ?>/wp-admin/profile.php">Profile and personal options</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=logout&redirect_to=<?php echo urlencode($_SERVER['REQUEST_URI']) ?>">Exit</a></li>
</ul>
</li>
</ul>
    <?php elseif ( get_option('users_can_register') ) : ?>

<h2 ><a name="toc-2"></a>Identification</h2>
<ul>
<li>
<form action="<?php bloginfo('url') ?>/wp-login.php" method="post">


            <label for="log"><input type="text" name="log" id="log" value="<?php echo wp_specialchars(stripslashes($user_login), 1) ?>" size="22" /> User</label>
            <label for="pwd"><input type="password" name="pwd" id="pwd" size="22" /> Password</label>
            <input type="submit" name="submit" value="Send" class="button" />
            <label for="rememberme"><input name="rememberme" id="rememberme" type="checkbox" checked="checked" value="forever" /> Remember me</label>
            

            <input type="hidden" name="redirect_to" value="<?php echo $_SERVER['REQUEST_URI']; ?>"/>
        </form>
</li>
<li><a href="<?php bloginfo('url') ?>/wp-register.php">Register</a></li>
<li><a href="<?php bloginfo('url') ?>/wp-login.php?action=lostpassword">Recover password</a></li>
</ul>
    <?php endif // get_option('users_can_register') ?>

</li>
标签:

热门文章