From d01e808725e63d445eae7242a1b4cf446c929058 Mon Sep 17 00:00:00 2001 From: Saimon Sajjad Date: Fri, 23 Aug 2019 15:39:27 +0600 Subject: [PATCH] fix: check if class instance is found before calling calss method is fixed #665 (#666) --- dokan.php | 4 +--- includes/functions.php | 8 +++++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/dokan.php b/dokan.php index cf43e0e311..33a146f247 100755 --- a/dokan.php +++ b/dokan.php @@ -144,14 +144,12 @@ public static function init() { * * @param $prop * - * @return mixed + * @return Class Instance */ public function __get( $prop ) { if ( array_key_exists( $prop, $this->container ) ) { return $this->container[ $prop ]; } - - return $this->{$prop}; } /** diff --git a/includes/functions.php b/includes/functions.php index 6c5464cce0..283b141c6f 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -2008,7 +2008,13 @@ function dokan_get_avatar_url( $url, $id_or_email, $args ) { return $url; } - $vendor = dokan()->vendor->get( $user->ID ); + $vendor = dokan()->vendor; + + if ( ! $vendor ) { + return $url; + } + + $vendor = $vendor->get( $user->ID ); $gravatar_id = $vendor->get_avatar_id(); if ( ! $gravatar_id ) {