tybruffy / ACF-Reusable-Field-Group

Advanced Custom Fields Plugin to reuse Field Groups
53 stars 16 forks source link

pretty_field_groups() : PHP Notice in conditional statement testing $post #4

Closed mcaskill closed 9 years ago

mcaskill commented 9 years ago

Hi,

Depending on PHP's error reporting level, this will cause a "Trying to get property of non-object" notice:

$current_id = $post->ID ? $post->ID : $_POST["parent"];

On my end, I've fixed it this way:

$current_id = ( isset( $post->ID ) ? $post->ID : $_POST['parent'] );

Although, I'm wondering if empty() would be a better choice:

$current_id = ( empty( $post->ID ) ? $_POST['parent'] : $post->ID );

Cheers!

tybruffy commented 9 years ago

Thanks! I'll take a look at these two things and push a new version up this weekend hopefully.

tybruffy commented 9 years ago

@mcaskill I've updated this in 1.0.2 to be:

$current_id = is_object( $post ) ? $post->ID : $_POST['parent'];

That's working for this on my end, but let me know if it's still causing issues for you.