I’m getting this error in WordPress and I don’t know what it’s asking. Here is the code starting on line 436.
if (count($this->keys) && $this->action == 'add') {
// Extract the last key
$last = $this->keys[count($this->keys) - 1];
// Are we trying to add stuff?
if ($last == $this->add_key) {
$this->data = $this->set_data($this->default, $this->keys);
}
}
Its in a plug in called ‘more fields. Its updated.
I don’t know what to try. PHP isn’t my forte.
2
Answers
Well, ChatGPT pointed out that
Might not be an array in some contexts. I would have never guessed that, but PHP isn't my forte. ChatGPT suggested checking to see if it was an array before implementing.
The fix:
}
Looks to be working and implemented well with the old plug in. If there is anything anyone else would like to point out, I'm all ears and willing to learn. Thank you.
Arrays, Generators, Objects (with public properties) and Iterators are implementing the Countable Interface.
If it is not one of those types you will get this error.
To fix this error you can check if it is countable.