src/WordpressApiClient.php
/**
     * recursive function to add ancestors info to list of categories- this is also necessary for generating succesors info later
     *
     * @param $sortedCategories
     * @param $id
     *
     * @return array
     */
recursive function to add ancestors info to list of categories- this is also necessary for generating succesors info later
@param $sortedCategories
@param $id

@return array
recursive function to add ancestors info to list of categories - this is also necessary for generating succesors info later @param $sortedCategories @param $id @return array
private function recursiveFindPathAndAncestors($sortedCategories, $id)
    {
        if (empty($sortedCategories[$id]['ancestors']) === false) {
            return $sortedCategories[$id]['ancestors'];
        } else {
            if ($sortedCategories[$id]['parent'] === null) {
                return [];
            } else {
                $recursiveAnswer = $this->recursiveFindPathAndAncestors($sortedCategories, $sortedCategories[$id]['parent']);
                $recursiveAnswer[] = $sortedCategories[$id]['parent'];
                return $recursiveAnswer;
            }
        }
    }
private function recursiveFindPathAndAncestors ( $ sortedCategories , $ id ) { if ( empty ( $ sortedCategories [ $ id ] [ 'ancestors' ] ) === false ) { return $ sortedCategories [ $ id ] [ 'ancestors' ] ; } else { if ( $ sortedCategories [ $ id ] [ 'parent' ] === null ) { return [ ] ; } else { $ recursiveAnswer = $ this -> recursiveFindPathAndAncestors ( $ sortedCategories , $ sortedCategories [ $ id ] [ 'parent' ] ) ; $ recursiveAnswer [ ] = $ sortedCategories [ $ id ] [ 'parent' ] ; return $ recursiveAnswer ; } } }
recursive function to add ancestors info to list of categories- this is also necessary for generating succesors info later
 @param $sortedCategories
 @param $id
recursive function to add ancestors info to list of categories - this is also necessary for generating succesors info later @param $sortedCategories @param $id