Hello,
First of all, thank you for the excellent plugin. It's extremely useful.
While attempting to exclude a MetaBox if a page is the child of another page I encountered the following warning:
Notice: Trying to get property of non-object in /home/ubuntu/app/wp/wp-content/plugins/meta-box-include-exclude/class-mb-include-exclude.php on line 301
This seems to be due to the fact that the $post
object assumes that there will always be a post_id
present. Unfortunately, (as far as I understand) new posts do not have their post_id
set until saving and other areas of the Dashboard do not have post_id
. This results in the notice being displayed.
The following is one possible way to get around this issue, though there are likely other ways to approach a solution:
public static function check_is_child( $value )
{
$post = get_post( self::$post_id );
if ( is_object($post) ){
$is_child = $post->post_parent ? true : false;
return $is_child === $value;
} else {
return false;
}
}