Trusted WordPress tutorials, when you need them most.
Beginner’s Guide to WordPress
WPB Kupası
25 Million+
Websites using our plugins
16+
Years of WordPress experience
3000+
WordPress tutorials
by experts

WordPress Yorumlarında HTML Nasıl Devre Dışı Bırakılır

WordPress varsayılan olarak yorumlar içinde <a> <em> <strong> vb. gibi belirli HTML etiketlerine izin verir. Dikkat ederseniz pek çok SPAM yorum da bu etiketleri içerir. SPAM yorumların çoğu HTML etiketlerini kullanan botlar ve komut dosyaları tarafından yapılır. WordPress yorumlarınızdan HTML’yi devre dışı bırakırsanız, çok sayıda SPAM’ı önleyebilirsiniz. Bu eğitimde size WordPress yorumlarınızdaki HTML etiketlerini nasıl devre dışı bırakabileceğinizi göstereceğiz.

Bu eğitim yalnızca etkin HTML etiketlerini devre dışı bırakacaktır. Yani birisi hala şöyle bir şey gönderebilir:

&lt;a&gt;&lt;em&gt;&lt;strong&gt;

Ve görünecektir, ancak etiketler işlevsel olmayacaktır. Yani birisi güçlü etiketi kullanırsa, metni kalınlaştırmayacaktır. Ayrıca pek çok SPAM botunun bunu yapacak zamanı yoktur çünkü bu yol çok zaman alır ve onlar için faydalı değildir.

Tek yapmanız gereken functions.php dosyanızı açmak ve aşağıdaki kodu eklemek:

    // This will occur when the comment is posted
    function plc_comment_post( $incoming_comment ) {

    // convert everything in a comment to display literally
    $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);

    // the one exception is single quotes, which cannot be #039; because WordPress marks it as spam
    $incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );

    return( $incoming_comment );
    }

    // This will occur before a comment is displayed
    function plc_comment_display( $comment_to_display ) {

    // Put the single quotes back in
    $comment_to_display = str_replace( '&apos;', "'", $comment_to_display );

    return $comment_to_display;
}

Bu kodu kendiniz elle eklemek istemiyorsanız, orijinal yazar indirebileceğiniz bir eklenti de sunuyor. Peter’ın Literal Comments eklentisini kurmanız ve etkinleştirmeniz yeterlidir.

