简体   繁体   中英

Undoing a strip_tags in php

I am trying to customize a Word press template and having some trouble. The page is http://rexonmedia.com/?page_id=113 and under each section there are description, all the text in description is plain text(Actionscript, Visit site ...). I want the text to be formatted or have links like the source (http://rexonmedia.com/?portfolio=audiomaya) with hyperlink.

I came to find out that the culprit here is "strip_tags" tags. It's used on two different places. I tried couple of scenarios but didn't work. Please help

   public function customFormat($content,$strip_tags = false,$shortcode=true){
   $content =   stripslashes($content);
   if($shortcode)
   $content = do_shortcode( shortcode_unautop( $content ) ); 
   $content = preg_replace('#^<\/p>|^<br\s?\/?>|<p>$|<p>\s*(&nbsp;)?\s*<\/p>#', '', $content);

   if($strip_tags)
     $content = strip_tags($content,"<hades>,<tabend>");

   return $content;

    }   

<?php  
global $more;    // Declare global $more (before the loop).
    $more = 1;
$content = get_the_content('');
$content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]&gt;', $content);
$this->shortenContent( $content_limit ,  strip_tags( $content  ) ); 
?>

Supply strip_tags with the allowable tags. The line in the first block of code would change to:

$content = strip_tags($content,"<strong><a>");

And the line in the second block of code would change to:

$this->shortenContent( $content_limit ,  strip_tags( $content, "<strong><a>" ) ); 

By the way, the function defines $strip_tags as false in the function definition if it is not supplied. Check that!

public function customFormat($content,$strip_tags = false,$shortcode=true){

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM