ttillberg/acf-vimeo-pro-data

get_field breaks when video title or descriptions contains double quotes

Closed this issue · 5 comments

psntr commented

As title says, the field doesn't return anything when the video title or its descriptions contains characters like double quotes " in the Vimeo video's settings.

Where does that come from?

I think it has to do with stripslashes corrupting JSON before it gets loaded. Any chance you could take a look what the value looks like before removing the slashes ? Also could you check if you have magic_quotes activated ?

psntr commented

Thank you for the reply.

So I'm not sure how to check the value before removing slashes. Because if I simply do that, nothing come out.

// Vimeo ACF
  $video_vimeo = get_field('featured_video', $post_id);
  print_r($video_vimeo);

On my server the magic_quotes are deprecated? Is it normal?

psntr commented

With a var_dump($vimeo_video) only NULL is shown

Sorry I wasn't clear at all. I meant inside the actual plugin code:

https://github.com/ttillberg/acf-vimeo-pro-data/blob/master/fields/acf-vimeo_pro_data-v5.php#L413

can you try:

  1. $json = stripslashes($value);
  2. $json = $value;
  3. $json = json_decode($value);

I'll check on my side too. But my guess is that it has something to do with magic_quotes

psntr commented

Thank you for the clarification! By replacing:
$json = json_decode(stripslashes($value));
to
$json = json_decode($value); in your code it worked!

I guess I can close this issue. Thank you again!