Bu yolun daha iyi olmasının nedeni, çekirdek dosyaları değiştirmenizi gerektirmemesidir. Eğer çekirdek dosyalarınızı düzenlemek istiyorsanız wp-includes/kses.php adresine gidebilir ve oradaki kodları düzenleyebilirsiniz. (Bu tavsiye edilmez, ancak bilgi olması açısından burada yer almaktadır.( Daha fazla ayrıntı içinWP Codex )

Açıklama: İçeriğimiz okuyucu desteklidir. Bu, bazı bağlantılarımıza tıklarsanız komisyon kazanabileceğimiz anlamına gelir. WPBeginner'ın nasıl finanse edildiğini, neden önemli olduğunu ve nasıl destek olabileceğinizi görün. İşte editoryal sürecimiz.

Avatar

Editorial Staff at WPBeginner is a team of WordPress experts led by Syed Balkhi with over 16 years of experience in WordPress, Web Hosting, eCommerce, SEO, and Marketing. Started in 2009, WPBeginner is now the largest free WordPress resource site in the industry and is often referred to as the Wikipedia for WordPress.

Ultimate WordPress Araç Kiti

Araç setimize ÜCRETSİZ erişim sağlayın - her profesyonelin sahip olması gereken WordPress ile ilgili ürün ve kaynaklardan oluşan bir koleksiyon!

Reader Interactions

24 yorumBir Cevap Bırakın

  1. Syed Balkhi

    Hey WPBeginner readers,
    Did you know you can win exciting prizes by commenting on WPBeginner?
    Every month, our top blog commenters will win HUGE rewards, including premium WordPress plugin licenses and cash prizes.
    You can get more details about the contest from here.
    Start sharing your thoughts below to stand a chance to win!

  2. Gwyneth Llewelyn

    Unfortunately, the Peter’s Literal Comments plugin is not active any longer; it has been updated last in 2015, and may not even work on recent versions any more. You might need to recommend a different plugin instead…

    • WPBeginner Support

      Thank you for letting us know that the plugin is not active a the moment. When we look at updating the article we will look for an alternative :)

      Yönetici

  3. KM Shariful

    What html codes I can use in comment box of wordpress site as a visitor?

    • WPBeginner Support

      Hi,

      You can use the following HTML tags in comments by default.

      <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

      Yönetici

  4. San Solanki

    Very well written article, i always follow your blog for all my wordpress problems thnks

  5. Ekesmall

    Is not working here………anyway round??

  6. Sandile Nxumalo

    After all these years, this still works. Thanks

  7. carlo

    Dude, you forgot the closing tag }

  8. anshu

    there are lots of commnts on my every blog post … how to disable HTML hyperlink so that i can prevent my blog post from spam

  9. falvarez

    I think that something is missing. You should add your function plc_comment_display() to the filter stack like this:

    add_filter(‘comment_text’, ‘plc_comment_display’);

    Regards.

  10. johnroypaul

    Brilliant article thanks! Seems to work perfectly well with the latest versions of wordpress as well (3.3) Made the code a lot cleaner as mentioned and seems to have made life easier when trying to implement the comments form into side areas ect. (Had a nightmare with previous use of the normal code)

  11. wordpress hosting

    The more mature you are, the harder at risk you are for getting something undesirable happen to you while overseas. Thanks for revealing your suggestions on this blog.You have good grapes on wordpress thanks for making my problem so easy .

  12. Kamal

    Great, by this way one can ensure that nobody drops links in the comment box. I really hate to see people doing that unnecessarily.

  13. shoaib hussain

    Nice piece of code,but if you happen to use thesis like I am,only needs to check a radio button and the html code vanishes.

    • Editorial Staff

      Yes you are right, but we are not supporting Thesis on this site because it is not compatible with the GPL License.

      Yönetici

  14. Cruz3N

    Its confused me Bro, but i make some simple plugin that allow you to replace with &gt ;

    <?php
    /*
    Plugin Name: Filter Comments
    Plugin URI: http://cruzenaldo.com/plugin-sederhana-filter-komentar/
    Description: Plugin sederhana untuk melakukan filterisasi terhadap komentar dan mencegah user menginput tag – tag HTML
    Author: Cruz3N
    Author URI: http://www.cruzenaldo.com/
    Version: 1.0
    */

    function my_function ($text) {
    $text = str_replace('’, ‘&gt ;’, $text);
    return $text;
    }

    add_filter(‘comment_text’, ‘my_function’);
    ?>

    You can modification that better… Hope usefull

    Download here
    http://www.box.net/shared/rgb4lmt5uy

    And this is my ugly blog :p
    http://cruzenaldo.com/

    Best Regard
    Cruz3N

  15. Infographiste

    Thank you for the useful tuto and easy to follow. I’ve found another one explaining how to disable HTML but was to hard and badly explained, anyway thanks again and have a great week end :)

  16. michelle

    this great and should help to block out loads of spam :) thanks

  17. Ms. Freeman

    This will be of great help from those spam bots that try to leave comments with twenty or so links…LOL:) Thanks

Bir Cevap Bırakın

Yorum bırakmayı seçtiğiniz için teşekkür ederiz. Lütfen tüm yorumların yorum poli̇ti̇kasi uyarınca denetlendiğini ve e-posta adresinizin yayımlanmayacağını unutmayın. Ad alanında anahtar kelime KULLANMAYIN. Kişisel ve anlamlı bir sohbet edelim.