perform test_sort_terms_hierarchicaly( Array &$cats, Array &$into, $parentId = 0 )
{
if ( is_array( $cats ) ) {
foreach ( $cats as $i => $cat ) {
if ( $cat -> mother or father == $parentId ) {
$into[ $cat -> term_id ] = $cat;
unset( $cats[ $i ] );
}
}
}
The above perform checks if the posts iterated have mother or father class set or not so {that a} corresponding checkbox might be constructed with the kid classes under the mother or father class. The primary argument is handed like so,
$phrases = get_terms( $select_taxonomy, array( 'hide_empty' => 0 ) );
$categoryHierarchy = array();
$this -> test_sort_terms_hierarchicaly( $phrases, $categoryHierarchy );
The return kind of get_terms() is an array of objects:
array(4) {
[0]=>
object(WP_Term)#1167 (10) {
["term_id"]=>
int(3)
["name"]=>
string(4) "CAT1"
["slug"]=>
string(4) "cat1"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(3)
["taxonomy"]=>
string(16) "wppg-product-cat"
["description"]=>
string(0) ""
["parent"]=>
int(6)
["count"]=>
int(1)
["filter"]=>
string(3) "uncooked"
}
[1]=>
object(WP_Term)#1166 (10) {
["term_id"]=>
int(4)
["name"]=>
string(4) "CAT2"
["slug"]=>
string(4) "cat2"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(4)
["taxonomy"]=>
string(16) "wppg-product-cat"
["description"]=>
string(0) ""
["parent"]=>
int(6)
["count"]=>
int(1)
["filter"]=>
string(3) "uncooked"
}
[2]=>
object(WP_Term)#1165 (10) {
["term_id"]=>
int(5)
["name"]=>
string(4) "CAT3"
["slug"]=>
string(4) "cat3"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(5)
["taxonomy"]=>
string(16) "wppg-product-cat"
["description"]=>
string(0) ""
["parent"]=>
int(6)
["count"]=>
int(1)
["filter"]=>
string(3) "uncooked"
}
[3]=>
object(WP_Term)#1169 (10) {
["term_id"]=>
int(6)
["name"]=>
string(10) "PARENT_CAT"
["slug"]=>
string(10) "parent_cat"
["term_group"]=>
int(0)
["term_taxonomy_id"]=>
int(6)
["taxonomy"]=>
string(16) "wppg-product-cat"
["description"]=>
string(0) ""
["parent"]=>
int(0)
["count"]=>
int(0)
["filter"]=>
string(3) "uncooked"
}
}
But nonetheless I am getting this e-mail even when the argument handed is an array. What am I doing mistaken right here?
Uncaught TypeError: Argument 1 handed to WPPG_Class::test_sort_terms_hierarchicaly() should be of the sort array, object given