I've searched and have had trouble finding an answer.
tl;dr I have a wordpress theme and no longer have support from the creator, and I'm trying to get rid of warning text popping up on the top of some pages. I'm not a programmer so I'm not sure what to do but I do understand code enough to patch in a fix from somewhere else. I need help.
Here's what I get:
Warning: Illegal string offset 'group_no' in file1.php on line 196
Warning: Illegal string offset 'order_no' in file1.php on line 196
Warning: Illegal string offset 'group_no' in file1.php on line 200
Here's the relevant code for file1.php:
function get_location( $location, $post_id )
{
// loaded by PHP already?
if( !empty($location) )
{
return $location;
}
// vars
$groups = array();
$group_no = 0;
// get all rules
$rules = get_post_meta($post_id, 'rule', false);
if( is_array($rules) )
{
foreach( $rules as $rule )
{
// if field group was duplicated, it may now be a serialized string!
$rule = maybe_unserialize($rule);
// does this rule have a group?
// + groups were added in 4.0.4
if( !isset($rule['group_no']) )
{
$rule['group_no'] = $group_no;
// sperate groups?
if( get_post_meta($post_id, 'allorany', true) == 'any' )
{
$group_no++;
}
}
// add to group
$groups[ $rule['group_no'] ][ $rule['order_no'] ] = $rule; // this is line 196
// sort rules
ksort( $groups[ $rule['group_no'] ] );
}
// sort groups
ksort( $groups ); //this is line 200
}
// return fields
return $groups;
}
I understand that this is an array assignment error of some kind but I'm not familiar enough with php to understand what the error is and how to fix it. How would I rebuild this code to make the error go away while preserving function?