Search
Close
AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

AI Assistant
Notifications
Clear all

Support for showing PHP code

2 Posts
2 Users
0 Reactions
3,720 Views
 lph
(@lph)
New Member
Joined: 10 years ago
Posts: 1
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
  [#479]

Many of my members post PHP code snippets wrapped with [PHP].  This tag shows up in the comments with the code. Is there a way to get this to look better?

Screen Shot 2016 05 21 at 1.21.57 PM


   
Quote
 Tom
(@tomson)
Famed Member Admin
Joined: 11 years ago
Posts: 4245
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
 

Hi lph

put this code in your current active theme's function.php file:

function wpdiscuz_display_php($comment){
    $comment = preg_replace_callback('|\[php\](.*?)\[\/php\]|is', 'wpdiscuz_php_code', $comment);
    return $comment;
}
function  wpdiscuz_php_code($match){
    return '<br/><pre><p style="text-align:right;border-bottom:1px solid #ddd; padding:5px 2px; margin:0px; color:#ccc;">| PHP CODE |</p>'.str_replace(array('>', '<'),array('&gt;','&lt;'),$match[1]).'</pre><br/>';
}
add_filter( 'comment_text', 'wpdiscuz_display_php' );


   
ReplyQuote
Share:
Scroll to top