base64_decode in wordpress

2

I am trying to save a coded with in the table posts_meta of Wordpress for later get that field, decode it and show the content, but somehow it makes an "escape" of all the quotes so that the Html after being decoded appears like this:

<div class=\"row\">
<div class=\"col-md-4 col-xs-4 col-sm-4 column\">
</div>

How can I solve it or what are the alternatives to the base64_encode function?

    
asked by Infobuscador 08.05.2016 в 13:16
source

2 answers

1

I always try to give priority to native Wordpress methods or functions to avoid problems in the long run.

In the end I solved it by using the function:

  

wp_unslah ()

$html = '
<div class=\"row\">
<div class=\"col-md-4 col-xs-4 col-sm-4 column\">
</div>';

$html = wp_unslash($html)
    
answered by 12.06.2016 / 12:50
source
1

To solve that you could eliminate the \ through the function str_replace() for example;

$a = '<div class=\"col-md-4 col-xs-4 col-sm-4 column\">';
$r = str_replace("\","",$a);

Or you could also use the stripslashes() function for example:

$a = '<div class=\"col-md-4 col-xs-4 col-sm-4 column\">';
stripslashes($a)

to check how they work you can print the html as text by htmlspecialchars()

echo htmlspecialchars($r);
echo htmlspecialchars(stripslashes($a));

In both cases it will print: <div class="col-md-4 col-xs-4 col-sm-4 column">

    
answered by 09.05.2016 в 16:33