wordpress: cum sa dezactivezi codul HTML din comentarii?

Daca doresti sa dezactivezi codul HTML din comentarii nu trebuie sa instalezi un anumit plugin pentru a face acest lucru.

Tot ce trebuie sa faci este sa adaugi urmatorul cod PHP in fisierul functions.php. Acest fisier il gasesti in template-ul care il folosesti.

[php]
<div id="_mcePaste">// This will occur when the comment is posted</div>
<div id="_mcePaste">function plc_comment_post( $incoming_comment ) {</div>
<div id="_mcePaste">// convert everything in a comment to display literally</div>
<div id="_mcePaste">$incoming_comment[‘comment_content’] = htmlspecialchars($incoming_comment[‘comment_content’]);</div>
<div id="_mcePaste">// the one exception is single quotes, which cannot be #039; because WordPress marks it as spam</div>
<div id="_mcePaste">$incoming_comment[‘comment_content’] = str_replace( "’", ‘&apos;’, $incoming_comment[‘comment_content’] );</div>
<div id="_mcePaste">return( $incoming_comment );</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">// This will occur before a comment is displayed</div>
<div id="_mcePaste">function plc_comment_display( $comment_to_display ) {</div>
<div id="_mcePaste">// Put the single quotes back in</div>
<div id="_mcePaste">$comment_to_display = str_replace( ‘&apos;’, "’", $comment_to_display );</div>
<div id="_mcePaste">return $comment_to_display;</div>
<div id="_mcePaste">}</div>
<div id="_mcePaste">add_filter( ‘preprocess_comment’, ‘plc_comment_post’, ”, 1);</div>
<div id="_mcePaste">add_filter( ‘comment_text’, ‘plc_comment_display’, ”, 1);</div>
<div id="_mcePaste">add_filter( ‘comment_text_rss’, ‘plc_comment_display’, ”, 1);</div>
<div id="_mcePaste">add_filter( ‘comment_excerpt’, ‘plc_comment_display’, ”, 1);</div>
// This will occur when the comment is postedfunction 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 displayedfunction 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;}
add_filter( ‘preprocess_comment’, ‘plc_comment_post’, ”, 1);add_filter( ‘comment_text’, ‘plc_comment_display’, ”, 1);add_filter( ‘comment_text_rss’, ‘plc_comment_display’, ”, 1);add_filter( ‘comment_excerpt’, ‘plc_comment_display’, ”, 1);

[/php]
Update: Imi cer scuze dar in codul PHP se strecurasera niste greseli

2 comentarii

  1. Multumesc pentru pont! A picat foarte bine.
    .-= thor a scris ultimul articol: F.A.Q. =-.

Spune si tu parerea...