1注释气泡没有Jetpack的Jetpack的风格的注释

一个关于WordPress的最好的事情是发表了内置的社交方面。让您的注释部分权可以到任何网站很重要, 包括我们在内。多年来,我们已经尝试了各种评论插件,包括Disqus和最近的Jetpack。然而, 我们一直都结束了把东西放回房子管理, 性能和隐私的原因。当我从Jetpack的意见搬回我真的错过了一些通过的Jetpack提供的光滑特点, 无论是社交网络的登录和一般光滑的造型。无论如何, 削减长话短说,我终于有今天的时间采取在WordPress的是如何“做”的意见很好看,并想出一个办法来建立一个内部系统看上去很光滑,并通过类似传送插座提供的评论接口。最重要的是其令人惊讶的简单和做事的“正确”的方式...


First — to deal with the “social” aspect, I’ve resor­ted to a plu­gin called Word­Press Social Login 通过 MiledThere are sev­er­al “social login” plu­gins, but this ver­sion (unlike the oth­ers) keeps everything totally in-house. It is a bit more work to con­fig­ure, but for the bene­fit to our vis­it­ors pri­vacy alone this is well worth it.

Next up was fig­ur­ing out how to change the built-in word­press com­ment form func­tion (fun­nily enough called comment_form()).  I’ll provide more detail later if any­one requests it, for now just find the rel­ev­ant code below…

的comments.php (在主题文件夹)

<!-- You can start editing here. -->

<?php if ( comments_open() ) : ?>

<section id="respond" class="respond-form">
<?php comment_form(); ?>

<script>
document.getElementById('hidden-form-area').style.display = 'none';
function myFunction()
{
document.getElementById('hidden-form-area').style.display = 'block';
}
</script>

</section>

<?php endif; // if you delete this the sky will fall on your head ?>

的functions.php (在主题文件夹)

function my_fields($fields)
{
    $fields['author'] = '<p class="comment-form-author"><input type="text" name="author" id="author" size="22" tabindex="1" placeholder="Name (required)" /></p>';
    $fields['email'] = '<p class="comment-form-email"><input type="text" name="email" id="email" size="22" tabindex="2" placeholder="E-mail (required - never shared with anyone)" /></p>';
    $fields['url'] = '<p class="comment-form-url"><input type="text" name="url" id="url" size="22" tabindex="2" placeholder="Website" /></p>';
    return $fields;
}
add_filter('comment_form_default_fields','my_fields');

function remove_notice($defaults)
{
    $defaults['comment_notes_before'] = '';
    $defaults['comment_notes_after'] = '';
    return $defaults;
}
add_filter( 'comment_form_defaults', 'remove_notice' );

function remove_textarea($defaults)
{
    $defaults['comment_field'] = '';
    return $defaults;
}
add_filter( 'comment_form_defaults', 'remove_textarea' );

function add_textarea()
{
    echo '<p class="comment-form-comment"><textarea id="comment" name="comment" placeholder="Enter your comment here..." onfocus="myFunction()"></textarea></p><div id="hidden-form-area">';
}
add_action( 'comment_form_top', 'add_textarea', 1 );

function add_hideend()
{
    echo '</div>';
}
add_action( 'comment_form_after', 'add_hideend' );

你怎么看? 请给我们一个评论如下! 如果您想订阅,请使用菜单上的订阅链接右上方. 您还可以通过使用下面的链接社会分享这与你的朋友. 干杯.

发表评论

条评论