DIY Главная Медиа Logo

Конечная сайт для проектирования и создания вашей установке домашнего кинотеатра и Привет-Fi.

1Комментарий пузырьКомментарии Jetpack стиле без Jetpack

One of the best things about word­press is the built-in social aspect provided by com­ments. Get­ting your com­ment sec­tion right can be very import­ant to any web­site, includ­ing ours. Over the years we’ve exper­i­mented with vari­ous com­ment plu­gins includ­ing Dis­qus and more recently Jet­pack. How­ever, мы всегда в конечном итоге навести в доме для управления, per­form­ance and pri­vacy reas­ons. When I moved back from Jet­pack com­ments I really missed some of the slick fea­tures provided by Jet­pack, both the social-net­work logins and the gen­er­al slick styl­ing. Any­way, to cut a long story short I finally had time today to take a good look at how word­press “does” com­ments and fig­ure out a way to build an in-house sys­tem which looks nice and slick like the com­ment inter­face provided by jet­pack. Best of all its sur­pris­ingly simple and does things the “prop­er” way…

Первый - иметь дело с «социальной» аспекте, Я прибег к плагин, который называется WordPress Социальная Войти от MiledThere are sev­er­al “social login” plu­gins, но эта версия (в отличие от других) keeps everything totally in-house. It is a bit more work to con­fig­ure, но в интересах наших посетителей частной жизни только это хорошо стоит.

Затем было выяснить, как изменить встроенный WordPress форме комментария функцию (достаточно весело-nily называется comment_form()).  Я предоставить более подробную информацию позже, если кто-то просит его, сейчас просто найти отн-EV-муравей ниже код ...

comments.php (в папке темы)

[PHP]
<!– You can start edit­ing here. –>

<?PHP, если ( comments_open() ) : ?>

<sec­tion id=“respond” class=“respond-form”>
<?PHP comment_form(); ?>

<сценарий>
document.getElementById(‘hidden-form-area’).style.display = ‘none’;
func­tion myFunction()
{
document.getElementById(‘hidden-form-area’).style.display = ‘block’;
}
</сценарий>

</раздел>

<?PHP ENDIF; // если вы удалите этот небо упадет на голову?>
[/PHP]

functions.php (в папке темы)

[PHP]
func­tion my_fields($поля)
{
$поля[«автор»] = ‘<p class=“comment-form-author”><input type=“text” name=“author” id=“author” size=“22” tabindex=“1” placeholder=“Name (обязательный)” /></р>»;
$поля[’email’] = ‘<p class=“comment-form-email”><input type=“text” name=“email” id=“email” size=“22” tabindex=“2” placeholder=“E‑mail (required — nev­er shared with any­one)” /></р>»;
$поля[‘url’] = ‘<p class=“comment-form-url”><input type=“text” name=“url” id=“url” size=“22” tabindex=“2” placeholder=“Website” /></р>»;
вернуться $ поля;
}
add_filter(‘comment_form_default_fields’,‘my_fields’);

func­tion remove_notice($по умолчанию)
{
$по умолчанию[‘comment_notes_before’] = ”;
$по умолчанию[‘comment_notes_after’] = ”;
вернуться $ умолчанию;
}
add_filter( ‘comment_form_defaults’, ‘remove_notice’ );

func­tion remove_textarea($по умолчанию)
{
$по умолчанию[‘comment_field’] = ”;
вернуться $ умолчанию;
}
add_filter( ‘comment_form_defaults’, ‘remove_textarea’ );

func­tion add_textarea()
{
эхо '<p class=“comment-form-comment”><textarea id=“comment” name=“comment” placeholder=“Enter your com­ment here…” onfocus=“myFunction()»></текстовой></р><div id=“hidden-form-area”>»;
}
add_action( ‘comment_form_top’, ‘add_textarea’, 1 );

func­tion add_hideend()
{
эхо '</дел>»;
}
add_action( ‘comment_form_after’, ‘add_hideend’ );
[/PHP]

оставьте ответ

Один Комментарий