一直看到别人有这功能,而我的主题没有这功能,而且每次弹出就直接到WP登录界面,于是开始到处学习,可是按照大家的教程,失败!失败!在失败!我处在崩溃的边缘!但是没有放弃,继续寻觅...看到了naruto的教程,简单,不用添加JS,但是出现了更大的问题,排版乱了,乱七八糟的,但是他这个方法至少让我实现了记录并隐藏!于是开始捣鼓这段代码,虽然现在效果已经实现,但是我总觉得我捣鼓出来的这代码有点问题,希望高人看到了能帮我指点指点,我觉的这段代码会产生一些没用的代码,这样代码又多,如果出现某些代码没用了,是不是可以删掉,节省空间提提速!我的代码如下:
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"><div id="respond">
<?php if ( $comment_author != "" ) : ?>
<div>
<?php printf(__('欢迎回来 <strong>%s</strong>,说说话,不要憋着哈!'), $comment_author) ?>
<span id="show_author_info"><a href="javascript:void(0);" onclick="setStyleDisplay('author_info','');setStyleDisplay('show_author_info','none');setStyleDisplay('hide_author_info','');"><?php _e('更改信息 »'); ?></a></span>
<span id="hide_author_info"><a href="javascript:void(0);" onclick="setStyleDisplay('author_info','none');setStyleDisplay('show_author_info','');setStyleDisplay('hide_author_info','none');"><?php _e('隐藏 »'); ?></a></span>
</div>
<?php endif; ?>
<div id="author_info">
<div>
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="24" tabindex="1" />
<label for="author"><font style="color:red">*</font><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></label>
</div>
<div>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="24" tabindex="2" />
<label for="email"><font style="color:red">*</font><?php _e('邮件地址 (不会被公开)');?> <?php if ($req) _e('(required)'); ?></label>
</div>
<div>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="24" tabindex="3" />
<label for="url"><?php _e('Website'); ?></label>
</div>
</div>
<?php if ( $comment_author != "" ) : ?>
<script type="text/javascript">function setStyleDisplay(id, status){document.getElementById(id).style.display = status;}
setStyleDisplay('hide_author_info','none');setStyleDisplay('author_info','none');</script>
<?php endif; ?>
而被我替换掉的主题源代码如下:
<form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform">
<div id="respond">
<?php if ($user_ID) : ?>
<?php
if (function_exists('wp_logout_url')) {
$logout_link = wp_logout_url();
} else {
$logout_link = get_option('siteurl') . '/wp-login.php?action=logout';
}
?>
<div>
<?php _e('欢迎回来'); ?> <a href="<?php echo get_option('siteurl'); ?>/wp-admin/profile.php"><strong><?php echo $user_identity; ?></strong></a>.
<a href="<?php echo $logout_link; ?>" title="<?php _e('Log out of this account'); ?>"><?php _e('换个马甲咯!!»'); ?></a>
</div>
<?php else : ?>
<?php if ( $comment_author != "" ) : ?>
<div>
<?php printf(__('欢迎回来<strong>%s</strong>.'), $comment_author) ?>
</div>
<?php endif; ?>
<div id="author_info">
<div>
<input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" size="24" tabindex="1" />
<label for="author"><font style="color:red">*</font><?php _e('Name'); ?> <?php if ($req) _e('(required)'); ?></label>
</div>
<div>
<input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" size="24" tabindex="2" />
<label for="email"><font style="color:red">*</font><?php _e('E-Mail (will not be published)','icavy');?> <?php if ($req) _e('(required)'); ?></label>
</div>
<div>
<input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" size="24" tabindex="3" />
<label for="url"><?php _e('Website'); ?></label>
</div>
</div>
<?php endif; ?>
对了,我上面的代码少了一个</DIV>,我如果加上的话,边栏错位!去掉的话就OK,并也可以达到一定的效果。这个代码应该要怎么修改呢
可能是你哪个地方少加了
我来盖楼!我用的是苹果动力,前段时间很不稳定,前段时间也就是30秒之前,经常性打不开!
我的pj也实现这个功能了,哈,这个是必须地
这就是折腾,刚看代码的时候头疼,看多了以后就没事了。
@兔魔王![:|](https://mofei.de/wp-content/themes/mofei%203.0.1/images/smilies/icon_neutral.gif)
@兔魔王, 弄花你的眼睛了,真不好意思!
现在看着可以了。呵呵
http://898tele.com - dianhuahaomaxianggang